PatientSelectTabInPatient.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476
  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 PatientSelectTabInPatient : UserControl {
  24. private IConsentMain consentMain = null;
  25. private ConsentCommandCtrl commandControl = null;
  26. private HospitalSvcRef.HospitalSvcSoapClient hospitalWebService = null;
  27. public PatientSelectTabInPatient() {
  28. InitializeComponent();
  29. }
  30. private void PatientSelectTabInPatient_Load(object sender, EventArgs e) {
  31. if(this.DesignMode || LicenseManager.UsageMode == LicenseUsageMode.Designtime) {
  32. return;
  33. }
  34. consentMain = ConsentMainControl.GetConsentMainInterface(this);
  35. if(commandControl == null) commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl;
  36. hospitalWebService = WebMethodCommon.GetHospitalWebService(consentMain.PluginExecuteInfo["hospitalSvcUrl"]);
  37. if (ConsentMainControl.SETTING_DATA["MY_PATIENT"].Equals("Y")) {
  38. chkMyPatient.Visible = true;
  39. }
  40. // 의사로 Agent 를 실행할 경우 입원 환자 탭에서 내환자 체크 박스 숨기기
  41. if(commandControl.CurrentEndUser != null) {
  42. if(!string.IsNullOrEmpty(commandControl.CurrentEndUser.JobKindCd)) {
  43. if(!commandControl.CurrentEndUser.JobKindCd.Substring(0, 2).Equals("11")) {
  44. chkMyPatient.Visible = false;
  45. }
  46. }
  47. }
  48. this.dateTimePickerClnDate.Value = DateTime.Now;
  49. InitComboBind();
  50. foreach(DeptListVO ward in (DeptListVO[])comboWard.DataSource) {
  51. if(ward.deptCd.Equals(commandControl.CurrentEndUser.DeptCode)) {
  52. comboWard.SelectedValue = commandControl.CurrentEndUser.DeptCode;
  53. break;
  54. }
  55. }
  56. InitDataGrid();
  57. }
  58. private void InitComboBind() {
  59. // 병동 정보 가져오기 및 설정
  60. DeptListVO[] wardList = this.hospitalWebService.GetWardList(this.consentMain.ConsentExecuteInfo["dutinstcd"]);
  61. if(wardList != null) {
  62. this.comboWard.DisplayMember = "deptnm";
  63. this.comboWard.ValueMember = "deptcd";
  64. this.comboWard.DataSource = wardList;
  65. }
  66. // 진료과 정보 가져오기 및 설정
  67. DeptListVO[] deptList = this.hospitalWebService.GetDeptList(GetSelectGubunValue(), this.consentMain.ConsentExecuteInfo["dutinstcd"]);
  68. if(deptList != null) {
  69. this.comboDept.DisplayMember = "deptnm";
  70. this.comboDept.ValueMember = "deptcd";
  71. this.comboDept.DataSource = deptList;
  72. }
  73. }
  74. private void InitDataGrid() {
  75. this.dataGridViewPatientSelectResult.AutoGenerateColumns = false;
  76. this.dataGridViewPatientSelectResult.AllowUserToAddRows = false;
  77. //this.dataGridViewPatientSelectResult.CellPainting += new DataGridViewCellPaintingEventHandler(this.dataGridViewPatientSelectResult_CellPainting);
  78. this.dataGridViewPatientSelectResult.ColumnHeaderMouseClick += new DataGridViewCellMouseEventHandler(this.dataGridViewPatientSelectResult_ColumnHeaderMouseClick);
  79. this.dataGridViewPatientSelectResult.RowPostPaint += new DataGridViewRowPostPaintEventHandler(this.dataGridViewPatientSelectResult_RowPostPaint);
  80. //CommonUtil.AddNewCheckBoxColumnToDataGridView(this.dataGridViewPatientSelectResult, "□", "colCheck", true, 30, DataGridViewContentAlignment.MiddleCenter);
  81. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "입원일자", "indd", true, 70);
  82. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "병실", "roomcd", true, 40);
  83. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "성명", "hngnm", true, 80);
  84. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "등록번호", "pid", true, 60);
  85. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "과", "deptnm", true, 120);
  86. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "주치의", "doctornm", true, 80);
  87. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "구분", "dschnoti", true, 80);
  88. //dataGridViewPatientSelectResult.Columns["colCheck"].Visible = false;
  89. }
  90. #region 환자 조회
  91. /// <summary>
  92. /// 선택된 구분 종류 반환
  93. /// </summary>
  94. /// <returns></returns>
  95. private string GetSelectGubunValue() {
  96. string strGubun = "";
  97. if(this.radioGubunAll.Checked) {
  98. strGubun = "A";
  99. }
  100. else {
  101. RadioButton rdoTemp = null;
  102. if(this.radioGubunFuture.Checked)
  103. rdoTemp = radioGubunFuture;
  104. else if(this.radioGubunIng.Checked)
  105. rdoTemp = radioGubunIng;
  106. else if(this.radioGubunOut.Checked)
  107. rdoTemp = radioGubunOut;
  108. strGubun = rdoTemp.Tag.ToString();
  109. }
  110. return strGubun;
  111. }
  112. private void BindDataGridRows() {
  113. if(this.consentMain == null) consentMain = ConsentMainControl.GetConsentMainInterface(this);
  114. if(this.hospitalWebService == null) this.hospitalWebService = WebMethodCommon.GetHospitalWebService(consentMain.PluginExecuteInfo["hospitalSvcUrl"]);
  115. string srchdd = this.dateTimePickerClnDate.Value.ToShortDateString().Replace("-", "");
  116. string orddeptcd = (this.comboDept.Items.Count > 0) ? this.comboDept.SelectedValue.ToString().Trim() : "";
  117. string doctorid = (this.comboDoctor.Items.Count > 0) ? this.comboDoctor.SelectedValue.ToString().Trim() : "";
  118. string pid = this.textBoxSearchText.Text.Trim();
  119. string wardcd = (this.comboWard.Items.Count > 0) ? this.comboWard.SelectedValue.ToString().Trim() : "";
  120. string patstat = GetSelectGubunValue();
  121. DocListVO selectedDoctor = comboDoctor.SelectedItem as DocListVO;
  122. Cursor currentCursor = this.Cursor;
  123. this.Cursor = Cursors.WaitCursor;
  124. // 입원 환자 목록 조회
  125. PatListVO[] resultData = hospitalWebService.GetPatientList(srchdd
  126. , orddeptcd
  127. , doctorid
  128. , pid
  129. , patstat
  130. , this.consentMain.ConsentExecuteInfo["dutinstcd"]
  131. , wardcd
  132. , this.consentMain.ConsentExecuteInfo["loginUserNo"]
  133. , chkMyPatient.Checked ? "Y" : string.Empty
  134. , string.Empty
  135. , selectedDoctor.drKind ?? ""
  136. , "I" // 입원
  137. , "N" // 검색탭 여부(Y: 검색탭, N: 그외)
  138. );
  139. this.Cursor = currentCursor;
  140. if(resultData == null) {
  141. return;
  142. }
  143. this.dataGridViewPatientSelectResult.DataSource = new SortableBindingList<PatListVO>(resultData);
  144. }
  145. /// <summary>
  146. /// 진료과 콤보 박스 아이템 변경 이벤트
  147. /// </summary>
  148. /// <param name="sender">The source of the event.</param>
  149. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  150. private void comboDept_SelectedIndexChanged(object sender, EventArgs e) {
  151. // 주치의 목록 가져오기
  152. DocListVO[] doctorList = this.hospitalWebService.GetDoctorList(DateTime.Now.ToShortDateString().Replace("-", ""),
  153. (this.comboDept.Items.Count > 0) ? this.comboDept.SelectedValue.ToString() : "", this.consentMain.ConsentExecuteInfo["dutinstcd"]);
  154. if(doctorList != null) {
  155. this.comboDoctor.DisplayMember = "doctornm";
  156. this.comboDoctor.ValueMember = "doctorid";
  157. this.comboDoctor.DataSource = doctorList;
  158. }
  159. }
  160. /// <summary>
  161. /// 조회 버튼 클릭 이벤트
  162. /// </summary>
  163. /// <param name="sender">The source of the event.</param>
  164. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  165. private void buttonPatientSelect_Click(object sender, EventArgs e) {
  166. var selectedWardIndex = this.comboWard.SelectedIndex;
  167. var selectedDeptIndex = this.comboDept.SelectedIndex;
  168. var selectedDoctorIndex = this.comboDoctor.SelectedIndex;
  169. var patientNameValue = this.textBoxSearchText.Text;
  170. if(selectedWardIndex == 0 && selectedDeptIndex == 0 && selectedDoctorIndex == 0 && String.Empty.Equals(patientNameValue)) {
  171. MessageBox.Show("병동, 진료과, 등록번호 중 1가지 이상 입력해주세요.");
  172. return;
  173. }
  174. buttonPatientSelect.Enabled = false;
  175. Application.DoEvents();
  176. try {
  177. BindDataGridRows();
  178. }
  179. catch(Exception ex) {
  180. throw ex;
  181. }
  182. finally {
  183. buttonPatientSelect.Enabled = true;
  184. }
  185. }
  186. #endregion
  187. #region 환자찾기 버튼 클릭 이벤트
  188. /// <summary>
  189. /// 환자 찾기 버튼 클릭 이벤트, 환자 조회 팝업창 생성
  190. /// </summary>
  191. /// <param name="sender">The source of the event.</param>
  192. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  193. private void buttonSearchPop_Click(object sender, EventArgs e) {
  194. string strTemp = this.textBoxSearchText.Text.Trim();
  195. int iResult;
  196. if(int.TryParse(strTemp, out iResult) && strTemp.Length > 6) {
  197. this.buttonPatientSelect.PerformClick();
  198. }
  199. else {
  200. PatientSearchPopup popup = new PatientSearchPopup(textBoxSearchText.Text
  201. , consentMain.ConsentExecuteInfo["dutinstcd"]
  202. , consentMain.ConsentExecuteInfo["sysInstNm"]);
  203. DialogResult result = popup.ShowDialog();
  204. if(result == DialogResult.OK) {
  205. this.textBoxSearchText.Text = popup.PatientID;
  206. this.buttonPatientSelect.PerformClick();
  207. }
  208. popup.Close();
  209. }
  210. }
  211. /// <summary>
  212. /// 등록번호 입력 컨트롤 키보드 입력 이벤트
  213. /// </summary>
  214. /// <param name="sender">The source of the event.</param>
  215. /// <param name="e">The <see cref="KeyEventArgs"/> instance containing the event data.</param>
  216. private void textBoxSearchText_KeyDown(object sender, KeyEventArgs e) {
  217. if(e.KeyCode == Keys.Enter) {
  218. this.buttonSearchPop.PerformClick();
  219. }
  220. }
  221. #endregion
  222. #region 그리드 이벤트
  223. /// <summary>
  224. /// 그리드 그리기 이벤트
  225. /// </summary>
  226. /// <param name="sender">The source of the event.</param>
  227. /// <param name="e">The <see cref="DataGridViewCellPaintingEventArgs"/> instance containing the event data.</param>
  228. private void dataGridViewPatientSelectResult_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) {
  229. //if(e.ColumnIndex == 0 && e.RowIndex == -1) {
  230. // Image InfoIcon;
  231. // // 체크박스 상태에 따른 아이콘 표시
  232. // if(dataGridViewPatientSelectResult.Columns[0].HeaderText.Equals("□")) {
  233. // InfoIcon = Image.FromFile(@"../../Resources/uncheck.png");
  234. // }
  235. // else {
  236. // InfoIcon = Image.FromFile(@"../../Resources/check.png");
  237. // }
  238. // e.Paint(e.CellBounds, DataGridViewPaintParts.All);
  239. // e.Graphics.DrawImage(InfoIcon, e.CellBounds);
  240. // e.Handled = true;
  241. //}
  242. }
  243. /// <summary>
  244. /// 컬럼 헤드 클릭 이벤트
  245. /// 선택 여부 체크박스 값 설정
  246. /// </summary>
  247. /// <param name="sender">The source of the event.</param>
  248. /// <param name="e">The <see cref="DataGridViewCellMouseEventArgs"/> instance containing the event data.</param>
  249. private void dataGridViewPatientSelectResult_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) {
  250. //if(e.ColumnIndex == 0 && e.RowIndex == -1) {
  251. // bool chkStatus = false;
  252. // if(dataGridViewPatientSelectResult.Columns[0].HeaderText.Equals("□")) {
  253. // dataGridViewPatientSelectResult.Columns[0].HeaderText = "☑";
  254. // chkStatus = true;
  255. // }
  256. // else {
  257. // dataGridViewPatientSelectResult.Columns[0].HeaderText = "□";
  258. // }
  259. // foreach(DataGridViewRow r in dataGridViewPatientSelectResult.Rows) {
  260. // r.Cells["colCheck"].Value = chkStatus;
  261. // }
  262. // dataGridViewPatientSelectResult.RefreshEdit();
  263. //}
  264. }
  265. /// <summary>
  266. /// 그리드 그리기 이후 이벤트, 행 번호 추가
  267. /// </summary>
  268. /// <param name="sender">The source of the event.</param>
  269. /// <param name="e">The <see cref="DataGridViewRowPostPaintEventArgs"/> instance containing the event data.</param>
  270. private void dataGridViewPatientSelectResult_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e) {
  271. if(e.RowIndex >= 0) {
  272. string NumberingText = (e.RowIndex + 1).ToString();
  273. // 글자 사이즈 구하기.
  274. SizeF stringSize = e.Graphics.MeasureString(NumberingText, Font);
  275. // 글자에 맞춰 좌표계산.
  276. PointF StringPoint = new PointF
  277. (
  278. Convert.ToSingle(this.dataGridViewPatientSelectResult.RowHeadersWidth - 3 - stringSize.Width),
  279. Convert.ToSingle(e.RowBounds.Y) + this.dataGridViewPatientSelectResult[0, e.RowIndex].ContentBounds.Height * 0.3f
  280. );
  281. // 문자열 그리기.
  282. e.Graphics.DrawString
  283. (
  284. NumberingText,
  285. Font,
  286. Brushes.Black,
  287. StringPoint.X,
  288. StringPoint.Y
  289. );
  290. }
  291. }
  292. /// <summary>
  293. /// 입원 환자 목록 그리드 셀 더블클릭 이벤트
  294. /// </summary>
  295. /// <param name="sender">The source of the event.</param>
  296. /// <param name="e">The <see cref="DataGridViewCellEventArgs"/> instance containing the event data.</param>
  297. private void dataGridViewPatientSelectResult_CellDoubleClick(object sender, DataGridViewCellEventArgs e) {
  298. if(e.RowIndex > -1) {
  299. PatListVO vo = this.dataGridViewPatientSelectResult.Rows[e.RowIndex].DataBoundItem as PatListVO;
  300. // 현재 선택 환자를 변경한다
  301. consentMain.PatientListCtrl.SetChangePID(vo);
  302. }
  303. }
  304. #endregion
  305. public void ClearCheckBox() {
  306. //bool chkStatus = false;
  307. //dataGridViewPatientSelectResult.Columns[0].HeaderText = "□";
  308. //foreach(DataGridViewRow r in dataGridViewPatientSelectResult.Rows) {
  309. // r.Cells["colCheck"].Value = chkStatus;
  310. //}
  311. //dataGridViewPatientSelectResult.RefreshEdit();
  312. }
  313. public List<PatListVO> GetCheckPatList() {
  314. List<PatListVO> voList = new List<PatListVO>();
  315. foreach(DataGridViewRow r in dataGridViewPatientSelectResult.Rows) {
  316. if(Convert.ToBoolean(r.Cells["colCheck"].Value)) {
  317. voList.Add(r.DataBoundItem as PatListVO);
  318. }
  319. }
  320. return voList;
  321. }
  322. private void comboWard_DrawItem(object sender, DrawItemEventArgs e) {
  323. ComboBox box = sender as ComboBox;
  324. if(box is null)
  325. return;
  326. e.DrawBackground();
  327. if(e.Index >= 0) {
  328. Graphics g = e.Graphics;
  329. using(Brush brush = ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
  330. ? new SolidBrush(SystemColors.Highlight)
  331. : new SolidBrush(e.BackColor)) {
  332. using(Brush textBrush = new SolidBrush(e.ForeColor)) {
  333. g.FillRectangle(brush, e.Bounds);
  334. g.DrawString(((DeptListVO[])box.DataSource)[e.Index].deptNm,
  335. e.Font,
  336. textBrush,
  337. (float)e.Bounds.X,
  338. (float)(e.Bounds.Y) + 2.34F);
  339. }
  340. }
  341. }
  342. e.DrawFocusRectangle();
  343. }
  344. private void comboWard_MeasureItem(object sender, MeasureItemEventArgs e) {
  345. e.ItemHeight = 20;
  346. }
  347. private void comboDept_DrawItem(object sender, DrawItemEventArgs e) {
  348. ComboBox box = sender as ComboBox;
  349. if(box is null)
  350. return;
  351. e.DrawBackground();
  352. if(e.Index >= 0) {
  353. Graphics g = e.Graphics;
  354. using(Brush brush = ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
  355. ? new SolidBrush(SystemColors.Highlight)
  356. : new SolidBrush(e.BackColor)) {
  357. using(Brush textBrush = new SolidBrush(e.ForeColor)) {
  358. g.FillRectangle(brush, e.Bounds);
  359. g.DrawString(((DeptListVO[])box.DataSource)[e.Index].deptNm,
  360. e.Font,
  361. textBrush,
  362. (float)e.Bounds.X,
  363. (float)(e.Bounds.Y) + 2.34F);
  364. }
  365. }
  366. }
  367. e.DrawFocusRectangle();
  368. }
  369. private void comboDept_MeasureItem(object sender, MeasureItemEventArgs e) {
  370. e.ItemHeight = 20;
  371. }
  372. private void comboDoctor_DrawItem(object sender, DrawItemEventArgs e) {
  373. ComboBox box = sender as ComboBox;
  374. if(box is null)
  375. return;
  376. e.DrawBackground();
  377. if(e.Index >= 0) {
  378. Graphics g = e.Graphics;
  379. using(Brush brush = ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
  380. ? new SolidBrush(SystemColors.Highlight)
  381. : new SolidBrush(e.BackColor)) {
  382. using(Brush textBrush = new SolidBrush(e.ForeColor)) {
  383. g.FillRectangle(brush, e.Bounds);
  384. g.DrawString(((DocListVO[])box.DataSource)[e.Index].doctorNm,
  385. e.Font,
  386. textBrush,
  387. (float)e.Bounds.X,
  388. (float)(e.Bounds.Y) + 2.34F);
  389. }
  390. }
  391. }
  392. e.DrawFocusRectangle();
  393. }
  394. private void comboDoctor_MeasureItem(object sender, MeasureItemEventArgs e) {
  395. e.ItemHeight = 20;
  396. }
  397. }
  398. }