From cd442ef3ca955b307261d4e799a7ba4857ac3003 Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Fri, 6 Sep 2024 18:07:27 +0530 Subject: [PATCH 1/8] Added support to have optionally restrictive range for RangeFormField's slider --- .../Form/FormFields/RangeFormField.tsx | 48 ++++++++++++------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/src/Components/Form/FormFields/RangeFormField.tsx b/src/Components/Form/FormFields/RangeFormField.tsx index b4ed7237c8a..0c9070d135b 100644 --- a/src/Components/Form/FormFields/RangeFormField.tsx +++ b/src/Components/Form/FormFields/RangeFormField.tsx @@ -12,9 +12,12 @@ import { SelectFormField } from "./SelectFormField"; type BaseProps = FormFieldBaseProps & { min: number; max: number; + sliderMin?: number; + sliderMax?: number; step?: number; valueDescriptions?: ValueDescription[]; hideInput?: boolean; + hideUnitInLabel?: boolean; }; type PropsWithUnit = BaseProps & { @@ -75,18 +78,20 @@ export default function RangeFormField(props: Props) { ? props.valueDescriptions?.find((vd) => (vd.till || props.max) >= value) : undefined; - const roundedValue = - Math.round(((value || min) + Number.EPSILON) * 100) / 100; - const allValueColors = props.valueDescriptions?.every((vd) => vd.color); - const trailPercent = ((roundedValue - min) / ((max || 0) - (min || 0))) * 100; + const [sliderMin, sliderMax] = [ + props.sliderMin ?? props.min, + props.sliderMax ?? props.max, + ].map(unit.conversionFn); - const snapStopLength = Math.min( - (props.max - props.min) / (props.step || 1), - props.max - props.min, - 20, - ); + const sliderDelta = sliderMax - sliderMin; + + const trailPercent = + ((Math.round(((value || sliderMin) + Number.EPSILON) * 100) / 100 - + sliderMin) / + sliderDelta) * + 100; const handleChange = (v: number) => field.handleChange(unit.inversionFn(v)); @@ -98,7 +103,10 @@ export default function RangeFormField(props: Props) { ...field, label: ( <> - {field.label} {unit.label && ({unit.label})} + {field.label}{" "} + {!props.hideUnitInLabel && unit.label && ( + ({unit.label}) + )} ), labelSuffix: ( @@ -124,6 +132,7 @@ export default function RangeFormField(props: Props) { max={max} errorClassName="hidden" inputClassName="py-1.5 mr-4" + disabled={props.disabled} /> {props.units?.length ? ( handleChange(e.target.valueAsNumber)} />
- {Array.from({ length: snapStopLength + 1 }).map((_, index) => ( + {Array.from({ + length: + 1 + Math.min(sliderDelta / (props.step || 1), sliderDelta, 20), + }).map((_, index) => (
))}
- {properRoundOf(min)} - {properRoundOf(max)} + {properRoundOf(sliderMin)} + {properRoundOf(sliderMax)}
); From 97ee9419976fca7d68d6c33c650a3b98e3320f7e Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Fri, 6 Sep 2024 19:05:50 +0530 Subject: [PATCH 2/8] Refactor blood pressure to align with new schema --- .../Common/BloodPressureFormField.tsx | 203 +++++++++++------- .../DailyRounds/LogUpdateCardAttribute.tsx | 4 +- .../Facility/Consultations/Mews.tsx | 2 +- .../Consultations/PrimaryParametersPlot.tsx | 18 +- src/Components/Facility/models.tsx | 7 +- .../LogUpdate/CriticalCarePreview.tsx | 10 +- src/Components/LogUpdate/Sections/Vitals.tsx | 104 ++++++--- src/Components/Patient/DailyRounds.tsx | 66 +++--- src/Components/Patient/models.tsx | 11 +- src/Components/Scribe/formDetails.ts | 4 +- src/Locale/en/Common.json | 4 +- src/Locale/en/LogUpdate.json | 7 +- 12 files changed, 253 insertions(+), 187 deletions(-) diff --git a/src/Components/Common/BloodPressureFormField.tsx b/src/Components/Common/BloodPressureFormField.tsx index 53c4adf2194..b38104fad59 100644 --- a/src/Components/Common/BloodPressureFormField.tsx +++ b/src/Components/Common/BloodPressureFormField.tsx @@ -1,111 +1,154 @@ +import { useTranslation } from "react-i18next"; import { FieldValidator } from "../Form/FieldValidators"; +import CheckBoxFormField from "../Form/FormFields/CheckBoxFormField"; import FormField from "../Form/FormFields/FormField"; import RangeAutocompleteFormField from "../Form/FormFields/RangeAutocompleteFormField"; import { - FieldChangeEvent, FormFieldBaseProps, useFormFieldPropsResolver, } from "../Form/FormFields/Utils"; import { BloodPressure } from "../Patient/models"; -type Props = FormFieldBaseProps; +type Props = FormFieldBaseProps; export default function BloodPressureFormField(props: Props) { + const { t } = useTranslation(); const field = useFormFieldPropsResolver(props); - const handleChange = (event: FieldChangeEvent) => { - const value: BloodPressure = { - ...field.value, - [event.name]: event.value, - }; - value.mean = meanArterialPressure(value); - field.onChange({ name: field.name, value }); + const handleChange = (bp: BloodPressure) => { + if (Object.values(bp).every((v) => (v ?? false) === false)) { + field.handleChange(null); + return; + } + + field.handleChange(bp); }; - const map = - !!props.value?.diastolic && - !!props.value.systolic && - meanArterialPressure(props.value); + const map = meanArterialPressure(props.value); return ( MAP: {map.toFixed(1)} - ) : undefined, + labelSuffix: map && MAP: {map}, }} > -
- - / - +
+
+ { + const bp = field.value ?? {}; + bp.systolic_not_measurable = value; + if (value) { + bp.systolic = null; + } + field.handleChange(bp); + }} + errorClassName="hidden" + /> + { + const bp = field.value ?? {}; + bp.systolic_not_measurable = false; + bp.systolic = value; + handleChange(bp); + }} + labelClassName="hidden" + errorClassName="hidden" + thresholds={[ + { + value: 0, + label: "Low", + className: "hidden md:block text-danger-500", + }, + { + value: 100, + label: "Normal", + className: "hidden md:block text-primary-500", + }, + { + value: 140, + label: "High", + className: "hidden md:block text-warning-500", + }, + ]} + /> +
+ + / + +
+ { + const bp = field.value ?? {}; + bp.diastolic_not_measurable = value; + if (value) { + bp.diastolic = null; + } + field.handleChange(bp); + }} + errorClassName="hidden" + /> + { + const bp = field.value ?? {}; + bp.diastolic_not_measurable = false; + bp.diastolic = value; + handleChange(bp); + }} + labelClassName="hidden" + errorClassName="hidden" + thresholds={[ + { + value: 0, + label: "Low", + className: "hidden md:block text-danger-500", + }, + { + value: 50, + label: "Normal", + className: "hidden md:block text-primary-500", + }, + { + value: 90, + label: "High", + className: "hidden md:block text-warning-500", + }, + ]} + /> +
); } -export const meanArterialPressure = ({ - diastolic, - systolic, -}: BloodPressure) => { - if (diastolic != null && systolic != null) { - return (2 * diastolic + systolic) / 3; +export const meanArterialPressure = (bp?: BloodPressure | null) => { + if (bp?.diastolic == null || bp?.systolic == null) { + return; } + return ((2 * bp.diastolic + bp.systolic) / 3).toFixed(); }; export const BloodPressureValidator: FieldValidator = (bp) => { diff --git a/src/Components/Facility/Consultations/DailyRounds/LogUpdateCardAttribute.tsx b/src/Components/Facility/Consultations/DailyRounds/LogUpdateCardAttribute.tsx index cc6f467b186..895314594c1 100644 --- a/src/Components/Facility/Consultations/DailyRounds/LogUpdateCardAttribute.tsx +++ b/src/Components/Facility/Consultations/DailyRounds/LogUpdateCardAttribute.tsx @@ -45,8 +45,8 @@ const LogUpdateCardAttribute = ({
- {(attributeValue as BloodPressure).systolic}/ - {(attributeValue as BloodPressure).diastolic} mmHg + {(attributeValue as BloodPressure).systolic || "--"}/ + {(attributeValue as BloodPressure).diastolic || "--"} mmHg
); diff --git a/src/Components/Facility/Consultations/Mews.tsx b/src/Components/Facility/Consultations/Mews.tsx index df54b83972f..91473a9a4ce 100644 --- a/src/Components/Facility/Consultations/Mews.tsx +++ b/src/Components/Facility/Consultations/Mews.tsx @@ -23,7 +23,7 @@ const getHeartRateScore = (value?: number) => { return 3; }; -const getSystolicBPScore = (value?: number) => { +const getSystolicBPScore = (value?: number | null) => { if (typeof value !== "number") return; if (value <= 70) return 3; diff --git a/src/Components/Facility/Consultations/PrimaryParametersPlot.tsx b/src/Components/Facility/Consultations/PrimaryParametersPlot.tsx index ca01ac1b113..45be8927b40 100644 --- a/src/Components/Facility/Consultations/PrimaryParametersPlot.tsx +++ b/src/Components/Facility/Consultations/PrimaryParametersPlot.tsx @@ -10,6 +10,7 @@ import CareIcon from "../../../CAREUI/icons/CareIcon"; import { PainDiagrams } from "./PainDiagrams"; import PageTitle from "../../Common/PageTitle"; import dayjs from "../../../Utils/dayjs"; +import { meanArterialPressure } from "../../Common/BloodPressureFormField"; interface PrimaryParametersPlotProps { facilityId: string; @@ -17,17 +18,6 @@ interface PrimaryParametersPlotProps { consultationId: string; } -const sanitizeBPAttribute = (value: number | undefined) => { - // Temp. hack until the cleaning of daily rounds as a db migration is done. - // TODO: remove once migration is merged. - - if (value == null || value < 0) { - return; - } - - return value; -}; - export const PrimaryParametersPlot = ({ consultationId, }: PrimaryParametersPlotProps) => { @@ -88,19 +78,19 @@ export const PrimaryParametersPlot = ({ { name: "diastolic", data: Object.values(results) - .map((p: any) => p.bp && sanitizeBPAttribute(p.bp.diastolic)) + .map((p: any) => p.bp?.diastolic) .reverse(), }, { name: "systolic", data: Object.values(results) - .map((p: any) => p.bp && sanitizeBPAttribute(p.bp.systolic)) + .map((p: any) => p.bp?.systolic) .reverse(), }, { name: "mean", data: Object.values(results) - .map((p: any) => p.bp && sanitizeBPAttribute(p.bp.mean)) + .map((p: any) => meanArterialPressure(p.bp)) .reverse(), }, ]; diff --git a/src/Components/Facility/models.tsx b/src/Components/Facility/models.tsx index 3f060240ee7..2b1419e17fa 100644 --- a/src/Components/Facility/models.tsx +++ b/src/Components/Facility/models.tsx @@ -14,6 +14,7 @@ import { ConsultationDiagnosis, CreateDiagnosis } from "../Diagnosis/types"; import { NormalPrescription, PRNPrescription } from "../Medicine/models"; import { AssignedToObjectModel, + BloodPressure, DailyRoundsModel, FileUploadModel, } from "../Patient/models"; @@ -402,11 +403,7 @@ export type PrimaryParametersPlotFields = | "rhythm_detail"; export type PrimaryParametersPlotRes = { - bp: { - mean?: number; - systolic?: number; - diastolic?: number; - }; + bp: BloodPressure; pulse: number; temperature: string; resp: number; diff --git a/src/Components/LogUpdate/CriticalCarePreview.tsx b/src/Components/LogUpdate/CriticalCarePreview.tsx index 67ad693ff48..48d2cd463d1 100644 --- a/src/Components/LogUpdate/CriticalCarePreview.tsx +++ b/src/Components/LogUpdate/CriticalCarePreview.tsx @@ -16,6 +16,7 @@ import { VentilatorFields } from "./Sections/RespiratorySupport/Ventilator"; import PressureSore from "./Sections/PressureSore/PressureSore"; import { IOBalanceSections } from "./Sections/IOBalance"; import PainChart from "./components/PainChart"; +import { meanArterialPressure } from "../Common/BloodPressureFormField"; type Props = { facilityId: string; @@ -215,10 +216,7 @@ export default function CriticalCarePreview(props: Props) { unit="mmHg" valueDescriptions={rangeValueDescription({ low: 49, high: 89 })} /> - +
)} { const Detail = (props: { label: React.ReactNode; - value?: string | number | boolean; + value?: string | number | boolean | null; suffix?: React.ReactNode; }) => { let value = props.value; @@ -517,7 +515,7 @@ const Detail = (props: { const RangeDetail = (props: { label: React.ReactNode; - value?: number; + value?: number | null; unit: React.ReactNode; max: number; valueDescriptions: ValueDescription[]; diff --git a/src/Components/LogUpdate/Sections/Vitals.tsx b/src/Components/LogUpdate/Sections/Vitals.tsx index 1fa4b3f3aac..b8131d713d3 100644 --- a/src/Components/LogUpdate/Sections/Vitals.tsx +++ b/src/Components/LogUpdate/Sections/Vitals.tsx @@ -2,61 +2,32 @@ import { useTranslation } from "react-i18next"; import { celsiusToFahrenheit, fahrenheitToCelsius, - properRoundOf, rangeValueDescription, } from "../../../Utils/utils"; import { meanArterialPressure } from "../../Common/BloodPressureFormField"; - import RadioFormField from "../../Form/FormFields/RadioFormField"; import RangeFormField from "../../Form/FormFields/RangeFormField"; import TextAreaFormField from "../../Form/FormFields/TextAreaFormField"; -import { FieldChangeEvent } from "../../Form/FormFields/Utils"; import PainChart from "../components/PainChart"; import { LogUpdateSectionMeta, LogUpdateSectionProps } from "../utils"; import { HEARTBEAT_RHYTHM_CHOICES } from "../../../Common/constants"; +import CheckBoxFormField from "../../Form/FormFields/CheckBoxFormField"; +import { FieldLabel } from "../../Form/FormFields/FormField"; +import { BloodPressure } from "../../Patient/models"; const Vitals = ({ log, onChange }: LogUpdateSectionProps) => { const { t } = useTranslation(); - const handleBloodPressureChange = (event: FieldChangeEvent) => { - const bp = { - ...(log.bp ?? {}), - [event.name]: event.value, - }; - bp.mean = meanArterialPressure(bp); - onChange({ bp }); - }; return (

{t("blood_pressure")}

- {t("map_acronym")}:{" "} - {(log.bp?.mean && properRoundOf(log.bp.mean)) || "--"} + {t("map_acronym")}: {meanArterialPressure(log.bp) ?? "--"} mmHg
- - + +
{ ); }; +const BPAttributeEditor = ({ + attribute, + log, + onChange, +}: LogUpdateSectionProps & { attribute: "systolic" | "diastolic" }) => { + const { t } = useTranslation(); + + const handleChange = (bp: BloodPressure) => { + if (Object.values(bp).every((v) => (v ?? false) === false)) { + onChange({ bp: undefined }); + return; + } + + onChange({ bp }); + }; + + return ( +
+ {t(attribute)} + { + const bp = log.bp ?? {}; + bp[`${attribute}_not_measurable`] = value; + if (value) { + bp[attribute] = null; + } + handleChange(bp); + }} + errorClassName="hidden" + /> + } + disabled={log.bp?.[`${attribute}_not_measurable`]} + onChange={({ value }) => { + const bp = log.bp ?? {}; + bp[`${attribute}_not_measurable`] = false; + bp[attribute] = value; + handleChange(bp); + }} + value={log.bp?.[attribute] ?? undefined} + min={0} + max={400} + sliderMin={30} + sliderMax={270} + step={1} + unit="mmHg" + valueDescriptions={rangeValueDescription( + attribute === "systolic" + ? { low: 99, high: 139 } + : { low: 49, high: 89 }, + )} + hideUnitInLabel + /> +
+ ); +}; + Vitals.meta = { title: "Vitals", icon: "l-heartbeat", diff --git a/src/Components/Patient/DailyRounds.tsx b/src/Components/Patient/DailyRounds.tsx index 0f0c7396f5e..8f2a0a5b06b 100644 --- a/src/Components/Patient/DailyRounds.tsx +++ b/src/Components/Patient/DailyRounds.tsx @@ -83,12 +83,7 @@ export const DailyRounds = (props: any) => { rhythm_detail: "", ventilator_spo2: null, consciousness_level: undefined, - bp: { - systolic: undefined, - diastolic: undefined, - mean: undefined, - }, - // bed: null, + bp: undefined, }; const initError = Object.assign( @@ -246,7 +241,7 @@ export const DailyRounds = (props: any) => { } return; case "bp": { - const error = BloodPressureValidator(state.form.bp); + const error = state.form.bp && BloodPressureValidator(state.form.bp); if (error) { errors.bp = error; invalidForm = true; @@ -656,17 +651,19 @@ export const DailyRounds = (props: any) => { state.form.rounds_type, ) && ( <> -

Vitals

- - +

{t("vitals")}

+ +
+ +
{ { { ]} /> - option.desc} - optionValue={(option) => option.id} - /> - - +
+ option.desc} + optionValue={(option) => option.id} + errorClassName="hidden" + /> + + +
{ diff --git a/src/Locale/en/Common.json b/src/Locale/en/Common.json index 24855e05d70..39eb3e97663 100644 --- a/src/Locale/en/Common.json +++ b/src/Locale/en/Common.json @@ -70,7 +70,7 @@ "date_of_positive_covid_19_swab": "Date of Positive Covid 19 Swab", "patient_no": "OP/IP No", "date_of_admission": "Date of Admission", - "india_1": "India", + "not_measurable": "Not measurable", "unique_id": "Unique Id", "date_and_time": "Date and Time", "facility_type": "Facility type", @@ -201,4 +201,4 @@ "oxygen_information": "Oxygen Information", "deleted_successfully": "{{name}} deleted successfully", "delete_item": "Delete {{name}}" -} +} \ No newline at end of file diff --git a/src/Locale/en/LogUpdate.json b/src/Locale/en/LogUpdate.json index 080e2fc979a..366ff285ab1 100644 --- a/src/Locale/en/LogUpdate.json +++ b/src/Locale/en/LogUpdate.json @@ -1,6 +1,6 @@ { "RESPIRATORY_SUPPORT_SHORT__UNKNOWN": "None", - "RESPIRATORY_SUPPORT_SHORT__OXYGEN_SUPPORT": "O2 Support", + "RESPIRATORY_SUPPORT_SHORT__OXYGEN_SUPPORT": "O₂ Support", "RESPIRATORY_SUPPORT_SHORT__NON_INVASIVE": "NIV", "RESPIRATORY_SUPPORT_SHORT__INVASIVE": "IV", "RESPIRATORY_SUPPORT__UNKNOWN": "None", @@ -58,6 +58,8 @@ "HEARTBEAT_RHYTHM__UNKNOWN": "Unknown", "heartbeat_rhythm": "Heartbeat Rhythm", "heartbeat_description": "Heartbeat Description", + "rhythm": "Rhythm", + "rhythm_description": "Rhythm description", "blood_pressure": "Blood Pressure", "map_acronym": "M.A.P.", "systolic": "Systolic", @@ -69,5 +71,6 @@ "pulse": "Pulse", "bradycardia": "Bradycardia", "tachycardia": "Tachycardia", - "spo2": "SpO₂" + "spo2": "SpO₂", + "vitals": "Vitals" } \ No newline at end of file From b4e90c37c64dc1e1a1a7eb1da84081ed0436bdc7 Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Tue, 10 Sep 2024 18:01:19 +0530 Subject: [PATCH 3/8] Drop measurable attribute for BP --- .../Common/BloodPressureFormField.tsx | 180 +++++++----------- .../LogUpdate/CriticalCarePreview.tsx | 4 +- src/Components/LogUpdate/Sections/Vitals.tsx | 78 +++----- src/Components/Patient/DailyRounds.tsx | 14 +- src/Components/Patient/models.tsx | 6 +- src/Locale/en/Common.json | 1 - 6 files changed, 98 insertions(+), 185 deletions(-) diff --git a/src/Components/Common/BloodPressureFormField.tsx b/src/Components/Common/BloodPressureFormField.tsx index b38104fad59..ca93d738f40 100644 --- a/src/Components/Common/BloodPressureFormField.tsx +++ b/src/Components/Common/BloodPressureFormField.tsx @@ -1,9 +1,9 @@ import { useTranslation } from "react-i18next"; import { FieldValidator } from "../Form/FieldValidators"; -import CheckBoxFormField from "../Form/FormFields/CheckBoxFormField"; import FormField from "../Form/FormFields/FormField"; import RangeAutocompleteFormField from "../Form/FormFields/RangeAutocompleteFormField"; import { + FieldChangeEvent, FormFieldBaseProps, useFormFieldPropsResolver, } from "../Form/FormFields/Utils"; @@ -14,18 +14,14 @@ type Props = FormFieldBaseProps; export default function BloodPressureFormField(props: Props) { const { t } = useTranslation(); const field = useFormFieldPropsResolver(props); + const map = meanArterialPressure(props.value); - const handleChange = (bp: BloodPressure) => { - if (Object.values(bp).every((v) => (v ?? false) === false)) { - field.handleChange(null); - return; - } - - field.handleChange(bp); + const handleChange = (event: FieldChangeEvent) => { + const bp = field.value ?? {}; + bp[event.name as keyof BloodPressure] = event.value; + field.handleChange(Object.values(bp).filter(Boolean).length ? bp : null); }; - const map = meanArterialPressure(props.value); - return ( MAP: {map}, }} > -
-
- { - const bp = field.value ?? {}; - bp.systolic_not_measurable = value; - if (value) { - bp.systolic = null; - } - field.handleChange(bp); - }} - errorClassName="hidden" - /> - { - const bp = field.value ?? {}; - bp.systolic_not_measurable = false; - bp.systolic = value; - handleChange(bp); - }} - labelClassName="hidden" - errorClassName="hidden" - thresholds={[ - { - value: 0, - label: "Low", - className: "hidden md:block text-danger-500", - }, - { - value: 100, - label: "Normal", - className: "hidden md:block text-primary-500", - }, - { - value: 140, - label: "High", - className: "hidden md:block text-warning-500", - }, - ]} - /> -
- - / - -
- { - const bp = field.value ?? {}; - bp.diastolic_not_measurable = value; - if (value) { - bp.diastolic = null; - } - field.handleChange(bp); - }} - errorClassName="hidden" - /> - { - const bp = field.value ?? {}; - bp.diastolic_not_measurable = false; - bp.diastolic = value; - handleChange(bp); - }} - labelClassName="hidden" - errorClassName="hidden" - thresholds={[ - { - value: 0, - label: "Low", - className: "hidden md:block text-danger-500", - }, - { - value: 50, - label: "Normal", - className: "hidden md:block text-primary-500", - }, - { - value: 90, - label: "High", - className: "hidden md:block text-warning-500", - }, - ]} - /> -
+
+ + / +
); diff --git a/src/Components/LogUpdate/CriticalCarePreview.tsx b/src/Components/LogUpdate/CriticalCarePreview.tsx index 48d2cd463d1..4bcc22afe09 100644 --- a/src/Components/LogUpdate/CriticalCarePreview.tsx +++ b/src/Components/LogUpdate/CriticalCarePreview.tsx @@ -488,7 +488,7 @@ const Section = (props: { title: string; children: React.ReactNode }) => { const Detail = (props: { label: React.ReactNode; - value?: string | number | boolean | null; + value?: string | number | boolean; suffix?: React.ReactNode; }) => { let value = props.value; @@ -515,7 +515,7 @@ const Detail = (props: { const RangeDetail = (props: { label: React.ReactNode; - value?: number | null; + value?: number; unit: React.ReactNode; max: number; valueDescriptions: ValueDescription[]; diff --git a/src/Components/LogUpdate/Sections/Vitals.tsx b/src/Components/LogUpdate/Sections/Vitals.tsx index b8131d713d3..186fa89b558 100644 --- a/src/Components/LogUpdate/Sections/Vitals.tsx +++ b/src/Components/LogUpdate/Sections/Vitals.tsx @@ -11,8 +11,6 @@ import TextAreaFormField from "../../Form/FormFields/TextAreaFormField"; import PainChart from "../components/PainChart"; import { LogUpdateSectionMeta, LogUpdateSectionProps } from "../utils"; import { HEARTBEAT_RHYTHM_CHOICES } from "../../../Common/constants"; -import CheckBoxFormField from "../../Form/FormFields/CheckBoxFormField"; -import { FieldLabel } from "../../Form/FormFields/FormField"; import { BloodPressure } from "../../Patient/models"; const Vitals = ({ log, onChange }: LogUpdateSectionProps) => { @@ -133,59 +131,31 @@ const BPAttributeEditor = ({ }: LogUpdateSectionProps & { attribute: "systolic" | "diastolic" }) => { const { t } = useTranslation(); - const handleChange = (bp: BloodPressure) => { - if (Object.values(bp).every((v) => (v ?? false) === false)) { - onChange({ bp: undefined }); - return; - } - - onChange({ bp }); - }; - return ( -
- {t(attribute)} - { - const bp = log.bp ?? {}; - bp[`${attribute}_not_measurable`] = value; - if (value) { - bp[attribute] = null; - } - handleChange(bp); - }} - errorClassName="hidden" - /> - } - disabled={log.bp?.[`${attribute}_not_measurable`]} - onChange={({ value }) => { - const bp = log.bp ?? {}; - bp[`${attribute}_not_measurable`] = false; - bp[attribute] = value; - handleChange(bp); - }} - value={log.bp?.[attribute] ?? undefined} - min={0} - max={400} - sliderMin={30} - sliderMax={270} - step={1} - unit="mmHg" - valueDescriptions={rangeValueDescription( - attribute === "systolic" - ? { low: 99, high: 139 } - : { low: 49, high: 89 }, - )} - hideUnitInLabel - /> -
+ { + const bp = log.bp ?? {}; + bp[event.name as keyof BloodPressure] = event.value; + onChange({ + bp: Object.values(bp).filter(Boolean).length ? bp : undefined, + }); + }} + value={log.bp?.[attribute] ?? undefined} + min={0} + max={400} + sliderMin={30} + sliderMax={270} + step={1} + unit="mmHg" + valueDescriptions={rangeValueDescription( + attribute === "systolic" + ? { low: 99, high: 139 } + : { low: 49, high: 89 }, + )} + hideUnitInLabel + /> ); }; diff --git a/src/Components/Patient/DailyRounds.tsx b/src/Components/Patient/DailyRounds.tsx index 8f2a0a5b06b..80d77d7eda6 100644 --- a/src/Components/Patient/DailyRounds.tsx +++ b/src/Components/Patient/DailyRounds.tsx @@ -327,7 +327,7 @@ export const DailyRounds = (props: any) => { if (!["VENTILATOR"].includes(state.form.rounds_type)) { data = { ...data, - bp: state.form.bp ?? {}, + bp: state.form.bp, pulse: state.form.pulse ?? null, resp: state.form.resp ?? null, temperature: state.form.temperature ?? null, @@ -653,13 +653,11 @@ export const DailyRounds = (props: any) => { <>

{t("vitals")}

-
- -
+ Date: Tue, 10 Sep 2024 18:14:00 +0530 Subject: [PATCH 4/8] Not sure why cypress run was using an older commit, so here's an empty commit... From 585b645d350b2b5a5c7c8497801917baf1089183 Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Sat, 14 Sep 2024 10:49:19 +0530 Subject: [PATCH 5/8] fix null checks --- src/Components/Common/BloodPressureFormField.tsx | 4 ++-- .../DailyRounds/LogUpdateCardAttribute.tsx | 10 +++------- src/Components/LogUpdate/CriticalCarePreview.tsx | 5 ++++- src/Components/LogUpdate/Sections/Vitals.tsx | 3 ++- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Components/Common/BloodPressureFormField.tsx b/src/Components/Common/BloodPressureFormField.tsx index ca93d738f40..205bc9a4905 100644 --- a/src/Components/Common/BloodPressureFormField.tsx +++ b/src/Components/Common/BloodPressureFormField.tsx @@ -14,7 +14,7 @@ type Props = FormFieldBaseProps; export default function BloodPressureFormField(props: Props) { const { t } = useTranslation(); const field = useFormFieldPropsResolver(props); - const map = meanArterialPressure(props.value); + const map = meanArterialPressure(props.value)?.toFixed(); const handleChange = (event: FieldChangeEvent) => { const bp = field.value ?? {}; @@ -96,7 +96,7 @@ export const meanArterialPressure = (bp?: BloodPressure | null) => { if (bp?.diastolic == null || bp?.systolic == null) { return; } - return ((2 * bp.diastolic + bp.systolic) / 3).toFixed(); + return (2 * bp.diastolic + bp.systolic) / 3; }; export const BloodPressureValidator: FieldValidator = (bp) => { diff --git a/src/Components/Facility/Consultations/DailyRounds/LogUpdateCardAttribute.tsx b/src/Components/Facility/Consultations/DailyRounds/LogUpdateCardAttribute.tsx index 895314594c1..c1b5fec3c8c 100644 --- a/src/Components/Facility/Consultations/DailyRounds/LogUpdateCardAttribute.tsx +++ b/src/Components/Facility/Consultations/DailyRounds/LogUpdateCardAttribute.tsx @@ -1,10 +1,6 @@ import { useTranslation } from "react-i18next"; import PatientCategoryBadge from "../../../Common/PatientCategoryBadge"; -import { - BloodPressure, - DailyRoundsModel, - NameQuantity, -} from "../../../Patient/models"; +import { DailyRoundsModel, NameQuantity } from "../../../Patient/models"; import { PatientCategory } from "../../models"; interface Props { @@ -45,8 +41,8 @@ const LogUpdateCardAttribute = ({
- {(attributeValue as BloodPressure).systolic || "--"}/ - {(attributeValue as BloodPressure).diastolic || "--"} mmHg + {(attributeValue as DailyRoundsModel["bp"])?.systolic || "--"}/ + {(attributeValue as DailyRoundsModel["bp"])?.diastolic || "--"} mmHg
); diff --git a/src/Components/LogUpdate/CriticalCarePreview.tsx b/src/Components/LogUpdate/CriticalCarePreview.tsx index 91a45e59289..3f3fa4b183c 100644 --- a/src/Components/LogUpdate/CriticalCarePreview.tsx +++ b/src/Components/LogUpdate/CriticalCarePreview.tsx @@ -217,7 +217,10 @@ export default function CriticalCarePreview(props: Props) { unit="mmHg" valueDescriptions={rangeValueDescription({ low: 49, high: 89 })} /> - +
)} {

{t("blood_pressure")}

- {t("map_acronym")}: {meanArterialPressure(log.bp) ?? "--"} mmHg + {t("map_acronym")}: {meanArterialPressure(log.bp)?.toFixed() ?? "--"}{" "} + mmHg
From d9f2c5d2abe77ee10bed622b09dd093e2ab66281 Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Fri, 20 Sep 2024 13:08:01 +0530 Subject: [PATCH 6/8] update field labels --- src/Components/LogUpdate/Sections/Vitals.tsx | 2 +- src/Locale/hi/LogUpdate.json | 1 - src/Locale/kn/LogUpdate.json | 1 - src/Locale/ml/LogUpdate.json | 1 - src/Locale/ta/LogUpdate.json | 1 - 5 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Components/LogUpdate/Sections/Vitals.tsx b/src/Components/LogUpdate/Sections/Vitals.tsx index 80c7325e881..44902bbf0b8 100644 --- a/src/Components/LogUpdate/Sections/Vitals.tsx +++ b/src/Components/LogUpdate/Sections/Vitals.tsx @@ -19,7 +19,7 @@ const Vitals = ({ log, onChange }: LogUpdateSectionProps) => { return (
-

{t("blood_pressure")}

+

{t("LOG_UPDATE_FIELD_LABEL__bp")}

{t("map_acronym")}: {meanArterialPressure(log.bp)?.toFixed() ?? "--"}{" "} mmHg diff --git a/src/Locale/hi/LogUpdate.json b/src/Locale/hi/LogUpdate.json index 176886c855b..9adc6a1e093 100644 --- a/src/Locale/hi/LogUpdate.json +++ b/src/Locale/hi/LogUpdate.json @@ -56,7 +56,6 @@ "HEARTBEAT_RHYTHM__REGULAR": "नियमित", "HEARTBEAT_RHYTHM__IRREGULAR": "अनियमित", "HEARTBEAT_RHYTHM__UNKNOWN": "अज्ञात", - "blood_pressure": "रक्तचाप", "map_acronym": "मानचित्र", "systolic": "सिस्टोलिक", "diastolic": "डायस्टोलिक", diff --git a/src/Locale/kn/LogUpdate.json b/src/Locale/kn/LogUpdate.json index 25e4ee4623e..188b02c3925 100644 --- a/src/Locale/kn/LogUpdate.json +++ b/src/Locale/kn/LogUpdate.json @@ -56,7 +56,6 @@ "HEARTBEAT_RHYTHM__REGULAR": "ನಿಯಮಿತ", "HEARTBEAT_RHYTHM__IRREGULAR": "ಅನಿಯಮಿತ", "HEARTBEAT_RHYTHM__UNKNOWN": "ಅಜ್ಞಾತ", - "blood_pressure": "ರಕ್ತದೊತ್ತಡ", "map_acronym": "ನಕ್ಷೆ", "systolic": "ಸಿಸ್ಟೊಲಿಕ್", "diastolic": "ಡಯಾಸ್ಟೊಲಿಕ್", diff --git a/src/Locale/ml/LogUpdate.json b/src/Locale/ml/LogUpdate.json index d2503cd8d34..f327199d509 100644 --- a/src/Locale/ml/LogUpdate.json +++ b/src/Locale/ml/LogUpdate.json @@ -56,7 +56,6 @@ "HEARTBEAT_RHYTHM__REGULAR": "പതിവ്", "HEARTBEAT_RHYTHM__IRREGULAR": "ക്രമരഹിതം", "HEARTBEAT_RHYTHM__UNKNOWN": "അജ്ഞാതം", - "blood_pressure": "രക്തസമ്മർദ്ദം", "map_acronym": "മാപ്പ്", "systolic": "സിസ്റ്റോളിക്", "diastolic": "ഡയസ്റ്റോളിക്", diff --git a/src/Locale/ta/LogUpdate.json b/src/Locale/ta/LogUpdate.json index 61a52f69d48..668dbd54a46 100644 --- a/src/Locale/ta/LogUpdate.json +++ b/src/Locale/ta/LogUpdate.json @@ -56,7 +56,6 @@ "HEARTBEAT_RHYTHM__REGULAR": "வழக்கமான", "HEARTBEAT_RHYTHM__IRREGULAR": "ஒழுங்கற்ற", "HEARTBEAT_RHYTHM__UNKNOWN": "தெரியவில்லை", - "blood_pressure": "இரத்த அழுத்தம்", "map_acronym": "வரைபடம்", "systolic": "சிஸ்டாலிக்", "diastolic": "டயஸ்டாலிக்", From 5c3a0d9ea60154cb4140f20ba8f5879a333dc29c Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Fri, 20 Sep 2024 13:08:31 +0530 Subject: [PATCH 7/8] remove hyphen from nor-adrenaline --- src/Components/LogUpdate/Sections/IOBalance.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/LogUpdate/Sections/IOBalance.tsx b/src/Components/LogUpdate/Sections/IOBalance.tsx index ca0bd4867d2..10f76581a46 100644 --- a/src/Components/LogUpdate/Sections/IOBalance.tsx +++ b/src/Components/LogUpdate/Sections/IOBalance.tsx @@ -14,7 +14,7 @@ export const IOBalanceSections = [ name: "Infusions", options: [ "Adrenalin", - "Nor-adrenalin", + "Noradrenalin", "Vasopressin", "Dopamine", "Dobutamine", From 0f1ba56027635f524145ae16e72320abd536ab04 Mon Sep 17 00:00:00 2001 From: rithviknishad Date: Fri, 20 Sep 2024 13:30:09 +0530 Subject: [PATCH 8/8] remove unused i18n key --- src/Locale/en/LogUpdate.json | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Locale/en/LogUpdate.json b/src/Locale/en/LogUpdate.json index 04b0dc281b9..53db9addb19 100644 --- a/src/Locale/en/LogUpdate.json +++ b/src/Locale/en/LogUpdate.json @@ -145,7 +145,6 @@ "pain_chart_description": "Mark region and intensity of pain", "bradycardia": "Bradycardia", "tachycardia": "Tachycardia", - "spo2": "SpO₂", "vitals": "Vitals", "procedures_select_placeholder": "Select procedures to add details", "oral_issue_for_non_oral_nutrition_route_error": "Can be specified only if nutrition route is set to Oral",