<?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">
    <sql id="basicInfoColumns">
        patient_id AS patientId,
        admiss_times AS admissTimes,
        inpatient_no AS inpatientNo,
        admiss_id AS admissId,
        admiss_date AS admissDate,
        dis_date AS disDate,
        admiss_dept_name AS admissDeptName,
        dis_dept_name AS disDeptName ,
        jzh,
        name,
        id_card AS idCard
    </sql>
    <select id="getByDisDate" resultType="com.docus.server.archive.entity.TBasic">
        SELECT
        <include refid="basicInfoColumns"></include>
        FROM
        docus_medicalrecord.t_basic
        WHERE
            dis_date BETWEEN #{start} AND #{end}
            AND admiss_date IS NOT NULL
            AND is_cancel = 0
        ORDER BY dis_date DESC
    </select>
    <select id="getByPatientIds" resultType="com.docus.server.archive.entity.TBasic">
        SELECT
        <include refid="basicInfoColumns"></include>
        FROM
        docus_medicalrecord.t_basic
        WHERE
        patient_id IN
        <foreach collection="patientIdList" item="patientId" separator="," open="(" close=")">
            #{patientId}
        </foreach>
        ORDER BY dis_date DESC
    </select>

</mapper>
