"use strict"; /** * mplus_medicine */ var mplus_medicine = function() { // 상속 mplus_common.call(this); var self = this; var patientData = []; var medicineList = []; var medicineSelectItem = []; var myTimer; var actTypeCheck = "EMR"; this.init = function() { //여기서 모든화면 콤보박스데이터를 집어넣자!!! 그래야지 화면이동할때 속도가 오래걸리지않음!!! // 접근 권한 체크 localStorage.removeItem("defaultHomePage"); localStorage.setItem("defaultHomePage", "medicine"); checkAccessPermission(); // 초기 화면 조건 구성 initCondition(); // 이벤트 초기화 addEvent(); // 환자 검색 실행 및 환자 정보 화면 출력 //searchPatient(); // $("#txtPatientId").focus(); //gLoginUserId //gLoginUserNm }; //==== 접근 권한 체크 { ==== var checkAccessPermission = function() { //if( !self.common.checkAccessJobKind( "1000")){ // self.alertTrue("접근 권한이 없습니다.", self.common.gotoDefaultHomePage); //} //if( !self.common.checkAccessUserAuth( "01")){ // self.alertTrue("접근 권한이 없습니다.", self.common.gotoDefaultHomePage); //} //self.common.disableElements( $("#myModalBtn")); }; //==== 접근 권한 체크 } ==== //==== 초기화 설정 { ==== var initCondition = function() { // 초기 화면 조건 구성 //환자정보 초기화 initPatientInfo(); StartTimer(); // 콤보박스 시간 Setting actionHourSetting(); // 콤보박스 시간 Setting var strCurDate = self.util.toDate(new Date()); $("#spanDate").text(strCurDate); $("#todayDate").text(strCurDate); }; /** * 콤보박스 시간과 분을 세팅 */ function actionHourSetting() { var today = new Date(); var todayHH = today.getHours(); var todayMM = today.getMinutes(); if (todayHH < 10) { todayHH = "0" + todayHH } if (todayMM < 10) { todayMM = "0" + todayMM } var time = ""; var value = ""; // SelectBox Hour Setting for (var i = 0; i < 24; i++) { if (i < 10) { value = "0" + i; } else { value = i; } time += ""; } $("#actionHour").empty(); $("#actionHour").append(time); $("#actionHour").val(todayHH); $("#actionHour").off("focus"); // SelectBox Minute Setting time = ""; for (var i = 0; i < 60; i++) { if (i < 10) { value = "0" + i; } else { value = i; } time += " "; } $("#actionMinute").empty(); $("#actionMinute").append(time); $("#actionMinute").val(todayMM); $("#actionMinute").off("focus"); }; function StartTimer() { clearInterval(myTimer); myTimer = setInterval(actingTimer ,1000); } function ClearTimer() { clearInterval(myTimer); } var actingTimer = function() { var today = new Date(); var todayHH = today.getHours(); var todayMM = today.getMinutes(); if (todayHH < 10) { todayHH = "0" + todayHH } if (todayMM < 10) { todayMM = "0" + todayMM } if (String(todayHH) + String(todayMM) > $("#actionHour").val() + $("#actionMinute").val(todayMM)) { $("#actionMinute").val(todayMM); $("#actionHour").val(todayHH); } }; /** * 환자 정보 초기화 */ var initPatientInfo = function() { $("#txtPatientId").val(""); $("#patientName").text("환자명"); $("#patientName button").attr("style", "display: none"); $("#patient-gender-age").text("환자정보"); $("#spanWard").text("실시부서"); $("#spanAcrionUserName").text("실시자명 (사번)"); }; /** * 리스트 초기화 */ function emptyMedicine() { $("#listItem").remove(); $("#divScanMsg").attr("style", "display: ;"); StartTimer(); } //==== 이벤트 설정 { ==== var addEvent = function() { // 컬럼 클릭의 정렬 이벤트 // eventColumnClick(); // // eventRowClick(); // eventCondition(); medicineActionEvent(); eventBackBlock(); // // eventBackBlock(); }; //검색 페이지 뒤로가기 막기 var eventBackBlock = function(){ $(window).off("backbutton"); $(window).bind("backbutton", function(event) { alert("clickable true"); if (event.originalEvent.persisted) { document.location.reload(); } }); }; this.barcodeCallback = function(data){ if(data.includes("PO@") == true){ var tempData = data.split("@"); var param = { hospitalCd: localStorage.getItem("hospitalCd"), AtcBarCodeData: tempData[1], }; self.safety.getAtcPrescriptionList(param, processGetAtcPrescriptionList); return; } var result = self.util.decodeBarcode(data); if(self.util.isEmpty(result)){ // modal 호출 emptyData("정보조회에 실패하였습니다.", "다시 시도해주세요."); return; } else if(result.type == 'pid'){ // 환자 바코드 스캔 var patientId = result.data; $("#txtPatientId").val(patientId); getPocPatientInfo(patientId, false); $("#txtPatientId").blur(); } else if(result.type == 'medicine'){ $("#txtPatientId").blur(); if(self.util.isEmpty(patientData) || patientData.length == 0){ emptyData('환자정보가 조회되지 않았습니다.', '환자정보를 조회하여 주세요'); return; } // 단일 투약 스캔 var aaa = [result.data]; barCodeMedicineListToggle(aaa); } // poBarcode else if (result.type == "poBarcode") { $("#txtPatientId").blur(); if(self.util.isEmpty(patientData) || patientData.length == 0){ emptyData('환자정보가 조회되지 않았습니다.', '환자정보를 조회하여 주세요'); return; } var spanDate = $("#spanDate").text().trim().split("-"); var dateStr = spanDate[0] + spanDate[1] + spanDate[2]; var dataList = new Array(); result.data.forEach(barData =>{ if(barData.date.toString() == dateStr){ dataList.push(barData.item); } }); // 투약 리스트 스캔 console.log("origndataList -- > " + dataList); barCodeMedicineListToggle(dataList); } else if (result.type == "medicineList") { if (self.util.isEmpty(result.data)) { emptyData('투약실시 바코드가 아닙니다.', '바코드를 다시 확인해주세요'); } else { barCodeMedicineListToggle(result.data); } } else{ $("#txtPatientId").blur(); emptyData('투약실시 바코드가 아닙니다.', '바코드를 다시 확인해주세요'); // $("#Modal01").modal("show"); } // // null 이라면 반환 // if(self.util.isEmpty(data)){ // return; // } // else{ // var result = self.util.decodeBarcode(data); // } // // // 환자 번호라면 // if(result.type == 'pid'){ // // 최초 리딩 시 환자 정보 초기화 // $("#txtBleedingPatientSearch").val(''); // // console.log('data: ' + result.data); // // 환자번호 표시 // $("#txtBleedingPatientSearch").val(result.data); // // 환자 정보 호출 // var param = { // hospitalCd: localStorage.getItem("hospitalCd"), // userId: gLoginUserId, // patientId: $("#txtBleedingPatientSearch").val() // }; // // self.medical.getPatientInfo(param, processGetPatientInfo); // } // // 투약 번호라면 // else if(result.type == 'specimenCd'){ // // } }; var processGetAtcPrescriptionList = function(output) { console.log("output -- > " + output); if(self.util.isEmpty(output)){ // modal 호출 emptyData("정보조회에 실패하였습니다.", "다시 시도해주세요."); return; } $("#txtPatientId").blur(); if(self.util.isEmpty(patientData) || patientData.length == 0){ emptyData('환자정보가 조회되지 않았습니다.', '환자정보를 조회하여 주세요'); return; } var outputTempData = output[0].prescriptionData.slice(0, -1); var outputData = outputTempData.split("*"); console.log("outputData -- > " + outputData); var dataList = new Array(); for (var i = 0; i < outputData.length; i++) { var result = self.util.decodeBarcode(outputData[i]); console.log("result -- > " + JSON.stringify(result)); if (result.type == "poBarcode") { var spanDate = $("#spanDate").text().trim().split("-"); var dateStr = spanDate[0] + spanDate[1] + spanDate[2]; result.data.forEach(barData =>{ if(barData.date.toString() == dateStr){ console.log("barData -- > " + barData.item); dataList.push(barData.item); } }); } } // 투약 리스트 스캔 console.log("dataList -- > " + dataList); barCodeMedicineListToggle(dataList); // for (var i = 0; i < output.length; i++) { // var result = self.util.decodeBarcode(output[i].prescriptionData); // console.log("result -- > " + JSON.stringify(result)); // if (result.type == "poBarcode") { // var spanDate = $("#spanDate").text().trim().split("-"); // var dateStr = spanDate[0] + spanDate[1] + spanDate[2]; // result.data.forEach(barData =>{ // if(barData.date.toString() == dateStr){ // dataList.push(barData.item); // } // }); // } } var eventCondition = function() { //투약일자 현재의 전 날짜를 가져온다 $("#dateMinus").off("click"); $("#dateMinus").on("click", function() { $(this).blur(); $("#spanDate").text(minusDate()); $("#medicineSearchBtn").click(); }); //투약일자 현재 이후 날짜를 가져온다 단 현재일 보다 커질 수 없다 $("#datePlus").off("click"); $("#datePlus").on("click", function() { $(this).blur(); var changeDate = plusDate(); if (changeDate == "") { } else { $("#spanDate").text(changeDate); $("#medicineSearchBtn").click(); } }); /** * 조회 버튼 클릭 이벤트 */ $("#medicineSearchBtn").off("click"); $("#medicineSearchBtn").on("click", function() { $(this).blur(); var txtSearch = $("#txtPatientId").val(); if (txtSearch == "") { $("#Modal01 .modal-body h4").text("입력된 환자번호가 없습니다."); $("#Modal01 .modal-body p").text("환자번호를 입력해주세요."); $("#Modal01").modal("show"); } else { // $("#medicineSearchBtn").removeClass("btn-secondary").addClass("btn-primary"); getPocPatientInfo($("#txtPatientId").val(), false); } }); }; $("#actionHour").change(function() { $("#actionHour option:selected").each(function() { ClearTimer(); var today = new Date(); var todayHH = today.getHours(); var todayMM = today.getMinutes(); // patientData[0].dschYn = "Y"; if (todayHH < 10) { todayHH = "0" + todayHH } if (todayMM < 10) { todayMM = "0" + todayMM } var nowActTime = String(todayHH) + String(todayMM); var selectHourValue = String($("#actionHour option:selected").val()); var nowMinVal = String($("#actionMinute").val()); if (selectHourValue + nowMinVal > nowActTime) { if (patientData.length > 0 && patientData[0].dschYn == "Y") { $("#actionHour").val(selectHourValue); } else { emptyData("시간변경 오류", "현재시간 이후로는 변경할 수 없습니다"); $("#actionMinute").val(todayMM); $("#actionHour").val(todayHH); } } }); }); $("#actionMinute").change(function() { $("#actionMinute option:selected").each(function() { ClearTimer(); var today = new Date(); var todayHH = today.getHours(); var todayMM = today.getMinutes(); // patientData[0].dschYn = "Y"; if (todayHH < 10) { todayHH = "0" + todayHH } if (todayMM < 10) { todayMM = "0" + todayMM } var nowActTime = String(todayHH) + String(todayMM); var selectMinValue = String($("#actionMinute option:selected").val()); var nowHourVal = String($("#actionHour").val()); if (nowHourVal + selectMinValue > nowActTime) { if (patientData.length > 0 && patientData[0].dschYn == "Y") { $("#actionMinute").val(selectMinValue); } else { emptyData("시간변경 오류", "현재시간 이후로는 변경할 수 없습니다"); $("#actionMinute").val(todayMM); $("#actionHour").val(todayHH); } } }); }); /** * 환자 조회 * @param {*} patientId 입력받은 환자번호 * @param {*} isSecondTrial 두 번째 호출 여부 */ var getPocPatientInfo = function(patientId, isSecondTrial) { var param = { hospitalCd: localStorage.getItem("hospitalCd"), userId: gLoginUserId, patientId: patientId, isSecondTrial: isSecondTrial }; self.safety.getPocPatientInfo(param, patientId, isSecondTrial, processGetPocPatientInfo); }; /** * 호출된 기본정보를 화면에 매핑 * @param {*} lists API 반환 데이터 * @param {*} barPid 입력받은 환자번호 * @param {*} isSecondTrial 두 번째 호출 여부 */ var processGetPocPatientInfo = function(lists, barPid, isSecondTrial) { patientData = []; actionHourSetting(); if (lists == "undefined" || lists == null || lists.length == 0) { $("#txtPatientId").val(''); $("#txtPatientId").blur(); initPatientInfo(); emptyMedicine(); emptyData("환자정보 조회 실패", "환자정보 조회에 실패하였습니다."); return; } // 1. 만일 환자 정보가 맞다면 환자 정보를 보여준다. if (barPid == lists[0].patientId) { patientData = lists; $("#patientName").text(patientData[0].patientNm); $("#patient-gender-age").text(patientData[0].age + "/" + patientData[0].gender + " " + patientData[0].roomNm + "호"); $("#spanWard").text(localStorage.getItem("selectedDeptNm")); $("#spanAcrionUserName").text(gLoginUserNm + "(" + gLoginUserId + ")"); $("#patientName").append(""); var summaryCd = patientData[0].patientSummaryCd.split(","); var spanTag = ""; for (var i = 0; i < summaryCd.length; i++) { var sCd = summaryCd[i]; if (sCd == "!") { sCd = "t"; } else if (sCd == "₩") { sCd = "w"; } spanTag = "" $("#patient-gender-age").append(spanTag); } // getPrescriptionList(lists, ""); getPrescriptionList(false); // 2. 환자 정보가 맞지 않으면 } else { // 2.1 2번째 호출이 아니면 다시 환자 정보 조회 if (!isSecondTrial) { getPocPatientInfo(barPid, true) // 2.2 2번째 호출이면 Alert } else { initPatientInfo(); emptyMedicine(); emptyData("환자정보 조회 실패", "시스템 이용량이 많습니다. 다시 조회해 주세요."); } } } /** * * @param {*} isSecondTrial 두 번째 호출 여부 */ var getPrescriptionList = function(isSecondTrial) { var medicationDt = $("#spanDate").text().split("-"); var inDd = patientData[0].inDd; var param = { hospitalCd : patientData[0].hospitalCd, userId : gLoginUserId, patientId : patientData[0].patientId, medicationDt : medicationDt[0]+medicationDt[1]+medicationDt[2], inDd : inDd, cretNo : patientData[0].cretNo, isSecondTrial: isSecondTrial } self.safety.getPrescriptionList(param, isSecondTrial, processGetPrescriptionList); } /** * * @param {*} isSecondTrial 두 번째 호출 여부 * @param {*} result API 반환 데이터 */ var processGetPrescriptionList = function(isSecondTrial, result) { medicineList = []; medicineSelectItem = []; console.log("result -- > " + JSON.stringify(result)); $("#listItem").empty(); // $("#listItem").remove(); // 반환되는 데이터가 Null 일 경우 if(self.util.isEmpty(result) || result.length == 0){ $("#divScanMsg").css("display", ""); // return emptyData("처방정보 조회", "조회된 처방정보가 없습니다."); return; } // 기존 환자정보와 반환 데이터 환자정보가 일치할 경우 if (patientData[0].patientId == result[0].patientId) { for (var i = 0; i < result.length; i++) { if (result[i].flag == "N") { medicineList.push(result[i]); } } if (medicineList.length == 0) { $("#divScanMsg").css("display", ""); return emptyData("처방정보 조회", "조회된 처방정보가 없습니다."); } // medicineList = result; $("#divScanMsg").attr("style", "display: none"); $("#con").append(""); var actionTime = []; for (var i = 0; i < medicineList.length; i++) { actionTime.push(medicineList[i].actMedicationTm); var frontAct = medicineList[i].actMedicationTm.substring(0, 2) % 24; if (frontAct < 10) { frontAct = "0" + frontAct; } else { frontAct = frontAct; } var item = "
  • " + "
    " + "
    " + "

    " + " " + frontAct + ":" + medicineList[i].actMedicationTm.substring(2, 4) // 투여시간 hh:mm + " " + "

    " + "

    " + " " + medicineList[i].prcpCd // 처방코드 + " " + "

    " + "

    " + medicineList[i].prescriptionNo // 처방 번호 + "

    " + "
    " + "
    " + "

    " + medicineList[i].prcpNm // 처방명 + "

    " + "

    " + " " + medicineList[i].prescriptionCapaDay + medicineList[i].prescriptionCapaDayUnit // 1일 용량 + 1일 용량 단위 + " " + " |" + medicineList[i].prescriptionTmDay // 일일 횟수 + " |" + medicineList[i].actMedicationInfo // 용법 + "

    " + "
    " + "
    " + " " + medicineList[i].prescriptionQtyDay + medicineList[i].prescriptionQtyDayUnit // 일일 수량 + 일일 수량 단위 + " " + "
    " + "
    " + "
  • "; $("#listItem").append(item); } medicienToggleEvent(); // 환자정보가 일치하지 않을 경우 } else { // 첫 번째 호출일 경우 if (!isSecondTrial) { getPrescriptionList(true); // 두 번째 호출하는 경우 } else { emptyData("처방정보 조회 실패", "시스템 이용량이 많습니다. 다시 조회해 주세요."); emptyMedicine(); } } StartTimer(); } function emptyData(title, message) { $("#Modal01 .modal-body h4").text(title); $("#Modal01 .modal-body p").text(message); $("#Modal01").modal("show"); } function medicienToggleEvent() { $(".list-group .list-group-item").off("dblclick"); $(".list-group .list-group-item").on("dblclick", function () { actTypeCheck = "EMR"; $(this).toggleClass('active'); var id = $(this).attr("id"); // var index = id.charAt(id.length - 1); var index = id.split("_")[1]; if ($(this).hasClass("active") == true) { medicineSelectItem[index] = medicineList[index]; } else { delete medicineSelectItem[index]; } }); } function makeCheckedItem(medicineObj, index){ var frontAct = medicineObj.actMedicationTm.substring(0, 2) % 24; if (frontAct < 10) { frontAct = "0" + frontAct; } return "
  • " + "
    " + "
    " + "

    " + " " + frontAct + ":" + medicineObj.actMedicationTm.substring(2, 4) // 투여시간 hh:mm + " " + "

    " + "

    " + " " + medicineObj.prcpCd // 처방코드 + " " + "

    " + "

    " + medicineObj.prescriptionNo // 처방 번호 + "

    " + "

    " + medicineObj.prescriptionTypeNm // 처방종류명 (경구, 주사, 마약, 수액) + "

    " + "
    " + "
    " + "

    " + medicineObj.prcpNm // 처방명 + "

    " + "

    " + " " + medicineObj.prescriptionCapaDay + medicineObj.prescriptionCapaDayUnit // 1일 용량 + 1일 용량 단위 + " " + " |" + medicineObj.prescriptionTmDay // 일일 횟수 + " |" + medicineObj.actMedicationInfo // 용법 + "

    " + "
    " + "
    " + " " + medicineObj.prescriptionQtyDay + medicineObj.prescriptionQtyDayUnit // 일일 수량 + 일일 수량 단위 + " " + "
    " + "
    " + "
  • "; } /** * ---------------------------------------------------- * List 프로토 타입 정의 시작 */ function List() { this.elements = {}; this.idx = 0; this.length = 0; } List.prototype.add = function(element) { this.length++; this.elements[this.idx++] = element; }; List.prototype.get = function(idx) { return this.elements[idx]; }; /** * LIST 프로토 타입 정의 끝 * ----------------------------------------------------- */ /** * 중복 아이템을 검사하고 중복되어 있다면 최근 시간에 가까운 * 아니라면 검색된 아이템을 반환 * @param {Array} prescriptionNo */ function checkDupItem(prescriptionNo){ var item = { index: new List(), obj: new List() }; medicineList.forEach(function(element, idx){ if(prescriptionNo == element.prescriptionNo){ item.index.add(idx); item.obj.add(element); // resultList.add(element); } }); var minIndex = 0; // 중복 발생 시 최근 아이템만 if(item.obj.length != 1){ var dayDelta = 0; var timeDelta = 0; var todayObj = moment(); var today = todayObj.format('YYYYMMDD'); var currentTime = todayObj.format('HHmm'); var toDateTime = new Date(todayObj.format('YYYY-MM-DD HH:mm')); var calDate = 0; for(var i = 0; i < item.obj.length; i++){ var tempItemObj = item.obj.get(i); var spanDate = $("#spanDate").text().trim().split("-"); var dateStr = spanDate[0] + spanDate[1] + spanDate[2]; var actMedicationTmDate = dateParse(dateStr+tempItemObj.actMedicationTm.trim()); if (i == 0) { calDate = Math.abs((toDateTime.getTime() - actMedicationTmDate.getTime())); } else { var tempValue = Math.abs(toDateTime.getTime() - actMedicationTmDate.getTime()); if(calDate > tempValue) { minIndex = i; } // if (toDateTime.getTime() > Math.abs(calDate)) { // console.log("222 -- > " + i); // // } } } } var retObj = { index: item.index.get(minIndex), obj: item.obj.get(minIndex) }; return retObj; } /** * 처방번호 스캔시 아이템 토글 * @param {String} prescriptionNo 수신 바코드 */ function barCodeMedicineListToggle(prescriptionNo) { // console.log("prescriptionNo -- > " + prescriptionNo); medicineSelectItem = []; var selectPrescription = []; // 선택된 아이템이 없다면 if(self.util.isEmpty(medicineSelectItem) || medicineSelectItem.length == 0){ $("#listItem").children().remove(); } for (var j = 0; j < prescriptionNo.length; j++) { for (var i = 0; i < medicineList.length; i++) { if (medicineList[i].prescriptionNo == prescriptionNo[j]) { selectPrescription.push(prescriptionNo[j]); } } } if (selectPrescription.length > 0) { var foundCnt = 0; for (var x = 0; x < selectPrescription.length; x++) { var medicineObj = checkDupItem(selectPrescription[x]); if (!self.util.isEmpty(medicineObj) && self.util.isEmpty(medicineSelectItem[medicineObj.index])) { medicineSelectItem[medicineObj.index] = medicineList[medicineObj.index]; var listStr = makeCheckedItem(medicineObj.obj, medicineObj.index); $("#divScanMsg").attr("style", "display: none"); $("#listItem").append(listStr); $("#medicine_" + medicineObj.index).addClass("active"); foundCnt++; } } if(foundCnt == 0){ emptyData("실시할 수 없는 투약 바코드 입니다.", ""); } } else { emptyData("조회된 처방이 없습니다.", "처방번호를 확인해주세요."); $("#divScanMsg").attr("style", "display: ;"); } actTypeCheck = "POC"; medicienToggleEvent(); }; function medicineActionEvent() { $("#medicineActionBtn").on("click", function() { $(this).blur(); var cnt = 0; var count = 0; var spanDate = $("#todayDate").text().split("-"); var actionDate = spanDate[0] + spanDate[1] + spanDate[2]; var inDdTm = patientData[0].inDd + patientData[0].inTm; var actDate = actionDate + $("#actionHour").val() + $("#actionMinute").val(); if (medicineSelectItem == null || medicineSelectItem.length == 0) { emptyData("투약할 처방을 선택하지 않았습니다.", "투약할 처방을 선택해주세요."); } else { if (inDdTm > actDate) { emptyData("실시시간이 입원일보다 빠릅니다.", "다시 확인해주시기 바랍니다."); } else { for (var key in medicineSelectItem) { cnt = cnt + 1; } for (var key in medicineSelectItem) { // console.log("asdfasdf -- > " + JSON.stringify(medicineSelectItem[i])); var hospitalCd = patientData[0].hospitalCd; // 병원코드 var userId = gLoginUserId; // 사용자 ID var prescriptionNo = medicineSelectItem[key].prescriptionNo; // 처방번호 // var actMedicationTm = $('#actionTimeCombo').val(); // 선택시간 -- > var actMedicationTm = $("#actionHour").val() + $("#actionMinute").val(); // -- > 콤보박스 수정 + 날짜 var prescriptionTypeCd = medicineSelectItem[key].prescriptionTypeCd; // 처방종류코드 (경구, 주사, 마약, 수액) var actMedicationDtTm = self.util.toDatetimeFatima2(new Date());// 현재시간 yyyy mm dd hh miss -- > spanDate.val + actMedicationTm var actTypeCheck = actTypeCheck; // 처리구분 (POC, EMR) var actType = "POC"; // 처리구분 (POC, EMR) console.log("actType -- > " + actType); var patientId = patientData[0].patientId; // 환자번호 var inDd = patientData[0].inDd; // 입원일자 var cretNo = patientData[0].cretNo; // 수진생성번호 var prcpDd = medicineSelectItem[key].prcpDd; // 처방일자 var prcpHistNo = medicineSelectItem[key].prcpHistNo; // 처방이력번호 var execPrcpNo = medicineSelectItem[key].execPrcpNo; // 실시번호(아점저구분) var prescriptionTmDay = medicineSelectItem[key].prescriptionTmDay; // 1일 횟수 var prcpCd = medicineSelectItem[key].prcpCd; // 처방코드 var prcpNm = medicineSelectItem[key].prcpNm; // 처방명 var prescriptionCapaDay = medicineSelectItem[key].prescriptionCapaDay; // 1일 용량 var drugBaseTmSpec = medicineSelectItem[key].drugBaseTmSpec; // 실시 기준시간 var execPrcpUniqNo = medicineSelectItem[key].execPrcpUniqNo; // 실시처방키(아점저구분) var execDeptCd = localStorage.getItem("selectedDeptCd"); // 로그인 로컬스토리지 사용자 선택 console.log(execDeptCd); var carecFact = medicineSelectItem[key].carecFact; // 상용구 var carecFactCd = medicineSelectItem[key].carecFactCd; // 상용구 코드 var prcpMixNo = medicineSelectItem[key].prcpMixNo; // 처방믹스번호 var prcpMixYn = medicineSelectItem[key].prcpMixYn; // 처방믹스여부 var tims = medicineSelectItem[key].tims.replace("#", ""); // 횟수(#제거) var actTm = medicineSelectItem[key].actMedicationTm; var param = { hospitalCd : hospitalCd , userId : userId , prescriptionNo : prescriptionNo , actMedicationTm : actMedicationTm , prescriptionTypeCd : prescriptionTypeCd , actMedicationDtTm : actMedicationDtTm , actType : actType , patientId : patientId , inDd : inDd , cretNo : cretNo , prcpDd : prcpDd , prcpHistNo : prcpHistNo , execPrcpNo : execPrcpNo , prescriptionTmDay : prescriptionTmDay , prcpCd : prcpCd , prcpNm : prcpNm , prescriptionCapaDay : prescriptionCapaDay, drugBaseTmSpec : drugBaseTmSpec , execPrcpUniqNo : execPrcpUniqNo , execDeptCd : execDeptCd, carecFact : carecFact , carecFactCd : carecFactCd , prcpMixNo : prcpMixNo , prcpMixYn : prcpMixYn , tims : tims , actTm : actTm } var result = self.safety.actMedication(param); count = count + 1; if (result != "") { if (result == "failed") { alert("투약실시에 오류가 발생하였습니다. \n" + prcpNm); } else { if (cnt == count) { alert("투약 실시가 처리되었습니다."); getPocPatientInfo($("#txtPatientId").val(), false); } } } // self.safety.actMedication(param, medicineActionCallbak, cnt, key); } } } }); } // var cnt = 0 // var outputAr = []; // var medicineActionCallbak = function(output, size, key) { // var param = {output, key}; // outputAr.push(param); // // if (size == outputAr.length) { // var errorFlag = false; // for (var i = 0; i < outputAr.length; i++) { // console.log("output[i] -- > " + outputAr[i].output); // if (outputAr[i].output == "0001") { // errorFlag = true; // } // } // if (errorFlag == true) { // alert("투약 실시에 오류가 발생하였습니다"); // // } else { // alert("투약 실시가 처리되었습니다."); // } // // getPocPatientInfo($("#txtPatientId").val()); // outputAr = []; // } //// location.reload(); // } function minusDate() { var dateAr = $("#spanDate").text().split("-"); var nowDate = new Date(dateAr[0], dateAr[1] - 1, dateAr[2]); var dateStr = nowDate.setDate(nowDate.getDate() - 1); $("#dateMinus").off("focus"); return moment(dateStr).format("YYYY-MM-DD"); } function plusDate() { var varCurDate = self.util.toDate(new Date()); // console.log("varCurDate -- > " + varCurDate); var dateAr = $("#spanDate").text().split("-"); var nowDate = new Date(dateAr[0], dateAr[1] - 1, dateAr[2]); var dateStr = nowDate.setDate(nowDate.getDate() + 1); dateStr = moment(dateStr).format("YYYY-MM-DD"); // console.log("dateStr -- > " + dateStr); $("#datePlus").off("focus"); if (varCurDate < dateStr) { if (patientData.length > 0) { var dschYn = patientData[0].dschYn; if (dschYn == "Y") { return moment(dateStr).format("YYYY-MM-DD"); } else { return ""; } } else { return ""; } } else { return moment(dateStr).format("YYYY-MM-DD"); } } /** * 문자열 일자 Date로 변환 * ex) 202002121430 */ function dateParse(str) { if(!/^(\d){12}$/.test(str) || str == "") return ""; var y = str.substr(0, 4); var m = str.substr(4, 2) - 1; var d = str.substr(6, 2); var h = str.substr(8, 2); var mm = str.substr(10, 2); return new Date(y,m,d,h,mm); } };