123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569 |
- "use strict";
- /**
- * mplus_safety_bleeding
- */
- var mplus_safety_bleeding = function() {
- // 상속
- mplus_common.call(this);
- //super
- var self = this;
- var curPage = "";
- var testId = localStorage.getItem("initLoginDtTm");
- console.log(testId);
- //==== 변수 { ====
-
- var varResultLists = [];
- var patientInfo = [];
-
- /* Fatima 전역 변수 */
- var specimenSearchCls = 0; // 실시조회 및 취소조회 검색 조건(실시 = 0, 취소 = 1)
- var gActSpecimenType = "Y"; // 실시조회 및 취소조회 검색 조건(처리 = Y, 취소 = C)
- var checkBoxArr = []; // checkBox 선택된 list를 따로 배열로 이동
- /* Fatima 전역 변수 */
- //==== 변수 } ====
- /**
- * 초기화
- */
- this.init = function() {
- //여기서 모든화면 콤보박스데이터를 집어넣자!!! 그래야지 화면이동할때 속도가 오래걸리지않음!!!
- localStorage.removeItem("defaultHomePage");
- localStorage.setItem("defaultHomePage", "bleeding");
- // 초기 화면 조건 구성
- initCondition();
- // 이벤트 초기화
- addEvent();
- // 환자 검색 실행 및 환자 정보 화면 출력
- //searchPatient();
- $("#txtBleedingPatientSearch").focus();
- };
- this.barcodeCallback = function(data){
- console.log("barcode read! inside bleeding.js");
- // null 이라면 반환
- if(self.util.isEmpty(data)){
- return;
- }
- else{
- var result = self.util.decodeBarcode(data);
- }
- if(self.util.isEmpty(result) || result.type == 'errBarcode'){
- $("#txtBleedingPatientSearch").blur();
- // if(result === null || result === undefined || result.type == 'errBarcode'){
- $("#alertBarcodeCheck").modal("show");
- return;
- }
- // 환자 번호라면
- else if(result.type == 'pid'){
- $("#txtBleedingPatientSearch").blur();
- // 최초 리딩 시 환자 정보 초기화
- $("#txtBleedingPatientSearch").val('');
- var patientId = result.data;
- $("#txtBleedingPatientSearch").val(patientId);
-
- if (gActSpecimenType == "Y") {
- $("#btnBleedingList").removeClass().addClass("btn btn-primary btn-block");
- $("#btnBleedingAct").removeClass().addClass("btn btn-danger btn-block");
- $("#btnCancleList").removeClass().addClass("btn btn-secondary btn-block");
- $("#btnBleedingAct").text("채혈 실시");
- } else {
- $("#btnBleedingList").removeClass().addClass("btn btn-secondary btn-block");
- $("#btnBleedingAct").removeClass().addClass("btn btn-danger btn-block");
- $("#btnCancleList").removeClass().addClass("btn btn-councel btn-block");
- $("#btnBleedingAct").text("채혈 취소");
- }
- getPocPatientInfo(patientId, false);
- }
- // 채혈 번호라면
- else if(result.type == 'specimenCd'){
- $("#txtBleedingPatientSearch").blur();
- if(self.util.isEmpty(patientInfo) || patientInfo.length == 0){
- $("#alertEmptyPatient").modal("show");
- return;
- }
- // 3 번째를 barcode
- //varResultLists
- var foundCnt = 0;
-
- for(var idx = 0; idx < varResultLists.length; idx++){
- if(varResultLists[idx].mainSpecimenCd == result.data){
- console.log("label[for='checkBleedingSel" + idx + "']");
- var labelObj = $("label[for='checkBleedingSel" + idx + "']");
- labelObj.attr('class', 'btn btn-barcode icon');
- var iptObj = $('input:checkbox[id="checkBleedingSel' + idx + '"]');
- iptObj.prop('checked', true);
- var li = $('li[id="listGroupItem_' + idx + '"]');
- li.addClass("active");
- foundCnt++;
- }
- }
- if(foundCnt == 0){
- $('#alertSpecimen').modal('show');
- }
- }
- else{
- $("#txtBleedingPatientSearch").blur();
- $("#alertBarcodeCheck").modal("show");
- }
- };
- //==== 초기화 설정 { ====
- var initCondition = function() {
- // 초기 화면 조건 구성
- //환자정보 초기화
- initPatientInfo();
- };
- /**
- * 환자 정보 초기화
- */
- 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() {
- $("#bleedingListGroup").empty();
- $("#barcodeGroup").attr("style", "display: ;");
- }
- /**
- * 채혈실시 초기화 및 체크된 데이터 배열에 담음
- */
- var initactSpecimen = function() {
- console.log('initactSpecimen');
- checkBoxArr = [];
- //CheckBoxLength 초기화
- // actSpecimenLength = 0;
- //처방번호 체크
- for (var fCnt = 0; fCnt < varResultLists.length; fCnt++) {
- if ($("#checkBleedingSel" + fCnt).is(":checked")) {
- // checkBoxArr.push(varResultLists[fCnt]);
- checkBoxArr[fCnt] = varResultLists[fCnt];
- // actSpecimenLength++;
- }
- }
-
- actSpecimen();
-
- // console.log("checkBoxArr -- > " + JSON.stringify(checkBoxArr));
- //
- // for (var key in checkBoxArr) {
- // console.log("key -- > " + key);
- // }
-
- //eventMakeBarcodeCondition();
- };
- /**
- * 환자정보 요청
- * @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) {
- patientInfo = [];
- // 반환받은 데이터가 Null 일 경우 Alert
- if(self.util.isEmpty(lists) || lists.length == 0){
- initPatientInfo();
- initList();
- $("#txtBleedingPatientSearch").blur();
- $("#alertSuccess .modal-body h4").text("환자정보 조회 실패");
- $("#alertSuccess .modal-body p").text("환자정보 조회에 실패하였습니다");
- $("#alertSuccess").modal("show");
- return;
- }
- // 입력받은 환자번호와 반환 데이터의 환자번호가 일치하는 경우
- if (barPid == lists[0].patientId) {
- patientInfo = lists;
- $(".patient-name").text(lists[0].patientNm);
- $("#patientInfo").text(lists[0].age + "/" + lists[0].gender + " " + lists[0].roomNm + "호");
- $("#todayDate").text("현재 날짜 : " + moment(new Date()).format("YYYY-MM-DD"));
- $(".patient-birthDt").text(lists[0].birthDt);
- $(".dept-name").text(localStorage.getItem("selectedDeptNm"));
- $(".user-name").text(gLoginUserNm);
- $(".user-code").text("(" + gLoginUserId + ")");
- $(".patient-name").append("<button type=\"button\" class=\"btn btn-blood\">" + lists[0].bloodType + "</button>");
-
- 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 = "<span class=\"glyphicon ico ico_" + sCd.toLowerCase() + " align-middle\" aria-hidden=\"true\"></span>"
- $("#patientInfo").append(spanTag);
- }
- getSpecimenList(false);
- // 환자 정보가 일치하지 않는 경우
- } else {
- // 첫 번째 호출인 경우
- if (!isSecondTrial) {
- getPocPatientInfo(barPid, true)
- // 두 번째 호출인 경우
- } else {
- initPatientInfo();
- initList();
- $("#txtBleedingPatientSearch").blur();
- $("#alertSuccess .modal-body h4").text("환자정보 조회 실패");
- $("#alertSuccess .modal-body p").text("시스템 이용량이 많습니다. 다시 조회해 주세요.");
- $("#alertSuccess").modal("show");
- }
- }
- };
- /**
- * 채혈 정보 호출
- * @param {*} isSecondTrial 두 번째 호출 여부
- */
- var getSpecimenList = function(isSecondTrial) {
- var param = {
- hospitalCd: "",
- userId: gLoginUserId,
- patientId: patientInfo[0].patientId,
- specimenSearchCls: specimenSearchCls,
- isSecondTrial: isSecondTrial
- };
- self.safety.getSpecimenList(param, isSecondTrial, processGetSpecimenList);
- };
- /**
- *
- * @param {*} isSecondTrial 두 번째 호출 여부
- * @param {*} lists API 반환 데이터
- */
- var processGetSpecimenList = function(isSecondTrial, lists){
- checkBoxArr = [];
- varResultLists = [];
- var strDisplayTemp = "";
- $("#bleedingListGroup").empty();
- // 반환되는 데이터가 Null 인 경우
- if(self.util.isEmpty(lists) || lists.length == 0){
- // $("#alertEmptyPatient .modal-body h4").text("검체정보 조회");
- // $("#alertEmptyPatient .modal-body p").text("조회된 검체정보가 없습니다.");
- // $("#alertEmptyPatient").modal("show");
- return;
- }
- // 기존의 환자정보와 반환 데이터의 환자정보가 일치하는 경우
- if (patientInfo[0].patientId == lists[0].patientId) {
- varResultLists = lists;
- $("#barcodeGroup").attr("style", "display: none;");
- for( var i = 0; i < lists.length; i++){
- strDisplayTemp += "<li class=\"list-group-item\" id=\"listGroupItem_" + i + "\" >"
- + "<div class=\"row\">"
- + "<div class=\"col-xs-10\">"
- + "<p>"
- + lists[i].specimenCd
- + "</p>"
- + "<p>"
- + lists[i].specimenNm
- + "</p>"
- + "</div>"
- + "<div class=\"col-xs-2 p-0 text-center select_ico\">"
- + "<input type=\"checkbox\" class=\"checkClassBleedingSel\" id=\"checkBleedingSel" + i + "\" autocomplete=\"off\"/>"
- + "<div class=\"group\">"
- + "<label class=\"btn btn-check icon\" for=\"checkBleedingSel" + i + "\" name=\"checkedItem" + i +"\" >"
- + "<span class=\"glyphicon glyphicon-ok\" aria-hidden=\"true\">"
- + "</span>"
- + "</label>"
- + "<label class=\"btn btn-outline-check icon\" for=\"checkBleedingSel" + i + "\" >"
- + "<span class=\"glyphicon \" aria-hidden=\"true\">"
- + "</span>"
- + "</label>"
- + "</div>"
- + "</div>"
- + "</li>";
- }
- $("#bleedingListGroup").append(strDisplayTemp);
- eventMakeCondition();
- // 환자정보가 일치하지 않는 경우
- } else {
- // 첫 번째 호출인 경우
- if (!isSecondTrial) {
- getSpecimenList(true)
- // 두 번째 호출인 경우
- } else {
- $("#alertEmptyPatient .modal-body h4").text("채혈정보 조회 오류");
- $("#alertEmptyPatient .modal-body p").text("시스템 이용량이 많습니다. 다시 조회해 주세요.");
- $("#alertEmptyPatient").modal("show");
- }
- }
- };
- // 채혈실시
- var actSpecimen = function() {
- if (checkBoxArr.length == 0) {
- $("#alertSuccess .modal-body h4").text("실시할 채혈 정보가 없습니다.");
- $("#alertSuccess .modal-body p").text(inputCnt + "실시할 채혈 정보를 선택해주세요.");
- $("#alertSuccess").modal("show");
- } else {
- var cnt = 0;
- var count = 0;
- for (var key in checkBoxArr) {
- cnt = cnt + 1;
- }
-
- for (var key in checkBoxArr) {
- var hospitalCd = localStorage.getItem("hospitalCd"); // 병원코드
- var userId = gLoginUserId; // 사용자 ID
- var specimenCd = checkBoxArr[key].specimenCd; // 검체바코드 번호
- var specimenNm = checkBoxArr[key].specimenNm; // 검체명
- var actSpecimenType = gActSpecimenType; // 검체처리구분(처리 : Y, 취소 : C)
- var actSpecimenDtTm = moment(new Date).format("YYYYMMDDHHMM"); // 검체처리일시
- var actType = ""; // 처리구분 (POC, EMR)
- var checkedItem = $("label[name=checkedItem" + key + "]");
- if (checkedItem.hasClass("btn-barcode")) {
- actType = "POC";
- } else {
- actType = "EMR";
- }
- var param = {
- hospitalCd : hospitalCd ,
- userId : userId ,
- specimenCd : specimenCd ,
- specimenNm : specimenNm ,
- actSpecimenType : actSpecimenType,
- actSpecimenDtTm : actSpecimenDtTm,
- actType : "POC" ,
- actTypeCheck : actType
- };
- var result = self.safety.actSpecimen(param);
-
- count = count + 1;
- if (result != "") {
- if (cnt == count) {
- var succMsg = "";
- var failMsg = "";
-
- if (result == "failed") {
- if (gActSpecimenType == "Y") {
- failMsg = "채혈실시에 오류가 발생하였습니다.";
- } else {
- failMsg = "채혈취소에 오류가 발생하였습니다.";
- }
-
- alert(failMsg);
- } else {
-
- if (gActSpecimenType == "Y") {
- succMsg = "채혈실시가 처리되었습니다.";
- } else {
- succMsg = "채혈취소가 처리되었습니다.";
- }
-
- alert(succMsg);
-
- }
- getPocPatientInfo($("#txtBleedingPatientSearch").val(), false);
- }
- }
-
- }
- }
-
-
- };
-
- var cnt = 0;
- var outputAr = [];
- var processActSpecimen = function(output, size, key) {
- console.log("processActSpecimen -- > " + JSON.stringify(output));
- console.log("processActSpecimen -- > " + size);
- console.log("processActSpecimen -- > " + 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;
- }
- }
-
- var succMsg = "";
- var failMsg = "";
- if (gActSpecimenType == "Y") {
- succMsg = "채혈실시가 처리되었습니다.";
- failMsg = "채혈실시에 오류가 발생하였습니다.";
- } else {
- succMsg = "채혈취소가 처리되었습니다.";
- failMsg = "채혈취소에 오류가 발생하였습니다.";
- }
-
- if (errorFlag == true) {
- alert(failMsg);
- } else {
- alert(succMsg);
- }
-
- outputAr = [];
- getPocPatientInfo($("#txtBleedingPatientSearch").val(), false);
- }
- };
- // 버튼 색상 및 글자 초기화
- var initButtonSetting = function() {
- $("#btnBleedingList").removeClass().addClass("btn btn-secondary btn-block");
- $("#btnCancleList").removeClass().addClass("btn btn-secondary btn-block");
- $("#btnBleedingAct").removeClass().addClass("btn btn-secondary btn-block");
- $("#btnBleedingAct").text("실시/취소");
- }
- //==== 초기화 설정 } ====
- //==== 이벤트 설정 { ====
- 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() {
-
- // 실시 조회 이벤트 처리
- $("#btnBleedingList").off("click");
- $("#btnBleedingList").on("click", function() {
- $(this).blur();
- var searchTxt = $("#txtBleedingPatientSearch").val();
- if (searchTxt == "") {
- $("#alertEmptyText").modal("show");
- } else {
- specimenSearchCls = 0;
- gActSpecimenType = "Y";
- //버튼 색상 변경
- $("#btnBleedingList").removeClass().addClass("btn btn-primary btn-block");
- $("#btnBleedingAct").removeClass().addClass("btn btn-danger btn-block");
- $("#btnCancleList").removeClass().addClass("btn btn-secondary btn-block");
- $("#btnBleedingAct").text("채혈 실시");
- // initPatientInfo();
- getPocPatientInfo(searchTxt, false);
- }
- });
- // 취소 조회 이벤트 처리
- $("#btnCancleList").off("click");
- $("#btnCancleList").on("click", function() {
- $(this).blur();
- var searchTxt = $("#txtBleedingPatientSearch").val();
- if (searchTxt == "") {
- $("#alertEmptyText").modal("show");
- } else {
- specimenSearchCls = 1;
- gActSpecimenType = "C";
- //버튼 색상 변경
- $("#btnBleedingList").removeClass().addClass("btn btn-secondary btn-block");
- $("#btnBleedingAct").removeClass().addClass("btn btn-danger btn-block");
- $("#btnCancleList").removeClass().addClass("btn btn-councel btn-block");
- $("#btnBleedingAct").text("채혈 취소");
- // initPatientInfo();
- getPocPatientInfo(searchTxt, false);
- }
- });
- // 실시/취소 버튼
- $("#btnBleedingAct").off("click");
- $("#btnBleedingAct").on("click", function() {
- $(this).blur();
- if ($("input:checkbox[class=checkClassBleedingSel]:checked").length <= 0) {
- $("#alertEmptySpecimen").modal("show");
- } else {
- initactSpecimen();
- }
- });
- };
- // 바코드 검색
- $("#btnBarcodeSearch").off("click");
- $("#btnBarcodeSearch").on("click", function() {
- $("#txtBleedingNumberSearchTxt").val("");
- readBarcode("number");
- });
-
- /*
- * 체크박스 상태 변경
- * 체크박스 체크 선택 시 Background 추가
- *
- * 바코드 리딩 체크박스 해제시 원래 체크박스 클래스로 바꿔줌
- */
- var eventMakeCondition = function() {
- $("#bleedingListGroup li input").off("click");
- $("#bleedingListGroup li input").on("click", function() {
- var li = $(this).parent().parent().parent(); // listGroupItem_ + i
- var id = li.attr("id");
- var rowNo = id.split('_')[1];
- var checkBox = $("#checkBleedingSel" + rowNo);
- var firstLabel = checkBox.parent().children().children().eq(0);
- var secondLabel = checkBox.parent().children().children().eq(1);
- if (checkBox.is(":checked") == true) {
- li.toggleClass("active");
- console.log(checkBox.is(":checked"));
- } else {
- li.toggleClass("active");
- firstLabel.attr("class", "btn btn-check icon");
- secondLabel.attr("class", "btn btn-outline-check icon");
- }
- });
- };
- }
|