← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6628: (patient) Separate each orgunit into one column in Tabular report.

 

------------------------------------------------------------
revno: 6628
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-04-18 11:03:50 +0700
message:
  (patient) Separate each orgunit into one column 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/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/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/program/ProgramStageInstanceService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java	2012-04-17 04:30:42 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java	2012-04-18 04:03:50 +0000
@@ -99,5 +99,4 @@
     
     List<Grid> getProgramStageInstancesReport( ProgramInstance programInstance, I18nFormat format, I18n i18n );
     
-    List<ProgramStageInstance> getProgramStages( OrganisationUnit orgunit, Program program, 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-04-17 04:30:42 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java	2012-04-18 04:03:50 +0000
@@ -77,5 +77,4 @@
 
     int count( ProgramStage programStage, Map<Integer,String> searchingIdenKeys, Map<Integer,String> searchingAttrKeys, Map<Integer,String> searchingKeys, Collection<Integer> orgunitIds, Date startDate, Date endDate );
     
-    List<ProgramStageInstance> get( OrganisationUnit orgunit, Program program, Date startDate, Date endDate );
 }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java	2012-04-17 04:30:42 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java	2012-04-18 04:03:50 +0000
@@ -336,12 +336,6 @@
         return grids;
     }
 
-    public List<ProgramStageInstance> getProgramStages( OrganisationUnit orgunit, Program program, Date startDate,
-        Date endDate )
-    {
-        return programStageInstanceStore.get( orgunit, program, startDate, endDate );
-    }
-
     // -------------------------------------------------------------------------
     // Supportive methods
     // -------------------------------------------------------------------------
@@ -369,9 +363,19 @@
             // Headers
             // ---------------------------------------------------------------------
 
-            grid.addHeader( new GridHeader( i18n.getString( "report_unit" ), false, true ) );
+            // Organisation units
+            int maxLevel = organisationUnitService.getMaxOfOrganisationUnitLevels();
+
+            for ( int i = level; i < maxLevel; i++ )
+            {
+                grid.addHeader( new GridHeader( organisationUnitService.getOrganisationUnitLevelByLevel( i ).getName(),
+                    false, true ) );
+            }
+
+            // Report-date
             grid.addHeader( new GridHeader( i18n.getString( "report_date" ), false, true ) );
 
+            // Identifier types
             int index = 0;
             if ( idens != null && idens.size() > 0 )
             {
@@ -382,6 +386,7 @@
                 }
             }
 
+            // Attributes
             if ( attributes != null && attributes.size() > 0 )
             {
                 for ( PatientAttribute attribute : attributes )
@@ -391,6 +396,7 @@
                 }
             }
 
+            // Dataelements
             if ( dataElements != null && dataElements.size() > 0 )
             {
                 for ( DataElement dataElement : dataElements )
@@ -409,10 +415,28 @@
                 grid.addRow();
 
                 // -------------------------------------------------------------
-                // Add enrollment information
-                // -------------------------------------------------------------
-
-                grid.addValue( getHierarchyOrgunit( programStageInstance.getOrganisationUnit(), level ) );
+                // Add organisation units
+                // -------------------------------------------------------------
+
+                Map<Integer, String> hierarchyOrgunit = getHierarchyOrgunit(
+                    programStageInstance.getOrganisationUnit(), level );
+
+                for ( int i = level; i < maxLevel; i++ )
+                {
+                    if ( hierarchyOrgunit.get( i ) != null )
+                    {
+                        grid.addValue( hierarchyOrgunit.get( i ) );
+                    }
+                    else
+                    {
+                        grid.addValue("");
+                    }
+                }
+
+                // -------------------------------------------------------------
+                // Report-date
+                // -------------------------------------------------------------
+
                 grid.addValue( format.formatDate( programStageInstance.getExecutionDate() ) );
 
                 // -------------------------------------------------------------
@@ -486,19 +510,22 @@
         return grid;
     }
 
-    private String getHierarchyOrgunit( OrganisationUnit orgunit, int level )
+    private Map<Integer, String> getHierarchyOrgunit( OrganisationUnit orgunit, int level )
     {
-        String hierarchyOrgunit = orgunit.getName();
+        Map<Integer, String> hierarchyOrgunit = new HashMap<Integer, String>();
+        hierarchyOrgunit.put( level, orgunit.getName() );
 
         orgunit = orgunit.getParent();
 
         while ( orgunit != null && organisationUnitService.getLevelOfOrganisationUnit( orgunit.getId() ) >= level )
         {
-            hierarchyOrgunit = orgunit.getName() + " / " + hierarchyOrgunit;
+            hierarchyOrgunit.put( organisationUnitService.getLevelOfOrganisationUnit( orgunit.getId() ), orgunit
+                .getName() );
 
             orgunit = orgunit.getParent();
         }
 
         return hierarchyOrgunit;
     }
+
 }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java	2012-04-17 04:30:42 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java	2012-04-18 04:03:50 +0000
@@ -44,7 +44,6 @@
 import org.hisp.dhis.jdbc.StatementBuilder;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.patient.Patient;
-import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramInstance;
 import org.hisp.dhis.program.ProgramStage;
 import org.hisp.dhis.program.ProgramStageInstance;
@@ -236,15 +235,10 @@
         return (countRow != null && countRow.size() > 0) ? countRow.get( 0 ) : 0;
     }
 
-    @SuppressWarnings( "unchecked" )
-    public List<ProgramStageInstance> get( OrganisationUnit orgunit, Program program, Date startDate, Date endDate )
-    {
-        return getCriteria().createAlias( "programStage", "programStage" ).add(
-            Restrictions.eq( "programStage.program", program ) ).add( Restrictions.eq( "organisationUnit", orgunit ) )
-            .add( Restrictions.between( "dueDate", startDate, endDate ) ).list();
-    }
-
-    // -------------------------------------------------------------------------
+    // -------------------------------------------------------------------------
+    // Supportive methods
+    // -------------------------------------------------------------------------
+    
     private String getTabularReportStatement( boolean isCount, ProgramStage programStage,
         Map<Integer, String> searchingIdenKeys, Map<Integer, String> searchingAttrKeys,
         Map<Integer, String> searchingDEKeys, Collection<Integer> orgunitIds, Date startDate, Date endDate,

=== 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-04-17 03:46:23 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateTabularReportAction.java	2012-04-18 04:03:50 +0000
@@ -345,9 +345,9 @@
         return type;
     }
 
-    // ---------------------------------------------------------------------
+    // -------------------------------------------------------------------------
     // Supportive methods
-    // ---------------------------------------------------------------------
+    // -------------------------------------------------------------------------
 
     public int getNumberOfPages( int totalRecord )
     {

=== 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-04-17 15:28:26 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2012-04-18 04:03:50 +0000
@@ -314,4 +314,5 @@
 et_no_data = No data returned from server
 et_no_dataelement = Please select at least one data element.
 em_no_orgunits = Please select an organisation unit.
-reload = Reload
\ No newline at end of file
+reset = Reset
+no = No.
\ 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-04-17 15:28:26 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js	2012-04-18 04:03:50 +0000
@@ -550,6 +550,7 @@
 						TR.state.total = json.total;
 						TR.value.valueTypes = json.valueTypes;
 						TR.value.fields = json.fields;
+						TR.value.columns = json.columns;
 						TR.value.values = json.items;
 						
 						if ( json.items.length > 1 )
@@ -725,6 +726,7 @@
     
     TR.value = {
 		valueTypes: [],
+		columns: [],
 		fields: [],
 		values: []
     };
@@ -735,7 +737,7 @@
 			// column
 			var cols = [];
 			cols[0] = {
-				header: '#', 
+				header: TR.i18n.no, 
 				dataIndex: 'id',
 				width: 50,
 				height: TR.conf.layout.east_gridcolumn_height,
@@ -744,26 +746,34 @@
 				groupable: true
 			}
 			
-			cols[1] = {
-				header: TR.i18n.report_unit, 
-				dataIndex: 'col1',
-				height: TR.conf.layout.east_gridcolumn_height,
-				sortable: false,
-				draggable: false,
-				groupable: true
-			};
-			
-			cols[2] = { 
+			var paramsLen = TR.cmp.params.identifierType.selected.store.data.length
+						+ TR.cmp.params.patientAttribute.selected.store.data.length
+						+ TR.cmp.params.dataelement.selected.store.data.length;
+			
+			var orgunitColsLen = TR.value.columns.length - paramsLen - 2;
+			var index = 1;
+			
+			for( index=1; index < orgunitColsLen + 1; index++ )
+			{
+				cols[index] = {
+					header: TR.value.columns[index], 
+					dataIndex: 'col' + index,
+					height: TR.conf.layout.east_gridcolumn_height,
+					sortable: false,
+					draggable: false,
+					groupable: true
+				}
+			}
+			
+			cols[index] = { 
 				header: TR.i18n.report_date, 
-				dataIndex: 'col2',
-				width: 150,
-				height: TR.conf.layout.east_gridcolumn_height,
+				dataIndex: 'col' + index,
 				sortable: false,
 				draggable: false,
 				groupable: true
 			};
 			
-			var index = 3;
+			index++;
 			TR.cmp.params.identifierType.selected.store.each( function(r) {
 				var dataIndex = "col" + index;
 				cols[index] = { 
@@ -797,7 +807,7 @@
 					draggable: false,
 					groupable: true,
 					editor: {
-							xtype: TR.value.valueTypes[index].valueType,
+							xtype: TR.value.valueTypes[index - orgunitColsLen - 2].valueType,
 							queryMode: 'local',
 							editable: true,
 							valueField: 'name',
@@ -805,7 +815,7 @@
 							allowBlank: true,
 							store:  new Ext.data.ArrayStore({
 								fields: ['name'],
-								data: TR.value.valueTypes[index].suggestedValues,
+								data: TR.value.valueTypes[index - orgunitColsLen - 2].suggestedValues,
 							})
 						}
 					};
@@ -826,7 +836,7 @@
 					draggable: false,
 					groupable: true,
 					editor: {
-						xtype: TR.value.valueTypes[index].valueType,
+						xtype: TR.value.valueTypes[index - orgunitColsLen - 2].valueType,
 							queryMode: 'local',
 							editable: true,
 							valueField: 'name',
@@ -834,38 +844,13 @@
 							allowBlank: true,
 							store: new Ext.data.ArrayStore({
 								fields: ['name'],
-								data: TR.value.valueTypes[index].suggestedValues,
+								data: TR.value.valueTypes[index - orgunitColsLen - 2].suggestedValues,
 							})
 					}
 				};
 				index++;
 			});
 			
-			cols1 = [
-				{
-					text: TR.i18n.commons,
-					colspan: 3, 
-					align: 'center'
-				},
-				{ 
-					text: TR.i18n.identifiers,
-					colspan: TR.cmp.params.identifierType.selected.length, 
-					align: 'center'
-				},
-				{
-					text: TR.i18n.attributes,
-					colspan: TR.cmp.params.patientAttribute.selected.length, 
-					align: 'center'
-				},
-				{
-					text: TR.i18n.data_elements,
-					colspan: TR.cmp.params.dataelement.selected.length, 
-					align: 'center'
-				}
-			];
-			
-			var group = new Ext.ux.grid.ColumnHeaderGroup({rows: [cols1, cols]});
-			
 			// grid
 			this.datatable = Ext.create('Ext.grid.Panel', {
                 height: TR.util.viewport.getSize().y - 68,
@@ -977,8 +962,6 @@
 							}
 						}
 					})
-					
-					,group
 				],
 				store: TR.store.datatable
 				,listeners: {
@@ -1048,7 +1031,7 @@
 			Ext.getCmp('currentPage').setValue( currentPage );	
 			TR.datatable.setPagingToolbarStatus();
 		},
-		reload: function() {
+		reset: function() {
 			TR.store.datatable.loadData([],false);
 			this.execute();
 		},
@@ -1809,11 +1792,11 @@
 						{
 							xtype: 'button',
 							cls: 'tr-toolbar-btn-1',
-							text: TR.i18n.reload,
+							text: TR.i18n.reset,
 							width: 50,
 							listeners: {
 								click: function() {
-									TR.exe.reload();
+									TR.exe.reset();
 								}
 							}
 						},

=== 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-04-17 03:46:23 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/i18n.vm	2012-04-18 04:03:50 +0000
@@ -1,12 +1,12 @@
 TR.i18n = {
 title:'$encoder.jsEscape($i18n.getString( 'title' ) , "'")',
 programs: '$encoder.jsEscape($i18n.getString( 'program' ) , "'")',
-identifier:'$encoder.jsEscape($i18n.getString( 'identifier' ) , "'")',
-attribute:'$encoder.jsEscape($i18n.getString( 'attribute' ) , "'")',
+identifiers:'$encoder.jsEscape($i18n.getString( 'identifiers' ) , "'")',
+attributes:'$encoder.jsEscape($i18n.getString( 'attributes' ) , "'")',
 start_date:'$encoder.jsEscape($i18n.getString( 'start_date' ) , "'")',
 end_date:'$encoder.jsEscape($i18n.getString( 'end_date' ) , "'")',
 et_no_programs:'$encoder.jsEscape($i18n.getString( 'et_no_programs' ) , "'")',
-data_element:'$encoder.jsEscape($i18n.getString( 'data_element' ) , "'")',
+data_elements:'$encoder.jsEscape($i18n.getString( 'data_elements' ) , "'")',
 program_stage:'$encoder.jsEscape($i18n.getString( 'program_stage' ) , "'")',
 please_select:'[' + '$encoder.jsEscape($i18n.getString( 'please_select' ) , "'")'  + ']',
 all_attribute_groups:'$encoder.jsEscape($i18n.getString( 'all_attribute_groups' ) , "'")',
@@ -35,4 +35,9 @@
 et_no_data:'$encoder.jsEscape($i18n.getString( 'et_no_data' ) , "'")',
 em_no_orgunits:'$encoder.jsEscape($i18n.getString( 'em_no_orgunits' ) , "'")',
 organisation_units:'$encoder.jsEscape($i18n.getString( 'organisation_units' ) , "'")',
+commons:'$encoder.jsEscape($i18n.getString( 'commons' ) , "'")',
+asc:'$encoder.jsEscape($i18n.getString( 'asc' ) , "'")',
+options:'$encoder.jsEscape($i18n.getString( 'options' ) , "'")',
+reset:'$encoder.jsEscape($i18n.getString( 'reset' ) , "'")',
+no:'$encoder.jsEscape($i18n.getString( 'no' ) , "'")'
 };
\ 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	2012-04-15 08:08:22 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularReport.vm	2012-04-18 04:03:50 +0000
@@ -1,12 +1,18 @@
 {
 #if( $grid.getRows().size() > 0)
-	#set( $noHeader = $grid.getRows().get(0).size() )
+	#set( $noHeader = $grid.getHeaders().size() )
+	#set ( $noOrgunit = $noHeader - $valueTypes.size())
 	'total': "$total",
 	'valueTypes':[
-		{"valueType": "", "suggestedValues":[]},
-		{"valueType": "", "suggestedValues":[]},
-		{"valueType": "", "suggestedValues":[]},
-		#set( $index = 0 )
+		#foreach( $col in $grid.getVisibleHeaders() )
+			#if ($velocityCount <= $noOrgunit + 1)
+				{
+					"valueType": "",
+					"suggestedValues": []
+				},
+			#end
+		#end
+			
 		#foreach( $valueType in $valueTypes )
 			{
 				"valueType": 
@@ -32,9 +38,16 @@
 			#set( $index = $index + 1 )
 		#end
 	],
+	'columns':[
+		"id",
+		#foreach( $colName in $grid.getVisibleHeaders() )
+			"$colName.name"
+			#if( $velocityCount < $noHeader ),#end
+		#end
+	],
 	'fields':[
 		"id",
-		#foreach( $col in $grid.getRows().get(0) )
+		#foreach( $col in $grid.getHeaders() )
 			"col$velocityCount"
 			#if( $velocityCount < $noHeader ),#end
 		#end
@@ -42,9 +55,13 @@
 	'items':[
 		{
 			"id":"$i18n.getString( 'filter' )",
-			"col1": "",
-			"col2": "",
-			#set( $index = 3 )
+			#foreach( $col in $grid.getVisibleHeaders() )
+				#if ($velocityCount <= $noOrgunit )
+					"col$velocityCount": "",
+				#end
+			#end
+			
+			#set( $index = $noOrgunit + 1 )
 			#foreach( $value in $values )
 				"col$index": "$value"
 				#if( $velocityCount < $values.size() ),#end
@@ -65,6 +82,7 @@
 #else
 	'total': 0,
 	'valueTypes':[],
+	'columns':[],
 	'fields':[],
 	'items':[]
 #end