1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534 |
- #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
- {
- /// <summary>
- /// 전자 동의서 관련 웹서비스
- /// </summary>
- /// <remarks>
- /// <p>[설계자]</p>
- /// <p> 클립소프트 연구소 홍지철 (jchong@clipsoft.co.kr)</p>
- /// <p>[원본 작성자]</p>
- /// <p> 클립소프트 기술부 이창훈 (chlee@clipsoft.co.kr)</p>
- /// <p>[수정 작성자]</p>
- /// <p> 클립소프트 기술부 이인희</p>
- /// <p>----------------------------------------------------------------------------------------</p>
- /// <p>[HISTORY]</p>
- /// <p> 2016-06-15 : 최초작성</p>
- /// <p>----------------------------------------------------------------------------------------</p>
- /// </remarks>
- /// <summary>
- /// ConsentSvc의 요약 설명입니다.
- /// </summary>
- [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);
- }
- /// <summary>
- /// 현재 연결된 IBatis Connection을 반환
- /// </summary>
- public ISqlMapper IbatisMapper {
- get {
- if (_ibatisHelper == null) {
- return null;
- } else {
- return _ibatisHelper.GetSqlMapper();
- }
- }
- }
- /// <summary>
- /// 현재 연결된 ISqlMapSession 을 반환
- /// </summary>
- 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<CategoryForDropdownVO> GetCategoryForDropdown(string categoryId) {
- List<CategoryForDropdownVO> result;
- try {
- using (FormCategoryDac dac = new FormCategoryDac()) {
- Hashtable param = new Hashtable();
- param.Add("category_id", categoryId);
- result = (List<CategoryForDropdownVO>)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<ConsentVO> GetConsentList(string patientCode, string startDt, string endDt, string consetState, string jobkindcd) {
- List<ConsentVO> 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<ConsentVO>)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<ConsentBySearchVO> GetConsentBySearch(string categoryId, string keyWord) {
- List<ConsentBySearchVO> 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<ConsentBySearchVO>)dac.GetConsentBySearch(this.IbatisMapper, param);
- }
- return result;
- } catch (Exception ex) {
- System.Diagnostics.Trace.WriteLine(string.Format("CLIP.eForm error: {0}", ex.Message));
- throw ex;
- }
- }
- /// <summary>
- /// CONSENT_MST_RID를 갖고 저장된 동의서 이미지를 조회
- /// </summary>
- /// <param name="consentMstRid">동의서 마스터 데이터 Rid</param>
- [WebMethod(Description = "동의서 저장된 이미지 내역 조회")]
- public List<ConsentImageVO> GetConsentImage(string consentMstRid) {
- List<ConsentImageVO> 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<ConsentImageVO>)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;
- }
- /// <summary>
- /// 전자동의서를 임시저장 한다.
- /// </summary>
- /// <param name="userId">로그인 사용자ID</param>
- /// <param name="patientCode">환자 등록번호</param>
- /// <param name="clnDeptCode">진료과 코드</param>
- /// <param name="formRid">(작성대상)서식 Rid</param>
- /// <param name="formCd">서식코드</param>
- /// <param name="consentMstRid">동의서 마스터 데이터 Rid</param>
- /// <param name="rewriteConsentMstRid">재 작성 대상 동의서 마스터 데이터 Rid</param>
- /// <param name="formXml">동의서 EPT Xml</param>
- /// <param name="dataXml">동의서 Data(필드들) Xml</param>
- /// <param name="deviceType">장비 유형 (WIN, AND, IOS, PRT 중1)</param>
- /// <param name="deviceIdentNo">장비 고유 식별자</param>
- /// <param name="vistType">내원구분</param>
- /// <param name="hosType">병원 구분</param>
- /// <param name="clnDate">병원 구분이 "I" 일 경우 입원일자/병원 구분이 "O"일 경우 진료일자</param>
- /// <param name="ward">병동 코드</param>
- /// <param name="roomcd">병실 코드</param>
- /// <param name="orderNo">처방번호</param>
- /// <param name="orderName">처방명</param>
- /// <param name="orderCd">처방코드</param>
- /// <param name="ocrCode">OCR 코드</param>
- /// <param name="cretno">생성번호</param>
- /// <param name="createUserName">작성자명</param>
- /// <param name="modifyUserName">수정자명</param>
- /// <param name="mainDrId">주치의 아이디</param>
- [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<string, string> outputDataDic;
- XmlDocument xmlDocument = new XmlDocument();
- xmlDocument.LoadXml(dataXml);
- outputDataDic = new Dictionary<string, string>();
- 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;
- }
- /// <summary>
- /// 전자 동의서를 완료저장 한다.
- /// </summary>
- /// <param name="userId">로그인 사용자ID</param>
- /// <param name="patientCode">환자 등록번호</param>
- /// <param name="clnDeptCode">진료과 코드</param>
- /// <param name="formRid">(작성대상)서식 Rid</param>
- /// <param name="formCd">서식코드</param>
- /// <param name="consentMstRid">동의서 마스터 데이터 Rid</param>
- /// <param name="rewriteConsentMstRid">재 작성 대상 동의서 마스터 데이터 Rid</param>
- /// <param name="formXml">동의서 EPT Xml</param>
- /// <param name="dataXml">동의서 Data(필드들) Xml</param>
- /// <param name="deviceType">장비 유형 (WIN, AND, IOS, PRT 중1)</param>
- /// <param name="deviceIdentNo">장비 고유 식별자</param>
- /// <param name="vistType">내원구분</param>
- /// <param name="hosType">병원 구분</param>
- /// <param name="clnDate">병원 구분이 "I" 일 경우 입원일자/병원 구분이 "O"일 경우 진료일자</param>
- /// <param name="ward">병동 코드</param>
- /// <param name="roomcd">병실 코드</param>
- /// <param name="orderNo">처방번호</param>
- /// <param name="orderCd">처방코드</param>
- /// <param name="orderName">처방명</param>
- /// <param name="createUserName">작성자명</param>
- /// <param name="modifyUserName">수정자명</param>
- /// <param name="mainDrId">주치의 아이디</param>
- [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;
- }
- /// <summary>
- /// 전자 동의서를 완료저장 한다.
- /// </summary>
- /// <param name="userId">로그인 사용자ID</param>
- /// <param name="patientCode">환자 등록번호</param>
- /// <param name="clnDeptCode">진료과 코드</param>
- /// <param name="formRid">(작성대상)서식 Rid</param>
- /// <param name="formCd">서식코드</param>
- /// <param name="consentMstRid">동의서 마스터 데이터 Rid</param>
- /// <param name="rewriteConsentMstRid">재 작성 대상 동의서 마스터 데이터 Rid</param>
- /// <param name="formXml">동의서 EPT Xml</param>
- /// <param name="dataXml">동의서 Data(필드들) Xml</param>
- /// <param name="deviceType">장비 유형 (WIN, AND, IOS, PRT 중1)</param>
- /// <param name="deviceIdentNo">장비 고유 식별자</param>
- /// <param name="vistType">내원구분</param>
- /// <param name="hosType">병원 구분</param>
- /// <param name="clnDate">병원 구분이 "I" 일 경우 입원일자/병원 구분이 "O"일 경우 진료일자</param>
- /// <param name="ward">병동 코드</param>
- /// <param name="roomcd">병실 코드</param>
- /// <param name="orderNo">처방번호</param>
- /// <param name="orderCd">처방코드</param>
- /// <param name="orderName">처방명</param>
- /// <param name="createUserName">작성자명</param>
- /// <param name="modifyUserName">수정자명</param>
- /// <param name="imageFileJson">이미지 파일 정보(전자동의서 서버)</param>
- /// <param name="certTarget">이미지 파일 공인인증 대상정보</param>
- /// <param name="certResult">이미지 파일 공인인증 처리정보</param>
- /// <param name="dschdd">퇴원일자</param>
- /// <param name="consentState">상태</param>
- /// <param name="mainDrId">주치의 아이디</param>
- [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;
- }
- /// <summary>
- /// 동의서 삭제/폐기 데이터를 저장 한다.
- /// </summary>
- /// <param name="userId">로그인 사용자ID</param>
- /// <param name="consentMstRid">동의서 마스터 데이터 Rid</param>
- /// <param name="patientCode">환자 등록번호</param>
- /// <param name="clnDeptCode">진료과 코드</param>
- /// <param name="ward">병동 코드</param>
- /// <param name="formRid">(작성대상)서식 Rid</param>
- /// <param name="rewriteConsentMstRid">재 작성 대상 동의서 마스터 데이터 Rid</param>
- /// <param name="reissueConsentMstRid">삭제/폐기 대상 동의서 마스터 데이터 Rid</param>
- /// <param name="consentState">동의서 상태</param>
- /// <param name="deviceIdentNo">장비 고유 식별자</param>
- /// <param name="reasonForUseN">삭제/폐기 사유</param>
- [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;
- }
- /// <summary>
- /// 프린트 출력 후 데이터를 저장 한다.
- /// </summary>
- /// <param name="userId">로그인 사용자ID</param>
- /// <param name="patientCode">환자 등록번호</param>
- /// <param name="clnDeptCode">진료과 코드</param>
- /// <param name="formRid">(작성대상)서식 Rid</param>
- /// <param name="formCd">서식코드</param>
- /// <param name="consentMstRid">동의서 마스터 데이터 Rid</param>
- /// <param name="rewriteConsentMstRid">재 작성 대상 동의서 마스터 데이터 Rid</param>
- /// <param name="formXml">동의서 EPT Xml</param>
- /// <param name="dataXml">동의서 Data(필드들) Xml</param>
- /// <param name="deviceType">장비 유형 (WIN, AND, IOS, PRT 중1)</param>
- /// <param name="deviceIdentNo">장비 고유 식별자</param>
- /// <param name="vistType">내원구분</param>
- /// <param name="hosType">병원 구분</param>
- /// <param name="clnDate">병원 구분이 "I" 일 경우 입원일자/병원 구분이 "O"일 경우 진료일자</param>
- /// <param name="ward">병동 코드</param>
- /// <param name="roomcd">병실 코드</param>
- /// <param name="orderNo">처방번호</param>
- /// <param name="orderName">처방명</param>
- /// <param name="orderCd">처방코드</param>
- /// <param name="ocrCode">OCR코드</param>
- /// <param name="cretno">생성번호</param>
- /// <param name="createUserName">작성자명</param>
- /// <param name="modifyUserName">수정자명</param>
- /// <param name="mainDrId">주치의 아이디</param>
- [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;
- }
- /// <summary>
- /// 동의서의 기왕력 데이터 저장
- /// </summary>
- /// <param name="patientCode">환자 등록번호</param>
- /// <param name="clnDate">진료일</param>
- /// <param name="bp">고/저혈압</param>
- /// <param name="dm">당뇨병</param>
- /// <param name="heart">심장질환</param>
- /// <param name="kidney">신장질환</param>
- /// <param name="respiration">호흡기질환</param>
- /// <param name="hx">과거병력</param>
- /// <param name="allergy">알레르기</param>
- /// <param name="drug">복용약물</param>
- /// <param name="smoking">흡연상태</param>
- /// <param name="idio">특이체질</param>
- /// <param name="nacrotics">마약사고</param>
- /// <param name="airway">기도이상 유무</param>
- /// <param name="hemorrhage">출혈소인</param>
- /// <param name="status_etc">기타</param>
- /// <param name="userId">로그인 사용자ID</param>
- [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;
- }
- /// <summary>
- /// 동의서 서명 완료일 경우 이미지 데이터 저장
- /// </summary>
- /// <param name="consentState">동의서 상태</param>
- /// <param name="imageFileName">이미지파일명(경로포함)</param>
- /// <param name="consentMstRid">동의서 마스터 데이터 Rid</param>
- /// <param name="userId">등록자ID</param>
- /// <param name="formRid">동의서 FORM ID</param>
- [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;
- }
- /// <summary>
- /// 서명완료된 이미지의 hash 정보 저장
- /// </summary>
- /// <param name="consentState">동의서 상태</param>
- /// <param name="consentMstRid">동의서 마스터 데이터 Rid</param>
- /// <param name="consentImageRid">이미지 데이터 Rid</param>
- /// <param name="userId">등록자ID</param>
- /// <param name="certTarget">hash 정보</param>
- [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<string, string> 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<string, string> 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<string, object> jsonRoot = null;
- jsonRoot = fastJSON.JSON.Parse(imageFileJson) as Dictionary<string, object>;
- if (jsonRoot != null && jsonRoot.Count > 0)
- {
- Hashtable imageHashTable = new Hashtable();
- int nowCnt = 1;
- foreach (KeyValuePair<string, object> 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<string, string> DataXmlToDictionary(string dataXml)
- {
- Dictionary<string, string> outputDataDic;
- XmlDocument xmlDocument = new XmlDocument();
- xmlDocument.LoadXml(dataXml);
- outputDataDic = new Dictionary<string, string>();
- 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;
- }
- /// <summary>
- /// EFORM_CODE에 정의하는 시퀀스(채번)을 구한다.
- /// </summary>
- /// <param name="sSubCd"></param>
- /// <returns></returns>
- 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;
- }
- }
- }
- }
|