<?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.archive.mapper.TBasicMapper">
    <insert id="insertBatch">
        INSERT INTO `docus_medicalrecord`.`t_basic`
            (`patient_id`, `admiss_times`, `inpatient_no`,  `name`, `name_spell`,
             `sex`,  `sex_name`,`age`, `age_month`, `age_day`, `id_card`, `telphone`,
             `admiss_date`,`admiss_dept`, `admiss_dept_name`,
             `dis_date`,`dis_dept`, `dis_dept_name`,
             `attending`, `attending_name`,
             `is_dead`,`file_source`,
             `jzh`,`bed_no`, `jz_card_no`, `total_cost`,
             `create_time`, `update_time`) VALUES
            <foreach collection="basicList" separator="," item="basic">
                (
                 #{basic.patientId},#{basic.admissTimes},#{basic.inpatientNo},#{basic.name},#{basic.nameSpell},
                 #{basic.sex},#{basic.sexName},#{basic.age},#{basic.ageMonth},#{basic.ageDay},#{basic.idCard},#{basic.telphone},
                 #{basic.admissDate},#{basic.admissDept},#{basic.admissDeptName},
                 #{basic.disDate},#{basic.disDept},#{basic.disDeptName},
                 #{basic.attending},#{basic.attendingName},
                 #{basic.isDead},#{basic.fileSource},
                 #{basic.jzh},#{basic.bedNo},#{basic.jzCardNo},#{basic.totalCost},
                 #{basic.createTime},#{basic.updateTime}
                )
            </foreach>
    </insert>
    <update id="updateBatch">
        <foreach collection="basicList"  item="basic">
          UPDATE  `docus_medicalrecord`.`t_basic`
          set inpatient_no=#{basic.inpatientNo},admiss_times=#{basic.admissTimes},name=#{basic.name},name_spell=#{basic.nameSpell},
            `sex`= #{basic.sex},  `sex_name`=#{basic.sexName},`age`=#{basic.age}, `age_month`=#{basic.ageMonth},
              `age_day`=#{basic.ageDay}, `id_card`=#{basic.idCard}, `telphone`=#{basic.telphone},
            `admiss_date`=#{basic.admissDate},`admiss_dept`=#{basic.admissDept}, `admiss_dept_name`=#{basic.admissDeptName},
            `dis_date`=  #{basic.disDate},`dis_dept`=#{basic.disDept}, `dis_dept_name`=#{basic.disDeptName},
            `attending`= #{basic.attending}, `attending_name`=#{basic.attendingName},
            `is_dead`=#{basic.isDead},`file_source`=#{basic.fileSource},
            `jzh`=  #{basic.jzh},`bed_no`=#{basic.bedNo}, `jz_card_no`=#{basic.jzCardNo}, `total_cost`=#{basic.totalCost},
            `create_time`= #{basic.createTime}, `update_time`=#{basic.updateTime}
            WHERE patient_id= #{basic.patientId};
        </foreach>
    </update>

    <select id="getByJzh" resultType="com.docus.server.archive.entity.TBasic">
        select `patient_id`, `admiss_times`, `inpatient_no`,  `name`, `name_spell`,
        `sex`,  `sex_name`,`age`, `age_month`, `age_day`, `id_card`, `telphone`,
        `admiss_date`,`admiss_dept`, `admiss_dept_name`,
        `dis_date`,`dis_dept`, `dis_dept_name`,
        `attending`, `attending_name`,
        `is_dead`,`file_source`,
        `jzh`,`bed_no`, `jz_card_no`, `total_cost`,
        `create_time`, `update_time`
        from docus_medicalrecord.t_basic
        where jzh in <foreach collection="jzhs" item="jzh" open="(" close=")" separator=",">
                        #{jzh}
                     </foreach>
    </select>
</mapper>
