← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8412: Generate program summary report properly.

 

------------------------------------------------------------
revno: 8412
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2012-10-06 23:13:56 +0700
message:
  Generate program summary report properly.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstanceService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstanceStore.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateReportAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateTabularReportAction.java


--
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/ProgramInstanceService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstanceService.java	2012-09-06 03:50:03 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstanceService.java	2012-10-06 16:13:56 +0000
@@ -84,7 +84,7 @@
 
     int countProgramInstances( Program program, OrganisationUnit organisationUnit );
     
-    int countProgramInstances( Program program, OrganisationUnit organisationUnit, Date startDate, Date endDate );
+    int countProgramInstances( Program program, Collection<Integer> orgunitIds, Date startDate, Date endDate );
     
     List<Grid> getProgramInstanceReport( Patient patient, I18n i18n, I18nFormat format );
     

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstanceStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstanceStore.java	2012-09-06 03:50:03 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramInstanceStore.java	2012-10-06 16:13:56 +0000
@@ -71,5 +71,5 @@
 
     int count( Program program, OrganisationUnit organisationUnit );
     
-    int count( Program program, OrganisationUnit organisationUnit, Date startDate, Date endDate );
+    int count( Program program, Collection<Integer> orgunitIds, Date startDate, Date endDate );
 }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java	2012-10-06 15:26:50 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java	2012-10-06 16:13:56 +0000
@@ -183,9 +183,9 @@
         return programInstanceStore.count( program, organisationUnit );
     }
 
-    public int countProgramInstances( Program program, OrganisationUnit organisationUnit, Date startDate, Date endDate )
+    public int countProgramInstances( Program program, Collection<Integer> orgunitIds, Date startDate, Date endDate )
     {
-        return programInstanceStore.count( program, organisationUnit, startDate, endDate );
+        return programInstanceStore.count( program, orgunitIds, startDate, endDate );
     }
 
     public List<Grid> getProgramInstanceReport( Patient patient, I18n i18n, I18nFormat format )

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java	2012-09-06 03:50:03 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramInstanceStore.java	2012-10-06 16:13:56 +0000
@@ -152,16 +152,18 @@
         return rs != null ? rs.intValue() : 0;
     }
 
-    public int count( Program program, OrganisationUnit organisationUnit, Date startDate, Date endDate )
+    public int count( Program program, Collection<Integer> orgunitIds, Date startDate, Date endDate )
     {
         Number rs = (Number) getCriteria( Restrictions.eq( "program", program ), 
             Restrictions.isNull( "endDate" ),
             Restrictions.ge( "enrollmentDate", startDate ), 
             Restrictions.le( "enrollmentDate", endDate ) )
             .createAlias( "patient", "patient" )
-            .add(Restrictions.eq( "patient.organisationUnit", organisationUnit ) )
+            .createAlias( "patient.organisationUnit", "organisationUnit" )
+            .add(Restrictions.in( "organisationUnit.id", orgunitIds ) )
             .setProjection( Projections.rowCount() ).uniqueResult();
 
         return rs != null ? rs.intValue() : 0;
     }
+
 }

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateReportAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateReportAction.java	2012-10-06 15:55:56 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateReportAction.java	2012-10-06 16:13:56 +0000
@@ -185,8 +185,8 @@
         }
         else if ( facilityLB.equals( "childrenOnly" ) )
         {
-            orgunitIds = new HashSet<Integer>( ConversionUtils.getIdentifiers( OrganisationUnit.class,
-                organisationUnit.getChildren() ) );
+            orgunitIds.addAll( organisationUnitService.getOrganisationUnitHierarchy().getChildren(
+                organisationUnit.getId() ) );
         }
         else
         {
@@ -201,7 +201,7 @@
             // Program instances for the selected program
             // ---------------------------------------------------------------------
 
-            total = programInstanceService.countProgramInstances( program, organisationUnit, sDate, eDate );
+            total = programInstanceService.countProgramInstances( program, orgunitIds, sDate, eDate );
 
             this.paging = createPaging( total );
 

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateTabularReportAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateTabularReportAction.java	2012-10-06 04:54:55 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateTabularReportAction.java	2012-10-06 16:13:56 +0000
@@ -292,8 +292,8 @@
             for ( Integer orgunitId : orgunitIds )
             {
                 OrganisationUnit selectedOrgunit = organisationUnitService.getOrganisationUnit( orgunitId );
-                organisationUnits = new HashSet<Integer>( ConversionUtils.getIdentifiers( OrganisationUnit.class,
-                    selectedOrgunit.getChildren() ) );
+                orgunitIds.addAll( organisationUnitService.getOrganisationUnitHierarchy().getChildren(
+                    selectedOrgunit.getId() ) );
             }
         }
         else