PatientSelectTabInPatient.cs 12 KB

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