<?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.lantone.daqe.mapper.BlocklossResultMapper">

    <select id="getBlockLossPage" resultType="com.lantone.daqe.dto.GetBlockLossPageDTO">
        SELECT
        id,
        behospital_code,
        rec_id,
        rec_title,
        loss_cause,
        loss_type,
        loss_way,
        gmt_modified,
        `status`,
        is_audited
        FROM
        `dc_blockloss_result`
        WHERE
        is_deleted = "N"
        <if test="getBlockLossPageVO.hospitalId != null">
            AND hospital_id = #{getBlockLossPageVO.hospitalId}
        </if>
        <if test="getBlockLossPageVO.startDate != null">
            <![CDATA[AND behospital_date >= #{getBlockLossPageVO.startDate}]]>
        </if>
        <if test="getBlockLossPageVO.endDate != null">
            <![CDATA[ AND behospital_date <= #{getBlockLossPageVO.endDate}]]>
        </if>
        <if test="getBlockLossPageVO.behospitalCode != null and getBlockLossPageVO.behospitalCode != ''">
            AND behospital_code LIKE CONCAT('%',#{getBlockLossPageVO.behospitalCode},'%')
        </if>
        <if test="getBlockLossPageVO.recId != null and getBlockLossPageVO.recId != ''">
            AND rec_id LIKE CONCAT('%',#{getBlockLossPageVO.recId},'%')
        </if>
        <if test="getBlockLossPageVO.recTitle != null and getBlockLossPageVO.recTitle != ''">
            AND rec_title LIKE CONCAT('%',#{getBlockLossPageVO.recTitle},'%')
        </if>
        <if test="getBlockLossPageVO.lossType != null and getBlockLossPageVO.lossType != ''">
            AND loss_type = #{getBlockLossPageVO.lossType}
        </if>
        <if test="getBlockLossPageVO.lossWay != null and getBlockLossPageVO.lossWay != ''">
            AND loss_way = #{getBlockLossPageVO.lossWay}
        </if>
        <if test="getBlockLossPageVO.isAudited != null and getBlockLossPageVO.isAudited != ''">
            AND is_audited = #{getBlockLossPageVO.isAudited}
        </if>
        <if test="getBlockLossPageVO.status != null and getBlockLossPageVO.status != ''">
            AND `status` = #{getBlockLossPageVO.status}
        </if>
    </select>
</mapper>