medicationlist.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. "use strict";
  2. /**
  3. * mplus_modal_medicationlist
  4. */
  5. var mplus_modal_medicationlist = function(){
  6. // 상속
  7. mplus_common.call(this);
  8. // 상위 객체 생성
  9. //var mplusPatient = new mplus_mobile_patient();
  10. //var mplusNursing = new mplus_nursing();
  11. //super
  12. var self = this;
  13. //==== 변수 { ====
  14. var varResultLists = [];
  15. //==== 변수 } ====
  16. /**
  17. * 초기화
  18. */
  19. this.init = function(sendParam){ //여기서 모든화면 콤보박스데이터를 집어넣자!!! 그래야지 화면이동할때 속도가 오래걸리지않음!!!
  20. // 초기 화면 조건 구성
  21. initCondition(sendParam);
  22. // 이벤트 초기화
  23. addEvent();
  24. };
  25. //==== 초기화 설정 { ====
  26. var initCondition = function(sendParam){
  27. $("#divMedicationListResultRows").empty();
  28. varResultLists = [];
  29. // 초기 화면 조건 구성
  30. // 일자 설정
  31. initStartEndDate();
  32. if(sendParam !== undefined && sendParam != null){
  33. //console.log("searchMedicationListPrescriptionCall call!");
  34. searchMedicationListPrescriptionCall(sendParam)
  35. }else{
  36. //console.log("searchMedicationList call!");
  37. searchMedicationList();
  38. }
  39. };
  40. var searchMedicationList = function(){
  41. //7일 이상 차이 날 경우 처리
  42. var varVitalListStartDt = moment($("#txtMedicationListStartDt").val() , "YYYY-MM-DD");
  43. var varVitalListEndDt = moment($("#txtMedicationListEndDt").val() , "YYYY-MM-DD");
  44. //console.log("날짜이동 : " + moment.duration(varVitalListStartDt.diff(varVitalListEndDt , "day")));
  45. /*
  46. if(moment.duration(varVitalListStartDt.diff(varVitalListEndDt , "day")) >= 1 || moment.duration(varVitalListStartDt.diff(varVitalListEndDt , "day")) <= -7){
  47. self.alert("1주 이상 검색할 수 없습니다.");
  48. initStartEndDate();
  49. return;
  50. }
  51. */
  52. //화면 호출일 경우
  53. var param = {
  54. userId:gLoginUserId,
  55. patientId:gPatientId,
  56. startDt: moment($("#txtMedicationListStartDt").val()).format("YYYYMMDD"),
  57. endDt: moment($("#txtMedicationListEndDt").val()).format("YYYYMMDD"),
  58. prescriptionCd:"%",
  59. prescriptionNo:"%"
  60. };
  61. self.medical.getMedicationList(param, processSearchMedicalInHisList);
  62. };
  63. var searchMedicationListPrescriptionCall = function(sendParam){
  64. if(sendParam === undefined || sendParam == null){
  65. self.alert("데이터 오류입니다. 관리자에게 문의하세요.");
  66. return;
  67. }
  68. //화면 호출일 경우
  69. var param = {
  70. userId:gLoginUserId,
  71. patientId:gPatientId,
  72. startDt: moment(sendParam.medicationSearchDt).format("YYYYMMDD"),
  73. endDt: moment(sendParam.medicationSearchDt).format("YYYYMMDD"),
  74. prescriptionCd:sendParam.prescriptionCd,
  75. prescriptionNo:sendParam.prescriptionNo
  76. };
  77. self.medical.getMedicationList(param, processSearchMedicalInHisList);
  78. };
  79. var processSearchMedicalInHisList = function(lists){
  80. //console.log(JSON.stringify(lists));
  81. varResultLists = lists;
  82. var strDisplayTemp = "";
  83. var varDoseDtTm = "";
  84. var varPrescriptionDtTm = "";
  85. $("#divMedicationListResultRows").empty();
  86. for( var i = 0; i < lists.length; i++){
  87. if(lists[i].doseDtTm != undefined && lists[i].doseDtTm != "" && lists[i].doseDtTm != null) {
  88. varDoseDtTm = moment(lists[i].doseDtTm , "YYYYMMDDhhmmss").format("MM/DD HH:mm");
  89. } else {
  90. varDoseDtTm = lists[i].doseDtTm;
  91. }
  92. if(lists[i].prescriptionDtTm != undefined && lists[i].prescriptionDtTm != "" && lists[i].prescriptionDtTm != null) {
  93. varPrescriptionDtTm = moment(lists[i].prescriptionDtTm , "YYYYMMDDhhmmss").format("YYYY-MM-DD HH:mm:ss");
  94. } else {
  95. varPrescriptionDtTm = lists[i].prescriptionDtTm;
  96. }
  97. strDisplayTemp += "<div id=\"" + "divMedicationList" + i + "\" class=\"row list-group-item\" listCnt=\"" + i + "\" prescriptionCd=\"" + lists[i].prescriptionCd + "\" style=\"overflow: hidden; padding-left: 0px; padding-right: 0px;\">"
  98. + " <div class=\"col-xs-12\" style=\" padding-left: 0px; padding-right: 0px;\">"
  99. + " <div class=\"col-xs-1 text-center\" style=\"padding: 4px 0px;\">" + lists[i].prescriptionNo + "</div>"
  100. + " <div class=\"col-xs-1 text-center\" style=\"padding: 4px 0px;\">" + lists[i].prescriptionClsNm +"</div>"
  101. + " <div class=\"col-xs-10 text-center\" style=\"padding: 4px 0px; text-align: left;\">" + lists[i].prescriptionNm + "</div>"
  102. + " </div>"
  103. + " <div class=\"col-xs-12\" style=\" padding-left: 0px; padding-right: 0px;\">"
  104. // + " <div class=\"col-xs-2 text-center\" style=\"padding: 4px 0px;\">" + ((moment(lists[i].doseDtTm , "YYYYMMDDhhmmss").format("YYYY-MM-DD HH:mm:ss") != "Invalid date") ? moment(lists[i].doseDtTm , "YYYYMMDDhhmmss").format("MM/DD HH:mm") : "-") + "</div>"
  105. + " <div class=\"col-xs-2 text-center\" style=\"padding: 4px 0px;\">" + varDoseDtTm + "</div>"
  106. + " <div class=\"col-xs-3 text-center\" style=\"padding: 4px 0px;\">" + lists[i].doseQtyPerDay + "/" + lists[i].doseQtyTotal + "</div>"
  107. + " <div class=\"col-xs-3 text-center\" style=\"padding: 4px 0px;\">" + lists[i].doseQtyPer1Tim + "</div>"
  108. + " <div class=\"col-xs-4 text-center\" style=\"padding: 4px 0px;\">" + lists[i].doseWay + "</div>"
  109. + " </div>"
  110. + " <div id=\"divMedicationListDetail" + i + "\" class=\"hidden col-xs-12\">"
  111. // + " <div class=\"col-xs-9 \" style=\"padding: 0px;\">" + ((moment(lists[i].prescriptionDtTm , "YYYYMMDDhhmmss").format("YYYY-MM-DD HH:mm:ss") != "Invalid date") ? moment(lists[i].prescriptionDtTm , "YYYYMMDDhhmmss").format("YYYY-MM-DD HH:mm:ss") : "-") + "/" + lists[i].prescriptionDeptNm + "/" + lists[i].prescriptionDoctorNm + "/" + lists[i].doseExecutorNm + "</div>";
  112. + " <div class=\"col-xs-9 \" style=\"padding: 0px;\">" + varPrescriptionDtTm + "/" + lists[i].prescriptionDeptNm + "/" + lists[i].prescriptionDoctorNm + "/" + lists[i].doseExecutorNm + "</div>";
  113. // 2019.05.09 백병원 요구사항으로 약품정보 버튼 미노출
  114. // 20190610 dkchoi75 일산백병원 요구사항으로 약품정보 버튼 노출 Y: 노출 N:미노출
  115. var varDrogInfoButtonYn = "Y";
  116. if(lists[i].prescriptionCd != null && lists[i].prescriptionCd != "" && lists[i].prescriptionCd != "-"){
  117. //if(lists[i].comment != null && lists[i].comment != "" && lists[i].comment != "-" && varDrogInfoButtonYn == "Y"){
  118. strDisplayTemp += "<div class=\"col-xs-3 \"><button id=\"btnCallDrugInfo\" type=\"button\" class=\"btn btn-info\">약품정보</button></div>";
  119. }else{
  120. strDisplayTemp += "<div class=\"col-xs-3 \"></div>";
  121. }
  122. strDisplayTemp += " </div>"
  123. + "</div>"
  124. ;
  125. //console.log( i + " : " + lists[i].deptNm);
  126. }
  127. $("#divMedicationListResultRows").append(strDisplayTemp); // element 추가
  128. //선택이벤트 처리
  129. addEventMedicationListResult();
  130. };
  131. var addEventMedicationListResult = function() {
  132. $("#divMedicationListResultRows .list-group-item").off("click"); // 기존 이벤트 해제
  133. $("#divMedicationListResultRows .list-group-item").on("click", function(e){
  134. //진료기록 조회 리스트 검색 처리
  135. var varPreCnt = e.currentTarget.attributes.listCnt.value;
  136. var varOrderCd = e.currentTarget.attributes.prescriptionCd.value;
  137. var divMedicationId = "#divMedicationListDetail" + varPreCnt;
  138. // 20190610 dkchoi75 일산백병원 약품정보 Naver 연동 서비스 구분 N:Naver, E:내부EMR, K:킴스
  139. var varDrugInfoApi = "N";
  140. //버튼 클릭 이벤트 처리
  141. if((e.target.id).indexOf("btnCallDrugInfo") != -1){
  142. //if(varResultLists[varPreCnt].prescriptionCd != null && varResultLists[varPreCnt].prescriptionCd != "" && varResultLists[varPreCnt].prescriptionCd != "-"){
  143. // if(varResultLists[varPreCnt].comment != null && varResultLists[varPreCnt].comment != "" && varResultLists[varPreCnt].comment != "-"){
  144. //examResultKey의 값을 정확하게 처리해야함!!! 체크바람!
  145. //if(e.target.id == "btnCallDrugInfo" && varOrderCd != null && varOrderCd != ""){//약품정보
  146. if(e.target.id == "btnCallDrugInfo" ){//약품정보
  147. if (varDrugInfoApi == "N") {
  148. var jsonMsg = {
  149. "type":"command",
  150. "functionType":"popup",
  151. "value" : {
  152. "url" : "http://m.terms.naver.com/medicineSearch.nhn?query=" + varResultLists[varPreCnt].comment,
  153. "method": "GET", // Default "GET" ** 2017-10-19 추가
  154. "parameters": "-" // POST 인 경우만, GET 인 경우는 "url" 에 모두 붙여서 전달 ** 2017-10-19 추가
  155. }
  156. };
  157. self.toNative(jsonMsg);
  158. } else if (varDrugInfoApi == "E") {
  159. //console.log("orderCd.value : " + varOrderCd);
  160. mplusModalMedication.init(param);
  161. $("#mplusAlertDrugInfo").modal("show");
  162. //mplusModalExamrsltty1.init(varPrescriptionLists[varPreCnt]);
  163. //self.alert("처방번호 : " + varResultLists[varPreCnt].prescriptionCd);
  164. } else if (varDrugInfoApi == "K") {
  165. // 킴스 연동 부분
  166. }
  167. var param = {
  168. orderCd: varOrderCd
  169. };
  170. }else{//판독결과
  171. self.alert("약품정보가 없습니다.");
  172. // 환자 정보 화면 띄우기
  173. //$("#modalExamRsltTy2").modal("show");
  174. //mplusModalExamrsltty2.init(varPrescriptionLists[varPreCnt]);
  175. //self.alert("처방번호 : " + varResultLists[varPreCnt].prescriptionCd);
  176. }
  177. // }else{
  178. // console.log("prescriptionCd값 확인바람 : " + varResultLists[varPreCnt].prescriptionCd);
  179. // }
  180. return;
  181. }
  182. if( $(divMedicationId).hasClass("hidden")) {
  183. $(divMedicationId).removeClass("hidden");
  184. } else {
  185. $(divMedicationId).addClass("hidden");
  186. }
  187. });
  188. };
  189. var initStartEndDate = function(){
  190. //오늘일자 로드
  191. var varToday = new Date();
  192. //일요일이면 차주 가져오기
  193. //다른 요일이면 해당 요일 처리
  194. //$("#txtMedicationListEndDt").val( moment(varToday).format("YYYY-MM-DD") );
  195. //varToday.setMonth(varToday.getMonth() - 1);
  196. //varToday.setDate(varToday.getDate() - 1);
  197. //$("#txtMedicationListStartDt").val( moment(varToday).format("YYYY-MM-DD") );
  198. $("#txtMedicationListEndDt").val( moment(varToday).format("YYYY-MM-DD") );
  199. $("#txtMedicationListStartDt").val( moment().subtract(1, 'months').format("YYYY-MM-DD") );
  200. };
  201. //==== 초기화 설정 } ====
  202. //==== 이벤트 설정 { ====
  203. var addEvent = function(){
  204. //$("#btnLogout").on("click", function(){
  205. // logout();
  206. //});
  207. eventColumnClick();
  208. eventRowClick();
  209. eventConditionClick();
  210. };
  211. var eventConditionClick = function(){
  212. // 1일 버튼클릭
  213. $("#btnMedicationListOneDaySearch").off('click'); // 기존 이벤트 해제
  214. $("#btnMedicationListOneDaySearch").on('click', function(e){
  215. $("#txtMedicationListStartDt").val( moment().subtract(1, 'days').format("YYYY-MM-DD") );
  216. searchMedicationList();
  217. });
  218. // 1주 버튼클릭
  219. /*
  220. $("#btnMedicationListOneWeekSearch").off('click'); // 기존 이벤트 해제
  221. $("#btnMedicationListOneWeekSearch").on('click', function(e){
  222. var varSelDate = new Date($("#txtMedicationListEndDt").val());
  223. varSelDate.setDate(varSelDate.getDate() - 6);
  224. //varSelDate.setMonth(varSelDate.getMonth() - 3);
  225. $("#txtMedicationListStartDt").val( moment(varSelDate).format("YYYY-MM-DD") );
  226. });
  227. */
  228. // 1달 버튼클릭
  229. $("#btnMedicationListOneMonthSearch").off("click"); // 기존 이벤트 해제
  230. $("#btnMedicationListOneMonthSearch").on("click", function(e){
  231. $("#txtMedicationListStartDt").val( moment().subtract(1, 'months').format("YYYY-MM-DD") );
  232. searchMedicationList();
  233. });
  234. // 3달 버튼클릭
  235. $("#btnMedicationListThreeMonthSearch").off('click'); // 기존 이벤트 해제
  236. $("#btnMedicationListThreeMonthSearch").on('click', function(e){
  237. $("#txtMedicationListStartDt").val( moment().subtract(3, 'months').format("YYYY-MM-DD") );
  238. searchMedicationList();
  239. });
  240. // 조회버튼
  241. $("#btnMedicationListSearch").off('click'); // 기존 이벤트 해제
  242. $("#btnMedicationListSearch").on('click', function(e){
  243. //로우 초기화
  244. $("#divMedicationListResultRows").empty();
  245. searchMedicationList();
  246. });
  247. };
  248. var eventColumnClick = function(){
  249. };
  250. var eventRowClick = function(){
  251. };
  252. //==== 이벤트 설정 } ====
  253. //==== 서비스 실행 { ====
  254. //==== 서비스 실행 { ====
  255. };