ConsentCommandCtrl.cs 142 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186
  1. #region Copyright ⓒ 2015 CLIPSOFT Co.,Ltd. All Rights Reserved.
  2. //
  3. // All rights are reserved. Reproduction or transmission in whole or in part,
  4. // in any form or by any means, electronic, mechanical or otherwise, is
  5. // prohibited without the prior written consent of the copyright owner.
  6. //
  7. // Filename:ConsentCommandCtrl.cs
  8. //
  9. #endregion
  10. using System;
  11. using System.ComponentModel;
  12. using System.Collections.Generic;
  13. using System.Windows.Forms;
  14. using System.IO;
  15. using System.Net;
  16. using System.Xml;
  17. using System.Drawing;
  18. using System.Security.Cryptography;
  19. using CLIP.eForm.Consent.UI.ConsentSvcRef;
  20. using CLIP.eForm.Consent.UI.HospitalSvcRef;
  21. using ClipSoft.eForm.Base.Dialog;
  22. using static CLIP.eForm.Consent.UI.Common;
  23. using ConsentFormListVO = CLIP.eForm.Consent.UI.ConsentSvcRef.ConsentFormListVO;
  24. using SingleReturnData = CLIP.eForm.Consent.UI.ConsentSvcRef.SingleReturnData;
  25. namespace CLIP.eForm.Consent.UI {
  26. /// <summary>
  27. /// 출력, 전자동의서 실행 버튼 클래스
  28. /// </summary>
  29. /// <remarks>
  30. /// <p>[설계자]</p>
  31. /// <p> 클립소프트 연구소 홍지철 (jchong@clipsoft.co.kr)</p>
  32. /// <p>[원본 작성자]</p>
  33. /// <p> 클립소프트 기술부 이창훈 (chlee@clipsoft.co.kr)</p>
  34. /// <p>[수정 작성자]</p>
  35. /// <p> 클립소프트 기술부 이인희</p>
  36. /// <p>----------------------------------------------------------------------------------------</p>
  37. /// <p>[HISTORY]</p>
  38. /// <p> 2016-06-21 : 최초작성</p>
  39. /// <p>----------------------------------------------------------------------------------------</p>
  40. /// </remarks>
  41. public partial class ConsentCommandCtrl : ConsentCommandCtrlBase {
  42. private PreviewConsent currentPreviewConsent = null;
  43. private TargetPatient currentTargetPatient = null;
  44. private EndUser currentEndUser = null;
  45. private IConsentMain consentMain = null;
  46. private ConsentSvcRef.ConsentSvcSoapClient consentWebService = null;
  47. private HospitalSvcRef.HospitalSvcSoapClient hospitalWebService = null;
  48. private string exportedImageFiles = string.Empty;
  49. private string exportedImageFilesJson = string.Empty;
  50. System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ConsentCommandCtrl));
  51. private bool m_IsComplete = false;
  52. public bool IsComplete => m_IsComplete;
  53. public ConsentCommandCtrl() {
  54. InitializeComponent();
  55. }
  56. public override bool EnableRedo {
  57. get {
  58. return base.EnableRedo;
  59. }
  60. set {
  61. base.EnableRedo = value;
  62. this.toolStripButtonRedo.Enabled = base.EnableRedo;
  63. }
  64. }
  65. public override bool reprintStatus {
  66. get {
  67. return base.reprintStatus;
  68. }
  69. set {
  70. base.reprintStatus = value;
  71. }
  72. }
  73. public override bool EnableUndo {
  74. get {
  75. return base.EnableUndo;
  76. }
  77. set {
  78. base.EnableUndo = value;
  79. this.toolStripButtonUndo.Enabled = base.EnableUndo;
  80. }
  81. }
  82. public override bool EnableRemoveAll {
  83. get {
  84. return base.EnableRemoveAll;
  85. }
  86. set {
  87. base.EnableRemoveAll = value;
  88. this.toolStripButtonDelAllDraw.Enabled = base.EnableRemoveAll;
  89. }
  90. }
  91. public override bool EnablePenDrawing {
  92. get {
  93. return base.EnableRemoveAll;
  94. }
  95. set {
  96. base.EnablePenDrawing = value;
  97. this.toolStripButtonPen.Enabled = base.EnablePenDrawing;
  98. }
  99. }
  100. public override bool EnablePenConfig {
  101. get {
  102. return base.EnablePenConfig;
  103. }
  104. set {
  105. base.EnablePenConfig = value;
  106. this.toolStripButtonPenConfig.Enabled = base.EnablePenConfig;
  107. }
  108. }
  109. public PreviewConsent CurrentPreviewConsent {
  110. get {
  111. return currentPreviewConsent;
  112. }
  113. set {
  114. currentPreviewConsent = value;
  115. }
  116. }
  117. public TargetPatient CurrentTargetPatient {
  118. get {
  119. return currentTargetPatient;
  120. }
  121. set {
  122. currentTargetPatient = value;
  123. }
  124. }
  125. public EndUser CurrentEndUser {
  126. get {
  127. return currentEndUser;
  128. }
  129. set {
  130. currentEndUser = value;
  131. }
  132. }
  133. /// <summary>
  134. /// 임시저장 버튼 클릭 활성화 여부 반환
  135. /// </summary>
  136. /// <returns></returns>
  137. public override bool getTempSaveButton() {
  138. return this.toolStripButtonTempSaveToServer.Enabled;
  139. }
  140. /// <summary>
  141. /// 저장 버튼 클릭 활성화 여부 반환
  142. /// </summary>
  143. /// <returns></returns>
  144. public override bool getSaveButton() {
  145. return this.toolStripButtonSaveToServer.Enabled;
  146. }
  147. public override void setTempSaveButton(bool enabled) {
  148. this.toolStripButtonTempSaveToServer.Enabled = enabled;
  149. }
  150. public override void setSaveButton(bool enabled) {
  151. this.toolStripButtonSaveToServer.Enabled = enabled;
  152. }
  153. public void setZoomRate(int rate) {
  154. toolStripComboBoxZoom.SelectedIndex = rate;
  155. toolStripComboBoxZoom.Enabled = true; // zoom rate
  156. toolStripButtonPrevPage.Enabled = true; // 이전 페이지
  157. toolStripButtonNextPage.Enabled = true; // 다음 페이지
  158. toolStripTextBoxPageIndex.Enabled = true; // 페이지 인덱스
  159. toolStripLabelTotalPages.Enabled = true;
  160. toolStripButtonFirstPage.Enabled = true; // 처음 페이지
  161. toolStripButtonLastPage.Enabled = true; // 마지막페이지
  162. toolStripTextBoxPageIndex.Text = consentMain.GetCurrentPageIndex().ToString();
  163. toolStripLabelTotalPages.Text = consentMain.GetTotalPageCount().ToString();
  164. }
  165. public override void setCompleteSaveButton(bool enabled) {
  166. this.toolStripButtonCompleteSaveToServer.Enabled = enabled;
  167. }
  168. protected override void OnLoad(EventArgs e) {
  169. base.OnLoad(e);
  170. if(this.DesignMode || LicenseManager.UsageMode == LicenseUsageMode.Designtime) {
  171. return;
  172. }
  173. if(!ConsentMainControl.HasVerticalMonitor) {
  174. this.toolStripButtonExecute.Visible = false;
  175. }
  176. else {
  177. this.toolStripButtonExecute.Visible = true;
  178. }
  179. this.consentMain = ConsentMainControl.GetConsentMainInterface(this);
  180. this.consentWebService = WebMethodCommon.GetConsentWebService(consentMain.PluginExecuteInfo["consentSvcUrl"]);
  181. this.hospitalWebService = WebMethodCommon.GetHospitalWebService(consentMain.PluginExecuteInfo["hospitalSvcUrl"]);
  182. InitZoomRateDropdownItems();
  183. this.consentMain.OnLoadPartControls += ConsentMain_OnLoadPartControls;
  184. this.toolStripButtons.MouseEnter += ToolStripButtons_MouseEnter;
  185. }
  186. private void ConsentMain_OnLoadPartControls(object sender, EventArgs e) {
  187. this.consentMain.OnVisibleEFormControl += ConsentMain_OnVisibleEFormControl;
  188. this.consentMain.OnInvisibleEFormControl += ConsentMain_OnInvisibleEFormControl;
  189. }
  190. private void ConsentMain_OnInvisibleEFormControl(object sender, EventArgs e) {
  191. this.consentMain.ConsentCommandCtrl.Enabled = false;
  192. }
  193. private void ConsentMain_OnVisibleEFormControl(object sender, EventArgs e) {
  194. this.consentMain.ConsentCommandCtrl.Enabled = true;
  195. }
  196. private void InitZoomRateDropdownItems() {
  197. // 콤보 박스에 저장되는 형식을 ArrayList 로 바꿈
  198. List<ZoomRateDropdownItem> zoomRateList = new List<ZoomRateDropdownItem>();
  199. zoomRateList.Add(new ZoomRateDropdownItem("50%", "50"));
  200. zoomRateList.Add(new ZoomRateDropdownItem("75%", "75"));
  201. zoomRateList.Add(new ZoomRateDropdownItem("100%", "100"));
  202. zoomRateList.Add(new ZoomRateDropdownItem("200%", "200"));
  203. zoomRateList.Add(new ZoomRateDropdownItem("창 너비에 맞춤", "pagewidth"));
  204. zoomRateList.Add(new ZoomRateDropdownItem("창 크기에 맞춤", "wholepage"));
  205. toolStripComboBoxZoom.Items.AddRange(zoomRateList.ToArray());
  206. }
  207. #region toolStripButton 이벤트
  208. private void ToolStripButtons_MouseEnter(object sender, EventArgs e) {
  209. this.toolStripButtons.Focus();
  210. }
  211. /// <summary>
  212. /// 처음 페이지로 이동 버튼 클릭 이벤트
  213. /// </summary>
  214. /// <param name="sender">The source of the event.</param>
  215. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  216. private void toolStripButtonFirstPage_Click(object sender, EventArgs e) {
  217. this.consentMain.MoveFirstPage();
  218. }
  219. /// <summary>
  220. /// 이전 페이지로 이동 버튼 클릭 이벤트
  221. /// </summary>
  222. /// <param name="sender">The source of the event.</param>
  223. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  224. private void toolStripButtonPrevPage_Click(object sender, EventArgs e) {
  225. this.consentMain.MovePrevPage();
  226. }
  227. /// <summary>
  228. /// 다음 페이지 이동 버튼 클릭 이벤트
  229. /// </summary>
  230. /// <param name="sender">The source of the event.</param>
  231. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  232. private void toolStripButtonNextPage_Click(object sender, EventArgs e) {
  233. this.consentMain.MoveNextPage();
  234. }
  235. /// <summary>
  236. /// 마지막 페이지로 이동 버튼 클릭 이벤트
  237. /// </summary>
  238. /// <param name="sender">The source of the event.</param>
  239. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  240. private void toolStripButtonLastPage_Click(object sender, EventArgs e) {
  241. this.consentMain.MoveLastPage();
  242. }
  243. /// <summary>
  244. /// toolStripTextBoxPageIndex 텍스트 변경 이벤트
  245. /// </summary>
  246. /// <param name="sender">The source of the event.</param>
  247. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  248. private void toolStripTextBoxPageIndex_TextChanged(object sender, EventArgs e) {
  249. if(!string.IsNullOrEmpty(this.toolStripTextBoxPageIndex.Text)) {
  250. bool currentIndexParseResult;
  251. int currentIndex = 0;
  252. currentIndexParseResult = int.TryParse(this.toolStripTextBoxPageIndex.Text, out currentIndex);
  253. bool totalIndexParseResult;
  254. int totalIndex = 0;
  255. totalIndexParseResult = int.TryParse(this.toolStripTextBoxPageIndex.Text, out totalIndex);
  256. if(currentIndexParseResult == false || totalIndexParseResult == false) {
  257. return;
  258. }
  259. if(currentIndex > totalIndex) {
  260. }
  261. // 입력한 페이지수가 전체 페이지 이하일 경우 해당 페이지로 이동
  262. else {
  263. this.consentMain.MoveToPageIndex(currentIndex);
  264. }
  265. }
  266. }
  267. /// <summary>
  268. /// 동의서 확대비율 지정 콤보 박스 변경 이벤트
  269. /// </summary>
  270. /// <param name="sender">The source of the event.</param>
  271. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  272. private void toolStripComboBoxZoom_SelectedIndexChanged(object sender, EventArgs e) {
  273. ZoomRateDropdownItem zoomRateItem = this.toolStripComboBoxZoom.SelectedItem as ZoomRateDropdownItem;
  274. if(zoomRateItem == null) {
  275. }
  276. else {
  277. this.consentMain.SetZoomRate(zoomRateItem.ItemValue);
  278. }
  279. }
  280. private void setCurrentPreviewConsent(ConsentFormListVO vo, int orderNo, string inputId, string inputNm) {
  281. // 현재 preview 할동의서 정보 설정
  282. CurrentPreviewConsent = new PreviewConsent {
  283. formRid = vo.formRid.ToString(),
  284. formGuid = vo.formGuid,
  285. formCd = vo.formCd.ToString(),
  286. FormName = vo.formName,
  287. formPrintName = vo.formPrntNm,
  288. prntCnt = vo.printCnt,
  289. consentMstRid = "-1",
  290. consentState = string.Empty,
  291. orderNo = orderNo,
  292. inputId = inputId,
  293. inputNm = inputNm,
  294. ReissueConsentMstRid = 0,
  295. RewriteConsentMstRid = 0,
  296. ordType = CurrentTargetPatient.VisitType,
  297. ocrtagPrntyn = vo.ocrTagPrntYn,
  298. userDrFlag = vo.userDrFlag,
  299. printOnly = vo.printOnly,
  300. opDiagName = vo.opDiagNm,
  301. drOnly = vo.DrOnly,
  302. opName = vo.opNm
  303. };
  304. Dictionary<FOSParameter, string> globalParams = Common.CreateGlobalParamsDictionary(consentMain.ConsentExecuteInfo["dutinstcd"]);
  305. List<string> formGuids = new List<string> { CurrentPreviewConsent.formGuid };
  306. SetPatientAndUser(globalParams);
  307. globalParams[FOSParameter.OCRCode] = string.Empty;
  308. var ocrBuf = GetOcrCode();
  309. if(string.IsNullOrEmpty(ocrBuf)) {
  310. MessageBox.Show("OCR 중복입니다. 다시 환자를 선택하여 주세요.");
  311. return;
  312. }
  313. int cnt = hospitalWebService.checkOcrDup(consentMain.ConsentExecuteInfo["dutinstcd"], ocrBuf);
  314. if(cnt > 0) {
  315. MessageBox.Show("OCRTAG 중복 발생입니다. 환자를 다시 선택하여 주십시요.");
  316. consentMain.ClearPreviewConsent(true);
  317. return;
  318. }
  319. globalParams[FOSParameter.OCRCode] = CurrentPreviewConsent.ocrCode = ocrBuf;
  320. globalParams[FOSParameter.Device] = "P";
  321. globalParams[FOSParameter.PrintTime] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  322. globalParams[FOSParameter.SignTime] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  323. globalParams[FOSParameter.PrintIp] = consentMain.ConsentExecuteInfo["printIP"];
  324. if(string.IsNullOrEmpty(CurrentPreviewConsent.ocrCode)) {
  325. MessageBox.Show("OCRTAG 생성 오류. 전산실에 문의 하세요.");
  326. consentMain.ClearPreviewConsent(true);
  327. return;
  328. }
  329. string fos = Common.GetFosString(formGuids
  330. , consentMain.PluginExecuteInfo["formServiceUrl"]
  331. , globalParams
  332. , null
  333. , consentMain.ConsentExecuteInfo["dutinstcd"]);
  334. SetEnableButtonsByCurrentConsent();
  335. consentMain.PreviewConsent(fos);
  336. }
  337. /// <summary>
  338. /// 출력 버튼 클릭 이벤트
  339. /// </summary>
  340. /// <param name="sender">The source of the event.</param>
  341. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  342. private void toolStripButtonPrint_Click(object sender, EventArgs e) {
  343. // dbs227, 현재 동의서 상태가 null 이라면 skip
  344. if(CurrentPreviewConsent == null) {
  345. SetEnableButtonsByCurrentConsent();
  346. return;
  347. }
  348. int cnt = hospitalWebService.checkOcrDup(consentMain.ConsentExecuteInfo["dutinstcd"], CurrentPreviewConsent.ocrCode);
  349. if(cnt > 0) {
  350. MessageBox.Show("OCRTAG 중복 발생입니다. 환자를 다시 선택하여 주십시요.");
  351. consentMain.ClearPreviewConsent(true);
  352. return;
  353. }
  354. // 경북대학교병원 요청사항 출력 제어
  355. string printControlMsg = string.Empty;
  356. string printOnly = string.Empty;
  357. printOnly = hospitalWebService.getPrintOnly(consentMain.ConsentExecuteInfo["dutinstcd"], CurrentPreviewConsent.formCd);
  358. printControlMsg = hospitalWebService.getPrintControlMsg(consentMain.ConsentExecuteInfo["dutinstcd"], CurrentTargetPatient.VisitType.ToUpper());
  359. // 6961 [전자동의서]출력시 특정 진찰료 면제사유시 제어 switch
  360. var runCount = hospitalWebService.checkHardcd(consentMain.ConsentExecuteInfo["dutinstcd"], "6961", "Y");
  361. var runCount2 = hospitalWebService.checkHardcd(consentMain.ConsentExecuteInfo["dutinstcd"], "6952", CurrentPreviewConsent.formCd);
  362. // 출력 전용 서식이 아닐 경우 출력 제한을 한다.
  363. if(!string.IsNullOrEmpty(printOnly) && printOnly.Equals("N")) {
  364. if(!string.IsNullOrEmpty(printControlMsg) && runCount2 < 1) {
  365. MessageBox.Show(printControlMsg);
  366. return;
  367. }
  368. }
  369. var count = hospitalWebService.checkPrintablePatient(consentMain.ConsentExecuteInfo["dutinstcd"],
  370. consentMain.ConsentExecuteInfo["patientNo"],
  371. consentMain.ConsentExecuteInfo["clnDate"],
  372. consentMain.ConsentExecuteInfo["cretno"]);
  373. // 6961 [전자동의서]출력시 특정 진찰료 면제사유시 제어 switch
  374. //var runCount = hospitalWebService.checkHardcd(consentMain.ConsentExecuteInfo["dutinstcd"], "6961", "Y");
  375. //var runCount2 = hospitalWebService.checkHardcd(consentMain.ConsentExecuteInfo["dutinstcd"], "6952", CurrentPreviewConsent.FormCd);
  376. // 해당 기준자료가 설정 되었다면 아래기능 호출
  377. if(runCount > 0) {
  378. if(count > 0) {
  379. MessageBox.Show("출력할 수 없는 수진이력입니다.\n(문의: 의무기록팀)", "확인", MessageBoxButtons.OK);
  380. return;
  381. }
  382. }
  383. if(CurrentPreviewConsent.consentState.ToUpper().Equals("UNFINISHED") || CurrentPreviewConsent.consentState.ToUpper().Equals("TEMP")) {
  384. MessageBox.Show(string.Format(Properties.Resources.msg_cannot_print_temp_doc)
  385. , string.Format(Properties.Resources.title_info),
  386. MessageBoxButtons.OK, MessageBoxIcon.Information);
  387. return;
  388. }
  389. this.consentMain.setPrintButton(true);
  390. // 진정동의서 출력 서식 확인
  391. int result = this.consentWebService.checkJinJeongDocument(consentMain.ConsentExecuteInfo["dutinstcd"], currentPreviewConsent.formCd);
  392. if(result > 0) {
  393. // 진정동의서를 출력 해야 한다.
  394. this.CurrentPreviewConsent.linkFormCd = "1100010977";
  395. }
  396. // 연계 서식이 없다면 기존 출력 루틴으로 출력
  397. if(/*this.CurrentPreviewConsent.linkFormCd == null || */string.IsNullOrEmpty(this.CurrentPreviewConsent.linkFormCd)) {
  398. PrintConsent();
  399. if (consentMain.multiParams == null)
  400. {
  401. consentMain.ClearPreviewConsent(true);
  402. }
  403. else
  404. {
  405. consentMain.showNextPreview();
  406. }
  407. }
  408. // 연계 서식이 있다면
  409. else {
  410. // 기관별 마취 동의서 서식 코드를 조회 한다
  411. String anstFormCd = this.consentWebService.getLinkedAnstDocument(consentMain.ConsentExecuteInfo["dutinstcd"]);
  412. if(anstFormCd == null && this.currentPreviewConsent.linkFormCd.Equals("1100010977")) {
  413. // 마취동의서 코드를 찾지 못하면 메시지 박스를 보여준다
  414. MessageBox.Show("기준자료 오류, 전산실에 문의하세요", "경고", MessageBoxButtons.OK, MessageBoxIcon.Information);
  415. return;
  416. }
  417. // 마취 동의서 라면
  418. if(this.CurrentPreviewConsent.linkFormCd.Equals(anstFormCd)) {
  419. // 출력 후 연계서식 정보 초기화되기 때문에 미리 값을 저장 해 둔다
  420. var linkFormCd = this.CurrentPreviewConsent.linkFormCd;
  421. var orderNo = this.CurrentPreviewConsent.orderNo;
  422. var inputNm = this.CurrentPreviewConsent.inputNm;
  423. var inputId = this.CurrentPreviewConsent.inputId;
  424. MessageBox.Show(string.Format(Properties.Resources.msg_info_anes_docu_print)
  425. , string.Format(Properties.Resources.title_info),
  426. MessageBoxButtons.OK, MessageBoxIcon.Information);
  427. // 선택된 동의서 출력
  428. PrintConsent();
  429. // 연계 동의서 출력
  430. //ConsentFormListVO[] voArr = this.consentWebService.GetConsentByFormcd(linkFormCd, consentMain.ConsentExecuteInfo["dutinstcd"]);
  431. ConsentFormListVO vo = this.consentWebService.GetConsentByFormcd(linkFormCd, consentMain.ConsentExecuteInfo["dutinstcd"]);
  432. // 조회된 서식이 없다면 출력 하지 않음
  433. if(vo == null) {
  434. return;
  435. }
  436. //setCurrentPreviewConsent(voArr[0], orderNo, inputId, inputNm);
  437. setCurrentPreviewConsent(vo, orderNo, inputId, inputNm);
  438. consentMain.setPrintButton(true);
  439. // 프린트 한다
  440. PrintConsent();
  441. }
  442. // 진정동의서 출력 해야 되는 경우라면
  443. else if(this.currentPreviewConsent.linkFormCd.Equals("1100010977")) {
  444. DialogResult clickResult = MessageBox.Show(string.Format(Properties.Resources.msg_jinjeong)
  445. , string.Format(Properties.Resources.title_jinjeong),
  446. MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information);
  447. switch(clickResult) {
  448. case DialogResult.Yes: {
  449. // 출력 후 연계서식 정보 초기화되기 때문에 미리 값을 저장 해 둔다
  450. var linkFormCd = this.CurrentPreviewConsent.linkFormCd;
  451. var orderNo = this.CurrentPreviewConsent.orderNo;
  452. var inputNm = this.CurrentPreviewConsent.inputNm;
  453. var inputId = this.CurrentPreviewConsent.inputId;
  454. // 선택된 동의서 출력
  455. PrintConsent();
  456. // 연계 동의서 출력
  457. //ConsentBySearchVO[] voArr = this.consentWebService.GetConsentByFormcd(linkFormCd, consentMain.ConsentExecuteInfo["dutinstcd"]);
  458. ConsentFormListVO vo = this.consentWebService.GetConsentByFormcd(linkFormCd, consentMain.ConsentExecuteInfo["dutinstcd"]);
  459. // 조회된 서식이 없다면 출력 하지 않음
  460. if(vo == null) {
  461. return;
  462. }
  463. setCurrentPreviewConsent(vo, orderNo, inputId, inputNm);
  464. consentMain.setPrintButton(true);
  465. // 프린트 한다
  466. PrintConsent();
  467. }
  468. break;
  469. case DialogResult.No: {
  470. // 선택된 동의서만 프린트
  471. PrintConsent();
  472. }
  473. break;
  474. case DialogResult.Cancel:
  475. // do nothing
  476. break;
  477. }
  478. }
  479. if (consentMain.multiParams == null)
  480. {
  481. // 출력을 다 하였으면 화면을 닫는다.
  482. consentMain.ClearPreviewConsent(true);
  483. }
  484. else
  485. {
  486. consentMain.showNextPreview();
  487. }
  488. }
  489. }
  490. /// <summary>
  491. /// 동의서 닫기 버튼 클릭 이벤트
  492. /// </summary>
  493. /// <param name="sender">The source of the event.</param>
  494. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  495. private void toolStripButtonCloseDualViewer_Click(object sender, EventArgs e) {
  496. this.consentMain.CloseDualViewer();
  497. }
  498. /// <summary>
  499. /// 임시저장 버튼 클릭 이벤트
  500. /// </summary>
  501. /// <param name="sender">The source of the event.</param>
  502. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  503. private void toolStripButtonTempSaveToServer_Click(object sender, EventArgs e) {
  504. // 동의서 임시 저장
  505. this.consentMain.TempSave();
  506. }
  507. /// <summary>
  508. /// 서명 버튼 클릭 이벤트
  509. /// </summary>
  510. /// <param name="sender">The source of the event.</param>
  511. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  512. private void toolStripButtonSaveToServer_Click(object sender, EventArgs e) {
  513. // dbs227, 현재 동의서 상태가 null 이라면 skip
  514. if(CurrentPreviewConsent == null) {
  515. SetEnableButtonsByCurrentConsent();
  516. return;
  517. }
  518. // 로그인 사용자와 동의서 작성자가 다르면 인증 저장 제한
  519. if(!CurrentEndUser.JobKindCd.Substring(0, 2).Equals("03") && !CurrentPreviewConsent.inputId.Equals(consentMain.ConsentExecuteInfo["loginUserNo"])) {
  520. MessageBox.Show("작성자만 인증 저장이 가능합니다.", "인증 저장 불가", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  521. return;
  522. }
  523. if(!CurrentEndUser.JobKindCd.Substring(0, 2).Equals("03") && CurrentPreviewConsent.drOnly.ToUpper().Equals("Y")) {
  524. MessageBox.Show("의사만 인증저장 가능한 동의서 입니다.\n문의:보건의료정보관리(의무기록)팀", "인증 저장 불가", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  525. return;
  526. }
  527. this.consentMain.saveClickPoint = true;
  528. this.consentMain.Save();
  529. this.consentMain.saveClickPoint = false;
  530. //저장 후 로그인 사용자를 현재endUser로 세팅
  531. consentMain.SetConsentUserInfo(consentMain.ConsentExecuteInfo["dutinstcd"]
  532. , consentMain.ConsentExecuteInfo["loginUserNo"]
  533. , consentMain.ConsentExecuteInfo["userDeptCd"]);
  534. }
  535. /// <summary>
  536. /// 확인 저장 버튼 클릭 이벤트
  537. /// </summary>
  538. /// <param name="sender">The source of the event.</param>
  539. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  540. private void toolStripButtonCompleteSaveToServer_Click(object sender, EventArgs e) {
  541. if (this.consentWebService.getCertUseYn(this.currentPreviewConsent.formCd,
  542. consentMain.ConsentExecuteInfo["dutinstcd"]) == "Y")
  543. {
  544. MessageBox.Show("인증서가 필요없는 서식은 [확인저장] 할 수 없습니다.\r[인증저장] 으로 진행하시기 바랍니다.");
  545. return;
  546. }
  547. m_IsComplete = true;
  548. this.consentMain.Save();
  549. m_IsComplete = false;
  550. }
  551. /// <summary>
  552. /// 전자동의서 실행 버튼 클릭 이벤트
  553. /// </summary>
  554. /// <param name="sender">The source of the event.</param>
  555. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  556. private void toolStripButtonExecute_Click(object sender, EventArgs e) {
  557. RunConsentDualView();
  558. }
  559. /// <summary>
  560. /// 펜 그리기 모드 활성화/비활성화 버튼 클릭 이벤트
  561. /// </summary>
  562. /// <param name="sender">The source of the event.</param>
  563. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  564. private void toolStripButtonPen_Click(object sender, EventArgs e) {
  565. bool isDrawMode = this.consentMain.IsDrawMode();
  566. this.consentMain.EnableDrawing(!isDrawMode);
  567. this.toolStripButtonPen.Checked = !isDrawMode;
  568. }
  569. /// <summary>
  570. /// 그리기 펜 설정 버튼 클릭 이벤트
  571. /// </summary>
  572. /// <param name="sender">The source of the event.</param>
  573. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  574. private void toolStripButtonPenConfig_Click(object sender, EventArgs e) {
  575. // 펜 색상 및 두께 변경
  576. this.consentMain.ConfigDrawingPen();
  577. }
  578. /// <summary>
  579. /// 펜 그리기 데이터 모두 삭제 버튼 클릭 이벤트
  580. /// </summary>
  581. /// <param name="sender">The source of the event.</param>
  582. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  583. private void toolStripButtonDelAllDraw_Click(object sender, EventArgs e) {
  584. this.consentMain.RemoveAllDrawing();
  585. }
  586. /// <summary>
  587. /// 펜 그리기 undo 버튼 클릭 이벤트
  588. /// </summary>
  589. /// <param name="sender">The source of the event.</param>
  590. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  591. private void toolStripButtonUndo_Click(object sender, EventArgs e) {
  592. this.consentMain.UndoDrawing();
  593. }
  594. /// <summary>
  595. /// 펜 그리기 redo 버튼 클릭 이벤트
  596. /// </summary>
  597. /// <param name="sender">The source of the event.</param>
  598. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  599. private void toolStripButtonRedo_Click(object sender, EventArgs e) {
  600. this.consentMain.RedoDrawing();
  601. }
  602. #endregion
  603. /// <summary>
  604. /// 페지 변경시 이벤트
  605. /// 외부에서 호출하는 메서드
  606. /// </summary>
  607. /// <param name="currentPageIndex">Index of the current page.</param>
  608. public override void OnPaging(int currentPageIndex) {
  609. this.toolStripTextBoxPageIndex.Text = currentPageIndex.ToString();
  610. }
  611. /// <summary>
  612. /// 동의서 종이 출력
  613. /// </summary>
  614. /// <param name="value"></param>
  615. public override void OnPrint(string value) {
  616. Cursor currentCursor = this.Cursor;
  617. try {
  618. this.Cursor = Cursors.WaitCursor;
  619. SaveDataForPrintedConsent(string.Empty);
  620. // dbs227, 경대병원 프린트 연동 로그 추후 기록
  621. // 기존 저장 루틴 위치 변경
  622. //SaveDataForPrintedConsent(string.Empty);
  623. // 출력 카운트만큼 출력 된 후 처리
  624. /*
  625. if (this.consentMain.printSaveStatus) {
  626. if (consentMain.ConsentExecuteInfo["printAct"].Equals("N")) {
  627. //MessageBox.Show(string.Format(Properties.Resources.msg_temp_print_confirm)
  628. // , string.Format(Properties.Resources.msg_caption_confirm), MessageBoxButtons.OK, MessageBoxIcon.Information);
  629. //출력후에는 전체목록 탭이 선택되게 한다.
  630. this.consentMain.ConsentListCtrl.InquiryConsentData(-2);
  631. } else {
  632. //agent 구동시 바로 출력을 하는 경우 미작성 탭이 선택되게 한다.
  633. this.consentMain.ConsentListCtrl.InquiryConsentData(9);
  634. }
  635. //Agent에서 출력요청한 내용이 모두 끝나면 창을 닫는다.
  636. if (consentMain.ConsentExecuteInfo["printAct"].Equals("Y")) {
  637. this.consentMain.agentCallPrintCnt--;
  638. if (this.consentMain.agentCallPrintCnt == 0) {
  639. this.consentMain.Parent_Disposed();
  640. }
  641. }
  642. }
  643. */
  644. }
  645. catch(Exception ex) {
  646. throw ex;
  647. }
  648. finally {
  649. this.Cursor = currentCursor;
  650. // dbs227 저장이 끝나면 preview 객체를 초기화 하여 준다
  651. CurrentPreviewConsent = null;
  652. }
  653. base.OnPrint(value);
  654. }
  655. /// <summary>
  656. /// 동의서 동의서 미리보기 상태 활성화 처리
  657. /// </summary>
  658. /// <param name="isIssuable"></param>
  659. public override void SetEnableConsentIssueCommands(bool isIssuable) {
  660. this.toolStripButtonPrint.Enabled = isIssuable;//프린트
  661. this.toolStripButtonExecute.Enabled = isIssuable;//아큐실행버튼
  662. this.toolStripButtonFirstPage.Enabled = isIssuable;//
  663. this.toolStripButtonPrevPage.Enabled = isIssuable;
  664. this.toolStripButtonNextPage.Enabled = isIssuable;
  665. this.toolStripButtonLastPage.Enabled = isIssuable;
  666. this.toolStripTextBoxPageIndex.Enabled = isIssuable;//페이지번호 보여주는부분 total page
  667. this.toolStripLabelTotalPages.Enabled = isIssuable;//
  668. this.toolStripTextBoxPageIndex.Text = consentMain.GetCurrentPageIndex().ToString();
  669. this.toolStripLabelTotalPages.Text = consentMain.GetTotalPageCount().ToString();
  670. this.toolStripComboBoxZoom.Enabled = isIssuable;//넓이 맞춤 서식 폭 조정
  671. this.toolStripButtonDeleteAllSignData.Enabled = isIssuable;//그림그린거 다없앤거
  672. this.toolStripButtonInsertAttach.Enabled = isIssuable;//첨지
  673. this.toolStripButtonDeleteAttach.Enabled = isIssuable;//첨지삭제
  674. //this.toolStripButtonSaveToServer.Enabled = isIssuable; // 인증 저장
  675. //this.toolStripButtonTempSaveToServer.Enabled = isIssuable; // 임시 저장
  676. //this.toolStripButtonCompleteSaveToServer.Enabled = isIssuable; // 완료 저장
  677. }
  678. /// <summary>
  679. /// 동의서 상태에 따라 버튼들 활성화를 조절한다
  680. /// </summary>
  681. public override void SetEnableButtonsByCurrentConsent() {
  682. string state = string.Empty;
  683. if(this.CurrentPreviewConsent != null) {
  684. state = this.CurrentPreviewConsent.consentState;
  685. }
  686. if(this.CurrentTargetPatient != null && !string.IsNullOrEmpty(this.CurrentTargetPatient.PatientCode)
  687. && CurrentPreviewConsent != null) {
  688. if(!ConsentMainControl.HasVerticalMonitor) {
  689. this.toolStripButtonTempSaveToServer.Enabled = true;
  690. this.toolStripButtonSaveToServer.Enabled = true;
  691. //this.toolStripButtonCompleteSaveToServer.Enabled = true;
  692. this.toolStripButtonPrint.Enabled = true;
  693. SetEnableButtonsByConsentStateForSingleView(state);
  694. this.EnablePenDrawing = true;
  695. this.EnablePenConfig = true;
  696. }
  697. else {
  698. //this.toolStripButtonCompleteSaveToServer.Enabled = true;
  699. this.toolStripButtonSaveToServer.Enabled = true;
  700. this.toolStripButtonExecute.Enabled = true;
  701. this.toolStripButtonPrint.Enabled = true;
  702. SetEnableButtonsByConsentStateForDualView(state);
  703. }
  704. this.toolStripButtonDelAllDraw.Enabled = true;
  705. this.toolStripButtonRedo.Enabled = true;
  706. this.toolStripButtonUndo.Enabled = true;
  707. }
  708. else {
  709. this.toolStripButtonPrint.Enabled = false;
  710. this.toolStripButtonTempSaveToServer.Enabled = false;
  711. //this.toolStripButtonCompleteSaveToServer.Enabled = false;
  712. this.toolStripButtonSaveToServer.Enabled = false;
  713. this.toolStripButtonDelAllDraw.Enabled = false;
  714. this.toolStripButtonRedo.Enabled = false;
  715. this.toolStripButtonUndo.Enabled = false;
  716. }
  717. }
  718. /// <summary>
  719. /// Dual Viewer 활성화 시 버튼 활성화 설정
  720. /// </summary>
  721. /// <param name="enabled">활성화 여부</param>
  722. public override void SetEnablementExecuteWhenDualViewerActive(bool enabled) {
  723. // 전자동의서 실행 버튼
  724. this.toolStripButtonExecute.Enabled = enabled;
  725. // 출력 버튼
  726. this.toolStripButtonPrint.Enabled = enabled;
  727. if(enabled) {
  728. if(this.CurrentPreviewConsent != null && this.CurrentPreviewConsent.outputType != null) {
  729. if(this.CurrentPreviewConsent.outputType.Equals("ELECTRONIC")) {
  730. this.toolStripButtonPrint.Enabled = !enabled;
  731. }
  732. }
  733. }
  734. // Dual Viewer 닫기 버튼
  735. this.toolStripButtonCloseDualViewer.Visible = !enabled;
  736. SetEnableByUserType();
  737. base.SetEnablementExecuteWhenDualViewerActive(enabled);
  738. }
  739. /// <summary>
  740. /// 동의서 상태에 따른 Dual view 상태의 버튼 설정
  741. /// </summary>
  742. /// <param name="state">The state.</param>
  743. private void SetEnableButtonsByConsentStateForDualView(string state) {
  744. if(state.Equals("PAPER_OUT")) {
  745. this.toolStripButtonExecute.Enabled = false;
  746. }
  747. else if(state.Equals("ELECTR_CMP") || state.Equals("CERTIFY_CMP")) {
  748. this.toolStripButtonExecute.Enabled = false;
  749. this.toolStripButtonPrint.Enabled = false;
  750. }
  751. if(this.CurrentPreviewConsent.RewriteConsentMstRid > 0) {
  752. this.toolStripButtonExecute.Enabled = true;
  753. }
  754. }
  755. /// <summary>
  756. /// 동의서 상태에 따른 Single view 상태의 버튼 설정
  757. /// </summary>
  758. /// <param name="state">The state.</param>
  759. private void SetEnableButtonsByConsentStateForSingleView(string state) {
  760. if(state.Equals("PAPER_OUT")) {
  761. this.toolStripButtonSaveToServer.Enabled = false;
  762. //this.toolStripButtonCompleteSaveToServer.Enabled = false;
  763. this.toolStripButtonTempSaveToServer.Enabled = false;
  764. this.toolStripButtonExecute.Enabled = false;
  765. }
  766. else if(state.Equals("ELECTR_CMP") || state.Equals("CERTIFY_CMP")) {
  767. this.toolStripButtonTempSaveToServer.Enabled = false;
  768. //this.toolStripButtonCompleteSaveToServer.Enabled = false;
  769. this.toolStripButtonSaveToServer.Enabled = false;
  770. this.toolStripButtonPrint.Enabled = false;
  771. }
  772. if(this.CurrentPreviewConsent.RewriteConsentMstRid > 0) {
  773. this.toolStripButtonTempSaveToServer.Enabled = true;
  774. //this.toolStripButtonCompleteSaveToServer.Enabled = true;
  775. this.toolStripButtonSaveToServer.Enabled = true;
  776. }
  777. }
  778. /// <summary>
  779. /// 미작성 동의서 삭제
  780. /// </summary>
  781. /// <param name="reasonForUseN"></param>
  782. public override void DeleteRecordOfDeleteConsent(string reasonForUseN) {
  783. SaveDataForDeleteConsent(reasonForUseN);
  784. }
  785. /// <summary>
  786. /// 출력된 동의서를 저장
  787. /// </summary>
  788. /// <param name="reasonForUseN">The reason for use n.</param>
  789. //private void SaveDataForPrintedConsent(string reasonForUseN) {
  790. public void SaveDataForPrintedConsent(string reasonForUseN) {
  791. string consentOutputType = this.CurrentPreviewConsent.outputType;
  792. string consentState = this.CurrentPreviewConsent.consentState;
  793. //int result = -1;
  794. //인쇄(바코드제외)인 경우 CONSENT_MST에 데이터를 입력하지 않는다.
  795. if((!string.IsNullOrEmpty(consentOutputType) && consentOutputType.Equals("PAPER_EXCEPT_BARCODE"))) {
  796. //return result;
  797. return;
  798. }
  799. // 다중 출력 시
  800. if(consentOutputType != null && consentOutputType.Equals("MULTI")) {
  801. Cursor currentCursor = this.Cursor;
  802. try {
  803. this.Cursor = Cursors.WaitCursor;
  804. List<PatListVO> volist = consentMain.PatientListCtrl.GetSelectedPatientList();
  805. string[] strOcrCd = null;
  806. if(this.CurrentPreviewConsent.multiOcrcode.Length > 0) {
  807. strOcrCd = this.CurrentPreviewConsent.multiOcrcode.Split('^');
  808. }
  809. string[] strMainDrIdCd = null;
  810. if(this.CurrentPreviewConsent.multiMainDrIdCd.Length > 0) {
  811. strMainDrIdCd = this.CurrentPreviewConsent.multiMainDrIdCd.Split('^');
  812. }
  813. int lastRid = -1;
  814. for(int i = 0; i < volist.Count; i++) {
  815. PatientVO vo = GetPatientByPatList(volist[i]);
  816. //string userId = (vo.inputId == null) ? CurrentEndUser.UserNo : vo.inputId;
  817. //string userName = (vo.inputNm == null) ? CurrentEndUser.UserName : vo.inputNm;
  818. string userId = this.consentMain.ConsentExecuteInfo["loginUserNo"];
  819. string userName = this.consentMain.ConsentExecuteInfo["loginUserName"];
  820. string deptCd = this.consentMain.ConsentExecuteInfo["userDeptCd"];
  821. string hosType = (vo.instCd == null) ? consentMain.ConsentExecuteInfo["dutinstcd"] : vo.instCd;
  822. if (string.IsNullOrEmpty(userName)) {
  823. UserVO userVo = hospitalWebService.GetUserInfo(userId, hosType, deptCd);
  824. userName = userVo.userName;
  825. }
  826. string patientCode = vo.pid;
  827. string clnDeptCode = vo.ordDeptCd;
  828. string vistType = vo.ordType;
  829. string clnDate = vo.inDd.Replace("-", "");
  830. int rewriteConsentMstRid = 0;
  831. string ward = vo.ward;
  832. string roomcd = vo.roomCd;
  833. string formRid = CurrentPreviewConsent.formRid;
  834. string formCd = CurrentPreviewConsent.formCd;
  835. string consentMstRid = CurrentPreviewConsent.consentMstRid;
  836. int orderNo = vo.orderNo;
  837. string orderCode = vo.dxCd;
  838. string orderName = vo.dxNm;
  839. string ocrCode = (strOcrCd != null && !string.IsNullOrEmpty(strOcrCd[i])) ? strOcrCd[i] : CurrentPreviewConsent.ocrCode;
  840. string mainDrId = (strMainDrIdCd != null && !string.IsNullOrEmpty(strMainDrIdCd[i])) ? strMainDrIdCd[i] : currentTargetPatient.MainDrId;
  841. int.TryParse(vo.cretNo, out int cretno);
  842. ConvertStringToInt(formRid, consentMstRid, out int formRidInt, out int consentMstRidInt);
  843. string deviceIdentNo = System.Environment.MachineName;
  844. // 동의서 프린트 출력 후 데이터를 저장
  845. consentMstRidInt = consentWebService.SavePrintOut(userId
  846. , patientCode
  847. , clnDeptCode
  848. , formRidInt
  849. , formCd
  850. , consentMstRidInt
  851. , rewriteConsentMstRid
  852. , null
  853. , null
  854. , "PRT"
  855. , deviceIdentNo
  856. , vistType
  857. , hosType
  858. , clnDate
  859. , ward
  860. , roomcd
  861. , orderNo
  862. , orderName
  863. , orderCode
  864. , ocrCode
  865. , cretno
  866. , userName
  867. , userName
  868. , mainDrId
  869. , CurrentEndUser.DeptCode
  870. , consentMain.GetTotalPageCount().ToString()
  871. , "P"
  872. , "P"
  873. , CurrentTargetPatient.OpRsrvNo);
  874. lastRid = consentMstRidInt;
  875. //result = lastRid;
  876. }
  877. this.consentMain.ConsentListCtrl.InquiryConsentData(lastRid);
  878. // dbs227,
  879. // 출력 모드가 아닐때는 초기화 하지 않는다.
  880. //if (!this.consentMain.ConsentExecuteInfo["printYN"].Equals("Y"))
  881. //{
  882. //this.consentMain.ConsentListCtrl.InquiryConsentData(lastRid);
  883. //}
  884. this.consentMain.multiPrintExecCnt++;
  885. }
  886. catch(Exception ex) {
  887. throw ex;
  888. }
  889. finally {
  890. this.Cursor = currentCursor;
  891. }
  892. consentMain.PatientListCtrl.SetClearCheckBox();
  893. if (consentMain.multiParams == null)
  894. {
  895. consentMain.ReInitializeViewer();
  896. }
  897. }
  898. else {
  899. if(this.CurrentTargetPatient != null && !string.IsNullOrEmpty(this.CurrentTargetPatient.PatientCode)) {
  900. //string userId = CurrentEndUser.UserNo;
  901. //string userName = CurrentEndUser.UserName;
  902. string userId = this.consentMain.ConsentExecuteInfo["loginUserNo"];
  903. string userName = this.consentMain.ConsentExecuteInfo["loginUserName"];
  904. string hosType = consentMain.ConsentExecuteInfo["dutinstcd"];
  905. string deptCd = this.consentMain.ConsentExecuteInfo["userDeptCd"];
  906. if (string.IsNullOrEmpty(userName)) {
  907. UserVO userVo = hospitalWebService.GetUserInfo(userId, hosType, deptCd);
  908. userName = userVo.userName;
  909. }
  910. string patientCode = CurrentTargetPatient.PatientCode;
  911. string clnDeptCode = CurrentTargetPatient.clnDeptCode;
  912. string vistType = CurrentTargetPatient.VisitType;
  913. string clnDate = CurrentTargetPatient.clnDate.Replace("-", "");
  914. string ward = CurrentTargetPatient.Ward;
  915. string roomcd = currentTargetPatient.RoomNo;
  916. int orderNo = CurrentTargetPatient.OrderNo;
  917. string orderCode = CurrentTargetPatient.OPdeptCode;
  918. string orderName = CurrentTargetPatient.OPdeptName;
  919. string mainDrId = CurrentTargetPatient.MainDrId;
  920. string formRid = CurrentPreviewConsent.formRid;
  921. string formCd = CurrentPreviewConsent.formCd;
  922. string consentMstRid = CurrentPreviewConsent.consentMstRid;
  923. string ocrCode = CurrentPreviewConsent.ocrCode;
  924. int cretno = 0;
  925. int.TryParse(CurrentTargetPatient.cretno, out cretno);
  926. ConvertStringToInt(formRid, consentMstRid, out int formRidInt, out int consentMstRidInt);
  927. int reissueConsentMstRid = 0;
  928. string deviceIdentNo = System.Environment.MachineName;
  929. Cursor currentCursor = this.Cursor;
  930. try {
  931. this.Cursor = Cursors.WaitCursor;
  932. // 동의서 프린트 출력 후 데이터를 저장
  933. consentMstRidInt = consentWebService.SavePrintOut(userId
  934. , patientCode
  935. , clnDeptCode
  936. , formRidInt
  937. , formCd
  938. , consentMstRidInt
  939. , reissueConsentMstRid
  940. , null
  941. , null
  942. , "PRT"
  943. , deviceIdentNo
  944. , vistType
  945. , hosType
  946. , clnDate
  947. , ward
  948. , roomcd
  949. , orderNo
  950. , orderName
  951. , orderCode
  952. , ocrCode
  953. , cretno
  954. , userName
  955. , userName
  956. , mainDrId
  957. , currentEndUser.DeptCode
  958. , consentMain.GetTotalPageCount().ToString()
  959. , "P"
  960. , "P"
  961. , CurrentTargetPatient.OpRsrvNo);
  962. if (consentMain.multiParams == null)
  963. {
  964. this.consentMain.ConsentListCtrl.InquiryConsentData(consentMstRidInt);
  965. }
  966. this.consentMain.multiPrintExecCnt++;
  967. //result = consentMstRidInt;
  968. }
  969. catch(Exception ex) {
  970. throw ex;
  971. }
  972. finally {
  973. this.Cursor = currentCursor;
  974. }
  975. }
  976. }
  977. //return result;
  978. }
  979. /// <summary>
  980. /// 출력 히스토리 삭제
  981. /// </summary>
  982. public void erasePrintHistory() {
  983. String consentMstRid = CurrentPreviewConsent.consentMstRid;
  984. String ocrCode = CurrentPreviewConsent.ocrCode;
  985. String instcd = consentMain.ConsentExecuteInfo["dutinstcd"];
  986. String pid = CurrentTargetPatient.PatientCode;
  987. Cursor currentCursor = this.Cursor;
  988. try {
  989. this.Cursor = Cursors.WaitCursor;
  990. consentWebService.updatePrintHistory(pid, ocrCode, instcd);
  991. }
  992. catch(Exception ex) {
  993. throw ex;
  994. }
  995. finally {
  996. this.Cursor = currentCursor;
  997. }
  998. }
  999. /// <summary>
  1000. /// 환자리스트의 한 환자의 상세정보를 조회한다
  1001. /// </summary>
  1002. /// <param name="patvo">조회할 환자의 PatListVO 인스턴스</param>
  1003. /// <returns></returns>
  1004. private PatientVO GetPatientByPatList(PatListVO patvo) {
  1005. string indd = string.Empty;
  1006. if(!string.IsNullOrEmpty(patvo.inDd)) indd = patvo.inDd.Replace("/", "").Replace("-", "");
  1007. PatientVO[] patientVOList = this.hospitalWebService.GetPatientInfo(patvo.pid
  1008. , indd
  1009. , patvo.ordType
  1010. , patvo.ordDeptCd
  1011. , patvo.cretNo.ToString()
  1012. , this.consentMain.ConsentExecuteInfo["dutinstcd"]
  1013. , this.consentMain.ConsentExecuteInfo["opRsrvNo"]);
  1014. if(patientVOList == null || patientVOList.Length == 0) {
  1015. return null;
  1016. }
  1017. else {
  1018. return patientVOList[0];
  1019. }
  1020. }
  1021. /// <summary>
  1022. /// 삭제 사유와 함께 전자동의서 삭제
  1023. /// </summary>
  1024. /// <param name="reasonForUseN">삭제할 사유</param>
  1025. private void SaveDataForDeleteConsent(string reasonForUseN) {
  1026. string userId = CurrentEndUser.UserNo;
  1027. string patientCode = CurrentTargetPatient.PatientCode;
  1028. string clnDeptCd = CurrentTargetPatient.clnDeptCode;
  1029. string ward = CurrentTargetPatient.Ward;
  1030. string roomcd = CurrentTargetPatient.RoomNo;
  1031. string formRid = CurrentPreviewConsent.formRid;
  1032. string consentMstRid = CurrentPreviewConsent.consentMstRid;
  1033. string consentState = CurrentPreviewConsent.consentState;
  1034. int rewriteConsentMstRid = CurrentPreviewConsent.RewriteConsentMstRid;
  1035. ConvertStringToInt(formRid, consentMstRid, out int formRidInt, out int consentMstRidInt);
  1036. int.TryParse(CurrentTargetPatient.cretno, out int cretno);
  1037. int reissueConsentMstRidInt = CurrentPreviewConsent.ReissueConsentMstRid;
  1038. string deviceIdentNo = System.Environment.MachineName;
  1039. this.consentWebService.SaveDelete(userId, Int32.Parse(consentMstRid), patientCode, clnDeptCd, CurrentPreviewConsent.formCd, CurrentTargetPatient.VisitType,
  1040. consentMain.ConsentExecuteInfo["dutinstcd"], CurrentTargetPatient.clnDate, reasonForUseN, CurrentPreviewConsent.ocrCode,
  1041. cretno, currentEndUser.DeptCode, consentMain.GetTotalPageCount().ToString(), "CP", "PC");
  1042. //this.consentWebService.SaveDelete(userId
  1043. // , consentMstRidInt
  1044. // , patientCode
  1045. // , clnDeptCd
  1046. // , ward
  1047. // , roomcd
  1048. // , formRidInt
  1049. // , CurrentPreviewConsent.FormCd
  1050. // , rewriteConsentMstRid
  1051. // , reissueConsentMstRidInt
  1052. // , consentState
  1053. // , deviceIdentNo
  1054. // , CurrentTargetPatient.VisitType
  1055. // , consentMain.ConsentExecuteInfo["dutinstcd"]
  1056. // , CurrentTargetPatient.clnDate
  1057. // , reasonForUseN
  1058. // , CurrentPreviewConsent.Ocrcode
  1059. // , cretno
  1060. // , currentEndUser.DeptCode
  1061. // , consentMain.GetTotalPageCount().ToString()
  1062. // , "CP"
  1063. // , "P");
  1064. }
  1065. private void SetHasMedicalHistoryInConsent(string patientCode) {
  1066. this.CurrentPreviewConsent.hasMedicalHistory = false;
  1067. }
  1068. /// <summary>
  1069. /// 동의서 뷰어에 동의서 로드
  1070. /// </summary>
  1071. public void RunConsentDualView() {
  1072. bool runDualView = true;
  1073. if(this.CurrentEndUser != null && this.CurrentPreviewConsent != null
  1074. && !string.IsNullOrEmpty(this.CurrentPreviewConsent.printOnly)
  1075. && this.CurrentPreviewConsent.printOnly.Equals("Y")
  1076. ) {
  1077. runDualView = false;
  1078. }
  1079. // 출력 상태일 경우 재출력만 가능하도록 버튼 조정
  1080. if(this.CurrentEndUser != null && this.CurrentPreviewConsent != null
  1081. && !string.IsNullOrEmpty(this.CurrentPreviewConsent.consentState)
  1082. && (this.CurrentPreviewConsent.consentState.ToUpper().Equals("PAPER_OUT"))) {
  1083. runDualView = false;
  1084. }
  1085. if(CurrentPreviewConsent == null) {
  1086. return;
  1087. }
  1088. // 동의서 로드 전 consent_mst_rid에 해당하는 동의서가 상위 상태값이 있는지 체크
  1089. SingleReturnData resultData = this.consentWebService.CheckConsentState(int.Parse(this.CurrentPreviewConsent.consentMstRid),
  1090. this.CurrentPreviewConsent.consentState);
  1091. int state = Int32.Parse(resultData.responseData);
  1092. if(state == 1) {
  1093. return;
  1094. }
  1095. // 출력만 가능하거나 출력상태일 경우 듀얼뷰어 실행 못하도록 적용
  1096. if(runDualView) this.consentMain.RunConsentDualView();
  1097. }
  1098. /// <summary>
  1099. /// 인증저장 된 동의서를 보여준다
  1100. /// </summary>
  1101. /// <param name="consentMain">The consent main.</param>
  1102. public void ShowCompleteConsent(IConsentMain consentMain) {
  1103. //SetEnableButtonsByCurrentConsent();
  1104. consentMain.ReviewConsent();
  1105. ConsentImageVO[] cImage = this.consentWebService.GetConsentImage(this.CurrentPreviewConsent.consentMstRid);
  1106. if(cImage != null && cImage.Length > 0) {
  1107. CLIP.eForm.ImageView.ImageViewCtrl iViewer = consentMain.GetImageViewerCtrl();
  1108. List<string> lStr = new List<string>();
  1109. string sPath = this.consentMain.PluginExecuteInfo["imageUploadPath"] + "/DataTempImage/";
  1110. string sLocal = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\Clipsoft\ClipSoft.eForm.Viewer\DataTemp\";
  1111. DirectoryInfo di = new DirectoryInfo(sLocal);
  1112. if(di.Exists == false) {
  1113. di.Create();
  1114. }
  1115. foreach(ConsentImageVO img in cImage) {
  1116. if(File.Exists(sLocal + img.ImageFilename)) {
  1117. Image imgTemp = Image.FromFile(sLocal + img.ImageFilename);
  1118. lStr.Add(ImageToBase64(imgTemp, System.Drawing.Imaging.ImageFormat.Jpeg));
  1119. imgTemp.Dispose();
  1120. }
  1121. else {
  1122. string orgFile = img.ImagePath + "\\" + img.ImageFilename;
  1123. string tempImgNm = orgFile.Substring(orgFile.IndexOf("\\") + 1).Replace("\\", "");
  1124. using(WebClient myWebClient = new WebClient()) {
  1125. myWebClient.DownloadFile(sPath + img.ImageFilename, sLocal + img.ImageFilename);
  1126. if(File.Exists(sLocal + img.ImageFilename)) {
  1127. Image imgTemp = Image.FromFile(sLocal + img.ImageFilename);
  1128. lStr.Add(ImageToBase64(imgTemp, System.Drawing.Imaging.ImageFormat.Jpeg));
  1129. imgTemp.Dispose();
  1130. }
  1131. else {
  1132. break;
  1133. }
  1134. }
  1135. }
  1136. }
  1137. if(lStr.Count > 0)
  1138. iViewer.Show();
  1139. iViewer.SetBase64Images(lStr);
  1140. }
  1141. else {
  1142. // 검색된 이미지가 없습니다.
  1143. }
  1144. }
  1145. /// <summary>
  1146. /// 이미지를 BASE64 로 인코딩
  1147. /// </summary>
  1148. /// <param name="image">변환할 이미지</param>
  1149. /// <param name="format">저장할 이미지 포멧</param>
  1150. /// <returns></returns>
  1151. public string ImageToBase64(Image image, System.Drawing.Imaging.ImageFormat format) {
  1152. using(MemoryStream ms = new MemoryStream()) {
  1153. // Convert Image to byte[]
  1154. image.Save(ms, format);
  1155. byte[] imageBytes = ms.ToArray();
  1156. // Convert byte[] to Base64 String
  1157. string base64String = Convert.ToBase64String(imageBytes);
  1158. return base64String;
  1159. }
  1160. }
  1161. /// <summary>
  1162. /// 동의서 미리 보기
  1163. /// </summary>
  1164. /// <param name="consentMain">미리보기할 동의서가 있는 인스턴스</param>
  1165. public void PreviewConsent(IConsentMain consentMain) {
  1166. // 근무지기관별 공통파라미터를 설정
  1167. Dictionary<FOSParameter, string> globalParams = Common.CreateGlobalParamsDictionary(consentMain.ConsentExecuteInfo["dutinstcd"]);
  1168. SetPatientAndUser(globalParams);
  1169. globalParams[FOSParameter.OCRCode] = string.Empty;
  1170. var ocrBuf = GetOcrCode();
  1171. if(string.IsNullOrEmpty(ocrBuf)) {
  1172. MessageBox.Show("OCR 중복입니다. 다시 환자를 선택하여 주세요.");
  1173. return;
  1174. }
  1175. globalParams[FOSParameter.OCRCode] = CurrentPreviewConsent.ocrCode = ocrBuf;
  1176. globalParams[FOSParameter.OCRCode] = CurrentPreviewConsent.ocrCode = GetOcrCode(); // OCR 코드
  1177. if(string.IsNullOrEmpty(CurrentPreviewConsent.ocrCode)) {
  1178. MessageBox.Show("OCRTAG 생성 오류. 전산실에 문의 하세요.");
  1179. consentMain.ClearPreviewConsent(true);
  1180. return;
  1181. }
  1182. globalParams[FOSParameter.Device] = "C";
  1183. globalParams[FOSParameter.PrintTime] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  1184. globalParams[FOSParameter.SignTime] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  1185. globalParams[FOSParameter.PrintIp] = consentMain.ConsentExecuteInfo["printIP"];
  1186. List<string> formGuids = new List<string> {
  1187. CurrentPreviewConsent.formGuid
  1188. };
  1189. string fos = Common.GetFosString(formGuids
  1190. , consentMain.PluginExecuteInfo["formServiceUrl"]
  1191. , globalParams
  1192. , null
  1193. , consentMain.ConsentExecuteInfo["dutinstcd"]);
  1194. SingleReturnData returnData = this.consentWebService.CheckConsentState(int.Parse(CurrentPreviewConsent.consentMstRid), CurrentPreviewConsent.consentState);
  1195. int state = Int32.Parse(returnData.responseData);
  1196. if(state == 1) {
  1197. MessageBoxDlg.Show(this, "이미 저장된 서식 입니다."
  1198. , string.Format(Properties.Resources.msg_caption_confirm),
  1199. MessageBoxButtons.OK, MessageBoxIcon.Information);
  1200. return;
  1201. }
  1202. consentMain.PreviewConsent(fos);//서식을 열도록 fos을 던짐
  1203. // 외래 환자 외에는 작성 완료(확인) 버튼 안보이게 설정
  1204. /*
  1205. if(CurrentTargetPatient.VisitType.Equals("O") && CurrentPreviewConsent.userDrFlag.Equals("Y")) {
  1206. toolStripButtonCompleteSaveToServer.Visible = true;
  1207. }
  1208. else {
  1209. toolStripButtonCompleteSaveToServer.Visible = false;
  1210. }
  1211. */
  1212. consentMain.ConsentCommandCtrl.SetEnableButtonsByCurrentConsent();
  1213. SetEnableByUserType();
  1214. }
  1215. /// <summary>
  1216. /// 현재 동의서의 OCR 코드를 가져온다. OCR 코드가 존재하지 않으면 서버로부터 얻어온다
  1217. /// </summary>
  1218. /// <returns>OCR 코드</returns>
  1219. public string GetOcrCode() {
  1220. string strOcrCode = "";
  1221. if(this.CurrentPreviewConsent.ocrtagPrntyn.Equals("N")) {
  1222. strOcrCode = " ";
  1223. }
  1224. else {
  1225. if(this.CurrentPreviewConsent != null
  1226. && !string.IsNullOrEmpty(this.CurrentPreviewConsent.ocrCode)) {
  1227. strOcrCode = this.CurrentPreviewConsent.ocrCode;
  1228. }
  1229. // OCR 코드가 없으면 서버로 부터 받아온다
  1230. // TODO 삭제
  1231. else {
  1232. if(this.CurrentPreviewConsent != null
  1233. && !string.IsNullOrEmpty(this.CurrentPreviewConsent.ocrtagPrntyn)
  1234. && this.CurrentPreviewConsent.ocrtagPrntyn.Equals("Y")) {
  1235. HospitalSvcRef.SingleReturnData returnData = hospitalWebService.GetOcrTag(this.consentMain.ConsentExecuteInfo["dutinstcd"]);
  1236. if(string.IsNullOrEmpty(returnData.responseData)){
  1237. throw new Exception("OCRTAG 생성 오류. 전산실에 문의 하세요.");
  1238. }
  1239. strOcrCode = returnData.responseData;
  1240. }
  1241. }
  1242. if(string.IsNullOrEmpty(strOcrCode)) {
  1243. throw new Exception("OCRTAG 생성 오류. 전산실에 문의 하세요.");
  1244. }
  1245. }
  1246. return strOcrCode;
  1247. }
  1248. /// <summary>
  1249. /// changingGlobalParams Dataset 에 FOS 파라미터의 name 과 value 를 설정한다
  1250. /// </summary>
  1251. /// <param name="globalParams"></param>
  1252. public void SetPatientAndUser(Dictionary<FOSParameter, string> globalParams) {
  1253. Dictionary<FOSParameter, string> changingGlobalParams = new Dictionary<FOSParameter, string>();
  1254. if(CurrentPreviewConsent == null) {
  1255. MessageBox.Show("동의서 정보가 없습니다.");
  1256. throw new Exception("동의서 정보가 없습니다.");
  1257. }
  1258. if(CurrentTargetPatient == null || string.IsNullOrEmpty(this.CurrentTargetPatient.PatientCode)) {
  1259. MessageBox.Show("환자 정보가 없습니다.");
  1260. throw new Exception("환자 정보가 없습니다.");
  1261. }
  1262. if(CurrentEndUser == null) {
  1263. MessageBox.Show("사용자 정보가 없습니다.");
  1264. throw new Exception("사용자 정보가 없습니다.");
  1265. }
  1266. // 동의서 정보
  1267. changingGlobalParams[FOSParameter.FormName] = this.CurrentPreviewConsent.formPrintName;
  1268. // 환자 정보
  1269. changingGlobalParams[FOSParameter.ImageUploadPath] = this.consentMain.PluginExecuteInfo["imageUploadPath"] + "/";
  1270. changingGlobalParams[FOSParameter.PatientCode] = this.CurrentTargetPatient.PatientCode;
  1271. changingGlobalParams[FOSParameter.PatientSexAge] = this.CurrentTargetPatient.PatientSexAge;
  1272. changingGlobalParams[FOSParameter.PatientName] = this.CurrentTargetPatient.PatientName;
  1273. changingGlobalParams[FOSParameter.PatientNameFix] = this.CurrentTargetPatient.PatientName;
  1274. changingGlobalParams[FOSParameter.PatientRRN] = this.CurrentTargetPatient.PatientJuminNo;
  1275. changingGlobalParams[FOSParameter.PatientRRNOrg] = this.CurrentTargetPatient.PatientJuminNoOrg;
  1276. changingGlobalParams[FOSParameter.RoomNo] = this.CurrentTargetPatient.Ward + "/" + this.CurrentTargetPatient.RoomNo;
  1277. changingGlobalParams[FOSParameter.VisitDate] = SetDateFormatting(this.CurrentTargetPatient.clnDate.Replace("-", ""));
  1278. changingGlobalParams[FOSParameter.DeptName] = this.CurrentTargetPatient.clnDeptName;
  1279. changingGlobalParams[FOSParameter.MainDoctor] = this.CurrentTargetPatient.MainDrNm;
  1280. changingGlobalParams[FOSParameter.PatientAddress] = this.CurrentTargetPatient.PatientAddr;
  1281. changingGlobalParams[FOSParameter.PatientTelNo] = this.CurrentTargetPatient.PatientTelNo;
  1282. changingGlobalParams[FOSParameter.PatientTelNoFix] = this.CurrentTargetPatient.PatientTelNo;
  1283. changingGlobalParams[FOSParameter.Insukind] = this.CurrentTargetPatient.Insukind;
  1284. changingGlobalParams[FOSParameter.DeptCode] = this.CurrentTargetPatient.clnDeptCode;
  1285. changingGlobalParams[FOSParameter.DiagName] = this.CurrentTargetPatient.OpDiagName;
  1286. changingGlobalParams[FOSParameter.OpRsrvNo] = this.CurrentTargetPatient.OpRsrvNo;
  1287. changingGlobalParams[FOSParameter.OperationName] = this.CurrentTargetPatient.OpName;
  1288. changingGlobalParams[FOSParameter.OpDoctorName] = this.CurrentTargetPatient.PerfDrName;
  1289. changingGlobalParams[FOSParameter.OpDeptName] = (this.CurrentTargetPatient.PerfDrFlag + "").Equals("전문의") ? this.CurrentTargetPatient.PerfDrDept ?? "" : "";
  1290. changingGlobalParams[FOSParameter.OpCommDeptName] = !(this.CurrentTargetPatient.PerfDrFlag + "").Equals("전문의") ? this.CurrentTargetPatient.PerfDrDept ?? "" : "";
  1291. changingGlobalParams[FOSParameter.AnstDrName1] = this.CurrentTargetPatient.AnstDrName1;
  1292. changingGlobalParams[FOSParameter.AnstDeptName1] = (this.CurrentTargetPatient.AnstDrFlag1 + "").Equals("전문의") ? this.CurrentTargetPatient.AnstDeptName1 ?? "" : "";
  1293. changingGlobalParams[FOSParameter.AnstCommDeptName1] = !(this.CurrentTargetPatient.AnstDrFlag1 + "").Equals("전문의") ? this.CurrentTargetPatient.AnstDeptName1 ?? "" : "";
  1294. changingGlobalParams[FOSParameter.AnstDrName2] = this.CurrentTargetPatient.AnstDrName2;
  1295. changingGlobalParams[FOSParameter.AnstDeptName2] = (this.CurrentTargetPatient.AnstDrFlag2 + "").Equals("전문의") ? this.CurrentTargetPatient.AnstDeptName2 ?? "" : "";
  1296. changingGlobalParams[FOSParameter.AnstCommDeptName3] = !(this.CurrentTargetPatient.AnstDrFlag2 + "").Equals("전문의") ? this.CurrentTargetPatient.AnstDeptName2 ?? "" : "";
  1297. changingGlobalParams[FOSParameter.AnstDrName3] = this.CurrentTargetPatient.AnstDrName3;
  1298. changingGlobalParams[FOSParameter.AnstDeptName3] = (this.CurrentTargetPatient.AnstDrFlag3 + "").Equals("전문의") ? this.CurrentTargetPatient.AnstDeptName3 ?? "" : "";
  1299. changingGlobalParams[FOSParameter.AnstCommDeptName3] = !(this.CurrentTargetPatient.AnstDrFlag3 + "").Equals("전문의") ? this.CurrentTargetPatient.AnstDeptName3 ?? "" : "";
  1300. if(!string.IsNullOrEmpty(this.CurrentTargetPatient.PatientJuminNo) && this.CurrentTargetPatient.PatientJuminNo.Length > 6) {
  1301. changingGlobalParams[FOSParameter.PatientBirthDay] = this.CurrentTargetPatient.PatientJuminNo.Substring(0, 6);
  1302. changingGlobalParams[FOSParameter.PatientBirthDayFix] = this.CurrentTargetPatient.PatientJuminNo.Substring(0, 6);
  1303. }
  1304. if(string.IsNullOrEmpty(changingGlobalParams[FOSParameter.DiagName])) {
  1305. changingGlobalParams[FOSParameter.DiagName] = this.CurrentPreviewConsent.opDiagName;
  1306. }
  1307. if(string.IsNullOrEmpty(changingGlobalParams[FOSParameter.DiagName])) {
  1308. changingGlobalParams[FOSParameter.DiagName] = this.CurrentTargetPatient.clnDxNm;
  1309. }
  1310. if(string.IsNullOrEmpty(changingGlobalParams[FOSParameter.DiagName])) {
  1311. if(!string.IsNullOrEmpty(consentMain.ConsentExecuteInfo["clnDxNm"])) {
  1312. changingGlobalParams[FOSParameter.DiagName] = consentMain.ConsentExecuteInfo["clnDxNm"];
  1313. }
  1314. }
  1315. if(string.IsNullOrEmpty(changingGlobalParams[FOSParameter.OperationName])) {
  1316. changingGlobalParams[FOSParameter.OperationName] = this.CurrentPreviewConsent.opName;
  1317. }
  1318. // 설명일 (수술 확정일)
  1319. var opDate = this.CurrentTargetPatient.OpCnfmDate;
  1320. var targetDate = new DateTime();
  1321. if(opDate != null && opDate.Length > 0) {
  1322. targetDate = DateTime.ParseExact(opDate, "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture);
  1323. changingGlobalParams[FOSParameter.SignDate] = targetDate.ToLongDateString();
  1324. }
  1325. else {
  1326. //changingGlobalParams[FOSParameter.SignDate] = this.CurrentTargetPatient.OpCnfmDate;
  1327. }
  1328. changingGlobalParams[FOSParameter.BP] = this.CurrentTargetPatient.Ex_bp;
  1329. changingGlobalParams[FOSParameter.DM] = this.CurrentTargetPatient.Ex_dm;
  1330. changingGlobalParams[FOSParameter.Heart] = this.CurrentTargetPatient.Ex_heart;
  1331. changingGlobalParams[FOSParameter.Kidney] = this.CurrentTargetPatient.Ex_kidney;
  1332. changingGlobalParams[FOSParameter.Respiration] = this.CurrentTargetPatient.Ex_respiration;
  1333. changingGlobalParams[FOSParameter.MedicalHistory] = this.CurrentTargetPatient.Ex_hx;
  1334. changingGlobalParams[FOSParameter.Allergy] = this.CurrentTargetPatient.Ex_allergy;
  1335. changingGlobalParams[FOSParameter.Drug] = this.CurrentTargetPatient.Ex_drug;
  1336. changingGlobalParams[FOSParameter.Smoking] = this.CurrentTargetPatient.Ex_smoking;
  1337. changingGlobalParams[FOSParameter.Idiosyncrasy] = this.CurrentTargetPatient.Ex_idio;
  1338. changingGlobalParams[FOSParameter.Nacrotics] = this.CurrentTargetPatient.Ex_nacrotics;
  1339. changingGlobalParams[FOSParameter.Airway] = this.CurrentTargetPatient.Ex_airway;
  1340. changingGlobalParams[FOSParameter.Hemorrhage] = this.CurrentTargetPatient.Ex_hemorrhage;
  1341. changingGlobalParams[FOSParameter.EtcStatus] = this.CurrentTargetPatient.Ex_status_etc;
  1342. // 외래일 경우 emr.mmbdhrcd.hardcdno = 6920 에 지정된 서식외에는 사용자를 진료의로 변경한다.
  1343. if(CurrentTargetPatient.VisitType.Equals("O") && CurrentPreviewConsent.userDrFlag.Equals("Y") && !CurrentEndUser.JobKindCd.Substring(0, 2).Equals("03")) {
  1344. //consentMain.SetConsentUserInfo(consentMain.ConsentExecuteInfo["dutinstcd"]
  1345. // , CurrentTargetPatient.MainDrId
  1346. // , currentTargetPatient.clnDeptCode); // 외래 진료의는 근무 부서 이외의 과의 처방을 낼 수 없다.
  1347. consentMain.SetConsentUserInfo(consentMain.ConsentExecuteInfo["dutinstcd"]
  1348. , CurrentTargetPatient.MainDrId
  1349. , currentTargetPatient.clnDeptCode, ""); // 외래 진료의는 근무 부서 이외의 과의 처방을 낼 수 없다.
  1350. }
  1351. else if(!CurrentEndUser.UserNo.Equals(consentMain.ConsentExecuteInfo["loginUserNo"])) {
  1352. // 로그인 사용자와 다른 경우 재조회
  1353. consentMain.SetConsentUserInfo(consentMain.ConsentExecuteInfo["dutinstcd"]
  1354. , consentMain.ConsentExecuteInfo["loginUserNo"]
  1355. , consentMain.ConsentExecuteInfo["userDeptCd"]);
  1356. }
  1357. string jobKindCd = !string.IsNullOrEmpty(currentEndUser.JobKindCd) ? currentEndUser.JobKindCd.Substring(0, 2) : "00";
  1358. changingGlobalParams[FOSParameter.UserName] = this.CurrentEndUser.UserName;
  1359. changingGlobalParams[FOSParameter.UserTelNo] = this.CurrentEndUser.UserTelNo;
  1360. changingGlobalParams[FOSParameter.ExplDrName] = jobKindCd.Substring(0, 2).Equals("03") ? CurrentEndUser.UserName : string.Empty;
  1361. changingGlobalParams[FOSParameter.ExplDrTelNo] = jobKindCd.Substring(0, 2).Equals("03") ? CurrentEndUser.UserTelNo : string.Empty;
  1362. // 사용자의 서명 이미지를 가져온다
  1363. UserSignImageVO vo = this.hospitalWebService.GetSignImage(this.CurrentEndUser.UserNo, this.consentMain.ConsentExecuteInfo["dutinstcd"]);
  1364. if(vo != null && vo.SignImage != null && vo.SignImage.Length > 0) {
  1365. // 서명 이미지를 BASE64 형식으로 변환한다.
  1366. changingGlobalParams[FOSParameter.SignImage] = ImageToBase64(byteArrayToImage(vo.SignImage), System.Drawing.Imaging.ImageFormat.Png);
  1367. // 의사의 경우라면 설명의사에 서명이미지를 설정한다
  1368. changingGlobalParams[FOSParameter.ExplDrSign] = jobKindCd.Substring(0, 2).Equals("03") ? changingGlobalParams[FOSParameter.SignImage] : string.Empty;
  1369. changingGlobalParams[FOSParameter.ExplDrSign_p] = changingGlobalParams[FOSParameter.ExplDrSign];
  1370. }
  1371. changingGlobalParams[FOSParameter.ExplDrName_P] = CurrentEndUser.UserName;
  1372. changingGlobalParams[FOSParameter.ExplDrTelNo_p] = CurrentEndUser.UserTelNo;
  1373. // 출력할 경우 설명 의사와 서명 이미지는 공백 처리
  1374. if (consentMain.ConsentExecuteInfo["printYN"].Equals("Y")) {
  1375. changingGlobalParams[FOSParameter.ExplDrName] = string.Empty;
  1376. changingGlobalParams[FOSParameter.ExplDrTelNo] = string.Empty;
  1377. changingGlobalParams[FOSParameter.ExplDrSign] = string.Empty;
  1378. changingGlobalParams[FOSParameter.PatientName] = string.Empty;
  1379. changingGlobalParams[FOSParameter.PatientBirthDay] = string.Empty;
  1380. changingGlobalParams[FOSParameter.PatientTelNo] = string.Empty;
  1381. // 보호자상주확인서 프린터 출력시 제외 항목
  1382. //changingGlobalParams[FOSParameter.UserName] = string.Empty;
  1383. //changingGlobalParams[FOSParameter.SignImage] = string.Empty;
  1384. }
  1385. // 원무 파라미터 설정
  1386. changingGlobalParams[FOSParameter.SpecDoctorYN] = consentMain.ConsentExecuteInfo["SpecDoctorYN"];
  1387. changingGlobalParams[FOSParameter.ContStartDate] = consentMain.ConsentExecuteInfo["ContStartDate"];
  1388. changingGlobalParams[FOSParameter.ContEndDate] = consentMain.ConsentExecuteInfo["ContEndDate"];
  1389. changingGlobalParams[FOSParameter.RoomCapa] = consentMain.ConsentExecuteInfo["RoomCapa"];
  1390. changingGlobalParams[FOSParameter.ContTelNo] = consentMain.ConsentExecuteInfo["ContTelNo"];
  1391. changingGlobalParams[FOSParameter.ContStaff1Name] = consentMain.ConsentExecuteInfo["ContStaff1Name"];
  1392. changingGlobalParams[FOSParameter.ContStaff2Name] = consentMain.ConsentExecuteInfo["ContStaff2Name"];
  1393. changingGlobalParams[FOSParameter.ContStaff3Name] = consentMain.ConsentExecuteInfo["ContStaff3Name"];
  1394. changingGlobalParams[FOSParameter.CardNo] = consentMain.ConsentExecuteInfo["CardNo"];
  1395. // 경대병원 파리미터 추가
  1396. changingGlobalParams[FOSParameter.tag1] = consentMain.ConsentExecuteInfo["tag1"];
  1397. changingGlobalParams[FOSParameter.tag2] = consentMain.ConsentExecuteInfo["tag2"];
  1398. changingGlobalParams[FOSParameter.tag3] = consentMain.ConsentExecuteInfo["tag3"];
  1399. changingGlobalParams[FOSParameter.tag4] = consentMain.ConsentExecuteInfo["tag4"];
  1400. changingGlobalParams[FOSParameter.tag5] = consentMain.ConsentExecuteInfo["tag5"];
  1401. changingGlobalParams[FOSParameter.tag6] = consentMain.ConsentExecuteInfo["tag6"];
  1402. changingGlobalParams[FOSParameter.tag7] = consentMain.ConsentExecuteInfo["tag7"];
  1403. changingGlobalParams[FOSParameter.tag8] = consentMain.ConsentExecuteInfo["tag8"];
  1404. changingGlobalParams[FOSParameter.tag9] = consentMain.ConsentExecuteInfo["tag9"];
  1405. changingGlobalParams[FOSParameter.tag10] = consentMain.ConsentExecuteInfo["tag10"];
  1406. // 한번 사용한 후 해당 설정은 초기화
  1407. consentMain.ConsentExecuteInfo["tag1"] = string.Empty;
  1408. consentMain.ConsentExecuteInfo["tag2"] = string.Empty;
  1409. consentMain.ConsentExecuteInfo["tag3"] = string.Empty;
  1410. consentMain.ConsentExecuteInfo["tag4"] = string.Empty;
  1411. consentMain.ConsentExecuteInfo["tag5"] = string.Empty;
  1412. consentMain.ConsentExecuteInfo["tag6"] = string.Empty;
  1413. consentMain.ConsentExecuteInfo["tag7"] = string.Empty;
  1414. consentMain.ConsentExecuteInfo["tag8"] = string.Empty;
  1415. consentMain.ConsentExecuteInfo["tag9"] = string.Empty;
  1416. consentMain.ConsentExecuteInfo["tag10"] = string.Empty;
  1417. ChangeGlobalParametersToNew(globalParams, changingGlobalParams);
  1418. }
  1419. /// <summary>
  1420. /// 임시저장 동의서를 보여준다
  1421. /// </summary>
  1422. /// <param name="consentMain"></param>
  1423. public void ShowTempSaveConsent(IConsentMain consentMain) {
  1424. if(string.IsNullOrEmpty(this.CurrentPreviewConsent.consentMstRid)
  1425. || this.CurrentPreviewConsent.consentMstRid.Equals("-1")) {
  1426. return;
  1427. }
  1428. List<string> formGuids = new List<string>();
  1429. formGuids.Add(this.CurrentPreviewConsent.formGuid);
  1430. Dictionary<string, string> actionParams = new Dictionary<string, string> {
  1431. { "rid", this.CurrentPreviewConsent.consentMstRid }//선택한 리스트의 rid, state
  1432. };
  1433. Dictionary<FOSParameter, string> globalParams = new Dictionary<FOSParameter, string>();
  1434. if(!string.IsNullOrEmpty(this.CurrentPreviewConsent.ordType)) {
  1435. if(!this.CurrentPreviewConsent.ordType.Equals("O")) {
  1436. globalParams[FOSParameter.UserName] = consentMain.ConsentExecuteInfo["loginUserName"];
  1437. }
  1438. if(CurrentEndUser.JobKindCd.Contains("03")) {
  1439. globalParams[FOSParameter.ExplDrName] = CurrentEndUser.UserName ?? string.Empty;
  1440. globalParams[FOSParameter.ExplDrTelNo] = CurrentEndUser.UserTelNo ?? string.Empty;
  1441. // 사용자의 서명 이미지를 가져온다
  1442. UserSignImageVO vo = this.hospitalWebService.GetSignImage(this.CurrentEndUser.UserNo, this.consentMain.ConsentExecuteInfo["dutinstcd"]);
  1443. if(vo != null && vo.SignImage != null && vo.SignImage.Length > 0) {
  1444. // 서명 이미지를 BASE64 형식으로 변환한다.
  1445. //globalParams[FOSParameter.SignImage] = ImageToBase64(byteArrayToImage(vo.SignImage), System.Drawing.Imaging.ImageFormat.Png);
  1446. // 의사의 경우라면 설명의사에 서명이미지를 설정한다
  1447. globalParams[FOSParameter.ExplDrSign] = ImageToBase64(byteArrayToImage(vo.SignImage), System.Drawing.Imaging.ImageFormat.Png) ?? string.Empty;
  1448. }
  1449. }
  1450. }
  1451. string fos = Common.GetFosStringForEpt(actionParams, consentMain.PluginExecuteInfo["formServiceUrl"], globalParams, consentMain.ConsentExecuteInfo["dutinstcd"]);
  1452. SingleReturnData returnData = this.consentWebService.CheckConsentState(int.Parse(this.CurrentPreviewConsent.consentMstRid), this.CurrentPreviewConsent.consentState);
  1453. int state = Int32.Parse(returnData.responseData);
  1454. if(state == 1) {
  1455. MessageBoxDlg.Show(this, "이미 저장된 서식 입니다."
  1456. , string.Format(Properties.Resources.msg_caption_confirm),
  1457. MessageBoxButtons.OK, MessageBoxIcon.Information);
  1458. return;
  1459. }
  1460. consentMain.PreviewConsent(fos);
  1461. // 외래 환자 외에는 작성 완료(확인) 버튼 안보이게 설정
  1462. /*
  1463. if(!CurrentTargetPatient.VisitType.Equals("O")) {
  1464. toolStripButtonCompleteSaveToServer.Visible = false;
  1465. }
  1466. else {
  1467. toolStripButtonCompleteSaveToServer.Visible = true;
  1468. }
  1469. */
  1470. consentMain.ConsentCommandCtrl.SetEnableConsentIssueCommands(true);
  1471. consentMain.ConsentCommandCtrl.SetEnableButtonsByCurrentConsent();
  1472. SetEnableByUserType();
  1473. }
  1474. private Image byteArrayToImage(byte[] byteArrayIn) {
  1475. MemoryStream ms = new MemoryStream(byteArrayIn);
  1476. Image returnImage = Image.FromStream(ms);
  1477. return returnImage;
  1478. }
  1479. /// <summary>
  1480. /// 동의서 임시 데이터 저장
  1481. /// </summary>
  1482. /// <param name="eptXmlValue"></param>
  1483. /// <param name="dataValue"></param>
  1484. public override void SaveTempConsentData(string eptXmlValue, string dataValue) {
  1485. //int state = this.consentWebService.CheckConsentState(int.Parse(this.CurrentPreviewConsent.ConsentMstRid), this.CurrentPreviewConsent.ConsentState);
  1486. SingleReturnData returnData = this.consentWebService.CheckConsentState(int.Parse(this.CurrentPreviewConsent.consentMstRid), this.CurrentPreviewConsent.consentState);
  1487. int state = Int32.Parse(returnData.responseData);
  1488. if(state == 1) {
  1489. MessageBoxDlg.Show(this, "이미 저장된 서식 입니다."
  1490. , string.Format(Properties.Resources.msg_caption_confirm),
  1491. MessageBoxButtons.OK, MessageBoxIcon.Information);
  1492. return;
  1493. }
  1494. //string userId = CurrentEndUser.UserNo;
  1495. //string userId = this.consentMain.ConsentExecuteInfo["loginUserNo"];
  1496. //string userName = this.consentMain.ConsentExecuteInfo["loginUserName"];
  1497. string userId = this.consentMain.ConsentExecuteInfo["loginUserNo"];
  1498. string userName = this.consentMain.ConsentExecuteInfo["loginUserName"];
  1499. string deptCd = this.consentMain.ConsentExecuteInfo["userDeptCd"];
  1500. string hosType = this.consentMain.ConsentExecuteInfo["dutinstcd"];
  1501. if (string.IsNullOrEmpty(userName)) {
  1502. UserVO userVo = hospitalWebService.GetUserInfo(userId, hosType, deptCd);
  1503. userName = userVo.userName;
  1504. }
  1505. string patientCode = CurrentTargetPatient.PatientCode;
  1506. string clnDeptCode = CurrentTargetPatient.clnDeptCode;
  1507. string vistType = CurrentTargetPatient.VisitType;
  1508. string clnDate = CurrentTargetPatient.clnDate.Replace("-", "");
  1509. int rewriteConsentMstRid = 0;
  1510. string ward = CurrentTargetPatient.Ward;
  1511. string roomcd = CurrentTargetPatient.RoomNo;
  1512. string formRid = CurrentPreviewConsent.formRid;
  1513. string formCd = CurrentPreviewConsent.formCd;
  1514. string consentMstRid = CurrentPreviewConsent.consentMstRid;
  1515. int orderNo = CurrentTargetPatient.OrderNo;
  1516. string orderCode = CurrentTargetPatient.clnDxCd;
  1517. string orderName = CurrentTargetPatient.clnDxNm;
  1518. string mainDrId = this.CurrentTargetPatient.MainDrId;
  1519. int.TryParse(CurrentTargetPatient.cretno, out int cretno);
  1520. ConvertStringToInt(formRid, consentMstRid, out int formRidInt, out int consentMstRidInt);
  1521. string deviceIdentNo = System.Environment.MachineName;
  1522. Cursor currentCursor = this.Cursor;
  1523. try {
  1524. this.Cursor = Cursors.WaitCursor;
  1525. string ocrCode = CurrentPreviewConsent.ocrCode;
  1526. if(string.IsNullOrEmpty(ocrCode)) {
  1527. ocrCode = CurrentPreviewConsent.ocrCode = GetOcrCode();
  1528. }
  1529. SingleReturnData returnData2 = this.consentWebService.SaveTempData(userId
  1530. , patientCode
  1531. , clnDeptCode
  1532. , formRidInt
  1533. , formCd
  1534. , consentMstRidInt
  1535. , rewriteConsentMstRid
  1536. , eptXmlValue
  1537. , dataValue
  1538. , consentMain.ConsentExecuteInfo["DeviceType"] //"WIN"
  1539. , deviceIdentNo
  1540. , vistType
  1541. , consentMain.ConsentExecuteInfo["dutinstcd"]
  1542. , clnDate
  1543. , ward
  1544. , roomcd
  1545. , orderNo
  1546. , orderName
  1547. , orderCode
  1548. , ocrCode
  1549. , cretno
  1550. , userName
  1551. , userName
  1552. , mainDrId
  1553. , CurrentEndUser.DeptCode
  1554. , consentMain.GetTotalPageCount().ToString()
  1555. , "T"
  1556. , "P" // 임시저장 시 P 상태로 기록, 스캔 매수 입력 하도록 설정
  1557. , CurrentTargetPatient.OpRsrvNo
  1558. // dbs227, 확인 저장 시 일괄저장이 가능하도록 ELECTR_CMP 상태로 바꿈
  1559. , m_IsComplete ? "ELECTR_CMP" : "");
  1560. consentMstRidInt = Int32.Parse(returnData2.responseData);
  1561. // 현재 사용하지 않음
  1562. //기왕력 데이터 저장
  1563. //SetNewMedicalHistory(dataValue);
  1564. // 작성 완료 시
  1565. if(m_IsComplete) {
  1566. MessageBoxDlg.Show(this, string.Format(Properties.Resources.msg_confirm_save_confirm)
  1567. , string.Format(Properties.Resources.msg_caption_confirm),
  1568. MessageBoxButtons.OK, MessageBoxIcon.Information);
  1569. // 작성 완료 시는 이력 탭 보기
  1570. this.consentMain.ConsentListCtrl.InquiryConsentData(0);
  1571. }
  1572. else {
  1573. if (consentMain.multiParams == null)
  1574. {
  1575. this.consentMain.ConsentListCtrl.InquiryConsentData(consentMstRidInt);
  1576. }
  1577. // Ku2.0 연동 시에는 메시지를 띄우지 않는다
  1578. if(consentMain.ConsentExecuteInfo["printYN"].Equals("Y")) {
  1579. MessageBoxDlg.Show(this, string.Format(Properties.Resources.msg_temp_save_confirm)
  1580. , string.Format(Properties.Resources.msg_caption_confirm),
  1581. MessageBoxButtons.OK, MessageBoxIcon.Information);
  1582. }
  1583. }
  1584. }
  1585. catch(Exception ex) {
  1586. throw ex;
  1587. }
  1588. finally {
  1589. this.Cursor = currentCursor;
  1590. }
  1591. }
  1592. /// <summary>
  1593. /// 현재의 문진기록을 저장한다
  1594. /// </summary>
  1595. /// <param name="dataXml">The data XML.</param>
  1596. private void SetNewMedicalHistory(string dataXml) {
  1597. Dictionary<FOSParameter, string> outputDataDic = DataXmlToDictionary(dataXml);
  1598. if(outputDataDic.ContainsKey(FOSParameter.BP)) this.CurrentTargetPatient.Ex_bp = outputDataDic[FOSParameter.BP];
  1599. if(outputDataDic.ContainsKey(FOSParameter.DM)) this.CurrentTargetPatient.Ex_dm = outputDataDic[FOSParameter.DM];
  1600. if(outputDataDic.ContainsKey(FOSParameter.Heart)) this.CurrentTargetPatient.Ex_heart = outputDataDic[FOSParameter.Heart];
  1601. if(outputDataDic.ContainsKey(FOSParameter.Kidney)) this.CurrentTargetPatient.Ex_kidney = outputDataDic[FOSParameter.Kidney];
  1602. if(outputDataDic.ContainsKey(FOSParameter.Respiration)) this.CurrentTargetPatient.Ex_respiration = outputDataDic[FOSParameter.Respiration];
  1603. if(outputDataDic.ContainsKey(FOSParameter.MedicalHistory)) this.CurrentTargetPatient.Ex_hx = outputDataDic[FOSParameter.MedicalHistory];
  1604. if(outputDataDic.ContainsKey(FOSParameter.Allergy)) this.CurrentTargetPatient.Ex_allergy = outputDataDic[FOSParameter.Allergy];
  1605. if(outputDataDic.ContainsKey(FOSParameter.Drug)) this.CurrentTargetPatient.Ex_drug = outputDataDic[FOSParameter.Drug];
  1606. if(outputDataDic.ContainsKey(FOSParameter.Smoking)) this.CurrentTargetPatient.Ex_smoking = outputDataDic[FOSParameter.Smoking];
  1607. if(outputDataDic.ContainsKey(FOSParameter.Idiosyncrasy)) this.CurrentTargetPatient.Ex_idio = outputDataDic[FOSParameter.Idiosyncrasy];
  1608. if(outputDataDic.ContainsKey(FOSParameter.Nacrotics)) this.CurrentTargetPatient.Ex_nacrotics = outputDataDic[FOSParameter.Nacrotics];
  1609. if(outputDataDic.ContainsKey(FOSParameter.Airway)) this.CurrentTargetPatient.Ex_airway = outputDataDic[FOSParameter.Airway];
  1610. if(outputDataDic.ContainsKey(FOSParameter.Hemorrhage)) this.CurrentTargetPatient.Ex_hemorrhage = outputDataDic[FOSParameter.Hemorrhage];
  1611. if(outputDataDic.ContainsKey(FOSParameter.EtcStatus)) this.CurrentTargetPatient.Ex_status_etc = outputDataDic[FOSParameter.EtcStatus];
  1612. }
  1613. /// <summary>
  1614. /// Data XML을 Dictionary 타입으로 변환하여 반환
  1615. /// </summary>
  1616. /// <param name="dataXml">변환될 Data XML</param>
  1617. /// <returns></returns>
  1618. private static Dictionary<FOSParameter, string> DataXmlToDictionary(string dataXml) {
  1619. Dictionary<FOSParameter, string> outputDataDic;
  1620. XmlDocument xmlDocument = new XmlDocument();
  1621. xmlDocument.LoadXml(dataXml);
  1622. outputDataDic = outputDataDic = new Dictionary<FOSParameter, string>();
  1623. XmlNode rootNode = xmlDocument.SelectSingleNode("form-data");
  1624. foreach(XmlNode childNode in rootNode.ChildNodes) {
  1625. string fieldName = string.Empty;
  1626. string fieldValue = string.Empty;
  1627. XmlElement outFieldElement = childNode as XmlElement;
  1628. if(outFieldElement == null) {
  1629. }
  1630. else {
  1631. fieldName = outFieldElement.Name;
  1632. if(fieldName.Equals("state")) {
  1633. foreach(XmlNode childNode2 in childNode.ChildNodes) {
  1634. XmlElement outFieldElement2 = childNode2 as XmlElement;
  1635. FOSParameter fieldName2 = (FOSParameter)Enum.Parse(typeof(FOSParameter), outFieldElement2.Name);
  1636. string fieldValue2 = string.Empty;
  1637. if(outFieldElement2.ChildNodes.Count > 0
  1638. && outFieldElement2.ChildNodes[0] is XmlCDataSection) {
  1639. fieldValue2 = ((XmlCDataSection)outFieldElement2.ChildNodes[0]).InnerText;
  1640. }
  1641. if(outputDataDic.ContainsKey(fieldName2)) {
  1642. outputDataDic[fieldName2] = fieldValue2;
  1643. }
  1644. else {
  1645. outputDataDic.Add(fieldName2, fieldValue2);
  1646. }
  1647. }
  1648. }
  1649. }
  1650. }
  1651. return outputDataDic;
  1652. }
  1653. /// <summary>
  1654. /// 동의서 완료 데이터 저장
  1655. /// </summary>
  1656. /// <param name="eptXmlValue"></param>
  1657. /// <param name="dataValue"></param>
  1658. public override bool SaveCompleteConsentData(string eptXmlValue, string dataValue, out object saveResult) {
  1659. int translateResult = -1;
  1660. string sCertTarget = string.Empty;
  1661. string sCertResult = string.Empty;
  1662. string consentState = "ELECTR_CMP";
  1663. string sizeValue = string.Empty;
  1664. try {
  1665. // 인증저장된 이미지 파일을 서버로 전송
  1666. translateResult = TranslateConsentToImageServer(exportedImageFiles, sCertResult, out string fileSizes);
  1667. sizeValue = fileSizes;
  1668. }
  1669. catch(Exception ex) {
  1670. string exMessage = ex.Message;
  1671. if(ex.InnerException != null) {
  1672. exMessage += Environment.NewLine + ex.InnerException.Message;
  1673. }
  1674. MessageBoxDlg.Show(true, string.Format(exMessage)
  1675. , string.Format("CLIP e-Form Consent-" + Properties.Resources.msg_caption_fail),
  1676. MessageBoxButtons.OK, MessageBoxIcon.Error);
  1677. saveResult = translateResult;
  1678. return false;
  1679. }
  1680. // TODO 원무 인증 저장 pass
  1681. // 원무 인증저장일 경우 인증 저장 pass
  1682. if(this.consentWebService.getCertUseYn(this.currentPreviewConsent.formCd,
  1683. consentMain.ConsentExecuteInfo["dutinstcd"]) == "Y")
  1684. //if (false)
  1685. {
  1686. consentState = "CERTIFY_CMP";
  1687. }
  1688. else if(this.m_IsComplete) {
  1689. // 인증저장 시 공인인증 처리 하지 않는다.
  1690. }
  1691. // 원무 인증저장이 아닐경우 기존루틴
  1692. else {
  1693. SignatureConfig sign = new SignatureConfig();
  1694. try {
  1695. // 공인인증 처리용
  1696. sCertTarget = sign.getSHA256ImageHash(exportedImageFiles, string.Empty);
  1697. // 공인인증 처리
  1698. sCertResult = ConsentImageSignature(sCertTarget, CurrentEndUser.UserNo, CurrentEndUser.UserName);
  1699. if(sCertResult == "-10") {
  1700. // "로그인 사용자 정보를 통하여 공인인증서 정보가 정상적으로 조회되지 않았습니다."
  1701. MessageBoxDlg.Show(true, Properties.Resources.msg_sign_user_info_fail
  1702. , string.Format("CLIP e-Form Consent-" + Properties.Resources.msg_caption_fail),
  1703. MessageBoxButtons.OK, MessageBoxIcon.Error);
  1704. saveResult = "-99";
  1705. return true;
  1706. }
  1707. else if(sCertResult == "-20") {
  1708. // "공인인증 서버 접속에 실패하였을 하였습니다."
  1709. MessageBoxDlg.Show(true, Properties.Resources.msg_sign_server_connection_fail
  1710. , string.Format("CLIP e-Form Consent-" + Properties.Resources.msg_caption_fail),
  1711. MessageBoxButtons.OK, MessageBoxIcon.Error);
  1712. saveResult = "-99";
  1713. return true;
  1714. }
  1715. else if(sCertResult == "-30") {
  1716. // "공인인증 서버 접속에 실패하였을 하였습니다."
  1717. MessageBoxDlg.Show(true, Properties.Resources.msg_sign_server_connection_fail
  1718. , string.Format("CLIP e-Form Consent-" + Properties.Resources.msg_caption_fail),
  1719. MessageBoxButtons.OK, MessageBoxIcon.Error);
  1720. saveResult = "-99";
  1721. return true;
  1722. }
  1723. else if(sCertResult == "-35") {
  1724. // 공인인증 비밀번호 입력하지 않고 닫음
  1725. saveResult = "-99";
  1726. return true;
  1727. }
  1728. else if(sCertResult == "-40") {
  1729. // "공인인증서 비밀번호가 틀렸습니다.
  1730. MessageBoxDlg.Show(true, Properties.Resources.msg_sign_password_fail
  1731. , string.Format("CLIP e-Form Consent-" + Properties.Resources.msg_caption_fail),
  1732. MessageBoxButtons.OK, MessageBoxIcon.Error);
  1733. saveResult = "-99";
  1734. return true;
  1735. }
  1736. else if(sCertResult == "-50") {
  1737. // "공인인증서명 처리를 실패하였을 하였습니다."
  1738. MessageBoxDlg.Show(true, Properties.Resources.msg_sign_exec_fail
  1739. , string.Format("CLIP e-Form Consent-" + Properties.Resources.msg_caption_fail),
  1740. MessageBoxButtons.OK, MessageBoxIcon.Error);
  1741. saveResult = "-99";
  1742. return true;
  1743. }
  1744. else if(sCertResult == "-99") {
  1745. // "공인인증서명 처리를 실패하였을 하였습니다."
  1746. MessageBoxDlg.Show(true, Properties.Resources.msg_sign_exec_fail
  1747. , string.Format("CLIP e-Form Consent-" + Properties.Resources.msg_caption_fail),
  1748. MessageBoxButtons.OK, MessageBoxIcon.Error);
  1749. saveResult = "-99";
  1750. return true;
  1751. }
  1752. translateResult = 1;
  1753. // 확인저장이 아니라면 인증저장이다
  1754. if(!m_IsComplete) {
  1755. consentState = "CERTIFY_CMP";
  1756. }
  1757. }
  1758. catch(Exception ex) {
  1759. string exMessage = ex.Message;
  1760. if(ex.InnerException != null) {
  1761. exMessage += Environment.NewLine + ex.InnerException.Message;
  1762. }
  1763. MessageBoxDlg.Show(true, string.Format(exMessage)
  1764. , string.Format("CLIP e-Form Consent-" + Properties.Resources.msg_caption_fail),
  1765. MessageBoxButtons.OK, MessageBoxIcon.Error);
  1766. saveResult = translateResult;
  1767. return false;
  1768. }
  1769. // DB 저장용
  1770. sCertTarget = sign.getSHA256ImageHash(exportedImageFiles, "^");
  1771. }
  1772. //string userId = CurrentEndUser.UserNo;
  1773. //string userName = CurrentEndUser.UserName;
  1774. string userId = this.consentMain.ConsentExecuteInfo["loginUserNo"];
  1775. string userName = this.consentMain.ConsentExecuteInfo["loginUserName"];
  1776. string deptCd = this.consentMain.ConsentExecuteInfo["userDeptCd"];
  1777. string hosType = consentMain.ConsentExecuteInfo["dutinstcd"];
  1778. if (string.IsNullOrEmpty(userName)) {
  1779. UserVO userVo = hospitalWebService.GetUserInfo(userId, hosType, deptCd);
  1780. userName = userVo.userName;
  1781. }
  1782. string patientCode = CurrentTargetPatient.PatientCode;
  1783. string clnDeptCode = CurrentTargetPatient.clnDeptCode;
  1784. string vistType = CurrentTargetPatient.VisitType;
  1785. string clnDate = CurrentTargetPatient.clnDate.Replace("-", "").Replace("/", "");
  1786. string ward = CurrentTargetPatient.Ward;
  1787. string roomcd = CurrentTargetPatient.RoomNo;
  1788. string formRid = CurrentPreviewConsent.formRid;
  1789. string formCd = CurrentPreviewConsent.formCd;
  1790. string consentMstRid = CurrentPreviewConsent.consentMstRid;
  1791. int rewriteConsentMstRid = CurrentPreviewConsent.RewriteConsentMstRid;
  1792. int orderNo = CurrentTargetPatient.OrderNo;
  1793. string orderCode = CurrentTargetPatient.clnDxCd;
  1794. string orderName = CurrentTargetPatient.clnDxNm;
  1795. string dschdd = CurrentTargetPatient.Dschdd;
  1796. string mainDrId = this.CurrentTargetPatient.MainDrId;
  1797. string actKind = (consentState.Equals("CERTIFY_CMP") ? "C" : "T");
  1798. //string ocrCode = CurrentPreviewConsent.Ocrcode;
  1799. //if (string.IsNullOrEmpty(ocrCode)) {
  1800. // ocrCode = CurrentPreviewConsent.Ocrcode = GetOcrCode();
  1801. //}
  1802. int.TryParse(CurrentTargetPatient.cretno, out int cretno);
  1803. ConvertStringToInt(formRid, consentMstRid, out int formRidInt, out int consentMstRidInt);
  1804. string deviceIdentNo = System.Environment.MachineName;
  1805. Cursor currentCursor = this.Cursor;
  1806. try {
  1807. this.Cursor = Cursors.WaitCursor;
  1808. string ocrCode = CurrentPreviewConsent.ocrCode;
  1809. if(string.IsNullOrEmpty(ocrCode)) {
  1810. ocrCode = CurrentPreviewConsent.ocrCode = GetOcrCode();
  1811. }
  1812. SingleReturnData returnData = this.consentWebService.SaveCompleteAll(userId
  1813. , patientCode
  1814. , clnDeptCode
  1815. , formRidInt
  1816. , formCd
  1817. , consentMstRidInt
  1818. , rewriteConsentMstRid
  1819. , eptXmlValue
  1820. , dataValue
  1821. , consentMain.ConsentExecuteInfo["DeviceType"] //"WIN"
  1822. , deviceIdentNo
  1823. , vistType
  1824. , consentMain.ConsentExecuteInfo["dutinstcd"] //hosType, hostype 대신 근무지기관코드를 전송한다
  1825. , clnDate
  1826. , ward
  1827. , roomcd
  1828. , orderNo
  1829. , orderName
  1830. , orderCode
  1831. , ocrCode
  1832. , cretno
  1833. , userName
  1834. , userName
  1835. , this.exportedImageFilesJson
  1836. , sCertTarget
  1837. , sCertResult
  1838. , dschdd
  1839. , consentState
  1840. , mainDrId
  1841. , CurrentEndUser.DeptCode
  1842. , consentMain.GetTotalPageCount().ToString()
  1843. , actKind
  1844. , "P"
  1845. , CurrentTargetPatient.OpRsrvNo
  1846. , sizeValue);
  1847. consentMstRidInt = Int32.Parse(returnData.responseData);
  1848. // 기왕력 데이터 저장 sPID
  1849. //SetNewMedicalHistory(dataValue);
  1850. if (consentMain.multiParams == null)
  1851. {
  1852. // 인증 저장 후에는 이력 탭 설정
  1853. this.consentMain.ConsentListCtrl.InquiryConsentData(0);
  1854. }
  1855. // dbs227
  1856. // TODO 인증저장 후 종료 메시지 및 닫기 버튼
  1857. //MessageBoxDlg.Show(this, string.Format(Properties.Resources.msg_esign_N_comp_save_confirm)
  1858. // , string.Format(Properties.Resources.msg_caption_confirm),
  1859. // MessageBoxButtons.OK, MessageBoxIcon.Information);
  1860. // 확인 저장 시 닫기 버튼 활성화 하지 않는다.
  1861. if(!consentState.Equals("ELECTR_CMP")) {
  1862. //연속서식의 경우 모든 서식을 작성할 때 까지 메시지를 띄우지 않는다.
  1863. if (consentMain.multiParams != null)
  1864. {
  1865. int page = 0;
  1866. Dictionary<string, object> pageParam = consentMain.multiParams[consentMain.multiParams.Count - 1];
  1867. if (pageParam.ContainsKey("PAGE_COUNT"))
  1868. {
  1869. page = Int32.TryParse(pageParam["PAGE_COUNT"].ToString(), out int pageNumber) ? pageNumber : -1;
  1870. }
  1871. else
  1872. {
  1873. MessageBox.Show("연속서식 페이지오류", Properties.Resources.msg_caption_fail, MessageBoxButtons.OK, MessageBoxIcon.Error);
  1874. saveResult = "-99";
  1875. return true;
  1876. }
  1877. if ((consentMain.multiParams.Count - 2) == page)
  1878. {
  1879. MessageBox.Show("모든 서식을 저장하였습니다, 확인을 누르면 종료합니다.",
  1880. string.Format(Properties.Resources.msg_caption_confirm),
  1881. MessageBoxButtons.OK, MessageBoxIcon.Information);
  1882. this.consentMain.Parent_Disposed();
  1883. }
  1884. }
  1885. else
  1886. {
  1887. DialogResult dialogResult = MessageBoxDlg.Show(this, string.Format(Properties.Resources.msg_esign_N_comp_save_confirm)
  1888. , string.Format(Properties.Resources.msg_caption_confirm),
  1889. MessageBoxButtons.YesNo, MessageBoxIcon.Information);
  1890. if (dialogResult == DialogResult.Yes)
  1891. {
  1892. if (this.consentMain.ConsentExecuteInfo["printAct"].Equals("Y"))
  1893. {
  1894. this.consentMain.Parent_Disposed();
  1895. }
  1896. else
  1897. {
  1898. this.ParentForm.WindowState = FormWindowState.Minimized;
  1899. }
  1900. }
  1901. }
  1902. }
  1903. if (consentMain.multiParams == null)
  1904. {
  1905. this.consentMain.ReInitializeViewer();
  1906. }
  1907. }
  1908. catch(Exception ex) {
  1909. throw ex;
  1910. }
  1911. finally {
  1912. this.Cursor = currentCursor;
  1913. try {
  1914. if(!string.IsNullOrEmpty(exportedImageFiles)) {
  1915. string[] imgFile = exportedImageFiles.Split('^');
  1916. if(imgFile != null && imgFile.Length > 0) {
  1917. FileInfo fileInfo;
  1918. foreach(string sImgFileName in imgFile) {
  1919. fileInfo = new FileInfo(sImgFileName);
  1920. if(fileInfo != null) {
  1921. // 이미지 파일 삭제
  1922. fileInfo.Delete();
  1923. }
  1924. }
  1925. fileInfo = new FileInfo(imgFile[0].Replace("_0.jpg", ".xml"));
  1926. if(fileInfo != null) {
  1927. // EPT 파일 삭제
  1928. fileInfo.Delete();
  1929. }
  1930. }
  1931. }
  1932. }
  1933. catch(System.IO.IOException e) {
  1934. throw e;
  1935. }
  1936. }
  1937. saveResult = 1;
  1938. return true;
  1939. }
  1940. /// <summary>
  1941. /// 전자서명을 한다
  1942. /// </summary>
  1943. /// <param name="sCertTarget">전자서명 대상</param>
  1944. /// <param name="userId">사용자ID</param>
  1945. /// <param name="userName">사용자 이름</param>
  1946. /// <returns>전자서명의 결과값</returns>
  1947. private string ConsentImageSignature(string sCertTarget, string userId, string userName) {
  1948. string resultValue = string.Empty;
  1949. try {
  1950. if(!string.IsNullOrEmpty(sCertTarget)) {
  1951. // 공인인증 서명
  1952. SignatureConfig sign = new SignatureConfig();
  1953. string rtn = "";
  1954. // 메모리에 본인 공인인증서가 아닐 경우
  1955. string sSignIp = consentMain.PluginExecuteInfo["signatureServerUrl"];
  1956. string sSignPort = consentMain.PluginExecuteInfo["signatureServerPort"];
  1957. int iPort = 0;
  1958. int.TryParse(sSignPort, out iPort);
  1959. // 공인인증 서버 접속
  1960. rtn = sign.SetSignServerInfo(sSignIp, iPort, userId);
  1961. // 공인인증 서명
  1962. resultValue = sign.SignatureExec(sCertTarget, rtn, userName, userId, this.consentMain.saveClickPoint);
  1963. if(string.IsNullOrEmpty(resultValue) || resultValue == "-1") {
  1964. // 공인인증 서명에 실패하였을 경우
  1965. return "-50";
  1966. }
  1967. }
  1968. }
  1969. catch(Exception ex) {
  1970. MessageBoxDlg.Show(true, string.Format(ex.Message)
  1971. , string.Format(Properties.Resources.msg_caption_confirm),
  1972. MessageBoxButtons.OK, MessageBoxIcon.Information);
  1973. resultValue = "-99";
  1974. }
  1975. return resultValue;
  1976. }
  1977. /// <summary>
  1978. /// 서버로 이미지 파일 전송
  1979. /// </summary>
  1980. /// <param name="exportedImageFiles">전송할 이미지 파일</param>
  1981. /// <param name="sCertResult">공인인증 결과</param>
  1982. /// <returns></returns>
  1983. private int TranslateConsentToImageServer(string exportedImageFiles, string sCertResult, out string fileSizes) {
  1984. int resultValue = -1;
  1985. fileSizes = string.Empty;
  1986. if(!string.IsNullOrEmpty(exportedImageFilesJson) && !string.IsNullOrEmpty(exportedImageFiles)) {
  1987. Dictionary<string, object> jsonRoot = null;
  1988. try {
  1989. jsonRoot = fastJSON.JSON.Parse(exportedImageFilesJson) as Dictionary<string, object>;
  1990. if(jsonRoot != null && jsonRoot.Count > 0) {
  1991. string sPath = string.Empty;
  1992. string sFileName = string.Empty;
  1993. string[] sFullPath = exportedImageFiles.Split('^');
  1994. int k = 0;
  1995. foreach(KeyValuePair<string, object> jr in jsonRoot) {
  1996. if(jr.Value != null && !string.IsNullOrEmpty(jr.Value.ToString())) {
  1997. sPath = string.Empty;
  1998. sFileName = string.Empty;
  1999. string[] filepath = jr.Value.ToString().Split('/');
  2000. for(int i = 0; i < filepath.Length; i++) {
  2001. if(i == 0) {
  2002. sPath = filepath[i];
  2003. }
  2004. else if((i + 1) == filepath.Length) {
  2005. sFileName = filepath[i];
  2006. }
  2007. else {
  2008. sPath += "/" + filepath[i];
  2009. }
  2010. }
  2011. //이미지를 서버에 업로드(전자동의서 서버에 저장)
  2012. System.Net.WebClient wcClient = new System.Net.WebClient();
  2013. string imageUploadServerUrl = this.consentMain.PluginExecuteInfo["imageUploadServerUrl"];
  2014. System.Collections.Specialized.NameValueCollection values = new System.Collections.Specialized.NameValueCollection();
  2015. values.Add("up_path", sPath + "/" + sFileName);
  2016. wcClient.QueryString = values;
  2017. var fileInfo = new FileInfo(sFullPath[k]);
  2018. if(k != 0) {
  2019. fileSizes += ",";
  2020. }
  2021. if(fileInfo != null) {
  2022. fileSizes += fileInfo.Length / 1024;
  2023. }
  2024. byte[] response = wcClient.UploadFile(imageUploadServerUrl, "POST", sFullPath[k++]);
  2025. }
  2026. }
  2027. }
  2028. }
  2029. catch(Exception) {
  2030. return resultValue = -99;
  2031. }
  2032. resultValue = 1;
  2033. }
  2034. return resultValue;
  2035. }
  2036. //private int TranslateConsentToImageServer(string exportedImageFiles, int consentMstRidInt, string sCertResult)
  2037. //{
  2038. // int resultValue = -1;
  2039. // if (!string.IsNullOrEmpty(exportedImageFiles))
  2040. // {
  2041. // string[] aryimgFile = exportedImageFiles.Split('^');
  2042. // if (aryimgFile != null && aryimgFile.Length > 0)
  2043. // {
  2044. // try
  2045. // {
  2046. // int consentImageRid_F = 0;
  2047. // string sCertTarget = "";
  2048. // for (int i = 0; i < aryimgFile.Length; i++)
  2049. // {
  2050. // string imgFile = aryimgFile[i];
  2051. // //MessageBox.Show(CurrentTargetPatient.PatientCode + "," + CurrentTargetPatient.VisitType + "," + CurrentTargetPatient.clnDate + "," + "20150815" + "," + CurrentTargetPatient.cretno + "," + "500" + "," + CurrentPreviewConsent.FormCd + "," + i.ToString() + "," + CurrentPreviewConsent.Ocrcode + "," + CurrentEndUser.UserNo);
  2052. // //LCTech 모듈을 위한 DB 작업을 하고 저장할 파일명을 얻는다.
  2053. // string newFileFullName = this.hospitalWebService.GetFileName(CurrentTargetPatient.PatientCode, CurrentTargetPatient.VisitType,
  2054. // CurrentTargetPatient.clnDate.Replace("-", ""), CurrentTargetPatient.Dschdd, CurrentTargetPatient.cretno,
  2055. // "500", CurrentPreviewConsent.FormCd, i.ToString(),
  2056. // CurrentPreviewConsent.Ocrcode, CurrentEndUser.UserNo);
  2057. // //MessageBox.Show(newFileFullName); //O:\fnuImage\201607\19\100501967
  2058. // string uploadFileName = newFileFullName + ".jpg";
  2059. // if (string.IsNullOrEmpty(newFileFullName))
  2060. // {
  2061. // return -10;
  2062. // }
  2063. // //이미지 정보 DB에 저장
  2064. // int consentImageRid = this.consentWebService.SaveImageUploadInfo("ELECTR_CMP", uploadFileName,
  2065. // consentMstRidInt, CurrentEndUser.UserNo, int.Parse(CurrentPreviewConsent.FormRid));
  2066. // /*
  2067. // //저장된 이미지에서 해쉬정보 추출
  2068. // string sCertTarget = GetImageCertification(imgFile);
  2069. // //해쉬정보 DB에 저장
  2070. // this.consentWebService.SaveImageSignInfo("ELECTR_CMP", consentMstRidInt, consentImageRid,
  2071. // CurrentEndUser.UserNo, sCertTarget);
  2072. // */
  2073. // if (i == 0) consentImageRid_F = consentImageRid; //첫번째 consentImageRid 를 저장한다.
  2074. // sCertTarget += GetImageCertification(imgFile) + "^";
  2075. // //이미지를 서버에 업로드(서버에서 나스에 저장)
  2076. // System.Net.WebClient wcClient = new System.Net.WebClient();
  2077. // string imageUploadServerUrl = this.consentMain.PluginExecuteInfo["imageUploadServerUrl"];
  2078. // System.Collections.Specialized.NameValueCollection values = new System.Collections.Specialized.NameValueCollection();
  2079. // values.Add("up_path", uploadFileName);
  2080. // wcClient.QueryString = values;
  2081. // wcClient.UploadFile(imageUploadServerUrl, "POST", imgFile);
  2082. // File.Delete(imgFile);
  2083. // }
  2084. // // 외래일 경우 공인인증 처리가 없음.
  2085. // if (!string.IsNullOrEmpty(CurrentTargetPatient.VisitType) && !CurrentTargetPatient.VisitType.Equals("O"))
  2086. // {
  2087. // sCertTarget = sCertTarget.Substring(0, sCertTarget.Length - 1);
  2088. // this.consentWebService.SaveImageSignInfo("ELECTR_CMP", consentMstRidInt, consentImageRid_F,
  2089. // CurrentEndUser.UserNo, sCertTarget, sCertResult);
  2090. // }
  2091. // resultValue = 1;
  2092. // }
  2093. // catch (Exception err)
  2094. // {
  2095. // resultValue = -99;
  2096. // throw err;
  2097. // }
  2098. // }
  2099. // }
  2100. // return resultValue;
  2101. //}
  2102. /// <summary>
  2103. /// 공인인증 이미지를 가져옴
  2104. /// 사용되는 곳 없음
  2105. /// </summary>
  2106. /// <param name="exportedImageFile">The exported image file.</param>
  2107. /// <returns></returns>
  2108. private string GetImageCertification(string exportedImageFile) {
  2109. try {
  2110. FileStream fileStream = null;
  2111. fileStream = new FileStream(exportedImageFile, FileMode.Open);
  2112. fileStream.Position = 0;
  2113. SHA256 mySHA256 = SHA256Managed.Create();
  2114. byte[] hashValue = mySHA256.ComputeHash(fileStream);
  2115. fileStream.Close();
  2116. return byteArrayToString(hashValue);
  2117. }
  2118. catch(Exception ex) {
  2119. string exMessage = ex.Message;
  2120. if(ex.InnerException != null) {
  2121. exMessage += Environment.NewLine + ex.InnerException.Message;
  2122. }
  2123. return exMessage;
  2124. }
  2125. }
  2126. private string byteArrayToString(byte[] bStr) {
  2127. string hexOutput = string.Empty;
  2128. foreach(char letter in bStr) {
  2129. int value = Convert.ToInt32(letter);
  2130. hexOutput += String.Format("{0:x}", value);
  2131. }
  2132. return hexOutput;
  2133. }
  2134. /// <summary>
  2135. /// 이미지 업로드시 사용될 exportedImageFilesJson 객체에 JSON 스타일로 값을 설정
  2136. /// </summary>
  2137. /// <param name="savedImageFileDescription">저장될 이미지 파일 설명</param>
  2138. public override void WorkExtraWithSavedImageFiles(string savedImageFileDescription) {
  2139. string[] aryImageInfo = savedImageFileDescription.Split(';');
  2140. Dictionary<string, string> dicImageInfo = new Dictionary<string, string>();
  2141. foreach(string imageInfo in aryImageInfo) {
  2142. string[] aryInfo = imageInfo.Split('=');
  2143. if(aryInfo.Length == 2) {
  2144. dicImageInfo.Add(aryInfo[0], aryInfo[1]);
  2145. }
  2146. }
  2147. int baseIndex = -1;
  2148. int.TryParse(dicImageInfo["base-index"], out baseIndex);
  2149. int totalFiles = -1;
  2150. int.TryParse(dicImageInfo["total-files"], out totalFiles);
  2151. if(baseIndex > -1 && totalFiles > 0) {
  2152. this.exportedImageFiles = string.Empty;
  2153. this.exportedImageFilesJson = "{ ";
  2154. string sUploadPath = string.Empty;
  2155. for(int i = baseIndex; i < baseIndex + totalFiles; i++) {
  2156. string exportedImageFile = string.Format("{0}\\{1}_{2}.{3}", dicImageInfo["path"], dicImageInfo["key"], i, dicImageInfo["extention"]);
  2157. exportedImageFiles += exportedImageFile;
  2158. sUploadPath = string.Format("{0}/{1}", DateTime.Now.ToString("yyyyMM"), DateTime.Now.ToString("dd"));
  2159. this.exportedImageFilesJson += string.Format("\"imageFile{0}\" : \"{1}/{2}_{3}.{4}\"", i, sUploadPath, dicImageInfo["key"], i, dicImageInfo["extention"]);
  2160. if(i + 1 < (baseIndex + totalFiles)) {
  2161. exportedImageFiles += "^";
  2162. this.exportedImageFilesJson += ", ";
  2163. }
  2164. }
  2165. this.exportedImageFilesJson += " }";
  2166. System.Diagnostics.Debug.WriteLine("Debug=> exportedImageFiles: " + this.exportedImageFiles);
  2167. System.Diagnostics.Debug.WriteLine("Debug=> exportedImageFilesJson: " + this.exportedImageFilesJson);
  2168. }
  2169. }
  2170. private void ConvertStringToInt(string formRid, string consentMstRid, out int formRidInt, out int consentMstRidInt) {
  2171. formRidInt = 0;
  2172. int.TryParse(formRid, out formRidInt);
  2173. consentMstRidInt = 0;
  2174. int.TryParse(consentMstRid, out consentMstRidInt);
  2175. }
  2176. /// <summary>
  2177. /// baseGlobalParams 의 딕셔너리 객체에 changingGlobalParams 의 딕셔너리 객체의 요소들을 변경함
  2178. /// 기존 baseGlobalParams 딕셔너리에 key 가 없으면 추가되지 않음
  2179. /// </summary>
  2180. /// <param name="baseGlobalParams">복사될 딕셔너리 객체</param>
  2181. /// <param name="changingGlobalParams">복사할 딕셔너리 객체</param>
  2182. private void ChangeGlobalParametersToNew(Dictionary<FOSParameter, string> baseGlobalParams, Dictionary<FOSParameter, string> changingGlobalParams) {
  2183. foreach(FOSParameter dicKey in changingGlobalParams.Keys) {
  2184. if(baseGlobalParams.ContainsKey(dicKey)) {
  2185. baseGlobalParams[dicKey] = changingGlobalParams[dicKey];
  2186. }
  2187. }
  2188. }
  2189. /// <summary>
  2190. /// 사용자에 따른 버튼 활성화
  2191. /// </summary>
  2192. private void SetEnableByUserType() {
  2193. // 기록 테이블의 출력 유무에 따른 서명버튼 활성화 처리
  2194. SetSaveButtonDisabledWhenPrintYN();
  2195. }
  2196. /// <summary>
  2197. /// 출력, 임시저장, 출력 버튼 활성화 여부 설정
  2198. /// </summary>
  2199. private void SetSaveButtonDisabledWhenPrintYN() {
  2200. // 뷰어 모드 적용
  2201. if(consentMain.ConsentExecuteInfo["readOnly"].Equals("Y")) {
  2202. this.toolStripButtons.Enabled = false;
  2203. return;
  2204. }
  2205. if(CurrentEndUser == null || CurrentPreviewConsent == null) {
  2206. return;
  2207. }
  2208. string printOnly = CurrentPreviewConsent.printOnly ?? string.Empty;
  2209. string consentState = CurrentPreviewConsent.consentState ?? string.Empty;
  2210. // 출력만 가능하게 설정
  2211. if(printOnly.Equals("Y")) {
  2212. this.toolStripButtonPrint.Enabled = true;
  2213. //this.toolStripButtonCompleteSaveToServer.Enabled = false;
  2214. this.toolStripButtonSaveToServer.Enabled = false;
  2215. this.toolStripButtonTempSaveToServer.Enabled = false;
  2216. this.toolStripButtonExecute.Enabled = false;
  2217. }
  2218. // 출력 상태일 경우 재출력만 가능하도록 버튼 조정
  2219. else if(consentState.ToUpper().Equals("PAPER_OUT")) {
  2220. this.toolStripButtonExecute.Enabled = false;
  2221. }
  2222. // 작성 완료일 경우 임시 저장 불가
  2223. else if(consentState.ToUpper().Equals("ELECTR_CMP")) {
  2224. this.toolStripButtonTempSaveToServer.Enabled = false;
  2225. }
  2226. }
  2227. private bool checkPrintablePatients(List<PatListVO> volist) {
  2228. foreach(PatListVO patInfo in volist) {
  2229. var cnt = hospitalWebService.checkPrintablePatient(consentMain.ConsentExecuteInfo["dutinstcd"],
  2230. patInfo.pid,
  2231. patInfo.inDd.Replace("/", "").Replace("-", ""),
  2232. patInfo.cretNo.ToString());
  2233. if(cnt > 0) {
  2234. return false;
  2235. }
  2236. }
  2237. return true;
  2238. }
  2239. /// <summary>
  2240. /// 동의서 출력
  2241. /// </summary>
  2242. private void PrintConsent() {
  2243. // 환자정보가 없을 경우 출력이 되지 않도록 적용
  2244. if(this.CurrentTargetPatient == null || string.IsNullOrEmpty(this.CurrentTargetPatient.PatientCode) || string.IsNullOrEmpty(this.CurrentTargetPatient.PatientName)) {
  2245. DialogResult result = MessageBox.Show(string.Format(Properties.Resources.msg_error_user_data)
  2246. , string.Format(Properties.Resources.msg_caption_fail),
  2247. MessageBoxButtons.OK, MessageBoxIcon.Information);
  2248. return;
  2249. }
  2250. // 출력 : patientInfo 를 기반으로 출력하는 경우와 환자목록에서 멀티선택 출력의 경우로 나눠야 한다.
  2251. List<PatListVO> volist = consentMain.PatientListCtrl.GetSelectedPatientList();
  2252. // 1명 출력할 경우
  2253. if(volist.Count == 1) {
  2254. if(this.CurrentPreviewConsent.consentMstRid != null
  2255. && !string.IsNullOrEmpty(this.CurrentPreviewConsent.consentMstRid)
  2256. && !this.CurrentPreviewConsent.consentMstRid.Equals("-1")
  2257. && !this.CurrentPreviewConsent.consentMstRid.Equals("0")) {
  2258. DialogResult result = MessageBox.Show(string.Format(Properties.Resources.msg_multi_print_fail)
  2259. , string.Format(Properties.Resources.msg_caption_fail),
  2260. MessageBoxButtons.OK, MessageBoxIcon.Information);
  2261. }
  2262. else {
  2263. PrintConsentDocument();
  2264. }
  2265. // 환자 목록에서 여러명을 체크박스로 선택하여 출력할 경우
  2266. }
  2267. else if(volist.Count > 0) {
  2268. var cnt = hospitalWebService.getMultiprintable(consentMain.ConsentExecuteInfo["dutinstcd"], CurrentPreviewConsent.formCd);
  2269. if(cnt < 1) {
  2270. MessageBox.Show("멀티출력 가능한 서식이 아닙니다. 전산실에 문의 하세요.");
  2271. return;
  2272. }
  2273. // 여러 환자 선택 시 출력 할 수 없는 수진이력이 있는지 확인한다.
  2274. if(!checkPrintablePatients(volist)) {
  2275. // 6961 [전자동의서]출력시 특정 진찰료 면제사유시 제어 switch
  2276. var runCount = hospitalWebService.checkHardcd(consentMain.ConsentExecuteInfo["dutinstcd"], "6961", "Y");
  2277. if(runCount > 0) {
  2278. MessageBox.Show("다중 선택된 환자 중 출력할 수 없는 수진이력이 있습니다.\n(문의: 의무기록팀)", "확인", MessageBoxButtons.OK);
  2279. return;
  2280. }
  2281. }
  2282. if(this.CurrentPreviewConsent.consentMstRid != null
  2283. && !string.IsNullOrEmpty(this.CurrentPreviewConsent.consentMstRid)
  2284. && !this.CurrentPreviewConsent.consentMstRid.Equals("-1")
  2285. && !this.CurrentPreviewConsent.consentMstRid.Equals("0")) {
  2286. DialogResult result = MessageBox.Show(string.Format(Properties.Resources.msg_multi_print_fail)
  2287. , string.Format(Properties.Resources.msg_caption_fail),
  2288. MessageBoxButtons.OK, MessageBoxIcon.Information);
  2289. }
  2290. else {
  2291. DialogResult result = MessageBox.Show(string.Format(Properties.Resources.msg_multi_print_question)
  2292. , string.Format(Properties.Resources.msg_caption_fail),
  2293. MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
  2294. if(result == DialogResult.OK) {
  2295. this.CurrentPreviewConsent.outputType = "MULTI";
  2296. MultiPrintConsentDocument(volist);
  2297. }
  2298. }
  2299. }
  2300. else {
  2301. PrintConsentDocument();
  2302. }
  2303. }
  2304. /// <summary>
  2305. /// 미리보기 데이터를 출력하는 경우
  2306. /// </summary>
  2307. public void PrintConsentDocument() {
  2308. Dictionary<string, Dictionary<FOSParameter, string>> formParamsList = new Dictionary<string, Dictionary<FOSParameter, string>>();
  2309. string[] formGuidList = new string[this.CurrentPreviewConsent.prntCnt];
  2310. var util = CLIP.eForm.Consent.Common.LoggingUtility.GetLoggingUtility("ERROR", log4net.Core.Level.Error, false);
  2311. for(int i = 0; i < this.CurrentPreviewConsent.prntCnt; i++) {
  2312. Dictionary<FOSParameter, string> formParams = Common.CreateGlobalParamsDictionary(consentMain.ConsentExecuteInfo["dutinstcd"]);
  2313. formGuidList[i] = this.CurrentPreviewConsent.formGuid;
  2314. SetPatientAndUser(formParams);
  2315. //formParams[FOSParameter.OCRCode] = this.CurrentPreviewConsent.Ocrcode = GetOcrCode();
  2316. if(i == 0) {
  2317. formParams[FOSParameter.OCRCode] = this.CurrentPreviewConsent.ocrCode = GetOcrCode();
  2318. if(!reprintStatus) {
  2319. int cnt = hospitalWebService.checkOcrDup(consentMain.ConsentExecuteInfo["dutinstcd"], CurrentPreviewConsent.ocrCode);
  2320. if(cnt > 0) {
  2321. MessageBox.Show("OCRTAG 중복 발생입니다. 환자를 다시 선택하여 주십시요.");
  2322. consentMain.ClearPreviewConsent(true);
  2323. return;
  2324. }
  2325. }
  2326. }
  2327. else {
  2328. var ocrStr = consentWebService.getOcrString(this.CurrentPreviewConsent.formCd,
  2329. consentMain.ConsentExecuteInfo["dutinstcd"]);
  2330. if(ocrStr == null) {
  2331. ocrStr = "[환자 보관용]";
  2332. }
  2333. else {
  2334. ocrStr = (ocrStr.Length < 0) ? "[환자 보관용]" : ocrStr;
  2335. }
  2336. //formParams[FOSParameter.OCRCode] = "[환자 보관용]";
  2337. formParams[FOSParameter.OCRCode] = ocrStr;
  2338. }
  2339. if(string.IsNullOrEmpty(this.CurrentPreviewConsent.ocrCode)) {
  2340. MessageBox.Show("OCRTAG 생성 오류. 전산실에 문의 하세요.");
  2341. consentMain.ClearPreviewConsent(true);
  2342. return;
  2343. }
  2344. formParams[FOSParameter.Device] = "P";
  2345. formParams[FOSParameter.PrintTime] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  2346. formParams[FOSParameter.PrintIp] = consentMain.ConsentExecuteInfo["printIP"];
  2347. if(i == 1) formParams[FOSParameter.PrintComment] = Properties.Resources.msg_print_comment_2;
  2348. else if(i == 2) formParams[FOSParameter.PrintComment] = Properties.Resources.msg_print_comment_3;
  2349. // dbs227, KNUH 프린터 출력 시 출력 일 시 제외
  2350. formParams[FOSParameter.PatientName] = string.Empty; // parCMDCHD_1PatientNm
  2351. // 전자동의서 상 이름이 안아올 경우 파라미터 필드를 parCMDCHD_1PatientNmFix 로 변경
  2352. // 단 파라미터 필드가 정의되어 있지 않는 경우 파라미터 필드를 추가하여 매핑
  2353. formParams[FOSParameter.ExplDrName] = string.Empty; // 설명의 이름 제거
  2354. formParams[FOSParameter.ExplDrTelNo] = string.Empty; // 설명의 전화번호 제거
  2355. formParams[FOSParameter.ExplDrSign] = string.Empty; // 설명의사 싸인 제거
  2356. formParamsList.Add((i + 1).ToString(), formParams);
  2357. util.WriteDebug(String.Format("{0}, {1}, {2}, {3}, {4}", formParams[FOSParameter.PrintTime],
  2358. formParams[FOSParameter.OCRCode],
  2359. formParams[FOSParameter.PatientCode],
  2360. CurrentTargetPatient.VisitType,
  2361. CurrentPreviewConsent.consentState ?? "NULL"));
  2362. }
  2363. string fosOcdcd = string.Empty;
  2364. string fos = Common.GetMultiFosString(formGuidList
  2365. , this.consentMain.PluginExecuteInfo["formServiceUrl"]
  2366. , null
  2367. , formParamsList
  2368. , consentMain.ConsentExecuteInfo["dutinstcd"]
  2369. , out fosOcdcd);
  2370. //PC클라이언트에서 프린트 출력을 눌렀을때 출력 데이타 입력 후 출력되게끔
  2371. if(this.consentMain.getPrintButton()) {
  2372. if(!CurrentPreviewConsent.ocrCode.Equals(fosOcdcd)) {
  2373. MessageBox.Show("OCRTAG 설정 오류 발생. 전산실에 문의 하세요.");
  2374. return;
  2375. }
  2376. this.consentMain.setPageCnt(CurrentPreviewConsent.prntCnt);
  2377. SaveDataForPrintedConsent(String.Empty);
  2378. }
  2379. this.consentMain.PrintConsentDocument(fos);
  2380. //util.CloseRoller();
  2381. // 화면 상에 보이는 데로 출력을 원하면 아래 로직 적용
  2382. //this.consentMain.PrintConsentDocument("");
  2383. }
  2384. //private int g_pageCnt = 0;
  2385. /// <summary>
  2386. /// 사용되지 않음
  2387. /// </summary>
  2388. public void PrintDirectConsentDocument() {
  2389. if(this.currentPreviewConsent == null || this.CurrentTargetPatient == null || this.CurrentEndUser == null) {
  2390. return;
  2391. }
  2392. //미리보기 데이터를 바로 출력하는 경우는 미작성상태인 경우로만 한다. (임시작성 이상의 경우는 바로 출력을 안하도록)
  2393. if(!this.currentPreviewConsent.consentState.ToUpper().Equals("UNFINISHED")) {
  2394. return;
  2395. }
  2396. int prntCnt = 0;
  2397. prntCnt = this.CurrentPreviewConsent.prntCnt;
  2398. int prntMsgCnt = 0;
  2399. if(!string.IsNullOrEmpty(this.consentMain.ConsentExecuteInfo["printList"])) {
  2400. if(!consentMain.ConsentExecuteInfo["prntCnt"].Equals("-1")) {
  2401. int.TryParse(this.consentMain.ConsentExecuteInfo["prntCnt"].ToString(), out prntCnt);
  2402. prntMsgCnt++;
  2403. }
  2404. }
  2405. Dictionary<string, Dictionary<FOSParameter, string>> formParamsList = new Dictionary<string, Dictionary<FOSParameter, string>>();
  2406. string[] formGuidList = new string[prntCnt];
  2407. string sOcrCd = string.Empty;
  2408. for(int i = 0; i < prntCnt; i++) {
  2409. Dictionary<FOSParameter, string> formParams = Common.CreateGlobalParamsDictionary(consentMain.ConsentExecuteInfo["dutinstcd"]);
  2410. Dictionary<FOSParameter, string> changingFormParams = new Dictionary<FOSParameter, string>();
  2411. SetPatientAndUser(formParams);
  2412. changingFormParams[FOSParameter.Device] = "P";
  2413. changingFormParams[FOSParameter.PrintTime] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  2414. changingFormParams[FOSParameter.PrintIp] = consentMain.ConsentExecuteInfo["printIP"];
  2415. if(i == 0) {
  2416. changingFormParams[FOSParameter.OCRCode] = this.CurrentPreviewConsent.ocrCode = GetOcrCode(); // OCR 코드
  2417. sOcrCd = this.CurrentPreviewConsent.ocrCode;
  2418. int cnt = hospitalWebService.checkOcrDup(consentMain.ConsentExecuteInfo["dutinstcd"], sOcrCd);
  2419. if(cnt > 0) {
  2420. MessageBox.Show("OCRTAG 중복 발생입니다. 환자를 다시 선택하여 주십시요.");
  2421. consentMain.ClearPreviewConsent(true);
  2422. return;
  2423. }
  2424. }
  2425. else {
  2426. changingFormParams[FOSParameter.OCRCode] = sOcrCd; //OCR코드
  2427. }
  2428. if(string.IsNullOrEmpty(this.CurrentPreviewConsent.ocrCode)) {
  2429. MessageBox.Show("OCRTAG 생성 오류. 전산실에 문의 하세요.");
  2430. consentMain.ClearPreviewConsent(true);
  2431. return;
  2432. }
  2433. if(prntMsgCnt == 1) changingFormParams[FOSParameter.PrintComment] = Properties.Resources.msg_print_comment_2;
  2434. else if(prntMsgCnt == 2) changingFormParams[FOSParameter.PrintComment] = Properties.Resources.msg_print_comment_3;
  2435. ChangeGlobalParametersToNew(formParams, changingFormParams);
  2436. formGuidList[i] = this.CurrentPreviewConsent.formGuid;
  2437. formParamsList.Add((i + 1).ToString(), formParams);
  2438. prntMsgCnt++;
  2439. }
  2440. string fos = Common.GetMultiFosString(formGuidList
  2441. , this.consentMain.PluginExecuteInfo["formServiceUrl"]
  2442. , null
  2443. , formParamsList
  2444. , consentMain.ConsentExecuteInfo["dutinstcd"]);
  2445. this.consentMain.PrintDirect(fos);
  2446. }
  2447. /// <summary>
  2448. /// 단일 서식 다중 환자 출력
  2449. /// </summary>
  2450. /// <param name="voList">환자 목록 리스트</param>
  2451. private void MultiPrintConsentDocument(List<PatListVO> voList) {
  2452. Dictionary<string, Dictionary<FOSParameter, string>> formParamsList = new Dictionary<string, Dictionary<FOSParameter, string>>();
  2453. List<string> formGuids = new List<string>();
  2454. int guidCnt = 0;
  2455. if(voList.Count > 0 && this.CurrentPreviewConsent.prntCnt > 0) {
  2456. guidCnt = voList.Count * this.CurrentPreviewConsent.prntCnt;
  2457. }
  2458. string[] formGuidList = new string[guidCnt];
  2459. int prntCnt = 0;
  2460. string sOcrCd = string.Empty;
  2461. for(int i = 0; i < voList.Count; i++) {
  2462. sOcrCd = string.Empty;
  2463. for(int j = 0; j < this.CurrentPreviewConsent.prntCnt; j++) {
  2464. PatientVO vo = GetPatientByPatList(voList[i]);
  2465. Dictionary<FOSParameter, string> formParams = Common.CreateGlobalParamsDictionary(consentMain.ConsentExecuteInfo["dutinstcd"]);
  2466. Dictionary<FOSParameter, string> changingFormParams = new Dictionary<FOSParameter, string>();
  2467. changingFormParams[FOSParameter.ImageUploadPath] = this.consentMain.PluginExecuteInfo["imageUploadPath"] + "/";
  2468. changingFormParams[FOSParameter.Device] = "P";
  2469. changingFormParams[FOSParameter.PatientCode] = vo.pid;
  2470. changingFormParams[FOSParameter.PatientSexAge] = vo.sa;
  2471. changingFormParams[FOSParameter.PatientName] = vo.patientName;
  2472. changingFormParams[FOSParameter.PatientRRN] = vo.juminNo;
  2473. changingFormParams[FOSParameter.PatientRRNOrg] = vo.orgJuminNo;
  2474. changingFormParams[FOSParameter.RoomNo] = vo.ward + "/" + vo.roomCd;
  2475. changingFormParams[FOSParameter.VisitDate] = SetDateFormatting(vo.inDd);
  2476. changingFormParams[FOSParameter.DeptName] = vo.deptEngAbbr;
  2477. changingFormParams[FOSParameter.FormName] = this.CurrentPreviewConsent.formPrintName;
  2478. changingFormParams[FOSParameter.MainDoctor] = vo.mainDrName;
  2479. // dbs227 다중 출력 시 환자 이름을 추가하여 준다
  2480. changingFormParams[FOSParameter.PatientNameFix] = vo.patientName;
  2481. // 출력할 경우 설명 의사와 서명 이미지는 공백 처리
  2482. //if (consentMain.ConsentExecuteInfo["printYN"].Equals("Y"))
  2483. {
  2484. //changingFormParams[FOSParameter.ExplDrName] = string.Empty;
  2485. //changingFormParams[FOSParameter.ExplDrTelNo] = string.Empty;
  2486. //changingFormParams[FOSParameter.ExplDrSign] = string.Empty;
  2487. //changingFormParams[FOSParameter.PatientName] = string.Empty;
  2488. //changingFormParams[FOSParameter.PatientBirthDay] = string.Empty;
  2489. //changingFormParams[FOSParameter.PatientTelNo] = string.Empty; // parCMSGBD_PT_tel
  2490. // 보호자상주확인서 프린터 출력시 제외 항목
  2491. //changingGlobalParams[FOSParameter.UserName] = string.Empty;
  2492. //changingGlobalParams[FOSParameter.SignImage] = string.Empty;
  2493. }
  2494. if(j == 0) {
  2495. HospitalSvcRef.SingleReturnData retData = hospitalWebService.GetOcrTag(this.consentMain.ConsentExecuteInfo["dutinstcd"]);
  2496. vo.ocrCd = retData.responseData;
  2497. int cnt = hospitalWebService.checkOcrDup(consentMain.ConsentExecuteInfo["dutinstcd"], vo.ocrCd);
  2498. if(cnt > 0) {
  2499. MessageBox.Show("OCRTAG 중복 발생입니다. 환자를 다시 선택하여 주십시요.");
  2500. consentMain.ClearPreviewConsent(true);
  2501. return;
  2502. }
  2503. changingFormParams[FOSParameter.OCRCode] = vo.ocrCd; //OCR코드
  2504. this.CurrentPreviewConsent.multiOcrcode += vo.ocrCd + "^";
  2505. this.CurrentPreviewConsent.multiMainDrIdCd += vo.mainDrId + "^";
  2506. sOcrCd = vo.ocrCd;
  2507. }
  2508. else {
  2509. changingFormParams[FOSParameter.OCRCode] = sOcrCd; //OCR코드
  2510. }
  2511. if(string.IsNullOrEmpty(sOcrCd)) {
  2512. MessageBox.Show("OCRTAG 생성 오류. 전산실에 문의 하세요.");
  2513. return;
  2514. }
  2515. if(j == 1) changingFormParams[FOSParameter.PrintComment] = Properties.Resources.msg_print_comment_2;
  2516. else if(j == 2) changingFormParams[FOSParameter.PrintComment] = Properties.Resources.msg_print_comment_3;
  2517. changingFormParams[FOSParameter.PrintTime] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  2518. changingFormParams[FOSParameter.PrintIp] = consentMain.ConsentExecuteInfo["printIP"];
  2519. ChangeGlobalParametersToNew(formParams, changingFormParams);
  2520. formGuidList[prntCnt] = this.CurrentPreviewConsent.formGuid;
  2521. //formGuids.Add(this.CurrentPreviewConsent.FormGuid);
  2522. formParamsList.Add((prntCnt + 1).ToString(), formParams);
  2523. prntCnt++;
  2524. }
  2525. }
  2526. if(this.CurrentPreviewConsent.multiOcrcode.Length > 0) {
  2527. this.CurrentPreviewConsent.multiOcrcode = this.CurrentPreviewConsent.multiOcrcode.Substring(0, this.CurrentPreviewConsent.multiOcrcode.Length - 1);
  2528. }
  2529. if(this.CurrentPreviewConsent.multiMainDrIdCd.Length > 0) {
  2530. this.CurrentPreviewConsent.multiMainDrIdCd = this.CurrentPreviewConsent.multiMainDrIdCd.Substring(0, this.CurrentPreviewConsent.multiMainDrIdCd.Length - 1);
  2531. }
  2532. string fos = Common.GetMultiFosString(formGuidList
  2533. , this.consentMain.PluginExecuteInfo["formServiceUrl"]
  2534. , null
  2535. , formParamsList
  2536. , consentMain.ConsentExecuteInfo["dutinstcd"]);
  2537. //PC클라이언트에서 프린트 출력을 눌렀을때 출력 데이타 입력 후 출력되게끔
  2538. if(this.consentMain.getPrintButton()) {
  2539. this.consentMain.setPageCnt(CurrentPreviewConsent.prntCnt);
  2540. SaveDataForPrintedConsent(String.Empty);
  2541. }
  2542. this.consentMain.PrintConsentDocument(fos);
  2543. }
  2544. private string SetDateFormatting(string adDate) {
  2545. if(adDate.Length == 8)
  2546. return string.Format("{0}/{1}/{2}", adDate.Substring(0, 4), adDate.Substring(4, 2), adDate.Substring(6, 2));
  2547. else
  2548. return adDate;
  2549. }
  2550. public override void OnRequiredInputViolation(string value) {
  2551. MessageBox.Show(this, value + " 항목이 누락되었습니다.", Properties.Resources.msg_caption_warn, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  2552. //MessageBoxDlg.Show(false, value + " 항목이 누락되었습니다.", Properties.Resources.msg_caption_warn, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  2553. }
  2554. /// <summary>
  2555. /// toolStripButtonPen 체크박스 활성화 여부 체크 및 이미지 변경
  2556. /// </summary>
  2557. /// <param name="enabled">if set to <c>true</c> [enabled].</param>
  2558. public override void onEnableDrawing(bool enabled) {
  2559. this.toolStripButtonPen.Checked = enabled;
  2560. if(this.toolStripButtonPen.Checked) this.toolStripButtonPen.Image = global::CLIP.eForm.Consent.UI.Properties.Resources.newDrawingClick;
  2561. else this.toolStripButtonPen.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButtonPen.Image")));
  2562. }
  2563. /// <summary>
  2564. /// 첨지 삭제 버튼 클릭 이벤트
  2565. /// </summary>
  2566. /// <param name="sender">The source of the event.</param>
  2567. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  2568. private void toolStripButtonDeleteAttach_Click(object sender, EventArgs e) {
  2569. this.consentMain.DeleteAttach();
  2570. setViewerPageInit();
  2571. }
  2572. /// <summary>
  2573. /// 첨지 추가 버튼 클릭 이벤트
  2574. /// </summary>
  2575. /// <param name="sender">The source of the event.</param>
  2576. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  2577. private void toolStripButtonInsertAttach_Click(object sender, EventArgs e) {
  2578. this.consentMain.InsertAttach();
  2579. setViewerPageInit();
  2580. }
  2581. /// <summary>
  2582. /// 뷰어 페이지 초기화
  2583. /// </summary>
  2584. public override void setViewerPageInit() {
  2585. this.toolStripLabelTotalPages.Text = this.consentMain.GetTotalPageCount().ToString();
  2586. this.toolStripTextBoxPageIndex.Text = this.consentMain.GetCurrentPageIndex().ToString();
  2587. }
  2588. /// <summary>
  2589. /// 환경설정 버튼 클릭 이벤트
  2590. /// </summary>
  2591. /// <param name="sender">The source of the event.</param>
  2592. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  2593. private void toolStripButtonConfig_Click(object sender, EventArgs e) {
  2594. ShowConfigDialog();
  2595. }
  2596. /// <summary>
  2597. /// 환경설정 다이얼로그를 불러온다
  2598. /// </summary>
  2599. private void ShowConfigDialog() {
  2600. ConfigForm configForm = new ConfigForm();
  2601. configForm.ShowDialog(this);
  2602. }
  2603. class ZoomRateDropdownItem {
  2604. private string caption = string.Empty;
  2605. public string Caption {
  2606. get { return caption; }
  2607. set { caption = value; }
  2608. }
  2609. private string itemValue = string.Empty;
  2610. public string ItemValue {
  2611. get { return itemValue; }
  2612. set { itemValue = value; }
  2613. }
  2614. public ZoomRateDropdownItem() {
  2615. }
  2616. public ZoomRateDropdownItem(string caption, string itemValue) {
  2617. this.caption = caption;
  2618. this.itemValue = itemValue;
  2619. }
  2620. public override string ToString() {
  2621. return caption;
  2622. }
  2623. }
  2624. /// <summary>
  2625. /// 환경설정 버튼 클릭 이벤트
  2626. /// </summary>
  2627. /// <param name="sender">The source of the event.</param>
  2628. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  2629. private void toolStripButtonConfig_Click_1(object sender, EventArgs e) {
  2630. ShowConfigDialog();
  2631. }
  2632. private void ConsentCommandCtrl_Click(object sender, EventArgs e) {
  2633. MessageBoxDlg.MessageBoxParent = this;
  2634. }
  2635. public void setCurrentPreviewConsentForm(ConsentFormListVO vo, int orderNo, string inputId, string inputNm) {
  2636. // 현재 preview 할동의서 정보 설정
  2637. CurrentPreviewConsent = new PreviewConsent {
  2638. formRid = vo.formRid.ToString(),
  2639. formGuid = vo.formGuid,
  2640. formCd = vo.formCd.ToString(),
  2641. FormName = vo.formName,
  2642. formPrintName = vo.formPrntNm,
  2643. prntCnt = vo.printCnt,
  2644. consentMstRid = vo.consentMstRid.ToString(),
  2645. consentState = vo.consentState,
  2646. orderNo = orderNo,
  2647. inputId = inputId,
  2648. inputNm = inputNm,
  2649. ReissueConsentMstRid = 0,
  2650. RewriteConsentMstRid = 0,
  2651. ordType = CurrentTargetPatient.VisitType,
  2652. ocrtagPrntyn = vo.ocrTagPrntYn,
  2653. userDrFlag = vo.userDrFlag,
  2654. printOnly = vo.printOnly,
  2655. opDiagName = vo.opDiagNm,
  2656. drOnly = vo.DrOnly,
  2657. opName = vo.opNm
  2658. };
  2659. Dictionary<FOSParameter, string> globalParams = Common.CreateGlobalParamsDictionary(consentMain.ConsentExecuteInfo["dutinstcd"]);
  2660. List<string> formGuids = new List<string> { CurrentPreviewConsent.formGuid };
  2661. SetPatientAndUser(globalParams);
  2662. globalParams[FOSParameter.OCRCode] = string.Empty;
  2663. var ocrBuf = GetOcrCode();
  2664. if (string.IsNullOrEmpty(ocrBuf)) {
  2665. MessageBox.Show("OCR 중복입니다. 다시 환자를 선택하여 주세요.");
  2666. return;
  2667. }
  2668. int cnt = hospitalWebService.checkOcrDup(consentMain.ConsentExecuteInfo["dutinstcd"], ocrBuf);
  2669. if (cnt > 0) {
  2670. MessageBox.Show("OCRTAG 중복 발생입니다. 환자를 다시 선택하여 주십시요.");
  2671. consentMain.ClearPreviewConsent(true);
  2672. return;
  2673. }
  2674. globalParams[FOSParameter.OCRCode] = CurrentPreviewConsent.ocrCode = ocrBuf;
  2675. globalParams[FOSParameter.Device] = "C";
  2676. globalParams[FOSParameter.PrintTime] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  2677. globalParams[FOSParameter.SignTime] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  2678. globalParams[FOSParameter.PrintIp] = consentMain.ConsentExecuteInfo["printIP"];
  2679. if (string.IsNullOrEmpty(CurrentPreviewConsent.ocrCode)) {
  2680. MessageBox.Show("OCRTAG 생성 오류. 전산실에 문의 하세요.");
  2681. consentMain.ClearPreviewConsent(true);
  2682. return;
  2683. }
  2684. string fos = Common.GetFosString(formGuids
  2685. , consentMain.PluginExecuteInfo["formServiceUrl"]
  2686. , globalParams
  2687. , null
  2688. , consentMain.ConsentExecuteInfo["dutinstcd"]);
  2689. SetEnableButtonsByCurrentConsent();
  2690. consentMain.PreviewConsent(fos);
  2691. RunConsentDualView();
  2692. SetEnableConsentIssueCommands(true);
  2693. }
  2694. public void setToolstripEnabled(bool isEnabled)
  2695. {
  2696. this.toolStripButtonFirstPage.Enabled = isEnabled;//
  2697. this.toolStripButtonPrevPage.Enabled = isEnabled;
  2698. this.toolStripButtonNextPage.Enabled = isEnabled;
  2699. this.toolStripButtonLastPage.Enabled = isEnabled;
  2700. this.toolStripTextBoxPageIndex.Enabled = isEnabled;//페이지번호 보여주는부분 total page
  2701. this.toolStripLabelTotalPages.Enabled = isEnabled;//
  2702. this.toolStripTextBoxPageIndex.Text = consentMain.GetCurrentPageIndex().ToString();
  2703. this.toolStripLabelTotalPages.Text = consentMain.GetTotalPageCount().ToString();
  2704. this.toolStripComboBoxZoom.Enabled = isEnabled;//넓이 맞춤 서식 폭 조정
  2705. this.toolStripButtonDeleteAllSignData.Enabled = isEnabled;//그림그린거 다없앤거
  2706. }
  2707. /// <summary>
  2708. /// 다중서식 실행시 듀얼뷰어를 실행시켰을 때 버튼 설정
  2709. /// </summary>
  2710. public void setMultiParamsDualViewrStripButton()
  2711. {
  2712. // 전자동의서 실행 버튼
  2713. this.toolStripButtonExecute.Enabled = false;
  2714. // 출력 버튼
  2715. this.toolStripButtonPrint.Enabled = true;
  2716. if (this.CurrentPreviewConsent != null && this.CurrentPreviewConsent.outputType != null)
  2717. {
  2718. if (this.CurrentPreviewConsent.outputType.Equals("ELECTRONIC"))
  2719. {
  2720. this.toolStripButtonPrint.Enabled = false;
  2721. }
  2722. }
  2723. // Dual Viewer 닫기 버튼
  2724. this.toolStripButtonCloseDualViewer.Visible = true;
  2725. SetEnableByUserType();
  2726. base.SetEnablementExecuteWhenDualViewerActive(true);
  2727. }
  2728. }
  2729. }