Преглед на файлове

1、非医嘱离院人数
2、31日内再入院记录

zhaops преди 5 години
родител
ревизия
f656ff6896

+ 6 - 0
src/main/java/com/diagbot/aggregate/MrStatisticsAggregate.java

@@ -88,14 +88,20 @@ public class MrStatisticsAggregate {
         retMap.put("死亡人数", 0);
         retMap.put("新生儿人数", 0);
         retMap.put("手术病人数", 0);
+        retMap.put("非医嘱离院人数", 0);
+        retMap.put("31日内再入院人数", 0);
         Integer totleNum = behospitalInfoFacade.leaveHosCount(filterVO);
         Integer deathNum = behospitalInfoFacade.deathCount(filterVO);
         Integer newBornNum = behospitalInfoFacade.newBornCount(filterVO);
         Integer operationNum = behospitalInfoFacade.operationCount(filterVO);
+        Integer nonAdviceNum = behospitalInfoFacade.nonAdviceCount(filterVO);
+        Integer reBehospitalNum = behospitalInfoFacade.get31DaysBehospitalCount(filterVO);
         retMap.put("总人数", totleNum);
         retMap.put("死亡人数", deathNum);
         retMap.put("新生儿人数", newBornNum);
         retMap.put("手术病人数", operationNum);
+        retMap.put("非医嘱离院人数", nonAdviceNum);
+        retMap.put("31日内再入院人数", reBehospitalNum);
         return retMap;
     }
 

+ 16 - 0
src/main/java/com/diagbot/mapper/BehospitalInfoMapper.java

@@ -254,4 +254,20 @@ public interface BehospitalInfoMapper extends BaseMapper<BehospitalInfo> {
      * @return
      */
     public List<EntryStatisticsDTO> entryStatistics(EntryStatisticsVO entryStatisticsVO);
+
+    /**
+     * 非医嘱离院病人记录
+     *
+     * @param filterVO
+     * @return
+     */
+    public int nonAdviceCount(FilterVO filterVO);
+
+    /**
+     * 31天内再入院记录
+     *
+     * @param filterVO
+     * @return
+     */
+    public int get31DaysBehospitalCount(FilterVO filterVO);
 }

+ 16 - 0
src/main/java/com/diagbot/service/BehospitalInfoService.java

@@ -247,4 +247,20 @@ public interface BehospitalInfoService extends IService<BehospitalInfo> {
      * @return
      */
     public List<EntryStatisticsDTO> entryStatistics(EntryStatisticsVO entryStatisticsVO);
+
+    /**
+     * 非医嘱离院病人记录
+     *
+     * @param filterVO
+     * @return
+     */
+    public int nonAdviceCount(FilterVO filterVO);
+
+    /**
+     * 31天内再入院记录
+     *
+     * @param filterVO
+     * @return
+     */
+    public int get31DaysBehospitalCount(FilterVO filterVO);
 }

+ 22 - 0
src/main/java/com/diagbot/service/impl/BehospitalInfoServiceImpl.java

@@ -336,4 +336,26 @@ public class BehospitalInfoServiceImpl extends ServiceImpl<BehospitalInfoMapper,
     public List<EntryStatisticsDTO> entryStatistics(EntryStatisticsVO entryStatisticsVO) {
         return baseMapper.entryStatistics(entryStatisticsVO);
     }
+
+    /**
+     * 非医嘱离院病人记录
+     *
+     * @param filterVO
+     * @return
+     */
+    @Override
+    public int nonAdviceCount(FilterVO filterVO) {
+        return baseMapper.nonAdviceCount(filterVO);
+    }
+
+    /**
+     * 31天内再入院记录
+     *
+     * @param filterVO
+     * @return
+     */
+    @Override
+    public int get31DaysBehospitalCount(FilterVO filterVO) {
+        return baseMapper.get31DaysBehospitalCount(filterVO);
+    }
 }

+ 241 - 0
src/main/resources/mapper/BehospitalInfoMapper.xml

@@ -3387,4 +3387,245 @@
             </choose>
         </if>
     </select>
+
+    <!-- 非医嘱离院病人记录-->
+    <select id="nonAdviceCount" resultType="int" parameterType="com.diagbot.vo.FilterVO">
+        SELECT
+        count(*)
+        FROM
+        med_behospital_info a,
+        med_home_page b
+        WHERE
+        a.is_deleted = 'N'
+        AND b.is_deleted = 'N'
+        AND a.hospital_id = b.hospital_id
+        AND a.behospital_code = b.behospital_code
+        AND b.leave_hospital_type = '非医嘱离院'
+        AND a.is_placefile = '1'
+        AND a.qc_type_id != 0
+        <if test="hospitalId != null and hospitalId != ''">
+            AND a.hospital_id = #{hospitalId}
+        </if>
+        <if test="startDate != null">
+            <![CDATA[ AND a.leave_hospital_date >= DATE(#{startDate})]]>
+        </if>
+        <if test="endDate != null">
+            <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
+        </if>
+    </select>
+
+    <!-- 31天内再入院记录-->
+    <select id="get31DaysBehospitalCount" resultType="int" parameterType="com.diagbot.vo.FilterVO">
+        SELECT
+        count(*)
+        FROM
+        (
+        SELECT
+        bc1.file_code,
+        bc1.diagnose,
+        bc1.behospitalCode,
+        bc1.behospitalDate,
+        bc1.leaveHospitalDate
+        FROM
+        (
+        SELECT
+        t1.file_code,
+        t1.diagnose,
+        t1.behospital_code AS behospitalCode,
+        t1.leave_hospital_date AS leaveHospitalDate,
+        t2.behospital_code AS lastBehospitalCode,
+        t2.behospital_date AS lastBehospitalDate,
+        t1.behospital_date AS behospitalDate,
+        t2.leave_hospital_date AS lastLeaveHospitalDate
+        FROM
+        (
+        SELECT
+        tt1.file_code,
+        tt1.diagnose,
+        tt2.behospital_code,
+        tt2.behospital_date,
+        tt2.leave_hospital_date
+        FROM
+        (
+        SELECT
+        a.file_code,
+        a.diagnose
+        FROM
+        med_behospital_info a
+        WHERE
+        a.is_deleted = 'N'
+        AND a.is_placefile = '1'
+        AND a.qc_type_id != 0
+        <if test="hospitalId != null and hospitalId != ''">
+            AND a.hospital_id = #{hospitalId}
+        </if>
+        <if test="startDate != null">
+            <![CDATA[ AND a.leave_hospital_date >= DATE(#{startDate})]]>
+        </if>
+        <if test="endDate != null">
+            <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
+        </if>
+        AND IFNULL( a.diagnose, '' )!= ''
+        GROUP BY
+        a.file_code,
+        a.diagnose
+        HAVING
+        count(*)> 1
+        ) tt1,
+        med_behospital_info tt2
+        WHERE
+        tt2.is_deleted = 'N'
+        AND tt1.file_code = tt2.file_code
+        AND tt1.diagnose = tt2.diagnose
+        ORDER BY
+        tt1.file_code,
+        tt1.diagnose,
+        tt2.behospital_date DESC
+        ) t1,
+        (
+        SELECT
+        tt1.file_code,
+        tt1.diagnose,
+        tt2.behospital_code,
+        tt2.behospital_date,
+        tt2.leave_hospital_date
+        FROM
+        (
+        SELECT
+        a.file_code,
+        a.diagnose
+        FROM
+        med_behospital_info a
+        WHERE
+        a.is_deleted = 'N'
+        AND a.is_placefile = 1
+        AND a.qc_type_id != 0
+        AND a.hospital_id = 1
+        AND IFNULL( a.diagnose, '' )!= ''
+        GROUP BY
+        a.file_code,
+        a.diagnose
+        HAVING
+        count(*)> 1
+        ) tt1,
+        med_behospital_info tt2
+        WHERE
+        tt2.is_deleted = 'N'
+        AND tt1.file_code = tt2.file_code
+        AND tt1.diagnose = tt2.diagnose
+        ORDER BY
+        tt1.file_code,
+        tt1.diagnose,
+        tt2.behospital_date DESC
+        ) t2
+        WHERE
+        t1.file_code = t2.file_code
+        AND t1.diagnose = t2.diagnose
+        AND t1.behospital_code != t2.behospital_code
+        AND ( TIMESTAMPDIFF( DAY, DATE( t2.leave_hospital_date ), DATE( t1.behospital_date )) BETWEEN 0 AND 31 )) bc1 UNION
+        SELECT
+        bc2.file_code,
+        bc2.diagnose,
+        bc2.lastBehospitalCode,
+        bc2.lastBehospitalDate,
+        bc2.lastLeaveHospitalDate
+        FROM
+        (
+        SELECT
+        t1.file_code,
+        t1.diagnose,
+        t1.behospital_code AS behospitalCode,
+        t1.leave_hospital_date AS leaveHospitalDate,
+        t2.behospital_code AS lastBehospitalCode,
+        t2.behospital_date AS lastBehospitalDate,
+        t1.behospital_date AS behospitalDate,
+        t2.leave_hospital_date AS lastLeaveHospitalDate
+        FROM
+        (
+        SELECT
+        tt1.file_code,
+        tt1.diagnose,
+        tt2.behospital_code,
+        tt2.behospital_date,
+        tt2.leave_hospital_date
+        FROM
+        (
+        SELECT
+        a.file_code,
+        a.diagnose
+        FROM
+        med_behospital_info a
+        WHERE
+        a.is_deleted = 'N'
+        AND a.is_placefile = '1'
+        AND a.qc_type_id != 0
+        <if test="hospitalId != null and hospitalId != ''">
+            AND a.hospital_id = #{hospitalId}
+        </if>
+        <if test="startDate != null">
+            <![CDATA[ AND a.leave_hospital_date >= DATE(#{startDate})]]>
+        </if>
+        <if test="endDate != null">
+            <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
+        </if>
+        AND IFNULL( a.diagnose, '' )!= ''
+        GROUP BY
+        a.file_code,
+        a.diagnose
+        HAVING
+        count(*)> 1
+        ) tt1,
+        med_behospital_info tt2
+        WHERE
+        tt2.is_deleted = 'N'
+        AND tt1.file_code = tt2.file_code
+        AND tt1.diagnose = tt2.diagnose
+        ORDER BY
+        tt1.file_code,
+        tt1.diagnose,
+        tt2.behospital_date DESC
+        ) t1,
+        (
+        SELECT
+        tt1.file_code,
+        tt1.diagnose,
+        tt2.behospital_code,
+        tt2.behospital_date,
+        tt2.leave_hospital_date
+        FROM
+        (
+        SELECT
+        a.file_code,
+        a.diagnose
+        FROM
+        med_behospital_info a
+        WHERE
+        a.is_deleted = 'N'
+        AND a.is_placefile = 1
+        AND a.qc_type_id != 0
+        AND a.hospital_id = 1
+        AND IFNULL( a.diagnose, '' )!= ''
+        GROUP BY
+        a.file_code,
+        a.diagnose
+        HAVING
+        count(*)> 1
+        ) tt1,
+        med_behospital_info tt2
+        WHERE
+        tt2.is_deleted = 'N'
+        AND tt1.file_code = tt2.file_code
+        AND tt1.diagnose = tt2.diagnose
+        ORDER BY
+        tt1.file_code,
+        tt1.diagnose,
+        tt2.behospital_date DESC
+        ) t2
+        WHERE
+        t1.file_code = t2.file_code
+        AND t1.diagnose = t2.diagnose
+        AND t1.behospital_code != t2.behospital_code
+        AND ( TIMESTAMPDIFF( DAY, DATE( t2.leave_hospital_date ), DATE( t1.behospital_date )) BETWEEN 0 AND 31 )) bc2
+        ) t
+    </select>
 </mapper>