<?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.docus.server.collection.infrastructure.dao.mapper.TBasicMapper">
    <insert id="insertBatch">
        INSERT INTO `docus_medicalrecord`.`t_basic`
        (`admiss_dept`,
        `attending`,
        `create_time`,
        `admiss_days`,
        `is_dead`,
        `sex_name`,
        `bed_num`,
        `age`,
        `sex`,
        `id_card`,
        `dis_dept`,
        `patient_id`,
        `admiss_times`,
        `inpatient_no`,
        `name`,
        `admiss_date`,
        `admiss_dept_name`,
        `dis_date`,
        `dis_dept_name`,
        `attending_name`,
        `jzh`,
        `is_other`)
        VALUES
        <foreach collection="tBasicList" item="tBasic" separator=",">
            (#{tBasic.admissDept},
            #{tBasic.attending},
            #{tBasic.createTime},
            #{tBasic.admissDays},
            #{tBasic.isDead},
            #{tBasic.sexName},
            #{tBasic.bedNum},
            #{tBasic.age},
            #{tBasic.sex},
            #{tBasic.idCard},
            #{tBasic.disDept},
            #{tBasic.patientId},
            #{tBasic.admissTimes},
            #{tBasic.inpatientNo},
            #{tBasic.name},
            #{tBasic.admissDate},
            #{tBasic.admissDeptName},
            #{tBasic.disDate},
            #{tBasic.disDeptName},
            #{tBasic.attendingName},
            #{tBasic.jzh},
            #{tBasic.isOther})
        </foreach>
    </insert>

    <update id="update">
        UPDATE `docus_medicalrecord`.`t_basic` SET
        `admiss_dept` = #{tBasic.admissDept},
        `attending` = #{tBasic.attending},
        `create_time` = #{tBasic.createTime},
        `admiss_days` = #{tBasic.admissDays},
        `is_dead` = #{tBasic.isDead},
        `sex_name` = #{tBasic.sexName},
        `bed_num` = #{tBasic.bedNum},
        `age` = #{tBasic.age},
        `sex` = #{tBasic.sex},
        `id_card` = #{tBasic.idCard},
        `dis_dept` = #{tBasic.disDept},
        `admiss_times` = #{tBasic.admissTimes},
        `name` = #{tBasic.name},
        `admiss_date` = #{tBasic.admissDate},
        `admiss_dept_name` = #{tBasic.admissDeptName},
        `dis_date` = #{tBasic.disDate},
        `dis_dept_name` = #{tBasic.disDeptName},
        `attending_name` = #{tBasic.attendingName},
        `is_other` = #{tBasic.isOther}
        WHERE
        `jzh` = #{tBasic.jzh}
    </update>

    <select id="selectOne" resultType="java.lang.Integer">
        select count(patient_id) from docus_medicalrecord.t_basic where jzh=#{jzh}
    </select>
    <select id="getPatientIdByJzh" resultType="java.lang.String">
        select patient_id from `docus_medicalrecord`.`t_basic` where jzh=#{jzh}
    </select>

</mapper>
