PatientSelectTabSearchPatient.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. using System;
  2. using System.Drawing;
  3. using System.ComponentModel;
  4. using System.Windows.Forms;
  5. using System.Collections.Generic;
  6. using CLIP.eForm.Consent.Dfh.UI.HospitalSvcRef;
  7. namespace CLIP.eForm.Consent.Dfh.UI
  8. {
  9. /// <summary>
  10. /// 환자목록 > 환자검색 탭 클래스
  11. /// </summary>
  12. /// <remarks>
  13. /// <p>[설계자]</p>
  14. /// <p> 클립소프트 연구소 홍지철 (jchong@clipsoft.co.kr)</p>
  15. /// <p>[원본 작성자]</p>
  16. /// <p> 클립소프트 기술부 이인희</p>
  17. /// <p>[수정 작성자]</p>
  18. /// <p> </p>
  19. /// <p>----------------------------------------------------------------------------------------</p>
  20. /// <p>[HISTORY]</p>
  21. /// <p> 2016-07-11 : 최초작성</p>
  22. /// <p>----------------------------------------------------------------------------------------</p>
  23. /// </remarks>
  24. public partial class PatientSelectTabSearchPatient : UserControl
  25. {
  26. private IConsentMain consentMain = null;
  27. private HospitalSvcRef.HospitalSvcSoapClient hospitalWebService = null;
  28. public PatientSelectTabSearchPatient()
  29. {
  30. InitializeComponent();
  31. }
  32. private void PatientSelectTabSearchPatient_Load(object sender, EventArgs e)
  33. {
  34. Boolean isInWpfDesignerMode = (LicenseManager.UsageMode == LicenseUsageMode.Designtime);
  35. Boolean isInFormsDesignerMode = (System.Diagnostics.Process.GetCurrentProcess().ProcessName == "devenv");
  36. if (isInWpfDesignerMode || isInFormsDesignerMode)
  37. {
  38. // is in any designer mode
  39. return;
  40. }
  41. if (this.DesignMode || LicenseManager.UsageMode == LicenseUsageMode.Designtime)
  42. {
  43. return;
  44. }
  45. consentMain = ConsentMainControl.GetConsentMainInterface(this);
  46. hospitalWebService = WebMethodCommon.GetHospitalWebService(consentMain.PluginExecuteInfo["hospitalSvcUrl"]);
  47. this.dateTimePickerClnDate.Value = DateTime.Now;
  48. InitComboBind();
  49. InitDataGrid();
  50. }
  51. private void InitComboBind()
  52. {
  53. // 진료과
  54. DeptListVO[] deptList = this.hospitalWebService.GetDeptList(GetSelectGubunValue());
  55. if (deptList != null)
  56. {
  57. this.comboDept.DisplayMember = "deptnm";
  58. this.comboDept.ValueMember = "deptcd";
  59. this.comboDept.DataSource = deptList;
  60. }
  61. }
  62. private void InitDataGrid()
  63. {
  64. this.dataGridViewPatientSelectResult.AutoGenerateColumns = false;
  65. this.dataGridViewPatientSelectResult.AllowUserToAddRows = false;
  66. //this.dataGridViewPatientSelectResult.CellPainting += new DataGridViewCellPaintingEventHandler(this.dataGridViewPatientSelectResult_CellPainting);
  67. this.dataGridViewPatientSelectResult.ColumnHeaderMouseClick += new DataGridViewCellMouseEventHandler(this.dataGridViewPatientSelectResult_ColumnHeaderMouseClick);
  68. this.dataGridViewPatientSelectResult.RowPostPaint += new DataGridViewRowPostPaintEventHandler(this.dataGridViewPatientSelectResult_RowPostPaint);
  69. CommonUtil.AddNewCheckBoxColumnToDataGridView(this.dataGridViewPatientSelectResult, "□", "colCheck", true, 30, DataGridViewContentAlignment.MiddleCenter);
  70. //CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "구분", "Gubun", true, 60);
  71. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "등록번호", "pid", true, 80);
  72. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "성명", "hngnm", true, 80);
  73. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "진료/입원일자", "indd", true, 120);
  74. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "진료과", "deptnm", true, 80);
  75. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "진료의", "doctornm", true, 80);
  76. }
  77. #region 환자 조회
  78. private void BindDataGridRows()
  79. {
  80. if (this.consentMain == null) consentMain = ConsentMainControl.GetConsentMainInterface(this);
  81. if (this.hospitalWebService == null) this.hospitalWebService = WebMethodCommon.GetHospitalWebService(consentMain.PluginExecuteInfo["hospitalSvcUrl"]);
  82. string srchdd = this.dateTimePickerClnDate.Value.ToShortDateString().Replace("-", "");
  83. string orddeptcd = (this.comboDept.Items.Count > 0) ? this.comboDept.SelectedValue.ToString().Trim() : "";
  84. string doctorid = (this.comboDoctor.Items.Count > 0) ? this.comboDoctor.SelectedValue.ToString().Trim() : "";
  85. string pid = this.textBoxSearchText.Text.Trim();
  86. string patstat = GetSelectGubunValue();
  87. PatListVO[] resultData = hospitalWebService.GetSrPatList(srchdd, orddeptcd, doctorid, pid, patstat);
  88. if (resultData == null)
  89. {
  90. return;
  91. }
  92. this.dataGridViewPatientSelectResult.DataSource = new SortableBindingList<PatListVO>(resultData);
  93. }
  94. private string GetSelectGubunValue()
  95. {
  96. string strGubun = "";
  97. RadioButton rdoTemp = null;
  98. if (this.radioGubunOut.Checked)
  99. rdoTemp = radioGubunOut;
  100. else if (this.radioGubunIn.Checked)
  101. rdoTemp = radioGubunIn;
  102. else if (this.radioGubunER.Checked)
  103. rdoTemp = radioGubunER;
  104. strGubun = rdoTemp.Tag.ToString();
  105. return strGubun;
  106. }
  107. private void comboDept_SelectedIndexChanged(object sender, EventArgs e)
  108. {
  109. // 주치의
  110. DocListVO[] doctorList = this.hospitalWebService.GetDoctorList(DateTime.Now.ToShortDateString().Replace("-", ""),
  111. (this.comboDept.Items.Count > 0) ? this.comboDept.SelectedValue.ToString() : "");
  112. if (doctorList != null)
  113. {
  114. this.comboDoctor.DisplayMember = "doctornm";
  115. this.comboDoctor.ValueMember = "doctorid";
  116. this.comboDoctor.DataSource = doctorList;
  117. }
  118. }
  119. private void buttonPatientSelect_Click(object sender, EventArgs e)
  120. {
  121. Cursor currentCursor = this.Cursor;
  122. try
  123. {
  124. this.Cursor = Cursors.WaitCursor;
  125. BindDataGridRows();
  126. }
  127. catch (Exception ex)
  128. {
  129. throw ex;
  130. }
  131. finally
  132. {
  133. this.Cursor = currentCursor;
  134. }
  135. }
  136. #endregion
  137. #region 환자찾기 버튼 클릭 이벤트
  138. private void buttonSearchPop_Click(object sender, EventArgs e)
  139. {
  140. string strTemp = this.textBoxSearchText.Text.Trim();
  141. int iResult;
  142. if (int.TryParse(strTemp, out iResult) && strTemp.Length > 6)
  143. {
  144. this.buttonPatientSelect.PerformClick();
  145. }
  146. else
  147. {
  148. PatientSearchPopup popup = new PatientSearchPopup(textBoxSearchText.Text);
  149. DialogResult result = popup.ShowDialog();
  150. if (result == DialogResult.OK)
  151. {
  152. this.textBoxSearchText.Text = popup.PatientID;
  153. this.buttonPatientSelect.PerformClick();
  154. }
  155. popup.Close();
  156. }
  157. }
  158. private void textBoxSearchText_KeyDown(object sender, KeyEventArgs e)
  159. {
  160. if (e.KeyCode == Keys.Enter)
  161. {
  162. this.buttonSearchPop.PerformClick();
  163. }
  164. }
  165. #endregion
  166. #region 그리드 이벤트
  167. private void dataGridViewPatientSelectResult_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
  168. {
  169. if (e.ColumnIndex == 0 && e.RowIndex == -1)
  170. {
  171. Image InfoIcon;
  172. if (dataGridViewPatientSelectResult.Columns[0].HeaderText.Equals("□"))
  173. {
  174. InfoIcon = Image.FromFile(@"../../Resources/uncheck.png");
  175. }
  176. else
  177. {
  178. InfoIcon = Image.FromFile(@"../../Resources/check.png");
  179. }
  180. e.Paint(e.CellBounds, DataGridViewPaintParts.All);
  181. e.Graphics.DrawImage(InfoIcon, e.CellBounds);
  182. e.Handled = true;
  183. }
  184. }
  185. private void dataGridViewPatientSelectResult_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
  186. {
  187. if (e.ColumnIndex == 0 && e.RowIndex == -1)
  188. {
  189. bool chkStatus = false;
  190. if (dataGridViewPatientSelectResult.Columns[0].HeaderText.Trim().Equals("□"))
  191. {
  192. dataGridViewPatientSelectResult.Columns[0].HeaderText = "☑";
  193. chkStatus = true;
  194. }
  195. else
  196. {
  197. dataGridViewPatientSelectResult.Columns[0].HeaderText = "□";
  198. }
  199. foreach (DataGridViewRow r in dataGridViewPatientSelectResult.Rows)
  200. {
  201. r.Cells["colCheck"].Value = chkStatus;
  202. }
  203. dataGridViewPatientSelectResult.RefreshEdit();
  204. }
  205. }
  206. private void dataGridViewPatientSelectResult_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
  207. {
  208. if (e.RowIndex >= 0)
  209. {
  210. string NumberingText = (e.RowIndex + 1).ToString();
  211. // 글자 사이즈 구하기.
  212. SizeF stringSize = e.Graphics.MeasureString(NumberingText, Font);
  213. // 글자에 맞춰 좌표계산.
  214. PointF StringPoint = new PointF
  215. (
  216. Convert.ToSingle(this.dataGridViewPatientSelectResult.RowHeadersWidth - 3 - stringSize.Width),
  217. Convert.ToSingle(e.RowBounds.Y) + this.dataGridViewPatientSelectResult[0, e.RowIndex].ContentBounds.Height * 0.3f
  218. );
  219. // 문자열 그리기.
  220. e.Graphics.DrawString
  221. (
  222. NumberingText,
  223. Font,
  224. Brushes.Black,
  225. StringPoint.X,
  226. StringPoint.Y
  227. );
  228. }
  229. }
  230. private void dataGridViewPatientSelectResult_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  231. {
  232. if (e.RowIndex > -1)
  233. {
  234. PatListVO vo = this.dataGridViewPatientSelectResult.Rows[e.RowIndex].DataBoundItem as PatListVO;
  235. consentMain.PatientListCtrl.SetChangePID(vo);
  236. }
  237. }
  238. #endregion
  239. public void ClearCheckBox()
  240. {
  241. bool chkStatus = false;
  242. dataGridViewPatientSelectResult.Columns[0].HeaderText = "□";
  243. foreach (DataGridViewRow r in dataGridViewPatientSelectResult.Rows)
  244. {
  245. r.Cells["colCheck"].Value = chkStatus;
  246. }
  247. dataGridViewPatientSelectResult.RefreshEdit();
  248. }
  249. public List<PatListVO> GetCheckPatList()
  250. {
  251. List<PatListVO> voList = new List<PatListVO>();
  252. foreach (DataGridViewRow r in dataGridViewPatientSelectResult.Rows)
  253. {
  254. if (Convert.ToBoolean(r.Cells["colCheck"].Value))
  255. {
  256. voList.Add(r.DataBoundItem as PatListVO);
  257. }
  258. }
  259. return voList;
  260. }
  261. }
  262. }