Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #8858: Allow decimal places for pCO2, pO2,. Fix #8859: Add additional unit of measure for pCO2 and pO2. #9044

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/Utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,13 @@ export const celsiusToFahrenheit = (celsius: number) => {
export const fahrenheitToCelsius = (fahrenheit: number) => {
return ((fahrenheit - 32) * 5) / 9;
};
export const mmHgToKPa = (mmHg: number) => {
return mmHg * 0.133322;
};

export const kPaToMmHg = (kPa: number) => {
return kPa / 0.133322;
};

/**
* Although same as `Objects.keys(...)`, this provides better type-safety.
Expand Down
2 changes: 1 addition & 1 deletion src/components/Form/FormFields/RangeFormField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type PropsWithUnit = BaseProps & {
units?: undefined;
};

type PropsWithUnits = BaseProps & {
export type PropsWithUnits = BaseProps & {
unit?: undefined;
units: {
label: string;
Expand Down
53 changes: 41 additions & 12 deletions src/components/LogUpdate/Sections/ABGAnalysis.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import { ReactNode } from "react";

import RangeFormField from "@/components/Form/FormFields/RangeFormField";
import { PropsWithUnits } from "@/components/Form/FormFields/RangeFormField";
import {
LogUpdateSectionMeta,
LogUpdateSectionProps,
} from "@/components/LogUpdate/utils";
import { DailyRoundsModel } from "@/components/Patient/models";

import { ValueDescription, rangeValueDescription } from "@/Utils/utils";
import {
ValueDescription,
kPaToMmHg,
mmHgToKPa,
rangeValueDescription,
} from "@/Utils/utils";

export const ABGAnalysisFields = [
{
Expand All @@ -17,10 +23,18 @@ export const ABGAnalysisFields = [
PO<sub>2</sub>
</span>
),
unit: "mmHg",
min: 10,
max: 400,
valueDescription: rangeValueDescription({ low: 49, high: 200 }),
min: 0,
max: 20,
step: 0.01,
valueDescription: rangeValueDescription({ low: 10.5, high: 13.5 }),
units: [
{ label: "kPa" },
{
label: "mmHg",
conversionFn: kPaToMmHg,
inversionFn: mmHgToKPa,
},
],
},
{
key: "pco2",
Expand All @@ -29,18 +43,26 @@ export const ABGAnalysisFields = [
PCO<sub>2</sub>
</span>
),
unit: "mmHg",
min: 10,
max: 200,
valueDescription: rangeValueDescription({ low: 34, high: 45 }),
min: 0,
max: 20,
step: 0.01,
valueDescription: rangeValueDescription({ low: 5.1, high: 5.6 }),
units: [
{ label: "kPa" },
{
label: "mmHg",
conversionFn: kPaToMmHg,
inversionFn: mmHgToKPa,
},
],
},
{
key: "ph",
label: "pH",
unit: "",
min: 0,
max: 10,
step: 0.1,
step: 0.001,
valueDescription: rangeValueDescription({ low: 7.35, high: 7.45 }),
},
{
Expand Down Expand Up @@ -94,11 +116,16 @@ export const ABGAnalysisFields = [
] satisfies {
key: keyof DailyRoundsModel;
label: ReactNode;
unit: string;
unit?: string;
min: number;
max: number;
step?: number;
valueDescription: ValueDescription[];
units?: {
label: string;
conversionFn?: (val: number) => number;
inversionFn?: (val: number) => number;
}[];
}[];

const ABGAnalysis = ({ log, onChange }: LogUpdateSectionProps) => {
Expand All @@ -108,7 +135,9 @@ const ABGAnalysis = ({ log, onChange }: LogUpdateSectionProps) => {
<RangeFormField
key={index}
label={field.label}
unit={field.unit}
{...(field.unit
? { unit: field.unit }
: ({ units: field.units } as PropsWithUnits))}
name={field.key}
onChange={(c) => onChange({ [field.key]: c.value })}
value={log[field.key] as number}
Expand Down
Loading