using System;
using CLIP.eForm.Server.Data;
using CLIP.eForm.Server.VO;
using IBatisNet.DataMapper;
using System.Collections.Generic;
using System.Collections;

namespace CLIP.eForm.Consent.Dac {
  public class SaveConsentDac : DacBase {
    public void InsertConsentMst(ISqlMapper mapper, Hashtable param) {
      mapper.QueryForObject<Int32>("INSERT_CONSENT_MST", param);
    }

    public void InsertConsentData(ISqlMapper mapper, Hashtable param) {
      mapper.QueryForObject<Int32>("INSERT_CONSENT_DATA", param);
    }

    public void InsertConsentImage(ISqlMapper mapper, Hashtable param) {
      mapper.QueryForObject<Int32>("INSERT_CONSENT_IMAGE", param);
    }

    public void InsertConsentImageSign(ISqlMapper mapper, Hashtable param) {
      mapper.QueryForObject<Int32>("INSERT_CONSENT_IMAGE_SIGN", param);
    }

    public void UpdateConsentMst(ISqlMapper mapper, Hashtable param) {
      mapper.QueryForObject<Int32>("UPDATE_CONSENT_MST", param);
    }

    public void UpdateConsentMstForReissue(ISqlMapper mapper, Hashtable param) {
      mapper.QueryForObject<Int32>("UPDATE_CONSENT_MST_FOR_REISSUE", param);
    }

    public int UpdateConsentMstForDelete(ISqlMapper mapper, Hashtable param) {
      return mapper.Update("UPDATE_CONSENT_MST_FOR_DELETE", param);
    }

    public int DeleteChartpageT(ISqlMapper mapper, Hashtable param) {
      return mapper.Delete("DELETE_CHARTPAGET", param);
    }

    public void UpdateConsentMstStatus(ISqlMapper mapper, Hashtable param) {
      mapper.QueryForObject<Int32>("UPDATE_CONSENT_MST_STATUS", param);
    }

    public void SetConsentDataChoice(ISqlMapper mapper, Hashtable param) {
      mapper.QueryForObject<Int32>("INSERT_CONSENT_DATA_CHOICE", param);
    }

    public void SetMediHistory(ISqlMapper mapper, Hashtable param) {
      mapper.QueryForObject<Int32>("SET_MEDI_HISTORY", param);
    }

    /// <summary>
    /// OCR 히스토리 테이블 저장
    /// </summary>
    /// <param name="mapper"></param>
    /// <param name="param"></param>
    public void InsertPrintData(ISqlMapper mapper, Hashtable param) {

      string histYN = mapper.QueryForObject<String>("getOcrPrntHistYN", param);

      //histYN = histYN ?? "Y";
      // 무조건 기록 되게 수정
      histYN = "Y";

      if (histYN.Equals("Y")) {
        // MRFMOCRPRNT에 업데이트 이슈 발생시 mapper.Insert("setOcrPrntInfo", param); mapper.Insert("setOcrPrntHistInfo", param); 이것만 사용
        mapper.Insert("setOcrPrntInfo", param);
        mapper.Insert("setOcrPrntHistInfo", param);
      }
    }

    public void InsertPmcmspif(ISqlMapper mapper, Hashtable param) {
      mapper.Insert("insPmcmspif", param);
    }

    public void InsertPmihagmt(ISqlMapper mapper, Hashtable param) {
      mapper.Insert("insPmihagmt", param);
    }

    public void InsertPmcminfo(ISqlMapper mapper, Hashtable param) {
      mapper.Insert("insPmcminfo", param);
    }

    public IList<string> getOcrType6Forms(ISqlMapper mapper, Hashtable param) {
      return mapper.QueryForList<string>("getOcrType6Forms", param);
      //return null;
    }

    public int GetConsentImageCount(ISqlMapper mapper, Hashtable param) {
      return mapper.QueryForObject<int>("GET_CONSET_IMAGE_COUNT", param);
    }
  }
}
