ConsentSvc.asmx.cs 119 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595
  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 CLIP.eForm.Consent.Web;
  23. using System.Security.AccessControl;
  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. imageServerProps = new ImageServerProps(_ibatisHelper.GetSqlMapper());
  55. }
  56. protected override void Dispose(bool disposing) {
  57. if (IbatisSession != null && IbatisSession.Transaction != null) {
  58. IbatisSession.CommitTransaction();
  59. IbatisSession.CloseConnection();
  60. }
  61. if (IbatisMapper != null)
  62. IbatisMapper.CloseConnection();
  63. base.Dispose(disposing);
  64. }
  65. /// <summary>
  66. /// 현재 연결된 IBatis Connection을 반환
  67. /// </summary>
  68. public ISqlMapper IbatisMapper {
  69. get {
  70. if (_ibatisHelper == null) {
  71. return null;
  72. } else {
  73. return _ibatisHelper.GetSqlMapper();
  74. }
  75. }
  76. }
  77. /// <summary>
  78. /// 현재 연결된 ISqlMapSession 을 반환
  79. /// </summary>
  80. public ISqlMapSession IbatisSession {
  81. get {
  82. if (_ibatisHelper == null) {
  83. return null;
  84. } else {
  85. return _ibatisHelper.GetMapSession();
  86. }
  87. }
  88. }
  89. [WebMethod]
  90. public bool CheckWebService() {
  91. return true;
  92. }
  93. /// <summary>
  94. /// 경북대학교병원 출력 로그에 기록되지 않아야 할 목록 조회
  95. /// </summary>
  96. /// <param name="dutinstcd"></param>
  97. /// <returns></returns>
  98. [WebMethod(Description = "Type 6 인 동의서 조회")]
  99. public List<String> getOcrType6Forms(string dutinstcd) {
  100. using (SaveConsentDac dac = new SaveConsentDac()) {
  101. Hashtable param = new Hashtable();
  102. param.Add("instcd", dutinstcd);
  103. return (List<String>) dac.getOcrType6Forms(this.IbatisMapper, param);
  104. }
  105. }
  106. [WebMethod]
  107. public bool CheckDatabaseConnection() {
  108. // TODO: 데이터 베이스 커넥션 테스트 호출 필요
  109. return false;
  110. }
  111. /// <summary>
  112. /// 동의서 하위 카테고리 조회
  113. /// </summary>
  114. /// <param name="instCd"></param>
  115. /// <returns></returns>
  116. [WebMethod(Description = "동의서 하위 카테고리 조회")]
  117. public List<CategoryForDropdownVO> GetCategoryForDropdown(string instCd) {
  118. List<CategoryForDropdownVO> result;
  119. try {
  120. using (FormCategoryDac dac = new FormCategoryDac()) {
  121. string categoryId = "";
  122. if (instCd.Equals("031")) {
  123. categoryId = "EMA_031";
  124. } else {
  125. categoryId = "EMA_032";
  126. }
  127. Hashtable param = new Hashtable();
  128. param.Add("category_id", categoryId);
  129. result = (List<CategoryForDropdownVO>) dac.GetCategoryForDropdown(this.IbatisMapper, param);
  130. CategoryForDropdownVO allSubCategory = new CategoryForDropdownVO();
  131. allSubCategory.CategoryId = categoryId;
  132. allSubCategory.CategoryName = "전체";
  133. allSubCategory.CategoryType = "F";
  134. result.Insert(0, allSubCategory);
  135. }
  136. return result;
  137. } catch (Exception ex) {
  138. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm GetCategoryForDropdown error: {0}", ex.Message));
  139. throw ex;
  140. }
  141. }
  142. ///// <summary>
  143. ///// 동의서 하위 카테고리 조회
  144. ///// </summary>
  145. ///// <param name="categoryId">카테고리 ID</param>
  146. ///// <returns></returns>
  147. //[WebMethod(Description = "동의서 하위 카테고리 조회")]
  148. //public List<CategoryForDropdownVO> GetCategoryForDropdown(string categoryId) {
  149. // List<CategoryForDropdownVO> result;
  150. // try {
  151. // using (FormCategoryDac dac = new FormCategoryDac()) {
  152. // Hashtable param = new Hashtable();
  153. // param.Add("category_id", categoryId);
  154. // result = (List<CategoryForDropdownVO>) dac.GetCategoryForDropdown(this.IbatisMapper, param);
  155. // if (categoryId.Equals("1")) {
  156. // CategoryForDropdownVO categoryForDropdownVO = new CategoryForDropdownVO();
  157. // categoryForDropdownVO.CategoryType = "F";
  158. // categoryForDropdownVO.CategoryId = "1CB1B494-1EF0-48BD-84D6-4965A54E6AEA";
  159. // categoryForDropdownVO.CategoryName = "전체";
  160. // result.Insert(0, categoryForDropdownVO);
  161. // } else {
  162. // CategoryForDropdownVO allSubCategory = new CategoryForDropdownVO();
  163. // allSubCategory.CategoryId = categoryId;
  164. // allSubCategory.CategoryName = "전체";
  165. // allSubCategory.CategoryType = "F";
  166. // result.Insert(0, allSubCategory);
  167. // }
  168. // }
  169. // return result;
  170. // } catch (Exception ex) {
  171. // CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm GetCategoryForDropdown error: {0}", ex.Message));
  172. // throw ex;
  173. // }
  174. //}
  175. [WebMethod(Description = "사용자 이름에 따른 환자별 동의서 목록 조회")]
  176. public List<ConsentVO> GetConsentListByUserName(string username, string startDt, string endDt, string consetState, string dutinstcd) {
  177. List<ConsentVO> result = null;
  178. try {
  179. using (ConsentDac dac = new ConsentDac()) {
  180. Hashtable param = new Hashtable {
  181. { "instcd", dutinstcd },
  182. { "startDt", startDt },
  183. { "endDt", endDt },
  184. { "usename", username },
  185. { "status", consetState}
  186. };
  187. return (List<ConsentVO>) dac.GetUnfinishedListPerUserName(this.IbatisMapper, param);
  188. }
  189. } catch (Exception ex) {
  190. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm GetUnfinishedListPerDoctor error: {0}", ex.Message));
  191. throw ex;
  192. }
  193. return result;
  194. }
  195. /// <summary>
  196. /// 환자, 상태에 따른 동의서 목록 검색
  197. /// </summary>
  198. /// <param name="pid">환자등록번호</param>
  199. /// <param name="startDt">데이터생성일자 조회 시작일</param>
  200. /// <param name="endDt">The end dt.</param>
  201. /// <param name="consentState">State of the conset.</param>
  202. /// <param name="instCd">근무지기관코드</param>
  203. /// <param name="userId">The user identifier.</param>
  204. /// <returns></returns>
  205. [WebMethod(Description = "환자/상태에 따른 동의서 목록 검색")]
  206. public List<ConsentVO> GetConsentList(string pid, string startDt, string endDt, string consentState, string instCd
  207. , string userId) {
  208. List<ConsentVO> result;
  209. try {
  210. // 임시저장 조회 시 미작성이 없으면 미작성 상태도 추가
  211. if (!string.IsNullOrEmpty(consentState)) {
  212. bool _hasTemp = false;
  213. bool _hasUnfinished = false;
  214. string[] _stateArr = consentState.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
  215. foreach (string s in _stateArr) {
  216. if (s.Equals("TEMP")) {
  217. _hasTemp = true;
  218. } else if (s.Equals("UNFINISHED")) {
  219. _hasUnfinished = true;
  220. }
  221. }
  222. if (_hasTemp && !_hasUnfinished) {
  223. consentState += ",'UNFINISHED'";
  224. }
  225. }
  226. using (ConsentDac dac = new ConsentDac()) {
  227. Hashtable param = new Hashtable {
  228. { "pid", pid },
  229. { "startDt", startDt },
  230. { "endDt", endDt },
  231. { "consentState", consentState },
  232. { "instCd", instCd },
  233. { "userId", userId ?? string.Empty}
  234. };
  235. //result = (List<ConsentVO>) dac.GetConsentList(this.IbatisMapper, param);
  236. result = (List<ConsentVO>) dac.GetConsentList(this.IbatisMapper, param);
  237. }
  238. return result;
  239. } catch (Exception ex) {
  240. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm GetConsentList error: {0}", ex.Message));
  241. throw ex;
  242. }
  243. }
  244. /// <summary>
  245. /// 동의서 찾기
  246. /// </summary>
  247. /// <param name="categoryId">카테고리 ID</param>
  248. /// <param name="keyWord">검색할 키워드</param>
  249. /// <param name="instCd">근무지기관코드</param>
  250. /// <returns></returns>
  251. [WebMethod(Description = "동의서 찾기(조회)")]
  252. public List<ConsentVO> GetConsentBySearch(string categoryId, string keyWord, string instCd) {
  253. List<ConsentVO> result;
  254. if (categoryId.Equals("EMA_031") || categoryId.Equals("EMA_032")) {
  255. categoryId = "";
  256. }
  257. try {
  258. using (ConsentDac dac = new ConsentDac()) {
  259. Hashtable param = new Hashtable();
  260. param.Add("categoryId", categoryId);
  261. param.Add("instCd", instCd);
  262. param.Add("keyWord", string.Format("%{0}%", keyWord));
  263. result = (List<ConsentVO>) dac.GetConsentBySearch(this.IbatisMapper, param);
  264. }
  265. return result;
  266. } catch (Exception ex) {
  267. System.Diagnostics.Trace.WriteLine(string.Format("CLIP.eForm GetConsentBySearch error: {0}", ex.Message));
  268. throw ex;
  269. }
  270. }
  271. /// <summary>
  272. /// 동의서 찾기
  273. /// </summary>
  274. /// <param name="formCd">서식코드</param>
  275. /// <param name="instCd">근무지기관코드</param>
  276. /// <returns>ConsentBySearchVO 객체 List</returns>
  277. [WebMethod(Description = "동의서 찾기(서식코드)")]
  278. public ConsentVO GetConsentByFormcd(string formCd, string instCd) {
  279. ConsentVO result = new ConsentVO();
  280. try {
  281. using (ConsentDac dac = new ConsentDac()) {
  282. Hashtable param = new Hashtable();
  283. //string formCdArr = "";
  284. //string[] cdArr = formCd.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
  285. //for (int i = 0; i < cdArr.Length; i++) {
  286. // formCdArr += string.Format("'{0}',", cdArr[i].Trim());
  287. //}
  288. //formCdArr = formCdArr.Remove(formCdArr.Length - 1);
  289. param.Add("formCd", formCd);
  290. param.Add("instCd", instCd);
  291. result = dac.GetConsentByFormcd(this.IbatisMapper, param);
  292. }
  293. return result;
  294. } catch (Exception ex) {
  295. System.Diagnostics.Trace.WriteLine(string.Format("CLIP.eForm GetConsentByFormcd error: {0}", ex.Message));
  296. throw ex;
  297. }
  298. }
  299. private class ImageServerProps {
  300. public string ipAddr;
  301. public string remotePath;
  302. public string user;
  303. public string pwd;
  304. public ImageServerProps(ISqlMapper IbatisMapper) {
  305. using (CommonCodeDac ccdac = new CommonCodeDac()) {
  306. IList<ImageServerPropsVO> props;
  307. Hashtable opts = new Hashtable();
  308. props = ccdac.GetImageServerProps(IbatisMapper, opts);
  309. foreach (var prop in props) {
  310. if (prop.active == "A") {
  311. ipAddr = prop.ipaddr;
  312. remotePath = prop.localpath;
  313. user = prop.username;
  314. pwd = prop.userpasswd;
  315. break;
  316. }
  317. }
  318. }
  319. }
  320. }
  321. ImageServerProps imageServerProps = null;
  322. /// <summary>
  323. /// CONSENT_MST_RID를 갖고 저장된 동의서 이미지를 조회
  324. /// </summary>
  325. /// <param name="consentMstRid">동의서 마스터 데이터 Rid</param>
  326. [WebMethod(Description = "동의서 저장된 이미지 내역 조회")]
  327. public List<ConsentImageVO> GetConsentImage(string consentMstRid) {
  328. List<ConsentImageVO> result;
  329. try {
  330. using (ConsentDac dac = new ConsentDac()) {
  331. Hashtable param = new Hashtable();
  332. int consentMstRidInt = 0;
  333. int.TryParse(consentMstRid, out consentMstRidInt);
  334. param.Add("consent-mst-rid", consentMstRidInt);
  335. result = (List<ConsentImageVO>) dac.GetConsentImage(this.IbatisMapper, param);
  336. // 사용자 ID 와 패스워드가 없다면 강제로 하드코딩 해서 기입한다
  337. if (imageServerProps.user == null || imageServerProps.user == "") {
  338. imageServerProps.user = "choiadmin";
  339. }
  340. if (imageServerProps.pwd == null || imageServerProps.pwd == "") {
  341. imageServerProps.pwd = "choiadmin";
  342. }
  343. var targetDrive = "";
  344. var destDirectory = imageServerProps.remotePath.Substring(2);
  345. var virtualDir = "";
  346. var remotePath = "";
  347. // 경로를 확인하여 가상 디렉토리 경로를 설정한다
  348. if (imageServerProps != null) {
  349. targetDrive = imageServerProps.remotePath.Substring(0, 1);
  350. switch (targetDrive) {
  351. case "W":
  352. virtualDir = "his032";
  353. break;
  354. case "Z":
  355. virtualDir = "his031";
  356. break;
  357. }
  358. remotePath = imageServerProps.remotePath;
  359. }
  360. // 계정을 choiadmin 으로 가장한다
  361. ClipSoft.Utility.ImpersonationUtility util = new ClipSoft.Utility.ImpersonationUtility();
  362. var imResult = util.ImpersonationStart(string.Empty, "choiadmin", "choiadmin");
  363. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("Impersonation Start, " + imResult);
  364. // for debug
  365. DirectoryInfo destDi = new DirectoryInfo(Server.MapPath("DataTempImage"));
  366. var destDirStr = destDi.ToString();
  367. DirectoryInfo origDi = new DirectoryInfo(Server.MapPath(virtualDir));
  368. // 해당 경로에 디렉토리가 없다면 생성하여 준다
  369. if (!destDi.Exists) {
  370. destDi.Create();
  371. }
  372. foreach (ConsentImageVO img in result) {
  373. string newFileName = String.Format(@"{0}{1}", img.ImagePath.Replace("\\", ""), img.ImageFilename);
  374. var origDiStr = String.Format(@"{0}\{1}\{2}", origDi.ToString(),
  375. remotePath.Substring(remotePath.IndexOf("ACTIVE_ENC") + @"ACTIVE_ENC\".Length),
  376. img.ImagePath);
  377. // for debug
  378. //var origDiStr = String.Format(@"{0}\{1}\{2}\{3}",
  379. // origDi.ToString(),
  380. // remotePath.Substring(remotePath.IndexOf("ACTIVE_ENC") + @"ACTIVE_ENC\".Length),
  381. // "consentTest",
  382. // img.ImagePath);
  383. var origFullPath = String.Format(@"{0}\{1}", origDiStr, img.ImageFilename);
  384. var destFullPath = String.Format(@"{0}\{1}", destDirStr, newFileName);
  385. try {
  386. File.Copy(origFullPath, destFullPath, true);
  387. } catch (Exception e) {
  388. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("file copy error", e);
  389. }
  390. img.ImagePath = destDirStr;
  391. img.ImageFilename = newFileName;
  392. }
  393. util.ImpersonationEnd();
  394. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("Impersonation end");
  395. }
  396. // ?? 왜 로컬에 있는 tempfile 들을 삭제할까?
  397. //int iResult = DeleteTempFile();
  398. return result;
  399. } catch (Exception ex) {
  400. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm GetConsentImage error: {0}", ex.Message));
  401. throw ex;
  402. }
  403. }
  404. public byte[] xmlData(string xml) {
  405. UTF8Encoding encoder = new UTF8Encoding();
  406. Decoder utf8Decode = encoder.GetDecoder();
  407. byte[] toEcodeByte = Convert.FromBase64String(xml);
  408. //byte[] toEcodeByte = Encoding.UTF8.GetBytes(xml);
  409. int charCount = utf8Decode.GetCharCount(toEcodeByte, 0, toEcodeByte.Length);
  410. char[] decodedChar = new char[charCount];
  411. utf8Decode.GetChars(toEcodeByte, 0, toEcodeByte.Length, decodedChar, 0);
  412. return toEcodeByte;
  413. }
  414. /// <summary>
  415. /// 전자동의서를 임시저장 한다. 안드로이드 저장부분 http connection 변경으로 인한 임시저장 함수 신설
  416. /// </summary>
  417. /// <param name="userId">로그인 사용자ID</param>
  418. /// <param name="patientCode">환자 등록번호</param>
  419. /// <param name="clnDeptCode">진료과 코드</param>
  420. /// <param name="formRid">(작성대상)서식 Rid</param>
  421. /// <param name="formCd">서식코드</param>
  422. /// <param name="consentMstRid">동의서 마스터 데이터 Rid</param>
  423. /// <param name="rewriteConsentMstRid">재 작성 대상 동의서 마스터 데이터 Rid</param>
  424. /// <param name="formXml">동의서 EPT Xml</param>
  425. /// <param name="dataXml">동의서 Data(필드들) Xml</param>
  426. /// <param name="deviceType">장비 유형 (WIN, AND, IOS, PRT 중1)</param>
  427. /// <param name="deviceIdentNo">장비 고유 식별자</param>
  428. /// <param name="vistType">내원구분</param>
  429. /// <param name="hosType">병원 구분</param>
  430. /// <param name="clnDate">병원 구분이 "I" 일 경우 입원일자/병원 구분이 "O"일 경우 진료일자</param>
  431. /// <param name="ward">병동 코드</param>
  432. /// <param name="roomcd">병실 코드</param>
  433. /// <param name="orderNo">처방번호</param>
  434. /// <param name="orderName">처방명</param>
  435. /// <param name="orderCd">처방코드</param>
  436. /// <param name="ocrCode">OCR 코드</param>
  437. /// <param name="cretno">생성번호</param>
  438. /// <param name="createUserName">작성자명</param>
  439. /// <param name="modifyUserName">수정자명</param>
  440. /// <param name="mainDrId">주치의 아이디</param>
  441. /// <param name="userDeptCd">사용자 부서 코드</param>
  442. /// <param name="pageCnt">동의서 매수</param>
  443. /// <param name="actKind">동작코드(T: 임시 저장, C: 인증 저장, P: 출력, CP: 삭제)</param>
  444. /// <param name="clientType">Client구분 (P: PC, M: 모바일)</param>
  445. /// <param name="opRsrvNo">수술예약번호</param>
  446. /// <returns>
  447. /// CONSENT_MST_RID
  448. /// </returns>
  449. [WebMethod(Description = "동의서 임시저장 NEW")]
  450. public SingleReturnData SaveTempDataNew(string userId, string patientCode, string clnDeptCode, int formRid, string formCd,
  451. int consentMstRid, int rewriteConsentMstRid, string formXml, string dataXml,
  452. string deviceType, string deviceIdentNo, string vistType, string hosType, string clnDate,
  453. string ward, string roomCd, int orderNo, string orderName, string orderCd, string ocrCode, int cretNo,
  454. string createUserName, string modifyUserName, string mainDrId,
  455. string userDeptCd, string pageCnt, string actKind, string clientType, string opRsrvNo,
  456. string consentState) {
  457. SingleReturnData result = new SingleReturnData();
  458. byte[] formXmlbyte64 = Convert.FromBase64String(formXml);
  459. byte[] dataXmlbyte64 = Convert.FromBase64String(dataXml);
  460. formXml = Encoding.UTF8.GetString(formXmlbyte64);
  461. dataXml = Encoding.UTF8.GetString(dataXmlbyte64);
  462. int reissueConsentMstRid = 0;
  463. consentState = string.IsNullOrEmpty(consentState) ? "TEMP" : consentState;
  464. consentMstRid = SaveData(userId, patientCode, clnDeptCode, formRid, formCd,
  465. consentMstRid, 0, reissueConsentMstRid, consentState, "N", formXml, dataXml,
  466. deviceType, deviceIdentNo, vistType, hosType, clnDate,
  467. ward, roomCd, string.Empty, orderNo, orderName, orderCd, ocrCode, cretNo,
  468. createUserName, modifyUserName, null, null, null, mainDrId,
  469. userDeptCd, pageCnt, actKind, clientType, opRsrvNo);
  470. result.responseData = Convert.ToString(consentMstRid);
  471. return result;
  472. }
  473. /// <summary>
  474. /// 전자동의서를 임시저장 한다.
  475. /// </summary>
  476. /// <param name="userId">로그인 사용자ID</param>
  477. /// <param name="patientCode">환자 등록번호</param>
  478. /// <param name="clnDeptCode">진료과 코드</param>
  479. /// <param name="formRid">(작성대상)서식 Rid</param>
  480. /// <param name="formCd">서식코드</param>
  481. /// <param name="consentMstRid">동의서 마스터 데이터 Rid</param>
  482. /// <param name="rewriteConsentMstRid">재 작성 대상 동의서 마스터 데이터 Rid</param>
  483. /// <param name="formXml">동의서 EPT Xml</param>
  484. /// <param name="dataXml">동의서 Data(필드들) Xml</param>
  485. /// <param name="deviceType">장비 유형 (WIN, AND, IOS, PRT 중1)</param>
  486. /// <param name="deviceIdentNo">장비 고유 식별자</param>
  487. /// <param name="vistType">내원구분</param>
  488. /// <param name="hosType">병원 구분</param>
  489. /// <param name="clnDate">병원 구분이 "I" 일 경우 입원일자/병원 구분이 "O"일 경우 진료일자</param>
  490. /// <param name="ward">병동 코드</param>
  491. /// <param name="roomcd">병실 코드</param>
  492. /// <param name="orderNo">처방번호</param>
  493. /// <param name="orderName">처방명</param>
  494. /// <param name="orderCd">처방코드</param>
  495. /// <param name="ocrCode">OCR 코드</param>
  496. /// <param name="cretno">생성번호</param>
  497. /// <param name="createUserName">작성자명</param>
  498. /// <param name="modifyUserName">수정자명</param>
  499. /// <param name="mainDrId">주치의 아이디</param>
  500. /// <param name="userDeptCd">사용자 부서 코드</param>
  501. /// <param name="pageCnt">동의서 매수</param>
  502. /// <param name="actKind">동작코드(T: 임시 저장, C: 인증 저장, P: 출력, CP: 삭제)</param>
  503. /// <param name="clientType">Client구분 (P: PC, M: 모바일)</param>
  504. /// <param name="opRsrvNo">수술예약번호</param>
  505. /// <returns>
  506. /// CONSENT_MST_RID
  507. /// </returns>
  508. [WebMethod(Description = "동의서 임시저장")]
  509. public SingleReturnData SaveTempData(string userId, string patientCode, string clnDeptCode, int formRid, string formCd,
  510. int consentMstRid, int rewriteConsentMstRid, string formXml, string dataXml,
  511. string deviceType, string deviceIdentNo, string vistType, string hosType, string clnDate,
  512. string ward, string roomCd, int orderNo, string orderName, string orderCd, string ocrCode, int cretNo,
  513. string createUserName, string modifyUserName, string mainDrId,
  514. string userDeptCd, string pageCnt, string actKind, string clientType, string opRsrvNo,
  515. string consentState) {
  516. SingleReturnData result = new SingleReturnData();
  517. //string orgFormXml = Unzip(formXml);
  518. //string orgDataXml = Unzip(dataXml);
  519. //dataXml = Unzip(xmlData(dataXml));
  520. //formXml = Unzip(xmlData(formXml));
  521. //string paramLog = "";
  522. //paramLog += "clnDept[" + userId + "]patientCode[" + patientCode + "]clnDeptCode[" + clnDeptCode + "]formRid[" + formRid + "]";
  523. //paramLog += "formCd[" + formCd + "]consentMstRid[" + consentMstRid + "]rewriteConsentMstRid[" + rewriteConsentMstRid + "]";
  524. //paramLog += "deviceType[" + deviceType + "]vistType[" + vistType + "]hosType[" + hosType + "]";
  525. //paramLog += "clnDate[" + clnDate + "]ward[" + ward + "]roomcd[" + roomcd + "]orderNo[" + orderNo + "]";
  526. //paramLog += "orderName[" + orderName + "]orderCd[" + orderCd + "]ocrCode[" + ocrCode + "]cretno[" + cretno + "]";
  527. //paramLog += "createUserName[" + createUserName + "]modifyUserName[" + modifyUserName + "]";
  528. //paramLog += "deviceIdentNo[" + deviceIdentNo + "]mainDrId[" + mainDrId + "]";
  529. //paramLog += "dataXml[" + dataXml + "]formXml[" + formXml + "]";
  530. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("dataXml -- > " + dataXml);
  531. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("formXml -- > " + formXml);
  532. int reissueConsentMstRid = 0;
  533. consentState = string.IsNullOrEmpty(consentState) ? "TEMP" : consentState;
  534. consentMstRid = SaveData(userId, patientCode, clnDeptCode, formRid, formCd,
  535. consentMstRid, 0, reissueConsentMstRid, consentState, "N", formXml, dataXml,
  536. deviceType, deviceIdentNo, vistType, hosType, clnDate,
  537. ward, roomCd, string.Empty, orderNo, orderName, orderCd, ocrCode, cretNo,
  538. createUserName, modifyUserName, null, null, null, mainDrId,
  539. userDeptCd, pageCnt, actKind, clientType, opRsrvNo);
  540. result.responseData = Convert.ToString(consentMstRid);
  541. return result;
  542. }
  543. /// <summary>
  544. /// 전자 동의서를 완료저장 한다.
  545. /// </summary>
  546. /// <param name="userId">로그인 사용자ID</param>
  547. /// <param name="patientCode">환자 등록번호</param>
  548. /// <param name="clnDeptCode">진료과 코드</param>
  549. /// <param name="formRid">(작성대상)서식 Rid</param>
  550. /// <param name="formCd">서식코드</param>
  551. /// <param name="consentMstRid">동의서 마스터 데이터 Rid</param>
  552. /// <param name="rewriteConsentMstRid">재 작성 대상 동의서 마스터 데이터 Rid</param>
  553. /// <param name="formXml">동의서 EPT Xml</param>
  554. /// <param name="dataXml">동의서 Data(필드들) Xml</param>
  555. /// <param name="deviceType">장비 유형 (WIN, AND, IOS, PRT 중1)</param>
  556. /// <param name="deviceIdentNo">장비 고유 식별자</param>
  557. /// <param name="vistType">내원구분</param>
  558. /// <param name="hosType">병원 구분</param>
  559. /// <param name="clnDate">병원 구분이 "I" 일 경우 입원일자/병원 구분이 "O"일 경우 진료일자</param>
  560. /// <param name="ward">병동 코드</param>
  561. /// <param name="roomcd">병실 코드</param>
  562. /// <param name="orderNo">처방번호</param>
  563. /// <param name="orderName">처방명</param>
  564. /// <param name="orderCd">처방코드</param>
  565. /// <param name="ocrCode">The ocr code.</param>
  566. /// <param name="cretno">The cretno.</param>
  567. /// <param name="createUserName">작성자명</param>
  568. /// <param name="modifyUserName">수정자명</param>
  569. /// <param name="mainDrId">주치의 아이디</param>
  570. /// <param name="userDeptCd">사용자 부서 코드</param>
  571. /// <param name="pageCnt">출력 매수</param>
  572. /// <param name="actKind">동작 코드</param>
  573. /// <param name="clientType">Client 구분</param>
  574. /// <param name="opRsrvNo">수술 예약 번호</param>
  575. /// <returns></returns>l
  576. [WebMethod(Description = "동의서 서명 완료")]
  577. public int SaveComplete(string userId, string patientCode, string clnDeptCode, int formRid, string formCd,
  578. int consentMstRid, int rewriteConsentMstRid, string formXml, string dataXml,
  579. string deviceType, string deviceIdentNo, string vistType, string hosType, string clnDate,
  580. string ward, string roomcd, int orderNo, string orderName, string orderCd, string ocrCode, int cretno,
  581. string createUserName, string modifyUserName, string mainDrId,
  582. string userDeptCd, string pageCnt, string actKind, string clientType, string opRsrvNo) {
  583. int reissueConsentMstRid = 0;
  584. string consentState = "ELECTR_CMP";
  585. string paperYn = "N";
  586. string reasonForUseN = string.Empty;
  587. rewriteConsentMstRid = 0;
  588. consentMstRid = SaveData(userId, patientCode, clnDeptCode, formRid, formCd,
  589. consentMstRid, rewriteConsentMstRid, reissueConsentMstRid, consentState, paperYn, formXml, dataXml,
  590. deviceType, deviceIdentNo, vistType, hosType, clnDate,
  591. ward, roomcd, reasonForUseN, orderNo, orderName, orderCd, ocrCode, cretno,
  592. createUserName, modifyUserName, null, null, null, mainDrId,
  593. userDeptCd, pageCnt, actKind, clientType, opRsrvNo);
  594. return consentMstRid;
  595. }
  596. /// <summary>
  597. /// 전자 동의서를 완료저장 한다. 안드로이드 저장부분 http connection 변경으로 인한 인증, 확인 함수 신설
  598. /// </summary>
  599. /// <param name="userId">로그인 사용자ID</param>
  600. /// <param name="patientCode">환자 등록번호</param>
  601. /// <param name="clnDeptCode">진료과 코드</param>
  602. /// <param name="formRid">(작성대상)서식 Rid</param>
  603. /// <param name="formCd">서식코드</param>
  604. /// <param name="consentMstRid">동의서 마스터 데이터 Rid</param>
  605. /// <param name="rewriteConsentMstRid">재 작성 대상 동의서 마스터 데이터 Rid</param>
  606. /// <param name="formXml">동의서 EPT Xml</param>
  607. /// <param name="dataXml">동의서 Data(필드들) Xml</param>
  608. /// <param name="deviceType">장비 유형 (WIN, AND, IOS, PRT 중1)</param>
  609. /// <param name="deviceIdentNo">장비 고유 식별자</param>
  610. /// <param name="vistType">내원구분</param>
  611. /// <param name="hosType">병원 구분</param>
  612. /// <param name="clnDate">병원 구분이 "I" 일 경우 입원일자/병원 구분이 "O"일 경우 진료일자</param>
  613. /// <param name="ward">병동 코드</param>
  614. /// <param name="roomcd">병실 코드</param>
  615. /// <param name="orderNo">처방번호</param>
  616. /// <param name="orderCd">처방코드</param>
  617. /// <param name="orderName">처방명</param>
  618. /// <param name="createUserName">작성자명</param>
  619. /// <param name="modifyUserName">수정자명</param>
  620. /// <param name="imageFileJson">이미지 파일 정보(전자동의서 서버)</param>
  621. /// <param name="certTarget">이미지 파일 공인인증 대상정보</param>
  622. /// <param name="certResult">이미지 파일 공인인증 처리정보</param>
  623. /// <param name="dschdd">퇴원일자</param>
  624. /// <param name="consentState">상태</param>
  625. /// <param name="mainDrId">주치의 아이디</param>
  626. /// <param name="userDeptCd">사용자 부서 코드</param>
  627. /// <param name="pageCnt">동의서 매수</param>
  628. /// <param name="actKind">동작코드(T: 임시 저장, C: 인증 저장, P: 출력, CP: 삭제)</param>
  629. /// <param name="clientType">Client구분 (P: PC, M: 모바일)</param>
  630. /// <param name="fileSize">이미지 파일 사이즈</param>
  631. [WebMethod(Description = "동의서 서명 완료 NEW")]
  632. public SingleReturnData SaveCompleteAllNew(string userId, string patientCode, string clnDeptCode, int formRid, string formCd,
  633. int consentMstRid, int rewriteConsentMstRid, string formXml, string dataXml,
  634. string deviceType, string deviceIdentNo, string vistType, string hosType, string clnDate,
  635. string ward, string roomCd, int orderNo, string orderName, string orderCd, string ocrCode, int cretNo,
  636. string createUserName, string modifyUserName, string imageFileJson, string certTarget, string certResult,
  637. string dschDd, string consentState, string mainDrId,
  638. string userDeptCd, string pageCnt, string actKind, string clientType, string opRsrvNo, string fileSize) {
  639. SingleReturnData result = new SingleReturnData();
  640. int reissueConsentMstRid = 0;
  641. string paperYn = "N";
  642. string reasonForUseN = string.Empty;
  643. byte[] formXmlbyte64 = Convert.FromBase64String(formXml);
  644. byte[] dataXmlbyte64 = Convert.FromBase64String(dataXml);
  645. formXml = Encoding.UTF8.GetString(formXmlbyte64);
  646. dataXml = Encoding.UTF8.GetString(dataXmlbyte64);
  647. rewriteConsentMstRid = 0;
  648. consentMstRid = SaveDataAll(userId, patientCode, clnDeptCode, formRid, formCd,
  649. consentMstRid, rewriteConsentMstRid, reissueConsentMstRid, consentState, paperYn, formXml, dataXml,
  650. deviceType, deviceIdentNo, vistType, hosType, clnDate,
  651. ward, roomCd, reasonForUseN, orderNo, orderName, orderCd, ocrCode, cretNo,
  652. createUserName, modifyUserName, imageFileJson, certTarget, certResult, dschDd, mainDrId,
  653. userDeptCd, pageCnt, actKind, clientType, opRsrvNo, fileSize);
  654. result.responseData = Convert.ToString(consentMstRid);
  655. return result;
  656. }
  657. /// <summary>
  658. /// 전자 동의서를 완료저장 한다.
  659. /// </summary>
  660. /// <param name="userId">로그인 사용자ID</param>
  661. /// <param name="patientCode">환자 등록번호</param>
  662. /// <param name="clnDeptCode">진료과 코드</param>
  663. /// <param name="formRid">(작성대상)서식 Rid</param>
  664. /// <param name="formCd">서식코드</param>
  665. /// <param name="consentMstRid">동의서 마스터 데이터 Rid</param>
  666. /// <param name="rewriteConsentMstRid">재 작성 대상 동의서 마스터 데이터 Rid</param>
  667. /// <param name="formXml">동의서 EPT Xml</param>
  668. /// <param name="dataXml">동의서 Data(필드들) Xml</param>
  669. /// <param name="deviceType">장비 유형 (WIN, AND, IOS, PRT 중1)</param>
  670. /// <param name="deviceIdentNo">장비 고유 식별자</param>
  671. /// <param name="vistType">내원구분</param>
  672. /// <param name="hosType">병원 구분</param>
  673. /// <param name="clnDate">병원 구분이 "I" 일 경우 입원일자/병원 구분이 "O"일 경우 진료일자</param>
  674. /// <param name="ward">병동 코드</param>
  675. /// <param name="roomcd">병실 코드</param>
  676. /// <param name="orderNo">처방번호</param>
  677. /// <param name="orderCd">처방코드</param>
  678. /// <param name="orderName">처방명</param>
  679. /// <param name="createUserName">작성자명</param>
  680. /// <param name="modifyUserName">수정자명</param>
  681. /// <param name="imageFileJson">이미지 파일 정보(전자동의서 서버)</param>
  682. /// <param name="certTarget">이미지 파일 공인인증 대상정보</param>
  683. /// <param name="certResult">이미지 파일 공인인증 처리정보</param>
  684. /// <param name="dschdd">퇴원일자</param>
  685. /// <param name="consentState">상태</param>
  686. /// <param name="mainDrId">주치의 아이디</param>
  687. /// <param name="userDeptCd">사용자 부서 코드</param>
  688. /// <param name="pageCnt">동의서 매수</param>
  689. /// <param name="actKind">동작코드(T: 임시 저장, C: 인증 저장, P: 출력, CP: 삭제)</param>
  690. /// <param name="clientType">Client구분 (P: PC, M: 모바일)</param>
  691. /// <param name="fileSize">이미지 파일 사이즈</param>
  692. [WebMethod(Description = "동의서 서명 완료")]
  693. public SingleReturnData SaveCompleteAll(string userId, string patientCode, string clnDeptCode, int formRid, string formCd,
  694. int consentMstRid, int rewriteConsentMstRid, string formXml, string dataXml,
  695. string deviceType, string deviceIdentNo, string vistType, string hosType, string clnDate,
  696. string ward, string roomCd, int orderNo, string orderName, string orderCd, string ocrCode, int cretNo,
  697. string createUserName, string modifyUserName, string imageFileJson, string certTarget, string certResult,
  698. string dschDd, string consentState, string mainDrId,
  699. string userDeptCd, string pageCnt, string actKind, string clientType, string opRsrvNo, string fileSize) {
  700. SingleReturnData result = new SingleReturnData();
  701. //string paramLog = "";
  702. //paramLog += "clnDept[" + userId + "]patientCode[" + patientCode + "]clnDeptCode[" + clnDeptCode + "]formRid[" + formRid + "]";
  703. //paramLog += "formCd[" + formCd + "]consentMstRid[" + consentMstRid + "]rewriteConsentMstRid[" + rewriteConsentMstRid + "]";
  704. //paramLog += "deviceType[" + deviceType + "]vistType[" + vistType + "]hosType[" + hosType + "]";
  705. //paramLog += "clnDate[" + clnDate + "]ward[" + ward + "]roomcd[" + roomCd + "]orderNo[" + orderNo + "]";
  706. //paramLog += "orderName[" + orderName + "]orderCd[" + orderCd + "]ocrCode[" + ocrCode + "]cretno[" + cretNo + "]";
  707. //paramLog += "createUserName[" + createUserName + "]modifyUserName[" + modifyUserName + "]imageFileJson[" + imageFileJson + "]certTarget[" + certTarget + "]";
  708. //paramLog += "dschdd[" + dschDd + "]consentState[" + consentState + "]mainDrId[" + mainDrId + "]";
  709. //paramLog += "dataXml[" + dataXml + "]formXml[" + formXml + "]certResult[" + certResult + "]" + "fileSize[" + fileSize + "]";
  710. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("CLIP.eForm SaveCompleteAll param : " + paramLog);
  711. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("json : " + imageFileJson);
  712. int reissueConsentMstRid = 0;
  713. string paperYn = "N";
  714. string reasonForUseN = string.Empty;
  715. rewriteConsentMstRid = 0;
  716. consentMstRid = SaveDataAll(userId, patientCode, clnDeptCode, formRid, formCd,
  717. consentMstRid, rewriteConsentMstRid, reissueConsentMstRid, consentState, paperYn, formXml, dataXml,
  718. deviceType, deviceIdentNo, vistType, hosType, clnDate,
  719. ward, roomCd, reasonForUseN, orderNo, orderName, orderCd, ocrCode, cretNo,
  720. createUserName, modifyUserName, imageFileJson, certTarget, certResult, dschDd, mainDrId,
  721. userDeptCd, pageCnt, actKind, clientType, opRsrvNo, fileSize);
  722. result.responseData = Convert.ToString(consentMstRid);
  723. return result;
  724. }
  725. /// <summary>
  726. /// 동의서 삭제/폐기 데이터를 저장 한다.
  727. /// </summary>
  728. /// <param name="userId">로그인 사용자ID</param>
  729. /// <param name="consentMstRidInt">The consent MST rid int.</param>
  730. /// <param name="patientCode">환자 등록번호</param>
  731. /// <param name="clnDeptCode">진료과 코드</param>
  732. /// <param name="ward">병동 코드</param>
  733. /// <param name="roomcd">The roomcd.</param>
  734. /// <param name="formRid">(작성대상)서식 Rid</param>
  735. /// <param name="formCd">서식 코드</param>
  736. /// <param name="rewriteConsentMstRid">재 작성 대상 동의서 마스터 데이터 Rid</param>
  737. /// <param name="reissueConsentMstRid">삭제/폐기 대상 동의서 마스터 데이터 Rid</param>
  738. /// <param name="consentState">동의서 상태</param>
  739. /// <param name="deviceIdentNo">장비 고유 식별자</param>
  740. /// <param name="vistType">진료 형태</param>
  741. /// <param name="hosType">기관 코드</param>
  742. /// <param name="clnDate">진료일</param>
  743. /// <param name="reasonForUseN">삭제/폐기 사유</param>
  744. /// <param name="ocrCode">OCR Tag</param>
  745. /// <param name="cretno">생성번호</param>
  746. /// <param name="userDeptCd">사용자 부서 코드</param>
  747. /// <param name="pageCnt">동의서 매수</param>
  748. /// <param name="actKind">동작코드(T: 임시 저장, C: 인증 저장, P: 출력, CP: 삭제)</param>
  749. /// <param name="clientType">Client구분 (P: PC, M: 모바일)</param>
  750. /// <returns></returns>
  751. [WebMethod(Description = "동의서 삭제/폐기 데이터를 저장")]
  752. public SingleReturnData SaveDelete(string userId, int consentMstRid, string patientCode, string clnDeptCode, string formCd,
  753. string vistType, string hosType, string clnDate, string reasonForUseN,
  754. string ocrCode, int cretno, string userDeptCd, string pageCnt, string actKind, string clientType) {
  755. SingleReturnData result = new SingleReturnData();
  756. if (this.IbatisSession.IsTransactionStart == false) {
  757. this.IbatisSession.BeginTransaction();
  758. }
  759. try {
  760. using (SaveConsentDac dac = new SaveConsentDac()) {
  761. Hashtable param = new Hashtable();
  762. param.Add("userId", userId);
  763. param.Add("reasonForUseN", reasonForUseN);
  764. param.Add("consentMstRid", consentMstRid);
  765. param.Add("ocrTag", ocrCode);
  766. int resultInt = dac.UpdateConsentMstForDelete(this.IbatisMapper, param);
  767. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Warn("Update resultInt -- > " + resultInt);
  768. if (resultInt > 0) {
  769. resultInt = dac.DeleteChartpageT(this.IbatisMapper, param);
  770. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Warn("Delete resultInt -- > " + resultInt);
  771. Hashtable ocrParam = new Hashtable {
  772. { "instcd", hosType },
  773. { "ocrtag", ocrCode },
  774. { "pid", patientCode },
  775. { "ordtype", vistType },
  776. { "orddd", clnDate },
  777. { "cretno", cretno },
  778. { "orddrid", null },
  779. { "orddeptcd", clnDeptCode },
  780. { "formcd", formCd },
  781. { "fstprntdeptcd", userDeptCd },
  782. { "fstprntid", userId },
  783. { "updtdeptcd", userDeptCd },
  784. { "updtuserid", userId },
  785. { "updtdt", DateTime.Now.ToString("yyyyMMddHHmmss")},
  786. { "pagecnt", pageCnt },
  787. { "updtresncnts", reasonForUseN },
  788. { "actkind", actKind },
  789. { "clienttype", clientType },
  790. { "endYn", "N" }
  791. };
  792. dac.InsertPrintData(this.IbatisMapper, ocrParam);
  793. } else {
  794. if (this.IbatisSession != null) this.IbatisSession.RollBackTransaction();
  795. consentMstRid = -1;
  796. }
  797. }
  798. } catch (Exception ex) {
  799. if (this.IbatisSession != null) this.IbatisSession.RollBackTransaction();
  800. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm SaveDelete ERROR : [{0}]", ex.ToString()));
  801. consentMstRid = -1;
  802. }
  803. result.responseData = Convert.ToString(consentMstRid);
  804. return result;
  805. }
  806. public List<ConsentVO> GetConsentData(string patientCode, int consentMstRid, string startDt, string endDt, string dutinstcd
  807. , string userId) {
  808. List<ConsentVO> result;
  809. try {
  810. using (ConsentDac dac = new ConsentDac()) {
  811. Hashtable param = new Hashtable {
  812. { "patientCode", patientCode },
  813. { "consentMstRid", consentMstRid },
  814. { "startDt", startDt },
  815. { "endDt", endDt },
  816. { "consentState", "'UNFINISHED', 'TEMP'" },
  817. { "instcd", dutinstcd },
  818. { "userId", userId ?? string.Empty}
  819. };
  820. result = (List<ConsentVO>) dac.GetConsentList(this.IbatisMapper, param);
  821. }
  822. return result;
  823. } catch (Exception ex) {
  824. System.Diagnostics.Trace.WriteLine(string.Format("CLIP.eForm GetConsentList error: {0}", ex.Message));
  825. throw ex;
  826. }
  827. }
  828. /// <summary>
  829. /// 프린트 출력 후 데이터를 저장 한다.
  830. /// </summary>
  831. /// <param name="userId">로그인 사용자ID</param>
  832. /// <param name="patientCode">환자 등록번호</param>
  833. /// <param name="clnDeptCode">진료과 코드</param>
  834. /// <param name="formRid">(작성대상)서식 Rid</param>
  835. /// <param name="formCd">서식코드</param>
  836. /// <param name="consentMstRid">동의서 마스터 데이터 Rid</param>
  837. /// <param name="reissueConsentMstRid">The reissue consent MST rid.</param>
  838. /// <param name="formXml">동의서 EPT Xml</param>
  839. /// <param name="dataXml">동의서 Data(필드들) Xml</param>
  840. /// <param name="deviceType">장비 유형 (WIN, AND, IOS, PRT 중1)</param>
  841. /// <param name="deviceIdentNo">장비 고유 식별자</param>
  842. /// <param name="vistType">내원구분</param>
  843. /// <param name="hosType">병원 구분</param>
  844. /// <param name="clnDate">병원 구분이 "I" 일 경우 입원일자/병원 구분이 "O"일 경우 진료일자</param>
  845. /// <param name="ward">병동 코드</param>
  846. /// <param name="roomcd">병실 코드</param>
  847. /// <param name="orderNo">처방번호</param>
  848. /// <param name="orderName">처방명</param>
  849. /// <param name="orderCd">처방코드</param>
  850. /// <param name="ocrCode">OCR코드</param>
  851. /// <param name="cretno">생성번호</param>
  852. /// <param name="createUserName">작성자명</param>
  853. /// <param name="modifyUserName">수정자명</param>
  854. /// <param name="mainDrId">주치의 아이디</param>
  855. /// <param name="userDeptCd">사용자 부서 코드</param>
  856. /// <param name="pageCnt">출력 매수</param>
  857. /// <param name="actKind">동작 방법</param>
  858. /// <param name="clientType">Client 타입</param>
  859. /// <param name="opRsrvNo">수술예약번호</param>
  860. /// <returns></returns>
  861. [WebMethod(Description = "동의서 프린트 출력 후 데이터를 저장")]
  862. public int SavePrintOut(string userId, string patientCode, string clnDeptCode, int formRid, string formCd,
  863. int consentMstRid, int reissueConsentMstRid, string formXml, string dataXml,
  864. string deviceType, string deviceIdentNo, string vistType, string hosType, string clnDate,
  865. string ward, string roomcd, int orderNo, string orderName, string orderCd, string ocrCode, int cretno,
  866. string createUserName, string modifyUserName, string mainDrId,
  867. string userDeptCd, string pageCnt, string actKind, string clientType, string opRsrvNo) {
  868. string consentState = "PAPER_OUT";
  869. string paperYn = "Y";
  870. consentMstRid = SavePrintData(userId, patientCode, clnDeptCode, formRid, formCd,
  871. consentMstRid, 0, reissueConsentMstRid, consentState, paperYn, formXml, dataXml,
  872. deviceType, deviceIdentNo, vistType, hosType, clnDate,
  873. ward, roomcd, null, orderNo, orderName, orderCd, ocrCode, cretno,
  874. createUserName, modifyUserName, null, null, null, mainDrId,
  875. userDeptCd, pageCnt, actKind, clientType, opRsrvNo);
  876. return consentMstRid;
  877. }
  878. /// <summary>
  879. /// 동의서의 기왕력 데이터 저장
  880. /// </summary>
  881. /// <param name="patientCode">환자 등록번호</param>
  882. /// <param name="clnDate">진료일</param>
  883. /// <param name="bp">고/저혈압</param>
  884. /// <param name="dm">당뇨병</param>
  885. /// <param name="heart">심장질환</param>
  886. /// <param name="kidney">신장질환</param>
  887. /// <param name="respiration">호흡기질환</param>
  888. /// <param name="hx">과거병력</param>
  889. /// <param name="allergy">알레르기</param>
  890. /// <param name="drug">복용약물</param>
  891. /// <param name="smoking">흡연상태</param>
  892. /// <param name="idio">특이체질</param>
  893. /// <param name="nacrotics">마약사고</param>
  894. /// <param name="airway">기도이상 유무</param>
  895. /// <param name="hemorrhage">출혈소인</param>
  896. /// <param name="status_etc">기타</param>
  897. /// <param name="userId">로그인 사용자ID</param>
  898. /// <returns></returns>
  899. [WebMethod(Description = "동의서의 기왕력 데이터 저장")]
  900. public string SaveMedicalHistory(string patientCode, string clnDate,
  901. string bp, string dm, string heart, string kidney, string respiration,
  902. string hx, string allergy, string drug, string smoking,
  903. string idio, string nacrotics, string airway, string hemorrhage, string status_etc,
  904. string userId) {
  905. try {
  906. using (SaveConsentDac dac = new SaveConsentDac()) {
  907. Hashtable paramHashTable = new Hashtable();
  908. paramHashTable.Add("patientCode", patientCode);
  909. paramHashTable.Add("clnDate", clnDate);
  910. paramHashTable.Add("bp", bp);
  911. paramHashTable.Add("dm", dm);
  912. paramHashTable.Add("heart", heart);
  913. paramHashTable.Add("kidney", kidney);
  914. paramHashTable.Add("respiration", respiration);
  915. paramHashTable.Add("hx", hx);
  916. paramHashTable.Add("allergy", allergy);
  917. paramHashTable.Add("drug", drug);
  918. paramHashTable.Add("smoking", smoking);
  919. paramHashTable.Add("idio", idio);
  920. paramHashTable.Add("nacrotics", nacrotics);
  921. paramHashTable.Add("airway", airway);
  922. paramHashTable.Add("hemorrhage", hemorrhage);
  923. paramHashTable.Add("status_etc", status_etc);
  924. paramHashTable.Add("userId", userId);
  925. dac.SetMediHistory(this.IbatisMapper, paramHashTable);
  926. }
  927. } catch (Exception ex) {
  928. if (this.IbatisSession != null) this.IbatisSession.RollBackTransaction();
  929. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm SaveMedicalHistory ERROR : [{0}]", ex.ToString()));
  930. throw ex;
  931. } finally {
  932. }
  933. return patientCode;
  934. }
  935. /// <summary>
  936. /// 동의서 서명 완료일 경우 이미지 데이터 저장
  937. /// </summary>
  938. /// <param name="consentState">동의서 상태</param>
  939. /// <param name="imageFileName">이미지파일명(경로포함)</param>
  940. /// <param name="consentMstRid">동의서 마스터 데이터 Rid</param>
  941. /// <param name="userId">등록자ID</param>
  942. /// <param name="formRid">동의서 FORM ID</param>
  943. /// <returns>저장된 consent image rid</returns>
  944. [WebMethod(Description = "동의서 서명 완료일 경우 이미지 데이터 저장")]
  945. public int SaveImageUploadInfo(string consentState, string imageFileName, int consentMstRid, string userId, int formRid) {
  946. int consentImageRid = 0;
  947. if (!string.IsNullOrEmpty(consentState) && consentState == "ELECTR_CMP") {
  948. using (SaveConsentDac dac = new SaveConsentDac()) {
  949. Hashtable imageHashTable = new Hashtable();
  950. imageHashTable.Add("consentMstRid", consentMstRid);
  951. consentImageRid = this.GetSequence("CONSENT_IMAGE");
  952. imageHashTable.Add("consentImageRid", consentImageRid);
  953. imageHashTable.Add("userId", userId);
  954. imageHashTable.Add("formRid", formRid);
  955. imageHashTable.Add("imagePath", imageFileName.Substring(0, imageFileName.LastIndexOf("\\")));
  956. imageHashTable.Add("imageFilename", imageFileName.Substring(imageFileName.LastIndexOf("\\") + 1));
  957. imageHashTable.Add("completeYn", "Y"); //paramHashTable["completeYn"]
  958. dac.InsertConsentImage(this.IbatisMapper, imageHashTable);
  959. }
  960. }
  961. return consentImageRid;
  962. }
  963. /// <summary>
  964. /// 서명완료된 이미지의 hash 정보 저장
  965. /// </summary>
  966. /// <param name="consentState">동의서 상태</param>
  967. /// <param name="consentMstRid">동의서 마스터 데이터 Rid</param>
  968. /// <param name="consentImageRid">이미지 데이터 Rid</param>
  969. /// <param name="userId">등록자ID</param>
  970. /// <param name="certTarget">hash 정보</param>
  971. /// <param name="sCertResult">공인인증서명 결과</param>
  972. [WebMethod(Description = "서명완료된 이미지의 hash 정보 저장")]
  973. public void SaveImageSignInfo(string consentState, int consentMstRid, int consentImageRid, string userId, string certTarget, string sCertResult) {
  974. string paramLog = "";
  975. paramLog += "consentState[" + consentState + "]consentMstRid[" + consentMstRid + "]consentImageRid[" + consentImageRid + "]userId[" + userId + "]";
  976. paramLog += "certTarget[" + certTarget + "]sCertResult[" + sCertResult + "]";
  977. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("CLIP.eForm SaveTempData param : " + paramLog);
  978. if (!string.IsNullOrEmpty(consentState) && consentState == "ELECTR_CMP") {
  979. using (SaveConsentDac dac = new SaveConsentDac()) {
  980. Hashtable imageHashTable = new Hashtable();
  981. imageHashTable.Add("consentMstRid", consentMstRid);
  982. imageHashTable.Add("consentImageRid", consentImageRid);
  983. imageHashTable.Add("certTarget", certTarget);
  984. imageHashTable.Add("certResult", sCertResult);
  985. imageHashTable.Add("userId", userId);
  986. dac.InsertConsentImageSign(this.IbatisMapper, imageHashTable);
  987. imageHashTable.Add("consentState", "CERTIFY_CMP");
  988. dac.UpdateConsentMstStatus(this.IbatisMapper, imageHashTable);
  989. }
  990. }
  991. }
  992. /// <summary>
  993. /// Saves the data.
  994. /// </summary>
  995. /// <param name="userId">The user identifier.</param>
  996. /// <param name="patientCode">The patient code.</param>
  997. /// <param name="clnDeptCode">The CLN dept code.</param>
  998. /// <param name="formRid">The form rid.</param>
  999. /// <param name="formCd">The form cd.</param>
  1000. /// <param name="consentMstRid">The consent MST rid.</param>
  1001. /// <param name="rewriteConsentMstRid">The rewrite consent MST rid.</param>
  1002. /// <param name="reissueConsentMstRid">The reissue consent MST rid.</param>
  1003. /// <param name="consentState">State of the consent.</param>
  1004. /// <param name="paperYn">The paper yn.</param>
  1005. /// <param name="formXml">The form XML.</param>
  1006. /// <param name="dataXml">The data XML.</param>
  1007. /// <param name="deviceType">Type of the device.</param>
  1008. /// <param name="deviceIdentNo">The device ident no.</param>
  1009. /// <param name="vistType">Type of the vist.</param>
  1010. /// <param name="hosType">Type of the hos.</param>
  1011. /// <param name="clnDate">The CLN date.</param>
  1012. /// <param name="ward">The ward.</param>
  1013. /// <param name="roomcd">The roomcd.</param>
  1014. /// <param name="reasonForUseN">The reason for use n.</param>
  1015. /// <param name="orderNo">The order no.</param>
  1016. /// <param name="orderName">Name of the order.</param>
  1017. /// <param name="orderCd">The order cd.</param>
  1018. /// <param name="ocrCode">The ocr code.</param>
  1019. /// <param name="cretno">The cretno.</param>
  1020. /// <param name="createUserName">Name of the create user.</param>
  1021. /// <param name="modifyUserName">Name of the modify user.</param>
  1022. /// <param name="imageFileName">Name of the image file.</param>
  1023. /// <param name="certTarget">The cert target.</param>
  1024. /// <param name="certResult">The cert result.</param>
  1025. /// <param name="mainDrId">The main dr identifier.</param>
  1026. /// <param name="userDeptCd">The user dept cd.</param>
  1027. /// <param name="pageCnt">The page count.</param>
  1028. /// <param name="actKind">Kind of the act.</param>
  1029. /// <param name="clientType">Type of the client.</param>
  1030. /// <param name="opRsrvNo">The op RSRV no.</param>
  1031. /// <returns></returns>
  1032. private int SaveData(string userId, string patientCode, string clnDeptCode, int formRid, string formCd,
  1033. int consentMstRid, int rewriteConsentMstRid, int reissueConsentMstRid, string consentState, string paperYn, string formXml, string dataXml,
  1034. string deviceType, string deviceIdentNo, string vistType, string hosType, string clnDate,
  1035. string ward, string roomcd, string reasonForUseN, int orderNo, string orderName, string orderCd, string ocrCode, int cretno,
  1036. string createUserName, string modifyUserName, string imageFileName, string certTarget, string certResult,
  1037. string mainDrId, string userDeptCd, string pageCnt, string actKind, string clientType, string opRsrvNo) {
  1038. bool isNewConsentMasterCase = false;
  1039. if (consentMstRid < 1) {
  1040. isNewConsentMasterCase = true;
  1041. }
  1042. try {
  1043. using (SaveConsentDac dac = new SaveConsentDac()) {
  1044. Hashtable paramHashTable = GetParamHashTable(userId, patientCode, clnDeptCode, formRid, formCd, consentMstRid, rewriteConsentMstRid,
  1045. reissueConsentMstRid, consentState, paperYn, formXml, dataXml, deviceType, deviceIdentNo,
  1046. vistType, hosType, clnDate, ward, roomcd, reasonForUseN,
  1047. orderNo, orderName, orderCd, ocrCode, cretno, createUserName, modifyUserName,
  1048. certTarget, certResult, mainDrId, opRsrvNo);
  1049. consentMstRid = (int) paramHashTable["consentMstRid"];
  1050. String endYn = "N";
  1051. if (consentState.Equals("TEMP")) {
  1052. endYn = "N";
  1053. }
  1054. //새로 작성하는 경우
  1055. if (isNewConsentMasterCase) {
  1056. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("");
  1057. dac.InsertConsentMst(this.IbatisMapper, paramHashTable);
  1058. dac.InsertConsentData(this.IbatisMapper, paramHashTable);
  1059. } else { //새로 작성 아닌 경우
  1060. if (reissueConsentMstRid > 0) {
  1061. if (string.IsNullOrEmpty(reasonForUseN)) {
  1062. //종이->종이 재발행
  1063. int newConsentMstRid = this.GetSequence("CONSENT_MST");
  1064. paramHashTable["consentMstRid"] = newConsentMstRid;
  1065. consentMstRid = newConsentMstRid;
  1066. dac.InsertConsentMst(this.IbatisMapper, paramHashTable);
  1067. dac.InsertConsentData(this.IbatisMapper, paramHashTable);
  1068. } else { // 삭제
  1069. dac.UpdateConsentMstForDelete(this.IbatisMapper, paramHashTable);
  1070. }
  1071. } else { //임시저장 또는 저장인 경우
  1072. dac.UpdateConsentMst(this.IbatisMapper, paramHashTable);
  1073. dac.InsertConsentData(this.IbatisMapper, paramHashTable);
  1074. }
  1075. }
  1076. // OCR 테이블 연계
  1077. Hashtable ocrParam = new Hashtable {
  1078. { "instcd", hosType },
  1079. { "ocrtag", ocrCode },
  1080. { "pid", patientCode },
  1081. { "ordtype", vistType },
  1082. { "orddd", clnDate },
  1083. { "cretno", cretno },
  1084. { "orddrid", mainDrId },
  1085. { "orddeptcd", clnDeptCode },
  1086. { "formcd", formCd },
  1087. { "fstprntdeptcd", userDeptCd },
  1088. { "fstprntid", userId },
  1089. { "updtdeptcd", userDeptCd },
  1090. { "updtuserid", userId },
  1091. { "updtdt", DateTime.Now.ToString("yyyyMMddHHmmss")},
  1092. { "pagecnt", pageCnt },
  1093. { "updtresncnts", reasonForUseN },
  1094. { "actkind", actKind },
  1095. { "clienttype", clientType },
  1096. { "endYn", endYn }
  1097. };
  1098. dac.InsertPrintData(this.IbatisMapper, ocrParam);
  1099. // 사용 안함
  1100. /*
  1101. if (!string.IsNullOrEmpty(dataXml)) {
  1102. Dictionary<string, string> outputDataDic = DataXmlToDictionary(dataXml);
  1103. Hashtable paramHashTableForMediHistory = new Hashtable();
  1104. paramHashTableForMediHistory.Add("patientCode", patientCode);
  1105. paramHashTableForMediHistory.Add("clnDate", clnDate.Replace("-", ""));
  1106. paramHashTableForMediHistory.Add("bp", outputDataDic.ContainsKey("IO_bp") ? outputDataDic["IO_bp"] : "");
  1107. paramHashTableForMediHistory.Add("dm", outputDataDic.ContainsKey("IO_dm") ? outputDataDic["IO_dm"] : "");
  1108. paramHashTableForMediHistory.Add("heart", outputDataDic.ContainsKey("IO_heart") ? outputDataDic["IO_heart"] : "");
  1109. paramHashTableForMediHistory.Add("kidney", outputDataDic.ContainsKey("IO_kidney") ? outputDataDic["IO_kidney"] : "");
  1110. paramHashTableForMediHistory.Add("respiration", outputDataDic.ContainsKey("IO_respiration") ? outputDataDic["IO_respiration"] : "");
  1111. paramHashTableForMediHistory.Add("hx", outputDataDic.ContainsKey("IO_hx") ? outputDataDic["IO_hx"] : "");
  1112. paramHashTableForMediHistory.Add("allergy", outputDataDic.ContainsKey("IO_allergy") ? outputDataDic["IO_allergy"] : "");
  1113. paramHashTableForMediHistory.Add("drug", outputDataDic.ContainsKey("IO_drug") ? outputDataDic["IO_drug"] : "");
  1114. paramHashTableForMediHistory.Add("smoking", outputDataDic.ContainsKey("IO_smoking") ? outputDataDic["IO_smoking"] : "");
  1115. paramHashTableForMediHistory.Add("idio", outputDataDic.ContainsKey("IO_idio") ? outputDataDic["IO_idio"] : "");
  1116. paramHashTableForMediHistory.Add("nacrotics", outputDataDic.ContainsKey("IO_nacrotics") ? outputDataDic["IO_nacrotics"] : "");
  1117. paramHashTableForMediHistory.Add("airway", outputDataDic.ContainsKey("IO_airway") ? outputDataDic["IO_airway"] : "");
  1118. paramHashTableForMediHistory.Add("hemorrhage", outputDataDic.ContainsKey("IO_hemorrhage") ? outputDataDic["IO_hemorrhage"] : "");
  1119. paramHashTableForMediHistory.Add("status_etc", outputDataDic.ContainsKey("IO_status_etc") ? outputDataDic["IO_status_etc"] : "");
  1120. paramHashTableForMediHistory.Add("userId", userId);
  1121. dac.SetMediHistory(this.IbatisMapper, paramHashTableForMediHistory);
  1122. }
  1123. */
  1124. }
  1125. } catch (Exception ex) {
  1126. if (this.IbatisSession != null) this.IbatisSession.RollBackTransaction();
  1127. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm SaveData ERROR : [{0}]", ex.ToString()));
  1128. return -1;
  1129. throw ex;
  1130. } finally {
  1131. }
  1132. return consentMstRid;
  1133. }
  1134. private int SaveDataAll(string userId, string patientCode, string clnDeptCode, int formRid, string formCd,
  1135. int consentMstRid, int rewriteConsentMstRid, int reissueConsentMstRid, string consentState, string paperYn, string formXml, string dataXml,
  1136. string deviceType, string deviceIdentNo, string vistType, string hosType, string clnDate,
  1137. string ward, string roomcd, string reasonForUseN, int orderNo, string orderName, string orderCd, string ocrCode, int cretno,
  1138. string createUserName, string modifyUserName, string imageFileJson, string certTarget,
  1139. string certResult, string dschdd, string mainDrId,
  1140. string userDeptCd, string pageCnt, string actKind, string clientType, string opRsrvNo, string fileSize) {
  1141. string endYn = "";
  1142. bool isNewConsentMasterCase = false;
  1143. if (consentMstRid < 1) {
  1144. isNewConsentMasterCase = true;
  1145. }
  1146. // CERTIFY_CMP 인증저장, ELECTR_CMP 확인저장
  1147. if (consentState.Equals("CERTIFY_CMP")) {
  1148. endYn = "Y";
  1149. } else if (consentState.Equals("ELECTR_CMP")) {
  1150. endYn = "C";
  1151. }
  1152. try {
  1153. using (SaveConsentDac dac = new SaveConsentDac()) {
  1154. Hashtable paramHashTable = GetParamHashTable(userId, patientCode, clnDeptCode, formRid, formCd, consentMstRid, rewriteConsentMstRid,
  1155. reissueConsentMstRid, consentState, paperYn, formXml, dataXml, deviceType, deviceIdentNo,
  1156. vistType, hosType, clnDate, ward, roomcd, reasonForUseN,
  1157. orderNo, orderName, orderCd, ocrCode, cretno, createUserName, modifyUserName,
  1158. certTarget, certResult, mainDrId, opRsrvNo);
  1159. consentMstRid = (int) paramHashTable["consentMstRid"];
  1160. //새로 작성하는 경우
  1161. if (isNewConsentMasterCase) {
  1162. dac.InsertConsentMst(this.IbatisMapper, paramHashTable);
  1163. dac.InsertConsentData(this.IbatisMapper, paramHashTable);
  1164. // TODO 이미지 저장 루틴 확인 및 적용 필요
  1165. //imageUpload(dac, paramHashTable, userId
  1166. // , patientCode, vistType, clnDate, dschdd, cretno, ocrCode
  1167. // , consentMstRid, consentState, formCd, formRid, dataXml
  1168. // , imageFileJson, certTarget, certResult, hosType, createUserName, hosType, fileSize);
  1169. }
  1170. //새로 작성 아닌 경우
  1171. else {
  1172. if (reissueConsentMstRid > 0) {
  1173. if (string.IsNullOrEmpty(reasonForUseN)) {
  1174. //종이->종이 재발행
  1175. int newConsentMstRid = this.GetSequence("CONSENT_MST");
  1176. paramHashTable["consentMstRid"] = newConsentMstRid;
  1177. consentMstRid = newConsentMstRid;
  1178. dac.InsertConsentMst(this.IbatisMapper, paramHashTable);
  1179. dac.InsertConsentData(this.IbatisMapper, paramHashTable);
  1180. // TODO 이미지 저장 루틴 확인 및 적용 필요
  1181. //imageUpload(dac, paramHashTable, userId
  1182. // , patientCode, vistType, clnDate, dschdd, cretno, ocrCode
  1183. // , consentMstRid, consentState, formCd, formRid, dataXml,
  1184. // imageFileJson, certTarget, certResult, hosType, createUserName, hosType, fileSize);
  1185. }
  1186. else {
  1187. dac.UpdateConsentMstForDelete(this.IbatisMapper, paramHashTable);
  1188. }
  1189. }
  1190. //임시저장 또는 저장인 경우
  1191. else {
  1192. Hashtable param = new Hashtable();
  1193. param.Add("consentMstRid", consentMstRid);
  1194. int imageCount = dac.GetConsentImageCount(this.IbatisMapper, param);
  1195. if (imageCount == 0) {
  1196. // TODO 이미지 저장 루틴 확인 및 적용 필요
  1197. //imageUpload(dac, paramHashTable, userId
  1198. // , patientCode, vistType, clnDate, dschdd, cretno, ocrCode
  1199. // , consentMstRid, consentState, formCd, formRid, dataXml
  1200. // , imageFileJson, certTarget, certResult, hosType, createUserName, hosType, fileSize);
  1201. }
  1202. dac.UpdateConsentMst(this.IbatisMapper, paramHashTable);
  1203. dac.InsertConsentData(this.IbatisMapper, paramHashTable);
  1204. if (imageCount > 0) {
  1205. // TODO 이미지 저장 루틴 확인 및 적용 필요
  1206. //confirmSaveImageCover(consentMstRid, userId, ocrCode, imageFileJson, consentState);
  1207. }
  1208. }
  1209. }
  1210. // OCR 테이블 연계
  1211. Hashtable ocrParam = new Hashtable {
  1212. { "instcd", hosType },
  1213. { "ocrtag", ocrCode },
  1214. { "pid", patientCode },
  1215. { "ordtype", vistType },
  1216. { "orddd", clnDate },
  1217. { "cretno", cretno },
  1218. { "orddrid", mainDrId },
  1219. { "orddeptcd", clnDeptCode },
  1220. { "formcd", formCd },
  1221. { "fstprntdeptcd", userDeptCd },
  1222. { "fstprntid", userId },
  1223. { "updtdeptcd", userDeptCd },
  1224. { "updtuserid", userId },
  1225. { "updtdt", DateTime.Now.ToString("yyyyMMddHHmmss")},
  1226. { "pagecnt", pageCnt },
  1227. { "updtresncnts", reasonForUseN },
  1228. { "actkind", actKind },
  1229. { "clienttype", clientType },
  1230. { "endYn", endYn }
  1231. };
  1232. dac.InsertPrintData(this.IbatisMapper, ocrParam);
  1233. if (consentState.Equals("CERTIFY_CMP")) {
  1234. // 원무 동의서 연동 지금은 사용하지 않음
  1235. // TODO 원무 동의서 연동 여부
  1236. //SavePatientConsentInfo(formCd, patientCode, ocrCode, hosType, clnDate, cretno.ToString(), vistType, clnDeptCode, mainDrId, userId, dataXml);
  1237. }
  1238. }
  1239. } catch (Exception ex) {
  1240. if (this.IbatisSession != null) this.IbatisSession.RollBackTransaction();
  1241. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm SaveDataAll ERROR : [{0}]", ex.ToString()));
  1242. return -1;
  1243. throw ex;
  1244. } finally {
  1245. }
  1246. return consentMstRid;
  1247. }
  1248. private void imageUpload(SaveConsentDac dac, Hashtable paramHashTable, string userId, string patientCode, string visitType, string clnDate,
  1249. string Dschdd, int cretno, string ocrcode, int consentMstRid, string consentState, string formCd, int formRid,
  1250. string dataXml, string imageFileJson, string certTarget, string certResult, string hosType, string createUserName,
  1251. string dutinstcd, string fileSize) {
  1252. // 서명 저장일 경우 emrindxm 테이블에 저장
  1253. if (!string.IsNullOrEmpty(consentState) && (consentState.Equals("ELECTR_CMP") || consentState.Equals("CERTIFY_CMP"))) {
  1254. string clnDeptCode = paramHashTable["clnDeptCd"] == null ? string.Empty : paramHashTable["clnDeptCd"].ToString();
  1255. string[] fileSizeAr = fileSize.Split(new char[] { ',' });
  1256. try {
  1257. int consentImageRid = this.GetSequence("CONSENT_IMAGE");
  1258. int firstImageRid = consentImageRid;
  1259. string sPath = string.Empty;
  1260. string sFileName = string.Empty;
  1261. string newFileFullName = string.Empty;
  1262. if (!string.IsNullOrEmpty(imageFileJson)) {
  1263. Dictionary<string, object> jsonRoot = null;
  1264. jsonRoot = fastJSON.JSON.Parse(imageFileJson) as Dictionary<string, object>;
  1265. if (jsonRoot != null && jsonRoot.Count > 0) {
  1266. Hashtable imageHashTable = new Hashtable();
  1267. int nowCnt = 1;
  1268. int fileSizeCnt = 0;
  1269. foreach (KeyValuePair<string, object> jr in jsonRoot) {
  1270. imageHashTable = new Hashtable();
  1271. imageHashTable.Add("consentMstRid", consentMstRid);
  1272. if (nowCnt > 1) consentImageRid = this.GetSequence("CONSENT_IMAGE");
  1273. imageHashTable.Add("consentImageRid", consentImageRid);
  1274. imageHashTable.Add("userId", userId);
  1275. imageHashTable.Add("formRid", formRid);
  1276. if (jr.Value != null && !string.IsNullOrEmpty(jr.Value.ToString())) {
  1277. sPath = "";
  1278. sFileName = "";
  1279. string[] filepath = jr.Value.ToString().Split('/');
  1280. for (int i = 0; i < filepath.Length; i++) {
  1281. if (i == 0) {
  1282. sPath = filepath[i];
  1283. } else if ((i + 1) == filepath.Length) {
  1284. sFileName = filepath[i];
  1285. } else {
  1286. sPath += "/" + filepath[i];
  1287. }
  1288. }
  1289. newFileFullName = string.Empty;
  1290. using (HospitalSvc hospitalWebService = new HospitalSvc()) {
  1291. //newFileFullName = hospitalWebService.GetFileName(patientCode, visitType,
  1292. // clnDate.Replace("-", ""), Dschdd, string.Format("{0}", cretno),
  1293. // "500", formCd, nowCnt.ToString(),
  1294. // ocrcode, userId, clnDeptCode, dutinstcd);
  1295. newFileFullName = hospitalWebService.GetFileName(patientCode, visitType,
  1296. clnDate.Replace("-", ""), Dschdd, string.Format("{0}", cretno),
  1297. fileSizeAr[fileSizeCnt], formCd, nowCnt.ToString(),
  1298. ocrcode, userId, clnDeptCode, dutinstcd);
  1299. fileSizeCnt++;
  1300. }
  1301. string uploadFileName = newFileFullName + ".jpg";
  1302. int idx = uploadFileName.LastIndexOf(".");
  1303. string sUploadPath = uploadFileName.Substring(idx - 4, 4);
  1304. string sUploadFileName = uploadFileName.Substring(uploadFileName.LastIndexOf("\\") + 1);
  1305. var remotePath = imageServerProps.remotePath;
  1306. //var destDrive = remotePath.Substring(0, 2);
  1307. var destDirectory = remotePath.Substring(2);
  1308. //remotePath = "Z:\\ACTIVE_ENC\\M\\TEST";
  1309. //destDirectory = "\\ACTIVE_ENC\\M\\TEST";
  1310. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("uploadFileName -- > " + uploadFileName);
  1311. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("sUploadPath -- > " + sUploadPath);
  1312. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("sUploadFileName -- > " + sUploadFileName);
  1313. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("remotePath -- > " + remotePath);
  1314. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("destDirectory -- > " + destDirectory);
  1315. var targetDrive = "";
  1316. var virtualDir = "";
  1317. // 경로를 확인하여 가상 디렉토리 경로를 설정한다
  1318. if (imageServerProps != null) {
  1319. targetDrive = imageServerProps.remotePath.Substring(0, 1);
  1320. switch (targetDrive) {
  1321. case "W":
  1322. virtualDir = "his032";
  1323. break;
  1324. case "Z":
  1325. virtualDir = "his031";
  1326. break;
  1327. }
  1328. }
  1329. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("targetDrive -- > " + targetDrive);
  1330. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("virtualDir -- > " + virtualDir);
  1331. // 계정을 choiadmin 으로 가장한다
  1332. ClipSoft.Utility.ImpersonationUtility util = new ClipSoft.Utility.ImpersonationUtility();
  1333. var imResult = util.ImpersonationStart(string.Empty, "choiadmin", "choiadmin");
  1334. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("Impersonation Start, " + imResult);
  1335. // IIS 가상 디렉토리 경로를 가져온다
  1336. DirectoryInfo di = new DirectoryInfo(Server.MapPath(virtualDir));
  1337. var destDirStr = String.Format(@"{0}\{1}\{2}",
  1338. di.ToString(),
  1339. remotePath.Substring(remotePath.IndexOf("ACTIVE_ENC") + @"ACTIVE_ENC\".Length),
  1340. sUploadPath);
  1341. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("destDirStr -- > " + destDirStr);
  1342. // for debug
  1343. //var destDirStr = String.Format(@"{0}\{1}\{2}\{3}\",
  1344. // di.ToString(),
  1345. // remotePath.Substring(remotePath.IndexOf("ACTIVE_ENC") + @"ACTIVE_ENC\".Length),
  1346. // "consentTest",
  1347. // sUploadPath);
  1348. DirectoryInfo destDi = new DirectoryInfo(destDirStr);
  1349. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("destDirStr: " + destDirStr + ", exists: " + destDi.Exists);
  1350. var destFullname = String.Format(@"{0}\{1}", destDirStr, sUploadFileName);
  1351. var localFile = Server.MapPath(string.Format(@"./UPLOAD/{0}/{1}", sPath, sFileName));
  1352. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("localFile -- > " + localFile);
  1353. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("destFullname -- > " + destFullname);
  1354. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("new DateTime() -- > " + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1355. if (!destDi.Exists) {
  1356. destDi.Create();
  1357. }
  1358. try {
  1359. File.Copy(localFile, destFullname);
  1360. } catch (Exception e) {
  1361. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(e);
  1362. File.Move(destFullname, destFullname.Insert(destFullname.LastIndexOf(".jpg"), "_" + imageHashTable["consentMstRid"] + "_" + DateTime.Now.ToString("yyyyMMddHHmmss")));
  1363. File.Copy(localFile, destFullname);
  1364. }
  1365. util.ImpersonationEnd();
  1366. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("Impersonation end");
  1367. imageHashTable.Add("imagePath", sUploadPath);
  1368. imageHashTable.Add("imageFilename", sUploadFileName);
  1369. imageHashTable.Add("completeYn", paramHashTable["completeYn"]);
  1370. dac.InsertConsentImage(this.IbatisMapper, imageHashTable);
  1371. }
  1372. nowCnt++;
  1373. } // end of foreach
  1374. }
  1375. }
  1376. paramHashTable.Add("consentImageRid", firstImageRid);
  1377. // TODO 원무 인증 저장 pass
  1378. // 원무 저장시 해당 정보 저장 or skip 확인 해 볼 것
  1379. // 사인정보 저장
  1380. dac.InsertConsentImageSign(this.IbatisMapper, paramHashTable);
  1381. } catch (Exception ex) {
  1382. using (HospitalSvc hospitalWebService = new HospitalSvc()) {
  1383. hospitalWebService.delEformData(patientCode, visitType,
  1384. clnDate.Replace("-", ""), Dschdd, string.Format("{0}", cretno),
  1385. formCd, ocrcode, userId, createUserName, string.Format("{0}", consentMstRid), hosType,
  1386. clnDeptCode, dutinstcd);
  1387. }
  1388. if (this.IbatisSession != null) this.IbatisSession.RollBackTransaction();
  1389. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm imageUpload ERROR : [{0}]", ex.ToString()));
  1390. throw ex;
  1391. }
  1392. }
  1393. }
  1394. /// <summary>
  1395. /// 확인저장 재 확인시 이미지 이름을 가져온다
  1396. /// 재 업로드하는 이미지를 가져온 이름으로 변경 후 기존의 이미지를 덮어쓴다
  1397. /// </summary>
  1398. /// <param name="pid">환자번호</param>
  1399. /// <param name="ocrTag">ocrTag</param>
  1400. /// <param name="pageNo">페이지 번호</param>
  1401. //[WebMethod(Description = "!@#")]
  1402. private string confirmSaveImageCover(int consentMstRidInt, string userId, string ocrCode, string imageFileJson, string consentState) {
  1403. List<ConsentImageVO> result;
  1404. string fileName = "";
  1405. try {
  1406. using (ConsentDac dac = new ConsentDac()) {
  1407. Dictionary<string, object> jsonRoot = fastJSON.JSON.Parse(imageFileJson) as Dictionary<string, object>;
  1408. Dictionary<string, string> pathDic = new Dictionary<string, string>();
  1409. List<String> sPath = new List<String>();
  1410. List<String> sFileName = new List<String>();
  1411. foreach (KeyValuePair<string, object> jr in jsonRoot) {
  1412. if (jr.Value != null && !string.IsNullOrEmpty(jr.Value.ToString())) {
  1413. //sPath = "";
  1414. //sFileName = "";
  1415. string[] filepath = jr.Value.ToString().Split('/');
  1416. sPath.Add(filepath[0] + "/" + filepath[1]);
  1417. sFileName.Add(filepath[2]);
  1418. }
  1419. }
  1420. Hashtable param = new Hashtable();
  1421. param.Add("consentMstRid", consentMstRidInt);
  1422. param.Add("userId", consentMstRidInt);
  1423. param.Add("ocrCode", ocrCode);
  1424. param.Add("consentState", consentState);
  1425. result = (List<ConsentImageVO>) dac.GetConsentImageFileName(this.IbatisMapper, param);
  1426. int cnt = 0;
  1427. foreach (ConsentImageVO img in result) {
  1428. fileName = img.ImageFilename;
  1429. var sUploadPath = img.ImagePath;
  1430. var remotePath = imageServerProps.remotePath;
  1431. var destDirectory = remotePath.Substring(2);
  1432. var targetDrive = "";
  1433. var virtualDir = "";
  1434. // 경로를 확인하여 가상 디렉토리 경로를 설정한다
  1435. if (imageServerProps != null) {
  1436. targetDrive = imageServerProps.remotePath.Substring(0, 1);
  1437. switch (targetDrive) {
  1438. case "W":
  1439. virtualDir = "his032";
  1440. break;
  1441. case "Z":
  1442. virtualDir = "his031";
  1443. break;
  1444. }
  1445. }
  1446. // 계정을 choiadmin 으로 가장한다
  1447. ClipSoft.Utility.ImpersonationUtility util = new ClipSoft.Utility.ImpersonationUtility();
  1448. var imResult = util.ImpersonationStart(string.Empty, "choiadmin", "choiadmin");
  1449. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("Impersonation Start, " + imResult);
  1450. // IIS 가상 디렉토리 경로를 가져온다
  1451. DirectoryInfo di = new DirectoryInfo(Server.MapPath(virtualDir));
  1452. var destDirStr = String.Format(@"{0}\{1}\{2}",
  1453. di.ToString(),
  1454. remotePath.Substring(remotePath.IndexOf("ACTIVE_ENC") + @"ACTIVE_ENC\".Length),
  1455. sUploadPath);
  1456. DirectoryInfo destDi = new DirectoryInfo(destDirStr);
  1457. var destFullname = String.Format(@"{0}\{1}", destDirStr, fileName);
  1458. var localFile = Server.MapPath(string.Format(@"./UPLOAD/{0}/{1}", sPath[cnt], sFileName[cnt]));
  1459. if (!destDi.Exists) {
  1460. destDi.Create();
  1461. }
  1462. try {
  1463. File.Copy(localFile, destFullname, true);
  1464. } catch (Exception e) {
  1465. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(e);
  1466. File.Move(destFullname, destFullname.Insert(destFullname.LastIndexOf(".jpg"), "_" + consentMstRidInt + "_" + DateTime.Now.ToString("yyyyMMddHHmmss")));
  1467. File.Copy(localFile, destFullname);
  1468. }
  1469. util.ImpersonationEnd();
  1470. cnt++;
  1471. }
  1472. dac.UpdateConsentImage(this.IbatisMapper, param);
  1473. }
  1474. } catch (Exception ex) {
  1475. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm imageUpload ERROR : [{0}]", ex.ToString()));
  1476. throw ex;
  1477. }
  1478. return fileName;
  1479. }
  1480. private bool checkOcrType6Form(string dutinstcd, string formCd) {
  1481. List<String> forms = getOcrType6Forms(dutinstcd);
  1482. int pos = forms.FindIndex(x => x.StartsWith(formCd));
  1483. return (pos > 0) ? true : false;
  1484. }
  1485. private int SavePrintData(string userId, string patientCode, string clnDeptCode, int formRid, string formCd,
  1486. int consentMstRid, int rewriteConsentMstRid, int reissueConsentMstRid, string consentState, string paperYn, string formXml, string dataXml,
  1487. string deviceType, string deviceIdentNo, string vistType, string hosType, string clnDate,
  1488. string ward, string roomcd, string reasonForUseN, int orderNo, string orderName, string orderCd, string ocrCode, int cretno,
  1489. string createUserName, string modifyUserName, string imageFileName, string certTarget,
  1490. string certResult, string mainDrId,
  1491. string userDeptCd, string pageCnt, string actKind, string clientType, string opRsrvNo) {
  1492. bool isNewConsentMasterCase = false;
  1493. if (consentMstRid < 1) {
  1494. isNewConsentMasterCase = true;
  1495. }
  1496. // OCR TYPE 6 는 기록하지 않는다
  1497. if (checkOcrType6Form(hosType, formCd)) {
  1498. return -1;
  1499. }
  1500. try {
  1501. using (SaveConsentDac dac = new SaveConsentDac()) {
  1502. Hashtable paramHashTable = GetParamHashTable(userId, patientCode, clnDeptCode, formRid, formCd, consentMstRid, rewriteConsentMstRid,
  1503. reissueConsentMstRid, consentState, paperYn, formXml, dataXml, deviceType, deviceIdentNo,
  1504. vistType, hosType, clnDate, ward, roomcd, reasonForUseN,
  1505. orderNo, orderName, orderCd, ocrCode, cretno, createUserName, modifyUserName,
  1506. certTarget, certResult, mainDrId, opRsrvNo);
  1507. consentMstRid = (int) paramHashTable["consentMstRid"];
  1508. //새로 출력하는 경우
  1509. if (isNewConsentMasterCase) {
  1510. dac.InsertConsentMst(this.IbatisMapper, paramHashTable);
  1511. }
  1512. //새로 작성 아닌 경우
  1513. else {
  1514. if (reissueConsentMstRid > 0)
  1515. dac.UpdateConsentMstForReissue(this.IbatisMapper, paramHashTable);
  1516. else
  1517. dac.UpdateConsentMst(this.IbatisMapper, paramHashTable);
  1518. }
  1519. // OCR 테이블 연계
  1520. Hashtable ocrParam = new Hashtable {
  1521. { "instcd", hosType },
  1522. { "ocrtag", ocrCode },
  1523. { "pid", patientCode },
  1524. { "ordtype", vistType },
  1525. { "orddd", clnDate },
  1526. { "cretno", cretno },
  1527. { "orddrid", mainDrId },
  1528. { "orddeptcd", clnDeptCode },
  1529. { "formcd", formCd },
  1530. { "fstprntdeptcd", userDeptCd },
  1531. { "fstprntid", userId },
  1532. { "updtdeptcd", userDeptCd },
  1533. { "updtuserid", userId },
  1534. { "updtdt", DateTime.Now.ToString("yyyyMMddHHmmss")},
  1535. { "pagecnt", pageCnt },
  1536. { "updtresncnts", reasonForUseN },
  1537. { "actkind", actKind },
  1538. { "clienttype", clientType }
  1539. };
  1540. dac.InsertPrintData(this.IbatisMapper, ocrParam);
  1541. }
  1542. } catch (Exception ex) {
  1543. if (this.IbatisSession != null) this.IbatisSession.RollBackTransaction();
  1544. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm SaveData ERROR : [{0}]", ex.ToString()));
  1545. throw ex;
  1546. } finally {
  1547. }
  1548. return consentMstRid;
  1549. }
  1550. public static int ExecuteCommand(string command, int timeout) {
  1551. var processInfo = new System.Diagnostics.ProcessStartInfo("cmd.exe", "/C " + command) {
  1552. RedirectStandardOutput = true,
  1553. CreateNoWindow = true,
  1554. UseShellExecute = false,
  1555. //WorkingDirectory = "C:\\",
  1556. //WorkingDirectory = ".\\",
  1557. };
  1558. var process = System.Diagnostics.Process.Start(processInfo);
  1559. process.WaitForExit(20000);
  1560. //string txt = process.StandardOutput.ReadToEnd();
  1561. //Console.WriteLine(txt);
  1562. var exitCode = process.ExitCode;
  1563. process.Close();
  1564. return exitCode;
  1565. }
  1566. private static Dictionary<string, string> DataXmlToDictionary(string dataXml) {
  1567. Dictionary<string, string> outputDataDic;
  1568. XmlDocument xmlDocument = new XmlDocument();
  1569. xmlDocument.LoadXml(dataXml);
  1570. outputDataDic = new Dictionary<string, string>();
  1571. XmlNode rootNode = xmlDocument.SelectSingleNode("form-data");
  1572. foreach (XmlNode childNode in rootNode.ChildNodes) {
  1573. string fieldName = string.Empty;
  1574. string fieldValue = string.Empty;
  1575. XmlElement outFieldElement = childNode as XmlElement;
  1576. if (outFieldElement != null) {
  1577. fieldName = outFieldElement.Name;
  1578. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("DataXmlToDictionary 0 : {0}/{1}", outFieldElement.ChildNodes.Count, fieldName));
  1579. if (outFieldElement.ChildNodes.Count == 1 && outFieldElement.ChildNodes[0] is XmlCDataSection) {
  1580. fieldValue = ((XmlCDataSection) outFieldElement.ChildNodes[0]).InnerText;
  1581. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("DataXmlToDictionary 1 : {0}/{1}", fieldName, fieldValue));
  1582. if (outputDataDic.ContainsKey(fieldName)) {
  1583. outputDataDic[fieldName] = fieldValue;
  1584. } else {
  1585. outputDataDic.Add(fieldName, fieldValue);
  1586. }
  1587. } else if (outFieldElement.ChildNodes.Count > 1) {
  1588. foreach (XmlNode childNode2 in childNode.ChildNodes) {
  1589. string fieldName2 = string.Empty;
  1590. string fieldValue2 = string.Empty;
  1591. XmlElement outFieldElement2 = childNode2 as XmlElement;
  1592. fieldName2 = outFieldElement2.Name;
  1593. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("DataXmlToDictionary : {0}", fieldName2));
  1594. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("DataXmlToDictionary : {0}", outFieldElement2.ChildNodes.Count));
  1595. if (outFieldElement2.ChildNodes.Count > 0 && outFieldElement2.ChildNodes[0] is XmlCDataSection) {
  1596. fieldValue2 = ((XmlCDataSection) outFieldElement2.ChildNodes[0]).InnerText;
  1597. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("DataXmlToDictionary 2 : {0}/{1}", fieldName2, fieldValue2));
  1598. }
  1599. if (outputDataDic.ContainsKey(fieldName2)) {
  1600. outputDataDic[fieldName2] = fieldValue2;
  1601. } else {
  1602. outputDataDic.Add(fieldName2, fieldValue2);
  1603. }
  1604. }
  1605. }
  1606. }
  1607. }
  1608. return outputDataDic;
  1609. }
  1610. /// <summary>
  1611. /// EFORM_CODE에 정의하는 시퀀스(채번)을 구한다.
  1612. /// </summary>
  1613. /// <param name="sSubCd"></param>
  1614. /// <returns></returns>
  1615. private int GetSequence(string sSubCd) {
  1616. int nSeq = -1;
  1617. try {
  1618. using (CommonCodeDac dac = new CommonCodeDac()) {
  1619. Code param = new Code();
  1620. param.sub_cd = sSubCd;
  1621. nSeq = dac.GetSequence(this.IbatisMapper, param);
  1622. if (nSeq == 0) {
  1623. dac.InsertSequence(this.IbatisMapper, param);
  1624. nSeq = 1;
  1625. } else {
  1626. param.ud1_num = ++nSeq;
  1627. dac.UpdateSequence(this.IbatisMapper, param);
  1628. }
  1629. }
  1630. } catch (Exception ex) {
  1631. if (this.IbatisSession != null) this.IbatisSession.RollBackTransaction();
  1632. throw ex;
  1633. }
  1634. return nSeq;
  1635. }
  1636. #region GetParamHashTable
  1637. private Hashtable GetParamHashTable(string userId, // 사용자 Id
  1638. string patientCode, // 환자 등록번호
  1639. string clnDeptCode, // 진료과 코드
  1640. int formRid, // (작성대상)서식 Rid
  1641. string formCd, // 서식코드 === CONSENT_DATA_CHOICE에서 입력여부 판단할 파라미터
  1642. int consentMstRid, // 동의서 마스터 데이터 Rid
  1643. int rewriteConsentMstRid, // 재 작성 대상 동의서 마스터 데이터 Rid
  1644. int reissueConsentMstRid, // 재 발행 대상 동의서 마스터 데이터 Rid
  1645. string consentState, // 동의서 상태 (TEMP, PAPER_OUT, ELECTR_CMP, CERTIFY_CMP)
  1646. string paperYn, // 인쇄 발행 여부
  1647. string formXml, // 동의서 EPT Xml
  1648. string dataXml, // 동의서 Data(필드들) Xml
  1649. string deviceType, // 장비 유형 (WIN, AND, IOS, PRT 중1)
  1650. string deviceIdentNo, // 장비 고유식별 번호
  1651. string vistType, // 내원 구분
  1652. string hosType, // 병원 구분
  1653. string clnDate, // 내원구분에 따른 입원일자/진료일자
  1654. string ward, // 병동 코드
  1655. string roomcd, // 병실 코드
  1656. string reasonForUseN, // 출력된 동의서 폐기 사유
  1657. int orderNo, // 처방번호
  1658. string orderName, // 처방명
  1659. string orderCd, // 처방코드
  1660. string ocrCode, // OCR 코드
  1661. int cretno, // 생성번호
  1662. string createUserName, // 작성자명
  1663. string modifyUserName, // 수정자명
  1664. string certTarget, // 서명데이터 원본
  1665. string certResult, // 서명데이터 결과값
  1666. string mainDrId, // 주치의 아이디
  1667. string opRsrvNo // 수술 예약 번호
  1668. ) {
  1669. Hashtable paramHashTable = new Hashtable();
  1670. paramHashTable.Add("userId", userId);
  1671. if (consentMstRid < 1) {
  1672. // insert case
  1673. consentMstRid = this.GetSequence("CONSENT_MST");
  1674. }
  1675. paramHashTable.Add("consentMstRid", consentMstRid);
  1676. paramHashTable.Add("patientCode", patientCode);
  1677. paramHashTable.Add("clnDeptCd", clnDeptCode);
  1678. paramHashTable.Add("vistType", vistType);
  1679. paramHashTable.Add("hosType", hosType);
  1680. paramHashTable.Add("clnDate", clnDate);
  1681. paramHashTable.Add("ward", ward);
  1682. paramHashTable.Add("roomcd", roomcd);
  1683. paramHashTable.Add("orderNo", orderNo);
  1684. paramHashTable.Add("orderName", orderName);
  1685. paramHashTable.Add("orderCd", orderCd);
  1686. paramHashTable.Add("ocrCode", ocrCode);
  1687. paramHashTable.Add("cretno", cretno);
  1688. paramHashTable.Add("createUserName", createUserName);
  1689. paramHashTable.Add("modifyUserName", modifyUserName);
  1690. paramHashTable.Add("formRid", formRid);
  1691. paramHashTable.Add("formCd", formCd);
  1692. paramHashTable.Add("consentState", consentState);
  1693. paramHashTable.Add("certTarget", certTarget); // TODO 원무 pass
  1694. paramHashTable.Add("certResult", certResult); // TODO 원무 pass
  1695. paramHashTable.Add("mainDrId", mainDrId);
  1696. paramHashTable.Add("opRsrvNo", opRsrvNo ?? string.Empty);
  1697. Encoding encoding = Encoding.GetEncoding("UTF-8");
  1698. //if (certResult != null)
  1699. //{
  1700. // paramHashTable.Add("certResult", encoding.GetBytes(certResult));
  1701. //}
  1702. string completeYn = "N"; // 완료 여부
  1703. switch (consentState) {
  1704. //case "ELECTR_CMP":
  1705. case "CERTIFY_CMP":
  1706. completeYn = "Y";
  1707. break;
  1708. default:
  1709. break;
  1710. }
  1711. paramHashTable.Add("completeYn", completeYn);
  1712. string completeDateTimeToChars = string.Empty;
  1713. if (completeYn.Equals("Y")) {
  1714. completeDateTimeToChars = "TO_CHAR(SYSDATE,'YYYY-MM-DD hh24:mi:ss')";
  1715. paramHashTable.Add("completeDateTimeToChars", completeDateTimeToChars);
  1716. } else {
  1717. paramHashTable.Add("completeDateTimeToChars", "''");
  1718. }
  1719. paramHashTable.Add("paperYn", paperYn);
  1720. string rewriteYn = "N"; // 재 작성 여부
  1721. if (rewriteConsentMstRid > 1) {
  1722. rewriteYn = "Y";
  1723. }
  1724. paramHashTable.Add("rewriteYn", rewriteYn);
  1725. paramHashTable.Add("rewriteConsentMstRid", rewriteConsentMstRid);
  1726. string reissueYn = "N"; // 재 발행(종이) 여부
  1727. if (reissueConsentMstRid > 1) {
  1728. reissueYn = "Y";
  1729. }
  1730. paramHashTable.Add("reissueYn", reissueYn);
  1731. paramHashTable.Add("reissueConsentMstRid", reissueConsentMstRid);
  1732. int consentDataRid = this.GetSequence("CONSENT_DATA");
  1733. paramHashTable.Add("consentDataRid", consentDataRid);
  1734. paramHashTable.Add("useYn", "Y");
  1735. encoding = Encoding.GetEncoding("UTF-8");
  1736. byte[] formBytesConent = null;
  1737. if (!string.IsNullOrEmpty(formXml)) {
  1738. formBytesConent = encoding.GetBytes(formXml);
  1739. }
  1740. byte[] dataBytesConent = null;
  1741. if (!string.IsNullOrEmpty(dataXml)) {
  1742. dataBytesConent = encoding.GetBytes(dataXml);
  1743. }
  1744. paramHashTable.Add("formXml", formBytesConent);
  1745. paramHashTable.Add("dataXml", dataBytesConent);
  1746. paramHashTable.Add("deviceType", deviceType);
  1747. paramHashTable.Add("deviceIdentNo", deviceIdentNo);
  1748. paramHashTable.Add("reasonForUseN", reasonForUseN);
  1749. return paramHashTable;
  1750. }
  1751. #endregion
  1752. //임시파일 삭제 (1일전 파일은 삭제)
  1753. //public int DeleteTempFile(string targetDate)
  1754. public int DeleteTempFile() {
  1755. //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
  1756. if (tempImageDelStatus.Equals(DateTime.Now.AddDays(-1).ToString().Substring(0, 10).Replace("-", ""))) {
  1757. return 1;
  1758. }
  1759. try {
  1760. string sSeverImgPath = Server.MapPath("./DataTempImage/");
  1761. DirectoryInfo di = new System.IO.DirectoryInfo(sSeverImgPath);
  1762. if (Directory.Exists(sSeverImgPath)) {
  1763. string[] filePaths = Directory.GetFiles(sSeverImgPath);
  1764. foreach (string fileName in filePaths) {
  1765. FileInfo fileInfo = new FileInfo(fileName);
  1766. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("DeleteTempFile fileInfo.CreationTime : {0}", fileInfo.CreationTime.ToString()));
  1767. if (fileInfo.CreationTime < DateTime.Now.AddDays(-1)) {
  1768. fileInfo.Delete();
  1769. }
  1770. }
  1771. }
  1772. tempImageDelStatus = DateTime.Now.AddDays(-1).ToString().Substring(0, 10).Replace("-", "");
  1773. return 1;
  1774. } catch {
  1775. return -1;
  1776. }
  1777. }
  1778. /// <summary>
  1779. /// 동의서 로드 전 consent_mst_rid에 해당하는 동의서가 상위 상태값이 있는지 체크
  1780. /// </summary>
  1781. /// <param name="consentmstrid"></param>
  1782. /// <param name="consent_state"></param>
  1783. /// <returns></returns>
  1784. [WebMethod(Description = "동의서 상위 상태값이 있는지 체크")]
  1785. public SingleReturnData CheckConsentState(int consentmstrid, string consent_state) {
  1786. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("rid: {0}, state: {1}", consentmstrid, consent_state));
  1787. SingleReturnData singleReturnData = new SingleReturnData();
  1788. try {
  1789. int result = -1;
  1790. int StateNo = 0;
  1791. String CurState;
  1792. using (ConsentDac dac = new ConsentDac()) {
  1793. Hashtable param = new Hashtable();
  1794. param.Add("consentmstrid", consentmstrid);
  1795. CurState = dac.GetConsentStateCheck(this.IbatisMapper, param);
  1796. }
  1797. if (CurState == null) {
  1798. singleReturnData.responseData = "0";
  1799. return singleReturnData;
  1800. } else if (CurState.Equals("UNFINISHED")) {
  1801. StateNo = 1;
  1802. } else if (CurState.Equals("TEMP")) {
  1803. StateNo = 2;
  1804. } else if (CurState.Equals("VERBAL")) {
  1805. StateNo = 3;
  1806. } else if (CurState.Equals("PAPER_OUT")) {
  1807. StateNo = 4;
  1808. } else if (CurState.Equals("ELECTR_CMP")) {
  1809. StateNo = 5;
  1810. } else if (CurState.Equals("CERTIFY_CMP")) {
  1811. StateNo = 6;
  1812. }
  1813. if (consent_state == null/* || string.IsNullOrEmpty(consent_state)*/) {
  1814. singleReturnData.responseData = Convert.ToString(result);
  1815. return singleReturnData;
  1816. } else if (consent_state.Equals("UNFINISHED")) {
  1817. result = 1;
  1818. } else if (consent_state.Equals("TEMP")) {
  1819. result = 2;
  1820. } else if (consent_state.Equals("VERBAL")) {
  1821. result = 3;
  1822. } else if (consent_state.Equals("PAPER_OUT")) {
  1823. result = 4;
  1824. } else if (consent_state.Equals("ELECTR_CMP")) {
  1825. result = 5;
  1826. } else if (consent_state.Equals("CERTIFY_CMP")) {
  1827. singleReturnData.responseData = Convert.ToString(result);
  1828. return singleReturnData;
  1829. }
  1830. if (result < StateNo)//로드하려는 동의서의 상태보다 현재 저장된 상태가 더 높은 상태일 경우
  1831. {
  1832. singleReturnData.responseData = "1";
  1833. return singleReturnData;
  1834. } else//로드하려는 동의서보다 현재 저장된 상태가 낮은상태일 경우 또는 같을경우
  1835. {
  1836. singleReturnData.responseData = "0";
  1837. return singleReturnData;
  1838. }
  1839. } catch {
  1840. singleReturnData.responseData = "-1";
  1841. return singleReturnData;
  1842. }
  1843. }
  1844. [WebMethod(Description = "AGMT 입력을 위한 consent_mst 조회")]
  1845. public string getAgmtConsentData(string instcd, string ocrtag) {
  1846. string retStr = string.Empty;
  1847. using(ConsentDac dac = new ConsentDac()) {
  1848. // 1. 먼저 OCRTAG 로 consent_mst 쪽에서 데이터를 가져온다
  1849. Hashtable param1 = new Hashtable();
  1850. param1.Add("instcd", instcd);
  1851. param1.Add("ocrtag", ocrtag);
  1852. AgmtVo vo = dac.getConsentMst(this.IbatisMapper, param1);
  1853. if(vo == null) {
  1854. return "error, EMA.CONSENT_MST 에 데이터가 없습니다. 입력 파라미터를 다시 확인하세요.";
  1855. }
  1856. // BLOB 데이터를 불러 온다.
  1857. Hashtable parma2 = new Hashtable();
  1858. parma2.Add("consentMstRid", vo.consentMstRid);
  1859. string rawXml = dac.getConsentData(IbatisMapper, parma2);
  1860. if(string.IsNullOrEmpty(rawXml)) {
  1861. return "error, BLOB 데이터 호출 오류";
  1862. }
  1863. try {
  1864. SavePatientConsentInfo(vo.formCd, vo.pid, vo.ocrtag, vo.instcd, vo.clnDate, String.Format("{0}", vo.cretno), vo.ordtype, vo.deptcd, vo.orddrid, vo.createUserId, rawXml);
  1865. retStr = String.Format("PID: {0}, ordtype: {1}, ocrtag: {2} 의 입원약정서가 pam.pmihagmt 테이블에 Insert 되었습니다.", vo.pid, vo.ordtype, vo.ocrtag);
  1866. }
  1867. catch(Exception e) {
  1868. retStr = e.ToString();
  1869. }
  1870. }
  1871. return retStr;
  1872. }
  1873. private void SavePatientConsentInfo(string p_formcd
  1874. , string p_pid
  1875. , string p_ocrtag
  1876. , string p_instcd
  1877. , string p_orddd
  1878. , string p_cretno
  1879. , string p_ordtype
  1880. , string p_orddeptcd
  1881. , string p_orddrid
  1882. , string p_userid
  1883. , string p_dataxml) {
  1884. try {
  1885. // 원무 동의서 연동 정보 입력
  1886. // 1300013649 : 입원약정서(기간)(E)
  1887. // 1300013647 : 선택진료신청서(E)
  1888. // 1300013648 : 입원약정서(일반)(E)
  1889. // 1100012120 : C3-개인정보 수집·이용 제공 동의서
  1890. // 1400015188 : C3-개인정보 수집 이용 제공 동의서(중국어)
  1891. // 1400015531 : C3-개인정보 수집·이용 및 제공 동의서(영어)
  1892. // 현재 입원 약정서 외에는 사용하지 않음
  1893. if (!p_formcd.Equals("1300013648")
  1894. /*&& !p_formcd.Equals("1300013647")
  1895. && !p_formcd.Equals("1100012120")
  1896. && !p_formcd.Equals("1400015188")
  1897. && !p_formcd.Equals("1400015531")*/
  1898. && !p_formcd.Equals("1300013649")) {
  1899. return;
  1900. }
  1901. // 동의서 내부 데이터 추출
  1902. Dictionary<string, string> pamDic = DataXmlToDictionary(p_dataxml);
  1903. var today = DateTime.Today.ToString("yyyyMMdd");
  1904. string fromdt = null, todt = null;
  1905. if (string.IsNullOrEmpty(pamDic["savCMDCBD_ContStartDate"]))
  1906. {
  1907. fromdt = today;
  1908. }
  1909. else
  1910. {
  1911. fromdt = pamDic["savCMDCBD_ContStartDate"];
  1912. }
  1913. if (string.IsNullOrEmpty(pamDic["savCMDCBD_ContEndDate"]))
  1914. {
  1915. todt = today;
  1916. }
  1917. else
  1918. {
  1919. todt = pamDic["savCMDCBD_ContEndDate"];
  1920. }
  1921. // 선택진료신청서 - 선택 진료 여부 > savCMDCBD_SpDrYN
  1922. // 입원약정서 - 약정시작일 > savCMDCBD_ContStartDate
  1923. // 입원약정서 - 약정종료일 > savCMDCBD_ContEndDate
  1924. // 개인정보이용동의서 - 확인항목 > chkitem00
  1925. // 개인정보이용동의서 - 확인여부 > chkvalue
  1926. Hashtable param = new Hashtable { { "pid", p_pid }
  1927. , { "ocrtag", p_ocrtag }
  1928. , { "instcd", p_instcd }
  1929. , { "orddd", p_orddd }
  1930. , { "cretno", p_cretno }
  1931. , { "ordtype", p_ordtype }
  1932. , { "msflag", "" }
  1933. , { "orddeptkind", "" }
  1934. , { "orddeptcd", p_orddeptcd }
  1935. , { "orddrid", p_orddrid }
  1936. , { "specordyn", ( pamDic.ContainsKey("savCMDCBD_SpDrYN") ? pamDic["savCMDCBD_SpDrYN"] : "" ) }
  1937. , { "specdrid", "" }
  1938. , { "userid", p_userid }
  1939. , { "contfromdd", fromdt }
  1940. , { "conttodd", todt }
  1941. , { "formcd", p_formcd }
  1942. , { "chkitem", "" }
  1943. , { "chkvalue", ""} };
  1944. using (SaveConsentDac dac = new SaveConsentDac()) {
  1945. // 선택 진료 신청 동의서
  1946. /*
  1947. if (p_formcd.Equals("1300013647")) {
  1948. for (int i = 0; i < 9; i++) {
  1949. param["msflag"] = i == 0 ? "M" : "S";
  1950. param["orddeptkind"] = string.Format("0{0}", i);
  1951. param["specdrid"] = i == 0 ? p_orddrid : "-";
  1952. dac.InsertPmcmspif(this.IbatisMapper, param);
  1953. }
  1954. }
  1955. */
  1956. // 입원 약정서
  1957. if (p_formcd.Equals("1300013648") || p_formcd.Equals("1300013649")) {
  1958. param["agmttype"] = p_formcd.Equals("1300013648") ? "1" : p_formcd.Equals("1300013649") ? "2" : "";
  1959. dac.InsertPmihagmt(this.IbatisMapper, param);
  1960. }
  1961. // 개인 정보 이용 동의서
  1962. // 개인정보이용동의서 연동 안함
  1963. /*
  1964. List<string> chkItemList = new List<string>();
  1965. List<string> chkValueList = new List<string>();
  1966. foreach(string key in pamDic.Keys) {
  1967. if (key.ToLower().Contains("chkitem")) {
  1968. chkItemList.Add(key);
  1969. chkValueList.Add(pamDic[key]);
  1970. }
  1971. }
  1972. for (int i = 0; i < chkItemList.Count; i++) {
  1973. param["chkitem"] = chkItemList[i];
  1974. param["chkvalue"] = chkValueList[i];
  1975. dac.InsertPmcminfo(this.IbatisMapper, param);
  1976. }
  1977. */
  1978. }
  1979. } catch (Exception ex) {
  1980. if (this.IbatisSession != null) this.IbatisSession.RollBackTransaction();
  1981. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm SavePatientConsentInfo ERROR : [{0}]", ex.ToString()));
  1982. throw ex;
  1983. }
  1984. }
  1985. /// <summary>
  1986. /// 기준자료로 부터 OCT 태그에 찍힐 String 값
  1987. /// 경북대병원 dependency
  1988. /// </summary>
  1989. /// <param name="formCd">The form cd.</param>
  1990. /// <param name="dutinstcd">The dutinstcd.</param>
  1991. /// <returns></returns>
  1992. [WebMethod(Description = "기준자료로 부터 OCT 태그에 찍힐 String 값")]
  1993. public String getOcrString(string formCd, string dutinstcd) {
  1994. using (ConsentDac dac = new ConsentDac()) {
  1995. Hashtable param = new Hashtable();
  1996. param.Add("formcd", formCd);
  1997. param.Add("instcd", dutinstcd);
  1998. return dac.getOcrString(this.IbatisMapper, param);
  1999. }
  2000. }
  2001. /// <summary>
  2002. /// 원무 서식의 인증저장 사용여부
  2003. /// Y 일 경우 인증서 묻기를 하지 않는다
  2004. /// 경북대병원 dependency
  2005. /// </summary>
  2006. /// <param name="formCd">서식 코드</param>
  2007. /// <param name="dutinstcd">근무지기관코드</param>
  2008. /// <returns></returns>
  2009. [WebMethod(Description = "원무서식 인증저장 사용여부, Y 일 경우 인증저장시 인증서 묻기 pass")]
  2010. public String getCertUseYn(String formCd, String dutinstcd) {
  2011. using (ConsentDac dac = new ConsentDac()) {
  2012. Hashtable param = new Hashtable();
  2013. param.Add("formcd", formCd);
  2014. param.Add("instcd", dutinstcd);
  2015. String value = dac.getCertuseYn(this.IbatisMapper, param);
  2016. return (value == null) ? "N" : value;
  2017. //return dac.getCertuseYn(this.IbatisMapper, param);
  2018. }
  2019. }
  2020. /// <summary>
  2021. /// 원무 서식의 인증저장 사용여부 (모바일에서 사용)
  2022. /// 원무 서식이 여러개 선택되었을때
  2023. /// Y 일 경우 인증서 묻기를 하지 않는다
  2024. /// 경북대병원 dependency
  2025. /// </summary>
  2026. /// <param name="formCd">서식 코드</param> 서식코드는 '11111111', '2222222', '333333' 형태로 들어옴
  2027. /// <param name="dutinstcd">근무지기관코드</param>
  2028. /// <returns></returns>
  2029. [WebMethod(Description = "원무서식 인증저장 사용여부, Y 일 경우 인증저장시 인증서 묻기 pass (모바일에서 다중 선택 기능 포함)")]
  2030. public String getCertUseYnData(String formCd, String dutinstcd) {
  2031. using (ConsentDac dac = new ConsentDac()) {
  2032. Hashtable param = new Hashtable();
  2033. param.Add("formcd", formCd);
  2034. param.Add("instcd", dutinstcd);
  2035. String result = dac.getCertUseYnData(this.IbatisMapper, param);
  2036. if (result == null) {
  2037. result = "";
  2038. }
  2039. return result;
  2040. }
  2041. }
  2042. /// <summary>
  2043. /// 경북대학교병원 PC 클라이언트 dual view 모드 활성화 여부 조회
  2044. /// </summary>
  2045. /// <param name="dutinstcd">근무지기관코드</param>
  2046. /// <param name="ipaddr">해당 PC 의 ip address</param>
  2047. /// <returns></returns>
  2048. [WebMethod(Description = "경북대학교병원 PC 클라이언트 dual view 모드 활성화 여부 조회")]
  2049. public String getDualViewMode(String dutinstcd, String ipaddr) {
  2050. using (ConsentDac dac = new ConsentDac()) {
  2051. Hashtable param = new Hashtable();
  2052. param.Add("instcd", dutinstcd);
  2053. param.Add("ipaddr", ipaddr);
  2054. String value = dac.getDualViewMode(this.IbatisMapper, param);
  2055. return (value == null) ? "N" : value;
  2056. }
  2057. //return "N";
  2058. }
  2059. /// <summary>
  2060. /// 확인저장 된 서식을 일괄저장
  2061. /// </summary>
  2062. /// <param name="consent_rids"></param>
  2063. /// <param name="ocrtags"></param>
  2064. /// <param name="instcd"></param>
  2065. /// <returns></returns>
  2066. [WebMethod(Description = "경북대학교병원 일괄 인증 저장")]
  2067. public String updateCertifyComplete(String consent_rids, String ocrtags, String instcd) {
  2068. String result = "N";
  2069. try {
  2070. Hashtable param1 = new Hashtable();
  2071. Hashtable param2 = new Hashtable();
  2072. param1.Add("consent_rids", consent_rids);
  2073. param1.Add("instcd", instcd);
  2074. param2.Add("ocrtags", ocrtags);
  2075. param2.Add("instcd", instcd);
  2076. using (ConsentDac dac = new ConsentDac()) {
  2077. // 동의서 테이블 master
  2078. dac.updateToCertifyConsentMst(this.IbatisMapper, param1);
  2079. // 경북대학교병원 출력 로그 테이블
  2080. dac.updateToCertifyOcrprnt(this.IbatisMapper, param2);
  2081. }
  2082. result = "Y";
  2083. } catch (Exception ex) {
  2084. if (this.IbatisSession != null) this.IbatisSession.RollBackTransaction();
  2085. result = "N";
  2086. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(
  2087. String.Format("CLIP.eForm updateCertifyComplete ERROR : [{0}]", ex.ToString()));
  2088. }
  2089. return result;
  2090. }
  2091. /// <summary>
  2092. /// 전자동의서 프린트 출력 오류 시 프린트 로그 삭제 메서드
  2093. /// </summary>
  2094. /// <param name="pid"></param>
  2095. /// <param name="ocrtag"></param>
  2096. /// <param name="instcd"></param>
  2097. [WebMethod(Description = "프린터 출력 오류 시 출력 히스토리 삭제")]
  2098. public void updatePrintHistory(String pid, String ocrtag, String instcd) {
  2099. try {
  2100. Hashtable param1 = new Hashtable();
  2101. param1.Add("pid", pid);
  2102. param1.Add("instcd", instcd);
  2103. param1.Add("ocrtag", ocrtag);
  2104. using (ConsentDac dac = new ConsentDac()) {
  2105. dac.updateOcrPrintHistory(this.IbatisMapper, param1);
  2106. dac.updateConsentMaster(this.IbatisMapper, param1);
  2107. }
  2108. } catch (Exception ex) {
  2109. if (this.IbatisSession != null) this.IbatisSession.RollBackTransaction();
  2110. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(
  2111. String.Format("CLIP.eForm updatePrintHistory ERROR : [{0}]", ex.ToString()));
  2112. }
  2113. }
  2114. /// <summary>
  2115. /// 동의서 선택시 해당일에 대해 중복으로 작성되었는지 확인 (즐겨찾기와 동의서 찾기에서 확인해야함)
  2116. /// </summary>
  2117. /// <param name="pid"></param>
  2118. /// <param name="instCd"></param>
  2119. /// <param name="formCd"></param> '000000', '000001', '000002' 콤마로 붙여야함
  2120. [WebMethod(Description = "동의서 선택시 해당일에 대해 중복으로 작성되었는지 확인")]
  2121. public SingleReturnData duplicateCertConsent(String pid, String instCd, String formCd) {
  2122. SingleReturnData result = new SingleReturnData();
  2123. using (ConsentDac dac = new ConsentDac()) {
  2124. Hashtable param = new Hashtable();
  2125. param.Add("pid", pid);
  2126. param.Add("instCd", instCd);
  2127. param.Add("formCd", formCd);
  2128. String res = dac.getDupCertConsent(this.IbatisMapper, param);
  2129. result.responseData = res;
  2130. return result;
  2131. }
  2132. }
  2133. /// <summary>
  2134. /// 진정동의서 출력 여부 확인
  2135. /// </summary>
  2136. /// <param name="instcd">사용자 근무지 기관코드</param>
  2137. /// <param name="formcd">조회할 서식 코드</param>
  2138. /// <returns>출력 하여야 할 서식이라면 0 초과의 값을 리턴</returns>
  2139. /// 0보다 크면 진정동의서 작성 0이면 기존 link서식 작성
  2140. [WebMethod(Description = "진정동의서 출력 여부 확인")]
  2141. public int checkJinJeongDocument(String instcd, String formcd) {
  2142. using (ConsentDac dac = new ConsentDac()) {
  2143. int result = 0;
  2144. Hashtable param = new Hashtable();
  2145. param.Add("instcd", instcd);
  2146. param.Add("formcd", formcd);
  2147. result = dac.checkJinJeongDocument(this.IbatisMapper, param);
  2148. return result;
  2149. }
  2150. }
  2151. /// <summary>
  2152. /// 기관코드별 마취 동의서 서식 코드를 조회한다
  2153. /// </summary>
  2154. /// <param name="instcd"></param>
  2155. /// <returns>마취동의서 서식 코드</returns>
  2156. [WebMethod(Description = "마취동의서 서식 코드 조회")]
  2157. public String getLinkedAnstDocument(String instcd) {
  2158. using (ConsentDac dac = new ConsentDac()) {
  2159. String formCd = null;
  2160. Hashtable param = new Hashtable { { "instcd", instcd } };
  2161. formCd = dac.getLinkedAsntDocument(this.IbatisMapper, param);
  2162. return formCd;
  2163. }
  2164. }
  2165. [WebMethod(Description = "수술 관련 동의서 조회")]
  2166. public string checkOperationDocument(String instcd, String formCd) {
  2167. using (ConsentDac dac = new ConsentDac()) {
  2168. Hashtable param = new Hashtable();
  2169. param.Add("instcd", instcd);
  2170. param.Add("formCd", formCd);
  2171. return dac.checkOperationDocuemnt(this.IbatisMapper, param);
  2172. }
  2173. }
  2174. public byte[] Zip(string str) {
  2175. var bytes = Encoding.UTF8.GetBytes(str);
  2176. using (var msi = new MemoryStream(bytes))
  2177. using (var mso = new MemoryStream()) {
  2178. using (var gs = new GZipStream(mso, CompressionMode.Compress)) {
  2179. CopyTo(msi, gs);
  2180. }
  2181. return mso.ToArray();
  2182. }
  2183. }
  2184. public string Unzip(byte[] bytes) {
  2185. using (var msi = new MemoryStream(bytes))
  2186. using (var mso = new MemoryStream()) {
  2187. using (var gs = new GZipStream(msi, CompressionMode.Decompress)) {
  2188. CopyTo(gs, mso);
  2189. }
  2190. return Encoding.UTF8.GetString(mso.ToArray());
  2191. }
  2192. }
  2193. public void CopyTo(Stream src, Stream dest) {
  2194. byte[] bytes = new byte[4096];
  2195. int cnt;
  2196. while ((cnt = src.Read(bytes, 0, bytes.Length)) != 0) {
  2197. dest.Write(bytes, 0, cnt);
  2198. }
  2199. }
  2200. [WebMethod(Description = "신규서식이 아닌 서식을 불러온다")]
  2201. public string GetConsentFormXml(int consentMstRid)
  2202. {
  2203. byte[] result = { 0 };
  2204. String formXml = "";
  2205. //SingleReturnData result = new SingleReturnData();
  2206. try
  2207. {
  2208. using (ConsentDac consentDac = new ConsentDac())
  2209. {
  2210. Hashtable param = new Hashtable();
  2211. param.Add("consentMstRid", consentMstRid);
  2212. formXml = consentDac.getConsentFormXml(this.IbatisMapper, param);
  2213. UTF8Encoding encoder = new UTF8Encoding();
  2214. Decoder utf8Decode = encoder.GetDecoder();
  2215. byte[] toEcodeByte = Convert.FromBase64String(formXml);
  2216. int charCount = utf8Decode.GetCharCount(toEcodeByte, 0, toEcodeByte.Length);
  2217. char[] decodedChar = new char[charCount];
  2218. utf8Decode.GetChars(toEcodeByte, 0, toEcodeByte.Length, decodedChar, 0);
  2219. formXml = Unzip(toEcodeByte);
  2220. }
  2221. }
  2222. catch (Exception ex)
  2223. {
  2224. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm GetConsentFormXml ERROR : [{0}]", ex.ToString()));
  2225. }
  2226. return formXml;
  2227. }
  2228. }
  2229. }