#region Copyright © 2015 CLIPSOFT Co.,Ltd. All Rights Reserved. // // All rights are reserved. Reproduction or transmission in whole or in part, // in any form or by any means, electronic, mechanical or otherwise, is // prohibited without the prior written consent of the copyright owner. // // Filename:ConsentSelectTabPageAll.cs // #endregion using System; using System.Collections.Generic; using System.ComponentModel; using System.Windows.Forms; using System.Configuration; using CLIP.eForm.Consent.Dfh.UI.ConsentSvcRef; using ClipSoft.eForm.Base.Dialog; namespace CLIP.eForm.Consent.Dfh.UI { /// /// 동의서 전체목록 탭 클래스 /// /// ///

[설계자]

///

클립소프트 연구소 홍지철 (jchong@clipsoft.co.kr)

///

[원본 작성자]

///

클립소프트 기술부 4팀 이창훈 (chlee@clipsoft.co.kr)

///

[수정 작성자]

///

클립소프트 기술부 이인희

///

----------------------------------------------------------------------------------------

///

[HISTORY]

///

2016-07-01 : 최초작성

///

----------------------------------------------------------------------------------------

///
public partial class ConsentSelectTabPageAll : UserControl { private ConsentSvcRef.ConsentSvcSoapClient consentWebService = null; private IConsentMain consentMain = null; private ConsentCommandCtrl commandControl = null; private string searchStartDate = string.Empty; public ConsentSelectTabPageAll() { InitializeComponent(); } private void ConsentSelectTabPageAll_Load(object sender, EventArgs e) { Boolean isInWpfDesignerMode = (LicenseManager.UsageMode == LicenseUsageMode.Designtime); Boolean isInFormsDesignerMode = (System.Diagnostics.Process.GetCurrentProcess().ProcessName == "devenv"); if (isInWpfDesignerMode || isInFormsDesignerMode) { // is in any designer mode return; } if (this.DesignMode || LicenseManager.UsageMode == LicenseUsageMode.Designtime) { return; } consentMain = ConsentMainControl.GetConsentMainInterface(this); commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl; consentWebService = WebMethodCommon.GetConsentWebService(consentMain.PluginExecuteInfo["consentSvcUrl"]); this.dateTimePickerEndDate.Value = DateTime.Now; InitDataGrid(); BindDataGridRows(); } private void InitDataGrid() { this.dataGridViewConsentSelectResult.MultiSelect = false; this.dataGridViewConsentSelectResult.AutoGenerateColumns = false; this.dataGridViewConsentSelectResult.AllowUserToAddRows = false; this.dataGridViewConsentSelectResult.CellDoubleClick += new DataGridViewCellEventHandler(dataGridViewConsentSelectResult_CellMouseDoubleClick); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "동의서명", "ConsentName", true, 250); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "상태", "ConsentStateDisp", true, 60); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "처방명", "OrderNm", true, 100); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "내원/입원일", "ClnDate", true, 100); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "진료과", "ClnDeptNm", true, 100); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "처방의", "CosignDcName", true, 80); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "병동", "Ward", true, 100); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "작성일시", "CreateDateTime", true, 120); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "작성자", "CreateUserName", true, 80); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "생성번호", "Cretno", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "상태코드", "ConsentState", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "처방구분코드", "OrderNo", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "동의서 고유코드", "FormGuid", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "동의서 고유RID", "FormRid", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "동의서 작성 마스터 RID", "ConsentMstRid", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "처방코드", "OrderCd", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "OCR코드", "OcrNumber", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "병실", "RoomCd", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "동의서코드", "FormCd", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "내원구분", "VisitType", false); } #region 검색 조건에 따른 환자의 동의서 조회 public void BindDataGridRows() { try { if (this.consentMain == null) consentMain = ConsentMainControl.GetConsentMainInterface(this); if (this.commandControl == null) commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl; if (this.consentWebService == null) this.consentWebService = WebMethodCommon.GetConsentWebService(consentMain.PluginExecuteInfo["consentSvcUrl"]); if (commandControl.CurrentTargetPatient != null && !string.IsNullOrEmpty(commandControl.CurrentTargetPatient.PatientCode)) { // 프린터 모드가 아닐 경우 if (!(consentMain.ConsentExecuteInfo.ContainsKey("printAct") && !string.IsNullOrEmpty(consentMain.ConsentExecuteInfo["printAct"]) && consentMain.ConsentExecuteInfo["printAct"].Equals("Y") ) //&& !this.consentMain.printSaveStatus ) { if (this.dateTimePickerStartDate.Value > this.dateTimePickerEndDate.Value) { this.dateTimePickerStartDate.Value = DateTime.Today - TimeSpan.FromDays(1); this.dateTimePickerEndDate.Value = DateTime.Today; } if (string.IsNullOrEmpty(searchStartDate)) { if (commandControl.CurrentTargetPatient != null && !string.IsNullOrEmpty(commandControl.CurrentTargetPatient.clnDate)) { searchStartDate = string.Format("{0}-{1}-{2}", commandControl.CurrentTargetPatient.clnDate.Substring(0, 4), commandControl.CurrentTargetPatient.clnDate.Substring(4, 2), commandControl.CurrentTargetPatient.clnDate.Substring(6, 2)); } else { searchStartDate = consentMain.PluginExecuteInfo["ConsentSearchStartDate"]; } } this.dateTimePickerStartDate.Value = Convert.ToDateTime(searchStartDate); string patientCode = commandControl.CurrentTargetPatient.PatientCode; string sDate = this.dateTimePickerStartDate.Value.ToShortDateString().Replace("-", ""); string eDate = this.dateTimePickerEndDate.Value.ToShortDateString().Replace("-", ""); string consentState = GetCheckConsentState(); ConsentVO[] resultData = consentWebService.GetConsentList(patientCode, sDate, eDate, consentState, string.Empty); if (resultData == null) { return; } this.dataGridViewConsentSelectResult.DataSource = new SortableBindingList(resultData); ConsentVO vo = GetCurrentConsentVO(0); if (vo != null) { ExecutePreviewWithSelectedConsent(vo); } } } } catch(Exception ex) { MessageBox.Show(this, ex.Message); } } //"ALL" or "'UNFINISHED','TEMP'" private string GetCheckConsentState() { string consentState = ""; if (this.checkBoxAll.Checked) { consentState = "ALL"; } else { if (this.checkBoxUnfinished.Checked) consentState += ((consentState.Length > 0) ? "," : "") + "'" + this.checkBoxUnfinished.Tag + "'"; if (this.checkBoxTemp.Checked) consentState += ((consentState.Length > 0) ? "," : "") + "'" + this.checkBoxTemp.Tag + "'"; if (this.checkBoxElectronicCmp.Checked) consentState += ((consentState.Length > 0) ? "," : "") + "'" + this.checkBoxElectronicCmp.Tag + "'"; if (this.checkBoxCertifyCmp.Checked) consentState += ((consentState.Length > 0) ? "," : "") + "'" + this.checkBoxCertifyCmp.Tag + "'"; if (this.checkBoxPaperOut.Checked) consentState += ((consentState.Length > 0) ? "," : "") + "'" + this.checkBoxPaperOut.Tag + "'"; if (this.checkBoxVerbal.Checked) consentState += ((consentState.Length > 0) ? "," : "") + "'" + this.checkBoxVerbal.Tag + "'"; } return consentState; } #endregion #region ConsentState 확인 private static bool IsConsentStateTempSave(ConsentVO vo) { if (vo.ConsentState.ToUpper().Equals("TEMP") || vo.ConsentState.ToUpper().Equals("VERBAL")) { return true; } return false; } private static bool IsConsentStatePrintOut(ConsentVO vo) { return vo.ConsentState.ToUpper().Equals("PAPER_OUT"); } private static bool IsConsentStateElectronicComplete(ConsentVO vo) { return vo.ConsentState.ToUpper().Equals("ELECTR_CMP"); } private static bool IsConsentStateCertifyComplete(ConsentVO vo) { return vo.ConsentState.ToUpper().Equals("CERTIFY_CMP"); } private static bool IsConsentStateUnfinished(ConsentVO vo) { return vo.ConsentState.ToUpper().Equals("UNFINISHED"); } private static bool IsConsentStateFnuPrintOut(ConsentVO vo) { return vo.ConsentState.ToUpper().Equals("FNU_PRINT"); } #endregion #region 체크박스 이벤트 private void checkBoxAll_CheckedChanged(object sender, EventArgs e) { if (this.checkBoxAll.Checked == true) { this.checkBoxUnfinished.Checked = false; this.checkBoxTemp.Checked = false; this.checkBoxElectronicCmp.Checked = false; this.checkBoxCertifyCmp.Checked = false; this.checkBoxPaperOut.Checked = false; } } private void checkBoxUnfinished_CheckedChanged(object sender, EventArgs e) { if (this.checkBoxUnfinished.Checked == true && this.checkBoxAll.Checked == true) { this.checkBoxAll.Checked = false; } } private void checkBoxTemp_CheckedChanged(object sender, EventArgs e) { if (this.checkBoxTemp.Checked == true && this.checkBoxAll.Checked == true) { this.checkBoxAll.Checked = false; } } private void checkBoxElectronicCmp_CheckedChanged(object sender, EventArgs e) { if (this.checkBoxElectronicCmp.Checked == true && this.checkBoxAll.Checked == true) { this.checkBoxAll.Checked = false; } } private void checkBoxCertifyCmp_CheckedChanged(object sender, EventArgs e) { if (this.checkBoxCertifyCmp.Checked == true && this.checkBoxAll.Checked == true) { this.checkBoxAll.Checked = false; } } private void checkBoxPaperOut_CheckedChanged(object sender, EventArgs e) { if (this.checkBoxPaperOut.Checked == true && this.checkBoxAll.Checked == true) { this.checkBoxAll.Checked = false; } } #endregion # region 조회버튼 클릭 이벤트 private void buttonConsentSelect_Click(object sender, EventArgs e) { string checkState = GetCheckConsentState(); if (checkState.Length > 0) { Cursor currentCursor = this.Cursor; if (!string.IsNullOrEmpty(searchStartDate)) { searchStartDate = this.dateTimePickerStartDate.Value.ToShortDateString(); } try { this.Cursor = Cursors.WaitCursor; BindDataGridRows(); } catch (Exception ex) { throw ex; } finally { this.Cursor = currentCursor; } } else { MessageBox.Show(string.Format(Properties.Resources.msg_unfinished_check) , string.Format(Properties.Resources.msg_caption_confirm), MessageBoxButtons.OK, MessageBoxIcon.Information); } } #endregion #region 동의서 미리보기 //선택된 Row의 ConsentVO 객체를 반환한다. private ConsentVO GetCurrentConsentVO(int rowIndex) { ConsentVO vo = null; if (rowIndex < 0) { return vo; } if (dataGridViewConsentSelectResult != null && dataGridViewConsentSelectResult.Rows.Count > 0) { //this.dataGridViewConsentSelectResult.Rows[rowIndex].Selected = true; //this.dataGridViewConsentSelectResult.CurrentCell = this.dataGridViewConsentSelectResult.Rows[rowIndex].Cells[0]; vo = this.dataGridViewConsentSelectResult.Rows[rowIndex].DataBoundItem as ConsentVO; } return vo; } //선택된 ConsentVO 객체를 미리보기 실행한다. private void ExecutePreviewWithSelectedConsent(ConsentVO vo) { if (consentMain == null) consentMain = ConsentMainControl.GetConsentMainInterface(this); if (commandControl == null) commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl; Cursor currentCursor = this.Cursor; this.Cursor = Cursors.WaitCursor; Dictionary globalParams = Common.CreateGlobalParamsDictionary(); commandControl.CurrentPreviewConsent = new PreviewConsent(); commandControl.CurrentPreviewConsent.FormRid = vo.FormRid.ToString(); commandControl.CurrentPreviewConsent.FormGuid = vo.FormGuid; commandControl.CurrentPreviewConsent.FormCd = vo.FormCd.ToString(); commandControl.CurrentPreviewConsent.FormName = vo.ConsentName; commandControl.CurrentPreviewConsent.PrntCnt = vo.PrntCnt; commandControl.CurrentPreviewConsent.ConsentMstRid = vo.ConsentMstRid.ToString(); commandControl.CurrentPreviewConsent.ConsentState = vo.ConsentState; commandControl.CurrentPreviewConsent.OrderNo = vo.OrderNo; commandControl.CurrentPreviewConsent.Ocrcode = vo.OcrNumber; commandControl.CurrentPreviewConsent.InputId = vo.CreateUserId; commandControl.CurrentPreviewConsent.InputNm = vo.CreateUserName; commandControl.CurrentPreviewConsent.ReissueConsentMstRid = (IsConsentStatePrintOut(vo)) ? vo.ConsentMstRid : 0; commandControl.CurrentPreviewConsent.RewriteConsentMstRid = (!IsConsentStateUnfinished(vo)) ? vo.ConsentMstRid : 0; commandControl.CurrentPreviewConsent.VisitType = vo.VisitType; //commandControl.CurrentPreviewConsent.FormName = vo.;//서식 이름 이걸로 쓰도록 수정 consentMain.PatientInfoCtrl.SetConsentDocumentName(vo.ConsentName); if (IsConsentStateTempSave(vo)) //임시저장 { commandControl.ShowTempSaveConsent(consentMain);//consent_data에 데이터가 있을때만 } else if (IsConsentStatePrintOut(vo)) //출력 { if (this.dataGridViewConsentSelectResult.SelectedRows.Count > 0 && this.dataGridViewConsentSelectResult.SelectedRows[0].Tag != null && this.dataGridViewConsentSelectResult.SelectedRows[0].Tag.Equals("reissueTarget")) { //재출력 하는 경우 commandControl.CurrentPreviewConsent.ReissueConsentMstRid = vo.ConsentMstRid; commandControl.CurrentPreviewConsent.RewriteConsentMstRid = 0; CheckClnDateInfo(vo); commandControl.PreviewConsent(consentMain); } else { CheckClnDateInfo(vo); commandControl.PreviewConsent(consentMain); //MessageBox.Show(string.Format(Properties.Resources.msg_completed_printed_click) // , string.Format(Properties.Resources.msg_caption_confirm), MessageBoxButtons.OK, MessageBoxIcon.Information); } } else if (IsConsentStateElectronicComplete(vo) || IsConsentStateCertifyComplete(vo)) //서명완료 { commandControl.ShowCompleteConsent(consentMain);//이미지 호출하는 함수 } else if (IsConsentStateUnfinished(vo)) //미작성 { CheckClnDateInfo(vo); commandControl.PreviewConsent(consentMain);//consent_data에 데이터가 없을때 사용하는 함수 } else if (IsConsentStateFnuPrintOut(vo)) //FNU 출력 { MessageBoxDlg.Show(true, string.Format(Properties.Resources.msg_fnu_printed) , string.Format(Properties.Resources.msg_caption_confirm) , MessageBoxButtons.OK, MessageBoxIcon.Information); } this.Cursor = currentCursor; } //동의서의 처방일자와 생성번호 등의 정보가 현재 정보와 일치하지 않은 경우, 미리보기를 위해서 데이터를 재조회한다. private void CheckClnDateInfo(ConsentVO vo) { bool bSame = true; if (!vo.ClnDate.Replace("-", "").Equals(commandControl.CurrentTargetPatient.clnDate.Replace("-", ""))) bSame = false; if (!vo.Cretno.ToString().Equals(commandControl.CurrentTargetPatient.cretno)) bSame = false; if (!vo.ClnDeptCd.Equals(commandControl.CurrentTargetPatient.clnDeptCode)) bSame = false; if (!vo.VisitType.Equals(commandControl.CurrentTargetPatient.VisitType)) bSame = false; if (bSame == false) { //동의서 맵핑 정보를 상단의 선택된 진료일과 작성자 정보로 한다. consentMain.PatientInfoCtrl.SetPatientByConsentInfo(vo.ClnDate.Replace("-", ""), vo.VisitType, vo.ClnDeptCd, vo.Cretno.ToString()); } } #endregion #region 그리드 이벤트 /* private void dataGridViewConsentSelectResult_CellClick(object sender, DataGridViewCellEventArgs e) { ConsentVO vo = GetCurrentConsentVO(e.RowIndex); if (vo != null) { IConsentMain consentMain = ConsentMainControl.GetConsentMainInterface(this); consentMain.preParamClean(); ExecutePreviewWithSelectedConsent(vo); } } */ private void dataGridViewConsentSelectResult_CellContextMenuStripNeeded(object sender, DataGridViewCellContextMenuStripNeededEventArgs e) { if (e.RowIndex > 0 && this.dataGridViewConsentSelectResult.Rows[e.RowIndex].Selected == true) { ConsentVO vo = GetCurrentConsentVO(e.RowIndex); if (vo.ConsentState.Equals("UNFINISHED") || vo.ConsentState.Equals("PAPER_OUT")) { ContextMenuStrip strip = new ContextMenuStrip(); //if (vo.ConsentState.Equals("UNFINISHED")) //{ // ToolStripMenuItem deleteRecord = new ToolStripMenuItem(); // deleteRecord.Text = "삭제"; // strip.Items.Add(deleteRecord); // deleteRecord.Click += new EventHandler(deleteRecord_Click); //} //else if (vo.ConsentState.Equals("PAPER_OUT")) { ToolStripMenuItem reprintRecord = new ToolStripMenuItem(); reprintRecord.Text = "재출력"; strip.Items.Add(reprintRecord); reprintRecord.Click += new EventHandler(reprintRecord_Click); } e.ContextMenuStrip = strip; } } } private void dataGridViewConsentSelectResult_CellMouseDoubleClick(object sender, DataGridViewCellEventArgs e) { ConsentVO vo = GetCurrentConsentVO(e.RowIndex); if (vo != null) { IConsentMain consentMain = ConsentMainControl.GetConsentMainInterface(this); consentMain.preParamClean(); ExecutePreviewWithSelectedConsent(vo); if (!vo.ConsentState.Equals("PAPER_OUT") && !vo.ConsentState.Equals("FNU_PRINT") && !vo.ConsentState.Equals("ELECTR_CMP") && !vo.ConsentState.Equals("CERTIFY_CMP")) { RunConsentDualView(); } } /* ConsentVO vo = GetCurrentConsentVO(e.RowIndex); if (vo != null) { if (vo.ConsentState.ToLower().Equals("electr_cmp") || vo.ConsentState.ToLower().Equals("certify_cmp") || vo.ConsentState.ToLower().Equals("paper_out")) { } else { //미작성, 임서저장 상태일때 마우스 더블클릭을 하면 양면으로 동의서 보여줌 RunConsentDualView(); } } */ } private void RunConsentDualView() { if (this.consentMain == null) consentMain = ConsentMainControl.GetConsentMainInterface(this); if (this.commandControl == null) commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl; commandControl.RunConsentDualView(); } private void deleteRecord_Click(object sender, EventArgs e) { if (consentMain == null) consentMain = ConsentMainControl.GetConsentMainInterface(this); if (commandControl == null) commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl; bool bDel = true; ReasonForUseN reasonForUseN = new ReasonForUseN(bDel); if (reasonForUseN.ShowDialog() == DialogResult.OK) { string reason = reasonForUseN.GetReasonForUseN(); reasonForUseN.Close(); if (this.dataGridViewConsentSelectResult.SelectedRows.Count != 0) { Cursor currentCursor = this.Cursor; try { this.Cursor = Cursors.WaitCursor; //동의서 삭제 처리를 위해서 재발행MstID에 값을 넣는다. ConsentVO vo = GetCurrentConsentVO(this.dataGridViewConsentSelectResult.SelectedRows[0].Index); commandControl.CurrentPreviewConsent.ReissueConsentMstRid = vo.ConsentMstRid; consentMain.ConsentCommandCtrl.DeleteRecordOfDeleteConsent(reason); consentMain.ConsentListCtrl.InquiryConsentData(-1); this.Cursor = currentCursor; MessageBox.Show(string.Format(Properties.Resources.msg_consent_record_deleted) , string.Format(Properties.Resources.msg_caption_confirm), MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { this.Cursor = currentCursor; throw ex; } finally { } } } } private void reprintRecord_Click(object sender, EventArgs e) { ConsentVO vo = GetCurrentConsentVO(this.dataGridViewConsentSelectResult.SelectedRows[0].Index); if (vo != null) { this.dataGridViewConsentSelectResult.SelectedRows[0].Tag = "reissueTarget"; // 재출력 대상 마킹 ExecutePreviewWithSelectedConsent(vo); this.dataGridViewConsentSelectResult.SelectedRows[0].Tag = null; //재출력을 하는 경우, 바로 출력이 되도록 한다. if (consentMain == null) consentMain = ConsentMainControl.GetConsentMainInterface(this); if (commandControl == null) commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl; commandControl.PrintConsentDocument(); } } #endregion public void clearSearchStartDate() { searchStartDate = string.Empty; } } }