improvement: users can now comment on a case and it's details and have an option to make it visible for clinics too.
This commit is contained in:
@@ -71,11 +71,6 @@ export class SaveLabCaseDto {
|
||||
@IsUUID()
|
||||
destinationOrganizationId?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@MaxLength(5000)
|
||||
labComment?: string;
|
||||
|
||||
@IsArray()
|
||||
@ArrayMinSize(1)
|
||||
@IsUUID(undefined, { each: true })
|
||||
|
||||
@@ -23,6 +23,8 @@ import {
|
||||
SaveTreatmentDraftDto,
|
||||
SaveTreatmentLabCasesDto,
|
||||
} from './dto/treatment.dto';
|
||||
import { CreateLabCaseCommentDto } from '../lab-case-comments/dto/lab-case-comment.dto';
|
||||
import { LabCaseCommentsService } from '../lab-case-comments/lab-case-comments.service';
|
||||
import { TreatmentsService } from './treatments.service';
|
||||
|
||||
@ApiTags('treatments')
|
||||
@@ -30,7 +32,10 @@ import { TreatmentsService } from './treatments.service';
|
||||
@UseGuards(JwtAuthGuard, ClinicOrgGuard)
|
||||
@Controller('treatments')
|
||||
export class TreatmentsController {
|
||||
constructor(private readonly treatmentsService: TreatmentsService) {}
|
||||
constructor(
|
||||
private readonly treatmentsService: TreatmentsService,
|
||||
private readonly commentsService: LabCaseCommentsService,
|
||||
) {}
|
||||
|
||||
@Get('linked-organizations')
|
||||
@ApiOperation({ summary: 'List active linked counterpart organizations (TAB_TREATMENT_READ)' })
|
||||
@@ -194,4 +199,34 @@ export class TreatmentsController {
|
||||
req.user.language,
|
||||
);
|
||||
}
|
||||
|
||||
@Get('lab-cases/:labCaseId/comments')
|
||||
@ApiOperation({ summary: 'List comments for a lab case during treatment dispatch' })
|
||||
listLabCaseComments(
|
||||
@Param('labCaseId') labCaseId: string,
|
||||
@Req() req: { user: { id: string; organizationId?: string } },
|
||||
) {
|
||||
const organizationId = this.treatmentsService.getOrganizationIdFromUser(req.user);
|
||||
return this.commentsService.listForClinicTreatmentCase(
|
||||
labCaseId,
|
||||
organizationId,
|
||||
req.user.id,
|
||||
);
|
||||
}
|
||||
|
||||
@Post('lab-cases/:labCaseId/comments')
|
||||
@ApiOperation({ summary: 'Add a comment to a lab case during treatment dispatch' })
|
||||
addLabCaseComment(
|
||||
@Param('labCaseId') labCaseId: string,
|
||||
@Body() dto: CreateLabCaseCommentDto,
|
||||
@Req() req: { user: { id: string; organizationId?: string } },
|
||||
) {
|
||||
const organizationId = this.treatmentsService.getOrganizationIdFromUser(req.user);
|
||||
return this.commentsService.addForClinicTreatmentCase(
|
||||
labCaseId,
|
||||
organizationId,
|
||||
req.user.id,
|
||||
dto,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,12 @@ import { Module } from '@nestjs/common';
|
||||
import { PrismaService } from '../../../prisma/prisma.service';
|
||||
import { ClinicOrgGuard } from '../../common/guards/clinic-org.guard';
|
||||
import { ProsthesisCatalogModule } from '../prosthesis-catalog/prosthesis-catalog.module';
|
||||
import { LabCaseCommentsModule } from '../lab-case-comments/lab-case-comments.module';
|
||||
import { TreatmentsController } from './treatments.controller';
|
||||
import { TreatmentsService } from './treatments.service';
|
||||
|
||||
@Module({
|
||||
imports: [ProsthesisCatalogModule],
|
||||
imports: [ProsthesisCatalogModule, LabCaseCommentsModule],
|
||||
controllers: [TreatmentsController],
|
||||
providers: [TreatmentsService, PrismaService, ClinicOrgGuard],
|
||||
})
|
||||
|
||||
@@ -397,7 +397,6 @@ export class TreatmentsService {
|
||||
clientKey: lc.clientId,
|
||||
sortOrder: index,
|
||||
destinationOrganizationId: lc.destinationOrganizationId ?? null,
|
||||
labComment: lc.labComment?.trim() || null,
|
||||
},
|
||||
})
|
||||
: await tx.labCase.create({
|
||||
@@ -406,7 +405,6 @@ export class TreatmentsService {
|
||||
clientKey: lc.clientId,
|
||||
sortOrder: index,
|
||||
destinationOrganizationId: lc.destinationOrganizationId ?? null,
|
||||
labComment: lc.labComment?.trim() || null,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -675,7 +673,6 @@ export class TreatmentsService {
|
||||
clientKey: string | null;
|
||||
sortOrder: number;
|
||||
destinationOrganizationId: string | null;
|
||||
labComment: string | null;
|
||||
sentAt: Date | null;
|
||||
details: Array<{
|
||||
treatmentDetailId: string;
|
||||
@@ -754,7 +751,6 @@ export class TreatmentsService {
|
||||
clientKey?: string | null;
|
||||
sortOrder?: number;
|
||||
destinationOrganizationId?: string | null;
|
||||
labComment?: string | null;
|
||||
sentAt?: Date | null;
|
||||
details?: Array<{
|
||||
treatmentDetailId: string;
|
||||
@@ -775,7 +771,6 @@ export class TreatmentsService {
|
||||
id: lc.id,
|
||||
clientId: lc.clientKey ?? lc.id,
|
||||
destinationOrganizationId: lc.destinationOrganizationId ?? null,
|
||||
labComment: lc.labComment ?? null,
|
||||
sentAt: lc.sentAt?.toISOString() ?? null,
|
||||
treatmentDetailIds: lc.details?.map((d) => d.treatmentDetailId) ?? [],
|
||||
details: (lc.details ?? []).map((d) => ({
|
||||
|
||||
Reference in New Issue
Block a user