<?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.BabyDiagnoseMapper">
<resultMap id="babyDiagnoseResultMap" type="com.lyms.platform.pojo.BabyDiagnoseModel">
<result column="blh" property="blh"/>
<result column="syxh" property="syxh"/>
<result column="hzxm" property="hzxm"/>
<result column="sex" property="sex"/>
<result column="birth" property="birth"/>
<result column="birthtime" property="birthtime"/>
<result column="cyzddm" property="cyzddm"/>
<result column="cyzdmc" property="cyzdmc"/>
<result column="sfzh" property="sfzh"/>
<result column="lxdh" property="lxdh"/>
<result column="lxdz" property="lxdz"/>
<result column="lxr" property="lxr"/>
<result column="lxrdh" property="lxrdh"/>
<result column="curraddr" property="curraddr"/>
<result column="cyrq" property="cyrq"/>
<result column="lrrq" property="lrrq"/>
<result column="rqrq" property="rqrq"/>
<result column="ryrq" property="ryrq"/>
<result column="cqrq" property="cqrq"/>
<result column="ksdm" property="ksdm"/>
<result column="bqdm" property="bqdm"/>
<result column="mblh" property="mblh"/>
<result column="msyxh" property="msyxh"/>
<result column="isbuild" property="isbuild"/>
</resultMap>
<insert id="addBabyDiagnose" parameterType="com.lyms.platform.pojo.BabyDiagnoseModel">
<selectKey order="AFTER" keyProperty="id" resultType="java.lang.Integer">SELECT LAST_INSERT_ID()</selectKey>
INSERT INTO lyms_baby_diagnose
(type,blh,syxh,hzxm,birth,
birthtime,sex,sfzh,lxdh,lxdz,lxr,lxrdh,
curraddr,lrrq,ryrq,rqrq,cyrq,cqrq,cyzddm,
cyzdmc,ksdm,bqdm,mblh,msyxh,isbuild)
VALUES (#{type},#{blh},#{syxh},#{hzxm},#{birth},
#{birthtime},#{sex},#{sfzh},#{lxdh},#{lxdz},#{lxr},#{lxrdh},
#{curraddr},#{lrrq},#{ryrq},#{rqrq},#{cyrq},#{cqrq},#{cyzddm},
#{cyzdmc},#{ksdm},#{bqdm},#{mblh},#{msyxh},#{isbuild})
</insert>
<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>
<select id="queryBabyDiagnoses" parameterType="java.util.Map" resultType="com.lyms.platform.pojo.BabyDiagnoseModel">
SELECT
id,blh,syxh,hzxm,birth,
birthtime,sex,sfzh,lxdh,lxdz,lxr,lxrdh,
curraddr,lrrq,ryrq,rqrq,cyrq,cqrq,cyzddm,
cyzdmc,ksdm,bqdm,mblh,msyxh,isbuild
FROM lyms_baby_diagnose
WHERE 1 = 1
<if test="id != null">
and id = #{id,jdbcType=INTEGER}
</if>
<if test="blh != null and blh != ''">
and blh = #{blh,jdbcType=VARCHAR}
</if>
<if test="syxh != null and syxh != ''">
and syxh = #{syxh,jdbcType=VARCHAR}
</if>
<include refid="orderAndLimit"/>
</select>
<update id="updateBabyDiagnose" parameterType="com.lyms.platform.pojo.BabyDiagnoseModel">
UPDATE
lyms_baby_diagnose
<set>
<if test="isbuild != null">
isbuild = #{isbuild,jdbcType=INTEGER},
</if>
</set>
where blh = #{blh,jdbcType=VARCHAR}
</update>
<update id="updateBabyDiagnoseType" parameterType="com.lyms.platform.pojo.BabyDiagnoseModel">
UPDATE
lyms_baby_diagnose
<set>
<if test="type != null">
type = #{type,jdbcType=VARCHAR},
</if>
</set>
where blh = #{blh,jdbcType=VARCHAR}
</update>
<sql id="babyDiagnosesCondition">
<where>
1=1
<if test="startDischargeDate != null and startDischargeDate!=''">
AND
<![CDATA[
DATEDIFF(#{startDischargeDate},cyrq)<=0
]]>
</if>
<if test="endDischargeDate != null and endDischargeDate!=''">
AND
<![CDATA[
DATEDIFF(#{endDischargeDate},cyrq)>=0
]]>
</if>
<if test="startBirthDate != null and startBirthDate!=''">
AND
<![CDATA[
DATEDIFF(#{startBirthDate},birth)<=0
]]>
</if>
<if test="endBirthDate != null and endBirthDate!=''">
AND
<![CDATA[
DATEDIFF(#{endBirthDate},birth)>=0
]]>
</if>
<if test="hospitalizationNo != null and hospitalizationNo != ''">
and blh = #{hospitalizationNo}
</if>
<if test="babyName != null and babyName!=''">
and hzxm =#{babyName} or lxrdh=#{babyName} OR lxdh=#{babyName}
</if>
<if test="finalDiagnosis != null and finalDiagnosis!= '' ">
and cyzddm like CONCAT(#{finalDiagnosis},'%')
</if>
<if test="isbuild != null">
and isbuild = #{isbuild}
</if>
<if test="type != null">
and type = #{type}
</if>
</where>
</sql>
<select id="queryBabyDiagnosesList" parameterType="com.lyms.platform.permission.model.BabyDiagnoseQuery"
resultMap="babyDiagnoseResultMap">
SELECT
type,id,blh,syxh,hzxm,birth,
birthtime,sex,sfzh,lxdh,lxdz,lxr,lxrdh,
curraddr,lrrq,ryrq,rqrq,cyrq,cqrq,cyzddm,
cyzdmc,ksdm,bqdm,mblh,msyxh,isbuild
FROM lyms_baby_diagnose
<include refid="babyDiagnosesCondition"/>
<include refid="orderAndLimit"/>
</select>
<select id="queryBabyDiagnosesListCount" parameterType="com.lyms.platform.permission.model.BabyDiagnoseQuery"
resultType="java.lang.Integer"
>
SELECT
count(1)
FROM lyms_baby_diagnose
<include refid="babyDiagnosesCondition"/>
</select>
</mapper>