From c21048431446104b58843c5906933ace9b80a8af Mon Sep 17 00:00:00 2001 From: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> Date: Mon, 18 Nov 2024 16:46:30 +0530 Subject: [PATCH] replicated the PR 9139 --- .../Facility/Consultations/VentilatorPlot.tsx | 60 +++++++------------ .../Consultations/VentilatorTable.tsx | 21 ++++--- 2 files changed, 36 insertions(+), 45 deletions(-) diff --git a/src/components/Facility/Consultations/VentilatorPlot.tsx b/src/components/Facility/Consultations/VentilatorPlot.tsx index 38948f165ea..2de4afe36a4 100644 --- a/src/components/Facility/Consultations/VentilatorPlot.tsx +++ b/src/components/Facility/Consultations/VentilatorPlot.tsx @@ -110,63 +110,47 @@ export const VentilatorPlot = ({ case "ventilator_tidal_volume": case "ventilator_peep": condition = - (currentRound.ventilator_interface === "INVASIVE" || - currentRound.ventilator_interface === "NON_INVASIVE") && - !!currentRound.ventilator_mode; + currentRound.ventilator_interface === "INVASIVE" || + currentRound.ventilator_interface === "NON_INVASIVE"; break; case "ventilator_fio2": condition = - currentRound.ventilator_interface === "OXYGEN_SUPPORT" && - currentRound.ventilator_oxygen_modality === "HIGH_FLOW_NASAL_CANNULA"; - break; - case "ventilator_spo2": - condition = - currentRound.ventilator_interface === "OXYGEN_SUPPORT" && - (currentRound.ventilator_oxygen_modality === "NASAL_PRONGS" || - currentRound.ventilator_oxygen_modality === "SIMPLE_FACE_MASK" || - currentRound.ventilator_oxygen_modality === - "NON_REBREATHING_MASK" || + currentRound.ventilator_interface === "INVASIVE" || + currentRound.ventilator_interface === "NON_INVASIVE" || + (currentRound.ventilator_interface === "OXYGEN_SUPPORT" && currentRound.ventilator_oxygen_modality === "HIGH_FLOW_NASAL_CANNULA"); break; + case "ventilator_spo2": + condition = currentRound.ventilator_interface !== "UNKNOWN"; + break; case "etco2": case "ventilator_oxygen_modality_flow_rate": condition = - !!currentRound.ventilator_mode || - !!currentRound.ventilator_oxygen_modality || - false; + currentRound.ventilator_interface === "OXYGEN_SUPPORT" && + currentRound.ventilator_oxygen_modality === "HIGH_FLOW_NASAL_CANNULA"; break; case "ventilator_oxygen_modality_oxygen_rate": condition = currentRound.ventilator_interface === "OXYGEN_SUPPORT" && - (currentRound.ventilator_oxygen_modality === "NASAL_PRONGS" || - currentRound.ventilator_oxygen_modality === "SIMPLE_FACE_MASK" || - currentRound.ventilator_oxygen_modality === "NON_REBREATHING_MASK"); + currentRound.ventilator_oxygen_modality !== "HIGH_FLOW_NASAL_CANNULA"; break; } switch (currentRound.ventilator_interface) { case "OXYGEN_SUPPORT": - legend = - t( - `OXYGEN_MODALITY__${currentRound.ventilator_oxygen_modality}_short`, - ) + - " (" + - t("RESPIRATORY_SUPPORT_SHORT__OXYGEN_SUPPORT") + - ")"; + legend = currentRound.ventilator_oxygen_modality + ? `${t(`OXYGEN_MODALITY__${currentRound.ventilator_oxygen_modality}_short`)} (${t("RESPIRATORY_SUPPORT_SHORT__OXYGEN_SUPPORT")})` + : t("RESPIRATORY_SUPPORT_SHORT__OXYGEN_SUPPORT"); break; case "INVASIVE": - legend = - t(`VENTILATOR_MODE__${currentRound.ventilator_mode}_short`) + - " (" + - t("RESPIRATORY_SUPPORT_SHORT__INVASIVE") + - ")"; + legend = currentRound.ventilator_mode + ? `${t(`VENTILATOR_MODE__${currentRound.ventilator_mode}_short`)} (${t("RESPIRATORY_SUPPORT_SHORT__INVASIVE")})` + : t("RESPIRATORY_SUPPORT_SHORT__INVASIVE"); break; case "NON_INVASIVE": - legend = - t(`VENTILATOR_MODE__${currentRound.ventilator_mode}_short`) + - " (" + - t("RESPIRATORY_SUPPORT_SHORT__NON_INVASIVE") + - ")"; + legend = currentRound.ventilator_mode + ? `${t(`VENTILATOR_MODE__${currentRound.ventilator_mode}_short`)} (${t("RESPIRATORY_SUPPORT_SHORT__NON_INVASIVE")})` + : t("RESPIRATORY_SUPPORT_SHORT__NON_INVASIVE"); break; } return { condition, legend }; @@ -178,9 +162,9 @@ export const VentilatorPlot = ({ switch (ventilatorInterface) { case "INVASIVE": case "NON_INVASIVE": - return round.ventilator_mode; + return round.ventilator_mode ?? "None"; case "OXYGEN_SUPPORT": - return round.ventilator_oxygen_modality; + return round.ventilator_oxygen_modality ?? "None"; default: return null; } diff --git a/src/components/Facility/Consultations/VentilatorTable.tsx b/src/components/Facility/Consultations/VentilatorTable.tsx index 2059f14bac0..9e4084cbaea 100644 --- a/src/components/Facility/Consultations/VentilatorTable.tsx +++ b/src/components/Facility/Consultations/VentilatorTable.tsx @@ -30,9 +30,13 @@ export default function VentilatorTable(props: VentilatorTableProps) { switch (ventilator_interface) { case "INVASIVE": case "NON_INVASIVE": - return t(`VENTILATOR_MODE__${ventilator_mode}`); + return ventilator_mode + ? t(`VENTILATOR_MODE__${ventilator_mode}`) + : "None"; case "OXYGEN_SUPPORT": - return t(`OXYGEN_MODALITY__${ventilator_oxygen_modality}`); + return ventilator_oxygen_modality + ? t(`OXYGEN_MODALITY__${ventilator_oxygen_modality}`) + : "None"; default: return null; } @@ -55,9 +59,9 @@ export default function VentilatorTable(props: VentilatorTableProps) { switch (ventilatorInterface) { case "INVASIVE": case "NON_INVASIVE": - return round.ventilator_mode; + return round.ventilator_mode ?? "None"; case "OXYGEN_SUPPORT": - return round.ventilator_oxygen_modality; + return round.ventilator_oxygen_modality ?? "None"; default: return null; } @@ -74,8 +78,9 @@ export default function VentilatorTable(props: VentilatorTableProps) { const nextInterfaceOrModality = getModeOrModality(nextRound); if ( nextInterfaceOrModality && - currentRound.ventilator_interface == nextRound.ventilator_interface && - currentInterfaceOrModality == nextInterfaceOrModality + currentRound.ventilator_interface === + nextRound.ventilator_interface && + currentInterfaceOrModality === nextInterfaceOrModality ) { index += 1; } else { @@ -105,6 +110,8 @@ export default function VentilatorTable(props: VentilatorTableProps) { const sortedData: DailyRoundsModel[] = dailyRoundsList.sort( compareByDateString("taken_at"), ); + const tableBody = VentilatorTableBody(sortedData); + if (!tableBody.length) return null; return (