From 01ef9969bdb61a4f1b6cbd30de0c9fe874bd39da Mon Sep 17 00:00:00 2001 From: kajambiya Date: Fri, 3 Nov 2023 15:40:42 +0300 Subject: [PATCH] fix undefined length property error --- src/api/api.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/api.ts b/src/api/api.ts index 75f7a248c..7aca9b3b0 100644 --- a/src/api/api.ts +++ b/src/api/api.ts @@ -66,7 +66,7 @@ export function getLocationsByTag(tag: string): Observable<{ uuid: string; displ export async function getPreviousEncounter(patientUuid: string, encounterType: string) { const query = `patient=${patientUuid}&_sort=-_lastUpdated&_count=1&type=${encounterType}`; let response = await openmrsFetch(`/ws/fhir2/R4/Encounter?${query}`); - if (response.data.entry.length) { + if (response?.data?.entry?.length) { const latestEncounter = response.data.entry[0].resource.id; response = await openmrsFetch(`/ws/rest/v1/encounter/${latestEncounter}?v=${encounterRepresentation}`); return response.data;