← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4640: Add birthday condition into Beneficiary Aggreation Query Builder function.

 

------------------------------------------------------------
revno: 4640
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-09-22 12:46:07 +0700
message:
  Add birthday condition into Beneficiary Aggreation Query Builder function.
modified:
  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-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-07-15 03:35:57 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/DefaultCaseAggregationConditionService.java	2011-09-22 05:46:07 +0000
@@ -76,6 +76,8 @@
 
     private final String IS_NULL = "is null";
 
+    private final String PROPERTY_AGE = "age";
+
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
@@ -266,7 +268,6 @@
             if ( programStage == null || dataElement == null || optionCombo == null )
             {
                 return "Invalid condition";
-
             }
 
             matcher.appendReplacement( decription, "[" + programStage.getName() + SEPARATOR_ID + dataElement.getName()
@@ -550,13 +551,24 @@
 
     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 "
+        String sql = "SELECT distinct(p.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 "
             + "psi.programinstanceid = pi.programinstanceid INNER JOIN patient as p ON "
             + "p.patientid = pi.patientid WHERE pd.organisationunitid = " + orgunitId + " "
-            + "AND psi.executionDate >= '" + startDate + "' AND psi.executionDate <= '" + endDate + "' AND p."
-            + propertyName + " ";
+            + "AND psi.executionDate >= '" + startDate + "' AND psi.executionDate <= '" + endDate;
+
+        if ( propertyName.equals( PROPERTY_AGE ) )
+        {
+            sql += "' AND ((  12 * ( EXTRACT(YEAR FROM '" + startDate + "' ) - EXTRACT(YEAR FROM birthdate ) ) ) + "
+                + "EXTRACT( MONTH FROM '" + startDate + "' ) - EXTRACT( MONTH FROM birthdate ) )" + " ";
+        }
+        else
+        {
+            sql += "' AND p." + propertyName + " ";
+        }
+
+        return sql;
     }
 
     private String getConditionForProgramProperty( int orgunitId, String startDate, String endDate )

=== 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-09-22 03:11:29 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties	2011-09-22 05:46:07 +0000
@@ -48,7 +48,7 @@
 please_specify_the_b_side_of_the_relationship_type = Please specify the B side of the relationship type
 relationship_type_management = Relationship Type Management
 or = or
-age = Age
+age_month = Age(months)
 specify_name_s = Please specify name(s)
 estimated = Estimated
 age_must_integer = Age must be integer
@@ -374,4 +374,6 @@
 tall= Tall
 patient_chart_details = Patient chart details
 single_event = Single event
-paitents_and_programs = Beneficiaries and Programs
\ No newline at end of file
+paitents_and_programs = Beneficiaries and Programs
+gender = Gender
+dob_type = DOB Type
\ 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-07-28 06:36:51 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addCaseAggregation.vm	2011-09-22 05:46:07 +0000
@@ -130,7 +130,8 @@
 				<td>
 					<select id="caseProperty" name="caseProperty" size="8" ondblclick="insertInfo(this);" style="width:18em; height:16.5em" >
 						<option value="[CP:gender]">$i18n.getString( "gender" )</option>
-						<option value="[CP:dobType]">$i18n.getString( "dobType" )</option>
+						<option value="[CP:dobType]">$i18n.getString( "dob_type" )</option>
+						<option value="[CP:age]">$i18n.getString( "age_month" )</option>
 						
 						#foreach( $patientAttribute in $patientAttributes )
 						<option value="[CA:$patientAttribute.id]">$encoder.htmlEncode( $patientAttribute.name )</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-07-28 07:45:31 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updateCaseAggregation.vm	2011-09-22 05:46:07 +0000
@@ -131,7 +131,8 @@
 				<td>
 					<select id="caseProperty" name="caseProperty" size="5" ondblclick="insertInfo(this);" style="width:20em; 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( "dob_type" )</option>
+						<option value="[CP:age]">$i18n.getString( "age_month" )</option>
 						
 						#foreach( $patientAttribute in $patientAttributes )
 						<option value="[CA:$patientAttribute.id]">$encoder.htmlEncode( $patientAttribute.name )</option>