PatientSelectTabOutPatient.cs 18 KB

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