<?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.diagbot.mapper.QcAbnormalMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.diagbot.entity.QcAbnormal">
        <id column="id" property="id" />
        <result column="is_deleted" property="isDeleted" />
        <result column="gmt_create" property="gmtCreate" />
        <result column="gmt_modified" property="gmtModified" />
        <result column="creator" property="creator" />
        <result column="modifier" property="modifier" />
        <result column="hospital_id" property="hospitalId" />
        <result column="behospital_code" property="behospitalCode" />
        <result column="type" property="type" />
        <result column="description" property="description" />
        <result column="status" property="status" />
        <result column="remark" property="remark" />
    </resultMap>

    <select id="getQcAnnormal" resultType="com.diagbot.dto.QcAbnormalDTO" parameterType="com.diagbot.vo.QcAbnormalVO">
        SELECT
        t1.*
        FROM
        `qc_abnormal` t1
        WHERE
        t1.is_deleted = 'N'
        <if test="hospitalId != null">
            and t1.hospital_id = #{hospitalId}
        </if>
        <if test="type != null">
            and t1.type = #{type}
        </if>
        <if test="status != null">
            and t1.status = #{status}
        </if>
        <if test="behospitalCode != null and behospitalCode != ''">
            and t1.behospital_code like CONCAT('%',#{behospitalCode},'%')
        </if>
        <if test="startDate != null and startDate != ''">
            <![CDATA[ and t1.gmt_create >= DATE(#{startDate})]]>
        </if>
        <if test="endDate != null and endDate != ''">
            <![CDATA[ and t1.gmt_create < DATE(#{endDate})]]>
        </if>
        order by t1.gmt_create desc
    </select>
</mapper>
