← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4964: Calculate number of people registered by organisation unit and period ( in Beneficiary aggregatio...

 

------------------------------------------------------------
revno: 4964
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2011-10-17 11:04:35 +0700
message:
  Calculate number of people registered by organisation unit and period ( in Beneficiary aggregation query builder function).
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/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	2011-07-13 02:28:39 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationCondition.java	2011-10-17 04:04:35 +0000
@@ -61,6 +61,8 @@
     public static String OBJECT_PROGRAM_PROPERTY = "PP";
     
     public static String OBJECT_PROGRAM = "PG";
+    
+    public static String OBJECT_PATIENT = "PT";
 
     // -------------------------------------------------------------------------
     // Fields

=== 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-10-05 09:19:52 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/DefaultCaseAggregationConditionService.java	2011-10-17 04:04:35 +0000
@@ -28,6 +28,7 @@
 package org.hisp.dhis.caseaggregation;
 
 import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.AGGRERATION_SUM;
+import static org.hisp.dhis.caseaggregation.CaseAggregationCondition.OBJECT_PATIENT;
 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;
@@ -74,8 +75,9 @@
 public class DefaultCaseAggregationConditionService
     implements CaseAggregationConditionService
 {
-    private final String regExp = "\\[(" + OBJECT_PROGRAM + "|" + OBJECT_PROGRAM_STAGE_DATAELEMENT + "|"
-        + OBJECT_PATIENT_ATTRIBUTE + "|" + OBJECT_PATIENT_PROPERTY + "|" + OBJECT_PROGRAM_PROPERTY + ")"
+    private final String regExp = "\\[(" + OBJECT_PATIENT + "|"  + OBJECT_PROGRAM + "|" 
+        + OBJECT_PROGRAM_STAGE_DATAELEMENT + "|" + OBJECT_PATIENT_ATTRIBUTE 
+        + "|" + OBJECT_PATIENT_PROPERTY + "|" + OBJECT_PROGRAM_PROPERTY + ")"
         + SEPARATOR_OBJECT + "([a-zA-Z0-9\\- ]+[" + SEPARATOR_ID + "[0-9]*]*)" + "\\]";
 
     private final String IS_NULL = "is null";
@@ -83,6 +85,8 @@
     private final String PROPERTY_AGE = "age";
 
     private final String INVALID_CONDITION = "Invalid condition";
+    
+    private final String NUMBER_PATIENTS_REGISTERED = "The number of beneficiaries registered";
 
     // -------------------------------------------------------------------------
     // Dependencies
@@ -298,10 +302,15 @@
             {
                 String[] ids = info[1].split( SEPARATOR_ID );
 
-                int objectId = Integer.parseInt( ids[0] );
+                if ( info[0].equalsIgnoreCase( OBJECT_PATIENT ) )
+                {
+                    matcher.appendReplacement( description, "[" + OBJECT_PATIENT + SEPARATOR_OBJECT
+                        + NUMBER_PATIENTS_REGISTERED + "]" );
+                }
+                else if ( info[0].equalsIgnoreCase( OBJECT_PATIENT_ATTRIBUTE ) )
+                {
+                    int objectId = Integer.parseInt( ids[0] );
 
-                if ( info[0].equalsIgnoreCase( OBJECT_PATIENT_ATTRIBUTE ) )
-                {
                     PatientAttribute patientAttribute = patientAttributeService.getPatientAttribute( objectId );
 
                     if ( patientAttribute == null )
@@ -314,6 +323,8 @@
                 }
                 else if ( info[0].equalsIgnoreCase( OBJECT_PROGRAM ) )
                 {
+                    int objectId = Integer.parseInt( ids[0] );
+                
                     Program program = programService.getProgram( objectId );
 
                     if ( program == null )
@@ -451,7 +462,11 @@
 
                 String[] info = match.split( SEPARATOR_OBJECT );
 
-                if ( info[0].equalsIgnoreCase( OBJECT_PATIENT_PROPERTY ) )
+                if ( info[0].equalsIgnoreCase( OBJECT_PATIENT ) )
+                {
+                    condition = getConditionForPatient( orgunitId, startDate, endDate );
+                }
+                else if ( info[0].equalsIgnoreCase( OBJECT_PATIENT_PROPERTY ) )
                 {
                     String propertyName = info[1];
                     condition = getConditionForPatientProperty( propertyName, orgunitId, startDate, endDate );
@@ -603,6 +618,14 @@
             + "AND pav.value ";
     }
 
+    private String getConditionForPatient( int orgunitId, String startDate, String endDate )
+    {
+        String sql = "SELECT p.patientid FROM patient as p WHERE p.organisationunitid = " + orgunitId + " "
+            + "AND p.registrationdate >= '" + startDate + "' AND p.registrationdate <= '" + endDate + "' ";
+        
+        return sql;
+    }
+    
     private String getConditionForPatientProperty( String propertyName, int orgunitId, String startDate, String endDate )
     {
         String sql = "SELECT distinct(p.patientid) FROM programstageinstance as psi INNER JOIN programstage as ps "

=== 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	2011-10-06 04:38:13 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties	2011-10-17 04:04:35 +0000
@@ -382,4 +382,5 @@
 others = Others
 test_condition = Test condition
 run_success = Run successful
-run_fail = Run failed
\ No newline at end of file
+run_fail = Run failed
+patients_registered = The number of beneficiaries registered
\ 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	2011-10-05 09:19:52 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addCaseAggregation.vm	2011-10-17 04:04:35 +0000
@@ -130,6 +130,7 @@
 			<tr>
 				<td>
 					<select id="caseProperty" name="caseProperty" size="8" ondblclick="insertInfo(this);" style="width:18em; height:16.5em" >
+						<option value="[PT:count]">$i18n.getString( "patients_registered" )</option>
 						<option value="[CP:gender]">$i18n.getString( "gender" )</option>
 						<option value="[CP:dobType]">$i18n.getString( "dob_type" )</option>
 						<option value="[CP:age]">$i18n.getString( "age_month" )</option>

=== 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	2011-10-05 09:19:52 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateCaseAggregation.vm	2011-10-17 04:04:35 +0000
@@ -131,6 +131,7 @@
 			<tr>
 				<td>
 					<select id="caseProperty" name="caseProperty" size="5" ondblclick="insertInfo(this);" style="width:20em; height:14.5em" >
+						<option value="[PT:count]">$i18n.getString( "patients_registered" )</option>
 						<option value="[CP:gender]">$i18n.getString( "gender" )</option>
 						<option value="[CP:dobType]">$i18n.getString( "dob_type" )</option>
 						<option value="[CP:age]">$i18n.getString( "age_month" )</option>