<?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.lyms.platform.permission.dao.master.BabyPatientExtendEarBabyMapper">
<resultMap id="BabyPatientExtendEarBabyResultMap"
type="com.lyms.platform.permission.model.BabyPatientExtendEarBaby">
<id column="id" property="id" jdbcType="VARCHAR"/>
<result column="name" property="name" jdbcType="VARCHAR"/>
<result column="sex" property="sex" jdbcType="INTEGER"/>
<result column="cardNo" property="cardno" jdbcType="VARCHAR"/>
<result column="birth" property="birth" jdbcType="TIMESTAMP"/>
<result column="mname" property="mname" jdbcType="VARCHAR"/>
<result column="mcert_type_id" property="mcertTypeId" jdbcType="VARCHAR"/>
<result column="mcert_no" property="mcertNo" jdbcType="VARCHAR"/>
<result column="mphone" property="mphone" jdbcType="VARCHAR"/>
<result column="vc_card_no" property="vcCardNo" jdbcType="VARCHAR"/>
<result column="build_doctor" property="buildDoctor" jdbcType="VARCHAR"/>
<result column="hospital_id" property="hospitalId" jdbcType="VARCHAR"/>
<result column="build_type" property="buildType" jdbcType="INTEGER"/>
<result column="enable" property="enable" jdbcType="VARCHAR"/>
<result column="yn" property="yn" jdbcType="INTEGER"/>
<result column="build_date" property="buildDate" jdbcType="TIMESTAMP"/>
<result column="baby_patient_id" property="babyPatientId" jdbcType="VARCHAR"/>
<result column="baby_ear_id" property="babyEarId" jdbcType="VARCHAR"/>
<result column="person_id" property="personId" jdbcType="VARCHAR"/>
</resultMap>
<insert id="addBabyPatientExtendEarBaby"
parameterType="com.lyms.platform.permission.model.BabyPatientExtendEarBaby">
insert into baby_patient_extend_ear_baby (id,name,sex,cardNo,birth,mname,mcert_type_id,mcert_no,mphone,vc_card_no,build_doctor,hospital_id,build_type,enable,yn,build_date,baby_patient_id,baby_ear_id,person_id) values (#{id},#{name},#{sex},#{cardno},#{birth},#{mname},#{mcertTypeId},#{mcertNo},#{mphone},#{vcCardNo},#{buildDoctor},#{hospitalId},#{buildType},#{enable},#{yn},#{buildDate},#{babyPatientId},#{babyEarId},#{personId})
</insert>
<update id="updateBabyPatientExtendEarBaby"
parameterType="com.lyms.platform.permission.model.BabyPatientExtendEarBaby">
update baby_patient_extend_ear_baby
<set>
<if test="name != null and name != ''">
name = #{name,jdbcType=VARCHAR},
</if>
<if test="sex != null and sex >= 0">
sex = #{sex,jdbcType=INTEGER},
</if>
<if test="cardno != null and cardno != ''">
cardNo = #{cardno,jdbcType=VARCHAR},
</if>
<if test="birth != null">
birth = #{birth,jdbcType=TIMESTAMP},
</if>
<if test="mname != null and mname != ''">
mname = #{mname,jdbcType=VARCHAR},
</if>
<if test="mcertTypeId != null and mcertTypeId != ''">
mcert_type_id = #{mcertTypeId,jdbcType=VARCHAR},
</if>
<if test="mcertNo != null and mcertNo != ''">
mcert_no = #{mcertNo,jdbcType=VARCHAR},
</if>
<if test="mphone != null and mphone != ''">
mphone = #{mphone,jdbcType=VARCHAR},
</if>
<if test="vcCardNo != null and vcCardNo != ''">
vc_card_no = #{vcCardNo,jdbcType=VARCHAR},
</if>
<if test="buildDoctor != null and buildDoctor != ''">
build_doctor = #{buildDoctor,jdbcType=VARCHAR},
</if>
<if test="hospitalId != null and hospitalId != ''">
hospital_id = #{hospitalId,jdbcType=VARCHAR},
</if>
<if test="buildType != null and buildType >= 0">
build_type = #{buildType,jdbcType=INTEGER},
</if>
<if test="enable != null and enable != ''">
enable = #{enable,jdbcType=VARCHAR},
</if>
<if test="yn != null and yn >= 0">
yn = #{yn,jdbcType=INTEGER},
</if>
<if test="buildDate != null">
build_date = #{buildDate,jdbcType=TIMESTAMP},
</if>
<if test="babyPatientId != null and babyPatientId != ''">
baby_patient_id = #{babyPatientId,jdbcType=VARCHAR},
</if>
<if test="babyEarId != null and babyEarId != ''">
baby_ear_id = #{babyEarId,jdbcType=VARCHAR},
</if>
<if test="personId != null and personId != ''">
person_id = #{personId,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
<delete id="deleteBabyPatientExtendEarBaby" parameterType="java.lang.String">
delete from baby_patient_extend_ear_baby where id = #{id,jdbcType=VARCHAR}
</delete>
<select id="getBabyPatientExtendEarBaby" resultMap="BabyPatientExtendEarBabyResultMap"
parameterType="java.lang.String">
select id,name,sex,cardNo,birth,mname,mcert_type_id,mcert_no,mphone,vc_card_no,build_doctor,hospital_id,build_type,enable,yn,build_date,baby_patient_id,baby_ear_id,person_id
from baby_patient_extend_ear_baby where id = #{id,jdbcType=VARCHAR}
</select>
<sql id="orderAndLimit">
<if test="sort != null and sort != '' ">
order by ${sort}
<if test="need != null">
limit #{offset, jdbcType=INTEGER} , #{limit, jdbcType=INTEGER}
</if>
</if>
</sql>
<sql id="BabyPatientExtendEarBabyCondition">
<where>
1 = 1
<if test="id != null and id != ''">
and id = #{id,jdbcType=VARCHAR}
</if>
<if test="name != null and name != ''">
and name = #{name,jdbcType=VARCHAR}
</if>
<if test="queryNo != null and queryNo != ''">
and (
name LIKE concat("%",#{queryNo,jdbcType=VARCHAR},"%")
or
mcert_no LIKE concat("%",#{queryNo,jdbcType=VARCHAR},"%")
or
mphone LIKE concat(#{queryNo,jdbcType=VARCHAR},"%")
or
cardno LIKE concat(#{queryNo,jdbcType=VARCHAR},"%")
)
</if>
<if test="sex != null and sex >= 0">
and sex = #{sex,jdbcType=INTEGER}
</if>
<if test="cardno != null and cardno != ''">
and cardNo = #{cardno,jdbcType=VARCHAR}
</if>
<if test="birth != null">
and birth = #{birth,jdbcType=TIMESTAMP}
</if>
<if test="birthStart!=null">
AND
<![CDATA[
DATEDIFF(#{birthStart},birth) <=0
]]>
</if>
<if test="birthEnd!=null">
and
<![CDATA[
DATEDIFF(#{birthEnd},birth) >=0
]]>
</if>
<if test="mname != null and mname != ''">
and mname = #{mname,jdbcType=VARCHAR}
</if>
<if test="mcertTypeId != null and mcertTypeId != ''">
and mcert_type_id = #{mcertTypeId,jdbcType=VARCHAR}
</if>
<if test="mcertNo != null and mcertNo != ''">
and mcert_no = #{mcertNo,jdbcType=VARCHAR}
</if>
<if test="mphone != null and mphone != ''">
and mphone = #{mphone,jdbcType=VARCHAR}
</if>
<if test="vcCardNo != null and vcCardNo != ''">
and vc_card_no = #{vcCardNo,jdbcType=VARCHAR}
</if>
<if test="buildDoctor != null and buildDoctor != ''">
and build_doctor = #{buildDoctor,jdbcType=VARCHAR}
</if>
<if test="hospitalId != null and hospitalId != ''">
and hospital_id = #{hospitalId,jdbcType=VARCHAR}
</if>
<if test="hospitalIds != null">
and hospital_id in
<foreach item="item" index="index" collection="hospitalIds" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="buildType != null and buildType >= 0">
and build_type = #{buildType,jdbcType=INTEGER}
</if>
<if test="enable != null and enable != ''">
and enable = #{enable,jdbcType=VARCHAR}
</if>
<if test="enables != null">
and enable in
<foreach item="item" index="index" collection="enables" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="isEnable != null and isEnable != ''">
and enable is null
</if>
<if test="noEnable != null and noEnable != ''">
and (enable != #{noEnable,jdbcType=VARCHAR}
or `enable` is null
)
</if>
<if test="yn != null and yn >= 0">
and yn = #{yn,jdbcType=INTEGER}
</if>
<if test="buildDate != null">
and build_date = #{buildDate,jdbcType=TIMESTAMP}
</if>
<if test="babyPatientId != null and babyPatientId != ''">
and baby_patient_id = #{babyPatientId,jdbcType=VARCHAR}
</if>
<if test="babyPatientIds != null and babyPatientIds!=''">
and baby_patient_id in
<foreach item="item" index="index" collection="babyPatientIds" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="babyEarId != null and babyEarId != ''">
and baby_ear_id = #{babyEarId,jdbcType=VARCHAR}
</if>
<if test="personId != null and personId != ''">
and person_id = #{personId,jdbcType=VARCHAR}
</if>
</where>
</sql>
<select id="queryBabyPatientExtendEarBaby" resultMap="BabyPatientExtendEarBabyResultMap"
parameterType="com.lyms.platform.permission.model.BabyPatientExtendEarBabyQuery">
select
id,name,sex,cardNo,birth,mname,mcert_type_id,mcert_no,mphone,vc_card_no,build_doctor,hospital_id,build_type,enable,yn,build_date,baby_patient_id,baby_ear_id,person_id
from baby_patient_extend_ear_baby
<include refid="BabyPatientExtendEarBabyCondition"/>
<include refid="orderAndLimit"/>
</select>
<select id="queryBabyPatientExtendEarBabyCount" resultType="int"
parameterType="com.lyms.platform.permission.model.BabyPatientExtendEarBabyQuery">
select count(1) from baby_patient_extend_ear_baby
<include refid="BabyPatientExtendEarBabyCondition"/>
</select>
</mapper>