Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 60 additions & 1 deletion src/app/app-modules/nurse-doctor/workarea/workarea.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2122,6 +2122,34 @@ export class WorkareaComponent
}
}
}

// Ensure doctor has added at least one prescription
if (this.attendant === 'doctor') {
try {
const drugPrescriptionForm = <FormGroup>(
(caseRecordForm && caseRecordForm.controls
? caseRecordForm.controls['drugPrescriptionForm']
: null)
);
if (drugPrescriptionForm) {
let prescribedDrugs =
drugPrescriptionForm.value &&
drugPrescriptionForm.value.prescribedDrugs
? drugPrescriptionForm.value.prescribedDrugs
: [];
prescribedDrugs = prescribedDrugs.filter((d: any) => !!d.createdBy);
if (!prescribedDrugs || prescribedDrugs.length === 0) {
required.push(
this.current_language_set?.Prescription?.prescriptionRequired ||
'Please add at least one prescription',
);
}
}
} catch (err) {
console.warn('Error validating prescription presence', err);
}
}

if (required.length) {
this.confirmationService.notify(
this.current_language_set.alerts.info.belowFields,
Expand Down Expand Up @@ -2231,7 +2259,7 @@ export class WorkareaComponent
!this.schedulerData
)
required.push(this.current_language_set.nurseData.scheduleTM);

if (required.length) {
this.confirmationService.notify(
this.current_language_set.alerts.info.belowFields,
Expand Down Expand Up @@ -2680,6 +2708,37 @@ export class WorkareaComponent
}
}

// For quick consult doctor flow, ensure at least one prescription exists
if (this.attendant === 'doctor') {
try {
const caseRecordForm = <FormGroup>(
this.patientMedicalForm.controls['patientCaseRecordForm']
);
const prescription =
caseRecordForm && caseRecordForm.controls
? caseRecordForm.controls['drugPrescriptionForm']
: null;
if (prescription) {
let prescribedDrugs =
prescription.value && prescription.value.prescribedDrugs
? prescription.value.prescribedDrugs
: [];
prescribedDrugs = prescribedDrugs.filter((d: any) => !!d.createdBy);
if (!prescribedDrugs || prescribedDrugs.length === 0) {
required.push(
this.current_language_set?.Prescription?.prescriptionRequired ||
'Please add at least one prescription',
);
}
}
} catch (err) {
console.warn(
'Error validating quick consult prescription presence',
err,
);
}
}

if (required.length) {
this.confirmationService.notify(
this.current_language_set.alerts.info.belowFields,
Expand Down