From 035c318b9b10ec5268a570625466a491824505dc Mon Sep 17 00:00:00 2001 From: D-matz Date: Sat, 21 Dec 2024 16:02:58 -0600 Subject: [PATCH] get units, absolute high, absolute low from concept api, add (units) (min-max) to label and min/max to form --- src/hooks/useConcepts.ts | 2 +- src/hooks/useFormFieldsMeta.ts | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) 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 &&