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

    <select id="selectNursingPlanItemsWithFrequencyCategory"
            resultType="cn.iocoder.yudao.module.system.controller.admin.nursing.vo.NursingPlanItemRespVO">
        select enpi.id,
               enpi.nursing_plan_id,
               enpi.nurse_item_id,
               enpi.nurse_item_name,
               enpi.frequency,
               enpi.frequency_type,
               enpi.operating_mode,
               enpi.is_delete,
               enpi.is_extra,
               enpi.begin_time,
               enpi.created_time,
               enpi.created_by,
               ni.frequency_category,
               ni.frequency_category_type
        from elderly_nursing_plan_item enpi
                 left join nurse_item ni on ni.id = enpi.nurse_item_id
        <where>
            enpi.nursing_plan_id = #{nursingPlanId}
            and enpi.is_delete = 0
            <if test="isExtra != null">
                and enpi.is_extra = #{isExtra}
            </if>
        </where>
        order by enpi.id asc
    </select>

</mapper>
