improvement: appointment dialog UX improved.

This commit is contained in:
2026-07-12 22:07:11 +03:30
parent 53b43f2cdb
commit abf0371a5b
18 changed files with 1006 additions and 759 deletions

View File

@@ -104,11 +104,18 @@ export class AppointmentsService {
patient: {
select: { id: true, firstName: true, lastName: true, mobile: true },
},
treatment: { select: { id: true } },
},
orderBy: [{ startAt: 'asc' }],
});
return { success: true, data: items };
return {
success: true,
data: items.map(({ treatment, ...appointment }) => ({
...appointment,
hasTreatment: Boolean(treatment),
})),
};
}
async create(
@@ -202,6 +209,18 @@ export class AppointmentsService {
const providerUserId = dto.providerUserId ?? existing.providerUserId;
const purpose = dto.purpose ?? existing.purpose;
if (dto.patientId && dto.patientId !== existing.patientId) {
const linkedTreatment = await this.prisma.treatment.findUnique({
where: { appointmentId: id },
select: { id: true },
});
if (linkedTreatment) {
throw new BadRequestException(
'Cannot change the patient while a treatment is linked to this appointment',
);
}
}
this.treatmentCatalog.assertKnownTreatmentType(purpose);
await this.ensurePatientInOrg(patientId, organizationId);