diff --git a/Common-UI b/Common-UI index 31e1f8f..4677d34 160000 --- a/Common-UI +++ b/Common-UI @@ -1 +1 @@ -Subproject commit 31e1f8f50414fb864ce83107a3318758c7dcd06e +Subproject commit 4677d34d9da62a00a5927447de105ce4bea74576 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 0c36f97..a0b9dbf 100644 --- a/src/app/app-modules/nurse-doctor/workarea/workarea.component.ts +++ b/src/app/app-modules/nurse-doctor/workarea/workarea.component.ts @@ -4492,13 +4492,23 @@ export class WorkareaComponent let workLocationId: any; if (jsonLoccationData?.previlegeObj[0]?.roles) { const roles = jsonLoccationData?.previlegeObj[0]?.roles; - roles.forEach((item: any) => { - if (item.RoleName.toLowerCase() === 'doctor') { - workLocationId = item.workingLocationID; - } - }); + // Prefer doctor role, fall back to first available role with a workingLocationID + const doctorRole = roles.find( + (item: any) => item.RoleName?.toLowerCase() === 'doctor', + ); + const fallbackRole = roles.find((item: any) => item.workingLocationID); + workLocationId = + doctorRole?.workingLocationID ?? fallbackRole?.workingLocationID; } console.log('workLocationId', workLocationId); + if (!workLocationId) { + this.abdmFacilityId = null; + this.abdmFacilityName = null; + this.sessionstorage.setItem('abdmFacilityId', null); + this.sessionstorage.setItem('abdmFacilityName', null); + this.saveAbdmFacilityForVisit(); + return; + } this.registrarService.getMappedFacility(workLocationId).subscribe( (res: any) => { if (res.statusCode === 200 && res.data !== null) {