/**
* This object will handle all the episode exclusion functionalities
*
* @class lexisnexis.component.exclusionsEpisodes
*/
jQuery.namespace('lexisnexis.component');
lexisnexis.component.ExclusionsEpisodes = lexisnexis.component.Table
.extend({
data : {
defaultOrder : [],
episodesOverallEfficiencyLow : 0,
episodesOverallEfficiencyHigh : 0,
episodesTableId : "#exclusions_episodes",
modalId : "#ln_exclusionModal",
delay : (function(){
var timer = 0;
return function(callback, ms){
clearTimeout (timer);
timer = setTimeout(callback, ms);
};
})()
},
/**
* initialize the table and register for functionality
*
* @method ready
*/
ready : function() {
var cs = this;
try {
/*cs.setDefaultOrder();
cs.setDefaultColumnsPref();
cs.data.tableOrder = cs.data.defaultOrder;*/
//cs.data.tableOrder.splice(0, 1);
//cs.tableRedraw();
//cs.getEpisodesExclusionEfficiencyValues();
//cs.initializeTable();
//cs.episodesCheckBoxes();
//cs.clearSelections();
//cs.registerExclusionsEpisodesSearch();
// cs.resetColReorder();
// cs.fixColumns();
} catch (err) {
LN.debug("error "+err);
}
}//,
// setDefaultOrder: function() {
// var cs=this;
// var arr = cs.data.defaultTablePreferences.split(",");
// for(var i=0;i<arr.length;i++) {
// cs.data.defaultOrder[i]=i;
// }
// },
// fixColumns: function() {
// var cs=this;
// var fc=new $.fn.dataTable.FixedColumns( cs.data.table, {
// leftColumns: 1
// } );
// fc.fnUpdate();
//
// },
//
// tableRedraw: function(){
// var cs=this;
// // as usual IE is special... :-/
// var timo = 200;
// var IEversion = cs.detectIE();
// if (IEversion !== false) { timo = 500; };
// $("#ln_exclusionModal").on('show.bs.modal', function (e) {
// setTimeout(function() {
// //alert(IEversion);
// $('#exclusions_patients').dataTable().fnAdjustColumnSizing();
// $('#ln_clearExclusionsBtn').prop('disabled',true);
// //$('#exclusions_patients').dataTable().fnDraw();
// },timo);
//
// });
//
// $('#patienttab').on('click', function (e) {
// $('#div_excludeEpisodesClear').css('display','none');
// $('#div_excludeEpisodesSearch').css('display','none');
// $('#div_excludeEpisodesRemove').css('display','none');
// $('#div_excludePatientsClear').css('display','');
// $('#div_excludePatientsSearch').css('display','');
// $('#div_excludePatientsRemove').css('display','');
// setTimeout(function() {
// $('#exclusions_patients').dataTable().fnAdjustColumnSizing();
// //$('#exclusions_patients').dataTable().fnDraw();
// }, 0);
// });
// $('#episodetab').on('click', function (e) {
// $('#div_excludePatientsClear').css('display','none');
// $('#div_excludePatientsSearch').css('display','none');
// $('#div_excludePatientsRemove').css('display','none');
// $('#div_excludeEpisodesClear').css('display','');
// $('#div_excludeEpisodesSearch').css('display','');
// $('#div_excludeEpisodesRemove').css('display','');
// setTimeout(function() {
// $('#exclusions_episodes').dataTable().fnAdjustColumnSizing(); // needed to lock 1st column as well.
// $('#exclusions_episodes').dataTable().fnDraw();
// }, 0);
// });
// },
//
// // temp method for defect #530 of sprint 5 - probably will need to be removed when the functionality is added.
// // this really should be a button at the bottom of page and not a tab!
// clearSelections: function() {
// $('#cleartab').mouseover(function(){
// $(this).css('color', '#777');
// $(this).css('cursor', 'default');
// });
// },
//
// // toggle "Clear Exclusions" button
// episodesCheckBoxes : function () {
//
// $("#ln_exclusionsEpisodes_clear_sel").click(function(event){
// $('.episode-chk-exclusions').each(function() {
// this.checked = false;
// $('#exclusionsEpisodesSelectAll').prop('checked',false);
// $('#ln_exclusionsEpisodes_clear_sel').attr('disabled','disabled');
// $('#ln_clearExclusionsEpisodesBtn').attr('disabled','disabled');
// });
// });
//
// // select all checkbox clicked
// $("#exclusions_episodes_wrapper .selectall").click(function(event){
// if(this.checked) {
// $('.episode-chk-exclusions').each(function() {
// this.checked = true;
// $('#ln_exclusionsEpisodes_clear_sel').removeAttr('disabled');
// $('#ln_clearExclusionsEpisodesBtn').removeAttr('disabled');
//
// });
//
// }else{
// $('.episode-chk-exclusions').each(function() {
// this.checked = false;
// $('#ln_exclusionsEpisodes_clear_sel').attr('disabled','disabled');
// $('#ln_clearExclusionsEpisodesBtn').attr('disabled','disabled');
//
// });
// }
// });
//
//// $('.episode-chk-exclusions').change(function(){
//// $("#exclusions_episodes_wrapper .selectall").prop('checked', false);
//// });
////
//// $('.chk-exclusions').click(function(){
//// var len1 = $("#ln_Exclusions input:checkbox:checked").length;
//// if ( len1 > 0 ){
//// $('#ln_clearExclusionsBtn').prop('disabled',true); // set to true for now as per story #229. Change to false in future
//// }else{
//// $('#ln_clearExclusionsBtn').prop('disabled',true);
//// }
//// });
// },
//
// episodeColorCodeTableDetails: function(cs,data){
// var efficiencyLow=parseFloat(cs.data.episodesOverallEfficiencyLow);
// var efficiencyHigh=parseFloat(cs.data.episodesOverallEfficiencyHigh);
// var dataVal=parseFloat(data);
//
// //LN.debug("Inside Color Coding: " + dataVal);
// if(dataVal<=efficiencyLow){
// return '<div class="ln-underutilization_color ln-insetShadowYellow ln-shadowEfficiency ln-goto-patientList" ><span class="fa fa-chevron-down ln-faRight"></span>'
// +data+'</div>';
//
// }else if(dataVal>efficiencyHigh){
// return '<div class="ln-overutilized_color ln-insetShadowRed ln-shadowEfficiency ln-goto-patientList" ><span class="fa fa-chevron-up ln-faRight"></span>'
// +data+'</div>';
//
// }else if(dataVal<=efficiencyHigh && dataVal>efficiencyLow){
// return '<div class="ln-expected_color ln-insetShadowGreen ln-shadowEfficiency ln-goto-patientList" ><span class="fa fa-check ln-faRight"></span>'
// +data+'</div>';
// }
// },
//
// getEpisodesExclusionEfficiencyValues : function() {
// var cs = this;
//
// $
// .ajax({
// cache : false,
// 'url' : LN.getContextPath() + "/getExclusionEfficiencyValues",
// //'dataType' : 'json',
// 'method' : 'post',
// 'data' : {},
// 'success' : function(data, textStatus, jqXHR) {
// try {
// //LN.debug('Data: ' + data);
// var arr = data.split('|');
//
// //LN.debug('High:' + arr[0]);
// //LN.debug('Low:' + arr[1]);
// cs.data.episodesOverallEfficiencyHigh = arr[0];
// cs.data.episodesOverallEfficiencyLow = arr[1];
//
// cs.initializeTable();
// cs.episodesCheckBoxes();
//
// } catch (err) {
// LN.debug("Error in getting episode exclusion efficiency values: "
// + err);
// }
// },
// 'beforeSend' : function(xhr) {
// xhr.setRequestHeader('X-TransactionID', LN
// .getPage().getTransactionID());
// },
// 'complete' : function() {
// //LN.debug('Completed');
// LN.hideOpaqueAjaxIndicator($('.ln-viewpane'));
// },
// 'error' : function(jqXHR, textStatus, errorThrown) {
// LN.debug('Error Thrown' + textStatus);
// }
// });
// // End Dynamic update
// },
//
// registerExclusionsEpisodesSearch: function() {
// var cs=this;
// $("#ln_exclusionEpisodes_grid_search").on('keyup',function () {
// var searchData=this.value.trim().toUpperCase();
//
// cs.data.delay(function(){
//
// if(searchData.trim().length>=3) {
//
// var table = $('#exclusions_episodes').DataTable();
//
// var episodeName = "";
//
// var numRows = table.rows(function (idx, data, node)
// {
// var rowIndex = idx;
// var rowNode = $('#exclusions_episodes').find('tbody tr:eq(' + rowIndex +')').get(0);
// episodeName = $(rowNode).find(".td_2").text().toUpperCase();
//
// if (episodeName.search(searchData) >= 0)
// {
// rowNode.style.display = '';
// }
// else
// {
// rowNode.style.display = 'none';
// }
//
// });
// }
// else if (searchData.trim().length==0)
// {
// var table = $('#exclusions_episodes').DataTable();
//
// var numRows = table.rows(function (idx, data, node)
// {
// var rowIndex = idx;
// var rowNode = $('#exclusions_episodes').find('tbody tr:eq(' + rowIndex +')').get(0);
// rowNode.style.display = '';
// });
// }
// }, 1000 );
// });
// },
//
// initializeTable : function() {
// var cs = this;
// //LN.debug("initializeTable called for exclusion Episodes tables");
// $(cs.data.episodesTableId).dataTable().fnDestroy();
// cs.data.table = $(cs.data.episodesTableId)
// .dataTable(
// {
// "paging": false,
// "info": false,
// "bsort": true,
// "scrollY" : "297",
// "sScrollX" : true,
// "bScrollCollapse" : false,
// "bFilter" : false,
//
// "dom": 'R<"top"f>rt<"bottom"ilp><"clear">',
// "processing" : false,
// "serverSide" : true,
// "searching": false,
// "bResponsive" :false,
// "ordering" : false,
// "bDeferRender" : true,
//
// "ajax" : {
// "cache": false,
// "url" : LN.getContextPath()+'/getExclusionEpisodeList',
// "type" : "POST",
// "dataType" : "json",
// "data" : {},
// 'beforeSend': function(xhr) {
// //LN.debug("beforeSend");
// xhr.setRequestHeader('X-TransactionID', LN.TRANSACTION_ID);
// cs.handleBeforeAjaxLoad(cs.data.episodesTableId);
// },
// 'complete' : function() {
// //LN.debug("Get Episode Exclusion complete");
// cs.handleAfterAjaxLoad(cs.data.episodesTableId);
// setTimeout(function(){
// cs.data.table.fnAdjustColumnSizing(false);
// },200);
//
// $("input.episode-chk-exclusions:checkbox").click(function()
// {
// if (!$("input.episode-chk-exclusions:checkbox").is(":checked"))
// {
// $('#exclusionsEpisodesSelectAll').prop('checked',false);
// $('#ln_exclusionsEpisodes_clear_sel').attr('disabled','disabled');
// $('#ln_clearExclusionsEpisodesBtn').attr('disabled','disabled');
// }
// else
// {
// $('#ln_exclusionsEpisodes_clear_sel').removeAttr('disabled');
// $('#ln_clearExclusionsEpisodesBtn').removeAttr('disabled');
// }
// });
//
// },
// "dataFilter" : function(json,type){
// var obj = jQuery.parseJSON(json);
// return json;
// }
// },
//
// "columnDefs": [
// { //checkbox col
// "render" : function(data, type, row) {
// return '<input class="control-label chk-exclusions episode-chk-exclusions" type="checkbox" value="' +data+ '">';
// },
// "targets" : [ 0 ]
// },
// { // episode description
// "render" : function(data, type, row) {
// return '<a href="#" class="text-left">' +data+ '</a>';
//
// },
// "targets" : [ 1 ],
// "sClass":'text-center ln-nowrap td_2'
// },
// { // Severity
// "targets" : [ 2 ],
// "sClass":'text-center ln-nowrap'
// },
// { // Patient Risk
// "render" : function(data, type, row) {
// return cs.episodeColorCodeTableDetails(cs,data);
// },
// "targets" : [3 ],
// "sClass":'text-center'
// },
// { // efficiency
// "render" : function(data, type, row) {
// return cs.episodeColorCodeTableDetails(cs,data);
// },
// "targets" : [4 ]
// },
// { // Case weight
// "render" : function(data, type, row) {
// return cs.episodeColorCodeTableDetails(cs,data);
// },
//
// "targets" : [5 ],
// "sClass":'text-center'
// },
// { // patients name
// "targets" : [ 6 ],
// "sClass" : 'ln-nowrap'
// },
// { //Responsible provider
// "targets" : [ 7 ],
// "sClass" : 'ln-nowrap'
// },
// { //Begin Date
// "targets" : [ 8 ],
// "sClass" : 'ln-nowrap text-center'
// },
// { //End Date
// "targets" : [ 9 ],
// "sClass" : 'ln-nowrap text-center'
// },
// { //Duration
// "targets" : [ 10 ],
// "sClass" : 'ln-nowrap text-center'
// },
// { //Admits
// "targets" : [ 11 ],
// "sClass" : 'ln-nowrap text-center'
// }
//
// ]
//
// }
// );
// // new $.fn.dataTable.FixedHeader( cs.data.tableId );
//
//
//// var fc = new $.fn.dataTable.FixedColumns( cs.data.table,{
//// leftColumns : 2
//// });
//
//
// }
});