-
Notifications
You must be signed in to change notification settings - Fork 248
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-4087: Enable input for set-based lab tests on lab results form and handle partial set results #2062
Conversation
Size Change: +391 B (0%) Total Size: 14.8 MB ℹ️ View Unchanged
|
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! Nice work and once again, only some nitpicking on my part.
@@ -157,3 +158,69 @@ export async function updateOrderResult( | |||
} | |||
throw new Error('Failed to update order'); | |||
} | |||
|
|||
export function createObservationPayload(concept: LabOrderConcept, order: Order, values: any) { |
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 always suspicious of explicitly using any
, especially when the code here implies a rather specific shape, namely that values
is that values is something like Record<string, unknown>
, which would be much better to use.
We should likewise type the sub functions here as this helps ensure the correctness of the code.
} | ||
|
||
if (!concept.set && concept.setMembers.length === 0) { |
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.
Why not just use else
or else if
?
if (concept.set && concept.setMembers.length > 0) { | ||
const groupMembers = concept.setMembers | ||
.map((member) => createGroupMember(member, order, values)) | ||
.filter((member) => member?.value !== null && member?.value !== 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.
.filter((member) => member?.value !== null && member?.value !== undefined); | |
.filter((member) => member !== null && member.value !== null && member.value !== undefined); |
function createObservation(order, groupMembers = null, value = null) { | ||
return { | ||
concept: { uuid: order.concept.uuid }, | ||
status: 'FINAL', |
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.
Ideally, eventually, this would be something the user can define.
return null; | ||
} | ||
|
||
if (['Numeric', 'Text'].includes(datatype.display)) { |
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.
This is actually a case where using display
is incorrect. display
is a user-facing property because its localizable, but because its localizable, we cannot rely on it's value being English. In this case, the "correct" value is (for historical reasons) hl7Abbreviation
, but name
is less likely to be wrong.
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.
hl7Abbreviation
is something like:
Datatype | Code |
---|---|
Coded | CWE |
Text | ST |
Numeric | NM |
bd0ecae
to
83a7d24
Compare
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.
Great work, @donaldkibet!
packages/esm-patient-orders-app/src/lab-results/lab-results.resource.ts
Outdated
Show resolved
Hide resolved
…form and handle partial set results
…orm and handle partial set results (openmrs#2062) * (feat) O3-4087 : enable input for set-based lab tests on lab results form and handle partial set results * code reviews changes * additional code review changes
Requirements
Summary
See https://openmrs.atlassian.net/browse/O3-4087
In this PR, I have updated the logic for generating lab observation (obs) values:
Non-set lab order concepts: If the lab order concept is not a set, we generate the payload. If no values are present for the concept, we return an empty array.
Set member lab order concepts: For concepts that are part of a set, we only return observation payloads for set members that have values. This ensures that incomplete results (missing values for some set members) do not affect the generation process.
Screenshots
Related Issue
Other