-
Notifications
You must be signed in to change notification settings - Fork 59
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-3316 Add support for encounter diagnosis #298
base: main
Are you sure you want to change the base?
Conversation
Size Change: -252 kB (-18.04%) 👏 Total Size: 1.15 MB
ℹ️ View Unchanged
|
const saveDiagnoses = await EncounterFormManager.saveDiagnosis(fields, savedEncounter); | ||
if (saveDiagnoses) { | ||
showSnackbar({ | ||
title: t('encounterDiagnosisSaved', 'Encounter diagnosis saved successfully'), | ||
kind: 'success', | ||
isLowContrast: true, | ||
}); | ||
} |
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.
So the EncounterResource supports diagnoses as a create-able property shouldn't we be creating the diagnoses in a single transaction with the encounter?
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.
Let me add it the same way we handle orders
@CynthiaKamau Ping, are you still working on this? Any blockers? |
Yes, there some fixes that need to be done on the backend to complete the work |
@CynthiaKamau Please provide links to the work or issues you're talking about. If there is no linkable issue/PR/talk/Slack, please tell us what work needs to be completed before this can move forward. |
This is the link to the backend pr |
Ok @CynthiaKamau , looks like that backend PR is merged. Can we move forward with this? |
a40ba8d
to
2415c6d
Compare
Im working on it now |
e5de3c9
to
63ad98e
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.
Nice work @CynthiaKamau! Are you planning on adding some test coverage?
@@ -300,6 +304,27 @@ export async function hydrateRepeatField( | |||
}), | |||
); | |||
} | |||
|
|||
//handle diagnoses | |||
const unMappedDiagnosis = encounter.diagnoses.filter((diagnosis) => { |
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.
const unMappedDiagnosis = encounter.diagnoses.filter((diagnosis) => { | |
const unMappedDiagnoses = encounter.diagnoses.filter((diagnosis) => { |
@@ -28,6 +29,7 @@ export function prepareEncounter( | |||
const obsForSubmission = []; | |||
prepareObs(obsForSubmission, formFields); | |||
const ordersForSubmission = prepareOrders(formFields); | |||
const diagnosisForSubmission = prepareDiagnosis(formFields); |
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.
const diagnosisForSubmission = prepareDiagnosis(formFields); | |
const diagnosesForSubmission = prepareDiagnosis(formFields); |
context: FormProcessorContextProps, | ||
): Promise<any> { | ||
const availableDiagnoses = sourceObject ?? (context.domainObjectValue as OpenmrsEncounter); | ||
const matchedDiagnosis = availableDiagnoses.diagnoses?.find( |
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.
const matchedDiagnosis = availableDiagnoses.diagnoses?.find( | |
const matchedDiagnoses = availableDiagnoses.diagnoses?.find( |
@@ -166,6 +166,7 @@ export class EncounterFormProcessor extends FormProcessor { | |||
try { | |||
const { data: savedEncounter } = await saveEncounter(abortController, encounter, encounter.uuid); | |||
const saveOrders = savedEncounter.orders.map((order) => order.orderNumber); | |||
const saveDiagnosis = savedEncounter.diagnoses.map((diagnosis) => diagnosis.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.
const saveDiagnosis = savedEncounter.diagnoses.map((diagnosis) => diagnosis.display); | |
const savedDiagnoses = savedEncounter.diagnoses.map((diagnosis) => diagnosis.display); |
@@ -237,3 +240,19 @@ function handleQuestionsWithObsComments(sectionQuestions: Array<FormField>): Arr | |||
|
|||
return augmentedQuestions; | |||
} | |||
|
|||
function handleDiagnosesDataSource(question: FormField) { |
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 would simply name this: handleDiagnosis(...)
63ad98e
to
bc33d5d
Compare
bc33d5d
to
089214e
Compare
sourceObject: OpenmrsResource, | ||
context: FormProcessorContextProps, | ||
): Promise<any> { | ||
const availableDiagnoses = sourceObject ?? (context.domainObjectValue as OpenmrsEncounter); |
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.
const availableDiagnoses = sourceObject ?? (context.domainObjectValue as OpenmrsEncounter); | |
const encounter = sourceObject ?? (context.domainObjectValue as OpenmrsEncounter); |
context: FormProcessorContextProps, | ||
): Promise<any> { | ||
const availableDiagnoses = sourceObject ?? (context.domainObjectValue as OpenmrsEncounter); | ||
const matchedDiagnoses = availableDiagnoses.diagnoses.find( |
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.
const matchedDiagnoses = availableDiagnoses.diagnoses.find( | |
const matchedDiagnosis = availableDiagnoses.diagnoses.find( |
}, | ||
]; | ||
|
||
describe('EncounterDiagnosesAdapter', () => { |
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.
Can you add test case(s) around:
- editing a value and the fact that the edited value gets voided
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.
@CynthiaKamau I discovered a bug while testing the entire feature.
Issue: When you delete a diagnosis (using the form repeat controls) and launch the form again in edit mode, the deleted diagnosis still exists, meaning it was never voided. This is partly why I requested the tests.
@@ -166,6 +166,7 @@ export class EncounterFormProcessor extends FormProcessor { | |||
try { | |||
const { data: savedEncounter } = await saveEncounter(abortController, encounter, encounter.uuid); | |||
const saveOrders = savedEncounter.orders.map((order) => order.orderNumber); | |||
const saveDiagnoses = savedEncounter.diagnoses.map((diagnosis) => diagnosis.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.
const saveDiagnoses = savedEncounter.diagnoses.map((diagnosis) => diagnosis.display); | |
const savedDiagnoses = savedEncounter.diagnoses.map((diagnosis) => diagnosis.display); |
(I would also rename saveOrders
-> savedOrders
)
// handle diagnoses | ||
if (saveDiagnoses.length) { | ||
showSnackbar({ | ||
title: translateFn('diagnosisSaved', 'Diagnosis(s) saved successfully'), |
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.
title: translateFn('diagnosisSaved', 'Diagnosis(s) saved successfully'), | |
title: translateFn('diagnosisSaved', 'Diagnosis(es) saved successfully'), |
@@ -300,6 +304,40 @@ export async function hydrateRepeatField( | |||
}), | |||
); | |||
} | |||
|
|||
const unMappedDiagnoses = encounter.diagnoses.filter((diagnosis) => { | |||
return !assignedDiagnosesIds.includes(diagnosis?.diagnosis?.coded.uuid); |
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 think the Diagnosis should include the field's ID in it's formFieldPath
otherwise we may end up including past diagnoses.
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.
@CynthiaKamau did you see this?
sortedDiagnoses | ||
.filter((diagnosis) => !diagnosis.voided) | ||
.map(async (diagnosis) => { | ||
const clone = cloneRepeatField(field, diagnosis, counter++); |
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.
Can you add a demo where we capture diagnoses with "repeat controls"?
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.
Done
Ping @samuelmale |
@brandones I left a few more comments for @CynthiaKamau |
Requirements
Summary
This feature attempts to introduce encounter diagnosis in RFE
Current RFE Schema :
Proposed schema as in AFE :
Screenshots
Screen.Recording.2024-10-02.at.15.21.51.mov
Related Issue
Other