Bläddra i källkod

控制台病案首页合格率占比sql调整

chengyao 3 år sedan
förälder
incheckning
395140c1f3

+ 29 - 73
dblayer-mbg/src/main/resources/mapper/report/BehospitalInfoMapper.xml

@@ -2170,24 +2170,17 @@
     <!-- 病案首页质控病历数统计-全院(首页)-->
     <select id="homePageQcPercent" resultType="com.lantone.common.dto.report.HomePageNumDTO">
         SELECT
-        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
+        ROUND( firstLevelNum/ mrNum, 4 ) AS firstLevelPercent,
+        concat( ROUND( firstLevelNum/ mrNum* 100, 2 ), '%' ) AS firstLevelPercentStr
+        FROM(
+        SELECT
+        count( distinct a.behospital_code) AS mrNum,
+        count(DISTINCT case when a.`home_page_level` = '合格' then a.behospital_code end) AS firstLevelNum
         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>
@@ -2210,7 +2203,7 @@
             <if test="endDate != null and endDate != ''">
                 <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
             </if>
-        </if>
+        </if>)t1
     </select>
 
     <!-- 病案首页完整率统计-全院(首页)-->
@@ -2228,29 +2221,18 @@
         FROM
         (
         SELECT
-        sum( d.rule_type = 1 ) AS emptyNum,
+        sum(a.rule_type = 1 ) AS emptyNum,
         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.home_page_level != ''
+        AND a.cases_entry_id is not null
+        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}
@@ -2288,46 +2270,29 @@
         t2.homePageMRNum,
         t1.improveNum,
         round( t1.improveNum / t2.homePageMRNum, 4 ) AS improvePercent,
-        Concat( round( t1.improveNum / t2.homePageMRNum * 100, 2 ), '%' ) AS improvePercentStr,
-        t1.improveToPassNum,
-        round( t1.improveToPassNum / t2.homePageMRNum, 4 ) AS improveToPassPercent,
-        Concat( round( t1.improveToPassNum / t2.homePageMRNum * 100, 2 ), '%' ) AS improveToPassPercentStr,
-        t1.improveToFullNum,
-        round( t1.improveToFullNum / t2.homePageMRNum, 4 ) AS improveToFullPercent,
-        Concat( round( t1.improveToFullNum / t2.homePageMRNum * 100, 2 ), '%' ) AS improveToFullPercentStr
+        Concat( round( t1.improveNum / t2.homePageMRNum * 100, 2 ), '%' ) AS improvePercentStr
         FROM
         (
         SELECT
-        <![CDATA[sum( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 ) AS improveToPassNum,]]>
-        sum( d.score_res = 20 ) AS improveToFullNum,
         count(*) AS improveNum
         FROM
-        med_behospital_info a,
+        med_qcresult_report a,
         med_home_page b,
-        med_qcresult_info c,
-        med_qcresult_cases d,
         (
         SELECT
-        m4.*
+        m1.hospital_id,
+        m1.behospital_code,
+        m1.score_res
         FROM
-        med_behospital_info m1,
-        med_home_page m2,
-        med_qcresult_info m3,
-        med_qcresult_cases m4
+        med_qcresult_report m1,
+        med_home_page m2
         WHERE
-        m1.is_deleted = 'N'
+        m1.is_deleted = 'Y'
         AND m2.is_deleted = 'N'
-        AND m3.is_deleted = 'Y'
-        AND m4.is_deleted = 'Y'
         AND m1.hospital_id = m2.hospital_id
-        AND m1.hospital_id = m3.hospital_id
-        AND m1.hospital_id = m4.hospital_id
         AND m1.behospital_code = m2.behospital_code
-        AND m1.behospital_code = m3.behospital_code
-        AND m1.behospital_code = m4.behospital_code
-        AND m3.gmt_create = m4.gmt_create
-        AND m3.have_home_page = 1
-        AND m4.cases_id = 243
+        AND m1.have_home_page = 1
+        AND m1.home_page_level != ""
         <if test="isPlacefile != null and isPlacefile != ''">
             and m1.is_placefile = #{isPlacefile}
         </if>
@@ -2355,23 +2320,17 @@
         m1.behospital_code
         ORDER BY
         m1.behospital_code,
-        m4.gmt_create
+        m1.gmt_create
         ) e
         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.hospital_id = d.hospital_id
         AND a.hospital_id = e.hospital_id
         AND a.behospital_code = b.behospital_code
-        AND a.behospital_code = c.behospital_code
-        AND a.behospital_code = d.behospital_code
         AND a.behospital_code = e.behospital_code
-        AND d.cases_id = 243
-        AND d.score_res > e.score_res
+        AND m1.home_page_level != ""
+        AND a.score_res > e.score_res
         <if test="isPlacefile != null and isPlacefile != ''">
             and a.is_placefile = #{isPlacefile}
         </if>
@@ -2400,16 +2359,13 @@
         SELECT
         count( DISTINCT a.behospital_code ) AS homePageMRNum
         FROM
-        med_behospital_info a,
-        med_home_page b,
-        med_qcresult_info c
+        med_qcresult_report a,
+        med_home_page b
         WHERE
         a.is_deleted = 'N'
         AND b.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 a.qc_type_id != 0
         <if test="isPlacefile != null and isPlacefile != ''">
             and a.is_placefile = #{isPlacefile}

+ 0 - 9
report-service/src/main/java/com/lantone/report/aggregate/HomePageStatisticsAggregate.java

@@ -44,16 +44,7 @@ public class HomePageStatisticsAggregate {
             pass.setTotleNum(qcNumDTO.getMrNum());
             pass.setPercent(qcNumDTO.getFirstLevelPercent());
             pass.setPercentStr(qcNumDTO.getFirstLevelPercentStr());
-            //不合格率
-            NumDTO unPass = new NumDTO();
-            unPass.setName("不合格率");
-            unPass.setNum(qcNumDTO.getSecondLevelNum());
-            unPass.setTotleNum(qcNumDTO.getMrNum());
-            unPass.setPercent(qcNumDTO.getSecondLevelPercent());
-            unPass.setPercentStr(qcNumDTO.getSecondLevelPercentStr());
-
             retMap.put("合格率", pass);
-            retMap.put("不合格率", unPass);
         }
         if (emptyNumDTO != null) {
             //完整率