PatientInfoCtrl.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  1. #region Copyright © 2015 CLIPSOFT Co.,Ltd. All Rights Reserved.
  2. //
  3. // All rights are reserved. Reproduction or transmission in whole or in part,
  4. // in any form or by any means, electronic, mechanical or otherwise, is
  5. // prohibited without the prior written consent of the copyright owner.
  6. //
  7. // Filename:PatientInfoCtrl.cs
  8. //
  9. #endregion
  10. using System;
  11. using System.ComponentModel;
  12. using System.Windows.Forms;
  13. using System.Collections.Generic;
  14. using ClipSoft.Exceptions;
  15. using CLIP.eForm.Consent.Dfh.UI.HospitalSvcRef;
  16. namespace CLIP.eForm.Consent.Dfh.UI
  17. {
  18. /// <summary>
  19. /// 동의서 조회 컨트롤의 환자 정보 탭 클래스
  20. /// </summary>
  21. /// <remarks>
  22. /// <p>[설계자]</p>
  23. /// <p> 클립소프트 연구소 홍지철 (jchong@clipsoft.co.kr)</p>
  24. /// <p>[원본 작성자]</p>
  25. /// <p> 클립소프트 기술부 이창훈 (chlee@clipsoft.co.kr)</p>
  26. /// <p>[수정 작성자]</p>
  27. /// <p> 클립소프트 기술부 이인희</p>
  28. /// <p>----------------------------------------------------------------------------------------</p>
  29. /// <p>[HISTORY]</p>
  30. /// <p> 2016-06-21 : 최초작성</p>
  31. /// <p>----------------------------------------------------------------------------------------</p>
  32. /// </remarks>
  33. public partial class PatientInfoCtrl : PatientInfoCtrlBase
  34. {
  35. private HospitalSvcRef.HospitalSvcSoapClient hospitalWebService = null;
  36. IConsentMain consentMain = null;
  37. ConsentCommandCtrl commandControl = null;
  38. public PatientInfoCtrl()
  39. {
  40. InitializeComponent();
  41. }
  42. private void PatientInfoCtrl_Load(object sender, EventArgs e)
  43. {
  44. if (this.DesignMode || LicenseManager.UsageMode == LicenseUsageMode.Designtime)
  45. {
  46. return;
  47. }
  48. consentMain = ConsentMainControl.GetConsentMainInterface(this);
  49. commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl;
  50. consentMain.OnLoadPartControls += ConsentMain_OnLoadPartControls;
  51. hospitalWebService = WebMethodCommon.GetHospitalWebService(consentMain.PluginExecuteInfo["hospitalSvcUrl"]);
  52. }
  53. private void ConsentMain_OnLoadPartControls(object sender, EventArgs e)
  54. {
  55. if (consentMain == null) consentMain = ConsentMainControl.GetConsentMainInterface(this);
  56. if (commandControl == null) commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl;
  57. try
  58. {
  59. SetEndUser(consentMain);
  60. SetPatientBasicInfo(consentMain);
  61. SetClnDateItem();
  62. if (comboTrmtPrd.Items.Count > 0) comboTrmtPrd.SelectedIndex = 0;
  63. }
  64. catch (UserException uex)
  65. {
  66. MessageBox.Show(string.Format(uex.Message)
  67. , string.Format(Properties.Resources.msg_caption_fail),
  68. MessageBoxButtons.OK, MessageBoxIcon.Error);
  69. consentMain.TerminateConsentMain();
  70. }
  71. }
  72. // 작성자 정보 셋팅
  73. private void SetEndUser(IConsentMain consentMain)
  74. {
  75. if (commandControl == null) commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl;
  76. if (consentMain.ConsentExecuteInfo.ContainsKey("userNo"))
  77. {
  78. GetUserDetailInfo(consentMain.ConsentExecuteInfo["userNo"], commandControl);
  79. }
  80. else
  81. {
  82. throw new UserException(Properties.Resources.msg_error_user_args);
  83. }
  84. }
  85. private void GetUserDetailInfo(string userNo, ConsentCommandCtrl commandControl)
  86. {
  87. UserVO userVO = (UserVO)this.hospitalWebService.GetUserInfo(userNo);
  88. if (userVO == null)
  89. {
  90. //if (userNo.Substring(0,4).Equals("5000"))
  91. //{
  92. // MessageBox.Show("일반의사는 출력만 가능합니다.");
  93. // commandControl.CurrentEndUser = new EndUser();
  94. // commandControl.CurrentEndUser.UserName = this.labelUserNm.Text = "일반의사";
  95. // commandControl.CurrentEndUser.UserNo = this.labelUserNo.Text = userNo;
  96. // commandControl.CurrentEndUser.DeptCode = "";
  97. // commandControl.CurrentEndUser.DeptName = this.labelUserDept.Text = "";
  98. //}
  99. //else
  100. //{
  101. throw new UserException(string.Format(Properties.Resources.msg_error_get_user, userNo));
  102. //}
  103. }
  104. else
  105. {
  106. if (userNo.Substring(0, 4).Equals("5000"))
  107. {
  108. MessageBox.Show("일반의사는 출력만 가능합니다.");
  109. }
  110. commandControl.CurrentEndUser = new EndUser();
  111. commandControl.CurrentEndUser.UserNo = this.labelUserNo.Text = userVO.UserNo;
  112. commandControl.CurrentEndUser.UserName = this.labelUserNm.Text = userVO.UserName;
  113. commandControl.CurrentEndUser.Password = userVO.UserPassword;
  114. commandControl.CurrentEndUser.DeptCode = userVO.UserDeptCode;
  115. commandControl.CurrentEndUser.DeptName = this.labelUserDept.Text = userVO.UserDeptName;
  116. commandControl.CurrentEndUser.UserGroupCode = userVO.UserGroupCode;
  117. commandControl.CurrentEndUser.HosType = userVO.HosType;
  118. if(!consentMain.ConsentExecuteInfo.ContainsKey("loginUserName"))
  119. {
  120. consentMain.ConsentExecuteInfo["loginUserName"] = commandControl.CurrentEndUser.UserName;
  121. }
  122. if(consentMain.ConsentExecuteInfo.ContainsKey("loginUserNo")
  123. && consentMain.ConsentExecuteInfo["loginUserNo"].Equals(commandControl.CurrentEndUser.UserNo))
  124. {
  125. consentMain.ConsentExecuteInfo["loginUserName"] = commandControl.CurrentEndUser.UserName;
  126. }
  127. }
  128. }
  129. // 환자 정보 셋팅
  130. private void SetPatientBasicInfo(IConsentMain consentMain)
  131. {
  132. if (consentMain.ConsentExecuteInfo.ContainsKey("patientNo") && consentMain.ConsentExecuteInfo.ContainsKey("clnDate")
  133. && consentMain.ConsentExecuteInfo.ContainsKey("visitType") && consentMain.ConsentExecuteInfo.ContainsKey("clnDept")
  134. && consentMain.ConsentExecuteInfo.ContainsKey("cretno"))
  135. {
  136. PatientVO[] patientVOList = this.hospitalWebService.GetPatientInfo( consentMain.ConsentExecuteInfo["patientNo"],
  137. consentMain.ConsentExecuteInfo["clnDate"],
  138. consentMain.ConsentExecuteInfo["visitType"],
  139. consentMain.ConsentExecuteInfo["clnDept"],
  140. consentMain.ConsentExecuteInfo["cretno"]
  141. );
  142. if (patientVOList == null || patientVOList.Length == 0)
  143. {
  144. //throw new UserException(string.Format(Properties.Resources.msg_error_get_patient
  145. // , consentMain.ConsentExecuteInfo["patientNo"]));
  146. //환자정보 없이 프로그램을 실행해야 하는 경우가 있음.
  147. commandControl.CurrentTargetPatient = new TargetPatient();
  148. if (commandControl != null && commandControl.CurrentEndUser != null)
  149. {
  150. commandControl.CurrentTargetPatient.HosType = commandControl.CurrentEndUser.HosType;
  151. }
  152. }
  153. else
  154. {
  155. PatientVO vo = patientVOList[0];
  156. this.labelPtntNm.Text = vo.IO_Pt_Name;
  157. this.labelPtntNo.Text = vo.IO_Pt_ID;
  158. commandControl.CurrentTargetPatient = new TargetPatient();
  159. if (commandControl != null && commandControl.CurrentEndUser != null)
  160. {
  161. commandControl.CurrentTargetPatient.HosType = commandControl.CurrentEndUser.HosType;
  162. }
  163. SetTargetPatientInfo(vo);
  164. }
  165. }
  166. else
  167. {
  168. throw new UserException(Properties.Resources.msg_error_patient_args);
  169. }
  170. }
  171. //PatientVO 정보를 이용해서 CurrentTargetPatient 정보 SET
  172. private void SetTargetPatientInfo(PatientVO vo)
  173. {
  174. commandControl.CurrentTargetPatient.PatientName = vo.IO_Pt_Name;
  175. commandControl.CurrentTargetPatient.PatientCode = vo.IO_Pt_ID;
  176. commandControl.CurrentTargetPatient.PatientSexAge = vo.IO_sex_age_y_m;
  177. commandControl.CurrentTargetPatient.PatientJuminNo = vo.IO_JuminNo;
  178. commandControl.CurrentTargetPatient.VisitType = vo.IO_VisitType;
  179. commandControl.CurrentTargetPatient.cretno = vo.IO_CretNo;
  180. commandControl.CurrentTargetPatient.Dschdd = vo.IO_Dschdd.Replace("-","");
  181. commandControl.CurrentTargetPatient.clnDate = vo.IO_ADdate;
  182. commandControl.CurrentTargetPatient.clnDeptCode = vo.IO_DeptCd;
  183. commandControl.CurrentTargetPatient.clnDeptName = vo.IO_DeptNm;
  184. commandControl.CurrentTargetPatient.clnDeptNameKO = vo.IO_Dept2;
  185. commandControl.CurrentTargetPatient.clnDxCd = vo.IO_DxCd;
  186. commandControl.CurrentTargetPatient.clnDxNm = vo.IO_DxNm;
  187. commandControl.CurrentTargetPatient.MainDrId = vo.IO_MaindrId;
  188. commandControl.CurrentTargetPatient.MainDrNm = vo.IO_MaindrNm;
  189. commandControl.CurrentTargetPatient.Ward = vo.IO_Ward;
  190. commandControl.CurrentTargetPatient.RoomNo = vo.IO_RoomNo;
  191. commandControl.CurrentTargetPatient.OrderNo = vo.IO_OrderNo;
  192. commandControl.CurrentTargetPatient.OPdrId = vo.IO_OPdrId;
  193. commandControl.CurrentTargetPatient.OPdrNm = vo.IO_OPdrNm;
  194. commandControl.CurrentTargetPatient.OPdeptCode = vo.IO_OPdeptCd;
  195. commandControl.CurrentTargetPatient.OPdeptName = vo.IO_OPdeptNm;
  196. commandControl.CurrentTargetPatient.PatientAddr = vo.IO_Zipcdaddr;
  197. commandControl.CurrentTargetPatient.PatientTelNo = vo.IO_Tel;
  198. commandControl.CurrentTargetPatient.Insukind = vo.IO_Insukind;
  199. commandControl.CurrentTargetPatient.Ex_bp = vo.IO_bp;
  200. commandControl.CurrentTargetPatient.Ex_dm = vo.IO_dm;
  201. commandControl.CurrentTargetPatient.Ex_heart = vo.IO_heart;
  202. commandControl.CurrentTargetPatient.Ex_kidney = vo.IO_kidney;
  203. commandControl.CurrentTargetPatient.Ex_respiration = vo.IO_respiration;
  204. commandControl.CurrentTargetPatient.Ex_hx = vo.IO_hx;
  205. commandControl.CurrentTargetPatient.Ex_allergy = vo.IO_allergy;
  206. commandControl.CurrentTargetPatient.Ex_drug = vo.IO_drug;
  207. commandControl.CurrentTargetPatient.Ex_smoking = vo.IO_smoking;
  208. commandControl.CurrentTargetPatient.Ex_idio = vo.IO_idio;
  209. commandControl.CurrentTargetPatient.Ex_nacrotics = vo.IO_nacrotics;
  210. commandControl.CurrentTargetPatient.Ex_airway = vo.IO_airway;
  211. commandControl.CurrentTargetPatient.Ex_hemorrhage = vo.IO_hemorrhage;
  212. commandControl.CurrentTargetPatient.Ex_status_etc = vo.IO_status_etc;
  213. }
  214. // 진료일 범위 설정
  215. private void SetClnDateItem()
  216. {
  217. Dictionary<string, string> comboItems = new Dictionary<string, string>();
  218. comboItems.Add(" - ", "");
  219. for (int i = 1; i < 4; i++)
  220. {
  221. comboItems.Add(i.ToString() + "개월", DateTime.Now.AddMonths(-i).ToShortDateString().Replace("-", ""));
  222. }
  223. comboTrmtPrd.DataSource = new BindingSource(comboItems, null);
  224. comboTrmtPrd.DisplayMember = "Key";
  225. comboTrmtPrd.ValueMember = "Value";
  226. }
  227. // 진료일 범위 선택했을때, 해당하는 진료일 조회하여 바인딩
  228. private void comboTrmtPrd_SelectedIndexChanged(object sender, EventArgs e)
  229. {
  230. Dictionary<string, string> comboItems = new Dictionary<string, string>();
  231. if (comboTrmtPrd.SelectedIndex == 0 && consentMain.ConsentExecuteInfo.ContainsKey("clnDate"))
  232. {
  233. //초기 넘겨준 특정 진료일을 바인딩
  234. comboItems = GetClnDateSearchList(consentMain.ConsentExecuteInfo["patientNo"], consentMain.ConsentExecuteInfo["clnDate"], "=", consentMain.ConsentExecuteInfo["clnDept"]);//consentMain.ConsentExecuteInfo.ContainsKey("clnDate")
  235. }
  236. else
  237. {
  238. //진료일 범위에 해당하는 진료일자 조회하여 바인딩
  239. comboItems = GetClnDateSearchList(consentMain.ConsentExecuteInfo["patientNo"], comboTrmtPrd.SelectedValue.ToString(), ">=", consentMain.ConsentExecuteInfo["clnDept"]);
  240. }
  241. if (comboItems.Count > 0)
  242. {
  243. comboTrmtDate.DataSource = new BindingSource(comboItems, null);
  244. comboTrmtDate.DisplayMember = "Key";
  245. comboTrmtDate.ValueMember = "Value";
  246. comboTrmtDate.Tag = consentMain.ConsentExecuteInfo["patientNo"];
  247. if (comboTrmtDate.Items.Count > 0)
  248. {
  249. if (comboTrmtDate.SelectedIndex == 0)
  250. GetTrmtInfo();
  251. else
  252. comboTrmtDate.SelectedIndex = 0;
  253. }
  254. }
  255. else
  256. {
  257. comboTrmtDate.DataSource = null;
  258. }
  259. }
  260. private Dictionary<string, string> GetClnDateSearchList(string patientNo, string clnDate, string searchType, string orddeptcd)
  261. {
  262. Dictionary<string, string> comboDates = new Dictionary<string, string>();
  263. ClnDateForDropdownVO[] clnDateList = this.hospitalWebService.GetTrmtDateList(patientNo, clnDate, searchType, orddeptcd);
  264. if (clnDateList != null && clnDateList.Length > 0)
  265. {
  266. foreach (ClnDateForDropdownVO vDate in clnDateList)
  267. {
  268. comboDates.Add(string.Format("{0} / {1} / {2} / {3} / {4}", vDate.VisitTypeName, vDate.ClnFormatDate, vDate.ClnDeptName, vDate.orddrid, vDate.CretNo),
  269. string.Format("{0} / {1} / {2} / {3} / {4}", vDate.ClnDate, vDate.VisitType, vDate.ClnDeptCode, vDate.CretNo, vDate.DeptCd));
  270. }
  271. }
  272. return comboDates;
  273. }
  274. private void comboTrmtDate_SelectedIndexChanged(object sender, EventArgs e)
  275. {
  276. GetTrmtInfo();
  277. }
  278. private void GetTrmtInfo()
  279. {
  280. //수진일자를 변경했을때 환자의 주진단 정보를 재조회한다.
  281. if (commandControl.CurrentTargetPatient != null && comboTrmtDate.SelectedItem != null)
  282. {
  283. string[] clnDate = ((KeyValuePair<string, string>)comboTrmtDate.SelectedItem).Value.Split('/');
  284. if (clnDate != null && clnDate.Length == 5)
  285. {
  286. PatientVO[] patientVOList = this.hospitalWebService.GetPatientInfo(consentMain.ConsentExecuteInfo["patientNo"],
  287. clnDate[0].Trim(),
  288. clnDate[1].Trim(),
  289. clnDate[4].Trim(),
  290. clnDate[3].Trim()
  291. );
  292. if (patientVOList == null || patientVOList.Length == 0)
  293. {
  294. throw new UserException(string.Format(Properties.Resources.msg_error_get_patient
  295. , consentMain.ConsentExecuteInfo["patientNo"]));
  296. }
  297. else
  298. {
  299. PatientVO vo = patientVOList[0];
  300. this.labelPtntNm.Text = vo.IO_Pt_Name;
  301. this.labelPtntNo.Text = vo.IO_Pt_ID;
  302. commandControl.CurrentTargetPatient = new TargetPatient();
  303. if (commandControl != null && commandControl.CurrentEndUser != null)
  304. {
  305. commandControl.CurrentTargetPatient.HosType = commandControl.CurrentEndUser.HosType;
  306. }
  307. SetTargetPatientInfo(vo);
  308. }
  309. }
  310. }
  311. }
  312. //환자목록에서 더블클릭했을 경우, 선택된 환자 정보로 상단정보를 재조회한다.
  313. public override void OnRefeashPartControls(string visitType)
  314. {
  315. if (consentMain == null) consentMain = ConsentMainControl.GetConsentMainInterface(this);
  316. if (commandControl == null) commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl;
  317. try
  318. {
  319. SetEndUser(consentMain);
  320. SetPatientBasicInfo(consentMain);
  321. //SetClnDateItem();
  322. if(!(comboTrmtDate!= null && comboTrmtDate.Tag != null
  323. && !string.IsNullOrEmpty(comboTrmtDate.Tag.ToString())
  324. && comboTrmtDate.Tag.Equals(consentMain.ConsentExecuteInfo["patientNo"])))
  325. {
  326. if (comboTrmtPrd.SelectedIndex > 0)
  327. comboTrmtPrd.SelectedIndex = 0;
  328. else
  329. comboTrmtPrd_SelectedIndexChanged(null, null);
  330. }
  331. }
  332. catch (UserException uex)
  333. {
  334. MessageBox.Show(string.Format(uex.Message)
  335. , string.Format(Properties.Resources.msg_caption_fail),
  336. MessageBoxButtons.OK, MessageBoxIcon.Error);
  337. consentMain.TerminateConsentMain();
  338. }
  339. }
  340. // 동의서명을 설정
  341. public override void SetConsentDocumentName(string documentName)
  342. {
  343. this.labelDocName.Text = documentName;
  344. }
  345. // 작성자 정보를 설정
  346. public override void SetConsentUserInfo(string userNo)
  347. {
  348. ConsentCommandCtrl commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl;
  349. GetUserDetailInfo(userNo, commandControl);
  350. }
  351. // 상단의 진료일과 작성자 정보로 설정 (수진일자를 변경했을때 환자의 주진단 정보를 재조회한다.)
  352. public override void SetBasicPatientInfo()
  353. {
  354. if (commandControl.CurrentTargetPatient != null && comboTrmtDate.SelectedValue != null)
  355. {
  356. string[] clnDate = ((KeyValuePair<string, string>)comboTrmtDate.SelectedItem).Value.Split('/');
  357. if (clnDate != null && clnDate.Length == 4)
  358. {
  359. PatientVO[] patientVOList = this.hospitalWebService.GetPatientInfo(consentMain.ConsentExecuteInfo["patientNo"],
  360. clnDate[0].Trim(),
  361. clnDate[1].Trim(),
  362. clnDate[2].Trim(),
  363. clnDate[3].Trim()
  364. );
  365. if (patientVOList == null || patientVOList.Length == 0)
  366. {
  367. throw new UserException(string.Format(Properties.Resources.msg_error_get_patient
  368. , consentMain.ConsentExecuteInfo["patientNo"]));
  369. }
  370. else
  371. {
  372. PatientVO vo = patientVOList[0];
  373. commandControl.CurrentTargetPatient = new TargetPatient();
  374. SetTargetPatientInfo(vo);
  375. }
  376. }
  377. }
  378. }
  379. //동의서 정보로 환자 주진단 정보 설정 (ConsentVO 데이터로 PatientVO 조회)
  380. public override void SetPatientByConsentInfo(string orderDate, string orderType, string orderDeptCd, string cretno)
  381. {
  382. PatientVO[] patientVOList = this.hospitalWebService.GetPatientInfo(commandControl.CurrentTargetPatient.PatientCode,
  383. orderDate.Replace("-", ""),
  384. orderType,
  385. orderDeptCd,
  386. cretno
  387. );
  388. if (patientVOList == null || patientVOList.Length == 0)
  389. {
  390. throw new UserException(string.Format(Properties.Resources.msg_error_get_patient
  391. , consentMain.ConsentExecuteInfo["patientNo"]));
  392. }
  393. else
  394. {
  395. PatientVO vo = patientVOList[0];
  396. commandControl.CurrentTargetPatient = new TargetPatient();
  397. SetTargetPatientInfo(vo);
  398. }
  399. }
  400. }
  401. }