← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8589: Check validation criteria before to add person into a single event program in data entry form.

 

------------------------------------------------------------
revno: 8589
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2012-10-19 14:45:01 +0700
message:
  Check validation criteria before to add person into a single event program in data entry form.
modified:
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/singleEvent.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/singleEventSelect.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/webapp/dhis-web-caseentry/javascript/commons.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js	2012-10-19 07:08:17 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js	2012-10-19 07:45:01 +0000
@@ -275,7 +275,7 @@
 }
 
 // ----------------------------------------------------------------------------
-// Show patients
+// Show death field in person re form
 // ----------------------------------------------------------------------------
 
 function isDeathOnChange()

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/singleEvent.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/singleEvent.js	2012-10-18 04:43:40 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/singleEvent.js	2012-10-19 07:45:01 +0000
@@ -95,11 +95,48 @@
 		data: getParamsForDiv('patientForm'),
 		success: function(json) {
 			var patientId = json.message.split('_')[0];
-			addData( getFieldValue('programIdAddPatient'), patientId )
+			validateSingleProgramEnrollment( getFieldValue('programIdAddPatient'), patientId )
 		}
      });
 }
 
+function validateSingleProgramEnrollment( programId, patientId )
+{	
+	jQuery('#loaderDiv').show();
+	jQuery.getJSON( "validatePatientProgramEnrollment.action",
+		{
+			patientId: patientId,
+			programId: programId
+		}, 
+		function( json ) 
+		{    
+			hideById('message');
+			var type = json.response;
+			if ( type == 'success' ){
+				addData( programId, patientId );
+			}
+			else if ( type == 'error' ){
+				setMessage( i18n_program_enrollment_failed + ':' + '\n' + message );
+				removePatientInSingleProgram(patientId);
+			}
+			else if ( type == 'input' ){
+				setMessage( json.message );
+				removePatientInSingleProgram(patientId);
+			}
+			jQuery('#loaderDiv').hide();
+		});
+}
+
+
+function removePatientInSingleProgram( patientId )
+{
+	$("#patientForm :input").attr("disabled",false);
+	jQuery.postJSON( "removePatient.action",
+		{
+			id: patientId
+		}, function(){});
+}
+
 function addData( programId, patientId )
 {		
 	var params = "programId=" + getFieldValue('programIdAddPatient');

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/singleEventSelect.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/singleEventSelect.vm	2012-10-11 09:03:33 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/singleEventSelect.vm	2012-10-19 07:45:01 +0000
@@ -25,7 +25,6 @@
 </div>
 
 <p><input type="button" class='button' value="$i18n.getString( 'back_to_search' )" id='backBtnFromEntry' onclick='backMainPage();' style='display:none;'></p>
-<span id='message'></span>
 
 <div class='hidden' id='selectForm' name='selectForm'>
 	<input id='executionDateNewEvent' name='executionDateNewEvent'>
@@ -46,6 +45,8 @@
 <div id='addRelationshipDiv'></div> <!-- Add relationship -->
 <div id='migrationPatientDiv'></div> <!-- Migration Patient -->
 
+<span id='message'></span>
+
 <script type="text/javascript">
 	var i18n_none = '$encoder.jsEscape( $i18n.getString( "none" ) , "'")';
 	var i18n_please_select_village = '[' + '$encoder.jsEscape( $i18n.getString( "please_select_village" ), "'")' + ']';