PatientSelectTabOutPatient.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  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.Dfh.UI.HospitalSvcRef;
  7. namespace CLIP.eForm.Consent.Dfh.UI
  8. {
  9. /// <summary>
  10. /// 환자목록 > 외래 탭 클래스
  11. /// </summary>
  12. /// <remarks>
  13. /// <p>[설계자]</p>
  14. /// <p> 클립소프트 연구소 홍지철 (jchong@clipsoft.co.kr)</p>
  15. /// <p>[원본 작성자]</p>
  16. /// <p> 클립소프트 기술부 이인희</p>
  17. /// <p>[수정 작성자]</p>
  18. /// <p> </p>
  19. /// <p>----------------------------------------------------------------------------------------</p>
  20. /// <p>[HISTORY]</p>
  21. /// <p> 2016-07-11 : 최초작성</p>
  22. /// <p>----------------------------------------------------------------------------------------</p>
  23. /// </remarks>
  24. public partial class PatientSelectTabOutPatient : UserControl
  25. {
  26. private IConsentMain consentMain = null;
  27. private ConsentCommandCtrl commandControl = null;
  28. private HospitalSvcRef.HospitalSvcSoapClient hospitalWebService = null;
  29. public PatientSelectTabOutPatient()
  30. {
  31. InitializeComponent();
  32. }
  33. private void PatientSelectTabOutPatient_Load(object sender, EventArgs e)
  34. {
  35. if (this.DesignMode || LicenseManager.UsageMode == LicenseUsageMode.Designtime)
  36. {
  37. return;
  38. }
  39. consentMain = ConsentMainControl.GetConsentMainInterface(this);
  40. if (commandControl == null) commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl;
  41. hospitalWebService = WebMethodCommon.GetHospitalWebService(consentMain.PluginExecuteInfo["hospitalSvcUrl"]);
  42. this.dateTimePickerClnDate.Value = DateTime.Now;
  43. InitComboBind();
  44. //setSearchDeptCode(commandControl.CurrentTargetPatient.clnDeptCode);
  45. string tempval = "";
  46. if (commandControl.CurrentEndUser.DeptCode.Substring(0, 3).Equals("201"))//내과계열은 직원 소속 부서가 전부 내과 외래라 구분 불가
  47. {
  48. if (commandControl.CurrentEndUser.DeptCode.Substring(0, 4).Equals("2011"))//감염내과 세팅
  49. {
  50. tempval = commandControl.CurrentEndUser.DeptCode.Substring(0, 4) + "000000";
  51. }
  52. else
  53. {
  54. tempval = "";
  55. }
  56. }
  57. else//내과아닌곳은 세팅
  58. {
  59. tempval = commandControl.CurrentEndUser.DeptCode.Substring(0, 3) +"0000000";
  60. }
  61. setSearchDeptCode(tempval);
  62. InitDataGrid();
  63. }
  64. public void setSearchDeptCode(string clnDeptCode)
  65. {
  66. if (!string.IsNullOrEmpty(clnDeptCode) && this.comboDept != null)
  67. {
  68. this.comboDept.SelectedValue = clnDeptCode;
  69. }
  70. }
  71. private void InitComboBind()
  72. {
  73. // 진료과
  74. DeptListVO[] deptList = this.hospitalWebService.GetDeptList(GetSelectGubunValue());
  75. if (deptList != null)
  76. {
  77. this.comboDept.DisplayMember = "deptnm";
  78. this.comboDept.ValueMember = "deptcd";
  79. this.comboDept.DataSource = deptList;
  80. }
  81. }
  82. private void InitDataGrid()
  83. {
  84. this.dataGridViewPatientSelectResult.AutoGenerateColumns = false;
  85. this.dataGridViewPatientSelectResult.AllowUserToAddRows = false;
  86. //this.dataGridViewPatientSelectResult.CellPainting += new DataGridViewCellPaintingEventHandler(this.dataGridViewPatientSelectResult_CellPainting);
  87. this.dataGridViewPatientSelectResult.ColumnHeaderMouseClick += new DataGridViewCellMouseEventHandler(this.dataGridViewPatientSelectResult_ColumnHeaderMouseClick);
  88. this.dataGridViewPatientSelectResult.RowPostPaint += new DataGridViewRowPostPaintEventHandler(this.dataGridViewPatientSelectResult_RowPostPaint);
  89. CommonUtil.AddNewCheckBoxColumnToDataGridView(this.dataGridViewPatientSelectResult, "□", "colCheck", true, 30, DataGridViewContentAlignment.MiddleCenter);
  90. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "등록번호", "pid", true, 60);
  91. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "성명", "hngnm", true, 80);
  92. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "구분", "elbulbodstat", true, 40);
  93. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "초진", "fsexamflag", true, 60);
  94. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "진료일자", "indd", true, 80);
  95. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "시간", "ordtm", true, 60);
  96. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "과", "deptengabbr", true, 40);
  97. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "진료의", "doctornm", true, 80);
  98. }
  99. #region 환자 조회
  100. public void BindDataGridRows()
  101. {
  102. if (this.consentMain == null) consentMain = ConsentMainControl.GetConsentMainInterface(this);
  103. if (this.hospitalWebService == null) this.hospitalWebService = WebMethodCommon.GetHospitalWebService(consentMain.PluginExecuteInfo["hospitalSvcUrl"]);
  104. string srchdd = this.dateTimePickerClnDate.Value.ToShortDateString().Replace("-", "");
  105. string orddeptcd = (this.comboDept.Items.Count > 0) ? this.comboDept.SelectedValue.ToString().Trim() : "";
  106. string doctorid = (this.comboDoctor.Items.Count > 0) ? this.comboDoctor.SelectedValue.ToString().Trim() : "";
  107. string pid = this.textBoxSearchText.Text.Trim();
  108. string patstat = GetSelectGubunValue();
  109. PatListVO[] resultData = hospitalWebService.GetOutPatList(srchdd, orddeptcd, doctorid, pid, patstat);
  110. if (resultData == null)
  111. {
  112. return;
  113. }
  114. this.dataGridViewPatientSelectResult.DataSource = new SortableBindingList<PatListVO>(resultData);
  115. }
  116. private string GetSelectGubunValue()
  117. {
  118. string strGubun = "";
  119. if (this.radioGubunAll.Checked)
  120. {
  121. strGubun = "";
  122. }
  123. else
  124. {
  125. RadioButton rdoTemp = null;
  126. if (this.radioGubunStep1.Checked)
  127. rdoTemp = radioGubunStep1;
  128. else if (this.radioGubunStep2.Checked)
  129. rdoTemp = radioGubunStep2;
  130. else if (this.radioGubunStep3.Checked)
  131. rdoTemp = radioGubunStep3;
  132. strGubun = rdoTemp.Tag.ToString();
  133. }
  134. return strGubun;
  135. }
  136. private void comboDept_SelectedIndexChanged(object sender, EventArgs e)
  137. {
  138. // 주치의
  139. DocListVO[] doctorList = this.hospitalWebService.GetDoctorList(DateTime.Now.ToShortDateString().Replace("-", ""),
  140. (this.comboDept.Items.Count > 0 && this.comboDept.SelectedValue != null) ? this.comboDept.SelectedValue.ToString() : "");
  141. if (doctorList != null)
  142. {
  143. this.comboDoctor.DisplayMember = "doctornm";
  144. this.comboDoctor.ValueMember = "doctorid";
  145. this.comboDoctor.DataSource = doctorList;
  146. }
  147. }
  148. private void buttonPatientSelect_Click(object sender, EventArgs e)
  149. {
  150. Cursor currentCursor = this.Cursor;
  151. try
  152. {
  153. this.Cursor = Cursors.WaitCursor;
  154. BindDataGridRows();
  155. }
  156. catch (Exception ex)
  157. {
  158. throw ex;
  159. }
  160. finally
  161. {
  162. this.Cursor = currentCursor;
  163. }
  164. }
  165. #endregion
  166. #region 환자찾기 버튼 클릭 이벤트
  167. private void buttonSearchPop_Click(object sender, EventArgs e)
  168. {
  169. string strTemp = this.textBoxSearchText.Text.Trim();
  170. int iResult;
  171. if (int.TryParse(strTemp, out iResult) && strTemp.Length > 6)
  172. {
  173. this.buttonPatientSelect.PerformClick();
  174. }
  175. else
  176. {
  177. PatientSearchPopup popup = new PatientSearchPopup(textBoxSearchText.Text);
  178. DialogResult result = popup.ShowDialog();
  179. if (result == DialogResult.OK)
  180. {
  181. this.textBoxSearchText.Text = popup.PatientID;
  182. this.buttonPatientSelect.PerformClick();
  183. }
  184. popup.Close();
  185. }
  186. }
  187. private void textBoxSearchText_KeyDown(object sender, KeyEventArgs e)
  188. {
  189. if (e.KeyCode == Keys.Enter)
  190. {
  191. this.buttonSearchPop.PerformClick();
  192. }
  193. }
  194. #endregion
  195. #region 그리드 이벤트
  196. private void dataGridViewPatientSelectResult_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
  197. {
  198. if (e.ColumnIndex == 0 && e.RowIndex == -1)
  199. {
  200. Image InfoIcon;
  201. if (dataGridViewPatientSelectResult.Columns[0].HeaderText.Equals("□"))
  202. {
  203. InfoIcon = Image.FromFile(@"../../Resources/uncheck.png");
  204. }
  205. else
  206. {
  207. InfoIcon = Image.FromFile(@"../../Resources/check.png");
  208. }
  209. e.Paint(e.CellBounds, DataGridViewPaintParts.All);
  210. e.Graphics.DrawImage(InfoIcon, e.CellBounds);
  211. e.Handled = true;
  212. }
  213. }
  214. private void dataGridViewPatientSelectResult_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
  215. {
  216. if (e.ColumnIndex == 0 && e.RowIndex == -1)
  217. {
  218. bool chkStatus = false;
  219. if (dataGridViewPatientSelectResult.Columns[0].HeaderText.Equals("□"))
  220. {
  221. dataGridViewPatientSelectResult.Columns[0].HeaderText = "☑";
  222. chkStatus = true;
  223. }
  224. else
  225. {
  226. dataGridViewPatientSelectResult.Columns[0].HeaderText = "□";
  227. }
  228. foreach (DataGridViewRow r in dataGridViewPatientSelectResult.Rows)
  229. {
  230. r.Cells["colCheck"].Value = chkStatus;
  231. }
  232. dataGridViewPatientSelectResult.RefreshEdit();
  233. }
  234. }
  235. private void dataGridViewPatientSelectResult_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
  236. {
  237. if (e.RowIndex >= 0)
  238. {
  239. string NumberingText = (e.RowIndex + 1).ToString();
  240. // 글자 사이즈 구하기.
  241. SizeF stringSize = e.Graphics.MeasureString(NumberingText, Font);
  242. // 글자에 맞춰 좌표계산.
  243. PointF StringPoint = new PointF
  244. (
  245. Convert.ToSingle(this.dataGridViewPatientSelectResult.RowHeadersWidth - 3 - stringSize.Width),
  246. Convert.ToSingle(e.RowBounds.Y) + this.dataGridViewPatientSelectResult[0, e.RowIndex].ContentBounds.Height * 0.3f
  247. );
  248. // 문자열 그리기.
  249. e.Graphics.DrawString
  250. (
  251. NumberingText,
  252. Font,
  253. Brushes.Black,
  254. StringPoint.X,
  255. StringPoint.Y
  256. );
  257. }
  258. }
  259. private void dataGridViewPatientSelectResult_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  260. {
  261. if (e.RowIndex > -1)
  262. {
  263. PatListVO vo = this.dataGridViewPatientSelectResult.Rows[e.RowIndex].DataBoundItem as PatListVO;
  264. consentMain.PatientListCtrl.SetChangePID(vo);
  265. consentMain = ConsentMainControl.GetConsentMainInterface(this);
  266. if (commandControl == null) commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl;
  267. if (commandControl.CurrentPreviewConsent != null)
  268. {
  269. commandControl.CurrentPreviewConsent.Ocrcode = null;
  270. commandControl.CurrentPreviewConsent.Ocrtagprntyn = "Y";
  271. }
  272. // if (commandControl.CurrentPreviewConsent.Ocrcode != null) commandControl.CurrentPreviewConsent.Ocrcode = "";
  273. setSearchDeptCode(commandControl.CurrentTargetPatient.clnDeptCode);
  274. }
  275. }
  276. #endregion
  277. public void ClearCheckBox()
  278. {
  279. bool chkStatus = false;
  280. dataGridViewPatientSelectResult.Columns[0].HeaderText = "□";
  281. foreach (DataGridViewRow r in dataGridViewPatientSelectResult.Rows)
  282. {
  283. r.Cells["colCheck"].Value = chkStatus;
  284. }
  285. dataGridViewPatientSelectResult.RefreshEdit();
  286. }
  287. public List<PatListVO> GetCheckPatList()
  288. {
  289. List<PatListVO> voList = new List<PatListVO>();
  290. foreach (DataGridViewRow r in dataGridViewPatientSelectResult.Rows)
  291. {
  292. if (Convert.ToBoolean(r.Cells["colCheck"].Value))
  293. {
  294. voList.Add(r.DataBoundItem as PatListVO);
  295. }
  296. }
  297. return voList;
  298. }
  299. }
  300. }