PatientSelectTabSearchPatient.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  1. using System;
  2. using System.Collections;
  3. using System.Drawing;
  4. using System.ComponentModel;
  5. using System.Windows.Forms;
  6. using System.Collections.Generic;
  7. using CLIP.eForm.Consent.UI.HospitalSvcRef;
  8. using System.Linq;
  9. namespace CLIP.eForm.Consent.UI {
  10. /// <summary>
  11. /// 환자목록 > 환자검색 탭 클래스
  12. /// </summary>
  13. /// <remarks>
  14. /// <p>[설계자]</p>
  15. /// <p> 클립소프트 연구소 홍지철 (jchong@clipsoft.co.kr)</p>
  16. /// <p>[원본 작성자]</p>
  17. /// <p> 클립소프트 기술부 이인희</p>
  18. /// <p>[수정 작성자]</p>
  19. /// <p> </p>
  20. /// <p>----------------------------------------------------------------------------------------</p>
  21. /// <p>[HISTORY]</p>
  22. /// <p> 2016-07-11 : 최초작성</p>
  23. /// <p>----------------------------------------------------------------------------------------</p>
  24. /// </remarks>
  25. public partial class PatientSelectTabSearchPatient : UserControl {
  26. private IConsentMain consentMain = null;
  27. private ConsentCommandCtrl commandControl = null;
  28. private HospitalSvcRef.HospitalSvcSoapClient hospitalWebService = null;
  29. public PatientSelectTabSearchPatient() {
  30. InitializeComponent();
  31. }
  32. private void PatientSelectTabSearchPatient_Load(object sender, EventArgs e) {
  33. Boolean isInWpfDesignerMode = (LicenseManager.UsageMode == LicenseUsageMode.Designtime);
  34. Boolean isInFormsDesignerMode = (System.Diagnostics.Process.GetCurrentProcess().ProcessName == "devenv");
  35. if (isInWpfDesignerMode || isInFormsDesignerMode) {
  36. // is in any designer mode
  37. return;
  38. }
  39. if (this.DesignMode || LicenseManager.UsageMode == LicenseUsageMode.Designtime) {
  40. return;
  41. }
  42. consentMain = ConsentMainControl.GetConsentMainInterface(this);
  43. commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl;
  44. hospitalWebService = WebMethodCommon.GetHospitalWebService(consentMain.PluginExecuteInfo["hospitalSvcUrl"]);
  45. this.dateTimePickerClnDate.Value = DateTime.Now;
  46. InitComboBind();
  47. InitDataGrid();
  48. }
  49. private void InitComboBind() {
  50. // 진료과
  51. //DeptListVO[] deptList = this.hospitalWebService.GetDeptList(GetSelectGubunValue(), consentMain.ConsentExecuteInfo["dutinstcd"]);
  52. DeptListVO[] deptList = this.hospitalWebService.GetOrgDeptList(GetSelectGubunValue(), this.consentMain.ConsentExecuteInfo["dutinstcd"]);
  53. if (deptList != null) {
  54. this.comboDept.DisplayMember = "deptnm";
  55. this.comboDept.ValueMember = "deptcd";
  56. this.comboDept.DataSource = deptList;
  57. }
  58. }
  59. private void InitDataGrid() {
  60. this.dataGridViewPatientSelectResult.AutoGenerateColumns = false;
  61. this.dataGridViewPatientSelectResult.AllowUserToAddRows = false;
  62. //this.dataGridViewPatientSelectResult.CellPainting += new DataGridViewCellPaintingEventHandler(this.dataGridViewPatientSelectResult_CellPainting);
  63. this.dataGridViewPatientSelectResult.ColumnHeaderMouseClick += new DataGridViewCellMouseEventHandler(this.dataGridViewPatientSelectResult_ColumnHeaderMouseClick);
  64. this.dataGridViewPatientSelectResult.RowPostPaint += new DataGridViewRowPostPaintEventHandler(this.dataGridViewPatientSelectResult_RowPostPaint);
  65. //CommonUtil.AddNewCheckBoxColumnToDataGridView(this.dataGridViewPatientSelectResult, "□", "colCheck", true, 30, DataGridViewContentAlignment.MiddleCenter);
  66. //CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "구분", "Gubun", true, 60);`
  67. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "등록번호", "pid", true, 80);
  68. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "성명", "hngnm", true, 80);
  69. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "진료/입원일자", "indd", true, 120);
  70. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "진료과", "deptnm", true, 80);
  71. CommonUtil.AddNewColumnToDataGridView(this.dataGridViewPatientSelectResult, "진료의", "doctornm", true, 80);
  72. }
  73. #region 환자 조회
  74. /// <summary>
  75. /// 선택된 조건으로 환자를 조회한다
  76. /// </summary>
  77. private void BindDataGridRows() {
  78. if (this.consentMain == null) consentMain = ConsentMainControl.GetConsentMainInterface(this);
  79. if (this.hospitalWebService == null) this.hospitalWebService = WebMethodCommon.GetHospitalWebService(consentMain.PluginExecuteInfo["hospitalSvcUrl"]);
  80. string srchdd = this.dateTimePickerClnDate.Value.ToShortDateString().Replace("-", "");
  81. string orddeptcd = (this.comboDept.Items.Count > 0) ? this.comboDept.SelectedValue.ToString().Trim() : String.Empty;
  82. string doctorid = (this.comboDoctor.Items.Count > 0) ? this.comboDoctor.SelectedValue.ToString().Trim() : String.Empty;
  83. string pid = this.textBoxSearchText.Text.Trim();
  84. string patientOrdtype = GetSelectGubunValue();
  85. Cursor currentCursor = this.Cursor;
  86. this.Cursor = Cursors.WaitCursor;
  87. PatListVO[] resultData = null;
  88. resultData = hospitalWebService.GetPatientList(patientOrdtype,
  89. "Y",
  90. srchdd,
  91. orddeptcd ?? String.Empty,
  92. doctorid ?? String.Empty,
  93. pid,
  94. "",
  95. "",
  96. consentMain.ConsentExecuteInfo["dutinstcd"],
  97. commandControl.CurrentEndUser.userId,
  98. "N",
  99. "");
  100. this.Cursor = currentCursor;
  101. if (resultData != null) {
  102. this.dataGridViewPatientSelectResult.DataSource = new SortableBindingList<PatListVO>(resultData);
  103. }
  104. }
  105. private string GetSelectGubunValue() {
  106. string strGubun = "";
  107. RadioButton rdoTemp = null;
  108. if (this.radioGubunOut.Checked) {
  109. rdoTemp = radioGubunOut;
  110. } else if (this.radioGubunIn.Checked) {
  111. rdoTemp = radioGubunIn;
  112. } else if (this.radioGubunER.Checked) {
  113. rdoTemp = radioGubunER;
  114. }
  115. strGubun = rdoTemp.Tag.ToString();
  116. return strGubun;
  117. }
  118. public Hashtable getQueryString() {
  119. //var result = new {
  120. // fromdd = dateTimePickerClnDate.Value.ToString("yyyyMMdd"),
  121. // wardcd = (this.comboWard.Items.Count > 0) ? this.comboWard.SelectedValue.ToString().Trim() : "",
  122. // deptcd = (this.comboDept.Items.Count > 0) ? this.comboDept.SelectedValue.ToString().Trim() : "",
  123. // doctorId = (this.comboDoctor.Items.Count > 0) ? this.comboDoctor.SelectedValue.ToString().Trim() : ""
  124. //};
  125. string srchDd = dateTimePickerClnDate.Value.ToString("yyyyMMdd");
  126. string deptcd = (this.comboDept.Items.Count > 0) ? this.comboDept.SelectedValue.ToString().Trim() : "";
  127. string doctorId = (this.comboDoctor.Items.Count > 0) ? this.comboDoctor.SelectedValue.ToString().Trim() : "";
  128. string pid = this.textBoxSearchText.Text;
  129. string strGubun = "";
  130. if (this.radioGubunOut.Checked) {
  131. strGubun = radioGubunOut.Tag.ToString();
  132. } else if (this.radioGubunIn.Checked) {
  133. strGubun = radioGubunIn.Tag.ToString();
  134. } else if (this.radioGubunER.Checked) {
  135. strGubun = radioGubunER.Tag.ToString();
  136. }
  137. Hashtable result = new Hashtable();
  138. result.Add("srchDd", srchDd);
  139. result.Add("ordDeptCd", deptcd);
  140. result.Add("doctorId", doctorId);
  141. result.Add("pid", pid);
  142. result.Add("patientState", strGubun);
  143. result.Add("srchYN", "Y");
  144. result.Add("ordType", "S");
  145. return result;
  146. }
  147. private void comboDept_SelectedIndexChanged(object sender, EventArgs e) {
  148. DocListVO[] doctorList = null;
  149. if (this.comboDept.SelectedIndex == 0) {
  150. doctorList = new DocListVO[1];
  151. DocListVO doc = new DocListVO();
  152. doc.doctorId = "";
  153. doc.doctorNm = "진료의(전체)";
  154. doc.drKind = "";
  155. doctorList[0] = doc;
  156. this.comboDoctor.DisplayMember = "doctornm";
  157. this.comboDoctor.ValueMember = "doctorid";
  158. this.comboDoctor.DataSource = doctorList;
  159. return;
  160. }
  161. // 주치의 목록 조회
  162. doctorList = this.hospitalWebService.GetDoctorList(DateTime.Now.ToShortDateString().Replace("-", ""),
  163. (this.comboDept.Items.Count > 0) ? this.comboDept.SelectedValue.ToString() : ""
  164. , consentMain.ConsentExecuteInfo["dutinstcd"]);
  165. if (doctorList != null) {
  166. this.comboDoctor.DisplayMember = "doctornm";
  167. this.comboDoctor.ValueMember = "doctorid";
  168. this.comboDoctor.DataSource = doctorList;
  169. }
  170. }
  171. /// <summary>
  172. /// 조회 버튼 클릭 이벤트
  173. /// </summary>
  174. /// <param name="sender">The source of the event.</param>
  175. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  176. private void buttonPatientSelect_Click(object sender, EventArgs e) {
  177. var selectedDeptIndex = this.comboDept.SelectedIndex;
  178. var selectedDoctorIndex = this.comboDoctor.SelectedIndex;
  179. var patientNameValue = this.textBoxSearchText.Text;
  180. if (selectedDeptIndex == 0 && selectedDoctorIndex == 0 && String.Empty.Equals(patientNameValue)) {
  181. MessageBox.Show("조회할 등록번호를 입력해주세요.");
  182. return;
  183. }
  184. Cursor currentCursor = this.Cursor;
  185. try {
  186. this.Cursor = Cursors.WaitCursor;
  187. BindDataGridRows();
  188. } catch (Exception ex) {
  189. throw ex;
  190. } finally {
  191. this.Cursor = currentCursor;
  192. }
  193. }
  194. #endregion
  195. #region 환자찾기 버튼 클릭 이벤트
  196. /// <summary>
  197. /// 등록번호 입력 컨트롤 키보드 입력 이벤트
  198. /// </summary>
  199. /// <param name="sender">The source of the event.</param>
  200. /// <param name="e">The <see cref="KeyEventArgs"/> instance containing the event data.</param>
  201. private void textBoxSearchText_KeyDown(object sender, KeyEventArgs e) {
  202. // 엔터 키 입력 시 환자 조회
  203. if (e.KeyCode == Keys.Enter) {
  204. buttonPatientSelect.PerformClick();
  205. }
  206. }
  207. #endregion
  208. #region 그리드 이벤트
  209. private void dataGridViewPatientSelectResult_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) {
  210. if (e.ColumnIndex == 0 && e.RowIndex == -1) {
  211. //Image InfoIcon;
  212. //if (dataGridViewPatientSelectResult.Columns[0].HeaderText.Equals("□")) {
  213. // InfoIcon = Image.FromFile(@"../../Resources/uncheck.png");
  214. //} else {
  215. // InfoIcon = Image.FromFile(@"../../Resources/check.png");
  216. //}
  217. //e.Paint(e.CellBounds, DataGridViewPaintParts.All);
  218. //e.Graphics.DrawImage(InfoIcon, e.CellBounds);
  219. //e.Handled = true;
  220. }
  221. }
  222. private void dataGridViewPatientSelectResult_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) {
  223. if (e.ColumnIndex == 0 && e.RowIndex == -1) {
  224. //bool chkStatus = false;
  225. //if (dataGridViewPatientSelectResult.Columns[0].HeaderText.Trim().Equals("□")) {
  226. // dataGridViewPatientSelectResult.Columns[0].HeaderText = "☑";
  227. // chkStatus = true;
  228. //} else {
  229. // dataGridViewPatientSelectResult.Columns[0].HeaderText = "□";
  230. //}
  231. //foreach (DataGridViewRow r in dataGridViewPatientSelectResult.Rows) {
  232. // r.Cells["colCheck"].Value = chkStatus;
  233. //}
  234. //dataGridViewPatientSelectResult.RefreshEdit();
  235. }
  236. }
  237. private void dataGridViewPatientSelectResult_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e) {
  238. if (e.RowIndex >= 0) {
  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. if (e.RowIndex > -1) {
  261. PatListVO vo = this.dataGridViewPatientSelectResult.Rows[e.RowIndex].DataBoundItem as PatListVO;
  262. consentMain.PatientListCtrl.SetChangePID(vo);
  263. }
  264. }
  265. #endregion
  266. /// <summary>
  267. /// 체크박스 내용 삭제
  268. /// </summary>
  269. public void ClearCheckBox() {
  270. bool chkStatus = false;
  271. //dataGridViewPatientSelectResult.Columns[0].HeaderText = "□";
  272. foreach (DataGridViewRow r in dataGridViewPatientSelectResult.Rows) {
  273. r.Cells["colCheck"].Value = chkStatus;
  274. }
  275. dataGridViewPatientSelectResult.RefreshEdit();
  276. }
  277. /// <summary>
  278. /// 현재 선택된 환자 목록 반환
  279. /// </summary>
  280. /// <returns>PatListVO 목록</returns>
  281. public List<PatListVO> GetCheckPatList() {
  282. List<PatListVO> voList = new List<PatListVO>();
  283. DataGridViewRow curRow = dataGridViewPatientSelectResult.CurrentRow;
  284. voList.Add(curRow.DataBoundItem as PatListVO);
  285. //foreach (DataGridViewRow r in dataGridViewPatientSelectResult.Rows) {
  286. // if (Convert.ToBoolean(r.Cells["colCheck"].Value)) {
  287. // voList.Add(r.DataBoundItem as PatListVO);
  288. // }
  289. //}
  290. return voList;
  291. }
  292. private void comboDept_DrawItem(object sender, DrawItemEventArgs e) {
  293. ComboBox box = sender as ComboBox;
  294. if (box is null)
  295. return;
  296. e.DrawBackground();
  297. if (e.Index >= 0) {
  298. Graphics g = e.Graphics;
  299. using (Brush brush = ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
  300. ? new SolidBrush(SystemColors.Highlight)
  301. : new SolidBrush(e.BackColor)) {
  302. using (Brush textBrush = new SolidBrush(e.ForeColor)) {
  303. g.FillRectangle(brush, e.Bounds);
  304. g.DrawString(((DeptListVO[]) box.DataSource)[e.Index].deptNm,
  305. e.Font,
  306. textBrush,
  307. (float) e.Bounds.X,
  308. (float) (e.Bounds.Y) + 2.34F);
  309. }
  310. }
  311. }
  312. e.DrawFocusRectangle();
  313. }
  314. private void comboDept_MeasureItem(object sender, MeasureItemEventArgs e) {
  315. e.ItemHeight = 20;
  316. }
  317. private void comboDoctor_DrawItem(object sender, DrawItemEventArgs e) {
  318. ComboBox box = sender as ComboBox;
  319. if (box is null)
  320. return;
  321. e.DrawBackground();
  322. if (e.Index >= 0) {
  323. Graphics g = e.Graphics;
  324. using (Brush brush = ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
  325. ? new SolidBrush(SystemColors.Highlight)
  326. : new SolidBrush(e.BackColor)) {
  327. using (Brush textBrush = new SolidBrush(e.ForeColor)) {
  328. g.FillRectangle(brush, e.Bounds);
  329. g.DrawString(((DocListVO[]) box.DataSource)[e.Index].doctorNm,
  330. e.Font,
  331. textBrush,
  332. (float) e.Bounds.X,
  333. (float) (e.Bounds.Y) + 2.34F);
  334. }
  335. }
  336. }
  337. e.DrawFocusRectangle();
  338. }
  339. private void comboDoctor_MeasureItem(object sender, MeasureItemEventArgs e) {
  340. e.ItemHeight = 20;
  341. }
  342. private void radioGubun_Click(object sender, EventArgs e) {
  343. bool isVisible = false;
  344. if (this.radioGubunOut.Checked) {
  345. isVisible = true;
  346. }
  347. commandControl.setCompleteSaveButton(isVisible);
  348. consentMain.ReInitializeViewer();
  349. }
  350. }
  351. }