ConsentCommandCtrl.cs 142 KB

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