diff --git a/src/Components/Common/BloodPressureFormField.tsx b/src/Components/Common/BloodPressureFormField.tsx index 53c4adf2194..3f057c7fd4f 100644 --- a/src/Components/Common/BloodPressureFormField.tsx +++ b/src/Components/Common/BloodPressureFormField.tsx @@ -1,3 +1,5 @@ +import { useTranslation } from "react-i18next"; +import { properRoundOf } from "../../Utils/utils"; import { FieldValidator } from "../Form/FieldValidators"; import FormField from "../Form/FormFields/FormField"; import RangeAutocompleteFormField from "../Form/FormFields/RangeAutocompleteFormField"; @@ -11,6 +13,7 @@ import { BloodPressure } from "../Patient/models"; type Props = FormFieldBaseProps; export default function BloodPressureFormField(props: Props) { + const { t } = useTranslation(); const field = useFormFieldPropsResolver(props); const handleChange = (event: FieldChangeEvent) => { @@ -18,30 +21,26 @@ export default function BloodPressureFormField(props: Props) { ...field.value, [event.name]: event.value, }; - value.mean = meanArterialPressure(value); field.onChange({ name: field.name, value }); }; - const map = - !!props.value?.diastolic && - !!props.value.systolic && - meanArterialPressure(props.value); + const map = props.value && meanArterialPressure(props.value); return ( MAP: {map.toFixed(1)} + MAP: {map} ) : undefined, }} >
/ { if (diastolic != null && systolic != null) { - return (2 * diastolic + systolic) / 3; + return properRoundOf((2 * diastolic + systolic) / 3); } }; export const BloodPressureValidator: FieldValidator = (bp) => { - if (Object.values(bp).every((v) => v == null)) { - return; - } - if (bp.diastolic == null) { - return "Diastolic is missing. Either specify both or clear both."; - } - if (bp.systolic == null) { - return "Systolic is missing. Either specify both or clear both."; + if (Object.values(bp).some((v) => v == null)) { + return "blood_pressure_missing_attrs"; } }; diff --git a/src/Components/Facility/Consultations/PrimaryParametersPlot.tsx b/src/Components/Facility/Consultations/PrimaryParametersPlot.tsx index ca01ac1b113..60f882d3a0e 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) => p.bp && meanArterialPressure(p.bp)) .reverse(), }, ]; diff --git a/src/Components/Facility/models.tsx b/src/Components/Facility/models.tsx index 3f060240ee7..cd07e19e162 100644 --- a/src/Components/Facility/models.tsx +++ b/src/Components/Facility/models.tsx @@ -403,9 +403,8 @@ export type PrimaryParametersPlotFields = export type PrimaryParametersPlotRes = { bp: { - mean?: number; - systolic?: number; - diastolic?: number; + systolic: number; + diastolic: number; }; pulse: number; temperature: string; diff --git a/src/Components/LogUpdate/CriticalCarePreview.tsx b/src/Components/LogUpdate/CriticalCarePreview.tsx index 00cbb47f69e..f9a74ea51ae 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; @@ -201,7 +202,7 @@ export default function CriticalCarePreview(props: Props) {
)} diff --git a/src/Components/LogUpdate/Sections/Vitals.tsx b/src/Components/LogUpdate/Sections/Vitals.tsx index 796575e4145..9f1755e4413 100644 --- a/src/Components/LogUpdate/Sections/Vitals.tsx +++ b/src/Components/LogUpdate/Sections/Vitals.tsx @@ -1,11 +1,10 @@ +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"; @@ -15,12 +14,13 @@ import PainChart from "../components/PainChart"; import { LogUpdateSectionMeta, LogUpdateSectionProps } from "../utils"; 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 }); }; @@ -28,26 +28,26 @@ const Vitals = ({ log, onChange }: LogUpdateSectionProps) => {

Blood Pressure

- MAP: {(log.bp?.mean && properRoundOf(log.bp.mean)) || "--"} + MAP: {(log.bp && meanArterialPressure(log.bp)) || "--"}
{ bp: { systolic: undefined, diastolic: undefined, - mean: undefined, }, - // bed: null, }; const initError = Object.assign( @@ -247,7 +245,7 @@ export const DailyRounds = (props: any) => { case "bp": { const error = BloodPressureValidator(state.form.bp); if (error) { - errors.bp = error; + errors.bp = t(error); invalidForm = true; scrollTo("bloodPressure"); } diff --git a/src/Components/Patient/models.tsx b/src/Components/Patient/models.tsx index 5387e457e9e..8af1e9cc9b9 100644 --- a/src/Components/Patient/models.tsx +++ b/src/Components/Patient/models.tsx @@ -288,7 +288,6 @@ export const DailyRoundTypes = [ export interface BloodPressure { diastolic?: number; - mean?: number; systolic?: number; } diff --git a/src/Components/Scribe/formDetails.ts b/src/Components/Scribe/formDetails.ts index 736ab971744..93d88d172cb 100644 --- a/src/Components/Scribe/formDetails.ts +++ b/src/Components/Scribe/formDetails.ts @@ -129,7 +129,7 @@ const DAILY_ROUND_FORM_SCRIBE_DATA: Field[] = [ { friendlyName: "bp", id: "bp", - default: { systolic: null, diastolic: null, mean: null }, + default: { systolic: null, diastolic: null }, type: "{ systolic?: number, diastolic?: number }", example: "{ systolic: 120 }", description: diff --git a/src/Locale/en/Common.json b/src/Locale/en/Common.json index 656791c3788..0f774a34349 100644 --- a/src/Locale/en/Common.json +++ b/src/Locale/en/Common.json @@ -192,5 +192,8 @@ "discard": "Discard", "live": "Live", "discharged": "Discharged", - "archived": "Archived" -} + "archived": "Archived", + "normal": "Normal", + "low": "Low", + "high": "High" +} \ No newline at end of file diff --git a/src/Locale/en/LogUpdate.json b/src/Locale/en/LogUpdate.json index 319a87bd8d8..39ec3515188 100644 --- a/src/Locale/en/LogUpdate.json +++ b/src/Locale/en/LogUpdate.json @@ -52,5 +52,8 @@ "NURSING_CARE_PROCEDURE__chest_tube_care": "Chest Tube Care", "NURSING_CARE_PROCEDURE__tracheostomy_care": "Tracheostomy Care", "NURSING_CARE_PROCEDURE__stoma_care": "Stoma Care", - "NURSING_CARE_PROCEDURE__catheter_care": "Catheter Care" + "NURSING_CARE_PROCEDURE__catheter_care": "Catheter Care", + "blood_pressure_missing_attrs": "Both systolic and diastolic is required", + "systolic": "Systolic", + "diastolic": "Diastolic" } \ No newline at end of file