<?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="SDtpSjdcFollowUpStatisticsMapper" >
    <!-- 通用查询映射结果 -->

    <select id="selectSDtpSjdcFollowUpStatisticsList" parameterType="pd" resultType="pd">
        select * from s_dtp_sjdc_follow_up_statistics where 1=1
        <if test="id !=null and id !='' ">
            and id = #{id}
        </if>
        <if test="follower !=null and follower !='' ">
            and follower = #{follower}
        </if>
        <if test="age !=null and age !='' ">
            and age = #{age}
        </if>
        <if test="gender !=null and gender !='' ">
            and gender = #{gender}
        </if>
        <if test="indication !=null and indication !='' ">
            and indication = #{indication}
        </if>
        <if test="adverseReaction !=null and adverseReaction !='' ">
            and adverseReaction = #{adverseReaction}
        </if>
        <if test="medicationStatus !=null and medicationStatus !='' ">
            and medicationStatus = #{medicationStatus}
        </if>
        <if test="cooperationLevel !=null and cooperationLevel !='' ">
            and cooperationLevel = #{cooperationLevel}
        </if>
        <if test="permanentDiscontinuation !=null and permanentDiscontinuation !='' ">
            and permanentDiscontinuation = #{permanentDiscontinuation}
        </if>
        <if test="temporarySuspension !=null and temporarySuspension !='' ">
            and temporarySuspension = #{temporarySuspension}
        </if>
        <if test="previousTreatmentPlan !=null and previousTreatmentPlan !='' ">
            and previousTreatmentPlan = #{previousTreatmentPlan}
        </if>
        <if test="currentTreatmentPlan !=null and currentTreatmentPlan !='' ">
            and currentTreatmentPlan = #{currentTreatmentPlan}
        </if>
        <if test="survivalPeriod !=null and survivalPeriod !='' ">
            and survivalPeriod = #{survivalPeriod}
        </if>
        <if test="genericName !=null and genericName !='' ">
            and genericName = #{genericName}
        </if>
        <if test="query != null and query!=''">
            AND genericName LIKE CONCAT('%', #{query}, '%')
        </if>

        <if test="patientCount !=null and patientCount !='' ">
            and patientCount = #{patientCount}
        </if>
        <if test="taskCount !=null and taskCount !='' ">
            and taskCount = #{taskCount}
        </if>
    </select>


    <update id="updateSDtpSjdcFollowUpStatistics" parameterType="pd" >
        update s_dtp_sjdc_follow_up_statistics
        <trim prefix=" SET " suffix="" prefixOverrides="," suffixOverrides=",">
        <if test="follower !=null and follower !='' ">
            follower = #{follower},
        </if>
        <if test="age !=null and age !='' ">
            age = #{age},
        </if>
        <if test="gender !=null and gender !='' ">
            gender = #{gender},
        </if>
        <if test="indication !=null and indication !='' ">
            indication = #{indication},
        </if>
        <if test="adverseReaction !=null and adverseReaction !='' ">
            adverseReaction = #{adverseReaction},
        </if>
        <if test="medicationStatus !=null and medicationStatus !='' ">
            medicationStatus = #{medicationStatus},
        </if>
        <if test="cooperationLevel !=null and cooperationLevel !='' ">
            cooperationLevel = #{cooperationLevel},
        </if>
        <if test="permanentDiscontinuation !=null and permanentDiscontinuation !='' ">
            permanentDiscontinuation = #{permanentDiscontinuation},
        </if>
        <if test="temporarySuspension !=null and temporarySuspension !='' ">
            temporarySuspension = #{temporarySuspension},
        </if>
        <if test="previousTreatmentPlan !=null and previousTreatmentPlan !='' ">
            previousTreatmentPlan = #{previousTreatmentPlan},
        </if>
        <if test="currentTreatmentPlan !=null and currentTreatmentPlan !='' ">
            currentTreatmentPlan = #{currentTreatmentPlan},
        </if>
        <if test="survivalPeriod !=null and survivalPeriod !='' ">
            survivalPeriod = #{survivalPeriod},
        </if>
        <if test="genericName !=null and genericName !='' ">
            genericName = #{genericName},
        </if>
        <if test="patientCount !=null and patientCount !='' ">
            patientCount = #{patientCount},
        </if>
        <if test="taskCount !=null and taskCount !='' ">
            taskCount = #{taskCount},
        </if>
        </trim>
        <if test="up != null and up!=''">
            <if test="id != null and id!=''">
                where id=#{id}
            </if>
        </if>
    </update>

    <delete id="SDtpSjdcFollowUpStatisticsRemove" parameterType="pd">
        <if test="ids != null">
            delete from s_dtp_sjdc_follow_up_statistics where
            <if test="ids != null">
                id in(${ids})
            </if>
        </if>
    </delete>

    <insert id="addSDtpSjdcFollowUpStatistics" parameterType="pd" >

        insert into s_dtp_sjdc_follow_up_statistics
        <trim prefix="(" suffix=")" prefixOverrides="," suffixOverrides=",">

        <if test="follower !=null and follower !='' ">
            follower,
        </if>
        <if test="age !=null and age !='' ">
            age,
        </if>
        <if test="gender !=null and gender !='' ">
            gender,
        </if>
        <if test="indication !=null and indication !='' ">
            indication,
        </if>
        <if test="adverseReaction !=null and adverseReaction !='' ">
            adverseReaction,
        </if>
        <if test="medicationStatus !=null and medicationStatus !='' ">
            medicationStatus,
        </if>
        <if test="cooperationLevel !=null and cooperationLevel !='' ">
            cooperationLevel,
        </if>
        <if test="permanentDiscontinuation !=null and permanentDiscontinuation !='' ">
            permanentDiscontinuation,
        </if>
        <if test="temporarySuspension !=null and temporarySuspension !='' ">
            temporarySuspension,
        </if>
        <if test="previousTreatmentPlan !=null and previousTreatmentPlan !='' ">
            previousTreatmentPlan,
        </if>
        <if test="currentTreatmentPlan !=null and currentTreatmentPlan !='' ">
            currentTreatmentPlan,
        </if>
        <if test="survivalPeriod !=null and survivalPeriod !='' ">
            survivalPeriod,
        </if>
        <if test="genericName !=null and genericName !='' ">
            genericName,
        </if>
        <if test="patientCount !=null and patientCount !='' ">
            patientCount,
        </if>
        <if test="taskCount !=null and taskCount !='' ">
            taskCount,
        </if>
        </trim>
        <trim prefix=" VALUES (" suffix=")" prefixOverrides="," suffixOverrides=",">
        <if test="follower !=null and follower !='' ">
             #{follower},
        </if>
        <if test="age !=null and age !='' ">
             #{age},
        </if>
        <if test="gender !=null and gender !='' ">
             #{gender},
        </if>
        <if test="indication !=null and indication !='' ">
             #{indication},
        </if>
        <if test="adverseReaction !=null and adverseReaction !='' ">
             #{adverseReaction},
        </if>
        <if test="medicationStatus !=null and medicationStatus !='' ">
             #{medicationStatus},
        </if>
        <if test="cooperationLevel !=null and cooperationLevel !='' ">
             #{cooperationLevel},
        </if>
        <if test="permanentDiscontinuation !=null and permanentDiscontinuation !='' ">
             #{permanentDiscontinuation},
        </if>
        <if test="temporarySuspension !=null and temporarySuspension !='' ">
             #{temporarySuspension},
        </if>
        <if test="previousTreatmentPlan !=null and previousTreatmentPlan !='' ">
             #{previousTreatmentPlan},
        </if>
        <if test="currentTreatmentPlan !=null and currentTreatmentPlan !='' ">
             #{currentTreatmentPlan},
        </if>
        <if test="survivalPeriod !=null and survivalPeriod !='' ">
             #{survivalPeriod},
        </if>
        <if test="genericName !=null and genericName !='' ">
             #{genericName},
        </if>
        <if test="patientCount !=null and patientCount !='' ">
             #{patientCount},
        </if>
        <if test="taskCount !=null and taskCount !='' ">
             #{taskCount},
        </if>
        </trim>

    </insert>

</mapper>
