Exit From Care Functionality

At PIH, we’ve a functional request to close all a patient’s active programs when that patient is marked as dead.

This used to be handled (I believe) by the Exit from Care functionality that existed in OpenMRS Core, it looks like this has been removed? (Along with the functionality to close orders).

Was there a reason for this?

Honestly, it would likely be straightforward to build our own custom logic for this, but there’s no reason we couldn’t build it into the current “Mark Patient Deceased” page provided by Core Apps if others are interested in it.

We’d likely be building the following functionality:

When a Patient is Marked as Dead, and saved, close all programs for the patient

When a patient is marked as death, check all active programs for that patient. For all active programs with an possible outcome of “Patient Died” (could be defined by a global property), set the program to that outcome on the date of death.

Perhaps more controversially, we’d like to build this functionality as well:

When a Patient is Marked as not dead, and saved, reopen patient programs

When a patient is marked as not dead, look for any patient programs that have an outcome of “Patient Died” and outcome date = date_of_death. Remove those outcomes.

Assumedly, we’d also add some functionality to close the orders and any visit active visits for a patient, but haven’t worked out the exact logic or priority for this yet.

We would add alerts/warning to the user letting them know that this would happen.

We are talking about building this into the “Mark Patient Deceased” page provided by Core Apps (likely delegating to logic we add to EMR API or Core):

We’re happy to build this functionality into a custom PIH page if there isn’t consensus, but seems like it would be preferably to build it into the Ref App for others to use if others think it makes sense.

@burke @dkayiwa @ibacher @mseaton @mksd @ssmusoke

Take care, Mark

Thanks @mogoodrich. I would love for this to come back to Core TBH, mainly because O3 will not encompass EMR API.

Hello @mogoodrich , thanks for bring this up

In the core we currently have an API call supported by a functionality that establishes a patient has left the care center .

I see an html exitFromCare tag in the html module which may need some fine tuning.

LIke @mksd ,I would love to see this in core to :grinning:


Thanks @mogoodrich for bringing this ,i believe this functionality is worth it, One of the functionality that i think can be handled is Cause Of Death Functionality, currently in openmrs cause of death attributes are manually configurable which is becoming not straight to be configured by new implementors , i believe if we can make them available in the system them without being configured can be good and straight forward , Otherwise some of our friends find it little not straight to implement them especially am ready to hear from different suggestions thanks

1 Like

Thanks @gcliff … so the weird thing about the exit from care API method that you mentioned is that it doesn’t look like it cancels orders and closes programs anymore (even if the comments say that it should).

You can see the comments here, but following the code I don’t see where this actually happens.

Let me know if I’m missing something.

Take care, Mark

@mogoodrich are you intending to build upon the already existing processDeath method?

@dkayiwa I believe the processDeath method ends up calling the exitFromCare method… so I don’t have a clear plan in place yet, but one option would be to restore the functionality in the exitFromCare method that seems to have been removed (closing programs/discontinuing orders).

Thoughts on this?

Take care, Mark

Looks fair enough.

My thought right now is to implement the business logic for this in EMR-API, but within a new service called ExitFromCare. Then, if we think it’s suitable for Core, we could migrate this new service there and deprecate the old methods in PatientService (which I think are only used by the Legacy UI?)

What would be the disadvantage of improving the old methods by adding this missing functionality to them?


No reason not to… but we need this in 2.3.x and I wouldn’t feel comfortable backporting these changes to these methods… if people end up deciding it’s suitable for Core, we could end up just reimplementing the old methods using the functionality added to EMR-API, but it seemed like if there was an controversy, starting a new service might be cleaner…

I get you! :slight_smile:

1 Like

We have run into this problem again after upgrading PIH Malawi EMR to OpenMRS 2.3.4. After the upgrade, the users are complaining that the programs are no longer automatically closed.

@dkayiwa , @gcliff , @mksd , would you have any objections if we add a configurable property to the exitFromCare method to automatically close any active programs? By default, the exitFromCare would behave the way it is now, but if an implementation needs to automatically close active programs then they would just set this global property that automatically closes any active programs when the patient is marked as Deceased and Exited from Care. Please let me know if you have any other suggestion on how to add back this deprecated Exit From Care feature.

FYI @mogoodrich


No objection from me.

Thanks @cioan , this would work for me!

sounds awesome , :+1:

No objections from me @cioan .

Thank you @dkayiwa , @mogoodrich , @gcliff and @mksd !

Here is the ticket I opened for adding this feature back. I will follow up soon with a PR. Thanks!


1 Like