← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6540: (patient) Add attribute and identifier into Tabular report.

 

------------------------------------------------------------
revno: 6540
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-04-11 13:25:02 +0700
message:
  (patient) Add attribute and identifier into Tabular report.
added:
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GetOrganisationUnitChildrenAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GetTabularParamsAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/LoadAttributeGroupsAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/LoadAttributesAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/LoadIdentifierTypesAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/LoadProgramsAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/TabularInitializeAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/responseTabularParams.vm
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java
  dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadProgramStagesAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateTabularReportAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/LoadDataElementsAction.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/caseAggregationForm.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/tabularReport.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/responseProgramStages.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchTabularReportResult.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/style/report.css
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/tabularReportResult.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/tabularReportSelect.vm
  dhis-2/dhis-web/dhis-web-visualizer/src/main/resources/org/hisp/dhis/visualizer/i18n_module.properties


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java	2012-03-23 03:46:08 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java	2012-04-11 06:25:02 +0000
@@ -37,6 +37,8 @@
 import org.hisp.dhis.i18n.I18nFormat;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.patient.Patient;
+import org.hisp.dhis.patient.PatientAttribute;
+import org.hisp.dhis.patient.PatientIdentifierType;
 
 /**
  * @author Abyot Asalefew
@@ -87,13 +89,13 @@
 
     List<ProgramStageInstance> getProgramStageInstances( Patient patient, Boolean completed );
             
-    List<ProgramStageInstance> searchProgramStageInstances( ProgramStage programStage, Map<Integer,String> searchingKeys, Collection<Integer> orgunitIds, Date startDate, Date endDate, boolean orderByOrgunitAsc, boolean orderByExecutionDateByAsc, int min, int max );
+    List<ProgramStageInstance> searchProgramStageInstances( ProgramStage programStage, Map<Integer,String> searchingIdenKeys, Map<Integer,String> searchingAttrKeys, Map<Integer,String> searchingDEKeys, Collection<Integer> orgunitIds, Date startDate, Date endDate, boolean orderByOrgunitAsc, boolean orderByExecutionDateByAsc, int min, int max );
 
-    Grid getTabularReport( ProgramStage programStage, List<DataElement> dataElements, Map<Integer,String> searchingKeys, Collection<Integer> orgunitIds, int level, Date startDate, Date endDate, boolean orderByOrgunitAsc, boolean orderByExecutionDateByAsc, int min, int max, I18nFormat format, I18n i18n );
+    Grid getTabularReport( ProgramStage programStage, List<PatientIdentifierType> idens, List<PatientAttribute> attributes, List<DataElement> dataElements, Map<Integer,String> searchingIdenKeys, Map<Integer,String> searchingAttrKeys, Map<Integer,String> searchingDEKeys, Collection<Integer> orgunitIds, int level, Date startDate, Date endDate, boolean orderByOrgunitAsc, boolean orderByExecutionDateByAsc, int min, int max, I18nFormat format, I18n i18n );
     
-    Grid getTabularReport( ProgramStage programStage, List<DataElement> dataElements, Map<Integer,String> searchingKeys, Collection<Integer> orgunitIds, int level, Date startDate, Date endDate, boolean orderByOrgunitAsc, boolean orderByExecutionDateByAsc, I18nFormat format, I18n i18n );
+    Grid getTabularReport( ProgramStage programStage, List<PatientIdentifierType> idens, List<PatientAttribute> attributes, List<DataElement> dataElements, Map<Integer,String> searchingIdenKeys, Map<Integer,String> searchingAttrKeys, Map<Integer,String> searchingDEKeys, Collection<Integer> orgunitIds, int level, Date startDate, Date endDate, boolean orderByOrgunitAsc, boolean orderByExecutionDateByAsc, I18nFormat format, I18n i18n );
 
-    int countProgramStageInstances( ProgramStage programStage, Map<Integer,String> searchingKeys, Collection<Integer> orgunitIds, Date startDate, Date endDate );
+    int countProgramStageInstances( ProgramStage programStage, Map<Integer,String> searchingIdenKeys, Map<Integer,String> searchingAttrKeys, Map<Integer,String> searchingDEKeys, Collection<Integer> orgunitIds, Date startDate, Date endDate );
     
     List<Grid> getProgramStageInstancesReport( ProgramInstance programInstance, I18nFormat format, I18n i18n );
 }

=== 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	2012-03-10 05:06:47 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java	2012-04-11 06:25:02 +0000
@@ -71,10 +71,10 @@
     
     List<ProgramStageInstance> get( ProgramStage programStage, OrganisationUnit orgunit, Date startDate, Date endDate, int min, int max );
     
-    List<ProgramStageInstance> get( ProgramStage programStage, Map<Integer,String> searchingKeys, Collection<Integer> orgunitIds, Date startDate, Date endDate, boolean orderByOrgunitAsc, boolean orderByExecutionDateByAsc, int min, int max );
+    List<ProgramStageInstance> get( ProgramStage programStage, Map<Integer,String> searchingIdenKeys, Map<Integer,String> searchingAttrKeys, Map<Integer,String> searchingDEKeys, Collection<Integer> orgunitIds, Date startDate, Date endDate, boolean orderByOrgunitAsc, boolean orderByExecutionDateByAsc, int min, int max );
     
-    List<ProgramStageInstance> get( ProgramStage programStage, Map<Integer,String> searchingKeys, Collection<Integer> orgunitIds, Date startDate, Date endDate, boolean orderByOrgunitAsc, boolean orderByExecutionDateByAsc );
+    List<ProgramStageInstance> get( ProgramStage programStage, Map<Integer,String> searchingIdenKeys, Map<Integer,String> searchingAttrKeys, Map<Integer,String> searchingDEKeys, Collection<Integer> orgunitIds, Date startDate, Date endDate, boolean orderByOrgunitAsc, boolean orderByExecutionDateByAsc );
 
-    int count( ProgramStage programStage, Map<Integer,String> searchingKeys, Collection<Integer> orgunitIds, Date startDate, Date endDate );
+    int count( ProgramStage programStage, Map<Integer,String> searchingIdenKeys, Map<Integer,String> searchingAttrKeys, Map<Integer,String> searchingKeys, Collection<Integer> orgunitIds, Date startDate, Date endDate );
     
 }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java	2012-04-10 10:10:21 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java	2012-04-11 06:25:02 +0000
@@ -42,6 +42,12 @@
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.patient.Patient;
+import org.hisp.dhis.patient.PatientAttribute;
+import org.hisp.dhis.patient.PatientIdentifier;
+import org.hisp.dhis.patient.PatientIdentifierService;
+import org.hisp.dhis.patient.PatientIdentifierType;
+import org.hisp.dhis.patientattributevalue.PatientAttributeValue;
+import org.hisp.dhis.patientattributevalue.PatientAttributeValueService;
 import org.hisp.dhis.patientdatavalue.PatientDataValue;
 import org.hisp.dhis.patientdatavalue.PatientDataValueService;
 import org.hisp.dhis.system.grid.ListGrid;
@@ -80,6 +86,20 @@
         this.organisationUnitService = organisationUnitService;
     }
 
+    private PatientIdentifierService identifierService;
+
+    public void setIdentifierService( PatientIdentifierService identifierService )
+    {
+        this.identifierService = identifierService;
+    }
+
+    private PatientAttributeValueService patientAttributeValueService;
+
+    public void setPatientAttributeValueService( PatientAttributeValueService patientAttributeValueService )
+    {
+        this.patientAttributeValueService = patientAttributeValueService;
+    }
+
     // -------------------------------------------------------------------------
     // Implementation methods
     // -------------------------------------------------------------------------
@@ -195,48 +215,58 @@
     }
 
     public List<ProgramStageInstance> searchProgramStageInstances( ProgramStage programStage,
-        Map<Integer, String> searchingKeys, Collection<Integer> orgunitIds, Date startDate, Date endDate,
+        Map<Integer, String> searchingIdenKeys, Map<Integer, String> searchingAttrKeys,
+        Map<Integer, String> searchingDEKeys, Collection<Integer> orgunitIds, Date startDate, Date endDate,
         boolean orderByOrgunitAsc, boolean orderByExecutionDateByAsc, int min, int max )
     {
-        return programStageInstanceStore.get( programStage, searchingKeys, orgunitIds, startDate, endDate,
-            orderByOrgunitAsc, orderByExecutionDateByAsc, min, max );
+        return programStageInstanceStore.get( programStage, searchingIdenKeys, searchingAttrKeys, searchingDEKeys,
+            orgunitIds, startDate, endDate, orderByOrgunitAsc, orderByExecutionDateByAsc, min, max );
     }
 
     public List<ProgramStageInstance> searchProgramStageInstances( ProgramStage programStage,
-        Map<Integer, String> searchingKeys, Collection<Integer> orgunitIds, Date startDate, Date endDate,
+        Map<Integer, String> searchingIdenKeys, Map<Integer, String> searchingAttrKeys,
+        Map<Integer, String> searchingDEKeys, Collection<Integer> orgunitIds, Date startDate, Date endDate,
         boolean orderByOrgunitAsc, boolean orderByExecutionDateByAsc )
     {
-        return programStageInstanceStore.get( programStage, searchingKeys, orgunitIds, startDate, endDate,
-            orderByOrgunitAsc, orderByExecutionDateByAsc );
-    }
-
-    public Grid getTabularReport( ProgramStage programStage, List<DataElement> dataElements,
-        Map<Integer, String> searchingKeys, Collection<Integer> orgunitIds, int level, Date startDate, Date endDate,
-        boolean orderByOrgunitAsc, boolean orderByExecutionDateByAsc, int min, int max, I18nFormat format, I18n i18n )
-    {
-        List<ProgramStageInstance> programStageInstances = searchProgramStageInstances( programStage, searchingKeys,
-            orgunitIds, startDate, endDate, orderByOrgunitAsc, orderByExecutionDateByAsc, min, max );
-
-        return createTabularGrid( level, programStage, programStageInstances, dataElements, startDate, endDate, format,
-            i18n );
-    }
-
-    public Grid getTabularReport( ProgramStage programStage, List<DataElement> dataElements,
-        Map<Integer, String> searchingKeys, Collection<Integer> orgunitIds, int level, Date startDate, Date endDate,
-        boolean orderByOrgunitAsc, boolean orderByExecutionDateByAsc, I18nFormat format, I18n i18n )
-    {
-        List<ProgramStageInstance> programStageInstances = searchProgramStageInstances( programStage, searchingKeys,
+        return programStageInstanceStore.get( programStage, searchingIdenKeys, searchingAttrKeys, searchingDEKeys,
             orgunitIds, startDate, endDate, orderByOrgunitAsc, orderByExecutionDateByAsc );
-
-        return createTabularGrid( level, programStage, programStageInstances, dataElements, startDate, endDate, format,
-            i18n );
+    }
+
+    public Grid getTabularReport( ProgramStage programStage, List<PatientIdentifierType> idens,
+        List<PatientAttribute> attributes, List<DataElement> dataElements, Map<Integer, String> searchingIdenKeys,
+        Map<Integer, String> searchingAttrKeys, Map<Integer, String> searchingDEKeys, Collection<Integer> orgunitIds,
+        int level, Date startDate, Date endDate, boolean orderByOrgunitAsc, boolean orderByExecutionDateByAsc, int min,
+        int max, I18nFormat format, I18n i18n )
+    {
+        List<ProgramStageInstance> programStageInstances = searchProgramStageInstances( programStage,
+            searchingIdenKeys, searchingAttrKeys, searchingDEKeys, orgunitIds, startDate, endDate, orderByOrgunitAsc,
+            orderByExecutionDateByAsc, min, max );
+
+        return createTabularGrid( level, programStage, programStageInstances, idens, attributes, dataElements,
+            startDate, endDate, format, i18n );
+    }
+
+    public Grid getTabularReport( ProgramStage programStage, List<PatientIdentifierType> idens,
+        List<PatientAttribute> attributes, List<DataElement> dataElements, Map<Integer, String> searchingIdenKeys,
+        Map<Integer, String> searchingAttrKeys, Map<Integer, String> searchingDEKeys, Collection<Integer> orgunitIds,
+        int level, Date startDate, Date endDate, boolean orderByOrgunitAsc, boolean orderByExecutionDateByAsc,
+        I18nFormat format, I18n i18n )
+    {
+        List<ProgramStageInstance> programStageInstances = searchProgramStageInstances( programStage,
+            searchingIdenKeys, searchingAttrKeys, searchingDEKeys, orgunitIds, startDate, endDate, orderByOrgunitAsc,
+            orderByExecutionDateByAsc );
+
+        return createTabularGrid( level, programStage, programStageInstances, idens, attributes, dataElements,
+            startDate, endDate, format, i18n );
     }
 
     @Override
-    public int countProgramStageInstances( ProgramStage programStage, Map<Integer, String> searchingKeys,
-        Collection<Integer> orgunitIds, Date startDate, Date endDate )
+    public int countProgramStageInstances( ProgramStage programStage, Map<Integer, String> searchingIdenKeys,
+        Map<Integer, String> searchingAttrKeys, Map<Integer, String> searchingDEKeys, Collection<Integer> orgunitIds,
+        Date startDate, Date endDate )
     {
-        return programStageInstanceStore.count( programStage, searchingKeys, orgunitIds, startDate, endDate );
+        return programStageInstanceStore.count( programStage, searchingIdenKeys, searchingAttrKeys, searchingDEKeys,
+            orgunitIds, startDate, endDate );
     }
 
     public List<Grid> getProgramStageInstancesReport( ProgramInstance programInstance, I18nFormat format, I18n i18n )
@@ -311,17 +341,16 @@
     // -------------------------------------------------------------------------
 
     private Grid createTabularGrid( Integer level, ProgramStage programStage,
-        List<ProgramStageInstance> programStageInstances, List<DataElement> dataElements, Date startDate, Date endDate,
+        List<ProgramStageInstance> programStageInstances, List<PatientIdentifierType> idens,
+        List<PatientAttribute> attributes, List<DataElement> dataElements, Date startDate, Date endDate,
         I18nFormat format, I18n i18n )
     {
         Grid grid = new ListGrid();
 
-        if ( dataElements != null && dataElements.size() > 0 && programStageInstances.size() > 0 )
+        if ( programStageInstances.size() > 0 )
         {
             Program program = programStage.getProgram();
 
-            Boolean anonymous = program.getAnonymous();
-
             // ---------------------------------------------------------------------
             // Create a grid
             // ---------------------------------------------------------------------
@@ -337,26 +366,87 @@
             grid.addHeader( new GridHeader( i18n.getString( "report_unit" ), false, true ) );
             grid.addHeader( new GridHeader( i18n.getString( "report_date" ), false, true ) );
 
-            for ( DataElement dataElement : dataElements )
-            {
-                grid.addHeader( new GridHeader( dataElement.getName(), false, true ) );
-            }
-
-            if ( !anonymous )
-            {
-                grid.addHeader( new GridHeader( "", true, false ) );
+            if ( idens != null && idens.size() > 0 )
+            {
+                for ( PatientIdentifierType identifierType : idens )
+                {
+                    grid.addHeader( new GridHeader( identifierType.getName(), false, true ) );
+                }
+            }
+
+            if ( attributes != null && attributes.size() > 0 )
+            {
+                for ( PatientAttribute attribute : attributes )
+                {
+                    grid.addHeader( new GridHeader( attribute.getName(), false, true ) );
+                }
+            }
+
+            if ( dataElements != null && dataElements.size() > 0 )
+            {
+                for ( DataElement dataElement : dataElements )
+                {
+                    grid.addHeader( new GridHeader( dataElement.getName(), false, true ) );
+                }
             }
 
             // ---------------------------------------------------------------------
-            // Values
+            // Get patient-identifiers
             // ---------------------------------------------------------------------
 
             for ( ProgramStageInstance programStageInstance : programStageInstances )
             {
                 grid.addRow();
+
+                // -------------------------------------------------------------
+                // Add enrollment information
+                // -------------------------------------------------------------
+
                 grid.addValue( getHierarchyOrgunit( programStageInstance.getOrganisationUnit(), level ) );
                 grid.addValue( format.formatDate( programStageInstance.getExecutionDate() ) );
 
+                // -------------------------------------------------------------
+                // Add patient-identifiers
+                // -------------------------------------------------------------
+
+                for ( PatientIdentifierType identifierType : idens )
+                {
+                    Patient patient = programStageInstance.getProgramInstance().getPatient();
+
+                    PatientIdentifier patientIdentifier = identifierService.getPatientIdentifier( identifierType,
+                        patient );
+
+                    if ( patientIdentifier != null )
+                    {
+                        grid.addValue( i18n.getString( patientIdentifier.getIdentifier() ) );
+                    }
+                    else
+                    {
+                        grid.addValue( "" );
+                    }
+                }
+
+                // ---------------------------------------------------------------------
+                // Get patient-attribute-values
+                // ---------------------------------------------------------------------
+
+                for ( PatientAttribute attribute : attributes )
+                {
+                    Patient patient = programStageInstance.getProgramInstance().getPatient();
+
+                    PatientAttributeValue patientAttributeValue = patientAttributeValueService
+                        .getPatientAttributeValue( patient, attribute );
+
+                    if ( patientAttributeValue != null )
+                    {
+                        grid.addValue( i18n.getString( patientAttributeValue.getValue() ) );
+                    }
+                    else
+                    {
+                        grid.addValue( "" );
+                    }
+                }
+
                 for ( DataElement dataElement : dataElements )
                 {
                     PatientDataValue patientDataValue = patientDataValueService.getPatientDataValue(
@@ -378,21 +468,9 @@
                         grid.addValue( "" );
                     }
                 }
-                
-                if ( !anonymous )
-                {
-                    ProgramInstance programInstance = programStageInstance.getProgramInstance();
-                    
-                    if ( programInstance != null && programInstance.getPatient() != null )
-                    {
-                        grid.addValue( programInstance.getPatient().getId() );
-                    }
-                    else
-                    {
-                        grid.addValue( "" );
-                    }
-                }
-            }
+
+            }// end for
+
         }
 
         return grid;
@@ -401,9 +479,9 @@
     private String getHierarchyOrgunit( OrganisationUnit orgunit, int level )
     {
         String hierarchyOrgunit = orgunit.getName();
-        
+
         orgunit = orgunit.getParent();
-        
+
         while ( orgunit != null && organisationUnitService.getLevelOfOrganisationUnit( orgunit.getId() ) >= level )
         {
             hierarchyOrgunit = orgunit.getName() + " / " + hierarchyOrgunit;

=== 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	2012-03-28 12:29:54 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java	2012-04-11 06:25:02 +0000
@@ -188,14 +188,14 @@
     }
 
     @SuppressWarnings( "unchecked" )
-    public List<ProgramStageInstance> get( ProgramStage programStage, Map<Integer, String> searchingKeys,
-        Collection<Integer> orgunitIds, Date startDate, Date endDate, boolean orderByOrgunitAsc,
-        boolean orderByExecutionDateByAsc, int min, int max )
+    public List<ProgramStageInstance> get( ProgramStage programStage, Map<Integer, String> searchingIdenKeys,
+        Map<Integer, String> searchingAttrKeys, Map<Integer, String> searchingDEKeys, Collection<Integer> orgunitIds,
+        Date startDate, Date endDate, boolean orderByOrgunitAsc, boolean orderByExecutionDateByAsc, int min, int max )
     {
-        if ( searchingKeys.keySet().size() > 0 )
+        if ( searchingDEKeys.keySet().size() > 0 )
         {
-            String sql = getBySearchingValues( false, programStage, searchingKeys, orgunitIds, startDate, endDate,
-                orderByOrgunitAsc, orderByExecutionDateByAsc )
+            String sql = getTabularReportStatement( false, programStage, searchingIdenKeys, searchingAttrKeys,
+                searchingDEKeys, orgunitIds, startDate, endDate, orderByOrgunitAsc, orderByExecutionDateByAsc )
                 + statementBuilder.limitRecord( min, max );
 
             List<Integer> ids = executeSQL( sql );
@@ -206,6 +206,7 @@
             {
                 programStageInstances.add( get( id ) );
             }
+
             return programStageInstances;
         }
 
@@ -235,14 +236,14 @@
     }
 
     @SuppressWarnings( "unchecked" )
-    public List<ProgramStageInstance> get( ProgramStage programStage, Map<Integer, String> searchingKeys,
-        Collection<Integer> orgunitIds, Date startDate, Date endDate, boolean orderByOrgunitAsc,
-        boolean orderByExecutionDateByAsc )
+    public List<ProgramStageInstance> get( ProgramStage programStage, Map<Integer, String> searchingIdenKeys,
+        Map<Integer, String> searchingAttrKeys, Map<Integer, String> searchingDEKeys, Collection<Integer> orgunitIds,
+        Date startDate, Date endDate, boolean orderByOrgunitAsc, boolean orderByExecutionDateByAsc )
     {
-        if ( searchingKeys.keySet().size() > 0 )
+        if ( searchingDEKeys.keySet().size() > 0 )
         {
-            String sql = getBySearchingValues( false, programStage, searchingKeys, orgunitIds, startDate, endDate,
-                orderByOrgunitAsc, orderByExecutionDateByAsc );
+            String sql = getTabularReportStatement( false, programStage, searchingIdenKeys, searchingAttrKeys,
+                searchingDEKeys, orgunitIds, startDate, endDate, orderByOrgunitAsc, orderByExecutionDateByAsc );
 
             List<Integer> ids = executeSQL( sql );
 
@@ -257,8 +258,7 @@
         }
 
         Criteria criteria = (getCriteria( Restrictions.eq( "programStage", programStage ), Restrictions.in(
-            "organisationUnit.id", orgunitIds ), Restrictions.between( "executionDate", startDate, endDate ) ))
-            .addOrder( Order.desc( "organisationUnit" ) ).addOrder( Order.desc( "executionDate" ) );
+            "organisationUnit.id", orgunitIds ), Restrictions.between( "executionDate", startDate, endDate ) ));
 
         if ( orderByOrgunitAsc )
         {
@@ -281,14 +281,17 @@
         return criteria.list();
     }
 
-    public int count( ProgramStage programStage, Map<Integer, String> searchingKeys, Collection<Integer> orgunitIds,
+    public int count( ProgramStage programStage, Map<Integer, String> searchingIdenKeys,
+        Map<Integer, String> searchingAttrKeys, Map<Integer, String> searchingDEKeys, Collection<Integer> orgunitIds,
         Date startDate, Date endDate )
     {
-        if ( searchingKeys.keySet().size() > 0 )
+        if ( searchingIdenKeys.keySet().size() > 0 || searchingAttrKeys.keySet().size() > 0
+            || searchingDEKeys.keySet().size() > 0 )
         {
-            String sql = getBySearchingValues( true, programStage, searchingKeys, orgunitIds, startDate, endDate, true,
-                true );
+            String sql = getTabularReportStatement( false, programStage, searchingIdenKeys, searchingAttrKeys,
+                searchingDEKeys, orgunitIds, startDate, endDate, true, true );
             List<Integer> countRow = executeSQL( sql );
+
             return (countRow != null && countRow.size() > 0) ? countRow.get( 0 ) : 0;
         }
 
@@ -299,35 +302,132 @@
         return rs != null ? rs.intValue() : 0;
     }
 
-    private String getBySearchingValues( boolean isCount, ProgramStage programStage,
-        Map<Integer, String> searchingKeys, Collection<Integer> orgunitIds, Date startDate, Date endDate,
+    private String getTabularReportStatement( boolean isCount, ProgramStage programStage,
+        Map<Integer, String> searchingIdenKeys, Map<Integer, String> searchingAttrKeys,
+        Map<Integer, String> searchingDEKeys, Collection<Integer> orgunitIds, Date startDate, Date endDate,
         boolean orderByOrgunitAsc, boolean orderByExecutionDateByAsc )
     {
-        String sql = " select distinct psi.programstageinstanceid from patientdatavalue pdv "
+        String select = "SELECT distinct psi.programstageinstanceid, psi.organisationunitid , psi.executiondate ";
+        String sqlID = " select distinct psi.programstageinstanceid from patientdatavalue pdv "
+            + "inner join programstageinstance psi on pdv.programstageinstanceid=psi.programstageinstanceid "
+            + "INNER JOIN patientidentifier as pid ON pid.patientid = p.patientid "
+            + "INNER JOIN patientidentifiertype as pit ON pid.patientidentifiertypeid = pit.patientidentifiertypeid ";
+        String sqlATTR = " select distinct psi.programstageinstanceid from patientdatavalue pdv "
             + "inner join programstageinstance psi on pdv.programstageinstanceid=psi.programstageinstanceid ";
-
-        String select = "select distinct psi.programstageinstanceid, psi.organisationunitid, psi.executiondate ";
-
-        String condition = " from patientdatavalue pdv "
+        String sqlDE = " select distinct psi.programstageinstanceid from patientdatavalue pdv "
             + "inner join programstageinstance psi on pdv.programstageinstanceid=psi.programstageinstanceid "
-            + "WHERE psi.executiondate >= '" + DateUtils.getMediumDateString( startDate )
+            + "INNER JOIN patientattributevalue as pav ON pav.patientid = p.patientid "
+            + "INNER JOIN patientattribute as pa ON pa.patientattributeid = pav.patientattributeid ";
+        String condition = "FROM patientdatavalue pdv "
+            + "INNER JOIN programstageinstance psi ON pdv.programstageinstanceid=psi.programstageinstanceid "
+            + "INNER JOIN programinstance pi ON pi.programinstanceid=psi.programinstanceid ";
+
+        if ( !programStage.getProgram().getAnonymous() )
+        {
+            condition += " INNER JOIN patient p ON p.patientid = pi.patientid ";
+            if ( searchingAttrKeys != null )
+            {
+                condition += "INNER JOIN patientattributevalue as pav ON pav.patientid = p.patientid "
+                    + "INNER JOIN patientattribute as pa ON pa.patientattributeid = pav.patientattributeid ";
+            }
+            if ( searchingIdenKeys != null )
+            {
+                condition += "INNER JOIN patientidentifier as pid ON pid.patientid = p.patientid "
+                    + "INNER JOIN patientidentifiertype as pit ON pid.patientidentifiertypeid = pit.patientidentifiertypeid ";
+            }
+        }
+
+        condition  += "WHERE psi.executiondate >= '" + DateUtils.getMediumDateString( startDate )
             + "' AND psi.executiondate <= '" + DateUtils.getMediumDateString( endDate ) + "' "
             + " AND psi.organisationunitid in " + splitListHelper( orgunitIds ) + " ";
 
-        Iterator<Integer> keys = searchingKeys.keySet().iterator();
+        // ---------------------------------------------------------------------
+        // Searching program-stage-instances by patient-identifiers
+        // ---------------------------------------------------------------------
+
+        Iterator<Integer> idenKeys = searchingIdenKeys.keySet().iterator();
         boolean index = false;
-        while ( keys.hasNext() )
-        {
-            Integer dataElementId = keys.next();
-
-            if ( index )
-            {
-                condition += " AND psi.programstageinstanceid in ( " + sql + " WHERE 1=1 ";
-            }
+        while ( idenKeys.hasNext() )
+        {            
+            Integer attributeId = idenKeys.next();
+
+            if ( index )
+            {
+                condition += " AND psi.programstageinstanceid in ( " + sqlID + " WHERE 1=1 ";;
+            }
+
+            condition += " AND pid.patientidentifierTypeid=" + attributeId + " AND lower(pid.identifier) ";
+
+            String compareValue = searchingIdenKeys.get( attributeId ).toLowerCase();
+
+            if ( compareValue.contains( "%" ) )
+            {
+                compareValue = compareValue.replace( "=", "like " );
+            }
+
+            condition += compareValue;
+
+            if ( index )
+            {
+                condition += ") ";
+            }
+
+            index = true;
+        }
+
+        // ---------------------------------------------------------------------
+        // Searching program-stage-instances by patient-attributes
+        // ---------------------------------------------------------------------
+
+        Iterator<Integer> attrKeys = searchingAttrKeys.keySet().iterator();
+        index = false;
+        while ( attrKeys.hasNext() )
+        {
+            Integer attributeId = attrKeys.next();
+
+            if ( index )
+            {
+                condition += " AND psi.programstageinstanceid in ( " + sqlATTR + " WHERE 1=1 ";
+            }
+
+            condition += " AND pav.patientattributeid=" + attributeId + " AND lower(pav.value) ";
+
+            String compareValue = searchingAttrKeys.get( attributeId ).toLowerCase();
+
+            if ( compareValue.contains( "%" ) )
+            {
+                compareValue = compareValue.replace( "=", "like " );
+            }
+
+            condition += compareValue;
+
+            if ( index )
+            {
+                condition += ") ";
+            }
+
+            index = true;
+        }
+
+        // ---------------------------------------------------------------------
+        // Searching program-stage-instances by dataelements
+        // ---------------------------------------------------------------------
+
+        Iterator<Integer> deKeys = searchingDEKeys.keySet().iterator();
+
+        index = false;
+        while ( deKeys.hasNext() )
+        {
+            Integer dataElementId = deKeys.next();
+
+            //if ( index )
+            //{
+                condition += " AND psi.programstageinstanceid in ( " + sqlDE + " WHERE 1=1 ";
+            //}
 
             condition += " AND pdv.dataElementid=" + dataElementId + " AND lower(pdv.value) ";
 
-            String compareValue = searchingKeys.get( dataElementId ).toLowerCase();
+            String compareValue = searchingDEKeys.get( dataElementId ).toLowerCase();
 
             if ( compareValue.contains( "%" ) )
             {
@@ -336,19 +436,19 @@
 
             condition += compareValue;
 
-            if ( index )
-            {
+            //if ( index )
+            //{
                 condition += ") ";
-            }
+            //}
 
-            index = true;
+            //index = true;
         }
 
         if ( isCount )
         {
             return "select count(psi.programstageinstanceid) " + condition;
         }
-
+        
         condition += " ORDER BY psi.organisationunitid ";
         condition += orderByOrgunitAsc ? "asc" : "desc";
         condition += ", psi.executiondate ";

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml	2012-03-27 01:29:30 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml	2012-04-11 06:25:02 +0000
@@ -207,6 +207,10 @@
 			ref="org.hisp.dhis.patientdatavalue.PatientDataValueService" />
 		<property name="organisationUnitService"
 			ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
+		<property name="identifierService"
+			ref="org.hisp.dhis.patient.PatientIdentifierService" />
+		<property name="patientAttributeValueService"
+			ref="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
 	</bean>
 
 	<bean id="org.hisp.dhis.program.ProgramInstanceService" class="org.hisp.dhis.program.DefaultProgramInstanceService">

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadProgramStagesAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadProgramStagesAction.java	2011-12-16 06:45:30 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadProgramStagesAction.java	2012-04-11 06:25:02 +0000
@@ -131,6 +131,11 @@
     public String execute()
         throws Exception
     {
+        if ( programId == null )
+        {
+            return SUCCESS;
+        }
+
         selectedStateManager.clearSelectedProgramInstance();
         selectedStateManager.clearSelectedProgramStageInstance();
 
@@ -158,7 +163,7 @@
             programInstance = programInstances.iterator().next();
 
             selectedStateManager.setSelectedProgramInstance( programInstance );
-            
+
             if ( programInstance.getProgramStageInstances() != null )
             {
                 colorMap = programStageInstanceService.colorProgramStageInstances( programInstance
@@ -166,7 +171,6 @@
             }
         }
 
-       
         return SUCCESS;
     }
 

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateTabularReportAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateTabularReportAction.java	2012-03-23 03:46:08 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateTabularReportAction.java	2012-04-11 06:25:02 +0000
@@ -35,7 +35,6 @@
 import java.util.Map;
 import java.util.Set;
 
-import org.hisp.dhis.caseentry.state.SelectedStateManager;
 import org.hisp.dhis.common.Grid;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementService;
@@ -44,7 +43,12 @@
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitHierarchy;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
 import org.hisp.dhis.paging.ActionPagingSupport;
+import org.hisp.dhis.patient.PatientAttribute;
+import org.hisp.dhis.patient.PatientAttributeService;
+import org.hisp.dhis.patient.PatientIdentifierType;
+import org.hisp.dhis.patient.PatientIdentifierTypeService;
 import org.hisp.dhis.program.ProgramStage;
 import org.hisp.dhis.program.ProgramStageInstance;
 import org.hisp.dhis.program.ProgramStageInstanceService;
@@ -58,15 +62,21 @@
 public class GenerateTabularReportAction
     extends ActionPagingSupport<ProgramStageInstance>
 {
+    private String PREFIX_IDENTIFIER_TYPE = "iden";
+
+    private String PREFIX_PATIENT_ATTRIBUTE = "attr";
+
+    private String PREFIX_DATA_ELEMENT = "de";
+
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
 
-    private SelectedStateManager selectedStateManager;
+    private OrganisationUnitSelectionManager selectionManager;
 
-    public void setSelectedStateManager( SelectedStateManager selectedStateManager )
+    public void setSelectionManager( OrganisationUnitSelectionManager selectionManager )
     {
-        this.selectedStateManager = selectedStateManager;
+        this.selectionManager = selectionManager;
     }
 
     private OrganisationUnitService organisationUnitService;
@@ -97,10 +107,31 @@
         this.programStageInstanceService = programStageInstanceService;
     }
 
+    private PatientIdentifierTypeService identifierTypeService;
+
+    public void setIdentifierTypeService( PatientIdentifierTypeService identifierTypeService )
+    {
+        this.identifierTypeService = identifierTypeService;
+    }
+
+    private PatientAttributeService patientAttributeService;
+
+    public void setPatientAttributeService( PatientAttributeService patientAttributeService )
+    {
+        this.patientAttributeService = patientAttributeService;
+    }
+
     // -------------------------------------------------------------------------
     // Input/Output
     // -------------------------------------------------------------------------
 
+    private Integer orgunitId;
+
+    public void setOrgunitId( Integer orgunitId )
+    {
+        this.orgunitId = orgunitId;
+    }
+
     private Integer programStageId;
 
     public void setProgramStageId( Integer programStageId )
@@ -108,13 +139,6 @@
         this.programStageId = programStageId;
     }
 
-    private List<Integer> dataElementIds = new ArrayList<Integer>();
-
-    public void setDataElementIds( List<Integer> dataElementIds )
-    {
-        this.dataElementIds = dataElementIds;
-    }
-
     private String startDate;
 
     public void setStartDate( String startDate )
@@ -129,13 +153,18 @@
         this.endDate = endDate;
     }
 
-    private Set<String> searchingValues = new HashSet<String>();
+    private List<String> searchingValues = new ArrayList<String>();
 
-    public void setSearchingValues( Set<String> searchingValues )
+    public void setSearchingValues( List<String> searchingValues )
     {
         this.searchingValues = searchingValues;
     }
 
+    public List<String> getSearchingValues()
+    {
+        return searchingValues;
+    }
+
     private boolean orderByOrgunitAsc;
 
     public void setOrderByOrgunitAsc( boolean orderByOrgunitAsc )
@@ -185,7 +214,21 @@
         this.format = format;
     }
 
-    private List<DataElement> dataElements;
+    private List<PatientIdentifierType> identifierTypes = new ArrayList<PatientIdentifierType>();
+
+    public List<PatientIdentifierType> getIdentifierTypes()
+    {
+        return identifierTypes;
+    }
+
+    private List<PatientAttribute> patientAttributes = new ArrayList<PatientAttribute>();
+
+    public List<PatientAttribute> getPatientAttributes()
+    {
+        return patientAttributes;
+    }
+
+    private List<DataElement> dataElements = new ArrayList<DataElement>();
 
     public List<DataElement> getDataElements()
     {
@@ -206,6 +249,12 @@
         this.facilityLB = facilityLB;
     }
 
+    private Map<Integer, String> searchingIdenKeys = new HashMap<Integer, String>();
+
+    private Map<Integer, String> searchingAttrKeys = new HashMap<Integer, String>();
+
+    private Map<Integer, String> searchingDEKeys = new HashMap<Integer, String>();
+
     // -------------------------------------------------------------------------
     // Implementation Action
     // -------------------------------------------------------------------------
@@ -217,13 +266,16 @@
         // Get orgunitIds
         // ---------------------------------------------------------------------
 
-        OrganisationUnit selectedOrgunit = selectedStateManager.getSelectedOrganisationUnit();
+        OrganisationUnit selectedOrgunit = selectionManager.getSelectedOrganisationUnit();
+        
+        // OrganisationUnit selectedOrgunit =
+        // organisationUnitService.getOrganisationUnit( orgunitId );
 
         Set<Integer> orgunitIds = new HashSet<Integer>();
 
         if ( facilityLB.equals( "selected" ) )
         {
-            orgunitIds.add( selectedOrgunit.getId() );
+            orgunitIds.add( orgunitId );
         }
         else
         {
@@ -249,29 +301,11 @@
 
         Date endValue = format.parseDate( endDate );
 
-        dataElements = new ArrayList<DataElement>();
-
-        // ---------------------------------------------------------------------
-        // Get selected dataelements
-        // ---------------------------------------------------------------------
-
-        for ( Integer dataElementId : dataElementIds )
-        {
-            dataElements.add( dataElementService.getDataElement( dataElementId ) );
-        }
-
-        // ---------------------------------------------------------------------
-        // Get searching-keys
-        // ---------------------------------------------------------------------
-
-        Map<Integer, String> searchingKeys = new HashMap<Integer, String>();
-
-        for ( String searchingValue : searchingValues )
-        {
-            String[] infor = searchingValue.split( "_" );
-
-            searchingKeys.put( Integer.parseInt( infor[0] ), infor[1] );
-        }
+        // ---------------------------------------------------------------------
+        // Get DE searching-keys
+        // ---------------------------------------------------------------------
+
+        getParams();
 
         // ---------------------------------------------------------------------
         // Generate tabular report
@@ -279,20 +313,66 @@
 
         if ( type == null )
         {
-            total = programStageInstanceService.countProgramStageInstances( programStage, searchingKeys, orgunitIds,
-                startValue, endValue );
+            total = programStageInstanceService.countProgramStageInstances( programStage, searchingIdenKeys,
+                searchingAttrKeys, searchingDEKeys, orgunitIds, startValue, endValue );
 
             this.paging = createPaging( total );
 
-            grid = programStageInstanceService.getTabularReport( programStage, dataElements, searchingKeys, orgunitIds,
-                level, startValue, endValue, orderByOrgunitAsc, orderByExecutionDateByAsc, paging
-                    .getStartPos(), paging.getPageSize(), format, i18n );
+            grid = programStageInstanceService.getTabularReport( programStage, identifierTypes, patientAttributes,
+                dataElements, searchingIdenKeys, searchingAttrKeys, searchingDEKeys, orgunitIds, level, startValue,
+                endValue, orderByOrgunitAsc, orderByExecutionDateByAsc, paging.getStartPos(), paging.getPageSize(),
+                format, i18n );
+
             return SUCCESS;
         }
 
-        grid = programStageInstanceService.getTabularReport( programStage, dataElements, searchingKeys, orgunitIds,
-            level, startValue, endValue, orderByOrgunitAsc, orderByExecutionDateByAsc, format, i18n );
+        grid = programStageInstanceService.getTabularReport( programStage, identifierTypes, patientAttributes,
+            dataElements, searchingIdenKeys, searchingAttrKeys, searchingDEKeys, orgunitIds, level, startValue,
+            endValue, orderByOrgunitAsc, orderByExecutionDateByAsc, format, i18n );
 
         return type;
     }
+
+    // ---------------------------------------------------------------------
+    // Supportive methods
+    // ---------------------------------------------------------------------
+
+    private void getParams()
+    {
+        // ---------------------------------------------------------------------
+        // Get Patient-Identifier searching-keys
+        // ---------------------------------------------------------------------
+
+        for ( String searchingValue : searchingValues )
+        {
+            String[] infor = searchingValue.split( "_" );
+            String objectType = infor[0];
+            int objectId = Integer.parseInt( infor[1] );
+
+            if ( objectType.equals( PREFIX_IDENTIFIER_TYPE ) )
+            {
+                identifierTypes.add( identifierTypeService.getPatientIdentifierType( objectId ) );
+                if ( infor.length == 3 )
+                {
+                    searchingIdenKeys.put( objectId, infor[2].trim() );
+                }
+            }
+            else if ( objectType.equals( PREFIX_PATIENT_ATTRIBUTE ) )
+            {
+                patientAttributes.add( patientAttributeService.getPatientAttribute( objectId ) );
+                if ( infor.length == 3 )
+                {
+                    searchingAttrKeys.put( objectId, infor[2].trim() );
+                }
+            }
+            else if ( objectType.equals( PREFIX_DATA_ELEMENT ) )
+            {
+                dataElements.add( dataElementService.getDataElement( objectId ) );
+                if ( infor.length == 3 )
+                {
+                    searchingDEKeys.put( objectId, infor[2].trim() );
+                }
+            }
+        }
+    }
 }

=== added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GetOrganisationUnitChildrenAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GetOrganisationUnitChildrenAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GetOrganisationUnitChildrenAction.java	2012-04-11 06:25:02 +0000
@@ -0,0 +1,105 @@
+package org.hisp.dhis.caseentry.action.report;
+
+/*
+ * Copyright (c) 2004-2012, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Jan Henrik Overland
+ */
+public class GetOrganisationUnitChildrenAction
+    implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private OrganisationUnitService organisationUnitService;
+
+    public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+    {
+        this.organisationUnitService = organisationUnitService;
+    }
+
+    // -------------------------------------------------------------------------
+    // Input
+    // -------------------------------------------------------------------------
+
+    private Integer node;
+    
+    public void setNode( Integer node )
+    {
+        this.node = node;
+    }
+
+    // -------------------------------------------------------------------------
+    // Output
+    // -------------------------------------------------------------------------
+
+    private List<OrganisationUnit> units = new ArrayList<OrganisationUnit>();
+    
+    public List<OrganisationUnit> getUnits()
+    {
+        return units;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    @Override
+    public String execute()
+        throws Exception
+    {
+        OrganisationUnit unit = organisationUnitService.getOrganisationUnit( node );
+        
+        int level = organisationUnitService.getLevelOfOrganisationUnit( unit.getId() ) + 1;
+        
+        if ( unit != null )
+        {
+            units = new ArrayList<OrganisationUnit>( unit.getChildren() );
+            
+            for ( OrganisationUnit organisationUnit : units )
+            {
+                organisationUnit.setLevel( level );
+            }
+
+            Collections.sort( units, new IdentifiableObjectNameComparator() );
+        }
+        
+        return SUCCESS;
+    }
+}

=== added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GetTabularParamsAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GetTabularParamsAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GetTabularParamsAction.java	2012-04-11 06:25:02 +0000
@@ -0,0 +1,134 @@
+/*
+ * Copyright (c) 2004-2012, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.hisp.dhis.caseentry.action.report;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.hisp.dhis.patient.PatientAttribute;
+import org.hisp.dhis.patient.PatientAttributeService;
+import org.hisp.dhis.patient.PatientIdentifierType;
+import org.hisp.dhis.patient.PatientIdentifierTypeService;
+import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramService;
+import org.hisp.dhis.program.ProgramStage;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ * 
+ * @version $GetTabularParamsAction.java Apr 3, 2012 8:42:24 AM$
+ */
+public class GetTabularParamsAction
+    implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private PatientIdentifierTypeService identifierTypeService;
+
+    private PatientAttributeService attributeService;
+
+    private ProgramService programService;
+
+    // -------------------------------------------------------------------------
+    // Input/Output
+    // -------------------------------------------------------------------------
+
+    private Integer programId;
+
+    private Collection<PatientIdentifierType> identifierTypes = new HashSet<PatientIdentifierType>();
+
+    private Collection<PatientAttribute> attributes = new HashSet<PatientAttribute>();
+
+    private Set<ProgramStage> programStages = new HashSet<ProgramStage>();
+
+    // -------------------------------------------------------------------------
+    // Getter && Setters
+    // -------------------------------------------------------------------------
+
+    public Collection<PatientIdentifierType> getIdentifierTypes()
+    {
+        return identifierTypes;
+    }
+
+    public Collection<PatientAttribute> getAttributes()
+    {
+        return attributes;
+    }
+
+    public void setIdentifierTypeService( PatientIdentifierTypeService identifierTypeService )
+    {
+        this.identifierTypeService = identifierTypeService;
+    }
+
+    public void setAttributeService( PatientAttributeService attributeService )
+    {
+        this.attributeService = attributeService;
+    }
+
+    public void setProgramService( ProgramService programService )
+    {
+        this.programService = programService;
+    }
+
+    public void setProgramId( Integer programId )
+    {
+        this.programId = programId;
+    }
+
+    public Set<ProgramStage> getProgramStages()
+    {
+        return programStages;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    @Override
+    public String execute()
+        throws Exception
+    {
+        Program program = programService.getProgram( programId );
+
+        programStages = program.getProgramStages();
+
+        identifierTypes = identifierTypeService.getPatientIdentifierTypesWithoutProgram();
+        identifierTypes.addAll( identifierTypeService.getPatientIdentifierTypes( program ) );
+
+        attributes = attributeService.getPatientAttributes( null, null );
+        attributes.addAll( attributeService.getPatientAttributes( program ) );
+
+        return SUCCESS;
+    }
+
+}

=== added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/LoadAttributeGroupsAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/LoadAttributeGroupsAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/LoadAttributeGroupsAction.java	2012-04-11 06:25:02 +0000
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2004-2012, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.hisp.dhis.caseentry.action.report;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import org.hisp.dhis.patient.PatientAttributeGroup;
+import org.hisp.dhis.patient.PatientAttributeGroupService;
+import org.hisp.dhis.patient.comparator.PatientAttributeGroupSortOrderComparator;
+import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ * 
+ * @version $LoadAttributeGroupsAction.java Apr 3, 2012 8:42:24 AM$
+ */
+public class LoadAttributeGroupsAction
+    implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private ProgramService programService;
+
+    private PatientAttributeGroupService attributeGroupService;
+
+    // -------------------------------------------------------------------------
+    // Input/Output
+    // -------------------------------------------------------------------------
+
+    private Integer programId;
+
+    private List<PatientAttributeGroup> attributeGroups = new ArrayList<PatientAttributeGroup>();
+
+    // -------------------------------------------------------------------------
+    // Getter && Setters
+    // -------------------------------------------------------------------------
+
+    public Collection<PatientAttributeGroup> getAttributeGroups()
+    {
+        return attributeGroups;
+    }
+
+    public void setAttributeGroupService( PatientAttributeGroupService attributeGroupService )
+    {
+        this.attributeGroupService = attributeGroupService;
+    }
+
+    public void setProgramService( ProgramService programService )
+    {
+        this.programService = programService;
+    }
+
+    public void setProgramId( Integer programId )
+    {
+        this.programId = programId;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    @Override
+    public String execute()
+        throws Exception
+    {
+        Program program = programService.getProgram( programId );
+
+        attributeGroups = new ArrayList<PatientAttributeGroup>( attributeGroupService
+            .getPatientAttributeGroups( program ) );
+        Collections.sort( attributeGroups, new PatientAttributeGroupSortOrderComparator() );
+
+        return SUCCESS;
+    }
+
+}

=== added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/LoadAttributesAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/LoadAttributesAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/LoadAttributesAction.java	2012-04-11 06:25:02 +0000
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2004-2012, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.hisp.dhis.caseentry.action.report;
+
+import java.util.Collection;
+import java.util.HashSet;
+
+import org.hisp.dhis.patient.PatientAttribute;
+import org.hisp.dhis.patient.PatientAttributeGroupService;
+import org.hisp.dhis.patient.PatientAttributeService;
+import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ * 
+ * @version $LoadAttributesAction.java Apr 3, 2012 8:42:24 AM$
+ */
+public class LoadAttributesAction
+    implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private ProgramService programService;
+
+    private PatientAttributeGroupService attributeGroupService;
+
+    private PatientAttributeService attributeService;
+
+    // -------------------------------------------------------------------------
+    // Input/Output
+    // -------------------------------------------------------------------------
+
+    private Integer programId;
+
+    private Integer attributeGroupId;
+
+    private Collection<PatientAttribute> patientAttributes = new HashSet<PatientAttribute>();
+
+    // -------------------------------------------------------------------------
+    // Getter && Setters
+    // -------------------------------------------------------------------------
+
+    public void setAttributeGroupService( PatientAttributeGroupService attributeGroupService )
+    {
+        this.attributeGroupService = attributeGroupService;
+    }
+
+    public Collection<PatientAttribute> getPatientAttributes()
+    {
+        return patientAttributes;
+    }
+
+    public void setAttributeGroupId( Integer attributeGroupId )
+    {
+        this.attributeGroupId = attributeGroupId;
+    }
+
+    public void setAttributeService( PatientAttributeService attributeService )
+    {
+        this.attributeService = attributeService;
+    }
+
+    public void setProgramService( ProgramService programService )
+    {
+        this.programService = programService;
+    }
+
+    public void setProgramId( Integer programId )
+    {
+        this.programId = programId;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    @Override
+    public String execute()
+        throws Exception
+    {
+        Program program = programService.getProgram( programId );
+        patientAttributes = attributeService.getPatientAttributes( program );
+
+        if ( attributeGroupId == null )
+        {
+            patientAttributes.addAll( attributeService.getPatientAttributes( null, null ) );
+        }
+        else
+        {
+            patientAttributes.retainAll( attributeGroupService.getPatientAttributeGroup( attributeGroupId )
+                .getAttributes() );
+        }
+
+        return SUCCESS;
+
+    }
+
+}

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/LoadDataElementsAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/LoadDataElementsAction.java	2012-03-05 04:22:57 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/LoadDataElementsAction.java	2012-04-11 06:25:02 +0000
@@ -79,8 +79,11 @@
     public String execute()
         throws Exception
     {
-        psDataElements = programStageService.getProgramStage( programStageId ).getProgramStageDataElements();
-
+        if ( programStageId != null )
+        {
+            psDataElements = programStageService.getProgramStage( programStageId ).getProgramStageDataElements();
+        }
+        
         return SUCCESS;
     }
 }

=== added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/LoadIdentifierTypesAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/LoadIdentifierTypesAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/LoadIdentifierTypesAction.java	2012-04-11 06:25:02 +0000
@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2004-2012, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.hisp.dhis.caseentry.action.report;
+
+import java.util.Collection;
+import java.util.HashSet;
+
+import org.hisp.dhis.patient.PatientIdentifierType;
+import org.hisp.dhis.patient.PatientIdentifierTypeService;
+import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ * 
+ * @version $LoadIdentifierTypesAction.java Apr 5, 2012 7:27:52 PM$
+ */
+public class LoadIdentifierTypesAction
+    implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private PatientIdentifierTypeService identifierTypeService;
+
+    private ProgramService programService;
+
+    // -------------------------------------------------------------------------
+    // Input/Output
+    // -------------------------------------------------------------------------
+
+    private Integer programId;
+
+    private Collection<PatientIdentifierType> identifierTypes = new HashSet<PatientIdentifierType>();
+
+    // -------------------------------------------------------------------------
+    // Getter && Setters
+    // -------------------------------------------------------------------------
+
+    public void setProgramService( ProgramService programService )
+    {
+        this.programService = programService;
+    }
+
+    public void setIdentifierTypeService( PatientIdentifierTypeService identifierTypeService )
+    {
+        this.identifierTypeService = identifierTypeService;
+    }
+
+    public Collection<PatientIdentifierType> getIdentifierTypes()
+    {
+        return identifierTypes;
+    }
+
+    public void setProgramId( Integer programId )
+    {
+        this.programId = programId;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    @Override
+    public String execute()
+        throws Exception
+    {
+        Program program = programService.getProgram( programId );
+
+        identifierTypes = identifierTypeService.getPatientIdentifierTypesWithoutProgram();
+        identifierTypes.addAll( identifierTypeService.getPatientIdentifierTypes( program ) );
+
+        return SUCCESS;
+    }
+
+}

=== added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/LoadProgramsAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/LoadProgramsAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/LoadProgramsAction.java	2012-04-11 06:25:02 +0000
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2004-2012, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.hisp.dhis.caseentry.action.report;
+
+import java.util.Collection;
+
+import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ * 
+ * @version $LoadProgramsAction.java Feb 28, 2012 9:35:50 AM$
+ */
+public class LoadProgramsAction
+    implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private ProgramService programService;
+
+    public void setProgramService( ProgramService programService )
+    {
+        this.programService = programService;
+    }
+
+    // -------------------------------------------------------------------------
+    // Input/output
+    // -------------------------------------------------------------------------
+
+    private Collection<Program> programs;
+
+    public Collection<Program> getPrograms()
+    {
+        return programs;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    @Override
+    public String execute()
+        throws Exception
+    {
+        programs = programService.getAllPrograms();
+
+        return SUCCESS;
+    }
+}

=== added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/TabularInitializeAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/TabularInitializeAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/TabularInitializeAction.java	2012-04-11 06:25:02 +0000
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2004-2012, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright notice, this
+ *   list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * * Neither the name of the HISP project nor the names of its contributors may
+ *   be used to endorse or promote products derived from this software without
+ *   specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.hisp.dhis.caseentry.action.report;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.program.Program;
+import org.hisp.dhis.program.ProgramService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ * 
+ * @version $TabularInitializeAction.java Apr 5, 2012 9:44:37 AM$
+ */
+public class TabularInitializeAction
+    implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private OrganisationUnitService organisationUnitService;
+
+    public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+    {
+        this.organisationUnitService = organisationUnitService;
+    }
+
+    private ProgramService programService;
+
+    public void setProgramService( ProgramService programService )
+    {
+        this.programService = programService;
+    }
+
+    // -------------------------------------------------------------------------
+    // Output
+    // -------------------------------------------------------------------------
+
+    private OrganisationUnit rootNode;
+
+    public OrganisationUnit getRootNode()
+    {
+        return rootNode;
+    }
+
+    private Collection<Program> programs;
+
+    public Collection<Program> getPrograms()
+    {
+        return programs;
+    }
+
+    private List<OrganisationUnitLevel> levels;
+
+    public List<OrganisationUnitLevel> getLevels()
+    {
+        return levels;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    public String execute()
+        throws Exception
+    {
+        Collection<OrganisationUnit> rootUnits = new ArrayList<OrganisationUnit>( organisationUnitService
+            .getOrganisationUnitsAtLevel( 1 ) );
+
+        programs = programService.getAllPrograms();
+
+        rootNode = rootUnits.size() > 0 ? rootUnits.iterator().next() : new OrganisationUnit();
+
+        levels = organisationUnitService.getFilledOrganisationUnitLevels();
+        
+        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	2012-03-29 04:15:07 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml	2012-04-11 06:25:02 +0000
@@ -25,8 +25,7 @@
 			ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
 		<property name="patientAttributeService"
 			ref="org.hisp.dhis.patient.PatientAttributeService" />
-		<property name="programService"
-			ref="org.hisp.dhis.program.ProgramService" />
+		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
 	</bean>
 
 	<bean id="org.hisp.dhis.caseentry.action.caseentry.ValidateSearchAction"
@@ -129,8 +128,9 @@
 			ref="org.hisp.dhis.program.ProgramStageInstanceService" />
 		<property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
 	</bean>
-	
-	<bean id="org.hisp.dhis.caseentry.action.caseentry.RegisterIrregularEncounterAction"
+
+	<bean
+		id="org.hisp.dhis.caseentry.action.caseentry.RegisterIrregularEncounterAction"
 		class="org.hisp.dhis.caseentry.action.caseentry.RegisterIrregularEncounterAction"
 		scope="prototype">
 		<property name="programStageInstanceService"
@@ -225,8 +225,7 @@
 		scope="prototype">
 		<property name="selectionManager"
 			ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
-		<property name="programService"
-			ref="org.hisp.dhis.program.ProgramService" />
+		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
 	</bean>
 
 	<bean id="org.hisp.dhis.caseentry.action.report.GenerateReportAction"
@@ -249,7 +248,7 @@
 		<property name="dataElementCategoryService"
 			ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
 	</bean>
-	
+
 	<bean id="org.hisp.dhis.caseentry.action.report.TabularReportSelectAction"
 		class="org.hisp.dhis.caseentry.action.report.TabularReportSelectAction"
 		scope="prototype">
@@ -257,41 +256,104 @@
 			ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
 		<property name="organisationUnitService"
 			ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
-		<property name="programService"
-			ref="org.hisp.dhis.program.ProgramService" />
+		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
+	</bean>
+
+	<bean id="org.hisp.dhis.caseentry.action.report.TabularInitializeAction"
+		class="org.hisp.dhis.caseentry.action.report.TabularInitializeAction"
+		scope="prototype">
+		<property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
+		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
+	</bean>
+	
+	<bean id="org.hisp.dhis.caseentry.action.report.GetOrganisationUnitChildrenAction"
+		class="org.hisp.dhis.visualizer.action.GetOrganisationUnitChildrenAction"
+		scope="prototype">
+		<property name="organisationUnitService"
+			ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
+	</bean>
+	
+	<bean id="org.hisp.dhis.caseentry.action.report.LoadProgramsAction"
+		class="org.hisp.dhis.caseentry.action.report.LoadProgramsAction"
+		scope="prototype">
+		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
+	</bean>
+
+	<bean id="org.hisp.dhis.caseentry.action.report.LoadIdentifierTypesAction"
+		class="org.hisp.dhis.caseentry.action.report.LoadIdentifierTypesAction"
+		scope="prototype">
+		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
+		<property name="identifierTypeService"
+			ref="org.hisp.dhis.patient.PatientIdentifierTypeService" />
+	</bean>
+	
+	<bean
+		id="org.hisp.dhis.caseentry.action.report.LoadAttributeGroupsAction"
+		class="org.hisp.dhis.caseentry.action.report.LoadAttributeGroupsAction"
+		scope="prototype">
+		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
+		<property name="attributeGroupService"
+			ref="org.hisp.dhis.patient.PatientAttributeGroupService" />
 	</bean>
 	
 	<bean id="org.hisp.dhis.caseentry.action.report.LoadProgramStagesAction"
 		class="org.hisp.dhis.caseentry.action.report.LoadProgramStagesAction"
 		scope="prototype">
-		<property name="programService"
-			ref="org.hisp.dhis.program.ProgramService" />
+		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
+	</bean>
+
+	<bean
+		id="org.hisp.dhis.caseentry.action.report.LoadAttributesAction"
+		class="org.hisp.dhis.caseentry.action.report.LoadAttributesAction"
+		scope="prototype">
+		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
+		<property name="attributeGroupService"
+			ref="org.hisp.dhis.patient.PatientAttributeGroupService" />
+		<property name="attributeService"
+			ref="org.hisp.dhis.patient.PatientAttributeService" />
 	</bean>
 	
 	<bean id="org.hisp.dhis.caseentry.action.report.LoadDataElementsAction"
-    	class="org.hisp.dhis.caseentry.action.report.LoadDataElementsAction" scope="prototype">
-    	<property name="programStageService"
-        	ref="org.hisp.dhis.program.ProgramStageService" />
-	</bean>
-	
-	<bean id="org.hisp.dhis.caseentry.action.report.ValidateTabularReportAction"
-    	class="org.hisp.dhis.caseentry.action.report.ValidateTabularReportAction" scope="prototype">
-        <property name="selectedStateManager"
-        	ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
-	</bean>
-	
-	<bean id="org.hisp.dhis.caseentry.action.report.GenerateTabularReportAction"
-    	class="org.hisp.dhis.caseentry.action.report.GenerateTabularReportAction" scope="prototype">
-    	<property name="programStageService"
-        	ref="org.hisp.dhis.program.ProgramStageService" />
-        <property name="dataElementService"
-        	ref="org.hisp.dhis.dataelement.DataElementService" />
-        <property name="programStageInstanceService"
-        	ref="org.hisp.dhis.program.ProgramStageInstanceService" />
-        <property name="selectedStateManager"
-        	ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
-         <property name="organisationUnitService"
-        	ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
+		class="org.hisp.dhis.caseentry.action.report.LoadDataElementsAction"
+		scope="prototype">
+		<property name="programStageService" ref="org.hisp.dhis.program.ProgramStageService" />
+	</bean>
+	
+	<bean
+		id="org.hisp.dhis.caseentry.action.report.GetTabularParamsAction"
+		class="org.hisp.dhis.caseentry.action.report.GetTabularParamsAction"
+		scope="prototype">
+		<property name="identifierTypeService"
+			ref="org.hisp.dhis.patient.PatientIdentifierTypeService" />
+		<property name="attributeService"
+			ref="org.hisp.dhis.patient.PatientAttributeService" />
+		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
+	</bean>
+
+	<bean
+		id="org.hisp.dhis.caseentry.action.report.GenerateTabularReportAction"
+		class="org.hisp.dhis.caseentry.action.report.GenerateTabularReportAction"
+		scope="prototype">
+		<property name="selectionManager"
+			ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
+		<property name="programStageService" ref="org.hisp.dhis.program.ProgramStageService" />
+		<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
+		<property name="programStageInstanceService"
+			ref="org.hisp.dhis.program.ProgramStageInstanceService" />
+		<property name="organisationUnitService"
+			ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
+		<property name="identifierTypeService"
+			ref="org.hisp.dhis.patient.PatientIdentifierTypeService" />
+		<property name="patientAttributeService"
+			ref="org.hisp.dhis.patient.PatientAttributeService" />
+	</bean>
+	
+	<bean
+		id="org.hisp.dhis.caseentry.action.report.ValidateTabularReportAction"
+		class="org.hisp.dhis.caseentry.action.report.ValidateTabularReportAction"
+		scope="prototype">
+		<property name="selectedStateManager"
+			ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
 	</bean>
 
 	<!-- Case Aggregation -->
@@ -335,7 +397,7 @@
 		<property name="periodGenericManager"
 			ref="org.hisp.dhis.caseentry.state.PeriodGenericManager" />
 	</bean>
-	
+
 	<bean
 		id="org.hisp.dhis.caseentry.action.caseaggregation.SaveAggregateDataValueAction"
 		class="org.hisp.dhis.caseentry.action.caseaggregation.SaveAggregateDataValueAction"
@@ -345,11 +407,10 @@
 		<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
 		<property name="categoryService"
 			ref="org.hisp.dhis.dataelement.DataElementCategoryService" />
-		<property name="periodService"
-			ref="org.hisp.dhis.period.PeriodService" />
+		<property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
 		<property name="dataValueService" ref="org.hisp.dhis.datavalue.DataValueService" />
 		<property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
-		
+
 	</bean>
 
 	<bean
@@ -398,33 +459,36 @@
 		<property name="aggregationConditionService"
 			ref="org.hisp.dhis.caseaggregation.CaseAggregationConditionService" />
 	</bean>
-	
-	<bean id="org.hisp.dhis.caseentry.action.caseentry.LoadAnonymousProgramsAction"
-		class="org.hisp.dhis.caseentry.action.caseentry.LoadAnonymousProgramsAction" scope="prototype">
+
+	<bean
+		id="org.hisp.dhis.caseentry.action.caseentry.LoadAnonymousProgramsAction"
+		class="org.hisp.dhis.caseentry.action.caseentry.LoadAnonymousProgramsAction"
+		scope="prototype">
 		<property name="selectionManager"
 			ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
-		<property name="programService"
-			ref="org.hisp.dhis.program.ProgramService" />
-		<property name="programInstanceService"
-			ref="org.hisp.dhis.program.ProgramInstanceService" />
+		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
+		<property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
 	</bean>
-	
-	<bean id="org.hisp.dhis.caseentry.action.caseentry.RemoveCurrentEncounterAction"
-		class="org.hisp.dhis.caseentry.action.caseentry.RemoveCurrentEncounterAction" scope="prototype">
+
+	<bean
+		id="org.hisp.dhis.caseentry.action.caseentry.RemoveCurrentEncounterAction"
+		class="org.hisp.dhis.caseentry.action.caseentry.RemoveCurrentEncounterAction"
+		scope="prototype">
 		<property name="programStageInstanceService"
 			ref="org.hisp.dhis.program.ProgramStageInstanceService" />
 	</bean>
-	
-	<bean id="org.hisp.dhis.caseentry.action.caseentry.CreateAnonymousEncounterAction"
-		class="org.hisp.dhis.caseentry.action.caseentry.CreateAnonymousEncounterAction" scope="prototype">
+
+	<bean
+		id="org.hisp.dhis.caseentry.action.caseentry.CreateAnonymousEncounterAction"
+		class="org.hisp.dhis.caseentry.action.caseentry.CreateAnonymousEncounterAction"
+		scope="prototype">
 		<property name="selectedStateManager"
 			ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
-		<property name="programInstanceService"
-			ref="org.hisp.dhis.program.ProgramInstanceService" />
+		<property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
 		<property name="programStageInstanceService"
 			ref="org.hisp.dhis.program.ProgramStageInstanceService" />
 	</bean>
- 
+
 	<!-- Patient -->
 
 	<bean id="org.hisp.dhis.caseentry.action.patient.SearchPersonAction"
@@ -480,7 +544,7 @@
 			<ref bean="org.hisp.dhis.patient.PatientIdentifierTypeService" />
 		</property>
 	</bean>
-	
+
 	<bean id="org.hisp.dhis.caseentry.action.patient.AddPatientAction"
 		class="org.hisp.dhis.caseentry.action.patient.AddPatientAction" scope="prototype">
 		<property name="selectionManager"
@@ -592,7 +656,7 @@
 		<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
 		<property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
 	</bean>
-	
+
 	<bean id="org.hisp.dhis.caseentry.action.patient.GetPatientLocationAction"
 		class="org.hisp.dhis.caseentry.action.patient.GetPatientLocationAction"
 		scope="prototype">
@@ -600,20 +664,22 @@
 		<property name="selectionTreeManager"
 			ref="org.hisp.dhis.oust.manager.SelectionTreeManager" />
 	</bean>
-	
-	<bean id="org.hisp.dhis.caseentry.action.patient.VerifyOrgunitRegistrationAction"
+
+	<bean
+		id="org.hisp.dhis.caseentry.action.patient.VerifyOrgunitRegistrationAction"
 		class="org.hisp.dhis.caseentry.action.patient.VerifyOrgunitRegistrationAction"
 		scope="prototype">
 		<property name="selectionTreeManager"
 			ref="org.hisp.dhis.oust.manager.SelectionTreeManager" />
 	</bean>
-	
-	<bean id="org.hisp.dhis.caseentry.action.patient.RegisterPatientLocationAction"
+
+	<bean
+		id="org.hisp.dhis.caseentry.action.patient.RegisterPatientLocationAction"
 		class="org.hisp.dhis.caseentry.action.patient.RegisterPatientLocationAction"
 		scope="prototype">
 		<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
 		<property name="selectionTreeManager"
-			ref="org.hisp.dhis.oust.manager.SelectionTreeManager" />	
+			ref="org.hisp.dhis.oust.manager.SelectionTreeManager" />
 	</bean>
 
 	<!-- Patient-Program Enrollment -->
@@ -625,7 +691,8 @@
 		<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
 		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
 		<property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
-		<property name="selectedStateManager" ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
+		<property name="selectedStateManager"
+			ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
 	</bean>
 
 	<bean id="org.hisp.dhis.caseentry.action.patient.ProgramEnrollmentAction"
@@ -634,13 +701,20 @@
 		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
 		<property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
 		<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
-		<property name="identifierTypeService" ref="org.hisp.dhis.patient.PatientIdentifierTypeService" />
-		<property name="patientIdentifierService" ref="org.hisp.dhis.patient.PatientIdentifierService" />
-		<property name="patientAttributeService" ref="org.hisp.dhis.patient.PatientAttributeService" />
-		<property name="patientAttributeGroupService" ref="org.hisp.dhis.patient.PatientAttributeGroupService" />
-		<property name="patientAttributeValueService" ref="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
-		<property name="programAttributeService" ref="org.hisp.dhis.program.ProgramAttributeService" />
-		<property name="selectedStateManager" ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
+		<property name="identifierTypeService"
+			ref="org.hisp.dhis.patient.PatientIdentifierTypeService" />
+		<property name="patientIdentifierService"
+			ref="org.hisp.dhis.patient.PatientIdentifierService" />
+		<property name="patientAttributeService"
+			ref="org.hisp.dhis.patient.PatientAttributeService" />
+		<property name="patientAttributeGroupService"
+			ref="org.hisp.dhis.patient.PatientAttributeGroupService" />
+		<property name="patientAttributeValueService"
+			ref="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
+		<property name="programAttributeService"
+			ref="org.hisp.dhis.program.ProgramAttributeService" />
+		<property name="selectedStateManager"
+			ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
 	</bean>
 
 	<bean
@@ -650,7 +724,8 @@
 		<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
 		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
 		<property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
-		<property name="programStageInstanceService" ref="org.hisp.dhis.program.ProgramStageInstanceService" />
+		<property name="programStageInstanceService"
+			ref="org.hisp.dhis.program.ProgramStageInstanceService" />
 	</bean>
 
 	<bean id="org.hisp.dhis.caseentry.action.patient.SaveDueDateAction"
@@ -686,23 +761,28 @@
 		<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
 		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
 	</bean>
-	
+
 	<bean
 		id="org.hisp.dhis.caseentry.action.patient.SaveIdentifierAndAttributeAction"
 		class="org.hisp.dhis.caseentry.action.patient.SaveIdentifierAndAttributeAction"
 		scope="prototype">
 		<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
-		<property name="identifierTypeService" ref="org.hisp.dhis.patient.PatientIdentifierTypeService" />
-		<property name="patientIdentifierService" ref="org.hisp.dhis.patient.PatientIdentifierService" />
-		<property name="patientAttributeValueService" ref="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
-		<property name="patientAttributeService" ref="org.hisp.dhis.patient.PatientAttributeService" />
-		<property name="patientAttributeOptionService" ref="org.hisp.dhis.patient.PatientAttributeOptionService" />
+		<property name="identifierTypeService"
+			ref="org.hisp.dhis.patient.PatientIdentifierTypeService" />
+		<property name="patientIdentifierService"
+			ref="org.hisp.dhis.patient.PatientIdentifierService" />
+		<property name="patientAttributeValueService"
+			ref="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
+		<property name="patientAttributeService"
+			ref="org.hisp.dhis.patient.PatientAttributeService" />
+		<property name="patientAttributeOptionService"
+			ref="org.hisp.dhis.patient.PatientAttributeOptionService" />
 		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
 	</bean>
-	
+
 	<!--  Relationship -->
-	
-		<bean
+
+	<bean
 		id="org.hisp.dhis.caseentry.action.patient.AddRelationshipPatientAction"
 		class="org.hisp.dhis.caseentry.action.patient.AddRelationshipPatientAction"
 		scope="prototype">
@@ -724,10 +804,9 @@
 		<property name="relationshipTypeService"
 			ref="org.hisp.dhis.relationship.RelationshipTypeService" />
 	</bean>
-	
+
 	<bean id="org.hisp.dhis.caseentry.action.patient.GetPartnerAction"
-		class="org.hisp.dhis.caseentry.action.patient.GetPartnerAction"
-		scope="prototype">
+		class="org.hisp.dhis.caseentry.action.patient.GetPartnerAction" scope="prototype">
 		<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
 		<property name="patientIdentifierService"
 			ref="org.hisp.dhis.patient.PatientIdentifierService" />
@@ -735,24 +814,22 @@
 		<property name="patientAttributeValueService"
 			ref="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
 	</bean>
-	
-	<bean
-		id="org.hisp.dhis.caseentry.action.patient.RemoveRelationshipAction"
+
+	<bean id="org.hisp.dhis.caseentry.action.patient.RemoveRelationshipAction"
 		class="org.hisp.dhis.caseentry.action.patient.RemoveRelationshipAction"
 		scope="prototype">
 		<property name="relationshipService"
 			ref="org.hisp.dhis.relationship.RelationshipService" />
 	</bean>
-	
+
 	<bean
 		id="org.hisp.dhis.caseentry.action.patient.RemoveRepresentativeAction"
 		class="org.hisp.dhis.caseentry.action.patient.RemoveRepresentativeAction"
 		scope="prototype">
 		<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
 	</bean>
-	
-	<bean
-		id="org.hisp.dhis.caseentry.action.patient.SaveRelationshipAction"
+
+	<bean id="org.hisp.dhis.caseentry.action.patient.SaveRelationshipAction"
 		class="org.hisp.dhis.caseentry.action.patient.SaveRelationshipAction"
 		scope="prototype">
 		<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
@@ -761,16 +838,15 @@
 		<property name="relationshipService"
 			ref="org.hisp.dhis.relationship.RelationshipService" />
 	</bean>
-	
-	<bean
-		id="org.hisp.dhis.caseentry.action.patient.SaveRepresentativeAction"
+
+	<bean id="org.hisp.dhis.caseentry.action.patient.SaveRepresentativeAction"
 		class="org.hisp.dhis.caseentry.action.patient.SaveRepresentativeAction"
 		scope="prototype">
 		<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
 		<property name="patientAttributeValueService"
 			ref="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
 	</bean>
-	
+
 	<bean
 		id="org.hisp.dhis.caseentry.action.patient.SearchRelationshipPatientAction"
 		class="org.hisp.dhis.caseentry.action.patient.SearchRelationshipPatientAction"
@@ -783,7 +859,7 @@
 		<property name="relationshipService"
 			ref="org.hisp.dhis.relationship.RelationshipService" />
 	</bean>
-	
+
 	<bean
 		id="org.hisp.dhis.caseentry.action.patient.ShowAddRelationshipFormAction"
 		class="org.hisp.dhis.caseentry.action.patient.ShowAddRelationshipFormAction"
@@ -796,7 +872,7 @@
 		<property name="patientAttributeService"
 			ref="org.hisp.dhis.patient.PatientAttributeService" />
 	</bean>
-	
+
 	<bean
 		id="org.hisp.dhis.caseentry.action.patient.ShowAddRelationshipPatientAction"
 		class="org.hisp.dhis.caseentry.action.patient.ShowAddRelationshipPatientAction"
@@ -831,7 +907,7 @@
 		<property name="patientAttributeValueService"
 			ref="org.hisp.dhis.patientattributevalue.PatientAttributeValueService" />
 	</bean>
-	
+
 	<bean
 		id="org.hisp.dhis.caseentry.action.patient.ValidateAddRelationshipPatientAction"
 		class="org.hisp.dhis.caseentry.action.patient.ValidateAddRelationshipPatientAction"
@@ -849,10 +925,11 @@
 			<ref bean="org.hisp.dhis.patient.PatientIdentifierTypeService" />
 		</property>
 	</bean>
-	
-	<bean id="org.hisp.dhis.caseentry.action.patient.ValidateSearchRelationshipAction"
+
+	<bean
+		id="org.hisp.dhis.caseentry.action.patient.ValidateSearchRelationshipAction"
 		class="org.hisp.dhis.caseentry.action.patient.ValidateSearchRelationshipAction"
 		scope="prototype">
 	</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	2012-03-30 02:13:18 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2012-04-11 06:25:02 +0000
@@ -250,7 +250,7 @@
 see_history_plan=See history / plan
 name_based_data_entry=Name-based data entry
 multiple_name_based_data_entry=Multiple name-based data entry
-orgunit_level= Organisation unit level
+use_data_from_level=Use data from level(s)
 saved = Saved
 save_selected_values = Save selected values
 save_all_values = Save all values
@@ -285,7 +285,7 @@
 D=Declared
 A=Approximated
 some_data_element_not_exist = Some data element is not exist
-orgunit_hiererachy_included_on = Organisation unit hiererachy included on
+include_parent_orgunits_starting_from_level = Include parent organisation units starting from (level)
 level = Level
 please_fill_out_only_one_of_these_fields = Please fill out at only one of these fields.
 age_year = Age(year)
@@ -298,4 +298,15 @@
 modify_due_date_or_visit_date = Modify Due/Visit dates
 data_entry_screen = Data entry Screen
 unenrol_success = Beneficiary un-enrolled successfully
-enrolled_for = Enrolled for
\ No newline at end of file
+enrolled_for = Enrolled for
+selected_boundary = Selected (boundary)
+regular_program = Regular program
+please_select_a_program_stage = Please select a program stage
+available_identifier_types = Available identifier types
+selected_identifier_types = Selected identifier types
+show_hierachy_from_level = Show hierachy from level
+attribute = Attribute
+download = Download
+xls = XLS
+pdf = PDF
+pdf = PDF
\ 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	2012-03-29 04:15:07 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml	2012-04-11 06:25:02 +0000
@@ -276,16 +276,61 @@
 			<param name="requiredAuthorities">F_GENERATE_BENEFICIARY_TABULAR_REPORT</param>
 		</action>
 		
-		<action name="loadTabularProgramStages"
+		<action name="getOrganisationUnitChildren"
+			class="org.hisp.dhis.visualizer.action.GetOrganisationUnitChildrenAction">
+			<result name="success" type="velocity-json">
+				/dhis-web-caseentry/jsonminOrganisationUnitChildren.vm</result>
+		</action>
+		
+		<action name="tabularInitialize"
+			class="org.hisp.dhis.caseentry.action.report.TabularInitializeAction">
+			 <result name="success" type="velocity-json">
+                /dhis-web-caseentry/jsonTabularInitialize.vm</result>
+		</action>
+
+		<action name="getReportPrograms"
+			class="org.hisp.dhis.caseentry.action.report.LoadProgramsAction">
+			<result name="success" type="velocity-json">
+				/dhis-web-commons/ajax/jsonPrograms.vm</result>
+		</action>
+		
+		<action name="getTabularParams"
+			class="org.hisp.dhis.caseentry.action.report.GetTabularParamsAction">
+			<result name="success" type="velocity-json">/dhis-web-caseentry/responseTabularParams.vm</result>
+		</action>
+				
+		<action name="loadReportIdentifierTypes"
+			class="org.hisp.dhis.caseentry.action.report.LoadIdentifierTypesAction">
+			<result name="success" type="velocity-json">
+				/dhis-web-caseentry/jsonIdentifierTypes.vm</result>
+		</action>
+		
+		<action name="loadReportAttributeGroups"
+			class="org.hisp.dhis.caseentry.action.report.LoadAttributeGroupsAction">
+			<result name="success" type="velocity-json">
+				/dhis-web-commons/ajax/jsonPatientAttributeGroups.vm</result>
+		</action>
+		
+		<action name="loadReportProgramStages"
 			class="org.hisp.dhis.caseentry.action.report.LoadProgramStagesAction">
 			<result name="success" type="velocity-json">/dhis-web-caseentry/responseProgramStages.vm</result>
 		</action>
 		
+		<action name="loadReportAttributes"
+			class="org.hisp.dhis.caseentry.action.report.LoadAttributesAction">
+			<result name="success" type="velocity-json">/dhis-web-commons/ajax/jsonPatientAttributes.vm</result>
+		</action>
+		
 		<action name="loadDataElements"
 			class="org.hisp.dhis.caseentry.action.report.LoadDataElementsAction">
 			<result name="success" type="velocity-json">/dhis-web-caseentry/responseDataElements.vm</result>
 		</action>
 		
+		<action name="getTabularParams"
+			class="org.hisp.dhis.caseentry.action.report.GetTabularParamsAction">
+			<result name="success" type="velocity-json">/dhis-web-caseentry/responseTabularParams.vm</result>
+		</action>
+		
 		<action name="validateTabularReport"
 			class="org.hisp.dhis.caseentry.action.report.ValidateTabularReportAction">
 			<result name="success" type="velocity-json">
@@ -303,12 +348,26 @@
 			<param name="requiredAuthorities">F_GENERATE_BENEFICIARY_TABULAR_REPORT</param>
 		</action>
 		
+		 <!--  action name="generateTabularReport"
+			class="org.hisp.dhis.caseentry.action.report.GenerateTabularReportAction">
+			<result name="success" type="velocity-json">/dhis-web-caseentry/jsonTabularReport.vm</result>
+			<result name="xls" type="gridXlsResult" />
+      		<result name="pdf" type="gridPdfResult" />
+			<param name="requiredAuthorities">F_GENERATE_BENEFICIARY_TABULAR_REPORT</param>
+		</action>  -->
+		
 		<action name="searchTabularReport"
 			class="org.hisp.dhis.caseentry.action.report.GenerateTabularReportAction">
 			<result name="success" type="velocity">/dhis-web-caseentry/searchTabularReportResult.vm</result>
 			<param name="requiredAuthorities">F_GENERATE_BENEFICIARY_TABULAR_REPORT</param>
 		</action>
 		
+		<!-- i18n -->
+
+        <action name="i18n" class="org.hisp.dhis.caseentry.action.NoAction">
+            <result name="success" type="velocity-javascript">/dhis-web-caseentry/i18n.vm</result>
+        </action>
+        
 		<!-- Case Aggregation -->
 
 		<action name="caseAggregationForm"

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationForm.vm	2012-03-12 04:19:40 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationForm.vm	2012-04-11 06:25:02 +0000
@@ -49,7 +49,7 @@
 			
 			<tr>
 				<td>
-				   $i18n.getString( "orgunit_level" )
+				   $i18n.getString( "use_data_from_level" )
 				</td>
 				<td>
 					<select id="facilityLB" name="facilityLB" style="width: 30em">

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/tabularReport.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/tabularReport.js	2012-03-23 03:46:08 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/tabularReport.js	2012-04-11 06:25:02 +0000
@@ -9,41 +9,69 @@
 
 selection.setListenerFunction( organisationUnitSelected );
 
-function loadProgramStages()
+
+// ---------------------------------------------------------------------
+// Load patient-identifiers && patient-attributes
+// ---------------------------------------------------------------------
+
+function getTabularParams()
 {
-	clearListById( 'programStageId' );
-	clearListById( 'availableDataElementIds' );
-	
-	if( getFieldValue('programId') == '' )
+	clearListById( 'availableIdenIds' );
+	clearListById( 'availableAttrIds' );
+	clearListById( 'programStageId');
+	if( getFieldValue('programStageId') == '' )
 	{
 		return;
 	}
-	
-	clearListById( 'dataElementIds' );
-	$.getJSON( 'loadTabularProgramStages.action',
-		{
-			programId: getFieldValue('programId')
-		}
-		, function( json ) 
-		{
-			var singleEvent = jQuery('#programId option:selected').attr('singleevent');
-			if(singleEvent=='false')
-			{
-				addOptionById( 'programStageId', '', i18n_please_select );
-			}
-			
-			for ( i in json.programStages ) 
-			{ 
-				$('#programStageId').append('<option value=' + json.programStages[i].id + '>' + json.programStages[i].name + '</option>');
-			}
-			
-			if(singleEvent=='true')
-			{
-				loadDataElements();
-			}
-		} );
+	else
+	{		
+		clearListById( 'availableAttrIds' );
+		$.getJSON( 'getTabularParams.action',
+			{
+				programId: getFieldValue('programId')
+			}
+			, function( json ) 
+			{
+				// Load patient-identifier-types
+				for ( i in json.identifierTypes ) 
+				{ 
+					$('#availableIdenIds').append('<option value="iden_' + json.identifierTypes[i].id + '_" >' + json.identifierTypes[i].name + '</option>');
+				}
+				
+				// Load patient-attributes
+				for ( i in json.patientAttributes ) 
+				{ 
+					$('#availableAttrIds').append('<option value="attr_' + json.patientAttributes[i].id + '_" >' + json.patientAttributes[i].name + '</option>');
+				}
+				
+				// Load program-stages
+				var noProgramStage = 0;
+				for ( i in json.programStages ) 
+				{ 
+					if( !json.programStages[i].irregular )
+					{
+						$('#programStageId').append('<option value=' + json.programStages[i].id + '>' + json.programStages[i].name + '</option>');
+						noProgramStage++;
+					}
+				}
+				
+				if( noProgramStage > 1 )
+				{
+					$('#programStageId').prepend('<option value="">' + i18n_please_select_a_program_stage + '</option>');
+					$('#programStageId option:first-child').attr("selected", "selected");
+				}
+				else if( noProgramStage == 1 )
+				{
+					loadDataElements();
+				}
+			} );
+	}
 }
 
+// ---------------------------------------------------------------------
+// Load dataelements by stage
+// ---------------------------------------------------------------------
+
 function loadDataElements()
 {
 	clearListById( 'availableDataElementIds' );
@@ -70,7 +98,7 @@
 				{
 					for ( i in json.dataElements ) 
 					{ 
-						$('#availableDataElementIds').append('<option value=' + json.dataElements[i].id + ' >' + json.dataElements[i].name + '</option>');
+						$('#availableDataElementIds').append('<option value="de_' + json.dataElements[i].id + '_" >' + json.dataElements[i].name + '</option>');
 					}
 				} );
 		}
@@ -282,20 +310,37 @@
 	var searchingValues = "";
 	var listSeachingValues = jQuery("#gridTable input[type=text]");
 	
-	listSeachingValues.each( function( i, item ){
-		if( item.value != '' )
-		{
+	if( listSeachingValues.length > 0 )
+	{
+		listSeachingValues.each( function( i, item ){
 			var value = getFormula( item.value );
-			searchingValues += "searchingValues=" + item.id + "_" + htmlEncode( value ) + "&";
-		}
-	});
-	
-	var dataElementIds = "";
-	var listDataElementIds = jQuery( "select[id=dataElementIds] option" );
-	listDataElementIds.each( function( i, item ){
-		dataElementIds += "dataElementIds=" + item.value;
-		dataElementIds += ( i < listDataElementIds.length - 1 ) ? "&" : "";
-	});
+			searchingValues += "&searchingValues=" + item.id + "_" ;
+			if( item.value != '' )
+			{
+				searchingValues += htmlEncode( value );
+			}
+		});
+	}
+	else
+	{
+		var listIdentifierTypes = jQuery( "select[id=selectedIdenIds] option" );
+		listIdentifierTypes.each( function( i, item ){
+			searchingValues += "searchingValues=" + item.value;
+			searchingValues += ( i < listIdentifierTypes.length - 1 ) ? "&" : "";
+		});
+		
+		var listPatientAttributes = jQuery( "select[id=selectedAttrIds] option" );
+		listPatientAttributes.each( function( i, item ){
+			searchingValues += "searchingValues=" + item.value;
+			searchingValues += ( i < listPatientAttributes.length - 1 ) ? "&" : "";
+		});
+		
+		var listDataElementIds = jQuery( "select[id=dataElementIds] option" );
+		listDataElementIds.each( function( i, item ){
+			searchingValues += "searchingValues=" + item.value;
+			searchingValues += ( i < listDataElementIds.length - 1 ) ? "&" : "";
+		});
+	}
 	
 	var orderByOrgunitAsc = jQuery( '#orderByOrgunitAsc' ).attr('orderBy');
 	if( orderByOrgunitAsc == null )
@@ -309,8 +354,7 @@
 		orderByExecutionDateByAsc = 'true';
 	}
 	
-	return searchingValues + dataElementIds
-				+ "&programStageId=" + getFieldValue('programStageId')
+	return searchingValues + "&programStageId=" + getFieldValue('programStageId')
 				+ "&startDate=" + getFieldValue('startDate')
 				+ "&endDate=" + getFieldValue('endDate')
 				+ "&facilityLB=" + getFieldValue('facilityLB')
@@ -358,3 +402,38 @@
 		item.value = '';
 	});	
 }
+
+
+//------------------------------------------------------------------------------
+// Filter data-element
+//------------------------------------------------------------------------------
+
+function filterDE( event, value, fieldName )
+{
+	var field = byId(fieldName);
+	for ( var index = 0; index < field.options.length; index++ )
+    {
+		var option = field.options[index];
+		
+		if(value.length == 0 )
+		{
+			option.style.display = "block";
+		}
+		else
+		{
+			if (option.text.toLowerCase().indexOf( value.toLowerCase() ) != -1 )
+			{
+				option.style.display = "block";
+			}
+			else
+			{
+				option.style.display = "none";
+			}
+		}
+    }	    
+}
+
+function toogleTB(tbody)
+{
+	jQuery( '#' + tbody ).toggle();
+}

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/responseProgramStages.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/responseProgramStages.vm	2012-01-11 08:34:43 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/responseProgramStages.vm	2012-04-11 06:25:02 +0000
@@ -4,7 +4,8 @@
 	#foreach( $programStage in $programStages )
 	  {
 		"id":  ${programStage.id} ,
-		"name": "$!encoder.jsonEncode( ${programStage.name} )"
+		"name": "$!encoder.jsonEncode( ${programStage.name} )",
+		"irregular": "${programStage.irregular}"
 	  }#if( $velocityCount < $size ),#end
 	#end],
 	

=== added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/responseTabularParams.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/responseTabularParams.vm	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/responseTabularParams.vm	2012-04-11 06:25:02 +0000
@@ -0,0 +1,29 @@
+#set( $size = $identifierTypes.size() )
+{ 
+"identifierTypes": [
+	#foreach( $identifierType in $identifierTypes )
+	  {
+		"id":  ${identifierType.id} ,
+		"name": "$!encoder.jsonEncode( ${identifierType.name} )"
+	  }#if( $velocityCount < $size ),#end
+	#end],
+	
+#set( $size = $attributes.size() )
+"patientAttributes": [
+	#foreach( $attribute in $attributes )
+	  {
+		"id":  ${attribute.id} ,
+		"name": "$!encoder.jsonEncode( ${attribute.name} )"
+	  }#if( $velocityCount < $size ),#end
+	#end],
+	
+#set( $size = $programStages.size() )
+"programStages": [
+	#foreach( $programStage in $programStages )
+	  {
+		"id":  ${programStage.id} ,
+		"name": "$!encoder.jsonEncode( ${programStage.name} )",
+		"irregular":${programStage.irregular}
+	  }#if( $velocityCount < $size ),#end
+	#end]
+}
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchTabularReportResult.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchTabularReportResult.vm	2012-03-23 03:46:08 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchTabularReportResult.vm	2012-04-11 06:25:02 +0000
@@ -2,12 +2,6 @@
 #set( $mark = false )
 #set( $i = 1 )
 
-#set( $anonymous = "true")
-
-#if( $grid.getVisibleHeaders().size() <  $grid.getHeaders().size() )
-	#set( $anonymous = "false" )
-#end
-
 #foreach( $row in $grid.getRows() )
 	<tr id="tr${i}" class='rowGrid'>
 		<td>
@@ -16,14 +10,7 @@
 		</td>
 		#foreach( $col in $row )
 			<td>
-				#set( $index = ( $velocityCount - 1 ) ) 
-				#if( $anonymous == "false" && ( $index == $row.size() - 1 ) )
-					#if($col)
-					<a href="javascript:showPatientHistory( '$col' )" title='$i18n.getString( "patient_details_and_history" )'><img src="../images/information.png" alt='$i18n.getString( "patient_details_and_history" )'></a>
-					#end
-				#else
-					$!encoder.htmlEncode( $col )
-				#end
+				$!encoder.htmlEncode( $col )
 			</td>
 		#end
 	</tr>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/style/report.css'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/style/report.css	2012-03-23 03:46:08 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/style/report.css	2012-04-11 06:25:02 +0000
@@ -2,9 +2,15 @@
 /* For GRID form                                                              */
 /*----------------------------------------------------------------------------*/
 
-.button
-{
-	width:140px; 
+input.button
+{
+	width:60px; 
+}
+
+select[multiple='true']
+{
+	min-width:250px;
+	min-height:250px;
 }
 
 input[type="button"], input[type="submit"]

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/tabularReportResult.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/tabularReportResult.vm	2012-03-23 03:53:21 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/tabularReportResult.vm	2012-04-11 06:25:02 +0000
@@ -15,11 +15,6 @@
 
 	<h5>$!encoder.htmlEncode( $grid.subtitle )</h5>
 
-	#set( $anonymous = "true")
-	#if( $grid.getVisibleHeaders().size() <  $grid.getHeaders().size() )
-		#set( $anonymous = "false" )
-	#end
-
 	<table class="listTable grid" id='gridTable'>
 		<tr>
 			<th>#</th>
@@ -31,6 +26,16 @@
 				$i18n.getString('report_date')
 					<a href="javascript:onchangeOrderBy( 'orderByExecutionDateByAsc' );"  title='$i18n.getString( "order_by_report_date" )'><img src="../images/asc.gif" alt='$i18n.getString( "desc" )' id='orderByExecutionDateByAsc' orderBy='true' style='curser:pointer;'></a>
 			</th>
+			#foreach( $identifierType in $identifierTypes )
+				<th>
+					$!encoder.htmlEncode( $identifierType.name )
+				</th>
+			#end
+			#foreach( $patientAttribute in $patientAttributes )
+				<th>
+					$!encoder.htmlEncode( $patientAttribute.name )
+				</th>
+			#end
 			#foreach( $dataElement in $dataElements )
 				<th>
 					$!encoder.htmlEncode( $dataElement.name )
@@ -47,14 +52,21 @@
 			</td>
 			<td></td>
 			<td></td>
+			#foreach( $identifierType in $identifierTypes )
+				<td>
+					<input type='text' id='iden_$identifierType.id' title='$i18n.getString("how_to_search_tabular_report")' onkeypress='onkeypressSearch( event );' #if($dataElement.optionSet) options='$dataElement.optionSet.options' #end />
+				</td>
+			#end
+			#foreach( $patientAttribute in $patientAttributes )
+				<td>
+					<input type='text' id='attr_$patientAttribute.id' title='$i18n.getString("how_to_search_tabular_report")' onkeypress='onkeypressSearch( event );' #if($dataElement.optionSet) options='$dataElement.optionSet.options' #end />
+				</td>
+			#end
 			#foreach( $dataElement in $dataElements )
 				<td>
-					<input type='text' id='$dataElement.id' title='$i18n.getString("how_to_search_tabular_report")' onkeypress='onkeypressSearch( event );' #if($dataElement.optionSet) options='$dataElement.optionSet.options' #end />
+					<input type='text' id='de_$dataElement.id' title='$i18n.getString("how_to_search_tabular_report")' onkeypress='onkeypressSearch( event );' #if($dataElement.optionSet) options='$dataElement.optionSet.options' #end />
 				</td>
 			#end
-			#if( $anonymous == "false" )
-				<td></td>
-			#end
 		</tr>
 		
 		<tbody id="gridContent">

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/tabularReportSelect.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/tabularReportSelect.vm	2012-03-23 03:53:21 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/tabularReportSelect.vm	2012-04-11 06:25:02 +0000
@@ -5,10 +5,10 @@
 		}, {
 			'beforeValidateHandler' : function()
 			{
-				listValidator( 'memberValidator', 'dataElementIds' );
+				listValidator( 'memberDEValidator', 'dataElementIds' );
 			}
 		} ); 
-
+		
 		datePickerInRange( 'startDate' , 'endDate' );	
 	});		
 </script>
@@ -17,9 +17,10 @@
 <form id="reportForm" name="reportForm" method="post">
 <p><input type="button" value="$i18n.getString('data')" onclick="showCriteria();" ></p>
 
-<div class="inputCriteria" id='criteriaDiv' style="width:600px;height:480px;margin-bottom:20px;">
+<div class="inputCriteria" id='criteriaDiv' style="width:900px;height:590px;margin-bottom:20px;">
 
 <table>	
+
     <tr>
 	  <td><label>$i18n.getString( "orgunit_boundary" )</label></td>
 	  <td colspan='2'><input type="text" readonly="readonly" id='orgunitname' name='orgunitname' #if($!orgunit) value="$!orgunit.name" #else value="[$i18n.getString( 'select' )]" #end ></td>
@@ -27,20 +28,20 @@
 	
     <tr>
 		<td>
-		   $i18n.getString( "orgunit_level" )
+		   $i18n.getString( "use_data_from_level" )
 		</td>
 		<td>
 			<select id="facilityLB" name="facilityLB">
 				<option value="all" selected="selected" >$i18n.getString( "all" )</option>
 				<option value="childrenOnly" >$i18n.getString( "children_only" )</option>
-				<option value="selected" >$i18n.getString( "selected" )</option>
+				<option value="selected" >$i18n.getString( "selected_boundary" )</option>
 			</select>
 		</td>
 	</tr>
 	
 	<tr>
 		<td>
-		   $i18n.getString( "orgunit_hiererachy_included_on" )
+		   $i18n.getString( "include_parent_orgunits_starting_from_level" )
 		</td>
 		<td>
 			<select id="level" name="level">
@@ -65,10 +66,10 @@
         </td>      
     </tr>
 	
-    <tr>
-        <td><label for="programId">$i18n.getString( "program" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
-        <td colspan='2'>
-            <select id="programId" name="programId" #if($!programs) #else disabled #end class="{validate:{required:true}}" onchange='loadProgramStages();'>
+	<tr>
+		<td><label>$i18n.getString( "program" )</label></td>
+		<td>
+            <select id="programId" name="programId" #if($!programs) #else disabled #end onchange='getTabularParams();'>
 				<option value=''>[$i18n.getString('please_select')]</option>
 				#foreach( $program in $programs )
 				<option value='$program.id' singleevent='$program.singleEvent'>$program.name</option>
@@ -76,48 +77,142 @@
 			</select>
         </td>
     </tr>
-        
     
-	<tr>
-        <td><label>$i18n.getString( "program_stage" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
-        <td colspan='2'>
-			<select id="programStageId" name="programStageId" class="{validate:{required:true}}" onchange='loadDataElements();'></select>
-        </td>      
-    </tr>
-	
-	<tr>
-		<td><label>$i18n.getString( "available_data_elements" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
-        <td colspan='2'>
-			<select id="availableDataElementIds" name="availableDataElementIds" multiple size='6' ondblclick="moveSelectedById( 'availableDataElementIds', 'dataElementIds' )" ></select>
-        </td>      
-    </tr>
-	
-	<tr>
-        <td></td>
-		<td> 
-			<input type="button" value="$i18n.getString( 'add_selected' )" title="$i18n.getString( 'add_selected' )" onclick="moveSelectedById( 'availableDataElementIds', 'dataElementIds' )" class="button" />
-            <input type="button" value="$i18n.getString( 'add_all' )" title="$i18n.getString( 'add_all' )" onclick="moveAllById( 'availableDataElementIds', 'dataElementIds' )" class="button" /> <br>
-            <input type="button" value="$i18n.getString( 'remove_selected' )" title="$i18n.getString( 'remove_selected' )" onclick="moveSelectedById( 'dataElementIds', 'availableDataElementIds' )" class="button" />
-            <input type="button" value="$i18n.getString( 'remove_all' )" title="$i18n.getString( 'remove_all' )" onclick="moveAllById( 'dataElementIds', 'availableDataElementIds' )" class="button" />
-        </td>
-    </tr>
-	
-	<tr>
-		<td><label>$i18n.getString( "selected_data_elements" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
-        <td>
-			<select id="dataElementIds" name="dataElementIds" multiple size='6' ondblclick="moveSelectedById( 'dataElementIds', 'availableDataElementIds' )" ></select>
-			<select id="memberValidator" multiple="multiple" class="{validate:{required:true}} hidden"/>
-        </td> 
-		<td style="width:30px; text-align:center">
-            <a href="javascript:moveUpSelectedOption('dataElementIds')"><img src="../images/move_up.png"/></a><br/><br/>
-            <a href="javascript:moveDownSelectedOption('dataElementIds')"><img src="../images/move_down.png"/></a><br/><br/>
-        </td>  			
-    </tr>
+</table>
+
+<p></p>
+<table width='100%'>
+	<tr onclick='toogleTB("idenTB")' style='cursor:pointer'>
+		<th>$i18n.getString( "available_identifier_types" )</td>
+		<th>$i18n.getString( "filter" )</th>
+		<th>$i18n.getString( "selected_identifier_types" ) <em title="$i18n.getString( 'required' )" class="required">*</em></td>
+	</tr>
+	
+	<tbody id='idenTB' style='display:none;'>
+		<tr>
+			<td>
+				<input type='text' id='searchAvailableIdenText' onkeyup="filterDE(event, this.value, 'searchAvailableIdenText');"/>
+				<input type="button" value="$i18n.getString( 'clear' )" onclick="setFieldValue('searchAvailableIdenText', '');" style="width:60px" >
+			</td> 
+			<td></td>
+			<td>
+				<input type='text' id='searchSelectedIdenText' onkeyup="filterDE(event, this.value, 'searchSelectedIdenText');"/>
+				<input type="button" value="$i18n.getString( 'clear' )" onclick="setFieldValue('searchSelectedIdenText', '');" class="button" >
+			</td>		
+		</tr>
+		
+		<tr>
+			<td>
+				<select id="availableIdenIds" name="availableAttrIds" multiple='true' size='16' ondblclick="moveSelectedById( 'availableIdenIds', 'selectedIdenIds' )" ></select>
+			</td>      
+			<td> 
+				<input type="button" value="$i18n.getString( '>' )" title="$i18n.getString( 'add_selected' )" onclick="moveSelectedById( 'availableIdenIds', 'selectedIdenIds' )" class="button" />
+				<input type="button" value="$i18n.getString( '>>' )" title="$i18n.getString( 'add_all' )" onclick="moveAllById( 'availableIdenIds', 'selectedIdenIds' )" class="button" /> <br>
+				<input type="button" value="$i18n.getString( '<' )" title="$i18n.getString( 'remove_selected' )" onclick="moveSelectedById( 'selectedIdenIds', 'availableIdenIds' )" class="button" />
+				<input type="button" value="$i18n.getString( '<<' )" title="$i18n.getString( 'remove_all' )" onclick="moveAllById( 'selectedIdenIds', 'availableIdenIds' )" class="button" />
+			</td>
+			<td>
+				<select id="selectedIdenIds" name="selectedIdenIds" multiple='true' size='16' ondblclick="moveSelectedById( 'selectedIdenIds', 'availableIdenIds' )" ></select>
+			</td> 
+			<td>
+				<a href="javascript:moveUpSelectedOption('selectedIdenIds')"><img src="../images/move_up.png"/></a><br/><br/>
+				<a href="javascript:moveDownSelectedOption('selectedIdenIds')"><img src="../images/move_down.png"/></a><br/><br/>
+			</td>  			
+		</tr>
+	
+	</tbody>
+	
+	<tr onclick='toogleTB("attrTB")' style='cursor:pointer'>
+		<th>$i18n.getString( "available_attribute" )</td>
+		<th>$i18n.getString( "filter" )</th>
+		<th>$i18n.getString( "selected_attribute" ) <em title="$i18n.getString( 'required' )" class="required">*</em></td>
+	</tr>
+		
+	<tbody id='attrTB' style='display:none;'>
+		
+		<tr>
+			<td>
+				<input type='text' id='searchAvailableAttrText' onkeyup="filterDE(event, this.value, 'searchAvailableAttrText');"/>
+				<input type="button" value="$i18n.getString( 'clear' )" onclick="setFieldValue('searchAvailableAttrText', '');" style="width:60px" >
+			</td> 
+			<td></td>
+			<td>
+				<input type='text' id='searchSelectedAttrText' onkeyup="filterDE(event, this.value, 'searchSelectedAttrText');"/>
+				<input type="button" value="$i18n.getString( 'clear' )" onclick="setFieldValue('searchSelectedAttrText', '');" class="button" >
+			</td>		
+		</tr>
+		
+		<tr>
+			<td>
+				<select id="availableAttrIds" name="availableAttrIds" multiple='true' size='16' ondblclick="moveSelectedById( 'availableAttrIds', 'selectedAttrIds' )" ></select>
+			</td>      
+			<td> 
+				<input type="button" value="$i18n.getString( '>' )" title="$i18n.getString( 'add_selected' )" onclick="moveSelectedById( 'availableAttrIds', 'selectedAttrIds' )" class="button" />
+				<input type="button" value="$i18n.getString( '>>' )" title="$i18n.getString( 'add_all' )" onclick="moveAllById( 'availableAttrIds', 'selectedAttrIds' )" class="button" /> <br>
+				<input type="button" value="$i18n.getString( '<' )" title="$i18n.getString( 'remove_selected' )" onclick="moveSelectedById( 'selectedAttrIds', 'availableAttrIds' )" class="button" />
+				<input type="button" value="$i18n.getString( '<<' )" title="$i18n.getString( 'remove_all' )" onclick="moveAllById( 'selectedAttrIds', 'availableAttrIds' )" class="button" />
+			</td>
+			<td>
+				<select id="selectedAttrIds" name="selectedAttrIds" multiple='true' size='16' ondblclick="moveSelectedById( 'selectedAttrIds', 'availableAttrIds' )" ></select>
+			</td> 
+			<td>
+				<a href="javascript:moveUpSelectedOption('selectedAttrIds')"><img src="../images/move_up.png"/></a><br/><br/>
+				<a href="javascript:moveDownSelectedOption('selectedAttrIds')"><img src="../images/move_down.png"/></a><br/><br/>
+			</td>  			
+		</tr>
+	</tbody>
+	
+	<tr onclick='toogleTB("deTB")' style='cursor:pointer'>
+		<th>$i18n.getString( "available_data_elements" )</td>
+		<th>$i18n.getString( "filter" )</th>
+		<th>$i18n.getString( "selected_data_elements" ) <em title="$i18n.getString( 'required' )" class="required">*</em></td>
+	</tr>
+	
+	<tbody id='deTB' style='display:none;'>
+	
+		<tr>
+			<td>
+				<select id="programStageId" name="programStageId" onchange='loadDataElements();'></select>
+			</td>      
+		</tr>
+		
+		<tr>
+			<td>
+				<input type='text' id='searchAvailableDEText' onkeyup="filterDE(event, this.value, 'availableDataElementIds');"/>
+				<input type="button" value="$i18n.getString( 'clear' )" onclick="setFieldValue('searchAvailableDEText', '');" style="width:60px" >
+			</td> 
+			<td></td>
+			<td>
+				<input type='text' id='searchSelectedDEText' onkeyup="filterDE(event, this.value, 'dataElementIds');"/>
+				<input type="button" value="$i18n.getString( 'clear' )" onclick="setFieldValue('searchSelectedDEText', '');" class="button" >
+			</td>		
+		</tr>
+		
+		<tr>
+			<td>
+				<select id="availableDataElementIds" name="availableDataElementIds" multiple='true' size='16' ondblclick="moveSelectedById( 'availableDataElementIds', 'dataElementIds' )" ></select>
+			</td>      
+			<td> 
+				<input type="button" value="$i18n.getString( '>' )" title="$i18n.getString( 'add_selected' )" onclick="moveSelectedById( 'availableDataElementIds', 'dataElementIds' )" class="button" />
+				<input type="button" value="$i18n.getString( '>>' )" title="$i18n.getString( 'add_all' )" onclick="moveAllById( 'availableDataElementIds', 'dataElementIds' )" class="button" /> <br>
+				<input type="button" value="$i18n.getString( '<' )" title="$i18n.getString( 'remove_selected' )" onclick="moveSelectedById( 'dataElementIds', 'availableDataElementIds' )" class="button" />
+				<input type="button" value="$i18n.getString( '<<' )" title="$i18n.getString( 'remove_all' )" onclick="moveAllById( 'dataElementIds', 'availableDataElementIds' )" class="button" />
+			</td>
+			<td>
+				<select id="dataElementIds" name="dataElementIds" multiple='true' size='16' ondblclick="moveSelectedById( 'dataElementIds', 'availableDataElementIds' )" ></select>
+				<select id="memberDEValidator" multiple="multiple" class="{validate:{required:true}} hidden"/>
+			</td> 
+			<td>
+				<a href="javascript:moveUpSelectedOption('dataElementIds')"><img src="../images/move_up.png"/></a><br/><br/>
+				<a href="javascript:moveDownSelectedOption('dataElementIds')"><img src="../images/move_down.png"/></a><br/><br/>
+			</td>  			
+		</tr>
+   </tbody>
    
-	    
+    <tr><td><p></p></td></tr>
 	<tr>
-    	<td></td>
-    	<td><input type="submit" id='generateBtn' name='generateBtn' #if($!programs) #else disabled #end value="$i18n.getString( 'generate' )" />
+    	<td>
+			<input type="submit" id='generateBtn' name='generateBtn' #if($!programs) #else disabled #end value="$i18n.getString( 'generate' )" />
     		<input type="button" value="$i18n.getString( 'cancel' )" onclick="hideCriteria();" />
     	</td>
     </tr>	                		
@@ -145,4 +240,5 @@
 	var i18n_syntax_error_in_search_value = '$encoder.jsEscape( $i18n.getString( "syntax_error_in_search_value" ) , "'")';
 	var i18n_remove_selected_data_elements = '$encoder.jsEscape( $i18n.getString( "remove_selected_data_elements" ) , "'")';
 	var i18n_patient_details_and_history = '$encoder.jsEscape( $i18n.getString( "patient_details_and_history" ) , "'" )';
+	var i18n_please_select_a_program_stage = '[' + '$encoder.jsEscape( $i18n.getString( "please_select_a_program_stage" ), "'")' + ']'; 
 </script>   

=== modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/resources/org/hisp/dhis/visualizer/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-visualizer/src/main/resources/org/hisp/dhis/visualizer/i18n_module.properties	2012-03-14 23:25:58 +0000
+++ dhis-2/dhis-web/dhis-web-visualizer/src/main/resources/org/hisp/dhis/visualizer/i18n_module.properties	2012-04-11 06:25:02 +0000
@@ -118,4 +118,6 @@
 wm_multiple_filter_period=Multiple periods selected as filter.
 wm_multiple_filter_orgunit=Multiple organisation units selected as filter.
 wm_multiple_filter_groups=Multiple organisation unit groups selected as filter.
-wm_first_filter_used=The first one is being used.
\ No newline at end of file
+wm_first_filter_used=The first one is being used.
+available_attribute = Available attribute 
+selected_attribute = Selected attribute
\ No newline at end of file