Skip to content

Commit

Permalink
Ventilator mode/Oxygen modality data as exclusive of each other (ohcn…
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacobjeevan authored and noufalrahim committed Oct 24, 2024
1 parent 5d2d284 commit 10927c8
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,25 @@ import { OXYGEN_MODALITY_OPTIONS } from "@/common/constants";
const OxygenRespiratorySupport = ({ log, onChange }: LogUpdateSectionProps) => {
const { t } = useTranslation();

const handleChange = (c: any) => {
let resetData = {};
switch (c.value) {
case "HIGH_FLOW_NASAL_CANNULA":
resetData = { ventilator_oxygen_modality_oxygen_rate: null };
break;
default:
resetData = {
ventilator_fio2: null,
ventilator_oxygen_modality_flow_rate: null,
};
}
onChange({
ventilator_oxygen_modality:
c.value as typeof log.ventilator_oxygen_modality,
...resetData,
});
};

return (
<>
<RadioFormField
Expand All @@ -17,12 +36,7 @@ const OxygenRespiratorySupport = ({ log, onChange }: LogUpdateSectionProps) => {
optionValue={(c) => c.value}
name="ventilator_oxygen_modality"
value={log.ventilator_oxygen_modality}
onChange={(c) =>
onChange({
ventilator_oxygen_modality:
c.value as typeof log.ventilator_oxygen_modality,
})
}
onChange={handleChange}
layout="vertical"
/>
<br />
Expand Down
39 changes: 33 additions & 6 deletions src/components/LogUpdate/Sections/RespiratorySupport/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,38 @@ const RespiratorySupport = ({ log, onChange }: LogUpdateSectionProps) => {
}
}, [warnForNoLinkedVentilator]);

const handleChange = (c: any) => {
let resetData = {};
if (["OXYGEN_SUPPORT", "UNKNOWN"].includes(c.value)) {
resetData = {
...resetData,
ventilator_spo2: undefined,
ventilator_fio2: undefined,
ventilator_peep: undefined,
ventilator_pip: undefined,
ventilator_mean_airway_pressure: undefined,
ventilator_resp_rate: undefined,
ventilator_pressure_support: undefined,
ventilator_tidal_volume: undefined,
ventilator_mode: undefined,
};
}
if (["INVASIVE", "NON_INVASIVE", "UNKNOWN"].includes(c.value)) {
resetData = {
...resetData,
ventilator_spo2: undefined,
ventilator_oxygen_modality_flow_rate: undefined,
ventilator_oxygen_modality_oxygen_rate: undefined,
ventilator_oxygen_modality: undefined,
};
}
onChange({
ventilator_interface: (c.value ||
"UNKNOWN") as typeof log.ventilator_interface,
...resetData,
});
};

return (
<div className="flex flex-col gap-8">
<RadioFormField
Expand Down Expand Up @@ -94,12 +126,7 @@ const RespiratorySupport = ({ log, onChange }: LogUpdateSectionProps) => {
optionValue={(c) => c.value}
name="respiratory_support"
value={log.ventilator_interface}
onChange={(c) =>
onChange({
ventilator_interface: (c.value ||
"UNKNOWN") as typeof log.ventilator_interface,
})
}
onChange={handleChange}
/>

<DialogModal
Expand Down

0 comments on commit 10927c8

Please sign in to comment.