Browse Source

报表病案首页合格率占比、各模块缺陷占比、条目缺陷占比sql调整

chengyao 3 years ago
parent
commit
dfe19d9d43

+ 0 - 7
dblayer-mbg/src/main/java/com/lantone/dblayermbg/mapper/report/QcresultInfoMapper.java

@@ -62,13 +62,6 @@ public interface QcresultInfoMapper extends BaseMapper<QcresultInfo> {
      */
     public Integer entryGroupByEntrySum(@Param("hospitalId") String hospitalId, @Param("isPlacefile") String isPlacefile, @Param("startDate") String startDate, @Param("endDate") String endDate);
 
-    /**
-     * 条目缺陷分值统计(内页)
-     *
-     * @return
-     */
-    public List<EntryNumDTO> entryGroupByEntryScore(@Param("hospitalId") String hospitalId, @Param("isPlacefile") String isPlacefile, @Param("ids") Set<Long> ids);
-
     /**
      * 质控病历数统计
      *

+ 38 - 110
dblayer-mbg/src/main/resources/mapper/report/BehospitalInfoMapper.xml

@@ -2403,40 +2403,39 @@
         t1.averageValue,
         t1.firstLevelNum,
         t1.secondLevelNum,
-        t1.firstLevelPercent,
-        t1.secondLevelPercent,
-        t1.firstLevelPercentStr,
-        t1.secondLevelPercentStr,
-        t3.emptyNum,
-        t3.errorNum,
-        t3.entryTotleNum,
-        t3.emptyPercent,
-        t3.errorPercent,
-        t3.emptyPercentStr,
-        t3.errorPercentStr
+        ROUND( t1.firstLevelNum/ t1.mrNum, 4 ) AS firstLevelPercent,
+        ROUND( t1.secondLevelNum/ t1.mrNum, 4 ) AS secondLevelPercent,
+        concat( ROUND( t1.firstLevelNum/t1.mrNum* 100, 2 ),'%' ) AS firstLevelPercentStr,
+        concat( ROUND( t1.secondLevelNum/t1.mrNum* 100, 2 ),'%' ) AS secondLevelPercentStr,
+        t2.emptyNum,
+        t2.errorNum,
+        t2.entryTotleNum,
+        t2.emptyPercent,
+        t2.errorPercent,
+        t2.emptyPercentStr,
+        t2.errorPercentStr
         FROM
         (
         SELECT
+        m1.deptId,
+        m1.deptName,
+        count(m1.behospital_code) AS mrNum,
+        ROUND( sum( CAST( m1.home_page_score AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
+        ROUND( avg( CAST( m1.home_page_score AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
+        SUM( m1.`home_page_level` = '合格' ) AS firstLevelNum,
+        SUM( m1.`home_page_level` = '不合格' ) AS secondLevelNum
+        from(
+        SELECT DISTINCT
         a.beh_dept_id AS deptId,
         a.beh_dept_name AS deptName,
-        count( * ) AS mrNum,
-        ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
-        ROUND( avg( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
-        SUM( c.`level` = '合格' ) AS firstLevelNum,
-        SUM( c.`level` = '不合格' ) AS secondLevelNum,
-        ROUND( SUM( c.`level` = '合格' )/ count( * ), 4 ) AS firstLevelPercent,
-        ROUND( SUM( c.`level` = '不合格' )/ count( * ), 4 ) AS secondLevelPercent,
-        concat( ROUND( SUM( c.`level` = '合格' )/ count( * )* 100, 2 ),'%' ) AS firstLevelPercentStr,
-        concat( ROUND( SUM( c.`level` = '不合格' )/ count( * )* 100, 2 ),'%' ) AS secondLevelPercentStr
+        a.behospital_code,
+        a.home_page_score,
+        a.home_page_level
         FROM
-        med_behospital_info a,
-        med_qcresult_cases c
+        med_qcresult_report a
         WHERE
         a.is_deleted = 'N'
-        AND c.is_deleted = 'N'
-        AND a.hospital_id = c.hospital_id
-        AND a.behospital_code = c.behospital_code
-        AND c.cases_id = 243
+        AND a.home_page_level != ''
         <if test="isPlacefile != null and isPlacefile != ''">
             and a.is_placefile = #{isPlacefile}
         </if>
@@ -2461,78 +2460,23 @@
             </if>
         </if>
         <if test="level != null and level != ''">
-            and c.level = #{level}
+            and a.level = #{level}
         </if>
         <if test="deptName != null and deptName != ''">
             and a.beh_dept_name like CONCAT('%',#{deptName},'%')
         </if>
+        ) m1
         GROUP BY
-        a.beh_dept_id,
-        a.beh_dept_name
-        ) t1,
+        m1.deptId,
+        m1.deptName)t1,
         (
         SELECT
-        a.beh_dept_id AS deptId,
-        a.beh_dept_name AS deptName,
-        count( * ) AS entryNum
-        FROM
-        med_behospital_info a,
-        med_qcresult_cases c,
-        med_qcresult_detail d,
-        qc_cases_entry e
-        WHERE
-        a.is_deleted = 'N'
-        AND c.is_deleted = 'N'
-        AND d.is_deleted = 'N'
-        AND e.is_deleted = 'N'
-        AND a.hospital_id = c.hospital_id
-        AND a.hospital_id = d.hospital_id
-        AND a.behospital_code = c.behospital_code
-        AND a.behospital_code = d.behospital_code
-        AND c.cases_id = d.cases_id
-        AND d.cases_id = e.cases_id
-        AND d.cases_entry_id = e.id
-        AND d.cases_id = 243
-        <if test="isPlacefile != null and isPlacefile != ''">
-            and a.is_placefile = #{isPlacefile}
-        </if>
-        AND a.qc_type_id != 0
-        <if test="hospitalId != null and hospitalId != ''">
-            AND a.hospital_id = #{hospitalId}
-        </if>
-        <if test="isPlacefile != null and isPlacefile == 0">
-            <if test="startDate != null and startDate != ''">
-                <![CDATA[ AND a.behospital_date >= #{startDate}]]>
-            </if>
-            <if test="endDate != null and endDate != ''">
-                <![CDATA[ AND a.behospital_date <= #{endDate}]]>
-            </if>
-        </if>
-        <if test="isPlacefile != null and isPlacefile == 1">
-            <if test="startDate != null and startDate != ''">
-                <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
-            </if>
-            <if test="endDate != null and endDate != ''">
-                <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
-            </if>
-        </if>
-        <if test="level != null and level != ''">
-            and c.level = #{level}
-        </if>
-        <if test="deptName != null and deptName != ''">
-            and a.beh_dept_name like CONCAT('%',#{deptName},'%')
-        </if>
-        GROUP BY
-        a.beh_dept_id,
-        a.beh_dept_name
-        ) t2,(
-        SELECT
         h1.deptId,
         h1.deptName,
         h1.emptyNum,
         h1.errorNum,
         h1.mrNum,
-        h2.entryNum,
+        h1.entryNum,
         h1.mrNum * h2.entryNum AS entryTotleNum,
         ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS emptyPercent,
         ROUND( ( h1.mrNum * h2.entryNum - h1.errorNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS errorPercent,
@@ -2540,35 +2484,22 @@
         emptyPercentStr,
         CONCAT( ROUND( ( h1.mrNum * h2.entryNum - h1.errorNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ), '%' ) AS
         errorPercentStr
-        FROM
-        (
+        from(
         SELECT
         a.beh_dept_id AS deptId,
         a.beh_dept_name AS deptName,
-        sum( d.rule_type = 1 ) AS emptyNum,
-        sum( d.rule_type = 2 ) AS errorNum,
+        count( * ) AS entryNum,
+        sum( a.rule_type = 1 ) AS emptyNum,
+        sum( a.rule_type = 2 ) AS errorNum,
         count( DISTINCT a.behospital_code ) AS mrNum
         FROM
-        med_behospital_info a,
-        med_qcresult_cases b,
-        med_qcresult_detail c,
-        qc_cases_entry d
+        med_qcresult_report a
         WHERE
         a.is_deleted = 'N'
-        AND b.is_deleted = 'N'
-        AND c.is_deleted = 'N'
-        AND d.is_deleted = 'N'
-        AND a.hospital_id = b.hospital_id
-        AND a.hospital_id = c.hospital_id
-        AND a.behospital_code = b.behospital_code
-        AND a.behospital_code = c.behospital_code
-        AND b.cases_id = c.cases_id
-        AND c.cases_id = d.cases_id
-        AND c.cases_entry_id = d.id
+        AND a.cases_id = 243
         <if test="isPlacefile != null and isPlacefile != ''">
             and a.is_placefile = #{isPlacefile}
         </if>
-        AND d.cases_id = 243
         AND a.qc_type_id != 0
         <if test="hospitalId != null and hospitalId != ''">
             AND a.hospital_id = #{hospitalId}
@@ -2590,7 +2521,7 @@
             </if>
         </if>
         <if test="level != null and level != ''">
-            and b.level = #{level}
+            and a.level = #{level}
         </if>
         <if test="deptName != null and deptName != ''">
             and a.beh_dept_name like CONCAT('%',#{deptName},'%')
@@ -2606,13 +2537,10 @@
         WHERE
         is_deleted = 'N'
         AND cases_id = 243
-        ) h2
-        ) t3
+        ) h2) t2
         WHERE
         t1.deptId = t2.deptId
-        AND t1.deptId = t3.deptId
         AND t1.deptName = t2.deptName
-        AND t1.deptName = t3.deptName
         <if test="asc != null and asc !=''">
             order by
             <choose>

+ 25 - 91
dblayer-mbg/src/main/resources/mapper/report/QcresultInfoMapper.xml

@@ -221,26 +221,13 @@
         FROM
         (
         SELECT
-        d.casesId,
-        e.NAME AS casesName,
-        d.num
-        FROM
-        (
-        SELECT
-        c.cases_id AS casesId,
+        a.cases_id AS casesId,
+        a.cases_name AS casesName,
         count(*) AS num
         FROM
-        med_behospital_info a,
-        med_qcresult_info b,
-        med_qcresult_detail c
+        med_qcresult_report a
         WHERE
         a.is_deleted = 'N'
-        AND b.is_deleted = 'N'
-        AND c.is_deleted = 'N'
-        AND a.hospital_id = b.hospital_id
-        AND a.hospital_id = c.hospital_id
-        AND a.behospital_code = b.behospital_code
-        AND a.behospital_code = c.behospital_code
         <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile != ''">
             and a.is_placefile = #{filterPageVO.isPlacefile}
         </if>
@@ -267,28 +254,19 @@
         <if test="filterPageVO.deptName != null and filterPageVO.deptName != ''">
             AND a.beh_dept_name like CONCAT('%', #{filterPageVO.deptName},'%')
         </if>
-        GROUP BY
-        c.cases_id
-        ) d,
-        qc_cases e
-        WHERE
-        e.is_deleted = 'N'
-        AND d.casesId = e.id
         <if test="filterPageVO.casesName != null and filterPageVO.casesName != ''">
-            AND e.name like CONCAT('%', #{filterPageVO.casesName},'%')
+            AND a.cases_name like CONCAT('%', #{filterPageVO.casesName},'%')
         </if>
+        GROUP BY
+        a.cases_id
         ) t1,
         (
         SELECT
-        COUNT(*) AS mrNum
+        COUNT(DISTINCT a.behospital_code) AS mrNum
         FROM
-        med_behospital_info a,
-        med_qcresult_info c
+        med_qcresult_report a
         WHERE
         a.is_deleted = 'N'
-        AND c.is_deleted = 'N'
-        AND a.hospital_id = c.hospital_id
-        AND a.behospital_code = c.behospital_code
         <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile != ''">
             and a.is_placefile = #{filterPageVO.isPlacefile}
         </if>
@@ -344,28 +322,17 @@
     <!-- 条目缺陷占比(内页) -->
     <select id="entryGroupByEntryInnerPage" resultType="com.lantone.common.dto.report.EntryNumDTO">
         SELECT
-        tt2.id as id,
-        tt2.name as name,
-        tt2.cases_id as casesId,
-        tt2.cases_name as casesName,
-        tt1.num as num,
-        tt1.is_reject as isReject
-        FROM
-        (
-        SELECT
-        a.hospital_id,
-        d.cases_entry_id,
-        d.cases_id,
+        a.cases_entry_id as id,
+        a.msg as name,
+        a.cases_id as casesId,
+        a.cases_name as casesName,
+        a.cases_deduct_score as score,
         count(*) as num,
-        d.is_reject
+        a.is_reject as isReject
         FROM
-        med_behospital_info a,
-        med_qcresult_detail d
+        med_qcresult_report a
         WHERE
         a.is_deleted = 'N'
-        AND d.is_deleted = 'N'
-        AND a.hospital_id = d.hospital_id
-        AND a.behospital_code = d.behospital_code
         <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile != ''">
             AND a.is_placefile = #{filterPageVO.isPlacefile}
         </if>
@@ -390,38 +357,28 @@
             </if>
         </if>
         <if test="filterPageVO.isReject != null">
-            AND d.is_reject = #{filterPageVO.isReject}
+            AND a.is_reject = #{filterPageVO.isReject}
         </if>
-        GROUP BY
-        d.cases_entry_id,
-        d.is_reject,
-        d.cases_id
-        ) tt1,
-        qc_cases_entry tt2
-        WHERE
-        tt2.is_deleted = 'N'
-        AND tt1.cases_id = tt2.cases_id
-        AND tt1.cases_entry_id = tt2.id
         <if test="filterPageVO.name != null and filterPageVO.name != ''">
-            AND tt2.name like CONCAT('%', #{filterPageVO.name},'%')
+            AND a.msg like CONCAT('%', #{filterPageVO.name},'%')
         </if>
         <if test="filterPageVO.casesName != null and filterPageVO.casesName != ''">
-            AND tt2.cases_name like CONCAT('%', #{filterPageVO.casesName},'%')
+            AND a.cases_name like CONCAT('%', #{filterPageVO.casesName},'%')
         </if>
+        GROUP BY
+        a.cases_entry_id,
+        a.is_reject,
+        a.cases_id
     </select>
 
-    <!-- 条目缺陷占比缺陷总量(内页) -->
+    <!-- 条目缺陷占比质控总量(内页) -->
     <select id="entryGroupByEntrySum" resultType="java.lang.Integer">
         SELECT
-        count(*) AS mrNum
+        count(distinct a.behospital_code) AS mrNum
         FROM
-        med_behospital_info a,
-        med_qcresult_info c
+        med_qcresult_report a
         WHERE
         a.is_deleted = 'N'
-        AND c.is_deleted = 'N'
-        AND a.hospital_id = c.hospital_id
-        AND a.behospital_code = c.behospital_code
         <if test="isPlacefile != null and isPlacefile != ''">
             and a.is_placefile = #{isPlacefile}
         </if>
@@ -447,29 +404,6 @@
         </if>
     </select>
 
-    <!-- 条目缺陷占比分值统计 -->
-    <select id="entryGroupByEntryScore" resultType="com.lantone.common.dto.report.EntryNumDTO">
-        SELECT
-        a.hospital_id as hospitalId,
-
-        <if test="isPlacefile != null and isPlacefile == 0">
-            a.score_run as score,
-        </if>
-        <if test="isPlacefile != null and isPlacefile == 1">
-            a.score,
-        </if>
-        a.cases_entry_id as id
-        FROM
-        qc_cases_entry_hospital a
-        WHERE
-        a.is_deleted = 'N'
-        AND a.hospital_id = #{hospitalId}
-        AND a.cases_entry_id IN
-        <foreach collection="ids" open="(" separator="," close=")" item="item">
-            ${item}
-        </foreach>
-    </select>
-
     <!-- 质控病历数统计 -->
     <select id="resultCount" parameterType="com.lantone.common.vo.report.QcresultFilterVO" resultType="map">
         SELECT

+ 1 - 12
report-service/src/main/java/com/lantone/report/facade/EntryCaseFacade.java

@@ -68,7 +68,7 @@ public class EntryCaseFacade {
         if (CollectionUtils.isEmpty(records)) {
             return entryNumDTOIPage;
         }
-        String hospitalId = filterPageVO.getHospitalId();
+
         //缺陷总数
         Integer sumInteget = qcresultInfoFacade.getBaseMapper().entryGroupByEntrySum(filterPageVO.getHospitalId(), filterPageVO.getIsPlacefile(),
                 filterPageVO.getStartDate(), filterPageVO.getEndDate());
@@ -86,17 +86,6 @@ public class EntryCaseFacade {
             record.setPercentStr(percent + "%");
             record.setTotleNum(sumInteget);
         }
-        //缺陷分值
-        String isPlacefile = filterPageVO.getIsPlacefile();
-        List<EntryNumDTO> entryScore = new ArrayList<>();
-        entryScore = qcresultInfoFacade.getBaseMapper().entryGroupByEntryScore(hospitalId, isPlacefile, ids);
-        for (EntryNumDTO record : records) {
-            for (EntryNumDTO entryNumDTO : entryScore) {
-                if (record.getId().equals(entryNumDTO.getId())) {
-                    record.setScore(entryNumDTO.getScore());
-                }
-            }
-        }
         return entryNumDTOIPage;
     }