123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476 |
- 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 {
- /// <summary>
- /// 환자목록 > 입원 탭 클래스
- /// </summary>
- /// <remarks>
- /// <p>[설계자]</p>
- /// <p> 클립소프트 연구소 홍지철 (jchong@clipsoft.co.kr)</p>
- /// <p>[원본 작성자]</p>
- /// <p> 클립소프트 기술부 이인희</p>
- /// <p>[수정 작성자]</p>
- /// <p> </p>
- /// <p>----------------------------------------------------------------------------------------</p>
- /// <p>[HISTORY]</p>
- /// <p> 2016-07-11 : 최초작성</p>
- /// <p>----------------------------------------------------------------------------------------</p>
- /// </remarks>
- public partial class PatientSelectTabInPatient : UserControl {
- private IConsentMain consentMain = null;
- private ConsentCommandCtrl commandControl = null;
- private HospitalSvcRef.HospitalSvcSoapClient hospitalWebService = null;
- public PatientSelectTabInPatient() {
- InitializeComponent();
- }
- private void PatientSelectTabInPatient_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"]);
- if (ConsentMainControl.SETTING_DATA["MY_PATIENT"].Equals("Y")) {
- chkMyPatient.Visible = true;
- }
- // 의사로 Agent 를 실행할 경우 입원 환자 탭에서 내환자 체크 박스 숨기기
- if(commandControl.CurrentEndUser != null) {
- if(!string.IsNullOrEmpty(commandControl.CurrentEndUser.JobKindCd)) {
- if(!commandControl.CurrentEndUser.JobKindCd.Substring(0, 2).Equals("11")) {
- chkMyPatient.Visible = false;
- }
- }
- }
- this.dateTimePickerClnDate.Value = DateTime.Now;
- InitComboBind();
- foreach(DeptListVO ward in (DeptListVO[])comboWard.DataSource) {
- if(ward.deptCd.Equals(commandControl.CurrentEndUser.DeptCode)) {
- comboWard.SelectedValue = commandControl.CurrentEndUser.DeptCode;
- break;
- }
- }
- InitDataGrid();
- }
- private void InitComboBind() {
- // 병동 정보 가져오기 및 설정
- DeptListVO[] wardList = this.hospitalWebService.GetWardList(this.consentMain.ConsentExecuteInfo["dutinstcd"]);
- if(wardList != null) {
- this.comboWard.DisplayMember = "deptnm";
- this.comboWard.ValueMember = "deptcd";
- this.comboWard.DataSource = wardList;
- }
- // 진료과 정보 가져오기 및 설정
- 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, "입원일자", "indd", true, 70);
- CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "병실", "roomcd", true, 40);
- CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "성명", "hngnm", true, 80);
- CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "등록번호", "pid", true, 60);
- CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "과", "deptnm", true, 120);
- CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "주치의", "doctornm", true, 80);
- CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "구분", "dschnoti", true, 80);
- //dataGridViewPatientSelectResult.Columns["colCheck"].Visible = false;
- }
- #region 환자 조회
- /// <summary>
- /// 선택된 구분 종류 반환
- /// </summary>
- /// <returns></returns>
- private string GetSelectGubunValue() {
- string strGubun = "";
- if(this.radioGubunAll.Checked) {
- strGubun = "A";
- }
- else {
- RadioButton rdoTemp = null;
- if(this.radioGubunFuture.Checked)
- rdoTemp = radioGubunFuture;
- else if(this.radioGubunIng.Checked)
- rdoTemp = radioGubunIng;
- else if(this.radioGubunOut.Checked)
- rdoTemp = radioGubunOut;
- strGubun = rdoTemp.Tag.ToString();
- }
- return strGubun;
- }
- 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 doctorid = (this.comboDoctor.Items.Count > 0) ? this.comboDoctor.SelectedValue.ToString().Trim() : "";
- string pid = this.textBoxSearchText.Text.Trim();
- string wardcd = (this.comboWard.Items.Count > 0) ? this.comboWard.SelectedValue.ToString().Trim() : "";
- string patstat = GetSelectGubunValue();
- DocListVO selectedDoctor = comboDoctor.SelectedItem as DocListVO;
- Cursor currentCursor = this.Cursor;
- this.Cursor = Cursors.WaitCursor;
- // 입원 환자 목록 조회
- PatListVO[] resultData = hospitalWebService.GetPatientList(srchdd
- , orddeptcd
- , doctorid
- , pid
- , patstat
- , this.consentMain.ConsentExecuteInfo["dutinstcd"]
- , wardcd
- , this.consentMain.ConsentExecuteInfo["loginUserNo"]
- , chkMyPatient.Checked ? "Y" : string.Empty
- , string.Empty
- , selectedDoctor.drKind ?? ""
- , "I" // 입원
- , "N" // 검색탭 여부(Y: 검색탭, N: 그외)
- );
- this.Cursor = currentCursor;
- if(resultData == null) {
- return;
- }
- this.dataGridViewPatientSelectResult.DataSource = new SortableBindingList<PatListVO>(resultData);
- }
- /// <summary>
- /// 진료과 콤보 박스 아이템 변경 이벤트
- /// </summary>
- /// <param name="sender">The source of the event.</param>
- /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
- 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.ToString() : "", this.consentMain.ConsentExecuteInfo["dutinstcd"]);
- if(doctorList != null) {
- this.comboDoctor.DisplayMember = "doctornm";
- this.comboDoctor.ValueMember = "doctorid";
- this.comboDoctor.DataSource = doctorList;
- }
- }
- /// <summary>
- /// 조회 버튼 클릭 이벤트
- /// </summary>
- /// <param name="sender">The source of the event.</param>
- /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
- private void buttonPatientSelect_Click(object sender, EventArgs e) {
- var selectedWardIndex = this.comboWard.SelectedIndex;
- var selectedDeptIndex = this.comboDept.SelectedIndex;
- var selectedDoctorIndex = this.comboDoctor.SelectedIndex;
- var patientNameValue = this.textBoxSearchText.Text;
- if(selectedWardIndex == 0 && selectedDeptIndex == 0 && selectedDoctorIndex == 0 && String.Empty.Equals(patientNameValue)) {
- MessageBox.Show("병동, 진료과, 등록번호 중 1가지 이상 입력해주세요.");
- return;
- }
- buttonPatientSelect.Enabled = false;
- Application.DoEvents();
- try {
- BindDataGridRows();
- }
- catch(Exception ex) {
- throw ex;
- }
- finally {
- buttonPatientSelect.Enabled = true;
- }
- }
- #endregion
- #region 환자찾기 버튼 클릭 이벤트
- /// <summary>
- /// 환자 찾기 버튼 클릭 이벤트, 환자 조회 팝업창 생성
- /// </summary>
- /// <param name="sender">The source of the event.</param>
- /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
- 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();
- }
- }
- /// <summary>
- /// 등록번호 입력 컨트롤 키보드 입력 이벤트
- /// </summary>
- /// <param name="sender">The source of the event.</param>
- /// <param name="e">The <see cref="KeyEventArgs"/> instance containing the event data.</param>
- private void textBoxSearchText_KeyDown(object sender, KeyEventArgs e) {
- if(e.KeyCode == Keys.Enter) {
- this.buttonSearchPop.PerformClick();
- }
- }
- #endregion
- #region 그리드 이벤트
- /// <summary>
- /// 그리드 그리기 이벤트
- /// </summary>
- /// <param name="sender">The source of the event.</param>
- /// <param name="e">The <see cref="DataGridViewCellPaintingEventArgs"/> instance containing the event data.</param>
- 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;
- //}
- }
- /// <summary>
- /// 컬럼 헤드 클릭 이벤트
- /// 선택 여부 체크박스 값 설정
- /// </summary>
- /// <param name="sender">The source of the event.</param>
- /// <param name="e">The <see cref="DataGridViewCellMouseEventArgs"/> instance containing the event data.</param>
- 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();
- //}
- }
- /// <summary>
- /// 그리드 그리기 이후 이벤트, 행 번호 추가
- /// </summary>
- /// <param name="sender">The source of the event.</param>
- /// <param name="e">The <see cref="DataGridViewRowPostPaintEventArgs"/> instance containing the event data.</param>
- 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
- );
- }
- }
- /// <summary>
- /// 입원 환자 목록 그리드 셀 더블클릭 이벤트
- /// </summary>
- /// <param name="sender">The source of the event.</param>
- /// <param name="e">The <see cref="DataGridViewCellEventArgs"/> instance containing the event data.</param>
- 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();
- }
- public List<PatListVO> GetCheckPatList() {
- List<PatListVO> voList = new List<PatListVO>();
- foreach(DataGridViewRow r in dataGridViewPatientSelectResult.Rows) {
- if(Convert.ToBoolean(r.Cells["colCheck"].Value)) {
- voList.Add(r.DataBoundItem as PatListVO);
- }
- }
- return voList;
- }
- private void comboWard_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 comboWard_MeasureItem(object sender, MeasureItemEventArgs e) {
- e.ItemHeight = 20;
- }
- 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;
- }
- }
- }
|