ConsentSelectTabPageUnfinished.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  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:ConsentSelectTabPageAll.cs
  8. //
  9. #endregion
  10. using System;
  11. using System.ComponentModel;
  12. using System.Windows.Forms;
  13. using System.Configuration;
  14. using CLIP.eForm.Consent.Dfh.UI.ConsentSvcRef;
  15. namespace CLIP.eForm.Consent.Dfh.UI
  16. {
  17. /// <summary>
  18. /// 동의서 미작성 탭 클래스
  19. /// </summary>
  20. /// <remarks>
  21. /// <p>[설계자]</p>
  22. /// <p> 클립소프트 연구소 홍지철 (jchong@clipsoft.co.kr)</p>
  23. /// <p>[원본 작성자]</p>
  24. /// <p> 클립소프트 기술부 4팀 이창훈 (chlee@clipsoft.co.kr)</p>
  25. /// <p>[수정 작성자]</p>
  26. /// <p> 클립소프트 기술부 이인희</p>
  27. /// <p>----------------------------------------------------------------------------------------</p>
  28. /// <p>[HISTORY]</p>
  29. /// <p> 2016-07-01 : 최초작성</p>
  30. /// <p>----------------------------------------------------------------------------------------</p>
  31. /// </remarks>
  32. public partial class ConsentSelectTabPageUnfinished : UserControl
  33. {
  34. private ConsentSvcRef.ConsentSvcSoapClient consentWebService = null;
  35. private IConsentMain consentMain = null;
  36. private ConsentCommandCtrl commandControl = null;
  37. public ConsentSelectTabPageUnfinished()
  38. {
  39. InitializeComponent();
  40. }
  41. private void ConsentSelectTabPageUnfinished_Load(object sender, EventArgs e)
  42. {
  43. if (this.DesignMode || LicenseManager.UsageMode == LicenseUsageMode.Designtime)
  44. {
  45. return;
  46. }
  47. consentMain = ConsentMainControl.GetConsentMainInterface(this);
  48. commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl;
  49. consentWebService = WebMethodCommon.GetConsentWebService(consentMain.PluginExecuteInfo["consentSvcUrl"]);
  50. InitDataGrid();
  51. }
  52. public void SelectAllUnfinishedConsents(int consentMstRid)
  53. {
  54. InitDataGrid();
  55. BindDataGridRows(consentMstRid);
  56. }
  57. private void InitDataGrid()
  58. {
  59. this.dataGridViewConsentSelectResult.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
  60. this.dataGridViewConsentSelectResult.MultiSelect = false;
  61. this.dataGridViewConsentSelectResult.AutoGenerateColumns = false;
  62. this.dataGridViewConsentSelectResult.AllowUserToAddRows = false;
  63. this.dataGridViewConsentSelectResult.CellClick += new DataGridViewCellEventHandler(dataGridViewConsentSelectResult_CellClick);
  64. this.dataGridViewConsentSelectResult.Columns.Clear();
  65. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "동의서명", "ConsentName", true, 250);
  66. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "상태", "ConsentStateDisp", true, 60);
  67. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "처방명", "OrderNm", true, 100);
  68. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "내원/입원일", "ClnDate", true, 100);
  69. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "진료과", "ClnDeptNm", true, 100);
  70. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "처방의", "CosignDcName", true, 80);
  71. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "병동", "Ward", true, 100);
  72. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "작성일시", "CreateDateTime", true, 120);
  73. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "작성자", "CreateUserName", true, 80);
  74. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "생성번호", "Cretno", false);
  75. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "상태코드", "ConsentState", false);
  76. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "처방구분코드", "OrderNo", false);
  77. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "동의서 고유코드", "FormGuid", false);
  78. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "동의서 고유RID", "FormRid", false);
  79. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "동의서 작성 마스터 RID", "ConsentMstRid", false);
  80. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "처방코드", "OrderCd", false);
  81. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "OCR코드", "OcrNumber", false);
  82. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "병실", "RoomCd", false);
  83. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "동의서코드", "FormCd", false);
  84. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "내원구분", "VisitType", false);
  85. }
  86. #region 미작성, 임시저장 동의서 조회
  87. public void BindDataGridRows(int consentMstRid)
  88. {
  89. if (this.consentMain == null) consentMain = ConsentMainControl.GetConsentMainInterface(this);
  90. if (this.commandControl == null) commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl;
  91. if (this.consentWebService == null) this.consentWebService = WebMethodCommon.GetConsentWebService(consentMain.PluginExecuteInfo["consentSvcUrl"]);
  92. try
  93. {
  94. if (commandControl.CurrentTargetPatient != null && !string.IsNullOrEmpty(commandControl.CurrentTargetPatient.PatientCode))
  95. {
  96. string patientCode = commandControl.CurrentTargetPatient.PatientCode;
  97. string sDate = consentMain.PluginExecuteInfo["ConsentSearchStartDate"].Replace("-", "");
  98. string eDate = DateTime.Now.ToShortDateString().Replace("-", "");
  99. string consentState = "'UNFINISHED','TEMP'";
  100. ConsentVO[] resultData = consentWebService.GetConsentList(patientCode, sDate, eDate, consentState, string.Empty);
  101. if (resultData == null)
  102. {
  103. return;
  104. }
  105. this.dataGridViewConsentSelectResult.DataSource = new SortableBindingList<ConsentVO>(resultData);
  106. //초기 전달받은 startFormCd 값이 있는 경우, 폼을 보여준다.
  107. if (consentMain.ConsentExecuteInfo != null
  108. && consentMain.ConsentExecuteInfo.ContainsKey("startFormCd")
  109. && !(string.IsNullOrEmpty(consentMain.ConsentExecuteInfo["startFormCd"])))
  110. {
  111. for (int i = 0; i < resultData.Length; i++)
  112. {
  113. if (((ConsentVO)resultData[i]).FormCd == consentMain.ConsentExecuteInfo["startFormCd"].ToString())
  114. {
  115. ConsentVO vo = GetCurrentConsentVO(i);
  116. if (vo != null)
  117. {
  118. ExecutePreviewWithSelectedConsent(vo);
  119. RunConsentDualView();
  120. }
  121. break;
  122. }
  123. }
  124. }
  125. else if (consentMstRid > 0)
  126. {
  127. for (int i = 0; i < resultData.Length; i++)
  128. {
  129. if (((ConsentVO)resultData[i]).ConsentMstRid == consentMstRid)
  130. {
  131. ConsentVO vo = GetCurrentConsentVO(i);
  132. if (vo != null)
  133. {
  134. ExecutePreviewWithSelectedConsent(vo);
  135. RunConsentDualView();
  136. }
  137. break;
  138. }
  139. }
  140. }
  141. else
  142. {
  143. ConsentVO vo = GetCurrentConsentVO(0);
  144. if (vo != null)
  145. {
  146. ExecutePreviewWithSelectedConsent(vo);
  147. }
  148. }
  149. }
  150. }
  151. catch (Exception ex)
  152. {
  153. throw ex;
  154. }
  155. }
  156. #endregion
  157. #region 동의서 미리보기
  158. //선택된 Row의 ConsentVO 객체를 반환한다.
  159. private ConsentVO GetCurrentConsentVO(int rowIndex)
  160. {
  161. ConsentVO vo = null;
  162. if (rowIndex < 0)
  163. {
  164. return vo;
  165. }
  166. if (dataGridViewConsentSelectResult != null && dataGridViewConsentSelectResult.Rows.Count > 0)
  167. {
  168. this.dataGridViewConsentSelectResult.Rows[rowIndex].Selected = true;
  169. this.dataGridViewConsentSelectResult.CurrentCell = this.dataGridViewConsentSelectResult.Rows[rowIndex].Cells[0];
  170. vo = this.dataGridViewConsentSelectResult.Rows[rowIndex].DataBoundItem as ConsentVO;
  171. }
  172. return vo;
  173. }
  174. //선택된 ConsentVO 객체를 미리보기 실행한다.
  175. private void ExecutePreviewWithSelectedConsent(ConsentVO vo)
  176. {
  177. if (consentMain == null) consentMain = ConsentMainControl.GetConsentMainInterface(this);
  178. if (commandControl == null) commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl;
  179. Cursor currentCursor = this.Cursor;
  180. this.Cursor = Cursors.WaitCursor;
  181. commandControl.CurrentPreviewConsent = new PreviewConsent();
  182. commandControl.CurrentPreviewConsent.FormRid = vo.FormRid.ToString();
  183. commandControl.CurrentPreviewConsent.FormGuid = vo.FormGuid;
  184. commandControl.CurrentPreviewConsent.FormCd = vo.FormCd.ToString();
  185. commandControl.CurrentPreviewConsent.FormName = vo.ConsentName;
  186. commandControl.CurrentPreviewConsent.PrntCnt = vo.PrntCnt;
  187. commandControl.CurrentPreviewConsent.ConsentMstRid = vo.ConsentMstRid.ToString();
  188. commandControl.CurrentPreviewConsent.ConsentState = vo.ConsentState;
  189. commandControl.CurrentPreviewConsent.OrderNo = vo.OrderNo;
  190. commandControl.CurrentPreviewConsent.Ocrcode = vo.OcrNumber;
  191. commandControl.CurrentPreviewConsent.InputId = vo.CreateUserId;
  192. commandControl.CurrentPreviewConsent.InputNm = vo.CreateUserName;
  193. commandControl.CurrentPreviewConsent.ReissueConsentMstRid = 0;
  194. commandControl.CurrentPreviewConsent.RewriteConsentMstRid = 0;
  195. commandControl.CurrentPreviewConsent.VisitType = vo.VisitType;
  196. commandControl.CurrentPreviewConsent.Ocrtagprntyn = vo.OcrTagYN;
  197. consentMain.PatientInfoCtrl.SetConsentDocumentName(vo.ConsentName);
  198. if (vo.ConsentState.ToUpper().Equals("TEMP"))
  199. {
  200. commandControl.ShowTempSaveConsent(consentMain);
  201. }
  202. else if (vo.ConsentState.ToUpper().Equals("UNFINISHED"))
  203. {
  204. CheckClnDateInfo(vo);
  205. commandControl.PreviewConsent(consentMain);
  206. }
  207. this.Cursor = currentCursor;
  208. }
  209. //동의서의 처방일자와 생성번호 등의 정보가 현재 정보와 일치하지 않은 경우, 미리보기를 위해서 데이터를 재조회한다.
  210. private void CheckClnDateInfo(ConsentVO vo)
  211. {
  212. if (consentMain == null) consentMain = ConsentMainControl.GetConsentMainInterface(this);
  213. if (commandControl == null) commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl;
  214. if (commandControl.CurrentTargetPatient == null) return;
  215. bool bSame = true;
  216. if (!string.IsNullOrEmpty(vo.ClnDate) && !vo.ClnDate.Replace("-", "").Equals(commandControl.CurrentTargetPatient.clnDate.Replace("-", "")))
  217. bSame = false;
  218. if (!vo.Cretno.ToString().Equals(commandControl.CurrentTargetPatient.cretno))
  219. bSame = false;
  220. if (!string.IsNullOrEmpty(vo.ClnDeptCd) && !vo.ClnDeptCd.Equals(commandControl.CurrentTargetPatient.clnDeptCode))
  221. bSame = false;
  222. if (!string.IsNullOrEmpty(vo.VisitType) && !vo.VisitType.Equals(commandControl.CurrentTargetPatient.VisitType))
  223. bSame = false;
  224. if (bSame == false)
  225. {
  226. //동의서 맵핑 정보를 상단의 선택된 진료일과 작성자 정보로 한다.
  227. consentMain.PatientInfoCtrl.SetPatientByConsentInfo(vo.ClnDate.Replace("-", ""),
  228. vo.VisitType,
  229. vo.ClnDeptCd,
  230. vo.Cretno.ToString());
  231. }
  232. }
  233. #endregion
  234. #region 그리드 이벤트
  235. private void dataGridViewConsentSelectResult_CellClick(object sender, DataGridViewCellEventArgs e)
  236. {
  237. ConsentVO vo = GetCurrentConsentVO(e.RowIndex);
  238. if (vo != null)
  239. {
  240. IConsentMain consentMain = ConsentMainControl.GetConsentMainInterface(this);
  241. consentMain.preParamClean();
  242. ExecutePreviewWithSelectedConsent(vo);
  243. RunConsentDualView();
  244. }
  245. }
  246. private void dataGridViewConsentSelectResult_CellContextMenuStripNeeded(object sender, DataGridViewCellContextMenuStripNeededEventArgs e)
  247. {
  248. //MessageBox.Show("dataGridViewConsentSelectResult_CellContextMenuStripNeeded");
  249. if (e.RowIndex >= 0 && this.dataGridViewConsentSelectResult.Rows[e.RowIndex].Selected == true)
  250. {
  251. ConsentVO vo = GetCurrentConsentVO(e.RowIndex);
  252. if (commandControl.CurrentPreviewConsent != null)// && commandControl.CurrentPreviewConsent.ConsentMstRid.Equals(this.dataGridViewConsentSelectResult.Rows[e.RowIndex].Index))
  253. {
  254. if (vo.ConsentState.Equals("UNFINISHED") || vo.ConsentState.Equals("TEMP"))
  255. {
  256. ContextMenuStrip strip = new ContextMenuStrip();
  257. if (vo.ConsentState.Equals("UNFINISHED") || vo.ConsentState.Equals("TEMP"))
  258. {
  259. ToolStripMenuItem deleteRecord = new ToolStripMenuItem();
  260. deleteRecord.Text = "삭제";
  261. strip.Items.Add(deleteRecord);
  262. deleteRecord.Click += new EventHandler(deleteRecord_Click);
  263. }
  264. // 임시저장 삭제로직 추가
  265. // 뷰어에 보여지는 동의서 상태가 임시저장일 경우에 보여질 메뉴명과 실행할 함수(deleteRecord_Click : 미작성 삭제하는 로직과 동일한 경우 동일한 함수를 사용하여 처리 가능함)
  266. //if (vo.ConsentState.Equals("TEMP"))
  267. //{
  268. // ToolStripMenuItem deleteRecord = new ToolStripMenuItem();
  269. // deleteRecord.Text = "삭제"; // 메뉴명
  270. // strip.Items.Add(deleteRecord); // 마우스 우클릭에 보여줄 메뉴에 추가
  271. // deleteRecord.Click += new EventHandler(deleteRecord_Click); // 마우스 우클릭 후 메뉴를 선택했을 경우 실행될 함수를 이벤트로 등록
  272. //}
  273. e.ContextMenuStrip = strip;
  274. }
  275. }
  276. }
  277. }
  278. private void dataGridViewConsentSelectResult_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
  279. {
  280. //MessageBox.Show("dataGridViewConsentSelectResult_CellMouseDoubleClick" + e.Button.ToString());
  281. ConsentVO vo = GetCurrentConsentVO(e.RowIndex);
  282. if (vo != null && !e.Button.ToString().Equals("Right"))
  283. {
  284. RunConsentDualView();
  285. }
  286. }
  287. private void RunConsentDualView()
  288. {
  289. if (this.consentMain == null) consentMain = ConsentMainControl.GetConsentMainInterface(this);
  290. if (this.commandControl == null) commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl;
  291. commandControl.RunConsentDualView();
  292. }
  293. //미작성인 경우, 배경색과 글씨색을 눈에 뜨이도록 한다.
  294. private void dataGridViewConsentSelectResult_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
  295. {
  296. foreach (DataGridViewRow row in dataGridViewConsentSelectResult.Rows)
  297. {
  298. if (!string.IsNullOrEmpty(row.Cells["ConsentState"].Value.ToString()))
  299. {
  300. if (row.Cells["ConsentState"].Value.ToString().ToUpper() == "UNFINISHED")
  301. {
  302. row.Cells[0].Style.ForeColor = System.Drawing.Color.Red;
  303. row.Cells[1].Style.ForeColor = System.Drawing.Color.Red;
  304. }
  305. }
  306. }
  307. }
  308. private void deleteRecord_Click(object sender, EventArgs e)
  309. {
  310. if (consentMain == null) consentMain = ConsentMainControl.GetConsentMainInterface(this);
  311. if (commandControl == null) commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl;
  312. bool bDel = true;
  313. ReasonForUseN reasonForUseN = new ReasonForUseN(bDel);
  314. if (reasonForUseN.ShowDialog() == DialogResult.OK)
  315. {
  316. string reason = reasonForUseN.GetReasonForUseN();
  317. reasonForUseN.Close();
  318. if (this.dataGridViewConsentSelectResult.SelectedRows.Count != 0)
  319. {
  320. Cursor currentCursor = this.Cursor;
  321. try
  322. {
  323. this.Cursor = Cursors.WaitCursor;
  324. ConsentVO vo = GetCurrentConsentVO(this.dataGridViewConsentSelectResult.SelectedRows[0].Index);
  325. commandControl.CurrentPreviewConsent.ReissueConsentMstRid = vo.ConsentMstRid;
  326. consentMain.ConsentCommandCtrl.DeleteRecordOfDeleteConsent(reason);
  327. consentMain.ConsentListCtrl.InquiryConsentData(-1);
  328. this.Cursor = currentCursor;
  329. MessageBox.Show(string.Format(Properties.Resources.msg_consent_record_deleted)
  330. , string.Format(Properties.Resources.msg_caption_confirm), MessageBoxButtons.OK, MessageBoxIcon.Information);
  331. }
  332. catch (Exception ex)
  333. {
  334. this.Cursor = currentCursor;
  335. throw ex;
  336. }
  337. }
  338. }
  339. }
  340. #endregion
  341. }
  342. }