ConsentCommandCtrl.cs 111 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580
  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. namespace CLIP.eForm.Consent.UI {
  24. /// <summary>
  25. /// 출력, 전자동의서 실행 버튼 클래스
  26. /// </summary>
  27. /// <remarks>
  28. /// <p>[설계자]</p>
  29. /// <p> 클립소프트 연구소 홍지철 (jchong@clipsoft.co.kr)</p>
  30. /// <p>[원본 작성자]</p>
  31. /// <p> 클립소프트 기술부 이창훈 (chlee@clipsoft.co.kr)</p>
  32. /// <p>[수정 작성자]</p>
  33. /// <p> 클립소프트 기술부 이인희</p>
  34. /// <p>----------------------------------------------------------------------------------------</p>
  35. /// <p>[HISTORY]</p>
  36. /// <p> 2016-06-21 : 최초작성</p>
  37. /// <p>----------------------------------------------------------------------------------------</p>
  38. /// </remarks>
  39. public partial class ConsentCommandCtrl : ConsentCommandCtrlBase {
  40. private PreviewConsent currentPreviewConsent = null;
  41. private TargetPatient currentTargetPatient = null;
  42. private EndUser currentEndUser = null;
  43. private IConsentMain consentMain = null;
  44. private ConsentSvcRef.ConsentSvcSoapClient consentWebService = null;
  45. private HospitalSvcRef.HospitalSvcSoapClient hospitalWebService = null;
  46. private string exportedImageFiles = string.Empty;
  47. private string exportedImageFilesJson = string.Empty;
  48. System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ConsentCommandCtrl));
  49. private bool m_IsComplete = false; // 확인 저장 버튼 클릭 여부
  50. public bool IsComplete => m_IsComplete;
  51. public ConsentCommandCtrl() {
  52. InitializeComponent();
  53. }
  54. public override bool EnableRedo {
  55. get {
  56. return base.EnableRedo;
  57. }
  58. set {
  59. base.EnableRedo = value;
  60. this.toolStripButtonRedo.Enabled = base.EnableRedo;
  61. }
  62. }
  63. public override bool EnableUndo {
  64. get {
  65. return base.EnableUndo;
  66. }
  67. set {
  68. base.EnableUndo = value;
  69. this.toolStripButtonUndo.Enabled = base.EnableUndo;
  70. }
  71. }
  72. public override bool EnableRemoveAll {
  73. get {
  74. return base.EnableRemoveAll;
  75. }
  76. set {
  77. base.EnableRemoveAll = value;
  78. this.toolStripButtonDelAllDraw.Enabled = base.EnableRemoveAll;
  79. }
  80. }
  81. public override bool EnablePenDrawing {
  82. get {
  83. return base.EnableRemoveAll;
  84. }
  85. set {
  86. base.EnablePenDrawing = value;
  87. this.toolStripButtonPen.Enabled = base.EnablePenDrawing;
  88. }
  89. }
  90. public override bool EnablePenConfig {
  91. get {
  92. return base.EnablePenConfig;
  93. }
  94. set {
  95. base.EnablePenConfig = value;
  96. this.toolStripButtonPenConfig.Enabled = base.EnablePenConfig;
  97. }
  98. }
  99. public PreviewConsent CurrentPreviewConsent {
  100. get {
  101. return currentPreviewConsent;
  102. }
  103. set {
  104. currentPreviewConsent = value;
  105. }
  106. }
  107. public TargetPatient CurrentTargetPatient {
  108. get {
  109. return currentTargetPatient;
  110. }
  111. set {
  112. currentTargetPatient = value;
  113. }
  114. }
  115. public EndUser CurrentEndUser {
  116. get {
  117. return currentEndUser;
  118. }
  119. set {
  120. currentEndUser = value;
  121. }
  122. }
  123. /// <summary>
  124. /// 임시저장 버튼 클릭 활성화 여부 반환
  125. /// </summary>
  126. /// <returns></returns>
  127. public override bool getTempSaveButton() {
  128. return this.toolStripButtonTempSaveToServer.Enabled;
  129. }
  130. /// <summary>
  131. /// 저장 버튼 클릭 활성화 여부 반환
  132. /// </summary>
  133. /// <returns></returns>
  134. public override bool getSaveButton() {
  135. return this.toolStripButtonSaveToServer.Enabled;
  136. }
  137. public override void setTempSaveButton(bool enabled) {
  138. this.toolStripButtonTempSaveToServer.Enabled = enabled;
  139. }
  140. public override void setSaveButton(bool enabled) {
  141. this.toolStripButtonSaveToServer.Enabled = enabled;
  142. }
  143. public void setButtonsVisibility(string patientOrdtype, string consentState) {
  144. if (patientOrdtype.Equals("O")) {
  145. toolStripButtonCompleteSaveToServer.Visible = true;
  146. toolStripButtonCompleteSaveToServer.Enabled = true;
  147. } else {
  148. toolStripButtonCompleteSaveToServer.Visible = false;
  149. toolStripButtonCompleteSaveToServer.Enabled = false;
  150. }
  151. if (consentState.Equals("인증") || consentState.Equals("확인")) {
  152. // 임시저장 버튼 비활성화
  153. toolStripButtonTempSaveToServer.Visible = false;
  154. toolStripButtonTempSaveToServer.Enabled = false;
  155. // 확인저장 버튼 비활성화
  156. toolStripButtonCompleteSaveToServer.Visible = false;
  157. toolStripButtonCompleteSaveToServer.Enabled = false;
  158. }
  159. else {
  160. // 임시저장 버튼 활성화
  161. toolStripButtonTempSaveToServer.Visible = true;
  162. toolStripButtonTempSaveToServer.Enabled = true;
  163. }
  164. }
  165. public void setZoomRate(int rate) {
  166. toolStripComboBoxZoom.SelectedIndex = rate;
  167. toolStripComboBoxZoom.Enabled = true; // zoom rate
  168. toolStripButtonPrevPage.Enabled = true; // 이전 페이지
  169. toolStripButtonNextPage.Enabled = true; // 다음 페이지
  170. toolStripTextBoxPageIndex.Enabled = true; // 페이지 인덱스
  171. toolStripLabelTotalPages.Enabled = true;
  172. toolStripButtonFirstPage.Enabled = true; // 처음 페이지
  173. toolStripButtonLastPage.Enabled = true; // 마지막페이지
  174. toolStripTextBoxPageIndex.Text = consentMain.GetCurrentPageIndex().ToString();
  175. toolStripLabelTotalPages.Text = consentMain.GetTotalPageCount().ToString();
  176. }
  177. public override void setCompleteSaveTempButton(bool enabled) {
  178. this.toolStripButtonTempSaveToServer.Enabled = enabled;
  179. this.toolStripButtonCompleteSaveToServer.Enabled = enabled;
  180. this.toolStripButtonCompleteSaveToServer.Visible = true;
  181. this.toolStripButtonSaveToServer.Enabled = true;
  182. }
  183. public override void setCompleteSaveButton(bool enabled) {
  184. this.toolStripButtonCompleteSaveToServer.Enabled = enabled;
  185. toolStripButtonCompleteSaveToServer.Visible = enabled;
  186. }
  187. protected override void OnLoad(EventArgs e) {
  188. base.OnLoad(e);
  189. if (this.DesignMode || LicenseManager.UsageMode == LicenseUsageMode.Designtime) {
  190. return;
  191. }
  192. if (!ConsentMainControl.HasMultipleMonitor) {
  193. this.toolStripButtonExecute.Visible = false;
  194. } else {
  195. this.toolStripButtonExecute.Visible = true;
  196. }
  197. this.consentMain = ConsentMainControl.GetConsentMainInterface(this);
  198. this.consentWebService = WebMethodCommon.GetConsentWebService(consentMain.PluginExecuteInfo["consentSvcUrl"]);
  199. this.hospitalWebService = WebMethodCommon.GetHospitalWebService(consentMain.PluginExecuteInfo["hospitalSvcUrl"]);
  200. InitZoomRateDropdownItems();
  201. this.consentMain.OnLoadPartControls += ConsentMain_OnLoadPartControls;
  202. this.toolStripButtons.MouseEnter += ToolStripButtons_MouseEnter;
  203. }
  204. private void ConsentMain_OnLoadPartControls(object sender, EventArgs e) {
  205. this.consentMain.OnVisibleEFormControl += ConsentMain_OnVisibleEFormControl;
  206. this.consentMain.OnInvisibleEFormControl += ConsentMain_OnInvisibleEFormControl;
  207. }
  208. private void ConsentMain_OnInvisibleEFormControl(object sender, EventArgs e) {
  209. this.consentMain.ConsentCommandCtrl.Enabled = false;
  210. }
  211. private void ConsentMain_OnVisibleEFormControl(object sender, EventArgs e) {
  212. this.consentMain.ConsentCommandCtrl.Enabled = true;
  213. }
  214. private void InitZoomRateDropdownItems() {
  215. // 콤보 박스에 저장되는 형식을 ArrayList 로 바꿈
  216. List<ZoomRateDropdownItem> zoomRateList = new List<ZoomRateDropdownItem>();
  217. zoomRateList.Add(new ZoomRateDropdownItem("50%", "50"));
  218. zoomRateList.Add(new ZoomRateDropdownItem("75%", "75"));
  219. zoomRateList.Add(new ZoomRateDropdownItem("100%", "100"));
  220. zoomRateList.Add(new ZoomRateDropdownItem("200%", "200"));
  221. zoomRateList.Add(new ZoomRateDropdownItem("창 너비에 맞춤", "pagewidth"));
  222. zoomRateList.Add(new ZoomRateDropdownItem("창 크기에 맞춤", "wholepage"));
  223. toolStripComboBoxZoom.Items.AddRange(zoomRateList.ToArray());
  224. }
  225. #region toolStripButton 이벤트
  226. private void ToolStripButtons_MouseEnter(object sender, EventArgs e) {
  227. this.toolStripButtons.Focus();
  228. }
  229. /// <summary>
  230. /// 처음 페이지로 이동 버튼 클릭 이벤트
  231. /// </summary>
  232. /// <param name="sender">The source of the event.</param>
  233. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  234. private void toolStripButtonFirstPage_Click(object sender, EventArgs e) {
  235. this.consentMain.MoveFirstPage();
  236. }
  237. /// <summary>
  238. /// 이전 페이지로 이동 버튼 클릭 이벤트
  239. /// </summary>
  240. /// <param name="sender">The source of the event.</param>
  241. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  242. private void toolStripButtonPrevPage_Click(object sender, EventArgs e) {
  243. this.consentMain.MovePrevPage();
  244. }
  245. /// <summary>
  246. /// 다음 페이지 이동 버튼 클릭 이벤트
  247. /// </summary>
  248. /// <param name="sender">The source of the event.</param>
  249. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  250. private void toolStripButtonNextPage_Click(object sender, EventArgs e) {
  251. this.consentMain.MoveNextPage();
  252. }
  253. /// <summary>
  254. /// 마지막 페이지로 이동 버튼 클릭 이벤트
  255. /// </summary>
  256. /// <param name="sender">The source of the event.</param>
  257. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  258. private void toolStripButtonLastPage_Click(object sender, EventArgs e) {
  259. this.consentMain.MoveLastPage();
  260. }
  261. /// <summary>
  262. /// toolStripTextBoxPageIndex 텍스트 변경 이벤트
  263. /// </summary>
  264. /// <param name="sender">The source of the event.</param>
  265. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  266. private void toolStripTextBoxPageIndex_TextChanged(object sender, EventArgs e) {
  267. if (!string.IsNullOrEmpty(this.toolStripTextBoxPageIndex.Text)) {
  268. bool currentIndexParseResult;
  269. int currentIndex = 0;
  270. currentIndexParseResult = int.TryParse(this.toolStripTextBoxPageIndex.Text, out currentIndex);
  271. bool totalIndexParseResult;
  272. int totalIndex = 0;
  273. totalIndexParseResult = int.TryParse(this.toolStripTextBoxPageIndex.Text, out totalIndex);
  274. if (currentIndexParseResult == false || totalIndexParseResult == false) {
  275. return;
  276. }
  277. if (currentIndex > totalIndex) {
  278. }
  279. // 입력한 페이지수가 전체 페이지 이하일 경우 해당 페이지로 이동
  280. else {
  281. this.consentMain.MoveToPageIndex(currentIndex);
  282. }
  283. }
  284. }
  285. /// <summary>
  286. /// 동의서 확대비율 지정 콤보 박스 변경 이벤트
  287. /// </summary>
  288. /// <param name="sender">The source of the event.</param>
  289. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  290. private void toolStripComboBoxZoom_SelectedIndexChanged(object sender, EventArgs e) {
  291. ZoomRateDropdownItem zoomRateItem = this.toolStripComboBoxZoom.SelectedItem as ZoomRateDropdownItem;
  292. if (zoomRateItem == null) {
  293. } else {
  294. this.consentMain.SetZoomRate(zoomRateItem.ItemValue);
  295. }
  296. }
  297. /// <summary>
  298. /// 출력 버튼 클릭 이벤트
  299. /// </summary>
  300. /// <param name="sender">The source of the event.</param>
  301. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  302. private void toolStripButtonPrint_Click(object sender, EventArgs e) {
  303. // dbs227, 현재 동의서 상태가 null 이라면 skip
  304. if (CurrentPreviewConsent == null) {
  305. SetEnableButtonsByCurrentConsent();
  306. return;
  307. }
  308. this.consentMain.setPrintButton(true);
  309. PrintConsent();
  310. }
  311. /// <summary>
  312. /// 동의서 닫기 버튼 클릭 이벤트
  313. /// </summary>
  314. /// <param name="sender">The source of the event.</param>
  315. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  316. private void toolStripButtonCloseDualViewer_Click(object sender, EventArgs e) {
  317. this.consentMain.CloseDualViewer();
  318. }
  319. /// <summary>
  320. /// 임시저장 버튼 클릭 이벤트
  321. /// </summary>
  322. /// <param name="sender">The source of the event.</param>
  323. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  324. private void toolStripButtonTempSaveToServer_Click(object sender, EventArgs e) {
  325. // 동의서 임시 저장
  326. this.consentMain.TempSave();
  327. }
  328. /// <summary>
  329. /// 서명 버튼 클릭 이벤트
  330. /// </summary>
  331. /// <param name="sender">The source of the event.</param>
  332. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  333. private void toolStripButtonSaveToServer_Click(object sender, EventArgs e) {
  334. // dbs227, 현재 동의서 상태가 null 이라면 skip
  335. if (CurrentPreviewConsent == null) {
  336. SetEnableButtonsByCurrentConsent();
  337. return;
  338. }
  339. // TODO 인증저장 권한은 누가?
  340. // 로그인 사용자와 동의서 작성자가 다르면 인증 저장 제한
  341. //if (!CurrentPreviewConsent.InputId.Equals(consentMain.ConsentExecuteInfo["loginUserId"])) {
  342. // MessageBox.Show("작성자만 인증 저장이 가능합니다.", "인증 저장 불가", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  343. // return;
  344. //}
  345. this.consentMain.saveClickPoint = true;
  346. this.consentMain.Save();
  347. this.consentMain.saveClickPoint = false;
  348. }
  349. /// <summary>
  350. /// 확인 저장 버튼 클릭 이벤트
  351. /// </summary>
  352. /// <param name="sender">The source of the event.</param>
  353. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  354. private void toolStripButtonCompleteSaveToServer_Click(object sender, EventArgs e) {
  355. m_IsComplete = true;
  356. this.consentMain.Save();
  357. m_IsComplete = false;
  358. }
  359. /// <summary>
  360. /// 전자동의서 실행 버튼 클릭 이벤트
  361. /// </summary>
  362. /// <param name="sender">The source of the event.</param>
  363. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  364. private void toolStripButtonExecute_Click(object sender, EventArgs e) {
  365. RunConsentDualView();
  366. }
  367. /// <summary>
  368. /// 펜 그리기 모드 활성화/비활성화 버튼 클릭 이벤트
  369. /// </summary>
  370. /// <param name="sender">The source of the event.</param>
  371. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  372. private void toolStripButtonPen_Click(object sender, EventArgs e) {
  373. bool isDrawMode = this.consentMain.IsDrawMode();
  374. this.consentMain.EnableDrawing(!isDrawMode);
  375. this.toolStripButtonPen.Checked = !isDrawMode;
  376. }
  377. /// <summary>
  378. /// 그리기 펜 설정 버튼 클릭 이벤트
  379. /// </summary>
  380. /// <param name="sender">The source of the event.</param>
  381. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  382. private void toolStripButtonPenConfig_Click(object sender, EventArgs e) {
  383. // 펜 색상 및 두께 변경
  384. this.consentMain.ConfigDrawingPen();
  385. }
  386. /// <summary>
  387. /// 펜 그리기 데이터 모두 삭제 버튼 클릭 이벤트
  388. /// </summary>
  389. /// <param name="sender">The source of the event.</param>
  390. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  391. private void toolStripButtonDelAllDraw_Click(object sender, EventArgs e) {
  392. this.consentMain.RemoveAllDrawing();
  393. }
  394. /// <summary>
  395. /// 펜 그리기 undo 버튼 클릭 이벤트
  396. /// </summary>
  397. /// <param name="sender">The source of the event.</param>
  398. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  399. private void toolStripButtonUndo_Click(object sender, EventArgs e) {
  400. this.consentMain.UndoDrawing();
  401. }
  402. /// <summary>
  403. /// 펜 그리기 redo 버튼 클릭 이벤트
  404. /// </summary>
  405. /// <param name="sender">The source of the event.</param>
  406. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  407. private void toolStripButtonRedo_Click(object sender, EventArgs e) {
  408. this.consentMain.RedoDrawing();
  409. }
  410. #endregion
  411. /// <summary>
  412. /// 페지 변경시 이벤트
  413. /// 외부에서 호출하는 메서드
  414. /// </summary>
  415. /// <param name="currentPageIndex">Index of the current page.</param>
  416. public override void OnPaging(int currentPageIndex) {
  417. this.toolStripTextBoxPageIndex.Text = currentPageIndex.ToString();
  418. }
  419. /// <summary>
  420. /// 동의서 종이 출력
  421. /// </summary>
  422. /// <param name="value"></param>
  423. public override void OnPrint(string value) {
  424. Cursor currentCursor = this.Cursor;
  425. try {
  426. this.Cursor = Cursors.WaitCursor;
  427. SaveDataForPrintedConsent(string.Empty);
  428. // dbs227, 경대병원 프린트 연동 로그 추후 기록
  429. // 기존 저장 루틴 위치 변경
  430. //SaveDataForPrintedConsent(string.Empty);
  431. // 출력 카운트만큼 출력 된 후 처리
  432. /*
  433. if (this.consentMain.printSaveStatus) {
  434. if (consentMain.ConsentExecuteInfo["printAct"].Equals("N")) {
  435. //MessageBox.Show(string.Format(Properties.Resources.msg_temp_print_confirm)
  436. // , string.Format(Properties.Resources.msg_caption_confirm), MessageBoxButtons.OK, MessageBoxIcon.Information);
  437. //출력후에는 전체목록 탭이 선택되게 한다.
  438. this.consentMain.ConsentListCtrl.InquiryConsentData(-2);
  439. } else {
  440. //agent 구동시 바로 출력을 하는 경우 미작성 탭이 선택되게 한다.
  441. this.consentMain.ConsentListCtrl.InquiryConsentData(9);
  442. }
  443. //Agent에서 출력요청한 내용이 모두 끝나면 창을 닫는다.
  444. if (consentMain.ConsentExecuteInfo["printAct"].Equals("Y")) {
  445. this.consentMain.agentCallPrintCnt--;
  446. if (this.consentMain.agentCallPrintCnt == 0) {
  447. this.consentMain.Parent_Disposed();
  448. }
  449. }
  450. }
  451. */
  452. } catch (Exception ex) {
  453. throw ex;
  454. } finally {
  455. this.Cursor = currentCursor;
  456. // dbs227 저장이 끝나면 preview 객체를 초기화 하여 준다
  457. CurrentPreviewConsent = null;
  458. }
  459. base.OnPrint(value);
  460. }
  461. /// <summary>
  462. /// 동의서 동의서 미리보기 상태 활성화 처리
  463. /// </summary>
  464. /// <param name="isIssuable"></param>
  465. public override void SetEnableConsentIssueCommands(bool isIssuable) {
  466. //this.toolStripButtonPrint.Enabled = isIssuable;//프린트
  467. this.toolStripButtonExecute.Enabled = isIssuable;//아큐실행버튼
  468. this.toolStripButtonFirstPage.Enabled = isIssuable;//
  469. this.toolStripButtonPrevPage.Enabled = isIssuable;
  470. this.toolStripButtonNextPage.Enabled = isIssuable;
  471. this.toolStripButtonLastPage.Enabled = isIssuable;
  472. this.toolStripTextBoxPageIndex.Enabled = isIssuable;//페이지번호 보여주는부분 total page
  473. this.toolStripLabelTotalPages.Enabled = isIssuable;//
  474. this.toolStripTextBoxPageIndex.Text = consentMain.GetCurrentPageIndex().ToString();
  475. this.toolStripLabelTotalPages.Text = consentMain.GetTotalPageCount().ToString();
  476. this.toolStripComboBoxZoom.Enabled = isIssuable;//넓이 맞춤 서식 폭 조정
  477. this.toolStripButtonDeleteAllSignData.Enabled = isIssuable;//그림그린거 다없앤거
  478. this.toolStripButtonInsertAttach.Enabled = isIssuable;//첨지
  479. this.toolStripButtonDeleteAttach.Enabled = isIssuable;//첨지삭제
  480. this.toolStripButtonSaveToServer.Enabled = isIssuable; // 인증 저장
  481. this.toolStripButtonTempSaveToServer.Enabled = isIssuable; // 임시 저장
  482. //this.toolStripButtonCompleteSaveToServer.Enabled = isIssuable; // 완료 저장
  483. }
  484. /// <summary>
  485. /// 동의서 상태에 따라 버튼들 활성화를 조절한다
  486. /// </summary>
  487. public override void SetEnableButtonsByCurrentConsent() {
  488. string state = string.Empty;
  489. if (this.CurrentPreviewConsent != null) {
  490. state = this.CurrentPreviewConsent.ConsentState;
  491. }
  492. if (this.CurrentTargetPatient != null && !string.IsNullOrEmpty(this.CurrentTargetPatient.pid)
  493. && CurrentPreviewConsent != null) {
  494. if (!ConsentMainControl.HasMultipleMonitor) {
  495. this.toolStripButtonTempSaveToServer.Enabled = true;
  496. this.toolStripButtonSaveToServer.Enabled = true;
  497. //this.toolStripButtonCompleteSaveToServer.Enabled = true;
  498. //this.toolStripButtonPrint.Enabled = true;
  499. SetEnableButtonsByConsentStateForSingleView(state);
  500. this.EnablePenDrawing = true;
  501. this.EnablePenConfig = true;
  502. } else {
  503. //this.toolStripButtonCompleteSaveToServer.Enabled = true;
  504. this.toolStripButtonSaveToServer.Enabled = true;
  505. this.toolStripButtonExecute.Enabled = true;
  506. //this.toolStripButtonPrint.Enabled = true;
  507. SetEnableButtonsByConsentStateForDualView(state);
  508. }
  509. this.toolStripButtonDelAllDraw.Enabled = true;
  510. this.toolStripButtonRedo.Enabled = true;
  511. this.toolStripButtonUndo.Enabled = true;
  512. } else {
  513. //this.toolStripButtonPrint.Enabled = false;
  514. this.toolStripButtonTempSaveToServer.Enabled = false;
  515. this.toolStripButtonCompleteSaveToServer.Enabled = false;
  516. this.toolStripButtonSaveToServer.Enabled = false;
  517. this.toolStripButtonDelAllDraw.Enabled = false;
  518. this.toolStripButtonRedo.Enabled = false;
  519. this.toolStripButtonUndo.Enabled = false;
  520. }
  521. }
  522. /// <summary>
  523. /// Dual Viewer 활성화 시 버튼 활성화 설정
  524. /// </summary>
  525. /// <param name="enabled">활성화 여부</param>
  526. public override void SetEnablementExecuteWhenDualViewerActive(bool enabled) {
  527. // 전자동의서 실행 버튼
  528. this.toolStripButtonExecute.Enabled = enabled;
  529. // 출력 버튼
  530. //this.toolStripButtonPrint.Enabled = enabled;
  531. if (enabled) {
  532. if (this.CurrentPreviewConsent != null && this.CurrentPreviewConsent.OutputType != null) {
  533. if (this.CurrentPreviewConsent.OutputType.Equals("ELECTRONIC")) {
  534. //this.toolStripButtonPrint.Enabled = !enabled;
  535. }
  536. }
  537. }
  538. // Dual Viewer 닫기 버튼
  539. this.toolStripButtonCloseDualViewer.Visible = !enabled;
  540. SetEnableByUserType();
  541. base.SetEnablementExecuteWhenDualViewerActive(enabled);
  542. }
  543. /// <summary>
  544. /// 동의서 상태에 따른 Dual view 상태의 버튼 설정
  545. /// </summary>
  546. /// <param name="state">The state.</param>
  547. private void SetEnableButtonsByConsentStateForDualView(string state) {
  548. if (state.Equals("PAPER_OUT")) {
  549. this.toolStripButtonExecute.Enabled = false;
  550. } else if (state.Equals("ELECTR_CMP") || state.Equals("CERTIFY_CMP")) {
  551. this.toolStripButtonExecute.Enabled = false;
  552. //this.toolStripButtonPrint.Enabled = false;
  553. }
  554. if (this.CurrentPreviewConsent.RewriteConsentMstRid > 0) {
  555. this.toolStripButtonExecute.Enabled = true;
  556. }
  557. }
  558. /// <summary>
  559. /// 동의서 상태에 따른 Single view 상태의 버튼 설정
  560. /// </summary>
  561. /// <param name="state">The state.</param>
  562. private void SetEnableButtonsByConsentStateForSingleView(string state) {
  563. if (state.Equals("PAPER_OUT")) {
  564. this.toolStripButtonSaveToServer.Enabled = false;
  565. this.toolStripButtonCompleteSaveToServer.Enabled = false;
  566. this.toolStripButtonTempSaveToServer.Enabled = false;
  567. this.toolStripButtonExecute.Enabled = false;
  568. } else if (state.Equals("ELECTR_CMP") || state.Equals("CERTIFY_CMP")) {
  569. this.toolStripButtonTempSaveToServer.Enabled = false;
  570. this.toolStripButtonCompleteSaveToServer.Enabled = false;
  571. this.toolStripButtonSaveToServer.Enabled = false;
  572. //this.toolStripButtonPrint.Enabled = false;
  573. }
  574. if (this.CurrentPreviewConsent.RewriteConsentMstRid > 0) {
  575. this.toolStripButtonTempSaveToServer.Enabled = true;
  576. //this.toolStripButtonCompleteSaveToServer.Enabled = true;
  577. this.toolStripButtonSaveToServer.Enabled = true;
  578. }
  579. }
  580. /// <summary>
  581. /// 미작성 동의서 삭제
  582. /// </summary>
  583. /// <param name="reasonForUseN"></param>
  584. public override int DeleteRecordOfDeleteConsent(string reasonForUseN) {
  585. return SaveDataForDeleteConsent(reasonForUseN);
  586. }
  587. /// <summary>
  588. /// 출력된 동의서를 저장
  589. /// </summary>
  590. /// <param name="reasonForUseN">The reason for use n.</param>
  591. //private void SaveDataForPrintedConsent(string reasonForUseN) {
  592. public void SaveDataForPrintedConsent(string reasonForUseN) {
  593. string consentOutputType = this.CurrentPreviewConsent.OutputType;
  594. string consentState = this.CurrentPreviewConsent.ConsentState;
  595. //int result = -1;
  596. //인쇄(바코드제외)인 경우 CONSENT_MST에 데이터를 입력하지 않는다.
  597. if ((!string.IsNullOrEmpty(consentOutputType) && consentOutputType.Equals("PAPER_EXCEPT_BARCODE"))) {
  598. //return result;
  599. return;
  600. }
  601. // 다중 출력 시
  602. if (consentOutputType != null && consentOutputType.Equals("MULTI")) {
  603. Cursor currentCursor = this.Cursor;
  604. try {
  605. this.Cursor = Cursors.WaitCursor;
  606. List<PatListVO> volist = consentMain.PatientListCtrl.GetSelectedPatientList();
  607. string[] strOcrCd = null;
  608. if (this.CurrentPreviewConsent.MultiOcrcode.Length > 0) {
  609. strOcrCd = this.CurrentPreviewConsent.MultiOcrcode.Split('^');
  610. }
  611. string[] strMainDrIdCd = null;
  612. if (this.CurrentPreviewConsent.MultiMainDrIdCd.Length > 0) {
  613. strMainDrIdCd = this.CurrentPreviewConsent.MultiMainDrIdCd.Split('^');
  614. }
  615. int lastRid = -1;
  616. for (int i = 0; i < volist.Count; i++) {
  617. PatientVO vo = GetPatientByPatList(volist[i]);
  618. string userId = CurrentEndUser.userId;
  619. string hosType = consentMain.ConsentExecuteInfo["dutinstcd"];
  620. string userName = CurrentEndUser.userName;
  621. string patientCode = vo.pid;
  622. string clnDeptCode = vo.ordDeptCd;
  623. string vistType = vo.ordType;
  624. string clnDate = vo.inDd.Replace("-", "");
  625. int rewriteConsentMstRid = 0;
  626. string ward = vo.ward;
  627. string roomcd = vo.roomCd;
  628. string formRid = CurrentPreviewConsent.FormRid;
  629. string formCd = CurrentPreviewConsent.FormCd;
  630. string consentMstRid = CurrentPreviewConsent.ConsentMstRid;
  631. // 처방 번호
  632. //int orderNo = vo.IO_OrderNo;
  633. // 진단 코드
  634. //string orderCode = vo.IO_Dx;
  635. string orderName = vo.diagHngNm;
  636. string ocrCode = (strOcrCd != null && !string.IsNullOrEmpty(strOcrCd[i])) ? strOcrCd[i] : CurrentPreviewConsent.Ocrcode;
  637. string mainDrId = (strMainDrIdCd != null && !string.IsNullOrEmpty(strMainDrIdCd[i])) ? strMainDrIdCd[i] : currentTargetPatient.mainDrId;
  638. int cretno = vo.cretNo;
  639. //int.TryParse(vo.cretNo, out int cretno);
  640. ConvertStringToInt(formRid, consentMstRid, out int formRidInt, out int consentMstRidInt);
  641. string deviceIdentNo = System.Environment.MachineName;
  642. // 동의서 프린트 출력 후 데이터를 저장
  643. consentMstRidInt = consentWebService.SavePrintOut(userId
  644. , patientCode
  645. , clnDeptCode
  646. , formRidInt
  647. , formCd
  648. , consentMstRidInt
  649. , rewriteConsentMstRid
  650. , null
  651. , null
  652. , "PRT"
  653. , deviceIdentNo
  654. , vistType
  655. , hosType
  656. , clnDate
  657. , ward
  658. , roomcd
  659. , 0 // orderNo 경대병원 사용하지 않음
  660. , "" // orderName 경대병원 사용하지 않음
  661. , "" // orderCode 경대병원 사용하지 않음
  662. , ocrCode
  663. , cretno
  664. , userName
  665. , userName
  666. , mainDrId
  667. , CurrentEndUser.deptcd
  668. , consentMain.GetTotalPageCount().ToString()
  669. , "P"
  670. , "PC"
  671. , CurrentTargetPatient.OpRsrvNo);
  672. lastRid = consentMstRidInt;
  673. //result = lastRid;
  674. }
  675. this.consentMain.ConsentListCtrl.InquiryConsentData(lastRid);
  676. // dbs227,
  677. // 출력 모드가 아닐때는 초기화 하지 않는다.
  678. //if (!this.consentMain.ConsentExecuteInfo["printYN"].Equals("Y"))
  679. //{
  680. //this.consentMain.ConsentListCtrl.InquiryConsentData(lastRid);
  681. //}
  682. this.consentMain.multiPrintExecCnt++;
  683. } catch (Exception ex) {
  684. throw ex;
  685. } finally {
  686. this.Cursor = currentCursor;
  687. }
  688. consentMain.PatientListCtrl.SetClearCheckBox();
  689. consentMain.ReInitializeViewer();
  690. } else {
  691. if (this.CurrentTargetPatient != null && !string.IsNullOrEmpty(this.CurrentTargetPatient.pid)) {
  692. string userId = CurrentEndUser.userId;
  693. string instcd = consentMain.ConsentExecuteInfo["dutinstcd"];
  694. string userName = CurrentEndUser.userName;
  695. string pid = CurrentTargetPatient.pid;
  696. string clnDeptCode = CurrentTargetPatient.clnDeptCode;
  697. string ordtype = CurrentTargetPatient.ordtype;
  698. string clnDate = CurrentTargetPatient.clnDate.Replace("-", "");
  699. string ward = CurrentTargetPatient.ward;
  700. string roomcd = currentTargetPatient.roomno;
  701. int orderNo = CurrentTargetPatient.orderno;
  702. string orderCode = CurrentTargetPatient.opDeptCd;
  703. string orderName = CurrentTargetPatient.opDeptNm;
  704. string mainDrId = CurrentTargetPatient.mainDrId;
  705. string formRid = CurrentPreviewConsent.FormRid;
  706. string formCd = CurrentPreviewConsent.FormCd;
  707. string consentMstRid = CurrentPreviewConsent.ConsentMstRid;
  708. string ocrCode = CurrentPreviewConsent.Ocrcode;
  709. int cretno = 0;
  710. int.TryParse(CurrentTargetPatient.cretno, out cretno);
  711. ConvertStringToInt(formRid, consentMstRid, out int formRidInt, out int consentMstRidInt);
  712. int reissueConsentMstRid = 0;
  713. string deviceIdentNo = System.Environment.MachineName;
  714. Cursor currentCursor = this.Cursor;
  715. try {
  716. this.Cursor = Cursors.WaitCursor;
  717. // 동의서 프린트 출력 후 데이터를 저장
  718. consentMstRidInt = consentWebService.SavePrintOut(userId
  719. , pid
  720. , clnDeptCode
  721. , formRidInt
  722. , formCd
  723. , consentMstRidInt
  724. , reissueConsentMstRid
  725. , null
  726. , null
  727. , "PRT"
  728. , deviceIdentNo
  729. , ordtype
  730. , instcd
  731. , clnDate
  732. , ward
  733. , roomcd
  734. , orderNo
  735. , orderName
  736. , orderCode
  737. , ocrCode
  738. , cretno
  739. , userName
  740. , userName
  741. , mainDrId
  742. , currentEndUser.deptcd
  743. , consentMain.GetTotalPageCount().ToString()
  744. , "P"
  745. , "PC"
  746. , CurrentTargetPatient.OpRsrvNo);
  747. this.consentMain.ConsentListCtrl.InquiryConsentData(consentMstRidInt);
  748. this.consentMain.multiPrintExecCnt++;
  749. //result = consentMstRidInt;
  750. } catch (Exception ex) {
  751. throw ex;
  752. } finally {
  753. this.Cursor = currentCursor;
  754. }
  755. }
  756. }
  757. //return result;
  758. }
  759. /// <summary>
  760. /// 출력 히스토리 삭제
  761. /// </summary>
  762. public void erasePrintHistory() {
  763. String consentMstRid = CurrentPreviewConsent.ConsentMstRid;
  764. String ocrCode = CurrentPreviewConsent.Ocrcode;
  765. String instcd = consentMain.ConsentExecuteInfo["dutinstcd"];
  766. String pid = CurrentTargetPatient.pid;
  767. Cursor currentCursor = this.Cursor;
  768. try {
  769. this.Cursor = Cursors.WaitCursor;
  770. consentWebService.updatePrintHistory(pid, ocrCode, instcd);
  771. } catch (Exception ex) {
  772. throw ex;
  773. } finally {
  774. this.Cursor = currentCursor;
  775. }
  776. }
  777. /// <summary>
  778. /// 환자리스트의 한 환자의 상세정보를 조회한다
  779. /// </summary>
  780. /// <param name="patvo">조회할 환자의 PatListVO 인스턴스</param>
  781. /// <returns></returns>
  782. private PatientVO GetPatientByPatList(PatListVO patvo) {
  783. string indd = string.Empty;
  784. if (!string.IsNullOrEmpty(patvo.inDd)) indd = patvo.inDd.Replace("/", "").Replace("-", "");
  785. PatientVO[] patientVOList = this.hospitalWebService.GetPatientInfo(patvo.pid
  786. , indd
  787. , patvo.ordType
  788. , patvo.ordDeptCd
  789. , patvo.cretNo.ToString()
  790. , this.consentMain.ConsentExecuteInfo["dutinstcd"]
  791. , this.consentMain.ConsentExecuteInfo["opRsrvNo"]);
  792. if (patientVOList == null || patientVOList.Length == 0) {
  793. return null;
  794. } else {
  795. return patientVOList[0];
  796. }
  797. }
  798. /// <summary>
  799. /// 삭제 사유와 함께 전자동의서 삭제
  800. /// </summary>
  801. /// <param name="reasonForUseN">삭제할 사유</param>
  802. private int SaveDataForDeleteConsent(string reasonForUseN) {
  803. string userId = CurrentEndUser.userId;
  804. string patientCode = CurrentTargetPatient.pid;
  805. string clnDeptCd = CurrentTargetPatient.clnDeptCode;
  806. string ward = CurrentTargetPatient.ward;
  807. string roomcd = CurrentTargetPatient.roomno;
  808. string formRid = CurrentPreviewConsent.FormRid;
  809. string consentMstRid = CurrentPreviewConsent.ConsentMstRid;
  810. string consentState = CurrentPreviewConsent.ConsentState;
  811. int rewriteConsentMstRid = CurrentPreviewConsent.RewriteConsentMstRid;
  812. ConvertStringToInt(formRid, consentMstRid, out int formRidInt, out int consentMstRidInt);
  813. int.TryParse(CurrentTargetPatient.cretno, out int cretno);
  814. int reissueConsentMstRidInt = CurrentPreviewConsent.ReissueConsentMstRid;
  815. string deviceIdentNo = System.Environment.MachineName;
  816. ConsentSvcRef.SingleReturnData result = this.consentWebService.saveDelete(userId, consentMstRid, reasonForUseN);
  817. return Convert.ToInt32(result.responseData);
  818. // TODO 추후 구현
  819. //this.consentWebService.SaveDelete(userId
  820. // , consentMstRidInt
  821. // , patientCode
  822. // , clnDeptCd
  823. // , ward
  824. // , roomcd
  825. // , formRidInt
  826. // , CurrentPreviewConsent.FormCd
  827. // , rewriteConsentMstRid
  828. // , reissueConsentMstRidInt
  829. // , consentState
  830. // , deviceIdentNo
  831. // , CurrentTargetPatient.ordtype
  832. // , consentMain.ConsentExecuteInfo["dutinstcd"]
  833. // , CurrentTargetPatient.clnDate
  834. // , reasonForUseN
  835. // , CurrentPreviewConsent.Ocrcode
  836. // , cretno
  837. // , currentEndUser.deptcd
  838. // , consentMain.GetTotalPageCount().ToString()
  839. // , "CP"
  840. // , "P");
  841. }
  842. private void SetHasMedicalHistoryInConsent(string patientCode) {
  843. this.CurrentPreviewConsent.HasMedicalHistory = false;
  844. }
  845. /// <summary>
  846. /// 동의서 뷰어에 동의서 로드
  847. /// </summary>
  848. public void RunConsentDualView() {
  849. bool runDualView = true;
  850. if(this.CurrentPreviewConsent == null) {
  851. return;
  852. }
  853. if (this.CurrentEndUser != null && this.CurrentPreviewConsent != null
  854. && !string.IsNullOrEmpty(this.CurrentPreviewConsent.PrintOnly)
  855. && this.CurrentPreviewConsent.PrintOnly.Equals("Y")
  856. ) {
  857. runDualView = false;
  858. }
  859. // 출력 상태일 경우 재출력만 가능하도록 버튼 조정
  860. if (this.CurrentEndUser != null && this.CurrentPreviewConsent != null
  861. && !string.IsNullOrEmpty(this.CurrentPreviewConsent.ConsentState)
  862. && (this.CurrentPreviewConsent.ConsentState.ToUpper().Equals("PAPER_OUT"))) {
  863. runDualView = false;
  864. }
  865. //현재 프로그램이 실행되고 있는정보 가져오기: 디버깅 모드라면 bin/debug/프로그램명.exe
  866. FileInfo exefileinfo = new FileInfo(Path.GetDirectoryName(Application.StartupPath));
  867. // AppDomain.CurrentDomain.DynamicDirectory
  868. // Server.MapPath("~")
  869. string path = Path.GetDirectoryName(Application.StartupPath);//@"C:\eForm Server\Consent-Web-Server-CNUH\";// HttpContext.Current.Request.PhysicalApplicationPath;
  870. string fileName = @"\config.ini"; //파일명
  871. //만약 현재 실행 되는 경로가 아닌 특정한 위치를 원한다면 위에 과정 상관없이 바로 경로셋팅 해 주면 된다. (예: c:\config.ini)
  872. string filePath = path + fileName; //ini 파일 경로
  873. iniUtil ini = new iniUtil(filePath); // 만들어 놓았던 iniUtil 객체 생성(생성자 인자로 파일경로 정보 넘겨줌)
  874. //이제 ini 객체를 이용해 맘것 사용하면 된다.
  875. string sMoniterNumber = ini.GetIniValue("DCMC", "MONITER_NUMBER");
  876. if (sMoniterNumber.Equals("0")) {
  877. return;
  878. }
  879. // 동의서 로드 전 consent_mst_rid에 해당하는 동의서가 상위 상태값이 있는지 체크
  880. //int state = this.consentWebService.CheckConsentState(int.Parse(this.CurrentPreviewConsent.ConsentMstRid),
  881. // this.CurrentPreviewConsent.ConsentState);
  882. //if (state == 1) {
  883. // return;
  884. //}
  885. // 출력만 가능하거나 출력상태일 경우 듀얼뷰어 실행 못하도록 적용
  886. if (runDualView) this.consentMain.RunConsentDualView();
  887. }
  888. /// <summary>
  889. /// 인증저장 된 동의서를 보여준다
  890. /// </summary>
  891. /// <param name="consentMain">The consent main.</param>
  892. public void ShowCompleteConsent(IConsentMain consentMain) {
  893. //SetEnableButtonsByCurrentConsent();
  894. consentMain.ReviewConsent();
  895. ConsentImageVO[] cImage = this.consentWebService.GetConsentImage(this.CurrentPreviewConsent.ConsentMstRid);
  896. if(cImage == null || cImage.Length == 0) {
  897. MessageBox.Show("검색된 이미지가 없습니다.", "경고", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  898. return;
  899. }
  900. CLIP.eForm.ImageView.ImageViewCtrl iViewer = consentMain.GetImageViewerCtrl();
  901. List<string> lStr = new List<string>();
  902. //string sPath = this.consentMain.PluginExecuteInfo["imageUploadPath"] + "/DataTempImage/";
  903. string sPath = consentMain.PluginExecuteInfo["baseConsentSvcURL"] + cImage[0].imagePath + "/";
  904. string sLocal = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\Clipsoft\ClipSoft.eForm.Viewer\DataTemp\";
  905. DirectoryInfo di = new DirectoryInfo(sLocal);
  906. if (di.Exists == false) {
  907. di.Create();
  908. }
  909. foreach (ConsentImageVO img in cImage) {
  910. if (File.Exists(sLocal + img.imageFilename)) {
  911. Image imgTemp = Image.FromFile(sLocal + img.imageFilename);
  912. lStr.Add(ImageToBase64(imgTemp, System.Drawing.Imaging.ImageFormat.Jpeg));
  913. imgTemp.Dispose();
  914. } else {
  915. string orgFile = img.imagePath + "\\" + img.imageFilename;
  916. string tempImgNm = orgFile.Substring(orgFile.IndexOf("\\") + 1).Replace("\\", "");
  917. using (WebClient myWebClient = new WebClient()) {
  918. myWebClient.DownloadFile(sPath + img.imageFilename, sLocal + img.imageFilename);
  919. if (File.Exists(sLocal + img.imageFilename)) {
  920. Image imgTemp = Image.FromFile(sLocal + img.imageFilename);
  921. lStr.Add(ImageToBase64(imgTemp, System.Drawing.Imaging.ImageFormat.Jpeg));
  922. imgTemp.Dispose();
  923. } else {
  924. break;
  925. }
  926. }
  927. }
  928. }
  929. // 이미지 생성이 완료되면 이미지를 보여준다
  930. iViewer.Show();
  931. iViewer.SetBase64Images(lStr);
  932. // if (lStr.Count > 0)
  933. iViewer.Show();
  934. iViewer.SetBase64Images(lStr);
  935. //} else {
  936. // // 검색된 이미지가 없습니다.
  937. //}
  938. }
  939. /// <summary>
  940. /// 이미지를 BASE64 로 인코딩
  941. /// </summary>
  942. /// <param name="image">변환할 이미지</param>
  943. /// <param name="format">저장할 이미지 포멧</param>
  944. /// <returns></returns>
  945. public string ImageToBase64(Image image, System.Drawing.Imaging.ImageFormat format) {
  946. using (MemoryStream ms = new MemoryStream()) {
  947. // Convert Image to byte[]
  948. image.Save(ms, format);
  949. byte[] imageBytes = ms.ToArray();
  950. // Convert byte[] to Base64 String
  951. string base64String = Convert.ToBase64String(imageBytes);
  952. return base64String;
  953. }
  954. }
  955. /// <summary>
  956. /// 동의서 미리 보기
  957. /// </summary>
  958. /// <param name="consentMain">미리보기할 동의서가 있는 인스턴스</param>
  959. public void PreviewConsent(IConsentMain consentMain) {
  960. // 근무지기관별 공통파라미터를 설정
  961. Dictionary<FOSParameter, string> globalParams = Common.CreateGlobalParamsDictionary(consentMain.ConsentExecuteInfo["dutinstcd"]);
  962. if (SetPatientAndUser(globalParams) < 0) {
  963. return;
  964. }
  965. globalParams[FOSParameter.LIST_OCRCODE] = CurrentPreviewConsent.Ocrcode = GetOcrCode(); // OCR 코드
  966. globalParams[FOSParameter.GLOBAL_MAIN_DR1_NM] = CurrentTargetPatient.mainDrNm; // maindrname
  967. //globalParams[FOSParameter.Device] = "PC";
  968. //globalParams[FOSParameter.PrintTime] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  969. //globalParams[FOSParameter.SignTime] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  970. globalParams[FOSParameter.GLOBAL_USER_IP] = consentMain.ConsentExecuteInfo["printIP"];
  971. List<Common.FormObject> forms = new List<FormObject>();
  972. forms.Add(new FormObject { formId = CurrentPreviewConsent.FormRid ?? "-1", formNm = CurrentPreviewConsent.FormName, consentMstRid = CurrentPreviewConsent.ConsentMstRid ?? "-1" });
  973. string fosNew = Common.getNewFosString(consentMain.PluginExecuteInfo["formServiceUrl"], globalParams, null, new List<String> { CurrentPreviewConsent.FormRid });
  974. int state = this.consentWebService.CheckConsentState(int.Parse(CurrentPreviewConsent.ConsentMstRid), CurrentPreviewConsent.ConsentState);
  975. if (state == 1) {
  976. MessageBoxDlg.Show(this, "이미 저장된 서식 입니다."
  977. , string.Format(Properties.Resources.msg_caption_confirm),
  978. MessageBoxButtons.OK, MessageBoxIcon.Information);
  979. return;
  980. }
  981. consentMain.PreviewConsent(fosNew);
  982. //consentMain.PreviewConsent(fos);//서식을 열도록 fos을 던짐
  983. // dbs227, 대가대 병원 UserDrFlag 사용하지 않음
  984. // 외래 환자 외에는 작성 완료(확인) 버튼 안보이게 설정
  985. //if (CurrentTargetPatient.ordtype.Equals("O") && CurrentPreviewConsent.UserDrFlag.Equals("Y")) {
  986. // toolStripButtonCompleteSaveToServer.Visible = true;
  987. //} else {
  988. // toolStripButtonCompleteSaveToServer.Visible = false;
  989. //}
  990. consentMain.ConsentCommandCtrl.SetEnableConsentIssueCommands(true);
  991. consentMain.ConsentCommandCtrl.SetEnableButtonsByCurrentConsent();
  992. SetEnableByUserType();
  993. }
  994. /// <summary>
  995. /// 현재 동의서의 OCR 코드를 가져온다. OCR 코드가 존재하지 않으면 서버로부터 얻어온다
  996. /// </summary>
  997. /// <returns>OCR 코드</returns>
  998. public string GetOcrCode() {
  999. string strOcrCode = "";
  1000. if (this.CurrentPreviewConsent != null
  1001. && !string.IsNullOrEmpty(this.CurrentPreviewConsent.Ocrcode)) {
  1002. strOcrCode = this.CurrentPreviewConsent.Ocrcode;
  1003. }
  1004. // OCR 코드가 없으면 서버로 부터 받아온다
  1005. else {
  1006. strOcrCode = hospitalWebService.GetOcrTag().responseData;
  1007. }
  1008. return strOcrCode;
  1009. }
  1010. /// <summary>
  1011. /// changingGlobalParams Dataset 에 FOS 파라미터의 name 과 value 를 설정한다
  1012. /// </summary>
  1013. /// <param name="globalParams"></param>
  1014. public int SetPatientAndUser(Dictionary<FOSParameter, string> globalParams) {
  1015. int retValue = 0;
  1016. Dictionary<FOSParameter, string> changingGlobalParams = new Dictionary<FOSParameter, string>();
  1017. if (CurrentPreviewConsent == null) {
  1018. MessageBox.Show("동의서 정보가 없습니다.");
  1019. //return -1;
  1020. throw new Exception("동의서 정보가 없습니다.");
  1021. retValue = -1;
  1022. }
  1023. if (CurrentTargetPatient == null || string.IsNullOrEmpty(this.CurrentTargetPatient.pid)) {
  1024. MessageBox.Show("환자 정보가 없습니다.");
  1025. //return -1;
  1026. throw new Exception("환자 정보가 없습니다.");
  1027. retValue = -1;
  1028. }
  1029. if (CurrentEndUser == null) {
  1030. MessageBox.Show("사용자 정보가 없습니다.");
  1031. //return -1;
  1032. throw new Exception("사용자 정보가 없습니다.");
  1033. retValue = -1;
  1034. }
  1035. // 동의서 정보
  1036. changingGlobalParams[FOSParameter.LIST_FORM_NM] = this.CurrentPreviewConsent.FormPrintName;
  1037. // 환자 정보
  1038. //changingGlobalParams[FOSParameter.ImageUploadPath] = this.consentMain.PluginExecuteInfo["imageUploadPath"] + "/";
  1039. changingGlobalParams[FOSParameter.GLOBAL_USER_NM] = this.currentEndUser.userName;
  1040. changingGlobalParams[FOSParameter.GLOBAL_PATIENT_ID] = this.CurrentTargetPatient.pid;
  1041. changingGlobalParams[FOSParameter.GLOBAL_PATIENT_ORDTYPE] = this.CurrentTargetPatient.ordtypeHngnm;
  1042. changingGlobalParams[FOSParameter.GLOBAL_PATIENT_SEXAGE] = this.CurrentTargetPatient.sa;
  1043. changingGlobalParams[FOSParameter.GLOBAL_PATIENT_NM] = this.CurrentTargetPatient.name;
  1044. changingGlobalParams[FOSParameter.GLOBAL_IS_PRINT_MODE] = "N";
  1045. changingGlobalParams[FOSParameter.GLOBAL_PATIENT_RRN] = this.CurrentTargetPatient.jumin;
  1046. changingGlobalParams[FOSParameter.GLOBAL_PATIENT_ROOM_NO] = this.CurrentTargetPatient.ward;
  1047. changingGlobalParams[FOSParameter.GLOBAL_PATIENT_ROOM_NO] = this.CurrentTargetPatient.roomno;
  1048. //changingGlobalParams[FOSParameter.GLOBAL_PATIENT_CLN_DATE] = SetDateFormatting(this.CurrentTargetPatient.clnDate.Replace("-", "").Replace("/", ""));
  1049. changingGlobalParams[FOSParameter.GLOBAL_PATIENT_CLN_DATE] = this.CurrentTargetPatient.clnDate.Replace("-", "").Replace("/", "");
  1050. changingGlobalParams[FOSParameter.GLOBAL_PATIENT_CLN_DEPT_NM] = this.CurrentTargetPatient.clnDeptName;
  1051. //changingGlobalParams[FOSParameter.MainDoctor] = this.CurrentTargetPatient.MainDrNm;
  1052. changingGlobalParams[FOSParameter.GLOBAL_PATIENT_ADDRESS] = this.CurrentTargetPatient.addr;
  1053. changingGlobalParams[FOSParameter.GLOBAL_PATIENT_MPPHONENO] = this.CurrentTargetPatient.telno;
  1054. //changingGlobalParams[FOSParameter.GLOBAL_PATIENT_TEL_NO] = this.CurrentTargetPatient.telno;
  1055. //changingGlobalParams[FOSParameter.patient] = this.CurrentTargetPatient.Insukind; // 확인 필요
  1056. changingGlobalParams[FOSParameter.GLOBAL_PATIENT_CLN_DEPT_CD] = this.CurrentTargetPatient.clnDeptEngNm;
  1057. changingGlobalParams[FOSParameter.GLOBAL_DIAG_HNGNM] = this.CurrentTargetPatient.OpDiagName;
  1058. changingGlobalParams[FOSParameter.GLOBAL_OP_RSRV_NO] = this.CurrentTargetPatient.OpRsrvNo;
  1059. changingGlobalParams[FOSParameter.GLOBAL_OPNM] = this.CurrentTargetPatient.OpName;
  1060. changingGlobalParams[FOSParameter.GLOBAL_OPREMFACT] = this.CurrentTargetPatient.OpremFact;
  1061. // 환자의 생년월일 입력, DB 에서 가져올 때 어떤 값을 가져오는 지
  1062. if (!string.IsNullOrEmpty(this.CurrentTargetPatient.jumin) && this.CurrentTargetPatient.jumin.Length > 6) {
  1063. // 주석 처리 yyyy-MM-dd
  1064. string parBirthDd = this.CurrentTargetPatient.birthDd ?? string.Empty;
  1065. if (!string.IsNullOrEmpty(parBirthDd)) {
  1066. parBirthDd = DateTime.ParseExact(parBirthDd, "yyyyMMdd", null).ToString("yyyy-MM-dd");
  1067. }
  1068. changingGlobalParams[FOSParameter.GLOBAL_PATIENT_BIRTHDAY] = parBirthDd;
  1069. //changingGlobalParams[FOSParameter.GLOBAL_PATIENT_BIRTHDAY] = this.CurrentTargetPatient.jumin.Substring(0, 6);
  1070. }
  1071. //if (string.IsNullOrEmpty(changingGlobalParams[FOSParameter.DiagName])) {
  1072. // if (!string.IsNullOrEmpty(consentMain.ConsentExecuteInfo["clnDxNm"])) {
  1073. // changingGlobalParams[FOSParameter.DiagName] = consentMain.ConsentExecuteInfo["clnDxNm"];
  1074. // }
  1075. //}
  1076. // 대구가톨릭대학교병원 요청사항
  1077. // 사용자가 입력한 진단명 수술명을 서식에 파라미터 필드로 전달한다
  1078. if (string.IsNullOrEmpty(changingGlobalParams[FOSParameter.GLOBAL_DIAG_HNGNM])) {
  1079. changingGlobalParams[FOSParameter.GLOBAL_DIAG_HNGNM] = this.CurrentTargetPatient.clnDxNm;/*사용자가 입력한 진단명*/
  1080. }
  1081. if (string.IsNullOrEmpty(changingGlobalParams[FOSParameter.GLOBAL_OPNM])) {
  1082. changingGlobalParams[FOSParameter.GLOBAL_OPNM] = this.CurrentTargetPatient.OpName;/*사용자가 입력한 수술명*/
  1083. }
  1084. changingGlobalParams[FOSParameter.GLOBAL_OPREMFACT] = this.CurrentTargetPatient.OpremFact;/*사용자가 입력한 진단명*/
  1085. // 설명일 (수술 확정일)
  1086. changingGlobalParams[FOSParameter.GLOBAL_OPCNFMDD] = this.CurrentTargetPatient.OpCnfmDate;
  1087. //consentMain.SetConsentUserInfo(consentMain.ConsentExecuteInfo["dutinstcd"], id, deptCd);
  1088. // 외래일 경우 emr.mmbdhrcd.hardcdno = 6920 에 지정된 서식외에는 사용자를 진료의로 변경한다.
  1089. if (CurrentTargetPatient.ordtype.Equals("O")) {
  1090. //consentMain.SetConsentUserInfo(consentMain.ConsentExecuteInfo["dutinstcd"]
  1091. // , CurrentTargetPatient.mainDrId
  1092. // , currentTargetPatient.clnDeptCode); // 외래 진료의는 근무 부서 이외의 과의 처방을 낼 수 없다.
  1093. } else if (!CurrentEndUser.userId.Equals(consentMain.ConsentExecuteInfo["loginUserId"])) {
  1094. // // 로그인 사용자와 다른 경우 재조회
  1095. // consentMain.SetConsentUserInfo(consentMain.ConsentExecuteInfo["dutinstcd"]
  1096. // , consentMain.ConsentExecuteInfo["loginUserId"]
  1097. // , consentMain.ConsentExecuteInfo["userDeptCd"]);
  1098. }
  1099. string jobKindCd = !string.IsNullOrEmpty(currentEndUser.jobkindcd) ? currentEndUser.jobkindcd.Substring(0, 2) : "00";
  1100. // 설명의사
  1101. // 로그인 한 사용자가 의사직종이라면 설명의사로 매핑한다.
  1102. var explDocId = "";
  1103. var explDocNm = "";
  1104. if (currentEndUser.jobkindcd.Substring(0, 2).Equals("03") || currentEndUser.jobkindcd.Substring(0, 2).Equals("06")) {
  1105. explDocId = CurrentEndUser.userId;
  1106. explDocNm = CurrentEndUser.userName;
  1107. }
  1108. //else if (CurrentTargetPatient.ordtype.Equals("O")) {
  1109. // explDocId = CurrentTargetPatient.mainDrId;
  1110. // explDocNm = CurrentTargetPatient.mainDrNm;
  1111. //}
  1112. // 사용자의 서명 이미지를 가져온다
  1113. UserSignImageVO vo = this.hospitalWebService.GetSignImage(explDocId, this.consentMain.ConsentExecuteInfo["dutinstcd"]);
  1114. // 설명의사 파라미터 매핑
  1115. if (!string.IsNullOrEmpty(explDocNm)) {
  1116. changingGlobalParams[FOSParameter.GLOBAL_EXPL_DR_NM] = explDocNm;
  1117. }
  1118. // 설명의사 서명
  1119. if (vo != null && vo.SignImage.Length > 0) {
  1120. // 서명 이미지를 BASE64 형식으로 변환한다.
  1121. changingGlobalParams[FOSParameter.GLOBAL_EXPL_DR_SIGN_DATA] = ImageToBase64(byteArrayToImage(vo.SignImage), System.Drawing.Imaging.ImageFormat.Png);
  1122. }
  1123. // 출력할 경우 나타낼 필요가 없는 파라미터는 처리
  1124. if (consentMain.ConsentExecuteInfo["printYN"].Equals("Y")) {
  1125. }
  1126. // 따로 매핑하지 않음
  1127. // 원무 파라미터 설정
  1128. //changingGlobalParams[FOSParameter.SpecDoctorYN] = consentMain.ConsentExecuteInfo["SpecDoctorYN"];
  1129. //changingGlobalParams[FOSParameter.ContStartDate] = consentMain.ConsentExecuteInfo["ContStartDate"];
  1130. //changingGlobalParams[FOSParameter.ContEndDate] = consentMain.ConsentExecuteInfo["ContEndDate"];
  1131. //changingGlobalParams[FOSParameter.RoomCapa] = consentMain.ConsentExecuteInfo["RoomCapa"];
  1132. //changingGlobalParams[FOSParameter.ContTelNo] = consentMain.ConsentExecuteInfo["ContTelNo"];
  1133. //changingGlobalParams[FOSParameter.ContStaff1Name] = consentMain.ConsentExecuteInfo["ContStaff1Name"];
  1134. //changingGlobalParams[FOSParameter.ContStaff2Name] = consentMain.ConsentExecuteInfo["ContStaff2Name"];
  1135. //changingGlobalParams[FOSParameter.ContStaff3Name] = consentMain.ConsentExecuteInfo["ContStaff3Name"];
  1136. //changingGlobalParams[FOSParameter.CardNo] = consentMain.ConsentExecuteInfo["CardNo"];
  1137. ChangeGlobalParametersToNew(globalParams, changingGlobalParams);
  1138. return 0;
  1139. }
  1140. /// <summary>
  1141. /// 임시저장 동의서를 보여준다
  1142. /// </summary>
  1143. /// <param name="consentMain"></param>
  1144. public void ShowTempSaveConsent(IConsentMain consentMain) {
  1145. if (string.IsNullOrEmpty(this.CurrentPreviewConsent.ConsentMstRid)
  1146. || this.CurrentPreviewConsent.ConsentMstRid.Equals("-1")) {
  1147. return;
  1148. }
  1149. List<string> formGuids = new List<string>();
  1150. formGuids.Add(this.CurrentPreviewConsent.FormGuid);
  1151. Dictionary<string, string> actionParams = new Dictionary<string, string> {
  1152. { "rid", this.CurrentPreviewConsent.ConsentMstRid }//선택한 리스트의 rid, state
  1153. };
  1154. Dictionary<FOSParameter, string> globalParams = new Dictionary<FOSParameter, string>();
  1155. if (!string.IsNullOrEmpty(this.CurrentPreviewConsent.VisitType)) {
  1156. if (!this.CurrentPreviewConsent.VisitType.Equals("O")) {
  1157. // 빌드를 위한 주석 처리
  1158. //globalParams[FOSParameter.userName] = consentMain.ConsentExecuteInfo["loginUserName"];
  1159. }
  1160. }
  1161. if (!CurrentEndUser.drkind.Equals("C")) {
  1162. globalParams[FOSParameter.GLOBAL_EXPL_DR_NM] = CurrentEndUser.userName;
  1163. // 사용자의 서명 이미지를 가져온다
  1164. UserSignImageVO vo = this.hospitalWebService.GetSignImage(CurrentEndUser.userId, this.consentMain.ConsentExecuteInfo["dutinstcd"]);
  1165. // 설명의사 서명
  1166. if (vo != null && vo.SignImage.Length > 0) {
  1167. // 서명 이미지를 BASE64 형식으로 변환한다.
  1168. globalParams[FOSParameter.GLOBAL_EXPL_DR_SIGN_DATA] = ImageToBase64(byteArrayToImage(vo.SignImage), System.Drawing.Imaging.ImageFormat.Png);
  1169. }
  1170. }
  1171. globalParams[FOSParameter.GLOBAL_MAIN_DR1_NM] = CurrentTargetPatient.mainDrNm;
  1172. string newFos = Common.getNewEptFosString(consentMain.PluginExecuteInfo["formServiceUrl"],
  1173. consentMain.PluginExecuteInfo["baseConsentSvcURL"],
  1174. globalParams,
  1175. new List<String> { CurrentPreviewConsent.FormRid },
  1176. new List<String> { CurrentPreviewConsent.ConsentMstRid });
  1177. //int state = this.consentWebService.CheckConsentState(int.Parse(this.CurrentPreviewConsent.ConsentMstRid), this.CurrentPreviewConsent.ConsentState);
  1178. //if (state == 1) {
  1179. // MessageBoxDlg.Show(this, "이미 저장된 서식 입니다."
  1180. // , string.Format(Properties.Resources.msg_caption_confirm),
  1181. // MessageBoxButtons.OK, MessageBoxIcon.Information);
  1182. // return;
  1183. //}
  1184. consentMain.PreviewConsent(newFos);
  1185. // 외래 환자 외에는 작성 완료(확인) 버튼 안보이게 설정
  1186. if (!CurrentTargetPatient.ordtype.Equals("O")) {
  1187. toolStripButtonCompleteSaveToServer.Visible = false;
  1188. } else {
  1189. toolStripButtonCompleteSaveToServer.Visible = true;
  1190. }
  1191. consentMain.ConsentCommandCtrl.SetEnableConsentIssueCommands(true);
  1192. consentMain.ConsentCommandCtrl.SetEnableButtonsByCurrentConsent();
  1193. SetEnableByUserType();
  1194. }
  1195. private Image byteArrayToImage(byte[] byteArrayIn) {
  1196. MemoryStream ms = new MemoryStream(byteArrayIn);
  1197. Image returnImage = Image.FromStream(ms);
  1198. return returnImage;
  1199. }
  1200. /// <summary>
  1201. /// 동의서 임시 데이터 저장
  1202. /// </summary>
  1203. /// <param name="eptXmlValue"></param>
  1204. /// <param name="dataValue"></param>
  1205. public override void SaveTempConsentData(string eptXmlValue, string dataValue, bool isTempSave2) {
  1206. // 임시 저장 된 서식을 다시 임시 저장
  1207. //int state = this.consentWebService.CheckConsentState(int.Parse(this.CurrentPreviewConsent.ConsentMstRid), this.CurrentPreviewConsent.ConsentState);
  1208. //if (state == 1) {
  1209. // MessageBoxDlg.Show(this, "이미 저장된 서식 입니다."
  1210. // , string.Format(Properties.Resources.msg_caption_confirm),
  1211. // MessageBoxButtons.OK, MessageBoxIcon.Information);
  1212. // return;
  1213. //}
  1214. string userId = CurrentEndUser.userId;
  1215. string userName = CurrentEndUser.userName;
  1216. string pid = CurrentTargetPatient.pid;
  1217. string clnDeptCode = CurrentTargetPatient.clnDeptCode;
  1218. string vistType = CurrentTargetPatient.ordtype;
  1219. string clnDate = CurrentTargetPatient.clnDate.Replace("-", "");
  1220. int rewriteConsentMstRid = 0;
  1221. string ward = CurrentTargetPatient.ward;
  1222. string roomcd = CurrentTargetPatient.roomno;
  1223. string formRid = CurrentPreviewConsent.FormRid;
  1224. string formCd = CurrentPreviewConsent.FormCd;
  1225. string consentMstRid = CurrentPreviewConsent.ConsentMstRid;
  1226. int orderNo = CurrentTargetPatient.orderno;
  1227. string orderCode = CurrentTargetPatient.clnDxCd;
  1228. string orderName = CurrentTargetPatient.clnDxNm;
  1229. string mainDrId = this.CurrentTargetPatient.mainDrId;
  1230. string ocrCode = CurrentPreviewConsent.Ocrcode;
  1231. if (string.IsNullOrEmpty(ocrCode)) {
  1232. ocrCode = CurrentPreviewConsent.Ocrcode = GetOcrCode();
  1233. }
  1234. int.TryParse(CurrentTargetPatient.cretno, out int cretno);
  1235. ConvertStringToInt(formRid, consentMstRid, out int formRidInt, out int consentMstRidInt);
  1236. string deviceIdentNo = Common.getMacAddress();
  1237. var consentState = "TEMP";
  1238. int translateResult = 0;
  1239. string sizeValue = string.Empty;
  1240. string strImgJson = string.Empty;
  1241. if (isTempSave2) {
  1242. // 확인저장 시 이미지 파일을 서버로 전송
  1243. translateResult = TranslateConsentToImageServer(exportedImageFiles, ""/* 확인저장 시 인증저장 정보는 없다*/, out string fileSizes);
  1244. sizeValue = fileSizes;
  1245. consentState = "ELECTR_CMP";
  1246. strImgJson = this.exportedImageFilesJson;
  1247. }
  1248. Cursor currentCursor = this.Cursor;
  1249. try {
  1250. this.Cursor = Cursors.WaitCursor;
  1251. // 임시저장 일때 actkind 는 "T" 로 설정하여 전송한다
  1252. ConsentSvcRef.SingleReturnData result = this.consentWebService.SaveTempData(userId
  1253. , CurrentEndUser.deptcd
  1254. , pid
  1255. , formRid
  1256. , formCd
  1257. , clnDeptCode
  1258. , eptXmlValue
  1259. , dataValue
  1260. , consentMstRidInt
  1261. , rewriteConsentMstRid
  1262. , "PC"
  1263. , deviceIdentNo
  1264. , vistType
  1265. , consentMain.ConsentExecuteInfo["dutinstcd"]
  1266. , clnDate
  1267. , CurrentTargetPatient.Dschdd
  1268. , ward
  1269. , roomcd
  1270. , ocrCode
  1271. , cretno
  1272. , mainDrId
  1273. , consentMain.GetTotalPageCount().ToString()
  1274. , "T"
  1275. , CurrentTargetPatient.OpRsrvNo
  1276. , consentState
  1277. , orderNo
  1278. , orderName
  1279. , orderCode
  1280. , "" // audioFileJson
  1281. , "" // audioFileSize
  1282. , strImgJson // imageFileJson
  1283. , sizeValue // fileSize(Image)
  1284. );
  1285. if (result != null && !string.IsNullOrEmpty(result.responseData)) {
  1286. consentMstRid = result.responseData;
  1287. } else {
  1288. MessageBox.Show("임시저장에 실패하였습니다.");
  1289. }
  1290. // 기왕력 데이터 저장
  1291. // 대가대 병원 사용하지 않음
  1292. //SetNewMedicalHistory(dataValue);
  1293. // 작성 완료 시
  1294. if (m_IsComplete) {
  1295. //MessageBoxDlg.Show(this, string.Format(Properties.Resources.msg_confirm_save_confirm)
  1296. // , string.Format(Properties.Resources.msg_caption_confirm),
  1297. // MessageBoxButtons.OK, MessageBoxIcon.Information);
  1298. // 작성 완료 시는 이력 탭 보기
  1299. this.consentMain.ConsentListCtrl.InquiryConsentData(0);
  1300. } else {
  1301. this.consentMain.ConsentListCtrl.InquiryConsentData(consentMstRidInt);
  1302. // Ku2.0 연동 시에는 메시지를 띄우지 않는다
  1303. if (consentMain.ConsentExecuteInfo["printYN"].Equals("Y")) {
  1304. MessageBoxDlg.Show(this, string.Format(Properties.Resources.msg_temp_save_confirm)
  1305. , string.Format(Properties.Resources.msg_caption_confirm),
  1306. MessageBoxButtons.OK, MessageBoxIcon.Information);
  1307. }
  1308. }
  1309. } catch (Exception ex) {
  1310. throw ex;
  1311. } finally {
  1312. this.Cursor = currentCursor;
  1313. }
  1314. }
  1315. /// <summary>
  1316. /// 현재의 문진기록을 저장한다
  1317. /// </summary>
  1318. /// <param name="dataXml">The data XML.</param>
  1319. private void SetNewMedicalHistory(string dataXml) {
  1320. Dictionary<FOSParameter, string> outputDataDic = DataXmlToDictionary(dataXml);
  1321. // 대가대 사용하지 않는 필드
  1322. //if (outputDataDic.ContainsKey(FOSParameter.BP)) this.CurrentTargetPatient.Ex_bp = outputDataDic[FOSParameter.BP];
  1323. //if (outputDataDic.ContainsKey(FOSParameter.DM)) this.CurrentTargetPatient.Ex_dm = outputDataDic[FOSParameter.DM];
  1324. //if (outputDataDic.ContainsKey(FOSParameter.Heart)) this.CurrentTargetPatient.Ex_heart = outputDataDic[FOSParameter.Heart];
  1325. //if (outputDataDic.ContainsKey(FOSParameter.Kidney)) this.CurrentTargetPatient.Ex_kidney = outputDataDic[FOSParameter.Kidney];
  1326. //if (outputDataDic.ContainsKey(FOSParameter.Respiration)) this.CurrentTargetPatient.Ex_respiration = outputDataDic[FOSParameter.Respiration];
  1327. //if (outputDataDic.ContainsKey(FOSParameter.MedicalHistory)) this.CurrentTargetPatient.Ex_hx = outputDataDic[FOSParameter.MedicalHistory];
  1328. //if (outputDataDic.ContainsKey(FOSParameter.Allergy)) this.CurrentTargetPatient.Ex_allergy = outputDataDic[FOSParameter.Allergy];
  1329. //if (outputDataDic.ContainsKey(FOSParameter.Drug)) this.CurrentTargetPatient.Ex_drug = outputDataDic[FOSParameter.Drug];
  1330. //if (outputDataDic.ContainsKey(FOSParameter.Smoking)) this.CurrentTargetPatient.Ex_smoking = outputDataDic[FOSParameter.Smoking];
  1331. //if (outputDataDic.ContainsKey(FOSParameter.Idiosyncrasy)) this.CurrentTargetPatient.Ex_idio = outputDataDic[FOSParameter.Idiosyncrasy];
  1332. //if (outputDataDic.ContainsKey(FOSParameter.Nacrotics)) this.CurrentTargetPatient.Ex_nacrotics = outputDataDic[FOSParameter.Nacrotics];
  1333. //if (outputDataDic.ContainsKey(FOSParameter.Airway)) this.CurrentTargetPatient.Ex_airway = outputDataDic[FOSParameter.Airway];
  1334. //if (outputDataDic.ContainsKey(FOSParameter.Hemorrhage)) this.CurrentTargetPatient.Ex_hemorrhage = outputDataDic[FOSParameter.Hemorrhage];
  1335. //if (outputDataDic.ContainsKey(FOSParameter.EtcStatus)) this.CurrentTargetPatient.Ex_status_etc = outputDataDic[FOSParameter.EtcStatus];
  1336. }
  1337. /// <summary>
  1338. /// Data XML을 Dictionary 타입으로 변환하여 반환
  1339. /// </summary>
  1340. /// <param name="dataXml">변환될 Data XML</param>
  1341. /// <returns></returns>
  1342. private static Dictionary<FOSParameter, string> DataXmlToDictionary(string dataXml) {
  1343. Dictionary<FOSParameter, string> outputDataDic;
  1344. XmlDocument xmlDocument = new XmlDocument();
  1345. xmlDocument.LoadXml(dataXml);
  1346. outputDataDic = outputDataDic = new Dictionary<FOSParameter, string>();
  1347. XmlNode rootNode = xmlDocument.SelectSingleNode("form-data");
  1348. foreach (XmlNode childNode in rootNode.ChildNodes) {
  1349. string fieldName = string.Empty;
  1350. string fieldValue = string.Empty;
  1351. XmlElement outFieldElement = childNode as XmlElement;
  1352. if (outFieldElement == null) {
  1353. } else {
  1354. fieldName = outFieldElement.Name;
  1355. if (fieldName.Equals("state")) {
  1356. foreach (XmlNode childNode2 in childNode.ChildNodes) {
  1357. XmlElement outFieldElement2 = childNode2 as XmlElement;
  1358. FOSParameter fieldName2 = (FOSParameter) Enum.Parse(typeof(FOSParameter), outFieldElement2.Name);
  1359. string fieldValue2 = string.Empty;
  1360. if (outFieldElement2.ChildNodes.Count > 0
  1361. && outFieldElement2.ChildNodes[0] is XmlCDataSection) {
  1362. fieldValue2 = ((XmlCDataSection) outFieldElement2.ChildNodes[0]).InnerText;
  1363. }
  1364. if (outputDataDic.ContainsKey(fieldName2)) {
  1365. outputDataDic[fieldName2] = fieldValue2;
  1366. } else {
  1367. outputDataDic.Add(fieldName2, fieldValue2);
  1368. }
  1369. }
  1370. }
  1371. }
  1372. }
  1373. return outputDataDic;
  1374. }
  1375. /// <summary>
  1376. /// 동의서 완료 데이터 저장
  1377. /// </summary>
  1378. /// <param name="eptXmlValue"></param>
  1379. /// <param name="dataValue"></param>
  1380. public override bool SaveCompleteConsentData(string eptXmlValue, string dataValue, out object saveResult) {
  1381. int translateResult = -1;
  1382. string sCertTarget = string.Empty;
  1383. string sCertResult = string.Empty;
  1384. string consentState = "CERTIFY_CMP";
  1385. string sizeValue = string.Empty;
  1386. try {
  1387. // 인증저장된 이미지 파일을 서버로 전송
  1388. translateResult = TranslateConsentToImageServer(exportedImageFiles, sCertResult, out string fileSizes);
  1389. sizeValue = fileSizes;
  1390. } catch (Exception ex) {
  1391. string exMessage = ex.Message;
  1392. if (ex.InnerException != null) {
  1393. exMessage += Environment.NewLine + ex.InnerException.Message;
  1394. }
  1395. MessageBoxDlg.Show(true, string.Format(exMessage)
  1396. , string.Format("CLIP e-Form Consent-" + Properties.Resources.msg_caption_fail),
  1397. MessageBoxButtons.OK, MessageBoxIcon.Error);
  1398. saveResult = translateResult;
  1399. return false;
  1400. }
  1401. //consentState = "CERTIFY_CMP";
  1402. SignatureConfig sign = new SignatureConfig();
  1403. try {
  1404. string certPass = this.CurrentPreviewConsent.certPass;
  1405. if (certPass.Equals("N")) {
  1406. // 공인인증 처리용
  1407. sCertTarget = sign.getSHA256ImageHash(exportedImageFiles, string.Empty);
  1408. // 공인인증 처리
  1409. sCertResult = ConsentImageSignature(sCertTarget, CurrentEndUser.userId, CurrentEndUser.userName);
  1410. //sCertResult = "TEST";
  1411. if (sCertResult == "-10") {
  1412. // "로그인 사용자 정보를 통하여 공인인증서 정보가 정상적으로 조회되지 않았습니다."
  1413. MessageBoxDlg.Show(true, Properties.Resources.msg_sign_user_info_fail
  1414. , string.Format("CLIP e-Form Consent-" + Properties.Resources.msg_caption_fail),
  1415. MessageBoxButtons.OK, MessageBoxIcon.Error);
  1416. saveResult = "-99";
  1417. return true;
  1418. } else if (sCertResult == "-20") {
  1419. // "공인인증 서버 접속에 실패하였을 하였습니다."
  1420. MessageBoxDlg.Show(true, Properties.Resources.msg_sign_server_connection_fail
  1421. , string.Format("CLIP e-Form Consent-" + Properties.Resources.msg_caption_fail),
  1422. MessageBoxButtons.OK, MessageBoxIcon.Error);
  1423. saveResult = "-99";
  1424. return true;
  1425. } else if (sCertResult == "-30") {
  1426. // "공인인증 서버 접속에 실패하였을 하였습니다."
  1427. MessageBoxDlg.Show(true, Properties.Resources.msg_sign_server_connection_fail
  1428. , string.Format("CLIP e-Form Consent-" + Properties.Resources.msg_caption_fail),
  1429. MessageBoxButtons.OK, MessageBoxIcon.Error);
  1430. saveResult = "-99";
  1431. return true;
  1432. } else if (sCertResult == "-35") {
  1433. // 공인인증 비밀번호 입력하지 않고 닫음
  1434. saveResult = "-99";
  1435. return true;
  1436. } else if (sCertResult == "-40") {
  1437. // "공인인증서 비밀번호가 틀렸습니다.
  1438. MessageBoxDlg.Show(true, Properties.Resources.msg_sign_password_fail
  1439. , string.Format("CLIP e-Form Consent-" + Properties.Resources.msg_caption_fail),
  1440. MessageBoxButtons.OK, MessageBoxIcon.Error);
  1441. saveResult = "-99";
  1442. return true;
  1443. } else if (sCertResult == "-50") {
  1444. // "공인인증서명 처리를 실패하였을 하였습니다."
  1445. MessageBoxDlg.Show(true, Properties.Resources.msg_sign_exec_fail
  1446. , string.Format("CLIP e-Form Consent-" + Properties.Resources.msg_caption_fail),
  1447. MessageBoxButtons.OK, MessageBoxIcon.Error);
  1448. saveResult = "-99";
  1449. return true;
  1450. } else if (sCertResult == "-99") {
  1451. // "공인인증서명 처리를 실패하였을 하였습니다."
  1452. MessageBoxDlg.Show(true, Properties.Resources.msg_sign_exec_fail
  1453. , string.Format("CLIP e-Form Consent-" + Properties.Resources.msg_caption_fail),
  1454. MessageBoxButtons.OK, MessageBoxIcon.Error);
  1455. saveResult = "-99";
  1456. return true;
  1457. }
  1458. }
  1459. translateResult = 1;
  1460. consentState = "CERTIFY_CMP";
  1461. } catch (Exception ex) {
  1462. string exMessage = ex.Message;
  1463. if (ex.InnerException != null) {
  1464. exMessage += Environment.NewLine + ex.InnerException.Message;
  1465. }
  1466. MessageBoxDlg.Show(true, string.Format(exMessage)
  1467. , string.Format("CLIP e-Form Consent-" + Properties.Resources.msg_caption_fail),
  1468. MessageBoxButtons.OK, MessageBoxIcon.Error);
  1469. saveResult = translateResult;
  1470. return false;
  1471. }
  1472. // DB 저장용
  1473. sCertTarget = sign.getSHA256ImageHash(exportedImageFiles, "^");
  1474. string userId = CurrentEndUser.userId;
  1475. string userDeptcd = CurrentEndUser.deptcd;
  1476. string hosType = consentMain.ConsentExecuteInfo["dutinstcd"];
  1477. string userName = CurrentEndUser.userName;
  1478. string pid = CurrentTargetPatient.pid;
  1479. string patientClnDeptCd = CurrentTargetPatient.clnDeptCode;
  1480. string patientOrdtype = CurrentTargetPatient.ordtype;
  1481. string clnDate = CurrentTargetPatient.clnDate.Replace("-", "").Replace("/", "");
  1482. string ward = CurrentTargetPatient.ward;
  1483. string roomcd = CurrentTargetPatient.roomno;
  1484. string formId = CurrentPreviewConsent.FormRid;
  1485. string formCd = CurrentPreviewConsent.FormCd;
  1486. string consentMstRid = CurrentPreviewConsent.ConsentMstRid;
  1487. int rewriteConsentMstRid = 0;
  1488. int orderNo = CurrentTargetPatient.orderno;
  1489. string orderCode = CurrentTargetPatient.clnDxCd;
  1490. string orderName = CurrentTargetPatient.clnDxNm;
  1491. string dschdd = CurrentTargetPatient.Dschdd;
  1492. string mainDrId = this.CurrentTargetPatient.mainDrId;
  1493. string actKind = (consentState.Equals("CERTIFY_CMP") ? "C" : "T");
  1494. string ocrCode = CurrentPreviewConsent.Ocrcode;
  1495. if (string.IsNullOrEmpty(ocrCode)) {
  1496. ocrCode = CurrentPreviewConsent.Ocrcode = GetOcrCode();
  1497. }
  1498. int.TryParse(CurrentTargetPatient.cretno, out int cretno);
  1499. ConvertStringToInt(formId, consentMstRid, out int formRidInt, out int consentMstRidInt);
  1500. //string deviceIdentNo = System.Environment.MachineName;
  1501. string macAddress = Common.getMacAddress();
  1502. Cursor currentCursor = this.Cursor;
  1503. var rid = Convert.ToInt32(CurrentPreviewConsent.ConsentMstRid);
  1504. if (rid < 1) {
  1505. rid = -1;
  1506. } else {
  1507. rewriteConsentMstRid = rid;
  1508. }
  1509. try {
  1510. this.Cursor = Cursors.WaitCursor;
  1511. // TODO
  1512. ConsentSvcRef.SingleReturnData resultData = this.consentWebService.SaveCompleteAll(userId,
  1513. userDeptcd,
  1514. pid,
  1515. formId,
  1516. formCd,
  1517. patientClnDeptCd,
  1518. eptXmlValue,
  1519. dataValue,
  1520. rid,
  1521. rewriteConsentMstRid,
  1522. "PC",
  1523. macAddress,
  1524. patientOrdtype,
  1525. consentMain.ConsentExecuteInfo["dutinstcd"],
  1526. clnDate,
  1527. dschdd,
  1528. ward,
  1529. roomcd,
  1530. ocrCode,
  1531. cretno,
  1532. mainDrId,
  1533. consentMain.GetTotalPageCount().ToString(),
  1534. actKind,
  1535. CurrentTargetPatient.OpRsrvNo,
  1536. consentState,
  1537. orderNo,
  1538. orderName,
  1539. orderCode,
  1540. exportedImageFilesJson,
  1541. sizeValue,
  1542. sCertResult,
  1543. sCertTarget,
  1544. "",
  1545. "");
  1546. // 인증 저장 후에는 이력 탭 설정
  1547. this.consentMain.ConsentListCtrl.InquiryConsentData(0);
  1548. // 인증저장 이후 PC 클라이언트를 종료하지 않는다.
  1549. // 확인 저장 시 닫기 버튼 활성화 하지 않는다.
  1550. //if (!consentState.Equals("ELECTR_CMP")) {
  1551. // DialogResult dialogResult = MessageBoxDlg.Show(this, string.Format(Properties.Resources.msg_esign_N_comp_save_confirm)
  1552. // , string.Format(Properties.Resources.msg_caption_confirm),
  1553. // MessageBoxButtons.YesNo, MessageBoxIcon.Information);
  1554. // if (dialogResult == DialogResult.Yes) {
  1555. // this.consentMain.Parent_Disposed();
  1556. // }
  1557. //}
  1558. this.consentMain.ReInitializeViewer();
  1559. } catch (Exception ex) {
  1560. throw ex;
  1561. } finally {
  1562. this.Cursor = currentCursor;
  1563. try {
  1564. if (!string.IsNullOrEmpty(exportedImageFiles)) {
  1565. string[] imgFile = exportedImageFiles.Split('^');
  1566. if (imgFile != null && imgFile.Length > 0) {
  1567. FileInfo fileInfo;
  1568. foreach (string sImgFileName in imgFile) {
  1569. fileInfo = new FileInfo(sImgFileName);
  1570. if (fileInfo != null) {
  1571. // 이미지 파일 삭제
  1572. fileInfo.Delete();
  1573. }
  1574. }
  1575. fileInfo = new FileInfo(imgFile[0].Replace("_0.jpg", ".xml"));
  1576. if (fileInfo != null) {
  1577. // EPT 파일 삭제
  1578. fileInfo.Delete();
  1579. }
  1580. }
  1581. }
  1582. } catch (System.IO.IOException e) {
  1583. throw e;
  1584. }
  1585. }
  1586. saveResult = 1;
  1587. return true;
  1588. }
  1589. /// <summary>
  1590. /// 전자서명을 한다
  1591. /// </summary>
  1592. /// <param name="sCertTarget">전자서명 대상</param>
  1593. /// <param name="userId">사용자ID</param>
  1594. /// <param name="userName">사용자 이름</param>
  1595. /// <returns>전자서명의 결과값</returns>
  1596. private string ConsentImageSignature(string sCertTarget, string userId, string userName) {
  1597. string resultValue = string.Empty;
  1598. try {
  1599. if (!string.IsNullOrEmpty(sCertTarget)) {
  1600. // 공인인증 서명
  1601. SignatureConfig sign = new SignatureConfig();
  1602. string rtn = "";
  1603. // 메모리에 본인 공인인증서가 아닐 경우
  1604. string sSignIp = consentMain.PluginExecuteInfo["signatureServerUrl"];
  1605. string sSignPort = consentMain.PluginExecuteInfo["signatureServerPort"];
  1606. int iPort = 0;
  1607. int.TryParse(sSignPort, out iPort);
  1608. // 공인인증 서버 접속
  1609. rtn = sign.SetSignServerInfo(sSignIp, iPort, userId);
  1610. // 공인인증 서명
  1611. resultValue = sign.SignatureExec(sCertTarget, rtn, userName, userId, this.consentMain.saveClickPoint);
  1612. if (string.IsNullOrEmpty(resultValue) || resultValue == "-1") {
  1613. // 공인인증 서명에 실패하였을 경우
  1614. return "-50";
  1615. }
  1616. }
  1617. } catch (Exception ex) {
  1618. MessageBoxDlg.Show(true, string.Format(ex.Message)
  1619. , string.Format(Properties.Resources.msg_caption_confirm),
  1620. MessageBoxButtons.OK, MessageBoxIcon.Information);
  1621. resultValue = "-99";
  1622. }
  1623. return resultValue;
  1624. }
  1625. /// <summary>
  1626. /// 서버로 이미지 파일 전송
  1627. /// </summary>
  1628. /// <param name="exportedImageFiles">전송할 이미지 파일</param>
  1629. /// <param name="sCertResult">공인인증 결과</param>
  1630. /// <returns></returns>
  1631. private int TranslateConsentToImageServer(string exportedImageFiles, string sCertResult, out string fileSizes) {
  1632. int resultValue = -1;
  1633. fileSizes = string.Empty;
  1634. if (!string.IsNullOrEmpty(exportedImageFilesJson) && !string.IsNullOrEmpty(exportedImageFiles)) {
  1635. Dictionary<string, object> jsonRoot = null;
  1636. try {
  1637. jsonRoot = fastJSON.JSON.Parse(exportedImageFilesJson) as Dictionary<string, object>;
  1638. if (jsonRoot != null && jsonRoot.Count > 0) {
  1639. string sPath = string.Empty;
  1640. string sFileName = string.Empty;
  1641. string[] sFullPath = exportedImageFiles.Split('^');
  1642. int k = 0;
  1643. foreach (KeyValuePair<string, object> jr in jsonRoot) {
  1644. if (jr.Value != null && !string.IsNullOrEmpty(jr.Value.ToString())) {
  1645. sPath = string.Empty;
  1646. sFileName = string.Empty;
  1647. string[] filepath = jr.Value.ToString().Split('/');
  1648. for (int i = 0; i < filepath.Length; i++) {
  1649. if (i == 0) {
  1650. sPath = filepath[i];
  1651. } else if ((i + 1) == filepath.Length) {
  1652. sFileName = filepath[i];
  1653. } else {
  1654. sPath += "/" + filepath[i];
  1655. }
  1656. }
  1657. //이미지를 서버에 업로드(전자동의서 서버에 저장)
  1658. System.Net.WebClient wcClient = new System.Net.WebClient();
  1659. string imageUploadServerUrl = this.consentMain.PluginExecuteInfo["imageUploadServerUrl"];
  1660. System.Collections.Specialized.NameValueCollection values = new System.Collections.Specialized.NameValueCollection();
  1661. values.Add("up_path", sPath + "/" + sFileName);
  1662. wcClient.QueryString = values;
  1663. if(k != 0) {
  1664. fileSizes += ",";
  1665. }
  1666. var fileInfo = new FileInfo(sFullPath[k]);
  1667. if(fileInfo != null) {
  1668. fileSizes += fileInfo.Length / 1024;
  1669. }
  1670. byte[] response = wcClient.UploadFile(imageUploadServerUrl, "POST", sFullPath[k++]);
  1671. }
  1672. }
  1673. }
  1674. } catch (Exception) {
  1675. return resultValue = -99;
  1676. }
  1677. resultValue = 1;
  1678. }
  1679. return resultValue;
  1680. }
  1681. //private int TranslateConsentToImageServer(string exportedImageFiles, int consentMstRidInt, string sCertResult)
  1682. //{
  1683. // int resultValue = -1;
  1684. // if (!string.IsNullOrEmpty(exportedImageFiles))
  1685. // {
  1686. // string[] aryimgFile = exportedImageFiles.Split('^');
  1687. // if (aryimgFile != null && aryimgFile.Length > 0)
  1688. // {
  1689. // try
  1690. // {
  1691. // int consentImageRid_F = 0;
  1692. // string sCertTarget = "";
  1693. // for (int i = 0; i < aryimgFile.Length; i++)
  1694. // {
  1695. // string imgFile = aryimgFile[i];
  1696. // //MessageBox.Show(CurrentTargetPatient.PatientCode + "," + CurrentTargetPatient.VisitType + "," + CurrentTargetPatient.clnDate + "," + "20150815" + "," + CurrentTargetPatient.cretno + "," + "500" + "," + CurrentPreviewConsent.FormCd + "," + i.ToString() + "," + CurrentPreviewConsent.Ocrcode + "," + CurrentEndUser.userId);
  1697. // //LCTech 모듈을 위한 DB 작업을 하고 저장할 파일명을 얻는다.
  1698. // string newFileFullName = this.hospitalWebService.GetFileName(CurrentTargetPatient.PatientCode, CurrentTargetPatient.VisitType,
  1699. // CurrentTargetPatient.clnDate.Replace("-", ""), CurrentTargetPatient.Dschdd, CurrentTargetPatient.cretno,
  1700. // "500", CurrentPreviewConsent.FormCd, i.ToString(),
  1701. // CurrentPreviewConsent.Ocrcode, CurrentEndUser.userId);
  1702. // //MessageBox.Show(newFileFullName); //O:\fnuImage\201607\19\100501967
  1703. // string uploadFileName = newFileFullName + ".jpg";
  1704. // if (string.IsNullOrEmpty(newFileFullName))
  1705. // {
  1706. // return -10;
  1707. // }
  1708. // //이미지 정보 DB에 저장
  1709. // int consentImageRid = this.consentWebService.SaveImageUploadInfo("ELECTR_CMP", uploadFileName,
  1710. // consentMstRidInt, CurrentEndUser.userId, int.Parse(CurrentPreviewConsent.FormRid));
  1711. // /*
  1712. // //저장된 이미지에서 해쉬정보 추출
  1713. // string sCertTarget = GetImageCertification(imgFile);
  1714. // //해쉬정보 DB에 저장
  1715. // this.consentWebService.SaveImageSignInfo("ELECTR_CMP", consentMstRidInt, consentImageRid,
  1716. // CurrentEndUser.userId, sCertTarget);
  1717. // */
  1718. // if (i == 0) consentImageRid_F = consentImageRid; //첫번째 consentImageRid 를 저장한다.
  1719. // sCertTarget += GetImageCertification(imgFile) + "^";
  1720. // //이미지를 서버에 업로드(서버에서 나스에 저장)
  1721. // System.Net.WebClient wcClient = new System.Net.WebClient();
  1722. // string imageUploadServerUrl = this.consentMain.PluginExecuteInfo["imageUploadServerUrl"];
  1723. // System.Collections.Specialized.NameValueCollection values = new System.Collections.Specialized.NameValueCollection();
  1724. // values.Add("up_path", uploadFileName);
  1725. // wcClient.QueryString = values;
  1726. // wcClient.UploadFile(imageUploadServerUrl, "POST", imgFile);
  1727. // File.Delete(imgFile);
  1728. // }
  1729. // // 외래일 경우 공인인증 처리가 없음.
  1730. // if (!string.IsNullOrEmpty(CurrentTargetPatient.VisitType) && !CurrentTargetPatient.VisitType.Equals("O"))
  1731. // {
  1732. // sCertTarget = sCertTarget.Substring(0, sCertTarget.Length - 1);
  1733. // this.consentWebService.SaveImageSignInfo("ELECTR_CMP", consentMstRidInt, consentImageRid_F,
  1734. // CurrentEndUser.userId, sCertTarget, sCertResult);
  1735. // }
  1736. // resultValue = 1;
  1737. // }
  1738. // catch (Exception err)
  1739. // {
  1740. // resultValue = -99;
  1741. // throw err;
  1742. // }
  1743. // }
  1744. // }
  1745. // return resultValue;
  1746. //}
  1747. /// <summary>
  1748. /// 공인인증 이미지를 가져옴
  1749. /// 사용되는 곳 없음
  1750. /// </summary>
  1751. /// <param name="exportedImageFile">The exported image file.</param>
  1752. /// <returns></returns>
  1753. private string GetImageCertification(string exportedImageFile) {
  1754. try {
  1755. FileStream fileStream = null;
  1756. fileStream = new FileStream(exportedImageFile, FileMode.Open);
  1757. fileStream.Position = 0;
  1758. SHA256 mySHA256 = SHA256Managed.Create();
  1759. byte[] hashValue = mySHA256.ComputeHash(fileStream);
  1760. fileStream.Close();
  1761. return byteArrayToString(hashValue);
  1762. } catch (Exception ex) {
  1763. string exMessage = ex.Message;
  1764. if (ex.InnerException != null) {
  1765. exMessage += Environment.NewLine + ex.InnerException.Message;
  1766. }
  1767. return exMessage;
  1768. }
  1769. }
  1770. private string byteArrayToString(byte[] bStr) {
  1771. string hexOutput = string.Empty;
  1772. foreach (char letter in bStr) {
  1773. int value = Convert.ToInt32(letter);
  1774. hexOutput += String.Format("{0:x}", value);
  1775. }
  1776. return hexOutput;
  1777. }
  1778. /// <summary>
  1779. /// 이미지 업로드시 사용될 exportedImageFilesJson 객체에 JSON 스타일로 값을 설정
  1780. /// </summary>
  1781. /// <param name="savedImageFileDescription">저장될 이미지 파일 설명</param>
  1782. public override void WorkExtraWithSavedImageFiles(string savedImageFileDescription) {
  1783. string[] aryImageInfo = savedImageFileDescription.Split(';');
  1784. Dictionary<string, string> dicImageInfo = new Dictionary<string, string>();
  1785. foreach (string imageInfo in aryImageInfo) {
  1786. string[] aryInfo = imageInfo.Split('=');
  1787. if (aryInfo.Length == 2) {
  1788. dicImageInfo.Add(aryInfo[0], aryInfo[1]);
  1789. }
  1790. }
  1791. int baseIndex = -1;
  1792. int.TryParse(dicImageInfo["base-index"], out baseIndex);
  1793. int totalFiles = -1;
  1794. int.TryParse(dicImageInfo["total-files"], out totalFiles);
  1795. if (baseIndex > -1 && totalFiles > 0) {
  1796. this.exportedImageFiles = string.Empty;
  1797. this.exportedImageFilesJson = "{ ";
  1798. string sUploadPath = string.Empty;
  1799. for (int i = baseIndex; i < baseIndex + totalFiles; i++) {
  1800. string exportedImageFile = string.Format("{0}\\{1}_{2}.{3}", dicImageInfo["path"], dicImageInfo["key"], i, dicImageInfo["extention"]);
  1801. exportedImageFiles += exportedImageFile;
  1802. sUploadPath = string.Format("{0}/{1}", DateTime.Now.ToString("yyyyMM"), DateTime.Now.ToString("dd"));
  1803. this.exportedImageFilesJson += string.Format("\"imageFile{0}\" : \"{1}/{2}_{3}.{4}\"", i, sUploadPath, dicImageInfo["key"], i, dicImageInfo["extention"]);
  1804. if (i + 1 < (baseIndex + totalFiles)) {
  1805. exportedImageFiles += "^";
  1806. this.exportedImageFilesJson += ", ";
  1807. }
  1808. }
  1809. this.exportedImageFilesJson += " }";
  1810. System.Diagnostics.Debug.WriteLine("Debug=> exportedImageFiles: " + this.exportedImageFiles);
  1811. System.Diagnostics.Debug.WriteLine("Debug=> exportedImageFilesJson: " + this.exportedImageFilesJson);
  1812. }
  1813. }
  1814. private void ConvertStringToInt(string formRid, string consentMstRid, out int formRidInt, out int consentMstRidInt) {
  1815. formRidInt = 0;
  1816. int.TryParse(formRid, out formRidInt);
  1817. consentMstRidInt = 0;
  1818. int.TryParse(consentMstRid, out consentMstRidInt);
  1819. }
  1820. /// <summary>
  1821. /// baseGlobalParams 의 딕셔너리 객체에 changingGlobalParams 의 딕셔너리 객체의 요소들을 변경함
  1822. /// 기존 baseGlobalParams 딕셔너리에 key 가 없으면 추가되지 않음
  1823. /// </summary>
  1824. /// <param name="baseGlobalParams">복사될 딕셔너리 객체</param>
  1825. /// <param name="changingGlobalParams">복사할 딕셔너리 객체</param>
  1826. private void ChangeGlobalParametersToNew(Dictionary<FOSParameter, string> baseGlobalParams, Dictionary<FOSParameter, string> changingGlobalParams) {
  1827. foreach (FOSParameter dicKey in changingGlobalParams.Keys) {
  1828. if (baseGlobalParams.ContainsKey(dicKey)) {
  1829. baseGlobalParams[dicKey] = changingGlobalParams[dicKey];
  1830. }
  1831. }
  1832. }
  1833. /// <summary>
  1834. /// 사용자에 따른 버튼 활성화
  1835. /// </summary>
  1836. private void SetEnableByUserType() {
  1837. // 기록 테이블의 출력 유무에 따른 서명버튼 활성화 처리
  1838. SetSaveButtonDisabledWhenPrintYN();
  1839. }
  1840. /// <summary>
  1841. /// 출력, 임시저장, 출력 버튼 활성화 여부 설정
  1842. /// </summary>
  1843. private void SetSaveButtonDisabledWhenPrintYN() {
  1844. // 뷰어 모드 적용
  1845. if (consentMain.ConsentExecuteInfo["readOnly"].Equals("Y")) {
  1846. this.toolStripButtons.Enabled = false;
  1847. return;
  1848. }
  1849. if (CurrentEndUser == null || CurrentPreviewConsent == null) {
  1850. return;
  1851. }
  1852. string printOnly = CurrentPreviewConsent.PrintOnly ?? string.Empty;
  1853. string consentState = CurrentPreviewConsent.ConsentState ?? string.Empty;
  1854. // 출력만 가능하게 설정
  1855. if (printOnly.Equals("Y")) {
  1856. //this.toolStripButtonPrint.Enabled = true;
  1857. this.toolStripButtonCompleteSaveToServer.Enabled = false;
  1858. this.toolStripButtonSaveToServer.Enabled = false;
  1859. this.toolStripButtonTempSaveToServer.Enabled = false;
  1860. this.toolStripButtonExecute.Enabled = false;
  1861. }
  1862. // 출력 상태일 경우 재출력만 가능하도록 버튼 조정
  1863. else if (consentState.ToUpper().Equals("PAPER_OUT")) {
  1864. this.toolStripButtonExecute.Enabled = false;
  1865. }
  1866. // 작성 완료일 경우 임시 저장 불가
  1867. else if (consentState.ToUpper().Equals("ELECTR_CMP")) {
  1868. this.toolStripButtonTempSaveToServer.Enabled = false;
  1869. }
  1870. }
  1871. /// <summary>
  1872. /// 동의서 출력
  1873. /// </summary>
  1874. private void PrintConsent() {
  1875. // 환자정보가 없을 경우 출력이 되지 않도록 적용
  1876. if (this.CurrentTargetPatient == null || string.IsNullOrEmpty(this.CurrentTargetPatient.pid) || string.IsNullOrEmpty(this.CurrentTargetPatient.name)) {
  1877. DialogResult result = MessageBox.Show(string.Format(Properties.Resources.msg_error_user_data)
  1878. , string.Format(Properties.Resources.msg_caption_fail),
  1879. MessageBoxButtons.OK, MessageBoxIcon.Information);
  1880. return;
  1881. }
  1882. // 출력 : patientInfo 를 기반으로 출력하는 경우와 환자목록에서 멀티선택 출력의 경우로 나눠야 한다.
  1883. List<PatListVO> volist = consentMain.PatientListCtrl.GetSelectedPatientList();
  1884. // 1명 출력할 경우
  1885. if (volist.Count == 1) {
  1886. if (this.CurrentPreviewConsent.ConsentMstRid != null
  1887. && !string.IsNullOrEmpty(this.CurrentPreviewConsent.ConsentMstRid)
  1888. && !this.CurrentPreviewConsent.ConsentMstRid.Equals("-1")
  1889. && !this.CurrentPreviewConsent.ConsentMstRid.Equals("0")) {
  1890. DialogResult result = MessageBox.Show(string.Format(Properties.Resources.msg_multi_print_fail)
  1891. , string.Format(Properties.Resources.msg_caption_fail),
  1892. MessageBoxButtons.OK, MessageBoxIcon.Information);
  1893. } else {
  1894. PrintConsentDocument();
  1895. }
  1896. // 환자 목록에서 여러명을 체크박스로 선택하여 출력할 경우
  1897. } else if (volist.Count > 0) {
  1898. if (this.CurrentPreviewConsent.ConsentMstRid != null
  1899. && !string.IsNullOrEmpty(this.CurrentPreviewConsent.ConsentMstRid)
  1900. && !this.CurrentPreviewConsent.ConsentMstRid.Equals("-1")
  1901. && !this.CurrentPreviewConsent.ConsentMstRid.Equals("0")) {
  1902. DialogResult result = MessageBox.Show(string.Format(Properties.Resources.msg_multi_print_fail)
  1903. , string.Format(Properties.Resources.msg_caption_fail),
  1904. MessageBoxButtons.OK, MessageBoxIcon.Information);
  1905. } else {
  1906. DialogResult result = MessageBox.Show(string.Format(Properties.Resources.msg_multi_print_question)
  1907. , string.Format(Properties.Resources.msg_caption_fail),
  1908. MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
  1909. if (result == DialogResult.OK) {
  1910. this.CurrentPreviewConsent.OutputType = "MULTI";
  1911. MultiPrintConsentDocument(volist);
  1912. }
  1913. }
  1914. } else {
  1915. PrintConsentDocument();
  1916. }
  1917. }
  1918. /// <summary>
  1919. /// 미리보기 데이터를 출력하는 경우
  1920. /// </summary>
  1921. public void PrintConsentDocument() {
  1922. Dictionary<string, Dictionary<FOSParameter, string>> formParamsList = new Dictionary<string, Dictionary<FOSParameter, string>>();
  1923. string[] formGuidList = new string[this.CurrentPreviewConsent.PrntCnt];
  1924. for (int i = 0; i < this.CurrentPreviewConsent.PrntCnt; i++) {
  1925. Dictionary<FOSParameter, string> formParams = Common.CreateGlobalParamsDictionary(consentMain.ConsentExecuteInfo["dutinstcd"]);
  1926. formGuidList[i] = this.CurrentPreviewConsent.FormGuid;
  1927. if (SetPatientAndUser(formParams) < 0) {
  1928. return;
  1929. }
  1930. //formParams[FOSParameter.OCRCode] = this.CurrentPreviewConsent.Ocrcode = GetOcrCode();
  1931. if (i == 0) {
  1932. formParams[FOSParameter.LIST_OCRCODE] = this.CurrentPreviewConsent.Ocrcode = GetOcrCode();
  1933. } else {
  1934. var ocrStr = consentWebService.getOcrString(this.CurrentPreviewConsent.FormCd,
  1935. consentMain.ConsentExecuteInfo["dutinstcd"]);
  1936. ocrStr = (ocrStr.Length < 0) ? "[환자 보관용]" : ocrStr;
  1937. //formParams[FOSParameter.OCRCode] = "[환자 보관용]";
  1938. formParams[FOSParameter.LIST_OCRCODE] = ocrStr;
  1939. }
  1940. //formParams[FOSParameter.Device] = "P";
  1941. //formParams[FOSParameter.PrintTime] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  1942. //formParams[FOSParameter.PrintIp] = consentMain.ConsentExecuteInfo["printIP"];
  1943. //if (i == 1) formParams[FOSParameter.PrintComment] = Properties.Resources.msg_print_comment_2;
  1944. //else if (i == 2) formParams[FOSParameter.PrintComment] = Properties.Resources.msg_print_comment_3;
  1945. // dbs227, KNUH 프린터 출력 시 출력 일 시 제외
  1946. //formParams[FOSParameter.PatientName] = string.Empty; // parCMDCHD_1PatientNm
  1947. // 전자동의서 상 이름이 안아올 경우 파라미터 필드를 parCMDCHD_1PatientNmFix 로 변경
  1948. // 단 파라미터 필드가 정의되어 있지 않는 경우 파라미터 필드를 추가하여 매핑
  1949. //formParams[FOSParameter.ExplDrName] = string.Empty; // 설명의 이름 제거
  1950. //formParams[FOSParameter.ExplDrTelNo] = string.Empty; // 설명의 전화번호 제거
  1951. //formParams[FOSParameter.ExplDrSign] = string.Empty; // 설명의사 싸인 제거
  1952. formParamsList.Add((i + 1).ToString(), formParams);
  1953. }
  1954. string fos = Common.GetMultiFosString(formGuidList
  1955. , this.consentMain.PluginExecuteInfo["formServiceUrl"]
  1956. , null
  1957. , formParamsList
  1958. , consentMain.ConsentExecuteInfo["dutinstcd"]);
  1959. //PC클라이언트에서 프린트 출력을 눌렀을때 출력 데이타 입력 후 출력되게끔
  1960. if (this.consentMain.getPrintButton()) {
  1961. this.consentMain.setPageCnt(CurrentPreviewConsent.PrntCnt);
  1962. SaveDataForPrintedConsent(String.Empty);
  1963. }
  1964. this.consentMain.PrintConsentDocument(fos);
  1965. // 화면 상에 보이는 데로 출력을 원하면 아래 로직 적용
  1966. //this.consentMain.PrintConsentDocument("");
  1967. }
  1968. //private int g_pageCnt = 0;
  1969. /// <summary>
  1970. /// 사용되지 않음
  1971. /// </summary>
  1972. public void PrintDirectConsentDocument() {
  1973. if (this.currentPreviewConsent == null || this.CurrentTargetPatient == null || this.CurrentEndUser == null) {
  1974. return;
  1975. }
  1976. //미리보기 데이터를 바로 출력하는 경우는 미작성상태인 경우로만 한다. (임시작성 이상의 경우는 바로 출력을 안하도록)
  1977. if (!this.currentPreviewConsent.ConsentState.ToUpper().Equals("UNFINISHED")) {
  1978. return;
  1979. }
  1980. int prntCnt = 0;
  1981. prntCnt = this.CurrentPreviewConsent.PrntCnt;
  1982. int prntMsgCnt = 0;
  1983. if (!string.IsNullOrEmpty(this.consentMain.ConsentExecuteInfo["printList"])) {
  1984. if (!consentMain.ConsentExecuteInfo["prntCnt"].Equals("-1")) {
  1985. int.TryParse(this.consentMain.ConsentExecuteInfo["prntCnt"].ToString(), out prntCnt);
  1986. prntMsgCnt++;
  1987. }
  1988. }
  1989. Dictionary<string, Dictionary<FOSParameter, string>> formParamsList = new Dictionary<string, Dictionary<FOSParameter, string>>();
  1990. string[] formGuidList = new string[prntCnt];
  1991. string sOcrCd = string.Empty;
  1992. for (int i = 0; i < prntCnt; i++) {
  1993. Dictionary<FOSParameter, string> formParams = Common.CreateGlobalParamsDictionary(consentMain.ConsentExecuteInfo["dutinstcd"]);
  1994. Dictionary<FOSParameter, string> changingFormParams = new Dictionary<FOSParameter, string>();
  1995. SetPatientAndUser(formParams);
  1996. // 빌드를 위한 주석 처리
  1997. //changingFormParams[FOSParameter.Device] = "P";
  1998. //changingFormParams[FOSParameter.PrintTime] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  1999. //changingFormParams[FOSParameter.PrintIp] = consentMain.ConsentExecuteInfo["printIP"];
  2000. //if (i == 0) {
  2001. // changingFormParams[FOSParameter.OCRCode] = this.CurrentPreviewConsent.Ocrcode = GetOcrCode(); // OCR 코드
  2002. // sOcrCd = this.CurrentPreviewConsent.Ocrcode;
  2003. //} else {
  2004. // changingFormParams[FOSParameter.OCRCode] = sOcrCd; //OCR코드
  2005. //}
  2006. //if (prntMsgCnt == 1) changingFormParams[FOSParameter.PrintComment] = Properties.Resources.msg_print_comment_2;
  2007. //else if (prntMsgCnt == 2) changingFormParams[FOSParameter.PrintComment] = Properties.Resources.msg_print_comment_3;
  2008. ChangeGlobalParametersToNew(formParams, changingFormParams);
  2009. formGuidList[i] = this.CurrentPreviewConsent.FormGuid;
  2010. formParamsList.Add((i + 1).ToString(), formParams);
  2011. prntMsgCnt++;
  2012. }
  2013. string fos = Common.GetMultiFosString(formGuidList
  2014. , this.consentMain.PluginExecuteInfo["formServiceUrl"]
  2015. , null
  2016. , formParamsList
  2017. , consentMain.ConsentExecuteInfo["dutinstcd"]);
  2018. this.consentMain.PrintDirect(fos);
  2019. }
  2020. /// <summary>
  2021. /// 단일 서식 다중 환자 출력
  2022. /// </summary>
  2023. /// <param name="voList">환자 목록 리스트</param>
  2024. private void MultiPrintConsentDocument(List<PatListVO> voList) {
  2025. Dictionary<string, Dictionary<FOSParameter, string>> formParamsList = new Dictionary<string, Dictionary<FOSParameter, string>>();
  2026. List<string> formGuids = new List<string>();
  2027. int guidCnt = 0;
  2028. if (voList.Count > 0 && this.CurrentPreviewConsent.PrntCnt > 0) {
  2029. guidCnt = voList.Count * this.CurrentPreviewConsent.PrntCnt;
  2030. }
  2031. string[] formGuidList = new string[guidCnt];
  2032. int prntCnt = 0;
  2033. string sOcrCd = string.Empty;
  2034. for (int i = 0; i < voList.Count; i++) {
  2035. sOcrCd = string.Empty;
  2036. for (int j = 0; j < this.CurrentPreviewConsent.PrntCnt; j++) {
  2037. PatientVO vo = GetPatientByPatList(voList[i]);
  2038. Dictionary<FOSParameter, string> formParams = Common.CreateGlobalParamsDictionary(consentMain.ConsentExecuteInfo["dutinstcd"]);
  2039. Dictionary<FOSParameter, string> changingFormParams = new Dictionary<FOSParameter, string>();
  2040. // 빌드를 위한 주석 처리
  2041. //changingFormParams[FOSParameter.ImageUploadPath] = this.consentMain.PluginExecuteInfo["imageUploadPath"] + "/";
  2042. //changingFormParams[FOSParameter.Device] = "P";
  2043. //changingFormParams[FOSParameter.PatientCode] = vo.IO_Pt_ID;
  2044. //changingFormParams[FOSParameter.PatientSexAge] = vo.IO_sex_age_y_m;
  2045. //changingFormParams[FOSParameter.PatientName] = vo.IO_Pt_Name;
  2046. //changingFormParams[FOSParameter.PatientRRN] = vo.IO_JuminNo;
  2047. //changingFormParams[FOSParameter.RoomNo] = vo.IO_Ward + "/" + vo.IO_RoomNo;
  2048. //changingFormParams[FOSParameter.VisitDate] = SetDateFormatting(vo.IO_ADdate);
  2049. //changingFormParams[FOSParameter.depthngnm] = vo.IO_DeptNm;
  2050. //changingFormParams[FOSParameter.FormName] = this.CurrentPreviewConsent.FormPrintName;
  2051. //changingFormParams[FOSParameter.MainDoctor] = vo.IO_MaindrNm;
  2052. // dbs227 다중 출력 시 환자 이름을 추가하여 준다
  2053. //changingFormParams[FOSParameter.PatientNameFix] = vo.IO_Pt_Name; // 빌드를 위한 주석 처리
  2054. // 출력할 경우 설명 의사와 서명 이미지는 공백 처리
  2055. //if (consentMain.ConsentExecuteInfo["printYN"].Equals("Y"))
  2056. {
  2057. //changingFormParams[FOSParameter.ExplDrName] = string.Empty;
  2058. //changingFormParams[FOSParameter.ExplDrTelNo] = string.Empty;
  2059. //changingFormParams[FOSParameter.ExplDrSign] = string.Empty;
  2060. //changingFormParams[FOSParameter.PatientName] = string.Empty;
  2061. //changingFormParams[FOSParameter.PatientBirthDay] = string.Empty;
  2062. //changingFormParams[FOSParameter.PatientTelNo] = string.Empty; // parCMSGBD_PT_tel
  2063. // 보호자상주확인서 프린터 출력시 제외 항목
  2064. //changingGlobalParams[FOSParameter.userName] = string.Empty;
  2065. //changingGlobalParams[FOSParameter.SignImage] = string.Empty;
  2066. }
  2067. if (j == 0) {
  2068. changingFormParams[FOSParameter.LIST_OCRCODE] = sOcrCd = /*vo.IO_OcrCd =*/ hospitalWebService.GetOcrTag().responseData; //OCR코드
  2069. //this.CurrentPreviewConsent.MultiOcrcode += vo.IO_OcrCd + "^";
  2070. //this.CurrentPreviewConsent.MultiMainDrIdCd += vo.IO_MaindrId + "^";
  2071. //sOcrCd = vo.IO_OcrCd;
  2072. } else {
  2073. changingFormParams[FOSParameter.LIST_OCRCODE] = sOcrCd; //OCR코드
  2074. }
  2075. //if (j == 1) changingFormParams[FOSParameter.PrintComment] = Properties.Resources.msg_print_comment_2;
  2076. //else if (j == 2) changingFormParams[FOSParameter.PrintComment] = Properties.Resources.msg_print_comment_3;
  2077. //changingFormParams[FOSParameter.PrintTime] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  2078. //changingFormParams[FOSParameter.PrintIp] = consentMain.ConsentExecuteInfo["printIP"];
  2079. ChangeGlobalParametersToNew(formParams, changingFormParams);
  2080. formGuidList[prntCnt] = this.CurrentPreviewConsent.FormGuid;
  2081. //formGuids.Add(this.CurrentPreviewConsent.FormGuid);
  2082. formParamsList.Add((prntCnt + 1).ToString(), formParams);
  2083. prntCnt++;
  2084. }
  2085. }
  2086. if (this.CurrentPreviewConsent.MultiOcrcode.Length > 0) {
  2087. this.CurrentPreviewConsent.MultiOcrcode = this.CurrentPreviewConsent.MultiOcrcode.Substring(0, this.CurrentPreviewConsent.MultiOcrcode.Length - 1);
  2088. }
  2089. if (this.CurrentPreviewConsent.MultiMainDrIdCd.Length > 0) {
  2090. this.CurrentPreviewConsent.MultiMainDrIdCd = this.CurrentPreviewConsent.MultiMainDrIdCd.Substring(0, this.CurrentPreviewConsent.MultiMainDrIdCd.Length - 1);
  2091. }
  2092. string fos = Common.GetMultiFosString(formGuidList
  2093. , this.consentMain.PluginExecuteInfo["formServiceUrl"]
  2094. , null
  2095. , formParamsList
  2096. , consentMain.ConsentExecuteInfo["dutinstcd"]);
  2097. //PC클라이언트에서 프린트 출력을 눌렀을때 출력 데이타 입력 후 출력되게끔
  2098. if (this.consentMain.getPrintButton()) {
  2099. this.consentMain.setPageCnt(CurrentPreviewConsent.PrntCnt);
  2100. SaveDataForPrintedConsent(String.Empty);
  2101. }
  2102. this.consentMain.PrintConsentDocument(fos);
  2103. }
  2104. private string SetDateFormatting(string adDate) {
  2105. if (adDate.Length == 8)
  2106. return string.Format("{0}/{1}/{2}", adDate.Substring(0, 4), adDate.Substring(4, 2), adDate.Substring(6, 2));
  2107. else
  2108. return adDate;
  2109. }
  2110. public override void OnRequiredInputViolation(string value) {
  2111. MessageBox.Show(value + " 항목이 누락되었습니다.", Properties.Resources.msg_caption_warn, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  2112. }
  2113. /// <summary>
  2114. /// toolStripButtonPen 체크박스 활성화 여부 체크 및 이미지 변경
  2115. /// </summary>
  2116. /// <param name="enabled">if set to <c>true</c> [enabled].</param>
  2117. public override void onEnableDrawing(bool enabled) {
  2118. this.toolStripButtonPen.Checked = enabled;
  2119. if (this.toolStripButtonPen.Checked) this.toolStripButtonPen.Image = global::CLIP.eForm.Consent.UI.Properties.Resources.newDrawingClick;
  2120. else this.toolStripButtonPen.Image = ((System.Drawing.Image) (resources.GetObject("toolStripButtonPen.Image")));
  2121. }
  2122. /// <summary>
  2123. /// 첨지 삭제 버튼 클릭 이벤트
  2124. /// </summary>
  2125. /// <param name="sender">The source of the event.</param>
  2126. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  2127. private void toolStripButtonDeleteAttach_Click(object sender, EventArgs e) {
  2128. this.consentMain.DeleteAttach();
  2129. setViewerPageInit();
  2130. }
  2131. /// <summary>
  2132. /// 첨지 추가 버튼 클릭 이벤트
  2133. /// </summary>
  2134. /// <param name="sender">The source of the event.</param>
  2135. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  2136. private void toolStripButtonInsertAttach_Click(object sender, EventArgs e) {
  2137. this.consentMain.InsertAttach();
  2138. setViewerPageInit();
  2139. }
  2140. /// <summary>
  2141. /// 뷰어 페이지 초기화
  2142. /// </summary>
  2143. public override void setViewerPageInit() {
  2144. this.toolStripLabelTotalPages.Text = this.consentMain.GetTotalPageCount().ToString();
  2145. this.toolStripTextBoxPageIndex.Text = this.consentMain.GetCurrentPageIndex().ToString();
  2146. }
  2147. /// <summary>
  2148. /// 환경설정 버튼 클릭 이벤트
  2149. /// </summary>
  2150. /// <param name="sender">The source of the event.</param>
  2151. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  2152. private void toolStripButtonConfig_Click(object sender, EventArgs e) {
  2153. ShowConfigDialog();
  2154. }
  2155. /// <summary>
  2156. /// 환경설정 다이얼로그를 불러온다
  2157. /// </summary>
  2158. private void ShowConfigDialog() {
  2159. ConfigForm configForm = new ConfigForm(this.consentMain);
  2160. configForm.ShowDialog(this);
  2161. }
  2162. class ZoomRateDropdownItem {
  2163. private string caption = string.Empty;
  2164. public string Caption {
  2165. get { return caption; }
  2166. set { caption = value; }
  2167. }
  2168. private string itemValue = string.Empty;
  2169. public string ItemValue {
  2170. get { return itemValue; }
  2171. set { itemValue = value; }
  2172. }
  2173. public ZoomRateDropdownItem() {
  2174. }
  2175. public ZoomRateDropdownItem(string caption, string itemValue) {
  2176. this.caption = caption;
  2177. this.itemValue = itemValue;
  2178. }
  2179. public override string ToString() {
  2180. return caption;
  2181. }
  2182. }
  2183. /// <summary>
  2184. /// 환경설정 버튼 클릭 이벤트
  2185. /// </summary>
  2186. /// <param name="sender">The source of the event.</param>
  2187. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  2188. private void toolStripButtonConfig_Click_1(object sender, EventArgs e) {
  2189. ShowConfigDialog();
  2190. }
  2191. private void ConsentCommandCtrl_Click(object sender, EventArgs e) {
  2192. MessageBoxDlg.MessageBoxParent = this;
  2193. }
  2194. }
  2195. }