← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9316: Minor fix statistical program report.

 

------------------------------------------------------------
revno: 9316
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2012-12-14 15:41:56 +0700
message:
  Minor fix statistical program report.
modified:
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.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-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	2012-12-14 07:29:29 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java	2012-12-14 08:41:56 +0000
@@ -293,40 +293,43 @@
         int total = programInstanceService.countProgramInstances( program, orgunitIds, startDate, endDate );
         grid.setSubtitle( i18n.getString( "total_result" ) + ": " + total );
 
-        grid.addHeader( new GridHeader( i18n.getString( "program_stage" ), false, true ) );
-        grid.addHeader( new GridHeader( i18n.getString( "completed" ), false, false ) );
-        grid.addHeader( new GridHeader( i18n.getString( "percent_completed" ), false, false ) );
-        grid.addHeader( new GridHeader( i18n.getString( "incomplete" ), false, false ) );
-        grid.addHeader( new GridHeader( i18n.getString( "percent_incomplete" ), false, false ) );
-        grid.addHeader( new GridHeader( i18n.getString( "Scheduled" ), false, false ) );
-        grid.addHeader( new GridHeader( i18n.getString( "percent_Scheduled" ), false, false ) );
-        grid.addHeader( new GridHeader( i18n.getString( "overdue" ), false, false ) );
-        grid.addHeader( new GridHeader( i18n.getString( "percent_overdue" ), false, false ) );
-
-        for ( ProgramStage programStage : program.getProgramStages() )
+        if ( total > 0 )
         {
-            grid.addRow();
-            grid.addValue( programStage.getName() );
-
-            int completed = programStageInstanceStore.getStatisticalProgramStageReport( programStage, orgunitIds,
-                startDate, endDate, ProgramStageInstance.COMPLETED_STATUS );
-            grid.addValue( completed );
-            grid.addValue( (completed + 0.0) / total );
-
-            int incomplete = programStageInstanceStore.getStatisticalProgramStageReport( programStage, orgunitIds,
-                startDate, endDate, ProgramStageInstance.VISITED_STATUS );
-            grid.addValue( incomplete );
-            grid.addValue( (incomplete + 0.0) / total );
-
-            int Scheduled = programStageInstanceStore.getStatisticalProgramStageReport( programStage, orgunitIds,
-                startDate, endDate, ProgramStageInstance.FUTURE_VISIT_STATUS );
-            grid.addValue( Scheduled );
-            grid.addValue( (Scheduled + 0.0) / total );
-
-            int overdue = programStageInstanceStore.getStatisticalProgramStageReport( programStage, orgunitIds,
-                startDate, endDate, ProgramStageInstance.LATE_VISIT_STATUS );
-            grid.addValue( overdue );
-            grid.addValue( (overdue + 0.0) / total );
+            grid.addHeader( new GridHeader( i18n.getString( "program_stage" ), false, true ) );
+            grid.addHeader( new GridHeader( i18n.getString( "completed" ), false, false ) );
+            grid.addHeader( new GridHeader( i18n.getString( "percent_completed" ), false, false ) );
+            grid.addHeader( new GridHeader( i18n.getString( "incomplete" ), false, false ) );
+            grid.addHeader( new GridHeader( i18n.getString( "percent_incomplete" ), false, false ) );
+            grid.addHeader( new GridHeader( i18n.getString( "Scheduled" ), false, false ) );
+            grid.addHeader( new GridHeader( i18n.getString( "percent_Scheduled" ), false, false ) );
+            grid.addHeader( new GridHeader( i18n.getString( "overdue" ), false, false ) );
+            grid.addHeader( new GridHeader( i18n.getString( "percent_overdue" ), false, false ) );
+
+            for ( ProgramStage programStage : program.getProgramStages() )
+            {
+                grid.addRow();
+                grid.addValue( programStage.getName() );
+
+                int completed = programStageInstanceStore.getStatisticalProgramStageReport( programStage, orgunitIds,
+                    startDate, endDate, ProgramStageInstance.COMPLETED_STATUS );
+                grid.addValue( completed );
+                grid.addValue( (completed + 0.0) / total );
+
+                int incomplete = programStageInstanceStore.getStatisticalProgramStageReport( programStage, orgunitIds,
+                    startDate, endDate, ProgramStageInstance.VISITED_STATUS );
+                grid.addValue( incomplete );
+                grid.addValue( (incomplete + 0.0) / total );
+
+                int Scheduled = programStageInstanceStore.getStatisticalProgramStageReport( programStage, orgunitIds,
+                    startDate, endDate, ProgramStageInstance.FUTURE_VISIT_STATUS );
+                grid.addValue( Scheduled );
+                grid.addValue( (Scheduled + 0.0) / total );
+
+                int overdue = programStageInstanceStore.getStatisticalProgramStageReport( programStage, orgunitIds,
+                    startDate, endDate, ProgramStageInstance.LATE_VISIT_STATUS );
+                grid.addValue( overdue );
+                grid.addValue( (overdue + 0.0) / total );
+            }
         }
 
         return grid;