/** * mplus_mobile_patient */ var mplus_mobile_patient = function(){ // 상속 mplus_common.call(this); // super var self = this; //변수 var div = $("
"); var tr = $(""); var th = $(""); var td = $(""); var table = $("
"); var thead = $(""); var tbody = $(""); var li = $("
  • "); var a = $(""); var span = $(""); var button = $(""); //기본 var $searchBtn = $('#searchBtn'), $recentSearchBtn = $('#recentSearchBtn'), $ulPatientList = $('#ulPatientList'); //처방 var $prescriptionPatientName = $('#prescriptionPatientName'), $prescriptionDtpSrchdd = $('#prescriptionDtpSrchdd'), $prescriptionSelectdd = $('#prescriptionSelectdd'), $prescriptionSelectbox = $('#prescriptionSelectbox'), $prescriptionList = $('#prescriptionList'); var patientInfo; var prescribeInfo; var prescribeList = []; //검사 var $patientName = $('#patientName'), $btnExamSearch = $('#btnExamSearch'), $datepicker = $('#datepicker'), $selectbox = $('#selectbox'), $examineList = $('#examineList'), $examinePlusBtn = $('#examinePlusBtn'), $examinePrevBtn = $('#prevExamBtn'), $examineNextBtn = $('#nextExamBtn'), examInfo; targetExamSeq = 0; // EMR $emrPrevBtn = $('#prevEmrBtn'); $emrNextBtn = $('#nextEmrBtn'); /** * 초기화 */ this.detailInit = function(){ $('.bottom-menu.selected').removeClass('selected'); $('[name=btnMoveDetail]').addClass('selected'); headerTitle.text("환자정보"); detailBinding(); }; this.prescriptionInit = function(){ $('.bottom-menu.selected').removeClass('selected'); $('[name=btnMovePrescription]').addClass('selected'); headerTitle.text("환자정보"); patientInfo = JSON.parse(localStorage.getItem('patientInfo')); $prescriptionPatientName.text(patientInfo.patientNm + ' ' + patientInfo.patientId); prescriptionAddEvent(); // 조회일자를 오늘날짜로 변경 - 2017/01/18 var today = moment(new Date()).format('YYYY-MM-DD'); $prescriptionDtpSrchdd.val(today); $('#prescriptionSelectbox').val('sel'); // 외래환자일 경우 날짜 선택을 과거 진료일자들 콤보박스로 할수있도록 함 if( patientInfo.treatTyp =='O') { $('#prescriptionDtpSrchdd').css('display', 'none'); $('#prescriptionSelectdd').css('display', 'block'); $('#prescriptionSelectdd').empty(); var param = { patientId: patientInfo.patientId, departmentCd: patientInfo.departmentCd==undefined? patientInfo.requestDeptCd: patientInfo.departmentCd, treatDt: patientInfo.treatDt }; var pastTreatDateList = self.treatment.getPastTreatDate(param); // 최근 10개만 표시 for(var i=0; (i').clone().attr('value', pastTreatDateList[i].treatDt) .text(moment(pastTreatDateList[i].treatDt).format('YYYY-MM-DD')); $('#prescriptionSelectdd').append(option); } // 오늘의 외래환자가 아닌경우 진료일자에 오늘이 포함되어있지 않으므로, 초기 조회날짜 변수 today를 첫번째 진료날짜로 바꿔치기함 today = pastTreatDateList[0].treatDt; } else { $('#prescriptionDtpSrchdd').css('display', 'block'); $('#prescriptionSelectdd').css('display', 'none'); } searchPrescriptionList(today, "sel"); }; this.examineInit = function(){ $('.bottom-menu.selected').removeClass('selected'); $('[name=btnMoveExamine]').addClass('selected'); headerTitle.text("환자정보"); patientInfo = JSON.parse(localStorage.getItem('patientInfo')); var today = new Date(); var prevDay = new Date(Date.parse(new Date()) - 365 * 1000 * 60 * 60 * 24); //일년전!! $('#examEndSrchdd').val(moment(today).format('YYYY-MM-DD')); $('#examStartSrchdd').val(moment(prevDay).format('YYYY-MM-DD')); searchExamineList(); //var categorys = ['검체검사', '기능검사', '병리검사', '영상검사']; //examineTreeCtrl.init(categorys); examineAddEvent(); //var today = new Date(); //$('#dtpSrchdd1').val(moment(today).format('YYYY-MM-DD')); }; this.consultInit = function(){ headerTitle.text("협진상세"); initConsultDetail(); }; this.emrInit = function(){ headerTitle.text("환자정보"); emrAddEvent(); searchEmrList(); }; /** * 이벤트 등록 */ var prescriptionAddEvent = function(){ $prescriptionDtpSrchdd.unbind(); $prescriptionDtpSrchdd.change(function(){ $('#prescriptionSelectbox').val('sel'); searchPrescriptionList($('#prescriptionDtpSrchdd').val(), $('#prescriptionSelectbox option:selected').val()); }); $prescriptionSelectdd.unbind(); $prescriptionSelectdd.change(function(){ $('#prescriptionSelectbox').val('sel'); searchPrescriptionList($('#prescriptionSelectdd').val(), $('#prescriptionSelectbox option:selected').val()); }); $prescriptionSelectbox.unbind(); $prescriptionSelectbox.change(function(){ bindingPrescription(prescribeList, $('#prescriptionSelectbox option:selected').val()); }); }; var examineAddEvent = function(){ $btnExamSearch.unbind(); $btnExamSearch.click(function(){ searchExamineList(); }); }; var examineInfoAddEvent = function() { // 이동할 때 로딩 뜨면 좋은데 어떻게 해도 안되네 ㅜㅜ $examinePrevBtn.unbind(); $examinePrevBtn.on('click', function(e){ if(targetExamSeq == 0) { self.alert('첫번째 검사입니다.'); return; } targetExamSeq--; bindExaminInfo(targetExamSeq); }); $examineNextBtn.unbind(); $examineNextBtn.on('click', function(e){ if(targetExamSeq + 1 == examList.length) { self.alert('마지막 검사입니다.'); return; } targetExamSeq++; bindExaminInfo(targetExamSeq); }); } //기본 데이터 바인딩 var detailBinding = function(){ var patient = JSON.parse(localStorage.getItem('patientInfo')); var param; if(patient.treatTyp=='I'||patient.consultTyp=='I'){ //patient.treatTyp=='I'인 경우는 없긴하다. 데이터 정상적으로 다 들어오면 테스트해보기.171103 param = { patientId: patient.patientId, treatTyp: 'I'/*, deptCode: patient.departmentCd==undefined? patient.reqDeptCode: patient.departmentCd*/ }; }else if(patient.treatTyp=='O'||patient.consultTyp=='O'){ param = { patientId: patient.patientId, treatTyp: 'O', departmentCd: patient.departmentCd==undefined? patient.reqDeptCode: patient.departmentCd, treatDt: patient.treatDt }; }else if(patient.treatTyp=='E'||patient.consultTyp=='E'){ param = { patientId: patient.patientId, treatTyp: 'E'/*, deptCode: patient.departmentCd==undefined? patient.reqDeptCode: patient.departmentCd, treatDate: patient.treatDt*/ }; }else{ } var patientInfo = self.patient.getPatInfo(param); $('#patientPopupNum').text(patientInfo.patientId); $('#patientPopupName').text(patientInfo.patientNm); $('#patientPopupBirth').text(patientInfo.birthDt!=''? moment(patientInfo.birthDt).format('YYYY-MM-DD'): ''); $('#patientPopupSex').text(patientInfo.gender + ' / ' + patientInfo.age); $('#patientPopupBloodTyp').text(patientInfo.bloodTyp); $('#patientPopupCellphone').text(patientInfo.cellphoneNo); $('#patientPopupGuardianphone').text(patientInfo.guardianPhoneNo); $('#patientPopupAddress').text(patientInfo.address); if(patientInfo.cellphoneNo!=undefined && patientInfo.cellphoneNo!=null&& patientInfo.cellphoneNo!=''){ $('#patientTelBtnBox').css('display', 'block'); $('#patientTelBtn').unbind(); $('#patientTelBtn').on('click', function(e){ location.href = 'tel:'+patientInfo.cellphoneNo; }); $('#patientSmsBtn').unbind(); $('#patientSmsBtn').on('click', function(e){ location.href = 'sms:'+patientInfo.cellphoneNo; }); }else{ $('#patientTelBtnBox').css('display', 'none'); } if(patientInfo.guardianPhoneNo!=undefined && patientInfo.guardianPhoneNo!=null&& patientInfo.guardianPhoneNo!=''){ $('#guardianTelBtnBox').css('display', 'block'); $('#guardianTelBtn').unbind(); $('#guardianTelBtn').on('click', function(e){ location.href = 'tel:'+patientInfo.guardianPhoneNo; }); $('#guardianSmsBtn').unbind(); $('#guardianSmsBtn').on('click', function(e){ location.href = 'sms:'+patientInfo.guardianPhoneNo; }); }else{ $('#guardianTelBtnBox').css('display', 'none'); } }; //처방 데이터바인딩 var searchPrescriptionList = function(date, type){ $prescriptionList.empty(); prescribeList = []; $('#prescriptionList').removeClass(); var patientInfo = JSON.parse(localStorage.getItem('patientInfo')); var param = {}; if(patientInfo.treatTyp == 'I' || patientInfo.consultTyp == 'I' || patientInfo.treatTyp=='E'){ param = { patientId: patientInfo.patientId, treatDt: patientInfo.inDt ==undefined? patientInfo.treatDt: patientInfo.inDt, prescriptionDt: moment(date).format('YYYYMMDD') }; }else{ param = { patientId: patientInfo.patientId, departmentCd: patientInfo.departmentCd==undefined? patientInfo.requestDeptCd: patientInfo.departmentCd, treatTyp: patientInfo.treatTyp==undefined? patientInfo.consultTyp: patientInfo.treatTyp, prescriptionDt: moment(date).format('YYYYMMDD') }; } self.patient.getPatPrescribeList(param, type, function(prescribeList, type) {bindingPrescription(prescribeList, type);}); }; var prescriptionCdArr = [ {prescriptionCd: 'A', prescriptionCdNm : '마취', prescriptionList: []}, {prescriptionCd: 'B', prescriptionCdNm : '진료예약', prescriptionList: []}, {prescriptionCd: 'C', prescriptionCdNm : '협진', prescriptionList: []}, {prescriptionCd: 'D', prescriptionCdNm : '식이', prescriptionList: []}, {prescriptionCd: 'G', prescriptionCdNm : '진단서', prescriptionList: []}, {prescriptionCd: 'H', prescriptionCdNm : '퇴원처방', prescriptionList: []}, {prescriptionCd: 'L', prescriptionCdNm : '진단검사', prescriptionList: []}, {prescriptionCd: 'M', prescriptionCdNm : '소모품', prescriptionList: []}, {prescriptionCd: 'O', prescriptionCdNm : '수술', prescriptionList: []}, {prescriptionCd: 'P', prescriptionCdNm : '약', prescriptionList: []}, {prescriptionCd: 'Q', prescriptionCdNm : '병실이동', prescriptionList: []}, {prescriptionCd: 'R', prescriptionCdNm : '통합검사', prescriptionList: []}, {prescriptionCd: 'S', prescriptionCdNm : '입원결정', prescriptionList: []}, {prescriptionCd: 'T', prescriptionCdNm : '처치', prescriptionList: []}, {prescriptionCd: 'W', prescriptionCdNm : '전과', prescriptionList: []}, {prescriptionCd: 'X', prescriptionCdNm : '기타', prescriptionList: []}, {prescriptionCd: 'Y', prescriptionCdNm : '건진', prescriptionList: []}, {prescriptionCd: 'Z', prescriptionCdNm : '메시지', prescriptionList: []}]; var prescriptionStatArr = [ {prescriptionStat: '00', prescriptionStatNm : '처방'}, {prescriptionStat: '01', prescriptionStatNm : '약신청'}, {prescriptionStat: '05', prescriptionStatNm : '대기'}, {prescriptionStat: '10', prescriptionStatNm : '출력'}, {prescriptionStat: '11', prescriptionStatNm : '조제완료'}, {prescriptionStat: '12', prescriptionStatNm : '조제취소'}, {prescriptionStat: '13', prescriptionStatNm : '불출'}, {prescriptionStat: '14', prescriptionStatNm : 'List출력'}, {prescriptionStat: '30', prescriptionStatNm : '채혈'}, {prescriptionStat: '31', prescriptionStatNm : '접수'}, {prescriptionStat: '32', prescriptionStatNm : '예약'}, {prescriptionStat: '33', prescriptionStatNm : '도착'}, {prescriptionStat: '34', prescriptionStatNm : '주사'}, {prescriptionStat: '35', prescriptionStatNm : '검사대기'}, {prescriptionStat: '36', prescriptionStatNm : 'RI주문'}, {prescriptionStat: '37', prescriptionStatNm : '검체도착'}, {prescriptionStat: '38', prescriptionStatNm : '검사중'}, {prescriptionStat: '39', prescriptionStatNm : '투여중'}, {prescriptionStat: '40', prescriptionStatNm : '시행'}, {prescriptionStat: '41', prescriptionStatNm : '완료'}, {prescriptionStat: '42', prescriptionStatNm : '서명대기'}, {prescriptionStat: '49', prescriptionStatNm : 'Rec.'}, {prescriptionStat: '50', prescriptionStatNm : '예결'}, {prescriptionStat: '51', prescriptionStatNm : '결과'}, {prescriptionStat: '90', prescriptionStatNm : '보류'}, {prescriptionStat: '91', prescriptionStatNm : '종료'}, {prescriptionStat: '92', prescriptionStatNm : '종료'}, {prescriptionStat: '93', prescriptionStatNm : '종료'}, {prescriptionStat: '95', prescriptionStatNm : '종료'}]; var bindingPrescription = function(prescribeListData, type){ $prescriptionList.empty(); prescribeList = prescribeListData; if(type=='sel'){ $prescriptionList.addClass("panel-group panel-group-joined"); prescriptionCdArr.forEach(function(item){item.prescriptionList.length = 0;}); for ( var i = 0; i < prescribeListData.length ; i++ ){ /* 2018.06.18. 안드로이드 호환 변경 prescriptionCdArr.find(function(item, index, array) { if( item.prescriptionCd == prescribeListData[i].prescriptionCd) { array[index].prescriptionList.push(prescribeListData[i]); return true; }}); */ for(var j=0; j 0 ) { bindingPrescriptionList(prescriptionCdArr[i].prescriptionList, type, prescriptionCdArr[i].prescriptionCdNm); } } }else if(type=='presno'){ $prescriptionList.addClass("panel-group panel-group-joined"); var groupingPresNo = []; for( var i = 0; i < prescribeListData.length; i++) { var presIndex = groupingPresNo.map(function(item){ return item.prescriptionNo;}).indexOf(prescribeListData[i].prescriptionNo); if(presIndex == -1) { //처음보는 처방번호 var prescription = {}; prescription.prescriptionNo = prescribeListData[i].prescriptionNo; prescription.prescriptionList = [ prescribeListData[i] ]; groupingPresNo.push(prescription); } else { // 봤던 처방번호 groupingPresNo[presIndex].prescriptionList.push(prescribeListData[i]); } } for ( var i = 0; i < groupingPresNo.length ; i++ ){ bindingPrescriptionList(groupingPresNo[i].prescriptionList, type, groupingPresNo[i].prescriptionNo); } } }; var bindingPrescriptionList = function(prescribeList, type, selName){ var divPanelHeading = div.clone().addClass("panel-heading"); var h4 = $("

    ").addClass("panel-title"); var h4A = $("