PatientSelectTabOutPatient.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  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 PatientSelectTabOutPatient : UserControl {
  24. private IConsentMain consentMain = null;
  25. private ConsentCommandCtrl commandControl = null;
  26. private HospitalSvcRef.HospitalSvcSoapClient hospitalWebService = null;
  27. public PatientSelectTabOutPatient() {
  28. InitializeComponent();
  29. }
  30. private void PatientSelectTabOutPatient_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. // 진료일자를 오늘 날자로 설정
  38. this.dateTimePickerClnDate.Value = DateTime.Now;
  39. InitComboBind();
  40. // 현재 사용자의 진료과로 설정한다
  41. setSearchDeptCode(commandControl.CurrentEndUser.DeptCode);
  42. InitDataGrid();
  43. }
  44. /// <summary>
  45. /// clnDeptCode 로 진료과를 설정한다
  46. /// </summary>
  47. /// <param name="clnDeptCode">설정할 진료과 코드</param>
  48. public void setSearchDeptCode(string clnDeptCode) {
  49. if(!string.IsNullOrEmpty(clnDeptCode) && this.comboDept != null) {
  50. foreach(DeptListVO dept in (DeptListVO[])comboDept.DataSource) {
  51. if(dept.deptCd.Equals(clnDeptCode)) {
  52. comboDept.SelectedValue = clnDeptCode;
  53. break;
  54. }
  55. }
  56. }
  57. }
  58. private void InitComboBind() {
  59. // 진료과
  60. DeptListVO[] deptList = this.hospitalWebService.GetDeptList(GetSelectGubunValue(), this.consentMain.ConsentExecuteInfo["dutinstcd"]);
  61. if(deptList != null) {
  62. this.comboDept.DisplayMember = "deptnm";
  63. this.comboDept.ValueMember = "deptcd";
  64. this.comboDept.DataSource = deptList;
  65. }
  66. }
  67. private void InitDataGrid() {
  68. this.dataGridViewPatientSelectResult.AutoGenerateColumns = false;
  69. this.dataGridViewPatientSelectResult.AllowUserToAddRows = false;
  70. //this.dataGridViewPatientSelectResult.CellPainting += new DataGridViewCellPaintingEventHandler(this.dataGridViewPatientSelectResult_CellPainting);
  71. this.dataGridViewPatientSelectResult.ColumnHeaderMouseClick += new DataGridViewCellMouseEventHandler(this.dataGridViewPatientSelectResult_ColumnHeaderMouseClick);
  72. this.dataGridViewPatientSelectResult.RowPostPaint += new DataGridViewRowPostPaintEventHandler(this.dataGridViewPatientSelectResult_RowPostPaint);
  73. //CommonUtil.AddNewCheckBoxColumnToDataGridView(this.dataGridViewPatientSelectResult, "□", "colCheck", true, 30, DataGridViewContentAlignment.MiddleCenter);
  74. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "등록번호", "pid", true, 60);
  75. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "성명", "hngnm", true, 80);
  76. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "구분", "elbulbodstat", true, 40);
  77. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "초진", "fsexamflag", true, 60);
  78. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "진료일자", "indd", true, 80);
  79. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "시간", "ordtm", true, 60);
  80. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "과", "deptengabbr", true, 40);
  81. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "진료의", "doctornm", true, 80);
  82. //dataGridViewPatientSelectResult.Columns["colCheck"].Visible = false;
  83. }
  84. #region 환자 조회
  85. /// <summary>
  86. /// 환자 조회
  87. /// </summary>
  88. public void BindDataGridRows() {
  89. if(this.consentMain == null) consentMain = ConsentMainControl.GetConsentMainInterface(this);
  90. if(this.hospitalWebService == null) this.hospitalWebService = WebMethodCommon.GetHospitalWebService(consentMain.PluginExecuteInfo["hospitalSvcUrl"]);
  91. string srchdd = this.dateTimePickerClnDate.Value.ToShortDateString().Replace("-", "");
  92. string orddeptcd = (this.comboDept.Items.Count > 0) ? this.comboDept.SelectedValue.ToString().Trim() : "";
  93. string doctorid = (this.comboDoctor.Items.Count > 0) ? this.comboDoctor.SelectedValue.ToString().Trim() : "";
  94. string pid = this.textBoxSearchText.Text.Trim();
  95. string patstat = GetSelectGubunValue();
  96. Cursor currentCursor = this.Cursor;
  97. this.Cursor = Cursors.WaitCursor;
  98. DocListVO selectedDoctor = comboDoctor.SelectedItem as DocListVO;
  99. var drKindValue = "";
  100. if(selectedDoctor != null && selectedDoctor.drKind != null) {
  101. drKindValue = selectedDoctor.drKind.Trim();
  102. }
  103. PatListVO[] resultData = hospitalWebService.GetPatientList(srchdd
  104. , orddeptcd
  105. , doctorid
  106. , pid
  107. , patstat
  108. , this.consentMain.ConsentExecuteInfo["dutinstcd"]
  109. , ""
  110. , this.consentMain.ConsentExecuteInfo["loginUserNo"]
  111. , ""
  112. , string.Empty
  113. , drKindValue ?? ""
  114. , "O" // 외래
  115. , "N" // 검색탭 여부(Y: 검색탭, N: 그외)
  116. );
  117. this.Cursor = currentCursor;
  118. if(resultData == null) {
  119. return;
  120. }
  121. this.dataGridViewPatientSelectResult.DataSource = new SortableBindingList<PatListVO>(resultData);
  122. }
  123. /// <summary>
  124. /// 검색할 조건을 반환한다
  125. /// </summary>
  126. /// <returns>조회 질의어</returns>
  127. private string GetSelectGubunValue() {
  128. string strGubun = "";
  129. if(this.radioGubunAll.Checked) {
  130. strGubun = "A";
  131. }
  132. else {
  133. RadioButton rdoTemp = null;
  134. if (this.radioGubunStep1.Checked)
  135. rdoTemp = radioGubunStep1;
  136. else if (this.radioGubunStep2.Checked)
  137. rdoTemp = radioGubunStep2;
  138. else if (this.radioGubunStep3.Checked)
  139. rdoTemp = radioGubunStep3;
  140. else if (this.radioGubunStep3.Checked)
  141. rdoTemp = radioGubunStep4;
  142. strGubun = rdoTemp.Tag.ToString();
  143. }
  144. return strGubun;
  145. }
  146. /// <summary>
  147. /// 부서명 콤보 박스 아이템 변경 이벤트
  148. /// </summary>
  149. /// <param name="sender">The source of the event.</param>
  150. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  151. private void comboDept_SelectedIndexChanged(object sender, EventArgs e) {
  152. // 주치의 목록을 가져온다
  153. DocListVO[] doctorList = this.hospitalWebService.GetDoctorList(DateTime.Now.ToShortDateString().Replace("-", ""),
  154. (this.comboDept.Items.Count > 0 && this.comboDept.SelectedValue != null) ? this.comboDept.SelectedValue.ToString() : ""
  155. , this.consentMain.ConsentExecuteInfo["dutinstcd"]);
  156. if(doctorList != null) {
  157. this.comboDoctor.DisplayMember = "doctornm";
  158. this.comboDoctor.ValueMember = "doctorid";
  159. this.comboDoctor.DataSource = doctorList;
  160. }
  161. }
  162. /// <summary>
  163. /// 환자 조회 버튼 클릭 이벤트
  164. /// </summary>
  165. /// <param name="sender">The source of the event.</param>
  166. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  167. private void buttonPatientSelect_Click(object sender, EventArgs e) {
  168. var selectedDeptIndex = this.comboDept.SelectedIndex;
  169. var selectedDoctorIndex = this.comboDoctor.SelectedIndex;
  170. var patientNameValue = this.textBoxSearchText.Text;
  171. if(selectedDeptIndex == 0 && selectedDoctorIndex == 0 && String.Empty.Equals(patientNameValue)) {
  172. MessageBox.Show("진료과, 등록번호 중 1가지 이상 입력해주세요.");
  173. return;
  174. }
  175. Cursor currentCursor = this.Cursor;
  176. try {
  177. this.Cursor = Cursors.WaitCursor;
  178. BindDataGridRows();
  179. }
  180. catch(Exception ex) {
  181. throw ex;
  182. }
  183. finally {
  184. this.Cursor = currentCursor;
  185. }
  186. }
  187. #endregion
  188. #region 환자찾기 버튼 클릭 이벤트
  189. /// <summary>
  190. /// 환자찾기 버튼 클릭 이벤트
  191. /// </summary>
  192. /// <param name="sender">The source of the event.</param>
  193. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  194. private void buttonSearchPop_Click(object sender, EventArgs e) {
  195. string strTemp = this.textBoxSearchText.Text.Trim();
  196. int iResult;
  197. if(int.TryParse(strTemp, out iResult) && strTemp.Length > 6) {
  198. this.buttonPatientSelect.PerformClick();
  199. }
  200. else {
  201. // 환자찾기 팝업 생성
  202. PatientSearchPopup popup = new PatientSearchPopup(textBoxSearchText.Text
  203. , consentMain.ConsentExecuteInfo["dutinstcd"]
  204. , consentMain.ConsentExecuteInfo["sysInstNm"]);
  205. DialogResult result = popup.ShowDialog();
  206. if(result == DialogResult.OK) {
  207. this.textBoxSearchText.Text = popup.PatientID;
  208. this.buttonPatientSelect.PerformClick();
  209. }
  210. popup.Close();
  211. }
  212. }
  213. /// <summary>
  214. /// 등록번호 텍스트 입력 이벤트
  215. /// </summary>
  216. /// <param name="sender">The source of the event.</param>
  217. /// <param name="e">The <see cref="KeyEventArgs"/> instance containing the event data.</param>
  218. private void textBoxSearchText_KeyDown(object sender, KeyEventArgs e) {
  219. if(e.KeyCode == Keys.Enter) {
  220. this.buttonSearchPop.PerformClick();
  221. }
  222. }
  223. #endregion
  224. #region 그리드 이벤트
  225. /// <summary>
  226. /// 그리기 이벤트 시 체크박스 상태값에 따라 다른 이미지를 설정한다
  227. /// </summary>
  228. /// <param name="sender">The source of the event.</param>
  229. /// <param name="e">The <see cref="DataGridViewCellPaintingEventArgs"/> instance containing the event data.</param>
  230. private void dataGridViewPatientSelectResult_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) {
  231. /// 그리드 이벤트
  232. //if(e.ColumnIndex == 0 && e.RowIndex == -1) {
  233. // Image InfoIcon;
  234. // if(dataGridViewPatientSelectResult.Columns[0].HeaderText.Equals("□")) {
  235. // InfoIcon = Image.FromFile(@"../../Resources/uncheck.png");
  236. // }
  237. // else {
  238. // InfoIcon = Image.FromFile(@"../../Resources/check.png");
  239. // }
  240. // e.Paint(e.CellBounds, DataGridViewPaintParts.All);
  241. // e.Graphics.DrawImage(InfoIcon, e.CellBounds);
  242. // e.Handled = true;
  243. //}
  244. }
  245. /// <summary>
  246. /// 컬럼 헤드 클릭 이벤트
  247. /// </summary>
  248. /// <param name="sender">The source of the event.</param>
  249. /// <param name="e">The <see cref="DataGridViewCellMouseEventArgs"/> instance containing the event data.</param>
  250. private void dataGridViewPatientSelectResult_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) {
  251. //if(e.ColumnIndex == 0 && e.RowIndex == -1) {
  252. // bool chkStatus = false;
  253. // if(dataGridViewPatientSelectResult.Columns[0].HeaderText.Equals("□")) {
  254. // dataGridViewPatientSelectResult.Columns[0].HeaderText = "☑";
  255. // chkStatus = true;
  256. // }
  257. // else {
  258. // dataGridViewPatientSelectResult.Columns[0].HeaderText = "□";
  259. // }
  260. // foreach(DataGridViewRow r in dataGridViewPatientSelectResult.Rows) {
  261. // r.Cells["colCheck"].Value = chkStatus;
  262. // }
  263. // dataGridViewPatientSelectResult.RefreshEdit();
  264. //}
  265. }
  266. private void dataGridViewPatientSelectResult_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e) {
  267. if(e.RowIndex >= 0) {
  268. string NumberingText = (e.RowIndex + 1).ToString();
  269. // 글자 사이즈 구하기.
  270. SizeF stringSize = e.Graphics.MeasureString(NumberingText, Font);
  271. // 글자에 맞춰 좌표계산.
  272. PointF StringPoint = new PointF
  273. (
  274. Convert.ToSingle(this.dataGridViewPatientSelectResult.RowHeadersWidth - 3 - stringSize.Width),
  275. Convert.ToSingle(e.RowBounds.Y) + this.dataGridViewPatientSelectResult[0, e.RowIndex].ContentBounds.Height * 0.3f
  276. );
  277. // 문자열 그리기.
  278. e.Graphics.DrawString
  279. (
  280. NumberingText,
  281. Font,
  282. Brushes.Black,
  283. StringPoint.X,
  284. StringPoint.Y
  285. );
  286. }
  287. }
  288. /// <summary>
  289. /// 외래 환자 리스트 그리드 셀 더블클릭 이벤트
  290. /// </summary>
  291. /// <param name="sender">The source of the event.</param>
  292. /// <param name="e">The <see cref="DataGridViewCellEventArgs"/> instance containing the event data.</param>
  293. private void dataGridViewPatientSelectResult_CellDoubleClick(object sender, DataGridViewCellEventArgs e) {
  294. if(e.RowIndex > -1) {
  295. PatListVO vo = this.dataGridViewPatientSelectResult.Rows[e.RowIndex].DataBoundItem as PatListVO;
  296. // 현재 선택된 환자를 바꾼다
  297. consentMain.PatientListCtrl.SetChangePID(vo);
  298. consentMain = ConsentMainControl.GetConsentMainInterface(this);
  299. if(commandControl == null) commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl;
  300. // 현재환자의 진료과로 변경한다
  301. setSearchDeptCode(commandControl.CurrentTargetPatient.clnDeptCode);
  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 comboDept_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 comboDept_MeasureItem(object sender, MeasureItemEventArgs e) {
  345. e.ItemHeight = 20;
  346. }
  347. private void comboDoctor_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(((DocListVO[])box.DataSource)[e.Index].doctorNm,
  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 comboDoctor_MeasureItem(object sender, MeasureItemEventArgs e) {
  370. e.ItemHeight = 20;
  371. }
  372. }
  373. }