consent.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722
  1. /**
  2. * consent
  3. */
  4. var mplus_mobile_consent = function(){
  5. mcare_mobile.call(this);
  6. var div = $("<div></div>");
  7. var tr = $("<tr></tr>");
  8. var th = $("<th></th>");
  9. var td = $("<td></td>");
  10. var table = $("<table></table>");
  11. var li = $("<li></li>");
  12. var a = $("<a></a>");
  13. var span = $("<span></span>");
  14. var $ulPatientList = $('#ulPatientList');
  15. var self = this;
  16. $serviceBaseUrl = contextPath + "/mobile";
  17. $hospitalServiceBaseUrl = contextPath + "/mobile/hospital";
  18. $consentServiceBaseUrl = contextPath + "/mobile/consent";
  19. this.hospital = {
  20. //부서리스트
  21. getDeptList : function(request){
  22. var deptList = [];
  23. $.ajax ({
  24. url : $hospitalServiceBaseUrl + '/getDeptList.json',
  25. type : 'POST',
  26. dataType: "json",
  27. contentType: "application/json",
  28. async: false,
  29. data: JSON.stringify(request),
  30. success: function(response){
  31. deptList = response.result;
  32. }
  33. });
  34. return deptList;
  35. },
  36. //의사리스트
  37. getDoctorList : function(request){
  38. var doctorList = [];
  39. $.ajax ({
  40. url : $hospitalServiceBaseUrl + '/getDoctorList.json',
  41. type : 'POST',
  42. dataType: "json",
  43. contentType: "application/json",
  44. async: false,
  45. data: JSON.stringify(request),
  46. success: function(response){
  47. doctorList = response.result;
  48. }
  49. });
  50. return doctorList;
  51. },
  52. //병동리스트
  53. getWardList : function(){
  54. var wardList = [];
  55. $.ajax ({
  56. url : $hospitalServiceBaseUrl + '/getWardList.json',
  57. type : 'POST',
  58. dataType: "json",
  59. contentType: "application/json",
  60. async: false,
  61. data: JSON.stringify({}),
  62. success: function(response){
  63. wardList = response.result;
  64. }
  65. });
  66. return wardList;
  67. },
  68. // 환자정보조회
  69. getPatientInfo : function(request){
  70. var patientInfoList = [];
  71. $.ajax ({
  72. url : $hospitalServiceBaseUrl + '/getPatientInfo.json',
  73. type : 'POST',
  74. dataType: "json",
  75. contentType: "application/json",
  76. async: false,
  77. data: JSON.stringify(request),
  78. success: function(response){
  79. if( response.msg != undefined ) {
  80. self.alert(response.msg);
  81. return;
  82. } else {
  83. patientInfoList = response.result;
  84. }
  85. }
  86. });
  87. return patientInfoList;
  88. }
  89. };
  90. this.patient = {
  91. //환자리스트 조회
  92. getPatientList : function(type, request, firstYn){
  93. var requestUrl = getPatientListUrl(type);
  94. // url이 안넘어왔을 때 (type을 잘못입력)
  95. if (requestUrl == undefined) {
  96. alert('잘못된 요청입니다.');
  97. return;
  98. };
  99. patientList = [];
  100. $ulPatientList.empty();
  101. $.ajax ({
  102. url : requestUrl,
  103. type : 'POST',
  104. dataType: "json",
  105. contentType: "application/json",
  106. beforeSend: function(){
  107. self.loading("show");
  108. },
  109. data: JSON.stringify(request)
  110. }).done(function(response){
  111. self.loading("hide");
  112. result = response.result
  113. patientList = result;
  114. if(firstYn!='Y'&&(result==undefined||result.length==0)) {
  115. self.loading("hide");
  116. self.alert('조회된 데이터가 없습니다.');
  117. return;
  118. };
  119. self.patient.setPatientList(type, result, "", "");
  120. });
  121. },
  122. setPatientList : function(type, list, sortKey, sortType, order){
  123. patientList = [];
  124. $ulPatientList.empty();
  125. result = sortKey==""? list: self.util.sortObj(list, sortKey, sortType, order);
  126. patientList = result;
  127. if(type=='I'){
  128. for(var i=0; i<result.length; i++){
  129. var aItem = a.clone().addClass("list-group-item").attr("seq", i);
  130. var divListRow = div.clone().addClass("list-row");
  131. var spanItem = span.clone().addClass("num").text(result[i].pid),
  132. spanItem2 = span.clone().addClass("name").text(result[i].deptnm),
  133. spanItem3 = span.clone().addClass("period").text(result[i].doctornm),
  134. divItem = divListRow.clone().html(spanItem).append(spanItem2).append(spanItem3);
  135. var spanItem4 = span.clone().addClass("num").text(result[i].sa),
  136. spanItem5 = span.clone().addClass("name").text(result[i].hngnm),
  137. spanItem6 = span.clone().addClass("period").text(result[i].roomcd),
  138. divItem2 = divListRow.clone().html(spanItem4).append(spanItem5).append(spanItem6);
  139. $ulPatientList.append(li.clone().html(aItem.clone().html(divItem).append(divItem2)).attr("id", "patient_"+i));
  140. };
  141. }else if(type=='O'){
  142. for(var i=0; i<result.length; i++){
  143. var aItem = a.clone().addClass("list-group-item").attr("seq", i);
  144. var divListRow = div.clone().addClass("list-row");
  145. var spanItem = span.clone().addClass("num").text(result[i].pid),
  146. spanItem2 = span.clone().addClass("name").text(result[i].deptnm),
  147. spanItem3 = span.clone().addClass("period").text(result[i].doctornm),
  148. divItem = divListRow.clone().html(spanItem).append(spanItem2).append(spanItem3);
  149. var spanItem4 = span.clone().addClass("num").text(result[i].sa),
  150. spanItem5 = span.clone().addClass("name").text(result[i].hngnm),
  151. divItem2 = divListRow.clone().html(spanItem4).append(spanItem5);
  152. $ulPatientList.append(li.clone().html(aItem.clone().html(divItem).append(divItem2)).attr("id", "patient_"+i));
  153. };
  154. }else if(type=='E'){
  155. for(var i=0; i<result.length; i++){
  156. var aItem = a.clone().addClass("list-group-item").attr("seq", i);
  157. var divListRow = div.clone().addClass("list-row");
  158. var spanItem = span.clone().addClass("num").text(result[i].pid),
  159. spanItem2 = span.clone().addClass("name").text(result[i].erorddeptnm),
  160. spanItem3 = span.clone().addClass("period").text(result[i].ermedispclnm),
  161. divItem = divListRow.clone().html(spanItem).append(spanItem2).append(spanItem3);
  162. var spanItem4 = span.clone().addClass("num").text(result[i].sa),
  163. spanItem5 = span.clone().addClass("name").text(result[i].hngnm),
  164. spanItem6 = span.clone().addClass("period").text(result[i].badcd),
  165. divItem2 = divListRow.clone().html(spanItem4).append(spanItem5).append(spanItem6);
  166. $ulPatientList.append(li.clone().html(aItem.clone().html(divItem).append(divItem2)));
  167. };
  168. }else if(type=='OP'){
  169. for(var i=0; i<result.length; i++){
  170. var aItem = a.clone().addClass("list-group-item").attr("seq", i);
  171. var divListRow = div.clone().addClass("list-row");
  172. var spanItem = span.clone().addClass("num").text(result[i].pid),
  173. spanItem2 = span.clone().addClass("name").text(result[i].deptnm),
  174. spanItem3 = span.clone().addClass("period").text(moment(result[i].opcnfmdd).format('YYYY/MM/DD')),
  175. divItem = divListRow.clone().html(spanItem).append(spanItem2).append(spanItem3);
  176. var spanItem4 = span.clone().addClass("num").text(result[i].sa),
  177. spanItem5 = span.clone().addClass("name").text(result[i].hngnm),
  178. spanItem6 = span.clone().addClass("period").text(result[i].oproomnm),
  179. divItem2 = divListRow.clone().html(spanItem4).append(spanItem5).append(spanItem6);
  180. $ulPatientList.append(li.clone().html(aItem.clone().html(divItem).append(divItem2)));
  181. };
  182. }else if(type=='SR'){
  183. for(var i=0; i<result.length; i++){
  184. var aItem = a.clone().addClass("list-group-item").attr("seq", i);
  185. var divListRow = div.clone().addClass("list-row");
  186. var spanItem = span.clone().addClass("num").text(result[i].pid),
  187. spanItem2 = span.clone().addClass("name").text(result[i].deptnm),
  188. spanItem3 = span.clone().addClass("period").text(result[i].doctornm),
  189. divItem = divListRow.clone().html(spanItem).append(spanItem2).append(spanItem3);
  190. var spanItem4 = span.clone().addClass("num").text(result[i].sa),
  191. spanItem5 = span.clone().addClass("name").text(result[i].hngnm),
  192. spanItem6 = span.clone().addClass("period").text(result[i].indd),
  193. divItem2 = divListRow.clone().html(spanItem4).append(spanItem5).append(spanItem6);
  194. $ulPatientList.append(li.clone().html(aItem.clone().html(divItem).append(divItem2)).attr("id", "patient_"+i));
  195. };
  196. };
  197. $('#ulPatientList .list-group-item').on("click", function(e){
  198. $('#ulPatientList a').removeClass('active');
  199. $(this).addClass('active');
  200. // 환자 리스트에서 환자 변경 시, 우측의 동의서 찾기 또는 즐겨찾기에서 이전 환자 동의서 선택 해제 2017.04.13 고객요구사항반영
  201. $('#ulConsentList input[type="checkbox"]:checked').prop('checked', false);
  202. $('#ulConsentList li.checked').removeClass('checked');
  203. $('#ulSetList input[type="checkbox"]:checked').prop('checked', false);
  204. $('#ulSetList li.checked').removeClass('checked');
  205. getPatientInfo(e.currentTarget.attributes.seq.value);
  206. });
  207. }
  208. };
  209. this.consent = {
  210. //동의서조회
  211. getConsentList : function(request){
  212. var consentList = [];
  213. $.ajax ({
  214. url : $consentServiceBaseUrl + '/getConsentList.json',
  215. type : 'POST',
  216. dataType: "json",
  217. contentType: "application/json",
  218. async: false,
  219. data: JSON.stringify(request),
  220. success: function(response){
  221. consentList = response.result;
  222. }
  223. });
  224. return consentList;
  225. },
  226. //동의서 검색
  227. getConsentBySearch: function(request){
  228. var consentList = [];
  229. $.ajax ({
  230. url : $consentServiceBaseUrl + '/getConsentBySearch.json',
  231. type : 'POST',
  232. dataType: "json",
  233. contentType: "application/json",
  234. async: false,
  235. data: JSON.stringify(request),
  236. success: function(response){
  237. consentList = response.result;
  238. }
  239. });
  240. return consentList;
  241. },
  242. //동의서 set조회
  243. getConsentSetList: function(request){
  244. var consentList = [];
  245. $.ajax ({
  246. url : $consentServiceBaseUrl + '/set/getConsentSetList.json',
  247. type : 'POST',
  248. dataType: "json",
  249. contentType: "application/json",
  250. async: false,
  251. data: JSON.stringify(request),
  252. success: function(response){
  253. consentList = response.result;
  254. }
  255. });
  256. return consentList;
  257. },
  258. //동의서 즐겨찾기 추가
  259. setUserFormSetList: function(request){
  260. var result = {};
  261. $.ajax ({
  262. url : $consentServiceBaseUrl + '/set/setUserFormSetList.json',
  263. type : 'POST',
  264. dataType: "json",
  265. contentType: "application/json",
  266. async: false,
  267. data: JSON.stringify(request),
  268. success: function(response){
  269. result = response.result;
  270. }
  271. });
  272. return result;
  273. },
  274. //동의서 즐겨찾기 삭제
  275. delUserFormSetList: function(request){
  276. var result = {};
  277. $.ajax ({
  278. url : $consentServiceBaseUrl + '/set/delUserFormSetList.json',
  279. type : 'POST',
  280. dataType: "json",
  281. contentType: "application/json",
  282. async: false,
  283. data: JSON.stringify(request),
  284. success: function(response){
  285. result = response.result;
  286. }
  287. });
  288. return result;
  289. },
  290. //동의서 삭제
  291. delConsent: function(request){
  292. var result = {};
  293. $.ajax ({
  294. url : $consentServiceBaseUrl+'/save/saveDelete.json',
  295. type : 'POST',
  296. contentType: "application/json",
  297. async: false,
  298. data: JSON.stringify(request),
  299. success: function(response){
  300. result = response.result;
  301. }
  302. });
  303. return result;
  304. },
  305. //ocr Tag 할당
  306. getOcrTag: function(){
  307. var result = '';
  308. $.ajax ({
  309. url : $consentServiceBaseUrl + '/getOcrTag.json',
  310. type : 'POST',
  311. dataType: "json",
  312. contentType: "application/json",
  313. data: JSON.stringify({}),
  314. async: false,
  315. success: function(response){
  316. result = response.result;
  317. }
  318. });
  319. return result;
  320. },
  321. //카테고리리스트 조회
  322. getCategoryForDropdown: function(request){
  323. var categoryList = [];
  324. $.ajax ({
  325. url : $consentServiceBaseUrl + '/getCategoryForDropdown.json',
  326. type : 'POST',
  327. dataType: "json",
  328. contentType: "application/json",
  329. async: false,
  330. data: JSON.stringify(request),
  331. success: function(response){
  332. categoryList = response.result;
  333. }
  334. });
  335. return categoryList;
  336. },
  337. //주치의별 동의서 검색
  338. getUnfinishedListPerDoctor: function(request){
  339. var consentList = [];
  340. $.ajax ({
  341. url : $consentServiceBaseUrl + '/getUnfinishedListPerDoctor.json',
  342. type : 'POST',
  343. dataType: "json",
  344. contentType: "application/json",
  345. async: false,
  346. data: JSON.stringify(request),
  347. success: function(response){
  348. consentList = response.result;
  349. }
  350. });
  351. return consentList;
  352. },
  353. // 동의서 이미지 정보 조회
  354. getConsentImage: function(request){
  355. var consentImageList = [];
  356. $.ajax ({
  357. url : $consentServiceBaseUrl + '/getConsentImage.json',
  358. type : 'POST',
  359. dataType: "json",
  360. contentType: "application/json",
  361. async: false,
  362. data: JSON.stringify(request),
  363. success: function(response){
  364. consentImageList = response.result;
  365. }
  366. });
  367. return consentImageList;
  368. },
  369. // 동의서 상태 체크
  370. checkConsentState: function(request){
  371. var state;
  372. $.ajax ({
  373. url : $consentServiceBaseUrl + '/checkConsentState.json',
  374. type : 'POST',
  375. dataType: "json",
  376. contentType: "application/json",
  377. async: false,
  378. data: JSON.stringify(request),
  379. success: function(response){
  380. state = response.result;
  381. }
  382. });
  383. return state;
  384. },
  385. makeConsentStateParam: function() {
  386. // 체크된 박스들
  387. var checkedStatus = $('.consentSearchBox input:checked[id!="chkboxConsentSign"]');
  388. // 체크된게 없으면 일단 이렇게 처리
  389. if( checkedStatus.length == 0 ) {
  390. self.alert('동의서 상태 조건을 선택하세요!');
  391. return;
  392. // 더이상 동의서 조회가 진행되지 않도록 하기
  393. }
  394. var consentStatus = '';
  395. for(var i = 0; i < checkedStatus.length; i++) {
  396. // 전체가 체크된 경우 뒤도 돌아보지않고 ALL만 리턴하도록
  397. if( checkedStatus[i].value == 'ALL') {
  398. consentStatus = checkedStatus[i].value;
  399. return consentStatus;
  400. } else {
  401. consentStatus = consentStatus + checkedStatus[i].value;
  402. }
  403. // 콤마 구분자 추가
  404. if(i != checkedStatus.length - 1) {
  405. consentStatus = consentStatus + ',';
  406. }
  407. }
  408. return consentStatus;
  409. },
  410. // 앱으로 넘겨줄 동의서 리스트 파라메터 만들기 - 작성중 기준
  411. makeConsentParam: function(patientInfo, consentList, userName) {
  412. // 유효성 검사 추가하기
  413. var consent = [];
  414. for( var i = 0; i < consentList.length; i++ ) {
  415. var unfinishedConsent = false;
  416. if( consentList[i].consentState == 'UNFINISHED' ) {
  417. unfinishedConsent = true;
  418. }
  419. var consentItem = {
  420. newConsent : unfinishedConsent? true: false,
  421. hospitalCretno: patientInfo.iocretNo,
  422. ward: patientInfo.ioward==null? "":patientInfo.ioward,
  423. roomNo: patientInfo.ioroomNo==null? "": patientInfo.ioroomNo,
  424. orderNo: consentList[i].orderNo,
  425. orderCd: consentList[i].orderCd==null?"":consentList[i].orderCd,
  426. IO_ocr_cd: consentList[i].ocrNumber==null?"":consentList[i].ocrNumber,
  427. consentCretno: consentList[i].cretno,
  428. outDate: patientInfo.iodschdd==null?"":patientInfo.iodschdd,
  429. mainDrId: patientInfo.iomaindrId==null?"":patientInfo.iomaindrId,
  430. consentState: consentList[i].consentState,
  431. rid: consentList[i].consentMstRid,
  432. IO_formname: consentList[i].consentName,
  433. IO_INPUTNM: userName,
  434. formCd: consentList[i].formCd,
  435. formRid: consentList[i].formRid,
  436. IO_Pt_ID: patientInfo.ioptID==null? "": patientInfo.ioptID,
  437. IO_sex_age_y_m: patientInfo.iosexAgeYM==null? "": patientInfo.iosexAgeYM,
  438. IO_Pt_name: patientInfo.ioptName==null? "": patientInfo.ioptName,
  439. IO_JuminNo: patientInfo.iojuminNo==null? "": patientInfo.iojuminNo,
  440. IO_PT_birthday: patientInfo.iojuminNo==null? "": patientInfo.iojuminNo.split('-')[0],
  441. IO_ADdate: patientInfo.ioaddate==null? "": moment(patientInfo.ioaddate).format('YYYY/MM/DD'),
  442. IO_Dept: patientInfo.iodeptNm==null? "": patientInfo.iodeptNm,
  443. IO_DeptCd: patientInfo.iodeptCd==null? "": patientInfo.iodeptCd,
  444. IO_OPdept: patientInfo.ioopdeptNm==null? "": patientInfo.ioopdeptNm,
  445. IO_OPdr: patientInfo.ioopdrNm==null? "": patientInfo.ioopdrNm,
  446. IO_Dx: patientInfo.iodxNm==null? "": patientInfo.iodxNm,
  447. IO_bp: patientInfo.iobp==null? "": patientInfo.iobp,
  448. IO_dm: patientInfo.iodm==null? "": patientInfo.iodm,
  449. IO_heart: patientInfo.ioheart==null? "": patientInfo.ioheart,
  450. IO_kidney: patientInfo.iokidney==null? "": patientInfo.iokidney,
  451. IO_respiration: patientInfo.iorespiration==null? "": patientInfo.iorespiration,
  452. IO_hx: patientInfo.iohx==null? "": patientInfo.iohx,
  453. IO_allergy: patientInfo.ioallergy==null? "": patientInfo.ioallergy,
  454. IO_drug: patientInfo.iodrug==null? "": patientInfo.iodrug,
  455. IO_smoking: patientInfo.iosmoking==null? "": patientInfo.iosmoking,
  456. IO_idio: patientInfo.ioidio==null? "": patientInfo.ioidio,
  457. IO_nacrotics: patientInfo.ionacrotics==null? "": patientInfo.ionacrotics,
  458. IO_airway: patientInfo.ioairway==null? "": patientInfo.ioairway,
  459. IO_hemorrhage: patientInfo.iohemorrhage==null? "": patientInfo.iohemorrhage,
  460. IO_status_etc: patientInfo.iostatusEtc==null? "": patientInfo.iostatusEtc
  461. }
  462. if( unfinishedConsent ) {
  463. consentItem.guid = consentList[i].formGuid;
  464. }
  465. if(consentItem.ward.length > 0 && consentItem.roomNo.length > 0) {
  466. consentItem.IO_roomNo = consentItem.ward + '/' + consentItem.roomNo;
  467. } else {
  468. consentItem.IO_roomNo = "";
  469. }
  470. // 외래>소화기내과인 경우 시술의,수술의 설정. 2017/1/3 고객요구사항
  471. if(patientInfo.iovisitType == 'O' && patientInfo.iodeptCd == '2010300000') {
  472. consentItem.IO_OPdr = patientInfo.iomaindrNm;
  473. }
  474. consent.push(consentItem);
  475. }
  476. return consent;
  477. },
  478. // 앱으로 넘겨줄 동의서 리스트 파라메터 만들기 - 신규 기준
  479. makeNewConsentParam: function(patientInfo, consentList, userName) {
  480. // 유효성 검사 추가하기
  481. var consent = [];
  482. //ocrTagYn체크해서 넣어주기
  483. for( var i = 0; i < consentList.length; i++ ) {
  484. var ocrtag = "";
  485. //if(consentList[i].printOnly=="N"){ //전부 N일테니 조건따위 필요하지않아!!*/
  486. ocrtag = this.getOcrTag().text;
  487. //}
  488. var consentItem = {
  489. newConsent : true,
  490. hospitalCretno: patientInfo.iocretNo,
  491. ward: patientInfo.ioward==null? "":patientInfo.ioward,
  492. roomNo: patientInfo.ioroomNo==null? "": patientInfo.ioroomNo,
  493. IO_ocr_cd: ocrtag,
  494. outDate: patientInfo.iodschdd==null?"":patientInfo.iodschdd,
  495. mainDrId: patientInfo.iomaindrId==null?"":patientInfo.iomaindrId,
  496. guid: consentList[i].formGuid,
  497. IO_formname: consentList[i].formName,
  498. IO_INPUTNM: userName,
  499. formCd: consentList[i].formCd,
  500. formRid: consentList[i].formRid,
  501. IO_Pt_ID: patientInfo.ioptID==null? "": patientInfo.ioptID,
  502. IO_sex_age_y_m: patientInfo.iosexAgeYM==null? "": patientInfo.iosexAgeYM,
  503. IO_Pt_name: patientInfo.ioptName==null? "": patientInfo.ioptName,
  504. IO_JuminNo: patientInfo.iojuminNo==null? "": patientInfo.iojuminNo,
  505. IO_PT_birthday: patientInfo.iojuminNo==null? "": patientInfo.iojuminNo.split('-')[0],
  506. IO_roomNo: patientInfo.ioroomNo==null? "": patientInfo.ioroomNo,
  507. IO_ADdate: patientInfo.ioaddate==null? "": moment(patientInfo.ioaddate).format('YYYY/MM/DD'),
  508. IO_Dept: patientInfo.iodeptNm==null? "": patientInfo.iodeptNm,
  509. IO_DeptCd: patientInfo.iodeptCd==null? "": patientInfo.iodeptCd,
  510. IO_OPdept: patientInfo.ioopdeptNm==null? "": patientInfo.ioopdeptNm,
  511. IO_OPdr: patientInfo.ioopdrNm==null? "": patientInfo.ioopdrNm,
  512. IO_Dx: patientInfo.iodxNm==null? "": patientInfo.iodxNm,
  513. IO_bp: patientInfo.iobp==null? "": patientInfo.iobp,
  514. IO_dm: patientInfo.iodm==null? "": patientInfo.iodm,
  515. IO_heart: patientInfo.ioheart==null? "": patientInfo.ioheart,
  516. IO_kidney: patientInfo.iokidney==null? "": patientInfo.iokidney,
  517. IO_respiration: patientInfo.iorespiration==null? "": patientInfo.iorespiration,
  518. IO_hx: patientInfo.iohx==null? "": patientInfo.iohx,
  519. IO_allergy: patientInfo.ioallergy==null? "": patientInfo.ioallergy,
  520. IO_drug: patientInfo.iodrug==null? "": patientInfo.iodrug,
  521. IO_smoking: patientInfo.iosmoking==null? "": patientInfo.iosmoking,
  522. IO_idio: patientInfo.ioidio==null? "": patientInfo.ioidio,
  523. IO_nacrotics: patientInfo.ionacrotics==null? "": patientInfo.ionacrotics,
  524. IO_airway: patientInfo.ioairway==null? "": patientInfo.ioairway,
  525. IO_hemorrhage: patientInfo.iohemorrhage==null? "": patientInfo.iohemorrhage,
  526. IO_status_etc: patientInfo.iostatusEtc==null? "": patientInfo.iostatusEtc
  527. }
  528. if(consentItem.ward.length > 0 && consentItem.roomNo.length > 0) {
  529. consentItem.IO_roomNo = consentItem.ward + '/' + consentItem.roomNo;
  530. } else {
  531. consentItem.IO_roomNo = "";
  532. }
  533. // 외래>소화기내과인 경우 시술의,수술의 설정. 2017/1/3 고객요구사항
  534. if(patientInfo.iovisitType == 'O' && patientInfo.iodeptCd == '2010300000') {
  535. consentItem.IO_OPdr = patientInfo.iomaindrNm;
  536. }
  537. consent.push(consentItem);
  538. }
  539. return consent;
  540. },
  541. // 앱으로 넘겨줄 global 파라메터 만들기
  542. makeGlobalParam: function(patientInfo, signDoctorId) {
  543. // 유효성 검사 추가하기
  544. if(patientInfo == undefined) return;
  545. // 현재 일시 계산
  546. var currentTime = new Date();
  547. var timeText = dateTimeFormat(currentTime);
  548. var param = {userid : signDoctorId};
  549. var result = this.getSignImage(param);
  550. var signImage = '';
  551. if(result != undefined) {
  552. if(result.signImage != null && result.signImage != '') {
  553. signImage = result.signImage;
  554. }
  555. }
  556. var global = {
  557. IO_device: "M",
  558. visitType: patientInfo.iovisitType,
  559. IO_signdate: timeText,
  560. IO_signtime: timeText,
  561. IO_printtime: timeText,
  562. IO_maindr: patientInfo.iomaindrNm==null? "": patientInfo.iomaindrNm,
  563. IO_SIGNIMG: signImage
  564. }
  565. // 응급일 경우 ioerdrNm에 실제 주치의가 들어오기때문에 이걸로 변경해줌.
  566. if( patientInfo.ioerdrNm != null) {
  567. global.IO_maindr = patientInfo.ioerdrNm;
  568. }
  569. return global;
  570. },
  571. // 의사 서명 이미지 정보 조회
  572. getSignImage : function(request){
  573. var signImage;
  574. $.ajax ({
  575. url : $hospitalServiceBaseUrl + '/getSignImage.json',
  576. type : 'POST',
  577. dataType: "json",
  578. contentType: "application/json",
  579. async: false,
  580. data: JSON.stringify(request),
  581. success: function(response){
  582. signImage = response.result;
  583. }
  584. });
  585. return signImage;
  586. }
  587. };
  588. // 환자리스트 URL 리턴
  589. // 입원: I, 외래: O, 응급: E, 수술: OP, 검색: SR
  590. function getPatientListUrl(type) {
  591. switch (type) {
  592. case 'I' :
  593. return $serviceBaseUrl + '/in/getInPatList.json';
  594. case 'O' :
  595. return $serviceBaseUrl + '/out/getOutPatList.json';
  596. case 'E' :
  597. return $serviceBaseUrl + '/er/getErPatList.json';
  598. case 'OP' :
  599. return $serviceBaseUrl + '/op/getOpPatList.json';
  600. case 'SR' :
  601. return $serviceBaseUrl + '/search/getSrPatList.json';
  602. default:
  603. return;
  604. }
  605. }
  606. function dateTimeFormat(date) {
  607. try{
  608. var yyyy = date.getFullYear().toString(),
  609. mm = (date.getMonth()+1).toString(),
  610. dd = date.getDate().toString(),
  611. hh = date.getHours().toString(),
  612. mi = date.getMinutes().toString(),
  613. ss = date.getSeconds().toString(),
  614. text = yyyy + "-" + (mm[1]?mm:"0"+mm[0]) + "-" + (dd[1]?dd:"0"+dd[0]) + " "
  615. + (hh[1]?hh:"0"+hh[0]) + ":" + (mi[1]?mi:"0"+mi[0]) + ":" + (ss[1]?ss:"0"+ss[0]) ;
  616. return text;
  617. } catch(e) {
  618. self.log(e, "mcare_util_simpleDateFormat" );
  619. }
  620. }
  621. };
  622. //환자 나이정보 리턴
  623. function editAgeToIdNum(idNum){
  624. var sex = '';
  625. var ageYm = '';
  626. var age = '';
  627. //성별과 나이 분리
  628. if(idNum.indexOf('/')>0){
  629. sex = idNum.split('/')[0];
  630. ageYm = idNum.split('/')[1];
  631. }else{
  632. ageYm = idNum;
  633. };
  634. //나이 가공
  635. if(ageYm.indexOf('y')>0){
  636. age = ageYm.split('y')[0];
  637. }else if(ageYm.indexOf('m')>0||ageYm.indexOf('d')>0){
  638. age = 0;
  639. }else{
  640. age = ageYm;
  641. };
  642. return sex + '/' + age;
  643. };