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.Dfh.UI.ConsentSvcRef; using ClipSoft.eForm.Base.Dialog; namespace CLIP.eForm.Consent.Dfh.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 _callParm = null; 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 : 수동출력 private static bool startform = true; public int agentCallPrintCnt { get; set; } object IConsentMainCtrl.CallParam { get { return _callParm; } set { _callParm = value; } } private System.Windows.Forms.Timer _timer; public ConsentMainControl(object callParam) { this.ConsentExecuteInfo = new Dictionary(); this.PluginExecuteInfo = new Dictionary(); SetWebServiceUrlAndTimeout(callParam); InitializeComponent(); this.PluginModuleName = ConfigurationManager.AppSettings["UIPluginAssembly"]; //MainControl의 resize가 일어난 직후 직접출력 처리를 위해서 추가되었음 _timer = new System.Windows.Forms.Timer(); _timer.Interval = 500; _timer.Tick += (sender, e) => ResizeFinished(); this.SizeChanged += new System.EventHandler(this.ConsentMainControl_SizeChanged); } private void ConsentMainControl_SizeChanged(object sender, EventArgs e) { _timer.Start(); } private void ResizeFinished() { _timer.Stop(); //agent 구동시 바로 출력을 하는 경우 if (this.ConsentExecuteInfo.ContainsKey("printAct") && !string.IsNullOrEmpty(this.ConsentExecuteInfo["printAct"]) && this.ConsentExecuteInfo["printAct"].Equals("Y")) { Form parentForm = this.Parent as Form; if (parentForm != null) { parentForm.Visible = false; } if (this.ConsentExecuteInfo.ContainsKey("printList") && !string.IsNullOrEmpty(this.ConsentExecuteInfo["printList"])) { if (this.PrintInfoList != null && this.PrintInfoList.Count > 0) { this.agentCallPrintCnt = PrintInfoList.Count; foreach (ConsentVO consentVO in this.PrintInfoList) { this.ConsentExecuteInfo["patientNo"] = consentVO.PatientCode; this.ConsentExecuteInfo["clnDate"] = consentVO.ClnDate; this.ConsentExecuteInfo["clnDept"] = consentVO.ClnDeptCd; this.ConsentExecuteInfo["visitType"] = consentVO.VisitType; this.ConsentExecuteInfo["cretno"] = consentVO.Cretno.ToString(); this.ConsentExecuteInfo["prntCnt"] = consentVO.PrntCnt.ToString(); this.ConsentExecuteInfo["startFormCd"] = consentVO.FormCd; this.patientInfoCtrl.OnRefeashPartControls(""); this.consentListCtrl.OnRefeashPartControls(); this.consentCommandCtrl.PrintDirectConsentDocument(); } } } else { this.agentCallPrintCnt = 1; this.consentCommandCtrl.PrintDirectConsentDocument(); } this.ConsentExecuteInfo["printAct"] = "N"; if (parentForm != null) { parentForm.WindowState = FormWindowState.Normal; parentForm.Close(); } } } public static bool HasVerticalMonitor { get { if (Screen.AllScreens.Length > 1) { foreach (Screen screen in Screen.AllScreens) { if (screen.Bounds.Width < screen.Bounds.Height) { return true; } } } return false; } } public static Dictionary GetConfigDictionary() { string serviceTarget = string.Empty; 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; } } configXml = new XmlDocument(); configXml.Load(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + string.Format("/CLIP.Consent-{0}.xml", serviceTarget)); 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); } } } private void SetWebServiceUrlAndTimeout(object _callParm) { try { if (_callParm != null) { Dictionary callParam = _callParm as Dictionary; if (callParam.ContainsKey("CALL_PARAMS")) { _callParm = callParam["CALL_PARAMS"] as object; } } Dictionary configDic = GetConfigDictionary(); this.PluginExecuteInfo.Add("consentSvcUrl", configDic["consentSvcUrl"]); this.PluginExecuteInfo.Add("hospitalSvcUrl", configDic["hospitalSvcUrl"]); this.PluginExecuteInfo.Add("formServiceUrl", configDic["formServiceUrl"]); 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; } protected override void OnLoad(EventArgs e) { if (string.IsNullOrEmpty(this.PluginModuleName)) { return; } if (startform) { startform = false; SignatureConfig sign = new SignatureConfig(); sign.SignAllClear(); } //MessageBoxDlg.Show(this, "시작부분.", string.Format(Properties.Resources.msg_caption_confirm),MessageBoxButtons.OK, MessageBoxIcon.Information); InitParamSetting(); InitEFormControl(); InvokeDelayedLoadEvent(); //agent 구동시 바로 출력을 하는 경우 if (!(this.ConsentExecuteInfo.ContainsKey("printAct") && !string.IsNullOrEmpty(this.ConsentExecuteInfo["printAct"]) && this.ConsentExecuteInfo["printAct"].Equals("Y"))) { // 화면이 종료될때 Agent도 종료되도록 수정 //this.Parent.Disposed += Parent_Disposed; } this.eFormViewerCtrl.GetCurrentViewer().UIUpdateOnDrawing += new Viewer.UIUpdateOnDrawingHandler(ConsentMainControl_UIUpdateOnDrawing); base.OnLoad(e); // 폰트 설치여부 체크 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.CreateNoWindow = true; UserProcess.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; UserProcess.Start(); } try { // 임시파일 삭제로직 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) { throw ex; } } // 화면이 종료될때 Agent도 종료되도록 수정 private void Parent_Disposed(object sender, EventArgs e) { foreach (Form form in Application.OpenForms) { if (form.Name.Equals("ConsentAgentForm")) { form.Dispose(); break; } } } // 화면이 종료될때 Agent도 종료되도록 수정 public void Parent_Disposed() { foreach (Form form in Application.OpenForms) { if (form.Name.Equals("ConsentAgentForm")) { form.Dispose(); break; } } } private void InitParamSetting() { try { if (_callParm != null) { Dictionary callParam = _callParm as Dictionary; if (callParam != null && callParam.Count < 2) { if (callParam["CALL_PARAMS"] != null) { _callParm = callParam["CALL_PARAMS"] as object; } } foreach (KeyValuePair callKV in _callParm 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) { this.ConsentExecuteInfo.Add("loginUserNo", userKV.Value.ToString()); // 사용자NO this.ConsentExecuteInfo.Add("userNo", userKV.Value.ToString()); // 사용자NO } } } } 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() == "PTNT_NO") { if (patientKV.Value != null) this.ConsentExecuteInfo.Add("patientNo", patientKV.Value.ToString()); // 환자 등록번호 } if (patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "VISIT_TYPE") { if (patientKV.Value != null) this.ConsentExecuteInfo.Add("visitType", patientKV.Value.ToString()); // 내원구분 } if (patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "CLN_DEPT") { if (patientKV.Value != null) this.ConsentExecuteInfo.Add("clnDept", patientKV.Value.ToString()); // 진료과 } if (patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "CLN_DATE") { if (patientKV.Value != null) this.ConsentExecuteInfo.Add("clnDate", patientKV.Value.ToString()); // 진료일자/입원일자 } if (patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "CRETNO") { if (patientKV.Value != null) this.ConsentExecuteInfo.Add("cretno", patientKV.Value.ToString()); // 수진번호 } if (patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "CLN_DX_NM") { if (patientKV.Value != null) this.ConsentExecuteInfo.Add("clnDxNm", 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() == "USE_LIST_VIEW") { if (execKV.Value != null) this.ConsentExecuteInfo.Add("useListView", execKV.Value.ToString()); // 동의서 리스트 사용 유무 } if (execKV.Key != null && !string.IsNullOrEmpty(execKV.Key.ToString()) && execKV.Key.ToString() == "PTNT_LIST_VIEW") { if (execKV.Value != null) this.ConsentExecuteInfo.Add("patientListView", execKV.Value.ToString()); // 환자 리스트 사용 유무 } if (execKV.Key != null && !string.IsNullOrEmpty(execKV.Key.ToString()) && execKV.Key.ToString() == "START_FORM_CD") { if (execKV.Value != null) this.ConsentExecuteInfo.Add("startFormCd", execKV.Value.ToString()); // 시작 FORM ID } if (execKV.Key != null && !string.IsNullOrEmpty(execKV.Key.ToString()) && execKV.Key.ToString() == "PTNT_ACT") { if (execKV.Value != null) this.ConsentExecuteInfo.Add("printAct", execKV.Value.ToString()); // 초기 프린트 } if (execKV.Key != null && !string.IsNullOrEmpty(execKV.Key.ToString()) && execKV.Key.ToString() == "PRINT_LIST") { if (execKV.Value != null) { // OrderInfoList, OrderInfo, ConsentVO List PatientList = execKV.Value as List; if (PatientList != null && PatientList.Count > 0) { PrintInfoList = new List(); ConsentVO consentVO = new ConsentVO(); for (int i = 0; i < PatientList.Count; i++) { consentVO = new ConsentVO(); consentVO.PrntCnt = -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.FormCd = 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 PrntCnt = 0; int.TryParse(callOrderKV.Value.ToString(), out PrntCnt); consentVO.PrntCnt = PrntCnt; // 출력 카운트 } if (callOrderKV.Key.ToString() == "CRETNO") { int cretno = 0; int.TryParse(callOrderKV.Value.ToString(), out cretno); consentVO.Cretno = cretno; // 차트번호 } } } PrintInfoList.Add(consentVO); } if (execKV.Value != null) this.ConsentExecuteInfo.Add("printList", PrintInfoList.Count.ToString()); // 출력 데이터 } } } } } } } else { throw new Exception("CallParam 미전달"); } bool printMode = false; if (this.ConsentExecuteInfo.ContainsKey("printAct") && !string.IsNullOrEmpty(this.ConsentExecuteInfo["printAct"]) && this.ConsentExecuteInfo["printAct"].Equals("Y")) { printMode = true; } MoniterViewSetting(printMode); } catch (Exception ex) { throw ex; } } private void MoniterViewSetting(bool printMode) { if(printMode) { return; } //현재 프로그램이 실행되고 있는정보 가져오기: 디버깅 모드라면 bin/debug/프로그램명.exe FileInfo exefileinfo = new FileInfo(Path.GetDirectoryName(Application.StartupPath)); // AppDomain.CurrentDomain.DynamicDirectory // Server.MapPath("~") string path = Path.GetDirectoryName(Application.StartupPath);// string fileName = @"\config.ini"; //파일명 //만약 현재 실행 되는 경로가 아닌 특정한 위치를 원한다면 위에 과정 상관없이 바로 경로셋팅 해 주면 된다. (예: c:\config.ini) string filePath = path + fileName; //ini 파일 경로 iniUtil ini = new iniUtil(filePath); // 만들어 놓았던 iniUtil 객체 생성(생성자 인자로 파일경로 정보 넘겨줌) //이제 ini 객체를 이용해 맘것 사용하면 된다. string sMoniterNumber = ini.GetIniValue("DFH", "MONITER_NUMBER"); int iMoniterNumber = 0; int.TryParse(sMoniterNumber, out iMoniterNumber); Point location = Point.Empty; int j = 1; FormWindowState windowStateBackup; foreach (Screen sc in Screen.AllScreens) { 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++; } } 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"); this.eFormViewerCtrl.SetRunOption("DUALVIEWER_TOOL_BAR_SIZE", "32"); this.eFormViewerCtrl.SetRunOption("DRAWING_PEN", "{ \"width\":\"2\",\"color\":{ \"a\":\"255\", \"r\":\"0\", \"g\":\"0\", \"b\":\"0\"} }"); 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\"}"); if (HasVerticalMonitor) { 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", "false"); // 가상키보드 사용 여부 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\"}"); } } private void InvokeDelayedLoadEvent() // TODO: 리팩터링 대상 comment by jchong 2016.06.11 { if (this.OnLoadPartControls != null) { Application.DoEvents(); Thread.Sleep(1); OnLoadPartControls.Invoke(this, new EventArgs()); } } 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); } void ConsentMainControl_UIUpdateOnDrawing(object sender, int undoStackCount, int redoStackCount, int totalStrokeCount) { 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; } } // 환자 정보가 바뀌었을때 컨트롤들의 정보를 재조회 void IConsentMain.UIControlsRefeash(string visitType) { this.patientInfoCtrl.OnRefeashPartControls(visitType); this.consentListCtrl.OnRefeashPartControls(); } void IConsentMain.PreviewConsent(string fos) { this.pnlCommand.Visible = true; this.pnlViewer.Visible = false; this.eFormViewerCtrl.Visible = true; 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.RunConsentDualView() { this.eFormViewerCtrl.OpenDualViewer(); } //일반 출력의 경우에도 기본프린터로 바로 출력하는 것으로 변경됨 // 수동으로 찾아서출력 void IConsentMain.PrintConsentDocument(string fos) { if (!string.IsNullOrEmpty(fos)) { this.eFormViewerCtrl.OpenFos(fos); } this.printSaveStatus = false; int 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; } //기본프린터로 출력, Agent에서 직접출력 void IConsentMain.PrintDirect(string fos) { if (!string.IsNullOrEmpty(fos)) { this.eFormViewerCtrl.OpenFos(fos); } int prntCnt = 0; prntCnt = consentCommandCtrl.CurrentPreviewConsent.PrntCnt; this.checkAutoPrint = true;//자동출력 if (this.ConsentExecuteInfo.ContainsKey("printList") && !string.IsNullOrEmpty(this.ConsentExecuteInfo["printList"])) { if (this.ConsentExecuteInfo.ContainsKey("prntCnt") && !string.IsNullOrEmpty(this.ConsentExecuteInfo["prntCnt"]) && !this.ConsentExecuteInfo["prntCnt"].ToString().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(); } 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(); } public void CloseDualViewer() { this.eFormViewerCtrl.CloseDualViewer(); this.consentCommandCtrl.SetEnableConsentIssueCommands(true); this.consentCommandCtrl.SetEnableButtonsByCurrentConsent(); } private void OnWrittenImageFile(string value) { this.consentCommandCtrl.WorkExtraWithSavedImageFiles(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(); object saveResult = null; bool isSaved = this.consentCommandCtrl.SaveCompleteConsentData(eptXmlValue, dataXmlValue, out 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"); return; } finally { this.eFormViewerCtrl.CloseDualViewer(); } } private void OnWrittenTempSaveFile(string value) { XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load(value); string eptXmlValue = xmlDocument.InnerXml; try { string dataXml = this.eFormViewerCtrl.GetDataXml(); this.consentCommandCtrl.SaveTempConsentData(eptXmlValue, dataXml); // 전자인증 서명 유무에 따른 분기 // 전자인증 서명여부가 "Y"가 아닐 경우 임시저장일경우 서명처리 한다. string esignYn = this.consentCommandCtrl.getPreviewConsentEsignYn(); if (!string.IsNullOrEmpty(esignYn) && esignYn.Equals("Y")) { // 임시 저장 this.consentCommandCtrl.SaveTempConsentData(eptXmlValue, dataXml); try { if (!string.IsNullOrEmpty(value)) { FileInfo fileInfo; fileInfo = new FileInfo(value); if (fileInfo != null) { // EPT 파일 삭제 fileInfo.Delete(); } } } catch (System.IO.IOException e) { throw e; } } else { // 서명 저장 프로세스(전자인증은 안함) this.OnWrittenDataXmlFile(value); } } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(string.Format("CLIP.eForm error: {0}", ex.Message)); //MessageBox.Show(string.Format(Properties.Resources.msg_temp_save_fail) // , string.Format(Properties.Resources.msg_caption_fail), // MessageBoxButtons.OK, MessageBoxIcon.Error); 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; } private void panelReview_Resize(object sender, EventArgs e) { if (this.pnlViewer.Visible) { if (OnResizeReviewConsent != null) { OnResizeReviewConsent.Invoke(this, new EventArgs()); } } } private void eFormViewerCtrl_OnError(string errorCode, string errorMessage) { } 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")) { this.OnWrittenImageFile(value); } if (eventCode.Equals("DATA_XML_PATH")) { // 작성완료 버튼이 활성화 되어 있을 경우에만 작성완료 로직을 진행한다. if(this.consentCommandCtrl.getSaveButton()) { this.consentCommandCtrl.setSaveButton(false); this.OnWrittenDataXmlFile(value); this.consentCommandCtrl.setSaveButton(true); this.eFormViewerCtrl.ConfirmSave(true, ""); } } if (eventCode.Equals("TEMP_SAVE_PATH")) { // 임시저장 버튼이 활성화 되어 있을 경우에만 임시저장 로직을 진행한다. if (this.consentCommandCtrl.getTempSaveButton()) { this.consentCommandCtrl.setTempSaveButton(false); this.OnWrittenTempSaveFile(value); this.consentCommandCtrl.setTempSaveButton(true); this.eFormViewerCtrl.ConfirmSave(true, ""); } } if (eventCode.Equals("PRINT_COMPLETE")) { this.consentCommandCtrl.OnPrint(value); } 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; } } } 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()); } } } public void preParamClean() { if (this.ConsentExecuteInfo.ContainsKey("startFormCd") && !string.IsNullOrEmpty(this.ConsentExecuteInfo["startFormCd"])) { this.ConsentExecuteInfo["startFormCd"] = string.Empty; } // consentCommandCtrl.fosOpenSequence = null; } void IConsentMain.ReInitializeViewer() { this.eFormViewerCtrl.ReInitializeViewer(); this.viewStatus = false; } public void OnProcessCmdKey(Keys keyData) { } } }