ConsentMainControl.cs.svn-base 75 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Windows.Forms;
  4. using CLIP.eForm.Consent.Common;
  5. using System.Reflection;
  6. using System.Threading;
  7. using System.Xml;
  8. using System.IO;
  9. using System.ComponentModel;
  10. using System.Configuration;
  11. using System.Drawing;
  12. using CLIP.eForm.Consent.UI.ConsentSvcRef;
  13. using ClipSoft.eForm.Base.Dialog;
  14. namespace CLIP.eForm.Consent.UI {
  15. /// <summary>
  16. /// 동의서 관리 메인 컨트롤 클래스
  17. /// </summary>
  18. /// <remarks>
  19. /// <p>[설계자]</p>
  20. /// <p> 클립소프트 연구소 홍지철 (jchong@clipsoft.co.kr)</p>
  21. /// <p>[원본 작성자]</p>
  22. /// <p> 클립소프트 기술부 이창훈 (chlee@clipsoft.co.kr)</p>
  23. /// <p>[수정 작성자]</p>
  24. /// <p> 클립소프트 기술부 이인희</p>
  25. /// <p>----------------------------------------------------------------------------------------</p>
  26. /// <p>[HISTORY]</p>
  27. /// <p> 2015-07-30 : 최초작성</p>
  28. /// <p>----------------------------------------------------------------------------------------</p>
  29. /// </remarks>
  30. public partial class ConsentMainControl : UserControl, IConsentMainCtrl, IConsentMain {
  31. // 사용되지 않음
  32. //private string currentFormGuid = string.Empty;
  33. private ConsentSvcRef.ConsentSvcSoapClient consentWebService;
  34. private HospitalSvcRef.HospitalSvcSoapClient hospitalWebService;
  35. [Browsable(false)]
  36. public ConsentSvcRef.ConsentSvcSoapClient ConsentWebService { get { return consentWebService; } }
  37. [Browsable(false)]
  38. public HospitalSvcRef.HospitalSvcSoapClient HospitalWebService { get { return hospitalWebService; } }
  39. public string PluginModuleName { get; set; }
  40. private Dictionary<string, string> outputDataDic = null;
  41. private Dictionary<string, object> processResultValues = new Dictionary<string, object>();
  42. public Dictionary<string, string> ConsentExecuteInfo { get; set; }
  43. public Dictionary<string, string> PluginExecuteInfo { get; set; }
  44. public Dictionary<string, object> ProcessResultValues { get { return processResultValues; } }
  45. public List<ConsentVO> PrintInfoList { get; set; }
  46. public event EventHandler OnLoadPartControls;
  47. public event EventHandler OnResizeReviewConsent;
  48. public event EventHandler OnVisibleEFormControl;
  49. public event EventHandler OnInvisibleEFormControl;
  50. public event ProcessResultHandler ProcessResult;
  51. public delegate void ProcessResultHandler(string result);
  52. public object mCallParm = null;
  53. private static bool startform = true;
  54. public bool printSaveStatus { get; set; }
  55. public int multiPrintPlanCnt { get; set; }
  56. public int multiPrintExecCnt { get; set; }
  57. public bool saveClickPoint { get; set; } // true : 메인창, false : 듀얼뷰어창
  58. public bool checkAutoPrint { get; set; } // true : 입실저장 자동출력, false : 수동출력
  59. public int agentCallPrintCnt { get; set; }
  60. public int printConsentCount = 1;
  61. // 원무 서식 인증서 pass 여부
  62. // 경북대병원 dependency
  63. public bool shouldPassCertify = false;
  64. /// <summary>
  65. /// Gets or sets the call parameter.
  66. /// </summary>
  67. /// <value>
  68. /// The call parameter.
  69. /// </value>
  70. object IConsentMainCtrl.CallParam {
  71. get {
  72. return mCallParm;
  73. }
  74. set {
  75. mCallParm = value;
  76. }
  77. }
  78. /// <summary>
  79. /// 세션을 체크하기 위한 내부 클래스
  80. /// </summary>
  81. private class MessageFilterClass : IMessageFilter {
  82. const int WM_KEYDOWN = 0x100; // 키보드 입력
  83. const int WM_LBUTTONDOWN = 0x0201; // 마우스 입력
  84. private DateTime lastInput;
  85. private int sesstionTimeout;
  86. /// <summary>
  87. /// 생성자, 반드시 이 생성자를 사용 할 것
  88. /// </summary>
  89. /// <param name="now">현재 시간</param>
  90. /// <param name="sessionTimeout">세션 타임아웃</param>
  91. public MessageFilterClass(DateTime now, string sessionTimeout) {
  92. this.lastInput = now;
  93. this.sesstionTimeout = Convert.ToInt32(sessionTimeout);
  94. }
  95. bool checkUseTime(DateTime current) {
  96. bool needToLogOut = false;
  97. // 현재시간과 마지막입력시간의 차를 구한다
  98. TimeSpan delta = current.Subtract(lastInput);
  99. // 세션시간 이상일 경우
  100. if(delta.Minutes >= this.sesstionTimeout) {
  101. needToLogOut = true;
  102. } else {
  103. lastInput = current;
  104. }
  105. return needToLogOut;
  106. }
  107. bool IMessageFilter.PreFilterMessage(ref Message m) {
  108. bool logout = false;
  109. switch (m.Msg) {
  110. case WM_LBUTTONDOWN:
  111. case WM_KEYDOWN:
  112. logout = checkUseTime(DateTime.Now);
  113. break;
  114. }
  115. if (logout) {
  116. SessionLogout();
  117. }
  118. // 이벤트를 전달하기 위해서는 false 로 리턴
  119. return false;
  120. }
  121. }
  122. /// <summary>
  123. /// 세선 타임아웃일 경우 로그아웃을 하기 위한 static 메서드
  124. /// </summary>
  125. private static void SessionLogout() {
  126. System.Diagnostics.Process[] processes = System.Diagnostics.Process.GetProcessesByName("CLIP.e-Form.Consent.WinAgent");
  127. if(processes.Length > 0) {
  128. MessageBox.Show("사용시간이 만료되어 종료합니다.");
  129. processes[0].Kill();
  130. }
  131. }
  132. /// <summary>
  133. /// Initializes a new instance of the <see cref="ConsentMainControl"/> class.
  134. /// </summary>
  135. /// <param name="callParam">The call parameter.</param>
  136. public ConsentMainControl(object callParam) {
  137. InitializeComponent();
  138. ToolTip _toolTip = new ToolTip();
  139. _toolTip.AutoPopDelay = 5000;
  140. _toolTip.InitialDelay = 0;
  141. _toolTip.ReshowDelay = 0;
  142. _toolTip.ShowAlways = true;
  143. // 도움말 버튼 비활성화
  144. //_toolTip.SetToolTip(this.btnHelp, "도움말");
  145. //MessageBox.Show("waiting for debugging...");
  146. // 실행 정보 데이터셋 초기화
  147. ConsentExecuteInfo = new Dictionary<string, string> {
  148. { "dutinstcd", string.Empty }, // 기관코드
  149. { "userId", string.Empty },
  150. { "userName", string.Empty },
  151. { "loginUserId", string.Empty },
  152. { "loginUserName", string.Empty },
  153. { "userDeptCd", string.Empty },
  154. { "userDeptName", string.Empty },
  155. { "userSupportDeptCd", string.Empty },
  156. { "userSupportBaseCd", string.Empty },
  157. { "patientId", string.Empty },
  158. { "patientOrdtype", string.Empty },
  159. { "patientClnDept", string.Empty },
  160. { "patientClnDate", string.Empty },
  161. { "patientClnDxNm", string.Empty }, // 진단명
  162. { "cretno", string.Empty },
  163. { "opRsrvNo", string.Empty },
  164. { "enablePatientList", string.Empty }, // 우측 환자 목록 뷰 활성화 여부
  165. { "enableConsentList", string.Empty }, // 좌측 동의서 목록 뷰 활성화 여부
  166. { "targetService", string.Empty }, // 대상 서비스 명(eg, DEV, REAL)
  167. // { "startFormCd", string.Empty },
  168. // { "printList", string.Empty }, // 다중 출력 목록
  169. { "formCd", string.Empty },
  170. { "ocrCd", string.Empty },
  171. // { "tempSave", string.Empty },
  172. { "printYN", string.Empty },
  173. { "printCount", string.Empty },
  174. { "printIP", string.Empty },
  175. { "prntCnt", string.Empty },
  176. { "userIOFlag", "O" }, // 사용자 탭 설정
  177. // { "readOnly", string.Empty },
  178. { "SpecDoctorYN", string.Empty },
  179. { "ContStartDate", string.Empty }, // 약정 시작일
  180. { "ContEndDate", string.Empty }, // 약정 종료일
  181. { "RoomCapa", string.Empty }, // 병실 정원
  182. { "ContTelNo", string.Empty }, // ContStartDate
  183. { "ContStaff1Name", string.Empty }, // 원무 담당자
  184. { "ContStaff2Name", string.Empty }, // 원무 팀장
  185. { "ContStaff3Name", string.Empty }, // 원무 과장
  186. { "CardNo", string.Empty } // 카드 번호
  187. //{ "dutinstcd", string.Empty },
  188. //{ "userNo", string.Empty },
  189. //{ "loginUserNo", string.Empty },
  190. //{ "userName", string.Empty },
  191. //{ "loginUserName", string.Empty },
  192. //{ "userDeptCd", string.Empty },
  193. //{ "userDeptName", string.Empty },
  194. //{ "patientNo", string.Empty },
  195. //{ "visitType", string.Empty },
  196. //{ "clnDept", string.Empty },
  197. //{ "clnDate", string.Empty },
  198. //{ "cretno", string.Empty },
  199. //{ "clnDxNm", string.Empty },
  200. //{ "opRsrvNo", string.Empty },
  201. //{ "useListView", string.Empty },
  202. //{ "patientListView", string.Empty },
  203. //{ "startFormCd", string.Empty },
  204. //{ "printAct", string.Empty },
  205. //{ "printList", string.Empty },
  206. //{ "formCd", string.Empty },
  207. //{ "ocrTag", string.Empty },
  208. //{ "tempSave", string.Empty },
  209. //{ "printYN", string.Empty },
  210. //{ "printCount", string.Empty },
  211. //{ "printIP", string.Empty },
  212. //{ "prntCnt", string.Empty },
  213. //{ "userIOFlag", "O" },
  214. //{ "sysInstNm", string.Empty },
  215. //{ "readOnly", string.Empty },
  216. //{ "SpecDoctorYN", string.Empty },
  217. //{ "ContStartDate", string.Empty },
  218. //{ "ContEndDate", string.Empty },
  219. //{ "RoomCapa", string.Empty },
  220. //{ "ContTelNo", string.Empty },
  221. //{ "ContStaff1Name", string.Empty },
  222. //{ "ContStaff2Name", string.Empty },
  223. //{ "ContStaff3Name", string.Empty },
  224. //{ "CardNo", string.Empty }
  225. };
  226. PluginExecuteInfo = new Dictionary<string, string>();
  227. // 넘겨받은 callParam 를 디코딩 한다
  228. InitParamSetting(callParam);
  229. SetWebServiceUrlAndTimeout();
  230. string sessionTimeout = "30";
  231. if (hospitalWebService != null) {
  232. // 세션 타임아웃을 가져온다
  233. sessionTimeout = hospitalWebService.getSessionTime("101");
  234. }
  235. string userId = ConsentExecuteInfo["userId"];
  236. hospitalWebService.userLoginOutLog(userId, "LOGIN", "PC", Common.getMacAddress());
  237. MessageFilterClass messageFilter = new MessageFilterClass(DateTime.Now, sessionTimeout);
  238. Application.AddMessageFilter(messageFilter);
  239. this.PluginModuleName = ConfigurationManager.AppSettings["UIPluginAssembly"];
  240. }
  241. /// <summary>
  242. /// Gets a value indicating whether this instance has vertical monitor.
  243. /// </summary>
  244. /// <value>
  245. /// <c>true</c> if this instance has vertical monitor; otherwise, <c>false</c>.
  246. /// </value>
  247. public static bool HasMultipleMonitor {
  248. get {
  249. if (Screen.AllScreens.Length > 1) {
  250. return true;
  251. }
  252. return false;
  253. }
  254. }
  255. /// <summary>
  256. /// 주어진 서버 이름으로 설정파일을 로딩 한다
  257. /// </summary>
  258. /// <param name="pServerName">로드 할 서버 설정 파일</param>
  259. /// <returns></returns>
  260. public static Dictionary<string, string> GetConfigDictionary(string pServerName) {
  261. Dictionary<string, string> result = new Dictionary<string, string>();
  262. /*
  263. XmlDocument configXml = new XmlDocument();
  264. configXml.Load(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + string.Format("/CLIP.Consent.xml"));
  265. XmlNodeList addNodes = configXml.SelectNodes("configuration/settings/add");
  266. foreach (XmlNode xmlNode in addNodes) {
  267. if (xmlNode.Attributes["key"].InnerText == "serviceTarget") {
  268. serviceTarget = ((XmlCDataSection)xmlNode.ChildNodes[0]).InnerText;
  269. }
  270. }
  271. */
  272. XmlDocument configXml = new XmlDocument();
  273. configXml.Load(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + string.Format("/CLIP.Consent-{0}.xml", pServerName));
  274. XmlNodeList addNodes = configXml.SelectNodes("configuration/settings/add");
  275. foreach (XmlNode xmlNode in addNodes) {
  276. result.Add(xmlNode.Attributes["key"].InnerText, ((XmlCDataSection) xmlNode.ChildNodes[0]).InnerText);
  277. }
  278. return result;
  279. }
  280. /// <summary>
  281. /// childControl의 부모와 그의 부모들에서 IConsentMain 인터페이스를 구현하는 클래스를 찾는다.
  282. /// </summary>
  283. /// <param name="childControl"></param>
  284. /// <returns></returns>
  285. public static IConsentMain GetConsentMainInterface(Control childControl) {
  286. if (childControl.Parent == null) {
  287. return null;
  288. } else {
  289. if (childControl.Parent is IConsentMain) {
  290. return childControl.Parent as IConsentMain;
  291. } else {
  292. return GetConsentMainInterface(childControl.Parent);
  293. }
  294. }
  295. }
  296. /// <summary>
  297. /// Sets the web service URL and timeout.
  298. /// </summary>
  299. private void SetWebServiceUrlAndTimeout() {
  300. try {
  301. Dictionary<string, string> configDic = GetConfigDictionary(ConsentExecuteInfo["sysInstNm"]);
  302. this.PluginExecuteInfo.Add("consentSvcUrl", configDic["consentSvcUrl"]);
  303. this.PluginExecuteInfo.Add("hospitalSvcUrl", configDic["hospitalSvcUrl"]);
  304. this.PluginExecuteInfo.Add("formServiceUrl", configDic["formServiceUrl"]);
  305. this.PluginExecuteInfo.Add("baseConsentSvcURL", configDic["baseConsentSvcURL"]);
  306. this.PluginExecuteInfo.Add("imageUploadServerUrl", configDic["imageUploadServerUrl"]);
  307. this.PluginExecuteInfo.Add("signatureServerUrl", configDic["signatureServerUrl"]);
  308. this.PluginExecuteInfo.Add("signatureServerPort", configDic["signatureServerPort"]);
  309. this.PluginExecuteInfo.Add("imageUploadPath", configDic["imageUploadPath"]);
  310. this.PluginExecuteInfo.Add("ConsentSearchStartDate", configDic["ConsentSearchStartDate"]);
  311. this.PluginExecuteInfo.Add("timeOut", "10");
  312. this.consentWebService = WebMethodCommon.GetConsentWebService(configDic["consentSvcUrl"]);
  313. this.hospitalWebService = WebMethodCommon.GetHospitalWebService(configDic["hospitalSvcUrl"]);
  314. } catch (Exception ex) {
  315. throw ex;
  316. }
  317. }
  318. public ConsentSvcRef.ConsentSvcSoapClient getConsentWebService() {
  319. return this.consentWebService;
  320. }
  321. public HospitalSvcRef.HospitalSvcSoapClient getHospitalWebService() {
  322. return this.hospitalWebService;
  323. }
  324. /// <summary>
  325. /// Initializes the parameters.
  326. /// </summary>
  327. public void initParams() {
  328. InitParamSetting(mCallParm);
  329. }
  330. /// <summary>
  331. /// 화면 초기화 시 수행해야 할 이벤트 처리
  332. /// </summary>
  333. /// <param name="e"></param>
  334. protected override void OnLoad(EventArgs e) {
  335. try {
  336. // 프로그램을 닫으면 Agent 도 종료되게끔
  337. //this.Parent.Disposed += Parent_Disposed;
  338. if (string.IsNullOrEmpty(this.PluginModuleName)) {
  339. return;
  340. }
  341. // 사용자 고정 모니터 설정
  342. MoniterViewSetting(false);
  343. if (ConsentExecuteInfo["printYN"].Equals("Y")) {
  344. this.Parent.Visible = false;
  345. }
  346. // 기존 인증서 삭제
  347. SignatureConfig sign = new SignatureConfig();
  348. if (!startform) {
  349. startform = false;
  350. sign.SignAllClear();
  351. }
  352. // eFormViewer 컨트롤 초기화
  353. InitEFormControl();
  354. InvokeDelayedLoadEvent();
  355. this.eFormViewerCtrl.GetCurrentViewer().UIUpdateOnDrawing
  356. += new Viewer.UIUpdateOnDrawingHandler(ConsentMainControl_UIUpdateOnDrawing);
  357. base.OnLoad(e);
  358. // dbs227
  359. // TODO 디버그 용 메시지 박스
  360. //Boolean openDualView = (this.consentWebService.getDualViewMode(ConsentExecuteInfo["dutinstcd"],
  361. // ConsentExecuteInfo["ipaddr"]) == "Y") ? true : false;
  362. //MessageBox.Show("Waiting for debugging at " + ConsentExecuteInfo["ipaddr"]);
  363. // 키보드 마우스 입력 이벤트
  364. // Ku2.0 연동
  365. GetConsentListByFormcd();
  366. // 폰트 설치여부 체크
  367. string familyName;
  368. string familyList = "";
  369. FontFamily[] fontFamilies;
  370. System.Drawing.Text.InstalledFontCollection installedFontCollection = new System.Drawing.Text.InstalledFontCollection();
  371. fontFamilies = installedFontCollection.Families;
  372. int count = fontFamilies.Length;
  373. int fontCheck = 0;
  374. for (int j = 0; j < count; ++j) {
  375. familyName = fontFamilies[j].Name;
  376. familyList = familyList + familyName;
  377. familyList = familyList + ", ";
  378. if (fontCheck != 1 && (familyName == "나눔고딕" || familyName == "NanumGothic")) {
  379. fontCheck = fontCheck + 1;
  380. }
  381. if (fontCheck < 100 && (familyName == "나눔고딕 ExtraBold" || familyName == "NanumGothicExtraBold" || familyName == "나눔고딕 아주 굵게")) {
  382. fontCheck = fontCheck + 10;
  383. }
  384. }
  385. // 폰트 설치 실행
  386. if (fontCheck < 11) {
  387. System.Diagnostics.Process UserProcess = new System.Diagnostics.Process();
  388. UserProcess.StartInfo.UseShellExecute = true;
  389. //UserProcess.StartInfo.FileName = "NanumFontSetup.exe";
  390. //UserProcess.StartInfo.WorkingDirectory = Path.GetDirectoryName(Application.StartupPath + "/Font/");
  391. // 폰트가 없어 최초 실행 시 에러 발생 부분 수정
  392. UserProcess.StartInfo.FileName = "FontInstall.exe";
  393. UserProcess.StartInfo.WorkingDirectory = Path.GetDirectoryName(Application.StartupPath + "\\");
  394. UserProcess.StartInfo.CreateNoWindow = true;
  395. UserProcess.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
  396. UserProcess.Start();
  397. UserProcess.WaitForExit();
  398. }
  399. string sTempPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\Clipsoft\ClipSoft.eForm.Viewer\DataTemp\";
  400. if (Directory.Exists(sTempPath)) {
  401. string[] filePaths = Directory.GetFiles(sTempPath);
  402. foreach (string fileName in filePaths) {
  403. FileInfo fileInfo = new FileInfo(fileName);
  404. if (fileInfo.Extension.Equals(".ept") || fileInfo.Extension.Equals(".jpg") || fileInfo.Extension.Equals(".xml")) {
  405. fileInfo.Delete();
  406. }
  407. }
  408. }
  409. } catch (Exception ex) {
  410. // 데이터베이스 저장 기능 추가로 해당 기능 삭제
  411. //File.WriteAllText(string.Format(@"{0}\eConsentLog\{1}_Agent.txt", Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
  412. // , DateTime.Now.ToString("yyyyMMdd_HHmmss"))
  413. // , ex.ToString());
  414. System.Diagnostics.Trace.WriteLine(string.Format("CLIP.eForm error: {0}", ex.Message));
  415. if (this.Parent is System.Windows.Forms.Form) {
  416. ((Form) this.Parent).DialogResult = DialogResult.Cancel;
  417. ((Form) this.Parent).Close();
  418. }
  419. }
  420. }
  421. // 화면이 종료될때 Agent도 종료되도록 수정
  422. /// <summary>
  423. /// Handles the Disposed event of the Parent control.
  424. /// </summary>
  425. /// <param name="sender">The source of the event.</param>
  426. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  427. private void Parent_Disposed(object sender, EventArgs e) {
  428. foreach (Form form in Application.OpenForms) {
  429. if (form.Name.Equals("ConsentAgentForm")) {
  430. string userId = ConsentExecuteInfo["userId"];
  431. hospitalWebService.userLoginOutLog(userId, "LOGOFF", "PC", Common.getMacAddress());
  432. form.Dispose();
  433. break;
  434. }
  435. }
  436. }
  437. // 화면이 종료될때 Agent도 종료되도록 수정
  438. /// <summary>
  439. /// Parents the disposed.
  440. /// </summary>
  441. public void Parent_Disposed() {
  442. foreach (Form form in Application.OpenForms) {
  443. if (form.Name.Equals("ConsentAgentForm")) {
  444. form.Dispose();
  445. break;
  446. }
  447. }
  448. }
  449. /// <summary>
  450. /// OCX 로 부터 넘겨 받은 파라미터를 decode
  451. /// </summary>
  452. /// <param name="pCallParm">EXEC_OPT 로 넘어온 파라미터 목록</param>
  453. /// <exception cref="Exception">CallParam 미전달</exception>
  454. private void InitParamSetting(object pCallParm) {
  455. try {
  456. if (pCallParm != null) {
  457. Dictionary<string, object> callParam = pCallParm as Dictionary<string, object>;
  458. if (callParam != null && callParam.Count < 2) {
  459. if (callParam["CALL_PARAMS"] != null) {
  460. pCallParm = callParam["CALL_PARAMS"] as object;
  461. }
  462. }
  463. foreach (KeyValuePair<string, object> callKV in pCallParm as Dictionary<string, object>) {
  464. // 사용자 정보
  465. if (callKV.Key != null && !string.IsNullOrEmpty(callKV.Key.ToString()) && callKV.Key.ToString() == "USER_INFO") {
  466. foreach (KeyValuePair<string, object> userKV in callKV.Value as Dictionary<string, object>) {
  467. if (userKV.Key != null && !string.IsNullOrEmpty(userKV.Key.ToString()) && userKV.Key.ToString() == "USER_ID") {
  468. if (userKV.Value != null) {
  469. ConsentExecuteInfo["userId"] = userKV.Value.ToString();
  470. ConsentExecuteInfo["loginUserId"] = userKV.Value.ToString();
  471. }
  472. } else if (userKV.Key != null && !string.IsNullOrEmpty(userKV.Key.ToString()) && userKV.Key.ToString() == "DUTINSTCD") {
  473. if (userKV.Value != null) {
  474. ConsentExecuteInfo["dutinstcd"] = userKV.Value.ToString();
  475. }
  476. } else if (userKV.Key != null && !string.IsNullOrEmpty(userKV.Key.ToString()) && userKV.Key.ToString() == "USER_NAME") {
  477. if (userKV.Value != null) {
  478. ConsentExecuteInfo["userName"] = userKV.Value.ToString();
  479. ConsentExecuteInfo["loginUserName"] = userKV.Value.ToString();
  480. }
  481. } else if (userKV.Key != null && !string.IsNullOrEmpty(userKV.Key.ToString()) && userKV.Key.ToString() == "USER_DEPTCD") {
  482. if (userKV.Value != null) {
  483. ConsentExecuteInfo["userDeptCd"] = userKV.Value.ToString();
  484. }
  485. } else if (userKV.Key != null && !string.IsNullOrEmpty(userKV.Key.ToString()) && userKV.Key.ToString() == "USER_DEPTNM") {
  486. if (userKV.Value != null) {
  487. ConsentExecuteInfo["userDeptName"] = userKV.Value.ToString();
  488. }
  489. } else if (userKV.Key != null && !string.IsNullOrEmpty(userKV.Key.ToString()) && userKV.Key.ToString() == "USER_SUPPORT_DEPT_CD") {
  490. if (userKV.Value != null) {
  491. ConsentExecuteInfo["userSupportDeptCd"] = userKV.Value.ToString();
  492. }
  493. } else if (userKV.Key != null && !string.IsNullOrEmpty(userKV.Key.ToString()) && userKV.Key.ToString() == "USER_SUPPORT_BASE_CD") {
  494. if (userKV.Value != null) {
  495. ConsentExecuteInfo["userSupportBaseCd"] = userKV.Value.ToString();
  496. }
  497. }
  498. //
  499. }
  500. }
  501. // 환자 정보
  502. if (callKV.Key != null && !string.IsNullOrEmpty(callKV.Key.ToString()) && callKV.Key.ToString() == "PATIENT_INFO") {
  503. foreach (KeyValuePair<string, object> patientKV in callKV.Value as Dictionary<string, object>) {
  504. if (patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "PATIENT_ID") {
  505. if (patientKV.Value != null) ConsentExecuteInfo["patientId"] = patientKV.Value.ToString();
  506. }
  507. if (patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "PATIENT_ORDTYPE") {
  508. if (patientKV.Value != null) ConsentExecuteInfo["patientOrdtype"] = patientKV.Value.ToString();
  509. }
  510. if (patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "PATIENT_CLN_DEPT") {
  511. if (patientKV.Value != null) ConsentExecuteInfo["patientClnDept"] = patientKV.Value.ToString();
  512. }
  513. if (patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "PATIENT_CLN_DATE") {
  514. if (patientKV.Value != null) ConsentExecuteInfo["patientClnDate"] = patientKV.Value.ToString();
  515. }
  516. if (patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "CRETNO") {
  517. if (patientKV.Value != null) ConsentExecuteInfo["cretno"] = patientKV.Value.ToString();
  518. }
  519. // 진단명
  520. if (patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "PATIENT_CLN_DX_NM") {
  521. if (patientKV.Value != null) ConsentExecuteInfo["patientClnDxNm"] = patientKV.Value.ToString();
  522. }
  523. if (patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "OPRSRVNO") {
  524. if (patientKV.Value != null) ConsentExecuteInfo["opRsrvNo"] = patientKV.Value.ToString();
  525. }
  526. }
  527. }
  528. if (callKV.Key != null && !string.IsNullOrEmpty(callKV.Key.ToString()) && callKV.Key.ToString() == "EXEC_OPT") {
  529. // 화면 설정 정보
  530. foreach (KeyValuePair<string, object> execKV in callKV.Value as Dictionary<string, object>) {
  531. if (execKV.Key != null && !string.IsNullOrEmpty(execKV.Key.ToString()) && execKV.Key.ToString() == "ENABLE_CONSENT_LIST") {
  532. if (execKV.Value != null) ConsentExecuteInfo["enableConsentList"] = execKV.Value.ToString(); // 동의서 리스트 사용 유무
  533. }
  534. if (execKV.Key != null && !string.IsNullOrEmpty(execKV.Key.ToString()) && execKV.Key.ToString() == "ENABLE_PATIENT_LIST") {
  535. if (execKV.Value != null) ConsentExecuteInfo["enablePatientList"] = execKV.Value.ToString(); // 환자 리스트 사용 유무
  536. }
  537. // 대가대 병원 초기 설정 없음
  538. if (execKV.Key != null && !string.IsNullOrEmpty(execKV.Key.ToString()) && execKV.Key.ToString() == "START_FORM_CD") {
  539. if (execKV.Value != null) ConsentExecuteInfo["startFormCd"] = execKV.Value.ToString(); // 시작 FORM ID
  540. }
  541. // 대가대 병원 초기 설정 없음
  542. if (execKV.Key != null && !string.IsNullOrEmpty(execKV.Key.ToString()) && execKV.Key.ToString() == "PTNT_ACT") {
  543. if (execKV.Value != null) ConsentExecuteInfo["printAct"] = execKV.Value.ToString(); // 초기 프린트
  544. }
  545. // 여러 서식 출력
  546. // 대가대 병원 사용되지 않음
  547. //eg, {PRINT_LIST: [{START_FORM_CD: VALUE, PTNT_NO: VALUE, VISIT_TYPE: VALUE, CLN_DATE: VALUE, CLN_DEPT:VAELU, PRINT_CNT: VALUE, CRETNO: VALUE}, ...]}
  548. if (execKV.Key != null && !string.IsNullOrEmpty(execKV.Key.ToString()) && execKV.Key.ToString() == "PRINT_LIST") {
  549. if (execKV.Value != null) {
  550. if (execKV.Value is List<object> PatientList && PatientList.Count > 0) {
  551. PrintInfoList = new List<ConsentVO>();
  552. ConsentVO consentVO = new ConsentVO();
  553. for (int i = 0; i < PatientList.Count; i++) {
  554. consentVO = new ConsentVO {
  555. printCnt = -1
  556. };
  557. foreach (KeyValuePair<string, object> callOrderKV in PatientList[i] as Dictionary<string, object>) {
  558. if (callOrderKV.Key != null && !string.IsNullOrEmpty(callOrderKV.Key.ToString()) && callOrderKV.Value != null) {
  559. if (callOrderKV.Key.ToString() == "START_FORM_CD") consentVO.formCode = callOrderKV.Value.ToString(); // 출력 서식코드
  560. //if (callOrderKV.Key.ToString() == "PTNT_NO") consentVO.PatientCode = callOrderKV.Value.ToString(); // 환자번호
  561. //if (callOrderKV.Key.ToString() == "VISIT_TYPE") consentVO.VisitType = callOrderKV.Value.ToString(); // 내원구분
  562. //if (callOrderKV.Key.ToString() == "CLN_DATE") consentVO.ClnDate = callOrderKV.Value.ToString(); // 진료일자
  563. //if (callOrderKV.Key.ToString() == "CLN_DEPT") consentVO.ClnDeptCd = callOrderKV.Value.ToString(); // 진료과
  564. if (callOrderKV.Key.ToString() == "PRINT_CNT") {
  565. int.TryParse(callOrderKV.Value.ToString(), out int PrntCnt);
  566. consentVO.printCnt = PrntCnt; // 출력 카운트
  567. }
  568. if (callOrderKV.Key.ToString() == "CRETNO") {
  569. int.TryParse(callOrderKV.Value.ToString(), out int cretno);
  570. //consentVO.Cretno = cretno; // 차트번호
  571. }
  572. }
  573. }
  574. PrintInfoList.Add(consentVO);
  575. }
  576. if (execKV.Value != null) ConsentExecuteInfo["printList"] = PrintInfoList.Count.ToString(); // 출력 데이터
  577. }
  578. }
  579. }
  580. if (execKV.Key != null && !string.IsNullOrEmpty(execKV.Key.ToString()) && execKV.Key.ToString() == "FORMCD") { // 서식 코드
  581. if (execKV.Value != null) ConsentExecuteInfo["formCd"] = execKV.Value.ToString();
  582. }
  583. if (execKV.Key != null && !string.IsNullOrEmpty(execKV.Key.ToString()) && execKV.Key.ToString() == "OCRCD") { // OCR 태그
  584. if (execKV.Value != null) ConsentExecuteInfo["ocrCd"] = execKV.Value.ToString();
  585. }
  586. if (execKV.Key != null && !string.IsNullOrEmpty(execKV.Key.ToString()) && execKV.Key.ToString() == "TEMP_SAVE") { // 임시 저장 (Ku2.0 연동)
  587. if (execKV.Value != null) ConsentExecuteInfo["tempSave"] = execKV.Value.ToString();
  588. }
  589. if (execKV.Key != null && !string.IsNullOrEmpty(execKV.Key.ToString()) && execKV.Key.ToString() == "PRINT_YN") { // 출력 여부 (Ku2.0 연동)
  590. if (execKV.Value != null) ConsentExecuteInfo["printYN"] = execKV.Value.ToString();
  591. }
  592. if (execKV.Key != null && !string.IsNullOrEmpty(execKV.Key.ToString()) && execKV.Key.ToString() == "PRINT_CNT") { // 출력 매수 (Ku2.0 연동)
  593. if (execKV.Value != null) ConsentExecuteInfo["printCount"] = execKV.Value.ToString();
  594. }
  595. if (execKV.Key != null && !string.IsNullOrEmpty(execKV.Key.ToString()) && execKV.Key.ToString() == "SYSINSTNM") { // 접속 서버 정보
  596. if (execKV.Value != null) {
  597. string systemName = string.Empty;
  598. // 대가대 병원 시스템 CD
  599. //instCd = execKV.Value.ToString().Contains("교육") ? "DEV101" : "EMR101";
  600. systemName = execKV.Value.ToString();
  601. //instCd = execKV.Value.ToString().Contains("본원") ? "031" : execKV.Value.ToString().Contains("칠곡") ? "032" : string.Empty;
  602. //instCd += execKV.Value.ToString().Contains("교육") ? "edu" : string.Empty;
  603. //instCd = "Dev";
  604. ConsentExecuteInfo["sysInstNm"] = systemName;
  605. }
  606. }
  607. // 보기 전용 여부
  608. // 대가대 병원 초기 설정 없음
  609. if (execKV.Key != null && !string.IsNullOrEmpty(execKV.Key.ToString()) && execKV.Key.ToString() == "READ_ONLY") {
  610. if (execKV.Value != null) ConsentExecuteInfo["readOnly"] = execKV.Value.ToString();
  611. }
  612. }
  613. }
  614. // 원무
  615. if (callKV.Key != null && !string.IsNullOrEmpty(callKV.Key.ToString()) && callKV.Key.ToString() == "PAM_INFO") {
  616. foreach (KeyValuePair<string, object> patientKV in callKV.Value as Dictionary<string, object>) {
  617. if (patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "SPEC_DR_YN") {
  618. if (patientKV.Value != null) ConsentExecuteInfo["SpecDoctorYN"] = patientKV.Value.ToString();
  619. }
  620. if (patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "CONT_START_DT") {
  621. if (patientKV.Value != null) ConsentExecuteInfo["ContStartDate"] = patientKV.Value.ToString();
  622. }
  623. if (patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "CONT_END_DT") {
  624. if (patientKV.Value != null) ConsentExecuteInfo["ContEndDate"] = patientKV.Value.ToString();
  625. }
  626. if (patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "ROOM_CAPA") {
  627. if (patientKV.Value != null) ConsentExecuteInfo["RoomCapa"] = patientKV.Value.ToString();
  628. }
  629. if (patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "CONT_TELNO") {
  630. if (patientKV.Value != null) ConsentExecuteInfo["ContTelNo"] = patientKV.Value.ToString();
  631. }
  632. if (patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "CONT_STAFF1") {
  633. if (patientKV.Value != null) ConsentExecuteInfo["ContStaff1Name"] = patientKV.Value.ToString();
  634. }
  635. if (patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "CONT_STAFF2") {
  636. if (patientKV.Value != null) ConsentExecuteInfo["ContStaff2Name"] = patientKV.Value.ToString();
  637. }
  638. if (patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "CONT_STAFF3") {
  639. if (patientKV.Value != null) ConsentExecuteInfo["ContStaff3Name"] = patientKV.Value.ToString();
  640. }
  641. if (patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "CARD_NO") {
  642. if (patientKV.Value != null) ConsentExecuteInfo["CardNo"] = patientKV.Value.ToString();
  643. }
  644. }
  645. }
  646. }
  647. } else {
  648. throw new Exception("CallParam 미전달");
  649. }
  650. // IP 주소 확인
  651. string printIp = string.Empty;
  652. foreach (System.Net.IPAddress ip in System.Net.Dns.GetHostAddresses(System.Net.Dns.GetHostName())) {
  653. if (ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) {
  654. printIp = ip.ToString();
  655. break;
  656. }
  657. }
  658. // dbs227, 경북대학교병원 ip address 기록
  659. ConsentExecuteInfo["ipaddr"] = printIp;
  660. if (!printIp.Equals(string.Empty)) {
  661. string[] ipArr = printIp.Split(new string[] { "." }, StringSplitOptions.RemoveEmptyEntries);
  662. if (ipArr.Length == 4) {
  663. printIp = string.Format("{0}.{1}", ipArr[2], ipArr[3]);
  664. } else {
  665. printIp = string.Empty;
  666. }
  667. }
  668. ConsentExecuteInfo["printIP"] = printIp;
  669. } catch (Exception ex) {
  670. throw ex;
  671. }
  672. }
  673. private string monitorNo = string.Empty;
  674. /// <summary>
  675. /// 모니터 뷰 설정
  676. /// </summary>
  677. /// <param name="printMode">출력 여부</param>
  678. private void MoniterViewSetting(bool printMode) {
  679. // 출력 모드라면 화면에 나타내지 않는다
  680. if (printMode) {
  681. return;
  682. }
  683. // 로딩 시 사용자 설정 모니터 정보를 불러온다.
  684. string userPrefMonitor = string.Empty;
  685. if(hospitalWebService != null) {
  686. userPrefMonitor = hospitalWebService.getUserPrefMonitor(ConsentExecuteInfo["userId"], ConsentExecuteInfo["dutinstcd"]);
  687. }
  688. int iMoniterNumber = 0;
  689. if (!string.IsNullOrEmpty(userPrefMonitor)) {
  690. //현재 프로그램이 실행되고 있는정보 가져오기: 디버깅 모드라면 bin/debug/프로그램명.exe
  691. FileInfo exefileinfo = new FileInfo(Path.GetDirectoryName(Application.StartupPath));
  692. string path = Path.GetDirectoryName(Application.StartupPath);
  693. string fileName = @"\config.ini"; //파일명
  694. //만약 현재 실행 되는 경로가 아닌 특정한 위치를 원한다면 위에 과정 상관없이 바로 경로셋팅 해 주면 된다. (예: c:\config.ini)
  695. string filePath = path + fileName; //ini 파일 경로
  696. // 만들어 놓았던 iniUtil 객체 생성(생성자 인자로 파일경로 정보 넘겨줌)
  697. iniUtil ini = new iniUtil(filePath);
  698. //이제 ini 객체를 이용해 맘것 사용하면 된다.
  699. string localValue = ini.GetIniValue("DCMC", "MONITER_NUMBER");
  700. // 서버에서 가져온 값과 로컬값이 다른다면 서버값으로 매핑하여 준다.
  701. if (!userPrefMonitor.Equals(localValue)) {
  702. ini.SetIniValue("DCMC", "MONITER_NUMBER", userPrefMonitor);
  703. }
  704. int.TryParse(userPrefMonitor, out iMoniterNumber);
  705. }
  706. monitorNo = userPrefMonitor;
  707. //Point location = Point.Empty;
  708. //int j = 1;
  709. //FormWindowState windowStateBackup;
  710. //foreach (Screen sc in Screen.AllScreens) {
  711. // // 출력할 모니터에 Form 을 생성하여 나타낸다
  712. // if (j == iMoniterNumber) {
  713. // Form parentForm = this.Parent as Form;
  714. // if (parentForm != null) {
  715. // windowStateBackup = parentForm.WindowState;
  716. // Size size = parentForm.Bounds.Size;
  717. // parentForm.WindowState = FormWindowState.Normal;
  718. // parentForm.StartPosition = FormStartPosition.Manual;
  719. // parentForm.ClientSize = new Size(size.Width, size.Height);
  720. // parentForm.Location = new Point(sc.Bounds.Left, sc.Bounds.Top);
  721. // parentForm.WindowState = windowStateBackup;
  722. // }
  723. // break;
  724. // }
  725. // j++;
  726. //}
  727. }
  728. public void setDualViewerOption(string monitorNo) {
  729. if (!string.IsNullOrEmpty(monitorNo)) {
  730. this.eFormViewerCtrl.SetRunOption("DUALVIEWER_DISPLAY_INDEX", monitorNo);
  731. }
  732. }
  733. /// <summary>
  734. /// eFormViewer 컨트롤에 대한 초기화
  735. /// run option 설정
  736. /// </summary>
  737. private void InitEFormControl() {
  738. Screen screen = Screen.FromControl(this);
  739. if (screen.Primary) {
  740. this.eFormViewerCtrl.SetRunOption("DEFAULT_ZOOM_RATE", "pagewidth");
  741. } else {
  742. this.eFormViewerCtrl.SetRunOption("DEFAULT_ZOOM_RATE", "pagewidth");
  743. }
  744. //this.eFormViewerCtrl.SetRunOption("ENABLE_DEBUG_VIEW", "true");
  745. //this.eFormViewerCtrl.SetRunOption("DEFAULT_TOOL_BAR_VISIBLE", "true");
  746. this.eFormViewerCtrl.SetRunOption("USE_CREDITCARD_SIGNPAD", "false");
  747. this.eFormViewerCtrl.SetRunOption("DEFAULT_TOOL_BAR_VISIBLE", "false");
  748. this.eFormViewerCtrl.SetRunOption("SET_EXTERNAL_CONTROL_DEFINED_PATH", this.PluginExecuteInfo["formServiceUrl"]);
  749. this.eFormViewerCtrl.SetRunOption("USE_EITHER_SIDE_MOVE_BUTTON", "true");
  750. // dbs227, 경북대학교병원 옵션, 형광펜 색으로
  751. this.eFormViewerCtrl.SetRunOption("DRAWING_PEN", "{ \"width\":\"9\",\"color\":{ \"a\":\"50\", \"r\":\"255\", \"g\":\"255\", \"b\":\"1\"} }");
  752. this.eFormViewerCtrl.SetRunOption("SET_VISIBLE_BUTTONS", "PAGE_ATTACH=true");
  753. this.eFormViewerCtrl.SetRunOption("IMAGE_SAVE_OPTION", "{\"dpi\":\"150\",\"gray\":\"false\",\"encode\":\"jpeg\",\"base-index\":\"1\",\"quality\":\"100\"}");
  754. // dbs227, 경북대학교병원 요청사항
  755. // 마우스 우클릭 그리기 모드 변경
  756. this.eFormViewerCtrl.SetRunOption("SET_MOUSE_RIGHT_CHANGE_MODE", "Drawing");
  757. // V2 버전 런 옵션
  758. this.eFormViewerCtrl.SetRunOption("RUN_AS_REPOSITORY_V2", "true");
  759. if (HasMultipleMonitor) {
  760. this.eFormViewerCtrl.SetRunOption("DUALVIEWER_TOOL_BAR_SIZE", "32");
  761. if (!string.IsNullOrEmpty(monitorNo)) {
  762. this.eFormViewerCtrl.SetRunOption("DUALVIEWER_DISPLAY_INDEX", monitorNo);
  763. //this.eFormViewerCtrl.SetRunOption("DUALVIEWER_DISPLAY_INDEX", "1");
  764. }
  765. this.eFormViewerCtrl.SetRunOption("RUN_AS_DUALVIEWER", "CLIP.eForm.DualViewer.dll");
  766. // this.eFormViewerCtrl.SetRunOption("READ_ONLY", "true");
  767. this.eFormViewerCtrl.SetRunOption("DUALVIEWER_TO_ACTIVATE_CONTROLS", "true");
  768. this.eFormViewerCtrl.SetRunOption("SET_VISIBLE_DUALVIEWER_TOOLSTRIP_MENU", "true");
  769. this.eFormViewerCtrl.SetRunOption("DUALVIEWER_TOOL_BAR_ENABLE", "true");
  770. // 툴바 위치 조절(true : 상단, false : 하단)
  771. this.eFormViewerCtrl.SetRunOption("USE_DUALVIEWER_TOOL_BAR_TOP", "true");
  772. // 가상키보드 사용 여부
  773. this.eFormViewerCtrl.SetRunOption("DUALVIEWER_VIRTUAL_KEYBOARD_VISIBLE", "true");
  774. // 관리자 권한 실행 저장 여부
  775. this.eFormViewerCtrl.SetRunOption("USE_ADMIN_PRIVILEGES_SAVE_EXECUTE", "false");
  776. this.eFormViewerCtrl.SetRunOption("DUALVIEWER_RESOLUTION", "{\"width\":\"768\",\"height\":\"1024\"}");
  777. }
  778. }
  779. /// <summary>
  780. /// Invokes the delayed load event.
  781. /// </summary>
  782. private void InvokeDelayedLoadEvent() // TODO: 리팩터링 대상 comment by jchong 2016.06.11
  783. {
  784. if (this.OnLoadPartControls != null) {
  785. Application.DoEvents();
  786. Thread.Sleep(1);
  787. OnLoadPartControls.Invoke(this, new EventArgs());
  788. }
  789. }
  790. /// <summary>
  791. /// </summary>
  792. /// <param name="msg">A <see cref="T:System.Windows.Forms.Message" />, passed by reference, that represents the window message to process.</param>
  793. /// <param name="keyData">One of the <see cref="T:System.Windows.Forms.Keys" /> values that represents the key to process.</param>
  794. /// <returns>
  795. /// true if the character was processed by the control; otherwise, false.
  796. /// </returns>
  797. protected override bool ProcessCmdKey(ref Message msg, Keys keyData) {
  798. if (msg.Msg == 0x100) {
  799. if (keyData == Keys.PageUp) {
  800. this.eFormViewerCtrl.MovePrevPage();
  801. }
  802. if (keyData == Keys.Next) {
  803. this.eFormViewerCtrl.MoveNextPage();
  804. }
  805. }
  806. return base.ProcessCmdKey(ref msg, keyData);
  807. }
  808. /// <summary>
  809. /// Consents the main control UI update on drawing.
  810. /// </summary>
  811. /// <param name="sender">The sender.</param>
  812. /// <param name="undoStackCount">The undo stack count.</param>
  813. /// <param name="redoStackCount">The redo stack count.</param>
  814. /// <param name="totalStrokeCount">The total stroke count.</param>
  815. /// <param name="totalAllPageStrokeCoun">The total all page stroke coun.</param>
  816. void ConsentMainControl_UIUpdateOnDrawing(object sender, int undoStackCount, int redoStackCount, int totalStrokeCount, int totalAllPageStrokeCoun) {
  817. if (undoStackCount > 0) {
  818. this.consentCommandCtrl.EnableUndo = true;
  819. } else {
  820. this.consentCommandCtrl.EnableUndo = false;
  821. }
  822. if (redoStackCount > 0) {
  823. this.consentCommandCtrl.EnableRedo = true;
  824. } else {
  825. this.consentCommandCtrl.EnableRedo = false;
  826. }
  827. if (totalStrokeCount > 0) {
  828. this.consentCommandCtrl.EnableRemoveAll = true;
  829. } else {
  830. this.consentCommandCtrl.EnableRemoveAll = false;
  831. }
  832. }
  833. ConsentListCtrlBase IConsentMain.ConsentListCtrl {
  834. get { return this.consentListCtrl; }
  835. }
  836. PatientInfoCtrlBase IConsentMain.PatientInfoCtrl {
  837. get { return this.patientInfoCtrl; }
  838. }
  839. PatientListCtrlBase IConsentMain.PatientListCtrl {
  840. get { return this.patientListCtrl; }
  841. }
  842. Dictionary<string, string> IConsentMain.ConsentExecuteInfo {
  843. get {
  844. return this.ConsentExecuteInfo;
  845. }
  846. set {
  847. this.ConsentExecuteInfo = value;
  848. }
  849. }
  850. Dictionary<string, string> IConsentMain.PluginExecuteInfo {
  851. get {
  852. return this.PluginExecuteInfo;
  853. }
  854. set {
  855. this.PluginExecuteInfo = value;
  856. }
  857. }
  858. ConsentCommandCtrlBase IConsentMain.ConsentCommandCtrl {
  859. get {
  860. return this.consentCommandCtrl;
  861. }
  862. }
  863. public Dictionary<string, object> ProcessResultValue {
  864. get {
  865. return processResultValues;
  866. }
  867. }
  868. /// <summary>
  869. /// 환자 정보가 바뀌었을때 컨트롤들의 정보를 재조회
  870. /// </summary>
  871. /// <param name="visitType">Type of the visit.</param>
  872. void IConsentMain.UIControlsRefeash(string visitType) {
  873. this.patientInfoCtrl.OnRefeashPartControls(visitType);
  874. this.consentListCtrl.OnRefeashPartControls();
  875. }
  876. /// <summary>
  877. /// 사용자 정보 변경
  878. /// </summary>
  879. /// <param name="pInstCd">근무지기관코드</param>
  880. /// <param name="pUserId">사용자ID</param>
  881. /// <param name="DutPlceCd">근무지부서</param>
  882. void IConsentMain.SetConsentUserInfo(string pInstCd, string pUserId, string DutPlceCd) {
  883. this.patientInfoCtrl.SetConsentUserInfo(pUserId, pInstCd, DutPlceCd);
  884. }
  885. void IConsentMain.ClearPreviewConsent(bool pDoInit) {
  886. consentCommandCtrl.CurrentPreviewConsent = null;
  887. patientInfoCtrl.SetConsentDocumentName("");
  888. if (pDoInit) {
  889. eFormViewerCtrl.ReInitializeViewer();
  890. imageViewCtrl1.Hide();
  891. }
  892. }
  893. void IConsentMain.PreviewConsent(string fos) {
  894. this.pnlCommand.Visible = true;
  895. this.pnlViewer.Visible = false;
  896. this.eFormViewerCtrl.Visible = true;
  897. // 배율정보 설정
  898. consentCommandCtrl.setZoomRate(4);
  899. consentCommandCtrl.setButtonsVisibility(consentCommandCtrl.CurrentTargetPatient.ordtype, consentCommandCtrl.CurrentPreviewConsent.ConsentState);
  900. this.eFormViewerCtrl.OpenFos(fos);
  901. }
  902. void IConsentMain.ClearConsent() {
  903. this.pnlCommand.Visible = true;
  904. this.pnlViewer.Visible = false;
  905. this.eFormViewerCtrl.Visible = true;
  906. this.eFormViewerCtrl.Open();
  907. }
  908. void IConsentMain.ReviewConsent() {
  909. this.pnlCommand.Visible = false;
  910. this.pnlViewer.Visible = true;
  911. this.eFormViewerCtrl.Visible = false;
  912. }
  913. void IConsentMain.setDualViewerButtonOtps(string otps) {
  914. InitEFormControl();
  915. this.eFormViewerCtrl.SetRunOption("SET_DUALVIEWER_VISIBLE_BUTTONS", otps);
  916. }
  917. void IConsentMain.RunConsentDualView() {
  918. this.eFormViewerCtrl.OpenDualViewer();
  919. }
  920. /// <summary>
  921. /// Prints the consent document.
  922. /// 수동으로 찾아서출력
  923. /// 일반 출력의 경우에도 기본프린터로 바로 출력하는 것으로 변경됨
  924. /// </summary>
  925. /// <param name="fos">The fos.</param>
  926. void IConsentMain.PrintConsentDocument(string fos) {
  927. //int rid = -1;
  928. if (!string.IsNullOrEmpty(fos)) {
  929. this.eFormViewerCtrl.OpenFos(fos);
  930. // dbs227 DB 기록 필요
  931. //rid = this.consentCommandCtrl.SaveDataForPrintedConsent(String.Empty);
  932. }
  933. this.printSaveStatus = false;
  934. int iPrntCnt = 0;
  935. //PC 클라이언트에서 출력 버튼 눌럿을때를 구분하여 pageCount넘겨줌
  936. //pageCount를 넘겨주지 않고 consentCommandCtrl.CurrentPreviewConsent.PrntCnt에서 출력 장수를 받았을때 초기화되어 익셉션 발생
  937. if (printButtonClick) {
  938. iPrntCnt = pageCnt;
  939. printButtonClick = false;
  940. } else {
  941. iPrntCnt = consentCommandCtrl.CurrentPreviewConsent.PrntCnt;
  942. }
  943. this.multiPrintPlanCnt = iPrntCnt;
  944. this.multiPrintExecCnt = 0;
  945. this.checkAutoPrint = false; //수동출력
  946. if (iPrntCnt > 0) {
  947. // 출력매수만큼 동의서 출력
  948. //for (int i = 0; i < iPrntCnt; i++)
  949. //{
  950. // if((i+1) == iPrntCnt) this.printSaveStatus = true;
  951. this.printSaveStatus = true;
  952. this.eFormViewerCtrl.PrintByPrinterName("");
  953. //}
  954. }
  955. this.printSaveStatus = false;
  956. // dbs227,
  957. // 출력 모드가 아닐때는 초기화 하지 않는다.
  958. //if (rid > 0)
  959. //{
  960. // this.consentListCtrl.InquiryConsentData(rid);
  961. //}
  962. }
  963. /// <summary>
  964. /// 기본프린터로 출력, Agent에서 직접출력
  965. /// dbs227, 경북대학교병원 사용하지 않음
  966. /// </summary>
  967. /// <param name="fos">출력할 FOS string</param>
  968. void IConsentMain.PrintDirect(string fos) {
  969. if (!string.IsNullOrEmpty(fos)) {
  970. // dbs227 DB 기록 필요
  971. //this.consentCommandCtrl.SaveDataForPrintedConsent(String.Empty);
  972. this.eFormViewerCtrl.OpenFos(fos);
  973. //this.consentCommandCtrl.SaveDataForPrintedConsent(String.Empty);
  974. }
  975. int prntCnt = 0;
  976. prntCnt = consentCommandCtrl.CurrentPreviewConsent.PrntCnt;
  977. this.checkAutoPrint = true;//자동출력
  978. if (!string.IsNullOrEmpty(this.ConsentExecuteInfo["printList"])) {
  979. if (!ConsentExecuteInfo["prntCnt"].Equals("-1")) {
  980. int.TryParse(this.ConsentExecuteInfo["prntCnt"].ToString(), out prntCnt);
  981. }
  982. }
  983. this.multiPrintPlanCnt = prntCnt;
  984. this.multiPrintExecCnt = 0;
  985. if (prntCnt > 0) {
  986. //this.printSaveStatus = false;
  987. //// 출력매수만큼 동의서 출력
  988. //for (int i = 0; i < prntCnt; i++)
  989. //{
  990. // if ((i + 1) == prntCnt) this.printSaveStatus = true;
  991. this.printSaveStatus = true;
  992. //기본프린터로 바로 출력하기로 함
  993. this.eFormViewerCtrl.PrintByPrinterName("");
  994. //}
  995. //this.printSaveStatus = false;
  996. }
  997. }
  998. void IConsentMain.MoveFirstPage() {
  999. this.eFormViewerCtrl.MoveFirstPage();
  1000. }
  1001. void IConsentMain.MovePrevPage() {
  1002. this.eFormViewerCtrl.MovePrevPage();
  1003. }
  1004. void IConsentMain.MoveNextPage() {
  1005. this.eFormViewerCtrl.MoveNextPage();
  1006. }
  1007. void IConsentMain.MoveLastPage() {
  1008. this.eFormViewerCtrl.MoveLastPage();
  1009. }
  1010. void IConsentMain.Save() {
  1011. this.eFormViewerCtrl.Save();
  1012. }
  1013. /// <summary>
  1014. /// eFormViewerCtrl 컨트롤의 TempSave 이벤트를 호출
  1015. /// </summary>
  1016. void IConsentMain.TempSave() {
  1017. this.eFormViewerCtrl.TempSave();
  1018. }
  1019. int IConsentMain.GetCurrentPageIndex() {
  1020. return this.eFormViewerCtrl.GetCurrentPageIndex();
  1021. }
  1022. int IConsentMain.GetTotalPageCount() {
  1023. return this.eFormViewerCtrl.GetTotalPageCount();
  1024. }
  1025. void IConsentMain.MoveToPageIndex(int pageIndex) {
  1026. this.eFormViewerCtrl.MoveToPageIndex(pageIndex);
  1027. }
  1028. void IConsentMain.SetZoomRate(string zoomRate) {
  1029. this.eFormViewerCtrl.SetZoomRate(zoomRate);
  1030. }
  1031. void IConsentMain.EnableDrawing(bool enable) {
  1032. this.eFormViewerCtrl.EnableDrawing(enable);
  1033. }
  1034. bool IConsentMain.IsDrawMode() {
  1035. return this.eFormViewerCtrl.IsDrawMode();
  1036. }
  1037. void IConsentMain.RemoveAllDrawing() {
  1038. this.eFormViewerCtrl.RemoveAllDrawing();
  1039. }
  1040. void IConsentMain.UndoDrawing() {
  1041. this.eFormViewerCtrl.UndoDrawing();
  1042. }
  1043. void IConsentMain.RedoDrawing() {
  1044. this.eFormViewerCtrl.RedoDrawing();
  1045. }
  1046. void IConsentMain.ConfigDrawingPen() {
  1047. this.eFormViewerCtrl.ConfigDrawingPen();
  1048. }
  1049. void IConsentMain.SetFingerScanValue(string controlId, string base64Image) {
  1050. this.eFormViewerCtrl.SetFingerPrintImage(controlId, base64Image, true);
  1051. }
  1052. void IConsentMain.SetSignatureImage(string controlId, string base64Image) {
  1053. this.eFormViewerCtrl.SetSignatureImage(controlId, base64Image, true);
  1054. }
  1055. public CLIP.eForm.ImageView.ImageViewCtrl GetImageViewerCtrl() {
  1056. return this.imageViewCtrl1;
  1057. }
  1058. void IConsentMain.CloseSignaturePopup(string controlId) {
  1059. this.eFormViewerCtrl.CloseSignaturePopup(controlId);
  1060. }
  1061. void IConsentMain.SetRunOption(string optionKey, string optionValue) {
  1062. this.eFormViewerCtrl.SetRunOption(optionKey, optionValue);
  1063. }
  1064. void IConsentMain.TerminateConsentMain() {
  1065. if (this.Parent is System.Windows.Forms.Form) {
  1066. ((Form) this.Parent).DialogResult = DialogResult.Cancel;
  1067. ((Form) this.Parent).Close();
  1068. }
  1069. }
  1070. /// <summary>
  1071. /// 첨지 삭제
  1072. /// </summary>
  1073. void IConsentMain.DeleteAttach() {
  1074. this.eFormViewerCtrl.DeleteAttach();
  1075. }
  1076. /// <summary>
  1077. /// 첨지 추가
  1078. /// </summary>
  1079. void IConsentMain.InsertAttach() {
  1080. this.eFormViewerCtrl.InsertAttach();
  1081. }
  1082. /// <summary>
  1083. /// 환자정보 설정
  1084. /// </summary>
  1085. void IConsentMain.SetPatientInfo() {
  1086. this.patientInfoCtrl.SetPatientInfo();
  1087. }
  1088. /// <summary>
  1089. /// Closes the dual viewer.
  1090. /// </summary>
  1091. public void CloseDualViewer() {
  1092. this.eFormViewerCtrl.CloseDualViewer();
  1093. this.consentCommandCtrl.SetEnableConsentIssueCommands(true);
  1094. this.consentCommandCtrl.SetEnableButtonsByCurrentConsent();
  1095. }
  1096. /// <summary>
  1097. /// 서명 시 이미지 파일 생성 된 후 호출
  1098. /// </summary>
  1099. /// <param name="value">저장 이미지 파일 설명</param>
  1100. private void OnWrittenImageFile(string value) {
  1101. this.consentCommandCtrl.WorkExtraWithSavedImageFiles(value);
  1102. }
  1103. /// <summary>
  1104. /// Called when [written data XML file].
  1105. /// </summary>
  1106. /// <param name="value">The value.</param>
  1107. private void OnWrittenDataXmlFile(string value) {
  1108. string dataXmlValue = string.Empty;
  1109. if (!string.IsNullOrEmpty(value)) {
  1110. XmlDocument xmlDocument = new XmlDocument();
  1111. xmlDocument.Load(value);
  1112. dataXmlValue = xmlDocument.InnerXml;
  1113. outputDataDic = new Dictionary<string, string>();
  1114. XmlNode rootNode = xmlDocument.SelectSingleNode("form-data");
  1115. foreach (XmlNode childNode in rootNode.ChildNodes) {
  1116. string fieldName = string.Empty;
  1117. string fieldValue = string.Empty;
  1118. XmlElement outFieldElement = childNode as XmlElement;
  1119. if (outFieldElement != null) {
  1120. fieldName = outFieldElement.Name;
  1121. if (outFieldElement.ChildNodes.Count > 0
  1122. && outFieldElement.ChildNodes[0] is XmlCDataSection) {
  1123. fieldValue = ((XmlCDataSection) outFieldElement.ChildNodes[0]).InnerText;
  1124. }
  1125. if (outputDataDic.ContainsKey(fieldName)) {
  1126. outputDataDic[fieldName] = fieldValue;
  1127. } else {
  1128. outputDataDic.Add(fieldName, fieldValue);
  1129. }
  1130. }
  1131. }
  1132. if (processResultValues.ContainsKey("OUTPUT_VALUES")) {
  1133. processResultValues["OUTPUT_VALUES"] = outputDataDic;
  1134. } else {
  1135. processResultValues.Add("OUTPUT_VALUES", outputDataDic);
  1136. }
  1137. }
  1138. try {
  1139. //int state = this.consentWebService.CheckConsentState(int.Parse(consentCommandCtrl.CurrentPreviewConsent.ConsentMstRid), consentCommandCtrl.CurrentPreviewConsent.ConsentState);
  1140. //if (state == 1) {
  1141. // MessageBoxDlg.Show(this, "이미 저장된 서식 입니다."
  1142. // , string.Format(Properties.Resources.msg_caption_confirm),
  1143. // MessageBoxButtons.OK, MessageBoxIcon.Information);
  1144. // return;
  1145. //}
  1146. string eptXmlValue = this.eFormViewerCtrl.GetTempSaveForm();
  1147. // Gzip -> base64 인코딩
  1148. eptXmlValue = Convert.ToBase64String(Common.Zip(eptXmlValue));
  1149. dataXmlValue = Convert.ToBase64String(Common.Zip(dataXmlValue));
  1150. bool isSaved = this.consentCommandCtrl.SaveCompleteConsentData(eptXmlValue, dataXmlValue, out object saveResult);
  1151. if (processResultValues.ContainsKey("OTHER_VALUE_1")) {
  1152. processResultValues["OTHER_VALUE_1"] = saveResult;
  1153. } else {
  1154. processResultValues.Add("OTHER_VALUE_1", saveResult);
  1155. }
  1156. if (isSaved) {
  1157. if (ProcessResult != null) {
  1158. ProcessResult.Invoke("SUCCESS");
  1159. }
  1160. } else {
  1161. ProcessResult.Invoke("FAIL");
  1162. }
  1163. } catch (Exception ex) {
  1164. System.Diagnostics.Trace.WriteLine(string.Format("CLIP.eForm error: {0}", ex.Message));
  1165. MessageBoxDlg.Show(true, string.Format(ex.Message)
  1166. , string.Format(Properties.Resources.msg_caption_fail),
  1167. MessageBoxButtons.OK, MessageBoxIcon.Error);
  1168. ProcessResult.Invoke("FAIL");
  1169. } finally {
  1170. this.eFormViewerCtrl.CloseDualViewer();
  1171. }
  1172. }
  1173. private void OnWrittenTempSaveFile(string value) {
  1174. XmlDocument xmlDocument = new XmlDocument();
  1175. xmlDocument.Load(value);
  1176. string eptXmlValue = xmlDocument.InnerXml; // 임시저장 서식 xml
  1177. try {
  1178. string dataXml = this.eFormViewerCtrl.GetDataXml(); // 저장 데이터 xml
  1179. consentCommandCtrl.CurrentPreviewConsent.PrntCnt = eFormViewerCtrl.GetTotalPageCount();
  1180. // Gzip -> base64 인코딩
  1181. eptXmlValue = Convert.ToBase64String(Common.Zip(eptXmlValue));
  1182. dataXml = Convert.ToBase64String(Common.Zip(dataXml));
  1183. consentCommandCtrl.SaveTempConsentData(eptXmlValue, dataXml, false);
  1184. } catch (Exception ex) {
  1185. System.Diagnostics.Trace.WriteLine(string.Format("CLIP.eForm error: {0}", ex.Message));
  1186. return;
  1187. } finally {
  1188. this.eFormViewerCtrl.CloseDualViewer();
  1189. }
  1190. }
  1191. private void OnWrittenTempSave2File(string value) {
  1192. XmlDocument xmlDocument = new XmlDocument();
  1193. xmlDocument.Load(value);
  1194. string eptXmlValue = xmlDocument.InnerXml; // 임시저장 서식 xml
  1195. try {
  1196. string dataXml = this.eFormViewerCtrl.GetDataXml(); // 저장 데이터 xml
  1197. consentCommandCtrl.CurrentPreviewConsent.PrntCnt = eFormViewerCtrl.GetTotalPageCount();
  1198. // Gzip -> base64 인코딩
  1199. eptXmlValue = Convert.ToBase64String(Common.Zip(eptXmlValue));
  1200. dataXml = Convert.ToBase64String(Common.Zip(dataXml));
  1201. consentCommandCtrl.SaveTempConsentData(eptXmlValue, dataXml, true);
  1202. } catch (Exception ex) {
  1203. System.Diagnostics.Trace.WriteLine(string.Format("CLIP.eForm error: {0}", ex.Message));
  1204. return;
  1205. } finally {
  1206. this.eFormViewerCtrl.CloseDualViewer();
  1207. }
  1208. }
  1209. public void SetConsentListSplitPanelVisibility(bool visibility) {
  1210. if (!visibility) {
  1211. this.splitConsent.Panel1Collapsed = true;
  1212. }
  1213. }
  1214. public void SetPatientListSplitPanelVisibility(bool visibility) {
  1215. if (!visibility) {
  1216. this.splitPatient.Panel2Collapsed = true;
  1217. }
  1218. }
  1219. public bool UseFingerScan { get; set; }
  1220. public bool viewStatus { get; set; }
  1221. public bool IsComplete() {
  1222. bool _isComplete = false;
  1223. if (consentCommandCtrl != null && consentCommandCtrl.CurrentPreviewConsent != null) {
  1224. string _state = consentCommandCtrl.CurrentPreviewConsent.ConsentState ?? string.Empty;
  1225. if (_state.Equals("ELECTR_CMP")) {
  1226. _isComplete = true;
  1227. }
  1228. }
  1229. return _isComplete;
  1230. }
  1231. private void panelReview_Resize(object sender, EventArgs e) {
  1232. if (this.pnlViewer.Visible) {
  1233. if (OnResizeReviewConsent != null) {
  1234. OnResizeReviewConsent.Invoke(this, new EventArgs());
  1235. }
  1236. }
  1237. }
  1238. /// <summary>
  1239. /// 동의서 뷰어 컨트롤 OnError 이벤트 핸들러
  1240. /// </summary>
  1241. /// <param name="errorCode">에러코드</param>
  1242. /// <param name="errorMessage">에러 메시지</param>
  1243. private void eFormViewerCtrl_OnError(string errorCode, string errorMessage) {
  1244. }
  1245. /// <summary>
  1246. /// 동의서 뷰어 컨트롤 OnProcess 이벤트 핸들러
  1247. /// </summary>
  1248. /// <param name="eventCode">이벤트 코드</param>
  1249. /// <param name="value">이벤트 값</param>
  1250. private void eFormViewerCtrl_OnProcess(string eventCode, string value) {
  1251. System.Diagnostics.Trace.WriteLine(string.Format("eventCode: {0} - value: {1}", eventCode, value));
  1252. // 동의서의 현제 페이지 번호 설정
  1253. if (eventCode.Equals("PAGING")) {
  1254. this.consentCommandCtrl.OnPaging(this.eFormViewerCtrl.GetCurrentPageIndex());
  1255. }
  1256. // 듀얼 뷰어 버튼 활성화 여부 제어?
  1257. if (eventCode.Equals("DUAL_VIEWER")) {
  1258. if (value.Equals("OPEN")) {
  1259. this.consentListCtrl.Enabled = false;
  1260. this.patientInfoCtrl.Enabled = false;
  1261. this.patientListCtrl.Enabled = false;
  1262. // this.eFormViewerCtrl.SetRunOption("READ_ONLY", "false");
  1263. this.consentCommandCtrl.EnablePenDrawing = true;
  1264. this.consentCommandCtrl.EnablePenConfig = true;
  1265. this.consentCommandCtrl.SetEnablementExecuteWhenDualViewerActive(false);
  1266. }
  1267. if (value.Equals("CLOSE")) {
  1268. this.consentListCtrl.Enabled = true;
  1269. this.patientInfoCtrl.Enabled = true;
  1270. this.patientListCtrl.Enabled = true;
  1271. // this.eFormViewerCtrl.SetRunOption("READ_ONLY", "true");
  1272. this.consentCommandCtrl.EnablePenDrawing = false;
  1273. this.consentCommandCtrl.EnablePenConfig = false;
  1274. this.consentCommandCtrl.onEnableDrawing(false);
  1275. this.eFormViewerCtrl.EnableDrawing(false);
  1276. this.consentCommandCtrl.SetEnablementExecuteWhenDualViewerActive(true);
  1277. }
  1278. }
  1279. // 동의서 작성완료 후 이미지 저장
  1280. if (eventCode.Equals("WRITTEN_IMAGE_FILE")) {
  1281. // bjw, [확인] 시에는 이미지 저장하지 않음
  1282. // dbs227, 확인 저장 시 이미지도 저장 하여야 함
  1283. //if (!consentCommandCtrl.IsComplete)
  1284. {
  1285. this.OnWrittenImageFile(value);
  1286. }
  1287. }
  1288. // 동의서 작성완료 후 Data XML 저장
  1289. if (eventCode.Equals("DATA_XML_PATH")) {
  1290. // [확인] 시에는 임시 저장만 한다.
  1291. if (consentCommandCtrl.IsComplete) {
  1292. //eFormViewerCtrl.TempSave();
  1293. eFormViewerCtrl.TempSave2();
  1294. } else {
  1295. // 작성완료 버튼이 활성화 되어 있을 경우에만 작성완료 로직을 진행한다.
  1296. if (this.consentCommandCtrl.getSaveButton()) {
  1297. this.consentCommandCtrl.setSaveButton(false);
  1298. this.OnWrittenDataXmlFile(value);
  1299. this.consentCommandCtrl.setSaveButton(true);
  1300. this.eFormViewerCtrl.ConfirmSave(true, "");
  1301. }
  1302. }
  1303. }
  1304. // 동의서 확인 저장
  1305. if (eventCode.Equals("TEMP_SAVE_PATH2")) {
  1306. this.OnWrittenTempSave2File(value);
  1307. this.eFormViewerCtrl.ConfirmSave(true, "");
  1308. }
  1309. // 동의서 임시저장
  1310. if (eventCode.Equals("TEMP_SAVE_PATH")) {
  1311. // 임시저장 버튼이 활성화 되어 있을 경우에만 임시저장 로직을 진행한다.
  1312. // Ku2.0 연동 시 임시저장 로직을 진행한다.
  1313. // 작성 완료 시
  1314. if (this.consentCommandCtrl.getTempSaveButton() || consentCommandCtrl.IsComplete) {
  1315. this.consentCommandCtrl.setTempSaveButton(false);
  1316. this.OnWrittenTempSaveFile(value);
  1317. if (!consentCommandCtrl.IsComplete) {
  1318. this.consentCommandCtrl.setTempSaveButton(true);
  1319. }
  1320. this.eFormViewerCtrl.ConfirmSave(true, "");
  1321. }
  1322. }
  1323. // 동의서 종이 출력
  1324. if (eventCode.Equals("PRINT_COMPLETE")) {
  1325. //this.consentCommandCtrl.OnPrint(value);
  1326. // dbs227, 출력 로그 업데이트
  1327. // 출력을 위한 호출일 경우 form 을 종료한다
  1328. if (printConsentCount == 0 && ConsentExecuteInfo["printYN"].Equals("Y")) {
  1329. Form parentForm = this.Parent as Form;
  1330. if (parentForm != null) {
  1331. parentForm.Close();
  1332. }
  1333. }
  1334. }
  1335. // dbs227, 동의서 프린트 실패
  1336. if (eventCode.Equals("PRINT_FAIL") || eventCode.Equals("PRINT_CANCEL")) {
  1337. }
  1338. //필수 항목 누락시 메시지 박스 호출
  1339. if (eventCode.Equals("REQUIRED_INPUT_VIOLATION")) {
  1340. this.consentCommandCtrl.OnRequiredInputViolation(value);
  1341. }
  1342. // 펜 그리기 모드 활성화 여부 제어
  1343. if (eventCode.Equals("ENABLE_DRAWING")) {
  1344. if (value.Equals("TRUE")) {
  1345. this.consentCommandCtrl.onEnableDrawing(true);
  1346. } else if (value.Equals("FALSE")) {
  1347. this.consentCommandCtrl.onEnableDrawing(false);
  1348. }
  1349. }
  1350. // 초기화 상태
  1351. if (eventCode.Equals("INITIALIZE_STATE")) {
  1352. if (value.Equals("FormViewInitialized")) {
  1353. viewStatus = true;
  1354. }
  1355. }
  1356. // 그외 이벤트
  1357. // 동의서 저장 버튼 활셩화여부 제어
  1358. // 동의서 임시서장 버튼 활성화 여부 반환(get)
  1359. // 동의서 임시저장 버튼 활성화 여부 제어(set)
  1360. }
  1361. private void eFormViewerCtrl_VisibleChanged(object sender, EventArgs e) {
  1362. if (this.eFormViewerCtrl.Visible) {
  1363. if (this.OnVisibleEFormControl != null) {
  1364. this.OnVisibleEFormControl.Invoke(this, new EventArgs());
  1365. }
  1366. } else {
  1367. if (this.OnInvisibleEFormControl != null) {
  1368. this.OnInvisibleEFormControl.Invoke(this, new EventArgs());
  1369. }
  1370. }
  1371. }
  1372. /// <summary>
  1373. /// startFormCd 를 초기화 한다
  1374. /// </summary>
  1375. public void preParamClean() {
  1376. this.ConsentExecuteInfo["startFormCd"] = string.Empty;
  1377. }
  1378. void IConsentMain.ReInitializeViewer() {
  1379. if (eFormViewerCtrl.GetTotalPageCount() > 0) {
  1380. this.eFormViewerCtrl.ReInitializeViewer();
  1381. }
  1382. this.viewStatus = false;
  1383. }
  1384. public void OnProcessCmdKey(Keys keyData) {
  1385. }
  1386. /// <summary>
  1387. /// OCX 에서 넘겨 받은 FORMCD 리스트를 서버에서 조회해 온다
  1388. /// </summary>
  1389. private void GetConsentListByFormcd() {
  1390. try {
  1391. string[] formCdArr = ConsentExecuteInfo["formCd"].Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
  1392. string[] ocrTagArr = ConsentExecuteInfo["ocrCd"].Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
  1393. printConsentCount = formCdArr.Length;
  1394. var today = DateTime.Today.ToString("yyyyMMdd");
  1395. for (int i = 0; i < formCdArr.Length; i++) {
  1396. // 서버에서 목록 조회
  1397. ConsentVO[] voArr = consentWebService.GetConsentByFormcd(formCdArr[i], ConsentExecuteInfo["dutinstcd"], today);
  1398. //ConsentVO[] voArr = consentWebService.GetConsentByFormcd(formCdArr[i], ConsentExecuteInfo["dutinstcd"]);
  1399. if (voArr == null || voArr.Length < 1) {
  1400. throw new Exception("지정된 동의서를 찾을 수 없습니다.");
  1401. }
  1402. ConsentVO vo = voArr[0];
  1403. // 현재 preview 할동의서 정보 설정
  1404. //consentCommandCtrl.CurrentPreviewConsent = new PreviewConsent();
  1405. consentCommandCtrl.CurrentPreviewConsent = new PreviewConsent {
  1406. FormRid = vo.formId.ToString(),
  1407. FormCd = vo.formCode.ToString(),
  1408. FormName = vo.formName,
  1409. FormPrintName = vo.formPrntNm,
  1410. PrntCnt = vo.printCnt,
  1411. ConsentMstRid = "-1",
  1412. ConsentState = string.Empty,
  1413. Ocrcode = vo.ocrTag,
  1414. certPass = vo.certPass,
  1415. InputId = consentCommandCtrl.CurrentEndUser.userId,
  1416. InputNm = consentCommandCtrl.CurrentEndUser.userName,
  1417. ReissueConsentMstRid = 0,
  1418. RewriteConsentMstRid = 0,
  1419. OpDiagName = consentCommandCtrl.CurrentTargetPatient.OpDiagName,
  1420. VisitType = consentCommandCtrl.CurrentTargetPatient.ordtype,
  1421. OpName = consentCommandCtrl.CurrentTargetPatient.OpName
  1422. };
  1423. // 출력 연동이 아닌 경우
  1424. if (ConsentExecuteInfo["printYN"].Equals("N")) {
  1425. Dictionary<FOSParameter, string> globalParams = Common.CreateGlobalParamsDictionary(ConsentExecuteInfo["dutinstcd"]);
  1426. List<string> formGuids = new List<string> {
  1427. consentCommandCtrl.CurrentPreviewConsent.FormGuid
  1428. };
  1429. consentCommandCtrl.SetPatientAndUser(globalParams);
  1430. if (ocrTagArr.Length > 0) {
  1431. globalParams[FOSParameter.LIST_OCRCODE] = consentCommandCtrl.CurrentPreviewConsent.Ocrcode = ocrTagArr[i]; // OCR 코드
  1432. } else {
  1433. globalParams[FOSParameter.LIST_OCRCODE] = consentCommandCtrl.CurrentPreviewConsent.Ocrcode = consentCommandCtrl.GetOcrCode(); // OCR 코드
  1434. }
  1435. globalParams[FOSParameter.GLOBAL_MAIN_DR1_NM] = consentCommandCtrl.CurrentTargetPatient.mainDrNm;
  1436. // 빌드를 위한 주석 처리
  1437. // 임시저장의 경우 C 로 설정
  1438. //globalParams[FOSParameter.Device] = "PC";
  1439. //globalParams[FOSParameter.PrintTime] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  1440. //globalParams[FOSParameter.SignTime] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  1441. //globalParams[FOSParameter.PrintIp] = ConsentExecuteInfo["printIP"];
  1442. string fos = Common.getNewFosString(PluginExecuteInfo["formServiceUrl"],
  1443. globalParams,
  1444. null,
  1445. new List<String> { consentCommandCtrl.CurrentPreviewConsent.FormRid });
  1446. consentCommandCtrl.SetEnableButtonsByCurrentConsent();
  1447. // 동의서 열기
  1448. eFormViewerCtrl.OpenFos(fos);
  1449. // 출력 히스토리 기록
  1450. //this.consentCommandCtrl.OnPrint(vo.FormPrintName);
  1451. //------------------------------
  1452. // TODO 자동 듀얼뷰어 실행
  1453. //Boolean openDualView = false;
  1454. Boolean openDualView = (this.consentWebService.getDualViewMode(ConsentExecuteInfo["dutinstcd"],
  1455. ConsentExecuteInfo["ipaddr"]) == "Y") ? true : false;
  1456. if (openDualView) {
  1457. consentCommandCtrl.RunConsentDualView();
  1458. }
  1459. // 배율정보 설정
  1460. consentCommandCtrl.setZoomRate(4);
  1461. //-------------------------------
  1462. if (ConsentExecuteInfo["tempSave"].Equals("N")) { // 지정된 동의서를 열기만 하는 경우
  1463. // 여러 개의 formcd 를 받더라도 첫번째 것만 보여준다
  1464. break;
  1465. } else if (ConsentExecuteInfo["tempSave"].Equals("Y")) { // 임시 저장
  1466. // 동의서 임시저장
  1467. eFormViewerCtrl.TempSave();
  1468. }
  1469. }
  1470. // 출력 연동
  1471. if (ConsentExecuteInfo["printYN"].Equals("Y")) {
  1472. int prntCnt = consentCommandCtrl.CurrentPreviewConsent.PrntCnt;
  1473. // 실행 파라미터에 PRINT_CNT 가 있고 0보다 클 경우 실행 파라미터를 우선으로 한다.
  1474. if (!string.IsNullOrEmpty(ConsentExecuteInfo["printCount"])) {
  1475. int.TryParse(ConsentExecuteInfo["printCount"], out prntCnt);
  1476. }
  1477. Dictionary<string, Dictionary<FOSParameter, string>> formParamsList = new Dictionary<string, Dictionary<FOSParameter, string>>();
  1478. string[] formGuidList = new string[prntCnt];
  1479. string sOcrCd = string.Empty;
  1480. for (int j = 0; j < prntCnt; j++) {
  1481. Dictionary<FOSParameter, string> formParams = Common.CreateGlobalParamsDictionary(ConsentExecuteInfo["dutinstcd"]);
  1482. consentCommandCtrl.SetPatientAndUser(formParams);
  1483. if (ocrTagArr.Length > 0) {
  1484. formParams[FOSParameter.LIST_OCRCODE] = consentCommandCtrl.CurrentPreviewConsent.Ocrcode = ocrTagArr[i];
  1485. } else {
  1486. sOcrCd = formParams[FOSParameter.LIST_OCRCODE] = consentCommandCtrl.CurrentPreviewConsent.Ocrcode = consentCommandCtrl.GetOcrCode();
  1487. }
  1488. // 동일 서식을 2장 있을 출력할 경우, 2장째부터는 OCR 태그가 아닌 [환자보관용] 텍스트가 출력
  1489. //if (j > 0) {
  1490. // var ocrStr = this.consentWebService.getOcrString(consentCommandCtrl.CurrentPreviewConsent.FormCd,
  1491. // ConsentExecuteInfo["dutinstcd"]);
  1492. // if (ocrStr == null) {
  1493. // ocrStr = "[환자 보관용]";
  1494. // }
  1495. // //ocrStr = (ocrStr == n) ? "[환자 보관용]" : ocrStr;
  1496. // //formParams[FOSParameter.OCRCode] = "[환자 보관용]";
  1497. // formParams[FOSParameter.LIST_OCRCODE] = ocrStr;
  1498. //}
  1499. // 빌드를 위한 주석 처리
  1500. //formParams[FOSParameter.Device] = "P";
  1501. //formParams[FOSParameter.PrintTime] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  1502. //formParams[FOSParameter.PrintIp] = ConsentExecuteInfo["printIP"];
  1503. //if (j == 1) formParams[FOSParameter.PrintComment] = Properties.Resources.msg_print_comment_2;
  1504. //else if (j == 2) formParams[FOSParameter.PrintComment] = Properties.Resources.msg_print_comment_3;
  1505. formGuidList[j] = consentCommandCtrl.CurrentPreviewConsent.FormGuid;
  1506. formParamsList.Add((j + 1).ToString(), formParams);
  1507. }
  1508. Dictionary<FOSParameter, string> globalParams = Common.CreateGlobalParamsDictionary(ConsentExecuteInfo["dutinstcd"]);
  1509. globalParams[FOSParameter.GLOBAL_MAIN_DR1_NM] = consentCommandCtrl.CurrentTargetPatient.mainDrNm;
  1510. string fos = Common.getNewFosString(PluginExecuteInfo["formServiceUrl"],
  1511. globalParams,
  1512. null,
  1513. new List<String> { consentCommandCtrl.CurrentPreviewConsent.FormRid });
  1514. String formPrintName = formParamsList["1"][FOSParameter.LIST_FORM_NM];
  1515. this.eFormViewerCtrl.OpenFos(fos);
  1516. // 출력 히스토리 기록
  1517. this.consentCommandCtrl.OnPrint(formPrintName);
  1518. //int testpagecnt = this.eFormViewerCtrl.GetTotalPageCount();
  1519. // dbs227, 출력 로그 업데이트
  1520. // consent_mst 기록
  1521. // InsertPrintData API 추가 후 기록
  1522. //this.consentCommandCtrl.SaveDataForPrintedConsent(String.Empty);
  1523. printConsentCount--;
  1524. this.eFormViewerCtrl.PrintByPrinterName("");
  1525. }
  1526. }
  1527. } catch (Exception ex) {
  1528. MessageBox.Show(ex.ToString());
  1529. throw ex;
  1530. }
  1531. }
  1532. private void btnHelp_Click(object sender, EventArgs e) {
  1533. btnHelp.Enabled = false;
  1534. Application.DoEvents();
  1535. System.Diagnostics.Process.Start(@"https://ema031.knuh.kr:9091/doc/guide.pdf");
  1536. btnHelp.Enabled = true;
  1537. }
  1538. int pageCnt = 0;
  1539. Boolean printButtonClick = false;
  1540. void IConsentMain.setPageCnt(int pageCnt) {
  1541. this.pageCnt = pageCnt;
  1542. //throw new NotImplementedException();
  1543. }
  1544. int IConsentMain.getPageCnt() {
  1545. return this.pageCnt;
  1546. //throw new NotImplementedException();
  1547. }
  1548. void IConsentMain.setPrintButton(bool flag) {
  1549. this.printButtonClick = flag;
  1550. //throw new NotImplementedException();
  1551. }
  1552. bool IConsentMain.getPrintButton() {
  1553. return this.printButtonClick;
  1554. //throw new NotImplementedException();
  1555. }
  1556. }
  1557. }