PatientSelectTabOperatePatient.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  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 PatientSelectTabOperatePatient : UserControl {
  24. private IConsentMain consentMain = null;
  25. private HospitalSvcRef.HospitalSvcSoapClient hospitalWebService = null;
  26. public PatientSelectTabOperatePatient() {
  27. InitializeComponent();
  28. }
  29. private void PatientSelectTabOperatePatient_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, "수술방", "oproomnm", true, 80);
  56. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "병실", "roomcd", true, 60);
  57. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "등록번호", "pid", true, 80);
  58. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "성명", "hngnm", true, 80);
  59. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "집도과", "deptnm", true, 80);
  60. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "집도의", "doctornm", true, 80);
  61. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "마취방법", "anstreqflag", true, 80);
  62. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "마취의", "anstdrnm", true, 80);
  63. //dataGridViewPatientSelectResult.Columns["colCheck"].Visible = false;
  64. }
  65. #region 환자 조회
  66. private void BindDataGridRows() {
  67. if(this.consentMain == null) consentMain = ConsentMainControl.GetConsentMainInterface(this);
  68. if(this.hospitalWebService == null) this.hospitalWebService = WebMethodCommon.GetHospitalWebService(consentMain.PluginExecuteInfo["hospitalSvcUrl"]);
  69. string srchdd = this.dateTimePickerClnDate.Value.ToShortDateString().Replace("-", "");
  70. string orddeptcd = (this.comboDept.Items.Count > 0) ? this.comboDept.SelectedValue.ToString().Trim() : "";
  71. string doctorid = (this.comboDoctor.Items.Count > 0) ? this.comboDoctor.SelectedValue.ToString().Trim() : "";
  72. string pid = this.textBoxSearchText.Text.Trim();
  73. string patstat = GetSelectGubunValue();
  74. Cursor currentCursor = this.Cursor;
  75. DocListVO selectedDoctor = comboDoctor.SelectedItem as DocListVO;
  76. var drKindValue = "";
  77. if(selectedDoctor != null && selectedDoctor.drKind != null) {
  78. drKindValue = selectedDoctor.drKind.Trim();
  79. }
  80. this.Cursor = Cursors.WaitCursor;
  81. PatListVO[] resultData = hospitalWebService.GetPatientList(srchdd
  82. , orddeptcd
  83. , doctorid
  84. , pid
  85. , patstat
  86. , this.consentMain.ConsentExecuteInfo["dutinstcd"]
  87. , ""
  88. , this.consentMain.ConsentExecuteInfo["loginUserNo"]
  89. , ""
  90. , string.Empty
  91. , drKindValue
  92. , "OP" // 수술
  93. , "N" // 검색탭 여부(Y: 검색탭, N: 그외)
  94. );
  95. this.Cursor = currentCursor;
  96. if(resultData == null) {
  97. return;
  98. }
  99. this.dataGridViewPatientSelectResult.DataSource = new SortableBindingList<PatListVO>(resultData);
  100. }
  101. private string GetSelectGubunValue() {
  102. string strGubun = "";
  103. RadioButton rdoTemp = null;
  104. if(this.radioGubunAll.Checked)
  105. rdoTemp = radioGubunAll;
  106. else if(this.radioGubunStep1.Checked)
  107. rdoTemp = radioGubunStep1;
  108. else if(this.radioGubunStep2.Checked)
  109. rdoTemp = radioGubunStep2;
  110. else if(this.radioGubunStep3.Checked)
  111. rdoTemp = radioGubunStep3;
  112. else if(this.radioGubunStep4.Checked)
  113. rdoTemp = radioGubunStep4;
  114. strGubun = rdoTemp.Tag.ToString();
  115. return strGubun;
  116. }
  117. private void comboDept_SelectedIndexChanged(object sender, EventArgs e) {
  118. // 주치의 목록 조회
  119. DocListVO[] doctorList = this.hospitalWebService.GetDoctorList(DateTime.Now.ToShortDateString().Replace("-", ""),
  120. (this.comboDept.Items.Count > 0) ? this.comboDept.SelectedValue.ToString() : ""
  121. , this.consentMain.ConsentExecuteInfo["dutinstcd"]);
  122. if(doctorList != null) {
  123. this.comboDoctor.DisplayMember = "doctornm";
  124. this.comboDoctor.ValueMember = "doctorid";
  125. this.comboDoctor.DataSource = doctorList;
  126. }
  127. }
  128. /// <summary>
  129. /// 조회버튼 클릭 이벤트
  130. /// </summary>
  131. /// <param name="sender">The source of the event.</param>
  132. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  133. private void buttonPatientSelect_Click(object sender, EventArgs e) {
  134. var selectedDeptIndex = this.comboDept.SelectedIndex;
  135. var selectedDoctorIndex = this.comboDoctor.SelectedIndex;
  136. var patientNameValue = this.textBoxSearchText.Text;
  137. //if(selectedDeptIndex == 0 && selectedDoctorIndex == 0 && String.Empty.Equals(patientNameValue)) {
  138. // MessageBox.Show("집도과, 집도의, 등록번호중 1가지 이상 입력해주세요.");
  139. // return;
  140. //}
  141. Cursor currentCursor = this.Cursor;
  142. try {
  143. this.Cursor = Cursors.WaitCursor;
  144. BindDataGridRows();
  145. }
  146. catch(Exception ex) {
  147. throw ex;
  148. }
  149. finally {
  150. this.Cursor = currentCursor;
  151. }
  152. }
  153. #endregion
  154. #region 환자찾기 버튼 클릭 이벤트
  155. /// <summary>
  156. /// 등록번호검색 버튼 클릭 이벤트
  157. /// </summary>
  158. /// <param name="sender">The source of the event.</param>
  159. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  160. private void buttonSearchPop_Click(object sender, EventArgs e) {
  161. string strTemp = this.textBoxSearchText.Text.Trim();
  162. int iResult;
  163. if(int.TryParse(strTemp, out iResult) && strTemp.Length > 6) {
  164. this.buttonPatientSelect.PerformClick();
  165. }
  166. else {
  167. PatientSearchPopup popup = new PatientSearchPopup(textBoxSearchText.Text
  168. , consentMain.ConsentExecuteInfo["dutinstcd"]
  169. , consentMain.ConsentExecuteInfo["sysInstNm"]);
  170. DialogResult result = popup.ShowDialog();
  171. if(result == DialogResult.OK) {
  172. this.textBoxSearchText.Text = popup.PatientID;
  173. this.buttonPatientSelect.PerformClick();
  174. }
  175. popup.Close();
  176. }
  177. }
  178. /// <summary>
  179. /// 환자 등록번호 입력 컨트롤 키보드 이벤트
  180. /// </summary>
  181. /// <param name="sender">The source of the event.</param>
  182. /// <param name="e">The <see cref="KeyEventArgs"/> instance containing the event data.</param>
  183. private void textBoxSearchText_KeyDown(object sender, KeyEventArgs e) {
  184. if(e.KeyCode == Keys.Enter) {
  185. this.buttonSearchPop.PerformClick();
  186. }
  187. }
  188. #endregion
  189. #region 그리드 이벤트
  190. private void dataGridViewPatientSelectResult_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) {
  191. //if(e.ColumnIndex == 0 && e.RowIndex == -1) {
  192. // Image InfoIcon;
  193. // if(dataGridViewPatientSelectResult.Columns[0].HeaderText.Equals("□")) {
  194. // InfoIcon = Image.FromFile(@"../../Resources/uncheck.png");
  195. // }
  196. // else {
  197. // InfoIcon = Image.FromFile(@"../../Resources/check.png");
  198. // }
  199. // e.Paint(e.CellBounds, DataGridViewPaintParts.All);
  200. // e.Graphics.DrawImage(InfoIcon, e.CellBounds);
  201. // e.Handled = true;
  202. //}
  203. }
  204. private void dataGridViewPatientSelectResult_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) {
  205. //if(e.ColumnIndex == 0 && e.RowIndex == -1) {
  206. // bool chkStatus = false;
  207. // if(dataGridViewPatientSelectResult.Columns[0].HeaderText.Equals("□")) {
  208. // dataGridViewPatientSelectResult.Columns[0].HeaderText = "☑";
  209. // chkStatus = true;
  210. // }
  211. // else {
  212. // dataGridViewPatientSelectResult.Columns[0].HeaderText = "□";
  213. // }
  214. // foreach(DataGridViewRow r in dataGridViewPatientSelectResult.Rows) {
  215. // r.Cells["colCheck"].Value = chkStatus;
  216. // }
  217. // dataGridViewPatientSelectResult.RefreshEdit();
  218. //}
  219. }
  220. private void dataGridViewPatientSelectResult_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e) {
  221. if(e.RowIndex >= 0) {
  222. string NumberingText = (e.RowIndex + 1).ToString();
  223. // 글자 사이즈 구하기.
  224. SizeF stringSize = e.Graphics.MeasureString(NumberingText, Font);
  225. // 글자에 맞춰 좌표계산.
  226. PointF StringPoint = new PointF
  227. (
  228. Convert.ToSingle(this.dataGridViewPatientSelectResult.RowHeadersWidth - 3 - stringSize.Width),
  229. Convert.ToSingle(e.RowBounds.Y) + this.dataGridViewPatientSelectResult[0, e.RowIndex].ContentBounds.Height * 0.3f
  230. );
  231. // 문자열 그리기.
  232. e.Graphics.DrawString
  233. (
  234. NumberingText,
  235. Font,
  236. Brushes.Black,
  237. StringPoint.X,
  238. StringPoint.Y
  239. );
  240. }
  241. }
  242. private void dataGridViewPatientSelectResult_CellDoubleClick(object sender, DataGridViewCellEventArgs e) {
  243. if(e.RowIndex > -1) {
  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. //bool chkStatus = false;
  251. //dataGridViewPatientSelectResult.Columns[0].HeaderText = "□";
  252. //foreach(DataGridViewRow r in dataGridViewPatientSelectResult.Rows) {
  253. // r.Cells["colCheck"].Value = chkStatus;
  254. //}
  255. //dataGridViewPatientSelectResult.RefreshEdit();
  256. }
  257. public List<PatListVO> GetCheckPatList() {
  258. List<PatListVO> voList = new List<PatListVO>();
  259. foreach(DataGridViewRow r in dataGridViewPatientSelectResult.Rows) {
  260. if(Convert.ToBoolean(r.Cells["colCheck"].Value)) {
  261. voList.Add(r.DataBoundItem as PatListVO);
  262. }
  263. }
  264. return voList;
  265. }
  266. private void comboDept_DrawItem(object sender, DrawItemEventArgs e) {
  267. ComboBox box = sender as ComboBox;
  268. if(box is null)
  269. return;
  270. e.DrawBackground();
  271. if(e.Index >= 0) {
  272. Graphics g = e.Graphics;
  273. using(Brush brush = ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
  274. ? new SolidBrush(SystemColors.Highlight)
  275. : new SolidBrush(e.BackColor)) {
  276. using(Brush textBrush = new SolidBrush(e.ForeColor)) {
  277. g.FillRectangle(brush, e.Bounds);
  278. g.DrawString(((DeptListVO[])box.DataSource)[e.Index].deptNm,
  279. e.Font,
  280. textBrush,
  281. (float)e.Bounds.X,
  282. (float)(e.Bounds.Y) + 2.34F);
  283. }
  284. }
  285. }
  286. e.DrawFocusRectangle();
  287. }
  288. private void comboDept_MeasureItem(object sender, MeasureItemEventArgs e) {
  289. e.ItemHeight = 20;
  290. }
  291. private void comboDoctor_DrawItem(object sender, DrawItemEventArgs e) {
  292. ComboBox box = sender as ComboBox;
  293. if(box is null)
  294. return;
  295. e.DrawBackground();
  296. if(e.Index >= 0) {
  297. Graphics g = e.Graphics;
  298. using(Brush brush = ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
  299. ? new SolidBrush(SystemColors.Highlight)
  300. : new SolidBrush(e.BackColor)) {
  301. using(Brush textBrush = new SolidBrush(e.ForeColor)) {
  302. g.FillRectangle(brush, e.Bounds);
  303. g.DrawString(((DocListVO[])box.DataSource)[e.Index].doctorNm,
  304. e.Font,
  305. textBrush,
  306. (float)e.Bounds.X,
  307. (float)(e.Bounds.Y) + 2.34F);
  308. }
  309. }
  310. }
  311. e.DrawFocusRectangle();
  312. }
  313. private void comboDoctor_MeasureItem(object sender, MeasureItemEventArgs e) {
  314. e.ItemHeight = 20;
  315. }
  316. }
  317. }