<?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="cn.iocoder.yudao.module.system.dal.mysql.biz.ElderlyHealthRecordMapper">
    <select id="queryPage"
            resultType="cn.iocoder.yudao.module.system.dal.dataobject.biz.ElderlyHealthRecordDO">
        select ei.id AS 'elder.id',ei.elder_name AS 'elder.elderName',ei.elder_sex AS 'elder.elderSex',ei.in_status AS 'elder.in_status',ei.tenant_id as 'elder.tenantId',hr.* from
        elderly_info ei
        LEFT JOIN
        elderly_health_record hr ON hr.elder_id = ei.id
        <where>
            1 = 1
            <if test="null != params.elderName and '' != params.elderName">
                AND ei.elder_name like concat('%',#{params.elderName} ,'%')
            </if>
            <if test="null != params.inStatus">
                AND ei.in_status = #{params.inStatus}
            </if>
            <if test="null != params.liveType and '' != params.liveType">
                AND hr.live_type = #{params.liveType}
            </if>
            <if test="null != params.orgType">
                AND ei.org_type = #{params.orgType}
            </if>
            <if test="null != params.tenantIds">
                AND ei.tenant_id in
                <foreach item="id" collection="params.tenantIds" open="(" separator="," close=")">
                    #{id}
                </foreach>
            </if>
        </where>
        order by ei.create_time desc
    </select>
</mapper>
