<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.emr.dao.ArchivePrintinfoMapper" >
  <resultMap id="BaseResultMap" type="com.emr.entity.ArchivePrintinfo" >
    <id column="ID" property="id" jdbcType="BIGINT" />
    <result column="print_userid" property="printUserid" jdbcType="NVARCHAR" />
    <result column="print_username" property="printUsername" jdbcType="NVARCHAR" />
    <result column="print_createtime" property="printCreatetime" jdbcType="TIMESTAMP" />
    <result column="archive_detail_id" property="archiveDetailId" jdbcType="NVARCHAR" />
    <result column="MasterID" property="masterid" jdbcType="NVARCHAR" />
    <result column="patient_id" property="patientId" jdbcType="NVARCHAR" />
    <result column="name" property="name" jdbcType="NVARCHAR" />
    <result column="admiss_id" property="admissId" jdbcType="NVARCHAR" />
    <result column="admiss_times" property="admissTimes" jdbcType="INTEGER" />
    <result column="assort_id" property="assortId" jdbcType="NVARCHAR" />
    <result column="assort_name" property="assortName" jdbcType="NVARCHAR" />
    <result column="FileTitle" property="filetitle" jdbcType="NVARCHAR" />
    <result column="PageCount" property="pagecount" jdbcType="INTEGER" />
    <result column="sys" property="sys" jdbcType="NVARCHAR" />
    <result column="C1" property="c1" jdbcType="NVARCHAR" />
    <result column="C2" property="c2" jdbcType="NVARCHAR" />
    <result column="D1" property="d1" jdbcType="INTEGER" />
    <result column="D2" property="d2" jdbcType="INTEGER" />
    <result column="T1" property="t1" jdbcType="TIMESTAMP" />
    <result column="T2" property="t2" jdbcType="TIMESTAMP" />
  </resultMap>
  <sql id="Base_Column_List" >
    ID, print_userid, print_username, print_createtime, archive_detail_id, MasterID, 
    patient_id, name, admiss_id, admiss_times, assort_id, assort_name, FileTitle, PageCount, 
    sys, C1, C2, D1, D2, T1, T2
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
    select 
    <include refid="Base_Column_List" />
    from archive_printInfo
    where ID = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
    delete from archive_printInfo
    where ID = #{id,jdbcType=BIGINT}
  </delete>
  <insert id="insert" parameterType="com.emr.entity.ArchivePrintinfo" >
    insert into archive_printInfo (ID, print_userid, print_username, 
      print_createtime, archive_detail_id, MasterID, 
      patient_id, name, admiss_id, 
      admiss_times, assort_id, assort_name, 
      FileTitle, PageCount, sys, 
      C1, C2, D1, D2, 
      T1, T2)
    values (#{id,jdbcType=BIGINT}, #{printUserid,jdbcType=NVARCHAR}, #{printUsername,jdbcType=NVARCHAR}, 
      #{printCreatetime,jdbcType=TIMESTAMP}, #{archiveDetailId,jdbcType=NVARCHAR}, #{masterid,jdbcType=NVARCHAR}, 
      #{patientId,jdbcType=NVARCHAR}, #{name,jdbcType=NVARCHAR}, #{admissId,jdbcType=NVARCHAR}, 
      #{admissTimes,jdbcType=INTEGER}, #{assortId,jdbcType=NVARCHAR}, #{assortName,jdbcType=NVARCHAR}, 
      #{filetitle,jdbcType=NVARCHAR}, #{pagecount,jdbcType=INTEGER}, #{sys,jdbcType=NVARCHAR}, 
      #{c1,jdbcType=NVARCHAR}, #{c2,jdbcType=NVARCHAR}, #{d1,jdbcType=INTEGER}, #{d2,jdbcType=INTEGER}, 
      #{t1,jdbcType=TIMESTAMP}, #{t2,jdbcType=TIMESTAMP})
  </insert>
  <insert id="insertSelective" parameterType="com.emr.entity.ArchivePrintinfo" >
    insert into archive_printInfo
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        ID,
      </if>
      <if test="printUserid != null" >
        print_userid,
      </if>
      <if test="printUsername != null" >
        print_username,
      </if>
      <if test="printCreatetime != null" >
        print_createtime,
      </if>
      <if test="archiveDetailId != null" >
        archive_detail_id,
      </if>
      <if test="masterid != null" >
        MasterID,
      </if>
      <if test="patientId != null" >
        patient_id,
      </if>
      <if test="name != null" >
        name,
      </if>
      <if test="admissId != null" >
        admiss_id,
      </if>
      <if test="admissTimes != null" >
        admiss_times,
      </if>
      <if test="assortId != null" >
        assort_id,
      </if>
      <if test="assortName != null" >
        assort_name,
      </if>
      <if test="filetitle != null" >
        FileTitle,
      </if>
      <if test="pagecount != null" >
        PageCount,
      </if>
      <if test="sys != null" >
        sys,
      </if>
      <if test="c1 != null" >
        C1,
      </if>
      <if test="c2 != null" >
        C2,
      </if>
      <if test="d1 != null" >
        D1,
      </if>
      <if test="d2 != null" >
        D2,
      </if>
      <if test="t1 != null" >
        T1,
      </if>
      <if test="t2 != null" >
        T2,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=BIGINT},
      </if>
      <if test="printUserid != null" >
        #{printUserid,jdbcType=NVARCHAR},
      </if>
      <if test="printUsername != null" >
        #{printUsername,jdbcType=NVARCHAR},
      </if>
      <if test="printCreatetime != null" >
        #{printCreatetime,jdbcType=TIMESTAMP},
      </if>
      <if test="archiveDetailId != null" >
        #{archiveDetailId,jdbcType=NVARCHAR},
      </if>
      <if test="masterid != null" >
        #{masterid,jdbcType=NVARCHAR},
      </if>
      <if test="patientId != null" >
        #{patientId,jdbcType=NVARCHAR},
      </if>
      <if test="name != null" >
        #{name,jdbcType=NVARCHAR},
      </if>
      <if test="admissId != null" >
        #{admissId,jdbcType=NVARCHAR},
      </if>
      <if test="admissTimes != null" >
        #{admissTimes,jdbcType=INTEGER},
      </if>
      <if test="assortId != null" >
        #{assortId,jdbcType=NVARCHAR},
      </if>
      <if test="assortName != null" >
        #{assortName,jdbcType=NVARCHAR},
      </if>
      <if test="filetitle != null" >
        #{filetitle,jdbcType=NVARCHAR},
      </if>
      <if test="pagecount != null" >
        #{pagecount,jdbcType=INTEGER},
      </if>
      <if test="sys != null" >
        #{sys,jdbcType=NVARCHAR},
      </if>
      <if test="c1 != null" >
        #{c1,jdbcType=NVARCHAR},
      </if>
      <if test="c2 != null" >
        #{c2,jdbcType=NVARCHAR},
      </if>
      <if test="d1 != null" >
        #{d1,jdbcType=INTEGER},
      </if>
      <if test="d2 != null" >
        #{d2,jdbcType=INTEGER},
      </if>
      <if test="t1 != null" >
        #{t1,jdbcType=TIMESTAMP},
      </if>
      <if test="t2 != null" >
        #{t2,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.emr.entity.ArchivePrintinfo" >
    update archive_printInfo
    <set >
      <if test="printUserid != null" >
        print_userid = #{printUserid,jdbcType=NVARCHAR},
      </if>
      <if test="printUsername != null" >
        print_username = #{printUsername,jdbcType=NVARCHAR},
      </if>
      <if test="printCreatetime != null" >
        print_createtime = #{printCreatetime,jdbcType=TIMESTAMP},
      </if>
      <if test="archiveDetailId != null" >
        archive_detail_id = #{archiveDetailId,jdbcType=NVARCHAR},
      </if>
      <if test="masterid != null" >
        MasterID = #{masterid,jdbcType=NVARCHAR},
      </if>
      <if test="patientId != null" >
        patient_id = #{patientId,jdbcType=NVARCHAR},
      </if>
      <if test="name != null" >
        name = #{name,jdbcType=NVARCHAR},
      </if>
      <if test="admissId != null" >
        admiss_id = #{admissId,jdbcType=NVARCHAR},
      </if>
      <if test="admissTimes != null" >
        admiss_times = #{admissTimes,jdbcType=INTEGER},
      </if>
      <if test="assortId != null" >
        assort_id = #{assortId,jdbcType=NVARCHAR},
      </if>
      <if test="assortName != null" >
        assort_name = #{assortName,jdbcType=NVARCHAR},
      </if>
      <if test="filetitle != null" >
        FileTitle = #{filetitle,jdbcType=NVARCHAR},
      </if>
      <if test="pagecount != null" >
        PageCount = #{pagecount,jdbcType=INTEGER},
      </if>
      <if test="sys != null" >
        sys = #{sys,jdbcType=NVARCHAR},
      </if>
      <if test="c1 != null" >
        C1 = #{c1,jdbcType=NVARCHAR},
      </if>
      <if test="c2 != null" >
        C2 = #{c2,jdbcType=NVARCHAR},
      </if>
      <if test="d1 != null" >
        D1 = #{d1,jdbcType=INTEGER},
      </if>
      <if test="d2 != null" >
        D2 = #{d2,jdbcType=INTEGER},
      </if>
      <if test="t1 != null" >
        T1 = #{t1,jdbcType=TIMESTAMP},
      </if>
      <if test="t2 != null" >
        T2 = #{t2,jdbcType=TIMESTAMP},
      </if>
    </set>
    where ID = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.emr.entity.ArchivePrintinfo" >
    update archive_printInfo
    set print_userid = #{printUserid,jdbcType=NVARCHAR},
      print_username = #{printUsername,jdbcType=NVARCHAR},
      print_createtime = #{printCreatetime,jdbcType=TIMESTAMP},
      archive_detail_id = #{archiveDetailId,jdbcType=NVARCHAR},
      MasterID = #{masterid,jdbcType=NVARCHAR},
      patient_id = #{patientId,jdbcType=NVARCHAR},
      name = #{name,jdbcType=NVARCHAR},
      admiss_id = #{admissId,jdbcType=NVARCHAR},
      admiss_times = #{admissTimes,jdbcType=INTEGER},
      assort_id = #{assortId,jdbcType=NVARCHAR},
      assort_name = #{assortName,jdbcType=NVARCHAR},
      FileTitle = #{filetitle,jdbcType=NVARCHAR},
      PageCount = #{pagecount,jdbcType=INTEGER},
      sys = #{sys,jdbcType=NVARCHAR},
      C1 = #{c1,jdbcType=NVARCHAR},
      C2 = #{c2,jdbcType=NVARCHAR},
      D1 = #{d1,jdbcType=INTEGER},
      D2 = #{d2,jdbcType=INTEGER},
      T1 = #{t1,jdbcType=TIMESTAMP},
      T2 = #{t2,jdbcType=TIMESTAMP}
    where ID = #{id,jdbcType=BIGINT}
  </update>
  <!--根据masterId查询分组打印次数-->
  <select id="selectPrintCountByMasterId" resultType="ArchivePrintinfo">
    select MasterID,COUNT(MasterID) admiss_times from archive_printInfo
    <where>
      <if test="masterIds != null and masterIds != ''">
        MasterID IN (<foreach collection="masterIds.split(',')" item="item" separator=",">#{item}</foreach>)
      </if>
    </where>
    group by MasterID
  </select>
</mapper>