<?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.his.HISBA2Mapper" >
  <resultMap id="BaseResultMap" type="com.emr.entity.his.HISBA2" >
    <id column="FID" property="fid" jdbcType="BIGINT" />
    <result column="FPRN" property="fprn" jdbcType="VARCHAR" />
    <result column="FTIMES" property="ftimes" jdbcType="INTEGER" />
    <result column="FZKTYKH" property="fzktykh" jdbcType="VARCHAR" />
    <result column="FZKDEPT" property="fzkdept" jdbcType="VARCHAR" />
    <result column="FZKDATE" property="fzkdate" jdbcType="TIMESTAMP" />
    <result column="FZKTIME" property="fzktime" jdbcType="VARCHAR" />
  </resultMap>
  <sql id="Base_Column_List" >
    FID, FPRN, FTIMES, FZKTYKH, FZKDEPT, FZKDATE, FZKTIME
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
    select 
    <include refid="Base_Column_List" />
    from HIS_BA2
    where FID = #{fid,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
    delete from HIS_BA2
    where FID = #{fid,jdbcType=BIGINT}
  </delete>
  <insert id="insert" parameterType="com.emr.entity.his.HISBA2" >
    insert into HIS_BA2 (FPRN, FTIMES,
      FZKTYKH, FZKDEPT, FZKDATE, 
      FZKTIME)
    values (#{fprn,jdbcType=VARCHAR}, #{ftimes,jdbcType=INTEGER},
      #{fzktykh,jdbcType=VARCHAR}, #{fzkdept,jdbcType=VARCHAR}, #{fzkdate,jdbcType=TIMESTAMP}, 
      #{fzktime,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.emr.entity.his.HISBA2" >
    insert into HIS_BA2
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="fid != null" >
        FID,
      </if>
      <if test="fprn != null" >
        FPRN,
      </if>
      <if test="ftimes != null" >
        FTIMES,
      </if>
      <if test="fzktykh != null" >
        FZKTYKH,
      </if>
      <if test="fzkdept != null" >
        FZKDEPT,
      </if>
      <if test="fzkdate != null" >
        FZKDATE,
      </if>
      <if test="fzktime != null" >
        FZKTIME,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="fid != null" >
        #{fid,jdbcType=BIGINT},
      </if>
      <if test="fprn != null" >
        #{fprn,jdbcType=VARCHAR},
      </if>
      <if test="ftimes != null" >
        #{ftimes,jdbcType=INTEGER},
      </if>
      <if test="fzktykh != null" >
        #{fzktykh,jdbcType=VARCHAR},
      </if>
      <if test="fzkdept != null" >
        #{fzkdept,jdbcType=VARCHAR},
      </if>
      <if test="fzkdate != null" >
        #{fzkdate,jdbcType=TIMESTAMP},
      </if>
      <if test="fzktime != null" >
        #{fzktime,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.emr.entity.his.HISBA2" >
    update HIS_BA2
    <set >
      <if test="fprn != null" >
        FPRN = #{fprn,jdbcType=VARCHAR},
      </if>
      <if test="ftimes != null" >
        FTIMES = #{ftimes,jdbcType=INTEGER},
      </if>
      <if test="fzktykh != null" >
        FZKTYKH = #{fzktykh,jdbcType=VARCHAR},
      </if>
      <if test="fzkdept != null" >
        FZKDEPT = #{fzkdept,jdbcType=VARCHAR},
      </if>
      <if test="fzkdate != null" >
        FZKDATE = #{fzkdate,jdbcType=TIMESTAMP},
      </if>
      <if test="fzktime != null" >
        FZKTIME = #{fzktime,jdbcType=VARCHAR},
      </if>
    </set>
    where FID = #{fid,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.emr.entity.his.HISBA2" >
    update HIS_BA2
    set FPRN = #{fprn,jdbcType=VARCHAR},
      FTIMES = #{ftimes,jdbcType=INTEGER},
      FZKTYKH = #{fzktykh,jdbcType=VARCHAR},
      FZKDEPT = #{fzkdept,jdbcType=VARCHAR},
      FZKDATE = #{fzkdate,jdbcType=TIMESTAMP},
      FZKTIME = #{fzktime,jdbcType=VARCHAR}
    where FID = #{fid,jdbcType=BIGINT}
  </update>
  <!--按病案号、住院次数查询记录-->
  <select id="selectAllByParam" resultMap="BaseResultMap">
      SELECT * FROM HIS_BA2 WHERE FPRN = #{fprn,jdbcType=VARCHAR} AND FTIMES = #{ftimes,jdbcType=INTEGER}
  </select>
  <!--批量添加-->
  <insert id="SimpleInsert" parameterType="java.util.List">
    insert into HIS_BA2(
      FPRN, FTIMES,
        FZKTYKH, FZKDEPT, FZKDATE,
        FZKTIME
    )
    values
    <foreach collection="list" item="items" separator=",">
      (
      #{items.fprn,jdbcType=VARCHAR}, #{items.ftimes,jdbcType=INTEGER},
      #{items.fzktykh,jdbcType=VARCHAR}, #{items.fzkdept,jdbcType=VARCHAR}, #{items.fzkdate,jdbcType=TIMESTAMP},
      #{items.fzktime,jdbcType=VARCHAR}
      )
    </foreach>
  </insert>
  <!--批量更新-->
  <update id="SimpleUpdate" parameterType="java.util.List">
    <foreach collection="list" item="items" separator=";">
      update HIS_BA2
      set FPRN = #{items.fprn,jdbcType=VARCHAR},
      FTIMES = #{items.ftimes,jdbcType=INTEGER},
      FZKTYKH = #{items.fzktykh,jdbcType=VARCHAR},
      FZKDEPT = #{items.fzkdept,jdbcType=VARCHAR},
      FZKDATE = #{items.fzkdate,jdbcType=TIMESTAMP},
      FZKTIME = #{items.fzktime,jdbcType=VARCHAR}
      where FID = #{items.fid,jdbcType=BIGINT}
    </foreach>
  </update>
  <!--批量删除-->
  <delete id="SimpleDelete" parameterType="java.lang.String">
    delete from HIS_BA2 where FID in (${ids})
  </delete>
</mapper>