From 68b58768ce7f6eb8b19495dcad8afa59fd1eb645 Mon Sep 17 00:00:00 2001 From: Fredrick2503 Date: Mon, 1 Jul 2024 09:33:50 +0530 Subject: [PATCH] Added ICU occupancy and changed the tool tip text --- src/Components/Facility/FacilityCard.tsx | 64 ++++++++++++++++++++++-- 1 file changed, 61 insertions(+), 3 deletions(-) diff --git a/src/Components/Facility/FacilityCard.tsx b/src/Components/Facility/FacilityCard.tsx index 89a4128f7e..d05c7f85e9 100644 --- a/src/Components/Facility/FacilityCard.tsx +++ b/src/Components/Facility/FacilityCard.tsx @@ -13,10 +13,16 @@ import useConfig from "../../Common/hooks/useConfig"; import { classNames } from "../../Utils/utils"; import request from "../../Utils/request/request"; import routes from "../../Redux/api"; +import { getBedTypes } from "../../Common/constants"; +import useQuery from "../../Utils/request/useQuery"; export const FacilityCard = (props: { facility: any; userType: any }) => { const { facility, userType } = props; const { kasp_string } = useConfig(); + const config = useConfig(); + const capacityQuery = useQuery(routes.getCapacity, { + pathParams: { facilityId: `${facility.id}` }, + }); const { t } = useTranslation(); const [notifyModalFor, setNotifyModalFor] = useState(undefined); @@ -44,7 +50,22 @@ export const FacilityCard = (props: { facility: any; userType: any }) => { setNotifyError("Message cannot be empty"); } }; - + const fac = { usedICU: 0, VacantICU: 0 }; + getBedTypes(config).map((x) => { + const res = capacityQuery.data?.results.find((data) => { + return data.room_type === x.id; + }); + if ( + res && + res.current_capacity !== undefined && + res.total_capacity !== undefined && + (res.room_type === 20 || res.room_type === 10) + ) { + fac.VacantICU = fac.VacantICU + res.current_capacity; + fac.usedICU = fac.usedICU + res.total_capacity; + return

; + } + }); return (

@@ -180,8 +201,12 @@ export const FacilityCard = (props: { facility: any; userType: any }) => { : "button-primary-border bg-primary-100" }`} > - - Live Patients / Total beds + + Total patients marked as admitted in consultation/ Total + no. of registered beds {" "} { {facility.bed_count}{" "} {" "}
+
0.85 + ? "button-danger-border bg-red-500" + : "button-primary-border bg-primary-100" + }`} + > + + ICU bed type/ Number of ICU beds registered + {" "} + 0.85 + ? "text-white" + : "text-primary-600", + )} + />{" "} +
0.85 + ? "text-white" + : "text-gray-700" + }`} + > + ICU Occupancy: {fac.usedICU} / {fac.VacantICU}{" "} +
{" "} +