<?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.emr.dao.commomSearch.ScanPathMapper" >
  <resultMap id="BaseResultMap" type="com.emr.vo.commomSearch.ScanPathVo" >
    <result column="patient_id" property="patientId" jdbcType="VARCHAR" />
    <result column="inpatient_no" property="inpatientNo" jdbcType="VARCHAR" />
    <result column="assort_id" property="assortId" jdbcType="VARCHAR" />
    <result column="scan_page" property="scanPage" jdbcType="VARCHAR" />
    <result column="dis_date" property="disDate" jdbcType="TIMESTAMP" />
    <result column="fileRealPath" property="fileRealPath" jdbcType="VARCHAR" />
  </resultMap>
  <!--根据patientId集合查询图片路径-->
  <select id="selectScanFileByPatientIds" resultMap="BaseResultMap" parameterType="java.lang.String">
    SELECT
        dbo.t_scan_assort.assort_id,
        dbo.t_scan_assort.scan_page,
        (dbo.t_gdh_index.file_path+'\'+dbo.t_scan_assort.scan_page) fileRealPath
    FROM
        dbo.t_gdh_index
    LEFT OUTER JOIN
        dbo.t_scan_assort
    ON
        dbo.t_gdh_index.patient_id = dbo.t_scan_assort.patient_id
    <where>
        dbo.t_scan_assort.patient_id in (${patientIds})
        <if test="assortIds != null">
            AND dbo.t_scan_assort.assort_id in (${assortIds})
        </if>
    </where>
    ORDER BY
        dbo.t_scan_assort.assort_id
  </select>


  <!--脐血库根据patientId集合查询图片路径-->
  <select id="selectScanFileByBloodPatientIds" resultMap="BaseResultMap" parameterType="java.lang.String">
    SELECT
        commomtable.patient_id,
        commomtable.name,
        commomtable.inpatient_no,
        commomtable.dis_date,
        dbo.t_scan_assort.assort_id,
        dbo.t_scan_assort.scan_page,
        (dbo.commomtable.${flag}+'\'+dbo.t_scan_assort.scan_page) fileRealPath
    FROM
        dbo.commomtable
    LEFT OUTER JOIN
        dbo.t_scan_assort
    ON
        dbo.commomtable.patient_id = dbo.t_scan_assort.patient_id
    LEFT OUTER JOIN
        dbo.zd_assort
    ON
        dbo.zd_assort.assort_id = dbo.t_scan_assort.assort_id
    <where>
        dbo.commomtable.patient_id in (${patientIds})
        <if test="assortIds != null">
            AND dbo.t_scan_assort.scan_page in (${assortIds})
        </if>
    </where>
    ORDER BY
        dbo.zd_assort.assort_sort
  </select>
    <!--根据patientId和分段Id查询图片路径-->
  <select id="selectScanFileByPatientIdAndAssortIds" resultMap="BaseResultMap" parameterType="java.lang.String">
    SELECT
        dbo.t_scan_assort.scan_page,
        (dbo.t_gdh_index.file_path+'\'+dbo.t_scan_assort.scan_page) fileRealPath
    FROM
        dbo.t_gdh_index
    LEFT OUTER JOIN
        dbo.t_scan_assort
    ON
        dbo.t_gdh_index.patient_id = dbo.t_scan_assort.patient_id
    WHERE
        dbo.t_scan_assort.patient_id = #{patientId}
    AND
        assort_id IN (#{assortIds})
  </select>
</mapper>