improvement: Nothing done is related to subscriptions!!!

This commit is contained in:
2026-09-05 20:44:16 +03:30
parent 5cd3436d0c
commit 1ca8e6178e
13 changed files with 431 additions and 57 deletions

View File

@@ -222,14 +222,7 @@ export class TreatmentsService {
const sentinel = await ensureWalkInPatient(this.prisma, organizationId);
patientId = sentinel.id;
} else {
await this.ensurePatientExists(dto.patientId!);
const patient = await this.prisma.patient.findUnique({
where: { id: dto.patientId! },
select: { isWalkIn: true },
});
if (patient?.isWalkIn) {
throw new AppException(ErrorCode.TREATMENT_PATIENT_OR_WALK_IN, HttpStatus.BAD_REQUEST);
}
await this.ensurePatientInOrg(dto.patientId!, organizationId);
patientId = dto.patientId!;
}
@@ -1670,6 +1663,20 @@ export class TreatmentsService {
}
}
private async ensurePatientInOrg(patientId: string, organizationId: string) {
const patient = await this.prisma.patient.findFirst({
where: {
id: patientId,
isWalkIn: false,
createdByOrganizationId: organizationId,
},
select: { id: true },
});
if (!patient) {
throw new AppException(ErrorCode.PATIENT_NOT_FOUND, HttpStatus.NOT_FOUND);
}
}
private async ensureTreatmentProvider(
treatmentId: string,
organizationId: string,