<?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.report.mapper.SysUserRoleMapper2">

    <select id="getUserByRole" resultType="com.lantone.report.dto.GetReviewerDTO">
        SELECT
        u.linkman userName,
        u.id id
        FROM
        sys_user u,
        sys_user_role role,
        sys_user_hospital uh
        WHERE
        u.is_deleted = "N"
        AND uh.is_deleted = "N"
        AND role.is_deleted = "N"
        AND uh.user_id = u.id
        AND u.id = role.user_id
        AND role.role_id = #{getReviewerVO.roleID}
        <if test="getReviewerVO.hospitalId != null ">
            AND uh.hospital_id = #{getReviewerVO.hospitalId}
        </if>
        <if test="getReviewerVO.selfFlag == false">
            AND u.id != #{getReviewerVO.claimantId}
        </if>
    </select>
</mapper>