ConsentSvc.asmx.cs 81 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534
  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.Dfh.Entity;
  21. using CLIP.eForm.Consent.Dfh.Dac;
  22. using CLIP.eForm.Consent.Dfh.Web;
  23. namespace CLIP.eForm.Consent.Dfh.WebService
  24. {
  25. /// <summary>
  26. /// 전자 동의서 관련 웹서비스
  27. /// </summary>
  28. /// <remarks>
  29. /// <p>[설계자]</p>
  30. /// <p> 클립소프트 연구소 홍지철 (jchong@clipsoft.co.kr)</p>
  31. /// <p>[원본 작성자]</p>
  32. /// <p> 클립소프트 기술부 이창훈 (chlee@clipsoft.co.kr)</p>
  33. /// <p>[수정 작성자]</p>
  34. /// <p> 클립소프트 기술부 이인희</p>
  35. /// <p>----------------------------------------------------------------------------------------</p>
  36. /// <p>[HISTORY]</p>
  37. /// <p> 2016-06-15 : 최초작성</p>
  38. /// <p>----------------------------------------------------------------------------------------</p>
  39. /// </remarks>
  40. /// <summary>
  41. /// ConsentSvc의 요약 설명입니다.
  42. /// </summary>
  43. [WebService(Namespace = "http://tempuri.org/")]
  44. [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
  45. [System.ComponentModel.ToolboxItem(false)]
  46. // ASP.NET AJAX를 사용하여 스크립트에서 이 웹 서비스를 호출하려면 다음 줄의 주석 처리를 제거합니다.
  47. // [System.Web.Script.Services.ScriptService]
  48. public class ConsentSvc : System.Web.Services.WebService {
  49. private IBatisHelper _ibatisHelper;
  50. private static string tempImageDelStatus = string.Empty;
  51. public ConsentSvc() {
  52. _ibatisHelper = new IBatisHelper("ConsentSvcOracleMap.config");
  53. }
  54. protected override void Dispose(bool disposing) {
  55. if (IbatisSession != null && IbatisSession.Transaction != null) {
  56. IbatisSession.CommitTransaction();
  57. IbatisSession.CloseConnection();
  58. }
  59. if (IbatisMapper != null)
  60. IbatisMapper.CloseConnection();
  61. base.Dispose(disposing);
  62. }
  63. /// <summary>
  64. /// 현재 연결된 IBatis Connection을 반환
  65. /// </summary>
  66. public ISqlMapper IbatisMapper {
  67. get {
  68. if (_ibatisHelper == null) {
  69. return null;
  70. } else {
  71. return _ibatisHelper.GetSqlMapper();
  72. }
  73. }
  74. }
  75. /// <summary>
  76. /// 현재 연결된 ISqlMapSession 을 반환
  77. /// </summary>
  78. public ISqlMapSession IbatisSession {
  79. get {
  80. if (_ibatisHelper == null) {
  81. return null;
  82. } else {
  83. return _ibatisHelper.GetMapSession();
  84. }
  85. }
  86. }
  87. [WebMethod]
  88. public bool CheckWebService() {
  89. return true;
  90. }
  91. [WebMethod]
  92. public bool CheckDatabaseConnection() {
  93. // TODO: 데이터 베이스 커넥션 테스트 호출 필요
  94. return false;
  95. }
  96. // 동의서 하위 카테고리 조회
  97. [WebMethod(Description = "동의서 하위 카테고리 조회")]
  98. public List<CategoryForDropdownVO> GetCategoryForDropdown(string categoryId) {
  99. List<CategoryForDropdownVO> result;
  100. try {
  101. using (FormCategoryDac dac = new FormCategoryDac()) {
  102. Hashtable param = new Hashtable();
  103. param.Add("category_id", categoryId);
  104. result = (List<CategoryForDropdownVO>)dac.GetCategoryForDropdown(this.IbatisMapper, param);
  105. if (categoryId.Equals("1")) {
  106. CategoryForDropdownVO categoryForDropdownVO = new CategoryForDropdownVO();
  107. categoryForDropdownVO.CategoryType = "F";
  108. categoryForDropdownVO.CategoryId = "1CB1B494-1EF0-48BD-84D6-4965A54E6AEA";
  109. categoryForDropdownVO.CategoryName = "전체";
  110. result.Insert(0, categoryForDropdownVO);
  111. } else {
  112. CategoryForDropdownVO allSubCategory = new CategoryForDropdownVO();
  113. allSubCategory.CategoryId = categoryId;
  114. allSubCategory.CategoryName = "전체";
  115. allSubCategory.CategoryType = "F";
  116. result.Insert(0, allSubCategory);
  117. }
  118. }
  119. return result;
  120. } catch (Exception ex) {
  121. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("CLIP.eForm error: {0}", ex.Message));
  122. throw ex;
  123. }
  124. }
  125. // 환자, 상태에 따른 동의서 목록 검색
  126. [WebMethod(Description = "환자/상태에 따른 동의서 목록 검색")]
  127. public List<ConsentVO> GetConsentList(string patientCode, string startDt, string endDt, string consetState, string jobkindcd) {
  128. List<ConsentVO> result;
  129. try {
  130. using (ConsentDac dac = new ConsentDac()) {
  131. Hashtable param = new Hashtable();
  132. string isnurs = "N";
  133. param.Add("patientCode", patientCode);
  134. param.Add("startDt", startDt);
  135. param.Add("endDt", endDt);
  136. param.Add("consentState", consetState);
  137. if (jobkindcd == "1140" || jobkindcd == "1113") {
  138. isnurs = "Y";
  139. }
  140. param.Add("isnurs", isnurs);
  141. result = (List<ConsentVO>)dac.GetConsentList(this.IbatisMapper, param);
  142. }
  143. return result;
  144. } catch (Exception ex) {
  145. System.Diagnostics.Trace.WriteLine(string.Format("CLIP.eForm error: {0}", ex.Message));
  146. throw ex;
  147. }
  148. }
  149. // 동의서 찾기
  150. [WebMethod(Description = "동의서 찾기(조회)")]
  151. public List<ConsentBySearchVO> GetConsentBySearch(string categoryId, string keyWord) {
  152. List<ConsentBySearchVO> result;
  153. try {
  154. using (ConsentDac dac = new ConsentDac()) {
  155. Hashtable param = new Hashtable();
  156. param.Add("category_id", categoryId);
  157. param.Add("key_word", string.Format("%{0}%", keyWord));
  158. result = (List<ConsentBySearchVO>)dac.GetConsentBySearch(this.IbatisMapper, param);
  159. }
  160. return result;
  161. } catch (Exception ex) {
  162. System.Diagnostics.Trace.WriteLine(string.Format("CLIP.eForm error: {0}", ex.Message));
  163. throw ex;
  164. }
  165. }
  166. /// <summary>
  167. /// CONSENT_MST_RID를 갖고 저장된 동의서 이미지를 조회
  168. /// </summary>
  169. /// <param name="consentMstRid">동의서 마스터 데이터 Rid</param>
  170. [WebMethod(Description = "동의서 저장된 이미지 내역 조회")]
  171. public List<ConsentImageVO> GetConsentImage(string consentMstRid) {
  172. List<ConsentImageVO> result;
  173. try {
  174. using (ConsentDac dac = new ConsentDac()) {
  175. Hashtable param = new Hashtable();
  176. int consentMstRidInt = 0;
  177. int.TryParse(consentMstRid, out consentMstRidInt);
  178. param.Add("consent-mst-rid", consentMstRidInt);
  179. result = (List<ConsentImageVO>)dac.GetConsentImage(this.IbatisMapper, param);
  180. //이미지를 조회한 후, 서버의 임시디렉토리에 파일을 복사해둔다.
  181. //파일명이 겹칠 수 있으므로 O:\fnuImage\201607\19\100501967 에서 fnuImage20160719100501967 으로 저장한다.
  182. foreach (ConsentImageVO img in result) {
  183. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("CLIP.eForm File Upload Impersonate START workemr"));
  184. //// 윈도우 계정으로 Impersonate
  185. ClipSoft.Utility.ImpersonationUtility util = new ClipSoft.Utility.ImpersonationUtility();
  186. util.ImpersonationStart(string.Empty, "workemr", "workemr");
  187. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("CLIP.eForm File Upload Impersonate END"));
  188. // @"\\192.168.0.222\00. 공용폴더\04. 프로그램 및 관련 매뉴얼\5. oracle\oracle"
  189. //string orgFile = @"\\192.168.100.32\image_a03\fnuImage\201610\13" + "\\" + img.ImageFilename;
  190. string orgFile = img.ImagePath + "\\" + img.ImageFilename;
  191. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("CLIP.eForm GetConsentImage orgFile: {0}", orgFile));
  192. string tempImgNm = orgFile.Substring(orgFile.IndexOf("\\") + 1).Replace("\\", "");
  193. if (!System.IO.File.Exists(Server.MapPath("./DataTempImage/") + tempImgNm)) {
  194. System.IO.File.Copy(orgFile, Server.MapPath("./DataTempImage/") + tempImgNm);
  195. }
  196. // Impersonate 종료
  197. util.ImpersonationEnd();
  198. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("CLIP.eForm File Upload Impersonate CLOSE"));
  199. }
  200. }
  201. int iResult = DeleteTempFile();
  202. return result;
  203. } catch (Exception ex) {
  204. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm GetConsentImage error: {0}", ex.Message));
  205. throw ex;
  206. }
  207. }
  208. [WebMethod(Description = "테스트 테스트 테스트")]
  209. public int SaveTempData1(string userId,
  210. string patientCode,
  211. string clnDeptCode,
  212. int formRid,
  213. string formCd,
  214. int consentMstRid,
  215. int rewriteConsentMstRid,
  216. string formXml,
  217. string dataXml,
  218. string deviceType,
  219. string deviceIdentNo,
  220. string vistType,
  221. string hosType,
  222. string clnDate,
  223. string ward,
  224. string roomcd,
  225. int orderNo,
  226. string orderName,
  227. string orderCd,
  228. string ocrCode,
  229. int cretno,
  230. string createUserName,
  231. string modifyUserName,
  232. string mainDrId
  233. ) {
  234. string paramLog = "";
  235. paramLog += "clnDept[" + userId + "]patientCode[" + patientCode + "]clnDeptCode[" + clnDeptCode + "]formRid[" + formRid + "]";
  236. paramLog += "formCd[" + formCd + "]" + "consentMstRid[" + consentMstRid + "]rewriteConsentMstRid[" + rewriteConsentMstRid + "]";
  237. paramLog += "deviceType[" + deviceType + "]vistType[" + vistType + "]hosType[" + hosType + "]";
  238. paramLog += "clnDate[" + clnDate + "]ward[" + ward + "]roomcd[" + roomcd + "]orderNo[" + orderNo + "]";
  239. paramLog += "orderName[" + orderName + "]orderCd[" + orderCd + "]ocrCode[" + ocrCode + "]cretno[" + cretno + "]";
  240. paramLog += "createUserName[" + createUserName + "]modifyUserName[" + modifyUserName + "]";
  241. paramLog += "deviceIdentNo[" + deviceIdentNo + "]mainDrId[" + mainDrId + "]";
  242. paramLog += "dataXml[" + dataXml + "]formXml[" + formXml + "]";
  243. byte[] byte64 = Convert.FromBase64String(dataXml);
  244. dataXml = Encoding.UTF8.GetString(byte64);
  245. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("CLIP.eForm SaveTempData param : " + dataXml);
  246. //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("SaveTempData1 --> ", "!@#!@#!@#!@#!@#!@#!@#!@#"));
  247. return 1;
  248. }
  249. /// <summary>
  250. /// 전자동의서를 임시저장 한다.
  251. /// </summary>
  252. /// <param name="userId">로그인 사용자ID</param>
  253. /// <param name="patientCode">환자 등록번호</param>
  254. /// <param name="clnDeptCode">진료과 코드</param>
  255. /// <param name="formRid">(작성대상)서식 Rid</param>
  256. /// <param name="formCd">서식코드</param>
  257. /// <param name="consentMstRid">동의서 마스터 데이터 Rid</param>
  258. /// <param name="rewriteConsentMstRid">재 작성 대상 동의서 마스터 데이터 Rid</param>
  259. /// <param name="formXml">동의서 EPT Xml</param>
  260. /// <param name="dataXml">동의서 Data(필드들) Xml</param>
  261. /// <param name="deviceType">장비 유형 (WIN, AND, IOS, PRT 중1)</param>
  262. /// <param name="deviceIdentNo">장비 고유 식별자</param>
  263. /// <param name="vistType">내원구분</param>
  264. /// <param name="hosType">병원 구분</param>
  265. /// <param name="clnDate">병원 구분이 "I" 일 경우 입원일자/병원 구분이 "O"일 경우 진료일자</param>
  266. /// <param name="ward">병동 코드</param>
  267. /// <param name="roomcd">병실 코드</param>
  268. /// <param name="orderNo">처방번호</param>
  269. /// <param name="orderName">처방명</param>
  270. /// <param name="orderCd">처방코드</param>
  271. /// <param name="ocrCode">OCR 코드</param>
  272. /// <param name="cretno">생성번호</param>
  273. /// <param name="createUserName">작성자명</param>
  274. /// <param name="modifyUserName">수정자명</param>
  275. /// <param name="mainDrId">주치의 아이디</param>
  276. [WebMethod(Description = "동의서 임시저장")]
  277. public int SaveTempData(string userId, string patientCode, string clnDeptCode, int formRid, string formCd,
  278. int consentMstRid, int rewriteConsentMstRid, string formXml, string dataXml,
  279. string deviceType, string deviceIdentNo, string vistType, string hosType, string clnDate,
  280. string ward, string roomcd, int orderNo, string orderName, string orderCd, string ocrCode, int cretno,
  281. string createUserName, string modifyUserName, string mainDrId)
  282. {
  283. string paramLog = "";
  284. paramLog += "clnDept[" + userId + "]patientCode[" + patientCode + "]clnDeptCode[" + clnDeptCode + "]formRid[" + formRid + "]";
  285. paramLog += "formCd[" + formCd + "]consentMstRid[" + consentMstRid + "]rewriteConsentMstRid[" + rewriteConsentMstRid + "]";
  286. paramLog += "deviceType[" + deviceType + "]vistType[" + vistType + "]hosType[" + hosType + "]";
  287. paramLog += "clnDate[" + clnDate + "]ward[" + ward + "]roomcd[" + roomcd + "]orderNo[" + orderNo + "]";
  288. paramLog += "orderName[" + orderName + "]orderCd[" + orderCd + "]ocrCode[" + ocrCode + "]cretno[" + cretno + "]";
  289. paramLog += "createUserName[" + createUserName + "]modifyUserName[" + modifyUserName + "]";
  290. paramLog += "deviceIdentNo[" + deviceIdentNo + "]mainDrId[" + mainDrId + "]";
  291. paramLog += "dataXml[" + dataXml + "]formXml[" + formXml + "]";
  292. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("CLIP.eForm SaveTempData param : " + paramLog);
  293. int reissueConsentMstRid = 0;
  294. string consentState = "TEMP";
  295. string paperYn = "N";
  296. string reasonForUseN = string.Empty;
  297. string verbal = string.Empty;
  298. byte[] byte64 = Convert.FromBase64String(dataXml);
  299. dataXml = Encoding.UTF8.GetString(byte64);
  300. if (!string.IsNullOrEmpty(dataXml))
  301. {
  302. Dictionary<string, string> outputDataDic;
  303. XmlDocument xmlDocument = new XmlDocument();
  304. xmlDocument.LoadXml(dataXml);
  305. outputDataDic = new Dictionary<string, string>();
  306. XmlNode rootNode = xmlDocument.SelectSingleNode("form-data");
  307. foreach (XmlNode childNode in rootNode.ChildNodes)
  308. {
  309. string fieldName = string.Empty;
  310. string fieldValue = string.Empty;
  311. XmlElement outFieldElement = childNode as XmlElement;
  312. if (outFieldElement == null)
  313. {
  314. }
  315. else
  316. {
  317. fieldName = outFieldElement.Name;
  318. if (outFieldElement.ChildNodes.Count == 1
  319. && outFieldElement.ChildNodes[0] is XmlCDataSection)
  320. {
  321. fieldValue = ((XmlCDataSection)outFieldElement.ChildNodes[0]).InnerText;
  322. if (!string.IsNullOrEmpty(fieldName) && fieldName.Equals("IO_verbal")
  323. && !string.IsNullOrEmpty(fieldValue) && fieldValue.Equals("Y"))
  324. {
  325. consentState = "VERBAL";
  326. break;
  327. }
  328. }
  329. else if (outFieldElement.ChildNodes.Count > 1)
  330. {
  331. foreach (XmlNode childNode2 in childNode.ChildNodes)
  332. {
  333. string fieldName2 = string.Empty;
  334. string fieldValue2 = string.Empty;
  335. XmlElement outFieldElement2 = childNode2 as XmlElement;
  336. fieldName2 = outFieldElement2.Name;
  337. if (outFieldElement2.ChildNodes.Count > 0
  338. && outFieldElement2.ChildNodes[0] is XmlCDataSection)
  339. {
  340. fieldValue2 = ((XmlCDataSection)outFieldElement2.ChildNodes[0]).InnerText;
  341. if (!string.IsNullOrEmpty(fieldName2) && fieldName2.Equals("IO_verbal")
  342. && !string.IsNullOrEmpty(fieldValue2) && fieldValue2.Equals("Y"))
  343. {
  344. consentState = "VERBAL";
  345. break;
  346. }
  347. }
  348. }
  349. }
  350. }
  351. }
  352. }
  353. rewriteConsentMstRid = 0;
  354. consentMstRid = SaveData(userId, patientCode, clnDeptCode, formRid, formCd,
  355. consentMstRid, rewriteConsentMstRid, reissueConsentMstRid, consentState, paperYn, formXml, dataXml,
  356. deviceType, deviceIdentNo, vistType, hosType, clnDate,
  357. ward, roomcd, reasonForUseN, orderNo, orderName, orderCd, ocrCode, cretno,
  358. createUserName, modifyUserName, null, null, null, mainDrId);
  359. return consentMstRid;
  360. }
  361. /// <summary>
  362. /// 전자 동의서를 완료저장 한다.
  363. /// </summary>
  364. /// <param name="userId">로그인 사용자ID</param>
  365. /// <param name="patientCode">환자 등록번호</param>
  366. /// <param name="clnDeptCode">진료과 코드</param>
  367. /// <param name="formRid">(작성대상)서식 Rid</param>
  368. /// <param name="formCd">서식코드</param>
  369. /// <param name="consentMstRid">동의서 마스터 데이터 Rid</param>
  370. /// <param name="rewriteConsentMstRid">재 작성 대상 동의서 마스터 데이터 Rid</param>
  371. /// <param name="formXml">동의서 EPT Xml</param>
  372. /// <param name="dataXml">동의서 Data(필드들) Xml</param>
  373. /// <param name="deviceType">장비 유형 (WIN, AND, IOS, PRT 중1)</param>
  374. /// <param name="deviceIdentNo">장비 고유 식별자</param>
  375. /// <param name="vistType">내원구분</param>
  376. /// <param name="hosType">병원 구분</param>
  377. /// <param name="clnDate">병원 구분이 "I" 일 경우 입원일자/병원 구분이 "O"일 경우 진료일자</param>
  378. /// <param name="ward">병동 코드</param>
  379. /// <param name="roomcd">병실 코드</param>
  380. /// <param name="orderNo">처방번호</param>
  381. /// <param name="orderCd">처방코드</param>
  382. /// <param name="orderName">처방명</param>
  383. /// <param name="createUserName">작성자명</param>
  384. /// <param name="modifyUserName">수정자명</param>
  385. /// <param name="mainDrId">주치의 아이디</param>
  386. [WebMethod(Description = "동의서 서명 완료")]
  387. public int SaveComplete(string userId, string patientCode, string clnDeptCode, int formRid, string formCd,
  388. int consentMstRid, int rewriteConsentMstRid, string formXml, string dataXml,
  389. string deviceType, string deviceIdentNo, string vistType, string hosType, string clnDate,
  390. string ward, string roomcd, int orderNo, string orderName, string orderCd, string ocrCode, int cretno,
  391. string createUserName, string modifyUserName, string mainDrId)
  392. {
  393. int reissueConsentMstRid = 0;
  394. string consentState = "ELECTR_CMP";
  395. string paperYn = "N";
  396. string reasonForUseN = string.Empty;
  397. rewriteConsentMstRid = 0;
  398. consentMstRid = SaveData(userId, patientCode, clnDeptCode, formRid, formCd,
  399. consentMstRid, rewriteConsentMstRid, reissueConsentMstRid, consentState, paperYn, formXml, dataXml,
  400. deviceType, deviceIdentNo, vistType, hosType, clnDate,
  401. ward, roomcd, reasonForUseN, orderNo, orderName, orderCd, ocrCode, cretno,
  402. createUserName, modifyUserName, null, null, null, mainDrId);
  403. return consentMstRid;
  404. }
  405. /// <summary>
  406. /// 전자 동의서를 완료저장 한다.
  407. /// </summary>
  408. /// <param name="userId">로그인 사용자ID</param>
  409. /// <param name="patientCode">환자 등록번호</param>
  410. /// <param name="clnDeptCode">진료과 코드</param>
  411. /// <param name="formRid">(작성대상)서식 Rid</param>
  412. /// <param name="formCd">서식코드</param>
  413. /// <param name="consentMstRid">동의서 마스터 데이터 Rid</param>
  414. /// <param name="rewriteConsentMstRid">재 작성 대상 동의서 마스터 데이터 Rid</param>
  415. /// <param name="formXml">동의서 EPT Xml</param>
  416. /// <param name="dataXml">동의서 Data(필드들) Xml</param>
  417. /// <param name="deviceType">장비 유형 (WIN, AND, IOS, PRT 중1)</param>
  418. /// <param name="deviceIdentNo">장비 고유 식별자</param>
  419. /// <param name="vistType">내원구분</param>
  420. /// <param name="hosType">병원 구분</param>
  421. /// <param name="clnDate">병원 구분이 "I" 일 경우 입원일자/병원 구분이 "O"일 경우 진료일자</param>
  422. /// <param name="ward">병동 코드</param>
  423. /// <param name="roomcd">병실 코드</param>
  424. /// <param name="orderNo">처방번호</param>
  425. /// <param name="orderCd">처방코드</param>
  426. /// <param name="orderName">처방명</param>
  427. /// <param name="createUserName">작성자명</param>
  428. /// <param name="modifyUserName">수정자명</param>
  429. /// <param name="imageFileJson">이미지 파일 정보(전자동의서 서버)</param>
  430. /// <param name="certTarget">이미지 파일 공인인증 대상정보</param>
  431. /// <param name="certResult">이미지 파일 공인인증 처리정보</param>
  432. /// <param name="dschdd">퇴원일자</param>
  433. /// <param name="consentState">상태</param>
  434. /// <param name="mainDrId">주치의 아이디</param>
  435. [WebMethod(Description = "동의서 서명 완료")]
  436. public int SaveCompleteAll(string userId, string patientCode, string clnDeptCode, int formRid, string formCd,
  437. int consentMstRid, int rewriteConsentMstRid, string formXml, string dataXml,
  438. string deviceType, string deviceIdentNo, string vistType, string hosType, string clnDate,
  439. string ward, string roomcd, int orderNo, string orderName, string orderCd, string ocrCode, int cretno,
  440. string createUserName, string modifyUserName, string imageFileJson, string certTarget, string certResult,
  441. string dschdd, string consentState, string mainDrId)
  442. {
  443. string paramLog = "";
  444. paramLog += "clnDept[" + userId + "]patientCode[" + patientCode + "]clnDeptCode[" + clnDeptCode + "]formRid[" + formRid + "]";
  445. paramLog += "formCd[" + formCd + "]consentMstRid[" + consentMstRid + "]rewriteConsentMstRid[" + rewriteConsentMstRid + "]";
  446. paramLog += "deviceType[" + deviceType + "]vistType[" + vistType + "]hosType[" + hosType + "]";
  447. paramLog += "clnDate[" + clnDate + "]ward[" + ward + "]roomcd[" + roomcd + "]orderNo[" + orderNo + "]";
  448. paramLog += "orderName[" + orderName + "]orderCd[" + orderCd + "]ocrCode[" + ocrCode + "]cretno[" + cretno + "]";
  449. paramLog += "createUserName[" + createUserName + "]modifyUserName[" + modifyUserName + "]imageFileJson[" + imageFileJson + "]certTarget[" + certTarget + "]";
  450. paramLog += "dschdd[" + dschdd + "]consentState[" + consentState + "]mainDrId[" + mainDrId + "]";
  451. paramLog += "dataXml[" + dataXml + "]formXml[" + formXml + "]certResult[" + certResult + "]";
  452. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("CLIP.eForm SaveCompleteAll param : " + paramLog);
  453. int reissueConsentMstRid = 0;
  454. string paperYn = "N";
  455. string reasonForUseN = string.Empty;
  456. byte[] byte64 = Convert.FromBase64String(dataXml);
  457. dataXml = Encoding.UTF8.GetString(byte64);
  458. rewriteConsentMstRid = 0;
  459. consentMstRid = SaveDataAll(userId, patientCode, clnDeptCode, formRid, formCd,
  460. consentMstRid, rewriteConsentMstRid, reissueConsentMstRid, consentState, paperYn, formXml, dataXml,
  461. deviceType, deviceIdentNo, vistType, hosType, clnDate,
  462. ward, roomcd, reasonForUseN, orderNo, orderName, orderCd, ocrCode, cretno,
  463. createUserName, modifyUserName, imageFileJson, certTarget, certResult, dschdd, mainDrId);
  464. return consentMstRid;
  465. }
  466. /// <summary>
  467. /// 동의서 삭제/폐기 데이터를 저장 한다.
  468. /// </summary>
  469. /// <param name="userId">로그인 사용자ID</param>
  470. /// <param name="consentMstRid">동의서 마스터 데이터 Rid</param>
  471. /// <param name="patientCode">환자 등록번호</param>
  472. /// <param name="clnDeptCode">진료과 코드</param>
  473. /// <param name="ward">병동 코드</param>
  474. /// <param name="formRid">(작성대상)서식 Rid</param>
  475. /// <param name="rewriteConsentMstRid">재 작성 대상 동의서 마스터 데이터 Rid</param>
  476. /// <param name="reissueConsentMstRid">삭제/폐기 대상 동의서 마스터 데이터 Rid</param>
  477. /// <param name="consentState">동의서 상태</param>
  478. /// <param name="deviceIdentNo">장비 고유 식별자</param>
  479. /// <param name="reasonForUseN">삭제/폐기 사유</param>
  480. [WebMethod(Description = "동의서 삭제/폐기 데이터를 저장")]
  481. public int SaveDelete(string userId, int consentMstRidInt, string patientCode, string clnDeptCode,
  482. string ward, string roomcd, int formRid, int rewriteConsentMstRid, int reissueConsentMstRid,
  483. string consentState, string deviceIdentNo, string reasonForUseN )
  484. {
  485. string paperYn = "N";
  486. consentMstRidInt = SaveData(userId, patientCode, clnDeptCode, formRid, null,
  487. consentMstRidInt, rewriteConsentMstRid, reissueConsentMstRid, consentState, paperYn, null, null,
  488. null, deviceIdentNo, null, null, null,
  489. ward, roomcd, reasonForUseN, 0, null, null, null, 0,
  490. null, null, null, null, null, null);
  491. return consentMstRidInt;
  492. }
  493. /// <summary>
  494. /// 프린트 출력 후 데이터를 저장 한다.
  495. /// </summary>
  496. /// <param name="userId">로그인 사용자ID</param>
  497. /// <param name="patientCode">환자 등록번호</param>
  498. /// <param name="clnDeptCode">진료과 코드</param>
  499. /// <param name="formRid">(작성대상)서식 Rid</param>
  500. /// <param name="formCd">서식코드</param>
  501. /// <param name="consentMstRid">동의서 마스터 데이터 Rid</param>
  502. /// <param name="rewriteConsentMstRid">재 작성 대상 동의서 마스터 데이터 Rid</param>
  503. /// <param name="formXml">동의서 EPT Xml</param>
  504. /// <param name="dataXml">동의서 Data(필드들) Xml</param>
  505. /// <param name="deviceType">장비 유형 (WIN, AND, IOS, PRT 중1)</param>
  506. /// <param name="deviceIdentNo">장비 고유 식별자</param>
  507. /// <param name="vistType">내원구분</param>
  508. /// <param name="hosType">병원 구분</param>
  509. /// <param name="clnDate">병원 구분이 "I" 일 경우 입원일자/병원 구분이 "O"일 경우 진료일자</param>
  510. /// <param name="ward">병동 코드</param>
  511. /// <param name="roomcd">병실 코드</param>
  512. /// <param name="orderNo">처방번호</param>
  513. /// <param name="orderName">처방명</param>
  514. /// <param name="orderCd">처방코드</param>
  515. /// <param name="ocrCode">OCR코드</param>
  516. /// <param name="cretno">생성번호</param>
  517. /// <param name="createUserName">작성자명</param>
  518. /// <param name="modifyUserName">수정자명</param>
  519. /// <param name="mainDrId">주치의 아이디</param>
  520. [WebMethod(Description = "동의서 프린트 출력 후 데이터를 저장")]
  521. public int SavePrintOut(string userId, string patientCode, string clnDeptCode, int formRid, string formCd,
  522. int consentMstRid, int reissueConsentMstRid, string formXml, string dataXml,
  523. string deviceType, string deviceIdentNo, string vistType, string hosType, string clnDate,
  524. string ward, string roomcd, int orderNo, string orderName, string orderCd, string ocrCode, int cretno,
  525. string createUserName, string modifyUserName, string mainDrId)
  526. {
  527. string consentState = "PAPER_OUT";
  528. string paperYn = "Y";
  529. consentMstRid = SavePrintData(userId, patientCode, clnDeptCode, formRid, formCd,
  530. consentMstRid, 0, reissueConsentMstRid, consentState, paperYn, formXml, dataXml,
  531. deviceType, deviceIdentNo, vistType, hosType, clnDate,
  532. ward, roomcd, null, orderNo, orderName, orderCd, ocrCode, cretno,
  533. createUserName, modifyUserName, null, null, null, mainDrId);
  534. return consentMstRid;
  535. }
  536. /// <summary>
  537. /// 동의서의 기왕력 데이터 저장
  538. /// </summary>
  539. /// <param name="patientCode">환자 등록번호</param>
  540. /// <param name="clnDate">진료일</param>
  541. /// <param name="bp">고/저혈압</param>
  542. /// <param name="dm">당뇨병</param>
  543. /// <param name="heart">심장질환</param>
  544. /// <param name="kidney">신장질환</param>
  545. /// <param name="respiration">호흡기질환</param>
  546. /// <param name="hx">과거병력</param>
  547. /// <param name="allergy">알레르기</param>
  548. /// <param name="drug">복용약물</param>
  549. /// <param name="smoking">흡연상태</param>
  550. /// <param name="idio">특이체질</param>
  551. /// <param name="nacrotics">마약사고</param>
  552. /// <param name="airway">기도이상 유무</param>
  553. /// <param name="hemorrhage">출혈소인</param>
  554. /// <param name="status_etc">기타</param>
  555. /// <param name="userId">로그인 사용자ID</param>
  556. [WebMethod(Description = "동의서의 기왕력 데이터 저장")]
  557. public string SaveMedicalHistory(string patientCode, string clnDate,
  558. string bp, string dm, string heart, string kidney, string respiration,
  559. string hx, string allergy, string drug, string smoking,
  560. string idio, string nacrotics, string airway, string hemorrhage, string status_etc,
  561. string userId)
  562. {
  563. try
  564. {
  565. using (SaveConsentDac dac = new SaveConsentDac())
  566. {
  567. Hashtable paramHashTable = new Hashtable();
  568. paramHashTable.Add("patientCode", patientCode);
  569. paramHashTable.Add("clnDate", clnDate);
  570. paramHashTable.Add("bp", bp);
  571. paramHashTable.Add("dm", dm);
  572. paramHashTable.Add("heart", heart);
  573. paramHashTable.Add("kidney", kidney);
  574. paramHashTable.Add("respiration", respiration);
  575. paramHashTable.Add("hx", hx);
  576. paramHashTable.Add("allergy", allergy);
  577. paramHashTable.Add("drug", drug);
  578. paramHashTable.Add("smoking", smoking);
  579. paramHashTable.Add("idio", idio);
  580. paramHashTable.Add("nacrotics", nacrotics);
  581. paramHashTable.Add("airway", airway);
  582. paramHashTable.Add("hemorrhage", hemorrhage);
  583. paramHashTable.Add("status_etc", status_etc);
  584. paramHashTable.Add("userId", userId);
  585. dac.SetMediHistory(this.IbatisMapper, paramHashTable);
  586. }
  587. }
  588. catch (Exception ex)
  589. {
  590. if (this.IbatisSession != null) this.IbatisSession.RollBackTransaction();
  591. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm SaveMedicalHistory ERROR : [{0}]", ex.ToString()));
  592. throw ex;
  593. }
  594. finally
  595. {
  596. }
  597. return patientCode;
  598. }
  599. /// <summary>
  600. /// 동의서 서명 완료일 경우 이미지 데이터 저장
  601. /// </summary>
  602. /// <param name="consentState">동의서 상태</param>
  603. /// <param name="imageFileName">이미지파일명(경로포함)</param>
  604. /// <param name="consentMstRid">동의서 마스터 데이터 Rid</param>
  605. /// <param name="userId">등록자ID</param>
  606. /// <param name="formRid">동의서 FORM ID</param>
  607. [WebMethod(Description = "동의서 서명 완료일 경우 이미지 데이터 저장")]
  608. public int SaveImageUploadInfo(string consentState, string imageFileName, int consentMstRid, string userId, int formRid)
  609. {
  610. int consentImageRid = 0;
  611. if (!string.IsNullOrEmpty(consentState) && consentState == "ELECTR_CMP")
  612. {
  613. using (SaveConsentDac dac = new SaveConsentDac())
  614. {
  615. Hashtable imageHashTable = new Hashtable();
  616. imageHashTable.Add("consentMstRid", consentMstRid);
  617. consentImageRid = this.GetSequence("CONSENT_IMAGE");
  618. imageHashTable.Add("consentImageRid", consentImageRid);
  619. imageHashTable.Add("userId", userId);
  620. imageHashTable.Add("formRid", formRid);
  621. imageHashTable.Add("imagePath", imageFileName.Substring(0, imageFileName.LastIndexOf("\\")));
  622. imageHashTable.Add("imageFilename", imageFileName.Substring(imageFileName.LastIndexOf("\\") + 1));
  623. imageHashTable.Add("completeYn", "Y"); //paramHashTable["completeYn"]
  624. dac.InsertConsentImage(this.IbatisMapper, imageHashTable);
  625. }
  626. }
  627. return consentImageRid;
  628. }
  629. /// <summary>
  630. /// 서명완료된 이미지의 hash 정보 저장
  631. /// </summary>
  632. /// <param name="consentState">동의서 상태</param>
  633. /// <param name="consentMstRid">동의서 마스터 데이터 Rid</param>
  634. /// <param name="consentImageRid">이미지 데이터 Rid</param>
  635. /// <param name="userId">등록자ID</param>
  636. /// <param name="certTarget">hash 정보</param>
  637. [WebMethod(Description = "서명완료된 이미지의 hash 정보 저장")]
  638. public void SaveImageSignInfo(string consentState, int consentMstRid, int consentImageRid, string userId, string certTarget, string sCertResult)
  639. {
  640. string paramLog = "";
  641. paramLog += "consentState[" + consentState + "]consentMstRid[" + consentMstRid + "]consentImageRid[" + consentImageRid + "]userId[" + userId + "]";
  642. paramLog += "certTarget[" + certTarget + "]sCertResult[" + sCertResult + "]";
  643. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("CLIP.eForm SaveTempData param : " + paramLog);
  644. if (!string.IsNullOrEmpty(consentState) && consentState == "ELECTR_CMP")
  645. {
  646. using (SaveConsentDac dac = new SaveConsentDac())
  647. {
  648. Hashtable imageHashTable = new Hashtable();
  649. imageHashTable.Add("consentMstRid", consentMstRid);
  650. imageHashTable.Add("consentImageRid", consentImageRid);
  651. imageHashTable.Add("certTarget", certTarget);
  652. imageHashTable.Add("certResult", sCertResult);
  653. imageHashTable.Add("userId", userId);
  654. dac.InsertConsentImageSign(this.IbatisMapper, imageHashTable);
  655. imageHashTable.Add("consentState", "CERTIFY_CMP");
  656. dac.UpdateConsentMstStatus(this.IbatisMapper, imageHashTable);
  657. }
  658. }
  659. }
  660. private int SaveData(string userId, string patientCode, string clnDeptCode, int formRid, string formCd,
  661. int consentMstRid, int rewriteConsentMstRid, int reissueConsentMstRid, string consentState, string paperYn, string formXml, string dataXml,
  662. string deviceType, string deviceIdentNo, string vistType, string hosType, string clnDate,
  663. string ward, string roomcd, string reasonForUseN, int orderNo, string orderName, string orderCd, string ocrCode, int cretno,
  664. string createUserName, string modifyUserName, string imageFileName, string certTarget, string certResult,
  665. string mainDrId)
  666. {
  667. bool isNewConsentMasterCase = false;
  668. if (consentMstRid < 1)
  669. {
  670. isNewConsentMasterCase = true;
  671. }
  672. try
  673. {
  674. using (SaveConsentDac dac = new SaveConsentDac())
  675. {
  676. Hashtable paramHashTable = GetParamHashTable(userId, patientCode, clnDeptCode, formRid, formCd, consentMstRid, rewriteConsentMstRid,
  677. reissueConsentMstRid, consentState, paperYn, formXml, dataXml, deviceType, deviceIdentNo,
  678. vistType, hosType, clnDate, ward, roomcd, reasonForUseN,
  679. orderNo, orderName, orderCd, ocrCode, cretno, createUserName, modifyUserName,
  680. certTarget, certResult, mainDrId);
  681. consentMstRid = (int)paramHashTable["consentMstRid"];
  682. //새로 작성하는 경우
  683. if (isNewConsentMasterCase)
  684. {
  685. dac.InsertConsentMst(this.IbatisMapper, paramHashTable);
  686. dac.InsertConsentData(this.IbatisMapper, paramHashTable);
  687. //ImageUploadInfo(dac, consentState, imageFileName, paramHashTable, consentMstRid, userId, formRid, deviceType);
  688. }
  689. //새로 작성 아닌 경우
  690. else
  691. {
  692. if (reissueConsentMstRid > 0)
  693. {
  694. if (string.IsNullOrEmpty(reasonForUseN))
  695. {
  696. //종이->종이 재발행
  697. int newConsentMstRid = this.GetSequence("CONSENT_MST");
  698. paramHashTable["consentMstRid"] = newConsentMstRid;
  699. consentMstRid = newConsentMstRid;
  700. dac.InsertConsentMst(this.IbatisMapper, paramHashTable);
  701. dac.InsertConsentData(this.IbatisMapper, paramHashTable);
  702. //ImageUploadInfo(dac, consentState, imageFileName, paramHashTable, consentMstRid, userId, formRid, deviceType);
  703. }
  704. else
  705. {
  706. dac.UpdateConsentMstForDelete(this.IbatisMapper, paramHashTable);
  707. }
  708. }
  709. //임시저장 또는 저장인 경우
  710. else
  711. {
  712. dac.UpdateConsentMst(this.IbatisMapper, paramHashTable);
  713. dac.InsertConsentData(this.IbatisMapper, paramHashTable);
  714. //ImageUploadInfo(dac, consentState, imageFileName, paramHashTable, consentMstRid, userId, formRid, deviceType);
  715. }
  716. }
  717. if (!string.IsNullOrEmpty(dataXml))
  718. {
  719. Dictionary<string, string> outputDataDic = DataXmlToDictionary(dataXml);
  720. Hashtable paramHashTableForMediHistory = new Hashtable();
  721. paramHashTableForMediHistory.Add("patientCode", patientCode);
  722. paramHashTableForMediHistory.Add("clnDate", clnDate.Replace("-", ""));
  723. paramHashTableForMediHistory.Add("bp", outputDataDic.ContainsKey("IO_bp") ? outputDataDic["IO_bp"] : "");
  724. paramHashTableForMediHistory.Add("dm", outputDataDic.ContainsKey("IO_dm") ? outputDataDic["IO_dm"] : "");
  725. paramHashTableForMediHistory.Add("heart", outputDataDic.ContainsKey("IO_heart") ? outputDataDic["IO_heart"] : "");
  726. paramHashTableForMediHistory.Add("kidney", outputDataDic.ContainsKey("IO_kidney") ? outputDataDic["IO_kidney"] : "");
  727. paramHashTableForMediHistory.Add("respiration", outputDataDic.ContainsKey("IO_respiration") ? outputDataDic["IO_respiration"] : "");
  728. paramHashTableForMediHistory.Add("hx", outputDataDic.ContainsKey("IO_hx") ? outputDataDic["IO_hx"] : "");
  729. paramHashTableForMediHistory.Add("allergy", outputDataDic.ContainsKey("IO_allergy") ? outputDataDic["IO_allergy"] : "");
  730. paramHashTableForMediHistory.Add("drug", outputDataDic.ContainsKey("IO_drug") ? outputDataDic["IO_drug"] : "");
  731. paramHashTableForMediHistory.Add("smoking", outputDataDic.ContainsKey("IO_smoking") ? outputDataDic["IO_smoking"] : "");
  732. paramHashTableForMediHistory.Add("idio", outputDataDic.ContainsKey("IO_idio") ? outputDataDic["IO_idio"] : "");
  733. paramHashTableForMediHistory.Add("nacrotics", outputDataDic.ContainsKey("IO_nacrotics") ? outputDataDic["IO_nacrotics"] : "");
  734. paramHashTableForMediHistory.Add("airway", outputDataDic.ContainsKey("IO_airway") ? outputDataDic["IO_airway"] : "");
  735. paramHashTableForMediHistory.Add("hemorrhage", outputDataDic.ContainsKey("IO_hemorrhage") ? outputDataDic["IO_hemorrhage"] : "");
  736. paramHashTableForMediHistory.Add("status_etc", outputDataDic.ContainsKey("IO_status_etc") ? outputDataDic["IO_status_etc"] : "");
  737. paramHashTableForMediHistory.Add("userId", userId);
  738. dac.SetMediHistory(this.IbatisMapper, paramHashTableForMediHistory);
  739. }
  740. }
  741. }
  742. catch (Exception ex)
  743. {
  744. if (this.IbatisSession != null) this.IbatisSession.RollBackTransaction();
  745. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm SaveData ERROR : [{0}]", ex.ToString()));
  746. throw ex;
  747. }
  748. finally
  749. {
  750. }
  751. return consentMstRid;
  752. }
  753. private int SaveDataAll(string userId, string patientCode, string clnDeptCode, int formRid, string formCd,
  754. int consentMstRid, int rewriteConsentMstRid, int reissueConsentMstRid, string consentState, string paperYn, string formXml, string dataXml,
  755. string deviceType, string deviceIdentNo, string vistType, string hosType, string clnDate,
  756. string ward, string roomcd, string reasonForUseN, int orderNo, string orderName, string orderCd, string ocrCode, int cretno,
  757. string createUserName, string modifyUserName, string imageFileJson, string certTarget,
  758. string certResult, string dschdd, string mainDrId)
  759. {
  760. bool isNewConsentMasterCase = false;
  761. if (consentMstRid < 1)
  762. {
  763. isNewConsentMasterCase = true;
  764. }
  765. try
  766. {
  767. using (SaveConsentDac dac = new SaveConsentDac())
  768. {
  769. Hashtable paramHashTable = GetParamHashTable(userId, patientCode, clnDeptCode, formRid, formCd, consentMstRid, rewriteConsentMstRid,
  770. reissueConsentMstRid, consentState, paperYn, formXml, dataXml, deviceType, deviceIdentNo,
  771. vistType, hosType, clnDate, ward, roomcd, reasonForUseN,
  772. orderNo, orderName, orderCd, ocrCode, cretno, createUserName, modifyUserName,
  773. certTarget, certResult, mainDrId);
  774. consentMstRid = (int)paramHashTable["consentMstRid"];
  775. //새로 작성하는 경우
  776. if (isNewConsentMasterCase)
  777. {
  778. dac.InsertConsentMst(this.IbatisMapper, paramHashTable);
  779. dac.InsertConsentData(this.IbatisMapper, paramHashTable);
  780. imageUpload(dac, paramHashTable, userId
  781. , patientCode, vistType, clnDate, dschdd, cretno, ocrCode
  782. , consentMstRid, consentState, formCd, formRid, dataXml, imageFileJson, certTarget, certResult, hosType, createUserName);
  783. }
  784. //새로 작성 아닌 경우
  785. else
  786. {
  787. if (reissueConsentMstRid > 0)
  788. {
  789. if (string.IsNullOrEmpty(reasonForUseN))
  790. {
  791. //종이->종이 재발행
  792. int newConsentMstRid = this.GetSequence("CONSENT_MST");
  793. paramHashTable["consentMstRid"] = newConsentMstRid;
  794. consentMstRid = newConsentMstRid;
  795. dac.InsertConsentMst(this.IbatisMapper, paramHashTable);
  796. dac.InsertConsentData(this.IbatisMapper, paramHashTable);
  797. imageUpload(dac, paramHashTable, userId
  798. , patientCode, vistType, clnDate, dschdd, cretno, ocrCode
  799. , consentMstRid, consentState, formCd, formRid, dataXml, imageFileJson, certTarget, certResult, hosType, createUserName);
  800. }
  801. else
  802. {
  803. dac.UpdateConsentMstForDelete(this.IbatisMapper, paramHashTable);
  804. }
  805. }
  806. //임시저장 또는 저장인 경우
  807. else
  808. {
  809. dac.UpdateConsentMst(this.IbatisMapper, paramHashTable);
  810. dac.InsertConsentData(this.IbatisMapper, paramHashTable);
  811. imageUpload(dac, paramHashTable, userId
  812. , patientCode, vistType, clnDate, dschdd, cretno, ocrCode
  813. , consentMstRid, consentState, formCd, formRid, dataXml, imageFileJson, certTarget, certResult, hosType, createUserName);
  814. }
  815. }
  816. if (!string.IsNullOrEmpty(dataXml))
  817. {
  818. Dictionary<string, string> outputDataDic = DataXmlToDictionary(dataXml);
  819. Hashtable paramHashTableForMediHistory = new Hashtable();
  820. paramHashTableForMediHistory.Add("patientCode", patientCode);
  821. paramHashTableForMediHistory.Add("clnDate", clnDate.Replace("-", ""));
  822. paramHashTableForMediHistory.Add("bp", outputDataDic.ContainsKey("IO_bp") ? outputDataDic["IO_bp"] : "");
  823. paramHashTableForMediHistory.Add("dm", outputDataDic.ContainsKey("IO_dm") ? outputDataDic["IO_dm"] : "");
  824. paramHashTableForMediHistory.Add("heart", outputDataDic.ContainsKey("IO_heart") ? outputDataDic["IO_heart"] : "");
  825. paramHashTableForMediHistory.Add("kidney", outputDataDic.ContainsKey("IO_kidney") ? outputDataDic["IO_kidney"] : "");
  826. paramHashTableForMediHistory.Add("respiration", outputDataDic.ContainsKey("IO_respiration") ? outputDataDic["IO_respiration"] : "");
  827. paramHashTableForMediHistory.Add("hx", outputDataDic.ContainsKey("IO_hx") ? outputDataDic["IO_hx"] : "");
  828. paramHashTableForMediHistory.Add("allergy", outputDataDic.ContainsKey("IO_allergy") ? outputDataDic["IO_allergy"] : "");
  829. paramHashTableForMediHistory.Add("drug", outputDataDic.ContainsKey("IO_drug") ? outputDataDic["IO_drug"] : "");
  830. paramHashTableForMediHistory.Add("smoking", outputDataDic.ContainsKey("IO_smoking") ? outputDataDic["IO_smoking"] : "");
  831. paramHashTableForMediHistory.Add("idio", outputDataDic.ContainsKey("IO_idio") ? outputDataDic["IO_idio"] : "");
  832. paramHashTableForMediHistory.Add("nacrotics", outputDataDic.ContainsKey("IO_nacrotics") ? outputDataDic["IO_nacrotics"] : "");
  833. paramHashTableForMediHistory.Add("airway", outputDataDic.ContainsKey("IO_airway") ? outputDataDic["IO_airway"] : "");
  834. paramHashTableForMediHistory.Add("hemorrhage", outputDataDic.ContainsKey("IO_hemorrhage") ? outputDataDic["IO_hemorrhage"] : "");
  835. paramHashTableForMediHistory.Add("status_etc", outputDataDic.ContainsKey("IO_status_etc") ? outputDataDic["IO_status_etc"] : "");
  836. paramHashTableForMediHistory.Add("userId", userId);
  837. dac.SetMediHistory(this.IbatisMapper, paramHashTableForMediHistory);
  838. }
  839. }
  840. }
  841. catch (Exception ex)
  842. {
  843. if (this.IbatisSession != null) this.IbatisSession.RollBackTransaction();
  844. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm SaveDataAll ERROR : [{0}]", ex.ToString()));
  845. throw ex;
  846. }
  847. finally
  848. {
  849. }
  850. return consentMstRid;
  851. }
  852. private void imageUpload(SaveConsentDac dac
  853. , Hashtable paramHashTable
  854. , string userId
  855. , string patientCode
  856. , string visitType
  857. , string clnDate
  858. , string Dschdd
  859. , int cretno
  860. , string ocrcode
  861. , int consentMstRid
  862. , string consentState
  863. , string formCd
  864. , int formRid
  865. , string dataXml
  866. , string imageFileJson
  867. , string certTarget
  868. , string certResult
  869. , string hosType
  870. , string createUserName
  871. )
  872. {
  873. // 서명 저장일 경우 emrindxm 테이블에 저장
  874. if (!string.IsNullOrEmpty(consentState) && ( consentState.Equals("ELECTR_CMP") || consentState.Equals("CERTIFY_CMP")) )
  875. {
  876. string clnDeptCode = paramHashTable["clnDeptCd"] == null ? string.Empty : paramHashTable["clnDeptCd"].ToString();
  877. try
  878. {
  879. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("CLIP.eForm File Upload imageFileJson[{0}]", imageFileJson));
  880. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("CLIP.eForm File Upload consentState[{0}]", consentState));
  881. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("CLIP.eForm File Upload certTarget[{0}]", certTarget));
  882. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("CLIP.eForm File Upload paramHashTable[certTarget[{0}]", paramHashTable["certTarget"]));
  883. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("CLIP.eForm File Upload certResult[{0}]", certResult));
  884. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("CLIP.eForm File Upload paramHashTable[certResult[{0}]", paramHashTable["certResult"]));
  885. int consentImageRid = this.GetSequence("CONSENT_IMAGE");
  886. //if (consentState.Equals("CERTIFY_CMP"))
  887. //{
  888. paramHashTable.Add("consentImageRid", consentImageRid);
  889. // 사인정보 저장
  890. dac.InsertConsentImageSign(this.IbatisMapper, paramHashTable);
  891. //}
  892. string sPath = string.Empty;
  893. string sFileName = string.Empty;
  894. string newFileFullName = string.Empty;
  895. if (!string.IsNullOrEmpty(imageFileJson))
  896. {
  897. Dictionary<string, object> jsonRoot = null;
  898. jsonRoot = fastJSON.JSON.Parse(imageFileJson) as Dictionary<string, object>;
  899. if (jsonRoot != null && jsonRoot.Count > 0)
  900. {
  901. Hashtable imageHashTable = new Hashtable();
  902. int nowCnt = 1;
  903. foreach (KeyValuePair<string, object> jr in jsonRoot)
  904. {
  905. imageHashTable = new Hashtable();
  906. imageHashTable.Add("consentMstRid", consentMstRid);
  907. if(nowCnt > 1) consentImageRid = this.GetSequence("CONSENT_IMAGE");
  908. imageHashTable.Add("consentImageRid", consentImageRid);
  909. imageHashTable.Add("userId", userId);
  910. imageHashTable.Add("formRid", formRid);
  911. if (jr.Value != null && !string.IsNullOrEmpty(jr.Value.ToString()))
  912. {
  913. sPath = "";
  914. sFileName = "";
  915. string[] filepath = jr.Value.ToString().Split('/');
  916. for (int i = 0; i < filepath.Length; i++)
  917. {
  918. if (i == 0)
  919. {
  920. sPath = filepath[i];
  921. }
  922. else if ((i + 1) == filepath.Length)
  923. {
  924. sFileName = filepath[i];
  925. }
  926. else
  927. {
  928. sPath += "/" + filepath[i];
  929. }
  930. }
  931. newFileFullName = string.Empty;
  932. using (HospitalSvc hospitalWebService = new HospitalSvc())
  933. {
  934. newFileFullName = hospitalWebService.GetFileName(patientCode, visitType,
  935. clnDate.Replace("-", ""), Dschdd, string.Format("{0}", cretno),
  936. "500", formCd, nowCnt.ToString(),
  937. ocrcode, userId, clnDeptCode);
  938. }
  939. //if (string.IsNullOrEmpty(newFileFullName))
  940. string uploadFileName = newFileFullName + ".jpg";
  941. string sUploadPath = uploadFileName.Substring(0, uploadFileName.LastIndexOf("\\") + 1);
  942. string sUploadFileName = uploadFileName.Substring(uploadFileName.LastIndexOf("\\") + 1);
  943. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("CLIP.eForm File Upload localpath[{0}]", Server.MapPath(string.Format("./UPLOAD/{0}/{1}", sPath, sFileName))));
  944. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("CLIP.eForm File Upload uploadFileName[{0}]", uploadFileName));
  945. if(uploadFileName.Length > 5)
  946. {
  947. if (Convert.ToInt16(uploadFileName.Substring(5, 1)) < 10) {
  948. uploadFileName = string.Format("\\\\192.168.100.32\\image_a0{0}", uploadFileName.Substring(5));
  949. }
  950. else
  951. {
  952. uploadFileName = string.Format("\\\\192.168.100.32\\image_a{0}", uploadFileName.Substring(5));
  953. }
  954. }
  955. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("CLIP.eForm File Upload uploadFileName[{0}]", uploadFileName));
  956. //// 윈도우 계정으로 Impersonate
  957. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("CLIP.eForm File Upload Impersonate START workemr"));
  958. ClipSoft.Utility.ImpersonationUtility util = new ClipSoft.Utility.ImpersonationUtility();
  959. util.ImpersonationStart(string.Empty, "workemr", "workemr");
  960. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("CLIP.eForm File Upload Impersonate END"));
  961. // 디렉토리 존재여부 체크
  962. DirectoryInfo di = new DirectoryInfo(uploadFileName.Substring(0, uploadFileName.LastIndexOf("\\") + 1));
  963. if (di.Exists == false)
  964. {
  965. di.Create();
  966. }
  967. // 파일 저장
  968. System.IO.File.Copy(Server.MapPath(string.Format("./UPLOAD/{0}/{1}", sPath, sFileName)), uploadFileName);
  969. // Impersonate 종료
  970. util.ImpersonationEnd();
  971. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("CLIP.eForm File Upload Impersonate CLOSE"));
  972. imageHashTable.Add("imagePath", sUploadPath);
  973. imageHashTable.Add("imageFilename", sUploadFileName);
  974. imageHashTable.Add("completeYn", paramHashTable["completeYn"]);
  975. dac.InsertConsentImage(this.IbatisMapper, imageHashTable);
  976. }
  977. nowCnt++;
  978. }
  979. }
  980. }
  981. //if (patientCode.Equals("0586244"))
  982. //{
  983. // throw new Exception();
  984. //}
  985. }
  986. catch (Exception ex)
  987. {
  988. using (HospitalSvc hospitalWebService = new HospitalSvc())
  989. {
  990. hospitalWebService.delEformData(patientCode, visitType,
  991. clnDate.Replace("-", ""), Dschdd, string.Format("{0}", cretno),
  992. formCd, ocrcode, userId, createUserName, string.Format("{0}", consentMstRid), hosType,
  993. clnDeptCode);
  994. }
  995. if (this.IbatisSession != null) this.IbatisSession.RollBackTransaction();
  996. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm imageUpload ERROR : [{0}]", ex.ToString()));
  997. throw ex;
  998. }
  999. }
  1000. }
  1001. private int SavePrintData(string userId, string patientCode, string clnDeptCode, int formRid, string formCd,
  1002. int consentMstRid, int rewriteConsentMstRid, int reissueConsentMstRid, string consentState, string paperYn, string formXml, string dataXml,
  1003. string deviceType, string deviceIdentNo, string vistType, string hosType, string clnDate,
  1004. string ward, string roomcd, string reasonForUseN, int orderNo, string orderName, string orderCd, string ocrCode, int cretno,
  1005. string createUserName, string modifyUserName, string imageFileName, string certTarget,
  1006. string certResult, string mainDrId)
  1007. {
  1008. bool isNewConsentMasterCase = false;
  1009. if (consentMstRid < 1)
  1010. {
  1011. isNewConsentMasterCase = true;
  1012. }
  1013. try
  1014. {
  1015. using (SaveConsentDac dac = new SaveConsentDac())
  1016. {
  1017. Hashtable paramHashTable = GetParamHashTable(userId, patientCode, clnDeptCode, formRid, formCd, consentMstRid, rewriteConsentMstRid,
  1018. reissueConsentMstRid, consentState, paperYn, formXml, dataXml, deviceType, deviceIdentNo,
  1019. vistType, hosType, clnDate, ward, roomcd, reasonForUseN,
  1020. orderNo, orderName, orderCd, ocrCode, cretno, createUserName, modifyUserName,
  1021. certTarget, certResult, mainDrId);
  1022. consentMstRid = (int)paramHashTable["consentMstRid"];
  1023. //새로 출력하는 경우
  1024. if (isNewConsentMasterCase)
  1025. {
  1026. dac.InsertConsentMst(this.IbatisMapper, paramHashTable);
  1027. }
  1028. //새로 작성 아닌 경우
  1029. else
  1030. {
  1031. if (reissueConsentMstRid > 0)
  1032. dac.UpdateConsentMstForReissue(this.IbatisMapper, paramHashTable);
  1033. else
  1034. dac.UpdateConsentMst(this.IbatisMapper, paramHashTable);
  1035. }
  1036. }
  1037. }
  1038. catch (Exception ex)
  1039. {
  1040. if (this.IbatisSession != null) this.IbatisSession.RollBackTransaction();
  1041. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm SaveData ERROR : [{0}]", ex.ToString()));
  1042. throw ex;
  1043. }
  1044. finally
  1045. {
  1046. }
  1047. return consentMstRid;
  1048. }
  1049. private static Dictionary<string, string> DataXmlToDictionary(string dataXml)
  1050. {
  1051. Dictionary<string, string> outputDataDic;
  1052. XmlDocument xmlDocument = new XmlDocument();
  1053. xmlDocument.LoadXml(dataXml);
  1054. outputDataDic = new Dictionary<string, string>();
  1055. XmlNode rootNode = xmlDocument.SelectSingleNode("form-data");
  1056. foreach (XmlNode childNode in rootNode.ChildNodes)
  1057. {
  1058. string fieldName = string.Empty;
  1059. string fieldValue = string.Empty;
  1060. XmlElement outFieldElement = childNode as XmlElement;
  1061. if (outFieldElement == null)
  1062. {
  1063. }
  1064. else
  1065. {
  1066. fieldName = outFieldElement.Name;
  1067. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("DataXmlToDictionary 0 : {0}/{1}", outFieldElement.ChildNodes.Count, fieldName));
  1068. if (outFieldElement.ChildNodes.Count == 1
  1069. && outFieldElement.ChildNodes[0] is XmlCDataSection)
  1070. {
  1071. fieldValue = ((XmlCDataSection)outFieldElement.ChildNodes[0]).InnerText;
  1072. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("DataXmlToDictionary 1 : {0}/{1}", fieldName, fieldValue));
  1073. if (outputDataDic.ContainsKey(fieldName))
  1074. {
  1075. outputDataDic[fieldName] = fieldValue;
  1076. }
  1077. else
  1078. {
  1079. outputDataDic.Add(fieldName, fieldValue);
  1080. }
  1081. }
  1082. else if (outFieldElement.ChildNodes.Count > 1)
  1083. {
  1084. foreach (XmlNode childNode2 in childNode.ChildNodes)
  1085. {
  1086. string fieldName2 = string.Empty;
  1087. string fieldValue2 = string.Empty;
  1088. XmlElement outFieldElement2 = childNode2 as XmlElement;
  1089. fieldName2 = outFieldElement2.Name;
  1090. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("DataXmlToDictionary : {0}", fieldName2));
  1091. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("DataXmlToDictionary : {0}", outFieldElement2.ChildNodes.Count));
  1092. if (outFieldElement2.ChildNodes.Count > 0
  1093. && outFieldElement2.ChildNodes[0] is XmlCDataSection)
  1094. {
  1095. fieldValue2 = ((XmlCDataSection)outFieldElement2.ChildNodes[0]).InnerText;
  1096. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("DataXmlToDictionary 2 : {0}/{1}", fieldName2, fieldValue2));
  1097. }
  1098. if (outputDataDic.ContainsKey(fieldName2))
  1099. {
  1100. outputDataDic[fieldName2] = fieldValue2;
  1101. }
  1102. else
  1103. {
  1104. outputDataDic.Add(fieldName2, fieldValue2);
  1105. }
  1106. }
  1107. }
  1108. }
  1109. }
  1110. return outputDataDic;
  1111. }
  1112. /// <summary>
  1113. /// EFORM_CODE에 정의하는 시퀀스(채번)을 구한다.
  1114. /// </summary>
  1115. /// <param name="sSubCd"></param>
  1116. /// <returns></returns>
  1117. private int GetSequence(string sSubCd)
  1118. {
  1119. int nSeq = -1;
  1120. try
  1121. {
  1122. using (CommonCodeDac dac = new CommonCodeDac())
  1123. {
  1124. Code param = new Code();
  1125. param.sub_cd = sSubCd;
  1126. nSeq = dac.GetSequence(this.IbatisMapper, param);
  1127. if (nSeq == 0)
  1128. {
  1129. dac.InsertSequence(this.IbatisMapper, param);
  1130. nSeq = 1;
  1131. }
  1132. else
  1133. {
  1134. param.ud1_num = ++nSeq;
  1135. dac.UpdateSequence(this.IbatisMapper, param);
  1136. }
  1137. }
  1138. }
  1139. catch (Exception ex)
  1140. {
  1141. if (this.IbatisSession != null) this.IbatisSession.RollBackTransaction();
  1142. throw ex;
  1143. }
  1144. return nSeq;
  1145. }
  1146. #region GetParamHashTable
  1147. private Hashtable GetParamHashTable(string userId, // 사용자 Id
  1148. string patientCode, // 환자 등록번호
  1149. string clnDeptCode, // 진료과 코드
  1150. int formRid, // (작성대상)서식 Rid
  1151. string formCd, // 서식코드 === CONSENT_DATA_CHOICE에서 입력여부 판단할 파라미터
  1152. int consentMstRid, // 동의서 마스터 데이터 Rid
  1153. int rewriteConsentMstRid, // 재 작성 대상 동의서 마스터 데이터 Rid
  1154. int reissueConsentMstRid, // 재 발행 대상 동의서 마스터 데이터 Rid
  1155. string consentState, // 동의서 상태 (TEMP, PAPER_OUT, ELECTR_CMP, CERTIFY_CMP)
  1156. string paperYn, // 인쇄 발행 여부
  1157. string formXml, // 동의서 EPT Xml
  1158. string dataXml, // 동의서 Data(필드들) Xml
  1159. string deviceType, // 장비 유형 (WIN, AND, IOS, PRT 중1)
  1160. string deviceIdentNo, // 장비 고유식별 번호
  1161. string vistType, // 내원 구분
  1162. string hosType, // 병원 구분
  1163. string clnDate, // 내원구분에 따른 입원일자/진료일자
  1164. string ward, // 병동 코드
  1165. string roomcd, // 병실 코드
  1166. string reasonForUseN, // 출력된 동의서 폐기 사유
  1167. int orderNo, // 처방번호
  1168. string orderName, // 처방명
  1169. string orderCd, // 처방코드
  1170. string ocrCode, // OCR 코드
  1171. int cretno, // 생성번호
  1172. string createUserName, // 작성자명
  1173. string modifyUserName, // 수정자명
  1174. string certTarget, // 서명데이터 원본
  1175. string certResult, // 서명데이터 결과값
  1176. string mainDrId // 주치의 아이디
  1177. )
  1178. {
  1179. Hashtable paramHashTable = new Hashtable();
  1180. paramHashTable.Add("userId", userId);
  1181. if (consentMstRid < 1)
  1182. {
  1183. // insert case
  1184. consentMstRid = this.GetSequence("CONSENT_MST");
  1185. }
  1186. paramHashTable.Add("consentMstRid", consentMstRid);
  1187. paramHashTable.Add("patientCode", patientCode);
  1188. paramHashTable.Add("clnDeptCd", clnDeptCode);
  1189. paramHashTable.Add("vistType", vistType);
  1190. paramHashTable.Add("hosType", hosType);
  1191. paramHashTable.Add("clnDate", clnDate);
  1192. paramHashTable.Add("ward", ward);
  1193. paramHashTable.Add("roomcd", roomcd);
  1194. paramHashTable.Add("orderNo", orderNo);
  1195. paramHashTable.Add("orderName", orderName);
  1196. paramHashTable.Add("orderCd", orderCd);
  1197. paramHashTable.Add("ocrCode", ocrCode);
  1198. paramHashTable.Add("cretno", cretno);
  1199. paramHashTable.Add("createUserName", createUserName);
  1200. paramHashTable.Add("modifyUserName", modifyUserName);
  1201. paramHashTable.Add("formRid", formRid);
  1202. paramHashTable.Add("formCd", formCd);
  1203. paramHashTable.Add("consentState", consentState);
  1204. paramHashTable.Add("certTarget", certTarget);
  1205. paramHashTable.Add("certResult", certResult);
  1206. paramHashTable.Add("mainDrId", mainDrId);
  1207. Encoding encoding = Encoding.GetEncoding("UTF-8");
  1208. //if (certResult != null)
  1209. //{
  1210. // paramHashTable.Add("certResult", encoding.GetBytes(certResult));
  1211. //}
  1212. string completeYn = "N"; // 완료 여부
  1213. switch (consentState)
  1214. {
  1215. case "ELECTR_CMP":
  1216. case "CERTIFY_CMP":
  1217. completeYn = "Y";
  1218. break;
  1219. default:
  1220. break;
  1221. }
  1222. paramHashTable.Add("completeYn", completeYn);
  1223. string completeDateTimeToChars = string.Empty;
  1224. if (completeYn.Equals("Y"))
  1225. {
  1226. completeDateTimeToChars = "TO_CHAR(SYSDATE,'YYYY-MM-DD hh24:mi:ss')";
  1227. paramHashTable.Add("completeDateTimeToChars", completeDateTimeToChars);
  1228. }
  1229. else
  1230. {
  1231. paramHashTable.Add("completeDateTimeToChars", "''");
  1232. }
  1233. paramHashTable.Add("paperYn", paperYn);
  1234. string rewriteYn = "N"; // 재 작성 여부
  1235. if (rewriteConsentMstRid > 1)
  1236. {
  1237. rewriteYn = "Y";
  1238. }
  1239. paramHashTable.Add("rewriteYn", rewriteYn);
  1240. paramHashTable.Add("rewriteConsentMstRid", rewriteConsentMstRid);
  1241. string reissueYn = "N"; // 재 발행(종이) 여부
  1242. if (reissueConsentMstRid > 1)
  1243. {
  1244. reissueYn = "Y";
  1245. }
  1246. paramHashTable.Add("reissueYn", reissueYn);
  1247. paramHashTable.Add("reissueConsentMstRid", reissueConsentMstRid);
  1248. int consentDataRid = this.GetSequence("CONSENT_DATA");
  1249. paramHashTable.Add("consentDataRid", consentDataRid);
  1250. paramHashTable.Add("useYn", "Y");
  1251. encoding = Encoding.GetEncoding("UTF-8");
  1252. byte[] formBytesConent = null;
  1253. if (!string.IsNullOrEmpty(formXml))
  1254. {
  1255. formBytesConent = encoding.GetBytes(formXml);
  1256. }
  1257. byte[] dataBytesConent = null;
  1258. if (!string.IsNullOrEmpty(dataXml))
  1259. {
  1260. dataBytesConent = encoding.GetBytes(dataXml);
  1261. }
  1262. paramHashTable.Add("formXml", formBytesConent);
  1263. paramHashTable.Add("dataXml", dataBytesConent);
  1264. paramHashTable.Add("deviceType", deviceType);
  1265. paramHashTable.Add("deviceIdentNo", deviceIdentNo);
  1266. paramHashTable.Add("reasonForUseN", reasonForUseN);
  1267. return paramHashTable;
  1268. }
  1269. #endregion
  1270. //임시파일 삭제 (1일전 파일은 삭제)
  1271. //public int DeleteTempFile(string targetDate)
  1272. public int DeleteTempFile()
  1273. {
  1274. 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
  1275. if(tempImageDelStatus.Equals(DateTime.Now.AddDays(-1).ToString().Substring(0, 10).Replace("-", "")))
  1276. {
  1277. return 1;
  1278. }
  1279. try
  1280. {
  1281. string sSeverImgPath = Server.MapPath("./DataTempImage/");
  1282. DirectoryInfo di = new System.IO.DirectoryInfo(sSeverImgPath);
  1283. if (Directory.Exists(sSeverImgPath))
  1284. {
  1285. string[] filePaths = Directory.GetFiles(sSeverImgPath);
  1286. foreach (string fileName in filePaths)
  1287. {
  1288. FileInfo fileInfo = new FileInfo(fileName);
  1289. CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("DeleteTempFile fileInfo.CreationTime : {0}", fileInfo.CreationTime.ToString()));
  1290. if (fileInfo.CreationTime < DateTime.Now.AddDays(-1))
  1291. {
  1292. fileInfo.Delete();
  1293. }
  1294. }
  1295. }
  1296. tempImageDelStatus = DateTime.Now.AddDays(-1).ToString().Substring(0,10).Replace("-","");
  1297. return 1;
  1298. }
  1299. catch
  1300. {
  1301. return -1;
  1302. }
  1303. }
  1304. //동의서 로드 전 consent_mst_rid에 해당하는 동의서가 상위 상태값이 있는지 체크
  1305. [WebMethod(Description = "동의서 상위 상태값이 있는지 체크")]
  1306. public int CheckConsentState(int consentmstrid, string consent_state)
  1307. {
  1308. try
  1309. {
  1310. int result = -1;
  1311. int StateNo = 0;
  1312. String CurState;
  1313. using (ConsentDac dac = new ConsentDac())
  1314. {
  1315. Hashtable param = new Hashtable();
  1316. param.Add("consentmstrid", consentmstrid);
  1317. CurState = dac.GetConsentStateCheck(this.IbatisMapper, param);
  1318. }
  1319. if(CurState == null){
  1320. return result;
  1321. }else if (CurState.Equals("UNFINISHED")){
  1322. StateNo = 1;
  1323. }else if (CurState.Equals("TEMP")){
  1324. StateNo = 2;
  1325. }else if (CurState.Equals("VERBAL")){
  1326. StateNo = 3;
  1327. }else if (CurState.Equals("PAPER_OUT")){
  1328. StateNo = 4;
  1329. }else if (CurState.Equals("ELECTR_CMP")){
  1330. StateNo = 5;
  1331. }else if (CurState.Equals("CERTIFY_CMP")){
  1332. StateNo = 6;
  1333. }
  1334. if(consent_state == null){
  1335. return result;
  1336. }else if (consent_state.Equals("UNFINISHED")){
  1337. result = 1;
  1338. }else if (consent_state.Equals("TEMP")){
  1339. result = 2;
  1340. }else if (consent_state.Equals("VERBAL")){
  1341. result = 3;
  1342. }else if (consent_state.Equals("PAPER_OUT")){
  1343. result = 4;
  1344. }else if (consent_state.Equals("ELECTR_CMP")){
  1345. result = 5;
  1346. }else if (consent_state.Equals("CERTIFY_CMP")){
  1347. return result;
  1348. }
  1349. if(result < StateNo)//로드하려는 동의서의 상태보다 현재 저장된 상태가 더 높은 상태일 경우
  1350. {
  1351. return 1;
  1352. }else//로드하려는 동의서보다 현재 저장된 상태가 낮은상태일 경우 또는 같을경우
  1353. {
  1354. return 0;
  1355. }
  1356. }
  1357. catch
  1358. {
  1359. return -1;
  1360. }
  1361. }
  1362. }
  1363. }