← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2234: Add function : Handling difference between incidentDate and enrollDate into Aggregation Engine fu...

 

------------------------------------------------------------
revno: 2234
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2010-11-30 13:17:34 +0700
message:
  Add function : Handling difference between incidentDate and enrollDate into Aggregation Engine funtion.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationCondition.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/DefaultCaseAggregationConditionService.java
  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/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/caseAggregation.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateCaseAggregation.vm


--
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-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<PatientDataValue> result = new HashSet<PatientDataValue>();
 
         String sql = createSQL( aggregationCondition, orgunit, period );
-        
+
         Collection<DataElement> 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<String> conditions, List<String> 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 @@
 <table>
 	<thead>
 		<tr>
-			<th colspan="3">$i18n.getString( "condition_detail" )</th>
+			<th colspan="4">$i18n.getString( "condition_detail" )</th>
 		</tr>
 	</thead>
 	
 	<tbody>
 	
 	<tr>
-	
-	<td>
+		<td>
 		<fieldset style="border: 1px solid #3f5d8e; ">
 		<legend>$i18n.getString( "program_stage_de" )</legend>
 		
@@ -121,7 +120,7 @@
 		
 		<td>
 		<fieldset style="border: 1px solid #3f5d8e; ">
-		<legend>$i18n.getString( "case_attributes" )</legend>
+		<legend>$i18n.getString( "case_properties" )</legend>
 		
 		<table>
 		
@@ -129,7 +128,7 @@
 				<td>
 					<select id="caseProperty" name="caseProperty" size="5" ondblclick="insertInfo(this);" style="width:15em; height:14.5em" >
 						<option value="[CP:gender]">$i18n.getString( "gender" )</option>
-						<option value="[CP:dob]">$i18n.getString( "dob" )</option>
+						<option value="[CP:dobType]">$i18n.getString( "dobType" )</option>
 					</select>
 				</td>
 			</tr>
@@ -151,11 +150,27 @@
 			</tr>
 		</table>
 		</fieldset>
-	
-		</td>
+		</td>
+		
+		<td>
+		<fieldset style="border: 1px solid #3f5d8e; ">
+		<legend>$i18n.getString( "program_properties" )</legend>
+		
+		<table>
+		
+			<tr>
+				<td>
+					<select id="caseProperty" name="caseProperty" size="5" ondblclick="insertInfo(this);" style="width:15em; height:14.5em" >
+						<option value="[PP:enrollmentdate - dateofincident]">$i18n.getString( "enrolldate_minus_incidentdate" )</option>
+					</select>
+				</td>
+			</tr>
+		</table>
+		</td>
+		
 	</tr>	
 	<tr>
-		<td colspan='3'>
+		<td colspan='4'>
 			<img src="../images/less.png" alt="$i18n.getString( 'less' )" onclick='insertOperator( "<" );' style="cursor:pointer;">
 			<img src="../images/less_or_equal.png" alt="$i18n.getString( 'less_or_equal' )" onclick='insertOperator( "<=" );' style="cursor:pointer;">
 			<img src="../images/greater.png" alt="$i18n.getString( 'greater' )" onclick='insertOperator( ">" );' style="cursor:pointer;">
@@ -176,10 +191,10 @@
 	
     </tbody>
 	<tr>
-		<td colspan='3'>
+		<td colspan='4'>
 			<fieldset style="border: 1px solid #3f5d8e; ">
 				<legend>$i18n.getString( "condition" )</legend>
-				<textarea id="aggregationCondition" name="aggregationCondition" style="width:54.5em; height:10em" class="{validate:{required:true}}" ></textarea>
+				<textarea id="aggregationCondition" name="aggregationCondition" style="width:72.5em; height:10em" class="{validate:{required:true}}" ></textarea>
 			</fieldset>
 		</td>
 	</tr>

=== 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 @@
-<h3>$i18n.getString( 'case_aggregation_condition' )</h3>
+<h3>$i18n.getString( 'case_aggregation_mapping' )</h3>
 
 <table class="mainPageTable">
   <tr>

=== 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 @@
 <table>
 	<thead>
 		<tr>
-			<th colspan="3">$i18n.getString( "condition_detail" )</th>
+			<th colspan="4">$i18n.getString( "condition_detail" )</th>
 		</tr>
 	</thead>
 	
@@ -158,9 +158,25 @@
 		</fieldset>
 	
 		</td>
+		
+		<td>
+		<fieldset style="border: 1px solid #3f5d8e; ">
+		<legend>$i18n.getString( "program_properties" )</legend>
+		
+		<table>
+		
+			<tr>
+				<td>
+					<select id="caseProperty" name="caseProperty" size="5" ondblclick="insertInfo(this);" style="width:15em; height:14.5em" >
+						<option value="[PP:enrollmentdate - dateofincident]">$i18n.getString( "enrolldate_minus_incidentdate" )</option>
+					</select>
+				</td>
+			</tr>
+		</table>
+		</td>
 	</tr>	
 	<tr>
-		<td colspan=3>
+		<td colspan=4>
 			<img src="../images/less.png" alt="$i18n.getString( 'less' )" onclick='insertOperator( "<" );' style="cursor:pointer;">
 			<img src="../images/less_or_equal.png" alt="$i18n.getString( 'less_or_equal' )" onclick='insertOperator( "<=" );' style="cursor:pointer;">
 			<img src="../images/greater.png" alt="$i18n.getString( 'greater' )" onclick='insertOperator( ">" );' style="cursor:pointer;">
@@ -181,10 +197,10 @@
 	
     </tbody>
 	<tr>
-		<td colspan='3'>
+		<td colspan='4'>
 			<fieldset style="border: 1px solid #3f5d8e; ">
 				<legend>$i18n.getString( "condition" )</legend>
-				<textarea id="aggregationCondition" name="aggregationCondition" style="width:54.5em; height:10em" class="{validate:{required:true}}" >$caseAggregation.aggregationExpression</textarea>
+				<textarea id="aggregationCondition" name="aggregationCondition" style="width:72.5em; height:10em" class="{validate:{required:true}}" >$caseAggregation.aggregationExpression</textarea>
 			</fieldset>
 		</td>
 	</tr>