<?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.StrOperativeFirstRecordMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.diagbot.entity.StrOperativeFirstRecord">
        <result column="rec_id" property="recId" />
        <result column="hospital_id" property="hospitalId" />
        <result column="behospital_code" property="behospitalCode" />
        <result column="name" property="name" />
        <result column="sex" property="sex" />
        <result column="age" property="age" />
        <result column="bed_no" property="bedNo" />
        <result column="dept_name" property="deptName" />
        <result column="record_date" property="recordDate" />
        <result column="operation_date" property="operationDate" />
        <result column="start_time" property="startTime" />
        <result column="end_time" property="endTime" />
        <result column="narcosis_type" property="narcosisType" />
        <result column="preoperation_diagnosis" property="preoperationDiagnosis" />
        <result column="postoperative_diagnosis" property="postoperativeDiagnosis" />
        <result column="operation_name" property="operationName" />
        <result column="operation_process" property="operationProcess" />
        <result column="postoperative_situation" property="postoperativeSituation" />
        <result column="postoperative_treatment" property="postoperativeTreatment" />
        <result column="postoperative_notice" property="postoperativeNotice" />
        <result column="postoperative_complication" property="postoperativeComplication" />
        <result column="rec_doctor" property="recDoctor" />
        <result column="rec_date" property="recDate" />
        <result column="audit_doctor" property="auditDoctor" />
        <result column="audit_date" property="auditDate" />
        <result column="whole_data" property="wholeData" />
        <result column="remark" property="remark" />
        <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 str_operative_first_record
            <set>
                name = #{item.name},
                sex = #{item.sex},
                age = #{item.age},
                bed_no = #{item.bedNo},
                dept_name = #{item.deptName},
                record_date = #{item.recordDate},
                operation_date = #{item.operationDate},
                start_time = #{item.startTime},
                end_time = #{item.endTime},
                narcosis_type = #{item.narcosisType},
                preoperation_diagnosis = #{item.preoperationDiagnosis},
                postoperative_diagnosis = #{item.postoperativeDiagnosis},
                operation_name = #{item.operationName},
                operation_process = #{item.operationProcess},
                postoperative_situation = #{item.postoperativeSituation},
                postoperative_treatment = #{item.postoperativeTreatment},
                postoperative_notice = #{item.postoperativeNotice},
                postoperative_complication = #{item.postoperativeComplication},
                rec_doctor = #{item.recDoctor},
                rec_date = #{item.recDate},
                audit_doctor = #{item.auditDoctor},
                audit_date = #{item.auditDate},
                whole_data = #{item.wholeData},
                remark = #{item.remark},
                <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}
        </foreach>
    </update>

    <select id="getColumnZhAndCh" resultType="com.diagbot.dto.data.ColumnZhAndChDTO">
        select COLUMN_NAME as en,column_comment as ch from INFORMATION_SCHEMA.Columns where table_name='str_operative_first_record'
    </select>

</mapper>
