diff --git a/src/components/records/patient/PatientForm.tsx b/src/components/records/patient/PatientForm.tsx index 4568b6c..4bf847e 100644 --- a/src/components/records/patient/PatientForm.tsx +++ b/src/components/records/patient/PatientForm.tsx @@ -10,7 +10,6 @@ import { VillageOptionDropdown } from '@/components/VillageOptionDropdown'; import { VillageContext } from '@/context/VillageContext'; import { getPatientAge } from '@/types/Patient'; import { VillagePrefix } from '@/types/VillagePrefixEnum'; -import { EMPTY_VITAL } from '@/types/Vital'; import { DateTime } from 'luxon'; import { FormEventHandler, useContext } from 'react'; import { Controller, useFormContext } from 'react-hook-form'; @@ -91,16 +90,8 @@ export function PatientForm({ /> )} /> - - + + - {!isEditing && (
- -

Vitals

- -

Child Vitals

- {showChildVitals ? (
- {/*
*/} -
- - -
- - (field[0].gender == undefined || field[0].gender == gender) && - field[0].age.includes(age) - )} + {!isEditing && ( +
+ +

Vitals

+ +

Child Vitals

+ {showChildVitals ? ( +
+ {/*
*/} +
+ + +
+ + (field[0].gender == undefined || + field[0].gender == gender) && + field[0].age.includes(age) + )} + /> +
+ ) : ( +

+ {age ? 'Not within child age range' : 'Age not specified'} +

+ )}
- ) : ( -

- {age ? "Not within child age range" : "Age not specified"} -

- )} -
)} ; - curVital: Vital; }) { const patientYearsOld = getPatientAge(patient).year; @@ -269,7 +267,8 @@ export function ChildVitalsFields({ () => allPubertyFields .filter( - field => field[0].gender == undefined || field[0].gender == patient.gender + field => + field[0].gender == undefined || field[0].gender == patient.gender ) .filter(field => field[0].age.includes(patientYearsOld)), [patient.gender, patientYearsOld] @@ -277,17 +276,11 @@ export function ChildVitalsFields({ return (
{childVitalsFields.length == 0 || ( - + )} {pubertyFields.length == 0 || ( - + )}
); @@ -295,10 +288,8 @@ export function ChildVitalsFields({ function ChildVitalsSection({ childVitalsFields, - curVital, }: { childVitalsFields: InputFieldData[]; - curVital: Vital; }) { return (
@@ -306,11 +297,7 @@ function ChildVitalsSection({
{/*
*/} {childVitalsFields.map(field => ( - + ))}
@@ -319,10 +306,8 @@ function ChildVitalsSection({ export function ChildPubertySection({ pubertyFields, - curVital, }: { pubertyFields: InputFieldData[][]; - curVital: Vital; }) { return (
@@ -335,18 +320,16 @@ export function ChildPubertySection({ {/*
*/} {pubertyFields.map(field => ( //
-
+
- +
))}
@@ -357,46 +340,21 @@ export function ChildPubertySection({ function VitalFieldRenderer({ field, - curVital, - className + className, }: { field: InputFieldData; - curVital: Vital; className?: string; }) { switch (field.type) { case 'dropdown': - return ( - - ); + return ; case 'text': - return ( - - ); + return ; case 'number': - return ( - - ); + return ; case 'yesNoOption': return ( - + ); } } diff --git a/src/components/records/vital/VitalsForm.tsx b/src/components/records/vital/VitalsForm.tsx index 4c00020..fde30e5 100644 --- a/src/components/records/vital/VitalsForm.tsx +++ b/src/components/records/vital/VitalsForm.tsx @@ -27,6 +27,7 @@ export function VitalsForm({ const useFormReturn = useForm({ mode: 'onBlur', reValidateMode: 'onBlur', + defaultValues: curVital, }); const { handleSubmit, reset, watch } = useFormReturn; const [formHeight, formWeight] = watch(['height', 'weight']); @@ -36,7 +37,9 @@ export function VitalsForm({ // the new values in curVitals. The RHFCustomSelect and Dropdown components will have // their values set to these new values via the defaultValue prop. useEffect(() => { - reset({}) + if (curVital) { + reset(curVital); + } }, [curVital, reset]) // if the user hasn’t provided a new height/weight, fall back @@ -217,7 +220,7 @@ export function VitalsForm({ options={['Yes', 'No']} />
- +

Other notes