/1000
");
characterCountText.appendTo($("#mcs_questiondetail").closest("td"));
$("#mcs_questiondetail").attr("maxlength", "1000");
$("#mcs_questiondetail").keyup(function () {
CharacterCount();
});
$("#hrc_noemailaddress_bool").change(function () {
EmailRequired();
});
$("#mcs_preferredmethodofcontact").change(function () {
HidePrefEmail();
});
//hide registries and purpose details
$('#mcs_mandatedregistries').parent().parent().hide();
$("#vhacrm_interactionsubpurposeid").parent().parent().hide();
var c = $("#vhacrm_interactionsubpurposeid").parent().parent().parent();
//Append a select tag with the following parameters to the above lookup
$("
", {
"class": "lookup form-control form-select",
"id": "drop-down", //it can be any name-id you like
}).appendTo(c);
$('#drop-down').parent().parent().hide();
//when subtopic is selected.
$("#drop-down").change(function () {
SaveSubTopic()
});
//when topic is selected.
$("#vhacrm_interactionpurposeid").change(function () {
PopulateSubTopics()
});
AddContactEntityAndPreferedMethod();
//RemoveVeteranServiceOrgs();
//when topic is selected.
$("#bah_interactedwith_code").change(function () {
OnChangeContactingEntity();
});
//when not contacting in regards to veteran changed
$("#bah_notveteran_bool").change(function () {
OnChangeContactingRegardsToVeteran();
});
//when relationship to veteran is changed
$("#bah_relationshiptoveteran_code").change(function () {
OnChangeRelationshipToVeteran();
});
//when clinician types is changed
$("#mcs_cliniciantype").change(function () {
OnChangeClinicianType();
});
DefaultContactInfo();
ChangeLabelsForNonVets();
})
function HidePrefEmail() {
var option = $('#mcs_preferredmethodofcontact').val();
if (option == 153190000) {
$('#hrc_noemailaddress_bool').prop("checked", false);
$('#hrc_noemailaddress_bool').parent().hide();
$('#hrc_noemailaddress_bool_label').parent().hide();
}
else {
$('#hrc_noemailaddress_bool').parent().show();
$('#hrc_noemailaddress_bool_label').parent().show();
}
}
function EmailRequired() {
var bemail = $('#hrc_noemailaddress_bool').is(":checked");
if (bemail == false) {
$("#mcs_vethomeemailaddress").attr('aria-required', "true");
$('#mcs_vethomeemailaddress').parent().prev().addClass("required");
}
else {
$("#mcs_vethomeemailaddress").attr('aria-required', "false");
$('#mcs_vethomeemailaddress').parent().prev().removeClass("required");
}
}
function SaveSubTopic() {
var id = $("#drop-down").val();
var txt = $("#drop-down option:selected").text();
$("#vhacrm_interactionsubpurposeid_name").attr("value", txt);
$("#vhacrm_interactionsubpurposeid").attr("value", id);
$("#vhacrm_interactionsubpurposeid_entityname").attr("value", "vhacrm_subareaintersection");
}
function PopulateSubTopics() {
var topic = $('#vhacrm_interactionpurposeid').val();
//registries evaluation or registry eligibility show registries multiselect
if (topic == 'c41bfdb1-2a98-ed11-aad1-001dd80701be' || topic == 'e2c0f764-9d2c-ee11-9966-001dd80769ee') {
$('#mcs_mandatedregistries').parent().parent().show();
$('#drop-down').parent().parent().hide();
}
//general information, questionnaire
else if (topic == 'd5ddc281-2a98-ed11-aad1-001dd80701be' || topic == 'e6f8e7d1-34a6-ed11-aad1-001dd80726d6') {
$('#mcs_mandatedregistries').parent().parent().hide();
$('#drop-down').parent().parent().show();
$('#drop-down').empty();
if (topic != null && topic != "") {
// request to our custom page with id as parameter
$.getJSON("/purposedetailsjson/?id=" + topic, function (data) {
if (data.results.length > 0) {
let option1 = document.createElement("option");
option1.value = 0;
option1.innerText = "";
$("#drop-down").append(option1);
//create option for each returned entity
data.results.forEach(element => {
let option = document.createElement("option");
option.value = element.Id;
option.innerText = element.Name;
$("#drop-down").append(option);
});
}
});
}
}
else {
$('#mcs_mandatedregistries').parent().parent().hide();
$('#drop-down').parent().parent().hide();
}
}
function AddContactEntityAndPreferedMethod() {
$('#bah_interactedwith_code').empty();
AddOption(' ', ' ', '#bah_interactedwith_code');
AddOption(810050001, 'Veteran', '#bah_interactedwith_code');
AddOption(803750013, 'Active Duty Service Member', '#bah_interactedwith_code');
AddOption(803750014, 'Clinician', '#bah_interactedwith_code');
AddOption(810050002, 'Meaningful Relationship', '#bah_interactedwith_code');
AddOption(399590001, 'Member of Congress', '#bah_interactedwith_code');
AddOption(803750012, 'VA Employee (Non-Clinical)', '#bah_interactedwith_code');
AddOption(810050003, 'Veteran Service Officer', '#bah_interactedwith_code');
AddOption(810050004, 'Other', '#bah_interactedwith_code');
$('#mcs_preferredmethodofcontact').empty();
AddOption(' ', ' ', '#mcs_preferredmethodofcontact');
AddOption(153190000, 'Email', '#mcs_preferredmethodofcontact');
AddOption(153190001, 'Phone', '#mcs_preferredmethodofcontact');
$('#bah_relationshiptoveteran_code').empty();
AddOption(' ', ' ', '#bah_relationshiptoveteran_code');
AddOption(810050000, 'Child', '#bah_relationshiptoveteran_code');
AddOption(810050003, 'Friend', '#bah_relationshiptoveteran_code');
AddOption(810050001, 'Parent', '#bah_relationshiptoveteran_code');
AddOption(810050005, 'Sibling', '#bah_relationshiptoveteran_code');
AddOption(810050002, 'Spouse', '#bah_relationshiptoveteran_code');
AddOption(810050004, 'Other', '#bah_relationshiptoveteran_code');
}
function RemoveVeteranServiceOrgs() {
var optionsToRemove = ['1ed0eeee-049c-ed11-aad0-001dd80721cf', '20d0eeee-049c-ed11-aad0-001dd80721cf'];
$.each(optionsToRemove, function (index, value) {
var optionToRemove = value;
$("#mcs_veteranserviceorganizationid option[value='" + optionToRemove + "']").remove();
});
}
function AddOption(id, name, ctrol) {
let option = document.createElement("option");
option.value = id;
option.innerText = name;
$(ctrol).append(option);
}
function OnChangeContactingEntity() {
var conentity = $('#bah_interactedwith_code').val();
HideAllContactingEntityRelatedFields();
//fields that show/required no matter what. Could probably delete later but putting these here for now to ensure it shows and we can move on
$('#bah_dob_date').parent().parent().parent().show();
$('#bah_dob_date').parent().prev().addClass("required");
$("#bah_dob_date").next().data("DateTimePicker").maxDate(moment());
$('#bah_notveteran_bool').prop('checked', false);
switch (conentity) {
//Veteran
case '810050001':
ChangeLabelsForNonVets();
break;
//Active Duty Service Member
case '803750013':
ChangeLabelsForNonVets();
break;
//Veteran Service Officer
case '810050003':
$('#bah_contactfullname').parent().parent().parent().show();
$('#mcs_veteranserviceorganizationid').parent().parent().parent().show();
$("#mcs_veteranserviceorganizationid").attr('aria-required', "true");
$('#mcs_veteranserviceorganizationid').parent().prev().addClass("required");
ChangeLabelsForNonVets();
break;
//Clinician
case '803750014':
$('#bah_contactfullname').parent().parent().parent().show();
$('#mcs_cliniciantype').parent().parent().parent().show();
$("#mcs_cliniciantype").attr('aria-required', "true");
$('#mcs_cliniciantype').parent().prev().addClass("required");
ChangeLabelsForNonVets();
break;
//Member of Congress
case '399590001':
$('#bah_contactfullname').parent().parent().parent().show();
$('#mcs_congressionaloffice').parent().parent().parent().show();
$("#mcs_congressionaloffice").attr('aria-required', "true");
$('#mcs_congressionaloffice').parent().prev().addClass("required");
ChangeLabelsForNonVets();
break;
// VA Employee (Non-Clinical)
case '803750012':
$('#bah_contactfullname').parent().parent().parent().show();
ChangeLabelsForNonVets();
break;
//Meaningful relationship
case '810050002':
$('#bah_contactfullname').parent().parent().parent().show();
$('#bah_relationshiptoveteran_code').parent().parent().parent().show();
$("#bah_relationshiptoveteran_code").attr('aria-required', "true");
$('#bah_relationshiptoveteran_code').parent().prev().addClass("required");
ChangeLabelsForNonVets();
break;
//Other
case '810050004':
$('#bah_contactfullname').parent().parent().parent().show();
$('#bah_interactedwithother_text').parent().parent().parent().show();
$("#bah_interactedwithother_text").attr('aria-required', "true");
$('#bah_interactedwithother_text').parent().prev().addClass("required");
ChangeLabelsForNonVets();
break;
default:
HideAllContactingEntityRelatedFields();
ChangeLabelsForNonVets();
}
}
function ChangeLabelsForNonVets() {
var conentity = $('#bah_interactedwith_code').val();
var notvet = $('#bah_notveteran_bool').is(":checked")
//Veteran/Servicemember
if (conentity != '810050001' && conentity != '803750013') {
if (notvet == false) {
$("label[for='bah_firstname_text']").text("Veteran's First Name");
$("label[for='bah_lastname_text']").text("Veteran's Last Name");
$("label[for='bah_dob_date_datepicker_description']").text("Veteran's Date of Birth");
$('#bah_notveteran_bool').parent().parent().parent().show();
$("#bah_dob_date").attr('aria-required', "true");
$('#bah_dob_date').parent().prev().addClass("required");
}
else {
$("label[for='bah_firstname_text']").text("First Name");
$("label[for='bah_lastname_text']").text("Last Name");
$("label[for='bah_dob_date_datepicker_description']").text("Date of Birth");
$('#bah_notveteran_bool').parent().parent().parent().show();
$('#bah_contactfullname').parent().parent().parent().hide();
}
}
else {
$("label[for='bah_firstname_text']").text("First Name");
$("label[for='bah_lastname_text']").text("Last Name");
$("label[for='bah_dob_date_datepicker_description']").text("Date of Birth");
$("#bah_dob_date").attr('aria-required', "true");
$('#bah_dob_date').parent().prev().addClass("required");
$('#bah_notveteran_bool').prop('checked', false);
$('#bah_notveteran_bool').parent().parent().parent().hide();
}
}
function OnChangeContactingRegardsToVeteran() {
var notvet = $('#bah_notveteran_bool').is(":checked")
if (notvet == false) {
$("label[for='bah_firstname_text']").text("Veteran's First Name");
$("label[for='bah_lastname_text']").text("Veteran's Last Name");
$("label[for='bah_dob_date_datepicker_description']").text("Veteran's Date of Birth");
$("#bah_dob_date").attr('aria-required', "true");
$('#bah_dob_date').parent().prev().addClass("required");
$('#bah_dob_date').parent().parent().parent().show();
$('#bah_contactfullname').parent().parent().parent().show();
}
else {
$("label[for='bah_firstname_text']").text("First Name");
$("label[for='bah_lastname_text']").text("Last Name");
$("label[for='bah_dob_date_datepicker_description']").text("Date of Birth");
$("#bah_dob_date_datepicker_description").val('');
$("#bah_dob_date").val('');
$("#bah_dob_date").attr('aria-required', "false");
$('#bah_dob_date').parent().prev().removeClass("required");
$('#bah_dob_date').parent().parent().parent().hide();
$('#bah_contactfullname').val('');
$('#bah_contactfullname').parent().parent().parent().hide();
}
}
function OnChangeRelationshipToVeteran() {
var relationship = $('#bah_relationshiptoveteran_code').val();
//other
if (relationship == '810050004') {
$('#bah_otherrelationship_text').parent().parent().parent().show();
$("#bah_otherrelationship_text").attr('aria-required', "true");
$('#bah_otherrelationship_text').parent().prev().addClass("required");
}
else {
$('#bah_otherrelationship_text').parent().parent().parent().hide();
$('#bah_otherrelationship_text').val('');
$('#bah_otherrelationship_text').val('');
$("#bah_otherrelationship_text").attr('aria-required', "false");
}
}
function OnChangeClinicianType() {
var clintype = $('#mcs_cliniciantype').val();
//Community
if (clintype == '803750000') {
$('#ccwf_providerfacility_text').parent().parent().parent().show();
$("#ccwf_providerfacility_text").attr('aria-required', "true");
$('#ccwf_providerfacility_text').parent().prev().addClass("required");
}
else {
$('#ccwf_providerfacility_text').parent().parent().parent().hide();
$('#ccwf_providerfacility_text').val('');
$("#ccwf_providerfacility_text").attr('aria-required', "false");
$('#ccwf_providerfacility_text').parent().prev().removeClass("required");
}
}
function HideAllContactingEntityRelatedFields() {
//$("#bah_dob_date").val('');
//$("#bah_dob_date").attr('aria-required', "false");
//$('#bah_dob_date').parent().parent().parent().hide();
//$('#bah_dob_date').parent().prev().removeClass("required");
$('#mcs_congressionaloffice').val('');
$("#mcs_congressionaloffice").attr('aria-required', "false");
$('#mcs_congressionaloffice').parent().parent().parent().hide();
$('#mcs_congressionaloffice').parent().prev().removeClass("required");
$('#bah_interactedwithother_text').val('');
$("#bah_interactedwithother_text").attr('aria-required', "false");
$('#bah_interactedwithother_text').parent().parent().parent().hide();
$('#bah_interactedwithother_text').parent().prev().removeClass("required");
$('#ccwf_providerfacility_text').val('');
$("#ccwf_providerfacility_text").attr('aria-required', "false");
$('#ccwf_providerfacility_text').parent().parent().parent().hide();
$('#ccwf_providerfacility_text').parent().prev().removeClass("required");
$('#mcs_veteranserviceorganizationid').val('');
$("#mcs_veteranserviceorganizationid").attr('aria-required', "false");
$('#mcs_veteranserviceorganizationid').parent().parent().parent().hide();
$('#mcs_veteranserviceorganizationid').parent().prev().removeClass("required");
$('#mcs_cliniciantype').val('');
$("#mcs_cliniciantype").attr('aria-required', "false");
$('#mcs_cliniciantype').parent().parent().parent().hide();
$('#mcs_cliniciantype').parent().prev().removeClass("required");
$('#bah_relationshiptoveteran_code').val('');
$("#bah_relationshiptoveteran_code").attr('aria-required', "false");
$('#bah_relationshiptoveteran_code').parent().parent().parent().hide();
$('#bah_relationshiptoveteran_code').parent().prev().removeClass("required");
$('#bah_otherrelationship_text').val('');
$("#bah_otherrelationship_text").attr('aria-required', "false");
$('#bah_otherrelationship_text').parent().parent().parent().hide();
$('#bah_otherrelationship_text').parent().prev().removeClass("required");
$('#bah_contactfullname').val('');
$('#bah_contactfullname').parent().parent().parent().hide();
}
function AddValidators() {
// Add event validator
if (typeof (Page_Validators) == 'undefined') return;
$.getScript('https://cdnjs.cloudflare.com/ajax/libs/jquery.mask/1.14.3/jquery.mask.js', function () {
var ctl = $("#bah_phonenumber_text");
ctl.mask("000-000-0000");
var ctl1 = $("#vhacrm_zip_text");
ctl1.mask("00000");
});
$("#mcs_vethomeemailaddress").attr('aria-required', "true");
$('#mcs_vethomeemailaddress').parent().prev().addClass("required");
// Create new validator - DOB required if Veteran or Active Service
var newValidator = document.createElement('span');
newValidator.style.display = "none";
newValidator.id = "bah_dob_dateValidator";
newValidator.controltovalidate = "bah_dob_date";
newValidator.errormessage = "
Date of Birth is required.";
newValidator.evaluationfunction = function () {
//var conentity = $('#bah_interactedwith_code').val();
var notvet = $('#bah_notveteran_bool').is(":checked")
if (notvet == false) {
if ($('#bah_dob_date').val() == null || $('#bah_dob_date').val().trim() == "") {
return false;
} else {
return true;
}
}
else {
return true;
}
/*
if (conentity == '810050001' || conentity == '803750013') {
if ($('#bah_dob_date').val() == null || $('#bah_dob_date').val().trim() == "") {
return false;
} else {
return true;
}
} else {
return true;
}
*/
};
Page_Validators.push(newValidator);
// Create new validator - email address
var newValidator = document.createElement('span');
newValidator.style.display = "none";
newValidator.id = "emailaddress1Validator";
newValidator.controltovalidate = "mcs_vethomeemailaddress";
newValidator.errormessage = "
Email is required.";
newValidator.evaluationfunction = function () {
var bemail = $('#hrc_noemailaddress_bool').is(":checked");
if (bemail == false) {
if ($('#mcs_vethomeemailaddress').val().trim() == "") {
return false;
} else {
return true;
}
} else {
return true;
}
};
Page_Validators.push(newValidator);
// Create new validator - bah_relationshiptoveteran_code
var newValidator = document.createElement('span');
newValidator.style.display = "none";
newValidator.id = "RelationshipToVeteranValidator";
newValidator.controltovalidate = "bah_relationshiptoveteran_code";
newValidator.errormessage = "
Relationship to Veteran is required.";
newValidator.evaluationfunction = function () {
var interactedWith = $('#bah_interactedwith_code').val();
//Meaningful Relationship=810050002
if (interactedWith == '810050002') {
if ($('#bah_relationshiptoveteran_code').val() == null || $('#bah_relationshiptoveteran_code').val() == "") {
return false;
} else {
return true;
}
} else {
return true;
}
};
Page_Validators.push(newValidator);
// Create new validator - mcs_cliniciantype
var newValidator = document.createElement('span');
newValidator.style.display = "none";
newValidator.id = "clinicianTypeValidator";
newValidator.controltovalidate = "mcs_cliniciantype";
newValidator.errormessage = "
Clinician type is required.";
newValidator.evaluationfunction = function () {
var interactedWith = $('#bah_interactedwith_code').val();
//Clinician=803750014
if (interactedWith == '803750014') {
if ($('#mcs_cliniciantype').val() == "") {
return false;
} else {
return true;
}
} else {
return true;
}
};
Page_Validators.push(newValidator);
// Create new validator - mcs_veteranserviceorganizationid
var newValidator = document.createElement('span');
newValidator.style.display = "none";
newValidator.id = "VetSvsOrgValidator";
newValidator.controltovalidate = "mcs_veteranserviceorganizationid";
newValidator.errormessage = "
Veteran service organization is required.";
newValidator.evaluationfunction = function () {
var interactedWith = $('#bah_interactedwith_code').val();
//Veteran Service Organization=810050003
if (interactedWith == '810050003') {
if ($('#mcs_veteranserviceorganizationid').val() == "") {
return false;
} else {
return true;
}
} else {
return true;
}
};
Page_Validators.push(newValidator);
// Create new validator - ccwf_providerfacility_text
var newValidator = document.createElement('span');
newValidator.style.display = "none";
newValidator.id = "ProviderFacilityValidator";
newValidator.controltovalidate = "ccwf_providerfacility_text";
newValidator.errormessage = "
Provider facility is required.";
newValidator.evaluationfunction = function () {
var clinicianType = $('#mcs_cliniciantype').val();
//Community=803750000
if (clinicianType == '803750000') {
if ($('#ccwf_providerfacility_text').val() == "") {
return false;
} else {
return true;
}
} else {
return true;
}
};
Page_Validators.push(newValidator);
// Create new validator - bah_otherrelationship_text
var newValidator = document.createElement('span');
newValidator.style.display = "none";
newValidator.id = "OtherRelationshipValidator";
newValidator.controltovalidate = "bah_otherrelationship_text";
newValidator.errormessage = "
Other relationship is required.";
newValidator.evaluationfunction = function () {
var relationshipType = $('#bah_relationshiptoveteran_code').val();
//Other=810050004
if (relationshipType == '810050004') {
if ($('#bah_otherrelationship_text').val() == "") {
return false;
} else {
return true;
}
} else {
return true;
}
};
Page_Validators.push(newValidator);
// Create new validator - mcs_congressionaloffice
var newValidator = document.createElement('span');
newValidator.style.display = "none";
newValidator.id = "CongressionalOfficeValidator";
newValidator.controltovalidate = "mcs_congressionaloffice";
newValidator.errormessage = "
Congressional office is required.";
newValidator.evaluationfunction = function () {
var interactedWith = $('#bah_interactedwith_code').val();
//Member of congress=399590001
if (interactedWith == '399590001') {
if ($('#mcs_congressionaloffice').val().trim() == "") {
return false;
} else {
return true;
}
} else {
return true;
}
};
Page_Validators.push(newValidator);
// Create new validator - bah_interactedwithother_text
var newValidator = document.createElement('span');
newValidator.style.display = "none";
newValidator.id = "InteractedWithOtherValidator";
newValidator.controltovalidate = "bah_interactedwithother_text";
newValidator.errormessage = "
Other title is required.";
newValidator.evaluationfunction = function () {
var interactedWith = $('#bah_interactedwith_code').val();
//Other=810050004
if (interactedWith == '810050004') {
if ($('#bah_interactedwithother_text').val() == "") {
return false;
} else {
return true;
}
} else {
return true;
}
};
Page_Validators.push(newValidator);
}
function DefaultContactInfo() {
var firstName = "";
var lastName = "";
var phone = "";
var email = "";
//if firstname is populated, assume they are signed in
if (firstName != "") {
$("#bah_firstname_text").val(firstName);
$("#bah_lastname_text").val(lastName);
$("#bah_phonenumber_text").val(phone);
$("#mcs_vethomeemailaddress").val(email);
$("#bah_interactedwith_code").val(810050001);
}
OnChangeContactingEntity();
}
function CharacterCount() {
var characterCount = $("#mcs_questiondetail").val().length,
current = $('#current'),
maximum = $('#maximum'),
theCount = $('#the-count');
current.text(characterCount);
}