#region Copyright © 2015 CLIPSOFT Co.,Ltd. All Rights Reserved. // // All rights are reserved. Reproduction or transmission in whole or in part, // in any form or by any means, electronic, mechanical or otherwise, is // prohibited without the prior written consent of the copyright owner. // // Filename: ConsentSvc.asmx.cs // #endregion using System; using System.IO; using System.Text; using System.Xml; using System.Collections.Generic; using System.Web.Services; using System.Collections; using IBatisNet.DataMapper; using CLIP.eForm.Server.Data; using CLIP.eForm.Server.VO; using CLIP.eForm.Consent.Dfh.Entity; using CLIP.eForm.Consent.Dfh.Dac; using CLIP.eForm.Consent.Dfh.Web; namespace CLIP.eForm.Consent.Dfh.WebService { /// /// 전자 동의서 관련 웹서비스 /// /// ///

[설계자]

///

클립소프트 연구소 홍지철 (jchong@clipsoft.co.kr)

///

[원본 작성자]

///

클립소프트 기술부 이창훈 (chlee@clipsoft.co.kr)

///

[수정 작성자]

///

클립소프트 기술부 이인희

///

----------------------------------------------------------------------------------------

///

[HISTORY]

///

2016-06-15 : 최초작성

///

----------------------------------------------------------------------------------------

///
/// /// ConsentSvc의 요약 설명입니다. /// [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.ComponentModel.ToolboxItem(false)] // ASP.NET AJAX를 사용하여 스크립트에서 이 웹 서비스를 호출하려면 다음 줄의 주석 처리를 제거합니다. // [System.Web.Script.Services.ScriptService] public class ConsentSvc : System.Web.Services.WebService { private IBatisHelper _ibatisHelper; private static string tempImageDelStatus = string.Empty; public ConsentSvc() { _ibatisHelper = new IBatisHelper("ConsentSvcOracleMap.config"); } protected override void Dispose(bool disposing) { if (IbatisSession != null && IbatisSession.Transaction != null) { IbatisSession.CommitTransaction(); IbatisSession.CloseConnection(); } if (IbatisMapper != null) IbatisMapper.CloseConnection(); base.Dispose(disposing); } /// /// 현재 연결된 IBatis Connection을 반환 /// public ISqlMapper IbatisMapper { get { if (_ibatisHelper == null) { return null; } else { return _ibatisHelper.GetSqlMapper(); } } } /// /// 현재 연결된 ISqlMapSession 을 반환 /// public ISqlMapSession IbatisSession { get { if (_ibatisHelper == null) { return null; } else { return _ibatisHelper.GetMapSession(); } } } [WebMethod] public bool CheckWebService() { return true; } [WebMethod] public bool CheckDatabaseConnection() { // TODO: 데이터 베이스 커넥션 테스트 호출 필요 return false; } // 동의서 하위 카테고리 조회 [WebMethod(Description = "동의서 하위 카테고리 조회")] public List GetCategoryForDropdown(string categoryId) { List result; try { using (FormCategoryDac dac = new FormCategoryDac()) { Hashtable param = new Hashtable(); param.Add("category_id", categoryId); result = (List)dac.GetCategoryForDropdown(this.IbatisMapper, param); if (categoryId.Equals("1")) { CategoryForDropdownVO categoryForDropdownVO = new CategoryForDropdownVO(); categoryForDropdownVO.CategoryType = "F"; categoryForDropdownVO.CategoryId = "1CB1B494-1EF0-48BD-84D6-4965A54E6AEA"; categoryForDropdownVO.CategoryName = "전체"; result.Insert(0, categoryForDropdownVO); } else { CategoryForDropdownVO allSubCategory = new CategoryForDropdownVO(); allSubCategory.CategoryId = categoryId; allSubCategory.CategoryName = "전체"; allSubCategory.CategoryType = "F"; result.Insert(0, allSubCategory); } } return result; } catch (Exception ex) { CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("CLIP.eForm error: {0}", ex.Message)); throw ex; } } // 환자, 상태에 따른 동의서 목록 검색 [WebMethod(Description = "환자/상태에 따른 동의서 목록 검색")] public List GetConsentList(string patientCode, string startDt, string endDt, string consetState, string jobkindcd) { List result; try { using (ConsentDac dac = new ConsentDac()) { Hashtable param = new Hashtable(); string isnurs = "N"; param.Add("patientCode", patientCode); param.Add("startDt", startDt); param.Add("endDt", endDt); param.Add("consentState", consetState); if (jobkindcd == "1140" || jobkindcd == "1113") { isnurs = "Y"; } param.Add("isnurs", isnurs); result = (List)dac.GetConsentList(this.IbatisMapper, param); } return result; } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(string.Format("CLIP.eForm error: {0}", ex.Message)); throw ex; } } // 동의서 찾기 [WebMethod(Description = "동의서 찾기(조회)")] public List GetConsentBySearch(string categoryId, string keyWord) { List result; try { using (ConsentDac dac = new ConsentDac()) { Hashtable param = new Hashtable(); param.Add("category_id", categoryId); param.Add("key_word", string.Format("%{0}%", keyWord)); result = (List)dac.GetConsentBySearch(this.IbatisMapper, param); } return result; } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(string.Format("CLIP.eForm error: {0}", ex.Message)); throw ex; } } /// /// CONSENT_MST_RID를 갖고 저장된 동의서 이미지를 조회 /// /// 동의서 마스터 데이터 Rid [WebMethod(Description = "동의서 저장된 이미지 내역 조회")] public List GetConsentImage(string consentMstRid) { List result; try { using (ConsentDac dac = new ConsentDac()) { Hashtable param = new Hashtable(); int consentMstRidInt = 0; int.TryParse(consentMstRid, out consentMstRidInt); param.Add("consent-mst-rid", consentMstRidInt); result = (List)dac.GetConsentImage(this.IbatisMapper, param); //이미지를 조회한 후, 서버의 임시디렉토리에 파일을 복사해둔다. //파일명이 겹칠 수 있으므로 O:\fnuImage\201607\19\100501967 에서 fnuImage20160719100501967 으로 저장한다. foreach (ConsentImageVO img in result) { CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("CLIP.eForm File Upload Impersonate START workemr")); //// 윈도우 계정으로 Impersonate ClipSoft.Utility.ImpersonationUtility util = new ClipSoft.Utility.ImpersonationUtility(); util.ImpersonationStart(string.Empty, "workemr", "workemr"); CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("CLIP.eForm File Upload Impersonate END")); // @"\\192.168.0.222\00. 공용폴더\04. 프로그램 및 관련 매뉴얼\5. oracle\oracle" //string orgFile = @"\\192.168.100.32\image_a03\fnuImage\201610\13" + "\\" + img.ImageFilename; string orgFile = img.ImagePath + "\\" + img.ImageFilename; CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("CLIP.eForm GetConsentImage orgFile: {0}", orgFile)); string tempImgNm = orgFile.Substring(orgFile.IndexOf("\\") + 1).Replace("\\", ""); if (!System.IO.File.Exists(Server.MapPath("./DataTempImage/") + tempImgNm)) { System.IO.File.Copy(orgFile, Server.MapPath("./DataTempImage/") + tempImgNm); } // Impersonate 종료 util.ImpersonationEnd(); CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("CLIP.eForm File Upload Impersonate CLOSE")); } } int iResult = DeleteTempFile(); return result; } catch (Exception ex) { CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm GetConsentImage error: {0}", ex.Message)); throw ex; } } [WebMethod(Description = "테스트 테스트 테스트")] public int SaveTempData1(string userId, string patientCode, string clnDeptCode, int formRid, string formCd, int consentMstRid, int rewriteConsentMstRid, string formXml, string dataXml, string deviceType, string deviceIdentNo, string vistType, string hosType, string clnDate, string ward, string roomcd, int orderNo, string orderName, string orderCd, string ocrCode, int cretno, string createUserName, string modifyUserName, string mainDrId ) { string paramLog = ""; paramLog += "clnDept[" + userId + "]patientCode[" + patientCode + "]clnDeptCode[" + clnDeptCode + "]formRid[" + formRid + "]"; paramLog += "formCd[" + formCd + "]" + "consentMstRid[" + consentMstRid + "]rewriteConsentMstRid[" + rewriteConsentMstRid + "]"; paramLog += "deviceType[" + deviceType + "]vistType[" + vistType + "]hosType[" + hosType + "]"; paramLog += "clnDate[" + clnDate + "]ward[" + ward + "]roomcd[" + roomcd + "]orderNo[" + orderNo + "]"; paramLog += "orderName[" + orderName + "]orderCd[" + orderCd + "]ocrCode[" + ocrCode + "]cretno[" + cretno + "]"; paramLog += "createUserName[" + createUserName + "]modifyUserName[" + modifyUserName + "]"; paramLog += "deviceIdentNo[" + deviceIdentNo + "]mainDrId[" + mainDrId + "]"; paramLog += "dataXml[" + dataXml + "]formXml[" + formXml + "]"; byte[] byte64 = Convert.FromBase64String(dataXml); dataXml = Encoding.UTF8.GetString(byte64); CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("CLIP.eForm SaveTempData param : " + dataXml); //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("SaveTempData1 --> ", "!@#!@#!@#!@#!@#!@#!@#!@#")); return 1; } /// /// 전자동의서를 임시저장 한다. /// /// 로그인 사용자ID /// 환자 등록번호 /// 진료과 코드 /// (작성대상)서식 Rid /// 서식코드 /// 동의서 마스터 데이터 Rid /// 재 작성 대상 동의서 마스터 데이터 Rid /// 동의서 EPT Xml /// 동의서 Data(필드들) Xml /// 장비 유형 (WIN, AND, IOS, PRT 중1) /// 장비 고유 식별자 /// 내원구분 /// 병원 구분 /// 병원 구분이 "I" 일 경우 입원일자/병원 구분이 "O"일 경우 진료일자 /// 병동 코드 /// 병실 코드 /// 처방번호 /// 처방명 /// 처방코드 /// OCR 코드 /// 생성번호 /// 작성자명 /// 수정자명 /// 주치의 아이디 [WebMethod(Description = "동의서 임시저장")] public int SaveTempData(string userId, string patientCode, string clnDeptCode, int formRid, string formCd, int consentMstRid, int rewriteConsentMstRid, string formXml, string dataXml, string deviceType, string deviceIdentNo, string vistType, string hosType, string clnDate, string ward, string roomcd, int orderNo, string orderName, string orderCd, string ocrCode, int cretno, string createUserName, string modifyUserName, string mainDrId) { string paramLog = ""; paramLog += "clnDept[" + userId + "]patientCode[" + patientCode + "]clnDeptCode[" + clnDeptCode + "]formRid[" + formRid + "]"; paramLog += "formCd[" + formCd + "]consentMstRid[" + consentMstRid + "]rewriteConsentMstRid[" + rewriteConsentMstRid + "]"; paramLog += "deviceType[" + deviceType + "]vistType[" + vistType + "]hosType[" + hosType + "]"; paramLog += "clnDate[" + clnDate + "]ward[" + ward + "]roomcd[" + roomcd + "]orderNo[" + orderNo + "]"; paramLog += "orderName[" + orderName + "]orderCd[" + orderCd + "]ocrCode[" + ocrCode + "]cretno[" + cretno + "]"; paramLog += "createUserName[" + createUserName + "]modifyUserName[" + modifyUserName + "]"; paramLog += "deviceIdentNo[" + deviceIdentNo + "]mainDrId[" + mainDrId + "]"; paramLog += "dataXml[" + dataXml + "]formXml[" + formXml + "]"; CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("CLIP.eForm SaveTempData param : " + paramLog); int reissueConsentMstRid = 0; string consentState = "TEMP"; string paperYn = "N"; string reasonForUseN = string.Empty; string verbal = string.Empty; byte[] byte64 = Convert.FromBase64String(dataXml); dataXml = Encoding.UTF8.GetString(byte64); if (!string.IsNullOrEmpty(dataXml)) { Dictionary outputDataDic; XmlDocument xmlDocument = new XmlDocument(); xmlDocument.LoadXml(dataXml); outputDataDic = new Dictionary(); XmlNode rootNode = xmlDocument.SelectSingleNode("form-data"); foreach (XmlNode childNode in rootNode.ChildNodes) { string fieldName = string.Empty; string fieldValue = string.Empty; XmlElement outFieldElement = childNode as XmlElement; if (outFieldElement == null) { } else { fieldName = outFieldElement.Name; if (outFieldElement.ChildNodes.Count == 1 && outFieldElement.ChildNodes[0] is XmlCDataSection) { fieldValue = ((XmlCDataSection)outFieldElement.ChildNodes[0]).InnerText; if (!string.IsNullOrEmpty(fieldName) && fieldName.Equals("IO_verbal") && !string.IsNullOrEmpty(fieldValue) && fieldValue.Equals("Y")) { consentState = "VERBAL"; break; } } else if (outFieldElement.ChildNodes.Count > 1) { foreach (XmlNode childNode2 in childNode.ChildNodes) { string fieldName2 = string.Empty; string fieldValue2 = string.Empty; XmlElement outFieldElement2 = childNode2 as XmlElement; fieldName2 = outFieldElement2.Name; if (outFieldElement2.ChildNodes.Count > 0 && outFieldElement2.ChildNodes[0] is XmlCDataSection) { fieldValue2 = ((XmlCDataSection)outFieldElement2.ChildNodes[0]).InnerText; if (!string.IsNullOrEmpty(fieldName2) && fieldName2.Equals("IO_verbal") && !string.IsNullOrEmpty(fieldValue2) && fieldValue2.Equals("Y")) { consentState = "VERBAL"; break; } } } } } } } rewriteConsentMstRid = 0; consentMstRid = SaveData(userId, patientCode, clnDeptCode, formRid, formCd, consentMstRid, rewriteConsentMstRid, reissueConsentMstRid, consentState, paperYn, formXml, dataXml, deviceType, deviceIdentNo, vistType, hosType, clnDate, ward, roomcd, reasonForUseN, orderNo, orderName, orderCd, ocrCode, cretno, createUserName, modifyUserName, null, null, null, mainDrId); return consentMstRid; } /// /// 전자 동의서를 완료저장 한다. /// /// 로그인 사용자ID /// 환자 등록번호 /// 진료과 코드 /// (작성대상)서식 Rid /// 서식코드 /// 동의서 마스터 데이터 Rid /// 재 작성 대상 동의서 마스터 데이터 Rid /// 동의서 EPT Xml /// 동의서 Data(필드들) Xml /// 장비 유형 (WIN, AND, IOS, PRT 중1) /// 장비 고유 식별자 /// 내원구분 /// 병원 구분 /// 병원 구분이 "I" 일 경우 입원일자/병원 구분이 "O"일 경우 진료일자 /// 병동 코드 /// 병실 코드 /// 처방번호 /// 처방코드 /// 처방명 /// 작성자명 /// 수정자명 /// 주치의 아이디 [WebMethod(Description = "동의서 서명 완료")] public int SaveComplete(string userId, string patientCode, string clnDeptCode, int formRid, string formCd, int consentMstRid, int rewriteConsentMstRid, string formXml, string dataXml, string deviceType, string deviceIdentNo, string vistType, string hosType, string clnDate, string ward, string roomcd, int orderNo, string orderName, string orderCd, string ocrCode, int cretno, string createUserName, string modifyUserName, string mainDrId) { int reissueConsentMstRid = 0; string consentState = "ELECTR_CMP"; string paperYn = "N"; string reasonForUseN = string.Empty; rewriteConsentMstRid = 0; consentMstRid = SaveData(userId, patientCode, clnDeptCode, formRid, formCd, consentMstRid, rewriteConsentMstRid, reissueConsentMstRid, consentState, paperYn, formXml, dataXml, deviceType, deviceIdentNo, vistType, hosType, clnDate, ward, roomcd, reasonForUseN, orderNo, orderName, orderCd, ocrCode, cretno, createUserName, modifyUserName, null, null, null, mainDrId); return consentMstRid; } /// /// 전자 동의서를 완료저장 한다. /// /// 로그인 사용자ID /// 환자 등록번호 /// 진료과 코드 /// (작성대상)서식 Rid /// 서식코드 /// 동의서 마스터 데이터 Rid /// 재 작성 대상 동의서 마스터 데이터 Rid /// 동의서 EPT Xml /// 동의서 Data(필드들) Xml /// 장비 유형 (WIN, AND, IOS, PRT 중1) /// 장비 고유 식별자 /// 내원구분 /// 병원 구분 /// 병원 구분이 "I" 일 경우 입원일자/병원 구분이 "O"일 경우 진료일자 /// 병동 코드 /// 병실 코드 /// 처방번호 /// 처방코드 /// 처방명 /// 작성자명 /// 수정자명 /// 이미지 파일 정보(전자동의서 서버) /// 이미지 파일 공인인증 대상정보 /// 이미지 파일 공인인증 처리정보 /// 퇴원일자 /// 상태 /// 주치의 아이디 [WebMethod(Description = "동의서 서명 완료")] public int SaveCompleteAll(string userId, string patientCode, string clnDeptCode, int formRid, string formCd, int consentMstRid, int rewriteConsentMstRid, string formXml, string dataXml, string deviceType, string deviceIdentNo, string vistType, string hosType, string clnDate, string ward, string roomcd, int orderNo, string orderName, string orderCd, string ocrCode, int cretno, string createUserName, string modifyUserName, string imageFileJson, string certTarget, string certResult, string dschdd, string consentState, string mainDrId) { string paramLog = ""; paramLog += "clnDept[" + userId + "]patientCode[" + patientCode + "]clnDeptCode[" + clnDeptCode + "]formRid[" + formRid + "]"; paramLog += "formCd[" + formCd + "]consentMstRid[" + consentMstRid + "]rewriteConsentMstRid[" + rewriteConsentMstRid + "]"; paramLog += "deviceType[" + deviceType + "]vistType[" + vistType + "]hosType[" + hosType + "]"; paramLog += "clnDate[" + clnDate + "]ward[" + ward + "]roomcd[" + roomcd + "]orderNo[" + orderNo + "]"; paramLog += "orderName[" + orderName + "]orderCd[" + orderCd + "]ocrCode[" + ocrCode + "]cretno[" + cretno + "]"; paramLog += "createUserName[" + createUserName + "]modifyUserName[" + modifyUserName + "]imageFileJson[" + imageFileJson + "]certTarget[" + certTarget + "]"; paramLog += "dschdd[" + dschdd + "]consentState[" + consentState + "]mainDrId[" + mainDrId + "]"; paramLog += "dataXml[" + dataXml + "]formXml[" + formXml + "]certResult[" + certResult + "]"; CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("CLIP.eForm SaveCompleteAll param : " + paramLog); int reissueConsentMstRid = 0; string paperYn = "N"; string reasonForUseN = string.Empty; byte[] byte64 = Convert.FromBase64String(dataXml); dataXml = Encoding.UTF8.GetString(byte64); rewriteConsentMstRid = 0; consentMstRid = SaveDataAll(userId, patientCode, clnDeptCode, formRid, formCd, consentMstRid, rewriteConsentMstRid, reissueConsentMstRid, consentState, paperYn, formXml, dataXml, deviceType, deviceIdentNo, vistType, hosType, clnDate, ward, roomcd, reasonForUseN, orderNo, orderName, orderCd, ocrCode, cretno, createUserName, modifyUserName, imageFileJson, certTarget, certResult, dschdd, mainDrId); return consentMstRid; } /// /// 동의서 삭제/폐기 데이터를 저장 한다. /// /// 로그인 사용자ID /// 동의서 마스터 데이터 Rid /// 환자 등록번호 /// 진료과 코드 /// 병동 코드 /// (작성대상)서식 Rid /// 재 작성 대상 동의서 마스터 데이터 Rid /// 삭제/폐기 대상 동의서 마스터 데이터 Rid /// 동의서 상태 /// 장비 고유 식별자 /// 삭제/폐기 사유 [WebMethod(Description = "동의서 삭제/폐기 데이터를 저장")] public int SaveDelete(string userId, int consentMstRidInt, string patientCode, string clnDeptCode, string ward, string roomcd, int formRid, int rewriteConsentMstRid, int reissueConsentMstRid, string consentState, string deviceIdentNo, string reasonForUseN ) { string paperYn = "N"; consentMstRidInt = SaveData(userId, patientCode, clnDeptCode, formRid, null, consentMstRidInt, rewriteConsentMstRid, reissueConsentMstRid, consentState, paperYn, null, null, null, deviceIdentNo, null, null, null, ward, roomcd, reasonForUseN, 0, null, null, null, 0, null, null, null, null, null, null); return consentMstRidInt; } /// /// 프린트 출력 후 데이터를 저장 한다. /// /// 로그인 사용자ID /// 환자 등록번호 /// 진료과 코드 /// (작성대상)서식 Rid /// 서식코드 /// 동의서 마스터 데이터 Rid /// 재 작성 대상 동의서 마스터 데이터 Rid /// 동의서 EPT Xml /// 동의서 Data(필드들) Xml /// 장비 유형 (WIN, AND, IOS, PRT 중1) /// 장비 고유 식별자 /// 내원구분 /// 병원 구분 /// 병원 구분이 "I" 일 경우 입원일자/병원 구분이 "O"일 경우 진료일자 /// 병동 코드 /// 병실 코드 /// 처방번호 /// 처방명 /// 처방코드 /// OCR코드 /// 생성번호 /// 작성자명 /// 수정자명 /// 주치의 아이디 [WebMethod(Description = "동의서 프린트 출력 후 데이터를 저장")] public int SavePrintOut(string userId, string patientCode, string clnDeptCode, int formRid, string formCd, int consentMstRid, int reissueConsentMstRid, string formXml, string dataXml, string deviceType, string deviceIdentNo, string vistType, string hosType, string clnDate, string ward, string roomcd, int orderNo, string orderName, string orderCd, string ocrCode, int cretno, string createUserName, string modifyUserName, string mainDrId) { string consentState = "PAPER_OUT"; string paperYn = "Y"; consentMstRid = SavePrintData(userId, patientCode, clnDeptCode, formRid, formCd, consentMstRid, 0, reissueConsentMstRid, consentState, paperYn, formXml, dataXml, deviceType, deviceIdentNo, vistType, hosType, clnDate, ward, roomcd, null, orderNo, orderName, orderCd, ocrCode, cretno, createUserName, modifyUserName, null, null, null, mainDrId); return consentMstRid; } /// /// 동의서의 기왕력 데이터 저장 /// /// 환자 등록번호 /// 진료일 /// 고/저혈압 /// 당뇨병 /// 심장질환 /// 신장질환 /// 호흡기질환 /// 과거병력 /// 알레르기 /// 복용약물 /// 흡연상태 /// 특이체질 /// 마약사고 /// 기도이상 유무 /// 출혈소인 /// 기타 /// 로그인 사용자ID [WebMethod(Description = "동의서의 기왕력 데이터 저장")] public string SaveMedicalHistory(string patientCode, string clnDate, string bp, string dm, string heart, string kidney, string respiration, string hx, string allergy, string drug, string smoking, string idio, string nacrotics, string airway, string hemorrhage, string status_etc, string userId) { try { using (SaveConsentDac dac = new SaveConsentDac()) { Hashtable paramHashTable = new Hashtable(); paramHashTable.Add("patientCode", patientCode); paramHashTable.Add("clnDate", clnDate); paramHashTable.Add("bp", bp); paramHashTable.Add("dm", dm); paramHashTable.Add("heart", heart); paramHashTable.Add("kidney", kidney); paramHashTable.Add("respiration", respiration); paramHashTable.Add("hx", hx); paramHashTable.Add("allergy", allergy); paramHashTable.Add("drug", drug); paramHashTable.Add("smoking", smoking); paramHashTable.Add("idio", idio); paramHashTable.Add("nacrotics", nacrotics); paramHashTable.Add("airway", airway); paramHashTable.Add("hemorrhage", hemorrhage); paramHashTable.Add("status_etc", status_etc); paramHashTable.Add("userId", userId); dac.SetMediHistory(this.IbatisMapper, paramHashTable); } } catch (Exception ex) { if (this.IbatisSession != null) this.IbatisSession.RollBackTransaction(); CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm SaveMedicalHistory ERROR : [{0}]", ex.ToString())); throw ex; } finally { } return patientCode; } /// /// 동의서 서명 완료일 경우 이미지 데이터 저장 /// /// 동의서 상태 /// 이미지파일명(경로포함) /// 동의서 마스터 데이터 Rid /// 등록자ID /// 동의서 FORM ID [WebMethod(Description = "동의서 서명 완료일 경우 이미지 데이터 저장")] public int SaveImageUploadInfo(string consentState, string imageFileName, int consentMstRid, string userId, int formRid) { int consentImageRid = 0; if (!string.IsNullOrEmpty(consentState) && consentState == "ELECTR_CMP") { using (SaveConsentDac dac = new SaveConsentDac()) { Hashtable imageHashTable = new Hashtable(); imageHashTable.Add("consentMstRid", consentMstRid); consentImageRid = this.GetSequence("CONSENT_IMAGE"); imageHashTable.Add("consentImageRid", consentImageRid); imageHashTable.Add("userId", userId); imageHashTable.Add("formRid", formRid); imageHashTable.Add("imagePath", imageFileName.Substring(0, imageFileName.LastIndexOf("\\"))); imageHashTable.Add("imageFilename", imageFileName.Substring(imageFileName.LastIndexOf("\\") + 1)); imageHashTable.Add("completeYn", "Y"); //paramHashTable["completeYn"] dac.InsertConsentImage(this.IbatisMapper, imageHashTable); } } return consentImageRid; } /// /// 서명완료된 이미지의 hash 정보 저장 /// /// 동의서 상태 /// 동의서 마스터 데이터 Rid /// 이미지 데이터 Rid /// 등록자ID /// hash 정보 [WebMethod(Description = "서명완료된 이미지의 hash 정보 저장")] public void SaveImageSignInfo(string consentState, int consentMstRid, int consentImageRid, string userId, string certTarget, string sCertResult) { string paramLog = ""; paramLog += "consentState[" + consentState + "]consentMstRid[" + consentMstRid + "]consentImageRid[" + consentImageRid + "]userId[" + userId + "]"; paramLog += "certTarget[" + certTarget + "]sCertResult[" + sCertResult + "]"; CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("CLIP.eForm SaveTempData param : " + paramLog); if (!string.IsNullOrEmpty(consentState) && consentState == "ELECTR_CMP") { using (SaveConsentDac dac = new SaveConsentDac()) { Hashtable imageHashTable = new Hashtable(); imageHashTable.Add("consentMstRid", consentMstRid); imageHashTable.Add("consentImageRid", consentImageRid); imageHashTable.Add("certTarget", certTarget); imageHashTable.Add("certResult", sCertResult); imageHashTable.Add("userId", userId); dac.InsertConsentImageSign(this.IbatisMapper, imageHashTable); imageHashTable.Add("consentState", "CERTIFY_CMP"); dac.UpdateConsentMstStatus(this.IbatisMapper, imageHashTable); } } } private int SaveData(string userId, string patientCode, string clnDeptCode, int formRid, string formCd, int consentMstRid, int rewriteConsentMstRid, int reissueConsentMstRid, string consentState, string paperYn, string formXml, string dataXml, string deviceType, string deviceIdentNo, string vistType, string hosType, string clnDate, string ward, string roomcd, string reasonForUseN, int orderNo, string orderName, string orderCd, string ocrCode, int cretno, string createUserName, string modifyUserName, string imageFileName, string certTarget, string certResult, string mainDrId) { bool isNewConsentMasterCase = false; if (consentMstRid < 1) { isNewConsentMasterCase = true; } try { using (SaveConsentDac dac = new SaveConsentDac()) { Hashtable paramHashTable = GetParamHashTable(userId, patientCode, clnDeptCode, formRid, formCd, consentMstRid, rewriteConsentMstRid, reissueConsentMstRid, consentState, paperYn, formXml, dataXml, deviceType, deviceIdentNo, vistType, hosType, clnDate, ward, roomcd, reasonForUseN, orderNo, orderName, orderCd, ocrCode, cretno, createUserName, modifyUserName, certTarget, certResult, mainDrId); consentMstRid = (int)paramHashTable["consentMstRid"]; //새로 작성하는 경우 if (isNewConsentMasterCase) { dac.InsertConsentMst(this.IbatisMapper, paramHashTable); dac.InsertConsentData(this.IbatisMapper, paramHashTable); //ImageUploadInfo(dac, consentState, imageFileName, paramHashTable, consentMstRid, userId, formRid, deviceType); } //새로 작성 아닌 경우 else { if (reissueConsentMstRid > 0) { if (string.IsNullOrEmpty(reasonForUseN)) { //종이->종이 재발행 int newConsentMstRid = this.GetSequence("CONSENT_MST"); paramHashTable["consentMstRid"] = newConsentMstRid; consentMstRid = newConsentMstRid; dac.InsertConsentMst(this.IbatisMapper, paramHashTable); dac.InsertConsentData(this.IbatisMapper, paramHashTable); //ImageUploadInfo(dac, consentState, imageFileName, paramHashTable, consentMstRid, userId, formRid, deviceType); } else { dac.UpdateConsentMstForDelete(this.IbatisMapper, paramHashTable); } } //임시저장 또는 저장인 경우 else { dac.UpdateConsentMst(this.IbatisMapper, paramHashTable); dac.InsertConsentData(this.IbatisMapper, paramHashTable); //ImageUploadInfo(dac, consentState, imageFileName, paramHashTable, consentMstRid, userId, formRid, deviceType); } } if (!string.IsNullOrEmpty(dataXml)) { Dictionary outputDataDic = DataXmlToDictionary(dataXml); Hashtable paramHashTableForMediHistory = new Hashtable(); paramHashTableForMediHistory.Add("patientCode", patientCode); paramHashTableForMediHistory.Add("clnDate", clnDate.Replace("-", "")); paramHashTableForMediHistory.Add("bp", outputDataDic.ContainsKey("IO_bp") ? outputDataDic["IO_bp"] : ""); paramHashTableForMediHistory.Add("dm", outputDataDic.ContainsKey("IO_dm") ? outputDataDic["IO_dm"] : ""); paramHashTableForMediHistory.Add("heart", outputDataDic.ContainsKey("IO_heart") ? outputDataDic["IO_heart"] : ""); paramHashTableForMediHistory.Add("kidney", outputDataDic.ContainsKey("IO_kidney") ? outputDataDic["IO_kidney"] : ""); paramHashTableForMediHistory.Add("respiration", outputDataDic.ContainsKey("IO_respiration") ? outputDataDic["IO_respiration"] : ""); paramHashTableForMediHistory.Add("hx", outputDataDic.ContainsKey("IO_hx") ? outputDataDic["IO_hx"] : ""); paramHashTableForMediHistory.Add("allergy", outputDataDic.ContainsKey("IO_allergy") ? outputDataDic["IO_allergy"] : ""); paramHashTableForMediHistory.Add("drug", outputDataDic.ContainsKey("IO_drug") ? outputDataDic["IO_drug"] : ""); paramHashTableForMediHistory.Add("smoking", outputDataDic.ContainsKey("IO_smoking") ? outputDataDic["IO_smoking"] : ""); paramHashTableForMediHistory.Add("idio", outputDataDic.ContainsKey("IO_idio") ? outputDataDic["IO_idio"] : ""); paramHashTableForMediHistory.Add("nacrotics", outputDataDic.ContainsKey("IO_nacrotics") ? outputDataDic["IO_nacrotics"] : ""); paramHashTableForMediHistory.Add("airway", outputDataDic.ContainsKey("IO_airway") ? outputDataDic["IO_airway"] : ""); paramHashTableForMediHistory.Add("hemorrhage", outputDataDic.ContainsKey("IO_hemorrhage") ? outputDataDic["IO_hemorrhage"] : ""); paramHashTableForMediHistory.Add("status_etc", outputDataDic.ContainsKey("IO_status_etc") ? outputDataDic["IO_status_etc"] : ""); paramHashTableForMediHistory.Add("userId", userId); dac.SetMediHistory(this.IbatisMapper, paramHashTableForMediHistory); } } } catch (Exception ex) { if (this.IbatisSession != null) this.IbatisSession.RollBackTransaction(); CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm SaveData ERROR : [{0}]", ex.ToString())); throw ex; } finally { } return consentMstRid; } private int SaveDataAll(string userId, string patientCode, string clnDeptCode, int formRid, string formCd, int consentMstRid, int rewriteConsentMstRid, int reissueConsentMstRid, string consentState, string paperYn, string formXml, string dataXml, string deviceType, string deviceIdentNo, string vistType, string hosType, string clnDate, string ward, string roomcd, string reasonForUseN, int orderNo, string orderName, string orderCd, string ocrCode, int cretno, string createUserName, string modifyUserName, string imageFileJson, string certTarget, string certResult, string dschdd, string mainDrId) { bool isNewConsentMasterCase = false; if (consentMstRid < 1) { isNewConsentMasterCase = true; } try { using (SaveConsentDac dac = new SaveConsentDac()) { Hashtable paramHashTable = GetParamHashTable(userId, patientCode, clnDeptCode, formRid, formCd, consentMstRid, rewriteConsentMstRid, reissueConsentMstRid, consentState, paperYn, formXml, dataXml, deviceType, deviceIdentNo, vistType, hosType, clnDate, ward, roomcd, reasonForUseN, orderNo, orderName, orderCd, ocrCode, cretno, createUserName, modifyUserName, certTarget, certResult, mainDrId); consentMstRid = (int)paramHashTable["consentMstRid"]; //새로 작성하는 경우 if (isNewConsentMasterCase) { dac.InsertConsentMst(this.IbatisMapper, paramHashTable); dac.InsertConsentData(this.IbatisMapper, paramHashTable); imageUpload(dac, paramHashTable, userId , patientCode, vistType, clnDate, dschdd, cretno, ocrCode , consentMstRid, consentState, formCd, formRid, dataXml, imageFileJson, certTarget, certResult, hosType, createUserName); } //새로 작성 아닌 경우 else { if (reissueConsentMstRid > 0) { if (string.IsNullOrEmpty(reasonForUseN)) { //종이->종이 재발행 int newConsentMstRid = this.GetSequence("CONSENT_MST"); paramHashTable["consentMstRid"] = newConsentMstRid; consentMstRid = newConsentMstRid; dac.InsertConsentMst(this.IbatisMapper, paramHashTable); dac.InsertConsentData(this.IbatisMapper, paramHashTable); imageUpload(dac, paramHashTable, userId , patientCode, vistType, clnDate, dschdd, cretno, ocrCode , consentMstRid, consentState, formCd, formRid, dataXml, imageFileJson, certTarget, certResult, hosType, createUserName); } else { dac.UpdateConsentMstForDelete(this.IbatisMapper, paramHashTable); } } //임시저장 또는 저장인 경우 else { dac.UpdateConsentMst(this.IbatisMapper, paramHashTable); dac.InsertConsentData(this.IbatisMapper, paramHashTable); imageUpload(dac, paramHashTable, userId , patientCode, vistType, clnDate, dschdd, cretno, ocrCode , consentMstRid, consentState, formCd, formRid, dataXml, imageFileJson, certTarget, certResult, hosType, createUserName); } } if (!string.IsNullOrEmpty(dataXml)) { Dictionary outputDataDic = DataXmlToDictionary(dataXml); Hashtable paramHashTableForMediHistory = new Hashtable(); paramHashTableForMediHistory.Add("patientCode", patientCode); paramHashTableForMediHistory.Add("clnDate", clnDate.Replace("-", "")); paramHashTableForMediHistory.Add("bp", outputDataDic.ContainsKey("IO_bp") ? outputDataDic["IO_bp"] : ""); paramHashTableForMediHistory.Add("dm", outputDataDic.ContainsKey("IO_dm") ? outputDataDic["IO_dm"] : ""); paramHashTableForMediHistory.Add("heart", outputDataDic.ContainsKey("IO_heart") ? outputDataDic["IO_heart"] : ""); paramHashTableForMediHistory.Add("kidney", outputDataDic.ContainsKey("IO_kidney") ? outputDataDic["IO_kidney"] : ""); paramHashTableForMediHistory.Add("respiration", outputDataDic.ContainsKey("IO_respiration") ? outputDataDic["IO_respiration"] : ""); paramHashTableForMediHistory.Add("hx", outputDataDic.ContainsKey("IO_hx") ? outputDataDic["IO_hx"] : ""); paramHashTableForMediHistory.Add("allergy", outputDataDic.ContainsKey("IO_allergy") ? outputDataDic["IO_allergy"] : ""); paramHashTableForMediHistory.Add("drug", outputDataDic.ContainsKey("IO_drug") ? outputDataDic["IO_drug"] : ""); paramHashTableForMediHistory.Add("smoking", outputDataDic.ContainsKey("IO_smoking") ? outputDataDic["IO_smoking"] : ""); paramHashTableForMediHistory.Add("idio", outputDataDic.ContainsKey("IO_idio") ? outputDataDic["IO_idio"] : ""); paramHashTableForMediHistory.Add("nacrotics", outputDataDic.ContainsKey("IO_nacrotics") ? outputDataDic["IO_nacrotics"] : ""); paramHashTableForMediHistory.Add("airway", outputDataDic.ContainsKey("IO_airway") ? outputDataDic["IO_airway"] : ""); paramHashTableForMediHistory.Add("hemorrhage", outputDataDic.ContainsKey("IO_hemorrhage") ? outputDataDic["IO_hemorrhage"] : ""); paramHashTableForMediHistory.Add("status_etc", outputDataDic.ContainsKey("IO_status_etc") ? outputDataDic["IO_status_etc"] : ""); paramHashTableForMediHistory.Add("userId", userId); dac.SetMediHistory(this.IbatisMapper, paramHashTableForMediHistory); } } } catch (Exception ex) { if (this.IbatisSession != null) this.IbatisSession.RollBackTransaction(); CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm SaveDataAll ERROR : [{0}]", ex.ToString())); throw ex; } finally { } return consentMstRid; } private void imageUpload(SaveConsentDac dac , Hashtable paramHashTable , string userId , string patientCode , string visitType , string clnDate , string Dschdd , int cretno , string ocrcode , int consentMstRid , string consentState , string formCd , int formRid , string dataXml , string imageFileJson , string certTarget , string certResult , string hosType , string createUserName ) { // 서명 저장일 경우 emrindxm 테이블에 저장 if (!string.IsNullOrEmpty(consentState) && ( consentState.Equals("ELECTR_CMP") || consentState.Equals("CERTIFY_CMP")) ) { string clnDeptCode = paramHashTable["clnDeptCd"] == null ? string.Empty : paramHashTable["clnDeptCd"].ToString(); try { CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("CLIP.eForm File Upload imageFileJson[{0}]", imageFileJson)); CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("CLIP.eForm File Upload consentState[{0}]", consentState)); CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("CLIP.eForm File Upload certTarget[{0}]", certTarget)); CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("CLIP.eForm File Upload paramHashTable[certTarget[{0}]", paramHashTable["certTarget"])); CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("CLIP.eForm File Upload certResult[{0}]", certResult)); CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("CLIP.eForm File Upload paramHashTable[certResult[{0}]", paramHashTable["certResult"])); int consentImageRid = this.GetSequence("CONSENT_IMAGE"); //if (consentState.Equals("CERTIFY_CMP")) //{ paramHashTable.Add("consentImageRid", consentImageRid); // 사인정보 저장 dac.InsertConsentImageSign(this.IbatisMapper, paramHashTable); //} string sPath = string.Empty; string sFileName = string.Empty; string newFileFullName = string.Empty; if (!string.IsNullOrEmpty(imageFileJson)) { Dictionary jsonRoot = null; jsonRoot = fastJSON.JSON.Parse(imageFileJson) as Dictionary; if (jsonRoot != null && jsonRoot.Count > 0) { Hashtable imageHashTable = new Hashtable(); int nowCnt = 1; foreach (KeyValuePair jr in jsonRoot) { imageHashTable = new Hashtable(); imageHashTable.Add("consentMstRid", consentMstRid); if(nowCnt > 1) consentImageRid = this.GetSequence("CONSENT_IMAGE"); imageHashTable.Add("consentImageRid", consentImageRid); imageHashTable.Add("userId", userId); imageHashTable.Add("formRid", formRid); if (jr.Value != null && !string.IsNullOrEmpty(jr.Value.ToString())) { sPath = ""; sFileName = ""; string[] filepath = jr.Value.ToString().Split('/'); for (int i = 0; i < filepath.Length; i++) { if (i == 0) { sPath = filepath[i]; } else if ((i + 1) == filepath.Length) { sFileName = filepath[i]; } else { sPath += "/" + filepath[i]; } } newFileFullName = string.Empty; using (HospitalSvc hospitalWebService = new HospitalSvc()) { newFileFullName = hospitalWebService.GetFileName(patientCode, visitType, clnDate.Replace("-", ""), Dschdd, string.Format("{0}", cretno), "500", formCd, nowCnt.ToString(), ocrcode, userId, clnDeptCode); } //if (string.IsNullOrEmpty(newFileFullName)) string uploadFileName = newFileFullName + ".jpg"; string sUploadPath = uploadFileName.Substring(0, uploadFileName.LastIndexOf("\\") + 1); string sUploadFileName = uploadFileName.Substring(uploadFileName.LastIndexOf("\\") + 1); CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("CLIP.eForm File Upload localpath[{0}]", Server.MapPath(string.Format("./UPLOAD/{0}/{1}", sPath, sFileName)))); CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("CLIP.eForm File Upload uploadFileName[{0}]", uploadFileName)); if(uploadFileName.Length > 5) { if (Convert.ToInt16(uploadFileName.Substring(5, 1)) < 10) { uploadFileName = string.Format("\\\\192.168.100.32\\image_a0{0}", uploadFileName.Substring(5)); } else { uploadFileName = string.Format("\\\\192.168.100.32\\image_a{0}", uploadFileName.Substring(5)); } } CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("CLIP.eForm File Upload uploadFileName[{0}]", uploadFileName)); //// 윈도우 계정으로 Impersonate CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("CLIP.eForm File Upload Impersonate START workemr")); ClipSoft.Utility.ImpersonationUtility util = new ClipSoft.Utility.ImpersonationUtility(); util.ImpersonationStart(string.Empty, "workemr", "workemr"); CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("CLIP.eForm File Upload Impersonate END")); // 디렉토리 존재여부 체크 DirectoryInfo di = new DirectoryInfo(uploadFileName.Substring(0, uploadFileName.LastIndexOf("\\") + 1)); if (di.Exists == false) { di.Create(); } // 파일 저장 System.IO.File.Copy(Server.MapPath(string.Format("./UPLOAD/{0}/{1}", sPath, sFileName)), uploadFileName); // Impersonate 종료 util.ImpersonationEnd(); CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("CLIP.eForm File Upload Impersonate CLOSE")); imageHashTable.Add("imagePath", sUploadPath); imageHashTable.Add("imageFilename", sUploadFileName); imageHashTable.Add("completeYn", paramHashTable["completeYn"]); dac.InsertConsentImage(this.IbatisMapper, imageHashTable); } nowCnt++; } } } //if (patientCode.Equals("0586244")) //{ // throw new Exception(); //} } catch (Exception ex) { using (HospitalSvc hospitalWebService = new HospitalSvc()) { hospitalWebService.delEformData(patientCode, visitType, clnDate.Replace("-", ""), Dschdd, string.Format("{0}", cretno), formCd, ocrcode, userId, createUserName, string.Format("{0}", consentMstRid), hosType, clnDeptCode); } if (this.IbatisSession != null) this.IbatisSession.RollBackTransaction(); CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm imageUpload ERROR : [{0}]", ex.ToString())); throw ex; } } } private int SavePrintData(string userId, string patientCode, string clnDeptCode, int formRid, string formCd, int consentMstRid, int rewriteConsentMstRid, int reissueConsentMstRid, string consentState, string paperYn, string formXml, string dataXml, string deviceType, string deviceIdentNo, string vistType, string hosType, string clnDate, string ward, string roomcd, string reasonForUseN, int orderNo, string orderName, string orderCd, string ocrCode, int cretno, string createUserName, string modifyUserName, string imageFileName, string certTarget, string certResult, string mainDrId) { bool isNewConsentMasterCase = false; if (consentMstRid < 1) { isNewConsentMasterCase = true; } try { using (SaveConsentDac dac = new SaveConsentDac()) { Hashtable paramHashTable = GetParamHashTable(userId, patientCode, clnDeptCode, formRid, formCd, consentMstRid, rewriteConsentMstRid, reissueConsentMstRid, consentState, paperYn, formXml, dataXml, deviceType, deviceIdentNo, vistType, hosType, clnDate, ward, roomcd, reasonForUseN, orderNo, orderName, orderCd, ocrCode, cretno, createUserName, modifyUserName, certTarget, certResult, mainDrId); consentMstRid = (int)paramHashTable["consentMstRid"]; //새로 출력하는 경우 if (isNewConsentMasterCase) { dac.InsertConsentMst(this.IbatisMapper, paramHashTable); } //새로 작성 아닌 경우 else { if (reissueConsentMstRid > 0) dac.UpdateConsentMstForReissue(this.IbatisMapper, paramHashTable); else dac.UpdateConsentMst(this.IbatisMapper, paramHashTable); } } } catch (Exception ex) { if (this.IbatisSession != null) this.IbatisSession.RollBackTransaction(); CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm SaveData ERROR : [{0}]", ex.ToString())); throw ex; } finally { } return consentMstRid; } private static Dictionary DataXmlToDictionary(string dataXml) { Dictionary outputDataDic; XmlDocument xmlDocument = new XmlDocument(); xmlDocument.LoadXml(dataXml); outputDataDic = new Dictionary(); XmlNode rootNode = xmlDocument.SelectSingleNode("form-data"); foreach (XmlNode childNode in rootNode.ChildNodes) { string fieldName = string.Empty; string fieldValue = string.Empty; XmlElement outFieldElement = childNode as XmlElement; if (outFieldElement == null) { } else { fieldName = outFieldElement.Name; CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("DataXmlToDictionary 0 : {0}/{1}", outFieldElement.ChildNodes.Count, fieldName)); if (outFieldElement.ChildNodes.Count == 1 && outFieldElement.ChildNodes[0] is XmlCDataSection) { fieldValue = ((XmlCDataSection)outFieldElement.ChildNodes[0]).InnerText; CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("DataXmlToDictionary 1 : {0}/{1}", fieldName, fieldValue)); if (outputDataDic.ContainsKey(fieldName)) { outputDataDic[fieldName] = fieldValue; } else { outputDataDic.Add(fieldName, fieldValue); } } else if (outFieldElement.ChildNodes.Count > 1) { foreach (XmlNode childNode2 in childNode.ChildNodes) { string fieldName2 = string.Empty; string fieldValue2 = string.Empty; XmlElement outFieldElement2 = childNode2 as XmlElement; fieldName2 = outFieldElement2.Name; CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("DataXmlToDictionary : {0}", fieldName2)); CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("DataXmlToDictionary : {0}", outFieldElement2.ChildNodes.Count)); if (outFieldElement2.ChildNodes.Count > 0 && outFieldElement2.ChildNodes[0] is XmlCDataSection) { fieldValue2 = ((XmlCDataSection)outFieldElement2.ChildNodes[0]).InnerText; CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("DataXmlToDictionary 2 : {0}/{1}", fieldName2, fieldValue2)); } if (outputDataDic.ContainsKey(fieldName2)) { outputDataDic[fieldName2] = fieldValue2; } else { outputDataDic.Add(fieldName2, fieldValue2); } } } } } return outputDataDic; } /// /// EFORM_CODE에 정의하는 시퀀스(채번)을 구한다. /// /// /// private int GetSequence(string sSubCd) { int nSeq = -1; try { using (CommonCodeDac dac = new CommonCodeDac()) { Code param = new Code(); param.sub_cd = sSubCd; nSeq = dac.GetSequence(this.IbatisMapper, param); if (nSeq == 0) { dac.InsertSequence(this.IbatisMapper, param); nSeq = 1; } else { param.ud1_num = ++nSeq; dac.UpdateSequence(this.IbatisMapper, param); } } } catch (Exception ex) { if (this.IbatisSession != null) this.IbatisSession.RollBackTransaction(); throw ex; } return nSeq; } #region GetParamHashTable private Hashtable GetParamHashTable(string userId, // 사용자 Id string patientCode, // 환자 등록번호 string clnDeptCode, // 진료과 코드 int formRid, // (작성대상)서식 Rid string formCd, // 서식코드 === CONSENT_DATA_CHOICE에서 입력여부 판단할 파라미터 int consentMstRid, // 동의서 마스터 데이터 Rid int rewriteConsentMstRid, // 재 작성 대상 동의서 마스터 데이터 Rid int reissueConsentMstRid, // 재 발행 대상 동의서 마스터 데이터 Rid string consentState, // 동의서 상태 (TEMP, PAPER_OUT, ELECTR_CMP, CERTIFY_CMP) string paperYn, // 인쇄 발행 여부 string formXml, // 동의서 EPT Xml string dataXml, // 동의서 Data(필드들) Xml string deviceType, // 장비 유형 (WIN, AND, IOS, PRT 중1) string deviceIdentNo, // 장비 고유식별 번호 string vistType, // 내원 구분 string hosType, // 병원 구분 string clnDate, // 내원구분에 따른 입원일자/진료일자 string ward, // 병동 코드 string roomcd, // 병실 코드 string reasonForUseN, // 출력된 동의서 폐기 사유 int orderNo, // 처방번호 string orderName, // 처방명 string orderCd, // 처방코드 string ocrCode, // OCR 코드 int cretno, // 생성번호 string createUserName, // 작성자명 string modifyUserName, // 수정자명 string certTarget, // 서명데이터 원본 string certResult, // 서명데이터 결과값 string mainDrId // 주치의 아이디 ) { Hashtable paramHashTable = new Hashtable(); paramHashTable.Add("userId", userId); if (consentMstRid < 1) { // insert case consentMstRid = this.GetSequence("CONSENT_MST"); } paramHashTable.Add("consentMstRid", consentMstRid); paramHashTable.Add("patientCode", patientCode); paramHashTable.Add("clnDeptCd", clnDeptCode); paramHashTable.Add("vistType", vistType); paramHashTable.Add("hosType", hosType); paramHashTable.Add("clnDate", clnDate); paramHashTable.Add("ward", ward); paramHashTable.Add("roomcd", roomcd); paramHashTable.Add("orderNo", orderNo); paramHashTable.Add("orderName", orderName); paramHashTable.Add("orderCd", orderCd); paramHashTable.Add("ocrCode", ocrCode); paramHashTable.Add("cretno", cretno); paramHashTable.Add("createUserName", createUserName); paramHashTable.Add("modifyUserName", modifyUserName); paramHashTable.Add("formRid", formRid); paramHashTable.Add("formCd", formCd); paramHashTable.Add("consentState", consentState); paramHashTable.Add("certTarget", certTarget); paramHashTable.Add("certResult", certResult); paramHashTable.Add("mainDrId", mainDrId); Encoding encoding = Encoding.GetEncoding("UTF-8"); //if (certResult != null) //{ // paramHashTable.Add("certResult", encoding.GetBytes(certResult)); //} string completeYn = "N"; // 완료 여부 switch (consentState) { case "ELECTR_CMP": case "CERTIFY_CMP": completeYn = "Y"; break; default: break; } paramHashTable.Add("completeYn", completeYn); string completeDateTimeToChars = string.Empty; if (completeYn.Equals("Y")) { completeDateTimeToChars = "TO_CHAR(SYSDATE,'YYYY-MM-DD hh24:mi:ss')"; paramHashTable.Add("completeDateTimeToChars", completeDateTimeToChars); } else { paramHashTable.Add("completeDateTimeToChars", "''"); } paramHashTable.Add("paperYn", paperYn); string rewriteYn = "N"; // 재 작성 여부 if (rewriteConsentMstRid > 1) { rewriteYn = "Y"; } paramHashTable.Add("rewriteYn", rewriteYn); paramHashTable.Add("rewriteConsentMstRid", rewriteConsentMstRid); string reissueYn = "N"; // 재 발행(종이) 여부 if (reissueConsentMstRid > 1) { reissueYn = "Y"; } paramHashTable.Add("reissueYn", reissueYn); paramHashTable.Add("reissueConsentMstRid", reissueConsentMstRid); int consentDataRid = this.GetSequence("CONSENT_DATA"); paramHashTable.Add("consentDataRid", consentDataRid); paramHashTable.Add("useYn", "Y"); encoding = Encoding.GetEncoding("UTF-8"); byte[] formBytesConent = null; if (!string.IsNullOrEmpty(formXml)) { formBytesConent = encoding.GetBytes(formXml); } byte[] dataBytesConent = null; if (!string.IsNullOrEmpty(dataXml)) { dataBytesConent = encoding.GetBytes(dataXml); } paramHashTable.Add("formXml", formBytesConent); paramHashTable.Add("dataXml", dataBytesConent); paramHashTable.Add("deviceType", deviceType); paramHashTable.Add("deviceIdentNo", deviceIdentNo); paramHashTable.Add("reasonForUseN", reasonForUseN); return paramHashTable; } #endregion //임시파일 삭제 (1일전 파일은 삭제) //public int DeleteTempFile(string targetDate) public int DeleteTempFile() { 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 if(tempImageDelStatus.Equals(DateTime.Now.AddDays(-1).ToString().Substring(0, 10).Replace("-", ""))) { return 1; } try { string sSeverImgPath = Server.MapPath("./DataTempImage/"); DirectoryInfo di = new System.IO.DirectoryInfo(sSeverImgPath); if (Directory.Exists(sSeverImgPath)) { string[] filePaths = Directory.GetFiles(sSeverImgPath); foreach (string fileName in filePaths) { FileInfo fileInfo = new FileInfo(fileName); CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug(string.Format("DeleteTempFile fileInfo.CreationTime : {0}", fileInfo.CreationTime.ToString())); if (fileInfo.CreationTime < DateTime.Now.AddDays(-1)) { fileInfo.Delete(); } } } tempImageDelStatus = DateTime.Now.AddDays(-1).ToString().Substring(0,10).Replace("-",""); return 1; } catch { return -1; } } //동의서 로드 전 consent_mst_rid에 해당하는 동의서가 상위 상태값이 있는지 체크 [WebMethod(Description = "동의서 상위 상태값이 있는지 체크")] public int CheckConsentState(int consentmstrid, string consent_state) { try { int result = -1; int StateNo = 0; String CurState; using (ConsentDac dac = new ConsentDac()) { Hashtable param = new Hashtable(); param.Add("consentmstrid", consentmstrid); CurState = dac.GetConsentStateCheck(this.IbatisMapper, param); } if(CurState == null){ return result; }else if (CurState.Equals("UNFINISHED")){ StateNo = 1; }else if (CurState.Equals("TEMP")){ StateNo = 2; }else if (CurState.Equals("VERBAL")){ StateNo = 3; }else if (CurState.Equals("PAPER_OUT")){ StateNo = 4; }else if (CurState.Equals("ELECTR_CMP")){ StateNo = 5; }else if (CurState.Equals("CERTIFY_CMP")){ StateNo = 6; } if(consent_state == null){ return result; }else if (consent_state.Equals("UNFINISHED")){ result = 1; }else if (consent_state.Equals("TEMP")){ result = 2; }else if (consent_state.Equals("VERBAL")){ result = 3; }else if (consent_state.Equals("PAPER_OUT")){ result = 4; }else if (consent_state.Equals("ELECTR_CMP")){ result = 5; }else if (consent_state.Equals("CERTIFY_CMP")){ return result; } if(result < StateNo)//로드하려는 동의서의 상태보다 현재 저장된 상태가 더 높은 상태일 경우 { return 1; }else//로드하려는 동의서보다 현재 저장된 상태가 낮은상태일 경우 또는 같을경우 { return 0; } } catch { return -1; } } } }