improvement: treatment preview and treatment history components overhauled. draft & completed status for treatment plan completely removed from the flow.

This commit is contained in:
2026-06-28 21:45:33 +03:30
parent 94b97aa0fa
commit feb0b26ad0
20 changed files with 571 additions and 608 deletions

View File

@@ -0,0 +1,8 @@
-- DropIndex
DROP INDEX IF EXISTS "treatments_organizationId_status_idx";
-- AlterTable
ALTER TABLE "treatments" DROP COLUMN "status";
-- DropEnum
DROP TYPE "TreatmentStatus";

View File

@@ -114,11 +114,6 @@ model Appointment {
@@map("appointments")
}
enum TreatmentStatus {
DRAFT
COMPLETED
}
enum LabTaskStatus {
PENDING
IN_PROGRESS
@@ -126,13 +121,12 @@ enum LabTaskStatus {
}
model Treatment {
id String @id @default(uuid())
id String @id @default(uuid())
organizationId String
patientId String
appointmentId String? @unique
appointmentId String? @unique
providerUserId String
title String
status TreatmentStatus @default(DRAFT)
treatmentAt DateTime
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
@@ -145,7 +139,6 @@ model Treatment {
updatedAt DateTime @updatedAt
@@index([patientId, treatmentAt])
@@index([organizationId, status])
@@map("treatments")
}

View File

@@ -1,5 +1,3 @@
import { TreatmentStatus } from '@prisma/client';
const FDI_TOOTH_IDS = new Set([
'11', '12', '13', '14', '15', '16', '17', '18',
'21', '22', '23', '24', '25', '26', '27', '28',
@@ -39,7 +37,3 @@ export function generateTreatmentTitle(
return parts.join(' · ');
}
export function mapTreatmentStatusForApi(status: TreatmentStatus): string {
return status === TreatmentStatus.DRAFT ? 'draft' : 'completed';
}

View File

@@ -40,7 +40,7 @@ export class TreatmentsController {
}
@Get('patients/:patientId/history')
@ApiOperation({ summary: 'List completed treatments for a patient (TAB_TREATMENT_READ)' })
@ApiOperation({ summary: 'List treatments for a patient (draft and completed, TAB_TREATMENT_READ)' })
listPatientHistory(
@Param('patientId') patientId: string,
@Query('limit', new ParseIntPipe({ optional: true })) limit = 20,

View File

@@ -4,7 +4,7 @@ import {
Injectable,
NotFoundException,
} from '@nestjs/common';
import { LinkStatus, TreatmentStatus } from '@prisma/client';
import { LinkStatus } from '@prisma/client';
import { createReadStream, existsSync, mkdirSync } from 'fs';
import { join } from 'path';
import { randomUUID } from 'crypto';
@@ -17,7 +17,6 @@ import {
} from './dto/treatment.dto';
import {
generateTreatmentTitle,
mapTreatmentStatusForApi,
normalizeTeeth,
} from './treatment.utils';
@@ -117,7 +116,7 @@ export class TreatmentsService {
where: {
patientId,
organizationId,
status: TreatmentStatus.COMPLETED,
details: { some: {} },
},
include: treatmentInclude,
orderBy: [{ treatmentAt: 'desc' }],
@@ -144,7 +143,6 @@ export class TreatmentsService {
where: {
appointmentId: appointment.id,
organizationId,
status: TreatmentStatus.DRAFT,
},
include: treatmentInclude,
});
@@ -196,7 +194,6 @@ export class TreatmentsService {
treatmentAt: appointment.startAt,
patientId: appointment.patientId,
providerUserId: appointment.providerUserId,
status: TreatmentStatus.DRAFT,
},
})
: await tx.treatment.create({
@@ -206,7 +203,6 @@ export class TreatmentsService {
appointmentId: appointment.id,
providerUserId: appointment.providerUserId,
title,
status: TreatmentStatus.DRAFT,
treatmentAt: appointment.startAt,
},
});
@@ -314,7 +310,7 @@ export class TreatmentsService {
);
const treatment = await this.prisma.treatment.findFirst({
where: { appointmentId: appointment.id, organizationId, status: TreatmentStatus.DRAFT },
where: { appointmentId: appointment.id, organizationId },
select: { id: true },
});
@@ -605,7 +601,6 @@ export class TreatmentsService {
patientId: string;
appointmentId: string | null;
title: string;
status: TreatmentStatus;
treatmentAt: Date;
details: Array<{
id: string;
@@ -660,7 +655,6 @@ export class TreatmentsService {
appointmentId: treatment.appointmentId,
title: treatment.title,
treatmentAt: treatment.treatmentAt.toISOString(),
status: mapTreatmentStatusForApi(treatment.status),
details: treatment.details.map((d) => this.mapDetail(d)),
labCases: treatment.labCases.map((lc) => this.mapLabCase(lc)),
documents,