#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.Dfh.UI.HospitalSvcRef; namespace CLIP.eForm.Consent.Dfh.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(); } 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; } 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; if (consentMain.ConsentExecuteInfo.ContainsKey("userNo")) { GetUserDetailInfo(consentMain.ConsentExecuteInfo["userNo"], commandControl); } else { throw new UserException(Properties.Resources.msg_error_user_args); } } private void GetUserDetailInfo(string userNo, ConsentCommandCtrl commandControl) { UserVO userVO = (UserVO)this.hospitalWebService.GetUserInfo(userNo); if (userVO == null) { //if (userNo.Substring(0,4).Equals("5000")) //{ // MessageBox.Show("일반의사는 출력만 가능합니다."); // commandControl.CurrentEndUser = new EndUser(); // commandControl.CurrentEndUser.UserName = this.labelUserNm.Text = "일반의사"; // commandControl.CurrentEndUser.UserNo = this.labelUserNo.Text = userNo; // commandControl.CurrentEndUser.DeptCode = ""; // commandControl.CurrentEndUser.DeptName = this.labelUserDept.Text = ""; //} //else //{ throw new UserException(string.Format(Properties.Resources.msg_error_get_user, userNo)); //} } else { if (userNo.Substring(0, 4).Equals("5000")) { MessageBox.Show("일반의사는 출력만 가능합니다."); } commandControl.CurrentEndUser = new EndUser(); commandControl.CurrentEndUser.UserNo = this.labelUserNo.Text = userVO.UserNo; commandControl.CurrentEndUser.UserName = this.labelUserNm.Text = userVO.UserName; commandControl.CurrentEndUser.Password = userVO.UserPassword; commandControl.CurrentEndUser.DeptCode = userVO.UserDeptCode; commandControl.CurrentEndUser.DeptName = this.labelUserDept.Text = userVO.UserDeptName; commandControl.CurrentEndUser.UserGroupCode = userVO.UserGroupCode; commandControl.CurrentEndUser.HosType = userVO.HosType; if(!consentMain.ConsentExecuteInfo.ContainsKey("loginUserName")) { consentMain.ConsentExecuteInfo["loginUserName"] = commandControl.CurrentEndUser.UserName; } if(consentMain.ConsentExecuteInfo.ContainsKey("loginUserNo") && consentMain.ConsentExecuteInfo["loginUserNo"].Equals(commandControl.CurrentEndUser.UserNo)) { consentMain.ConsentExecuteInfo["loginUserName"] = commandControl.CurrentEndUser.UserName; } } } // 환자 정보 셋팅 private void SetPatientBasicInfo(IConsentMain consentMain) { if (consentMain.ConsentExecuteInfo.ContainsKey("patientNo") && consentMain.ConsentExecuteInfo.ContainsKey("clnDate") && consentMain.ConsentExecuteInfo.ContainsKey("visitType") && consentMain.ConsentExecuteInfo.ContainsKey("clnDept") && consentMain.ConsentExecuteInfo.ContainsKey("cretno")) { PatientVO[] patientVOList = this.hospitalWebService.GetPatientInfo( consentMain.ConsentExecuteInfo["patientNo"], consentMain.ConsentExecuteInfo["clnDate"], consentMain.ConsentExecuteInfo["visitType"], consentMain.ConsentExecuteInfo["clnDept"], consentMain.ConsentExecuteInfo["cretno"] ); if (patientVOList == null || patientVOList.Length == 0) { //throw new UserException(string.Format(Properties.Resources.msg_error_get_patient // , consentMain.ConsentExecuteInfo["patientNo"])); //환자정보 없이 프로그램을 실행해야 하는 경우가 있음. commandControl.CurrentTargetPatient = new TargetPatient(); if (commandControl != null && commandControl.CurrentEndUser != null) { commandControl.CurrentTargetPatient.HosType = commandControl.CurrentEndUser.HosType; } } else { PatientVO vo = patientVOList[0]; this.labelPtntNm.Text = vo.IO_Pt_Name; this.labelPtntNo.Text = vo.IO_Pt_ID; commandControl.CurrentTargetPatient = new TargetPatient(); if (commandControl != null && commandControl.CurrentEndUser != null) { commandControl.CurrentTargetPatient.HosType = commandControl.CurrentEndUser.HosType; } SetTargetPatientInfo(vo); } } else { throw new UserException(Properties.Resources.msg_error_patient_args); } } //PatientVO 정보를 이용해서 CurrentTargetPatient 정보 SET private void SetTargetPatientInfo(PatientVO vo) { commandControl.CurrentTargetPatient.PatientName = vo.IO_Pt_Name; commandControl.CurrentTargetPatient.PatientCode = vo.IO_Pt_ID; commandControl.CurrentTargetPatient.PatientSexAge = vo.IO_sex_age_y_m; commandControl.CurrentTargetPatient.PatientJuminNo = vo.IO_JuminNo; commandControl.CurrentTargetPatient.VisitType = vo.IO_VisitType; commandControl.CurrentTargetPatient.cretno = vo.IO_CretNo; commandControl.CurrentTargetPatient.Dschdd = vo.IO_Dschdd.Replace("-",""); commandControl.CurrentTargetPatient.clnDate = vo.IO_ADdate; commandControl.CurrentTargetPatient.clnDeptCode = vo.IO_DeptCd; commandControl.CurrentTargetPatient.clnDeptName = vo.IO_DeptNm; commandControl.CurrentTargetPatient.clnDeptNameKO = vo.IO_Dept2; commandControl.CurrentTargetPatient.clnDxCd = vo.IO_DxCd; commandControl.CurrentTargetPatient.clnDxNm = vo.IO_DxNm; commandControl.CurrentTargetPatient.MainDrId = vo.IO_MaindrId; commandControl.CurrentTargetPatient.MainDrNm = vo.IO_MaindrNm; commandControl.CurrentTargetPatient.Ward = vo.IO_Ward; commandControl.CurrentTargetPatient.RoomNo = vo.IO_RoomNo; commandControl.CurrentTargetPatient.OrderNo = vo.IO_OrderNo; commandControl.CurrentTargetPatient.OPdrId = vo.IO_OPdrId; commandControl.CurrentTargetPatient.OPdrNm = vo.IO_OPdrNm; commandControl.CurrentTargetPatient.OPdeptCode = vo.IO_OPdeptCd; commandControl.CurrentTargetPatient.OPdeptName = vo.IO_OPdeptNm; commandControl.CurrentTargetPatient.PatientAddr = vo.IO_Zipcdaddr; commandControl.CurrentTargetPatient.PatientTelNo = vo.IO_Tel; commandControl.CurrentTargetPatient.Insukind = vo.IO_Insukind; commandControl.CurrentTargetPatient.Ex_bp = vo.IO_bp; commandControl.CurrentTargetPatient.Ex_dm = vo.IO_dm; commandControl.CurrentTargetPatient.Ex_heart = vo.IO_heart; commandControl.CurrentTargetPatient.Ex_kidney = vo.IO_kidney; commandControl.CurrentTargetPatient.Ex_respiration = vo.IO_respiration; commandControl.CurrentTargetPatient.Ex_hx = vo.IO_hx; commandControl.CurrentTargetPatient.Ex_allergy = vo.IO_allergy; commandControl.CurrentTargetPatient.Ex_drug = vo.IO_drug; commandControl.CurrentTargetPatient.Ex_smoking = vo.IO_smoking; commandControl.CurrentTargetPatient.Ex_idio = vo.IO_idio; commandControl.CurrentTargetPatient.Ex_nacrotics = vo.IO_nacrotics; commandControl.CurrentTargetPatient.Ex_airway = vo.IO_airway; commandControl.CurrentTargetPatient.Ex_hemorrhage = vo.IO_hemorrhage; commandControl.CurrentTargetPatient.Ex_status_etc = vo.IO_status_etc; } // 진료일 범위 설정 private void SetClnDateItem() { Dictionary comboItems = new Dictionary(); comboItems.Add(" - ", ""); 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"; } // 진료일 범위 선택했을때, 해당하는 진료일 조회하여 바인딩 private void comboTrmtPrd_SelectedIndexChanged(object sender, EventArgs e) { Dictionary comboItems = new Dictionary(); if (comboTrmtPrd.SelectedIndex == 0 && consentMain.ConsentExecuteInfo.ContainsKey("clnDate")) { //초기 넘겨준 특정 진료일을 바인딩 comboItems = GetClnDateSearchList(consentMain.ConsentExecuteInfo["patientNo"], consentMain.ConsentExecuteInfo["clnDate"], "=", consentMain.ConsentExecuteInfo["clnDept"]);//consentMain.ConsentExecuteInfo.ContainsKey("clnDate") } else { //진료일 범위에 해당하는 진료일자 조회하여 바인딩 comboItems = GetClnDateSearchList(consentMain.ConsentExecuteInfo["patientNo"], comboTrmtPrd.SelectedValue.ToString(), ">=", consentMain.ConsentExecuteInfo["clnDept"]); } if (comboItems.Count > 0) { comboTrmtDate.DataSource = new BindingSource(comboItems, null); comboTrmtDate.DisplayMember = "Key"; comboTrmtDate.ValueMember = "Value"; comboTrmtDate.Tag = consentMain.ConsentExecuteInfo["patientNo"]; 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); 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["patientNo"], clnDate[0].Trim(), clnDate[1].Trim(), clnDate[4].Trim(), clnDate[3].Trim() ); if (patientVOList == null || patientVOList.Length == 0) { throw new UserException(string.Format(Properties.Resources.msg_error_get_patient , consentMain.ConsentExecuteInfo["patientNo"])); } else { PatientVO vo = patientVOList[0]; this.labelPtntNm.Text = vo.IO_Pt_Name; this.labelPtntNo.Text = vo.IO_Pt_ID; commandControl.CurrentTargetPatient = new TargetPatient(); if (commandControl != null && commandControl.CurrentEndUser != null) { commandControl.CurrentTargetPatient.HosType = commandControl.CurrentEndUser.HosType; } 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(!(comboTrmtDate!= null && comboTrmtDate.Tag != null && !string.IsNullOrEmpty(comboTrmtDate.Tag.ToString()) && comboTrmtDate.Tag.Equals(consentMain.ConsentExecuteInfo["patientNo"]))) { 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(); } } // 동의서명을 설정 public override void SetConsentDocumentName(string documentName) { this.labelDocName.Text = documentName; } // 작성자 정보를 설정 public override void SetConsentUserInfo(string userNo) { ConsentCommandCtrl commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl; GetUserDetailInfo(userNo, 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["patientNo"], clnDate[0].Trim(), clnDate[1].Trim(), clnDate[2].Trim(), clnDate[3].Trim() ); if (patientVOList == null || patientVOList.Length == 0) { throw new UserException(string.Format(Properties.Resources.msg_error_get_patient , consentMain.ConsentExecuteInfo["patientNo"])); } else { PatientVO vo = patientVOList[0]; commandControl.CurrentTargetPatient = new TargetPatient(); SetTargetPatientInfo(vo); } } } } //동의서 정보로 환자 주진단 정보 설정 (ConsentVO 데이터로 PatientVO 조회) public override void SetPatientByConsentInfo(string orderDate, string orderType, string orderDeptCd, string cretno) { PatientVO[] patientVOList = this.hospitalWebService.GetPatientInfo(commandControl.CurrentTargetPatient.PatientCode, orderDate.Replace("-", ""), orderType, orderDeptCd, cretno ); if (patientVOList == null || patientVOList.Length == 0) { throw new UserException(string.Format(Properties.Resources.msg_error_get_patient , consentMain.ConsentExecuteInfo["patientNo"])); } else { PatientVO vo = patientVOList[0]; commandControl.CurrentTargetPatient = new TargetPatient(); SetTargetPatientInfo(vo); } } } }