|
|
@@ -339,8 +339,14 @@
|
|
|
fd.dept_id,
|
|
|
fd.hospital_id,
|
|
|
fd.group_code,
|
|
|
+ -- 平均操作时长
|
|
|
AVG(fp.operate_second) AS avgOperateSecond,
|
|
|
+ -- 操作次数 (等于总处方数)
|
|
|
COUNT(*) as operation,
|
|
|
+ -- 开方数量
|
|
|
+ COUNT(DISTINCT fp.prescribe_code) as prescribeNum,
|
|
|
+ -- 拒方率计算
|
|
|
+ ROUND(COUNT(CASE WHEN fp.status = 2 THEN 1 END) * 1.0 / COUNT(*), 4) AS rejectRate,
|
|
|
de.dept_name,
|
|
|
ho.hospital_name
|
|
|
FROM fs_prescribe fp
|
|
|
@@ -363,11 +369,19 @@
|
|
|
<if test="hospitalId != null and hospitalId != ''">
|
|
|
AND ho.hospital_id = #{hospitalId}
|
|
|
</if>
|
|
|
- <if test="startOperateTime != null">
|
|
|
- AND fp.start_operate_time >= #{startOperateTime}
|
|
|
+ <!-- 日期范围筛选 -->
|
|
|
+ <if test="!(queryYear != null and queryMonth != null) and startOperateTime != null">
|
|
|
+ AND fp.start_operate_time >= #{startOperateTime}
|
|
|
</if>
|
|
|
- <if test="endOperateTime != null">
|
|
|
- AND fp.end_operate_time <= #{endOperateTime}
|
|
|
+ <if test="!(queryYear != null and queryMonth != null) and endOperateTime != null">
|
|
|
+ AND fp.end_operate_time <= #{endOperateTime}
|
|
|
+ </if>
|
|
|
+ <!-- 新增:月度筛选条件 -->
|
|
|
+ <if test="queryYear != null">
|
|
|
+ AND YEAR(fp.start_operate_time) = #{queryYear}
|
|
|
+ </if>
|
|
|
+ <if test="queryMonth != null">
|
|
|
+ AND MONTH(fp.start_operate_time) = #{queryMonth}
|
|
|
</if>
|
|
|
|
|
|
GROUP BY
|
|
|
@@ -375,9 +389,22 @@
|
|
|
fd.doctor_name,
|
|
|
fd.dept_id,
|
|
|
fd.hospital_id
|
|
|
-
|
|
|
+ <if test="minRejectRate != null or maxRejectRate != null">
|
|
|
+ HAVING 1=1
|
|
|
+ </if>
|
|
|
+ <if test="minRejectRate != null">
|
|
|
+ AND ROUND(COUNT(CASE WHEN fp.status = 2 THEN 1 END) * 1.0 / COUNT(*), 4) >= #{minRejectRate}
|
|
|
+ </if>
|
|
|
+ <if test="maxRejectRate != null">
|
|
|
+ AND ROUND(COUNT(CASE WHEN fp.status = 2 THEN 1 END) * 1.0 / COUNT(*), 4) <= #{maxRejectRate}
|
|
|
+ </if>
|
|
|
ORDER BY
|
|
|
- avgOperateSecond
|
|
|
+ <choose>
|
|
|
+ <when test="orderByColumn == 'prescribeNum' or orderByColumn == 'operation'">prescribeNum</when>
|
|
|
+ <when test="orderByColumn == 'rejectRate'">rejectRate</when>
|
|
|
+ <!-- 默认排序字段 -->
|
|
|
+ <otherwise>avgOperateSecond</otherwise>
|
|
|
+ </choose>
|
|
|
<choose>
|
|
|
<when test="sort != null and sort == 'desc'">DESC</when>
|
|
|
<otherwise>ASC</otherwise>
|