dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #14765
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5111: Error when running Patient Aggregation in MySQL.
------------------------------------------------------------
revno: 5111
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2011-11-04 09:53:33 +0700
message:
Error when running Patient Aggregation in MySQL.
modified:
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/DefaultCaseAggregationConditionService.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/caseaggregation/DefaultCaseAggregationConditionService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/DefaultCaseAggregationConditionService.java 2011-11-03 02:20:41 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/DefaultCaseAggregationConditionService.java 2011-11-04 02:53:33 +0000
@@ -613,7 +613,7 @@
else if ( info[0].equalsIgnoreCase( OBJECT_PROGRAM_PROPERTY ) )
{
- condition = getConditionForProgramProperty( orgunitId, startDate, endDate ) + info[1];
+ condition = getConditionForProgramProperty( orgunitId, operator, startDate, endDate ) + info[1];
}
else if ( info[0].equalsIgnoreCase( OBJECT_PROGRAM ) )
{
@@ -735,7 +735,7 @@
sql = "SELECT p.patient ";
}
- sql = "FROM patient as p WHERE p.organisationunitid = " + orgunitId + " " + "AND p.registrationdate >= '"
+ sql += "FROM patient as p WHERE p.organisationunitid = " + orgunitId + " " + "AND p.registrationdate >= '"
+ startDate + "' AND p.registrationdate <= '" + endDate + "' ";
return sql;
@@ -751,7 +751,7 @@
sql = "SELECT p.patient ";
}
- sql = "FROM programstageinstance as psi INNER JOIN programstage as ps "
+ sql += "FROM programstageinstance as psi INNER JOIN programstage as ps "
+ "ON psi.programstageid = ps.programstageid INNER JOIN patientdatavalue as pd ON "
+ "psi.programstageinstanceid = pd.programstageinstanceid INNER JOIN programinstance as pi ON "
+ "psi.programinstanceid = pi.programinstanceid INNER JOIN patient as p ON "
@@ -771,9 +771,16 @@
return sql;
}
- private String getConditionForProgramProperty( int orgunitId, String startDate, String endDate )
+ private String getConditionForProgramProperty( int orgunitId, String operator, String startDate, String endDate )
{
- return "FROM programstageinstance as psi "
+ String sql = "SELECT distinct(p.patient) ";
+
+ if ( operator.equals( AGGRERATION_SUM ) )
+ {
+ sql = "SELECT p.patient ";
+ }
+
+ return sql + "FROM programstageinstance as psi "
+ "INNER JOIN programinstance as pi ON psi.programinstanceid = pi.programinstanceid "
+ "INNER JOIN patient as p ON p.patientid = pi.patientid WHERE p.organisationunitid = " + orgunitId + " "
+ "AND psi.executionDate >= '" + startDate + "' AND psi.executionDate <= '" + endDate + "' AND ";