dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #21789
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10412: Only run case-aggregate-fomulas for orgunits which have data in periods selected.
------------------------------------------------------------
revno: 10412
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-03-25 11:02:33 +0700
message:
Only run case-aggregate-fomulas for orgunits which have data in periods selected.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.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-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java 2013-03-25 03:32:55 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java 2013-03-25 04:02:33 +0000
@@ -125,4 +125,6 @@
int getOverDueEventCount( ProgramStage programStage, Collection<Integer> orgunitIds, Date startDate, Date endDate );
int averageNumberCompletedProgramInstance( Program program , Collection<Integer> orgunitIds, Date startDate, Date endDate, Boolean completed );
+
+ Collection<Integer> getOrganisationUnitIds ( Date startDate, Date endDate );
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java 2013-03-25 03:32:55 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java 2013-03-25 04:02:33 +0000
@@ -124,4 +124,6 @@
int averageNumberCompleted( Program program, Collection<Integer> orgunitIds, Date startDate, Date endDate,
Boolean completed );
+ Collection<Integer> getOrgunitIds ( Date startDate, Date endDate );
+
}
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java 2013-03-25 03:32:55 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java 2013-03-25 04:02:33 +0000
@@ -366,7 +366,7 @@
if ( totalCompleted != 0 )
{
int stageCompleted = averageNumberCompletedProgramInstance( program, orgunitIds, startDate, endDate, true );
- percent = (stageCompleted + 0.0) / ( totalCompleted - totalDiscontinued );
+ percent = (stageCompleted + 0.0) / (totalCompleted - totalDiscontinued);
}
grid.addValue( format.formatValue( percent ) );
grid.addValue( "" );
@@ -501,4 +501,11 @@
{
return programStageInstanceStore.averageNumberCompleted( program, orgunitIds, startDate, endDate, completed );
}
+
+ @Override
+ public Collection<Integer> getOrganisationUnitIds( Date startDate, Date endDate )
+ {
+ return programStageInstanceStore.getOrgunitIds( startDate, endDate );
+ }
+
}
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java 2013-03-25 03:32:55 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java 2013-03-25 04:02:33 +0000
@@ -1944,6 +1944,17 @@
return rs != null ? rs.intValue() : 0;
}
+ @SuppressWarnings( "unchecked" )
+ public Collection<Integer> getOrgunitIds( Date startDate, Date endDate )
+ {
+ Criteria criteria = getCriteria();
+ criteria.add( Restrictions.between( "executionDate", startDate, endDate ) );
+ criteria.createAlias( "organisationUnit", "orgunit" );
+ criteria.setProjection( Projections.distinct( Projections.projectionList().add(
+ Projections.property( "orgunit.id" ), "orgunitid" ) ) );
+ return criteria.list();
+ }
+
// ---------------------------------------------------------------------
// Get orgunitIds
// ---------------------------------------------------------------------
@@ -2016,7 +2027,7 @@
// total
if ( dataCols > 1 )
{
- grid.addValue( format.formatValue( total ));
+ grid.addValue( format.formatValue( total ) );
}
}
@@ -2028,13 +2039,13 @@
int total = 0;
for ( int i = cols - dataCols + 1; i <= cols; i++ )
{
- grid.addValue( format.formatValue(sumRow[i] ));
-
+ grid.addValue( format.formatValue( sumRow[i] ) );
+
total += sumRow[i];
}
if ( cols > cols - dataCols + 1 )
{
- grid.addValue( format.formatValue( total ));
+ grid.addValue( format.formatValue( total ) );
}
}
}
@@ -2073,7 +2084,7 @@
// Add total value of the column
if ( cols > 2 )
{
- grid.addValue( format.formatValue( total ));
+ grid.addValue( format.formatValue( total ) );
}
columnValues.put( index, column );
@@ -2122,13 +2133,13 @@
total += (Long) columnValues.get( i ).get( j );
}
}
- column.add( format.formatValue( total ) );
-
+ column.add( format.formatValue( total ) );
+
allTotal += total;
}
if ( cols > 2 )
{
- column.add(format.formatValue(allTotal ));
+ column.add( format.formatValue( allTotal ) );
}
grid.addColumn( column );
}
@@ -2138,5 +2149,5 @@
ex.printStackTrace();
}
}
-
+
}
=== 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-03-10 15:03:37 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/CaseAggregationResultAction.java 2013-03-25 04:02:33 +0000
@@ -51,6 +51,7 @@
import org.hisp.dhis.oust.manager.SelectionTreeManager;
import org.hisp.dhis.period.CalendarPeriodType;
import org.hisp.dhis.period.Period;
+import org.hisp.dhis.program.ProgramStageInstanceService;
import com.opensymphony.xwork2.Action;
@@ -102,6 +103,13 @@
this.organisationUnitService = organisationUnitService;
}
+ private ProgramStageInstanceService programStageInstanceService;
+
+ public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService )
+ {
+ this.programStageInstanceService = programStageInstanceService;
+ }
+
private I18nFormat format;
public void setFormat( I18nFormat format )
@@ -202,6 +210,28 @@
public String execute()
throws Exception
{
+
+ // ---------------------------------------------------------------------
+ // Get CaseAggregateCondition list
+ // ---------------------------------------------------------------------
+
+ DataSet selectedDataSet = dataSetService.getDataSet( dataSetId );
+
+ Collection<CaseAggregationCondition> aggregationConditions = aggregationConditionService
+ .getCaseAggregationCondition( selectedDataSet.getDataElements() );
+
+ // ---------------------------------------------------------------------
+ // Get selected periods list
+ // ---------------------------------------------------------------------
+
+ Date sDate = format.parseDate( startDate );
+ Date eDate = format.parseDate( endDate );
+
+ CalendarPeriodType periodType = (CalendarPeriodType) CalendarPeriodType.getPeriodTypeByName( selectedDataSet
+ .getPeriodType().getName() );
+
+ periods.addAll( periodType.generatePeriods( sDate, eDate ) );
+
// ---------------------------------------------------------------------
// Get selected orgunits
// ---------------------------------------------------------------------
@@ -231,24 +261,8 @@
selectedOrgunit.getId() ) );
}
- // ---------------------------------------------------------------------
- // Get CaseAggregateCondition list
- // ---------------------------------------------------------------------
-
- DataSet selectedDataSet = dataSetService.getDataSet( dataSetId );
-
- Collection<CaseAggregationCondition> aggregationConditions = aggregationConditionService
- .getCaseAggregationCondition( selectedDataSet.getDataElements() );
-
- // ---------------------------------------------------------------------
- // Get selected periods list
- // ---------------------------------------------------------------------
-
- CalendarPeriodType periodType = (CalendarPeriodType) CalendarPeriodType.getPeriodTypeByName( selectedDataSet
- .getPeriodType().getName() );
-
- periods.addAll( periodType.generatePeriods( format.parseDate( startDate ), format.parseDate( endDate ) ) );
-
+ orgunitIds.retainAll( programStageInstanceService.getOrganisationUnitIds( sDate, eDate ) );
+
// ---------------------------------------------------------------------
// Aggregation
// ---------------------------------------------------------------------
=== 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-03-21 04:37:26 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml 2013-03-25 04:02:33 +0000
@@ -155,7 +155,7 @@
<property name="programStageInstanceService"
ref="org.hisp.dhis.program.ProgramStageInstanceService" />
</bean>
-
+
<!-- Multi DataEntry -->
<bean
@@ -184,7 +184,8 @@
<property name="selectedStateManager"
ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
- <property name="programStageInstanceService" ref="org.hisp.dhis.program.ProgramStageInstanceService" />
+ <property name="programStageInstanceService"
+ ref="org.hisp.dhis.program.ProgramStageInstanceService" />
<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
</bean>
@@ -305,6 +306,8 @@
<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
@@ -347,10 +350,10 @@
ref="org.hisp.dhis.program.ProgramExpressionService" />
</bean>
- <bean id="org.hisp.dhis.caseentry.action.GetProgramMetaDataAction" class="org.hisp.dhis.caseentry.action.GetProgramMetaDataAction"
- scope="prototype">
- <property name="programService" ref="org.hisp.dhis.program.ProgramService" />
- </bean>
+ <bean id="org.hisp.dhis.caseentry.action.GetProgramMetaDataAction"
+ class="org.hisp.dhis.caseentry.action.GetProgramMetaDataAction" scope="prototype">
+ <property name="programService" ref="org.hisp.dhis.program.ProgramService" />
+ </bean>
<bean
id="org.hisp.dhis.caseentry.action.caseentry.LoadAnonymousProgramsAction"
@@ -653,10 +656,12 @@
<property name="patientAttributeOptionService"
ref="org.hisp.dhis.patient.PatientAttributeOptionService" />
<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
- <property name="patientAttributeService" ref="org.hisp.dhis.patient.PatientAttributeService" />
+ <property name="patientAttributeService"
+ ref="org.hisp.dhis.patient.PatientAttributeService" />
</bean>
- <bean id="org.hisp.dhis.caseentry.action.patient.SetProgramInstanceStatusAction"
+ <bean
+ id="org.hisp.dhis.caseentry.action.patient.SetProgramInstanceStatusAction"
class="org.hisp.dhis.caseentry.action.patient.SetProgramInstanceStatusAction"
scope="prototype">
<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
@@ -934,15 +939,16 @@
<property name="tabularReportService"
ref="org.hisp.dhis.patientreport.PatientTabularReportService" />
</bean>
-
-
- <bean id="org.hisp.dhis.caseentry.action.report.GetOrganisationUnitsAction"
- class="org.hisp.dhis.caseentry.action.report.GetOrganisationUnitsAction"
- scope="prototype">
- <property name="organisationUnitService"
- ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
- </bean>
-
+
+
+ <bean
+ id="org.hisp.dhis.caseentry.action.report.GetOrganisationUnitsAction"
+ class="org.hisp.dhis.caseentry.action.report.GetOrganisationUnitsAction"
+ scope="prototype">
+ <property name="organisationUnitService"
+ ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
+ </bean>
+
<!-- Patient Aggregate Report -->
@@ -1069,13 +1075,12 @@
<property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
</bean>
-
+
<bean
id="org.hisp.dhis.caseentry.action.caseentry.RemoveProgramInstanceAction"
class="org.hisp.dhis.caseentry.action.caseentry.RemoveProgramInstanceAction"
scope="prototype">
- <property name="programInstanceService"
- ref="org.hisp.dhis.program.ProgramInstanceService" />
+ <property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
</bean>
<!-- Comment -->