← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 22206: tracked entity instance web-api end point now supports for seaching by program incident date.

 

------------------------------------------------------------
revno: 22206
committer: Abyot Asalefew Gizaw <abyot@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2016-03-09 12:18:52 +0100
message:
  tracked entity instance web-api end point now supports for seaching by program incident date.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceQueryParams.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityInstanceStore.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/TrackedEntityInstanceController.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/trackedentity/TrackedEntityInstanceQueryParams.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceQueryParams.java	2016-01-05 12:17:59 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceQueryParams.java	2016-03-09 11:18:52 +0000
@@ -112,12 +112,22 @@
     /**
      * Start date for enrollment in the given program.
      */
-    private Date programStartDate;
+    private Date programEnrollmentStartDate;
     
     /**
      * End date for enrollment in the given program.
      */
-    private Date programEndDate;
+    private Date programEnrollmentEndDate;
+        
+    /**
+     * Start date for incident in the given program.
+     */
+    private Date programIncidentStartDate;
+    
+    /**
+     * End date for incident in the given program.
+     */
+    private Date programIncidentEndDate;
     
     /**
      * Tracked entity of the instances in the response.
@@ -433,19 +443,35 @@
     }
     
     /**
-     * Indicates whether this params specifies a program start date.
-     */
-    public boolean hasProgramStartDate()
-    {
-        return programStartDate != null;
-    }
-    
-    /**
-     * Indicates whether this params specifies a program end date.
-     */
-    public boolean hasProgramEndDate()
-    {
-        return programEndDate != null;
+     * Indicates whether this params specifies a program enrollment start date.
+     */
+    public boolean hasProgramEnrollmentStartDate()
+    {
+        return programEnrollmentStartDate != null;
+    }
+    
+    /**
+     * Indicates whether this params specifies a program enrollment end date.
+     */
+    public boolean hasProgramEnrollmentEndDate()
+    {
+        return programEnrollmentEndDate != null;
+    }
+    
+    /**
+     * Indicates whether this params specifies a program incident start date.
+     */
+    public boolean hasProgramIncidentStartDate()
+    {
+        return programIncidentStartDate != null;
+    }
+    
+    /**
+     * Indicates whether this params specifies a program incident end date.
+     */
+    public boolean hasProgramIncidentEndDate()
+    {
+        return programIncidentEndDate != null;
     }
     
     /**
@@ -548,7 +574,8 @@
     {
         return "[Query: " + query + ", Attributes: " + attributes + ", filters: " + filters + 
             ", program: " + program + ", program status " + programStatus + ", follow up: " + followUp + 
-            ", program start date: " + programStartDate + ", program end date: " + programEndDate + 
+            ", program enrollemnt start date: " + programEnrollmentStartDate + ", program enrollment end date: " + programEnrollmentEndDate + 
+            ", program incident start date: " + programIncidentStartDate + ", program incident end date: " + programIncidentEndDate + 
             ", tracked entity: " + trackedEntity + ", org unit mode: " + organisationUnitMode + 
             ", event start date: " + eventStartDate + ", event end date: " + eventEndDate + 
             ", event status: " + eventStatus + "]";
@@ -638,24 +665,44 @@
         this.followUp = followUp;
     }
 
-    public Date getProgramStartDate()
-    {
-        return programStartDate;
-    }
-
-    public void setProgramStartDate( Date programStartDate )
-    {
-        this.programStartDate = programStartDate;
-    }
-
-    public Date getProgramEndDate()
-    {
-        return programEndDate;
-    }
-
-    public void setProgramEndDate( Date programEndDate )
-    {
-        this.programEndDate = programEndDate;
+    public Date getProgramEnrollmentStartDate()
+    {
+        return programEnrollmentStartDate;
+    }
+
+    public void setProgramEnrollmentStartDate( Date programEnrollmentStartDate )
+    {
+        this.programEnrollmentStartDate = programEnrollmentStartDate;
+    }
+
+    public Date getProgramEnrollmentEndDate()
+    {
+        return programEnrollmentEndDate;
+    }
+
+    public void setProgramEnrollmentEndDate( Date programEnrollmentEndDate )
+    {
+        this.programEnrollmentEndDate = programEnrollmentEndDate;
+    }
+
+    public Date getProgramIncidentStartDate()
+    {
+        return programIncidentStartDate;
+    }
+
+    public void setProgramIncidentStartDate( Date programIncidentStartDate )
+    {
+        this.programIncidentStartDate = programIncidentStartDate;
+    }
+
+    public Date getProgramIncidentEndDate()
+    {
+        return programIncidentEndDate;
+    }
+
+    public void setProgramIncidentEndDate( Date programIncidentEndDate )
+    {
+        this.programIncidentEndDate = programIncidentEndDate;
     }
 
     public TrackedEntity getTrackedEntity()

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceService.java	2016-01-20 03:58:55 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceService.java	2016-03-09 11:18:52 +0000
@@ -124,31 +124,33 @@
     /**
      * Returns a TrackedEntityInstanceQueryParams based on the given input.
      *
-     * @param query            the query string.
-     * @param attribute        the set of attributes.
-     * @param filter           the set of filters.
-     * @param ou               the set of organisation unit identifiers.
-     * @param ouMode           the OrganisationUnitSelectionMode.
-     * @param program          the Program identifier.
-     * @param programStatus    the ProgramStatus in the given program.
-     * @param followUp         indicates follow up status in the given Program.
-     * @param programStartDate the start date for enrollment in the given
-     *                         Program.
-     * @param programEndDate   the end date for enrollment in the given Program.
-     * @param trackedEntity    the TrackedEntity uid.
-     * @param eventStatus      the event status for the given Program.
-     * @param eventStartDate   the event start date for the given Program.
-     * @param eventEndDate     the event end date for the given Program.
-     * @param skipMeta         indicates whether to include meta data in the response.
-     * @param page             the page number.
-     * @param pageSize         the page size.
-     * @param totalPages       indicates whether to include the total number of pages.
-     * @param skipPaging       whether to skip paging.
+     * @param query                             the query string.
+     * @param attribute                         the set of attributes.
+     * @param filter                            the set of filters.
+     * @param ou                                the set of organisation unit identifiers.
+     * @param ouMode                            the OrganisationUnitSelectionMode.
+     * @param program                           the Program identifier.
+     * @param programStatus                     the ProgramStatus in the given program.
+     * @param followUp                          indicates follow up status in the given Program.
+     * @param programEnrollmentStartDate        the start date for enrollment in the given
+     *                                          Program.
+     * @param programEnrollmentEndDate          the end date for enrollment in the given Program.
+     * @param programIncidentStartDate          the start date for incident in the given Program.
+     * @param programIncidentEndDate            the end date for enrollment in the given Program.
+     * @param trackedEntity                     the TrackedEntity uid.
+     * @param eventStatus                       the event status for the given Program.
+     * @param eventStartDate                    the event start date for the given Program.
+     * @param eventEndDate                      the event end date for the given Program.
+     * @param skipMeta                          indicates whether to include meta data in the response.
+     * @param page                              the page number.
+     * @param pageSize                          the page size.
+     * @param totalPages                        indicates whether to include the total number of pages.
+     * @param skipPaging                        whether to skip paging.
      * @return a TrackedEntityInstanceQueryParams.
      */
     TrackedEntityInstanceQueryParams getFromUrl( String query, Set<String> attribute, Set<String> filter,
         Set<String> ou, OrganisationUnitSelectionMode ouMode, String program, ProgramStatus programStatus,
-        Boolean followUp, Date programStartDate, Date programEndDate, String trackedEntity, EventStatus eventStatus,
+        Boolean followUp, Date programEnrollmentStartDate, Date programEnrollmentEndDate, Date programIncidentStartDate, Date programIncidentEndDate, String trackedEntity, EventStatus eventStatus,
         Date eventStartDate, Date eventEndDate, boolean skipMeta, Integer page, Integer pageSize, boolean totalPages, boolean skipPaging );
 
     /**

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceService.java	2016-01-20 03:58:55 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceService.java	2016-03-09 11:18:52 +0000
@@ -306,16 +306,26 @@
             violation = "Program must be defined when follow up status is defined";
         }
 
-        if ( params.hasProgramStartDate() && !params.hasProgram() )
-        {
-            violation = "Program must be defined when program start date is specified";
-        }
-
-        if ( params.hasProgramEndDate() && !params.hasProgram() )
-        {
-            violation = "Program must be defined when program end date is specified";
-        }
-
+        if ( params.hasProgramEnrollmentStartDate() && !params.hasProgram() )
+        {
+            violation = "Program must be defined when program enrollment start date is specified";
+        }
+
+        if ( params.hasProgramEnrollmentEndDate() && !params.hasProgram() )
+        {
+            violation = "Program must be defined when program enrollment end date is specified";
+        }
+
+        if ( params.hasProgramIncidentStartDate() && !params.hasProgram() )
+        {
+            violation = "Program must be defined when program incident start date is specified";
+        }
+
+        if ( params.hasProgramIncidentEndDate() && !params.hasProgram() )
+        {
+            violation = "Program must be defined when program incident end date is specified";
+        }
+        
         if ( params.hasEventStatus() && (!params.hasEventStartDate() || !params.hasEventEndDate()) )
         {
             violation = "Event start and end date must be specified when event status is specified";
@@ -347,7 +357,7 @@
     @Override
     public TrackedEntityInstanceQueryParams getFromUrl( String query, Set<String> attribute, Set<String> filter,
         Set<String> ou, OrganisationUnitSelectionMode ouMode, String program, ProgramStatus programStatus,
-        Boolean followUp, Date programStartDate, Date programEndDate, String trackedEntity, EventStatus eventStatus,
+        Boolean followUp, Date programEnrollmentStartDate, Date programEnrollmentEndDate, Date programIncidentStartDate, Date programIncidentEndDate, String trackedEntity, EventStatus eventStatus,
         Date eventStartDate, Date eventEndDate, boolean skipMeta, Integer page, Integer pageSize, boolean totalPages, boolean skipPaging )
     {
         TrackedEntityInstanceQueryParams params = new TrackedEntityInstanceQueryParams();
@@ -407,8 +417,10 @@
         params.setProgram( pr );
         params.setProgramStatus( programStatus );
         params.setFollowUp( followUp );
-        params.setProgramStartDate( programStartDate );
-        params.setProgramEndDate( programEndDate );
+        params.setProgramEnrollmentStartDate( programEnrollmentStartDate );
+        params.setProgramEnrollmentEndDate( programEnrollmentEndDate );
+        params.setProgramIncidentStartDate( programIncidentStartDate );
+        params.setProgramIncidentEndDate( programIncidentEndDate );
         params.setTrackedEntity( te );
         params.setOrganisationUnitMode( ouMode );
         params.setEventStatus( eventStatus );

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityInstanceStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityInstanceStore.java	2016-01-20 03:58:55 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityInstanceStore.java	2016-03-09 11:18:52 +0000
@@ -197,14 +197,24 @@
                 hql += hlp.whereAnd() + "pi.followup = " + params.getFollowUp();
             }
 
-            if ( params.hasProgramStartDate() )
-            {
-                hql += hlp.whereAnd() + "pi.enrollmentDate >= '" + getMediumDateString( params.getProgramStartDate() ) + "'";
-            }
-
-            if ( params.hasProgramEndDate() )
-            {
-                hql += hlp.whereAnd() + "pi.enrollmentDate <= '" + getMediumDateString( params.getProgramEndDate() ) + "'";
+            if ( params.hasProgramEnrollmentStartDate() )
+            {
+                hql += hlp.whereAnd() + "pi.enrollmentDate >= '" + getMediumDateString( params.getProgramEnrollmentStartDate() ) + "'";
+            }
+
+            if ( params.hasProgramEnrollmentEndDate() )
+            {
+                hql += hlp.whereAnd() + "pi.enrollmentDate <= '" + getMediumDateString( params.getProgramEnrollmentEndDate() ) + "'";
+            }
+            
+            if ( params.hasProgramIncidentStartDate() )
+            {
+                hql += hlp.whereAnd() + "pi.incidentDate >= '" + getMediumDateString( params.getProgramIncidentStartDate() ) + "'";
+            }
+
+            if ( params.hasProgramIncidentEndDate() )
+            {
+                hql += hlp.whereAnd() + "pi.incidentDate <= '" + getMediumDateString( params.getProgramIncidentEndDate() ) + "'";
             }
 
             hql += ")";
@@ -403,14 +413,24 @@
                 sql += "and pi.followup = " + params.getFollowUp() + " ";
             }
 
-            if ( params.hasProgramStartDate() )
-            {
-                sql += "and pi.enrollmentdate >= '" + getMediumDateString( params.getProgramStartDate() ) + "' ";
-            }
-
-            if ( params.hasProgramEndDate() )
-            {
-                sql += "and pi.enrollmentdate <= '" + getMediumDateString( params.getProgramEndDate() ) + "' ";
+            if ( params.hasProgramEnrollmentStartDate() )
+            {
+                sql += "and pi.enrollmentdate >= '" + getMediumDateString( params.getProgramEnrollmentStartDate() ) + "' ";
+            }
+
+            if ( params.hasProgramEnrollmentEndDate() )
+            {
+                sql += "and pi.enrollmentdate <= '" + getMediumDateString( params.getProgramEnrollmentEndDate() ) + "' ";
+            }
+            
+            if ( params.hasProgramIncidentStartDate() )
+            {
+                sql += "and pi.incidentdate >= '" + getMediumDateString( params.getProgramIncidentStartDate() ) + "' ";
+            }
+
+            if ( params.hasProgramIncidentEndDate() )
+            {
+                sql += "and pi.incidentdate <= '" + getMediumDateString( params.getProgramIncidentEndDate() ) + "' ";
             }
 
             if ( params.hasEventStatus() )

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/TrackedEntityInstanceController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/TrackedEntityInstanceController.java	2016-02-01 07:36:06 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/TrackedEntityInstanceController.java	2016-03-09 11:18:52 +0000
@@ -29,6 +29,8 @@
  */
 
 import com.google.common.collect.Lists;
+
+import org.apache.commons.lang3.ObjectUtils;
 import org.hisp.dhis.common.DxfNamespaces;
 import org.hisp.dhis.common.Grid;
 import org.hisp.dhis.common.OrganisationUnitSelectionMode;
@@ -80,6 +82,12 @@
 
 /**
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ * 
+ * 
+ * The following statements are added not to cause api break. 
+ * They need to be remove say in 2.26 or so once users are aware of the changes.
+ * programEnrollmentStartDate= ObjectUtils.firstNonNull( programEnrollmentStartDate, programStartDate );
+ * programEnrollmentEndDate= ObjectUtils.firstNonNull( programEnrollmentEndDate, programEndDate );
  */
 @Controller
 @RequestMapping( value = TrackedEntityInstanceSchemaDescriptor.API_ENDPOINT )
@@ -122,7 +130,11 @@
         @RequestParam( required = false ) ProgramStatus programStatus,
         @RequestParam( required = false ) Boolean followUp,
         @RequestParam( required = false ) Date programStartDate,
+        @RequestParam( required = false ) Date programEnrollmentStartDate,
         @RequestParam( required = false ) Date programEndDate,
+        @RequestParam( required = false ) Date programEnrollmentEndDate,
+        @RequestParam( required = false ) Date programIncidentStartDate,
+        @RequestParam( required = false ) Date programIncidentEndDate,
         @RequestParam( required = false ) String trackedEntity,
         @RequestParam( required = false ) EventStatus eventStatus,
         @RequestParam( required = false ) Date eventStartDate,
@@ -133,6 +145,8 @@
         @RequestParam( required = false ) boolean totalPages,
         @RequestParam( required = false ) boolean skipPaging ) throws Exception
     {
+        programEnrollmentStartDate= ObjectUtils.firstNonNull( programEnrollmentStartDate, programStartDate );
+        programEnrollmentEndDate= ObjectUtils.firstNonNull( programEnrollmentEndDate, programEndDate );
         List<String> fields = Lists.newArrayList( contextService.getParameterValues( "fields" ) );
 
         if ( fields.isEmpty() )
@@ -143,7 +157,7 @@
         Set<String> orgUnits = TextUtils.splitToArray( ou, TextUtils.SEMICOLON );
 
         TrackedEntityInstanceQueryParams params = instanceService.getFromUrl( query, attribute, filter, orgUnits, ouMode,
-            program, programStatus, followUp, programStartDate, programEndDate, trackedEntity,
+            program, programStatus, followUp, programEnrollmentStartDate, programEnrollmentEndDate, programIncidentStartDate, programIncidentEndDate, trackedEntity,
             eventStatus, eventStartDate, eventEndDate, skipMeta, page, pageSize, totalPages, skipPaging );
 
         List<TrackedEntityInstance> trackedEntityInstances = trackedEntityInstanceService.getTrackedEntityInstances( params );
@@ -173,7 +187,11 @@
         @RequestParam( required = false ) ProgramStatus programStatus,
         @RequestParam( required = false ) Boolean followUp,
         @RequestParam( required = false ) Date programStartDate,
+        @RequestParam( required = false ) Date programEnrollmentStartDate,
         @RequestParam( required = false ) Date programEndDate,
+        @RequestParam( required = false ) Date programEnrollmentEndDate,
+        @RequestParam( required = false ) Date programIncidentStartDate,
+        @RequestParam( required = false ) Date programIncidentEndDate,
         @RequestParam( required = false ) String trackedEntity,
         @RequestParam( required = false ) EventStatus eventStatus,
         @RequestParam( required = false ) Date eventStartDate,
@@ -186,9 +204,11 @@
         Model model,
         HttpServletResponse response ) throws Exception
     {
+        programEnrollmentStartDate= ObjectUtils.firstNonNull( programEnrollmentStartDate, programStartDate );
+        programEnrollmentEndDate= ObjectUtils.firstNonNull( programEnrollmentEndDate, programEndDate );
         Set<String> orgUnits = TextUtils.splitToArray( ou, TextUtils.SEMICOLON );
         TrackedEntityInstanceQueryParams params = instanceService.getFromUrl( query, attribute, filter, orgUnits, ouMode,
-            program, programStatus, followUp, programStartDate, programEndDate, trackedEntity,
+            program, programStatus, followUp, programEnrollmentStartDate, programEnrollmentEndDate, programIncidentStartDate, programIncidentEndDate, trackedEntity,
             eventStatus, eventStartDate, eventEndDate, skipMeta, page, pageSize, totalPages, skipPaging );
 
         contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_JSON, CacheStrategy.NO_CACHE );
@@ -211,7 +231,11 @@
         @RequestParam( required = false ) ProgramStatus programStatus,
         @RequestParam( required = false ) Boolean followUp,
         @RequestParam( required = false ) Date programStartDate,
+        @RequestParam( required = false ) Date programEnrollmentStartDate,
         @RequestParam( required = false ) Date programEndDate,
+        @RequestParam( required = false ) Date programEnrollmentEndDate,
+        @RequestParam( required = false ) Date programIncidentStartDate,
+        @RequestParam( required = false ) Date programIncidentEndDate,
         @RequestParam( required = false ) String trackedEntity,
         @RequestParam( required = false ) EventStatus eventStatus,
         @RequestParam( required = false ) Date eventStartDate,
@@ -223,9 +247,11 @@
         @RequestParam( required = false ) boolean skipPaging,
         HttpServletResponse response ) throws Exception
     {
+        programEnrollmentStartDate= ObjectUtils.firstNonNull( programEnrollmentStartDate, programStartDate );
+        programEnrollmentEndDate= ObjectUtils.firstNonNull( programEnrollmentEndDate, programEndDate );
         Set<String> orgUnits = TextUtils.splitToArray( ou, TextUtils.SEMICOLON );
         TrackedEntityInstanceQueryParams params = instanceService.getFromUrl( query, attribute, filter, orgUnits, ouMode,
-            program, programStatus, followUp, programStartDate, programEndDate, trackedEntity,
+            program, programStatus, followUp, programEnrollmentStartDate, programEnrollmentEndDate, programIncidentStartDate, programIncidentEndDate, trackedEntity,
             eventStatus, eventStartDate, eventEndDate, skipMeta, page, pageSize, totalPages, skipPaging );
 
         contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_XML, CacheStrategy.NO_CACHE );
@@ -244,7 +270,11 @@
         @RequestParam( required = false ) ProgramStatus programStatus,
         @RequestParam( required = false ) Boolean followUp,
         @RequestParam( required = false ) Date programStartDate,
+        @RequestParam( required = false ) Date programEnrollmentStartDate,
         @RequestParam( required = false ) Date programEndDate,
+        @RequestParam( required = false ) Date programEnrollmentEndDate,
+        @RequestParam( required = false ) Date programIncidentStartDate,
+        @RequestParam( required = false ) Date programIncidentEndDate,
         @RequestParam( required = false ) String trackedEntity,
         @RequestParam( required = false ) EventStatus eventStatus,
         @RequestParam( required = false ) Date eventStartDate,
@@ -256,9 +286,11 @@
         @RequestParam( required = false ) boolean skipPaging,
         HttpServletResponse response ) throws Exception
     {
+        programEnrollmentStartDate= ObjectUtils.firstNonNull( programEnrollmentStartDate, programStartDate );
+        programEnrollmentEndDate= ObjectUtils.firstNonNull( programEnrollmentEndDate, programEndDate );
         Set<String> orgUnits = TextUtils.splitToArray( ou, TextUtils.SEMICOLON );
         TrackedEntityInstanceQueryParams params = instanceService.getFromUrl( query, attribute, filter, orgUnits, ouMode,
-            program, programStatus, followUp, programStartDate, programEndDate, trackedEntity,
+            program, programStatus, followUp, programEnrollmentStartDate, programEnrollmentEndDate, programIncidentStartDate, programIncidentEndDate, trackedEntity,
             eventStatus, eventStartDate, eventEndDate, skipMeta, page, pageSize, totalPages, skipPaging );
 
         contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_EXCEL, CacheStrategy.NO_CACHE );
@@ -277,7 +309,11 @@
         @RequestParam( required = false ) ProgramStatus programStatus,
         @RequestParam( required = false ) Boolean followUp,
         @RequestParam( required = false ) Date programStartDate,
+        @RequestParam( required = false ) Date programEnrollmentStartDate,
         @RequestParam( required = false ) Date programEndDate,
+        @RequestParam( required = false ) Date programEnrollmentEndDate,
+        @RequestParam( required = false ) Date programIncidentStartDate,
+        @RequestParam( required = false ) Date programIncidentEndDate,
         @RequestParam( required = false ) String trackedEntity,
         @RequestParam( required = false ) EventStatus eventStatus,
         @RequestParam( required = false ) Date eventStartDate,
@@ -289,9 +325,11 @@
         @RequestParam( required = false ) boolean skipPaging,
         HttpServletResponse response ) throws Exception
     {
+        programEnrollmentStartDate= ObjectUtils.firstNonNull( programEnrollmentStartDate, programStartDate );
+        programEnrollmentEndDate= ObjectUtils.firstNonNull( programEnrollmentEndDate, programEndDate );
         Set<String> orgUnits = TextUtils.splitToArray( ou, TextUtils.SEMICOLON );
         TrackedEntityInstanceQueryParams params = instanceService.getFromUrl( query, attribute, filter, orgUnits, ouMode,
-            program, programStatus, followUp, programStartDate, programEndDate, trackedEntity,
+            program, programStatus, followUp, programEnrollmentStartDate, programEnrollmentEndDate, programIncidentStartDate, programIncidentEndDate, trackedEntity,
             eventStatus, eventStartDate, eventEndDate, skipMeta, page, pageSize, totalPages, skipPaging );
 
         contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_CSV, CacheStrategy.NO_CACHE );