PatientSelectTabSearchPatient.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  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.UI.HospitalSvcRef;
  7. namespace CLIP.eForm.Consent.UI {
  8. /// <summary>
  9. /// 환자목록 > 환자검색 탭 클래스
  10. /// </summary>
  11. /// <remarks>
  12. /// <p>[설계자]</p>
  13. /// <p> 클립소프트 연구소 홍지철 (jchong@clipsoft.co.kr)</p>
  14. /// <p>[원본 작성자]</p>
  15. /// <p> 클립소프트 기술부 이인희</p>
  16. /// <p>[수정 작성자]</p>
  17. /// <p> </p>
  18. /// <p>----------------------------------------------------------------------------------------</p>
  19. /// <p>[HISTORY]</p>
  20. /// <p> 2016-07-11 : 최초작성</p>
  21. /// <p>----------------------------------------------------------------------------------------</p>
  22. /// </remarks>
  23. public partial class PatientSelectTabSearchPatient : UserControl {
  24. private IConsentMain consentMain = null;
  25. private HospitalSvcRef.HospitalSvcSoapClient hospitalWebService = null;
  26. public PatientSelectTabSearchPatient() {
  27. InitializeComponent();
  28. }
  29. private void PatientSelectTabSearchPatient_Load(object sender, EventArgs e) {
  30. Boolean isInWpfDesignerMode = (LicenseManager.UsageMode == LicenseUsageMode.Designtime);
  31. Boolean isInFormsDesignerMode = (System.Diagnostics.Process.GetCurrentProcess().ProcessName == "devenv");
  32. if(isInWpfDesignerMode || isInFormsDesignerMode) {
  33. // is in any designer mode
  34. return;
  35. }
  36. if(this.DesignMode || LicenseManager.UsageMode == LicenseUsageMode.Designtime) {
  37. return;
  38. }
  39. consentMain = ConsentMainControl.GetConsentMainInterface(this);
  40. hospitalWebService = WebMethodCommon.GetHospitalWebService(consentMain.PluginExecuteInfo["hospitalSvcUrl"]);
  41. this.dateTimePickerClnDate.Value = DateTime.Now;
  42. InitComboBind();
  43. InitDataGrid();
  44. }
  45. private void InitComboBind() {
  46. // 진료과
  47. DeptListVO[] deptList = this.hospitalWebService.GetDeptList(GetSelectGubunValue(), consentMain.ConsentExecuteInfo["dutinstcd"]);
  48. if(deptList != null) {
  49. this.comboDept.DisplayMember = "deptnm";
  50. this.comboDept.ValueMember = "deptcd";
  51. this.comboDept.DataSource = deptList;
  52. }
  53. }
  54. private void InitDataGrid() {
  55. this.dataGridViewPatientSelectResult.AutoGenerateColumns = false;
  56. this.dataGridViewPatientSelectResult.AllowUserToAddRows = false;
  57. //this.dataGridViewPatientSelectResult.CellPainting += new DataGridViewCellPaintingEventHandler(this.dataGridViewPatientSelectResult_CellPainting);
  58. //this.dataGridViewPatientSelectResult.ColumnHeaderMouseClick += new DataGridViewCellMouseEventHandler(this.dataGridViewPatientSelectResult_ColumnHeaderMouseClick);
  59. this.dataGridViewPatientSelectResult.RowPostPaint += new DataGridViewRowPostPaintEventHandler(this.dataGridViewPatientSelectResult_RowPostPaint);
  60. //CommonUtil.AddNewCheckBoxColumnToDataGridView(this.dataGridViewPatientSelectResult, "□", "colCheck", true, 30, DataGridViewContentAlignment.MiddleCenter);
  61. //CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "구분", "Gubun", true, 60);
  62. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "등록번호", "pid", true, 80);
  63. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "성명", "hngnm", true, 80);
  64. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "진료/입원일자", "indd", true, 120);
  65. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "진료과", "deptnm", true, 80);
  66. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "진료의", "doctornm", true, 80);
  67. //dataGridViewPatientSelectResult.Columns["colCheck"].Visible = false;
  68. }
  69. #region 환자 조회
  70. /// <summary>
  71. /// 선택된 조건으로 환자를 조회한다
  72. /// </summary>
  73. private void BindDataGridRows() {
  74. if(this.consentMain == null) consentMain = ConsentMainControl.GetConsentMainInterface(this);
  75. if(this.hospitalWebService == null) this.hospitalWebService = WebMethodCommon.GetHospitalWebService(consentMain.PluginExecuteInfo["hospitalSvcUrl"]);
  76. string srchdd = this.dateTimePickerClnDate.Value.ToShortDateString().Replace("-", "");
  77. string orddeptcd = (this.comboDept.Items.Count > 0) ? this.comboDept.SelectedValue.ToString().Trim() : "";
  78. string doctorid = (this.comboDoctor.Items.Count > 0) ? this.comboDoctor.SelectedValue.ToString().Trim() : "";
  79. string pid = this.textBoxSearchText.Text.Trim();
  80. string selectFlag = GetSelectGubunValue();
  81. Cursor currentCursor = this.Cursor;
  82. this.Cursor = Cursors.WaitCursor;
  83. DocListVO selectedDoctor = comboDoctor.SelectedItem as DocListVO;
  84. var drKindValue = "";
  85. if(selectedDoctor != null && selectedDoctor.drKind != null) {
  86. drKindValue = selectedDoctor.drKind.Trim();
  87. }
  88. PatListVO[] resultData = hospitalWebService.GetPatientList(srchdd
  89. , orddeptcd
  90. , doctorid
  91. , pid
  92. , selectFlag
  93. , this.consentMain.ConsentExecuteInfo["dutinstcd"]
  94. , ""
  95. , this.consentMain.ConsentExecuteInfo["loginUserNo"]
  96. , ""
  97. , string.Empty
  98. , drKindValue ?? ""
  99. , "SR" // 입원
  100. , "Y" // 검색탭 여부(Y: 검색탭, N: 그외)
  101. );
  102. this.Cursor = currentCursor;
  103. if(resultData == null) {
  104. return;
  105. }
  106. this.dataGridViewPatientSelectResult.DataSource = new SortableBindingList<PatListVO>(resultData);
  107. }
  108. private string GetSelectGubunValue() {
  109. string strGubun = "";
  110. RadioButton rdoTemp = null;
  111. if(this.radioGubunOut.Checked)
  112. rdoTemp = radioGubunOut;
  113. else if(this.radioGubunIn.Checked)
  114. rdoTemp = radioGubunIn;
  115. else if(this.radioGubunER.Checked)
  116. rdoTemp = radioGubunER;
  117. strGubun = rdoTemp.Tag.ToString();
  118. return strGubun;
  119. }
  120. private void comboDept_SelectedIndexChanged(object sender, EventArgs e) {
  121. // 주치의 목록 조회
  122. DocListVO[] doctorList = this.hospitalWebService.GetDoctorList(DateTime.Now.ToShortDateString().Replace("-", ""),
  123. (this.comboDept.Items.Count > 0) ? this.comboDept.SelectedValue.ToString() : ""
  124. , consentMain.ConsentExecuteInfo["dutinstcd"]);
  125. if(doctorList != null) {
  126. this.comboDoctor.DisplayMember = "doctornm";
  127. this.comboDoctor.ValueMember = "doctorid";
  128. this.comboDoctor.DataSource = doctorList;
  129. }
  130. }
  131. /// <summary>
  132. /// 조회 버튼 클릭 이벤트
  133. /// </summary>
  134. /// <param name="sender">The source of the event.</param>
  135. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  136. private void buttonPatientSelect_Click(object sender, EventArgs e) {
  137. var selectedDeptIndex = this.comboDept.SelectedIndex;
  138. var selectedDoctorIndex = this.comboDoctor.SelectedIndex;
  139. var patientNameValue = this.textBoxSearchText.Text;
  140. if(selectedDeptIndex == 0 && selectedDoctorIndex == 0 && String.Empty.Equals(patientNameValue)) {
  141. MessageBox.Show("조회할 등록번호를 입력해주세요.");
  142. return;
  143. }
  144. Cursor currentCursor = this.Cursor;
  145. try {
  146. this.Cursor = Cursors.WaitCursor;
  147. BindDataGridRows();
  148. }
  149. catch(Exception ex) {
  150. throw ex;
  151. }
  152. finally {
  153. this.Cursor = currentCursor;
  154. }
  155. }
  156. #endregion
  157. #region 환자찾기 버튼 클릭 이벤트
  158. /// <summary>
  159. /// 등록번호 검색 버튼 클릭 이벤트
  160. /// </summary>
  161. /// <param name="sender">The source of the event.</param>
  162. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  163. private void buttonSearchPop_Click(object sender, EventArgs e) {
  164. string strTemp = this.textBoxSearchText.Text.Trim();
  165. int iResult;
  166. if(int.TryParse(strTemp, out iResult) && strTemp.Length > 6) {
  167. this.buttonPatientSelect.PerformClick();
  168. }
  169. else {
  170. PatientSearchPopup popup = new PatientSearchPopup(textBoxSearchText.Text
  171. , consentMain.ConsentExecuteInfo["dutinstcd"]
  172. , consentMain.ConsentExecuteInfo["sysInstNm"]);
  173. DialogResult result = popup.ShowDialog();
  174. if(result == DialogResult.OK) {
  175. this.textBoxSearchText.Text = popup.PatientID;
  176. this.buttonPatientSelect.PerformClick();
  177. }
  178. popup.Close();
  179. }
  180. }
  181. /// <summary>
  182. /// 등록번호 입력 컨트롤 키보드 입력 이벤트
  183. /// </summary>
  184. /// <param name="sender">The source of the event.</param>
  185. /// <param name="e">The <see cref="KeyEventArgs"/> instance containing the event data.</param>
  186. private void textBoxSearchText_KeyDown(object sender, KeyEventArgs e) {
  187. if(e.KeyCode == Keys.Enter && this.textBoxSearchText.Text.Length > 0) {
  188. buttonPatientSelect.PerformClick();
  189. //this.buttonSearchPop.PerformClick();
  190. }
  191. }
  192. #endregion
  193. #region 그리드 이벤트
  194. //private void dataGridViewPatientSelectResult_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) {
  195. // if(e.ColumnIndex == 0 && e.RowIndex == -1) {
  196. // Image InfoIcon;
  197. // if(dataGridViewPatientSelectResult.Columns[0].HeaderText.Equals("□")) {
  198. // InfoIcon = Image.FromFile(@"../../Resources/uncheck.png");
  199. // }
  200. // else {
  201. // InfoIcon = Image.FromFile(@"../../Resources/check.png");
  202. // }
  203. // e.Paint(e.CellBounds, DataGridViewPaintParts.All);
  204. // e.Graphics.DrawImage(InfoIcon, e.CellBounds);
  205. // e.Handled = true;
  206. // }
  207. //}
  208. //private void dataGridViewPatientSelectResult_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) {
  209. // if(e.ColumnIndex == 0 && e.RowIndex == -1) {
  210. // bool chkStatus = false;
  211. // if(dataGridViewPatientSelectResult.Columns[0].HeaderText.Trim().Equals("□")) {
  212. // dataGridViewPatientSelectResult.Columns[0].HeaderText = "☑";
  213. // chkStatus = true;
  214. // }
  215. // else {
  216. // dataGridViewPatientSelectResult.Columns[0].HeaderText = "□";
  217. // }
  218. // foreach(DataGridViewRow r in dataGridViewPatientSelectResult.Rows) {
  219. // r.Cells["colCheck"].Value = chkStatus;
  220. // }
  221. // dataGridViewPatientSelectResult.RefreshEdit();
  222. // }
  223. //}
  224. private void dataGridViewPatientSelectResult_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e) {
  225. if(e.RowIndex >= 0) {
  226. string NumberingText = (e.RowIndex + 1).ToString();
  227. // 글자 사이즈 구하기.
  228. SizeF stringSize = e.Graphics.MeasureString(NumberingText, Font);
  229. // 글자에 맞춰 좌표계산.
  230. PointF StringPoint = new PointF
  231. (
  232. Convert.ToSingle(this.dataGridViewPatientSelectResult.RowHeadersWidth - 3 - stringSize.Width),
  233. Convert.ToSingle(e.RowBounds.Y) + this.dataGridViewPatientSelectResult[0, e.RowIndex].ContentBounds.Height * 0.3f
  234. );
  235. // 문자열 그리기.
  236. e.Graphics.DrawString
  237. (
  238. NumberingText,
  239. Font,
  240. Brushes.Black,
  241. StringPoint.X,
  242. StringPoint.Y
  243. );
  244. }
  245. }
  246. private void dataGridViewPatientSelectResult_CellDoubleClick(object sender, DataGridViewCellEventArgs e) {
  247. if(e.RowIndex > -1) {
  248. PatListVO vo = this.dataGridViewPatientSelectResult.Rows[e.RowIndex].DataBoundItem as PatListVO;
  249. consentMain.PatientListCtrl.SetChangePID(vo);
  250. }
  251. }
  252. #endregion
  253. //public void ClearCheckBox() {
  254. // bool chkStatus = false;
  255. // dataGridViewPatientSelectResult.Columns[0].HeaderText = "□";
  256. // foreach(DataGridViewRow r in dataGridViewPatientSelectResult.Rows) {
  257. // r.Cells["colCheck"].Value = chkStatus;
  258. // }
  259. // dataGridViewPatientSelectResult.RefreshEdit();
  260. //}
  261. public List<PatListVO> GetCheckPatList() {
  262. List<PatListVO> voList = new List<PatListVO>();
  263. foreach(DataGridViewRow r in dataGridViewPatientSelectResult.Rows) {
  264. if(Convert.ToBoolean(r.Cells["colCheck"].Value)) {
  265. voList.Add(r.DataBoundItem as PatListVO);
  266. }
  267. }
  268. return voList;
  269. }
  270. private void comboDept_DrawItem(object sender, DrawItemEventArgs e) {
  271. ComboBox box = sender as ComboBox;
  272. if(box is null)
  273. return;
  274. e.DrawBackground();
  275. if(e.Index >= 0) {
  276. Graphics g = e.Graphics;
  277. using(Brush brush = ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
  278. ? new SolidBrush(SystemColors.Highlight)
  279. : new SolidBrush(e.BackColor)) {
  280. using(Brush textBrush = new SolidBrush(e.ForeColor)) {
  281. g.FillRectangle(brush, e.Bounds);
  282. g.DrawString(((DeptListVO[])box.DataSource)[e.Index].deptNm,
  283. e.Font,
  284. textBrush,
  285. (float)e.Bounds.X,
  286. (float)(e.Bounds.Y) + 2.34F);
  287. }
  288. }
  289. }
  290. e.DrawFocusRectangle();
  291. }
  292. private void comboDept_MeasureItem(object sender, MeasureItemEventArgs e) {
  293. e.ItemHeight = 20;
  294. }
  295. private void comboDoctor_DrawItem(object sender, DrawItemEventArgs e) {
  296. ComboBox box = sender as ComboBox;
  297. if(box is null)
  298. return;
  299. e.DrawBackground();
  300. if(e.Index >= 0) {
  301. Graphics g = e.Graphics;
  302. using(Brush brush = ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
  303. ? new SolidBrush(SystemColors.Highlight)
  304. : new SolidBrush(e.BackColor)) {
  305. using(Brush textBrush = new SolidBrush(e.ForeColor)) {
  306. g.FillRectangle(brush, e.Bounds);
  307. g.DrawString(((DocListVO[])box.DataSource)[e.Index].doctorNm,
  308. e.Font,
  309. textBrush,
  310. (float)e.Bounds.X,
  311. (float)(e.Bounds.Y) + 2.34F);
  312. }
  313. }
  314. }
  315. e.DrawFocusRectangle();
  316. }
  317. private void comboDoctor_MeasureItem(object sender, MeasureItemEventArgs e) {
  318. e.ItemHeight = 20;
  319. }
  320. }
  321. }