PatientSelectTabEmergencyPatient.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  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 PatientSelectTabEmergencyPatient : UserControl {
  24. private IConsentMain consentMain = null;
  25. private HospitalSvcRef.HospitalSvcSoapClient hospitalWebService = null;
  26. public PatientSelectTabEmergencyPatient() {
  27. InitializeComponent();
  28. }
  29. private void PatientSelectTabEmergencyPatient_Load(object sender, EventArgs e) {
  30. if(this.DesignMode || LicenseManager.UsageMode == LicenseUsageMode.Designtime) {
  31. return;
  32. }
  33. consentMain = ConsentMainControl.GetConsentMainInterface(this);
  34. hospitalWebService = WebMethodCommon.GetHospitalWebService(consentMain.PluginExecuteInfo["hospitalSvcUrl"]);
  35. this.dateTimePickerClnDate.Value = DateTime.Now;
  36. InitComboBind();
  37. InitDataGrid();
  38. }
  39. private void InitComboBind() {
  40. // 진료과
  41. DeptListVO[] deptList = this.hospitalWebService.GetDeptList(GetSelectGubunValue(), this.consentMain.ConsentExecuteInfo["dutinstcd"]);
  42. if(deptList != null) {
  43. this.comboDept.DisplayMember = "deptnm";
  44. this.comboDept.ValueMember = "deptcd";
  45. this.comboDept.DataSource = deptList;
  46. }
  47. }
  48. private void InitDataGrid() {
  49. this.dataGridViewPatientSelectResult.AutoGenerateColumns = false;
  50. this.dataGridViewPatientSelectResult.AllowUserToAddRows = false;
  51. //this.dataGridViewPatientSelectResult.CellPainting += new DataGridViewCellPaintingEventHandler(this.dataGridViewPatientSelectResult_CellPainting);
  52. //this.dataGridViewPatientSelectResult.ColumnHeaderMouseClick += new DataGridViewCellMouseEventHandler(this.dataGridViewPatientSelectResult_ColumnHeaderMouseClick);
  53. this.dataGridViewPatientSelectResult.RowPostPaint += new DataGridViewRowPostPaintEventHandler(this.dataGridViewPatientSelectResult_RowPostPaint);
  54. //CommonUtil.AddNewCheckBoxColumnToDataGridView(this.dataGridViewPatientSelectResult, "□", "colCheck", true, 30, DataGridViewContentAlignment.MiddleCenter);
  55. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "등록번호", "pid", true, 80);
  56. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "성명", "hngnm", true, 80);
  57. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "입원일자", "indd", true, 80);
  58. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "진료과", "deptnm", true, 100);
  59. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "진료의", "doctornm", true, 80);
  60. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "ER접수과", "erorddeptnm", true, 100);
  61. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "ER진료의", "ermedispclnm", true, 80);
  62. //dataGridViewPatientSelectResult.Columns["colCheck"].Visible = false;
  63. }
  64. #region 환자 조회
  65. private void BindDataGridRows() {
  66. if(this.consentMain == null) consentMain = ConsentMainControl.GetConsentMainInterface(this);
  67. if(this.hospitalWebService == null) this.hospitalWebService = WebMethodCommon.GetHospitalWebService(consentMain.PluginExecuteInfo["hospitalSvcUrl"]);
  68. string srchdd = this.dateTimePickerClnDate.Value.ToShortDateString().Replace("-", "");
  69. string orddeptcd = (this.comboDept.Items.Count > 0) ? this.comboDept.SelectedValue.ToString().Trim() : "";
  70. string doctorid = (this.comboDoctor.Items.Count > 0) ? this.comboDoctor.SelectedValue.ToString().Trim() : "";
  71. string pid = this.textBoxSearchText.Text.Trim();
  72. string patstat = GetSelectGubunValue().Replace("-", "");
  73. Cursor currentCursor = this.Cursor;
  74. this.Cursor = Cursors.WaitCursor;
  75. DocListVO selectedDoctor = comboDoctor.SelectedItem as DocListVO;
  76. var drKindValue = "";
  77. if(selectedDoctor != null && selectedDoctor.drKind != null) {
  78. drKindValue = selectedDoctor.drKind.Trim();
  79. }
  80. PatListVO[] resultData = hospitalWebService.GetPatientList(srchdd
  81. , orddeptcd
  82. , doctorid
  83. , pid
  84. , patstat
  85. , this.consentMain.ConsentExecuteInfo["dutinstcd"]
  86. , ""
  87. , this.consentMain.ConsentExecuteInfo["loginUserNo"]
  88. , ""
  89. , string.Empty
  90. , drKindValue ?? ""
  91. , "E" // 응급
  92. , "N" // 검색탭 여부(Y: 검색탭, N: 그외)
  93. );
  94. this.Cursor = currentCursor;
  95. if(resultData == null) {
  96. return;
  97. }
  98. this.dataGridViewPatientSelectResult.DataSource = new SortableBindingList<PatListVO>(resultData);
  99. }
  100. private string GetSelectGubunValue() {
  101. string strGubun = "";
  102. if(this.radioGubunAll.Checked) {
  103. strGubun = "A";
  104. }
  105. else {
  106. RadioButton rdoTemp = null;
  107. if(this.radioGubunOutIng.Checked)
  108. rdoTemp = radioGubunOutIng;
  109. else if(this.radioGubunIng.Checked)
  110. rdoTemp = radioGubunIng;
  111. else if(this.radioGubunOut.Checked)
  112. rdoTemp = radioGubunOut;
  113. strGubun = rdoTemp.Tag.ToString();
  114. }
  115. return strGubun;
  116. }
  117. /// <summary>
  118. /// 진료과 콤보 컨트롤 아이템 변경 이벤트
  119. /// </summary>
  120. /// <param name="sender">The source of the event.</param>
  121. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  122. private void comboDept_SelectedIndexChanged(object sender, EventArgs e) {
  123. // 주치의 목록 조회
  124. DocListVO[] doctorList = this.hospitalWebService.GetDoctorList(DateTime.Now.ToShortDateString().Replace("-", ""),
  125. (this.comboDept.Items.Count > 0) ? this.comboDept.SelectedValue.ToString() : "", this.consentMain.ConsentExecuteInfo["dutinstcd"]);
  126. if(doctorList != null) {
  127. this.comboDoctor.DisplayMember = "doctornm";
  128. this.comboDoctor.ValueMember = "doctorid";
  129. this.comboDoctor.DataSource = doctorList;
  130. }
  131. }
  132. /// <summary>
  133. /// 조회 버튼 클릭 이벤트
  134. /// </summary>
  135. /// <param name="sender">The source of the event.</param>
  136. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  137. private void buttonPatientSelect_Click(object sender, EventArgs e) {
  138. var selectedDeptIndex = this.comboDept.SelectedIndex;
  139. var selectedDoctorIndex = this.comboDoctor.SelectedIndex;
  140. var patientNameValue = this.textBoxSearchText.Text;
  141. //if(selectedDeptIndex == 0 && selectedDoctorIndex == 0 && String.Empty.Equals(patientNameValue)) {
  142. // MessageBox.Show("진료과, 등록번호 중 1가지 이상 입력해주세요.");
  143. // return;
  144. //}
  145. Cursor currentCursor = this.Cursor;
  146. try {
  147. this.Cursor = Cursors.WaitCursor;
  148. BindDataGridRows();
  149. }
  150. catch(Exception ex) {
  151. throw ex;
  152. }
  153. finally {
  154. this.Cursor = currentCursor;
  155. }
  156. }
  157. #endregion
  158. #region 환자찾기 버튼 클릭 이벤트
  159. /// <summary>
  160. /// 환자 번호 입력 컨트롤 키보드 입력 이벤트
  161. /// </summary>
  162. /// <param name="sender">The source of the event.</param>
  163. /// <param name="e">The <see cref="KeyEventArgs"/> instance containing the event data.</param>
  164. private void textBoxSearchText_KeyDown(object sender, KeyEventArgs e) {
  165. if(e.KeyCode == Keys.Enter) {
  166. this.buttonSearchPop.PerformClick();
  167. }
  168. }
  169. /// <summary>
  170. /// 환자 검색 팝업버튼 클릭 이벤트
  171. /// </summary>
  172. /// <param name="sender">The source of the event.</param>
  173. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  174. private void buttonSearchPop_Click(object sender, EventArgs e) {
  175. string strTemp = this.textBoxSearchText.Text.Trim();
  176. int iResult;
  177. if(int.TryParse(strTemp, out iResult) && strTemp.Length > 6) {
  178. this.buttonPatientSelect.PerformClick();
  179. }
  180. else {
  181. PatientSearchPopup popup = new PatientSearchPopup(textBoxSearchText.Text
  182. , consentMain.ConsentExecuteInfo["dutinstcd"]
  183. , consentMain.ConsentExecuteInfo["sysInstNm"]);
  184. DialogResult result = popup.ShowDialog();
  185. if(result == DialogResult.OK) {
  186. this.textBoxSearchText.Text = popup.PatientID;
  187. this.buttonPatientSelect.PerformClick();
  188. }
  189. popup.Close();
  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.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. }