<?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.tBoby.TBabyMapper" >
  <resultMap id="BaseResultMap" type="com.emr.entity.tBoby.TBaby" >
    <result column="patient_id" property="patientId" jdbcType="VARCHAR" />
    <result column="fetation_times" property="fetationTimes" jdbcType="SMALLINT" />
    <result column="childbirth_times" property="childbirthTimes" jdbcType="SMALLINT" />
    <result column="childbirth_time" property="childbirthTime" jdbcType="TIMESTAMP" />
    <result column="childbirth_mothed" property="childbirthMothed" jdbcType="VARCHAR" />
    <result column="sex" property="sex" jdbcType="VARCHAR" />
    <result column="head" property="head" jdbcType="DECIMAL" />
    <result column="chest" property="chest" jdbcType="DECIMAL" />
    <result column="avoirdupois" property="avoirdupois" jdbcType="DECIMAL" />
    <result column="stature" property="stature" jdbcType="DECIMAL" />
    <result column="diag_type" property="diagType" jdbcType="VARCHAR" />
    <result column="diag_code" property="diagCode" jdbcType="VARCHAR" />
    <result column="diag_name" property="diagName" jdbcType="VARCHAR" />
    <result column="father" property="father" jdbcType="VARCHAR" />
    <result column="id_card" property="idCard" jdbcType="VARCHAR" />
    <result column="work_addr" property="workAddr" jdbcType="VARCHAR" />
    <result column="home_addr" property="homeAddr" jdbcType="VARCHAR" />
    <result column="breathing" property="breathing" jdbcType="VARCHAR" />
    <result column="rescue_times" property="rescueTimes" jdbcType="VARCHAR" />
    <result column="rescue_success_times" property="rescueSuccessTimes" jdbcType="VARCHAR" />
  </resultMap>
  <insert id="insert" parameterType="com.emr.entity.tBoby.TBaby" >
    insert into t_baby (patient_id, fetation_times, childbirth_times, 
      childbirth_time, childbirth_mothed, sex, 
      head, chest, avoirdupois, 
      stature, diag_type, diag_code, 
      diag_name, father, id_card, 
      work_addr, home_addr, breathing, 
      rescue_times, rescue_success_times)
    values (#{patientId,jdbcType=VARCHAR}, #{fetationTimes,jdbcType=SMALLINT}, #{childbirthTimes,jdbcType=SMALLINT}, 
      #{childbirthTime,jdbcType=TIMESTAMP}, #{childbirthMothed,jdbcType=VARCHAR}, #{sex,jdbcType=VARCHAR}, 
      #{head,jdbcType=DECIMAL}, #{chest,jdbcType=DECIMAL}, #{avoirdupois,jdbcType=DECIMAL}, 
      #{stature,jdbcType=DECIMAL}, #{diagType,jdbcType=VARCHAR}, #{diagCode,jdbcType=VARCHAR}, 
      #{diagName,jdbcType=VARCHAR}, #{father,jdbcType=VARCHAR}, #{idCard,jdbcType=VARCHAR}, 
      #{workAddr,jdbcType=VARCHAR}, #{homeAddr,jdbcType=VARCHAR}, #{breathing,jdbcType=VARCHAR}, 
      #{rescueTimes,jdbcType=VARCHAR}, #{rescueSuccessTimes,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.emr.entity.tBoby.TBaby" >
    insert into t_baby
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="patientId != null" >
        patient_id,
      </if>
      <if test="fetationTimes != null" >
        fetation_times,
      </if>
      <if test="childbirthTimes != null" >
        childbirth_times,
      </if>
      <if test="childbirthTime != null" >
        childbirth_time,
      </if>
      <if test="childbirthMothed != null" >
        childbirth_mothed,
      </if>
      <if test="sex != null" >
        sex,
      </if>
      <if test="head != null" >
        head,
      </if>
      <if test="chest != null" >
        chest,
      </if>
      <if test="avoirdupois != null" >
        avoirdupois,
      </if>
      <if test="stature != null" >
        stature,
      </if>
      <if test="diagType != null" >
        diag_type,
      </if>
      <if test="diagCode != null" >
        diag_code,
      </if>
      <if test="diagName != null" >
        diag_name,
      </if>
      <if test="father != null" >
        father,
      </if>
      <if test="idCard != null" >
        id_card,
      </if>
      <if test="workAddr != null" >
        work_addr,
      </if>
      <if test="homeAddr != null" >
        home_addr,
      </if>
      <if test="breathing != null" >
        breathing,
      </if>
      <if test="rescueTimes != null" >
        rescue_times,
      </if>
      <if test="rescueSuccessTimes != null" >
        rescue_success_times,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="patientId != null" >
        #{patientId,jdbcType=VARCHAR},
      </if>
      <if test="fetationTimes != null" >
        #{fetationTimes,jdbcType=SMALLINT},
      </if>
      <if test="childbirthTimes != null" >
        #{childbirthTimes,jdbcType=SMALLINT},
      </if>
      <if test="childbirthTime != null" >
        #{childbirthTime,jdbcType=TIMESTAMP},
      </if>
      <if test="childbirthMothed != null" >
        #{childbirthMothed,jdbcType=VARCHAR},
      </if>
      <if test="sex != null" >
        #{sex,jdbcType=VARCHAR},
      </if>
      <if test="head != null" >
        #{head,jdbcType=DECIMAL},
      </if>
      <if test="chest != null" >
        #{chest,jdbcType=DECIMAL},
      </if>
      <if test="avoirdupois != null" >
        #{avoirdupois,jdbcType=DECIMAL},
      </if>
      <if test="stature != null" >
        #{stature,jdbcType=DECIMAL},
      </if>
      <if test="diagType != null" >
        #{diagType,jdbcType=VARCHAR},
      </if>
      <if test="diagCode != null" >
        #{diagCode,jdbcType=VARCHAR},
      </if>
      <if test="diagName != null" >
        #{diagName,jdbcType=VARCHAR},
      </if>
      <if test="father != null" >
        #{father,jdbcType=VARCHAR},
      </if>
      <if test="idCard != null" >
        #{idCard,jdbcType=VARCHAR},
      </if>
      <if test="workAddr != null" >
        #{workAddr,jdbcType=VARCHAR},
      </if>
      <if test="homeAddr != null" >
        #{homeAddr,jdbcType=VARCHAR},
      </if>
      <if test="breathing != null" >
        #{breathing,jdbcType=VARCHAR},
      </if>
      <if test="rescueTimes != null" >
        #{rescueTimes,jdbcType=VARCHAR},
      </if>
      <if test="rescueSuccessTimes != null" >
        #{rescueSuccessTimes,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <select id="selectAllByPatientId" resultMap="BaseResultMap">
    SELECT * FROM t_baby WHERE patient_id = #{patientId}
    <if test="fetationTimes != null">
        AND fetation_times = #{fetationTimes}
    </if>
  </select>
</mapper>