<?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.diagbot.mapper.MedCrisisInfoMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.diagbot.entity.MedCrisisInfo">
        <id column="rec_id" property="recId" />
        <result column="hospital_id" property="hospitalId" />
        <result column="behospital_code" property="behospitalCode" />
        <result column="rec_type" property="recType" />
        <result column="crisis_id" property="crisisId" />
        <result column="crisis_name" property="crisisName" />
        <result column="dept_id" property="deptId" />
        <result column="dept_name" property="deptName" />
        <result column="doctor_id" property="doctorId" />
        <result column="doctor_name" property="doctorName" />
        <result column="crisis_value" property="crisisValue" />
        <result column="crisis_desc" property="crisisDesc" />
        <result column="crisis_status" property="crisisStatus" />
        <result column="crisis_top_value" property="crisisTopValue" />
        <result column="crisis_lower_value" property="crisisLowerValue" />
        <result column="send_date" property="sendDate" />
        <result column="rep_date" property="repDate" />
        <result column="is_deleted" property="isDeleted" />
        <result column="gmt_create" property="gmtCreate" />
        <result column="gmt_modified" property="gmtModified" />
        <result column="creator" property="creator" />
        <result column="modifier" property="modifier" />
    </resultMap>

    <update id="updateBatchByKey">
        <foreach collection="list" item="item"  separator=";">
            update med_crisis_info
            <set>
                    crisis_id = #{item.crisisId},
                    crisis_name = #{item.crisisName},
                    dept_id = #{item.deptId},
                    dept_name = #{item.deptName},
                    doctor_id = #{item.doctorId},
                    doctor_name = #{item.doctorName},
                    crisis_value = #{item.crisisValue},
                    crisis_desc = #{item.crisisDesc},
                    crisis_status = #{item.crisisStatus},
                    crisis_top_value = #{item.crisisTopValue},
                    crisis_lower_value = #{item.crisisLowerValue},
                    send_date = #{item.sendDate},
                    rep_date = #{item.repDate},
                <if test="item.gmtModified != null">
                    gmt_modified = #{item.gmtModified},
                </if>
                <if test="item.modifier != null">
                    modifier = #{item.modifier},
                </if>
            </set>
            where rec_id = #{item.recId} and hospital_id = #{item.hospitalId} and behospital_code = #{item.behospitalCode} and rec_type = #{item.recType}
        </foreach>
    </update>

</mapper>
