← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7367: Tabular report, added object TabularReportColumn as an abstraction over report query parameters

 

------------------------------------------------------------
revno: 7367
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2012-06-24 16:29:16 +0200
message:
  Tabular report, added object TabularReportColumn as an abstraction over report query parameters
added:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientreport/TabularReportColumn.java
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/report/GenerateTabularReportAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml


--
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
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientreport/TabularReportColumn.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientreport/TabularReportColumn.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientreport/TabularReportColumn.java	2012-06-24 14:29:16 +0000
@@ -0,0 +1,130 @@
+package org.hisp.dhis.patientreport;
+
+public class TabularReportColumn
+{
+    public static String PREFIX_META_DATA = "meta";    
+    public static String PREFIX_IDENTIFIER_TYPE = "iden";
+    public static String PREFIX_FIXED_ATTRIBUTE = "fixedAttr";    
+    public static String PREFIX_PATIENT_ATTRIBUTE = "attr";
+    public static String PREFIX_DATA_ELEMENT = "de";
+    
+    private String prefix;
+    
+    private String identifier;
+    
+    private boolean hidden;
+    
+    private String query;
+    
+    private String name;
+
+    // -------------------------------------------------------------------------
+    // Constructor
+    // -------------------------------------------------------------------------
+    
+    public TabularReportColumn()
+    {
+    }
+    
+    public TabularReportColumn( String prefix, String identifier, String name, boolean hidden, String query )
+    {
+        this.prefix = prefix;
+        this.identifier = identifier;
+        this.name = name;
+        this.hidden = hidden;
+        this.query = query;
+    }
+
+    // -------------------------------------------------------------------------
+    // Logic
+    // -------------------------------------------------------------------------
+    
+    public boolean hasQuery()
+    {
+        return query != null;
+    }
+
+    public Integer getIdentifierAsInt()
+    {
+        return identifier != null ? Integer.parseInt( identifier ) : null;
+    }
+
+    public boolean isMeta()
+    {
+        return PREFIX_META_DATA.equals( prefix );
+    }
+    
+    public boolean isIdentifierType()
+    {
+        return PREFIX_IDENTIFIER_TYPE.equals( prefix );
+    }
+    
+    public boolean isFixedAttribute()
+    {
+        return PREFIX_FIXED_ATTRIBUTE.equals( prefix );
+    }
+    
+    public boolean isDynamicAttribute()
+    {
+        return PREFIX_PATIENT_ATTRIBUTE.equals( prefix );
+    }
+    
+    public boolean isDataElement()
+    {
+        return PREFIX_DATA_ELEMENT.equals( prefix );
+    }
+
+    // -------------------------------------------------------------------------
+    // Get methods
+    // -------------------------------------------------------------------------
+    
+    public String getPrefix()
+    {
+        return prefix;
+    }
+
+    public void setPrefix( String prefix )
+    {
+        this.prefix = prefix;
+    }
+
+    public String getIdentifier()
+    {
+        return identifier;
+    }
+
+    public void setIdentifier( String identifier )
+    {
+        this.identifier = identifier;
+    }
+
+    public boolean isHidden()
+    {
+        return hidden;
+    }
+
+    public void setHidden( boolean hidden )
+    {
+        this.hidden = hidden;
+    }
+
+    public String getQuery()
+    {
+        return query;
+    }
+
+    public void setQuery( String query )
+    {
+        this.query = query;
+    }
+
+    public String getName()
+    {
+        return name;
+    }
+
+    public void setName( String name )
+    {
+        this.name = name;
+    }
+}

=== 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-06-24 13:42:21 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java	2012-06-24 14:29:16 +0000
@@ -36,6 +36,7 @@
 import org.hisp.dhis.i18n.I18nFormat;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.patient.Patient;
+import org.hisp.dhis.patientreport.TabularReportColumn;
 
 /**
  * @author Abyot Asalefew
@@ -86,10 +87,10 @@
 
     List<ProgramStageInstance> getProgramStageInstances( Patient patient, Boolean completed );
 
-    Grid getTabularReport( ProgramStage programStage, List<String> searchKeys, Collection<Integer> organisationUnits, 
+    Grid getTabularReport( ProgramStage programStage, List<TabularReportColumn> columns, Collection<Integer> organisationUnits, 
         int level, Date startDate, Date endDate, boolean descOrder, Integer min, Integer max );
 
-    int getTabularReportCount( ProgramStage programStage, List<String> searchKeys,
+    int getTabularReportCount( ProgramStage programStage, List<TabularReportColumn> columns,
         Collection<Integer> organisationUnits, int level, 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-06-24 13:42:21 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java	2012-06-24 14:29:16 +0000
@@ -36,6 +36,7 @@
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
 import org.hisp.dhis.patient.Patient;
+import org.hisp.dhis.patientreport.TabularReportColumn;
 
 /**
  * @author Abyot Asalefew
@@ -74,9 +75,9 @@
     List<ProgramStageInstance> get( ProgramStage programStage, OrganisationUnit orgunit, Date startDate, Date endDate, int min, int max );
     
     Grid getTabularReport( ProgramStage programStage, Map<Integer, OrganisationUnitLevel> orgUnitLevelMap,
-        Collection<Integer> orgUnits, List<String> searchKeys, int level, int maxLevel, Date startDate,
+        Collection<Integer> orgUnits, List<TabularReportColumn> columns, int level, int maxLevel, Date startDate,
         Date endDate, boolean descOrder, Integer min, Integer max );
     
-    int getTabularReportCount( ProgramStage programStage, List<String> searchKeys,
+    int getTabularReportCount( ProgramStage programStage, List<TabularReportColumn> columns,
         Collection<Integer> organisationUnits, int level, int maxLevel, 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-06-14 13:07:22 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java	2012-06-24 14:29:16 +0000
@@ -45,6 +45,7 @@
 import org.hisp.dhis.patient.Patient;
 import org.hisp.dhis.patientdatavalue.PatientDataValue;
 import org.hisp.dhis.patientdatavalue.PatientDataValueService;
+import org.hisp.dhis.patientreport.TabularReportColumn;
 import org.hisp.dhis.system.grid.ListGrid;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -195,7 +196,7 @@
         return programStageInstanceStore.get( patient, completed );
     }
 
-    public Grid getTabularReport( ProgramStage programStage, List<String> searchingKeys,
+    public Grid getTabularReport( ProgramStage programStage, List<TabularReportColumn> columns,
         Collection<Integer> organisationUnits, int level, Date startDate, Date endDate, boolean descOrder, Integer min,
         Integer max )
     {
@@ -204,15 +205,15 @@
         Map<Integer, OrganisationUnitLevel> orgUnitLevelMap = organisationUnitService.getOrganisationUnitLevelMap();
 
         return programStageInstanceStore.getTabularReport( programStage, orgUnitLevelMap, organisationUnits,
-            searchingKeys, level, maxLevel, startDate, endDate, descOrder, min, max );
+            columns, level, maxLevel, startDate, endDate, descOrder, min, max );
     }
 
-    public int getTabularReportCount( ProgramStage programStage, List<String> searchingKeys,
+    public int getTabularReportCount( ProgramStage programStage, List<TabularReportColumn> columns,
         Collection<Integer> organisationUnits, int level, Date startDate, Date endDate )
     {
         int maxLevel = organisationUnitService.getMaxOfOrganisationUnitLevels();
 
-        return programStageInstanceStore.getTabularReportCount( programStage, searchingKeys, organisationUnits, level,
+        return programStageInstanceStore.getTabularReportCount( programStage, columns, organisationUnits, level,
             maxLevel, startDate, endDate );
     }
 

=== 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-06-24 13:42:21 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java	2012-06-24 14:29:16 +0000
@@ -26,12 +26,6 @@
  */
 package org.hisp.dhis.program.hibernate;
 
-import static org.hisp.dhis.patientreport.PatientTabularReport.PREFIX_DATA_ELEMENT;
-import static org.hisp.dhis.patientreport.PatientTabularReport.PREFIX_FIXED_ATTRIBUTE;
-import static org.hisp.dhis.patientreport.PatientTabularReport.PREFIX_IDENTIFIER_TYPE;
-import static org.hisp.dhis.patientreport.PatientTabularReport.PREFIX_PATIENT_ATTRIBUTE;
-import static org.hisp.dhis.system.util.TextUtils.lower;
-
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Date;
@@ -53,6 +47,7 @@
 import org.hisp.dhis.patient.Patient;
 import org.hisp.dhis.patient.PatientAttributeService;
 import org.hisp.dhis.patient.PatientIdentifierTypeService;
+import org.hisp.dhis.patientreport.TabularReportColumn;
 import org.hisp.dhis.program.ProgramInstance;
 import org.hisp.dhis.program.ProgramStage;
 import org.hisp.dhis.program.ProgramStageInstance;
@@ -92,27 +87,6 @@
         this.statementBuilder = statementBuilder;
     }
 
-    private PatientIdentifierTypeService patientIdentifierTypeService;
-
-    public void setPatientIdentifierTypeService( PatientIdentifierTypeService patientIdentifierTypeService )
-    {
-        this.patientIdentifierTypeService = patientIdentifierTypeService;
-    }
-
-    private PatientAttributeService patientAttributeService;
-
-    public void setPatientAttributeService( PatientAttributeService patientAttributeService )
-    {
-        this.patientAttributeService = patientAttributeService;
-    }
-
-    private DataElementService dataElementService;
-
-    public void setDataElementService( DataElementService dataElementService )
-    {
-        this.dataElementService = dataElementService;
-    }
-
     // -------------------------------------------------------------------------
     // Implemented methods
     // -------------------------------------------------------------------------
@@ -222,7 +196,7 @@
     }
 
     public Grid getTabularReport( ProgramStage programStage, Map<Integer, OrganisationUnitLevel> orgUnitLevelMap,
-        Collection<Integer> orgUnits, List<String> searchKeys, int level, int maxLevel, Date startDate,
+        Collection<Integer> orgUnits, List<TabularReportColumn> columns, int level, int maxLevel, Date startDate,
         Date endDate, boolean descOrder, Integer min, Integer max )
     {
         // ---------------------------------------------------------------------
@@ -238,48 +212,20 @@
         {
             int l = i + 1;
             String name = orgUnitLevelMap.containsKey( l ) ? orgUnitLevelMap.get( l ).getName() : "Level " + l;
-
+            
             grid.addHeader( new GridHeader( name, false, true ) );
         }
 
-        for ( String searchKey : searchKeys )
+        for ( TabularReportColumn column : columns )
         {
-            String[] values = searchKey.split( "_" );
-            String objectType = values[0];
-
-            boolean hidden = Boolean.parseBoolean( values[2] );
-            String name = "";
-
-            if ( objectType.equals( PREFIX_FIXED_ATTRIBUTE ) )
-            {
-                name = values[1];
-            }
-            else
-            {
-                int objectId = Integer.parseInt( values[1] );
-
-                if ( objectType.equals( PREFIX_IDENTIFIER_TYPE ) )
-                {
-                    name = patientIdentifierTypeService.getPatientIdentifierType( objectId ).getName();
-                }
-                else if ( objectType.equals( PREFIX_PATIENT_ATTRIBUTE ) )
-                {
-                    name = patientAttributeService.getPatientAttribute( objectId ).getName();
-                }
-                else if ( objectType.equals( PREFIX_DATA_ELEMENT ) )
-                {
-                    name = dataElementService.getDataElement( objectId ).getName();
-                }
-            }
-
-            grid.addHeader( new GridHeader( name, hidden, true ) );
+            grid.addHeader( new GridHeader( column.getName(), column.isHidden(), true ) );
         }
 
         // ---------------------------------------------------------------------
         // Get SQL and build grid 
         // ---------------------------------------------------------------------
         
-        String sql = getTabularReportSql( false, programStage, searchKeys, orgUnits, level, maxLevel, startDate,
+        String sql = getTabularReportSql( false, programStage, columns, orgUnits, level, maxLevel, startDate,
             endDate, descOrder, min, max );
 
         SqlRowSet rowSet = jdbcTemplate.queryForRowSet( sql );
@@ -289,10 +235,10 @@
         return grid;
     }
 
-    public int getTabularReportCount( ProgramStage programStage, List<String> searchKeys,
+    public int getTabularReportCount( ProgramStage programStage, List<TabularReportColumn> columns,
         Collection<Integer> organisationUnits, int level, int maxLevel, Date startDate, Date endDate )
     {
-        String sql = getTabularReportSql( true, programStage, searchKeys, organisationUnits, level, maxLevel,
+        String sql = getTabularReportSql( true, programStage, columns, organisationUnits, level, maxLevel,
             startDate, endDate, false, null, null );
 
         return jdbcTemplate.queryForInt( sql );
@@ -302,10 +248,7 @@
     // Supportive methods
     // -------------------------------------------------------------------------
 
-    /**
-     * Search values on format type_id/name_hidden_='query'
-     */
-    private String getTabularReportSql( boolean count, ProgramStage programStage, List<String> searchKeys,
+    private String getTabularReportSql( boolean count, ProgramStage programStage, List<TabularReportColumn> columns,
         Collection<Integer> orgUnits, int level, int maxLevel, Date startDate, Date endDate, boolean descOrder,
         Integer min, Integer max )
     {
@@ -321,57 +264,49 @@
             sql += "(select name from organisationunit where organisationunitid=ous.idlevel" + l + ") as level_" + i + ",";
         }
 
-        for ( String searchKey : searchKeys )
+        for ( TabularReportColumn column : columns )
         {
-            String[] values = searchKey.split( "_" );
-            String objectType = values[0];
-
-            if ( objectType.equals( PREFIX_FIXED_ATTRIBUTE ) )
-            {
-                sql += "p." + values[1] + ",";
-
-                if ( values.length == 4 )
-                {
-                    where += operator + "lower(" + values[1] + ") " + lower( values[3] ) + " ";
-                    operator = "and ";
-                }
-            }
-            else
-            {
-                int objectId = Integer.parseInt( values[1] );
-
-                if ( objectType.equals( PREFIX_IDENTIFIER_TYPE ) )
-                {
-                    sql += "(select identifier from patientidentifier where patientid=p.patientid and patientidentifiertypeid="
-                        + objectId + ") as identifier_" + objectId + ",";
-
-                    if ( values.length == 4 )
-                    {
-                        where += operator + "lower(identifier_" + objectId + ") " + lower( values[3] ) + " ";
-                        operator = "and ";
-                    }
-                }
-                else if ( objectType.equals( PREFIX_PATIENT_ATTRIBUTE ) )
-                {
-                    sql += "(select value from patientattributevalue where patientid=p.patientid and patientattributeid="
-                        + objectId + ") as attribute_" + objectId + ",";
-                    
-                    if ( values.length == 4 )
-                    {
-                        where += operator + "lower(attribute_" + objectId + ") " + lower( values[3] ) + " ";
-                        operator = "and ";
-                    }
-                }
-                else if ( objectType.equals( PREFIX_DATA_ELEMENT ) )
-                {
-                    sql += "(select value from patientdatavalue where programstageinstanceid=psi.programstageinstanceid and dataelementid="
-                        + objectId + ") as element_" + objectId + ",";
-
-                    if ( values.length == 4 )
-                    {
-                        where += operator + "lower(element_" + objectId + ") " + lower( values[3] ) + " ";
-                        operator = "and ";
-                    }
+            if ( column.isFixedAttribute() )
+            {
+                sql += "p." + column.getIdentifier() + ",";
+
+                if ( column.hasQuery() )
+                {
+                    where += operator + "lower(" + column.getIdentifier() + ") " + column.getQuery() + " ";
+                    operator = "and ";
+                }
+            }
+            else if ( column.isIdentifierType() )
+            {
+                sql += "(select identifier from patientidentifier where patientid=p.patientid and patientidentifiertypeid="
+                    + column.getIdentifier() + ") as identifier_" + column.getIdentifier() + ",";
+
+                if ( column.hasQuery() )
+                {
+                    where += operator + "lower(identifier_" + column.getIdentifier() + ") " + column.getQuery() + " ";
+                    operator = "and ";
+                }
+            }
+            else if ( column.isDynamicAttribute() )
+            {
+                sql += "(select value from patientattributevalue where patientid=p.patientid and patientattributeid="
+                    + column.getIdentifier() + ") as attribute_" + column.getIdentifier() + ",";
+                
+                if ( column.hasQuery() )
+                {
+                    where += operator + "lower(attribute_" + column.getIdentifier() + ") " + column.getQuery() + " ";
+                    operator = "and ";
+                }
+            }
+            else if ( column.isDataElement() )
+            {
+                sql += "(select value from patientdatavalue where programstageinstanceid=psi.programstageinstanceid and dataelementid="
+                    + column.getIdentifier() + ") as element_" + column.getIdentifier() + ",";
+
+                if ( column.hasQuery() )
+                {
+                    where += operator + "lower(element_" + column.getIdentifier() + ") " + column.getQuery() + " ";
+                    operator = "and ";
                 }
             }
         }
@@ -412,8 +347,7 @@
         sql += (min != null && max != null) ? statementBuilder.limitRecord( min, max ) : "";
         sql += ") as tabular ";// TODO page size
 
-        // filters
-        sql += where;
+        sql += where; // filters
 
         sql = sql.substring( 0, sql.length() - 1 ) + " "; // Remove last comma
 

=== 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-06-14 13:07:22 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/META-INF/dhis/beans.xml	2012-06-24 14:29:16 +0000
@@ -39,10 +39,6 @@
 		<property name="sessionFactory" ref="sessionFactory" />
 		<property name="jdbcTemplate" ref="jdbcTemplate" />
 		<property name="statementBuilder" ref="statementBuilder" />
-		<property name="patientAttributeService"
-			ref="org.hisp.dhis.patient.PatientAttributeService" />
-		<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
-		<property name="patientIdentifierTypeService" ref="org.hisp.dhis.patient.PatientIdentifierTypeService" />
 	</bean>
 
 	<bean id="org.hisp.dhis.program.ProgramInstanceStore"

=== 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-06-24 13:42:21 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateTabularReportAction.java	2012-06-24 14:29:16 +0000
@@ -27,9 +27,7 @@
 
 package org.hisp.dhis.caseentry.action.report;
 
-import static org.hisp.dhis.patientreport.PatientTabularReport.PREFIX_DATA_ELEMENT;
-import static org.hisp.dhis.patientreport.PatientTabularReport.PREFIX_PATIENT_ATTRIBUTE;
-import static org.hisp.dhis.patientreport.PatientTabularReport.VALUE_TYPE_OPTION_SET;
+import static org.hisp.dhis.patientreport.PatientTabularReport.*;
 
 import java.util.ArrayList;
 import java.util.Collection;
@@ -52,11 +50,14 @@
 import org.hisp.dhis.patient.PatientAttributeOption;
 import org.hisp.dhis.patient.PatientAttributeService;
 import org.hisp.dhis.patient.PatientIdentifierType;
+import org.hisp.dhis.patient.PatientIdentifierTypeService;
+import org.hisp.dhis.patientreport.TabularReportColumn;
 import org.hisp.dhis.program.ProgramStage;
 import org.hisp.dhis.program.ProgramStageInstance;
 import org.hisp.dhis.program.ProgramStageInstanceService;
 import org.hisp.dhis.program.ProgramStageService;
 import org.hisp.dhis.system.util.ConversionUtils;
+import org.hisp.dhis.system.util.TextUtils;
 
 /**
  * @author Chau Thu Tran
@@ -104,6 +105,13 @@
     {
         this.patientAttributeService = patientAttributeService;
     }
+    
+    private PatientIdentifierTypeService patientIdentifierTypeService;
+
+    public void setPatientIdentifierTypeService( PatientIdentifierTypeService patientIdentifierTypeService )
+    {
+        this.patientIdentifierTypeService = patientIdentifierTypeService;
+    }
 
     // -------------------------------------------------------------------------
     // Input/Output
@@ -295,7 +303,7 @@
 
         Date startValue = format.parseDate( startDate );
         Date endValue = format.parseDate( endDate );
-        getParams();
+        List<TabularReportColumn> columns = getTableColumns();
         
         // ---------------------------------------------------------------------
         // Generate tabular report
@@ -303,7 +311,7 @@
 
         if ( type == null ) // Tabular report
         {
-            int totalRecords = programStageInstanceService.getTabularReportCount( programStage, searchingValues,
+            int totalRecords = programStageInstanceService.getTabularReportCount( programStage, columns,
                 organisationUnits, level, startValue, endValue );
 
             total = getNumberOfPages( totalRecords );
@@ -311,12 +319,12 @@
             this.paging = createPaging( totalRecords );
             // total = paging.getTotal(); //TODO
 
-            grid = programStageInstanceService.getTabularReport( programStage, searchingValues, organisationUnits,
+            grid = programStageInstanceService.getTabularReport( programStage, columns, organisationUnits,
                 level, startValue, endValue, !orderByOrgunitAsc, paging.getStartPos(), paging.getPageSize() );
         }
         else // Download as Excel        
         {
-            grid = programStageInstanceService.getTabularReport( programStage, searchingValues, organisationUnits,
+            grid = programStageInstanceService.getTabularReport( programStage, columns, organisationUnits,
                 level, startValue, endValue, !orderByOrgunitAsc, null, null );
         }
         
@@ -336,16 +344,34 @@
         return (totalRecord % pageSize == 0) ? (totalRecord / pageSize) : (totalRecord / pageSize + 1);
     }
 
-    private void getParams()
+    private List<TabularReportColumn> getTableColumns()
     {
+        List<TabularReportColumn> columns = new ArrayList<TabularReportColumn>();
+        
         int index = 0;
         
         for ( String searchValue : searchingValues )
         {
             String[] values = searchValue.split( "_" );
             String prefix = values[0];
+            
+            TabularReportColumn column = new TabularReportColumn();
+            column.setPrefix( prefix );
+            column.setIdentifier( values[1] );
+            column.setHidden( Boolean.parseBoolean( values[2] ) );            
+            column.setQuery( values.length == 4 ? TextUtils.lower( values[3] ) : null );
 
-            if ( prefix.equals( PREFIX_PATIENT_ATTRIBUTE ) )
+            if ( PREFIX_FIXED_ATTRIBUTE.equals( prefix ) )
+            {
+                column.setName( values[1] );
+            }
+            else if ( PREFIX_IDENTIFIER_TYPE.equals( prefix ) )
+            {
+                PatientIdentifierType identifierType = patientIdentifierTypeService.getPatientIdentifierType( column.getIdentifierAsInt() );
+                
+                column.setName( identifierType.getName() );
+            }
+            else if ( PREFIX_PATIENT_ATTRIBUTE.equals( prefix ) )
             {
                 int objectId = Integer.parseInt( values[1] );
                 PatientAttribute attribute = patientAttributeService.getPatientAttribute( objectId );
@@ -353,8 +379,10 @@
                 
                 valueTypes.add( attribute.getValueType() );
                 mapSuggestedValues.put( index, getSuggestedAttributeValues( attribute ) );
+                
+                column.setName( attribute.getName() );
             }
-            else if ( prefix.equals( PREFIX_DATA_ELEMENT ) )
+            else if ( PREFIX_DATA_ELEMENT.equals( prefix ) )
             {
                 int objectId = Integer.parseInt( values[1] );
                 DataElement dataElement = dataElementService.getDataElement( objectId );
@@ -363,10 +391,16 @@
                 String valueType = dataElement.getOptionSet() != null ? VALUE_TYPE_OPTION_SET : dataElement.getType();
                 valueTypes.add( valueType );
                 mapSuggestedValues.put( index, getSuggestedDataElementValues( dataElement ) );
+                
+                column.setName( dataElement.getName() );
             }
             
+            columns.add( column );
+            
             index++;
         }
+        
+        return columns;
     }
 
     private List<String> getSuggestedAttributeValues( PatientAttribute patientAttribute )

=== 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-06-23 11:05:13 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml	2012-06-24 14:29:16 +0000
@@ -876,6 +876,7 @@
 		<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
 		<property name="patientAttributeService"
 			ref="org.hisp.dhis.patient.PatientAttributeService" />
+		<property name="patientIdentifierTypeService" ref="org.hisp.dhis.patient.PatientIdentifierTypeService" />
 	</bean>
 
 	<bean