Skip to content
Merged
Show file tree
Hide file tree
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 @@ -13,6 +13,7 @@
(keyup.enter)="preventSubmitOnEnter($event)"
>
<mat-horizontal-stepper
#stepper
linear="false"
(selectionChange)="updatePending($event)"
>
Expand Down
96 changes: 73 additions & 23 deletions src/app/app-modules/nurse-doctor/workarea/workarea.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import { SetLanguageComponent } from '../../core/components/set-language.compone
import { SpecialistLoginComponent } from '../../core/components/specialist-login/specialist-login.component';
import { HttpServiceService } from '../../core/services/http-service.service';
import { MatDialog, MatDialogRef } from '@angular/material/dialog';
import { MatStepper } from '@angular/material/stepper';
import { SessionStorageService } from 'Common-UI/src/registrar/services/session-storage.service';
import { HealthIdDisplayModalComponent } from 'Common-UI/src/registrar/abha-components/health-id-display-modal/health-id-display-modal.component';
import { RegistrarService } from 'Common-UI/src/registrar/services/registrar.service';
Expand All @@ -81,6 +82,9 @@ export class WorkareaComponent
@ViewChild('sidenav')
sidenav: any;

@ViewChild('stepper')
stepper!: MatStepper;

visitMode: any;
ancMode: any;
pncMode: any;
Expand Down Expand Up @@ -2374,7 +2378,7 @@ export class WorkareaComponent
const diagForm3 = <FormGroup>diagForm2.controls[0];
if (diagForm3.controls['viewProvisionalDiagnosisProvided'].errors) {
required.push(
this.current_language_set.DiagnosisDetails.provisionaldiagnosis,
`${this.current_language_set?.common?.caseRecord ?? 'Case Record'}: ${this.current_language_set.DiagnosisDetails.provisionaldiagnosis}`,
);
}

Expand All @@ -2387,8 +2391,7 @@ export class WorkareaComponent
item.conceptID === '')
)
required.push(
this.current_language_set
.pleaseSelectprovisionalDiagnosisWithSnomedCode,
`${this.current_language_set?.common?.caseRecord ?? 'Case Record'}: ${this.current_language_set.pleaseSelectprovisionalDiagnosisWithSnomedCode}`,
);
});
}
Expand Down Expand Up @@ -2498,7 +2501,7 @@ export class WorkareaComponent

if (diagForm3.controls['viewProvisionalDiagnosisProvided'].errors) {
required.push(
this.current_language_set.DiagnosisDetails.provisionaldiagnosis,
`${this.current_language_set?.common?.caseRecord ?? 'Case Record'}: ${this.current_language_set.DiagnosisDetails.provisionaldiagnosis}`,
);
}

Expand All @@ -2511,8 +2514,7 @@ export class WorkareaComponent
item.conceptID === '')
)
required.push(
this.current_language_set
.pleaseSelectprovisionalDiagnosisWithSnomedCode,
`${this.current_language_set?.common?.caseRecord ?? 'Case Record'}: ${this.current_language_set.pleaseSelectprovisionalDiagnosisWithSnomedCode}`,
);
});
}
Expand All @@ -2536,8 +2538,7 @@ export class WorkareaComponent
item.conceptID === '')
)
required.push(
this.current_language_set
.pleaseSelectprovisionalDiagnosisWithSnomedCode,
`${this.current_language_set?.common?.caseRecord ?? 'Case Record'}: ${this.current_language_set.pleaseSelectprovisionalDiagnosisWithSnomedCode}`,
);
});
}
Expand All @@ -2553,7 +2554,7 @@ export class WorkareaComponent
const diagForm3 = <FormGroup>diagForm2.controls[0];
if (diagForm3.controls['viewProvisionalDiagnosisProvided'].errors) {
required.push(
this.current_language_set.DiagnosisDetails.provisionaldiagnosis,
`${this.current_language_set?.common?.caseRecord ?? 'Case Record'}: ${this.current_language_set.DiagnosisDetails.provisionaldiagnosis}`,
);
}

Expand All @@ -2566,8 +2567,7 @@ export class WorkareaComponent
item.conceptID === '')
)
required.push(
this.current_language_set
.pleaseSelectprovisionalDiagnosisWithSnomedCode,
`${this.current_language_set?.common?.caseRecord ?? 'Case Record'}: ${this.current_language_set.pleaseSelectprovisionalDiagnosisWithSnomedCode}`,
);
});
}
Expand All @@ -2582,7 +2582,7 @@ export class WorkareaComponent
const diagForm1 = <FormGroup>diagForm.controls['diagnosisForm'];
if (diagForm1.controls['provisionalDiagnosisPrimaryDoctor'].errors) {
required.push(
this.current_language_set.DiagnosisDetails.provisionaldiagnosis,
`${this.current_language_set?.common?.caseRecord ?? 'Case Record'}: ${this.current_language_set.DiagnosisDetails.provisionaldiagnosis}`,
);
}
}
Expand All @@ -2596,7 +2596,7 @@ export class WorkareaComponent
const diagForm1 = <FormGroup>diagForm.controls['diagnosisForm'];
if (diagForm1.controls['provisionalDiagnosisPrimaryDoctor'].errors) {
required.push(
this.current_language_set.DiagnosisDetails.provisionaldiagnosis,
`${this.current_language_set?.common?.caseRecord ?? 'Case Record'}: ${this.current_language_set.DiagnosisDetails.provisionaldiagnosis}`,
);
}
}
Expand Down Expand Up @@ -2913,7 +2913,9 @@ export class WorkareaComponent
const temp =
diagnosisForm1.controls['ncdScreeningConditionArray'].value;
if (diagnosisForm1.controls['ncdScreeningConditionArray'].errors) {
required.push(this.current_language_set.casesheet.ncdCondition);
required.push(
`${this.current_language_set?.common?.caseRecord ?? 'Case Record'}: ${this.current_language_set.casesheet.ncdCondition}`,
);
}
let flag = false;

Expand All @@ -2926,7 +2928,9 @@ export class WorkareaComponent
flag &&
diagnosisForm1.controls['ncdScreeningConditionOther'].value === null
)
required.push(this.current_language_set.nCDConditionOther);
required.push(
`${this.current_language_set?.common?.caseRecord ?? 'Case Record'}: ${this.current_language_set.nCDConditionOther}`,
);
}
}
}
Expand Down Expand Up @@ -2963,11 +2967,54 @@ export class WorkareaComponent
required,
);
this.resetSpinnerandEnableTheSubmitButton();
// Navigate back to the case record step if there are errors from that section,
// so the doctor can locate and fix the missing fields easily.
if (
(this.attendant === 'doctor' || this.designation === 'TC Specialist') &&
this.stepper
) {
const hasCaseRecordErrors = required.some((msg: string) =>
msg
.toLowerCase()
.includes(
(
this.current_language_set?.common?.caseRecord ?? 'case record'
).toLowerCase(),
),
);
if (hasCaseRecordErrors) {
this.navigateToCaseRecordStep();
}
}
return 0;
} else {
return 1;
}
}

navigateToCaseRecordStep(): void {
if (!this.stepper) return;
const steps = this.stepper.steps.toArray();
const idx = steps.findIndex((s: any) => {
const label = (s.label || '').toLowerCase();
return label.includes('case') || label.includes('record');
});
if (idx >= 0) {
this.stepper.selectedIndex = idx;
}
}

navigateToQuickConsultStep(): void {
if (!this.stepper) return;
const steps = this.stepper.steps.toArray();
const idx = steps.findIndex((s: any) => {
const label = (s.label || '').toLowerCase();
return label.includes('quick') || label.includes('consult');
});
if (idx >= 0) {
this.stepper.selectedIndex = idx;
}
}
checkForSnomedCTCode(caseRecordForm: any) {
const clinicalObservation = <FormGroup>(
caseRecordForm.controls['generalFindingsForm'].controls[
Expand Down Expand Up @@ -3649,7 +3696,9 @@ export class WorkareaComponent
);
}
if (form.controls['clinicalObservation'].errors) {
required.push(this.current_language_set.casesheet.clinicalObs);
required.push(
`${this.current_language_set?.historyData?.QuickConsultDetails?.quickconsult ?? 'Quick Consult'}: ${this.current_language_set.casesheet.clinicalObs}`,
);
}
if (
this.visitCategory === 'General OPD (QC)' &&
Expand All @@ -3666,7 +3715,7 @@ export class WorkareaComponent
const diagForm3 = <FormGroup>diagForm2.controls[0];
if (diagForm3.controls['viewProvisionalDiagnosisProvided'].errors) {
required.push(
this.current_language_set.DiagnosisDetails.provisionaldiagnosis,
`${this.current_language_set?.historyData?.QuickConsultDetails?.quickconsult ?? 'Quick Consult'}: ${this.current_language_set.DiagnosisDetails.provisionaldiagnosis}`,
);
}

Expand All @@ -3679,8 +3728,7 @@ export class WorkareaComponent
item.conceptID === '')
)
required.push(
this.current_language_set
.pleaseSelectprovisionalDiagnosisWithSnomedCode,
`${this.current_language_set?.historyData?.QuickConsultDetails?.quickconsult ?? 'Quick Consult'}: ${this.current_language_set.pleaseSelectprovisionalDiagnosisWithSnomedCode}`,
);
});
}
Expand All @@ -3698,7 +3746,7 @@ export class WorkareaComponent
const diagForm3 = <FormGroup>diagForm2.controls[0];
if (diagForm3.controls['viewProvisionalDiagnosisProvided'].errors) {
required.push(
this.current_language_set.DiagnosisDetails.provisionaldiagnosis,
`${this.current_language_set?.historyData?.QuickConsultDetails?.quickconsult ?? 'Quick Consult'}: ${this.current_language_set.DiagnosisDetails.provisionaldiagnosis}`,
);
}

Expand All @@ -3711,8 +3759,7 @@ export class WorkareaComponent
item.conceptID === '')
)
required.push(
this.current_language_set
.pleaseSelectprovisionalDiagnosisWithSnomedCode,
`${this.current_language_set?.historyData?.QuickConsultDetails?.quickconsult ?? 'Quick Consult'}: ${this.current_language_set.pleaseSelectprovisionalDiagnosisWithSnomedCode}`,
);
});
}
Expand All @@ -3723,7 +3770,7 @@ export class WorkareaComponent

if (form.controls['provisionalDiagnosisList'].errors) {
required.push(
this.current_language_set.DiagnosisDetails.provisionaldiagnosis,
`${this.current_language_set?.historyData?.QuickConsultDetails?.quickconsult ?? 'Quick Consult'}: ${this.current_language_set.DiagnosisDetails.provisionaldiagnosis}`,
);
}

Expand Down Expand Up @@ -3782,6 +3829,9 @@ export class WorkareaComponent
required,
);
this.resetSpinnerandEnableTheSubmitButton();
if (this.stepper) {
this.navigateToQuickConsultStep();
}
return 0;
} else {
return 1;
Expand Down