@@ -14,18 +14,38 @@ import ApiService from '../ApiService';
1414import Context from '../Context' ;
1515
1616const INPUT_RANGES = {
17+ age : { min : 0 , max : 130 } ,
1718 systolicBloodPressure : { min : 90 , max : 180 } ,
1819 diastolicBloodPressure : { min : 60 , max : 120 } ,
1920 heartRateBpm : { min : 40 , max : 200 } ,
2021 respiratoryRate : { min : 12 , max : 25 } ,
2122 oxygenSaturation : { min : 0 , max : 100 } ,
2223 temperature : { min : 80 , max : 150 } ,
24+ glasgowComaScale : { min : 3 , max : 15 } ,
2325} ;
2426
2527function getRange ( property , extreme ) {
2628 return INPUT_RANGES [ property ] ? INPUT_RANGES [ property ] [ extreme ] : null ;
2729}
2830
31+ // use prop-spreading here because all we're doing is defaulting some props and letting the rest
32+ // pass through to FormInput
33+ function NumericField ( { property, size = 'small' , min = getRange ( property , 'min' ) , max = getRange ( property , 'max' ) , ...props } ) {
34+ return (
35+ < FormInput
36+ property = { property }
37+ size = { size }
38+ min = { min }
39+ max = { max }
40+ type = "number"
41+ /* eslint-disable-next-line react/jsx-props-no-spreading */
42+ { ...props }
43+ />
44+ ) ;
45+ }
46+
47+ NumericField . propTypes = FormInput . propTypes ;
48+
2949function PatientFields ( { ringdown, onChange } ) {
3050 const [ ambulanceIds , setAmbulanceIds ] = useState ( [ ] ) ;
3151 const [ dispatchCallNumbers , setDispatchCallNumbers ] = useState ( [ ] ) ;
@@ -91,27 +111,24 @@ function PatientFields({ ringdown, onChange }) {
91111 < Heading title = "Patient Info" />
92112 < div className = "usa-accordion__content" >
93113 < fieldset className = "usa-fieldset" >
94- < FormInput
95- label = "Age (estim.)"
96- onChange = { handleUserInput }
114+ < NumericField
115+ label = "Age (estimated)"
97116 property = "age"
98- required
99- size = "small"
100- type = "number"
101117 unit = "years"
102118 value = { ringdown . age }
119+ required
103120 validationState = { ringdown . getValidationState ( 'age' ) }
121+ onChange = { handleUserInput }
104122 />
105123 </ fieldset >
106124 < FormRadioFieldSet labelText = "Gender Identity" property = "sex" isRequired validationState = { ringdown . getValidationState ( 'sex' ) } >
107- < FormRadio currentValue = { ringdown . sex } label = "Male" onChange = { handleUserInput } property = "sex" value = "MALE" />
108- < FormRadio currentValue = { ringdown . sex } label = "Female" onChange = { handleUserInput } property = "sex" value = "FEMALE" />
109- < FormRadio currentValue = { ringdown . sex } label = "Non-binary" onChange = { handleUserInput } property = "sex" value = "NON-BINARY" />
125+ < FormRadio currentValue = { ringdown . sex } label = "Male" property = "sex" value = "MALE" onChange = { handleUserInput } />
126+ < FormRadio currentValue = { ringdown . sex } label = "Female" property = "sex" value = "FEMALE" onChange = { handleUserInput } />
127+ < FormRadio currentValue = { ringdown . sex } label = "Non-binary" property = "sex" value = "NON-BINARY" onChange = { handleUserInput } />
110128 </ FormRadioFieldSet >
111129 < FormRadioFieldSet
112130 labelText = "Urgency"
113131 property = "emergencyServiceResponseType"
114- isRequired
115132 validationState = { ringdown . getValidationState ( 'emergencyServiceResponseType' ) }
116133 >
117134 < FormRadio
@@ -127,7 +144,7 @@ function PatientFields({ ringdown, onChange }) {
127144 onChange = { handleUserInput }
128145 property = "emergencyServiceResponseType"
129146 value = "CODE 3"
130- disabled = { window . env . REACT_APP_DISABLE_CODE_3 === 'true' }
147+ disabled
131148 />
132149 </ FormRadioFieldSet >
133150 < fieldset className = "usa-fieldset" >
@@ -166,67 +183,34 @@ function PatientFields({ ringdown, onChange }) {
166183 />
167184 </ FormRadioFieldSet >
168185 </ div >
169- < Heading title = "Vitals" subtitle = "( optional) " />
186+ < Heading title = "Vitals" subtitle = "optional" />
170187 < div className = "usa-accordion__content" >
171188 < fieldset className = "usa-fieldset" >
172- < FormInput
189+ < NumericField
173190 label = "Blood Pressure"
174- onChange = { handleUserInput }
175191 property = "systolicBloodPressure"
176- size = "small"
177- type = "number"
178192 unit = "/"
179- min = { getRange ( 'systolicBloodPressure' , 'min' ) }
180- max = { getRange ( 'systolicBloodPressure' , 'max' ) }
181193 value = { ringdown . systolicBloodPressure }
194+ onChange = { handleUserInput }
182195 >
183196 < span className = "usa-hint usa-hint--unit" > </ span >
184- < FormInput
185- onChange = { handleUserInput }
197+ < NumericField
186198 isWrapped = { false }
187199 property = "diastolicBloodPressure"
188- size = "small"
189- type = "number"
190200 unit = "mmHg"
191- min = { getRange ( 'diastolicBloodPressure' , 'min' ) }
192- max = { getRange ( 'diastolicBloodPressure' , 'max' ) }
193201 value = { ringdown . diastolicBloodPressure }
202+ onChange = { handleUserInput }
194203 />
195- </ FormInput >
196- < FormInput
197- label = "Pulse"
198- onChange = { handleUserInput }
199- property = "heartRateBpm"
200- size = "small"
201- type = "number"
202- unit = "bpm"
203- min = { getRange ( 'heartRateBpm' , 'min' ) }
204- max = { getRange ( 'heartRateBpm' , 'max' ) }
205- value = { ringdown . heartRateBpm }
206- />
207- < FormInput
204+ </ NumericField >
205+ < NumericField label = "Pulse" property = "heartRateBpm" unit = "beats/min" value = { ringdown . heartRateBpm } onChange = { handleUserInput } />
206+ < NumericField
208207 label = "Respiratory Rate"
209- onChange = { handleUserInput }
210208 property = "respiratoryRate"
211- size = "small"
212- type = "number"
213- min = { getRange ( 'respiratoryRate' , 'min' ) }
214- max = { getRange ( 'respiratoryRate' , 'max' ) }
215- unit = "breath/m"
209+ unit = "breaths/min"
216210 value = { ringdown . respiratoryRate }
217- />
218- < FormInput
219- label = "SpO2"
220211 onChange = { handleUserInput }
221- property = "oxygenSaturation"
222- size = "small"
223- type = "number"
224- unit = "%"
225- pattern = "[0-9]*"
226- min = { getRange ( 'oxygenSaturation' , 'min' ) }
227- max = { getRange ( 'oxygenSaturation' , 'max' ) }
228- value = { ringdown . oxygenSaturation }
229212 />
213+ < NumericField label = "SpO2" property = "oxygenSaturation" unit = "%" value = { ringdown . oxygenSaturation } onChange = { handleUserInput } />
230214 < div className = "padding-left-4" >
231215 < FormRadio
232216 currentValue = { ringdown . lowOxygenResponseType }
@@ -240,40 +224,38 @@ function PatientFields({ ringdown, onChange }) {
240224 < FormRadio
241225 currentValue = { ringdown . lowOxygenResponseType }
242226 disabled = { ringdown . oxygenSaturation === null || ringdown . oxygenSaturation === '' }
243- label = "O2"
227+ label = {
228+ < span >
229+ O< sub > 2</ sub >
230+ </ span >
231+ }
244232 onChange = { handleUserInput }
245233 property = "lowOxygenResponseType"
246234 value = "SUPPLEMENTAL OXYGEN"
247235 />
248236 < div className = "margin-left-4" >
249- < FormInput
250- disabled = { ringdown . lowOxygenResponseType !== 'SUPPLEMENTAL OXYGEN' }
251- onChange = { handleUserInput }
237+ < NumericField
252238 property = "supplementalOxygenAmount"
253- size = "small"
254- type = "number"
255239 unit = "L"
240+ disabled = { ringdown . lowOxygenResponseType !== 'SUPPLEMENTAL OXYGEN' }
256241 value = { ringdown . supplementalOxygenAmount }
242+ onChange = { handleUserInput }
257243 />
258244 </ div >
259245 </ div >
260246 </ div >
261- < FormInput
262- label = "Temp."
263- onChange = { handleUserInput }
264- property = "temperature"
265- size = "small"
266- type = "number"
267- min = { getRange ( 'temperature' , 'min' ) }
268- max = { getRange ( 'temperature' , 'max' ) }
269- unit = "°F"
270- value = { ringdown . temperature }
271- />
247+ < NumericField label = "Temp." property = "temperature" unit = "°F" value = { ringdown . temperature } onChange = { handleUserInput } />
272248 </ fieldset >
273249 </ div >
274- < Heading title = "Additional notes " subtitle = "( optional) " />
250+ < Heading title = "Additional Notes " subtitle = "optional" />
275251 < div className = "usa-accordion__content" >
276252 < fieldset className = "usa-fieldset" >
253+ < FormTextArea
254+ label = "Treatments administered"
255+ property = "treatmentNotes"
256+ value = { ringdown . treatmentNotes }
257+ onChange = { handleUserInput }
258+ />
277259 < FormCheckbox
278260 currentValue = { ringdown . etohSuspectedIndicator }
279261 label = "ETOH suspected"
@@ -319,14 +301,19 @@ function PatientFields({ ringdown, onChange }) {
319301 property = "covid19SuspectedIndicator"
320302 value = { true }
321303 />
322- < FormCheckbox
323- currentValue = { ringdown . ivIndicator }
324- label = "IV started"
304+ < NumericField
305+ label = "GCS"
306+ property = "glasgowComaScale"
307+ unit = "/ 15"
308+ value = { ringdown . glasgowComaScale }
309+ onChange = { handleUserInput }
310+ />
311+ < FormTextArea
312+ label = "Other"
313+ property = "otherObservationNotes"
314+ value = { ringdown . otherObservationNotes }
325315 onChange = { handleUserInput }
326- property = "ivIndicator"
327- value = { true }
328316 />
329- < FormTextArea label = "Other" onChange = { onChange } property = "otherObservationNotes" value = { ringdown . otherObservationNotes } />
330317 </ fieldset >
331318 </ div >
332319 </ div >
0 commit comments