feature: Phase 2- splitting the treatment schema into TreatmentDetail and LabCase.
This commit is contained in:
@@ -19,7 +19,10 @@ import { memoryStorage } from 'multer';
|
||||
import type { Response } from 'express';
|
||||
import { ClinicOrgGuard } from '../../common/guards/clinic-org.guard';
|
||||
import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard';
|
||||
import { SaveTreatmentDraftDto, SendTreatmentCaseDto } from './dto/treatment.dto';
|
||||
import {
|
||||
SaveTreatmentDraftDto,
|
||||
SaveTreatmentLabCasesDto,
|
||||
} from './dto/treatment.dto';
|
||||
import { TreatmentsService } from './treatments.service';
|
||||
|
||||
@ApiTags('treatments')
|
||||
@@ -67,7 +70,7 @@ export class TreatmentsController {
|
||||
}
|
||||
|
||||
@Put('appointments/:appointmentId/draft')
|
||||
@ApiOperation({ summary: 'Save draft treatment for an appointment (TAB_TREATMENT_EDIT)' })
|
||||
@ApiOperation({ summary: 'Save draft treatment details for an appointment (TAB_TREATMENT_EDIT)' })
|
||||
saveDraft(
|
||||
@Param('appointmentId') appointmentId: string,
|
||||
@Body() dto: SaveTreatmentDraftDto,
|
||||
@@ -82,8 +85,24 @@ export class TreatmentsController {
|
||||
);
|
||||
}
|
||||
|
||||
@Post('appointments/:appointmentId/cases/:caseClientKey/attachments')
|
||||
@ApiOperation({ summary: 'Upload attachments for a draft case (TAB_TREATMENT_EDIT)' })
|
||||
@Put('appointments/:appointmentId/lab-cases')
|
||||
@ApiOperation({ summary: 'Save lab case groupings for a draft treatment (TAB_TREATMENT_EDIT)' })
|
||||
saveLabCases(
|
||||
@Param('appointmentId') appointmentId: string,
|
||||
@Body() dto: SaveTreatmentLabCasesDto,
|
||||
@Req() req: { user: { id: string; organizationId?: string } },
|
||||
) {
|
||||
const organizationId = this.treatmentsService.getOrganizationIdFromUser(req.user);
|
||||
return this.treatmentsService.saveLabCasesForAppointment(
|
||||
appointmentId,
|
||||
dto,
|
||||
organizationId,
|
||||
req.user.id,
|
||||
);
|
||||
}
|
||||
|
||||
@Post('appointments/:appointmentId/details/:detailClientKey/attachments')
|
||||
@ApiOperation({ summary: 'Upload attachments for a draft treatment detail (TAB_TREATMENT_EDIT)' })
|
||||
@ApiConsumes('multipart/form-data')
|
||||
@ApiBody({
|
||||
schema: {
|
||||
@@ -101,14 +120,39 @@ export class TreatmentsController {
|
||||
storage: memoryStorage(),
|
||||
}),
|
||||
)
|
||||
uploadAttachments(
|
||||
uploadDetailAttachments(
|
||||
@Param('appointmentId') appointmentId: string,
|
||||
@Param('detailClientKey') detailClientKey: string,
|
||||
@UploadedFiles() files: Express.Multer.File[],
|
||||
@Req() req: { user: { id: string; organizationId?: string } },
|
||||
) {
|
||||
const organizationId = this.treatmentsService.getOrganizationIdFromUser(req.user);
|
||||
return this.treatmentsService.uploadDetailAttachments(
|
||||
appointmentId,
|
||||
detailClientKey,
|
||||
files,
|
||||
organizationId,
|
||||
req.user.id,
|
||||
);
|
||||
}
|
||||
|
||||
/** @deprecated Use details/:detailClientKey/attachments */
|
||||
@Post('appointments/:appointmentId/cases/:caseClientKey/attachments')
|
||||
@ApiOperation({ summary: 'Legacy alias for detail attachment upload' })
|
||||
@ApiConsumes('multipart/form-data')
|
||||
@UseInterceptors(
|
||||
FilesInterceptor('files', 20, {
|
||||
storage: memoryStorage(),
|
||||
}),
|
||||
)
|
||||
uploadDetailAttachmentsLegacy(
|
||||
@Param('appointmentId') appointmentId: string,
|
||||
@Param('caseClientKey') caseClientKey: string,
|
||||
@UploadedFiles() files: Express.Multer.File[],
|
||||
@Req() req: { user: { id: string; organizationId?: string } },
|
||||
) {
|
||||
const organizationId = this.treatmentsService.getOrganizationIdFromUser(req.user);
|
||||
return this.treatmentsService.uploadCaseAttachments(
|
||||
return this.treatmentsService.uploadDetailAttachments(
|
||||
appointmentId,
|
||||
caseClientKey,
|
||||
files,
|
||||
@@ -136,14 +180,13 @@ export class TreatmentsController {
|
||||
file.stream.pipe(res);
|
||||
}
|
||||
|
||||
@Post('cases/:caseId/send')
|
||||
@ApiOperation({ summary: 'Send a treatment case to linked organizations (TAB_TREATMENT_EDIT)' })
|
||||
sendCase(
|
||||
@Param('caseId') caseId: string,
|
||||
@Body() dto: SendTreatmentCaseDto,
|
||||
@Post('lab-cases/:labCaseId/send')
|
||||
@ApiOperation({ summary: 'Send a lab case to its destination organization (TAB_TREATMENT_EDIT)' })
|
||||
sendLabCase(
|
||||
@Param('labCaseId') labCaseId: string,
|
||||
@Req() req: { user: { id: string; organizationId?: string } },
|
||||
) {
|
||||
const organizationId = this.treatmentsService.getOrganizationIdFromUser(req.user);
|
||||
return this.treatmentsService.sendCase(caseId, dto, organizationId, req.user.id);
|
||||
return this.treatmentsService.sendLabCase(labCaseId, organizationId, req.user.id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user