← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6228: (patient) Auto load data-elements when selecting a single-event program.

 

------------------------------------------------------------
revno: 6228
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2012-03-09 11:46:32 +0700
message:
  (patient) Auto load data-elements when selecting a single-event program.
modified:
  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/caseaggregation/CaseAggregationResultAction.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/TabularReportSelectAction.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/caseAggregationForm.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/tabularReport.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/responsePrograms.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchTabularReportResult.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/style/report.css
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/tabularReportResult.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/tabularReportSelect.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-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-03-07 05:54:02 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/program/hibernate/HibernateProgramStageInstanceStore.java	2012-03-09 04:46:32 +0000
@@ -261,7 +261,7 @@
 
         String condition = " WHERE psi.duedate >= '" + DateUtils.getMediumDateString( startDate )
             + "' AND psi.duedate <= '" + DateUtils.getMediumDateString( endDate ) + "' "
-            + " AND psi.organisationunitid in( " + orgunitIds + ") ";
+            + " AND psi.organisationunitid in " + splitListHelper ( orgunitIds ) + " ";
 
         Iterator<Integer> keys = searchingKeys.keySet().iterator();
         boolean index = false;
@@ -335,5 +335,34 @@
             holder.close();
         }
     }
+    
+    /**
+     * Splits a list of integers by comma. Use this method if you have a list
+     * that will be used in f.ins. a WHERE xxx IN (list) clause in SQL.
+     * 
+     * @param Collection <Integer> list of Integers
+     * @return the list as a string splitted by a comma.
+     */
+    private String splitListHelper( Collection<Integer> list )
+    {
+        StringBuffer sb = new StringBuffer();
+        int count = 0;
+
+        sb.append( "(" );
+        for ( Integer i : list )
+        {
+            sb.append( i );
+
+            count++;
+
+            if ( count < list.size() )
+            {
+                sb.append( "," );
+            }
+        }
+        sb.append( ")" );
+
+        return sb.toString();
+    }
 
 }

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/CaseAggregationResultAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/CaseAggregationResultAction.java	2012-02-27 05:35:23 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/CaseAggregationResultAction.java	2012-03-09 04:46:32 +0000
@@ -188,11 +188,11 @@
             return SUCCESS;
         }
 
-        if ( facilityLB.equals( "random" ) )
+        if ( facilityLB.equals( "selected" ) )
         {
             orgunits.add( selectedOrgunit );
         }
-        else if ( facilityLB.equals( "immChildren" ) )
+        else if ( facilityLB.equals( "childrenOnly" ) )
         {
             orgunits.addAll( getChildOrgUnitTree( selectedOrgunit ) );
         }

=== 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-03-07 05:54:02 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/GenerateTabularReportAction.java	2012-03-09 04:46:32 +0000
@@ -203,7 +203,7 @@
 
         Set<Integer> orgunitIds = new HashSet<Integer>();
 
-        if ( facilityLB.equals( "random" ) )
+        if ( facilityLB.equals( "selected" ) )
         {
             orgunitIds.add( selectedOrgunit.getId() );
         }
@@ -215,7 +215,7 @@
 
             orgunitIds.addAll( childOrgUnitIdentifiers );
 
-            if ( facilityLB.equals( "immChildren" ) )
+            if ( facilityLB.equals( "childrenOnly" ) )
             {
                 orgunitIds.remove( selectedOrgunit.getId() );
             }

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/TabularReportSelectAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/TabularReportSelectAction.java	2012-03-05 04:22:57 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/report/TabularReportSelectAction.java	2012-03-09 04:46:32 +0000
@@ -29,8 +29,6 @@
 
 import java.util.Collection;
 
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
 import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramService;
 
@@ -47,14 +45,7 @@
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
-
-    private OrganisationUnitSelectionManager selectionManager;
-
-    public void setSelectionManager( OrganisationUnitSelectionManager selectionManager )
-    {
-        this.selectionManager = selectionManager;
-    }
-
+    
     private ProgramService programService;
 
     public void setProgramService( ProgramService programService )
@@ -66,13 +57,6 @@
     // Dependencies
     // -------------------------------------------------------------------------
 
-    private OrganisationUnit orgunit;
-
-    public OrganisationUnit getOrgunit()
-    {
-        return orgunit;
-    }
-
     private Collection<Program> programs;
 
     public Collection<Program> getPrograms()
@@ -86,9 +70,7 @@
 
     public String execute()
     {
-        orgunit = selectionManager.getSelectedOrganisationUnit();
-
-        programs = programService.getPrograms( orgunit );
+         programs = programService.getAllPrograms();
 
         return SUCCESS;
     }

=== 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	2012-03-08 04:56:36 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml	2012-03-09 04:46:32 +0000
@@ -256,8 +256,6 @@
 	<bean id="org.hisp.dhis.caseentry.action.report.TabularReportSelectAction"
 		class="org.hisp.dhis.caseentry.action.report.TabularReportSelectAction"
 		scope="prototype">
-		<property name="selectionManager"
-			ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
 		<property name="programService"
 			ref="org.hisp.dhis.program.ProgramService" />
 	</bean>

=== 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-03-09 01:56:35 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2012-03-09 04:46:32 +0000
@@ -76,8 +76,7 @@
 value_must_negative_integer=Value must be an negative integer
 days=days
 please_select=Please select
-immediate_children=Immediate Children
-all_children=All children
+children_only=Children Only
 aggregate=Aggregate
 added=Added
 updated=Updated
@@ -271,4 +270,5 @@
 program_enrollment = Program enrollment
 date_of_enrollment=Date of enrollment
 date_of_incident=Date of incident
-patient_details_and_history = Beneficiary details and history
\ No newline at end of file
+patient_details_and_history = Beneficiary details and history
+selected = Selected

=== 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	2012-03-08 04:56:36 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml	2012-03-09 04:46:32 +0000
@@ -265,7 +265,7 @@
 			<param name="stylesheets">../dhis-web-caseentry/style/report.css</param>
 		</action>
 		
-		<action name="loadProgramsByOrgunit"
+		<action name="loadAllPrograms"
 			class="org.hisp.dhis.caseentry.action.report.TabularReportSelectAction">
 			<interceptor-ref name="organisationUnitTreeStack" />
 			<result name="success" type="velocity-json">/dhis-web-caseentry/responsePrograms.vm</result>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationForm.vm	2012-03-08 06:39:51 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/caseAggregationForm.vm	2012-03-09 04:46:32 +0000
@@ -45,17 +45,17 @@
 					<input type="button" value=">>"  onclick="getNextPeriodForEnd()" id="nextPeriodForEndBtn" disabled />
 					<i><span id='warningMessage' style="color:red"></span></i>
 				</td>
-					
 			</tr>
+			
 			<tr>
 				<td>
 				   $i18n.getString( "facility_by" )
 				</td>
 				<td>
 					<select id="facilityLB" name="facilityLB" style="width: 30em">
-						<option value="random" selected>$i18n.getString( "selected" )</option>
-						<option value="immChildren" >$i18n.getString( "immediate_children" )</option>
-						<option value="children" >$i18n.getString( "all_children" )</option>
+						<option value="selected" selected="selected">$i18n.getString( "selected" )</option>
+						<option value="childrenOnly" >$i18n.getString( "children_only" )</option>
+						<option value="all">$i18n.getString( "all" )</option>
 					</select>
 				</td>
 			</tr>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/tabularReport.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/tabularReport.js	2012-03-07 05:54:02 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/tabularReport.js	2012-03-09 04:46:32 +0000
@@ -5,7 +5,7 @@
 	clearListById( 'programStageId' );
 	clearListById( 'availableDataElementIds' );
 	
-	$.getJSON( 'loadProgramsByOrgunit.action',{}
+	$.getJSON( 'loadAllPrograms.action',{}
 		, function( json ) 
 		{
 			clearListById( 'programId' );
@@ -14,7 +14,9 @@
 			var preSelectedProgramId = getFieldValue('selectedProgramId');
 			for ( i in json.programs ) 
 			{ 
-				$('#programId').append('<option value=' + json.programs[i].id + '>' + json.programs[i].name + '</option>');
+				$('#programId').append( '<option value=' + json.programs[i].id 
+					+ ' singleevent=' + json.programs[i].singleEvent + '>' 
+					+ json.programs[i].name + '</option>' );
 			}
 
 			if( json.programs.length > 0 )
@@ -50,12 +52,21 @@
 		}
 		, function( json ) 
 		{
-			addOptionById( 'programStageId', '', i18n_please_select );
+			var singleEvent = jQuery('#programId option:selected').attr('singleevent');
+			if(singleEvent=='false')
+			{
+				addOptionById( 'programStageId', '', i18n_please_select );
+			}
 			
 			for ( i in json.programStages ) 
 			{ 
 				$('#programStageId').append('<option value=' + json.programStages[i].id + '>' + json.programStages[i].name + '</option>');
 			}
+			
+			if(singleEvent=='true')
+			{
+				loadDataElements();
+			}
 		} );
 }
 

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/responsePrograms.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/responsePrograms.vm	2011-12-28 06:21:57 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/responsePrograms.vm	2012-03-09 04:46:32 +0000
@@ -4,7 +4,8 @@
 	#foreach( $program in $programs )
 	  {
 		"id":  ${program.id} ,
-		"name": "$!encoder.jsonEncode( ${program.name} )"
+		"name": "$!encoder.jsonEncode( ${program.name} )",
+		"singleEvent": "$program.singleEvent"
 	  }#if( $velocityCount < $size ),#end
 	#end]
 }
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchTabularReportResult.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchTabularReportResult.vm	2012-03-05 06:07:54 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/searchTabularReportResult.vm	2012-03-09 04:46:32 +0000
@@ -2,7 +2,7 @@
 	#set( $mark = false )
 	#set( $i = 1 )
 	#foreach( $row in $grid.getVisibleRows() )
-		<tr id="tr${i}">
+		<tr id="tr${i}" class='rowGrid'>
 			<td>
 				#set( $nr = ( ( $paging.getCurrentPage() - 1  ) * $paging.pageSize ) + $velocityCount )
 				$nr

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/style/report.css'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/style/report.css	2012-03-07 05:54:02 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/style/report.css	2012-03-09 04:46:32 +0000
@@ -27,9 +27,9 @@
   width:75%;
 }
   
-.grid tr {
-  background-color:#eee;
-  }
+.filter { background: #cccccc; } 
+  
+.rowGrid{ background-color:#eee; }
   
 .grid th, .grid td
 {
@@ -39,8 +39,6 @@
   border:1px solid #fff;
 }
 
-.small-button {
-	font-size: .8em !important;
-}
+.small-button { font-size: .8em !important; }
 
 .ui-autocomplete { height: 100px; overflow-y: scroll; overflow-x: hidden;}
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/tabularReportResult.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/tabularReportResult.vm	2012-03-05 06:07:54 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/tabularReportResult.vm	2012-03-09 04:46:32 +0000
@@ -15,15 +15,16 @@
 
 <table class="listTable grid" id='gridTable'>
 	<tr>
-		<th>#</th>
+		<th></th>
 		#foreach( $dataElement in $dataElements )
 			<th>
 				$!encoder.htmlEncode( $dataElement.name )
 			</th>
 		#end
 	</tr>
-	<tr>
-		<td></td>
+	
+	<tr class='filter'>
+		<td>$i18n.getString('filter')</td>
 		#foreach( $dataElement in $dataElements )
 			<td>
 				<input type='text' id='$dataElement.id' title='$i18n.getString("how_to_search_tabular_report")' onkeypress='searchTabularReport( event );' #if($dataElement.optionSet) options='$dataElement.optionSet.options' #end />

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/tabularReportSelect.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/tabularReportSelect.vm	2012-03-08 08:56:27 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/tabularReportSelect.vm	2012-03-09 04:46:32 +0000
@@ -17,20 +17,21 @@
 	  <td><label>$i18n.getString( "reporting_unit" )</label></td>
 	  <td colspan='2'><input type="text" readonly="readonly" id='orgunitname' name='orgunitname' #if($!orgunit) value="$!orgunit.name" #else value="[$i18n.getString( 'select' )]" #end ></td>
     </tr>
-    
+	
     <tr>
-        <td><label for="programId">$i18n.getString( "program" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
-        <td colspan='2'>
-            <select id="programId" name="programId" #if($!programs) #else disabled #end class="{validate:{required:true}}" onchange='loadProgramStages();'>
-				<option value=''>[$i18n.getString('please_select')]</option>
-				#foreach( $program in $programs )
-				<option value='$program.id'>$program.name</option>
-				#end
+		<td>
+		   $i18n.getString( "facility_by" )
+		</td>
+		<td>
+			<select id="facilityLB" name="facilityLB" style="width: 30em">
+				<option value="selected" selected="selected">$i18n.getString( "selected" )</option>
+				<option value="childrenOnly" >$i18n.getString( "children_only" )</option>
+				<option value="all">$i18n.getString( "all" )</option>
 			</select>
-        </td>
-    </tr>
-        
-    <tr>
+		</td>
+	</tr>
+	
+	<tr>
         <td><label>$i18n.getString( "start_date" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
         <td colspan='2'>
             <input type="text" id="startDate" name="startDate" class="{validate:{required:true}}" />
@@ -49,6 +50,20 @@
             </script> 				
         </td>      
     </tr>
+	
+    <tr>
+        <td><label for="programId">$i18n.getString( "program" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
+        <td colspan='2'>
+            <select id="programId" name="programId" #if($!programs) #else disabled #end class="{validate:{required:true}}" onchange='loadProgramStages();'>
+				<option value=''>[$i18n.getString('please_select')]</option>
+				#foreach( $program in $programs )
+				<option value='$program.id' singleevent='$program.singleEvent'>$program.name</option>
+				#end
+			</select>
+        </td>
+    </tr>
+        
+    
 	<tr>
         <td><label>$i18n.getString( "program_stage" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
         <td colspan='2'>
@@ -81,18 +96,7 @@
             <a href="javascript:moveDownSelectedOption('dataElementIds')"><img src="../images/move_down.png"/></a><br/><br/>
         </td>  			
     </tr>
-    <tr>
-		<td>
-		   $i18n.getString( "facility_by" )
-		</td>
-		<td>
-			<select id="facilityLB" name="facilityLB" style="width: 30em">
-				<option value="children" selected="selected">$i18n.getString( "all_children" )</option>
-				<option value="immChildren" >$i18n.getString( "immediate_children" )</option>
-				<option value="random">$i18n.getString( "selected" )</option>
-			</select>
-		</td>
-	</tr>
+   
 	    
 	<tr>
     	<td></td>