using System; using System.Collections.Generic; using System.Windows.Forms; using CLIP.eForm.Consent.Common; using System.Reflection; using System.Threading; using System.Xml; using System.IO; using System.ComponentModel; using System.Configuration; using System.Drawing; using CLIP.eForm.Consent.UI.ConsentSvcRef; using ClipSoft.eForm.Base.Dialog; namespace CLIP.eForm.Consent.UI { /// /// 동의서 관리 메인 컨트롤 클래스 /// /// ///

[설계자]

///

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

///

[원본 작성자]

///

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

///

[수정 작성자]

///

클립소프트 기술부 이인희

///

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

///

[HISTORY]

///

2015-07-30 : 최초작성

///

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

///
public partial class ConsentMainControl : UserControl, IConsentMainCtrl, IConsentMain { // 사용되지 않음 //private string currentFormGuid = string.Empty; private ConsentSvcRef.ConsentSvcSoapClient consentWebService; private HospitalSvcRef.HospitalSvcSoapClient hospitalWebService; [Browsable(false)] public ConsentSvcRef.ConsentSvcSoapClient ConsentWebService { get { return consentWebService; } } [Browsable(false)] public HospitalSvcRef.HospitalSvcSoapClient HospitalWebService { get { return hospitalWebService; } } public string PluginModuleName { get; set; } private Dictionary outputDataDic = null; private Dictionary processResultValues = new Dictionary(); public Dictionary ConsentExecuteInfo { get; set; } public Dictionary PluginExecuteInfo { get; set; } public Dictionary ProcessResultValues { get { return processResultValues; } } public List PrintInfoList { get; set; } public event EventHandler OnLoadPartControls; public event EventHandler OnResizeReviewConsent; public event EventHandler OnVisibleEFormControl; public event EventHandler OnInvisibleEFormControl; public event ProcessResultHandler ProcessResult; public delegate void ProcessResultHandler(string result); public object mCallParm = null; private static bool startform = true; public bool printSaveStatus { get; set; } public int multiPrintPlanCnt { get; set; } public int multiPrintExecCnt { get; set; } public bool saveClickPoint { get; set; } // true : 메인창, false : 듀얼뷰어창 public bool checkAutoPrint { get; set; } // true : 입실저장 자동출력, false : 수동출력 public int agentCallPrintCnt { get; set; } public int printConsentCount = 1; // 원무 서식 인증서 pass 여부 // 경북대병원 dependency public bool shouldPassCertify = false; /// /// Gets or sets the call parameter. /// /// /// The call parameter. /// object IConsentMainCtrl.CallParam { get { return mCallParm; } set { mCallParm = value; } } /// /// 세션을 체크하기 위한 내부 클래스 /// private class MessageFilterClass : IMessageFilter { const int WM_KEYDOWN = 0x100; // 키보드 입력 const int WM_LBUTTONDOWN = 0x0201; // 마우스 입력 private DateTime lastInput; private int sesstionTimeout; /// /// 생성자, 반드시 이 생성자를 사용 할 것 /// /// 현재 시간 /// 세션 타임아웃 public MessageFilterClass(DateTime now, string sessionTimeout) { this.lastInput = now; this.sesstionTimeout = Convert.ToInt32(sessionTimeout); } bool checkUseTime(DateTime current) { bool needToLogOut = false; // 현재시간과 마지막입력시간의 차를 구한다 TimeSpan delta = current.Subtract(lastInput); // 세션시간 이상일 경우 if(delta.Minutes >= this.sesstionTimeout) { needToLogOut = true; } else { lastInput = current; } return needToLogOut; } bool IMessageFilter.PreFilterMessage(ref Message m) { bool logout = false; switch (m.Msg) { case WM_LBUTTONDOWN: case WM_KEYDOWN: logout = checkUseTime(DateTime.Now); break; } if (logout) { SessionLogout(); } // 이벤트를 전달하기 위해서는 false 로 리턴 return false; } } /// /// 세선 타임아웃일 경우 로그아웃을 하기 위한 static 메서드 /// private static void SessionLogout() { System.Diagnostics.Process[] processes = System.Diagnostics.Process.GetProcessesByName("CLIP.e-Form.Consent.WinAgent"); if(processes.Length > 0) { MessageBox.Show("사용시간이 만료되어 종료합니다."); processes[0].Kill(); } } /// /// Initializes a new instance of the class. /// /// The call parameter. public ConsentMainControl(object callParam) { InitializeComponent(); ToolTip _toolTip = new ToolTip(); _toolTip.AutoPopDelay = 5000; _toolTip.InitialDelay = 0; _toolTip.ReshowDelay = 0; _toolTip.ShowAlways = true; // 도움말 버튼 비활성화 //_toolTip.SetToolTip(this.btnHelp, "도움말"); //MessageBox.Show("waiting for debugging..."); // 실행 정보 데이터셋 초기화 ConsentExecuteInfo = new Dictionary { { "dutinstcd", string.Empty }, // 기관코드 { "userId", string.Empty }, { "userName", string.Empty }, { "loginUserId", string.Empty }, { "loginUserName", string.Empty }, { "userDeptCd", string.Empty }, { "userDeptName", string.Empty }, { "userSupportDeptCd", string.Empty }, { "userSupportBaseCd", string.Empty }, { "patientId", string.Empty }, { "patientOrdtype", string.Empty }, { "patientClnDept", string.Empty }, { "patientClnDate", string.Empty }, { "patientClnDxNm", string.Empty }, // 진단명 { "cretno", string.Empty }, { "opRsrvNo", string.Empty }, { "enablePatientList", string.Empty }, // 우측 환자 목록 뷰 활성화 여부 { "enableConsentList", string.Empty }, // 좌측 동의서 목록 뷰 활성화 여부 { "targetService", string.Empty }, // 대상 서비스 명(eg, DEV, REAL) // { "startFormCd", string.Empty }, // { "printList", string.Empty }, // 다중 출력 목록 { "formCd", string.Empty }, { "ocrCd", string.Empty }, // { "tempSave", string.Empty }, { "printYN", string.Empty }, { "printCount", string.Empty }, { "printIP", string.Empty }, { "prntCnt", string.Empty }, { "userIOFlag", "O" }, // 사용자 탭 설정 // { "readOnly", string.Empty }, { "SpecDoctorYN", string.Empty }, { "ContStartDate", string.Empty }, // 약정 시작일 { "ContEndDate", string.Empty }, // 약정 종료일 { "RoomCapa", string.Empty }, // 병실 정원 { "ContTelNo", string.Empty }, // ContStartDate { "ContStaff1Name", string.Empty }, // 원무 담당자 { "ContStaff2Name", string.Empty }, // 원무 팀장 { "ContStaff3Name", string.Empty }, // 원무 과장 { "CardNo", string.Empty } // 카드 번호 //{ "dutinstcd", string.Empty }, //{ "userNo", string.Empty }, //{ "loginUserNo", string.Empty }, //{ "userName", string.Empty }, //{ "loginUserName", string.Empty }, //{ "userDeptCd", string.Empty }, //{ "userDeptName", string.Empty }, //{ "patientNo", string.Empty }, //{ "visitType", string.Empty }, //{ "clnDept", string.Empty }, //{ "clnDate", string.Empty }, //{ "cretno", string.Empty }, //{ "clnDxNm", string.Empty }, //{ "opRsrvNo", string.Empty }, //{ "useListView", string.Empty }, //{ "patientListView", string.Empty }, //{ "startFormCd", string.Empty }, //{ "printAct", string.Empty }, //{ "printList", string.Empty }, //{ "formCd", string.Empty }, //{ "ocrTag", string.Empty }, //{ "tempSave", string.Empty }, //{ "printYN", string.Empty }, //{ "printCount", string.Empty }, //{ "printIP", string.Empty }, //{ "prntCnt", string.Empty }, //{ "userIOFlag", "O" }, //{ "sysInstNm", string.Empty }, //{ "readOnly", string.Empty }, //{ "SpecDoctorYN", string.Empty }, //{ "ContStartDate", string.Empty }, //{ "ContEndDate", string.Empty }, //{ "RoomCapa", string.Empty }, //{ "ContTelNo", string.Empty }, //{ "ContStaff1Name", string.Empty }, //{ "ContStaff2Name", string.Empty }, //{ "ContStaff3Name", string.Empty }, //{ "CardNo", string.Empty } }; PluginExecuteInfo = new Dictionary(); // 넘겨받은 callParam 를 디코딩 한다 InitParamSetting(callParam); SetWebServiceUrlAndTimeout(); string sessionTimeout = "30"; if (hospitalWebService != null) { // 세션 타임아웃을 가져온다 sessionTimeout = hospitalWebService.getSessionTime("101"); } string userId = ConsentExecuteInfo["userId"]; hospitalWebService.userLoginOutLog(userId, "LOGIN", "PC", Common.getMacAddress()); MessageFilterClass messageFilter = new MessageFilterClass(DateTime.Now, sessionTimeout); Application.AddMessageFilter(messageFilter); this.PluginModuleName = ConfigurationManager.AppSettings["UIPluginAssembly"]; } /// /// Gets a value indicating whether this instance has vertical monitor. /// /// /// true if this instance has vertical monitor; otherwise, false. /// public static bool HasMultipleMonitor { get { if (Screen.AllScreens.Length > 1) { return true; } return false; } } /// /// 주어진 서버 이름으로 설정파일을 로딩 한다 /// /// 로드 할 서버 설정 파일 /// public static Dictionary GetConfigDictionary(string pServerName) { Dictionary result = new Dictionary(); /* XmlDocument configXml = new XmlDocument(); configXml.Load(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + string.Format("/CLIP.Consent.xml")); XmlNodeList addNodes = configXml.SelectNodes("configuration/settings/add"); foreach (XmlNode xmlNode in addNodes) { if (xmlNode.Attributes["key"].InnerText == "serviceTarget") { serviceTarget = ((XmlCDataSection)xmlNode.ChildNodes[0]).InnerText; } } */ XmlDocument configXml = new XmlDocument(); configXml.Load(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + string.Format("/CLIP.Consent-{0}.xml", pServerName)); XmlNodeList addNodes = configXml.SelectNodes("configuration/settings/add"); foreach (XmlNode xmlNode in addNodes) { result.Add(xmlNode.Attributes["key"].InnerText, ((XmlCDataSection) xmlNode.ChildNodes[0]).InnerText); } return result; } /// /// childControl의 부모와 그의 부모들에서 IConsentMain 인터페이스를 구현하는 클래스를 찾는다. /// /// /// public static IConsentMain GetConsentMainInterface(Control childControl) { if (childControl.Parent == null) { return null; } else { if (childControl.Parent is IConsentMain) { return childControl.Parent as IConsentMain; } else { return GetConsentMainInterface(childControl.Parent); } } } /// /// Sets the web service URL and timeout. /// private void SetWebServiceUrlAndTimeout() { try { Dictionary configDic = GetConfigDictionary(ConsentExecuteInfo["sysInstNm"]); this.PluginExecuteInfo.Add("consentSvcUrl", configDic["consentSvcUrl"]); this.PluginExecuteInfo.Add("hospitalSvcUrl", configDic["hospitalSvcUrl"]); this.PluginExecuteInfo.Add("formServiceUrl", configDic["formServiceUrl"]); this.PluginExecuteInfo.Add("baseConsentSvcURL", configDic["baseConsentSvcURL"]); this.PluginExecuteInfo.Add("imageUploadServerUrl", configDic["imageUploadServerUrl"]); this.PluginExecuteInfo.Add("signatureServerUrl", configDic["signatureServerUrl"]); this.PluginExecuteInfo.Add("signatureServerPort", configDic["signatureServerPort"]); this.PluginExecuteInfo.Add("imageUploadPath", configDic["imageUploadPath"]); this.PluginExecuteInfo.Add("ConsentSearchStartDate", configDic["ConsentSearchStartDate"]); this.PluginExecuteInfo.Add("timeOut", "10"); this.consentWebService = WebMethodCommon.GetConsentWebService(configDic["consentSvcUrl"]); this.hospitalWebService = WebMethodCommon.GetHospitalWebService(configDic["hospitalSvcUrl"]); } catch (Exception ex) { throw ex; } } public ConsentSvcRef.ConsentSvcSoapClient getConsentWebService() { return this.consentWebService; } public HospitalSvcRef.HospitalSvcSoapClient getHospitalWebService() { return this.hospitalWebService; } /// /// Initializes the parameters. /// public void initParams() { InitParamSetting(mCallParm); } /// /// 화면 초기화 시 수행해야 할 이벤트 처리 /// /// protected override void OnLoad(EventArgs e) { try { // 프로그램을 닫으면 Agent 도 종료되게끔 //this.Parent.Disposed += Parent_Disposed; if (string.IsNullOrEmpty(this.PluginModuleName)) { return; } // 사용자 고정 모니터 설정 MoniterViewSetting(false); if (ConsentExecuteInfo["printYN"].Equals("Y")) { this.Parent.Visible = false; } // 기존 인증서 삭제 SignatureConfig sign = new SignatureConfig(); if (!startform) { startform = false; sign.SignAllClear(); } // eFormViewer 컨트롤 초기화 InitEFormControl(); InvokeDelayedLoadEvent(); this.eFormViewerCtrl.GetCurrentViewer().UIUpdateOnDrawing += new Viewer.UIUpdateOnDrawingHandler(ConsentMainControl_UIUpdateOnDrawing); base.OnLoad(e); // dbs227 // TODO 디버그 용 메시지 박스 //Boolean openDualView = (this.consentWebService.getDualViewMode(ConsentExecuteInfo["dutinstcd"], // ConsentExecuteInfo["ipaddr"]) == "Y") ? true : false; //MessageBox.Show("Waiting for debugging at " + ConsentExecuteInfo["ipaddr"]); // 키보드 마우스 입력 이벤트 // Ku2.0 연동 GetConsentListByFormcd(); // 폰트 설치여부 체크 string familyName; string familyList = ""; FontFamily[] fontFamilies; System.Drawing.Text.InstalledFontCollection installedFontCollection = new System.Drawing.Text.InstalledFontCollection(); fontFamilies = installedFontCollection.Families; int count = fontFamilies.Length; int fontCheck = 0; for (int j = 0; j < count; ++j) { familyName = fontFamilies[j].Name; familyList = familyList + familyName; familyList = familyList + ", "; if (fontCheck != 1 && (familyName == "나눔고딕" || familyName == "NanumGothic")) { fontCheck = fontCheck + 1; } if (fontCheck < 100 && (familyName == "나눔고딕 ExtraBold" || familyName == "NanumGothicExtraBold" || familyName == "나눔고딕 아주 굵게")) { fontCheck = fontCheck + 10; } } // 폰트 설치 실행 if (fontCheck < 11) { System.Diagnostics.Process UserProcess = new System.Diagnostics.Process(); UserProcess.StartInfo.UseShellExecute = true; //UserProcess.StartInfo.FileName = "NanumFontSetup.exe"; //UserProcess.StartInfo.WorkingDirectory = Path.GetDirectoryName(Application.StartupPath + "/Font/"); // 폰트가 없어 최초 실행 시 에러 발생 부분 수정 UserProcess.StartInfo.FileName = "FontInstall.exe"; UserProcess.StartInfo.WorkingDirectory = Path.GetDirectoryName(Application.StartupPath + "\\"); UserProcess.StartInfo.CreateNoWindow = true; UserProcess.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; UserProcess.Start(); UserProcess.WaitForExit(); } string sTempPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\Clipsoft\ClipSoft.eForm.Viewer\DataTemp\"; if (Directory.Exists(sTempPath)) { string[] filePaths = Directory.GetFiles(sTempPath); foreach (string fileName in filePaths) { FileInfo fileInfo = new FileInfo(fileName); if (fileInfo.Extension.Equals(".ept") || fileInfo.Extension.Equals(".jpg") || fileInfo.Extension.Equals(".xml")) { fileInfo.Delete(); } } } } catch (Exception ex) { // 데이터베이스 저장 기능 추가로 해당 기능 삭제 //File.WriteAllText(string.Format(@"{0}\eConsentLog\{1}_Agent.txt", Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) // , DateTime.Now.ToString("yyyyMMdd_HHmmss")) // , ex.ToString()); System.Diagnostics.Trace.WriteLine(string.Format("CLIP.eForm error: {0}", ex.Message)); if (this.Parent is System.Windows.Forms.Form) { ((Form) this.Parent).DialogResult = DialogResult.Cancel; ((Form) this.Parent).Close(); } } } // 화면이 종료될때 Agent도 종료되도록 수정 /// /// Handles the Disposed event of the Parent control. /// /// The source of the event. /// The instance containing the event data. private void Parent_Disposed(object sender, EventArgs e) { foreach (Form form in Application.OpenForms) { if (form.Name.Equals("ConsentAgentForm")) { string userId = ConsentExecuteInfo["userId"]; hospitalWebService.userLoginOutLog(userId, "LOGOFF", "PC", Common.getMacAddress()); form.Dispose(); break; } } } // 화면이 종료될때 Agent도 종료되도록 수정 /// /// Parents the disposed. /// public void Parent_Disposed() { foreach (Form form in Application.OpenForms) { if (form.Name.Equals("ConsentAgentForm")) { form.Dispose(); break; } } } /// /// OCX 로 부터 넘겨 받은 파라미터를 decode /// /// EXEC_OPT 로 넘어온 파라미터 목록 /// CallParam 미전달 private void InitParamSetting(object pCallParm) { try { if (pCallParm != null) { Dictionary callParam = pCallParm as Dictionary; if (callParam != null && callParam.Count < 2) { if (callParam["CALL_PARAMS"] != null) { pCallParm = callParam["CALL_PARAMS"] as object; } } foreach (KeyValuePair callKV in pCallParm as Dictionary) { // 사용자 정보 if (callKV.Key != null && !string.IsNullOrEmpty(callKV.Key.ToString()) && callKV.Key.ToString() == "USER_INFO") { foreach (KeyValuePair userKV in callKV.Value as Dictionary) { if (userKV.Key != null && !string.IsNullOrEmpty(userKV.Key.ToString()) && userKV.Key.ToString() == "USER_ID") { if (userKV.Value != null) { ConsentExecuteInfo["userId"] = userKV.Value.ToString(); ConsentExecuteInfo["loginUserId"] = userKV.Value.ToString(); } } else if (userKV.Key != null && !string.IsNullOrEmpty(userKV.Key.ToString()) && userKV.Key.ToString() == "DUTINSTCD") { if (userKV.Value != null) { ConsentExecuteInfo["dutinstcd"] = userKV.Value.ToString(); } } else if (userKV.Key != null && !string.IsNullOrEmpty(userKV.Key.ToString()) && userKV.Key.ToString() == "USER_NAME") { if (userKV.Value != null) { ConsentExecuteInfo["userName"] = userKV.Value.ToString(); ConsentExecuteInfo["loginUserName"] = userKV.Value.ToString(); } } else if (userKV.Key != null && !string.IsNullOrEmpty(userKV.Key.ToString()) && userKV.Key.ToString() == "USER_DEPTCD") { if (userKV.Value != null) { ConsentExecuteInfo["userDeptCd"] = userKV.Value.ToString(); } } else if (userKV.Key != null && !string.IsNullOrEmpty(userKV.Key.ToString()) && userKV.Key.ToString() == "USER_DEPTNM") { if (userKV.Value != null) { ConsentExecuteInfo["userDeptName"] = userKV.Value.ToString(); } } else if (userKV.Key != null && !string.IsNullOrEmpty(userKV.Key.ToString()) && userKV.Key.ToString() == "USER_SUPPORT_DEPT_CD") { if (userKV.Value != null) { ConsentExecuteInfo["userSupportDeptCd"] = userKV.Value.ToString(); } } else if (userKV.Key != null && !string.IsNullOrEmpty(userKV.Key.ToString()) && userKV.Key.ToString() == "USER_SUPPORT_BASE_CD") { if (userKV.Value != null) { ConsentExecuteInfo["userSupportBaseCd"] = userKV.Value.ToString(); } } // } } // 환자 정보 if (callKV.Key != null && !string.IsNullOrEmpty(callKV.Key.ToString()) && callKV.Key.ToString() == "PATIENT_INFO") { foreach (KeyValuePair patientKV in callKV.Value as Dictionary) { if (patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "PATIENT_ID") { if (patientKV.Value != null) ConsentExecuteInfo["patientId"] = patientKV.Value.ToString(); } if (patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "PATIENT_ORDTYPE") { if (patientKV.Value != null) ConsentExecuteInfo["patientOrdtype"] = patientKV.Value.ToString(); } if (patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "PATIENT_CLN_DEPT") { if (patientKV.Value != null) ConsentExecuteInfo["patientClnDept"] = patientKV.Value.ToString(); } if (patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "PATIENT_CLN_DATE") { if (patientKV.Value != null) ConsentExecuteInfo["patientClnDate"] = patientKV.Value.ToString(); } if (patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "CRETNO") { if (patientKV.Value != null) ConsentExecuteInfo["cretno"] = patientKV.Value.ToString(); } // 진단명 if (patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "PATIENT_CLN_DX_NM") { if (patientKV.Value != null) ConsentExecuteInfo["patientClnDxNm"] = patientKV.Value.ToString(); } if (patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "OPRSRVNO") { if (patientKV.Value != null) ConsentExecuteInfo["opRsrvNo"] = patientKV.Value.ToString(); } } } if (callKV.Key != null && !string.IsNullOrEmpty(callKV.Key.ToString()) && callKV.Key.ToString() == "EXEC_OPT") { // 화면 설정 정보 foreach (KeyValuePair execKV in callKV.Value as Dictionary) { if (execKV.Key != null && !string.IsNullOrEmpty(execKV.Key.ToString()) && execKV.Key.ToString() == "ENABLE_CONSENT_LIST") { if (execKV.Value != null) ConsentExecuteInfo["enableConsentList"] = execKV.Value.ToString(); // 동의서 리스트 사용 유무 } if (execKV.Key != null && !string.IsNullOrEmpty(execKV.Key.ToString()) && execKV.Key.ToString() == "ENABLE_PATIENT_LIST") { if (execKV.Value != null) ConsentExecuteInfo["enablePatientList"] = execKV.Value.ToString(); // 환자 리스트 사용 유무 } // 대가대 병원 초기 설정 없음 if (execKV.Key != null && !string.IsNullOrEmpty(execKV.Key.ToString()) && execKV.Key.ToString() == "START_FORM_CD") { if (execKV.Value != null) ConsentExecuteInfo["startFormCd"] = execKV.Value.ToString(); // 시작 FORM ID } // 대가대 병원 초기 설정 없음 if (execKV.Key != null && !string.IsNullOrEmpty(execKV.Key.ToString()) && execKV.Key.ToString() == "PTNT_ACT") { if (execKV.Value != null) ConsentExecuteInfo["printAct"] = execKV.Value.ToString(); // 초기 프린트 } // 여러 서식 출력 // 대가대 병원 사용되지 않음 //eg, {PRINT_LIST: [{START_FORM_CD: VALUE, PTNT_NO: VALUE, VISIT_TYPE: VALUE, CLN_DATE: VALUE, CLN_DEPT:VAELU, PRINT_CNT: VALUE, CRETNO: VALUE}, ...]} if (execKV.Key != null && !string.IsNullOrEmpty(execKV.Key.ToString()) && execKV.Key.ToString() == "PRINT_LIST") { if (execKV.Value != null) { if (execKV.Value is List PatientList && PatientList.Count > 0) { PrintInfoList = new List(); ConsentVO consentVO = new ConsentVO(); for (int i = 0; i < PatientList.Count; i++) { consentVO = new ConsentVO { printCnt = -1 }; foreach (KeyValuePair callOrderKV in PatientList[i] as Dictionary) { if (callOrderKV.Key != null && !string.IsNullOrEmpty(callOrderKV.Key.ToString()) && callOrderKV.Value != null) { if (callOrderKV.Key.ToString() == "START_FORM_CD") consentVO.formCode = callOrderKV.Value.ToString(); // 출력 서식코드 //if (callOrderKV.Key.ToString() == "PTNT_NO") consentVO.PatientCode = callOrderKV.Value.ToString(); // 환자번호 //if (callOrderKV.Key.ToString() == "VISIT_TYPE") consentVO.VisitType = callOrderKV.Value.ToString(); // 내원구분 //if (callOrderKV.Key.ToString() == "CLN_DATE") consentVO.ClnDate = callOrderKV.Value.ToString(); // 진료일자 //if (callOrderKV.Key.ToString() == "CLN_DEPT") consentVO.ClnDeptCd = callOrderKV.Value.ToString(); // 진료과 if (callOrderKV.Key.ToString() == "PRINT_CNT") { int.TryParse(callOrderKV.Value.ToString(), out int PrntCnt); consentVO.printCnt = PrntCnt; // 출력 카운트 } if (callOrderKV.Key.ToString() == "CRETNO") { int.TryParse(callOrderKV.Value.ToString(), out int cretno); //consentVO.Cretno = cretno; // 차트번호 } } } PrintInfoList.Add(consentVO); } if (execKV.Value != null) ConsentExecuteInfo["printList"] = PrintInfoList.Count.ToString(); // 출력 데이터 } } } if (execKV.Key != null && !string.IsNullOrEmpty(execKV.Key.ToString()) && execKV.Key.ToString() == "FORMCD") { // 서식 코드 if (execKV.Value != null) ConsentExecuteInfo["formCd"] = execKV.Value.ToString(); } if (execKV.Key != null && !string.IsNullOrEmpty(execKV.Key.ToString()) && execKV.Key.ToString() == "OCRCD") { // OCR 태그 if (execKV.Value != null) ConsentExecuteInfo["ocrCd"] = execKV.Value.ToString(); } if (execKV.Key != null && !string.IsNullOrEmpty(execKV.Key.ToString()) && execKV.Key.ToString() == "TEMP_SAVE") { // 임시 저장 (Ku2.0 연동) if (execKV.Value != null) ConsentExecuteInfo["tempSave"] = execKV.Value.ToString(); } if (execKV.Key != null && !string.IsNullOrEmpty(execKV.Key.ToString()) && execKV.Key.ToString() == "PRINT_YN") { // 출력 여부 (Ku2.0 연동) if (execKV.Value != null) ConsentExecuteInfo["printYN"] = execKV.Value.ToString(); } if (execKV.Key != null && !string.IsNullOrEmpty(execKV.Key.ToString()) && execKV.Key.ToString() == "PRINT_CNT") { // 출력 매수 (Ku2.0 연동) if (execKV.Value != null) ConsentExecuteInfo["printCount"] = execKV.Value.ToString(); } if (execKV.Key != null && !string.IsNullOrEmpty(execKV.Key.ToString()) && execKV.Key.ToString() == "SYSINSTNM") { // 접속 서버 정보 if (execKV.Value != null) { string systemName = string.Empty; // 대가대 병원 시스템 CD //instCd = execKV.Value.ToString().Contains("교육") ? "DEV101" : "EMR101"; systemName = execKV.Value.ToString(); //instCd = execKV.Value.ToString().Contains("본원") ? "031" : execKV.Value.ToString().Contains("칠곡") ? "032" : string.Empty; //instCd += execKV.Value.ToString().Contains("교육") ? "edu" : string.Empty; //instCd = "Dev"; ConsentExecuteInfo["sysInstNm"] = systemName; } } // 보기 전용 여부 // 대가대 병원 초기 설정 없음 if (execKV.Key != null && !string.IsNullOrEmpty(execKV.Key.ToString()) && execKV.Key.ToString() == "READ_ONLY") { if (execKV.Value != null) ConsentExecuteInfo["readOnly"] = execKV.Value.ToString(); } } } // 원무 if (callKV.Key != null && !string.IsNullOrEmpty(callKV.Key.ToString()) && callKV.Key.ToString() == "PAM_INFO") { foreach (KeyValuePair patientKV in callKV.Value as Dictionary) { if (patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "SPEC_DR_YN") { if (patientKV.Value != null) ConsentExecuteInfo["SpecDoctorYN"] = patientKV.Value.ToString(); } if (patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "CONT_START_DT") { if (patientKV.Value != null) ConsentExecuteInfo["ContStartDate"] = patientKV.Value.ToString(); } if (patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "CONT_END_DT") { if (patientKV.Value != null) ConsentExecuteInfo["ContEndDate"] = patientKV.Value.ToString(); } if (patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "ROOM_CAPA") { if (patientKV.Value != null) ConsentExecuteInfo["RoomCapa"] = patientKV.Value.ToString(); } if (patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "CONT_TELNO") { if (patientKV.Value != null) ConsentExecuteInfo["ContTelNo"] = patientKV.Value.ToString(); } if (patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "CONT_STAFF1") { if (patientKV.Value != null) ConsentExecuteInfo["ContStaff1Name"] = patientKV.Value.ToString(); } if (patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "CONT_STAFF2") { if (patientKV.Value != null) ConsentExecuteInfo["ContStaff2Name"] = patientKV.Value.ToString(); } if (patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "CONT_STAFF3") { if (patientKV.Value != null) ConsentExecuteInfo["ContStaff3Name"] = patientKV.Value.ToString(); } if (patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "CARD_NO") { if (patientKV.Value != null) ConsentExecuteInfo["CardNo"] = patientKV.Value.ToString(); } } } } } else { throw new Exception("CallParam 미전달"); } // IP 주소 확인 string printIp = string.Empty; foreach (System.Net.IPAddress ip in System.Net.Dns.GetHostAddresses(System.Net.Dns.GetHostName())) { if (ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) { printIp = ip.ToString(); break; } } // dbs227, 경북대학교병원 ip address 기록 ConsentExecuteInfo["ipaddr"] = printIp; if (!printIp.Equals(string.Empty)) { string[] ipArr = printIp.Split(new string[] { "." }, StringSplitOptions.RemoveEmptyEntries); if (ipArr.Length == 4) { printIp = string.Format("{0}.{1}", ipArr[2], ipArr[3]); } else { printIp = string.Empty; } } ConsentExecuteInfo["printIP"] = printIp; } catch (Exception ex) { throw ex; } } private string monitorNo = string.Empty; /// /// 모니터 뷰 설정 /// /// 출력 여부 private void MoniterViewSetting(bool printMode) { // 출력 모드라면 화면에 나타내지 않는다 if (printMode) { return; } // 로딩 시 사용자 설정 모니터 정보를 불러온다. string userPrefMonitor = string.Empty; if(hospitalWebService != null) { userPrefMonitor = hospitalWebService.getUserPrefMonitor(ConsentExecuteInfo["userId"], ConsentExecuteInfo["dutinstcd"]); } int iMoniterNumber = 0; if (!string.IsNullOrEmpty(userPrefMonitor)) { //현재 프로그램이 실행되고 있는정보 가져오기: 디버깅 모드라면 bin/debug/프로그램명.exe FileInfo exefileinfo = new FileInfo(Path.GetDirectoryName(Application.StartupPath)); string path = Path.GetDirectoryName(Application.StartupPath); string fileName = @"\config.ini"; //파일명 //만약 현재 실행 되는 경로가 아닌 특정한 위치를 원한다면 위에 과정 상관없이 바로 경로셋팅 해 주면 된다. (예: c:\config.ini) string filePath = path + fileName; //ini 파일 경로 // 만들어 놓았던 iniUtil 객체 생성(생성자 인자로 파일경로 정보 넘겨줌) iniUtil ini = new iniUtil(filePath); //이제 ini 객체를 이용해 맘것 사용하면 된다. string localValue = ini.GetIniValue("DCMC", "MONITER_NUMBER"); // 서버에서 가져온 값과 로컬값이 다른다면 서버값으로 매핑하여 준다. if (!userPrefMonitor.Equals(localValue)) { ini.SetIniValue("DCMC", "MONITER_NUMBER", userPrefMonitor); } int.TryParse(userPrefMonitor, out iMoniterNumber); } monitorNo = userPrefMonitor; //Point location = Point.Empty; //int j = 1; //FormWindowState windowStateBackup; //foreach (Screen sc in Screen.AllScreens) { // // 출력할 모니터에 Form 을 생성하여 나타낸다 // if (j == iMoniterNumber) { // Form parentForm = this.Parent as Form; // if (parentForm != null) { // windowStateBackup = parentForm.WindowState; // Size size = parentForm.Bounds.Size; // parentForm.WindowState = FormWindowState.Normal; // parentForm.StartPosition = FormStartPosition.Manual; // parentForm.ClientSize = new Size(size.Width, size.Height); // parentForm.Location = new Point(sc.Bounds.Left, sc.Bounds.Top); // parentForm.WindowState = windowStateBackup; // } // break; // } // j++; //} } public void setDualViewerOption(string monitorNo) { if (!string.IsNullOrEmpty(monitorNo)) { this.eFormViewerCtrl.SetRunOption("DUALVIEWER_DISPLAY_INDEX", monitorNo); } } /// /// eFormViewer 컨트롤에 대한 초기화 /// run option 설정 /// private void InitEFormControl() { Screen screen = Screen.FromControl(this); if (screen.Primary) { this.eFormViewerCtrl.SetRunOption("DEFAULT_ZOOM_RATE", "pagewidth"); } else { this.eFormViewerCtrl.SetRunOption("DEFAULT_ZOOM_RATE", "pagewidth"); } //this.eFormViewerCtrl.SetRunOption("ENABLE_DEBUG_VIEW", "true"); //this.eFormViewerCtrl.SetRunOption("DEFAULT_TOOL_BAR_VISIBLE", "true"); this.eFormViewerCtrl.SetRunOption("USE_CREDITCARD_SIGNPAD", "false"); this.eFormViewerCtrl.SetRunOption("DEFAULT_TOOL_BAR_VISIBLE", "false"); this.eFormViewerCtrl.SetRunOption("SET_EXTERNAL_CONTROL_DEFINED_PATH", this.PluginExecuteInfo["formServiceUrl"]); this.eFormViewerCtrl.SetRunOption("USE_EITHER_SIDE_MOVE_BUTTON", "true"); // dbs227, 경북대학교병원 옵션, 형광펜 색으로 this.eFormViewerCtrl.SetRunOption("DRAWING_PEN", "{ \"width\":\"9\",\"color\":{ \"a\":\"50\", \"r\":\"255\", \"g\":\"255\", \"b\":\"1\"} }"); this.eFormViewerCtrl.SetRunOption("SET_VISIBLE_BUTTONS", "PAGE_ATTACH=true"); this.eFormViewerCtrl.SetRunOption("IMAGE_SAVE_OPTION", "{\"dpi\":\"150\",\"gray\":\"false\",\"encode\":\"jpeg\",\"base-index\":\"1\",\"quality\":\"100\"}"); // dbs227, 경북대학교병원 요청사항 // 마우스 우클릭 그리기 모드 변경 this.eFormViewerCtrl.SetRunOption("SET_MOUSE_RIGHT_CHANGE_MODE", "Drawing"); // V2 버전 런 옵션 this.eFormViewerCtrl.SetRunOption("RUN_AS_REPOSITORY_V2", "true"); if (HasMultipleMonitor) { this.eFormViewerCtrl.SetRunOption("DUALVIEWER_TOOL_BAR_SIZE", "32"); if (!string.IsNullOrEmpty(monitorNo)) { this.eFormViewerCtrl.SetRunOption("DUALVIEWER_DISPLAY_INDEX", monitorNo); //this.eFormViewerCtrl.SetRunOption("DUALVIEWER_DISPLAY_INDEX", "1"); } this.eFormViewerCtrl.SetRunOption("RUN_AS_DUALVIEWER", "CLIP.eForm.DualViewer.dll"); // this.eFormViewerCtrl.SetRunOption("READ_ONLY", "true"); this.eFormViewerCtrl.SetRunOption("DUALVIEWER_TO_ACTIVATE_CONTROLS", "true"); this.eFormViewerCtrl.SetRunOption("SET_VISIBLE_DUALVIEWER_TOOLSTRIP_MENU", "true"); this.eFormViewerCtrl.SetRunOption("DUALVIEWER_TOOL_BAR_ENABLE", "true"); // 툴바 위치 조절(true : 상단, false : 하단) this.eFormViewerCtrl.SetRunOption("USE_DUALVIEWER_TOOL_BAR_TOP", "true"); // 가상키보드 사용 여부 this.eFormViewerCtrl.SetRunOption("DUALVIEWER_VIRTUAL_KEYBOARD_VISIBLE", "true"); // 관리자 권한 실행 저장 여부 this.eFormViewerCtrl.SetRunOption("USE_ADMIN_PRIVILEGES_SAVE_EXECUTE", "false"); this.eFormViewerCtrl.SetRunOption("DUALVIEWER_RESOLUTION", "{\"width\":\"768\",\"height\":\"1024\"}"); } } /// /// Invokes the delayed load event. /// private void InvokeDelayedLoadEvent() // TODO: 리팩터링 대상 comment by jchong 2016.06.11 { if (this.OnLoadPartControls != null) { Application.DoEvents(); Thread.Sleep(1); OnLoadPartControls.Invoke(this, new EventArgs()); } } /// /// /// A , passed by reference, that represents the window message to process. /// One of the values that represents the key to process. /// /// true if the character was processed by the control; otherwise, false. /// protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { if (msg.Msg == 0x100) { if (keyData == Keys.PageUp) { this.eFormViewerCtrl.MovePrevPage(); } if (keyData == Keys.Next) { this.eFormViewerCtrl.MoveNextPage(); } } return base.ProcessCmdKey(ref msg, keyData); } /// /// Consents the main control UI update on drawing. /// /// The sender. /// The undo stack count. /// The redo stack count. /// The total stroke count. /// The total all page stroke coun. void ConsentMainControl_UIUpdateOnDrawing(object sender, int undoStackCount, int redoStackCount, int totalStrokeCount, int totalAllPageStrokeCoun) { if (undoStackCount > 0) { this.consentCommandCtrl.EnableUndo = true; } else { this.consentCommandCtrl.EnableUndo = false; } if (redoStackCount > 0) { this.consentCommandCtrl.EnableRedo = true; } else { this.consentCommandCtrl.EnableRedo = false; } if (totalStrokeCount > 0) { this.consentCommandCtrl.EnableRemoveAll = true; } else { this.consentCommandCtrl.EnableRemoveAll = false; } } ConsentListCtrlBase IConsentMain.ConsentListCtrl { get { return this.consentListCtrl; } } PatientInfoCtrlBase IConsentMain.PatientInfoCtrl { get { return this.patientInfoCtrl; } } PatientListCtrlBase IConsentMain.PatientListCtrl { get { return this.patientListCtrl; } } Dictionary IConsentMain.ConsentExecuteInfo { get { return this.ConsentExecuteInfo; } set { this.ConsentExecuteInfo = value; } } Dictionary IConsentMain.PluginExecuteInfo { get { return this.PluginExecuteInfo; } set { this.PluginExecuteInfo = value; } } ConsentCommandCtrlBase IConsentMain.ConsentCommandCtrl { get { return this.consentCommandCtrl; } } public Dictionary ProcessResultValue { get { return processResultValues; } } /// /// 환자 정보가 바뀌었을때 컨트롤들의 정보를 재조회 /// /// Type of the visit. void IConsentMain.UIControlsRefeash(string visitType) { this.patientInfoCtrl.OnRefeashPartControls(visitType); this.consentListCtrl.OnRefeashPartControls(); } /// /// 사용자 정보 변경 /// /// 근무지기관코드 /// 사용자ID /// 근무지부서 void IConsentMain.SetConsentUserInfo(string pInstCd, string pUserId, string DutPlceCd) { this.patientInfoCtrl.SetConsentUserInfo(pUserId, pInstCd, DutPlceCd); } void IConsentMain.ClearPreviewConsent(bool pDoInit) { consentCommandCtrl.CurrentPreviewConsent = null; patientInfoCtrl.SetConsentDocumentName(""); if (pDoInit) { eFormViewerCtrl.ReInitializeViewer(); imageViewCtrl1.Hide(); } } void IConsentMain.PreviewConsent(string fos) { this.pnlCommand.Visible = true; this.pnlViewer.Visible = false; this.eFormViewerCtrl.Visible = true; // 배율정보 설정 consentCommandCtrl.setZoomRate(4); consentCommandCtrl.setButtonsVisibility(consentCommandCtrl.CurrentTargetPatient.ordtype, consentCommandCtrl.CurrentPreviewConsent.ConsentState); this.eFormViewerCtrl.OpenFos(fos); } void IConsentMain.ClearConsent() { this.pnlCommand.Visible = true; this.pnlViewer.Visible = false; this.eFormViewerCtrl.Visible = true; this.eFormViewerCtrl.Open(); } void IConsentMain.ReviewConsent() { this.pnlCommand.Visible = false; this.pnlViewer.Visible = true; this.eFormViewerCtrl.Visible = false; } void IConsentMain.setDualViewerButtonOtps(string otps) { InitEFormControl(); this.eFormViewerCtrl.SetRunOption("SET_DUALVIEWER_VISIBLE_BUTTONS", otps); } void IConsentMain.RunConsentDualView() { this.eFormViewerCtrl.OpenDualViewer(); } /// /// Prints the consent document. /// 수동으로 찾아서출력 /// 일반 출력의 경우에도 기본프린터로 바로 출력하는 것으로 변경됨 /// /// The fos. void IConsentMain.PrintConsentDocument(string fos) { //int rid = -1; if (!string.IsNullOrEmpty(fos)) { this.eFormViewerCtrl.OpenFos(fos); // dbs227 DB 기록 필요 //rid = this.consentCommandCtrl.SaveDataForPrintedConsent(String.Empty); } this.printSaveStatus = false; int iPrntCnt = 0; //PC 클라이언트에서 출력 버튼 눌럿을때를 구분하여 pageCount넘겨줌 //pageCount를 넘겨주지 않고 consentCommandCtrl.CurrentPreviewConsent.PrntCnt에서 출력 장수를 받았을때 초기화되어 익셉션 발생 if (printButtonClick) { iPrntCnt = pageCnt; printButtonClick = false; } else { iPrntCnt = consentCommandCtrl.CurrentPreviewConsent.PrntCnt; } this.multiPrintPlanCnt = iPrntCnt; this.multiPrintExecCnt = 0; this.checkAutoPrint = false; //수동출력 if (iPrntCnt > 0) { // 출력매수만큼 동의서 출력 //for (int i = 0; i < iPrntCnt; i++) //{ // if((i+1) == iPrntCnt) this.printSaveStatus = true; this.printSaveStatus = true; this.eFormViewerCtrl.PrintByPrinterName(""); //} } this.printSaveStatus = false; // dbs227, // 출력 모드가 아닐때는 초기화 하지 않는다. //if (rid > 0) //{ // this.consentListCtrl.InquiryConsentData(rid); //} } /// /// 기본프린터로 출력, Agent에서 직접출력 /// dbs227, 경북대학교병원 사용하지 않음 /// /// 출력할 FOS string void IConsentMain.PrintDirect(string fos) { if (!string.IsNullOrEmpty(fos)) { // dbs227 DB 기록 필요 //this.consentCommandCtrl.SaveDataForPrintedConsent(String.Empty); this.eFormViewerCtrl.OpenFos(fos); //this.consentCommandCtrl.SaveDataForPrintedConsent(String.Empty); } int prntCnt = 0; prntCnt = consentCommandCtrl.CurrentPreviewConsent.PrntCnt; this.checkAutoPrint = true;//자동출력 if (!string.IsNullOrEmpty(this.ConsentExecuteInfo["printList"])) { if (!ConsentExecuteInfo["prntCnt"].Equals("-1")) { int.TryParse(this.ConsentExecuteInfo["prntCnt"].ToString(), out prntCnt); } } this.multiPrintPlanCnt = prntCnt; this.multiPrintExecCnt = 0; if (prntCnt > 0) { //this.printSaveStatus = false; //// 출력매수만큼 동의서 출력 //for (int i = 0; i < prntCnt; i++) //{ // if ((i + 1) == prntCnt) this.printSaveStatus = true; this.printSaveStatus = true; //기본프린터로 바로 출력하기로 함 this.eFormViewerCtrl.PrintByPrinterName(""); //} //this.printSaveStatus = false; } } void IConsentMain.MoveFirstPage() { this.eFormViewerCtrl.MoveFirstPage(); } void IConsentMain.MovePrevPage() { this.eFormViewerCtrl.MovePrevPage(); } void IConsentMain.MoveNextPage() { this.eFormViewerCtrl.MoveNextPage(); } void IConsentMain.MoveLastPage() { this.eFormViewerCtrl.MoveLastPage(); } void IConsentMain.Save() { this.eFormViewerCtrl.Save(); } /// /// eFormViewerCtrl 컨트롤의 TempSave 이벤트를 호출 /// void IConsentMain.TempSave() { this.eFormViewerCtrl.TempSave(); } int IConsentMain.GetCurrentPageIndex() { return this.eFormViewerCtrl.GetCurrentPageIndex(); } int IConsentMain.GetTotalPageCount() { return this.eFormViewerCtrl.GetTotalPageCount(); } void IConsentMain.MoveToPageIndex(int pageIndex) { this.eFormViewerCtrl.MoveToPageIndex(pageIndex); } void IConsentMain.SetZoomRate(string zoomRate) { this.eFormViewerCtrl.SetZoomRate(zoomRate); } void IConsentMain.EnableDrawing(bool enable) { this.eFormViewerCtrl.EnableDrawing(enable); } bool IConsentMain.IsDrawMode() { return this.eFormViewerCtrl.IsDrawMode(); } void IConsentMain.RemoveAllDrawing() { this.eFormViewerCtrl.RemoveAllDrawing(); } void IConsentMain.UndoDrawing() { this.eFormViewerCtrl.UndoDrawing(); } void IConsentMain.RedoDrawing() { this.eFormViewerCtrl.RedoDrawing(); } void IConsentMain.ConfigDrawingPen() { this.eFormViewerCtrl.ConfigDrawingPen(); } void IConsentMain.SetFingerScanValue(string controlId, string base64Image) { this.eFormViewerCtrl.SetFingerPrintImage(controlId, base64Image, true); } void IConsentMain.SetSignatureImage(string controlId, string base64Image) { this.eFormViewerCtrl.SetSignatureImage(controlId, base64Image, true); } public CLIP.eForm.ImageView.ImageViewCtrl GetImageViewerCtrl() { return this.imageViewCtrl1; } void IConsentMain.CloseSignaturePopup(string controlId) { this.eFormViewerCtrl.CloseSignaturePopup(controlId); } void IConsentMain.SetRunOption(string optionKey, string optionValue) { this.eFormViewerCtrl.SetRunOption(optionKey, optionValue); } void IConsentMain.TerminateConsentMain() { if (this.Parent is System.Windows.Forms.Form) { ((Form) this.Parent).DialogResult = DialogResult.Cancel; ((Form) this.Parent).Close(); } } /// /// 첨지 삭제 /// void IConsentMain.DeleteAttach() { this.eFormViewerCtrl.DeleteAttach(); } /// /// 첨지 추가 /// void IConsentMain.InsertAttach() { this.eFormViewerCtrl.InsertAttach(); } /// /// 환자정보 설정 /// void IConsentMain.SetPatientInfo() { this.patientInfoCtrl.SetPatientInfo(); } /// /// Closes the dual viewer. /// public void CloseDualViewer() { this.eFormViewerCtrl.CloseDualViewer(); this.consentCommandCtrl.SetEnableConsentIssueCommands(true); this.consentCommandCtrl.SetEnableButtonsByCurrentConsent(); } /// /// 서명 시 이미지 파일 생성 된 후 호출 /// /// 저장 이미지 파일 설명 private void OnWrittenImageFile(string value) { this.consentCommandCtrl.WorkExtraWithSavedImageFiles(value); } /// /// Called when [written data XML file]. /// /// The value. private void OnWrittenDataXmlFile(string value) { string dataXmlValue = string.Empty; if (!string.IsNullOrEmpty(value)) { XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load(value); dataXmlValue = xmlDocument.InnerXml; outputDataDic = new Dictionary(); XmlNode rootNode = xmlDocument.SelectSingleNode("form-data"); foreach (XmlNode childNode in rootNode.ChildNodes) { string fieldName = string.Empty; string fieldValue = string.Empty; XmlElement outFieldElement = childNode as XmlElement; if (outFieldElement != null) { fieldName = outFieldElement.Name; if (outFieldElement.ChildNodes.Count > 0 && outFieldElement.ChildNodes[0] is XmlCDataSection) { fieldValue = ((XmlCDataSection) outFieldElement.ChildNodes[0]).InnerText; } if (outputDataDic.ContainsKey(fieldName)) { outputDataDic[fieldName] = fieldValue; } else { outputDataDic.Add(fieldName, fieldValue); } } } if (processResultValues.ContainsKey("OUTPUT_VALUES")) { processResultValues["OUTPUT_VALUES"] = outputDataDic; } else { processResultValues.Add("OUTPUT_VALUES", outputDataDic); } } try { //int state = this.consentWebService.CheckConsentState(int.Parse(consentCommandCtrl.CurrentPreviewConsent.ConsentMstRid), consentCommandCtrl.CurrentPreviewConsent.ConsentState); //if (state == 1) { // MessageBoxDlg.Show(this, "이미 저장된 서식 입니다." // , string.Format(Properties.Resources.msg_caption_confirm), // MessageBoxButtons.OK, MessageBoxIcon.Information); // return; //} string eptXmlValue = this.eFormViewerCtrl.GetTempSaveForm(); // Gzip -> base64 인코딩 eptXmlValue = Convert.ToBase64String(Common.Zip(eptXmlValue)); dataXmlValue = Convert.ToBase64String(Common.Zip(dataXmlValue)); bool isSaved = this.consentCommandCtrl.SaveCompleteConsentData(eptXmlValue, dataXmlValue, out object saveResult); if (processResultValues.ContainsKey("OTHER_VALUE_1")) { processResultValues["OTHER_VALUE_1"] = saveResult; } else { processResultValues.Add("OTHER_VALUE_1", saveResult); } if (isSaved) { if (ProcessResult != null) { ProcessResult.Invoke("SUCCESS"); } } else { ProcessResult.Invoke("FAIL"); } } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(string.Format("CLIP.eForm error: {0}", ex.Message)); MessageBoxDlg.Show(true, string.Format(ex.Message) , string.Format(Properties.Resources.msg_caption_fail), MessageBoxButtons.OK, MessageBoxIcon.Error); ProcessResult.Invoke("FAIL"); } finally { this.eFormViewerCtrl.CloseDualViewer(); } } private void OnWrittenTempSaveFile(string value) { XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load(value); string eptXmlValue = xmlDocument.InnerXml; // 임시저장 서식 xml try { string dataXml = this.eFormViewerCtrl.GetDataXml(); // 저장 데이터 xml consentCommandCtrl.CurrentPreviewConsent.PrntCnt = eFormViewerCtrl.GetTotalPageCount(); // Gzip -> base64 인코딩 eptXmlValue = Convert.ToBase64String(Common.Zip(eptXmlValue)); dataXml = Convert.ToBase64String(Common.Zip(dataXml)); consentCommandCtrl.SaveTempConsentData(eptXmlValue, dataXml, false); } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(string.Format("CLIP.eForm error: {0}", ex.Message)); return; } finally { this.eFormViewerCtrl.CloseDualViewer(); } } private void OnWrittenTempSave2File(string value) { XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load(value); string eptXmlValue = xmlDocument.InnerXml; // 임시저장 서식 xml try { string dataXml = this.eFormViewerCtrl.GetDataXml(); // 저장 데이터 xml consentCommandCtrl.CurrentPreviewConsent.PrntCnt = eFormViewerCtrl.GetTotalPageCount(); // Gzip -> base64 인코딩 eptXmlValue = Convert.ToBase64String(Common.Zip(eptXmlValue)); dataXml = Convert.ToBase64String(Common.Zip(dataXml)); consentCommandCtrl.SaveTempConsentData(eptXmlValue, dataXml, true); } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(string.Format("CLIP.eForm error: {0}", ex.Message)); return; } finally { this.eFormViewerCtrl.CloseDualViewer(); } } public void SetConsentListSplitPanelVisibility(bool visibility) { if (!visibility) { this.splitConsent.Panel1Collapsed = true; } } public void SetPatientListSplitPanelVisibility(bool visibility) { if (!visibility) { this.splitPatient.Panel2Collapsed = true; } } public bool UseFingerScan { get; set; } public bool viewStatus { get; set; } public bool IsComplete() { bool _isComplete = false; if (consentCommandCtrl != null && consentCommandCtrl.CurrentPreviewConsent != null) { string _state = consentCommandCtrl.CurrentPreviewConsent.ConsentState ?? string.Empty; if (_state.Equals("ELECTR_CMP")) { _isComplete = true; } } return _isComplete; } private void panelReview_Resize(object sender, EventArgs e) { if (this.pnlViewer.Visible) { if (OnResizeReviewConsent != null) { OnResizeReviewConsent.Invoke(this, new EventArgs()); } } } /// /// 동의서 뷰어 컨트롤 OnError 이벤트 핸들러 /// /// 에러코드 /// 에러 메시지 private void eFormViewerCtrl_OnError(string errorCode, string errorMessage) { } /// /// 동의서 뷰어 컨트롤 OnProcess 이벤트 핸들러 /// /// 이벤트 코드 /// 이벤트 값 private void eFormViewerCtrl_OnProcess(string eventCode, string value) { System.Diagnostics.Trace.WriteLine(string.Format("eventCode: {0} - value: {1}", eventCode, value)); // 동의서의 현제 페이지 번호 설정 if (eventCode.Equals("PAGING")) { this.consentCommandCtrl.OnPaging(this.eFormViewerCtrl.GetCurrentPageIndex()); } // 듀얼 뷰어 버튼 활성화 여부 제어? if (eventCode.Equals("DUAL_VIEWER")) { if (value.Equals("OPEN")) { this.consentListCtrl.Enabled = false; this.patientInfoCtrl.Enabled = false; this.patientListCtrl.Enabled = false; // this.eFormViewerCtrl.SetRunOption("READ_ONLY", "false"); this.consentCommandCtrl.EnablePenDrawing = true; this.consentCommandCtrl.EnablePenConfig = true; this.consentCommandCtrl.SetEnablementExecuteWhenDualViewerActive(false); } if (value.Equals("CLOSE")) { this.consentListCtrl.Enabled = true; this.patientInfoCtrl.Enabled = true; this.patientListCtrl.Enabled = true; // this.eFormViewerCtrl.SetRunOption("READ_ONLY", "true"); this.consentCommandCtrl.EnablePenDrawing = false; this.consentCommandCtrl.EnablePenConfig = false; this.consentCommandCtrl.onEnableDrawing(false); this.eFormViewerCtrl.EnableDrawing(false); this.consentCommandCtrl.SetEnablementExecuteWhenDualViewerActive(true); } } // 동의서 작성완료 후 이미지 저장 if (eventCode.Equals("WRITTEN_IMAGE_FILE")) { // bjw, [확인] 시에는 이미지 저장하지 않음 // dbs227, 확인 저장 시 이미지도 저장 하여야 함 //if (!consentCommandCtrl.IsComplete) { this.OnWrittenImageFile(value); } } // 동의서 작성완료 후 Data XML 저장 if (eventCode.Equals("DATA_XML_PATH")) { // [확인] 시에는 임시 저장만 한다. if (consentCommandCtrl.IsComplete) { //eFormViewerCtrl.TempSave(); eFormViewerCtrl.TempSave2(); } else { // 작성완료 버튼이 활성화 되어 있을 경우에만 작성완료 로직을 진행한다. if (this.consentCommandCtrl.getSaveButton()) { this.consentCommandCtrl.setSaveButton(false); this.OnWrittenDataXmlFile(value); this.consentCommandCtrl.setSaveButton(true); this.eFormViewerCtrl.ConfirmSave(true, ""); } } } // 동의서 확인 저장 if (eventCode.Equals("TEMP_SAVE_PATH2")) { this.OnWrittenTempSave2File(value); this.eFormViewerCtrl.ConfirmSave(true, ""); } // 동의서 임시저장 if (eventCode.Equals("TEMP_SAVE_PATH")) { // 임시저장 버튼이 활성화 되어 있을 경우에만 임시저장 로직을 진행한다. // Ku2.0 연동 시 임시저장 로직을 진행한다. // 작성 완료 시 if (this.consentCommandCtrl.getTempSaveButton() || consentCommandCtrl.IsComplete) { this.consentCommandCtrl.setTempSaveButton(false); this.OnWrittenTempSaveFile(value); if (!consentCommandCtrl.IsComplete) { this.consentCommandCtrl.setTempSaveButton(true); } this.eFormViewerCtrl.ConfirmSave(true, ""); } } // 동의서 종이 출력 if (eventCode.Equals("PRINT_COMPLETE")) { //this.consentCommandCtrl.OnPrint(value); // dbs227, 출력 로그 업데이트 // 출력을 위한 호출일 경우 form 을 종료한다 if (printConsentCount == 0 && ConsentExecuteInfo["printYN"].Equals("Y")) { Form parentForm = this.Parent as Form; if (parentForm != null) { parentForm.Close(); } } } // dbs227, 동의서 프린트 실패 if (eventCode.Equals("PRINT_FAIL") || eventCode.Equals("PRINT_CANCEL")) { } //필수 항목 누락시 메시지 박스 호출 if (eventCode.Equals("REQUIRED_INPUT_VIOLATION")) { this.consentCommandCtrl.OnRequiredInputViolation(value); } // 펜 그리기 모드 활성화 여부 제어 if (eventCode.Equals("ENABLE_DRAWING")) { if (value.Equals("TRUE")) { this.consentCommandCtrl.onEnableDrawing(true); } else if (value.Equals("FALSE")) { this.consentCommandCtrl.onEnableDrawing(false); } } // 초기화 상태 if (eventCode.Equals("INITIALIZE_STATE")) { if (value.Equals("FormViewInitialized")) { viewStatus = true; } } // 그외 이벤트 // 동의서 저장 버튼 활셩화여부 제어 // 동의서 임시서장 버튼 활성화 여부 반환(get) // 동의서 임시저장 버튼 활성화 여부 제어(set) } private void eFormViewerCtrl_VisibleChanged(object sender, EventArgs e) { if (this.eFormViewerCtrl.Visible) { if (this.OnVisibleEFormControl != null) { this.OnVisibleEFormControl.Invoke(this, new EventArgs()); } } else { if (this.OnInvisibleEFormControl != null) { this.OnInvisibleEFormControl.Invoke(this, new EventArgs()); } } } /// /// startFormCd 를 초기화 한다 /// public void preParamClean() { this.ConsentExecuteInfo["startFormCd"] = string.Empty; } void IConsentMain.ReInitializeViewer() { if (eFormViewerCtrl.GetTotalPageCount() > 0) { this.eFormViewerCtrl.ReInitializeViewer(); } this.viewStatus = false; } public void OnProcessCmdKey(Keys keyData) { } /// /// OCX 에서 넘겨 받은 FORMCD 리스트를 서버에서 조회해 온다 /// private void GetConsentListByFormcd() { try { string[] formCdArr = ConsentExecuteInfo["formCd"].Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); string[] ocrTagArr = ConsentExecuteInfo["ocrCd"].Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); printConsentCount = formCdArr.Length; var today = DateTime.Today.ToString("yyyyMMdd"); for (int i = 0; i < formCdArr.Length; i++) { // 서버에서 목록 조회 ConsentVO[] voArr = consentWebService.GetConsentByFormcd(formCdArr[i], ConsentExecuteInfo["dutinstcd"], today); //ConsentVO[] voArr = consentWebService.GetConsentByFormcd(formCdArr[i], ConsentExecuteInfo["dutinstcd"]); if (voArr == null || voArr.Length < 1) { throw new Exception("지정된 동의서를 찾을 수 없습니다."); } ConsentVO vo = voArr[0]; // 현재 preview 할동의서 정보 설정 //consentCommandCtrl.CurrentPreviewConsent = new PreviewConsent(); consentCommandCtrl.CurrentPreviewConsent = new PreviewConsent { FormRid = vo.formId.ToString(), FormCd = vo.formCode.ToString(), FormName = vo.formName, FormPrintName = vo.formPrntNm, PrntCnt = vo.printCnt, ConsentMstRid = "-1", ConsentState = string.Empty, Ocrcode = vo.ocrTag, certPass = vo.certPass, InputId = consentCommandCtrl.CurrentEndUser.userId, InputNm = consentCommandCtrl.CurrentEndUser.userName, ReissueConsentMstRid = 0, RewriteConsentMstRid = 0, OpDiagName = consentCommandCtrl.CurrentTargetPatient.OpDiagName, VisitType = consentCommandCtrl.CurrentTargetPatient.ordtype, OpName = consentCommandCtrl.CurrentTargetPatient.OpName }; // 출력 연동이 아닌 경우 if (ConsentExecuteInfo["printYN"].Equals("N")) { Dictionary globalParams = Common.CreateGlobalParamsDictionary(ConsentExecuteInfo["dutinstcd"]); List formGuids = new List { consentCommandCtrl.CurrentPreviewConsent.FormGuid }; consentCommandCtrl.SetPatientAndUser(globalParams); if (ocrTagArr.Length > 0) { globalParams[FOSParameter.LIST_OCRCODE] = consentCommandCtrl.CurrentPreviewConsent.Ocrcode = ocrTagArr[i]; // OCR 코드 } else { globalParams[FOSParameter.LIST_OCRCODE] = consentCommandCtrl.CurrentPreviewConsent.Ocrcode = consentCommandCtrl.GetOcrCode(); // OCR 코드 } globalParams[FOSParameter.GLOBAL_MAIN_DR1_NM] = consentCommandCtrl.CurrentTargetPatient.mainDrNm; // 빌드를 위한 주석 처리 // 임시저장의 경우 C 로 설정 //globalParams[FOSParameter.Device] = "PC"; //globalParams[FOSParameter.PrintTime] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); //globalParams[FOSParameter.SignTime] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); //globalParams[FOSParameter.PrintIp] = ConsentExecuteInfo["printIP"]; string fos = Common.getNewFosString(PluginExecuteInfo["formServiceUrl"], globalParams, null, new List { consentCommandCtrl.CurrentPreviewConsent.FormRid }); consentCommandCtrl.SetEnableButtonsByCurrentConsent(); // 동의서 열기 eFormViewerCtrl.OpenFos(fos); // 출력 히스토리 기록 //this.consentCommandCtrl.OnPrint(vo.FormPrintName); //------------------------------ // TODO 자동 듀얼뷰어 실행 //Boolean openDualView = false; Boolean openDualView = (this.consentWebService.getDualViewMode(ConsentExecuteInfo["dutinstcd"], ConsentExecuteInfo["ipaddr"]) == "Y") ? true : false; if (openDualView) { consentCommandCtrl.RunConsentDualView(); } // 배율정보 설정 consentCommandCtrl.setZoomRate(4); //------------------------------- if (ConsentExecuteInfo["tempSave"].Equals("N")) { // 지정된 동의서를 열기만 하는 경우 // 여러 개의 formcd 를 받더라도 첫번째 것만 보여준다 break; } else if (ConsentExecuteInfo["tempSave"].Equals("Y")) { // 임시 저장 // 동의서 임시저장 eFormViewerCtrl.TempSave(); } } // 출력 연동 if (ConsentExecuteInfo["printYN"].Equals("Y")) { int prntCnt = consentCommandCtrl.CurrentPreviewConsent.PrntCnt; // 실행 파라미터에 PRINT_CNT 가 있고 0보다 클 경우 실행 파라미터를 우선으로 한다. if (!string.IsNullOrEmpty(ConsentExecuteInfo["printCount"])) { int.TryParse(ConsentExecuteInfo["printCount"], out prntCnt); } Dictionary> formParamsList = new Dictionary>(); string[] formGuidList = new string[prntCnt]; string sOcrCd = string.Empty; for (int j = 0; j < prntCnt; j++) { Dictionary formParams = Common.CreateGlobalParamsDictionary(ConsentExecuteInfo["dutinstcd"]); consentCommandCtrl.SetPatientAndUser(formParams); if (ocrTagArr.Length > 0) { formParams[FOSParameter.LIST_OCRCODE] = consentCommandCtrl.CurrentPreviewConsent.Ocrcode = ocrTagArr[i]; } else { sOcrCd = formParams[FOSParameter.LIST_OCRCODE] = consentCommandCtrl.CurrentPreviewConsent.Ocrcode = consentCommandCtrl.GetOcrCode(); } // 동일 서식을 2장 있을 출력할 경우, 2장째부터는 OCR 태그가 아닌 [환자보관용] 텍스트가 출력 //if (j > 0) { // var ocrStr = this.consentWebService.getOcrString(consentCommandCtrl.CurrentPreviewConsent.FormCd, // ConsentExecuteInfo["dutinstcd"]); // if (ocrStr == null) { // ocrStr = "[환자 보관용]"; // } // //ocrStr = (ocrStr == n) ? "[환자 보관용]" : ocrStr; // //formParams[FOSParameter.OCRCode] = "[환자 보관용]"; // formParams[FOSParameter.LIST_OCRCODE] = ocrStr; //} // 빌드를 위한 주석 처리 //formParams[FOSParameter.Device] = "P"; //formParams[FOSParameter.PrintTime] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); //formParams[FOSParameter.PrintIp] = ConsentExecuteInfo["printIP"]; //if (j == 1) formParams[FOSParameter.PrintComment] = Properties.Resources.msg_print_comment_2; //else if (j == 2) formParams[FOSParameter.PrintComment] = Properties.Resources.msg_print_comment_3; formGuidList[j] = consentCommandCtrl.CurrentPreviewConsent.FormGuid; formParamsList.Add((j + 1).ToString(), formParams); } Dictionary globalParams = Common.CreateGlobalParamsDictionary(ConsentExecuteInfo["dutinstcd"]); globalParams[FOSParameter.GLOBAL_MAIN_DR1_NM] = consentCommandCtrl.CurrentTargetPatient.mainDrNm; string fos = Common.getNewFosString(PluginExecuteInfo["formServiceUrl"], globalParams, null, new List { consentCommandCtrl.CurrentPreviewConsent.FormRid }); String formPrintName = formParamsList["1"][FOSParameter.LIST_FORM_NM]; this.eFormViewerCtrl.OpenFos(fos); // 출력 히스토리 기록 this.consentCommandCtrl.OnPrint(formPrintName); //int testpagecnt = this.eFormViewerCtrl.GetTotalPageCount(); // dbs227, 출력 로그 업데이트 // consent_mst 기록 // InsertPrintData API 추가 후 기록 //this.consentCommandCtrl.SaveDataForPrintedConsent(String.Empty); printConsentCount--; this.eFormViewerCtrl.PrintByPrinterName(""); } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); throw ex; } } private void btnHelp_Click(object sender, EventArgs e) { btnHelp.Enabled = false; Application.DoEvents(); System.Diagnostics.Process.Start(@"https://ema031.knuh.kr:9091/doc/guide.pdf"); btnHelp.Enabled = true; } int pageCnt = 0; Boolean printButtonClick = false; void IConsentMain.setPageCnt(int pageCnt) { this.pageCnt = pageCnt; //throw new NotImplementedException(); } int IConsentMain.getPageCnt() { return this.pageCnt; //throw new NotImplementedException(); } void IConsentMain.setPrintButton(bool flag) { this.printButtonClick = flag; //throw new NotImplementedException(); } bool IConsentMain.getPrintButton() { return this.printButtonClick; //throw new NotImplementedException(); } } }