Bläddra i källkod

诊断依据规则

zhoutg 4 år sedan
förälder
incheckning
38f85170e9

+ 2 - 2
src/main/java/com/diagbot/config/CacheDeleteInit.java

@@ -38,8 +38,8 @@ public class CacheDeleteInit implements CommandLineRunner {
         cacheFacade.getdiseaseFilterCache();
         log.info("CDSS-CORE服务启动加载疾病过滤缓存成功!");
 
-        cacheFacade.loadAllRuleCache();
-        log.info("CDSS-CORE服务启动加载医学知识库中的所有规则缓存成功!");
+        // cacheFacade.loadAllRuleCache();
+        // log.info("CDSS-CORE服务启动加载医学知识库中的所有规则缓存成功!");
 
         cacheFacade.loadAllBaseDiagnoseCache();
         log.info("CDSS-CORE服务启动加载诊断依据缓存成功!");

+ 16 - 0
src/main/java/com/diagbot/dto/ReverseDTO.java

@@ -0,0 +1,16 @@
+package com.diagbot.dto;
+
+import lombok.Data;
+
+/**
+ * @Description:基础推理出参
+ * @Author:zhoutg
+ * @time: 2020/7/29 15:34
+ */
+@Data
+public class ReverseDTO {
+    private String libName; // 标准词名称
+    private String sonName; // 子项名称
+    private Long sonId; // 子项conceptId
+    private Long sonType; // 子项类型
+}

+ 17 - 6
src/main/java/com/diagbot/facade/ConceptInfoFacade.java

@@ -1,21 +1,22 @@
 package com.diagbot.facade;
 
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
+import com.diagbot.dto.ReverseDTO;
 import com.diagbot.entity.ConceptInfo;
 import com.diagbot.enums.IsDeleteEnum;
-import com.diagbot.service.ConceptInfoService;
-import org.springframework.beans.factory.annotation.Autowired;
+import com.diagbot.service.impl.ConceptInfoServiceImpl;
+import com.diagbot.vo.ReverseVO;
 import org.springframework.stereotype.Component;
 
+import java.util.List;
+
 /**
  * @Description:
  * @Author:zhaops
  * @time: 2020/12/28 11:47
  */
 @Component
-public class ConceptInfoFacade {
-    @Autowired
-    ConceptInfoService conceptInfoService;
+public class ConceptInfoFacade extends ConceptInfoServiceImpl {
 
     /**
      * 标准术语名称修改
@@ -30,7 +31,17 @@ public class ConceptInfoFacade {
                 .eq("name", oldName)
                 .eq("type", labelType)
                 .set("name", newName);
-        conceptInfoService.update(updateWrapper);
+        this.update(updateWrapper);
         return true;
     }
+
+    /**
+     * 根据诊断反推
+     *
+     * @param reverseVO
+     * @return
+     */
+    public List<ReverseDTO> getReverseFac(ReverseVO reverseVO) {
+        return this.getReverse(reverseVO);
+    }
 }

+ 6 - 0
src/main/java/com/diagbot/mapper/ConceptInfoMapper.java

@@ -1,7 +1,11 @@
 package com.diagbot.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.diagbot.dto.ReverseDTO;
 import com.diagbot.entity.ConceptInfo;
+import com.diagbot.vo.ReverseVO;
+
+import java.util.List;
 
 /**
  * <p>
@@ -12,4 +16,6 @@ import com.diagbot.entity.ConceptInfo;
  * @since 2020-08-18
  */
 public interface ConceptInfoMapper extends BaseMapper<ConceptInfo> {
+
+    public List<ReverseDTO> getReverse(ReverseVO reverseVO);
 }

+ 38 - 13
src/main/java/com/diagbot/process/PushProcess.java

@@ -9,6 +9,7 @@ import com.diagbot.dto.DiagnoseDTO;
 import com.diagbot.dto.NeoPushDTO;
 import com.diagbot.dto.PushBaseDTO;
 import com.diagbot.dto.PushDTO;
+import com.diagbot.dto.ReverseDTO;
 import com.diagbot.dto.RuleBaseDTO;
 import com.diagbot.dto.TreatDTO;
 import com.diagbot.dto.WordCrfDTO;
@@ -25,6 +26,7 @@ import com.diagbot.enums.PushRelationTypeEnum;
 import com.diagbot.enums.RedisEnum;
 import com.diagbot.enums.StandConvertEnum;
 import com.diagbot.facade.CommonFacade;
+import com.diagbot.facade.ConceptInfoFacade;
 import com.diagbot.facade.KlDiagnoseFacade;
 import com.diagbot.facade.KlRelationFacade;
 import com.diagbot.facade.NeoFacade;
@@ -43,6 +45,7 @@ import com.diagbot.vo.DiseaseItemVO;
 import com.diagbot.vo.IcssVo;
 import com.diagbot.vo.NeoPushVO;
 import com.diagbot.vo.PushVO;
+import com.diagbot.vo.ReverseVO;
 import com.diagbot.vo.neoPushEntity.Diag;
 import com.diagbot.vo.neoPushEntity.DiagVo;
 import com.google.common.collect.Lists;
@@ -58,8 +61,8 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
@@ -96,6 +99,8 @@ public class PushProcess {
     VitalRule vitalRule;
     @Autowired
     GroupRule groupRule;
+    @Autowired
+    ConceptInfoFacade conceptInfoFacade;
 
 
     public PushDTO processIcss(PushVO pushVo) {
@@ -354,12 +359,14 @@ public class PushProcess {
      */
     public PushDTO process(PushVO pushVo, Map<String, Map<String, String>> standConvertMap, WordCrfDTO wordCrfDTO) {
         int length = pushVo.getLength();
-        PushDTO pushDTO = new PushDTO();
-        // 推送诊断
-        pushDiagnose(wordCrfDTO, pushDTO);
-        // List<String> ruleTypeList = Arrays.asList(pushVo.getFeatureType().split(","));
-        // Map<String, List<String>> typeWords = typeWords(standConvertMap);
-        // Map<String, List<PushBaseDTO>> dis = new HashMap<>();
+        // TODO 聚合诊断依据推送的诊断和大数据推送的可能诊断
+        PushDTO pushDTO = pushDiagnose(wordCrfDTO);
+        List<String> ruleTypeList = Arrays.asList(pushVo.getFeatureType().split(","));
+        Map<String, List<String>> typeWords = typeWords(standConvertMap);
+
+        // 根据诊断反推(根据性别和年龄过滤,并根据界面已有信息过滤,根据长度截取)
+        reversePushPackage(pushDTO, ruleTypeList, typeWords, wordCrfDTO, length);
+
         // if (ListUtil.isNotEmpty(push)) {
         //     //先把所有疾病推出来
         //     if (ruleTypeList.contains("7")) {
@@ -384,7 +391,8 @@ public class PushProcess {
      * 根据诊断依据推送疾病
      * @param wordCrfDTO
      */
-    public void pushDiagnose(WordCrfDTO wordCrfDTO, PushDTO pushDTO) {
+    public PushDTO pushDiagnose(WordCrfDTO wordCrfDTO) {
+        PushDTO pushDTO = new PushDTO();
         // 读取所有的诊断依据规则——已去重
         List<BaseDiagnoseDTO> diagnoselist = redisUtil.get(RedisEnum.allBaseDiagnose.getName());
         // 匹配的诊断依据规则
@@ -395,7 +403,7 @@ public class PushProcess {
         List<Clinical> clinicals = commonFacade.getClinicalSource(wordCrfDTO);
         /**---------------------------数据统一处理结束--------------------------------- */
 
-        // TODO 规则处理
+        // 规则处理
         for (BaseDiagnoseDTO base : diagnoselist) {
             RuleBaseDTO ruleBaseDTO = new RuleBaseDTO();
             BeanUtil.copyProperties(base, ruleBaseDTO);
@@ -406,11 +414,12 @@ public class PushProcess {
                         case Symptom: // 症状
                             commonRule.compareNameWithPush(clinicals, ruleBaseDTO, baseIdList, baseIds);
                             break;
-                        case VitalResult: // 体格检查结果
-                            break;
                         case Disease: // 疾病【病史】
                             commonRule.compareNameWithPush(wordCrfDTO.getPastLabel().getDiags(), ruleBaseDTO, baseIdList, baseIds);
                             break;
+                        case VitalResult: // 体格检查结果
+                            vitalRule.push(wordCrfDTO.getVitalLabel(), ruleBaseDTO, baseIdList, baseIds);
+                            break;
                         case Group: // 人群
                             groupRule.push(wordCrfDTO, ruleBaseDTO, baseIdList, baseIds);
                             break;
@@ -428,6 +437,7 @@ public class PushProcess {
                             ageRule.push(wordCrfDTO, ruleBaseDTO, baseIdList, baseIds);
                             break;
                         case Vital: // 体格检查项目
+                            vitalRule.push(wordCrfDTO.getVitalLabel(), ruleBaseDTO, baseIdList, baseIds);
                             break;
                     }
                     break;
@@ -446,6 +456,7 @@ public class PushProcess {
         pushDTO.getDebug().put("诊断依据ID列表", StringUtils.join(baseIdList, ","));
         Map<String, List<PushBaseDTO>> pushDiagnoseDTO = setPushDiagnose(wordCrfDTO, baseIdList);
         pushDTO.setDis(pushDiagnoseDTO);
+        return pushDTO;
     }
 
     /**
@@ -515,14 +526,28 @@ public class PushProcess {
                 words.add(name);
                 words.add(standName);
             });
-            typeWordsMap.put(type, new ArrayList<>(new HashSet<>(words)));
+            typeWordsMap.put(type, new ArrayList<>(new LinkedHashSet<>(words)));
         }
 
         return typeWordsMap;
     }
 
-    private void reversePushPackage(){
+    /**
+     * 6.0 根据诊断反推其他信息
+     *
+     * @param pushDTO
+     * @param ruleTypeList
+     * @param typeWords
+     * @param length
+     */
+    private void reversePushPackage(PushDTO pushDTO, List<String> ruleTypeList, Map<String, List<String>> typeWords, WordCrfDTO wordCrfDTO, int length){
+        // TODO 拼接查询数据的入参
+        ReverseVO reverseVO = new ReverseVO();
+
+        // TODO 查询数据
+        List<ReverseDTO> reverseDTOList = conceptInfoFacade.getReverseFac(reverseVO);
 
+        // TODO 放到对应位置
     }
 
     private void reversePushPackage(int length, PushDTO pushDTO, List<String> ruleTypeList, Map<String, List<String>> typeWords, NeoPushVO pushVO, Map<String, List<PushBaseDTO>> dis) {

+ 15 - 0
src/main/java/com/diagbot/rule/VitalRule.java

@@ -39,6 +39,21 @@ public class VitalRule {
         }
     }
 
+    /**
+     * 比较体征——推送
+     *
+     * @param vitalLabel
+     * @param ruleBaseDTO
+     * @param baseIdList
+     * @param ids
+     */
+    public void push(VitalLabel vitalLabel, RuleBaseDTO ruleBaseDTO, List<Long> baseIdList, String ids) {
+        Map<String, Object> map = CoreUtil.compareVital(ruleBaseDTO, vitalLabel);
+        if (CoreUtil.getMapFlag(map)) {
+            CoreUtil.addSplitString(baseIdList, ids);
+        }
+    }
+
     /**
      * 比较体征——高危手术
      *

+ 6 - 0
src/main/java/com/diagbot/service/ConceptInfoService.java

@@ -1,7 +1,11 @@
 package com.diagbot.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.diagbot.dto.ReverseDTO;
 import com.diagbot.entity.ConceptInfo;
+import com.diagbot.vo.ReverseVO;
+
+import java.util.List;
 
 /**
  * <p>
@@ -12,4 +16,6 @@ import com.diagbot.entity.ConceptInfo;
  * @since 2020-08-18
  */
 public interface ConceptInfoService extends IService<ConceptInfo> {
+
+    public List<ReverseDTO> getReverse(ReverseVO reverseVO);
 }

+ 8 - 0
src/main/java/com/diagbot/service/impl/ConceptInfoServiceImpl.java

@@ -2,11 +2,15 @@ package com.diagbot.service.impl;
 
 import com.baomidou.dynamic.datasource.annotation.DS;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.diagbot.dto.ReverseDTO;
 import com.diagbot.entity.ConceptInfo;
 import com.diagbot.mapper.ConceptInfoMapper;
 import com.diagbot.service.ConceptInfoService;
+import com.diagbot.vo.ReverseVO;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * <p>
  * 静态知识标准术语表 服务实现类
@@ -18,4 +22,8 @@ import org.springframework.stereotype.Service;
 @Service
 @DS("cdss")
 public class ConceptInfoServiceImpl extends ServiceImpl<ConceptInfoMapper, ConceptInfo> implements ConceptInfoService {
+    @Override
+    public List<ReverseDTO> getReverse(ReverseVO reverseVO) {
+        return baseMapper.getReverse(reverseVO);
+    }
 }

+ 19 - 0
src/main/java/com/diagbot/vo/ReverseVO.java

@@ -0,0 +1,19 @@
+package com.diagbot.vo;
+
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @Description:基础推理入参
+ * @Author:zhoutg
+ * @time: 2020/7/29 15:34
+ */
+@Data
+public class ReverseVO {
+    private String libName; // 标准词名称
+    private String libType; // 标准词类型
+    private List<Long> relationType; // 关联类型
+    private Integer sexType;
+    private Double age;
+}

+ 64 - 10
src/main/resources/mapper/ConceptInfoMapper.xml

@@ -4,16 +4,70 @@
 
     <!-- 通用查询映射结果 -->
     <resultMap id="BaseResultMap" type="com.diagbot.entity.ConceptInfo">
-        <id column="id" property="id" />
-        <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" />
-        <result column="name" property="name" />
-        <result column="type" property="type" />
-        <result column="clinical_pathway_name" property="clinicalPathwayName" />
-        <result column="notice_name" property="noticeName" />
+        <id column="id" property="id"/>
+        <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"/>
+        <result column="name" property="name"/>
+        <result column="type" property="type"/>
+        <result column="clinical_pathway_name" property="clinicalPathwayName"/>
+        <result column="notice_name" property="noticeName"/>
     </resultMap>
 
+    <select id="getReverse" resultType="com.diagbot.dto.ReverseDTO">
+        SELECT
+        t.*, e.sex_type,
+        e.min_age,
+        e.max_age
+        FROM
+        (
+        SELECT
+        a.lib_name,
+        d.id sonId,
+        d.lib_type sonType,
+        d.lib_name sonName,
+        c.order_no
+        FROM
+        kl_concept a,
+        kl_relation b,
+        kl_relation_order c,
+        kl_concept d
+        WHERE
+        a.is_deleted = 'N'
+        AND b.is_deleted = 'N'
+        AND c.is_deleted = 'N'
+        AND d.is_deleted = 'N'
+        <if test="libName != null and libName != ''">
+            AND a.lib_name = #{libName}
+        </if>
+        <if test="libType != null and libType != ''">
+            AND a.lib_type = #{libType}
+        </if>
+        AND a.id = b.start_id
+        AND b.end_id = d.id
+        AND b.id = c.t_relation_id
+        <if test="relationType != null and relationType.size() > 0">
+            AND b.relation_id IN
+            <foreach collection="relationType" open="(" close=")" separator="," item="item">
+                #{item}
+            </foreach>
+        </if>
+        ) t
+        LEFT JOIN kl_concept_common e ON t.sonId = e.concept_id
+        AND e.is_deleted = 'N'
+        <if test="sexType != null and sexType != 3 and sexType != ''">
+            and e.sex_type in (3, #{sexType})
+        </if>
+        <if test="age != null and age != ''">
+            <![CDATA[ and ((e.age_begin <= #{age} and e.age_end >= #{age})
+                      OR e.min_age IS NULL
+                      OR e.max_age IS NULL)]]>
+        </if>
+        ORDER BY
+        t.sonType,
+        t.order_no
+    </select>
+
 </mapper>