<?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.archivesqlserver.mapper.ArchiveMasterMapper">


    <select id="listByCondition" resultType="com.docus.server.archivesqlserver.entity.ArchiveMaster">
        select
            id,
            inp_no as inpNo,
            visit_id as visitId
        from
             dbo.archive_master
        <where>
            <if test="condition.id !=null and condition.id != ''">
                AND id=#{condition.id}
            </if>
            <if test="condition.inpNo != null and condition.inpNo != ''">
                AND inp_no=#{condition.inpNo}
            </if>
            <if test="condition.visitId != null and condition.visitId != ''">
                AND visit_id=#{condition.visitId}
            </if>
        </where>

    </select>
    <select id="listByNoCollectTaskAndGeDisDate"
            resultType="com.docus.server.archivesqlserver.entity.ArchiveMaster">
        select  master.id,
                master.inp_no as inpNo,
                master.visit_id as visitId
        from dbo.Archive_Master master
        where master.discharge_date_time >= #{disDate}
          and id not in (
            select
                MasterID
            from dbo.archive_collect_task task
            where sysflag=#{sysCode}
        )
    </select>
</mapper>
