improvement: delete action added for unsent treatment details. some edit controls added to details and shipments.

This commit is contained in:
2026-07-16 22:45:37 +03:30
parent 334b7841ae
commit cf07b4d8a8
7 changed files with 82 additions and 1 deletions

View File

@@ -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;

View File

@@ -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 });