ConsentCommandCtrl.cs 110 KB

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