← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3815: Fix bug: Don't load categoryOptionName for muti-dimentional dataelemt fields into default entry f...

 

------------------------------------------------------------
revno: 3815
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2011-06-01 12:14:19 +0700
message:
  Fix bug: Don't load categoryOptionName for muti-dimentional dataelemt fields into default entry form ( Patient module ).
modified:
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadDataEntryAction.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/dataEntryForm.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataRecordingSelect.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/dataEntry.js


--
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-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadDataEntryAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadDataEntryAction.java	2011-05-27 01:09:01 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseentry/LoadDataEntryAction.java	2011-06-01 05:14:19 +0000
@@ -32,6 +32,8 @@
 import java.util.HashMap;
 import java.util.Map;
 
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
 import org.hisp.dhis.dataentryform.DataEntryForm;
 import org.hisp.dhis.i18n.I18n;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
@@ -45,6 +47,7 @@
 import org.hisp.dhis.program.ProgramInstanceService;
 import org.hisp.dhis.program.ProgramStage;
 import org.hisp.dhis.program.ProgramStageDataElement;
+import org.hisp.dhis.program.ProgramStageDataElementService;
 import org.hisp.dhis.program.ProgramStageInstance;
 import org.hisp.dhis.program.ProgramStageInstanceService;
 import org.hisp.dhis.program.ProgramStageService;
@@ -77,6 +80,8 @@
 
     private OrganisationUnitSelectionManager selectionManager;
 
+    private ProgramStageDataElementService programStageDataElementService;
+
     // -------------------------------------------------------------------------
     // Input && Output
     // -------------------------------------------------------------------------
@@ -85,6 +90,8 @@
 
     private Integer patientId;
 
+    private boolean useDefaultForm;
+
     private ProgramStageInstance programStageInstance;
 
     private String customDataEntryFormCode;
@@ -95,6 +102,8 @@
 
     private Map<Integer, PatientDataValue> patientDataValueMap;
 
+    private Map<Integer, Collection<DataElementCategoryOptionCombo>> optionMap = new HashMap<Integer, Collection<DataElementCategoryOptionCombo>>();
+
     private OrganisationUnit organisationUnit;
 
     // -------------------------------------------------------------------------
@@ -106,6 +115,11 @@
         this.programStageInstanceService = programStageInstanceService;
     }
 
+    public void setProgramStageDataElementService( ProgramStageDataElementService programStageDataElementService )
+    {
+        this.programStageDataElementService = programStageDataElementService;
+    }
+
     public void setPatientService( PatientService patientService )
     {
         this.patientService = patientService;
@@ -135,7 +149,17 @@
     {
         this.selectionManager = selectionManager;
     }
-    
+
+    public Map<Integer, Collection<DataElementCategoryOptionCombo>> getOptionMap()
+    {
+        return optionMap;
+    }
+
+    public boolean isUseDefaultForm()
+    {
+        return useDefaultForm;
+    }
+
     public OrganisationUnit getOrganisationUnit()
     {
         return organisationUnit;
@@ -151,6 +175,11 @@
         this.patientId = patientId;
     }
 
+    public void setUseDefaultForm( boolean useDefaultForm )
+    {
+        this.useDefaultForm = useDefaultForm;
+    }
+
     public void setI18n( I18n i18n )
     {
         this.i18n = i18n;
@@ -203,6 +232,17 @@
         if ( programStageInstance != null )
         {
             // ---------------------------------------------------------------------
+            // Get CategoryOptions
+            // ---------------------------------------------------------------------
+
+            Collection<DataElement> dataElements = programStageDataElementService.getListDataElement( programStage );
+
+            for ( DataElement dataElement : dataElements )
+            {
+                optionMap.put( dataElement.getId(), dataElement.getCategoryCombo().getOptionCombos() );
+            }
+
+            // ---------------------------------------------------------------------
             // Get data values
             // ---------------------------------------------------------------------
 
@@ -220,15 +260,17 @@
             // Get data-entry-form
             // ---------------------------------------------------------------------
 
-            DataEntryForm dataEntryForm = programStage.getDataEntryForm();
-
-            if ( dataEntryForm != null )
+            if ( !useDefaultForm )
             {
-                customDataEntryFormCode = programDataEntryService.prepareDataEntryFormForEntry( dataEntryForm
-                    .getHtmlCode(), patientDataValues, "", i18n, programStage, programStageInstance, organisationUnit );
+                DataEntryForm dataEntryForm = programStage.getDataEntryForm();
+
+                if ( dataEntryForm != null )
+                {
+                    customDataEntryFormCode = programDataEntryService.prepareDataEntryFormForEntry( dataEntryForm
+                        .getHtmlCode(), patientDataValues, "", i18n, programStage, programStageInstance,
+                        organisationUnit );
+                }
             }
-
-            return SUCCESS;
         }
 
         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	2011-05-27 01:09:01 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml	2011-06-01 05:14:19 +0000
@@ -169,6 +169,8 @@
 		<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
 		<property name="selectionManager"
 			ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
+		<property name="programStageDataElementService"
+			ref="org.hisp.dhis.program.ProgramStageDataElementService" />
 	</bean>
 
 	<bean

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm	2011-05-27 01:09:01 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm	2011-06-01 05:14:19 +0000
@@ -26,34 +26,40 @@
 <span id="startMsg" style="font-style:italic; color:blue; display: #if($programStageInstance.executionDate) none #else block #end">$i18n.getString( "report_date_warning" )</span>
 
 <div id='entryForm' style="display: #if($programStageInstance.executionDate) block #else none #end">
-	
-	<div id="customEntryScreenContainer">
-		#if( $customDataEntryFormCode ) 
-			<div id="dragDiv">
-				<table id="listInfo">
-					<tr><td style="text-align:left"><strong>$i18n.getString("org_unit_name") :</strong></td> <td id="orgUnitNameField" style="text-align:right"></td></tr>
-					<tr><td style="text-align:left"><strong>$i18n.getString("program_stage_name") :</strong></td> <td  id="programStageName" style="text-align:right">$programStageInstance.programStage.name</td></tr>
-					<tr><td style="text-align:left"><strong>$i18n.getString("datae_element_name") :</strong></td> <td id="dataelementName" style="text-align:right"></td></tr>
-				</table>
-			</div>
-		   $customDataEntryFormCode
-		#else 
-			<span style="font-style:italic; color:blue"> $i18n.getString( "no_custom_data_entry_exist" )</span>
-		#end
-	</div>
-
-	<div id="defaultEntryScreenContainer" style='display:none;'>
-		<table class="mainPageTable">
-			<col id="noCol">
-			<col id="deCol">    
-			<col id="entryCol">
-			<col id="facilityCol">       
-			<tr>
-				<th>$i18n.getString( "nr" )</th>
-				<th>$i18n.getString( "data_element" )</th>                   
-				<th>$i18n.getString( "entry" )</th>
-				<th>$i18n.getString( "facility_provided_data" )</th>             
-			</tr>
+	#if( !$useDefaultForm)
+		<div id="customEntryScreenContainer">
+			#if( $customDataEntryFormCode ) 
+				<div id="dragDiv">
+					<table id="listInfo">
+						<tr><td style="text-align:left"><strong>$i18n.getString("org_unit_name") :</strong></td> <td id="orgUnitNameField" style="text-align:right"></td></tr>
+						<tr><td style="text-align:left"><strong>$i18n.getString("program_stage_name") :</strong></td> <td  id="programStageName" style="text-align:right">$programStageInstance.programStage.name</td></tr>
+						<tr><td style="text-align:left"><strong>$i18n.getString("datae_element_name") :</strong></td> <td id="dataelementName" style="text-align:right"></td></tr>
+					</table>
+				</div>
+			   $customDataEntryFormCode
+			#else 
+				<span style="font-style:italic; color:blue"> $i18n.getString( "no_custom_data_entry_exist" )</span>
+			#end
+
+			<script type="text/javascript"> 
+				initCustomCheckboxes();
+				DRAG_DIV.init();
+			</script>
+		</div>
+	#else
+		<div id="defaultEntryScreenContainer" >
+
+			<table class="mainPageTable">
+				<col id="noCol">
+				<col id="deCol">    
+				<col id="entryCol">
+				<col id="facilityCol">       
+				<tr>
+					<th>$i18n.getString( "nr" )</th>
+					<th>$i18n.getString( "data_element" )</th>                   
+					<th>$i18n.getString( "entry" )</th>
+					<th>$i18n.getString( "facility_provided_data" )</th>             
+				</tr>
 			#set( $dataElementRowCount = 0 )
 			#set( $mark = 0 )
 			#set( $tabIndex = 1 )
@@ -79,7 +85,7 @@
 						</span>
 					</td>        
 					##type        
-					<td style="display:none"><span id="value[$programStageDataElement.dataElement.id].type" style="display:none">$encoder.htmlEncode( $programStageDataElement.dataElement.getDetailedNumberType() )</span></td>       
+					<td style="display:none"><span id="value[$programStageDataElement.dataElement.id].type" style="display:none">$encoder.htmlEncode( $programStageDataElement.dataElement.type )</span></td>       
 					##entry        
 					<td>        
 						#if( $programStageDataElement.dataElement.type == "bool" )
@@ -96,24 +102,24 @@
 									<option value="$optionValue.id" #if( $patientDataValue.value == $optionValue.id ) selected="selected" #end>$encoder.htmlEncode( $optionValue.name )</option>
 								#end
 							</select>
-						#elseif( $programStageDataElement.dataElement.type == "date" ) 
-							<input type="text" data="{compulsory: $programStageDataElement.compulsory }" #if($programStageInstance.completed) disabled="disabled" #end id="value[$programStageDataElement.dataElement.id].date" name="entryfield" value="$!encoder.htmlEncode($patientDataValue.value)" onchange="saveDateValue( $programStageDataElement.dataElement.id, '$encoder.jsEncode( $programStageDataElement.dataElement.name )' )" tabindex="$tabIndex" >
-								<script type="text/javascript">
-									datePicker('value\\[$programStageDataElement.dataElement.id\\]\\.date', false);
-								</script>  					
+						#elseif( $programStageDataElement.dataElement.type == "date" )
+							<input type="text" data="{compulsory: $programStageDataElement.compulsory }" #if($programStageInstance.completed) disabled="disabled" #end id="value[$programStageDataElement.dataElement.id].date" name="entryfield" value="$!encoder.htmlEncode( $patientDataValue.value )" onchange="saveDateValue( $programStageDataElement.dataElement.id, '$encoder.jsEncode( $programStageDataElement.dataElement.name )' )" tabindex="$tabIndex" >
+							<script type="text/javascript">
+								datePicker('value\\[$programStageDataElement.dataElement.id\\]\\.date', false);
+							</script>                     
 						#else
 							<input name="entryfield" data="{compulsory: $programStageDataElement.compulsory }" #if($programStageInstance.completed) disabled="disabled" #end id="value[$programStageDataElement.dataElement.id].value" type="text" value="$!encoder.htmlEncode( $patientDataValue.value )" onchange="saveValue( $programStageDataElement.dataElement.id, '$encoder.jsEncode( $programStageDataElement.dataElement.name )' )" onkeypress="return keyPress(event, this)" tabindex="$tabIndex" >
 						#end
 					</td>   
 					##providedByAnotherFacility                
-					<td>     
+					<td>   
 						#if ( $patientDataValue.value )        
 							#if( !$patientDataValue.providedByAnotherFacility )
 								$patientDataValue.organisationUnit.name
-								<input name="providedByAnotherFacility" id="value[$programStageDataElement.dataElement.id].providedByAnotherFacility" type="hidden" onclick="updateProvidingFacility( $programStageDataElement.dataElement.id, this )">
+								<input  name="providedByAnotherFacility" id="value[$programStageDataElement.dataElement.id].providedByAnotherFacility" type="hidden" onclick="updateProvidingFacility( $programStageDataElement.dataElement.id, this )">
 							#else
 								$i18n.getString("other_facility")
-								<input name="providedByAnotherFacility" id="value[$programStageDataElement.dataElement.id].providedByAnotherFacility" type="hidden" onclick="updateProvidingFacility( $programStageDataElement.dataElement.id, this )">
+								<input  name="providedByAnotherFacility" id="value[$programStageDataElement.dataElement.id].providedByAnotherFacility" type="hidden" onclick="updateProvidingFacility( $programStageDataElement.dataElement.id, this )">
 							#end
 						 #else
 							<input name="providedByAnotherFacility" id="value[$programStageDataElement.dataElement.id].providedByAnotherFacility" type="checkbox" onclick="updateProvidingFacility( $programStageDataElement.dataElement.id, this )">
@@ -122,13 +128,9 @@
 				</tr>
 				#set( $tabIndex = $tabIndex + 1 )
 			#end
-		</table>
-
-	</div>
-</div>
-
-</div>
-<script type="text/javascript"> 
-	initCustomCheckboxes();
-	DRAG_DIV.init();
-</script>
\ No newline at end of file
+			</table>
+		</div>
+	#end
+</div>
+
+</div>
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataRecordingSelect.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataRecordingSelect.vm	2011-05-25 08:44:29 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataRecordingSelect.vm	2011-06-01 05:14:19 +0000
@@ -45,7 +45,7 @@
 			<input type="button" id="validationBtn" value="$i18n.getString('validation')" onClick="javascript: runValidation();", '_blank', 'width=800, height=400, scrollbars=yes, resizable=yes' );" style="width:12em " disabled="disabled" >
 		</td>
 		<td align='right'>
-			<input type="checkbox" id="useDefaultForm" name="useDefaultForm" value="true" onclick="selectUseDefaultDataEntryForm();" disabled="disabled" />
+			<input type="checkbox" id="useDefaultForm" name="useDefaultForm" value="true" onclick="loadDataEntry();" disabled="disabled" />
 			<label>$i18n.getString( "use_default_form" )</label><br>	
 		</td>
 		</td>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/dataEntry.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/dataEntry.js	2011-05-27 01:09:01 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/dataEntry.js	2011-06-01 05:14:19 +0000
@@ -136,11 +136,12 @@
 	
 	// Load data-entry form
 	showLoader();
-	
+	var useDefaultForm = jQuery("#useDefaultForm").attr('checked') ? true : false;
 	jQuery('#dataEntryFormDiv').load("dataentryform.action",
 		{
 			programStageId:getFieldValue('programStageId'),
-			patientId: getFieldValue('patientId')
+			patientId: getFieldValue('patientId'),
+			useDefaultForm : useDefaultForm
 		}, 
 		function( )
 		{
@@ -155,23 +156,6 @@
 		});
 }
 
-//--------------------------------------------------------------------------------------------
-// Checkbox useDefaultForm is checked
-//--------------------------------------------------------------------------------------------
-
-function selectUseDefaultDataEntryForm()
-{
-	if( byId('useDefaultForm').checked )
-	{
-		hideById( 'customEntryScreenContainer' );
-		showById( 'defaultEntryScreenContainer' );
-	}else
-	{
-		hideById( 'defaultEntryScreenContainer' );
-		showById( 'customEntryScreenContainer' );
-	}
-}
-
 //-----------------------------------------------------------------------------
 // Search Patient
 //-----------------------------------------------------------------------------
@@ -1485,7 +1469,6 @@
 	var currentFocus; 
     if( jQuery("#entryFormContainer") ) {
 		
-		selectUseDefaultDataEntryForm();
         if( jQuery("#executionDate").val() )
         {
             jQuery("#startMsg").hide();
@@ -1494,24 +1477,6 @@
             toggleContentForReportDate(false);
         }
 		
-        jQuery("#customEntryScreenContainer td").hover(
-            function(){
-                var childrens = jQuery(this).children("input[name='entryfield'],select[name='entryselect']");
-                
-				if( jQuery(childrens[0]).is(":disabled")) 
-				{
-                    DRAG_DIV.showData(jQuery(childrens[0]).metadata({
-                        "type":"attr",
-                        "name":"data"
-                    }));
-                }
-				
-				
-            },
-            function(){
-            }
-            );
-		
         jQuery("input[name='entryfield'],select[name='entryselect']").each(function(){
             jQuery(this).focus(function(){
                 currentFocus = this;