← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14933: Apply web-api for visit schedule function (WIP).

 

------------------------------------------------------------
revno: 14933
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-04-22 07:47:56 +0800
message:
  Apply web-api for visit schedule function (WIP).
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceStore.java
  dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceService.java
  dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityInstanceStore.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/activityPlanSelect.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/addSingleEventRegistration.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/activityPlan.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/smsReminder.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programTrackingSelect.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/selectTrackedEntityInstance.vm


--
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/TrackedEntityInstanceService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceService.java	2014-04-18 14:01:25 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceService.java	2014-04-21 23:47:56 +0000
@@ -53,8 +53,11 @@
     String ID = TrackedEntityInstanceService.class.getName();
 
     public static final int ERROR_NONE = 0;
+
     public static final int ERROR_DUPLICATE_IDENTIFIER = 1;
+
     public static final int ERROR_ENROLLMENT = 2;
+
     public static final String SAPERATOR = "_";
 
     /**
@@ -65,7 +68,7 @@
      * @return a grid.
      */
     Grid getTrackedEntityInstances( TrackedEntityInstanceQueryParams params );
-    
+
     /**
      * Returns a TrackedEntityInstanceQueryParams based on the given input.
      * 
@@ -77,7 +80,8 @@
      * @param program the Program identifier.
      * @param programStatus the ProgramStatus in the given orogram.
      * @param followUp indicates follow up status in the given Program.
-     * @param programStartDate the start date for enrollment 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.
@@ -88,20 +92,22 @@
      * @param pageSize the page size.
      * @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, Date eventStartDate, Date eventEndDate, boolean skipMeta, Integer page, Integer pageSize );
-    
+    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,
+        Date eventStartDate, Date eventEndDate, boolean skipMeta, Integer page, Integer pageSize );
+
     /**
      * Validates the given TrackedEntityInstanceQueryParams. The params is
-     * considered valid if no exception are thrown and the method returns normally.
+     * considered valid if no exception are thrown and the method returns
+     * normally.
      * 
      * @param params the TrackedEntityInstanceQueryParams.
      * @throws IllegalQueryException if the given params is invalid.
      */
     void validate( TrackedEntityInstanceQueryParams params )
         throws IllegalQueryException;
-    
+
     /**
      * Adds an {@link TrackedEntityInstance}
      * 
@@ -293,68 +299,6 @@
     Object getObjectValue( String property, String value, I18nFormat format );
 
     /**
-     * Search entityInstances by attribute values and/or a program which
-     * entityInstances enrolled into
-     * 
-     * @param searchKeys The key for searching entityInstances by attribute
-     *        values, identifiers and/or a program
-     * @param orgunit Organisation unit where entityInstances registered
-     * @param followup Only getting entityInstances with program risked if this
-     *        property is true. And getting entityInstances without program
-     *        risked if its value is false
-     * @param attributes The attribute values of these attribute are displayed
-     *        into result
-     * @param statusEnrollment The status of program of entityInstances. There
-     *        are three status, includes Active enrollments only, Completed
-     *        enrollments only and Active and completed enrollments
-     * @param min
-     * @param max
-     * 
-     * @return An object
-     */
-    Collection<TrackedEntityInstance> searchTrackedEntityInstances( List<String> searchKeys,
-        Collection<OrganisationUnit> orgunit, Boolean followup, Collection<TrackedEntityAttribute> attributes,
-        Integer statusEnrollment, Integer min, Integer max );
-
-    /**
-     * Get the number of entityInstances who meet the criteria for searching
-     * 
-     * @param searchKeys The key for searching entityInstances by attribute
-     *        values and/or a program
-     * @param orgunit Organisation unit where entityInstances registered
-     * @param followup Only getting entityInstances with program risked if this
-     *        property is true. And getting entityInstances without program
-     *        risked if its value is false
-     * @param statusEnrollment The status of program of entityInstances. There
-     *        are three status, includes Active enrollments only, Completed
-     *        enrollments only and Active and completed enrollments
-     * 
-     * @return The number of entityInstances
-     */
-    int countSearchTrackedEntityInstances( List<String> searchKeys, Collection<OrganisationUnit> orgunit,
-        Boolean followup, Integer statusEnrollment );
-
-    /**
-     * Get phone numbers of persons who meet the criteria for searching *
-     * 
-     * @param searchKeys The key for searching entityInstances by attribute
-     *        values and/or a program
-     * @param orgunit Organisation unit where entityInstances registered
-     * @param followup Only getting entityInstances with program risked if this
-     *        property is true. And getting entityInstances without program
-     *        risked if its value is false
-     * @param statusEnrollment The status of program of entityInstances. There
-     *        are three status, includes Active enrollments only, Completed
-     *        enrollments only and Active and completed enrollments
-     * @param min
-     * @param max
-     * 
-     * @return List of entityInstance
-     */
-    Collection<String> getTrackedEntityInstancePhoneNumbers( List<String> searchKeys,
-        Collection<OrganisationUnit> orgunit, Boolean followup, Integer statusEnrollment, Integer min, Integer max );
-
-    /**
      * Get events which meet the criteria for searching
      * 
      * @param searchKeys The key for searching entityInstances by attribute
@@ -374,25 +318,25 @@
     List<Integer> getProgramStageInstances( List<String> searchKeys, Collection<OrganisationUnit> orgunit,
         Boolean followup, Integer statusEnrollment, Integer min, Integer max );
 
-    /**
-     * Get visit schedule of person who meet the criteria for searching
-     * 
-     * @param searchKeys The key for searching entityInstances by attribute
-     *        values and/or a program
-     * @param orgunit Organisation unit where entityInstances registered
-     * @param followup Only getting entityInstances with program risked if this
-     *        property is true. And getting entityInstances without program
-     *        risked if its value is false
-     * @param statusEnrollment The status of program of entityInstances. There
-     *        are three status, includes Active enrollments only, Completed
-     *        enrollments only and Active and completed enrollments
-     * @parma min
-     * @param max
-     * 
-     * @return Grid
-     */
-    Grid getScheduledEventsReport( List<String> searchKeys, Collection<OrganisationUnit> orgunits, Boolean followup,
-        Integer statusEnrollment, Integer min, Integer max, I18n i18n );
+//    /**
+//     * Get visit schedule of person who meet the criteria for searching
+//     * 
+//     * @param searchKeys The key for searching entityInstances by attribute
+//     *        values and/or a program
+//     * @param orgunit Organisation unit where entityInstances registered
+//     * @param followup Only getting entityInstances with program risked if this
+//     *        property is true. And getting entityInstances without program
+//     *        risked if its value is false
+//     * @param statusEnrollment The status of program of entityInstances. There
+//     *        are three status, includes Active enrollments only, Completed
+//     *        enrollments only and Active and completed enrollments
+//     * @parma min
+//     * @param max
+//     * 
+//     * @return Grid
+//     */
+//    Grid getScheduledEventsReport( List<String> searchKeys, Collection<OrganisationUnit> orgunits, Boolean followup,
+//        Integer statusEnrollment, Integer min, Integer max, I18n i18n );
 
     /**
      * Search entityInstances by phone number (performs partial search)
@@ -405,27 +349,27 @@
      */
     Collection<TrackedEntityInstance> getTrackedEntityInstancesByPhone( String phoneNumber, Integer min, Integer max );
 
-    /**
-     * Get events of entityInstances who meet the criteria for searching
-     * 
-     * @param program Program. It's is used for getting attributes of this
-     *        program and put attribute values of entityInstances into the
-     *        result
-     * @param searchKeys The key for searching entityInstances by attribute
-     *        values and/or a program
-     * @param orgunit Organisation unit where entityInstances registered
-     * @param followup Only getting entityInstances with program risked if this
-     *        property is true. And getting entityInstances without program
-     *        risked if its value is false
-     * @param statusEnrollment The status of program of entityInstances. There
-     *        are three status, includes Active enrollments only, Completed
-     *        enrollments only and Active and completed enrollments
-     * @param i18n I18n
-     * 
-     * @return Grid
-     */
-    Grid getTrackingEventsReport( Program program, List<String> searchKeys, Collection<OrganisationUnit> orgunits,
-        Boolean followup, Integer statusEnrollment, I18n i18n );
+//    /**
+//     * Get events of entityInstances who meet the criteria for searching
+//     * 
+//     * @param program Program. It's is used for getting attributes of this
+//     *        program and put attribute values of entityInstances into the
+//     *        result
+//     * @param searchKeys The key for searching entityInstances by attribute
+//     *        values and/or a program
+//     * @param orgunit Organisation unit where entityInstances registered
+//     * @param followup Only getting entityInstances with program risked if this
+//     *        property is true. And getting entityInstances without program
+//     *        risked if its value is false
+//     * @param statusEnrollment The status of program of entityInstances. There
+//     *        are three status, includes Active enrollments only, Completed
+//     *        enrollments only and Active and completed enrollments
+//     * @param i18n I18n
+//     * 
+//     * @return Grid
+//     */
+//    Grid getTrackingEventsReport( Program program, List<String> searchKeys, Collection<OrganisationUnit> orgunits,
+//        Boolean followup, Integer statusEnrollment, I18n i18n );
 
     /**
      * Validate entityInstance attributes and validation criteria by program
@@ -436,9 +380,9 @@
      *        null, the system check unique attribute values of the
      *        entityInstance
      * @param format I18nFormat
-     * @return Error code 0 : Validation is OK 
-     *                    1_<duplicate-value> : The attribute value is duplicated 
-     *                    2_<validation-criteria-id> : Violate validation criteria of the program
+     * @return Error code 0 : Validation is OK 1_<duplicate-value> : The
+     *         attribute value is duplicated 2_<validation-criteria-id> :
+     *         Violate validation criteria of the program
      */
     String validateTrackedEntityInstance( TrackedEntityInstance entityInstance, Program program, I18nFormat format );
 

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceStore.java	2014-04-12 04:55:36 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceStore.java	2014-04-21 23:47:56 +0000
@@ -115,24 +115,24 @@
      * @return The number of entityInstances
      */
     int countGetTrackedEntityInstancesByOrgUnitProgram( OrganisationUnit organisationUnit, Program program );
-
-    /**
-     * Get number of entityInstances who meet the criteria for searching
-     * 
-     * @param searchKeys The key for searching entityInstances by attribute
-     *        values and/or a program
-     * @param orgunit Organisation unit where entityInstances registered
-     * @param followup Only getting entityInstances with program risked if this
-     *        property is true. And getting entityInstances without program
-     *        risked if its value is false
-     * @param statusEnrollment The status of program of entityInstances. There
-     *        are three status, includes Active enrollments only, Completed
-     *        enrollments only and Active and completed enrollments
-     * 
-     * @return The number of entityInstances
-     */
-    int countSearch( List<String> searchKeys, Collection<OrganisationUnit> orgunit, Boolean followup,
-        Integer statusEnrollment );
+//
+//    /**
+//     * Get number of entityInstances who meet the criteria for searching
+//     * 
+//     * @param searchKeys The key for searching entityInstances by attribute
+//     *        values and/or a program
+//     * @param orgunit Organisation unit where entityInstances registered
+//     * @param followup Only getting entityInstances with program risked if this
+//     *        property is true. And getting entityInstances without program
+//     *        risked if its value is false
+//     * @param statusEnrollment The status of program of entityInstances. There
+//     *        are three status, includes Active enrollments only, Completed
+//     *        enrollments only and Active and completed enrollments
+//     * 
+//     * @return The number of entityInstances
+//     */
+//    int countSearch( List<String> searchKeys, Collection<OrganisationUnit> orgunit, Boolean followup,
+//        Integer statusEnrollment );
 
     /**
      * Search entityInstances by phone number (performs partial search)
@@ -144,30 +144,7 @@
      * @return List of instances
      */
     Collection<TrackedEntityInstance> getByPhoneNumber( String phoneNumber, Integer min, Integer max );
-
-    /**
-     * Search events of entityInstances who meet the criteria for searching
-     * 
-     * @param searchKeys The key for searching entityInstances by attribute
-     *        values and/or a program
-     * @param orgunit Organisation unit where entityInstances registered
-     * @param followup Only getting entityInstances with program risked if this
-     *        property is true. And getting entityInstances without program
-     *        risked if its value is false
-     * @param attributes The attribute values of these attribute are displayed
-     *        into result
-     * @param statusEnrollment The status of program of entityInstances. There
-     *        are three status, includes Active enrollments only, Completed
-     *        enrollments only and Active and completed enrollments
-     * @param min
-     * @param max
-     * 
-     * @return List of entityInstances
-     */
-    Collection<TrackedEntityInstance> search( List<String> searchKeys, Collection<OrganisationUnit> orgunit,
-        Boolean followup, Collection<TrackedEntityAttribute> attributes, Integer statusEnrollment, Integer min,
-        Integer max );
-
+    
     /**
      * Search events which meet the criteria for searching
      * 
@@ -202,29 +179,29 @@
      */
     Collection<TrackedEntityInstance> getByProgram( Program program, Integer min, Integer max );
 
-    /**
-     * Search events of entityInstances who meet the criteria for searching
-     * 
-     * @param grid Grid with headers
-     * @param searchKeys The key for searching entityInstances by attribute
-     *        values and/or a program
-     * @param orgunit Organisation unit where entityInstances registered
-     * @param followup Only getting entityInstances with program risked if this
-     *        property is true. And getting entityInstances without program
-     *        risked if its value is false
-     * @param attributes The attribute values of these attribute are displayed
-     *        into result
-     * @param statusEnrollment The status of program of entityInstances. There
-     *        are three status, includes Active enrollments only, Completed
-     *        enrollments only and Active and completed enrollments
-     * @param min
-     * @param max
-     * 
-     * @return Grid
-     */
-    Grid getTrackedEntityInstanceEventReport( Grid grid, List<String> searchKeys, Collection<OrganisationUnit> orgunit,
-        Boolean followup, Collection<TrackedEntityAttribute> attributes, Integer statusEnrollment, Integer min,
-        Integer max );
+//    /**
+//     * Search events of entityInstances who meet the criteria for searching
+//     * 
+//     * @param grid Grid with headers
+//     * @param searchKeys The key for searching entityInstances by attribute
+//     *        values and/or a program
+//     * @param orgunit Organisation unit where entityInstances registered
+//     * @param followup Only getting entityInstances with program risked if this
+//     *        property is true. And getting entityInstances without program
+//     *        risked if its value is false
+//     * @param attributes The attribute values of these attribute are displayed
+//     *        into result
+//     * @param statusEnrollment The status of program of entityInstances. There
+//     *        are three status, includes Active enrollments only, Completed
+//     *        enrollments only and Active and completed enrollments
+//     * @param min
+//     * @param max
+//     * 
+//     * @return Grid
+//     */
+//    Grid getTrackedEntityInstanceEventReport( Grid grid, List<String> searchKeys, Collection<OrganisationUnit> orgunit,
+//        Boolean followup, Collection<TrackedEntityAttribute> attributes, Integer statusEnrollment, Integer min,
+//        Integer max );
 
     /**
      * Validate entity-instances attribute values and validation criteria by program

=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceService.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceService.java	2014-04-21 11:05:22 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceService.java	2014-04-21 23:47:56 +0000
@@ -737,47 +737,6 @@
     }
 
     @Override
-    public Collection<TrackedEntityInstance> searchTrackedEntityInstances( List<String> searchKeys,
-        Collection<OrganisationUnit> orgunits, Boolean followup, Collection<TrackedEntityAttribute> attributes,
-        Integer statusEnrollment, Integer min, Integer max )
-    {
-        return trackedEntityInstanceStore.search( searchKeys, orgunits, followup, attributes, statusEnrollment, min, max );
-    }
-
-    @Override
-    public int countSearchTrackedEntityInstances( List<String> searchKeys, Collection<OrganisationUnit> orgunits,
-        Boolean followup, Integer statusEnrollment )
-    {
-        return trackedEntityInstanceStore.countSearch( searchKeys, orgunits, followup, statusEnrollment );
-    }
-
-    @Override
-    public Collection<String> getTrackedEntityInstancePhoneNumbers( List<String> searchKeys,
-        Collection<OrganisationUnit> orgunits, Boolean followup, Integer statusEnrollment, Integer min, Integer max )
-    {
-        Collection<TrackedEntityInstance> entityInstances = trackedEntityInstanceStore.search( searchKeys, orgunits, followup,
-            null, statusEnrollment, min, max );
-        Set<String> phoneNumbers = new HashSet<String>();
-
-        for ( TrackedEntityInstance instance : entityInstances )
-        {
-            Collection<TrackedEntityAttributeValue> attributeValues = instance.getAttributeValues();
-            if ( attributeValues != null )
-            {
-                for ( TrackedEntityAttributeValue attributeValue : attributeValues )
-                {
-                    if ( attributeValue.getAttribute().getValueType().equals( TrackedEntityAttribute.TYPE_PHONE_NUMBER ) )
-                    {
-                        phoneNumbers.add( attributeValue.getValue() );
-                    }
-                }
-            }
-        }
-
-        return phoneNumbers;
-    }
-
-    @Override
     public List<Integer> getProgramStageInstances( List<String> searchKeys, Collection<OrganisationUnit> orgunits,
         Boolean followup, Integer statusEnrollment, Integer min, Integer max )
     {
@@ -792,96 +751,96 @@
         return trackedEntityInstanceStore.getByPhoneNumber( phoneNumber, min, max );
     }
 
-    @Override
-    public Grid getScheduledEventsReport( List<String> searchKeys, Collection<OrganisationUnit> orgunits,
-        Boolean followup, Integer statusEnrollment, Integer min, Integer max, I18n i18n )
-    {
-        String startDate = "";
-        String endDate = "";
-        for ( String searchKey : searchKeys )
-        {
-            String[] keys = searchKey.split( "_" );
-            if ( keys[0].equals( TrackedEntityInstance.PREFIX_PROGRAM_EVENT_BY_STATUS ) )
-            {
-                startDate = keys[2];
-                endDate = keys[3];
-            }
-        }
-
-        Grid grid = new ListGrid();
-        grid.setTitle( i18n.getString( "activity_plan" ) );
-        if ( !startDate.isEmpty() && !endDate.isEmpty() )
-        {
-            grid.setSubtitle( i18n.getString( "from" ) + " " + startDate + " " + i18n.getString( "to" ) + " " + endDate );
-        }
-
-        grid.addHeader( new GridHeader( "entityInstanceid", true, true ) );
-        grid.addHeader( new GridHeader( i18n.getString( "first_name" ), false, true ) );
-        grid.addHeader( new GridHeader( i18n.getString( "middle_name" ), false, true ) );
-        grid.addHeader( new GridHeader( i18n.getString( "last_name" ), false, true ) );
-        grid.addHeader( new GridHeader( i18n.getString( "gender" ), false, true ) );
-        grid.addHeader( new GridHeader( i18n.getString( "phone_number" ), false, true ) );
-
-        Collection<TrackedEntityAttribute> attributes = attributeService
-            .getTrackedEntityAttributesByDisplayOnVisitSchedule( true );
-        for ( TrackedEntityAttribute attribute : attributes )
-        {
-            grid.addHeader( new GridHeader( attribute.getDisplayName(), false, true ) );
-        }
-
-        grid.addHeader( new GridHeader( "programstageinstanceid", true, true ) );
-        grid.addHeader( new GridHeader( i18n.getString( "program_stage" ), false, true ) );
-        grid.addHeader( new GridHeader( i18n.getString( "due_date" ), false, true ) );
-
-        return trackedEntityInstanceStore.getTrackedEntityInstanceEventReport( grid, searchKeys, orgunits, followup,
-            attributes, statusEnrollment, min, max );
-    }
-
-    @Override
-    public Grid getTrackingEventsReport( Program program, List<String> searchKeys,
-        Collection<OrganisationUnit> orgunits, Boolean followup, Integer statusEnrollment, I18n i18n )
-    {
-        String startDate = "";
-        String endDate = "";
-        for ( String searchKey : searchKeys )
-        {
-            String[] keys = searchKey.split( "_" );
-            if ( keys[0].equals( TrackedEntityInstance.PREFIX_PROGRAM_EVENT_BY_STATUS ) )
-            {
-                startDate = keys[2];
-                endDate = keys[3];
-            }
-        }
-
-        Grid grid = new ListGrid();
-        grid.setTitle( i18n.getString( "program_tracking" ) );
-        if ( !startDate.isEmpty() && !endDate.isEmpty() )
-        {
-            grid.setSubtitle( i18n.getString( "from" ) + " " + startDate + " " + i18n.getString( "to" ) + " " + endDate );
-        }
-
-        grid.addHeader( new GridHeader( "entityInstanceid", true, true ) );
-        grid.addHeader( new GridHeader( i18n.getString( "first_name" ), true, true ) );
-        grid.addHeader( new GridHeader( i18n.getString( "middle_name" ), true, true ) );
-        grid.addHeader( new GridHeader( i18n.getString( "last_name" ), true, true ) );
-        grid.addHeader( new GridHeader( i18n.getString( "gender" ), true, true ) );
-        grid.addHeader( new GridHeader( i18n.getString( "phone_number" ), false, true ) );
-
-        Collection<TrackedEntityAttribute> attributes = program.getTrackedEntityAttributes();
-
-        for ( TrackedEntityAttribute attribute : attributes )
-        {
-            grid.addHeader( new GridHeader( attribute.getDisplayName(), false, true ) );
-        }
-
-        grid.addHeader( new GridHeader( "programstageinstanceid", true, true ) );
-        grid.addHeader( new GridHeader( i18n.getString( "program_stage" ), false, true ) );
-        grid.addHeader( new GridHeader( i18n.getString( "due_date" ), false, true ) );
-        grid.addHeader( new GridHeader( i18n.getString( "risk" ), false, true ) );
-
-        return trackedEntityInstanceStore.getTrackedEntityInstanceEventReport( grid, searchKeys, orgunits, followup,
-            attributes, statusEnrollment, null, null );
-    }
+//    @Override
+//    public Grid getScheduledEventsReport( List<String> searchKeys, Collection<OrganisationUnit> orgunits,
+//        Boolean followup, Integer statusEnrollment, Integer min, Integer max, I18n i18n )
+//    {
+//        String startDate = "";
+//        String endDate = "";
+//        for ( String searchKey : searchKeys )
+//        {
+//            String[] keys = searchKey.split( "_" );
+//            if ( keys[0].equals( TrackedEntityInstance.PREFIX_PROGRAM_EVENT_BY_STATUS ) )
+//            {
+//                startDate = keys[2];
+//                endDate = keys[3];
+//            }
+//        }
+//
+//        Grid grid = new ListGrid();
+//        grid.setTitle( i18n.getString( "activity_plan" ) );
+//        if ( !startDate.isEmpty() && !endDate.isEmpty() )
+//        {
+//            grid.setSubtitle( i18n.getString( "from" ) + " " + startDate + " " + i18n.getString( "to" ) + " " + endDate );
+//        }
+//
+//        grid.addHeader( new GridHeader( "entityInstanceid", true, true ) );
+//        grid.addHeader( new GridHeader( i18n.getString( "first_name" ), false, true ) );
+//        grid.addHeader( new GridHeader( i18n.getString( "middle_name" ), false, true ) );
+//        grid.addHeader( new GridHeader( i18n.getString( "last_name" ), false, true ) );
+//        grid.addHeader( new GridHeader( i18n.getString( "gender" ), false, true ) );
+//        grid.addHeader( new GridHeader( i18n.getString( "phone_number" ), false, true ) );
+//
+//        Collection<TrackedEntityAttribute> attributes = attributeService
+//            .getTrackedEntityAttributesByDisplayOnVisitSchedule( true );
+//        for ( TrackedEntityAttribute attribute : attributes )
+//        {
+//            grid.addHeader( new GridHeader( attribute.getDisplayName(), false, true ) );
+//        }
+//
+//        grid.addHeader( new GridHeader( "programstageinstanceid", true, true ) );
+//        grid.addHeader( new GridHeader( i18n.getString( "program_stage" ), false, true ) );
+//        grid.addHeader( new GridHeader( i18n.getString( "due_date" ), false, true ) );
+//
+//        return trackedEntityInstanceStore.getTrackedEntityInstanceEventReport( grid, searchKeys, orgunits, followup,
+//            attributes, statusEnrollment, min, max );
+//    }
+
+//    @Override
+//    public Grid getTrackingEventsReport( Program program, List<String> searchKeys,
+//        Collection<OrganisationUnit> orgunits, Boolean followup, Integer statusEnrollment, I18n i18n )
+//    {
+//        String startDate = "";
+//        String endDate = "";
+//        for ( String searchKey : searchKeys )
+//        {
+//            String[] keys = searchKey.split( "_" );
+//            if ( keys[0].equals( TrackedEntityInstance.PREFIX_PROGRAM_EVENT_BY_STATUS ) )
+//            {
+//                startDate = keys[2];
+//                endDate = keys[3];
+//            }
+//        }
+//
+//        Grid grid = new ListGrid();
+//        grid.setTitle( i18n.getString( "program_tracking" ) );
+//        if ( !startDate.isEmpty() && !endDate.isEmpty() )
+//        {
+//            grid.setSubtitle( i18n.getString( "from" ) + " " + startDate + " " + i18n.getString( "to" ) + " " + endDate );
+//        }
+//
+//        grid.addHeader( new GridHeader( "entityInstanceid", true, true ) );
+//        grid.addHeader( new GridHeader( i18n.getString( "first_name" ), true, true ) );
+//        grid.addHeader( new GridHeader( i18n.getString( "middle_name" ), true, true ) );
+//        grid.addHeader( new GridHeader( i18n.getString( "last_name" ), true, true ) );
+//        grid.addHeader( new GridHeader( i18n.getString( "gender" ), true, true ) );
+//        grid.addHeader( new GridHeader( i18n.getString( "phone_number" ), false, true ) );
+//
+//        Collection<TrackedEntityAttribute> attributes = program.getTrackedEntityAttributes();
+//
+//        for ( TrackedEntityAttribute attribute : attributes )
+//        {
+//            grid.addHeader( new GridHeader( attribute.getDisplayName(), false, true ) );
+//        }
+//
+//        grid.addHeader( new GridHeader( "programstageinstanceid", true, true ) );
+//        grid.addHeader( new GridHeader( i18n.getString( "program_stage" ), false, true ) );
+//        grid.addHeader( new GridHeader( i18n.getString( "due_date" ), false, true ) );
+//        grid.addHeader( new GridHeader( i18n.getString( "risk" ), false, true ) );
+//
+//        return trackedEntityInstanceStore.getTrackedEntityInstanceEventReport( grid, searchKeys, orgunits, followup,
+//            attributes, statusEnrollment, null, null );
+//    }
 
     @Override
     public String validateTrackedEntityInstance( TrackedEntityInstance instance, Program program, I18nFormat format )
@@ -926,4 +885,5 @@
     {
         return trackedEntityInstanceStore.getByAttributeValue( searchText, attributeId, min, max );
     }
+
 }

=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityInstanceStore.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityInstanceStore.java	2014-04-21 11:05:22 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityInstanceStore.java	2014-04-21 23:47:56 +0000
@@ -29,6 +29,7 @@
  */
 
 import static org.hisp.dhis.common.IdentifiableObjectUtils.getIdentifiers;
+import static org.hisp.dhis.program.ProgramStageInstance.SKIPPED_STATUS;
 import static org.hisp.dhis.system.util.DateUtils.getMediumDateString;
 import static org.hisp.dhis.system.util.TextUtils.getCommaDelimitedString;
 import static org.hisp.dhis.system.util.TextUtils.getTokens;
@@ -45,7 +46,6 @@
 import static org.hisp.dhis.trackedentity.TrackedEntityInstanceQueryParams.ORG_UNIT_ID;
 import static org.hisp.dhis.trackedentity.TrackedEntityInstanceQueryParams.TRACKED_ENTITY_ID;
 import static org.hisp.dhis.trackedentity.TrackedEntityInstanceQueryParams.TRACKED_ENTITY_INSTANCE_ID;
-import static org.hisp.dhis.program.ProgramStageInstance.SKIPPED_STATUS;
 
 import java.sql.ResultSet;
 import java.sql.SQLException;
@@ -633,38 +633,7 @@
             throw new RuntimeException( ex );
         }
     }
-
-    // -------------------------------------------------------------------------
-    // TODO Everything from here downwards must be replaced or removed!
-    // -------------------------------------------------------------------------
-
-    @Override
-    // TODO this method must be changed - cannot retrieve one by one
-    public Collection<TrackedEntityInstance> search( List<String> searchKeys, Collection<OrganisationUnit> orgunits,
-        Boolean followup, Collection<TrackedEntityAttribute> attributes, Integer statusEnrollment, Integer min,
-        Integer max )
-    {
-        String sql = searchTrackedEntityInstanceSql( false, searchKeys, orgunits, followup, attributes,
-            statusEnrollment, min, max );
-        Collection<TrackedEntityInstance> instances = new HashSet<TrackedEntityInstance>();
-        try
-        {
-            instances = jdbcTemplate.query( sql, new RowMapper<TrackedEntityInstance>()
-            {
-                public TrackedEntityInstance mapRow( ResultSet rs, int rowNum )
-                    throws SQLException
-                {
-                    return get( rs.getInt( 1 ) );
-                }
-            } );
-        }
-        catch ( Exception ex )
-        {
-            ex.printStackTrace();
-        }
-        return instances;
-    }
-
+    
     @Override
     public List<Integer> getProgramStageInstances( List<String> searchKeys, Collection<OrganisationUnit> orgunits,
         Boolean followup, Collection<TrackedEntityAttribute> attributes, Integer statusEnrollment, Integer min,
@@ -693,28 +662,28 @@
         return programStageInstanceIds;
     }
 
-    public int countSearch( List<String> searchKeys, Collection<OrganisationUnit> orgunits, Boolean followup,
-        Integer statusEnrollment )
-    {
-        String sql = searchTrackedEntityInstanceSql( true, searchKeys, orgunits, followup, null, statusEnrollment,
-            null, null );
-        return jdbcTemplate.queryForObject( sql, Integer.class );
-    }
-
-    @Override
-    public Grid getTrackedEntityInstanceEventReport( Grid grid, List<String> searchKeys,
-        Collection<OrganisationUnit> orgunits, Boolean followup, Collection<TrackedEntityAttribute> attributes,
-        Integer statusEnrollment, Integer min, Integer max )
-    {
-        String sql = searchTrackedEntityInstanceSql( false, searchKeys, orgunits, followup, attributes,
-            statusEnrollment, min, max );
-
-        SqlRowSet rowSet = jdbcTemplate.queryForRowSet( sql );
-
-        GridUtils.addRows( grid, rowSet );
-
-        return grid;
-    }
+//    public int countSearch( List<String> searchKeys, Collection<OrganisationUnit> orgunits, Boolean followup,
+//        Integer statusEnrollment )
+//    {
+//        String sql = searchTrackedEntityInstanceSql( true, searchKeys, orgunits, followup, null, statusEnrollment,
+//            null, null );
+//        return jdbcTemplate.queryForObject( sql, Integer.class );
+//    }
+//
+//    @Override
+//    public Grid getTrackedEntityInstanceEventReport( Grid grid, List<String> searchKeys,
+//        Collection<OrganisationUnit> orgunits, Boolean followup, Collection<TrackedEntityAttribute> attributes,
+//        Integer statusEnrollment, Integer min, Integer max )
+//    {
+//        String sql = searchTrackedEntityInstanceSql( false, searchKeys, orgunits, followup, attributes,
+//            statusEnrollment, min, max );
+//
+//        SqlRowSet rowSet = jdbcTemplate.queryForRowSet( sql );
+//
+//        GridUtils.addRows( grid, rowSet );
+//
+//        return grid;
+//    }
 
     private String searchTrackedEntityInstanceSql( boolean count, List<String> searchKeys,
         Collection<OrganisationUnit> orgunits, Boolean followup, Collection<TrackedEntityAttribute> attributes,

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/activityPlanSelect.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/activityPlanSelect.vm	2014-04-17 16:00:32 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/activityPlanSelect.vm	2014-04-21 23:47:56 +0000
@@ -2,7 +2,7 @@
 	jQuery(document).ready(	function(){
 		validation( 'activityPlanForm', function(form){
 			if(getFieldValue('export')=='false'){
-				showActitityList();
+				showActitityList(1);
 			}
 			else{
 				exportActitityList('xls');
@@ -22,7 +22,7 @@
 	<input type='hidden' id='programStageName' name='programStageName'>
 	<input type='hidden' id='programStageInstanceId' name='programStageInstanceId'>
 	<input type='hidden' id='searchByProgramStage' name='searchByProgramStage' value="false">
-	<input type='hidden' id='orgunitId' name='orgunitId' value='$organisationUnit.id' >
+	<input type='hidden' id='orgunitId' name='orgunitId' value='$organisationUnit.uid' >
 	<input type="hidden" id='hideLink' name='hideLink' value='false'>
 	<input type='hidden' id='isSearchByProgram' name='isSearchByProgram' value='false' >
 	<input type='hidden' id='export' name= 'export'>
@@ -54,7 +54,7 @@
 						#end
 						#foreach($program in $programs)
 							#if($program.type=='1') 
-								<option value="$program.id" type='$program.type'>$program.displayName</option>
+								<option value="$program.uid" type='$program.type'>$program.displayName</option>
 							#end
 						#end
 					</select>
@@ -63,14 +63,13 @@
 			<tr>
 				<td>$i18n.getString('status')</td>
 				<td>
-					<select id="statusEvent" name="statusEvent" onchange="statusEventOnChange()">
-						<option value='3_4' selected>$i18n.getString("overdue_scheduled")</option>
-						<option value='3'>$i18n.getString("scheduled_in_future")</option> 
-						<option value='4'>$i18n.getString("overdue")</option>
-						<option value='2'>$i18n.getString("incomplete")</option>
-						<option value='2_3_4'>$i18n.getString("scheduled_overdue_incomplete")</option>
-						<option value='1'>$i18n.getString("completed")</option>
-						<option value='1_2_3_4'>$i18n.getString("all")</option>
+					<select id="status" name="status" onchange="statusEventOnChange()">
+						<option value=''>$i18n.getString("all")</option> 
+						<option value='FUTURE_VISIT' selected>$i18n.getString("scheduled_in_future")</option> 
+						<option value='LATE_VISIT'>$i18n.getString("overdue")</option>
+						<option value='VISITED'>$i18n.getString("incomplete")</option>
+						<option value='COMPLETED'>$i18n.getString("completed")</option>
+						<option value='SKIPPED'>$i18n.getString("skipped")</option> 
 					</select>
 				</td>
 			</tr>
@@ -105,9 +104,9 @@
 			<tr>
 				<td>$i18n.getString('use_data_from_level')</td>
 				<td>
-					<input type="radio" id='facilityLB1' name="facilityLB" value="selected" checked> $i18n.getString('selected')
-					<input type="radio" id='facilityLB2' name="facilityLB" value="childrenOnly"> $i18n.getString('children_only')
-					<input type="radio" id='facilityLB3' name="facilityLB" value="all"> $i18n.getString('all')
+					<input type="radio" id='ouMode1' name="ouMode" value="SELECTED" checked> $i18n.getString('selected')
+					<input type="radio" id='ouMode2' name="ouMode" value="CHILDREN"> $i18n.getString('children_only')
+					<input type="radio" id='ouMode3' name="ouMode" value="CHILDREN"> $i18n.getString('all')
 				</td>
 			</tr>
 			<tr>
@@ -132,6 +131,7 @@
 <div id='migrationEntityInstanceDiv'></div> <!-- Migration EntityInstance -->
 
 <div id='contentDataRecord'></div>
+<div id='eventList'></div>
 
 #parse( "dhis-web-commons/loader/loader.vm" )
 	
@@ -206,5 +206,26 @@
 	var i18n_comment = '$encoder.jsEscape( $i18n.getString( "comment" ) , "'")';
 	var i18n_message = '$encoder.jsEscape( $i18n.getString( "message" ) , "'")';
 	
+	var i18n_total_result = '$encoder.jsEscape( $i18n.getString( "total_result" ) , "'")';
+	var i18n_no_result_found = '$encoder.jsEscape( $i18n.getString( "no_result_found" ) , "'")';
+	var i18n_operations = '$encoder.jsEscape( $i18n.getString( "operations" ) , "'")';
+	var i18n_dashboard = '$encoder.jsEscape( $i18n.getString( "dashboard" ) , "'")';
+	var i18n_edit_profile = '$encoder.jsEscape( $i18n.getString( "edit_profile" ) , "'")';
+	var i18n_manage_relationship = '$encoder.jsEscape( $i18n.getString( "manage_relationship" ) , "'")';
+	var i18n_change_location = '$encoder.jsEscape( $i18n.getString( "change_location" ) , "'")';
+	var i18n_confirm_delete_tracked_entity_instance = '$encoder.jsEscape( $i18n.getString( "confirm_delete_tracked_entity_instance" ) , "'")';
+	var i18n_remove = '$encoder.jsEscape( $i18n.getString( "remove" ) , "'")';
+	var i18n_tracked_entity_instance_details_and_history = '$encoder.jsEscape( $i18n.getString( "tracked_entity_instance_details_and_history" ) , "'")';
+	var i18n_first = '$encoder.jsEscape( $i18n.getString( "first" ) , "'")';
+	var i18n_prev = '$encoder.jsEscape( $i18n.getString( "prev" ) , "'")';
+	var i18n_page = '$encoder.jsEscape( $i18n.getString( "page" ) , "'")';
+	var i18n_next = '$encoder.jsEscape( $i18n.getString( "next" ) , "'")';
+	var i18n_last = '$encoder.jsEscape( $i18n.getString( "last" ) , "'")';
+	var i18n_complete_program_confirm_message = '$encoder.jsEscape( $i18n.getString( "complete_program_confirm_message" ) , "'")';
+	var i18n_for = '$encoder.jsEscape( $i18n.getString( "for" ) , "'")';
+	var i18n_data_entry = '$encoder.jsEscape( $i18n.getString( "data_entry" ) , "'")';
+	var i18n_events = '$encoder.jsEscape( $i18n.getString( "events" ) , "'")';
+
+	var registrationProgress = false;
 	setDateRange();
 </script>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/addSingleEventRegistration.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/addSingleEventRegistration.vm	2014-04-21 16:30:29 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/addSingleEventRegistration.vm	2014-04-21 23:47:56 +0000
@@ -1,7 +1,6 @@
 <script>
 	jQuery("#singleEventForm").ready(	function(){
 		currentDiv = 'entityInstanceForm';
-		checkedDuplicate = false;
 		
 		jQuery("#singleEventForm").validate({
 			 meta:"validate"

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/activityPlan.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/activityPlan.js	2014-04-06 15:48:31 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/activityPlan.js	2014-04-21 23:47:56 +0000
@@ -32,41 +32,240 @@
 	}
 }
 
-function showActitityList()
+function showActitityList(page)
 {
 	setFieldValue('listAll', "true");
 	hideById('listEntityInstanceDiv');
 	$('#contentDataRecord').html('');
-	var facilityLB = $('input[name=facilityLB]:checked').val();
-	var programId = getFieldValue('program');
-    var searchTexts = "stat_" + programId
-        + "_" + getFieldValue('startDueDate')
-        + "_" + getFieldValue('endDueDate');
-
-    if( facilityLB == 'selected' ) {
-        searchTexts += "_" + getFieldValue('orgunitId');
-    }
-    else if( facilityLB == 'all' ) {
-        searchTexts += "_0";
-    }
-    else if( facilityLB == 'childrenOnly' ) {
-        searchTexts += "_-1";
-    }
-
-    searchTexts += "_false_" + getFieldValue('statusEvent');
-
+  
 	showLoader();
-
-    jQuery('#listEntityInstanceDiv').load('getActivityPlanRecords.action', {
-        programId: programId,
-        listAll: false,
-        searchTexts: searchTexts
-    }, function() {
-        showById('colorHelpLink');
-        showById('listEntityInstanceDiv');
-        setTableStyles();
-        hideLoader();
-    });
+	
+	var params = "ou=" + getFieldValue("orgunitId");
+	params += "&program=" + getFieldValue('program');
+	params += "&ouMode=" + $('input[name=ouMode]:checked').val();
+	params += "&programStatus=ACTIVE";
+	params += "&page=" + page;
+	params += "&eventStartDate=" + getFieldValue('startDueDate');
+	params += "&eventEndDate=" + getFieldValue('endDueDate');
+	
+	if(getFieldValue('status')!=''){
+		params += '&eventStatus=' + getFieldValue('status');
+	}
+	
+	$('#attributeIds option').each(function(i, item){
+		params += "&attribute=" + item.value;
+	});
+	
+	$.ajax({
+		type : "GET",
+		url : "../api/trackedEntityInstances.json",
+		data : params,
+		dataType : "json",
+		success : function(json) {
+			setInnerHTML('listEntityInstanceDiv', displayevents(json, page));
+			showById('listEntityInstanceDiv');
+			jQuery('#loaderDiv').hide();
+			hideLoader();
+		}
+	});
+}
+
+function displayevents(json, page) {
+	var table = "";
+	
+	// Header
+	if (json.metaData.pager.total > 0) {
+		table += "<p>" + i18n_total_result + " : " + json.metaData.pager.total
+				+ "</p>";
+	} else {
+		table += "<p>" + i18n_no_result_found + "</p>";
+	}
+	
+	// TEI list
+	table += "<table class='listTable' width='100%'>";
+	
+	var idx = 4;
+	table += "<col width='30' />";
+	for (var i = idx; i < json.width; i++) {
+		table += "<col />";
+	}
+	table += "<col width='200' />";
+	table += "<thead><tr><th>#</th>";
+	for (var i = idx; i < json.width; i++) {
+		table += "<th>" + json.headers[i].column + "</th>";
+	}
+	table += "<th>" + i18n_operations + "</th>";
+	table += "</tr></thead>";
+	
+	table += "<tbody id='list'>";
+	for ( var i in json.rows) {
+		var cols = json.rows[i];
+		var uid = cols[0];
+		var no = eval(json.metaData.pager.page);
+		no = (no - 1) * 50 + eval(i) + 1;
+		table += "<tr id='tr" + uid + "'>";
+		table += "<td>" + no + "</td>";
+		for (var j = idx; j < json.width; j++) {
+			var colVal = cols[j];
+			if (j == 4) {
+				colVal = json.metaData.names[colVal];
+			}
+			table += "<td onclick=\"javascript:isDashboard=true;showTrackedEntityInstanceDashboardForm( '"
+				+ uid
+				+ "' )\" title='"
+				+ i18n_dashboard
+				+ "'>" + colVal + "</td>";
+		}
+		
+		// Operations column
+		table += "<td>";
+		table += "<a href=\"javascript:isDashboard=false;showEvents('"
+				+ uid
+				+ "' )\" title='"
+				+ i18n_events
+				+ "'><img src='../images/edit_sections.png' alt='"
+				+ i18n_events
+				+ "'></a>";
+		table += "<a href=\"javascript:isDashboard=false;showTrackedEntityInstanceDashboardForm( '"
+				+ uid
+				+ "' )\" title='"
+				+ i18n_dashboard
+				+ "'><img src='../images/enroll.png' alt='"
+				+ i18n_dashboard
+				+ "'></a>";
+		table += "<a href=\"javascript:loadDataEntryDialog( '" + uid + "' ) \" "
+				+ " title='"
+				+ i18n_edit
+				+ "'><img src= '../images/edit.png' alt='"
+				+ i18n_edit
+				+ "'></a>";
+		table += "<a href=\"javascript:showTrackedEntityInstanceHistory( '" + uid + "' ) \" "
+				+ " title='"
+				+ i18n_edit
+				+ "'><img src= '../images/edit.png' alt='"
+				+ i18n_edit
+				+ "'></a>";
+		table += "</td>";
+		table += "</tr>";
+	}
+	table += "</tbody>";
+	table += "</table>";
+	
+	return table + paging(json, page);
+	
+	if( json.metaData.pager.total > 0 ){
+		// Event list
+		table += "<table class='listTable' width='100%'>";
+		
+		table += "<col width='30' />";// Ordered no.
+		table += "<col />"; // Event-date
+		table += "<col />"; // Data values
+		table += "<col width='200' />"; // Operations
+		
+		table += "<thead><tr><th>#</th>";
+		table += "<th>" + i18n_event_date + "</th>";
+		table += "<th>" + i18n_data_values + "</th>";
+		table += "<th>" + i18n_operations + "</th>";
+		table += "</tr></thead>";
+		
+		table += "<tbody id='list'>";
+		for ( var i in json.events) {
+			var row = json.events[i];
+			var uid = row.event;
+			var teiUid = row.trackedEntityInstance;
+			var no = eval(json.metaData.pager.page);
+			no = (no - 1) * json.metaData.pager.pageSize + eval(i) + 1;
+			table += "<tr id='tr" + uid + "'>";
+			table += "<td>" + no + "</td>";// No.
+			table += "<td>" + row.eventDate + "</td>";// Event-date
+			
+			// Data values
+			table += "<td>";
+			if( row.dataValues!=undefined ){
+				table += "<table>";
+				for (var j in row.dataValues) {
+					var colVal = row.dataValues[j].dataElement;
+					table += "<tr><td>" +  json.metaData.de[colVal] + ": </td>";
+					table += "<td>" +  row.dataValues[j].value + "</td></tr>";
+				}
+				table += "</table>";
+			}
+			else{
+				table += "</td>";
+			}
+			
+			
+		}
+		table += "</tbody>";
+		table += "</table>";
+	
+		table += paging(json, page);
+	}
+	return table;
+}
+
+// Paging
+
+function paging(json, page) {
+	var table = "<table width='100%' style='background-color: #ebf0f6;'><tr><td colspan='"
+			+ json.width + "'>";
+	table += "<div class='paging'>";
+	table += "<span class='first' title='" + i18n_first + "'>««</span>";
+	table += "<span class='prev' title='" + i18n_prev + "'>«</span>";
+	for (var i = 1; i <= json.metaData.pager.pageCount; i++) {
+		if (i == page) {
+			table += "<span class='page' title='" + i18n_page + " " + i + "'>"
+				+ i + "</span>";
+		} else {
+			table += "<a class='page' title='" + i18n_page + " " + i
+				+ "' href='javascript:showActitityList( " + i
+				+ ");'>" + i + "</a>";
+		}
+		table += "<span class='seperator'>|</span>";
+	}
+	table += "<span class='next' title='" + i18n_next + "'>» </span>";
+	table += "<span class='last' title='" + i18n_last + "'>»»</span>";
+	table += "</div>";
+	table += "</tr></table>";
+	return table;
+}
+
+function showEvents( teiUid){
+	var params = "orgUnit=" + getFieldValue("orgunitId");
+	params += "&program=" + getFieldValue('program');
+	params += "&programStatus=ACTIVE";
+	params += "&trackedEntityInstance=" + teiUid;
+	if(getFieldValue('status')!=''){
+		params += '&eventStatus=' + getFieldValue('status');
+	}
+	params += "&eventStartDate=" + getFieldValue('startDueDate');
+	params += "&eventEndDate=" + getFieldValue('endDueDate');
+	
+	$.ajax({
+		type : "GET",
+		url : "../api/events.json",
+		data : params,
+		dataType : "json",
+		success : function(json) {
+			var table = "<table>"
+			for ( var i in json.events) {
+				var row = json.events[i];
+				var uid = row.event;
+				var eventDate = row.eventDate;
+				table += "<tr><td><a href='javascript:programTrackingList( \"" + uid + "\") ' >" + eventDate + "</a></td></tr>";
+			}
+			table += "</table>";
+			$('#eventList').html(table);
+			$('#eventList').dialog({
+				title : i18n_events,
+				maximize : true,
+				closable : true,
+				modal : false,
+				width : 380,
+				height : 290
+			}).show('fast');
+		}
+	});
 }
 
 function exportActitityList( type )
@@ -89,7 +288,7 @@
         params += "_-1";
     }
 
-    params += "_false_" + getFieldValue('statusEvent');
+    params += "_false_" + getFieldValue('status');
     window.location.href = "getActivityPlanRecords.action?" + params;
 }
 
@@ -126,16 +325,16 @@
 {
 	if( !byId('useCalendar').checked )
 	{
-		var statusEvent = getFieldValue("statusEvent");
+		var status = getFieldValue("status");
 
-		if( statusEvent == '1_2_3_4'
-			|| statusEvent == '3_4'
-			|| statusEvent == '2_3_4' ){
+		if( status == '1_2_3_4'
+			|| status == '3_4'
+			|| status == '2_3_4' ){
 			enable('showEventSince');
 			enable('showEventUpTo');
 			setDateRange();
 		}
-		else if( statusEvent == '3' ){
+		else if( status == '3' ){
 			disable('showEventSince');
 			enable('showEventUpTo');
 			setDateRange();
@@ -150,7 +349,7 @@
 
 function setDateRange()
 {
-	var statusEvent = getFieldValue("statusEvent");
+	var status = getFieldValue("status");
 	var date = new Date();
 	var d = date.getDate();
 	var m = date.getMonth();
@@ -187,13 +386,13 @@
 	}
 
 	// check status to get date-range
-    if( statusEvent == '1_2_3_4'
-        || statusEvent == '3_4'
-        || statusEvent == '2_3_4' ) {
+    if( status == '1_2_3_4'
+        || status == '3_4'
+        || status == '2_3_4' ) {
         startDate = startDateSince;
         endDate = endDateUpTo;
 
-    } else if( statusEvent == '3' ) {
+    } else if( status == '3' ) {
         startDate = startDateUpTo;
         endDate = endDateUpTo;
     }

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/smsReminder.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/smsReminder.js	2014-04-18 18:17:51 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/smsReminder.js	2014-04-21 23:47:56 +0000
@@ -95,7 +95,6 @@
 			setTableStyles();
 		}
 	});
-	
 }
 
 function displayevents(json, page) {

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programTrackingSelect.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programTrackingSelect.vm	2014-04-18 18:17:51 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programTrackingSelect.vm	2014-04-21 23:47:56 +0000
@@ -180,7 +180,6 @@
 	var i18n_complete_program_confirm_message = '$encoder.jsEscape( $i18n.getString( "complete_program_confirm_message" ) , "'")';
 	var i18n_events = '$encoder.jsEscape( $i18n.getString( "events" ) , "'")';
 	
-	var checkedDuplicate = false;
 	var registration = false;
 	
 	// eventList - 0 : Not events

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/selectTrackedEntityInstance.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/selectTrackedEntityInstance.vm	2014-04-21 16:30:29 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/selectTrackedEntityInstance.vm	2014-04-21 23:47:56 +0000
@@ -134,7 +134,6 @@
 	
 	var canChangeLocation = $auth.hasAccess( "dhis-web-caseentry", "getTrackedEntityInstanceLocation" );
 	
-	var checkedDuplicate = false;
 	// -1: no search anything
 	//  0: show list all tracked_entity_instance
 	//  1: advanced-search