<?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.ruoyi.web.work.mapper.ResultMapper">

    <select id="selectList" resultType="com.ruoyi.web.work.domain.Result">
        select * from tb_obx_result
        <where>
            <if test="id != null "> and id = #{id}</if>
            <if test="obrId != null "> and obr_id = #{obrId}</if>
            <if test="serialNo != null  and serialNo != ''"> and serial_no = #{serialNo}</if>
            <if test="dataType != null  and dataType != ''"> and data_type = #{dataType}</if>
            <if test="mecTechObsProject != null  and mecTechObsProject != ''"> and mec_tech_obs_project = #{mecTechObsProject}</if>
            <if test="mecTechObsName != null  and mecTechObsName != ''"> and mec_tech_obs_name = #{mecTechObsName}</if>
            <if test="obsProjectDetail != null  and obsProjectDetail != ''"> and obs_project_detail = #{obsProjectDetail}</if>
            <if test="projectInfo != null  and projectInfo != ''"> and project_info = #{projectInfo}</if>
            <if test="unitCode != null  and unitCode != ''"> and unit_code = #{unitCode}</if>
            <if test="unitName != null  and unitName != ''"> and unit_name like concat('%', #{unitName}, '%')</if>
            <if test="result != null  and result != ''"> and result = #{result}</if>
            <if test="sign != null  and sign != ''"> and sign = #{sign}</if>
            <if test="obsClassification != null  and obsClassification != ''"> and obs_classification = #{obsClassification}</if>
            <if test="testMethod != null  and testMethod != ''"> and test_method = #{testMethod}</if>
        </where>
    </select>

    <select id="getResultByCard" resultType="com.ruoyi.web.work.domain.Result">
        SELECT * FROM tb_obx_result
            JOIN tb_obr_request on tb_obx_result.obr_id=tb_obr_request.id
                where tb_obr_request.card_id=#{card}
    </select>

    <select id="getAllResultByPatId" resultType="com.ruoyi.web.work.domain.Result">
        SELECT * FROM tb_obx_result
        WHERE tb_obx_result.obr_id IN
              (SELECT tb_obr_request.id FROM tb_obr_request
               WHERE tb_obr_request.orc_id IN
                     ( SELECT tb_orc_report.id FROM tb_orc_report WHERE tb_orc_report.pat_id =#{patId} ))
    </select>


    <select id="selectResultByObrId" resultType="com.ruoyi.web.work.domain.Result">
        SELECT * FROM tb_obx_result
        WHERE obr_id = #{obrId}
    </select>


</mapper>
