Hi all (particularly @burke and others who worked on the Order Entry API) ,
I’ve been working a bit with the Order Entry API lately, and am trying to best understand how and when to use the REVISE and RENEW order actions and when to void previous Orders.
In the old 1.9 API, orders could be edited, and applications existed (in various modules, core, htmlformentry, etc) that provided a means to do so. Most of the time, Orders were just edited in place, though if one desired they could have written code to void the previous Order and create a new Order. Unlike with Obs, this was not enforced or built into the OpenMRS API for Ordering in 1.9.
In the current system, Orders are immutable, and a subsequent REVISE, RENEW, or DISCONTINUE order is needed to modify an existing Order. Alternatively, one could simply void an existing Order, and then issue a fresh NEW Order for the same orderable with the revised details, though it is unclear how and when this would be considered the right practice. I’m trying to figure out how to support Order editing functionality in htmlformentry and elsewhere, and when to use these particular approaches.
Initially, I figured it was most appropriate to use the REVISE action whenever editing an active Order. However, working with the OrderService API, I’ve run into a few questions. Here is the code in question:
if (REVISE == order.getAction()) {
if (previousOrder == null) {
throw new MissingRequiredPropertyException("Order.previous.required", (Object[]) null);
}
stopOrder(previousOrder, aMomentBefore(order.getDateActivated()), isRetrospective);
} else if (DISCONTINUE == order.getAction()) {
discontinueExistingOrdersIfNecessary(order, isRetrospective);
}
Questions:
-
If I edit an Encounter and revise the details of an Order within that Encounter (so the dateActivated of both the previous and new Order are the same - inherited from the encounterDatetime), this would seem to modify the existing Order so that the stopDate is a moment before the dateActivated. Is this what we want? It would seem like in this case we really would be better off voiding the existing Order and creating a new Order. Is REVISE really appropriate for this use case? Should our API handle this case differently (either via validation rules or logic to void rather than stop where appropriate)?
-
If I issue a REVISE order, intending to make a future change (eg. in 3 days I want the current order to close and a new order to start) is this an appropriate use of the API? If so, current API seemingly will not work, as it always sets the previous Order stopDate to the dateActivated of the new Order, not to the effectiveStartDate of the new Order (which accounts for scheduled orders as well).
-
I don’t see any API support for a RENEW order, though presumably one could code it into their own methods. How is RENEW meant to differ from REVISE, if REVISE works as in the code above? What is the meaningful difference between RENEW and REVISE, from an end-user or application design perspective?
Thanks! Mike