-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(feat) O3-4201: Enhance Number Question Labels Display Unit and Range (Min/Max) from Concept #454
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 + ")"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This potentially breaks i18n workflows because it mutates the field's label which is implicitly used as the translation key. Since the concept is stored under the field's meta, this can safely be done within the number component post label translation; something like: <NumberInput
id={field.id}
label={<FieldLabel field={field} customLabel={t(field.label) + extractFieldUnitsAndRange(field.meta.concept)} />} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @samuelmale thanks, moved the units and range to the number component. Also for a concept that defines min but not max it looks like leaving critical alone for now There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should harmonize the view here to what we're doing here, which is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I mean, that was always going to be a possibility... This just made it apparent for that one case. |
||
} | ||
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 && | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ibacher when is it necessary to use
hiCritical
vslowCritical
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of the values that aren't
lowAbsolute
andhiAbsolute
are basically only for displaying concerning results (outside the normal range, but inside the critical range) or critical results (outside the critical range, but within the absolute range). Does that make sense?lowAbsolute
andhiAbsolute
should be rare and only in cases where the value can never exceed that range (e.g., SpO2 is a percent, so it's always between 0 and 100; heights and weights should never be a negative number, things like that).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But we can handle critical icons in a separate PR.