← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9870: Add user-orgunit, user-orgunit-children and useCompletedEvent propertites for case-based report

 

------------------------------------------------------------
revno: 9870
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-02-22 11:49:30 +0700
message:
  Add user-orgunit, user-orgunit-children and useCompletedEvent propertites for case-based report
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientreport/PatientTabularReport.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/GenerateAggregateReportAction.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/java/org/hisp/dhis/caseentry/action/report/SaveTabularReportAction.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/webapp/dhis-web-caseentry/app/app.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/cacheManifest.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js
  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/patientreport/PatientTabularReport.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientreport/PatientTabularReport.java	2012-12-27 14:07:54 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patientreport/PatientTabularReport.java	2013-02-22 04:49:30 +0000
@@ -85,6 +85,12 @@
 
     private String facilityLB;
 
+    private Boolean useCompletedEvents;
+
+    private Boolean userOrganisationUnit;
+
+    private Boolean userOrganisationUnitChildren;
+
     // -------------------------------------------------------------------------
     // Constructors
     // -------------------------------------------------------------------------
@@ -201,4 +207,35 @@
     {
         this.facilityLB = facilityLB;
     }
+
+    public Boolean getUserOrganisationUnit()
+    {
+        return userOrganisationUnit;
+    }
+
+    public void setUserOrganisationUnit( Boolean userOrganisationUnit )
+    {
+        this.userOrganisationUnit = userOrganisationUnit;
+    }
+
+    public Boolean getUserOrganisationUnitChildren()
+    {
+        return userOrganisationUnitChildren;
+    }
+
+    public void setUserOrganisationUnitChildren( Boolean userOrganisationUnitChildren )
+    {
+        this.userOrganisationUnitChildren = userOrganisationUnitChildren;
+    }
+
+    public Boolean getUseCompletedEvents()
+    {
+        return useCompletedEvents;
+    }
+
+    public void setUseCompletedEvents( Boolean useCompletedEvents )
+    {
+        this.useCompletedEvents = useCompletedEvents;
+    }
+
 }

=== 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	2013-02-07 10:25:34 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/resources/org/hisp/dhis/patientreport/hibernate/PatientTabularReport.hbm.xml	2013-02-22 04:49:30 +0000
@@ -62,6 +62,12 @@
 
     <many-to-one name="user" class="org.hisp.dhis.user.User"
       column="userid" foreign-key="fk_patienttabularreport_userid" />
+      
+    <property name="useCompletedEvents" />
+    
+    <property name="userOrganisationUnit" />
+
+    <property name="userOrganisationUnitChildren" />
 
   </class>
 </hibernate-mapping>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateAggregateReportAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateAggregateReportAction.java	2013-02-13 15:16:11 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateAggregateReportAction.java	2013-02-22 04:49:30 +0000
@@ -29,7 +29,6 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
@@ -44,7 +43,6 @@
 import org.hisp.dhis.period.PeriodService;
 import org.hisp.dhis.period.PeriodType;
 import org.hisp.dhis.period.RelativePeriods;
-import org.hisp.dhis.period.comparator.PeriodComparator;
 import org.hisp.dhis.program.ProgramStage;
 import org.hisp.dhis.program.ProgramStageInstanceService;
 import org.hisp.dhis.program.ProgramStageService;

=== 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	2013-02-18 13:12:14 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateTabularReportAction.java	2013-02-22 04:49:30 +0000
@@ -55,6 +55,7 @@
 import org.hisp.dhis.program.ProgramStageInstanceService;
 import org.hisp.dhis.program.ProgramStageService;
 import org.hisp.dhis.system.util.TextUtils;
+import org.hisp.dhis.user.CurrentUserService;
 
 /**
  * @author Chau Thu Tran
@@ -96,11 +97,18 @@
         this.programStageInstanceService = programStageInstanceService;
     }
 
+    private CurrentUserService currentUserService;
+
+    public void setCurrentUserService( CurrentUserService currentUserService )
+    {
+        this.currentUserService = currentUserService;
+    }
+
     // -------------------------------------------------------------------------
     // Input/Output
     // -------------------------------------------------------------------------
 
-    private Collection<Integer> orgunitIds;
+    private Collection<Integer> orgunitIds = new HashSet<Integer>();
 
     public void setOrgunitIds( Collection<Integer> orgunitIds )
     {
@@ -156,6 +164,20 @@
         this.level = level;
     }
 
+    private Boolean userOrganisationUnit;
+
+    public void setUserOrganisationUnit( Boolean userOrganisationUnit )
+    {
+        this.userOrganisationUnit = userOrganisationUnit;
+    }
+
+    private Boolean userOrganisationUnitChildren;
+
+    public void setUserOrganisationUnitChildren( Boolean userOrganisationUnitChildren )
+    {
+        this.userOrganisationUnitChildren = userOrganisationUnitChildren;
+    }
+
     private Grid grid;
 
     public Grid getGrid()
@@ -196,11 +218,11 @@
         this.format = format;
     }
 
-    private Boolean completed;
+    private Boolean useCompletedEvents;
 
-    public void setCompleted( Boolean completed )
+    public void setUseCompletedEvents( Boolean useCompletedEvents )
     {
-        this.completed = completed;
+        this.useCompletedEvents = useCompletedEvents;
     }
 
     private List<DataElement> dataElements = new ArrayList<DataElement>();
@@ -253,6 +275,38 @@
         throws Exception
     {
         // ---------------------------------------------------------------------
+        // Get user orgunits
+        // ---------------------------------------------------------------------
+
+        if ( userOrganisationUnit || userOrganisationUnitChildren )
+        {
+            Collection<OrganisationUnit> userOrgunits = currentUserService.getCurrentUser().getOrganisationUnits();
+            orgunitIds = new HashSet<Integer>();
+
+            if ( userOrganisationUnit )
+            {
+                for ( OrganisationUnit userOrgunit : userOrgunits )
+                {
+                    orgunitIds.add( userOrgunit.getId() );
+                }
+            }
+
+            if ( userOrganisationUnitChildren )
+            {
+                for ( OrganisationUnit userOrgunit : userOrgunits )
+                {
+                    if ( userOrgunit.hasChild() )
+                    {
+                        for ( OrganisationUnit childOrgunit : userOrgunit.getSortedChildren() )
+                        {
+                            orgunitIds.add( childOrgunit.getId() );
+                        }
+                    }
+                }
+            }
+        }
+
+        // ---------------------------------------------------------------------
         // Get orgunitIds
         // ---------------------------------------------------------------------
 
@@ -276,17 +330,8 @@
         {
             for ( Integer orgunitId : orgunitIds )
             {
-                OrganisationUnit selectedOrgunit = organisationUnitService.getOrganisationUnit( orgunitId );
-
-                if ( selectedOrgunit.getParent() == null )
-                {
-                    organisationUnits = null; // Ignore unit criteria when root
-                }
-                else
-                {
-                    organisationUnits.addAll( organisationUnitService.getOrganisationUnitHierarchy().getChildren(
-                        orgunitId ) );
-                }
+                organisationUnits.addAll( organisationUnitService.getOrganisationUnitHierarchy()
+                    .getChildren( orgunitId ) );
             }
         }
 
@@ -324,20 +369,21 @@
             if ( type == null ) // Tabular report
             {
                 totalRecords = programStageInstanceService.getTabularReportCount( programStage, columns,
-                    organisationUnits, level, completed, startValue, endValue );
+                    organisationUnits, level, useCompletedEvents, startValue, endValue );
 
                 total = getNumberOfPages( totalRecords );
 
                 this.paging = createPaging( totalRecords );
 
                 grid = programStageInstanceService.getTabularReport( programStage, columns, organisationUnits, level,
-                    startValue, endValue, !orderByOrgunitAsc, completed, getStartPos(), paging.getPageSize(), i18n );
+                    startValue, endValue, !orderByOrgunitAsc, useCompletedEvents, getStartPos(), paging.getPageSize(),
+                    i18n );
             }
             else
             // Download as Excel
             {
                 grid = programStageInstanceService.getTabularReport( programStage, columns, organisationUnits, level,
-                    startValue, endValue, !orderByOrgunitAsc, completed, null, null, i18n );
+                    startValue, endValue, !orderByOrgunitAsc, useCompletedEvents, null, null, i18n );
             }
         }
         catch ( SQLGrammarException ex )

=== 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-06-12 03:38:24 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/SaveTabularReportAction.java	2013-02-22 04:49:30 +0000
@@ -154,6 +154,12 @@
 
     private String facilityLB;
 
+    private Boolean useCompletedEvents;
+
+    private Boolean userOrganisationUnit;
+
+    private Boolean userOrganisationUnitChildren;
+
     // -------------------------------------------------------------------------
     // Setters
     // -------------------------------------------------------------------------
@@ -203,6 +209,21 @@
         this.programStageId = programStageId;
     }
 
+    public void setUseCompletedEvents( Boolean useCompletedEvents )
+    {
+        this.useCompletedEvents = useCompletedEvents;
+    }
+
+    public void setUserOrganisationUnit( Boolean userOrganisationUnit )
+    {
+        this.userOrganisationUnit = userOrganisationUnit;
+    }
+
+    public void setUserOrganisationUnitChildren( Boolean userOrganisationUnitChildren )
+    {
+        this.userOrganisationUnitChildren = userOrganisationUnitChildren;
+    }
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -211,8 +232,8 @@
     public String execute()
         throws Exception
     {
-        Set<OrganisationUnit> orgunits = new HashSet<OrganisationUnit>( organisationUnitService
-            .getOrganisationUnits( orgunitIds ) );
+        Set<OrganisationUnit> orgunits = new HashSet<OrganisationUnit>(
+            organisationUnitService.getOrganisationUnits( orgunitIds ) );
         ProgramStage programStage = programStageService.getProgramStage( programStageId );
 
         // ---------------------------------------------------------------------
@@ -228,6 +249,21 @@
         tabularReport.setSortedOrgunitAsc( orderByOrgunitAsc );
         tabularReport.setUser( currentUserService.getCurrentUser() );
 
+        if ( useCompletedEvents != null )
+        {
+            tabularReport.setUseCompletedEvents( useCompletedEvents );
+        }
+
+        if ( userOrganisationUnit != null )
+        {
+            tabularReport.setUserOrganisationUnit( userOrganisationUnit );
+        }
+
+        if ( userOrganisationUnitChildren != null )
+        {
+            tabularReport.setUserOrganisationUnitChildren( userOrganisationUnitChildren );
+        }
+
         // ---------------------------------------------------------------------
         // Get searching-keys
         // ---------------------------------------------------------------------

=== 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	2013-02-19 04:01:58 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml	2013-02-22 04:49:30 +0000
@@ -879,6 +879,7 @@
 		<property name="organisationUnitService"
 			ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
 		<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
+		<property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
 	</bean>
 
 	<bean

=== 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-02-19 08:38:10 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/app/app.js	2013-02-22 04:49:30 +0000
@@ -1001,6 +1001,9 @@
 								Ext.getCmp('endDate').setValue( f.endDate );
 								Ext.getCmp('facilityLBCombobox').setValue( f.facilityLB );
 								Ext.getCmp('levelCombobox').setValue( f.level );
+								Ext.getCmp('userOrgunit').setValue( f.userOrganisationUnit );
+								Ext.getCmp('userOrgunitChildren').setValue( f.userOrganisationUnitChildren );								
+								Ext.getCmp('completedEventsOpt').setValue(f.useCompletedEvents);
 								
 								// Orgunits
 								
@@ -1162,7 +1165,6 @@
 									};
 								}
 								TR.store.fixedperiod.selected.loadData(periods);
-																
 								
 								// Orgunits
 								
@@ -1604,6 +1606,9 @@
 				
 				// organisation unit
 				p.orgunitIds = TR.state.orgunitIds;
+				p.userOrganisationUnit = Ext.getCmp('userOrgunit').getValue();
+				p.userOrganisationUnitChildren = Ext.getCmp('userOrgunitChildren').getValue();
+				p.useCompletedEvents = Ext.getCmp('completedEventsOpt').getValue();
 				
 				// Get searching values
 				p.searchingValues = [];
@@ -1653,7 +1658,10 @@
 				document.getElementById('orderByOrgunitAsc').value = this.orderByOrgunitAsc;
 				document.getElementById('orderByExecutionDateByAsc').value = this.orderByExecutionDateByAsc;
 				document.getElementById('programStageId').value = TR.cmp.params.programStage.getValue();				
-				
+				document.getElementById('userOrganisationUnit').value = Ext.getCmp('userOrgunit').getValue();
+				document.getElementById('userOrganisationUnitChildren').value = Ext.getCmp('userOrgunitChildren').getValue();
+				document.getElementById('useCompletedEvents').value = Ext.getCmp('completedEventsOpt').getValue();
+
 				// orgunits
 				var orgunitIdList = document.getElementById('orgunitIds');
 				TR.util.list.clearList(orgunitIdList);
@@ -1769,7 +1777,9 @@
 						return false;
 					}
 				
-					if (TR.state.orgunitIds.length == 0) {
+					if (TR.state.orgunitIds.length == 0 
+						&& TR.cmp.aggregateFavorite.userorganisationunit.getValue() == 'false'
+						&& TR.cmp.aggregateFavorite.userorganisationunitchildren.getValue() == 'false' ) {
 						TR.util.notification.error(TR.i18n.et_no_orgunits, TR.i18n.em_no_orgunits);
 						return false;
 					}
@@ -1997,7 +2007,6 @@
 				
 				p.facilityLB = TR.cmp.settings.facilityLB.getValue();
 				p.position = position;
-				
 				p.useCompletedEvents = Ext.getCmp('completedEventsOpt').getValue();
 				
 				return p;
@@ -2811,7 +2820,6 @@
 													Ext.getCmp('downloadPdfIcon').setVisible(false);
 													Ext.getCmp('downloadCvsIcon').setVisible(false);
 													Ext.getCmp('positionField').setVisible(false);
-													Ext.getCmp('completedEventsOpt').setVisible(false);
 													Ext.getCmp('aggregateFavoriteBtn').setVisible(false);
 													Ext.getCmp('datePeriodRangeDiv').setVisible(false);
 													Ext.getCmp('deSumCbx').setVisible(false);
@@ -2844,7 +2852,6 @@
 													Ext.getCmp('downloadCvsIcon').setVisible(true);
 													Ext.getCmp('aggregateFavoriteBtn').setVisible(true);
 													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);
@@ -5611,7 +5618,6 @@
 				Ext.getCmp('downloadPdfIcon').setVisible(false);
 				Ext.getCmp('downloadCvsIcon').setVisible(false);
 				Ext.getCmp('positionField').setVisible(false);
-				Ext.getCmp('completedEventsOpt').setVisible(false);
 				Ext.getCmp('aggregateFavoriteBtn').setVisible(false);
 				Ext.getCmp('datePeriodRangeDiv').setVisible(false);
 				Ext.getCmp('caseBasedFavoriteBtn').setVisible(true);

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/cacheManifest.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/cacheManifest.vm	2013-02-22 03:59:31 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/cacheManifest.vm	2013-02-22 04:49:30 +0000
@@ -1,5 +1,5 @@
 CACHE MANIFEST
-# 2.11-SNAPSHOT V5
+# 2.11-SNAPSHOT V6
 NETWORK:
 *
 CACHE:

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js	2013-02-22 03:59:31 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js	2013-02-22 04:49:30 +0000
@@ -385,7 +385,7 @@
 		params += '&endDate=' + getFieldValue('endDate');
 		if(byId("incompleted").checked)
 		{
-			params += '&completed=false';
+			params += '&useCompletedEvents=false';
 		}
 		jQuery( '#advancedSearchTB tr' ).each( function(index, row){
 			if( index>1 )
@@ -417,6 +417,8 @@
 	params += '&orgunitIds=' + getFieldValue('orgunitId');
 	params += '&programStageId=' + jQuery('#programId option:selected').attr('psid');
 	params += '&orderByOrgunitAsc=false';
+	params += '&userOrganisationUnit=false';
+	params += '&userOrganisationUnitChildren=false';
 
 	contentDiv = 'listDiv';
 	showLoader();

=== 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	2013-02-13 15:58:32 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonTabularReport.vm	2013-02-22 04:49:30 +0000
@@ -9,6 +9,10 @@
 		#else
 			"false",
 		#end
+	#if( $tabularReport.programStage)
+		#set($programStage = $tabularReport.programStage)
+	#end
+	
 	"type": "${programStage.program.type}",
 	"programStageId": "${programStage.id}",
 	"programStageName": "$!encoder.jsonEncode( ${programStage.displayName} )",
@@ -17,6 +21,9 @@
 	"level": "${tabularReport.level}",
 	"sortedOrgunitAsc": "${tabularReport.sortedOrgunitAsc}",
 	"facilityLB": "${tabularReport.facilityLB}",
+	"useCompletedEvents": "$!tabularReport.useCompletedEvents",
+	"userOrganisationUnit": "$!tabularReport.userOrganisationUnit",
+	"userOrganisationUnitChildren": "$!tabularReport.userOrganisationUnitChildren",
 	"orgunitIds": [
 		#set( $size = $tabularReport.organisationUnits.size() )
 		#set( $organisationUnits = ${tabularReport.organisationUnits} )