Gitea 5 jaren geleden
bovenliggende
commit
48a9dbbbc5

+ 15 - 1
CLIP.e-Form.Consent.Entity/ConsentVO.cs

@@ -31,7 +31,7 @@ namespace CLIP.eForm.Consent.Entity {
 
     public ConsentVO() {
       foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(this)) {
-        if (property.DisplayName == "idx" || property.DisplayName == "consentMstRid" || property.DisplayName == "formId") {
+        if (property.DisplayName == "idx" || property.DisplayName == "consentMstRid" || property.DisplayName == "formId" || property.DisplayName == "cretNo") {
           property.SetValue(this, 0);
         } else {
           property.SetValue(this, "");
@@ -43,6 +43,20 @@ namespace CLIP.eForm.Consent.Entity {
     public int formId { get; set; }
     public string formCode { get; set; }
     public string formName { get; set; }
+    public string consentState { get; set; }
+    public string consentStateEng { get; set; }
+    public string prntCnt { get; set; }
+    public string ocrTag { get; set; }
+    public string pid { get; set; }
+    public string patientName { get; set; }
+    public string createUserId { get; set; }
+    public int cretNo { get; set; }
+    public string deptCd { get; set; }
+    public string mainDrId { get; set; }
+    public string inDd { get; set; }
+    public string ordDeptCd { get; set; }
+    public string ordType { get; set; }
+
   }
 
   /*

+ 316 - 351
CLIP.e-Form.Consent.Web/ConsentSvc.asmx.cs

@@ -140,15 +140,16 @@ namespace CLIP.eForm.Consent.WebService {
     /// <summary>
     /// 환자, 상태에 따른 동의서 목록 검색
     /// </summary>
-    /// <param name="pid">환자등록번호</param>
-    /// <param name="userId">사용자 아이디, 작성자별 조회시 pid는 입력하지 않고 userId만 보내줘야함</param>
+    /// <param name="patientCode">환자등록번호</param>
     /// <param name="startDt">데이터생성일자 조회 시작일</param>
-    /// <param name="endDt">조회 마지막 일자 (현재 일자를 넣음)</param>
-    /// <param name="consentState">동의서 상태</param>
+    /// <param name="endDt">The end dt.</param>
+    /// <param name="consentState">State of the conset.</param>
     /// <param name="instCd">근무지기관코드</param>
+    /// <param name="userId">The user identifier.</param>
     /// <returns></returns>
     [WebMethod(Description = "환자/상태에 따른 동의서 목록 검색")]
-    public List<ConsentVO> GetConsentList(string pid, string userId, string startDt, string endDt, string consentState, string instCd) {
+    public List<ConsentVO> GetConsentList(string patientCode, string startDt, string endDt, string consentState, string instCd
+                                        , string userId) {
 
       List<ConsentVO> result;
 
@@ -175,14 +176,15 @@ namespace CLIP.eForm.Consent.WebService {
         using (ConsentDac dac = new ConsentDac()) {
 
           Hashtable param = new Hashtable {
-                        { "pid", pid },
-                        { "userId", userId },
+                        { "patientCode", patientCode },
                         { "startDt", startDt },
                         { "endDt", endDt },
                         { "consentState", consentState },
-                        { "instCd", instCd }
+                        { "instCd", instCd },
+                        { "userId", userId ?? string.Empty}
                     };
 
+          //result = (List<ConsentFormListVO>) dac.GetConsentList(this.IbatisMapper, param);
           result = (List<ConsentVO>) dac.GetConsentList(this.IbatisMapper, param);
         }
 
@@ -387,9 +389,8 @@ namespace CLIP.eForm.Consent.WebService {
     /// </summary>
     /// <param name="userId">사용자 아이디 107810</param>
     /// <param name="instCd">근무지기관코드</param>
-    /// <param name="toDay">오늘 날짜</param>
     [WebMethod(Description = "동의서 SET 조회")]
-    public List<ConsentVO> GetConsentSetList(string userId, string instCd, string toDay) {
+    public List<ConsentVO> GetConsentSetList(string userId, string instCd) {
       List<ConsentVO> result;
 
       try {
@@ -397,7 +398,6 @@ namespace CLIP.eForm.Consent.WebService {
           Hashtable param = new Hashtable();
           param.Add("instCd", instCd);
           param.Add("userId", userId);
-          param.Add("toDay", toDay);
           result = (List<ConsentVO>) dac.GetConsentSetList(this.IbatisMapper, param);
         }
 
@@ -540,8 +540,8 @@ namespace CLIP.eForm.Consent.WebService {
 
       try {
         using (ConsentDac dac = new ConsentDac()) {
-          string remotePath = "";
-          Dictionary<String, String> remoteData = remoteInfo();
+          //          string remotePath = "";
+          //          Dictionary<String, String> remoteData = remoteInfo();
           Hashtable param = new Hashtable();
 
           int consentMstRidInt = 0;
@@ -549,6 +549,7 @@ namespace CLIP.eForm.Consent.WebService {
 
           param.Add("consent-mst-rid", consentMstRidInt);
           result = (List<ConsentImageVO>) dac.GetConsentImage(this.IbatisMapper, param);
+          /*
           remotePath = result[0].imagePath;
 
           // 계정을 choiadmin 으로 가장한다
@@ -586,7 +587,8 @@ namespace CLIP.eForm.Consent.WebService {
         }
         // ?? 왜 로컬에 있는 tempfile 들을 삭제할까?
         //int iResult = DeleteTempFile();
-
+        */
+        }
         return result;
       } catch (Exception ex) {
         CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm GetConsentImage error: {0}", ex.Message));
@@ -710,90 +712,112 @@ namespace CLIP.eForm.Consent.WebService {
     }
 
     /// <summary>
-    /// 임시저장, 확인저장
+    /// 전자동의서를 임시저장 한다.
     /// </summary>
     /// <param name="userId">로그인 사용자ID</param>
-    /// <param name="userDeptCd">로그인 사용자 부서 코드</param>
-    /// <param name="pid">환자 등록번호</param>
-    /// <param name="formId">서식 ID</param>
-    /// <param name="formCd">서식 코드</param>
-    /// <param name="patientDeptCd">환자가 내원한, 속해있는 부서 코드</param>
-    /// <param name="formXml">서식 정보</param>
-    /// <param name="dataXml">사용자가 작성한 서식 내용</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="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="deviceMacAddr">장비 고유 식별자</param>
-    /// <param name="ordType">내원 구분 입원 : I, 외래 : O, 수술 : OP, 응급 : ER</param>
-    /// <param name="instCd">근무지 기관코드</param>
-    /// <param name="inDd">내원 일자 입원 : inDd, 외래 : ordDd</param>
-    /// <param name="ward">병동</param>
-    /// <param name="roomCd">병실</param>
-    /// <param name="ocrTag">ocrTag</param>
-    /// <param name="cretNo">생성번호</param>
-    /// <param name="mainDrId">환자를 담당하는 의사(담당교수, 주치의, 담당의사 등)</param>
-    /// <param name="formPageCnt">동의서 총 장수</param>
-    /// <param name="actionKind">임시저장 : T, 인증저장 : C</param>
-    /// <param name="opRsrvNo">수술번호</param>
-    /// <param name="consentState">동의서 상태</param>
-    /// <param name="orderNo">처방번호</param> 20190822 원형만 유지하되 당장 사용하지 않음
-    /// <param name="orderName">처방 이름</param> 20190822 원형만 유지하되 당장 사용하지 않음
-    /// <param name="orderCd">처방 코드?</param> 20190822 원형만 유지하되 당장 사용하지 않음
-    /// <param name="audioFileJson">음성녹음 바이너리 데이터</param>
-    /// <param name="audioFileSize">음성녹음 파일 사이즈</param>
-    /// <param name="imageFileJson">이미지 바이너리 데이터</param>
-    /// <param name="fileSize">이미지 파일 사이즈</param>
-    /// <returns></returns>
+    /// <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>
+    /// <param name="userDeptCd">사용자 부서 코드</param>
+    /// <param name="pageCnt">동의서 매수</param>
+    /// <param name="actKind">동작코드(T: 임시 저장, C: 인증 저장, P: 출력, CP: 삭제)</param>
+    /// <param name="clientType">Client구분 (P: PC, M: 모바일)</param>
+    /// <param name="opRsrvNo">수술예약번호</param>
+    /// <returns>
+    /// CONSENT_MST_RID
+    /// </returns>
     [WebMethod(Description = "동의서 임시저장")]
-    public SingleReturnData SaveTempData(string userId, string userDeptCd, string pid, string formId, string formCd, string patientDeptCd, string formXml, string dataXml,
-                            int consentMstRid, int reWriteConsentMstRid, string deviceType, string deviceMacAddr, string ordType, string instCd, string inDd, string dSchDd,
-                            string ward, string roomCd, string ocrTag, int cretNo, string mainDrId, string formPageCnt, string actionKind, string opRsrvNo, string consentState,
-                            int orderNo, string orderName, string orderCd, string audioFileJson, string audioFileSize, string imageFileJson, string fileSize) {
-
+    public SingleReturnData 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 userDeptCd, string pageCnt, string actKind, string clientType, string opRsrvNo,
+                                string consentState) {
       SingleReturnData result = new SingleReturnData();
 
-      //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(String.Format("userId -- >  [{0}]", userId));
-      //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("userDeptCd -- > " + userDeptCd);
-      //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("pid -- > " + pid);
-      //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("formId -- > " + formId);
-      //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("formCd -- > " + formCd);
-      //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("patientDeptCd -- > " + patientDeptCd);
-      ////CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("formXml -- > " + formXml);
-      ////CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("dataXml -- > " + dataXml);
-      //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("consentMstRid -- > " + consentMstRid);
-      //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("reWriteConsentMstRid -- > " + reWriteConsentMstRid);
-      //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("deviceType -- > " + deviceType);
-      //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("deviceMacAddr -- > " + deviceMacAddr);
-      //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("ordType -- > " + ordType);
-      //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("instCd -- > " + instCd);
-      //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("inDd -- > " + inDd);
-      //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("ward -- > " + ward);
-      //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("roomCd -- > " + roomCd);
-      //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("ocrTag -- > " + ocrTag);
-      //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("cretNo -- > " + cretNo);
-      //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("mainDrId -- > " + mainDrId);
-      //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("formPageCnt -- > " + formPageCnt);
-      //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("actionKind -- > " + actionKind);
-      //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("opRsrvNo -- > " + opRsrvNo);
-      //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("consentState -- > " + consentState);
-      //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("orderNo -- > " + orderNo);
-      //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("orderName -- > " + orderName);
-      //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("orderCd -- > " + orderCd);
-
-      consentMstRid = SaveData(userId, userDeptCd, pid, formId, formCd, patientDeptCd, formXml, dataXml,
-                               consentMstRid, reWriteConsentMstRid, deviceType, deviceMacAddr, ordType, instCd, inDd, dSchDd,
-                               ward, roomCd, ocrTag, cretNo, mainDrId, formPageCnt, actionKind, opRsrvNo, consentState,
-                               orderNo, orderName, orderCd, audioFileJson, audioFileSize, imageFileJson, fileSize);
+      int reissueConsentMstRid = 0;
+
+      consentState = string.IsNullOrEmpty(consentState) ? "TEMP" : consentState;
+
+      consentMstRid = SaveData(userId, patientCode, clnDeptCode, formRid, formCd,
+                               consentMstRid, 0, reissueConsentMstRid, consentState, "N", formXml, dataXml,
+                               deviceType, deviceIdentNo, vistType, hosType, clnDate,
+                               ward, roomCd, string.Empty, orderNo, orderName, orderCd, ocrCode, cretNo,
+                               createUserName, modifyUserName, null, null, null, mainDrId,
+                               userDeptCd, pageCnt, actKind, clientType, opRsrvNo);
 
       result.responseData = Convert.ToString(consentMstRid);
       return result;
     }
 
-    public int SaveData(string userId, string userDeptCd, string pid, string formId, string formCd, string patientDeptCd, string formXml, string dataXml,
-                        int consentMstRid, int reWriteConsentMstRid, string deviceType, string deviceMacAddr, string ordType, string instCd, string inDd, string dSchDd,
-                        string ward, string roomCd, string ocrTag, int cretNo, string mainDrId, string formPageCnt, string actionKind, string opRsrvNo, string consentState,
-                        int orderNo, string orderName, string orderCd, string audioFileJson, string audioFileSize, string imageFileJson, string fileSize) {
-      
+    /// <summary>
+    /// Saves the data.
+    /// </summary>
+    /// <param name="userId">The user identifier.</param>
+    /// <param name="patientCode">The patient code.</param>
+    /// <param name="clnDeptCode">The CLN dept code.</param>
+    /// <param name="formRid">The form rid.</param>
+    /// <param name="formCd">The form cd.</param>
+    /// <param name="consentMstRid">The consent MST rid.</param>
+    /// <param name="rewriteConsentMstRid">The rewrite consent MST rid.</param>
+    /// <param name="reissueConsentMstRid">The reissue consent MST rid.</param>
+    /// <param name="consentState">State of the consent.</param>
+    /// <param name="paperYn">The paper yn.</param>
+    /// <param name="formXml">The form XML.</param>
+    /// <param name="dataXml">The data XML.</param>
+    /// <param name="deviceType">Type of the device.</param>
+    /// <param name="deviceIdentNo">The device ident no.</param>
+    /// <param name="vistType">Type of the vist.</param>
+    /// <param name="hosType">Type of the hos.</param>
+    /// <param name="clnDate">The CLN date.</param>
+    /// <param name="ward">The ward.</param>
+    /// <param name="roomcd">The roomcd.</param>
+    /// <param name="reasonForUseN">The reason for use n.</param>
+    /// <param name="orderNo">The order no.</param>
+    /// <param name="orderName">Name of the order.</param>
+    /// <param name="orderCd">The order cd.</param>
+    /// <param name="ocrCode">The ocr code.</param>
+    /// <param name="cretno">The cretno.</param>
+    /// <param name="createUserName">Name of the create user.</param>
+    /// <param name="modifyUserName">Name of the modify user.</param>
+    /// <param name="imageFileName">Name of the image file.</param>
+    /// <param name="certTarget">The cert target.</param>
+    /// <param name="certResult">The cert result.</param>
+    /// <param name="mainDrId">The main dr identifier.</param>
+    /// <param name="userDeptCd">The user dept cd.</param>
+    /// <param name="pageCnt">The page count.</param>
+    /// <param name="actKind">Kind of the act.</param>
+    /// <param name="clientType">Type of the client.</param>
+    /// <param name="opRsrvNo">The op RSRV no.</param>
+    /// <returns></returns>
+    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, string userDeptCd, string pageCnt, string actKind, string clientType, string opRsrvNo) {
+
       bool isNewConsentMasterCase = false;
       if (consentMstRid < 1) {
         isNewConsentMasterCase = true;
@@ -806,94 +830,78 @@ namespace CLIP.eForm.Consent.WebService {
       try {
         using (SaveConsentDac dac = new SaveConsentDac()) {
 
-          int updateResult = 0;
-          int deleteResult = 0;
+          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, opRsrvNo, pageCnt);
 
-          Hashtable imrParam = new Hashtable();
-          imrParam.Add("ocrTag", "'" + ocrTag + "%'");
-          int imrCount = (int) dac.ImrCount(this.IbatisMapper, imrParam);
+          consentMstRid = (int) paramHashTable["consentMstRid"];
+          
+          //새로 작성하는 경우
+          if (isNewConsentMasterCase) {
+            //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("");
+            dac.InsertConsentMst(this.IbatisMapper, paramHashTable);
+            dac.InsertConsentData(this.IbatisMapper, paramHashTable);
 
-          ImrData imrData = new ImrData();
-          if (imrCount > 0) {
-            imrData = (ImrData) dac.ImrData(this.IbatisMapper, imrParam);
-          }
+          } else { //새로 작성 아닌 경우
 
-          Hashtable paramHashTable = GetParamHashTable(userId, userDeptCd, pid, formId, formCd, patientDeptCd, formXml, dataXml,
-                                                       consentMstRid, reWriteConsentMstRid, deviceType, deviceMacAddr, ordType, instCd, inDd,
-                                                       ward, roomCd, ocrTag, cretNo, mainDrId, formPageCnt, actionKind, opRsrvNo, consentState,
-                                                       orderNo, orderName, orderCd, null, null);
+            if (reissueConsentMstRid > 0) {
 
-          //reasonForUseN
-          paramHashTable.Add("macAddress", deviceMacAddr);
-          consentMstRid = (int) paramHashTable["consentMstRid"];
+              if (string.IsNullOrEmpty(reasonForUseN)) {
+                //종이->종이 재발행 
+                int newConsentMstRid = this.GetSequence("CONSENT_MST");
+                paramHashTable["consentMstRid"] = newConsentMstRid;
+                consentMstRid = newConsentMstRid;
 
-          if (isNewConsentMasterCase == true) {
-            dac.InsertConsentMst(this.IbatisMapper, paramHashTable);
-            dac.InsertConsentData(this.IbatisMapper, paramHashTable);
-          } else {
-            dac.UpdateConsentMst(this.IbatisMapper, paramHashTable);
-            dac.UpdateConsentData(this.IbatisMapper, paramHashTable);
-          }
+                dac.InsertConsentMst(this.IbatisMapper, paramHashTable);
+                dac.InsertConsentData(this.IbatisMapper, paramHashTable);
 
-          if (!string.IsNullOrEmpty(audioFileJson)) {
-            audioUpLoad(dac, paramHashTable, userId, consentMstRid, formId, audioFileJson, audioFileSize, ocrTag, pid);
-          }
+              } else { // 삭제
 
-          if (!string.IsNullOrEmpty(imageFileJson)) {
-            imageUpload(dac, paramHashTable, userId, pid, ordType, inDd, dSchDd, cretNo, ocrTag, consentMstRid, consentState, formCd, formId, dataXml, imageFileJson, instCd, patientDeptCd, fileSize);
-          }
+                dac.UpdateConsentMstForDelete(this.IbatisMapper, paramHashTable);
 
-          if (imrCount > 0) {
-            String[] strAr = imrData.fileName.Split(new char[] { '_' });
-            imrData.fileName = strAr[0] + "_" + strAr[1];
+              }
 
-            imrParam.Add("fileName", "'" + imrData.fileName + "%'");
-            imrParam.Add("inputDate", imrData.inputDate);
-            imrParam.Add("userId", imrData.userId);
+            } else { //임시저장 또는 저장인 경우
 
-            updateResult = dac.ImrScanFileUpdate(this.IbatisMapper, imrParam);
-            if (updateResult > 0) {
-              deleteResult = dac.ImrScanFileDelete(this.IbatisMapper, imrParam);
-            }
+              dac.UpdateConsentMst(this.IbatisMapper, paramHashTable);
+              dac.InsertConsentData(this.IbatisMapper, paramHashTable);
 
-            if (imrCount != deleteResult) {
-              throw new Exception();
             }
-
           }
 
+          // OCR 테이블 연계
           Hashtable ocrParam = new Hashtable {
-                        { "instcd", instCd },
-                        { "ocrtag", ocrTag },
-                        { "pid", pid },
-                        { "ordtype", ordType },
-                        { "orddd", inDd },
-                        { "cretno", cretNo },
+                        { "instcd", hosType },
+                        { "ocrtag", ocrCode },
+                        { "pid", patientCode },
+                        { "ordtype", vistType },
+                        { "orddd", clnDate },
+                        { "cretno", cretno },
                         { "orddrid", mainDrId },
-                        { "orddeptcd", patientDeptCd },
+                        { "orddeptcd", clnDeptCode },
                         { "formcd", formCd },
                         { "fstprntdeptcd", userDeptCd },
                         { "fstprntid", userId },
                         { "updtdeptcd", userDeptCd },
                         { "updtuserid", userId },
                         { "updtdt", DateTime.Now.ToString("yyyyMMddHHmmss")},
-                        { "pagecnt", formPageCnt },
-                        //{ "updtresncnts", reasonForUseN },
-                        { "actkind", actionKind },
-                        { "clienttype", "M" }
+                        { "pagecnt", pageCnt },
+                        { "updtresncnts", reasonForUseN },
+                        { "actkind", actKind },
+                        { "clienttype", clientType }
                     };
 
           dac.InsertPrintData(this.IbatisMapper, ocrParam);
-
-          if (this.IbatisSession != null) this.IbatisSession.CommitTransaction();
-
         }
       } 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()));
+        return -1;
         throw ex;
+      } finally {
       }
-
       return consentMstRid;
     }
 
@@ -1002,93 +1010,6 @@ namespace CLIP.eForm.Consent.WebService {
 
     }
 
-    private Hashtable GetParamHashTable(string userId, string userDeptCd, string pid, string formId, string formCd, string patientDeptCd, string formXml, string dataXml,
-                                        int consentMstRid, int reWriteConsentMstRid, string deviceType, string deviceMacAddr, string ordType, string instCd, string inDd,
-                                        string ward, string roomCd, string ocrTag, int cretNo, string mainDrId, string formPageCnt, string actionKind, string opRsrvNo, string consentState,
-                                        int orderNo, string orderName, string orderCd, string certResult, string certTarget) {
-
-      Hashtable paramHashTable = new Hashtable();
-      paramHashTable.Add("userId", userId);
-
-      if (consentMstRid < 1) {
-        consentMstRid = this.GetSequence("CONSENT_MST");
-      }
-
-      paramHashTable.Add("consentMstRid", consentMstRid);
-      paramHashTable.Add("patientCode", pid);
-      paramHashTable.Add("clnDeptCd", patientDeptCd);
-      paramHashTable.Add("vistType", ordType);
-      paramHashTable.Add("hosType", instCd);
-      paramHashTable.Add("clnDate", inDd);
-      paramHashTable.Add("ward", ward);
-      paramHashTable.Add("roomcd", roomCd);
-      paramHashTable.Add("orderNo", orderNo);
-      paramHashTable.Add("orderName", orderName);
-      paramHashTable.Add("orderCd", orderCd);
-      paramHashTable.Add("ocrCode", ocrTag);
-      paramHashTable.Add("cretno", cretNo);
-      paramHashTable.Add("createUserName", userId);
-      paramHashTable.Add("modifyUserName", userId);
-      paramHashTable.Add("formRid", formId);
-      paramHashTable.Add("formCd", formCd);
-      paramHashTable.Add("consentState", consentState);
-      paramHashTable.Add("certTarget", certTarget);   // TODO 원무 pass
-      paramHashTable.Add("certResult", certResult);   // TODO 원무 pass
-      paramHashTable.Add("mainDrId", mainDrId);
-      paramHashTable.Add("opRsrvNo", opRsrvNo ?? string.Empty);
-
-      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", "''");
-      }
-
-      string rewriteYn = "N"; // 재 작성 여부
-      if (reWriteConsentMstRid > 1) {
-        rewriteYn = "Y";
-      }
-      paramHashTable.Add("rewriteYn", rewriteYn);
-      paramHashTable.Add("rewriteConsentMstRid", reWriteConsentMstRid);
-
-      int consentDataRid = this.GetSequence("CONSENT_DATA");
-      paramHashTable.Add("consentDataRid", consentDataRid);
-
-      paramHashTable.Add("useYn", "Y");
-
-      Encoding 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("deviceMacAddr", deviceMacAddr);
-      paramHashTable.Add("pageCnt", formPageCnt);
-      //paramHashTable.Add("reasonForUseN", reasonForUseN);
-
-      return paramHashTable;
-    }
-
     /// <summary>
     /// 일괄인증저장
     /// </summary>
@@ -1206,61 +1127,87 @@ namespace CLIP.eForm.Consent.WebService {
     }
 
     /// <summary>
-    /// 임시저장, 확인저장
+    /// 전자 동의서를 완료저장 한다.
     /// </summary>
     /// <param name="userId">로그인 사용자ID</param>
-    /// <param name="userDeptCd">로그인 사용자 부서 코드</param>
-    /// <param name="pid">환자 등록번호</param>
-    /// <param name="formId">서식 ID</param>
-    /// <param name="formCd">서식 코드</param>
-    /// <param name="patientDeptCd">환자가 내원한, 속해있는 부서 코드</param>
-    /// <param name="formXml">서식 정보</param>
-    /// <param name="dataXml">사용자가 작성한 서식 내용</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="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="deviceMacAddr">장비 고유 식별자</param>
-    /// <param name="ordType">내원 구분 입원 : I, 외래 : O, 수술 : OP, 응급 : ER</param>
-    /// <param name="instCd">근무지 기관코드</param>
-    /// <param name="inDd">내원 일자 입원 : inDd, 외래 : ordDd</param>
-    /// <param name="ward">병동</param>
-    /// <param name="roomCd">병실</param>
-    /// <param name="ocrTag">ocrTag</param>
-    /// <param name="cretNo">생성번호</param>
-    /// <param name="mainDrId">환자를 담당하는 의사(담당교수, 주치의, 담당의사 등)</param>
-    /// <param name="formPageCnt">동의서 총 장수</param>
-    /// <param name="actionKind">임시저장 : T, 인증저장 : C</param>
-    /// <param name="opRsrvNo">수술번호</param>
-    /// <param name="consentState">동의서 상태</param>
-    /// <param name="orderNo">처방번호</param> 20190822 원형만 유지하되 당장 사용하지 않음
-    /// <param name="orderName">처방 이름</param> 20190822 원형만 유지하되 당장 사용하지 않음
-    /// <param name="orderCd">처방 코드?</param> 20190822 원형만 유지하되 당장 사용하지 않음
+    /// <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="fileSize">이미지 파일 사이즈(전자동의서 서버)</param>
-    /// <param name="audioFileJson">오디오 파일 정보(전자동의서 서버)</param>
-    /// <param name="audioFileSize">오디오 파일 사이즈</param>
+    /// <param name="certTarget">이미지 파일 공인인증 대상정보</param>
+    /// <param name="certResult">이미지 파일 공인인증 처리정보</param>
+    /// <param name="dschdd">퇴원일자</param>
+    /// <param name="consentState">상태</param>
+    /// <param name="mainDrId">주치의 아이디</param>
+    /// <param name="userDeptCd">사용자 부서 코드</param>
+    /// <param name="pageCnt">동의서 매수</param>
+    /// <param name="actKind">동작코드(T: 임시 저장, C: 인증 저장, P: 출력, CP: 삭제)</param>
+    /// <param name="clientType">Client구분 (P: PC, M: 모바일)</param>
+    /// <param name="fileSize">이미지 파일 사이즈</param>
     [WebMethod(Description = "동의서 서명 완료")]
-    public SingleReturnData SaveCompleteAll(string userId, string userDeptCd, string pid, string formId, string formCd, string patientDeptCd, string formXml, string dataXml,
-                               int consentMstRid, int reWriteConsentMstRid, string deviceType, string deviceMacAddr, string ordType, string instCd, string inDd, string dSchDd,
-                               string ward, string roomCd, string ocrTag, int cretNo, string mainDrId, string formPageCnt, string actionKind, string opRsrvNo, string consentState,
-                               int orderNo, string orderName, string orderCd, string imageFileJson, string fileSize, string certResult, string certTarget,
-                               string audioFileJson, string audioFileSize) {
+    public SingleReturnData 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 userDeptCd, string pageCnt, string actKind, string clientType, string opRsrvNo, string fileSize) {
 
       SingleReturnData result = new SingleReturnData();
 
-      consentMstRid = SaveDataAll(userId, userDeptCd, pid, formId, formCd, patientDeptCd, formXml, dataXml,
-                            consentMstRid, reWriteConsentMstRid, deviceType, deviceMacAddr, ordType, instCd, inDd, dSchDd,
-                            ward, roomCd, ocrTag, cretNo, mainDrId, formPageCnt, actionKind, opRsrvNo, consentState,
-                            orderNo, orderName, orderCd, imageFileJson, fileSize, certResult, certTarget, audioFileJson, audioFileSize, out int rslt);
+      //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 + "]" + "fileSize[" + fileSize + "]";
+      //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("CLIP.eForm SaveCompleteAll param : " + paramLog);
+      CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("json : " + imageFileJson);
+
+      int reissueConsentMstRid = 0;
+      string paperYn = "N";
+      string reasonForUseN = string.Empty;
+
+      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,
+                               userDeptCd, pageCnt, actKind, clientType, opRsrvNo, fileSize);
 
-      result.responseData = Convert.ToString(rslt);
+      result.responseData = Convert.ToString(consentMstRid);
       return result;
     }
 
-    public int SaveDataAll(string userId, string userDeptCd, string pid, string formId, string formCd, string patientDeptCd, string formXml, string dataXml,
-                           int consentMstRid, int reWriteConsentMstRid, string deviceType, string deviceMacAddr, string ordType, string instCd, string inDd, string dSchDd,
-                           string ward, string roomCd, string ocrTag, int cretNo, string mainDrId, string formPageCnt, string actionKind, string opRsrvNo, string consentState,
-                           int orderNo, string orderName, string orderCd, string imageFileJson, string fileSize, string certResult, string certTarget, string audioFileJson, string audioFileSize, out int result) {
+    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,
+                                       string userDeptCd, string pageCnt, string actKind, string clientType, string opRsrvNo, string fileSize) {
 
       bool isNewConsentMasterCase = false;
       if (consentMstRid < 1) {
@@ -1273,119 +1220,135 @@ namespace CLIP.eForm.Consent.WebService {
 
       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, opRsrvNo, pageCnt);
 
-          int updateResult = 0;
-          int deleteResult = 0;
-
-          Hashtable imrParam = new Hashtable();
-          imrParam.Add("ocrTag", "'" + ocrTag + "%'");
-          int imrCount = (int) dac.ImrCount(this.IbatisMapper, imrParam);
-
-          ImrData imrData = new ImrData();
-          if (imrCount > 0) {
-            imrData = (ImrData) dac.ImrData(this.IbatisMapper, imrParam);
-          }
-
-          Hashtable paramHashTable = GetParamHashTable(userId, userDeptCd, pid, formId, formCd, patientDeptCd, formXml, dataXml,
-                                                       consentMstRid, reWriteConsentMstRid, deviceType, deviceMacAddr, ordType, instCd, inDd,
-                                                       ward, roomCd, ocrTag, cretNo, mainDrId, formPageCnt, actionKind, opRsrvNo, consentState,
-                                                       orderNo, orderName, orderCd, certResult, certTarget);
-
-          paramHashTable.Add("macAddress", deviceMacAddr);
           consentMstRid = (int) paramHashTable["consentMstRid"];
-          result = consentMstRid;
 
-          if (isNewConsentMasterCase == true) {
+          //새로 작성하는 경우
+          if (isNewConsentMasterCase) {
             dac.InsertConsentMst(this.IbatisMapper, paramHashTable);
             dac.InsertConsentData(this.IbatisMapper, paramHashTable);
-            imageUpload(dac, paramHashTable, userId, pid, ordType, inDd, dSchDd, cretNo, ocrTag, consentMstRid, consentState, formCd, formId, dataXml, imageFileJson, instCd, patientDeptCd, fileSize);
-          } else {
 
-            if (consentState == "CERTIFY_CMP" && reWriteConsentMstRid > 0) {
+            
+            /*
+            imageUpload(dac, paramHashTable, userId
+                        , patientCode, vistType, clnDate, dschdd, cretno, ocrCode
+                        , consentMstRid, consentState, formCd, formRid, dataXml
+                        , imageFileJson, certTarget, certResult, hosType, createUserName, hosType, fileSize);
+                        */
+          }
+            //새로 작성 아닌 경우
+            else {
+            if (reissueConsentMstRid > 0) {
+              //종이->종이 재발행 
               int newConsentMstRid = this.GetSequence("CONSENT_MST");
-              paramHashTable["rewriteConsentMstRid"] = newConsentMstRid;
-              dac.ReWriteUpdateConsentMst(this.IbatisMapper, paramHashTable);
-
+              paramHashTable["consentMstRid"] = newConsentMstRid;
               consentMstRid = newConsentMstRid;
-              paramHashTable["consentMstRid"] = consentMstRid;
-              paramHashTable["rewriteYn"] = "N";
-              paramHashTable["useYn"] = "Y";
-              paramHashTable["rewriteConsentMstRid"] = 0;
 
               dac.InsertConsentMst(this.IbatisMapper, paramHashTable);
               dac.InsertConsentData(this.IbatisMapper, paramHashTable);
-              imageUpload(dac, paramHashTable, userId, pid, ordType, inDd, dSchDd, cretNo, ocrTag, consentMstRid, consentState, formCd, formId, dataXml, imageFileJson, instCd, patientDeptCd, fileSize);
-            } else {
-              dac.UpdateConsentMst(this.IbatisMapper, paramHashTable);
-              dac.UpdateConsentData(this.IbatisMapper, paramHashTable);
-              imageUpload(dac, paramHashTable, userId, pid, ordType, inDd, dSchDd, cretNo, ocrTag, consentMstRid, consentState, formCd, formId, dataXml, imageFileJson, instCd, patientDeptCd, fileSize);
-            }
-          }
-
-
 
-          if (!string.IsNullOrEmpty(audioFileJson)) {
-            audioUpLoad(dac, paramHashTable, userId, consentMstRid, formId, audioFileJson, audioFileSize, ocrTag, pid);
-          }
-
-          if (imrCount > 0) {
-            String[] strAr = imrData.fileName.Split(new char[] { '_' });
-            imrData.fileName = strAr[0] + "_" + strAr[1];
-
-            imrParam.Add("fileName", "'" + imrData.fileName + "%'");
-            imrParam.Add("inputDate", imrData.inputDate);
-            imrParam.Add("userId", imrData.userId);
-
-            updateResult = dac.ImrScanFileUpdate(this.IbatisMapper, imrParam);
-            if (updateResult > 0) {
-              deleteResult = dac.ImrScanFileDelete(this.IbatisMapper, imrParam);
             }
+            //임시저장 또는 저장인 경우
+            else {
 
-            if (imrCount != deleteResult) {
-              throw new Exception();
+              dac.UpdateConsentMst(this.IbatisMapper, paramHashTable);
+              dac.InsertConsentData(this.IbatisMapper, paramHashTable);
+
+              
             }
           }
 
+          imageSaveData(dac, imageFileJson, consentMstRid, userId, formRid);
+
+          // OCR 테이블 연계
           Hashtable ocrParam = new Hashtable {
-                        { "instcd", instCd },
-                        { "ocrtag", ocrTag },
-                        { "pid", pid },
-                        { "ordtype", ordType },
-                        { "orddd", inDd },
-                        { "cretno", cretNo },
+                        { "instcd", hosType },
+                        { "ocrtag", ocrCode },
+                        { "pid", patientCode },
+                        { "ordtype", vistType },
+                        { "orddd", clnDate },
+                        { "cretno", cretno },
                         { "orddrid", mainDrId },
-                        { "orddeptcd", patientDeptCd },
+                        { "orddeptcd", clnDeptCode },
                         { "formcd", formCd },
                         { "fstprntdeptcd", userDeptCd },
                         { "fstprntid", userId },
                         { "updtdeptcd", userDeptCd },
                         { "updtuserid", userId },
                         { "updtdt", DateTime.Now.ToString("yyyyMMddHHmmss")},
-                        { "pagecnt", formPageCnt },
-                        //{ "updtresncnts", reasonForUseN },
-                        { "actkind", actionKind },
-                        { "clienttype", "M" }
+                        { "pagecnt", pageCnt },
+                        { "updtresncnts", reasonForUseN },
+                        { "actkind", actKind },
+                        { "clienttype", clientType }
                     };
 
-          dac.InsertPrintData(this.IbatisMapper, ocrParam, isNewConsentMasterCase);
+          dac.InsertPrintData(this.IbatisMapper, ocrParam);
+
+        }
+      } 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()));
+        return -1;
+        throw ex;
+      } finally {
+      }
+      return consentMstRid;
+    }
+
+    private void imageSaveData(SaveConsentDac dac, String imageFileJson, int consentMstRid, string userId, int formId) {
+      Dictionary<string, object> jsonRoot = fastJSON.JSON.Parse(imageFileJson) as Dictionary<string, object>;
+      int consentImageRid = this.GetSequence("CONSENT_IMAGE");
+      string sPath = string.Empty;
+      string sFileName = string.Empty;
 
-          //CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Debug("formCd -- > " + formCd);
-          if (formCd == "1200005463" || formCd == "1800014564") {
-            SavePatientConsentInfo(formCd, pid, ocrTag, userId, dataXml);
+      int nowCnt = 1;
+
+      try {
+        foreach (KeyValuePair<string, object> jr in jsonRoot) {
+          Hashtable imageHashTable = new Hashtable();
+          imageHashTable.Add("consentMstRid", consentMstRid);
+
+          consentImageRid = this.GetSequence("CONSENT_IMAGE");
+          
+          imageHashTable.Add("consentImageRid", consentImageRid);
+          imageHashTable.Add("userId", userId);
+          imageHashTable.Add("formRid", formId);
+
+          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];
+              }
+
+            }
           }
 
-          if (this.IbatisSession != null) this.IbatisSession.CommitTransaction();
+          imageHashTable.Add("imagePath", sPath);
+          imageHashTable.Add("imageFilename", sFileName);
+          imageHashTable.Add("completeYn", "Y");
 
+          dac.InsertConsentImage(this.IbatisMapper, imageHashTable);
         }
-      } 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()));
-        result = -1;
+        nowCnt++;
+      } catch(Exception ex) {
+        CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm imageSaveData ERROR : [{0}]", ex.ToString()));
         throw ex;
       }
 
-      return result;
     }
 
     private void imageUpload(SaveConsentDac dac, Hashtable paramHashTable, string userId, string pid, string ordType, string inDd, string dSchDd, int cretNo, string ocrTag,
@@ -2444,7 +2407,7 @@ namespace CLIP.eForm.Consent.WebService {
                                                        reissueConsentMstRid, consentState, paperYn, formXml, dataXml, deviceType, deviceIdentNo,
                                                        vistType, hosType, clnDate, ward, roomcd, reasonForUseN,
                                                        orderNo, orderName, orderCd, ocrCode, cretno, createUserName, modifyUserName,
-                                                       certTarget, certResult, mainDrId, opRsrvNo);
+                                                       certTarget, certResult, mainDrId, opRsrvNo, pageCnt);
 
           consentMstRid = (int) paramHashTable["consentMstRid"];
 
@@ -2636,7 +2599,8 @@ namespace CLIP.eForm.Consent.WebService {
                                             string certTarget,          // 서명데이터 원본
                                             string certResult,          // 서명데이터 결과값
                                             string mainDrId,            // 주치의 아이디
-                                            string opRsrvNo             // 수술 예약 번호
+                                            string opRsrvNo,             // 수술 예약 번호
+                                            string pageCnt
                                         ) {
       Hashtable paramHashTable = new Hashtable();
       paramHashTable.Add("userId", userId);
@@ -2666,6 +2630,7 @@ namespace CLIP.eForm.Consent.WebService {
       paramHashTable.Add("certResult", certResult);   // TODO 원무 pass
       paramHashTable.Add("mainDrId", mainDrId);
       paramHashTable.Add("opRsrvNo", opRsrvNo ?? string.Empty);
+      paramHashTable.Add("pageCnt", pageCnt);
 
       Encoding encoding = Encoding.GetEncoding("UTF-8");
       //if (certResult != null)

+ 10 - 17
CLIP.e-Form.Consent.Web/HospitalSvc.asmx.cs

@@ -876,37 +876,30 @@ namespace CLIP.eForm.Consent.WebService {
     /// </summary>
     /// <param name="userId">사용자 아이디 107810</param>
     /// <param name="formCd">서식코드 </param>
-    /// <param name="dutInstCd">근무지기관코드</param>
-    /// <param name="toDay">오늘 날짜</param>
+    /// <param name="instCd">근무지기관코드</param>
     [WebMethod(Description = "사용자 즐겨찾기 추가")]
-    public SingleReturnData SetUserFormSetList(string userId, string formCd, string dutInstCd, string toDay) {
+    public SingleReturnData SetUserFormSetList(String userId, String formCd, String instCd) {
       SingleReturnData result = new SingleReturnData();
       int res = 0;
-
       try {
         using (UserDac dac = new UserDac()) {
           Hashtable param = new Hashtable();
-          param.Add("instCd", dutInstCd);
+          param.Add("instCd", instCd);
           param.Add("userId", userId);
           param.Add("formCd", formCd);
-          param.Add("toDay", toDay);
-
-          int count = dac.GetUserFormCode(this.IbatisMapper, param);
-          CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error("count");
-          CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(count);
-          if (count > 0) {
-            result.responseData = "0";
-          } else {
-            res = dac.SetUserFormSet(this.IbatisMapper, param);
-          }
-          
+
+          res = dac.SetUserFormSet(this.IbatisMapper, param);
+
         }
+
+        result.responseData = Convert.ToString(res);
+
+        return result;
       } catch (Exception ex) {
         CLIP.eForm.Server.Diagnostics.LogHelper.LoggingHandler.Error(string.Format("CLIP.eForm SetUserFormSetList error: {0}", ex.Message));
         throw ex;
       }
 
-      return result;
     }
 
     /// <summary>

+ 46 - 117
CLIP.e-Form.Consent.Web/OracleQuery/CLIP.e-Form.Consent.FormRepository.xml

@@ -38,11 +38,24 @@
     
     <statement id="GET_CONSENT_BY_SEARCH_LIST" parameterClass="System.Collections.Hashtable" resultMap="ConsentMap">
       <![CDATA[
-        SELECT '' AS IDX,
+        SELECT ''           AS IDX,
                ''           AS CONSENT_MST_RID,
-               CF.FORM_ID AS FORM_ID,
+               CF.FORM_ID   AS FORM_ID,
                CF.FORM_CODE AS FORM_CODE,
-               CF.FORM_NAME AS FORM_NAME
+               CF.FORM_NAME AS FORM_NAME,
+               ''           AS CONSENT_STATE,
+               ''           AS CONSENT_STATE_ENG,
+               ''           AS PRNT_CNT,
+               ''           AS OCR_TAG,
+               ''           AS PID,
+               ''           AS PATIENT_NAME,
+               ''           AS CREATE_USER_ID,
+               ''           AS CRET_NO,
+               ''           AS DEPT_CD,
+               ''           AS MAIN_DR_ID,
+               ''           AS IN_DD,
+               ''           AS ORD_DEPT_CD,
+               ''           AS ORD_TYPE
           FROM EMA.CLIP_FORM CF
           LEFT OUTER JOIN EMA.CLIP_FORM_DATA CFD
             ON CF.FORM_ID = CFD.FORM_ID
@@ -50,9 +63,12 @@
  
       ]]>
       <isNotEmpty property="categoryId">
-        <![CDATA[
+        <isNotEqual property="categoryId" compareValue="1">
+                  <![CDATA[
           AND CF.FORM_CATEGORY_ID = #categoryId#
         ]]>
+        </isNotEqual>
+
       </isNotEmpty>
       <isNotEmpty property="keyWord">
         <![CDATA[
@@ -181,24 +197,10 @@
     <statement id="GET_CONSENT_LIST" parameterClass="System.Collections.Hashtable" resultMap="ConsentMap">
       <![CDATA[
         SELECT ''                                                                        AS IDX,
+               CONSENT_MST_RID                                                           AS CONSENT_MST_RID,
                CF.FORM_ID                                                                AS FORM_ID,
                CF.FORM_CODE                                                              AS FORM_CODE,
                CF.FORM_NAME                                                              AS FORM_NAME,
-               MF.FORMPRNTNM                                                             AS FORM_PRNT_NM,
-               CMT.PAGECNT                                                               AS PRNT_CNT,
-               (SELECT DECODE(COUNT(FORMCD), 0, 'N', 'Y')                                AS CERT_PASS
-                  FROM EMR.MRFMFORMEMA
-                 WHERE INSTCD   = #instCd#
-                   AND TO_CHAR(SYSDATE, 'YYYYMMDD') BETWEEN FORMFROMDT AND FORMTODT
-                   AND FORMTODT = '99991231'
-                   AND FORMCD   = CF.FORM_CODE)                                           AS CERT_PASS,
-               CMT.PID                                                                    AS PID,
-               (SELECT DEPTENGABBR
-                  FROM com.zsdddept
-                 WHERE INSTCD    = #instCd#
-                   AND TO_CHAR(CURRENT_DATE,'YYYYMMDD') BETWEEN valifromdd AND valitodd
-                   AND RCPTUSEYN = 'Y'
-                   AND DEPTCD    = CMT.CLN_DEPT_CD)                                      AS DEPT_ENG_ABBR,
                DECODE(CMT.CONSENT_STATE, 'TEMP',        '임시',
                                          'ELECTR_CMP',  '확인',
                                          'PAPER_OUT',   '출력',
@@ -206,113 +208,45 @@
                                          'UNFINISHED',  '임시',
                                          'VERBAL',      '구두',
                                          CMT.CONSENT_STATE)                              AS CONSENT_STATE,
-               CMT.CONSENT_MST_RID                                                       AS CONSENT_MST_RID,
+               CMT.CONSENT_STATE                                                         AS CONSENT_STATE_ENG,
+               CMT.PAGECNT                                                               AS PRNT_CNT,
                CMT.OCR_NUMBER                                                            AS OCR_TAG,
-               CMT.MODIFY_USER_ID                                                        AS MODIFY_USER_ID,
-               CMT.MODIFY_USER_NAME                                                      AS MODIFY_USER_NM,
-               CMT.MODIFY_DATETIME                                                       AS MODIFY_DATETIME,
-               CMT.CREATE_DATETIME                                                       AS CREATE_DATETIME,
-               CMT.CLN_DATE                                                              AS CLN_DATE,
+               CMT.PID                                                                   AS PID,
+               (SELECT HNGNM 
+                  FROM PAM.PMCMPTBS PTBS 
+                 WHERE INSTCD = '031'
+                   AND PID    = #patientCode#)                                           AS PATIENT_NAME,
+               CMT.CREATE_USER_ID                                                        AS CREATE_USER_ID,
                CMT.CRETNO                                                                AS CRET_NO,
-               CMT.VISIT_TYPE                                                            AS ORD_TYPE,
                CMT.CLN_DEPT_CD                                                           AS DEPT_CD,
-               CMT.MAIN_DR_ID                                                            AS MAIN_DR_ID
-      ]]>
-      <isNotEmpty property="userId">
-        <![CDATA[
-               , (SELECT ptbs.hngnm
-                    FROM PAM.PMCMPTBS PTBS
-                   WHERE PTBS.INSTCD = '101'
-                     AND PTBS.PID    = CMT.PID)                                          AS PATIENT_NAME
-        ]]>
-      </isNotEmpty>
-      <isEmpty property="userId">
-        <![CDATA[
-               , ''                                                                      AS PATIENT_NAME
-        ]]>
-      </isEmpty>
-      <![CDATA[
-          FROM EMA.CONSENT_MST CMT,
-               EMA.CLIP_FORM CF
+               CMT.MAIN_DR_ID                                                            AS MAIN_DR_ID,
+               CMT.CLN_DATE                                                              AS IN_DD,
+               CMT.CLN_DEPT_CD                                                           AS ORD_DEPT_CD,
+               CMT.VISIT_TYPE                                                            AS ORD_TYPE
+          FROM EMA.CLIP_FORM CF
           LEFT OUTER JOIN EMA.CLIP_FORM_DATA CFD
-            ON CF.FORM_ID = CFD.FORM_ID
-          LEFT OUTER JOIN EMR.MRFMFORM MF
-            ON CF.FORM_CODE = MF.FORMCD
-           AND MF.INSTCD = '101'
-         WHERE 1 = 1 ]]>
+            ON CF.FORM_ID = CFD.FORM_ID,
+               EMA.CONSENT_MST CMT
+         WHERE 1 = 1
+           AND CMT.PID = #patientCode#
+           ]]>
       <isNotEqual property="consentState" compareValue="ALL">
         <![CDATA[
-          AND CMT.CONSENT_STATE IN ($consentState$)
+            AND CMT.CONSENT_STATE IN ($consentState$)
         ]]>
       </isNotEqual>
-      <!--isNotEmpty property="selectState">
-        <isNotEmpty property="userId">
-          <![CDATA[
-            AND CMT.MAIN_DR_ID = #userId#
-          ]]>
-        </isNotEmpty>
-      </isNotEmpty-->
-      <isEmpty property="selectState">
-        <isNotEmpty property="userId">
-          <![CDATA[
-            AND CMT.MODIFY_USER_ID = #userId#
-          ]]>
-        </isNotEmpty>
-      </isEmpty>
-      <isNotEmpty property="pid">
-        <![CDATA[
-          AND CMT.PID = #pid#
-        ]]>
-      </isNotEmpty>
       <![CDATA[
-           AND TO_CHAR(TO_DATE(CMT.CREATE_DATETIME, 'YYYY-MM-DD HH24:MI:SS'), 'YYYYMMDD') BETWEEN #startDt# AND #endDt#
-           AND CMT.HOS_TYPE = #instCd#
-           AND TO_CHAR(SYSDATE, 'YYYYMMDDHH24MISS') BETWEEN MF.FORMFROMDT AND MF.FORMTODT
+           
+           AND CMT.FORM_CD = CF.FORM_CODE
+           AND CF.PRODUCT_ID = 1
            AND CF.FORM_TYPE = 'FORM_TYPE_001'
-           AND CF.PRODUCT_ID = '1'
            AND CF.USE_YN = 'Y'
-           AND CF.FORM_ID = CMT.FORM_RID
-           AND PUBLICATION_YN = 'Y'
-           AND MF.FORMPROGFLAG LIKE 'OCR%'
-           AND CMT.USE_YN = 'Y'
-           AND CASE WHEN EXISTS ( SELECT 1
-                                    FROM EMR.MRFMOCRPRNT e
-                                   WHERE e.INSTCD = #instCd#
-                                     AND e.OCRTAG = CMT.OCR_NUMBER) THEN
-                                CASE WHEN CMT.CONSENT_STATE IN ('UNFINISHED', 'TEMP', 'PAPER_OUT', 'ELECTR_CMP')
-                                       AND EXISTS ( SELECT 1
-                                                      FROM EMR.MRFMOCRPRNT e,
-                                                           EMR.MRFHOCRPRNT f
-                                                     WHERE e.INSTCD = #instCd#
-                                                       AND e.OCRTAG = CMT.OCR_NUMBER
-                                                       AND f.INSTCD = e.INSTCD
-                                                       AND f.OCRTAG = e.OCRTAG
-                                                       AND f.UPDTDT = e.UPDTDT
-                                                       AND f.STATCD = 'P'
-                                                   ) THEN 'Y'
-                                  WHEN CMT.consent_state = 'CERTIFY_CMP'
-                                   AND EXISTS ( SELECT 1
-                                                  FROM EMR.MRFMOCRPRNT e,
-                                                       EMR.MRFHOCRPRNT f
-                                                 WHERE e.INSTCD = #instCd#
-                                                   AND e.OCRTAG = CMT.OCR_NUMBER
-                                                   AND f.INSTCD = e.INSTCD
-                                                   AND f.OCRTAG = e.OCRTAG
-                                                   AND f.UPDTDT = e.UPDTDT
-                                                   AND f.STATCD = 'C'
-                                              ) THEN 'Y'
-                     ELSE 'N'
-                   END
-                 ELSE 'Y'
-               END = 'Y'
-               
-           AND CFD.FORM_VERSION = ( SELECT MAX(FORM_VERSION) 
-                                      FROM EMA.CLIP_FORM_DATA A 
+           AND CFD.PUBLICATION_YN = 'Y'
+           AND CFD.FORM_VERSION = ( SELECT MAX(FORM_VERSION)
+                                      FROM EMA.CLIP_FORM_DATA A
                                      WHERE A.FORM_ID = CFD.FORM_ID
                                        AND A.PUBLICATION_YN = 'Y'
                                        AND A.product_id = '1' )
-
-        ORDER BY PID, CMT.OCR_NUMBER DESC, CMT.CONSENT_STATE ASC
       ]]>
     </statement>
 
@@ -1680,11 +1614,6 @@
           FROM  EMA.CONSENT_IMAGE A
          WHERE  COMPLETE_YN = 'Y'
            AND  CONSENT_MST_RID = #consent-mst-rid#
-           AND  CONSENT_IMAGE_RID = (
-                                      SELECT MAX(CONSENT_IMAGE_RID)
-                                        FROM EMA.CONSENT_IMAGE
-                                       WHERE CONSENT_MST_RID = A.CONSENT_MST_RID
-                                    )
          ORDER BY CONSENT_IMAGE_RID, IMAGE_FILENAME
       ]]>
     </statement>

+ 18 - 5
CLIP.e-Form.Consent.Web/OracleQuery/CLIP.e-Form.Consent.ResultMap.xml

@@ -61,11 +61,24 @@
     </resultMap -->
 
     <resultMap id="ConsentMap" class="ConsentVO">
-      <result property="idx"      column="IDX"       />
-      <result property="consentMstRid"      column="CONSENT_MST_RID"       />
-      <result property="formId"   column="FORM_ID"   nullValue="" />
-      <result property="formCode" column="FORM_CODE" nullValue="" />
-      <result property="formName" column="FORM_NAME" nullValue="" />
+      <result property="idx"             column="IDX" />
+      <result property="consentMstRid"   column="CONSENT_MST_RID" />
+      <result property="formId"          column="FORM_ID"           nullValue="" />
+      <result property="formCode"        column="FORM_CODE"         nullValue="" />
+      <result property="formName"        column="FORM_NAME"         nullValue="" />
+      <result property="consentState"    column="CONSENT_STATE"     nullValue="" />
+      <result property="consentStateEng" column="CONSENT_STATE_ENG" nullValue="" />
+      <result property="prntCnt"         column="PRNT_CNT"          nullValue="" />
+      <result property="ocrTag"          column="OCR_TAG"           nullValue="" />
+      <result property="pid"             column="PID"               nullValue="" />
+      <result property="patientName"     column="PATIENT_NAME"      nullValue="" />
+      <result property="createUserId"    column="CREATE_USER_ID"    nullValue="" />
+      <result property="cretNo"          column="CRET_NO"           />
+      <result property="deptCd"          column="DEPT_CD"           nullValue="" />
+      <result property="mainDrId"        column="MAIN_DR_ID"        nullValue="" />
+      <result property="inDd"            column="IN_DD"             nullValue="" />
+      <result property="ordDeptCd"       column="ORD_DEPT_CD"       nullValue="" />
+      <result property="ordType"         column="ORD_TYPE"          nullValue="" />
     </resultMap>
 
     <resultMap id="ImageServerPropsMap" class="ImageServerPropsVO">

+ 36 - 36
CLIP.e-Form.Consent.Web/OracleQuery/CLIP.e-Form.Hospital.User.xml

@@ -149,42 +149,42 @@
     <insert id="setUserFormSet" parameterClass="System.Collections.Hashtable">
       <![CDATA[ 
         INSERT INTO emr.mrfmsetindx(
-								instcd,
-								itemindxseq,
-								supitemindxseq,
-								indxflag,
-								indxnm,
-								indxcnts,
-								deptcd,
-								userid,
-								linkflag,
-								linkcd,
-								comnseq,
-								fstrgstrid,
-								fstrgstdt,
-								lastupdtrid,
-								lastupdtdt,
-								jobkind,
-								slipno
-								)
-				VALUES(
-								#instCd#,
-								EMR.SQ_MRFMSETINDX_01.NEXTVAL,
-								468,
-								'O',
-								'',
-								'',
-								'',
-								#userId#,
-								'Y',
-								#formCd#,
-								'',
-								#userId#,
-								systimestamp,
-								#userId#,
-								systimestamp,
-								'',
-								'')
+                instcd,
+                itemindxseq,
+                supitemindxseq,
+                indxflag,
+                indxnm,
+                indxcnts,
+                deptcd,
+                userid,
+                linkflag,
+                linkcd,
+                comnseq,
+                fstrgstrid,
+                fstrgstdt,
+                lastupdtrid,
+                lastupdtdt,
+                jobkind,
+                slipno
+                )
+        VALUES(
+                #instCd#,
+                EMR.SQ_MRFMSETINDX_01.NEXTVAL,
+                472,
+                'O',
+                '',
+                '',
+                '',
+                #userId#,
+                'Y',
+                #formCd#,
+                '',
+                #userId#,
+                systimestamp,
+                #userId#,
+                systimestamp,
+                '',
+                '')
         ]]>
       <selectKey type="post" resultClass="System.Int32" property="itemindxseq">
         <![CDATA[SELECT EMR.SQ_MRFMSETINDX_01.CURRVAL AS itemindxseq FROM DUAL]]>

+ 91 - 107
CLIP.e-Form.Consent.Web/OracleQuery/CLIP.e-Form.Server.Viewer.Data.xml

@@ -2,77 +2,77 @@
 <!--<sqlMap namespace="CLIP.e-Form.Consent.Dfh" xmlns="http://ibatis.apache.org/mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >-->
 <sqlMap namespace="CLIP.e-Form.Consent" xmlns="http://ibatis.apache.org/mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
   <statements>
-    <!-- update id="INSERT_CONSENT_MST" parameterClass="System.Collections.Hashtable" -->
     <insert id="INSERT_CONSENT_MST" parameterClass="System.Collections.Hashtable">
       <![CDATA[
-        insert into EMA.CONSENT_MST
-        (
-          CONSENT_MST_RID,
-          HOS_TYPE, 
-          PID,
-          VISIT_TYPE,
-          OCR_NUMBER,
-          CLN_DEPT_CD,
-          CLN_DATE,
-          CRETNO,
-          WARDCD,
-          ROOMCD,
-          FORM_RID,
-          CONSENT_STATE,
-          COMPLETE_YN,
-          COMPLETE_DATETIME,
-          PAPER_YN,
-          REISSUE_YN,
-          REISSUE_CONSENT_MST_RID,
-          REWRITE_YN,
-          REWRITE_CONSENT_MST_RID,
-          USE_YN,
-          MAIN_DR_ID,
-          CREATE_USER_ID,
-          CREATE_DATETIME,
-          MODIFY_USER_ID,
-          MODIFY_DATETIME,
-          CREATE_USER_NAME,
-          MODIFY_USER_NAME,
-          OPRSRVNO,
-          PAGECNT,
-          FORM_CD,
-          DEVICE_IDENT_NO
-        )
-        values
-        (
-          #consentMstRid#,
-          #hosType#,
-          #patientCode#,
-          #vistType#,
-          #ocrCode#,
-          #clnDeptCd#,
-          #clnDate#,
-          #cretno#,
-          #ward#,
-          #roomcd#,
-          #formRid#,
-          #consentState#,
-          #completeYn#,
-          $completeDateTimeToChars$,
-          #paperYn#,
-          #reissueYn#,
-          #reissueConsentMstRid#,
-          #rewriteYn#,
-          #rewriteConsentMstRid#,
-          'Y',
-          #mainDrId#,
-          #userId#,
-          TO_CHAR(SYSDATE,'yyyy-mm-dd hh24:mi:ss'),
-          #userId#,
-          TO_CHAR(SYSDATE,'yyyy-mm-dd hh24:mi:ss'),
-          #createUserName#,
-          COM.FN_ZS_GETUSERNM(#userId#, TO_CHAR(SYSDATE, 'YYYYMMDD')),
-          #opRsrvNo#,
-          #pageCnt#,
-          #formCd#,
-          #macAddress#
-        )
+        MERGE INTO CONSENT_MST
+        USING DUAL ON (CONSENT_MST_RID = #consentMstRid# AND PID = #patientCode# AND HOS_TYPE = #hosType#)
+         WHEN NOT MATCHED THEN
+              insert
+              (
+               CONSENT_MST_RID,
+               HOS_TYPE, 
+               PID,
+               VISIT_TYPE,
+               OCR_NUMBER,
+               CLN_DEPT_CD,
+               CLN_DATE,
+               CRETNO,
+               WARDCD,
+               ROOMCD,
+               FORM_RID,
+               CONSENT_STATE,
+               COMPLETE_YN,
+               COMPLETE_DATETIME,
+               PAPER_YN,
+               REISSUE_YN,
+               REISSUE_CONSENT_MST_RID,
+               REWRITE_YN,
+               REWRITE_CONSENT_MST_RID,
+               USE_YN,
+               MAIN_DR_ID,
+               CREATE_USER_ID,
+               CREATE_DATETIME,
+               MODIFY_USER_ID,
+               MODIFY_DATETIME,
+               CREATE_USER_NAME,
+               MODIFY_USER_NAME,
+               FORM_CD,
+               PAGECNT,
+               oprsrvno
+              )
+              values
+              (
+               #consentMstRid#,
+               #hosType#,
+               #patientCode#,
+               #vistType#,
+               #ocrCode#,
+               #clnDeptCd#,
+               #clnDate#,
+               #cretno#,
+               #ward#,
+               #roomcd#,
+               #formRid#,
+               #consentState#,
+               #completeYn#,
+               $completeDateTimeToChars$,
+               #paperYn#,
+               #reissueYn#,
+               #reissueConsentMstRid#,
+               #rewriteYn#,
+               #rewriteConsentMstRid#,
+               'Y',
+               #mainDrId#,
+               #userId#,
+               TO_CHAR(SYSDATE,'yyyy-mm-dd hh24:mi:ss'),
+               #userId#,
+               TO_CHAR(SYSDATE,'yyyy-mm-dd hh24:mi:ss'),
+               #createUserName#,
+               #modifyUserName#,
+               #formCd#,
+               #pageCnt#,
+               #opRsrvNo#
+              )
       ]]>
     </insert>
 
@@ -88,10 +88,10 @@
          WHERE CONSENT_MST_RID = #consentMstRid#
       ]]>
     </insert>
-      
+
     <insert id="INSERT_CONSENT_DATA" parameterClass="System.Collections.Hashtable">
       <![CDATA[
-        insert into EMA.CONSENT_DATA
+        insert into CONSENT_DATA
         (
           CONSENT_DATA_RID,
           CONSENT_MST_RID,
@@ -110,7 +110,7 @@
           #consentMstRid#,
           #formRid#,
           #deviceType#,
-          #macAddress#,
+          #deviceIdentNo#,
           #completeYn#,
           #userId#,
           TO_CHAR(SYSDATE,'yyyy-mm-dd hh24:mi:ss'),
@@ -119,6 +119,7 @@
         )
       ]]>
     </insert>
+    
     <insert id="INSERT_CONSENT_AUDIO" parameterClass="System.Collections.Hashtable">
 
       <![CDATA[
@@ -412,7 +413,8 @@
                           AND ocrtag = #ocrtag# )
         WHEN MATCHED THEN
              UPDATE
-                SET updtdt      = #updtdt#
+                SET eocryn      = DECODE(#actkind#, 'P', 'N', 'Y')
+                  , updtdt      = #updtdt#
                   , updtdeptcd  = #fstprntdeptcd#
                   , updtuserid  = #fstprntid#
                   , lastupdtrid = #fstprntid#
@@ -443,7 +445,11 @@
                   , rcpdd
                   , prcpno
                   , prcphistno
-                  , execprcpno )
+                  , execprcpno
+                  , eocryn
+                  , realprntyn
+                  , inputflag
+                  , verflag )
            VALUES ( #instcd#
                   , #ocrtag#
                   , #pid#
@@ -453,11 +459,7 @@
                   , #orddrid#
                   , #orddeptcd#
                   , #formcd#
-                  , ( SELECT MAX(a.formfromdt)
-                        FROM emr.mrfmform a
-                       WHERE instcd   =       #instcd#
-                         AND formcd   =       #formcd#
-                         AND #updtdt# BETWEEN formfromdt AND formtodt )
+                  , SYSDATE
                   , ''
                   , ''
                   , #updtdt#
@@ -473,7 +475,11 @@
                   , ''
                   , ''
                   , ''
-                  , '' )]]>
+                  , ''
+                  , DECODE(#actkind#, 'P', 'N', 'Y')
+                  , ''
+                  , #clienttype#
+                  , 'L' )]]>
     </insert>
 
     <update id="updateOcrPrntHistInfo" parameterClass="System.Collections.Hashtable">
@@ -501,7 +507,7 @@
                   , fstrgstrid
                   , fstrgstdt
                   , lastupdtrid
-                  , lastupdtdt )
+                  , lastupdtdt)
            VALUES ( #instcd#
                   , #ocrtag#
                   , #updtdt#
@@ -510,35 +516,13 @@
                   , #updtresncnts#
                   , #fstprntdeptcd#
                   , DECODE(#actkind#, 'C', 'Y', 'N')
-                  , CASE WHEN TO_NUMBER(#pagecnt#) < 0 THEN
-                              ( SELECT COUNT(1)
-                                  FROM emr.mrfmocr  a
-                                     , emr.mrfmform b
-                                 WHERE a.formcd     =       #formcd#
-                                   AND b.instcd     =       a.instcd
-                                   AND b.formcd     =       a.formcd
-                                   AND b.formfromdt =       a.formfromdt
-                                   AND #updtdt#     BETWEEN b.formfromdt AND b.formtodt
-                              )
-                         ELSE TO_NUMBER(#pagecnt#)
-                     END
-                  , DECODE(#actkind#, 'P', 0
-                                    ,  CASE WHEN TO_NUMBER(#pagecnt#) < 0 THEN
-                                                 ( SELECT COUNT(1)
-                                                    FROM emr.mrfmocr  a
-                                                       , emr.mrfmform b
-                                                   WHERE a.formcd     =       #formcd#
-                                                     AND b.instcd     =       a.instcd
-                                                     AND b.formcd     =       a.formcd
-                                                     AND b.formfromdt =       a.formfromdt
-                                                     AND #updtdt#     BETWEEN b.formfromdt AND b.formtodt
-                                                )
-                                           ELSE TO_NUMBER(#pagecnt#)
-                                        END)
+                  , #pagecnt#
+                  , #pagecnt#
                   , #fstprntid#
                   , SYSTIMESTAMP
                   , #fstprntid#
-                  , SYSTIMESTAMP )]]>
+                  , SYSTIMESTAMP)
+      ]]>
     </insert>
 
     <!-- 선택 진료 신청 정보 -->

+ 1 - 1
CLIP.e-Form.Consent.Web/Properties/PublishProfiles/CustomProfile.pubxml

@@ -12,6 +12,6 @@
     <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
     <ExcludeApp_Data>False</ExcludeApp_Data>
     <publishUrl>C:\ConsentService\consentServer</publishUrl>
-    <DeleteExistingFiles>True</DeleteExistingFiles>
+    <DeleteExistingFiles>False</DeleteExistingFiles>
   </PropertyGroup>
 </Project>