← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4816: Add Register-event button into Enroll program form to enter data from registration form directly.

 

------------------------------------------------------------
revno: 4816
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-10-04 13:28:34 +0700
message:
  Add Register-event button into Enroll program form to enter data from registration form directly.
removed:
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/dataEntry.js
added:
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/form.js
modified:
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ProgramEnrollmentAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ProgramEnrollmentSelectAction.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/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/patient.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientRegistrationList.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentForm.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentSelectForm.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/selectPatient.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-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ProgramEnrollmentAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ProgramEnrollmentAction.java	2011-09-14 06:36:13 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ProgramEnrollmentAction.java	2011-10-04 06:28:34 +0000
@@ -29,6 +29,8 @@
 import java.util.ArrayList;
 import java.util.Collection;
 
+import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager;
 import org.hisp.dhis.patient.Patient;
 import org.hisp.dhis.patient.PatientService;
 import org.hisp.dhis.program.Program;
@@ -56,6 +58,8 @@
 
     private ProgramInstanceService programInstanceService;
 
+    private OrganisationUnitSelectionManager selectionManager;
+
     // -------------------------------------------------------------------------
     // Input/Output
     // -------------------------------------------------------------------------
@@ -67,9 +71,11 @@
     private Patient patient;
 
     private Program program;
-    
+
     private ProgramInstance programInstance;
 
+    private Boolean registerEvent;
+
     private Collection<ProgramStageInstance> programStageInstances = new ArrayList<ProgramStageInstance>();
 
     // -------------------------------------------------------------------------
@@ -91,6 +97,11 @@
         this.programInstanceService = programInstanceService;
     }
 
+    public void setSelectionManager( OrganisationUnitSelectionManager selectionManager )
+    {
+        this.selectionManager = selectionManager;
+    }
+
     public void setPatientId( Integer patientId )
     {
         this.patientId = patientId;
@@ -121,6 +132,11 @@
         return programStageInstances;
     }
 
+    public Boolean getRegisterEvent()
+    {
+        return registerEvent;
+    }
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -146,6 +162,10 @@
             programStageInstances = programInstance.getProgramStageInstances();
         }
 
+        OrganisationUnit selectedOrgunit = selectionManager.getSelectedOrganisationUnit();
+      
+        registerEvent = program.getOrganisationUnits().contains( selectedOrgunit );
+
         return SUCCESS;
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ProgramEnrollmentSelectAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ProgramEnrollmentSelectAction.java	2011-09-14 06:36:13 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/patient/ProgramEnrollmentSelectAction.java	2011-10-04 06:28:34 +0000
@@ -95,7 +95,7 @@
     {
         patient = patientService.getPatient( id );
 
-        programs = programService.getPrograms( false );
+        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	2011-09-28 04:02:30 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml	2011-10-04 06:28:34 +0000
@@ -561,6 +561,7 @@
 		<property name="programService" ref="org.hisp.dhis.program.ProgramService" />
 		<property name="programInstanceService" ref="org.hisp.dhis.program.ProgramInstanceService" />
 		<property name="patientService" ref="org.hisp.dhis.patient.PatientService" />
+		<property name="selectionManager" ref="org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager" />
 	</bean>
 
 	<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	2011-10-04 03:10:03 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2011-10-04 06:28:34 +0000
@@ -1,4 +1,4 @@
-back_to_search 													= Back to Search
+back_to_search 													= Go back to search
 program_stages_history_plan 									= Program Stages History/Plan
 completed_on 													= Completed On  
 scheduled_for 													= Scheduled For  
@@ -351,7 +351,8 @@
 update_enrollment 												= Update Enrollment
 empty_search_result 											= Empty Search Result
 please_search_here 												= Please Search Here
-program_enrollment 												= Program Enrollment Management
+program_enrollment_management									= Program enrollment management
+patient_registered 												= Beneficiary registered
 patient_details 												= Beneficiary Details
 enrolled_in_program 											= Enrolled in Programs
 update_patient 													= Edit profile of beneficiary
@@ -430,4 +431,5 @@
 format_date														= Format Date
 specify_search_criteria											= Please specify search criteria
 patient_profile													= Beneficiary profile
-other_details													= Other details
\ No newline at end of file
+other_details													= Other details
+register_event													= Register event
\ 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	2011-09-30 09:10:14 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml	2011-10-04 06:28:34 +0000
@@ -26,8 +26,9 @@
 			<param name="menu">/dhis-web-caseentry/dataEntryMenu.vm</param>
 			<param name="javascripts">../dhis-web-commons/ouwt/ouwt.js
 				,javascript/commons.js
-				,javascript/dataEntry.js,
-				../dhis-web-commons/javascripts/date.js
+				,javascript/form.js
+				,javascript/entry.js
+				,../dhis-web-commons/javascripts/date.js
 			</param>
 		</action>
 
@@ -127,7 +128,7 @@
 			<param name="page">/dhis-web-caseentry/multiDataEntrySelect.vm</param>
 			<param name="menu">/dhis-web-caseentry/dataEntryMenu.vm</param>
 			<param name="javascripts">../dhis-web-commons/ouwt/ouwt.js,javascript/commons.js,
-				javascript/dataEntry.js</param>
+				javascript/form.js</param>
 		</action>
 
 		<action name="getPrograms"
@@ -149,14 +150,14 @@
 			class="org.hisp.dhis.caseentry.action.caseentry.ProgramStageCustomDataEntryAction">
 			<result name="success" type="velocity">/content.vm</result>
 			<param name="page">/dhis-web-caseentry/programStageDataEntryForm.vm</param>
-			<param name="javascripts">javascript/dataEntry.js,../dhis-web-commons/javascripts/date.js</param>
+			<param name="javascripts">javascript/form.js,../dhis-web-commons/javascripts/date.js</param>
 		</action>
 
 		<action name="loadProgramStageRecords"
 			class="org.hisp.dhis.caseentry.action.caseentry.ProgramStageCustomDataEntryAction">
 			<result name="success" type="velocity">/content.vm</result>
 			<param name="page">/dhis-web-caseentry/dataEntryForm.vm</param>
-			<param name="javascripts">javascript/dataEntry.js,../dhis-web-commons/javascripts/date.js</param>
+			<param name="javascripts">javascript/form.js,../dhis-web-commons/javascripts/date.js</param>
 		</action>
 
 		<action name="completeProgramStageDataEntry"
@@ -304,9 +305,18 @@
 				../dhis-web-commons/ouwt/ouwt.js
 				,javascript/commons.js
 				,javascript/patient.js
+				,javascript/entry.js
 				,javascript/relationshipPatient.js
 			</param>
 		</action>
+		
+		<action name="selectDataRecordingFromRegistration"
+			class="org.hisp.dhis.caseentry.action.caseentry.DataRecordingSelectAction">
+			<result name="success" type="velocity">/content.vm</result>
+			<param name="page">/dhis-web-caseentry/dataRecordingSelect.vm</param>
+			<param name="javascripts">javascript/entry.js</param>
+			<param name="stylesheets">style/patient.css</param>
+		</action>
 
 		<action name="organisationUnitHasPatients"
 			class="org.hisp.dhis.caseentry.action.patient.VerifyOrganisationUnitHasParentAction">

=== 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-10-04 03:15:04 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataEntryForm.vm	2011-10-04 06:28:34 +0000
@@ -136,4 +136,4 @@
 
 </div>
 
-<div id='validateProgramDiv'></div>
\ No newline at end of file
+<div id='validateProgramDiv'></div>

=== 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-10-03 02:20:58 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/dataRecordingSelect.vm	2011-10-04 06:28:34 +0000
@@ -1,5 +1,5 @@
 <div>
-    <input type="button" value="$i18n.getString( 'back_to_search' )" onclick="javascript:showSearchForm();" style="width:10em">
+    <input type="button" value="$i18n.getString( 'back_to_search' )" id='backBtnFromEntry' onclick="javascript:showSearchForm();" style="width:10em">
 </div>
    
 <table class="mainPageTable"> 

=== removed 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-10-03 02:20:58 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/dataEntry.js	1970-01-01 00:00:00 +0000
@@ -1,1068 +0,0 @@
-
-function organisationUnitSelected( orgUnits, orgUnitNames )
-{
-	setInnerHTML( 'contentDiv', '' );
-	setFieldValue( 'orgunitName', orgUnitNames[0] );
-	
-	hideById('dataEntryFormDiv');
-	hideById('dataRecordingSelectDiv');
-	showById('searchPatientDiv');
-	
-	enable('searchingAttributeId');
-	jQuery('#searchText').removeAttr('readonly');
-	enable('searchBtn');	
-	enable('listPatientBtn');
-}
-
-selection.setListenerFunction( organisationUnitSelected );
-
-//--------------------------------------------------------------------------------------------
-// Show search-form
-//--------------------------------------------------------------------------------------------
-
-function showSearchForm()
-{
-	hideById('dataRecordingSelectDiv');
-	hideById('dataEntryFormDiv');
-	showById('searchPatientDiv');
-	showById('contentDiv');
-}
-
-//--------------------------------------------------------------------------------------------
-// Show all patients in select orgunit
-//--------------------------------------------------------------------------------------------
-
-isAjax = true;
-function listAllPatient()
-{
-	showLoader();
-	jQuery('#contentDiv').load( 'listAllPatients.action',{},
-		function()
-		{
-			hideById('dataRecordingSelectDiv');
-			hideById('dataEntryFormDiv');
-			showById('searchPatientDiv');
-			hideLoader();
-		});
-}
-
-//--------------------------------------------------------------------------------------------
-// Show selected data-recording
-//--------------------------------------------------------------------------------------------
-
-function showSelectedDataRecoding( patientId )
-{
-	showLoader();
-	hideById('searchPatientDiv');
-	hideById('dataEntryFormDiv');
-	jQuery('#dataRecordingSelectDiv').load( 'selectDataRecording.action', 
-		{
-			patientId: patientId
-		},
-		function()
-		{
-			showById('dataRecordingSelectDiv');
-			hideLoader();
-			hideById('contentDiv');
-		});
-}
-
-//--------------------------------------------------------------------------------------------
-// Load program-stages by the selected program
-//--------------------------------------------------------------------------------------------
-
-function loadProgramStages()
-{
-	hideById('dataEntryFormDiv');
-	clearListById('programStageId');
-		
-	if ( getFieldValue('programId') == 0 )
-	{
-		return;
-	}
-	jQuery.postJSON( "loadProgramStages.action",
-		{
-			programId: getFieldValue('programId')
-		}, 
-		function( json ) 
-		{    
-			addOptionById( 'programStageId', "0", i18n_select );
-			for ( i in json.programStages ) 
-			{
-				addOptionById( 'programStageId', json.programStages[i].id, json.programStages[i].name );
-			} 
-			
-			// show history / plan
-			setInnerHTML( 'currentSelection', '' ); 
-			var history = '<h4>' + i18n_program_stages_history_plan + '</h4>';
-			history += '<table>';
-			for ( i in json.programStageInstances ) 
-			{
-				history += '<tr>';
-                history += '<td>';
-                history += '<span class="bold">' + json.programStageInstances[i].name + '</span>';
-				history += '</td>';
-                history += '<td style="text-align:center" bgcolor=' + json.programStageInstances[i].colorMap + '>';
-                history += json.programStageInstances[i].infor;
-                history += '</td>';
-                history += '</tr>';
-			}
-			history += '</table>';
-			setInnerHTML( 'currentSelection', history );
-			
-			var singleEvent = jQuery('#programId option:selected').attr('singleevent');
-			if(singleEvent=='true')
-			{
-				byId('programStageId').selectedIndex = 1;
-				disable('programStageId');
-				loadDataEntry();
-			}
-			else
-			{
-				enable('programStageId');
-			}
-	});
-}
-
-//--------------------------------------------------------------------------------------------
-// Load data-entry-form
-//--------------------------------------------------------------------------------------------
-
-function loadDataEntry()
-{
-	setInnerHTML('dataEntryFormDiv', '');
-	showById('dataEntryFormDiv');
-	setFieldValue( 'dueDate', '' );
-	setFieldValue( 'executionDate', '' );
-	
-	if( getFieldValue('programStageId') == null
-		|| getFieldValue('programStageId') == 0 )
-	{
-		disable('validationBtn');
-		disable('completeBtn');
-		return;
-	}
-	
-	showLoader();
-	
-	$( '#dataEntryFormDiv' ).load( "dataentryform.action", 
-		{ 
-			programStageId:getFieldValue('programStageId')
-		},function( )
-		{
-			enable('validationBtn');
-			enable('completeBtn');
-			
-			hideLoader();
-			hideById('contentDiv'); 
-		} );
-}
-
-//-----------------------------------------------------------------------------
-// Search Patient
-//-----------------------------------------------------------------------------
-
-function searchPatientsOnKeyUp( event )
-{
-	var key = getKeyCode( event );
-	
-	if ( key==13 )// Enter
-	{
-		validateSearch();
-	}
-}
-
-function getKeyCode(e)
-{
-	 if (window.event)
-		return window.event.keyCode;
-	 return (e)? e.which : null;
-}
- 
-function validateSearch( event )
-{	
-	var request = new Request();
-	request.setResponseTypeXML( 'message' );
-	request.setCallbackSuccess( searchValidationCompleted );
-	request.sendAsPost('searchText=' + getFieldValue( 'searchText' ));
-	request.send( 'validateSearch.action' );
-}
-
-function searchValidationCompleted( messageElement )
-{
-    var type = messageElement.getAttribute( 'type' );
-    var message = messageElement.firstChild.nodeValue;
-	
-    if ( type == 'success' )
-    {
-		showLoader();
-		hideById('dataEntryFormDiv');
-		hideById('dataRecordingSelectDiv');
-		$('#contentDiv').load( 'searchPatient.action', 
-			{
-				searchingAttributeId: getFieldValue('searchingAttributeId'), 
-				searchText: getFieldValue('searchText')
-			},
-			function()
-			{
-				showById('searchPatientDiv');
-				hideLoader();
-			});
-    }
-    else if ( type == 'error' )
-    {
-        showErrorMessage( i18n_searching_patient_failed + ':' + '\n' + message );
-    }
-    else if ( type == 'input' )
-    {
-        showWarningMessage( message );
-    }
-}
-
-//------------------------------------------------------------------------------
-//Save value
-//------------------------------------------------------------------------------
-
-function saveVal( dataElementId, optionComboId )
-{
-	var programStageId = byId('programStageId').value;
-	var fieldId = programStageId + '-' + dataElementId + '-' + optionComboId + '-val';
-	var data = jQuery( "#" + fieldId ).metadata({
-        type:'attr',
-        name:'data'
-    });
-	var field = byId( fieldId ); 
-	var dataElementName = data.deName; 
-    var type = data.deType;
-    var providedByAnotherFacility = document.getElementById( programStageId + '_' + dataElementId + '_facility' ).checked;
- 
-	field.style.backgroundColor = '#ffffcc';
-    
-    if( field.value != '' )
-    {
-        if ( type == 'int' || type == 'number' || type == 'positiveNumber' || type == 'negativeNumber' )
-        {
-            if (  type == 'int' && !isInt( field.value ))
-            {
-                field.style.backgroundColor = '#ffcc00';
-
-                window.alert( i18n_value_must_integer + '\n\n' + dataElementName );
-
-                field.select();
-                field.focus();
-
-                return;
-            }
-			else if ( type == 'number' && !isRealNumber( field.value ) )
-            {
-                field.style.backgroundColor = '#ffcc00';
-                window.alert( i18n_value_must_number + '\n\n' + dataElementName );
-                field.select();
-                field.focus();
-
-                return;
-            } 
-			else if ( type == 'positiveNumber' && !isPositiveInt( field.value ) )
-            {
-                field.style.backgroundColor = '#ffcc00';
-                window.alert( i18n_value_must_positive_integer + '\n\n' + dataElementName );
-                field.select();
-                field.focus();
-
-                return;
-            } 
-			else if ( type == 'negativeNumber' && !isNegativeInt( field.value ) )
-            {
-                field.style.backgroundColor = '#ffcc00';
-                window.alert( i18n_value_must_negative_integer + '\n\n' + dataElementName );
-                field.select();
-                field.focus();
-
-                return;
-            }
-        }
-    	
-    }
-    
-	var valueSaver = new ValueSaver( dataElementId, optionComboId,  field.value, providedByAnotherFacility, type, '#ccffcc'  );
-    valueSaver.save();
-}
-
-function saveDate( dataElementId )
-{	
-	var programStageId = byId('programStageId').value;
-	var fieldId = programStageId + '-' + dataElementId + '-val';
-	var field = jQuery( "#" + fieldId ); 
-	var fieldValue = field.val();
-	var data = field.metadata({
-        type:'attr',
-        name:'data'
-    });
-	
-    var providedByAnotherFacility = document.getElementById( programStageId + '_' + dataElementId + '_facility' ).checked;
- 
-	if( fieldValue !="")
-    { 
-		var d2 = new Date( fieldValue );
-        if( d2 == 'Invalid Date' )
-        {
-            field.css({
-                "background-color":"#ffcc00"
-            });
-            window.alert('Incorrect format for date value. The correct format should be ' + dateFormat.replace('yy', 'yyyy') +' \n\n ' + data.deName );
-		  
-            field.focus();
-
-            return;
-        }
-    }
-	
-	var dueDate = new Date( jQuery('#dueDate').val() );
-	var inputtedDate = new Date( fieldValue );
-	if( inputtedDate < dueDate )
-	{
-		field.css({
-                "background-color":"#ffcc00"
-            });
-            window.alert( i18n_date_is_greater_then_or_equals_due_date );
-		  
-            field.focus();
-
-            return;
-	}
-	
-    var dateSaver = new DateSaver( dataElementId, fieldValue, providedByAnotherFacility, '#ccffcc' );
-    dateSaver.save();
-}
-
-function saveOpt( dataElementId )
-{
-	var programStageId = byId('programStageId').value;
-	var field = byId( programStageId + '-' + dataElementId + '-val' );
-	
-	field.style.backgroundColor = '#ffffcc';
-	var providedByAnotherFacility = document.getElementById( programStageId + '_' + dataElementId + '_facility' ).checked;
- 
-	var valueSaver = new ValueSaver( dataElementId, 0, field.options[field.selectedIndex].value, providedByAnotherFacility, 'bool', '#ccffcc' );
-    valueSaver.save();
-}
-
-function updateProvidingFacility( dataElementId, checkedBox )
-{
-	var programStageId = byId( 'programStageId' ).value;
-    checkedBox.style.backgroundColor = '#ffffcc';
-    var providedByAnotherFacility = document.getElementById( programStageId + '_' + dataElementId + '_facility' ).checked;
- 
-    var facilitySaver = new FacilitySaver( dataElementId, providedByAnotherFacility, '#ccffcc' );
-    facilitySaver.save();
-    
-}
-
-function saveExecutionDate( programStageId, executionDateValue )
-{
-    var field = document.getElementById( 'executionDate' );
-	
-    field.style.backgroundColor = '#ffffcc';
-	
-    var executionDateSaver = new ExecutionDateSaver( programStageId, executionDateValue, '#ccffcc' );
-    executionDateSaver.save();
-	
-    if( !jQuery("#entryForm").is(":visible") )
-    {
-        toggleContentForReportDate(true);
-    }
-}
-
-/**
-* Display data element name in selection display when a value field recieves
-* focus.
-* XXX May want to move this to a separate function, called by valueFocus.
-* @param e focus event
-* @author Hans S. Tommerholt
-*/
-function valueFocus(e) 
-{
-    //Retrieve the data element id from the id of the field
-    var str = e.target.id;
-	
-    var match = /.*\[(.*)\]/.exec( str ); //value[-dataElementId-]
-	
-    if ( ! match )
-    {
-        return;
-    }
-
-    var deId = match[1];
-	
-    //Get the data element name
-    var nameContainer = document.getElementById('value[' + deId + '].name');
-	
-    if ( ! nameContainer )
-    {
-        return;
-    }
-
-    var name = '';
-	
-    var as = nameContainer.getElementsByTagName('a');
-
-    if ( as.length > 0 )	//Admin rights: Name is in a link
-    {
-        name = as[0].firstChild.nodeValue;
-    }
-    else
-    {
-        name = nameContainer.firstChild.nodeValue;
-    }
-	
-}
-
-function keyPress( event, field )
-{
-    var key = 0;
-    if ( event.charCode )
-    {
-        key = event.charCode; /* Safari2 (Mac) (and probably Konqueror on Linux, untested) */
-    }
-    else
-    {
-        if ( event.keyCode )
-        {
-            key = event.keyCode; /* Firefox1.5 (Mac/Win), Opera9 (Mac/Win), IE6, IE7Beta2, Netscape7.2 (Mac) */
-        }
-        else
-        {
-            if ( event.which )
-            {
-                key = event.which; /* Older Netscape? (No browsers triggered yet) */
-            }
-        }
-    }
-   
-    if ( key == 13 ) /* CR */
-    { 
-        nextField = getNextEntryField( field );
-        if ( nextField )
-        {
-            nextField.focus(); /* Does not seem to actually work in Safari, unless you also have an Alert in between */
-        }
-        return true;
-    }
-    
-    /* Illegal characters can be removed with a new if-block and return false */
-    return true;
-}
-
-function getNextEntryField( field )
-{
-    var inputs = document.getElementsByName( "entryfield" );
-    
-    // Simple bubble sort
-    for ( var i = 0; i < inputs.length - 1; ++i )
-    {
-        for ( var j = i + 1; j < inputs.length; ++j )
-        {
-            if ( inputs[i].tabIndex > inputs[j].tabIndex )
-            {
-                tmp = inputs[i];
-                inputs[i] = inputs[j];
-                inputs[j] = tmp;
-            }
-        }
-    }
-    
-    i = 0;
-    for ( ; i < inputs.length; ++i )
-    {
-        if ( inputs[i] == field )
-        {
-            break;
-        }
-    }
-    
-    if ( i == inputs.length - 1 )
-    {
-        // No more fields after this:
-        return false;
-    }
-    else
-    {
-        return inputs[i + 1];
-    }
-}
-
-//-----------------------------------------------------------------
-// Save value for dataElement of type text, number, boolean, combo
-//-----------------------------------------------------------------
-
-function ValueSaver( dataElementId_, selectedOption_, value_, providedByAnotherFacility_, dataElementType_, resultColor_  )
-{
-    var SUCCESS = '#ccffcc';
-    var ERROR = '#ccccff';
-	
-    var dataElementId = dataElementId_;
-    var selectedOption = selectedOption_;
-	var value = value_;
-    var providedByAnotherFacility = providedByAnotherFacility_;
-	var type = dataElementType_;
-    var resultColor = resultColor_;
-	
-    this.save = function()
-    {
-		var params = 'dataElementId=' + dataElementId;
-			params += '&optionComboId=' + selectedOption;
-			params += '&value=' + value;
-			params += '&providedByAnotherFacility=' + providedByAnotherFacility;
-			
-        var request = new Request();
-        request.setCallbackSuccess( handleResponse );
-        request.setCallbackError( handleHttpError );
-        request.setResponseTypeXML( 'status' );
-		request.sendAsPost( params );
-        request.send( 'saveValue.action');
-    };
- 
-    function handleResponse( rootElement )
-    {
-        var codeElement = rootElement.getElementsByTagName( 'code' )[0];
-        var code = parseInt( codeElement.firstChild.nodeValue );
-        if ( code == 0 )
-        {
-            markValue( resultColor );
-        }
-        else
-        {
-            if(value!="")
-            {
-                markValue( ERROR );
-                window.alert( i18n_saving_value_failed_status_code + '\n\n' + code );
-            }
-            else
-            {
-                markValue( resultColor );
-            }
-        }
-    }
- 
-    function handleHttpError( errorCode )
-    {
-        markValue( ERROR );
-        window.alert( i18n_saving_value_failed_error_code + '\n\n' + errorCode );
-    }
- 
-    function markValue( color )
-    {
-		var programStageId = getFieldValue('programStageId');
-        var element;
-     
-        if( selectedOption )
-        {
-            element = byId( programStageId + "-" + dataElementId + "-" + selectedOption +'-val' );
-        }
-        else
-        {
-            element = byId( programStageId + "-" + dataElementId + '-val' );
-        }
-             
-        element.style.backgroundColor = color;
-    }
-}
-
-function DateSaver( dataElementId_, value_, providedByAnotherFacility_, resultColor_ )
-{
-    var SUCCESS = '#ccffcc';
-    var ERROR = '#ffcc00';
-	
-    var dataElementId = dataElementId_;
-    var value = value_;
-    var providedByAnotherFacility = providedByAnotherFacility_;
-    var resultColor = resultColor_;
-
-    this.save = function()
-    {
-		var params = 'dataElementId=' + dataElementId;
-		params +=  '&value=' + value;
-		params +=  '&providedByAnotherFacility=' + providedByAnotherFacility;
-
-        var request = new Request();
-        request.setCallbackSuccess( handleResponse );
-        request.setCallbackError( handleHttpError );
-        request.setResponseTypeXML( 'status' );
-		request.sendAsPost( params );
-        request.send( 'saveDateValue.action' );
-    };
-
-    function handleResponse( rootElement )
-    {
-        var codeElement = rootElement.getElementsByTagName( 'code' )[0];
-        var code = parseInt( codeElement.firstChild.nodeValue );
-        if ( code == 0 )
-        {
-            markValue( resultColor );
-        }
-        else if(code == 1)
-        {
-            if(value != "")
-            {
-                var dataelementList = rootElement.getElementsByTagName( 'validation' );
-                var message = '';
-
-                for ( var i = 0; i < dataelementList.length; i++ )
-                {
-                    message += "\n - " + dataelementList[i].firstChild.nodeValue;
-                }
-
-                markValue( ERROR );
-                window.alert( i18n_violate_validation + message);
-            }
-            else
-            {
-                markValue( resultColor );
-            }
-        }
-		else if(code == 2)
-        {
-			markValue( ERROR );
-            window.alert( i18n_invalid_date + ":\n" + rootElement.getElementsByTagName( 'message' )[0].firstChild.nodeValue );
-		}
-        else
-        {
-            if(value != "")
-            {
-                markValue( ERROR );
-                window.alert( i18n_invalid_date );
-            }
-            else
-            {
-                markValue( resultColor );
-            }
-        }
-    }
-
-    function handleHttpError( errorCode )
-    {
-        markValue( ERROR );
-        window.alert( i18n_saving_value_failed_error_code + '\n\n' + errorCode );
-    }
-
-    function markValue( color )
-    {
-		var programStageId = byId('programStageId').value;
-        var element = byId(  programStageId + "-" + dataElementId + '-val' );
-        
-        element.style.backgroundColor = color;
-    }
-}
-
-function FacilitySaver( dataElementId_, providedByAnotherFacility_, resultColor_ )
-{
-    var SUCCESS = 'success';
-    var ERROR = '#error';
-	
-    var dataElementId = dataElementId_;
-    var providedByAnotherFacility = providedByAnotherFacility_;
-    var resultColor = resultColor_;
-
-    this.save = function()
-    {
-        var request = new Request();
-        request.setCallbackSuccess( handleResponseCheckBox );
-        request.setCallbackError( handleHttpErrorCheckBox );
-        request.setResponseTypeXML( 'status' ); 
-        request.send( 'saveProvidingFacility.action?dataElementId=' + dataElementId 
-					+'&providedByAnotherFacility=' + providedByAnotherFacility );
-    };
-
-    function handleResponseCheckBox( rootElement )
-    {
-        var codeElement = rootElement.getElementsByTagName( 'code' )[0];
-        var code = parseInt( codeElement.firstChild.nodeValue );
-        if ( code == 0 )
-        {
-            markValue( SUCCESS );
-        }
-        else
-        {
-            markValue( ERROR );
-            window.alert( i18n_saving_value_failed_status_code + '\n\n' + code );
-        }
-    }
-
-    function handleHttpErrorCheckBox( errorCode )
-    {
-        markValue( ERROR );
-        window.alert( i18n_saving_value_failed_error_code + '\n\n' + errorCode );
-    }
-
-    function markValue( result )
-    {
-		var programStageId = byId( 'programStageId' ).value;
-        if( result == SUCCESS )
-        {
-            jQuery('label[for="'+programStageId+'_'+dataElementId+'_facility"]').toggleClass('checked');
-        }
-        else if( result == ERROR )
-        {
-            jQuery('label[for="'+programStageId+'_'+dataElementId+'_facility"]').removeClass('checked');
-            jQuery('label[for="'+programStageId+'_'+dataElementId+'_facility"]').addClass('error');
-        }
-    }
-}
-
-function ExecutionDateSaver( programStageId_, executionDate_, resultColor_ )
-{
-    var SUCCESS = '#ccffcc';
-    var ERROR = '#ffcc00';
-	
-    var programStageId = programStageId_;
-    var executionDate = executionDate_;
-    var resultColor = resultColor_;
-
-    this.save = function()
-    {
-        var request = new Request();
-        request.setCallbackSuccess( handleResponse );
-        request.setCallbackError( handleHttpError );
-        request.setResponseTypeXML( 'status' );
-		
-		var params  = "executionDate=" + executionDate;
-			params += "&programStageId=" + programStageId;
-		request.sendAsPost(params);
-		
-        request.send( "saveExecutionDate.action");
-    };
-
-    function handleResponse( rootElement )
-    {
-        var codeElement = rootElement.getAttribute( 'type' );
-        if ( codeElement == 'success' )
-        {
-            markValue( resultColor );
-			setFieldValue('programStageInstanceId',rootElement.firstChild.nodeValue);
-			showById('entryFormContainer');
-			showById('dataEntryFormDiv');
-			showById('entryForm');
-        }
-        else
-        {
-            if( executionDate != "")
-            {
-                markValue( ERROR );
-                window.alert( i18n_invalid_date );
-            }
-            else
-            {
-                markValue( resultColor );
-            }
-			hideById('dataEntryFormDiv');
-        }
-    }
-
-    function handleHttpError( errorCode )
-    {
-        markValue( ERROR );
-        window.alert( i18n_saving_value_failed_error_code + '\n\n' + errorCode );
-    }
-
-    function markValue( color )
-    {
-        var element = document.getElementById( 'executionDate' );
-           
-        element.style.backgroundColor = color;
-    }
-}
-
-//-----------------------------------------------------------------
-//
-//-----------------------------------------------------------------
-
-
-function initCustomCheckboxes()
-{
-    jQuery('input[type=checkbox][name="providedByAnotherFacility"]').prettyCheckboxes();
-}
-
-DRAG_DIV = {
-    init : function()
-    {
-        var dragDiv = jQuery("#dragDiv");
-        dragDiv.show();
-        var left = screen.width - 500 ;
-        var top = Math.round(jQuery("#entryFormContainer").position().top )  ;
-        dragDiv.css({
-            'left': left+'px',
-            'top': top+'px'
-        });
-        dragDiv.draggable();
-    },
-		
-    showData : function(data)
-    {
-        jQuery("#dataelementName").text(data.deName);
-    },
-		
-    resetData : function()
-    {
-        jQuery("#orgUnitNameField").text("");
-        jQuery("#programStageName").text("");
-        jQuery("#dataelementName").text("");
-    }
-};
-function toggleContentForReportDate(show)
-{
-    if( show ){
-        jQuery("#startMsg").hide();
-        jQuery("#entryForm").show();
-        jQuery("#completeBtn").removeAttr('disabled');
-		jQuery("#validationBtn").removeAttr('disabled');
-    }else {
-        jQuery("#entryForm").hide();
-        jQuery("#completeBtn").attr('disabled', 'disabled');
-		jQuery("#validationBtn").attr('disabled', 'disabled');
-        jQuery("#startMsg").show();
-    }
-}
-
-function openChildRegistrationForm()
-{
-    var patientId = document.getElementById( "id" ).value;
-	
-    window.location.href = "../dhis-web-caseentry/showAddRelationshipPatient.action?id="+patientId;
-}
-
-function doComplete()
-{
-    var flag = false;
-    jQuery("#dataEntryFormDiv input[name='entryfield'],select[name='entryselect']").each(function(){
-        jQuery(this).parent().removeClass("errorCell");
-        if( jQuery(this).metadata({
-            "type":"attr",
-            "name":"data"
-        }).compulsory ){
-            if( !jQuery(this).val() || jQuery(this).val() == "undifined" ){
-                flag = true;
-                jQuery(this).parent().addClass("errorCell");
-            }
-        }
-    });
-    if( flag ){
-        alert(i18n_error_required_field);
-        return;
-    }else {
-        if( confirm(i18n_complete_confirm_message) )
-		{
-			$.postJSON( "completeDataEntry.action",
-				{
-					programStageInstanceId: getFieldValue('programStageInstanceId')
-				},
-				function (data)
-				{
-					jQuery("#dataEntryFormDiv :input").each(function()
-					{
-						jQuery(this).attr('disabled', 'disabled');
-					});
-					jQuery("#dataEntryFormDiv").find(".ui-datepicker-trigger").each(function()
-					{
-						jQuery(this).attr('style', 'display:none');
-					});
-					jQuery("#dataEntryFormDiv").find(".holder").each(function()
-					{
-						jQuery(this).attr('style', 'display:none');
-					});
-					
-					hideLoader();
-					hideById('contentDiv');
-				},'xml');
-		}
-    }
-}
-
-TOGGLE = {
-    init : function() {
-        jQuery(".togglePanel").each(function(){
-            jQuery(this).next("table:first").addClass("sectionClose");
-            jQuery(this).addClass("close");
-            jQuery(this).click(function(){
-                var table = jQuery(this).next("table:first");
-                if( table.hasClass("sectionClose")){
-                    table.removeClass("sectionClose").addClass("sectionOpen");
-                    jQuery(this).removeClass("close").addClass("open");
-                    window.scroll(0,jQuery(this).position().top);
-                }else if( table.hasClass("sectionOpen")){
-                    table.removeClass("sectionOpen").addClass("sectionClose");
-                    jQuery(this).removeClass("open").addClass("close");
-                }
-            });
-        });
-    }
-};
-
-//------------------------------------------------------
-// Run validation
-//------------------------------------------------------
-
-function runValidation()
-{
-	$('#validateProgramDiv' ).load( 'validateProgram.action' ).dialog({
-			title: i18n_violate_validation,
-			maximize: true, 
-			closable: true,
-			modal:true,
-			overlay:{background:'#000000', opacity:0.1},
-			width: 800,
-			height: 450
-		});
-}
-
-//------------------------------------------------------
-// Multi Data-entry
-//------------------------------------------------------
-
-function multiDataEntryOrgunitSelected( orgUnits )
-{
-	hideById("listPatient");
-	jQuery.postJSON( "getPrograms.action",
-	{
-	}, 
-	function( json ) 
-	{    
-		enable('programId');
-		enable('patientAttributeId');
-		
-		clearListById('programId');
-		if(json.programs.length == 0)
-		{
-			disable('programId');
-			disable('patientAttributeId');
-		}
-		else
-		{
-			addOptionById( 'programId', "0", i18n_select );
-			
-			for ( var i in json.programs ) 
-			{
-				addOptionById( 'programId', json.programs[i].id, json.programs[i].name );
-			} 
-		}	
-		setFieldValue( 'orgunitName', json.organisationUnit );
-	});
-}
-
-function selectProgram()
-{
-	setInnerHTML('listPatient', '');
-	if( getFieldValue('programId') == 0 )
-	{
-		hideById('listPatient');
-		return;
-	}
-	
-	contentDiv = 'listPatient';
-	showLoader();
-	jQuery('#listPatient').load("getDataRecords.action",
-		{
-			programId:getFieldValue('programId'),
-			sortPatientAttributeId: getFieldValue('patientAttributeId')
-		}, 
-		function()
-		{
-			showById("listPatient");
-			hideLoader();
-		});
-}
-
-function viewPrgramStageRecords( programStageInstanceId ) 
-{
-	$('#contentDataRecord').dialog('destroy').remove();
-    $('<div id="contentDataRecord">' ).load("viewProgramStageRecords.action",
-		{
-			programStageInstanceId: programStageInstanceId
-			
-		}).dialog(
-		{
-			title: 'ProgramStage',
-			maximize: true, 
-			closable: true,
-			modal:true,
-			overlay:{background:'#000000', opacity:0.1},
-			width: 800,
-			height: 400
-		});
-}
-
-function loadProgramStageRecords( programStageInstanceId ) 
-{
-	setInnerHTML('dataEntryFormDiv', '');
-	showLoader();
-    $('#dataEntryFormDiv' ).load("loadProgramStageRecords.action",
-		{
-			programStageInstanceId: programStageInstanceId
-		}, function() {
-			hideLoader();
-		});
-}
-
-function entryFormContainerOnReady()
-{
-	var currentFocus = undefined;
-
-    if( jQuery("#entryFormContainer") ) {
-		
-        if( jQuery("#executionDate").val() )
-        {
-            jQuery("#startMsg").hide();
-        }else
-        {
-            toggleContentForReportDate(false);
-        }
-		
-        jQuery("input[name='entryfield'],select[name='entryselect']").each(function(){
-            jQuery(this).focus(function(){
-                currentFocus = this;
-                DRAG_DIV.showData(jQuery(this).metadata({
-                    "type":"attr",
-                    "name":"data"
-                }));
-            });
-            jQuery(this).blur(function(){
-               
-                });
-            jQuery(this).hover(
-                function(){
-                    DRAG_DIV.showData(jQuery(this).metadata({
-                        "type":"attr",
-                        "name":"data"
-                    }));
-                },
-                function()
-                {
-                    if(currentFocus) {
-                        DRAG_DIV.showData(jQuery(currentFocus).metadata({
-                            "type":"attr",
-                            "name":"data"
-                        }));
-                    }
-                }
-                );
-            jQuery(this).addClass("inputText");
-        });
-		
-        TOGGLE.init();
-    }
-}
-
-// -------------------------------------------------------------------------
-// Show Patient chart list
-// -------------------------------------------------------------------------
-
-function patientChartList( patientId )
-{
-    $( '#patientChartListDiv' ).load('patientChartList.action?patientId=' + patientId ).dialog( {
-        autoOpen : true,
-        modal : true,
-        height : 400,
-        width : 500,
-        resizable : false,
-        title : 'Viewing Chart'
-    } );
-}

=== added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js	2011-10-04 06:28:34 +0000
@@ -0,0 +1,828 @@
+
+//--------------------------------------------------------------------------------------------
+// Load program-stages by the selected program
+//--------------------------------------------------------------------------------------------
+
+function loadProgramStages()
+{
+	hideById('dataEntryFormDiv');
+	clearListById('programStageId');
+		
+	if ( getFieldValue('programId') == 0 )
+	{
+		return;
+	}
+	jQuery.postJSON( "loadProgramStages.action",
+		{
+			programId: getFieldValue('programId')
+		}, 
+		function( json ) 
+		{    
+			addOptionById( 'programStageId', "0", i18n_select );
+			for ( i in json.programStages ) 
+			{
+				addOptionById( 'programStageId', json.programStages[i].id, json.programStages[i].name );
+			} 
+			
+			// show history / plan
+			setInnerHTML( 'currentSelection', '' ); 
+			var history = '<h4>' + i18n_program_stages_history_plan + '</h4>';
+			history += '<table>';
+			for ( i in json.programStageInstances ) 
+			{
+				history += '<tr>';
+                history += '<td>';
+                history += '<span class="bold">' + json.programStageInstances[i].name + '</span>';
+				history += '</td>';
+                history += '<td style="text-align:center" bgcolor=' + json.programStageInstances[i].colorMap + '>';
+                history += json.programStageInstances[i].infor;
+                history += '</td>';
+                history += '</tr>';
+			}
+			history += '</table>';
+			setInnerHTML( 'currentSelection', history );
+			
+			var singleEvent = jQuery('#programId option:selected').attr('singleevent');
+			if(singleEvent=='true')
+			{
+				byId('programStageId').selectedIndex = 1;
+				disable('programStageId');
+				loadDataEntry();
+			}
+			else
+			{
+				enable('programStageId');
+			}
+	});
+}
+
+//--------------------------------------------------------------------------------------------
+// Load data-entry-form
+//--------------------------------------------------------------------------------------------
+
+function loadDataEntry()
+{
+	setInnerHTML('dataEntryFormDiv', '');
+	showById('dataEntryFormDiv');
+	setFieldValue( 'dueDate', '' );
+	setFieldValue( 'executionDate', '' );
+	
+	if( getFieldValue('programStageId') == null
+		|| getFieldValue('programStageId') == 0 )
+	{
+		disable('validationBtn');
+		disable('completeBtn');
+		return;
+	}
+	
+	showLoader();
+	
+	$( '#dataEntryFormDiv' ).load( "dataentryform.action", 
+		{ 
+			programStageId:getFieldValue('programStageId')
+		},function( )
+		{
+			enable('validationBtn');
+			enable('completeBtn');
+			
+			hideLoader();
+			hideById('contentDiv'); 
+		} );
+}
+
+//------------------------------------------------------------------------------
+//Save value
+//------------------------------------------------------------------------------
+
+function saveVal( dataElementId, optionComboId )
+{
+	var programStageId = byId('programStageId').value;
+	var fieldId = programStageId + '-' + dataElementId + '-' + optionComboId + '-val';
+	var data = jQuery( "#" + fieldId ).metadata({
+        type:'attr',
+        name:'data'
+    });
+	var field = byId( fieldId ); 
+	var dataElementName = data.deName; 
+    var type = data.deType;
+    var providedByAnotherFacility = document.getElementById( programStageId + '_' + dataElementId + '_facility' ).checked;
+ 
+	field.style.backgroundColor = '#ffffcc';
+    
+    if( field.value != '' )
+    {
+        if ( type == 'int' || type == 'number' || type == 'positiveNumber' || type == 'negativeNumber' )
+        {
+            if (  type == 'int' && !isInt( field.value ))
+            {
+                field.style.backgroundColor = '#ffcc00';
+
+                window.alert( i18n_value_must_integer + '\n\n' + dataElementName );
+
+                field.select();
+                field.focus();
+
+                return;
+            }
+			else if ( type == 'number' && !isRealNumber( field.value ) )
+            {
+                field.style.backgroundColor = '#ffcc00';
+                window.alert( i18n_value_must_number + '\n\n' + dataElementName );
+                field.select();
+                field.focus();
+
+                return;
+            } 
+			else if ( type == 'positiveNumber' && !isPositiveInt( field.value ) )
+            {
+                field.style.backgroundColor = '#ffcc00';
+                window.alert( i18n_value_must_positive_integer + '\n\n' + dataElementName );
+                field.select();
+                field.focus();
+
+                return;
+            } 
+			else if ( type == 'negativeNumber' && !isNegativeInt( field.value ) )
+            {
+                field.style.backgroundColor = '#ffcc00';
+                window.alert( i18n_value_must_negative_integer + '\n\n' + dataElementName );
+                field.select();
+                field.focus();
+
+                return;
+            }
+        }
+    	
+    }
+    
+	var valueSaver = new ValueSaver( dataElementId, optionComboId,  field.value, providedByAnotherFacility, type, '#ccffcc'  );
+    valueSaver.save();
+}
+
+function saveDate( dataElementId )
+{	
+	var programStageId = byId('programStageId').value;
+	var fieldId = programStageId + '-' + dataElementId + '-val';
+	var field = jQuery( "#" + fieldId ); 
+	var fieldValue = field.val();
+	var data = field.metadata({
+        type:'attr',
+        name:'data'
+    });
+	
+    var providedByAnotherFacility = document.getElementById( programStageId + '_' + dataElementId + '_facility' ).checked;
+ 
+	if( fieldValue !="")
+    { 
+		var d2 = new Date( fieldValue );
+        if( d2 == 'Invalid Date' )
+        {
+            field.css({
+                "background-color":"#ffcc00"
+            });
+            window.alert('Incorrect format for date value. The correct format should be ' + dateFormat.replace('yy', 'yyyy') +' \n\n ' + data.deName );
+		  
+            field.focus();
+
+            return;
+        }
+    }
+	
+	var dueDate = new Date( jQuery('#dueDate').val() );
+	var inputtedDate = new Date( fieldValue );
+	if( inputtedDate < dueDate )
+	{
+		field.css({
+                "background-color":"#ffcc00"
+            });
+            window.alert( i18n_date_is_greater_then_or_equals_due_date );
+		  
+            field.focus();
+
+            return;
+	}
+	
+    var dateSaver = new DateSaver( dataElementId, fieldValue, providedByAnotherFacility, '#ccffcc' );
+    dateSaver.save();
+}
+
+function saveOpt( dataElementId )
+{
+	var programStageId = byId('programStageId').value;
+	var field = byId( programStageId + '-' + dataElementId + '-val' );
+	
+	field.style.backgroundColor = '#ffffcc';
+	var providedByAnotherFacility = document.getElementById( programStageId + '_' + dataElementId + '_facility' ).checked;
+ 
+	var valueSaver = new ValueSaver( dataElementId, 0, field.options[field.selectedIndex].value, providedByAnotherFacility, 'bool', '#ccffcc' );
+    valueSaver.save();
+}
+
+function updateProvidingFacility( dataElementId, checkedBox )
+{
+	var programStageId = byId( 'programStageId' ).value;
+    checkedBox.style.backgroundColor = '#ffffcc';
+    var providedByAnotherFacility = document.getElementById( programStageId + '_' + dataElementId + '_facility' ).checked;
+ 
+    var facilitySaver = new FacilitySaver( dataElementId, providedByAnotherFacility, '#ccffcc' );
+    facilitySaver.save();
+    
+}
+
+function saveExecutionDate( programStageId, executionDateValue )
+{
+    var field = document.getElementById( 'executionDate' );
+	
+    field.style.backgroundColor = '#ffffcc';
+	
+    var executionDateSaver = new ExecutionDateSaver( programStageId, executionDateValue, '#ccffcc' );
+    executionDateSaver.save();
+	
+    if( !jQuery("#entryForm").is(":visible") )
+    {
+        toggleContentForReportDate(true);
+    }
+}
+
+/**
+* Display data element name in selection display when a value field recieves
+* focus.
+* XXX May want to move this to a separate function, called by valueFocus.
+* @param e focus event
+* @author Hans S. Tommerholt
+*/
+function valueFocus(e) 
+{
+    //Retrieve the data element id from the id of the field
+    var str = e.target.id;
+	
+    var match = /.*\[(.*)\]/.exec( str ); //value[-dataElementId-]
+	
+    if ( ! match )
+    {
+        return;
+    }
+
+    var deId = match[1];
+	
+    //Get the data element name
+    var nameContainer = document.getElementById('value[' + deId + '].name');
+	
+    if ( ! nameContainer )
+    {
+        return;
+    }
+
+    var name = '';
+	
+    var as = nameContainer.getElementsByTagName('a');
+
+    if ( as.length > 0 )	//Admin rights: Name is in a link
+    {
+        name = as[0].firstChild.nodeValue;
+    }
+    else
+    {
+        name = nameContainer.firstChild.nodeValue;
+    }
+	
+}
+
+function keyPress( event, field )
+{
+    var key = 0;
+    if ( event.charCode )
+    {
+        key = event.charCode; /* Safari2 (Mac) (and probably Konqueror on Linux, untested) */
+    }
+    else
+    {
+        if ( event.keyCode )
+        {
+            key = event.keyCode; /* Firefox1.5 (Mac/Win), Opera9 (Mac/Win), IE6, IE7Beta2, Netscape7.2 (Mac) */
+        }
+        else
+        {
+            if ( event.which )
+            {
+                key = event.which; /* Older Netscape? (No browsers triggered yet) */
+            }
+        }
+    }
+   
+    if ( key == 13 ) /* CR */
+    { 
+        nextField = getNextEntryField( field );
+        if ( nextField )
+        {
+            nextField.focus(); /* Does not seem to actually work in Safari, unless you also have an Alert in between */
+        }
+        return true;
+    }
+    
+    /* Illegal characters can be removed with a new if-block and return false */
+    return true;
+}
+
+function getNextEntryField( field )
+{
+    var inputs = document.getElementsByName( "entryfield" );
+    
+    // Simple bubble sort
+    for ( var i = 0; i < inputs.length - 1; ++i )
+    {
+        for ( var j = i + 1; j < inputs.length; ++j )
+        {
+            if ( inputs[i].tabIndex > inputs[j].tabIndex )
+            {
+                tmp = inputs[i];
+                inputs[i] = inputs[j];
+                inputs[j] = tmp;
+            }
+        }
+    }
+    
+    i = 0;
+    for ( ; i < inputs.length; ++i )
+    {
+        if ( inputs[i] == field )
+        {
+            break;
+        }
+    }
+    
+    if ( i == inputs.length - 1 )
+    {
+        // No more fields after this:
+        return false;
+    }
+    else
+    {
+        return inputs[i + 1];
+    }
+}
+
+//-----------------------------------------------------------------
+// Save value for dataElement of type text, number, boolean, combo
+//-----------------------------------------------------------------
+
+function ValueSaver( dataElementId_, selectedOption_, value_, providedByAnotherFacility_, dataElementType_, resultColor_  )
+{
+    var SUCCESS = '#ccffcc';
+    var ERROR = '#ccccff';
+	
+    var dataElementId = dataElementId_;
+    var selectedOption = selectedOption_;
+	var value = value_;
+    var providedByAnotherFacility = providedByAnotherFacility_;
+	var type = dataElementType_;
+    var resultColor = resultColor_;
+	
+    this.save = function()
+    {
+		var params = 'dataElementId=' + dataElementId;
+			params += '&optionComboId=' + selectedOption;
+			params += '&value=' + value;
+			params += '&providedByAnotherFacility=' + providedByAnotherFacility;
+			
+        var request = new Request();
+        request.setCallbackSuccess( handleResponse );
+        request.setCallbackError( handleHttpError );
+        request.setResponseTypeXML( 'status' );
+		request.sendAsPost( params );
+        request.send( 'saveValue.action');
+    };
+ 
+    function handleResponse( rootElement )
+    {
+        var codeElement = rootElement.getElementsByTagName( 'code' )[0];
+        var code = parseInt( codeElement.firstChild.nodeValue );
+        if ( code == 0 )
+        {
+            markValue( resultColor );
+        }
+        else
+        {
+            if(value!="")
+            {
+                markValue( ERROR );
+                window.alert( i18n_saving_value_failed_status_code + '\n\n' + code );
+            }
+            else
+            {
+                markValue( resultColor );
+            }
+        }
+    }
+ 
+    function handleHttpError( errorCode )
+    {
+        markValue( ERROR );
+        window.alert( i18n_saving_value_failed_error_code + '\n\n' + errorCode );
+    }
+ 
+    function markValue( color )
+    {
+		var programStageId = getFieldValue('programStageId');
+        var element;
+     
+        if( selectedOption )
+        {
+            element = byId( programStageId + "-" + dataElementId + "-" + selectedOption +'-val' );
+        }
+        else
+        {
+            element = byId( programStageId + "-" + dataElementId + '-val' );
+        }
+             
+        element.style.backgroundColor = color;
+    }
+}
+
+function DateSaver( dataElementId_, value_, providedByAnotherFacility_, resultColor_ )
+{
+    var SUCCESS = '#ccffcc';
+    var ERROR = '#ffcc00';
+	
+    var dataElementId = dataElementId_;
+    var value = value_;
+    var providedByAnotherFacility = providedByAnotherFacility_;
+    var resultColor = resultColor_;
+
+    this.save = function()
+    {
+		var params = 'dataElementId=' + dataElementId;
+		params +=  '&value=' + value;
+		params +=  '&providedByAnotherFacility=' + providedByAnotherFacility;
+
+        var request = new Request();
+        request.setCallbackSuccess( handleResponse );
+        request.setCallbackError( handleHttpError );
+        request.setResponseTypeXML( 'status' );
+		request.sendAsPost( params );
+        request.send( 'saveDateValue.action' );
+    };
+
+    function handleResponse( rootElement )
+    {
+        var codeElement = rootElement.getElementsByTagName( 'code' )[0];
+        var code = parseInt( codeElement.firstChild.nodeValue );
+        if ( code == 0 )
+        {
+            markValue( resultColor );
+        }
+        else if(code == 1)
+        {
+            if(value != "")
+            {
+                var dataelementList = rootElement.getElementsByTagName( 'validation' );
+                var message = '';
+
+                for ( var i = 0; i < dataelementList.length; i++ )
+                {
+                    message += "\n - " + dataelementList[i].firstChild.nodeValue;
+                }
+
+                markValue( ERROR );
+                window.alert( i18n_violate_validation + message);
+            }
+            else
+            {
+                markValue( resultColor );
+            }
+        }
+		else if(code == 2)
+        {
+			markValue( ERROR );
+            window.alert( i18n_invalid_date + ":\n" + rootElement.getElementsByTagName( 'message' )[0].firstChild.nodeValue );
+		}
+        else
+        {
+            if(value != "")
+            {
+                markValue( ERROR );
+                window.alert( i18n_invalid_date );
+            }
+            else
+            {
+                markValue( resultColor );
+            }
+        }
+    }
+
+    function handleHttpError( errorCode )
+    {
+        markValue( ERROR );
+        window.alert( i18n_saving_value_failed_error_code + '\n\n' + errorCode );
+    }
+
+    function markValue( color )
+    {
+		var programStageId = byId('programStageId').value;
+        var element = byId(  programStageId + "-" + dataElementId + '-val' );
+        
+        element.style.backgroundColor = color;
+    }
+}
+
+function FacilitySaver( dataElementId_, providedByAnotherFacility_, resultColor_ )
+{
+    var SUCCESS = 'success';
+    var ERROR = '#error';
+	
+    var dataElementId = dataElementId_;
+    var providedByAnotherFacility = providedByAnotherFacility_;
+    var resultColor = resultColor_;
+
+    this.save = function()
+    {
+        var request = new Request();
+        request.setCallbackSuccess( handleResponseCheckBox );
+        request.setCallbackError( handleHttpErrorCheckBox );
+        request.setResponseTypeXML( 'status' ); 
+        request.send( 'saveProvidingFacility.action?dataElementId=' + dataElementId 
+					+'&providedByAnotherFacility=' + providedByAnotherFacility );
+    };
+
+    function handleResponseCheckBox( rootElement )
+    {
+        var codeElement = rootElement.getElementsByTagName( 'code' )[0];
+        var code = parseInt( codeElement.firstChild.nodeValue );
+        if ( code == 0 )
+        {
+            markValue( SUCCESS );
+        }
+        else
+        {
+            markValue( ERROR );
+            window.alert( i18n_saving_value_failed_status_code + '\n\n' + code );
+        }
+    }
+
+    function handleHttpErrorCheckBox( errorCode )
+    {
+        markValue( ERROR );
+        window.alert( i18n_saving_value_failed_error_code + '\n\n' + errorCode );
+    }
+
+    function markValue( result )
+    {
+		var programStageId = byId( 'programStageId' ).value;
+        if( result == SUCCESS )
+        {
+            jQuery('label[for="'+programStageId+'_'+dataElementId+'_facility"]').toggleClass('checked');
+        }
+        else if( result == ERROR )
+        {
+            jQuery('label[for="'+programStageId+'_'+dataElementId+'_facility"]').removeClass('checked');
+            jQuery('label[for="'+programStageId+'_'+dataElementId+'_facility"]').addClass('error');
+        }
+    }
+}
+
+function ExecutionDateSaver( programStageId_, executionDate_, resultColor_ )
+{
+    var SUCCESS = '#ccffcc';
+    var ERROR = '#ffcc00';
+	
+    var programStageId = programStageId_;
+    var executionDate = executionDate_;
+    var resultColor = resultColor_;
+
+    this.save = function()
+    {
+        var request = new Request();
+        request.setCallbackSuccess( handleResponse );
+        request.setCallbackError( handleHttpError );
+        request.setResponseTypeXML( 'status' );
+		
+		var params  = "executionDate=" + executionDate;
+			params += "&programStageId=" + programStageId;
+		request.sendAsPost(params);
+		
+        request.send( "saveExecutionDate.action");
+    };
+
+    function handleResponse( rootElement )
+    {
+        var codeElement = rootElement.getAttribute( 'type' );
+        if ( codeElement == 'success' )
+        {
+            markValue( resultColor );
+			setFieldValue('programStageInstanceId',rootElement.firstChild.nodeValue);
+			showById('entryFormContainer');
+			showById('dataEntryFormDiv');
+			showById('entryForm');
+        }
+        else
+        {
+            if( executionDate != "")
+            {
+                markValue( ERROR );
+                window.alert( i18n_invalid_date );
+            }
+            else
+            {
+                markValue( resultColor );
+            }
+			hideById('dataEntryFormDiv');
+        }
+    }
+
+    function handleHttpError( errorCode )
+    {
+        markValue( ERROR );
+        window.alert( i18n_saving_value_failed_error_code + '\n\n' + errorCode );
+    }
+
+    function markValue( color )
+    {
+        var element = document.getElementById( 'executionDate' );
+           
+        element.style.backgroundColor = color;
+    }
+}
+
+//-----------------------------------------------------------------
+//
+//-----------------------------------------------------------------
+
+
+function initCustomCheckboxes()
+{
+    jQuery('input[type=checkbox][name="providedByAnotherFacility"]').prettyCheckboxes();
+}
+
+DRAG_DIV = {
+    init : function()
+    {
+        var dragDiv = jQuery("#dragDiv");
+        dragDiv.show();
+        var left = screen.width - 500 ;
+        var top = Math.round(jQuery("#entryFormContainer").position().top )  ;
+        dragDiv.css({
+            'left': left+'px',
+            'top': top+'px'
+        });
+        dragDiv.draggable();
+    },
+		
+    showData : function(data)
+    {
+        jQuery("#dataelementName").text(data.deName);
+    },
+		
+    resetData : function()
+    {
+        jQuery("#orgUnitNameField").text("");
+        jQuery("#programStageName").text("");
+        jQuery("#dataelementName").text("");
+    }
+};
+function toggleContentForReportDate(show)
+{
+    if( show ){
+        jQuery("#startMsg").hide();
+        jQuery("#entryForm").show();
+        jQuery("#completeBtn").removeAttr('disabled');
+		jQuery("#validationBtn").removeAttr('disabled');
+    }else {
+        jQuery("#entryForm").hide();
+        jQuery("#completeBtn").attr('disabled', 'disabled');
+		jQuery("#validationBtn").attr('disabled', 'disabled');
+        jQuery("#startMsg").show();
+    }
+}
+
+function doComplete()
+{
+    var flag = false;
+    jQuery("#dataEntryFormDiv input[name='entryfield'],select[name='entryselect']").each(function(){
+        jQuery(this).parent().removeClass("errorCell");
+        if( jQuery(this).metadata({
+            "type":"attr",
+            "name":"data"
+        }).compulsory ){
+            if( !jQuery(this).val() || jQuery(this).val() == "undifined" ){
+                flag = true;
+                jQuery(this).parent().addClass("errorCell");
+            }
+        }
+    });
+    if( flag ){
+        alert(i18n_error_required_field);
+        return;
+    }else {
+        if( confirm(i18n_complete_confirm_message) )
+		{
+			$.postJSON( "completeDataEntry.action",
+				{
+					programStageInstanceId: getFieldValue('programStageInstanceId')
+				},
+				function (data)
+				{
+					jQuery("#dataEntryFormDiv :input").each(function()
+					{
+						jQuery(this).attr('disabled', 'disabled');
+					});
+					jQuery("#dataEntryFormDiv").find(".ui-datepicker-trigger").each(function()
+					{
+						jQuery(this).attr('style', 'display:none');
+					});
+					jQuery("#dataEntryFormDiv").find(".holder").each(function()
+					{
+						jQuery(this).attr('style', 'display:none');
+					});
+					
+					hideLoader();
+					hideById('contentDiv');
+				},'xml');
+		}
+    }
+}
+
+TOGGLE = {
+    init : function() {
+        jQuery(".togglePanel").each(function(){
+            jQuery(this).next("table:first").addClass("sectionClose");
+            jQuery(this).addClass("close");
+            jQuery(this).click(function(){
+                var table = jQuery(this).next("table:first");
+                if( table.hasClass("sectionClose")){
+                    table.removeClass("sectionClose").addClass("sectionOpen");
+                    jQuery(this).removeClass("close").addClass("open");
+                    window.scroll(0,jQuery(this).position().top);
+                }else if( table.hasClass("sectionOpen")){
+                    table.removeClass("sectionOpen").addClass("sectionClose");
+                    jQuery(this).removeClass("open").addClass("close");
+                }
+            });
+        });
+    }
+};
+
+function entryFormContainerOnReady()
+{
+	var currentFocus = undefined;
+
+    if( jQuery("#entryFormContainer") ) {
+		
+        if( jQuery("#executionDate").val() )
+        {
+            jQuery("#startMsg").hide();
+        }else
+        {
+            toggleContentForReportDate(false);
+        }
+		
+        jQuery("input[name='entryfield'],select[name='entryselect']").each(function(){
+            jQuery(this).focus(function(){
+                currentFocus = this;
+                DRAG_DIV.showData(jQuery(this).metadata({
+                    "type":"attr",
+                    "name":"data"
+                }));
+            });
+            jQuery(this).blur(function(){
+               
+                });
+            jQuery(this).hover(
+                function(){
+                    DRAG_DIV.showData(jQuery(this).metadata({
+                        "type":"attr",
+                        "name":"data"
+                    }));
+                },
+                function()
+                {
+                    if(currentFocus) {
+                        DRAG_DIV.showData(jQuery(currentFocus).metadata({
+                            "type":"attr",
+                            "name":"data"
+                        }));
+                    }
+                }
+                );
+            jQuery(this).addClass("inputText");
+        });
+		
+        TOGGLE.init();
+    }
+}
+
+//------------------------------------------------------
+// Run validation
+//------------------------------------------------------
+
+function runValidation()
+{
+	$('#validateProgramDiv' ).load( 'validateProgram.action' ).dialog({
+			title: i18n_violate_validation,
+			maximize: true, 
+			closable: true,
+			modal:true,
+			overlay:{background:'#000000', opacity:0.1},
+			width: 800,
+			height: 450
+		});
+}
\ No newline at end of file

=== added file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/form.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/form.js	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/form.js	2011-10-04 06:28:34 +0000
@@ -0,0 +1,253 @@
+
+function organisationUnitSelected( orgUnits, orgUnitNames )
+{
+	setInnerHTML( 'contentDiv', '' );
+	setFieldValue( 'orgunitName', orgUnitNames[0] );
+	
+	hideById('dataEntryFormDiv');
+	hideById('dataRecordingSelectDiv');
+	showById('searchPatientDiv');
+	
+	enable('searchingAttributeId');
+	jQuery('#searchText').removeAttr('readonly');
+	enable('searchBtn');	
+	enable('listPatientBtn');
+}
+
+selection.setListenerFunction( organisationUnitSelected );
+//--------------------------------------------------------------------------------------------
+// Show selected data-recording
+//--------------------------------------------------------------------------------------------
+
+function showSelectedDataRecoding( patientId )
+{
+	showLoader();
+	hideById('searchPatientDiv');
+	hideById('dataEntryFormDiv');
+	jQuery('#dataRecordingSelectDiv').load( 'selectDataRecording.action', 
+		{
+			patientId: patientId
+		},
+		function()
+		{
+			showById('dataRecordingSelectDiv');
+			hideLoader();
+			hideById('contentDiv');
+		});
+}
+
+//--------------------------------------------------------------------------------------------
+// Show search-form
+//--------------------------------------------------------------------------------------------
+
+function showSearchForm()
+{
+	hideById('dataRecordingSelectDiv');
+	hideById('dataEntryFormDiv');
+	showById('searchPatientDiv');
+	showById('contentDiv');
+}
+
+//--------------------------------------------------------------------------------------------
+// Show all patients in select orgunit
+//--------------------------------------------------------------------------------------------
+
+isAjax = true;
+function listAllPatient()
+{
+	showLoader();
+	jQuery('#contentDiv').load( 'listAllPatients.action',{},
+		function()
+		{
+			hideById('dataRecordingSelectDiv');
+			hideById('dataEntryFormDiv');
+			showById('searchPatientDiv');
+			hideLoader();
+		});
+}
+
+//--------------------------------------------------------------------------------------------
+// Show selected data-recording
+//--------------------------------------------------------------------------------------------
+
+function showSelectedDataRecoding( patientId )
+{
+	showLoader();
+	hideById('searchPatientDiv');
+	hideById('dataEntryFormDiv');
+	jQuery('#dataRecordingSelectDiv').load( 'selectDataRecording.action', 
+		{
+			patientId: patientId
+		},
+		function()
+		{
+			showById('dataRecordingSelectDiv');
+			hideLoader();
+			hideById('contentDiv');
+		});
+}
+
+//-----------------------------------------------------------------------------
+// Search Patient
+//-----------------------------------------------------------------------------
+
+function searchPatientsOnKeyUp( event )
+{
+	var key = getKeyCode( event );
+	
+	if ( key==13 )// Enter
+	{
+		validateSearch();
+	}
+}
+
+function getKeyCode(e)
+{
+	 if (window.event)
+		return window.event.keyCode;
+	 return (e)? e.which : null;
+}
+ 
+function validateSearch( event )
+{	
+	var request = new Request();
+	request.setResponseTypeXML( 'message' );
+	request.setCallbackSuccess( searchValidationCompleted );
+	request.sendAsPost('searchText=' + getFieldValue( 'searchText' ));
+	request.send( 'validateSearch.action' );
+}
+
+function searchValidationCompleted( messageElement )
+{
+    var type = messageElement.getAttribute( 'type' );
+    var message = messageElement.firstChild.nodeValue;
+	
+    if ( type == 'success' )
+    {
+		showLoader();
+		hideById('dataEntryFormDiv');
+		hideById('dataRecordingSelectDiv');
+		$('#contentDiv').load( 'searchPatient.action', 
+			{
+				searchingAttributeId: getFieldValue('searchingAttributeId'), 
+				searchText: getFieldValue('searchText')
+			},
+			function()
+			{
+				showById('searchPatientDiv');
+				hideLoader();
+			});
+    }
+    else if ( type == 'error' )
+    {
+        showErrorMessage( i18n_searching_patient_failed + ':' + '\n' + message );
+    }
+    else if ( type == 'input' )
+    {
+        showWarningMessage( message );
+    }
+}
+
+//------------------------------------------------------
+// Multi Data-entry
+//------------------------------------------------------
+
+function multiDataEntryOrgunitSelected( orgUnits )
+{
+	hideById("listPatient");
+	jQuery.postJSON( "getPrograms.action",
+	{
+	}, 
+	function( json ) 
+	{    
+		enable('programId');
+		enable('patientAttributeId');
+		
+		clearListById('programId');
+		if(json.programs.length == 0)
+		{
+			disable('programId');
+			disable('patientAttributeId');
+		}
+		else
+		{
+			addOptionById( 'programId', "0", i18n_select );
+			
+			for ( var i in json.programs ) 
+			{
+				addOptionById( 'programId', json.programs[i].id, json.programs[i].name );
+			} 
+		}	
+		setFieldValue( 'orgunitName', json.organisationUnit );
+	});
+}
+
+function selectProgram()
+{
+	setInnerHTML('listPatient', '');
+	if( getFieldValue('programId') == 0 )
+	{
+		hideById('listPatient');
+		return;
+	}
+	
+	contentDiv = 'listPatient';
+	showLoader();
+	jQuery('#listPatient').load("getDataRecords.action",
+		{
+			programId:getFieldValue('programId'),
+			sortPatientAttributeId: getFieldValue('patientAttributeId')
+		}, 
+		function()
+		{
+			showById("listPatient");
+			hideLoader();
+		});
+}
+
+function viewPrgramStageRecords( programStageInstanceId ) 
+{
+	$('#contentDataRecord').dialog('destroy').remove();
+    $('<div id="contentDataRecord">' ).load("viewProgramStageRecords.action",
+		{
+			programStageInstanceId: programStageInstanceId
+			
+		}).dialog(
+		{
+			title: 'ProgramStage',
+			maximize: true, 
+			closable: true,
+			modal:true,
+			overlay:{background:'#000000', opacity:0.1},
+			width: 800,
+			height: 400
+		});
+}
+
+function loadProgramStageRecords( programStageInstanceId ) 
+{
+	setInnerHTML('dataEntryFormDiv', '');
+	showLoader();
+    $('#dataEntryFormDiv' ).load("loadProgramStageRecords.action",
+		{
+			programStageInstanceId: programStageInstanceId
+		}, function() {
+			hideLoader();
+		});
+}
+
+// -------------------------------------------------------------------------
+// Show Patient chart list
+// -------------------------------------------------------------------------
+
+function patientChartList( patientId )
+{
+    $( '#patientChartListDiv' ).load('patientChartList.action?patientId=' + patientId ).dialog( {
+        autoOpen : true,
+        modal : true,
+        height : 400,
+        width : 500,
+        resizable : false,
+        title : 'Viewing Chart'
+    } );
+}

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js	2011-09-30 08:37:26 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/patient.js	2011-10-04 06:28:34 +0000
@@ -471,6 +471,7 @@
 	if( programId == 0 )
 	{
 		disable('enrollBtn');
+		disable('registerEventBtn');
 		return;
 	}
 		
@@ -482,7 +483,31 @@
 		}, function()
 		{
 			showById('programEnrollmentDiv');
-			enable('enrollBtn');
+			
+			var registerEvent = getFieldValue('registerEvent');
+			if(registerEvent == 'true')
+			{
+				enable('registerEventBtn');
+			}
+			else
+			{
+				disable('registerEventBtn');
+			}
+			
+			var singleEvent = jQuery('#programId option:selected').attr('singleevent');
+			if(singleEvent=='true')
+			{
+				disable('enrollBtn');
+				disable('enrollmentDate');
+				disable('dateOfIncident');
+			}
+			else
+			{
+				enable('enrollBtn');
+				enable('enrollmentDate');
+				enable('dateOfIncident');
+			}
+			
 			jQuery('#loaderDiv').hide();
 		});
 }
@@ -679,6 +704,8 @@
 	hideById('enrollmentDiv');
 	hideById('listRelationshipDiv');
 	hideById('addRelationshipDiv');
+	hideById('dataRecordingSelectDiv');
+	hideById('dataEntryFormDiv');
 	
 	showById('selectDiv');
 	showById('searchPatientDiv');
@@ -820,3 +847,27 @@
 	jQuery( '#' + rowId ).remove();
 }		
 
+function showSelectedDataRecoding( patientId )
+{
+	showLoader();
+	hideById('searchPatientDiv');
+	hideById('dataEntryFormDiv');
+	jQuery('#dataRecordingSelectDiv').load( 'selectDataRecordingFromRegistration.action', 
+		{
+			patientId: patientId
+		},
+		function()
+		{
+			hideById('enrollmentDiv');
+			showById('dataRecordingSelectDiv');
+			
+			var selectedProgramId = jQuery('#programEnrollmentSelectDiv select[name=programId]').val();
+			jQuery('#dataRecordingSelectDiv select[name=programId] option[value=' + selectedProgramId + ']').attr('selected', 'selected');
+			loadProgramStages();
+			showById('dataRecordingSelectDiv');
+			jQuery("#backBtnFromEntry").click(function() {
+					loadPatientList();
+			});
+			hideLoader();
+		});
+}

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientRegistrationList.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientRegistrationList.vm	2011-10-04 03:10:03 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/patientRegistrationList.vm	2011-10-04 06:28:34 +0000
@@ -92,7 +92,7 @@
 				#end
 				
 				<td style="text-align:center">
-				  <a href="javascript:showProgramEnrollmentSelectForm( '$patient.id' )" title='$i18n.getString( "program_enrollment" )'><img src="../images/enroll.png" alt='$i18n.getString( "program_enrollment" )'></a>                  
+				  <a href="javascript:showProgramEnrollmentSelectForm( '$patient.id' )" title='$i18n.getString( "program_enrollment_management" )'><img src="../images/enroll.png" alt='$i18n.getString( "program_enrollment" )'></a>                  
 				  <a href="javascript:showUnenrollmentSelectForm('$patient.id')" title='$i18n.getString( "program_unenrollment_management" )'><img src="../images/unenroll.png" alt='$i18n.getString( "program_unenrollment_management" )'></a>
 				  <a href="javascript:showUpdatePatientForm( '$patient.id' )" title='$i18n.getString( "edit_profile" )'><img src="../images/edit.png" alt='$i18n.getString( "edit_profile" )'></a>
 				  <a href="javascript:setFieldValue( 'isShowPatientList', false ); showRelationshipList('$patient.id')" title='$i18n.getString( "manage_relationship" )'><img src="../images/relationship.png" alt='$i18n.getString( "manage_relationship" )'></a>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentForm.vm	2011-09-14 06:36:13 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentForm.vm	2011-10-04 06:28:34 +0000
@@ -1,3 +1,5 @@
+<input type='hidden' id='registerEvent' name='registerEvent' value='$registerEvent'>
+
 #if( $programStageInstances )
 	<table width=100%>
 		<col id="noCol">

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentSelectForm.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentSelectForm.vm	2011-09-30 08:37:26 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/programEnrollmentSelectForm.vm	2011-10-04 06:28:34 +0000
@@ -1,9 +1,4 @@
-<div>
-    <input type="button" value="$i18n.getString( "back_to_search" )" onclick="loadPatientList();" style="width:10em">
-</div>
-
-
-<h3>$i18n.getString( "program_enrollment" )</h3>
+<h3>$i18n.getString( "patient_registered" )</h3>
 
 <div id='programEnrollmentSelectDiv'>
 
@@ -33,30 +28,29 @@
 
 	<hr style="clear:both">
 
-	<table>    
+	<table width='100%'>    
 		<tr>
 			<td style="width:180px"><label for="programId">$i18n.getString( "program" )</label></td>
 			<td>
-				<select id="programId" name="programId" style='width:20.3em' onchange="showProgramEnrollmentForm('$patient.id', this.value);" style="min-width:200px" #if( $programs.size() == 0 ) disabled="disabled"#end>
+				<select id="programId" name="programId" style='width:30.3em' onchange="showProgramEnrollmentForm('$patient.id', this.value);" style="min-width:200px" #if( $programs.size() == 0 ) disabled="disabled"#end>
 					<option value="0">[$i18n.getString( "select" )]</option>
 					#foreach( $program in $programs )
-						<option value="$program.id">$encoder.htmlEncode( $program.name )</option>
+						<option value="$program.id" singleevent='$program.singleEvent'>$encoder.htmlEncode( $program.name )</option>
 					#end
 				</select>
 			</td>
+			<td></td>
+			</td></td>
 		</tr>   
 			
-	</table>
-
-	<table width="100%">
 		<tr>
-			<td style="width:180px"><label for="enrollmentDate">$i18n.getString( "date_of_enrollment" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
-			<td><input type="text" id="enrollmentDate" name="enrollmentDate" style='width:20em'> <i>( <span id='enrollmentDateDescription'></span> )</i></td>
-		</tr>
+			<td><label for="enrollmentDate">$i18n.getString( "date_of_enrollment" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
+			<td colspan='2' align='left'><input type="text" id="enrollmentDate" name="enrollmentDate" style='width:30em'> <i>( <span id='enrollmentDateDescription'></span> )</i></td>
+			</tr>
 		
 		<tr>
-			<td style="width:180px"><label for="dateOfIncident">$i18n.getString( "date_of_incident" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
-			<td><input type="text" id="dateOfIncident" name="dateOfIncident" style='width:20em'><i>( <span id='dateOfIncidentDescription'></span> )</i></td>
+			<td><label for="dateOfIncident">$i18n.getString( "date_of_incident" ) <em title="$i18n.getString( "required" )" class="required">*</em></label></td>
+			<td colspan='2'><input type="text" id="dateOfIncident" name="dateOfIncident" style='width:30em'><i>( <span id='dateOfIncidentDescription'></span> )</i></td>
 		</tr>
 		<tr>
 			<td></td>
@@ -64,12 +58,12 @@
 			<td></td>                             
 		</tr>
 		
-	</table>
-
-	<table>
 		<tr>
-			<td style="width:180px">
-				<input type="button" id='enrollBtn' name='enrollBtn' value="$i18n.getString( 'enroll' )" onclick='validateProgramEnrollment();' disabled="disabled" />
+			<td></td>
+			<td style="width:180px" colspan='2'>
+				<input type="button" id='enrollBtn' name='enrollBtn' value="$i18n.getString( 'enroll' )" onclick='validateProgramEnrollment();' disabled="disabled" style='width:10em'/>
+				<input type="button" id='registerEventBtn' value="$i18n.getString( 'register_event' )" onclick="showSelectedDataRecoding('$patient.id')" disabled="disabled" style='width:10em'/>
+				<input type="button" value="$i18n.getString( "back_to_search" )" onclick="loadPatientList();" style="width:10em">
 			</td>                                        
 		</tr>
 	</table>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/selectPatient.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/selectPatient.vm	2011-10-04 03:10:03 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/selectPatient.vm	2011-10-04 06:28:34 +0000
@@ -58,6 +58,8 @@
 <div id='enrollmentDiv'></div> <!-- Program Enrollment Form -->
 <div id='listRelationshipDiv'></div> <!-- List relationship -->
 <div id='addRelationshipDiv'></div> <!-- Add relationship -->
+<div id='dataRecordingSelectDiv'></div>
+<div id='dataEntryFormDiv'></div>
 
 #parse( "/dhis-web-commons/loader/loader.vm" )
 
@@ -107,6 +109,28 @@
 	var i18n_yes = '$encoder.jsEscape( $i18n.getString( "yes" ) , "'")';
 	var i18n_no = '$encoder.jsEscape( $i18n.getString( "no" ) , "'")';
 	var i18n_choose_this_person = '$encoder.jsEscape( $i18n.getString( "choose_this_person" ) , "'")';
+	
+	var i18n_select = '[' + '$encoder.jsEscape( $i18n.getString( "select" ), "'")' + ']';
+	var i18n_program_stages_history_plan = '$encoder.jsEscape( $i18n.getString( "program_stages_history_plan" ) , "'")';
+	
+	var i18n_value_must_integer = '$encoder.jsEscape( $i18n.getString( "value_must_integer" ) , "'")';
+	var i18n_value_must_number = '$encoder.jsEscape( $i18n.getString( "value_must_number" ) , "'")';
+	var i18n_value_must_positive_integer = '$encoder.jsEscape( $i18n.getString( "value_must_positive_integer" ) , "'")';
+	var i18n_value_must_negative_integer = '$encoder.jsEscape( $i18n.getString( "value_must_negative_integer" ) , "'")';
+    var i18n_invalid_date =   '$encoder.jsEscape( $i18n.getString( "invalid_date" ) , "'")' + ".\n " 
+							+ '$encoder.jsEscape( $i18n.getString( "format_date" ) , "'")' + " '" 
+							+ dateFormat.replace('yy', 'yyyy') + " '" ; 
+    var i18n_saving_value_failed_status_code = '$encoder.jsEscape( $i18n.getString( "saving_value_failed_status_code" ) , "'")';
+    var i18n_saving_value_failed_error_code = '$encoder.jsEscape( $i18n.getString( "saving_value_failed_error_code" ) , "'")';
+    var i18n_searching_patient_failed = '$encoder.jsEscape( $i18n.getString( "searching_patient_failed" ) , "'")';
+    var i18n_complete_confirm_message = '$encoder.jsEscape( $i18n.getString( "complete_confirm_message" ) , "'")';
+    var i18n_error_required_field = '$encoder.jsEscape( $i18n.getString( "error_required_field" ) , "'")';
+	var i18n_violate_validation = '$encoder.jsEscape( $i18n.getString( "violate_validation" ) , "'")';
+	var i18n_date_is_greater_then_or_equals_due_date = '$encoder.jsEscape( $i18n.getString( "date_is_greater_then_or_equals_due_date" ) , "'")';
+	
+	var i18n_violate_validation = '$encoder.jsEscape( $i18n.getString( "violate_validation" ) , "'")';
+	
+	
 	var checkedDuplicate = false;
 	// -1: no search anything
 	//  0: show list all patient