<?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.mzsy.mapper.MzsyReportDataViewMapper">


    <select id="findByPatJzhAndOtherCondition" resultType="com.docus.server.mzsy.entity.MzsyReportDataView">
        select
            ZYH,
            ZYCS,
            FFILE_ID AS ffileId,
            FFILE_NAME AS ffileName,
            FFILE_AF_TIME AS ffileAfTime,
            FFILE_TIME AS ffileTime,
            FFILE_PATH AS ffilePath,
            FPAT_JZH AS fpatJzh,
            FPAT_MODULE AS fpatModule,
            REPORT_DOCTOR AS reportDoctor,
            UPDATE_TIME AS updateTime
        from dbo.V_REPORT_DATA
        where FPAT_JZH = #{jzh}
        <if test="ext != null and ext != ''">
            ${ext}
        </if>

    </select>
    <select id="findByPatIdAndOtherCondition" resultType="com.docus.server.mzsy.entity.MzsyMectReportView">
        SELECT  apply_id as applyId,
               SENDDATE as sendDate,
               patient_name as patientName,
               PDFREPORTPATH as pdfReportPath,
               MODULENAME as moduleName,
               PatientID as patientId
        FROM interface_xmjs.dbo.V_MECT_Result
        WHERE PatientID = #{patId}
        <if test="ext != null and ext != ''">
            ${ext}
        </if>
        order by SENDDATE  asc
    </select>
    <select id="findByPatNoTimeAndOtherCondition" resultType="com.docus.server.mzsy.entity.MzsyReportDataView">
        select
        ZYH,
        ZYCS,
        FFILE_ID AS ffileId,
        FFILE_NAME AS ffileName,
        FFILE_AF_TIME AS ffileAfTime,
        FFILE_TIME AS ffileTime,
        FFILE_PATH AS ffilePath,
        FPAT_JZH AS fpatJzh,
        FPAT_MODULE AS fpatModule,
        REPORT_DOCTOR AS reportDoctor,
        UPDATE_TIME AS updateTime
        from dbo.V_REPORT_DATA
        where ZYH=#{inpatientNo}
        and FFILE_TIME  between #{admissDate} and #{disDate}
        <if test="ext != null and ext != ''">
            ${ext}
        </if>
    </select>
</mapper>
