← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6192: (patient) Add a selectbox for retrieving all records registered for the selected orgunit; sort se...

 

------------------------------------------------------------
revno: 6192
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-03-07 12:54:02 +0700
message:
  (patient) Add a selectbox for retrieving all records registered for the selected orgunit; sort selected data elements in tabular report.
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-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
  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/caseAggregationForm.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/tabularReport.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/style/report.css
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/tabularReportSelect.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/program/ProgramStageInstanceService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java	2012-03-07 02:40:08 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java	2012-03-07 05:54:02 +0000
@@ -87,11 +87,11 @@
 
     List<ProgramStageInstance> getProgramStageInstances( Patient patient, Boolean completed );
             
-    List<ProgramStageInstance> searchProgramStageInstances( ProgramStage programStage, Map<Integer,String> searchingKeys, OrganisationUnit orgunit, Date startDate, Date endDate, int min, int max );
+    List<ProgramStageInstance> searchProgramStageInstances( ProgramStage programStage, Map<Integer,String> searchingKeys, Collection<Integer> orgunitIds, Date startDate, Date endDate, int min, int max );
 
-    Grid getTabularReport( ProgramStage programStage, List<DataElement> dataElements, Map<Integer,String> searchingKeys, OrganisationUnit orgunit, Date startDate, Date endDate, int min, int max, I18nFormat format, I18n i18n );
+    Grid getTabularReport( ProgramStage programStage, List<DataElement> dataElements, Map<Integer,String> searchingKeys, Collection<Integer> orgunitIds, Date startDate, Date endDate, int min, int max, I18nFormat format, I18n i18n );
     
-    Grid getTabularReport( ProgramStage programStage, List<DataElement> dataElements, Map<Integer,String> searchingKeys, OrganisationUnit orgunit, Date startDate, Date endDate, I18nFormat format, I18n i18n );
+    Grid getTabularReport( ProgramStage programStage, List<DataElement> dataElements, Map<Integer,String> searchingKeys, Collection<Integer> orgunitIds, Date startDate, Date endDate, I18nFormat format, I18n i18n );
 
-    int countProgramStageInstances( ProgramStage programStage, Map<Integer,String> searchingKeys, OrganisationUnit orgunit, Date startDate, Date endDate );
+    int countProgramStageInstances( ProgramStage programStage, Map<Integer,String> searchingKeys, Collection<Integer> orgunitIds, Date startDate, Date endDate );
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java	2012-03-07 02:40:08 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java	2012-03-07 05:54:02 +0000
@@ -71,10 +71,10 @@
     
     List<ProgramStageInstance> get( ProgramStage programStage, OrganisationUnit orgunit, Date startDate, Date endDate, int min, int max );
     
-    List<ProgramStageInstance> get( ProgramStage programStage, Map<Integer,String> searchingKeys, OrganisationUnit orgunit, Date startDate, Date endDate, int min, int max );
+    List<ProgramStageInstance> get( ProgramStage programStage, Map<Integer,String> searchingKeys, Collection<Integer> orgunitIds, Date startDate, Date endDate, int min, int max );
     
-    List<ProgramStageInstance> get( ProgramStage programStage, Map<Integer,String> searchingKeys, OrganisationUnit orgunit, Date startDate, Date endDate );
+    List<ProgramStageInstance> get( ProgramStage programStage, Map<Integer,String> searchingKeys, Collection<Integer> orgunitIds, Date startDate, Date endDate );
 
-    int count( ProgramStage programStage, Map<Integer,String> searchingKeys, OrganisationUnit orgunit, Date startDate, Date endDate );
+    int count( ProgramStage programStage, Map<Integer,String> searchingKeys, Collection<Integer> orgunitIds, Date startDate, Date endDate );
     
 }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java	2012-03-07 02:40:08 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java	2012-03-07 05:54:02 +0000
@@ -186,42 +186,42 @@
     }
 
     public List<ProgramStageInstance> searchProgramStageInstances( ProgramStage programStage,
-        Map<Integer, String> searchingKeys, OrganisationUnit orgunit, Date startDate, Date endDate, int min, int max )
+        Map<Integer, String> searchingKeys, Collection<Integer> orgunitIds, Date startDate, Date endDate, int min, int max )
     {
-        return programStageInstanceStore.get( programStage, searchingKeys, orgunit, startDate, endDate, min, max );
+        return programStageInstanceStore.get( programStage, searchingKeys, orgunitIds, startDate, endDate, min, max );
     }
     
     public List<ProgramStageInstance> searchProgramStageInstances( ProgramStage programStage,
-        Map<Integer, String> searchingKeys, OrganisationUnit orgunit, Date startDate, Date endDate )
+        Map<Integer, String> searchingKeys, Collection<Integer> orgunitIds, Date startDate, Date endDate )
     {
-        return programStageInstanceStore.get( programStage, searchingKeys, orgunit, startDate, endDate );
+        return programStageInstanceStore.get( programStage, searchingKeys, orgunitIds, startDate, endDate );
     }
 
     public Grid getTabularReport( ProgramStage programStage, List<DataElement> dataElements,
-        Map<Integer, String> searchingKeys, OrganisationUnit orgunit, Date startDate, Date endDate, int min, int max,
+        Map<Integer, String> searchingKeys, Collection<Integer> orgunitIds, Date startDate, Date endDate, int min, int max,
         I18nFormat format, I18n i18n )
     {
         List<ProgramStageInstance> programStageInstances = searchProgramStageInstances( programStage, searchingKeys,
-            orgunit, startDate, endDate, min, max );
+            orgunitIds, startDate, endDate, min, max );
 
         return createTabularGrid( programStage, programStageInstances, dataElements, startDate, endDate, format, i18n );
     }
 
     public Grid getTabularReport( ProgramStage programStage, List<DataElement> dataElements,
-        Map<Integer, String> searchingKeys, OrganisationUnit orgunit, Date startDate, Date endDate, I18nFormat format,
+        Map<Integer, String> searchingKeys, Collection<Integer> orgunitIds, Date startDate, Date endDate, I18nFormat format,
         I18n i18n )
     {
         List<ProgramStageInstance> programStageInstances = searchProgramStageInstances( programStage, searchingKeys,
-            orgunit, startDate, endDate );
+            orgunitIds, startDate, endDate );
 
         return createTabularGrid( programStage, programStageInstances, dataElements, startDate, endDate, format, i18n );
     }
 
     @Override
     public int countProgramStageInstances( ProgramStage programStage, Map<Integer, String> searchingKeys,
-        OrganisationUnit orgunit, Date startDate, Date endDate )
+        Collection<Integer> orgunitIds, Date startDate, Date endDate )
     {
-        return programStageInstanceStore.count( programStage, searchingKeys, orgunit, startDate, endDate );
+        return programStageInstanceStore.count( programStage, searchingKeys, orgunitIds, 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-03-07 02:40:08 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java	2012-03-07 05:54:02 +0000
@@ -132,7 +132,7 @@
     @SuppressWarnings( "unchecked" )
     public List<ProgramStageInstance> get( OrganisationUnit unit, Date after, Date before, Boolean completed )
     {
-        String hql = "from ProgramStageInstance where programInstance.patient.organisationUnit = :unit";
+        String hql = "from ProgramStageInstance psi where psi.organisationUnit = :unit";
 
         if ( after != null )
         {
@@ -182,16 +182,17 @@
         Date endDate, int min, int max )
     {
         return getCriteria( Restrictions.eq( "programStage", programStage ),
-            Restrictions.between( "dueDate", startDate, endDate ) ).setFirstResult( min ).setMaxResults( max ).list();
+            Restrictions.eq( "organisationUnit", orgunit ), Restrictions.between( "dueDate", startDate, endDate ) )
+            .setFirstResult( min ).setMaxResults( max ).list();
     }
 
     @SuppressWarnings( "unchecked" )
     public List<ProgramStageInstance> get( ProgramStage programStage, Map<Integer, String> searchingKeys,
-        OrganisationUnit orgunit, Date startDate, Date endDate, int min, int max )
+        Collection<Integer> orgunitIds, Date startDate, Date endDate, int min, int max )
     {
         if ( searchingKeys.keySet().size() > 0 )
         {
-            String sql = getBySearchingValues( false, programStage, searchingKeys, orgunit, startDate, endDate )
+            String sql = getBySearchingValues( false, programStage, searchingKeys, orgunitIds, startDate, endDate )
                 + statementBuilder.limitRecord( min, max );
 
             List<Integer> ids = executeSQL( sql );
@@ -205,19 +206,20 @@
 
             return programStageInstances;
         }
-        
-        return (getCriteria( Restrictions.eq( "programStage", programStage ), Restrictions.eq( "organisationUnit",
-            orgunit ), Restrictions.between( "dueDate", startDate, endDate ) )).setFirstResult( min ).setMaxResults( max ).list();
+
+        return (getCriteria( Restrictions.eq( "programStage", programStage ), Restrictions.in( "organisationUnit.id",
+            orgunitIds ), Restrictions.between( "dueDate", startDate, endDate ) )).setFirstResult( min ).setMaxResults(
+            max ).list();
     }
-    
+
     @SuppressWarnings( "unchecked" )
     public List<ProgramStageInstance> get( ProgramStage programStage, Map<Integer, String> searchingKeys,
-        OrganisationUnit orgunit, Date startDate, Date endDate )
+        Collection<Integer> orgunitIds, Date startDate, Date endDate )
     {
         if ( searchingKeys.keySet().size() > 0 )
         {
-            String sql = getBySearchingValues( false, programStage, searchingKeys, orgunit, startDate, endDate );
-            
+            String sql = getBySearchingValues( false, programStage, searchingKeys, orgunitIds, startDate, endDate );
+
             List<Integer> ids = executeSQL( sql );
 
             List<ProgramStageInstance> programStageInstances = new ArrayList<ProgramStageInstance>();
@@ -229,37 +231,37 @@
 
             return programStageInstances;
         }
-        
-        return (getCriteria( Restrictions.eq( "programStage", programStage ), Restrictions.eq( "organisationUnit",
-            orgunit ), Restrictions.between( "dueDate", startDate, endDate ) )).list();
+
+        return (getCriteria( Restrictions.eq( "programStage", programStage ), Restrictions.in( "organisationUnit.id",
+            orgunitIds ), Restrictions.between( "dueDate", startDate, endDate ) )).list();
     }
 
-    public int count( ProgramStage programStage, Map<Integer, String> searchingKeys, OrganisationUnit orgunit,
+    public int count( ProgramStage programStage, Map<Integer, String> searchingKeys, Collection<Integer> orgunitIds,
         Date startDate, Date endDate )
     {
         if ( searchingKeys.keySet().size() > 0 )
         {
-            String sql = getBySearchingValues( true, programStage, searchingKeys, orgunit, startDate, endDate );
+            String sql = getBySearchingValues( true, programStage, searchingKeys, orgunitIds, startDate, endDate );
             List<Integer> countRow = executeSQL( sql );
             return (countRow != null && countRow.size() > 0) ? countRow.get( 0 ) : 0;
         }
 
-        Number rs = (Number) (getCriteria( Restrictions.eq( "programStage", programStage ), Restrictions.eq(
-            "organisationUnit", orgunit ), Restrictions.between( "dueDate", startDate, endDate ) )).setProjection(
-            Projections.rowCount() ).uniqueResult();
+        Number rs = (Number) (getCriteria( Restrictions.eq( "programStage", programStage ), Restrictions.in(
+            "organisationUnit.id", orgunitIds ), Restrictions.between( "dueDate", startDate, endDate ) ))
+            .setProjection( Projections.rowCount() ).uniqueResult();
 
         return rs != null ? rs.intValue() : 0;
     }
 
     private String getBySearchingValues( boolean isCount, ProgramStage programStage,
-        Map<Integer, String> searchingKeys, OrganisationUnit orgunit, Date startDate, Date endDate )
+        Map<Integer, String> searchingKeys, Collection<Integer> orgunitIds, Date startDate, Date endDate )
     {
         String sql = "select distinct( psi.programstageinstanceid) from patientdatavalue pdv "
             + "inner join programstageinstance psi on pdv.programstageinstanceid=psi.programstageinstanceid ";
 
         String condition = " WHERE psi.duedate >= '" + DateUtils.getMediumDateString( startDate )
             + "' AND psi.duedate <= '" + DateUtils.getMediumDateString( endDate ) + "' "
-            + " AND psi.organisationunitid=" + orgunit.getId() + " ";
+            + " AND psi.organisationunitid in( " + orgunitIds + ") ";
 
         Iterator<Integer> keys = searchingKeys.keySet().iterator();
         boolean index = false;

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateTabularReportAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateTabularReportAction.java	2012-03-05 04:22:57 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateTabularReportAction.java	2012-03-07 05:54:02 +0000
@@ -43,6 +43,8 @@
 import org.hisp.dhis.i18n.I18n;
 import org.hisp.dhis.i18n.I18nFormat;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitHierarchy;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.paging.ActionPagingSupport;
 import org.hisp.dhis.program.ProgramInstance;
 import org.hisp.dhis.program.ProgramInstanceService;
@@ -70,6 +72,13 @@
         this.selectedStateManager = selectedStateManager;
     }
 
+    private OrganisationUnitService organisationUnitService;
+
+    public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+    {
+        this.organisationUnitService = organisationUnitService;
+    }
+
     private ProgramStageService programStageService;
 
     public void setProgramStageService( ProgramStageService programStageService )
@@ -172,6 +181,13 @@
         this.type = type;
     }
 
+    private String facilityLB;
+
+    public void setFacilityLB( String facilityLB )
+    {
+        this.facilityLB = facilityLB;
+    }
+
     // -------------------------------------------------------------------------
     // Implementation Action
     // -------------------------------------------------------------------------
@@ -179,7 +195,35 @@
     public String execute()
         throws Exception
     {
-        OrganisationUnit organisationUnit = selectedStateManager.getSelectedOrganisationUnit();
+        // ---------------------------------------------------------------------
+        // Get orgunitIds
+        // ---------------------------------------------------------------------
+
+        OrganisationUnit selectedOrgunit = selectedStateManager.getSelectedOrganisationUnit();
+
+        Set<Integer> orgunitIds = new HashSet<Integer>();
+
+        if ( facilityLB.equals( "random" ) )
+        {
+            orgunitIds.add( selectedOrgunit.getId() );
+        }
+        else
+        {
+            OrganisationUnitHierarchy hierarchy = organisationUnitService.getOrganisationUnitHierarchy();
+
+            Set<Integer> childOrgUnitIdentifiers = hierarchy.getChildren( selectedOrgunit.getId() );
+
+            orgunitIds.addAll( childOrgUnitIdentifiers );
+
+            if ( facilityLB.equals( "immChildren" ) )
+            {
+                orgunitIds.remove( selectedOrgunit.getId() );
+            }
+        }
+
+        // ---------------------------------------------------------------------
+        // Get program-stage, start-date, end-date
+        // ---------------------------------------------------------------------
 
         ProgramStage programStage = programStageService.getProgramStage( programStageId );
 
@@ -189,11 +233,19 @@
 
         dataElements = new ArrayList<DataElement>();
 
+        // ---------------------------------------------------------------------
+        // Get selected dataelements
+        // ---------------------------------------------------------------------
+
         for ( Integer dataElementId : dataElementIds )
         {
             dataElements.add( dataElementService.getDataElement( dataElementId ) );
         }
 
+        // ---------------------------------------------------------------------
+        // Get searching-keys
+        // ---------------------------------------------------------------------
+
         Map<Integer, String> searchingKeys = new HashMap<Integer, String>();
 
         for ( String searchingValue : searchingValues )
@@ -203,20 +255,24 @@
             searchingKeys.put( Integer.parseInt( infor[0] ), infor[1] );
         }
 
+        // ---------------------------------------------------------------------
+        // Generate tabular report
+        // ---------------------------------------------------------------------
+
         if ( type == null )
         {
             total = programStageInstanceService.countProgramStageInstances( programStage, searchingKeys,
-                organisationUnit, startValue, endValue );
+                orgunitIds, startValue, endValue );
 
             this.paging = createPaging( total );
 
             grid = programStageInstanceService.getTabularReport( programStage, dataElements, searchingKeys,
-                organisationUnit, startValue, endValue, paging.getStartPos(), paging.getPageSize(), format, i18n );
+                orgunitIds, startValue, endValue, paging.getStartPos(), paging.getPageSize(), format, i18n );
             return SUCCESS;
         }
-        
+
         grid = programStageInstanceService.getTabularReport( programStage, dataElements, searchingKeys,
-            organisationUnit, startValue, endValue, format, i18n );
+            orgunitIds, startValue, endValue, format, i18n );
 
         return type;
     }

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml	2012-03-07 02:40:08 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml	2012-03-07 05:54:02 +0000
@@ -285,6 +285,8 @@
         	ref="org.hisp.dhis.program.ProgramStageInstanceService" />
         <property name="selectedStateManager"
         	ref="org.hisp.dhis.caseentry.state.SelectedStateManager" />
+         <property name="organisationUnitService"
+        	ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
 	</bean>
 
 	<!-- Case Aggregation -->

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2012-03-07 02:40:08 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2012-03-07 05:54:02 +0000
@@ -36,7 +36,8 @@
 registration_date=Date of Registration
 full_name=Full Name
 entry=Entry
-data_element=Data Element
+available_data_elements=Available Data Element
+selected_data_elements=Selected Data Element
 nr=Number
 program_stage=Program Stage
 specify_a_search_criteria=Please specify your search criteria
@@ -250,7 +251,7 @@
 see_history_plan=See history / plan
 name_based_data_entry=Name-based data entry
 multiple_name_based_data_entry=Multiple name-based data entry
-ga_facilityby=Organisation Unit By
+facility_by=Organisation Unit By
 saved = Saved
 save_selected_values = Save selected values
 save_all_values = Save all values
@@ -264,4 +265,6 @@
 set_complete_status = Set complete status
 orgunit_provided_service = Organisation unit provided service
 how_to_search_tabular_report = Quotes (") match phrases. Text values support %%, %=, %= and =. Numeric values support >=, >, <=, <, = and != operators.
-syntax_error_in_search_value = Syntax error is in search value
\ No newline at end of file
+syntax_error_in_search_value = Syntax error is in search value
+remove_selected_data_elements = Please remove selected data elements to select other program stage. Do you want to remove them ?
+add_selected = Add selected

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationForm.vm	2011-11-07 07:56:20 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationForm.vm	2012-03-07 05:54:02 +0000
@@ -49,7 +49,7 @@
 			</tr>
 			<tr>
 				<td>
-				   $i18n.getString( "ga_facilityby" )
+				   $i18n.getString( "facility_by" )
 				</td>
 				<td>
 					<select id="facilityLB" name="facilityLB" style="width: 30em">

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/tabularReport.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/tabularReport.js	2012-03-05 07:32:05 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/tabularReport.js	2012-03-07 05:54:02 +0000
@@ -2,8 +2,8 @@
 function organisationUnitSelected( orgUnits, orgUnitNames )
 {
 	hideById('contentDiv');
-	setFieldValue('startDate', '');
-	setFieldValue('endDate', '');
+	clearListById( 'programStageId' );
+	clearListById( 'availableDataElementIds' );
 	
 	$.getJSON( 'loadProgramsByOrgunit.action',{}
 		, function( json ) 
@@ -36,12 +36,14 @@
 function loadProgramStages()
 {
 	clearListById( 'programStageId' );
-	clearListById( 'dataElementIds' );
+	clearListById( 'availableDataElementIds' );
 	
 	if( getFieldValue('programId') == '' )
 	{
 		return;
 	}
+	
+	clearListById( 'dataElementIds' );
 	$.getJSON( 'loadTabularProgramStages.action',
 		{
 			programId: getFieldValue('programId')
@@ -59,23 +61,34 @@
 
 function loadDataElements()
 {
-	clearListById( 'dataElementIds' );
 	if( getFieldValue('programStageId') == '' )
 	{
 		return;
 	}
-	
-	$.getJSON( 'loadDataElements.action',
-		{
-			programStageId: getFieldValue('programStageId')
-		}
-		, function( json ) 
-		{
-			for ( i in json.dataElements ) 
-			{ 
-				$('#dataElementIds').append('<option value=' + json.dataElements[i].id + '>' + json.dataElements[i].name + '</option>');
-			}
-		} );
+	else
+	{
+		var result = false;
+		if( byId( 'dataElementIds' ).options.length > 0 )
+		{
+			result = window.confirm( i18n_remove_selected_data_elements );
+		}
+		
+		if ( result || byId( 'dataElementIds' ).options.length == 0 )
+		{
+			clearListById( 'dataElementIds' );
+			$.getJSON( 'loadDataElements.action',
+				{
+					programStageId: getFieldValue('programStageId')
+				}
+				, function( json ) 
+				{
+					for ( i in json.dataElements ) 
+					{ 
+						$('#availableDataElementIds').append('<option value=' + json.dataElements[i].id + '>' + json.dataElements[i].name + '</option>');
+					}
+				} );
+		}
+	}
 }
 
 
@@ -257,7 +270,7 @@
 	});
 	
 	var dataElementIds = "";
-	var listDataElementIds = jQuery( "select[id=dataElementIds] option:selected" );
+	var listDataElementIds = jQuery( "select[id=dataElementIds] option" );
 	listDataElementIds.each( function( i, item ){
 		dataElementIds += "dataElementIds=" + item.value;
 		dataElementIds += ( i < listDataElementIds.length - 1 ) ? "&" : "";
@@ -266,5 +279,6 @@
 	return searchingValues + dataElementIds
 				+ "&programStageId=" + getFieldValue('programStageId')
 				+ "&startDate=" + getFieldValue('startDate')
-				+ "&endDate=" + getFieldValue('endDate');
+				+ "&endDate=" + getFieldValue('endDate')
+				+ "&facilityLB=" + getFieldValue('facilityLB');
 }

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/style/report.css'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/style/report.css	2012-03-05 06:07:54 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/style/report.css	2012-03-07 05:54:02 +0000
@@ -7,7 +7,12 @@
 	width:140px; 
 }
 
-.inputCriteria input
+input[type="button"], input[type="submit"]
+{
+	width:150px;
+}
+
+.inputCriteria input[type="text"]
 {
 	width:350px; 
 }

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/tabularReportSelect.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/tabularReportSelect.vm	2012-03-05 06:07:54 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/tabularReportSelect.vm	2012-03-07 05:54:02 +0000
@@ -10,17 +10,17 @@
 <form id="reportForm" name="reportForm" method="post">
 <p><input type="button" value="$i18n.getString('data')" onclick="showCriteria();" style="width:150px;" ></p>
 
-<div class="inputCriteria" id='criteriaDiv' style="width:530px;height:300px;margin-bottom:20px;">
+<div class="inputCriteria" id='criteriaDiv' style="width:550px;height:460px;margin-bottom:20px;">
 
 <table>	
     <tr>
 	  <td><label>$i18n.getString( "reporting_unit" )</label></td>
-	  <td><input type="text" readonly="readonly" id='orgunitname' name='orgunitname' #if($!orgunit) value="$!orgunit.name" #else value="[$i18n.getString( 'select' )]" #end ></td>
+	  <td colspan='2'><input type="text" readonly="readonly" id='orgunitname' name='orgunitname' #if($!orgunit) value="$!orgunit.name" #else value="[$i18n.getString( 'select' )]" #end ></td>
     </tr>
     
     <tr>
         <td><label for="programId">$i18n.getString( "program" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
-        <td>
+        <td colspan='2'>
             <select id="programId" name="programId" #if($!programs) #else disabled #end class="{validate:{required:true}}" onchange='loadProgramStages();'>
 				<option value=''>[$i18n.getString('please_select')]</option>
 				#foreach( $program in $programs )
@@ -32,7 +32,7 @@
         
     <tr>
         <td><label>$i18n.getString( "start_date" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
-        <td>
+        <td colspan='2'>
             <input type="text" id="startDate" name="startDate" class="{validate:{required:true}}" />
 			<script type="text/javascript">
 				datePicker('startDate');
@@ -42,7 +42,7 @@
     
     <tr>
         <td><label>$i18n.getString( "end_date" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
-        <td>
+        <td colspan='2'>
             <input type="text" id="endDate" name="endDate" class="{validate:{required:true}}" />
             <script type="text/javascript">
 				datePicker('endDate');
@@ -51,21 +51,57 @@
     </tr>
 	<tr>
         <td><label>$i18n.getString( "program_stage" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
-        <td>
+        <td colspan='2'>
 			<select id="programStageId" name="programStageId" class="{validate:{required:true}}" onchange='loadDataElements();'></select>
         </td>      
     </tr>
+	
 	<tr>
-		<td><label>$i18n.getString( "data_elements" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
-         <td>
-			<select id="dataElementIds" name="dataElementIds" multiple size='6' class="{validate:{required:true}}" ></select>
+		<td><label>$i18n.getString( "available_data_elements" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
+        <td colspan='2'>
+			<select id="availableDataElementIds" name="availableDataElementIds" multiple size='6' ondblclick="moveSelectedById( 'availableDataElementIds', 'dataElementIds' )" ></select>
         </td>      
     </tr>
+	
+	<tr>
+        <td></td>
+		<td>
+            <input type="button" value="$i18n.getString( 'add_selected' )" title="$i18n.getString( 'add_selected' )" onclick="moveSelectedById( 'availableDataElementIds', 'dataElementIds' )" />
+            <input type="button" value="$i18n.getString( 'remove_selected' )" title="$i18n.getString( 'remove_selected' )" onclick="moveSelectedById( 'dataElementIds', 'availableDataElementIds' )" />
+        </td>
+    </tr>
+	
+	<tr>
+		<td><label>$i18n.getString( "selected_data_elements" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
+        <td>
+			<select id="dataElementIds" name="dataElementIds" multiple size='6' class="{validate:{required:true}}" ondblclick="moveSelectedById( 'dataElementIds', 'availableDataElementIds' )" ></select>
+        </td> 
+		<td style="width:30px; text-align:center">
+            <a href="javascript:moveUpSelectedOption('dataElementIds')"><img src="../images/move_up.png"/></a><br/><br/>
+            <a href="javascript:moveDownSelectedOption('dataElementIds')"><img src="../images/move_down.png"/></a><br/><br/>
+        </td>  			
+    </tr>
+    <tr>
+		<td>
+		   $i18n.getString( "facility_by" )
+		</td>
+		<td>
+			<select id="facilityLB" name="facilityLB" style="width: 30em">
+				<option value="random" selected>$i18n.getString( "selected" )</option>
+				<option value="immChildren" >$i18n.getString( "immediate_children" )</option>
+				<option value="children" >$i18n.getString( "child_tree" )</option>
+			</select>
+		</td>
+	</tr>
+	
+	<tr>
+		<td>&nbsp;</td>
+	</tr>
     
-    <tr>
+	<tr>
     	<td></td>
-    	<td><input type="submit" id='generateBtn' name='generateBtn' #if($!programs) #else disabled #end value="$i18n.getString( 'generate' )" style="width:150px;" />
-    		<input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='index.action'" style="width:150px;" />
+    	<td><input type="submit" id='generateBtn' name='generateBtn' #if($!programs) #else disabled #end value="$i18n.getString( 'generate' )" />
+    		<input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='index.action'" />
     	</td>
     </tr>	                		
 </table>
@@ -88,4 +124,5 @@
 	var i18n_show_all_items = "[" + '$encoder.jsEscape( $i18n.getString( "show_all_items" ) , "'" )' + "]";
 	var i18n_complete_confirm_message = '$encoder.jsEscape( $i18n.getString( "complete_confirm_message" ) , "'")';
 	var i18n_syntax_error_in_search_value = '$encoder.jsEscape( $i18n.getString( "syntax_error_in_search_value" ) , "'")';
+	var i18n_remove_selected_data_elements = '$encoder.jsEscape( $i18n.getString( "remove_selected_data_elements" ) , "'")';
 </script>