← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12864: Clean up code.

 

------------------------------------------------------------
revno: 12864
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-11-04 13:00:38 +0700
message:
  Clean up code.
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


--
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-11-04 03:13:27 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java	2013-11-04 06:00:38 +0000
@@ -112,49 +112,6 @@
         ProgramStage programStage );
 
     /**
-     * Retrieve an event list on a program stage
-     * 
-     * @param programStage ProgramStage
-     * 
-     * @return ProgramStageInstance
-     */
-    Collection<ProgramStageInstance> getProgramStageInstances( ProgramStage programStage );
-
-    /**
-     * Retrieve an event list on program stage by an orgunit
-     * 
-     * @param programStage ProgramStage
-     * @param organisationUnit OrganisationUnit
-     * 
-     * @return ProgramStageInstance list
-     */
-    Collection<ProgramStageInstance> getProgramStageInstances( ProgramStage programStage,
-        OrganisationUnit organisationUnit );
-
-    /**
-     * Retrieve an event list on program stage by an orgunit in a due date
-     * period
-     * 
-     * @param programStage ProgramStage
-     * @param organisationUnit OrganisationUnit
-     * @param after Optional date the instance should be on or after.
-     * @param before Optional date the instance should be on or before.
-     * 
-     * @return ProgramStageInstance list
-     */
-    Collection<ProgramStageInstance> getProgramStageInstances( ProgramStage programStage,
-        OrganisationUnit organisationUnit, Date after, Date before );
-
-    /**
-     * Retrieve an event list on program instance list
-     * 
-     * @param programInstances ProgramInstance list
-     * 
-     * @return ProgramStageInstance list
-     */
-    Collection<ProgramStageInstance> getProgramStageInstances( Collection<ProgramInstance> programInstances );
-
-    /**
      * Retrieve an event list on program instance list with a certain status
      * 
      * @param programInstances ProgramInstance list
@@ -167,54 +124,6 @@
         boolean completed );
 
     /**
-     * Retrieve an event list on due-date
-     * 
-     * @param dueDate Due date
-     * 
-     * @return ProgramStageInstance list
-     */
-    Collection<ProgramStageInstance> getProgramStageInstances( Date dueDate );
-
-    /**
-     * Retrieve an event list by status on due date
-     * 
-     * @param dueDate Due date
-     * @param completed Optional flag to only get completed (<code>true</code> )
-     *        or uncompleted (<code>false</code>) instances.
-     * 
-     * @return ProgramStageInstance list
-     */
-    Collection<ProgramStageInstance> getProgramStageInstances( Date dueDate, Boolean completed );
-
-    /**
-     * Retrieve an event list in a period
-     * 
-     * @param after - Optional date the instance should be on or after.
-     * @param before - optional date the instance should be on or before.
-     * 
-     * @param ProgramStageInstance list
-     */
-    Collection<ProgramStageInstance> getProgramStageInstances( Date after, Date before );
-
-    /**
-     * Retrieve an event list by complete status in a period
-     * 
-     * @param after Optional date the instance should be on or after.
-     * @param before Optional date the instance should be on or before.
-     * @param completed Optional flag to only get completed (<code>true</code> )
-     *        or uncompleted (<code>false</code>) instances.
-     */
-    Collection<ProgramStageInstance> getProgramStageInstances( Date startDate, Date endDate, Boolean completed );
-
-    /**
-     * Returns all {@link ProgramStageInstance}.
-     * 
-     * @return a collection of all event, or an empty collection if there are no
-     *         ProgramStageInstances.
-     */
-    Collection<ProgramStageInstance> getAllProgramStageInstances();
-
-    /**
      * Get statuses of events
      * 
      * @param programStageInstances ProgramStageInstance list
@@ -224,19 +133,6 @@
     Map<Integer, Integer> statusProgramStageInstances( Collection<ProgramStageInstance> programStageInstances );
 
     /**
-     * Get all {@link ProgramStageInstance program stage instances} for unit,
-     * optionally filtering by date or completed.
-     * 
-     * @param unit - the unit to get instances for.
-     * @param after - optional date the instance should be on or after.
-     * @param before - optional date the instance should be on or before.
-     * @param completed - optional flag to only get completed (<code>true</code>
-     *        ) or uncompleted (<code>false</code>) instances.
-     * @return
-     */
-    List<ProgramStageInstance> get( OrganisationUnit unit, Date after, Date before, Boolean completed );
-
-    /**
      * Get all events by patient, optionally filtering by completed.
      * 
      * @param patient Patient
@@ -313,10 +209,6 @@
     List<ProgramStageInstance> getStatisticalProgramStageDetailsReport( ProgramStage programStage,
         Collection<Integer> orgunitIds, Date startDate, Date endDate, int status, Integer max, Integer min );
 
-    // -------------------------------------------------------------------------
-    // Statistical
-    // -------------------------------------------------------------------------
-
     /**
      * Get events of a program by report date
      * 
@@ -358,7 +250,7 @@
      * @return A number
      */
     int averageNumberCompletedProgramInstance( Program program, Collection<Integer> orgunitIds, Date startDate,
-        Date endDate, Integer status );
+        Date endDate, int status );
 
     /**
      * Get ids of orgunits where events happened in a period
@@ -441,4 +333,5 @@
      */
     void createProgramStageInstance( Patient patient, Program program, Date executionDate,
         OrganisationUnit organisationUnit );
+
 }

=== 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-11-04 03:13:27 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java	2013-11-04 06:00:38 +0000
@@ -79,55 +79,6 @@
     Collection<ProgramStageInstance> get( ProgramStage programStage );
 
     /**
-     * Retrieve an event list on due-date
-     * 
-     * @param dueDate Due date
-     * 
-     * @return ProgramStageInstance list
-     */
-    Collection<ProgramStageInstance> get( Date dueDate );
-
-    /**
-     * Retrieve an event list by status on due date
-     * 
-     * @param dueDate Due date
-     * @param completed Optional flag to only get completed (<code>true</code> )
-     *        or uncompleted (<code>false</code>) instances.
-     * 
-     * @return ProgramStageInstance list
-     */
-    Collection<ProgramStageInstance> get( Date dueDate, Boolean completed );
-
-    /**
-     * Retrieve an event list in a due date period
-     * 
-     * @param after - Optional date the instance should be on or after.
-     * @param before - optional date the instance should be on or before.
-     * 
-     * @param ProgramStageInstance list
-     */
-    Collection<ProgramStageInstance> get( Date startDate, Date endDate );
-
-    /**
-     * Retrieve an event list by complete status in a period
-     * 
-     * @param after Optional date the instance should be on or after.
-     * @param before Optional date the instance should be on or before.
-     * @param completed Optional flag to only get completed (<code>true</code> )
-     *        or uncompleted (<code>false</code>) instances.
-     */
-    Collection<ProgramStageInstance> get( Date startDate, Date endDate, Boolean completed );
-
-    /**
-     * Retrieve an event list on program instance list
-     * 
-     * @param programInstances ProgramInstance list
-     * 
-     * @return ProgramStageInstance list
-     */
-    Collection<ProgramStageInstance> get( Collection<ProgramInstance> programInstances );
-
-    /**
      * Retrieve an event list on program instance list with a certain status
      * 
      * @param programInstances ProgramInstance list
@@ -139,18 +90,6 @@
     Collection<ProgramStageInstance> get( Collection<ProgramInstance> programInstances, boolean completed );
 
     /**
-     * Get all {@link ProgramStageInstance program stage instances} for unit.
-     * 
-     * @param unit - the unit to get instances for.
-     * @param after - optional date the instance should be on or after.
-     * @param before - optional date the instance should be on or before.
-     * @param completed - optional flag to only get completed (<code>true</code>
-     *        ) or uncompleted (<code>false</code>) instances.
-     * @return
-     */
-    List<ProgramStageInstance> get( OrganisationUnit unit, Date after, Date before, Boolean completed );
-
-    /**
      * Get all events by patient, optionally filtering by completed.
      * 
      * @param patient Patient
@@ -163,30 +102,6 @@
     List<ProgramStageInstance> get( Patient patient, Boolean completed );
 
     /**
-     * Retrieve an event list on program stage by an orgunit
-     * 
-     * @param programStage ProgramStage
-     * @param organisationUnit OrganisationUnit
-     * 
-     * @return ProgramStageInstance list
-     */
-    List<ProgramStageInstance> get( ProgramStage programStage, OrganisationUnit orgunit );
-
-    /**
-     * Retrieve an event list on program stage by an orgunit in a due date
-     * period
-     * 
-     * @param programStage ProgramStage
-     * @param organisationUnit OrganisationUnit
-     * @param after Optional date the instance should be on or after.
-     * @param before Optional date the instance should be on or before.
-     * 
-     * @return ProgramStageInstance list
-     */
-    List<ProgramStageInstance> get( ProgramStage programStage, OrganisationUnit orgunit, Date startDate, Date endDate,
-        int min, int max );
-
-    /**
      * Remove events without any data values
      * 
      * @param programStage Empty events belong to this program stage are removed
@@ -306,8 +221,8 @@
      *        LATE_VISIT_STATUS
      * @return A number
      */
-    int averageNumberCompleted( Program program, Collection<Integer> orgunitIds, Date startDate, Date endDate,
-        Integer status );
+    int averageNumberCompleted( Program program, Collection<Integer> orgunitIds, Date after, Date before,
+        int status );
 
     /**
      * Get ids of orgunits where events happened in a period

=== 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-11-04 00:01:39 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java	2013-11-04 06:00:38 +0000
@@ -124,32 +124,32 @@
     // Implementation methods
     // -------------------------------------------------------------------------
 
+    @Override
     public int addProgramStageInstance( ProgramStageInstance programStageInstance )
     {
         programStageInstance.setAutoFields();
         return programStageInstanceStore.save( programStageInstance );
     }
 
+    @Override
     public void deleteProgramStageInstance( ProgramStageInstance programStageInstance )
     {
         programStageInstanceStore.delete( programStageInstance );
     }
 
-    public Collection<ProgramStageInstance> getAllProgramStageInstances()
-    {
-        return programStageInstanceStore.getAll();
-    }
-
+    @Override
     public ProgramStageInstance getProgramStageInstance( int id )
     {
         return programStageInstanceStore.get( id );
     }
 
+    @Override
     public ProgramStageInstance getProgramStageInstance( String uid )
     {
         return programStageInstanceStore.getByUid( uid );
     }
 
+    @Override
     public ProgramStageInstance getProgramStageInstance( ProgramInstance programInstance, ProgramStage programStage )
     {
         return programStageInstanceStore.get( programInstance, programStage );
@@ -162,31 +162,14 @@
         return programStageInstanceStore.getAll( programInstance, programStage );
     }
 
-    public Collection<ProgramStageInstance> getProgramStageInstances( ProgramStage programStage )
-    {
-        return programStageInstanceStore.get( programStage );
-    }
-
-    @Override
-    public Collection<ProgramStageInstance> getProgramStageInstances( ProgramStage programStage,
-        OrganisationUnit organisationUnit )
-    {
-        return programStageInstanceStore.get( programStage, organisationUnit );
-    }
-
-    @Override
-    public Collection<ProgramStageInstance> getProgramStageInstances( ProgramStage programStage,
-        OrganisationUnit organisationUnit, Date start, Date end )
-    {
-        return programStageInstanceStore.get( programStage, organisationUnit, start, end, 0, Integer.MAX_VALUE );
-    }
-
+    @Override
     public void updateProgramStageInstance( ProgramStageInstance programStageInstance )
     {
         programStageInstance.setAutoFields();
         programStageInstanceStore.update( programStageInstance );
     }
 
+    @Override
     public Map<Integer, Integer> statusProgramStageInstances( Collection<ProgramStageInstance> programStageInstances )
     {
         Map<Integer, Integer> colorMap = new HashMap<Integer, Integer>();
@@ -199,47 +182,20 @@
         return colorMap;
     }
 
-    public Collection<ProgramStageInstance> getProgramStageInstances( Collection<ProgramInstance> programInstances )
-    {
-        return programStageInstanceStore.get( programInstances );
-    }
-
+    @Override
     public Collection<ProgramStageInstance> getProgramStageInstances( Collection<ProgramInstance> programInstances,
         boolean completed )
     {
         return programStageInstanceStore.get( programInstances, completed );
     }
 
-    public Collection<ProgramStageInstance> getProgramStageInstances( Date dueDate )
-    {
-        return programStageInstanceStore.get( dueDate );
-    }
-
-    public Collection<ProgramStageInstance> getProgramStageInstances( Date dueDate, Boolean completed )
-    {
-        return programStageInstanceStore.get( dueDate, completed );
-    }
-
-    public Collection<ProgramStageInstance> getProgramStageInstances( Date startDate, Date endDate )
-    {
-        return programStageInstanceStore.get( startDate, endDate );
-    }
-
-    public Collection<ProgramStageInstance> getProgramStageInstances( Date startDate, Date endDate, Boolean completed )
-    {
-        return programStageInstanceStore.get( startDate, endDate, completed );
-    }
-
-    public List<ProgramStageInstance> get( OrganisationUnit unit, Date after, Date before, Boolean completed )
-    {
-        return programStageInstanceStore.get( unit, after, before, completed );
-    }
-
+    @Override
     public List<ProgramStageInstance> getProgramStageInstances( Patient patient, Boolean completed )
     {
         return programStageInstanceStore.get( patient, completed );
     }
 
+    @Override
     public List<Grid> getProgramStageInstancesReport( ProgramInstance programInstance, I18nFormat format, I18n i18n )
     {
         List<Grid> grids = new ArrayList<Grid>();
@@ -309,6 +265,7 @@
         return grids;
     }
 
+    @Override
     public void removeEmptyEvents( ProgramStage programStage, OrganisationUnit organisationUnit )
     {
         programStageInstanceStore.removeEmptyEvents( programStage, organisationUnit );
@@ -320,29 +277,19 @@
         programStageInstanceStore.update( programStageInstanceIds, outboundSms );
     }
 
+    @Override
     public Collection<SchedulingProgramObject> getSendMesssageEvents()
     {
         return programStageInstanceStore.getSendMesssageEvents();
     }
 
+    @Override
     public Collection<ProgramStageInstance> getProgramStageInstances( Program program, Collection<Integer> orgunitIds,
         Date startDate, Date endDate, Boolean completed )
     {
         return programStageInstanceStore.get( program, orgunitIds, startDate, endDate, completed );
     }
 
-    public int getProgramStageInstanceCount( Program program, Collection<Integer> orgunitIds, Date startDate,
-        Date endDate, Boolean completed )
-    {
-        return programStageInstanceStore.count( program, orgunitIds, startDate, endDate, completed );
-    }
-
-    public int getProgramStageInstanceCount( ProgramStage programStage, Collection<Integer> orgunitIds, Date startDate,
-        Date endDate, Boolean completed )
-    {
-        return programStageInstanceStore.count( programStage, orgunitIds, startDate, endDate, completed );
-    }
-
     @Override
     public Grid getStatisticalReport( Program program, Collection<Integer> orgunitIds, Date startDate, Date endDate,
         I18n i18n, I18nFormat format )
@@ -465,16 +412,14 @@
             grid.addValue( programStage.getDisplayName() );
 
             // Visits scheduled (All)
-
-            int totalAll = this.getProgramStageInstanceCount( programStage, orgunitIds, startDate, endDate, null );
+            int totalAll = programStageInstanceStore.count( programStage, orgunitIds, startDate, endDate, null );
             grid.addValue( totalAll );
 
             // Visits done (#) = Incomplete + Complete stages.
-
-            int totalCompletedEvent = this.getProgramStageInstanceCount( programStage, orgunitIds, startDate, endDate,
+            int totalCompletedEvent = programStageInstanceStore.count( programStage, orgunitIds, startDate, endDate,
                 true );
             int totalVisit = totalCompletedEvent
-                + this.getProgramStageInstanceCount( programStage, orgunitIds, startDate, endDate, false );
+                + programStageInstanceStore.count( programStage, orgunitIds, startDate, endDate, false );
             grid.addValue( totalVisit );
 
             // Visits done (%)
@@ -516,6 +461,7 @@
         return grid;
     }
 
+    @Override
     public List<ProgramStageInstance> getStatisticalProgramStageDetailsReport( ProgramStage programStage,
         Collection<Integer> orgunitIds, Date startDate, Date endDate, int status, Integer min, Integer max )
     {
@@ -532,7 +478,7 @@
 
     @Override
     public int averageNumberCompletedProgramInstance( Program program, Collection<Integer> orgunitIds, Date startDate,
-        Date endDate, Integer status )
+        Date endDate, int status )
     {
         return programStageInstanceStore.averageNumberCompleted( program, orgunitIds, startDate, endDate, status );
     }
@@ -755,4 +701,5 @@
 
         return outboundSms;
     }
+
 }
\ No newline at end of file

=== 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-11-04 00:01:39 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java	2013-11-04 06:00:38 +0000
@@ -36,7 +36,6 @@
 import java.util.List;
 
 import org.hibernate.Criteria;
-import org.hibernate.Query;
 import org.hibernate.criterion.Order;
 import org.hibernate.criterion.Projections;
 import org.hibernate.criterion.Restrictions;
@@ -71,7 +70,7 @@
     // -------------------------------------------------------------------------
     // Dependency
     // -------------------------------------------------------------------------
-    
+
     private ProgramInstanceService programInstanceService;
 
     public void setProgramInstanceService( ProgramInstanceService programInstanceService )
@@ -83,6 +82,7 @@
     // Implemented methods
     // -------------------------------------------------------------------------
 
+    @Override
     @SuppressWarnings( "unchecked" )
     public ProgramStageInstance get( ProgramInstance programInstance, ProgramStage programStage )
     {
@@ -93,6 +93,7 @@
         return list.isEmpty() ? null : list.get( list.size() - 1 );
     }
 
+    @Override
     @SuppressWarnings( "unchecked" )
     public Collection<ProgramStageInstance> getAll( ProgramInstance programInstance, ProgramStage programStage )
     {
@@ -102,18 +103,14 @@
         return criteria.list();
     }
 
+    @Override
     @SuppressWarnings( "unchecked" )
     public Collection<ProgramStageInstance> get( ProgramStage programStage )
     {
         return getCriteria( Restrictions.eq( "programStage", programStage ) ).list();
     }
 
-    @SuppressWarnings( "unchecked" )
-    public Collection<ProgramStageInstance> get( Collection<ProgramInstance> programInstances )
-    {
-        return getCriteria( Restrictions.in( "programInstance", programInstances ) ).list();
-    }
-
+    @Override
     @SuppressWarnings( "unchecked" )
     public Collection<ProgramStageInstance> get( Collection<ProgramInstance> programInstances, boolean completed )
     {
@@ -121,71 +118,7 @@
             Restrictions.eq( "completed", completed ) ).list();
     }
 
-    @SuppressWarnings( "unchecked" )
-    public Collection<ProgramStageInstance> get( Date dueDate )
-    {
-        return getCriteria( Restrictions.eq( "dueDate", dueDate ) ).list();
-    }
-
-    @SuppressWarnings( "unchecked" )
-    public Collection<ProgramStageInstance> get( Date dueDate, Boolean completed )
-    {
-        return getCriteria( Restrictions.eq( "dueDate", dueDate ), Restrictions.eq( "completed", completed ) ).list();
-    }
-
-    @SuppressWarnings( "unchecked" )
-    public Collection<ProgramStageInstance> get( Date startDate, Date endDate )
-    {
-        return (getCriteria( Restrictions.ge( "dueDate", startDate ), Restrictions.le( "dueDate", endDate ) )).list();
-    }
-
-    @SuppressWarnings( "unchecked" )
-    public Collection<ProgramStageInstance> get( Date startDate, Date endDate, Boolean completed )
-    {
-        return (getCriteria( Restrictions.ge( "dueDate", startDate ), Restrictions.le( "dueDate", endDate ),
-            Restrictions.eq( "completed", completed ) )).list();
-    }
-
-    @SuppressWarnings( "unchecked" )
-    public List<ProgramStageInstance> get( OrganisationUnit unit, Date after, Date before, Boolean completed )
-    {
-        String hql = "from ProgramStageInstance psi where psi.organisationUnit = :unit";
-
-        if ( after != null )
-        {
-            hql += " and dueDate >= :after";
-        }
-
-        if ( before != null )
-        {
-            hql += " and dueDate <= :before";
-        }
-
-        if ( completed != null )
-        {
-            hql += " and completed = :completed";
-        }
-
-        Query q = getQuery( hql ).setEntity( "unit", unit );
-
-        if ( after != null )
-        {
-            q.setDate( "after", after );
-        }
-
-        if ( before != null )
-        {
-            q.setDate( "before", before );
-        }
-
-        if ( completed != null )
-        {
-            q.setBoolean( "completed", completed );
-        }
-
-        return q.list();
-    }
-
+    @Override
     @SuppressWarnings( "unchecked" )
     public List<ProgramStageInstance> get( Patient patient, Boolean completed )
     {
@@ -194,23 +127,8 @@
         return getQuery( hql ).setEntity( "patient", patient ).setBoolean( "completed", completed ).list();
     }
 
+
     @Override
-    @SuppressWarnings( "unchecked" )
-    public List<ProgramStageInstance> get( ProgramStage programStage, OrganisationUnit organisationUnit )
-    {
-        return getCriteria( Restrictions.eq( "programStage", programStage ),
-            Restrictions.eq( "organisationUnit", organisationUnit ) ).list();
-    }
-
-    @SuppressWarnings( "unchecked" )
-    public List<ProgramStageInstance> get( ProgramStage programStage, OrganisationUnit orgunit, Date startDate,
-        Date endDate, int min, int max )
-    {
-        return getCriteria( Restrictions.eq( "programStage", programStage ),
-            Restrictions.eq( "organisationUnit", orgunit ), Restrictions.between( "dueDate", startDate, endDate ) )
-            .setFirstResult( min ).setMaxResults( max ).list();
-    }
-
     public void removeEmptyEvents( ProgramStage programStage, OrganisationUnit organisationUnit )
     {
         String sql = "delete from programstageinstance where programstageid=" + programStage.getId()
@@ -242,6 +160,7 @@
         }
     }
 
+    @Override
     public Collection<SchedulingProgramObject> getSendMesssageEvents()
     {
         String sql = " ( " + sendMessageToPatientSql() + " ) ";
@@ -296,6 +215,7 @@
         return schedulingProgramObjects;
     }
 
+    @Override
     public int getStatisticalProgramStageReport( ProgramStage programStage, Collection<Integer> orgunitIds,
         Date startDate, Date endDate, int status )
     {
@@ -306,6 +226,7 @@
         return rs != null ? rs.intValue() : 0;
     }
 
+    @Override
     @SuppressWarnings( "unchecked" )
     public List<ProgramStageInstance> getStatisticalProgramStageDetailsReport( ProgramStage programStage,
         Collection<Integer> orgunitIds, Date startDate, Date endDate, int status, Integer min, Integer max )
@@ -321,6 +242,7 @@
         return criteria.list();
     }
 
+    @Override
     public int getOverDueCount( ProgramStage programStage, Collection<Integer> orgunitIds, Date startDate, Date endDate )
     {
         Calendar yesterday = Calendar.getInstance();
@@ -349,6 +271,7 @@
         return rs != null ? rs.intValue() : 0;
     }
 
+    @Override
     @SuppressWarnings( "unchecked" )
     public Collection<ProgramStageInstance> get( Program program, Collection<Integer> orgunitIds, Date startDate,
         Date endDate, Boolean completed )
@@ -356,6 +279,7 @@
         return getCriteria( program, orgunitIds, startDate, endDate, completed ).list();
     }
 
+    @Override
     public int count( Program program, Collection<Integer> orgunitIds, Date startDate, Date endDate, Boolean completed )
     {
         Number rs = (Number) getCriteria( program, orgunitIds, startDate, endDate, completed ).setProjection(
@@ -364,6 +288,7 @@
         return rs != null ? rs.intValue() : 0;
     }
 
+    @Override
     public int count( ProgramStage programStage, Collection<Integer> orgunitIds, Date startDate, Date endDate,
         Boolean completed )
     {
@@ -373,6 +298,7 @@
         return rs != null ? rs.intValue() : 0;
     }
 
+    @Override
     public Grid getCompleteness( Collection<Integer> orgunitIds, Program program, String startDate, String endDate,
         I18n i18n )
     {
@@ -539,11 +465,12 @@
         return criteria;
     }
 
-    public int averageNumberCompleted( Program program, Collection<Integer> orgunitIds, Date startDate, Date endDate,
-        Integer status )
+    @Override
+    public int averageNumberCompleted( Program program, Collection<Integer> orgunitIds, Date after, Date before,
+        int status )
     {
         Collection<ProgramInstance> programInstances = programInstanceService.getProgramInstancesByStatus(
-            ProgramInstance.STATUS_COMPLETED, program, orgunitIds, startDate, endDate );
+            ProgramInstance.STATUS_COMPLETED, program, orgunitIds, after, before );
         Criteria criteria = getCriteria();
         criteria.createAlias( "programInstance", "programInstance" );
         criteria.createAlias( "programStage", "programStage" );
@@ -551,7 +478,7 @@
         criteria.add( Restrictions.eq( "programInstance.program", program ) );
         criteria.add( Restrictions.eq( "programInstance.status", status ) );
         criteria.add( Restrictions.in( "organisationUnit.id", orgunitIds ) );
-        criteria.add( Restrictions.between( "programInstance.endDate", startDate, endDate ) );
+        criteria.add( Restrictions.between( "programInstance.endDate", after, before ) );
         criteria.add( Restrictions.eq( "completed", true ) );
         if ( programInstances != null && programInstances.size() > 0 )
         {