-
Notifications
You must be signed in to change notification settings - Fork 221
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
Conversation
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.
@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) && ( |
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.
Just inline the function definitions. Don't write one-line functions.
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.
@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.
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.
@brandones am on it right now.
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 okay, except for the oneline func as mention by Brandone.
@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. |
@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. |
@brandones , @denniskigen, @samuelmale, @ibacher kind help please! for the sake of sharing my blocker, I modified the function to this:
instead of :
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 |
@@ -135,6 +135,9 @@ const MedicationsDetailsTable: React.FC<ActiveMedicationsProps> = ({ | |||
{formatDate(new Date(medication.dateStopped))} | |||
</span> | |||
) : null} | |||
{medication.dateStopped != null && !medication.hasOwnProperty('modified') && ( |
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.
@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...
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.
@ibacher Kindly let me begin from here .
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.
@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.
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 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).
Code refactor Add a logic for medications that are automatically stopped
591113e
to
a1cb70d
Compare
) : null} | ||
{medication.dateStopped ? ( | ||
)} | ||
{(medication.dateStopped || medication.autoStopDate) && ( |
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.
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.
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 |
The 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 |
@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 |
@ibacher the order is actually discontinued and a second row is created in the database with the action of |
@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 |
Thanks @jwnasambu 👍 |
@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:
|
@dkayiwa with the latest commit this is what I have. I am so sorry for the late commitment my internet is very bad |
@jwnasambu is there anything wrong that you see with it? |
@dkayiwa let me look at it again. |
@dkayiwa I have removed the status parameter the function since its no longer in use. |
@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. |
The patient id is just an example. Replace it with the relevant value. |
@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. |
If you have done what i requested, then that is all. |
@denniskigen Thanks for everything as we discussed during the coffee break, I am closing this PR and Reference it to the new PR. |
@jwnasambu please link the new PR |
Requirements
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