patient.js 48 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094
  1. /**
  2. * mplus_mobile_patient
  3. */
  4. var mplus_mobile_patient = function(){
  5. // 상속
  6. mplus_common.call(this);
  7. // super
  8. var self = this;
  9. //변수
  10. var div = $("<div></div>");
  11. var tr = $("<tr></tr>");
  12. var th = $("<th></th>");
  13. var td = $("<td></td>");
  14. var table = $("<table></table>");
  15. var thead = $("<thead></thead>");
  16. var tbody = $("<tbody></tbody>");
  17. var li = $("<li></li>");
  18. var a = $("<a></a>");
  19. var span = $("<span></span>");
  20. var button = $("<button></button>");
  21. //기본
  22. var $searchBtn = $('#searchBtn'),
  23. $recentSearchBtn = $('#recentSearchBtn'),
  24. $ulPatientList = $('#ulPatientList');
  25. //처방
  26. var $prescriptionPatientName = $('#prescriptionPatientName'),
  27. $prescriptionDtpSrchdd = $('#prescriptionDtpSrchdd'),
  28. $prescriptionSelectdd = $('#prescriptionSelectdd'),
  29. $prescriptionSelectbox = $('#prescriptionSelectbox'),
  30. $prescriptionList = $('#prescriptionList');
  31. var patientInfo;
  32. var prescribeInfo;
  33. var prescribeList = [];
  34. //검사
  35. var $patientName = $('#patientName'),
  36. $btnExamSearch = $('#btnExamSearch'),
  37. $datepicker = $('#datepicker'),
  38. $selectbox = $('#selectbox'),
  39. $examineList = $('#examineList'),
  40. $examinePlusBtn = $('#examinePlusBtn'),
  41. $examinePrevBtn = $('#prevExamBtn'),
  42. $examineNextBtn = $('#nextExamBtn'),
  43. examInfo;
  44. targetExamSeq = 0;
  45. // EMR
  46. $emrPrevBtn = $('#prevEmrBtn');
  47. $emrNextBtn = $('#nextEmrBtn');
  48. /**
  49. * 초기화
  50. */
  51. this.detailInit = function(){
  52. $('.bottom-menu.selected').removeClass('selected');
  53. $('[name=btnMoveDetail]').addClass('selected');
  54. headerTitle.text("환자정보");
  55. detailBinding();
  56. };
  57. this.prescriptionInit = function(){
  58. $('.bottom-menu.selected').removeClass('selected');
  59. $('[name=btnMovePrescription]').addClass('selected');
  60. headerTitle.text("환자정보");
  61. patientInfo = JSON.parse(localStorage.getItem('patientInfo'));
  62. $prescriptionPatientName.text(patientInfo.patientNm + ' ' + patientInfo.patientId);
  63. prescriptionAddEvent();
  64. // 조회일자를 오늘날짜로 변경 - 2017/01/18
  65. var today = moment(new Date()).format('YYYY-MM-DD');
  66. $prescriptionDtpSrchdd.val(today);
  67. $('#prescriptionSelectbox').val('sel');
  68. // 외래환자일 경우 날짜 선택을 과거 진료일자들 콤보박스로 할수있도록 함
  69. if( patientInfo.treatTyp =='O') {
  70. $('#prescriptionDtpSrchdd').css('display', 'none');
  71. $('#prescriptionSelectdd').css('display', 'block');
  72. $('#prescriptionSelectdd').empty();
  73. var param = {
  74. patientId: patientInfo.patientId,
  75. departmentCd: patientInfo.departmentCd==undefined? patientInfo.requestDeptCd: patientInfo.departmentCd,
  76. treatDt: patientInfo.treatDt
  77. };
  78. var pastTreatDateList = self.treatment.getPastTreatDate(param);
  79. // 최근 10개만 표시
  80. for(var i=0; (i<pastTreatDateList.length && i<10); i++){
  81. option = $('<option></option>').clone().attr('value', pastTreatDateList[i].treatDt)
  82. .text(moment(pastTreatDateList[i].treatDt).format('YYYY-MM-DD'));
  83. $('#prescriptionSelectdd').append(option);
  84. }
  85. // 오늘의 외래환자가 아닌경우 진료일자에 오늘이 포함되어있지 않으므로, 초기 조회날짜 변수 today를 첫번째 진료날짜로 바꿔치기함
  86. today = pastTreatDateList[0].treatDt;
  87. } else {
  88. $('#prescriptionDtpSrchdd').css('display', 'block');
  89. $('#prescriptionSelectdd').css('display', 'none');
  90. }
  91. searchPrescriptionList(today, "sel");
  92. };
  93. this.examineInit = function(){
  94. $('.bottom-menu.selected').removeClass('selected');
  95. $('[name=btnMoveExamine]').addClass('selected');
  96. headerTitle.text("환자정보");
  97. patientInfo = JSON.parse(localStorage.getItem('patientInfo'));
  98. var today = new Date();
  99. var prevDay = new Date(Date.parse(new Date()) - 365 * 1000 * 60 * 60 * 24); //일년전!!
  100. $('#examEndSrchdd').val(moment(today).format('YYYY-MM-DD'));
  101. $('#examStartSrchdd').val(moment(prevDay).format('YYYY-MM-DD'));
  102. searchExamineList();
  103. //var categorys = ['검체검사', '기능검사', '병리검사', '영상검사'];
  104. //examineTreeCtrl.init(categorys);
  105. examineAddEvent();
  106. //var today = new Date();
  107. //$('#dtpSrchdd1').val(moment(today).format('YYYY-MM-DD'));
  108. };
  109. this.consultInit = function(){
  110. headerTitle.text("협진상세");
  111. initConsultDetail();
  112. };
  113. this.emrInit = function(){
  114. headerTitle.text("환자정보");
  115. emrAddEvent();
  116. searchEmrList();
  117. };
  118. /**
  119. * 이벤트 등록
  120. */
  121. var prescriptionAddEvent = function(){
  122. $prescriptionDtpSrchdd.unbind();
  123. $prescriptionDtpSrchdd.change(function(){
  124. $('#prescriptionSelectbox').val('sel');
  125. searchPrescriptionList($('#prescriptionDtpSrchdd').val(), $('#prescriptionSelectbox option:selected').val());
  126. });
  127. $prescriptionSelectdd.unbind();
  128. $prescriptionSelectdd.change(function(){
  129. $('#prescriptionSelectbox').val('sel');
  130. searchPrescriptionList($('#prescriptionSelectdd').val(), $('#prescriptionSelectbox option:selected').val());
  131. });
  132. $prescriptionSelectbox.unbind();
  133. $prescriptionSelectbox.change(function(){
  134. bindingPrescription(prescribeList, $('#prescriptionSelectbox option:selected').val());
  135. });
  136. };
  137. var examineAddEvent = function(){
  138. $btnExamSearch.unbind();
  139. $btnExamSearch.click(function(){
  140. searchExamineList();
  141. });
  142. };
  143. var examineInfoAddEvent = function() {
  144. // 이동할 때 로딩 뜨면 좋은데 어떻게 해도 안되네 ㅜㅜ
  145. $examinePrevBtn.unbind();
  146. $examinePrevBtn.on('click', function(e){
  147. if(targetExamSeq == 0) {
  148. self.alert('첫번째 검사입니다.');
  149. return;
  150. }
  151. targetExamSeq--;
  152. bindExaminInfo(targetExamSeq);
  153. });
  154. $examineNextBtn.unbind();
  155. $examineNextBtn.on('click', function(e){
  156. if(targetExamSeq + 1 == examList.length) {
  157. self.alert('마지막 검사입니다.');
  158. return;
  159. }
  160. targetExamSeq++;
  161. bindExaminInfo(targetExamSeq);
  162. });
  163. }
  164. //기본 데이터 바인딩
  165. var detailBinding = function(){
  166. var patient = JSON.parse(localStorage.getItem('patientInfo'));
  167. var param;
  168. if(patient.treatTyp=='I'||patient.consultTyp=='I'){ //patient.treatTyp=='I'인 경우는 없긴하다. 데이터 정상적으로 다 들어오면 테스트해보기.171103
  169. param = {
  170. patientId: patient.patientId,
  171. treatTyp: 'I'/*,
  172. deptCode: patient.departmentCd==undefined? patient.reqDeptCode: patient.departmentCd*/
  173. };
  174. }else if(patient.treatTyp=='O'||patient.consultTyp=='O'){
  175. param = {
  176. patientId: patient.patientId,
  177. treatTyp: 'O',
  178. departmentCd: patient.departmentCd==undefined? patient.reqDeptCode: patient.departmentCd,
  179. treatDt: patient.treatDt
  180. };
  181. }else if(patient.treatTyp=='E'||patient.consultTyp=='E'){
  182. param = {
  183. patientId: patient.patientId,
  184. treatTyp: 'E'/*,
  185. deptCode: patient.departmentCd==undefined? patient.reqDeptCode: patient.departmentCd,
  186. treatDate: patient.treatDt*/
  187. };
  188. }else{
  189. }
  190. var patientInfo = self.patient.getPatInfo(param);
  191. $('#patientPopupNum').text(patientInfo.patientId);
  192. $('#patientPopupName').text(patientInfo.patientNm);
  193. $('#patientPopupBirth').text(patientInfo.birthDt!=''? moment(patientInfo.birthDt).format('YYYY-MM-DD'): '');
  194. $('#patientPopupSex').text(patientInfo.gender + ' / ' + patientInfo.age);
  195. $('#patientPopupBloodTyp').text(patientInfo.bloodTyp);
  196. $('#patientPopupCellphone').text(patientInfo.cellphoneNo);
  197. $('#patientPopupGuardianphone').text(patientInfo.guardianPhoneNo);
  198. $('#patientPopupAddress').text(patientInfo.address);
  199. if(patientInfo.cellphoneNo!=undefined && patientInfo.cellphoneNo!=null&& patientInfo.cellphoneNo!=''){
  200. $('#patientTelBtnBox').css('display', 'block');
  201. $('#patientTelBtn').unbind();
  202. $('#patientTelBtn').on('click', function(e){
  203. location.href = 'tel:'+patientInfo.cellphoneNo;
  204. });
  205. $('#patientSmsBtn').unbind();
  206. $('#patientSmsBtn').on('click', function(e){
  207. location.href = 'sms:'+patientInfo.cellphoneNo;
  208. });
  209. }else{
  210. $('#patientTelBtnBox').css('display', 'none');
  211. }
  212. if(patientInfo.guardianPhoneNo!=undefined && patientInfo.guardianPhoneNo!=null&& patientInfo.guardianPhoneNo!=''){
  213. $('#guardianTelBtnBox').css('display', 'block');
  214. $('#guardianTelBtn').unbind();
  215. $('#guardianTelBtn').on('click', function(e){
  216. location.href = 'tel:'+patientInfo.guardianPhoneNo;
  217. });
  218. $('#guardianSmsBtn').unbind();
  219. $('#guardianSmsBtn').on('click', function(e){
  220. location.href = 'sms:'+patientInfo.guardianPhoneNo;
  221. });
  222. }else{
  223. $('#guardianTelBtnBox').css('display', 'none');
  224. }
  225. };
  226. //처방 데이터바인딩
  227. var searchPrescriptionList = function(date, type){
  228. $prescriptionList.empty();
  229. prescribeList = [];
  230. $('#prescriptionList').removeClass();
  231. var patientInfo = JSON.parse(localStorage.getItem('patientInfo'));
  232. var param = {};
  233. if(patientInfo.treatTyp == 'I' || patientInfo.consultTyp == 'I' || patientInfo.treatTyp=='E'){
  234. param = {
  235. patientId: patientInfo.patientId,
  236. treatDt: patientInfo.inDt ==undefined? patientInfo.treatDt: patientInfo.inDt,
  237. prescriptionDt: moment(date).format('YYYYMMDD')
  238. };
  239. }else{
  240. param = {
  241. patientId: patientInfo.patientId,
  242. departmentCd: patientInfo.departmentCd==undefined? patientInfo.requestDeptCd: patientInfo.departmentCd,
  243. treatTyp: patientInfo.treatTyp==undefined? patientInfo.consultTyp: patientInfo.treatTyp,
  244. prescriptionDt: moment(date).format('YYYYMMDD')
  245. };
  246. }
  247. self.patient.getPatPrescribeList(param, type, function(prescribeList, type) {bindingPrescription(prescribeList, type);});
  248. };
  249. var prescriptionCdArr = [
  250. {prescriptionCd: 'A', prescriptionCdNm : '마취', prescriptionList: []},
  251. {prescriptionCd: 'B', prescriptionCdNm : '진료예약', prescriptionList: []},
  252. {prescriptionCd: 'C', prescriptionCdNm : '협진', prescriptionList: []},
  253. {prescriptionCd: 'D', prescriptionCdNm : '식이', prescriptionList: []},
  254. {prescriptionCd: 'G', prescriptionCdNm : '진단서', prescriptionList: []},
  255. {prescriptionCd: 'H', prescriptionCdNm : '퇴원처방', prescriptionList: []},
  256. {prescriptionCd: 'L', prescriptionCdNm : '진단검사', prescriptionList: []},
  257. {prescriptionCd: 'M', prescriptionCdNm : '소모품', prescriptionList: []},
  258. {prescriptionCd: 'O', prescriptionCdNm : '수술', prescriptionList: []},
  259. {prescriptionCd: 'P', prescriptionCdNm : '약', prescriptionList: []},
  260. {prescriptionCd: 'Q', prescriptionCdNm : '병실이동', prescriptionList: []},
  261. {prescriptionCd: 'R', prescriptionCdNm : '통합검사', prescriptionList: []},
  262. {prescriptionCd: 'S', prescriptionCdNm : '입원결정', prescriptionList: []},
  263. {prescriptionCd: 'T', prescriptionCdNm : '처치', prescriptionList: []},
  264. {prescriptionCd: 'W', prescriptionCdNm : '전과', prescriptionList: []},
  265. {prescriptionCd: 'X', prescriptionCdNm : '기타', prescriptionList: []},
  266. {prescriptionCd: 'Y', prescriptionCdNm : '건진', prescriptionList: []},
  267. {prescriptionCd: 'Z', prescriptionCdNm : '메시지', prescriptionList: []}];
  268. var prescriptionStatArr = [
  269. {prescriptionStat: '00', prescriptionStatNm : '처방'},
  270. {prescriptionStat: '01', prescriptionStatNm : '약신청'},
  271. {prescriptionStat: '05', prescriptionStatNm : '대기'},
  272. {prescriptionStat: '10', prescriptionStatNm : '출력'},
  273. {prescriptionStat: '11', prescriptionStatNm : '조제완료'},
  274. {prescriptionStat: '12', prescriptionStatNm : '조제취소'},
  275. {prescriptionStat: '13', prescriptionStatNm : '불출'},
  276. {prescriptionStat: '14', prescriptionStatNm : 'List출력'},
  277. {prescriptionStat: '30', prescriptionStatNm : '채혈'},
  278. {prescriptionStat: '31', prescriptionStatNm : '접수'},
  279. {prescriptionStat: '32', prescriptionStatNm : '예약'},
  280. {prescriptionStat: '33', prescriptionStatNm : '도착'},
  281. {prescriptionStat: '34', prescriptionStatNm : '주사'},
  282. {prescriptionStat: '35', prescriptionStatNm : '검사대기'},
  283. {prescriptionStat: '36', prescriptionStatNm : 'RI주문'},
  284. {prescriptionStat: '37', prescriptionStatNm : '검체도착'},
  285. {prescriptionStat: '38', prescriptionStatNm : '검사중'},
  286. {prescriptionStat: '39', prescriptionStatNm : '투여중'},
  287. {prescriptionStat: '40', prescriptionStatNm : '시행'},
  288. {prescriptionStat: '41', prescriptionStatNm : '완료'},
  289. {prescriptionStat: '42', prescriptionStatNm : '서명대기'},
  290. {prescriptionStat: '49', prescriptionStatNm : 'Rec.'},
  291. {prescriptionStat: '50', prescriptionStatNm : '예결'},
  292. {prescriptionStat: '51', prescriptionStatNm : '결과'},
  293. {prescriptionStat: '90', prescriptionStatNm : '보류'},
  294. {prescriptionStat: '91', prescriptionStatNm : '종료'},
  295. {prescriptionStat: '92', prescriptionStatNm : '종료'},
  296. {prescriptionStat: '93', prescriptionStatNm : '종료'},
  297. {prescriptionStat: '95', prescriptionStatNm : '종료'}];
  298. var bindingPrescription = function(prescribeListData, type){
  299. $prescriptionList.empty();
  300. prescribeList = prescribeListData;
  301. if(type=='sel'){
  302. $prescriptionList.addClass("panel-group panel-group-joined");
  303. prescriptionCdArr.forEach(function(item){item.prescriptionList.length = 0;});
  304. for ( var i = 0; i < prescribeListData.length ; i++ ){
  305. /* 2018.06.18. 안드로이드 호환 변경
  306. prescriptionCdArr.find(function(item, index, array) {
  307. if( item.prescriptionCd == prescribeListData[i].prescriptionCd) {
  308. array[index].prescriptionList.push(prescribeListData[i]);
  309. return true;
  310. }});
  311. */
  312. for(var j=0; j<prescriptionCdArr.length ; j++){
  313. if( prescriptionCdArr[j].prescriptionCd == prescribeListData[i].prescriptionCd ){
  314. prescriptionCdArr[j].prescriptionList.push(prescribeListData[i]);
  315. break;
  316. }
  317. }
  318. }
  319. for ( var i = 0; i < prescriptionCdArr.length ; i++ ){
  320. if( prescriptionCdArr[i].prescriptionList.length > 0 ) {
  321. bindingPrescriptionList(prescriptionCdArr[i].prescriptionList, type, prescriptionCdArr[i].prescriptionCdNm);
  322. }
  323. }
  324. }else if(type=='presno'){
  325. $prescriptionList.addClass("panel-group panel-group-joined");
  326. var groupingPresNo = [];
  327. for( var i = 0; i < prescribeListData.length; i++) {
  328. var presIndex = groupingPresNo.map(function(item){ return item.prescriptionNo;}).indexOf(prescribeListData[i].prescriptionNo);
  329. if(presIndex == -1) { //처음보는 처방번호
  330. var prescription = {};
  331. prescription.prescriptionNo = prescribeListData[i].prescriptionNo;
  332. prescription.prescriptionList = [ prescribeListData[i] ];
  333. groupingPresNo.push(prescription);
  334. } else { // 봤던 처방번호
  335. groupingPresNo[presIndex].prescriptionList.push(prescribeListData[i]);
  336. }
  337. }
  338. for ( var i = 0; i < groupingPresNo.length ; i++ ){
  339. bindingPrescriptionList(groupingPresNo[i].prescriptionList, type, groupingPresNo[i].prescriptionNo);
  340. }
  341. }
  342. };
  343. var bindingPrescriptionList = function(prescribeList, type, selName){
  344. var divPanelHeading = div.clone().addClass("panel-heading");
  345. var h4 = $("<h4></h4>").addClass("panel-title");
  346. var h4A = $("<a data-toggle='collapse' data-target='#collapse_"+$('[data-toggle="collapse"]').length+"' class='collapsed' aria-expanded='false'>").text(selName).append(
  347. $("<i></i>").addClass("fa fa-chevron-circle-up")
  348. );
  349. var panelHeading = divPanelHeading.append(h4.append(h4A));
  350. var divCollapse = div.clone().attr("id", 'collapse_'+$('[data-toggle="collapse"]').length).attr("aria-expanded", "false").addClass("panel-collapse collapse");
  351. var divPanelBody = div.clone().addClass("panel-body");
  352. for(var j=0; j<prescribeList.length; j++){
  353. var thContent = th.clone().text("처방내역");
  354. var tdContentBox = div.clone().addClass('col-xs-9 pd0').text(prescribeList[j].prescriptionNm);
  355. var tdContentBox1 = span.clone().addClass("label-1").text(prescribeList[j].prescriptionCd);
  356. //약처리
  357. if(prescribeList[j].prescriptionCd == "P"){
  358. tdContentBox.append(span.clone().addClass("spaninject").attr('id','pat_spaninjec_'+j).attr('injecOrdCd',prescribeList[j].orderCd).text("복약정보"));
  359. }
  360. var tdContent = td.clone().append(tdContentBox).append(tdContentBox1);
  361. var trContent = tr.clone().append(thContent).append(tdContent);
  362. var thCode = th.clone().text("처방상태");
  363. var tdCode = td.clone().text(getPrescriptionCode(prescribeList[j].prescriptionStat));
  364. var trCode = tr.clone().append(thCode).append(tdCode);
  365. var thDoctor = th.clone().text("처방의");
  366. var tdDoctor = td.clone().text(prescribeList[j].doctorNm);
  367. var trDoctor = tr.clone().append(thDoctor).append(tdDoctor);
  368. //약과 처치처방만 횟수 표시
  369. if(prescribeList[j].prescriptionCd == "P" || prescribeList[j].prescriptionCd == "T"){
  370. var tdDetail, trDetail;
  371. if(prescribeList[j].prescriptionCd == "P"){
  372. tdDetail = td.clone().attr("colspan", "2").addClass("merge").text("투여량 "+ prescribeList[j].doseQtyPerTim +
  373. ' (' + prescribeList[j].doseTQty +"), 횟수 "+prescribeList[j].doseQtyPerDay+", 일수 "+prescribeList[j].doseDay);
  374. trDetail = tr.clone().append(tdDetail);
  375. }else{
  376. tdDetail = td.clone().attr("colspan", "2").addClass("merge").text("횟수 "+prescribeList[j].doseQtyPerDay);
  377. trDetail = tr.clone().append(tdDetail);
  378. }
  379. divPanelBody.append(table.clone().addClass("info-style").append(tbody.clone().append(trContent).append(trCode).append(trDoctor).append(trDetail)));
  380. }else{
  381. divPanelBody.append(table.clone().addClass("info-style").append(tbody.clone().append(trContent).append(trCode).append(trDoctor)));
  382. }
  383. }
  384. $prescriptionList.append(div.clone().addClass("panel panel-default").append(panelHeading).append(divCollapse.append(divPanelBody)));
  385. $('#prescriptionList .panel-title a').unbind();
  386. $('#prescriptionList .panel-title a').on('click',function(){
  387. if ($(this).is('.on')){
  388. $(this).find('.fa').removeClass('fa-chevron-circle-down')
  389. $(this).find('.fa').addClass('fa-chevron-circle-up')
  390. $(this).removeClass('on')
  391. }else{
  392. $(this).addClass('on')
  393. $(this).find('.fa').removeClass('fa-chevron-circle-up')
  394. $(this).find('.fa').addClass('fa-chevron-circle-down')
  395. }
  396. });
  397. };
  398. var getPrescriptionCode = function(code){
  399. //2018.06.18 안드로이드 호환변경
  400. //var prescriptionCode = prescriptionStatArr.find(function(item) {if( item.prescriptionStat == code) return true;});
  401. var prescriptionCode = undefined;
  402. for(var i = 0 ; i < prescriptionStatArr.length ; i++){
  403. if(prescriptionStatArr[i].prescriptionStat == code){
  404. prescriptionCode = prescriptionStatArr[i];
  405. break;
  406. }
  407. }
  408. if( prescriptionCode != undefined ) {
  409. return prescriptionCode.prescriptionStatNm;
  410. } else {
  411. return '-';
  412. }
  413. };
  414. //검사 데이터바인딩
  415. var searchExamineList = function(){
  416. $examineList.empty();
  417. var patientInfo = JSON.parse(localStorage.patientInfo);
  418. $('#examPatientName').text(patientInfo.patientNm + ' ' + patientInfo.patientId);
  419. var param = {
  420. patientId: patientInfo.patientId
  421. };
  422. self.patient.getExamList(param, function(result) { bindExamineList(result)});
  423. };
  424. var bindExamineList = function(examListData){
  425. examList = examListData;
  426. examineTreeCtrl.init(examListData);
  427. };
  428. /*var bindExaminInfo = function(seq) {
  429. var param = {
  430. examinationRst: examList[seq].examKey
  431. };
  432. examInfo = self.patient.getExamInfo(param);
  433. $('#examineInfo').empty();
  434. var tableData = table.clone().attr('id', 'examineDetailList');
  435. var tbodyData = tbody.clone();
  436. examineInfoAddEvent();
  437. //pacs버튼 생성 코드
  438. if(examInfo.pacs){
  439. var divPacsBtn = div.clone().addClass('div-btn-pacs').append(button.clone().addClass('btn btn-primary btn-block').attr('id', 'btnPacsOpen').text('PACS'));
  440. $('#examineInfo').append(divPacsBtn);
  441. $('#btnPacsOpen').on('click', function(){
  442. pacsOpen(examInfo);
  443. });
  444. };
  445. if(examInfo.type=='N'){
  446. if(examInfo.style){
  447. for(var j=0; j<examInfo.result.length; j++){
  448. var tdData1 = td.clone().addClass('examine-style_'+ examInfo.result[j].content1).append(div.clone().append($('<pre></pre>').clone().text(examInfo.result[j].content2)).append(span.clone().addClass('none-style').text(examInfo.result[j].content3!=undefined && examInfo.result[j].content3!=null && examInfo.result[j].content3!=''? ' '+ examInfo.result[j].content3: '')));
  449. var trData1 = tr.clone().append(tdData1);
  450. tbodyData.append(trData1);
  451. };
  452. tableData.append(tbodyData);
  453. $('#examineInfo').append(tableData);
  454. }else{
  455. for(var j=0; j<examInfo.result.length; j++){
  456. var tdData1 = td.clone().addClass('title-td').append(div.clone().text(examInfo.result[j].content1));
  457. var tdData2 = td.clone().addClass('text-center pd0').append(div.clone().text(examInfo.result[j].content2));
  458. var tdData3 = td.clone().addClass('text-center pd0').append(div.clone().addClass(examInfo.result[j].content3=='▲'? 'arrow-up': examInfo.result[j].content3=='▼'? 'arrow-down': '').text(examInfo.result[j].content3));
  459. var trData = tr.clone().append(tdData1).append(tdData2).append(tdData3);
  460. tbodyData.append(trData);
  461. };
  462. tableData.append(tbodyData);
  463. $('#examineInfo').append(tableData);
  464. }
  465. }else{
  466. for(var j=0; j<examInfo.result.length; j++){
  467. var divData = div.clone().addClass('type-T').append($('<pre></pre>').clone().addClass(examInfo.result[j].content2=='-'? 'content-type': '').text(examInfo.result[j].content1));
  468. $('#examineInfo').append(divData);
  469. };
  470. };
  471. $('#headerTitle2').text("상세정보");
  472. $('#nursingPopup [id*=popContent]').removeClass('in');
  473. $('#nursingPopup #popContentExamineInfo').addClass('in');
  474. $('#nursingPopup').css('display', 'block');
  475. $('#examineInfo').scrollTop(0);
  476. $( '#examineInfo' ).unbind();
  477. $( '#examineInfo' ).on('touchstart',function(){
  478. $('#examMoveBtn').css({display: 'none'}).fadeOut('slow');
  479. });
  480. $( '#examineInfo' ).on('touchend',function(){
  481. $('#examMoveBtn').css({display: 'block'}).fadeIn('slow');
  482. });
  483. }
  484. */
  485. //협진 데이터바인딩
  486. var initConsultDetail = function(){
  487. var patientInfo = JSON.parse(localStorage.getItem('patientInfo'));
  488. var param = {
  489. patientId: patientInfo.patientId,
  490. requestDt: patientInfo.requestDt,
  491. requestDeptCd: patientInfo.requestDeptCd==null? ' ': patientInfo.requestDeptCd,
  492. requestDrId: patientInfo.requestDrId==null? ' ': patientInfo.requestDrId,
  493. responseDeptCd: patientInfo.executeDeptCd==null? ' ': patientInfo.executeDeptCd,
  494. responseDrId: patientInfo.hopeDrId==null? ' ': patientInfo.hopeDrId,
  495. consultTyp: patientInfo.consultTyp
  496. };
  497. var consultInfo = self.consult.getConsultInfo(param);
  498. $('#tdConsultName').text(patientInfo.patientNm + ' ' + patientInfo.patientId);
  499. if(!$.isEmptyObject(consultInfo)){
  500. $('#tdDiagName').text(consultInfo.diagnosisNm);
  501. $('#tdRequest').html(decodeURI(patientInfo.requestDeptNm) + ' / ' + decodeURI(patientInfo.requestDrNm) + '<button id="btnDoctorTel" class="btn btn-danger" style="padding: 3px 8px; margin: -3.6px 0px -2.4px 7px"><i class="fa fa-phone"></i><span class="hidden">전화걸기</span></button>');
  502. $('#tdReply').text(patientInfo.executeDeptNm+' / ' + (patientInfo.responseDrNm!=undefined&&patientInfo.responseDrNm!=null&&patientInfo.responseDrNm!=''?patientInfo.responseDrNm: ''));
  503. $('#spanRequestDate').text(patientInfo.requestDt!=undefined&&patientInfo.requestDt!=null&&patientInfo.requestDt!=''?(patientInfo.requestDt!=''? moment(patientInfo.requestDt).format('YYYY-MM-DD'):''): '');
  504. $('#divRequestDetail').html(consultInfo.requestTxt.replace(/\\r\\n|\\r/gi, '</br>'));
  505. $('#spanReplyDate').text(consultInfo.responseDtTm!=undefined&&consultInfo.responseDtTm!=null&&consultInfo.responseDtTm!=''? moment(consultInfo.responseDtTm).format('YYYY-MM-DD'): '');
  506. $('#divReplyDetail').html(consultInfo.responseTxt!=undefined&&consultInfo.responseTxt!=null&&consultInfo.responseTxt!=''? consultInfo.responseTxt.replace(/\\r\\n|\\r/gi, '</br>'): '');
  507. }
  508. $('#btnDoctorTel').unbind();
  509. $('#btnDoctorTel').on('click', function(e){
  510. if(consultInfo.requestDrTel==undefined||consultInfo.requestDrTel==null||consultInfo.requestDrTel==''){
  511. self.alert('의뢰 의사의 전화번호가 존재하지 않습니다.');
  512. return;
  513. }
  514. location.href = 'tel:'+consultInfo.requestDrTel;
  515. });
  516. $('#popContentConsultDetail').scrollTop(0);
  517. };
  518. var emrAddEvent = function() {
  519. $emrPrevBtn.unbind();
  520. $emrPrevBtn.on('click', function(e){
  521. var totalImageCount = $('img[id^="emrImg_"]')[0].id.split('_')[1];
  522. var currentImageSeq = $('img[id^="emrImg_"].img-disp-Y')[0].id.split('_')[2];
  523. $('img[id^="emrImg_"]').removeClass('img-disp-Y').addClass('img-disp-N');
  524. if(currentImageSeq==0){
  525. $('#emrImg_'+totalImageCount+'_'+(parseInt(totalImageCount)-1)).removeClass('img-disp-N').addClass('img-disp-Y');
  526. $('#emrPageInfo').html(parseInt(totalImageCount) + ' / ' + totalImageCount);
  527. }else{
  528. $('#emrImg_'+totalImageCount+'_'+(parseInt(currentImageSeq)-1)).removeClass('img-disp-N').addClass('img-disp-Y');
  529. $('#emrPageInfo').html(parseInt(currentImageSeq) + ' / ' + totalImageCount);
  530. };
  531. $('.emr-detail').scrollTop(0);
  532. });
  533. $emrNextBtn.unbind();
  534. $emrNextBtn.on('click', function(e){
  535. var totalImageCount = $('img[id^="emrImg_"]')[0].id.split('_')[1];
  536. var currentImageSeq = $('img[id^="emrImg_"].img-disp-Y')[0].id.split('_')[2];
  537. $('img[id^="emrImg_"]').removeClass('img-disp-Y').addClass('img-disp-N');
  538. if(currentImageSeq==(totalImageCount-1)){
  539. $('#emrImg_'+totalImageCount+'_0').removeClass('img-disp-N').addClass('img-disp-Y');
  540. $('#emrPageInfo').html('1 / ' + totalImageCount);
  541. }else{
  542. $('#emrImg_'+totalImageCount+'_'+(parseInt(currentImageSeq)+1)).removeClass('img-disp-N').addClass('img-disp-Y');
  543. $('#emrPageInfo').html((parseInt(currentImageSeq)+2) + ' / ' + totalImageCount);
  544. };
  545. $('.emr-detail').scrollTop(0);
  546. });
  547. }
  548. //emr리스트 조회
  549. var searchEmrList = function(){
  550. var patientInfo = JSON.parse(localStorage.getItem('patientInfo'));
  551. var param = {
  552. patientId: patientInfo.patientId,
  553. certCode: 'ALL',
  554. treatDate: patientInfo.treatDate,
  555. deptCode: patientInfo.deptCode,
  556. treatType: 'O',
  557. };
  558. var emrList = self.patient.getEmrList(param);
  559. if(emrList==undefined||emrList==null||emrList.length==0){
  560. self.alert('조회할 이미지가 없습니다.');
  561. $('#nursingPopup').css('display', 'none');
  562. return;
  563. };
  564. $('.tab-content .tab-pane').css('overflow', 'hidden');
  565. var emrImageList = [];
  566. for(var i=0; i<emrList.length; i++){
  567. emrImageList.push({imgPath: contextPath+'/mobile/patient/getEmrImage.json?fileName='+emrList[i].fileName});
  568. };
  569. $('.mp-page-header, #emrPageInfo').css('display', 'block');
  570. if( emrImageList.length > 1 ) {
  571. $('#prevEmrBtn, #nextEmrBtn').css('display', 'block');
  572. } else {
  573. $('#prevEmrBtn, #nextEmrBtn').css('display', 'none');
  574. };
  575. var wh=$(window).height();
  576. // EMR 이미지 리스트 추가
  577. $('#emrList').empty();
  578. for(var j=0; j<emrImageList.length; j++){
  579. var imageItem = '';
  580. if(j==0){
  581. imageItem = $('<img src="'+emrImageList[j].imgPath+'" id="emrImg_'+emrImageList.length+'_'+j+'" class="img-disp-Y">');
  582. }else{
  583. imageItem = $('<img src="'+emrImageList[j].imgPath+'" id="emrImg_'+emrImageList.length+'_'+j+'" class="img-disp-N">');
  584. };
  585. $('#emrList').append(imageItem);
  586. };
  587. // 첫번째 이미지 보이게 하기 / 페이지 정보 셋팅
  588. $('#emrPageInfo').html('1 / ' + emrImageList.length);
  589. var element = $('meta[name=viewport]')[0];
  590. element.setAttribute('content','width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=3.0, user-scalable=yes');
  591. $('#emrList').unbind();
  592. $('#emrList').on('click touchend', function(event) {//터치엔드일때만 클릭을한번 더먹이면어떨까?
  593. var zoom = document.documentElement.clientWidth / window.innerWidth;
  594. if(zoom > 1){
  595. $('.mp-page-header, #prevEmrBtn, #nextEmrBtn, #emrPageInfo').css('display', 'none');
  596. }else{
  597. if( $('#emrList img').length > 1 ) {
  598. $('#prevEmrBtn, #nextEmrBtn').css('display', 'block');
  599. }
  600. $('.mp-page-header, #emrPageInfo').css('display', 'block');
  601. };
  602. if(event.type=='touchend'){ //아이폰에서 헤더와 버튼이 제대로 나타나지 않아서 한번더 이벤트를 먹임
  603. $('#emrList').click();
  604. };
  605. });
  606. };
  607. //pacsOpen 버튼클릭
  608. var pacsOpen = function(examInfo){
  609. var jsonmsg = {
  610. "type" : "command",
  611. "functionType" : "callPacs",
  612. "value" : {"user_id": "hyumc", "user_pw": "mob*app/hy01", "accno": examInfo.accNo}
  613. };
  614. self.toNative(jsonmsg);
  615. };
  616. // 검사 Tree
  617. var treeClose = $('<span class="glyphicon glyphicon-menu-up" aria-hidden="true"></span>');
  618. var treeOpen = $('<span class="glyphicon glyphicon-menu-down" aria-hidden="true"></span>');
  619. var highIcon = $('<span class="exam-ref-result-high">H</span>');
  620. var lowIcon = $('<span class="exam-ref-result-low">L</span>');
  621. var $btnPacs = $('#btnPacs');
  622. /**
  623. * 검사 Tree
  624. * 상위 카테고리(대분류), 하위 카테고리(중분류), 검사 Title 이 각각 레벨 1, 2, 3으로 존재한다.
  625. * 카테고리 상태: 열림, 닫힘 - "open" class의 존재 여부로 판단한다.
  626. *
  627. * */
  628. var examineTreeCtrl = {
  629. /* 전체 검사리스트를 받아서 데이터를 쓰기 좋게 편집하고, 대분류 카테고리들만 화면에 배치한다. */
  630. init: function(examList) {
  631. var examineList = $('#examineList');
  632. examineList.empty();
  633. var level1 = div.clone().addClass('tree-level-1').append(div.clone().addClass('item').append(treeClose));
  634. var level2 = div.clone().addClass('tree-level-2');
  635. examineTreeCtrl.examList = examList;
  636. examineTreeCtrl.grouping(examList);
  637. /* 상위 카테고리 배치 - Level 1 */
  638. for( var i = 0; i < examineTreeCtrl.examData.length; i++) {
  639. var node = level1.clone();
  640. var nodeData = node.find('.item').attr('id', 'node_' + examineTreeCtrl.examData[i].categoryCd).attr('level', '1');
  641. nodeData.append(examineTreeCtrl.examData[i].categoryNm);
  642. nodeData.click(function(e) {examineTreeCtrl.nodeOpen(e);});
  643. examineList.append(node);
  644. /* 하위 카테고리 컨테이너 배치 - Level 2 (border-left)*/
  645. /* 상위 카테고리의 바로 아래에 위치한다. */
  646. var nodeLvl2 = level2.clone().attr('parent', 'node_' + examineTreeCtrl.examData[i].categoryCd); // parent 속성은 상위 카테고리의 ID
  647. examineList.append(nodeLvl2);
  648. /* 마지막 Level 2는 닫힌 상태에서 border left가 없어야 하기 때문에 last class 추가*/
  649. if( i == (examineTreeCtrl.examData.length - 1)) {
  650. nodeData.addClass('last');
  651. nodeLvl2.css('display', 'none');
  652. }
  653. };
  654. $('.tree-level-1 .item').click(); //level 2까지 열기위함
  655. },
  656. /* 카테고리를 열거나 닫는다. */
  657. nodeOpen: function(e) {
  658. var targetNode = $(e.currentTarget);
  659. var targetNodeId = e.currentTarget.id;
  660. var level = targetNode.attr('level');
  661. var isOpen = targetNode.hasClass('open');
  662. var isLast = targetNode.hasClass('last');
  663. if( isOpen ) { /* 닫기 */
  664. targetNode.removeClass('open');
  665. targetNode.find('span').removeClass('glyphicon-menu-down').addClass('glyphicon-menu-up'); // 화살표 방향 전환
  666. if (level == '1') {
  667. /* Level 2를 비운다. */
  668. var level2 = $('#examineList .tree-level-2[parent=' + targetNodeId + ']');
  669. level2.empty();
  670. if(isLast) {
  671. level2.css('display', 'none');
  672. }
  673. } else if (level == '2') {
  674. /* Level 3를 없앤다. */
  675. var level3 = $('#examineList .tree-level-3[parent=' + targetNodeId + ']');
  676. level3.remove();
  677. }
  678. } else { /* 열기 */
  679. targetNode.addClass('open');
  680. targetNode.find('span').removeClass('glyphicon-menu-up').addClass('glyphicon-menu-down'); // 화살표 방향 전환
  681. if (level == '1') {
  682. // 중분류 가져오기
  683. var lowerCategorys = examineTreeCtrl.getLowerCategory(targetNodeId.split('node_')[1]);
  684. var level2 = $('#examineList .tree-level-2[parent=' + targetNodeId + ']');
  685. if(isLast) {
  686. level2.css('display', 'block');
  687. }
  688. for( var i = 0; i < lowerCategorys.length; i++ ) {
  689. var nodeLvl2Item = div.clone().addClass('item').append(treeClose.clone()).append(lowerCategorys[i].categoryNm);
  690. var nodeLvl2Data = div.clone().addClass('item-wrap').append(nodeLvl2Item).attr('level', '2').attr('id', 'node2_' + lowerCategorys[i].categoryCd);
  691. nodeLvl2Data.click(function(e) { examineTreeCtrl.nodeOpen(e); });
  692. level2.append(nodeLvl2Data);
  693. }
  694. } else if (level == '2') {
  695. var parentId = targetNode.parent().attr('parent').split('node_')[1];
  696. var examList = examineTreeCtrl.getExamList(parentId, targetNodeId.split('node2_')[1]);
  697. examList = self.util.sortObj(examList, 'examinationDt', 'date', 'down');
  698. var level3 = div.clone().addClass('tree-level-3').attr('parent', targetNodeId);
  699. for( var i = 0; i < examList.length; i++ ) {
  700. var examName = span.clone().addClass('').append(examList[i].examinationNm);
  701. var examDateStatus = span.clone().addClass('exam-date-status').append('&nbsp;&nbsp;[ ' + examList[i].examinationDt + ' ' + (examList[i].examinationRst==null? '': examList[i].examinationRst) + ' ]');
  702. var pacsYn = (examList[i].highClassCd!='B' && examList[i].pacs!=null && (examList[i].pacs=='H'||examList[i].pacs=='M'||examList[i].pacs=='S'||examList[i].pacs=='Y'))? span.clone().addClass('glyphicon glyphicon-picture pacs'): '';
  703. var examItem = div.clone().addClass('item').append(examName).append(examDateStatus).append(pacsYn).attr('id', 'node3_' + examList[i].examinationId).attr('highClassCd', examList[i].highClassCd).attr('accNo', examList[i].AccNo).attr('pacs', examList[i].pacs);
  704. /*examItem.click(function(e) {
  705. examineTreeCtrl.getExamInfo(e.currentTarget.id.split('node3_')[1]);
  706. });*/
  707. level3.append(examItem);
  708. }
  709. targetNode.after(level3);
  710. $('[id*=node3_]').unbind();
  711. $('[id*=node3_]').click(function(e){
  712. examineTreeCtrl.getExamInfo(e.currentTarget.id.split('node3_')[1]);
  713. $('#examName').text(e.currentTarget.innerText);
  714. });
  715. }
  716. }
  717. },
  718. getLowerCategory: function(categoryCd) {
  719. //2018.06.18. 안드로이드 호환 변경
  720. //return examineTreeCtrl.examData.find(function(item) {if(item.categoryCd == categoryCd){return true}}).lowerCategory;
  721. var rExamineTreeCtrl = undefined;
  722. for(var i = 0 ; i < examineTreeCtrl.examData.length ; i++){
  723. if(examineTreeCtrl.examData[i].categoryCd == categoryCd){
  724. rExamineTreeCtrl = examineTreeCtrl.examData[i];
  725. break;
  726. }
  727. }
  728. return rExamineTreeCtrl.lowerCategory;
  729. },
  730. getExamList: function(categoryCd, lowerCategoryCd) {
  731. var lowerCategory = examineTreeCtrl.getLowerCategory(categoryCd);
  732. //2018.06.18. 안드로이드 호환 변경
  733. //return lowerCategory.find(function(item) {if(item.categoryCd == lowerCategoryCd){return true}}).examList;
  734. var rLowerCategory = undefined;
  735. for(var i = 0 ; i < lowerCategory.length ; i++){
  736. if(lowerCategory[i].categoryCd == lowerCategoryCd){
  737. rLowerCategory = lowerCategory[i];
  738. break;
  739. }
  740. }
  741. return rLowerCategory.examList;
  742. },
  743. getExamInfo: function(examId) {
  744. var selectedExam = examineTreeCtrl.examList[examId];
  745. var patientInfo = JSON.parse(localStorage.getItem('patientInfo'));
  746. $('#examInfoPatientName').text(patientInfo.patientNm + ' ' + patientInfo.patientId);
  747. $btnPacs.css('display', 'none');
  748. $('#examineInfo').empty();
  749. if( selectedExam.highClassCd == 'B') { // 검체검사
  750. examineTreeCtrl.drawExam_B(selectedExam);
  751. } else if( selectedExam.highClassCd == 'D') { // 병리검사
  752. examineTreeCtrl.drawExam_D(selectedExam);
  753. } else if( selectedExam.highClassCd == 'E'){ // 기능검사
  754. examineTreeCtrl.drawExam_E(selectedExam);
  755. } else if( selectedExam.highClassCd == 'C'){ // 영상검사
  756. examineTreeCtrl.drawExam_C(selectedExam);
  757. } else { // 검체검사, 병리검사가 아닌 모든 검사
  758. examineTreeCtrl.drawExam(selectedExam);
  759. }
  760. $('#patientPopup #popContentExamineInfo').addClass('in');
  761. $('#examineInfo').scrollLeft(0);
  762. $('.exam-wrap').scrollTop(0);
  763. $('#patientPopup').css('display', 'block');
  764. },
  765. drawExam: function(selectedExam){
  766. var tempExamText = "판독 결과 : <br> 판독결과 ~~~~~~~~~~~~ <br> 판독 결과 ~~~~~~~~~~~.";
  767. $('#examineInfo').append(div.clone().addClass('col-xs-12').append(span.clone().addClass('top-info-style').append(tempExamText)));
  768. },
  769. drawExam_D: function(selectedExam) {
  770. // var param = {
  771. // patientId: patientInfo.patientId,
  772. // accNo: selectedExam.AccNo
  773. // };
  774. // var examRslt = self.patient.getExamRsltByPA(param);
  775. // //console.log(examRslt);
  776. // if( examRslt.result.length == 0 ) {
  777. // $('#examineInfo').append(div.clone().addClass('col-xs-12').append(span.clone().addClass('top-info-style').append('판독 결과 없음')));
  778. // } else {
  779. // $('#examineInfo').append(div.clone().addClass('col-xs-12').append(span.clone().addClass('mp-dot')).append(span.clone().addClass('top-info-style').append('병리의사: ' + examRslt.result[0].ReadDrNm + ' / ' + examRslt.result[0].PthoDrNm)));
  780. // $('#examineInfo').append(div.clone().addClass('col-xs-12 mt5').append(span.clone().addClass('mp-dot')).append(span.clone().addClass('top-info-style').append('Name Of Operation')));
  781. // $('#examineInfo').append(div.clone().addClass('col-xs-12 mt5 top-info-style exam-rslt').append(span.clone().addClass('top-info-style').append(examRslt.result[0].ExNm)));
  782. // $('#examineInfo').append(div.clone().addClass('col-xs-12').append(span.clone().addClass('mp-dot')).append(span.clone().addClass('top-info-style').append('Pathological Diagnosis')));
  783. // $('#examineInfo').append(div.clone().addClass('col-xs-12 mt5 top-info-style exam-rslt').append(span.clone().addClass('top-info-style').html(examRslt.result[0].Diagnosis.replace(/\n/g, '<br>'))));
  784. // if(examRslt.result[0].GrossDiagnosis != undefined) { //2018.04.09 병원 요구사항으로 데이터 추가
  785. // $('#examineInfo').append(div.clone().addClass('col-xs-12').append(span.clone().addClass('mp-dot')).append(span.clone().addClass('top-info-style').append('Gross Description')));
  786. // $('#examineInfo').append(div.clone().addClass('col-xs-12 mt5 top-info-style exam-rslt').append(span.clone().addClass('top-info-style').html(examRslt.result[0].GrossDiagnosis.replace(/\n/g, '<br>'))));
  787. // }
  788. // }
  789. var tempReadDrNm = "홍길동";
  790. var tempPthoDrNm = "홍길동01, 홍길동 02";
  791. var tempExNm = "검체유형 : Voided Urine Cytology";
  792. var tempDiagnosis = "Negative for hight-grade urothelial carcinoma, according to The Paris System for Reportind Urinary Cytology";
  793. $('#examineInfo').append(div.clone().addClass('col-xs-12').append(span.clone().addClass('mp-dot')).append(span.clone().addClass('top-info-style').append('병리의사: ' + tempReadDrNm + ' / ' + tempPthoDrNm)));
  794. $('#examineInfo').append(div.clone().addClass('col-xs-12 mt5').append(span.clone().addClass('mp-dot')).append(span.clone().addClass('top-info-style').append('Name Of Operation')));
  795. $('#examineInfo').append(div.clone().addClass('col-xs-12 mt5 top-info-style exam-rslt').append(span.clone().addClass('top-info-style').append(tempExNm)));
  796. $('#examineInfo').append(div.clone().addClass('col-xs-12').append(span.clone().addClass('mp-dot')).append(span.clone().addClass('top-info-style').append('Pathological Diagnosis')));
  797. $('#examineInfo').append(div.clone().addClass('col-xs-12 mt5 top-info-style exam-rslt').append(span.clone().addClass('top-info-style').html(tempDiagnosis.replace(/\n/g, '<br>'))));
  798. },
  799. drawExam_B: function(selectedExam) {
  800. // var param, examInfo;
  801. // if(selectedExam.middleClassCd == "B08"){ // 미생물 결과값 별도처리 "middleClassNm": "미생물"
  802. // param = {
  803. // ymdGb: 'B',
  804. // ordYmd: selectedExam.OrdYmd,
  805. // ordExecYmd: selectedExam.examinationDt.replace(/-/gi, ''),
  806. // unitNo: patientInfo.patientId,
  807. // ordSlipCd: selectedExam.OrdSlipCd
  808. // };
  809. // examInfo = self.patient.GetExamRsltByGer(param);
  810. // }else{
  811. // param = {
  812. // patientId: patientInfo.patientId,
  813. // prescriptionDt: selectedExam.OrdYmd,
  814. // executeDt: selectedExam.examinationDt.replace(/-/gi, ''),
  815. // ordSlipCd: selectedExam.OrdSlipCd
  816. // };
  817. // examInfo = self.patient.getExamInfo(param);
  818. // }
  819. // var examInfoList = examineTreeCtrl.examInfoGrouping(examInfo.result);
  820. var examTable = table.clone();
  821. var examThead = thead.clone();
  822. var examRow = tr.clone().addClass('exam-header');
  823. var spcNmCol = th.clone().append('검체명');
  824. var grExamNmCol = th.clone().attr('colspan', '2').append('검사명');
  825. var rsltCol = th.clone().append('결과');
  826. var refNmrcCol = th.clone().append('참고치');
  827. var rsltUnitCdNmCol = th.clone().append('단위');
  828. var refNmrcGbCol = th.clone().append('판<br>정');
  829. var rsltProgStusNmCol = th.clone().append('상태');
  830. var examinationDtTmCol = th.clone().append('일시');
  831. examRow.append(spcNmCol).append(grExamNmCol).append(rsltCol).append(refNmrcCol).append(rsltUnitCdNmCol).append(refNmrcGbCol).append(rsltProgStusNmCol).append(examinationDtTmCol);
  832. examTable.append(examThead.append(examRow));
  833. //if(examInfoList.length==0){
  834. var emptyCol = td.clone().attr('colspan', 9).append('-');
  835. examTable.append(tr.clone().addClass('text-center').append(emptyCol));
  836. //}
  837. // for(var i=0; i<examInfoList.length; i++){
  838. // for(var j=0; j<examInfoList[i].GrExam.length; j++){
  839. // for(var k=0; k<examInfoList[i].GrExam[j].examList.length; k++){
  840. // var examRow = tr.clone();
  841. // var spcNmCol = '';
  842. // var grExamNmCol = '';
  843. // var examNmCol = '';
  844. // if(j==0 && k==0) spcNmCol = td.clone().addClass('text-center').attr('rowspan', examInfoList[i].SpcLength).append(examInfoList[i].SpcNm);
  845. // if(k==0){
  846. // if(examInfoList[i].GrExam[j].examList.length>1){
  847. // grExamNmCol = td.clone().attr('rowspan', examInfoList[i].GrExam[j].examList.length).append(examInfoList[i].GrExam[j].examList[k].GrExamNm);
  848. // examNmCol = td.clone().append(examInfoList[i].GrExam[j].examList[k].ExamNm);
  849. // }else{
  850. // grExamNmCol = td.clone().attr('colspan', 2).append(examInfoList[i].GrExam[j].examList[k].GrExamNm);
  851. // }
  852. // }else{
  853. // examNmCol = td.clone().append(examInfoList[i].GrExam[j].examList[k].ExamNm);
  854. // }
  855. // var rsltCol;
  856. // if(examInfoList[i].GrExam[j].examList[k].IncrGrd != null || examInfoList[i].GrExam[j].examList[k].IncrGrd !== undefined){
  857. // if(examInfoList[i].GrExam[j].examList[k].Rslt == null){
  858. // examInfoList[i].GrExam[j].examList[k].Rslt = "";
  859. // }
  860. // rsltCol = td.clone().append(examInfoList[i].GrExam[j].examList[k].IncrGrd + examInfoList[i].GrExam[j].examList[k].Rslt);
  861. // }else{
  862. // if(examInfoList[i].GrExam[j].examList[k].Rslt == null){
  863. // examInfoList[i].GrExam[j].examList[k].Rslt = "";
  864. // }
  865. // rsltCol = td.clone().append( examInfoList[i].GrExam[j].examList[k].Rslt);
  866. // }
  867. // var refNmrcCol = td.clone().append(examInfoList[i].GrExam[j].examList[k].RefNmrc);
  868. // var rsltUnitCdNmCol = td.clone().append(examInfoList[i].GrExam[j].examList[k].RsltUnitCdNm);
  869. // var refNmrcGbCol = td.clone().addClass('text-center');
  870. // if( examInfoList[i].GrExam[j].examList[k].RefNmrcGb == 'H' ) {refNmrcGbCol.append(highIcon.clone());}
  871. // else if ( examInfoList[i].GrExam[j].examList[k].RefNmrcGb == 'L' ) {refNmrcGbCol.append(lowIcon.clone());}
  872. //
  873. // var rsltProgStusNmCol = td.clone().append(examInfoList[i].GrExam[j].examList[k].RsltProgStusNm);
  874. // var examinationDtTmCol = td.clone().append(examInfoList[i].GrExam[j].examList[k].examinationDtTm==null? '': (self.util.toPrettyDateFormat(examInfoList[i].GrExam[j].examList[k].examinationDtTm)));
  875. //
  876. // examRow.append(spcNmCol).append(grExamNmCol).append(examNmCol).append(rsltCol).append(refNmrcCol).append(rsltUnitCdNmCol).append(refNmrcGbCol).append(rsltProgStusNmCol).append(examinationDtTmCol);
  877. // examTable.append(examRow);
  878. // }
  879. // }
  880. // }
  881. $('#examineInfo').append(examTable);
  882. },
  883. drawExam_E: function(selectedExam) {
  884. var tempExamText = "1. Enlarged LA. <br>2.Relaxation abnormality of LV filling pattern with elevated LV filling pressure. <br>3. Concentric LVH. <br>4. Non-RHD.";
  885. $('#examineInfo').append(div.clone().addClass('col-xs-12').append(span.clone().addClass('top-info-style').append(tempExamText)));
  886. examineTreeCtrl.drawPacs(selectedExam);
  887. },
  888. drawExam_C: function(selectedExam) {
  889. var tempReadDrNm = "홍길동";
  890. var tempSplstDrNm = "홍길동01";
  891. var tempRslt = "some scoliosis of thoracic and lumbar spines with degenerative spondylosis and osteoporosis or osteopenia.\nAbnormal opacity of Lt. retrocardiac areas are seen from pneumonia or atelectasis.";
  892. $('#examineInfo').append(div.clone().addClass('col-xs-6 col-sm-3').append(span.clone().addClass('mp-dot')).append(span.clone().addClass('top-info-style').append('판독의: ' + tempReadDrNm)));
  893. $('#examineInfo').append(div.clone().addClass('col-xs-6 col-sm-3').append(span.clone().addClass('mp-dot')).append(span.clone().addClass('top-info-style').append('전문의: ' + tempSplstDrNm)));
  894. $('#examineInfo').append(div.clone().addClass('col-xs-12 mt5 top-info-style exam-rslt').html(tempRslt.replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\n/g, '<br>')));
  895. examineTreeCtrl.drawPacs(selectedExam);
  896. },
  897. drawPacs: function(selectedExam){
  898. var pacs = selectedExam.pacs;
  899. if( pacs == 'S' || pacs == 'M' || pacs == 'H' || pacs == 'Y' ) {
  900. $btnPacs.css('display', 'initial');
  901. $btnPacs.attr('examId', selectedExam.examinationId);
  902. $btnPacs.unbind();
  903. $btnPacs.click(function(e){
  904. var examId = e.currentTarget.attributes.examId.value;
  905. var selectedExam = examineTreeCtrl.examList[examId];
  906. var patientInfo = JSON.parse(localStorage.getItem('patientInfo'));
  907. var jsonmsg, url, title;
  908. if( selectedExam.pacs == 'S' ) { // GE PACS
  909. title = "GE";
  910. url = self.getPacsUrl(selectedExam.pacs, localStorage.hospitalCd);
  911. url = url.replace('{patientId}', patientInfo.patientId).replace('{accNo}', selectedExam.AccNo);
  912. //안드로이드 iOS분기처리
  913. if(/android/i.test(navigator.userAgent.toLowerCase())){
  914. }else if(/iphone|ipad|ipod/i.test(navigator.userAgent.toLowerCase())){
  915. url = encodeURIComponent(url);
  916. }
  917. jsonmsg = {
  918. "type" : "command",
  919. "functionType" : "popup",
  920. "value" : {"url": url}
  921. };
  922. } else if( selectedExam.pacs == 'M' ){ // MUSE
  923. title = "MUSE";
  924. url = self.getPacsUrl(selectedExam.pacs, localStorage.hospitalCd);
  925. url = url.replace('{patientId}', patientInfo.patientId);
  926. jsonmsg = {
  927. "type" : "command",
  928. "functionType" : "popup",
  929. "value" : {"url": url}
  930. };
  931. } else if( selectedExam.pacs == 'H' ){ // Cardiac PACS - infinitt 앱 연동
  932. title = "Cardiac PACS";
  933. self.alert('서비스 준비 중입니다.');
  934. return;
  935. } else if( selectedExam.pacs == 'Y' ){ // Cardiac PACS - infinitt 앱 연동
  936. //$('#examineInfo').append(div.clone().addClass('col-xs-12').append(span.clone().addClass('top-info-style').append( 'PACS Image !! ')));
  937. $('#modalSamplePACS').modal('show');
  938. } else {
  939. title = "ETC PACS";
  940. self.alert('서비스 준비 중입니다.');
  941. return;
  942. }
  943. // var logging = {
  944. // "logType" : "PACS",
  945. // "userId" : loginUserId,
  946. // "userName" : loginUserName,
  947. // "deptName" : selectDeptName,
  948. // "title" : title,
  949. // "content" : url,
  950. // "content2" : navigator.userAgent,
  951. // "content3" : localStorage.hospitalCd
  952. // };
  953. // var loggingResult = self.patient.loggingLookupPACS(logging);
  954. // if( loggingResult.result == 1 ) {
  955. // self.toNative(jsonmsg);
  956. // } else {
  957. // self.alert('다시 시도해주세요.');
  958. // }
  959. });
  960. }
  961. },
  962. /* 서버로부터 받은 데이터를 정리한다. examList */
  963. grouping: function(examList) {
  964. var groupingExam = [];
  965. for( var i = 0; i < examList.length; i++) {
  966. // ID 부여
  967. examList[i].examinationId = i;
  968. var categoryIndex = groupingExam.map(function(item){ return item.categoryCd;}).indexOf(examList[i].highClassCd);
  969. if(categoryIndex == -1) { //처음보는 대분류
  970. var group = {};
  971. group.categoryCd = examList[i].highClassCd;
  972. group.categoryNm = examList[i].highClassNm;
  973. group.lowerCategory = [{ categoryCd: examList[i].middleClassCd, categoryNm: examList[i].middleClassNm, examList: [ examList[i]] }];
  974. groupingExam.push(group);
  975. } else { // 기존에 등록된 대분류
  976. var lowerCategoryIndex = groupingExam[categoryIndex].lowerCategory.map(function(item) {return item.categoryCd;}).indexOf(examList[i].middleClassCd);
  977. if( lowerCategoryIndex == -1) { // 처음보는 중분류
  978. var lowerCategory = {};
  979. lowerCategory.categoryCd = examList[i].middleClassCd;
  980. lowerCategory.categoryNm = examList[i].middleClassNm;
  981. lowerCategory.examList = [ examList[i] ];
  982. groupingExam[categoryIndex].lowerCategory.push(lowerCategory);
  983. } else { // 기존에 등록된 중분류
  984. groupingExam[categoryIndex].lowerCategory[lowerCategoryIndex].examList.push(examList[i]);
  985. }
  986. }
  987. }
  988. examineTreeCtrl.examData = groupingExam;
  989. },
  990. examData: [],
  991. examList: []
  992. };
  993. };