Skip to content

Commit

Permalink
🔧 Hide Camera Feed Tab for bed with no camera attached. (#6536)
Browse files Browse the repository at this point in the history
* Hide Camera Feed Tab for bed with no camera attached

* Resolved requested changes.
  • Loading branch information
shyamprakash123 authored Nov 7, 2023
1 parent fbf8eee commit e7fbde8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
15 changes: 15 additions & 0 deletions src/Components/Facility/ConsultationDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { ConsultationModel, ICD11DiagnosisModel } from "../models";
import {
getConsultation,
getPatient,
listAssetBeds,
listShiftRequests,
} from "../../../Redux/actions";
import { statusType, useAbortableEffect } from "../../../Common/utils";
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -126,6 +128,17 @@ 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";
}
);
setIsCameraAttached(isCameraAttachedRes);
const id = res.data.patient;
const patientRes = await dispatch(getPatient({ id }));
if (patientRes?.data) {
Expand Down Expand Up @@ -336,6 +349,7 @@ export const ConsultationDetails = (props: any) => {
Doctor Connect
</button>
{patientData.last_consultation?.id &&
isCameraAttached &&
["DistrictAdmin", "StateAdmin", "Doctor"].includes(
authUser.user_type
) && (
Expand Down Expand Up @@ -507,6 +521,7 @@ export const ConsultationDetails = (props: any) => {
{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(
Expand Down
4 changes: 1 addition & 3 deletions src/Components/Facility/Consultations/Feed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,7 @@ export const Feed: React.FC<IFeedProps> = ({ 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";
}
),
},
Expand Down

0 comments on commit e7fbde8

Please sign in to comment.