← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8569: Allow to search anonymous events with one many values for one attribute.

 

------------------------------------------------------------
revno: 8569
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-10-18 11:58:55 +0700
message:
  Allow to search anonymous events with one many values for one attribute.
modified:
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java	2012-10-16 09:52:43 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java	2012-10-18 04:58:55 +0000
@@ -375,9 +375,13 @@
             }
             else if ( column.isIdentifierType() )
             {
-                sql += "(select identifier from patientidentifier where patientid=p.patientid and patientidentifiertypeid="
-                    + column.getIdentifier() + ") as identifier_" + column.getIdentifier() + ",";
-
+                String deKey = "identifier_" + column.getIdentifier();
+                if ( !deKeys.contains( deKey ) )
+                {
+                    sql += "(select identifier from patientidentifier where patientid=p.patientid and patientidentifiertypeid="
+                        + column.getIdentifier() + ") as identifier_" + column.getIdentifier() + ",";
+                }
+                
                 if ( column.hasQuery() )
                 {
                     where += operator + "lower(identifier_" + column.getIdentifier() + ") " + column.getQuery() + " ";
@@ -386,8 +390,12 @@
             }
             else if ( column.isDynamicAttribute() )
             {
-                sql += "(select value from patientattributevalue where patientid=p.patientid and patientattributeid="
-                    + column.getIdentifier() + ") as attribute_" + column.getIdentifier() + ",";
+                String deKey = "attribute_" + column.getIdentifier();
+                if ( !deKeys.contains( deKey ) )
+                {
+                    sql += "(select value from patientattributevalue where patientid=p.patientid and patientattributeid="
+                        + column.getIdentifier() + ") as attribute_" + column.getIdentifier() + ",";
+                }
 
                 if ( column.hasQuery() )
                 {