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

(fix) O3-2825: Medications that have been discontinued should have a "Discontinued" label #1691

Closed
wants to merge 27 commits into from

Conversation

jwnasambu
Copy link
Contributor

@jwnasambu jwnasambu commented Feb 23, 2024

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

I modified the tableRows mapping function to conditionally add the "Discontinued" label based on whether the medication is discontinued or modified. To achieve this, I added a new constant isDiscontinued to check if the medication is discontinued then conditionally render the "Discontinued" label only when isDiscontinued is true. This way, the label will be displayed only for discontinued medications and not for modified.

Screenshots

screencast.2024-07-02.9.PM-50-36.mp4

Related Issue

(https://openmrs.atlassian.net/jira/software/c/projects/O3/issues/O3-2825)

Other

@jwnasambu jwnasambu marked this pull request as draft February 23, 2024 00:44
@brandones brandones changed the title '(fix)O3-2825:Addressing Medication Status Ambiguity in Past Medications (fix) O3-2825:Addressing Medication Status Ambiguity in Past Medications Jun 21, 2024
Copy link
Contributor

@brandones brandones left a comment

Choose a reason for hiding this comment

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

@jwnasambu, why is this in draft? Does it work?

@@ -131,6 +139,9 @@ const MedicationsDetailsTable: React.FC<ActiveMedicationsProps> = ({
{formatDate(new Date(medication.dateStopped))}
</span>
) : null}
{isMedicationDiscontinued(medication) && !isMedicationModified(medication) && (
Copy link
Contributor

Choose a reason for hiding this comment

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

Just inline the function definitions. Don't write one-line functions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@brandones Oh sorry for the late response! I have been sick that is the reason of my late response. The reason it was in draft is because I was informed the design was still in discussion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@brandones am on it right now.

Copy link
Contributor

@njiddasalifu njiddasalifu left a comment

Choose a reason for hiding this comment

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

looks okay, except for the oneline func as mention by Brandone.

@brandones brandones changed the title (fix) O3-2825:Addressing Medication Status Ambiguity in Past Medications (fix) O3-2825: Medications that have been discontinued should have a "Discontinued" label Jun 28, 2024
@brandones brandones marked this pull request as ready for review June 28, 2024 19:50
@brandones
Copy link
Contributor

@jwnasambu I think we should go ahead with this. Slack link for posterity.

Please make the fix I requested (you said "on it right now" two days ago, what happened?) and then we'll get this in.

@jwnasambu
Copy link
Contributor Author

jwnasambu commented Jul 1, 2024

@brandones you are right! its the very night I fell again again and it was more worse but am back to my feet again. Thanks for holding me accountable.

@jwnasambu
Copy link
Contributor Author

@brandones , @denniskigen, @samuelmale, @ibacher kind help please! for the sake of sharing my blocker, I modified the function to this:

{medication.dateStopped != null && !medication.hasOwnProperty('modified') && (
  <span className={styles.label01}> &mdash; {t('discontinued', 'Discontinued').toUpperCase()}</span>
)}

instead of :

{medication.dateStopped != null && medication.modified && (
  <span className={styles.label01}> &mdash; {t('modified', 'Modified').toUpperCase()}</span>
)}
{medication.dateStopped != null && !medication.modified && (
  <span className={styles.label01}> &mdash; {t('discontinued', 'Discontinued').toUpperCase()}</span>
)}


to check for the modified property.

Apparently, the label "Discontinued" is displayed if the medication has a dateStopped and does not have a modified property. I am not certain if the modified property is meant to be void in OpenMRS and that is why it is not appearing on the type order https://github.com/openmrs/openmrs-esm-patient-chart/blob/main/packages/esm-patient-common-lib/src/orders/types.ts hence displaying "Discontinued" label irrespective of the medication being modified or discontinued is both actions are determined by endDate.

@@ -135,6 +135,9 @@ const MedicationsDetailsTable: React.FC<ActiveMedicationsProps> = ({
{formatDate(new Date(medication.dateStopped))}
</span>
) : null}
{medication.dateStopped != null && !medication.hasOwnProperty('modified') && (
Copy link
Member

Choose a reason for hiding this comment

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

@jwnasambu Where does the medication.modified property come from? That isn't part of the backend module and I don't see it being added in the frontend? Discontinued orders should have action property set to DISCONTINUED I think...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ibacher Kindly let me begin from here .

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ibacher, after console logging the medication and checking the array properties, I didn't see anything like modified property. However, after careful consideration, I conclude that the endDate in this context is used to display medication details, specifically to show when a medication order was stopped, which suits both modified and discontinued statuses. Kindly I stand to be corrected.

Copy link
Member

Choose a reason for hiding this comment

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

I don't know that it's guaranteed that dateStopped will always be set. That is, it will be set for medications that have been discontinued, but maybe not for those with a autoStopDate (sp. of property).

) : null}
{medication.dateStopped ? (
)}
{(medication.dateStopped || medication.autoStopDate) && (
Copy link
Member

Choose a reason for hiding this comment

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

If we're checking autoStopDate, we need to ensure that it's actually passed. This property can be set prior to the medication being stopped.

@denniskigen denniskigen marked this pull request as draft July 17, 2024 20:18
@denniskigen
Copy link
Member

I've set this to draft because @dkayiwa is exploring a potential regression in the backend that's causing discontinued orders to have the incorrect action property (NEW instead of DISCONTINUE).

@dkayiwa
Copy link
Member

dkayiwa commented Jul 17, 2024

The order end point calls an API method that is designed not to return discontinued orders: https://github.com/openmrs/openmrs-core/blob/2.6.7/api/src/main/java/org/openmrs/api/OrderService.java#L228

If we are sure that we want to include discontinued orders, and be backwards compatible, we would create a new parameter for the end point to also includeDiscontinuedOrders and then call a new API method which was introduced in platform 2.2 https://github.com/openmrs/openmrs-core/blob/2.6.7/api/src/main/java/org/openmrs/api/OrderService.java#L268

@ibacher
Copy link
Member

ibacher commented Jul 18, 2024

@dkayiwa Awesome! I think we do need that parameter for this use-case. The other part that's a little disconcerting is that the DISCONTINUE order doesn't actually seem to be discontinuing the order, i.e., we consistently get an order with the action of NEW returned from the API. Is this something like the DISCONTINUE needs to be submitted as a PUT rather than POST?

@dkayiwa
Copy link
Member

dkayiwa commented Jul 18, 2024

@ibacher the order is actually discontinued and a second row is created in the database with the action of DISCONTINUE together with a corresponding date_stopped. But when the end point is doing the get, it only fetches this old/original row and leaves out the one created as a result of the discontinuation.

@jwnasambu
Copy link
Contributor Author

@dkayiwa, @denniskigen, @ibacher For accountability purposes I created a ticket on this link https://openmrs.atlassian.net/browse/RESTWS-951 though it's still in need assessment status.

@dkayiwa
Copy link
Member

dkayiwa commented Aug 1, 2024

Thanks @jwnasambu 👍

@dkayiwa
Copy link
Member

dkayiwa commented Aug 27, 2024

@jwnasambu can you change the url by doing two things:

Remove the &status=ACTIVE parameter

Change the orderType parameter to orderTypes

And hence end up with something like this below:

/openmrs/ws/rest/v1/order?patient=025b4433-efa2-4eab-9473-748a1cf34222&careSetting=6f0c9a92-6f24-11e3-af88-005056821db0&orderTypes=131168f4-15f5-102d-96e4-000c29c2a5d7&v=custom:(uuid,dosingType,orderNumber,accessionNumber,patient:ref,action,careSetting:ref,previousOrder:ref,dateActivated,scheduledDate,dateStopped,autoExpireDate,orderType:ref,encounter:ref,orderer:(uuid,display,person:(display)),orderReason,orderReasonNonCoded,orderType,urgency,instructions,commentToFulfiller,drug:(uuid,display,strength,dosageForm:(display,uuid),concept),dose,doseUnits:ref,frequency:ref,asNeeded,asNeededCondition,quantity,quantityUnits:ref,numRefills,dosingInstructions,duration,durationUnits:ref,route:ref,brandName,dispenseAsWritten)

@jwnasambu
Copy link
Contributor Author

jwnasambu commented Aug 28, 2024

@dkayiwa with the latest commit this is what I have. I am so sorry for the late commitment my internet is very bad
Screenshot 2024-08-28 at 11 30 47 PM

@dkayiwa
Copy link
Member

dkayiwa commented Aug 28, 2024

@jwnasambu is there anything wrong that you see with it?

@jwnasambu
Copy link
Contributor Author

@dkayiwa let me look at it again.

@jwnasambu
Copy link
Contributor Author

@jwnasambu is there anything wrong that you see with it?

@dkayiwa I have removed the status parameter the function since its no longer in use.

@dkayiwa
Copy link
Member

dkayiwa commented Aug 28, 2024

@jwnasambu in other words, after doing as i advised above, are you able to get the data that you had wanted?

@jwnasambu
Copy link
Contributor Author

@jwnasambu in other words, after doing as i advised above, are you able to get the data that you had wanted?

@dkayiwa Yes I do have all the the data. Though, the patient ID in the URL is not the same as the one you share which is understandable since every patient in the OpenMRS system has a unique identifier the rest of the data is the same.

@dkayiwa
Copy link
Member

dkayiwa commented Aug 28, 2024

The patient id is just an example. Replace it with the relevant value.

@jwnasambu
Copy link
Contributor Author

@dkayiwa I am somehow confused about what I am missing out. Based on the discussion during the coffee break I think I have what you requested. Kindly I stand to be corrected.

@dkayiwa
Copy link
Member

dkayiwa commented Aug 29, 2024

If you have done what i requested, then that is all.

@jwnasambu
Copy link
Contributor Author

@denniskigen Thanks for everything as we discussed during the coffee break, I am closing this PR and Reference it to the new PR.

@jwnasambu jwnasambu closed this Sep 26, 2024
@brandones
Copy link
Contributor

@jwnasambu please link the new 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.

6 participants