Skip to content
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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

D-matz
Copy link

@D-matz D-matz commented Dec 21, 2024

Add (unit) (min-max) to label, validate input against concept min/max

https://openmrs.atlassian.net/browse/O3-4201

Related: https://openmrs.atlassian.net/browse/O3-4122

4122 also suggests a warning for values within the absolute range but outside normal or critical range. Looking for suggestions on how to implement that, and how to add a test case for a concept with units and min/max

Requirements

  • This PR has a title that briefly describes the work done including the ticket number. If there is a ticket, make sure your PR title includes a conventional commit label. See existing PR titles for inspiration.
  • My work conforms to the OpenMRS 3.0 Styleguide and design documentation.
  • My work includes tests or is validated by existing tests.

Summary

Screenshots

Related Issue

Other

@D-matz
Copy link
Author

D-matz commented Dec 21, 2024

@samuelmale @ibacher please let me know if you had other approaches in mind for this or issues
lower
within

greater

Copy link
Member

@samuelmale samuelmale left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add some test coverage asserting that the units and labels are incorporated in the label?

{
if(matchingConcept.units)
{
field.label = field.label + " (" + matchingConcept.units + ")";
Copy link
Member

Choose a reason for hiding this comment

The 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)} />}

Copy link
Author

Choose a reason for hiding this comment

The 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
min0

leaving critical alone for now

Copy link
Member

@ibacher ibacher Jan 9, 2025

Choose a reason for hiding this comment

The 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 >= 0 or <= 100 things like that. (Note that "Min" is hard to support because now that's a string that needs to be translated).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

min1

unfortunately it splits the label onto a new line, but the format should match the chart lab result format

Copy link
Member

Choose a reason for hiding this comment

The 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.

@@ -5,7 +5,7 @@ import { type FetchResponse, type OpenmrsResource, openmrsFetch, restBaseUrl } f
type ConceptFetchResponse = FetchResponse<{ results: Array<OpenmrsResource> }>;

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)))';
Copy link
Member

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 vs lowCritical?

Copy link
Member

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 and hiAbsolute 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 and hiAbsolute 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).

Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants