← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9976: Add facility-by-level option for activity plan; Improve Program Tracking UI.

 

------------------------------------------------------------
revno: 9976
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-03-05 14:29:03 +0700
message:
  Add facility-by-level option for activity plan; Improve Program Tracking UI.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientStore.java
  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/patient/DefaultPatientService.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.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
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetActivityPlansAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetDataRecordsAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties
  dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/activityPlanRecords.vm
  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/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/programTrackingRecords.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchPatientCriteria.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/patient/PatientService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientService.java	2013-01-21 08:13:02 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientService.java	2013-03-05 07:29:03 +0000
@@ -211,7 +211,7 @@
     
     Collection<String> getPatientPhoneNumbers( List<String> searchKeys, OrganisationUnit orgunit, Integer min, Integer max );
 
-    Collection<Integer> getProgramStageInstances( List<String> searchKeys, OrganisationUnit orgunit, Integer min, Integer max );
+    List<Integer> getProgramStageInstances( List<String> searchKeys, OrganisationUnit orgunit, Integer min, Integer max );
     
     Grid getScheduledEventsReport( List<String> searchKeys, OrganisationUnit orgunit, I18n i18n );
 

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientStore.java	2013-01-21 08:13:02 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientStore.java	2013-03-05 07:29:03 +0000
@@ -75,7 +75,7 @@
     Collection<String> getPatientPhoneNumbers( List<String> searchKeys, OrganisationUnit orgunit, Integer min,
         Integer max );
 
-    Collection<Integer> getProgramStageInstances( List<String> searchKeys, OrganisationUnit orgunit, Integer min,
+    List<Integer> getProgramStageInstances( List<String> searchKeys, OrganisationUnit orgunit, Integer min,
         Integer max );
 
     Grid getPatientEventReport( Grid grid, List<String> searchKeys, OrganisationUnit orgunit );

=== 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-03-04 09:38:55 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java	2013-03-05 07:29:03 +0000
@@ -127,5 +127,5 @@
 
     int getActiveInstanceCount( Program program, Collection<Integer> orgunitIds, Date startDate, Date endDate,
         Collection<Integer> statusList );
-
+    
 }

=== 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-03-04 09:38:55 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java	2013-03-05 07:29:03 +0000
@@ -114,5 +114,5 @@
     
    int getActiveInstanceCount( Program program, Collection<Integer> orgunitIds, Date startDate,
         Date endDate, Collection<Integer> statusList );
-
+   
 }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java	2013-02-18 08:23:36 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientService.java	2013-03-05 07:29:03 +0000
@@ -540,7 +540,7 @@
         return patientStore.getPatientPhoneNumbers( searchKeys, orgunit, min, max );
     }
 
-    public Collection<Integer> getProgramStageInstances( List<String> searchKeys, OrganisationUnit orgunit,
+    public List<Integer> getProgramStageInstances( List<String> searchKeys, OrganisationUnit orgunit,
         Integer min, Integer max )
     {
         return patientStore.getProgramStageInstances( searchKeys, orgunit, min, max );

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java	2013-02-18 08:42:43 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/hibernate/HibernatePatientStore.java	2013-03-05 07:29:03 +0000
@@ -256,7 +256,7 @@
                 {
                     return get( rs.getInt( 1 ) );
                 }
-            });
+            } );
         }
         catch ( Exception ex )
         {
@@ -281,7 +281,7 @@
                     String phoneNumber = rs.getString( "phonenumber" );
                     return (phoneNumber == null || phoneNumber.isEmpty()) ? "0" : phoneNumber;
                 }
-            });
+            } );
         }
         catch ( Exception ex )
         {
@@ -291,11 +291,11 @@
     }
 
     @Override
-    public Collection<Integer> getProgramStageInstances( List<String> searchKeys, OrganisationUnit orgunit,
-        Integer min, Integer max )
+    public List<Integer> getProgramStageInstances( List<String> searchKeys, OrganisationUnit orgunit, Integer min,
+        Integer max )
     {
         String sql = searchPatientSql( false, searchKeys, orgunit, min, max );
-        Collection<Integer> programStageInstanceIds = new HashSet<Integer>();
+        List<Integer> programStageInstanceIds = new ArrayList<Integer>();
         try
         {
             programStageInstanceIds = jdbcTemplate.query( sql, new RowMapper<Integer>()
@@ -305,7 +305,7 @@
                 {
                     return rs.getInt( "programstageinstanceid" );
                 }
-            });
+            } );
         }
         catch ( Exception ex )
         {
@@ -336,7 +336,7 @@
 
         return grid;
     }
-    
+
     // -------------------------------------------------------------------------
     // Supportive methods
     // -------------------------------------------------------------------------
@@ -421,7 +421,6 @@
                 isPriorityEvent = Boolean.parseBoolean( keys[5] );
                 patientWhere += patientOperator + "pgi.patientid=p.patientid and ";
                 patientWhere += "pgi.programid=" + id + " and ";
-                patientWhere += "psi.duedate>='" + keys[2] + "' and psi.duedate<='" + keys[3] + "' and ";
                 patientWhere += "pgi.completed = false ";
 
                 String operatorStatus = "";
@@ -433,23 +432,29 @@
                     switch ( statusEvent )
                     {
                     case ProgramStageInstance.COMPLETED_STATUS:
-                        patientWhere += condition + operatorStatus + "("
-                            + " psi.completed=true and psi.organisationunitid=" + keys[4] + ")";
+                        patientWhere += condition + operatorStatus
+                            + "( psi.executiondate is not null and  psi.executiondate>='" + keys[2]
+                            + "' and psi.executiondate<='" + keys[3]
+                            + "' and psi.completed=true and psi.organisationunitid=" + keys[4] + ")";
+                        operatorStatus = " OR ";
                         condition = "";
-                        operatorStatus = " OR ";
                         continue;
                     case ProgramStageInstance.VISITED_STATUS:
-                        patientWhere += condition + operatorStatus + "("
-                            + " psi.executiondate is not null and psi.completed=false and psi.organisationunitid="
-                            + keys[4] + ")";
+                        patientWhere += condition + operatorStatus
+                            + "( psi.executiondate is not null and psi.executiondate>='" + keys[2]
+                            + "' and psi.executiondate<='" + keys[3]
+                            + "' and psi.completed=false and psi.organisationunitid=" + keys[4] + ")";
                         operatorStatus = " OR ";
                         condition = "";
                         continue;
                     case ProgramStageInstance.FUTURE_VISIT_STATUS:
                         patientWhere += condition
                             + operatorStatus
-                            + "("
-                            + " psi.status is null and psi.executiondate is null and (DATE(now()) - DATE(psi.duedate) <= 0) and p.organisationunitid="
+                            + "( psi.executiondate is null and psi.duedate>='"
+                            + keys[2]
+                            + "' and psi.duedate<='"
+                            + keys[3]
+                            + "' and psi.status is null and (DATE(now()) - DATE(psi.duedate) <= 0) and p.organisationunitid="
                             + keys[4] + ")";
                         operatorStatus = " OR ";
                         condition = "";
@@ -457,12 +462,21 @@
                     case ProgramStageInstance.LATE_VISIT_STATUS:
                         patientWhere += condition
                             + operatorStatus
-                            + "("
-                            + " psi.status is null and psi.executiondate is null and (DATE(now()) - DATE(psi.duedate) > 0) and p.organisationunitid="
+                            + "( psi.executiondate is null and  psi.duedate>='"
+                            + keys[2]
+                            + "' and psi.duedate<='"
+                            + keys[3]
+                            + "' and psi.status is null  and (DATE(now()) - DATE(psi.duedate) > 0) and p.organisationunitid="
                             + keys[4] + ")";
                         operatorStatus = " OR ";
                         condition = "";
                         continue;
+                    case ProgramStageInstance.SKIPPED_STATUS:
+                        patientWhere += condition + operatorStatus + "( psi.status=5 and  psi.duedate>='" + keys[2]
+                            + "' and psi.duedate<='" + keys[3] + "' and p.organisationunitid=" + keys[4] + ")";
+                        operatorStatus = " OR ";
+                        condition = "";
+                        continue;
                     default:
                         continue;
                     }
@@ -559,7 +573,7 @@
     {
         String hql = "select p from Patient p where p.phoneNumber like '%" + phoneNumber + "%'";
         Query query = getQuery( hql );
-        
+
         if ( min != null && max != null )
         {
             query.setFirstResult( min ).setMaxResults( max );
@@ -595,5 +609,5 @@
 
         return patients;
     }
-    
+
 }

=== 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-03-05 03:28:49 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java	2013-03-05 07:29:03 +0000
@@ -381,6 +381,7 @@
 
         // Header
         grid.addHeader( new GridHeader( i18n.getString( "date_scheduled" ), false, false ) );
+        grid.addHeader( new GridHeader( i18n.getString( "orgunit" ), false, false ) );
         grid.addHeader( new GridHeader( i18n.getString( "full_name" ), false, false ) );
         grid.addHeader( new GridHeader( i18n.getString( "phone_number" ), false, false ) );
         grid.addHeader( new GridHeader( i18n.getString( "program_stage" ), false, false ) );
@@ -404,6 +405,14 @@
 
             grid.addRow();
             grid.addValue( DateUtils.getMediumDateString( stageInstance.getDueDate() ) );
+            if( stageInstance.getExecutionDate() != null )
+            {
+                grid.addValue( stageInstance.getOrganisationUnit().getName() );
+            }
+            else
+            {
+                grid.addValue( patient.getOrganisationUnit().getName() );
+            }
             grid.addValue( displayPatientName );
             grid.addValue( patient.getPhoneNumber() );
             grid.addValue( stageInstance.getProgramStage().getDisplayName() );
@@ -412,9 +421,11 @@
         return grid;
     }
 
+    @Override
     public int getActiveInstanceCount( Program program, Collection<Integer> orgunitIds, Date startDate, Date endDate,
         Collection<Integer> statusList )
     {
         return programStageInstanceStore.getActiveInstanceCount( program, orgunitIds, startDate, endDate, statusList );
     }
+    
 }

=== 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-03-04 14:14:36 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java	2013-03-05 07:29:03 +0000
@@ -699,7 +699,7 @@
         Criteria criteria = getActiveInstanceCriteria( program, orgunitIds, startDate, endDate, statusList, null, null );
 
         List<ProgramStageInstance> list = criteria.list();
-       
+
         return list != null ? list.size() : 0;
     }
 
@@ -1940,7 +1940,7 @@
         }
     }
 
-    public Criteria getActiveInstanceCriteria( Program program, Collection<Integer> orgunitIds, Date startDate,
+    private Criteria getActiveInstanceCriteria( Program program, Collection<Integer> orgunitIds, Date startDate,
         Date endDate, Collection<Integer> statusList, Integer max, Integer min )
     {
         Criteria criteria = getCriteria();
@@ -1968,14 +1968,12 @@
                     Restrictions.in( "organisationUnit.id", orgunitIds ) ) );
                 break;
             case ProgramStageInstance.FUTURE_VISIT_STATUS:
-                disjunction.add( Restrictions.and(
-                    Restrictions.isNull( "executionDate" ), 
+                disjunction.add( Restrictions.and( Restrictions.isNull( "executionDate" ),
                     Restrictions.between( "dueDate", new Date(), endDate ),
                     Restrictions.in( "regOrgunit.id", orgunitIds ) ) );
                 break;
             case ProgramStageInstance.LATE_VISIT_STATUS:
-                disjunction.add( Restrictions.and(
-                    Restrictions.isNull( "executionDate" ), 
+                disjunction.add( Restrictions.and( Restrictions.isNull( "executionDate" ),
                     Restrictions.between( "dueDate", startDate, new Date() ),
                     Restrictions.in( "regOrgunit.id", orgunitIds ) ) );
                 break;
@@ -1985,7 +1983,7 @@
         }
 
         criteria.add( disjunction );
-        
+
         if ( min != null && max != null )
         {
             criteria.setFirstResult( min );
@@ -1995,7 +1993,7 @@
         criteria.addOrder( Order.asc( "executionDate" ) );
         criteria.addOrder( Order.asc( "dueDate" ) );
         criteria.addOrder( Order.asc( "programStage.minDaysFromStart" ) );
-        
+
         return criteria;
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetActivityPlansAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetActivityPlansAction.java	2013-03-04 14:05:33 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetActivityPlansAction.java	2013-03-05 07:29:03 +0000
@@ -36,6 +36,7 @@
 import org.hisp.dhis.i18n.I18n;
 import org.hisp.dhis.i18n.I18nFormat;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.paging.ActionPagingSupport;
 import org.hisp.dhis.patient.PatientIdentifierType;
 import org.hisp.dhis.program.Program;
@@ -76,6 +77,13 @@
         this.programStageInstanceService = programStageInstanceService;
     }
 
+    private OrganisationUnitService organisationUnitService;
+
+    public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+    {
+        this.organisationUnitService = organisationUnitService;
+    }
+
     private I18n i18n;
 
     public void setI18n( I18n i18n )
@@ -122,6 +130,13 @@
         this.endDate = endDate;
     }
 
+    private String facilityLB;
+
+    public void setFacilityLB( String facilityLB )
+    {
+        this.facilityLB = facilityLB;
+    }
+
     private String type;
 
     public void setType( String type )
@@ -173,19 +188,36 @@
     {
         OrganisationUnit orgunit = selectedStateManager.getSelectedOrganisationUnit();
 
+        // ---------------------------------------------------------------------
+        // Get orgunitIds
+        // ---------------------------------------------------------------------
+
         Collection<Integer> orgunitIds = new HashSet<Integer>();
-        orgunitIds.add( orgunit.getId() );
+
+        if ( facilityLB.equals( "selected" ) )
+        {
+            orgunitIds.add( orgunit.getId() );
+        }
+        else if ( facilityLB.equals( "childrenOnly" ) )
+        {
+            orgunitIds.addAll( organisationUnitService.getOrganisationUnitHierarchy().getChildren( orgunit.getId() ) );
+            orgunitIds.remove( orgunit.getId() );
+        }
+        else
+        {
+            orgunitIds.addAll( organisationUnitService.getOrganisationUnitHierarchy().getChildren( orgunit.getId() ) );
+        }
+
+        // ---------------------------------------------------------------------
+        // Program instances for the selected program
+        // ---------------------------------------------------------------------
 
         program = programService.getProgram( programId );
-        
-        // ---------------------------------------------------------------------
-        // Program instances for the selected program
-        // ---------------------------------------------------------------------
 
         if ( type == null )
         {
             identifierTypes = program.getPatientIdentifierTypes();
-            
+
             total = programStageInstanceService.getActiveInstanceCount( program, orgunitIds,
                 format.parseDate( startDate ), format.parseDate( endDate ), statusList );
 

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetDataRecordsAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetDataRecordsAction.java	2012-09-27 08:00:40 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/GetDataRecordsAction.java	2013-03-05 07:29:03 +0000
@@ -35,15 +35,16 @@
 
 import org.hisp.dhis.caseentry.state.SelectedStateManager;
 import org.hisp.dhis.common.Grid;
-import org.hisp.dhis.i18n.I18n;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.paging.ActionPagingSupport;
 import org.hisp.dhis.patient.Patient;
+import org.hisp.dhis.patient.PatientIdentifierType;
 import org.hisp.dhis.patient.PatientService;
 import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramInstance;
-import org.hisp.dhis.program.ProgramInstanceService;
 import org.hisp.dhis.program.ProgramService;
+import org.hisp.dhis.program.ProgramStageInstance;
+import org.hisp.dhis.program.ProgramStageInstanceService;
 
 public class GetDataRecordsAction
     extends ActionPagingSupport<Patient>
@@ -73,24 +74,24 @@
         this.programService = programService;
     }
 
-    private ProgramInstanceService programInstanceService;
-
-    public void setProgramInstanceService( ProgramInstanceService programInstanceService )
-    {
-        this.programInstanceService = programInstanceService;
-    }
-
-    private I18n i18n;
-
-    public void setI18n( I18n i18n )
-    {
-        this.i18n = i18n;
+    private ProgramStageInstanceService programStageInstanceService;
+
+    public void setProgramStageInstanceService( ProgramStageInstanceService programStageInstanceService )
+    {
+        this.programStageInstanceService = programStageInstanceService;
     }
 
     // -------------------------------------------------------------------------
     // Input/output
     // -------------------------------------------------------------------------
 
+    private Boolean searchBySelectedOrgunit;
+
+    public void setSearchBySelectedOrgunit( Boolean searchBySelectedOrgunit )
+    {
+        this.searchBySelectedOrgunit = searchBySelectedOrgunit;
+    }
+
     private Integer programId;
 
     public void setProgramId( Integer programId )
@@ -98,20 +99,6 @@
         this.programId = programId;
     }
 
-    private boolean listAll;
-
-    public void setListAll( boolean listAll )
-    {
-        this.listAll = listAll;
-    }
-
-    private Boolean searchBySelectedOrgunit;
-
-    public void setSearchBySelectedOrgunit( Boolean searchBySelectedOrgunit )
-    {
-        this.searchBySelectedOrgunit = searchBySelectedOrgunit;
-    }
-
     private List<String> searchTexts = new ArrayList<String>();
 
     public void setSearchTexts( List<String> searchTexts )
@@ -119,13 +106,6 @@
         this.searchTexts = searchTexts;
     }
 
-    private String type;
-
-    public void setType( String type )
-    {
-        this.type = type;
-    }
-
     private Integer total;
 
     public Integer getTotal()
@@ -147,6 +127,20 @@
         return patients;
     }
 
+    private List<ProgramStageInstance> programStageInstances = new ArrayList<ProgramStageInstance>();
+
+    public List<ProgramStageInstance> getProgramStageInstances()
+    {
+        return programStageInstances;
+    }
+
+    private List<PatientIdentifierType> identifierTypes;
+
+    public List<PatientIdentifierType> getIdentifierTypes()
+    {
+        return identifierTypes;
+    }
+
     private Program program;
 
     public Program getProgram()
@@ -170,57 +164,29 @@
     {
         OrganisationUnit orgunit = selectedStateManager.getSelectedOrganisationUnit();
 
-        program = programService.getProgram( programId );
-
-        // ---------------------------------------------------------------------
-        // Program instances for the selected program
-        // ---------------------------------------------------------------------
-        if ( type == null ) // Tabular report
-        {
-            // List all patients
-            if ( listAll )
-            {
-                total = (program == null) ? patientService.countGetPatientsByOrgUnit( orgunit ) : patientService
-                    .countGetPatientsByOrgUnitProgram( orgunit, program );
-
-                this.paging = createPaging( total );
-
-                patients = new ArrayList<Patient>( patientService.getPatients( orgunit, program, paging.getStartPos(),
-                    paging.getPageSize() ) );
-
-            }
-            // search patients
-            else if ( searchTexts.size() > 0 )
-            {
-                orgunit = (searchBySelectedOrgunit) ? orgunit : null;
-
-                total = patientService.countSearchPatients( searchTexts, orgunit );
-                this.paging = createPaging( total );
-                patients = patientService.searchPatients( searchTexts, orgunit, paging.getStartPos(),
-                    paging.getPageSize() );
-            }
-
-            for ( Patient patient : patients )
-            {
-                Collection<ProgramInstance> programInstances = programInstanceService.getProgramInstances( patient,
-                    program, false );
-
-                if ( programInstances == null || programInstances.size() == 0 )
-                {
-                    programInstanceMap.put( patient, null );
-                }
-                else
-                {
-                    programInstanceMap.put( patient, programInstances.iterator().next() );
-                }
-            }
-        }
-        else
-        // Download as Excel
-        {
-            grid = patientService.getScheduledEventsReport( searchTexts, orgunit, i18n );
+        if ( programId != null )
+        {
+            program = programService.getProgram( programId );
+            
+            identifierTypes = program.getPatientIdentifierTypes();
         }
         
-        return type == null ? SUCCESS : type;
+        if ( searchTexts.size() > 0 )
+        {
+            orgunit = (searchBySelectedOrgunit) ? orgunit : null;
+
+            total = patientService.countSearchPatients( searchTexts, orgunit );
+            this.paging = createPaging( total );
+
+            List<Integer> stageInstanceIds = patientService.getProgramStageInstances( searchTexts, orgunit,
+                paging.getStartPos(), paging.getPageSize() );
+
+            for ( Integer stageInstanceId : stageInstanceIds )
+            {
+                programStageInstances.add( programStageInstanceService.getProgramStageInstance( stageInstanceId ) );
+            }
+        }
+
+        return SUCCESS;
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml	2013-03-04 09:38:55 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml	2013-03-05 07:29:03 +0000
@@ -188,8 +188,8 @@
 		<property name="selectedStateManager"
 			ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
 		<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
+		<property name="programStageInstanceService" ref="org.hisp.dhis.program.ProgramStageInstanceService" />
 		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
-		<property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
 	</bean>
 
 	<!-- Single-event DataEntry -->
@@ -1106,6 +1106,8 @@
 		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
 		<property name="programStageInstanceService"
 			ref="org.hisp.dhis.program.ProgramStageInstanceService" />
+		<property name="organisationUnitService"
+			ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
 	</bean>
 
 </beans>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2013-03-05 04:09:58 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2013-03-05 07:29:03 +0000
@@ -572,4 +572,5 @@
 date_scheduled = Date scheduled
 visit_schedule_form = Visit schedule
 missing_patient_attribute = Missing person attribute
-missing_patient_identifier_type = Missing patient identifier type
\ No newline at end of file
+missing_patient_identifier_type = Missing patient identifier type
+advanced_search = Advanced search
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml	2013-03-04 15:35:48 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml	2013-03-05 07:29:03 +0000
@@ -973,6 +973,7 @@
       <param name="javascripts">
         ../dhis-web-commons/ouwt/ouwt.js,
         javascript/commons.js,
+        javascript/patient.js,
         javascript/relationshipPatient.js,
         javascript/entry.js,
         javascript/smsReminder.js
@@ -1076,13 +1077,6 @@
       <result name="xls" type="gridXlsResult" />
       <result name="pdf" type="gridPdfResult" />
     </action>
-
-    <action name="exportActitityList"
-      class="org.hisp.dhis.caseentry.action.caseentry.GetDataRecordsAction">
-      <result name="xls" type="gridXlsResult" />
-      <result name="pdf" type="gridPdfResult" />
-      <param name="requiredAuthorities">F_ACTIVITY_PLAN_EXPORT</param>
-    </action>
-
+	
   </package>
 </struts>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/activityPlanRecords.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/activityPlanRecords.vm	2013-03-05 05:09:03 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/activityPlanRecords.vm	2013-03-05 07:29:03 +0000
@@ -18,6 +18,7 @@
 		<tr>
 			<th>#</th>
 			<th>$i18n.getString('date_scheduled')</th>
+			<th>$i18n.getString('orgunit')</th>
 			<th>$i18n.getString('full_name')</th>
 			<th>$i18n.getString('phone_number')</th>
 			<th>$i18n.getString( "program_stage" )</th>
@@ -32,6 +33,7 @@
 				#set( $nr = ( ( $paging.getCurrentPage() - 1  ) * $paging.pageSize ) + $velocityCount )
 				$nr
 			</td>
+			
 			<td>
 				#if($!programStageInstance.executionDate)
 					$format.formatDate($!programStageInstance.executionDate)
@@ -40,6 +42,14 @@
 				#end
 			</td>
 			
+			<td>
+				#if($!programStageInstance.executionDate)
+					$!programStageInstance.organisationUnit.name
+				#else
+					$patient.organisationUnit.name
+				#end
+			</td>
+			
 			<td><a href="javascript:isDashboard=false;showPatientDashboardForm( '$patient.id' )">
 				#set($value="")
 				#foreach( $identifierType in $identifierTypes)
@@ -61,7 +71,6 @@
 			<td><a href="javascript:loadDataEntryDialog( $programStageInstance.id );">$programStageInstance.programStage.displayName</a></td>
 			
 		</tr>
-		#set( $mark = !$mark )
 	#end
 	</tbody>
 </table>

=== 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	2013-03-05 04:09:58 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/activityPlanSelect.vm	2013-03-05 07:29:03 +0000
@@ -91,6 +91,14 @@
 				</td>
 			</tr>
 			<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')
+				</td>
+			</tr>
+			<tr>
 				<td></td>
 				<td>
 					<input type="submit" class='large-button' id='listPatientBtn' value="$i18n.getString( 'show_activity_list' )" onclick="setFieldValue('export', false);">

=== 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	2013-03-05 05:09:03 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/activityPlan.js	2013-03-05 07:29:03 +0000
@@ -62,7 +62,8 @@
 		{
 			programId:getFieldValue('programIdAddPatient'),
 			startDate:getFieldValue('startDueDate'),
-			endDue:getFieldValue('endDueDate')
+			endDue:getFieldValue('endDueDate'),
+			facilityLB: $('input[name=facilityLB]:checked').val()
 		}, 
 		function()
 		{
@@ -79,6 +80,8 @@
 	params += "&startDate=" + getFieldValue('startDueDate');
 	params += "&endDue=" + getFieldValue('endDueDate');
 	params += "&type=xls";
+	params += "&facilityLB=" + $('input[name=facilityLB]:checked').val();
+	
 	var statusEvent = getFieldValue('statusEvent').split('_');
 	for( var i in statusEvent){
 		params += "&statusList=" + statusEvent[i];

=== 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	2012-12-18 05:41:39 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/smsReminder.js	2013-03-05 07:29:03 +0000
@@ -75,7 +75,7 @@
 			setInnerHTML('searchInforLbl',i18n_list_all_patients);
 			showById('colorHelpLink');
 			showById('listEventDiv');
-			resize();
+			setTableStyles();
 			hideLoader();
 		});
 }
@@ -97,11 +97,11 @@
 		type:"POST",
 		data: params,
 		success: function( html ){
+			setTableStyles();
 			jQuery('#listEventDiv').html(html);
 			showById('colorHelpLink');
 			showById('listEventDiv');
 			eventList = 2;
-			resize();
 			hideLoader();
 		}
 	});

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programTrackingRecords.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programTrackingRecords.vm	2013-01-23 10:27:28 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programTrackingRecords.vm	2013-03-05 07:29:03 +0000
@@ -21,110 +21,68 @@
 	</tr>
 </table>
 
-#if( $patients && $patients.size()>0 )
-	<p>#parse( "/dhis-web-caseentry/colorHelp.vm" )</p>
-	
-	<table id="patientList" class="listTable">
-		#set( $mark = false )                 
-		#foreach( $patient in $patients )
-			#set( $programInstance = '')
-			#set( $programInstance = $programInstanceMap.get( $patient ) )
-				<tr #alternate( $mark ) id='event_$programInstance.id'>
-					<td>
-						#set( $value="")
-						#foreach( $identifierType in $programInstance.program.patientIdentifierTypes )
-							#foreach( $pIdentifier in $patient.identifiers )
-								#if($identifierType.personDisplayName=="true" && $identifierType.id==$pIdentifier.identifierType.id)
-									#set($value=$value + $pIdentifier.identifier + "&#13;&#10;" )
-								#end
-							#end
-						#end
-						#if($value=="")
-							#set($value=$patient.getFullName())
-						#end
-						<input type='button' class='patient-object' value='$value' onclick='javascript:showPatientDashboardForm( "$programInstance.patient.id" );' title='$i18n.getString( "patient_dashboard" )'>
-					</td>
-					<td class='bold' style='cursor:pointer;font-size:25px' onclick="eventFlowToggle($programInstance.id)">
-						<a>&raquo;</a>
-					</td>
-					#set( $programStageInstances = $programInstance.programStageInstances )
-					<td>
-						<table id='tb_$programInstance.id' class="stage-container">	
-							<tr>
-								<td>
-									<div class="arrow-left" onclick="moveLeft('flow_$programInstance.id')">&nbsp;</div>
-								</td>
-								<td>
-									<div id='flow_$!programInstance.id' class="stage-flow">
-										<table class="table-flow">
-										<tr>
-										#set( $flag = "false" )
-										#set( $idx = 0)
-										#foreach( $programStageInstance in $programStageInstances )
-											#set( $idx = $idx + 1)
-											<td id="arrow_$programStageInstance.id" style='font-size:25px;'>&rarr;</td>
-											<td id="td_$programStageInstance.id">
-												#set($title="")
-												#set($index = 0)
-												#foreach( $comment in $programStageInstance.patientComments)
-													#if( $index < 5)
-														#set( $title= $title + "$format.formatDate( $comment.createdDate ) - $comment.creator - $comment.commentText &#13;&#10;" )
-														#set( $index = $index + 1 )
-													#end
-												#end
-												
-												#set($valueDate=$format.formatDate( $programStageInstance.dueDate ))
-												#if($!programStageInstance.executionDate)
-													#set($valueDate=$format.formatDate( $programStageInstance.executionDate ))
-												#end
-												
-												<input type='button' id='ps_$programStageInstance.id' name='programStageBtn' 
-													programStageInstanceId='$programStageInstance.id' 
-													programStageName='$encoder.htmlEncode($programStageInstance.programStage.displayName)' 
-													programStageId='$programStageInstance.programStage.id' 
-													programInstanceId='$programInstance.id'
-													dueDate='$format.formatDate( $programStageInstance.dueDate )'
-													status='$programStageInstance.getEventStatus()'
-													index="$idx"
-													class='stage-object'
-													value='$programStageInstance.programStage.displayName&#13;&#10;$valueDate' 
-													title="$title" onclick='javascript:programTrackingList( $programStageInstance.id, false );'>
-												<script>
-													var status = $programStageInstance.getEventStatus(); 
-													var dueDate = "$format.formatDate($programStageInstance.dueDate)";
-													setEventColorStatus( $programStageInstance.id ,status, dueDate );
-												</script>
-											</td>
-										#end
-										</tr>
-									</table></div>
-								</td>
-								
-								<td>
-									<div class="arrow-right" onclick="moveRight('flow_$programInstance.id')">&nbsp;</div>
-								</td>
-							</tr>
-						</table>
-					</td>
-				</tr>
-			#if( $mark )
-				#set( $mark = false )
-			#else
-				#set( $mark = true )
-			#end 
-		#end
-	</table>
-	
-	<div class="paging-container">
-		#parse( "/dhis-web-commons/paging/paging.vm" )
-	</div>
-	
-	<div id="detailsInfo"></div>
+#if( $programStageInstances && $programStageInstances.size()>0 )
+
+<table class='listTable gridTable'>
+	<col/>
+	<col/>
+	<col width='30%'/>
+	<thead>
+		<tr>
+			<th>#</th>
+			<th>$i18n.getString('date_scheduled')</th>
+			<th>$i18n.getString('full_name')</th>
+			<th>$i18n.getString('phone_number')</th>
+			<th>$i18n.getString( "program_stage" )</th>
+		</tr>
+	</thead>
+	<tbody id="list">
+	#set( $mark = false ) 
+	#foreach( $programStageInstance in $programStageInstances )
+		#set($patient = $programStageInstance.programInstance.patient)
+		<tr id='tr$programStageInstance.id'>
+			<td>
+				#set( $nr = ( ( $paging.getCurrentPage() - 1  ) * $paging.pageSize ) + $velocityCount )
+				$nr
+			</td>
+			
+			<td>
+				#if($!programStageInstance.executionDate)
+					$format.formatDate($!programStageInstance.executionDate)
+				#else
+					$format.formatDate($!programStageInstance.dueDate)
+				#end
+			</td>
+			
+			<td><a href="javascript:isDashboard=false;showPatientDashboardForm( '$patient.id' )">
+				#set($value="")
+				#foreach( $identifierType in $identifierTypes)
+					#foreach( $identifier in $patient.identifiers)
+						#if($identifier.identifierType.id==$identifierType.id)
+							#set($value=$identifier.identifier)
+						#end
+					#end
+				#end
+				#if($value=="")
+					#set($value=$patient.getFullName())
+				#end
+				
+				$value
+			</a></td>
+			
+			<td>$!patient.phoneNumber</td>
+			
+			<td><a href="javascript:programTrackingList( $programStageInstance.id, false );">$programStageInstance.programStage.displayName</a></td>
+			
+		</tr>
+	#end
+	</tbody>
+</table>
+
+<div class="paging-container">
+	#parse( "/dhis-web-commons/paging/paging.vm" )
+</div>
+
+<div id="detailsInfo"></div>
+
 #end
-
-<script>
-	$(window).bind('resize', function(e){ 
-		resize();
-	});
-	reloadRecordList();
-</script>
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchPatientCriteria.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchPatientCriteria.vm	2013-03-05 04:09:58 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchPatientCriteria.vm	2013-03-05 07:29:03 +0000
@@ -14,7 +14,7 @@
 		<td rowspan='2' valign='bottom'>
 			<input type="button" class='large-button' id='listPatientBtn' value="$i18n.getString( 'list_all_patients' )" onclick="javascript:listAllPatient();" disabled >
 			<input type="button" class='large-button' id='addPatientBtn' name='addPatientBtn' class='large-button' value='$i18n.getString( "add_new" )' onclick="showAddPatientForm();" disabled >
-			<input type="button" class='large-button' id='advancedSearchBtn' value='$i18n.getString( "advanced_search" )' onclick="jQuery('#advanced-search').toggle();" disabled>
+			<input type="button" style='width:120px' id='advancedSearchBtn' value='$i18n.getString( "advanced_search" )' onclick="jQuery('#advanced-search').toggle();" disabled>
 		</td>
 	</tr> 
 	<tr id='programAddPatientTR'>
@@ -40,6 +40,7 @@
 					<option value='2'>$i18n.getString("incomplete")</option>
 					<option value='1'>$i18n.getString("completed")</option>
 					<option value='3'>$i18n.getString("scheduled_in_future")</option> 
+					<option value='5'>$i18n.getString("skipped")</option> 
 				</select>
 			</td>
 		</tr>