ConsentMainControl.cs 113 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045
  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. {
  16. /// <summary>
  17. /// 동의서 관리 메인 컨트롤 클래스
  18. /// </summary>
  19. /// <remarks>
  20. /// <p>[설계자]</p>
  21. /// <p> 클립소프트 연구소 홍지철 (jchong@clipsoft.co.kr)</p>
  22. /// <p>[원본 작성자]</p>
  23. /// <p> 클립소프트 기술부 이창훈 (chlee@clipsoft.co.kr)</p>
  24. /// <p>[수정 작성자]</p>
  25. /// <p> 클립소프트 기술부 이인희</p>
  26. /// <p>----------------------------------------------------------------------------------------</p>
  27. /// <p>[HISTORY]</p>
  28. /// <p> 2015-07-30 : 최초작성</p>
  29. /// <p>----------------------------------------------------------------------------------------</p>
  30. /// </remarks>
  31. public partial class ConsentMainControl : UserControl, IConsentMainCtrl, IConsentMain
  32. {
  33. private string currentFormGuid = string.Empty;
  34. private ConsentSvcRef.ConsentSvcSoapClient consentWebService;
  35. private HospitalSvcRef.HospitalSvcSoapClient hospitalWebService;
  36. //private IConsentMainForm _consentMainForm = null; // AgentForm(리턴시 사용)
  37. [Browsable(false)]
  38. public ConsentSvcRef.ConsentSvcSoapClient ConsentWebService { get { return consentWebService; } }
  39. [Browsable(false)]
  40. public HospitalSvcRef.HospitalSvcSoapClient HospitalWebService { get { return hospitalWebService; } }
  41. public string PluginModuleName { get; set; }
  42. private Dictionary<string, string> outputDataDic = null;
  43. private Dictionary<string, object> processResultValues = new Dictionary<string, object>();
  44. public Dictionary<string, string> ConsentExecuteInfo { get; set; }
  45. public Dictionary<string, string> PluginExecuteInfo { get; set; }
  46. public Dictionary<string, object> ProcessResultValues { get { return processResultValues; } }
  47. public List<ConsentFormListVO> PrintInfoList { get; set; }
  48. public event EventHandler OnLoadPartControls;
  49. public event EventHandler OnResizeReviewConsent;
  50. public event EventHandler OnVisibleEFormControl;
  51. public event EventHandler OnInvisibleEFormControl;
  52. public event ProcessResultHandler ProcessResult;
  53. public delegate void ProcessResultHandler(string result);
  54. public object mCallParm = null;
  55. public bool printSaveStatus { get; set; }
  56. public int multiPrintPlanCnt { get; set; }
  57. public int multiPrintExecCnt { get; set; }
  58. public bool saveClickPoint { get; set; } // true : 메인창, false : 듀얼뷰어창
  59. public bool checkAutoPrint { get; set; } // true : 입실저장 자동출력, false : 수동출력
  60. private static bool startform = true;
  61. public int agentCallPrintCnt { get; set; }
  62. public int printConsentCount = 1;
  63. // 원무 서식 인증서 pass 여부
  64. // 경북대병원 dependency
  65. public bool shouldPassCertify = false;
  66. public static Dictionary<String, String> SETTING_DATA = new Dictionary<String, String>();
  67. /// <summary>
  68. /// Gets or sets the call parameter.
  69. /// </summary>
  70. /// <value>
  71. /// The call parameter.
  72. /// </value>
  73. object IConsentMainCtrl.CallParam
  74. {
  75. get
  76. {
  77. return mCallParm;
  78. }
  79. set
  80. {
  81. mCallParm = value;
  82. }
  83. }
  84. public List<Dictionary<string, object>> multiParams { get; set; }
  85. /// <summary>
  86. /// Initializes a new instance of the <see cref="ConsentMainControl"/> class.
  87. /// </summary>
  88. /// <param name="callParam">The call parameter.</param>
  89. public ConsentMainControl(object callParam)
  90. {
  91. //MessageBox.Show("Waiting");
  92. InitializeComponent();
  93. bool isMultiParams = false;
  94. ToolTip _toolTip = new ToolTip();
  95. _toolTip.AutoPopDelay = 5000;
  96. _toolTip.InitialDelay = 0;
  97. _toolTip.ReshowDelay = 0;
  98. _toolTip.ShowAlways = true;
  99. _toolTip.SetToolTip(this.btnHelp, "도움말");
  100. // 실행 정보 데이터셋 초기화
  101. ConsentExecuteInfo = new Dictionary<string, string> {
  102. { "dutinstcd", string.Empty },
  103. { "userNo", string.Empty },
  104. { "loginUserNo", string.Empty },
  105. { "userName", string.Empty },
  106. { "loginUserName", string.Empty },
  107. { "userDeptCd", string.Empty },
  108. { "userDeptName", string.Empty },
  109. { "patientNo", string.Empty },
  110. { "visitType", string.Empty },
  111. { "clnDept", string.Empty },
  112. { "clnDate", string.Empty },
  113. { "cretno", string.Empty },
  114. { "clnDxNm", string.Empty },
  115. { "opRsrvNo", string.Empty },
  116. { "useListView", string.Empty },
  117. { "patientListView", string.Empty },
  118. { "startFormCd", string.Empty },
  119. { "printAct", string.Empty },
  120. { "printList", string.Empty },
  121. { "formCd", string.Empty },
  122. { "ocrTag", string.Empty },
  123. { "tempSave", string.Empty },
  124. { "printYN", string.Empty },
  125. { "printCount", string.Empty },
  126. { "printIP", string.Empty },
  127. { "prntCnt", string.Empty },
  128. { "userIOFlag", "O" },
  129. { "sysInstNm", string.Empty },
  130. { "readOnly", string.Empty },
  131. { "SpecDoctorYN", string.Empty },
  132. { "ContStartDate", string.Empty },
  133. { "ContEndDate", string.Empty },
  134. { "RoomCapa", string.Empty },
  135. { "ContTelNo", string.Empty },
  136. { "ContStaff1Name", string.Empty },
  137. { "ContStaff2Name", string.Empty },
  138. { "ContStaff3Name", string.Empty },
  139. { "DeviceType", string.Empty },
  140. // 경대병원 태그 추가
  141. { "tag1", string.Empty },
  142. { "tag2", string.Empty },
  143. { "tag3", string.Empty },
  144. { "tag4", string.Empty },
  145. { "tag5", string.Empty },
  146. { "tag6", string.Empty },
  147. { "tag7", string.Empty },
  148. { "tag8", string.Empty },
  149. { "tag9", string.Empty },
  150. { "tag10", string.Empty },
  151. { "CardNo", string.Empty }
  152. };
  153. PluginExecuteInfo = new Dictionary<string, string>();
  154. //연속서식인지 구분하는 부분
  155. if ((callParam != null) && (callParam is Dictionary<string, object> result)) {
  156. if (result.ContainsKey("VERSION") && result["VERSION"].ToString().Equals("2.0")) {
  157. isMultiParams = true;
  158. }
  159. }
  160. if (isMultiParams) {
  161. //연속서식일 때
  162. //화면설정 정보는 전역변수에 할당하고 나머지 배열로 들어오는 정보들은 multiParams에 할당하여
  163. //동의서를 부를 때 하나씩 전역변수에 넣고 동의서를 부른다
  164. InitMultiParamSetting(callParam);
  165. SetWebServiceUrlAndTimeout();
  166. this.PluginModuleName = ConfigurationManager.AppSettings["UIPluginAssembly"];
  167. if (multiParams.Count > 0) {
  168. //연속서식의 첫번째 서식을 불러오기 위해 파라미터 배열의 가장 첫번째 데이터를 전역변수에 할당한다
  169. Dictionary<string, object> pageCountParam = ((Dictionary<string, object>)multiParams[multiParams.Count - 1]);
  170. if (pageCountParam.ContainsKey("PAGE_COUNT") && Int32.TryParse(pageCountParam["PAGE_COUNT"].ToString(), out int page)) {
  171. setConsentViewMultiParams(page);
  172. }
  173. }
  174. } else {
  175. //연속서식이 아닐 때
  176. // 넘겨받은 callParam 를 디코딩 한다
  177. InitParamSetting(callParam);
  178. SetWebServiceUrlAndTimeout();
  179. this.PluginModuleName = ConfigurationManager.AppSettings["UIPluginAssembly"];
  180. }
  181. }
  182. //private void SendKeyValueMessageToAdapter(int key, string message)
  183. //{
  184. // _consentMainForm.SendKeyValueMessageToAdapter(key, message);
  185. //}
  186. /// <summary>
  187. /// Gets a value indicating whether this instance has vertical monitor.
  188. /// </summary>
  189. /// <value>
  190. /// <c>true</c> if this instance has vertical monitor; otherwise, <c>false</c>.
  191. /// </value>
  192. public static bool HasVerticalMonitor
  193. {
  194. get
  195. {
  196. if (Screen.AllScreens.Length > 1)
  197. {
  198. foreach (Screen screen in Screen.AllScreens)
  199. {
  200. if (screen.Bounds.Width < screen.Bounds.Height)
  201. {
  202. return true;
  203. }
  204. }
  205. }
  206. return false;
  207. }
  208. }
  209. /// <summary>
  210. /// 수술 관련 동의서 호출 시 수술탭 확인 후 팝업 호출
  211. /// </summary>
  212. /// <param name="formCd"></param>
  213. public bool checkOperationDocument(string formCd)
  214. {
  215. var hardcd = consentWebService.checkOperationDocument(ConsentExecuteInfo["dutinstcd"], formCd);
  216. var retValue = true;
  217. if (!opPatientSelected && hardcd.Equals("Y"))
  218. {
  219. DialogResult result = MessageBox.Show("수술정보가 없습니다. 수술 동의서는 수술 Tab에서 서식 출력 바랍니다.\n수술 정보 없이 계속 진행하시겠습니까?", "확인", MessageBoxButtons.OKCancel);
  220. if (result != DialogResult.OK)
  221. {
  222. retValue = false;
  223. }
  224. }
  225. return retValue;
  226. }
  227. private bool opPatientSelected = false;
  228. public void setOpPatientSelected(bool value)
  229. {
  230. this.opPatientSelected = value;
  231. }
  232. /// <summary>
  233. /// 주어진 서버 이름으로 설정파일을 로딩 한다
  234. /// </summary>
  235. /// <param name="pServerName">로드 할 서버 설정 파일</param>
  236. /// <returns></returns>
  237. public static Dictionary<string, string> GetConfigDictionary(string pServerName)
  238. {
  239. Dictionary<string, string> result = new Dictionary<string, string>();
  240. /*
  241. XmlDocument configXml = new XmlDocument();
  242. configXml.Load(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + string.Format("/CLIP.Consent.xml"));
  243. XmlNodeList addNodes = configXml.SelectNodes("configuration/settings/add");
  244. foreach (XmlNode xmlNode in addNodes) {
  245. if (xmlNode.Attributes["key"].InnerText == "serviceTarget") {
  246. serviceTarget = ((XmlCDataSection)xmlNode.ChildNodes[0]).InnerText;
  247. }
  248. }
  249. */
  250. XmlDocument configXml = new XmlDocument();
  251. configXml.Load(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + string.Format("/CLIP.Consent-{0}.xml", pServerName));
  252. XmlNodeList addNodes = configXml.SelectNodes("configuration/settings/add");
  253. foreach (XmlNode xmlNode in addNodes)
  254. {
  255. result.Add(xmlNode.Attributes["key"].InnerText, ((XmlCDataSection)xmlNode.ChildNodes[0]).InnerText);
  256. }
  257. return result;
  258. }
  259. /// <summary>
  260. /// childControl의 부모와 그의 부모들에서 IConsentMain 인터페이스를 구현하는 클래스를 찾는다.
  261. /// </summary>
  262. /// <param name="childControl"></param>
  263. /// <returns></returns>
  264. public static IConsentMain GetConsentMainInterface(Control childControl)
  265. {
  266. if (childControl.Parent == null)
  267. {
  268. return null;
  269. }
  270. else
  271. {
  272. if (childControl.Parent is IConsentMain)
  273. {
  274. return childControl.Parent as IConsentMain;
  275. }
  276. else
  277. {
  278. return GetConsentMainInterface(childControl.Parent);
  279. }
  280. }
  281. }
  282. /// <summary>
  283. /// Sets the web service URL and timeout.
  284. /// </summary>
  285. private void SetWebServiceUrlAndTimeout()
  286. {
  287. try
  288. {
  289. Dictionary<string, string> configDic = GetConfigDictionary(ConsentExecuteInfo["sysInstNm"]);
  290. this.PluginExecuteInfo.Add("consentSvcUrl", configDic["consentSvcUrl"]);
  291. this.PluginExecuteInfo.Add("hospitalSvcUrl", configDic["hospitalSvcUrl"]);
  292. this.PluginExecuteInfo.Add("formServiceUrl", configDic["formServiceUrl"]);
  293. this.PluginExecuteInfo.Add("imageUploadServerUrl", configDic["imageUploadServerUrl"]);
  294. this.PluginExecuteInfo.Add("signatureServerUrl", configDic["signatureServerUrl"]);
  295. this.PluginExecuteInfo.Add("signatureServerPort", configDic["signatureServerPort"]);
  296. this.PluginExecuteInfo.Add("imageUploadPath", configDic["imageUploadPath"]);
  297. this.PluginExecuteInfo.Add("ConsentSearchStartDate", configDic["ConsentSearchStartDate"]);
  298. this.PluginExecuteInfo.Add("timeOut", "10");
  299. this.consentWebService = WebMethodCommon.GetConsentWebService(configDic["consentSvcUrl"]);
  300. this.hospitalWebService = WebMethodCommon.GetHospitalWebService(configDic["hospitalSvcUrl"]);
  301. }
  302. catch (Exception ex)
  303. {
  304. throw ex;
  305. }
  306. }
  307. public ConsentSvcRef.ConsentSvcSoapClient getConsentWebService()
  308. {
  309. return this.consentWebService;
  310. }
  311. public HospitalSvcRef.HospitalSvcSoapClient getHospitalWebService()
  312. {
  313. return this.hospitalWebService;
  314. }
  315. /// <summary>
  316. /// Initializes the parameters.
  317. /// </summary>
  318. public void initParams()
  319. {
  320. InitParamSetting(mCallParm);
  321. }
  322. /// <summary>
  323. /// 화면 초기화 시 수행해야 할 이벤트 처리
  324. /// </summary>
  325. /// <param name="e"></param>
  326. protected override void OnLoad(EventArgs e)
  327. {
  328. try
  329. {
  330. // 출력을 사용하면 프로그램 종료 이벤트 추가
  331. if (ConsentExecuteInfo["printAct"].Equals("Y"))
  332. {
  333. this.Parent.Disposed += Parent_Disposed;
  334. }
  335. if (string.IsNullOrEmpty(this.PluginModuleName))
  336. {
  337. return;
  338. }
  339. // 고정 모니터 설정
  340. MoniterViewSetting(ConsentExecuteInfo["printYN"].Equals("Y") ? true : false);
  341. if (ConsentExecuteInfo["printYN"].Equals("Y"))
  342. {
  343. this.Parent.Visible = false;
  344. }
  345. // 기존 인증서 삭제
  346. SignatureConfig sign = new SignatureConfig();
  347. if (!startform)
  348. {
  349. startform = false;
  350. sign.SignAllClear();
  351. }
  352. // eFormViewer 컨트롤 초기화
  353. InitEFormControl();
  354. HospitalSvcRef.SingleReturnData baseData = this.hospitalWebService.GetBaseData(ConsentExecuteInfo["dutinstcd"]);
  355. String[] strAr = baseData.responseData.Split(',');
  356. for (int i = 0; i < strAr.Length; i++)
  357. {
  358. String[] dataAr = strAr[i].Split('|');
  359. String key = "";
  360. String value = "";
  361. for (int j = 0; j < dataAr.Length; j++)
  362. {
  363. if (j == 0)
  364. {
  365. key = dataAr[j];
  366. }
  367. else
  368. {
  369. value = dataAr[j];
  370. }
  371. }
  372. SETTING_DATA.Add(key, value);
  373. }
  374. // TODO 201909
  375. // 경북대학교병원 특정 옵션 호출 시 조회 화면 제거 루틴 추가 필요
  376. //ConsentExecuteInfo["useListView"] = "N";
  377. //ConsentExecuteInfo["patientListView"] = "N";
  378. InvokeDelayedLoadEvent();
  379. this.eFormViewerCtrl.GetCurrentViewer().UIUpdateOnDrawing
  380. += new Viewer.UIUpdateOnDrawingHandler(ConsentMainControl_UIUpdateOnDrawing);
  381. base.OnLoad(e);
  382. // dbs227
  383. // TODO 디버그 용 메시지 박스
  384. //Boolean openDualView = (this.consentWebService.getDualViewMode(ConsentExecuteInfo["dutinstcd"],
  385. // ConsentExecuteInfo["ipaddr"]) == "Y") ? true : false;
  386. //MessageBox.Show("Waiting for debugging at " + ConsentExecuteInfo["ipaddr"]);
  387. // Ku2.0 연동
  388. GetConsentListByFormcd();
  389. // 폰트 설치여부 체크
  390. string familyName;
  391. string familyList = "";
  392. FontFamily[] fontFamilies;
  393. System.Drawing.Text.InstalledFontCollection installedFontCollection = new System.Drawing.Text.InstalledFontCollection();
  394. fontFamilies = installedFontCollection.Families;
  395. int count = fontFamilies.Length;
  396. int fontCheck = 0;
  397. for (int j = 0; j < count; ++j)
  398. {
  399. familyName = fontFamilies[j].Name;
  400. familyList = familyList + familyName;
  401. familyList = familyList + ", ";
  402. if (fontCheck != 1 && (familyName == "나눔고딕" || familyName == "NanumGothic"))
  403. {
  404. fontCheck = fontCheck + 1;
  405. }
  406. if (fontCheck < 100 && (familyName == "나눔고딕 ExtraBold" || familyName == "NanumGothicExtraBold" || familyName == "나눔고딕 아주 굵게"))
  407. {
  408. fontCheck = fontCheck + 10;
  409. }
  410. }
  411. // 폰트 설치 실행
  412. if (fontCheck < 11)
  413. {
  414. System.Diagnostics.Process UserProcess = new System.Diagnostics.Process();
  415. UserProcess.StartInfo.UseShellExecute = true;
  416. //UserProcess.StartInfo.FileName = "NanumFontSetup.exe";
  417. //UserProcess.StartInfo.WorkingDirectory = Path.GetDirectoryName(Application.StartupPath + "/Font/");
  418. // 폰트가 없어 최초 실행 시 에러 발생 부분 수정
  419. UserProcess.StartInfo.FileName = "FontInstall.exe";
  420. UserProcess.StartInfo.WorkingDirectory = Path.GetDirectoryName(Application.StartupPath + "\\");
  421. UserProcess.StartInfo.CreateNoWindow = true;
  422. UserProcess.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
  423. UserProcess.Start();
  424. }
  425. string sTempPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\Clipsoft\ClipSoft.eForm.Viewer\DataTemp\";
  426. if (Directory.Exists(sTempPath))
  427. {
  428. string[] filePaths = Directory.GetFiles(sTempPath);
  429. foreach (string fileName in filePaths)
  430. {
  431. FileInfo fileInfo = new FileInfo(fileName);
  432. if (fileInfo.Extension.Equals(".ept") || fileInfo.Extension.Equals(".jpg") || fileInfo.Extension.Equals(".xml"))
  433. {
  434. fileInfo.Delete();
  435. }
  436. }
  437. }
  438. if (multiParams != null && multiParams.Count > 0) {
  439. int pageCount = Int32.TryParse(((Dictionary<string, object>)multiParams[multiParams.Count - 1])["PAGE_COUNT"].ToString(), out int page) ? page : 0;
  440. showConsentView(pageCount);
  441. Boolean openDualView = (this.consentWebService.getDualViewMode(ConsentExecuteInfo["dutinstcd"], ConsentExecuteInfo["ipaddr"]) == "Y") ? true : false;
  442. if (openDualView)
  443. {
  444. consentCommandCtrl.RunConsentDualView();
  445. }
  446. }
  447. }
  448. catch (Exception ex)
  449. {
  450. // 데이터베이스 저장 기능 추가로 해당 기능 삭제
  451. //File.WriteAllText(string.Format(@"{0}\eConsentLog\{1}_Agent.txt", Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
  452. // , DateTime.Now.ToString("yyyyMMdd_HHmmss"))
  453. // , ex.ToString());
  454. Console.WriteLine(ex.ToString());
  455. if (this.Parent is System.Windows.Forms.Form)
  456. {
  457. ((Form)this.Parent).DialogResult = DialogResult.Cancel;
  458. ((Form)this.Parent).Close();
  459. }
  460. }
  461. }
  462. // 화면이 종료될때 Agent도 종료되도록 수정
  463. /// <summary>
  464. /// Handles the Disposed event of the Parent control.
  465. /// </summary>
  466. /// <param name="sender">The source of the event.</param>
  467. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  468. private void Parent_Disposed(object sender, EventArgs e)
  469. {
  470. foreach (Form form in Application.OpenForms)
  471. {
  472. if (form.Name.Equals("ConsentAgentForm"))
  473. {
  474. form.Dispose();
  475. break;
  476. }
  477. }
  478. }
  479. // 화면이 종료될때 Agent도 종료되도록 수정
  480. /// <summary>
  481. /// Parents the disposed.
  482. /// </summary>
  483. public void Parent_Disposed()
  484. {
  485. foreach (Form form in Application.OpenForms)
  486. {
  487. if (form.Name.Equals("ConsentAgentForm"))
  488. {
  489. form.Dispose();
  490. break;
  491. }
  492. }
  493. }
  494. /// <summary>
  495. /// OCX 로 부터 넘겨 받은 파라미터를 decode
  496. /// </summary>
  497. /// <param name="pCallParm">EXEC_OPT 로 넘어온 파라미터 목록</param>
  498. /// <exception cref="Exception">CallParam 미전달</exception>
  499. private void InitParamSetting(object pCallParm)
  500. {
  501. try
  502. {
  503. if (pCallParm != null)
  504. {
  505. Dictionary<string, object> callParam = pCallParm as Dictionary<string, object>;
  506. if (callParam != null && callParam.Count < 2)
  507. {
  508. if (callParam["CALL_PARAMS"] != null)
  509. {
  510. pCallParm = callParam["CALL_PARAMS"] as object;
  511. }
  512. }
  513. foreach (KeyValuePair<string, object> callKV in pCallParm as Dictionary<string, object>)
  514. {
  515. // 사용자 정보
  516. if (callKV.Key != null && !string.IsNullOrEmpty(callKV.Key.ToString()) && callKV.Key.ToString() == "USER_INFO")
  517. {
  518. foreach (KeyValuePair<string, object> userKV in callKV.Value as Dictionary<string, object>)
  519. {
  520. if (userKV.Key != null && !string.IsNullOrEmpty(userKV.Key.ToString()) && userKV.Key.ToString() == "USER_ID")
  521. {
  522. if (userKV.Value != null)
  523. {
  524. ConsentExecuteInfo["userNo"] = userKV.Value.ToString();
  525. ConsentExecuteInfo["loginUserNo"] = userKV.Value.ToString();
  526. }
  527. }
  528. else if (userKV.Key != null && !string.IsNullOrEmpty(userKV.Key.ToString()) && userKV.Key.ToString() == "DUTINSTCD")
  529. {
  530. if (userKV.Value != null)
  531. {
  532. ConsentExecuteInfo["dutinstcd"] = userKV.Value.ToString();
  533. }
  534. }
  535. else if (userKV.Key != null && !string.IsNullOrEmpty(userKV.Key.ToString()) && userKV.Key.ToString() == "USER_NAME")
  536. {
  537. if (userKV.Value != null)
  538. {
  539. ConsentExecuteInfo["userName"] = userKV.Value.ToString();
  540. ConsentExecuteInfo["loginUserName"] = userKV.Value.ToString();
  541. }
  542. }
  543. else if (userKV.Key != null && !string.IsNullOrEmpty(userKV.Key.ToString()) && userKV.Key.ToString() == "USER_DEPTCD")
  544. {
  545. if (userKV.Value != null)
  546. {
  547. ConsentExecuteInfo["userDeptCd"] = userKV.Value.ToString();
  548. }
  549. }
  550. else if (userKV.Key != null && !string.IsNullOrEmpty(userKV.Key.ToString()) && userKV.Key.ToString() == "USER_DEPTNM")
  551. {
  552. if (userKV.Value != null)
  553. {
  554. ConsentExecuteInfo["userDeptName"] = userKV.Value.ToString();
  555. }
  556. }
  557. }
  558. }
  559. // 환자 정보
  560. if (callKV.Key != null && !string.IsNullOrEmpty(callKV.Key.ToString()) && callKV.Key.ToString() == "PATIENT_INFO")
  561. {
  562. foreach (KeyValuePair<string, object> patientKV in callKV.Value as Dictionary<string, object>)
  563. {
  564. if (patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "PTNT_NO")
  565. {
  566. if (patientKV.Value != null) ConsentExecuteInfo["patientNo"] = patientKV.Value.ToString();
  567. }
  568. if (patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "VISIT_TYPE")
  569. {
  570. if (patientKV.Value != null) ConsentExecuteInfo["visitType"] = patientKV.Value.ToString();
  571. }
  572. if (patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "CLN_DEPT")
  573. {
  574. if (patientKV.Value != null) ConsentExecuteInfo["clnDept"] = patientKV.Value.ToString();
  575. }
  576. if (patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "CLN_DATE")
  577. {
  578. if (patientKV.Value != null) ConsentExecuteInfo["clnDate"] = patientKV.Value.ToString();
  579. }
  580. if (patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "CRETNO")
  581. {
  582. if (patientKV.Value != null) ConsentExecuteInfo["cretno"] = patientKV.Value.ToString();
  583. }
  584. if (patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "CLN_DX_NM")
  585. {
  586. if (patientKV.Value != null) ConsentExecuteInfo["clnDxNm"] = patientKV.Value.ToString();
  587. }
  588. if (patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "OPRSRVNO")
  589. {
  590. if (patientKV.Value != null) ConsentExecuteInfo["opRsrvNo"] = patientKV.Value.ToString();
  591. }
  592. }
  593. }
  594. if (callKV.Key != null && !string.IsNullOrEmpty(callKV.Key.ToString()) && callKV.Key.ToString() == "EXEC_OPT")
  595. {
  596. // 화면 설정 정보
  597. foreach (KeyValuePair<string, object> execKV in callKV.Value as Dictionary<string, object>)
  598. {
  599. if (execKV.Key != null && !string.IsNullOrEmpty(execKV.Key.ToString()) && execKV.Key.ToString() == "USE_LIST_VIEW")
  600. {
  601. if (execKV.Value != null) ConsentExecuteInfo["useListView"] = execKV.Value.ToString(); // 동의서 리스트 사용 유무
  602. }
  603. if (execKV.Key != null && !string.IsNullOrEmpty(execKV.Key.ToString()) && execKV.Key.ToString() == "PTNT_LIST_VIEW")
  604. {
  605. if (execKV.Value != null) ConsentExecuteInfo["patientListView"] = execKV.Value.ToString(); // 환자 리스트 사용 유무
  606. }
  607. if (execKV.Key != null && !string.IsNullOrEmpty(execKV.Key.ToString()) && execKV.Key.ToString() == "START_FORM_CD")
  608. {
  609. if (execKV.Value != null) ConsentExecuteInfo["startFormCd"] = execKV.Value.ToString(); // 시작 FORM ID
  610. }
  611. if (execKV.Key != null && !string.IsNullOrEmpty(execKV.Key.ToString()) && execKV.Key.ToString() == "PTNT_ACT")
  612. {
  613. if (execKV.Value != null) ConsentExecuteInfo["printAct"] = execKV.Value.ToString(); // 초기 프린트
  614. }
  615. if (execKV.Key != null && !string.IsNullOrEmpty(execKV.Key.ToString()) && execKV.Key.ToString() == "PRINT_LIST")
  616. {
  617. if (execKV.Value != null)
  618. {
  619. if (execKV.Value is List<object> PatientList && PatientList.Count > 0)
  620. {
  621. PrintInfoList = new List<ConsentFormListVO>();
  622. ConsentFormListVO consentVO = new ConsentFormListVO();
  623. for (int i = 0; i < PatientList.Count; i++)
  624. {
  625. consentVO = new ConsentFormListVO {
  626. printCnt = -1
  627. };
  628. foreach (KeyValuePair<string, object> callOrderKV in PatientList[i] as Dictionary<string, object>)
  629. {
  630. if (callOrderKV.Key != null && !string.IsNullOrEmpty(callOrderKV.Key.ToString()) && callOrderKV.Value != null)
  631. {
  632. if (callOrderKV.Key.ToString() == "START_FORM_CD") consentVO.formCd = callOrderKV.Value.ToString(); // 출력 서식코드
  633. if (callOrderKV.Key.ToString() == "PTNT_NO") consentVO.pid = callOrderKV.Value.ToString(); // 환자번호
  634. if (callOrderKV.Key.ToString() == "VISIT_TYPE") consentVO.ordType= callOrderKV.Value.ToString(); // 내원구분
  635. if (callOrderKV.Key.ToString() == "CLN_DATE") consentVO.inDd = callOrderKV.Value.ToString(); // 진료일자
  636. if (callOrderKV.Key.ToString() == "CLN_DEPT") consentVO.ordDeptCd = callOrderKV.Value.ToString(); // 진료과
  637. if (callOrderKV.Key.ToString() == "PRINT_CNT")
  638. {
  639. int.TryParse(callOrderKV.Value.ToString(), out int PrntCnt);
  640. consentVO.printCnt = PrntCnt; // 출력 카운트
  641. }
  642. if (callOrderKV.Key.ToString() == "CRETNO")
  643. {
  644. int.TryParse(callOrderKV.Value.ToString(), out int cretno);
  645. consentVO.cretNo = cretno; // 차트번호
  646. }
  647. }
  648. }
  649. PrintInfoList.Add(consentVO);
  650. }
  651. if (execKV.Value != null) ConsentExecuteInfo["printList"] = PrintInfoList.Count.ToString(); // 출력 데이터
  652. }
  653. }
  654. }
  655. if (execKV.Key != null && !string.IsNullOrEmpty(execKV.Key.ToString()) && execKV.Key.ToString() == "FORMCD")
  656. { // 서식 코드
  657. if (execKV.Value != null) ConsentExecuteInfo["formCd"] = execKV.Value.ToString();
  658. }
  659. if (execKV.Key != null && !string.IsNullOrEmpty(execKV.Key.ToString()) && execKV.Key.ToString() == "OCRTAG")
  660. { // OCR 태그
  661. if (execKV.Value != null) ConsentExecuteInfo["ocrTag"] = execKV.Value.ToString();
  662. }
  663. if (execKV.Key != null && !string.IsNullOrEmpty(execKV.Key.ToString()) && execKV.Key.ToString() == "TEMP_SAVE")
  664. { // 임시 저장 (Ku2.0 연동)
  665. if (execKV.Value != null) ConsentExecuteInfo["tempSave"] = execKV.Value.ToString();
  666. }
  667. if (execKV.Key != null && !string.IsNullOrEmpty(execKV.Key.ToString()) && execKV.Key.ToString() == "PRINT_YN")
  668. { // 출력 여부 (Ku2.0 연동)
  669. if (execKV.Value != null) ConsentExecuteInfo["printYN"] = execKV.Value.ToString();
  670. }
  671. if (execKV.Key != null && !string.IsNullOrEmpty(execKV.Key.ToString()) && execKV.Key.ToString() == "PRINT_CNT")
  672. { // 출력 매수 (Ku2.0 연동)
  673. if (execKV.Value != null) ConsentExecuteInfo["printCount"] = execKV.Value.ToString();
  674. }
  675. if (execKV.Key != null && !string.IsNullOrEmpty(execKV.Key.ToString()) && execKV.Key.ToString() == "SYSINSTNM")
  676. { // 접속 서버 정보
  677. if (execKV.Value != null)
  678. {
  679. string instCd = string.Empty;
  680. instCd = execKV.Value.ToString().Contains("본원") ? "031" : execKV.Value.ToString().Contains("칠곡") ? "032" : string.Empty;
  681. instCd += execKV.Value.ToString().Contains("교육") ? "edu" : string.Empty;
  682. //instCd = "Dev";
  683. ConsentExecuteInfo["sysInstNm"] = instCd;
  684. }
  685. }
  686. if (execKV.Key != null && !string.IsNullOrEmpty(execKV.Key.ToString()) && execKV.Key.ToString() == "READONLY")
  687. { // 보기 전용 여부
  688. if (execKV.Value != null) ConsentExecuteInfo["readOnly"] = execKV.Value.ToString();
  689. }
  690. }
  691. }
  692. // 원무
  693. if (callKV.Key != null && !string.IsNullOrEmpty(callKV.Key.ToString()) && callKV.Key.ToString() == "PAM_INFO")
  694. {
  695. foreach (KeyValuePair<string, object> patientKV in callKV.Value as Dictionary<string, object>)
  696. {
  697. if (patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "SPEC_DR_YN")
  698. {
  699. if (patientKV.Value != null) ConsentExecuteInfo["SpecDoctorYN"] = patientKV.Value.ToString();
  700. }
  701. if (patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "CONT_START_DT")
  702. {
  703. if (patientKV.Value != null) ConsentExecuteInfo["ContStartDate"] = patientKV.Value.ToString();
  704. }
  705. if (patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "CONT_END_DT")
  706. {
  707. if (patientKV.Value != null) ConsentExecuteInfo["ContEndDate"] = patientKV.Value.ToString();
  708. }
  709. if (patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "ROOM_CAPA")
  710. {
  711. if (patientKV.Value != null) ConsentExecuteInfo["RoomCapa"] = patientKV.Value.ToString();
  712. }
  713. if (patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "CONT_TELNO")
  714. {
  715. if (patientKV.Value != null) ConsentExecuteInfo["ContTelNo"] = patientKV.Value.ToString();
  716. }
  717. if (patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "CONT_STAFF1")
  718. {
  719. if (patientKV.Value != null) ConsentExecuteInfo["ContStaff1Name"] = patientKV.Value.ToString();
  720. }
  721. if (patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "CONT_STAFF2")
  722. {
  723. if (patientKV.Value != null) ConsentExecuteInfo["ContStaff2Name"] = patientKV.Value.ToString();
  724. }
  725. if (patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "CONT_STAFF3")
  726. {
  727. if (patientKV.Value != null) ConsentExecuteInfo["ContStaff3Name"] = patientKV.Value.ToString();
  728. }
  729. if (patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "CARD_NO")
  730. {
  731. if (patientKV.Value != null) ConsentExecuteInfo["CardNo"] = patientKV.Value.ToString();
  732. }
  733. // 경대병원 원무 태그 추가
  734. if(patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "TAG1") {
  735. if(patientKV.Value != null)
  736. ConsentExecuteInfo["tag1"] = patientKV.Value.ToString();
  737. }
  738. if(patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "TAG2") {
  739. if(patientKV.Value != null)
  740. ConsentExecuteInfo["tag2"] = patientKV.Value.ToString();
  741. }
  742. if(patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "TAG3") {
  743. if(patientKV.Value != null)
  744. ConsentExecuteInfo["tag3"] = patientKV.Value.ToString();
  745. }
  746. if(patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "TAG4") {
  747. if(patientKV.Value != null)
  748. ConsentExecuteInfo["tag4"] = patientKV.Value.ToString();
  749. }
  750. if(patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "TAG5") {
  751. if(patientKV.Value != null)
  752. ConsentExecuteInfo["tag5"] = patientKV.Value.ToString();
  753. }
  754. if(patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "TAG6") {
  755. if(patientKV.Value != null)
  756. ConsentExecuteInfo["tag6"] = patientKV.Value.ToString();
  757. }
  758. if(patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "TAG7") {
  759. if(patientKV.Value != null)
  760. ConsentExecuteInfo["tag7"] = patientKV.Value.ToString();
  761. }
  762. if(patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "TAG8") {
  763. if(patientKV.Value != null)
  764. ConsentExecuteInfo["tag8"] = patientKV.Value.ToString();
  765. }
  766. if(patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "TAG9") {
  767. if(patientKV.Value != null)
  768. ConsentExecuteInfo["tag9"] = patientKV.Value.ToString();
  769. }
  770. if(patientKV.Key != null && !string.IsNullOrEmpty(patientKV.Key.ToString()) && patientKV.Key.ToString() == "TAG10") {
  771. if(patientKV.Value != null)
  772. ConsentExecuteInfo["tag10"] = patientKV.Value.ToString();
  773. }
  774. }
  775. }
  776. }
  777. }
  778. else
  779. {
  780. throw new Exception("CallParam 미전달");
  781. }
  782. // IP 주소 확인
  783. string printIp = string.Empty;
  784. foreach (System.Net.IPAddress ip in System.Net.Dns.GetHostAddresses(System.Net.Dns.GetHostName()))
  785. {
  786. if (ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
  787. {
  788. printIp = ip.ToString();
  789. break;
  790. }
  791. }
  792. // dbs227, 경북대학교병원 ip address 기록
  793. ConsentExecuteInfo["ipaddr"] = printIp;
  794. if (!printIp.Equals(string.Empty))
  795. {
  796. string[] ipArr = printIp.Split(new string[] { "." }, StringSplitOptions.RemoveEmptyEntries);
  797. if (ipArr.Length == 4)
  798. {
  799. printIp = string.Format("{0}.{1}", ipArr[2], ipArr[3]);
  800. }
  801. else
  802. {
  803. printIp = string.Empty;
  804. }
  805. }
  806. ConsentExecuteInfo["printIP"] = printIp;
  807. //버전정보
  808. string[] versionName = Assembly.GetExecutingAssembly().FullName.Split(',')[1].Split('.');
  809. string version = versionName[versionName.Length - 1];
  810. ConsentExecuteInfo["DeviceType"] = "WIN," + version + "," + ConsentExecuteInfo["dutinstcd"];
  811. }
  812. catch (Exception ex)
  813. {
  814. throw ex;
  815. }
  816. }
  817. /// <summary>
  818. /// 모니터 뷰 설정
  819. /// </summary>
  820. /// <param name="printMode">출력 여부</param>
  821. private void MoniterViewSetting(bool printMode)
  822. {
  823. // 출력 모드라면 화면에 나타내지 않는다
  824. if (printMode)
  825. {
  826. return;
  827. }
  828. //현재 프로그램이 실행되고 있는정보 가져오기: 디버깅 모드라면 bin/debug/프로그램명.exe
  829. FileInfo exefileinfo = new FileInfo(Path.GetDirectoryName(Application.StartupPath));
  830. // AppDomain.CurrentDomain.DynamicDirectory
  831. // Server.MapPath("~")
  832. string path = Path.GetDirectoryName(Application.StartupPath);//
  833. string fileName = @"\config.ini"; //파일명
  834. //만약 현재 실행 되는 경로가 아닌 특정한 위치를 원한다면 위에 과정 상관없이 바로 경로셋팅 해 주면 된다. (예: c:\config.ini)
  835. string filePath = path + fileName; //ini 파일 경로
  836. iniUtil ini = new iniUtil(filePath); // 만들어 놓았던 iniUtil 객체 생성(생성자 인자로 파일경로 정보 넘겨줌)
  837. //이제 ini 객체를 이용해 맘것 사용하면 된다.
  838. string sMoniterNumber = ini.GetIniValue("DFH", "MONITER_NUMBER");
  839. int iMoniterNumber = 0;
  840. int.TryParse(sMoniterNumber, out iMoniterNumber);
  841. Point location = Point.Empty;
  842. int j = 1;
  843. FormWindowState windowStateBackup;
  844. foreach (Screen sc in Screen.AllScreens)
  845. {
  846. // 출력할 모니터에 Form 을 생성하여 나타낸다
  847. if (j == iMoniterNumber)
  848. {
  849. Form parentForm = this.Parent as Form;
  850. if (parentForm != null)
  851. {
  852. windowStateBackup = parentForm.WindowState;
  853. Size size = parentForm.Bounds.Size;
  854. parentForm.WindowState = FormWindowState.Normal;
  855. parentForm.StartPosition = FormStartPosition.Manual;
  856. parentForm.ClientSize = new Size(size.Width, size.Height);
  857. parentForm.Location = new Point(sc.Bounds.Left, sc.Bounds.Top);
  858. parentForm.WindowState = windowStateBackup;
  859. }
  860. break;
  861. }
  862. j++;
  863. }
  864. }
  865. /// <summary>
  866. /// eFormViewer 컨트롤에 대한 초기화
  867. /// run option 설정
  868. /// </summary>
  869. private void InitEFormControl()
  870. {
  871. Screen screen = Screen.FromControl(this);
  872. var zoomRate = "100"; // 기본값
  873. var tempValue = hospitalWebService.getZoomRate(ConsentExecuteInfo["dutinstcd"]);
  874. if (!string.IsNullOrEmpty(tempValue))
  875. {
  876. zoomRate = tempValue;
  877. }
  878. if (screen.Primary)
  879. {
  880. //this.eFormViewerCtrl.SetRunOption("DEFAULT_ZOOM_RATE", "pagewidth");
  881. this.eFormViewerCtrl.SetRunOption("DEFAULT_ZOOM_RATE", zoomRate);
  882. }
  883. else
  884. {
  885. this.eFormViewerCtrl.SetRunOption("DEFAULT_ZOOM_RATE", "pagewidth");
  886. }
  887. string apiResult = string.Empty;
  888. string[] penOtps = null;
  889. //string alpathHexValue = "127"; // 기본 투명도
  890. string widthValue = "9"; // 기본 굵기
  891. System.Drawing.Color color = Color.FromArgb(127, 255, 255, 1); // 기본색
  892. if (hospitalWebService != null)
  893. {
  894. apiResult = hospitalWebService.getPenOptions(ConsentExecuteInfo["dutinstcd"]);
  895. if (apiResult.Length > 0)
  896. {
  897. penOtps = apiResult.Split(',');
  898. int alpha = Convert.ToInt32(penOtps[1]);
  899. int MULTI_CONST = 254;
  900. int MULTI_PEPRC = 100;
  901. string hexValue = penOtps[0].Replace("#", "");
  902. color = Color.FromArgb(Convert.ToInt32(penOtps[1]),
  903. Convert.ToInt32(hexValue.Substring(0, 2), 16),
  904. Convert.ToInt32(hexValue.Substring(2, 2), 16),
  905. Convert.ToInt32(hexValue.Substring(4, 2), 16));
  906. //color = System.Drawing.ColorTranslator.FromHtml(penOtps[0]);
  907. widthValue = penOtps[2];
  908. }
  909. }
  910. //this.eFormViewerCtrl.SetRunOption("ENABLE_DEBUG_VIEW", "true");
  911. //this.eFormViewerCtrl.SetRunOption("DEFAULT_TOOL_BAR_VISIBLE", "true");
  912. this.eFormViewerCtrl.SetRunOption("USE_CREDITCARD_SIGNPAD", "false");
  913. this.eFormViewerCtrl.SetRunOption("DEFAULT_TOOL_BAR_VISIBLE", "false");
  914. this.eFormViewerCtrl.SetRunOption("SET_EXTERNAL_CONTROL_DEFINED_PATH", this.PluginExecuteInfo["formServiceUrl"]);
  915. this.eFormViewerCtrl.SetRunOption("USE_EITHER_SIDE_MOVE_BUTTON", "true");
  916. this.eFormViewerCtrl.SetRunOption("DUALVIEWER_TOOL_BAR_SIZE", "32");
  917. var penStrValue = "{ \"width\":\"" + widthValue
  918. + "\",\"color\":{ \"a\":\""
  919. + color.A.ToString() + "\", \"r\":\""
  920. + color.R.ToString() + "\", \"g\":\""
  921. + color.G.ToString() + "\", \"b\":\""
  922. + color.B.ToString() + "\"} }";
  923. // dbs227, 경북대학교병원 옵션, 형광펜 색으로
  924. this.eFormViewerCtrl.SetRunOption("DRAWING_PEN", "{ \"width\":\"" + widthValue
  925. + "\",\"color\":{ \"a\":\""
  926. + color.A.ToString() + "\", \"r\":\""
  927. + color.R.ToString() + "\", \"g\":\""
  928. + color.G.ToString() + "\", \"b\":\""
  929. + color.B.ToString() + "\"} }");
  930. this.eFormViewerCtrl.SetRunOption("SET_VISIBLE_BUTTONS", "PAGE_ATTACH=true");
  931. this.eFormViewerCtrl.SetRunOption("IMAGE_SAVE_OPTION", "{\"dpi\":\"150\",\"gray\":\"false\",\"encode\":\"jpeg\",\"base-index\":\"1\",\"quality\":\"100\"}");
  932. // dbs227, 경북대학교병원 요청사항
  933. // 마우스 우클릭 그리기 모드 변경
  934. this.eFormViewerCtrl.SetRunOption("SET_MOUSE_RIGHT_CHANGE_MODE", "Drawing");
  935. // true 로 설정 시 TabPoint 프로그램을 통한 듀얼 모니터 제어
  936. // false 로 설정 시 윈도우 드라이버로 듀얼 보니터 제어
  937. //this.eFormViewerCtrl.SetRunOption("USE_DUALVIEWER_ACU", "true");
  938. if (HasVerticalMonitor)
  939. {
  940. this.eFormViewerCtrl.SetRunOption("RUN_AS_DUALVIEWER", "CLIP.eForm.DualViewer.dll");
  941. // this.eFormViewerCtrl.SetRunOption("READ_ONLY", "true");
  942. this.eFormViewerCtrl.SetRunOption("DUALVIEWER_TO_ACTIVATE_CONTROLS", "true");
  943. this.eFormViewerCtrl.SetRunOption("SET_VISIBLE_DUALVIEWER_TOOLSTRIP_MENU", "false");
  944. this.eFormViewerCtrl.SetRunOption("DUALVIEWER_TOOL_BAR_ENABLE", "true");
  945. // 툴바 위치 조절(true : 상단, false : 하단)
  946. this.eFormViewerCtrl.SetRunOption("USE_DUALVIEWER_TOOL_BAR_TOP", "false");
  947. // 가상키보드 사용 여부
  948. this.eFormViewerCtrl.SetRunOption("DUALVIEWER_VIRTUAL_KEYBOARD_VISIBLE", "true");
  949. // 관리자 권한 실행 저장 여부
  950. this.eFormViewerCtrl.SetRunOption("USE_ADMIN_PRIVILEGES_SAVE_EXECUTE", "false");
  951. this.eFormViewerCtrl.SetRunOption("DUALVIEWER_RESOLUTION", "{\"width\":\"768\",\"height\":\"1024\"}");
  952. }
  953. }
  954. /// <summary>
  955. /// Invokes the delayed load event.
  956. /// </summary>
  957. private void InvokeDelayedLoadEvent() // TODO: 리팩터링 대상 comment by jchong 2016.06.11
  958. {
  959. if (this.OnLoadPartControls != null)
  960. {
  961. Application.DoEvents();
  962. Thread.Sleep(1);
  963. OnLoadPartControls.Invoke(this, new EventArgs());
  964. }
  965. }
  966. /// <summary>
  967. /// </summary>
  968. /// <param name="msg">A <see cref="T:System.Windows.Forms.Message" />, passed by reference, that represents the window message to process.</param>
  969. /// <param name="keyData">One of the <see cref="T:System.Windows.Forms.Keys" /> values that represents the key to process.</param>
  970. /// <returns>
  971. /// true if the character was processed by the control; otherwise, false.
  972. /// </returns>
  973. protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
  974. {
  975. if (msg.Msg == 0x100)
  976. {
  977. if (keyData == Keys.PageUp)
  978. {
  979. this.eFormViewerCtrl.MovePrevPage();
  980. }
  981. if (keyData == Keys.Next)
  982. {
  983. this.eFormViewerCtrl.MoveNextPage();
  984. }
  985. }
  986. return base.ProcessCmdKey(ref msg, keyData);
  987. }
  988. /// <summary>
  989. /// Consents the main control UI update on drawing.
  990. /// </summary>
  991. /// <param name="sender">The sender.</param>
  992. /// <param name="undoStackCount">The undo stack count.</param>
  993. /// <param name="redoStackCount">The redo stack count.</param>
  994. /// <param name="totalStrokeCount">The total stroke count.</param>
  995. /// <param name="totalAllPageStrokeCoun">The total all page stroke coun.</param>
  996. void ConsentMainControl_UIUpdateOnDrawing(object sender, int undoStackCount, int redoStackCount, int totalStrokeCount, int totalAllPageStrokeCoun)
  997. {
  998. if (undoStackCount > 0)
  999. {
  1000. this.consentCommandCtrl.EnableUndo = true;
  1001. }
  1002. else
  1003. {
  1004. this.consentCommandCtrl.EnableUndo = false;
  1005. }
  1006. if (redoStackCount > 0)
  1007. {
  1008. this.consentCommandCtrl.EnableRedo = true;
  1009. }
  1010. else
  1011. {
  1012. this.consentCommandCtrl.EnableRedo = false;
  1013. }
  1014. if (totalStrokeCount > 0)
  1015. {
  1016. this.consentCommandCtrl.EnableRemoveAll = true;
  1017. }
  1018. else
  1019. {
  1020. this.consentCommandCtrl.EnableRemoveAll = false;
  1021. }
  1022. }
  1023. ConsentListCtrlBase IConsentMain.ConsentListCtrl
  1024. {
  1025. get { return this.consentListCtrl; }
  1026. }
  1027. PatientInfoCtrlBase IConsentMain.PatientInfoCtrl
  1028. {
  1029. get { return this.patientInfoCtrl; }
  1030. }
  1031. PatientListCtrlBase IConsentMain.PatientListCtrl
  1032. {
  1033. get { return this.patientListCtrl; }
  1034. }
  1035. Dictionary<string, string> IConsentMain.ConsentExecuteInfo
  1036. {
  1037. get
  1038. {
  1039. return this.ConsentExecuteInfo;
  1040. }
  1041. set
  1042. {
  1043. this.ConsentExecuteInfo = value;
  1044. }
  1045. }
  1046. Dictionary<string, string> IConsentMain.PluginExecuteInfo
  1047. {
  1048. get
  1049. {
  1050. return this.PluginExecuteInfo;
  1051. }
  1052. set
  1053. {
  1054. this.PluginExecuteInfo = value;
  1055. }
  1056. }
  1057. ConsentCommandCtrlBase IConsentMain.ConsentCommandCtrl
  1058. {
  1059. get
  1060. {
  1061. return this.consentCommandCtrl;
  1062. }
  1063. }
  1064. void IConsentMain.changeInDd(string inDd)
  1065. {
  1066. consentListCtrl.changeInDd(inDd);
  1067. }
  1068. public Dictionary<string, object> ProcessResultValue
  1069. {
  1070. get
  1071. {
  1072. return processResultValues;
  1073. }
  1074. }
  1075. /// <summary>
  1076. /// 환자 정보가 바뀌었을때 컨트롤들의 정보를 재조회
  1077. /// </summary>
  1078. /// <param name="visitType">Type of the visit.</param>
  1079. void IConsentMain.UIControlsRefeash(string visitType)
  1080. {
  1081. this.patientInfoCtrl.OnRefeashPartControls(visitType);
  1082. this.consentListCtrl.OnRefeashPartControls();
  1083. }
  1084. /// <summary>
  1085. /// 사용자 정보 변경
  1086. /// </summary>
  1087. /// <param name="pInstCd">근무지기관코드</param>
  1088. /// <param name="pUserId">사용자ID</param>
  1089. /// <param name="DutPlceCd">근무지부서</param>
  1090. void IConsentMain.SetConsentUserInfo(string pInstCd, string pUserId, string DutPlceCd)
  1091. {
  1092. this.patientInfoCtrl.SetConsentUserInfo(pUserId, pInstCd, DutPlceCd);
  1093. }
  1094. void IConsentMain.SetConsentUserInfo(string pInstCd, string pUserId, string DutPlceCd, string temp) {
  1095. this.patientInfoCtrl.SetConsentUserInfo(pUserId, pInstCd, DutPlceCd);
  1096. }
  1097. void IConsentMain.ClearPreviewConsent(bool pDoInit)
  1098. {
  1099. consentCommandCtrl.CurrentPreviewConsent = null;
  1100. patientInfoCtrl.SetConsentDocumentName("");
  1101. if (pDoInit)
  1102. {
  1103. eFormViewerCtrl.Visible = false;
  1104. eFormViewerCtrl.CloseDualViewer();
  1105. //eFormViewerCtrl.ReInitializeViewer();
  1106. imageViewCtrl1.Hide();
  1107. }
  1108. }
  1109. void IConsentMain.PreviewConsent(string fos)
  1110. {
  1111. this.pnlCommand.Visible = true;
  1112. this.pnlViewer.Visible = false;
  1113. this.eFormViewerCtrl.Visible = true;
  1114. //eFormViewerCtrl.SetRunOption("RUN_AS_REPOSITORY_V2", "true"); //v2 설정
  1115. this.eFormViewerCtrl.OpenFos(fos);
  1116. }
  1117. void IConsentMain.ClearConsent()
  1118. {
  1119. this.pnlCommand.Visible = true;
  1120. this.pnlViewer.Visible = false;
  1121. this.eFormViewerCtrl.Visible = true;
  1122. this.eFormViewerCtrl.Open();
  1123. }
  1124. void IConsentMain.ReviewConsent()
  1125. {
  1126. this.pnlCommand.Visible = false;
  1127. this.pnlViewer.Visible = true;
  1128. this.eFormViewerCtrl.Visible = false;
  1129. eFormViewerCtrl.CloseDualViewer();
  1130. }
  1131. void IConsentMain.RunConsentDualView()
  1132. {
  1133. this.eFormViewerCtrl.OpenDualViewer();
  1134. }
  1135. /// <summary>
  1136. /// Prints the consent document.
  1137. /// 수동으로 찾아서출력
  1138. /// 일반 출력의 경우에도 기본프린터로 바로 출력하는 것으로 변경됨
  1139. /// </summary>
  1140. /// <param name="fos">The fos.</param>
  1141. void IConsentMain.PrintConsentDocument(string fos)
  1142. {
  1143. //int rid = -1;
  1144. if (!string.IsNullOrEmpty(fos))
  1145. {
  1146. this.eFormViewerCtrl.OpenFos(fos);
  1147. // dbs227 DB 기록 필요
  1148. //rid = this.consentCommandCtrl.SaveDataForPrintedConsent(String.Empty);
  1149. }
  1150. this.printSaveStatus = false;
  1151. int iPrntCnt = 0;
  1152. //PC 클라이언트에서 출력 버튼 눌럿을때를 구분하여 pageCount넘겨줌
  1153. //pageCount를 넘겨주지 않고 consentCommandCtrl.CurrentPreviewConsent.PrntCnt에서 출력 장수를 받았을때 초기화되어 익셉션 발생
  1154. if (printButtonClick)
  1155. {
  1156. iPrntCnt = pageCnt;
  1157. printButtonClick = false;
  1158. }
  1159. else
  1160. {
  1161. iPrntCnt = consentCommandCtrl.CurrentPreviewConsent.prntCnt;
  1162. }
  1163. this.multiPrintPlanCnt = iPrntCnt;
  1164. this.multiPrintExecCnt = 0;
  1165. this.checkAutoPrint = false; //수동출력
  1166. if (iPrntCnt > 0)
  1167. {
  1168. // 출력매수만큼 동의서 출력
  1169. //for (int i = 0; i < iPrntCnt; i++)
  1170. //{
  1171. // if((i+1) == iPrntCnt) this.printSaveStatus = true;
  1172. this.printSaveStatus = true;
  1173. this.eFormViewerCtrl.PrintByPrinterName("");
  1174. //}
  1175. }
  1176. this.printSaveStatus = false;
  1177. // dbs227,
  1178. // 출력 모드가 아닐때는 초기화 하지 않는다.
  1179. //if (rid > 0)
  1180. //{
  1181. // this.consentListCtrl.InquiryConsentData(rid);
  1182. //}
  1183. }
  1184. /// <summary>
  1185. /// 기본프린터로 출력, Agent에서 직접출력
  1186. /// dbs227, 경북대학교병원 사용하지 않음
  1187. /// </summary>
  1188. /// <param name="fos">출력할 FOS string</param>
  1189. void IConsentMain.PrintDirect(string fos)
  1190. {
  1191. if (!string.IsNullOrEmpty(fos))
  1192. {
  1193. // dbs227 DB 기록 필요
  1194. //this.consentCommandCtrl.SaveDataForPrintedConsent(String.Empty);
  1195. this.eFormViewerCtrl.OpenFos(fos);
  1196. //this.consentCommandCtrl.SaveDataForPrintedConsent(String.Empty);
  1197. }
  1198. int prntCnt = 0;
  1199. prntCnt = consentCommandCtrl.CurrentPreviewConsent.prntCnt;
  1200. this.checkAutoPrint = true;//자동출력
  1201. if (!string.IsNullOrEmpty(this.ConsentExecuteInfo["printList"]))
  1202. {
  1203. if (!ConsentExecuteInfo["prntCnt"].Equals("-1"))
  1204. {
  1205. int.TryParse(this.ConsentExecuteInfo["prntCnt"].ToString(), out prntCnt);
  1206. }
  1207. }
  1208. this.multiPrintPlanCnt = prntCnt;
  1209. this.multiPrintExecCnt = 0;
  1210. if (prntCnt > 0)
  1211. {
  1212. //this.printSaveStatus = false;
  1213. //// 출력매수만큼 동의서 출력
  1214. //for (int i = 0; i < prntCnt; i++)
  1215. //{
  1216. // if ((i + 1) == prntCnt) this.printSaveStatus = true;
  1217. this.printSaveStatus = true;
  1218. //기본프린터로 바로 출력하기로 함
  1219. this.eFormViewerCtrl.PrintByPrinterName("");
  1220. //}
  1221. //this.printSaveStatus = false;
  1222. }
  1223. }
  1224. void IConsentMain.MoveFirstPage()
  1225. {
  1226. this.eFormViewerCtrl.MoveFirstPage();
  1227. }
  1228. void IConsentMain.MovePrevPage()
  1229. {
  1230. this.eFormViewerCtrl.MovePrevPage();
  1231. }
  1232. void IConsentMain.MoveNextPage()
  1233. {
  1234. this.eFormViewerCtrl.MoveNextPage();
  1235. }
  1236. void IConsentMain.MoveLastPage()
  1237. {
  1238. this.eFormViewerCtrl.MoveLastPage();
  1239. }
  1240. void IConsentMain.Save()
  1241. {
  1242. this.eFormViewerCtrl.Save();
  1243. }
  1244. /// <summary>
  1245. /// eFormViewerCtrl 컨트롤의 TempSave 이벤트를 호출
  1246. /// </summary>
  1247. void IConsentMain.TempSave()
  1248. {
  1249. this.eFormViewerCtrl.TempSave();
  1250. }
  1251. int IConsentMain.GetCurrentPageIndex()
  1252. {
  1253. return this.eFormViewerCtrl.GetCurrentPageIndex();
  1254. }
  1255. int IConsentMain.GetTotalPageCount()
  1256. {
  1257. return this.eFormViewerCtrl.GetTotalPageCount();
  1258. }
  1259. void IConsentMain.MoveToPageIndex(int pageIndex)
  1260. {
  1261. this.eFormViewerCtrl.MoveToPageIndex(pageIndex);
  1262. }
  1263. void IConsentMain.SetZoomRate(string zoomRate)
  1264. {
  1265. this.eFormViewerCtrl.SetZoomRate(zoomRate);
  1266. }
  1267. void IConsentMain.EnableDrawing(bool enable)
  1268. {
  1269. this.eFormViewerCtrl.EnableDrawing(enable);
  1270. }
  1271. bool IConsentMain.IsDrawMode()
  1272. {
  1273. return this.eFormViewerCtrl.IsDrawMode();
  1274. }
  1275. void IConsentMain.RemoveAllDrawing()
  1276. {
  1277. this.eFormViewerCtrl.RemoveAllDrawing();
  1278. }
  1279. void IConsentMain.UndoDrawing()
  1280. {
  1281. this.eFormViewerCtrl.UndoDrawing();
  1282. }
  1283. void IConsentMain.RedoDrawing()
  1284. {
  1285. this.eFormViewerCtrl.RedoDrawing();
  1286. }
  1287. void IConsentMain.ConfigDrawingPen()
  1288. {
  1289. this.eFormViewerCtrl.ConfigDrawingPen();
  1290. }
  1291. void IConsentMain.SetFingerScanValue(string controlId, string base64Image)
  1292. {
  1293. this.eFormViewerCtrl.SetFingerPrintImage(controlId, base64Image, true);
  1294. }
  1295. void IConsentMain.SetSignatureImage(string controlId, string base64Image)
  1296. {
  1297. this.eFormViewerCtrl.SetSignatureImage(controlId, base64Image, true);
  1298. }
  1299. public CLIP.eForm.ImageView.ImageViewCtrl GetImageViewerCtrl()
  1300. {
  1301. return this.imageViewCtrl1;
  1302. }
  1303. void IConsentMain.CloseSignaturePopup(string controlId)
  1304. {
  1305. this.eFormViewerCtrl.CloseSignaturePopup(controlId);
  1306. }
  1307. void IConsentMain.SetRunOption(string optionKey, string optionValue)
  1308. {
  1309. this.eFormViewerCtrl.SetRunOption(optionKey, optionValue);
  1310. }
  1311. void IConsentMain.TerminateConsentMain()
  1312. {
  1313. if (this.Parent is System.Windows.Forms.Form)
  1314. {
  1315. ((Form)this.Parent).DialogResult = DialogResult.Cancel;
  1316. ((Form)this.Parent).Close();
  1317. }
  1318. }
  1319. /// <summary>
  1320. /// 첨지 삭제
  1321. /// </summary>
  1322. void IConsentMain.DeleteAttach()
  1323. {
  1324. this.eFormViewerCtrl.DeleteAttach();
  1325. }
  1326. /// <summary>
  1327. /// 첨지 추가
  1328. /// </summary>
  1329. void IConsentMain.InsertAttach()
  1330. {
  1331. this.eFormViewerCtrl.InsertAttach();
  1332. }
  1333. /// <summary>
  1334. /// 환자정보 설정
  1335. /// </summary>
  1336. void IConsentMain.SetPatientInfo()
  1337. {
  1338. this.patientInfoCtrl.SetPatientInfo();
  1339. }
  1340. /// <summary>
  1341. /// Closes the dual viewer.
  1342. /// </summary>
  1343. public void CloseDualViewer()
  1344. {
  1345. this.eFormViewerCtrl.CloseDualViewer();
  1346. this.consentCommandCtrl.SetEnableConsentIssueCommands(true);
  1347. this.consentCommandCtrl.SetEnableButtonsByCurrentConsent();
  1348. }
  1349. /// <summary>
  1350. /// 서명 시 이미지 파일 생성 된 후 호출
  1351. /// </summary>
  1352. /// <param name="value">저장 이미지 파일 설명</param>
  1353. private void OnWrittenImageFile(string value)
  1354. {
  1355. this.consentCommandCtrl.WorkExtraWithSavedImageFiles(value);
  1356. }
  1357. /// <summary>
  1358. /// Called when [written data XML file].
  1359. /// </summary>
  1360. /// <param name="value">The value.</param>
  1361. private void OnWrittenDataXmlFile(string value)
  1362. {
  1363. string dataXmlValue = string.Empty;
  1364. if (!string.IsNullOrEmpty(value))
  1365. {
  1366. XmlDocument xmlDocument = new XmlDocument();
  1367. xmlDocument.Load(value);
  1368. dataXmlValue = xmlDocument.InnerXml;
  1369. outputDataDic = new Dictionary<string, string>();
  1370. XmlNode rootNode = xmlDocument.SelectSingleNode("form-data");
  1371. foreach (XmlNode childNode in rootNode.ChildNodes)
  1372. {
  1373. string fieldName = string.Empty;
  1374. string fieldValue = string.Empty;
  1375. XmlElement outFieldElement = childNode as XmlElement;
  1376. if (outFieldElement != null)
  1377. {
  1378. fieldName = outFieldElement.Name;
  1379. if (outFieldElement.ChildNodes.Count > 0
  1380. && outFieldElement.ChildNodes[0] is XmlCDataSection)
  1381. {
  1382. fieldValue = ((XmlCDataSection)outFieldElement.ChildNodes[0]).InnerText;
  1383. }
  1384. if (outputDataDic.ContainsKey(fieldName))
  1385. {
  1386. outputDataDic[fieldName] = fieldValue;
  1387. }
  1388. else
  1389. {
  1390. outputDataDic.Add(fieldName, fieldValue);
  1391. }
  1392. }
  1393. }
  1394. if (processResultValues.ContainsKey("OUTPUT_VALUES"))
  1395. {
  1396. processResultValues["OUTPUT_VALUES"] = outputDataDic;
  1397. }
  1398. else
  1399. {
  1400. processResultValues.Add("OUTPUT_VALUES", outputDataDic);
  1401. }
  1402. }
  1403. try
  1404. {
  1405. SingleReturnData returnData = this.consentWebService.CheckConsentState(int.Parse(consentCommandCtrl.CurrentPreviewConsent.consentMstRid), consentCommandCtrl.CurrentPreviewConsent.consentState);
  1406. //int state = this.consentWebService.CheckConsentState(int.Parse(consentCommandCtrl.CurrentPreviewConsent.ConsentMstRid), consentCommandCtrl.CurrentPreviewConsent.ConsentState);
  1407. int state = Int32.Parse(returnData.responseData);
  1408. if (state == 1)
  1409. {
  1410. MessageBoxDlg.Show(this, "이미 저장된 서식 입니다."
  1411. , string.Format(Properties.Resources.msg_caption_confirm),
  1412. MessageBoxButtons.OK, MessageBoxIcon.Information);
  1413. return;
  1414. }
  1415. string eptXmlValue = this.eFormViewerCtrl.GetTempSaveForm();
  1416. bool isSaved = this.consentCommandCtrl.SaveCompleteConsentData(eptXmlValue, dataXmlValue, out object saveResult);
  1417. if (processResultValues.ContainsKey("OTHER_VALUE_1"))
  1418. {
  1419. processResultValues["OTHER_VALUE_1"] = saveResult;
  1420. }
  1421. else
  1422. {
  1423. processResultValues.Add("OTHER_VALUE_1", saveResult);
  1424. }
  1425. if (isSaved)
  1426. {
  1427. if (ProcessResult != null)
  1428. {
  1429. ProcessResult.Invoke("SUCCESS");
  1430. }
  1431. }
  1432. else
  1433. {
  1434. ProcessResult.Invoke("FAIL");
  1435. }
  1436. }
  1437. catch (Exception ex)
  1438. {
  1439. System.Diagnostics.Trace.WriteLine(string.Format("CLIP.eForm error: {0}", ex.Message));
  1440. MessageBoxDlg.Show(true, string.Format(ex.Message)
  1441. , string.Format(Properties.Resources.msg_caption_fail),
  1442. MessageBoxButtons.OK, MessageBoxIcon.Error);
  1443. initConsent();
  1444. ProcessResult.Invoke("FAIL");
  1445. }
  1446. finally
  1447. {
  1448. if (multiParams == null)
  1449. {
  1450. this.eFormViewerCtrl.CloseDualViewer();
  1451. }
  1452. }
  1453. }
  1454. private void OnWrittenTempSaveFile(string value)
  1455. {
  1456. XmlDocument xmlDocument = new XmlDocument();
  1457. xmlDocument.Load(value);
  1458. string eptXmlValue = xmlDocument.InnerXml;
  1459. try
  1460. {
  1461. string dataXml = this.eFormViewerCtrl.GetDataXml();
  1462. consentCommandCtrl.SaveTempConsentData(eptXmlValue, dataXml);
  1463. }
  1464. catch (Exception ex)
  1465. {
  1466. System.Diagnostics.Trace.WriteLine(string.Format("CLIP.eForm error: {0}", ex.Message));
  1467. MessageBoxDlg.Show(true, string.Format(ex.Message)
  1468. , string.Format(Properties.Resources.msg_caption_fail),
  1469. MessageBoxButtons.OK, MessageBoxIcon.Error);
  1470. initConsent();
  1471. return;
  1472. }
  1473. finally
  1474. {
  1475. if (multiParams == null)
  1476. {
  1477. this.eFormViewerCtrl.CloseDualViewer();
  1478. }
  1479. }
  1480. }
  1481. public void SetConsentListSplitPanelVisibility(bool visibility)
  1482. {
  1483. if (!visibility)
  1484. {
  1485. this.splitConsent.Panel1Collapsed = true;
  1486. }
  1487. }
  1488. public void SetPatientListSplitPanelVisibility(bool visibility)
  1489. {
  1490. if (!visibility)
  1491. {
  1492. this.splitPatient.Panel2Collapsed = true;
  1493. }
  1494. }
  1495. public bool UseFingerScan { get; set; }
  1496. public bool viewStatus { get; set; }
  1497. public bool IsComplete()
  1498. {
  1499. bool _isComplete = false;
  1500. if (consentCommandCtrl != null && consentCommandCtrl.CurrentPreviewConsent != null)
  1501. {
  1502. string _state = consentCommandCtrl.CurrentPreviewConsent.consentState ?? string.Empty;
  1503. if (_state.Equals("ELECTR_CMP"))
  1504. {
  1505. _isComplete = true;
  1506. }
  1507. }
  1508. return _isComplete;
  1509. }
  1510. private void panelReview_Resize(object sender, EventArgs e)
  1511. {
  1512. if (this.pnlViewer.Visible)
  1513. {
  1514. if (OnResizeReviewConsent != null)
  1515. {
  1516. OnResizeReviewConsent.Invoke(this, new EventArgs());
  1517. }
  1518. }
  1519. }
  1520. /// <summary>
  1521. /// 동의서 뷰어 컨트롤 OnError 이벤트 핸들러
  1522. /// </summary>
  1523. /// <param name="errorCode">에러코드</param>
  1524. /// <param name="errorMessage">에러 메시지</param>
  1525. private void eFormViewerCtrl_OnError(string errorCode, string errorMessage)
  1526. {
  1527. }
  1528. /// <summary>
  1529. /// 동의서 뷰어 컨트롤 OnProcess 이벤트 핸들러
  1530. /// </summary>
  1531. /// <param name="eventCode">이벤트 코드</param>
  1532. /// <param name="value">이벤트 값</param>
  1533. private void eFormViewerCtrl_OnProcess(string eventCode, string value)
  1534. {
  1535. System.Diagnostics.Trace.WriteLine(string.Format("eventCode: {0} - value: {1}", eventCode, value));
  1536. // 동의서의 현제 페이지 번호 설정
  1537. if (eventCode.Equals("PAGING"))
  1538. {
  1539. this.consentCommandCtrl.OnPaging(this.eFormViewerCtrl.GetCurrentPageIndex());
  1540. }
  1541. // 듀얼 뷰어 버튼 활성화 여부 제어?
  1542. if (eventCode.Equals("DUAL_VIEWER"))
  1543. {
  1544. if (value.Equals("OPEN"))
  1545. {
  1546. this.consentListCtrl.Enabled = false;
  1547. this.patientInfoCtrl.Enabled = false;
  1548. this.patientListCtrl.Enabled = false;
  1549. // this.eFormViewerCtrl.SetRunOption("READ_ONLY", "false");
  1550. this.consentCommandCtrl.EnablePenDrawing = true;
  1551. this.consentCommandCtrl.EnablePenConfig = true;
  1552. if (multiParams != null)
  1553. {
  1554. consentCommandCtrl.setMultiParamsDualViewrStripButton();
  1555. }
  1556. else
  1557. {
  1558. this.consentCommandCtrl.SetEnablementExecuteWhenDualViewerActive(false);
  1559. }
  1560. }
  1561. if (value.Equals("CLOSE"))
  1562. {
  1563. this.consentListCtrl.Enabled = true;
  1564. this.patientInfoCtrl.Enabled = true;
  1565. this.patientListCtrl.Enabled = true;
  1566. // this.eFormViewerCtrl.SetRunOption("READ_ONLY", "true");
  1567. this.consentCommandCtrl.EnablePenDrawing = false;
  1568. this.consentCommandCtrl.EnablePenConfig = false;
  1569. this.consentCommandCtrl.onEnableDrawing(false);
  1570. this.eFormViewerCtrl.EnableDrawing(false);
  1571. this.consentCommandCtrl.SetEnablementExecuteWhenDualViewerActive(true);
  1572. }
  1573. }
  1574. // 동의서 작성완료 후 이미지 저장
  1575. if (eventCode.Equals("WRITTEN_IMAGE_FILE"))
  1576. {
  1577. // 확인 저장 시 이미지는 저장 함
  1578. //if (!consentCommandCtrl.IsComplete)
  1579. {
  1580. this.OnWrittenImageFile(value);
  1581. }
  1582. }
  1583. // 동의서 작성완료 후 Data XML 저장
  1584. if (eventCode.Equals("DATA_XML_PATH"))
  1585. {
  1586. // [확인] 시에는 임시 저장만 한다.
  1587. //if (consentCommandCtrl.IsComplete) {
  1588. // eFormViewerCtrl.TempSave();
  1589. //}
  1590. // 작성완료 버튼이 활성화 되어 있을 경우에만 작성완료 로직을 진행한다.
  1591. //else if (this.consentCommandCtrl.getSaveButton()) {
  1592. if (this.consentCommandCtrl.getSaveButton())
  1593. {
  1594. this.consentCommandCtrl.setSaveButton(false);
  1595. this.OnWrittenDataXmlFile(value);
  1596. this.consentCommandCtrl.setSaveButton(true);
  1597. this.eFormViewerCtrl.ConfirmSave(true, "");
  1598. //정상저장 후 다중서식 작업중일 경우 다음 동의서를 로드한다
  1599. if (processResultValues.ContainsKey("OTHER_VALUE_1") && processResultValues["OTHER_VALUE_1"].ToString().Equals("1"))
  1600. {
  1601. if (multiParams != null)
  1602. {
  1603. showNextConsent();
  1604. }
  1605. }
  1606. }
  1607. }
  1608. // 동의서 임시저장
  1609. if (eventCode.Equals("TEMP_SAVE_PATH"))
  1610. {
  1611. // 임시저장 버튼이 활성화 되어 있을 경우에만 임시저장 로직을 진행한다.
  1612. // Ku2.0 연동 시 임시저장 로직을 진행한다.
  1613. // 작성 완료 시
  1614. if (this.consentCommandCtrl.getTempSaveButton() || ConsentExecuteInfo["printYN"].Equals("Y") || consentCommandCtrl.IsComplete)
  1615. {
  1616. this.consentCommandCtrl.setTempSaveButton(false);
  1617. this.OnWrittenTempSaveFile(value);
  1618. if (!consentCommandCtrl.IsComplete)
  1619. {
  1620. this.consentCommandCtrl.setTempSaveButton(true);
  1621. }
  1622. this.eFormViewerCtrl.ConfirmSave(true, "");
  1623. }
  1624. //다중서식 작업중일 경우 다음 동의서를 출력한다
  1625. if (multiParams != null)
  1626. {
  1627. showNextConsent();
  1628. }
  1629. }
  1630. // 동의서 종이 출력
  1631. if (eventCode.Equals("PRINT_COMPLETE"))
  1632. {
  1633. //this.consentCommandCtrl.OnPrint(value);
  1634. // dbs227, 출력 로그 업데이트
  1635. // 출력을 위한 호출일 경우 form 을 종료한다
  1636. if (printConsentCount == 0 && ConsentExecuteInfo["printYN"].Equals("Y"))
  1637. {
  1638. Form parentForm = this.Parent as Form;
  1639. if (parentForm != null)
  1640. {
  1641. parentForm.Close();
  1642. }
  1643. }
  1644. }
  1645. // dbs227, 동의서 프린트 실패
  1646. if (eventCode.Equals("PRINT_FAIL") || eventCode.Equals("PRINT_CANCEL"))
  1647. {
  1648. // 추후 업무 협의 후 진행
  1649. //consentCommandCtrl.erasePrintHistory();
  1650. }
  1651. //필수 항목 누락시 메시지 박스 호출
  1652. if (eventCode.Equals("REQUIRED_INPUT_VIOLATION"))
  1653. {
  1654. this.consentCommandCtrl.OnRequiredInputViolation(value);
  1655. }
  1656. // 펜 그리기 모드 활성화 여부 제어
  1657. if (eventCode.Equals("ENABLE_DRAWING"))
  1658. {
  1659. if (value.Equals("TRUE"))
  1660. {
  1661. this.consentCommandCtrl.onEnableDrawing(true);
  1662. }
  1663. else if (value.Equals("FALSE"))
  1664. {
  1665. this.consentCommandCtrl.onEnableDrawing(false);
  1666. }
  1667. }
  1668. // 초기화 상태
  1669. if (eventCode.Equals("INITIALIZE_STATE"))
  1670. {
  1671. if (value.Equals("FormViewInitialized"))
  1672. {
  1673. viewStatus = true;
  1674. }
  1675. }
  1676. // 그외 이벤트
  1677. // 동의서 저장 버튼 활셩화여부 제어
  1678. // 동의서 임시서장 버튼 활성화 여부 반환(get)
  1679. // 동의서 임시저장 버튼 활성화 여부 제어(set)
  1680. }
  1681. private void eFormViewerCtrl_VisibleChanged(object sender, EventArgs e)
  1682. {
  1683. if (this.eFormViewerCtrl.Visible)
  1684. {
  1685. if (this.OnVisibleEFormControl != null)
  1686. {
  1687. this.OnVisibleEFormControl.Invoke(this, new EventArgs());
  1688. }
  1689. }
  1690. else
  1691. {
  1692. if (this.OnInvisibleEFormControl != null)
  1693. {
  1694. this.OnInvisibleEFormControl.Invoke(this, new EventArgs());
  1695. }
  1696. }
  1697. }
  1698. /// <summary>
  1699. /// startFormCd 를 초기화 한다
  1700. /// </summary>
  1701. public void preParamClean()
  1702. {
  1703. this.ConsentExecuteInfo["startFormCd"] = string.Empty;
  1704. }
  1705. void IConsentMain.ReInitializeViewer()
  1706. {
  1707. if (eFormViewerCtrl.GetTotalPageCount() > 0)
  1708. {
  1709. eFormViewerCtrl.Visible = false;
  1710. eFormViewerCtrl.CloseDualViewer();
  1711. //this.eFormViewerCtrl.ReInitializeViewer();
  1712. }
  1713. this.viewStatus = false;
  1714. }
  1715. public void OnProcessCmdKey(Keys keyData)
  1716. {
  1717. }
  1718. /// <summary>
  1719. /// OCX 에서 넘겨 받은 FORMCD 리스트를 서버에서 조회해 온다
  1720. /// </summary>
  1721. private void GetConsentListByFormcd()
  1722. {
  1723. try
  1724. {
  1725. string[] formCdArr = ConsentExecuteInfo["formCd"].Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
  1726. string[] ocrTagArr = ConsentExecuteInfo["ocrTag"].Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
  1727. printConsentCount = formCdArr.Length;
  1728. for (int i = 0; i < formCdArr.Length; i++)
  1729. {
  1730. // 서버에서 목록 조회
  1731. ConsentFormListVO vo = consentWebService.GetConsentByFormcd(formCdArr[i]
  1732. , ConsentExecuteInfo["dutinstcd"]);
  1733. if (vo == null/* || voArr.Length < 1*/)
  1734. {
  1735. throw new Exception("지정된 동의서를 찾을 수 없습니다.");
  1736. }
  1737. //ConsentBySearchVO vo = voArr[0];
  1738. // 현재 preview 할동의서 정보 설정
  1739. consentCommandCtrl.CurrentPreviewConsent = new PreviewConsent();
  1740. consentCommandCtrl.CurrentPreviewConsent.formRid = vo.formRid.ToString();
  1741. consentCommandCtrl.CurrentPreviewConsent.formGuid = vo.formGuid;
  1742. consentCommandCtrl.CurrentPreviewConsent.formCd = vo.formCd.ToString();
  1743. consentCommandCtrl.CurrentPreviewConsent.FormName = vo.formName;
  1744. consentCommandCtrl.CurrentPreviewConsent.formPrintName = vo.formPrntNm;
  1745. consentCommandCtrl.CurrentPreviewConsent.prntCnt = vo.printCnt;
  1746. consentCommandCtrl.CurrentPreviewConsent.consentMstRid = "-1";
  1747. consentCommandCtrl.CurrentPreviewConsent.consentState = string.Empty;
  1748. consentCommandCtrl.CurrentPreviewConsent.inputId = consentCommandCtrl.CurrentEndUser.UserNo;
  1749. consentCommandCtrl.CurrentPreviewConsent.inputNm = consentCommandCtrl.CurrentEndUser.UserName;
  1750. consentCommandCtrl.CurrentPreviewConsent.ReissueConsentMstRid = 0;
  1751. consentCommandCtrl.CurrentPreviewConsent.RewriteConsentMstRid = 0;
  1752. consentCommandCtrl.CurrentPreviewConsent.ocrtagPrntyn = vo.ocrTagPrntYn;
  1753. consentCommandCtrl.CurrentPreviewConsent.printOnly = vo.printOnly;
  1754. consentCommandCtrl.CurrentPreviewConsent.opDiagName = vo.opDiagNm;
  1755. consentCommandCtrl.CurrentPreviewConsent.opName = vo.opNm;
  1756. consentCommandCtrl.CurrentPreviewConsent.drOnly = vo.DrOnly;
  1757. consentCommandCtrl.CurrentPreviewConsent.userDrFlag = vo.userDrFlag;
  1758. // 출력 연동이 아닌 경우
  1759. if (ConsentExecuteInfo["printYN"].Equals("N"))
  1760. {
  1761. Dictionary<FOSParameter, string> globalParams = Common.CreateGlobalParamsDictionary(ConsentExecuteInfo["dutinstcd"]);
  1762. List<string> formGuids = new List<string> {
  1763. consentCommandCtrl.CurrentPreviewConsent.formGuid
  1764. };
  1765. consentCommandCtrl.SetPatientAndUser(globalParams);
  1766. if (ocrTagArr.Length > 0)
  1767. {
  1768. globalParams[FOSParameter.OCRCode] = consentCommandCtrl.CurrentPreviewConsent.ocrCode = ocrTagArr[i]; // OCR 코드
  1769. }
  1770. else
  1771. {
  1772. globalParams[FOSParameter.OCRCode] = consentCommandCtrl.CurrentPreviewConsent.ocrCode = consentCommandCtrl.GetOcrCode(); // OCR 코드
  1773. }
  1774. int cnt = hospitalWebService.checkOcrDup(ConsentExecuteInfo["dutinstcd"], consentCommandCtrl.CurrentPreviewConsent.ocrCode);
  1775. if(cnt > 0) {
  1776. MessageBox.Show("OCRTAG 중복 발생입니다. 환자를 다시 선택하여 주십시요.");
  1777. return;
  1778. }
  1779. // 임시저장의 경우 C 로 설정
  1780. globalParams[FOSParameter.Device] = "C";
  1781. globalParams[FOSParameter.PrintTime] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  1782. globalParams[FOSParameter.SignTime] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  1783. globalParams[FOSParameter.PrintIp] = ConsentExecuteInfo["printIP"];
  1784. CLIP.eForm.Consent.UI.HospitalSvcRef.SingleReturnData retVal = hospitalWebService.getEmrDataString("A01"
  1785. , ConsentExecuteInfo["dutinstcd"]
  1786. , ConsentExecuteInfo["patientNo"]
  1787. , ConsentExecuteInfo["clnDate"]
  1788. , ConsentExecuteInfo["cretno"]
  1789. , consentCommandCtrl.CurrentPreviewConsent.formCd);
  1790. globalParams[FOSParameter.emrinfo] = retVal.responseData;
  1791. string fos = Common.GetFosString(formGuids
  1792. , PluginExecuteInfo["formServiceUrl"]
  1793. , globalParams
  1794. , null
  1795. , ConsentExecuteInfo["dutinstcd"]);
  1796. // TODO 원무 인증 저장 pass
  1797. // 원무 동의서는 인증저장을 하지 않는다
  1798. shouldPassCertify = (this.consentWebService.getCertUseYn(consentCommandCtrl.CurrentPreviewConsent.formCd,
  1799. ConsentExecuteInfo["dutinstcd"]) == "Y") ? true : false;
  1800. // KU 시스템 연계시 동의서 종류와 상관 없이 인증버튼 활성화
  1801. //if (shouldPassCertify)
  1802. {
  1803. // 인증저장 버튼을 활성화 한다
  1804. consentCommandCtrl.SetEnableButtonsByCurrentConsent();
  1805. //consentCommandCtrl.setSaveButton(true);
  1806. }
  1807. // 동의서 열기
  1808. eFormViewerCtrl.OpenFos(fos);
  1809. // 출력 히스토리 기록
  1810. //this.consentCommandCtrl.OnPrint(vo.FormPrintName);
  1811. //------------------------------
  1812. // TODO 자동 듀얼뷰어 실행
  1813. //Boolean openDualView = false;
  1814. Boolean openDualView = (this.consentWebService.getDualViewMode(ConsentExecuteInfo["dutinstcd"],
  1815. ConsentExecuteInfo["ipaddr"]) == "Y") ? true : false;
  1816. if (openDualView)
  1817. {
  1818. if (!eFormViewerCtrl.Visible) {
  1819. eFormViewerCtrl.Visible = true;
  1820. }
  1821. consentCommandCtrl.RunConsentDualView();
  1822. }
  1823. //-------------------------------
  1824. // dbs227 원무 인증 저장 pass
  1825. if (shouldPassCertify)
  1826. {
  1827. //this.eFormViewerCtrl.SetZoomRate("wholepage");
  1828. //consentCommandCtrl.setZoomRate(5);
  1829. }
  1830. if (ConsentExecuteInfo["tempSave"].Equals("N"))
  1831. { // 지정된 동의서를 열기만 하는 경우
  1832. // 여러 개의 formcd 를 받더라도 첫번째 것만 보여준다
  1833. break;
  1834. }
  1835. else if (ConsentExecuteInfo["tempSave"].Equals("Y"))
  1836. { // 임시 저장
  1837. // 동의서 임시저장
  1838. eFormViewerCtrl.TempSave();
  1839. }
  1840. }
  1841. // 출력 연동
  1842. if (ConsentExecuteInfo["printYN"].Equals("Y"))
  1843. {
  1844. int prntCnt = consentCommandCtrl.CurrentPreviewConsent.prntCnt;
  1845. // 실행 파라미터에 PRINT_CNT 가 있고 0보다 클 경우 실행 파라미터를 우선으로 한다.
  1846. if (!string.IsNullOrEmpty(ConsentExecuteInfo["printCount"]))
  1847. {
  1848. int.TryParse(ConsentExecuteInfo["printCount"], out prntCnt);
  1849. }
  1850. Dictionary<string, Dictionary<FOSParameter, string>> formParamsList = new Dictionary<string, Dictionary<FOSParameter, string>>();
  1851. string[] formGuidList = new string[prntCnt];
  1852. string sOcrCd = string.Empty;
  1853. for (int j = 0; j < prntCnt; j++)
  1854. {
  1855. Dictionary<FOSParameter, string> formParams = Common.CreateGlobalParamsDictionary(ConsentExecuteInfo["dutinstcd"]);
  1856. consentCommandCtrl.SetPatientAndUser(formParams);
  1857. if (ocrTagArr.Length > 0)
  1858. {
  1859. formParams[FOSParameter.OCRCode] = consentCommandCtrl.CurrentPreviewConsent.ocrCode = ocrTagArr[i];
  1860. }
  1861. else
  1862. {
  1863. sOcrCd = formParams[FOSParameter.OCRCode] = consentCommandCtrl.CurrentPreviewConsent.ocrCode = consentCommandCtrl.GetOcrCode();
  1864. }
  1865. int cnt = hospitalWebService.checkOcrDup(ConsentExecuteInfo["dutinstcd"], consentCommandCtrl.CurrentPreviewConsent.ocrCode);
  1866. if(cnt > 0) {
  1867. MessageBox.Show("OCRTAG 중복 발생입니다. 환자를 다시 선택하여 주십시요.");
  1868. return;
  1869. }
  1870. // 동일 서식을 2장 있을 출력할 경우, 2장째부터는 OCR 태그가 아닌 [환자보관용] 텍스트가 출력
  1871. if (j > 0)
  1872. {
  1873. var ocrStr = this.consentWebService.getOcrString(consentCommandCtrl.CurrentPreviewConsent.formCd,
  1874. ConsentExecuteInfo["dutinstcd"]);
  1875. if (ocrStr == null)
  1876. {
  1877. ocrStr = "[환자 보관용]";
  1878. }
  1879. //ocrStr = (ocrStr == n) ? "[환자 보관용]" : ocrStr;
  1880. //formParams[FOSParameter.OCRCode] = "[환자 보관용]";
  1881. formParams[FOSParameter.OCRCode] = ocrStr;
  1882. }
  1883. formParams[FOSParameter.Device] = "P";
  1884. formParams[FOSParameter.PrintTime] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  1885. formParams[FOSParameter.PrintIp] = ConsentExecuteInfo["printIP"];
  1886. if (j == 1) formParams[FOSParameter.PrintComment] = Properties.Resources.msg_print_comment_2;
  1887. else if (j == 2) formParams[FOSParameter.PrintComment] = Properties.Resources.msg_print_comment_3;
  1888. CLIP.eForm.Consent.UI.HospitalSvcRef.SingleReturnData retVal = hospitalWebService.getEmrDataString("A01"
  1889. , ConsentExecuteInfo["dutinstcd"]
  1890. , ConsentExecuteInfo["patientNo"]
  1891. , ConsentExecuteInfo["clnDate"]
  1892. , ConsentExecuteInfo["cretno"]
  1893. , consentCommandCtrl.CurrentPreviewConsent.formCd);
  1894. formParams[FOSParameter.emrinfo] = retVal.responseData;
  1895. formGuidList[j] = consentCommandCtrl.CurrentPreviewConsent.formGuid;
  1896. formParamsList.Add((j + 1).ToString(), formParams);
  1897. }
  1898. string fos = Common.GetMultiFosString(formGuidList
  1899. , PluginExecuteInfo["formServiceUrl"]
  1900. , null
  1901. , formParamsList
  1902. , ConsentExecuteInfo["dutinstcd"]);
  1903. String formPrintName = formParamsList["1"][FOSParameter.FormName];
  1904. this.eFormViewerCtrl.OpenFos(fos);
  1905. // 출력 히스토리 기록
  1906. this.consentCommandCtrl.OnPrint(formPrintName);
  1907. //int testpagecnt = this.eFormViewerCtrl.GetTotalPageCount();
  1908. // dbs227, 출력 로그 업데이트
  1909. // consent_mst 기록
  1910. // InsertPrintData API 추가 후 기록
  1911. //this.consentCommandCtrl.SaveDataForPrintedConsent(String.Empty);
  1912. printConsentCount--;
  1913. this.eFormViewerCtrl.PrintByPrinterName("");
  1914. }
  1915. }
  1916. }
  1917. catch (Exception ex)
  1918. {
  1919. MessageBox.Show(ex.ToString());
  1920. initConsent();
  1921. throw ex;
  1922. }
  1923. }
  1924. public void initConsent()
  1925. {
  1926. consentCommandCtrl.CurrentPreviewConsent = null;
  1927. patientInfoCtrl.SetConsentDocumentName("");
  1928. eFormViewerCtrl.Visible = false;
  1929. //eFormViewerCtrl.ReInitializeViewer();
  1930. imageViewCtrl1.Hide();
  1931. }
  1932. private void btnHelp_Click(object sender, EventArgs e)
  1933. {
  1934. btnHelp.Enabled = false;
  1935. Application.DoEvents();
  1936. System.Diagnostics.Process.Start(@"https://ema031.knuh.kr:9091/doc/guide.pdf");
  1937. btnHelp.Enabled = true;
  1938. }
  1939. int pageCnt = 0;
  1940. Boolean printButtonClick = false;
  1941. void IConsentMain.setPageCnt(int pageCnt)
  1942. {
  1943. this.pageCnt = pageCnt;
  1944. //throw new NotImplementedException();
  1945. }
  1946. int IConsentMain.getPageCnt()
  1947. {
  1948. return this.pageCnt;
  1949. //throw new NotImplementedException();
  1950. }
  1951. void IConsentMain.setPrintButton(bool flag)
  1952. {
  1953. this.printButtonClick = flag;
  1954. //throw new NotImplementedException();
  1955. }
  1956. bool IConsentMain.getPrintButton()
  1957. {
  1958. return this.printButtonClick;
  1959. //throw new NotImplementedException();
  1960. }
  1961. public void SendToMainControlMessage(object obj)
  1962. {
  1963. throw new NotImplementedException();
  1964. }
  1965. public void OnAlreadyExistsConsentForm(ref bool closeForm)
  1966. {
  1967. throw new NotImplementedException();
  1968. }
  1969. /// <summary>
  1970. /// OCX 로 부터 넘겨 받은 파라미터를 decode(연속서식)
  1971. /// </summary>
  1972. /// <param name="pCallParm">EXEC_OPT 로 넘어온 파라미터 목록</param>
  1973. /// <exception cref="Exception">CallParam 미전달</exception>
  1974. private void InitMultiParamSetting(object pCallParm) {
  1975. try {
  1976. if (pCallParm != null) {
  1977. Dictionary<string, object> callParam = pCallParm as Dictionary<string, object>;
  1978. if (callParam != null && callParam.Count < 2) {
  1979. if (callParam["CALL_PARAMS"] != null) {
  1980. pCallParm = callParam["CALL_PARAMS"] as object;
  1981. }
  1982. }
  1983. multiParams = new List<Dictionary<string, object>>();
  1984. foreach (KeyValuePair<string, object> callKV in pCallParm as Dictionary<string, object>) {
  1985. // 화면 설정 정보
  1986. // 화면 설정 정보는 한번만 받으면 되기 때문에 받자마자 전역변수에 넣어준다
  1987. if (callKV.Key != null && !string.IsNullOrEmpty(callKV.Key.ToString()) && callKV.Key.ToString() == "EXEC_OPT") {
  1988. foreach (KeyValuePair<string, object> execKV in callKV.Value as Dictionary<string, object>) {
  1989. string value = execKV.Value != null ? execKV.Value.ToString() : "";
  1990. switch (execKV.Key) {
  1991. case "USE_LIST_VIEW":
  1992. ConsentExecuteInfo["useListView"] = "N";
  1993. break;
  1994. case "PTNT_LIST_VIEW":
  1995. ConsentExecuteInfo["patientListView"] = "N";
  1996. break;
  1997. case "START_FORM_CD":
  1998. ConsentExecuteInfo["startFormCd"] = value;
  1999. break;
  2000. case "PTNT_ACT":
  2001. ConsentExecuteInfo["printAct"] = value;
  2002. break;
  2003. case "PRINT_LIST":
  2004. if (execKV.Value != null) {
  2005. if (execKV.Value is List<object> PatientList && PatientList.Count > 0) {
  2006. PrintInfoList = new List<ConsentFormListVO>();
  2007. ConsentFormListVO consentVO = new ConsentFormListVO();
  2008. for (int i = 0; i < PatientList.Count; i++) {
  2009. consentVO = new ConsentFormListVO {
  2010. printCnt = -1
  2011. };
  2012. foreach (KeyValuePair<string, object> callOrderKV in PatientList[i] as Dictionary<string, object>) {
  2013. if (callOrderKV.Key != null && !string.IsNullOrEmpty(callOrderKV.Key.ToString()) && callOrderKV.Value != null) {
  2014. if (callOrderKV.Key.ToString() == "START_FORM_CD") consentVO.formCd = callOrderKV.Value.ToString(); // 출력 서식코드
  2015. if (callOrderKV.Key.ToString() == "PTNT_NO") consentVO.pid = callOrderKV.Value.ToString(); // 환자번호
  2016. if (callOrderKV.Key.ToString() == "VISIT_TYPE") consentVO.ordType = callOrderKV.Value.ToString(); // 내원구분
  2017. if (callOrderKV.Key.ToString() == "CLN_DATE") consentVO.inDd = callOrderKV.Value.ToString(); // 진료일자
  2018. if (callOrderKV.Key.ToString() == "CLN_DEPT") consentVO.ordDeptCd = callOrderKV.Value.ToString(); // 진료과
  2019. if (callOrderKV.Key.ToString() == "PRINT_CNT") {
  2020. int.TryParse(callOrderKV.Value.ToString(), out int PrntCnt);
  2021. consentVO.printCnt = PrntCnt; // 출력 카운트
  2022. }
  2023. if (callOrderKV.Key.ToString() == "CRETNO") {
  2024. int.TryParse(callOrderKV.Value.ToString(), out int cretno);
  2025. consentVO.cretNo = cretno; // 차트번호
  2026. }
  2027. }
  2028. }
  2029. PrintInfoList.Add(consentVO);
  2030. }
  2031. if (execKV.Value != null) ConsentExecuteInfo["printList"] = PrintInfoList.Count.ToString(); // 출력 데이터
  2032. }
  2033. }
  2034. break;
  2035. case "FORMCD":
  2036. ConsentExecuteInfo["formCd"] = value;
  2037. break;
  2038. case "OCRTAG":
  2039. ConsentExecuteInfo["ocrTag"] = value;
  2040. break;
  2041. case "TEMP_SAVE":
  2042. ConsentExecuteInfo["tempSave"] = value;
  2043. break;
  2044. case "PRINT_YN":
  2045. ConsentExecuteInfo["printYN"] = value;
  2046. break;
  2047. case "PRINT_CNT":
  2048. ConsentExecuteInfo["printCount"] = value;
  2049. break;
  2050. case "SYSINSTNM":
  2051. if (execKV.Value != null) {
  2052. string instCd = string.Empty;
  2053. instCd = execKV.Value.ToString().Contains("본원") ? "031" : execKV.Value.ToString().Contains("칠곡") ? "032" : string.Empty;
  2054. instCd += execKV.Value.ToString().Contains("교육") ? "edu" : string.Empty;
  2055. //instCd = "Dev";
  2056. ConsentExecuteInfo["sysInstNm"] = instCd;
  2057. }
  2058. break;
  2059. case "READONLY":
  2060. ConsentExecuteInfo["readOnly"] = value;
  2061. break;
  2062. default:
  2063. break;
  2064. }
  2065. }
  2066. }
  2067. //연속 서식 파라미터 디코드
  2068. //연속 서식을 위한 파라미터들은 배열 형태로 들어오기 때문에 dictionary 배열로 디코드 한 후에
  2069. //서식을 로드할 때 하나씩 불러와 전역변수에 넣어준다
  2070. else if (callKV.Key != null && !string.IsNullOrEmpty(callKV.Key.ToString()) && callKV.Key.ToString() == "PARAMS") {
  2071. List<object> paramsList = callKV.Value as List<object>;
  2072. if (paramsList == null) {
  2073. throw new Exception("InitMultiParamSetting 오류");
  2074. }
  2075. int multiParamCount = 0;
  2076. foreach (Dictionary<string, object> item in paramsList) {
  2077. multiParams.Add(new Dictionary<string, object>());
  2078. if (item != null && item.ContainsKey("PATIENT_INFO")) {
  2079. //환자정보
  2080. multiParams[multiParamCount].Add("PATIENT_INFO", new Dictionary<string, object>());
  2081. Dictionary<string, object> multiParamPatient = (multiParams[multiParamCount])["PATIENT_INFO"] as Dictionary<string, object>;
  2082. multiParamPatient.Add("PTNT_NO", "");
  2083. multiParamPatient.Add("VISIT_TYPE", "");
  2084. multiParamPatient.Add("CLN_DEPT", "");
  2085. multiParamPatient.Add("CLN_DATE", "");
  2086. multiParamPatient.Add("CRETNO", "");
  2087. multiParamPatient.Add("CLN_DX_NM", "");
  2088. multiParamPatient.Add("OPRSRVNO", "");
  2089. foreach (KeyValuePair<string, object> patientItem in item["PATIENT_INFO"] as Dictionary<string, object>) {
  2090. string value = patientItem.Value != null ? patientItem.Value.ToString() : "";
  2091. switch (patientItem.Key) {
  2092. case "PTNT_NO":
  2093. multiParamPatient["PTNT_NO"] = value;
  2094. break;
  2095. case "VISIT_TYPE":
  2096. multiParamPatient["VISIT_TYPE"] = value;
  2097. break;
  2098. case "CLN_DEPT":
  2099. multiParamPatient["CLN_DEPT"] = value;
  2100. break;
  2101. case "CLN_DATE":
  2102. multiParamPatient["CLN_DATE"] = value;
  2103. break;
  2104. case "CRETNO":
  2105. multiParamPatient["CRETNO"] = value;
  2106. break;
  2107. case "CLN_DX_NM":
  2108. multiParamPatient["CLN_DX_NM"] = value;
  2109. break;
  2110. case "OPRSRVNO":
  2111. multiParamPatient["OPRSRVNO"] = value;
  2112. break;
  2113. default:
  2114. break;
  2115. }
  2116. }
  2117. }
  2118. if (item.ContainsKey("USER_INFO")) {
  2119. //사용자 정보
  2120. multiParams[multiParamCount].Add("USER_INFO", new Dictionary<string, object>());
  2121. Dictionary<string, object> multiParamUser = (multiParams[multiParamCount])["USER_INFO"] as Dictionary<string, object>;
  2122. multiParamUser.Add("USER_ID", "");
  2123. multiParamUser.Add("DUTINSTCD", "");
  2124. multiParamUser.Add("USER_NAME", "");
  2125. multiParamUser.Add("USER_DEPTCD", "");
  2126. multiParamUser.Add("USER_DEPTNM", "");
  2127. foreach (KeyValuePair<string, object> userItem in item["USER_INFO"] as Dictionary<string, object>) {
  2128. string value = userItem.Value != null ? userItem.Value.ToString() : "";
  2129. switch (userItem.Key) {
  2130. case "USER_ID":
  2131. multiParamUser["USER_ID"] = value;
  2132. break;
  2133. case "DUTINSTCD":
  2134. multiParamUser["DUTINSTCD"] = value;
  2135. break;
  2136. case "USER_NAME":
  2137. multiParamUser["USER_NAME"] = value;
  2138. break;
  2139. case "USER_DEPTCD":
  2140. multiParamUser["USER_DEPTCD"] = value;
  2141. break;
  2142. case "USER_DEPTNM":
  2143. multiParamUser["USER_DEPTNM"] = value;
  2144. break;
  2145. default:
  2146. break;
  2147. }
  2148. }
  2149. }
  2150. if (item.ContainsKey("PAM_INFO")) {
  2151. //원무
  2152. multiParams[multiParamCount].Add("PAM_INFO", new Dictionary<string, object>());
  2153. Dictionary<string, object> multiParamPam = (multiParams[multiParamCount])["PAM_INFO"] as Dictionary<string, object>;
  2154. multiParamPam.Add("SPEC_DR_YN", "");
  2155. multiParamPam.Add("CONT_START_DT", "");
  2156. multiParamPam.Add("CONT_END_DT", "");
  2157. multiParamPam.Add("ROOM_CAPA", "");
  2158. multiParamPam.Add("CONT_TELNO", "");
  2159. multiParamPam.Add("CONT_STAFF1", "");
  2160. multiParamPam.Add("CONT_STAFF2", "");
  2161. multiParamPam.Add("CONT_STAFF3", "");
  2162. multiParamPam.Add("CARD_NO", "");
  2163. multiParamPam.Add("TAG1", "");
  2164. multiParamPam.Add("TAG2", "");
  2165. multiParamPam.Add("TAG3", "");
  2166. multiParamPam.Add("TAG4", "");
  2167. multiParamPam.Add("TAG5", "");
  2168. multiParamPam.Add("TAG6", "");
  2169. multiParamPam.Add("TAG7", "");
  2170. multiParamPam.Add("TAG8", "");
  2171. multiParamPam.Add("TAG9", "");
  2172. multiParamPam.Add("TAG10", "");
  2173. foreach (KeyValuePair<string, object> pamItem in item["PAM_INFO"] as Dictionary<string, object>) {
  2174. string value = pamItem.Value != null ? pamItem.Value.ToString() : "";
  2175. switch (pamItem.Key) {
  2176. case "SPEC_DR_YN":
  2177. multiParamPam["SPEC_DR_YN"] = value;
  2178. break;
  2179. case "CONT_START_DT":
  2180. multiParamPam["CONT_START_DT"] = value;
  2181. break;
  2182. case "CONT_END_DT":
  2183. multiParamPam["CONT_END_DT"] = value;
  2184. break;
  2185. case "ROOM_CAPA":
  2186. multiParamPam["ROOM_CAPA"] = value;
  2187. break;
  2188. case "CONT_TELNO":
  2189. multiParamPam["CONT_TELNO"] = value;
  2190. break;
  2191. case "CONT_STAFF1":
  2192. multiParamPam["CONT_STAFF1"] = value;
  2193. break;
  2194. case "CONT_STAFF2":
  2195. multiParamPam["CONT_STAFF2"] = value;
  2196. break;
  2197. case "CONT_STAFF3":
  2198. multiParamPam["CONT_STAFF3"] = value;
  2199. break;
  2200. case "CARD_NO":
  2201. multiParamPam["CARD_NO"] = value;
  2202. break;
  2203. case "TAG1":
  2204. multiParamPam["TAG1"] = value;
  2205. break;
  2206. case "TAG2":
  2207. multiParamPam["TAG2"] = value;
  2208. break;
  2209. case "TAG3":
  2210. multiParamPam["TAG3"] = value;
  2211. break;
  2212. case "TAG4":
  2213. multiParamPam["TAG4"] = value;
  2214. break;
  2215. case "TAG5":
  2216. multiParamPam["TAG5"] = value;
  2217. break;
  2218. case "TAG6":
  2219. multiParamPam["TAG6"] = value;
  2220. break;
  2221. case "TAG7":
  2222. multiParamPam["TAG7"] = value;
  2223. break;
  2224. case "TAG8":
  2225. multiParamPam["TAG8"] = value;
  2226. break;
  2227. case "TAG9":
  2228. multiParamPam["TAG9"] = value;
  2229. break;
  2230. case "TAG10":
  2231. multiParamPam["TAG10"] = value;
  2232. break;
  2233. default:
  2234. break;
  2235. }
  2236. }
  2237. }
  2238. if (item.ContainsKey("CONSENT_DATA")) {
  2239. //동의서 데이터
  2240. multiParams[multiParamCount].Add("CONSENT_DATA", new Dictionary<string, object>());
  2241. Dictionary<string, object> multiParamConsent = (multiParams[multiParamCount])["CONSENT_DATA"] as Dictionary<string, object>;
  2242. multiParamConsent.Add("ocrTag", "");
  2243. multiParamConsent.Add("formCd", "");
  2244. multiParamConsent.Add("tempsaveYn", "");
  2245. foreach (KeyValuePair<string, object> consentItem in item["CONSENT_DATA"] as Dictionary<string, object>) {
  2246. string value = consentItem.Value != null ? consentItem.Value.ToString() : "";
  2247. switch (consentItem.Key) {
  2248. case "ocrTag":
  2249. multiParamConsent["ocrTag"] = value;
  2250. break;
  2251. case "formCd":
  2252. multiParamConsent["formCd"] = value;
  2253. break;
  2254. case "tempsaveYn":
  2255. multiParamConsent["tempsaveYn"] = value;
  2256. break;
  2257. default:
  2258. break;
  2259. }
  2260. }
  2261. }
  2262. multiParamCount++;
  2263. }
  2264. }
  2265. }
  2266. multiParams.Add(new Dictionary<string, object>() { ["PAGE_COUNT"] = 0 });
  2267. } else {
  2268. throw new Exception("CallParam 미전달");
  2269. }
  2270. // IP 주소 확인
  2271. string printIp = string.Empty;
  2272. foreach (System.Net.IPAddress ip in System.Net.Dns.GetHostAddresses(System.Net.Dns.GetHostName())) {
  2273. if (ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) {
  2274. printIp = ip.ToString();
  2275. break;
  2276. }
  2277. }
  2278. // dbs227, 경북대학교병원 ip address 기록
  2279. ConsentExecuteInfo["ipaddr"] = printIp;
  2280. if (!printIp.Equals(string.Empty)) {
  2281. string[] ipArr = printIp.Split(new string[] { "." }, StringSplitOptions.RemoveEmptyEntries);
  2282. if (ipArr.Length == 4) {
  2283. printIp = string.Format("{0}.{1}", ipArr[2], ipArr[3]);
  2284. } else {
  2285. printIp = string.Empty;
  2286. }
  2287. }
  2288. ConsentExecuteInfo["printIP"] = printIp;
  2289. //버전정보
  2290. string[] versionName = Assembly.GetExecutingAssembly().FullName.Split(',')[1].Split('.');
  2291. string version = versionName[versionName.Length - 1];
  2292. ConsentExecuteInfo["DeviceType"] = "WIN," + version + "," + ConsentExecuteInfo["dutinstcd"];
  2293. } catch (Exception ex) {
  2294. throw ex;
  2295. }
  2296. }
  2297. /// <summary>
  2298. /// 연속서식을 위한 배열 데이터를 꺼내서 전역변수에 할당한다
  2299. /// </summary>
  2300. /// <param name="page">받아올 배열의 인덱스</param>
  2301. private void setConsentViewMultiParams(int page) {
  2302. Dictionary<string, object> currentParam = multiParams[page];
  2303. setGlobalValueWithMultiParam(currentParam);
  2304. }
  2305. /// <summary>
  2306. /// 파라미터를 받아 전역변수에 할당
  2307. /// </summary>
  2308. /// <param name="pCallParm">EXEC_OPT 로 넘어온 파라미터 목록</param>
  2309. /// <exception cref="Exception">CallParam 미전달</exception>
  2310. private void setGlobalValueWithMultiParam(object pCallParm) {
  2311. try {
  2312. if (pCallParm != null) {
  2313. Dictionary<string, object> callParam = pCallParm as Dictionary<string, object>;
  2314. if (callParam != null && callParam.Count < 2) {
  2315. if (callParam["CALL_PARAMS"] != null) {
  2316. pCallParm = callParam["CALL_PARAMS"] as object;
  2317. }
  2318. }
  2319. foreach (KeyValuePair<string, object> callKV in pCallParm as Dictionary<string, object>) {
  2320. // 사용자 정보
  2321. if (callKV.Key != null && callKV.Key.ToString() == "USER_INFO") {
  2322. foreach (KeyValuePair<string, object> userKV in callKV.Value as Dictionary<string, object>) {
  2323. string value = userKV.Value != null ? userKV.Value.ToString() : "";
  2324. switch (userKV.Key.ToString()) {
  2325. case "USER_ID":
  2326. ConsentExecuteInfo["userNo"] = value;
  2327. ConsentExecuteInfo["loginUserNo"] = value;
  2328. break;
  2329. case "DUTINSTCD":
  2330. ConsentExecuteInfo["dutinstcd"] = value;
  2331. break;
  2332. case "USER_NAME":
  2333. ConsentExecuteInfo["userName"] = value;
  2334. ConsentExecuteInfo["loginUserName"] = value;
  2335. break;
  2336. case "USER_DEPTCD":
  2337. ConsentExecuteInfo["userDeptCd"] = value;
  2338. break;
  2339. case "USER_DEPTNM":
  2340. ConsentExecuteInfo["userDeptName"] = value;
  2341. break;
  2342. default:
  2343. break;
  2344. }
  2345. }
  2346. }
  2347. // 환자 정보
  2348. if (callKV.Key != null && callKV.Key.ToString() == "PATIENT_INFO") {
  2349. foreach (KeyValuePair<string, object> patientKV in callKV.Value as Dictionary<string, object>) {
  2350. string value = patientKV.Value != null ? patientKV.Value.ToString() : "";
  2351. switch (patientKV.Key.ToString()) {
  2352. case "PTNT_NO":
  2353. ConsentExecuteInfo["patientNo"] = value;
  2354. break;
  2355. case "VISIT_TYPE":
  2356. ConsentExecuteInfo["visitType"] = value;
  2357. break;
  2358. case "CLN_DEPT":
  2359. ConsentExecuteInfo["clnDept"] = value;
  2360. break;
  2361. case "CLN_DATE":
  2362. ConsentExecuteInfo["clnDate"] = value;
  2363. break;
  2364. case "CRETNO":
  2365. ConsentExecuteInfo["cretno"] = value;
  2366. break;
  2367. case "CLN_DX_NM":
  2368. ConsentExecuteInfo["clnDxNm"] = value;
  2369. break;
  2370. case "OPRSRVNO":
  2371. ConsentExecuteInfo["opRsrvNo"] = value;
  2372. break;
  2373. default:
  2374. break;
  2375. }
  2376. }
  2377. }
  2378. // 원무
  2379. if (callKV.Key != null && callKV.Key.ToString() == "PAM_INFO") {
  2380. foreach (KeyValuePair<string, object> pamKV in callKV.Value as Dictionary<string, object>) {
  2381. string value = pamKV.Value != null ? pamKV.Value.ToString() : "";
  2382. switch (pamKV.Key.ToString()) {
  2383. case "SPEC_DR_YN":
  2384. ConsentExecuteInfo["SpecDoctorYN"] = value;
  2385. break;
  2386. case "CONT_START_DT":
  2387. ConsentExecuteInfo["ContStartDate"] = value;
  2388. break;
  2389. case "CONT_END_DT":
  2390. ConsentExecuteInfo["ContEndDate"] = value;
  2391. break;
  2392. case "ROOM_CAPA":
  2393. ConsentExecuteInfo["RoomCapa"] = value;
  2394. break;
  2395. case "CONT_TELNO":
  2396. ConsentExecuteInfo["ContTelNo"] = value;
  2397. break;
  2398. case "CONT_STAFF1":
  2399. ConsentExecuteInfo["ContStaff1Name"] = value;
  2400. break;
  2401. case "CONT_STAFF2":
  2402. ConsentExecuteInfo["ContStaff2Name"] = value;
  2403. break;
  2404. case "CONT_STAFF3":
  2405. ConsentExecuteInfo["ContStaff3Name"] = value;
  2406. break;
  2407. case "CARD_NO":
  2408. ConsentExecuteInfo["CardNo"] = value;
  2409. break;
  2410. case "TAG1":
  2411. ConsentExecuteInfo["tag1"] = value;
  2412. break;
  2413. case "TAG2":
  2414. ConsentExecuteInfo["tag2"] = value;
  2415. break;
  2416. case "TAG3":
  2417. ConsentExecuteInfo["tag3"] = value;
  2418. break;
  2419. case "TAG4":
  2420. ConsentExecuteInfo["tag4"] = value;
  2421. break;
  2422. case "TAG5":
  2423. ConsentExecuteInfo["tag5"] = value;
  2424. break;
  2425. case "TAG6":
  2426. ConsentExecuteInfo["tag6"] = value;
  2427. break;
  2428. case "TAG7":
  2429. ConsentExecuteInfo["tag7"] = value;
  2430. break;
  2431. case "TAG8":
  2432. ConsentExecuteInfo["tag8"] = value;
  2433. break;
  2434. case "TAG9":
  2435. ConsentExecuteInfo["tag9"] = value;
  2436. break;
  2437. case "TAG10":
  2438. ConsentExecuteInfo["tag10"] = value;
  2439. break;
  2440. default:
  2441. break;
  2442. }
  2443. }
  2444. }
  2445. }
  2446. } else {
  2447. throw new Exception("CallParam 미전달");
  2448. }
  2449. } catch (Exception ex) {
  2450. throw ex;
  2451. }
  2452. }
  2453. /// <summary>
  2454. /// 파라미터 배열의 인덱스를 가지고 해당 파라미터에 대한 동의서를 띄운다
  2455. /// </summary>
  2456. /// <param name="page"></param>
  2457. private void showConsentView(int page) {
  2458. Dictionary<string, object> currentParam = multiParams[page] as Dictionary<string, object>;
  2459. if (!(currentParam != null && currentParam.ContainsKey("CONSENT_DATA"))) {
  2460. return;
  2461. }
  2462. setConsentViewMultiParams(page);
  2463. patientInfoCtrl.OnRefeashPartControls("");
  2464. //파라미터를 가지고 동의서 정보를 만든다
  2465. if (currentParam["CONSENT_DATA"] is Dictionary<string, object> currentConsent) {
  2466. //ConsentFormListVO consent = new ConsentFormListVO();
  2467. ConsentFormListVO consent = consentWebService.GetConsentByFormcd(currentConsent["formCd"].ToString(), ConsentExecuteInfo["dutinstcd"].ToString());
  2468. if (consent == null)
  2469. {
  2470. MessageBox.Show("동의서 정보가 잘못되었습니다.");
  2471. return;
  2472. }
  2473. consent.createUserId = ConsentExecuteInfo["loginUserNo"];
  2474. consent.createUserName = ConsentExecuteInfo["loginUserName"];
  2475. consent.ocrTag = currentConsent["ocrTag"] != null ? currentConsent["ocrTag"].ToString() : "";
  2476. consent.pid = ConsentExecuteInfo["patientNo"] != null ? ConsentExecuteInfo["patientNo"].ToString() : "";
  2477. consent.inDd = ConsentExecuteInfo["clnDate"] != null ? ConsentExecuteInfo["clnDate"].ToString() : "";
  2478. consent.ordType = ConsentExecuteInfo["visitType"] != null ? ConsentExecuteInfo["visitType"].ToString() : "";
  2479. consent.ordDeptCd = ConsentExecuteInfo["clnDept"] != null ? ConsentExecuteInfo["clnDept"].ToString() : "";
  2480. if (ConsentExecuteInfo["cretno"] != null)
  2481. {
  2482. consent.cretNo = Int32.TryParse(ConsentExecuteInfo["cretno"], out int res) ? res : 0;
  2483. }
  2484. consent.opRsrvNo = ConsentExecuteInfo["opRsrvNo"] != null ? ConsentExecuteInfo["opRsrvNo"].ToString() : "";
  2485. executePreviewConsent(consent);
  2486. } else {
  2487. return;
  2488. }
  2489. }
  2490. private void showNextConsent()
  2491. {
  2492. //현재 동의서가 몇번째인지 받아온다
  2493. Dictionary<string, object> currentPageParam = ((Dictionary<string, object>)multiParams[multiParams.Count - 1]);
  2494. int page = Int32.TryParse(currentPageParam["PAGE_COUNT"].ToString(), out int cnt) ? cnt : -1;
  2495. currentPageParam["PAGE_COUNT"] = Int32.Parse(currentPageParam["PAGE_COUNT"].ToString()) + 1;
  2496. if (page >= 0)
  2497. {
  2498. //마지막 서식이면 종료한다.
  2499. if (multiParams.Count - 2 == page)
  2500. {
  2501. Form parentForm = this.Parent as Form;
  2502. if (parentForm != null)
  2503. {
  2504. parentForm.Close();
  2505. }
  2506. }
  2507. page++;
  2508. showConsentView(page);
  2509. }
  2510. }
  2511. private void executePreviewConsent(ConsentFormListVO vo)
  2512. {
  2513. Cursor currentCursor = this.Cursor;
  2514. this.Cursor = Cursors.WaitCursor;
  2515. consentCommandCtrl.CurrentPreviewConsent = new PreviewConsent
  2516. {
  2517. formRid = vo.formRid.ToString(),
  2518. formGuid = vo.formGuid,
  2519. formCd = vo.formCd.ToString(),
  2520. FormName = vo.formName,
  2521. formPrintName = vo.formPrntNm,
  2522. prntCnt = vo.printCnt,
  2523. consentMstRid = vo.consentMstRid.ToString(),
  2524. consentStateEngnm = vo.consentStateEng,
  2525. orderNo = 0,
  2526. ocrCode = vo.ocrTag,
  2527. inputId = vo.createUserId,
  2528. inputNm = vo.createUserName,
  2529. ReissueConsentMstRid = IsConsentStatePrintOut(vo) ? vo.consentMstRid : 0,
  2530. RewriteConsentMstRid = !IsConsentStateUnfinished(vo) ? vo.consentMstRid : 0,
  2531. ordType = vo.ordType,
  2532. ocrtagPrntyn = vo.ocrTagPrntYn,
  2533. userDrFlag = vo.userDrFlag,
  2534. printOnly = vo.printOnly,
  2535. opDiagName = vo.opDiagNm,
  2536. consentState = vo.consentStateEng,
  2537. drOnly = vo.DrOnly,
  2538. opName = vo.opNm
  2539. };
  2540. try
  2541. {
  2542. patientInfoCtrl.SetConsentDocumentName(vo.formName);
  2543. //동의서와 유저 상태에 따라 상단의 저장버튼을 활성화시키는 구문
  2544. if (consentCommandCtrl.CurrentTargetPatient.VisitType.Equals("O"))
  2545. {
  2546. consentCommandCtrl.setCompleteSaveButton(true);
  2547. }
  2548. else
  2549. {
  2550. if (ConsentMainControl.SETTING_DATA["ELECTR_CMP"].Equals("Y") && consentCommandCtrl.CurrentEndUser.JobKindCd.Substring(0, 2).Equals("03"))
  2551. {
  2552. consentCommandCtrl.setCompleteSaveButton(true);
  2553. }
  2554. else
  2555. {
  2556. consentCommandCtrl.setCompleteSaveButton(false);
  2557. }
  2558. }
  2559. if (!consentCommandCtrl.CurrentEndUser.JobKindCd.Substring(0, 2).Equals("03"))
  2560. {
  2561. consentCommandCtrl.setCompleteSaveButton(false);
  2562. }
  2563. consentCommandCtrl.PreviewConsent(this);
  2564. //임시저장 활성화 여부
  2565. consentCommandCtrl.setToolstripEnabled(true);
  2566. Dictionary<string, object> consentData = getParamsWithIndex(getCurrentConsentPage())["CONSENT_DATA"] as Dictionary<string, object>;
  2567. if (consentData.ContainsKey("tempsaveYn"))
  2568. {
  2569. if (consentData["tempsaveYn"].ToString().Equals("Y"))
  2570. {
  2571. consentCommandCtrl.setTempSaveButton(true);
  2572. }
  2573. else
  2574. {
  2575. consentCommandCtrl.setTempSaveButton(false);
  2576. }
  2577. }
  2578. }
  2579. catch
  2580. {
  2581. }
  2582. finally
  2583. {
  2584. this.Cursor = currentCursor;
  2585. }
  2586. }
  2587. #region ConsentState 확인
  2588. private static bool IsConsentStateTempSave(ConsentFormListVO vo)
  2589. {
  2590. if (vo.consentStateEng.ToUpper().Equals("TEMP") || vo.consentStateEng.ToUpper().Equals("VERBAL"))
  2591. {
  2592. return true;
  2593. }
  2594. return false;
  2595. }
  2596. private static bool IsConsentStatePrintOut(ConsentFormListVO vo)
  2597. {
  2598. return vo.consentStateEng.ToUpper().Equals("PAPER_OUT");
  2599. }
  2600. private static bool IsConsentStateElectronicComplete(ConsentFormListVO vo)
  2601. {
  2602. return vo.consentStateEng.ToUpper().Equals("ELECTR_CMP");
  2603. }
  2604. private static bool IsConsentStateCertifyComplete(ConsentFormListVO vo)
  2605. {
  2606. return vo.consentStateEng.ToUpper().Equals("CERTIFY_CMP");
  2607. }
  2608. private static bool IsConsentStateUnfinished(ConsentFormListVO vo)
  2609. {
  2610. return vo.consentStateEng.ToUpper().Equals("UNFINISHED");
  2611. }
  2612. #endregion
  2613. /// <summary>
  2614. /// 다중 서식을 받아왔을 때 현재 보고있는 서식의 인덱스를 반환한다
  2615. /// </summary>
  2616. /// <returns></returns>
  2617. private int getCurrentConsentPage()
  2618. {
  2619. int page = 0;
  2620. if (multiParams != null)
  2621. {
  2622. Dictionary<string, object> pageParam = multiParams[multiParams.Count - 1];
  2623. if (pageParam.ContainsKey("PAGE_COUNT"))
  2624. {
  2625. page = Int32.TryParse(pageParam["PAGE_COUNT"].ToString(), out int pageNumber) ? pageNumber : -1;
  2626. }
  2627. }
  2628. return page;
  2629. }
  2630. /// <summary>
  2631. /// 다중 서식의 특정 페이지에 대한 파라미터를 불러온다
  2632. /// </summary>
  2633. /// <param name="page"></param>
  2634. /// <returns></returns>
  2635. private Dictionary<string, object> getParamsWithIndex(int page)
  2636. {
  2637. Dictionary<string, object> returnParam = null;
  2638. if (multiParams != null)
  2639. {
  2640. returnParam = multiParams[page];
  2641. }
  2642. return returnParam;
  2643. }
  2644. public void showNextPreview()
  2645. {
  2646. showNextConsent();
  2647. }
  2648. }
  2649. }