ConsentCommandCtrl.cs 143 KB

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