Permalink
Browse files

PTM-87 : Functionality to Merge Patients in the report

  • Loading branch information...
Lahiru-J committed Aug 12, 2017
1 parent a327c3e commit 6ee57f19ef62eea642b18d1642c938cd2033f8ab
Showing with 1,289 additions and 99 deletions.
  1. +324 −80 api/src/main/java/org/openmrs/module/patientmatching/MatchingReportUtils.java
  2. +8 −0 api/src/main/java/org/openmrs/module/patientmatching/Report.java
  3. +37 −12 api/src/main/java/org/regenstrief/linkage/io/OpenMRSReader.java
  4. +1 −1 api/src/main/java/org/regenstrief/linkage/io/ReaderProvider.java
  5. +21 −0 api/src/main/resources/ConfigurationEntry.hbm.xml
  6. +18 −0 api/src/main/resources/MatchingRecord.hbm.xml
  7. +14 −0 api/src/main/resources/MatchingRecordAttribute.hbm.xml
  8. +23 −0 api/src/main/resources/PatientMatchingConfiguration.hbm.xml
  9. +33 −0 api/src/main/resources/Report.hbm.xml
  10. +18 −0 api/src/main/resources/ReportGenerationStep.hbm.xml
  11. +375 −0 api/src/test/java/org/openmrs/module/patientmatching/MatchingReportUtilsTest.java
  12. +68 −0 api/src/test/java/org/regenstrief/linkage/io/OpenMRSReaderTest.java
  13. +146 −0 api/src/test/resources/PatientMatchingTestDataSet.xml
  14. +59 −0 api/src/test/resources/TestingApplicationContext.xml
  15. +15 −0 api/src/test/resources/patient-matching-hibernate.cfg.xml
  16. +5 −0 omod/pom.xml
  17. +33 −1 omod/src/main/java/org/openmrs/module/patientmatching/web/dwr/DWRMatchingConfigUtilities.java
  18. +3 −1 omod/src/main/resources/config.xml
  19. +5 −2 omod/src/main/webapp/dupesList.jsp
  20. +3 −2 omod/src/main/webapp/reportForm.jsp
  21. +42 −0 omod/src/test/java/org/openmrs/module/patientmatching/web/dwr/DWRMatchingConfigUtilitiesTest.java
  22. +38 −0 omod/src/test/resources/PatientTestDataSet.xml

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -73,4 +73,12 @@ public void setUsedConfigurationList(Set<PatientMatchingConfiguration> usedConfi
public void setReportGenerationSteps(Set<ReportGenerationStep> reportGenerationSteps){
this.reportGenerationSteps = reportGenerationSteps;
}
public void addMatchingRecord(MatchingRecord matchingRecord){this.matchingRecordSet.add(matchingRecord);}
public void clearReportGenerationSteps(){this.reportGenerationSteps.clear();}
public void addReportGenerationStep(ReportGenerationStep reportGenerationStep){
this.reportGenerationSteps.add(reportGenerationStep);
}
}
@@ -9,6 +9,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Date;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -19,6 +20,7 @@
import org.hibernate.SessionFactory;
import org.hibernate.criterion.ProjectionList;
import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Restrictions;
import org.hibernate.type.StandardBasicTypes;
import org.openmrs.Patient;
import org.openmrs.PatientIdentifierType;
@@ -62,26 +64,32 @@
private Collection<String> projections;
/**
*
*/
private Date reportCreatedOn;
private List<Patient> addedUpdatedPatients;
public OpenMRSReader() {
this(null);
this(null,null);
}
public OpenMRSReader(Collection<String> projections) {
public OpenMRSReader(Collection<String> projections, Date reportCreatedOn) {
pageNumber = 0;
resultMode = MODE_PATIENT;
expand_patient = true;
if (projections != null && !projections.contains("org.openmrs.Patient.patientId")) {
projections.add("org.openmrs.Patient.patientId");
}
this.projections = projections;
log.info("Getting all patient records ...");
updatePatientList();
log.info("Finish intialization ...");
this.projections = null;
this.reportCreatedOn = reportCreatedOn;
}
public void init(){
addedUpdatedPatients = new ArrayList<Patient>();
log.info("Getting all patient records ...");
updatePatientList();
log.info("Finished initialization ...");
}
public void setExpandPatient(boolean expand){
@@ -93,6 +101,12 @@ private Criteria createCriteria(){
criteria = createHibernateSession().createCriteria(Patient.class)
.setMaxResults(PAGING_SIZE)
.setFirstResult(pageNumber * PAGING_SIZE);
// Add restriction to fetch the patients based on the date report created on
if(reportCreatedOn != null)
criteria.add(Restrictions.or(Restrictions.gt("dateCreated",reportCreatedOn),
Restrictions.gt("dateChanged",reportCreatedOn)));
if (projections != null) {
resultMode = MODE_PROJECTION;
ProjectionList projectionList = Projections.projectionList();
@@ -122,7 +136,7 @@ private Criteria createCriteria(){
}
return criteria;
}
private Session createHibernateSession() {
HibernateConnection connection = new HibernateConnection();
SessionFactory sessionFactory = connection.getSessionFactory();
@@ -228,6 +242,13 @@ private void updatePatientList() {
}
}
}
if(list.size() > 0) {
for (Object patient : list) {
addedUpdatedPatients.add((Patient) patient);
}
}
patients = list.iterator();
}
@@ -347,4 +368,8 @@ public boolean reset() {
return (patients != null);
}
public List<Patient> getAddedUpdatedPatients() {
return addedUpdatedPatients;
}
}
@@ -112,7 +112,7 @@ private Connection getConnection(LinkDataSource lds){
private DataSource getDataSource(LinkDataSource lds){
try{
String driver, url, user, passwd;
String[] access = lds.getAccess().split(",");
String[] access = lds.getAccess().split(",",-1);
driver = access[0];
url = access[1];
user = access[2];
@@ -0,0 +1,21 @@
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="org.openmrs.module.patientmatching.ConfigurationEntry" table="patientmatching_configurationEntries">
<id name="entryId" column="entry_id"
unsaved-value="0">
<generator class="identity" />
</id>
<discriminator column="entry_id" insert="false" />
<many-to-one name="patientMatchingConfiguration" class="org.openmrs.module.patientmatching.PatientMatchingConfiguration" not-null="true">
<column name="configuration_id" />
</many-to-one>
<property name="fieldViewName" column="field_view_name" length="255" unique="true" />
<property name="fieldName" column="field_name" not-null="true" />
<property name="inclusion" column="inclusion" not-null="false" />
<property name="blockOrder" column="block_order" not-null="false" />
<property name="flag" column="flag" not-null="false" />
</class>
</hibernate-mapping>
@@ -0,0 +1,18 @@
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="org.openmrs.module.patientmatching.MatchingRecord" table="patientmatching_matchingset">
<id name="setId" column="set_id" unsaved-value="0">
<generator class="identity" />
</id>
<property name="groupId" type="java.lang.Integer" column="group_id" not-null="true" />
<many-to-one name="report" class="org.openmrs.module.patientmatching.Report" not-null="true">
<column name="report_id" />
</many-to-one>
<many-to-one name="patient" column="patient_id" class="org.openmrs.Patient"/>
<property name="state" type="java.lang.String" column="state" not-null="true"/>
<set name="matchingRecordAttributeSet" lazy="true" inverse="true" cascade="all-delete-orphan" sort="natural">
<key column="matching_record_id" not-null="true"/>
<one-to-many class="org.openmrs.module.patientmatching.MatchingRecordAttribute"/>
</set>
</class>
</hibernate-mapping>
@@ -0,0 +1,14 @@
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping auto-import="false">
<class name="org.openmrs.module.patientmatching.MatchingRecordAttribute" table="patientmatching_matching_attribute">
<id name="recordAttributeId" column="record_attribute_id"
unsaved-value="0">
<generator class="identity" />
</id>
<many-to-one name="matchingRecord" class="org.openmrs.module.patientmatching.MatchingRecord" not-null="true">
<column name="matching_record_id" />
</many-to-one>
<property name="fieldName" column="field_name" length="128" />
<property name="fieldValue" column="field_value" not-null="true" length="128"/>
</class>
</hibernate-mapping>
@@ -0,0 +1,23 @@
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="org.openmrs.module.patientmatching">
<class name="PatientMatchingConfiguration" table="patientmatching_configuration">
<id name="configurationId" column="configuration_id" unsaved-value="0">
<generator class="identity" />
</id>
<property name="configurationName" column="configuration_name" length="255" unique="true" />
<property name="randomSampleSize" column="random_sample_size" not-null="true" />
<property name="usingRandomSample" column="using_random_sample" not-null="true"/>
<property name="estimatedPairs" column="estimated_pairs" not-null="true"/>
<property name="estimatedTime" column="estimated_time" not-null="true"/>
<property name="totalRecords" column="total_records" not-null="true"/>
<!-- bi-directional one-to-many association -->
<set name="configurationEntries" lazy="true" inverse="true" cascade="all-delete-orphan" sort="natural">
<key column="configuration_id" not-null="true" />
<one-to-many class="org.openmrs.module.patientmatching.ConfigurationEntry" />
</set>
</class>
</hibernate-mapping>
@@ -0,0 +1,33 @@
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping auto-import="false">
<class name="org.openmrs.module.patientmatching.Report" table="patientmatching_report">
<id name="reportId" column="report_id"
unsaved-value="0">
<generator class="identity" />
</id>
<property name="reportName" column="report_name" length="255" />
<property name="createdOn" type="java.util.Date" column="created_on" not-null="true" length="19"/>
<many-to-one name="createdBy" class="org.openmrs.User">
<column name="created_by" />
</many-to-one>
<set name="matchingRecordSet" lazy="true" inverse="true" cascade="all-delete-orphan" sort="natural">
<key column="report_id" not-null="true"/>
<one-to-many class="org.openmrs.module.patientmatching.MatchingRecord"/>
</set>
<set name="reportGenerationSteps" lazy="true" inverse="true" cascade="all-delete-orphan" sort="natural">
<key column="report_id" not-null="true"/>
<one-to-many class="org.openmrs.module.patientmatching.ReportGenerationStep"/>
</set>
<set name="usedConfigurationList" table="patientmatching_report_configuration" cascade="none">
<key column="report_id"/>
<many-to-many column="configuration_id"
class="org.openmrs.module.patientmatching.PatientMatchingConfiguration"/>
</set>
</class>
</hibernate-mapping>
@@ -0,0 +1,18 @@
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="org.openmrs.module.patientmatching.ReportGenerationStep" table=" patientmatching_report_generation_step">
<id name="stepId" type="int" column="step_id"
unsaved-value="0">
<generator class="identity" />
</id>
<many-to-one name="report" class="org.openmrs.module.patientmatching.Report" not-null="true">
<column name="report_id" />
</many-to-one>
<property name="processName" type="java.lang.String" column="process_name" length="50" />
<property name="sequenceNo" type="java.lang.Integer" column="sequence_number" not-null="true" />
<property name="timeTaken" type="java.lang.Integer" column="time_taken" not-null="false" />
</class>
</hibernate-mapping>
Oops, something went wrong.

0 comments on commit 6ee57f1

Please sign in to comment.