jQuery.namespace('lexisnexis.component');
lexisnexis.component.patientprofile = lexisnexis.component.Table.extend({
data : {
splitBy : ",",
patientDetailTableId : '#patient_profile_measures_table'
},
ready : function() {
var cs = this;
try {
cs.data.isPatientProfile = $("#ln_isPatientProfileScreenFlag").val() ;
//cs.callWebservice();
cs.registerApplyButtonChange(cs);
// cs.onDataSetChange();
//cs.populatPatientSummaryTotals(cs);
LN.getPage().registerEvent(EVENT_TYPES.APPLY_BUTTON_CLICK,
cs, cs.registerApplyButtonChange);
}catch (err) {
LN.debug("error in datatable" + err);
}
},
registerApplyButtonChange : function(cs) {
cs.getClientParameters(cs);
cs.callWebservice();
},
callWebservice: function(){
var cs= this;
var queryString = window.location.search;
var id = LN.getParameterByName("id");
var patientName = escape(LN.getParameterByName("patientName"));
var patientId = LN.getParameterByName("patientId");
var ajaxURL = [LN.getContextPath()+"/patientProfileMemberKey?id="+id + "&selDataSet=" +$('#ln_topmenu_dataset').attr('datasetkey')];
var updatepatient = null;
updatepatient = $.ajax({
'url': ajaxURL,
'contentType': 'application/json',
'dataType': 'json',
'method': 'post',
'data': JSON.stringify({
"selDataSet":$('#ln_topmenu_dataset').attr('datasetkey')
}),
'success': function(data, textStatus, jqXHR) {
try {
var patientProfileJson = JSON.stringify(data);
var patientMemberMemberCount = data.patientProfileMemberKeyResponseDTO.patientMemberCount;
var patientName = data.patientProfileMemberKeyResponseDTO.patientName;
var policyHolderId = data.patientProfileMemberKeyResponseDTO.policyHolderId;
cs.populatPatientDemographics(cs);
$('#ln_patientName').html(patientName);
$('#ln_patientProfileMainDiv').removeClass("ln-display-none");
if(parseInt(patientMemberMemberCount) > 0){
LN.hideAjaxIndicator($('#ln_patientProfileMainDiv'));
$('#ln_patientProfileMainDiv').show();
$('#patientProfileErrordiv').hide();
}else {
$('#ln_patientProfileMainDiv').hide();
$('#patientProfileErrordiv').show();
}
} catch(err) {
LN.debug("error ="+err);
}
},
'beforeSend' : function() {
LN.showAjaxIndicator("#ln_patientProfileMainDiv");
LN.showAjaxIndicator("#patientProfileErrordiv");
},
'complete':function() {
LN.hideAjaxIndicator("#ln_patientProfileMainDiv");
LN.hideAjaxIndicator("#patientProfileErrordiv");
},
'error': function(jqXHR, textStatus, errorThrown) {
}
});
},
getPatientDetails : function() {
var cs = this;
$.ajax({
url : LN.getContextPath()+'/getPatientProfile',
data : {
},
type : "POST",
success : function(data) {
}
});
},
populatPatientSummaryTotals: function(cs) {
$.ajax({
beforeSend: function() {
LN.showAjaxIndicator("#patient_profile_summary_total");
},
url: "getPatientProfileSummaryTotals",
data: {
},
method: 'POST',
dataType: 'json',
success: function(response) {
cs.colorCodeTotalsTable(cs, response);
var summaryTotalsTemplate = $("#patient_profile_summary_total_template").html();
var summaryTotalsHtml = Mustache.to_html(summaryTotalsTemplate, response);
$("#patient_profile_summary_total").html(summaryTotalsHtml);
$('#ln_patient_profile_totalCost').html(formatUtil.formatNumber(parseInt(response.totalCost)));
$('#ln_patient_profile_benchmarkCost').html(formatUtil.formatNumber(parseInt(response.benchmarkCost)));
$('#ln_patient_profile_savings').html(formatUtil.formatNumber(parseInt(response.potentialSavings)));
//$('#filteredProviderCount').text(response.providerCount);
},
error : function(err){
$('#patient_profile_summary_total').html('<span style="color:red">Error: Data is currently unavailable.</span>');
},
complete: function(data){
LN.hideAjaxIndicator("#patient_profile_summary_total");
}
});
},
populatPatientPCPInfo: function(cs) {
$.ajax({
beforeSend: function() {
LN.showAjaxIndicator("#patient_profile_pcp");
},
url: "getPatientProfilePCPInfo",
data: {
},
method: 'POST',
dataType: 'json',
success: function(response) {
cs.colorCodeTotalsTable(cs, response);
var summaryTotalsTemplate = $("#patient_profile_pcp_template").html();
var summaryTotalsHtml = Mustache.to_html(summaryTotalsTemplate, response);
$("#patient_profile_pcp").html(summaryTotalsHtml);
},
error : function(err){
$('#patient_profile_pcp').html('<span style="color:red">Error: Data is currently unavailable.</span>');
},
complete: function(data){
LN.hideAjaxIndicator("#patient_profile_pcp");
}
});
},
populatPatientDemographics: function(cs) {
$.ajax({
beforeSend: function() {
LN.showAjaxIndicator("#patient_profile_demographics");
},
url: "getPatientProfileDemographics",
data: {
},
method: 'POST',
dataType: 'json',
success: function(response) {
if(response.policyHolderId != null){
var summaryTotalsTemplate = $("#patient_profile_demographics_template").html();
var summaryTotalsHtml = Mustache.to_html(summaryTotalsTemplate, response);
$("#patient_profile_demographics").html(summaryTotalsHtml);
cs.populatPatientSummaryTotals(cs);
cs.initpatientDetailMeasures(cs);
cs.populatPatientPCPInfo(cs);
}else{
$('#ln_patientProfileMainDiv').hide();
$('#patientProfileErrordiv').show();
}
},
error : function(err){
$('#patient_profile_demographics').html('<span style="color:red">Error: Data is currently unavailable.</span>');
},
complete: function(data){
LN.hideAjaxIndicator("#patient_profile_demographics");
}
});
},
populatPatientGetMeasures: function(cs) {
$.ajax({
beforeSend: function() {
LN.showAjaxIndicator("#patient_profile_measures");
},
url: "getPatientProfileMeasures",
data: {
},
method: 'POST',
dataType: 'json',
success: function(response) {
var summaryTotalsTemplate = $("#patient_profile_measures_template").html();
var summaryTotalsHtml = Mustache.to_html(summaryTotalsTemplate, response);
$("#patient_profile_measures").html(summaryTotalsHtml);
},
error : function(err){
$('#patient_profile_measures').html('<span style="color:red">Error: Data is currently unavailable.</span>');
},
complete: function(data){
LN.hideAjaxIndicator("#patient_profile_measures");
}
});
},
initpatientDetailMeasures: function(cs) {
var cs = this;
LN.debug("initializeTable called");
var tableid = "patient_profile_measures_table";
$(cs.data.patientDetailTableId).dataTable().fnDestroy();
cs.data.table = $('#patient_profile_measures_table').dataTable({
'scrollY' : '200px',
"sScrollX" : "100%",
"sScrollXInner" : "100%",
'scrollCollapse' : false,
"iDisplayLength" : 100,
'dom' : 'rt',
"bLengthChange" : false,
"autoWidth" : false,
"processing" : false,
"serverSide" : true,
'responsive' : true,
"bAutoWidth" : true,
"ordering" : true,
"order" : [
[ 0, "asc"]
],
"aoColumns" : [ {
sWidth : '50%'
}, {
sWidth : '50%'
}],
'ajax' : {
"url" : LN.getContextPath()+'/getPatientProfileMeasures',
"type" : "POST",
"data" : function ( d ) {
return $.extend( {}, d, {
'columnNames': ["measureCategory","measureName"],
'dataSetId':$('#ln_topmenu_dataset').attr("datasetkey")
} );
},
"dataType" : "json",
'beforeSend' : function(xhr) {
xhr.setRequestHeader('X-TransactionID', LN.TRANSACTION_ID);
cs.handleBeforeAjaxLoad(cs.data.patientDetailTableId);
},
'complete' : function() {
cs.handleAfterAjaxLoad(cs.data.patientDetailTableId);
$('#patient_profile_measures_table_wrapper').removeClass();
}
},
"fnDrawCallback" : function(oSettings) {
cs.addGotoPageComponentPPM(tableid, tableid+"_gotobtn",tableid+"_gototxt",tableid+"_gotoerror");
cs.removeSecondarySortingHeaderColor(oSettings,cs.data.summaryTableId,2);
$('#compliancecount').text(oSettings._iRecordsTotal);
}
});
},
getClientParameters: function(cs){
$.ajax({
url: LN.getContextPath()+'/getOverallefficiencyParameters',
method: 'POST',
async: true,
cache:true,
dataType : "json",
success: function(response){
//cs.clearData(cs);
if(response){
_.each(response, function(resp) {
if(resp.name==='PPM_OVERALL_EFFICIENCY_HIGH'){
cs.data.overallEfficiencyHigh=resp.value;
}else if(resp.name==='PPM_OVERALL_EFFICIENCY_LOW'){
cs.data.overallEfficiencyLow=resp.value;
}
cs.data.efficiencyIndex="0.0";
});
}
},
error: function(data){
cs.clearData(cs);
cs.handleError(cs);
},
complete: function(){
// cs.stopLoader();
}
});
}
});