Skip to content

Commit

Permalink
Fixed oxygen support option in respiratory support (#5261)
Browse files Browse the repository at this point in the history
* not fixed yet

* Added Oxygen Respiratory Support

* small updates
  • Loading branch information
shivankacker authored Apr 7, 2023
1 parent cecdce5 commit e47b65f
Show file tree
Hide file tree
Showing 7 changed files with 208 additions and 140 deletions.
3 changes: 2 additions & 1 deletion src/Common/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,8 @@ export const ADMITTED_TO = [
export const RESPIRATORY_SUPPORT = [
{ id: "NIV", text: "NON_INVASIVE" },
{ id: "IV", text: "INVASIVE" },
{ id: "O2", text: "UNKNOWN" },
{ id: "O2", text: "OXYGEN_SUPPORT" },
{ id: "NONE", text: "UNKNOWN" },
];

export type PatientCategoryID = "Comfort" | "Stable" | "Moderate" | "Critical";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ let saveData = (id, consultationId, state, send, updateCB) => {
}

let ventilatorInterfaceOptions: array<Options.t> = [
{
label: "None",
value: "UNKNOWN",
name: "ventilator_interface",
},
{
label: "Invasive ventilator (IV)",
value: "INVASIVE",
Expand All @@ -160,7 +165,7 @@ let ventilatorInterfaceOptions: array<Options.t> = [
},
{
label: "Oxygen Support",
value: "UNKNOWN",
value: "OXYGEN_SUPPORT",
name: "ventilator_interface",
},
]
Expand Down Expand Up @@ -191,7 +196,8 @@ let make = (~ventilatorParameters: VentilatorParameters.t, ~id, ~consultationId,
let editor = switch state.ventilator_interface {
| INVASIVE => <CriticalCare__VentilatorParametersEditor__Invasive state send />
| NON_INVASIVE => <CriticalCare__VentilatorParametersEditor__NonInvasive state send />
| UNKNOWN => <CriticalCare__VentilatorParametersEditor__None state send />
| UNKNOWN => <CriticalCare__VentilatorParametersEditor__None />
| OXYGEN_SUPPORT => <CriticalCare__VentilatorParametersEditor__OxygenSupport state send />
}

<div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,126 +1,4 @@
let str = React.string
open CriticalCare__Types

let ventilatorOxygenModality: array<Options.t> = [
{label: "Nasal Prongs", value: "NASAL_PRONGS", name: "oxygenModality"},
{label: "Simple Face Mask", value: "SIMPLE_FACE_MASK", name: "oxygenModality"},
{label: "Non Rebreathing Mask", value: "NON_REBREATHING_MASK", name: "oxygenModality"},
{label: "High Flow Nasal Cannula", value: "HIGH_FLOW_NASAL_CANNULA", name: "oxygenModality"},
]

let silderOptionArray = [
{
"title": "FiO2 (%)",
"start": "21",
"end": "100",
"interval": "10",
"step": 1.0,
"id": "ventilator_fi02",
"min": 21.0,
"max": 60.0,
},
{
"title": "SPO2 (%)",
"start": "0",
"end": "100",
"interval": "10",
"step": 1.0,
"id": "ventilator_spo2",
"min": 90.0,
"max": 100.0,
},
]

@react.component
let make = (~state: VentilatorParameters.state, ~send: VentilatorParameters.action => unit) => {
let getOxygenFlowRateLabel = switch state.ventilator_oxygen_modality {
| NASAL_PRONGS => VentilatorParameters.getStatus(1.0, "Low", 4.0, "High")
| SIMPLE_FACE_MASK => VentilatorParameters.getStatus(5.0, "Low", 10.0, "High")
| NON_REBREATHING_MASK => VentilatorParameters.getStatus(11.0, "Low", 15.0, "High")
| _ => VentilatorParameters.getStatus(0.0, "Low", 50.0, "High")
}
<div>
<h4 className="mb-4"> {str("Oxygen Modality")} </h4>
<CriticalCare__RadioButton
defaultChecked={VentilatorParameters.encodeVentilatorOxygenModalityType(
state.ventilator_oxygen_modality,
)}
onChange={e => {
send(
SetOxygenModality(
VentilatorParameters.decodeVetilatorOxygenModalityType(ReactEvent.Form.target(e)["id"]),
),
)
}}
options={ventilatorOxygenModality}
ishorizontal={false}
/>
{state.ventilator_oxygen_modality === HIGH_FLOW_NASAL_CANNULA
? <Slider
title={"Flow Rate"}
start={"0"}
end={"70"}
interval={"5"}
step={1.0}
value={Belt.Int.toString(
switch state.ventilator_oxygen_modality_flow_rate {
| Some(value) => value
| _ => 0
},
)}
setValue={s => send(SetOxygenModalityFlowRate(Belt.Int.fromString(s)))}
getLabel={VentilatorParameters.getStatus(35.0, "Low", 60.0, "High")}
hasError={ValidationUtils.isInputInRangeInt(0, 70, state.ventilator_oxygen_modality_flow_rate)}
/>
: <Slider
title={"Oxygen Flow Rate"}
start={"0"}
end={"50"}
interval={"5"}
step={1.0}
value={Belt.Int.toString(
switch state.ventilator_oxygen_modality_oxygen_rate {
| Some(value) => value
| _ => 0
},
)}
setValue={s => send(SetOxygenModalityOxygenRate(Belt.Int.fromString(s)))}
getLabel={getOxygenFlowRateLabel}
hasError={ValidationUtils.isInputInRangeInt(0, 50, state.ventilator_oxygen_modality_oxygen_rate)}
/>}
{silderOptionArray
|> Array.map(option => {
let value: option<int> = switch option["id"] {
| "ventilator_oxygen_modality_flow_rate" => state.ventilator_oxygen_modality_flow_rate
| "ventilator_fi02" => state.ventilator_fi02
| "ventilator_spo2" => state.ventilator_spo2
| _ => None
}
let handleChange: option<int> => VentilatorParameters.action = s =>
switch option["id"] {
| "ventilator_fi02" => SetFIO2(s)
| "ventilator_spo2" => SetSPO2(s)
}
let className = option["id"] === "ventilator_fi02" && state.ventilator_oxygen_modality !== HIGH_FLOW_NASAL_CANNULA ? "hidden" : ""
<Slider
className
key={`none-${option["id"]}`}
title={option["title"]}
start={option["start"]}
end={option["end"]}
interval={option["interval"]}
step={option["step"]}
value={Belt.Int.toString(
switch value {
| Some(value) => value
| _ => Pervasives.int_of_string(option["start"])
},
)}
setValue={s => send(handleChange(Belt.Int.fromString(s)))}
getLabel={VentilatorParameters.getStatus(option["min"], "Low", option["max"], "High")}
hasError={ValidationUtils.isInputInRangeFloat(option["start"], option["end"], Some(Belt.Int.toFloat(switch value { | None => Pervasives.int_of_string(option["start"]) | Some(v) => v })))}
/>
})
|> React.array}
</div>
let make = () => {
<div />
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
let str = React.string
open CriticalCare__Types

let ventilatorOxygenModality: array<Options.t> = [
{label: "Nasal Prongs", value: "NASAL_PRONGS", name: "oxygenModality"},
{label: "Simple Face Mask", value: "SIMPLE_FACE_MASK", name: "oxygenModality"},
{label: "Non Rebreathing Mask", value: "NON_REBREATHING_MASK", name: "oxygenModality"},
{label: "High Flow Nasal Cannula", value: "HIGH_FLOW_NASAL_CANNULA", name: "oxygenModality"},
]

let silderOptionArray = [
{
"title": "FiO2 (%)",
"start": "21",
"end": "100",
"interval": "10",
"step": 1.0,
"id": "ventilator_fi02",
"min": 21.0,
"max": 60.0,
},
{
"title": "SPO2 (%)",
"start": "0",
"end": "100",
"interval": "10",
"step": 1.0,
"id": "ventilator_spo2",
"min": 90.0,
"max": 100.0,
},
]

@react.component
let make = (~state: VentilatorParameters.state, ~send: VentilatorParameters.action => unit) => {
let getOxygenFlowRateLabel = switch state.ventilator_oxygen_modality {
| NASAL_PRONGS => VentilatorParameters.getStatus(1.0, "Low", 4.0, "High")
| SIMPLE_FACE_MASK => VentilatorParameters.getStatus(5.0, "Low", 10.0, "High")
| NON_REBREATHING_MASK => VentilatorParameters.getStatus(11.0, "Low", 15.0, "High")
| _ => VentilatorParameters.getStatus(0.0, "Low", 50.0, "High")
}
<div>
<h4 className="mb-4"> {str("Oxygen Modality")} </h4>
<CriticalCare__RadioButton
defaultChecked={VentilatorParameters.encodeVentilatorOxygenModalityType(
state.ventilator_oxygen_modality,
)}
onChange={e => {
send(
SetOxygenModality(
VentilatorParameters.decodeVetilatorOxygenModalityType(ReactEvent.Form.target(e)["id"]),
),
)
}}
options={ventilatorOxygenModality}
ishorizontal={false}
/>
{state.ventilator_oxygen_modality === HIGH_FLOW_NASAL_CANNULA
? <Slider
title={"Flow Rate"}
start={"0"}
end={"70"}
interval={"5"}
step={1.0}
value={Belt.Int.toString(
switch state.ventilator_oxygen_modality_flow_rate {
| Some(value) => value
| _ => 0
},
)}
setValue={s => send(SetOxygenModalityFlowRate(Belt.Int.fromString(s)))}
getLabel={VentilatorParameters.getStatus(35.0, "Low", 60.0, "High")}
hasError={ValidationUtils.isInputInRangeInt(
0,
70,
state.ventilator_oxygen_modality_flow_rate,
)}
/>
: <Slider
title={"Oxygen Flow Rate"}
start={"0"}
end={"50"}
interval={"5"}
step={1.0}
value={Belt.Int.toString(
switch state.ventilator_oxygen_modality_oxygen_rate {
| Some(value) => value
| _ => 0
},
)}
setValue={s => send(SetOxygenModalityOxygenRate(Belt.Int.fromString(s)))}
getLabel={getOxygenFlowRateLabel}
hasError={ValidationUtils.isInputInRangeInt(
0,
50,
state.ventilator_oxygen_modality_oxygen_rate,
)}
/>}
{silderOptionArray
|> Array.map(option => {
let value: option<int> = switch option["id"] {
| "ventilator_oxygen_modality_flow_rate" => state.ventilator_oxygen_modality_flow_rate
| "ventilator_fi02" => state.ventilator_fi02
| "ventilator_spo2" => state.ventilator_spo2
| _ => None
}
let handleChange: option<int> => VentilatorParameters.action = s =>
switch option["id"] {
| "ventilator_fi02" => SetFIO2(s)
| "ventilator_spo2" => SetSPO2(s)
}
let className =
option["id"] === "ventilator_fi02" &&
state.ventilator_oxygen_modality !== HIGH_FLOW_NASAL_CANNULA
? "hidden"
: ""
<Slider
className
key={`none-${option["id"]}`}
title={option["title"]}
start={option["start"]}
end={option["end"]}
interval={option["interval"]}
step={option["step"]}
value={Belt.Int.toString(
switch value {
| Some(value) => value
| _ => Pervasives.int_of_string(option["start"])
},
)}
setValue={s => send(handleChange(Belt.Int.fromString(s)))}
getLabel={VentilatorParameters.getStatus(option["min"], "Low", option["max"], "High")}
hasError={ValidationUtils.isInputInRangeFloat(
option["start"],
option["end"],
Some(
Belt.Int.toFloat(
switch value {
| None => Pervasives.int_of_string(option["start"])
| Some(v) => v
},
),
),
)}
/>
})
|> React.array}
</div>
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ type parentventilatorModeType = CMV | SIMV | UNKNOWN

type ventilatorInterfaceType =
| UNKNOWN
| OXYGEN_SUPPORT
| INVASIVE
| NON_INVASIVE

Expand Down Expand Up @@ -36,6 +37,7 @@ let encodeVentilatorInterfaceType = ventilatorInterfaceType => {
switch ventilatorInterfaceType {
| INVASIVE => "INVASIVE"
| NON_INVASIVE => "NON_INVASIVE"
| OXYGEN_SUPPORT => "OXYGEN_SUPPORT"
| UNKNOWN => "UNKNOWN"
}
}
Expand Down Expand Up @@ -77,6 +79,7 @@ let decodeVentilatorInterfaceType = ventilatorInterfaceType => {
| "INVASIVE" => INVASIVE
| "NON_INVASIVE" => NON_INVASIVE
| "UNKNOWN" => UNKNOWN
| "OXYGEN_SUPPORT" => OXYGEN_SUPPORT
| _ => UNKNOWN
}
}
Expand Down Expand Up @@ -111,6 +114,7 @@ let ventilatorInterfaceTypeToString = ventilatorInterfaceType => {
| INVASIVE => "Invasive"
| NON_INVASIVE => "Non Invasive"
| UNKNOWN => "Unknown"
| OXYGEN_SUPPORT => "Oxygen Support"
}
}

Expand Down Expand Up @@ -139,7 +143,8 @@ let ventilatorOxygenModalityTypeToString = ventilatorOxygenModalityType => {
}
}

export type t = {
@genType
type t = {
ventilator_interface: ventilatorInterfaceType,
ventilator_mode: ventilatorModeType,
ventilator_oxygen_modality: ventilatorOxygenModalityType,
Expand Down
26 changes: 14 additions & 12 deletions src/Components/Patient/ManagePatients.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -594,18 +594,20 @@ export const PatientManager = () => {
</div>
</div>
{patient.last_consultation?.last_daily_round
?.ventilator_interface && (
<div className="rounded-full p-2 self-center border border-black text-center bg-cyan-100 font-semibold text-sm max-w-fit mt-0 mb-auto">
{
RESPIRATORY_SUPPORT.find(
(resp) =>
resp.text ===
patient.last_consultation?.last_daily_round
?.ventilator_interface
)?.id
}
</div>
)}
?.ventilator_interface &&
patient.last_consultation?.last_daily_round
?.ventilator_interface !== "UNKNOWN" && (
<div className="rounded-full shrink-0 w-8 h-8 flex items-center justify-center border border-primary-600 text-primary-600 bg-primary-100 font-semibold text-xs mb-auto">
{
RESPIRATORY_SUPPORT.find(
(resp) =>
resp.text ===
patient.last_consultation?.last_daily_round
?.ventilator_interface
)?.id
}
</div>
)}
</div>
</Link>
);
Expand Down
Loading

0 comments on commit e47b65f

Please sign in to comment.