outpatientsch.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  1. "use strict";
  2. /**
  3. * mplus_medical_outpatientsch
  4. */
  5. var mplus_schedule_outpatientsch = function(){
  6. // 상속
  7. mplus_common.call(this);
  8. // 상위 객체 생성
  9. //var mplusPatient = new mplus_mobile_patient();
  10. //var mplusNursing = new mplus_nursing();
  11. //super
  12. var self = this;
  13. //선택일자 전역변수
  14. var varSelDate;
  15. var varResultLists = [];
  16. //==== 변수 } ====
  17. /**
  18. * 초기화
  19. */
  20. this.init = function(){ //여기서 모든화면 콤보박스데이터를 집어넣자!!! 그래야지 화면이동할때 속도가 오래걸리지않음!!!
  21. // 접근 권한 체크
  22. checkAccessPermission();
  23. // 초기 화면 조건 구성
  24. initCondition();
  25. // 이벤트 초기화
  26. addEvent();
  27. };
  28. //==== 접근 권한 체크 { ====
  29. var checkAccessPermission = function(){
  30. //if( !self.common.checkAccessJobKind( "1000")){
  31. // self.alertTrue("접근 권한이 없습니다.", self.common.gotoDefaultHomePage);
  32. //}
  33. //if( !self.common.checkAccessUserAuth( "01")){
  34. // self.alertTrue("접근 권한이 없습니다.", self.common.gotoDefaultHomePage);
  35. //}
  36. //self.common.disableElements( $("#myModalBtn"));
  37. };
  38. //==== 접근 권한 체크 } ====
  39. //==== 초기화 설정 { ====
  40. var initCondition = function(){
  41. // 초기 화면 조건 구성
  42. // 순서 조심! startdt enddt 설정 후 서버에서 부서리스트를 설정 후 스케줄데이터를 호출해야함
  43. //0.데이터 초기화
  44. $("#txtDoctorInfoDoctorNm").text("");
  45. $("#txtDoctorInfoSpeciality").text("");
  46. $("#txtDoctorInfoDoctorTel").text("");
  47. $("#sltOutpatientschDept").empty();
  48. $("#divOutpatientschResultRows").empty();
  49. //1.기간설정
  50. initStartEndDate();
  51. //2.주 일자 처리
  52. initWeekDate();
  53. //3.선택 부서 처리
  54. initSelDept();
  55. };
  56. var initStartEndDate = function(){
  57. varSelDate = new Date();
  58. //일요일이면 차주 가져오기
  59. //다른 요일이면 해당 요일 처리
  60. varSelDate.setDate(varSelDate.getDate() - varSelDate.getDay() + 1);
  61. $("#txtOutpatientschStartYear").text( moment(varSelDate).format("YYYY") );
  62. $("#txtOutpatientschStartMonth").text( moment(varSelDate).format("MM") );
  63. $("#txtOutpatientschStartDay").text( moment(varSelDate).format("DD") );
  64. varSelDate.setDate(varSelDate.getDate() + 5);
  65. $("#txtOutpatientschEndYear").text( moment(varSelDate).format("YYYY") );
  66. $("#txtOutpatientschEndMonth").text( moment(varSelDate).format("MM") );
  67. $("#txtOutpatientschEndDay").text( moment(varSelDate).format("DD") );
  68. varSelDate.setDate(varSelDate.getDate() - 5);
  69. //console.log("처리일자 : " + moment(varSelDate).format("YYYY-MM-DD"));
  70. };
  71. var initSelDept = function(){
  72. //search deptlist
  73. var param = {
  74. userId: gLoginUserId,
  75. jobCls: localStorage.selectedJobKindCd
  76. };
  77. self.schedule.getShcDeptList(param, processSearchShcDeptList);
  78. };
  79. var processSearchShcDeptList = function(lists){
  80. $("#sltOutpatientschDept").empty();
  81. var strDisplayTemp = "";
  82. strDisplayTemp = "<option value=\"\">부서</option>";
  83. if(lists != undefined){
  84. for(var i=0; i<lists.length; i++){
  85. strDisplayTemp += "<option value=\""+ lists[i].deptCd +"\">"+ lists[i].deptNm +"</option>";
  86. }
  87. }
  88. $("#sltOutpatientschDept").append(strDisplayTemp);
  89. $("#sltOutpatientschDept").val(localStorage.selectedDeptCd);
  90. if($("#sltOutpatientschDept").val()==null){
  91. $("#sltOutpatientschDept").val($("#sltOutpatientschDept option:first").val());
  92. };
  93. //기본 정보 셋팅 후 호출
  94. searchWorkSch();
  95. };
  96. //==== 초기화 설정 } ====
  97. //==== 이벤트 설정 { ====
  98. var addEvent = function(){
  99. eventRowClick();
  100. eventConditionClick();
  101. };
  102. var eventConditionClick = function(){
  103. //부서변경 이벤트
  104. $("#sltOutpatientschDept").change(function(){
  105. searchWorkSch();
  106. });
  107. // 이전 주 버튼클릭
  108. $("#btnOutpatientschBeforeWeek").off("click"); // 기존 이벤트 해제
  109. $("#btnOutpatientschBeforeWeek").on("click", function(e){
  110. varSelDate.setDate(varSelDate.getDate() - 7);
  111. $("#txtOutpatientschStartYear").text( moment(varSelDate).format("YYYY") );
  112. $("#txtOutpatientschStartMonth").text( moment(varSelDate).format("MM") );
  113. $("#txtOutpatientschStartDay").text( moment(varSelDate).format("DD") );
  114. varSelDate.setDate(varSelDate.getDate() + 5);
  115. $("#txtOutpatientschEndYear").text( moment(varSelDate).format("YYYY") );
  116. $("#txtOutpatientschEndMonth").text( moment(varSelDate).format("MM") );
  117. $("#txtOutpatientschEndDay").text( moment(varSelDate).format("DD") );
  118. varSelDate.setDate(varSelDate.getDate() - 5);
  119. initWeekDate();
  120. searchWorkSch();
  121. });
  122. // 다음 주 버튼클릭
  123. $("#btnOutpatientschNextWeek").off("click"); // 기존 이벤트 해제
  124. $("#btnOutpatientschNextWeek").on("click", function(e){
  125. varSelDate.setDate(varSelDate.getDate() + 7);
  126. $("#txtOutpatientschStartYear").text( moment(varSelDate).format("YYYY") );
  127. $("#txtOutpatientschStartMonth").text( moment(varSelDate).format("MM") );
  128. $("#txtOutpatientschStartDay").text( moment(varSelDate).format("DD") );
  129. varSelDate.setDate(varSelDate.getDate() + 5);
  130. $("#txtOutpatientschEndYear").text( moment(varSelDate).format("YYYY") );
  131. $("#txtOutpatientschEndMonth").text( moment(varSelDate).format("MM") );
  132. $("#txtOutpatientschEndDay").text( moment(varSelDate).format("DD") );
  133. varSelDate.setDate(varSelDate.getDate() - 5);
  134. initWeekDate();
  135. searchWorkSch();
  136. });
  137. //전화걸기
  138. $("#btnDoctorInfoDoctorTelCall").unbind();
  139. $("#btnDoctorInfoDoctorTelCall").on("click", function(e){
  140. if($("#txtDoctorInfoDoctorTel").text()==""){
  141. self.alert("해당 의사의 전화번호가 존재하지 않습니다.");
  142. return;
  143. };
  144. location.href = "tel:"+$("#txtDoctorInfoDoctorTel").text();
  145. });
  146. //조회 클릭
  147. $("#btnOutpatientschSearch").unbind();
  148. $("#btnOutpatientschSearch").on("click", function(e){
  149. searchWorkSch();
  150. });
  151. $(window).unbind();
  152. $(window).resize(function() {
  153. //p 사이즈 처리
  154. var pHeightSize = ($("#sltOutpatientschDept").height() * 0.6);
  155. var pWidthSize = ($("#sltOutpatientschDept").width() * 0.15);
  156. $(".schptag").width(pWidthSize);
  157. $(".schptag").height(pHeightSize);
  158. });
  159. };
  160. var initWeekDate = function(){
  161. var tempSelDate = new Date(varSelDate);
  162. $("#txtSchMonDate").text(moment(tempSelDate).format("DD"));
  163. tempSelDate.setDate(tempSelDate.getDate() + 1);
  164. $("#txtSchTueDate").text(moment(tempSelDate).format("DD"));
  165. tempSelDate.setDate(tempSelDate.getDate() + 1);
  166. $("#txtSchWedDate").text(moment(tempSelDate).format("DD"));
  167. tempSelDate.setDate(tempSelDate.getDate() + 1);
  168. $("#txtSchThuDate").text(moment(tempSelDate).format("DD"));
  169. tempSelDate.setDate(tempSelDate.getDate() + 1);
  170. $("#txtSchFriDate").text(moment(tempSelDate).format("DD"));
  171. tempSelDate.setDate(tempSelDate.getDate() + 1);
  172. $("#txtSchSatDate").text(moment(tempSelDate).format("DD"));
  173. };
  174. var eventRowClick = function(){
  175. // 스케줄 선택 이벤트 처리
  176. $(".duty-schedule .dutyDoctorId").off("click"); // 기존 이벤트 해제
  177. $(".duty-schedule .dutyDoctorId").on("click", function(e){
  178. var doctorId = e.currentTarget.attributes.doctorId.value;
  179. //console.log("click : " + doctorId);
  180. var param = {
  181. userId:gLoginUserId,
  182. doctorId: doctorId
  183. };
  184. self.schedule.getDoctorInfo(param, processSearchDoctorInfo);
  185. // 환자 정보 화면 띄우기
  186. //$("#modalDoctorInfo").modal("show");
  187. //mplusModalDoctorinfo.init(param);
  188. });
  189. };
  190. var processSearchDoctorInfo = function(lists){
  191. //console.log("lists : " + lists.length);
  192. if(lists !== undefined && lists != null && lists.length != 0 && lists[0].doctorId != undefined && lists[0].doctorId != null && lists[0].doctorId != ""){
  193. /*
  194. var varDoctorInfo = "주치의 : " + lists[0].doctorNm +"<br/>"
  195. + "전문분야 : "+ lists[0].speciality+"<br/>"
  196. + "전화번호 : "+ lists[0].doctorTel;
  197. $("#mplusAlertDoctorInfoBody").append(varDoctorInfo);
  198. */
  199. if(lists[0].doctorNm != "" && lists[0].doctorNm != null && lists[0].doctorNm != undefined) {
  200. $("#txtDoctorInfoDoctorNm").text(lists[0].doctorNm);
  201. }else{
  202. $("#txtDoctorInfoDoctorNm").text("");
  203. }
  204. if(lists[0].speciality != "" && lists[0].speciality != null && lists[0].speciality != undefined) {
  205. $("#txtDoctorInfoSpeciality").text(lists[0].speciality);
  206. }else{
  207. $("#txtDoctorInfoSpeciality").text("");
  208. }
  209. if(lists[0].doctorTel != "" && lists[0].doctorTel != null && lists[0].doctorTel != undefined){
  210. $("#txtDoctorInfoDoctorTel").text(lists[0].doctorTel);
  211. $("#btnDoctorInfoDoctorTelCall").css('display', 'inline-block');
  212. }else{
  213. $("#txtDoctorInfoDoctorTel").text("");
  214. $("#btnDoctorInfoDoctorTelCall").css('display', 'none');
  215. }
  216. $("#mplusAlertDoctorInfo").modal("show");
  217. }else{
  218. self.alert("해당 의사의 정보가 없습니다.");
  219. }
  220. };
  221. //==== 이벤트 설정 } ====
  222. //==== 스케줄 정보 조회 처리 { ====
  223. // 스케줄 정보 조회
  224. var searchWorkSch = function(){
  225. var tempSelDate = new Date(varSelDate);
  226. tempSelDate.setDate(tempSelDate.getDate() + 5);
  227. //console.log("searchWorkSch varSelDate : " + moment(varSelDate).format("YYYY-MM-DD") + " / tempSelDate : " + moment(tempSelDate).format("YYYY-MM-DD"));
  228. var param = {
  229. userId: gLoginUserId,
  230. startDt: moment(varSelDate).format("YYYYMMDD"),
  231. endDt: moment(tempSelDate).format("YYYYMMDD"),
  232. selectedDeptCd: $("#sltOutpatientschDept").val()
  233. };
  234. self.schedule.getWorkSch(param, processSearchWorkSch);
  235. };
  236. // 스케줄 정보 조회 결과 처리
  237. var processSearchWorkSch = function(lists){
  238. // 1. 스케줄 조회 결과 리스트를 varResultLists로 복사
  239. varResultLists = lists;
  240. // 2. 스케줄 검색 결과 리스트를 재정리 : 아이디순서별
  241. //20190527 dkchoi75 상계백병원 앱 자체 정렬 않되게 요청
  242. // self.common.sortArrayObject( varResultLists, "doctorId", true);
  243. // 3. 스케줄 검색 결과를 화면에 disaplay
  244. drawWorkSchList();
  245. };
  246. // 환자 정보 화면에 그리기
  247. var drawWorkSchList = function(){
  248. //1.아이디로 정렬 된 list 같은 아이디 위치 체크
  249. //2.해당 위치까지 for은 돌려 각 일별 근무일정 arry에 담기
  250. //3.출력하기
  251. var lists = varResultLists;
  252. var strDisplayTemp = "";
  253. $("#divOutpatientschResultRows").empty();
  254. //월 화 수 목 금 토 일 변수
  255. var scheduleList = ["","","","","","",""];
  256. //CSS Style List
  257. var scheduleClassList = ["D-type","N-type","ICU"];
  258. //CSS 변수
  259. var varCSSTemp = 0;
  260. //p 사이즈 처리
  261. var pHeightSize = ($("#sltOutpatientschDept").height() * 0.6);
  262. var pWidthSize = ($("#sltOutpatientschDept").width() * 0.15);
  263. for( var i = 0; i < lists.length; ){
  264. //초기화
  265. scheduleList = [["","","","","","",""],["","","","","","",""]];
  266. var varDocId = lists[i].doctorId;
  267. var inputEndCnt = 0;
  268. var startCnt = i;
  269. //의사 동일 ID 위치 처리
  270. for( ; i < lists.length ; i++){
  271. if(varDocId != lists[i].doctorId){
  272. varDocId = lists[i].doctorId;
  273. inputEndCnt = i;
  274. break;
  275. }
  276. inputEndCnt = i;
  277. }
  278. //마지막 list까지 확인했을 경우 inputEndCnt +1처리 위의 for에서 처리 제한
  279. if(i == lists.length) inputEndCnt += 1;
  280. for(var inputCnt = startCnt ; inputCnt < inputEndCnt ; inputCnt++){
  281. //console.log("cnt inputCnt : " + inputCnt + " lists[inputCnt].dayCd : " + lists[inputCnt].dayCd + " lists[inputCnt].workingInfo : " + lists[inputCnt].workingInfo + " userid : " + lists[inputCnt].doctorId);
  282. //null값 처리
  283. if(lists[inputCnt].workingInfo == null){
  284. lists[inputCnt].workingInfo = "&nbsp";
  285. }
  286. if(lists[inputCnt].dayCd == "MON"){
  287. scheduleList[0][0] = lists[inputCnt].workingInfo;
  288. scheduleList[1][0] = drawWorkSchListColor(lists[inputCnt].workingInfo);
  289. } else if (lists[inputCnt].dayCd == "TUE"){
  290. scheduleList[0][1] = lists[inputCnt].workingInfo;
  291. scheduleList[1][1] = drawWorkSchListColor(lists[inputCnt].workingInfo);
  292. } else if (lists[inputCnt].dayCd == "WED"){
  293. scheduleList[0][2] = lists[inputCnt].workingInfo;
  294. scheduleList[1][2] = drawWorkSchListColor(lists[inputCnt].workingInfo);
  295. } else if (lists[inputCnt].dayCd == "THU"){
  296. scheduleList[0][3] = lists[inputCnt].workingInfo;
  297. scheduleList[1][3] = drawWorkSchListColor(lists[inputCnt].workingInfo);
  298. } else if (lists[inputCnt].dayCd == "FRI"){
  299. scheduleList[0][4] = lists[inputCnt].workingInfo;
  300. scheduleList[1][4] = drawWorkSchListColor(lists[inputCnt].workingInfo);
  301. } else if (lists[inputCnt].dayCd == "SAT"){
  302. scheduleList[0][5] = lists[inputCnt].workingInfo;
  303. scheduleList[1][5] = drawWorkSchListColor(lists[inputCnt].workingInfo);
  304. } else if (lists[inputCnt].dayCd == "SUN"){
  305. scheduleList[0][6] = lists[inputCnt].workingInfo;
  306. scheduleList[1][6] = drawWorkSchListColor(lists[inputCnt].workingInfo);
  307. }
  308. }
  309. strDisplayTemp += "<div class=\"duty-person \">"
  310. + "<div class=\"row\">"
  311. + " <div class=\"col-sm-2 col-xs-2 dutyDoctorId\" doctorId=\"" + lists[startCnt].doctorId + "\" style=\"margin-top: 8px;\">" + lists[startCnt].doctorNm + "</div>"
  312. + " <div class=\"col-sm-2 col-xs-2 "+scheduleList[1][0]+"\">"
  313. + " <p class=\"schptag\">"+scheduleList[0][0]+"</p>"
  314. + " </div>"
  315. + " <div class=\"col-sm-2 col-xs-2 "+scheduleList[1][1]+"\">"
  316. + " <p class=\"schptag\">"+scheduleList[0][1]+"</p>"
  317. + " </div>"
  318. + " <div class=\"col-sm-2 col-xs-2 "+scheduleList[1][2]+"\">"
  319. + " <p class=\"schptag\">"+scheduleList[0][2]+"</p>"
  320. + " </div>"
  321. + " <div class=\"col-sm-2 col-xs-2 "+scheduleList[1][3]+"\">"
  322. + " <p class=\"schptag\">"+scheduleList[0][3]+"</p>"
  323. + " </div>"
  324. + " <div class=\"col-sm-2 col-xs-2 "+scheduleList[1][4]+"\">"
  325. + " <p class=\"schptag\">"+scheduleList[0][4]+"</p>"
  326. + " </div>"
  327. + " <div class=\"col-sm-2 col-xs-2 "+scheduleList[1][5]+"\">"
  328. + " <p class=\"schptag\">"+scheduleList[0][5]+"</p>"
  329. + " </div>"
  330. + " </div>"
  331. + "</div>"
  332. ;
  333. varCSSTemp++;
  334. }
  335. $("#divOutpatientschResultRows").append(strDisplayTemp); // element 추가
  336. $(".schptag").width(pWidthSize);
  337. $(".schptag").height(pHeightSize);
  338. eventRowClick();
  339. };
  340. //외래진료일정 색상변경(건대용)
  341. var drawWorkSchListColor = function(colorData){
  342. var returnColorData = "";
  343. if(colorData == "오전"){//#c2d4de
  344. returnColorData = "pRed";
  345. }else if(colorData == "오후"){//#99abb5
  346. returnColorData = "pGreen";
  347. }else if(colorData == "종일"){//#e9c77b
  348. returnColorData = "pBlue";
  349. }else if(colorData == "&nbsp"){//회색
  350. returnColorData = "pGrey";
  351. }else{//#e2b49a
  352. returnColorData = "pYellow";
  353. }
  354. return returnColorData;
  355. };
  356. //==== 환자 정보 조회 처리 } ====
  357. };