瀏覽代碼

Merge remote-tracking branch 'origin/master'

MarkHuang 4 年之前
父節點
當前提交
717a62a025

+ 1 - 1
src/main/java/com/diagbot/dto/PushBaseDTO.java

@@ -16,5 +16,5 @@ public class PushBaseDTO {
     //条目名称
     private String name;
     //医院端名称
-    private List<String> clientNames;
+    private List<String> hisNameList;
 }

+ 2 - 6
src/main/java/com/diagbot/facade/BillFacade.java

@@ -37,14 +37,10 @@ public class BillFacade {
     public void billFac(IndicationPushVO indicationPushVO, WordCrfDTO wordCrfDTO, IndicationDTO res) {
         // 开单合理性图谱接口调用
         BillNeoVO billNeoVO = fillBillNeo(wordCrfDTO);
-
         List<BillNeoDTO> billNeoDTOList = neoFacade.getBillNeo(billNeoVO);
 
-        // 获取药品缓存信息,现在不用
-        // neoFacade.getDrugCache();
-
-        // 规则开发
-       billProcess.process(billNeoDTOList, wordCrfDTO, res);
+        // 规则处理
+        billProcess.process(billNeoDTOList, wordCrfDTO, res);
     }
 
 

+ 3 - 1
src/main/java/com/diagbot/facade/NeoFacade.java

@@ -14,6 +14,7 @@ import org.springframework.cache.annotation.Cacheable;
 import org.springframework.stereotype.Component;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.List;
@@ -45,7 +46,8 @@ public class NeoFacade {
     @Cacheable(value = "cache", key = "'drugCache'")
     public Map<String, List<String>> getDrugCache() {
         Map<String, List<String>> res = new HashMap<>();
-        res.put("ddd", new ArrayList<>());
+        res.put("泰舒达类", Arrays.asList("泰舒达"));
+        res.put("青霉素类", Arrays.asList("青霉素"));
         return res;
     }
 

+ 39 - 31
src/main/java/com/diagbot/process/BillProcess.java

@@ -1,7 +1,5 @@
 package com.diagbot.process;
 
-import com.diagbot.biz.push.entity.Lis;
-import com.diagbot.biz.push.entity.Pacs;
 import com.diagbot.dto.BillMsg;
 import com.diagbot.dto.BillNeoDTO;
 import com.diagbot.dto.BillNeoMaxDTO;
@@ -9,23 +7,31 @@ import com.diagbot.dto.IndicationDTO;
 import com.diagbot.dto.NodeNeoDTO;
 import com.diagbot.dto.WordCrfDTO;
 import com.diagbot.enums.NeoEnum;
-import com.diagbot.model.entity.*;
+import com.diagbot.facade.NeoFacade;
+import com.diagbot.model.entity.Clinical;
+import com.diagbot.model.entity.Diag;
+import com.diagbot.model.entity.GeneralDesc;
+import com.diagbot.model.entity.Medicine;
+import com.diagbot.model.entity.Operation;
 import com.diagbot.model.label.ChiefLabel;
 import com.diagbot.model.label.DiagLabel;
 import com.diagbot.model.label.PastLabel;
 import com.diagbot.model.label.PresentLabel;
 import com.diagbot.rule.AgeRule;
-import com.diagbot.rule.DiagRule;
+import com.diagbot.rule.CommonRule;
+import com.diagbot.rule.DrugRule;
 import com.diagbot.rule.LisRule;
 import com.diagbot.rule.PacsRule;
 import com.diagbot.rule.SexRule;
 import com.diagbot.util.BeanUtil;
 import com.diagbot.util.ListUtil;
 import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
 /**
  * @Description: 开单总入口
@@ -35,6 +41,9 @@ import java.util.List;
 @Component
 public class BillProcess {
 
+    @Autowired
+    NeoFacade neoFacade;
+
     public void process(List<BillNeoDTO> billNeoDTOList, WordCrfDTO wordCrfDTO, IndicationDTO res) {
         // 合并图谱数据到同一个对象中
         List<BillNeoMaxDTO> billNeoMaxDTOList = new ArrayList<>();
@@ -49,7 +58,7 @@ public class BillProcess {
             }
             billNeoMaxDTO.setOrderName(billNeoDTO.getName()); // 开单名称
             billNeoMaxDTO.setOrderStandName(billNeoDTO.getStandname()); // 开单标准名称
-            // 测试数据开始
+            // TODO 测试数据开始
             if (billNeoDTO.getName().equals("普通胃镜检查")) {
                 NodeNeoDTO sexNeo = new NodeNeoDTO();
                 sexNeo.setName("男");
@@ -68,14 +77,11 @@ public class BillProcess {
                 billNeoDTO.getPacsBillNeoDTO().getOperations().add(opereat2);
 
                 NodeNeoDTO drug = new NodeNeoDTO();
-                drug.setName("拜阿司匹林");
+                drug.setName("青霉素类");
                 billNeoDTO.getPacsBillNeoDTO().getAllergicmeds().add(drug);
-                NodeNeoDTO drug2 = new NodeNeoDTO();
-                drug2.setName("美多芭");
-                billNeoDTO.getPacsBillNeoDTO().getAllergicmeds().add(drug2);
 
                 NodeNeoDTO drug3 = new NodeNeoDTO();
-                drug3.setName("泰舒达");
+                drug3.setName("泰舒达类");
                 billNeoDTO.getPacsBillNeoDTO().getOralmeds().add(drug3);
 
             }
@@ -89,18 +95,23 @@ public class BillProcess {
 
     // 规则处理
     public void processRule(List<BillNeoMaxDTO> billNeoMaxDTOList, WordCrfDTO wordCrfDTO, IndicationDTO indicationDTO) {
+        // 获取药品缓存
+        Map<String, List<String>> drugMap = neoFacade.getDrugCache();
         DiagLabel diagLabel = wordCrfDTO.getDiagLabel();
         ChiefLabel chiefLabel = wordCrfDTO.getChiefLabel();
         PresentLabel presentLabel = wordCrfDTO.getPresentLabel();
         PastLabel pastLabel = wordCrfDTO.getPastLabel();
-        List<Diag> diags = new ArrayList<>();
-        List<Clinical> clinicals = new ArrayList<>();
+
+        // 诊断数据
+        List<Diag> diags = diagLabel.getDiags();
+
+        // 手术数据
         List<Operation> operations_present = presentLabel.getOperations();
         List<Operation> operations_past = pastLabel.getOperations();
         operations_present.addAll(operations_past);
-        if(diagLabel != null){
-            diags = diagLabel.getDiags();
-        }
+
+        // 临床表现数据
+        List<Clinical> clinicals = new ArrayList<>();
         if(chiefLabel != null && ListUtil.isNotEmpty(chiefLabel.getClinicals())){
             clinicals.addAll(chiefLabel.getClinicals());
         }
@@ -108,8 +119,6 @@ public class BillProcess {
         if(presentLabel != null && ListUtil.isNotEmpty(presentLabel.getClinicals())){
             clinicals.addAll(presentLabel.getClinicals());
         }
-        List<Lis> lis = wordCrfDTO.getLis();
-        List<Pacs> pacs = wordCrfDTO.getPacs();
 
         List<BillMsg> billMsgList = new ArrayList<>();
         for (BillNeoMaxDTO bill : billNeoMaxDTOList) {
@@ -120,25 +129,25 @@ public class BillProcess {
             AgeRule.compareAgeWithBill(wordCrfDTO, bill, billMsgList, NeoEnum.ageNeoDTO.getName());
 
             // 诊断
-            DiagRule.compareDiseaseWithBill(bill.getDisease(), diags, bill, billMsgList, NeoEnum.disease.getName());
+            CommonRule.compareNameWithBill(bill.getDisease(), diags, bill, billMsgList, NeoEnum.disease.getName());
 
-            //化验
-            LisRule.compareLisWithBill(lis, bill, billMsgList, NeoEnum.lis.getName());
+            // 化验
+            LisRule.compareLisWithBill(wordCrfDTO.getLis(), bill, billMsgList, NeoEnum.lis.getName());
 
-             //辅检
-            PacsRule.comparePacsWithBill(bill.getPacs(), pacs, bill, billMsgList, NeoEnum.pacs.getName());
+            // 辅检
+            PacsRule.comparePacsWithBill(bill.getPacs(), wordCrfDTO.getPacs(), bill, billMsgList, NeoEnum.pacs.getName());
 
-            //临床表现
-            DiagRule.compareDiseaseWithBill(bill.getClinicfindings(), clinicals, bill, billMsgList, NeoEnum.clinicfindings.getName());
+            // 临床表现
+            CommonRule.compareNameWithBill(bill.getClinicfindings(), clinicals, bill, billMsgList, NeoEnum.clinicfindings.getName());
 
-            //手术(既往史、现病史)
-            DiagRule.compareDiseaseWithBill(bill.getOperations(), operations_present, bill, billMsgList, NeoEnum.operations.getName());
+            // 手术(既往史、现病史)
+            CommonRule.compareNameWithBill(bill.getOperations(), operations_present, bill, billMsgList, NeoEnum.operations.getName());
 
-            //禁忌过敏药品(既往史)
-            DiagRule.compareDiseaseWithBill(bill.getAllergicmeds(), pastLabel.getAllergyMedicines(), bill, billMsgList, NeoEnum.allergicmeds.getName());
+            // 禁忌过敏药品(既往史)
+            DrugRule.compareDrugWithBill(bill.getAllergicmeds(), pastLabel.getAllergyMedicines(), bill, billMsgList, drugMap, NeoEnum.allergicmeds.getName());
 
-            //服用药品(现病史一般情况后的药品)
-            DiagRule.compareDiseaseWithBill(bill.getOralmeds(), takeMedicine(presentLabel), bill, billMsgList, NeoEnum.oralmeds.getName());
+            // 服用药品(现病史一般情况后的药品)
+            DrugRule.compareDrugWithBill(bill.getOralmeds(), takeMedicine(presentLabel), bill, billMsgList, drugMap, NeoEnum.oralmeds.getName());
 
         }
         indicationDTO.setBillMsgList(billMsgList);
@@ -167,6 +176,5 @@ public class BillProcess {
             }
         }
         return takems;
-
     }
 }

+ 52 - 0
src/main/java/com/diagbot/rule/CommonRule.java

@@ -0,0 +1,52 @@
+package com.diagbot.rule;
+
+import com.diagbot.dto.BillMsg;
+import com.diagbot.dto.BillNeoMaxDTO;
+import com.diagbot.dto.NodeNeoDTO;
+import com.diagbot.model.entity.Negative;
+import com.diagbot.util.CoreUtil;
+import com.diagbot.util.ListUtil;
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * @description: 通用规则提取
+ * @author: kwz
+ * @time: 2020/8/3 14:47
+ */
+public class CommonRule {
+
+    /**
+     * 比较界面元素是否在图谱中存在(匹配名称)
+     *
+     * @param neoList 图谱结构
+     * @param inputLises 界面元素
+     * @return
+     */
+    public static <T> void compareNameWithBill(List<NodeNeoDTO> neoList, List<T> inputLises, BillNeoMaxDTO billNeoMaxDTO, List<BillMsg> billMsgList, String type) {
+        Map<String, String> old_stand = new HashMap<>();
+        if (ListUtil.isNotEmpty(neoList) && ListUtil.isNotEmpty(inputLises)) {
+            List<String> dl = neoList.stream().map(x -> x.getName()).collect(Collectors.toList());
+            for (T d : inputLises) {
+                Negative val = (Negative) CoreUtil.getFieldValue(d, "negative");
+                if (val == null) {
+                    String c = (String) CoreUtil.getFieldValue(d, "standName");
+                    String c_name = (String) CoreUtil.getFieldValue(d, "name");
+                    if (StringUtils.isNotBlank(c) && dl.contains(c)) {
+                        old_stand.put(c_name, c);
+                    }
+                }
+            }
+            if (old_stand.size() > 0) {
+                for (Map.Entry<String, String> d : old_stand.entrySet()) {
+                    BillMsg commonBillMsg = CoreUtil.getCommonBillMsg(billNeoMaxDTO.getOrderName(), billNeoMaxDTO.getOrderStandName(), d.getKey(), d.getValue(), type);
+                    billMsgList.add(commonBillMsg);
+                }
+            }
+        }
+    }
+}

+ 0 - 52
src/main/java/com/diagbot/rule/DiagRule.java

@@ -1,52 +0,0 @@
-package com.diagbot.rule;
-
-import com.diagbot.dto.BillMsg;
-import com.diagbot.dto.BillNeoMaxDTO;
-import com.diagbot.dto.NodeNeoDTO;
-import com.diagbot.model.entity.Negative;
-import com.diagbot.util.CoreUtil;
-import com.diagbot.util.ListUtil;
-import org.apache.commons.lang3.StringUtils;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-
-/**
- * @description: 实验室检查和辅助检查规则
- * @author: kwz
- * @time: 2020/8/3 14:47
- */
-public class DiagRule {
-    /**
-     * 比较疾病
-     *
-     * @param drugLises
-     * @param inputLises
-     * @return
-     */
-    public static <T> void compareDiseaseWithBill(List<NodeNeoDTO> drugLises, List<T> inputLises, BillNeoMaxDTO billNeoMaxDTO, List<BillMsg> billMsgList, String type) {
-        Map<String,String> old_stand = new HashMap<>();
-        if(ListUtil.isNotEmpty(drugLises) && ListUtil.isNotEmpty(inputLises)){
-            List<String> dl = drugLises.stream().map(x -> x.getName()).collect(Collectors.toList());
-            for (T d:inputLises) {
-                Negative val = (Negative)CoreUtil.getFieldValue(d, "negative");
-                if(val == null){
-                    String c = (String) CoreUtil.getFieldValue(d, "standName");
-                    String c_name = (String) CoreUtil.getFieldValue(d, "name");
-                    if(StringUtils.isNotBlank(c) && dl.contains(c)){
-                        old_stand.put(c_name,c);
-                    }
-                }
-            }
-            if(old_stand.size() > 0){
-                for (Map.Entry<String,String> d:old_stand.entrySet()) {
-                    BillMsg commonBillMsg = CoreUtil.getCommonBillMsg(billNeoMaxDTO.getOrderName(),billNeoMaxDTO.getOrderStandName(),d.getKey(),d.getValue(), type);
-                    billMsgList.add(commonBillMsg);
-                }
-            }
-        }
-
-    }
-}

+ 60 - 0
src/main/java/com/diagbot/rule/DrugRule.java

@@ -0,0 +1,60 @@
+package com.diagbot.rule;
+
+import com.diagbot.dto.BillMsg;
+import com.diagbot.dto.BillNeoMaxDTO;
+import com.diagbot.dto.NodeNeoDTO;
+import com.diagbot.model.entity.Negative;
+import com.diagbot.util.CoreUtil;
+import com.diagbot.util.ListUtil;
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * @description: 实验室检查和辅助检查规则
+ * @author: kwz
+ * @time: 2020/8/3 14:47
+ */
+public class DrugRule {
+
+    /**
+     * 比较药品是否存在(图谱返回的是药品大类,需要从缓存中获取大类对应的药品名称)
+     *
+     * @param drugLises
+     * @param inputLises
+     * @return
+     */
+    public static <T> void compareDrugWithBill(List<NodeNeoDTO> drugLises, List<T> inputLises, BillNeoMaxDTO billNeoMaxDTO,
+                                               List<BillMsg> billMsgList, Map<String, List<String>> drugMap, String type) {
+        Map<String, String> old_stand = new HashMap<>();
+        if (ListUtil.isNotEmpty(drugLises) && ListUtil.isNotEmpty(inputLises)) {
+            List<String> drugType = drugLises.stream().map(x -> x.getName()).collect(Collectors.toList());
+            List<String> allDrug = new ArrayList<>(); // 所有的药品名称
+            for (String drugT : drugType) {
+                if (drugMap.get(drugT) != null) {
+                    allDrug.addAll(drugMap.get(drugT));
+                }
+            }
+            for (T d : inputLises) {
+                Negative val = (Negative) CoreUtil.getFieldValue(d, "negative");
+                if (val == null) {
+                    String c = (String) CoreUtil.getFieldValue(d, "standName");
+                    String c_name = (String) CoreUtil.getFieldValue(d, "name");
+                    if (StringUtils.isNotBlank(c) && allDrug.contains(c)) {
+                        old_stand.put(c_name, c);
+                    }
+                }
+            }
+            if (old_stand.size() > 0) {
+                for (Map.Entry<String, String> d : old_stand.entrySet()) {
+                    BillMsg commonBillMsg = CoreUtil.getCommonBillMsg(billNeoMaxDTO.getOrderName(), billNeoMaxDTO.getOrderStandName(), d.getKey(), d.getValue(), type);
+                    billMsgList.add(commonBillMsg);
+                }
+            }
+        }
+    }
+}