"use strict"; /** * mplus_safety_bleeding * 2020.02.06 */ var mplus_transfusion = function() { // 상속 mplus_common.call(this); var self = this; /* Fatima 전역 변수 */ var bloodArr = []; // API 호출 lists 를 담는 List var patientArr = []; // 환자 정보 List var executionDtTm = self.util.toDatetimeFatima2(new Date()); var selectItem = []; // 선택된 아이템 정보 // 인증저장 완료 후 초기화 필요함 var doctorInfo = []; // 시작 및 간호사 정보 var failedArr = []; // 마지막 활력징후 API 에서 실패한 데이터 var successArr = []; // 마지막 활력징후 API 에서 성공한 데이터 var xmlDataArr = []; // native Callback XML 데이터 저장 var signDataArr = []; // native Callback 인증 데이터 저장 var certXml = ""; // toNative 로 던져주기 위한 Xml String var maxIndex = 0; this.maxLengthCheck = function(object){ if (object.value.length > object.maxLength){ object.value = object.value.slice(0, object.maxLength); } if (object.id == "inputTemperature" && object.value.length == 2) { $("#inputTemperatureSub").focus(); } if (object.id == "inputTemperature2" && object.value.length == 2) { $("#inputTemperatureSub2").focus(); } if (object.id == "inputTemperature3" && object.value.length == 2) { $("#inputTemperatureSub3").focus(); } if (object.id == "inputTemperatureSub" && object.value.length == 1) { $("#inputSbp").focus(); } if (object.id == "inputTemperatureSub2" && object.value.length == 1) { $("#inputSbp2").focus(); } if (object.id == "inputTemperatureSub3" && object.value.length == 1) { $("#inputSbp3").focus(); } if (object.id == "nfcDoctorId1" && object.value.length == 6) { var doctorId = String($("#nfcDoctorId1").val()).padStart(6, "0"); var type = "first"; if ($("#nfcDoctorId2").val() == "" || $("#nfcDoctorId2").val() == null) { getDoctorId(doctorId, type); } else { if ($("#nfcDoctorId2").val() == $("#nfcDoctorId1").val()) { alert("의료진은 중복으로 입력될 수 없습니다."); $("#nfcDoctorId1").val(""); } else { getDoctorId(doctorId, type); } } } if (object.id == "nfcDoctorId2" && object.value.length == 6) { var doctorId = String($("#nfcDoctorId2").val()).padStart(6, "0"); var type = "second"; if ($("#nfcDoctorId1").val() == "" || $("#nfcDoctorId1").val() == null) { getDoctorId(doctorId, type); } else { if ($("#nfcDoctorId2").val() == $("#nfcDoctorId1").val()) { alert("의료진은 중복으로 입력될 수 없습니다."); $("#nfcDoctorId2").val(""); } else { getDoctorId(doctorId, type); } } } }; /* Fatima 전역 변수 */ /** * 초기화 */ this.init = function() { localStorage.removeItem("defaultHomePage"); localStorage.setItem("defaultHomePage", "transfusion"); // 초기 화면 조건 구성 initCondition(); // 이벤트 초기화 addEvent(); $("#txtTransFusionSearch").focus(); }; //==== 초기화 설정 { ==== var initCondition = function() { // 초기 화면 조건 구성 //환자정보 초기화 initPatientInfo(); }; /** * 2020.02.06 * 수혈 환자 정보 초기화 */ var initPatientInfo = function() { $(".patient-name").text("환자명"); $(".patient-gender-age").text("성별/나이"); $(".patient-birthDt").text("생년월일"); $("#patientInfo").text("성별/나이"); $(".dept-name").text("실시부서"); $(".user-name").text("실시자명"); $(".user-code").text("(사원번호)"); $(".patient-name button").attr("style", "display: none"); }; var initList = function() { $("#bloodListGroup").empty(); $("#scanBarcodeGroup").attr("style", "display: ;"); $("#bloodDetail").attr("style", "display: none;"); } function initLayout() { $("#inputPulse").val(""); $("#inputRespiration").val(""); $("#inputTemperature").val(""); $("#inputTemperatureSub").val(""); $("#inputSbp").val(""); $("#inputDbp").val(""); $("#inputPulse2").val(""); $("#inputRespiration2").val(""); $("#inputTemperature2").val(""); $("#inputTemperatureSub2").val(""); $("#inputSbp2").val(""); $("#inputDbp2").val(""); $(".modal-body.pt-4.pb-4").children().remove(); $("#inputPulse3").val(""); $("#inputRespiration3").val(""); $("#inputTemperature3").val(""); $("#inputTemperatureSub3").val(""); $("#inputSbp3").val(""); $("#inputDbp3").val(""); } /** * * 환자 기본정보 호출 * @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 2 번째 호출 여부 */ var processGetPocPatientInfo = function(lists, barPid, isSecondTrial) { patientArr = []; if(self.util.isEmpty(lists) || lists.length == 0){ initPatientInfo(); initList(); $("#Modal01 .modal-body h4").text("환자정보 조회 실패"); $("#Modal01 .modal-body p").text("환자정보 조회에 실패하였습니다."); $("#Modal01").modal("show"); $('#txtTransFusionSearch').blur(); return; } // 1. 만일 환자 정보가 맞다면 환자 정보를 보여준다. if (barPid == lists[0].patientId) { patientArr = lists; $(".patient-name").text(lists[0].patientNm); $("#patientInfo").text(lists[0].age + "/" + lists[0].gender + " " + lists[0].roomNm + "호"); $(".patient-birthDt").text(lists[0].birthDt); $(".dept-name").text(localStorage.getItem("selectedDeptNm")); $(".user-name").text(gLoginUserNm); $(".user-code").text("(" + gLoginUserId + ")"); $(".patient-name").append(""); var summaryCd = lists[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 = "" $("#patientInfo").append(spanTag); } getBloodCheckList(false); } // 2. 환자 정보가 맞지 않으면 else { // 2.1 2번째 호출이 아니면 다시 환자 정보 조회 if (!isSecondTrial) { getPocPatientInfo(barPid, true); } // 2.2 2번째 호출이면 Alert else { initPatientInfo(); initList(); $("#Modal01 .modal-body h4").text("환자정보 조회 실패"); $("#Modal01 .modal-body p").text("시스템 이용량이 많습니다. 다시 조회해 주세요."); $("#Modal01").modal("show"); } } } /** * 바코드 콜백 */ this.barcodeCallback = function(data) { var result = ""; // null 이라면 반환 if(self.util.isEmpty(data)){ return; } else{ result = self.util.decodeBarcode(data); } if(self.util.isEmpty(result) || result.type == 'errBarcode'){ $("#txtTransFusionSearch").blur(); $("#Modal01 .modal-body h4").text("수혈실시 바코드가 아닙니다."); $("#Modal01 .modal-body p").text("바코드를 다시 확인해주세요."); $("#Modal01").modal("show"); return; } else if (result.type == 'pid') { var patientId = result.data; $("#txtTransFusionSearch").val(patientId) getPocPatientInfo(patientId, false); $("#btnTransFusionSearch").removeClass("btn-secondary").addClass("btn-primary"); $("#txtTransFusionSearch").blur(); } else if (result.type == "medicine") { $("#txtTransFusionSearch").blur(); if (patientArr.length == 0) { $("#Modal01 .modal-body h4").text("환자 정보가 없습니다."); $("#Modal01 .modal-body p").text("환자 조회를 해주세요."); $("#Modal01").modal("show"); return; } var foundCnt = 0; for(var idx = 0; idx < bloodArr.length; idx++){ if(bloodArr[idx].prescriptionNo == result.data.replace("B", "")){ // console.log("label[for='checkBloodSel_" + idx + "']"); var labelObj = $("label[for='checkBloodSel_" + idx + "']"); labelObj.attr('class', 'btn btn-barcode icon'); var iptObj = $('input:checkbox[id="checkBloodSel_' + idx + '"]'); iptObj.prop('checked', true); var li = $('li[id="listGroupItem_' + idx + '"]'); li.addClass("active"); foundCnt++; } } if(foundCnt == 0){ $("#Modal01 .modal-body h4").text("실시할 수 없는 수혈 바코드 입니다."); $("#Modal01 .modal-body p").text(""); $("#Modal01").modal("show"); } } else{ $("#txtTransFusionSearch").blur(); $("#Modal01 .modal-body h4").text("수혈실시 바코드가 아닙니다."); $("#Modal01 .modal-body p").text("바코드를 다시 확인해주세요."); $("#Modal01").modal("show"); } }; /** * 혈액내역정보 리스트 호출 * @param {*} isSecondTrial 두 번째 호출여부 */ var getBloodCheckList = function(isSecondTrial) { var param = { hospitalCd: localStorage.getItem("hospitalCd"), userId : gLoginUserId, patientId: $("#txtTransFusionSearch").val(), isSecondTrial: isSecondTrial }; self.safety.getBloodCheckList(param, isSecondTrial, processGetBloodCheckList); } /** * 혈액내역정보 호출된 리스트 매핑 * @param {*} isSecondTrial 2번째 호출 여부 * @param {*} lists API 반환 데이터 */ var processGetBloodCheckList = function(isSecondTrial, lists) { console.log("bloodList -- > " + JSON.stringify(lists)); bloodArr = []; var strListTemp = ""; $("#bloodListGroup").empty(); // 예외처리 if(self.util.isEmpty(lists) || lists.length == 0){ // $("#Modal01 .modal-body h4").text("수혈정보 조회"); // $("#Modal01 .modal-body p").text("조회된 혈액정보가 없습니다."); // $("#Modal01").modal("show"); return; } // 1. 기존 환자 ID와 반환되는 환자 ID가 일치하다면 정상적으로 실행 if (patientArr[0].patientId == lists[0].patientId) { bloodArr = lists; $("#scanBarcodeGroup").attr("style", "display: none;"); $("#bloodDetail").attr("style", "display: "); for (var i = 0; i < lists.length; i++) { var statusMapping = lists[i].bloodCheckupStatus; var bloodCheckupStatus = ""; var prcpNm = ""; var dTtm = ""; if (lists[i].releaseDtTm == null || lists[i].releaseDtTm == "" || lists[i].releaseDtTm == undefined) { lists[i].releaseDtTm = ""; } if (statusMapping == "00") { bloodCheckupStatus = "혈액불출"; prcpNm = "불출일시"; dTtm = (lists[i].releaseDtTm).substring(4, 6) + "-" + (lists[i].releaseDtTm).substring(6, 8) + "
" + (lists[i].releaseDtTm).substring(8, 10) + ":" + (lists[i].releaseDtTm).substring(10, 12); } else if (statusMapping == "01") { bloodCheckupStatus = "환자/혈액/의료진 확인"; prcpNm = "불출일시"; dTtm = (lists[i].releaseDtTm).substring(4, 6) + "-" + (lists[i].releaseDtTm).substring(6, 8) + "
" + (lists[i].releaseDtTm).substring(8, 10) + ":" + (lists[i].releaseDtTm).substring(10, 12); } else if (statusMapping == "02") { bloodCheckupStatus = "수혈안내동의"; prcpNm = "승인일시"; dTtm = (lists[i].approvalDtTm).substring(4, 6) + "-" + (lists[i].approvalDtTm).substring(6, 8) + "
" + (lists[i].approvalDtTm).substring(8, 10) + ":" + (lists[i].approvalDtTm).substring(10, 12); } else if (statusMapping == "03") { bloodCheckupStatus = "약물투여확인"; prcpNm = "승인일시"; dTtm = (lists[i].approvalDtTm).substring(4, 6) + "-" + (lists[i].approvalDtTm).substring(6, 8) + "
" + (lists[i].approvalDtTm).substring(8, 10) + ":" + (lists[i].approvalDtTm).substring(10, 12); } else if (statusMapping == "04") { bloodCheckupStatus = "활력징후 측정(15분후)"; prcpNm = "수혈시작"; dTtm = (lists[i].startDtTm).substring(4, 6) + "-" + (lists[i].startDtTm).substring(6, 8) + "
" + (lists[i].startDtTm).substring(8, 10) + ":" + (lists[i].startDtTm).substring(10, 12); } else if (statusMapping == "05") { bloodCheckupStatus = "활력징후 측정(수혈종료)"; prcpNm = "수혈시작"; dTtm = (lists[i].startDtTm).substring(4, 6) + "-" + (lists[i].startDtTm).substring(6, 8) + "
" + (lists[i].startDtTm).substring(8, 10) + ":" + (lists[i].startDtTm).substring(10, 12); } else { bloodCheckupStatus = "활력징후 측정(수혈종료)"; prcpNm = "수혈시작"; dTtm = (lists[i].startDtTm).substring(4, 6) + "-" + (lists[i].startDtTm).substring(6, 8) + "
" + (lists[i].startDtTm).substring(8, 10) + ":" + (lists[i].startDtTm).substring(10, 12); } strListTemp += "
  • " + "
    " // CheckBox 시작 + "
    " + "" + "
    " + "" + "" + "
    " + "
    " // CheckBox 끝 //혈액 정보(활력징후 시작시간 혈액형 혈액처방정보 출력 + "
    " + "

    " + bloodCheckupStatus + "

    " + "

    " + lists[i].bloodNo +" " + lists[i].bloodType + lists[i].bloodRhType + "

    " + "

    " + lists[i].bloodProduct + "

    " + "
    " //혈액 정보(활력징후 시작시간 혈액형 혈액처방정보 출력 끝 //수혈 진행 상황 및 시간 출력 + "
    " + "" + prcpNm + "" + "
    " + "" + dTtm + "" + "
    " //수혈 진행 상황 및 시간 출력 // //리스트 오른쪽 버튼 + "
    " + "

    " + "" + "" + "" + "" + "

    " + "
    " // // 리스트 오른쪽 버튼 + "
  • " + ""; } $("#bloodListGroup").append(strListTemp); openDetailModal(); inputCheckedItem(); inputListClick(); // 2. 환자정보가 일치하지 않다면 } else { // 2.1 첫번째 호출인가 if (!isSecondTrial) { getBloodCheckList(true); // 2.2 두번째 호출인가 } else { $("#Modal01 .modal-body h4").text("수혈정보 조회 오류"); $("#Modal01 .modal-body p").text("시스템 이용량이 많습니다. 다시 조회해 주세요."); $("#Modal01").modal("show"); } } } /** * 체크박스 선택 아이템 */ var inputCheckedItem = function() { // $("#bloodListGroup li input").off("click"); $("#bloodListGroup li input").on("click", function() { var li = $(this).parent().parent().parent(); var id = li.attr("id"); var rowNum = id.split('_')[1]; var checkBox = $("#checkBloodSel_" + rowNum); var firstLabel = checkBox.parent().children().children().eq(0); var secondLabel = checkBox.parent().children().children().eq(1); if (checkBox.is(":checked") == true) { li.toggleClass("active"); } else { li.toggleClass("active"); firstLabel.attr("class", "btn btn-check icon"); secondLabel.attr("class", "btn btn-outline-check icon"); } }); }; function openDetailModal() { $(".list-group li a").on("click", function () { var id = $(this).attr("id"); var index = id.split("_")[1]; var checkYn = ""; var hospitalCd = localStorage.getItem("hospitalCd"); var userId = gLoginUserId; var patientId = $("#txtTransFusionSearch").val(); var prescriptionNo = bloodArr[index].prescriptionNo; var bloodNo = bloodArr[index].bloodNo; var bloodSeq = bloodArr[index].bloodSeq; var bloodProduct = bloodArr[index].bloodProduct; var param = { hospitalCd : hospitalCd , userId : userId , patientId : patientId , prescriptionNo : prescriptionNo, bloodNo : bloodNo , bloodSeq : bloodSeq , bloodProduct : bloodProduct }; self.safety.getBloodDetailInfo(param, index, bloodDetailInfoCallback); }); } var bloodDetailInfoCallback = function(index, output) { $("#detailBloodSeq").attr("style", "display: none;"); $("#detailBloodCheckupNm").attr("style", "display: none;"); $("#detailBloodCheckupNm2").attr("style", "display: none;"); $("#detailStartDtTm").attr("style", "display: none;"); $("#detailBf").attr("style", "display: none;"); $("#detail15").attr("style", "display: none;"); if (output.length == 0) { $("#Modal01 .modal-body h4").text("수혈 상세정보가 없습니다."); $("#Modal01 .modal-body p").text(""); $("#Modal01").modal("show"); return; } else{ if (bloodArr[index].prescriptionNo != output[0].prescriptionNo) { $("#Modal01 .modal-body h4").text("상세정보 조회 오류"); $("#Modal01 .modal-body p").text("상세정보 조회에 실패하였습니다."); $("#Modal01").modal("show"); return; } $("#ModalDetail").modal("show"); var transBfDiastolicBp = output[0].transBfDiastolicBp == undefined ? "" : output[0].transBfDiastolicBp; var trans15DiastolicBp = output[0].trans15DiastolicBp == undefined ? "" : output[0].trans15DiastolicBp; var bloodSeq = output[0].bloodSeq == undefined ? "" : output[0].bloodSeq; var bloodType = output[0].bloodType == undefined ? "" : output[0].bloodType; var transBfSystolicBp = output[0].transBfSystolicBp == undefined ? "" : output[0].transBfSystolicBp; var transBfRespiration = output[0].transBfRespiration == undefined ? "" : output[0].transBfRespiration; var prcpHistNo = output[0].prcpHistNo == undefined ? "" : output[0].prcpHistNo; var transAfRespiration = output[0].transAfRespiration == undefined ? "" : output[0].transAfRespiration; var transBfBodytemperature = output[0].transBfBodytemperature == undefined ? "" : output[0].transBfBodytemperature; var ird = output[0].ird == undefined ? "" : output[0].ird; var trans15SystolicBp = output[0].trans15SystolicBp == undefined ? "" : output[0].trans15SystolicBp; var hospitalCd = output[0].hospitalCd == undefined ? "" : output[0].hospitalCd; var transAfDiastolicBp = output[0].transAfDiastolicBp == undefined ? "" : output[0].transAfDiastolicBp; var transAfSystolicBp = output[0].transAfSystolicBp == undefined ? "" : output[0].transAfSystolicBp; var transCheckupId2 = output[0].transCheckupId2 == undefined ? "" : output[0].transCheckupId2; var prcpDd = output[0].prcpDd == undefined ? "" : output[0].prcpDd; var transCheckupId1 = output[0].transCheckupId1 == undefined ? "" : output[0].transCheckupId1; var prcpNm = output[0].prcpNm == undefined ? "" : output[0].prcpNm; var approvalDtTm = output[0].approvalDtTm == undefined ? "" : output[0].approvalDtTm; var releaseDtTm = output[0].releaseDtTm == undefined ? "" : output[0].releaseDtTm; var prcpCd = output[0].prcpCd == undefined ? "" : output[0].prcpCd; var bloodNo = output[0].bloodNo == undefined ? "" : output[0].bloodNo; var startDtTm = output[0].startDtTm == undefined ? "" : output[0].startDtTm; var bloodProduct = output[0].bloodProduct == undefined ? "" : output[0].bloodProduct; var prescriptionNo = output[0].prescriptionNo == undefined ? "" : output[0].prescriptionNo; var transBfPulse = output[0].transBfPulse == undefined ? "" : output[0].transBfPulse; var trans15Bodytemperature = output[0].trans15Bodytemperature == undefined ? "" : output[0].trans15Bodytemperature; var receiveId = output[0].receiveId == undefined ? "" : output[0].receiveId; var transCheckupNm1 = output[0].transCheckupNm1 == undefined ? "" : output[0].transCheckupNm1; var transAfBodytemperature = output[0].transAfBodytemperature == undefined ? "" : output[0].transAfBodytempera; var receiveNm = output[0].receiveNm == undefined ? "" : output[0].receiveNm; var trans15Pulse = output[0].trans15Pulse == undefined ? "" : output[0].trans15Pulse; var transAfPulse = output[0].transAfPulse == undefined ? "" : output[0].transAfPulse; var trans15Respiration = output[0].trans15Respiration == undefined ? "" : output[0].trans15Respiration; var transCheckupNm2 = output[0].transCheckupNm2 == undefined ? "" : output[0].transCheckupNm2; var bloodRhType = output[0].bloodRhType == undefined ? "" : output[0].bloodRhType; var sideEffectNms = output[0].sideEffectNms == undefined? "" : output[0].sideEffectNms; var transStopYn = output[0].transStopYn == undefined? "" : output[0].transStopYn; var transStopReasonNm = output[0].transStopReasonNm == undefined? "" : output[0].transStopReasonNm; $("#bloodNo").text(bloodNo); $("#bloodProduct").text(prcpNm); $("#bloodType").text(bloodType+bloodRhType); $("#ird").text(ird); $("#bloodSeq").text(bloodSeq); $("#transCheckupNm1").text(transCheckupNm1); $("#transCheckupNm2").text(transCheckupNm2); $("#receiveNm").text(receiveNm); if (sideEffectNms == null || sideEffectNms == "" || sideEffectNms == undefined) { $("#detailSideEffect").attr("style", "display: none;"); } else { // var sideEffectNm = sideEffectNms.replace(" /", ","); // sideEffectNm[0].substring(1); // $("#detailSideEffectNm").empty(); // for (var i = 0; i < sideEffectNm.length; i++) { // $("#detailSideEffectNm").append("

    " + sideEffectNm[i] +"

    "); // } // $("#detailSideEffect").attr("style", "display: ;"); // } var sideEffectNm = sideEffectNms.substring(1); $("#detailSideEffectNm").empty(); $("#detailSideEffectNm").append("

    " + sideEffectNm +"

    "); $("#detailSideEffect").attr("style", "display: ;"); } if (transStopYn == null || transStopYn == "" || transStopYn == undefined) { $("#detailTransYn").attr("style", "display: none;"); $("#detailTransNm").attr("style", "display: none;"); } else { $("#detailTransYn2").text(transStopYn); $("#detailTransYn").attr("style", "display: ;"); if (transStopYn == "N") { $("#detailTransNm").attr("style", "display: none;"); } else { var transStopReasonNms = transStopReasonNm.trim(); $("#detailTransNms").empty(); $("#detailTransNms").text(transStopReasonNms); $("#detailTransNm").attr("style", "display: ;"); } } if (releaseDtTm != "") { $("#releaseDtTm").text(moment(fullDateParse(releaseDtTm)).format("YYYY-MM-DD HH:mm:ss")); } if (approvalDtTm != "") { $("#approvalDtTm").text(moment(fullDateParse(approvalDtTm)).format("YYYY-MM-DD HH:mm:ss")); } if (startDtTm != "") { $("#startDtTm").text(moment(dateParse(startDtTm)).format("YYYY-MM-DD HH:mm")); } if (!self.util.isEmpty(transBfPulse)) { $("#detailBloodSeq").attr("style", "display: ;"); $("#detailBloodCheckupNm").attr("style", "display: ;"); $("#detailBloodCheckupNm2").attr("style", "display: ;"); $("#detailStartDtTm").attr("style", "display: ;"); $("#detailBf").attr("style", "display: ;"); } $("#transBfPulseRespiration").text("맥박 : " + transBfPulse + "회, " + "호흡 : " + transBfRespiration + "회"); $("#transBfBodytemperature").text("체온 : " + transBfBodytemperature + ", 혈압 : " + transBfSystolicBp + " / " + transBfDiastolicBp); $("#trans15PulseRespiration").text("맥박 : " + trans15Pulse + "회, " + "호흡 : " + trans15Respiration + "회"); $("#trans15Bodytemperature").text("체온 : " + trans15Bodytemperature + ", 혈압 : " + trans15SystolicBp + " / " + trans15DiastolicBp); if (self.util.isEmpty(trans15Pulse)) { $("#newBadge").attr("style", "display: none"); } else { $("#newBadge").attr("style", "display: none"); $("#detail15").attr("style", "display: ;"); } } } /** * 리스트 아이템 선택 이벤트 */ var inputListClick = function () { // $("#bloodListGroup li").off("click"); $("#bloodListGroup li").on("click", function(e) { if(e.target.localName != "input" && e.target.localName != "label" && e.target.localName != "span"){ selectItem = []; var li = $(this); var id = li.attr("id"); var input = li.children().children().children("input"); var bloodCheckupStatus = []; bloodCheckupStatus.push(bloodArr[id.split("_")[1]].bloodCheckupStatus); var bCheckUpStatus = bloodArr[id.split("_")[1]].bloodCheckupStatus; input.prop("checked", true); li.addClass("active"); var selectList = $('#bloodListGroup li[class="list-group-item active"] input'); for (var i = 0; i < selectList.length; i++) { var _id = selectList[i].id.split("_")[1]; var _bloodCheckupStatus = bloodArr[_id].bloodCheckupStatus; for (var j = 0; j < bloodCheckupStatus.length; j++) { if (_bloodCheckupStatus != bloodCheckupStatus[j]) { $("#Modal01 .modal-body h4").text("같은 단계의 혈액팩이 아닙니다."); $("#Modal01 .modal-body p").text("일괄처리를 할 수 없습니다."); $("#Modal01").modal("show"); input.prop("checked", false); li.removeClass("active"); return; } } selectItem.push(bloodArr[_id]); } if (bCheckUpStatus == "00") { // 혈액불출 openStep2Modal(); } else if (bCheckUpStatus == "04") { // 활력징후 측정(수혈전) openStep3Modal(); } else if (bCheckUpStatus == "05") { // 활력징후 측정(15분후) openStep4Modal(); } else if (bCheckUpStatus == "06") { openStep4Modal(); } } }); }; function openStep2Modal() { $(".modal").modal("hide"); $(".modal-backdrop").modal("hide"); $("#step3").modal("show"); var patientId = patientArr[0].patientId; var patientNm = patientArr[0].patientNm; var bloodType = patientArr[0].bloodType; var gender = patientArr[0].gender; var age = patientArr[0].age; var birthDt = moment(patientArr[0].birthDt).format("YYYY-MM-DD"); var deptNm = localStorage.getItem("selectedDeptNm"); var summaryCd = patientArr[0].patientSummaryCd.split(","); var wardNm = patientArr[0].wardNm; var roomNm = patientArr[0].roomNm; var bedNm = patientArr[0].bedNm; var inDd = patientArr[0].inDd; var doctorNm = patientArr[0].doctorNm; $(".h2PatientInfo").text(patientId + " " + patientNm); $(".h2PatientInfo").append("" + " " + bloodType +""); $(".patientSexNAge").text(gender + "/" + age + " " + roomNm + "호"); $(".userInfo").html("실시부서 : " + deptNm +"|" + gLoginUserNm + "(" +gLoginUserId +")"); $(".date span").eq(0).remove(); $(".date").html("" + self.util.toDatetimeFatima(new Date()) + ""); var spanTag = ""; for (var i = 0; i < summaryCd.length; i++) { var sCd = summaryCd[i]; if (sCd == "!") { sCd = "t"; } else if (sCd == "₩") { sCd = "w"; } spanTag = "" $(".patientSexNAge").append(spanTag); } $("#patientIdName2").text(patientId + " " + patientNm); $("#patientSexNAge2").text(gender + "/" + age + " " + birthDt); $("#blood2").text(bloodType); $("#wardInfo").text(wardNm + "/" + roomNm + "/" + bedNm); $("#inDd").text(moment(inDd).format("YYYY-MM-DD")); var collapseDiv = $("#collapse2 div[class=row]"); var badgeCount = (selectItem.length -1); var badgeCountTag = " + " + badgeCount +""; $("#heading2 button[data-toggle=collapse] div[class=row]").children().eq(0).text(selectItem[0].bloodNo); $("#heading2 button[data-toggle=collapse] div[class=row]").children().eq(1).html(selectItem[0].prcpNm + (badgeCount > 0 ? badgeCountTag : "")); collapseDiv.children().remove(); var divItem = ""; for (var i = 1; i < selectItem.length; i++) { divItem = "
    "+ selectItem[i].bloodNo + "
    " + "
    " + selectItem[i].prcpNm + "
    "; collapseDiv.append(divItem); } $("#nfcDoctorName1").text(""); $("#nfcDoctorId1").val(""); $("#checkUpDoctorId1").remove(); $("#nfcDoctorName2").text(""); $("#nfcDoctorId2").val(""); $("#checkUpDoctorId2").remove(); $("#save3").off("click"); $("#save3").on("click", function() { var nfcDoctorId1 = $("#nfcDoctorId1").val().trim(); var nfcDoctorId2 = $("#nfcDoctorId2").val().trim(); if (nfcDoctorId1 != "" && nfcDoctorId2 != "") { $("#checkUpDoctorId1").remove(); $("#checkUpDoctorId2").remove(); $("#nfcDoctorId1").parent().append(""); $("#nfcDoctorId2").parent().append(""); // var result = inputCheckupId(); } else { alert("의료진은 2명이 필수 입력입니다."); return; } var inputPulse = $("#inputPulse").val(); var inputRespiration = $("#inputRespiration").val(); var inputTemperature = $("#inputTemperature").val(); var inputTemperatureSub = $("#inputTemperatureSub").val(); var inputSbp = $("#inputSbp").val(); var inputDbp = $("#inputDbp").val(); if (inputPulse == "" || inputRespiration == "" || inputTemperature == "" || inputTemperatureSub == "" || inputSbp == "" || inputDbp == "") { alert("미입력된 항목이 있습니다. \n입력 후, 진행이 가능합니다."); } else { inputBloodHealthCheckStep3(); // openStep3Modal(); } }); } function openStep3Modal() { getSideEffectList(); getTransStopReasonList("Step2"); $(".modal").modal("hide"); $(".modal-backdrop").modal("hide"); $("#step4").modal("show"); var patientId = patientArr[0].patientId; var patientNm = patientArr[0].patientNm; var bloodType = patientArr[0].bloodType; var gender = patientArr[0].gender; var age = patientArr[0].age; var deptNm = localStorage.getItem("selectedDeptNm"); var summaryCd = patientArr[0].patientSummaryCd.split(","); var roomNm = patientArr[0].roomNm; $("#patientInfo2").text(patientId + " " + patientNm); $("#patientInfo2").append("" + " " + bloodType +""); $("#patientSexAge2").text(gender + "/" + age + " " + roomNm + "호"); $(".userInfo").html("실시부서 : " + deptNm +"|" + gLoginUserNm + "(" +gLoginUserId +")"); $(".date span").eq(0).remove(); $(".date").html("" + self.util.toDatetimeFatima(new Date()) + ""); var startDtTm = selectItem[0].startDtTm; if (selectItem[0].startDtTm == null || selectItem[0].startDtTm == "" || selectItem[0].startDtTm == undefined) { startDtTm = executionDtTm; } var badgeCount = (selectItem.length -1); var badgeCountTag = " + " + badgeCount +""; $("#heading4 button[data-toggle=collapse] div[class=row]").children().eq(0).text(selectItem[0].bloodNo); $("#heading4 button[data-toggle=collapse] div[class=row]").children().eq(1).html(selectItem[0].prcpNm + (badgeCount > 0 ? badgeCountTag : "")); if (startDtTm != "") { var strDate = moment(dateParse(startDtTm)).format("YYYY-MM-DD HH:mm"); var addDate = new Date(strDate); var convertAddDate = addDate.setMinutes(addDate.getMinutes() + 15); var convertStrDate = moment(new Date(convertAddDate)).format("YYYY-MM-DD HH:mm"); $(".time_box").children().eq(0).text("시작 : " + strDate); // console.log("strDate -- > " + strDate); $(".info_box2 p[class=blood]").text("15분 : " + convertStrDate); } else { $(".time_box").children().eq(0).text("시작 : "); $(".info_box2 p[class=blood]").text("15분 : "); } var collapseDiv = $("#collapse4 div[class=row]"); collapseDiv.children().remove(); var divItem = ""; for (var i = 1; i < selectItem.length; i++) { divItem = "
    "+ selectItem[i].bloodNo + "
    " + "
    " + selectItem[i].prcpNm + "
    "; collapseDiv.append(divItem); } $("#sideEffectEmpty").on("click", function() { for (var i = 0; i < $("input[name=sideEffectChk]").length; i++) { $("input[name=sideEffectChk]").eq(i).prop("checked", false); } $("#inputEtc").val(""); $("#inputEtc").attr("disabled", true); }); $(".sideEffect").on("click", function(){ // getSideEffectList(); $("#sideEffect_pop").modal("show"); // $("#sideEffect_pop").attr("style", "display: block"); }); $("#save4").off("click"); $("#save4").on("click", function() { var inputPulse = $("#inputPulse2").val(); var inputRespiration = $("#inputRespiration2").val(); var inputTemperature = $("#inputTemperature2").val(); var inputTemperatureSub = $("#inputTemperatureSub2").val(); var inputSbp = $("#inputSbp2").val(); var inputDbp = $("#inputDbp2").val(); var stopYn = "N"; if ($("#raY1").is(":checked") == true) { stopYn = "Y"; } else if ($("#raN1").is(":checked") == true) { stopYn = "N"; } if (inputPulse == "" || inputRespiration == "" || inputTemperature == "" || inputTemperatureSub == "" || inputSbp == "" || inputDbp == "") { alert("미입력된 항목이 있습니다. \n입력 후, 진행이 가능합니다."); } else { if (stopYn == "Y") { if ($("#reasonBox option:selected").text().trim() == "기타") { if ($("#reasonEtc").val() == "") { alert("미입력된 항목이 있습니다. \n입력 후, 진행이 가능합니다."); } else { inputBloodHealthCheckStep4(stopYn, convertStrDate); } } else { inputBloodHealthCheckStep4(stopYn, convertStrDate); } } else { inputBloodHealthCheckStep4(stopYn, convertStrDate); } } }); } function openStep4Modal() { getTransStopReasonList("Step3"); getSideFinishEffectList(); $(".modal").modal("hide"); $(".modal-backdrop").modal("hide"); $("#step5").modal("show"); var patientId = patientArr[0].patientId; var patientNm = patientArr[0].patientNm; var bloodType = patientArr[0].bloodType; var gender = patientArr[0].gender; var age = patientArr[0].age; var deptNm = localStorage.getItem("selectedDeptNm"); var summaryCd = patientArr[0].patientSummaryCd.split(","); var roomNm = patientArr[0].roomNm; $("#patientInfo3").text(patientId + " " + patientNm); $("#patientInfo3").append("" + " " + bloodType +""); $("#patientSexAge3").text(gender + "/" + age + " " + roomNm + "호"); $(".userInfo").html("실시부서 : " + deptNm +"|" + gLoginUserNm + "(" +gLoginUserId +")"); $(".date span").eq(0).remove(); $(".date").html("" + self.util.toDatetimeFatima(new Date()) + ""); var badgeCount = (selectItem.length -1); var badgeCountTag = " + " + badgeCount +""; $("#heading5 button[data-toggle=collapse] div[class=row]").children().eq(0).text(selectItem[0].bloodNo); $("#heading5 button[data-toggle=collapse] div[class=row]").children().eq(1).html(selectItem[0].prcpNm + (badgeCount > 0 ? badgeCountTag : "")); var collapseDiv = $("#collapse5 div[class=row]"); collapseDiv.children().remove(); var divItem = ""; for (var i = 1; i < selectItem.length; i++) { divItem = "
    "+ selectItem[i].bloodNo + "
    " + "
    " + selectItem[i].prcpNm + "
    "; collapseDiv.append(divItem); } $("#sideEffectInputN").off("click"); $("#sideEffectInputN").on("click", function() { // console.log("sideEffectInputN"); $("#sideEffetcValue").val("N"); for (var i = 0; i < $("input[name=sideEffectChk2]").length; i++) { $("input[name=sideEffectChk2]").eq(i).prop("checked", false); } $("#inputFinishEtc").val(""); }); $("#sideEffectInputY").off("click"); $("#sideEffectInputY").on("click", function() { // console.log("sideEffectInputY"); $("#sideEffetcValue").val("Y"); // getSideFinishEffectList(); $("#sideEffect_pop2").modal("show"); }); $("#saveEndNext").off("click"); $("#saveEndNext").on("click", function() { saveEndEvent("saveEndNext"); }); $("#saveEnd").off("click"); $("#saveEnd").on("click", function() { saveEndEvent("saveEnd"); }); } function saveEndEvent(type) { var inputPulse = $("#inputPulse3").val(); var inputRespiration = $("#inputRespiration3").val(); var inputTemperature = $("#inputTemperature3").val(); var inputTemperatureSub = $("#inputTemperatureSub3").val(); var inputSbp = $("#inputSbp3").val(); var inputDbp = $("#inputDbp3").val(); var stopYn = "N"; var index = selectItem.length - 1; if ($("#raY2").is(":checked") == true) { stopYn = "Y"; } else if ($("#raN2").is(":checked") == true) { stopYn = "N"; } if (inputPulse == "" || inputRespiration == "" || inputTemperature == "" || inputTemperatureSub == "" || inputSbp == "" || inputDbp == "") { alert("미입력된 항목이 있습니다. \n입력 후, 진행이 가능합니다."); } else { if (stopYn == "Y") { if ($("#reasonBox2 option:selected").text().trim() == "기타") { if ($("#reasonEtc2").val() == "") { alert("미입력된 항목이 있습니다. \n입력 후, 진행이 가능합니다."); } else { inputBloodHealthCheckFinishStep(stopYn); } } else { inputBloodHealthCheckFinishStep(stopYn); } } else { inputBloodHealthCheckFinishStep(stopYn); } } } async function inputBloodHealthCheckFinishStep(stopYn) { stopYn = stopYn == "Y" ? stopYn : "N"; var sideEffect = "N"; var sideEffectCode = ""; var sideEffectName = ""; for (var i = 0; i < $("input[name=sideEffectChk2]").length; i++) { if ($("input[name=sideEffectChk2]").eq(i).is(":checked") == true) { sideEffect = "Y"; var _sideEffectName = $("input[name=sideEffectChk2]").eq(i).parent().parent().children().eq(1).text().trim(); var _sideEffectCode = $("input[name=sideEffectCode2]").eq(i).val().trim(); // sideEffectCode += "CD:" + _sideEffectCode + "^"; sideEffectCode += _sideEffectCode + "^"; if (_sideEffectName == "기타") { sideEffectName = $("#inputFinishEtc").val(); } } } var transStopReasonCd = ""; var transStopReasonEtc = ""; if (stopYn == "Y") { if ($("#raY2").is(":checked") == true) { transStopReasonCd = $("#reasonBox2 option:selected").val(); if ($("#reasonBox2 option:selected").text().trim() == "기타") { transStopReasonEtc = $("#reasonEtc2").val(); } } else { transStopReasonCd = ""; transStopReasonEtc = ""; } } else { transStopReasonCd = ""; transStopReasonEtc = ""; } sideEffectCode = sideEffectCode.slice(0,-1); executionDtTm = ""; var cnt = 0; for (var i = 0; i < selectItem.length; i++) { var hospitalCd = localStorage.getItem("hospitalCd"); var userId = gLoginUserId; var userDeptCd = localStorage.getItem("selectedDeptCd"); var patientId = $("#txtTransFusionSearch").val(); var prescriptionNo = selectItem[i].prescriptionNo; var bloodNo = selectItem[i].bloodNo; var bloodSeq = selectItem[i].bloodSeq; var bloodProduct = selectItem[i].bloodProduct; var bloodCheckupStatus = "06"; var pulse = $("#inputPulse3").val(); var respiration = $("#inputRespiration3").val(); var bodytemperature = $("#inputTemperature3").val() + "." + $("#inputTemperatureSub3").val(); //체온 var systolicBp = $("#inputSbp3").val(); var diastolicBp = $("#inputDbp3").val(); var sideEffectYn = sideEffect; var sideEffectCds = sideEffectCode; var sideEffectNm = sideEffectName; var transStopYn = stopYn; executionDtTm = self.util.toDatetimeFatima2(new Date()); var bloodType = selectItem[i].bloodType; var bloodRhType = selectItem[i].bloodRhType; var prcpNm = selectItem[i].prcpNm; var prcpCd = selectItem[i].prcpCd; var prcpDd = selectItem[i].prcpDd; var transCheckupId1 = ""; var transCheckupId2 = ""; var param = { hospitalCd : hospitalCd , userId : userId , userDeptCd : userDeptCd , patientId : patientId , prescriptionNo : prescriptionNo , bloodNo : bloodNo , bloodSeq : bloodSeq , bloodProduct : bloodProduct , bloodCheckupStatus : bloodCheckupStatus, pulse : pulse , respiration : respiration , bodytemperature : bodytemperature , systolicBp : systolicBp , diastolicBp : diastolicBp , sideEffectYn : sideEffectYn , sideEffectCds : sideEffectCds , sideEffectNm : sideEffectNm , transStopYn : transStopYn , executionDtTm : executionDtTm , bloodType : bloodType , bloodRhType : bloodRhType , prcpNm : prcpNm , prcpCd : prcpCd , prcpDd : prcpDd , transCheckupId1 : "" , transCheckupId2 : "" , transCheckupNm1 : "" , transCheckupNm2 : "" , transStopReasonCd : transStopReasonCd , transStopReasonEtc : transStopReasonEtc } self.safety.inputBloodHealthCheck(param, selectItem, inputBloodHealthCheckCallback, "finish"); // inputBloodHealthCheckCallback("", i, 3, "finish"); } } function inputBloodHealthCheckStep3() { executionDtTm = ""; var cnt = 0; for (var i = 0; i < selectItem.length; i++) { var hospitalCd = localStorage.getItem("hospitalCd"); var userId = gLoginUserId; var userDeptCd = localStorage.getItem("selectedDeptCd"); var patientId = $("#txtTransFusionSearch").val(); var prescriptionNo = selectItem[i].prescriptionNo; var bloodNo = selectItem[i].bloodNo; var bloodSeq = selectItem[i].bloodSeq; var bloodProduct = selectItem[i].bloodProduct; var bloodCheckupStatus = "04"; // 00 var pulse = $("#inputPulse").val(); var respiration = $("#inputRespiration").val(); var bodytemperature = $("#inputTemperature").val() + "." + $("#inputTemperatureSub").val(); //체온 var systolicBp = $("#inputSbp").val(); var diastolicBp = $("#inputDbp").val(); var sideEffectYn = "N"; var sideEffectCds = ""; var sideEffectNm = ""; var transStopYn = "N"; executionDtTm = self.util.toDatetimeFatima2(new Date()); var bloodType = selectItem[i].bloodType; var bloodRhType = selectItem[i].bloodRhType; var prcpNm = selectItem[i].prcpNm; var prcpCd = selectItem[i].prcpCd; var prcpDd = selectItem[i].prcpDd; var transCheckupId1 = $("#nfcDoctorId1").val(); var transCheckupId2 = $("#nfcDoctorId2").val(); var transCheckupNm1 = $("#nfcDoctorName1").text(); var transCheckupNm2 = $("#nfcDoctorName2").text(); var transStopReasonCd = ""; var transStopReasonEtc = ""; var param = { hospitalCd : hospitalCd , userId : userId , userDeptCd : userDeptCd , patientId : patientId , prescriptionNo : prescriptionNo , bloodNo : bloodNo , bloodSeq : bloodSeq , bloodProduct : bloodProduct , bloodCheckupStatus : bloodCheckupStatus, pulse : pulse , respiration : respiration , bodytemperature : bodytemperature , systolicBp : systolicBp , diastolicBp : diastolicBp , sideEffectYn : sideEffectYn , sideEffectCds : sideEffectCds , sideEffectNm : sideEffectNm , transStopYn : transStopYn , executionDtTm : executionDtTm , bloodType : bloodType , bloodRhType : bloodRhType , prcpNm : prcpNm , prcpCd : prcpCd , prcpDd : prcpDd , transCheckupId1 : transCheckupId1 , transCheckupId2 : transCheckupId2 , transCheckupNm1 : transCheckupNm1, transCheckupNm2 : transCheckupNm2, transStopReasonCd : transStopReasonCd, transStopReasonEtc : transStopReasonEtc } console.log("step3 param -- > " + JSON.stringify(param)); self.safety.inputBloodHealthCheck(param, selectItem, inputBloodHealthCheckCallback, "step3"); } } function inputBloodHealthCheckCallback(result, checkCnt, itemCount, stepName) { // stepName 마지막 단계인 경우 인증저장 시작 if (stepName == "finish1") { if (checkCnt == itemCount) { if (result == undefined) { alert("저장에 실패하였습니다."); } else { // 인증저장에 필요한 전역변수 초기화 successArr = []; failedArr = []; signDataArr = []; xmlDataArr = []; signDataArr = []; certXml = ""; maxIndex = 0; // result = "0000,0001,0000"; // 활력징후 입력 API 성공 여부 조회 var resultAr = result.split(","); for (var i = 0; i < resultAr.length; i++) { var resCode = resultAr[i]; if (resCode != "0000") { failedArr.push(selectItem[i]); // 활력징후 입력 실패 } else { successArr.push(selectItem[i]); // 활력징후 입력 성공 } } maxIndex = successArr.length - 1; // 네이티브 콜백에서 인덱스를 비교하기 위한 인덱스 for (var i = 0; i < successArr.length; i++) { var prescriptionNo = successArr[i].prescriptionNo; var bloodNo = successArr[i].bloodNo; var bloodSeq = successArr[i].bloodSeq; var bloodProduct = successArr[i].bloodProduct; var index = i; getCertDetailInfo(prescriptionNo, bloodNo, bloodSeq, bloodProduct, index); } } } } else { if (checkCnt == itemCount) { if (result == undefined) { alert("저장에 실패하였습니다."); } else { result = result.slice(0,-1); var resultAr = result.split(","); for (var i = 0; i < resultAr.length; i++) { var resCode = resultAr[i]; if (resCode != "0000") { alert("저장에 실패하였습니다."); return; } } $(".modal").modal("hide"); $(".modal-backdrop").modal("hide"); getPocPatientInfo($("#txtTransFusionSearch").val(), false); } } } } /** * successArr 데이터를 호출하여 상세정보 API Call * * @param {*} prescriptionNo * @param {*} bloodNo * @param {*} bloodSeq * @param {*} bloodProduct * @param {*} index certToNative 호출을 한 번만 하기위한 index 값 */ function getCertDetailInfo(prescriptionNo, bloodNo, bloodSeq, bloodProduct, index) { console.log("----------Start DetailApiCall----------"); var detailParam = { hospitalCd: localStorage.getItem("hospitalCd"), userId: gLoginUserId, patientId: patientArr[0].patientId, prescriptionNo: prescriptionNo, bloodNo: bloodNo, bloodSeq: bloodSeq, bloodProduct: bloodProduct } self.safety.getBloodDetailInfo(detailParam, index, certTempDetailInfo); } /** * * * @param {*} index getCertDetailInfo 에서 받아온 파라미터 * @param {*} lists getBloodDetailInfo 리턴 데이터 */ function certTempDetailInfo(index, lists) { console.log("----------Second DetailCallback----------" + JSON.stringify(lists)); var checkIndex = index + 1; // successArr 과 비교하여 네이티브를 한번만 호출 (checkIndex == successArr.length) doctorInfo = []; // doctorInfo 호출하기 전에 기존에 있는 데이터 초기화 필요, 아니면 3, 4로 쌓임 getDoctorId(lists[0].transCheckupId1, "cert"); // 시작간호사 호출 getDoctorId(lists[0].transCheckupId2, "cert"); // 확인간호사 호출 if (index == 0) { certXml += certXmlItem(lists); } else { certXml += "|%POC%|" + certXmlItem(lists); // 인증해야할 데이터가 여러개일 경우 단일 String -> Native(split) } // Callback 이 오기전에 상위 for loop 가 계속 돌아감 // 최상위 for문 i + 1 값과 successArr.length 가 같을 때 한 번만 호출 if (checkIndex == successArr.length) { certDataToNative(certXml); } } /** * xml 데이터와 Native 호출 * * @param {*} data XmlData */ function certDataToNative(data) { var msg = { type: "command", // 네이티브에서 Error, Command 구분 functionType: "certDataToNative", // 네이티브 함수 이름 value: { userId: gLoginUserId, // userId xmlData: data, // xmlData callbackFn: "window.activeObj.certCallback" // callback 함수명 } } self.toNative(msg) }; /** * @param {*} returnCode ex) {"success" : "0000", "index" : "0"} * @param {*} signData 사인데이터 * @param {*} xmlData XML 원본 데이터 */ this.certCallback = function(returnCode, signData, xmlData) { // reutrnCode JSON Parse var result = new Object(); if (typeof returnCode === "string") { result = JSON.parse(returnCode); } else { result = returnCode; } console.log("first failedArr -- > " + JSON.stringify(failedArr)); var index = Number(result.index); // index를 String으로 받아오기 때문에 Number로 형변환 하여 사용함 console.log("index -- > " + index); if (self.util.isEmpty(result)) { alert("인증저장에 실패하였습니다 \n 다시 시도 해주세요."); } else { if (result.success == "0000") { // 성공 했을 경우 사인데이터와 xml데이터를 전역 Arr에 담음 signDataArr.push(signData); xmlDataArr.push(xmlData); } else { failedArr.push(successArr[index]); // failedArr 에 추가함 (failedArr 은 순서 상관 없음) console.log("second failedArr -- > " + JSON.stringify(failedArr)); successArr.splice(index, 1); // 실패 했을 경우 successArr 해당 인덱스를 제거 } } // 네이티브 for문 index 값과 로직이 돌기 전 successArr 길이가 같다면 아래 for loop 수행 if (index == maxIndex) { for (var i = 0; i < successArr.length; i++) { var param = { hospitalCd: localStorage.getItem("hospitalCd"), userId: gLoginUserId, patientId: successArr[i].patientId, prescriptionNo: successArr[i].prescriptionNo, bloodNo: successArr[i].bloodNo, bloodSeq: successArr[i].bloodSeq, bloodProduct: successArr[i].bloodProduct, // bloodXmlData: btoa(unescape(encodeURIComponent(xmlDataArr[i]))), bloodXmlData: xmlDataArr[i], bloodSignData: signDataArr[i] // bloodXmlData: "TEST", // bloodSignData: "TESTTEST" } self.safety.inputBloodSignData(param, successArr, inputBloodSignDataCallback); } } }; /** * 인증저장 Callback, 기본적인 구조는 inputBloodHealthCheck 와 같음 * * @param {*} result returnCode ex) "0000,0001,0000,0001" * @param {*} checkCnt API 가 호출된 횟수 * @param {*} itemCnt successArr.length */ function inputBloodSignDataCallback(result, checkCnt, itemCnt) { console.log("result -- > " + result); if (checkCnt == itemCnt) { if (result == undefined) { alert("저장에 실패하였습니다."); } else { result = result.slice(0,-1); var resultAr = result.split(","); // 실패한 코드가 내려오면 successArr index 값을 제거 후 failedArr 에 추가 for (var i = 0; i < resultAr.length; i++) { var resCode = resultAr[i]; if (resCode != "0000") { successArr.splice(i, 1); failedArr.push(selectItem[i]); } } if (failedArr.length > 0) { for (var i = 0; i < failedArr.length; i++) { if (self.util.isEmpty(failedArr[i])) { failedArr.splice(i, 1); } } } console.log("real failedArr -- > " + JSON.stringify(failedArr)); var successMsg = ""; var failMsg = ""; console.log("successArr -- > " + JSON.stringify(successArr)); // Alert에 보여줄 Message 정의 (혈액번호가 리스트에 보여지므로 혈액번호로 정의함) if (successArr.length != 0 || failedArr.length != 0) { if (successArr.length != 0) { for (var i = 0; i < successArr.length; i++) { if (i == 0) { successMsg += successArr[i].bloodNo; } else { successMsg += ", " + successArr[i].bloodNo; } } } if (failedArr.length != 0) { for (var i = 0; i < failedArr.length; i++) { if (i == 0) { failMsg += failedArr[i].bloodNo; } else { failMsg += ", " + successArr[i].bloodNo; } } } alert("인증 성공(혈액번호) \n " + successMsg + "\n 인증 실패(혈액번호) \n" + failMsg); $(".modal").modal("hide"); $(".modal-backdrop").modal("hide"); getPocPatientInfo($("#txtTransFusionSearch").val(), false); } } } } /** * @param {*} lists 호출된 상세정보 리스트 */ var certXmlItem = function(lists) { var endDate = self.util.toDatetimeFatima2(new Date()); // YYYYMMddHHmm var certXml = ""; certXml = "" + " " + " " + self.util.isXmlEmpty(patientArr[0].patientId) + "" + " "+ self.util.isXmlEmpty(patientArr[0].patientNm) + "" + " " + " " + " " + " " + self.util.isXmlEmpty(patientArr[0].insukind) + "" + " " + self.util.isXmlEmpty(patientArr[0].deptNm) + "" + " " + self.util.isXmlEmpty(patientArr[0].doctorNm) + "" + " " + " " + " " + " " + " " + self.util.isXmlEmpty(lists[0].bloodNo) + "" + " " + " " + " " + self.util.isXmlEmpty(lists[0].startDtTm.slice(0,8)) + "" + " " + self.util.isXmlEmpty(lists[0].startDtTm.slice(8)) + "" + " " + endDate.slice(0, 8) + "" + " " + endDate.slice(8) + "" + " " + self.util.isXmlEmpty(doctorInfo[0].deptNm) + "" + " " + self.util.isXmlEmpty(doctorInfo[0].doctorNm) + "" + " " + self.util.isXmlEmpty(doctorInfo[1].deptNm) +"" + " " + self.util.isXmlEmpty(doctorInfo[1].doctorNm) + "" + " " + self.util.isXmlEmpty(lists[0].transStopYn) + " " + " " + self.util.isXmlEmpty(lists[0].drugqty) + "" + " " + " " + self.util.isXmlEmpty(doctorInfo[0].doctorId) + "," + self.util.isXmlEmpty(doctorInfo[0].doctorNm) + ",,," + self.util.isXmlEmpty(doctorInfo[0].deptNm) + "," + self.util.isXmlEmpty(doctorInfo[0].deptCd) + "" + " " + self.util.isXmlEmpty(doctorInfo[1].doctorId) + "," + self.util.isXmlEmpty(doctorInfo[1].doctorNm) + ",,," + self.util.isXmlEmpty(doctorInfo[1].deptNm) + "," + self.util.isXmlEmpty(doctorInfo[1].deptCd) + "" + " " + self.util.isXmlEmpty(lists[0].sideEffectNms) + " " + " " + self.util.isXmlEmpty(lists[0].instcd) + " " + " " + " " + self.util.isXmlEmpty(lists[0].prcpno) + " " + " " + self.util.isXmlEmpty(lists[0].drugqty) + " " + " " + self.util.isXmlEmpty(lists[0].tnscarerecseq) + " " + " " + self.util.isXmlEmpty(doctorInfo[1].deptNm) +" " + " " + self.util.isXmlEmpty(doctorInfo[1].doctorId) + "," + self.util.isXmlEmpty(doctorInfo[1].doctorNm) + ",,," + self.util.isXmlEmpty(doctorInfo[1].deptNm) + "," + self.util.isXmlEmpty(doctorInfo[1].deptCd) + " " + " " + self.util.isXmlEmpty(doctorInfo[1].doctorNm) + " " + " " + " " + " " + " u " + " " + self.util.isXmlEmpty(lists[0].startDtTm.slice(0,8)) + " " + " " + self.util.isXmlEmpty(lists[0].startDtTm.slice(8)) + " " + " 수혈시작 " + " " + " " + self.util.isXmlEmpty(lists[0].transBfPulse) + " " + " " + self.util.isXmlEmpty(lists[0].transBfRespiration) + " " + " " + " " + self.util.isXmlEmpty(lists[0].tnscarerecseq) + " " + " 1 " + " " + self.util.isXmlEmpty(lists[0].instcd) + " " + " " + self.util.isXmlEmpty(lists[0].bloodNo) + " " + " " + self.util.isXmlEmpty(patientArr[0].patientId) + " " + " " + self.util.isXmlEmpty(lists[0].prcpCd) + " " + " " + " " + " u " + " " + self.util.isXmlEmpty(lists[0].trans15dttm.slice(0, 8)) + " " + " " + self.util.isXmlEmpty(lists[0].trans15dttm.slice(8)) + " " + " 수혈15분이내 " + " " + " " + self.util.isXmlEmpty(lists[0].trans15Pulse) + " " + " " + self.util.isXmlEmpty(lists[0].trans15Respiration) + " " + " " + " " + self.util.isXmlEmpty(lists[0].tnscarerecseq) + " " + " 2 " + " " + self.util.isXmlEmpty(lists[0].instcd) + " " + " " + self.util.isXmlEmpty(lists[0].bloodNo) + " " + " " + self.util.isXmlEmpty(patientArr[0].patientId) + " " + " " + self.util.isXmlEmpty(lists[0].prcpCd) + " " + " " + " " + " u " + " " + self.util.isXmlEmpty(lists[0].transafdttm.slice(0, 8)) + " " + " " + self.util.isXmlEmpty(lists[0].transafdttm.slice(8)) + " " + " 수혈종료 " + " " + " " + self.util.isXmlEmpty(lists[0].transAfPulse) + " " + " " + self.util.isXmlEmpty(lists[0].transAfRespiration) + " " + " " + " " + self.util.isXmlEmpty(lists[0].tnscarerecseq) + " " + " 3 " + " " + self.util.isXmlEmpty(lists[0].instcd) + " " + " " + self.util.isXmlEmpty(lists[0].bloodNo) + " " + " " + self.util.isXmlEmpty(patientArr[0].patientId) + " " + " " + self.util.isXmlEmpty(lists[0].prcpCd) + " " + " " + " " + " " + " " + " " + self.util.isXmlEmpty(localStorage.getItem("selectedUserId")) + "" + " " + self.util.isXmlEmpty(localStorage.getItem("selectedUserNm")) + "" + " " + self.util.isXmlEmpty(localStorage.getItem("posinstnm")) + "" + " " + self.util.isXmlEmpty(localStorage.getItem("posdeptnm")) + "" + " " + self.util.isXmlEmpty(localStorage.getItem("dutplceinstnm")) + "" + " " + self.util.isXmlEmpty(localStorage.getItem("dutplcenm")) + "" + " " + self.util.isXmlEmpty(localStorage.getItem("selectedJobKindNm")) + "" + " " + self.util.isXmlEmpty(localStorage.getItem("jobposnm")) + "" + " " + self.util.isXmlEmpty(localStorage.getItem("selectedUserId")) + "" + " " + self.util.isXmlEmpty(localStorage.getItem("prfshipflagnm")) + "" + " " + self.util.isXmlEmpty(localStorage.getItem("deptabbr")) + "" + " " + self.util.isXmlEmpty(localStorage.getItem("systemnm")) + "" + " " + self.util.isXmlEmpty(localStorage.getItem("systeminstnm")) + "" + " " + self.util.isXmlEmpty(localStorage.getItem("initLoginDtTm")) + "" + " " + ""; return certXml; } function getSideFinishEffectList() { var param = { hospitalCd : localStorage.getItem("hospitalCd"), userId : gLoginUserId } self.safety.getSideEffectList(param, getSideEffectListFinishCallback); } function getSideEffectListFinishCallback(output) { $("#sideEffectFinish").children().remove(); for (var i = 0; i < output.length; i++) { var sideEffectNm = output[i].sideEffectNm.trim(); var sideEffectCd = output[i].sideEffectCd.trim(); var div = "
    " + "
    " + " " + "
    " + " " + " " + "
    " + "
    " + "
    " + sideEffectNm + " " + "
    " + "
    "; if (sideEffectNm == "기타") { div = "
    " + "
    " + " " + "
    " + " " + " " + "
    " + "
    " + "
    " + sideEffectNm + " " + " " + "
    " + "
    "; } // $(".modal-body.pt-4.pb-4").append(div); $("#sideEffectFinish").append(div); } var sideEffectCds = selectItem[0].sideEffectCds; var realSideEffects = sideEffectCds.split("^"); // var sideEffectCds = "02^03^07"; // var realSideEffects = sideEffectCds.split("^"); if (realSideEffects.length > 0) { for (var i = 0; i < realSideEffects.length; i++) { for (var j = 0; j < output.length; j++) { if (realSideEffects[i] == output[j].sideEffectCd) { $("#b" + (j + 1)).prop("checked", true); if (output[j].sideEffectCd == "07") { $("#sideEffectEtc2").prop("checked", true); $("#inputFinishEtc").attr("disabled", false); $("#inputFinishEtc").val(output[j].sideEffectNm); } } } } } $("#sideEffectEtc2").off("click"); $("#sideEffectEtc2").on("click", function() { if ($("#sideEffectEtc2").is(":checked") == true) { $("#inputFinishEtc").attr("disabled", false); } else { $("#inputFinishEtc").attr("disabled", true); } }); $("#sideEffectButton2").off("click"); $("#sideEffectButton2").on("click", function() { $("#sideEffect_pop2").modal("hide"); // $("#sideEffect_pop").attr("style", "display: none"); }); // $("#transfusionStop2").off("click"); // $("#transfusionStop2").on("click", function() { // var checkCnt = 0; // for (var i = 0; i < $("input[name=sideEffectChk2]").length; i++) { // if ($("input[name=sideEffectChk2]").eq(i).is(":checked") == true) { // checkCnt = checkCnt + 1; // } // } // if ($("#inputPulse3").val() == "" || $("#inputRespiration3").val() == "" // || $("#inputTemperature3").val() == "" || $("#inputTemperatureSub3").val() == "" // || $("#inputSbp3").val() == "" || $("#inputDbp3").val() == "") { // alert("미입력된 항목이 있습니다. \n입력 후, 진행이 가능합니다."); // return; // } // if (checkCnt == 0) { // alert("미입력된 항목이 있습니다. \n입력 후, 진행이 가능합니다."); // } else { // inputBloodHealthCheckFinishStep("Y", 0); // // $("#sideEffect_pop").attr("style", "display: none"); // $("#sideEffect_pop2").modal("hide"); // $(".modal").modal("hide"); // $(".modal-backdrop").modal("hide"); // getPocPatientInfo($("#txtTransFusionSearch").val(), false); // } // }); } function getTransStopReasonList(type) { var param = { hospitalCd : localStorage.getItem("hospitalCd"), userId : gLoginUserId } self.safety.getTransStopReasonList(param, type ,getTransStopReasonListCallBack); } function getTransStopReasonListCallBack(type, output) { if (type == "Step2") { secondStepTransYn(output); } else if (type == "Step3") { thirdstepTransYn(output); } } function secondStepTransYn(output) { $("#reasonEtcDiv").attr("style", "display: none;"); $("#reasonBox").attr("disabled", true); $("#raN1").prop('checked', true); $("#reasonBox").empty(); $("#reasonEtc").val(""); var reason = ""; for (var i = 0; i < output.length; i++) { var transStopReasonNm = output[i].transStopReasonNm; var transStopReasonCd = output[i].transStopReasonCd; reason += " "; } $("#reasonBox").append(reason); $("#raY1").off("click"); $("#raY1").on("click", function() { if ($("#raY1").is(":checked") == true) { $("#reasonBox").attr("disabled", false); if ($("#reasonBox option:selected").text().trim() == "기타") { $("#reasonEtcDiv").attr("style", "display: ;"); } } else { $("#reasonBox").attr("disabled", true); $("#reasonEtcDiv").attr("style", "display: none;"); } }); $("#raN1").off("click"); $("#raN1").on("click", function() { if ($("#raN1").is(":checked") == true) { $("#reasonBox").attr("disabled", true); $("#reasonEtcDiv").attr("style", "display: none;"); } else { $("#reasonBox").attr("disabled", false); if ($("#reasonBox option:selected").text().trim() == "기타") { $("#reasonEtcDiv").attr("style", "display: ;"); } } }); $("#reasonBox").change(function() { $("#reasonBox option:selected").each(function() { var selectEtc = $("#reasonBox option:selected").text().trim(); if (selectEtc == "기타") { $("#reasonEtcDiv").attr("style", "display: ;"); } else { $("#reasonEtcDiv").attr("style", "display: none;"); } }); }); } function thirdstepTransYn(output) { $("#reasonEtcDiv2").attr("style", "display: none;"); $("#reasonBox2").attr("disabled", true); $("#raN2").prop('checked', true); $("#reasonBox2").empty(); $("#reasonEtc2").val(""); var selectTransStopYn = selectItem[0].transStopYn; var selectTransStopReasonEtc = selectItem[0].transStopReasonEtc; var selectTransStopReasonCd = selectItem[0].transStopReasonCd; var reason = ""; for (var i = 0; i < output.length; i++) { var transStopReasonNm = output[i].transStopReasonNm; var transStopReasonCd = output[i].transStopReasonCd; reason += " "; } $("#reasonBox2").append(reason); if (selectTransStopYn == "Y") { $("#raY2").prop("checked", true); $("#reasonBox2").attr("disabled", false); for (var i = 0; i < output.length; i++) { if (selectTransStopReasonCd == output[i].transStopReasonCd) { // $("#reasonBox2").selectpicker('refresh'); // $("#reasonBox2").selectpicker("val", output[i].transStopReasonNm); $("#reasonBox2 option:eq(" + i + ")").attr("selected", "selected"); if (output[i].transStopReasonCd.trim() == "12399") { $("#reasonBox2 option:eq(" + i + ")").attr("selected", "selected"); $("#reasonEtc2").val(selectTransStopReasonEtc); $("#reasonEtcDiv2").attr("style", "display: ;"); } } } } $("#raY2").off("click"); $("#raY2").on("click", function() { if ($("#raY2").is(":checked") == true) { $("#reasonBox2").attr("disabled", false); if ($("#reasonBox2 option:selected").text().trim() == "기타") { $("#reasonEtcDiv2").attr("style", "display: ;"); } } else { $("#reasonBox2").attr("disabled", true); $("#reasonEtcDiv2").attr("style", "display: none;"); } }); $("#raN2").off("click"); $("#raN2").on("click", function() { if ($("#raN2").is(":checked") == true) { $("#reasonBox2").attr("disabled", true); $("#reasonEtcDiv2").attr("style", "display: none;"); } else { $("#reasonBox2").attr("disabled", false); if ($("#reasonBox2 option:selected").text().trim() == "기타") { $("#reasonEtcDiv2").attr("style", "display: ;"); } } }); $("#reasonBox2").change(function() { $("#reasonBox2 option:selected").each(function() { var selectEtc = $("#reasonBox2 option:selected").text().trim(); if (selectEtc == "기타") { $("#reasonEtcDiv2").attr("style", "display: ;"); } else { $("#reasonEtcDiv2").attr("style", "display: none;"); } }); }); } function getSideEffectList() { var param = { hospitalCd : localStorage.getItem("hospitalCd"), userId : gLoginUserId } self.safety.getSideEffectList(param, getSideEffectList15Callback); } function getSideEffectList15Callback(output) { $("#sideEffectPop").children().remove(); for (var i = 0; i < output.length; i++) { var sideEffectNm = output[i].sideEffectNm.trim(); var sideEffectCd = output[i].sideEffectCd.trim(); var div = "
    " + "
    " + " " + "
    " + " " + " " + "
    " + "
    " + "
    " + sideEffectNm + " " + "
    " + "
    "; if (sideEffectNm == "기타") { div = "
    " + "
    " + " " + "
    " + " " + " " + "
    " + "
    " + "
    " + sideEffectNm + " " + " " + "
    " + "
    "; } // $(".modal-body.pt-4.pb-4").append(div); $("#sideEffectPop").append(div); } $("#sideEffectEtc").off("click"); $("#sideEffectEtc").on("click", function() { if ($("#sideEffectEtc").is(":checked") == true) { $("#inputEtc").attr("disabled", false); } else { $("#inputEtc").attr("disabled", true); } }); $("#sideEffectButton").off("click"); $("#sideEffectButton").on("click", function() { $("#sideEffect_pop").modal("hide"); // $("#sideEffect_pop").attr("style", "display: none"); }); $("#transfusionStop").off("click"); $("#transfusionStop").on("click", function() { var checkCnt = 0; for (var i = 0; i < $("input[name=sideEffectChk]").length; i++) { if ($("input[name=sideEffectChk]").eq(i).is(":checked") == true) { checkCnt = checkCnt + 1; } } if ($("#inputPulse2").val() == "" || $("#inputRespiration2").val() == "" || $("#inputTemperature2").val() == "" || $("#inputTemperatureSub2").val() == "" || $("#inputSbp2").val() == "" || $("#inputDbp2").val() == "") { alert("미입력된 항목이 있습니다. \n입력 후, 진행이 가능합니다."); return; } if (checkCnt == 0) { alert("미입력된 항목이 있습니다. \n입력 후, 진행이 가능합니다."); } else { inputBloodHealthCheckStep4("Y"); // $("#sideEffect_pop").attr("style", "display: none"); $("#sideEffect_pop").modal("hide"); $(".modal").modal("hide"); $(".modal-backdrop").modal("hide"); getPocPatientInfo($("#txtTransFusionSearch").val(), false); } }); } function inputBloodHealthCheckStep4(stopYn, convertStrDate) { stopYn = stopYn == "Y" ? stopYn : "N"; var sideEffect = "N"; var sideEffectCode = ""; var sideEffectName = ""; for (var i = 0; i < $("input[name=sideEffectChk]").length; i++) { if ($("input[name=sideEffectChk]").eq(i).is(":checked") == true) { sideEffect = "Y"; var _sideEffectName = $("input[name=sideEffectChk]").eq(i).parent().parent().children().eq(1).text().trim(); var _sideEffectCode = $("input[name=sideEffectCode]").eq(i).val().trim(); // sideEffectCode += "CD:" + _sideEffectCode + "^"; sideEffectCode += _sideEffectCode + "^"; if (_sideEffectName == "기타") { sideEffectName = $("#inputEtc").val(); } } } var transStopReasonCd = ""; var transStopReasonEtc = ""; if (stopYn == "Y") { if ($("#raY1").is(":checked") == true) { transStopReasonCd = $("#reasonBox option:selected").val(); if ($("#reasonBox option:selected").text().trim() == "기타") { transStopReasonEtc = $("#reasonEtc").val(); } } else { transStopReasonCd = ""; transStopReasonEtc = ""; } } else { transStopReasonCd = ""; transStopReasonEtc = ""; } sideEffectCode = sideEffectCode.slice(0,-1); executionDtTm = ""; var cnt = 0; for (var i = 0; i < selectItem.length; i++) { var hospitalCd = localStorage.getItem("hospitalCd"); var userId = gLoginUserId; var userDeptCd = localStorage.getItem("selectedDeptCd"); var patientId = $("#txtTransFusionSearch").val(); var prescriptionNo = selectItem[i].prescriptionNo; var bloodNo = selectItem[i].bloodNo; var bloodSeq = selectItem[i].bloodSeq; var bloodProduct = selectItem[i].bloodProduct; var bloodCheckupStatus = "05"; var pulse = $("#inputPulse2").val(); var respiration = $("#inputRespiration2").val(); var bodytemperature = $("#inputTemperature2").val() + "." + $("#inputTemperatureSub2").val(); //체온 var systolicBp = $("#inputSbp2").val(); var diastolicBp = $("#inputDbp2").val(); var sideEffectYn = sideEffect; var sideEffectCds = sideEffectCode; var sideEffectNm = sideEffectName; var transStopYn = stopYn; console.log("stopYn -- > " + stopYn); executionDtTm = moment(convertStrDate).format("YYYYMMDDHHmm"); console.log("executionDtTm -- > " + executionDtTm); var bloodType = selectItem[i].bloodType; var bloodRhType = selectItem[i].bloodRhType; var prcpNm = selectItem[i].prcpNm; var prcpCd = selectItem[i].prcpCd; var prcpDd = selectItem[i].prcpDd; var transCheckupId1 = ""; var transCheckupId2 = ""; transStopReasonCd = transStopReasonCd; console.log("transStopReasonCd -- > " + transStopReasonCd); transStopReasonEtc = transStopReasonEtc; console.log("transStopReasonEtc -- > " + transStopReasonEtc); var param = { hospitalCd : hospitalCd , userId : userId , userDeptCd : userDeptCd , patientId : patientId , prescriptionNo : prescriptionNo , bloodNo : bloodNo , bloodSeq : bloodSeq , bloodProduct : bloodProduct , bloodCheckupStatus : bloodCheckupStatus, pulse : pulse , respiration : respiration , bodytemperature : bodytemperature , systolicBp : systolicBp , diastolicBp : diastolicBp , sideEffectYn : sideEffectYn , sideEffectCds : sideEffectCds , sideEffectNm : sideEffectNm , transStopYn : transStopYn , executionDtTm : executionDtTm , bloodType : bloodType , bloodRhType : bloodRhType , prcpNm : prcpNm , prcpCd : prcpCd , prcpDd : prcpDd , transCheckupId1 : "" , transCheckupId2 : "" , transStopReasonCd : transStopReasonCd , transStopReasonEtc : transStopReasonEtc, transCheckupNm1 : "", transCheckupNm2 : "" } console.log("inputBloodHealthCheckStep4 param -- > " + JSON.stringify(param)); // self.safety.inputBloodHealthCheck(param, inputBloodHealthCheckCallback, selectItem); self.safety.inputBloodHealthCheck(param, selectItem, inputBloodHealthCheckCallback, "step4"); }; } // Step01 NFC 태그 이벤트 this.nfctagCallback = function(doctorId){ if(self.util.isEmpty(doctorId)){ $("#Modal01 .modal-body h4").text("NFC 정보가 없습니다"); $("#Modal01 .modal-body p").text("NFC 정보를 확인하여 주세요"); $("#Modal01").modal("show"); return; } else { var stringData = String(doctorId); stringData = stringData.padStart(10, '0'); getNfcDoctorId(stringData); console.log('NFC TAG READ: ' + stringData); } }; // Step01 NFC 태그 후 의료진 정보 API 호출 var getNfcDoctorId = function(doctorId) { var param = { hospitalCd: localStorage.getItem("hospitalCd"), nfcId : doctorId } self.safety.getNfcDoctorId(param, processGetNfcDoctorId); }; // 의료진 정보 API Callback var processGetNfcDoctorId = function(result) { var checkUpDoctorIdList = $("#inputDoctor input[name=checkUpDoctorId]"); if (checkUpDoctorIdList.length >= 2) { alert("의료진은 최대 2명 까지 입력 가능합니다."); } else { for (var i = 0; i < checkUpDoctorIdList.length; i++) { var _doctorId = checkUpDoctorIdList[i].value; if (_doctorId.trim() == result[0].doctorId.trim()) { alert("의료진 정보가 중복되었습니다."); return; } } } if(result.length == 0) { alert("조회된 의료진이 없습니다."); } else { if(result.length == 0){ alert("조회된 의료진이 없습니다."); } else { $("#doctorEmpty").attr("style", "display: none;"); if ($("#nfcDoctorId1").val() == "") { $("#nfcDoctorId1").val(""); $("#nfcDoctorName1").text(""); $("#checkUpDoctorId1").remove(); $("#nfcDoctorName1").text(result[0].doctorNm.trim()) $("#nfcDoctorId1").val(result[0].doctorId.trim()); $("#nfcDoctorId1").parent().append(""); } else if ($("#nfcDoctorId2").val() == "") { $("#nfcDoctorId2").val(""); $("#nfcDoctorName2").text(""); $("#checkUpDoctorId2").remove(); $("#nfcDoctorName2").text(result[0].doctorNm.trim()) $("#nfcDoctorId2").val(result[0].doctorId.trim()); $("#nfcDoctorId2").parent().append(""); } $("#inputDoctor div button").on("click", function() { $(this).parent().parent().children().eq(0).children().eq(0).val(""); $(this).parent().parent().children().eq(0).children().eq(1).remove(); $(this).parent().parent().children().eq(1).text("") }); } } }; var getDoctorId = function (doctorId, type) { var param = { hospitalCd: localStorage.getItem("hospitalCd"), userId: gLoginUserId, doctorId: doctorId } self.schedule.getDoctorInfo(param, processGetDoctorId, type); }; var processGetDoctorId = function(output, type) { if (output.length == 0) { alert("조회된 정보가 없습니다. 사번을 확인하여 주세요"); if (type == "first") { $("#nfcDoctorId1").val(""); } else if (type == "second") { $("#nfcDoctorId2").val(""); } } else { if (type == "first") { $("#nfcDoctorName1").text(output[0].doctorNm); } else if (type == "second") { $("#nfcDoctorName2").text(output[0].doctorNm); } else if (type == "cert") { doctorInfo.push(output[0]); console.log("----------Third DoctorInfo----------" + JSON.stringify(doctorInfo)); } } } /** * 문자열 일자 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); var d = str.substr(6, 2); var h = str.substr(8, 2); var mm = str.substr(10, 2); return new Date(y,m-1,d,h,mm); } /** * 문자열 일자 Date로 변환 * ex) 20200212143010 * YYYY-MM-DD HH:mm:ss */ function fullDateParse(str) { if(!/^(\d){14}$/.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); var ss = str.substr(12, 2); return new Date(y,m,d,h,mm,ss); } /** * 문자열 일자 Date로 변환 * ex) 02 12 14 30 * MM-DD HH:mm */ function dateParse2(str) { if(!/^(\d){8}$/.test(str) || str == "") return ""; var m = str.substr(0, 2); var d = str.substr(2, 2); var h = str.substr(4, 2); var mm = str.substr(6, 2); return new Date(m, d, h, mm); } // 기본 클릭 이벤트 및 여러 이벤트 추가 var addEvent = function() { eventCondition(); eventBackBlock(); }; //검색 페이지 뒤로가기 막기 var eventBackBlock = function() { $(window).off("pageshow"); $(window).bind("pageshow", function(event) { if (event.originalEvent.persisted) { document.location.reload(); } }); }; var eventCondition = function() { /** * 조회 버튼 클릭 이벤트 */ $("#btnTransFusionSearch").off("click"); $("#btnTransFusionSearch").on("click", function() { $(this).blur(); var txtSearch = $("#txtTransFusionSearch").val(); if (txtSearch == "") { $("#Modal01 .modal-body h4").text("입력된 환자번호가 없습니다."); $("#Modal01 .modal-body p").text("환자번호를 입력해주세요."); $("#Modal01").modal("show"); } else { $("#btnTransFusionSearch").removeClass("btn-secondary").addClass("btn-primary"); getPocPatientInfo($("#txtTransFusionSearch").val(), false); } }); // Enter 입력시 검색 $("#txtTransFusionSearch").off("keydown"); $("#txtTransFusionSearch").on("keydown", function(e) { if (e.keyCode == 13 && $("#txtTransFusionSearch").val().length != 0) { $("#btnTransFusionSearch").removeClass("btn-secondary").addClass("btn-primary"); initPatientInfo(); getPocPatientInfo($("#txtTransFusionSearch").val(), false); } else if (e.keyCode == 13 && $("#txtTransFusionSearch").val().length == 0) { $("#Modal01 .modal-body h4").text("입력된 환자번호가 없습니다."); $("#Modal01 .modal-body p").text("환자번호를 입력해주세요."); $("#Modal01").modal("show"); $("#txtTransFusionSearch").focus(); } }); $(".btn_close.float-right").off("click"); $(".btn_close.float-right").on("click", function() { $(".modal").modal("hide"); $(".modal-backdrop").modal("hide"); getPocPatientInfo($("#txtTransFusionSearch").val(), false); }); /** * 활력징후 삭제 버튼 이벤트 시작 */ $("#bfPulseDel").off("click"); $("#bfPulseDel").on("click", function() { $("#inputPulse").val(""); }); $("#bfRespirationDel").off("click"); $("#bfRespirationDel").on("click", function() { $("#inputRespiration").val(""); }); $("#bfTempDel").off("click"); $("#bfTempDel").on("click", function() { $("#inputTemperature").val(""); $("#inputTemperatureSub").val(""); }); $("#bfSbpDel").off("click"); $("#bfSbpDel").on("click", function() { $("#inputSbp").val(""); }); $("#bfDbpDel").off("click"); $("#bfDbpDel").on("click", function() { $("#inputDbp").val(""); }); $("#15PulseDel").off("click"); $("#15PulseDel").on("click", function() { $("#inputPulse2").val(""); }); $("#15RespirationDel").off("click"); $("#15RespirationDel").on("click", function() { $("#inputRespiration2").val(""); }); $("#15TempDel").off("click"); $("#15TempDel").on("click", function() { $("#inputTemperature2").val(""); $("#inputTemperatureSub2").val(""); }); $("#15SbpDel").off("click"); $("#15SbpDel").on("click", function() { $("#inputSbp2").val(""); }); $("#15DbpDel").off("click"); $("#15DbpDel").on("click", function() { $("#inputDbp2").val(""); }); $("#afPulseDel").off("click"); $("#afPulseDel").on("click", function() { $("#inputPulse3").val(""); }); $("#afRespirationDel").off("click"); $("#afRespirationDel").on("click", function() { $("#inputRespiration3").val(""); }); $("#afTempDel").off("click"); $("#afTempDel").on("click", function() { $("#inputTemperature3").val(""); $("#inputTemperatureSub3").val(""); }); $("#afSbpDel").off("click"); $("#afSbpDel").on("click", function() { $("#inputSbp3").val(""); }); $("#afDbpDel").off("click"); $("#afDbpDel").on("click", function() { $("#inputDbp3").val(""); }); /** * 활력징후 삭제 버튼 이벤트 끝 */ /** * Step1 의료진 수동 입력 삭제버튼 */ $("#delFirstDoctor").off("click"); $("#delFirstDoctor").on("click", function() { $("#nfcDoctorId1").val(""); $("#nfcDoctorName1").text(""); }); $("#delSecondDoctor").off("click"); $("#delSecondDoctor").on("click", function() { $("#nfcDoctorId2").val(""); $("#nfcDoctorName2").text(""); }); /** * Step1 의료진 수동 입력 삭제버튼 끝 */ }; };