/*
* This js file would contain the logic of creating data tables for
* the ZipCodes panel in create Template Patients tab.
* Author : sankpa01
*
*/
jQuery.namespace('lexisnexis.component');
lexisnexis.component.patientZipCodes = lexisnexis.component.tableNodes_v3.extend({
/**
* On load initializing
*/
ready : function () {
var cs = this;
/*$.extend(cs.data, );*/
cs.data.initialize = true;
/**
* Create Table for the selected and available Conditions
*/
cs.createTables();
/**
* Register Data Set Change
*/
LN.getPage().registerEvent(EVENT_TYPES.APPLY_BUTTON_CLICK, cs, cs.onDataSetChange);
/**
* Setting the threshold exceed message
*/
cs.data.thresholdExceedMsg = "You have exceeded the maximum number of zip codes (" + LN.THRESHOLD_LIMIT + ") that you may add to the Selected zip codes list. Please uncheck {0} name(s) from the Available zip codes List";
},
/**
* Refresh left and right panels
*/
onDataSetChange : function(cs){
cs.data.initialize = true;
$('#availableZipCodes').DataTable().draw();
cs.getProvidersCountForSelNetworks();
},
/**
* Fetches the table response from the service
*/
fetchResponse : function ( tableObj ) {
var response = [];
var sObj = [];
var cs = this;
var ajaxObj = {
'ajax' : function ( data, callback, settings ) {
var inputData = data;
var startIndex = inputData.start ? inputData.start : 0;
var searchJSON = cs.searchTermsJSON();
var jsonString = {
"startIndex" : startIndex,
"searchTerms" : searchJSON
};
LN.debug(JSON.stringify(jsonString));
$.ajax( {
'url' : LN.getContextPath() + "/ppmGetPatientZipCodes/" + $('#ln_topmenu_dataset').attr("dataSetkey"),
'method' : 'POST',
"dataType" : "json",
"data" : {
inputJson : JSON.stringify( jsonString ),
selectedZipCodes : cs.getSelectedZipCodesData(),
triggerEvent: cs.getTriggeringEvent()
},
'beforeSend' : function () {
LN.showAjaxIndicator( $( '#availableZipCodes' ).parent() );
},
'complete' : function () {
$("#selectedZipCodes th:first-child").css("width","20px");
LN.hideAjaxIndicator( $( '#availableZipCodes' ).parent() );
},
'success' : function ( data ) {
cs.data.totalRecordCount = data.totalRecords;
// Rendering selected conditions list in the right
var selectedZipCodesTable = $( '#selectedZipCodes' ).DataTable();
selectedZipCodesTable.clear().draw();
selectedZipCodesTable.rows.add(data.aaDataRight ).draw();
callback( {
draw : inputData.draw,
data : data.aaDataLeft,
recordsTotal : data.totalRecords,
recordsFiltered : data.totalRecords
} );
cs.performActionOnSelectallCheckBoxes(data);
}
} );
}
};
return ajaxObj;
},
getSelectedZipCodesData: function() {
var cs = this;
var selectedZipCodes = $( '#selectedZipCodes' ).DataTable().data().toArray();
var tableData1 = SQLike.q( {
Unpack : selectedZipCodes,
Columns : ['zipCode','zipCode', 'grayed']
} );
$("#selectedZipCodes th:first-child").css("width","20px");
return tableData1.length>0 ? JSON.stringify(tableData1) : "";
},
getTriggeringEvent:function() {
var cs = this;
if(cs.data.moveComplete){
return "moveEvent";
}else{
return "initial";
}
},
//Method to update the Provider Count
getProvidersCountForSelZipCodes:function() {
var cs = this;
createTemplateJs.updatePatientCountAjax("/ppmProviderCountForPatientZipCodes", "&selectedZipCodes="
+ cs.getSelectedZipCodesData() );
cs.data.moveComplete = false;
}
});