/**
 * mplus_mobile_consult
 */
var mplus_mobile_consult = function(){
	//상속
	mplus_common.call(this);
	var mplusPatient = new mplus_mobile_patient();
	
	//super
	var self = this;
	
	//변수
	var div = $('<div></div>');
	var tr = $('<tr></tr>');
	var th = $('<th></th>');
	var td = $('<td></td>');
	var table = $('<table></table>');
	var li = $('<li></li>');
	var a = $('<a></a>');
	var span = $('<span></span>');
	var button = $('<button></button>');
	
	var today = new Date();
    var prevDay = new Date(Date.parse(new Date()) - 6 * 1000 * 60 * 60 * 24); //일주일전!!
    
	/**
	 * 초기화
	 */
	this.init = function(){
		replyInitDataSetting();		
		deptReplyInitDataSetting();
		requestInitDataSetting();
		replyInit();
		replyAddEvent();
		replySearchConsultList();
		
		deptReplyAddEvent();
		requestAddEvent();
		$('#consultTab a[data-toggle="tab"]').unbind();
		$('#consultTab a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
			if($("ul.nav-tabs#consultTab li.active a").attr('aria-controls')=='tabReply'){
				replyInit();
				replySearchConsultList();
			}else if($("ul.nav-tabs#consultTab li.active a").attr('aria-controls')=='tabDeptReply'){
				deptReplyInit();
				deptReplySearchConsultList();
			}else if($("ul.nav-tabs#consultTab li.active a").attr('aria-controls')=='tabRequest'){
				requestInit();
				requestSearchConsultList();
			}else{
				/*slef.aler('에러메시지?');*/
			};
		});
	};
	
	/*----------------------- 의뢰 resource  ----------------------*/
	var $replyTotalNumSpan = $('#replyTotalNumSpan'),
		$replyRefreshBtn = $('#replyRefreshBtn'),
	 	$replyUlConsultList = $('#replyUlConsultList'),
	 	$replyBtnSortOpen = $('#replyBtnSortOpen');
	
	var replyConsultList = []; 
	
	/**
	 * 초기화
	 */
	var replyInit = function(){
	    var todayDateStr = moment(today).format('YYYY-MM-DD');
	    var prevDayStr = moment(prevDay).format('YYYY-MM-DD');
	    
	    $("#replyDtpEndSrchdd").val(todayDateStr);
	    $("#replyDtpStartSrchdd").val(prevDayStr);
	    
	    replyConsultList = [];
	    $('#replySltStatus').val('N');
	    $('#replySltTreatType').val('I');
	    $replyTotalNumSpan.text(0);
	    $replyUlConsultList.empty();
	    
	    var sortList = [{key: 'wardNm', type: 'string',  value: '병동순'},
		            {key: 'age', type: 'number', value: '연령순'},
		            {key: 'patientNm', type: 'string', value: '이름순'}];
		sortInit(sortList);
		$('#sortConfirmBtn').unbind();
		$('#sortConfirmBtn').on("click", function(e){
			$('#sortModal').modal('hide');
			replySortConsultList($('#sltSort').val(), $('#sltSort option:selected').attr('type'), $('input[type="radio"][name="sortRadio"]:checked').val());

			$('.header span').css('display', 'none');
			$('.header.sort_'+$('#sltSort').val()+' .sort-icon-'+$('input[type="radio"][name="sortRadio"]:checked').val()).css('display', 'inline-block');
		});
	};
	/**
	 * 이벤트 등록
	 */
	var replyAddEvent = function(){
		$replyRefreshBtn.on("click", function(e){
			$('.header span').css('display', 'none');
			replySearchConsultList();
		});
		$replyBtnSortOpen.on("click", function(e){
			$('#sortModal').modal('show');
		});
	};
	/**
	 * 기초데이터 셋팅
	 */
	var replyInitDataSetting = function(){
	};
	
	var replySearchConsultList = function(){
		if($('#replyDtpStartSrchdd').val()=='' || $('#replyDtpEndSrchdd').val()==''){
			self.alert('조회 일자를 입력해주세요.');
			return;
		}else if(self.dateCalc($('#replyDtpStartSrchdd').val(), $('#replyDtpEndSrchdd').val())>6){
			self.alert('조회 기간은 7일이내로 설정해주세요.');
			return;
		}else if(self.dateCalc($('#replyDtpStartSrchdd').val(), $('#replyDtpEndSrchdd').val())<0){
			self.alert('조회 기간을 확인해주세요.');
			return;
		};
		$replyUlConsultList.empty();
		replyConsultList = [];
		var param = {
						startDt: moment($('#replyDtpStartSrchdd').val()).format('YYYYMMDD'),
						endDt: moment($('#replyDtpEndSrchdd').val()).format('YYYYMMDD'),
						departmentCd: localStorage.selectDeptCode,
						doctorId: loginUserId,
						viewTyp: 'U',
						treatTyp: $('#replySltTreatType').val(),
						statusTyp: $('#replySltStatus').val()
					};
		self.consult.getConsultResList(param, 'reply');
		$("#reply_consultList .header.visit-dt").text($('#replySltTreatType').val()=='I'? '입원일': '진료일'); 
		/*bindingConsultList(consultList);*/
	}
	var replySortConsultList = function(key, type, method){
		replyConsultList = self.util.sortObj(replyConsultList, key, type, method);
		replyBindingConsultList(replyConsultList, null);
	};
	
	replyBindingConsultList = function(bindConsultList, extraMsg){
		$replyUlConsultList.empty();
		replyConsultList = bindConsultList;
		$replyTotalNumSpan.text(replyConsultList.length);
		
		if(replyConsultList.length==0){
			$replyUlConsultList.append(li.clone().append(div.clone().addClass('text-center no-result').text('―')));
		};
		
		for(var i=0; i<replyConsultList.length; i++){
			var divNumHospital = div.clone().addClass("num_b col-xs-3 col-sm-2 pdr0 letter-control").text(replyConsultList[i].consultTyp=='I'? replyConsultList[i].wardNm + '/' + replyConsultList[i].roomNm : '외래');
			var divName = div.clone().addClass("name col-xs-6 col-sm-4").text(replyConsultList[i].patientNm + ' ' + replyConsultList[i].patientId);
			var divNum = div.clone().addClass("num_3 col-xs-3 col-sm-2").text(replyConsultList[i].gender + ' / ' + replyConsultList[i].age);
			/*var divNum = div.clone().addClass("num col-xs-3 col-sm-2").append(
					span.clone().addClass('badge ' + (replyConsultList[i].sex=='F'? 'female':'male') )
					.text( (replyConsultList[i].sex=='F'? 'F':'M') + replyConsultList[i].age )
			);
			*/
			
			var divEmpty = div.clone().addClass('clearfix visible-xs-block').text(' '); 
			
			var divDay = div.clone().addClass("col-xs-3 hidden-sm hidden-md hidden-lg").html('&nbsp;');
			var divDoctor = div.clone().addClass("doctor col-xs-6 col-sm-2").text(replyConsultList[i].requestDeptCd +' / ' + replyConsultList[i].requestDrNm);
			var divDate = div.clone().addClass("out col-xs-3 col-sm-2 pdr0 letter-control").text(replyConsultList[i].visitDt==''? '': moment(replyConsultList[i].visitDt).format('YYYY-MM-DD'));
			
			var divPatientInfo = div.clone().addClass("list-row container").append(divNumHospital).append(divName).append(divNum).append(divEmpty).append(divDay).append(divDoctor).append(divDate);
			
			var divRequest = $("<strong></strong>").text("의뢰: ");
			var spanRequest = span.clone().addClass("date1").text(replyConsultList[i].requestDt!=undefined&&replyConsultList[i].requestDt!=null&&replyConsultList[i].requestDt!=''? moment(replyConsultList[i].requestDt).format('YYYY-MM-DD'): '');
			var divReply = $("<strong></strong>").text("회신: ");
			var spanReply = span.clone().addClass("date1").text(replyConsultList[i].responseDtTm!=undefined&&replyConsultList[i].responseDtTm!=null&&replyConsultList[i].responseDtTm!=''? moment(replyConsultList[i].responseDtTm).format('YYYY-MM-DD'): '');
			var divTreatmentDate = div.clone().addClass("list-row container text-center list-row-3").append(div.clone().addClass("col-xs-12 col-sm-12").append(
					divRequest).append(spanRequest).append(divReply).append(spanReply));
			
			
			$replyUlConsultList.append(li.clone().append(a.clone().addClass("list-group-item").attr('consultNo', i).append(divPatientInfo).append(divTreatmentDate)));
		};
		$("#replyUlConsultList .list-group-item").on("click", function(e){
			var consultInfo = replyConsultList[e.currentTarget.attributes.consultNo.value];
			consultInfo.treatDt = consultInfo.visitDt;
			consultInfo.consultTyp = consultInfo.consultTyp;
			localStorage.setItem('patientInfo', JSON.stringify(consultInfo));
			
			$('#patientPopup .popup-content').removeClass('in');
			$('#patientPopup #popContentConsultDetail').addClass('in');
			$('#newPopupFooter2').css('display', 'block');
			$('#patientPopup').css({'height': '-webkit-calc(100% - 40px)',
									 'height': '-moz-calc(100% - 40px)',
									 'height': 'calc(100% - 40px)',
									 'bottom': '0px',
									 'display': 'block'});
			mplusPatient.consultInit();
			
			/*$('.popFootContent button, .footContent button').removeClass('active');
			$('#headerTitle1').text("협진");
			$('#prescriptionContent, #examineContent, #detailContent').css('display', 'none');
			$('#consultDetailContent').css('display', 'block');
			$('#pageDetail').unbind();
			$('#pageDetail').modal('show');
			$('#consultDetailContent').scrollTop(0);
			
			var mplusDetail = new mplus_mobile_patientDetail();*/
			/*location.href = contextPath + '/mobile/patient/consultDetail.page';*/
			
			/*$('#pageDetail').on('hidden.bs.modal', function() {
				$('.popFootContent button').removeClass('active');
			});*/
		});
	} 
	/*----------------------- 의뢰 resource 종료 ----------------------*/
	
	/*----------------------- 과회신 resource  ----------------------*/
	var $deptReplyTotalNumSpan = $('#deptReplyTotalNumSpan'),
	 	$deptReplyRefreshBtn = $('#deptReplyRefreshBtn'),
	 	$deptReplyUlConsultList = $('#deptReplyUlConsultList'),
	 	$deptReplyBtnSortOpen = $('#deptReplyBtnSortOpen');
	
	var deptReplyConsultList = []; 
	
	/**
	 * 초기화
	 */
	var deptReplyInit = function(){
	    var todayDateStr = moment(today).format('YYYY-MM-DD');
	    var prevDayStr = moment(prevDay).format('YYYY-MM-DD');
	    
	    $("#deptReplyDtpEndSrchdd").val(todayDateStr);
	    $("#deptReplyDtpStartSrchdd").val(prevDayStr);
	    	    
	    deptReplyConsultList = []; 
	    $('#deptReplySltStatus').val('N');
	    $('#deptReplySltTreatType').val('I');
	    $deptReplyTotalNumSpan.text(0);
	    $deptReplyUlConsultList.empty();
	    
	    var sortList = [{key: 'wardNm', type: 'string',  value: '병동순'},
		            {key: 'age', type: 'number', value: '연령순'},
		            {key: 'patientNm', type: 'string', value: '이름순'}];
		sortInit(sortList);
		
		$('#sortConfirmBtn').unbind();
		$('#sortConfirmBtn').on("click", function(e){
			$('#sortModal').modal('hide');
			deptReplySortConsultList($('#sltSort').val(), $('#sltSort option:selected').attr('type'), $('input[type="radio"][name="sortRadio"]:checked').val());
			

			$('.header span').css('display', 'none');
			$('.header.sort_'+$('#sltSort').val()+' .sort-icon-'+$('input[type="radio"][name="sortRadio"]:checked').val()).css('display', 'inline-block');
		});
	};
	/**
	 * 이벤트 등록
	 */
	var deptReplyAddEvent = function(){
		$deptReplyRefreshBtn.on("click", function(e){
			$('.header span').css('display', 'none');
			deptReplySearchConsultList();
		});
		$deptReplyBtnSortOpen.on("click", function(e){
			$('#sortModal').modal('show');
		});
		
		
	};
	/**
	 * 기초데이터 셋팅
	 */
	var deptReplyInitDataSetting = function(){
	};
	
	var deptReplySearchConsultList = function(){
		if($('#deptReplyDtpStartSrchdd').val()=='' || $('#deptReplyDtpEndSrchdd').val()==''){
			self.alert('조회 일자를 입력해주세요.');
			return;
		}else if(self.dateCalc($('#deptReplyDtpStartSrchdd').val(), $('#deptReplyDtpEndSrchdd').val())>6){
			self.alert('조회 기간은 7일이내로 설정해주세요.');
			return;
		}else if(self.dateCalc($('#deptReplyDtpStartSrchdd').val(), $('#deptReplyDtpEndSrchdd').val())<0){
			self.alert('조회 기간을 확인해주세요.');
			return;
		};
		$deptReplyUlConsultList.empty();
		deptReplyConsultList = [];
		var param = {
							startDt: moment($('#deptReplyDtpStartSrchdd').val()).format('YYYYMMDD'),
							endDt: moment($('#deptReplyDtpEndSrchdd').val()).format('YYYYMMDD'),
							departmentCd: localStorage.selectDeptCode,
							/*doctorId: loginUserId,*/
							viewTyp: 'D',
							treatTyp: $('#deptReplySltTreatType').val(),
							statusTyp: $('#deptReplySltStatus').val()
					};
		self.consult.getConsultResList(param, 'deptReply');
		$("#deptReply_consultList .header.visit-dt").text($('#deptReplySltTreatType').val()=='I'? '입원일': '진료일');
		/*bindingConsultList(consultList);*/
		
	}
	var deptReplySortConsultList = function(key, type, method){
		deptReplyConsultList = self.util.sortObj(deptReplyConsultList, key, type, method);
		deptReplyBindingConsultList(deptReplyConsultList, null);
	};
	
	deptReplyBindingConsultList = function(bindConsultList, extraMsg){
		$deptReplyUlConsultList.empty();
		deptReplyConsultList = bindConsultList;
		
		$deptReplyTotalNumSpan.text(deptReplyConsultList.length);
		
		if(deptReplyConsultList.length==0){
			$deptReplyUlConsultList.append(li.clone().append(div.clone().addClass('text-center no-result').text('―')));
		};
		
		for(var i=0; i<deptReplyConsultList.length; i++){
			
			var divNumHospital = div.clone().addClass("num_b col-xs-3 col-sm-2 pdr0 letter-control").text(deptReplyConsultList[i].consultTyp=='I'? deptReplyConsultList[i].wardNm + '/' +deptReplyConsultList[i].roomNm: '외래');
			var divName = div.clone().addClass("name col-xs-6 col-sm-4").text(deptReplyConsultList[i].patientNm + ' ' +deptReplyConsultList[i].patientId);
			var divNum = div.clone().addClass("num_3 col-xs-3 col-sm-2").text(deptReplyConsultList[i].gender + ' / ' + deptReplyConsultList[i].age);
			/*var divNum = div.clone().addClass("num col-xs-3 col-sm-2").append(
					span.clone().addClass('badge ' + (deptReplyConsultList[i].sex=='F'? 'female':'male') )
					.text( (deptReplyConsultList[i].sex=='F'? 'F':'M') + deptReplyConsultList[i].age )
			);*/
			
			var divEmpty = div.clone().addClass('clearfix visible-xs-block').text(' ');
			var divDay = div.clone().addClass("col-xs-3 hidden-sm hidden-md hidden-lg").html('&nbsp;');
			var divDoctor = div.clone().addClass("doctor col-xs-6 col-sm-2").text(deptReplyConsultList[i].requestDeptCd + ' / '+ deptReplyConsultList[i].requestDrNm);
			var divDate = div.clone().addClass("out col-xs-3 col-sm-2 pdr0 letter-control").text(deptReplyConsultList[i].visitDt==''? '' : moment(deptReplyConsultList[i].visitDt).format('YYYY-MM-DD'));
			
			var divPatientInfo = div.clone().addClass("list-row container").append(divNumHospital).append(divName).append(divNum).append(divEmpty).append(divDay).append(divDoctor).append(divDate);
			
			var divRequest = $("<strong></strong>").text("의뢰: ");
			var spanRequest = span.clone().addClass("date1").text(deptReplyConsultList[i].requestDt!=undefined&&deptReplyConsultList[i].requestDt!=null&&deptReplyConsultList[i].requestDt!=''? moment(deptReplyConsultList[i].requestDt).format('YYYY-MM-DD'): '');
			var divReply = $("<strong></strong>").text("회신: ");
			var spanReply = span.clone().addClass("date1").text(deptReplyConsultList[i].responseDtTm!=undefined&&deptReplyConsultList[i].responseDtTm!=null&&deptReplyConsultList[i].responseDtTm!=''? moment(deptReplyConsultList[i].responseDtTm).format('YYYY-MM-DD'): '');
			var divTreatmentDate = div.clone().addClass("list-row container text-center list-row-3").append(div.clone().addClass("col-xs-12 col-sm-12").append(
					divRequest).append(spanRequest).append(divReply).append(spanReply));
			
			
			$deptReplyUlConsultList.append(li.clone().append(a.clone().addClass("list-group-item").attr('consultNo', i).append(divPatientInfo).append(divTreatmentDate)));
		};
		$("#deptReplyUlConsultList .list-group-item").on("click", function(e){
			var consultInfo = deptReplyConsultList[e.currentTarget.attributes.consultNo.value];
			consultInfo.treatDt = consultInfo.visitDt;
			consultInfo.treatTyp = consultInfo.consultTyp;
			localStorage.setItem('patientInfo', JSON.stringify(consultInfo));
			
			$('#patientPopup .popup-content').removeClass('in');
			$('#patientPopup #popContentConsultDetail').addClass('in');
			$('#newPopupFooter2').css('display', 'block');
			$('#patientPopup').css({'height': '-webkit-calc(100% - 40px)',
									 'height': '-moz-calc(100% - 40px)',
									 'height': 'calc(100% - 40px)',
									 'bottom': '0px',
									 'display': 'block'});
			mplusPatient.consultInit();
			
			
			/*$('.popFootContent button, .footContent button').removeClass('active');
			$('#headerTitle1').text("협진");
			$('#prescriptionContent, #examineContent, #detailContent').css('display', 'none');
			$('#consultDetailContent').css('display', 'block');
			$('#pageDetail').unbind();
			$('#pageDetail').modal('show');
			$('#consultDetailContent').scrollTop(0);
						
			var mplusDetail = new mplus_mobile_patientDetail();*/
			/*location.href = contextPath + '/mobile/patient/consultDetail.page';*/
			/*$('#pageDetail').on('hidden.bs.modal', function() {
				$('.popFootContent button').removeClass('active');
			});*/
		});
	} 
	
	/*----------------------- 과회신 resource 종료 ----------------------*/
	
	/*----------------------- 의뢰 resource  ----------------------*/
	var $requestTotalNumSpan = $('#requestTotalNumSpan'),
	 	$requestRefreshBtn = $('#requestRefreshBtn'),
	 	$requestUlConsultList = $('#requestUlConsultList'),
	 	$requestBtnSortOpen = $('#requestBtnSortOpen');
	
	var requestConsultList = []; 
	
	/**
	 * 초기화
	 */
	var requestInit = function(){
	    var todayDateStr = moment(today).format('YYYY-MM-DD');
	    var prevDayStr = moment(prevDay).format('YYYY-MM-DD');
	    
	    $("#requestDtpEndSrchdd").val(todayDateStr);
	    $("#requestDtpStartSrchdd").val(prevDayStr);
	    
	    var sortList = [{key: 'wardNm', type: 'string',  value: '병동순'},
		            {key: 'age', type: 'number', value: '연령순'},
		            {key: 'patientNm', type: 'string', value: '이름순'}];
		sortInit(sortList);
		
		$requestTotalNumSpan.text(0);
		$requestUlConsultList.empty();
		requestConsultList = []; 
		
		$('#sortConfirmBtn').unbind();
		$('#sortConfirmBtn').on("click", function(e){
			$('#sortModal').modal('hide');
			requestSortConsultList($('#sltSort').val(), $('#sltSort option:selected').attr('type'), $('input[type="radio"][name="sortRadio"]:checked').val());
			
			$('.header span').css('display', 'none');
			$('.header.sort_'+$('#sltSort').val()+' .sort-icon-'+$('input[type="radio"][name="sortRadio"]:checked').val()).css('display', 'inline-block');
		});
	};
	/**
	 * 이벤트 등록
	 */
	var requestAddEvent = function(){
		$requestRefreshBtn.on("click", function(e){
			$('.header span').css('display', 'none');
			requestSearchConsultList();
		});
		$requestBtnSortOpen.on("click", function(e){
			$('#sortModal').modal('show');
		});
	};
	
	/**
	 * 기초데이터 셋팅
	 */
	var requestInitDataSetting = function(){
	
	};
	
	var requestSearchConsultList = function(){
		if($('#requestDtpStartSrchdd').val()=='' || $('#requestDtpEndSrchdd').val()==''){
			self.alert('조회 일자를 입력해주세요.');
			return;
		}else if(self.dateCalc($('#requestDtpStartSrchdd').val(), $('#requestDtpEndSrchdd').val())>6){
			self.alert('조회 기간은 7일이내로 설정해주세요.');
			return;
		}else if(self.dateCalc($('#requestDtpStartSrchdd').val(), $('#requestDtpEndSrchdd').val())<0){
			self.alert('조회 기간을 확인해주세요.');
			return;
		};
		$requestUlConsultList.empty();
		requestConsultList = [];
		var param = {
						startDt: moment($('#requestDtpStartSrchdd').val()).format('YYYYMMDD'),
						endDt: moment($('#requestDtpEndSrchdd').val()).format('YYYYMMDD'),
						departmentCd: localStorage.selectDeptCode,
						doctorId: loginUserId,
						statusTyp: 'A' // 임시셋팅
					};
		self.consult.getConsultReqList(param);
		/*bindingConsultList(consultList);*/
	};
	
	var requestSortConsultList = function(key, type, method){
		requestConsultList = self.util.sortObj(requestConsultList, key, type, method);
		requestBindingConsultList(requestConsultList, null);
	};
	
	requestBindingConsultList = function(bindConsultList, extraMsg){
		$requestUlConsultList.empty();
		requestConsultList = bindConsultList;
			
		$requestTotalNumSpan.text(requestConsultList.length);
		
		if(requestConsultList.length==0){
			$requestUlConsultList.append(li.clone().append(div.clone().addClass('text-center no-result').text('―')));
		};
		
		for(var i=0; i<requestConsultList.length; i++){
			var divNumHospital = div.clone().addClass("num_b col-xs-3 col-sm-2 pdr0 letter-control").text(requestConsultList[i].consultTyp=='I'? requestConsultList[i].wardNm + '/'+ requestConsultList[i].roomNm: '외래');
			var divName = div.clone().addClass("name col-xs-6 col-sm-4").text(requestConsultList[i].patientNm + ' ' + requestConsultList[i].patientId);
			var divNum = div.clone().addClass("num_3 col-xs-3 col-sm-2").text( requestConsultList[i].gender + ' / ' +requestConsultList[i].age );
			/*var divNum = div.clone().addClass("num col-xs-3 col-sm-2").append(
					span.clone().addClass('badge ' + (requestConsultList[i].sex=='F'? 'female':'male') )
					.text( (requestConsultList[i].sex=='F'? 'F':'M') + requestConsultList[i].age )
			);*/
			
			var divEmpty = div.clone().addClass('clearfix visible-xs-block').text(' ');
			
			var divDay = div.clone().addClass("col-xs-3 hidden-sm hidden-md hidden-lg").html('&nbsp;');
			var divDoctor = div.clone().addClass("doctor col-xs-6 col-sm-2").text(requestConsultList[i].requestDeptCd + ' / ' + requestConsultList[i].requestDrNm);
			var divDate = div.clone().addClass("out col-xs-3 col-sm-2 pdr0 letter-control").text(requestConsultList[i].visitDt==''? '': moment(requestConsultList[i].visitDt).format('YYYY-MM-DD'));
			
			var divPatientInfo = div.clone().addClass("list-row container").append(divNumHospital).append(divName).append(divNum).append(divEmpty).append(divDay).append(divDoctor).append(divDate);
			
			var divRequest = $("<strong></strong>").text("의뢰: ");
			var spanRequest = span.clone().addClass("date1").text(requestConsultList[i].requestDt!=undefined&&requestConsultList[i].requestDt!=null&&requestConsultList[i].requestDt!=''? moment(requestConsultList[i].requestDt).format('YYYY-MM-DD'):'');
			var divReply = $("<strong></strong>").text("회신: ");
			var spanReply = span.clone().addClass("date1").text(requestConsultList[i].responseDtTm!=undefined&&requestConsultList[i].responseDtTm!=null&&requestConsultList[i].responseDtTm!=''? moment(requestConsultList[i].responseDtTm).format('YYYY-MM-DD'): '');
			var divTreatmentDate = div.clone().addClass("list-row container text-center list-row-3").append(div.clone().addClass("col-xs-12 col-sm-12").append(
					divRequest).append(spanRequest).append(divReply).append(spanReply));
			
			
			$requestUlConsultList.append(li.clone().append(a.clone().addClass("list-group-item").attr('consultNo', i).append(divPatientInfo).append(divTreatmentDate)));
		};
		$("#requestUlConsultList .list-group-item").on("click", function(e){
			var consultInfo = requestConsultList[e.currentTarget.attributes.consultNo.value];
			consultInfo.treatDt = consultInfo.visitDt;
			consultInfo.treatTyp = consultInfo.consultTyp;
			localStorage.setItem('patientInfo', JSON.stringify(consultInfo));
			
			$('#patientPopup .popup-content').removeClass('in');
			$('#patientPopup #popContentConsultDetail').addClass('in');
			$('#newPopupFooter2').css('display', 'block');
			$('#patientPopup').css({'height': '-webkit-calc(100% - 40px)',
									 'height': '-moz-calc(100% - 40px)',
									 'height': 'calc(100% - 40px)',
									 'bottom': '0px',
									 'display': 'block'});
			mplusPatient.consultInit();
			
			/*$('.popFootContent button, .footContent button').removeClass('active');
			$('#headerTitle1').text("협진");
			$('#prescriptionContent, #examineContent, #detailContent').css('display', 'none');
			$('#consultDetailContent').css('display', 'block');
			$('#pageDetail').unbind();
			$('#pageDetail').modal('show');
			$('#consultDetailContent').scrollTop(0);*/
			
			/*var mplusDetail = new mplus_mobile_patientDetail();*/
			/*location.href = contextPath + '/mobile/patient/consultDetail.page';*/
			/*$('#pageDetail').on('hidden.bs.modal', function() {
				$('.popFootContent button').removeClass('active');
			});*/
		})
	} 
	/*----------------------- 회신 resource 종료 ----------------------*/
	
};
