/**
* Verifies whether the current [Person] has an active enrollment in the selected [Program]
*
* @param {any} cfs_people_id - GUID of the Person . Default: Form's [people_id]
* @param {any} cfs_program_providing_service_id - GUID of the Program. Default: [program_providing_service_id]
* @returns {string} - {'on'} if Intake is needed, {''} otherwise.
*/
function cfs_IsIntakeNeeded(cfs_people_id, cfs_program_providing_service_id) {
cfs_people_id = ((cfs_people_id == null) || (cfs_people_id == false)) ? getElementFromXML(formXML, 'people_id') : cfs_people_id;
cfs_program_providing_service_id = ((cfs_program_providing_service_id == null) || (cfs_program_providing_service_id == false)) ? getFormElement('program_providing_service') : cfs_program_providing_service_id;
var cfs_condition = 'people_id = \'\'' + cfs_people_id + '\'\' AND program_info_id = \'\'' + cfs_program_providing_service_id + '\'\'';
var cfs_program_name = getDataValue('current_program_enrollment_view', 'people_id', cfs_people_id, 'program_name', cfs_condition);
var cfs_end_date = (getDataValue('current_program_enrollment_view', 'people_id', cfs_people_id, 'end_date', cfs_condition));
var cfs_has_enrollment = (cfs_program_name) ? true : false;
var cfs_is_active = (!cfs_end_date) ? true : false;
if (!cfs_has_enrollment) {
var cfs_intake_needed = 'on';
} else {
var cfs_intake_needed = (!cfs_is_active) ? 'on' : '';
}
cfs_intake_needed = (cfs_program_providing_service_id == '') ? '' : cfs_intake_needed;
if (cfs_program_providing_service_id != '') {
(!cfs_intake_needed) ? alert('Client already has an active enrolment on ' + cfs_program_name + '. Current enrollment MUST be Discharged prior to Triage.') : null;
}
return cfs_intake_needed;
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.