/**
* mplus_mobile_operation
*/
var mplus_mobile_operation = function(){
//상속
mplus_common.call(this);
//super
var self = this;
//변수
var div = $("
");
var tr = $("
");
var th = $(" | ");
var td = $(" | ");
var table = $("");
var li = $("");
var a = $("");
var span = $("");
var button = $("");
var $opViewToDt = $('#opViewToDt'),
$opViewFmDt = $('#opViewFmDt'),
$opTotalNumSpan = $('#opTotalNumSpan'),
$opSearchBtn = $('#opSearchBtn'),
$ulOperationList = $('#ulOperationList'),
$opSortOpenBtn = $('#opSortOpenBtn'),
$anesViewToDt = $('#anesViewToDt'),
$anesViewFmDt = $('#anesViewFmDt'),
$anesTotalNumSpan = $('#anesTotalNumSpan'),
$anesSearchBtn = $('#anesSearchBtn'),
$ulAnesthesiaList = $('#ulAnesthesiaList'),
$anesSortOpenBtn = $('#anesSortOpenBtn'),
$trViewToDt = $('#trViewToDt'),
$trViewFmDt = $('#trViewFmDt'),
$trTotalNumSpan = $('#trTotalNumSpan'),
$trSearchBtn = $('#trSearchBtn'),
$ulTreatmentList = $('#ulTreatmentList'),
$trSortOpenBtn = $('#trSortOpenBtn');
var today = new Date();
var prevDay = new Date(Date.parse(new Date()) - 6 * 1000 * 60 * 60 * 24); //일주일전!!
var operatingList = [];
var anesthesiaList = [];
var treatmentList = [];
var deptList = new Array();
self.hospital.getDeptList('D', function(result) {
var sltList = result;
$('#opDepartmentCd').empty();
$('#anesDepartmentCd').empty();
$('#trDepartmentCd').empty();
var totalOption = $('').clone().attr('value', '%').text('전체');
$('#opDepartmentCd, #anesDepartmentCd, #trDepartmentCd').append(totalOption);
for(var i=0; i').clone().attr('value', sltList[i].departmentCd)
.text(sltList[i].operatingDeptNm);
$('#opDepartmentCd, #anesDepartmentCd, #trDepartmentCd').append(option);
};
$('#opDepartmentCd').val('%');
$('#anesDepartmentCd').val('%');
$('#trDepartmentCd').val('%');
});
self.hospital.getOpCntrList(function(result) {
var OpCntrList = result;
$('#opOperatingCntr').empty();
$('#anesOperatingCntr').empty();
var totalOption = $('').clone().attr('value', '%').text('전체');
$('#opOperatingCntr, #anesOperatingCntr').append(totalOption);
for(var i=0; i').clone().attr('value', OpCntrList[i].operatingCntrCd)
.text(OpCntrList[i].operatingCntrNm);
$('#opOperatingCntr, #anesOperatingCntr').append(option);
};
$('#opOperatingCntr').val('%');
$('#anesOperatingCntr').val('%');
});
self.hospital.getTrCntrList(function(result) {
var TrCntrList = result;
$('#trTreatmentCntr').empty();
var totalOption = $('').clone().attr('value', '%').text('전체');
$('#trTreatmentCntr').append(totalOption);
for(var i=0; i').clone().attr('value', TrCntrList[i].treatmentCntrCd)
.text(TrCntrList[i].treatmentCntrNm);
$('#trTreatmentCntr').append(option);
};
$('#trTreatmentCntr').val('%');
});
// self.hospital.getOpRoomList( "MOR", function(result) {
// var opRoomList = result;
// $('#opOperatingRoom').empty();
// $('#anesOperatingRoom').empty();
// var totalOption = $('').clone().attr('value', '%').text('전체');
// $('#opOperatingRoom, #anesOperatingRoom').append(totalOption);
//
// for(var i=0; i').clone().attr('value', opRoomList[i].operatingRoomCd)
// .text(opRoomList[i].operatingRoomNm);
// $('#opOperatingRoom, #anesOperatingRoom').append(option);
// };
// $('#opOperatingRoom').val('%');
// $('#anesOperatingRoom').val('%');
// });
/**
* 초기화
*/
this.init = function(){
operatingInit();
operatingAddEvent();
searchOperatingList();
var sortList = new Array();
sortList = [{key: 'operatingDeptNm', type: 'string', value: '집도과순'},
{key: 'operatingRoom', type: 'string', value: '수술방번호순'},
{key: 'patientNm', type: 'string', value: '이름순'}];
sortInit(sortList);
$('#operatingTab a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
patientInfoInit();
if($("ul#operatingTab.nav-tabs li.active a").attr('aria-controls')=='tabOperating'){
operatingInit();
operatingAddEvent();
sortList = [{key: 'operatingDeptNm', type: 'string', value: '집도과순'},
{key: 'operatingRoom', type: 'string', value: '수술방번호순'},
{key: 'patientNm', type: 'string', value: '이름순'}];
sortInit(sortList);
searchOperatingList();
}else if($("ul#operatingTab.nav-tabs li.active a").attr('aria-controls')=='tabAnesthesia'){
anesthesiaInit();
anesthesiaAddEvent();
sortList = [{key: 'operatingDeptNm', type: 'string', value: '집도과순'},
{key: 'operatingRoom', type: 'string', value: '수술방번호순'},
{key: 'patientNm', type: 'string', value: '이름순'}];
sortInit(sortList);
searchAnesthesiaList();
}else if($("ul#operatingTab.nav-tabs li.active a").attr('aria-controls')=='tabTreatment'){
treatmentInit();
treatmentAddEvent();
sortList = [{key: 'operatingDeptNm', type: 'string', value: '시술과순'},
{key: 'treatmentCntrCd', type: 'string', value: '시술실순'},
{key: 'patientNm', type: 'string', value: '이름순'}];
sortInit(sortList);
searchTreatmentList();
}else{
/*slef.aler('에러메시지?');*/
};
});
};
var patientInfoInit = function(){
$('#divId').text('');
$('#divOpPatientName').text('');
$('#divOpDoctorName').text('');
$('#divAnesthesiaDrNm').text('');
$('#divOperatingCntr').text('');
$('#divOpName1').text('');
$('#divOpTime').text('');
$('#divAnTime').text('');
$('#divAnesMethod').text('');
$('#divOperatingSticksOut').text('');
};
/*-----------------수술 탭---------------------*/
var operatingInit = function(){
var todayDateStr = moment(today).format('YYYY-MM-DD');
/*var prevDayStr = moment(prevDay).format('YYYY-MM-DD');*/
$opViewToDt.val(todayDateStr);
$opViewFmDt.val(todayDateStr);
$('.anDisplayOnly').css('display', 'none');
$('.trDisplayOnly').css('display', 'none');
$('.opDisplayOnly').css('display', 'block');
$('.trDisplayNone').css('display', 'block');
$('#opDepartmentCd').val('%');
$('#opOperatingCntr').val('%');
$('#opOperatingRoom').val('%');
$('[id*=opOperatingTyp]').prop('checked', false);
$('#opOperatingTypAll').prop('checked', true);
if( self.isTablet() ) {
$('.tablet-header-ctrl').addClass('text-center');
}
operatingList = [];
$opTotalNumSpan.text(0);
$ulOperationList.empty();
};
/**
* 이벤트 등록
*/
var operatingAddEvent = function(){
$opSearchBtn.unbind();
$opSearchBtn.on("click", function(e){
$('.header span').css('display', 'none');
searchOperatingList();
});
$opSortOpenBtn.unbind();
$opSortOpenBtn.on("click", function(e){
$('#sortModal').modal('show');
});
$('#sortConfirmBtn').unbind();
$('#sortConfirmBtn').on("click", function(e){
$('#sortModal').modal('hide');
sortOperatingList($('#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');
});
$('#opOperatingTypAll').unbind();
$('#opOperatingTypAll').change(function(e){
if(e.currentTarget.checked){
$('[id*=opOperatingTyp]:not(#opOperatingTypAll)').prop('checked', false);
}
});
$('[id*=opOperatingTyp]:not(#opOperatingTypAll)').unbind();
$('[id*=opOperatingTyp]:not(#opOperatingTypAll)').change(function(e){
if(e.currentTarget.checked && $('#opOperatingTypAll').prop('checked')){
$('#opOperatingTypAll').prop('checked', false);
}
});
// 수술실 변경
$('#opOperatingCntr').unbind();
$('#opOperatingCntr').on("change", function(e){
if( e.currentTarget.value == '') return;
changeOpOperatingRoom(e.currentTarget.value);
});
};
// 수술실 리스트 변경시, 방 목록 재로드
var changeOpOperatingRoom = function( ParamOperatingCntr){
self.hospital.getOpRoomList( ParamOperatingCntr, function(result) {
var opRoomList = result;
$('#opOperatingRoom').empty();
var totalOption = $('').clone().attr('value', '%').text('전체');
$('#opOperatingRoom').append(totalOption);
for(var i=0; i').clone().attr('value', opRoomList[i].operatingRoomCd)
.text(opRoomList[i].operatingRoomNm);
$('#opOperatingRoom').append(option);
};
$('#opOperatingRoom').val('%');
});
};
var sortOperatingList = function(key, type, method){
operatingList = self.util.sortObj(operatingList, key, type, method);
bindingOperatingList(operatingList);
};
var searchOperatingList = function(){
if($opViewToDt.val()=='' || $opViewFmDt.val()==''){
self.alert('조회 일자를 입력해주세요.');
return;
}
if(self.dateCalc($opViewFmDt.val(), $opViewToDt.val())>6){
self.alert('조회 기간은 7일이내로 설정해주세요.');
return;
}else if(self.dateCalc($opViewFmDt.val(), $opViewToDt.val())<0){
self.alert('조회 기간을 확인해주세요.');
return;
}
if($('[id*=opOperatingTyp]:checked').length<1){
$('#opOperatingTypAll').prop('checked', true);
}
patientInfoInit();
$ulOperationList.empty();
operatingList = [];
var param = {
startDt: moment($opViewFmDt.val()).format('YYYYMMDD'),
endDt: moment($opViewToDt.val()).format('YYYYMMDD'),
operatingCntrCd: $('#opOperatingCntr').val(),
departmentCd: $('#opDepartmentCd').val(),
operatingRoomCd: $('#opOperatingRoom').val(),
operatingDrNm: '%',
operatingTyp1: ($('#opOperatingTypAll').prop('checked') || $('#opOperatingTyp1').prop('checked'))? '1': '0',
operatingTyp2: ($('#opOperatingTypAll').prop('checked') || $('#opOperatingTyp2').prop('checked'))? '1': '0',
operatingTyp3: ($('#opOperatingTypAll').prop('checked') || $('#opOperatingTyp3').prop('checked'))? '1': '0'
};
self.schedule.getOpSchedule(param);
bindingOperatingList(operatingList, null);
};
bindingOperatingList = function(bindOperatingList, extraMsg){
$ulOperationList.empty();
$opTotalNumSpan.text(bindOperatingList.length);
operatingList = bindOperatingList;
if(operatingList.length==0){
$ulOperationList.append(li.clone().append(div.clone().addClass('text-center no-result').text('―')));
}
for(var i=0; i').clone().attr('value', '%').text('전체');
$('#anesOperatingRoom').append(totalOption);
for(var i=0; i').clone().attr('value', opRoomList[i].operatingRoomCd)
.text(opRoomList[i].operatingRoomNm);
$('#anesOperatingRoom').append(option);
};
$('#anesOperatingRoom').val('%');
});
};
var sortAnesthesiaList = function(key, type, method){
anesthesiaList = self.util.sortObj(anesthesiaList, key, type, method);
bindingAnesthesiaList(anesthesiaList);
};
var searchAnesthesiaList = function(){
if($anesViewToDt.val()=='' || $anesViewFmDt.val()==''){
self.alert('조회 일자를 입력해주세요.');
return;
};
if(self.dateCalc($anesViewFmDt.val(), $anesViewToDt.val())>6){
self.alert('조회 기간은 7일이내로 설정해주세요.');
return;
}else if(self.dateCalc($anesViewFmDt.val(), $anesViewToDt.val())<0){
self.alert('조회 기간을 확인해주세요.');
return;
};
if($('[id*=anesOperatingTyp]:checked').length<1){
$('#anesOperatingTypAll').prop('checked', true);
};
patientInfoInit();
$ulAnesthesiaList.empty();
anesthesiaList = [];
var param = {
startDt: moment($anesViewFmDt.val()).format('YYYYMMDD'),
endDt: moment($anesViewToDt.val()).format('YYYYMMDD'),
operatingCntrCd: $('#anesOperatingCntr').val(),
departmentCd: $('#anesDepartmentCd').val(),
operatingRoomCd: $('#anesOperatingRoom').val(),
operatingDrNm: '%',
operatingTyp1: ($('#anesOperatingTypAll').prop('checked') || $('#anesOperatingTyp1').prop('checked'))? '1': '0',
operatingTyp2: ($('#anesOperatingTypAll').prop('checked') || $('#anesOperatingTyp2').prop('checked'))? '1': '0',
operatingTyp3: ($('#anesOperatingTypAll').prop('checked') || $('#anesOperatingTyp3').prop('checked'))? '1': '0'
};
self.schedule.getAnSchedule(param);
bindingAnesthesiaList(anesthesiaList, null);
};
bindingAnesthesiaList = function(bindAnesthesiaList, extraMsg){
$ulAnesthesiaList.empty();
$anesTotalNumSpan.text(bindAnesthesiaList.length);
anesthesiaList = bindAnesthesiaList;
if(anesthesiaList.length==0){
$ulAnesthesiaList.append(li.clone().append(div.clone().addClass('text-center no-result').text('―')));
}
for(var i=0; i6){
self.alert('조회 기간은 7일이내로 설정해주세요.');
return;
}else if(self.dateCalc($trViewFmDt.val(), $trViewToDt.val())<0){
self.alert('조회 기간을 확인해주세요.');
return;
}
if($('[id*=trTreatmentTyp]:checked').length<1){
$('#trTreatmentTypAll').prop('checked', true);
}
patientInfoInit();
$ulTreatmentList.empty();
treatmentList = [];
var param = {
startDt: moment($trViewFmDt.val()).format('YYYYMMDD'),
endDt: moment($trViewToDt.val()).format('YYYYMMDD'),
treatTyp: $('#trTreatTyp').val(),
departmentCd: $('#trDepartmentCd').val(),
treatmentCntrCd: $('#trTreatmentCntr').val(),
treatmentTyp1: $('#trTreatmentTyp1').prop('checked')? '1': '0',
treatmentTyp2: $('#trTreatmentTyp2').prop('checked')? '1': '0',
treatmentTyp3: $('#trTreatmentTyp3').prop('checked')? '1': '0'
};
self.schedule.getTrSchedule(param);
bindingTreatmentList(treatmentList, null);
};
bindingTreatmentList = function(bindTreatmentList, extraMsg){
$ulTreatmentList.empty();
$trTotalNumSpan.text(bindTreatmentList.length);
treatmentList = bindTreatmentList;
if(treatmentList.length==0){
$ulTreatmentList.append(li.clone().append(div.clone().addClass('text-center no-result').text('―')));
}
for(var i=0; i