← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9663: Add ad-hoc aggregated reports in Tabular reports (WIP).

 

------------------------------------------------------------
revno: 9663
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2013-01-30 16:34:29 +0700
message:
  Add ad-hoc aggregated reports in Tabular reports (WIP).
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientreport/PatientAggregateReport.java
  dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patientreport/hibernate/PatientAggregateReport.hbm.xml
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/SaveAggregateReportAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularAggregateReport.vm


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

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientreport/PatientAggregateReport.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientreport/PatientAggregateReport.java	2013-01-30 07:54:43 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientreport/PatientAggregateReport.java	2013-01-30 09:34:29 +0000
@@ -109,6 +109,8 @@
     private int position;
 
     private DataElement deGroupBy;
+    
+    private DataElement deSum;
 
     private String aggregateType;
 
@@ -295,4 +297,14 @@
         this.userOrganisationUnitChildren = userOrganisationUnitChildren;
     }
 
+    public DataElement getDeSum()
+    {
+        return deSum;
+    }
+
+    public void setDeSum( DataElement deSum )
+    {
+        this.deSum = deSum;
+    }
+
 }

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patientreport/hibernate/PatientAggregateReport.hbm.xml'
--- dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patientreport/hibernate/PatientAggregateReport.hbm.xml	2013-01-21 09:52:11 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patientreport/hibernate/PatientAggregateReport.hbm.xml	2013-01-30 09:34:29 +0000
@@ -74,6 +74,9 @@
 		<property name="userOrganisationUnit" />
 		
 		<property name="userOrganisationUnitChildren" />
+		
+		<many-to-one name="deSum" class="org.hisp.dhis.dataelement.DataElement"
+			column="desumid" foreign-key="fk_patientaggregatereport_dataelementsumtid" />
 
 	</class>
 </hibernate-mapping>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/SaveAggregateReportAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/SaveAggregateReportAction.java	2013-01-25 08:32:01 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/SaveAggregateReportAction.java	2013-01-30 09:34:29 +0000
@@ -193,6 +193,13 @@
         this.deGroupBy = deGroupBy;
     }
 
+    private Integer deSum;
+
+    public void setDeSum( Integer deSum )
+    {
+        this.deSum = deSum;
+    }
+
     private Boolean useCompletedEvents;
 
     public void setUseCompletedEvents( Boolean useCompletedEvents )
@@ -255,6 +262,11 @@
         {
             aggregateReport.setDeGroupBy( dataElementService.getDataElement( deGroupBy ) );
         }
+        
+        if ( deSum != null )
+        {
+            aggregateReport.setDeSum( dataElementService.getDataElement( deSum ) );
+        }
 
         if ( useCompletedEvents != null )
         {

=== 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-30 07:54:43 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js	2013-01-30 09:34:29 +0000
@@ -1227,7 +1227,8 @@
 								Ext.getCmp('limitOption').setValue( f.limitRecords );
 								TR.util.positionFilter.convert( f.position );
 								Ext.getCmp('dataElementGroupByCbx').setValue( f.deGroupBy );
-								Ext.getCmp('aggregateType').setValue( f.deGroupBy );
+								Ext.getCmp('deSumCbx').setValue( f.deSum );
+								Ext.getCmp('aggregateType').setValue( f.aggregateType );
 								Ext.getCmp('levelCombobox').setValue( f.level );
 																
 								// Program stage									
@@ -1235,7 +1236,6 @@
 								storeProgramStage.parent = f.programStageId;
 								storeProgramStage.isLoadFromFavorite = true;
 								storeProgramStage.load({params: {programId: f.programId}});
-								
 								Ext.getCmp('programStageCombobox').setValue( f.programStageId );
 								
 								TR.exe.execute();
@@ -1921,7 +1921,7 @@
 				p.aggregateType = Ext.getCmp('aggregateType').getValue().aggregateType;
 				if( p.aggregateType != 'count')
 				{
-					p.deSum = Ext.getCmp('deSumCbx').getValue();
+					p.deSum = Ext.getCmp('deSumCbx').getValue().split('_')[1];
 				}				
 				
 				// orgunits
@@ -2747,7 +2747,6 @@
 									id: 'reportTypeGroup',
 									fieldLabel: TR.i18n.report_type,
 									labelStyle: 'font-weight:bold',
-									//labelAlign: 'top',
 									columns: 2,
 									vertical: true,
 									items: [
@@ -2760,6 +2759,7 @@
 											change: function (cb, nv, ov) {
 												if(nv)
 												{
+													// for case-based report
 													dataElementTabTitle.innerHTML = TR.i18n.data_elements;
 													Ext.getCmp('limitOption').setVisible(false);
 													Ext.getCmp('dataElementGroupByCbx').setVisible(false);
@@ -2770,6 +2770,7 @@
 													Ext.getCmp('completedEventsOpt').setVisible(false);
 													Ext.getCmp('aggregateFavoriteBtn').setVisible(false);
 													Ext.getCmp('datePeriodRangeDiv').setVisible(false);
+													Ext.getCmp('deSumCbx').setVisible(false);
 													Ext.getCmp('caseBasedFavoriteBtn').setVisible(true);
 													Ext.getCmp('levelCombobox').setVisible(true);
 													
@@ -2789,6 +2790,7 @@
 											change: function (cb, nv, ov) {
 												if(nv)
 												{
+													// For aggregate report
 													dataElementTabTitle.innerHTML = TR.i18n.data_filter;
 													Ext.getCmp('limitOption').setVisible(true);
 													Ext.getCmp('dataElementGroupByCbx').setVisible(true);
@@ -2796,11 +2798,12 @@
 													Ext.getCmp('downloadPdfIcon').setVisible(true);
 													Ext.getCmp('downloadCvsIcon').setVisible(true);
 													Ext.getCmp('aggregateFavoriteBtn').setVisible(true);
-													Ext.getCmp('caseBasedFavoriteBtn').setVisible(false);
 													Ext.getCmp('positionField').setVisible(true);
 													Ext.getCmp('completedEventsOpt').setVisible(true);
+													Ext.getCmp('deSumCbx').setVisible(true);
 													Ext.getCmp('dateRangeDiv').setVisible(false);
 													Ext.getCmp('levelCombobox').setVisible(false);
+													Ext.getCmp('caseBasedFavoriteBtn').setVisible(false);
 													
 													Ext.getCmp('datePeriodRangeDiv').setVisible(true);
 													Ext.getCmp('fixedPeriodsDiv').setVisible(true);
@@ -4176,12 +4179,29 @@
 														boxLabel: TR.i18n.avg,
 														name: 'aggregateType',
 														inputValue: 'avg'
-													}]
+													}],
+													listeners: {
+														change : function(thisFormField, newValue, oldValue, eOpts) {
+														  var opt = newValue.aggregateType[0];
+														  
+														  if( opt==oldValue.aggregateType && newValue.aggregateType.length > 1){
+															opt = newValue.aggregateType[1];
+														  }
+														  
+														  if (opt=='sum' || opt=='avg') {
+															Ext.getCmp('deSumCbx').enable();
+														  }
+														  else  if (opt=='count'){
+															Ext.getCmp('deSumCbx').disable();
+														  }
+														}
+													}
 												},
 												{
 													xtype: 'combobox',
 													cls: 'tr-combo',
 													id: 'deSumCbx',
+													disabled: true,
 													fieldLabel: TR.i18n.sum_avg_of,
 													labelWidth: 135,
 													emptyText: TR.i18n.please_select,
@@ -5526,6 +5546,7 @@
 				dataElementTabTitle.innerHTML = TR.i18n.data_elements;
 				Ext.getCmp('limitOption').setVisible(false);
 				Ext.getCmp('dataElementGroupByCbx').setVisible(false);
+				Ext.getCmp('deSumCbx').setVisible(false);
 				Ext.getCmp('aggregateType').setVisible(false);
 				Ext.getCmp('downloadPdfIcon').setVisible(false);
 				Ext.getCmp('downloadCvsIcon').setVisible(false);

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularAggregateReport.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularAggregateReport.vm	2013-01-26 07:07:27 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularAggregateReport.vm	2013-01-30 09:34:29 +0000
@@ -90,6 +90,7 @@
 	"limitRecords": "$!aggregateReport.limitRecords",
 	"position": "${aggregateReport.position}",
 	"deGroupBy": #if($!aggregateReport.deGroupBy) "de_$!aggregateReport.deGroupBy.id" #else "" #end,
+	"deSum": #if($!aggregateReport.deSum) "de_$!aggregateReport.deSum.id" #else "" #end,
 	"aggregateType": "${aggregateReport.aggregateType}",
 	"useCompletedEvents": "$!aggregateReport.useCompletedEvents",
 	"userOrganisationUnit": "$!aggregateReport.userOrganisationUnit",