<?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.HISBA7Mapper" >
  <resultMap id="BaseResultMap" type="com.emr.entity.his.HISBA7" >
    <id column="FID" property="fid" jdbcType="BIGINT" />
    <result column="FPRN" property="fprn" jdbcType="VARCHAR" />
    <result column="FTIMES" property="ftimes" jdbcType="INTEGER" />
    <result column="FHLRQ1" property="fhlrq1" jdbcType="TIMESTAMP" />
    <result column="FHLRQ2" property="fhlrq2" jdbcType="TIMESTAMP" />
    <result column="FHLDRUG" property="fhldrug" jdbcType="VARCHAR" />
    <result column="FHLPROC" property="fhlproc" jdbcType="VARCHAR" />
    <result column="FHLLXBH" property="fhllxbh" jdbcType="VARCHAR" />
    <result column="FHLLX" property="fhllx" jdbcType="VARCHAR" />
  </resultMap>
  <sql id="Base_Column_List" >
    FID, FPRN, FTIMES, FHLRQ1, FHLRQ2, FHLDRUG, FHLPROC, FHLLXBH, FHLLX
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
    select 
    <include refid="Base_Column_List" />
    from HIS_BA7
    where FID = #{fid,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
    delete from HIS_BA7
    where FID = #{fid,jdbcType=BIGINT}
  </delete>
  <insert id="insert" parameterType="com.emr.entity.his.HISBA7" >
    insert into HIS_BA7 (FPRN, FTIMES,
      FHLRQ1, FHLRQ2, FHLDRUG, 
      FHLPROC, FHLLXBH, FHLLX
      )
    values (#{fprn,jdbcType=VARCHAR}, #{ftimes,jdbcType=INTEGER},
      #{fhlrq1,jdbcType=TIMESTAMP}, #{fhlrq2,jdbcType=TIMESTAMP}, #{fhldrug,jdbcType=VARCHAR}, 
      #{fhlproc,jdbcType=VARCHAR}, #{fhllxbh,jdbcType=VARCHAR}, #{fhllx,jdbcType=VARCHAR}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.emr.entity.his.HISBA7" >
    insert into HIS_BA7
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="fid != null" >
        FID,
      </if>
      <if test="fprn != null" >
        FPRN,
      </if>
      <if test="ftimes != null" >
        FTIMES,
      </if>
      <if test="fhlrq1 != null" >
        FHLRQ1,
      </if>
      <if test="fhlrq2 != null" >
        FHLRQ2,
      </if>
      <if test="fhldrug != null" >
        FHLDRUG,
      </if>
      <if test="fhlproc != null" >
        FHLPROC,
      </if>
      <if test="fhllxbh != null" >
        FHLLXBH,
      </if>
      <if test="fhllx != null" >
        FHLLX,
      </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="fhlrq1 != null" >
        #{fhlrq1,jdbcType=TIMESTAMP},
      </if>
      <if test="fhlrq2 != null" >
        #{fhlrq2,jdbcType=TIMESTAMP},
      </if>
      <if test="fhldrug != null" >
        #{fhldrug,jdbcType=VARCHAR},
      </if>
      <if test="fhlproc != null" >
        #{fhlproc,jdbcType=VARCHAR},
      </if>
      <if test="fhllxbh != null" >
        #{fhllxbh,jdbcType=VARCHAR},
      </if>
      <if test="fhllx != null" >
        #{fhllx,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.emr.entity.his.HISBA7" >
    update HIS_BA7
    <set >
      <if test="fprn != null" >
        FPRN = #{fprn,jdbcType=VARCHAR},
      </if>
      <if test="ftimes != null" >
        FTIMES = #{ftimes,jdbcType=INTEGER},
      </if>
      <if test="fhlrq1 != null" >
        FHLRQ1 = #{fhlrq1,jdbcType=TIMESTAMP},
      </if>
      <if test="fhlrq2 != null" >
        FHLRQ2 = #{fhlrq2,jdbcType=TIMESTAMP},
      </if>
      <if test="fhldrug != null" >
        FHLDRUG = #{fhldrug,jdbcType=VARCHAR},
      </if>
      <if test="fhlproc != null" >
        FHLPROC = #{fhlproc,jdbcType=VARCHAR},
      </if>
      <if test="fhllxbh != null" >
        FHLLXBH = #{fhllxbh,jdbcType=VARCHAR},
      </if>
      <if test="fhllx != null" >
        FHLLX = #{fhllx,jdbcType=VARCHAR},
      </if>
    </set>
    where FID = #{fid,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.emr.entity.his.HISBA7" >
    update HIS_BA7
    set FPRN = #{fprn,jdbcType=VARCHAR},
      FTIMES = #{ftimes,jdbcType=INTEGER},
      FHLRQ1 = #{fhlrq1,jdbcType=TIMESTAMP},
      FHLRQ2 = #{fhlrq2,jdbcType=TIMESTAMP},
      FHLDRUG = #{fhldrug,jdbcType=VARCHAR},
      FHLPROC = #{fhlproc,jdbcType=VARCHAR},
      FHLLXBH = #{fhllxbh,jdbcType=VARCHAR},
      FHLLX = #{fhllx,jdbcType=VARCHAR}
    where FID = #{fid,jdbcType=BIGINT}
  </update>
  <!--按病案号、住院次数查询记录-->
  <select id="selectAllByParam" resultMap="BaseResultMap">
      SELECT * FROM HIS_BA7 WHERE FPRN = #{fprn,jdbcType=VARCHAR} AND FTIMES = #{ftimes,jdbcType=INTEGER}
  </select>
  <!--批量删除-->
  <delete id="deleteAllByParam">
      DELETE FROM HIS_BA7 WHERE FPRN = #{fprn,jdbcType=VARCHAR} AND FTIMES = #{ftimes,jdbcType=INTEGER}
  </delete>
  <!--批量添加-->
  <insert id="SimpleInsert" parameterType="java.util.List">
    insert into HIS_BA7(
    FPRN, FTIMES,
    FHLRQ1, FHLRQ2, FHLDRUG,
    FHLPROC, FHLLXBH, FHLLX
    )
    values
    <foreach collection="list" item="items" separator=",">
      (
      #{items.fprn,jdbcType=VARCHAR}, #{items.ftimes,jdbcType=INTEGER},
      #{items.fhlrq1,jdbcType=TIMESTAMP}, #{items.fhlrq2,jdbcType=TIMESTAMP}, #{items.fhldrug,jdbcType=VARCHAR},
      #{items.fhlproc,jdbcType=VARCHAR}, #{items.fhllxbh,jdbcType=VARCHAR}, #{items.fhllx,jdbcType=VARCHAR}
      )
    </foreach>
  </insert>
</mapper>