← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11482: Allow to select multi orgunits in Program stage completeness.

 

------------------------------------------------------------
revno: 11482
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-07-23 11:16:21 +0700
message:
  Allow to select multi orgunits in Program stage completeness.
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/caseentry/ProgramStageInstanceCompletenessAction.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/resources/struts.xml
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/programStageCompleteness.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programStageCompletenessSelect.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	2013-07-04 08:55:19 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceService.java	2013-07-23 04:16:21 +0000
@@ -132,7 +132,7 @@
 
     Collection<Integer> getOrganisationUnitIds( Date startDate, Date endDate );
 
-    Grid getCompletenessProgramStageInstance( OrganisationUnit orgunit, Program program, String startDate,
+    Grid getCompletenessProgramStageInstance( Collection<Integer> orgunits, Program program, String startDate,
         String endDate, I18n i18n );
 
 }

=== 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	2013-07-04 06:19:49 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/program/ProgramStageInstanceStore.java	2013-07-23 04:16:21 +0000
@@ -123,6 +123,6 @@
 
     Collection<Integer> getOrgunitIds( Date startDate, Date endDate );
 
-    Grid getCompleteness( OrganisationUnit orgunit, Program program, String startDate, String endDate, I18n i18n );
+    Grid getCompleteness( Collection<Integer> orgunitIds, Program program, String startDate, String endDate, I18n i18n );
 
 }

=== 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	2013-07-04 08:55:19 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/DefaultProgramStageInstanceService.java	2013-07-23 04:16:21 +0000
@@ -523,10 +523,10 @@
     }
 
     @Override
-    public Grid getCompletenessProgramStageInstance( OrganisationUnit orgunit, Program program, String startDate,
+    public Grid getCompletenessProgramStageInstance( Collection<Integer> orgunitIds, Program program, String startDate,
         String endDate, I18n i18n )
     {
-        return programStageInstanceStore.getCompleteness( orgunit, program, startDate, endDate, i18n );
+        return programStageInstanceStore.getCompleteness( orgunitIds, program, startDate, endDate, i18n );
     }
 
 }

=== 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-07-02 12:24:02 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java	2013-07-23 04:16:21 +0000
@@ -732,7 +732,7 @@
         return rs != null ? rs.intValue() : 0;
     }
 
-    public Grid getCompleteness( OrganisationUnit orgunit, Program program, String startDate, String endDate, I18n i18n )
+    public Grid getCompleteness( Collection<Integer> orgunitIds, Program program, String startDate, String endDate, I18n i18n )
     {
         String sql = "SELECT ou.name as orgunit, ps.name as events, psi.completeduser as user_name, count(psi.programstageinstanceid) as number_of_events "
             + "         FROM programstageinstance psi INNER JOIN programstage ps "
@@ -741,9 +741,9 @@
             + "                         ON ou.organisationunitid=psi.organisationunitid"
             + "                 INNER JOIN program pg "
             + "                         ON pg.programid = ps.programid "
-            + "         WHERE ou.parentid = "
-            + orgunit.getId()
-            + "                 AND pg.programid = "
+            + "         WHERE ou.organisationunitid in ( "
+            + TextUtils.getCommaDelimitedString( orgunitIds )
+            + " )                AND pg.programid = "
             + program.getId()
             + "         GROUP BY ou.name, ps.name, psi.completeduser, psi.completeddate, psi.completed "
             + "         HAVING psi.completeddate >= '"

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/ProgramStageInstanceCompletenessAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/ProgramStageInstanceCompletenessAction.java	2013-04-16 05:41:25 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/ProgramStageInstanceCompletenessAction.java	2013-07-23 04:16:21 +0000
@@ -27,10 +27,14 @@
 
 package org.hisp.dhis.caseentry.action.caseentry;
 
+import java.util.Collection;
+import java.util.HashSet;
+
 import org.hisp.dhis.common.Grid;
 import org.hisp.dhis.i18n.I18n;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.oust.manager.SelectionTreeManager;
 import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramService;
 import org.hisp.dhis.program.ProgramStageInstanceService;
@@ -49,11 +53,18 @@
     // Dependencies
     // -------------------------------------------------------------------------
 
-    private OrganisationUnitSelectionManager selectionManager;
-
-    public void setSelectionManager( OrganisationUnitSelectionManager selectionManager )
-    {
-        this.selectionManager = selectionManager;
+    private SelectionTreeManager selectionTreeManager;
+
+    public void setSelectionTreeManager( SelectionTreeManager selectionTreeManager )
+    {
+        this.selectionTreeManager = selectionTreeManager;
+    }
+
+    private OrganisationUnitService organisationUnitService;
+
+    public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+    {
+        this.organisationUnitService = organisationUnitService;
     }
 
     private ProgramService programService;
@@ -109,6 +120,13 @@
         this.type = type;
     }
 
+    private String facilityLB;
+
+    public void setFacilityLB( String facilityLB )
+    {
+        this.facilityLB = facilityLB;
+    }
+
     private Grid grid;
 
     public Grid getGrid()
@@ -126,10 +144,40 @@
     {
         Program program = programService.getProgram( programId );
 
-        OrganisationUnit orgunit = selectionManager.getSelectedOrganisationUnit();
-
-        grid = programStageInstanceService.getCompletenessProgramStageInstance( orgunit, program, startDate, endDate,
-            i18n );
+        Collection<OrganisationUnit> orgunits = selectionTreeManager.getRootOrganisationUnits();
+
+        program = programService.getProgram( programId );
+
+        // ---------------------------------------------------------------------
+        // Get orgunitIds
+        // ---------------------------------------------------------------------
+
+        Collection<Integer> orgunitIds = new HashSet<Integer>();
+
+        for ( OrganisationUnit orgunit : orgunits )
+        {
+            if ( facilityLB.equals( "selected" ) )
+            {
+                orgunitIds.add( orgunit.getId() );
+            }
+            else if ( facilityLB.equals( "childrenOnly" ) )
+            {
+                orgunitIds
+                    .addAll( organisationUnitService.getOrganisationUnitHierarchy().getChildren( orgunit.getId() ) );
+                orgunitIds.remove( orgunit.getId() );
+            }
+            else
+            {
+                orgunitIds
+                    .addAll( organisationUnitService.getOrganisationUnitHierarchy().getChildren( orgunit.getId() ) );
+            }
+        }
+
+        if ( orgunitIds.size() > 0 )
+        {
+            grid = programStageInstanceService.getCompletenessProgramStageInstance( orgunitIds, program, startDate,
+                endDate, i18n );
+        }
 
         return (type == null) ? SUCCESS : 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	2013-07-23 02:52:29 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml	2013-07-23 04:16:21 +0000
@@ -1162,8 +1162,10 @@
 		id="org.hisp.dhis.caseentry.action.caseentry.ProgramStageInstanceCompletenessAction"
 		class="org.hisp.dhis.caseentry.action.caseentry.ProgramStageInstanceCompletenessAction"
 		scope="prototype">
-		<property name="selectionManager"
-			ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
+		<property name="selectionTreeManager"
+			ref="org.hisp.dhis.oust.manager.SelectionTreeManager" />
+		<property name="organisationUnitService"
+			ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
 		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
 		<property name="programStageInstanceService"
 			ref="org.hisp.dhis.program.ProgramStageInstanceService" />

=== 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-07-09 07:14:55 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2013-07-23 04:16:21 +0000
@@ -664,4 +664,5 @@
 table_layout = Layout
 is_hidden = Is hidden
 default_form_name = Default form name
-custom_form_name = Custom form name
\ No newline at end of file
+custom_form_name = Custom form name
+use_orgunits_from_level = Use organisation Units from level
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml	2013-06-13 07:36:43 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml	2013-07-23 04:16:21 +0000
@@ -1163,10 +1163,9 @@
       <interceptor-ref name="organisationUnitTreeStack" />
       <result name="success" type="velocity">/main.vm</result>
       <param name="page">/dhis-web-caseentry/programStageCompletenessSelect.vm</param>
-      <param name="menu">/dhis-web-caseentry/reportsMenu.vm</param>
+      <param name="menu">/dhis-web-caseentry/reportsMenuWithoutOrgunit.vm</param>
       <param name="stylesheets">style/style.css</param>
       <param name="javascripts">
-      	../dhis-web-commons/ouwt/ouwt.js,
       	javascript/commons.js,
       	javascript/programStageCompleteness.js</param>
       <param name="requiredAuthorities">F_PROGRAM_STAGE_COMPLETENESS</param>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/programStageCompleteness.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/programStageCompleteness.js	2013-05-21 10:08:44 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/programStageCompleteness.js	2013-07-23 04:16:21 +0000
@@ -2,6 +2,8 @@
 
 function orgunitSelected( orgUnits, orgUnitNames )
 {
+	showById('selectDiv');
+	hideById('showDataBtn');
 	hideById("listPatientDiv");
 	setFieldValue('orgunitName', orgUnitNames[0]);
 	setFieldValue('orgunitId', orgUnits[0]);
@@ -11,12 +13,15 @@
 
 function generateStageCompleteness()
 {
+	hideById('selectDiv');
+	showById('showDataBtn');
 	showLoader();
 	jQuery('#completenessDiv').load('generateProgramStageCompleteness.action',
 		{
 			programId: getFieldValue('programId'),
 			startDate: getFieldValue('startDate'),
-			endDate: getFieldValue('endDate')
+			endDate: getFieldValue('endDate'),
+			facilityLB: $('input[name=facilityLB]:checked').val()
 		}, 
 		function()
 		{

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programStageCompletenessSelect.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programStageCompletenessSelect.vm	2013-06-04 06:13:22 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programStageCompletenessSelect.vm	2013-07-23 04:16:21 +0000
@@ -16,7 +16,7 @@
 <h3 id='mainLinkLbl'>$i18n.getString( "program_stage_completeness_form" ) #openHelp('program_stage_completeness')</h3>
 <form id='activityPlanForm' name='activityPlanForm'>
 	<input type='hidden' id='export' value='export'>
-	<div id='selectDiv' class='advanced-search' style='width:550px;'>
+	<div id='selectDiv' style='width:550px;'>
 		<table style="margin-bottom:8px;width:550px;">    
 			<tr>
 				<td>
@@ -54,16 +54,31 @@
 				</td>
 			</tr>
 			<tr>
-				<td></td>
+				<td>$i18n.getString('use_orgunits_from_level')</td>
 				<td>
-					<input type="submit" class='large-button' id='listPatientBtn' value="$i18n.getString( 'generate' )" onclick="setFieldValue('export', false);">
-					<input type="submit" class='large-button' value="$i18n.getString( 'export_xls' )" onclick="setFieldValue('export', true);">
+					<input type="radio" id='facilityLB1' name="facilityLB" value="selected" checked> $i18n.getString('selected')
+					<input type="radio" id='facilityLB2' name="facilityLB" value="childrenOnly"> $i18n.getString('children_only')
+					<input type="radio" id='facilityLB3' name="facilityLB" value="all"> $i18n.getString('all')
 				</td>
 			</tr>
 		</table>
+	
+		<table id="selectionTable">
+			<tr>
+			  <td>
+				#organisationUnitSelectionTree( true, true, false )
+			  </td>
+			</tr>
+		</table>
+		<p>
+			<input type="submit" class='large-button' id='listPatientBtn' value="$i18n.getString( 'generate' )" onclick="setFieldValue('export', false);">
+			<input type="submit" class='large-button' value="$i18n.getString( 'export_xls' )" onclick="setFieldValue('export', true);">
+		</p>
+	
 	</div>
 </form>
 
+<input type='button' id='showDataBtn' class='hidden' value='$i18n.getString("show_data")' onclick="hideById('completenessDiv');hideById('showDataBtn');showById('selectDiv');">
 <div id='completenessDiv' name='completenessDiv'></div>
 
 #parse( "dhis-web-commons/loader/loader.vm" )