From 9b15ebfe33ddb762ba49e3dbafcb41799aa888a2 Mon Sep 17 00:00:00 2001 From: Jacobjohnjeevan Date: Fri, 11 Oct 2024 14:34:40 +0530 Subject: [PATCH 1/4] Add error msg for entering decimal values for certain ABG fields - Error messages for PO2, PCO2 and Base Excess. --- src/Components/Form/FormFields/RangeFormField.tsx | 5 +++++ src/Components/LogUpdate/Sections/ABGAnalysis.tsx | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/Components/Form/FormFields/RangeFormField.tsx b/src/Components/Form/FormFields/RangeFormField.tsx index e7e9b1e9a53..ab6a1839689 100644 --- a/src/Components/Form/FormFields/RangeFormField.tsx +++ b/src/Components/Form/FormFields/RangeFormField.tsx @@ -18,6 +18,7 @@ type BaseProps = FormFieldBaseProps & { valueDescriptions?: ValueDescription[]; hideInput?: boolean; hideUnitInLabel?: boolean; + allowIntegersOnly?: boolean; }; type PropsWithUnit = BaseProps & { @@ -71,6 +72,10 @@ export default function RangeFormField(props: Props) { if (value > max) { return `Value must be lesser than or equal to ${max}${unit?.label ?? ""}.`; } + + if (props.allowIntegersOnly && Math.abs(value % 1) != 0) { + return `Value must be an integer, cannot use decimals.`; + } })(); const valueDescription = diff --git a/src/Components/LogUpdate/Sections/ABGAnalysis.tsx b/src/Components/LogUpdate/Sections/ABGAnalysis.tsx index c0d8d32b5ba..795959f2eee 100644 --- a/src/Components/LogUpdate/Sections/ABGAnalysis.tsx +++ b/src/Components/LogUpdate/Sections/ABGAnalysis.tsx @@ -16,6 +16,7 @@ export const ABGAnalysisFields = [ min: 10, max: 400, valueDescription: rangeValueDescription({ low: 49, high: 200 }), + allowIntegersOnly: true, }, { key: "pco2", @@ -28,6 +29,7 @@ export const ABGAnalysisFields = [ min: 10, max: 200, valueDescription: rangeValueDescription({ low: 34, high: 45 }), + allowIntegersOnly: true, }, { key: "ph", @@ -58,6 +60,7 @@ export const ABGAnalysisFields = [ min: -20, max: 20, valueDescription: rangeValueDescription({ low: -3, high: 2 }), + allowIntegersOnly: true, }, { key: "lactate", @@ -94,6 +97,7 @@ export const ABGAnalysisFields = [ max: number; step?: number; valueDescription: ValueDescription[]; + allowIntegersOnly?: boolean; }[]; const ABGAnalysis = ({ log, onChange }: LogUpdateSectionProps) => { @@ -111,6 +115,7 @@ const ABGAnalysis = ({ log, onChange }: LogUpdateSectionProps) => { max={field.max} step={field.step || 1} valueDescriptions={field.valueDescription} + allowIntegersOnly={field.allowIntegersOnly ?? false} /> ))} From a5c0a0976492e5a40d8e5e74284516d4e58f5857 Mon Sep 17 00:00:00 2001 From: Jacobjohnjeevan Date: Fri, 11 Oct 2024 18:13:53 +0530 Subject: [PATCH 2/4] Added decimal value error msg for fields in BloodSugar, Dialysis etc --- src/Components/LogUpdate/Sections/BloodSugar.tsx | 1 + src/Components/LogUpdate/Sections/Dialysis.tsx | 2 ++ .../Sections/RespiratorySupport/OxygenSupport.tsx | 4 ++++ .../LogUpdate/Sections/RespiratorySupport/Ventilator.tsx | 9 +++++++++ .../LogUpdate/Sections/RespiratorySupport/index.tsx | 1 + src/Components/LogUpdate/Sections/Vitals.tsx | 3 +++ 6 files changed, 20 insertions(+) diff --git a/src/Components/LogUpdate/Sections/BloodSugar.tsx b/src/Components/LogUpdate/Sections/BloodSugar.tsx index eb9db7c2e74..1143267b3f0 100644 --- a/src/Components/LogUpdate/Sections/BloodSugar.tsx +++ b/src/Components/LogUpdate/Sections/BloodSugar.tsx @@ -19,6 +19,7 @@ const BloodSugar = ({ log, onChange }: LogUpdateSectionProps) => { min={0} max={700} valueDescriptions={rangeValueDescription({ low: 69, high: 110 })} + allowIntegersOnly />

diff --git a/src/Components/LogUpdate/Sections/Dialysis.tsx b/src/Components/LogUpdate/Sections/Dialysis.tsx index 2a6ed1988c1..aa75d3639e6 100644 --- a/src/Components/LogUpdate/Sections/Dialysis.tsx +++ b/src/Components/LogUpdate/Sections/Dialysis.tsx @@ -12,6 +12,7 @@ const Dialysis = ({ log, onChange }: LogUpdateSectionProps) => { value={log.dialysis_fluid_balance} min={0} max={5000} + allowIntegersOnly />
{ value={log.dialysis_net_balance} min={0} max={5000} + allowIntegersOnly /> ); diff --git a/src/Components/LogUpdate/Sections/RespiratorySupport/OxygenSupport.tsx b/src/Components/LogUpdate/Sections/RespiratorySupport/OxygenSupport.tsx index 758b49613ce..2fabc2370cb 100644 --- a/src/Components/LogUpdate/Sections/RespiratorySupport/OxygenSupport.tsx +++ b/src/Components/LogUpdate/Sections/RespiratorySupport/OxygenSupport.tsx @@ -41,6 +41,7 @@ const OxygenRespiratorySupport = ({ log, onChange }: LogUpdateSectionProps) => { min={0} max={70} valueDescriptions={rangeValueDescription({ low: 34, high: 60 })} + allowIntegersOnly />
{ min={21} max={100} valueDescriptions={rangeValueDescription({ high: 60 })} + allowIntegersOnly /> ) : ( @@ -72,6 +74,7 @@ const OxygenRespiratorySupport = ({ log, onChange }: LogUpdateSectionProps) => { min={0} max={50} valueDescriptions={rangeValueDescription({ low: 4, high: 10 })} + allowIntegersOnly /> )}
@@ -88,6 +91,7 @@ const OxygenRespiratorySupport = ({ log, onChange }: LogUpdateSectionProps) => { min={0} max={100} valueDescriptions={rangeValueDescription({ low: 89 })} + allowIntegersOnly /> ); diff --git a/src/Components/LogUpdate/Sections/RespiratorySupport/Ventilator.tsx b/src/Components/LogUpdate/Sections/RespiratorySupport/Ventilator.tsx index 4af1dc0fea7..7e178750a7b 100644 --- a/src/Components/LogUpdate/Sections/RespiratorySupport/Ventilator.tsx +++ b/src/Components/LogUpdate/Sections/RespiratorySupport/Ventilator.tsx @@ -24,6 +24,7 @@ export const VentilatorFields = [ min: 0, max: 100, valueDescription: rangeValueDescription({ low: 11, high: 30 }), + allowIntegersOnly: true, }, { key: "ventilator_mean_airway_pressure", @@ -32,6 +33,7 @@ export const VentilatorFields = [ min: 0, max: 40, valueDescription: rangeValueDescription({ low: 11, high: 25 }), + allowIntegersOnly: true, }, { key: "ventilator_resp_rate", @@ -40,6 +42,7 @@ export const VentilatorFields = [ min: 0, max: 100, valueDescription: rangeValueDescription({ low: 39, high: 60 }), + allowIntegersOnly: true, }, { key: "ventilator_pressure_support", @@ -48,6 +51,7 @@ export const VentilatorFields = [ min: 0, max: 40, valueDescription: rangeValueDescription({ low: 6, high: 15 }), + allowIntegersOnly: true, }, { key: "ventilator_tidal_volume", @@ -56,6 +60,7 @@ export const VentilatorFields = [ min: 0, max: 1000, valueDescription: rangeValueDescription({}), + allowIntegersOnly: true, }, { key: "ventilator_fio2", @@ -68,6 +73,7 @@ export const VentilatorFields = [ min: 21, max: 100, valueDescription: rangeValueDescription({ high: 60 }), + allowIntegersOnly: true, }, { key: "ventilator_spo2", @@ -80,6 +86,7 @@ export const VentilatorFields = [ min: 0, max: 100, valueDescription: rangeValueDescription({ low: 89 }), + allowIntegersOnly: true, }, ] satisfies { key: keyof DailyRoundsModel; @@ -89,6 +96,7 @@ export const VentilatorFields = [ max: number; step?: number; valueDescription: ValueDescription[]; + allowIntegersOnly?: boolean; }[]; const VentilatorRespiratorySupport = ({ @@ -116,6 +124,7 @@ const VentilatorRespiratorySupport = ({ max={field.max} step={field.step || 1} valueDescriptions={field.valueDescription} + allowIntegersOnly={field.allowIntegersOnly} /> ))} diff --git a/src/Components/LogUpdate/Sections/RespiratorySupport/index.tsx b/src/Components/LogUpdate/Sections/RespiratorySupport/index.tsx index 6c58d0bfa72..98fe7c1c366 100644 --- a/src/Components/LogUpdate/Sections/RespiratorySupport/index.tsx +++ b/src/Components/LogUpdate/Sections/RespiratorySupport/index.tsx @@ -85,6 +85,7 @@ const RespiratorySupport = ({ log, onChange }: LogUpdateSectionProps) => { max={200} step={1} valueDescriptions={rangeValueDescription({ low: 34, high: 45 })} + allowIntegersOnly />
{ step={1} unit="%" valueDescriptions={rangeValueDescription({ low: 89 })} + allowIntegersOnly /> { step={1} unit="bpm" valueDescriptions={rangeValueDescription({ low: 11, high: 16 })} + allowIntegersOnly />
@@ -105,6 +107,7 @@ const Vitals = ({ log, onChange }: LogUpdateSectionProps) => { text: t("tachycardia"), }, ]} + allowIntegersOnly /> Date: Mon, 14 Oct 2024 12:52:35 +0530 Subject: [PATCH 3/4] Rm error message, convert to int instead --- src/Components/Form/FormFields/RangeFormField.tsx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Components/Form/FormFields/RangeFormField.tsx b/src/Components/Form/FormFields/RangeFormField.tsx index ab6a1839689..6915e00e983 100644 --- a/src/Components/Form/FormFields/RangeFormField.tsx +++ b/src/Components/Form/FormFields/RangeFormField.tsx @@ -72,10 +72,6 @@ export default function RangeFormField(props: Props) { if (value > max) { return `Value must be lesser than or equal to ${max}${unit?.label ?? ""}.`; } - - if (props.allowIntegersOnly && Math.abs(value % 1) != 0) { - return `Value must be an integer, cannot use decimals.`; - } })(); const valueDescription = @@ -98,7 +94,10 @@ export default function RangeFormField(props: Props) { sliderDelta) * 100; - const handleChange = (v: number) => field.handleChange(unit.inversionFn(v)); + const handleChange = (v: number) => + field.handleChange( + unit.inversionFn(props.allowIntegersOnly ? Math.round(v) : v), + ); const displayValue = value != null ? properRoundOf(value) : ""; From 6f5ab64875274bff3b4c36665cdf09d9bdf5be5f Mon Sep 17 00:00:00 2001 From: Jacobjohnjeevan Date: Wed, 16 Oct 2024 18:52:28 +0530 Subject: [PATCH 4/4] Changed to use step size instead - removed the parameter added to keep track if field should be int only --- src/Components/Form/FormFields/RangeFormField.tsx | 5 +---- src/Components/LogUpdate/Sections/ABGAnalysis.tsx | 5 ----- src/Components/LogUpdate/Sections/BloodSugar.tsx | 3 +-- src/Components/LogUpdate/Sections/Dialysis.tsx | 2 -- .../Sections/RespiratorySupport/OxygenSupport.tsx | 4 ---- .../LogUpdate/Sections/RespiratorySupport/Ventilator.tsx | 9 --------- .../LogUpdate/Sections/RespiratorySupport/index.tsx | 1 - src/Components/LogUpdate/Sections/Vitals.tsx | 5 +---- 8 files changed, 3 insertions(+), 31 deletions(-) diff --git a/src/Components/Form/FormFields/RangeFormField.tsx b/src/Components/Form/FormFields/RangeFormField.tsx index 6915e00e983..c09cbfb2293 100644 --- a/src/Components/Form/FormFields/RangeFormField.tsx +++ b/src/Components/Form/FormFields/RangeFormField.tsx @@ -18,7 +18,6 @@ type BaseProps = FormFieldBaseProps & { valueDescriptions?: ValueDescription[]; hideInput?: boolean; hideUnitInLabel?: boolean; - allowIntegersOnly?: boolean; }; type PropsWithUnit = BaseProps & { @@ -95,9 +94,7 @@ export default function RangeFormField(props: Props) { 100; const handleChange = (v: number) => - field.handleChange( - unit.inversionFn(props.allowIntegersOnly ? Math.round(v) : v), - ); + field.handleChange(unit.inversionFn(props.step === 1 ? Math.round(v) : v)); const displayValue = value != null ? properRoundOf(value) : ""; diff --git a/src/Components/LogUpdate/Sections/ABGAnalysis.tsx b/src/Components/LogUpdate/Sections/ABGAnalysis.tsx index 795959f2eee..c0d8d32b5ba 100644 --- a/src/Components/LogUpdate/Sections/ABGAnalysis.tsx +++ b/src/Components/LogUpdate/Sections/ABGAnalysis.tsx @@ -16,7 +16,6 @@ export const ABGAnalysisFields = [ min: 10, max: 400, valueDescription: rangeValueDescription({ low: 49, high: 200 }), - allowIntegersOnly: true, }, { key: "pco2", @@ -29,7 +28,6 @@ export const ABGAnalysisFields = [ min: 10, max: 200, valueDescription: rangeValueDescription({ low: 34, high: 45 }), - allowIntegersOnly: true, }, { key: "ph", @@ -60,7 +58,6 @@ export const ABGAnalysisFields = [ min: -20, max: 20, valueDescription: rangeValueDescription({ low: -3, high: 2 }), - allowIntegersOnly: true, }, { key: "lactate", @@ -97,7 +94,6 @@ export const ABGAnalysisFields = [ max: number; step?: number; valueDescription: ValueDescription[]; - allowIntegersOnly?: boolean; }[]; const ABGAnalysis = ({ log, onChange }: LogUpdateSectionProps) => { @@ -115,7 +111,6 @@ const ABGAnalysis = ({ log, onChange }: LogUpdateSectionProps) => { max={field.max} step={field.step || 1} valueDescriptions={field.valueDescription} - allowIntegersOnly={field.allowIntegersOnly ?? false} /> ))}
diff --git a/src/Components/LogUpdate/Sections/BloodSugar.tsx b/src/Components/LogUpdate/Sections/BloodSugar.tsx index 1143267b3f0..235eb09a840 100644 --- a/src/Components/LogUpdate/Sections/BloodSugar.tsx +++ b/src/Components/LogUpdate/Sections/BloodSugar.tsx @@ -19,7 +19,6 @@ const BloodSugar = ({ log, onChange }: LogUpdateSectionProps) => { min={0} max={700} valueDescriptions={rangeValueDescription({ low: 69, high: 110 })} - allowIntegersOnly />

@@ -33,7 +32,7 @@ const BloodSugar = ({ log, onChange }: LogUpdateSectionProps) => { value={log.insulin_intake_dose} min={0} max={100} - step={1} + step={0.1} /> { value={log.dialysis_fluid_balance} min={0} max={5000} - allowIntegersOnly />
{ value={log.dialysis_net_balance} min={0} max={5000} - allowIntegersOnly /> ); diff --git a/src/Components/LogUpdate/Sections/RespiratorySupport/OxygenSupport.tsx b/src/Components/LogUpdate/Sections/RespiratorySupport/OxygenSupport.tsx index 2fabc2370cb..758b49613ce 100644 --- a/src/Components/LogUpdate/Sections/RespiratorySupport/OxygenSupport.tsx +++ b/src/Components/LogUpdate/Sections/RespiratorySupport/OxygenSupport.tsx @@ -41,7 +41,6 @@ const OxygenRespiratorySupport = ({ log, onChange }: LogUpdateSectionProps) => { min={0} max={70} valueDescriptions={rangeValueDescription({ low: 34, high: 60 })} - allowIntegersOnly />
{ min={21} max={100} valueDescriptions={rangeValueDescription({ high: 60 })} - allowIntegersOnly /> ) : ( @@ -74,7 +72,6 @@ const OxygenRespiratorySupport = ({ log, onChange }: LogUpdateSectionProps) => { min={0} max={50} valueDescriptions={rangeValueDescription({ low: 4, high: 10 })} - allowIntegersOnly /> )}
@@ -91,7 +88,6 @@ const OxygenRespiratorySupport = ({ log, onChange }: LogUpdateSectionProps) => { min={0} max={100} valueDescriptions={rangeValueDescription({ low: 89 })} - allowIntegersOnly /> ); diff --git a/src/Components/LogUpdate/Sections/RespiratorySupport/Ventilator.tsx b/src/Components/LogUpdate/Sections/RespiratorySupport/Ventilator.tsx index 7e178750a7b..4af1dc0fea7 100644 --- a/src/Components/LogUpdate/Sections/RespiratorySupport/Ventilator.tsx +++ b/src/Components/LogUpdate/Sections/RespiratorySupport/Ventilator.tsx @@ -24,7 +24,6 @@ export const VentilatorFields = [ min: 0, max: 100, valueDescription: rangeValueDescription({ low: 11, high: 30 }), - allowIntegersOnly: true, }, { key: "ventilator_mean_airway_pressure", @@ -33,7 +32,6 @@ export const VentilatorFields = [ min: 0, max: 40, valueDescription: rangeValueDescription({ low: 11, high: 25 }), - allowIntegersOnly: true, }, { key: "ventilator_resp_rate", @@ -42,7 +40,6 @@ export const VentilatorFields = [ min: 0, max: 100, valueDescription: rangeValueDescription({ low: 39, high: 60 }), - allowIntegersOnly: true, }, { key: "ventilator_pressure_support", @@ -51,7 +48,6 @@ export const VentilatorFields = [ min: 0, max: 40, valueDescription: rangeValueDescription({ low: 6, high: 15 }), - allowIntegersOnly: true, }, { key: "ventilator_tidal_volume", @@ -60,7 +56,6 @@ export const VentilatorFields = [ min: 0, max: 1000, valueDescription: rangeValueDescription({}), - allowIntegersOnly: true, }, { key: "ventilator_fio2", @@ -73,7 +68,6 @@ export const VentilatorFields = [ min: 21, max: 100, valueDescription: rangeValueDescription({ high: 60 }), - allowIntegersOnly: true, }, { key: "ventilator_spo2", @@ -86,7 +80,6 @@ export const VentilatorFields = [ min: 0, max: 100, valueDescription: rangeValueDescription({ low: 89 }), - allowIntegersOnly: true, }, ] satisfies { key: keyof DailyRoundsModel; @@ -96,7 +89,6 @@ export const VentilatorFields = [ max: number; step?: number; valueDescription: ValueDescription[]; - allowIntegersOnly?: boolean; }[]; const VentilatorRespiratorySupport = ({ @@ -124,7 +116,6 @@ const VentilatorRespiratorySupport = ({ max={field.max} step={field.step || 1} valueDescriptions={field.valueDescription} - allowIntegersOnly={field.allowIntegersOnly} /> ))} diff --git a/src/Components/LogUpdate/Sections/RespiratorySupport/index.tsx b/src/Components/LogUpdate/Sections/RespiratorySupport/index.tsx index 98fe7c1c366..6c58d0bfa72 100644 --- a/src/Components/LogUpdate/Sections/RespiratorySupport/index.tsx +++ b/src/Components/LogUpdate/Sections/RespiratorySupport/index.tsx @@ -85,7 +85,6 @@ const RespiratorySupport = ({ log, onChange }: LogUpdateSectionProps) => { max={200} step={1} valueDescriptions={rangeValueDescription({ low: 34, high: 45 })} - allowIntegersOnly />
{ step={1} unit="%" valueDescriptions={rangeValueDescription({ low: 89 })} - allowIntegersOnly /> { step={1} unit="bpm" valueDescriptions={rangeValueDescription({ low: 11, high: 16 })} - allowIntegersOnly />
@@ -107,7 +105,6 @@ const Vitals = ({ log, onChange }: LogUpdateSectionProps) => { text: t("tachycardia"), }, ]} - allowIntegersOnly />