Browse Source

1、病案首页合格率占比、完整率、完善率-科室-首页
2、病案首页合格率占比、完整率、完善率-科室-内页

zhaops 5 years ago
parent
commit
a6a5f3673f

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

@@ -5,6 +5,7 @@ import com.diagbot.dto.CaseAndDeptNumDTO;
 import com.diagbot.dto.DeptBaseDTO;
 import com.diagbot.dto.DeptEntryNumDTO;
 import com.diagbot.dto.DeptNumDTO;
+import com.diagbot.dto.HomePageNumDTO;
 import com.diagbot.dto.LevelStatisticsDTO;
 import com.diagbot.dto.NumDTO;
 import com.diagbot.util.BeanUtil;
@@ -573,7 +574,7 @@ public class ConsoleByDeptFacade {
      * @param filterOrderByDeptVO
      * @return
      */
-    public List<LevelStatisticsDTO> homePageLevelStatisticsByDept(FilterOrderByDeptVO filterOrderByDeptVO) {
+    public List<HomePageNumDTO> homePageLevelStatisticsByDept(FilterOrderByDeptVO filterOrderByDeptVO) {
         List<DeptBaseDTO> deptList = getDept();
         if (ListUtil.isEmpty(deptList)) {
             return null;
@@ -589,7 +590,11 @@ public class ConsoleByDeptFacade {
         filterOrderByDeptVO.setEndDate(endDate);
         filterOrderByDeptVO.setHospitalId(hosptialId);
         filterOrderByDeptVO.setUserId(Long.valueOf(userId));
-        List<LevelStatisticsDTO> records = behospitalInfoFacade.homePageLevelStatisticsByDept(filterOrderByDeptVO);
+        List<HomePageNumDTO> records = behospitalInfoFacade.homePageLevelStatisticsByDept(filterOrderByDeptVO);
+        HomePageNumDTO item = getGlobleRecord(records, filterOrderByDeptVO.getDeptName());
+        if (item != null) {
+            records.add(0, item);
+        }
         return records;
     }
 
@@ -599,8 +604,8 @@ public class ConsoleByDeptFacade {
      * @param filterOrderByDeptVO
      * @return
      */
-    public List<LevelStatisticsDTO> homePageLevelByDeptLimit(FilterOrderByDeptVO filterOrderByDeptVO) {
-        DecimalFormat df = new DecimalFormat("#0.00");
+    public List<HomePageNumDTO> homePageLevelByDeptLimit(FilterOrderByDeptVO filterOrderByDeptVO) {
+
         List<DeptBaseDTO> deptList = getDept();
         if (ListUtil.isEmpty(deptList)) {
             return null;
@@ -619,62 +624,119 @@ public class ConsoleByDeptFacade {
         if (filterOrderByDeptVO.getLimitCount() == null || filterOrderByDeptVO.getLimitCount().equals(0)) {
             filterOrderByDeptVO.setLimitCount(10);
         }
-        List<LevelStatisticsDTO> records = behospitalInfoFacade.homePageLevelStatisticsByDept(filterOrderByDeptVO);
-        //增加全科室
-        LevelStatisticsDTO item = new LevelStatisticsDTO();
+        List<HomePageNumDTO> records = behospitalInfoFacade.homePageLevelStatisticsByDept(filterOrderByDeptVO);
+        HomePageNumDTO item = getGlobleRecord(records, filterOrderByDeptVO.getDeptName());
+        if (item != null) {
+            records.add(0, item);
+        }
+
+        records = records
+                .stream()
+                .limit(filterOrderByDeptVO.getLimitCount())
+                .collect(Collectors.toList());
+
+        return records;
+    }
+
+    /**
+     * 获取某个科室全科室数据
+     *
+     * @param records
+     * @param deptName
+     * @return
+     */
+    public HomePageNumDTO getGlobleRecord(List<HomePageNumDTO> records, String deptName) {
+        DecimalFormat df = new DecimalFormat("#0.00");
+        HomePageNumDTO item = new HomePageNumDTO();
+        //总病历数
         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))) + "%";
-        item.setDoctorName(filterOrderByDeptVO.getDeptName());
+        //条目缺陷总数(模块下条目*病历数)
+        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(deptName);
         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(filterOrderByDeptVO.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;
     }
 }

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

@@ -164,7 +164,7 @@ public interface BehospitalInfoMapper extends BaseMapper<BehospitalInfo> {
      * @param filterOrderByDeptVO
      * @return
      */
-    public List<LevelStatisticsDTO> homePageLevelStatisticsByDept(FilterOrderByDeptVO filterOrderByDeptVO);
+    public List<HomePageNumDTO> homePageLevelStatisticsByDept(FilterOrderByDeptVO filterOrderByDeptVO);
 
     /**
      * 科室缺陷占比-科室(分页)

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

@@ -166,7 +166,7 @@ public interface BehospitalInfoService extends IService<BehospitalInfo> {
      * @param filterOrderByDeptVO
      * @return
      */
-    public List<LevelStatisticsDTO> homePageLevelStatisticsByDept(FilterOrderByDeptVO filterOrderByDeptVO);
+    public List<HomePageNumDTO> homePageLevelStatisticsByDept(FilterOrderByDeptVO filterOrderByDeptVO);
 
     /**
      * 缺陷明细-科室(分页)

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

@@ -222,7 +222,7 @@ public class BehospitalInfoServiceImpl extends ServiceImpl<BehospitalInfoMapper,
      * @return
      */
     @Override
-    public List<LevelStatisticsDTO> homePageLevelStatisticsByDept(FilterOrderByDeptVO filterOrderByDeptVO) {
+    public List<HomePageNumDTO> homePageLevelStatisticsByDept(FilterOrderByDeptVO filterOrderByDeptVO) {
         return baseMapper.homePageLevelStatisticsByDept(filterOrderByDeptVO);
     }
 

+ 3 - 2
src/main/java/com/diagbot/web/ConsoleByDeptController.java

@@ -6,6 +6,7 @@ import com.diagbot.dto.CaseAndDeptNumDTO;
 import com.diagbot.dto.DeptBaseDTO;
 import com.diagbot.dto.DeptEntryNumDTO;
 import com.diagbot.dto.DeptNumDTO;
+import com.diagbot.dto.HomePageNumDTO;
 import com.diagbot.dto.LevelStatisticsDTO;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.facade.ConsoleByDeptFacade;
@@ -90,7 +91,7 @@ public class ConsoleByDeptController {
                     "desc: 排序(降序) <br>")
     @PostMapping("/homePageLevelByDeptLimit")
     @SysLogger("homePageLevelByDeptLimit")
-    public RespDTO<List<LevelStatisticsDTO>> homePageLevelByDeptLimit(@RequestBody @Valid FilterOrderByDeptVO filterOrderByDeptVO) {
+    public RespDTO<List<HomePageNumDTO>> homePageLevelByDeptLimit(@RequestBody @Valid FilterOrderByDeptVO filterOrderByDeptVO) {
         return RespDTO.onSuc(consoleByDeptFacade.homePageLevelByDeptLimit(filterOrderByDeptVO));
     }
     //endregion -----------------------首页接口结束------------------------------
@@ -195,7 +196,7 @@ public class ConsoleByDeptController {
                     "desc: 排序(降序) <br>")
     @PostMapping("/homePageLevelStatisticsByDept")
     @SysLogger("homePageLevelStatisticsByDept")
-    public RespDTO<List<LevelStatisticsDTO>> homePageLevelStatisticsByDept(@RequestBody @Valid FilterOrderByDeptVO filterOrderByDeptVO) {
+    public RespDTO<List<HomePageNumDTO>> homePageLevelStatisticsByDept(@RequestBody @Valid FilterOrderByDeptVO filterOrderByDeptVO) {
         return RespDTO.onSuc(consoleByDeptFacade.homePageLevelStatisticsByDept(filterOrderByDeptVO));
     }
 

+ 3 - 2
src/main/java/com/diagbot/web/ConsoleController.java

@@ -6,6 +6,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.RespDTO;
@@ -420,7 +421,7 @@ public class ConsoleController {
                     "desc: 排序(降序) <br>")
     @PostMapping("/homePageLevelStatistics")
     @SysLogger("homePageLevelStatistics")
-    public RespDTO<List<LevelStatisticsDTO>> homePageLevelStatistics(@RequestBody @Valid FilterOrderVO filterOrderVO) {
+    public RespDTO<List<HomePageNumDTO>> homePageLevelStatistics(@RequestBody @Valid FilterOrderVO filterOrderVO) {
         return RespDTO.onSuc(consoleFacade.homePageLevelStatistics(filterOrderVO));
     }
 
@@ -438,7 +439,7 @@ public class ConsoleController {
                     "desc: 排序(降序) <br>")
     @PostMapping("/homePageLevelLimit")
     @SysLogger("homePageLevelLimit")
-    public RespDTO<List<LevelStatisticsDTO>> homePageLevelLimit(@RequestBody @Valid FilterOrderVO filterOrderVO) {
+    public RespDTO<List<HomePageNumDTO>> homePageLevelLimit(@RequestBody @Valid FilterOrderVO filterOrderVO) {
         return RespDTO.onSuc(consoleFacade.homePageLevelLimit(filterOrderVO));
     }
 }

+ 109 - 20
src/main/resources/mapper/BehospitalInfoMapper.xml

@@ -1633,7 +1633,7 @@
 
     <!-- 病案首页合格率占比-科室 -->
     <select id="homePageLevelStatisticsByDept" parameterType="com.diagbot.vo.FilterOrderByDeptVO"
-            resultType="com.diagbot.dto.LevelStatisticsDTO">
+            resultType="com.diagbot.dto.HomePageNumDTO">
         SELECT
         t1.doctorId,
         t1.doctorName,
@@ -1646,29 +1646,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.doctor_id AS doctorId,
         a.doctor_name AS doctorName,
-        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
@@ -1762,10 +1765,88 @@
         GROUP BY
         a.doctor_id,
         a.doctor_name
-        ) t2
+        ) t2,(
+        SELECT
+        h1.doctorId,
+        h1.doctorName,
+        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.doctor_id AS doctorId,
+        a.doctor_name AS doctorName,
+        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,
+        sys_user_dept e
+        WHERE
+        a.is_deleted = 'N'
+        AND b.is_deleted = 'N'
+        AND c.is_deleted = 'N'
+        AND d.is_deleted = 'N'
+        AND e.is_deleted = 'N'
+        AND a.hospital_id = b.hospital_id
+        AND a.hospital_id = c.hospital_id
+        AND a.hospital_id = e.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.doctor_name like CONCAT('%',#{name},'%')
+        </if>
+        <if test="userId!=null and userId !=''">
+            AND e.user_id = #{userId}
+        </if>
+        <if test="deptName!=null and deptName !=''">
+            AND a.beh_dept_name = #{deptName}
+        </if>
+        GROUP BY
+        a.doctor_id,
+        a.doctor_name
+        ) h1,(
+        SELECT
+        count(*) AS entryNum
+        FROM
+        qc_cases_entry
+        WHERE
+        is_deleted = 'N'
+        AND cases_id = 243
+        ) h2
+        ) t3
         WHERE
         t1.doctorId = t2.doctorId
+        AND t1.doctorId = t3.doctorId
         AND t1.doctorName = t2.doctorName
+        AND t1.doctorName = t3.doctorName
         <if test="asc != null and asc !=''">
             order by
             <choose>
@@ -1777,13 +1858,17 @@
                 <when test='asc=="averageValue"'>averageValue asc</when>
                 <when test='asc=="firstLevelNum"'>firstLevelNum asc</when>
                 <when test='asc=="secondLevelNum"'>secondLevelNum asc</when>
-                <when test='asc=="thirdLevelNum"'>thirdLevelNum asc</when>
                 <when test='asc=="firstLevelPercent"'>firstLevelPercent asc</when>
                 <when test='asc=="secondLevelPercent"'>secondLevelPercent asc</when>
-                <when test='asc=="thirdLevelPercent"'>thirdLevelPercent asc</when>
                 <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
                 <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
-                <when test='asc=="thirdLevelPercentStr"'>thirdLevelPercent 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>doctorName asc</otherwise>
             </choose>
         </if>
@@ -1798,13 +1883,17 @@
                 <when test='desc=="averageValue"'>averageValue desc</when>
                 <when test='desc=="firstLevelNum"'>firstLevelNum desc</when>
                 <when test='desc=="secondLevelNum"'>secondLevelNum desc</when>
-                <when test='desc=="thirdLevelNum"'>thirdLevelNum desc</when>
                 <when test='desc=="firstLevelPercent"'>firstLevelPercent desc</when>
                 <when test='desc=="secondLevelPercent"'>secondLevelPercent desc</when>
-                <when test='desc=="thirdLevelPercent"'>thirdLevelPercent desc</when>
                 <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
                 <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
-                <when test='desc=="thirdLevelPercentStr"'>thirdLevelPercent 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>doctorName desc</otherwise>
             </choose>
         </if>