ConsentSelectTabConsentSearch.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  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:ConsentSelectTabConsentSearch.cs
  8. //
  9. #endregion
  10. using System;
  11. using System.ComponentModel;
  12. using System.Drawing;
  13. using System.Windows.Forms;
  14. using CLIP.eForm.Consent.UI.ConsentSvcRef;
  15. using CLIP.eForm.Consent.UI.HospitalSvcRef;
  16. using System.Linq;
  17. using System.Diagnostics;
  18. namespace CLIP.eForm.Consent.UI {
  19. /// <summary>
  20. /// 동의서 찾기 탭 클래스
  21. /// </summary>
  22. /// <remarks>
  23. /// <p>[설계자]</p>
  24. /// <p> 클립소프트 연구소 홍지철 (jchong@clipsoft.co.kr)</p>
  25. /// <p>[원본 작성자]</p>
  26. /// <p> 클립소프트 기술부 4팀 이창훈 (chlee@clipsoft.co.kr)</p>
  27. /// <p>[수정 작성자]</p>
  28. /// <p> 클립소프트 기술부 이인희</p>
  29. /// <p>----------------------------------------------------------------------------------------</p>
  30. /// <p>[HISTORY]</p>
  31. /// <p> 2015-07-30 : 최초작성</p>
  32. /// <p>----------------------------------------------------------------------------------------</p>
  33. /// </remarks>
  34. public partial class ConsentSelectTabConsentSearch : UserControl {
  35. private ConsentSvcRef.ConsentSvcSoapClient consentWebService = null;
  36. private HospitalSvcRef.HospitalSvcSoapClient hospitalWebService = null;
  37. private IConsentMain consentMain = null;
  38. private ConsentCommandCtrl commandControl = null;
  39. public ConsentSelectTabConsentSearch() {
  40. InitializeComponent();
  41. }
  42. private void ConsentSelectTabConsentSearch_Load(object sender, EventArgs e) {
  43. if (this.DesignMode || LicenseManager.UsageMode == LicenseUsageMode.Designtime) {
  44. return;
  45. }
  46. consentMain = ConsentMainControl.GetConsentMainInterface(this);
  47. commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl;
  48. consentWebService = WebMethodCommon.GetConsentWebService(consentMain.PluginExecuteInfo["consentSvcUrl"]);
  49. hospitalWebService = WebMethodCommon.GetHospitalWebService(consentMain.PluginExecuteInfo["hospitalSvcUrl"]);
  50. //InitComboBoxConsentType();
  51. // 동의서 찾기에서 기본 카테고리를 해당 기관으로 기본적으로 설정되게끔 변경
  52. //comboBoxConsentType.SelectedValue = string.Format("EMA_{0}", consentMain.ConsentExecuteInfo["dutinstcd"]);
  53. InitComboBoxConsentSubType("");
  54. InitDataGrid();
  55. }
  56. /// <summary>
  57. /// 초기 DataGrid 항목 설정
  58. /// </summary>
  59. private void InitDataGrid() {
  60. this.dataGridViewConsentSelectResult.AllowUserToAddRows = false;
  61. this.dataGridViewConsentSelectResult.CellDoubleClick += new DataGridViewCellEventHandler(dataGridViewConsentSelectResult_CellDoubleClick);
  62. // 화면에 표시할 컬럼
  63. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "동의서명", "FormName", true, 250);
  64. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "동의서 코드", "formCode", true, 100);
  65. //CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "동의서 종류", "FullCategoryName", true, 150);
  66. //CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "동의서 고유코드", "FormGuid", false);
  67. //CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "전자서명 여부", "EsignYn", false);
  68. // 화면에 표시하지 않을 컬럼
  69. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "주치의", "mainDrId", false);
  70. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "동의서 고유ID", "formId", false);
  71. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "동의서 출력 이름", "formPrntNm", false);
  72. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "출력 매수", "printCnt", false);
  73. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "환자명", "pid", false);
  74. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "인덱스", "idx", false);
  75. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "부서 영문명", "deptEngName", false);
  76. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "동의서 상태", "consentState", false);
  77. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "동의서 마스터 RID", "consentMstRid", false);
  78. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "OCRTAG", "ocrTag", false);
  79. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "환자이름", "patientName", false);
  80. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "수정자ID", "modifyUserId", false);
  81. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "수정자 이름", "modifyUserNm", false);
  82. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "수정일자", "modifyDatetime", false);
  83. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "certPass", "certPass", false);
  84. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "생성일자", "createDatetime", false);
  85. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "진료일자", "clnDate", false);
  86. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "cretNo", "cretNo", false);
  87. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "ordType", "ordType", false);
  88. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "부서코드", "deptCd", false);
  89. //dataGridViewConsentSelectResult.Columns["idx"].Visible = false;
  90. //dataGridViewConsentSelectResult.Columns["formId"].Visible = false;
  91. //dataGridViewConsentSelectResult.Columns["formPrntNm"].Visible = false;
  92. //dataGridViewConsentSelectResult.Columns["printCnt"].Visible = false;
  93. //dataGridViewConsentSelectResult.Columns["pid"].Visible = false;
  94. //dataGridViewConsentSelectResult.Columns["deptEngName"].Visible = false;
  95. //dataGridViewConsentSelectResult.Columns["consentState"].Visible = false;
  96. //dataGridViewConsentSelectResult.Columns["consentMstRid"].Visible = false;
  97. //dataGridViewConsentSelectResult.Columns["ocrTag"].Visible = false;
  98. //dataGridViewConsentSelectResult.Columns["patientName"].Visible = false;
  99. //dataGridViewConsentSelectResult.Columns["modifyUserId"].Visible = false;
  100. //dataGridViewConsentSelectResult.Columns["modifyUserNm"].Visible = false;
  101. //dataGridViewConsentSelectResult.Columns["modifyDatetime"].Visible = false;
  102. }
  103. #region 동의서 카테고리 바인딩
  104. /// <summary>
  105. /// 동의서 하위 분류 조회 및 바인딩
  106. /// </summary>
  107. /// <param name="parentValue">The parent value.</param>
  108. private void InitComboBoxConsentSubType(string parentValue) {
  109. // 주어진 parentValue 로 GetCategoryForDropdown API 호출
  110. CategoryForDropdownVO[] arrayData = consentWebService.GetCategoryForDropdown();
  111. this.comboBoxConsentSubType.DisplayMember = "CategoryName";
  112. this.comboBoxConsentSubType.ValueMember = "CategoryId";
  113. this.comboBoxConsentSubType.DataSource = arrayData;
  114. }
  115. #endregion
  116. #region 동의서 조회하고 그리드 바인딩
  117. /// <summary>
  118. /// textBoxConsentSearchKeyWord 키보드 입력 이벤트
  119. /// </summary>
  120. /// <param name="sender">The source of the event.</param>
  121. /// <param name="e">The <see cref="KeyEventArgs"/> instance containing the event data.</param>
  122. private void textBoxConsentSearchKeyWord_KeyDown(object sender, KeyEventArgs e) {
  123. // 엔터키 입력 시 조회 버튼 클릭 이벤트 수행
  124. if (e.KeyCode == Keys.Enter) {
  125. this.buttonConsentSelect.PerformClick();
  126. }
  127. }
  128. /// <summary>
  129. /// 조회 버튼 클릭 이벤트
  130. /// </summary>
  131. /// <param name="sender">The source of the event.</param>
  132. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  133. private void buttonConsentSelect_Click(object sender, EventArgs e) {
  134. buttonConsentSelect.Enabled = false;
  135. Application.DoEvents();
  136. IConsentMain consentMain = ConsentMainControl.GetConsentMainInterface(this);
  137. ConsentCommandCtrl commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl;
  138. consentMain.preParamClean();
  139. GetConsentBySearch();
  140. buttonConsentSelect.Enabled = true;
  141. }
  142. /// <summary>
  143. /// 동의서 검색
  144. /// </summary>
  145. private void GetConsentBySearch() {
  146. Cursor currentCursor = this.Cursor;
  147. try {
  148. this.Cursor = Cursors.WaitCursor;
  149. string keyWord = string.Empty;
  150. keyWord = this.textBoxConsentSearchKeyWord.Text;
  151. //var categoryCode = "";
  152. CategoryForDropdownVO selectedItem = (CategoryForDropdownVO)comboBoxConsentSubType.SelectedItem;
  153. var today = DateTime.Now.ToString("yyyyMMdd");
  154. var categoryId = selectedItem.categoryId.ToString();
  155. if(categoryId.Equals("1") && string.IsNullOrEmpty(keyWord)) {
  156. MessageBox.Show("동의서 분류 및 검색어를 입력해주세요.");
  157. return;
  158. }
  159. if (categoryId.Equals("1")) {
  160. categoryId = string.Empty;
  161. }
  162. //ConsentBySearchVO[] arrayData = consentWebService.GetConsentBySearch(consentType, keyWord, consentMain.ConsentExecuteInfo["dutinstcd"]);
  163. ConsentVO[] arrayData = consentWebService.GetConsentBySearch(categoryId, keyWord, consentMain.ConsentExecuteInfo["dutinstcd"], today);
  164. if (arrayData == null) {
  165. return;
  166. }
  167. this.dataGridViewConsentSelectResult.DataSource = new SortableBindingList<ConsentVO>(arrayData);
  168. } catch (Exception ex) {
  169. throw ex;
  170. } finally {
  171. this.Cursor = currentCursor;
  172. }
  173. }
  174. #endregion
  175. #region 그리드 이벤트
  176. /// <summary>
  177. /// dataGridViewConsentSelectResult 그리드 셀 더블클릭 이벤트
  178. /// </summary>
  179. /// <param name="sender">The source of the event.</param>
  180. /// <param name="e">The <see cref="DataGridViewCellEventArgs"/> instance containing the event data.</param>
  181. private void dataGridViewConsentSelectResult_CellDoubleClick(object sender, DataGridViewCellEventArgs e) {
  182. if (consentMain == null) consentMain = ConsentMainControl.GetConsentMainInterface(this);
  183. if (commandControl == null) commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl;
  184. // dbs227, 셀 클릭 시 더블클릭 인식되어 작동되는 경우 오류
  185. if (e.RowIndex < 0) {
  186. return;
  187. }
  188. ConsentVO vo = GetCurrentConsentSearchVO(e.RowIndex);
  189. if (vo != null) {
  190. // 선택된 동의서가 현재 보여지고 있는 동의서와 다른 경우, 임시 저장 여부 확인
  191. if (/*!consentMain.ConsentExecuteInfo["readOnly"].Equals("Y") &&*/ // 대가대 병원 readonly 기능 사용 안함
  192. !string.IsNullOrEmpty(commandControl.CurrentTargetPatient.pid) &&
  193. commandControl.CurrentPreviewConsent != null && !commandControl.CurrentPreviewConsent.FormRid.Equals(vo.formId.ToString()) &&
  194. (commandControl.CurrentPreviewConsent.ConsentState == string.Empty || commandControl.CurrentPreviewConsent.ConsentState == "TEMP")) {
  195. // dbs227, 임시저장 팝업 사용 안함
  196. //DialogResult result = MessageBox.Show(string.Format(Properties.Resources.msg_confirm_tempsave)
  197. // , string.Format(Properties.Resources.msg_caption_confirm),
  198. // MessageBoxButtons.YesNo, MessageBoxIcon.Information);
  199. //if (result == DialogResult.Yes) {
  200. // consentMain.TempSave();
  201. //}
  202. }
  203. Cursor currentCursor = this.Cursor;
  204. this.Cursor = Cursors.WaitCursor;
  205. ExecutePreviewWithSelectedConsent(vo);
  206. // 듀얼뷰어 상태일 때 동의서 로드
  207. string otps = "";
  208. if (vo.consentState.Equals("임시") || vo.consentState.Equals("확인")) {
  209. otps += "FILE_SAVE=true";
  210. if (vo.consentState.Equals("임시")) {
  211. otps += ";FILE_TEMP_SAVE=true;FILE_TEMP_SAVE2=true";
  212. } else {
  213. otps += ";FILE_TEMP_SAVE=false;FILE_TEMP_SAVE2=false";
  214. }
  215. } else if (vo.consentState.Equals("인증")) {
  216. otps += "FILE_SAVE=true;FILE_TEMP_SAVE=false;FILE_TEMP_SAVE2=false";
  217. } else {
  218. otps += "FILE_SAVE=true;FILE_TEMP_SAVE=false;FILE_TEMP_SAVE2=false";
  219. }
  220. consentMain.setDualViewerButtonOtps(otps);
  221. RunConsentDualView();
  222. this.Cursor = currentCursor;
  223. }
  224. }
  225. private void RunConsentDualView() {
  226. if (this.consentMain == null) consentMain = ConsentMainControl.GetConsentMainInterface(this);
  227. if (this.commandControl == null) commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl;
  228. commandControl.RunConsentDualView();
  229. }
  230. /// <summary>
  231. /// dataGridViewConsentSelectResult 그리드 셀 마우스 우클릭 이벤트
  232. /// </summary>
  233. /// <param name="sender">The source of the event.</param>
  234. /// <param name="e">The <see cref="DataGridViewCellContextMenuStripNeededEventArgs"/> instance containing the event data.</param>
  235. private void dataGridViewConsentSelectResult_CellContextMenuStripNeeded(object sender, DataGridViewCellContextMenuStripNeededEventArgs e) {
  236. if (e.RowIndex >= 0 && this.dataGridViewConsentSelectResult.Rows[e.RowIndex].Selected == true) {
  237. ContextMenuStrip strip = new ContextMenuStrip();
  238. ToolStripMenuItem setItemAdd = new ToolStripMenuItem();
  239. setItemAdd.Text = "즐겨찾기 추가";
  240. strip.Items.Add(setItemAdd);
  241. setItemAdd.Click += new EventHandler(setItemAdd_Click);
  242. e.ContextMenuStrip = strip;
  243. }
  244. }
  245. /// <summary>
  246. /// 선택된 동의서를 개인SET에 등록
  247. /// </summary>
  248. /// <param name="sender">The source of the event.</param>
  249. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  250. private void setItemAdd_Click(object sender, EventArgs e) {
  251. IConsentMain consentMain = ConsentMainControl.GetConsentMainInterface(this);
  252. ConsentCommandCtrl commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl;
  253. if (this.dataGridViewConsentSelectResult.SelectedRows.Count != 0) {
  254. HospitalSvcRef.SingleReturnData result = null;
  255. Cursor currentCursor = this.Cursor;
  256. this.Cursor = Cursors.WaitCursor;
  257. try {
  258. ConsentVO vo = GetCurrentConsentSearchVO(this.dataGridViewConsentSelectResult.SelectedRows[0].Index);
  259. var today = DateTime.Now.ToString("yyyyMMdd");
  260. // 동의서 SET에 추가하는 웹서비스 호출
  261. result = hospitalWebService.SetUserFormSetList(commandControl.CurrentEndUser.userId
  262. , vo.formCode
  263. , consentMain.ConsentExecuteInfo["dutinstcd"]
  264. , today);
  265. } catch (Exception ex){
  266. throw ex;
  267. } finally {
  268. this.Cursor = currentCursor;
  269. }
  270. // 즐겨찾기 추가 성공
  271. if (string.IsNullOrEmpty(result.responseData)) {
  272. MessageBox.Show(string.Format(Properties.Resources.msg_consent_set_add_success)
  273. , string.Format(Properties.Resources.msg_caption_confirm)
  274. , MessageBoxButtons.OK
  275. , MessageBoxIcon.Information);
  276. }
  277. // 즐겨찾기 추가 실패
  278. else {
  279. MessageBox.Show(string.Format(Properties.Resources.msg_consent_set_add_failed)
  280. , string.Format(Properties.Resources.msg_caption_confirm)
  281. , MessageBoxButtons.OK
  282. , MessageBoxIcon.Warning);
  283. }
  284. }
  285. }
  286. #endregion
  287. #region 동의서 미리보기
  288. private ConsentVO GetCurrentConsentSearchVO(int rowIndex) {
  289. ConsentVO vo = null;
  290. if (rowIndex < 0) {
  291. return vo;
  292. }
  293. vo = this.dataGridViewConsentSelectResult.Rows[rowIndex].DataBoundItem as ConsentVO;
  294. return vo;
  295. }
  296. private void ExecutePreviewWithSelectedConsent(ConsentVO vo) {
  297. if (consentMain == null) consentMain = ConsentMainControl.GetConsentMainInterface(this);
  298. if (commandControl == null) commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl;
  299. Cursor currentCursor = this.Cursor;
  300. try {
  301. this.Cursor = Cursors.WaitCursor;
  302. commandControl.CurrentPreviewConsent = new PreviewConsent {
  303. FormRid = vo.formId.ToString(),
  304. FormCd = vo.formCode.ToString(),
  305. FormName = vo.formName,
  306. FormPrintName = vo.formPrntNm,
  307. PrntCnt = vo.printCnt,
  308. ConsentMstRid = "-1",
  309. ConsentState = vo.consentState,
  310. Ocrcode = vo.ocrTag,
  311. InputId = commandControl.CurrentEndUser.userId,
  312. InputNm = commandControl.CurrentEndUser.userName,
  313. ReissueConsentMstRid = 0,
  314. RewriteConsentMstRid = 0,
  315. OpDiagName = commandControl.CurrentTargetPatient.OpDiagName,
  316. VisitType = commandControl.CurrentTargetPatient.ordtype,
  317. OpName = commandControl.CurrentTargetPatient.OpName,
  318. certPass = vo.certPass
  319. };
  320. consentMain.PatientInfoCtrl.SetConsentDocumentName(vo.formPrntNm);
  321. commandControl.PreviewConsent(consentMain);
  322. } catch (Exception e){
  323. throw e;
  324. } finally {
  325. this.Cursor = currentCursor;
  326. }
  327. }
  328. #endregion
  329. private void comboBoxConsentType_DrawItem(object sender, DrawItemEventArgs e) {
  330. ComboBox box = sender as ComboBox;
  331. if (box is null)
  332. return;
  333. e.DrawBackground();
  334. if (e.Index >= 0) {
  335. Graphics g = e.Graphics;
  336. using (Brush brush = ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
  337. ? new SolidBrush(SystemColors.Highlight)
  338. : new SolidBrush(e.BackColor)) {
  339. using (Brush textBrush = new SolidBrush(e.ForeColor)) {
  340. g.FillRectangle(brush, e.Bounds);
  341. g.DrawString(((CategoryForDropdownVO[]) box.DataSource)[e.Index].categoryName,
  342. e.Font,
  343. textBrush,
  344. (float) e.Bounds.X,
  345. (float) (e.Bounds.Y) + 2.34F);
  346. }
  347. }
  348. }
  349. e.DrawFocusRectangle();
  350. }
  351. private void comboBoxConsentType_MeasureItem(object sender, MeasureItemEventArgs e) {
  352. e.ItemHeight = 20;
  353. }
  354. private void comboBoxConsentSubType_DrawItem(object sender, DrawItemEventArgs e) {
  355. ComboBox box = sender as ComboBox;
  356. if (box is null)
  357. return;
  358. e.DrawBackground();
  359. if (e.Index >= 0) {
  360. Graphics g = e.Graphics;
  361. using (Brush brush = ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
  362. ? new SolidBrush(SystemColors.Highlight)
  363. : new SolidBrush(e.BackColor)) {
  364. using (Brush textBrush = new SolidBrush(e.ForeColor)) {
  365. g.FillRectangle(brush, e.Bounds);
  366. g.DrawString(((CategoryForDropdownVO[]) box.DataSource)[e.Index].categoryName,
  367. e.Font,
  368. textBrush,
  369. (float) e.Bounds.X,
  370. (float) (e.Bounds.Y) + 2.34F);
  371. }
  372. }
  373. }
  374. e.DrawFocusRectangle();
  375. }
  376. private void comboBoxConsentSubType_MeasureItem(object sender, MeasureItemEventArgs e) {
  377. e.ItemHeight = 20;
  378. }
  379. }
  380. }