From 48a112a2718cefda8d9a80420dba780171b06d3e Mon Sep 17 00:00:00 2001
From: 陈昶聿 <chychen@nbjetron.com>
Date: 星期二, 14 四月 2026 17:32:40 +0800
Subject: [PATCH] 【景宁】再次随访的随访任务做完,首次的随访任务的完成时间也变成再次随访的完成时间
---
smartor/src/main/resources/mapper/smartor/PatMedInhospMapper.xml | 219 +++++++++++++++---------------------------------------
1 files changed, 63 insertions(+), 156 deletions(-)
diff --git a/smartor/src/main/resources/mapper/smartor/PatMedInhospMapper.xml b/smartor/src/main/resources/mapper/smartor/PatMedInhospMapper.xml
index d6a5473..24f8484 100644
--- a/smartor/src/main/resources/mapper/smartor/PatMedInhospMapper.xml
+++ b/smartor/src/main/resources/mapper/smartor/PatMedInhospMapper.xml
@@ -854,167 +854,74 @@
<select id="selectPatMedInhospCount" parameterType="com.smartor.domain.PatMedReq"
resultType="com.smartor.domain.PatMedRes">
- SELECT SUM( rs ) AS rs,
- SUM( rc ) AS rc,
- SUM( scsf ) AS scsf,
- SUM( zcsf ) AS zcsf,
- SUM( zbsf ) AS zbsf
+ SELECT SUM(rc) AS rc,
+ SUM(rs) AS rs,
+ SUM(scsf) AS scsf,
+ SUM(zcsf) AS zcsf,
+ SUM(zbsf) AS zbsf
FROM (
- <!-- 鍑洪櫌浜烘-->
- SELECT
- COUNT(1) AS rc,
- 0 AS rs,
- 0 AS scsf,
- 0 AS zcsf,
- 0 AS zbsf
- FROM
- pat_med_inhosp
- JOIN
- pat_archive ON pat_archive.id = pat_med_inhosp.patid
- where 1=1
- and pat_med_inhosp.del_flag=0
- <if test="orgid != null and orgid != ''">
- and pat_med_inhosp.orgid = #{orgid}
- </if>
- AND pat_archive.idcardno IS NOT NULL
- <if test="zy != null">
- and pat_med_inhosp.inhospstate=0
- and date_format(pat_med_inhosp.starttime,'%y%m%d') >= date_format(#{startDate},'%y%m%d')
- and date_format(pat_med_inhosp.starttime,'%y%m%d') <= date_format(#{endDate},'%y%m%d')
- <if test="deptcodeList != null and deptcodeList.size() > 0">
- and pat_med_inhosp.deptcode in
+ <!-- 鍑洪櫌浜烘锛氬幓鎺� date_format 鍖呰锛屼娇鏃ユ湡瀛楁绱㈠紩鐢熸晥 -->
+ SELECT
+ COUNT(1) AS rc,
+ 0 AS rs,
+ 0 AS scsf,
+ 0 AS zcsf,
+ 0 AS zbsf
+ FROM pat_med_inhosp
+ JOIN pat_archive ON pat_archive.id = pat_med_inhosp.patid
+ WHERE pat_med_inhosp.del_flag = 0
+ <if test="orgid != null and orgid != ''">
+ AND pat_med_inhosp.orgid = #{orgid}
+ </if>
+ AND pat_archive.idcardno IS NOT NULL
+ <if test="zy != null">
+ AND pat_med_inhosp.inhospstate = 0
+ AND pat_med_inhosp.starttime >= #{startDate}
+ AND pat_med_inhosp.starttime < DATE_ADD(#{endDate}, INTERVAL 1 DAY)
+ <if test="deptcodeList != null and deptcodeList.size() > 0">
+ AND pat_med_inhosp.deptcode IN
+ <foreach collection="deptcodeList" item="deptcode" open="(" separator="," close=")">
+ #{deptcode}
+ </foreach>
+ </if>
+ </if>
+ <if test="cy != null">
+ AND pat_med_inhosp.inhospstate = 1
+ AND pat_med_inhosp.endtime >= #{startDate}
+ AND pat_med_inhosp.endtime < DATE_ADD(#{endDate}, INTERVAL 1 DAY)
+ <if test="deptcodeList != null and deptcodeList.size() > 0">
+ AND pat_med_inhosp.leaveldeptcode IN
+ <foreach collection="deptcodeList" item="deptcode" open="(" separator="," close=")">
+ #{deptcode}
+ </foreach>
+ </if>
+ </if>
+ UNION ALL
+ <!-- 闅忚鏈嶅姟/棣栨/鍐嶆/涓撶梾闅忚锛氬悎骞朵负鍗曟鎵弿锛岀敤鏉′欢鑱氬悎浠f浛4涓� UNION ALL -->
+ SELECT
+ 0 AS rc,
+ COUNT(1) AS rs,
+ SUM(CASE WHEN service_type = 2 AND visit_count = 1 THEN 1 ELSE 0 END) AS scsf,
+ SUM(CASE WHEN service_type = 2 AND visit_count > 1 THEN 1 ELSE 0 END) AS zcsf,
+ SUM(CASE WHEN service_type = 13 THEN 1 ELSE 0 END) AS zbsf
+ FROM service_subtask
+ WHERE del_flag = 0
+ AND service_type IN (2, 13)
+ <if test="orgid != null and orgid != ''">
+ AND orgid = #{orgid}
+ </if>
+ <if test="startDate != null">
+ AND visit_time >= #{startDate}
+ </if>
+ <if test="endDate != null">
+ AND visit_time < DATE_ADD(#{endDate}, INTERVAL 1 DAY)
+ </if>
+ <if test="deptcodeList != null and deptcodeList.size() > 0">
+ AND deptcode IN
<foreach collection="deptcodeList" item="deptcode" open="(" separator="," close=")">
#{deptcode}
</foreach>
</if>
- </if>
- <if test="cy != null">
- and pat_med_inhosp.inhospstate=1
- and date_format(pat_med_inhosp.endtime,'%y%m%d') >= date_format(#{startDate},'%y%m%d')
- and date_format(pat_med_inhosp.endtime,'%y%m%d') <= date_format(#{endDate},'%y%m%d')
- <if test="deptcodeList != null and deptcodeList.size() > 0">
- and pat_med_inhosp.leaveldeptcode in
- <foreach collection="deptcodeList" item="deptcode" open="(" separator="," close=")">
- #{deptcode}
- </foreach>
- </if>
- </if>
- <!-- 闅忚鏈嶅姟浜烘暟 -->
- union all
- select
- 0 AS rc,
- count(1) AS rs,
- 0 AS scsf,
- 0 AS zcsf,
- 0 AS zbsf
- FROM
- service_subtask
- where 1=1
- and del_flag = 0
- and service_type=2
- <if test="orgid != null and orgid != ''">
- and orgid = #{orgid}
- </if>
- <if test="startDate != null">
- AND date_format( visit_time, '%y%m%d' ) >= date_format( #{startDate}, '%y%m%d' )
- </if>
- <if test="endDate != null">
- AND date_format( visit_time, '%y%m%d' ) <= date_format(#{endDate},'%y%m%d')
- </if>
- <if test="deptcodeList != null and deptcodeList.size() > 0">
- and deptcode in
- <foreach collection="deptcodeList" item="deptcode" open="(" separator="," close=")">
- #{deptcode}
- </foreach>
- </if>
- <!-- 棣栨闅忚浜烘暟 -->
- union all
- select
- 0 AS rc,
- 0 AS rs,
- count(1) AS scsf,
- 0 AS zcsf,
- 0 AS zbsf
- FROM
- service_subtask
- where 1=1
- and del_flag = 0
- and service_type=2
- and visit_count is not null
- and visit_count = 1
- <if test="orgid != null and orgid != ''">
- and orgid = #{orgid}
- </if>
- <if test="startDate != null">
- AND date_format( visit_time, '%y%m%d' ) >= date_format( #{startDate}, '%y%m%d' )
- </if>
- <if test="endDate != null">
- AND date_format( visit_time, '%y%m%d' ) <= date_format(#{endDate},'%y%m%d')
- </if>
- <if test="deptcodeList != null and deptcodeList.size() > 0">
- and deptcode in
- <foreach collection="deptcodeList" item="deptcode" open="(" separator="," close=")">
- #{deptcode}
- </foreach>
- </if>
- <!-- 鍐嶆闅忚浜烘暟 -->
- union all
- select
- 0 AS rc,
- 0 AS rs,
- 0 AS scsf,
- count(1) AS zcsf,
- 0 AS zbsf
- FROM
- service_subtask
- where 1=1
- and del_flag = 0
- and service_type=2
- and visit_count is not null
- and visit_count > 1
- <if test="orgid != null and orgid != ''">
- and orgid = #{orgid}
- </if>
- <if test="startDate != null">
- AND date_format( visit_time, '%y%m%d' ) >= date_format( #{startDate}, '%y%m%d' )
- </if>
- <if test="endDate != null">
- AND date_format( visit_time, '%y%m%d' ) <= date_format(#{endDate},'%y%m%d')
- </if>
- <if test="deptcodeList != null and deptcodeList.size() > 0">
- and deptcode in
- <foreach collection="deptcodeList" item="deptcode" open="(" separator="," close=")">
- #{deptcode}
- </foreach>
- </if>
- <!-- 涓撶梾闅忚浜烘暟 -->
- union all
- select
- 0 AS rc,
- 0 AS rs,
- 0 AS scsf,
- 0 AS zcsf,
- count(1) AS zbsf
- FROM
- service_subtask
- where 1=1
- and del_flag = 0
- and service_type=13
- <if test="orgid != null and orgid != ''">
- and orgid = #{orgid}
- </if>
- <if test="startDate != null">
- AND date_format( visit_time, '%y%m%d' ) >= date_format( #{startDate}, '%y%m%d' )
- </if>
- <if test="endDate != null">
- AND date_format( visit_time, '%y%m%d' ) <= date_format(#{endDate},'%y%m%d')
- </if>
- <if test="deptcodeList != null and deptcodeList.size() > 0">
- and deptcode in
- <foreach collection="deptcodeList" item="deptcode" open="(" separator="," close=")">
- #{deptcode}
- </foreach>
- </if>
) AS combined_data
</select>
--
Gitblit v1.9.3