consent.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715
  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. getPatientInfo(e.currentTarget.attributes.seq.value);
  201. });
  202. }
  203. };
  204. this.consent = {
  205. //동의서조회
  206. getConsentList : function(request){
  207. var consentList = [];
  208. $.ajax ({
  209. url : $consentServiceBaseUrl + '/getConsentList.json',
  210. type : 'POST',
  211. dataType: "json",
  212. contentType: "application/json",
  213. async: false,
  214. data: JSON.stringify(request),
  215. success: function(response){
  216. consentList = response.result;
  217. }
  218. });
  219. return consentList;
  220. },
  221. //동의서 검색
  222. getConsentBySearch: function(request){
  223. var consentList = [];
  224. $.ajax ({
  225. url : $consentServiceBaseUrl + '/getConsentBySearch.json',
  226. type : 'POST',
  227. dataType: "json",
  228. contentType: "application/json",
  229. async: false,
  230. data: JSON.stringify(request),
  231. success: function(response){
  232. consentList = response.result;
  233. }
  234. });
  235. return consentList;
  236. },
  237. //동의서 set조회
  238. getConsentSetList: function(request){
  239. var consentList = [];
  240. $.ajax ({
  241. url : $consentServiceBaseUrl + '/set/getConsentSetList.json',
  242. type : 'POST',
  243. dataType: "json",
  244. contentType: "application/json",
  245. async: false,
  246. data: JSON.stringify(request),
  247. success: function(response){
  248. consentList = response.result;
  249. }
  250. });
  251. return consentList;
  252. },
  253. //동의서 즐겨찾기 추가
  254. setUserFormSetList: function(request){
  255. var result = {};
  256. $.ajax ({
  257. url : $consentServiceBaseUrl + '/set/setUserFormSetList.json',
  258. type : 'POST',
  259. dataType: "json",
  260. contentType: "application/json",
  261. async: false,
  262. data: JSON.stringify(request),
  263. success: function(response){
  264. result = response.result;
  265. }
  266. });
  267. return result;
  268. },
  269. //동의서 즐겨찾기 삭제
  270. delUserFormSetList: function(request){
  271. var result = {};
  272. $.ajax ({
  273. url : $consentServiceBaseUrl + '/set/delUserFormSetList.json',
  274. type : 'POST',
  275. dataType: "json",
  276. contentType: "application/json",
  277. async: false,
  278. data: JSON.stringify(request),
  279. success: function(response){
  280. result = response.result;
  281. }
  282. });
  283. return result;
  284. },
  285. //동의서 삭제
  286. delConsent: function(request){
  287. var result = {};
  288. $.ajax ({
  289. url : $consentServiceBaseUrl+'/save/saveDelete.json',
  290. type : 'POST',
  291. contentType: "application/json",
  292. async: false,
  293. data: JSON.stringify(request),
  294. success: function(response){
  295. result = response.result;
  296. }
  297. });
  298. return result;
  299. },
  300. //ocr Tag 할당
  301. getOcrTag: function(){
  302. var result = '';
  303. $.ajax ({
  304. url : $consentServiceBaseUrl + '/getOcrTag.json',
  305. type : 'POST',
  306. dataType: "json",
  307. contentType: "application/json",
  308. data: JSON.stringify({}),
  309. async: false,
  310. success: function(response){
  311. result = response.result;
  312. }
  313. });
  314. return result;
  315. },
  316. //카테고리리스트 조회
  317. getCategoryForDropdown: function(request){
  318. var categoryList = [];
  319. $.ajax ({
  320. url : $consentServiceBaseUrl + '/getCategoryForDropdown.json',
  321. type : 'POST',
  322. dataType: "json",
  323. contentType: "application/json",
  324. async: false,
  325. data: JSON.stringify(request),
  326. success: function(response){
  327. categoryList = response.result;
  328. }
  329. });
  330. return categoryList;
  331. },
  332. //주치의별 동의서 검색
  333. getUnfinishedListPerDoctor: function(request){
  334. var consentList = [];
  335. $.ajax ({
  336. url : $consentServiceBaseUrl + '/getUnfinishedListPerDoctor.json',
  337. type : 'POST',
  338. dataType: "json",
  339. contentType: "application/json",
  340. async: false,
  341. data: JSON.stringify(request),
  342. success: function(response){
  343. consentList = response.result;
  344. }
  345. });
  346. return consentList;
  347. },
  348. // 동의서 이미지 정보 조회
  349. getConsentImage: function(request){
  350. var consentImageList = [];
  351. $.ajax ({
  352. url : $consentServiceBaseUrl + '/getConsentImage.json',
  353. type : 'POST',
  354. dataType: "json",
  355. contentType: "application/json",
  356. async: false,
  357. data: JSON.stringify(request),
  358. success: function(response){
  359. consentImageList = response.result;
  360. }
  361. });
  362. return consentImageList;
  363. },
  364. // 동의서 상태 체크
  365. checkConsentState: function(request){
  366. var state;
  367. $.ajax ({
  368. url : $consentServiceBaseUrl + '/checkConsentState.json',
  369. type : 'POST',
  370. dataType: "json",
  371. contentType: "application/json",
  372. async: false,
  373. data: JSON.stringify(request),
  374. success: function(response){
  375. state = response.result;
  376. }
  377. });
  378. return state;
  379. },
  380. makeConsentStateParam: function() {
  381. // 체크된 박스들
  382. var checkedStatus = $('.consentSearchBox input:checked[id!="chkboxConsentSign"]');
  383. // 체크된게 없으면 일단 이렇게 처리
  384. if( checkedStatus.length == 0 ) {
  385. self.alert('동의서 상태 조건을 선택하세요!');
  386. return;
  387. // 더이상 동의서 조회가 진행되지 않도록 하기
  388. }
  389. var consentStatus = '';
  390. for(var i = 0; i < checkedStatus.length; i++) {
  391. // 전체가 체크된 경우 뒤도 돌아보지않고 ALL만 리턴하도록
  392. if( checkedStatus[i].value == 'ALL') {
  393. consentStatus = checkedStatus[i].value;
  394. return consentStatus;
  395. } else {
  396. consentStatus = consentStatus + checkedStatus[i].value;
  397. }
  398. // 콤마 구분자 추가
  399. if(i != checkedStatus.length - 1) {
  400. consentStatus = consentStatus + ',';
  401. }
  402. }
  403. return consentStatus;
  404. },
  405. // 앱으로 넘겨줄 동의서 리스트 파라메터 만들기 - 작성중 기준
  406. makeConsentParam: function(patientInfo, consentList, userName) {
  407. // 유효성 검사 추가하기
  408. var consent = [];
  409. for( var i = 0; i < consentList.length; i++ ) {
  410. var unfinishedConsent = false;
  411. if( consentList[i].consentState == 'UNFINISHED' ) {
  412. unfinishedConsent = true;
  413. }
  414. var consentItem = {
  415. newConsent : unfinishedConsent? true: false,
  416. hospitalCretno: patientInfo.iocretNo,
  417. ward: patientInfo.ioward==null? "":patientInfo.ioward,
  418. roomNo: patientInfo.ioroomNo==null? "": patientInfo.ioroomNo,
  419. orderNo: consentList[i].orderNo,
  420. orderCd: consentList[i].orderCd==null?"":consentList[i].orderCd,
  421. IO_ocr_cd: consentList[i].ocrNumber==null?"":consentList[i].ocrNumber,
  422. consentCretno: consentList[i].cretno,
  423. outDate: patientInfo.iodschdd==null?"":patientInfo.iodschdd,
  424. mainDrId: patientInfo.iomaindrId==null?"":patientInfo.iomaindrId,
  425. consentState: consentList[i].consentState,
  426. rid: consentList[i].consentMstRid,
  427. IO_formname: consentList[i].consentName,
  428. IO_INPUTNM: userName,
  429. formCd: consentList[i].formCd,
  430. formRid: consentList[i].formRid,
  431. IO_Pt_ID: patientInfo.ioptID==null? "": patientInfo.ioptID,
  432. IO_sex_age_y_m: patientInfo.iosexAgeYM==null? "": patientInfo.iosexAgeYM,
  433. IO_Pt_name: patientInfo.ioptName==null? "": patientInfo.ioptName,
  434. IO_JuminNo: patientInfo.iojuminNo==null? "": patientInfo.iojuminNo,
  435. IO_PT_birthday: patientInfo.iojuminNo==null? "": patientInfo.iojuminNo.split('-')[0],
  436. IO_ADdate: patientInfo.ioaddate==null? "": moment(patientInfo.ioaddate).format('YYYY/MM/DD'),
  437. IO_Dept: patientInfo.iodeptNm==null? "": patientInfo.iodeptNm,
  438. IO_DeptCd: patientInfo.iodeptCd==null? "": patientInfo.iodeptCd,
  439. IO_OPdept: patientInfo.ioopdeptNm==null? "": patientInfo.ioopdeptNm,
  440. IO_OPdr: patientInfo.ioopdrNm==null? "": patientInfo.ioopdrNm,
  441. IO_Dx: patientInfo.iodxNm==null? "": patientInfo.iodxNm,
  442. IO_bp: patientInfo.iobp==null? "": patientInfo.iobp,
  443. IO_dm: patientInfo.iodm==null? "": patientInfo.iodm,
  444. IO_heart: patientInfo.ioheart==null? "": patientInfo.ioheart,
  445. IO_kidney: patientInfo.iokidney==null? "": patientInfo.iokidney,
  446. IO_respiration: patientInfo.iorespiration==null? "": patientInfo.iorespiration,
  447. IO_hx: patientInfo.iohx==null? "": patientInfo.iohx,
  448. IO_allergy: patientInfo.ioallergy==null? "": patientInfo.ioallergy,
  449. IO_drug: patientInfo.iodrug==null? "": patientInfo.iodrug,
  450. IO_smoking: patientInfo.iosmoking==null? "": patientInfo.iosmoking,
  451. IO_idio: patientInfo.ioidio==null? "": patientInfo.ioidio,
  452. IO_nacrotics: patientInfo.ionacrotics==null? "": patientInfo.ionacrotics,
  453. IO_airway: patientInfo.ioairway==null? "": patientInfo.ioairway,
  454. IO_hemorrhage: patientInfo.iohemorrhage==null? "": patientInfo.iohemorrhage,
  455. IO_status_etc: patientInfo.iostatusEtc==null? "": patientInfo.iostatusEtc
  456. }
  457. if( unfinishedConsent ) {
  458. consentItem.guid = consentList[i].formGuid;
  459. }
  460. if(consentItem.ward.length > 0 && consentItem.roomNo.length > 0) {
  461. consentItem.IO_roomNo = consentItem.ward + '/' + consentItem.roomNo;
  462. } else {
  463. consentItem.IO_roomNo = "";
  464. }
  465. // 외래>소화기내과인 경우 시술의,수술의 설정. 2017/1/3 고객요구사항
  466. if(patientInfo.iovisitType == 'O' && patientInfo.iodeptCd == '2010300000') {
  467. consentItem.IO_OPdr = patientInfo.iomaindrNm;
  468. }
  469. consent.push(consentItem);
  470. }
  471. return consent;
  472. },
  473. // 앱으로 넘겨줄 동의서 리스트 파라메터 만들기 - 신규 기준
  474. makeNewConsentParam: function(patientInfo, consentList, userName) {
  475. // 유효성 검사 추가하기
  476. var consent = [];
  477. //ocrTagYn체크해서 넣어주기
  478. for( var i = 0; i < consentList.length; i++ ) {
  479. var ocrtag = "";
  480. //if(consentList[i].printOnly=="N"){ //전부 N일테니 조건따위 필요하지않아!!*/
  481. ocrtag = this.getOcrTag().text;
  482. //}
  483. var consentItem = {
  484. newConsent : true,
  485. hospitalCretno: patientInfo.iocretNo,
  486. ward: patientInfo.ioward==null? "":patientInfo.ioward,
  487. roomNo: patientInfo.ioroomNo==null? "": patientInfo.ioroomNo,
  488. IO_ocr_cd: ocrtag,
  489. outDate: patientInfo.iodschdd==null?"":patientInfo.iodschdd,
  490. mainDrId: patientInfo.iomaindrId==null?"":patientInfo.iomaindrId,
  491. guid: consentList[i].formGuid,
  492. IO_formname: consentList[i].formName,
  493. IO_INPUTNM: userName,
  494. formCd: consentList[i].formCd,
  495. formRid: consentList[i].formRid,
  496. IO_Pt_ID: patientInfo.ioptID==null? "": patientInfo.ioptID,
  497. IO_sex_age_y_m: patientInfo.iosexAgeYM==null? "": patientInfo.iosexAgeYM,
  498. IO_Pt_name: patientInfo.ioptName==null? "": patientInfo.ioptName,
  499. IO_JuminNo: patientInfo.iojuminNo==null? "": patientInfo.iojuminNo,
  500. IO_PT_birthday: patientInfo.iojuminNo==null? "": patientInfo.iojuminNo.split('-')[0],
  501. IO_roomNo: patientInfo.ioroomNo==null? "": patientInfo.ioroomNo,
  502. IO_ADdate: patientInfo.ioaddate==null? "": moment(patientInfo.ioaddate).format('YYYY/MM/DD'),
  503. IO_Dept: patientInfo.iodeptNm==null? "": patientInfo.iodeptNm,
  504. IO_DeptCd: patientInfo.iodeptCd==null? "": patientInfo.iodeptCd,
  505. IO_OPdept: patientInfo.ioopdeptNm==null? "": patientInfo.ioopdeptNm,
  506. IO_OPdr: patientInfo.ioopdrNm==null? "": patientInfo.ioopdrNm,
  507. IO_Dx: patientInfo.iodxNm==null? "": patientInfo.iodxNm,
  508. IO_bp: patientInfo.iobp==null? "": patientInfo.iobp,
  509. IO_dm: patientInfo.iodm==null? "": patientInfo.iodm,
  510. IO_heart: patientInfo.ioheart==null? "": patientInfo.ioheart,
  511. IO_kidney: patientInfo.iokidney==null? "": patientInfo.iokidney,
  512. IO_respiration: patientInfo.iorespiration==null? "": patientInfo.iorespiration,
  513. IO_hx: patientInfo.iohx==null? "": patientInfo.iohx,
  514. IO_allergy: patientInfo.ioallergy==null? "": patientInfo.ioallergy,
  515. IO_drug: patientInfo.iodrug==null? "": patientInfo.iodrug,
  516. IO_smoking: patientInfo.iosmoking==null? "": patientInfo.iosmoking,
  517. IO_idio: patientInfo.ioidio==null? "": patientInfo.ioidio,
  518. IO_nacrotics: patientInfo.ionacrotics==null? "": patientInfo.ionacrotics,
  519. IO_airway: patientInfo.ioairway==null? "": patientInfo.ioairway,
  520. IO_hemorrhage: patientInfo.iohemorrhage==null? "": patientInfo.iohemorrhage,
  521. IO_status_etc: patientInfo.iostatusEtc==null? "": patientInfo.iostatusEtc
  522. }
  523. if(consentItem.ward.length > 0 && consentItem.roomNo.length > 0) {
  524. consentItem.IO_roomNo = consentItem.ward + '/' + consentItem.roomNo;
  525. } else {
  526. consentItem.IO_roomNo = "";
  527. }
  528. // 외래>소화기내과인 경우 시술의,수술의 설정. 2017/1/3 고객요구사항
  529. if(patientInfo.iovisitType == 'O' && patientInfo.iodeptCd == '2010300000') {
  530. consentItem.IO_OPdr = patientInfo.iomaindrNm;
  531. }
  532. consent.push(consentItem);
  533. }
  534. return consent;
  535. },
  536. // 앱으로 넘겨줄 global 파라메터 만들기
  537. makeGlobalParam: function(patientInfo, signDoctorId) {
  538. // 유효성 검사 추가하기
  539. if(patientInfo == undefined) return;
  540. // 현재 일시 계산
  541. var currentTime = new Date();
  542. var timeText = dateTimeFormat(currentTime);
  543. var param = {userid : signDoctorId};
  544. var result = this.getSignImage(param);
  545. var signImage = '';
  546. if(result != undefined) {
  547. if(result.signImage != null && result.signImage != '') {
  548. signImage = result.signImage;
  549. }
  550. }
  551. var global = {
  552. IO_device: "M",
  553. visitType: patientInfo.iovisitType,
  554. IO_signdate: timeText,
  555. IO_signtime: timeText,
  556. IO_printtime: timeText,
  557. IO_maindr: patientInfo.iomaindrNm==null? "": patientInfo.iomaindrNm,
  558. IO_SIGNIMG: signImage
  559. }
  560. // 응급일 경우 ioerdrNm에 실제 주치의가 들어오기때문에 이걸로 변경해줌.
  561. if( patientInfo.ioerdrNm != null) {
  562. global.IO_maindr = patientInfo.ioerdrNm;
  563. }
  564. return global;
  565. },
  566. // 의사 서명 이미지 정보 조회
  567. getSignImage : function(request){
  568. var signImage;
  569. $.ajax ({
  570. url : $hospitalServiceBaseUrl + '/getSignImage.json',
  571. type : 'POST',
  572. dataType: "json",
  573. contentType: "application/json",
  574. async: false,
  575. data: JSON.stringify(request),
  576. success: function(response){
  577. signImage = response.result;
  578. }
  579. });
  580. return signImage;
  581. }
  582. };
  583. // 환자리스트 URL 리턴
  584. // 입원: I, 외래: O, 응급: E, 수술: OP, 검색: SR
  585. function getPatientListUrl(type) {
  586. switch (type) {
  587. case 'I' :
  588. return $serviceBaseUrl + '/in/getInPatList.json';
  589. case 'O' :
  590. return $serviceBaseUrl + '/out/getOutPatList.json';
  591. case 'E' :
  592. return $serviceBaseUrl + '/er/getErPatList.json';
  593. case 'OP' :
  594. return $serviceBaseUrl + '/op/getOpPatList.json';
  595. case 'SR' :
  596. return $serviceBaseUrl + '/search/getSrPatList.json';
  597. default:
  598. return;
  599. }
  600. }
  601. function dateTimeFormat(date) {
  602. try{
  603. var yyyy = date.getFullYear().toString(),
  604. mm = (date.getMonth()+1).toString(),
  605. dd = date.getDate().toString(),
  606. hh = date.getHours().toString(),
  607. mi = date.getMinutes().toString(),
  608. ss = date.getSeconds().toString(),
  609. text = yyyy + "-" + (mm[1]?mm:"0"+mm[0]) + "-" + (dd[1]?dd:"0"+dd[0]) + " "
  610. + (hh[1]?hh:"0"+hh[0]) + ":" + (mi[1]?mi:"0"+mi[0]) + ":" + (ss[1]?ss:"0"+ss[0]) ;
  611. return text;
  612. } catch(e) {
  613. self.log(e, "mcare_util_simpleDateFormat" );
  614. }
  615. }
  616. };
  617. //환자 나이정보 리턴
  618. function editAgeToIdNum(idNum){
  619. var sex = '';
  620. var ageYm = '';
  621. var age = '';
  622. //성별과 나이 분리
  623. if(idNum.indexOf('/')>0){
  624. sex = idNum.split('/')[0];
  625. ageYm = idNum.split('/')[1];
  626. }else{
  627. ageYm = idNum;
  628. };
  629. //나이 가공
  630. if(ageYm.indexOf('y')>0){
  631. age = ageYm.split('y')[0];
  632. }else if(ageYm.indexOf('m')>0||ageYm.indexOf('d')>0){
  633. age = 0;
  634. }else{
  635. age = ageYm;
  636. };
  637. return sex + '/' + age;
  638. };