记录工作台需求相关

1.需求

 2.语句

 <!--====================工作台相关接口=====================-->
    <select id="selectEquCount" resultType="int">
        select count(*) from t_record
        <where>
            1 = 1
            <if test="doctorId != null "> and doctor_id = #{doctorId}</if>
            <if test="hospitalId != null "> and hospital_id = #{hospitalId}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
            <if test="month != null ">
                and DATE_FORMAT(create_time,'%Y%m') = DATE_FORMAT(CURDATE(),'%Y%m')
            </if>
            <if test="week != null ">
                and YEARWEEK(date_format(create_time,'%Y-%m-%d'),1) = YEARWEEK(now(),1)
            </if>
            <if test="day != null ">
                and TO_DAYS(create_time) = TO_DAYS(NOW())
            </if>
        </where>
    </select>

    <select id="dayPlan" resultType="com.ruoyi.system.domain.resp.PlatformDayPlanResp">
        select
        a.create_time as createTime,
        if(a.status = '0','预约','就诊') as status,
        b.name
        from t_record a LEFT JOIN t_patient b on a.patient_id = b.id
        where TO_DAYS(a.create_time) = TO_DAYS(NOW())
        and b.del_flag = 0
        <if test="doctorId != null "> and a.doctor_id = #{doctorId}</if>
        <if test="hospitalId != null "> and a.hospital_id = #{hospitalId}</if>
        ORDER BY a.create_time desc
        limit 5
    </select>

    <select id="weekMonthPersonCount" resultType="com.ruoyi.system.domain.resp.WeekMonthPersonCountResp">
        select date_format(create_time, '%Y-%m-%d') createTime, count(*) count
        from
        <if test="weekMonth == 1 || weekMonth == null">
        (select * from t_record  where DATE_SUB(CURDATE(), INTERVAL 7 DAY) &lt;= date(create_time)) X
        </if>
        <if test="weekMonth == 2">
        (select * from t_record  where DATE_SUB(CURDATE(), INTERVAL 30 DAY) &lt;= date(create_time)) X
        </if>
        where X.status = '1'
        <if test="doctorId != null "> and X.doctor_id = #{doctorId}</if>
        <if test="hospitalId != null "> and X.hospital_id = #{hospitalId}</if>
        group by date_format(X.create_time, '%Y-%m-%d');
    </select>

    <select id="ageCount" resultType="com.ruoyi.system.domain.TPatient">
        SELECT
        DISTINCT(a.phone),a.id,a.age
        from t_patient a
        inner JOIN t_record b on a.id = b.patient_id
        where 1 = 1
        and a.del_flag = 0
        <if test="doctorId != null "> and b.doctor_id = #{doctorId}</if>
        <if test="hospitalId != null "> and b.hospital_id = #{hospitalId}</if>
    </select>

    <select id="weekMonthTimeCount" resultType="com.ruoyi.system.domain.resp.WeekMonthTimeResp">
        select date_format(create_time, '%H') createTime, count(*) count
        from
        <if test="weekMonth == 1 || weekMonth == null">
            (select * from t_record  where DATE_SUB(CURDATE(), INTERVAL 7 DAY) &lt;= date(create_time)) X
        </if>
        <if test="weekMonth == 2">
            (select * from t_record  where DATE_SUB(CURDATE(), INTERVAL 30 DAY) &lt;= date(create_time)) X
        </if>
        where X.status = '1'
        <if test="doctorId != null "> and X.doctor_id = #{doctorId}</if>
        <if test="hospitalId != null "> and X.hospital_id = #{hospitalId}</if>
        group by date_format(X.create_time, '%H');
    </select>
    <!--====================工作台相关接口=====================-->

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值