Add Parameter to Include Discontinued Orders in API Endpoint
Description
The current API endpoint for retrieving orders does not return discontinued orders. This behavior is due to the endpoint calling an API method (getActiveOrders) that is designed to exclude discontinued orders. For backward compatibility and to address use cases that require including discontinued orders, a new parameter includeDiscontinuedOrders should be added to the endpoint. The endpoint should then call the appropriate API method (getOrdersIncludingDiscontinued) introduced in platform 2.2.
Steps to Reproduce:
Call the existing orders endpoint.
Observe that orders with a DISCONTINUE action are not included in the response .i.e. the DISCONTINUE order does not appear to be discontinuing the order properly. Instead of seeing an order with a DISCONTINUE action, we consistently get an order with the action of NEW.Upon investigation, it was found that a new row with the action DISCONTINUE and a corresponding date_stopped is created in the database. However, the endpoint fetches only the original row with the action NEW, leaving out the discontinued row.
Proposed Solution:
Add a new parameter includeDiscontinuedOrders to the orders endpoint.
Modify the endpoint logic to call getOrdersIncludingDiscontinued when includeDiscontinuedOrders is set to true.
Ensure that both active and discontinued orders are returned in the response when the parameter is used.
Investigate and fix the issue where the DISCONTINUE order is not being processed correctly by the endpoint, ensuring the discontinuation action and corresponding date are included in the response.
Environment:
OpenMRS Platform 2.2 and above
Affected version: openmrs 3.0[The entire discussion is on this PR ]
Activity
Juliet Wamalwa August 27, 2024 at 6:13 PM
am so sorry for the late response I was in the middle of a bug fix. Kindly am happy to work on it and present tomorrow during the coffee break.
The current API endpoint for retrieving orders does not return discontinued orders. This behavior is due to the endpoint calling an API method (
getActiveOrders
) that is designed to exclude discontinued orders. For backward compatibility and to address use cases that require including discontinued orders, a new parameterincludeDiscontinuedOrders
should be added to the endpoint. The endpoint should then call the appropriate API method (getOrdersIncludingDiscontinued
) introduced in platform 2.2.Steps to Reproduce:
Call the existing orders endpoint.
Observe that orders with a
DISCONTINUE
action are not included in the response .i.e. theDISCONTINUE
order does not appear to be discontinuing the order properly. Instead of seeing an order with aDISCONTINUE
action, we consistently get an order with the action ofNEW
.Upon investigation, it was found that a new row with the actionDISCONTINUE
and a correspondingdate_stopped
is created in the database. However, the endpoint fetches only the original row with the actionNEW
, leaving out the discontinued row.Proposed Solution:
Add a new parameter
includeDiscontinuedOrders
to the orders endpoint.Modify the endpoint logic to call
getOrdersIncludingDiscontinued
whenincludeDiscontinuedOrders
is set totrue
.Ensure that both active and discontinued orders are returned in the response when the parameter is used.
Investigate and fix the issue where the
DISCONTINUE
order is not being processed correctly by the endpoint, ensuring the discontinuation action and corresponding date are included in the response.Environment:
OpenMRS Platform 2.2 and above
Affected version: openmrs 3.0[The entire discussion is on this PR ]