/**
* This js will handle all the Create template Provider functionalities
*/
lexisnexis.component.CreateTemplateProviders = lexisnexis.component.Component
.extend({
data : {
ID: {
SCORE_DIV_TABLE: '#ContainerScores',
SELECT_ALL_PATIENT:'#patientRiskSelectAll',
SELECT_ALL_CASEMIX:'#caseMixSelectAll',
SELECT_ALL_EFFRISK:'#efficiencyRiskSelectAll',
PATIENT_ALL_CHECKBOXES: " input[class^='ptchk']",
CASEMIX_ALL_CHECKBOXES: " input[class^='casechk']",
EFFRISK_ALL_CHECKBOXES: " input[class^='effriskchk']"
},
CHECK_BOX_CHECK_ATTR:'checked',
getProvidersSpecialiesURL : '/getProvidersSpecialities',
//getDataSetProvidersSpecialiesURL : '/getDataSetProvidersSpecialies',
specialitiesAvailableDiv : '#availableSpecialitiesList',
specialitiesSelectedDiv : '#selectedSpecialitiesList',
searchSpecialitiesInputBox : '#specialitySearch',
specialitiesMoveRightBtn : '#specialities-move-right',
specialitiesMoveLeftBtn : '#specialities-move-left',
specialitiesSelectAllAvailableCheckBox : '#specialitiesSelectAllAvailable',
specialitiesSelectAllSelectedCheckBox : '#specialitiesSelectAllSelected',
GET_PROVIDER_COUNT_SPECIALITIES: "getProviderSCountForSpecialities",
GET_PROVIDER_COUNT_SCORES: "getProvidersCountForScores",
selectedListPlaceHolder :"#specialities-Selected-list-placeholder",
availableListPlaceholder : "#specialities-Avail-list-placeholder",
selSpecialtiesDataSet : [],
specialitiesfilteredContent : [],
patientRiskArray: [],
caseMixArray: [],
effRiskArray: [],
delay : (function(){
var timer = 0;
return function(callback, ms){
clearTimeout (timer);
timer = setTimeout(callback, ms);
};
})()
},
ready : function() {
var cs = this;
$("#specialities-No-Match-Result").hide();
$(cs.data.availableListPlaceholder).hide();
$(cs.data.selectedListPlaceHolder).hide();
cs.setupJSTree();
cs.onChangeOfClassification();
cs.onChangeOfSelectAllBox();
cs.specialitiesMoveRight();
cs.specialitiesMoveLeft();
cs.displaySpecialitiesHelpDialog();
cs.displayHelpPopOver();
cs.checkAllAvailable();
cs.checkUncheckScoreChkBx();
cs.validateScoreTxtBox();
cs.setupInputValidations();
LN.getPage().registerEvent(EVENT_TYPES.APPLY_BUTTON_CLICK, cs, cs.onDataSetChange);
},
setupJSTree : function(){
var cs = this;
var params = JSON.stringify({
'selDataSet' : $('#ln_topmenu_dataset').attr("dataSetkey"),
'providerSpeciality' : $('#specialityClassification').val()
});
LN.ajaxPostJSON($(cs.data.specialitiesAvailableDiv).parent(), LN.getContextPath() + cs.data.getProvidersSpecialiesURL, params, cs.specialitiesPanelCallBack, cs);
// Preventing the default submit action for the search box.
$(cs.data.searchSpecialitiesInputBox).keydown(function(e) {
if(e.keyCode == 13){
e.preventDefault();
}
});
// Search
$(cs.data.searchSpecialitiesInputBox).bind('input propertychange keyup',function(e) {
var searchLength = $(cs.data.searchSpecialitiesInputBox).val().length;
$(cs.data.specialitiesAvailableDiv).jstree("deselect_all");
$('#specialitiesSelectAllAvailable').prop('checked', false);
if (searchLength > 2) {
var searchValue = $(cs.data.searchSpecialitiesInputBox).val();
var searchResult = $(cs.data.specialitiesAvailableDiv).jstree('search', searchValue);
if ($(searchResult).find('.jstree-search').length == 0) {
$("#specialities-No-Match-Result").show();
$(cs.data.availableListPlaceholder).hide();
$(cs.data.specialitiesAvailableDiv).hide();
$(cs.data.specialitiesSelectAllAvailableCheckBox).prop('disabled', true);
}else {
$("#specialities-No-Match-Result").hide();
$(cs.data.specialitiesAvailableDiv).show();
$(cs.data.specialitiesSelectAllAvailableCheckBox).prop('disabled', false);
};
} else {
$(cs.data.specialitiesAvailableDiv).jstree(true).clear_search();
$("#specialities-No-Match-Result").hide();
var leftTree =$(cs.data.specialitiesAvailableDiv);
leftTree.show();
if(leftTree.find('li').length == 0){
$(cs.data.availableListPlaceholder).show();
$(cs.data.specialitiesSelectAllAvailableCheckBox).prop('disabled', true);
}
else{
$(cs.data.specialitiesSelectAllAvailableCheckBox).prop('disabled', false);
}
}
});
},
//This call back function is called after ajax is completed (setupJSTree)
specialitiesPanelCallBack : function(cs, data){
var leftJStree = $(cs.data.specialitiesAvailableDiv);
var rightJStree = $(cs.data.specialitiesSelectedDiv);
var leftPanelData = data.leftPanel;
var rightPanelData = data.rightPanel;
//finding gray out node
var rightPanelData = data.rightPanel;
var selSpecialtiesDataSet = [];
$.each(rightPanelData, function(i) {
$.each(rightPanelData[i].children, function(j, specialObj){
if (specialObj.grayOut) {
selSpecialtiesDataSet.push(specialObj.id);
}
});
});
cs.data.selSpecialtiesDataSet = selSpecialtiesDataSet;
//Specialties Available Panel
leftJStree.jstree({
'plugins' : ["search", "checkbox", "sort", "wholerow"],
"checkbox" : {
},
'core' : {
'check_callback' : true,
'themes' : {
'icons' : false,
'responsive' : true
},
'data' : leftPanelData
},
'search' : {
'show_only_matches' : true
}
}).bind("changed.jstree", function (node, action, selected, event) {
cs.bindLeftSpecialitiesCheckBoxEvent();
}).bind("search.jstree", {cs:cs}, function(e, data){
var result = [];
var nodes = data.nodes;
for(var i=0; i< nodes.length; i++){
result.push($(cs.data.specialitiesAvailableDiv).jstree(true).get_node(nodes[i]));
}
cs.data.specialitiesfilteredContent = result;
}).bind("ready.jstree", function(event, data){
if ($(cs.data.searchSpecialitiesInputBox).val().length > 2) {
$(cs.data.searchSpecialitiesInputBox).trigger('keyup');
}else{
$(cs.data.searchSpecialitiesInputBox).val('');
}
});
//Specialties Selected Panel
rightJStree.jstree({
'plugins' : ["checkbox", "sort", "wholerow"],
'checkbox' : {
},
'core' : {
'check_callback' : true,
'themes' : {
'icons' : false,
'responsive' : true
},
'data' : rightPanelData
}
}).bind("ready.jstree", function (event, data) {
rightJStree.jstree(true).open_all();
cs.addGrayColorTextSpecialtiesDataSet(cs.data.selSpecialtiesDataSet);
cs.showDefaultTeePaneText(cs.data.specialitiesAvailableDiv,cs.data.availableListPlaceholder);
cs.showDefaultTeePaneText(cs.data.specialitiesSelectedDiv,cs.data.selectedListPlaceHolder);
cs.enableOrDisableSelectAllCheckBox();
cs.bindRightSpecialitiesCheckBoxEvent();
}).bind("changed.jstree", function (event, data) {
cs.bindRightSpecialitiesCheckBoxEvent();
cs.addGrayColorTextSpecialtiesDataSet(cs.data.selSpecialtiesDataSet);
}).bind("open_node.jstree", function(event,data){
cs.addGrayColorTextSpecialtiesDataSet(cs.data.selSpecialtiesDataSet);
});
},
onChangeOfClassification : function(){
var cs = this;
$("#specialityClassification").on('change', function() {
var params = JSON.stringify({
'selDataSet' : $('#ln_topmenu_dataset').attr("dataSetkey"),
'providerSpeciality' : $('#specialityClassification').val()
});
//Clear search box and un check the select All check box.
$(cs.data.searchSpecialitiesInputBox).val('');
$("#specialities-No-Match-Result").hide();
$(cs.data.specialitiesAvailableDiv).show();
$('#specialitiesSelectAllAvailable').prop('checked', false);
LN.ajaxPostJSON($(cs.data.specialitiesAvailableDiv).parent(), LN.getContextPath() + cs.data.getProvidersSpecialiesURL, params, cs.reloadJsTree, cs);
});
},
//Reload left panel when you change classification drop box
reloadJsTree : function(cs, data){
var leftJStree = $(cs.data.specialitiesAvailableDiv);
leftJStree.jstree("destroy");
leftJStree.jstree({
'plugins' : ["search", "checkbox", "sort", "wholerow"],
'checkbox' : {
},
'core' : {
'check_callback' : true,
'themes' : {
'icons' : false,
'responsive' : true
},
'data' : data.leftPanel
},
'search' : {
'show_only_matches' : true
}
}).bind("ready.jstree", function (event, data) {
cs.showDefaultTeePaneText(cs.data.specialitiesAvailableDiv,cs.data.availableListPlaceholder);
cs.enableOrDisableSelectAllCheckBox();
}).bind("changed.jstree", function (node, action, selected, event) {
cs.bindLeftSpecialitiesCheckBoxEvent();
}).bind("search.jstree", {cs:cs}, function(e, data){
var result = [];
for(var i=0; i< data.nodes.length; i++){
result.push($(cs.data.specialitiesAvailableDiv).jstree(true).get_node(data.nodes[i]));
}
cs.data.specialitiesfilteredContent = result;
});
},
//Method would get fired when selectAll check box are changed
onChangeOfSelectAllBox : function(){
var cs = this;
//Left panel
$("#specialitiesSelectAllAvailable").on('change', function() {
if($('#specialitiesSelectAllAvailable').is(':checked')){
var searchValue = $(cs.data.searchSpecialitiesInputBox).val();
var searchResult = $(cs.data.specialitiesAvailableDiv).jstree('search', searchValue);
if($('#specialities-No-Match-Result:visible').length == 0){
if ($(searchResult).find('.jstree-search').length > 0) {
$(cs.data.specialitiesAvailableDiv).jstree('select_node', cs.data.specialitiesfilteredContent);
}
else{
$(cs.data.specialitiesAvailableDiv).jstree("select_all");
}
}
}
else{
$(cs.data.specialitiesAvailableDiv).jstree("deselect_all");
}
});
//Right panel
$("#specialitiesSelectAllSelected").on('change', function() {
if($('#specialitiesSelectAllSelected').is(':checked')){
$(cs.data.specialitiesSelectedDiv).jstree("select_all");
}
else{
$(cs.data.specialitiesSelectedDiv).jstree("deselect_all");
}
});
},
//Method to move nodes from left to right
specialitiesMoveRight : function(){
var cs = this;
$(cs.data.specialitiesMoveRightBtn).click(function(e) {
LN.showAjaxIndicator($(cs.data.specialitiesSelectedDiv).parent());
setTimeout( function() {
cs.moveNodesToRight(cs.data.specialitiesAvailableDiv, cs.data.specialitiesSelectedDiv);
$(cs.data.specialitiesSelectedDiv).jstree("deselect_all");
$(cs.data.specialitiesSelectedDiv).jstree(true).open_all();
cs.showDefaultTeePaneText(cs.data.specialitiesAvailableDiv,cs.data.availableListPlaceholder);
cs.showDefaultTeePaneText(cs.data.specialitiesSelectedDiv,cs.data.selectedListPlaceHolder);
//Mark select all Check box as unchecked
if($('#specialitiesSelectAllAvailable').is(':checked')){
$('#specialitiesSelectAllAvailable').prop('checked', false);
}
cs.enableOrDisableSelectAllCheckBox();
/*//Mark select all Check box as checked , if available select All is checked
if($('#specialitiesSelectAllSelected').is(':checked')){
$(cs.data.specialitiesSelectedDiv).jstree("select_all");
}*/
cs.addGrayColorTextSpecialtiesDataSet(cs.data.selSpecialtiesDataSet);
if ($(cs.data.searchSpecialitiesInputBox).val().length > 2) {
var searchResult = $(cs.data.specialitiesAvailableDiv).jstree('search', $(cs.data.searchSpecialitiesInputBox).val());
if ($(searchResult).find('.jstree-search').length == 0) {
//Clear search value
$(cs.data.searchSpecialitiesInputBox).val('');
}
}
$(cs.data.searchSpecialitiesInputBox).trigger('keyup');
LN.hideAjaxIndicator($(cs.data.specialitiesSelectedDiv).parent());
cs.callPatientCountAjax();
},300);
});
},
//Method to move node right to left
specialitiesMoveLeft : function(){
var cs = this;
$(cs.data.specialitiesMoveLeftBtn).click(function(e){
LN.showAjaxIndicator($(cs.data.specialitiesAvailableDiv).parent());
setTimeout( function() {
cs.moveNodesToLeft(cs.data.specialitiesAvailableDiv, cs.data.specialitiesSelectedDiv);
$(cs.data.specialitiesSelectedDiv).jstree("deselect_all");
$(cs.data.specialitiesAvailableDiv).jstree("deselect_all");
cs.showDefaultTeePaneText(cs.data.specialitiesAvailableDiv,cs.data.availableListPlaceholder);
cs.showDefaultTeePaneText(cs.data.specialitiesSelectedDiv,cs.data.selectedListPlaceHolder);
//Mark select all Check box as unchecked
if($('#specialitiesSelectAllSelected').is(':checked')){
$('#specialitiesSelectAllSelected').prop('checked', false);
}
cs.enableOrDisableSelectAllCheckBox();
//cs.bindRightSpecialitiesCheckBoxEvent();
//Mark select all Check box as checked , if available select All is checked
/*if($('#specialitiesSelectAllAvailable').is(':checked')){
$(cs.data.specialitiesAvailableDiv).jstree("select_all");
}*/
cs.addGrayColorTextSpecialtiesDataSet(cs.data.selSpecialtiesDataSet);
$(cs.data.searchSpecialitiesInputBox).trigger('keyup');
LN.hideAjaxIndicator($(cs.data.specialitiesAvailableDiv).parent());
cs.callPatientCountAjax();
},300);
});
},
moveNodesToRight : function(sourceTree, destinationTree) {
var cs = this;
var sourceTreeRef = $(sourceTree).jstree(true);
var destinationTreeRef = $(destinationTree).jstree(true);
var parentNodeName = $('#specialityClassification').val();
//Read all selected nodes from source
var sourceTreeSel = sourceTreeRef.get_selected("true");
if(sourceTreeSel.length > 0){
//Search parent is there or not, if not create and add nodes to parent as child
var parentNodeObj = destinationTreeRef.get_node(parentNodeName);
if(!parentNodeObj){
//Creating parent node
parentNodeObj = destinationTreeRef.create_node("#", {"id":parentNodeName,"text":parentNodeName});
}
//loop through nodes
$(sourceTreeSel).each(function(i, nodeObj) {
destinationTreeRef.create_node(parentNodeObj, {"id":nodeObj.id,"text":nodeObj.text});
});
//Node to remove from left panel
sourceTreeRef.delete_node(sourceTreeRef.get_selected());
}
},
moveNodesToLeft : function (sourceTree, destinationTree){
var cs = this;
var sourceTreeRef = $(sourceTree).jstree(true);
var destinationTreeRef = $(destinationTree).jstree(true);
var parentNodeName = $('#specialityClassification').val();
//Read all selected nodes from destination
var destinationTreeSel = destinationTreeRef.get_selected("true");
//Move nodes belongs to parent which classification is selected.
var parentNode = destinationTreeRef.get_node(parentNodeName);
//loop through nodes
$(destinationTreeSel).each(function(i, nodeObj) {
if(nodeObj.parent == parentNodeName){
//Check moving node is out of stock or not
if($.inArray( nodeObj.id , cs.data.selSpecialtiesDataSet ) == -1){
sourceTreeRef.create_node("#", {"id":nodeObj.id,"text":nodeObj.text});
}
}
});
//Node to remove from right panel
destinationTreeRef.delete_node(destinationTreeRef.get_selected());
},
enableOrDisableSelectAllCheckBox : function(){
//Disable/Enable select check box
var cs = this;
var AvailableDiv = $("#availableSpecialitiesList > ul >li");
if(AvailableDiv.length > 0) {
$(cs.data.specialitiesSelectAllAvailableCheckBox).prop('disabled', false);
}
else{
$(cs.data.specialitiesSelectAllAvailableCheckBox).prop('disabled', true);
}
var selectedDiv = $("#selectedSpecialitiesList > ul >li");
if(selectedDiv.length > 0) {
$(cs.data.specialitiesSelectAllSelectedCheckBox).prop('disabled', false);
}
else{
$(cs.data.specialitiesSelectAllSelectedCheckBox).prop('disabled', true);
}
},
callPatientCountAjax : function() {
var cs = this;
var selectedSpecialities = [];
var roots = $(cs.data.specialitiesSelectedDiv).jstree(true).get_json('#', { 'flat': true });
$.each(roots, function(i, item) {
//selectedSpecialities.push({"id": roots[i].id.split('-')[0], "type" : roots[i].id.split('-')[1] ,"text": roots[i].text, "parent": roots[i].parent});
selectedSpecialities.push({"id": roots[i].id,"text": roots[i].text, "topValue": roots[i].parent});
});
createTemplateJs.updatePatientCountAjax(cs.data.GET_PROVIDER_COUNT_SPECIALITIES, "&selectedSpecialities=" + escape(JSON.stringify(selectedSpecialities)));
},
//Need to refresh left panel with new data.
onDataSetChange : function(cs){
var params = JSON.stringify({
'selDataSet' : $('#ln_topmenu_dataset').attr("dataSetkey"),
'providerSpeciality' : $('#specialityClassification').val()
});
LN.ajaxPostJSON($(cs.data.specialitiesAvailableDiv).parent(), LN.getContextPath() + cs.data.getProvidersSpecialiesURL, params, cs.dataSetReloadJsTreeCallBack, cs);
},
dataSetReloadJsTreeCallBack : function(cs, data){
//Left Tree
$(cs.data.specialitiesAvailableDiv).jstree("destroy");
// Right Tree
$(cs.data.specialitiesSelectedDiv).jstree("destroy");
cs.specialitiesPanelCallBack(cs, data);
},
addGrayColorTextSpecialtiesDataSet : function(selSpecialtiesDataSet){
var cs = this;
//Open all
$(cs.data.specialitiesSelectedDiv).jstree(true).open_all();
jQuery.each(cs.data.selSpecialtiesDataSet, function(index,value) {
$('#'+value).addClass('ln-ppm-jsTreetext-light-grey');
});
},
showDefaultTeePaneText : function(jsTreeNodeId,placeHolderdivId) {
/*alert($(jsTreeNodeCheck)+'----->'+$(jsTreeNodeCheck).length)*/
var jsTreeNodeCheck = (jsTreeNodeId)+" > ul >li";
if($(jsTreeNodeCheck).length > 0) {
$(placeHolderdivId).hide();
}
else {
$(placeHolderdivId).show();
}
},
displaySpecialitiesHelpDialog:function(){
$( ".ln_ppm_specialities_context_help" ).click( function(event) {
var msg = 'Help Text needs to be added..';
dlg.simpleDialog(msg,"Specialties",200,400, false, '',this);
dlg.controllEvent(event);
});
},
/*
* Context Help Method (see contextHelp.js)
*/
displayHelpPopOver:function() {
$( ".ln_ppm_providers_context_help" ).on("click",function() {
var msg = 'Help Text needs to be added..';
var title ="Provider ID's";
var placement = "left";
contextHelp.popOver(".ln_ppm_providers_context_help",title,msg,placement);
});
},
//Method to handle when user selected all check boxes manually , Select All check box
//shold get selected automatically.
bindLeftSpecialitiesCheckBoxEvent : function(){
var cs = this;
var selectedArrayLength = $("#availableSpecialitiesList").jstree(true).get_selected(false).length;
var allNodesArrayLength = $("#availableSpecialitiesList").jstree(true).get_json('#', { 'flat': true }).length;
if (cs.data.specialitiesfilteredContent.length > 0) {
if(selectedArrayLength > 0 && selectedArrayLength == cs.data.specialitiesfilteredContent.length){
$('#specialitiesSelectAllAvailable').prop('checked', true);
}
else{
$('#specialitiesSelectAllAvailable').prop('checked', false);
}
}
else{
if(selectedArrayLength > 0 && selectedArrayLength == allNodesArrayLength){
$('#specialitiesSelectAllAvailable').prop('checked', true);
}
else{
$('#specialitiesSelectAllAvailable').prop('checked', false);
}
}
if(selectedArrayLength > 0){
$(cs.data.specialitiesMoveRightBtn).prop('disabled', false);
}else{
$(cs.data.specialitiesMoveRightBtn).prop('disabled', true);
}
},
bindRightSpecialitiesCheckBoxEvent : function(){
var cs = this;
var selectedArrayLength = $("#selectedSpecialitiesList").jstree(true).get_selected(false).length;
var allNodesArrayLength = $("#selectedSpecialitiesList").jstree(true).get_json('#', { 'flat': true }).length;
if( selectedArrayLength > 0 && selectedArrayLength == allNodesArrayLength){
$('#specialitiesSelectAllSelected').prop('checked', true);
}
else{
$('#specialitiesSelectAllSelected').prop('checked', false);
}
if(selectedArrayLength > 0){
$(cs.data.specialitiesMoveLeftBtn).prop('disabled', false);
}else{
$(cs.data.specialitiesMoveLeftBtn).prop('disabled', true);
}
},
checkAllAvailable: function(){
var cs=this;
$(cs.data.ID.SELECT_ALL_PATIENT).change(function(){
var availableCheckBoxes=$(cs.data.ID.SCORE_DIV_TABLE + cs.data.ID.PATIENT_ALL_CHECKBOXES);
if(this.checked) {
availableCheckBoxes.prop(cs.data.CHECK_BOX_CHECK_ATTR, true);
$(cs.data.ID.SCORE_DIV_TABLE + cs.data.ID.PATIENT_ALL_CHECKBOXES).each(function (index) {
if(this.checked){
checked=true;
}
});
cs.clearPatientTextBoxValue();
}else{
availableCheckBoxes.prop(cs.data.CHECK_BOX_CHECK_ATTR, false);
}
createTemplateJs.updatePatientCountAjax(cs.data.GET_PROVIDER_COUNT_SCORES);
});
$(cs.data.ID.SELECT_ALL_CASEMIX).change(function(){
var availableCheckBoxes=$(cs.data.ID.SCORE_DIV_TABLE + cs.data.ID.CASEMIX_ALL_CHECKBOXES);
if(this.checked) {
availableCheckBoxes.prop(cs.data.CHECK_BOX_CHECK_ATTR, true);
$(cs.data.ID.SCORE_DIV_TABLE + cs.data.ID.CASEMIX_ALL_CHECKBOXES).each(function (index) {
if(this.checked){
checked=true;
}
});
cs.clearCaseMixTextBoxValue();
}else{
availableCheckBoxes.prop(cs.data.CHECK_BOX_CHECK_ATTR, false);
}
createTemplateJs.updatePatientCountAjax(cs.data.GET_PROVIDER_COUNT_SCORES);
});
$(cs.data.ID.SELECT_ALL_EFFRISK).change(function(){
var availableCheckBoxes=$(cs.data.ID.SCORE_DIV_TABLE + cs.data.ID.EFFRISK_ALL_CHECKBOXES);
if(this.checked) {
availableCheckBoxes.prop(cs.data.CHECK_BOX_CHECK_ATTR, true);
$(cs.data.ID.SCORE_DIV_TABLE + cs.data.ID.EFFRISK_ALL_CHECKBOXES).each(function (index) {
if(this.checked){
checked=true;
}
});
cs.clearEffRiskTextBoxValue();
}else{
availableCheckBoxes.prop(cs.data.CHECK_BOX_CHECK_ATTR, false);
}
createTemplateJs.updatePatientCountAjax(cs.data.GET_PROVIDER_COUNT_SCORES);
});
},
validateScoreTxtBox: function(){
var cs = this;
$('#ContainerScores input[type="text"]').on('keyup', function() {
cs.data.delay( function(){
createTemplateJs.updatePatientCountAjax(cs.data.GET_PROVIDER_COUNT_SCORES);
},2000);
});
$('#ContainerScores input[type="text"]').keydown(function(e) {
if(e.keyCode == 13){
e.preventDefault();
}
});
$('#patientLowTxtBox,#patientHighTxtBox').keypress(function(event) {
var availableCheckBoxes=$(cs.data.ID.SCORE_DIV_TABLE + cs.data.ID.PATIENT_ALL_CHECKBOXES);
availableCheckBoxes.prop(cs.data.CHECK_BOX_CHECK_ATTR, false);
$(cs.data.ID.SELECT_ALL_PATIENT).prop(cs.data.CHECK_BOX_CHECK_ATTR, false);
});
$('#caseMixLowTxtBox,#caseMixHighTxtBox').keypress(function(event) {
var availableCheckBoxes=$(cs.data.ID.SCORE_DIV_TABLE + cs.data.ID.CASEMIX_ALL_CHECKBOXES);
availableCheckBoxes.prop(cs.data.CHECK_BOX_CHECK_ATTR, false);
$(cs.data.ID.SELECT_ALL_CASEMIX).prop(cs.data.CHECK_BOX_CHECK_ATTR, false);
});
$('#effRiskLowTxtBox,#effRiskHighTxtBox').keypress(function(event) {
var availableCheckBoxes=$(cs.data.ID.SCORE_DIV_TABLE + cs.data.ID.EFFRISK_ALL_CHECKBOXES);
availableCheckBoxes.prop(cs.data.CHECK_BOX_CHECK_ATTR, false);
$(cs.data.ID.SELECT_ALL_EFFRISK).prop(cs.data.CHECK_BOX_CHECK_ATTR, false);
});
},
setupInputValidations: function() {
$('#patientLowTxtBox').rules("add",{
patientLowRange : true,
floatValue: true
});
$('#patientHighTxtBox').rules("add",{
patientHighRange : true,
floatValue: true
});
$('#caseMixLowTxtBox').rules("add",{
caseMixLowRange : true,
floatValue: true
});
$('#caseMixHighTxtBox').rules("add",{
caseMixHighRange : true,
floatValue: true
});
$('#effRiskLowTxtBox').rules("add",{
effRiskLowRange : true,
floatValue: true
});
$('#effRiskHighTxtBox').rules("add",{
effRiskHighRange : true,
floatValue: true
});
$('#ln_last_name').rules('add', {
required : false,
nospecialchar : true,
nonumber : true
});
$('#ln_first_name').rules('add', {
required : false,
nospecialchar : true,
nonumber : true
});
$('#ln_identifier_value').rules('add', {
required : false,
nospecialchar : true /* ,
messages : {
nospecialchar : "Please enter alphanumeric characters"
}*/
});
$('#ln_city').rules('add', {
required : false,
nospecialchar : true,
nonumber : true
});
$('#ln_zip').rules('add', {
required : false,
zipnospecial : true,
zipcode : true
});
},
clearPatientTextBoxValue: function() {
$('#patientLowTxtBox').val('');
$('#patientHighTxtBox').val('');
$('#patientLowTxtBox').attr('placeholder', "0.0");
$('#patientHighTxtBox').attr('placeholder', "0.0");
},
clearCaseMixTextBoxValue: function() {
$('#caseMixLowTxtBox').val('');
$('#caseMixHighTxtBox').val('');
$('#caseMixLowTxtBox').attr('placeholder', "0.0");
$('#caseMixHighTxtBox').attr('placeholder', "0.0");
},
clearEffRiskTextBoxValue: function() {
$('#effRiskLowTxtBox').val('');
$('#effRiskHighTxtBox').val('');
$('#effRiskLowTxtBox').attr('placeholder', "0.0");
$('#effRiskHighTxtBox').attr('placeholder', "0.0");
},
checkUncheckScoreChkBx: function(){
var cs=this;
$(cs.data.ID.SCORE_DIV_TABLE + cs.data.ID.PATIENT_ALL_CHECKBOXES).change(function () {
if(!this.checked){
$(cs.data.ID.SELECT_ALL_PATIENT).prop(cs.data.CHECK_BOX_CHECK_ATTR, false);
// see if any others are checked
var checked = false;
$(cs.data.ID.SCORE_DIV_TABLE + cs.data.ID.PATIENT_ALL_CHECKBOXES).each(function (index) {
if(this.checked){ checked=true; }
});
}else{
var allChecked=true;
$(cs.data.ID.SCORE_DIV_TABLE + cs.data.ID.PATIENT_ALL_CHECKBOXES).each(function (index) {
if(!this.checked){
allChecked=false;
}
});
if(allChecked){
$(cs.data.ID.SELECT_ALL_PATIENT).prop(cs.data.CHECK_BOX_CHECK_ATTR, true);
}
cs.clearPatientTextBoxValue();
}
createTemplateJs.updatePatientCountAjax(cs.data.GET_PROVIDER_COUNT_SCORES);
});
$(cs.data.ID.SCORE_DIV_TABLE + cs.data.ID.CASEMIX_ALL_CHECKBOXES).change(function () {
if(!this.checked){
$(cs.data.ID.SELECT_ALL_CASEMIX).prop(cs.data.CHECK_BOX_CHECK_ATTR, false);
// see if any others are checked
var checked = false;
$(cs.data.ID.SCORE_DIV_TABLE + cs.data.ID.CASEMIX_ALL_CHECKBOXES).each(function (index) {
if(this.checked){ checked=true; }
});
}else{
cs.clearCaseMixTextBoxValue();
var allChecked=true;
$(cs.data.ID.SCORE_DIV_TABLE + cs.data.ID.CASEMIX_ALL_CHECKBOXES).each(function (index) {
if(!this.checked){
allChecked=false;
}
});
if(allChecked){
$(cs.data.ID.SELECT_ALL_CASEMIX).prop(cs.data.CHECK_BOX_CHECK_ATTR, true);
}
}
createTemplateJs.updatePatientCountAjax(cs.data.GET_PROVIDER_COUNT_SCORES);
});
$(cs.data.ID.SCORE_DIV_TABLE + cs.data.ID.EFFRISK_ALL_CHECKBOXES).change(function () {
if(!this.checked){
var checked = false;
$(cs.data.ID.SELECT_ALL_EFFRISK).prop(cs.data.CHECK_BOX_CHECK_ATTR, false);
// see if any others are checked
$(cs.data.ID.SCORE_DIV_TABLE + cs.data.ID.EFFRISK_ALL_CHECKBOXES).each(function (index) {
if(this.checked){ checked=true; }
});
}else{
cs.clearEffRiskTextBoxValue();
var allChecked=true;
$(cs.data.ID.SCORE_DIV_TABLE + cs.data.ID.EFFRISK_ALL_CHECKBOXES).each(function (index) {
if(!this.checked){
allChecked=false;
}
});
if(allChecked){
$(cs.data.ID.SELECT_ALL_EFFRISK).prop(cs.data.CHECK_BOX_CHECK_ATTR, true);
}
}
createTemplateJs.updatePatientCountAjax(cs.data.GET_PROVIDER_COUNT_SCORES);
});
}
});
$.validator.addMethod("patientLowRange", function(value, element) {
if($('#patientHighTxtBox').val().length > 0 && value.length > 0){
if(($('#patientHighTxtBox').val().length == value.length)){
if (parseFloat(value) > parseFloat($('#patientHighTxtBox').val())) {
return false;
}
}else if($('#patientHighTxtBox').val().length > value.length){
if(parseFloat(value) > parseFloat($('#patientHighTxtBox').val())){
return false;
}
}else if($('#patientHighTxtBox').val().length < value.length){
if(parseFloat($('#patientHighTxtBox').val()) < parseFloat(value)){
return false;
}
}
}
return true;
}, 'From value cannot be greater than To value');
$.validator.addMethod("patientHighRange", function(value, element) {
if($('#patientLowTxtBox').val().length > 0 && value.length > 0){
if(($('#patientLowTxtBox').val().length == value.length)){
if (parseFloat(value) < parseFloat($('#patientLowTxtBox').val())) {
return false;
}
}else if($('#patientLowTxtBox').val().length > value.length){
if(parseFloat(value) < parseFloat($('#patientLowTxtBox').val())){
return false;
}
}else if($('#patientLowTxtBox').val().length < value.length){
if(parseFloat($('#patientLowTxtBox').val()) > parseFloat(value)){
return false;
}
}
}
return true;
}, 'To value cannot be less than From value');
$.validator.addMethod("floatValue", function(value, element) {
if(value.length > 0 ){
if(!value.match('^[0-9]*[.]?[0-9]+$')){
return false;
}
if(isNaN(parseFloat(value))){
return false;
}
}
return true;
}, 'Please Enter Decimal Value');
$.validator.addMethod("caseMixLowRange", function(value, element) {
if($('#caseMixHighTxtBox').val().length > 0 && value.length > 0){
if(($('#caseMixHighTxtBox').val().length == value.length)){
if (parseFloat(value) > parseFloat($('#caseMixHighTxtBox').val())) {
return false;
}
}else if($('#caseMixHighTxtBox').val().length > value.length){
if(parseFloat(value) > parseFloat($('#caseMixHighTxtBox').val())){
return false;
}
}else if($('#caseMixHighTxtBox').val().length < value.length){
if(parseFloat($('#caseMixHighTxtBox').val()) < parseFloat(value) ){
return false;
}
}
}
return true;
}, 'From value cannot be greater than To value');
$.validator.addMethod("caseMixHighRange", function(value, element) {
if($('#caseMixLowTxtBox').val().length > 0 && value.length > 0){
if(($('#caseMixLowTxtBox').val().length == value.length)){
if (parseFloat(value) < parseFloat($('#caseMixLowTxtBox').val())) {
return false;
}
}else if($('#caseMixLowTxtBox').val().length > value.length){
if(parseFloat(value) < parseFloat($('#caseMixLowTxtBox').val())){
return false;
}
}else if($('#caseMixLowTxtBox').val().length < value.length){
if(parseFloat($('#caseMixLowTxtBox').val()) > parseFloat(value)){
return false;
}
}
}
return true;
}, 'To value cannot be less than From value');
$.validator.addMethod("effRiskLowRange", function(value, element) {
if($('#effRiskHighTxtBox').val().length > 0 && value.length > 0){
if(($('#effRiskHighTxtBox').val().length == value.length)){
if (parseFloat(value) > parseFloat($('#effRiskHighTxtBox').val())) {
return false;
}
}else if($('#effRiskHighTxtBox').val().length > value.length){
if(parseFloat(value) > parseFloat($('#effRiskHighTxtBox').val())){
return false;
}
}else if($('#effRiskHighTxtBox').val().length < value.length){
if(parseFloat($('#effRiskHighTxtBox').val()) < parseFloat(value)){
return false;
}
}
}
return true;
}, 'From value cannot be greater than To value');
$.validator.addMethod("effRiskHighRange", function(value, element) {
if($('#effRiskLowTxtBox').val().length > 0 && value.length > 0){
if(($('#effRiskLowTxtBox').val().length == value.length)){
if (parseFloat(value) < parseFloat($('#effRiskLowTxtBox').val())) {
return false;
}
}else if($('#effRiskLowTxtBox').val().length > value.length){
if(parseFloat(value) < parseFloat($('#effRiskLowTxtBox').val())){
return false;
}
}else if($('#effRiskLowTxtBox').val().length < value.length){
if(parseFloat($('#effRiskLowTxtBox').val()) > parseFloat(value)){
return false;
}
}
}
return true;
}, 'To value cannot be less than From value');
$.validator.addMethod("nospecialchar", function(value, element) {
var pattern = /[+*.,!@#$%^&();/|\\?-]/g;
return !pattern.test(value);
}, "Please enter alpha characters");
$.validator.addMethod("nonumber", function(value, element) {
var pattern = /[0-9]/g;
return !pattern.test(value);
}, "Please enter alpha characters");
$.validator.addMethod("zipcode", function(value, element) {
var pattern = /^(\s*|\d+)$/g;
return pattern.test(value);
}, "Please enter a numeric zip code");
$.validator.addMethod("zipnospecial", function(value, element) {
var pattern = /[+*.,!@#$%^&();/|\\?-]/g;
return !pattern.test(value);
}, "Please enter a numeric zip code");