Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
}
}

checkNurseRequirements(medicalForm: any, host: WorkareaValidationHost) {

Check failure on line 77 in src/app/app-modules/nurse-doctor/workarea/workarea-validation.service.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this function to reduce its Cognitive Complexity from 216 to the 15 allowed.

See more on https://sonarcloud.io/project/issues?id=PSMRI_MMU-UI-NEXT&issues=AaCPjgArhiA4T0pbwO8V&open=AaCPjgArhiA4T0pbwO8V&pullRequest=477
const vitalsForm = <FormGroup>medicalForm.controls['patientVitalsForm'];
const examinationForm = <FormGroup>(
host.patientMedicalForm.controls['patientExaminationForm']
Expand Down Expand Up @@ -572,8 +572,35 @@
}
}

// Note: the original app does NOT require a prescription on doctor submit,
// so no "at least one prescription" check is added here (kept faithful).
// Ensure the doctor has added at least one prescription before submit.
if (host.attendantType === 'doctor') {
try {
const caseRecordForm = <FormGroup>(
medicalForm.controls['patientCaseRecordForm']
);
const drugPrescriptionForm = <FormGroup>(
(caseRecordForm && caseRecordForm.controls

Check warning on line 582 in src/app/app-modules/nurse-doctor/workarea/workarea-validation.service.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Prefer using an optional chain expression instead, as it's more concise and easier to read.

See more on https://sonarcloud.io/project/issues?id=PSMRI_MMU-UI-NEXT&issues=AaCPjgArhiA4T0pbwO8W&open=AaCPjgArhiA4T0pbwO8W&pullRequest=477
? caseRecordForm.controls['drugPrescriptionForm']
: null)
);
if (drugPrescriptionForm) {
let prescribedDrugs =
drugPrescriptionForm.value &&
drugPrescriptionForm.value.prescribedDrugs

Check warning on line 589 in src/app/app-modules/nurse-doctor/workarea/workarea-validation.service.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Prefer using an optional chain expression instead, as it's more concise and easier to read.

See more on https://sonarcloud.io/project/issues?id=PSMRI_MMU-UI-NEXT&issues=AaCPjgArhiA4T0pbwO8X&open=AaCPjgArhiA4T0pbwO8X&pullRequest=477
? drugPrescriptionForm.value.prescribedDrugs
: [];
prescribedDrugs = prescribedDrugs.filter((d: any) => !!d.createdBy);
if (!prescribedDrugs || prescribedDrugs.length === 0) {
required.push(
host.currentLanguageSet?.Prescription?.prescriptionRequired ||
'Please add at least one prescription'
);
}
}
} catch (err) {
console.warn('Error validating prescription presence', err);
}
}

if (required.length) {
host.confirmationService.notify(
Expand Down Expand Up @@ -984,7 +1011,7 @@
}
}

checkQuickConsultDoctorData(

Check failure on line 1014 in src/app/app-modules/nurse-doctor/workarea/workarea-validation.service.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this function to reduce its Cognitive Complexity from 46 to the 15 allowed.

See more on https://sonarcloud.io/project/issues?id=PSMRI_MMU-UI-NEXT&issues=AaCPjgArhiA4T0pbwO8Y&open=AaCPjgArhiA4T0pbwO8Y&pullRequest=477
patientMedicalForm: any,
host: WorkareaValidationHost
) {
Expand Down Expand Up @@ -1068,8 +1095,36 @@
}
}

// Note: the original app does NOT require a prescription on submit (quick
// consult doctor flow included), so no such check is added here.
// Quick consult doctor flow: ensure at least one prescription exists.
if (host.attendantType === 'doctor') {
try {
const quickConsultCaseRecordForm = <FormGroup>(
host.patientMedicalForm.controls['patientCaseRecordForm']
);
const prescription =
quickConsultCaseRecordForm && quickConsultCaseRecordForm.controls

Check warning on line 1105 in src/app/app-modules/nurse-doctor/workarea/workarea-validation.service.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Prefer using an optional chain expression instead, as it's more concise and easier to read.

See more on https://sonarcloud.io/project/issues?id=PSMRI_MMU-UI-NEXT&issues=AaCPjgArhiA4T0pbwO8Z&open=AaCPjgArhiA4T0pbwO8Z&pullRequest=477
? quickConsultCaseRecordForm.controls['drugPrescriptionForm']
: null;
if (prescription) {
let prescribedDrugs =
prescription.value && prescription.value.prescribedDrugs

Check warning on line 1110 in src/app/app-modules/nurse-doctor/workarea/workarea-validation.service.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Prefer using an optional chain expression instead, as it's more concise and easier to read.

See more on https://sonarcloud.io/project/issues?id=PSMRI_MMU-UI-NEXT&issues=AaCPjgArhiA4T0pbwO8a&open=AaCPjgArhiA4T0pbwO8a&pullRequest=477
? prescription.value.prescribedDrugs
: [];
prescribedDrugs = prescribedDrugs.filter((d: any) => !!d.createdBy);
if (!prescribedDrugs || prescribedDrugs.length === 0) {
required.push(
host.currentLanguageSet?.Prescription?.prescriptionRequired ||
'Please add at least one prescription'
);
}
}
} catch (err) {
console.warn(
'Error validating quick consult prescription presence',
err
);
}
}

if (required.length) {
host.confirmationService.notify(
Expand Down