Skip to content

Commit

Permalink
Staging Patch | Respiratory support table/graph: render no data point…
Browse files Browse the repository at this point in the history
…s with no mode/modality (#9151)
  • Loading branch information
khavinshankar authored Nov 18, 2024
2 parents c3b1ba2 + c210484 commit 3c7ef5c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 45 deletions.
60 changes: 22 additions & 38 deletions src/components/Facility/Consultations/VentilatorPlot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand All @@ -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;
}
Expand Down
21 changes: 14 additions & 7 deletions src/components/Facility/Consultations/VentilatorTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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 {
Expand Down Expand Up @@ -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 (
<div className="my-3 w-full overflow-x-scroll rounded-lg border bg-white px-4 pt-3 shadow">
Expand All @@ -122,7 +129,7 @@ export default function VentilatorTable(props: VentilatorTableProps) {
</th>
</tr>
</thead>
<tbody>{VentilatorTableBody(sortedData)}</tbody>
<tbody>{tableBody}</tbody>
</table>
</div>
);
Expand Down

0 comments on commit 3c7ef5c

Please sign in to comment.