#region Copyright © 2015 CLIPSOFT Co.,Ltd. All Rights Reserved. // // All rights are reserved. Reproduction or transmission in whole or in part, // in any form or by any means, electronic, mechanical or otherwise, is // prohibited without the prior written consent of the copyright owner. // // Filename:PatientInfoCtrl.cs // #endregion using System; using System.ComponentModel; using System.Windows.Forms; using System.Collections.Generic; using ClipSoft.Exceptions; using CLIP.eForm.Consent.UI.HospitalSvcRef; using System.Linq; namespace CLIP.eForm.Consent.UI { /// /// 동의서 조회 컨트롤의 환자 정보 탭 클래스 /// /// ///

[설계자]

///

클립소프트 연구소 홍지철 (jchong@clipsoft.co.kr)

///

[원본 작성자]

///

클립소프트 기술부 이창훈 (chlee@clipsoft.co.kr)

///

[수정 작성자]

///

클립소프트 기술부 이인희

///

----------------------------------------------------------------------------------------

///

[HISTORY]

///

2016-06-21 : 최초작성

///

----------------------------------------------------------------------------------------

///
public partial class PatientInfoCtrl : PatientInfoCtrlBase { private HospitalSvcRef.HospitalSvcSoapClient hospitalWebService = null; IConsentMain consentMain = null; ConsentCommandCtrl commandControl = null; public PatientInfoCtrl() { InitializeComponent(); } public void SetPatientInfo() { if (consentMain == null) consentMain = ConsentMainControl.GetConsentMainInterface(this); SetPatientBasicInfo(consentMain); SetClnDateItem(); } private void PatientInfoCtrl_Load(object sender, EventArgs e) { if (this.DesignMode || LicenseManager.UsageMode == LicenseUsageMode.Designtime) { return; } consentMain = ConsentMainControl.GetConsentMainInterface(this); commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl; consentMain.OnLoadPartControls += ConsentMain_OnLoadPartControls; hospitalWebService = WebMethodCommon.GetHospitalWebService(consentMain.PluginExecuteInfo["hospitalSvcUrl"]); } private void ConsentMain_OnLoadPartControls(object sender, EventArgs e) { if (consentMain == null) consentMain = ConsentMainControl.GetConsentMainInterface(this); if (commandControl == null) commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl; try { SetEndUser(consentMain); SetPatientBasicInfo(consentMain); SetClnDateItem(); if (comboTrmtPrd.Items.Count > 0) comboTrmtPrd.SelectedIndex = 0; // 로딩 될 때 발행리스트 탭이 갱신 되어야 한다. consentMain.ConsentListCtrl.consentSelectTabPageAllRefresh(); } catch (UserException uex) { MessageBox.Show(string.Format(uex.Message) , string.Format(Properties.Resources.msg_caption_fail), MessageBoxButtons.OK, MessageBoxIcon.Error); consentMain.TerminateConsentMain(); } } // 작성자 정보 셋팅 private void SetEndUser(IConsentMain consentMain) { if (commandControl == null) commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl; GetUserDetailInfo(consentMain.ConsentExecuteInfo["userId"] , consentMain.ConsentExecuteInfo["dutinstcd"] , consentMain.ConsentExecuteInfo["userDeptCd"] , commandControl); } private void GetUserDetailInfo(string userid, string dutinstcd, string dutplcecd, ConsentCommandCtrl commandControl) { UserVO userVO = (UserVO) this.hospitalWebService.GetUserInfo(userid, dutinstcd, dutplcecd); if (userVO == null) { if (!string.IsNullOrEmpty(consentMain.ConsentExecuteInfo["userDeptCd"])) { // 실행 정보에 있는 사용자 정보 설정 commandControl.CurrentEndUser = new EndUser(); commandControl.CurrentEndUser.userId = this.labelUserNo.Text = consentMain.ConsentExecuteInfo["userId"]; commandControl.CurrentEndUser.userName = this.labelUserNm.Text = consentMain.ConsentExecuteInfo["userName"]; commandControl.CurrentEndUser.Password = ""; commandControl.CurrentEndUser.deptcd = consentMain.ConsentExecuteInfo["userDeptCd"]; commandControl.CurrentEndUser.supportDeptcd = consentMain.ConsentExecuteInfo["userSupportDeptCd"]; commandControl.CurrentEndUser.supportBaseCd = consentMain.ConsentExecuteInfo["supportBaseCd"]; commandControl.CurrentEndUser.depthngnm = this.labelUserDept.Text = consentMain.ConsentExecuteInfo["userDeptName"]; //commandControl.CurrentEndUser.UserGroupCode = ""; commandControl.CurrentEndUser.instcd = consentMain.ConsentExecuteInfo["dutinstcd"]; commandControl.CurrentEndUser.userTelNo = ""; commandControl.CurrentEndUser.jobkindcd = userVO.jobKindCd; commandControl.CurrentEndUser.jobkindnm = userVO.jobKindNm; commandControl.CurrentEndUser.drkind = userVO.drKind; } else { string _msg = string.Format("[{0}] 에 해당하는 의사정보가 없습니다.", userid); MessageBox.Show(_msg); throw new Exception(_msg); } } else { commandControl.CurrentEndUser = new EndUser(); commandControl.CurrentEndUser.userId = this.labelUserNo.Text = userVO.userId; commandControl.CurrentEndUser.userName = this.labelUserNm.Text = userVO.userName; commandControl.CurrentEndUser.deptcd = userVO.userDeptcd; commandControl.CurrentEndUser.supportDeptcd = userVO.userSupportDeptCd; commandControl.CurrentEndUser.supportBaseCd = userVO.userSupportBaseCd; commandControl.CurrentEndUser.depthngnm = this.labelUserDept.Text = userVO.userDepthngnm; //commandControl.CurrentEndUser.UserGroupCode = userVO.UserGroupCode; //commandControl.CurrentEndUser.supportBaseCd = userVO.; commandControl.CurrentEndUser.instcd = consentMain.ConsentExecuteInfo["dutinstcd"]; commandControl.CurrentEndUser.userTelNo = userVO.userTelNo; commandControl.CurrentEndUser.jobkindcd = userVO.jobKindCd; commandControl.CurrentEndUser.jobkindnm = userVO.jobKindNm; commandControl.CurrentEndUser.ioflag = userVO.ioFlag ?? ""; commandControl.CurrentEndUser.drkind = userVO.drKind; consentMain.ConsentExecuteInfo["userIOFlag"] = commandControl.CurrentEndUser.ioflag; } } // 환자 정보 셋팅 private void SetPatientBasicInfo(IConsentMain consentMain) { PatientVO[] patientVOList = this.hospitalWebService.GetPatientInfo(consentMain.ConsentExecuteInfo["patientId"] , consentMain.ConsentExecuteInfo["patientClnDate"] , consentMain.ConsentExecuteInfo["patientOrdtype"] , consentMain.ConsentExecuteInfo["patientClnDept"] , consentMain.ConsentExecuteInfo["cretno"] , consentMain.ConsentExecuteInfo["dutinstcd"] , consentMain.ConsentExecuteInfo["opRsrvNo"]); // 환자 정보가 없는 경우 if (patientVOList == null || patientVOList.Length == 0) { commandControl.CurrentTargetPatient = new TargetPatient(); } else { PatientVO vo = patientVOList[0]; this.labelPtntNm.Text = vo.patientName; this.labelPtntNo.Text = vo.pid; commandControl.CurrentTargetPatient = new TargetPatient(); SetTargetPatientInfo(vo); } } /// /// PatientVO 정보를 이용해서 CurrentTargetPatient 정보 SET /// /// 설정할 PatientVO 클래스의 인스턴스 private void SetTargetPatientInfo(PatientVO vo) { var ordtypeHngnm = ""; if (!string.IsNullOrEmpty(vo.ordType)) { switch (vo.ordType) { case "I": ordtypeHngnm = "입원"; break; case "O": ordtypeHngnm = "외래"; break; case "E": ordtypeHngnm = "응급"; break; case "OP": ordtypeHngnm = "수술"; break; } } // TODO 검증 필요 commandControl.CurrentTargetPatient.instcd = consentMain.ConsentExecuteInfo["dutinstcd"]; commandControl.CurrentTargetPatient.name = vo.patientName; commandControl.CurrentTargetPatient.pid = vo.pid; commandControl.CurrentTargetPatient.sa = vo.sa; commandControl.CurrentTargetPatient.jumin = vo.juminNo; commandControl.CurrentTargetPatient.birthDd = vo.patientBirthDd; commandControl.CurrentTargetPatient.ordtype = vo.ordType; commandControl.CurrentTargetPatient.ordtypeHngnm = ordtypeHngnm; commandControl.CurrentTargetPatient.cretno = vo.cretNo.ToString(); commandControl.CurrentTargetPatient.Dschdd = vo.dSchDd.Replace("-", "").Replace("/", ""); commandControl.CurrentTargetPatient.clnDate = vo.inDd.Replace("-", "").Replace("/", ""); commandControl.CurrentTargetPatient.clnDeptEngNm = vo.deptEngNm; commandControl.CurrentTargetPatient.clnDeptCode = vo.ordDeptCd; commandControl.CurrentTargetPatient.clnDeptName = vo.deptNm; commandControl.CurrentTargetPatient.clnDxNm = vo.diagHngNm; commandControl.CurrentTargetPatient.mainDrId = vo.mainDrId; commandControl.CurrentTargetPatient.mainDrNm = vo.mainDrNm; commandControl.CurrentTargetPatient.ward = vo.ward; commandControl.CurrentTargetPatient.roomno = vo.roomCd; //commandControl.CurrentTargetPatient.orderno = vo.IO_OrderNo; commandControl.CurrentTargetPatient.opDrId = vo.opDoctorId; commandControl.CurrentTargetPatient.opDrNm = vo.opDoctorNm; commandControl.CurrentTargetPatient.opDeptCd = vo.opDeptCd; commandControl.CurrentTargetPatient.opDeptNm = vo.opDeptNm; commandControl.CurrentTargetPatient.addr = vo.patientAddr; commandControl.CurrentTargetPatient.telno = vo.patientMobileNo; //commandControl.CurrentTargetPatient.Insukind = vo.IO_Insukind; // 수술 정보 commandControl.CurrentTargetPatient.OpRsrvNo = vo.opRsrvNo; commandControl.CurrentTargetPatient.OpCnfmDate = vo.opCnFmDd; commandControl.CurrentTargetPatient.OpName = vo.opNm; commandControl.CurrentTargetPatient.OpremFact = vo.opremFact; /// TODO 필요시 구현 구현 //commandControl.CurrentTargetPatient.OpDiagName = vo.OpDiagName; //commandControl.CurrentTargetPatient.OpName = vo.OpName; //commandControl.CurrentTargetPatient.AnstDrName1 = vo.AnstDrName1; //commandControl.CurrentTargetPatient.AnstDrFlag1 = vo.AnstDrFlag1; //commandControl.CurrentTargetPatient.AnstDeptName1 = vo.AnstDeptName1; //commandControl.CurrentTargetPatient.AnstDrName2 = vo.AnstDrName2; //commandControl.CurrentTargetPatient.AnstDrFlag2 = vo.AnstDrFlag2; //commandControl.CurrentTargetPatient.AnstDeptName2 = vo.AnstDeptName2; //commandControl.CurrentTargetPatient.AnstDrName3 = vo.AnstDrName3; //commandControl.CurrentTargetPatient.AnstDrFlag3 = vo.AnstDrFlag3; //commandControl.CurrentTargetPatient.AnstDeptName3 = vo.AnstDeptName3; } /// /// 진료일 범위 설정 /// private void SetClnDateItem() { Dictionary comboItems = new Dictionary(); comboItems.Add(" - ", ""); // 환자 선택 시 수진 이력이 자동으로 갱신되게끔 변경 // 수진 이력 기간 조회 시 현재 일자가 아니라 선택된 진료일, 혹은 입원일을 기준으로 기간이 설정되게끔 수정 if (commandControl.CurrentTargetPatient != null && !string.IsNullOrEmpty(commandControl.CurrentTargetPatient.clnDate)) { for (int i = 1; i < 4; i++) { comboItems.Add(i.ToString() + "개월", commandControl.CurrentTargetPatient.clnDate); } } else { for (int i = 1; i < 4; i++) { comboItems.Add(i.ToString() + "개월", DateTime.Now.AddMonths(-i).ToShortDateString().Replace("-", "")); } } comboTrmtPrd.DataSource = new BindingSource(comboItems, null); comboTrmtPrd.DisplayMember = "Key"; comboTrmtPrd.ValueMember = "Value"; } /// /// 진료일 범위 선택했을때, 해당하는 진료일 조회하여 바인딩 /// /// The source of the event. /// The instance containing the event data. private void comboTrmtPrd_SelectedIndexChanged(object sender, EventArgs e) { Dictionary comboItems = new Dictionary(); if (comboTrmtPrd.SelectedIndex == 0) { //초기 넘겨준 특정 진료일을 바인딩 comboItems = GetClnDateSearchList(commandControl.CurrentTargetPatient.pid , commandControl.CurrentTargetPatient.clnDate , "=" , commandControl.CurrentTargetPatient.clnDeptCode); } else { //진료일 범위에 해당하는 진료일자 조회하여 바인딩 comboItems = GetClnDateSearchList(commandControl.CurrentTargetPatient.pid , comboTrmtPrd.SelectedValue.ToString() , ">=" , commandControl.CurrentTargetPatient.clnDeptCode); } if (comboItems.Count > 0) { comboTrmtDate.DataSource = new BindingSource(comboItems, null); comboTrmtDate.DisplayMember = "Key"; comboTrmtDate.ValueMember = "Value"; comboTrmtDate.Tag = consentMain.ConsentExecuteInfo["patientId"]; if (comboTrmtDate.Items.Count > 0) { if (comboTrmtDate.SelectedIndex == 0) { } //GetTrmtInfo(); else comboTrmtDate.SelectedIndex = 0; } } else { comboTrmtDate.DataSource = null; } } /// /// 검색된 진료일 값을 컨트롤에 바인딩 /// /// 환자번호 /// 진료일자 /// 검색일자 /// 진단부서 /// private Dictionary GetClnDateSearchList(string patientNo, string clnDate, string searchType, string orddeptcd) { Dictionary comboDates = new Dictionary(); // 환자의 주진단 정보를 조회 ClnDateForDropdownVO[] clnDateList = this.hospitalWebService.GetTrmtDateList(patientNo , clnDate , searchType , orddeptcd , consentMain.ConsentExecuteInfo["dutinstcd"] , consentMain.ConsentExecuteInfo["patientOrdtype"]); if (clnDateList != null && clnDateList.Length > 0) { foreach (ClnDateForDropdownVO vDate in clnDateList) { comboDates.Add(string.Format("{0} / {1} / {2} / {3} / {4}", vDate.VisitTypeName, vDate.ClnFormatDate, vDate.ClnDeptName, vDate.orddrid, vDate.CretNo), string.Format("{0} / {1} / {2} / {3} / {4}", vDate.ClnDate, vDate.VisitType, vDate.ClnDeptCode, vDate.CretNo, vDate.DeptCd)); } } return comboDates; } private void comboTrmtDate_SelectedIndexChanged(object sender, EventArgs e) { GetTrmtInfo(); } /// /// 환자 선택시 수진일자별 진단 데이터 조회하여 환자명과 내원번호를 설정하고 /// 현재 선택된 한자로 설정한다 /// /// private void GetTrmtInfo() { //수진일자를 변경했을때 환자의 주진단 정보를 재조회한다. if (commandControl.CurrentTargetPatient != null && comboTrmtDate.SelectedItem != null) { string[] clnDate = ((KeyValuePair) comboTrmtDate.SelectedItem).Value.Split('/'); if (clnDate != null && clnDate.Length == 5) { // 환자 선택시 수진일자별 진단 데이터 조회 PatientVO[] patientVOList = this.hospitalWebService.GetPatientInfo(consentMain.ConsentExecuteInfo["patientId"] , clnDate[0].Trim() , clnDate[1].Trim() , clnDate[4].Trim() , clnDate[3].Trim() , this.consentMain.ConsentExecuteInfo["dutinstcd"] , this.consentMain.ConsentExecuteInfo["opRsrvNo"]); if (patientVOList == null || patientVOList.Length == 0) { throw new UserException(string.Format(Properties.Resources.msg_error_get_patient , consentMain.ConsentExecuteInfo["patientId"])); } else { PatientVO vo = patientVOList[0]; // 환자명과 내원번호 설정 this.labelPtntNm.Text = vo.patientName; this.labelPtntNo.Text = vo.pid; //현재 선택된 환자로 설정 commandControl.CurrentTargetPatient = new TargetPatient(); SetTargetPatientInfo(vo); } } } } /// /// 환자목록에서 더블클릭했을 경우, 선택된 환자 정보로 상단정보를 재조회한다. /// /// 방문 타입 public override void OnRefeashPartControls(string visitType) { if (consentMain == null) consentMain = ConsentMainControl.GetConsentMainInterface(this); if (commandControl == null) commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl; try { SetEndUser(consentMain); SetPatientBasicInfo(consentMain); SetClnDateItem(); if (comboTrmtPrd.SelectedIndex > 0) { comboTrmtPrd.SelectedIndex = 0; } else { comboTrmtPrd_SelectedIndexChanged(null, null); } } catch (UserException uex) { MessageBox.Show(string.Format(uex.Message) , string.Format(Properties.Resources.msg_caption_fail), MessageBoxButtons.OK, MessageBoxIcon.Error); consentMain.TerminateConsentMain(); } } /// /// 동의서명을 설정 /// /// Name of the document. public override void SetConsentDocumentName(string documentName) { this.labelDocName.Text = documentName; } /// /// 작성자 정보를 설정 /// /// The userid. /// The dutinstcd. /// The dutplcecd. public override void SetConsentUserInfo(string userid, string dutinstcd, string dutplcecd) { ConsentCommandCtrl commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl; GetUserDetailInfo(userid, dutinstcd, dutplcecd, commandControl); } /// /// 상단의 진료일과 작성자 정보로 설정 (수진일자를 변경했을때 환자의 주진단 정보를 재조회한다.) /// /// public override void SetBasicPatientInfo() { if (commandControl.CurrentTargetPatient != null && comboTrmtDate.SelectedValue != null) { string[] clnDate = ((KeyValuePair) comboTrmtDate.SelectedItem).Value.Split('/'); if (clnDate != null && clnDate.Length == 4) { PatientVO[] patientVOList = this.hospitalWebService.GetPatientInfo(consentMain.ConsentExecuteInfo["patientId"] , clnDate[0].Trim() , clnDate[1].Trim() , clnDate[2].Trim() , clnDate[3].Trim() , consentMain.ConsentExecuteInfo["dutinstcd"] , consentMain.ConsentExecuteInfo["opRsrvNo"]); if (patientVOList == null || patientVOList.Length == 0) { throw new UserException(string.Format(Properties.Resources.msg_error_get_patient , consentMain.ConsentExecuteInfo["patientId"])); } else { PatientVO vo = patientVOList[0]; commandControl.CurrentTargetPatient = new TargetPatient(); SetTargetPatientInfo(vo); } } } } /// /// 동의서 정보로 환자 주진단 정보 설정 (ConsentVO 데이터로 PatientVO 조회) /// /// The order date. /// Type of the order. /// The order dept cd. /// The cretno. /// public override void SetPatientByConsentInfo(string orderDate, string orderType, string orderDeptCd, string cretno) { PatientVO[] patientVOList = this.hospitalWebService.GetPatientInfo(commandControl.CurrentTargetPatient.pid , orderDate.Replace("-", "") , orderType , orderDeptCd , cretno , this.consentMain.ConsentExecuteInfo["dutinstcd"] , this.consentMain.ConsentExecuteInfo["opRsrvNo"]); if (patientVOList == null || patientVOList.Length == 0) { throw new UserException(string.Format(Properties.Resources.msg_error_get_patient , consentMain.ConsentExecuteInfo["patientId"])); } else { PatientVO vo = patientVOList[0]; commandControl.CurrentTargetPatient = new TargetPatient(); SetTargetPatientInfo(vo); } } } }