ConsentCommandCtrl.cs 144 KB

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