=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationCondition.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationCondition.java 2010-11-25 22:22:10 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationCondition.java 2010-11-30 06:17:34 +0000 @@ -61,6 +61,8 @@ public static String OBJECT_PATIENT_PROPERTY = "CP"; + public static String OBJECT_PROGRAM_PROPERTY = "PP"; + // ------------------------------------------------------------------------- === 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 2010-11-29 02:04:22 +0000 +++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/DefaultCaseAggregationConditionService.java 2010-11-30 06:17:34 +0000 @@ -30,6 +30,7 @@ import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.AGGRERATION_SUM; import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_PATIENT_ATTRIBUTE; import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_PATIENT_PROPERTY; +import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_PROGRAM_PROPERTY; import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_PROGRAM_STAGE_DATAELEMENT; import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OPERATOR_AND; import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.SEPARATOR_ID; @@ -162,7 +163,7 @@ Collection result = new HashSet(); String sql = createSQL( aggregationCondition, orgunit, period ); - + Collection dataElements = getDataElementsInExpression( aggregationCondition .getAggregationExpression() ); @@ -177,7 +178,7 @@ result.addAll( dataValues ); } - + return result; } @@ -209,7 +210,8 @@ String[] expression = aggregationCondition.getAggregationExpression().split( "(AND|OR)" ); String regExp = "\\[(" + OBJECT_PROGRAM_STAGE_DATAELEMENT + "|" + OBJECT_PATIENT_ATTRIBUTE + "|" - + OBJECT_PATIENT_PROPERTY + ")" + SEPARATOR_OBJECT + "([a-zA-Z0-9]+[" + SEPARATOR_ID + "[0-9]*]*)" + "\\]"; + + OBJECT_PATIENT_PROPERTY + "|" + OBJECT_PROGRAM_PROPERTY + ")" + SEPARATOR_OBJECT + "([a-zA-Z0-9\\- ]+[" + + SEPARATOR_ID + "[0-9]*]*)" + "\\]"; // --------------------------------------------------------------------- // parse expressions @@ -239,13 +241,13 @@ if ( info[0].equalsIgnoreCase( OBJECT_PATIENT_PROPERTY ) ) { String propertyName = info[1]; - condition = getCondititionForPatientProperty( propertyName, orgunitId, startDate, endDate ); + condition = getConditionForPatientProperty( propertyName, orgunitId, startDate, endDate ); } else if ( info[0].equalsIgnoreCase( OBJECT_PATIENT_ATTRIBUTE ) ) { int attributeId = Integer.parseInt( info[1] ); - condition = getCondititionForPatientAttribute( attributeId, orgunitId, startDate, endDate ); + condition = getConditionForPatientAttribute( attributeId, orgunitId, startDate, endDate ); } else if ( info[0].equalsIgnoreCase( OBJECT_PROGRAM_STAGE_DATAELEMENT ) ) { @@ -255,7 +257,7 @@ int dataElementId = Integer.parseInt( ids[1] ); int optionComboId = Integer.parseInt( ids[2] ); - condition = getCondititionForDataElement( programStageId, dataElementId, optionComboId, orgunitId, + condition = getConditionForDataElement( programStageId, dataElementId, optionComboId, orgunitId, startDate, endDate ); if ( !expression[i].contains( "+" ) ) { @@ -267,6 +269,11 @@ } } + else if ( info[0].equalsIgnoreCase( OBJECT_PROGRAM_PROPERTY ) ) + { + condition = getConditionForProgramProperty( orgunitId, startDate, endDate ) + info[1]; + } + // ------------------------------------------------------------- // Replacing the operand with 1 in order to later be able to // verify @@ -304,7 +311,7 @@ conditions.add( condition ); } - + return getSQL( conditions, operators ); } @@ -341,20 +348,20 @@ return dataElements; } - private String getCondititionForDataElement( int programStageId, int dataElementId, int optionComboId, - int orgunitId, String startDate, String endDate ) + private String getConditionForDataElement( int programStageId, int dataElementId, int optionComboId, int orgunitId, + String startDate, String endDate ) { return "SELECT distinct(pi.patientid) 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 pi.programinstanceid = psi.programinstanceid " + "WHERE pd.categoryoptioncomboid = " + optionComboId + " AND pd.dataelementid = " + dataElementId + " " - + " AND pd.organisationunitid = " + orgunitId + " AND ps.programstageid = " + programStageId + " " - + " AND psi.executionDate >= '" + startDate + "' AND psi.executionDate <= '" + endDate + "' "; + + "AND pd.organisationunitid = " + orgunitId + " AND ps.programstageid = " + programStageId + " " + + "AND psi.executionDate >= '" + startDate + "' AND psi.executionDate <= '" + endDate + "' "; } - private String getCondititionForPatientAttribute( int attributeId, int orgunitId, String startDate, String endDate ) + private String getConditionForPatientAttribute( int attributeId, int orgunitId, String startDate, String endDate ) { return "distinct(pi.patientid) FROM programstageinstance as psi " + "INNER JOIN programstage as ps ON psi.programstageid = ps.programstageid " @@ -366,8 +373,7 @@ + "AND pav.value "; } - private String getCondititionForPatientProperty( String propertyName, int orgunitId, String startDate, - String endDate ) + private String getConditionForPatientProperty( String propertyName, int orgunitId, String startDate, String endDate ) { return "SELECT distinct(p.patientid) FROM programstageinstance as psi INNER JOIN programstage as ps " + "ON psi.programstageid = ps.programstageid INNER JOIN patientdatavalue as pd ON " @@ -378,6 +384,14 @@ + propertyName + " "; } + private String getConditionForProgramProperty( int orgunitId, String startDate, String endDate ) + { + return "SELECT distinct(p.patientid) 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 "; + } + private String getSQL( List conditions, List operators ) { String sql = conditions.get( 0 ); @@ -420,21 +434,27 @@ return patientIds.size(); } -// public static void main( String[] args ) -// { -// -// CaseAggregationCondition aggregationCondition = new CaseAggregationCondition(); -// -// aggregationCondition.setOperator( CaseAggregationCondition.AGGRERATION_COUNT ); -// -// // aggregationCondition.setAggregationExpression( -// // "( [DE:1.1.1] + [DE:1.1.1] + [DE:1.1.1] > 0 " ); -// aggregationCondition.setAggregationExpression( " [DE:15.1.1] + [DE:16.2.1] > 0" ); -// // ); -// -// DefaultCaseAggregationConditionService service = new DefaultCaseAggregationConditionService(); -// -// service.getDataElementsInExpression( aggregationCondition.getAggregationExpression() ); -// } + // public static void main( String[] args ) + // { + // + // CaseAggregationCondition aggregationCondition = new + // CaseAggregationCondition(); + // + // aggregationCondition.setOperator( + // CaseAggregationCondition.AGGRERATION_COUNT ); + // + // // aggregationCondition.setAggregationExpression( + // // "( [DE:1.1.1] + [DE:1.1.1] + [DE:1.1.1] > 0 " ); + // aggregationCondition.setAggregationExpression( + // " [DE:15.1.1] + [DE:16.2.1] > 0" ); + // // + // aggregationCondition.setAggregationExpression("[PP:enrollmentdate - dateofincident] > 0"); + // // ); + // + // DefaultCaseAggregationConditionService service = new + // DefaultCaseAggregationConditionService(); + // + // service.parseConditition( aggregationCondition, null, null ); + // } } === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties 2010-11-25 22:22:10 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties 2010-11-30 06:17:34 +0000 @@ -446,12 +446,13 @@ file_type_not_supported = File type is not supported dataelement_group = DataElement Group option_combo = Option Combo -case_aggregation_condition = Case Aggregation Condition -case_aggregation_condition_detail = Case aggregation condition details -add_case_aggregation_condition = Add Case aggregation condition +case_aggregation_condition = Beneficiary Aggregation QueryBuilder +case_aggregation_condition_detail = Beneficiary Aggregation QueryBuilder details +add_case_aggregation_condition = Add Beneficiary Aggregation QueryBuilder case_attributes_and_properties = Case Attributes ans Properties condition = Condition condition_detail = Condition details -update_case_aggregation_condition = Update Case aggregation condition - +update_case_aggregation_condition = Update Beneficiary Aggregation QueryBuilder +enrolldate_minus_incidentdate = Enroll Date - Incident Date +program_properties = Program properties \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addCaseAggregation.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addCaseAggregation.vm 2010-11-25 22:22:10 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addCaseAggregation.vm 2010-11-30 06:17:34 +0000 @@ -61,15 +61,14 @@ - + - - + + + + - - === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/caseAggregation.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/caseAggregation.vm 2010-11-25 22:22:10 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/caseAggregation.vm 2010-11-30 06:17:34 +0000 @@ -1,4 +1,4 @@ -

$i18n.getString( 'case_aggregation_condition' )

+

$i18n.getString( 'case_aggregation_mapping' )

$i18n.getString( "condition_detail" )$i18n.getString( "condition_detail" )
+
$i18n.getString( "program_stage_de" ) @@ -121,7 +120,7 @@
- $i18n.getString( "case_attributes" ) + $i18n.getString( "case_properties" ) @@ -129,7 +128,7 @@ @@ -151,11 +150,27 @@
- -
+
+ $i18n.getString( "program_properties" ) + + + + + + +
+ +
+
+ $i18n.getString( 'less' ) $i18n.getString( 'less_or_equal' ) $i18n.getString( 'greater' ) @@ -176,10 +191,10 @@
+
$i18n.getString( "condition" ) - +
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateCaseAggregation.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateCaseAggregation.vm 2010-11-25 22:22:10 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateCaseAggregation.vm 2010-11-30 06:17:34 +0000 @@ -66,7 +66,7 @@
- + @@ -158,9 +158,25 @@ + + - -
$i18n.getString( "condition_detail" )$i18n.getString( "condition_detail" )
+
+ $i18n.getString( "program_properties" ) + + + + + + +
+ +
+
+ $i18n.getString( 'less' ) $i18n.getString( 'less_or_equal' ) $i18n.getString( 'greater' ) @@ -181,10 +197,10 @@
+
$i18n.getString( "condition" ) - +