← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9564: Add ad-hoc aggregated reports in Tabular reports - Allow right-click to select chilren orgunit; a...

 

------------------------------------------------------------
revno: 9564
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-01-21 14:29:15 +0700
message:
  Add ad-hoc aggregated reports in Tabular reports - Allow right-click to select chilren orgunit; allow to pivot table content of case 6,7 and 8.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientreport/PatientAggregateReport.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/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/style/style.css


--
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-16 08:41:28 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientreport/PatientAggregateReport.java	2013-01-21 07:29:15 +0000
@@ -64,6 +64,10 @@
     public static final int POSITION_ROW_ORGUNIT_COLUMN_DATA = 7;
 
     public static final int POSITION_ROW_DATA = 8;
+    
+    public static final int POSITION_ROW_DATA_COLUMN_PERIOD = 9; // PIVOT FROM 6
+    
+    public static final int POSITION_ROW_DATA_COLUMN_ORGUNIT = 10; // PIVOT FROM A
 
     private ProgramStage programStage;
 

=== 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-01-21 06:18:31 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java	2013-01-21 07:29:15 +0000
@@ -504,7 +504,8 @@
         }
 
         // Type = 6 && With group-by
-        else if ( position == PatientAggregateReport.POSITION_ROW_PERIOD_COLUMN_DATA && deGroupBy != null )
+        else if ( (position == PatientAggregateReport.POSITION_ROW_PERIOD_COLUMN_DATA || position == PatientAggregateReport.POSITION_ROW_DATA_COLUMN_PERIOD)
+            && deGroupBy != null )
         {
             List<String> deValues = new ArrayList<String>();
 
@@ -514,11 +515,13 @@
             // Headers cols
             // ---------------------------------------------------------------------
 
-            grid.addHeader( new GridHeader( i18n.getString( "period" ), false, true ) );
-
-            for ( String deValue : deValues )
+            if ( position == PatientAggregateReport.POSITION_ROW_PERIOD_COLUMN_DATA )
             {
-                grid.addHeader( new GridHeader( deValue, false, false ) );
+                grid.addHeader( new GridHeader( i18n.getString( "period" ), false, true ) );
+                for ( String deValue : deValues )
+                {
+                    grid.addHeader( new GridHeader( deValue, false, false ) );
+                }
             }
 
             // ---------------------------------------------------------------------
@@ -530,14 +533,18 @@
         }
 
         // Type = 6 && NOT group-by
-        else if ( position == PatientAggregateReport.POSITION_ROW_PERIOD_COLUMN_DATA && deGroupBy == null )
+        else if ( (position == PatientAggregateReport.POSITION_ROW_PERIOD_COLUMN_DATA || position == PatientAggregateReport.POSITION_ROW_DATA_COLUMN_PERIOD)
+            && deGroupBy == null )
         {
             // ---------------------------------------------------------------------
             // Headers cols
             // ---------------------------------------------------------------------
 
-            grid.addHeader( new GridHeader( i18n.getString( "period" ), false, true ) );
-            grid.addHeader( new GridHeader( i18n.getString( aggregateType ), false, false ) );
+            if ( position == PatientAggregateReport.POSITION_ROW_PERIOD_COLUMN_DATA )
+            {
+                grid.addHeader( new GridHeader( i18n.getString( "period" ), false, true ) );
+                grid.addHeader( new GridHeader( i18n.getString( aggregateType ), false, false ) );
+            }
 
             // ---------------------------------------------------------------------
             // Get SQL and build grid
@@ -548,7 +555,8 @@
         }
 
         // Type = 7 && Group-by
-        else if ( position == PatientAggregateReport.POSITION_ROW_ORGUNIT_COLUMN_DATA && deGroupBy != null )
+        else if ( (position == PatientAggregateReport.POSITION_ROW_ORGUNIT_COLUMN_DATA || position == PatientAggregateReport.POSITION_ROW_DATA_COLUMN_ORGUNIT)
+            && deGroupBy != null )
         {
             List<String> deValues = dataElementService.getDataElement( deGroupBy ).getOptionSet().getOptions();
 
@@ -556,11 +564,14 @@
             // Headers cols
             // ---------------------------------------------------------------------
 
-            grid.addHeader( new GridHeader( i18n.getString( "orgunit" ), false, true ) );
-
-            for ( String deValue : deValues )
+            if ( position == PatientAggregateReport.POSITION_ROW_ORGUNIT_COLUMN_DATA )
             {
-                grid.addHeader( new GridHeader( deValue, false, false ) );
+                grid.addHeader( new GridHeader( i18n.getString( "orgunit" ), false, true ) );
+
+                for ( String deValue : deValues )
+                {
+                    grid.addHeader( new GridHeader( deValue, false, false ) );
+                }
             }
 
             // ---------------------------------------------------------------------
@@ -573,15 +584,19 @@
         }
 
         // Type = 7 && NOT group-by
-        else if ( position == PatientAggregateReport.POSITION_ROW_ORGUNIT_COLUMN_DATA )
+        else if ( (position == PatientAggregateReport.POSITION_ROW_ORGUNIT_COLUMN_DATA || position == PatientAggregateReport.POSITION_ROW_DATA_COLUMN_ORGUNIT)
+            && deGroupBy == null )
         {
             // ---------------------------------------------------------------------
             // Headers cols
             // ---------------------------------------------------------------------
-
-            grid.addHeader( new GridHeader( i18n.getString( "orgunit" ), false, true ) );
-            grid.addHeader( new GridHeader( i18n.getString( aggregateType ), false, false ) );
-
+            
+            if ( position == PatientAggregateReport.POSITION_ROW_ORGUNIT_COLUMN_DATA )
+            {
+                grid.addHeader( new GridHeader( i18n.getString( "orgunit" ), false, true ) );
+                grid.addHeader( new GridHeader( i18n.getString( aggregateType ), false, false ) );
+            }
+            
             // ---------------------------------------------------------------------
             // Get SQL and build grid
             // ---------------------------------------------------------------------
@@ -608,18 +623,21 @@
             sql = getAggregateReportSQL8( programStage, orgunitIds, facilityLB, filterSQL, deGroupBy, periods
                 .iterator().next(), aggregateType, limit, useCompletedEvents, format );
         }
+
         System.out.println( "\n\n === \n " + sql );
         SqlRowSet rowSet = jdbcTemplate.queryForRowSet( sql );
 
         // Type != 2
-        if ( position != PatientAggregateReport.POSITION_ROW_PERIOD_COLUMN_ORGUNIT )
+        if ( position == PatientAggregateReport.POSITION_ROW_PERIOD_COLUMN_ORGUNIT
+            || position == PatientAggregateReport.POSITION_ROW_DATA_COLUMN_PERIOD
+            || position == PatientAggregateReport.POSITION_ROW_DATA_COLUMN_ORGUNIT )
+        {
+            pivotTable( grid, rowSet );
+        }
+        else
         {
             GridUtils.addRows( grid, rowSet );
         }
-        else
-        {
-            pivotTable( grid, rowSet );
-        }
 
         return grid;
     }
@@ -1061,8 +1079,6 @@
     {
         String sql = "";
 
-        int index = 0;
-
         Collection<Integer> orgunitIds = getOrganisationUnits( root, facilityLB );
 
         for ( Period period : periods )
@@ -1094,9 +1110,7 @@
                 sql += "        (SELECT value from patientdatavalue ";
                 sql += "        WHERE programstageinstanceid=psi_1.programstageinstanceid AND ";
                 sql += "              dataelementid=" + deGroupBy + ") = '" + deValue + "' ";
-                sql += ") as de_value_" + index + ",";
-
-                index++;
+                sql += ") as \"" + deValue + "\",";
             }
             sql = sql.substring( 0, sql.length() - 1 ) + " ";
 
@@ -1161,7 +1175,7 @@
                 sql += "WHERE programstageinstanceid=psi_1.programstageinstanceid AND ";
                 sql += "      dataelementid=" + deGroupBy + ") is not null ";
             }
-            sql += filterSQL + "),";
+            sql += filterSQL + ") as \"" + aggregateType + "\",";
 
             sql = sql.substring( 0, sql.length() - 1 ) + " ";
 
@@ -1219,7 +1233,7 @@
                 sql += "   WHERE programstageinstanceid=psi_1.programstageinstanceid AND ";
                 sql += "     dataelementid= pdv_1.dataelementid AND ";
                 sql += "     dataelementid=" + deGroupBy + "  ) = '" + deValue + "' ";
-                sql += "),";
+                sql += ") as \"" + aggregateType + "\",";
             }
 
             sql = sql.substring( 0, sql.length() - 1 ) + " ) ";
@@ -1261,7 +1275,7 @@
             }
             sql += "        psi_1.organisationunitid in (" + TextUtils.getCommaDelimitedString( orgunitIds ) + ") AND ";
             sql += "        psi_1.programstageid=" + programStage.getId() + " ";
-            sql += filterSQL + ") ) ";
+            sql += filterSQL + ") as \"" + aggregateType + "\" ) ";
 
             sql += " UNION ";
         }

=== 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-01-21 06:18:31 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2013-01-21 07:29:15 +0000
@@ -541,4 +541,5 @@
 user_orgunit_children = User organisation unit chilren
 auto_select_orgunit_by = Auto-select organisation units by
 like = LIKE
-in = IN
\ No newline at end of file
+in = IN
+select_all_children = Select all children
\ 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-01-21 06:18:31 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js	2013-01-21 07:29:15 +0000
@@ -142,7 +142,9 @@
 		POSITION_ROW_ORGUNIT: 5,
 		POSITION_ROW_PERIOD_COLUMN_DATA: 6,
 		POSITION_ROW_ORGUNIT_COLUMN_DATA: 7,
-		POSITION_ROW_DATA: 8
+		POSITION_ROW_DATA: 8,
+		POSITION_ROW_DATA_COLUMN_PERIOD: 9,
+		POSITION_ROW_DATA_COLUMN_ORGUNIT: 10
 	},
     statusbar: {
 		icon: {
@@ -527,7 +529,10 @@
 				{
 					var periodStore = TR.cmp.settings.positionPeriod.store;
 					periodStore.removeAll();
-					periodStore.add ({value: 1,name: TR.i18n.rows});
+					periodStore.add (
+						{value: 1,name: TR.i18n.rows},
+						{value: 3,name: TR.i18n.filter}
+					);
 					Ext.getCmp('positionPeriodCbx').setValue( 1 );
 					
 					var dataStore = TR.cmp.settings.positionData.store;
@@ -542,6 +547,7 @@
 					periodStore.removeAll();
 					periodStore.add (
 						{value: 1,name: TR.i18n.rows},
+						{value: 2,name: TR.i18n.columns},
 						{value: 3,name: TR.i18n.filters}
 					);
 					Ext.getCmp('positionPeriodCbx').setValue( 1 );
@@ -577,6 +583,20 @@
 					}
 					Ext.getCmp('positionDataCbx').setValue( 3 );
 				}
+				else if( o==2 ){
+					if( p==3 ){
+						dataStore.add (
+							{value: 1,name: TR.i18n.rows}
+						);
+						Ext.getCmp('positionDataCbx').setValue( 1 );
+					}
+					else if( p==1 ){
+						dataStore.add (
+							{value: 3,name: TR.i18n.filters}
+						);
+						Ext.getCmp('positionDataCbx').setValue( 3 );
+					}
+				}
 				else if( o==3 && p==1 ){
 					dataStore.add (
 						{value: 2,name: TR.i18n.columns},
@@ -584,7 +604,7 @@
 					);
 					Ext.getCmp('positionDataCbx').setValue( 2 );
 				}
-				else if( o==3 && p==3 ){
+				else if( o==3 && ( p==2 || p==3 ) ){
 					var dataStore = TR.cmp.settings.positionData.store;
 					dataStore.removeAll();
 					dataStore.add (
@@ -651,6 +671,18 @@
 					Ext.getCmp('positionDataCbx').setValue(1);
 					this.period();
 					break;
+				case TR.conf.reportPosition.POSITION_ROW_DATA_COLUMN_PERIOD :
+					Ext.getCmp('positionOrgunitCbx').setValue(3);
+					Ext.getCmp('positionPeriodCbx').setValue(2);
+					Ext.getCmp('positionDataCbx').setValue(1);
+					this.period();
+					break;
+				case TR.conf.reportPosition.POSITION_ROW_DATA_COLUMN_ORGUNIT :
+					Ext.getCmp('positionOrgunitCbx').setValue(2);
+					Ext.getCmp('positionPeriodCbx').setValue(3);
+					Ext.getCmp('positionDataCbx').setValue(1);
+					this.period();
+					break;
 				}
 			}
 		},
@@ -1757,6 +1789,16 @@
 				{
 					return TR.conf.reportPosition.POSITION_ROW_DATA;
 				}
+				// 9
+				if( positionOrgunit==3 && positionPeriod==2 && positionData==1 )
+				{
+					return TR.conf.reportPosition.POSITION_ROW_DATA_COLUMN_PERIOD;
+				}
+				// 10
+				if( positionOrgunit==2 && positionPeriod==3 && positionData==1 )
+				{
+					return TR.conf.reportPosition.POSITION_ROW_DATA_COLUMN_ORGUNIT;
+				}
 				return '';
 			},
 			getParams: function( isSorted ) {

=== 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-01-21 06:18:31 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/i18n.vm	2013-01-21 07:29:15 +0000
@@ -154,4 +154,5 @@
 auto_select_orgunit_by: '$encoder.jsEscape($i18n.getString( 'auto_select_orgunit_by' ) , "'")',
 in: '$encoder.jsEscape($i18n.getString( 'in' ) , "'")',
 like: '$encoder.jsEscape($i18n.getString( 'like' ) , "'")',
+select_all_children: '$encoder.jsEscape($i18n.getString( 'select_all_children' ) , "'")'
 };
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/style/style.css'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/style/style.css	2012-12-17 03:12:41 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/style/style.css	2013-01-21 07:29:15 +0000
@@ -502,3 +502,10 @@
     line-height: 170%;
 }
 
+/* Treepanel contextmenu */
+#treepanel-contextmenu {
+    border-radius: 2px;
+    border-width: 1px;
+    border-style: solid;
+    border-color: #aaa;
+}