ConsentSelectTabPageAll.cs 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934
  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.Drawing;
  12. using System.Collections.Generic;
  13. using System.ComponentModel;
  14. using System.Windows.Forms;
  15. using System.Configuration;
  16. using CLIP.eForm.Consent.UI.ConsentSvcRef;
  17. using ClipSoft.eForm.Base.Dialog;
  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> 2016-07-01 : 최초작성</p>
  32. /// <p>----------------------------------------------------------------------------------------</p>
  33. /// </remarks>
  34. public partial class ConsentSelectTabPageAll : UserControl {
  35. private ConsentSvcRef.ConsentSvcSoapClient consentWebService = null;
  36. private IConsentMain consentMain = null;
  37. private ConsentCommandCtrl commandControl = null;
  38. private string searchStartDate = string.Empty;
  39. public ConsentSelectTabPageAll() {
  40. InitializeComponent();
  41. }
  42. private void ConsentSelectTabPageAll_Load(object sender, EventArgs e) {
  43. Boolean isInWpfDesignerMode = (LicenseManager.UsageMode == LicenseUsageMode.Designtime);
  44. Boolean isInFormsDesignerMode = (System.Diagnostics.Process.GetCurrentProcess().ProcessName == "devenv");
  45. if (isInWpfDesignerMode || isInFormsDesignerMode) {
  46. // is in any designer mode
  47. return;
  48. }
  49. if (this.DesignMode || LicenseManager.UsageMode == LicenseUsageMode.Designtime) {
  50. return;
  51. }
  52. consentMain = ConsentMainControl.GetConsentMainInterface(this);
  53. commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl;
  54. consentWebService = WebMethodCommon.GetConsentWebService(consentMain.PluginExecuteInfo["consentSvcUrl"]);
  55. this.dateTimePickerEndDate.Value = DateTime.Now;
  56. this.dateTimePickerStartDate.Value = DateTime.Now.AddMonths(-1);
  57. InitDataGrid();
  58. BindDataGridRows();
  59. }
  60. public void InitDataGrid() {
  61. this.dataGridViewConsentSelectResult.DataSource = null;
  62. this.dataGridViewConsentSelectResult.Columns.Clear();
  63. // 사용자별
  64. if (rdoUser.Checked) {
  65. // dbs227, 일괄저장 기능
  66. // 이벤트 해재
  67. this.dataGridViewConsentSelectResult.ColumnHeaderMouseClick -= dataGridViewConsentSelectResult_ColumnHeaderMouseClick;
  68. this.dataGridViewConsentSelectResult.CellMouseClick -= dataGridViewConsentSelectResult_CellClick;
  69. // 이벤트 추가
  70. this.dataGridViewConsentSelectResult.ColumnHeaderMouseClick += new DataGridViewCellMouseEventHandler(this.dataGridViewConsentSelectResult_ColumnHeaderMouseClick);
  71. //this.dataGridViewConsentSelectResult.RowPostPaint += new DataGridViewRowPostPaintEventHandler(this.dataGridViewConsentSelectResult_RowPostPaint);
  72. // 체크박스 컬럼을 추가
  73. CommonUtil.AddNewCheckBoxColumnToDataGridView(this.dataGridViewConsentSelectResult, "□", "colCheck", false, 30, DataGridViewContentAlignment.MiddleCenter);
  74. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "OCRTAG", "ocrTag", true, 100);
  75. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "등록번호", "pid", true);
  76. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "동의서명", "formName", true, 180);
  77. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "상태", "consentState", true, 60, DataGridViewContentAlignment.MiddleCenter);
  78. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "작성자", "modifyUserNm", true, 70, DataGridViewContentAlignment.MiddleCenter);
  79. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "작성일시", "modifyDatetime", true, 120, DataGridViewContentAlignment.MiddleCenter);
  80. // 사용자에게 표시하지 않을 컬럼
  81. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "성명", "PatientName", false);
  82. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "인덱스", "idx", false);
  83. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "서식번호", "formId", false);
  84. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "서식코드", "formCode", false);
  85. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "서식출력명", "formPrntNm", false);
  86. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "출력매수", "printCnt", false);
  87. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "마스터RID", "consentMstRid", false);
  88. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "작성자 ID", "modifyUserId", false);
  89. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "부서 약어", "deptEngName", false);
  90. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "certPass", "certPass", false);
  91. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "생성일자", "createDatetime", false);
  92. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "진료일자", "clnDate", false);
  93. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "cretNo", "cretNo", false);
  94. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "ordType", "ordType", false);
  95. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "부서코드", "deptCd", false);
  96. }
  97. // 환자별
  98. else {
  99. // debug
  100. // dbs227, 일괄저장 기능
  101. // 이벤트 해재
  102. this.dataGridViewConsentSelectResult.ColumnHeaderMouseClick -= dataGridViewConsentSelectResult_ColumnHeaderMouseClick;
  103. this.dataGridViewConsentSelectResult.CellMouseClick -= dataGridViewConsentSelectResult_CellClick;
  104. // 이벤트 추가
  105. this.dataGridViewConsentSelectResult.ColumnHeaderMouseClick += new DataGridViewCellMouseEventHandler(this.dataGridViewConsentSelectResult_ColumnHeaderMouseClick);
  106. dataGridViewConsentSelectResult.CellMouseClick += new DataGridViewCellMouseEventHandler(this.dataGridViewConsentSelectResult_CellClick);
  107. // 체크박스 컬럼을 추가
  108. CommonUtil.AddNewCheckBoxColumnToDataGridView(this.dataGridViewConsentSelectResult, "□", "colCheck", false, 30, DataGridViewContentAlignment.MiddleCenter);
  109. // 사용자에게 표시할 컬럼
  110. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "OCRTAG", "ocrTag", true, 100);
  111. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "동의서명", "formName", true, 180);
  112. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "등록번호", "pid", true);
  113. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "상태", "consentState", true, 60, DataGridViewContentAlignment.MiddleCenter);
  114. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "작성자", "modifyUserNm", true, 70, DataGridViewContentAlignment.MiddleCenter);
  115. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "작성일시", "modifyDatetime", true, 120, DataGridViewContentAlignment.MiddleCenter);
  116. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "담당교수", "mainDrId", true);
  117. // 사용자에게 표시하지 않을 컬럼
  118. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "성명", "patientName", false);
  119. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "인덱스", "idx", false);
  120. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "서식번호", "formId", false);
  121. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "서식코드", "formCode", false);
  122. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "서식출력명", "formPrntNm", false);
  123. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "출력매수", "printCnt", false);
  124. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "마스터RID", "consentMstRid", false);
  125. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "작성자 ID", "modifyUserId", false);
  126. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "부서 약어", "deptEngName", false);
  127. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "certPass", "certPass", false);
  128. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "생성일자", "createDatetime", false);
  129. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "진료일자", "clnDate", false);
  130. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "cretNo", "cretNo", false);
  131. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "ordType", "ordType", false);
  132. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "부서코드", "deptCd", false);
  133. }
  134. }
  135. private void dataGridViewConsentSelectResult_CellClick(object sender, DataGridViewCellMouseEventArgs e) {
  136. if (e.RowIndex < 0 || e.ColumnIndex < 0) {
  137. return;
  138. }
  139. if (e.ColumnIndex == 0) {
  140. DataGridViewRow curRow = dataGridViewConsentSelectResult.Rows[e.RowIndex];
  141. var value = curRow.Cells["colCheck"].Value;
  142. Boolean checkValue = false;
  143. if (value == null || !(Boolean) value) {
  144. checkValue = false;
  145. } else {
  146. checkValue = true;
  147. }
  148. curRow.Cells[e.ColumnIndex].Value = !checkValue;
  149. }
  150. }
  151. /// <summary>
  152. /// dbs227, 일괄저장 추가
  153. /// 체크박스 이벤트 처리
  154. /// </summary>
  155. /// <param name="sender"></param>
  156. /// <param name="e"></param>
  157. private void dataGridViewConsentSelectResult_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) {
  158. if (e.ColumnIndex == 0 && e.RowIndex == -1) {
  159. bool chkStatus = false;
  160. if (dataGridViewConsentSelectResult.Columns[0].HeaderText.Equals("□")) {
  161. dataGridViewConsentSelectResult.Columns[0].HeaderText = "☑";
  162. chkStatus = true;
  163. } else {
  164. dataGridViewConsentSelectResult.Columns[0].HeaderText = "□";
  165. }
  166. foreach (DataGridViewRow r in dataGridViewConsentSelectResult.Rows) {
  167. r.Cells["colCheck"].Value = chkStatus;
  168. }
  169. dataGridViewConsentSelectResult.RefreshEdit();
  170. }
  171. }
  172. #region 검색 조건에 따른 환자의 동의서 조회
  173. /// <summary>
  174. /// 동의서 목록 조회
  175. /// </summary>
  176. public void BindDataGridRows() {
  177. try {
  178. if (this.consentMain == null) consentMain = ConsentMainControl.GetConsentMainInterface(this);
  179. if (this.commandControl == null) commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl;
  180. if (this.consentWebService == null) this.consentWebService = WebMethodCommon.GetConsentWebService(consentMain.PluginExecuteInfo["consentSvcUrl"]);
  181. string patientCode = string.Empty;
  182. if (commandControl.CurrentTargetPatient != null && !string.IsNullOrEmpty(commandControl.CurrentTargetPatient.pid)) {
  183. patientCode = commandControl.CurrentTargetPatient.pid;
  184. }
  185. string userId = string.Empty;
  186. if (rdoUser.Checked) {
  187. userId = consentMain.ConsentExecuteInfo["loginUserId"];
  188. }
  189. if (!patientCode.Equals(string.Empty) || !userId.Equals(string.Empty)) {
  190. if (this.dateTimePickerStartDate.Value > this.dateTimePickerEndDate.Value) {
  191. this.dateTimePickerStartDate.Value = DateTime.Today - TimeSpan.FromDays(30);
  192. this.dateTimePickerEndDate.Value = DateTime.Today;
  193. }
  194. // 이전 진료일로 검색일자 설정
  195. if (string.IsNullOrEmpty(searchStartDate)) {
  196. if (commandControl.CurrentTargetPatient != null && !string.IsNullOrEmpty(commandControl.CurrentTargetPatient.clnDate)) {
  197. //searchStartDate = string.Format("{0}-{1}-{2}", commandControl.CurrentTargetPatient.clnDate.Substring(0, 4), commandControl.CurrentTargetPatient.clnDate.Substring(4, 2), commandControl.CurrentTargetPatient.clnDate.Substring(6, 2));
  198. } else {
  199. //searchStartDate = consentMain.PluginExecuteInfo["ConsentSearchStartDate"];
  200. }
  201. }
  202. this.dateTimePickerStartDate.Value = DateTime.Now.AddMonths(-1);
  203. string sDate = this.dateTimePickerStartDate.Value.ToShortDateString().Replace("-", "");
  204. string eDate = this.dateTimePickerEndDate.Value.ToShortDateString().Replace("-", "");
  205. string consentState = GetCheckConsentState();
  206. // 조회조건이 불충분하면 조회하지 않는다.
  207. if (string.IsNullOrEmpty(consentState)) {
  208. return;
  209. }
  210. ConsentVO[] resultData = null;
  211. resultData = consentWebService.GetConsentList(patientCode
  212. , userId
  213. , sDate
  214. , eDate
  215. , consentState
  216. , consentMain.ConsentExecuteInfo["dutinstcd"]);
  217. if (resultData == null) {
  218. return;
  219. }
  220. // 진료일 표시 형식 변경
  221. //foreach (ConsentVO v in resultData) {
  222. // if (v.ClnDate.Length == 8) {
  223. // v.ClnDate = v.ClnDate.Substring(0, 4) + "-" + v.ClnDate.Substring(4, 2) + "-" + v.ClnDate.Substring(6, 2);
  224. // }
  225. //}
  226. this.dataGridViewConsentSelectResult.DataSource = new SortableBindingList<ConsentVO>(resultData);
  227. // 목록 조회 후 자동 선택 기능 제외
  228. consentMain.ClearPreviewConsent(true);
  229. /*
  230. ConsentVO vo = GetCurrentConsentVO(0);
  231. if (vo != null) {
  232. ExecutePreviewWithSelectedConsent(vo);
  233. } else {
  234. consentMain.ClearPreviewConsent(true);
  235. }
  236. */
  237. } else {
  238. // dbs227, 발행리스트 시작일자를 한달전으로 설정
  239. //this.dateTimePickerStartDate.Value = DateTime.Now.AddMonths(-1);
  240. }
  241. } catch (Exception ex) {
  242. MessageBox.Show(this, ex.Message);
  243. }
  244. }
  245. /// <summary>
  246. /// 검색할 동의서 상태의 값을 반환한다
  247. /// </summary>
  248. /// <returns>현재 체크박스에 선택된 값을 String 타입으로 반환, ex) "ALL" or "'UNFINISHED','TEMP'"</returns>
  249. private string GetCheckConsentState() {
  250. string consentState = "";
  251. if (this.checkBoxAll.Checked) {
  252. consentState = "ALL";
  253. } else {
  254. if (this.checkBoxUnfinished.Checked)
  255. consentState += ((consentState.Length > 0) ? "," : "") + "'" + this.checkBoxUnfinished.Tag + "'";
  256. if (this.checkBoxTemp.Checked)
  257. consentState += ((consentState.Length > 0) ? "," : "") + "'" + this.checkBoxTemp.Tag + "'";
  258. if (this.checkBoxElectronicCmp.Checked)
  259. consentState += ((consentState.Length > 0) ? "," : "") + "'" + this.checkBoxElectronicCmp.Tag + "'";
  260. if (this.checkBoxCertifyCmp.Checked)
  261. consentState += ((consentState.Length > 0) ? "," : "") + "'" + this.checkBoxCertifyCmp.Tag + "'";
  262. if (this.checkBoxPaperOut.Checked)
  263. consentState += ((consentState.Length > 0) ? "," : "") + "'" + this.checkBoxPaperOut.Tag + "'";
  264. if (this.checkBoxVerbal.Checked)
  265. consentState += ((consentState.Length > 0) ? "," : "") + "'" + this.checkBoxVerbal.Tag + "'";
  266. }
  267. return consentState;
  268. }
  269. #endregion
  270. #region ConsentState 확인
  271. private static bool IsConsentStateTempSave(ConsentVO vo) {
  272. if (vo.consentState.ToUpper().Equals("TEMP") || vo.consentState.ToUpper().Equals("VERBAL")) {
  273. return true;
  274. }
  275. return false;
  276. }
  277. private static bool IsConsentStatePrintOut(ConsentVO vo) {
  278. return vo.consentState.ToUpper().Equals("PAPER_OUT");
  279. }
  280. private static bool IsConsentStateElectronicComplete(ConsentVO vo) {
  281. return vo.consentState.ToUpper().Equals("ELECTR_CMP");
  282. }
  283. private static bool IsConsentStateCertifyComplete(ConsentVO vo) {
  284. return vo.consentState.ToUpper().Equals("CERTIFY_CMP");
  285. }
  286. private static bool IsConsentStateUnfinished(ConsentVO vo) {
  287. return vo.consentState.ToUpper().Equals("UNFINISHED");
  288. }
  289. #endregion
  290. #region 체크박스 이벤트
  291. private void checkBoxAll_CheckedChanged(object sender, EventArgs e) {
  292. if (this.checkBoxAll.Checked == true) {
  293. this.checkBoxUnfinished.Checked = false;
  294. this.checkBoxTemp.Checked = false;
  295. this.checkBoxElectronicCmp.Checked = false;
  296. this.checkBoxCertifyCmp.Checked = false;
  297. this.checkBoxPaperOut.Checked = false;
  298. }
  299. }
  300. private void checkBoxUnfinished_CheckedChanged(object sender, EventArgs e) {
  301. if (this.checkBoxUnfinished.Checked == true && this.checkBoxAll.Checked == true) {
  302. this.checkBoxAll.Checked = false;
  303. }
  304. }
  305. private void checkBoxTemp_CheckedChanged(object sender, EventArgs e) {
  306. if (this.checkBoxTemp.Checked == true && this.checkBoxAll.Checked == true) {
  307. this.checkBoxAll.Checked = false;
  308. }
  309. }
  310. private void checkBoxElectronicCmp_CheckedChanged(object sender, EventArgs e) {
  311. if (this.checkBoxElectronicCmp.Checked == true && this.checkBoxAll.Checked == true) {
  312. this.checkBoxAll.Checked = false;
  313. }
  314. }
  315. private void checkBoxCertifyCmp_CheckedChanged(object sender, EventArgs e) {
  316. if (this.checkBoxCertifyCmp.Checked == true && this.checkBoxAll.Checked == true) {
  317. this.checkBoxAll.Checked = false;
  318. }
  319. }
  320. private void checkBoxPaperOut_CheckedChanged(object sender, EventArgs e) {
  321. if (this.checkBoxPaperOut.Checked == true && this.checkBoxAll.Checked == true) {
  322. this.checkBoxAll.Checked = false;
  323. }
  324. }
  325. #endregion
  326. #region 조회버튼 클릭 이벤트
  327. /// <summary>
  328. /// 동의서 목록 조회
  329. /// </summary>
  330. /// <param name="sender">The source of the event.</param>
  331. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  332. private void buttonConsentSelect_Click(object sender, EventArgs e) {
  333. buttonConsentSelect.Enabled = false;
  334. Application.DoEvents();
  335. string checkState = GetCheckConsentState();
  336. if (checkState.Length > 0) {
  337. if (!string.IsNullOrEmpty(searchStartDate)) {
  338. searchStartDate = this.dateTimePickerStartDate.Value.ToShortDateString();
  339. }
  340. try {
  341. InitDataGrid();
  342. BindDataGridRows();
  343. } catch (Exception ex) {
  344. throw ex;
  345. }
  346. } else {
  347. MessageBox.Show("조회할 동의서 상태를 1개 이상 선택하세요");
  348. }
  349. buttonConsentSelect.Enabled = true;
  350. }
  351. #endregion
  352. #region 동의서 미리보기
  353. //선택된 Row의 ConsentVO 객체를 반환한다.
  354. private ConsentVO GetCurrentConsentVO(int rowIndex) {
  355. ConsentVO vo = null;
  356. if (rowIndex < 0) {
  357. return vo;
  358. }
  359. if (dataGridViewConsentSelectResult != null && dataGridViewConsentSelectResult.Rows.Count > 0) {
  360. this.dataGridViewConsentSelectResult.Rows[rowIndex].Selected = true;
  361. //this.dataGridViewConsentSelectResult.CurrentCell = this.dataGridViewConsentSelectResult.Rows[rowIndex].Cells[0];
  362. vo = this.dataGridViewConsentSelectResult.Rows[rowIndex].DataBoundItem as ConsentVO;
  363. }
  364. return vo;
  365. }
  366. //선택된 ConsentVO 객체를 미리보기 실행한다.
  367. private void ExecutePreviewWithSelectedConsent(ConsentVO vo) {
  368. if (consentMain == null) consentMain = ConsentMainControl.GetConsentMainInterface(this);
  369. if (commandControl == null) commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl;
  370. Cursor currentCursor = this.Cursor;
  371. this.Cursor = Cursors.WaitCursor;
  372. if (rdoUser.Checked) {
  373. //consentMain.ConsentExecuteInfo["patientId"] = vo.PatientCode;
  374. //consentMain.ConsentExecuteInfo["patientOrdtype"] = vo.VisitType;
  375. //consentMain.ConsentExecuteInfo["patientClnDept"] = vo.ClnDate.Replace("-", "");
  376. //consentMain.ConsentExecuteInfo["patientClnDept"] = vo.ClnDeptCd;
  377. //consentMain.ConsentExecuteInfo["cretno"] = vo.Cretno.ToString();
  378. //consentMain.ConsentExecuteInfo["opRsrvNo"] = vo.OpRsrvNo;
  379. consentMain.SetPatientInfo();
  380. }
  381. commandControl.CurrentPreviewConsent = new PreviewConsent {
  382. FormRid = vo.formId.ToString(),
  383. FormCd = vo.formCode.ToString(),
  384. FormName = vo.formName,
  385. FormPrintName = vo.formPrntNm,
  386. PrntCnt = vo.printCnt,
  387. ConsentMstRid = vo.consentMstRid.ToString(),
  388. ConsentState = vo.consentState,
  389. Ocrcode = vo.ocrTag,
  390. certPass = vo.certPass,
  391. InputId = commandControl.CurrentEndUser.userId,
  392. InputNm = commandControl.CurrentEndUser.userName,
  393. ReissueConsentMstRid = 0,
  394. RewriteConsentMstRid = 0,
  395. OpDiagName = commandControl.CurrentTargetPatient.OpDiagName,
  396. VisitType = commandControl.CurrentTargetPatient.ordtype,
  397. OpName = commandControl.CurrentTargetPatient.OpName
  398. };
  399. try {
  400. consentMain.PatientInfoCtrl.SetConsentDocumentName(vo.formName);
  401. // 임시저장 서식 호출
  402. //if (commandControl.CurrentPreviewConsent.ConsentState.Equals("임시")) {
  403. // commandControl.ShowTempSaveConsent(consentMain);
  404. //}
  405. switch (commandControl.CurrentPreviewConsent.ConsentState) {
  406. case "임시":
  407. commandControl.ShowTempSaveConsent(consentMain);
  408. break;
  409. case "인증":
  410. string pid = commandControl.CurrentTargetPatient.pid;
  411. string ordDd = commandControl.CurrentTargetPatient.clnDate;
  412. string cretNo = commandControl.CurrentTargetPatient.cretno;
  413. string ordType = commandControl.CurrentTargetPatient.ordtype;
  414. string recDd = vo.createDatetime;
  415. string userId = commandControl.CurrentEndUser.userId;
  416. recDd = recDd.Split(' ')[0].Replace("-", "");
  417. SingleReturnData srd = this.consentWebService.ReUseCertifyConsentFlag(pid, ordDd, cretNo, ordType, recDd, userId);
  418. string result = srd.responseData;
  419. if (result.Equals("OK")) {
  420. DialogResult dlr = MessageBox.Show("인증저장 된 서식입니다 수정하시겠습니까?", "", MessageBoxButtons.OKCancel);
  421. if (dlr == DialogResult.OK) {
  422. commandControl.ShowTempSaveConsent(consentMain);
  423. commandControl.setCompleteSaveTempButton(false);
  424. } else {
  425. commandControl.ShowCompleteConsent(consentMain);//이미지 호출하는 함수
  426. }
  427. } else {
  428. commandControl.ShowCompleteConsent(consentMain);//이미지 호출하는 함수
  429. }
  430. break;
  431. case "확인":
  432. commandControl.ShowTempSaveConsent(consentMain);
  433. break;
  434. default:
  435. break;
  436. }
  437. //if (IsConsentStateTempSave(vo) || IsConsentStateElectronicComplete(vo)) { // 임시저장 or 작성완료
  438. // commandControl.ShowTempSaveConsent(consentMain);
  439. //} else if (IsConsentStatePrintOut(vo)) { // 출력
  440. // if (this.dataGridViewConsentSelectResult.SelectedRows.Count > 0 &&
  441. // this.dataGridViewConsentSelectResult.SelectedRows[0].Tag != null &&
  442. // this.dataGridViewConsentSelectResult.SelectedRows[0].Tag.Equals("reissueTarget")) {
  443. // // TODO 재출력 기능 사용하지 않음. 요구사항 확인 필요
  444. // //재출력 하는 경우
  445. // //commandControl.CurrentPreviewConsent.ReissueConsentMstRid = vo.ConsentMstRid;
  446. // commandControl.CurrentPreviewConsent.RewriteConsentMstRid = 0;
  447. // //CheckClnDateInfo(vo);
  448. // commandControl.PreviewConsent(consentMain);
  449. // } else {
  450. // //CheckClnDateInfo(vo);
  451. // commandControl.PreviewConsent(consentMain);
  452. // }
  453. //} else if (IsConsentStateCertifyComplete(vo)) { // 인증저장
  454. // commandControl.ShowCompleteConsent(consentMain);//이미지 호출하는 함수
  455. //} else if (IsConsentStateUnfinished(vo)) { //미작성
  456. // //CheckClnDateInfo(vo);
  457. // commandControl.PreviewConsent(consentMain); // consent_data에 데이터가 없을때 사용하는 함수
  458. //}
  459. } catch (Exception e){
  460. throw e;
  461. } finally {
  462. this.Cursor = currentCursor;
  463. }
  464. }
  465. //동의서의 처방일자와 생성번호 등의 정보가 현재 정보와 일치하지 않은 경우, 미리보기를 위해서 데이터를 재조회한다.
  466. private void CheckClnDateInfo(ConsentVO vo) {
  467. //bool bSame = true;
  468. //if (!vo.ClnDate.Replace("-", "").Equals(commandControl.CurrentTargetPatient.clnDate.Replace("-", "")))
  469. // bSame = false;
  470. //if (!vo.Cretno.ToString().Equals(commandControl.CurrentTargetPatient.cretno))
  471. // bSame = false;
  472. //if (!vo.ClnDeptCd.Equals(commandControl.CurrentTargetPatient.clnDeptCode))
  473. // bSame = false;
  474. //if (!vo.VisitType.Equals(commandControl.CurrentTargetPatient.VisitType))
  475. // bSame = false;
  476. //if (bSame == false) {
  477. // //동의서 맵핑 정보를 상단의 선택된 진료일과 작성자 정보로 한다.
  478. // consentMain.PatientInfoCtrl.SetPatientByConsentInfo(vo.ClnDate.Replace("-", ""),
  479. // vo.VisitType,
  480. // vo.ClnDeptCd,
  481. // vo.Cretno.ToString());
  482. //}
  483. }
  484. #endregion
  485. #region 그리드 이벤트
  486. /*
  487. private void dataGridViewConsentSelectResult_CellClick(object sender, DataGridViewCellEventArgs e)
  488. {
  489. ConsentVO vo = GetCurrentConsentVO(e.RowIndex);
  490. if (vo != null)
  491. {
  492. IConsentMain consentMain = ConsentMainControl.GetConsentMainInterface(this);
  493. consentMain.preParamClean();
  494. ExecutePreviewWithSelectedConsent(vo);
  495. }
  496. }
  497. */
  498. /// <summary>
  499. /// dataGridViewConsentSelectResult 그리드 컨트롤의 셀 우클릭 메뉴 생성
  500. /// </summary>
  501. /// <param name="sender">The source of the event.</param>
  502. /// <param name="e">The <see cref="DataGridViewCellContextMenuStripNeededEventArgs"/> instance containing the event data.</param>
  503. private void dataGridViewConsentSelectResult_CellContextMenuStripNeeded(object sender, DataGridViewCellContextMenuStripNeededEventArgs e) {
  504. // 대가대 병원 사용하지 않는 실행 옵션
  505. //if (consentMain.ConsentExecuteInfo["readOnly"].Equals("Y")) {
  506. // return;
  507. //}
  508. if (e.RowIndex > -1 && this.dataGridViewConsentSelectResult.Rows[e.RowIndex].Selected == true) {
  509. ConsentVO vo = GetCurrentConsentVO(e.RowIndex);
  510. if (vo.consentState.Equals("임시")) {
  511. ContextMenuStrip strip = new ContextMenuStrip();
  512. // 임시저장의 경우 삭제메뉴를 보여준다
  513. if (vo.consentState.Equals("임시")) {
  514. // dbs227, 삭제 기능 제거
  515. ToolStripMenuItem deleteRecord = new ToolStripMenuItem {
  516. Text = "삭제"
  517. };
  518. strip.Items.Add(deleteRecord);
  519. deleteRecord.Click += new EventHandler(deleteRecord_Click);
  520. // 출력의 경우 재출력 메뉴를 보여준다
  521. }
  522. //else if (vo.consentState.Equals("출력")) {
  523. // ToolStripMenuItem reprintRecord = new ToolStripMenuItem {
  524. // Text = "재출력"
  525. // };
  526. // strip.Items.Add(reprintRecord);
  527. // reprintRecord.Click += new EventHandler(reprintRecord_Click);
  528. //}
  529. e.ContextMenuStrip = strip;
  530. }
  531. }
  532. }
  533. /// <summary>
  534. /// dataGridViewConsentSelectResult 그리드 컨트롤의 CellMouseDoubleClick 이벤트 핸들러
  535. /// </summary>
  536. /// <param name="sender">The source of the event.</param>
  537. /// <param name="e">The <see cref="DataGridViewCellEventArgs"/> instance containing the event data.</param>
  538. private void dataGridViewConsentSelectResult_CellMouseDoubleClick(object sender, DataGridViewCellEventArgs e) {
  539. if (consentMain == null) consentMain = ConsentMainControl.GetConsentMainInterface(this);
  540. if (commandControl == null) commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl;
  541. // dbs227, 셀 클릭 시 더블클릭 인식되어 작동되는 경우 오류
  542. if (e.RowIndex < 0) {
  543. return;
  544. }
  545. ConsentVO vo = GetCurrentConsentVO(e.RowIndex);
  546. // 현재 선택된 동의서를 가져온다
  547. // dbs227, 출력된 동의서는 미리보기를 하지 않는다
  548. if (vo.consentState.Equals("PAPER_OUT")) {
  549. MessageBox.Show(String.Format(Properties.Resources.msg_printed_consent),
  550. String.Format(Properties.Resources.title_printed_consent));
  551. return;
  552. }
  553. //MessageBox.Show("asdfasdf");
  554. if (vo != null) {
  555. // startFormCd 를 초기화 한다
  556. consentMain.preParamClean();
  557. // 동의서 미리보기
  558. ExecutePreviewWithSelectedConsent(vo);
  559. string otps = "";
  560. if (vo.consentState.Equals("임시") || vo.consentState.Equals("확인")) {
  561. otps += "FILE_SAVE=true";
  562. if (vo.consentState.Equals("임시")) {
  563. otps += ";FILE_TEMP_SAVE=true;FILE_TEMP_SAVE2=true";
  564. } else {
  565. otps += ";FILE_TEMP_SAVE=false;FILE_TEMP_SAVE2=false";
  566. }
  567. } else if (vo.consentState.Equals("인증")) {
  568. otps += "FILE_SAVE=true;FILE_TEMP_SAVE=false;FILE_TEMP_SAVE2=false";
  569. } else {
  570. otps += "FILE_SAVE=true;FILE_TEMP_SAVE=false;FILE_TEMP_SAVE2=false";
  571. }
  572. consentMain.setDualViewerButtonOtps(otps);
  573. switch (vo.consentState) {
  574. case "임시": // 임시
  575. case "확인": // 확인
  576. // 듀얼뷰어 상태일 때 동의서 로드
  577. RunConsentDualView();
  578. break;
  579. }
  580. }
  581. /*
  582. ConsentVO vo = GetCurrentConsentVO(e.RowIndex);
  583. if (vo != null)
  584. {
  585. if (vo.ConsentState.ToLower().Equals("electr_cmp") || vo.ConsentState.ToLower().Equals("certify_cmp") || vo.ConsentState.ToLower().Equals("paper_out"))
  586. {
  587. }
  588. else
  589. {
  590. //미작성, 임서저장 상태일때 마우스 더블클릭을 하면 양면으로 동의서 보여줌
  591. RunConsentDualView();
  592. }
  593. }
  594. */
  595. }
  596. /// <summary>
  597. /// 동의서 뷰어에 동의서 로드
  598. /// </summary>
  599. private void RunConsentDualView() {
  600. if (this.consentMain == null) consentMain = ConsentMainControl.GetConsentMainInterface(this);
  601. if (this.commandControl == null) commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl;
  602. commandControl.RunConsentDualView();
  603. }
  604. /// <summary>
  605. /// 동의서 삭제 이벤트 핸들러
  606. /// </summary>
  607. /// <param name="sender">The source of the event.</param>
  608. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  609. private void deleteRecord_Click(object sender, EventArgs e) {
  610. if (consentMain == null) consentMain = ConsentMainControl.GetConsentMainInterface(this);
  611. if (commandControl == null) commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl;
  612. bool bDel = true;
  613. ReasonForUseN reasonForUseN = new ReasonForUseN(bDel);
  614. if (reasonForUseN.ShowDialog() == DialogResult.OK) {
  615. string reason = reasonForUseN.GetReasonForUseN();
  616. reasonForUseN.Close();
  617. int updated = 0;
  618. if (this.dataGridViewConsentSelectResult.SelectedRows.Count != 0) {
  619. Cursor currentCursor = this.Cursor;
  620. try {
  621. this.Cursor = Cursors.WaitCursor;
  622. //동의서 삭제 처리를 위해서 재발행MstID에 값을 넣는다.
  623. ConsentVO vo = GetCurrentConsentVO(this.dataGridViewConsentSelectResult.SelectedRows[0].Index);
  624. // TODO dbs227 삭제 오류
  625. if (commandControl.CurrentPreviewConsent == null) {
  626. commandControl.CurrentPreviewConsent = new PreviewConsent {
  627. FormRid = vo.formId.ToString(),
  628. FormCd = vo.formCode.ToString(),
  629. FormName = vo.formName,
  630. FormPrintName = vo.formPrntNm,
  631. PrntCnt = vo.printCnt,
  632. ConsentMstRid = vo.consentMstRid.ToString(),
  633. ConsentState = vo.consentState,
  634. Ocrcode = vo.ocrTag,
  635. certPass = vo.certPass,
  636. InputId = commandControl.CurrentEndUser.userId,
  637. InputNm = commandControl.CurrentEndUser.userName,
  638. ReissueConsentMstRid = 0,
  639. RewriteConsentMstRid = 0,
  640. OpDiagName = commandControl.CurrentTargetPatient.OpDiagName,
  641. VisitType = commandControl.CurrentTargetPatient.ordtype,
  642. OpName = commandControl.CurrentTargetPatient.OpName
  643. };
  644. }
  645. //commandControl.CurrentPreviewConsent.ReissueConsentMstRid = vo.ConsentMstRid;
  646. // 미작성 동의서 삭제
  647. updated = consentMain.ConsentCommandCtrl.DeleteRecordOfDeleteConsent(reason);
  648. // 동의서 목록 재조회 (미작성 동의서 삭제, 임시저장용 재조회, 인쇄출력용 재조회, 저장용(저장후 닫힘이 아닌 경우))
  649. consentMain.ConsentListCtrl.InquiryConsentData(-1);
  650. } catch (Exception ex) {
  651. throw ex;
  652. } finally {
  653. this.Cursor = currentCursor;
  654. }
  655. if(updated > 0) {
  656. MessageBox.Show(string.Format(Properties.Resources.msg_consent_record_deleted)
  657. , string.Format(Properties.Resources.msg_caption_confirm),
  658. MessageBoxButtons.OK, MessageBoxIcon.Information);
  659. }
  660. }
  661. }
  662. }
  663. /// <summary>
  664. /// 재출력 클릭
  665. /// </summary>
  666. /// <param name="sender">The source of the event.</param>
  667. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  668. private void reprintRecord_Click(object sender, EventArgs e) {
  669. ConsentVO vo = GetCurrentConsentVO(this.dataGridViewConsentSelectResult.SelectedRows[0].Index);
  670. if (vo != null) {
  671. this.dataGridViewConsentSelectResult.SelectedRows[0].Tag = "reissueTarget"; // 재출력 대상 마킹
  672. ExecutePreviewWithSelectedConsent(vo);
  673. this.dataGridViewConsentSelectResult.SelectedRows[0].Tag = null;
  674. //재출력을 하는 경우, 바로 출력이 되도록 한다.
  675. if (consentMain == null) consentMain = ConsentMainControl.GetConsentMainInterface(this);
  676. if (commandControl == null) commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl;
  677. commandControl.PrintConsentDocument();
  678. }
  679. }
  680. #endregion
  681. public void clearSearchStartDate() {
  682. searchStartDate = string.Empty;
  683. }
  684. private void dataGridViewConsentSelectResult_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e) {
  685. foreach (DataGridViewRow row in dataGridViewConsentSelectResult.Rows) {
  686. if (!string.IsNullOrEmpty(row.Cells["ConsentState"].Value.ToString())) {
  687. if (row.Cells["ConsentState"].Value.ToString().ToUpper() == "UNFINISHED") {
  688. row.DefaultCellStyle.ForeColor = System.Drawing.Color.Red;
  689. }
  690. }
  691. }
  692. }
  693. private void dataGridViewConsentSelectResult_CellClick(object sender, DataGridViewCellEventArgs e) {
  694. }
  695. /// <summary>
  696. /// 선택된 동의서를 가져온다
  697. /// </summary>
  698. /// <returns>선택된 동의서 목록</returns>
  699. public List<ConsentVO> getConfirmedCheckedConsentList() {
  700. List<ConsentVO> consents = new List<ConsentVO>();
  701. foreach (DataGridViewRow row in dataGridViewConsentSelectResult.Rows) {
  702. if (Convert.ToBoolean(row.Cells["colCheck"].Value)) {
  703. ConsentVO consent = row.DataBoundItem as ConsentVO;
  704. if (!consent.consentState.Equals("ELECTR_CMP")) {
  705. return null;
  706. }
  707. consents.Add(consent);
  708. }
  709. }
  710. return consents;
  711. }
  712. /// <summary>
  713. /// 선택 초기화
  714. /// </summary>
  715. private void ClearCheckBox() {
  716. bool chkStatus = false;
  717. dataGridViewConsentSelectResult.Columns[0].HeaderText = "□";
  718. foreach (DataGridViewRow r in dataGridViewConsentSelectResult.Rows) {
  719. r.Cells["colCheck"].Value = chkStatus;
  720. }
  721. dataGridViewConsentSelectResult.RefreshEdit();
  722. }
  723. /// <summary>
  724. /// dbs227, 일괄저장
  725. /// 선택된 환자들의 저장 상태를 일괄저장으로 변경한다.
  726. /// </summary>
  727. /// <param name="sender"></param>
  728. /// <param name="e"></param>
  729. private void saveAllCertify_Click(object sender, EventArgs e) {
  730. // 선택된 동의서 목록을 가져온다.
  731. List<ConsentVO> lists = getConfirmedCheckedConsentList();
  732. if (lists == null || lists.Count < 1) {
  733. MessageBox.Show("동의서를 선택하거나 확인 저장 동의서만 선택해 주세요.");
  734. //ClearCheckBox();
  735. return;
  736. }
  737. String mstRids = "";
  738. String ocrTags = "";
  739. int i = 0;
  740. foreach (ConsentVO consent in lists) {
  741. if (i != 0) {
  742. mstRids += ",";
  743. ocrTags += ",";
  744. }
  745. /// TODO 구현 필요
  746. //mstRids += "'" + consent.ConsentMstRid + "'";
  747. //ocrTags += "'" + consent.OcrNumber + "'";
  748. i++;
  749. }
  750. // 선택된 동의서 상태값을 바꿔 준다.
  751. String result = consentWebService.updateCertifyComplete(mstRids, ocrTags, consentMain.ConsentExecuteInfo["dutinstcd"]);
  752. if (result.Equals("Y")) {
  753. MessageBox.Show("일괄저장 하였습니다.");
  754. ClearCheckBox();
  755. try {
  756. this.checkBoxAll.Checked = true;
  757. InitDataGrid();
  758. BindDataGridRows();
  759. } catch (Exception ex) {
  760. throw ex;
  761. }
  762. }
  763. }
  764. /// <summary>
  765. /// 사용자 라디오 버튼 클릭 시 일괄저장을 보여준다
  766. /// </summary>
  767. /// <param name="sender"></param>
  768. /// <param name="e"></param>
  769. private void rdoUser_CheckedChanged(object sender, EventArgs e) {
  770. if (!rdoUser.Checked) {
  771. saveAllCertify.Visible = false;
  772. }
  773. // 현재 로그인 한 사용자가 의사라면 일괄저장 버튼을 활성화 하여 준다.
  774. else if (rdoUser.Checked && commandControl.CurrentEndUser.jobkindcd.Equals("0330")) {
  775. // saveAllCertify 버튼 보이도록
  776. //saveAllCertify.Visible = true;
  777. }
  778. }
  779. }
  780. }