← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10705: Add new formula to calculate number of children orgunits completed all program-stage-instance (WIP).

 

------------------------------------------------------------
revno: 10705
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2013-04-28 21:35:49 +0700
message:
  Add new formula to calculate number of children orgunits completed all program-stage-instance (WIP).
modified:
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/jdbc/JdbcCaseAggregationConditionManager.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/CaseAggregationResultAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml


--
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/jdbc/JdbcCaseAggregationConditionManager.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/jdbc/JdbcCaseAggregationConditionManager.java	2013-04-28 08:54:29 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/jdbc/JdbcCaseAggregationConditionManager.java	2013-04-28 14:35:49 +0000
@@ -288,23 +288,18 @@
                 String caseOperator = rs.getString( "caseoperator" );
                 int deSumId = rs.getInt( "desumid" );
 
-                boolean flag = hasOrgunitProgramStageCompleted( caseExpression );
-
-                if ( !flag )
-                {
-                    Collection<Integer> _orgunitIds = getServiceOrgunit(
-                        DateUtils.getMediumDateString( period.getStartDate() ),
-                        DateUtils.getMediumDateString( period.getEndDate() ) );
-
-                    if ( orgunitIds == null )
-                    {
-                        orgunitIds = new HashSet<Integer>();
-                        orgunitIds.addAll( _orgunitIds );
-                    }
-                    else
-                    {
-                        orgunitIds.retainAll( _orgunitIds );
-                    }
+                Collection<Integer> _orgunitIds = getServiceOrgunit(
+                    DateUtils.getMediumDateString( period.getStartDate() ),
+                    DateUtils.getMediumDateString( period.getEndDate() ) );
+
+                if ( orgunitIds == null )
+                {
+                    orgunitIds = new HashSet<Integer>();
+                    orgunitIds.addAll( _orgunitIds );
+                }
+                else
+                {
+                    orgunitIds.retainAll( _orgunitIds );
                 }
 
                 // ---------------------------------------------------------------------
@@ -957,9 +952,8 @@
                 + "         FROM programstageinstance psi ";
         }
 
-        sql += " JOIN organisationunit ou ON psi.organisationunitid=ou.organisationunitid " + " WHERE ou.parentid="
-            + orgunitId + " AND psi.completed=true AND psi.programstageid = " + programStageId + " AND "
-            + " psi.executiondate >= '" + startDate + "' AND psi.executiondate <= '" + endDate + "' ";
+        sql += " WHERE psi.organisationunitid=" + orgunitId + " AND psi.completed=true AND psi.programstageid = " + programStageId
+            + " AND " + " psi.executiondate >= '" + startDate + "' AND psi.executiondate <= '" + endDate + "' ";
 
         if ( flag )
         {

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/CaseAggregationResultAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/CaseAggregationResultAction.java	2013-04-28 08:54:29 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/CaseAggregationResultAction.java	2013-04-28 14:35:49 +0000
@@ -52,7 +52,6 @@
 import org.hisp.dhis.period.CalendarPeriodType;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodType;
-import org.hisp.dhis.program.ProgramStageInstanceService;
 
 import com.opensymphony.xwork2.Action;
 
@@ -104,13 +103,6 @@
         this.organisationUnitService = organisationUnitService;
     }
 
-    private ProgramStageInstanceService programStageInstanceService;
-
-    public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService )
-    {
-        this.programStageInstanceService = programStageInstanceService;
-    }
-
     private I18nFormat format;
 
     public void setFormat( I18nFormat format )
@@ -264,19 +256,12 @@
         // ---------------------------------------------------------------------
         // Aggregation
         // ---------------------------------------------------------------------
-        for ( CaseAggregationCondition condition : aggregationConditions )
+        for ( Integer orgUnitId : orgunitIds )
         {
-            boolean flag = aggregationConditionService.hasOrgunitProgramStageCompleted( condition.getAggregationExpression() );
-
-            if ( !flag )
-            {
-                orgunitIds.retainAll( programStageInstanceService.getOrganisationUnitIds( sDate, eDate ) );
-            }
-            
-            for ( Integer orgUnitId : orgunitIds )
-            {
-                OrganisationUnit orgUnit = organisationUnitService.getOrganisationUnit( orgUnitId );
-
+            OrganisationUnit orgUnit = organisationUnitService.getOrganisationUnit( orgUnitId );
+
+            for ( CaseAggregationCondition condition : aggregationConditions )
+            {
                 DataElement dElement = condition.getAggregationDataElement();
                 DataElementCategoryOptionCombo optionCombo = condition.getOptionCombo();
 

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml	2013-04-24 06:11:42 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml	2013-04-28 14:35:49 +0000
@@ -315,8 +315,6 @@
 		<property name="dataValueService" ref="org.hisp.dhis.datavalue.DataValueService" />
 		<property name="organisationUnitService"
 			ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
-		<property name="programStageInstanceService"
-			ref="org.hisp.dhis.program.ProgramStageInstanceService" />
 	</bean>
 
 	<bean