=== modified file 'dhis-2/dhis-services/dhis-service-eventreporting/src/main/java/org/hisp/dhis/caseaggregation/hibernate/HibernateCaseAggregationConditionStore.java' --- dhis-2/dhis-services/dhis-service-eventreporting/src/main/java/org/hisp/dhis/caseaggregation/hibernate/HibernateCaseAggregationConditionStore.java 2014-03-20 10:38:01 +0000 +++ dhis-2/dhis-services/dhis-service-eventreporting/src/main/java/org/hisp/dhis/caseaggregation/hibernate/HibernateCaseAggregationConditionStore.java 2014-03-25 06:23:18 +0000 @@ -548,7 +548,7 @@ } else { - condition = getConditionForProgramStage( ids[0], operator, orgunitIds, startDate, endDate ); + condition = getConditionForProgramStage( ids[0], orgunitIds, startDate, endDate ); } } else if ( info[0].equalsIgnoreCase( OBJECT_PROGRAM_STAGE_PROPERTY ) ) @@ -635,6 +635,11 @@ sql += " AND _pdv.value "; } } + + if( !isExist ) + { + sql = "(" + sql + " ) AND " + getConditionForProgramStage( programStageId, orgunitIds, startDate, endDate ) + ")"; + } return sql; } @@ -730,7 +735,7 @@ * [PS:1] * */ - private String getConditionForProgramStage( String programStageId, String operator, Collection orgunitIds, + private String getConditionForProgramStage( String programStageId, Collection orgunitIds, String startDate, String endDate ) { String sql = " EXISTS ( SELECT _psi.programstageinstanceid FROM programstageinstance _psi " === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/caseAggregationForm.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/caseAggregationForm.vm 2014-02-20 16:11:16 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/caseAggregationForm.vm 2014-03-25 06:23:18 +0000 @@ -80,7 +80,7 @@