improvement: Nothing done is related to subscriptions!!!
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user