Explorar o código

1、病案首页合格率占比-全院-首页
2、病案首页合格率占比-全院-内页

zhaops %!s(int64=5) %!d(string=hai) anos
pai
achega
d357632204

+ 37 - 0
src/main/java/com/diagbot/dto/HomePageNumDTO.java

@@ -0,0 +1,37 @@
+package com.diagbot.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2020/6/5 17:32
+ */
+@Getter
+@Setter
+public class HomePageNumDTO {
+    private String deptId;
+    private String deptName;
+    private String doctorId;
+    private String doctorName;
+    private Integer entryNum;
+    private Integer mrNum;
+    private Double totleValue;
+    private Double averageValue;
+    private Integer firstLevelNum;
+    private Integer secondLevelNum;
+    private Double firstLevelPercent;
+    private Double secondLevelPercent;
+    private String firstLevelPercentStr;
+    private String secondLevelPercentStr;
+    private String deptClassId;
+    private String deptClass;
+    private Integer emptyNum;
+    private Integer errorNum;
+    private Integer entryTotleNum;
+    private Double emptyPercent;
+    private Double errorPercent;
+    private String emptyPercentStr;
+    private String errorPercentStr;
+}

+ 88 - 26
src/main/java/com/diagbot/facade/ConsoleFacade.java

@@ -8,6 +8,7 @@ import com.diagbot.dto.AverageStatisticsDTO;
 import com.diagbot.dto.CaseNumDTO;
 import com.diagbot.dto.DeptNumDTO;
 import com.diagbot.dto.EntryNumDTO;
+import com.diagbot.dto.HomePageNumDTO;
 import com.diagbot.dto.LevelStatisticsDTO;
 import com.diagbot.dto.NumDTO;
 import com.diagbot.dto.QcResultPercentDTO;
@@ -23,7 +24,6 @@ import com.diagbot.vo.FilterPageVO;
 import com.diagbot.vo.FilterVO;
 import com.google.common.collect.Lists;
 import io.github.lvyahui8.spring.aggregate.facade.DataBeanAggregateQueryFacade;
-import io.github.lvyahui8.spring.annotation.InvokeParameter;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
@@ -585,14 +585,18 @@ public class ConsoleFacade {
      * @param filterOrderVO
      * @return
      */
-    public List<LevelStatisticsDTO> homePageLevelStatistics(FilterOrderVO filterOrderVO) {
+    public List<HomePageNumDTO> homePageLevelStatistics(FilterOrderVO filterOrderVO) {
         String hosptialId = SysUserUtils.getCurrentHospitalID();
         String startDate = filterFacade.getStartDateStr(filterOrderVO.getType(), null);
         String endDate = filterFacade.getEndDateStr(filterOrderVO.getType(), null);
         filterOrderVO.setStartDate(startDate);
         filterOrderVO.setEndDate(endDate);
         filterOrderVO.setHospitalId(hosptialId);
-        List<LevelStatisticsDTO> records = behospitalInfoFacade.homePageLevelStatistics(filterOrderVO);
+        List<HomePageNumDTO> records = behospitalInfoFacade.homePageLevelStatistics(filterOrderVO);
+        HomePageNumDTO item = getGlobleRecord(records);
+        if (item != null) {
+            records.add(0, item);
+        }
         return records;
     }
 
@@ -602,8 +606,8 @@ public class ConsoleFacade {
      * @param filterOrderVO
      * @return
      */
-    public List<LevelStatisticsDTO> homePageLevelLimit(FilterOrderVO filterOrderVO) {
-        DecimalFormat df = new DecimalFormat("#0.00");
+    public List<HomePageNumDTO> homePageLevelLimit(FilterOrderVO filterOrderVO) {
+
         String hosptialId = SysUserUtils.getCurrentHospitalID();
         String startDate = filterFacade.getStartDateStr(filterOrderVO.getType(), null);
         String endDate = filterFacade.getEndDateStr(filterOrderVO.getType(), null);
@@ -613,63 +617,121 @@ public class ConsoleFacade {
         if (filterOrderVO.getLimitCount() == null || filterOrderVO.getLimitCount().equals(0)) {
             filterOrderVO.setLimitCount(10);
         }
-        List<LevelStatisticsDTO> records = behospitalInfoFacade.homePageLevelStatistics(filterOrderVO);
+        List<HomePageNumDTO> records = behospitalInfoFacade.homePageLevelStatistics(filterOrderVO);
+        HomePageNumDTO item = getGlobleRecord(records);
+        if (item != null) {
+            records.add(0, item);
+        }
+        records = records
+                .stream()
+                .limit(filterOrderVO.getLimitCount())
+                .collect(Collectors.toList());
+        return records;
+    }
 
-        //增加全院
-        LevelStatisticsDTO item = new LevelStatisticsDTO();
+    /**
+     * 增加全院记录
+     *
+     * @param records
+     * @return
+     */
+    public HomePageNumDTO getGlobleRecord(List<HomePageNumDTO> records) {
+        DecimalFormat df = new DecimalFormat("#0.00");
+        HomePageNumDTO item = new HomePageNumDTO();
+
+        if (ListUtil.isEmpty(records)) {
+            return null;
+        }
+
+        //总病历数
         Integer mrNum = records
                 .stream()
-                .map(LevelStatisticsDTO::getMrNum)
+                .map(HomePageNumDTO::getMrNum)
                 .reduce(0, Integer::sum);
         if (mrNum == null || mrNum == 0) {
-            return Lists.newLinkedList();
+            return null;
         }
+        //总缺陷数
         Integer entryNum = records
                 .stream()
-                .map(LevelStatisticsDTO::getEntryNum)
+                .map(HomePageNumDTO::getEntryNum)
                 .reduce(0, Integer::sum);
-        Double totleFee = records
+        //总分
+        Double totleValue = records
                 .stream()
                 .map(i -> BigDecimal.valueOf(i.getTotleValue()))
                 .reduce(BigDecimal.ZERO, BigDecimal::add)
                 .doubleValue();
-        Double averageFee = BigDecimal.valueOf(totleFee)
+        //平均分
+        Double averageValue = BigDecimal.valueOf(totleValue)
                 .divide(BigDecimal.valueOf(mrNum), 2, RoundingMode.HALF_UP)
                 .doubleValue();
+        //合格病历总数
         Integer firstLevelNum = records
                 .stream()
-                .map(LevelStatisticsDTO::getFirstLevelNum)
+                .map(HomePageNumDTO::getFirstLevelNum)
                 .reduce(0, Integer::sum);
+        //合格病历占比
         Double firstLevelPercent = BigDecimal.valueOf(firstLevelNum)
                 .divide(BigDecimal.valueOf(mrNum), 4, RoundingMode.HALF_UP)
                 .doubleValue();
         String firstLevelPercentStr
                 = df.format(BigDecimal.valueOf(firstLevelPercent).multiply(BigDecimal.valueOf(100))) + "%";
-        Integer secondLevelNum = mrNum - firstLevelNum;
+        //不合格病历数
+        Integer secondLevelNum = records
+                .stream()
+                .map(HomePageNumDTO::getSecondLevelNum)
+                .reduce(0, Integer::sum);
+        //不合格病历占比
         Double secondLevelPercent = BigDecimal.valueOf(secondLevelNum)
                 .divide(BigDecimal.valueOf(mrNum), 4, RoundingMode.HALF_UP)
                 .doubleValue();
         String secondLevelPercentStr
                 = df.format(BigDecimal.valueOf(secondLevelPercent).multiply(BigDecimal.valueOf(100))) + "%";
+        //条目缺陷总数(模块下条目*病历数)
+        Integer entryTotleNum = records
+                .stream()
+                .map(HomePageNumDTO::getEntryTotleNum)
+                .reduce(0, Integer::sum);
+        //空项总数
+        Integer emptyNum = records
+                .stream()
+                .map(HomePageNumDTO::getEmptyNum)
+                .reduce(0, Integer::sum);
+        Double emptyPercent = BigDecimal.valueOf(emptyNum)
+                .divide(BigDecimal.valueOf(entryTotleNum), 4, RoundingMode.HALF_UP)
+                .doubleValue();
+        String emptyPercentStr
+                = df.format(BigDecimal.valueOf(emptyPercent).multiply(BigDecimal.valueOf(100))) + "%";
+        //错误项总数
+        Integer errorNum = records
+                .stream()
+                .map(HomePageNumDTO::getErrorNum)
+                .reduce(0, Integer::sum);
+        Double errorPercent = BigDecimal.valueOf(errorNum)
+                .divide(BigDecimal.valueOf(entryTotleNum), 4, RoundingMode.HALF_UP)
+                .doubleValue();
+        String errorPercentStr
+                = df.format(BigDecimal.valueOf(errorPercent).multiply(BigDecimal.valueOf(100))) + "%";
+
         item.setDeptName("全院");
         item.setEntryNum(entryNum);
         item.setMrNum(mrNum);
-        item.setTotleValue(totleFee);
-        item.setAverageValue(averageFee);
+        item.setTotleValue(totleValue);
+        item.setAverageValue(averageValue);
         item.setFirstLevelNum(firstLevelNum);
         item.setFirstLevelPercent(firstLevelPercent);
         item.setFirstLevelPercentStr(firstLevelPercentStr);
         item.setSecondLevelNum(secondLevelNum);
         item.setSecondLevelPercent(secondLevelPercent);
         item.setSecondLevelPercentStr(secondLevelPercentStr);
-
-        records.add(0, item);
-
-        records = records
-                .stream()
-                .limit(filterOrderVO.getLimitCount())
-                .collect(Collectors.toList());
-
-        return records;
+        item.setEntryTotleNum(entryTotleNum);
+        item.setEmptyNum(emptyNum);
+        item.setEmptyPercent(emptyPercent);
+        item.setEmptyPercentStr(emptyPercentStr);
+        item.setErrorNum(errorNum);
+        item.setErrorPercent(errorPercent);
+        item.setErrorPercentStr(errorPercentStr);
+        return item;
     }
 }

+ 2 - 1
src/main/java/com/diagbot/mapper/BehospitalInfoMapper.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.diagbot.dto.BehospitalInfoDTO;
 import com.diagbot.dto.DeptNumDTO;
 import com.diagbot.dto.ExportExcelDTO;
+import com.diagbot.dto.HomePageNumDTO;
 import com.diagbot.dto.LevelStatisticsDTO;
 import com.diagbot.dto.MsgDTO;
 import com.diagbot.dto.NumDTO;
@@ -147,7 +148,7 @@ public interface BehospitalInfoMapper extends BaseMapper<BehospitalInfo> {
      * @param filterOrderVO
      * @return
      */
-    public List<LevelStatisticsDTO> homePageLevelStatistics(FilterOrderVO filterOrderVO);
+    public List<HomePageNumDTO> homePageLevelStatistics(FilterOrderVO filterOrderVO);
 
     /**
      * 各科室缺陷占比(主任医生)

+ 2 - 1
src/main/java/com/diagbot/service/BehospitalInfoService.java

@@ -6,6 +6,7 @@ import com.diagbot.dto.BehospitalInfoDTO;
 import com.diagbot.dto.DeptNumDTO;
 import com.diagbot.dto.ExportExcelDTO;
 import com.diagbot.dto.ExportQcresultDTO;
+import com.diagbot.dto.HomePageNumDTO;
 import com.diagbot.dto.LevelStatisticsDTO;
 import com.diagbot.dto.MsgDTO;
 import com.diagbot.dto.NumDTO;
@@ -149,7 +150,7 @@ public interface BehospitalInfoService extends IService<BehospitalInfo> {
      * @param filterOrderVO
      * @return
      */
-    public List<LevelStatisticsDTO> homePageLevelStatistics(FilterOrderVO filterOrderVO);
+    public List<HomePageNumDTO> homePageLevelStatistics(FilterOrderVO filterOrderVO);
 
     /**
      * 各科室缺陷占比(主任医生)

+ 2 - 1
src/main/java/com/diagbot/service/impl/BehospitalInfoServiceImpl.java

@@ -6,6 +6,7 @@ import com.diagbot.dto.BehospitalInfoDTO;
 import com.diagbot.dto.DeptNumDTO;
 import com.diagbot.dto.ExportQcresultDTO;
 import com.diagbot.dto.ExportExcelDTO;
+import com.diagbot.dto.HomePageNumDTO;
 import com.diagbot.dto.LevelStatisticsDTO;
 import com.diagbot.dto.MsgDTO;
 import com.diagbot.dto.NumDTO;
@@ -199,7 +200,7 @@ public class BehospitalInfoServiceImpl extends ServiceImpl<BehospitalInfoMapper,
      * @return
      */
     @Override
-    public List<LevelStatisticsDTO> homePageLevelStatistics(FilterOrderVO filterOrderVO) {
+    public List<HomePageNumDTO> homePageLevelStatistics(FilterOrderVO filterOrderVO) {
         return baseMapper.homePageLevelStatistics(filterOrderVO);
     }
 

+ 100 - 14
src/main/resources/mapper/BehospitalInfoMapper.xml

@@ -1205,7 +1205,7 @@
 
     <!-- 病案首页合格率占比 -全院-->
     <select id="homePageLevelStatistics" parameterType="com.diagbot.vo.FilterOrderVO"
-            resultType="com.diagbot.dto.LevelStatisticsDTO">
+            resultType="com.diagbot.dto.HomePageNumDTO">
         SELECT
         t1.deptId,
         t1.deptName,
@@ -1218,29 +1218,32 @@
         t1.firstLevelPercent,
         t1.secondLevelPercent,
         t1.firstLevelPercentStr,
-        t1.secondLevelPercentStr
+        t1.secondLevelPercentStr,
+        t3.emptyNum,
+        t3.errorNum,
+        t3.entryTotleNum,
+        t3.emptyPercent,
+        t3.errorPercent,
+        t3.emptyPercentStr,
+        t3.errorPercentStr
         FROM
         (
         SELECT
         a.beh_dept_id AS deptId,
         a.beh_dept_name AS deptName,
-        count( DISTINCT c.id ) AS mrNum,
-        ROUND( sum( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
-        ROUND( sum( CAST(c.score_res as DECIMAL ( 18, 2 )) )/ count(*), 2 ) AS averageValue,
+        count( DISTINCT a.behospital_code ) AS mrNum,
+        ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
+        ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) )/ count(*), 2 ) AS averageValue,
         COUNT( DISTINCT CASE WHEN c.`level` = '合格' THEN c.id END ) AS firstLevelNum,
         COUNT( DISTINCT CASE WHEN c.`level` = '不合格' THEN c.id END ) AS secondLevelNum,
-        ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '合格' THEN c.id END )/ count( DISTINCT c.id ), 4
-        ) AS firstLevelPercent,
-        ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '不合格' THEN c.id END )/ count( DISTINCT c.id ),
-        4 ) AS secondLevelPercent,
+        ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '合格' THEN c.id END )/ count( DISTINCT c.id ), 4 ) AS firstLevelPercent,
+        ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '不合格' THEN c.id END )/ count( DISTINCT c.id ), 4 ) AS secondLevelPercent,
         concat(
-        ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '合格' THEN c.id END )/ count( DISTINCT c.id )*
-        100, 2 ),
+        ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '合格' THEN c.id END )/ count( DISTINCT c.id )* 100, 2 ),
         '%'
         ) AS firstLevelPercentStr,
         concat(
-        ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '不合格' THEN c.id END )/ count( DISTINCT c.id )*
-        100, 2 ),
+        ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '不合格' THEN c.id END )/ count( DISTINCT c.id )* 100, 2 ),
         '%'
         ) AS secondLevelPercentStr
         FROM
@@ -1316,10 +1319,79 @@
         GROUP BY
         a.beh_dept_id,
         a.beh_dept_name
-        ) t2
+        ) t2,(
+        SELECT
+        h1.deptId,
+        h1.deptName,
+        h1.emptyNum,
+        h1.errorNum,
+        h1.mrNum,
+        h2.entryNum,
+        h1.mrNum * h2.entryNum AS entryTotleNum,
+        ROUND( h1.emptyNum / ( h1.mrNum * h2.entryNum ), 4 ) AS emptyPercent,
+        ROUND( h1.errorNum / ( h1.mrNum * h2.entryNum ), 4 ) AS errorPercent,
+        CONCAT( ROUND( h1.emptyNum / ( h1.mrNum * h2.entryNum )* 100, 2 ), '%' ) AS emptyPercentStr,
+        CONCAT( ROUND( h1.errorNum /( h1.mrNum * h2.entryNum )* 100, 2 ), '%' ) AS errorPercentStr
+        FROM
+        (
+        SELECT
+        a.beh_dept_id AS deptId,
+        a.beh_dept_name AS deptName,
+        sum( d.rule_type = 1 ) AS emptyNum,
+        round( sum( d.rule_type = 2 )/ 2, 0 ) 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
+        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 c.cases_id = d.cases_id
+        AND c.cases_entry_id = d.id
+        AND a.is_placefile = '1'
+        AND d.cases_id = 243
+        <![CDATA[AND a.qc_type_id <>0 ]]>
+        <if test="hospitalId != null and hospitalId != ''">
+            AND a.hospital_id = #{hospitalId}
+        </if>
+        <if test="startDate != null and startDate != ''">
+            <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
+        </if>
+        <if test="endDate != null and endDate != ''">
+            <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
+        </if>
+        <if test="level != null and level != ''">
+            and b.level = #{level}
+        </if>
+        <if test="name != null and name != ''">
+            and a.beh_dept_name like CONCAT('%',#{name},'%')
+        </if>
+        GROUP BY
+        a.beh_dept_id,
+        a.beh_dept_name
+        ) h1,(
+        SELECT
+        count(*) AS entryNum
+        FROM
+        qc_cases_entry
+        WHERE
+        is_deleted = 'N'
+        AND cases_id = 243
+        ) h2
+        ) t3
         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>
@@ -1335,6 +1407,13 @@
                 <when test='asc=="secondLevelPercent"'>secondLevelPercent asc</when>
                 <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
                 <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
+                <when test='asc=="emptyNum"'>emptyNum asc</when>
+                <when test='asc=="errorNum"'>errorNum asc</when>
+                <when test='asc=="entryTotleNum"'>entryTotleNum asc</when>
+                <when test='asc=="emptyPercent"'>emptyPercent asc</when>
+                <when test='asc=="errorPercent"'>errorPercent asc</when>
+                <when test='asc=="emptyPercentStr"'>emptyPercent asc</when>
+                <when test='asc=="errorPercentStr"'>errorPercent asc</when>
                 <otherwise>deptName asc</otherwise>
             </choose>
         </if>
@@ -1353,6 +1432,13 @@
                 <when test='desc=="secondLevelPercent"'>secondLevelPercent desc</when>
                 <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
                 <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
+                <when test='desc=="emptyNum"'>emptyNum desc</when>
+                <when test='desc=="errorNum"'>errorNum desc</when>
+                <when test='desc=="entryTotleNum"'>entryTotleNum desc</when>
+                <when test='desc=="emptyPercent"'>emptyPercent desc</when>
+                <when test='desc=="errorPercent"'>errorPercent desc</when>
+                <when test='desc=="emptyPercentStr"'>emptyPercent desc</when>
+                <when test='desc=="errorPercentStr"'>errorPercent desc</when>
                 <otherwise>deptName desc</otherwise>
             </choose>
         </if>