PatientSelectTabOperatePatient.cs 17 KB

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