From 45c73c0a4b72e5c11bdebd24f1c395888634c9d7 Mon Sep 17 00:00:00 2001 From: 5Amogh Date: Tue, 10 Mar 2026 16:38:31 +0530 Subject: [PATCH] fix: amm-1978 mandatory field section highlighted --- .../workarea/workarea.component.html | 1 + .../workarea/workarea.component.ts | 96 ++++++++++++++----- 2 files changed, 74 insertions(+), 23 deletions(-) diff --git a/src/app/app-modules/nurse-doctor/workarea/workarea.component.html b/src/app/app-modules/nurse-doctor/workarea/workarea.component.html index a099666..9600169 100644 --- a/src/app/app-modules/nurse-doctor/workarea/workarea.component.html +++ b/src/app/app-modules/nurse-doctor/workarea/workarea.component.html @@ -13,6 +13,7 @@ (keyup.enter)="preventSubmitOnEnter($event)" > diff --git a/src/app/app-modules/nurse-doctor/workarea/workarea.component.ts b/src/app/app-modules/nurse-doctor/workarea/workarea.component.ts index 9de001b..6a31ffb 100644 --- a/src/app/app-modules/nurse-doctor/workarea/workarea.component.ts +++ b/src/app/app-modules/nurse-doctor/workarea/workarea.component.ts @@ -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'; @@ -81,6 +82,9 @@ export class WorkareaComponent @ViewChild('sidenav') sidenav: any; + @ViewChild('stepper') + stepper!: MatStepper; + visitMode: any; ancMode: any; pncMode: any; @@ -2374,7 +2378,7 @@ export class WorkareaComponent const diagForm3 = 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}`, ); } @@ -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}`, ); }); } @@ -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}`, ); } @@ -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}`, ); }); } @@ -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}`, ); }); } @@ -2553,7 +2554,7 @@ export class WorkareaComponent const diagForm3 = 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}`, ); } @@ -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}`, ); }); } @@ -2582,7 +2582,7 @@ export class WorkareaComponent const diagForm1 = 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}`, ); } } @@ -2596,7 +2596,7 @@ export class WorkareaComponent const diagForm1 = 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}`, ); } } @@ -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; @@ -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}`, + ); } } } @@ -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 = ( caseRecordForm.controls['generalFindingsForm'].controls[ @@ -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)' && @@ -3666,7 +3715,7 @@ export class WorkareaComponent const diagForm3 = 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}`, ); } @@ -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}`, ); }); } @@ -3698,7 +3746,7 @@ export class WorkareaComponent const diagForm3 = 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}`, ); } @@ -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}`, ); }); } @@ -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}`, ); } @@ -3782,6 +3829,9 @@ export class WorkareaComponent required, ); this.resetSpinnerandEnableTheSubmitButton(); + if (this.stepper) { + this.navigateToQuickConsultStep(); + } return 0; } else { return 1;