Auto expiry of Visits in Bahmni
Close Stale Visit Task
- Bahmni supports automatic closing of Visits which are open and inactive for more than 24 (configurable) hours. This is done via the Scheduler feature of OpenMRS. We use the “Close Stale Visit Task” scheduler to perform this check, and close stale visits. The class name is: “org.openmrs.module.emrapi.adt.CloseStaleVisitsTask”.
- OpenMRS also provides an out-of-box scheduler for doing this called “Auto Close Visit Tasks”. The class name is: “org.openmrs.scheduler.tasks.AutoCloseVisitsTask”. We don’t use this one, and therefore disable this, or delete its entry from OpenMRS DB.
- emrapi.visitExpireHours - The property that is read by CloseStaleVisitTasks to decide when to consider a visit as stale and close it (value in Hours). This value is set in the global_property table of OpenMRS.
- Check this commit to see the SQL Queries that need to be fired for setting this up: Visit Commit
- You can go to OpenMRS -> Administration -> Manage Scheduler (to see that the 'Close Stale Visit Task' scheduler is running).
- The "CloseStaleVisitTask" scheduler will not close any visit which has an Admit Disposition (and the patient has not yet been discharged).
The "CloseStaleVisitTask" scheduler does not allow us to choose which visit types should be closed. It works on ALL visit types (except maybe IPD since that one follows the Admin/Discharge logic). OpenMRS scheduler "Auto Close Visit Task" does support this feature (via the visits.autoCloseVisitType property, but then it isn't as "smart" as CloseStaleVisitTasks).
Expire Visit At Midnight
- If you want to expire all visits at midnight the same day the patient came you can set the CloseStaleVisitsTasks scheduler to run every 24 hours at midnight, and "emrapi.visitExpireHours" to "0" hours so that it runs every midnight, and closes all visits which are open immediately.
- In some NGOs/Orgs, in order to save electricity costs, servers may be shut down in the evening. In that case, these schedulers will not run, if they are set for midnight. Please adjust the scheduler trigger time to ensure it is triggered before server is shut down at end of the day.
The Bahmni documentation is licensed under Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)