← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 7268: Select multi-orgunits in Tabular report.

 

------------------------------------------------------------
revno: 7268
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2012-06-11 15:24:34 +0700
message:
  Select multi-orgunits in Tabular report.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientreport/PatientTabularReport.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/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/GenerateTabularReportAction.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/java/org/hisp/dhis/caseentry/action/report/TabularInitializeAction.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/webapp/dhis-web-caseentry/app/app.js
  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/jsonTabularInitialize.vm
  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/responseDataElements.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/PatientTabularReport.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientreport/PatientTabularReport.java	2012-05-15 02:36:43 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientreport/PatientTabularReport.java	2012-06-11 08:24:34 +0000
@@ -30,6 +30,7 @@
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import java.util.Set;
 
 import org.hisp.dhis.common.BaseIdentifiableObject;
 import org.hisp.dhis.dataelement.DataElement;
@@ -80,7 +81,7 @@
 
     private List<DataElement> dataElements = new ArrayList<DataElement>();
 
-    private OrganisationUnit organisationUnit;
+    private Set<OrganisationUnit> organisationUnits;
 
     private int level;
 
@@ -137,14 +138,14 @@
         this.programStage = programStage;
     }
 
-    public OrganisationUnit getOrganisationUnit()
+    public Set<OrganisationUnit> getOrganisationUnits()
     {
-        return organisationUnit;
+        return organisationUnits;
     }
 
-    public void setOrganisationUnit( OrganisationUnit organisationUnit )
+    public void setOrganisationUnits( Set<OrganisationUnit> organisationUnits )
     {
-        this.organisationUnit = organisationUnit;
+        this.organisationUnits = organisationUnits;
     }
 
     public List<PatientIdentifierType> getIdentifiers()

=== 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	2012-06-04 10:03:56 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/startup/TableAlteror.java	2012-06-11 08:24:34 +0000
@@ -110,10 +110,12 @@
 
         executeSql( "ALTER TABLE caseaggregationcondition RENAME description TO name" );
         updateCaseAggregationCondition();
-        
+
         executeSql( "UPDATE programstage_dataelements SET allowProvidedElsewhere=false WHERE allowProvidedElsewhere is null" );
         executeSql( "UPDATE patientdatavalue SET providedElsewhere=false WHERE providedElsewhere is null" );
         executeSql( "ALTER TABLE programstageinstance DROP COLUMN providedbyanotherfacility" );
+
+        updateTabularReportTable();
     }
 
     // -------------------------------------------------------------------------
@@ -216,6 +218,30 @@
         }
     }
 
+    private void updateTabularReportTable()
+    {
+        try
+        {
+            StatementHolder holder = statementManager.getHolder();
+
+            Statement statement = holder.getStatement();
+
+            ResultSet resultSet = statement
+                .executeQuery( "SELECT patienttabularreportid, organisationunitid FROM patienttabularreport" );
+
+            while ( resultSet.next() )
+            {
+                executeSql( " INSERT INTO patienttabularreport_organisationUnits ( patienttabularreportid, organisationunitid ) VALUES ( " + resultSet.getInt( 1 ) + ", " + resultSet.getInt( 2 ) + ")" );
+            }
+            
+            executeSql( "ALTER TABLE patienttabularreport DROP COLUMN organisationunitid" );
+        }
+        catch ( Exception e )
+        {
+            e.printStackTrace();
+        }
+    }
+
     private int executeSql( String sql )
     {
         try

=== 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	2012-05-23 15:02:50 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patientreport/hibernate/PatientTabularReport.hbm.xml	2012-06-11 08:24:34 +0000
@@ -50,11 +50,14 @@
 			<many-to-many class="org.hisp.dhis.dataelement.DataElement"
 				foreign-key="patienttabularreport_dataelementid" />
 		</list>
-
-		<many-to-one name="organisationUnit"
-			class="org.hisp.dhis.organisationunit.OrganisationUnit" column="organisationunitid"
-			foreign-key="fk_patient_organisationunitid" />
-
+		
+	 	<set name="organisationUnits" table="patienttabularreport_organisationUnits">
+	      <cache usage="read-write" />
+	      <key column="patienttabularreportid" foreign-key="fk_patienttabularreport_organisationUnitid" />
+	      <many-to-many column="organisationunitid" class="org.hisp.dhis.organisationunit.OrganisationUnit"
+	          foreign-key="fk_patienttabularreportid_organisationunit" />
+	    </set>
+    	
 		<property name="level" />
 
 		<property name="sortedOrgunitAsc" />

=== 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-06 13:44:00 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateTabularReportAction.java	2012-06-11 08:24:34 +0000
@@ -35,6 +35,7 @@
 import static org.hisp.dhis.patientreport.PatientTabularReport.VALUE_TYPE_OPTION_SET;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -119,11 +120,11 @@
     // Input/Output
     // -------------------------------------------------------------------------
 
-    private Integer orgunitId;
+    private Collection<Integer> orgunitIds;
 
-    public void setOrgunitId( Integer orgunitId )
+    public void setOrgunitIds( Collection<Integer> orgunitIds )
     {
-        this.orgunitId = orgunitId;
+        this.orgunitIds = orgunitIds;
     }
 
     private Integer programStageId;
@@ -282,24 +283,32 @@
 
         if ( facilityLB.equals( "selected" ) )
         {
-            organisationUnits.add( orgunitId );
+            organisationUnits.addAll( orgunitIds );
         }
         else if ( facilityLB.equals( "childrenOnly" ) )
         {
-            OrganisationUnit selectedOrgunit = organisationUnitService.getOrganisationUnit( orgunitId );
-            organisationUnits = new HashSet<Integer>( ConversionUtils.getIdentifiers( OrganisationUnit.class, selectedOrgunit.getChildren() ) );
+            for ( Integer orgunitId : orgunitIds )
+            {
+                OrganisationUnit selectedOrgunit = organisationUnitService.getOrganisationUnit( orgunitId );
+                organisationUnits = new HashSet<Integer>( ConversionUtils.getIdentifiers( OrganisationUnit.class,
+                    selectedOrgunit.getChildren() ) );
+            }
         }
         else
         {
-            OrganisationUnit selectedOrgunit = organisationUnitService.getOrganisationUnit( orgunitId );
-            
-            if ( selectedOrgunit.getParent() == null )
-            {
-                organisationUnits = null; // Ignore org unit criteria when root
-            }
-            else
-            {
-                organisationUnits = organisationUnitService.getOrganisationUnitHierarchy().getChildren( orgunitId );
+            for ( Integer orgunitId : orgunitIds )
+            {
+                OrganisationUnit selectedOrgunit = organisationUnitService.getOrganisationUnit( orgunitId );
+
+                if ( selectedOrgunit.getParent() == null )
+                {
+                    organisationUnits = null; // Ignore org unit criteria when
+                                              // root
+                }
+                else
+                {
+                    organisationUnits = organisationUnitService.getOrganisationUnitHierarchy().getChildren( orgunitId );
+                }
             }
         }
 
@@ -309,8 +318,8 @@
 
         ProgramStage programStage = programStageService.getProgramStage( programStageId );
 
-        //TODO check sql traffic
-        
+        // TODO check sql traffic
+
         Date startValue = format.parseDate( startDate );
 
         Date endValue = format.parseDate( endDate );
@@ -327,28 +336,29 @@
 
         if ( type == null ) // Tabular report
         {
-            int totalRecords = programStageInstanceService.getTabularReportCount( programStage, identifierTypes, fixedAttributes, patientAttributes, dataElements, 
-                searchingIdenKeys, searchingAttrKeys, searchingDEKeys, organisationUnits, level, startValue, endValue );
+            int totalRecords = programStageInstanceService.getTabularReportCount( programStage, identifierTypes,
+                fixedAttributes, patientAttributes, dataElements, searchingIdenKeys, searchingAttrKeys,
+                searchingDEKeys, organisationUnits, level, startValue, endValue );
 
             total = getNumberOfPages( totalRecords );
-            
+
             this.paging = createPaging( totalRecords );
-            //total = paging.getTotal(); //TODO
-            
+            // total = paging.getTotal(); //TODO
+
             grid = programStageInstanceService.getTabularReport( programStage, hiddenCols, identifierTypes,
                 fixedAttributes, patientAttributes, dataElements, searchingIdenKeys, searchingAttrKeys,
-                searchingDEKeys, organisationUnits, level, startValue, endValue, !orderByOrgunitAsc,
-                paging.getStartPos(), paging.getPageSize() );
+                searchingDEKeys, organisationUnits, level, startValue, endValue, !orderByOrgunitAsc, paging
+                    .getStartPos(), paging.getPageSize() );
         }
-        else // Download as Excel
+        else
+        // Download as Excel
         {
             grid = programStageInstanceService.getTabularReport( programStage, hiddenCols, identifierTypes,
                 fixedAttributes, patientAttributes, dataElements, searchingIdenKeys, searchingAttrKeys,
-                searchingDEKeys, organisationUnits, level, startValue, endValue, !orderByOrgunitAsc,
-                null, null );
+                searchingDEKeys, organisationUnits, level, startValue, endValue, !orderByOrgunitAsc, null, null );
         }
-System.out.println();
-System.out.println(grid);
+        System.out.println();
+        System.out.println( grid );
 
         return type == null ? SUCCESS : type;
     }
@@ -368,13 +378,13 @@
         // ---------------------------------------------------------------------
         // Get Patient-Identifier searching-keys
         // ---------------------------------------------------------------------
-        
+
         int index = 0;
         for ( String searchingValue : searchingValues )
         {
             String[] infor = searchingValue.split( "_" );
             String objectType = infor[0];
-            
+
             if ( objectType.equals( PREFIX_META_DATA ) )
             {
                 hiddenCols.add( Boolean.parseBoolean( infor[2] ) );
@@ -422,10 +432,12 @@
                 {
                     searchingAttrKeys.put( objectId, infor[3].trim() );
                     String value = infor[3].trim();
-                    if ( attribute.getValueType().equals( PatientAttribute.TYPE_BOOL ) )
-                    {
-                        value = (value.indexOf( i18n.getString( "yes" ) ) != -1) ? "true" : "false";
-                    }
+                    // if ( attribute.getValueType().equals(
+                    // PatientAttribute.TYPE_BOOL ) )
+                    // {
+                    // value = (value.indexOf( i18n.getString( "yes" ) ) != -1)
+                    // ? "true" : "false";
+                    // }
                     values.add( value );
                 }
                 else
@@ -449,14 +461,17 @@
                 if ( infor.length == 4 )
                 {
                     String value = infor[3].trim();
-                    if ( dataElement.getType().equals( DataElement.VALUE_TYPE_BOOL ) )
-                    {
-                        int startIndx = value.indexOf( '\'' ) + 1;
-                        int endIndx = value.lastIndexOf( '\'' );
-                        String key = value.substring( startIndx, endIndx );
-                                              
-                        value = (key.equals(i18n.getString( "yes" ))) ? value.replace( key, "true" ) : value.replace( key, "false" );
-                    }                   
+                    // if ( dataElement.getType().equals(
+                    // DataElement.VALUE_TYPE_BOOL ) )
+                    // {
+                    // int startIndx = value.indexOf( '\'' ) + 1;
+                    // int endIndx = value.lastIndexOf( '\'' );
+                    // String key = value.substring( startIndx, endIndx );
+                    //                           
+                    // value = (key.equals(i18n.getString( "yes" ))) ?
+                    // value.replace( key, "true" ) : value.replace( key,
+                    // "false" );
+                    // }
                     searchingDEKeys.put( objectId, value );
                     values.add( value );
                 }

=== 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	2012-05-29 07:37:37 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/SaveTabularReportAction.java	2012-06-11 08:24:34 +0000
@@ -33,7 +33,10 @@
 import static org.hisp.dhis.patientreport.PatientTabularReport.PREFIX_PATIENT_ATTRIBUTE;
 
 import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementService;
@@ -134,7 +137,7 @@
 
     private List<String> searchingValues = new ArrayList<String>();
 
-    private Integer orgunitId;
+    private Collection<Integer> orgunitIds;
 
     private boolean orderByOrgunitAsc;
 
@@ -181,9 +184,9 @@
         this.startDate = startDate;
     }
 
-    public void setOrgunitId( Integer orgunitId )
+    public void setOrgunitIds( Collection<Integer> orgunitIds )
     {
-        this.orgunitId = orgunitId;
+        this.orgunitIds = orgunitIds;
     }
 
     public void setProgramStageId( Integer programStageId )
@@ -199,7 +202,8 @@
     public String execute()
         throws Exception
     {
-        OrganisationUnit orgunit = organisationUnitService.getOrganisationUnit( orgunitId );
+        Set<OrganisationUnit> orgunits = new HashSet<OrganisationUnit>( organisationUnitService
+            .getOrganisationUnits( orgunitIds ) );
         ProgramStage programStage = programStageService.getProgramStage( programStageId );
 
         // ---------------------------------------------------------------------
@@ -210,7 +214,7 @@
         tabularReport.setStartDate( format.parseDate( startDate ) );
         tabularReport.setEndDate( format.parseDate( endDate ) );
         tabularReport.setProgramStage( programStage );
-        tabularReport.setOrganisationUnit( orgunit );
+        tabularReport.setOrganisationUnits( orgunits );
         tabularReport.setLevel( level );
         tabularReport.setFacilityLB( facilityLB );
         tabularReport.setSortedOrgunitAsc( orderByOrgunitAsc );
@@ -226,7 +230,7 @@
 
         List<DataElement> dataElements = new ArrayList<DataElement>();
         List<String> fixedAttributes = new ArrayList<String>();
-        
+
         for ( String searchingValue : searchingValues )
         {
             String[] infor = searchingValue.split( "_" );
@@ -252,7 +256,6 @@
                 DataElement dataElement = dataElementService.getDataElement( objectId );
                 dataElements.add( dataElement );
             }
-
         }
 
         tabularReport.setFixedAttributes( fixedAttributes );

=== modified 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	2012-04-11 06:25:02 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/TabularInitializeAction.java	2012-06-11 08:24:34 +0000
@@ -29,9 +29,13 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
+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.OrganisationUnitGroup;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
 import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.program.Program;
@@ -58,6 +62,13 @@
         this.organisationUnitService = organisationUnitService;
     }
 
+    private OrganisationUnitGroupService organisationUnitGroupService;
+
+    public void setOrganisationUnitGroupService( OrganisationUnitGroupService organisationUnitGroupService )
+    {
+        this.organisationUnitGroupService = organisationUnitGroupService;
+    }
+
     private ProgramService programService;
 
     public void setProgramService( ProgramService programService )
@@ -90,6 +101,13 @@
         return levels;
     }
 
+    private List<OrganisationUnitGroup> orgunitGroups;
+
+    public List<OrganisationUnitGroup> getOrgunitGroups()
+    {
+        return orgunitGroups;
+    }
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -100,12 +118,15 @@
         Collection<OrganisationUnit> rootUnits = new ArrayList<OrganisationUnit>( organisationUnitService
             .getOrganisationUnitsAtLevel( 1 ) );
 
+        rootNode = rootUnits.size() > 0 ? rootUnits.iterator().next() : new OrganisationUnit();
+
+        orgunitGroups = new ArrayList<OrganisationUnitGroup>( organisationUnitGroupService.getAllOrganisationUnitGroups() );
+        Collections.sort( orgunitGroups, IdentifiableObjectNameComparator.INSTANCE );
+
         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-06-07 04:23:40 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml	2012-06-11 08:24:34 +0000
@@ -810,6 +810,7 @@
 		scope="prototype">
 		<property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
 		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
+		<property name="organisationUnitGroupService" ref="org.hisp.dhis.organisationunit.OrganisationUnitGroupService" />
 	</bean>
 	
 	<bean id="org.hisp.dhis.caseentry.action.report.GetOrganisationUnitChildrenAction"

=== 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-06-08 07:22:50 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2012-06-11 08:24:34 +0000
@@ -354,4 +354,5 @@
 after = After
 on = On
 clear_filter = Clear filter
-events = Events
\ No newline at end of file
+events = Events
+orgunit_groups = Groups
\ 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	2012-06-08 07:00:56 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js	2012-06-11 08:24:34 +0000
@@ -17,6 +17,13 @@
 					}
 				}
 				
+				for (var orgunitGroup in r.orgunitGroups) {
+					obj.system.orgunitGroup = [];
+					for (var i = 0; i < r.orgunitGroups.length; i++) {
+						obj.system.orgunitGroup.push({id: r.orgunitGroups[i].id, name: r.orgunitGroups[i].name });
+					}
+				}
+				
 				for (var level in r.levels) {
 					obj.system.level = [];
 					for (var i = 0; i < r.levels.length; i++) {
@@ -490,7 +497,7 @@
 							Ext.getCmp('endDate').setValue( f.endDate );
 							Ext.getCmp('facilityLBCombobox').setValue( f.facilityLB );
 							Ext.getCmp('levelCombobox').setValue( f.level );
-							TR.state.orgunitId = f.organisationUnitId;
+							TR.state.orgunitIds = f.orgunitIds;
 							
 							TR.cmp.params.patientProperty.objects = [];
 							TR.cmp.params.dataelement.objects = [];
@@ -557,10 +564,19 @@
 	};
     
     TR.store = {
-        program: Ext.create('Ext.data.Store', {
-                fields: ['id', 'name', 'type'],
-				data:TR.init.system.program
-            }),
+		program: Ext.create('Ext.data.Store', {
+			fields: ['id', 'name', 'type'],
+			data:TR.init.system.program
+		}),
+		orgunitGroup: Ext.create('Ext.data.Store', {
+			fields: ['id', 'name', 'type'],
+			data:TR.init.system.orgunitGroup,
+			listeners: {
+				load: function() {
+					this.insert(0,{id:"", name: TR.i18n.none});
+				}
+			}
+		}),
 		patientProperty: {
             available: Ext.create('Ext.data.Store', {
                 fields: ['id', 'name'],
@@ -705,7 +721,7 @@
 		total: 1,
 		orderByOrgunitAsc: true,
 		orderByExecutionDateByAsc: true,
-		orgunitId: 0,
+		orgunitIds: [],
 		generateReport: function( type, isFilter ) {
 			// Validation
 			if( !this.validation.objects() )
@@ -832,14 +848,16 @@
 			p.facilityLB = TR.cmp.settings.facilityLB.getValue();
 			p.level = TR.cmp.settings.level.getValue();
 			
-			// organisation unit
-			p.orgunitId = TR.state.orgunitId;
+			// orders
 			p.orderByOrgunitAsc = this.orderByOrgunitAsc;
 			p.orderByExecutionDateByAsc= this.orderByExecutionDateByAsc;
 			
 			p.programStageId = TR.cmp.params.programStage.getValue();
 			p.currentPage = this.currentPage;
 			
+			// organisation unit
+			p.orgunitIds = TR.state.orgunitIds;
+			
 			// Get searching values
 			p.searchingValues = [];
 			if( !TR.state.paramChanged() )
@@ -1668,17 +1686,39 @@
 								items: [
 									// ORGANISATION UNIT
 									{
-										title: '<div style="height:17px">' + TR.i18n.organisation_units + '</div>',
+										title: '<div style="height:17px;background-image:url(images/organisationunit.png); background-repeat:no-repeat; padding-left:20px">' + TR.i18n.organisation_units + '</div>',
 										hideCollapseTool: true,
 										items: [
 											{
+												xtype: 'combobox',
+												cls: 'tr-combo',
+												name: TR.init.system.orgunitGroup,
+												id: 'orgGroupCombobox',
+												emptyText: TR.i18n.please_select,
+												hidden: true,
+												queryMode: 'local',
+												editable: false,
+												valueField: 'id',
+												displayField: 'name',
+												fieldLabel: TR.i18n.orgunit_groups,
+												labelWidth: 135,
+												emptyText: TR.i18n.please_select,
+												width: TR.conf.layout.west_fieldset_width - TR.conf.layout.west_width_subtractor,
+												store: TR.store.orgunitGroup,
+												listeners: {
+													added: function() {
+														TR.cmp.settings.orgunitGroup = this;
+													}
+												}
+											},
+											{
 												xtype: 'treepanel',
 												cls: 'tr-tree',
 												id: 'treeOrg',
 												width: TR.conf.layout.west_fieldset_width - TR.conf.layout.west_width_subtractor,
 												height: 273,
 												autoScroll: true,
-												multiSelect: false,
+												multiSelect: true,
 												isrendered: false,
 												storage: {},
 												addToStorage: function(objects) {
@@ -1722,10 +1762,15 @@
 													afterrender: function( treePanel, eOpts )
 													{
 														treePanel.getSelectionModel().select( treePanel.getRootNode() );
-														TR.state.orgunitId = treePanel.getSelectionModel().getSelection()[0].data.id;
+														TR.state.orgunitIds = [];
+														TR.state.orgunitIds.push( treePanel.getSelectionModel().getSelection()[0].data.id );
 													},
 													itemclick : function(view,rec,item,index,eventObj){
-														TR.state.orgunitId = TR.cmp.params.organisationunit.treepanel.getSelectionModel().getSelection()[0].data.id;
+														TR.state.orgunitIds = [];
+														var selectedNodes = TR.cmp.params.organisationunit.treepanel.getSelectionModel().getSelection();
+														for( var i=0; i<selectedNodes.length; i++ ){
+															TR.state.orgunitIds.push( selectedNodes[i].data.id);
+														}
 													}
 												}
 											}
@@ -1742,7 +1787,7 @@
 									
 									// IDENTIFIER TYPE and PATIENT-ATTRIBUTE
 									{
-										title: '<div style="height:17px">' + TR.i18n.identifiers_and_attributes + '</div>',
+										title: '<div style="height:17px;background-image:url(images/data.png); background-repeat:no-repeat; padding-left:20px">' + TR.i18n.identifiers_and_attributes + '</div>',
 										hideCollapseTool: true,
 										items: [
 											{
@@ -1868,7 +1913,7 @@
 									
 									// DATA ELEMENTS
 									{
-										title: '<div style="height:17px">' + TR.i18n.data_elements + '</div>',
+										title: '<div style="height:17px;background-image:url(images/data.png); background-repeat:no-repeat; padding-left:20px;">' + TR.i18n.data_elements + '</div>',
 										hideCollapseTool: true,
 										items: [
 											{
@@ -2113,7 +2158,7 @@
 									
 									// OPTIONS
 									{
-										title: '<div style="height:17px">' + TR.i18n.options + '</div>',
+										title: '<div style="height:17px;background-image:url(images/options.png); background-repeat:no-repeat; padding-left:20px;">' + TR.i18n.options + '</div>',
 										hideCollapseTool: true,
 										cls: 'tr-accordion-options',
 										items: [

=== 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	2012-06-01 04:31:00 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/i18n.vm	2012-06-11 08:24:34 +0000
@@ -79,5 +79,7 @@
 the_date_is_not_valid:'$encoder.jsEscape($i18n.getString( 'the_date_is_not_valid' ) , "'")',
 before:'$encoder.jsEscape($i18n.getString( 'before' ) , "'")',
 after:'$encoder.jsEscape($i18n.getString( 'after' ) , "'")',
-on:'$encoder.jsEscape($i18n.getString( 'on' ) , "'")'
+on:'$encoder.jsEscape($i18n.getString( 'on' ) , "'")',
+orgunit_groups:'$encoder.jsEscape($i18n.getString( 'orgunit_groups' ) , "'")',
+none: '[' + '$encoder.jsEscape($i18n.getString( 'none' ) , "'")' + ']'
 };
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularInitialize.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularInitialize.vm	2012-05-28 16:54:25 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularInitialize.vm	2012-06-11 08:24:34 +0000
@@ -22,7 +22,16 @@
 		  }#if( $velocityCount < $programs.size() ),#end
 		#end
 	],
-		
+	
+	"orgunitGroups": [
+		#foreach( $orgunitGroup in $orgunitGroups )
+		  {
+			"id":  "${orgunitGroup.id}" ,
+			"name": "${orgunitGroup.name}"
+		  }#if($velocityCount < $orgunitGroups.size()),#end
+		#end
+	],
+	
 	"levels": [
 		#foreach( $level in $levels )
 		  {

=== 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	2012-05-31 10:17:58 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularReport.vm	2012-06-11 08:24:34 +0000
@@ -14,10 +14,17 @@
 	"programStageName": "${tabularReport.programStage.name}",
 	"startDate": "$!format.formatDate( $tabularReport.startDate )",
 	"endDate": "$!format.formatDate( ${tabularReport.endDate} )",
-	"organisationUnitId": "${tabularReport.organisationUnit.id}",
 	"level": "${tabularReport.level}",
 	"sortedOrgunitAsc": "${tabularReport.sortedOrgunitAsc}",
 	"facilityLB": "${tabularReport.facilityLB}",
+	"orgunitIds": [
+		#set( $size = $tabularReport.organisationUnits.size() )
+		#set( $organisationUnits = ${tabularReport.organisationUnits} )
+		#foreach( ${organisationUnit} in $!{organisationUnits} )
+			$organisationUnit.id
+			#if( $velocityCount < $size ),#end
+		#end
+	],
 	"patientProperties": [
 		#set( $fixedAttributes = ${tabularReport.fixedAttributes} )
 		#foreach( ${fixedAttribute} in $!{fixedAttributes} )

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/responseDataElements.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/responseDataElements.vm	2012-05-31 10:17:58 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/responseDataElements.vm	2012-06-11 08:24:34 +0000
@@ -3,7 +3,7 @@
 #foreach( $psDataElement in $psDataElements )
   {
     "id": "de_$!{psDataElement.dataElement.id}",
-    "name": "$encoder.xmlEncode(${psDataElement.dataElement.name} )",
+    "name": "$encoder.xmlEncode(${psDataElement.dataElement.displayName} )",
 	"valueType": #if( $psDataElement.dataElement.optionSet )
 					"list"
 				 #else