diff --git a/client/src/Components/FormMultiField.js b/client/src/Components/FormMultiField.js new file mode 100644 index 00000000..dddae54e --- /dev/null +++ b/client/src/Components/FormMultiField.js @@ -0,0 +1,21 @@ +import React from 'react'; +import './FormMultiField.scss'; + +const FormMultiField = ({ label, children }) => { + return ( + <> + {label} +
+ {children.map((child) => { + return ( +
+ {child} +
+ ); + })} +
+ + ); +}; + +export default FormMultiField; diff --git a/client/src/EMS/BloodPressureField.scss b/client/src/Components/FormMultiField.scss similarity index 85% rename from client/src/EMS/BloodPressureField.scss rename to client/src/Components/FormMultiField.scss index 646cdabe..af6bf0e0 100644 --- a/client/src/EMS/BloodPressureField.scss +++ b/client/src/Components/FormMultiField.scss @@ -1,12 +1,12 @@ @import '../theme/base'; -.bpfield { +.multi-field { display: flex; gap: 0.6rem; position: relative; } -.bpfield__input { +.multi-field__input { .grid-row { flex-wrap: nowrap; } diff --git a/client/src/EMS/BloodPressureField.js b/client/src/EMS/BloodPressureField.js index 09ac9811..f143171b 100644 --- a/client/src/EMS/BloodPressureField.js +++ b/client/src/EMS/BloodPressureField.js @@ -5,7 +5,7 @@ import { ValidationState } from '../Models/PatientFieldData'; import FormInput from '../Components/FormInput'; import { useForm } from '../Components/Form'; -import './BloodPressureField.scss'; +import FormMultiField from '../Components/FormMultiField'; function BPInput({ metadata, unit }) { const { data, onChange } = useForm(); @@ -18,18 +18,16 @@ function BPInput({ metadata, unit }) { // grouped with its input in a div because the fields are arranged horizontally // in a row. since the errors are absolutely positioned, they'd both shift to // the left margin of the .bpfield without this extra div, causing an overlap. -
- -
+ ); } @@ -39,15 +37,16 @@ export default function BloodPressureField({ systolicMetadata, diastolicMetadata const hasError = validations.includes(ValidationState.RANGE_ERROR); return ( - <> - -
- - -
- + + Blood pressure + + } + > + + + ); } diff --git a/client/src/EMS/PatientFields.js b/client/src/EMS/PatientFields.js index 3c486287..78d0a5a8 100644 --- a/client/src/EMS/PatientFields.js +++ b/client/src/EMS/PatientFields.js @@ -12,6 +12,7 @@ import Ringdown from '../Models/Ringdown'; import ApiService from '../ApiService'; import Context from '../Context'; import patient from '../../../shared/metadata/patient'; +import TemperatureField from './TemperatureField'; const Patient = patient.getFieldHash(); @@ -157,7 +158,7 @@ function PatientFields({ ringdown, onChange }) { /> - + diff --git a/client/src/EMS/TemperatureField.js b/client/src/EMS/TemperatureField.js new file mode 100644 index 00000000..6e470d7f --- /dev/null +++ b/client/src/EMS/TemperatureField.js @@ -0,0 +1,61 @@ +import React, { useState } from 'react'; +import { useForm } from '../Components/Form'; +import FormInput from '../Components/FormInput'; + +import { ValidationState } from '../Models/PatientFieldData'; +import classNames from 'classnames'; + +import FormMultiField from '../Components/FormMultiField'; + +const TemperatureInput = ({ metadata, unit, onChange, value }) => { + const { data } = useForm(); + const { name, range = {} } = metadata || {}; + const { min, max } = range; + + return ( + + ); +}; + +const TemperatureField = ({ temperatureMetadata }) => { + const { data, onChange } = useForm(); + const [celsius, setCelsius] = useState(''); + const celsiusMetadata = { name: 'celsius', unit: '°C', range: { min: 26.5, max: 65.5 } }; + + const hasError = data.getValidationState(temperatureMetadata.name) === ValidationState.RANGE_ERROR; + + const handleOnChange = (name, value) => { + if (name === 'celsius') { + onChange('temperature', (parseFloat(value) * 1.8 + 32).toFixed(2)); + setCelsius(value); + } else { + onChange(name, value); + setCelsius(((parseFloat(value) - 32) / 1.8).toFixed(2)); + } + }; + return ( + <> + + Temperature + + } + > + + + + + ); +}; + +export default TemperatureField;