Orders are not correctly voided when an Encounter is voided

Description

The OrderService.voidOrder method has some custom business logic baked into it to address the fact that voiding an order may have an impact on any "previousOrder" that it closed.  Specifically it has this logic - see OrderServiceImpl:voidOrder(Order, String):

When operating on Orders directly, this works as intended.

The authors of the EncounterService.voidEncounter(Encounter, String) clearly saw the need to delegate down to the service methods for nested objects, as there is this logic in place in that method:

However, in practice, we find that when an Encounter is voided, neither of the ObsService.voidObs or OrderService.voidOrder methods are ever getting called, and although the associated Orders end up voided, the logic responsible for "un-stopping" previous orders is never executed.

The reason for this is that our AOP-based "RequireDataAdvice" executes prior to the method execution of EncounterService.voidEncounter, and pre-emptively and recusively voids all nested properties of Encounter that implement Voidable.  So by the time the above method is executed, all of the Obs or Orders are voided, and the voided check ensures that the associated service method call is never invoked.

The simplest solution would be to remove the voided check around both Obs and Orders, and call the void method on each regardless of whether the object is already voided or not.  We can tweak the logic of the downstream voidXyz service methods to not update the voidedBy and dateVoided (and possibly voidReason) properties if they are already populated, if that is the reason why this check exists.

Other solutions welcome - , , ,  let me know if there are any thoughts or concerns.   FYI.

Activity

Show:

Mike Seaton April 29, 2021 at 6:05 PM

Daniel Kayiwa April 28, 2021 at 5:31 PM

Mike Seaton April 28, 2021 at 3:06 PM

I have a PR issued here against 2.3.x:  https://github.com/openmrs/openmrs-core/pull/3759

 /  or others FYI

Mike Seaton April 26, 2021 at 11:12 PM

Thanks for the quick reply .  Sorry - I didn't see anything on Talk.  I'll grab this one from you if you haven't already worked on it.

Jessie Anker April 26, 2021 at 11:04 PM

 I have looked at the issue and I do have questions about it. I believe I sent you a message over OpenMRS Talk. I am still working out what exactly I need to do, so if this issue needs to be completed in a timely manner I can look for a different issue to work on?

Fixed

Details

Assignee

Reporter

Complexity

Low

Priority

Created March 9, 2021 at 3:13 PM
Updated April 29, 2021 at 6:15 PM
Resolved April 29, 2021 at 6:15 PM