ConsentSelectTabPageAll.cs 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935
  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. // dbs227, 발행리스트 시작일자를 한달전으로 설정
  57. //this.dateTimePickerStartDate.Value = DateTime.Now.AddMonths(-1);
  58. this.dateTimePickerStartDate.Value = DateTime.Now.AddDays(-7);
  59. InitDataGrid();
  60. BindDataGridRows();
  61. }
  62. private void InitDataGrid() {
  63. this.dataGridViewConsentSelectResult.DataSource = null;
  64. this.dataGridViewConsentSelectResult.Columns.Clear();
  65. //this.dataGridViewConsentSelectResult.ColumnHeaderMouseClick -= dataGridViewConsentSelectResult_ColumnHeaderMouseClick;
  66. //this.dataGridViewConsentSelectResult.CellMouseClick -= dataGridViewConsentSelectResult_CellClick;
  67. // 이벤트 추가
  68. //this.dataGridViewConsentSelectResult.ColumnHeaderMouseClick += new DataGridViewCellMouseEventHandler(this.dataGridViewConsentSelectResult_ColumnHeaderMouseClick);
  69. // 그리드에 표시할 컬럼
  70. CommonUtil.insertColumnToDataGridView(0, this.dataGridViewConsentSelectResult, "등록번호", "pid", true, 60, DataGridViewContentAlignment.MiddleCenter);
  71. CommonUtil.insertColumnToDataGridView(1, this.dataGridViewConsentSelectResult, "성명", "patientName", true, 60, DataGridViewContentAlignment.MiddleCenter);
  72. CommonUtil.insertColumnToDataGridView(2, this.dataGridViewConsentSelectResult, "OCRTAG", "ocrTag", true, 80);
  73. CommonUtil.insertColumnToDataGridView(3, this.dataGridViewConsentSelectResult, "동의서명", "formName", true, 180);
  74. CommonUtil.insertColumnToDataGridView(4, this.dataGridViewConsentSelectResult, "진료/\n입원일", "clnDate", true, 80, DataGridViewContentAlignment.MiddleCenter);
  75. CommonUtil.insertColumnToDataGridView(5, this.dataGridViewConsentSelectResult, "진료과명", "clnDeptNm", true);
  76. CommonUtil.insertColumnToDataGridView(6, this.dataGridViewConsentSelectResult, "병동코드", "wardCd", true);
  77. CommonUtil.insertColumnToDataGridView(7, this.dataGridViewConsentSelectResult, "병실코드", "roomCd", true);
  78. CommonUtil.insertColumnToDataGridView(8, this.dataGridViewConsentSelectResult, "상태", "consentStateDisp", true, 60, DataGridViewContentAlignment.MiddleCenter);
  79. CommonUtil.insertColumnToDataGridView(9, this.dataGridViewConsentSelectResult, "작성자\n아이디", "createUserId", true);
  80. CommonUtil.insertColumnToDataGridView(10, this.dataGridViewConsentSelectResult, "작성자", "createUserName", true);
  81. CommonUtil.insertColumnToDataGridView(11, this.dataGridViewConsentSelectResult, "수정자\n아이디", "modifyUserId", false);
  82. CommonUtil.insertColumnToDataGridView(12, this.dataGridViewConsentSelectResult, "수정자", "modifyUserName", true, 70, DataGridViewContentAlignment.MiddleCenter);
  83. CommonUtil.insertColumnToDataGridView(13, this.dataGridViewConsentSelectResult, "작성일시", "createDatetime", true, 120, DataGridViewContentAlignment.MiddleCenter);
  84. // 그리드에 표시하지 않을 컬럼
  85. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "서식 코드", "formCd", false);
  86. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "출력 매수", "prntCnt", false);
  87. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "울력전용", "prntOnly", false);
  88. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "서식 출력명", "formPrintName", false);
  89. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "의사 전용 서식 여부", "DrOnly", false);
  90. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "기관번호", "instCd", false);
  91. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "진료과코드", "clnDeptCd", false);
  92. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "주치의", "mainDrId", false);
  93. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "수술진단명", "opDiagName", false);
  94. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "수술명", "opName", false);
  95. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "수술예약번호", "opRsrvNo", false);
  96. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "동의서 고유코드", "consentMstRid", false);
  97. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "OCRTAG 출력여부", "ocrTagYN", false);
  98. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "서식 ID", "formId", false);
  99. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "consentState", "consentState", false);
  100. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "ordtype", "ordType", false);
  101. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "cretNo", "cretNo", false);
  102. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "certUseYn", "certUseYn", false);
  103. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "userDrFlag", "userDrFlag", false);
  104. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "linkFormCd", "linkFormCd", false);
  105. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "jinjeongCd", "jinjeongCd", false);
  106. }
  107. //private void dataGridViewConsentSelectResult_CellClick(object sender, DataGridViewCellMouseEventArgs e) {
  108. // if (e.RowIndex < 0 || e.ColumnIndex < 0) {
  109. // return;
  110. // }
  111. // if (e.ColumnIndex == 0) {
  112. // DataGridViewRow curRow = dataGridViewConsentSelectResult.Rows[e.RowIndex];
  113. // var value = curRow.Cells["colCheck"].Value;
  114. // Boolean checkValue = false;
  115. // if (value == null || !(Boolean) value) {
  116. // checkValue = false;
  117. // } else {
  118. // checkValue = true;
  119. // }
  120. // curRow.Cells[e.ColumnIndex].Value = !checkValue;
  121. // }
  122. //}
  123. /// <summary>
  124. /// dbs227, 일괄저장 추가
  125. /// 체크박스 이벤트 처리
  126. /// </summary>
  127. /// <param name="sender"></param>
  128. /// <param name="e"></param>
  129. //private void dataGridViewConsentSelectResult_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) {
  130. // if (e.ColumnIndex == 0 && e.RowIndex == -1) {
  131. // bool chkStatus = false;
  132. // if (dataGridViewConsentSelectResult.Columns[0].HeaderText.Equals("□")) {
  133. // dataGridViewConsentSelectResult.Columns[0].HeaderText = "☑";
  134. // chkStatus = true;
  135. // } else {
  136. // dataGridViewConsentSelectResult.Columns[0].HeaderText = "□";
  137. // }
  138. // foreach (DataGridViewRow r in dataGridViewConsentSelectResult.Rows) {
  139. // r.Cells["colCheck"].Value = chkStatus;
  140. // }
  141. // dataGridViewConsentSelectResult.RefreshEdit();
  142. // }
  143. //}
  144. #region 검색 조건에 따른 환자의 동의서 조회
  145. /// <summary>
  146. /// 동의서 목록 조회
  147. /// </summary>
  148. public void BindDataGridRows() {
  149. try {
  150. if (this.consentMain == null) consentMain = ConsentMainControl.GetConsentMainInterface(this);
  151. if (this.commandControl == null) commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl;
  152. if (this.consentWebService == null) this.consentWebService = WebMethodCommon.GetConsentWebService(consentMain.PluginExecuteInfo["consentSvcUrl"]);
  153. string patientCode = string.Empty;
  154. if (commandControl.CurrentTargetPatient != null && !string.IsNullOrEmpty(commandControl.CurrentTargetPatient.PatientCode)) {
  155. patientCode = commandControl.CurrentTargetPatient.PatientCode;
  156. }
  157. string userId = string.Empty;
  158. if (rdoUser.Checked) {
  159. userId = consentMain.ConsentExecuteInfo["loginUserNo"];
  160. }
  161. if (!patientCode.Equals(string.Empty) || !userId.Equals(string.Empty)) {
  162. // 프린터 모드가 아닐 경우
  163. if (!consentMain.ConsentExecuteInfo["printYN"].Equals("Y")) {
  164. if (this.dateTimePickerStartDate.Value > this.dateTimePickerEndDate.Value) {
  165. this.dateTimePickerStartDate.Value = DateTime.Today - TimeSpan.FromDays(30);
  166. // this.dateTimePickerStartDate.Value = DateTime.Today - TimeSpan.FromDays(1);
  167. this.dateTimePickerEndDate.Value = DateTime.Today;
  168. }
  169. // 이전 진료일로 검색일자 설정
  170. if (string.IsNullOrEmpty(searchStartDate)) {
  171. if (commandControl.CurrentTargetPatient != null && !string.IsNullOrEmpty(commandControl.CurrentTargetPatient.clnDate)) {
  172. //searchStartDate = string.Format("{0}-{1}-{2}", commandControl.CurrentTargetPatient.clnDate.Substring(0, 4), commandControl.CurrentTargetPatient.clnDate.Substring(4, 2), commandControl.CurrentTargetPatient.clnDate.Substring(6, 2));
  173. } else {
  174. //searchStartDate = consentMain.PluginExecuteInfo["ConsentSearchStartDate"];
  175. }
  176. }
  177. //this.dateTimePickerStartDate.Value = Convert.ToDateTime(searchStartDate);
  178. // dbs227, 발행리스트 시작일자를 한달전으로 설정
  179. //this.dateTimePickerStartDate.Value = DateTime.Now.AddMonths(-1);
  180. string sDate = this.dateTimePickerStartDate.Value.ToShortDateString().Replace("-", "");
  181. string eDate = this.dateTimePickerEndDate.Value.ToShortDateString().Replace("-", "");
  182. string consentState = GetCheckConsentState();
  183. ConsentVO[] resultData = null;
  184. // 환자별 검색
  185. if (rdoUser.Checked == false) {
  186. resultData = consentWebService.GetConsentList(patientCode
  187. , sDate
  188. , eDate
  189. , consentState
  190. , consentMain.ConsentExecuteInfo["dutinstcd"]
  191. , userId);
  192. }
  193. // 사용자 별 검색
  194. else {
  195. var searchString = searchName.Text?.Trim();
  196. // 검색할 사용자 이름이 없다면 메시지박스를 보여준다
  197. if (searchString == null || searchString.Equals(String.Empty)) {
  198. MessageBox.Show("검색할 사용자 이름을 입력하세요", "경고", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  199. return;
  200. }
  201. resultData = consentWebService.GetConsentList(patientCode
  202. , sDate
  203. , eDate
  204. , consentState
  205. , consentMain.ConsentExecuteInfo["dutinstcd"]
  206. , searchString); // 검색할 사용자 ID 를 넣는다
  207. }
  208. //ConsentVO[] resultData = consentWebService.GetConsentList(patientCode
  209. // , sDateF
  210. // , eDate
  211. // , consentState
  212. // , string.Empty
  213. // , consentMain.ConsentExecuteInfo["dutinstcd"]
  214. // , userId);
  215. if (resultData == null) {
  216. return;
  217. }
  218. // 진료일 표시 형식 변경
  219. //foreach (ConsentVO v in resultData) {
  220. // if (v.clnDate.Length == 8) {
  221. // v.clnDate = v.clnDate.Substring(0, 4) + "-" + v.clnDate.Substring(4, 2) + "-" + v.clnDate.Substring(6, 2);
  222. // }
  223. //}
  224. this.dataGridViewConsentSelectResult.DataSource = new SortableBindingList<ConsentVO>(resultData);
  225. // 목록 조회 후 자동 선택 기능 제외
  226. consentMain.ClearPreviewConsent(true);
  227. /*
  228. ConsentFormListVO vo = GetCurrentConsentVO(0);
  229. if (vo != null) {
  230. ExecutePreviewWithSelectedConsent(vo);
  231. } else {
  232. consentMain.ClearPreviewConsent(true);
  233. }
  234. */
  235. }
  236. } else {
  237. //// dbs227, 발행리스트 시작일자를 한달전으로 설정
  238. //this.dateTimePickerStartDate.Value = DateTime.Now.AddMonths(-1);
  239. }
  240. } catch (Exception ex) {
  241. MessageBox.Show(this, ex.Message);
  242. }
  243. }
  244. /// <summary>
  245. /// 검색할 동의서 상태의 값을 반환한다
  246. /// </summary>
  247. /// <returns>현재 체크박스에 선택된 값을 String 타입으로 반환, ex) "ALL" or "'UNFINISHED','TEMP'"</returns>
  248. private string GetCheckConsentState() {
  249. string consentState = "";
  250. if (this.checkBoxAll.Checked) {
  251. consentState = "ALL";
  252. } else {
  253. if (this.checkBoxUnfinished.Checked)
  254. consentState += ((consentState.Length > 0) ? "," : "") + "'" + this.checkBoxUnfinished.Tag + "'";
  255. if (this.checkBoxTemp.Checked)
  256. //consentState += ((consentState.Length > 0) ? "," : "") + "'" + this.checkBoxTemp.Tag + "'";
  257. consentState += ((consentState.Length > 0) ? "," : "") + "'TEMP', 'UNFINISHED', 'ELECTR_CMP'";
  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(string.Format(Properties.Resources.msg_unfinished_check)
  348. , string.Format(Properties.Resources.msg_caption_confirm),
  349. MessageBoxButtons.OK, MessageBoxIcon.Information);
  350. }
  351. buttonConsentSelect.Enabled = true;
  352. }
  353. #endregion
  354. #region 동의서 미리보기
  355. //선택된 Row의 ConsentVO 객체를 반환한다.
  356. private ConsentVO GetCurrentConsentVO(int rowIndex) {
  357. ConsentVO vo = null;
  358. if (rowIndex < 0) {
  359. return vo;
  360. }
  361. if (dataGridViewConsentSelectResult != null && dataGridViewConsentSelectResult.Rows.Count > 0) {
  362. this.dataGridViewConsentSelectResult.Rows[rowIndex].Selected = true;
  363. //this.dataGridViewConsentSelectResult.CurrentCell = this.dataGridViewConsentSelectResult.Rows[rowIndex].Cells[0];
  364. vo = this.dataGridViewConsentSelectResult.Rows[rowIndex].DataBoundItem as ConsentVO;
  365. }
  366. return vo;
  367. }
  368. //선택된 ConsentVO 객체를 미리보기 실행한다.
  369. private void ExecutePreviewWithSelectedConsent(ConsentVO vo) {
  370. if (consentMain == null) consentMain = ConsentMainControl.GetConsentMainInterface(this);
  371. if (commandControl == null) commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl;
  372. Cursor currentCursor = this.Cursor;
  373. this.Cursor = Cursors.WaitCursor;
  374. if (rdoUser.Checked) {
  375. consentMain.ConsentExecuteInfo["patientNo"] = vo.pid;
  376. consentMain.ConsentExecuteInfo["clnDate"] = vo.clnDate.Replace("-", "");
  377. consentMain.ConsentExecuteInfo["visitType"] = vo.ordtype;
  378. consentMain.ConsentExecuteInfo["clnDept"] = vo.clnDeptCd;
  379. consentMain.ConsentExecuteInfo["cretno"] = vo.cretno.ToString();
  380. consentMain.ConsentExecuteInfo["opRsrvNo"] = vo.opRsrvNo;
  381. consentMain.SetPatientInfo();
  382. }
  383. commandControl.CurrentPreviewConsent = new PreviewConsent {
  384. formId = vo.formId.ToString(),
  385. formCd = vo.formCd.ToString(),
  386. formName = vo.formName,
  387. formPrintName = vo.formPrintName,
  388. prntCnt = vo.prntCnt,
  389. consentMstRid = vo.consentMstRid.ToString(),
  390. consentState = vo.consentStateDisp,
  391. consentStateEng = vo.consentState,
  392. orderNo = 0,
  393. ocrCode = vo.ocrTag,
  394. inputId = vo.createUserId,
  395. inputNm = vo.createUserName,
  396. ReissueConsentMstRid = IsConsentStatePrintOut(vo) ? vo.consentMstRid : 0,
  397. RewriteConsentMstRid = !IsConsentStateUnfinished(vo) ? vo.consentMstRid : 0,
  398. ordType = vo.ordtype,
  399. ocrtagPrntyn = vo.ocrTagYN,
  400. userDrFlag = vo.userDrFlag,
  401. printOnly = vo.prntOnly,
  402. opDiagName = vo.opDiagName,
  403. drOnly = vo.DrOnly,
  404. opName = vo.opName
  405. };
  406. try {
  407. consentMain.PatientInfoCtrl.SetConsentDocumentName(vo.formName);
  408. if (IsConsentStateTempSave(vo) || IsConsentStateElectronicComplete(vo)) { // 임시저장 or 작성완료
  409. commandControl.ShowTempSaveConsent(consentMain);
  410. } else if (IsConsentStatePrintOut(vo)) { // 출력
  411. if (this.dataGridViewConsentSelectResult.SelectedRows.Count > 0 &&
  412. this.dataGridViewConsentSelectResult.SelectedRows[0].Tag != null &&
  413. this.dataGridViewConsentSelectResult.SelectedRows[0].Tag.Equals("reissueTarget")) {
  414. //재출력 하는 경우
  415. commandControl.CurrentPreviewConsent.ReissueConsentMstRid = vo.consentMstRid;
  416. commandControl.CurrentPreviewConsent.RewriteConsentMstRid = 0;
  417. //CheckClnDateInfo(vo);
  418. commandControl.PreviewConsent(consentMain);
  419. } else {
  420. //CheckClnDateInfo(vo);
  421. commandControl.PreviewConsent(consentMain);
  422. }
  423. } else if (IsConsentStateCertifyComplete(vo)) { // 인증저장
  424. commandControl.ShowCompleteConsent(consentMain);//이미지 호출하는 함수
  425. } else if (IsConsentStateUnfinished(vo)) { //미작성
  426. //CheckClnDateInfo(vo);
  427. commandControl.PreviewConsent(consentMain); // consent_data에 데이터가 없을때 사용하는 함수
  428. }
  429. } catch {
  430. } finally {
  431. this.Cursor = currentCursor;
  432. }
  433. }
  434. //동의서의 처방일자와 생성번호 등의 정보가 현재 정보와 일치하지 않은 경우, 미리보기를 위해서 데이터를 재조회한다.
  435. private void CheckClnDateInfo(ConsentVO vo) {
  436. /*
  437. bool bSame = true;
  438. if (!vo.ClnDate.Replace("-", "").Equals(commandControl.CurrentTargetPatient.clnDate.Replace("-", "")))
  439. bSame = false;
  440. if (!vo.Cretno.ToString().Equals(commandControl.CurrentTargetPatient.cretno))
  441. bSame = false;
  442. if (!vo.ClnDeptCd.Equals(commandControl.CurrentTargetPatient.clnDeptCode))
  443. bSame = false;
  444. if (!vo.VisitType.Equals(commandControl.CurrentTargetPatient.VisitType))
  445. bSame = false;
  446. if (bSame == false) {
  447. //동의서 맵핑 정보를 상단의 선택된 진료일과 작성자 정보로 한다.
  448. consentMain.PatientInfoCtrl.SetPatientByConsentInfo(vo.ClnDate.Replace("-", ""),
  449. vo.VisitType,
  450. vo.ClnDeptCd,
  451. vo.Cretno.ToString());
  452. }
  453. */
  454. }
  455. #endregion
  456. #region 그리드 이벤트
  457. /*
  458. private void dataGridViewConsentSelectResult_CellClick(object sender, DataGridViewCellEventArgs e)
  459. {
  460. ConsentFormListVO vo = GetCurrentConsentVO(e.RowIndex);
  461. if (vo != null)
  462. {
  463. IConsentMain consentMain = ConsentMainControl.GetConsentMainInterface(this);
  464. consentMain.preParamClean();
  465. ExecutePreviewWithSelectedConsent(vo);
  466. }
  467. }
  468. */
  469. /// <summary>
  470. /// dataGridViewConsentSelectResult 그리드 컨트롤의 셀 우클릭 메뉴 생성
  471. /// </summary>
  472. /// <param name="sender">The source of the event.</param>
  473. /// <param name="e">The <see cref="DataGridViewCellContextMenuStripNeededEventArgs"/> instance containing the event data.</param>
  474. private void dataGridViewConsentSelectResult_CellContextMenuStripNeeded(object sender, DataGridViewCellContextMenuStripNeededEventArgs e) {
  475. if (consentMain.ConsentExecuteInfo["readOnly"].Equals("Y")) {
  476. return;
  477. }
  478. if (e.RowIndex > -1 && this.dataGridViewConsentSelectResult.Rows[e.RowIndex].Selected == true) {
  479. ConsentVO vo = GetCurrentConsentVO(e.RowIndex);
  480. if (vo.consentState.Equals("TEMP") || vo.consentState.Equals("PAPER_OUT")) {
  481. ContextMenuStrip strip = new ContextMenuStrip();
  482. // 임시, 확인 저장의 경우 삭제메뉴를 보여준다
  483. if (vo.consentState.Equals("TEMP") || vo.consentState.Equals("ELECTR_CMP")) {
  484. // 사용자와 생성자가 동일해야 삭제 가능
  485. if(commandControl.CurrentEndUser.UserNo.Equals(vo.createUserId)) {
  486. ToolStripMenuItem deleteRecord = new ToolStripMenuItem {
  487. Text = "삭제"
  488. };
  489. strip.Items.Add(deleteRecord);
  490. deleteRecord.Click += new EventHandler(deleteRecord_Click);
  491. }
  492. // 출력의 경우 재출력 메뉴를 보여준다
  493. } else if (vo.consentState.Equals("PAPER_OUT")) {
  494. ToolStripMenuItem reprintRecord = new ToolStripMenuItem {
  495. Text = "재출력"
  496. };
  497. strip.Items.Add(reprintRecord);
  498. reprintRecord.Click += new EventHandler(reprintRecord_Click);
  499. }
  500. e.ContextMenuStrip = strip;
  501. }
  502. }
  503. }
  504. /// <summary>
  505. /// dataGridViewConsentSelectResult 그리드 컨트롤의 CellMouseDoubleClick 이벤트 핸들러
  506. /// </summary>
  507. /// <param name="sender">The source of the event.</param>
  508. /// <param name="e">The <see cref="DataGridViewCellEventArgs"/> instance containing the event data.</param>
  509. private void dataGridViewConsentSelectResult_CellMouseDoubleClick(object sender, DataGridViewCellEventArgs e) {
  510. if (consentMain == null) consentMain = ConsentMainControl.GetConsentMainInterface(this);
  511. if (commandControl == null) commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl;
  512. // dbs227, 셀 클릭 시 더블클릭 인식되어 작동되는 경우 오류
  513. if (e.RowIndex < 0) {
  514. return;
  515. }
  516. // 현재 선택된 동의서를 가져온다
  517. ConsentVO vo = GetCurrentConsentVO(e.RowIndex);
  518. string electrVisble = ConsentMainControl.SETTING_DATA["ELECTR_CMP"];
  519. if (commandControl.CurrentTargetPatient.VisitType.Equals("O")) {
  520. if (electrVisble.Equals("Y")) {
  521. commandControl.setCompleteSaveButton(true);
  522. }
  523. } else {
  524. if (electrVisble.Equals("Y") && commandControl.CurrentEndUser.JobKindCd.Substring(0, 2).Equals("03")) {
  525. commandControl.setCompleteSaveButton(true);
  526. } else {
  527. commandControl.setCompleteSaveButton(false);
  528. }
  529. }
  530. //if (commandControl.CurrentTargetPatient.VisitType.Equals("O")) {
  531. // commandControl.setCompleteSaveButton(true);
  532. //} else {
  533. // if (ConsentMainControl.SETTING_DATA["ELECTR_CMP"].Equals("Y") && commandControl.CurrentEndUser.JobKindCd.Substring(0, 2).Equals("03")) {
  534. // commandControl.setCompleteSaveButton(true);
  535. // } else {
  536. // commandControl.setCompleteSaveButton(false);
  537. // }
  538. //}
  539. //의사가 아니면 확인저장 비활성화
  540. //if (!commandControl.CurrentEndUser.JobKindCd.Substring(0, 2).Equals("03")) {
  541. // commandControl.setCompleteSaveButton(false);
  542. //}
  543. // dbs227, 출력된 동의서는 미리보기를 하지 않는다
  544. if (vo.consentState.Equals("PAPER_OUT")) {
  545. MessageBox.Show(String.Format(Properties.Resources.msg_printed_consent),
  546. String.Format(Properties.Resources.title_printed_consent));
  547. return;
  548. }
  549. if (vo != null) {
  550. if (!consentMain.checkOperationDocument(vo.formCd)) {
  551. return;
  552. }
  553. // 선택된 동의서가 현재 보여지고 있는 동의서와 다른 경우, 임시 저장 여부 확인
  554. if (!consentMain.ConsentExecuteInfo["readOnly"].Equals("Y") &&
  555. !string.IsNullOrEmpty(commandControl.CurrentTargetPatient.PatientCode) &&
  556. commandControl.CurrentPreviewConsent != null && !commandControl.CurrentPreviewConsent.formId.Equals(vo.formId.ToString()) &&
  557. (commandControl.CurrentPreviewConsent.consentState == string.Empty || commandControl.CurrentPreviewConsent.consentState == "TEMP")) {
  558. // dbs227, 임시저장 팝업 사용 안함
  559. //DialogResult result = MessageBox.Show(string.Format(Properties.Resources.msg_confirm_tempsave)
  560. // , string.Format(Properties.Resources.msg_caption_confirm),
  561. // MessageBoxButtons.YesNo, MessageBoxIcon.Information);
  562. //if (result == DialogResult.Yes) {
  563. // consentMain.TempSave();
  564. //}
  565. }
  566. // startFormCd 를 초기화 한다
  567. consentMain.preParamClean();
  568. // 동의서 미리보기
  569. ExecutePreviewWithSelectedConsent(vo);
  570. if (!vo.consentState.Equals("PAPER_OUT") && !vo.consentState.Equals("ELECTR_CMP") && !vo.consentState.Equals("CERTIFY_CMP")) {
  571. // 동의서 뷰어에 동의서 로드
  572. RunConsentDualView();
  573. }
  574. }
  575. /*
  576. ConsentFormListVO vo = GetCurrentConsentVO(e.RowIndex);
  577. if (vo != null)
  578. {
  579. if (vo.ConsentState.ToLower().Equals("electr_cmp") || vo.ConsentState.ToLower().Equals("certify_cmp") || vo.ConsentState.ToLower().Equals("paper_out"))
  580. {
  581. }
  582. else
  583. {
  584. //미작성, 임서저장 상태일때 마우스 더블클릭을 하면 양면으로 동의서 보여줌
  585. RunConsentDualView();
  586. }
  587. }
  588. */
  589. }
  590. /// <summary>
  591. /// 동의서 뷰어에 동의서 로드
  592. /// </summary>
  593. private void RunConsentDualView() {
  594. if (this.consentMain == null) consentMain = ConsentMainControl.GetConsentMainInterface(this);
  595. if (this.commandControl == null) commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl;
  596. commandControl.RunConsentDualView();
  597. }
  598. /// <summary>
  599. /// 동의서 삭제 이벤트 핸들러
  600. /// </summary>
  601. /// <param name="sender">The source of the event.</param>
  602. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  603. private void deleteRecord_Click(object sender, EventArgs e) {
  604. if (consentMain == null) consentMain = ConsentMainControl.GetConsentMainInterface(this);
  605. if (commandControl == null) commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl;
  606. bool bDel = true;
  607. ReasonForUseN reasonForUseN = new ReasonForUseN(bDel);
  608. if (reasonForUseN.ShowDialog() == DialogResult.OK) {
  609. string reason = reasonForUseN.GetReasonForUseN();
  610. reasonForUseN.Close();
  611. if (this.dataGridViewConsentSelectResult.SelectedRows.Count != 0) {
  612. Cursor currentCursor = this.Cursor;
  613. try {
  614. this.Cursor = Cursors.WaitCursor;
  615. //동의서 삭제 처리를 위해서 재발행MstID에 값을 넣는다.
  616. ConsentVO vo = GetCurrentConsentVO(this.dataGridViewConsentSelectResult.SelectedRows[0].Index);
  617. // TODO dbs227 삭제 오류
  618. if (commandControl.CurrentPreviewConsent == null) {
  619. commandControl.CurrentPreviewConsent = new PreviewConsent {
  620. formId = vo.formId.ToString(),
  621. formCd = vo.formCd.ToString(),
  622. formName = vo.formName,
  623. formPrintName = vo.formPrintName,
  624. prntCnt = vo.prntCnt,
  625. consentMstRid = vo.consentMstRid.ToString(),
  626. consentStateEng = vo.consentState,
  627. orderNo = 0,
  628. ocrCode = vo.ocrTag,
  629. inputId = vo.createUserId,
  630. inputNm = vo.createUserName,
  631. ReissueConsentMstRid = IsConsentStatePrintOut(vo) ? vo.consentMstRid : 0,
  632. RewriteConsentMstRid = !IsConsentStateUnfinished(vo) ? vo.consentMstRid : 0,
  633. ordType = vo.ordtype,
  634. ocrtagPrntyn = vo.ocrTagYN,
  635. userDrFlag = vo.userDrFlag,
  636. printOnly = vo.prntOnly,
  637. opDiagName = vo.opDiagName,
  638. drOnly = vo.DrOnly,
  639. opName = vo.opName
  640. };
  641. }
  642. commandControl.CurrentPreviewConsent.ReissueConsentMstRid = vo.consentMstRid;
  643. // 미작성 동의서 삭제
  644. consentMain.ConsentCommandCtrl.DeleteRecordOfDeleteConsent(reason);
  645. // 동의서 목록 재조회 (미작성 동의서 삭제, 임시저장용 재조회, 인쇄출력용 재조회, 저장용(저장후 닫힘이 아닌 경우))
  646. consentMain.ConsentListCtrl.InquiryConsentData(-1);
  647. } catch (Exception ex) {
  648. throw ex;
  649. } finally {
  650. this.Cursor = currentCursor;
  651. }
  652. MessageBox.Show(string.Format(Properties.Resources.msg_consent_record_deleted)
  653. , string.Format(Properties.Resources.msg_caption_confirm),
  654. MessageBoxButtons.OK, MessageBoxIcon.Information);
  655. }
  656. }
  657. }
  658. /// <summary>
  659. /// 재출력 클릭
  660. /// </summary>
  661. /// <param name="sender">The source of the event.</param>
  662. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  663. private void reprintRecord_Click(object sender, EventArgs e) {
  664. ConsentVO vo = GetCurrentConsentVO(this.dataGridViewConsentSelectResult.SelectedRows[0].Index);
  665. if (vo != null) {
  666. if (vo.consentState.Equals("반납확인")) {
  667. MessageBox.Show("반납확인 서식은 재출력이 불가능 합니다.");
  668. return;
  669. }
  670. this.dataGridViewConsentSelectResult.SelectedRows[0].Tag = "reissueTarget"; // 재출력 대상 마킹
  671. ExecutePreviewWithSelectedConsent(vo);
  672. this.dataGridViewConsentSelectResult.SelectedRows[0].Tag = null;
  673. //재출력을 하는 경우, 바로 출력이 되도록 한다.
  674. if (consentMain == null) consentMain = ConsentMainControl.GetConsentMainInterface(this);
  675. if (commandControl == null) commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl;
  676. // 출력 로그 저장을 위한 버튼 클릭 설정
  677. this.consentMain.setPrintButton(true);
  678. // 재출력 시 OCRTAG 중복확인 제외
  679. commandControl.reprintStatus = true;
  680. commandControl.PrintConsentDocument();
  681. commandControl.reprintStatus = false;
  682. }
  683. }
  684. #endregion
  685. public void clearSearchStartDate() {
  686. searchStartDate = string.Empty;
  687. }
  688. private void dataGridViewConsentSelectResult_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e) {
  689. //foreach (DataGridViewRow row in dataGridViewConsentSelectResult.Rows) {
  690. // if (!string.IsNullOrEmpty(row.Cells["consentStateEng"].Value.ToString())) {
  691. // if (row.Cells["consentStateEng"].Value.ToString().ToUpper() == "UNFINISHED") {
  692. // row.DefaultCellStyle.ForeColor = System.Drawing.Color.Red;
  693. // }
  694. // }
  695. //}
  696. }
  697. private void dataGridViewConsentSelectResult_CellClick(object sender, DataGridViewCellEventArgs e) {
  698. }
  699. /// <summary>
  700. /// 선택된 동의서를 가져온다
  701. /// </summary>
  702. /// <returns>선택된 동의서 목록</returns>
  703. public List<ConsentVO> getConfirmedCheckedConsentList() {
  704. List<ConsentVO> consents = new List<ConsentVO>();
  705. foreach (DataGridViewRow row in dataGridViewConsentSelectResult.Rows) {
  706. if (Convert.ToBoolean(row.Cells["colCheck"].Value)) {
  707. ConsentVO consent = row.DataBoundItem as ConsentVO;
  708. if (!consent.consentState.Equals("ELECTR_CMP")) {
  709. return null;
  710. }
  711. consents.Add(consent);
  712. }
  713. }
  714. return consents;
  715. }
  716. /// <summary>
  717. /// 선택 초기화
  718. /// </summary>
  719. //private void ClearCheckBox() {
  720. // bool chkStatus = false;
  721. // dataGridViewConsentSelectResult.Columns[0].HeaderText = "□";
  722. // foreach (DataGridViewRow r in dataGridViewConsentSelectResult.Rows) {
  723. // r.Cells["colCheck"].Value = chkStatus;
  724. // }
  725. // dataGridViewConsentSelectResult.RefreshEdit();
  726. //}
  727. /// <summary>
  728. /// dbs227, 일괄저장
  729. /// 선택된 환자들의 저장 상태를 일괄저장으로 변경한다.
  730. /// </summary>
  731. /// <param name="sender"></param>
  732. /// <param name="e"></param>
  733. private void saveAllCertify_Click(object sender, EventArgs e) {
  734. // 선택된 동의서 목록을 가져온다.
  735. List<ConsentVO> lists = getConfirmedCheckedConsentList();
  736. if (lists == null || lists.Count < 1) {
  737. MessageBox.Show("동의서를 선택하거나 확인 저장 동의서만 선택해 주세요.");
  738. //ClearCheckBox();
  739. return;
  740. }
  741. String mstRids = "";
  742. String ocrTags = "";
  743. int i = 0;
  744. foreach (ConsentVO consent in lists) {
  745. if (i != 0) {
  746. mstRids += ",";
  747. ocrTags += ",";
  748. }
  749. mstRids += "'" + consent.consentMstRid + "'";
  750. ocrTags += "'" + consent.ocrTag + "'";
  751. i++;
  752. }
  753. // 선택된 동의서 상태값을 바꿔 준다.
  754. String result = consentWebService.updateCertifyComplete(mstRids, ocrTags, consentMain.ConsentExecuteInfo["dutinstcd"]);
  755. if (result.Equals("Y")) {
  756. MessageBox.Show("일괄저장 하였습니다.");
  757. //ClearCheckBox();
  758. try {
  759. this.checkBoxAll.Checked = true;
  760. InitDataGrid();
  761. BindDataGridRows();
  762. } catch (Exception ex) {
  763. throw ex;
  764. }
  765. }
  766. }
  767. /// <summary>
  768. /// 사용자 라디오 버튼 클릭 시 일괄저장을 보여준다
  769. /// </summary>
  770. /// <param name="sender"></param>
  771. /// <param name="e"></param>
  772. private void rdoUser_CheckedChanged(object sender, EventArgs e) {
  773. if (!rdoUser.Checked) {
  774. //saveAllCertify.Visible = false;
  775. searchName.Visible = false;
  776. }
  777. // 현재 로그인 한 사용자가 의사라면 일괄저장 버튼을 활성화 하여 준다.
  778. else if (rdoUser.Checked/* && commandControl.CurrentEndUser.JobKindCd.Equals("0330")*/) {
  779. // saveAllCertify 버튼 보이도록
  780. //saveAllCertify.Visible = true;
  781. searchName.Visible = true;
  782. }
  783. }
  784. }
  785. }