#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 ConsentVO = CLIP.eForm.Consent.UI.ConsentSvcRef.ConsentVO; 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, "서식 ID", "formId", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "서식상태", "consentStateDisp", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "OCRTAG 출력여부", "ocrTagYN", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "출력 매수", "prntCnt", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "울력전용", "prntOnly", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "서식 출력명", "formPrintName", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "의사 전용 서식 여부", "DrOnly", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "기관번호", "instCd", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "진료과코드", "clnDeptCd", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "진료과명", "clnDeptNm", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "내원일", "clnDate", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "주치의", "mainDrId", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "병동코드", "wardCd", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "병실코드", "roomCd", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "수술진단명", "opDiagName", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "수술명", "opName", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "수술예약번호", "opRsrvNo", false); 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, "수정자 아이디", "modifyUserId", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "생성자 이름", "modifyUserName", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "OCRTAG", "ocrTag", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "환자번호", "pid", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "ordtype", "ordType", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "cretNo", "cretNo", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "patientName", "patientName", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "consentState", "consentState", false); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewConsentSelectResult, "certUseYn", "certUseYn", 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; } ConsentVO[] arrayData = consentWebService.GetConsentBySearch(consentType, keyWord, consentMain.ConsentExecuteInfo["dutinstcd"]); 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; } ConsentVO 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.formId.Equals(vo.formId.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 { ConsentVO 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 ConsentVO GetCurrentConsentSearchVO(int rowIndex) { ConsentVO vo = null; if (rowIndex < 0) { return vo; } vo = this.dataGridViewConsentSelectResult.Rows[rowIndex].DataBoundItem as ConsentVO; return vo; } private void ExecutePreviewWithSelectedConsent(ConsentVO 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 { formId = vo.formId.ToString(), formCd = vo.formCd.ToString(), formName = vo.formName, formPrintName = vo.formPrintName, prntCnt = vo.prntCnt, consentMstRid = "-1", consentState = string.Empty, consentStateEng = string.Empty, inputId = commandControl.CurrentEndUser.UserNo, inputNm = commandControl.CurrentEndUser.UserName, ReissueConsentMstRid = 0, RewriteConsentMstRid = 0, ocrtagPrntyn = vo.ocrTagYN, userDrFlag = vo.userDrFlag, printOnly = vo.prntOnly, opDiagName = vo.opDiagName, opName = vo.opName, 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; } ConsentVO 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.formId.Equals(vo.formId.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; } } } }