-
Notifications
You must be signed in to change notification settings - Fork 245
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-4084: Implement numeric validation for lab results entry form #2061
Conversation
Size Change: -6.97 kB (-0.05%) Total Size: 14.8 MB ℹ️ View Unchanged
|
Thanks, @donaldkibet for working on this. I support the approach you have implemented and I propose that we also update the displayed result ranges accordingly. Similar to the implementation here, we probably should show the hiAbsolute and lowAbsolute only if they are defined. The current implementation, IIRC, gets the minimum of the defined LOW ranges and maximum of the defined HIGH ranges. The gap is mostly when not all the ranges are defined resulting in false HIGH or LOW ranges. Borrowing from the PR description, we should:
These are just my thoughts and we can benefit more from other people's perspectives. |
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.
Thanks @donaldkibet for adding this much needed validation. I have no objections to this PR because typically the ranges cover all the valid entries and will avoid entry of wrong data.
The only concern would be if typically the specified ranges configured accommodate edge cases as you also mentioned in the PR description. Wouldn't there be scenarios where the the entered value would be critically high/low and prevent data entry due to failing validation?
But if there ranges already have that in account then it's all good. Maybe the people with more medical knowledge like @gracepotma can advise on this.
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.
Approach looks good. There are a couple of very technical issues with the implementation here, but should be easy to fix.
if (lowerLimit === null && upperLimit === null) { | ||
return baseSchema; | ||
} |
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.
Shouldn't the check here be for undefined
rather than null
? The typings imply that these variables can never be null.
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.
I'm under the impression that what we accept here should be driven by what the backend actually returns, i.e., if we're always setting these values to null
(as in the tests), then the types here should be number | null
and I guess the code works as-is. If the backend doesn't return values for those, then the types should be as-written, but the code updated. The safest option would be to just explicitly support number | null | undefined
and then be sure to check for undefined.
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.
Thanks, @ibacher
packages/esm-patient-orders-app/src/lab-results/useLabResultsFormSchema.tsx
Outdated
Show resolved
Hide resolved
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.
Looks good! I've left a few minor comments.
packages/esm-patient-orders-app/src/lab-results/useLabResultsFormSchema.tsx
Outdated
Show resolved
Hide resolved
packages/esm-patient-orders-app/src/lab-results/lab-results.resource.ts
Outdated
Show resolved
Hide resolved
packages/esm-patient-orders-app/src/lab-results/lab-results-form.test.tsx
Outdated
Show resolved
Hide resolved
packages/esm-patient-orders-app/src/lab-results/lab-results-form.test.tsx
Outdated
Show resolved
Hide resolved
packages/esm-patient-orders-app/src/lab-results/lab-results-form.test.tsx
Show resolved
Hide resolved
packages/esm-patient-orders-app/src/lab-results/lab-results-form.test.tsx
Outdated
Show resolved
Hide resolved
packages/esm-patient-orders-app/src/lab-results/lab-results-form.test.tsx
Outdated
Show resolved
Hide resolved
packages/esm-patient-orders-app/src/lab-results/lab-results-form.test.tsx
Outdated
Show resolved
Hide resolved
packages/esm-patient-orders-app/src/lab-results/lab-results-form.test.tsx
Outdated
Show resolved
Hide resolved
packages/esm-patient-orders-app/src/lab-results/lab-results-form.component.tsx
Outdated
Show resolved
Hide resolved
Merging this in since failing e2e test failing isn't associated with this change. |
…rm (openmrs#2061) * (feat) O3-4084 : implement numeric validation for lab results entry form * code reviews changes * additional code review changes
Requirements
Summary
See https://openmrs.atlassian.net/browse/O3-4084
I have implemented the validation logic as follows:
hiAbsolute
andlowAbsolute
as they represent the max and min thresholds supported by the backend.I have not used the critical high or low values for validation because there are cases where values might fall outside of their ranges. should we leverage these values for validation. cc @ibacher @makombe @ojwanganto @denniskigen @CynthiaKamau
Screenshots
Related Issue
Other