dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #30040
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15232: Support aggregate query builder formulas for the number days between visit-date of event and a da...
------------------------------------------------------------
revno: 15232
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-05-12 22:37:40 +0800
message:
Support aggregate query builder formulas for the number days between visit-date of event and a date-attribute value.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationCondition.java
dhis-2/dhis-services/dhis-service-eventreporting/src/main/java/org/hisp/dhis/caseaggregation/hibernate/HibernateCaseAggregationConditionStore.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/caseAggregationForm.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 2014-03-21 09:29:10 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationCondition.java 2014-05-12 14:37:40 +0000
@@ -77,7 +77,11 @@
public static String OBJECT_TRACKED_ENTITY_PROGRAM_STAGE_PROPERTY = "PC";
public static String OBJECT_ORGUNIT_COMPLETE_PROGRAM_STAGE = "PSIC";
-
+
+ public static String FORMULA_AGE = "age";
+
+ public static String FORMULA_VISIT = "visit";
+
public static String OBJECT_PROGRAM_PROPERTY_INCIDENT_DATE = "dateOfIncident";
public static String OBJECT_PROGRAM_PROPERTY_ENROLLEMENT_DATE = "enrollmentDate";
=== 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-25 06:23:18 +0000
+++ dhis-2/dhis-services/dhis-service-eventreporting/src/main/java/org/hisp/dhis/caseaggregation/hibernate/HibernateCaseAggregationConditionStore.java 2014-05-12 14:37:40 +0000
@@ -652,17 +652,30 @@
private String getConditionForTrackedEntityAttribute( String attributeId, Collection<Integer> orgunitIds,
boolean isExist )
{
- String sql = " SELECT * FROM trackedentityattributevalue _pav "
- + " WHERE _pav.trackedentityinstanceid=pi.trackedentityinstanceid ";
+ String sql = " SELECT * FROM trackedentityattributevalue _pav ";
+
if ( attributeId.split( SEPARATOR_ID ).length == 2 )
{
- attributeId = attributeId.split( SEPARATOR_ID )[0];
- sql += " AND _pav.trackedentityattributeid=" + attributeId + " AND DATE(now()) - DATE( _pav.value ) ";
+ if ( attributeId.split( SEPARATOR_ID )[1].equals( CaseAggregationCondition.FORMULA_VISIT ) )
+ {
+ sql += " inner join programinstance _pi on _pav.trackedentityinstanceid=_pi.trackedentityinstanceid ";
+ sql += " inner join programstageinstance _psi on _pi.programinstanceid=_psi.programinstanceid ";
+
+ attributeId = attributeId.split( SEPARATOR_ID )[0];
+ sql += " WHERE _pav.patientid=pi.patientid AND _pav.trackedentityattributeid=" + attributeId + " AND DATE(_psi.executiondate) - DATE( _pav.value ) ";
+ }
+ else if ( attributeId.split( SEPARATOR_ID )[1].equals( CaseAggregationCondition.FORMULA_AGE ) )
+ {
+ sql += " inner join programinstance _pi on _pav.trackedentityinstanceid=_pi.trackedentityinstanceid ";
+
+ attributeId = attributeId.split( SEPARATOR_ID )[0];
+ sql += " WHERE _pav.patientid=pi.patientid AND _pav.trackedentityattributeid=" + attributeId + " AND DATE(_psi.enrollmentdate) - DATE( _pav.value ) ";
+ }
}
else
{
- sql += " AND _pav.trackedentityattributeid=" + attributeId + " AND _pav.value ";
+ sql += " WHERE _pav.patientid=pi.patientid AND _pav.trackedentityattributeid=" + attributeId + " AND _pav.value ";
}
if ( isExist )
=== 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-05-10 06:45:30 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/webapp/dhis-web-maintenance-program/caseAggregationForm.vm 2014-05-12 14:37:40 +0000
@@ -81,7 +81,9 @@
#foreach($attribute in $attributes)
#if($attribute.valueType=='age')
#set($attId=$attribute.id + ".age")
- <option suggested="" title="$attribute.displayName" value="[CA:$attId]">$attribute.displayName</option>
+ #set($attVisitId=$attribute.id + ".visit")
+ <option suggested="" title="$attribute.displayName" value="[CA:$attId]">$attribute.displayName ($i18n.getString('ages'))</option>
+ <option value="[PS:*] AND [CA:$attVisitId]" name="multiProgram">$attribute.displayName ($i18n.getString( "age_at_visit_days_since_birth" ))</option>
#else
<option suggested="" title="$attribute.displayName" value="[CA:$attribute.id]">$attribute.displayName</option>
#end