ConsentSelectTabPageConsentSet.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  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:ConsentSelectTabPageConsentSet.cs
  8. //
  9. #endregion
  10. using System;
  11. using System.ComponentModel;
  12. using System.Windows.Forms;
  13. using CLIP.eForm.Consent.UI.HospitalSvcRef;
  14. using CLIP.eForm.Consent.UI.ConsentSvcRef;
  15. using ClipSoft.eForm.Base.Dialog;
  16. using System.Linq;
  17. namespace CLIP.eForm.Consent.UI {
  18. /// <summary>
  19. /// 동의서 SET 탭 클래스
  20. /// </summary>
  21. /// <remarks>
  22. /// <p>[설계자]</p>
  23. /// <p> 클립소프트 연구소 홍지철 (jchong@clipsoft.co.kr)</p>
  24. /// <p>[원본 작성자]</p>
  25. /// <p> 클립소프트 기술부 4팀 이창훈 (chlee@clipsoft.co.kr)</p>
  26. /// <p>[수정 작성자]</p>
  27. /// <p> 클립소프트 기술부 이인희</p>
  28. /// <p>----------------------------------------------------------------------------------------</p>
  29. /// <p>[HISTORY]</p>
  30. /// <p> 2016-06-28 : 최초작성</p>
  31. /// <p>----------------------------------------------------------------------------------------</p>
  32. /// </remarks>
  33. public partial class ConsentSelectTabPageConsentSet : UserControl {
  34. private HospitalSvcRef.HospitalSvcSoapClient hospitalWebService = null;
  35. private ConsentSvcRef.ConsentSvcSoapClient consentWebService = null;
  36. private IConsentMain consentMain = null;
  37. private ConsentCommandCtrl commandControl = null;
  38. public ConsentSelectTabPageConsentSet() {
  39. InitializeComponent();
  40. }
  41. private void initResources() {
  42. consentMain = ConsentMainControl.GetConsentMainInterface(this);
  43. commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl;
  44. hospitalWebService = WebMethodCommon.GetHospitalWebService(consentMain.PluginExecuteInfo["hospitalSvcUrl"]);
  45. consentWebService = WebMethodCommon.GetConsentWebService(consentMain.PluginExecuteInfo["consentSvcUrl"]);
  46. }
  47. private void ConsentSelectTabPageConsentSet_Load(object sender, EventArgs e) {
  48. if (this.DesignMode || LicenseManager.UsageMode == LicenseUsageMode.Designtime) {
  49. return;
  50. }
  51. consentMain = ConsentMainControl.GetConsentMainInterface(this);
  52. commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl;
  53. hospitalWebService = WebMethodCommon.GetHospitalWebService(consentMain.PluginExecuteInfo["hospitalSvcUrl"]);
  54. consentWebService = WebMethodCommon.GetConsentWebService(consentMain.PluginExecuteInfo["consentSvcUrl"]);
  55. if (commandControl.CurrentEndUser != null) {
  56. InitConsentSetTreeView();
  57. }
  58. }
  59. /// <summary>
  60. /// 즐겨찾기 트리 노드 생성 (개인 SET)
  61. /// </summary>
  62. public void InitConsentSetTreeView() {
  63. if (consentMain == null || commandControl == null || hospitalWebService == null) {
  64. initResources();
  65. }
  66. //개인SET과 진료과SET인 경우
  67. //ConsentSetVO[] arrayData = this.hospitalWebService.GetConsentSetList(commandControl.CurrentEndUser.userId,
  68. // commandControl.CurrentEndUser.deptcd);
  69. // 동의서 SET 조회
  70. //ConsentSetVO[] arrayData = this.consentWebService.GetConsentSetList(commandControl.CurrentEndUser.userId, consentMain.ConsentExecuteInfo["dutinstcd"]);
  71. var today = DateTime.Now.ToString("yyyyMMdd");
  72. ConsentVO[] arrayData = consentWebService.GetConsentSetList(commandControl.CurrentEndUser.userId, consentMain.ConsentExecuteInfo["dutinstcd"], today);
  73. this.treeViewConsentSet.Nodes.Clear();
  74. TreeNode personalTreeNode = AddFirstChildNodeOfTreeView("PERS", "개인 SET", 1);
  75. //TreeNode deptTreeNode = AddFirstChildNodeOfTreeView("DEPT", "진료과 SET", 2);
  76. // 조회 결과를 동의서 node 에 추가
  77. if (arrayData != null) {
  78. foreach (ConsentVO vo in arrayData) {
  79. AddConsentNode(personalTreeNode, vo);
  80. //if (vo.SetAuth.Equals("PERS_SET")) {
  81. // AddConsentNode(personalTreeNode, vo);
  82. //}
  83. //else if (vo.SetAuth.Equals("DEPT_SET"))
  84. //{
  85. // AddDeptsConsentSet(vo);
  86. //}
  87. }
  88. }
  89. this.treeViewConsentSet.Nodes["PERS"].ExpandAll();
  90. //this.treeViewConsentSet.Nodes["DEPT"].Expand();
  91. //사용자의 부서에 해당하는 동의서들만 펼친다.
  92. //if (this.treeViewConsentSet.Nodes["DEPT"].Nodes.ContainsKey(commandControl.CurrentEndUser.deptcd))
  93. //{
  94. // this.treeViewConsentSet.Nodes["DEPT"].Nodes[commandControl.CurrentEndUser.deptcd].ExpandAll();
  95. //}
  96. }
  97. /// <summary>
  98. /// 동의서 미리보기
  99. /// </summary>
  100. private void ExecutePreviewWithSelectedConsent() {
  101. ConsentVO vo = this.treeViewConsentSet.SelectedNode.Tag as ConsentVO;
  102. if (vo == null) {
  103. return;
  104. }
  105. if (consentMain == null) consentMain = ConsentMainControl.GetConsentMainInterface(this);
  106. if (commandControl == null) commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl;
  107. // 선택된 동의서가 현재 보여지고 있는 동의서와 다른 경우, 임시 저장 여부 확인
  108. if (!string.IsNullOrEmpty(commandControl.CurrentTargetPatient.pid) &&
  109. commandControl.CurrentPreviewConsent != null && !commandControl.CurrentPreviewConsent.FormRid.Equals(vo.formId.ToString()) &&
  110. (commandControl.CurrentPreviewConsent.ConsentState == string.Empty || commandControl.CurrentPreviewConsent.ConsentState == "TEMP")) {
  111. // dbs227, 임시저장 팝업 사용 안함
  112. //DialogResult result = MessageBox.Show(string.Format(Properties.Resources.msg_confirm_tempsave)
  113. // , string.Format(Properties.Resources.msg_caption_confirm),
  114. // MessageBoxButtons.YesNo, MessageBoxIcon.Information);
  115. //if (result == DialogResult.Yes) {
  116. // consentMain.TempSave();
  117. //}
  118. }
  119. consentMain.preParamClean();
  120. PatientInfoCtrl patient = consentMain.PatientInfoCtrl as PatientInfoCtrl;
  121. Cursor currentCursor = this.Cursor;
  122. this.Cursor = Cursors.WaitCursor;
  123. commandControl.CurrentPreviewConsent = new PreviewConsent {
  124. FormRid = vo.formId.ToString(),
  125. FormCd = vo.formCode.ToString(),
  126. FormName = vo.formName,
  127. FormPrintName = vo.formPrntNm,
  128. PrntCnt = vo.printCnt,
  129. ConsentMstRid = vo.consentMstRid.ToString(),
  130. ConsentState = vo.consentState,
  131. Ocrcode = vo.ocrTag,
  132. certPass = vo.certPass,
  133. InputId = commandControl.CurrentEndUser.userId,
  134. InputNm = commandControl.CurrentEndUser.userName,
  135. ReissueConsentMstRid = 0,
  136. RewriteConsentMstRid = 0,
  137. OpDiagName = commandControl.CurrentTargetPatient.OpDiagName,
  138. VisitType = commandControl.CurrentTargetPatient.ordtype,
  139. OpName = commandControl.CurrentTargetPatient.OpName
  140. };
  141. //동의서 맵핑 정보를 상단의 선택된 진료일과 작성자 정보로 한다.
  142. consentMain.PatientInfoCtrl.SetBasicPatientInfo();
  143. consentMain.PatientInfoCtrl.SetConsentDocumentName(vo.formName);
  144. commandControl.PreviewConsent(consentMain);
  145. this.Cursor = currentCursor;
  146. }
  147. #region 트리 노드 추가
  148. /// <summary>
  149. /// parent node 를 생성하여 treeViewConsentSet 에 추가한다
  150. /// </summary>
  151. /// <param name="treeNodeName">Name of the tree node.</param>
  152. /// <param name="treeNodeLabel">The tree node label.</param>
  153. /// <param name="imageIndex">Index of the image.</param>
  154. /// <returns></returns>
  155. private TreeNode AddFirstChildNodeOfTreeView(string treeNodeName, string treeNodeLabel, int imageIndex) {
  156. TreeNode parentNode = new TreeNode(treeNodeLabel);
  157. parentNode.Name = treeNodeName;
  158. parentNode.ImageIndex = imageIndex;
  159. parentNode.SelectedImageIndex = imageIndex;
  160. this.treeViewConsentSet.Nodes.Add(parentNode);
  161. return parentNode;
  162. }
  163. /// <summary>
  164. /// 주어진 parentTreeNode에 자식노드를 추가한다
  165. /// </summary>
  166. /// <param name="parentTreeNode">부모 노드</param>
  167. /// <param name="vo">추가할 자식 노드</param>
  168. private void AddConsentNode(TreeNode parentTreeNode, ConsentVO vo) {
  169. TreeNode childTreeNode = new TreeNode();
  170. childTreeNode.Text = vo.formName; // + "[" + consentSet.FormCd + "]";
  171. childTreeNode.ImageIndex = 0;
  172. childTreeNode.SelectedImageIndex = 0;
  173. childTreeNode.Tag = vo;
  174. parentTreeNode.Nodes.Add(childTreeNode);
  175. ContextMenuStrip strip = new ContextMenuStrip();
  176. ToolStripMenuItem setItemDelete = new ToolStripMenuItem();
  177. setItemDelete.Text = "즐겨찾기 삭제";
  178. strip.Items.Add(setItemDelete);
  179. setItemDelete.Click += new EventHandler(setItemDelete_Click);
  180. childTreeNode.ContextMenuStrip = strip;
  181. }
  182. /*
  183. private void AddDeptsConsentSet(ConsentSetVO vo)
  184. {
  185. TreeNode deptNode = this.treeViewConsentSet.Nodes["DEPT"];
  186. if (deptNode.Nodes.ContainsKey(vo.DeptCd))
  187. {
  188. AddConsentNode(deptNode.Nodes[vo.DeptCd], vo);
  189. }
  190. else
  191. {
  192. //해당 부서코드 노드를 생성 한다.
  193. TreeNode deptSubNode = new TreeNode(vo.DeptNm);
  194. deptSubNode.Name = vo.DeptCd;
  195. deptSubNode.ImageIndex = 3;
  196. deptSubNode.SelectedImageIndex = 3;
  197. deptNode.Nodes.Add(deptSubNode);
  198. //부서코드 노드에 동의서들을 추가한다.
  199. AddConsentNode(deptSubNode, vo);
  200. }
  201. }
  202. */
  203. #endregion
  204. #region 트리 컨트롤 이벤트
  205. /// <summary>
  206. /// treeViewConsentSet 더블 클릭 이벤트
  207. /// </summary>
  208. /// <param name="sender">The source of the event.</param>
  209. /// <param name="e">The <see cref="TreeNodeMouseClickEventArgs"/> instance containing the event data.</param>
  210. private void treeViewConsentSet_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) {
  211. if (this.treeViewConsentSet.SelectedNode.Tag != null) {
  212. // 환자정보 체크
  213. // 환자정보가 없을 때 서버 request 후 오류 발생 후 프로그램 종료 발생
  214. if (commandControl == null) commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl;
  215. var visitType = commandControl.CurrentTargetPatient?.ordtype ?? null;
  216. // 방문 타입이 없다면 메시지 박스를 보여준다
  217. if (visitType == null) {
  218. MessageBoxDlg.Show(this, string.Format(Properties.Resources.msg_error_no_patient),
  219. string.Format(Properties.Resources.msg_caption_warn),
  220. MessageBoxButtons.OK,
  221. MessageBoxIcon.Information);
  222. return;
  223. }
  224. ConsentVO vo = this.treeViewConsentSet.SelectedNode.Tag as ConsentVO;
  225. // 미리보기 수행
  226. ExecutePreviewWithSelectedConsent();
  227. string otps = "";
  228. if (vo.consentState.Equals("임시") || vo.consentState.Equals("확인")) {
  229. otps += "FILE_SAVE=true";
  230. if (vo.consentState.Equals("임시")) {
  231. otps += ";FILE_TEMP_SAVE=true;FILE_TEMP_SAVE2=true";
  232. } else {
  233. otps += ";FILE_TEMP_SAVE=false;FILE_TEMP_SAVE2=false";
  234. }
  235. }
  236. else if (vo.consentState.Equals("인증")) {
  237. otps += "FILE_SAVE=true;FILE_TEMP_SAVE=false;FILE_TEMP_SAVE2=false";
  238. }
  239. else {
  240. otps += "FILE_SAVE=true;FILE_TEMP_SAVE=false;FILE_TEMP_SAVE2=false";
  241. }
  242. consentMain.setDualViewerButtonOtps(otps);
  243. // 듀얼뷰어 상태일 때 동의서 로드
  244. RunConsentDualView();
  245. //switch (vo.consentState) {
  246. // case "임시": // 임시
  247. // case "확인": // 확인
  248. // // 듀얼뷰어 상태일 때 동의서 로드
  249. // RunConsentDualView();
  250. // break;
  251. //}
  252. /*
  253. ConsentSetVO vo = this.treeViewConsentSet.SelectedNode.Tag as ConsentSetVO;
  254. if (vo != null)
  255. {
  256. RunConsentDualView();
  257. }
  258. */
  259. }
  260. }
  261. /// <summary>
  262. /// 트리 노드 선택해서 SET 삭제
  263. /// </summary>
  264. /// <param name="sender">The source of the event.</param>
  265. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  266. private void setItemDelete_Click(object sender, EventArgs e) {
  267. ConsentVO vo = this.treeViewConsentSet.SelectedNode.Tag as ConsentVO;
  268. if (vo == null) {
  269. MessageBox.Show("마우스 좌클릭하여 선택 한 후 삭제하세요.");
  270. return;
  271. }
  272. IConsentMain consentMain = ConsentMainControl.GetConsentMainInterface(this);
  273. Cursor currentCursor = this.Cursor;
  274. try {
  275. this.Cursor = Cursors.WaitCursor;
  276. // 동의서 SET에 추가하는 웹서비스 콜
  277. hospitalWebService.DelUserFormSetList(vo.idx.ToString(), commandControl.CurrentEndUser.userId, vo.formCode, consentMain.ConsentExecuteInfo["dutinstcd"]);
  278. this.Cursor = currentCursor;
  279. } catch (Exception ex) {
  280. throw ex;
  281. } finally {
  282. InitConsentSetTreeView();
  283. this.Cursor = currentCursor;
  284. }
  285. MessageBox.Show(string.Format(Properties.Resources.msg_consent_set_deleted)
  286. , string.Format(Properties.Resources.msg_caption_confirm), MessageBoxButtons.OK, MessageBoxIcon.Information);
  287. }
  288. private void RunConsentDualView() {
  289. if (this.consentMain == null) consentMain = ConsentMainControl.GetConsentMainInterface(this);
  290. if (this.commandControl == null) commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl;
  291. commandControl.RunConsentDualView();
  292. }
  293. #endregion
  294. }
  295. }