| | |
| | | COALESCE(NULLIF(TRIM(current_preachform), ''), TRIM(SUBSTRING_INDEX(preachform, ',', 1))) |
| | | </sql> |
| | | |
| | | <!-- 累计发送方式统计用:归一化 preachform 顺序(去空格、统一中文逗号) --> |
| | | <sql id="normalizedPreachformExpr"> |
| | | REPLACE(REPLACE(IFNULL(preachform, ''), ' ', ''), ',', ',') |
| | | </sql> |
| | | |
| | | <!-- 累计发送方式统计用:归一化后的有效 current_preachform(为空时取 preachform 第一个) --> |
| | | <sql id="normalizedEffectiveCurrentPreachformExpr"> |
| | | COALESCE(NULLIF(TRIM(current_preachform), ''), |
| | | TRIM(SUBSTRING_INDEX(<include refid="normalizedPreachformExpr"/>, ',', 1))) |
| | | </sql> |
| | | |
| | | <select id="selectServiceSubtaskBySendstate" parameterType="com.ruoyi.task.domain.entity.ServiceSubtaskEntity" |
| | | resultMap="ServiceSubtaskResult"> |
| | | <include refid="selectServiceSubtaskVo"/> |
| | |
| | | ), '%y%m%d' ) ) |
| | | THEN 1 ELSE 0 END ) finished,1 AS tasknumber FROM service_subtask |
| | | WHERE del_flag=0 |
| | | <if test="starttime == null and endtime==null"> |
| | | <!-- 只有未指定任何时间范围时才默认只统计已到期任务; |
| | | 只按出院时间查询时不能再排除未来 visit_time,否则及时率分母与主表不一致。 --> |
| | | <if test="starttime == null and endtime == null and startOutHospTime == null and endOutHospTime == null"> |
| | | AND visit_time < NOW() |
| | | </if> |
| | | <if test="starttime != null and endtime!=null"> |
| | |
| | | WHERE ss.del_flag = 0 |
| | | AND ss.visit_time IS NOT NULL |
| | | AND ss.sendstate != 4 |
| | | <if test="starttime == null and endtime==null"> |
| | | <!-- 只有未指定任何时间范围时才默认只统计已到期任务; |
| | | 只按出院时间查询时不能再排除未来 visit_time,否则及时率分母与主表不一致。 --> |
| | | <if test="starttime == null and endtime == null and startOutHospTime == null and endOutHospTime == null"> |
| | | AND DATE(ss.visit_time) < DATE(NOW()) |
| | | </if> |
| | | <if test="starttime != null and endtime!=null"> |
| | |
| | | where 1=1 |
| | | and a.del_flag = '0' |
| | | and b.del_flag = '0' |
| | | and a.appltype = '3' |
| | | <!-- 专病统计:单病种任务(appltype=3) + 专病任务组(appltype=5) --> |
| | | and ( |
| | | a.appltype = '3' |
| | | or ( |
| | | a.appltype = '5' |
| | | and ( |
| | | a.hosp_type = '3' |
| | | or (a.diag_type is not null and a.diag_type <> '') |
| | | or exists ( |
| | | select 1 |
| | | from service_task_schedule s |
| | | where s.taskid = a.taskid |
| | | and s.del_flag = '0' |
| | | and s.icd10_codes is not null |
| | | and s.icd10_codes <> '' |
| | | ) |
| | | ) |
| | | ) |
| | | ) |
| | | <if test="orgid != null and orgid != ''">and a.orgid = #{orgid}</if> |
| | | <if test="campusid != null and campusid != ''">and b.campusid = #{campusid}</if> |
| | | <if test="taskId != null">and a.task_id = #{taskId}</if> |
| | | <if test="taskId != null">and a.taskid = #{taskId}</if> |
| | | <if test="taskName != null and taskName != ''"> |
| | | and a.task_name like concat('%', #{taskName}, '%') |
| | | </if> |
| | |
| | | and a.diag_type = #{diagType} |
| | | </if> |
| | | <if test="taskIds != null and taskIds.size() > 0"> |
| | | AND a.task_id IN |
| | | AND a.taskid IN |
| | | <foreach collection="taskIds" item="taskIdItem" open="(" separator="," |
| | | close=")"> |
| | | #{taskIdItem} |
| | |
| | | </if> |
| | | <if test="currentPreachform != null and currentPreachform != '' "> |
| | | AND <include refid="effectiveCurrentPreachformExpr"/> = #{currentPreachform} |
| | | <if test="followUpCountStyle != null and followUpCountStyle = '1'"> |
| | | <!-- 注意:OGNL 里单引号 '1' 是 Character,String 与之用 = 比较会得到非 0 数字(恒真),必须用 =="1" --> |
| | | <if test='followUpCountStyle != null and followUpCountStyle == "1"'> |
| | | AND sendstate != 4 |
| | | </if> |
| | | <if test='followUpCountStyle != null and followUpCountStyle == "3"'> |
| | | AND sendstate = 6 |
| | | </if> |
| | | </if> |
| | | <!-- |
| | | 累计发送方式下钻: |
| | | preachform 是执行顺序(如 3,5,4,1),current_preachform 是当前执行到的位置。 |
| | | 若要在“语音”下钻,则 current 位于语音及之后的所有行都要返回。 |
| | | 以下条件与 ServiceSubtaskServiceImpl#applyFirstCumulativePreachformStatistics 口径一致: |
| | | current 为空 -> 按 preachform 第一个方式 |
| | | current = -1 -> 按最后一个位置(全部方式都进入过) |
| | | current 不在顺序中 -> 只做精确匹配兜底 |
| | | --> |
| | | <if test="cumulativePreachform != null and cumulativePreachform != ''"> |
| | | AND ( |
| | | CASE |
| | | WHEN <include refid="normalizedPreachformExpr"/> = '' THEN |
| | | <include refid="normalizedEffectiveCurrentPreachformExpr"/> = #{cumulativePreachform} |
| | | |
| | | WHEN <include refid="normalizedEffectiveCurrentPreachformExpr"/> = '-1' THEN |
| | | FIND_IN_SET(#{cumulativePreachform}, |
| | | <include refid="normalizedPreachformExpr"/>) > 0 |
| | | |
| | | WHEN FIND_IN_SET(<include refid="normalizedEffectiveCurrentPreachformExpr"/>, |
| | | <include refid="normalizedPreachformExpr"/>) = 0 THEN |
| | | <include refid="normalizedEffectiveCurrentPreachformExpr"/> = #{cumulativePreachform} |
| | | |
| | | ELSE |
| | | FIND_IN_SET(#{cumulativePreachform}, |
| | | <include refid="normalizedPreachformExpr"/>) > 0 |
| | | AND FIND_IN_SET(#{cumulativePreachform}, |
| | | <include refid="normalizedPreachformExpr"/>) |
| | | <= FIND_IN_SET(<include refid="normalizedEffectiveCurrentPreachformExpr"/>, |
| | | <include refid="normalizedPreachformExpr"/>) |
| | | END |
| | | ) |
| | | <if test='followUpCountStyle != null and followUpCountStyle == "1"'> |
| | | AND sendstate != 4 |
| | | </if> |
| | | <if test='followUpCountStyle != null and followUpCountStyle == "3"'> |
| | | AND sendstate = 6 |
| | | </if> |
| | | </if> |
| | | <if test="excep != null and excep != ''"> |
| | | AND excep = #{excep} |