| | |
| | | <result property="senduuid" column="senduuid"/> |
| | | <result property="result" column="result"/> |
| | | <result property="finishtime" column="finishtime"/> |
| | | <result property="finishState" column="finish_state"/> |
| | | <result property="recordid" column="recordid"/> |
| | | <result property="exrecallcount" column="exrecallcount"/> |
| | | <result property="pulltime" column="pulltime"/> |
| | |
| | | <result property="leavehospitaldistrictname" column="leavehospitaldistrictname"/> |
| | | <result property="excep" column="excep"/> |
| | | <result property="remark" column="remark"/> |
| | | <result property="doctorOpinion" column="doctor_opinion"/> |
| | | <result property="suggest" column="suggest"/> |
| | | <result property="sendstate" column="sendstate"/> |
| | | <result property="inhospid" column="inhospid"/> |
| | |
| | | long_send_time, |
| | | openid, |
| | | remark, |
| | | doctor_opinion, |
| | | service_type, |
| | | libtemplateid, |
| | | libtemplatename, |
| | |
| | | senduuid, |
| | | result, |
| | | finishtime, |
| | | finish_state, |
| | | recordid, |
| | | exrecallcount, |
| | | pulltime, |
| | |
| | | task_situation, |
| | | is_manually_called |
| | | from service_subtask |
| | | </sql> |
| | | |
| | | <!-- 超时完成、延期完成逻辑 完成时状态(finish_state)计算:仅当本次更新把 sendstate 置为 6(随访完成)时使用。 |
| | | 基准截止时间 base = endtime + send_day(缺省1) + (Σ service_subtask_preachform.compensate_time + 1) 天, |
| | | 与 RyTask/RedisMqReceiver 的 isSubtaskDeadline 口径保持一致; |
| | | delay = COALESCE(service_task.delay_finish_days, 0); |
| | | finish_time = COALESCE(入参 finishtime, 库中 finishtime, NOW()): |
| | | finish_time <= base -> 1 正常完成 |
| | | delay > 0 且 finish_time <= base + delay -> 2 延期完成 |
| | | 其余(含 delay 为 0 或 NULL、或已超出延期窗口) -> 3 超时完成 |
| | | finishtime 为空时用 NOW() 兜底,保证完成时一定写入状态; |
| | | 仅当 endtime 为空导致无法计算时才保持原值不覆盖。 --> |
| | | <sql id="finishStateExpr"> |
| | | CASE |
| | | WHEN service_subtask.endtime IS NULL THEN finish_state |
| | | WHEN COALESCE(#{finishtime,jdbcType=TIMESTAMP}, service_subtask.finishtime, NOW()) |
| | | <= DATE_ADD( |
| | | DATE_ADD( |
| | | service_subtask.endtime, |
| | | INTERVAL COALESCE((SELECT st.send_day FROM service_task st |
| | | WHERE st.taskid = service_subtask.taskid AND st.del_flag = '0' LIMIT 1), 1) DAY |
| | | ), |
| | | INTERVAL (COALESCE((SELECT SUM(CAST(COALESCE(NULLIF(TRIM(pf.compensate_time), ''), '0') AS SIGNED)) |
| | | FROM service_subtask_preachform pf |
| | | WHERE pf.subid = service_subtask.id AND pf.del_flag = 0), 0) + 1) DAY |
| | | ) |
| | | THEN 1 |
| | | WHEN COALESCE((SELECT st.delay_finish_days FROM service_task st |
| | | WHERE st.taskid = service_subtask.taskid AND st.del_flag = '0' LIMIT 1), 0) > 0 |
| | | AND COALESCE(#{finishtime,jdbcType=TIMESTAMP}, service_subtask.finishtime, NOW()) |
| | | <= DATE_ADD( |
| | | DATE_ADD( |
| | | DATE_ADD( |
| | | service_subtask.endtime, |
| | | INTERVAL COALESCE((SELECT st.send_day FROM service_task st |
| | | WHERE st.taskid = service_subtask.taskid AND st.del_flag = '0' LIMIT 1), 1) DAY |
| | | ), |
| | | INTERVAL (COALESCE((SELECT SUM(CAST(COALESCE(NULLIF(TRIM(pf.compensate_time), ''), '0') AS SIGNED)) |
| | | FROM service_subtask_preachform pf |
| | | WHERE pf.subid = service_subtask.id AND pf.del_flag = 0), 0) + 1) DAY |
| | | ), |
| | | INTERVAL COALESCE((SELECT st.delay_finish_days FROM service_task st |
| | | WHERE st.taskid = service_subtask.taskid AND st.del_flag = '0' LIMIT 1), 0) DAY |
| | | ) |
| | | THEN 2 |
| | | ELSE 3 |
| | | END |
| | | </sql> |
| | | |
| | | <select id="selectServiceSubtaskBySendstate" parameterType="com.smartor.domain.entity.ServiceSubtaskEntity" |
| | |
| | | AND visit_count > 1 |
| | | </if> |
| | | <if test="remark != null">and remark = #{remark}</if> |
| | | <if test="doctorOpinion != null and doctorOpinion != ''">and doctor_opinion like concat('%', #{doctorOpinion}, '%')</if> |
| | | <if test="suggest != null">and suggest = #{suggest}</if> |
| | | <if test="createBy != null">and create_by = #{createBy}</if> |
| | | <if test="taskGuid != null">and task_guid = #{taskGuid}</if> |
| | |
| | | <if test="senduuid != null">senduuid,</if> |
| | | <if test="result != null">result,</if> |
| | | <if test="finishtime != null">finishtime,</if> |
| | | <if test="finishState != null">finish_state,</if> |
| | | <if test="recordid != null">recordid,</if> |
| | | <if test="exrecallcount != null">exrecallcount,</if> |
| | | <if test="pulltime != null">pulltime,</if> |
| | |
| | | <if test="nurseName != null ">nurse_name,</if> |
| | | <if test="nurseId != null ">nurse_id,</if> |
| | | <if test="remark != null ">remark,</if> |
| | | <if test="doctorOpinion != null ">doctor_opinion,</if> |
| | | <if test="suggest != null ">suggest,</if> |
| | | <if test="sendstate != null ">sendstate,</if> |
| | | <if test="inhospid != null ">inhospid,</if> |
| | |
| | | <if test="senduuid != null">#{senduuid},</if> |
| | | <if test="result != null">#{result},</if> |
| | | <if test="finishtime != null">#{finishtime},</if> |
| | | <if test="finishState != null">#{finishState},</if> |
| | | <if test="recordid != null">#{recordid},</if> |
| | | <if test="exrecallcount != null">#{exrecallcount},</if> |
| | | <if test="pulltime != null">#{pulltime},</if> |
| | |
| | | <if test="nurseName != null ">#{nurseName},</if> |
| | | <if test="nurseId != null ">#{nurseId},</if> |
| | | <if test="remark != null ">#{remark},</if> |
| | | <if test="doctorOpinion != null ">#{doctorOpinion},</if> |
| | | <if test="suggest != null ">#{suggest},</if> |
| | | <if test="sendstate != null ">#{sendstate},</if> |
| | | <if test="inhospid != null ">#{inhospid},</if> |
| | |
| | | <if test="isManuallyCalled != null ">#{isManuallyCalled},</if> |
| | | </trim> |
| | | </insert> |
| | | |
| | | <!-- 二次随访幂等:仅当 is_visit_again 不是目标值时更新,返回受影响行数 --> |
| | | <update id="updateIsVisitAgainById"> |
| | | update service_subtask |
| | | set is_visit_again = #{isVisitAgain}, |
| | | update_time = now() |
| | | where id = #{id} |
| | | and (is_visit_again is null or is_visit_again <> #{isVisitAgain}) |
| | | </update> |
| | | |
| | | <update id="updateServiceSubtask" parameterType="com.smartor.domain.ServiceSubtask"> |
| | | update service_subtask |
| | |
| | | <if test="openid != null ">openid = #{openid},</if> |
| | | <if test="longSendTime != null ">long_send_time = #{longSendTime},</if> |
| | | <if test="sendstate != null ">sendstate = #{sendstate},</if> |
| | | <if test="sendstate != null and sendstate == 6">finish_state = <include refid="finishStateExpr"/>,</if> |
| | | <if test="serviceType != null ">service_type = #{serviceType},</if> |
| | | <if test="score != null ">score = #{score},</if> |
| | | <if test="submit != null ">submit = #{submit},</if> |
| | |
| | | <if test="nurseName != null ">nurse_name=#{nurseName},</if> |
| | | <if test="nurseId != null ">nurse_id=#{nurseId},</if> |
| | | <if test="remark != null ">remark=#{remark},</if> |
| | | <if test="doctorOpinion != null ">doctor_opinion=#{doctorOpinion},</if> |
| | | <if test="suggest != null ">suggest=#{suggest},</if> |
| | | <if test="inhospid != null ">inhospid=#{inhospid},</if> |
| | | <if test="patfrom != null ">patfrom=#{patfrom},</if> |
| | |
| | | <if test="openid != null ">openid = #{openid},</if> |
| | | <if test="longSendTime != null ">long_send_time = #{longSendTime},</if> |
| | | <if test="sendstate != null ">sendstate = #{sendstate},</if> |
| | | <if test="sendstate != null and sendstate == 6">finish_state = <include refid="finishStateExpr"/>,</if> |
| | | <if test="serviceType != null ">service_type = #{serviceType},</if> |
| | | <if test="score != null ">score = #{score},</if> |
| | | <if test="visitCount != null ">visit_count = #{visitCount},</if> |
| | |
| | | <if test="nurseName != null ">nurse_name=#{nurseName},</if> |
| | | <if test="nurseId != null ">nurse_id=#{nurseId},</if> |
| | | <if test="remark != null ">remark=#{remark},</if> |
| | | <if test="doctorOpinion != null ">doctor_opinion=#{doctorOpinion},</if> |
| | | <if test="suggest != null ">suggest=#{suggest},</if> |
| | | <if test="inhospid != null ">inhospid=#{inhospid},</if> |
| | | <if test="patfrom != null ">patfrom=#{patfrom},</if> |
| | |
| | | <if test="sex != null">sex = #{sex},</if> |
| | | <if test="delFlag != null">del_flag = #{delFlag},</if> |
| | | <if test="sendstate != null ">sendstate = #{sendstate},</if> |
| | | <if test="sendstate != null and sendstate == 6">finish_state = <include refid="finishStateExpr"/>,</if> |
| | | <if test="age != null">age = #{age},</if> |
| | | <if test="sfzh != null">sfzh = #{sfzh},</if> |
| | | <if test="addr != null">addr = #{addr},</if> |
| | |
| | | <if test="nurseName != null ">nurse_name=#{nurseName},</if> |
| | | <if test="nurseId != null ">nurse_id=#{nurseId},</if> |
| | | <if test="remark != null ">remark=#{remark},</if> |
| | | <if test="doctorOpinion != null ">doctor_opinion=#{doctorOpinion},</if> |
| | | <if test="suggest != null ">suggest=#{suggest},</if> |
| | | <if test="inhospid != null ">inhospid=#{inhospid},</if> |
| | | <if test="patfrom != null ">patfrom=#{patfrom},</if> |
| | |
| | | <if test="phone != null">phone = #{phone},</if> |
| | | <if test="sex != null">sex = #{sex},</if> |
| | | <if test="sendstate != null ">sendstate = #{sendstate},</if> |
| | | <if test="sendstate != null and sendstate == 6">finish_state = <include refid="finishStateExpr"/>,</if> |
| | | <if test="age != null">age = #{age},</if> |
| | | <if test="sfzh != null">sfzh = #{sfzh},</if> |
| | | <if test="addr != null">addr = #{addr},</if> |
| | |
| | | <if test="nurseName != null ">nurse_name=#{nurseName},</if> |
| | | <if test="nurseId != null ">nurse_id=#{nurseId},</if> |
| | | <if test="remark != null ">remark=#{remark},</if> |
| | | <if test="doctorOpinion != null ">doctor_opinion=#{doctorOpinion},</if> |
| | | <if test="suggest != null ">suggest=#{suggest},</if> |
| | | <if test="inhospid != null ">inhospid=#{inhospid},</if> |
| | | <if test="patfrom != null ">patfrom=#{patfrom},</if> |
| | |
| | | continue_count, |
| | | continue_time_next, |
| | | task_situation, |
| | | finish_state, |
| | | is_manually_called |
| | | from service_subtask |
| | | where 1=1 |
| | |
| | | continue_time_next, |
| | | task_situation, |
| | | remark, |
| | | doctor_opinion, |
| | | finish_state, |
| | | is_manually_called |
| | | from service_subtask |
| | | where 1=1 |
| | |
| | | <if test="startTime != null and endTime!=null"> |
| | | AND visit_time >= DATE(#{startTime}) |
| | | AND visit_time < DATE_ADD(DATE(#{endTime}), INTERVAL 1 DAY) |
| | | </if> |
| | | <if test="hospitalStartTime != null and hospitalEndTime!=null"> |
| | | AND endtime >= DATE(#{hospitalStartTime}) |
| | | AND endtime < DATE_ADD(DATE(#{hospitalEndTime}), INTERVAL 1 DAY) |
| | | </if> |
| | | <if test="visitDeptCode != null">and visit_dept_code = #{visitDeptCode}</if> |
| | | <if test="visitDeptName != null">and visit_dept_name = #{visitDeptName}</if> |
| | |
| | | </if> |
| | | <if test="taskSituation != null"> |
| | | AND task_situation = #{taskSituation} |
| | | </if> |
| | | <if test="finishState != null"> |
| | | AND finish_state = #{finishState} |
| | | </if> |
| | | <if test="drcode != null and drcode != ''"> |
| | | AND drcode = #{drcode} |
| | |
| | | nurse_id, |
| | | nurse_name, |
| | | remark, |
| | | doctor_opinion, |
| | | inhospid, |
| | | patfrom, |
| | | task_guid, |
| | |
| | | continue_count, |
| | | continue_time_next, |
| | | task_situation, |
| | | remark |
| | | remark, |
| | | doctor_opinion |
| | | from service_subtask |
| | | where 1=1 |
| | | and del_flag = 0 |