Parcourir la source

保存分母code

zhanghang il y a 4 ans
Parent
commit
52998c95df

+ 77 - 0
src/main/java/com/diagbot/entity/MedIndexRelevance.java

@@ -0,0 +1,77 @@
+package com.diagbot.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import lombok.Data;
+
+import java.time.LocalDateTime;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author zhanghang
+ * @since 2021-04-30
+ */
+@Data
+public class MedIndexRelevance implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 主缓存表id
+     */
+    private Integer indexResultId;
+
+    /**
+     * 病历条目关联表type
+     */
+    private Integer relevanceType;
+
+    /**
+     * 医院ID
+     */
+    private String hospitalId;
+
+    /**
+     * 病人病历号
+     */
+    private String behospitalCode;
+
+    private String startDate;
+
+    private String endDate;
+
+    /**
+     * 是否删除,N:未删除,Y:删除
+     */
+    private String isDeleted;
+
+    /**
+     * 记录创建时间
+     */
+    private Date gmtCreate;
+
+    /**
+     * 记录修改时间,如果时间是1970年则表示纪录未修改
+     */
+    private Date gmtModified;
+
+    /**
+     * 创建人,0表示无创建人值
+     */
+    private String creator;
+
+    /**
+     * 修改人,如果为0则表示纪录未修改
+     */
+    private String modifier;
+
+
+}

+ 1 - 0
src/main/java/com/diagbot/enums/QualityContent.java

@@ -13,6 +13,7 @@ public class QualityContent {
     public static final String NUMBER_OF_HOSPITAL = "入院人数";
     public static final String NO_RECORD_OPERATION = "无病案首页手术患者";
     public static final String NO_RECORD_OPERATION_PATHOLOGY = "无病案首页手术病理患者";
+    public static final double pathologyFee = 68.00;
     /**
      * 是否需要用到医嘱的指标名称
      */

+ 133 - 37
src/main/java/com/diagbot/facade/ConsoleFacade.java

@@ -21,6 +21,7 @@ import com.google.common.collect.Lists;
 import io.github.lvyahui8.spring.aggregate.facade.DataBeanAggregateQueryFacade;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.ibatis.annotations.Param;
+import org.apache.poi.hssf.record.DVALRecord;
 import org.apache.poi.ss.formula.functions.Na;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -77,7 +78,8 @@ public class ConsoleFacade {
     private DoctorAdviceFacade doctorAdviceFacade;
     @Autowired
     private MedIndexResultFacade medIndexResultFacade;
-
+    @Autowired
+    private MedIndexRelevanceFacade medIndexRelevanceFacade;
     //region-----------------------聚合接口开始-------------------------------
 
     /**
@@ -596,31 +598,79 @@ public class ConsoleFacade {
      */
     public void getMedicaIndicator(FilterVO filterVO){
         MedIndexResult medIndexResult = new MedIndexResult();
-        Map<String, Long> selectOperationNumMap = behospitalInfoFacade.selectOperationNum(filterVO);
+       List<Map<String, String>> selectOperationNumMap = behospitalInfoFacade.selectOperationNum(filterVO);
+        if(ListUtil.isNotEmpty(selectOperationNumMap)) {
         //出院人数
-        Long startCount = selectOperationNumMap.get(QualityContent.DISCHARGED_PATIENTS);
-            Long operationFeeNum = 0L;
-                filterVO.setFlagStr("2");
-        List<MedManageParamsDTO> doctorAdviceMedManageParams = behospitalInfoFacade.getMedManageParams(filterVO);
-                Map<String, Long> adviceNum = getAdviceNum(filterVO,doctorAdviceMedManageParams);
-                //手术人数
-                operationFeeNum = selectOperationNumMap.get("operationFee");
-                Long operation = adviceNum.get("operation");
-                operationFeeNum = operationFeeNum + operation;
+        CopyOnWriteArrayList<String> operationCode = new CopyOnWriteArrayList<>();
+        CopyOnWriteArrayList<String> operationPathologyCode = new CopyOnWriteArrayList<>();
+        CopyOnWriteArrayList<String> antibiosisCode = new CopyOnWriteArrayList<>();
+        Long operationFeeNum = 0L;
+            filterVO.setFlagStr("2");
+            List<MedManageParamsDTO> doctorAdviceMedManageParams = behospitalInfoFacade.getMedManageParams(filterVO);
+            Map<String, List<String>> adviceNum = getAdviceNum(filterVO, doctorAdviceMedManageParams);
+                Long startCount = (Long.valueOf(selectOperationNumMap.size()));
+                for (Map<String, String> stringStringMap : selectOperationNumMap) {
+                    if (Double.parseDouble(stringStringMap.get("operationFee"))>0){
+                        String behospitalCode = stringStringMap.get("behospitalCode");
+                        operationCode.add(behospitalCode);
+                    }
+                }
+            for (Map<String, String> stringStringMap : selectOperationNumMap) {
+                if (Double.parseDouble(stringStringMap.get("operationFee"))>0 && Double.parseDouble(stringStringMap.get("pathologyFee"))>QualityContent.pathologyFee){
+                    String behospitalCode = stringStringMap.get("behospitalCode");
+                    operationPathologyCode.add(behospitalCode);
+                }
+            }
+            for (Map<String, String> stringStringMap : selectOperationNumMap) {
+                if (Double.parseDouble(stringStringMap.get("antibiosisFee"))>0){
+                    String behospitalCode = stringStringMap.get("behospitalCode");
+                    antibiosisCode.add(behospitalCode);
+                }
+            }
+            //手术人
+                List<String> operationList = adviceNum.get("operation");
+                if(ListUtil.isNotEmpty(operationList)){
+                    for (String s : operationList) {
+                        operationCode.add(s);
+                    }
+                }
+                operationFeeNum = Long.valueOf(String.valueOf(operationCode.size()));
                 //CT人数
-                Long CTNum = adviceNum.get("CT");
+                List<String> ctList = adviceNum.get("CT");
+                Long CTNum=0L;
+                if(ListUtil.isNotEmpty(ctList)) {
+                    CTNum = Long.valueOf(String.valueOf(ctList.size()));
+                }
                 //MR人数
-                Long MRNum = adviceNum.get("MR");
+                List<String> mrList = adviceNum.get("MR");
+                Long MRNum=0L;
+                if(ListUtil.isNotEmpty(ctList)) {
+                    MRNum = Long.valueOf(String.valueOf(mrList.size()));
+                }
                 //手术病理人数
-                Long operationPathologyFeeNum = selectOperationNumMap.get("operationPathologyFee");
-                Long operationPathology = adviceNum.get("operationPathology");
-                operationPathologyFeeNum = operationPathologyFeeNum + operationPathology;
+                List<String> operationPathologyList = adviceNum.get("operationPathology");
+                if(ListUtil.isNotEmpty(operationPathologyList)){
+                    for (String s : operationPathologyList) {
+                        operationPathologyCode.add(s);
+                    }
+                }
+                Long operationPathologyFeeNum = Long.valueOf(operationPathologyCode.size());
                 //抗菌药物人数
-                Long antibiosisFeeNum = selectOperationNumMap.get("antibiosisFee");
-                Long antibiosisNum = adviceNum.get("antibiosis");
-                antibiosisFeeNum = antibiosisFeeNum + antibiosisNum;
+
+                List<String> antibiosisList = adviceNum.get("antibiosis");
+
+                if(ListUtil.isNotEmpty(antibiosisList)) {
+                    for (String s : antibiosisList) {
+                        antibiosisCode.add(s);
+                    }
+                }
+                Long antibiosisFeeNum = Long.valueOf(antibiosisCode.size());
                 //恶性肿瘤化学治疗人数
-                Long chemotherapyMalignantTumorsNum = adviceNum.get("chemotherapyMalignantTumors");
+                List<String> chemotherapyMalignantTumorsList = adviceNum.get("chemotherapyMalignantTumors");
+                Long chemotherapyMalignantTumorsNum =0L;
+                if(ListUtil.isNotEmpty(chemotherapyMalignantTumorsList)) {
+                    chemotherapyMalignantTumorsNum=   Long.valueOf(chemotherapyMalignantTumorsList.size());
+                }
                 //出院人数
                     if(startCount!=null){
                         medIndexResult.setAdmissionResult(Double.valueOf(startCount));
@@ -676,7 +726,42 @@ public class ConsoleFacade {
         medIndexResult.setEndDate(filterVO.getEndDate());
         medIndexResult.setGmtCreate(new Date());
         medIndexResultFacade.save(medIndexResult);
-
+        Integer id = medIndexResult.getId();
+        MedIndexRelevance medIndexRelevance = new MedIndexRelevance();
+        medIndexRelevance.setIndexResultId(id);
+        medIndexRelevance.setHospitalId(filterVO.getHospitalId());
+        medIndexRelevance.setStartDate(filterVO.getStartDate());
+        medIndexRelevance.setEndDate(filterVO.getEndDate());
+        medIndexRelevance.setGmtCreate(new Date());
+        if(ListUtil.isNotEmpty(ctList)) {
+            if(ListUtil.isNotEmpty(operationCode)) {
+                medIndexRelevance.setRelevanceType(4);
+                for (String Code : operationCode) {
+                    medIndexRelevance.setBehospitalCode(Code);
+                    medIndexRelevanceFacade.save(medIndexRelevance);
+                }
+            }
+            medIndexRelevance.setRelevanceType(8);
+            for (String CTCode : ctList) {
+                medIndexRelevance.setBehospitalCode(CTCode);
+                medIndexRelevanceFacade.save(medIndexRelevance);
+            }
+        }
+        if(ListUtil.isNotEmpty(mrList)) {
+            medIndexRelevance.setRelevanceType(9);
+            for (String MrCode : mrList) {
+                medIndexRelevance.setBehospitalCode(MrCode);
+                medIndexRelevanceFacade.save(medIndexRelevance);
+            }
+        }
+            if(ListUtil.isNotEmpty(operationPathologyCode)) {
+                medIndexRelevance.setRelevanceType(10);
+                for (String Code : operationPathologyCode) {
+                    medIndexRelevance.setBehospitalCode(Code);
+                    medIndexRelevanceFacade.save(medIndexRelevance);
+                }
+            }
+        }
     }
     /**
      * 两数据相除得到百分比
@@ -757,10 +842,10 @@ public class ConsoleFacade {
     /**
      * 遍历医嘱信息存入相关数据
      */
-    public Map<String,Long> getAdviceNum(FilterVO filterVO,List<MedManageParamsDTO> doctorAdviceMedManageParamsList) {
+    public Map<String,List<String>> getAdviceNum(FilterVO filterVO, List<MedManageParamsDTO> doctorAdviceMedManageParamsList) {
         CopyOnWriteArrayList<MedManageParamsDTO> doctorAdviceMedManageParams = new CopyOnWriteArrayList<>(doctorAdviceMedManageParamsList);
         String indexName = filterVO.getIndexName();
-        Map map = new HashMap<String,Integer>();
+        Map mapCode = new HashMap<String,List<String>>();
         List<String> CTBehospitalCode = new CopyOnWriteArrayList<>();
         List<String> operationPathologyBehospitalCode = new CopyOnWriteArrayList<>();
         List<String> MRBehospitalCode = new CopyOnWriteArrayList<>();
@@ -892,42 +977,53 @@ public class ConsoleFacade {
             myPool.shutdown();
 
             if(ListUtil.isEmpty(CTBehospitalCode)){
-                map.put("CT",Long.valueOf(0));
+         //       map.put("CT",Long.valueOf(0));
+                mapCode.put("CT",null);
             }else {
-                map.put("CT",Long.valueOf(CTBehospitalCode.size()));
+        //        map.put("CT",Long.valueOf(CTBehospitalCode.size()));
+                mapCode.put("CT",CTBehospitalCode);
             }
             if(ListUtil.isEmpty(MRBehospitalCode)){
-                map.put("MR",Long.valueOf(0));
+         //       map.put("MR",Long.valueOf(0));
+                mapCode.put("MR",null);
             }else {
-                map.put("MR",Long.valueOf(MRBehospitalCode.size()));
+       //         map.put("MR",Long.valueOf(MRBehospitalCode.size()));
+                mapCode.put("MR",MRBehospitalCode);
             }
             if(ListUtil.isEmpty(operationBehospitalCode)){
-                map.put("operation",Long.valueOf(0));
+       //         map.put("operation",Long.valueOf(0));
+                mapCode.put("operation",null);
             }else {
-                map.put("operation",Long.valueOf(operationBehospitalCode.size()));
+       //         map.put("operation",Long.valueOf(operationBehospitalCode.size()));
+                mapCode.put("operation",operationBehospitalCode);
             }
             if(ListUtil.isEmpty(operationBehospitalCode)||ListUtil.isEmpty(operationPathologyBehospitalCode)){
-                map.put("operationPathology",Long.valueOf(0));
+        //        map.put("operationPathology",Long.valueOf(0));
+                mapCode.put("operationPathology",null);
             }else {
                 for (String operation : operationBehospitalCode) {
                     if(pathologyBehospitalCode.contains(operation)){
                         operationPathologyBehospitalCode.add(operation);
                     }
                 }
-                map.put("operationPathology",Long.valueOf(operationPathologyBehospitalCode.size()));
+           //     map.put("operationPathology",Long.valueOf(operationPathologyBehospitalCode.size()));
+                mapCode.put("operationPathology",operationBehospitalCode);
             }
             if(ListUtil.isEmpty(antibiosisBehospitalCode)){
-                map.put("antibiosis",Long.valueOf(0));
+        //        map.put("antibiosis",Long.valueOf(0));
+                mapCode.put("antibiosis",null);
             }else {
-                map.put("antibiosis",Long.valueOf(antibiosisBehospitalCode.size()));
+         //       map.put("antibiosis",Long.valueOf(antibiosisBehospitalCode.size()));
+                mapCode.put("antibiosis",antibiosisBehospitalCode);
             }
             if(ListUtil.isEmpty(chemotherapyMalignantTumorsBehospitalCode)){
-                map.put("chemotherapyMalignantTumors",Long.valueOf(0));
+          //      map.put("chemotherapyMalignantTumors",Long.valueOf(0));
+                mapCode.put("chemotherapyMalignantTumors",null);
             }else {
-                map.put("chemotherapyMalignantTumors",Long.valueOf(chemotherapyMalignantTumorsBehospitalCode.size()));
+       //         map.put("chemotherapyMalignantTumors",Long.valueOf(chemotherapyMalignantTumorsBehospitalCode.size()));
+                mapCode.put("chemotherapyMalignantTumors",antibiosisBehospitalCode);
             }
-
-            return map;
+            return mapCode;
         }
     }
     /**

+ 14 - 0
src/main/java/com/diagbot/facade/MedIndexRelevanceFacade.java

@@ -0,0 +1,14 @@
+package com.diagbot.facade;
+import com.diagbot.service.impl.MedIndexRelevanceServiceImpl;
+
+import org.springframework.stereotype.Component;
+
+
+/**
+ * @Description:
+ * @author: zhoutg
+ * @time: 2020/4/12 11:39
+ */
+@Component
+public class MedIndexRelevanceFacade extends MedIndexRelevanceServiceImpl {
+}

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

@@ -707,7 +707,7 @@ public interface BehospitalInfoMapper extends BaseMapper<BehospitalInfo> {
      * @param filterVO
      * @return
      */
-    public Map<String,Long> selectOperationNum(@Param("filterVO") FilterVO filterVO);
+    public List<Map<String, String>> selectOperationNum(@Param("filterVO") FilterVO filterVO);
 
     /**
      * 病理CT/MR触发多规则人数

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

@@ -0,0 +1,16 @@
+package com.diagbot.mapper;
+
+import com.diagbot.entity.MedIndexRelevance;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author zhanghang
+ * @since 2021-04-30
+ */
+public interface MedIndexRelevanceMapper extends BaseMapper<MedIndexRelevance> {
+
+}

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

@@ -662,7 +662,7 @@ public interface BehospitalInfoService extends IService<BehospitalInfo> {
      * @param filterVO
      * @return
      */
-    public Map<String,Long> selectOperationNum(@Param("filterVO")FilterVO filterVO);
+    public List<Map<String, String>> selectOperationNum(@Param("filterVO")FilterVO filterVO);
 
     /**
      * 触发规则人数

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

@@ -0,0 +1,16 @@
+package com.diagbot.service;
+
+import com.diagbot.entity.MedIndexRelevance;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author zhanghang
+ * @since 2021-04-30
+ */
+public interface MedIndexRelevanceService extends IService<MedIndexRelevance> {
+
+}

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

@@ -1101,7 +1101,7 @@ public class BehospitalInfoServiceImpl extends ServiceImpl<BehospitalInfoMapper,
      * @param  filterVO
      * @return
      */
-    public Map<String,Long> selectOperationNum(@Param("filterVO")FilterVO filterVO){
+    public List<Map<String, String>> selectOperationNum(@Param("filterVO")FilterVO filterVO){
         return  baseMapper.selectOperationNum(filterVO);
 
     }

+ 20 - 0
src/main/java/com/diagbot/service/impl/MedIndexRelevanceServiceImpl.java

@@ -0,0 +1,20 @@
+package com.diagbot.service.impl;
+
+import com.diagbot.entity.MedIndexRelevance;
+import com.diagbot.mapper.MedIndexRelevanceMapper;
+import com.diagbot.service.MedIndexRelevanceService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author zhanghang
+ * @since 2021-04-30
+ */
+@Service
+public class MedIndexRelevanceServiceImpl extends ServiceImpl<MedIndexRelevanceMapper, MedIndexRelevance> implements MedIndexRelevanceService {
+
+}

+ 5 - 51
src/main/resources/mapper/BehospitalInfoMapper.xml

@@ -17582,9 +17582,7 @@
         AND a.is_placefile = #{filterVO.isPlacefile}
         <if test="filterVO.startDate != null and  filterVO.endDate != null">
             <![CDATA[ and a.leave_hospital_date >= #{filterVO.startDate}]]>
-            <![CDATA[ AND a
-
-            .leave_hospital_date <= #{filterVO.endDate}]]>
+            <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
         </if>
         <![CDATA[ and  a.qc_type_id <>'0' ]]>
         AND a.behospital_code = c.behospital_code
@@ -17606,54 +17604,10 @@
     <!--  时间段出院,住院, 手术费,抗菌药物,手术和病理费等含有人数 -->
     <select id="selectOperationNum" parameterType="com.diagbot.vo.FilterVO" resultType="java.util.Map">
         select
-        <if test="filterVO.startDate != null and  filterVO.endDate != null">
-        count(
-        CASE
-        WHEN   <![CDATA[  d.leave_hospital_date >= #{filterVO.startDate}]]>
-            <![CDATA[ AND d.leave_hospital_date <= #{filterVO.endDate}]]> THEN
-        1
-        ELSE
-        NULL
-        END
-        )  AS '出院人数',
-        count(
-        CASE
-        WHEN   <![CDATA[  d.leave_hospital_date >= #{filterVO.startDate}]]>
-            <![CDATA[ AND d.leave_hospital_date <= #{filterVO.endDate}]]> THEN
-        1
-        ELSE
-        NULL
-        END
-        )  AS '入院人数',
-        </if>
-        count(
-        CASE
-        WHEN   b.operation_fee > 0
-        THEN
-        1
-        ELSE
-        NULL
-        END
-        ) AS 'operationFee',
-        count(
-        CASE
-        WHEN   b.antibiosis_fee > 0
-        THEN
-        1
-        ELSE
-        NULL
-        END
-        ) AS 'antibiosisFee',
-        count(
-        CASE
-        WHEN   b.operation_fee > 0
-        AND   b.pathology_fee > 0
-        THEN
-        1
-        ELSE
-        NULL
-        END
-        ) AS 'operationPathologyFee'
+        d.behospital_code behospitalCode,
+        b.operation_fee operationFee,
+        b.pathology_fee pathologyFee,
+        b.antibiosis_fee antibiosisFee
         FROM
         (
         SELECT

+ 21 - 0
src/main/resources/mapper/MedIndexRelevanceMapper.xml

@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.diagbot.mapper.MedIndexRelevanceMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.diagbot.entity.MedIndexRelevance">
+        <id column="id" property="id" />
+        <result column="index_result_id" property="indexResultId" />
+        <result column="relevance_type" property="relevanceType" />
+        <result column="hospital_id" property="hospitalId" />
+        <result column="behospital_code" property="behospitalCode" />
+        <result column="start_date" property="startDate" />
+        <result column="end_date" property="endDate" />
+        <result column="is_deleted" property="isDeleted" />
+        <result column="gmt_create" property="gmtCreate" />
+        <result column="gmt_modified" property="gmtModified" />
+        <result column="creator" property="creator" />
+        <result column="modifier" property="modifier" />
+    </resultMap>
+
+</mapper>