From 8d8a8a319caeca5289dccb10dccf7db0cafc4c49 Mon Sep 17 00:00:00 2001 From: Shyam prakash Date: Thu, 2 Nov 2023 21:16:41 +0530 Subject: [PATCH 1/2] Hide Camera Feed Tab for bed with no camera attached --- .../Facility/ConsultationDetails/index.tsx | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/Components/Facility/ConsultationDetails/index.tsx b/src/Components/Facility/ConsultationDetails/index.tsx index 202c9200b0a..9488242f16c 100644 --- a/src/Components/Facility/ConsultationDetails/index.tsx +++ b/src/Components/Facility/ConsultationDetails/index.tsx @@ -8,6 +8,7 @@ import { ConsultationModel, ICD11DiagnosisModel } from "../models"; import { getConsultation, getPatient, + listAssetBeds, listShiftRequests, } from "../../../Redux/actions"; import { statusType, useAbortableEffect } from "../../../Common/utils"; @@ -88,6 +89,7 @@ export const ConsultationDetails = (props: any) => { const [openDischargeSummaryDialog, setOpenDischargeSummaryDialog] = useState(false); const [openDischargeDialog, setOpenDischargeDialog] = useState(false); + const [isCameraAttached, setIsCameraAttached] = useState(false); const getPatientGender = (patientData: any) => GENDER_TYPES.find((i) => i.id === patientData.gender)?.text; @@ -126,6 +128,20 @@ 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.filter( + (asset: { asset_object: { meta: { asset_type: string } } }) => { + return asset?.asset_object?.meta?.asset_type === "CAMERA" + ? true + : false; + } + ).length >= 1; + setIsCameraAttached(isCameraAttachedRes); const id = res.data.patient; const patientRes = await dispatch(getPatient({ id })); if (patientRes?.data) { @@ -335,7 +351,7 @@ export const ConsultationDetails = (props: any) => { > Doctor Connect - {patientData.last_consultation?.id && ( + {patientData.last_consultation?.id && isCameraAttached && ( { {CONSULTATION_TABS.map((p: OptionsType) => { if (p.text === "FEED") { if ( + isCameraAttached === false || // No camera attached consultationData?.discharge_date || // Discharged !consultationData?.current_bed?.bed_object?.id || // Not admitted to bed !["DistrictAdmin", "StateAdmin", "Doctor"].includes( From c4d8333c8e992d3a3a2808b7fe02ddfe41764c78 Mon Sep 17 00:00:00 2001 From: Shyam prakash Date: Fri, 3 Nov 2023 21:09:24 +0530 Subject: [PATCH 2/2] Resolved requested changes. --- .../Facility/ConsultationDetails/index.tsx | 13 +++++-------- src/Components/Facility/Consultations/Feed.tsx | 4 +--- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/Components/Facility/ConsultationDetails/index.tsx b/src/Components/Facility/ConsultationDetails/index.tsx index 9488242f16c..db51496a05b 100644 --- a/src/Components/Facility/ConsultationDetails/index.tsx +++ b/src/Components/Facility/ConsultationDetails/index.tsx @@ -133,14 +133,11 @@ export const ConsultationDetails = (props: any) => { bed: data?.current_bed?.bed_object?.id, }) ); - const isCameraAttachedRes = - assetRes.data.results.filter( - (asset: { asset_object: { meta: { asset_type: string } } }) => { - return asset?.asset_object?.meta?.asset_type === "CAMERA" - ? true - : false; - } - ).length >= 1; + const isCameraAttachedRes = assetRes.data.results.some( + (asset: { asset_object: { asset_class: string } }) => { + return asset?.asset_object?.asset_class === "ONVIF"; + } + ); setIsCameraAttached(isCameraAttachedRes); const id = res.data.patient; const patientRes = await dispatch(getPatient({ id })); diff --git a/src/Components/Facility/Consultations/Feed.tsx b/src/Components/Facility/Consultations/Feed.tsx index 31691c736f4..5f86bb8781c 100644 --- a/src/Components/Facility/Consultations/Feed.tsx +++ b/src/Components/Facility/Consultations/Feed.tsx @@ -115,9 +115,7 @@ export const Feed: React.FC = ({ consultationId, facilityId }) => { ...bedAssets.data, results: bedAssets.data.results.filter( (asset: { asset_object: { meta: { asset_type: string } } }) => { - return asset?.asset_object?.meta?.asset_type === "CAMERA" - ? true - : false; + return asset?.asset_object?.meta?.asset_type === "CAMERA"; } ), },