=== 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 @@

-