← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11111: Add more option Use-data-element-form-name in tabular report. This option is enabled as default.

 

------------------------------------------------------------
revno: 11111
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-05-30 16:08:10 +0700
message:
  Add more option Use-data-element-form-name in tabular report. This option is enabled as default.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientreport/PatientAggregateReport.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientreport/PatientTabularReport.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.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/org/hisp/dhis/patientreport/hibernate/PatientTabularReport.hbm.xml
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateAggregateReportAction.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/SaveAggregateReportAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/SaveTabularReportAction.java
  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/webapp/dhis-web-caseentry/app/app.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/index.html
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/i18n.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularAggregateReport.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularReport.vm


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

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientreport/PatientAggregateReport.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientreport/PatientAggregateReport.java	2013-01-30 09:34:29 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientreport/PatientAggregateReport.java	2013-05-30 09:08:10 +0000
@@ -120,6 +120,8 @@
 
     private Boolean userOrganisationUnitChildren;
 
+    private Boolean useFormNameDataElement;
+    
     // User created
 
     private User user;
@@ -307,4 +309,14 @@
         this.deSum = deSum;
     }
 
+    public Boolean getUseFormNameDataElement()
+    {
+        return useFormNameDataElement;
+    }
+
+    public void setUseFormNameDataElement( Boolean useFormNameDataElement )
+    {
+        this.useFormNameDataElement = useFormNameDataElement;
+    }
+
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientreport/PatientTabularReport.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientreport/PatientTabularReport.java	2013-05-23 16:04:26 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientreport/PatientTabularReport.java	2013-05-30 09:08:10 +0000
@@ -89,6 +89,8 @@
     private List<String> filterValues = new ArrayList<String>();
     
     private Boolean displayOrgunitCode;
+    
+    private Boolean useFormNameDataElement;
 
     // -------------------------------------------------------------------------
     // Constructors
@@ -112,6 +114,16 @@
         return startDate;
     }
 
+    public Boolean getUseFormNameDataElement()
+    {
+        return useFormNameDataElement;
+    }
+
+    public void setUseFormNameDataElement( Boolean useFormNameDataElement )
+    {
+        this.useFormNameDataElement = useFormNameDataElement;
+    }
+
     public void setStartDate( Date startDate )
     {
         this.startDate = startDate;

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java	2013-05-23 16:04:26 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java	2013-05-30 09:08:10 +0000
@@ -95,7 +95,7 @@
 
     int getTabularReportCount( Boolean anonynousEntryForm, ProgramStage programStage,
         List<TabularReportColumn> columns, Collection<Integer> organisationUnits, int level, Boolean completed,
-        Boolean displayOrgunitCode, Date startDate, Date endDate );
+        Date startDate, Date endDate );
 
     List<Grid> getProgramStageInstancesReport( ProgramInstance programInstance, I18nFormat format, I18n i18n );
 
@@ -114,7 +114,7 @@
     Grid getAggregateReport( int position, ProgramStage programStage, Collection<Integer> orgunitIds,
         String facilityLB, Integer deGroupBy, Integer deSum, Map<Integer, Collection<String>> deFilters,
         List<Period> periods, String aggregateType, Integer limit, Boolean useCompletedEvents, Boolean displayTotals,
-        I18nFormat format, I18n i18n );
+        Boolean useFormNameDataElement, I18nFormat format, I18n i18n );
 
     // -------------------------------------------------------------------------
     // Statistical

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java	2013-05-23 16:04:26 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java	2013-05-30 09:08:10 +0000
@@ -89,7 +89,7 @@
 
     int getTabularReportCount( Boolean anonynousEntryForm, ProgramStage programStage,
         List<TabularReportColumn> columns, Collection<Integer> organisationUnits, int level, int maxLevel,
-        Date startDate, Date endDate, Boolean completed, Boolean displayOrgunitCode  );
+        Date startDate, Date endDate, Boolean completed );
 
     void removeEmptyEvents( ProgramStage programStage, OrganisationUnit organisationUnit );
 
@@ -106,7 +106,7 @@
     Grid getAggregateReport( int position, ProgramStage programStage, Collection<Integer> orgunitIds,
         String facilityLB, Integer deGroupBy, Integer deSum, Map<Integer, Collection<String>> deFilters,
         List<Period> periods, String aggregateType, Integer limit, Boolean useCompletedEvents, Boolean displayTotals,
-        I18nFormat format, I18n i18n );
+        Boolean useFormNameDataElement, I18nFormat format, I18n i18n );
 
     Collection<ProgramStageInstance> get( Program program, Collection<Integer> orgunitIds, Date startDate,
         Date endDate, Boolean completed );

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java	2013-05-30 06:08:13 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java	2013-05-30 09:08:10 +0000
@@ -214,6 +214,8 @@
         executeSql( "ALTER TABLE patient ALTER COLUMN underage DROP NOT NULL");
         executeSql( "ALTER TABLE program ALTER COLUMN dateofenrollmentdescription DROP NOT NULL");
         executeSql( "UPDATE program SET displayOnAllOrgunit=true where displayOnAllOrgunit is null" );
+        executeSql( "UPDATE program SET useFormNameDataElement=true where useFormNameDataElement is null" );
+        
         
     }
 

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java	2013-05-23 16:04:26 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java	2013-05-30 09:08:10 +0000
@@ -176,25 +176,30 @@
         return programStageInstanceStore.get( patient, completed );
     }
 
-    public Grid getTabularReport( Boolean anonynousEntryForm, ProgramStage programStage, List<TabularReportColumn> columns,
-        Collection<Integer> organisationUnits, int level, Date startDate, Date endDate, boolean descOrder,
-        Boolean completed, Boolean accessPrivateInfo, Boolean displayOrgunitCode, Integer min, Integer max, I18n i18n )
+    @Override
+    public Grid getTabularReport( Boolean anonynousEntryForm, ProgramStage programStage,
+        List<TabularReportColumn> columns, Collection<Integer> organisationUnits, int level, Date startDate,
+        Date endDate, boolean descOrder, Boolean completed, Boolean accessPrivateInfo, Boolean displayOrgunitCode,
+        Integer min, Integer max, I18n i18n )
     {
         int maxLevel = organisationUnitService.getMaxOfOrganisationUnitLevels();
 
         Map<Integer, OrganisationUnitLevel> orgUnitLevelMap = organisationUnitService.getOrganisationUnitLevelMap();
 
-        return programStageInstanceStore.getTabularReport( anonynousEntryForm, programStage, orgUnitLevelMap, organisationUnits, columns,
-            level, maxLevel, startDate, endDate, descOrder, completed, accessPrivateInfo, displayOrgunitCode, min, max, i18n );
+        return programStageInstanceStore.getTabularReport( anonynousEntryForm, programStage, orgUnitLevelMap,
+            organisationUnits, columns, level, maxLevel, startDate, endDate, descOrder, completed, accessPrivateInfo,
+            displayOrgunitCode, min, max, i18n );
     }
 
-    public int getTabularReportCount( Boolean anonynousEntryForm, ProgramStage programStage, List<TabularReportColumn> columns,
-        Collection<Integer> organisationUnits, int level, Boolean completed, Boolean displayOrgunitCode, Date startDate, Date endDate )
+    @Override
+    public int getTabularReportCount( Boolean anonynousEntryForm, ProgramStage programStage,
+        List<TabularReportColumn> columns, Collection<Integer> organisationUnits, int level, Boolean completed,
+        Date startDate, Date endDate )
     {
         int maxLevel = organisationUnitService.getMaxOfOrganisationUnitLevels();
 
-        return programStageInstanceStore.getTabularReportCount( anonynousEntryForm, programStage, columns, organisationUnits, level,
-            maxLevel, startDate, endDate, completed, displayOrgunitCode );
+        return programStageInstanceStore.getTabularReportCount( anonynousEntryForm, programStage, columns,
+            organisationUnits, level, maxLevel, startDate, endDate, completed );
     }
 
     public List<Grid> getProgramStageInstancesReport( ProgramInstance programInstance, I18nFormat format, I18n i18n )
@@ -346,7 +351,7 @@
         grid.addValue( "" );
 
         // Total programs discontinued (un-enrollments)
-        
+
         int totalDiscontinued = programInstanceService.countProgramInstancesByStatus( ProgramInstance.STATUS_CANCELLED,
             program, orgunitIds, startDate, endDate );
         grid.addRow();
@@ -484,10 +489,10 @@
     public Grid getAggregateReport( int position, ProgramStage programStage, Collection<Integer> orgunitIds,
         String facilityLB, Integer deGroupBy, Integer deSum, Map<Integer, Collection<String>> deFilters,
         List<Period> periods, String aggregateType, Integer limit, Boolean useCompletedEvents, Boolean displayTotals,
-        I18nFormat format, I18n i18n )
+        Boolean useFormNameDataElement, I18nFormat format, I18n i18n )
     {
         return programStageInstanceStore.getAggregateReport( position, programStage, orgunitIds, facilityLB, deGroupBy,
-            deSum, deFilters, periods, aggregateType, limit, useCompletedEvents, displayTotals, format, i18n );
+            deSum, deFilters, periods, aggregateType, limit, useCompletedEvents, displayTotals, useFormNameDataElement, format, i18n );
     }
 
     @Override
@@ -509,9 +514,10 @@
     {
         return programStageInstanceStore.getOrgunitIds( startDate, endDate );
     }
-    
+
     @Override
-    public Grid getCompletenessProgramStageInstance( OrganisationUnit orgunit, Program program, String startDate, String endDate, I18n i18n )
+    public Grid getCompletenessProgramStageInstance( OrganisationUnit orgunit, Program program, String startDate,
+        String endDate, I18n i18n )
     {
         return programStageInstanceStore.getCompleteness( orgunit, program, startDate, endDate, i18n );
     }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java	2013-05-24 05:22:57 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java	2013-05-30 09:08:10 +0000
@@ -257,6 +257,7 @@
             .setFirstResult( min ).setMaxResults( max ).list();
     }
 
+    @Override
     public Grid getTabularReport( Boolean anonynousEntryForm, ProgramStage programStage,
         Map<Integer, OrganisationUnitLevel> orgUnitLevelMap, Collection<Integer> orgUnits,
         List<TabularReportColumn> columns, int level, int maxLevel, Date startDate, Date endDate, boolean descOrder,
@@ -351,10 +352,10 @@
 
     public int getTabularReportCount( Boolean anonynousEntryForm, ProgramStage programStage,
         List<TabularReportColumn> columns, Collection<Integer> organisationUnits, int level, int maxLevel,
-        Date startDate, Date endDate, Boolean completed, Boolean displayOrgunitCode )
+        Date startDate, Date endDate, Boolean completed )
     {
         String sql = getTabularReportSql( anonynousEntryForm, true, programStage, columns, organisationUnits, level,
-            maxLevel, startDate, endDate, false, completed, null, displayOrgunitCode, null, null );
+            maxLevel, startDate, endDate, false, completed, null, null, null, null );
 
         return jdbcTemplate.queryForObject( sql, Integer.class );
     }
@@ -484,7 +485,7 @@
     public Grid getAggregateReport( int position, ProgramStage programStage, Collection<Integer> orgunitIds,
         String facilityLB, Integer deGroupBy, Integer deSum, Map<Integer, Collection<String>> deFilters,
         List<Period> periods, String aggregateType, Integer limit, Boolean useCompletedEvents, Boolean displayTotals,
-        I18nFormat format, I18n i18n )
+        Boolean useFormNameDataElement, I18nFormat format, I18n i18n )
     {
         String sql = "";
         String filterSQL = filterSQLStatement( deFilters );
@@ -499,8 +500,13 @@
         String subTitle = " ";
         if ( deSum != null )
         {
-            subTitle = i18n.getString( "group_by" ) + ": "
-                + dataElementService.getDataElement( deSum ).getDisplayName() + "; ";
+            DataElement dataElement = dataElementService.getDataElement( deSum );
+            String dename = dataElement.getDisplayName();
+            if ( useFormNameDataElement != null || useFormNameDataElement )
+            {
+                dename = dataElement.getFormNameFallback();
+            }
+            subTitle = i18n.getString( "group_by" ) + ": " + dename + "; ";
         }
 
         // Filter is only one orgunit
@@ -645,7 +651,7 @@
         else if ( position == PatientAggregateReport.POSITION_ROW_DATA_COLUMN_PERIOD && deGroupBy != null )
         {
             sql = getAggregateReportSQL9( programStage, orgunitIds.iterator().next(), facilityLB, filterSQL, deGroupBy,
-                deSum, periods, aggregateType, limit, useCompletedEvents, format );
+                deSum, periods, aggregateType, limit, useCompletedEvents, useFormNameDataElement, format );
         }
 
         // Type = 6 && With group-by
@@ -888,7 +894,7 @@
 
     private String getTabularReportSql( Boolean anonynousEntryForm, boolean count, ProgramStage programStage,
         List<TabularReportColumn> columns, Collection<Integer> orgUnits, int level, int maxLevel, Date startDate,
-        Date endDate, boolean descOrder, Boolean completed, Boolean accessPrivateInfo, Boolean displayOrgunitCode,
+        Date endDate, Boolean descOrder, Boolean completed, Boolean accessPrivateInfo, Boolean displayOrgunitCode,
         Integer min, Integer max )
     {
         Set<String> deKeys = new HashSet<String>();
@@ -1074,7 +1080,7 @@
         }
 
         sql += "psi.executiondate ";
-        sql += descOrder ? "desc " : "";
+        sql += (descOrder == null || descOrder) ? "desc " : "";
         sql += ") as tabular ";
         sql += where; // filters
         sql = sql.substring( 0, sql.length() - 1 ) + " "; // Remove last comma
@@ -1917,7 +1923,7 @@
      **/
     private String getAggregateReportSQL9( ProgramStage programStage, Integer root, String facilityLB,
         String filterSQL, Integer deGroupBy, Integer deSum, Collection<Period> periods, String aggregateType,
-        Integer limit, Boolean useCompletedEvents, I18nFormat format )
+        Integer limit, Boolean useCompletedEvents, Boolean useFormNameDataElement,I18nFormat format )
     {
         String sql = "";
         Collection<Integer> allOrgunitIds = getOrganisationUnits( root, facilityLB );
@@ -1956,7 +1962,13 @@
 
         String firstPeriodName = "";
 
-        String groupByName = dataElementService.getDataElement( deGroupBy ).getDisplayName();
+        DataElement dataElement = dataElementService.getDataElement( deGroupBy );
+        String groupByName = dataElement.getDisplayName();
+        if ( useFormNameDataElement != null || useFormNameDataElement )
+        {
+            groupByName = dataElement.getFormNameFallback();
+        }
+        
         for ( String deValue : deValues )
         {
             sql += "(SELECT DISTINCT '" + deValue + "' as \"" + groupByName + "\", ";

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patientreport/hibernate/PatientTabularReport.hbm.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patientreport/hibernate/PatientTabularReport.hbm.xml	2013-05-23 16:04:26 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patientreport/hibernate/PatientTabularReport.hbm.xml	2013-05-30 09:08:10 +0000
@@ -51,6 +51,8 @@
     
     <property name="displayOrgunitCode" />
     
+    <property name="useFormNameDataElement" />
+    
     <!-- Access properties -->
    
     <many-to-one name="user" class="org.hisp.dhis.user.User"

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateAggregateReportAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateAggregateReportAction.java	2013-05-15 06:28:45 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateAggregateReportAction.java	2013-05-30 09:08:10 +0000
@@ -236,6 +236,13 @@
         this.displayTotals = displayTotals;
     }
 
+    private Boolean useFormNameDataElement;
+
+    public void setUseFormNameDataElement( Boolean useFormNameDataElement )
+    {
+        this.useFormNameDataElement = useFormNameDataElement;
+    }
+
     // -------------------------------------------------------------------------
     // Output
     // -------------------------------------------------------------------------
@@ -253,8 +260,8 @@
 
     public String execute()
     {
-        displayTotals = ( displayTotals == null )? false : displayTotals;
-        
+        displayTotals = (displayTotals == null) ? false : displayTotals;
+
         // ---------------------------------------------------------------------
         // Get user orgunits
         // ---------------------------------------------------------------------
@@ -346,7 +353,8 @@
         }
 
         grid = programStageInstanceService.getAggregateReport( position, programStage, orgunitIds, facilityLB,
-            deGroupBy, deSum, deFilterMap, periods, aggregateType, limitRecords, useCompletedEvents, displayTotals, format, i18n );
+            deGroupBy, deSum, deFilterMap, periods, aggregateType, limitRecords, useCompletedEvents, displayTotals,
+            useFormNameDataElement, format, i18n );
 
         return type == null ? SUCCESS : type;
     }
@@ -384,7 +392,7 @@
             rp.clear().setLast3Months( true );
             periods.addAll( periodService.reloadPeriods( rp.getRelativePeriods() ) );
         }
-        
+
         if ( relativePeriods.contains( "last12Months" ) )
         {
             rp.clear().setLast12Months( true );

=== 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	2013-05-23 16:04:26 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateTabularReportAction.java	2013-05-30 09:08:10 +0000
@@ -27,7 +27,12 @@
 
 package org.hisp.dhis.caseentry.action.report;
 
-import static org.hisp.dhis.patientreport.PatientTabularReport.*;
+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_NUMBER_DATA_ELEMENT;
+import static org.hisp.dhis.patientreport.PatientTabularReport.PREFIX_PATIENT_ATTRIBUTE;
+import static org.hisp.dhis.patientreport.PatientTabularReport.VALUE_TYPE_OPTION_SET;
 
 import java.util.ArrayList;
 import java.util.Collection;
@@ -311,6 +316,13 @@
         this.displayOrgunitCode = displayOrgunitCode;
     }
 
+    private Boolean useFormNameDataElement;
+
+    public void setUseFormNameDataElement( Boolean useFormNameDataElement )
+    {
+        this.useFormNameDataElement = useFormNameDataElement;
+    }
+
     private boolean accessPrivateInfo = false;
 
     // -------------------------------------------------------------------------
@@ -412,7 +424,7 @@
             if ( type == null ) // Tabular report
             {
                 totalRecords = programStageInstanceService.getTabularReportCount( anonynousEntryForm, programStage,
-                    columns, organisationUnits, level, useCompletedEvents, displayOrgunitCode, startValue, endValue );
+                    columns, organisationUnits, level, useCompletedEvents, startValue, endValue );
 
                 total = getNumberOfPages( totalRecords );
 
@@ -531,7 +543,15 @@
                     {
                         column.setDateType( true );
                     }
-                    column.setName( dataElement.getFormNameFallback() );
+                    
+                    if ( useFormNameDataElement != null && useFormNameDataElement )
+                    {
+                        column.setName( dataElement.getFormNameFallback() );
+                    }
+                    else
+                    {
+                        column.setName( dataElement.getDisplayName() );  
+                    }
                 }
 
                 columns.add( column );

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/SaveAggregateReportAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/SaveAggregateReportAction.java	2013-02-28 04:34:35 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/SaveAggregateReportAction.java	2013-05-30 09:08:10 +0000
@@ -220,7 +220,14 @@
     {
         this.userOrganisationUnitChildren = userOrganisationUnitChildren;
     }
-
+    
+    private Boolean useFormNameDataElement;
+    
+    public void setUseFormNameDataElement( Boolean useFormNameDataElement )
+    {
+        this.useFormNameDataElement = useFormNameDataElement;
+    }
+    
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -260,7 +267,8 @@
         aggregateReport.setFacilityLB( facilityLB );
         aggregateReport.setLimitRecords( limitRecords );
         aggregateReport.setPosition( position );
-
+        aggregateReport.setUseFormNameDataElement( useFormNameDataElement );
+        
         if ( deGroupBy != null )
         {
             aggregateReport.setDeGroupBy( dataElementService.getDataElement( deGroupBy ) );

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/SaveTabularReportAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/SaveTabularReportAction.java	2013-05-24 04:19:07 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/SaveTabularReportAction.java	2013-05-30 09:08:10 +0000
@@ -121,6 +121,8 @@
 
     private Boolean displayOrgunitCode;
 
+    private Boolean useFormNameDataElement;
+
     // -------------------------------------------------------------------------
     // Setters
     // -------------------------------------------------------------------------
@@ -190,6 +192,11 @@
         this.userOrganisationUnitChildren = userOrganisationUnitChildren;
     }
 
+    public void setUseFormNameDataElement( Boolean useFormNameDataElement )
+    {
+        this.useFormNameDataElement = useFormNameDataElement;
+    }
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -200,8 +207,9 @@
     {
         userOrganisationUnit = (userOrganisationUnit == null) ? false : userOrganisationUnit;
         userOrganisationUnitChildren = (userOrganisationUnitChildren == null) ? false : userOrganisationUnitChildren;
-        displayOrgunitCode = (displayOrgunitCode == null) ? false : displayOrgunitCode;;
-       
+        displayOrgunitCode = (displayOrgunitCode == null) ? false : displayOrgunitCode;
+        ;
+
         Set<OrganisationUnit> orgunits = new HashSet<OrganisationUnit>(
             organisationUnitService.getOrganisationUnits( orgunitIds ) );
 
@@ -220,6 +228,7 @@
         tabularReport.setSortedOrgunitAsc( orderByOrgunitAsc );
         tabularReport.setUser( currentUserService.getCurrentUser() );
         tabularReport.setDisplayOrgunitCode( displayOrgunitCode );
+        tabularReport.setUseFormNameDataElement( useFormNameDataElement );
 
         if ( useCompletedEvents != null )
         {

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2013-05-29 08:36:29 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2013-05-30 09:08:10 +0000
@@ -653,4 +653,5 @@
 show_only_risk_cases = Show only Risk cases
 toggle_risk_status = Toggle risk status
 with = with
-status_events = events
\ No newline at end of file
+status_events = events
+use_data_element_form_names = Use data element form names
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js	2013-05-30 03:47:35 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js	2013-05-30 09:08:10 +0000
@@ -1877,6 +1877,15 @@
 					p.displayOrgunitCode = Ext.getCmp('displayOrgunitCode').getValue();
 				}
 				
+				if( Ext.getCmp('useFormNameDataElementOpt').getValue()== true )
+				{
+					p.useFormNameDataElement = Ext.getCmp('useFormNameDataElementOpt').getValue();
+				}
+				else
+				{
+					p.useFormNameDataElement = "false";
+				}
+				
 				// Get searching values
 				p.filterValues = [];
 				
@@ -1979,6 +1988,15 @@
 				document.getElementById('userOrganisationUnit').value = Ext.getCmp('userOrgunit').getValue();
 				document.getElementById('userOrganisationUnitChildren').value = Ext.getCmp('userOrgunitChildren').getValue();
 
+				if( Ext.getCmp('useFormNameDataElementOpt').getValue()== true )
+				{
+					document.getElementById('useFormNameDataElement').value = Ext.getCmp('useFormNameDataElementOpt').getValue();
+				}
+				else
+				{
+					document.getElementById('useFormNameDataElement').value = "false";
+				}
+				
 				// orgunits
 				var orgunitIdList = document.getElementById('orgunitIds');
 				TR.util.list.clearList(orgunitIdList);
@@ -2307,6 +2325,13 @@
 					p.deGroupBy = Ext.getCmp('dataElementGroupByCbx').getValue().split('_')[1];
 				}
 				
+				if( Ext.getCmp('useFormNameDataElementOpt').getValue()== true ){
+					p.useFormNameDataElement = Ext.getCmp('useFormNameDataElementOpt').getValue();
+				}
+				else{
+					p.useFormNameDataElement = "false";
+				}
+				
 				// Filter values for data-elements
 				
 				p.deFilters = [];
@@ -2395,6 +2420,13 @@
 				document.getElementById('facilityLB').value = TR.cmp.settings.facilityLB.getValue();
 				document.getElementById('position').value = TR.state.aggregateReport.getPosition();
 				
+				if( Ext.getCmp('useFormNameDataElementOpt').getValue()== true ){
+					document.getElementById('useFormNameDataElement').value = Ext.getCmp('useFormNameDataElementOpt').getValue();
+				}
+				else{
+					document.getElementById('useFormNameDataElement').value = "false";
+				}
+				
 				if( Ext.getCmp('dataElementGroupByCbx').getValue() != null 
 					&& Ext.getCmp('dataElementGroupByCbx').getValue() != '' ){
 					document.getElementById('deGroupBy').value = Ext.getCmp('dataElementGroupByCbx').getValue().split('_')[1];
@@ -2834,6 +2866,8 @@
 		createColTable: function(){
 			var cols = [];
 				
+			// Case-based tabular report
+			
 			if(Ext.getCmp('reportTypeGroup').getValue().reportType=='true')
 			{
 				var orgUnitCols = ( TR.init.system.maxLevels + 1 - TR.cmp.settings.level.getValue() );
@@ -2912,7 +2946,7 @@
 				// Data element columns
 				
 				TR.cmp.params.dataelement.selected.store.each( function(r) {
-					cols[++index] = TR.datatable.createColumn( r.data.valueType, r.data.id, r.data.compulsory, r.data.name, index );
+					cols[++index] = TR.datatable.createColumn( r.data.valueType, r.data.id, r.data.compulsory, TR.value.columns[index].name, index );
 				});
 			
 			}
@@ -4100,6 +4134,17 @@
 			labelWidth: 135
 		});
 		
+		var useFormNameDataElementField = Ext.create('Ext.form.field.Checkbox', {
+			xtype: 'checkbox',
+			cls: 'tr-checkbox',
+			id: 'useFormNameDataElementOpt',
+			style:'padding-left: 20px;',
+			boxLabel: TR.i18n.use_data_element_form_names,
+			boxLabelAlign: 'before',
+			labelWidth: 135,
+			checked: true
+		});
+		
 		var facilityLBField = Ext.create('Ext.form.field.ComboBox', {
 			cls: 'tr-combo',
 			id: 'facilityLBCombobox',
@@ -4253,7 +4298,8 @@
 							items:[
 								completedEventsField,
 								displayTotalsOptField,
-								displayOrgunitCodeField
+								displayOrgunitCodeField,
+								useFormNameDataElementField
 							]
 						},
 						facilityLBField,
@@ -4619,6 +4665,7 @@
 													Ext.getCmp('caseBasedFavoriteBtn').setVisible(true);
 													Ext.getCmp('levelCombobox').setVisible(true);
 													Ext.getCmp('displayOrgunitCode').setVisible(true);
+													
 													var level = Ext.getCmp('levelCombobox').getValue();
 													if( level==null || level!='' ){
 														Ext.getCmp('levelCombobox').setValue('1');

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/index.html'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/index.html	2013-05-19 08:24:25 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/index.html	2013-05-30 09:08:10 +0000
@@ -28,6 +28,7 @@
 		<input type="hidden" id="orderByOrgunitAsc" name="orderByOrgunitAsc" >
 		<input type="hidden" id="orderByExecutionDateByAsc" name="orderByExecutionDateByAsc" >
 		<select multiple id="filterValues" name="filterValues" class="hidden"></select>
+		<input type="hidden" id="useFormNameDataElement" name="useFormNameDataElement" >
     </form>
 	
     <script type="text/javascript">TR = {};</script>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/i18n.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/i18n.vm	2013-05-23 16:04:26 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/i18n.vm	2013-05-30 09:08:10 +0000
@@ -193,5 +193,6 @@
 can_view: '$encoder.jsEscape($i18n.getString( 'can_view' ) , "'")',
 can_edit_and_view: '$encoder.jsEscape($i18n.getString( 'can_edit_and_view' ) , "'")',
 public_access: '$encoder.jsEscape($i18n.getString( 'public_access' ) , "'")',
-display_orgunit_code: '$encoder.jsEscape($i18n.getString( 'display_orgunit_code' ) , "'")'
+display_orgunit_code: '$encoder.jsEscape($i18n.getString( 'display_orgunit_code' ) , "'")',
+use_data_element_form_names: '$encoder.jsEscape($i18n.getString( 'use_data_element_form_names' ) , "'")'
 };
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularAggregateReport.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularAggregateReport.vm	2013-05-24 04:19:07 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularAggregateReport.vm	2013-05-30 09:08:10 +0000
@@ -106,5 +106,6 @@
 	"useCompletedEvents": "$!aggregateReport.useCompletedEvents",
 	"displayTotals": "$!aggregateReport.displayTotals",
 	"userOrganisationUnit": "$!aggregateReport.userOrganisationUnit",
-	"userOrganisationUnitChildren": "$!aggregateReport.userOrganisationUnitChildren"
+	"userOrganisationUnitChildren": "$!aggregateReport.userOrganisationUnitChildren",
+	"useFormNameDataElement": "$!aggregateReport.useFormNameDataElement"
 }
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularReport.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularReport.vm	2013-05-23 16:04:26 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularReport.vm	2013-05-30 09:08:10 +0000
@@ -33,6 +33,7 @@
 	"sortedOrgunitAsc": "${tabularReport.sortedOrgunitAsc}",
 	"facilityLB": "${tabularReport.facilityLB}",
 	"displayOrgunitCode": "$!tabularReport.displayOrgunitCode",
+	"useFormNameDataElement": "$!tabularReport.useFormNameDataElement",
 	"useCompletedEvents": "$!tabularReport.useCompletedEvents",
 	"userOrganisationUnit": "$!tabularReport.userOrganisationUnit",
 	"userOrganisationUnitChildren": "$!tabularReport.userOrganisationUnitChildren",