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

[설계자]

///

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

///

[원본 작성자]

///

클립소프트 기술부 이인희

///

[수정 작성자]

///

///

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

///

[HISTORY]

///

2016-07-11 : 최초작성

///

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

///
public partial class PatientSelectTabSearchPatient : UserControl { private IConsentMain consentMain = null; private ConsentCommandCtrl commandControl = null; private HospitalSvcRef.HospitalSvcSoapClient hospitalWebService = null; public PatientSelectTabSearchPatient() { InitializeComponent(); } private void PatientSelectTabSearchPatient_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; hospitalWebService = WebMethodCommon.GetHospitalWebService(consentMain.PluginExecuteInfo["hospitalSvcUrl"]); this.dateTimePickerClnDate.Value = DateTime.Now; InitComboBind(); InitDataGrid(); } private void InitComboBind() { // 진료과 //DeptListVO[] deptList = this.hospitalWebService.GetDeptList(GetSelectGubunValue(), consentMain.ConsentExecuteInfo["dutinstcd"]); DeptListVO[] deptList = this.hospitalWebService.GetOrgDeptList(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, "구분", "Gubun", true, 60);` CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "등록번호", "pid", true, 80); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "성명", "hngnm", true, 80); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "진료/입원일자", "indd", true, 120); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "진료과", "deptnm", true, 80); CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "진료의", "doctornm", true, 80); } #region 환자 조회 /// /// 선택된 조건으로 환자를 조회한다 /// private 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.Empty; string doctorid = (this.comboDoctor.Items.Count > 0) ? this.comboDoctor.SelectedValue.ToString().Trim() : String.Empty; string pid = this.textBoxSearchText.Text.Trim(); string patientOrdtype = GetSelectGubunValue(); Cursor currentCursor = this.Cursor; this.Cursor = Cursors.WaitCursor; PatListVO[] resultData = null; resultData = hospitalWebService.GetPatientList(patientOrdtype, "Y", srchdd, orddeptcd ?? String.Empty, doctorid ?? String.Empty, pid, "", "", consentMain.ConsentExecuteInfo["dutinstcd"], commandControl.CurrentEndUser.userId, "N", ""); this.Cursor = currentCursor; if (resultData != null) { this.dataGridViewPatientSelectResult.DataSource = new SortableBindingList(resultData); } } private string GetSelectGubunValue() { string strGubun = ""; RadioButton rdoTemp = null; if (this.radioGubunOut.Checked) { rdoTemp = radioGubunOut; } else if (this.radioGubunIn.Checked) { rdoTemp = radioGubunIn; } else if (this.radioGubunER.Checked) { rdoTemp = radioGubunER; } strGubun = rdoTemp.Tag.ToString(); return strGubun; } public Hashtable getQueryString() { //var result = new { // fromdd = dateTimePickerClnDate.Value.ToString("yyyyMMdd"), // wardcd = (this.comboWard.Items.Count > 0) ? this.comboWard.SelectedValue.ToString().Trim() : "", // deptcd = (this.comboDept.Items.Count > 0) ? this.comboDept.SelectedValue.ToString().Trim() : "", // doctorId = (this.comboDoctor.Items.Count > 0) ? this.comboDoctor.SelectedValue.ToString().Trim() : "" //}; string srchDd = dateTimePickerClnDate.Value.ToString("yyyyMMdd"); string deptcd = (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; string strGubun = ""; if (this.radioGubunOut.Checked) { strGubun = radioGubunOut.Tag.ToString(); } else if (this.radioGubunIn.Checked) { strGubun = radioGubunIn.Tag.ToString(); } else if (this.radioGubunER.Checked) { strGubun = radioGubunER.Tag.ToString(); } Hashtable result = new Hashtable(); result.Add("srchDd", srchDd); result.Add("ordDeptCd", deptcd); result.Add("doctorId", doctorId); result.Add("pid", pid); result.Add("patientState", strGubun); result.Add("srchYN", "Y"); result.Add("ordType", "S"); return result; } private void comboDept_SelectedIndexChanged(object sender, EventArgs e) { DocListVO[] doctorList = null; if (this.comboDept.SelectedIndex == 0) { doctorList = new DocListVO[1]; DocListVO doc = new DocListVO(); doc.doctorId = ""; doc.doctorNm = "진료의(전체)"; doc.drKind = ""; doctorList[0] = doc; this.comboDoctor.DisplayMember = "doctornm"; this.comboDoctor.ValueMember = "doctorid"; this.comboDoctor.DataSource = doctorList; return; } // 주치의 목록 조회 doctorList = this.hospitalWebService.GetDoctorList(DateTime.Now.ToShortDateString().Replace("-", ""), (this.comboDept.Items.Count > 0) ? this.comboDept.SelectedValue.ToString() : "" , 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("조회할 등록번호를 입력해주세요."); 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 textBoxSearchText_KeyDown(object sender, KeyEventArgs e) { // 엔터 키 입력 시 환자 조회 if (e.KeyCode == Keys.Enter) { buttonPatientSelect.PerformClick(); } } #endregion #region 그리드 이벤트 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; } } private void dataGridViewPatientSelectResult_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) { if (e.ColumnIndex == 0 && e.RowIndex == -1) { //bool chkStatus = false; //if (dataGridViewPatientSelectResult.Columns[0].HeaderText.Trim().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 ); } } 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); } } #endregion /// /// 체크박스 내용 삭제 /// public void ClearCheckBox() { bool chkStatus = false; //dataGridViewPatientSelectResult.Columns[0].HeaderText = "□"; foreach (DataGridViewRow r in dataGridViewPatientSelectResult.Rows) { r.Cells["colCheck"].Value = chkStatus; } dataGridViewPatientSelectResult.RefreshEdit(); } /// /// 현재 선택된 환자 목록 반환 /// /// PatListVO 목록 public List GetCheckPatList() { List voList = new List(); DataGridViewRow curRow = dataGridViewPatientSelectResult.CurrentRow; voList.Add(curRow.DataBoundItem as PatListVO); //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; } private void radioGubun_Click(object sender, EventArgs e) { bool isVisible = false; if (this.radioGubunOut.Checked) { isVisible = true; } commandControl.setCompleteSaveButton(isVisible); consentMain.ReInitializeViewer(); } } }