<?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.ruoyi.script.mapper.PatientScriptMapper">

    <resultMap type="com.ruoyi.script.entity.PatientScript" id="PatientScriptResult">
        <result property="id"    column="id"    />
        <result property="patientName"    column="patient_name"    />
        <result property="patientAge"    column="patient_age"    />
        <result property="patientSex"    column="patient_sex"    />
        <result property="patientCard"    column="patient_card"    />
        <result property="scanTime"    column="scan_time"    />
        <result property="scanPosition"    column="scan_position"    />
        <result property="scanDoctor"    column="scan_doctor"    />
        <result property="structureImage"    column="structure_image"    />
        <result property="featureImage"    column="feature_image"    />

        <result property="repetitionTime"    column="repetition_time"    />
        <result property="scanningOrder"    column="scanning_order"    />
        <result property="sliceNumber"    column="slice_number"    />
        <result property="fibreNumber"    column="fibre_number"    />
        <result property="minLength"    column="min_length"    />
        <result property="maxLength"    column="max_length"    />
        <result property="angleAdjustment"    column="angle_adjustment"    />
        <result property="usageMethod"    column="usage_method"    />
        <result property="type"    column="type"    />
        <result property="status"    column="status"/>
        <result property="resImage"    column="res_image"/>
        <result property="resInfo"    column="res_info"/>
        <result property="createTime"    column="create_time"    />
        <result property="createId"    column="create_id"    />
        <result property="isAll"    column="is_all"    />

    </resultMap>
    <update id="updateStatus" parameterType="com.ruoyi.script.entity.PatientScript">
        update patient_script
        set `status` = #{status}
        ,`res_image` = #{resImage}
        ,`res_info` = #{resInfo}
        where id = #{id}
    </update>
    <delete id="removeByIds" parameterType="java.util.List">
    delete from  patient_script where id in
    <foreach collection="idList" item="id" separator="," open="(" close=")">
        #{id}
    </foreach>

    </delete>
    <select id="selectList"  resultMap="PatientScriptResult">
        select  * from patient_script
        <where>
            <if test="patientName != null  and patientName != ''"> and patient_name like concat('%',#{patientName},'%') </if>
            <if test="patientCard != null  and patientCard != ''"> and patient_card like concat('%',#{patientCard},'%') </if>
            <if test="scanDoctor != null  and scanDoctor != ''"> and scan_doctor like concat('%',#{scanDoctor},'%') </if>
            <if test="isAll != null  and isAll != ''"> and is_all= #{isAll} </if>
        </where>
        order by scan_time desc
    </select>
    <select id="getById" resultMap="PatientScriptResult">
        select  * from patient_script
        where  id =#{id}
    </select>
    <select id="getMriInfo" resultType="com.ruoyi.script.entity.MriInfo">
        SELECT
            *
        FROM
            mri_info
        WHERE `key` = #{key}
    </select>

    <insert id="addData" parameterType="com.ruoyi.script.entity.PatientScript" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
        insert into patient_script
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="patientName != null">patient_name,</if>
            <if test="patientAge != null">patient_age,</if>
            <if test="patientSex != null">patient_sex,</if>
            <if test="patientCard != null">patient_card,</if>
            <if test="scanTime != null">scan_time,</if>
            <if test="scanPosition != null">scan_position,</if>
            <if test="scanDoctor != null">scan_doctor,</if>
            <if test="structureImage != null">structure_image,</if>
            <if test="featureImage != null">feature_image,</if>
            <if test="repetitionTime != null">repetition_time,</if>
            <if test="scanningOrder != null">scanning_order,</if>
            <if test="blOrder != null">bl_order,</if>
            <if test="zdDoctor != null">zd_doctor,</if>
            <if test="shDoctor != null">sh_doctor,</if>
            <if test="sliceNumber != null">slice_number,</if>
            <if test="fibreNumber != null">fibre_number,</if>
            <if test="minLength != null">min_length,</if>
            <if test="maxLength != null">max_length,</if>
            <if test="angleAdjustment != null">angle_adjustment,</if>
            <if test="usageMethod != null">usage_method,</if>
            <if test="type != null">`type`,</if>
            <if test="status != null">`status`,</if>
            <if test="resImage != null">`res_image`,</if>
            <if test="resInfo != null">`res_info`,</if>
            <if test="isAll != null">`is_all`,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createId != null">create_id,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="patientName != null">#{patientName},</if>
            <if test="patientAge != null">#{patientAge},</if>
            <if test="patientSex != null">#{patientSex},</if>
            <if test="patientCard != null">#{patientCard},</if>
            <if test="scanTime != null">#{scanTime},</if>
            <if test="scanPosition != null">#{scanPosition},</if>
            <if test="scanDoctor != null">#{scanDoctor},</if>
            <if test="structureImage != null">#{structureImage},</if>
            <if test="featureImage != null">#{featureImage},</if>
            <if test="repetitionTime != null">#{repetitionTime},</if>
            <if test="scanningOrder != null">#{scanningOrder},</if>
            <if test="blOrder != null">#{blOrder},</if>
            <if test="zdDoctor != null">#{zdDoctor},</if>
            <if test="shDoctor != null">#{shDoctor},</if>
            <if test="sliceNumber != null">#{sliceNumber},</if>
            <if test="fibreNumber != null">#{fibreNumber},</if>
            <if test="minLength != null">#{minLength},</if>
            <if test="maxLength != null">#{maxLength},</if>
            <if test="angleAdjustment != null">#{angleAdjustment},</if>
            <if test="usageMethod != null">#{usageMethod},</if>
            <if test="type != null">#{type},</if>
            <if test="status != null">#{status},</if>
            <if test="resImage != null">#{resImage},</if>
            <if test="resInfo != null">#{resInfo},</if>
            <if test="isAll != null">#{isAll},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createId != null">create_id,</if>


        </trim>
    </insert>
</mapper>