ConsentCommandCtrl.cs 144 KB

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