gerd
11/8/2016 - 1:12 PM

episode_list.js

/**
 * This object will handle all the EpisodeList functionalities
 * 
 * @class lexisnexis.component.ETGList
 */

jQuery.namespace('lexisnexis.component');
lexisnexis.component.EpisodeList = lexisnexis.component.Table
        .extend({
            data : {
            	defaultEpisodeStartingRow: 0,
            	gridSearchCount: 0,
            	exclusionArray: [],            	
            	searchFieldId : '#ln_episode_grid_search',
            	previousVal: '',
            	summaryTableId : '#ln_summary_episode_list',
  		        detailTableId : '#ln_detail_episode_list',
                defaultOrder : [],
                firstTime: true,
                detailTableInitialized: false,
                saveId : '#episodelistTable_save',
		        resetId : '#episodelistTable_reset',
                summaryViewName: "Summary View",
                detailsViewName: "Detail View",
                summaryContainer: "#ln_summary_episode_list_container",
                detailsContainer: "#ln_detail_episode_list_container",
                episodeListTotalsUrl: "getEpisodeListTotals" ,
                baseUrl: "getEpisodeListSummary" ,
                detailsGridColumnId: '#ln_episode_dtl_grid',
                summaryGridColumnId: '#ln_episode_grid',
                defaultSortColumn_summary : "Total Variance",
                defaultSecondarySortColumn_summary : "Patient Name",
                defaultSortColumn_detail :"Total Variance",
                defaultSecondarySortColumn_detail : "Patient Name",
				GET_EXCLUSION_COUNT_METHOD : "getEpisodeListExclusionCount",
				classhideColumn:"ln-hide-column",
				SEND_EXCLUDED_EPISODES_METHOD : "excludeEpisodesFromEpisodeList",
	            GET_PROVIDER_COUNT_METHOD: "getProviderCountForGroup",
				sessionExclusionsCount : 0,
                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;
                cs.data.isProviderProfile = $("#ln_isProfileScreenFlag").val() ;

                cs.getExclusionCount();               
                cs.populateTotalsGrid(cs);
                cs.initializeSummaryTable();
                //cs.initializeDetailsTable();
                cs.registerViewBy();
                cs.registerViewAll();
                //validateSearch(cs, cs.data.searchFieldId);
                cs.registerSearch();
                cs.registerButtonActions();
            	cs.displayHelpPopOver();
            	cs.displayHelpDialog();
            	cs.registerViewByUtilization() ;
            	//cs.updateUtilization() ;
            	LN.getPage().registerEvent(EVENT_TYPES.APPLY_BUTTON_CLICK,
                        cs, cs.populateTotalsGrid);   
                LN.getPage().registerEvent(EVENT_TYPES.APPLY_BUTTON_CLICK,
                        cs, cs.reloadGrid); 
                $(cs.data.saveId).click(function(e) {
                    //cs.saveColumnOrdering();
                });
                //$("#ln_episode_grid_search").placeholder();     
                if ( cs.data.isProviderProfile === "true" ) {
    	        	LN.getPage().checkPCPProviderProfile();
                	$(".fa-eye").hide();
                	$(".ln-export-icon").hide();
                }
                
            },
            
            /* added for patient profile screen  */
            getPatientProfileDetails : function(){ 
            	$('.patientProfileDetails').on('click', function(e){
                    if($(this).attr('patientName')){
    	            	 var patientProfileName = $(this).attr('patientName');
    	            	 var patientId = $(this).attr('patientId');
    	            }
    	            e.preventDefault();
    	            
    	            var fromScreen = "EL";
    	            
                    if ( $("#ln_isProfileScreenFlag").val() === "true" )
                    {
                    	fromScreen = "PPEL";
                    }
    	            
    	            $.ajax({
    					url : LN.getContextPath()+'/updatePatientProfileDetails',
    					data : {
    						"patientName" : patientProfileName,
    						"fromScreen" : fromScreen,
    						"patientId" : patientId  
    					},
    					type : "POST",
    					success : function(data) {
    						location.href = LN.getContextPath()+'/patientprofile';
    					}
    				  });
    	    	});
    	    },
            
              createEpisodeArrayValue: function (episodeDescription, severity, patientRisk, caseWeight, efficiency, patientName, responsibleProvider, beginDate, endDate, duration, numofAdmits, episodeKey)
            {
            	return {episodeDescription : episodeDescription, severity : severity, patientRisk : patientRisk, caseWeight : caseWeight, efficiency : efficiency, patientName : patientName, responsibleProvider : responsibleProvider, beginDate : beginDate, endDate : endDate, duration : duration, numofAdmits : numofAdmits, episodeKey : episodeKey};
            },
            pushEpisodeToArray: function (cs, episodeDescription, severity, patientRisk, caseWeight, efficiency, patientName, responsibleProvider, beginDate, endDate, duration, numofAdmits, episodeKey)
            {
            	//LN.debug('Length of array before: ' + cs.data.exclusionArray.length);
    			//LN.debug('Pushing - ' + episodeDescription + ' : ' + severity + ' : ' +  patientRisk + ' : ' + caseWeight + ' : ' + efficiency + ' : ' + patientName + ' : ' + responsibleProvider + ' : ' + beginDate + ' : ' + endDate + ' : ' + duration);
                if (!(cs.isEpisodeInArray(cs, episodeDescription, severity, patientRisk, caseWeight, efficiency, patientName, responsibleProvider, beginDate, endDate, duration, numofAdmits, episodeKey)))
            	{
                	cs.data.exclusionArray.push(cs.createEpisodeArrayValue(episodeDescription, severity, patientRisk, caseWeight, efficiency, patientName, responsibleProvider, beginDate, endDate, duration, numofAdmits, episodeKey));
            	}
            	//LN.debug('Length of array after: ' + cs.data.exclusionArray.length);
            	//LN.debug('Pushed Data' + cs.data.exclusionArray[0].episodeDescription + ' : ' + cs.data.exclusionArray[0].severity + ' : ' +  cs.data.exclusionArray[0].patientRisk + ' : ' + cs.data.exclusionArray[0].caseWeight + ' : ' + cs.data.exclusionArray[0].efficiency + ' : ' + cs.data.exclusionArray[0].patientName + ' : ' + cs.data.exclusionArray[0].responsibleProvider + ' : ' + cs.data.exclusionArray[0].beginDate + ' : ' + cs.data.exclusionArray[0].endDate + ' : ' + cs.data.exclusionArray[0].duration);

            },
            removeEpisodeFromArray: function (cs, episodeDescription, severity, patientRisk, caseWeight, efficiency, patientName, responsibleProvider, beginDate, endDate, duration, numofAdmits, episodeKey)
            {
        		var arrayLocation = -1;
        		
        		for (var i=0; i < cs.data.exclusionArray.length; i++)
    			{
        			if (	(cs.data.exclusionArray[i].episodeDescription == episodeDescription) &&
        					(cs.data.exclusionArray[i].severity == severity) &&
        					(cs.data.exclusionArray[i].patientRisk == patientRisk) &&
        					(cs.data.exclusionArray[i].caseWeight == caseWeight) &&
        					(cs.data.exclusionArray[i].efficiency == efficiency) &&
        					(cs.data.exclusionArray[i].patientName == patientName) &&
        					(cs.data.exclusionArray[i].responsibleProvider == responsibleProvider) &&
        					(cs.data.exclusionArray[i].beginDate == beginDate) &&
        					(cs.data.exclusionArray[i].endDate == endDate) &&
        					(cs.data.exclusionArray[i].episodeKey == episodeKey) &&
        					(cs.data.exclusionArray[i].numofAdmits == numofAdmits) &&
        					(cs.data.exclusionArray[i].duration == duration))
    				{
        				arrayLocation = i;
        				break;
    				}
    			}
        		
            	if (arrayLocation >= 0)
        		{
                	cs.data.exclusionArray.splice(arrayLocation, 1);        		
        		}
            },
            isEpisodeInArray: function(cs, episodeDescription, severity, patientRisk, caseWeight, efficiency, patientName, responsibleProvider, beginDate, endDate, duration, numofAdmits, episodeKey)
            {
        		var arrayLocation = -1;
        		
        		for (var i=0; i < cs.data.exclusionArray.length; i++)
    			{
        			//LN.debug('Compare 2 - ' + cs.data.exclusionArray[i].episodeDescription + ' : ' + cs.data.exclusionArray[i].severity + ' : ' +  cs.data.exclusionArray[i].patientRisk + ' : ' + cs.data.exclusionArray[i].caseWeight + ' : ' + cs.data.exclusionArray[i].efficiency + ' : ' + cs.data.exclusionArray[i].patientName + ' : ' + cs.data.exclusionArray[i].responsibleProvider + ' : ' + cs.data.exclusionArray[i].beginDate + ' : ' + cs.data.exclusionArray[i].endDate + ' : ' + cs.data.exclusionArray[i].duration + ' : ' + cs.data.exclusionArray[i].episodeKey + ' : ' + cs.data.exclusionArray[i].numofAdmits );
        			if (	(cs.data.exclusionArray[i].episodeDescription == episodeDescription) &&
        					(cs.data.exclusionArray[i].severity == severity) &&
        					(cs.data.exclusionArray[i].patientRisk == patientRisk) &&
        					(cs.data.exclusionArray[i].caseWeight == caseWeight) &&
        					(cs.data.exclusionArray[i].efficiency == efficiency) &&
        					(cs.data.exclusionArray[i].patientName == patientName) &&
        					(cs.data.exclusionArray[i].responsibleProvider == responsibleProvider) &&
        					(cs.data.exclusionArray[i].beginDate == beginDate) &&
        					(cs.data.exclusionArray[i].endDate == endDate) &&
        					(cs.data.exclusionArray[i].episodeKey == episodeKey) &&
        					(cs.data.exclusionArray[i].numofAdmits == numofAdmits) &&
        					(cs.data.exclusionArray[i].duration == duration))
    				{
        				arrayLocation = i;
        				break;
    				}
    			}
        		
            	if (arrayLocation >= 0)
        		{
            		//LN.debug('Found one, index: ' + arrayLocation);
                	return true;        		
        		}
            	
            	return false;            	
            },
            checkedEpisode: function(cs, cbID, cbChecked, tableID)
            {
            	var checkBoxName = '#' + cbID;
            	var rowID = cbID.replace('checkBox_', '');
            	var rowNode = $(tableID).find('tbody tr:eq(' + rowID +')').get(0);
            	
       			var filter_val = $(checkBoxName).attr('filter_val_1');
            	
       			var filter_array = filter_val.split('|');
            	//LN.debug('TableID- ' + tableID);
            	//LN.debug('RowNode- ' + rowNode);
            	//LN.debug('cbChecked- ' + cbChecked);
            	//var tempPatientArray = patientArray;

                var episodeDescription = "";
                var severity = "";
                var patientRisk = "";
                var caseWeight = "";
                var efficiency = "";
                var patientName = "";
                var responsibleProvider = "";
                var beginDate = "";
                var endDate = "";
                var duration = "";
                var numofAdmits = "";
                var episodeKey = "";

        		episodeKey = filter_array[0];
        		episodeDescription = filter_array[2];
        		severity = filter_array[3];
        		patientRisk = filter_array[4];
        		caseWeight = filter_array[5];
        		efficiency = filter_array[6];
        		patientName = filter_array[7];
        		responsibleProvider = filter_array[8];
        		beginDate = filter_array[9];
        		endDate = filter_array[10];
        		duration = filter_array[11];
        		numofAdmits = filter_array[12];
                
                
//                var currentView=$('#ln_episodeList_viewBydesc').text(); 
//            	if(currentView ===cs.data.summaryViewName){
//            		episodeKey = $(checkBoxName).val();
//            		episodeDescription = $(rowNode).find(".td_1").html();
//            		severity = $(rowNode).find(".td_3").html();
//            		patientRisk = $(rowNode).find(".td_4").text();
//            		caseWeight = $(rowNode).find(".td_6").text();
//            		efficiency = $(rowNode).find(".td_5").text();
//            		patientName = $(rowNode).find(".td_2").html();
//            		responsibleProvider = $(rowNode).find(".td_10").html();
//            		beginDate = $(rowNode).find(".td_12").html();
//            		endDate = $(rowNode).find(".td_13").html();
//            		duration = $(rowNode).find(".td_14").html();
//            		numofAdmits = $(rowNode).find(".td_16").html();
//            	} else{
//            		episodeKey = $(checkBoxName).val();
//            		episodeDescription = $(rowNode).find(".td_1").html();
//            		severity = $(rowNode).find(".td_3").html();
//            		patientRisk = $(rowNode).find(".td_4").text();
//            		caseWeight = $(rowNode).find(".td_6").text();
//            		efficiency = $(rowNode).find(".td_5").text();
//            		patientName = $(rowNode).find(".td_2").html();
//            		responsibleProvider = $(rowNode).find(".td_14").html();
//            		beginDate = $(rowNode).find(".td_15").html();
//            		endDate = $(rowNode).find(".td_16").html();
//            		duration = $(rowNode).find(".td_18").html();
//            		numofAdmits = $(rowNode).find(".td_19").html();
//            	}

                if (cbChecked)
            	{
                	//LN.debug('Push to Array');
                    cs.pushEpisodeToArray(cs, episodeDescription, severity, patientRisk, caseWeight, efficiency, patientName, responsibleProvider, beginDate, endDate, duration, numofAdmits, episodeKey);
            	}
                else
            	{
                	//LN.debug('Remove From Array');
                    cs.removeEpisodeFromArray(cs, episodeDescription, severity, patientRisk, caseWeight, efficiency, patientName, responsibleProvider, beginDate, endDate, duration, numofAdmits, episodeKey);            
            	}         
                
         		if (cs.data.exclusionArray.length <= 0)
         		{
 					$('#ln_episode_clear_sel').attr('disabled','disabled');            							            		
 					$('#ln_episode_excl_sel').attr('disabled','disabled');            							            		
         		}
         		else
         		{
         			$('#ln_episode_clear_sel').removeAttr('disabled');
         			$('#ln_episode_excl_sel').removeAttr('disabled');
         		}                
            },
            setCheckBoxes: function(cs, tableID)
            {
            	var table = $(tableID).DataTable();

                var episodeDescription = "";
                var severity = "";
                var patientRisk = "";
                var caseWeight = "";
                var efficiency = "";
                var patientName = "";
                var responsibleProvider = "";
                var beginDate = "";
                var endDate = "";
                var duration = "";
                var numofAdmits = "";
            	var episodeKey = "";

            	
            	var numRows = table.rows(function (idx, data, node) 
            			{
            				var rowIndex = idx;
                			var rowNode = $(tableID).find('tbody tr:eq(' + rowIndex +')').get(0);
                        	//var checkBoxName = '#checkBox_' + idx;

                        	var currentView=$('#ln_episodeList_viewBydesc').text(); 
                        	if(currentView ===cs.data.summaryViewName){
                        		episodeKey = $(rowNode).find('input[type="checkbox"]').val().split('|')[0];
                        		episodeDescription = $(rowNode).find(".td_1").text();
                        		severity = $(rowNode).find(".td_3").html();
                        		patientRisk = $(rowNode).find(".td_4").text();
                        		caseWeight = $(rowNode).find(".td_6").text();
                        		efficiency = $(rowNode).find(".td_5").text();
                        		patientName = $(rowNode).find(".td_2").text();
                        		responsibleProvider = $(rowNode).find(".td_10").text();
                        		beginDate = $(rowNode).find(".td_12").html();
                        		endDate = $(rowNode).find(".td_13").html();
                        		duration = $(rowNode).find(".td_14").html();
                        		numofAdmits = $(rowNode).find(".td_16").html();
                        	} else{
                        		episodeKey = $(rowNode).find('input[type="checkbox"]').val().split('|')[0];
                        		episodeDescription = $(rowNode).find(".td_1").text();
                        		severity = $(rowNode).find(".td_3").html();
                        		patientRisk = $(rowNode).find(".td_4").text();
                        		caseWeight = $(rowNode).find(".td_6").text();
                        		efficiency = $(rowNode).find(".td_5").text();
                        		patientName = $(rowNode).find(".td_2").text();
                        		responsibleProvider = $(rowNode).find(".td_14").text();
                        		beginDate = $(rowNode).find(".td_15").html();
                        		endDate = $(rowNode).find(".td_16").html();
                        		duration = $(rowNode).find(".td_18").html();
                        		numofAdmits = $(rowNode).find(".td_19").html();
                        	}
                            
                			//LN.debug('Compare 1 - ' +episodeDescription + ' : ' + severity + ' : ' +  patientRisk + ' : ' + caseWeight + ' : ' + efficiency + ' : ' + patientName + ' : ' + responsibleProvider + ' : ' + beginDate + ' : ' + endDate + ' : ' + duration + ' : ' + episodeKey  + ' : ' + numofAdmits);
                            if (cs.isEpisodeInArray(cs, episodeDescription, severity, patientRisk, caseWeight, efficiency, patientName, responsibleProvider, beginDate, endDate, duration, numofAdmits, episodeKey))
                        	{
                            	var checkboxName = '#checkBox_' + idx;
                            	//LN.debug('Found one to check:' + checkboxName);
                            	$(tableID).find('tbody tr:eq(' + rowIndex +')').find('input[type="checkbox"]').prop('checked',true);
                            	$(checkboxName).prop('checked',true);
                        	}
            			});

            },            
            
            displayHelpPopOver:function(){
           		
           		$(document).on("click", "#ln_episode_totals_help", function () {
           	        var msg = 'Help Text needs to be added..';
           	        var title = 'Summary (Totals)';
           	        var placement = "left";
           	        contextHelp.popOver("#ln_episode_totals_help",title,msg,placement);
           	    });
           		
           		$(document).on("click", "#ln_episodetableHelp", function () {
           	        var msg = 'Help Text needs to be added..';
           	        var title ="Episode List";
           	        var placement = "left";
           	        contextHelp.popOver("#ln_episodetableHelp",title,msg,placement);
           	    });
           		
           	},
           	
           	
           	displayHelpDialog:function(){
           	
           	},
           	
           	displayErrorDialog:function(cs){
       	        var msg = 'You have exceeded the maximum number of episodes to be excluded. <br><br> Already excluded: ' + cs.data.sessionExclusionsCount + '<br> Currently selected: ' + cs.data.exclusionArray.length;
       	        var titleText = "Exceeded Exclude Limit (max 250)";  // pass in your title
           		$.growl({title : "",message : msg});           		
                
           	},

           	displaySuccessDialog:function(cs, numberExcluded){
       	        var msg = '';
       	        msg = numberExcluded + ' episode(s) have been excluded.';
       	        var titleText = "Episodes Excluded";  // pass in your title
           		$.growl({title : "",message : msg});           		
           	},
           	
           	populateTotalsGrid: function(cs){
            	$.ajax({
            		beforeSend: function(){
            			LN.showAjaxIndicator("#ln_episode_summary_table .table");
            		},
                	url: cs.data.episodeListTotalsUrl,
                	data: {'dataSetId':$('#ln_topmenu_dataset').attr("datasetkey"),
          		       'selDataSetRangeRiskColumnName':  $('#ln_topmenu_dataset_range_id').attr("riskColumnName"),
         		       'selDataSetRangeBegin':  $('#ln_topmenu_dataset_range_id').attr("beginDateKey"),
    				   'selDataSetRangeEnd':  $('#ln_topmenu_dataset_range_id').attr("endDateKey")},
                	method: 'POST',
                	dataType: 'json',
                	success: function(data){ 
                		cs.colorCodeTotalsTable(cs,data);
          			    data.episodeCount = numeral(data.episodeCount).format('0,0');
          			    data.admits = numeral(data.admits).format('0,0');
          			    data.totalCost = formatUtil.formatNumber(parseInt(data.totalCost));
          			    data.savings = formatUtil.formatNumber(parseInt(data.savings));
                		var template = $('#ln_episode_summary_table_template').html();
              		    var html = Mustache.to_html(template, data);
              		    $("#ln_episode_summary_table").html(html);
              		  $('#ln_episode_list_totalCost').html(data.totalCost);
              		  $('#ln_episode_list_savings').html(data.savings);
                	},
                	complete: function(data){
                		LN.hideAjaxIndicator("#ln_episode_summary_table .table");
                	}
                });
            },
            
           	/**
           	 * THis method will update the provider count and also trigger update of the grids
           	 */
           	updateUtilization: function(cs) {
        		LN.getPage().updateProviderCounts(true);          		
           	},
           	
           	/**
           	 * This function handles the "View By:" click event and reloads the table accordingly
           	 */
           			
           	registerViewBy: function(){
            	var cs=this;
            	
            	// sets default anchor on page load
            	setViewByAnchor();
            	
            	function setViewByAnchor() {
	            	// loop the ol list and set the anchor class to active for the selected view type
	            	_.each($('.ln-episodeList-viewBy-type a'),function(anchor){
	            		
	    				if( $("#ln_episodeList_viewBydesc").text() === $(anchor).text() ) {
	    					$(anchor).addClass('active');
	    				} else {
	    					$(anchor).removeClass('active');
	    				}
	            	});
            	}

            	$(".ln-episodeList-viewBy-type").on("click",function(e){
            		e.preventDefault();
            		var currentView = $("#ln_episodeList_viewBydesc").text();
	        		var selectedView = $(this).text();
            		
	        		
	        		if (currentView != selectedView ) {
	        			if (selectedView == "Summary View") {
	            			$(cs.data.summaryContainer).show();
			                $(cs.data.detailsContainer).hide();
	        			} else {
	            			$(cs.data.summaryContainer).hide();
			                $(cs.data.detailsContainer).show();
	        			}
	                	 
	                	// reset text to new selected view type
	                	$("#ln_episodeList_viewBydesc").text(selectedView);
	                	$('#ln_episodeList_viewBydescHidden').val(selectedView) ;
	        			
	        			if(selectedView == "Detail View" && !cs.data.detailTableInitialized){
		                	 cs.data.detailTableInitialized=true;
		                	 cs.initializeDetailsTable(cs);
		                }else{
		                	cs.reloadTableViews(cs, selectedView);
		                }
	                	
		        		// update active anchor 
		        		setViewByAnchor();
	        		}

            	});
            	
            
            },
           	
           	registerViewByUtilization: function(){
            	var cs=this;
            	//LN.debug("registerViewByUtilization");
            	$(".ln-episodeList-viewBy-utilization").on("click",function(){  
            		var currentUtil = $("#ln_episode_viewby_utilization").text();
            		var selectedUtil =$(this).text();
            		
            		if (selectedUtil != currentUtil) {
                		$('#ln_episode_viewby_utilization').text(selectedUtil);
                		//push the event for updating.
                		//update the provider count
                        var dataVal=JSON.stringify({'selUtilization': selectedUtil});
                        LN.ajaxPostJSON('', 'updateEpisodeUtilization', dataVal, cs.updateUtilization, cs);
                        
            		}

            	});
     
            	_.each($('.ln-episodeList-viewBy-utilization a'),function(anchor){
    				if($("#ln_episode_viewby_utilization").text() === $(anchor).text()){
    					$(anchor).addClass('active');
    				}else{
    					$(anchor).removeClass('active');
    				}				
    			}); 
 
            } , 
            
            
            
            registerSearch:function(){
            	var cs=this;
            	
            	$(cs.data.searchFieldId).on('keyup',function (e) {
            		var isValidSearch=true;
            		if (!isValidateSearch(e,cs.data.searchFieldId,true)) {
            			isValidSearch= false;
            			cs.data.previousVal = $(cs.data.searchFieldId).val();
        			}
            		 cs.data.providerId=this.value.toUpperCase();
                 	
                 	 cs.data.delay(function(){
                 		 if(isValidSearch && cs.data.gridSearchCount==0){
                 			if(isValidTextLength(cs,$(cs.data.searchFieldId).val(),3)){ 
                        	var currentView=$('#ln_episodeList_viewBydesc').text();                        	
                     		if(currentView ===cs.data.summaryViewName){
                     			cs.data.gridSearchCount++;
                        		$(cs.data.summaryTableId).DataTable().ajax.reload(function(data){
                        			cs.noDataCleanup(data.iTotalDisplayRecords);
                        		});
                    		}
	                     	else {
	                     		cs.data.gridSearchCount++;
	                     		$(cs.data.detailTableId).DataTable().ajax.reload(function(data){
	                     			cs.noDataCleanup(data.iTotalDisplayRecords);
	                     		});
	                     	}
                  	  }
                 	 }
         			 }, 1000 );
                 	
             });
            },
            

            reloadTableViews: function(cs,viewName){
            	cs.data.gridSearchCount=0;//reset search count
	        	if(viewName==cs.data.summaryViewName){
              		cs.data.tableSummary.fnReloadAjax(cs.data.baseSummaryUrl);
	        	}else{
              		cs.data.tableDetail.fnReloadAjax(cs.data.baseDetailsUrl);
	        	}
            },
            
            
            reloadGrid: function(cs){
            	cs.data.gridSearchCount=0;//reset search count
            	var episodeGridDesc=$('#ln_episodeList_viewBydesc').text();                        	
    	        	if(episodeGridDesc===cs.data.summaryViewName){
                  		cs.data.tableSummary.fnReloadAjax(cs.data.baseSummaryUrl);
            		}else{
                  		cs.data.tableDetail.fnReloadAjax(cs.data.baseDetailsUrl);
            		}
            		
            },
            

            
            registerViewAll: function() {
            	var cs = this;
            	$("#ln_episode_viewall").on("click","li a",function(e) {
            		e.preventDefault();
            		var selectText = $(this).text();
            		$("#ln_episode_viewall_id").html(selectText);
            	});
            },
            
            registerButtonActions: function() {
            	var cs = this;
            	
            	$('#ln_episode_excl_sel').on('click',function(e){
            		if ((cs.data.exclusionArray.length + cs.data.sessionExclusionsCount) <= 250)
            		{
                		cs.sendExcludedEpisodes();            			
            		}
            		else
        			{
            			cs.displayErrorDialog(cs);
        			}
            		
            	});
            	
            	$('#ln_episode_clear_sel').on('click',function(e){
            		$("input.activeChkBox:checkbox").attr('checked',false);
					$('#ln_episode_clear_sel').attr('disabled','disabled');            							            		
					$('#ln_episode_excl_sel').attr('disabled','disabled');
					cs.data.exclusionArray.length = 0;            		
            	});
            	
            	$('#ln_episode_view_by_etg').on('click',function(e){
           			location.href="etgList";
            	});
            },
            
            
            setDefaultOrder: function() {
            	var cs=this;
            	var arr = cs.data.defaultTablePreferences.split(",");
            	for(var i=0;i<arr.length;i++) {
            		cs.data.defaultOrder[i]=i;
            	}
            },
                       
            
            colorCodeTableDetails: function(cs,data , gotoCss){
            	var efficiencyLow=parseFloat(cs.data.overallEfficiencyLow);
           		var efficiencyHigh=parseFloat(cs.data.overallEfficiencyHigh);                 	        	 
    	        var dataVal=parseFloat(data);    	        
    	        var gotoCssClass = "" ; 
    	        if(isNaN(dataVal)){
    	        	dataVal=parseFloat("0");
    	        }	
    	        
    	        if(gotoCss){ 
    	        	gotoCssClass = ' ln-goto-patientList' ; 
    	        }
    	        
				if(dataVal<efficiencyLow){                        			
           			return '<div class="ln-underutilization_color ln-insetShadowYellow ln-shadowEfficiency ' +  gotoCssClass +  ' ln-grid-color-code" ><span class="fa fa-level-down ln-faRight"></span>'
               	        	 +data+'</div>';
           			
           		}else if(dataVal>efficiencyHigh){                        			
           			return '<div class="ln-overutilized_color ln-insetShadowRed ln-shadowEfficiency ' + gotoCssClass + ' ln-grid-color-code" ><span class="fa fa-level-up ln-faRight"></span>'
               	        	 +data+'</div>';
           			
           		}else if(dataVal<=efficiencyHigh && dataVal>=efficiencyLow){                        			
           			return '<div class="ln-expected_color ln-insetShadowGreen ln-shadowEfficiency ' + gotoCssClass + ' ln-grid-color-code" ><span class="fa fa-check ln-faRight"></span>'
               	        	 +data+'</div>';                        			
           		}
            },
            
            getExclusionCount : function() {
				var cs = this;

				$
						.ajax({
							cache : false,
							'url' : LN.getContextPath() + "/" + cs.data.GET_EXCLUSION_COUNT_METHOD,
							'dataType' : 'json',
							'method' : 'post',
							'data' : {},
							'success' : function(data, textStatus, jqXHR) {
								try {
									//LN.debug('Returned Exclusion Count=' + data);
									cs.data.sessionExclusionsCount = data;
									
								} catch (err) {
									// growl the error
									LN.debug("Error in getting patient exclusion count: "
											+ err);
								}
							},
							'beforeSend' : function(xhr) {
								xhr.setRequestHeader('X-TransactionID', LN
										.getPage().getTransactionID());
								cs.data.isInAjaxCall = true;
							},
							'complete' : function() {
								LN.hideOpaqueAjaxIndicator($('.ln-viewpane'));
							},
							'error' : function(jqXHR, textStatus, errorThrown) {
								cs.data.isInAjaxCall = false;
							}
						});
				// End Dynamic update
			},

            sendExcludedEpisodes : function() {
				var cs = this;
				var jsonString = JSON.stringify(cs.data.exclusionArray);
				//LN.debug("Json String:" + jsonString);
				$
						.ajax({
							cache : false,
							'url' : LN.getContextPath() + "/" + cs.data.SEND_EXCLUDED_EPISODES_METHOD,
							'dataType' : 'json',
							'method' : 'post',
							'data' : {"jsonData": jsonString},
							'success' : function(data, textStatus, jqXHR) {
								try {
									//LN.debug("Success on excluded episode");
					                cs.getExclusionCount();
								} catch (err) {
									// growl the error
									LN.debug("Error in sending excluded episodes: "
											+ err);
								}
							},
							'beforeSend' : function(xhr) {
								xhr.setRequestHeader('X-TransactionID', LN
										.getPage().getTransactionID());
								cs.data.isInAjaxCall = true;
							},
							'complete' : function() {
								LN.hideOpaqueAjaxIndicator($('.ln-viewpane'));
								var numberExcluded = cs.data.exclusionArray.length;
								cs.displaySuccessDialog(cs, numberExcluded);
								cs.data.exclusionArray.length = 0;
								LN.getPage().updateProviderCounts(true);
							},
							'error' : function(jqXHR, textStatus, errorThrown) {
								cs.data.isInAjaxCall = false;
							}
						});
				// End Dynamic update
			},
            
            initializeSummaryTable : function() {
                var cs = this;
                LN.debug("initializeSummaryTable called ");
                var prevColumnNamesArray=cs.getCurrentSummaryColumnNamesArray(cs.data.summaryTableId);
                $(cs.data.summaryContainer).show();
                $(cs.data.detailsContainer).hide();
                
                $(cs.data.summaryTableId).dataTable().fnDestroy();
                cs.data.tableSummary = $(cs.data.summaryTableId)
	                .dataTable(
                        {
                        	//"dom" : 'Rlfrt',
                        	"dom": 'R<"top"f>rt<"bottom"ilp><"clear">',
                        	scrollY: "300px",
                            scrollX: "true",
                            scrollCollapse: true,
                            "bFilter" : false,
                            "iTotalRecords" : "dataTableModel.iTotalRecords",
                            "iDisplayLength" : 100,
                            "processing" : false,
                            "serverSide" : true,
                            //"bAutoWidth" : false,
                            "bLengthChange" : true,
                            "bResponsive" :false,
                            "ordering" : true, 
                            "paging": true,
                            "pagingType": "simple_numbers",
                            "colReorder": {
                                "iFixedColumns": 3,
                                "fnReorderCallback": function() {
                                	 drillDownFilters.registerDrillDowns();
                                	 cs.getPatientProfileDetails();
                                },
                                realtime: true
                            },
                            "bDeferRender" : true,
                            "ajax" : {
                                "cache": false,
                                "url" :cs.data.baseUrl,
                                "type" : "POST",
                                "dataType" : "json",
                                "data" : function ( d ) {
                                	var columnNamesArray=cs.getCurrentSummaryColumnNamesArray(cs.data.summaryTableId);
                                    //LN.debug("data called");
                                    return $.extend( {}, d, {
                                    	 "columnNames":columnNamesArray.length>0?columnNamesArray:prevColumnNamesArray,
                                         "selDataSet":$('#ln_topmenu_dataset').attr('datasetkey'),
                                         'selDataSetRangeBegin':  $('#ln_topmenu_dataset_range_id').attr("beginDateKey"),
                         				 'selDataSetRangeEnd':  $('#ln_topmenu_dataset_range_id').attr("endDateKey"),
                         				 'selSubClientIds' : $('#ln_subClient_id').attr("data-key"),
                         				 'selBenchMark' : $('#ln_benchid').attr("data-key"),
                         				'selUtilization' : $('#ln_episode_viewby_utilization').text() ,  
                         				 'selDataSetRangeRiskColumnName':  $('#ln_topmenu_dataset_range_id').attr("riskColumnName"),
                         				 'currentView':'summary',
                         				 'searchProviderName':cs.data.providerId
                                    } ); },
                                'beforeSend': function(xhr) {
                                	cs.data.prevProviderId = cs.data.providerId;
                                	xhr.setRequestHeader('X-TransactionID', LN.TRANSACTION_ID);
					                cs.data.defaultEpisodeStartingRow = 0;                                    
                                	$('.DTFC_LeftHeadWrapper').css('display','none');
                                	$('.DTFC_LeftBodyWrapper').css('display','none');
                                    cs.handleBeforeAjaxLoad(cs.data.summaryTableId);
                                },
                                'complete' : function() {
 			                    	if(cs.data.gridSearchCount>0){
 			                        	cs.data.gridSearchCount--;
 			                        } 
 			                    	$('.DTFC_LeftHeadWrapper').css('display','block');
                                 	$('.DTFC_LeftBodyWrapper').css('display','block');
                                	 cs.handleAfterAjaxLoad(cs.data.summaryTableId);  
                                	
                                     setTimeout(function(){
                                     	cs.data.tableSummary.fnAdjustColumnSizing(false);
                                     },300);
                                    

                                	var IEver = cs.detectIE(); 
                                	if (IEver){
                                		// remove double scroll bar for IE only
                                		$('.DTFC_LeftBodyLiner').css('overflow','hidden');
                                	}
                                     

                                     if (cs.data.exclusionArray.length > 0)
                                 	{
 				            			$('#ln_episode_clear_sel').removeAttr('disabled');
 				            			$('#ln_episode_excl_sel').removeAttr('disabled');
                                 	}
                                     else
                                 	{
     									$('#ln_episode_clear_sel').attr('disabled','disabled');
     									$('#ln_episode_excl_sel').attr('disabled','disabled');                                	
                                 	}
 					            	$("input.activeChkBox:checkbox").click(function()
 			                    	{
 					            		if (!$("input.activeChkBox:checkbox").is(":checked"))
 					            		{
 				        					$('#ln_episode_clear_sel').attr('disabled','disabled');            							            		
 				        					$('#ln_episode_excl_sel').attr('disabled','disabled');            							            		
 					            		}
 					            		else
 					            		{
 					            			$('#ln_episode_clear_sel').removeAttr('disabled');
 					            			$('#ln_episode_excl_sel').removeAttr('disabled');
 					            		}
 										cs.checkedEpisode(cs, this.id, this.checked, cs.data.summaryTableId);
 			                    	});
 					                cs.data.defaultEpisodeStartingRow = 0;
 			                    	if(cs.data.gridSearchCount==0 && cs.data.prevProviderId!=cs.data.providerId){
 			                    		$(cs.data.searchFieldId).trigger('keyup');
 			                    	}
                                },
                                "dataFilter" : function(json,type){
                                	var obj = jQuery.parseJSON(json);
                                	cs.enableExport(obj);
                                	return json;
                                }
                            }, 
                            "order" : [
                                       [cs.getPreferencesIndex(cs.data.summaryDefaultTablePreferences  ,cs.data.defaultSortColumn_summary),"desc" ],
                                       [cs.getPreferencesIndex(cs.data.summaryDefaultTablePreferences  ,cs.data.defaultSecondarySortColumn_summary),"asc" ]
                                       ], 
                            "columnDefs": [
                                           {
                                        	 "width": "1%",
                                        	 "targets":0,
                                        	 "render" : function(data,type,row) {
                                        		// var newId = cs.data.defaultEpisodeStartingRow++;
                                        		 var newId = row[0].split('|')[0];
                                        		 var newRowInfo = row[0] + "|" 
                                        		 				+ row[1] + "|" 
                                        		 				+ row[3] + "|" 
                                        		 				+ row[4] + "|" 
                                        		 				+ row[6] + "|" 
                                        		 				+ row[5] + "|" 
                                        		 				+ row[2] + "|" 
                                        		 				+ row[10] + "|" 
                                        		 				+ row[12] + "|" 
                                        		 				+ row[13] + "|" 
                                        		 				+ row[14] + "|" 
                                        		 				+ row[16];
                                        		 return '<input type="checkbox" class="activeChkBox td_episodeKey"' + 'id=checkBox_' + newId  + ' value="' + data + '" filter_val_1="' + newRowInfo + '">';
                                        	 },
                                        	 "sortable":false
                                           },
                                           { 
                                        	 // note: GS 10/29/15 - rendering the fixed columns with a fixed width fixes alignment issues as seen in IR#1276
                                        	   "render" : function(data,type,row) {
                                          			if ( cs.data.isProviderProfile === "true")
                                        			{
                                        				return '<span class=text-nowrap>' + data + '</span>';                                                				
                                        			}
                                           			else
                                           			{                                        		   
                                           				return '<span class="description"><a class="ln-EL_ED_EL" href="javascript:void(0);" filterText="'+row[2]+'">'+ data +'</a></span>';
                                           			}
                                        	   },
                                               "sClass":"ln-text-align-left td_1",
                                               "targets": 1,
                                               "sortable":true
                                           },
                                           { 
                                           	// note: GS 10/29/15 - rendering the fixed columns with a fixed width fixes alignment issues as seen in IR#1276
                                           	   "render" : function(data,type,row) {
                                           		return '<a href="javascript:void(0);" class="patientProfileDetails" patientName="'+ row[2] +'" patientId= "'+row[18]+'">'+ data + '</a>';  
                                           	   },
                                                  "sClass":"ln-text-align-left td_2",
                                                  "targets": 2,
                                                  "sortable":true
                                             },
                                             
                                              { 
                                                 "sClass":"ln-text-center td_3",
                                                 "width": "1%",
                                                 "targets": 3,
                                                 "sortable":true
                                              },
                                           
                                           {
	       										"render" : function(data, type, row) {
	       											return cs.colorCodeTableDetails(cs,data);
	       										},
	                                            "sClass":"td_4",
	       										"targets" : [ 4 ]
	       									},
	       									
                                           {
	       										"render" : function(data, type, row) {
	       											return cs.colorCodeTableDetails(cs,data);
	       										},
	                                            "sClass":"td_5",
	       										"targets" : [ 5 ]
	       									},
	       									
	       									{   // color pill removed as per IR#1826
	       										/*"render" : function(data, type, row) {
	       											return cs.colorCodeTableDetails(cs,data);
	       										},*/
	                                            "sClass":"td_6",
	       										"targets" : [ 6 ]
	       									},
	       									

	       									{
	       										"render" : function(data, type, row) {       											
	       											return formatUtil.formatNumber(parseInt(data));      											
	       										},
	       										"targets" : [ 7 , 8 , 9 ]
	       									},
	       									
	       									{ 
	                                             "sClass":"ln-text-align-left td_10 text-nowrap",
	                                             "targets": 10,
	                                             "render" : function(data,type,row) {
                                        			if ( cs.data.isProviderProfile === "true")
                                        			{
                                        				return data;                                                				
                                        			}
                                           			else
                                           			{	                                            	 
                                           				return '<a class="ln-EL_PP_PR drilldown" href="javascript:void(0);" filter_val="' + row[19] + '">' + data + '</a>';
                                           			}//	                                            	 
//	                                            	var fromScreen = "EL";
//	                                            	return '<a href="javascript:void(0);" class="providerProfileDetails" fromScreen="'
//  													+ fromScreen
//  													+ '" subClientId="'
//  													+ row[0].split(":")[1]
//  													+ '" providerName="' + data
//  													+ '" providerId="'
//  													+ row[0].split(":")[2] + '" >' + data
//  													+ '</a>';
	                                             },
	                                             "sortable":true
	                                          },

                                           { 
                                               "sClass":"td_11",
                                               "targets": 11
                                           },

                                           { 
                                               "sClass":"td_12",
                                               "targets": 12
                                           },
                                           
                                           { 
                                               "sClass":"td_13",
                                               "targets": 13
                                           },

                                           { 
                                               "sClass":"td_14",
                                               "targets": 14
                                           },

                                           { 
                                               "sClass":"td_15",
                                               "targets": 15
                                           },
                                           { 
                                               "sClass":"td_16",
                                               "targets": 16
                                           },
                                           {
                                        	   "sClass":cs.data.classhideColumn,
                                        	   "width": "1%",
                                        	   "targets": 17
                                           },
                                           { 
                                               "sClass":cs.data.classhideColumn,
                                               "width": "1%",
                                               "targets": [18]
                                           },
	                                       { 
	                                           "sClass": cs.data.classhideColumn,
	                                           "width": "1%",
	                                           "targets": [19]   
	                                       }
                                           
                                         ],
                                       "fnDrawCallback" : function(oSettings) {                                           
                                    	  /* $('.ln-overallEfficiency-patients').on('click',function(){
                                    		   location.href="patientList";
                                    	   });*/

                                    	   cs.addGotoPageComponentPPM("ln_summary_episode_list","ln_summary_episode_list_gotobtn","ln_summary_episode_list_gototxt","ln_summary_episode_list_gotoerror");
                                    	   cs.removeSecondarySortingHeaderColor(oSettings,cs.data.summaryTableId,2);
                                    	   cs.setCheckBoxes(cs, cs.data.summaryTableId);
                                    	   cs.getPatientProfileDetails();
                                       },
                                       "fnPreDrawCallback" : function(oSettings) {
                                       	if (oSettings.aaSorting[0] && oSettings.aaSorting[0][0] !== cs.getPreferencesIndex(cs.data.summaryDefaultTablePreferences  ,cs.data.defaultSortColumn_summary) ) {
                                       		cs.data.manualsort = true;
                                       	}
                                       	return true;
                                       },
                                     "fnInitComplete": function(oSettings, json) {
                                    	 cs.noDataCleanup(json.iTotalDisplayRecords);
                                    	 setTimeout(function(){
		        	         	    		$('.ln-tableheadertextextended a').on('click',function(e){
		        	         	    			e.preventDefault();
		        	         	    			return false;
		        	         	    		});
		        	         	    		//$('.DTFC_LeftHeadWrapper #Select_All').removeClass('sorting_asc');
                                    	 },0);        	         	    	
                                     }
                        }    	
                    );
                new $.fn.dataTable.FixedColumns( cs.data.tableSummary,{
                	leftColumns:2
                } );
                $('#ln_goToSummaryControl').on('keyup',function(){
                	if($('#ln_goToSummaryControl').val()===" "||$('#ln_goToSummaryControl').val()<=0){
                		cs.data.tableSummary.page(0).draw( false );
                	}else
                	{
                    	cs.data.tableSummary.page($('#ln_goToSummaryControl').val()-1).draw( false );
                	}
                });
            },
            
            initializeDetailsTable: function(cs){
            	//var cs = this;
            	LN.debug("initializeDetailsTable called ");
            	var prevColumnNamesArray=cs.getCurrentSummaryColumnNamesArray(cs.data.detailTableId);
            	
                $(cs.data.summaryContainer).hide();
                $(cs.data.detailsContainer).show();
            	
            	$(cs.data.detailTableId).dataTable().fnDestroy();
                cs.data.tableDetail = $(cs.data.detailTableId)
	                .dataTable(
                        {
                        	//"dom" : 'Rlfrt',
                        	"dom": 'R<"top"f>rt<"bottom"ilp><"clear">',
                        	scrollY: "300px",
                            scrollX: "true",
                            scrollCollapse: true,
                            "bFilter" : false,
                            "iTotalRecords" : "dataTableModel.iTotalRecords",
                            "iDisplayLength" : 100,
                            "processing" : false,
                            "serverSide" : true,
                            //"bAutoWidth" : true,
                            "bLengthChange" : true,
                            "bResponsive" :false,
                            "ordering" : true, 
                            "paging": true,
                            "pagingType": "simple_numbers",
                            "colReorder": {
                                "iFixedColumns": 3,
                                "fnReorderCallback": function() {
                                        	drillDownFilters.registerDrillDowns();
                                        	cs.getPatientProfileDetails();
                                },
                                realtime: true
                            },
                            "bDeferRender" : true,
                            "ajax" : {
                                "cache": false,
                                "url" :cs.data.baseUrl,
                                "type" : "POST",
                                "dataType" : "json",
                                "data" : function ( d ) {
                                    //LN.debug("data called");
                                    var columnNamesArray=cs.getCurrentSummaryColumnNamesArray(cs.data.detailTableId);
                                    return $.extend( {}, d, {
                                    	"columnNames":columnNamesArray.length>0?columnNamesArray:prevColumnNamesArray,
                                                "selDataSet":$('#ln_topmenu_dataset').attr('datasetkey'),
                                                'selDataSetRangeBegin':  $('#ln_topmenu_dataset_range_id').attr("beginDateKey"),
                        						'selDataSetRangeEnd':  $('#ln_topmenu_dataset_range_id').attr("endDateKey"),
                        						'selSubClientIds' : $('#ln_subClient_id').attr("data-key"),
                        						'selBenchMark' : $('#ln_benchid').attr("data-key"),
                        						'selDataSetRangeRiskColumnName':  $('#ln_topmenu_dataset_range_id').attr("riskColumnName"),
                        						'currentView':'detail',
                        						'searchProviderName':cs.data.providerId
                                    } ); },
                                'beforeSend': function(xhr) {
                                	cs.data.prevProviderId = cs.data.providerId;
                                	xhr.setRequestHeader('X-TransactionID', LN.TRANSACTION_ID);
					                cs.data.defaultEpisodeStartingRow = 0;                                    
                                	$('.DTFC_LeftHeadWrapper').css('display','none');
                                	$('.DTFC_LeftBodyWrapper').css('display','none');
                                    cs.handleBeforeAjaxLoad(cs.data.detailTableId);
                                },
                                'complete' : function() {
                                	if(cs.data.gridSearchCount>0){
                                    	cs.data.gridSearchCount--;
                                    }
                                    cs.handleAfterAjaxLoad(cs.data.detailTableId);
                                	//$('.DTFC_LeftHeadWrapper #Select_All').removeClass('sorting_asc');
                                	$('.DTFC_LeftHeadWrapper').css('display','block');
                                	$('.DTFC_LeftBodyWrapper').css('display','block');
                                	
                                    setTimeout(function(){
                                     	cs.data.tableDetail.fnAdjustColumnSizing(false);
                                     },100);
                                    
                                	var IEver = cs.detectIE(); 
                                	if (IEver){
                                		// remove double scroll bar for IE only
                                		$('.DTFC_LeftBodyLiner').css('overflow','hidden');
                                	}
                                    
                                    
                                    if (cs.data.exclusionArray.length > 0)
                                	{
				            			$('#ln_episode_clear_sel').removeAttr('disabled');
				            			$('#ln_episode_excl_sel').removeAttr('disabled');
                                	}
                                    else
                                	{
    									$('#ln_episode_clear_sel').attr('disabled','disabled');
    									$('#ln_episode_excl_sel').attr('disabled','disabled');                                	
                                	}
					            	$("input.activeChkBox:checkbox").click(function()
			                    	{
					            		if (!$("input.activeChkBox:checkbox").is(":checked"))
					            		{
				        					$('#ln_episode_clear_sel').attr('disabled','disabled');            							            		
				        					$('#ln_episode_excl_sel').attr('disabled','disabled');            							            		
					            		}
					            		else
					            		{
					            			$('#ln_episode_clear_sel').removeAttr('disabled');
					            			$('#ln_episode_excl_sel').removeAttr('disabled');
					            		}
										cs.checkedEpisode(cs, this.id, this.checked, cs.data.detailTableId);
			                    	});
					                cs.data.defaultEpisodeStartingRow = 0;
 			                    	if(cs.data.gridSearchCount==0 && cs.data.prevProviderId!=cs.data.providerId){
 			                    		$(cs.data.searchFieldId).trigger('keyup');
 			                    	}
                                },
                                "dataFilter" : function(json,type){
                                	var obj = jQuery.parseJSON(json);
                                	cs.enableExport(obj);
                                	return json;
                                }
                            }, 
                            "order" : [
                                       [cs.getPreferencesIndex(cs.data.detailDefaultTablePreferences  ,cs.data.defaultSortColumn_detail),"desc" ],
                                       [cs.getPreferencesIndex(cs.data.detailDefaultTablePreferences  ,cs.data.defaultSecondarySortColumn_detail),"asc" ]
                                       ],
                            "columnDefs": [

                                           {
                                        	 "width": "1%",
                                        	 "targets":0,
                                        	 "render" : function(data,type,row) {
                                        		 //var newId = cs.data.defaultEpisodeStartingRow++;         
                                        		 var newId = row[0].split('|')[0];     
                                        		 var newRowInfo = row[0] + "|" 
                         		 				+ row[1] + "|" 
                         		 				+ row[3] + "|" 
                         		 				+ row[4] + "|" 
                         		 				+ row[6] + "|" 
                         		 				+ row[5] + "|" 
                         		 				+ row[2] + "|" 
                         		 				+ row[14] + "|" 
                         		 				+ row[15] + "|" 
                         		 				+ row[16] + "|" 
                         		 				+ row[18] + "|" 
                         		 				+ row[19];
                                        		 return '<input type="checkbox" class="activeChkBox"' + 'id=checkBox_' + newId + ' value="' + data + '" filter_val_1="' + newRowInfo + '">';
                                        	 },
                                        	 "sortable":false
                                           },
                                           { 
                                          	 // note: GS 10/29/15 - rendering the fixed columns with a fixed widh fixes alignment issues as seen in IR#1276
                                        	   "render" : function(data,type,row) {
                                          			if ( cs.data.isProviderProfile === "true")
                                        			{
                                        				return '<span class=text-nowrap>' + data + '</span>';                                                				
                                        			}
                                           			else
                                           			{                                        		   
                                           				return '<span class="description"><a class="ln-EL_ED_EL" href="javascript:void(0);" filterText="'+row[2]+'">'+ data +'</a></span>';
                                           			}
                                        	   },
                                               "sClass":"ln-text-align-left td_1",
                                               "targets": 1,
                                               "sortable":true
                                           },
                                           { 
                                        	// note: GS 10/29/15 - rendering the fixed columns with a fixed width fixes alignment issues as seen in IR#1276
                                        	   "render" : function(data,type,row) {
                                        		   return '<a href="javascript:void(0);" class="text-nowrap patientProfileDetails" patientName="'+ row[2] +'" patientId= "'+row[21]+'">'+ data + '</a>';
                                        	   },
                                               "sClass":"ln-text-align-left td_2",
                                               "targets": 2,
                                               "sortable":true
                                          },
                                          
                                           { 
                                              "sClass":"ln-text-center td_3",
                                              "width": "1%",
                                              "targets": 3,
                                              "sortable":true
                                           },
                                           {
	       										"render" : function(data, type, row) {
	       											return cs.colorCodeTableDetails(cs,data);
	       										},
	                                            "sClass":"td_4",
	       										"width": "1%",
	       										"targets" : [ 4 ]
	       									},
                                           {
	       										"render" : function(data, type, row) {
	       											return cs.colorCodeTableDetails(cs,data);
	       										},
	                                            "sClass":"td_5",
	       										"width": "1%",
	       										"targets" : [ 5 ]
	       									},
                                           {
	       										// no color as per IR#1826
	       										/*"render" : function(data, type, row) {
	       											return cs.colorCodeTableDetails(cs,data);
	       										},*/
	                                            "sClass":"td_6",
	       										"width": "1%",
	       										"targets" : [ 6 ]
	       									},
	       									
	       									{
	       										"render" : function(data, type, row) {       											
	       											return formatUtil.formatNumber(parseInt(data));      											
	       										},
	       										"targets" : [ 7 , 8 ]
	       									},
	       									
	       									{
	       										"render" : function(data, type, row) {
	       											return cs.colorCodeTableDetails(cs,data);
	       										},
	                                            "sClass":"td_9",
	       										"width": "1%",
	       										"targets" : [ 9 ]
	       									},
	       									
	       									{
	       										"render" : function(data, type, row) {
	       											return cs.colorCodeTableDetails(cs,data);
	       										},
	                                            "sClass":"td_10",
	       										"width": "1%",
	       										"targets" : [ 10 ]
	       									},
	       									
	       									{
	       										"render" : function(data, type, row) {
	       											return cs.colorCodeTableDetails(cs,data);
	       										},
	                                            "sClass":"td_11",
	       										"width": "1%",
	       										"targets" : [ 11 ]
	       									},
	       									
	       									{
	       										"render" : function(data, type, row) {
	       											return cs.colorCodeTableDetails(cs,data);
	       										},
	                                            "sClass":"td_12",
	       										"width": "1%",
	       										"targets" : [ 12 ]
	       									},
	       									
	       									{
	       										"render" : function(data, type, row) {
	       											return cs.colorCodeTableDetails(cs,data);
	       										},
	                                            "sClass":"td_13",
	       										"width": "1%",
	       										"targets" : [ 13 ]
	       									},
	       									
                                           { 
                                             "sClass":"ln-text-align-left td_14 text-nowrap",
                                             "width": "1%",
                                             "targets": 14,
                                             "render" : function(data,type,row) {
                                            	// return '<a class="ln-EL_PP_PD drilldown" href="javascript:void(0);">'+data+'</a>';
                                        			if ( cs.data.isProviderProfile === "true")
                                        			{
                                        				return data;                                                				
                                        			}
                                           			else
                                           			{                                            	 
                                           				return '<a class="ln-EL_PP_PR drilldown" href="javascript:void(0);" filter_val="' + row[22] + '">' + data + '</a>';
                                           			}
//                                            	 var fromScreen = "EL";
//	                                            	return '<a href="javascript:void(0);" class="providerProfileDetails" fromScreen="'
//													+ fromScreen
//													+ '" subClientId="'
//													+ row[0].split(":")[1]
//													+ '" providerName="' + data
//													+ '" providerId="'
//													+ row[0].split(":")[2] + '" >' + data
//													+ '</a>';
                                    	     },
                                             "sortable":true
                                           },
                                           
                                           { 
                                               "sClass":"td_15",
                                               "width": "1%",
                                               "targets": [15]
                                           },

                                           { 
                                               "sClass":"td_16",
                                               "width": "1%",
                                               "targets": [16]
                                           },
                                           
                                           { 
                                               "sClass":"td_17",
                                               "width": "1%",
                                               "targets": [17]
                                           },
                                           { 
                                               "sClass":"td_18",
                                               "width": "1%",
                                               "targets": 18
                                           },
                                           { 
                                               "sClass":"td_19",
                                               "width": "1%",
                                               "targets": 19
                                           },
                                           { 
                                        	   "sClass":cs.data.classhideColumn,
                                        	   "width": "1%",
                                        	   "targets": 20
                                           },
                                           { 
                                               "sClass":cs.data.classhideColumn,
                                               "width": "1%",
                                               "targets": [21]
                                           },
	                                       { 
	                                           "sClass": cs.data.classhideColumn,
	                                           "width": "1%",
	                                           "targets": [22]   
	                                       }
                                           
                                       ],
                               "fnDrawCallback" : function(oSettings) {                                           
                            	  /* $('td.ln-overallEfficiency-patients').on('click',function(){
                            		   location.href="patientList";
                            	   }); */
                            	   cs.addGotoPageComponentPPM("ln_detail_episode_list","ln_detail_episode_list_gotobtn","ln_detail_episode_list_gototxt","ln_detail_episode_list_gotoerror");
                            	   cs.removeSecondarySortingHeaderColor(oSettings,cs.data.detailTableId,2);
                            	   cs.setCheckBoxes(cs, cs.data.detailTableId);
                            	   cs.getPatientProfileDetails();
                               },
                               "fnPreDrawCallback" : function(oSettings) {
                               	if (oSettings.aaSorting[0] && oSettings.aaSorting[0][0] !== cs.getPreferencesIndex(cs.data.summaryDefaultTablePreferences  ,cs.data.defaultSortColumn_detail) ) {
                               		cs.data.manualsort = true;
                               	}
                               	return true;
                               },
                             "fnInitComplete": function(oSettings, json) {
                            	 cs.noDataCleanup(json.iTotalDisplayRecords);
                            	 setTimeout(function(){
        	         	    		$('.ln-tableheadertextextended a').on('click',function(e){
        	         	    			e.preventDefault();
        	         	    			return false;
        	         	    		});        	         	    		
                            	 },0);  
                             }
                        }    	
                    );
                new $.fn.dataTable.FixedColumns( cs.data.tableDetail,{
                	leftColumns:2
                } );
                 
             
            }            
            
        });