← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10188: Fix bug for loading completed events in aggregate tabular report.

 

------------------------------------------------------------
revno: 10188
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-03-14 01:50:11 +0700
message:
  Fix bug for loading completed events in aggregate tabular report.
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	2013-03-13 17:24:42 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java	2013-03-13 18:50:11 +0000
@@ -674,7 +674,7 @@
             sql = getAggregateReportSQL8( programStage, orgunitIds, facilityLB, filterSQL, deGroupBy, periods
                 .iterator().next(), aggregateType, limit, useCompletedEvents, format );
         }
- System.out.println("\n\n === \n " + sql );       
+        System.out.println( "\n\n === \n " + sql );
         if ( !sql.isEmpty() )
         {
             SqlRowSet rowSet = jdbcTemplate.queryForRowSet( sql );
@@ -1087,9 +1087,9 @@
                 {
                     sql += " dataelementid=" + deSum + " AND ";
                 }
-                if ( useCompletedEvents )
+                if ( useCompletedEvents != null )
                 {
-                    sql += " psi_1.completed = true AND ";
+                    sql += " AND psi_1.completed = " + useCompletedEvents + " AND ";
                 }
                 if ( deGroupBy != null )
                 {
@@ -1169,9 +1169,9 @@
                 {
                     sql += " dataelementid=" + deSum + " AND ";
                 }
-                if ( useCompletedEvents )
+                if ( useCompletedEvents != null )
                 {
-                    sql += " psi_1.completed = true AND ";
+                    sql += " psi_1.completed = " + useCompletedEvents + " AND ";
                 }
                 if ( deGroupBy != null )
                 {
@@ -1246,9 +1246,9 @@
                 {
                     sql += " dataelementid=" + deSum + " AND ";
                 }
-                if ( useCompletedEvents )
+                if ( useCompletedEvents != null )
                 {
-                    sql += " psi_1.completed = true AND ";
+                    sql += " psi_1.completed = " + useCompletedEvents + " AND ";
                 }
                 if ( deGroupBy != null )
                 {
@@ -1314,15 +1314,15 @@
                 sql += "WHERE programstageinstanceid=psi_1.programstageinstanceid AND ";
                 sql += "      dataelementid=" + deGroupBy + ") is not null ";
             }
-            if ( useCompletedEvents )
+            if ( useCompletedEvents != null )
             {
-                sql += " AND psi_1.completed = true ";
+                sql += " AND psi_1.completed = " + useCompletedEvents + " ";
             }
             if ( deSum != null )
             {
                 sql += " AND dataelementid=" + deSum + "  ";
             }
-            
+
             sql += " LIMIT 1 ) as " + aggregateType + "  ) ";
             sql += " UNION ";
         }
@@ -1430,9 +1430,9 @@
                 {
                     sql += " AND dataelementid=" + deSum + "  ";
                 }
-                if ( useCompletedEvents )
+                if ( useCompletedEvents != null )
                 {
-                    sql += " AND psi.completed = true ";
+                    sql += " AND psi.completed = " + useCompletedEvents + " ";
                 }
                 sql += "GROUP BY dataelementid ";
 
@@ -1441,7 +1441,7 @@
             }
 
             sql = sql.substring( 0, sql.length() - 6 );
-            
+
             if ( limit != null )
             {
                 sql += " LIMIT " + limit;
@@ -1507,9 +1507,9 @@
             {
                 sql += " AND dataelementid=" + deSum + "  ";
             }
-            if ( useCompletedEvents )
+            if ( useCompletedEvents != null )
             {
-                sql += " AND psi.completed = true ";
+                sql += " AND psi.completed = " + useCompletedEvents + " ";
             }
             sql += "GROUP BY dataelementid ";
 
@@ -1534,7 +1534,7 @@
         Integer limit, Boolean useCompletedEvents, I18nFormat format )
     {
         String sql = "";
-        
+
         for ( Integer root : roots )
         {
             Collection<Integer> orgunitIds = getOrganisationUnits( root, facilityLB );
@@ -1563,9 +1563,9 @@
                 {
                     sql += " dataelementid=" + deSum + " AND ";
                 }
-                if ( useCompletedEvents )
+                if ( useCompletedEvents != null )
                 {
-                    sql += " psi_1.completed = true AND ";
+                    sql += " psi_1.completed = " + useCompletedEvents + " AND ";
                 }
                 sql += "        psi_1.programstageid=" + programStage.getId() + " ";
                 sql += filterSQL + " AND ";
@@ -1626,9 +1626,9 @@
             {
                 sql += " dataelementid=" + deSum + " AND ";
             }
-            if ( useCompletedEvents )
+            if ( useCompletedEvents != null )
             {
-                sql += " psi_1.completed = true AND ";
+                sql += " psi_1.completed = " + useCompletedEvents + " AND ";
             }
             sql += "        psi_1.organisationunitid in (" + TextUtils.getCommaDelimitedString( orgunitIds ) + ") AND ";
             sql += "        psi_1.programstageid=" + programStage.getId() + " ";
@@ -1665,9 +1665,9 @@
             sql += "            ON psi_1.programstageinstanceid = pdv_1.programstageinstanceid ";
             sql += "WHERE ";
             sql += " psi_1.programstageid=" + programStage.getId() + " AND ";
-            if ( useCompletedEvents )
+            if ( useCompletedEvents != null )
             {
-                sql += " psi_1.completed = true AND ";
+                sql += " psi_1.completed = " + useCompletedEvents + " AND ";
             }
             sql += "    psi_1.executiondate >= '" + format.formatDate( period.getStartDate() ) + "' AND ";
             sql += "    psi_1.executiondate <= '" + format.formatDate( period.getEndDate() ) + "' AND ";
@@ -1735,12 +1735,12 @@
         }
 
         String firstPeriodName = "";
-        
+
         String groupByName = dataElementService.getDataElement( deGroupBy ).getDisplayName();
         for ( String deValue : deValues )
         {
 
-            sql += "(SELECT DISTINCT '" + deValue + "' as \"" + groupByName +"\", ";
+            sql += "(SELECT DISTINCT '" + deValue + "' as \"" + groupByName + "\", ";
 
             for ( Period period : periods )
             {
@@ -1785,9 +1785,9 @@
                 {
                     sql += " AND dataelementid=" + deSum + " ";
                 }
-                if ( useCompletedEvents )
+                if ( useCompletedEvents != null )
                 {
-                    sql += " AND psi_1.completed = true ";
+                    sql += " AND psi_1.completed = " + useCompletedEvents + " ";
                 }
 
                 sql += ") as \"" + periodName + "\",";