clinic.js 56 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383
  1. /**
  2. * mplus_mobile_clinic
  3. */
  4. var mplus_mobile_clinic = function(){
  5. //상속
  6. mplus_common.call(this);
  7. var mplusPatient = new mplus_mobile_patient();
  8. var mplusNursing = new mplus_nursing();
  9. //super
  10. var self = this;
  11. //변수
  12. var div = $('<div></div>');
  13. var tr = $('<tr></tr>');
  14. var th = $('<th></th>');
  15. var td = $('<td></td>');
  16. var table = $('<table></table>');
  17. var li = $('<li></li>');
  18. var a = $('<a></a>');
  19. var span = $('<span></span>');
  20. var button = $('<button></button>');
  21. var deptList = new Array();
  22. var wardList = new Array();
  23. var requestToServer = true;
  24. var searchedPatientList = [];
  25. self.hospital.getDeptList('D', function(result) {deptList = result});
  26. self.hospital.getDeptList('W', function(result) {wardList = result});
  27. /**
  28. * 초기화
  29. */
  30. this.init = function(){ //여기서 모든화면 콤보박스데이터를 집어넣자!!! 그래야지 화면이동할때 속도가 오래걸리지않음!!!
  31. inInitDataSetting();
  32. outInitDataSetting();
  33. searchInitDataSetting();
  34. inAddEvent();
  35. inInit();
  36. inSearchPatientList();
  37. outAddEvent();
  38. emerAddEvent();
  39. searchAddEvent();
  40. $('#clinicTab a[data-toggle="tab"]').unbind();
  41. $('#clinicTab a[data-toggle="tab"]').on('click', function (e) {
  42. /*if($('#overlay').css('bottom')=='-49px'){*/
  43. $('#openToggle').css({bottom:10}); //에니메이션을 넣으니 화면이 이동된후에 에니메이션 동작이 되어서 css만변경
  44. $('#overlay').stop().animate({bottom:-290},500);
  45. $('#nursingPopup').stop().animate({bottom:-max},500);
  46. $('#newPopupFooter').css('display', 'none');
  47. $('#patientList').css('margin-bottom', '0');
  48. $('#searchPatientList').css('margin-bottom', '0');
  49. $('#openToggle').removeClass('on');
  50. $('#openToggle').find('.fa').removeClass('fa-chevron-down');
  51. $('#openToggle').find('.fa').addClass('fa-chevron-up');
  52. /*}*/
  53. });
  54. $('#clinicTab a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
  55. $('.tab-pane').scrollTop(0);
  56. patientInfoInit();
  57. if($("ul#clinicTab.nav-tabs li.active a").attr('aria-controls')=='tabIn'){
  58. inInit();
  59. inSearchPatientList();
  60. }else if($("ul#clinicTab.nav-tabs li.active a").attr('aria-controls')=='tabOut'){
  61. outInit();
  62. outSearchPatientList();
  63. }else if($("ul#clinicTab.nav-tabs li.active a").attr('aria-controls')=='tabEmer'){
  64. emerInit();
  65. emerInitDataSetting();
  66. emerSearchPatientList();
  67. }else if($("ul#clinicTab.nav-tabs li.active a").attr('aria-controls')=='tabSearch'){
  68. searchInit();
  69. }else{
  70. /*slef.aler('에러메시지?');*/
  71. }
  72. });
  73. localStorage.setItem('treatType', treatType);
  74. };
  75. var patientInfoInit = function(){
  76. $('#divId').text('');
  77. $('#divDiagName').text('');
  78. $('#divOpName').text('');
  79. $('#divOpDate').text('');
  80. $('#divTreatDate').text('');
  81. $('#divDoctorName').text('');
  82. $('#tdNameNum').text('');
  83. //로컬스토리지 정보는 없애야할지 테스트헤보고 넣기!
  84. };
  85. /*----------------------- 입원 resource ----------------------*/
  86. var $inTotalNumSpan = $('#inTotalNumSpan'),
  87. $inRoundBtn = $('#inRoundBtn'),
  88. $inInsertBtn = $('#inInsertBtn'),
  89. $rountInsertBtn = $('#rountInsertBtn'),
  90. $inSearchBtn = $('#inSearchBtn'),
  91. $inUlPatientList = $('#inUlPatientList'),
  92. $inSltDept = $('#inSltDept'),
  93. $inChkTotalView = $('#inChkTotalView'),
  94. $inBtnSortOpen = $('#inBtnSortOpen'),
  95. $inPidSearch = $('#inPidSearch');
  96. var inRecentSearchType, //최근 검색했던 전체, 본인 여부(정렬시 필요)
  97. inPatientList = [];
  98. var inInit = function(){
  99. treatType = 'I';
  100. $inPidSearch.val('');
  101. requestToServer = true;
  102. searchedPatientList = [];
  103. // TODO: 전문의 & 강사일 때만 회진 기능 이용할 수 있도록 구현하기
  104. var jobKindCd = JSON.parse(localStorage.user).jobKindCd;
  105. $('#inChkTotalView').prop('checked', true);
  106. if(jobKindCd=='S' || jobKindCd=='G'){ //jobKindCd: S(전문의), G(강사)
  107. $inRoundBtn.css('display', 'initial');
  108. $('#roundBtnWrap').css('display', 'initial');
  109. if(jobKindCd=='S'){
  110. $('#inChkTotalView').prop('checked', false);
  111. }
  112. }else{
  113. $inRoundBtn.css('display', 'none');
  114. $('#roundBtnWrap').css('display', 'none');
  115. }
  116. var sortList = [{key: 'wardNm', type: 'string', value: '병동순'},
  117. {key: 'age', type: 'number', value: '연령순'},
  118. {key: 'patientNm', type: 'string', value: '이름순'}];
  119. inRecentSearchType = '';
  120. inPatientList = [];
  121. $inSltDept.val(localStorage.selectDeptCode);
  122. $inTotalNumSpan.text(0);
  123. $inUlPatientList.empty();
  124. sortInit(sortList);
  125. $('#sortConfirmBtn').unbind();
  126. $('#sortConfirmBtn').on("click", function(e){
  127. $('#sortModal').modal('hide');
  128. inSortPatientList($('#sltSort').val(), $('#sltSort option:selected').attr('type'), $('input[type="radio"][name="sortRadio"]:checked').val());
  129. $('.header span').css('display', 'none');
  130. $('.header.sort_'+$('#sltSort').val()+' .sort-icon-'+$('input[type="radio"][name="sortRadio"]:checked').val()).css('display', 'inline-block');
  131. });
  132. // 태블릿일 때는 회진 체크박스를 맨 앞으로 배치한다
  133. if( self.isTablet() ) {
  134. $('#inPatientHeaderTablet').css('display', 'block');
  135. $('#inPatientHeaderPhone').css('display', 'none');
  136. }else{
  137. $('#inPatientHeaderTablet').css('display', 'none');
  138. $('#inPatientHeaderPhone').css('display', 'block');
  139. }
  140. };
  141. /**
  142. * 이벤트등록
  143. */
  144. var inAddEvent = function(){
  145. $inRoundBtn.on('click', function(e){
  146. if( self.isTablet() ) {
  147. $('#roundAllChkBoxWrapTablet').css('display', 'block');
  148. }else{
  149. $('#roundAllChkBoxWrapPhone').css('display', 'block');
  150. $('.in-date-wrap').removeClass('pdr0').addClass('pd0');
  151. $('.bed-wrap').removeClass('col-xs-5').addClass('col-xs-4');
  152. $('.patientNm-wrap').removeClass('col-xs-4').addClass('col-xs-5');
  153. $('.doctor-wrap').removeClass('col-xs-4').removeClass('pd0').addClass('col-xs-3').addClass('pdr0');
  154. }
  155. $('.chk-box-wrap').css('display', 'block');
  156. $('.empty-wrap').css('display', 'none');
  157. $inRoundBtn.css('display', 'none');
  158. $inInsertBtn.css('display', 'initial');
  159. $('#roundAllChkBox').prop('checked', true).trigger('change');
  160. });
  161. $inInsertBtn.on('click', function(e){
  162. if($('[id*=check_]:checked').length==0){
  163. self.alert('환자를 선택해주세요.');
  164. return;
  165. };
  166. $('#dateRound')[0].value = self.util.toDate(new Date());
  167. $('#timeRound')[0].value = '--:--';
  168. $('#roundMemo').text('환자 및 보호자분은 질문사항을 미리 준비해 주시고 병실에서 대기하여 주시기 바랍니다.');
  169. $('#modalRoundInsert').modal('show');
  170. });
  171. $rountInsertBtn.on('click', function(e){
  172. //회진시간입력 로직 호출
  173. var currentTime = new Date();
  174. currentTime.setSeconds(00);
  175. if($('#dateRound').val()=='' || $('#timeRound').val()==''){
  176. self.alert('회진시간을 입력해주세요.');
  177. return;
  178. }
  179. var roundTime = new Date($('#dateRound').val() +' '+ $('#timeRound').val());
  180. if(currentTime.getTime() - roundTime.getTime() > 0){
  181. self.alert('회진시간은 현재시간 이후로 설정해주세요.');
  182. return;
  183. }
  184. var patientInfo = JSON.parse(localStorage.user);
  185. var selectPatientList = [];
  186. var executeRoundFailList = [];
  187. var param = {'round': []};
  188. for(var i=0; i<$('[id*=check_]:checked').length; i++){
  189. var commentMsg = '';
  190. if(patientInfo.hospitalCd=='10'){
  191. commentMsg = '<강남세브란스병원 회진안내>\n';
  192. }else{
  193. commentMsg = '<세브란스병원 회진안내>\n';
  194. }
  195. commentMsg = commentMsg
  196. + moment(currentTime).format('MM월 DD일') +' '+ $('#inSltDept option:selected').text() + ' ' + patientInfo.userNm + '선생님 '
  197. + self.util.restoreRoundTime($('#timeRound').val()) + '부터 회진 예정입니다. \n'
  198. + '<전달사항>\n'
  199. + $('#roundMemo').val().replace( /\r?\n/g, "\n" );
  200. var roundPatientInfo = {
  201. 'hospitalCd': localStorage.hospitalCd,
  202. //'patientId': $('[id*=check_]:checked')[i].value, // 20180622 shinsunwoo value 가 "ALL"로 나오는 오류로 수정
  203. 'patientId': inPatientList[$('[id*=check_]:checked')[i].id.split('_')[1]].patientId,
  204. 'inputDt': moment(currentTime).format('YYYYMMDD'),
  205. 'inputTm': moment(currentTime).format('HHmm00'),
  206. 'roundTreatMemo': commentMsg,
  207. 'roundTreatDt': moment($('#dateRound').val()).format('YYYYMMDD'),
  208. 'roundTreatTm': $('#timeRound').val().replace(':', '')+'00',
  209. 'departmentCd': inPatientList[$('[id*=check_]:checked')[i].id.split('_')[1]].departmentCd,
  210. 'userId': patientInfo.userId};
  211. selectPatientList.push(inPatientList[$('[id*=check_]:checked')[i].id.split('_')[1]]);
  212. param.round.push(roundPatientInfo);
  213. }
  214. //실패 케이스 처리
  215. var executeRoundTreatResult = self.treatment.executeRoundTreat(param);
  216. if( executeRoundTreatResult.result == undefined ){
  217. $('#modalRoundInsert').modal('hide');
  218. self.alert(executeRoundTreatResult.msg);
  219. return;
  220. }
  221. executeRoundTreatResult = executeRoundTreatResult.result;
  222. for(var j=0; j<executeRoundTreatResult.length; j++){
  223. if(executeRoundTreatResult[j].returnCd=='1'){
  224. for(var k=0; k<selectPatientList.length; k++){
  225. if(executeRoundTreatResult[j].patientId == selectPatientList[k].patientId){
  226. var failData = selectPatientList[k];
  227. executeRoundFailList.push({'patientId': failData.patientId, 'patientNm': failData.patientNm});
  228. break;
  229. }
  230. }
  231. }
  232. }
  233. if(executeRoundFailList.length>0){
  234. var alertMsg = '';
  235. $('#modalRoundInsert').modal('hide');
  236. $('[id*=check_]').prop('checked', false);
  237. for(var j=0; j<executeRoundFailList.length; j++){
  238. $('[id*=check_][value='+executeRoundFailList[j].patientId+']').prop('checked', true);
  239. alertMsg = alertMsg + executeRoundFailList[j].patientId + ' / ' + executeRoundFailList[j].patientNm + '<br/>';
  240. }
  241. alertMsg = alertMsg + '환자 회진정보 입력 실패하였습니다.';
  242. self.alert(alertMsg);
  243. }else{
  244. $inRoundBtn.css('display', 'initial');
  245. $inInsertBtn.css('display', 'none');
  246. $('#modalRoundInsert').modal('hide');
  247. self.alert('환자 회진정보가 입력되었습니다.');
  248. $('#roundAllChkBoxWrapPhone').css('display', 'none');
  249. $('#roundAllChkBoxWrapTablet').css('display', 'none');
  250. $('.chk-box-wrap').css('display', 'none');
  251. $('.empty-wrap').css('display', 'block');
  252. if(!self.isTablet()){
  253. $('.in-date-wrap').removeClass('pd0').addClass('pdr0');
  254. $('.bed-wrap').removeClass('col-xs-4').addClass('col-xs-5');
  255. $('.patientNm-wrap').removeClass('col-xs-5').addClass('col-xs-4');
  256. $('.doctor-wrap').removeClass('col-xs-3').removeClass('pdr0').addClass('col-xs-4').addClass('pd0');
  257. }
  258. }
  259. });
  260. $inSearchBtn.on('click', function(e){
  261. $('.header span').css('display', 'none');
  262. // 검색조건(진료과, 본인or전체) 변동사항이 없고, 환자번호 검색어가 입력된경우
  263. // 서버로 따로 요청하지 않고 이미 받은 데이터에서 환자번호 필터링만 한다.
  264. if( !requestToServer && $inPidSearch.val().length > 0) {
  265. inPatientList = searchedPatientList.filter(val => {return val.patientId.indexOf($inPidSearch.val()) >= 0;});
  266. inBindingPatientList(inRecentSearchType, inPatientList, null);
  267. } /*else if (!requestToServer && $inPidSearch.val().length == 0) {
  268. inPatientList = searchedPatientList;
  269. inBindingPatientList(inRecentSearchType, inPatientList, null);
  270. } */else {
  271. inSearchPatientList();
  272. }
  273. });
  274. $inBtnSortOpen.on("click", function(e){
  275. $('#sortModal').modal('show');
  276. });
  277. $inPidSearch.on('click', function(e){
  278. e.currentTarget.value = '';
  279. });
  280. $inSltDept.on('change', function(e){
  281. requestToServer = true;
  282. });
  283. $inChkTotalView.on('change', function(e){
  284. requestToServer = true;
  285. });
  286. };
  287. /**
  288. * 기초데이터 셋팅
  289. */
  290. var inInitDataSetting = function(){
  291. /* var sltList = deptList.concat(wardList); */
  292. var deptList = JSON.parse(localStorage.user).departmentList;
  293. var sltList = deptList;
  294. $inSltDept.empty();
  295. for(var i=0; i<sltList.length; i++){
  296. option = $('<option></option>').clone().attr('value', sltList[i].departmentCd)
  297. .attr('departmentTyp', sltList[i].departmentTyp)
  298. .text(sltList[i].departmentNm);
  299. $inSltDept.append(option);
  300. }
  301. };
  302. var inSearchPatientList = function(){
  303. inRecentSearchType = $inChkTotalView.prop('checked')? 'all': 'mine';
  304. $inUlPatientList.empty();
  305. inPatientList = [];
  306. patientInfoInit();
  307. //과별, 병동별 입원환자 조회
  308. if($inChkTotalView.prop('checked')){
  309. var type = $('#inSltDept option[value='+$('#inSltDept').val()+']').attr('departmentTyp');
  310. var param;
  311. if(type=='D'){
  312. param = {
  313. departmentCd: $inSltDept.val()
  314. };
  315. }else{
  316. param = {
  317. wardCd: $inSltDept.val()
  318. };
  319. }
  320. self.treatment.getInPatListPerDeptOrWard(param, 'all', 'in');
  321. /*bindingPatientList('all', patientList);*/
  322. //과,병동 & 의사별 입원환자 조회
  323. }else{
  324. var type = $('#inSltDept option[value='+$('#inSltDept').val()+']').attr('departmentTyp');
  325. var param;
  326. if(type=='D'){
  327. param = {
  328. departmentCd: $inSltDept.val(),
  329. doctorId: loginUserId
  330. };
  331. }else{
  332. param = {
  333. wardCd: $inSltDept.val(),
  334. doctorId: loginUserId
  335. };
  336. }
  337. self.treatment.getInPatListPerDDOrWD(param, 'mine');
  338. /*patientList = self.treatment.getInPatListPerDDOrWD(param);
  339. bindingPatientList('mine', patientList);*/
  340. }
  341. };
  342. var inSortPatientList = function(key, type, method){
  343. inPatientList = self.util.sortObj(inPatientList, key, type, method);
  344. inBindingPatientList(inRecentSearchType, inPatientList, null);
  345. };
  346. inBindingPatientList = function(type, bindPatientList, extraMsg){ //all: 전체, mine: 본인
  347. if( $inPidSearch.val().length > 0 ) {
  348. inPatientList = bindPatientList.filter(val => {return val.patientId.indexOf($inPidSearch.val()) >= 0;});
  349. } else {
  350. inPatientList = bindPatientList;
  351. }
  352. if( requestToServer ) {
  353. searchedPatientList = bindPatientList;
  354. requestToServer = false;
  355. }
  356. if(!self.isTablet()){
  357. $('.in-date-wrap').removeClass('pd0').addClass('pdr0');
  358. $('.bed-wrap').removeClass('col-xs-4').addClass('col-xs-5');
  359. $('.patientNm-wrap').removeClass('col-xs-5').addClass('col-xs-4');
  360. $('.doctor-wrap').removeClass('col-xs-3').removeClass('pdr0').addClass('col-xs-4').addClass('pd0');
  361. }
  362. $inUlPatientList.empty();
  363. $inTotalNumSpan.text(inPatientList.length);
  364. if(inPatientList.length==0){
  365. $inUlPatientList.append(li.clone().append(div.clone().addClass('text-center no-result').text('―')));
  366. }
  367. $inRoundBtn.css('display', 'initial');
  368. $inInsertBtn.css('display', 'none');
  369. $('#roundAllChkBoxWrapPhone').css('display', 'none');
  370. $('#roundAllChkBoxWrapTablet').css('display', 'none');
  371. for(var i=0; i<inPatientList.length; i++){
  372. var divPatientInfo = div.clone().addClass('list-row container');
  373. if( self.isTablet() ) {
  374. var div12Row1 = div.clone().addClass('col-xs-12 col-sm-12 pd0');
  375. var divNum = div.clone().addClass('col-xs-2 col-sm-2 sexage').append(
  376. span.clone().text( (inPatientList[i].gender=='F'? 'F':'M') + ' / '+ inPatientList[i].age )
  377. );
  378. var divDay = div.clone().addClass('day col-xs-2 col-sm-2 pdr0 bed-wrap ').text(inPatientList[i].wardNm + '/' + inPatientList[i].roomNm + '/' + inPatientList[i].bedNm);
  379. var divName = div.clone().addClass('name col-xs-2 col-sm-2 pd0 patientNm-wrap').text(inPatientList[i].patientNm + ' ' + inPatientList[i].patientId);
  380. var checkbox = $('<input type="checkbox" value="ALL" checked=""><label for=""></label>').attr('id', 'check_' + i).attr('for', 'check_' + i);
  381. var divRound = div.clone().addClass('num_b checkbox3 checkbox-sm checkbox-check checkbox-light col-xs-1 col-sm-1 pdr0 chk-box-wrap').append(checkbox);
  382. var divDoctor = div.clone().addClass('doctor col-xs-2 col-sm-2 pd0 doctor-wrap').text(inPatientList[i].departmentCd + ' / ' + inPatientList[i].doctorNm);
  383. var divDate = div.clone().addClass('date col-xs-3 col-sm-3 pdr0 in-date-wrap letter-control').text((inPatientList[i].inDt!=undefined&&inPatientList[i].inDt!=null&&inPatientList[i].inDt!=''? moment(inPatientList[i].inDt).format('YYYY-MM-DD'):'')
  384. + ' HOD '
  385. + inPatientList[i].inDay);
  386. var divFirstRow = div12Row1.clone().append(divRound).append(divDay).append(divDate).append(divName).append(divNum).append(divDoctor);
  387. divPatientInfo.append(divFirstRow);
  388. } else {
  389. var div12Row1 = div.clone().addClass('col-xs-12 col-sm-8 pd0');
  390. var div12Row2 = div.clone().addClass('col-xs-12 col-sm-4 pd0');
  391. var divNum = div.clone().addClass('col-xs-3 col-sm-2 sexage').append(
  392. span.clone().text( (inPatientList[i].gender=='F'? 'F':'M') + ' / '+ inPatientList[i].age )
  393. );
  394. var divDay = div.clone().addClass('day col-xs-5 col-sm-3 pdr0 bed-wrap').text(inPatientList[i].wardNm + '/' + inPatientList[i].roomNm + '/' + inPatientList[i].bedNm);
  395. var divName = div.clone().addClass('name col-xs-4 col-sm-5 pd0 patientNm-wrap').text(inPatientList[i].patientNm + ' ' + inPatientList[i].patientId);
  396. var divEmpty = div.clone().addClass('clearfix visible-xs-block').text(' ');
  397. var checkbox = $('<input type="checkbox" value="ALL" checked=""><label for=""></label>').attr('id', 'check_' + i).attr('for', 'check_' + i);
  398. var divRound = div.clone().addClass('num_b checkbox3 checkbox-sm checkbox-check checkbox-light col-xs-4 col-sm-2 pdr0 chk-box-wrap').append(checkbox);
  399. var divEmpty1 = div.clone().addClass('doctor col-xs-3 hidden-sm hidden-md hidden-lg empty-wrap').text('');
  400. var divDoctor = div.clone().addClass('doctor col-xs-4 col-sm-5 pd0 doctor-wrap').text(inPatientList[i].departmentCd + ' / ' + inPatientList[i].doctorNm);
  401. var divDate = div.clone().addClass('date col-xs-5 col-sm-5 pdr0 in-date-wrap letter-control').text((inPatientList[i].inDt!=undefined&&inPatientList[i].inDt!=null&&inPatientList[i].inDt!=''? moment(inPatientList[i].inDt).format('YYYY-MM-DD'):'')
  402. + ' HOD '
  403. + inPatientList[i].inDay);
  404. var divFirstRow = div12Row1.clone().append(divDay).append(divName).append(divNum);
  405. var divSecondRow = div12Row2.clone().append(divRound).append(divDate).append(divDoctor).append(divEmpty).append(divEmpty1);
  406. divPatientInfo.append(divFirstRow).append(divSecondRow);
  407. $('#inDateWrap').before($('#roundAllChkBoxWrapPhone'));
  408. }
  409. $inUlPatientList.append(li.clone().append(a.clone().addClass('list-group-item').attr('patientNo', i).attr('patientId', inPatientList[i].patientId).append(divPatientInfo)));
  410. $('.chk-box-wrap').css('display', 'none');
  411. $('#roundAllChkBox').unbind();
  412. $('#roundAllChkBox').on('change', function(e){
  413. $('[id*=check_]').prop('checked', e.currentTarget.checked);
  414. });
  415. };
  416. $('#inUlPatientList .list-group-item').on('click',function(){
  417. if(event.toElement.id.indexOf('check')>-1){
  418. return;
  419. }
  420. $('.list-group-item').removeClass('active');
  421. $(this).addClass('active');
  422. var patientNo = event.currentTarget.attributes.patientNo.value;
  423. var patientInfo = inPatientList[patientNo];
  424. patientInfo.treatDt=patientInfo.inDt;
  425. patientInfo.treatTyp=treatType;
  426. localStorage.setItem('patientInfo', JSON.stringify(patientInfo));
  427. $('#nursingPopup [id*=popContent]').removeClass('in');
  428. $('#nursingPopup #popContentNursingRecode').addClass('in');
  429. if(!$('#openToggle').is('.on')){
  430. $('#nursingRecodeTab.nav-tabs a[href="#tabInfo"]').tab('show');
  431. }else{
  432. mplusNursing.reInit($("ul#nursingRecodeTab.nav-tabs li.active a").attr('aria-controls'));
  433. }
  434. $('#newPopupFooter').css('display', 'block');
  435. /*$('#nursingPopup').css('display', 'block');*/
  436. $('.list-group-item').removeClass('active');
  437. $(this).addClass('active');
  438. // 선택한 환자의 스크롤 위치 구하기
  439. var pos = $('#tabIn').scrollTop() + $('#inUlPatientList li a.list-group-item[patientno='+patientNo+']').offset().top;
  440. $('#patientList').css('margin-bottom', '100vh');
  441. if( self.isTablet() ) {
  442. // 적절한 위치로 이동
  443. $('#tabIn').animate({scrollTop: pos - 150}, 500);
  444. $('#nursingPopup').height(max2-245);
  445. $('#nursingPopup .tab-content .tab-pane').height(max2-317);
  446. $('#openToggle').stop().animate({bottom: wh-280 },500);
  447. }else{
  448. // 적절한 위치로 이동
  449. $('#tabIn').animate({scrollTop: pos - 77}, 500);
  450. $('#nursingPopup').height(max2-105);
  451. $('#nursingPopup .tab-content .tab-pane').height(max2-177);
  452. $('#openToggle').stop().animate({bottom: wh-140 },500);
  453. }
  454. $('#openToggle').addClass('on');
  455. $('#openToggle').find('.fa').removeClass('fa-chevron-up');
  456. $('#openToggle').find('.fa').addClass('fa-chevron-down');
  457. $('#nursingPopup').stop().animate({bottom:0},500);
  458. $('#nursingPopup').css({'display': 'block'});
  459. mplusNursing.init();
  460. var patientInfo = inPatientList[event.currentTarget.attributes.patientNo.value];
  461. patientInfo.treatTyp=treatType;
  462. localStorage.setItem('patientInfo', JSON.stringify(patientInfo));
  463. var param = {
  464. hospitalCd: localStorage.hospitalCd,
  465. patientId: patientInfo.patientId
  466. };
  467. var patientInfoData = self.nursing.getPatientInfo(param);
  468. bindingPatientDetail(patientInfo, patientInfoData);
  469. // 다음이벤트 (환자리스트가 아닌 화면영역을 클릭했을 때 토글 내려가게 하는 기능) 동작을 막기 위함
  470. return false;
  471. });
  472. };
  473. /*----------------------- 입원 resource 종료 ----------------------*/
  474. /*----------------------- 외래 resource ----------------------*/
  475. var $outTotalNumSpan = $('#outTotalNumSpan'),
  476. $outSearchDate = $('#outSearchDate'),
  477. $outSearchBtn = $('#outSearchBtn'),
  478. $outUlPatientList = $('#outUlPatientList'),
  479. $outBtnSortOpen = $('#outBtnSortOpen'),
  480. $outSltDept = $('#outSltDept'),
  481. $outSltDoctor = $('#outSltDoctor'),
  482. $outPidSearch = $('#outPidSearch');
  483. var outRecentSearchType, //최근 검색했던 전체, 본인 여부(정렬시 필요)
  484. outPatientList = [];
  485. var treatType = '';
  486. var outInit = function(){
  487. treatType = 'O';
  488. $outPidSearch.val('');
  489. requestToServer = true;
  490. searchedPatientList = [];
  491. $outSearchDate.val(moment(new Date()).format('YYYY-MM-DD'));
  492. var sortList = [{key: 'age', type: 'number', value: '연령순'},
  493. {key: 'patientNm', type: 'string', value: '이름순'},
  494. {key: 'treatTm', type: 'number', value: '진료시간순'}];
  495. outRecentSearchType = '';
  496. outPatientList = [];
  497. $outSltDept.val(localStorage.selectDeptCode).trigger('change');
  498. if($outSltDept.val()==null){
  499. $outSltDept[0].selectedIndex = 0;
  500. }
  501. $outTotalNumSpan.text(0);
  502. $outUlPatientList.empty();
  503. sortInit(sortList);
  504. $('#sortConfirmBtn').unbind();
  505. $('#sortConfirmBtn').on("click", function(e){
  506. $('#sortModal').modal('hide');
  507. outSortPatientList($('#sltSort').val(), $('#sltSort option:selected').attr('type'), $('input[type="radio"][name="sortRadio"]:checked').val());
  508. $('.header span').css('display', 'none');
  509. $('.header.sort_'+$('#sltSort').val()+' .sort-icon-'+$('input[type="radio"][name="sortRadio"]:checked').val()).css('display', 'inline-block');
  510. });
  511. $('#outChkTotalView').prop('checked', true);
  512. if(jobKindCd=='S'){
  513. $('#outChkTotalView').prop('checked', false);
  514. $('#outSltDoctor').val(JSON.parse(localStorage.user).userId);
  515. if($('#outSltDoctor').val()==null) $('#outSltDoctor').val(' ');
  516. }
  517. };
  518. var outAddEvent = function() {
  519. $outSearchBtn.on("click", function(e) {
  520. $('.header span').css('display', 'none');
  521. // 검색조건(진료과, 진료의, 진료일) 변동사항이 없고, 환자번호 검색어가 입력된경우
  522. // 서버로 따로 요청하지 않고 이미 받은 데이터에서 환자번호 필터링만 한다.
  523. if( !requestToServer && $outPidSearch.val().length > 0) {
  524. outPatientList = searchedPatientList.filter(val => {return val.patientId.indexOf($outPidSearch.val()) >= 0;});
  525. outBindingPatientList(outPatientList, null);
  526. } else {
  527. outSearchPatientList();
  528. }
  529. });
  530. $outBtnSortOpen.on("click", function(e){
  531. $('#sortModal').modal('show');
  532. });
  533. $outSltDept.on("change", function(e){
  534. if( e.currentTarget.value == '' ) return;
  535. var doctorList = self.hospital.getDoctorList({
  536. departmentCd: e.currentTarget.value
  537. });
  538. $outSltDoctor.empty();
  539. var totalOption = $('<option></option>').clone().attr('value', ' ').text('전체');
  540. $outSltDoctor.append(totalOption);
  541. for(var i=0; i<doctorList.length; i++){
  542. var option = $('<option></option>').clone().attr('value', doctorList[i].doctorId).text(doctorList[i].doctorNm);
  543. $outSltDoctor.append(option);
  544. }
  545. });
  546. $outPidSearch.on('click', function(e){
  547. e.currentTarget.value = '';
  548. });
  549. $outSearchDate.on('change', function(e){
  550. requestToServer = true;
  551. });
  552. $outSltDept.on('change', function(e){
  553. requestToServer = true;
  554. });
  555. $outSltDoctor.on('change', function(e){
  556. requestToServer = true;
  557. });
  558. };
  559. var outInitDataSetting = function(){
  560. var deptList = JSON.parse(localStorage.user).departmentList;
  561. var userJobKindCd = JSON.parse(localStorage.user).jobKindCd;
  562. var sltList = deptList;
  563. $outSltDept.empty();
  564. for(var i=0; i<sltList.length; i++){
  565. if(!(userJobKindCd=='N' && sltList[i].departmentTyp=='W')){
  566. option = $('<option></option>').clone().attr('value', sltList[i].departmentCd)
  567. .text(sltList[i].departmentNm);
  568. $outSltDept.append(option);
  569. }
  570. }
  571. };
  572. var outSearchPatientList = function() {
  573. if($outSearchDate.val()==''){
  574. self.alert('조회 일자를 입력해주세요.');
  575. return;
  576. }
  577. $outUlPatientList.empty();
  578. outPatientList = [];
  579. patientInfoInit();
  580. //과별 외래환자 조회
  581. if($outSltDoctor.val().trim() == ''){
  582. var param;
  583. param = {
  584. treatDt: moment($outSearchDate.val()).format('YYYYMMDD'),
  585. departmentCd: $outSltDept.val()
  586. };
  587. self.treatment.getOutPatList(param, 'out');
  588. }else{
  589. //전체해제, 진료과&병동선택
  590. var param;
  591. param = {
  592. treatDt: moment($outSearchDate.val()).format('YYYYMMDD'),
  593. departmentCd: $outSltDept.val(),
  594. doctorId: $outSltDoctor.val()
  595. };
  596. self.treatment.getOutPatList(param, 'out');
  597. }
  598. };
  599. var outSortPatientList = function(key, type, method){
  600. var sortPatientList = self.util.sortObj(outPatientList, key, type, method);
  601. outBindingPatientList(sortPatientList, null);
  602. };
  603. outBindingPatientList = function(bindPatientList, extraMsg){ //all: 전체, mine: 본인
  604. if( $outPidSearch.val().length > 0 ) {
  605. outPatientList = bindPatientList.filter(val => {return val.patientId.indexOf($outPidSearch.val()) >= 0;});
  606. } else {
  607. outPatientList = bindPatientList;
  608. }
  609. if( requestToServer ) {
  610. searchedPatientList = bindPatientList;
  611. requestToServer = false;
  612. }
  613. $outUlPatientList.empty();
  614. $outTotalNumSpan.text(outPatientList.length);
  615. if(outPatientList.length==0){
  616. $outUlPatientList.append(li.clone().append(div.clone().addClass('text-center no-result').text('―')));
  617. }
  618. for(var i=0; i<outPatientList.length; i++){
  619. var divTime = div.clone().addClass('day col-xs-3 col-sm-3').text(outPatientList[i].treatTm!=''?(outPatientList[i].treatTm.substr(0,2)+':'+outPatientList[i].treatTm.substr(2,2)+':'+outPatientList[i].treatTm.substr(4,2)):'');
  620. var divName = div.clone().addClass('name col-xs-6 col-sm-6').text(outPatientList[i].patientNm + ' ' + outPatientList[i].patientId);
  621. var divNum = div.clone().addClass('num_3 col-xs-3 col-sm-3').text(outPatientList[i].gender + ' / ' + outPatientList[i].age);
  622. var divReserveTime = div.clone().addClass('day col-xs-3 hidden-sm').text('');
  623. var divDoctor = div.clone().addClass('doctor col-xs-6 col-sm-6').text(outPatientList[i].departmentCd + ' / '+ outPatientList[i].doctorNm);
  624. var divStatus = div.clone().addClass('col-xs-3 col-sm-3').text(outPatientList[i].treatStat);
  625. var divRow1 = div.clone().addClass('list-row container').append(div.clone().addClass('col-xs-12 col-sm-6 pd0').append(divTime).append(divName).append(divNum));
  626. var divRow2 = div.clone().addClass('col-xs-12 col-sm-6 pd0').append(divReserveTime).append(divDoctor).append(divStatus);
  627. var divRow = a.clone().addClass('list-group-item').attr('patientNo', i).attr('patientId', outPatientList[i].patientId).append(divRow1.append(divRow2));
  628. // 퇴실사유가 있는경우 아래에 출력한다.
  629. if(outPatientList[i].outRsn != undefined && outPatientList[i].outRsn != '' && outPatientList[i].outRsn != '') {
  630. var divOutReasonWrap = div.clone().addClass('list-row container');
  631. var divOutReason = div.clone().addClass('col-xs-9 col-sm-10').append($("<strong></strong>").text("퇴실사유: ")).append(span.clone().text(outPatientList[i].outRsn));
  632. divOutReasonWrap.append(div.clone().addClass('col-xs-3 col-sm-2')).append(divOutReason);
  633. divRow.append(divOutReasonWrap);
  634. }
  635. $outUlPatientList.append(li.clone().append(divRow));
  636. }
  637. $('#outPatientList .list-group-item').on('click',function(){
  638. if(event.toElement.id.indexOf('check')>-1){
  639. return;
  640. }
  641. $('.list-group-item').removeClass('active');
  642. $(this).addClass('active');
  643. var patientNo = event.currentTarget.attributes.patientNo.value;
  644. var patientInfo = outPatientList[patientNo];
  645. patientInfo.treatDt=patientInfo.treatDt;
  646. patientInfo.treatTyp=treatType;
  647. localStorage.setItem('patientInfo', JSON.stringify(patientInfo));
  648. $('#nursingPopup [id*=popContent]').removeClass('in');
  649. $('#nursingPopup #popContentNursingRecode').addClass('in');
  650. if(!$('#openToggle').is('.on')){
  651. $('#nursingRecodeTab.nav-tabs a[href="#tabInfo"]').tab('show');
  652. }else{
  653. mplusNursing.reInit($("ul#nursingRecodeTab.nav-tabs li.active a").attr('aria-controls'));
  654. }
  655. $('#newPopupFooter').css('display', 'block');
  656. /*$('#nursingPopup').css('display', 'block');*/
  657. $('.list-group-item').removeClass('active');
  658. $(this).addClass('active');
  659. // 선택한 환자의 스크롤 위치 구하기
  660. var pos = $('#tabOut').scrollTop() + $('#outUlPatientList li a.list-group-item[patientno='+patientNo+']').offset().top;
  661. $('#outPatientList').css('margin-bottom', '100vh');
  662. if( self.isTablet() ) {
  663. // 적절한 위치로 이동
  664. $('#tabOut').animate({scrollTop: pos - 150}, 500);
  665. $('#nursingPopup').height(max2-245);
  666. $('#nursingPopup .tab-content .tab-pane').height(max2-317);
  667. $('#openToggle').stop().animate({bottom: wh-280 },500);
  668. }else{
  669. // 적절한 위치로 이동
  670. $('#tabOut').animate({scrollTop: pos - 77}, 500);
  671. $('#nursingPopup').height(max2-105);
  672. $('#nursingPopup .tab-content .tab-pane').height(max2-177);
  673. $('#openToggle').stop().animate({bottom: wh-140 },500);
  674. }
  675. $('#openToggle').addClass('on');
  676. $('#openToggle').find('.fa').removeClass('fa-chevron-up');
  677. $('#openToggle').find('.fa').addClass('fa-chevron-down');
  678. $('#nursingPopup').stop().animate({bottom:0},500);
  679. $('#nursingPopup').css({'display': 'block'});
  680. mplusNursing.init();
  681. var param = {
  682. hospitalCd: localStorage.hospitalCd,
  683. patientId: patientInfo.patientId
  684. };
  685. var patientInfoData = self.nursing.getPatientInfo(param);
  686. bindingPatientDetail(patientInfo, patientInfoData);
  687. // 다음이벤트 (환자리스트가 아닌 화면영역을 클릭했을 때 토글 내려가게 하는 기능) 동작을 막기 위함
  688. return false;
  689. /*$('.list-group-item').removeClass('active');
  690. $(this).addClass('active');
  691. $('#openToggle').stop().animate({bottom:240},500);
  692. $('#overlay').stop().animate({bottom:-49},500);
  693. $(this).addClass('active');
  694. $('#footer').css('overflow','visible');
  695. $('#openToggle').addClass('on');
  696. $('#openToggle').find('.fa').removeClass('fa-chevron-up');
  697. $('#openToggle').find('.fa').addClass('fa-chevron-down');
  698. var patientInfo = outPatientList[event.currentTarget.attributes.patientNo.value];
  699. localStorage.setItem('patientInfo', JSON.stringify(patientInfo));
  700. var param = {
  701. patientId: patientInfo.patientId,
  702. departmentCd: patientInfo.departmentCd,
  703. treatTyp: treatType,
  704. treatDt: patientInfo.treatDt};
  705. self.patient.getTreatInfo(param);*/
  706. });
  707. };
  708. /*----------------------- 외래 resource 종료 ----------------------*/
  709. /*----------------------- 응급 resource ----------------------*/
  710. var $emerTotalNumSpan = $('#emerTotalNumSpan'),
  711. $emerSearchBtn = $('#emerSearchBtn'),
  712. $emerUlPatientList = $('#emerUlPatientList'),
  713. $emerBtnSortOpen = $('#emerBtnSortOpen'),
  714. $emerSltDept = $('#emerSltDept'),
  715. $emerPidSearch = $('#emerPidSearch');
  716. var emerPatientList = [];
  717. var emerInit = function(){
  718. treatType = 'E';
  719. $emerPidSearch.val('');
  720. requestToServer = true;
  721. var sortList = [{key: 'age', type: 'number', value: '연령순'},
  722. {key: 'patientNm', type: 'string', value: '이름순'}];
  723. emerPatientList = [];
  724. $emerUlPatientList.empty();
  725. $emerTotalNumSpan.text(0);
  726. sortInit(sortList);
  727. $('#sortConfirmBtn').unbind();
  728. $('#sortConfirmBtn').on("click", function(e){
  729. $('#sortModal').modal('hide');
  730. emerSortPatientList($('#sltSort').val(), $('#sltSort option:selected').attr('type'), $('input[type="radio"][name="sortRadio"]:checked').val());
  731. $('.header span').css('display', 'none');
  732. $('.header.sort_'+$('#sltSort').val()+' .sort-icon-'+$('input[type="radio"][name="sortRadio"]:checked').val()).css('display', 'inline-block');
  733. });
  734. };
  735. /**
  736. * 이벤트등록
  737. */
  738. var emerAddEvent = function(){
  739. $emerSearchBtn.on('click', function(e){
  740. $('.header span').css('display', 'none');
  741. // 검색조건(진료과) 변동사항이 없고, 환자번호 검색어가 입력된경우
  742. // 서버로 따로 요청하지 않고 이미 받은 데이터에서 환자번호 필터링만 한다.
  743. if( !requestToServer && $emerPidSearch.val().length > 0) {
  744. emerPatientList = searchedPatientList.filter(val => {return val.patientId.indexOf($emerPidSearch.val()) >= 0;});
  745. emerBindingPatientList(emerPatientList, null);
  746. } else {
  747. emerSearchPatientList();
  748. }
  749. });
  750. $emerBtnSortOpen.on("click", function(e){
  751. $('#sortModal').modal('show');
  752. });
  753. $emerPidSearch.on('click', function(e){
  754. e.currentTarget.value = '';
  755. });
  756. $emerSltDept.on('change', function(e){
  757. requestToServer = true;
  758. });
  759. };
  760. /**
  761. * 기초데이터 셋팅
  762. * 20180727 shinsunwoo 전체 옵션의 기본값을 'A'로 지정
  763. */
  764. var emerInitDataSetting = function(){
  765. var sltList = deptList;
  766. $('#emerSltDept').empty();
  767. var totalOption = $('<option></option>').clone().attr('value', 'A')
  768. .text('전체');
  769. $('#emerSltDept').append(totalOption);
  770. for(var i=0; i<sltList.length; i++){
  771. option = $('<option></option>').clone().attr('value', sltList[i].departmentCd)
  772. .text(sltList[i].departmentNm);
  773. $('#emerSltDept').append(option);
  774. }
  775. $('#emerSltDept').val('A');
  776. };
  777. var emerSearchPatientList = function(){
  778. $emerUlPatientList.empty();
  779. emerPatientList = [];
  780. patientInfoInit();
  781. var param = {
  782. departmentCd: $('#emerSltDept').val()==null? ' ': $('#emerSltDept').val()
  783. };
  784. self.treatment.getErPatList(param, 'all');
  785. /*bindingPatientList('all', patientList);*/
  786. };
  787. var emerSortPatientList = function(key, type, method){
  788. emerPatientList = self.util.sortObj(emerPatientList, key, type, method);
  789. emerBindingPatientList(emerPatientList, null);
  790. };
  791. emerBindingPatientList = function(bindPatientList, extraMsg){ //all: 전체
  792. if( $emerPidSearch.val().length > 0 ) {
  793. emerPatientList = bindPatientList.filter(val => {return val.patientId.indexOf($emerPidSearch.val()) >= 0;});
  794. } else {
  795. emerPatientList = bindPatientList;
  796. }
  797. if( requestToServer ) {
  798. searchedPatientList = bindPatientList;
  799. requestToServer = false;
  800. }
  801. $emerUlPatientList.empty();
  802. $emerTotalNumSpan.text(emerPatientList.length);
  803. if(emerPatientList.length==0){
  804. $emerUlPatientList.append(li.clone().append(div.clone().addClass('text-center no-result').text('―')));
  805. }
  806. for(var i=0; i<emerPatientList.length; i++){
  807. var divWard = div.clone().addClass('col-xs-4 col-sm-5 pdr0 letter-control').text(emerPatientList[i].wardNm + '/' + emerPatientList[i].roomNm + '/' + emerPatientList[i].bedNm);
  808. var divName = div.clone().addClass('name col-xs-5 col-sm-4 pd0').text(emerPatientList[i].patientNm + ' ' + emerPatientList[i].patientId);
  809. var divNum = div.clone().addClass('num_3 col-xs-3 col-sm-3 pdr0').text(emerPatientList[i].gender +' / '+ emerPatientList[i].age);
  810. var divDay = div.clone().addClass('day col-xs-4 col-sm-4 pdr0').text(Math.floor(emerPatientList[i].elapsedTm/60) + '시간 ' + (emerPatientList[i].elapsedTm%60) + '분');
  811. var divDoctor = div.clone().addClass('doctor col-xs-5 col-sm-4 pd0').text(emerPatientList[i].departmentCd + ' / ' + emerPatientList[i].doctorNm);
  812. var divDate = div.clone().addClass('date col-xs-3 col-sm-4 pdr0 letter-control').text(emerPatientList[i].treatDt!=undefined&&emerPatientList[i].treatDt!=null&&emerPatientList[i].treatDt!=''? moment(emerPatientList[i].treatDt).format('YYYY-MM-DD'):'');
  813. var divPatientInfo1 = div.clone().addClass('list-row container').append(div.clone().addClass('col-xs-12 col-sm-7 pd0').append(divWard).append(divName).append(divNum));
  814. var divPatientInfo2 = div.clone().addClass('col-xs-12 col-sm-5 pd0').append(divDay).append(divDoctor).append(divDate);
  815. var divRow = a.clone().addClass('list-group-item').attr('patientNo', i).attr('patientId', emerPatientList[i].patientId).append(divPatientInfo1.append(divPatientInfo2));
  816. // 퇴실사유가 있는 경우 아래에 출력해준다.
  817. if(emerPatientList[i].outRsn != undefined && emerPatientList[i].outRsn != '' && emerPatientList[i].outRsn != '') {
  818. var divOutReasonWrap = div.clone().addClass('list-row container');
  819. var divOutReason = div.clone().addClass('col-xs-9 col-sm-10').append($("<strong></strong>").text("퇴실사유: ")).append(span.clone().text(emerPatientList[i].outRsn));
  820. divOutReasonWrap.append(div.clone().addClass('col-xs-3 col-sm-2')).append(divOutReason);
  821. divRow.append(divOutReasonWrap);
  822. }
  823. $emerUlPatientList.append(li.clone().append(divRow));
  824. }
  825. $('#emerPatientList .list-group-item').on('click',function(){
  826. if(event.toElement.id.indexOf('check')>-1){
  827. return;
  828. }
  829. $('.list-group-item').removeClass('active');
  830. $(this).addClass('active');
  831. var patientNo = event.currentTarget.attributes.patientNo.value;
  832. var patientInfo = emerPatientList[patientNo];
  833. patientInfo.treatDt=patientInfo.treatDt;
  834. patientInfo.treatTyp=treatType;
  835. localStorage.setItem('patientInfo', JSON.stringify(patientInfo));
  836. $('#nursingPopup [id*=popContent]').removeClass('in');
  837. $('#nursingPopup #popContentNursingRecode').addClass('in');
  838. if(!$('#openToggle').is('.on')){
  839. $('#nursingRecodeTab.nav-tabs a[href="#tabInfo"]').tab('show');
  840. }else{
  841. mplusNursing.reInit($("ul#nursingRecodeTab.nav-tabs li.active a").attr('aria-controls'));
  842. }
  843. $('#newPopupFooter').css('display', 'block');
  844. /*$('#nursingPopup').css('display', 'block');*/
  845. $('.list-group-item').removeClass('active');
  846. $(this).addClass('active');
  847. // 선택한 환자의 스크롤 위치 구하기
  848. var pos = $('#tabEmer').scrollTop() + $('#emerUlPatientList li a.list-group-item[patientno='+patientNo+']').offset().top;
  849. $('#emerPatientList').css('margin-bottom', '100vh');
  850. if( self.isTablet() ) {
  851. // 적절한 위치로 이동
  852. $('#tabEmer').animate({scrollTop: pos - 150}, 500);
  853. $('#nursingPopup').height(max2-245);
  854. $('#nursingPopup .tab-content .tab-pane').height(max2-317);
  855. $('#openToggle').stop().animate({bottom: wh-280 },500);
  856. }else{
  857. // 적절한 위치로 이동
  858. $('#tabEmer').animate({scrollTop: pos - 77}, 500);
  859. $('#nursingPopup').height(max2-105);
  860. $('#nursingPopup .tab-content .tab-pane').height(max2-177);
  861. $('#openToggle').stop().animate({bottom: wh-140 },500);
  862. };
  863. $('#openToggle').addClass('on');
  864. $('#openToggle').find('.fa').removeClass('fa-chevron-up');
  865. $('#openToggle').find('.fa').addClass('fa-chevron-down');
  866. $('#nursingPopup').stop().animate({bottom:0},500);
  867. $('#nursingPopup').css({'display': 'block'});
  868. mplusNursing.init();
  869. var param = {
  870. hospitalCd: localStorage.hospitalCd,
  871. patientId: patientInfo.patientId
  872. };
  873. var patientInfoData = self.nursing.getPatientInfo(param);
  874. bindingPatientDetail(patientInfo, patientInfoData);
  875. // 다음이벤트 (환자리스트가 아닌 화면영역을 클릭했을 때 토글 내려가게 하는 기능) 동작을 막기 위함
  876. return false;
  877. /*$('.list-group-item').removeClass('active');
  878. $(this).addClass('active');
  879. $('#openToggle').stop().animate({bottom:240},500);
  880. $('#overlay').stop().animate({bottom:-49},500);
  881. $(this).addClass('active');
  882. $('#footer').css('overflow','visible');
  883. $('#openToggle').addClass('on');
  884. $('#openToggle').find('.fa').removeClass('fa-chevron-up');
  885. $('#openToggle').find('.fa').addClass('fa-chevron-down');
  886. var patientInfo = emerPatientList[event.currentTarget.attributes.patientNo.value];
  887. localStorage.setItem('patientInfo', JSON.stringify(patientInfo));
  888. var param = {
  889. patientId: patientInfo.patientId,
  890. departmentCd: patientInfo.departmentCd,
  891. treatTyp: treatType,
  892. treatDt: patientInfo.treatDt};
  893. self.patient.getTreatInfo(param);*/
  894. });
  895. };
  896. /*----------------------- 응급 resource 종료 ----------------------*/
  897. /*----------------------- 검색 resource ----------------------*/
  898. var $searchSearchBtn = $('#searchSearchBtn'),
  899. $searchSearchDate = $('#searchSearchDate'),
  900. $searchUlPatientList = $('#searchUlPatientList'),
  901. $searchSearchConditionUpper = $('#searchSearchConditionUpper'),
  902. $searchSearchConditionLower = $('#searchSearchConditionLower'),
  903. $searchSearchConditionType = $('#searchSearchConditionType');
  904. var searchPatientList = [];
  905. var searchInit = function(){
  906. treatType = 'S';
  907. $searchSearchDate.val(moment(new Date()).format('YYYY-MM-DD'));
  908. $('input[type="radio"][name="plist-search"][value="treat"]').prop('checked', true);
  909. searchSearchTypeChange('treat');
  910. var sortList = [{key: 'wardNm', type: 'string', value: '병동순'},
  911. {key: 'age', type: 'number', value: '연령순'},
  912. {key: 'patientNm', type: 'string', value: '이름순'}];
  913. searchPatientList = [];
  914. $searchUlPatientList.empty();
  915. sortInit(sortList);
  916. if( self.isTablet() ){
  917. $('#searchPatientHeaderPhone').css('display', 'none');
  918. $('#searchPatientHeaderTablet').css('display', 'block');
  919. }else{
  920. $('#searchPatientHeaderPhone').css('display', 'block');
  921. $('#searchPatientHeaderTablet').css('display', 'none');
  922. }
  923. }
  924. /**
  925. * 이벤트등록
  926. */
  927. var searchAddEvent = function(){
  928. $searchSearchBtn.on("click", function(e){
  929. searchSearchPatientList();
  930. });
  931. /*$searchRecentSearchBtn.on("click", function(e){
  932. searchSearchPatientList();
  933. });*/
  934. $('input[type="radio"][name="plist-search"]').on('change', function(e) {
  935. patientInfoInit();
  936. searchSearchTypeChange(e.currentTarget.value);
  937. });
  938. $('input[type="radio"][name="treatment"]').on('change', function(e) {
  939. $searchUlPatientList.empty();
  940. searchPatientList = [];
  941. patientInfoInit();
  942. if(e.currentTarget.value=='in'){
  943. $searchSearchDate.attr('readonly', true);
  944. $('.treat-header').text('입원일');
  945. }else{
  946. $searchSearchDate.val(moment(new Date()).format('YYYY-MM-DD'));
  947. $searchSearchDate.attr('readonly', false);
  948. $('.treat-header').text('진료일');
  949. }
  950. });
  951. };
  952. /**
  953. * 기초데이터 셋팅
  954. */
  955. var searchInitDataSetting = function(){
  956. };
  957. /**
  958. * 검색 상태변경 이벤트
  959. */
  960. var searchSearchTypeChange = function(type){
  961. $searchSearchConditionUpper.empty();
  962. $searchSearchConditionLower.empty();
  963. $searchUlPatientList.empty();
  964. searchPatientList = [];
  965. var conditionUpper;
  966. var conditionLower;
  967. if(type == 'treat'){
  968. $searchSearchConditionUpper.attr('class', 'col-xs-5 pdr5');
  969. $searchSearchConditionLower.attr('class', 'col-xs-5 pdl5');
  970. conditionUpper = $('<select></select>').clone().addClass('form-control').attr('id', 'searchSltDept');
  971. for(var i=0; i<deptList.length; i++){
  972. option = $('<option></option>').clone().attr('value', deptList[i].departmentCd)
  973. .text(deptList[i].departmentNm);
  974. conditionUpper.append(option);
  975. }
  976. conditionLower = $('<select></select>').clone().addClass('form-control').attr('id', 'search_sltDoctor');
  977. $searchSearchConditionType.css('display', 'block');
  978. $searchSearchConditionUpper.html(conditionUpper);
  979. $searchSearchConditionLower.html(conditionLower);
  980. $('#searchSltDept').change(function(e) {
  981. var doctorList = self.hospital.getDoctorList({
  982. departmentCd: e.currentTarget.value
  983. });
  984. $('#search_sltDoctor').empty();
  985. for(var i=0; i<doctorList.length; i++){
  986. option = $('<option></option>').clone().attr('value', doctorList[i].doctorId)
  987. .text(doctorList[i].doctorNm);
  988. conditionLower.append(option);
  989. }
  990. $searchSearchConditionLower.html(conditionLower);
  991. });
  992. $('#searchSltDept').change();
  993. $('input[type="radio"][name="treatment"][value="in"]').prop("checked", true);
  994. $searchSearchDate.val(moment(new Date()).format('YYYY-MM-DD'));
  995. $searchSearchDate.attr('readonly', true);
  996. }else if(type == 'hospital'){
  997. $searchSearchConditionUpper.attr('class', 'col-xs-5 pdr5');
  998. $searchSearchConditionLower.attr('class', 'col-xs-5 pdl5');
  999. conditionUpper = $('<select></select>').clone().addClass('form-control').attr('id', 'search_sltWard');
  1000. for(var i=0; i<wardList.length; i++){
  1001. option = $('<option></option>').clone().attr('value', wardList[i].departmentCd)
  1002. .text(wardList[i].departmentNm);
  1003. conditionUpper.append(option);
  1004. }
  1005. conditionLower = $('<select></select>').clone().addClass('form-control').attr('id', 'searchSltDept');
  1006. for(var i=0; i<deptList.length; i++){
  1007. option = $('<option></option>').clone().attr('value', deptList[i].departmentCd)
  1008. .text(deptList[i].departmentNm);
  1009. conditionLower.append(option);
  1010. }
  1011. $searchSearchConditionType.css('display', 'none');
  1012. $searchSearchConditionUpper.html(conditionUpper);
  1013. $searchSearchConditionLower.html(conditionLower);
  1014. }else{
  1015. $searchSearchConditionUpper.attr('class', 'col-xs-5 pdr5');
  1016. $searchSearchConditionLower.attr('class', 'col-xs-5 pdl5');
  1017. conditionUpper =
  1018. $('<select></select>').clone().addClass('form-control').attr('id', 'search_sltPatientCondition').append(
  1019. $('<option></option>').clone().attr('value', 'name').text('환자명')
  1020. ).append(
  1021. $('<option></option>').clone().attr('value', 'num').text('등록번호')
  1022. );
  1023. conditionLower =
  1024. $('<input></input>').clone().addClass('form-control').attr('type', 'text').attr('placeholder', '검색').attr('id', 'search_txtSrData');
  1025. $searchSearchConditionType.css('display', 'none');
  1026. $searchSearchConditionUpper.html(conditionUpper);
  1027. $searchSearchConditionLower.html(conditionLower);
  1028. }
  1029. };
  1030. var searchSearchPatientList = function(){
  1031. $searchUlPatientList.empty();
  1032. searchPatientList = [];
  1033. patientInfoInit();
  1034. // 진료과/진료의 검색
  1035. if($('input[type="radio"][name="plist-search"]:checked').val()=='treat'){
  1036. var param = {};
  1037. if($('input[type="radio"][name="treatment"]:checked').val()=='in'){
  1038. param = {
  1039. departmentCd: $('#searchSltDept').val(),
  1040. doctorId: $('#search_sltDoctor').val()
  1041. };
  1042. self.treatment.getInPatListPerDeptOrWard(param, 'I', 'search');
  1043. }else{
  1044. if($('#searchSearchDate').val()==''){
  1045. self.alert('조회 일자를 입력해주세요.');
  1046. return;
  1047. }
  1048. param = {
  1049. departmentCd: $('#searchSltDept').val(),
  1050. doctorId: $('#search_sltDoctor').val(),
  1051. treatDt: moment($('#searchSearchDate').val()).format('YYYYMMDD')
  1052. };
  1053. self.treatment.getOutPatList(param, 'search');
  1054. }
  1055. //병동/진료과 검색
  1056. }else if($('input[type="radio"][name="plist-search"]:checked').val()=='hospital'){
  1057. var param = {};
  1058. param = {
  1059. wardCd: $('#search_sltWard').val(),
  1060. departmentCd: $('#searchSltDept').val()
  1061. };
  1062. self.treatment.getSrPatListByWD(param);
  1063. //재원환자검색
  1064. }else if($('input[type="radio"][name="plist-search"]:checked').val()=='patient'){
  1065. if($('#search_txtSrData').val()==''){
  1066. self.alert('조회할 '+ $('#search_sltPatientCondition option:selected').text() +'을(를) 입력해주세요.');
  1067. return;
  1068. }else if($('#search_sltPatientCondition option:selected').val()=='name' && $('#search_txtSrData').val().length<2){
  1069. self.alert($('#search_sltPatientCondition option:selected').text() + '을 2글자 이상 입력해주세요.');
  1070. return;
  1071. }
  1072. var param = {};
  1073. if($('#search_sltPatientCondition').val()=='name'){
  1074. param = {
  1075. patientNm: $('#search_txtSrData').val()
  1076. };
  1077. }else{
  1078. param = {
  1079. patientId: $('#search_txtSrData').val()
  1080. };
  1081. }
  1082. self.treatment.getSrPatList(param);
  1083. }else{
  1084. }
  1085. };
  1086. searchBindingPatientList = function(bindPatientList, extraMsg){ //all: 전체, mine: 본인
  1087. searchPatientList = bindPatientList;
  1088. if(searchPatientList.length==0){
  1089. $searchUlPatientList.append(li.clone().append(div.clone().addClass('text-center no-result').text('―')));
  1090. }
  1091. for(var i=0; i<searchPatientList.length; i++){
  1092. var divNum = div.clone().addClass("col-xs-3 col-sm-2 pdr0").text( (searchPatientList[i].gender=='F'? 'F':'M') + ' / ' + searchPatientList[i].age);
  1093. var divName = div.clone().addClass("name col-xs-4 col-sm-2 pd0").text(searchPatientList[i].patientNm + ' ' + searchPatientList[i].patientId);
  1094. var divNumHospital = div.clone().addClass("num_b col-xs-5 col-sm-2 pdr0 letter-control").text(searchPatientList[i].treatTyp=='O'? '외래': searchPatientList[i].wardNm + '/' + searchPatientList[i].roomNm + '/' + searchPatientList[i].bedNm);
  1095. var divDoctor = div.clone().addClass("doctor col-xs-4 col-sm-2 pd0").text(searchPatientList[i].departmentCd + ' / ' + searchPatientList[i].doctorNm);
  1096. var divDate = div.clone().addClass("date col-xs-5 col-sm-3 pdr0 letter-control").text(searchPatientList[i].treatTyp=='O'? moment(searchPatientList[i].treatDt).format('YYYY-MM-DD') : moment(searchPatientList[i].inDt).format('YYYY-MM-DD')+ ' HOD '+ searchPatientList[i].inDay);
  1097. if(self.isTablet()){
  1098. var divPatientInfo = div.clone().addClass("list-row container").append(divNumHospital).append(divDate).append(divName).append(divNum).append(divDoctor);
  1099. }else{
  1100. var divPatientInfo = div.clone().addClass("list-row container").append(divNumHospital).append(divName).append(divNum).append(divDate).append(divDoctor);
  1101. }
  1102. $searchUlPatientList.append(li.clone().append(a.clone().addClass("list-group-item").attr('patientNo', i).attr('patientId', searchPatientList[i].patientId).append(divPatientInfo)));
  1103. }
  1104. $('#searchPatientList .list-group-item').on('click',function(){
  1105. var patientInfo = searchPatientList[event.currentTarget.attributes.patientNo.value];
  1106. var patientNo = event.currentTarget.attributes.patientNo.value;
  1107. if($('input[type="radio"][name="plist-search"]:checked').val()=='treat'){
  1108. if($('input[type="radio"][name="treatment"]:checked').val()=='in'){
  1109. patientInfo.treatTyp='I';
  1110. }
  1111. }else{
  1112. patientInfo.treatTyp='I';
  1113. }
  1114. localStorage.setItem('patientInfo', JSON.stringify(patientInfo));
  1115. var param = {
  1116. patientId: patientInfo.patientId,
  1117. departmentCd: patientInfo.departmentCd,
  1118. treatTyp: patientInfo.treatTyp,
  1119. treatDt: patientInfo.inDt==undefined? patientInfo.treatDt: patientInfo.inDt};
  1120. $('.list-group-item').removeClass('active');
  1121. $(this).addClass('active');
  1122. /*$('#nursingPopup [id*=popContent]').removeClass('in');
  1123. $('#nursingPopup #popContentNursingRecode').addClass('in');
  1124. $('#nursingRecodeTab.nav-tabs a[href="#tabInfo"]').tab('show');
  1125. $('#nursingPopup').css('display', 'block');*/
  1126. $('.list-group-item').removeClass('active');
  1127. $(this).addClass('active');
  1128. var patientNo = event.currentTarget.attributes.patientNo.value;
  1129. var patientInfo = searchPatientList[patientNo];
  1130. patientInfo.treatDt=patientInfo.inDt;
  1131. patientInfo.treatTyp=patientInfo.treatTyp;
  1132. localStorage.setItem('patientInfo', JSON.stringify(patientInfo));
  1133. $('#nursingPopup [id*=popContent]').removeClass('in');
  1134. $('#nursingPopup #popContentNursingRecode').addClass('in');
  1135. if(!$('#openToggle').is('.on')){
  1136. $('#nursingRecodeTab.nav-tabs a[href="#tabInfo"]').tab('show');
  1137. }else{
  1138. mplusNursing.reInit($("ul#nursingRecodeTab.nav-tabs li.active a").attr('aria-controls'));
  1139. }
  1140. $('#newPopupFooter').css('display', 'block');
  1141. /*$('#nursingPopup').css('display', 'block');*/
  1142. $('.list-group-item').removeClass('active');
  1143. $(this).addClass('active');
  1144. // 선택한 환자의 스크롤 위치 구하기
  1145. var pos = $('#tabSearch').scrollTop() + $('#searchPatientList li a.list-group-item[patientno='+patientNo+']').offset().top;
  1146. $('#searchPatientList').css('margin-bottom', '100vh');
  1147. if( self.isTablet() ) {
  1148. // 적절한 위치로 이동
  1149. $('#tabSearch').animate({scrollTop: pos - 150}, 500);
  1150. $('#nursingPopup').height(max2-245);
  1151. $('#nursingPopup .tab-content .tab-pane').height(max2-317);
  1152. $('#openToggle').stop().animate({bottom: wh-280 },500);
  1153. }else{
  1154. // 적절한 위치로 이동
  1155. $('#tabSearch').animate({scrollTop: pos - 77}, 500);
  1156. $('#nursingPopup').height(max2-105);
  1157. $('#nursingPopup .tab-content .tab-pane').height(max2-177);
  1158. $('#openToggle').stop().animate({bottom: wh-140 },500);
  1159. }
  1160. $('#openToggle').addClass('on');
  1161. $('#openToggle').find('.fa').removeClass('fa-chevron-up');
  1162. $('#openToggle').find('.fa').addClass('fa-chevron-down');
  1163. $('#nursingPopup').stop().animate({bottom:0},500);
  1164. $('#nursingPopup').css({'display': 'block'});
  1165. mplusNursing.init();
  1166. var patientInfo = searchPatientList[event.currentTarget.attributes.patientNo.value];
  1167. patientInfo.treatTyp=patientInfo.treatTyp;
  1168. localStorage.setItem('patientInfo', JSON.stringify(patientInfo));
  1169. var param = {
  1170. hospitalCd: localStorage.hospitalCd,
  1171. patientId: patientInfo.patientId
  1172. };
  1173. var patientInfoData = self.nursing.getPatientInfo(param);
  1174. bindingPatientDetail(patientInfo, patientInfoData);
  1175. // 다음이벤트 (환자리스트가 아닌 화면영역을 클릭했을 때 토글 내려가게 하는 기능) 동작을 막기 위함
  1176. return false;
  1177. });
  1178. };
  1179. /*----------------------- 검색 resource 종료 ----------------------*/
  1180. /*----------------------- 상세-정보탭 공통 --------------------------*/
  1181. var bindingPatientDetail = function(patientInfo, patientInfoData) {
  1182. if(patientInfoData!=undefined){
  1183. // if(patientInfoData.patientDtl!="") {console.log('테스트');}
  1184. $('#nursingPopupId').text(patientInfoData.patientId);
  1185. $('#nursingPopupNameNum').text(patientInfoData.patientNm + ' / ' + patientInfoData.patientId);
  1186. $('#nursingPopupBirth').text(patientInfoData.birthDt!=""&&patientInfoData.birthDt!=null&&patientInfoData.birthDt!=undefined? moment(patientInfoData.birthDt).format('YYYY-MM-DD'):patientInfoData.birthDt);
  1187. $('#nursingPopupSex').text(patientInfoData.gender + ' / '+ patientInfoData.age);
  1188. $('#nursingPopupRoom').text(patientInfoData.wardNm + ' / '+ patientInfoData.roomNm + ' / '+ patientInfoData.bedNm);
  1189. $('#nursingDiagnosisNm').text(patientInfoData.diagnosisNm);
  1190. $('#nursingOperatingDt').text(patientInfoData.operatingDt!=""&&patientInfoData.operatingDt!=null&&patientInfoData.operatingDt!=undefined? moment(patientInfoData.operatingDt).format('YYYY-MM-DD'):patientInfoData.operatingDt);
  1191. $('#nursingOperatingNm').text(patientInfoData.operatingNm);
  1192. if(patientInfo.treatTyp == 'E') {
  1193. $('#nursingInDt').text(patientInfo.treatDt!=""&&patientInfo.treatDt!=null&&patientInfo.treatDt!=undefined? moment(patientInfo.treatDt).format('YYYY-MM-DD'):patientInfo.treatDt);
  1194. } else {
  1195. $('#nursingInDt').text(patientInfoData.inDt!=""&&patientInfoData.inDt!=null&&patientInfoData.inDt!=undefined? moment(patientInfoData.inDt).format('YYYY-MM-DD'):patientInfoData.inDt);
  1196. }
  1197. $('#nursingInRsn').html(patientInfoData.inRsn.replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\n/g, '<br>'));
  1198. $('#nursingCurrentStat').html(patientInfoData.currentStat.replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\n/g, '<br>'));
  1199. }else{
  1200. $('#nursingPopupId').text(patientInfo.patientId);
  1201. $('#nursingPopupNameNum').text('');
  1202. $('#nursingPopupBirth').text('');
  1203. $('#nursingPopupSex').text('');
  1204. $('#nursingPopupRoom').text('');
  1205. $('#nursingDiagnosisNm').text('');
  1206. $('#nursingOperatingDt').text('');
  1207. $('#nursingOperatingNm').text('');
  1208. $('#nursingInDt').text('');
  1209. $('#nursingInRsn').text('');
  1210. $('#nursingCurrentStat').text('');
  1211. }
  1212. };
  1213. };