diff --git a/src/hooks/useConcepts.ts b/src/hooks/useConcepts.ts index d6f2d217..e844c2cc 100644 --- a/src/hooks/useConcepts.ts +++ b/src/hooks/useConcepts.ts @@ -5,7 +5,7 @@ import { type FetchResponse, type OpenmrsResource, openmrsFetch, restBaseUrl } f type ConceptFetchResponse = FetchResponse<{ results: Array }>; const conceptRepresentation = - 'custom:(uuid,display,conceptClass:(uuid,display),answers:(uuid,display),conceptMappings:(conceptReferenceTerm:(conceptSource:(name),code)))'; + 'custom:(units,lowAbsolute,hiAbsolute,uuid,display,conceptClass:(uuid,display),answers:(uuid,display),conceptMappings:(conceptReferenceTerm:(conceptSource:(name),code)))'; export function useConcepts(references: Set): { concepts: Array | undefined; diff --git a/src/hooks/useFormFieldsMeta.ts b/src/hooks/useFormFieldsMeta.ts index 973b7ae0..fd360fee 100644 --- a/src/hooks/useFormFieldsMeta.ts +++ b/src/hooks/useFormFieldsMeta.ts @@ -11,6 +11,20 @@ export function useFormFieldsMeta(rawFormFields: FormField[], concepts: OpenmrsR const matchingConcept = findConceptByReference(field.questionOptions.concept, concepts); field.questionOptions.concept = matchingConcept ? matchingConcept.uuid : field.questionOptions.concept; field.label = field.label ? field.label : matchingConcept?.display; + if(matchingConcept) + { + if(matchingConcept.units) + { + field.label = field.label + " (" + matchingConcept.units + ")"; + } + if(matchingConcept.lowAbsolute && matchingConcept.hiAbsolute) + { + field.label = field.label + " (" + matchingConcept.lowAbsolute + "-" + matchingConcept.hiAbsolute + ")"; + field.questionOptions.min = matchingConcept.lowAbsolute; + field.questionOptions.max = matchingConcept.hiAbsolute; + } + } + if ( codedTypes.includes(field.questionOptions.rendering) && !field.questionOptions.answers?.length &&