← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12550: Fix bug in Aggregate tabular report.

 

------------------------------------------------------------
revno: 12550
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-10-10 16:04:12 +0700
message:
  Fix bug in Aggregate tabular report.
modified:
  dhis-2/dhis-services/dhis-service-eventreporting/src/main/java/org/hisp/dhis/caseaggregation/jdbc/JdbcCaseAggregationConditionManager.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/multiDataEntry.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js


--
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-eventreporting/src/main/java/org/hisp/dhis/caseaggregation/jdbc/JdbcCaseAggregationConditionManager.java'
--- dhis-2/dhis-services/dhis-service-eventreporting/src/main/java/org/hisp/dhis/caseaggregation/jdbc/JdbcCaseAggregationConditionManager.java	2013-10-09 02:47:12 +0000
+++ dhis-2/dhis-services/dhis-service-eventreporting/src/main/java/org/hisp/dhis/caseaggregation/jdbc/JdbcCaseAggregationConditionManager.java	2013-10-10 09:04:12 +0000
@@ -341,34 +341,21 @@
                 }
 
                 sql += "FROM ";
-                String innerJoin = "";
-                boolean hasPatients = hasPatientCriteria( caseExpression );
-                boolean hasProgramInstances = hasProgramInstanceCriteria( caseExpression );
                 boolean hasDataelement = hasDataelementCriteria( caseExpression );
 
-                if ( hasPatients || hasProgramInstances )
-                {
-                    sql += innerJoin + "programinstance as pi INNER JOIN patient p on p.patientid=pi.patientid ";
-                    if ( !hasDataelement )
-                    {
-                        sql += "INNER JOIN organisationunit ou on ou.organisationunitid=p.organisationunitid ";
-                    }
-                    innerJoin = " INNER JOIN ";
-                }
-
-                if ( hasDataelement )
-                {
-                    if ( hasPatients || hasProgramInstances )
-                    {
-                        sql += " ON pi.programinstanceid=psi.programinstanceid ";
-                    }
-                    else
-                    {
-                        sql += " INNER JOIN programinstance pi on pi.programinstanceid=pi.programinstanceid ";
-                    }
-                    sql += "INNER JOIN organisationunit ou on ou.organisationunitid=psi.organisationunitid ";
-                }
-
+                if( hasDataelement)
+                {
+                    sql += " programinstance as pi ";
+                    sql += " INNER JOIN programstageinstance psi ON pi.programinstanceid=psi.programinstanceid ";
+                    sql += " INNER JOIN organisationunit ou ON ou.organisationunitid=psi.organisationunitid ";
+                }
+                else
+                {
+                    sql += " programinstance as pi INNER JOIN patient p on p.patientid=pi.patientid ";
+                    sql += " INNER JOIN organisationunit ou ON ou.organisationunitid=p.organisationunitid ";
+                }
+               
+                
                 sql += " WHERE "
                     + createSQL( caseExpression, operator, orgunitIds,
                         DateUtils.getMediumDateString( period.getStartDate() ),
@@ -402,7 +389,7 @@
         }
 
         sql = sql.replaceAll( "COMBINE", "" );
-
+        
         return sql;
     }
 
@@ -412,7 +399,6 @@
         String sql = "SELECT ";
 
         boolean hasPatients = hasPatientCriteria( caseExpression );
-        boolean hasProgramInstances = hasProgramInstanceCriteria( caseExpression );
         boolean hasDataelement = hasDataelementCriteria( caseExpression );
 
         Collection<Integer> orgunitIds = new HashSet<Integer>();
@@ -429,45 +415,39 @@
         {
             if ( hasPatients || operator.equals( CaseAggregationCondition.AGGRERATION_COUNT ) )
             {
-                sql += "p.name, p.gender, p.birthDate, p.phoneNumber, ";
+                sql += "p.name, p.gender, p.birthDate, p.phoneNumber,";
             }
 
             if ( hasDataelement )
             {
-                sql += "pdv.value,pgs.name as program_stage, psi.executiondate as report_date, ";
+                sql += "pdv.value,pgs.name as program_stage, psi.executiondate as report_date,";
             }
         }
 
-        sql += "1";
-        sql += "FROM ";
-        String innerJoin = "";
-
-        if ( hasDataelement )
-        {
-            sql += innerJoin + "programstageinstance as psi ";
-            sql += "INNER JOIN programstage as pgs ON pgs.programstageid = psi.programstageid ";
-            sql += "INNER JOIN patientdatavalue as pdv ON psi.programstageinstanceid = pdv.programstageinstanceid ";
-            innerJoin = " INNER JOIN ";
-        }
-        else if ( hasPatients || operator.equals( CaseAggregationCondition.AGGRERATION_COUNT ) )
-        {
-            sql += innerJoin + "programinstance as pi ON pi.programinstanceid = psi.programinstanceid ";
-            sql += "INNER JOIN patient p on p.patientid=pi.patientid  ";
-            innerJoin = " INNER JOIN ";
-        }
-        else if ( (hasProgramInstances && !hasPatients) || operator.equals( CaseAggregationCondition.AGGRERATION_COUNT ) )
-        {
-            sql += innerJoin + " programinstance as pi ON pi.programinstanceid = psi.programinstanceid ";
-            innerJoin = " INNER JOIN ";
-        }
-
-        sql += innerJoin
-            + "organisationunit ou on ou.organisationunitid=psi.organisationunitid WHERE "
+        sql = sql.substring( 0, sql.length() - 1 );
+        sql += " FROM ";
+
+        if( hasDataelement)
+        {
+            sql += " programinstance as pi INNER JOIN patient p on p.patientid=pi.patientid";
+            sql += " INNER JOIN programstageinstance psi ON pi.programinstanceid=psi.programinstanceid ";
+            sql += " INNER JOIN organisationunit ou ON ou.organisationunitid=psi.organisationunitid ";
+            sql += " INNER JOIN patientdatavalue pdv ON pdv.programstageinstanceid=psi.programstageinstanceid ";
+            sql += " INNER JOIN program pg ON pg.programid=pi.programid ";
+            sql += " INNER JOIN programstage pgs ON pgs.programid=pg.programid ";
+        }
+        else
+        {
+            sql += " programinstance as pi INNER JOIN patient p on p.patientid=pi.patientid";
+            sql += " INNER JOIN organisationunit ou ON ou.organisationunitid=p.organisationunitid ";
+        }
+
+        sql += " WHERE "
             + createSQL( caseExpression, operator, orgunitIds, DateUtils.getMediumDateString( period.getStartDate() ),
                 DateUtils.getMediumDateString( period.getEndDate() ) );
 
         sql = sql.replaceAll( "COMBINE", "" );
-
+        
         return sql;
     }
 
@@ -899,7 +879,7 @@
         String sql = " EXISTS ( SELECT _psi.programstageinstanceid from programstageinstance _psi "
             + "WHERE _psi.programstageinstanceid=psi.programstageinstanceid AND ( _psi.executionDate BETWEEN '"
             + startDate + "' AND '" + endDate + "') AND " + propertyName;
-
+        
         return sql;
     }
 
@@ -911,10 +891,10 @@
      */
     private String getConditionForProgramProperty( String operator, String startDate, String endDate, String property )
     {
-        String sql = " EXISTS ( SELECT _pi.programinstanceid FROM programinstance as _pi WHERE psi.programinstanceid=_pi.programsinstanceid AND "
-            + "psi.executionDate >= '"
+        String sql = " EXISTS ( SELECT _pi.programinstanceid FROM programinstance as _pi WHERE _pi.programinstanceid=pi.programsinstanceid AND "
+            + "pi.enrollmentdate >= '"
             + startDate
-            + "' AND psi.executionDate <= '"
+            + "' AND pi.enrollmentdate <= '"
             + endDate
             + "' AND "
             + property
@@ -951,8 +931,8 @@
     private String getConditionForProgramStage( String programStageId, String operator, Collection<Integer> orgunitIds,
         String startDate, String endDate )
     {
-        String sql = " EXISTS ( SELECT _psi.programstageinstanceid FROM programinstance as _pi INNER JOIN programstageinstance _psi "
-            + "ON _pi.programinstanceid = _psi.programinstanceid WHERE _psi.programstageinstanceid=psi.programstageinstanceid "
+        String sql = " EXISTS ( SELECT _psi.programstageinstanceid FROM programstageinstance _psi "
+            + "WHERE _psi.programstageinstanceid=psi.programstageinstanceid "
             + "AND _psi.programstageid="
             + programStageId
             + "  AND _psi.executiondate >= '"

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.java	2013-09-19 03:16:23 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramDataEntryService.java	2013-10-10 09:04:12 +0000
@@ -561,7 +561,7 @@
     // -------------------------------------------------------------------------
     // Supportive methods
     // -------------------------------------------------------------------------
-
+        
     private String populateCustomDataEntryForTextBox( DataElement dataElement, String inputHTML )
     {
         if ( dataElement != null )

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/multiDataEntry.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/multiDataEntry.js	2013-10-07 13:20:56 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/multiDataEntry.js	2013-10-10 09:04:12 +0000
@@ -113,29 +113,6 @@
     });
 }
 
-function advancedSearch( params )
-{
-	params += "&searchTexts=prg_" + getFieldValue('programIdAddPatient');
-
-    var programId = getFieldValue('programIdAddPatient');
-
-    if( !isNaN(programId) || programId == null) {
-        params += "&programId=" + parseInt(programId);
-    }
-
-	$.ajax({
-		url: 'getDataRecords.action',
-		type:"POST",
-		data: params,
-		success: function( html ){
-			jQuery('#listPatientDiv').html(html);
-			showById('colorHelpLink');
-			showById('listPatientDiv');
-			hideLoader();
-		}
-	});
-}
-
 function loadDataEntryDialog( programStageInstanceId ) 
 {
 	jQuery("#patientList input[name='programStageBtn']").each(function(i,item){

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js	2013-10-09 06:40:18 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js	2013-10-10 09:04:12 +0000
@@ -430,7 +430,7 @@
 			hideById('contentDiv');
 			
 			var reportDateToUse = selectedProgramStageInstance.attr('reportDateToUse');
-			if(reportDateToUse!='' && $('#executionDate').val() == '' ){
+			if(reportDateToUse != "undefined" && reportDateToUse!='' && $('#executionDate').val() == '' ){
 				$('#executionDate').val(reportDateToUse);
 				$('#executionDate').change();
 			}