In hospital workaday life it happens to be that in 1% of the treatments multiple accounts are created for a single patient. Thus the treatment history is spread over different accounts and needs to be merged.
I tried to find it out how this can be done with Bahmni but got stuck. Can you please give me some hints how it can be achieved? If it’s not yet supported, what would be the entry point for the implementation and installation of custom apps?
What I tried so far
Access the “Data Quality Dashboard” in Bahmni
The Bahmni Feature Guide shows a screenshot of a “Data Quality Dashboard” which might
be used for this purpose. Unfortunatly, I cannot figure out how to use this feature.
The only trace I could find of it in the source code was in the “endtb-config” repository (patientListPrint.html).
So I tried to install Bahmni with the EndTB config but it failed due to a SQL constraint
violation in the “implementation-config.yml” task (see install steps, error message and full console output).
The link to the openmrs-module-bahmnidataintegrity GitHub repository, which I found in the thread where the development of the Data Integrity feature is being discussed is not valid any-more. So I have no idea yet how to install/access the data quality dashboard.
Access the Data Quality Dashboard directly in OpenMRS
Bahmni actively doesn’t use/support merging of duplicate patients feature. However you can achieve that by using Patient matching module provided by openmrs. Please refer to the wiki link from openmrs.
https://wiki.openmrs.org/display/docs/Patient+Matching+Module
Data quality dashboard is more related to patient data like if a patient is having wrong data recorded or any important patient data is missing while entering the data against him/her. It is not used for merging the patient records.
Now the module can be installed in the Manage Modules section of OpenMRS. Click on the “Add or Upgrade Module” button, select the downloaded “omod” file and the click on the “Upload” button.
Click on “Create a new strategy” and select e.g. “(Address) City / Village”, “(Name) Family Name”, “(Name) Given Name” as “Should Match” and “(Patient) Gender” as “Must Match”. Fill in a strategy name at the top and then click the “Save” button on the bottom.
Now we can go to the “Create Report” menu, select the created strategy and then click on the “Generate Report” button.
The report will then show up in the “Available Reports” section. After clicking on “View Report” a new window will open which allows us to select patient accounts and then we can click on the “Merge GroupId X” button.
Then the patients can be merged by clicking on the “Merge Patients” button.
A more detailed description can be found in the OpenMRS Wiki. A description of the algorithm used to identify matching patient records can be found there as well.
Problems with the patient merging
Unfortunatly, I ran into two problems.
(1) After clicking on the “Merge GroupId X” button the browser tries to request OpenMRS hosted by link.regenstrief.org. As workaround I copied the URL and inserted my local hostname.
(2) When I then click on the “Merge Patients” button this will lead to an error page.
An Internal Error has Occurred
org.hibernate.exception.ConstraintViolationException
could not insert: [org.openmrs.PatientIdentifier]
I’ll have to investigate this later. Any tips are appriciated. (I have installed Bahmni 0.83 with CentOS 6.8 hosted on VirtualBox.)
23-11-2016 01:57:56 [ERROR] JDBCExceptionReporter - Duplicate entry 'GAN200007' for key 'unique_patient_identifier'
Nov 23, 2016 1:57:56 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [openmrs] in context with path [openmrs] threw exception [Request processing failed; nested exception is org.hibernate.exception.ConstraintViolationException: could not insert: [org.openmrs.PatientIdentifier]] with root cause
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry 'GAN200007' for key 'unique_patient_identifier'
...
at org.openmrs.api.db.hibernate.HibernateUserDAO.getUsersByPerson(HibernateUserDAO.java:500)
at org.openmrs.api.impl.UserServiceImpl.getUsersByPerson(UserServiceImpl.java:427)
...
at org.openmrs.web.controller.patient.MergePatientsFormController.onSubmit(MergePatientsFormController.java:99)
at org.openmrs.web.controller.patient.MergePatientsFormController.processFormSubmission(MergePatientsFormController.java:64)
...
Interestingly, the patient merging via the MergePatientsFormController was part of the OpenMRS core project and was removed a year ago with this commit.
Yes, kind of. Thank you for this link! I am happy to see that this feature is included in the OpenMRS core as it seems like exactly what my friend requested. Unfortunately, I am still getting a similar error message.
23-11-2016 03:22:07 [ERROR] JDBCExceptionReporter - Duplicate entry 'GAN200013' for key 'unique_patient_identifier'
Nov 23, 2016 3:22:07 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [openmrs] in context with path [openmrs] threw exception [Request processing failed; nested exception is org.hibernate.exception.ConstraintViolationException: could not insert: [org.openmrs.PatientIdentifier]] with root cause
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry 'GAN200013' for key 'unique_patient_identifier'
...
at org.openmrs.api.db.hibernate.HibernateUserDAO.getUsersByPerson(HibernateUserDAO.java:500)
at org.openmrs.api.impl.UserServiceImpl.getUsersByPerson(UserServiceImpl.java:427)
...
at org.openmrs.api.impl.PatientServiceImpl.mergeAddresses(PatientServiceImpl.java:1132)
at org.openmrs.api.impl.PatientServiceImpl.mergePatients(PatientServiceImpl.java:817)
at org.openmrs.api.impl.PatientServiceImpl.mergePatients(PatientServiceImpl.java:1565)
...
What comes to my mind now is that the duplicate entry GAN200013 is the patient ID from Bahmni. While PatientServiceImpl#mergePatients merges all sorts of things the Bahmni ID seems like still not considered.
The Bahmni installation with which I experienced the error described above is v0.83. I have started the installation from scratch with Bahmni 0.86 and now the patient merging works via the link from Daniel Kayiwa.
I guess the reason is that this snippet was not yet included in the Bahmni 0.83 distribution:
<changeSet id="201607281228" author="Preethi, Gaurav">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="1">
SELECT count(*) FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE TABLE_NAME='patient_identifier' AND CONSTRAINT_NAME='unique_patient_identifier';
</sqlCheck>
</preConditions>
<comment>Drop unique constraint on identifier column in patient_identifier table</comment>
<sql>
ALTER TABLE patient_identifier DROP INDEX unique_patient_identifier;
</sql>
</changeSet>