improvement: delete action added for unsent treatment details. some edit controls added to details and shipments.
This commit is contained in:
@@ -64,6 +64,7 @@ export const ErrorCode = {
|
||||
CONFLICT_FUTURE_APPOINTMENTS: 'CONFLICT_FUTURE_APPOINTMENTS',
|
||||
APPOINTMENT_PATIENT_LOCKED: 'APPOINTMENT_PATIENT_LOCKED',
|
||||
APPOINTMENT_HAS_TREATMENT: 'APPOINTMENT_HAS_TREATMENT',
|
||||
TREATMENT_DETAIL_SENT: 'TREATMENT_DETAIL_SENT',
|
||||
BAD_REQUEST: 'BAD_REQUEST',
|
||||
INTERNAL_ERROR: 'INTERNAL_ERROR',
|
||||
} as const;
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import {
|
||||
BadRequestException,
|
||||
ForbiddenException,
|
||||
HttpStatus,
|
||||
Injectable,
|
||||
NotFoundException,
|
||||
} from '@nestjs/common';
|
||||
import { AppException, ErrorCode } from '../../common/errors';
|
||||
import { LabCaseActivityType, LabTaskStatus, LinkStatus, Prisma } from '@prisma/client';
|
||||
import { createReadStream, existsSync, mkdirSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
@@ -908,6 +910,25 @@ export class TreatmentsService {
|
||||
throw new BadRequestException('At least one file is required');
|
||||
}
|
||||
|
||||
const existingDetail = await this.prisma.treatmentDetail.findFirst({
|
||||
where: {
|
||||
clientKey: detailClientKey,
|
||||
treatment: {
|
||||
appointmentId,
|
||||
organizationId,
|
||||
...treatmentProviderScopeWhere(actorUserId),
|
||||
},
|
||||
},
|
||||
select: {
|
||||
labCaseLink: {
|
||||
select: { labCase: { select: { sentAt: true } } },
|
||||
},
|
||||
},
|
||||
});
|
||||
if (existingDetail?.labCaseLink?.labCase.sentAt) {
|
||||
throw new AppException(ErrorCode.TREATMENT_DETAIL_SENT, HttpStatus.CONFLICT);
|
||||
}
|
||||
|
||||
const orgDir = join(this.uploadRoot, organizationId);
|
||||
mkdirSync(orgDir, { recursive: true });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user