#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:ConsentSelectTabConsentSearch.cs // #endregion using System; using System.ComponentModel; using System.Drawing; using System.Windows.Forms; using CLIP.eForm.Consent.UI.ConsentSvcRef; using CLIP.eForm.Consent.UI.HospitalSvcRef; using ConsentFormListVO = CLIP.eForm.Consent.UI.ConsentSvcRef.ConsentFormListVO; namespace CLIP.eForm.Consent.UI { /// /// 동의서 찾기 탭 클래스 /// /// ///

[설계자]

///

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

///

[원본 작성자]

///

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

///

[수정 작성자]

///

클립소프트 기술부 이인희

///

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

///

[HISTORY]

///

2015-07-30 : 최초작성

///

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

///
public partial class ConsentSelectTabConsentSearch : UserControl { private ConsentSvcRef.ConsentSvcSoapClient consentWebService = null; private HospitalSvcRef.HospitalSvcSoapClient hospitalWebService = null; private IConsentMain consentMain = null; private ConsentCommandCtrl commandControl = null; Timer grdClickTimer = new Timer(); public ConsentSelectTabConsentSearch() { InitializeComponent(); grdClickTimer.Interval = 500; grdClickTimer.Tag = "stop"; grdClickTimer.Tick += grdTimer_Tick; } private void ConsentSelectTabConsentSearch_Load(object sender, EventArgs e) { if (this.DesignMode || LicenseManager.UsageMode == LicenseUsageMode.Designtime) { return; } consentMain = ConsentMainControl.GetConsentMainInterface(this); commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl; consentWebService = WebMethodCommon.GetConsentWebService(consentMain.PluginExecuteInfo["consentSvcUrl"]); hospitalWebService = WebMethodCommon.GetHospitalWebService(consentMain.PluginExecuteInfo["hospitalSvcUrl"]); InitComboBoxConsentType(); // 동의서 찾기에서 기본 카테고리를 해당 기관으로 기본적으로 설정되게끔 변경 //comboBoxConsentType.SelectedValue = string.Format("EMA_{0}", consentMain.ConsentExecuteInfo["dutinstcd"]); InitDataGrid(); } /// /// 초기 DataGrid 항목 설정 /// private void InitDataGrid() { this.dataGridViewConsentSelectResult.AllowUserToAddRows = false; this.dataGridViewConsentSelectResult.CellDoubleClick += new DataGridViewCellEventHandler(dataGridViewConsentSelectResult_CellDoubleClick); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "동의서명", "formName", true, 250); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "동의서 코드", "formCd", true, 100); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "동의서 고유코드", "consentMstRid", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "생성자 아이디", "createUserId", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "생성자 아이디", "createUserName", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "생성자 아이디", "createDatetime", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "OCRTAG", "ocrTag", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "환자번호", "pid", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "내원일", "inDd", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "ordtype", "ordType", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "ordDeptCd", "ordDeptCd", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "cretNo", "cretNo", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "opRsrvNo", "opRsrvNo", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "patientName", "patientName", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "consentState", "consentState", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "consentStateEng", "consentStateEng", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "formGuid", "formGuid", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "formRid", "formRid", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "printOnly", "printOnly", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "printCnt", "printCnt", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "ocrTagPrntYn", "ocrTagPrntYn", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "formPrntNm", "formPrntNm", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "certUseYn", "certUseYn", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "opDiagNm", "opDiagNm", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "opNm", "opNm", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "userDrFlag", "userDrFlag", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "linkFormCd", "linkFormCd", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "jinjeongCd", "jinjeongCd", false); //CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "jinjeongCd", "jinjeongCd", false); } #region 동의서 카테고리 바인딩 /// /// 초기 동의서 카테고리 바인딩 /// private void InitComboBoxConsentType() { CategoryForDropdownVO[] arrayData = consentWebService.GetCategoryForDropdown(consentMain.ConsentExecuteInfo["dutinstcd"]); CategoryForDropdownVO[] mainCategory = new CategoryForDropdownVO[1]; CategoryForDropdownVO mainItem = new CategoryForDropdownVO(); mainItem.CategoryId = "F"; mainItem.CategoryName = "전체"; mainCategory[0] = mainItem; this.comboBoxConsentType.DisplayMember = "CategoryName"; this.comboBoxConsentType.ValueMember = "CategoryId"; this.comboBoxConsentType.DataSource = mainCategory; // 서브 카테고리 설정 InitComboBoxConsentSubType(consentMain.ConsentExecuteInfo["dutinstcd"]); } class MainCategory { String CategoryName; String CategoryId; public MainCategory(String CategoryName, String CategoryId) { this.CategoryName = CategoryName; this.CategoryId = CategoryId; } } /// /// comboBoxConsentType 콤보 컨트롤 변경 이벤트 /// /// The source of the event. /// The instance containing the event data. private void comboBoxConsentType_SelectedIndexChanged(object sender, EventArgs e) { //SetSubConsentTypeDataToComboBox(); } /// /// 동의서 하위 분류 항목 바인딩 /// private void SetSubConsentTypeDataToComboBox() { string comboBoxConsentTypeValue = comboBoxConsentType.SelectedValue.ToString(); // 전체 선택 if (comboBoxConsentTypeValue.Equals("CATE_ALL")) { this.comboBoxConsentSubType.DataSource = null; this.comboBoxConsentSubType.Enabled = false; } else { this.comboBoxConsentSubType.Enabled = true; InitComboBoxConsentSubType(comboBoxConsentTypeValue); } } /// /// 동의서 하위 분류 조회 및 바인딩 /// /// The parent value. private void InitComboBoxConsentSubType(string parentValue) { // 주어진 parentValue 로 GetCategoryForDropdown API 호출 CategoryForDropdownVO[] arrayData = consentWebService.GetCategoryForDropdown(parentValue); this.comboBoxConsentSubType.DisplayMember = "CategoryName"; this.comboBoxConsentSubType.ValueMember = "CategoryId"; this.comboBoxConsentSubType.DataSource = arrayData; } #endregion #region 동의서 조회하고 그리드 바인딩 /// /// textBoxConsentSearchKeyWord 키보드 입력 이벤트 /// /// The source of the event. /// The instance containing the event data. private void textBoxConsentSearchKeyWord_KeyDown(object sender, KeyEventArgs e) { // 엔터키 입력 시 조회 버튼 클릭 이벤트 수행 if (e.KeyCode == Keys.Enter) { this.buttonConsentSelect.PerformClick(); } } /// /// 조회 버튼 클릭 이벤트 /// /// The source of the event. /// The instance containing the event data. private void buttonConsentSelect_Click(object sender, EventArgs e) { buttonConsentSelect.Enabled = false; Application.DoEvents(); IConsentMain consentMain = ConsentMainControl.GetConsentMainInterface(this); ConsentCommandCtrl commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl; consentMain.preParamClean(); GetConsentBySearch(); buttonConsentSelect.Enabled = true; } /// /// 동의서 검색 /// private void GetConsentBySearch() { Cursor currentCursor = this.Cursor; try { this.Cursor = Cursors.WaitCursor; string consentType = string.Empty; // 부서명이 선택되어 있지 않으면 근무지기관코드로 검색 if (this.comboBoxConsentSubType.SelectedValue == null) { consentType = this.comboBoxConsentType.SelectedValue.ToString(); } // 부서명이 선택되어 있으면 부서명으로 검색 else { consentType = this.comboBoxConsentSubType.SelectedValue.ToString(); } string keyWord = string.Empty; keyWord = "%" + this.textBoxConsentSearchKeyWord.Text + "%"; if ((consentType.Equals("EMA_031") || consentType.Equals("EMA_032")) && keyWord.Trim().Equals("%%")) { MessageBox.Show("과 또는 검색어를 입력해주세요."); return; } //ConsentFormListVO[] arrayData = consentWebService.GetConsentBySearch(consentType, keyWord, consentMain.ConsentExecuteInfo["dutinstcd"]); ConsentVO[] arrayData = consentWebService.GetConsentBySearch("4", keyWord, "031"); if (arrayData == null) { return; } this.dataGridViewConsentSelectResult.DataSource = new SortableBindingList(arrayData); } catch (Exception ex) { throw ex; } finally { this.Cursor = currentCursor; } } #endregion #region 그리드 이벤트 /// /// dataGridViewConsentSelectResult 그리드 셀 더블클릭 이벤트 /// /// The source of the event. /// The instance containing the event data. private void dataGridViewConsentSelectResult_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (consentMain == null) consentMain = ConsentMainControl.GetConsentMainInterface(this); if (commandControl == null) commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl; // dbs227, 셀 클릭 시 더블클릭 인식되어 작동되는 경우 오류 if (e.RowIndex < 0) { return; } ConsentFormListVO vo = GetCurrentConsentSearchVO(e.RowIndex); // if (!consentMain.checkOperationDocument(vo.formCd)) { return; } string electrVisble = ConsentMainControl.SETTING_DATA["ELECTR_CMP"]; if (commandControl.CurrentTargetPatient.VisitType.Equals("O")) { if (electrVisble.Equals("Y")) { commandControl.setCompleteSaveButton(true); } } else { if (electrVisble.Equals("Y") && commandControl.CurrentEndUser.JobKindCd.Substring(0, 2).Equals("03")) { commandControl.setCompleteSaveButton(true); } else { commandControl.setCompleteSaveButton(false); } } //if (commandControl.CurrentTargetPatient.VisitType.Equals("O")) { // commandControl.setCompleteSaveButton(true); //} else { // if (ConsentMainControl.SETTING_DATA["ELECTR_CMP"].Equals("Y") && commandControl.CurrentEndUser.JobKindCd.Substring(0, 2).Equals("03")) { // commandControl.setCompleteSaveButton(true); // } else { // commandControl.setCompleteSaveButton(false); // } //} //의사가 아닐경우 확인저장 비활성화 //if (!commandControl.CurrentEndUser.JobKindCd.Substring(0, 2).Equals("03")) { // commandControl.setCompleteSaveButton(false); //} if (vo != null) { // 선택된 동의서가 현재 보여지고 있는 동의서와 다른 경우, 임시 저장 여부 확인 if (!consentMain.ConsentExecuteInfo["readOnly"].Equals("Y") && !string.IsNullOrEmpty(commandControl.CurrentTargetPatient.PatientCode) && commandControl.CurrentPreviewConsent != null && !commandControl.CurrentPreviewConsent.formRid.Equals(vo.formRid.ToString()) && (commandControl.CurrentPreviewConsent.consentState == string.Empty || commandControl.CurrentPreviewConsent.consentState == "TEMP")) { // dbs227, 임시저장 팝업 사용 안함 //DialogResult result = MessageBox.Show(string.Format(Properties.Resources.msg_confirm_tempsave) // , string.Format(Properties.Resources.msg_caption_confirm), // MessageBoxButtons.YesNo, MessageBoxIcon.Information); //if (result == DialogResult.Yes) { // consentMain.TempSave(); //} } Cursor currentCursor = this.Cursor; this.Cursor = Cursors.WaitCursor; ExecutePreviewWithSelectedConsent(vo); RunConsentDualView(); commandControl.SetEnableConsentIssueCommands(true); this.Cursor = currentCursor; } } private void RunConsentDualView() { if (this.consentMain == null) consentMain = ConsentMainControl.GetConsentMainInterface(this); if (this.commandControl == null) commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl; commandControl.RunConsentDualView(); } /// /// dataGridViewConsentSelectResult 그리드 셀 마우스 우클릭 이벤트 /// /// The source of the event. /// The instance containing the event data. private void dataGridViewConsentSelectResult_CellContextMenuStripNeeded(object sender, DataGridViewCellContextMenuStripNeededEventArgs e) { if (e.RowIndex >= 0 && this.dataGridViewConsentSelectResult.Rows[e.RowIndex].Selected == true) { ContextMenuStrip strip = new ContextMenuStrip(); ToolStripMenuItem setItemAdd = new ToolStripMenuItem(); setItemAdd.Text = "즐겨찾기 추가"; strip.Items.Add(setItemAdd); setItemAdd.Click += new EventHandler(setItemAdd_Click); e.ContextMenuStrip = strip; } } /// /// 선택된 동의서를 개인SET에 등록 /// /// The source of the event. /// The instance containing the event data. private void setItemAdd_Click(object sender, EventArgs e) { IConsentMain consentMain = ConsentMainControl.GetConsentMainInterface(this); ConsentCommandCtrl commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl; if (this.dataGridViewConsentSelectResult.SelectedRows.Count != 0) { Cursor currentCursor = this.Cursor; this.Cursor = Cursors.WaitCursor; try { ConsentFormListVO vo = GetCurrentConsentSearchVO(this.dataGridViewConsentSelectResult.SelectedRows[0].Index); // 동의서 SET에 추가하는 웹서비스 호출 hospitalWebService.SetUserFormSetList(commandControl.CurrentEndUser.UserNo, vo.formCd, consentMain.ConsentExecuteInfo["dutinstcd"]); } catch { } finally { this.Cursor = currentCursor; } MessageBox.Show(string.Format(Properties.Resources.msg_consent_set_added) , string.Format(Properties.Resources.msg_caption_confirm), MessageBoxButtons.OK, MessageBoxIcon.Information); } } #endregion #region 동의서 미리보기 private ConsentFormListVO GetCurrentConsentSearchVO(int rowIndex) { ConsentFormListVO vo = null; if (rowIndex < 0) { return vo; } vo = this.dataGridViewConsentSelectResult.Rows[rowIndex].DataBoundItem as ConsentFormListVO; return vo; } private void ExecutePreviewWithSelectedConsent(ConsentFormListVO vo) { if (consentMain == null) consentMain = ConsentMainControl.GetConsentMainInterface(this); if (commandControl == null) commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl; Cursor currentCursor = this.Cursor; try { this.Cursor = Cursors.WaitCursor; commandControl.CurrentPreviewConsent = new PreviewConsent { formRid = vo.formRid.ToString(), formGuid = vo.formGuid, formCd = vo.formCd.ToString(), FormName = vo.formName, formPrintName = vo.formPrntNm, prntCnt = vo.printCnt, consentMstRid = "-1", consentState = string.Empty, consentStateEngnm = string.Empty, inputId = commandControl.CurrentEndUser.UserNo, inputNm = commandControl.CurrentEndUser.UserName, ReissueConsentMstRid = 0, RewriteConsentMstRid = 0, ocrtagPrntyn = vo.ocrTagPrntYn, userDrFlag = vo.userDrFlag, printOnly = vo.printOnly, opDiagName = vo.opDiagNm, opName = vo.opNm, ocrCode = "", drOnly = vo.DrOnly, linkFormCd = vo.linkFormCd }; consentMain.PatientInfoCtrl.SetConsentDocumentName(vo.formName); commandControl.PreviewConsent(consentMain); } catch (Exception e) { MessageBox.Show(this, e.Message); consentMain.ClearPreviewConsent(true); } finally { this.Cursor = currentCursor; } } #endregion private void comboBoxConsentType_DrawItem(object sender, DrawItemEventArgs e) { ComboBox box = sender as ComboBox; if (box is null) return; e.DrawBackground(); if (e.Index >= 0) { Graphics g = e.Graphics; using (Brush brush = ((e.State & DrawItemState.Selected) == DrawItemState.Selected) ? new SolidBrush(SystemColors.Highlight) : new SolidBrush(e.BackColor)) { using (Brush textBrush = new SolidBrush(e.ForeColor)) { g.FillRectangle(brush, e.Bounds); g.DrawString(((CategoryForDropdownVO[]) box.DataSource)[e.Index].CategoryName, e.Font, textBrush, (float) e.Bounds.X, (float) (e.Bounds.Y) + 2.34F); } } } e.DrawFocusRectangle(); } private void comboBoxConsentType_MeasureItem(object sender, MeasureItemEventArgs e) { e.ItemHeight = 20; } private void comboBoxConsentSubType_DrawItem(object sender, DrawItemEventArgs e) { ComboBox box = sender as ComboBox; if (box is null) return; e.DrawBackground(); if (e.Index >= 0) { Graphics g = e.Graphics; using (Brush brush = ((e.State & DrawItemState.Selected) == DrawItemState.Selected) ? new SolidBrush(SystemColors.Highlight) : new SolidBrush(e.BackColor)) { using (Brush textBrush = new SolidBrush(e.ForeColor)) { g.FillRectangle(brush, e.Bounds); g.DrawString(((CategoryForDropdownVO[]) box.DataSource)[e.Index].CategoryName, e.Font, textBrush, (float) e.Bounds.X, (float) (e.Bounds.Y) + 2.34F); } } } e.DrawFocusRectangle(); } private void comboBoxConsentSubType_MeasureItem(object sender, MeasureItemEventArgs e) { e.ItemHeight = 20; } private void dataGridViewConsentSelectResult_Click(object sender, EventArgs e) { if (grdClickTimer.Tag.ToString().Equals("run")) { grdTimer_Tick(null, null); dataGridViewConsentSelectResult_DoubleClickProcessor(dataGridViewConsentSelectResult.SelectedRows[0].Index); } else { grdClickTimer.Start(); grdClickTimer.Tag = "run"; } } private void grdTimer_Tick(object sender, EventArgs e) { grdClickTimer.Stop(); grdClickTimer.Tag = "stop"; } /// /// dataGridViewConsentSelectResult 그리드 셀 더블클릭 이벤트(더블클릭이 안먹히는 경우에 들어갈 이벤트핸들러) /// /// The source of the event. /// The instance containing the event data. private void dataGridViewConsentSelectResult_DoubleClickProcessor(int row) { if (consentMain == null) consentMain = ConsentMainControl.GetConsentMainInterface(this); if (commandControl == null) commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl; // dbs227, 셀 클릭 시 더블클릭 인식되어 작동되는 경우 오류 if (row < 0) { return; } ConsentFormListVO vo = GetCurrentConsentSearchVO(row); // if (!consentMain.checkOperationDocument(vo.formCd)) { return; } string electrVisble = ConsentMainControl.SETTING_DATA["ELECTR_CMP"]; if (commandControl.CurrentTargetPatient.VisitType.Equals("O")) { if (electrVisble.Equals("Y")) { commandControl.setCompleteSaveButton(true); } } else { if (electrVisble.Equals("Y") && commandControl.CurrentEndUser.JobKindCd.Substring(0, 2).Equals("03")) { commandControl.setCompleteSaveButton(true); } else { commandControl.setCompleteSaveButton(false); } } //if (commandControl.CurrentTargetPatient.VisitType.Equals("O")) { // commandControl.setCompleteSaveButton(true); //} else { // if (ConsentMainControl.SETTING_DATA["ELECTR_CMP"].Equals("Y") && commandControl.CurrentEndUser.JobKindCd.Substring(0, 2).Equals("03")) { // commandControl.setCompleteSaveButton(true); // } else { // commandControl.setCompleteSaveButton(false); // } //} //의사가 아닐경우 확인저장 비활성화 //if (!commandControl.CurrentEndUser.JobKindCd.Substring(0, 2).Equals("03")) { // commandControl.setCompleteSaveButton(false); //} if (vo != null) { // 선택된 동의서가 현재 보여지고 있는 동의서와 다른 경우, 임시 저장 여부 확인 if (!consentMain.ConsentExecuteInfo["readOnly"].Equals("Y") && !string.IsNullOrEmpty(commandControl.CurrentTargetPatient.PatientCode) && commandControl.CurrentPreviewConsent != null && !commandControl.CurrentPreviewConsent.formRid.Equals(vo.formRid.ToString()) && (commandControl.CurrentPreviewConsent.consentState == string.Empty || commandControl.CurrentPreviewConsent.consentState == "TEMP")) { // dbs227, 임시저장 팝업 사용 안함 //DialogResult result = MessageBox.Show(string.Format(Properties.Resources.msg_confirm_tempsave) // , string.Format(Properties.Resources.msg_caption_confirm), // MessageBoxButtons.YesNo, MessageBoxIcon.Information); //if (result == DialogResult.Yes) { // consentMain.TempSave(); //} } Cursor currentCursor = this.Cursor; this.Cursor = Cursors.WaitCursor; ExecutePreviewWithSelectedConsent(vo); RunConsentDualView(); commandControl.SetEnableConsentIssueCommands(true); this.Cursor = currentCursor; } } } }