ConsentSvc.asmx.cs.svn-base 144 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130
  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: ConsentSvc.asmx.cs
  8. //
  9. #endregion
  10. using System;
  11. using System.IO;
  12. using System.Text;
  13. using System.Xml;
  14. using System.Collections.Generic;
  15. using System.Web.Services;
  16. using System.Collections;
  17. using IBatisNet.DataMapper;
  18. using CLIP.eForm.Server.Data;
  19. using CLIP.eForm.Server.VO;
  20. using CLIP.eForm.Consent.Entity;
  21. using CLIP.eForm.Consent.Dac;
  22. using System.DirectoryServices;
  23. using System.Web.Script.Services;
  24. using System.IO.Compression;
  25. namespace CLIP.eForm.Consent.WebService {
  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-15 : 최초작성</p>
  39. /// <p>----------------------------------------------------------------------------------------</p>
  40. /// </remarks>
  41. /// <summary>
  42. /// ConsentSvc의 요약 설명입니다.
  43. /// </summary>
  44. [WebService(Namespace = "http://tempuri.org/")]
  45. [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
  46. [System.ComponentModel.ToolboxItem(false)]
  47. // ASP.NET AJAX를 사용하여 스크립트에서 이 웹 서비스를 호출하려면 다음 줄의 주석 처리를 제거합니다.
  48. // [System.Web.Script.Services.ScriptService]
  49. public class ConsentSvc : System.Web.Services.WebService {
  50. private IBatisHelper _ibatisHelper;
  51. private static string tempImageDelStatus = string.Empty;
  52. public ConsentSvc() {
  53. _ibatisHelper = new IBatisHelper("ConsentSvcOracleMap.config");
  54. }
  55. protected override void Dispose(bool disposing) {
  56. if (IbatisSession != null && IbatisSession.Transaction != null) {
  57. IbatisSession.CommitTransaction();
  58. IbatisSession.CloseConnection();
  59. }
  60. if (IbatisMapper != null)
  61. IbatisMapper.CloseConnection();
  62. base.Dispose(disposing);
  63. }
  64. /// <summary>
  65. /// 현재 연결된 IBatis Connection을 반환
  66. /// </summary>
  67. public ISqlMapper IbatisMapper {
  68. get {
  69. if (_ibatisHelper == null) {
  70. return null;
  71. } else {
  72. return _ibatisHelper.GetSqlMapper();
  73. }
  74. }
  75. }
  76. /// <summary>
  77. /// 현재 연결된 ISqlMapSession 을 반환
  78. /// </summary>
  79. public ISqlMapSession IbatisSession {
  80. get {
  81. if (_ibatisHelper == null) {
  82. return null;
  83. } else {
  84. return _ibatisHelper.GetMapSession();
  85. }
  86. }
  87. }
  88. [WebMethod]
  89. public bool CheckWebService() {
  90. return true;
  91. }
  92. /// <summary>
  93. /// 경북대학교병원 출력 로그에 기록되지 않아야 할 목록 조회
  94. /// </summary>
  95. /// <param name="dutinstcd"></param>
  96. /// <returns></returns>
  97. [WebMethod(Description = "Type 6 인 동의서 조회")]
  98. public List<String> getOcrType6Forms(string dutinstcd) {
  99. using (SaveConsentDac dac = new SaveConsentDac()) {
  100. Hashtable param = new Hashtable();
  101. param.Add("instcd", dutinstcd);
  102. return (List<String>) dac.getOcrType6Forms(this.IbatisMapper, param);
  103. }
  104. }
  105. [WebMethod]
  106. public bool CheckDatabaseConnection() {
  107. // TODO: 데이터 베이스 커넥션 테스트 호출 필요
  108. return false;
  109. }
  110. /// <summary>
  111. /// 동의서 카테고리 조회
  112. /// </summary>
  113. [WebMethod(Description = "동의서 카테고리 조회")]
  114. public List<CategoryForDropdownVO> GetCategoryForDropdown() {
  115. List<CategoryForDropdownVO> result;
  116. try {
  117. using (FormCategoryDac dac = new FormCategoryDac()) {
  118. Hashtable param = new Hashtable();
  119. result = (List<CategoryForDropdownVO>) dac.GetCategoryForDropdown(this.IbatisMapper, param);
  120. }
  121. } catch (Exception ex) {
  122. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm GetCategoryForDropdown error: {0}", ex.Message));
  123. throw ex;
  124. }
  125. return result;
  126. }
  127. /// <summary>
  128. /// 환자, 상태에 따른 동의서 목록 검색
  129. /// </summary>
  130. /// <param name="pid">환자등록번호</param>
  131. /// <param name="userId">사용자 아이디, 작성자별 조회시 pid는 입력하지 않고 userId만 보내줘야함</param>
  132. /// <param name="startDt">데이터생성일자 조회 시작일</param>
  133. /// <param name="endDt">조회 마지막 일자 (현재 일자를 넣음)</param>
  134. /// <param name="consentState">동의서 상태</param>
  135. /// <param name="instCd">근무지기관코드</param>
  136. /// <returns></returns>
  137. [WebMethod(Description = "환자/상태에 따른 동의서 목록 검색")]
  138. public List<ConsentVO> GetConsentList(string pid, string userId, string startDt, string endDt, string consentState, string instCd) {
  139. List<ConsentVO> result;
  140. try {
  141. // 임시저장 조회 시 미작성이 없으면 미작성 상태도 추가
  142. if (!string.IsNullOrEmpty(consentState)) {
  143. bool _hasTemp = false;
  144. bool _hasUnfinished = false;
  145. string[] _stateArr = consentState.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
  146. foreach (string s in _stateArr) {
  147. if (s.Equals("TEMP")) {
  148. _hasTemp = true;
  149. } else if (s.Equals("UNFINISHED")) {
  150. _hasUnfinished = true;
  151. }
  152. }
  153. if (_hasTemp && !_hasUnfinished) {
  154. consentState += ",'UNFINISHED'";
  155. }
  156. }
  157. using (ConsentDac dac = new ConsentDac()) {
  158. Hashtable param = new Hashtable {
  159. { "pid", pid },
  160. { "userId", userId },
  161. { "startDt", startDt },
  162. { "endDt", endDt },
  163. { "consentState", consentState },
  164. { "instCd", instCd }
  165. };
  166. result = (List<ConsentVO>) dac.GetConsentList(this.IbatisMapper, param);
  167. }
  168. return result;
  169. } catch (Exception ex) {
  170. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm GetConsentList error: {0}", ex.Message));
  171. throw ex;
  172. }
  173. }
  174. /// <summary>
  175. /// 환자, 상태에 따른 동의서 목록 검색
  176. /// </summary>
  177. /// <param name="srchDd">환자 조회에 들어가는 날짜, 검사 탭일때는 fromDt</param>
  178. /// <param name="pid">환자등록번호</param>
  179. /// <param name="userId">사용자 아이디, 작성자별 조회시 pid는 입력하지 않고 userId만 보내줘야함</param>
  180. /// <param name="startDt">데이터생성일자 조회 시작일</param>
  181. /// <param name="endDt">조회 마지막 일자 (현재 일자를 넣음)</param>
  182. /// <param name="consentState">동의서 상태</param>
  183. /// <param name="instCd">근무지기관코드</param>
  184. /// <param name="doctorId">의사 아이디</param>
  185. /// <param name="ordDeptCd">진료과 코드</param>
  186. /// <param name="patientState">환자 동의서 상태, ordType가 S 이면 patientState가 입원, 외래, 응급으로 구분한다</param>
  187. /// <param name="ordType">입원(I), 외래(O), 응급(ER), 수술(OP), 검사(EX), 검색(S) 구분 코드</param>
  188. /// <param name="myPatient">ordType가 입원일때 간호사, 의사 내환자 선택여부</param>
  189. /// <param name="wardCd">입원 일때 병동코드</param>
  190. /// <param name="drKind">로그인 사용자 직종 구분 코드 A : 전문의, B : 주치의(교수), C : 그 외 직종</param>
  191. /// <param name="srchYN">검색탭 인지 구분</param>
  192. /// <param name="toDd">검사탭 일때 시작일</param>
  193. /// <param name="mainDr">검사탭 일때 판독의 이름</param>
  194. /// <param name="mainDrChecked">검사탭 일때 판독의, 예정 판독의 구분 Y : 예정 판독의, N : 판독의</param>
  195. /// <param name="supportBaseCd">검사탭 일때 지원부서 베이스 코드</param>
  196. /// <param name="supportDeptCd">검사탭 일때 지원부서 하위 코드</param>
  197. /// <returns></returns>
  198. [WebMethod(Description = "날짜별 확인, 임시 동의서 리스트")]
  199. public List<ConsentVO> GetConsentDateList(string srchDd, string pid, string userId, string startDt, string endDt, string consentState, string instCd, string doctorId, string ordDeptCd, string patientState,
  200. string ordType, string myPatient, string wardCd, string drKind, string srchYN,
  201. string toDd, string mainDr, string mainDrChecked, string supportBaseCd, string supportDeptCd) {
  202. List<ConsentVO> result = null;
  203. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("srchDd -- > " + srchDd);
  204. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("pid -- > " + pid);
  205. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("userId -- > " + userId);
  206. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("startDt -- > " + startDt);
  207. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("endDt -- > " + endDt);
  208. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("consentState -- > " + consentState);
  209. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("instCd -- > " + instCd);
  210. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("doctorId -- > " + doctorId);
  211. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("ordDeptCd -- > " + ordDeptCd);
  212. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("patientState -- > " + patientState);
  213. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("ordType -- > " + ordType);
  214. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("myPatient -- > " + myPatient);
  215. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("wardCd -- > " + wardCd);
  216. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("drKind -- > " + drKind);
  217. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("srchYN -- > " + srchYN);
  218. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("toDd -- > " + toDd);
  219. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("mainDr -- > " + mainDr);
  220. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("mainDrChecked -- > " + mainDrChecked);
  221. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("supportBaseCd -- > " + supportBaseCd);
  222. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("supportDeptCd -- > " + supportDeptCd);
  223. try {
  224. // 임시저장 조회 시 미작성이 없으면 미작성 상태도 추가
  225. if (!string.IsNullOrEmpty(consentState)) {
  226. bool _hasTemp = false;
  227. bool _hasUnfinished = false;
  228. string[] _stateArr = consentState.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
  229. foreach (string s in _stateArr) {
  230. if (s.Equals("TEMP")) {
  231. _hasTemp = true;
  232. } else if (s.Equals("UNFINISHED")) {
  233. _hasUnfinished = true;
  234. }
  235. }
  236. if (_hasTemp && !_hasUnfinished) {
  237. consentState += ",'UNFINISHED'";
  238. }
  239. }
  240. if (ordType == "S") {
  241. ordType = patientState;
  242. }
  243. // 병동 일때
  244. var myPatientFlag = myPatient ?? "N";
  245. wardCd = wardCd ?? "";
  246. userId = userId ?? "";
  247. // 검색탭에서 쓰임
  248. srchYN = srchYN ?? "N";
  249. // 검사 일때
  250. toDd = toDd ?? "";
  251. mainDr = mainDr ?? "";
  252. mainDrChecked = mainDrChecked ?? "";
  253. supportBaseCd = supportBaseCd ?? "";
  254. supportDeptCd = supportDeptCd ?? "";
  255. using (ConsentDac dac = new ConsentDac()) {
  256. Hashtable param = new Hashtable();
  257. param.Add("srchDd", srchDd);
  258. param.Add("pid", pid);
  259. param.Add("userId", userId);
  260. param.Add("startDt", startDt);
  261. param.Add("endDt", endDt);
  262. param.Add("consentState", consentState);
  263. param.Add("instCd", instCd);
  264. param.Add("doctorId", doctorId);
  265. param.Add("ordDeptCd", ordDeptCd);
  266. param.Add("patientState", patientState);
  267. param.Add("ordType", ordType);
  268. param.Add("myPatient", myPatientFlag);
  269. param.Add("wardCd", wardCd);
  270. param.Add("srchYN", srchYN);
  271. param.Add("drKind", drKind);
  272. param.Add("isMainD", mainDrChecked);
  273. param.Add("mainDrId", mainDr);
  274. param.Add("baseCd", supportBaseCd);
  275. param.Add("supportDeptCd", supportDeptCd);
  276. param.Add("toDt", toDd);
  277. param.Add("fromDt", srchDd);
  278. result = (List<ConsentVO>) dac.GetConsentDateList(this.IbatisMapper, param);
  279. }
  280. return result;
  281. } catch (Exception ex) {
  282. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm GetConsentDateList error: {0}", ex.Message));
  283. throw ex;
  284. }
  285. }
  286. /// <summary>
  287. /// 환자 목록에서 환자 선택시 환자 처방연동 서식 리스트
  288. /// </summary>
  289. /// <param name="pid">환자 등록번호</param>
  290. /// <param name="ordDd">진료 일자</param>
  291. /// <returns></returns>
  292. [WebMethod(Description = "환자 처방연동서식")]
  293. public List<ConsentVO> GetPrescriptionConsentList(string pid, string ordDd) {
  294. List<ConsentVO> result;
  295. try {
  296. using (ConsentDac dac = new ConsentDac()) {
  297. Hashtable param = new Hashtable();
  298. param.Add("pid", pid);
  299. param.Add("ordDd", ordDd);
  300. result = (List<ConsentVO>) dac.GetPrescriptionConsentList(this.IbatisMapper, param);
  301. }
  302. return result;
  303. } catch (Exception ex) {
  304. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm GetPrescriptionConsentList error: {0}", ex.Message));
  305. throw ex;
  306. }
  307. }
  308. /// <summary>
  309. /// 동의서 찾기
  310. /// </summary>
  311. /// <param name="categoryId">카테고리 ID 전체 : 빈값</param>
  312. /// <param name="keyWord">검색할 키워드</param>
  313. /// <param name="instCd">근무지기관코드, 101, 031</param>
  314. /// <param name="toDay">오늘 일자, 20190101</param>
  315. /// <returns></returns>
  316. [WebMethod(Description = "동의서 찾기(조회)")]
  317. public List<ConsentVO> GetConsentBySearch(string categoryId, string keyWord, string instCd, string toDay) {
  318. List<ConsentVO> result;
  319. try {
  320. using (ConsentDac dac = new ConsentDac()) {
  321. keyWord = keyWord ?? "";
  322. if (keyWord != "") {
  323. keyWord = string.Format("%{0}%", keyWord);
  324. }
  325. Hashtable param = new Hashtable();
  326. param.Add("categoryId", categoryId);
  327. param.Add("keyWord", keyWord.ToUpper());
  328. param.Add("instCd", instCd);
  329. param.Add("toDay", toDay);
  330. result = (List<ConsentVO>) dac.GetConsentBySearch(this.IbatisMapper, param);
  331. }
  332. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(result);
  333. return result;
  334. } catch (Exception ex) {
  335. System.Diagnostics.Trace.WriteLine(string.Format("CLIP.eForm GetConsentBySearch error: {0}", ex.Message));
  336. throw ex;
  337. }
  338. }
  339. /// <summary>
  340. /// 동의서 SET 조회
  341. /// </summary>
  342. /// <param name="userId">사용자 아이디 107810</param>
  343. /// <param name="instCd">근무지기관코드</param>
  344. /// <param name="toDay">오늘 날짜</param>
  345. [WebMethod(Description = "동의서 SET 조회")]
  346. public List<ConsentVO> GetConsentSetList(string userId, string instCd, string toDay) {
  347. List<ConsentVO> result;
  348. try {
  349. using (ConsentDac dac = new ConsentDac()) {
  350. Hashtable param = new Hashtable();
  351. param.Add("instCd", instCd);
  352. param.Add("userId", userId);
  353. param.Add("toDay", toDay);
  354. result = (List<ConsentVO>) dac.GetConsentSetList(this.IbatisMapper, param);
  355. }
  356. return result;
  357. } catch (Exception ex) {
  358. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm GetConsentSetList error: {0}", ex.Message));
  359. throw ex;
  360. }
  361. }
  362. /// <summary>
  363. /// 동의서 찾기
  364. /// </summary>
  365. /// <param name="calcscorCd">수가코드</param>
  366. /// <returns></returns>
  367. //[WebMethod(Description = "동의서 찾기(수가코드)")]
  368. //public List<ConsentBySearchVO> GetConsentByCalcscorcd(string calcscorCd) {
  369. // List<ConsentBySearchVO> result;
  370. // try {
  371. // using (ConsentDac dac = new ConsentDac()) {
  372. // Hashtable param = new Hashtable();
  373. // param.Add("calcscorcd", calcscorCd);
  374. // result = (List<ConsentBySearchVO>) dac.GetConsentByCalcscorcd(this.IbatisMapper, param);
  375. // }
  376. // return result;
  377. // } catch (Exception ex) {
  378. // System.Diagnostics.Trace.WriteLine(string.Format("CLIP.eForm GetConsentByCalcscorcd error: {0}", ex.Message));
  379. // throw ex;
  380. // }
  381. //}
  382. /// <summary>
  383. /// 동의서 찾기
  384. /// </summary>
  385. /// <param name="formCd">서식코드</param>
  386. /// <param name="instCd">근무지기관코드</param>
  387. /// <returns>ConsentBySearchVO 객체 List</returns>
  388. [WebMethod(Description = "동의서 찾기(서식코드)")]
  389. public List<ConsentVO> GetConsentByFormcd(string formCd, string instCd, string today) {
  390. List<ConsentVO> result;
  391. try {
  392. using (ConsentDac dac = new ConsentDac()) {
  393. Hashtable param = new Hashtable();
  394. string formCdArr = "";
  395. if(formCd.Length == 0) {
  396. return null;
  397. }
  398. string[] cdArr = formCd.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
  399. for (int i = 0; i < cdArr.Length; i++) {
  400. formCdArr += string.Format("'{0}',", cdArr[i].Trim());
  401. }
  402. formCdArr = formCdArr.Remove(formCdArr.Length - 1);
  403. param.Add("formcdarr", formCdArr);
  404. param.Add("instCd", instCd);
  405. param.Add("today", today);
  406. result = (List<ConsentVO>) dac.getConsentByFormcd(this.IbatisMapper, param);
  407. }
  408. return result;
  409. } catch (Exception ex) {
  410. System.Diagnostics.Trace.WriteLine(string.Format("CLIP.eForm GetConsentByFormcd error: {0}", ex.Message));
  411. throw ex;
  412. }
  413. }
  414. /// <summary>
  415. /// 동의서 재인증 여부
  416. /// </summary>
  417. /// <param name="pid">환자 등록번호</param>
  418. /// <param name="ordDd">진료 일자</param>
  419. /// <param name="cretNo">수진 일련번호</param>
  420. /// <param name="ordType">내원 경로 입원 : I, 외래 : O, 응급 : ER, 수술 : OP, 검사 : EX</param>
  421. /// <param name="recDd">동의서 작성 일자</param>
  422. /// <param name="userId">사용자 아이디</param>
  423. [WebMethod(Description = "동의서 재인증 여부")]
  424. public SingleReturnData ReUseCertifyConsentFlag(string pid, string ordDd, string cretNo, string ordType, string recDd, string userId) {
  425. SingleReturnData rts = new SingleReturnData();
  426. try {
  427. using (ConsentDac dac = new ConsentDac()) {
  428. Hashtable param = new Hashtable();
  429. param.Add("vInstcd", "101");
  430. param.Add("vPid", pid);
  431. param.Add("vOrddd", ordDd);
  432. param.Add("vCretno", cretNo);
  433. param.Add("vOrdtype", ordType);
  434. param.Add("vRecdd", recDd);
  435. param.Add("vUserid", userId);
  436. string result = dac.ReUseCertifyConsentFlag(this.IbatisMapper, param);
  437. rts.responseData = result;
  438. }
  439. } catch (Exception ex) {
  440. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm ReUseCertifyConsentFlag error: {0}", ex.Message));
  441. throw ex;
  442. }
  443. return rts;
  444. }
  445. /// <summary>
  446. /// 일괄인증 허용 사용자 여부
  447. /// </summary>
  448. /// <param name="instcd"></param>
  449. /// <param name="userid"></param>
  450. /// <returns>OK 일때 일괄인증 수행, 그외의 값은 일괄인증 허가되지 않음</returns>
  451. [WebMethod(Description = "일괄인증 허용 사용자 여부")]
  452. public SingleReturnData getSaveAllFlag(string instcd, string userid) {
  453. //string retValue = string.Empty;
  454. SingleReturnData retValue = new SingleReturnData();
  455. String result = "";
  456. try {
  457. using (ConsentDac dac = new ConsentDac()) {
  458. Hashtable param = new Hashtable();
  459. param.Add("instcd", "101");
  460. param.Add("userid", userid);
  461. result = dac.getSaveAllFlag(this.IbatisMapper, param);
  462. retValue.responseData = result;
  463. }
  464. }catch(Exception e) {
  465. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm getSaveAllFlag error: {0}", e.Message));
  466. }
  467. return retValue;
  468. }
  469. /// <summary>
  470. /// CONSENT_MST_RID를 갖고 저장된 동의서 이미지를 조회
  471. /// </summary>
  472. /// <param name="consentMstRid">동의서 마스터 데이터 Rid</param>
  473. [WebMethod(Description = "동의서 저장된 이미지 내역 조회")]
  474. public List<ConsentImageVO> GetConsentImage(string consentMstRid) {
  475. List<ConsentImageVO> result;
  476. try {
  477. using (ConsentDac dac = new ConsentDac()) {
  478. string remotePath = "";
  479. Dictionary<String, String> remoteData = remoteInfo();
  480. Hashtable param = new Hashtable();
  481. int consentMstRidInt = 0;
  482. int.TryParse(consentMstRid, out consentMstRidInt);
  483. param.Add("consent-mst-rid", consentMstRidInt);
  484. result = (List<ConsentImageVO>) dac.GetConsentImage(this.IbatisMapper, param);
  485. remotePath = result[0].imagePath;
  486. // 계정을 choiadmin 으로 가장한다
  487. ClipSoft.Utility.ImpersonationUtility util = new ClipSoft.Utility.ImpersonationUtility();
  488. var imResult = util.ImpersonationStart(remotePath, remoteData["NETDRV_USERID_ADMIN"], remoteData["NETDRV_PASSWORD_ADMIN"]);
  489. // for debug
  490. DirectoryInfo destDi = new DirectoryInfo(Server.MapPath("DataTempImage"));
  491. var destDirStr = destDi.ToString();
  492. DirectoryInfo origDi = new DirectoryInfo(remotePath);
  493. // 해당 경로에 디렉토리가 없다면 생성하여 준다
  494. if (!destDi.Exists) {
  495. destDi.Create();
  496. }
  497. foreach (ConsentImageVO img in result) {
  498. var origFullPath = String.Format(@"{0}\{1}", origDi, img.imageFilename);
  499. var destFullPath = String.Format(@"{0}\{1}{2}", destDirStr, img.imageFilename, ".jpg");
  500. try {
  501. // 파일이 존재하면 덮어 쓴다.
  502. File.Copy(origFullPath, destFullPath, true);
  503. } catch (Exception e) {
  504. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("file copy error", e);
  505. }
  506. img.imagePath = "DataTempImage";
  507. img.imageFilename = img.imageFilename + ".jpg";
  508. }
  509. util.ImpersonationEnd();
  510. }
  511. // ?? 왜 로컬에 있는 tempfile 들을 삭제할까?
  512. //int iResult = DeleteTempFile();
  513. return result;
  514. } catch (Exception ex) {
  515. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm GetConsentImage error: {0}", ex.Message));
  516. throw ex;
  517. }
  518. }
  519. [WebMethod(Description = "동의서 저장된 음성 녹음 파일 갯수 확인")]
  520. public SingleReturnData GetConsentAudioCount(string consentMstRid) {
  521. SingleReturnData rts = new SingleReturnData();
  522. try {
  523. using (ConsentDac dac = new ConsentDac()) {
  524. Hashtable param = new Hashtable();
  525. param.Add("consentMstRid", consentMstRid);
  526. int result = 0;
  527. result = (int) dac.GetConsentAudioCount(this.IbatisMapper, param);
  528. rts.responseData = Convert.ToString(result);
  529. }
  530. } catch (Exception ex) {
  531. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm GetConsentAudio error: {0}", ex.Message));
  532. throw ex;
  533. }
  534. return rts;
  535. }
  536. [WebMethod(Description = "동의서 저장된 음성 녹음 파일 내역 조회")]
  537. public List<ConsentImageVO> GetConsentAudio(string consentMstRid) {
  538. List<ConsentImageVO> result;
  539. try {
  540. using (ConsentDac dac = new ConsentDac()) {
  541. string remotePath = "";
  542. Dictionary<String, String> remoteData = remoteInfo();
  543. Hashtable param = new Hashtable();
  544. int consentMstRidInt = 0;
  545. int.TryParse(consentMstRid, out consentMstRidInt);
  546. param.Add("consentMstRid", consentMstRid);
  547. result = (List<ConsentImageVO>) dac.getConsentAudio(this.IbatisMapper, param);
  548. if(result.Count > 0) {
  549. remotePath = result[0].imagePath;
  550. ClipSoft.Utility.ImpersonationUtility util = new ClipSoft.Utility.ImpersonationUtility();
  551. var imResult = util.ImpersonationStart(remotePath, remoteData["NETDRV_USERID_ADMIN"], remoteData["NETDRV_PASSWORD_ADMIN"]);
  552. DirectoryInfo destDi = new DirectoryInfo(Server.MapPath("DataTempImage"));
  553. var destDirStr = destDi.ToString();
  554. DirectoryInfo origDi = new DirectoryInfo(remotePath);
  555. // 해당 경로에 디렉토리가 없다면 생성하여 준다
  556. if (!destDi.Exists) {
  557. destDi.Create();
  558. }
  559. foreach (ConsentImageVO img in result) {
  560. var origFullPath = String.Format(@"{0}\{1}", origDi, img.imageFilename);
  561. var destFullPath = String.Format(@"{0}\{1}{2}", destDirStr, img.imageFilename, ".mp4");
  562. try {
  563. File.Copy(origFullPath, destFullPath, true);
  564. } catch (Exception e) {
  565. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("file copy error", e);
  566. }
  567. img.imagePath = "DataTempImage";
  568. img.imageFilename = img.imageFilename + ".mp4";
  569. }
  570. util.ImpersonationEnd();
  571. }
  572. }
  573. return result;
  574. } catch (Exception ex) {
  575. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm GetConsentAudio error: {0}", ex.Message));
  576. throw ex;
  577. }
  578. }
  579. /// <summary>
  580. /// 임시저장 동의서 삭제
  581. /// </summary>
  582. /// <param name="userId"></param>
  583. /// <param name="consentMstRid"></param>
  584. /// <param name="reasonForUseN"></param>
  585. [WebMethod(Description = "임시저장 동의서 삭제")]
  586. public SingleReturnData saveDelete(string userId, string consentMstRid, string reasonForUseN) {
  587. SingleReturnData rts = new SingleReturnData();
  588. int result = 0;
  589. string ocrTag = "";
  590. try {
  591. if (this.IbatisSession.IsTransactionStart == false) {
  592. this.IbatisSession.BeginTransaction();
  593. }
  594. using (SaveConsentDac dac = new SaveConsentDac()) {
  595. Hashtable param = new Hashtable();
  596. param.Add("userId", userId);
  597. param.Add("consentMstRid", consentMstRid);
  598. param.Add("reasonForUseN", reasonForUseN);
  599. ocrTag = dac.UpdateConsentMstForDelete(this.IbatisMapper, param);
  600. if (!string.IsNullOrEmpty(ocrTag)) {
  601. param.Add("ocrTag", ocrTag);
  602. result = dac.UpdateMrfhocrprntStatCd(this.IbatisMapper, param);
  603. }
  604. rts.responseData = Convert.ToString(result);
  605. }
  606. if (this.IbatisSession != null) this.IbatisSession.CommitTransaction();
  607. } catch (Exception ex) {
  608. if (this.IbatisSession != null) this.IbatisSession.RollBackTransaction();
  609. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm saveDelete ERROR : [{0}]", ex.ToString()));
  610. throw ex;
  611. }
  612. return rts;
  613. }
  614. /// <summary>
  615. /// 임시저장, 확인저장
  616. /// </summary>
  617. /// <param name="userId">로그인 사용자ID</param>
  618. /// <param name="userDeptCd">로그인 사용자 부서 코드</param>
  619. /// <param name="pid">환자 등록번호</param>
  620. /// <param name="formId">서식 ID</param>
  621. /// <param name="formCd">서식 코드</param>
  622. /// <param name="patientDeptCd">환자가 내원한, 속해있는 부서 코드</param>
  623. /// <param name="formXml">서식 정보</param>
  624. /// <param name="dataXml">사용자가 작성한 서식 내용</param>
  625. /// <param name="consentMstRid">동의서 마스터 데이터 Rid</param>
  626. /// <param name="reWriteconsentMstRid">재 작성 대상 동의서 마스터 데이터 Rid</param>
  627. /// <param name="deviceType">장비 유형 (WIN, AND, IOS, PRT 중1)</param>
  628. /// <param name="deviceMacAddr">장비 고유 식별자</param>
  629. /// <param name="ordType">내원 구분 입원 : I, 외래 : O, 수술 : OP, 응급 : ER</param>
  630. /// <param name="instCd">근무지 기관코드</param>
  631. /// <param name="inDd">내원 일자 입원 : inDd, 외래 : ordDd</param>
  632. /// <param name="ward">병동</param>
  633. /// <param name="roomCd">병실</param>
  634. /// <param name="ocrTag">ocrTag</param>
  635. /// <param name="cretNo">생성번호</param>
  636. /// <param name="mainDrId">환자를 담당하는 의사(담당교수, 주치의, 담당의사 등)</param>
  637. /// <param name="formPageCnt">동의서 총 장수</param>
  638. /// <param name="actionKind">임시저장 : T, 인증저장 : C</param>
  639. /// <param name="opRsrvNo">수술번호</param>
  640. /// <param name="consentState">동의서 상태</param>
  641. /// <param name="orderNo">처방번호</param> 20190822 원형만 유지하되 당장 사용하지 않음
  642. /// <param name="orderName">처방 이름</param> 20190822 원형만 유지하되 당장 사용하지 않음
  643. /// <param name="orderCd">처방 코드?</param> 20190822 원형만 유지하되 당장 사용하지 않음
  644. /// <param name="audioFileJson">음성녹음 바이너리 데이터</param>
  645. /// <param name="audioFileSize">음성녹음 파일 사이즈</param>
  646. /// <param name="imageFileJson">이미지 바이너리 데이터</param>
  647. /// <param name="fileSize">이미지 파일 사이즈</param>
  648. /// <returns></returns>
  649. [WebMethod(Description = "동의서 임시저장")]
  650. public SingleReturnData SaveTempData(string userId, string userDeptCd, string pid, string formId, string formCd, string patientDeptCd, string formXml, string dataXml,
  651. int consentMstRid, int reWriteConsentMstRid, string deviceType, string deviceMacAddr, string ordType, string instCd, string inDd, string dSchDd,
  652. string ward, string roomCd, string ocrTag, int cretNo, string mainDrId, string formPageCnt, string actionKind, string opRsrvNo, string consentState,
  653. int orderNo, string orderName, string orderCd, string audioFileJson, string audioFileSize, string imageFileJson, string fileSize) {
  654. SingleReturnData result = new SingleReturnData();
  655. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(String.Format("userId -- > [{0}]", userId));
  656. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("userDeptCd -- > " + userDeptCd);
  657. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("pid -- > " + pid);
  658. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("formId -- > " + formId);
  659. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("formCd -- > " + formCd);
  660. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("patientDeptCd -- > " + patientDeptCd);
  661. ////CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("formXml -- > " + formXml);
  662. ////CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("dataXml -- > " + dataXml);
  663. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("consentMstRid -- > " + consentMstRid);
  664. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("reWriteConsentMstRid -- > " + reWriteConsentMstRid);
  665. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("deviceType -- > " + deviceType);
  666. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("deviceMacAddr -- > " + deviceMacAddr);
  667. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("ordType -- > " + ordType);
  668. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("instCd -- > " + instCd);
  669. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("inDd -- > " + inDd);
  670. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("ward -- > " + ward);
  671. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("roomCd -- > " + roomCd);
  672. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("ocrTag -- > " + ocrTag);
  673. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("cretNo -- > " + cretNo);
  674. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("mainDrId -- > " + mainDrId);
  675. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("formPageCnt -- > " + formPageCnt);
  676. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("actionKind -- > " + actionKind);
  677. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("opRsrvNo -- > " + opRsrvNo);
  678. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("consentState -- > " + consentState);
  679. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("orderNo -- > " + orderNo);
  680. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("orderName -- > " + orderName);
  681. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("orderCd -- > " + orderCd);
  682. consentMstRid = SaveData(userId, userDeptCd, pid, formId, formCd, patientDeptCd, formXml, dataXml,
  683. consentMstRid, reWriteConsentMstRid, deviceType, deviceMacAddr, ordType, instCd, inDd, dSchDd,
  684. ward, roomCd, ocrTag, cretNo, mainDrId, formPageCnt, actionKind, opRsrvNo, consentState,
  685. orderNo, orderName, orderCd, audioFileJson, audioFileSize, imageFileJson, fileSize);
  686. result.responseData = Convert.ToString(consentMstRid);
  687. return result;
  688. }
  689. public int SaveData(string userId, string userDeptCd, string pid, string formId, string formCd, string patientDeptCd, string formXml, string dataXml,
  690. int consentMstRid, int reWriteConsentMstRid, string deviceType, string deviceMacAddr, string ordType, string instCd, string inDd, string dSchDd,
  691. string ward, string roomCd, string ocrTag, int cretNo, string mainDrId, string formPageCnt, string actionKind, string opRsrvNo, string consentState,
  692. int orderNo, string orderName, string orderCd, string audioFileJson, string audioFileSize, string imageFileJson, string fileSize) {
  693. bool isNewConsentMasterCase = false;
  694. if (consentMstRid < 1) {
  695. isNewConsentMasterCase = true;
  696. }
  697. if (this.IbatisSession.IsTransactionStart == false) {
  698. this.IbatisSession.BeginTransaction();
  699. }
  700. try {
  701. using (SaveConsentDac dac = new SaveConsentDac()) {
  702. int updateResult = 0;
  703. int deleteResult = 0;
  704. Hashtable imrParam = new Hashtable();
  705. imrParam.Add("ocrTag", "'" + ocrTag + "%'");
  706. int imrCount = (int) dac.ImrCount(this.IbatisMapper, imrParam);
  707. ImrData imrData = new ImrData();
  708. if (imrCount > 0) {
  709. imrData = (ImrData) dac.ImrData(this.IbatisMapper, imrParam);
  710. }
  711. Hashtable paramHashTable = GetParamHashTable(userId, userDeptCd, pid, formId, formCd, patientDeptCd, formXml, dataXml,
  712. consentMstRid, reWriteConsentMstRid, deviceType, deviceMacAddr, ordType, instCd, inDd,
  713. ward, roomCd, ocrTag, cretNo, mainDrId, formPageCnt, actionKind, opRsrvNo, consentState,
  714. orderNo, orderName, orderCd, null, null);
  715. //reasonForUseN
  716. paramHashTable.Add("macAddress", deviceMacAddr);
  717. consentMstRid = (int) paramHashTable["consentMstRid"];
  718. if (isNewConsentMasterCase == true) {
  719. dac.InsertConsentMst(this.IbatisMapper, paramHashTable);
  720. dac.InsertConsentData(this.IbatisMapper, paramHashTable);
  721. } else {
  722. dac.UpdateConsentMst(this.IbatisMapper, paramHashTable);
  723. dac.UpdateConsentData(this.IbatisMapper, paramHashTable);
  724. }
  725. if (!string.IsNullOrEmpty(audioFileJson)) {
  726. audioUpLoad(dac, paramHashTable, userId, consentMstRid, formId, audioFileJson, audioFileSize, ocrTag, pid);
  727. }
  728. if (!string.IsNullOrEmpty(imageFileJson)) {
  729. imageUpload(dac, paramHashTable, userId, pid, ordType, inDd, dSchDd, cretNo, ocrTag, consentMstRid, consentState, formCd, formId, dataXml, imageFileJson, instCd, patientDeptCd, fileSize);
  730. }
  731. if (imrCount > 0) {
  732. String[] strAr = imrData.fileName.Split(new char[] { '_' });
  733. imrData.fileName = strAr[0] + "_" + strAr[1];
  734. imrParam.Add("fileName", "'" + imrData.fileName + "%'");
  735. imrParam.Add("inputDate", imrData.inputDate);
  736. imrParam.Add("userId", imrData.userId);
  737. updateResult = dac.ImrScanFileUpdate(this.IbatisMapper, imrParam);
  738. if (updateResult > 0) {
  739. deleteResult = dac.ImrScanFileDelete(this.IbatisMapper, imrParam);
  740. }
  741. if (imrCount != deleteResult) {
  742. throw new Exception();
  743. }
  744. }
  745. Hashtable ocrParam = new Hashtable {
  746. { "instcd", instCd },
  747. { "ocrtag", ocrTag },
  748. { "pid", pid },
  749. { "ordtype", ordType },
  750. { "orddd", inDd },
  751. { "cretno", cretNo },
  752. { "orddrid", mainDrId },
  753. { "orddeptcd", patientDeptCd },
  754. { "formcd", formCd },
  755. { "fstprntdeptcd", userDeptCd },
  756. { "fstprntid", userId },
  757. { "updtdeptcd", userDeptCd },
  758. { "updtuserid", userId },
  759. { "updtdt", DateTime.Now.ToString("yyyyMMddHHmmss")},
  760. { "pagecnt", formPageCnt },
  761. //{ "updtresncnts", reasonForUseN },
  762. { "actkind", actionKind },
  763. { "clienttype", "M" }
  764. };
  765. dac.InsertPrintData(this.IbatisMapper, ocrParam);
  766. if (this.IbatisSession != null) this.IbatisSession.CommitTransaction();
  767. }
  768. } catch (Exception ex) {
  769. if (this.IbatisSession != null) this.IbatisSession.RollBackTransaction();
  770. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm SaveData ERROR : [{0}]", ex.ToString()));
  771. throw ex;
  772. }
  773. return consentMstRid;
  774. }
  775. private void audioUpLoad(SaveConsentDac dac, Hashtable paramHashTable, string userId, int consentMstRid, string formId, string audioFileJson, string audioFileSize, string ocrTag, string pid) {
  776. Dictionary<String, String> remoteData = remoteInfo();
  777. try {
  778. string[] fileSizeAr = audioFileSize.Split(new char[] { ',' });
  779. int consentImageRid = this.GetSequence("CONSENT_AUDIO");
  780. string sPath = string.Empty;
  781. string sFileName = string.Empty;
  782. Dictionary<string, object> jsonRoot = null;
  783. jsonRoot = fastJSON.JSON.Parse(audioFileJson) as Dictionary<string, object>;
  784. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("fileSize -- > " + audioFileSize);
  785. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("audioFileJson -- > " + audioFileJson);
  786. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("jsonRoot -- > " + jsonRoot);
  787. if (jsonRoot != null && jsonRoot.Count > 0) {
  788. Hashtable audioHashTable = null;
  789. int nowCnt = 1;
  790. int audioCnt = 1;
  791. foreach (KeyValuePair<string, object> jr in jsonRoot) {
  792. audioHashTable = new Hashtable();
  793. audioHashTable.Add("consentMstRid", consentMstRid);
  794. if (nowCnt > 1) {
  795. consentImageRid = this.GetSequence("CONSENT_AUDIO");
  796. }
  797. audioHashTable.Add("consentImageRid", consentImageRid);
  798. audioHashTable.Add("userId", userId);
  799. audioHashTable.Add("formId", formId);
  800. if (jr.Value != null && !string.IsNullOrEmpty(jr.Value.ToString())) {
  801. sPath = "";
  802. sFileName = "";
  803. string[] filePath = jr.Value.ToString().Split('/');
  804. for (int i = 0; i < filePath.Length; i++) {
  805. if (i == 0) {
  806. sPath = filePath[i];
  807. } else if ((i + 1) == filePath.Length) {
  808. sFileName = filePath[i];
  809. } else {
  810. sPath += "/" + filePath[i];
  811. }
  812. }
  813. var date = DateTime.Now.ToString("yyyyMM");
  814. var uniqDatetime = DateTime.Now.ToString("yyyyMMddhhmmss");
  815. string uploadFileName = "audio_" + uniqDatetime + "_" + ocrTag + "_" + audioCnt;
  816. string sUploadPath = uploadFileName.Substring(4, 4);
  817. string sUploadFileName = uploadFileName.Substring(uploadFileName.LastIndexOf("\\") + 1);
  818. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("uploadFileName -- > " + uploadFileName);
  819. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("sUploadPath -- > " + sUploadPath);
  820. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("sUploadFileName -- > " + sUploadFileName);
  821. audioCnt++;
  822. //var remotePath = remoteData["IMAGEPATH"] + "\\temp_" + remoteData["PATH_IMGDATA"] + "\\" + date + "\\" + pid;
  823. var remotePath = remoteData["IMAGEPATH"] + "\\" + remoteData["PATH_IMGDATA"] + "\\" + date + "\\" + pid;
  824. ClipSoft.Utility.ImpersonationUtility util = new ClipSoft.Utility.ImpersonationUtility();
  825. var imResult = util.ImpersonationStart(remotePath, remoteData["NETDRV_USERID_ADMIN"], remoteData["NETDRV_PASSWORD_ADMIN"]);
  826. DirectoryInfo destDi = new DirectoryInfo(remotePath);
  827. string destDirStr = destDi.Name;
  828. var destFullname = String.Format(@"{0}\{1}", remotePath, sUploadFileName);
  829. var localFile = Server.MapPath(string.Format(@"./UPLOAD/{0}/{1}", sPath, sFileName));
  830. if (!destDi.Exists) {
  831. destDi.Create();
  832. }
  833. try {
  834. File.Copy(localFile, destFullname, true);
  835. } catch (Exception ex) {
  836. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm audioUpLoad fileCopy ERROR : [{0}]", ex.ToString()));
  837. throw ex;
  838. }
  839. util.ImpersonationEnd();
  840. audioHashTable.Add("audioPath", remotePath);
  841. audioHashTable.Add("audioFilename", sUploadFileName);
  842. audioHashTable.Add("completeYn", paramHashTable["completeYn"]);
  843. dac.InsertConsentAudio(this.IbatisMapper, audioHashTable);
  844. }
  845. }
  846. nowCnt++;
  847. }
  848. } catch (Exception ex) {
  849. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm audioUpLoad ERROR : [{0}]", ex.ToString()));
  850. throw ex;
  851. }
  852. }
  853. private Hashtable GetParamHashTable(string userId, string userDeptCd, string pid, string formId, string formCd, string patientDeptCd, string formXml, string dataXml,
  854. int consentMstRid, int reWriteConsentMstRid, string deviceType, string deviceMacAddr, string ordType, string instCd, string inDd,
  855. string ward, string roomCd, string ocrTag, int cretNo, string mainDrId, string formPageCnt, string actionKind, string opRsrvNo, string consentState,
  856. int orderNo, string orderName, string orderCd, string certResult, string certTarget) {
  857. Hashtable paramHashTable = new Hashtable();
  858. paramHashTable.Add("userId", userId);
  859. if (consentMstRid < 1) {
  860. consentMstRid = this.GetSequence("CONSENT_MST");
  861. }
  862. paramHashTable.Add("consentMstRid", consentMstRid);
  863. paramHashTable.Add("patientCode", pid);
  864. paramHashTable.Add("clnDeptCd", patientDeptCd);
  865. paramHashTable.Add("vistType", ordType);
  866. paramHashTable.Add("hosType", instCd);
  867. paramHashTable.Add("clnDate", inDd);
  868. paramHashTable.Add("ward", ward);
  869. paramHashTable.Add("roomcd", roomCd);
  870. paramHashTable.Add("orderNo", orderNo);
  871. paramHashTable.Add("orderName", orderName);
  872. paramHashTable.Add("orderCd", orderCd);
  873. paramHashTable.Add("ocrCode", ocrTag);
  874. paramHashTable.Add("cretno", cretNo);
  875. paramHashTable.Add("createUserName", userId);
  876. paramHashTable.Add("modifyUserName", userId);
  877. paramHashTable.Add("formRid", formId);
  878. paramHashTable.Add("formCd", formCd);
  879. paramHashTable.Add("consentState", consentState);
  880. paramHashTable.Add("certTarget", certTarget); // TODO 원무 pass
  881. paramHashTable.Add("certResult", certResult); // TODO 원무 pass
  882. paramHashTable.Add("mainDrId", mainDrId);
  883. paramHashTable.Add("opRsrvNo", opRsrvNo ?? string.Empty);
  884. string completeYn = "N"; // 완료 여부
  885. switch (consentState) {
  886. case "ELECTR_CMP":
  887. case "CERTIFY_CMP":
  888. completeYn = "Y";
  889. break;
  890. default:
  891. break;
  892. }
  893. paramHashTable.Add("completeYn", completeYn);
  894. string completeDateTimeToChars = string.Empty;
  895. if (completeYn.Equals("Y")) {
  896. completeDateTimeToChars = "TO_CHAR(SYSDATE,'YYYY-MM-DD hh24:mi:ss')";
  897. paramHashTable.Add("completeDateTimeToChars", completeDateTimeToChars);
  898. } else {
  899. paramHashTable.Add("completeDateTimeToChars", "''");
  900. }
  901. string rewriteYn = "N"; // 재 작성 여부
  902. if (reWriteConsentMstRid > 1) {
  903. rewriteYn = "Y";
  904. }
  905. paramHashTable.Add("rewriteYn", rewriteYn);
  906. paramHashTable.Add("rewriteConsentMstRid", reWriteConsentMstRid);
  907. int consentDataRid = this.GetSequence("CONSENT_DATA");
  908. paramHashTable.Add("consentDataRid", consentDataRid);
  909. paramHashTable.Add("useYn", "Y");
  910. Encoding encoding = Encoding.GetEncoding("UTF-8");
  911. byte[] formBytesConent = null;
  912. if (!string.IsNullOrEmpty(formXml)) {
  913. formBytesConent = encoding.GetBytes(formXml);
  914. }
  915. byte[] dataBytesConent = null;
  916. if (!string.IsNullOrEmpty(dataXml)) {
  917. dataBytesConent = encoding.GetBytes(dataXml);
  918. }
  919. paramHashTable.Add("formXml", formBytesConent);
  920. paramHashTable.Add("dataXml", dataBytesConent);
  921. paramHashTable.Add("deviceType", deviceType);
  922. paramHashTable.Add("deviceMacAddr", deviceMacAddr);
  923. paramHashTable.Add("pageCnt", formPageCnt);
  924. //paramHashTable.Add("reasonForUseN", reasonForUseN);
  925. return paramHashTable;
  926. }
  927. /// <summary>
  928. /// 일괄인증저장
  929. /// </summary>
  930. /// <param name="userId">사용자 아이디</param>
  931. /// <param name="userName">사용자 이름</param>
  932. /// <param name="macAddress">macAddress</param>
  933. /// <param name="json">일괄인증저장 되어야할 데이터 json string |%%|로 붙어서 나옴</param>
  934. [WebMethod(Description = "일괄 인증저장")]
  935. public SingleReturnData SaveAutoCompleteAll(string userId, string userName, string macAddress, string json) {
  936. SingleReturnData result = new SingleReturnData();
  937. string success = "false";
  938. int updateResult = 0;
  939. try {
  940. if (!string.IsNullOrEmpty(json)) {
  941. using (SaveConsentDac dac = new SaveConsentDac()) {
  942. if (this.IbatisSession.IsTransactionStart == false) {
  943. this.IbatisSession.BeginTransaction();
  944. }
  945. string[] separatingStrings = { "|%%|" };
  946. string[] jsonAr = json.Split(separatingStrings, System.StringSplitOptions.RemoveEmptyEntries);
  947. for (int i = 0; i < jsonAr.Length; i++) {
  948. string jsonData = jsonAr[i];
  949. Dictionary<string, object> jsonRoot = fastJSON.JSON.Parse(jsonData) as Dictionary<string, object>; ;
  950. if (jsonRoot != null && jsonRoot.Count > 0) {
  951. Hashtable dataTable = new Hashtable();
  952. string idx = jsonRoot["idx"].ToString();
  953. string consentMstRid = jsonRoot["consentMstRid"].ToString();
  954. string pid = jsonRoot["pid"].ToString();
  955. string ocrTag = jsonRoot["ocrTag"].ToString();
  956. string deptCd = jsonRoot["deptCd"].ToString();
  957. dataTable.Add("userId", userId);
  958. dataTable.Add("userName", userName);
  959. dataTable.Add("idx", idx);
  960. dataTable.Add("consentMstRid", consentMstRid);
  961. dataTable.Add("consentState", "CERTIFY_CMP");
  962. dataTable.Add("pid", pid);
  963. dataTable.Add("ocrTag", ocrTag);
  964. dataTable.Add("deptCd", deptCd);
  965. dataTable.Add("updtdt", DateTime.Now.ToString("yyyyMMddHHmmss"));
  966. dataTable.Add("macAddress", macAddress);
  967. updateResult = dac.SaveAutoCompleteAll(this.IbatisMapper, dataTable);
  968. if (updateResult < 0) {
  969. new Exception();
  970. }
  971. }
  972. }
  973. }
  974. success = "true";
  975. if (this.IbatisSession != null) this.IbatisSession.CommitTransaction();
  976. }
  977. } catch (Exception ex) {
  978. success = "false";
  979. if (this.IbatisSession != null) this.IbatisSession.RollBackTransaction();
  980. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm SaveAutoCompleteAll ERROR : [{0}]", ex.ToString()));
  981. }
  982. //if (!string.IsNullOrEmpty(json)) {
  983. //Dictionary<string, string> jsonRoot = null;
  984. //jsonRoot = fastJSON.JSON.Parse(json) as Dictionary<string, string>;
  985. // if (jsonRoot != null && jsonRoot.Count > 0) {
  986. // Hashtable imageHashTable = new Hashtable();
  987. // foreach (KeyValuePair<string, string> jr in jsonRoot) {
  988. // int i = 0;
  989. // }
  990. // }
  991. //}
  992. result.responseData = success;
  993. return result;
  994. }
  995. [WebMethod(Description = "테스트")]
  996. public ImrData imrTest() {
  997. int imrCount = 0;
  998. ImrData imrData = new ImrData();
  999. try {
  1000. using (SaveConsentDac dac = new SaveConsentDac()) {
  1001. Hashtable imrParam = new Hashtable();
  1002. //var pValue = ocr + "%;
  1003. imrParam.Add("ocrTag", "'2019121952292%'");
  1004. imrParam.Add("inputDate", "20191219 10:11:53");
  1005. imrParam.Add("userId", "E00004");
  1006. imrData = (ImrData) dac.ImrData(this.IbatisMapper, imrParam);
  1007. String[] strAr = imrData.fileName.Split(new char[] { '_' });
  1008. imrData.fileName = strAr[0] + "_" + strAr[1];
  1009. imrParam.Add("fileName", "'" + imrData.fileName + "%'");
  1010. int result = dac.ImrScanFileDelete(this.IbatisMapper, imrParam);
  1011. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("result -- > " + result);
  1012. }
  1013. } catch (Exception ex) {
  1014. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm SaveDataAll ERROR : [{0}]", ex.ToString()));
  1015. }
  1016. return imrData;
  1017. }
  1018. /// <summary>
  1019. /// 임시저장, 확인저장
  1020. /// </summary>
  1021. /// <param name="userId">로그인 사용자ID</param>
  1022. /// <param name="userDeptCd">로그인 사용자 부서 코드</param>
  1023. /// <param name="pid">환자 등록번호</param>
  1024. /// <param name="formId">서식 ID</param>
  1025. /// <param name="formCd">서식 코드</param>
  1026. /// <param name="patientDeptCd">환자가 내원한, 속해있는 부서 코드</param>
  1027. /// <param name="formXml">서식 정보</param>
  1028. /// <param name="dataXml">사용자가 작성한 서식 내용</param>
  1029. /// <param name="consentMstRid">동의서 마스터 데이터 Rid</param>
  1030. /// <param name="reWriteconsentMstRid">재 작성 대상 동의서 마스터 데이터 Rid</param>
  1031. /// <param name="deviceType">장비 유형 (WIN, AND, IOS, PRT 중1)</param>
  1032. /// <param name="deviceMacAddr">장비 고유 식별자</param>
  1033. /// <param name="ordType">내원 구분 입원 : I, 외래 : O, 수술 : OP, 응급 : ER</param>
  1034. /// <param name="instCd">근무지 기관코드</param>
  1035. /// <param name="inDd">내원 일자 입원 : inDd, 외래 : ordDd</param>
  1036. /// <param name="ward">병동</param>
  1037. /// <param name="roomCd">병실</param>
  1038. /// <param name="ocrTag">ocrTag</param>
  1039. /// <param name="cretNo">생성번호</param>
  1040. /// <param name="mainDrId">환자를 담당하는 의사(담당교수, 주치의, 담당의사 등)</param>
  1041. /// <param name="formPageCnt">동의서 총 장수</param>
  1042. /// <param name="actionKind">임시저장 : T, 인증저장 : C</param>
  1043. /// <param name="opRsrvNo">수술번호</param>
  1044. /// <param name="consentState">동의서 상태</param>
  1045. /// <param name="orderNo">처방번호</param> 20190822 원형만 유지하되 당장 사용하지 않음
  1046. /// <param name="orderName">처방 이름</param> 20190822 원형만 유지하되 당장 사용하지 않음
  1047. /// <param name="orderCd">처방 코드?</param> 20190822 원형만 유지하되 당장 사용하지 않음
  1048. /// <param name="imageFileJson">이미지 파일 정보(전자동의서 서버)</param>
  1049. /// <param name="fileSize">이미지 파일 사이즈(전자동의서 서버)</param>
  1050. /// <param name="audioFileJson">오디오 파일 정보(전자동의서 서버)</param>
  1051. /// <param name="audioFileSize">오디오 파일 사이즈</param>
  1052. [WebMethod(Description = "동의서 서명 완료")]
  1053. public SingleReturnData SaveCompleteAll(string userId, string userDeptCd, string pid, string formId, string formCd, string patientDeptCd, string formXml, string dataXml,
  1054. int consentMstRid, int reWriteConsentMstRid, string deviceType, string deviceMacAddr, string ordType, string instCd, string inDd, string dSchDd,
  1055. string ward, string roomCd, string ocrTag, int cretNo, string mainDrId, string formPageCnt, string actionKind, string opRsrvNo, string consentState,
  1056. int orderNo, string orderName, string orderCd, string imageFileJson, string fileSize, string certResult, string certTarget,
  1057. string audioFileJson, string audioFileSize) {
  1058. SingleReturnData result = new SingleReturnData();
  1059. consentMstRid = SaveDataAll(userId, userDeptCd, pid, formId, formCd, patientDeptCd, formXml, dataXml,
  1060. consentMstRid, reWriteConsentMstRid, deviceType, deviceMacAddr, ordType, instCd, inDd, dSchDd,
  1061. ward, roomCd, ocrTag, cretNo, mainDrId, formPageCnt, actionKind, opRsrvNo, consentState,
  1062. orderNo, orderName, orderCd, imageFileJson, fileSize, certResult, certTarget, audioFileJson, audioFileSize, out int rslt);
  1063. result.responseData = Convert.ToString(rslt);
  1064. return result;
  1065. }
  1066. public int SaveDataAll(string userId, string userDeptCd, string pid, string formId, string formCd, string patientDeptCd, string formXml, string dataXml,
  1067. int consentMstRid, int reWriteConsentMstRid, string deviceType, string deviceMacAddr, string ordType, string instCd, string inDd, string dSchDd,
  1068. string ward, string roomCd, string ocrTag, int cretNo, string mainDrId, string formPageCnt, string actionKind, string opRsrvNo, string consentState,
  1069. int orderNo, string orderName, string orderCd, string imageFileJson, string fileSize, string certResult, string certTarget, string audioFileJson, string audioFileSize, out int result) {
  1070. bool isNewConsentMasterCase = false;
  1071. if (consentMstRid < 1) {
  1072. isNewConsentMasterCase = true;
  1073. }
  1074. if (this.IbatisSession.IsTransactionStart == false) {
  1075. this.IbatisSession.BeginTransaction();
  1076. }
  1077. try {
  1078. using (SaveConsentDac dac = new SaveConsentDac()) {
  1079. int updateResult = 0;
  1080. int deleteResult = 0;
  1081. Hashtable imrParam = new Hashtable();
  1082. imrParam.Add("ocrTag", "'" + ocrTag + "%'");
  1083. int imrCount = (int) dac.ImrCount(this.IbatisMapper, imrParam);
  1084. ImrData imrData = new ImrData();
  1085. if (imrCount > 0) {
  1086. imrData = (ImrData) dac.ImrData(this.IbatisMapper, imrParam);
  1087. }
  1088. Hashtable paramHashTable = GetParamHashTable(userId, userDeptCd, pid, formId, formCd, patientDeptCd, formXml, dataXml,
  1089. consentMstRid, reWriteConsentMstRid, deviceType, deviceMacAddr, ordType, instCd, inDd,
  1090. ward, roomCd, ocrTag, cretNo, mainDrId, formPageCnt, actionKind, opRsrvNo, consentState,
  1091. orderNo, orderName, orderCd, certResult, certTarget);
  1092. paramHashTable.Add("macAddress", deviceMacAddr);
  1093. consentMstRid = (int) paramHashTable["consentMstRid"];
  1094. result = consentMstRid;
  1095. if (isNewConsentMasterCase == true) {
  1096. dac.InsertConsentMst(this.IbatisMapper, paramHashTable);
  1097. dac.InsertConsentData(this.IbatisMapper, paramHashTable);
  1098. imageUpload(dac, paramHashTable, userId, pid, ordType, inDd, dSchDd, cretNo, ocrTag, consentMstRid, consentState, formCd, formId, dataXml, imageFileJson, instCd, patientDeptCd, fileSize);
  1099. } else {
  1100. if (consentState == "CERTIFY_CMP" && reWriteConsentMstRid > 0) {
  1101. int newConsentMstRid = this.GetSequence("CONSENT_MST");
  1102. paramHashTable["rewriteConsentMstRid"] = newConsentMstRid;
  1103. dac.ReWriteUpdateConsentMst(this.IbatisMapper, paramHashTable);
  1104. consentMstRid = newConsentMstRid;
  1105. paramHashTable["consentMstRid"] = consentMstRid;
  1106. paramHashTable["rewriteYn"] = "N";
  1107. paramHashTable["useYn"] = "Y";
  1108. paramHashTable["rewriteConsentMstRid"] = 0;
  1109. dac.InsertConsentMst(this.IbatisMapper, paramHashTable);
  1110. dac.InsertConsentData(this.IbatisMapper, paramHashTable);
  1111. imageUpload(dac, paramHashTable, userId, pid, ordType, inDd, dSchDd, cretNo, ocrTag, consentMstRid, consentState, formCd, formId, dataXml, imageFileJson, instCd, patientDeptCd, fileSize);
  1112. } else {
  1113. dac.UpdateConsentMst(this.IbatisMapper, paramHashTable);
  1114. dac.UpdateConsentData(this.IbatisMapper, paramHashTable);
  1115. imageUpload(dac, paramHashTable, userId, pid, ordType, inDd, dSchDd, cretNo, ocrTag, consentMstRid, consentState, formCd, formId, dataXml, imageFileJson, instCd, patientDeptCd, fileSize);
  1116. }
  1117. }
  1118. if (!string.IsNullOrEmpty(audioFileJson)) {
  1119. audioUpLoad(dac, paramHashTable, userId, consentMstRid, formId, audioFileJson, audioFileSize, ocrTag, pid);
  1120. }
  1121. if (imrCount > 0) {
  1122. String[] strAr = imrData.fileName.Split(new char[] { '_' });
  1123. imrData.fileName = strAr[0] + "_" + strAr[1];
  1124. imrParam.Add("fileName", "'" + imrData.fileName + "%'");
  1125. imrParam.Add("inputDate", imrData.inputDate);
  1126. imrParam.Add("userId", imrData.userId);
  1127. updateResult = dac.ImrScanFileUpdate(this.IbatisMapper, imrParam);
  1128. if (updateResult > 0) {
  1129. deleteResult = dac.ImrScanFileDelete(this.IbatisMapper, imrParam);
  1130. }
  1131. if (imrCount != deleteResult) {
  1132. throw new Exception();
  1133. }
  1134. }
  1135. Hashtable ocrParam = new Hashtable {
  1136. { "instcd", instCd },
  1137. { "ocrtag", ocrTag },
  1138. { "pid", pid },
  1139. { "ordtype", ordType },
  1140. { "orddd", inDd },
  1141. { "cretno", cretNo },
  1142. { "orddrid", mainDrId },
  1143. { "orddeptcd", patientDeptCd },
  1144. { "formcd", formCd },
  1145. { "fstprntdeptcd", userDeptCd },
  1146. { "fstprntid", userId },
  1147. { "updtdeptcd", userDeptCd },
  1148. { "updtuserid", userId },
  1149. { "updtdt", DateTime.Now.ToString("yyyyMMddHHmmss")},
  1150. { "pagecnt", formPageCnt },
  1151. //{ "updtresncnts", reasonForUseN },
  1152. { "actkind", actionKind },
  1153. { "clienttype", "M" }
  1154. };
  1155. dac.InsertPrintData(this.IbatisMapper, ocrParam, isNewConsentMasterCase);
  1156. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("formCd -- > " + formCd);
  1157. if (formCd == "1200005463" || formCd == "1800014564") {
  1158. SavePatientConsentInfo(formCd, pid, ocrTag, userId, dataXml);
  1159. }
  1160. if (this.IbatisSession != null) this.IbatisSession.CommitTransaction();
  1161. }
  1162. } catch (Exception ex) {
  1163. if (this.IbatisSession != null) this.IbatisSession.RollBackTransaction();
  1164. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm SaveDataAll ERROR : [{0}]", ex.ToString()));
  1165. result = -1;
  1166. throw ex;
  1167. }
  1168. return result;
  1169. }
  1170. private void imageUpload(SaveConsentDac dac, Hashtable paramHashTable, string userId, string pid, string ordType, string inDd, string dSchDd, int cretNo, string ocrTag,
  1171. int consentMstRid, string consentState, string formCd, string formId, string dataXml, string imageFileJson, string instCd, string deptCd, string fileSize) {
  1172. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("imageUpload");
  1173. // 서명 저장일 경우 emrindxm 테이블에 저장
  1174. if (!string.IsNullOrEmpty(consentState) && (consentState.Equals("ELECTR_CMP") || consentState.Equals("CERTIFY_CMP"))) {
  1175. // 진료과 코드
  1176. string clnDeptCode = paramHashTable["clnDeptCd"] == null ? string.Empty : paramHashTable["clnDeptCd"].ToString();
  1177. Dictionary<String, String> remoteData = remoteInfo();
  1178. string[] fileSizeAr = fileSize.Split(new char[] { ',' });
  1179. try {
  1180. int consentImageRid = this.GetSequence("CONSENT_IMAGE");
  1181. int firstImageRid = consentImageRid;
  1182. string sPath = string.Empty;
  1183. string sFileName = string.Empty;
  1184. //string newFileFullName = string.Empty;
  1185. if (!string.IsNullOrEmpty(imageFileJson)) {
  1186. Dictionary<string, object> jsonRoot = null;
  1187. jsonRoot = fastJSON.JSON.Parse(imageFileJson) as Dictionary<string, object>;
  1188. if (jsonRoot != null && jsonRoot.Count > 0) {
  1189. Hashtable imageHashTable = new Hashtable();
  1190. int nowCnt = 1;
  1191. int pageNum = 1;
  1192. int fileSizeCnt = 0;
  1193. var date = DateTime.Now.ToString("yyyyMM");
  1194. var uniqDatetime = DateTime.Now.ToString("yyyyMMddhhmmss");
  1195. foreach (KeyValuePair<string, object> jr in jsonRoot) {
  1196. imageHashTable = new Hashtable();
  1197. imageHashTable.Add("consentMstRid", consentMstRid);
  1198. if (nowCnt > 1) {
  1199. consentImageRid = this.GetSequence("CONSENT_IMAGE");
  1200. }
  1201. imageHashTable.Add("consentImageRid", consentImageRid);
  1202. imageHashTable.Add("userId", userId);
  1203. imageHashTable.Add("formRid", formId);
  1204. if (jr.Value != null && !string.IsNullOrEmpty(jr.Value.ToString())) {
  1205. sPath = "";
  1206. sFileName = "";
  1207. string[] filePath = jr.Value.ToString().Split('/');
  1208. for (int i = 0; i < filePath.Length; i++) {
  1209. if (i == 0) {
  1210. sPath = filePath[i];
  1211. } else if ((i + 1) == filePath.Length) {
  1212. sFileName = filePath[i];
  1213. } else {
  1214. sPath += "/" + filePath[i];
  1215. }
  1216. }
  1217. }
  1218. string uploadFileName = uniqDatetime + "_" + ocrTag + "_" + pageNum;
  1219. //int idx = uploadFileName.LastIndexOf(".");
  1220. string sUploadPath = uploadFileName.Substring(4, 4);
  1221. string sUploadFileName = uploadFileName.Substring(uploadFileName.LastIndexOf("\\") + 1);
  1222. authProcess(pid, cretNo, inDd, deptCd, ordType, ocrTag, consentMstRid, userId, pageNum, formCd, sUploadFileName, remoteData["IMAGE_SEQ"], fileSizeAr[fileSizeCnt].Trim());
  1223. fileSizeCnt++;
  1224. pageNum++;
  1225. // 운영 배포 테스트를 위한 temp 경로 삭제
  1226. // 실제 운영 테스트 시 100번 환자로만 진행 필요
  1227. var remotePath = remoteData["IMAGEPATH"] + "\\" + remoteData["PATH_IMGDATA"] + "\\" + date + "\\" + pid;
  1228. //var remotePath = remoteData["IMAGEPATH"] + "\\temp_" + remoteData["PATH_IMGDATA"] + "\\" + date + "\\" + pid;
  1229. //var destDirectory = remotePath.Substring(2);
  1230. ClipSoft.Utility.ImpersonationUtility util = new ClipSoft.Utility.ImpersonationUtility();
  1231. //var imResult = util.ImpersonationStart(remotePath, remoteData["NETDRV_USERID_ADMIN"], remoteData["NETDRV_PASSWORD_ADMIN"]);
  1232. var imResult = util.ImpersonationStart(remotePath, remoteData["NETDRV_USERID_ADMIN"], remoteData["NETDRV_PASSWORD_ADMIN"]);
  1233. DirectoryInfo destDi = new DirectoryInfo(remotePath);
  1234. string destDirStr = destDi.Name;
  1235. var destFullname = String.Format(@"{0}\{1}", remotePath, sUploadFileName);
  1236. var localFile = Server.MapPath(string.Format(@"./UPLOAD/{0}/{1}", sPath, sFileName));
  1237. if (!destDi.Exists) {
  1238. destDi.Create();
  1239. }
  1240. try {
  1241. File.Copy(localFile, destFullname, true);
  1242. } catch (Exception ex) {
  1243. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm imageUpload fileCopy ERROR : [{0}]", ex.ToString()));
  1244. throw ex;
  1245. }
  1246. util.ImpersonationEnd();
  1247. imageHashTable.Add("imagePath", remotePath);
  1248. imageHashTable.Add("imageFilename", sUploadFileName);
  1249. imageHashTable.Add("completeYn", paramHashTable["completeYn"]);
  1250. dac.InsertConsentImage(this.IbatisMapper, imageHashTable);
  1251. }
  1252. nowCnt++;
  1253. }
  1254. }
  1255. paramHashTable.Add("consentImageRid", firstImageRid);
  1256. // TODO 원무 인증 저장 pass
  1257. // 원무 저장시 해당 정보 저장 or skip 확인 해 볼 것
  1258. // 사인정보 저장
  1259. dac.InsertConsentImageSign(this.IbatisMapper, paramHashTable);
  1260. } catch (Exception ex) {
  1261. //using (HospitalSvc hospitalWebService = new HospitalSvc()) {
  1262. // hospitalWebService.delEformData(patientCode, visitType,
  1263. // clnDate.Replace("-", ""), Dschdd, string.Format("{0}", cretno),
  1264. // formCd, ocrcode, userId, createUserName, string.Format("{0}", consentMstRid), hosType,
  1265. // clnDeptCode, dutinstcd);
  1266. //}
  1267. //if (this.IbatisSession != null) this.IbatisSession.RollBackTransaction();
  1268. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm imageUpload ERROR : [{0}]", ex.ToString()));
  1269. throw ex;
  1270. }
  1271. }
  1272. }
  1273. private void authProcess(string pid, int cretNo, string ordDd, string deptCd, string ordType, string ocrTag,
  1274. int consentMstRid, string userId, int pageNum, string formCd, string fileName, string imageSvrSeq, string fileSize) {
  1275. int seq = 0;
  1276. int seqNo = 0;
  1277. try {
  1278. using (ConsentDac consentDac = new ConsentDac()) {
  1279. Hashtable param = new Hashtable();
  1280. param.Add("pid", pid);
  1281. param.Add("cretNo", cretNo);
  1282. param.Add("ordDd", ordDd);
  1283. param.Add("deptCd", deptCd);
  1284. param.Add("ordType", ordType);
  1285. param.Add("userId", userId);
  1286. //param.Add("pageNo", pageNum);
  1287. param.Add("formCd", formCd);
  1288. param.Add("imgServer", imageSvrSeq);
  1289. param.Add("fileSize", Convert.ToInt32(fileSize));
  1290. var date = DateTime.Now.ToString("yyyyMM");
  1291. string mstRid = Convert.ToString(consentMstRid);
  1292. param.Add("ocrTag", ocrTag + "^" + mstRid);
  1293. param.Add("fileName", date + "\\" + pid + "\\" + fileName);
  1294. // 외래면 0 아니면 1
  1295. if (ordType.Equals("O")) {
  1296. param.Add("inOut", 0);
  1297. } else {
  1298. param.Add("inOut", 1);
  1299. }
  1300. if (cretNo == 0 || ordDd.Equals("") || deptCd.Equals("") || ordType.Equals("")) {
  1301. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Warn("cretNo -- > " + cretNo);
  1302. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Warn("ordDd -- > " + ordDd);
  1303. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Warn("deptCd -- > " + deptCd);
  1304. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Warn("ordType -- > " + ordType);
  1305. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Warn("ocrTag -- > " + ocrTag);
  1306. throw new Exception();
  1307. }
  1308. seq = Convert.ToInt32(consentDac.getTreatTSeq(this.IbatisMapper, param));
  1309. param.Add("seq", seq);
  1310. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Warn("seq -- > " + seq);
  1311. if (seq == 0) {
  1312. seq = Convert.ToInt32(consentDac.getTreatTNewSeq(this.IbatisMapper, param));
  1313. seq = seq + 1;
  1314. param.Remove("seq");
  1315. param.Add("seq", seq);
  1316. consentDac.insertScanGroup(this.IbatisMapper, param);
  1317. }
  1318. seqNo = consentDac.getScanFileMaxSeq(this.IbatisMapper, param);
  1319. seqNo = seqNo + 1;
  1320. param.Add("seqNo", seqNo);
  1321. consentDac.insertScanFile(this.IbatisMapper, param);
  1322. }
  1323. } catch (Exception ex) {
  1324. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm authProcess ERROR : [{0}]", ex.ToString()));
  1325. throw ex;
  1326. }
  1327. }
  1328. private Dictionary<String, String> remoteInfo() {
  1329. Dictionary<String, String> data = new Dictionary<string, string>();
  1330. try {
  1331. using (CommonCodeDac codeDac = new CommonCodeDac()) {
  1332. IList<ImageServerPropsVO> imageServerProps;
  1333. Hashtable opts = new Hashtable();
  1334. imageServerProps = codeDac.GetImageServerProps(this.IbatisMapper, opts);
  1335. foreach (var prop in imageServerProps) {
  1336. if (prop.imageSeq != "") {
  1337. data.Add("IMAGE_SEQ", prop.imageSeq);
  1338. }
  1339. data.Add(prop.keyName, prop.keyValue);
  1340. }
  1341. }
  1342. List<string> users = new List<string>();
  1343. var path = string.Format("WinNT://{0},computer", Environment.MachineName);
  1344. using (var computerEntry = new DirectoryEntry(path)) {
  1345. foreach(DirectoryEntry childEntry in computerEntry.Children) {
  1346. if (childEntry.SchemaClassName == "User") {
  1347. users.Add(childEntry.Name);
  1348. }
  1349. }
  1350. }
  1351. //if (users.Contains("imr") == true) {
  1352. // CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("&&&&&&");
  1353. // var entry = new DirectoryEntry(path);
  1354. // DirectoryEntries childEntry2 = entry.Children;
  1355. // DirectoryEntry user = childEntry2.Find("imr");
  1356. // CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("user.Name -- > " + user.Name);
  1357. // childEntry2.Remove(user);
  1358. // user.CommitChanges();
  1359. //}
  1360. if (users.Contains("imr") == false) {
  1361. DirectoryEntry localMachine = new DirectoryEntry("WinNT://" + Environment.MachineName);
  1362. DirectoryEntry newUser = localMachine.Children.Add(data["NETDRV_USERID_ADMIN"], "user");
  1363. newUser.Invoke("SetPassword", new object[] { data["NETDRV_PASSWORD_ADMIN"] });
  1364. newUser.Invoke("Put", new object[] { "Description", "Test user" });
  1365. newUser.CommitChanges();
  1366. newUser.Close();
  1367. }
  1368. } catch (Exception ex) {
  1369. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm remoteInfo ERROR : [{0}]", ex.ToString()));
  1370. throw ex;
  1371. }
  1372. return data;
  1373. }
  1374. [WebMethod(Description = "신규서식이 아닌 서식을 불러온다")]
  1375. public string GetConsentFormXml(int consentMstRid) {
  1376. byte[] result = { 0 };
  1377. String formXml = "";
  1378. //SingleReturnData result = new SingleReturnData();
  1379. try {
  1380. using (ConsentDac consentDac = new ConsentDac()) {
  1381. Hashtable param = new Hashtable();
  1382. param.Add("consentMstRid", consentMstRid);
  1383. formXml = consentDac.getConsentFormXml(this.IbatisMapper, param);
  1384. UTF8Encoding encoder = new UTF8Encoding();
  1385. Decoder utf8Decode = encoder.GetDecoder();
  1386. byte[] toEcodeByte = Convert.FromBase64String(formXml);
  1387. int charCount = utf8Decode.GetCharCount(toEcodeByte, 0, toEcodeByte.Length);
  1388. char[] decodedChar = new char[charCount];
  1389. utf8Decode.GetChars(toEcodeByte, 0, toEcodeByte.Length, decodedChar, 0);
  1390. formXml = Unzip(toEcodeByte);
  1391. }
  1392. } catch (Exception ex) {
  1393. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm GetConsentFormXml ERROR : [{0}]", ex.ToString()));
  1394. }
  1395. return formXml;
  1396. }
  1397. public byte[] Zip(string str) {
  1398. var bytes = Encoding.UTF8.GetBytes(str);
  1399. using (var msi = new MemoryStream(bytes))
  1400. using (var mso = new MemoryStream()) {
  1401. using (var gs = new GZipStream(mso, CompressionMode.Compress)) {
  1402. CopyTo(msi, gs);
  1403. }
  1404. return mso.ToArray();
  1405. }
  1406. }
  1407. public string Unzip(byte[] bytes) {
  1408. using (var msi = new MemoryStream(bytes))
  1409. using (var mso = new MemoryStream()) {
  1410. using (var gs = new GZipStream(msi, CompressionMode.Decompress)) {
  1411. CopyTo(gs, mso);
  1412. }
  1413. return Encoding.UTF8.GetString(mso.ToArray());
  1414. }
  1415. }
  1416. public void CopyTo(Stream src, Stream dest) {
  1417. byte[] bytes = new byte[4096];
  1418. int cnt;
  1419. while ((cnt = src.Read(bytes, 0, bytes.Length)) != 0) {
  1420. dest.Write(bytes, 0, cnt);
  1421. }
  1422. }
  1423. /// <summary>
  1424. /// 전자 동의서를 완료저장 한다.
  1425. /// </summary>
  1426. /// <param name="userId">로그인 사용자ID</param>
  1427. /// <param name="patientCode">환자 등록번호</param>
  1428. /// <param name="clnDeptCode">진료과 코드</param>
  1429. /// <param name="formRid">(작성대상)서식 Rid</param>
  1430. /// <param name="formCd">서식코드</param>
  1431. /// <param name="consentMstRid">동의서 마스터 데이터 Rid</param>
  1432. /// <param name="rewriteConsentMstRid">재 작성 대상 동의서 마스터 데이터 Rid</param>
  1433. /// <param name="formXml">동의서 EPT Xml</param>
  1434. /// <param name="dataXml">동의서 Data(필드들) Xml</param>
  1435. /// <param name="deviceType">장비 유형 (WIN, AND, IOS, PRT 중1)</param>
  1436. /// <param name="deviceIdentNo">장비 고유 식별자</param>
  1437. /// <param name="vistType">내원구분</param>
  1438. /// <param name="hosType">병원 구분</param>
  1439. /// <param name="clnDate">병원 구분이 "I" 일 경우 입원일자/병원 구분이 "O"일 경우 진료일자</param>
  1440. /// <param name="ward">병동 코드</param>
  1441. /// <param name="roomcd">병실 코드</param>
  1442. /// <param name="orderNo">처방번호</param>
  1443. /// <param name="orderCd">처방코드</param>
  1444. /// <param name="orderName">처방명</param>
  1445. /// <param name="createUserName">작성자명</param>
  1446. /// <param name="modifyUserName">수정자명</param>
  1447. /// <param name="imageFileJson">이미지 파일 정보(전자동의서 서버)</param>
  1448. /// <param name="certTarget">이미지 파일 공인인증 대상정보</param>
  1449. /// <param name="certResult">이미지 파일 공인인증 처리정보</param>
  1450. /// <param name="dschdd">퇴원일자</param>
  1451. /// <param name="consentState">상태</param>
  1452. /// <param name="mainDrId">주치의 아이디</param>
  1453. /// <param name="userDeptCd">사용자 부서 코드</param>
  1454. /// <param name="pageCnt">동의서 매수</param>
  1455. /// <param name="actKind">동작코드(T: 임시 저장, C: 인증 저장, P: 출력, CP: 삭제)</param>
  1456. /// <param name="clientType">Client구분 (P: PC, M: 모바일)</param>
  1457. //[WebMethod(Description = "동의서 서명 완료")]
  1458. //public int SaveCompleteAll(string userId, string patientCode, string clnDeptCode, int formRid, string formCd,
  1459. // int consentMstRid, int rewriteConsentMstRid, string formXml, string dataXml,
  1460. // string deviceType, string deviceIdentNo, string vistType, string hosType, string clnDate,
  1461. // string ward, string roomcd, int orderNo, string orderName, string orderCd, string ocrCode, int cretno,
  1462. // string createUserName, string modifyUserName, string imageFileJson, string certTarget, string certResult,
  1463. // string dschdd, string consentState, string mainDrId,
  1464. // string userDeptCd, string pageCnt, string actKind, string clientType, string opRsrvNo) {
  1465. // string paramLog = "";
  1466. // paramLog += "clnDept[" + userId + "]patientCode[" + patientCode + "]clnDeptCode[" + clnDeptCode + "]formRid[" + formRid + "]";
  1467. // paramLog += "formCd[" + formCd + "]consentMstRid[" + consentMstRid + "]rewriteConsentMstRid[" + rewriteConsentMstRid + "]";
  1468. // paramLog += "deviceType[" + deviceType + "]vistType[" + vistType + "]hosType[" + hosType + "]";
  1469. // paramLog += "clnDate[" + clnDate + "]ward[" + ward + "]roomcd[" + roomcd + "]orderNo[" + orderNo + "]";
  1470. // paramLog += "orderName[" + orderName + "]orderCd[" + orderCd + "]ocrCode[" + ocrCode + "]cretno[" + cretno + "]";
  1471. // paramLog += "createUserName[" + createUserName + "]modifyUserName[" + modifyUserName + "]imageFileJson[" + imageFileJson + "]certTarget[" + certTarget + "]";
  1472. // paramLog += "dschdd[" + dschdd + "]consentState[" + consentState + "]mainDrId[" + mainDrId + "]";
  1473. // paramLog += "dataXml[" + dataXml + "]formXml[" + formXml + "]certResult[" + certResult + "]";
  1474. // //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("CLIP.eForm SaveCompleteAll param : " + paramLog);
  1475. // //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("json : " + imageFileJson);
  1476. // int reissueConsentMstRid = 0;
  1477. // string paperYn = "N";
  1478. // string reasonForUseN = string.Empty;
  1479. // rewriteConsentMstRid = 0;
  1480. // consentMstRid = SaveDataAll(userId, patientCode, clnDeptCode, formRid, formCd,
  1481. // consentMstRid, rewriteConsentMstRid, reissueConsentMstRid, consentState, paperYn, formXml, dataXml,
  1482. // deviceType, deviceIdentNo, vistType, hosType, clnDate,
  1483. // ward, roomcd, reasonForUseN, orderNo, orderName, orderCd, ocrCode, cretno,
  1484. // createUserName, modifyUserName, imageFileJson, certTarget, certResult, dschdd, mainDrId,
  1485. // userDeptCd, pageCnt, actKind, clientType, opRsrvNo);
  1486. // return consentMstRid;
  1487. //}
  1488. /// <summary>
  1489. /// 동의서 삭제/폐기 데이터를 저장 한다.
  1490. /// </summary>
  1491. /// <param name="userId">로그인 사용자ID</param>
  1492. /// <param name="consentMstRidInt">The consent MST rid int.</param>
  1493. /// <param name="patientCode">환자 등록번호</param>
  1494. /// <param name="clnDeptCode">진료과 코드</param>
  1495. /// <param name="ward">병동 코드</param>
  1496. /// <param name="roomcd">The roomcd.</param>
  1497. /// <param name="formRid">(작성대상)서식 Rid</param>
  1498. /// <param name="formCd">서식 코드</param>
  1499. /// <param name="rewriteConsentMstRid">재 작성 대상 동의서 마스터 데이터 Rid</param>
  1500. /// <param name="reissueConsentMstRid">삭제/폐기 대상 동의서 마스터 데이터 Rid</param>
  1501. /// <param name="consentState">동의서 상태</param>
  1502. /// <param name="deviceIdentNo">장비 고유 식별자</param>
  1503. /// <param name="vistType">진료 형태</param>
  1504. /// <param name="hosType">기관 코드</param>
  1505. /// <param name="clnDate">진료일</param>
  1506. /// <param name="reasonForUseN">삭제/폐기 사유</param>
  1507. /// <param name="ocrCode">OCR Tag</param>
  1508. /// <param name="cretno">생성번호</param>
  1509. /// <param name="userDeptCd">사용자 부서 코드</param>
  1510. /// <param name="pageCnt">동의서 매수</param>
  1511. /// <param name="actKind">동작코드(T: 임시 저장, C: 인증 저장, P: 출력, CP: 삭제)</param>
  1512. /// <param name="clientType">Client구분 (P: PC, M: 모바일)</param>
  1513. /// <returns></returns>
  1514. //[WebMethod(Description = "동의서 삭제/폐기 데이터를 저장")]
  1515. //public int SaveDelete(string userId, int consentMstRidInt, string patientCode, string clnDeptCode,
  1516. // string ward, string roomcd, int formRid, string formCd, int rewriteConsentMstRid, int reissueConsentMstRid,
  1517. // string consentState, string deviceIdentNo, string vistType, string hosType, string clnDate, string reasonForUseN,
  1518. // string ocrCode, int cretno,
  1519. // string userDeptCd, string pageCnt, string actKind, string clientType) {
  1520. // string paperYn = "N";
  1521. // consentMstRidInt = SaveData(userId, patientCode, clnDeptCode, formRid, formCd,
  1522. // consentMstRidInt, rewriteConsentMstRid, reissueConsentMstRid, consentState, paperYn, null, null,
  1523. // null, deviceIdentNo, vistType, hosType, clnDate,
  1524. // ward, roomcd, reasonForUseN, 0, null, null, ocrCode, cretno,
  1525. // null, null, null, null, null, null,
  1526. // userDeptCd, pageCnt, actKind, clientType, "");
  1527. // return consentMstRidInt;
  1528. //}
  1529. /// <summary>
  1530. /// 프린트 출력 후 데이터를 저장 한다.
  1531. /// </summary>
  1532. /// <param name="userId">로그인 사용자ID</param>
  1533. /// <param name="patientCode">환자 등록번호</param>
  1534. /// <param name="clnDeptCode">진료과 코드</param>
  1535. /// <param name="formRid">(작성대상)서식 Rid</param>
  1536. /// <param name="formCd">서식코드</param>
  1537. /// <param name="consentMstRid">동의서 마스터 데이터 Rid</param>
  1538. /// <param name="reissueConsentMstRid">The reissue consent MST rid.</param>
  1539. /// <param name="formXml">동의서 EPT Xml</param>
  1540. /// <param name="dataXml">동의서 Data(필드들) Xml</param>
  1541. /// <param name="deviceType">장비 유형 (WIN, AND, IOS, PRT 중1)</param>
  1542. /// <param name="deviceIdentNo">장비 고유 식별자</param>
  1543. /// <param name="vistType">내원구분</param>
  1544. /// <param name="hosType">병원 구분</param>
  1545. /// <param name="clnDate">병원 구분이 "I" 일 경우 입원일자/병원 구분이 "O"일 경우 진료일자</param>
  1546. /// <param name="ward">병동 코드</param>
  1547. /// <param name="roomcd">병실 코드</param>
  1548. /// <param name="orderNo">처방번호</param>
  1549. /// <param name="orderName">처방명</param>
  1550. /// <param name="orderCd">처방코드</param>
  1551. /// <param name="ocrCode">OCR코드</param>
  1552. /// <param name="cretno">생성번호</param>
  1553. /// <param name="createUserName">작성자명</param>
  1554. /// <param name="modifyUserName">수정자명</param>
  1555. /// <param name="mainDrId">주치의 아이디</param>
  1556. /// <param name="userDeptCd">사용자 부서 코드</param>
  1557. /// <param name="pageCnt">출력 매수</param>
  1558. /// <param name="actKind">동작 방법</param>
  1559. /// <param name="clientType">Client 타입</param>
  1560. /// <param name="opRsrvNo">수술예약번호</param>
  1561. /// <returns></returns>
  1562. [WebMethod(Description = "동의서 프린트 출력 후 데이터를 저장")]
  1563. public int SavePrintOut(string userId, string patientCode, string clnDeptCode, int formRid, string formCd,
  1564. int consentMstRid, int reissueConsentMstRid, string formXml, string dataXml,
  1565. string deviceType, string deviceIdentNo, string vistType, string hosType, string clnDate,
  1566. string ward, string roomcd, int orderNo, string orderName, string orderCd, string ocrCode, int cretno,
  1567. string createUserName, string modifyUserName, string mainDrId,
  1568. string userDeptCd, string pageCnt, string actKind, string clientType, string opRsrvNo) {
  1569. string consentState = "PAPER_OUT";
  1570. string paperYn = "Y";
  1571. consentMstRid = SavePrintData(userId, patientCode, clnDeptCode, formRid, formCd,
  1572. consentMstRid, 0, reissueConsentMstRid, consentState, paperYn, formXml, dataXml,
  1573. deviceType, deviceIdentNo, vistType, hosType, clnDate,
  1574. ward, roomcd, null, orderNo, orderName, orderCd, ocrCode, cretno,
  1575. createUserName, modifyUserName, null, null, null, mainDrId,
  1576. userDeptCd, pageCnt, actKind, clientType, opRsrvNo);
  1577. return consentMstRid;
  1578. }
  1579. /// <summary>
  1580. /// 동의서의 기왕력 데이터 저장
  1581. /// </summary>
  1582. /// <param name="patientCode">환자 등록번호</param>
  1583. /// <param name="clnDate">진료일</param>
  1584. /// <param name="bp">고/저혈압</param>
  1585. /// <param name="dm">당뇨병</param>
  1586. /// <param name="heart">심장질환</param>
  1587. /// <param name="kidney">신장질환</param>
  1588. /// <param name="respiration">호흡기질환</param>
  1589. /// <param name="hx">과거병력</param>
  1590. /// <param name="allergy">알레르기</param>
  1591. /// <param name="drug">복용약물</param>
  1592. /// <param name="smoking">흡연상태</param>
  1593. /// <param name="idio">특이체질</param>
  1594. /// <param name="nacrotics">마약사고</param>
  1595. /// <param name="airway">기도이상 유무</param>
  1596. /// <param name="hemorrhage">출혈소인</param>
  1597. /// <param name="status_etc">기타</param>
  1598. /// <param name="userId">로그인 사용자ID</param>
  1599. /// <returns></returns>
  1600. [WebMethod(Description = "동의서의 기왕력 데이터 저장")]
  1601. public string SaveMedicalHistory(string patientCode, string clnDate,
  1602. string bp, string dm, string heart, string kidney, string respiration,
  1603. string hx, string allergy, string drug, string smoking,
  1604. string idio, string nacrotics, string airway, string hemorrhage, string status_etc,
  1605. string userId) {
  1606. try {
  1607. using (SaveConsentDac dac = new SaveConsentDac()) {
  1608. Hashtable paramHashTable = new Hashtable();
  1609. paramHashTable.Add("patientCode", patientCode);
  1610. paramHashTable.Add("clnDate", clnDate);
  1611. paramHashTable.Add("bp", bp);
  1612. paramHashTable.Add("dm", dm);
  1613. paramHashTable.Add("heart", heart);
  1614. paramHashTable.Add("kidney", kidney);
  1615. paramHashTable.Add("respiration", respiration);
  1616. paramHashTable.Add("hx", hx);
  1617. paramHashTable.Add("allergy", allergy);
  1618. paramHashTable.Add("drug", drug);
  1619. paramHashTable.Add("smoking", smoking);
  1620. paramHashTable.Add("idio", idio);
  1621. paramHashTable.Add("nacrotics", nacrotics);
  1622. paramHashTable.Add("airway", airway);
  1623. paramHashTable.Add("hemorrhage", hemorrhage);
  1624. paramHashTable.Add("status_etc", status_etc);
  1625. paramHashTable.Add("userId", userId);
  1626. dac.SetMediHistory(this.IbatisMapper, paramHashTable);
  1627. }
  1628. } catch (Exception ex) {
  1629. if (this.IbatisSession != null) this.IbatisSession.RollBackTransaction();
  1630. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm SaveMedicalHistory ERROR : [{0}]", ex.ToString()));
  1631. throw ex;
  1632. } finally {
  1633. }
  1634. return patientCode;
  1635. }
  1636. /// <summary>
  1637. /// 동의서 서명 완료일 경우 이미지 데이터 저장
  1638. /// </summary>
  1639. /// <param name="consentState">동의서 상태</param>
  1640. /// <param name="imageFileName">이미지파일명(경로포함)</param>
  1641. /// <param name="consentMstRid">동의서 마스터 데이터 Rid</param>
  1642. /// <param name="userId">등록자ID</param>
  1643. /// <param name="formRid">동의서 FORM ID</param>
  1644. /// <returns>저장된 consent image rid</returns>
  1645. [WebMethod(Description = "동의서 서명 완료일 경우 이미지 데이터 저장")]
  1646. public int SaveImageUploadInfo(string consentState, string imageFileName, int consentMstRid, string userId, int formRid) {
  1647. int consentImageRid = 0;
  1648. if (!string.IsNullOrEmpty(consentState) && consentState == "ELECTR_CMP") {
  1649. using (SaveConsentDac dac = new SaveConsentDac()) {
  1650. Hashtable imageHashTable = new Hashtable();
  1651. imageHashTable.Add("consentMstRid", consentMstRid);
  1652. consentImageRid = this.GetSequence("CONSENT_IMAGE");
  1653. imageHashTable.Add("consentImageRid", consentImageRid);
  1654. imageHashTable.Add("userId", userId);
  1655. imageHashTable.Add("formRid", formRid);
  1656. imageHashTable.Add("imagePath", imageFileName.Substring(0, imageFileName.LastIndexOf("\\")));
  1657. imageHashTable.Add("imageFilename", imageFileName.Substring(imageFileName.LastIndexOf("\\") + 1));
  1658. imageHashTable.Add("completeYn", "Y"); //paramHashTable["completeYn"]
  1659. dac.InsertConsentImage(this.IbatisMapper, imageHashTable);
  1660. }
  1661. }
  1662. return consentImageRid;
  1663. }
  1664. /// <summary>
  1665. /// 서명완료된 이미지의 hash 정보 저장
  1666. /// </summary>
  1667. /// <param name="consentState">동의서 상태</param>
  1668. /// <param name="consentMstRid">동의서 마스터 데이터 Rid</param>
  1669. /// <param name="consentImageRid">이미지 데이터 Rid</param>
  1670. /// <param name="userId">등록자ID</param>
  1671. /// <param name="certTarget">hash 정보</param>
  1672. /// <param name="sCertResult">공인인증서명 결과</param>
  1673. [WebMethod(Description = "서명완료된 이미지의 hash 정보 저장")]
  1674. public void SaveImageSignInfo(string consentState, int consentMstRid, int consentImageRid, string userId, string certTarget, string sCertResult) {
  1675. string paramLog = "";
  1676. paramLog += "consentState[" + consentState + "]consentMstRid[" + consentMstRid + "]consentImageRid[" + consentImageRid + "]userId[" + userId + "]";
  1677. paramLog += "certTarget[" + certTarget + "]sCertResult[" + sCertResult + "]";
  1678. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("CLIP.eForm SaveTempData param : " + paramLog);
  1679. if (!string.IsNullOrEmpty(consentState) && consentState == "ELECTR_CMP") {
  1680. using (SaveConsentDac dac = new SaveConsentDac()) {
  1681. Hashtable imageHashTable = new Hashtable();
  1682. imageHashTable.Add("consentMstRid", consentMstRid);
  1683. imageHashTable.Add("consentImageRid", consentImageRid);
  1684. imageHashTable.Add("certTarget", certTarget);
  1685. imageHashTable.Add("certResult", sCertResult);
  1686. imageHashTable.Add("userId", userId);
  1687. dac.InsertConsentImageSign(this.IbatisMapper, imageHashTable);
  1688. imageHashTable.Add("consentState", "CERTIFY_CMP");
  1689. dac.UpdateConsentMstStatus(this.IbatisMapper, imageHashTable);
  1690. }
  1691. }
  1692. }
  1693. /// <summary>
  1694. /// Saves the data.
  1695. /// </summary>
  1696. /// <param name="userId">The user identifier.</param>
  1697. /// <param name="patientCode">The patient code.</param>
  1698. /// <param name="clnDeptCode">The CLN dept code.</param>
  1699. /// <param name="formRid">The form rid.</param>
  1700. /// <param name="formCd">The form cd.</param>
  1701. /// <param name="consentMstRid">The consent MST rid.</param>
  1702. /// <param name="rewriteConsentMstRid">The rewrite consent MST rid.</param>
  1703. /// <param name="reissueConsentMstRid">The reissue consent MST rid.</param>
  1704. /// <param name="consentState">State of the consent.</param>
  1705. /// <param name="paperYn">The paper yn.</param>
  1706. /// <param name="formXml">The form XML.</param>
  1707. /// <param name="dataXml">The data XML.</param>
  1708. /// <param name="deviceType">Type of the device.</param>
  1709. /// <param name="deviceIdentNo">The device ident no.</param>
  1710. /// <param name="vistType">Type of the vist.</param>
  1711. /// <param name="hosType">Type of the hos.</param>
  1712. /// <param name="clnDate">The CLN date.</param>
  1713. /// <param name="ward">The ward.</param>
  1714. /// <param name="roomcd">The roomcd.</param>
  1715. /// <param name="reasonForUseN">The reason for use n.</param>
  1716. /// <param name="orderNo">The order no.</param>
  1717. /// <param name="orderName">Name of the order.</param>
  1718. /// <param name="orderCd">The order cd.</param>
  1719. /// <param name="ocrCode">The ocr code.</param>
  1720. /// <param name="cretno">The cretno.</param>
  1721. /// <param name="createUserName">Name of the create user.</param>
  1722. /// <param name="modifyUserName">Name of the modify user.</param>
  1723. /// <param name="imageFileName">Name of the image file.</param>
  1724. /// <param name="certTarget">The cert target.</param>
  1725. /// <param name="certResult">The cert result.</param>
  1726. /// <param name="mainDrId">The main dr identifier.</param>
  1727. /// <param name="userDeptCd">The user dept cd.</param>
  1728. /// <param name="pageCnt">The page count.</param>
  1729. /// <param name="actKind">Kind of the act.</param>
  1730. /// <param name="clientType">Type of the client.</param>
  1731. /// <param name="opRsrvNo">The op RSRV no.</param>
  1732. /// <returns></returns>
  1733. //private int SaveData(string userId, string patientCode, string clnDeptCode, int formRid, string formCd,
  1734. // int consentMstRid, int rewriteConsentMstRid, int reissueConsentMstRid, string consentState, string paperYn, string formXml, string dataXml,
  1735. // string deviceType, string deviceIdentNo, string vistType, string hosType, string clnDate,
  1736. // string ward, string roomcd, string reasonForUseN, int orderNo, string orderName, string orderCd, string ocrCode, int cretno,
  1737. // string createUserName, string modifyUserName, string imageFileName, string certTarget, string certResult,
  1738. // string mainDrId, string userDeptCd, string pageCnt, string actKind, string clientType, string opRsrvNo) {
  1739. // bool isNewConsentMasterCase = false;
  1740. // if (consentMstRid < 1) {
  1741. // isNewConsentMasterCase = true;
  1742. // }
  1743. // if (this.IbatisSession.IsTransactionStart == false) {
  1744. // this.IbatisSession.BeginTransaction();
  1745. // }
  1746. // try {
  1747. // using (SaveConsentDac dac = new SaveConsentDac()) {
  1748. // Hashtable paramHashTable = GetParamHashTable(userId, patientCode, clnDeptCode, formRid, formCd, consentMstRid, rewriteConsentMstRid,
  1749. // reissueConsentMstRid, consentState, paperYn, formXml, dataXml, deviceType, deviceIdentNo,
  1750. // vistType, hosType, clnDate, ward, roomcd, reasonForUseN,
  1751. // orderNo, orderName, orderCd, ocrCode, cretno, createUserName, modifyUserName,
  1752. // certTarget, certResult, mainDrId, opRsrvNo);
  1753. // consentMstRid = (int) paramHashTable["consentMstRid"];
  1754. // //새로 작성하는 경우
  1755. // if (isNewConsentMasterCase) {
  1756. // dac.InsertConsentMst(this.IbatisMapper, paramHashTable);
  1757. // dac.InsertConsentData(this.IbatisMapper, paramHashTable);
  1758. // } else { //새로 작성 아닌 경우
  1759. // if (reissueConsentMstRid > 0) {
  1760. // if (string.IsNullOrEmpty(reasonForUseN)) {
  1761. // //종이->종이 재발행
  1762. // int newConsentMstRid = this.GetSequence("CONSENT_MST");
  1763. // paramHashTable["consentMstRid"] = newConsentMstRid;
  1764. // consentMstRid = newConsentMstRid;
  1765. // dac.InsertConsentMst(this.IbatisMapper, paramHashTable);
  1766. // dac.InsertConsentData(this.IbatisMapper, paramHashTable);
  1767. // } else { // 삭제
  1768. // dac.UpdateConsentMstForDelete(this.IbatisMapper, paramHashTable);
  1769. // }
  1770. // } else { //임시저장 또는 저장인 경우
  1771. // dac.UpdateConsentMst(this.IbatisMapper, paramHashTable);
  1772. // dac.InsertConsentData(this.IbatisMapper, paramHashTable);
  1773. // }
  1774. // }
  1775. // // OCR 테이블 연계
  1776. // Hashtable ocrParam = new Hashtable {
  1777. // { "instcd", hosType },
  1778. // { "ocrtag", ocrCode },
  1779. // { "pid", patientCode },
  1780. // { "ordtype", vistType },
  1781. // { "orddd", clnDate },
  1782. // { "cretno", cretno },
  1783. // { "orddrid", mainDrId },
  1784. // { "orddeptcd", clnDeptCode },
  1785. // { "formcd", formCd },
  1786. // { "fstprntdeptcd", userDeptCd },
  1787. // { "fstprntid", userId },
  1788. // { "updtdeptcd", userDeptCd },
  1789. // { "updtuserid", userId },
  1790. // { "updtdt", DateTime.Now.ToString("yyyyMMddHHmmss")},
  1791. // { "pagecnt", pageCnt },
  1792. // { "updtresncnts", reasonForUseN },
  1793. // { "actkind", actKind },
  1794. // { "clienttype", clientType }
  1795. // };
  1796. // dac.InsertPrintData(this.IbatisMapper, ocrParam);
  1797. // if (this.IbatisSession != null) this.IbatisSession.CommitTransaction();
  1798. // }
  1799. // } catch (Exception ex) {
  1800. // if (this.IbatisSession != null) this.IbatisSession.RollBackTransaction();
  1801. // CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm SaveData ERROR : [{0}]", ex.ToString()));
  1802. // throw ex;
  1803. // } finally {
  1804. // }
  1805. // return consentMstRid;
  1806. //}
  1807. //private int SaveDataAll(string userId, string patientCode, string clnDeptCode, int formRid, string formCd,
  1808. // int consentMstRid, int rewriteConsentMstRid, int reissueConsentMstRid, string consentState, string paperYn, string formXml, string dataXml,
  1809. // string deviceType, string deviceIdentNo, string vistType, string hosType, string clnDate,
  1810. // string ward, string roomcd, string reasonForUseN, int orderNo, string orderName, string orderCd, string ocrCode, int cretno,
  1811. // string createUserName, string modifyUserName, string imageFileJson, string certTarget,
  1812. // string certResult, string dschdd, string mainDrId,
  1813. // string userDeptCd, string pageCnt, string actKind, string clientType, string opRsrvNo) {
  1814. // bool isNewConsentMasterCase = false;
  1815. // if (consentMstRid < 1) {
  1816. // isNewConsentMasterCase = true;
  1817. // }
  1818. // try {
  1819. // using (SaveConsentDac dac = new SaveConsentDac()) {
  1820. // Hashtable paramHashTable = GetParamHashTable(userId, patientCode, clnDeptCode, formRid, formCd, consentMstRid, rewriteConsentMstRid,
  1821. // reissueConsentMstRid, consentState, paperYn, formXml, dataXml, deviceType, deviceIdentNo,
  1822. // vistType, hosType, clnDate, ward, roomcd, reasonForUseN,
  1823. // orderNo, orderName, orderCd, ocrCode, cretno, createUserName, modifyUserName,
  1824. // certTarget, certResult, mainDrId, opRsrvNo);
  1825. // consentMstRid = (int) paramHashTable["consentMstRid"];
  1826. // //새로 작성하는 경우
  1827. // if (isNewConsentMasterCase) {
  1828. // dac.InsertConsentMst(this.IbatisMapper, paramHashTable);
  1829. // dac.InsertConsentData(this.IbatisMapper, paramHashTable);
  1830. // imageUpload(dac, paramHashTable, userId
  1831. // , patientCode, vistType, clnDate, dschdd, cretno, ocrCode
  1832. // , consentMstRid, consentState, formCd, formRid, dataXml, imageFileJson, certTarget, certResult, hosType, createUserName, hosType);
  1833. // }
  1834. // //새로 작성 아닌 경우
  1835. // else {
  1836. // if (reissueConsentMstRid > 0) {
  1837. // if (string.IsNullOrEmpty(reasonForUseN)) {
  1838. // //종이->종이 재발행
  1839. // int newConsentMstRid = this.GetSequence("CONSENT_MST");
  1840. // paramHashTable["consentMstRid"] = newConsentMstRid;
  1841. // consentMstRid = newConsentMstRid;
  1842. // dac.InsertConsentMst(this.IbatisMapper, paramHashTable);
  1843. // dac.InsertConsentData(this.IbatisMapper, paramHashTable);
  1844. // imageUpload(dac, paramHashTable, userId
  1845. // , patientCode, vistType, clnDate, dschdd, cretno, ocrCode
  1846. // , consentMstRid, consentState, formCd, formRid, dataXml, imageFileJson, certTarget, certResult, hosType, createUserName, hosType);
  1847. // } else {
  1848. // dac.UpdateConsentMstForDelete(this.IbatisMapper, paramHashTable);
  1849. // }
  1850. // }
  1851. // //임시저장 또는 저장인 경우
  1852. // else {
  1853. // dac.UpdateConsentMst(this.IbatisMapper, paramHashTable);
  1854. // dac.InsertConsentData(this.IbatisMapper, paramHashTable);
  1855. // imageUpload(dac, paramHashTable, userId
  1856. // , patientCode, vistType, clnDate, dschdd, cretno, ocrCode
  1857. // , consentMstRid, consentState, formCd, formRid, dataXml, imageFileJson, certTarget, certResult, hosType, createUserName, hosType);
  1858. // }
  1859. // }
  1860. // // OCR 테이블 연계
  1861. // Hashtable ocrParam = new Hashtable {
  1862. // { "instcd", hosType },
  1863. // { "ocrtag", ocrCode },
  1864. // { "pid", patientCode },
  1865. // { "ordtype", vistType },
  1866. // { "orddd", clnDate },
  1867. // { "cretno", cretno },
  1868. // { "orddrid", mainDrId },
  1869. // { "orddeptcd", clnDeptCode },
  1870. // { "formcd", formCd },
  1871. // { "fstprntdeptcd", userDeptCd },
  1872. // { "fstprntid", userId },
  1873. // { "updtdeptcd", userDeptCd },
  1874. // { "updtuserid", userId },
  1875. // { "updtdt", DateTime.Now.ToString("yyyyMMddHHmmss")},
  1876. // { "pagecnt", pageCnt },
  1877. // { "updtresncnts", reasonForUseN },
  1878. // { "actkind", actKind },
  1879. // { "clienttype", clientType }
  1880. // };
  1881. // dac.InsertPrintData(this.IbatisMapper, ocrParam);
  1882. // // 원무 동의서 연동
  1883. // SavePatientConsentInfo(formCd
  1884. // , patientCode
  1885. // , ocrCode
  1886. // , hosType
  1887. // , clnDate
  1888. // , cretno.ToString()
  1889. // , vistType
  1890. // , clnDeptCode
  1891. // , mainDrId
  1892. // , userId
  1893. // , dataXml);
  1894. // }
  1895. // } catch (Exception ex) {
  1896. // if (this.IbatisSession != null) this.IbatisSession.RollBackTransaction();
  1897. // CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm SaveDataAll ERROR : [{0}]", ex.ToString()));
  1898. // throw ex;
  1899. // } finally {
  1900. // }
  1901. // return consentMstRid;
  1902. //}
  1903. //private void imageUpload(SaveConsentDac dac
  1904. // , Hashtable paramHashTable
  1905. // , string userId
  1906. // , string patientCode
  1907. // , string visitType
  1908. // , string clnDate
  1909. // , string Dschdd
  1910. // , int cretno
  1911. // , string ocrcode
  1912. // , int consentMstRid
  1913. // , string consentState
  1914. // , string formCd
  1915. // , int formRid
  1916. // , string dataXml
  1917. // , string imageFileJson
  1918. // , string certTarget
  1919. // , string certResult
  1920. // , string hosType
  1921. // , string createUserName
  1922. // , string dutinstcd
  1923. // ) {
  1924. // // 서명 저장일 경우 emrindxm 테이블에 저장
  1925. // if (!string.IsNullOrEmpty(consentState) && (consentState.Equals("ELECTR_CMP") || consentState.Equals("CERTIFY_CMP"))) {
  1926. // string clnDeptCode = paramHashTable["clnDeptCd"] == null ? string.Empty : paramHashTable["clnDeptCd"].ToString();
  1927. // try {
  1928. // int consentImageRid = this.GetSequence("CONSENT_IMAGE");
  1929. // int firstImageRid = consentImageRid;
  1930. // string sPath = string.Empty;
  1931. // string sFileName = string.Empty;
  1932. // string newFileFullName = string.Empty;
  1933. // if (!string.IsNullOrEmpty(imageFileJson)) {
  1934. // Dictionary<string, object> jsonRoot = null;
  1935. // jsonRoot = fastJSON.JSON.Parse(imageFileJson) as Dictionary<string, object>;
  1936. // if (jsonRoot != null && jsonRoot.Count > 0) {
  1937. // Hashtable imageHashTable = new Hashtable();
  1938. // int nowCnt = 1;
  1939. // foreach (KeyValuePair<string, object> jr in jsonRoot) {
  1940. // imageHashTable = new Hashtable();
  1941. // imageHashTable.Add("consentMstRid", consentMstRid);
  1942. // if (nowCnt > 1) consentImageRid = this.GetSequence("CONSENT_IMAGE");
  1943. // imageHashTable.Add("consentImageRid", consentImageRid);
  1944. // imageHashTable.Add("userId", userId);
  1945. // imageHashTable.Add("formRid", formRid);
  1946. // if (jr.Value != null && !string.IsNullOrEmpty(jr.Value.ToString())) {
  1947. // sPath = "";
  1948. // sFileName = "";
  1949. // string[] filepath = jr.Value.ToString().Split('/');
  1950. // for (int i = 0; i < filepath.Length; i++) {
  1951. // if (i == 0) {
  1952. // sPath = filepath[i];
  1953. // } else if ((i + 1) == filepath.Length) {
  1954. // sFileName = filepath[i];
  1955. // } else {
  1956. // sPath += "/" + filepath[i];
  1957. // }
  1958. // }
  1959. // newFileFullName = string.Empty;
  1960. // using (HospitalSvc hospitalWebService = new HospitalSvc()) {
  1961. // newFileFullName = hospitalWebService.GetFileName(patientCode, visitType,
  1962. // clnDate.Replace("-", ""), Dschdd, string.Format("{0}", cretno),
  1963. // "500", formCd, nowCnt.ToString(),
  1964. // ocrcode, userId, clnDeptCode, dutinstcd);
  1965. // }
  1966. // string uploadFileName = newFileFullName + ".jpg";
  1967. // int idx = uploadFileName.LastIndexOf(".");
  1968. // string sUploadPath = uploadFileName.Substring(idx - 4, 4);
  1969. // string sUploadFileName = uploadFileName.Substring(uploadFileName.LastIndexOf("\\") + 1);
  1970. // var remotePath = imageServerProps.remotePath;
  1971. // //var destDrive = remotePath.Substring(0, 2);
  1972. // var destDirectory = remotePath.Substring(2);
  1973. // var targetDrive = "";
  1974. // var virtualDir = "";
  1975. // // 경로를 확인하여 가상 디렉토리 경로를 설정한다
  1976. // if (imageServerProps != null) {
  1977. // targetDrive = imageServerProps.remotePath.Substring(0, 1);
  1978. // switch (targetDrive) {
  1979. // case "W":
  1980. // virtualDir = "his032";
  1981. // break;
  1982. // case "Z":
  1983. // virtualDir = "his031";
  1984. // break;
  1985. // }
  1986. // }
  1987. // // 계정을 choiadmin 으로 가장한다
  1988. // ClipSoft.Utility.ImpersonationUtility util = new ClipSoft.Utility.ImpersonationUtility();
  1989. // var imResult = util.ImpersonationStart(string.Empty, "choiadmin", "choiadmin");
  1990. // CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("Impersonation Start, " + imResult);
  1991. // // IIS 가상 디렉토리 경로를 가져온다
  1992. // DirectoryInfo di = new DirectoryInfo(Server.MapPath(virtualDir));
  1993. // var destDirStr = String.Format(@"{0}\{1}\{2}",
  1994. // di.ToString(),
  1995. // remotePath.Substring(remotePath.IndexOf("ACTIVE_ENC") + @"ACTIVE_ENC\".Length),
  1996. // sUploadPath);
  1997. // // for debug
  1998. // //var destDirStr = String.Format(@"{0}\{1}\{2}\{3}\",
  1999. // // di.ToString(),
  2000. // // remotePath.Substring(remotePath.IndexOf("ACTIVE_ENC") + @"ACTIVE_ENC\".Length),
  2001. // // "consentTest",
  2002. // // sUploadPath);
  2003. // DirectoryInfo destDi = new DirectoryInfo(destDirStr);
  2004. // //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("destDirStr: " + destDirStr + ", exists: " + destDi.Exists);
  2005. // var destFullname = String.Format(@"{0}\{1}", destDirStr, sUploadFileName);
  2006. // var localFile = Server.MapPath(string.Format(@"./UPLOAD/{0}/{1}", sPath, sFileName));
  2007. // //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("local: " + localFile + ", remote: " + destFullname);
  2008. // if (!destDi.Exists) {
  2009. // destDi.Create();
  2010. // }
  2011. // try {
  2012. // File.Copy(localFile, destFullname);
  2013. // } catch (Exception e) {
  2014. // CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(e);
  2015. // }
  2016. // util.ImpersonationEnd();
  2017. // CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("Impersonation end");
  2018. // imageHashTable.Add("imagePath", sUploadPath);
  2019. // imageHashTable.Add("imageFilename", sUploadFileName);
  2020. // imageHashTable.Add("completeYn", paramHashTable["completeYn"]);
  2021. // dac.InsertConsentImage(this.IbatisMapper, imageHashTable);
  2022. // }
  2023. // nowCnt++;
  2024. // } // end of foreach
  2025. // }
  2026. // }
  2027. // paramHashTable.Add("consentImageRid", firstImageRid);
  2028. // // TODO 원무 인증 저장 pass
  2029. // // 원무 저장시 해당 정보 저장 or skip 확인 해 볼 것
  2030. // // 사인정보 저장
  2031. // dac.InsertConsentImageSign(this.IbatisMapper, paramHashTable);
  2032. // } catch (Exception ex) {
  2033. // using (HospitalSvc hospitalWebService = new HospitalSvc()) {
  2034. // hospitalWebService.delEformData(patientCode, visitType,
  2035. // clnDate.Replace("-", ""), Dschdd, string.Format("{0}", cretno),
  2036. // formCd, ocrcode, userId, createUserName, string.Format("{0}", consentMstRid), hosType,
  2037. // clnDeptCode, dutinstcd);
  2038. // }
  2039. // if (this.IbatisSession != null) this.IbatisSession.RollBackTransaction();
  2040. // CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm imageUpload ERROR : [{0}]", ex.ToString()));
  2041. // throw ex;
  2042. // }
  2043. // }
  2044. //}
  2045. private bool checkOcrType6Form(string dutinstcd, string formCd) {
  2046. List<String> forms = getOcrType6Forms(dutinstcd);
  2047. int pos = forms.FindIndex(x => x.StartsWith(formCd));
  2048. return (pos > 0) ? true : false;
  2049. }
  2050. private int SavePrintData(string userId, string patientCode, string clnDeptCode, int formRid, string formCd,
  2051. int consentMstRid, int rewriteConsentMstRid, int reissueConsentMstRid, string consentState, string paperYn, string formXml, string dataXml,
  2052. string deviceType, string deviceIdentNo, string vistType, string hosType, string clnDate,
  2053. string ward, string roomcd, string reasonForUseN, int orderNo, string orderName, string orderCd, string ocrCode, int cretno,
  2054. string createUserName, string modifyUserName, string imageFileName, string certTarget,
  2055. string certResult, string mainDrId,
  2056. string userDeptCd, string pageCnt, string actKind, string clientType, string opRsrvNo) {
  2057. bool isNewConsentMasterCase = false;
  2058. if (consentMstRid < 1) {
  2059. isNewConsentMasterCase = true;
  2060. }
  2061. // OCR TYPE 6 는 기록하지 않는다
  2062. if (checkOcrType6Form(hosType, formCd)) {
  2063. return -1;
  2064. }
  2065. try {
  2066. using (SaveConsentDac dac = new SaveConsentDac()) {
  2067. Hashtable paramHashTable = GetParamHashTable(userId, patientCode, clnDeptCode, formRid, formCd, consentMstRid, rewriteConsentMstRid,
  2068. reissueConsentMstRid, consentState, paperYn, formXml, dataXml, deviceType, deviceIdentNo,
  2069. vistType, hosType, clnDate, ward, roomcd, reasonForUseN,
  2070. orderNo, orderName, orderCd, ocrCode, cretno, createUserName, modifyUserName,
  2071. certTarget, certResult, mainDrId, opRsrvNo);
  2072. consentMstRid = (int) paramHashTable["consentMstRid"];
  2073. //새로 출력하는 경우
  2074. if (isNewConsentMasterCase) {
  2075. dac.InsertConsentMst(this.IbatisMapper, paramHashTable);
  2076. }
  2077. //새로 작성 아닌 경우
  2078. else {
  2079. if (reissueConsentMstRid > 0)
  2080. dac.UpdateConsentMstForReissue(this.IbatisMapper, paramHashTable);
  2081. else
  2082. dac.UpdateConsentMst(this.IbatisMapper, paramHashTable);
  2083. }
  2084. // OCR 테이블 연계
  2085. Hashtable ocrParam = new Hashtable {
  2086. { "instcd", hosType },
  2087. { "ocrtag", ocrCode },
  2088. { "pid", patientCode },
  2089. { "ordtype", vistType },
  2090. { "orddd", clnDate },
  2091. { "cretno", cretno },
  2092. { "orddrid", mainDrId },
  2093. { "orddeptcd", clnDeptCode },
  2094. { "formcd", formCd },
  2095. { "fstprntdeptcd", userDeptCd },
  2096. { "fstprntid", userId },
  2097. { "updtdeptcd", userDeptCd },
  2098. { "updtuserid", userId },
  2099. { "updtdt", DateTime.Now.ToString("yyyyMMddHHmmss")},
  2100. { "pagecnt", pageCnt },
  2101. { "updtresncnts", reasonForUseN },
  2102. { "actkind", actKind },
  2103. { "clienttype", clientType }
  2104. };
  2105. dac.InsertPrintData(this.IbatisMapper, ocrParam);
  2106. }
  2107. } catch (Exception ex) {
  2108. if (this.IbatisSession != null) this.IbatisSession.RollBackTransaction();
  2109. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm SaveData ERROR : [{0}]", ex.ToString()));
  2110. throw ex;
  2111. } finally {
  2112. }
  2113. return consentMstRid;
  2114. }
  2115. public static int ExecuteCommand(string command, int timeout) {
  2116. var processInfo = new System.Diagnostics.ProcessStartInfo("cmd.exe", "/C " + command) {
  2117. RedirectStandardOutput = true,
  2118. CreateNoWindow = true,
  2119. UseShellExecute = false,
  2120. //WorkingDirectory = "C:\\",
  2121. //WorkingDirectory = ".\\",
  2122. };
  2123. var process = System.Diagnostics.Process.Start(processInfo);
  2124. process.WaitForExit(20000);
  2125. //string txt = process.StandardOutput.ReadToEnd();
  2126. //Console.WriteLine(txt);
  2127. var exitCode = process.ExitCode;
  2128. process.Close();
  2129. return exitCode;
  2130. }
  2131. private static Dictionary<string, string> DataXmlToDictionary(string dataXml) {
  2132. Dictionary<string, string> outputDataDic;
  2133. XmlDocument xmlDocument = new XmlDocument();
  2134. xmlDocument.LoadXml(dataXml);
  2135. outputDataDic = new Dictionary<string, string>();
  2136. XmlNode rootNode = xmlDocument.SelectSingleNode("form-data");
  2137. foreach (XmlNode childNode in rootNode.ChildNodes) {
  2138. string fieldName = string.Empty;
  2139. string fieldValue = string.Empty;
  2140. XmlElement outFieldElement = childNode as XmlElement;
  2141. if (outFieldElement != null) {
  2142. fieldName = outFieldElement.Name;
  2143. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("DataXmlToDictionary 0 : {0}/{1}", outFieldElement.ChildNodes.Count, fieldName));
  2144. if (outFieldElement.ChildNodes.Count == 1 && outFieldElement.ChildNodes[0] is XmlCDataSection) {
  2145. fieldValue = ((XmlCDataSection) outFieldElement.ChildNodes[0]).InnerText;
  2146. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("DataXmlToDictionary 1 : {0}/{1}", fieldName, fieldValue));
  2147. if (outputDataDic.ContainsKey(fieldName)) {
  2148. outputDataDic[fieldName] = fieldValue;
  2149. } else {
  2150. outputDataDic.Add(fieldName, fieldValue);
  2151. }
  2152. } else if (outFieldElement.ChildNodes.Count > 1) {
  2153. foreach (XmlNode childNode2 in childNode.ChildNodes) {
  2154. string fieldName2 = string.Empty;
  2155. string fieldValue2 = string.Empty;
  2156. XmlElement outFieldElement2 = childNode2 as XmlElement;
  2157. fieldName2 = outFieldElement2.Name;
  2158. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("DataXmlToDictionary : {0}", fieldName2));
  2159. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("DataXmlToDictionary : {0}", outFieldElement2.ChildNodes.Count));
  2160. if (outFieldElement2.ChildNodes.Count > 0 && outFieldElement2.ChildNodes[0] is XmlCDataSection) {
  2161. fieldValue2 = ((XmlCDataSection) outFieldElement2.ChildNodes[0]).InnerText;
  2162. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("DataXmlToDictionary 2 : {0}/{1}", fieldName2, fieldValue2));
  2163. }
  2164. if (outputDataDic.ContainsKey(fieldName2)) {
  2165. outputDataDic[fieldName2] = fieldValue2;
  2166. } else {
  2167. outputDataDic.Add(fieldName2, fieldValue2);
  2168. }
  2169. }
  2170. }
  2171. }
  2172. }
  2173. return outputDataDic;
  2174. }
  2175. /// <summary>
  2176. /// EFORM_CODE에 정의하는 시퀀스(채번)을 구한다.
  2177. /// </summary>
  2178. /// <param name="sSubCd"></param>
  2179. /// <returns></returns>
  2180. private int GetSequence(string sSubCd) {
  2181. int nSeq = -1;
  2182. try {
  2183. using (CommonCodeDac dac = new CommonCodeDac()) {
  2184. Code param = new Code();
  2185. param.sub_cd = sSubCd;
  2186. nSeq = dac.GetSequence(this.IbatisMapper, param);
  2187. if (nSeq == 0) {
  2188. dac.InsertSequence(this.IbatisMapper, param);
  2189. nSeq = 1;
  2190. } else {
  2191. param.ud1_num = ++nSeq;
  2192. dac.UpdateSequence(this.IbatisMapper, param);
  2193. }
  2194. }
  2195. } catch (Exception ex) {
  2196. if (this.IbatisSession != null) this.IbatisSession.RollBackTransaction();
  2197. throw ex;
  2198. }
  2199. return nSeq;
  2200. }
  2201. #region GetParamHashTable
  2202. private Hashtable GetParamHashTable(string userId, // 사용자 Id
  2203. string patientCode, // 환자 등록번호
  2204. string clnDeptCode, // 진료과 코드
  2205. int formRid, // (작성대상)서식 Rid
  2206. string formCd, // 서식코드 === CONSENT_DATA_CHOICE에서 입력여부 판단할 파라미터
  2207. int consentMstRid, // 동의서 마스터 데이터 Rid
  2208. int rewriteConsentMstRid, // 재 작성 대상 동의서 마스터 데이터 Rid
  2209. int reissueConsentMstRid, // 재 발행 대상 동의서 마스터 데이터 Rid
  2210. string consentState, // 동의서 상태 (TEMP, PAPER_OUT, ELECTR_CMP, CERTIFY_CMP)
  2211. string paperYn, // 인쇄 발행 여부
  2212. string formXml, // 동의서 EPT Xml
  2213. string dataXml, // 동의서 Data(필드들) Xml
  2214. string deviceType, // 장비 유형 (WIN, AND, IOS, PRT 중1)
  2215. string deviceIdentNo, // 장비 고유식별 번호
  2216. string vistType, // 내원 구분
  2217. string hosType, // 병원 구분
  2218. string clnDate, // 내원구분에 따른 입원일자/진료일자
  2219. string ward, // 병동 코드
  2220. string roomcd, // 병실 코드
  2221. string reasonForUseN, // 출력된 동의서 폐기 사유
  2222. int orderNo, // 처방번호
  2223. string orderName, // 처방명
  2224. string orderCd, // 처방코드
  2225. string ocrCode, // OCR 코드
  2226. int cretno, // 생성번호
  2227. string createUserName, // 작성자명
  2228. string modifyUserName, // 수정자명
  2229. string certTarget, // 서명데이터 원본
  2230. string certResult, // 서명데이터 결과값
  2231. string mainDrId, // 주치의 아이디
  2232. string opRsrvNo // 수술 예약 번호
  2233. ) {
  2234. Hashtable paramHashTable = new Hashtable();
  2235. paramHashTable.Add("userId", userId);
  2236. if (consentMstRid < 1) {
  2237. // insert case
  2238. consentMstRid = this.GetSequence("CONSENT_MST");
  2239. }
  2240. paramHashTable.Add("consentMstRid", consentMstRid);
  2241. paramHashTable.Add("patientCode", patientCode);
  2242. paramHashTable.Add("clnDeptCd", clnDeptCode);
  2243. paramHashTable.Add("vistType", vistType);
  2244. paramHashTable.Add("hosType", hosType);
  2245. paramHashTable.Add("clnDate", clnDate);
  2246. paramHashTable.Add("ward", ward);
  2247. paramHashTable.Add("roomcd", roomcd);
  2248. paramHashTable.Add("orderNo", orderNo);
  2249. paramHashTable.Add("orderName", orderName);
  2250. paramHashTable.Add("orderCd", orderCd);
  2251. paramHashTable.Add("ocrCode", ocrCode);
  2252. paramHashTable.Add("cretno", cretno);
  2253. paramHashTable.Add("createUserName", createUserName);
  2254. paramHashTable.Add("modifyUserName", modifyUserName);
  2255. paramHashTable.Add("formRid", formRid);
  2256. paramHashTable.Add("formCd", formCd);
  2257. paramHashTable.Add("consentState", consentState);
  2258. paramHashTable.Add("certTarget", certTarget); // TODO 원무 pass
  2259. paramHashTable.Add("certResult", certResult); // TODO 원무 pass
  2260. paramHashTable.Add("mainDrId", mainDrId);
  2261. paramHashTable.Add("opRsrvNo", opRsrvNo ?? string.Empty);
  2262. Encoding encoding = Encoding.GetEncoding("UTF-8");
  2263. //if (certResult != null)
  2264. //{
  2265. // paramHashTable.Add("certResult", encoding.GetBytes(certResult));
  2266. //}
  2267. string completeYn = "N"; // 완료 여부
  2268. switch (consentState) {
  2269. case "ELECTR_CMP":
  2270. case "CERTIFY_CMP":
  2271. completeYn = "Y";
  2272. break;
  2273. default:
  2274. break;
  2275. }
  2276. paramHashTable.Add("completeYn", completeYn);
  2277. string completeDateTimeToChars = string.Empty;
  2278. if (completeYn.Equals("Y")) {
  2279. completeDateTimeToChars = "TO_CHAR(SYSDATE,'YYYY-MM-DD hh24:mi:ss')";
  2280. paramHashTable.Add("completeDateTimeToChars", completeDateTimeToChars);
  2281. } else {
  2282. paramHashTable.Add("completeDateTimeToChars", "''");
  2283. }
  2284. paramHashTable.Add("paperYn", paperYn);
  2285. string rewriteYn = "N"; // 재 작성 여부
  2286. if (rewriteConsentMstRid > 1) {
  2287. rewriteYn = "Y";
  2288. }
  2289. paramHashTable.Add("rewriteYn", rewriteYn);
  2290. paramHashTable.Add("rewriteConsentMstRid", rewriteConsentMstRid);
  2291. string reissueYn = "N"; // 재 발행(종이) 여부
  2292. if (reissueConsentMstRid > 1) {
  2293. reissueYn = "Y";
  2294. }
  2295. paramHashTable.Add("reissueYn", reissueYn);
  2296. paramHashTable.Add("reissueConsentMstRid", reissueConsentMstRid);
  2297. int consentDataRid = this.GetSequence("CONSENT_DATA");
  2298. paramHashTable.Add("consentDataRid", consentDataRid);
  2299. paramHashTable.Add("useYn", "Y");
  2300. encoding = Encoding.GetEncoding("UTF-8");
  2301. byte[] formBytesConent = null;
  2302. if (!string.IsNullOrEmpty(formXml)) {
  2303. formBytesConent = encoding.GetBytes(formXml);
  2304. }
  2305. byte[] dataBytesConent = null;
  2306. if (!string.IsNullOrEmpty(dataXml)) {
  2307. dataBytesConent = encoding.GetBytes(dataXml);
  2308. }
  2309. paramHashTable.Add("formXml", formBytesConent);
  2310. paramHashTable.Add("dataXml", dataBytesConent);
  2311. paramHashTable.Add("deviceType", deviceType);
  2312. paramHashTable.Add("deviceIdentNo", deviceIdentNo);
  2313. paramHashTable.Add("reasonForUseN", reasonForUseN);
  2314. return paramHashTable;
  2315. }
  2316. #endregion
  2317. //임시파일 삭제 (1일전 파일은 삭제)
  2318. //public int DeleteTempFile(string targetDate)
  2319. public int DeleteTempFile() {
  2320. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("DeleteTempFile DateTime.Now.AddDays(-1) : {0}", DateTime.Now.AddDays(-1).ToString())); // 2016-11-06 오후 8:19:56
  2321. if (tempImageDelStatus.Equals(DateTime.Now.AddDays(-1).ToString().Substring(0, 10).Replace("-", ""))) {
  2322. return 1;
  2323. }
  2324. try {
  2325. string sSeverImgPath = Server.MapPath("./DataTempImage/");
  2326. DirectoryInfo di = new System.IO.DirectoryInfo(sSeverImgPath);
  2327. if (Directory.Exists(sSeverImgPath)) {
  2328. string[] filePaths = Directory.GetFiles(sSeverImgPath);
  2329. foreach (string fileName in filePaths) {
  2330. FileInfo fileInfo = new FileInfo(fileName);
  2331. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("DeleteTempFile fileInfo.CreationTime : {0}", fileInfo.CreationTime.ToString()));
  2332. if (fileInfo.CreationTime < DateTime.Now.AddDays(-1)) {
  2333. fileInfo.Delete();
  2334. }
  2335. }
  2336. }
  2337. tempImageDelStatus = DateTime.Now.AddDays(-1).ToString().Substring(0, 10).Replace("-", "");
  2338. return 1;
  2339. } catch {
  2340. return -1;
  2341. }
  2342. }
  2343. /// <summary>
  2344. /// 동의서 로드 전 consent_mst_rid에 해당하는 동의서가 상위 상태값이 있는지 체크
  2345. /// </summary>
  2346. /// <param name="consentmstrid"></param>
  2347. /// <param name="consent_state"></param>
  2348. /// <returns></returns>
  2349. [WebMethod(Description = "동의서 상위 상태값이 있는지 체크")]
  2350. public int CheckConsentState(int consentmstrid, string consent_state) {
  2351. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("rid: {0}, state: {1}", consentmstrid, consent_state));
  2352. try {
  2353. int result = -1;
  2354. int StateNo = 0;
  2355. String CurState;
  2356. using (ConsentDac dac = new ConsentDac()) {
  2357. Hashtable param = new Hashtable();
  2358. param.Add("consentmstrid", consentmstrid);
  2359. CurState = dac.GetConsentStateCheck(this.IbatisMapper, param);
  2360. }
  2361. if (CurState == null) {
  2362. return result;
  2363. } else if (CurState.Equals("UNFINISHED")) {
  2364. StateNo = 1;
  2365. } else if (CurState.Equals("TEMP")) {
  2366. StateNo = 2;
  2367. } else if (CurState.Equals("VERBAL")) {
  2368. StateNo = 3;
  2369. } else if (CurState.Equals("PAPER_OUT")) {
  2370. StateNo = 4;
  2371. } else if (CurState.Equals("ELECTR_CMP")) {
  2372. StateNo = 5;
  2373. } else if (CurState.Equals("CERTIFY_CMP")) {
  2374. StateNo = 6;
  2375. }
  2376. if (consent_state == null/* || string.IsNullOrEmpty(consent_state)*/) {
  2377. return result;
  2378. } else if (consent_state.Equals("UNFINISHED")) {
  2379. result = 1;
  2380. } else if (consent_state.Equals("TEMP")) {
  2381. result = 2;
  2382. } else if (consent_state.Equals("VERBAL")) {
  2383. result = 3;
  2384. } else if (consent_state.Equals("PAPER_OUT")) {
  2385. result = 4;
  2386. } else if (consent_state.Equals("ELECTR_CMP")) {
  2387. result = 5;
  2388. } else if (consent_state.Equals("CERTIFY_CMP")) {
  2389. return result;
  2390. }
  2391. if (result < StateNo)//로드하려는 동의서의 상태보다 현재 저장된 상태가 더 높은 상태일 경우
  2392. {
  2393. return 1;
  2394. } else//로드하려는 동의서보다 현재 저장된 상태가 낮은상태일 경우 또는 같을경우
  2395. {
  2396. return 0;
  2397. }
  2398. } catch {
  2399. return -1;
  2400. }
  2401. }
  2402. /// <summary>
  2403. /// 개인정보 동의서 일때만 해당 메서드를 사용함 (formCd가 1200005463, 1800014564 인것만)
  2404. /// </summary>
  2405. private void SavePatientConsentInfo(string formCd, string pid, string ocrTag, string userId, string dataXml) {
  2406. try {
  2407. // 동의서 내부 데이터 추출
  2408. UTF8Encoding encoder = new UTF8Encoding();
  2409. Decoder utf8Decode = encoder.GetDecoder();
  2410. byte[] toEcodeByte = Convert.FromBase64String(dataXml);
  2411. int charCount = utf8Decode.GetCharCount(toEcodeByte, 0, toEcodeByte.Length);
  2412. char[] decodedChar = new char[charCount];
  2413. utf8Decode.GetChars(toEcodeByte, 0, toEcodeByte.Length, decodedChar, 0);
  2414. dataXml = Unzip(toEcodeByte);
  2415. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("dataXml -- > " + dataXml);
  2416. Dictionary<string, string> pamDic = DataXmlToDictionary(dataXml);
  2417. string savPrivacy1 = pamDic.ContainsKey("sav_privacy1") ? pamDic["sav_privacy1"].ToString() : ""; // 개인정보 서식의 메인 동의, 미동의 데이터
  2418. string savPrivacy2 = pamDic.ContainsKey("sav_privacy2") ? pamDic["sav_privacy2"].ToString() : ""; // 개인정보 서식의 첫 번째 동의, 미동의 데이터 (사후서비스제공)
  2419. string savPrivacy3 = pamDic.ContainsKey("sav_privacy3") ? pamDic["sav_privacy3"].ToString() : ""; // 개인정보 서식의 두 번째 동의, 미동의 데이터 (모바일안내)
  2420. string savPrivacy4 = pamDic.ContainsKey("sav_privacy4") ? pamDic["sav_privacy4"].ToString() : ""; // 개인정보 서식의 세 번째 동의, 미동의 데이터 (행사안내)
  2421. string savPrivacy5 = pamDic.ContainsKey("sav_privacy5") ? pamDic["sav_privacy5"].ToString() : ""; // 개인정보 서식의 네 번째 동의, 미동의 데이터 (협력병원)
  2422. string patientNm = pamDic.ContainsKey("savSG_PatientNm") ? pamDic["savSG_PatientNm"].ToString() : ""; // 환자 이름
  2423. string patientSign = pamDic.ContainsKey("savSG_PatientSign") ? pamDic["savSG_PatientSign"].ToString() : ""; // 환자 서명
  2424. string agentNm = pamDic.ContainsKey("savSG_AgentNm") ? pamDic["savSG_AgentNm"].ToString() : ""; // 동의권자 이름
  2425. string agnentSign = pamDic.ContainsKey("savSG_AgentSign") ? pamDic["savSG_AgentSign"].ToString() : ""; // 동의권자 서명
  2426. string agentRelation = pamDic.ContainsKey("savSG_AgentRelation") ? pamDic["savSG_AgentRelation"].ToString() : "1"; // 환자와의 관계 드롭박스
  2427. string agentETC = pamDic.ContainsKey("savSG_AgentETC") ? pamDic["savSG_AgentETC"].ToString() : ""; // 환자와의 관계 글상자(기타 입력란)
  2428. string agentReason = pamDic.ContainsKey("savSG_AgentReason") ? pamDic["savSG_AgentReason"].ToString() : ""; // 동의권자서명이유 상위컨트롤(라디오박스)
  2429. string agentPhone = pamDic.ContainsKey("savSG_AgentPhone") ? pamDic["savSG_AgentPhone"].ToString() : ""; // 법정대리인 연락처 글상자
  2430. string agentReasonText = pamDic.ContainsKey("savSG_AgentReasonText") ? pamDic["savSG_AgentReasonText"].ToString() : ""; // 기타 글 상자
  2431. // 관계가 없다면 본인 서명 아니라면 값을
  2432. agentRelation = agentRelation == "" ? "1" : agentRelation;
  2433. // 동의권자 서명 사유
  2434. var value5 = string.Empty;
  2435. var value6 = string.Empty;
  2436. var value7 = string.Empty;
  2437. var value8 = string.Empty;
  2438. var value9 = string.Empty;
  2439. switch (agentReason) {
  2440. case "value1":
  2441. value5 = "Y";
  2442. break;
  2443. case "value2":
  2444. value6 = "Y";
  2445. break;
  2446. case "value3":
  2447. value7 = "Y";
  2448. break;
  2449. case "value4":
  2450. value8 = "Y";
  2451. break;
  2452. case "value5":
  2453. value9 = "Y";
  2454. break;
  2455. }
  2456. using (SaveConsentDac dac = new SaveConsentDac()) {
  2457. Hashtable param = new Hashtable();
  2458. param.Add("pid", pid);
  2459. param.Add("userId", userId);
  2460. param.Add("instcd", "101");
  2461. int pamSeqResult = dac.getPamSeqNo(this.IbatisMapper, param);
  2462. // 기존의 개인정보보호 동의서가 있다면 업데이트
  2463. if(pamSeqResult > 0) {
  2464. dac.updatePreSignData(this.IbatisMapper, param);
  2465. }
  2466. // 개인정보보호동의서 신규
  2467. param.Add("patientNm", patientNm);
  2468. param.Add("agentRelation", agentRelation);
  2469. param.Add("patientSign", string.IsNullOrEmpty(patientSign) ? "N" : "Y");
  2470. param.Add("savPrivacy1", savPrivacy1);
  2471. param.Add("savPrivacy2", savPrivacy2);
  2472. param.Add("savPrivacy3", savPrivacy3);
  2473. param.Add("savPrivacy4", savPrivacy4);
  2474. param.Add("savPrivacy5", savPrivacy5);
  2475. param.Add("value5", value5);
  2476. param.Add("value6", value6);
  2477. param.Add("value7", value7);
  2478. param.Add("value8", value8);
  2479. param.Add("value9", value9);
  2480. param.Add("telno", agentPhone);
  2481. param.Add("etc", agentReasonText);
  2482. param.Add("seqno", pamSeqResult);
  2483. param.Add("seqno2", Convert.ToString(Convert.ToInt32(pamSeqResult) + 1));
  2484. var result = dac.insPmcmpicm(this.IbatisMapper, param);
  2485. pamSeqResult = pamSeqResult + 1;
  2486. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("pamSeqResult -- > " + pamSeqResult);
  2487. }
  2488. } catch (Exception ex) {
  2489. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm SavePatientConsentInfo ERROR : [{0}]", ex.ToString()));
  2490. throw ex;
  2491. }
  2492. }
  2493. /// <summary>
  2494. /// 기준자료로 부터 OCT 태그에 찍힐 String 값
  2495. /// 경북대병원 dependency
  2496. /// </summary>
  2497. /// <param name="formCd">The form cd.</param>
  2498. /// <param name="dutinstcd">The dutinstcd.</param>
  2499. /// <returns></returns>
  2500. [WebMethod(Description = "기준자료로 부터 OCT 태그에 찍힐 String 값")]
  2501. public String getOcrString(string formCd, string dutinstcd) {
  2502. using (ConsentDac dac = new ConsentDac()) {
  2503. Hashtable param = new Hashtable();
  2504. param.Add("formcd", formCd);
  2505. param.Add("instcd", dutinstcd);
  2506. return dac.getOcrString(this.IbatisMapper, param);
  2507. }
  2508. }
  2509. /// <summary>
  2510. /// 원무 서식의 인증저장 사용여부
  2511. /// Y 일 경우 인증서 묻기를 하지 않는다
  2512. /// 경북대병원 dependency
  2513. /// </summary>
  2514. /// <param name="formCd">서식 코드</param>
  2515. /// <param name="dutinstcd">근무지기관코드</param>
  2516. /// <returns></returns>
  2517. [WebMethod(Description = "원무서식 인증저장 사용여부, Y 일 경우 인증저장시 인증서 묻기 pass")]
  2518. public String getCertUseYn(String formCd, String dutinstcd) {
  2519. using (ConsentDac dac = new ConsentDac()) {
  2520. Hashtable param = new Hashtable();
  2521. param.Add("formcd", formCd);
  2522. param.Add("instcd", dutinstcd);
  2523. String value = dac.getCertuseYn(this.IbatisMapper, param);
  2524. return (value == null) ? "N" : value;
  2525. //return dac.getCertuseYn(this.IbatisMapper, param);
  2526. }
  2527. }
  2528. /// <summary>
  2529. /// 원무 서식의 인증저장 사용여부 (모바일에서 사용)
  2530. /// 원무 서식이 여러개 선택되었을때
  2531. /// Y 일 경우 인증서 묻기를 하지 않는다
  2532. /// 경북대병원 dependency
  2533. /// </summary>
  2534. /// <param name="formCd">서식 코드</param> 서식코드는 '11111111', '2222222', '333333' 형태로 들어옴
  2535. /// <param name="dutinstcd">근무지기관코드</param>
  2536. /// <returns></returns>
  2537. [WebMethod(Description = "원무서식 인증저장 사용여부, Y 일 경우 인증저장시 인증서 묻기 pass (모바일에서 다중 선택 기능 포함)")]
  2538. public String getCertUseYnData(String formCd, String dutinstcd) {
  2539. using (ConsentDac dac = new ConsentDac()) {
  2540. Hashtable param = new Hashtable();
  2541. param.Add("formcd", formCd);
  2542. param.Add("instcd", dutinstcd);
  2543. String result = dac.getCertUseYnData(this.IbatisMapper, param);
  2544. if (result == null) {
  2545. result = "";
  2546. }
  2547. return result;
  2548. }
  2549. }
  2550. /// <summary>
  2551. /// 경북대학교병원 PC 클라이언트 dual view 모드 활성화 여부 조회
  2552. /// </summary>
  2553. /// <param name="dutinstcd">근무지기관코드</param>
  2554. /// <param name="ipaddr">해당 PC 의 ip address</param>
  2555. /// <returns></returns>
  2556. [WebMethod(Description = "경북대학교병원 PC 클라이언트 dual view 모드 활성화 여부 조회")]
  2557. public String getDualViewMode(String dutinstcd, String ipaddr) {
  2558. using (ConsentDac dac = new ConsentDac()) {
  2559. Hashtable param = new Hashtable();
  2560. param.Add("instcd", dutinstcd);
  2561. param.Add("ipaddr", ipaddr);
  2562. String value = dac.getDualViewMode(this.IbatisMapper, param);
  2563. return (value == null) ? "N" : value;
  2564. }
  2565. //return "N";
  2566. }
  2567. /// <summary>
  2568. /// 확인저장 된 서식을 일괄저장
  2569. /// </summary>
  2570. /// <param name="consent_rids"></param>
  2571. /// <param name="ocrtags"></param>
  2572. /// <param name="instcd"></param>
  2573. /// <returns></returns>
  2574. [WebMethod(Description = "경북대학교병원 일괄 인증 저장")]
  2575. public String updateCertifyComplete(String consent_rids, String ocrtags, String instcd) {
  2576. String result = "N";
  2577. try {
  2578. Hashtable param1 = new Hashtable();
  2579. Hashtable param2 = new Hashtable();
  2580. param1.Add("consent_rids", consent_rids);
  2581. param1.Add("instcd", instcd);
  2582. param2.Add("ocrtags", ocrtags);
  2583. param2.Add("instcd", instcd);
  2584. using (ConsentDac dac = new ConsentDac()) {
  2585. // 동의서 테이블 master
  2586. dac.updateToCertifyConsentMst(this.IbatisMapper, param1);
  2587. // 경북대학교병원 출력 로그 테이블
  2588. dac.updateToCertifyOcrprnt(this.IbatisMapper, param2);
  2589. }
  2590. result = "Y";
  2591. } catch (Exception ex) {
  2592. if (this.IbatisSession != null) this.IbatisSession.RollBackTransaction();
  2593. result = "N";
  2594. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(
  2595. String.Format("CLIP.eForm updateCertifyComplete ERROR : [{0}]", ex.ToString()));
  2596. }
  2597. return result;
  2598. }
  2599. /// <summary>
  2600. /// 전자동의서 프린트 출력 오류 시 프린트 로그 삭제 메서드
  2601. /// </summary>
  2602. /// <param name="pid"></param>
  2603. /// <param name="ocrtag"></param>
  2604. /// <param name="instcd"></param>
  2605. [WebMethod(Description = "프린터 출력 오류 시 출력 히스토리 삭제")]
  2606. public void updatePrintHistory(String pid, String ocrtag, String instcd) {
  2607. try {
  2608. Hashtable param1 = new Hashtable();
  2609. param1.Add("pid", pid);
  2610. param1.Add("instcd", instcd);
  2611. param1.Add("ocrtag", ocrtag);
  2612. using (ConsentDac dac = new ConsentDac()) {
  2613. dac.updateOcrPrintHistory(this.IbatisMapper, param1);
  2614. dac.updateConsentMaster(this.IbatisMapper, param1);
  2615. }
  2616. } catch (Exception ex) {
  2617. if (this.IbatisSession != null) this.IbatisSession.RollBackTransaction();
  2618. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(
  2619. String.Format("CLIP.eForm updatePrintHistory ERROR : [{0}]", ex.ToString()));
  2620. }
  2621. }
  2622. /// <summary>
  2623. /// 동의서 선택시 해당일에 대해 중복으로 정상되었는지 확인
  2624. /// </summary>
  2625. /// <param name="pid"></param>
  2626. /// <param name="instcd"></param>
  2627. /// <param name="formcd"></param> '000000', '000001', '000002' 콤마로 붙여야함
  2628. [WebMethod(Description = "동의서 선택시 해당일에 대해 중복으로 정상되었는지 확인")]
  2629. public String duplicateCertConsent(String pid, String instcd, String formcd) {
  2630. using (ConsentDac dac = new ConsentDac()) {
  2631. Hashtable param = new Hashtable();
  2632. param.Add("pid", pid);
  2633. param.Add("instcd", instcd);
  2634. param.Add("formcd", formcd);
  2635. String result = dac.getDupCertConsent(this.IbatisMapper, param);
  2636. if (result == null) {
  2637. result = "N";
  2638. }
  2639. return result;
  2640. }
  2641. }
  2642. [WebMethod(Description = "동의서 선택시 해당일에 대해 중복으로 정상되었는지 확인")]
  2643. public String getUserTableGrants() {
  2644. string result = string.Empty;
  2645. using(CommonCodeDac dac = new CommonCodeDac()) {
  2646. Hashtable param = new Hashtable();
  2647. dac.GetImageServerProps(this.IbatisMapper, param);
  2648. }
  2649. return result;
  2650. }
  2651. }
  2652. }