diff --git a/src/Components/Facility/ConsultationDetails/index.tsx b/src/Components/Facility/ConsultationDetails/index.tsx index c0af068d66c..c438fa3fca7 100644 --- a/src/Components/Facility/ConsultationDetails/index.tsx +++ b/src/Components/Facility/ConsultationDetails/index.tsx @@ -38,6 +38,7 @@ import { ConsultationNeurologicalMonitoringTab } from "./ConsultationNeurologica import { ConsultationNutritionTab } from "./ConsultationNutritionTab"; import PatientNotesSlideover from "../PatientNotesSlideover"; import LegacyDiagnosesList from "../../Diagnosis/LegacyDiagnosesList"; +import { AssetBedModel } from "../../Assets/AssetTypes"; const Loading = lazy(() => import("../../Common/Loading")); const PageTitle = lazy(() => import("../../Common/PageTitle")); @@ -120,16 +121,19 @@ export const ConsultationDetails = (props: any) => { data.symptoms_text = symptoms.join(", "); } setConsultationData(data); - const assetRes = await dispatch( - listAssetBeds({ - bed: data?.current_bed?.bed_object?.id, - }) - ); - const isCameraAttachedRes = assetRes.data.results.some( - (asset: { asset_object: { asset_class: string } }) => { - return asset?.asset_object?.asset_class === "ONVIF"; - } - ); + const assetRes = data?.current_bed?.bed_object?.id + ? await dispatch( + listAssetBeds({ + bed: data?.current_bed?.bed_object?.id, + }) + ) + : null; + const isCameraAttachedRes = + assetRes != null + ? assetRes.data.results.some((asset: AssetBedModel) => { + return asset?.asset_object?.asset_class === "ONVIF"; + }) + : false; setIsCameraAttached(isCameraAttachedRes); const id = res.data.patient; const patientRes = await dispatch(getPatient({ id }));