<?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.QcTypeMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.diagbot.entity.QcType">
        <id column="id" property="id" />
        <result column="hospital_id" property="hospitalId" />
        <result column="name" property="name" />
        <result column="default_module" property="defaultModule" />
        <result column="parent_type_id" property="parentTypeId" />
        <result column="sex" property="sex" />
        <result column="beh_dept_id" property="behDeptId" />
        <result column="beh_dept_name" property="behDeptName" />
        <result column="remark" property="remark" />
        <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" />
    </resultMap>

    <!--分页-->
    <select id="getList" resultType="com.diagbot.dto.QcTypePageDTO">
        SELECT a.* FROM `qc_type` a
        WHERE a.is_deleted = 'N'
        <if test="hospitalId != null">
            AND a.hospital_id = #{hospitalId}
        </if>
        <if test="name != null and name != ''">
            AND UPPER(a.name) like concat ('%', UPPER(trim(#{name})), '%')
        </if>
        order by a.gmt_modified desc
    </select>
</mapper>
