using System; using System.Drawing; using System.ComponentModel; using System.Windows.Forms; using System.Collections.Generic; using CLIP.eForm.Consent.UI.HospitalSvcRef; namespace CLIP.eForm.Consent.UI { /// /// 환자목록 > 외래 탭 클래스 /// /// ///

[설계자]

///

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

///

[원본 작성자]

///

클립소프트 기술부 이인희

///

[수정 작성자]

///

///

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

///

[HISTORY]

///

2016-07-11 : 최초작성

///

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

///
public partial class PatientSelectTabOutPatient : UserControl { private IConsentMain consentMain = null; private ConsentCommandCtrl commandControl = null; private HospitalSvcRef.HospitalSvcSoapClient hospitalWebService = null; public PatientSelectTabOutPatient() { InitializeComponent(); } private void PatientSelectTabOutPatient_Load(object sender, EventArgs e) { if(this.DesignMode || LicenseManager.UsageMode == LicenseUsageMode.Designtime) { return; } consentMain = ConsentMainControl.GetConsentMainInterface(this); if(commandControl == null) commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl; hospitalWebService = WebMethodCommon.GetHospitalWebService(consentMain.PluginExecuteInfo["hospitalSvcUrl"]); // 진료일자를 오늘 날자로 설정 this.dateTimePickerClnDate.Value = DateTime.Now; InitComboBind(); // 현재 사용자의 진료과로 설정한다 setSearchDeptCode(commandControl.CurrentEndUser.DeptCode); InitDataGrid(); } /// /// clnDeptCode 로 진료과를 설정한다 /// /// 설정할 진료과 코드 public void setSearchDeptCode(string clnDeptCode) { if(!string.IsNullOrEmpty(clnDeptCode) && this.comboDept != null) { foreach(DeptListVO dept in (DeptListVO[])comboDept.DataSource) { if(dept.deptCd.Equals(clnDeptCode)) { comboDept.SelectedValue = clnDeptCode; break; } } } } private void InitComboBind() { // 진료과 DeptListVO[] deptList = this.hospitalWebService.GetDeptList(GetSelectGubunValue(), this.consentMain.ConsentExecuteInfo["dutinstcd"]); if(deptList != null) { this.comboDept.DisplayMember = "deptnm"; this.comboDept.ValueMember = "deptcd"; this.comboDept.DataSource = deptList; } } private void InitDataGrid() { this.dataGridViewPatientSelectResult.AutoGenerateColumns = false; this.dataGridViewPatientSelectResult.AllowUserToAddRows = false; //this.dataGridViewPatientSelectResult.CellPainting += new DataGridViewCellPaintingEventHandler(this.dataGridViewPatientSelectResult_CellPainting); this.dataGridViewPatientSelectResult.ColumnHeaderMouseClick += new DataGridViewCellMouseEventHandler(this.dataGridViewPatientSelectResult_ColumnHeaderMouseClick); this.dataGridViewPatientSelectResult.RowPostPaint += new DataGridViewRowPostPaintEventHandler(this.dataGridViewPatientSelectResult_RowPostPaint); //CommonUtil.AddNewCheckBoxColumnToDataGridView(this.dataGridViewPatientSelectResult, "□", "colCheck", true, 30, DataGridViewContentAlignment.MiddleCenter); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "등록번호", "pid", true, 60); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "성명", "hngnm", true, 80); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "구분", "elbulbodstat", true, 40); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "초진", "fsexamflag", true, 60); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "진료일자", "indd", true, 80); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "시간", "ordtm", true, 60); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "과", "deptengabbr", true, 40); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "진료의", "doctornm", true, 80); //dataGridViewPatientSelectResult.Columns["colCheck"].Visible = false; } #region 환자 조회 /// /// 환자 조회 /// public void BindDataGridRows() { if(this.consentMain == null) consentMain = ConsentMainControl.GetConsentMainInterface(this); if(this.hospitalWebService == null) this.hospitalWebService = WebMethodCommon.GetHospitalWebService(consentMain.PluginExecuteInfo["hospitalSvcUrl"]); string srchdd = this.dateTimePickerClnDate.Value.ToShortDateString().Replace("-", ""); string orddeptcd = (this.comboDept.Items.Count > 0) ? this.comboDept.SelectedValue.ToString().Trim() : ""; string doctorid = (this.comboDoctor.Items.Count > 0) ? this.comboDoctor.SelectedValue.ToString().Trim() : ""; string pid = this.textBoxSearchText.Text.Trim(); string patstat = GetSelectGubunValue(); Cursor currentCursor = this.Cursor; this.Cursor = Cursors.WaitCursor; DocListVO selectedDoctor = comboDoctor.SelectedItem as DocListVO; var drKindValue = ""; if(selectedDoctor != null && selectedDoctor.drKind != null) { drKindValue = selectedDoctor.drKind.Trim(); } PatListVO[] resultData = hospitalWebService.GetPatientList(srchdd , orddeptcd , doctorid , pid , patstat , this.consentMain.ConsentExecuteInfo["dutinstcd"] , "" , this.consentMain.ConsentExecuteInfo["loginUserNo"] , "" , string.Empty , drKindValue ?? "" , "O" // 외래 , "N" // 검색탭 여부(Y: 검색탭, N: 그외) ); this.Cursor = currentCursor; if(resultData == null) { return; } this.dataGridViewPatientSelectResult.DataSource = new SortableBindingList(resultData); } /// /// 검색할 조건을 반환한다 /// /// 조회 질의어 private string GetSelectGubunValue() { string strGubun = ""; if(this.radioGubunAll.Checked) { strGubun = "A"; } else { RadioButton rdoTemp = null; if (this.radioGubunStep1.Checked) rdoTemp = radioGubunStep1; else if (this.radioGubunStep2.Checked) rdoTemp = radioGubunStep2; else if (this.radioGubunStep3.Checked) rdoTemp = radioGubunStep3; else if (this.radioGubunStep3.Checked) rdoTemp = radioGubunStep4; strGubun = rdoTemp.Tag.ToString(); } return strGubun; } /// /// 부서명 콤보 박스 아이템 변경 이벤트 /// /// The source of the event. /// The instance containing the event data. private void comboDept_SelectedIndexChanged(object sender, EventArgs e) { // 주치의 목록을 가져온다 DocListVO[] doctorList = this.hospitalWebService.GetDoctorList(DateTime.Now.ToShortDateString().Replace("-", ""), (this.comboDept.Items.Count > 0 && this.comboDept.SelectedValue != null) ? this.comboDept.SelectedValue.ToString() : "" , this.consentMain.ConsentExecuteInfo["dutinstcd"]); if(doctorList != null) { this.comboDoctor.DisplayMember = "doctornm"; this.comboDoctor.ValueMember = "doctorid"; this.comboDoctor.DataSource = doctorList; } } /// /// 환자 조회 버튼 클릭 이벤트 /// /// The source of the event. /// The instance containing the event data. private void buttonPatientSelect_Click(object sender, EventArgs e) { var selectedDeptIndex = this.comboDept.SelectedIndex; var selectedDoctorIndex = this.comboDoctor.SelectedIndex; var patientNameValue = this.textBoxSearchText.Text; if(selectedDeptIndex == 0 && selectedDoctorIndex == 0 && String.Empty.Equals(patientNameValue)) { MessageBox.Show("진료과, 등록번호 중 1가지 이상 입력해주세요."); return; } Cursor currentCursor = this.Cursor; try { this.Cursor = Cursors.WaitCursor; BindDataGridRows(); } catch(Exception ex) { throw ex; } finally { this.Cursor = currentCursor; } } #endregion #region 환자찾기 버튼 클릭 이벤트 /// /// 환자찾기 버튼 클릭 이벤트 /// /// The source of the event. /// The instance containing the event data. private void buttonSearchPop_Click(object sender, EventArgs e) { string strTemp = this.textBoxSearchText.Text.Trim(); int iResult; if(int.TryParse(strTemp, out iResult) && strTemp.Length > 6) { this.buttonPatientSelect.PerformClick(); } else { // 환자찾기 팝업 생성 PatientSearchPopup popup = new PatientSearchPopup(textBoxSearchText.Text , consentMain.ConsentExecuteInfo["dutinstcd"] , consentMain.ConsentExecuteInfo["sysInstNm"]); DialogResult result = popup.ShowDialog(); if(result == DialogResult.OK) { this.textBoxSearchText.Text = popup.PatientID; this.buttonPatientSelect.PerformClick(); } popup.Close(); } } /// /// 등록번호 텍스트 입력 이벤트 /// /// The source of the event. /// The instance containing the event data. private void textBoxSearchText_KeyDown(object sender, KeyEventArgs e) { if(e.KeyCode == Keys.Enter) { this.buttonSearchPop.PerformClick(); } } #endregion #region 그리드 이벤트 /// /// 그리기 이벤트 시 체크박스 상태값에 따라 다른 이미지를 설정한다 /// /// The source of the event. /// The instance containing the event data. private void dataGridViewPatientSelectResult_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) { /// 그리드 이벤트 //if(e.ColumnIndex == 0 && e.RowIndex == -1) { // Image InfoIcon; // if(dataGridViewPatientSelectResult.Columns[0].HeaderText.Equals("□")) { // InfoIcon = Image.FromFile(@"../../Resources/uncheck.png"); // } // else { // InfoIcon = Image.FromFile(@"../../Resources/check.png"); // } // e.Paint(e.CellBounds, DataGridViewPaintParts.All); // e.Graphics.DrawImage(InfoIcon, e.CellBounds); // e.Handled = true; //} } /// /// 컬럼 헤드 클릭 이벤트 /// /// The source of the event. /// The instance containing the event data. private void dataGridViewPatientSelectResult_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) { //if(e.ColumnIndex == 0 && e.RowIndex == -1) { // bool chkStatus = false; // if(dataGridViewPatientSelectResult.Columns[0].HeaderText.Equals("□")) { // dataGridViewPatientSelectResult.Columns[0].HeaderText = "☑"; // chkStatus = true; // } // else { // dataGridViewPatientSelectResult.Columns[0].HeaderText = "□"; // } // foreach(DataGridViewRow r in dataGridViewPatientSelectResult.Rows) { // r.Cells["colCheck"].Value = chkStatus; // } // dataGridViewPatientSelectResult.RefreshEdit(); //} } private void dataGridViewPatientSelectResult_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e) { if(e.RowIndex >= 0) { string NumberingText = (e.RowIndex + 1).ToString(); // 글자 사이즈 구하기. SizeF stringSize = e.Graphics.MeasureString(NumberingText, Font); // 글자에 맞춰 좌표계산. PointF StringPoint = new PointF ( Convert.ToSingle(this.dataGridViewPatientSelectResult.RowHeadersWidth - 3 - stringSize.Width), Convert.ToSingle(e.RowBounds.Y) + this.dataGridViewPatientSelectResult[0, e.RowIndex].ContentBounds.Height * 0.3f ); // 문자열 그리기. e.Graphics.DrawString ( NumberingText, Font, Brushes.Black, StringPoint.X, StringPoint.Y ); } } /// /// 외래 환자 리스트 그리드 셀 더블클릭 이벤트 /// /// The source of the event. /// The instance containing the event data. private void dataGridViewPatientSelectResult_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if(e.RowIndex > -1) { PatListVO vo = this.dataGridViewPatientSelectResult.Rows[e.RowIndex].DataBoundItem as PatListVO; // 현재 선택된 환자를 바꾼다 consentMain.PatientListCtrl.SetChangePID(vo); consentMain = ConsentMainControl.GetConsentMainInterface(this); if(commandControl == null) commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl; // 현재환자의 진료과로 변경한다 setSearchDeptCode(commandControl.CurrentTargetPatient.clnDeptCode); } } #endregion public void ClearCheckBox() { //bool chkStatus = false; //dataGridViewPatientSelectResult.Columns[0].HeaderText = "□"; //foreach(DataGridViewRow r in dataGridViewPatientSelectResult.Rows) { // r.Cells["colCheck"].Value = chkStatus; //} //dataGridViewPatientSelectResult.RefreshEdit(); } public List GetCheckPatList() { List voList = new List(); foreach(DataGridViewRow r in dataGridViewPatientSelectResult.Rows) { if(Convert.ToBoolean(r.Cells["colCheck"].Value)) { voList.Add(r.DataBoundItem as PatListVO); } } return voList; } private void comboDept_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(((DeptListVO[])box.DataSource)[e.Index].deptNm, e.Font, textBrush, (float)e.Bounds.X, (float)(e.Bounds.Y) + 2.34F); } } } e.DrawFocusRectangle(); } private void comboDept_MeasureItem(object sender, MeasureItemEventArgs e) { e.ItemHeight = 20; } private void comboDoctor_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(((DocListVO[])box.DataSource)[e.Index].doctorNm, e.Font, textBrush, (float)e.Bounds.X, (float)(e.Bounds.Y) + 2.34F); } } } e.DrawFocusRectangle(); } private void comboDoctor_MeasureItem(object sender, MeasureItemEventArgs e) { e.ItemHeight = 20; } } }