zhoutg 4 anni fa
parent
commit
37786da149
32 ha cambiato i file con 2227 aggiunte e 973 eliminazioni
  1. 3 3
      src/main/java/com/diagbot/aggregate/IndicationAggregate.java
  2. 20 0
      src/main/java/com/diagbot/dto/LisOtherDTO.java
  3. 22 0
      src/main/java/com/diagbot/dto/RuleExtDTO.java
  4. 26 0
      src/main/java/com/diagbot/dto/RuleSimpleDTO.java
  5. 66 0
      src/main/java/com/diagbot/enums/BaseTypeEnum.java
  6. 68 0
      src/main/java/com/diagbot/enums/ConEnum.java
  7. 81 0
      src/main/java/com/diagbot/enums/LibTypeEnum.java
  8. 66 0
      src/main/java/com/diagbot/enums/RuleTypeEnum.java
  9. 86 44
      src/main/java/com/diagbot/facade/BillFacade.java
  10. 42 4
      src/main/java/com/diagbot/facade/CommonFacade.java
  11. 49 21
      src/main/java/com/diagbot/facade/CriticalFacade.java
  12. 61 59
      src/main/java/com/diagbot/facade/HighRiskFacade.java
  13. 3 6
      src/main/java/com/diagbot/facade/NeoFacade.java
  14. 8 124
      src/main/java/com/diagbot/facade/OtherTipFacade.java
  15. 1 1
      src/main/java/com/diagbot/facade/TestFacade.java
  16. 352 206
      src/main/java/com/diagbot/process/BillProcess.java
  17. 111 12
      src/main/java/com/diagbot/process/CriticalProcess.java
  18. 154 0
      src/main/java/com/diagbot/process/HighRiskProcess.java
  19. 119 53
      src/main/java/com/diagbot/process/OtherTipProcess.java
  20. 45 15
      src/main/java/com/diagbot/rule/AgeRule.java
  21. 161 95
      src/main/java/com/diagbot/rule/CommonRule.java
  22. 23 30
      src/main/java/com/diagbot/rule/DrugRule.java
  23. 80 55
      src/main/java/com/diagbot/rule/GroupRule.java
  24. 221 28
      src/main/java/com/diagbot/rule/LisRule.java
  25. 16 20
      src/main/java/com/diagbot/rule/MedEquRule.java
  26. 88 27
      src/main/java/com/diagbot/rule/PacsRule.java
  27. 26 16
      src/main/java/com/diagbot/rule/SexRule.java
  28. 29 18
      src/main/java/com/diagbot/rule/VitalRule.java
  29. 136 69
      src/main/java/com/diagbot/util/CoreUtil.java
  30. 0 20
      src/main/java/com/diagbot/util/MsgUtil.java
  31. 38 47
      src/main/java/com/diagbot/util/RedisUtil.java
  32. 26 0
      src/main/java/com/diagbot/vo/RuleVO.java

+ 3 - 3
src/main/java/com/diagbot/aggregate/IndicationAggregate.java

@@ -81,7 +81,7 @@ public class IndicationAggregate {
         // 开单合理性
         if (indicationPushVO != null && indicationPushVO.getRuleTypeList().contains("2")) {
             try {
-                billFacade.billFac(indicationPushVO, wordCrfDTO, res);
+                billFacade.billFac(wordCrfDTO, res);
                 CoreUtil.getDebugStr(start, "开单规则耗时", res.getDebug());
             } catch (Exception e) {
                 String errMsg = StringUtil.isNotBlank(indicationPushVO.getIdNum()) ?
@@ -135,7 +135,7 @@ public class IndicationAggregate {
         // 危急值提示
         if (indicationPushVO != null && indicationPushVO.getRuleTypeList().contains("1")) {
             try {
-                criticalFacade.criticalFac(indicationPushVO, wordCrfDTO, res);
+                criticalFacade.criticalFac(wordCrfDTO, res);
                 CoreUtil.getDebugStr(start, "危急值提示耗时", res.getDebug());
                 return res;
             } catch (Exception e) {
@@ -161,7 +161,7 @@ public class IndicationAggregate {
         // 其他提示
         if (indicationPushVO != null && indicationPushVO.getRuleTypeList().contains("4")) {
             try {
-                otherTipFacade.otherTipFac(indicationPushVO, wordCrfDTO, res);
+                otherTipFacade.otherTipFac(wordCrfDTO, res);
                 CoreUtil.getDebugStr(start, "其他值提示耗时", res.getDebug());
                 return res;
             } catch (Exception e) {

+ 20 - 0
src/main/java/com/diagbot/dto/LisOtherDTO.java

@@ -0,0 +1,20 @@
+package com.diagbot.dto;
+
+import lombok.Data;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @Description:
+ * @Author:zhoutg
+ * @time: 2020/8/12 15:53
+ */
+@Data
+public class LisOtherDTO {
+    private String name; // 提示名称
+    private List<String> drugMsg = new ArrayList<>(); // 药品拼接提示语
+    private List<String> diseaseMsg = new ArrayList<>(); // 诊断拼接提示语
+    private List<String> groupMsg = new ArrayList<>(); // 人群拼接提示语
+    private List<String> operationMsg = new ArrayList<>(); // 手术拼接提示语
+}

+ 22 - 0
src/main/java/com/diagbot/dto/RuleExtDTO.java

@@ -0,0 +1,22 @@
+package com.diagbot.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description: 规则扩展类
+ * @author: zhoutg
+ * @time: 2021/2/3 16:34
+ */
+@Getter
+@Setter
+public class RuleExtDTO extends RuleDTO{
+    // 医院名称
+    private String inputName;
+    // 时间
+    private String dateValue;
+    // 类型名称
+    private String libTypeName;
+    // // 剂型
+    private String form;
+}

+ 26 - 0
src/main/java/com/diagbot/dto/RuleSimpleDTO.java

@@ -0,0 +1,26 @@
+package com.diagbot.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description: 规则扩展类
+ * @author: zhoutg
+ * @time: 2021/2/3 16:34
+ */
+@Getter
+@Setter
+public class RuleSimpleDTO {
+    // 医院名称
+    private String inputName;
+    // 标准名称
+    private String libName;
+    // 时间
+    private String dateValue;
+    // 类型名称
+    private String libTypeName;
+    // 剂型
+    private String form;
+    // 提示语
+    private String msg;
+}

+ 66 - 0
src/main/java/com/diagbot/enums/BaseTypeEnum.java

@@ -0,0 +1,66 @@
+package com.diagbot.enums;
+
+import com.diagbot.core.KeyedNamed;
+import lombok.Setter;
+
+/**
+ * @author zhoutg
+ * @Description: 类型枚举
+ * @date 2018年10月11日 下午3:33:22
+ */
+
+public enum BaseTypeEnum implements KeyedNamed {
+
+    B1(1, "开单外等于术语本身"),
+    B2(2, "开单外存在比较"),
+    B3(3, "开单外不等于术语本身"),
+    B4(4, "过敏原"),
+    B5(5, "开单项"),
+    B6(6, "检查结果正则表达式");
+
+    @Setter
+    private int key;
+
+    @Setter
+    private String name;
+
+    BaseTypeEnum(int key, String name) {
+        this.key = key;
+        this.name = name;
+    }
+
+    public static BaseTypeEnum getEnum(int key) {
+        for (BaseTypeEnum item : BaseTypeEnum.values()) {
+            if (item.key == key) {
+                return item;
+            }
+        }
+        return null;
+    }
+
+    public static BaseTypeEnum getEnum(String value) {
+        for (BaseTypeEnum item : BaseTypeEnum.values()) {
+            if (item.getName().equals(value)) {
+                return item;
+            }
+        }
+        return null;
+    }
+
+    public static String getName(int key) {
+        BaseTypeEnum item = getEnum(key);
+        return item != null ? item.name : null;
+    }
+
+    @Override
+    public int getKey() {
+        return key;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+
+}

+ 68 - 0
src/main/java/com/diagbot/enums/ConEnum.java

@@ -0,0 +1,68 @@
+package com.diagbot.enums;
+
+import com.diagbot.core.KeyedNamed;
+import lombok.Setter;
+
+/**
+ * @author zhoutg
+ * @Description: 禁忌枚举类型
+ * @date 2018年10月11日 下午3:33:22
+ */
+
+public enum ConEnum implements KeyedNamed {
+
+    gender(1, "禁忌性别"),
+    age(2, "禁忌年龄"),
+    clinicfindings(3, "禁忌临床表现"),
+    oralmeds(4, "禁忌服用药品"),
+    allergicmeds(5, "禁忌过敏药品"),
+    operations(6, "禁忌手术"),
+    procedures(7, "禁忌操作"),
+    lis(8, "禁忌实验室检查"),
+    pacs(9, "禁忌辅助检查"),
+    disease(10, "禁忌疾病"),
+    group(11, "禁忌人群"),
+    conflictmeds(12, "配伍禁忌"),
+    vitals(13, "禁忌查体"),
+    pacsDesc(14, "禁忌辅助检查描述"),
+    medEqu(15, "禁忌医疗器械及物品"),
+    exclusion(16, "开单项互斥"),
+    otherAllergy(17, "禁忌其他过敏原");
+
+    @Setter
+    private int key;
+
+    @Setter
+    private String name;
+
+    ConEnum(int key, String name) {
+        this.key = key;
+        this.name = name;
+    }
+
+    public static ConEnum getEnum(int key) {
+        for (ConEnum item : ConEnum.values()) {
+            if (item.key == key) {
+                return item;
+            }
+        }
+        return null;
+    }
+
+    public static String getName(int key) {
+        ConEnum item = getEnum(key);
+        return item != null ? item.name : null;
+    }
+
+    @Override
+    public int getKey() {
+        return key;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+
+}

+ 81 - 0
src/main/java/com/diagbot/enums/LibTypeEnum.java

@@ -0,0 +1,81 @@
+package com.diagbot.enums;
+
+import com.diagbot.core.KeyedNamed;
+import lombok.Setter;
+
+/**
+ * @description: 词性类型枚举
+ * @author: zhoutg
+ * @date: 2021/2/22 13:44
+ */
+public enum LibTypeEnum implements KeyedNamed {
+
+    disease(100, "疾病"),
+    drug(101, "药品通用名"),
+    clinical(103, "症状"),
+    vital(104, "体格检查项目"),
+    vitalRes(105, "体格检查结果"),
+    operation(106, "手术和操作"),
+    lis(107, "实验室检查套餐"),
+    lisDetail(108, "实验室检查子项目"),
+    pacs(109, "辅助检查项目"),
+    pacsSub(110, "辅助检查子项目"),
+    pacsResult(112, "辅助检查结果"),
+    transfusion(113, "输血类型"),
+    sex(116, "性别"),
+    group(117, "人群"),
+    otherAllergy(119, "其他过敏原"),
+    ylqxjwp(120, "医疗器械及物品"),
+    yphxwzlb(301, "药品化学物质类别"),
+    ypzlxlb(302, "药品治疗学类别"),
+    ypylxlb(303, "药品药理学类别"),
+    ypjpxlb(304, "药品解剖学类别"),
+    age(410, "年龄"),
+    ;
+
+    @Setter
+    private int key;
+
+    @Setter
+    private String name;
+
+    LibTypeEnum(int key, String name) {
+        this.key = key;
+        this.name = name;
+    }
+
+    public static LibTypeEnum getEnum(int key) {
+        for (LibTypeEnum item : LibTypeEnum.values()) {
+            if (item.key == key) {
+                return item;
+            }
+        }
+        return null;
+    }
+
+    public static LibTypeEnum getEnum(String value) {
+        for (LibTypeEnum item : LibTypeEnum.values()) {
+            if (item.getName().equals(value)) {
+                return item;
+            }
+        }
+        return null;
+    }
+
+    public static String getName(int key) {
+        LibTypeEnum item = getEnum(key);
+        return item != null ? item.name : null;
+    }
+
+    @Override
+    public int getKey() {
+        return key;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+
+}

+ 66 - 0
src/main/java/com/diagbot/enums/RuleTypeEnum.java

@@ -0,0 +1,66 @@
+package com.diagbot.enums;
+
+import com.diagbot.core.KeyedNamed;
+import lombok.Setter;
+
+/**
+ * @author zhoutg
+ * @Description: 类型枚举
+ * @date 2018年10月11日 下午3:33:22
+ */
+
+public enum RuleTypeEnum implements KeyedNamed {
+
+    bill(1, "开单合理性"),
+    high(2, "高危"),
+    critical(3, "危急值"),
+    other(4, "其他值提醒"),
+    transfusion(5, "其他值提醒输血"),
+    repeat(6, "正常项目重复开立");
+
+    @Setter
+    private int key;
+
+    @Setter
+    private String name;
+
+    RuleTypeEnum(int key, String name) {
+        this.key = key;
+        this.name = name;
+    }
+
+    public static RuleTypeEnum getEnum(int key) {
+        for (RuleTypeEnum item : RuleTypeEnum.values()) {
+            if (item.key == key) {
+                return item;
+            }
+        }
+        return null;
+    }
+
+    public static RuleTypeEnum getEnum(String value) {
+        for (RuleTypeEnum item : RuleTypeEnum.values()) {
+            if (item.getName().equals(value)) {
+                return item;
+            }
+        }
+        return null;
+    }
+
+    public static String getName(int key) {
+        RuleTypeEnum item = getEnum(key);
+        return item != null ? item.name : null;
+    }
+
+    @Override
+    public int getKey() {
+        return key;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+
+}

+ 86 - 44
src/main/java/com/diagbot/facade/BillFacade.java

@@ -3,21 +3,22 @@ package com.diagbot.facade;
 import com.diagbot.biz.push.entity.Item;
 import com.diagbot.biz.push.entity.Lis;
 import com.diagbot.biz.push.entity.Pacs;
-import com.diagbot.dto.BillNeoDTO;
 import com.diagbot.dto.IndicationDTO;
 import com.diagbot.dto.WordCrfDTO;
+import com.diagbot.enums.LibTypeEnum;
+import com.diagbot.enums.RuleTypeEnum;
+import com.diagbot.enums.TypeEnum;
 import com.diagbot.process.BillProcess;
+import com.diagbot.util.RedisUtil;
 import com.diagbot.util.StringUtil;
-import com.diagbot.vo.BillNeoVO;
 import com.diagbot.vo.Drug;
-import com.diagbot.vo.IndicationPushVO;
 import com.diagbot.vo.ItemExt;
+import com.diagbot.vo.RuleVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
-import java.util.HashMap;
+import java.util.ArrayList;
 import java.util.List;
-import java.util.Map;
 
 /**
  * @Description: 开单合理性facade
@@ -33,69 +34,110 @@ public class BillFacade {
     BillProcess billProcess;
     @Autowired
     CommonFacade commonFacade;
+    @Autowired
+    RedisUtil redisUtil;
 
     /**
      * 开单合理性业务
+     *
      * @param
      * @return
      */
-    public void billFac(IndicationPushVO indicationPushVO, WordCrfDTO wordCrfDTO, IndicationDTO res) {
-        // 开单合理性图谱接口调用
-        BillNeoVO billNeoVO = fillBillNeo(wordCrfDTO);
-        List<BillNeoDTO> billNeoDTOList = neoFacade.getBillNeo(billNeoVO);
-
-        // 规则处理
-        billProcess.process(billNeoDTOList, wordCrfDTO, res);
+    public void billFac(WordCrfDTO wordCrfDTO, IndicationDTO res) {
+        // 获取开单项入参
+        List<RuleVO> ruleVOList = getRuleVO(wordCrfDTO);
+        billProcess.processRule(ruleVOList, wordCrfDTO, res);
 
         // 结果去重处理
         commonFacade.dealMsg(res.getBillMsgList());
     }
 
-    public BillNeoVO fillBillNeo(WordCrfDTO wordCrfDTO) {
-        BillNeoVO billNeoVO = new BillNeoVO();
-
-        List<Drug> drugs = wordCrfDTO.getDrugOrder();
-
-        for (Drug item : drugs) {
-            billNeoVO.getDrugList().add(new HashMap<String, Drug>()
-                        {{put(item.getName(), item);}});
+    /**
+     * 获取开单项入参
+     *
+     * @param wordCrfDTO
+     * @return
+     */
+    public List<RuleVO> getRuleVO(WordCrfDTO wordCrfDTO) {
+        List<RuleVO> ruleVOList = new ArrayList<>();
+        // 药品
+        List<Drug> drugOrder = wordCrfDTO.getDrugOrder();
+        for (Drug item : drugOrder) {
+            if (StringUtil.isNotBlank(item.getUniqueName())) {
+                RuleVO ruleVO = new RuleVO();
+                ruleVO.setInputName(item.getName());
+                ruleVO.setLibName(item.getUniqueName());
+                ruleVO.setLibType(LibTypeEnum.drug.getKey());
+                ruleVO.setLibTypeName(TypeEnum.drug.getName());
+                ruleVO.setDateValue(item.getDateValue());
+                ruleVOList.add(ruleVO);
+            }
         }
 
-        List<Pacs> pacslist = wordCrfDTO.getPacsOrder();
-        for (Pacs pacs : pacslist) {
-            billNeoVO.getPacsList().add(new HashMap<String, String>()
-                        {{put(pacs.getName(), pacs.getUniqueName());}});
-        }
+        // 辅检
+        List<Pacs> pacsOrder = wordCrfDTO.getPacsOrder();
+        for (Pacs pacs : pacsOrder) {
+            if (StringUtil.isNotBlank(pacs.getUniqueName())) {
+                RuleVO ruleVO = new RuleVO();
+                ruleVO.setInputName(pacs.getName());
+                ruleVO.setLibName(pacs.getUniqueName());
+                ruleVO.setLibType(LibTypeEnum.pacs.getKey());
+                ruleVO.setLibTypeName(TypeEnum.pacs.getName());
+                ruleVO.setDateValue(pacs.getDateValue());
+                ruleVOList.add(ruleVO);
 
-        List<Lis> lislist = wordCrfDTO.getLisOrder();
-        for (Lis lis : lislist) {
-            if (StringUtil.isBlank(lis.getDetailName())) {
-                billNeoVO.getLisList().add(new HashMap<String, String>()
-                        {{put(lis.getName(), lis.getUniqueName());}});
+                RuleVO ruleVO1 = new RuleVO();
+                ruleVO1.setInputName(pacs.getName());
+                ruleVO1.setLibName(pacs.getUniqueName());
+                ruleVO1.setLibType(LibTypeEnum.pacs.getKey());
+                ruleVO1.setLibTypeName(TypeEnum.pacs.getName());
+                ruleVO1.setSuffix(String.valueOf(RuleTypeEnum.repeat.getKey()));
+                ruleVO1.setDateValue(pacs.getDateValue());
+                ruleVOList.add(ruleVO1);
             }
-            else {
-                billNeoVO.getLisDetailList().add(new HashMap<String, String>()
-                        {{put(lis.getName(), lis.getUniqueName());}});
+        }
+
+        // 化验套餐
+        List<Lis> lisOrder = wordCrfDTO.getLisOrder();
+        for (Lis lis : lisOrder) {
+            if (StringUtil.isNotBlank(lis.getUniqueName())) {
+                RuleVO ruleVO = new RuleVO();
+                ruleVO.setInputName(lis.getName());
+                ruleVO.setLibName(lis.getUniqueName());
+                ruleVO.setLibType(LibTypeEnum.lis.getKey());
+                ruleVO.setLibTypeName(TypeEnum.lis.getName());
+                ruleVO.setDateValue(lis.getDateValue());
+                ruleVOList.add(ruleVO);
             }
         }
 
+        // 手术和操作开单项
         List<Item> operations = wordCrfDTO.getOperationOrder();
         for (Item item : operations) {
-            billNeoVO.getOperationList().add(new HashMap<String, String>()
-                        {{put(item.getName(), item.getUniqueName());}});
-        }
-
-        List<Item> diags = wordCrfDTO.getDiagOrder();
-        for (Item item : diags) {
-            billNeoVO.getDiagList().add(new HashMap<String, String>()
-                        {{put(item.getName(), item.getUniqueName());}});
+            if (StringUtil.isNotBlank(item.getUniqueName())) {
+                RuleVO ruleVO = new RuleVO();
+                ruleVO.setInputName(item.getName());
+                ruleVO.setLibName(item.getUniqueName());
+                ruleVO.setLibType(LibTypeEnum.operation.getKey());
+                ruleVO.setLibTypeName(TypeEnum.operation.getName());
+                ruleVO.setDateValue(item.getDateValue());
+                ruleVOList.add(ruleVO);
+            }
         }
 
+        // 输血开单项
         List<ItemExt> transfusions = wordCrfDTO.getTransfusionOrder();
         for (ItemExt item : transfusions) {
-            billNeoVO.getTransfusionList().add(new HashMap<String, String>()
-                        {{put(item.getName(), item.getUniqueName());}});
+            if (StringUtil.isNotBlank(item.getUniqueName())) {
+                RuleVO ruleVO = new RuleVO();
+                ruleVO.setInputName(item.getName());
+                ruleVO.setLibName(item.getUniqueName());
+                ruleVO.setLibType(LibTypeEnum.transfusion.getKey());
+                ruleVO.setLibTypeName(TypeEnum.transfusion.getName());
+                ruleVO.setDateValue(item.getDateValue());
+                ruleVOList.add(ruleVO);
+            }
         }
-        return billNeoVO;
+        return ruleVOList;
     }
 }

+ 42 - 4
src/main/java/com/diagbot/facade/CommonFacade.java

@@ -4,12 +4,18 @@ import com.diagbot.biz.push.entity.Item;
 import com.diagbot.biz.push.entity.Lis;
 import com.diagbot.client.CRFServiceClient;
 import com.diagbot.dto.BillMsg;
+import com.diagbot.dto.RuleDTO;
+import com.diagbot.dto.RuleExtDTO;
 import com.diagbot.dto.WordCrfDTO;
+import com.diagbot.enums.LibTypeEnum;
+import com.diagbot.enums.RedisEnum;
 import com.diagbot.enums.StandConvertEnum;
 import com.diagbot.model.ai.AIAnalyze;
 import com.diagbot.model.entity.BodyPart;
+import com.diagbot.model.entity.Clinical;
 import com.diagbot.model.entity.Modification;
 import com.diagbot.model.entity.Pacs;
+import com.diagbot.model.entity.Vital;
 import com.diagbot.model.label.ChiefLabel;
 import com.diagbot.model.label.DiagLabel;
 import com.diagbot.model.label.PacsLabel;
@@ -17,10 +23,13 @@ import com.diagbot.model.label.PastLabel;
 import com.diagbot.model.label.PresentLabel;
 import com.diagbot.model.label.VitalLabel;
 import com.diagbot.rule.CommonRule;
+import com.diagbot.util.BeanUtil;
 import com.diagbot.util.CoreUtil;
 import com.diagbot.util.ListUtil;
+import com.diagbot.util.RedisUtil;
 import com.diagbot.util.StringUtil;
 import com.diagbot.vo.NeoPushVO;
+import com.diagbot.vo.RuleVO;
 import com.diagbot.vo.SearchData;
 import com.diagbot.vo.StandConvert;
 import com.diagbot.vo.neoPushEntity.ChiefPushVo;
@@ -57,6 +66,8 @@ public class CommonFacade {
     PacsConfigFacade pacsConfigFacade;
     @Autowired
     CommonRule commonRule;
+    @Autowired
+    RedisUtil redisUtil;
 
     //组装好的label
     public WordCrfDTO crf_process(SearchData searchData) {
@@ -296,8 +307,8 @@ public class CommonFacade {
         CoreUtil.setPropertyList(wordCrfDTO.getPacsOrder(), "name", "uniqueName", map.get(StandConvertEnum.pacs.toString()));
 
         // 【体征回填】
-        CoreUtil.setPropertyList(vitalLabel.getVitals(), map.get(StandConvertEnum.vital.toString()));
-        CoreUtil.setPropertyList(vitalLabel.getClinicals(), map.get(StandConvertEnum.vital.toString()));
+        // CoreUtil.setPropertyList(vitalLabel.getVitals(), map.get(StandConvertEnum.vital.toString()));
+        // CoreUtil.setPropertyList(vitalLabel.getClinicals(), map.get(StandConvertEnum.vital.toString()));
 
         // 【手术回填】
         // 1、主诉手术
@@ -449,10 +460,10 @@ public class CommonFacade {
         PresentLabel presentLabel = wordCrfDTO.getPresentLabel();
         VitalLabel vitalLabel = wordCrfDTO.getVitalLabel();
         if (ListUtil.isNotEmpty(presentLabel.getVitals())) {
-            vitalLabel.getVitals().addAll(presentLabel.getVitals());
+            vitalLabel.getVitals().addAll(BeanUtil.listCopyTo(presentLabel.getVitals(), Vital.class));
         }
         if (ListUtil.isNotEmpty(presentLabel.getClinicals())) {
-            vitalLabel.getClinicals().addAll(presentLabel.getClinicals());
+            vitalLabel.getClinicals().addAll(BeanUtil.listCopyTo(presentLabel.getClinicals(), Clinical.class));
         }
     }
 
@@ -662,5 +673,32 @@ public class CommonFacade {
             }
         }
     }
+
+    /**
+     * 获取开单项数据,如没有redis数据,则返回null
+     *
+     * @param ruleVO
+     * @return
+     */
+    public RuleExtDTO getRuleData(RuleVO ruleVO) {
+        RuleExtDTO ruleExtDTO = null;
+        // 获取规则数据
+        RuleDTO ruleDTO = redisUtil.get(RedisEnum.allRule.getName() + ruleVO.getLibType() + "_" + ruleVO.getLibName() + "_" + ruleVO.getSuffix());
+        if (ruleDTO == null) {
+            // 辅检特殊处理,如果为空,再获取【辅助检查项目】【辅助检查子项目】中另外一个
+            if (ruleVO.getLibType().equals(LibTypeEnum.pacs.getKey())) {
+                ruleDTO = redisUtil.get("allRule:" + LibTypeEnum.pacsSub.getKey() + "_" + ruleVO.getLibName() + "_" + ruleVO.getSuffix());
+            } else if (ruleVO.getLibType().equals(LibTypeEnum.pacsSub.getKey())) {
+                ruleDTO = redisUtil.get("allRule:" + LibTypeEnum.pacs.getKey() + "_" + ruleVO.getLibName() + "_" + ruleVO.getSuffix());
+            }
+        }
+        if (ruleDTO != null) {
+            ruleExtDTO = new RuleExtDTO();
+            BeanUtil.copyProperties(ruleVO, ruleExtDTO);
+            BeanUtil.copyProperties(ruleDTO, ruleExtDTO);
+            return ruleExtDTO;
+        }
+        return ruleExtDTO;
+    }
 }
 

+ 49 - 21
src/main/java/com/diagbot/facade/CriticalFacade.java

@@ -1,14 +1,19 @@
 package com.diagbot.facade;
 
-import com.diagbot.dto.CriticalNeoDTO;
+import com.diagbot.biz.push.entity.Lis;
+import com.diagbot.biz.push.entity.Pacs;
 import com.diagbot.dto.IndicationDTO;
 import com.diagbot.dto.WordCrfDTO;
+import com.diagbot.enums.LibTypeEnum;
+import com.diagbot.enums.RuleTypeEnum;
+import com.diagbot.enums.TypeEnum;
 import com.diagbot.process.CriticalProcess;
-import com.diagbot.vo.CriticalNeoVO;
-import com.diagbot.vo.IndicationPushVO;
+import com.diagbot.util.StringUtil;
+import com.diagbot.vo.RuleVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -31,30 +36,53 @@ public class CriticalFacade {
      * @param
      * @return
      */
-    public void criticalFac(IndicationPushVO indicationPushVO, WordCrfDTO wordCrfDTO, IndicationDTO res) {
-        // 危急值图谱接口调用
-        CriticalNeoVO criticalNeoVOs = fillCriticalNeo(wordCrfDTO);
-        List<CriticalNeoDTO> criticalNeoDTOList = neoFacade.getCritialNeo(criticalNeoVOs);
-
-        criticalProcess.process(criticalNeoDTOList, wordCrfDTO, res);
-
+    public void criticalFac(WordCrfDTO wordCrfDTO, IndicationDTO res) {
+        // 化验危急值
+        criticalProcess.processLis(wordCrfDTO, res);
+        // 辅检危急值
+        criticalProcess.processPacs(wordCrfDTO, res);
         // 结果去重处理
         commonFacade.dealMsg(res.getCriticalValList());
     }
 
 
 
+    /**
+     * 获取危急值入参
+     *
+     * @param wordCrfDTO
+     * @return
+     */
+    public List<RuleVO> getRuleVO(WordCrfDTO wordCrfDTO) {
+        List<RuleVO> ruleVOList = new ArrayList<>();
+        // 化验数值
+        List<Lis> lisList = wordCrfDTO.getLis();
+        for (Lis lis : lisList) {
+            if (StringUtil.isNotBlank(lis.getUniqueName())) {
+                RuleVO ruleVO = new RuleVO();
+                ruleVO.setInputName(lis.getName());
+                ruleVO.setLibName(lis.getUniqueName());
+                ruleVO.setLibType(LibTypeEnum.lis.getKey());
+                ruleVO.setLibTypeName(TypeEnum.lis.getName());
+                ruleVO.setDateValue(lis.getDateValue());
+                ruleVO.setSuffix(String.valueOf(RuleTypeEnum.critical.getKey()));
+                ruleVOList.add(ruleVO);
+            }
+        }
 
-    public CriticalNeoVO fillCriticalNeo(WordCrfDTO wordCrfDTO) {
-        CriticalNeoVO criticalNeoVO = new CriticalNeoVO();
-
-        criticalNeoVO.setAge(wordCrfDTO.getAgeNum());
-        criticalNeoVO.setSex(wordCrfDTO.getSex());
-        criticalNeoVO.setVitalLabel(wordCrfDTO.getVitalLabel());
-        criticalNeoVO.setLis(wordCrfDTO.getLis());
-        criticalNeoVO.setPacsLabel(wordCrfDTO.getPacsLabel());
-
-
-        return criticalNeoVO;
+        // 辅检
+        List<Pacs> pacsList = wordCrfDTO.getPacs();
+        for (Pacs pacs : pacsList) {
+            if (StringUtil.isNotBlank(pacs.getUniqueName())) {
+                RuleVO ruleVO = new RuleVO();
+                ruleVO.setInputName(pacs.getName());
+                ruleVO.setLibName(pacs.getUniqueName());
+                ruleVO.setLibType(LibTypeEnum.pacs.getKey());
+                ruleVO.setLibTypeName(TypeEnum.pacs.getName());
+                ruleVO.setDateValue(pacs.getDateValue());
+                ruleVOList.add(ruleVO);
+            }
+        }
+        return ruleVOList;
     }
 }

+ 61 - 59
src/main/java/com/diagbot/facade/HighRiskFacade.java

@@ -1,7 +1,6 @@
 package com.diagbot.facade;
 
 import com.diagbot.biz.push.entity.Item;
-import com.diagbot.dto.HighRiskNeoDTO;
 import com.diagbot.dto.IndicationDTO;
 import com.diagbot.dto.WordCrfDTO;
 import com.diagbot.process.HighRiskProcess;
@@ -33,65 +32,68 @@ public class HighRiskFacade {
      * @return
      */
     public void highRiskFac(IndicationPushVO indicationPushVO, WordCrfDTO wordCrfDTO, IndicationDTO res) {
-        // 高风险图谱接口调用
-        // HighRiskNeoVO highRiskNeoVO = fillHighRiskNeo(wordCrfDTO);
-        List<HighRiskNeoDTO> highRiskNeoDTOList = neoFacade.getHighRiskNeo(wordCrfDTO);
-        // 规则处理
-        // TODO 测试数据开始
-        // HighRiskNeoDTO highRiskNeoDTO = new HighRiskNeoDTO();
-        // highRiskNeoDTO.setIsHighrisk(false);
-        // highRiskNeoDTO.setName("锁骨下动脉药物洗脱支架置入术");
-        // highRiskNeoDTO.setStandname("锁骨下动脉药物洗脱支架置入术");
-        // highRiskNeoDTO.setType("手术");
-        // List<NodeNeoDTO> factor = highRiskNeoDTO.getFactor();
-        // NodeNeoDTO nodeNeo = new NodeNeoDTO();
-        // nodeNeo.setTermtype("诊断");
-        // nodeNeo.setName("急性胰腺炎");
-        // factor.add(nodeNeo);
-        // NodeNeoDTO nodeLis = new NodeNeoDTO();
-        // nodeLis.setTermtype("化验");
-        // nodeLis.setName("白细胞计数");
-        // nodeLis.setMax(new BigDecimal(20));
-        // nodeLis.setMin(new BigDecimal(10));
-        // nodeLis.setValType(0);
-        // factor.add(nodeLis);
-        // NodeNeoDTO nodeLis1 = new NodeNeoDTO();
-        // nodeLis1.setTermtype("化验");
-        // nodeLis1.setName("红细胞压积");
-        // nodeLis1.setVal("阳性");
-        // factor.add(nodeLis1);
-        //
-        // NodeNeoDTO nodePass = new NodeNeoDTO();
-        // nodePass.setTermtype("辅检");
-        // nodePass.setName("胸部CT");
-        // nodePass.setVal("肺叶根治性切除标本");
-        // factor.add(nodePass);
-        // NodeNeoDTO vital = new NodeNeoDTO();
-        // vital.setName("体温");
-        // vital.setMax(new BigDecimal("39.1"));
-        // vital.setMin(new BigDecimal("35.1"));
-        // vital.setValType(1);
-        // vital.setTermtype("查体");
-        // factor.add(vital);
+        // 高危药品 TODO
+
+        // 高危手术 TODO
+        // // 高风险图谱接口调用
+        // // HighRiskNeoVO highRiskNeoVO = fillHighRiskNeo(wordCrfDTO);
+        // List<HighRiskNeoDTO> highRiskNeoDTOList = neoFacade.getHighRiskNeo(wordCrfDTO);
+        // // 规则处理
+        // // TODO 测试数据开始
+        // // HighRiskNeoDTO highRiskNeoDTO = new HighRiskNeoDTO();
+        // // highRiskNeoDTO.setIsHighrisk(false);
+        // // highRiskNeoDTO.setName("锁骨下动脉药物洗脱支架置入术");
+        // // highRiskNeoDTO.setStandname("锁骨下动脉药物洗脱支架置入术");
+        // // highRiskNeoDTO.setType("手术");
+        // // List<NodeNeoDTO> factor = highRiskNeoDTO.getFactor();
+        // // NodeNeoDTO nodeNeo = new NodeNeoDTO();
+        // // nodeNeo.setTermtype("诊断");
+        // // nodeNeo.setName("急性胰腺炎");
+        // // factor.add(nodeNeo);
+        // // NodeNeoDTO nodeLis = new NodeNeoDTO();
+        // // nodeLis.setTermtype("化验");
+        // // nodeLis.setName("白细胞计数");
+        // // nodeLis.setMax(new BigDecimal(20));
+        // // nodeLis.setMin(new BigDecimal(10));
+        // // nodeLis.setValType(0);
+        // // factor.add(nodeLis);
+        // // NodeNeoDTO nodeLis1 = new NodeNeoDTO();
+        // // nodeLis1.setTermtype("化验");
+        // // nodeLis1.setName("红细胞压积");
+        // // nodeLis1.setVal("阳性");
+        // // factor.add(nodeLis1);
+        // //
+        // // NodeNeoDTO nodePass = new NodeNeoDTO();
+        // // nodePass.setTermtype("辅检");
+        // // nodePass.setName("胸部CT");
+        // // nodePass.setVal("肺叶根治性切除标本");
+        // // factor.add(nodePass);
+        // // NodeNeoDTO vital = new NodeNeoDTO();
+        // // vital.setName("体温");
+        // // vital.setMax(new BigDecimal("39.1"));
+        // // vital.setMin(new BigDecimal("35.1"));
+        // // vital.setValType(1);
+        // // vital.setTermtype("查体");
+        // // factor.add(vital);
+        // // //
+        // // NodeNeoDTO vitalBp = new NodeNeoDTO();
+        // // vitalBp.setName("意识模糊");
+        // // vitalBp.setValType(1);
+        // // vitalBp.setVal("意识模糊");
+        // // vitalBp.setTermtype("查体");
+        // // factor.add(vitalBp);
+        // //
+        // // NodeNeoDTO vitalBp2 = new NodeNeoDTO();
+        // // vitalBp2.setName("年龄");
+        // // vitalBp2.setMax(new BigDecimal("1"));
+        // // vitalBp2.setMin(new BigDecimal("18"));
+        // // vitalBp2.setValType(1);
+        // // vitalBp2.setTermtype("年龄");
+        // // factor.add(vitalBp2);
         // //
-        // NodeNeoDTO vitalBp = new NodeNeoDTO();
-        // vitalBp.setName("意识模糊");
-        // vitalBp.setValType(1);
-        // vitalBp.setVal("意识模糊");
-        // vitalBp.setTermtype("查体");
-        // factor.add(vitalBp);
-        //
-        // NodeNeoDTO vitalBp2 = new NodeNeoDTO();
-        // vitalBp2.setName("年龄");
-        // vitalBp2.setMax(new BigDecimal("1"));
-        // vitalBp2.setMin(new BigDecimal("18"));
-        // vitalBp2.setValType(1);
-        // vitalBp2.setTermtype("年龄");
-        // factor.add(vitalBp2);
-        //
-        // highRiskNeoDTOList.add(highRiskNeoDTO);
-        // TODO 测试数据结束
-        highRiskProcess.process(highRiskNeoDTOList, res,wordCrfDTO);
+        // // highRiskNeoDTOList.add(highRiskNeoDTO);
+        // // TODO 测试数据结束
+        // highRiskProcess.process(highRiskNeoDTOList, res,wordCrfDTO);
 
         // 结果去重处理
         commonFacade.dealMsg(res.getHighRiskList());

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

@@ -17,7 +17,6 @@ import com.diagbot.dto.NodeNeoDTO;
 import com.diagbot.dto.OtherTipNeoDTO;
 import com.diagbot.dto.OtherTipPacsNeoDTO;
 import com.diagbot.dto.OtherTipTransfusionNeoDTO;
-import com.diagbot.dto.PushBaseDTO;
 import com.diagbot.dto.RuleDTO;
 import com.diagbot.dto.StandConvertCrfBatchDTO;
 import com.diagbot.dto.StandConvertCrfDTO;
@@ -39,8 +38,6 @@ import com.diagbot.enums.StandConvertEnum;
 import com.diagbot.enums.StaticTypeEnum;
 import com.diagbot.exception.CommonErrorCode;
 import com.diagbot.exception.CommonException;
-import com.diagbot.mapper.SymptomFeatureMapper;
-import com.diagbot.mapper.TranHospitalFilterMapper;
 import com.diagbot.model.entity.PD;
 import com.diagbot.repository.*;
 import com.diagbot.service.KlDiseaseCorrespondingService;
@@ -1489,7 +1486,7 @@ public class NeoFacade {
 
         if (ListUtil.isNotEmpty(wordList)) {
             for (String s : wordList) {
-                String value = redisUtil.getWithString(type + "Conv:" + s);
+                String value = redisUtil.get(type + "Conv:" + s);
                 if (value == null) {
                     StandConvertCrfVO standConvertCrfVO = new StandConvertCrfVO();
                     standConvertCrfVO.setWord_type(type);
@@ -1556,7 +1553,7 @@ public class NeoFacade {
         // 将所有的词放入typeMap中
         for (String s : originList) {
             if (!typeMap.containsKey(s)) {
-                String value = redisUtil.getWithString(type + "Conv:" + s);
+                String value = redisUtil.get(type + "Conv:" + s);
                 typeMap.put(s, value);
             }
         }
@@ -1622,7 +1619,7 @@ public class NeoFacade {
         // 将所有的词放入typeMap中
         for (String s : originList) {
             if (!typeMap.containsKey(s)) {
-                String value = redisUtil.getWithString(type + "Conv:" + s);
+                String value = redisUtil.get(type + "Conv:" + s);
                 typeMap.put(s, value);
             }
         }

+ 8 - 124
src/main/java/com/diagbot/facade/OtherTipFacade.java

@@ -1,17 +1,11 @@
 package com.diagbot.facade;
 
 import com.diagbot.dto.IndicationDTO;
-import com.diagbot.dto.OtherTipNeoDTO;
-import com.diagbot.dto.OtherTipPacsNeoDTO;
-import com.diagbot.dto.OtherTipTransfusionNeoDTO;
 import com.diagbot.dto.WordCrfDTO;
 import com.diagbot.process.OtherTipProcess;
-import com.diagbot.vo.IndicationPushVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
-import java.util.List;
-
 /**
  * @Description: 其他提示facade
  * @author: zhoutg
@@ -33,127 +27,17 @@ public class OtherTipFacade {
      * @param
      * @return
      */
-    public void otherTipFac(IndicationPushVO indicationPushVO, WordCrfDTO wordCrfDTO, IndicationDTO res) {
-        List<OtherTipNeoDTO> otherTipNeoDTOList = neoFacade.getOtherRemind(wordCrfDTO.getLis());
-        // 其他提示——化验
-        // // TODO 测试数据开始
-        // OtherTipNeoDTO otherTipNeoDTO = new OtherTipNeoDTO();
-        // otherTipNeoDTO.setName("血常规");
-        // otherTipNeoDTO.setDetailName("血葡萄糖测定");
-        // otherTipNeoDTO.setValue(20.0D);
-        // List<NodeNeoDTO> factor = new ArrayList<>();
-        // NodeNeoDTO nodeNeoDTO = new NodeNeoDTO();
-        // // otherTipNeoDTO.setOtherValue("阳性");
-        // nodeNeoDTO.setName("急性胰腺炎");
-        // nodeNeoDTO.setTermtype("诊断");
-        // factor.add(nodeNeoDTO);
-        // otherTipNeoDTO.setFactor(factor);
-        // otherTipNeoDTOList.add(otherTipNeoDTO);
-        //
-        // OtherTipNeoDTO otherTipNeoDTO2 = new OtherTipNeoDTO();
-        // otherTipNeoDTO2.setName("血生化检查");
-        // otherTipNeoDTO2.setDetailName("血肌酐测定");
-        // otherTipNeoDTO2.setValue(200.0);
-        // List<NodeNeoDTO> factor2 = new ArrayList<>();
-        // NodeNeoDTO nodeNeoDTO2 = new NodeNeoDTO();
-        // nodeNeoDTO2.setName("坦洛新");
-        // nodeNeoDTO2.setTermtype("药品");
-        // factor2.add(nodeNeoDTO2);
-        // otherTipNeoDTO2.setFactor(factor2);
-        // otherTipNeoDTOList.add(otherTipNeoDTO2);
-        // // TODO 测试数据结束
-        otherTipProcess.processLis(otherTipNeoDTOList, wordCrfDTO, res);
+    public void otherTipFac(WordCrfDTO wordCrfDTO, IndicationDTO res) {
+        // 其他值提醒——化验 TODO
 
-        // 其他提示——建议输血
-        List<OtherTipTransfusionNeoDTO> otherTipTransfusionNeoDTOList = neoFacade.getRecommendTransfs(wordCrfDTO);
-        // TODO 测试数据开始
-        // // 化验 + 诊断
-        // OtherTipTransfusionNeoDTO otherTipTransfusionNeoDTO = new OtherTipTransfusionNeoDTO();
-        // otherTipTransfusionNeoDTO.setName("血小板");
-        // List<Lis> lisList = new ArrayList<>();
-        // Lis lis1 = new Lis();
-        // lis1.setValue(30.0);
-        // // lis1.setOtherValue("阳性");
-        // lis1.setName("血常规");
-        // lis1.setDetailName("血小板计数");
-        // lisList.add(lis1);
-        // otherTipTransfusionNeoDTO.setLisList(lisList);
-        // List<Item> diag = new ArrayList<>();
-        // Item item = new Item();
-        // item.setName("败血症");
-        // item.setUniqueName("败血症");
-        // diag.add(item);
-        // otherTipTransfusionNeoDTO.setDiag(diag);
-        // otherTipTransfusionNeoDTOList.add(otherTipTransfusionNeoDTO);
-        //
-        // // 化验 + 手术
-        // OtherTipTransfusionNeoDTO otherTipTransfusionNeoDTO2 = new OtherTipTransfusionNeoDTO();
-        // otherTipTransfusionNeoDTO2.setName("血小板");
-        // List<Lis> lisList2 = new ArrayList<>();
-        // Lis lis2 = new Lis();
-        // lis2.setValue(30.0);
-        // // lis2.setOtherValue("阳性");
-        // lis2.setName("血常规");
-        // lis2.setDetailName("血小板计数");
-        // lisList2.add(lis2);
-        // otherTipTransfusionNeoDTO2.setLisList(lisList2);
-        // List<Item> operation = new ArrayList<>();
-        // Item item2 = new Item();
-        // item2.setName("咽鼓管置管术");
-        // item2.setUniqueName("咽鼓管置管术");
-        // operation.add(item2);
-        // otherTipTransfusionNeoDTO2.setOperation(operation);
-        // otherTipTransfusionNeoDTOList.add(otherTipTransfusionNeoDTO2);
-        //
-        // // 化验 + 辅检名称
-        // OtherTipTransfusionNeoDTO otherTipTransfusionNeoDTO3 = new OtherTipTransfusionNeoDTO();
-        // otherTipTransfusionNeoDTO3.setName("血小板");
-        // List<Lis> lisList3 = new ArrayList<>();
-        // Lis lis3 = new Lis();
-        // lis3.setValue(30.0);
-        // // lis2.setOtherValue("阳性");
-        // lis3.setName("血常规");
-        // lis3.setDetailName("血小板计数");
-        // lisList3.add(lis3);
-        // otherTipTransfusionNeoDTO3.setLisList(lisList3);
-        // List<Item> pacs = new ArrayList<>();
-        // Item item3 = new Item();
-        // item3.setName("直视下支气管活检术");
-        // item3.setUniqueName("直视下支气管活检术");
-        // pacs.add(item3);
-        // otherTipTransfusionNeoDTO3.setPacs(pacs);
-        // otherTipTransfusionNeoDTOList.add(otherTipTransfusionNeoDTO3);
-        //
-        // // 化验 + 辅检结果
-        // OtherTipTransfusionNeoDTO otherTipTransfusionNeoDTO4 = new OtherTipTransfusionNeoDTO();
-        // otherTipTransfusionNeoDTO4.setName("血小板");
-        // List<Lis> lisList4 = new ArrayList<>();
-        // Lis lis4 = new Lis();
-        // lis4.setValue(30.0);
-        // // lis2.setOtherValue("阳性");
-        // lis4.setName("血常规");
-        // lis4.setDetailName("血小板计数");
-        // lisList4.add(lis4);
-        // otherTipTransfusionNeoDTO4.setLisList(lisList4);
-        // List<Item> pacsRes = new ArrayList<>();
-        // Item item4 = new Item();
-        // item4.setName("MA 值降低伴有明显出血");
-        // item4.setUniqueName("MA 值降低伴有明显出血");
-        // pacsRes.add(item4);
-        // otherTipTransfusionNeoDTO4.setPacsRes(pacsRes);
-        // otherTipTransfusionNeoDTOList.add(otherTipTransfusionNeoDTO4);
+        // 其他值提醒——辅检 TODO
 
-        // TODO 测试数据结束
-        otherTipProcess.processTransfusion(otherTipTransfusionNeoDTOList, res);
+        // 其他值提醒——输血 TODO
 
-        // 其他提示——辅检
-        List<OtherTipPacsNeoDTO> otherTipPacsNeoDTOList = neoFacade.getPacsReminds(wordCrfDTO);
-        // TODO 测试数据开始
-        // OtherTipPacsNeoDTO otherTipPacsNeoDTO = new OtherTipPacsNeoDTO();
-        // otherTipPacsNeoDTO.setMsg("该患者年龄在18-60岁,主胰管内径≥3mm,可考虑主胰管扩张");
-        // otherTipPacsNeoDTOList.add(otherTipPacsNeoDTO);
-        // TODO 测试数据结束
-        otherTipProcess.processPacs(otherTipPacsNeoDTOList, res);
+        // // 其他提示——建议输血
+        // List<OtherTipTransfusionNeoDTO> otherTipTransfusionNeoDTOList = neoFacade.getRecommendTransfs(wordCrfDTO);
+        // // TODO 测试数据结束
+        // otherTipProcess.processTransfusion(otherTipTransfusionNeoDTOList, res);
 
         // 结果去重处理
         commonFacade.dealMsg(res.getOtherList());

+ 1 - 1
src/main/java/com/diagbot/facade/TestFacade.java

@@ -206,7 +206,7 @@ public class TestFacade {
                             drugAll.addAll(drugList);
                         } else if ("药品类别".equals(bean.getDrugType())) {
                             for (String s : drugList) {
-                                List<String> drugRedis = (List<String>) redisUtil.get(RedisEnum.drugType.getName() + s);
+                                List<String> drugRedis = redisUtil.get(RedisEnum.drugType.getName() + s);
                                 if (ListUtil.isNotEmpty(drugRedis)) {
                                     drugAll.addAll(drugRedis);
                                 }

+ 352 - 206
src/main/java/com/diagbot/process/BillProcess.java

@@ -1,14 +1,18 @@
 package com.diagbot.process;
 
 import com.diagbot.biz.push.entity.Item;
-import com.diagbot.biz.push.entity.Pacs;
 import com.diagbot.dto.BillMsg;
-import com.diagbot.dto.BillNeoDTO;
-import com.diagbot.dto.BillNeoMaxDTO;
 import com.diagbot.dto.IndicationDTO;
+import com.diagbot.dto.RuleBaseDTO;
+import com.diagbot.dto.RuleConditionDTO;
+import com.diagbot.dto.RuleExtDTO;
+import com.diagbot.dto.RuleSimpleDTO;
 import com.diagbot.dto.WordCrfDTO;
-import com.diagbot.enums.NeoEnum;
-import com.diagbot.enums.TypeEnum;
+import com.diagbot.enums.BaseTypeEnum;
+import com.diagbot.enums.ConEnum;
+import com.diagbot.enums.LibTypeEnum;
+import com.diagbot.enums.RuleTypeEnum;
+import com.diagbot.facade.CommonFacade;
 import com.diagbot.facade.NeoFacade;
 import com.diagbot.model.entity.Clinical;
 import com.diagbot.model.entity.Operation;
@@ -27,13 +31,14 @@ import com.diagbot.rule.SexRule;
 import com.diagbot.rule.VitalRule;
 import com.diagbot.util.BeanUtil;
 import com.diagbot.util.CoreUtil;
-import com.diagbot.util.ListUtil;
-import com.diagbot.util.StringUtil;
+import com.diagbot.vo.RuleVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 import java.util.ArrayList;
+import java.util.LinkedHashSet;
 import java.util.List;
+import java.util.Set;
 
 /**
  * @Description: 开单总入口
@@ -63,219 +68,360 @@ public class BillProcess {
     GroupRule groupRule;
     @Autowired
     MedEquRule medEquRule;
-
-    public void process(List<BillNeoDTO> billNeoDTOList, WordCrfDTO wordCrfDTO, IndicationDTO res) {
-        // 合并图谱数据到同一个对象中
-        List<BillNeoMaxDTO> billNeoMaxDTOList = new ArrayList<>();
-        for (BillNeoDTO billNeoDTO : billNeoDTOList) {
-            BillNeoMaxDTO billNeoMaxDTO = new BillNeoMaxDTO();
-            if (billNeoDTO.getDrugBillNeoDTO() != null) {
-                BeanUtil.copyProperties(billNeoDTO.getDrugBillNeoDTO(), billNeoMaxDTO);
-                billNeoMaxDTO.setType(TypeEnum.drug.getName());
-            } else if (billNeoDTO.getLisBillNeoDTO() != null) {
-                BeanUtil.copyProperties(billNeoDTO.getLisBillNeoDTO(), billNeoMaxDTO);
-                billNeoMaxDTO.setType(TypeEnum.lis.getName());
-            } else if (billNeoDTO.getPacsBillNeoDTO() != null) {
-                BeanUtil.copyProperties(billNeoDTO.getPacsBillNeoDTO(), billNeoMaxDTO);
-                billNeoMaxDTO.setType(TypeEnum.pacs.getName());
-            } else if (billNeoDTO.getOperationBillNeoDTO() != null) {
-                BeanUtil.copyProperties(billNeoDTO.getOperationBillNeoDTO(), billNeoMaxDTO);
-                if (ListUtil.isNotEmpty(billNeoDTO.getOperationBillNeoDTO().getMedallegen())) {
-                    billNeoMaxDTO.getAllergicmeds().addAll(billNeoDTO.getOperationBillNeoDTO().getMedallegen());
-                }
-                billNeoMaxDTO.setType(TypeEnum.operation.getName());
-            } else if (billNeoDTO.getTransfusionBillNeoDTO() != null) {
-                BeanUtil.copyProperties(billNeoDTO.getTransfusionBillNeoDTO(), billNeoMaxDTO);
-                billNeoMaxDTO.setType(TypeEnum.transfusion.getName());
-            }
-            billNeoMaxDTO.setOrderName(billNeoDTO.getName()); // 开单名称
-            billNeoMaxDTO.setOrderStandName(billNeoDTO.getStandname()); // 开单标准名称
-            // // TODO 测试数据开始
-            // if (billNeoDTO.getStandname().equals("胸部CT")) {
-            //     NodeNeoDTO nodeNeoDTO = new NodeNeoDTO();
-            //     nodeNeoDTO.setName("幼儿");
-            //     billNeoMaxDTO.getGroup().add(nodeNeoDTO);
-            // }
-            // if (billNeoDTO.getStandname().equals("胸部CT")) {
-            //     NodeNeoDTO nodeNeoDTO = new NodeNeoDTO();
-            //     nodeNeoDTO.setName("心电图");
-            //     billNeoMaxDTO.getPacsOrder().add(nodeNeoDTO);
-            // }
-            // if (billNeoDTO.getStandname().equals("心电图")) {
-            //     NodeNeoDTO nodeNeoDTO = new NodeNeoDTO();
-            //     nodeNeoDTO.setName("胸部CT");
-            //     billNeoMaxDTO.getPacsOrder().add(nodeNeoDTO);
-            // }
-            // if (billNeoDTO.getName().equals("普通胃镜检查")) {
-            //     NodeNeoDTO sexNeo = new NodeNeoDTO();
-            //     sexNeo.setName("男");
-            //     billNeoMaxDTO.setGender(sexNeo);
-            //
-            //     NodeNeoDTO nodeNeoDTO = new NodeNeoDTO();
-            //     nodeNeoDTO.setName("红细胞压积");
-            //     nodeNeoDTO.setVal("阳性");
-            //     billNeoDTO.getPacsBillNeoDTO().getLis().add(nodeNeoDTO);
-            //
-            //     NodeNeoDTO nodepacsDTO = new NodeNeoDTO();
-            //     nodepacsDTO.setName("上腹部平扫");
-            //     billNeoDTO.getPacsBillNeoDTO().getPacs().add(nodepacsDTO);
-            //
-            //     NodeNeoDTO opereat = new NodeNeoDTO();
-            //     opereat.setName("胸腔镜下左下肺叶切除术");
-            //     billNeoDTO.getPacsBillNeoDTO().getOperations().add(opereat);
-            //     NodeNeoDTO opereat2 = new NodeNeoDTO();
-            //     opereat2.setName("区域淋巴结清扫术");
-            //     billNeoDTO.getPacsBillNeoDTO().getOperations().add(opereat2);
-            //
-            //     NodeNeoDTO drug = new NodeNeoDTO();
-            //     drug.setName("青霉素类");
-            //     billNeoDTO.getPacsBillNeoDTO().getAllergicmeds().add(drug);
-            //
-            //     NodeNeoDTO drug3 = new NodeNeoDTO();
-            //     drug3.setName("泰舒达类");
-            //     billNeoDTO.getPacsBillNeoDTO().getOralmeds().add(drug3);
-            //
-            //     // NodeNeoDTO vital = new NodeNeoDTO();
-            //     // vital.setName("体温");
-            //     // vital.setMax(new BigDecimal("39.1"));
-            //     // vital.setMin(new BigDecimal("35.1"));
-            //     // vital.setValType(1);
-            //     // billNeoDTO.getPacsBillNeoDTO().getVitals().add(vital);
-            //
-            //     NodeNeoDTO vitalBp = new NodeNeoDTO();
-            //     vitalBp.setName("舒张压");
-            //     vitalBp.setMax(new BigDecimal("120"));
-            //     vitalBp.setMin(new BigDecimal("100"));
-            //     vitalBp.setValType(1);
-            //     billNeoDTO.getPacsBillNeoDTO().getVitals().add(vitalBp);
-            //
-            //     NodeNeoDTO vitalBp2 = new NodeNeoDTO();
-            //     vitalBp2.setName("收缩压");
-            //     vitalBp2.setMax(new BigDecimal("120"));
-            //     vitalBp2.setMin(new BigDecimal("100"));
-            //     vitalBp2.setValType(1);
-            //     billNeoDTO.getPacsBillNeoDTO().getVitals().add(vitalBp2);
-            // }
-            // 测试数据结束
-
-            System.out.println(billNeoMaxDTO);
-            billNeoMaxDTOList.add(billNeoMaxDTO);
-        }
-
-        // 辅检开单项时间赋值,用于规则【无需重复开单项】
-        // 由于mark之前返回的billNeoDTOList没有时间字段,就用辅检开单的原始数据name和uniqueName两个字段相同时
-        // 进行赋值。可能会存在多个相同的开单项,时间需要分别赋值:处理方式是时间只用一次,刚好可以对上
-        if (ListUtil.isNotEmpty(billNeoMaxDTOList) && ListUtil.isNotEmpty(wordCrfDTO.getPacsOrder())) {
-            List<Integer> useList = new ArrayList<>();
-            for (int i = 0; i < billNeoMaxDTOList.size(); i++) {
-                BillNeoMaxDTO billNeoMaxDTO = billNeoMaxDTOList.get(i);
-                for (int j = 0; j < wordCrfDTO.getPacsOrder().size(); j++) {
-                    Pacs pacs = wordCrfDTO.getPacsOrder().get(j);
-                    if (StringUtil.isNotBlank(pacs.getName()) && StringUtil.isNotBlank(pacs.getUniqueName())
-                            && pacs.getName().equals(billNeoMaxDTO.getOrderName())
-                            && pacs.getUniqueName().equals(billNeoMaxDTO.getOrderStandName())) {
-                        if (!useList.contains(j)) { // 判断使用标识
-                            billNeoMaxDTO.setDateValue(pacs.getDateValue());
-                            useList.add(j);
-                            break;
-                        }
-                    }
-                }
-            }
-        }
-        processRule(billNeoMaxDTOList, wordCrfDTO, res);
-    }
+    @Autowired
+    CommonFacade commonFacade;
 
     // 规则处理
-    public void processRule(List<BillNeoMaxDTO> billNeoMaxDTOList, WordCrfDTO wordCrfDTO, IndicationDTO indicationDTO) {
-        ChiefLabel chiefLabel = wordCrfDTO.getChiefLabel();
-        PresentLabel presentLabel = wordCrfDTO.getPresentLabel();
-        PastLabel pastLabel = wordCrfDTO.getPastLabel();
-
-        // 【过敏药品数据来源】
-        List<Item> allergyMedicines = commonRule.getDrugAllergySource(wordCrfDTO);
-
-        // 【药品数据来源】(主诉、现病史、既往史、结构化药品)
-        List<Item> medicineAll = wordCrfDTO.getDrugSource();
-
-        // 【诊断数据来源】
-        List<Item> diags = wordCrfDTO.getDiagSource();
-
-        // 【辅检结果数据来源】
-        PacsLabel pacsLabel = wordCrfDTO.getPacsLabel();
-        List<Item> pacsDescList = pacsLabel.getRes();
-
-        // 【手术数据来源】
-        List<Operation> operations_all = new ArrayList<>();
-        List<Item> operation = wordCrfDTO.getOperation();
-        List<Operation> operationsItem = new ArrayList<>();
-        for (Item item : operation) {
-            Operation operaData = new Operation();
-            operaData.setName(item.getName());
-            operaData.setStandName(item.getUniqueName());
-            operationsItem.add(operaData);
-        }
-        CoreUtil.addList(operations_all, chiefLabel.getOperations()); // 主诉手术
-        CoreUtil.addList(operations_all, presentLabel.getOperations()); // 现病史手术
-        CoreUtil.addList(operations_all, pastLabel.getOperations()); // 既往史手术
-        CoreUtil.addList(operations_all, operationsItem); // 结构化手术
-
-        // 【临床表现数据来源】(主诉、现病史)
-        List<Clinical> clinicals = new ArrayList<>();
-        CoreUtil.addList(clinicals, chiefLabel.getClinicals()); // 主诉临床表现
-        CoreUtil.addList(clinicals, presentLabel.getClinicals()); // 现病史临床表现
-
-        List<BillMsg> billMsgList = new ArrayList<>();
-        for (BillNeoMaxDTO bill : billNeoMaxDTOList) {
-            // 性别
-            sexRule.bill(wordCrfDTO, bill, billMsgList, NeoEnum.gender.getName());
-
-            // 年龄
-            ageRule.bill(wordCrfDTO, bill, billMsgList, NeoEnum.ageNeoDTO.getName());
-
-            // 诊断
-            commonRule.compareItemWithBill(bill.getDisease(), diags, bill, billMsgList, NeoEnum.disease.getName());
-
-            // 化验
-            lisRule.bill(wordCrfDTO.getLis(), bill, billMsgList, NeoEnum.lis.getName());
-
-            // 体征
-            vitalRule.bill(wordCrfDTO.getVitalLabel(), bill, billMsgList, NeoEnum.vitals.getName());
+    public void processRule(List<RuleVO> ruleVOList, WordCrfDTO wordCrfDTO, IndicationDTO indicationDTO) {
+        List<BillMsg> billMsgList = indicationDTO.getBillMsgList();
+        Set<String> set = new LinkedHashSet<>();    // A与B不宜同时进行, B与A不宜同时进行 只能提示一个
+        for (RuleVO ruleVO : ruleVOList) {
+            /** 1、获取开单项相关数据 */
+            RuleExtDTO ruleExtDTO = commonFacade.getRuleData(ruleVO);
+            if (ruleExtDTO == null) {
+                continue;
+            }
 
-            // 辅检
-            pacsRule.bill(bill.getPacs(), wordCrfDTO.getPacs(), bill, billMsgList, NeoEnum.pacs.getName());
+            /** 2、简化拼接对象,用于开单项提示语 */
+            RuleSimpleDTO ruleSimpleDTO = new RuleSimpleDTO();
+            BeanUtil.copyProperties(ruleExtDTO, ruleSimpleDTO);
 
-            // 临床表现
-            commonRule.compareNameWithBill(bill.getClinicfindings(), clinicals, bill, billMsgList, NeoEnum.clinicfindings.getName());
+            /**---------------------------3、数据统一处理开始--------------------------------- */
+            ChiefLabel chiefLabel = wordCrfDTO.getChiefLabel();
+            PresentLabel presentLabel = wordCrfDTO.getPresentLabel();
+            PastLabel pastLabel = wordCrfDTO.getPastLabel();
 
-            // 手术(既往史、现病史、医嘱手术)
-            commonRule.compareNameWithBill(bill.getOperations(), operations_all, bill, billMsgList, NeoEnum.operations.getName());
+            // 【过敏药品数据来源】
+            List<Item> allergyMedicines = commonRule.getDrugAllergySource(wordCrfDTO);
 
-            // 禁忌过敏药品(既往史)
-            drugRule.bill(bill.getAllergicmeds(), allergyMedicines, bill, billMsgList, NeoEnum.allergicmeds.getName());
+            // 【药品数据来源】(主诉、现病史、既往史、结构化药品)
+            List<Item> medicineAll = wordCrfDTO.getDrugSource();
 
-            // 服用药品(主诉、现病史、既往史、结构化药品)
-            drugRule.bill(bill.getOralmeds(), medicineAll, bill, billMsgList, NeoEnum.oralmeds.getName());
+            // 【诊断数据来源】
+            List<Item> diags = wordCrfDTO.getDiagSource();
 
-            // 禁忌人群
-            groupRule.bill(wordCrfDTO, bill, billMsgList, NeoEnum.group.getName());
+            // 【辅检结果数据来源】
+            PacsLabel pacsLabel = wordCrfDTO.getPacsLabel();
+            List<Item> pacsDescList = pacsLabel.getRes();
 
-            // 禁用辅助检查描述
-            commonRule.compareItemWithBill(bill.getPacsDesc(), pacsDescList, bill, billMsgList, NeoEnum.pacsDesc.getName());
+            // 【手术数据来源】
+            List<Operation> operations_all = new ArrayList<>();
+            List<Item> operation = wordCrfDTO.getOperation();
+            List<Operation> operationsItem = new ArrayList<>();
+            for (Item item : operation) {
+                Operation operaData = new Operation();
+                operaData.setName(item.getName());
+                operaData.setStandName(item.getUniqueName());
+                operationsItem.add(operaData);
+            }
+            CoreUtil.addList(operations_all, chiefLabel.getOperations()); // 主诉手术
+            CoreUtil.addList(operations_all, presentLabel.getOperations()); // 现病史手术
+            CoreUtil.addList(operations_all, pastLabel.getOperations()); // 既往史手术
+            CoreUtil.addList(operations_all, operationsItem); // 结构化手术
 
-            // 禁忌医疗器械及物品
-            medEquRule.bill(wordCrfDTO, bill, billMsgList, NeoEnum.medEqu.getName());
+            // 【临床表现数据来源】(主诉、现病史)
+            List<Clinical> clinicals = new ArrayList<>();
+            CoreUtil.addList(clinicals, chiefLabel.getClinicals()); // 主诉临床表现
+            CoreUtil.addList(clinicals, presentLabel.getClinicals()); // 现病史临床表现
+            /**---------------------------数据统一处理结束--------------------------------- */
 
-            // 无需重复开单项
-            commonRule.needlessRepeatOrder(wordCrfDTO, bill, billMsgList);
+            /** 4、规则处理 */
+            List<RuleConditionDTO> ruleConditionDTOList = ruleExtDTO.getRuleConditionDTOList();
+            for (RuleConditionDTO ruleConditionDTO : ruleConditionDTOList) {
+                List<RuleBaseDTO> ruleBaseDTOList = ruleConditionDTO.getRuleBaseDTOList();
+                switch (RuleTypeEnum.getEnum(ruleExtDTO.getRuleType())) {
+                    case bill: // redis 数据以 _1结尾
+                        for (RuleBaseDTO ruleBaseDTO : ruleBaseDTOList) {
+                            if (LibTypeEnum.getEnum(ruleBaseDTO.getBaseLibType()) != null) { // 避免空指针
+                                switch (LibTypeEnum.getEnum(ruleBaseDTO.getBaseLibType())) {
+                                    case sex: // 性别
+                                        sexRule.bill(wordCrfDTO, ruleBaseDTO, billMsgList, ConEnum.gender.getName(), ruleSimpleDTO);
+                                    case age: // 年龄
+                                        ageRule.bill(wordCrfDTO, ruleBaseDTO, billMsgList, ConEnum.age.getName(), ruleSimpleDTO);
+                                        break;
+                                    case disease: // 诊断
+                                        commonRule.compareItemWithBill(diags, ruleBaseDTO, billMsgList, ConEnum.disease.getName(), ruleSimpleDTO);
+                                        break;
+                                    case lisDetail: // 化验
+                                        lisRule.bill(wordCrfDTO.getLis(), ruleBaseDTO, billMsgList, ConEnum.lis.getName(), ruleSimpleDTO);
+                                        break;
+                                    case vitalRes: //体格检查结果
+                                    case vital: // 体格检查项目
+                                        vitalRule.bill(wordCrfDTO.getVitalLabel(), ruleBaseDTO, billMsgList, ConEnum.vitals.getName(), ruleSimpleDTO);
+                                        break;
+                                    case pacs: // 辅检项目
+                                        if (ruleBaseDTO.getBaseType() != null && ruleBaseDTO.getBaseType().equals(BaseTypeEnum.B5.getKey())) {
+                                            // 开单项互斥
+                                            commonRule.exclusionBill(wordCrfDTO, ruleBaseDTO, billMsgList, ruleSimpleDTO, set);
+                                        } else {
+                                            // 辅检项目,暂无数据
+                                            pacsRule.bill(wordCrfDTO.getPacs(), ruleBaseDTO, billMsgList, ConEnum.pacs.getName(), ruleSimpleDTO);
+                                        }
+                                        break;
+                                    case clinical: // 临床表现
+                                        commonRule.compareNameWithBill(clinicals, ruleBaseDTO, billMsgList, ConEnum.clinicfindings.getName(), ruleSimpleDTO);
+                                        break;
+                                    case operation: // 手术(既往史、现病史、医嘱手术)
+                                        commonRule.compareNameWithBill(operations_all, ruleBaseDTO, billMsgList, ConEnum.operations.getName(), ruleSimpleDTO);
+                                        break;
+                                    case drug:
+                                    case yphxwzlb:
+                                    case ypzlxlb:
+                                    case ypylxlb:
+                                    case ypjpxlb:
+                                        if (ruleBaseDTO.getBaseType().equals(4)) {
+                                            // 禁忌过敏药品(既往史)
+                                            drugRule.bill(allergyMedicines, ruleBaseDTO, billMsgList, ConEnum.allergicmeds.getName(), ruleSimpleDTO);
+                                        } else {
+                                            // 服用药品(主诉、现病史、既往史、结构化药品)
+                                            drugRule.bill(medicineAll, ruleBaseDTO, billMsgList, ConEnum.oralmeds.getName(), ruleSimpleDTO);
+                                        }
+                                        break;
+                                    case otherAllergy: // 其他过敏原
+                                        drugRule.bill(allergyMedicines, ruleBaseDTO, billMsgList, ConEnum.otherAllergy.getName(), ruleSimpleDTO);
+                                        break;
+                                    case group: // 禁忌人群
+                                        groupRule.bill(wordCrfDTO, ruleBaseDTO, billMsgList, ConEnum.group.getName(), ruleSimpleDTO);
+                                        break;
+                                    case pacsResult: // 禁用辅助检查描述
+                                        commonRule.compareItemWithBill(pacsDescList, ruleBaseDTO, billMsgList, ConEnum.pacsDesc.getName(), ruleSimpleDTO);
+                                        break;
+                                    case ylqxjwp: // 禁忌医疗器械及物品
+                                        medEquRule.bill(wordCrfDTO, ruleBaseDTO, billMsgList, ConEnum.medEqu.getName(), ruleSimpleDTO);
+                                        break;
+                                    default:
+                                        break;
+                                }
+                            }
+                        }
+                        break;
+                    case repeat:  // redis 数据以 _6结尾
+                        for (RuleBaseDTO ruleBaseDTO : ruleBaseDTOList) {
+                            // 无需重复开单项
+                            commonRule.needlessRepeatOrder(wordCrfDTO, ruleBaseDTO, billMsgList, ruleSimpleDTO);
+                        }
+                        break;
+                    default:
+                        break;
+                }
+            }
         }
-
         // 24小时重复开单项
         commonRule.repeat24Bill(wordCrfDTO, billMsgList);
-
-        // 互斥开单项
-        commonRule.exclusionBill(billNeoMaxDTOList, wordCrfDTO, billMsgList);
-        indicationDTO.setBillMsgList(billMsgList);
     }
 
+    // public void process(List<BillNeoDTO> billNeoDTOList, WordCrfDTO wordCrfDTO, IndicationDTO res) {
+    //     // 合并图谱数据到同一个对象中
+    //     List<BillNeoMaxDTO> billNeoMaxDTOList = new ArrayList<>();
+    //     for (BillNeoDTO billNeoDTO : billNeoDTOList) {
+    //         BillNeoMaxDTO billNeoMaxDTO = new BillNeoMaxDTO();
+    //         if (billNeoDTO.getDrugBillNeoDTO() != null) {
+    //             BeanUtil.copyProperties(billNeoDTO.getDrugBillNeoDTO(), billNeoMaxDTO);
+    //             billNeoMaxDTO.setType(TypeEnum.drug.getName());
+    //         } else if (billNeoDTO.getLisBillNeoDTO() != null) {
+    //             BeanUtil.copyProperties(billNeoDTO.getLisBillNeoDTO(), billNeoMaxDTO);
+    //             billNeoMaxDTO.setType(TypeEnum.lis.getName());
+    //         } else if (billNeoDTO.getPacsBillNeoDTO() != null) {
+    //             BeanUtil.copyProperties(billNeoDTO.getPacsBillNeoDTO(), billNeoMaxDTO);
+    //             billNeoMaxDTO.setType(TypeEnum.pacs.getName());
+    //         } else if (billNeoDTO.getOperationBillNeoDTO() != null) {
+    //             BeanUtil.copyProperties(billNeoDTO.getOperationBillNeoDTO(), billNeoMaxDTO);
+    //             if (ListUtil.isNotEmpty(billNeoDTO.getOperationBillNeoDTO().getMedallegen())) {
+    //                 billNeoMaxDTO.getAllergicmeds().addAll(billNeoDTO.getOperationBillNeoDTO().getMedallegen());
+    //             }
+    //             billNeoMaxDTO.setType(TypeEnum.operation.getName());
+    //         } else if (billNeoDTO.getTransfusionBillNeoDTO() != null) {
+    //             BeanUtil.copyProperties(billNeoDTO.getTransfusionBillNeoDTO(), billNeoMaxDTO);
+    //             billNeoMaxDTO.setType(TypeEnum.transfusion.getName());
+    //         }
+    //         billNeoMaxDTO.setOrderName(billNeoDTO.getName()); // 开单名称
+    //         billNeoMaxDTO.setOrderStandName(billNeoDTO.getStandname()); // 开单标准名称
+    //         // // TODO 测试数据开始
+    //         // if (billNeoDTO.getStandname().equals("胸部CT")) {
+    //         //     NodeNeoDTO nodeNeoDTO = new NodeNeoDTO();
+    //         //     nodeNeoDTO.setName("幼儿");
+    //         //     billNeoMaxDTO.getGroup().add(nodeNeoDTO);
+    //         // }
+    //         // if (billNeoDTO.getStandname().equals("胸部CT")) {
+    //         //     NodeNeoDTO nodeNeoDTO = new NodeNeoDTO();
+    //         //     nodeNeoDTO.setName("心电图");
+    //         //     billNeoMaxDTO.getPacsOrder().add(nodeNeoDTO);
+    //         // }
+    //         // if (billNeoDTO.getStandname().equals("心电图")) {
+    //         //     NodeNeoDTO nodeNeoDTO = new NodeNeoDTO();
+    //         //     nodeNeoDTO.setName("胸部CT");
+    //         //     billNeoMaxDTO.getPacsOrder().add(nodeNeoDTO);
+    //         // }
+    //         // if (billNeoDTO.getName().equals("普通胃镜检查")) {
+    //         //     NodeNeoDTO sexNeo = new NodeNeoDTO();
+    //         //     sexNeo.setName("男");
+    //         //     billNeoMaxDTO.setGender(sexNeo);
+    //         //
+    //         //     NodeNeoDTO nodeNeoDTO = new NodeNeoDTO();
+    //         //     nodeNeoDTO.setName("红细胞压积");
+    //         //     nodeNeoDTO.setVal("阳性");
+    //         //     billNeoDTO.getPacsBillNeoDTO().getLis().add(nodeNeoDTO);
+    //         //
+    //         //     NodeNeoDTO nodepacsDTO = new NodeNeoDTO();
+    //         //     nodepacsDTO.setName("上腹部平扫");
+    //         //     billNeoDTO.getPacsBillNeoDTO().getPacs().add(nodepacsDTO);
+    //         //
+    //         //     NodeNeoDTO opereat = new NodeNeoDTO();
+    //         //     opereat.setName("胸腔镜下左下肺叶切除术");
+    //         //     billNeoDTO.getPacsBillNeoDTO().getOperations().add(opereat);
+    //         //     NodeNeoDTO opereat2 = new NodeNeoDTO();
+    //         //     opereat2.setName("区域淋巴结清扫术");
+    //         //     billNeoDTO.getPacsBillNeoDTO().getOperations().add(opereat2);
+    //         //
+    //         //     NodeNeoDTO drug = new NodeNeoDTO();
+    //         //     drug.setName("青霉素类");
+    //         //     billNeoDTO.getPacsBillNeoDTO().getAllergicmeds().add(drug);
+    //         //
+    //         //     NodeNeoDTO drug3 = new NodeNeoDTO();
+    //         //     drug3.setName("泰舒达类");
+    //         //     billNeoDTO.getPacsBillNeoDTO().getOralmeds().add(drug3);
+    //         //
+    //         //     // NodeNeoDTO vital = new NodeNeoDTO();
+    //         //     // vital.setName("体温");
+    //         //     // vital.setMax(new BigDecimal("39.1"));
+    //         //     // vital.setMin(new BigDecimal("35.1"));
+    //         //     // vital.setValType(1);
+    //         //     // billNeoDTO.getPacsBillNeoDTO().getVitals().add(vital);
+    //         //
+    //         //     NodeNeoDTO vitalBp = new NodeNeoDTO();
+    //         //     vitalBp.setName("舒张压");
+    //         //     vitalBp.setMax(new BigDecimal("120"));
+    //         //     vitalBp.setMin(new BigDecimal("100"));
+    //         //     vitalBp.setValType(1);
+    //         //     billNeoDTO.getPacsBillNeoDTO().getVitals().add(vitalBp);
+    //         //
+    //         //     NodeNeoDTO vitalBp2 = new NodeNeoDTO();
+    //         //     vitalBp2.setName("收缩压");
+    //         //     vitalBp2.setMax(new BigDecimal("120"));
+    //         //     vitalBp2.setMin(new BigDecimal("100"));
+    //         //     vitalBp2.setValType(1);
+    //         //     billNeoDTO.getPacsBillNeoDTO().getVitals().add(vitalBp2);
+    //         // }
+    //         // 测试数据结束
+    //
+    //         System.out.println(billNeoMaxDTO);
+    //         billNeoMaxDTOList.add(billNeoMaxDTO);
+    //     }
+    //
+    //     // 辅检开单项时间赋值,用于规则【无需重复开单项】
+    //     // 由于mark之前返回的billNeoDTOList没有时间字段,就用辅检开单的原始数据name和uniqueName两个字段相同时
+    //     // 进行赋值。可能会存在多个相同的开单项,时间需要分别赋值:处理方式是时间只用一次,刚好可以对上
+    //     if (ListUtil.isNotEmpty(billNeoMaxDTOList) && ListUtil.isNotEmpty(wordCrfDTO.getPacsOrder())) {
+    //         List<Integer> useList = new ArrayList<>();
+    //         for (int i = 0; i < billNeoMaxDTOList.size(); i++) {
+    //             BillNeoMaxDTO billNeoMaxDTO = billNeoMaxDTOList.get(i);
+    //             for (int j = 0; j < wordCrfDTO.getPacsOrder().size(); j++) {
+    //                 Pacs pacs = wordCrfDTO.getPacsOrder().get(j);
+    //                 if (StringUtil.isNotBlank(pacs.getName()) && StringUtil.isNotBlank(pacs.getUniqueName())
+    //                         && pacs.getName().equals(billNeoMaxDTO.getOrderName())
+    //                         && pacs.getUniqueName().equals(billNeoMaxDTO.getOrderStandName())) {
+    //                     if (!useList.contains(j)) { // 判断使用标识
+    //                         billNeoMaxDTO.setDateValue(pacs.getDateValue());
+    //                         useList.add(j);
+    //                         break;
+    //                     }
+    //                 }
+    //             }
+    //         }
+    //     }
+    //     processRule(billNeoMaxDTOList, wordCrfDTO, res);
+    // }
+    //
+    // // 规则处理
+    // public void processRule(List<BillNeoMaxDTO> billNeoMaxDTOList, WordCrfDTO wordCrfDTO, IndicationDTO indicationDTO) {
+    //     ChiefLabel chiefLabel = wordCrfDTO.getChiefLabel();
+    //     PresentLabel presentLabel = wordCrfDTO.getPresentLabel();
+    //     PastLabel pastLabel = wordCrfDTO.getPastLabel();
+    //
+    //     // 【过敏药品数据来源】
+    //     List<Item> allergyMedicines = commonRule.getDrugAllergySource(wordCrfDTO);
+    //
+    //     // 【药品数据来源】(主诉、现病史、既往史、结构化药品)
+    //     List<Item> medicineAll = wordCrfDTO.getDrugSource();
+    //
+    //     // 【诊断数据来源】
+    //     List<Item> diags = wordCrfDTO.getDiagSource();
+    //
+    //     // 【辅检结果数据来源】
+    //     PacsLabel pacsLabel = wordCrfDTO.getPacsLabel();
+    //     List<Item> pacsDescList = pacsLabel.getRes();
+    //
+    //     // 【手术数据来源】
+    //     List<Operation> operations_all = new ArrayList<>();
+    //     List<Item> operation = wordCrfDTO.getOperation();
+    //     List<Operation> operationsItem = new ArrayList<>();
+    //     for (Item item : operation) {
+    //         Operation operaData = new Operation();
+    //         operaData.setName(item.getName());
+    //         operaData.setStandName(item.getUniqueName());
+    //         operationsItem.add(operaData);
+    //     }
+    //     CoreUtil.addList(operations_all, chiefLabel.getOperations()); // 主诉手术
+    //     CoreUtil.addList(operations_all, presentLabel.getOperations()); // 现病史手术
+    //     CoreUtil.addList(operations_all, pastLabel.getOperations()); // 既往史手术
+    //     CoreUtil.addList(operations_all, operationsItem); // 结构化手术
+    //
+    //     // 【临床表现数据来源】(主诉、现病史)
+    //     List<Clinical> clinicals = new ArrayList<>();
+    //     CoreUtil.addList(clinicals, chiefLabel.getClinicals()); // 主诉临床表现
+    //     CoreUtil.addList(clinicals, presentLabel.getClinicals()); // 现病史临床表现
+    //
+    //     List<BillMsg> billMsgList = new ArrayList<>();
+    //     for (BillNeoMaxDTO bill : billNeoMaxDTOList) {
+    //         // 性别
+    //         // sexRule.bill(wordCrfDTO, bill, billMsgList, NeoEnum.gender.getName());
+    //
+    //         // 年龄
+    //         // ageRule.bill(wordCrfDTO, bill, billMsgList, NeoEnum.ageNeoDTO.getName());
+    //
+    //         // 诊断
+    //         // commonRule.compareItemWithBill(bill.getDisease(), diags, bill, billMsgList, NeoEnum.disease.getName());
+    //         //
+    //         // // 化验
+    //         // lisRule.bill(wordCrfDTO.getLis(), bill, billMsgList, NeoEnum.lis.getName());
+    //
+    //         // 体征
+    //         // vitalRule.bill(wordCrfDTO.getVitalLabel(), bill, billMsgList, NeoEnum.vitals.getName());
+    //         //
+    //         // // 辅检
+    //         // pacsRule.bill(bill.getPacs(), wordCrfDTO.getPacs(), bill, billMsgList, NeoEnum.pacs.getName());
+    //         //
+    //         // // 临床表现
+    //         // commonRule.compareNameWithBill(bill.getClinicfindings(), clinicals, bill, billMsgList, NeoEnum.clinicfindings.getName());
+    //         //
+    //         // // 手术(既往史、现病史、医嘱手术)
+    //         // commonRule.compareNameWithBill(bill.getOperations(), operations_all, bill, billMsgList, NeoEnum.operations.getName());
+    //         //
+    //         // // 禁忌过敏药品(既往史)
+    //         // drugRule.bill(bill.getAllergicmeds(), allergyMedicines, bill, billMsgList, NeoEnum.allergicmeds.getName());
+    //         //
+    //         // // 服用药品(主诉、现病史、既往史、结构化药品)
+    //         // drugRule.bill(bill.getOralmeds(), medicineAll, bill, billMsgList, NeoEnum.oralmeds.getName());
+    //         //
+    //         // // 禁忌人群
+    //         // groupRule.bill(wordCrfDTO, bill, billMsgList, NeoEnum.group.getName());
+    //         //
+    //         // // 禁用辅助检查描述
+    //         // commonRule.compareItemWithBill(bill.getPacsDesc(), pacsDescList, bill, billMsgList, NeoEnum.pacsDesc.getName());
+    //         //
+    //         // // 禁忌医疗器械及物品
+    //         // medEquRule.bill(wordCrfDTO, bill, billMsgList, NeoEnum.medEqu.getName());
+    //         //
+    //         // // 无需重复开单项
+    //         // commonRule.needlessRepeatOrder(wordCrfDTO, bill, billMsgList);
+    //     }
+    //
+    //     // 24小时重复开单项
+    //     commonRule.repeat24Bill(wordCrfDTO, billMsgList);
+    //
+    //     // 互斥开单项
+    //     commonRule.exclusionBill(billNeoMaxDTOList, wordCrfDTO, billMsgList);
+    //     indicationDTO.setBillMsgList(billMsgList);
+    // }
+
 }

+ 111 - 12
src/main/java/com/diagbot/process/CriticalProcess.java

@@ -1,16 +1,29 @@
 package com.diagbot.process;
 
+import com.diagbot.biz.push.entity.Item;
+import com.diagbot.biz.push.entity.Lis;
 import com.diagbot.dto.BillMsg;
-import com.diagbot.dto.CriticalNeoDTO;
 import com.diagbot.dto.IndicationDTO;
+import com.diagbot.dto.RuleBaseDTO;
+import com.diagbot.dto.RuleConditionDTO;
+import com.diagbot.dto.RuleExtDTO;
 import com.diagbot.dto.WordCrfDTO;
+import com.diagbot.enums.LibTypeEnum;
+import com.diagbot.enums.RuleTypeEnum;
 import com.diagbot.enums.TypeEnum;
+import com.diagbot.facade.CommonFacade;
+import com.diagbot.model.label.PacsLabel;
 import com.diagbot.rule.LisRule;
 import com.diagbot.rule.PacsRule;
+import com.diagbot.util.StringUtil;
+import com.diagbot.vo.RuleVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import java.util.LinkedHashSet;
+import java.util.LinkedList;
 import java.util.List;
+import java.util.Set;
 
 /**
  * @Description: 危急值总入口
@@ -24,26 +37,112 @@ public class CriticalProcess {
     LisRule lisRule;
     @Autowired
     PacsRule pacsRule;
+    @Autowired
+    CommonFacade commonFacade;
 
     /**
-     * 处理业务
+     * 处理业务——化验
      *
-     * @param criticalNeoDTOList
      * @param wordCrfDTO
      * @param res
      */
-    public void process(List<CriticalNeoDTO> criticalNeoDTOList, WordCrfDTO wordCrfDTO, IndicationDTO res) {
+    public void processLis(WordCrfDTO wordCrfDTO, IndicationDTO res) {
         List<BillMsg> criticalList = res.getCriticalValList();
-        for (CriticalNeoDTO critical : criticalNeoDTOList) {
-            switch (TypeEnum.getEnum(critical.getType())) {
-                case lis: // 化验
-                    lisRule.critical(wordCrfDTO, critical, criticalList);
-                    break;
-                case pacs: // 辅检
-                    pacsRule.critical(critical, criticalList);
+        List<Lis> lisList = wordCrfDTO.getLis();
+        for (Lis lis : lisList) {
+            RuleVO ruleVO = getRuleVO(lis);
+            // 1、获取危急值相关数据
+            if (ruleVO != null) {
+                RuleExtDTO ruleExtDTO = commonFacade.getRuleData(ruleVO);
+                if (ruleExtDTO == null) {
+                    continue;
+                }
+                List<RuleConditionDTO> ruleConditionDTOList = ruleExtDTO.getRuleConditionDTOList();
+                for (RuleConditionDTO ruleConditionDTO : ruleConditionDTOList) {
+                    List<RuleBaseDTO> ruleBaseDTOList = ruleConditionDTO.getRuleBaseDTOList();
+                    // 2、规则匹配
+                    lisRule.critical(lis, ruleBaseDTOList, criticalList, wordCrfDTO);
+                }
+            }
+        }
+    }
+
+    /**
+     * 处理业务——辅检
+     *
+     * @param wordCrfDTO
+     * @param res
+     */
+    public void processPacs(WordCrfDTO wordCrfDTO, IndicationDTO res) {
+        List<BillMsg> criticalList = res.getCriticalValList();
+        PacsLabel pacsLabel = wordCrfDTO.getPacsLabel();
+        List<Item> itemList = pacsLabel.getRes();
+        Set<String> set = new LinkedHashSet<>();
+        List<String> msg = new LinkedList<>();
+        for (Item item : itemList) {
+            RuleVO ruleVO = getRuleVO(item);
+            if (ruleVO != null) {
+                // 1、获取危急值相关数据
+                RuleExtDTO ruleExtDTO = commonFacade.getRuleData(ruleVO);
+                // 如果有完全包含关系,留下最长的一条,例如:右中间支气管异物, 支气管异物,异物,
+                // 最终只提示:右中间支气管异物
+                if (ruleExtDTO != null) {
+                    set.add(ruleExtDTO.getLibName());
+                }
+            }
+        }
+        for (String s : set) {
+            boolean flag = true;
+            for (String s1 : set) {
+                if (s1.contains(s) && !s1.equals(s)) {
+                    flag = false;
                     break;
+                }
             }
+            if (flag) {
+                msg.add(s);
+            }
+        }
+        pacsRule.critical(msg, criticalList);
+    }
+
+    /**
+     * 获取危急值入参——化验
+     *
+     * @param lis
+     * @return
+     */
+    public RuleVO getRuleVO(Lis lis) {
+        if (StringUtil.isNotBlank(lis.getUniqueName())) {
+            RuleVO ruleVO = new RuleVO();
+            ruleVO.setInputName(lis.getName());
+            ruleVO.setLibName(lis.getUniqueName());
+            ruleVO.setLibType(LibTypeEnum.lisDetail.getKey());
+            ruleVO.setLibTypeName(TypeEnum.lis.getName());
+            ruleVO.setDateValue(lis.getDateValue());
+            ruleVO.setSuffix(String.valueOf(RuleTypeEnum.critical.getKey()));
+            return ruleVO;
+        }
+        return null;
+    }
+
+    /**
+     * 获取危急值入参——辅检
+     *
+     * @param item
+     * @return
+     */
+    public RuleVO getRuleVO(Item item) {
+        if (StringUtil.isNotBlank(item.getUniqueName())) {
+            RuleVO ruleVO = new RuleVO();
+            ruleVO.setInputName(item.getName());
+            ruleVO.setLibName(item.getUniqueName());
+            ruleVO.setLibType(LibTypeEnum.pacsResult.getKey());
+            ruleVO.setLibTypeName(TypeEnum.pacs.getName());
+            ruleVO.setDateValue(item.getDateValue());
+            ruleVO.setSuffix(String.valueOf(RuleTypeEnum.critical.getKey()));
+            return ruleVO;
         }
-        res.setCriticalValList(criticalList);
+        return null;
     }
 }

+ 154 - 0
src/main/java/com/diagbot/process/HighRiskProcess.java

@@ -1,12 +1,28 @@
 package com.diagbot.process;
 
+import com.diagbot.biz.push.entity.Item;
 import com.diagbot.dto.BillMsg;
 import com.diagbot.dto.HighRiskNeoDTO;
 import com.diagbot.dto.IndicationDTO;
 import com.diagbot.dto.NodeNeoDTO;
+import com.diagbot.dto.RuleBaseDTO;
+import com.diagbot.dto.RuleConditionDTO;
+import com.diagbot.dto.RuleExtDTO;
+import com.diagbot.dto.RuleSimpleDTO;
 import com.diagbot.dto.WordCrfDTO;
+import com.diagbot.enums.LibTypeEnum;
+import com.diagbot.enums.RuleTypeEnum;
 import com.diagbot.enums.TypeEnum;
+import com.diagbot.facade.CommonFacade;
+import com.diagbot.model.label.PacsLabel;
+import com.diagbot.rule.AgeRule;
 import com.diagbot.rule.CommonRule;
+import com.diagbot.rule.LisRule;
+import com.diagbot.rule.VitalRule;
+import com.diagbot.util.BeanUtil;
+import com.diagbot.util.StringUtil;
+import com.diagbot.vo.Drug;
+import com.diagbot.vo.RuleVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
@@ -23,6 +39,144 @@ public class HighRiskProcess {
 
     @Autowired
     CommonRule commonRule;
+    @Autowired
+    CommonFacade commonFacade;
+    @Autowired
+    AgeRule ageRule;
+    @Autowired
+    LisRule lisRule;
+    @Autowired
+    VitalRule vitalRule;
+
+    /**
+     * 处理业务——高危药品
+     *
+     * @param wordCrfDTO
+     * @param res
+     */
+    public void processDrug(WordCrfDTO wordCrfDTO, IndicationDTO res) {
+        List<BillMsg> highRiskList = res.getHighRiskList();
+        List<Drug> drugList = wordCrfDTO.getDrugOrder();
+        for (Drug drug : drugList) {
+            RuleVO ruleVO = getRuleVO(drug);
+            // 1、获取高危相关数据
+            if (ruleVO != null) {
+                RuleExtDTO ruleExtDTO = commonFacade.getRuleData(ruleVO);
+                if (ruleExtDTO == null) {
+                    continue;
+                }
+                // 2、简化拼接对象,用于开单项提示语
+                RuleSimpleDTO ruleSimpleDTO = new RuleSimpleDTO();
+                BeanUtil.copyProperties(ruleExtDTO, ruleSimpleDTO);
+                // 3、规则匹配
+                List<RuleConditionDTO> ruleConditionDTOList = ruleExtDTO.getRuleConditionDTOList();
+                for (RuleConditionDTO ruleConditionDTO : ruleConditionDTOList) {
+                    List<RuleBaseDTO> ruleBaseDTOList = ruleConditionDTO.getRuleBaseDTOList();
+                    ruleSimpleDTO.setMsg(ruleConditionDTO.getMsg());
+                    for (RuleBaseDTO ruleBaseDTO : ruleBaseDTOList ) {
+                        if (ruleBaseDTO.getBaseLibName().equals(ruleVO.getForm())) {
+                            commonRule.highRisk(ruleSimpleDTO, highRiskList);
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * 处理业务——高危药品
+     *
+     * @param wordCrfDTO
+     * @param res
+     */
+    public void processOperation(WordCrfDTO wordCrfDTO, IndicationDTO res) {
+        List<BillMsg> highRiskList = res.getHighRiskList();
+        List<Item> operationList = wordCrfDTO.getOperationOrder();
+        for (Item operate : operationList) {
+            RuleVO ruleVO = getRuleVO(operate);
+            // 1、获取高危相关数据
+            if (ruleVO != null) {
+                RuleExtDTO ruleExtDTO = commonFacade.getRuleData(ruleVO);
+                if (ruleExtDTO == null) {
+                    continue;
+                }
+                // 2、简化拼接对象,用于开单项提示语
+                RuleSimpleDTO ruleSimpleDTO = new RuleSimpleDTO();
+                BeanUtil.copyProperties(ruleExtDTO, ruleSimpleDTO);
+                // 3、规则匹配
+                List<RuleConditionDTO> ruleConditionDTOList = ruleExtDTO.getRuleConditionDTOList();
+                for (RuleConditionDTO ruleConditionDTO : ruleConditionDTOList) {
+                    List<RuleBaseDTO> ruleBaseDTOList = ruleConditionDTO.getRuleBaseDTOList();
+                    for (RuleBaseDTO ruleBaseDTO : ruleBaseDTOList ) {
+                        if (LibTypeEnum.getEnum(ruleBaseDTO.getBaseLibType()) != null) { // 避免空指针
+                            switch (LibTypeEnum.getEnum(ruleBaseDTO.getBaseLibType())) {
+                                case age: // 年龄
+                                    ageRule.highOperation(wordCrfDTO, ruleBaseDTO, highRiskList, ruleSimpleDTO);
+                                    break;
+                                case disease: // 诊断
+                                    commonRule.compareItemWithHighRisk(wordCrfDTO.getDiag(), ruleBaseDTO, highRiskList, ruleSimpleDTO);
+                                    break;
+                                case lisDetail: // 化验
+                                    lisRule.highOperation(wordCrfDTO.getLis(), ruleBaseDTO, highRiskList, ruleSimpleDTO);
+                                    break;
+                                case vitalRes: //体格检查结果
+                                case vital: // 体格检查项目
+                                    vitalRule.highOperation(wordCrfDTO.getVitalLabel(), ruleBaseDTO, highRiskList, ruleSimpleDTO);
+                                    break;
+                                case pacsResult: // 禁用辅助检查描述
+                                    // 【辅检结果数据来源】
+                                    PacsLabel pacsLabel = wordCrfDTO.getPacsLabel();
+                                    List<Item> pacsDescList = pacsLabel.getRes();
+                                    commonRule.compareItemWithHighRisk(pacsDescList, ruleBaseDTO, highRiskList, ruleSimpleDTO);
+                                    break;
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * 获取高危入参——药品
+     *
+     * @param bean
+     * @return
+     */
+    public RuleVO getRuleVO(Drug bean) {
+        if (StringUtil.isNotBlank(bean.getUniqueName())) {
+            RuleVO ruleVO = new RuleVO();
+            ruleVO.setInputName(bean.getName());
+            ruleVO.setLibName(bean.getUniqueName());
+            ruleVO.setLibType(LibTypeEnum.drug.getKey());
+            ruleVO.setLibTypeName(TypeEnum.drug.getName());
+            ruleVO.setDateValue(bean.getDateValue());
+            ruleVO.setSuffix(String.valueOf(RuleTypeEnum.high.getKey()));
+            ruleVO.setForm(bean.getForm());
+            return ruleVO;
+        }
+        return null;
+    }
+
+    /**
+     * 获取高危入参——手术
+     *
+     * @param bean
+     * @return
+     */
+    public RuleVO getRuleVO(Item bean) {
+        if (StringUtil.isNotBlank(bean.getUniqueName())) {
+            RuleVO ruleVO = new RuleVO();
+            ruleVO.setInputName(bean.getName());
+            ruleVO.setLibName(bean.getUniqueName());
+            ruleVO.setLibType(LibTypeEnum.operation.getKey());
+            ruleVO.setLibTypeName(TypeEnum.operation.getName());
+            ruleVO.setDateValue(bean.getDateValue());
+            ruleVO.setSuffix(String.valueOf(RuleTypeEnum.high.getKey()));
+            return ruleVO;
+        }
+        return null;
+    }
 
     /**
      * 处理业务

+ 119 - 53
src/main/java/com/diagbot/process/OtherTipProcess.java

@@ -1,29 +1,33 @@
 package com.diagbot.process;
 
+import com.diagbot.biz.push.entity.Item;
 import com.diagbot.biz.push.entity.Lis;
 import com.diagbot.dto.BillMsg;
 import com.diagbot.dto.IndicationDTO;
-import com.diagbot.dto.NodeNeoDTO;
-import com.diagbot.dto.OtherTipNeoDTO;
-import com.diagbot.dto.OtherTipPacsNeoDTO;
 import com.diagbot.dto.OtherTipTransfusionNeoDTO;
+import com.diagbot.dto.RuleBaseDTO;
+import com.diagbot.dto.RuleConditionDTO;
+import com.diagbot.dto.RuleExtDTO;
 import com.diagbot.dto.WordCrfDTO;
-import com.diagbot.enums.NeoEnum;
+import com.diagbot.enums.LibTypeEnum;
+import com.diagbot.enums.RuleTypeEnum;
 import com.diagbot.enums.TypeEnum;
+import com.diagbot.facade.CommonFacade;
+import com.diagbot.model.label.PacsLabel;
 import com.diagbot.rule.CommonRule;
 import com.diagbot.rule.GroupRule;
+import com.diagbot.rule.LisRule;
+import com.diagbot.rule.PacsRule;
 import com.diagbot.util.CoreUtil;
 import com.diagbot.util.ListUtil;
 import com.diagbot.util.MsgUtil;
 import com.diagbot.util.StringUtil;
+import com.diagbot.vo.RuleVO;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
-import java.util.LinkedHashMap;
 import java.util.List;
-import java.util.Map;
-import java.util.Set;
 import java.util.stream.Collectors;
 
 /**
@@ -38,51 +42,35 @@ public class OtherTipProcess {
     GroupRule groupRule;
     @Autowired
     CommonRule commonRule;
+    @Autowired
+    CommonFacade commonFacade;
+    @Autowired
+    LisRule lisRule;
+    @Autowired
+    PacsRule pacsRule;
 
     /**
      * 处理业务——化验
      *
-     * @param otherTipNeoDTOList
      * @param wordCrfDTO
      * @param res
      */
-    public void processLis(List<OtherTipNeoDTO> otherTipNeoDTOList, WordCrfDTO wordCrfDTO, IndicationDTO res) {
-        // 化验结果与诊断和开单药品进行匹配
-        for (OtherTipNeoDTO otherTipNeoDTO : otherTipNeoDTOList) {
-            List<NodeNeoDTO> factor = otherTipNeoDTO.getFactor();
-
-            if (ListUtil.isNotEmpty(factor)) {
-                for (NodeNeoDTO nodeNeoDTO : factor) {
-                    Map map = new LinkedHashMap();
-                    if (TypeEnum.disease.getName().equals(nodeNeoDTO.getTermtype())) { // 诊断
-                        map = CoreUtil.compareNameWithNode(nodeNeoDTO, wordCrfDTO.getDiag());
-                    } else if (TypeEnum.drug.getName().equals(nodeNeoDTO.getTermtype())) { // 药品
-                        map = CoreUtil.compareNameWithNode(nodeNeoDTO, wordCrfDTO.getDrug());
-                    } else if (NeoEnum.group.getName().equals(nodeNeoDTO.getTermtype())) { // "禁忌人群"
-                        map = groupRule.gravidityRule(wordCrfDTO);
-                    }
-                    if (CoreUtil.getMapFlag(map) == true) {
-                        String content = "";
-                        if (otherTipNeoDTO.getName() == null || otherTipNeoDTO.getDetailName() == null
-                                || !otherTipNeoDTO.getName().equals(otherTipNeoDTO.getDetailName())) {
-                            content = otherTipNeoDTO.getName() + otherTipNeoDTO.getDetailName();
-                        } else {
-                            content = otherTipNeoDTO.getDetailName();
-                        }
-
-                        if (StringUtil.isNotBlank(otherTipNeoDTO.getOtherValue())) {
-                            content += otherTipNeoDTO.getOtherValue();
-                        } else {
-                            content += CoreUtil.subZeroAndDot(otherTipNeoDTO.getValue().toString());
-                        }
-                        List<String> msgList = (List<String>)map.get("msg");
-                        if (ListUtil.isNotEmpty(msgList)) {
-                            for (String msg : msgList) {
-                                BillMsg billMsg = MsgUtil.getCommonOtherTipLisMsg(content, msg, nodeNeoDTO.getTermtype());
-                                res.getOtherList().add(billMsg);
-                            }
-                        }
-                    }
+    public void processLis(WordCrfDTO wordCrfDTO, IndicationDTO res) {
+        List<Lis> lisList = wordCrfDTO.getLis();
+        List<BillMsg> otherList = res.getOtherList();
+        for (Lis lis : lisList) {
+            RuleVO ruleVO = getRuleVO(lis, RuleTypeEnum.other.getKey());
+            // 1、获取相关数据
+            if (ruleVO != null) {
+                RuleExtDTO ruleExtDTO = commonFacade.getRuleData(ruleVO);
+                if (ruleExtDTO == null) {
+                    continue;
+                }
+                List<RuleConditionDTO> ruleConditionDTOList = ruleExtDTO.getRuleConditionDTOList();
+                for (RuleConditionDTO ruleConditionDTO : ruleConditionDTOList) {
+                    List<RuleBaseDTO> ruleBaseDTOList = ruleConditionDTO.getRuleBaseDTOList();
+                    // 2、规则匹配
+                    lisRule.otherLis(lis, ruleBaseDTOList, otherList, wordCrfDTO);
                 }
             }
         }
@@ -91,20 +79,98 @@ public class OtherTipProcess {
     /**
      * 处理业务——辅检
      *
-     * @param otherTipTransfusionNeoDTOList
+     * @param wordCrfDTO
+     * @param res
+     */
+    public void processPacs(WordCrfDTO wordCrfDTO, IndicationDTO res) {
+        PacsLabel pacsLabel = wordCrfDTO.getPacsLabel();
+        List<Item> itemList = pacsLabel.getRes();
+        List<BillMsg> otherList = res.getOtherList();
+        for (Item item : itemList) {
+            RuleVO ruleVO = getRuleVO(item);
+            // 1、获取相关数据
+            if (ruleVO != null) {
+                RuleExtDTO ruleExtDTO = commonFacade.getRuleData(ruleVO);
+                if (ruleExtDTO == null) {
+                    continue;
+                }
+                List<RuleConditionDTO> ruleConditionDTOList = ruleExtDTO.getRuleConditionDTOList();
+                for (RuleConditionDTO ruleConditionDTO : ruleConditionDTOList) {
+                    List<RuleBaseDTO> ruleBaseDTOList = ruleConditionDTO.getRuleBaseDTOList();
+                    // 2、规则匹配
+                    pacsRule.otherPacs(ruleBaseDTOList, ruleConditionDTO.getMsg(), otherList, wordCrfDTO);
+                }
+            }
+        }
+    }
+
+    /**
+     * 处理业务——输血
+     *
+     * @param wordCrfDTO
      * @param res
      */
-    public void processPacs(List<OtherTipPacsNeoDTO> otherTipTransfusionNeoDTOList, IndicationDTO res) {
-        if (ListUtil.isNotEmpty(otherTipTransfusionNeoDTOList)) {
-            // 去重
-            Set<String> msgList = otherTipTransfusionNeoDTOList.stream().map(r -> r.getMsg()).collect(Collectors.toSet());
-            for (String s : msgList) {
-                BillMsg billMsg = MsgUtil.getCommonOtherTipPacsMsg(s);
-                res.getOtherList().add(billMsg);
+    public void processTransfusion(WordCrfDTO wordCrfDTO, IndicationDTO res) {
+        List<Lis> lisList = wordCrfDTO.getLis();
+        List<BillMsg> otherList = res.getOtherList();
+        for (Lis lis : lisList) {
+            RuleVO ruleVO = getRuleVO(lis, RuleTypeEnum.transfusion.getKey());
+            // 1、获取相关数据
+            if (ruleVO != null) {
+                RuleExtDTO ruleExtDTO = commonFacade.getRuleData(ruleVO);
+                if (ruleExtDTO == null) {
+                    continue;
+                }
+                List<RuleConditionDTO> ruleConditionDTOList = ruleExtDTO.getRuleConditionDTOList();
+                for (RuleConditionDTO ruleConditionDTO : ruleConditionDTOList) {
+                    List<RuleBaseDTO> ruleBaseDTOList = ruleConditionDTO.getRuleBaseDTOList();
+                    // 2、规则匹配
+                    lisRule.otherTransfusion(lis, ruleBaseDTOList, ruleConditionDTO.getMsg(), otherList, wordCrfDTO);
+                }
             }
         }
     }
 
+    /**
+     * 获取其他值提醒入参——辅检
+     *
+     * @param bean
+     * @return
+     */
+    public RuleVO getRuleVO(Item bean) {
+        if (StringUtil.isNotBlank(bean.getUniqueName())) {
+            RuleVO ruleVO = new RuleVO();
+            ruleVO.setInputName(bean.getName());
+            ruleVO.setLibName(bean.getUniqueName());
+            ruleVO.setLibType(LibTypeEnum.pacsResult.getKey());
+            ruleVO.setLibTypeName(TypeEnum.pacs.getName());
+            ruleVO.setDateValue(bean.getDateValue());
+            ruleVO.setSuffix(String.valueOf(RuleTypeEnum.other.getKey()));
+            return ruleVO;
+        }
+        return null;
+    }
+
+    /**
+     * 获取其他值提醒入参——化验
+     *
+     * @param lis
+     * @return
+     */
+    public RuleVO getRuleVO(Lis lis, Integer key) {
+        if (StringUtil.isNotBlank(lis.getUniqueName())) {
+            RuleVO ruleVO = new RuleVO();
+            ruleVO.setInputName(lis.getName());
+            ruleVO.setLibName(lis.getUniqueName());
+            ruleVO.setLibType(LibTypeEnum.lisDetail.getKey());
+            ruleVO.setLibTypeName(TypeEnum.lis.getName());
+            ruleVO.setDateValue(lis.getDateValue());
+            ruleVO.setSuffix(String.valueOf(key));
+            return ruleVO;
+        }
+        return null;
+    }
+
     /**
      * 处理业务——输血
      *

+ 45 - 15
src/main/java/com/diagbot/rule/AgeRule.java

@@ -1,8 +1,8 @@
 package com.diagbot.rule;
 
 import com.diagbot.dto.BillMsg;
-import com.diagbot.dto.BillNeoMaxDTO;
-import com.diagbot.dto.NodeNeoDTO;
+import com.diagbot.dto.RuleBaseDTO;
+import com.diagbot.dto.RuleSimpleDTO;
 import com.diagbot.dto.WordCrfDTO;
 import com.diagbot.util.CoreUtil;
 import com.diagbot.util.MsgUtil;
@@ -19,25 +19,55 @@ import java.util.List;
 public class AgeRule {
 
     /**
-     * 年龄比较
+     * 比较年龄——开单项
      *
      * @param wordCrfDTO
-     * @param billNeoMaxDTO
-     * @return
+     * @param ruleBaseDTO
+     * @param billMsgList
+     * @param conType
+     * @param ruleSimpleDTO
      */
-    public void bill(WordCrfDTO wordCrfDTO, BillNeoMaxDTO billNeoMaxDTO, List<BillMsg> billMsgList, String type) {
-        NodeNeoDTO ageNeoDTO = billNeoMaxDTO.getAgeNeoDTO();
-        Boolean flag = false;
-        if (ageNeoDTO != null && wordCrfDTO.getAgeNum() != null) {
-            Double age = wordCrfDTO.getAgeNum();
-            flag = CoreUtil.compareNum(ageNeoDTO, age);
-        }
+    public void bill(WordCrfDTO wordCrfDTO, RuleBaseDTO ruleBaseDTO, List<BillMsg> billMsgList, String conType, RuleSimpleDTO ruleSimpleDTO) {
+        Boolean flag = getFlag(wordCrfDTO, ruleBaseDTO);
         if (flag) {
-            // String message = CoreUtil.getStrMsgWithRange(ageNeoDTO, "年龄", String.valueOf(wordCrfDTO.getAge()));
             String message = "年龄" + wordCrfDTO.getAge();
-            BillMsg billMsg = MsgUtil.getCommonBillMsg(billNeoMaxDTO.getOrderName(), billNeoMaxDTO.getOrderStandName(),
-                    message, type, billNeoMaxDTO.getType());
+            BillMsg billMsg = MsgUtil.getCommonBillMsg(ruleSimpleDTO.getInputName(), ruleSimpleDTO.getLibName(),
+                    message, conType, ruleSimpleDTO.getLibTypeName());
             billMsgList.add(billMsg);
         }
     }
+
+    /**
+     * 比较年龄——高危手术
+     *
+     * @param wordCrfDTO
+     * @param ruleBaseDTO
+     * @param highRiskList
+     * @param ruleSimpleDTO
+     */
+    public void highOperation(WordCrfDTO wordCrfDTO, RuleBaseDTO ruleBaseDTO, List<BillMsg> highRiskList, RuleSimpleDTO ruleSimpleDTO) {
+        Boolean flag = getFlag(wordCrfDTO, ruleBaseDTO);
+        if (flag) {
+            String message = "年龄:" + wordCrfDTO.getAge();
+            BillMsg billMsg = MsgUtil.getComplexOperationMsg(message, ruleSimpleDTO.getInputName(), ruleSimpleDTO.getLibTypeName());
+            highRiskList.add(billMsg);
+        }
+    }
+
+    /**
+     * 匹配规则
+     *
+     * @param wordCrfDTO
+     * @param ruleBaseDTO
+     * @return
+     */
+    public boolean getFlag(WordCrfDTO wordCrfDTO, RuleBaseDTO ruleBaseDTO) {
+        Boolean flag = false;
+        if (wordCrfDTO.getAgeNum() != null) {
+            Double age = wordCrfDTO.getAgeNum();
+            flag = CoreUtil.compareNum(ruleBaseDTO, age);
+        }
+        return flag;
+    }
+
 }

+ 161 - 95
src/main/java/com/diagbot/rule/CommonRule.java

@@ -3,9 +3,10 @@ package com.diagbot.rule;
 import com.diagbot.biz.push.entity.Item;
 import com.diagbot.biz.push.entity.Pacs;
 import com.diagbot.dto.BillMsg;
-import com.diagbot.dto.BillNeoMaxDTO;
 import com.diagbot.dto.HighRiskNeoDTO;
 import com.diagbot.dto.NodeNeoDTO;
+import com.diagbot.dto.RuleBaseDTO;
+import com.diagbot.dto.RuleSimpleDTO;
 import com.diagbot.dto.WordCrfDTO;
 import com.diagbot.enums.NeoEnum;
 import com.diagbot.enums.TypeEnum;
@@ -17,20 +18,19 @@ import com.diagbot.util.ListUtil;
 import com.diagbot.util.MsgUtil;
 import com.diagbot.util.StringUtil;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.ss.formula.functions.T;
 import org.springframework.stereotype.Component;
 
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.Date;
-import java.util.HashMap;
-import java.util.LinkedHashSet;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
-import java.util.stream.Collectors;
 
 /**
  * @description: 通用规则提取
@@ -41,39 +41,35 @@ import java.util.stream.Collectors;
 public class CommonRule {
 
     /**
-     * 比较界面元素是否在图谱中存在(匹配名称)
+     * 比较阳性属性是否匹配
      *
-     * @param neoList       图谱结构
-     * @param inputLises    界面元素
-     * @param billNeoMaxDTO 开单项名称,开单项标准名称
-     * @return
+     * @param input
+     * @param ruleBaseDTO
+     * @param billMsgList
+     * @param conType
+     * @param ruleSimpleDTO
+     * @param <T>
      */
-    public <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) {
+    public <T> void compareNameWithBill(List<T> input, RuleBaseDTO ruleBaseDTO, List<BillMsg> billMsgList,
+                                        String conType, RuleSimpleDTO ruleSimpleDTO) {
+        if (ListUtil.isNotEmpty(input)) {
+            for (T d : input) {
                 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()) {
-                    if ("禁忌手术".equals(type)) {
-                        BillMsg commonBillMsg = MsgUtil.getCommonSurgeryMsg(
-                                billNeoMaxDTO.getOrderName(), billNeoMaxDTO.getOrderStandName(),
-                                d.getKey(), type, billNeoMaxDTO.getType());
-                        billMsgList.add(commonBillMsg);
-                    } else {
-                        BillMsg commonBillMsg = MsgUtil.getCommonBillMsg(
-                                billNeoMaxDTO.getOrderName(), billNeoMaxDTO.getOrderStandName(),
-                                d.getKey(), type, billNeoMaxDTO.getType());
-                        billMsgList.add(commonBillMsg);
+                    if (StringUtils.isNotBlank(c) && CoreUtil.compareName(ruleBaseDTO, c)) {
+                        if ("禁忌手术".equals(conType)) {
+                            BillMsg commonBillMsg = MsgUtil.getCommonSurgeryMsg(
+                                    ruleSimpleDTO.getInputName(), ruleSimpleDTO.getLibName(),
+                                    c_name, conType, ruleSimpleDTO.getLibTypeName());
+                            billMsgList.add(commonBillMsg);
+                        } else {
+                            BillMsg commonBillMsg = MsgUtil.getCommonBillMsg(
+                                    ruleSimpleDTO.getInputName(), ruleSimpleDTO.getLibName(),
+                                    c_name, conType, ruleSimpleDTO.getLibTypeName());
+                            billMsgList.add(commonBillMsg);
+                        }
                     }
                 }
             }
@@ -81,67 +77,129 @@ public class CommonRule {
     }
 
     /**
-     * 比较界面元素是否在图谱中存在(匹配名称)
+     * 比较是否包含
      *
-     * @param neoList       图谱结构
-     * @param input         界面元素
-     * @param billNeoMaxDTO 开单项名称,开单项标准名称
+     * @param input
+     * @param ruleBaseDTO
      * @return
      */
-    public <T> void compareItemWithBill(List<NodeNeoDTO> neoList, List<T> input, BillNeoMaxDTO billNeoMaxDTO, List<BillMsg> billMsgList, String type) {
-        Map<String, String> old_stand = new HashMap<>();
-        if (ListUtil.isNotEmpty(neoList) && ListUtil.isNotEmpty(input)) {
-            for (T d : input) {
-                String c = (String) CoreUtil.getFieldValue(d, "uniqueName");
-                String c_name = (String) CoreUtil.getFieldValue(d, "name");
-                for (NodeNeoDTO nodeNeoDTO : neoList) {
-                    if (CoreUtil.compareNodeName(nodeNeoDTO, c)) {
-                        old_stand.put(c_name, c);
-                    }
+    public <T> Boolean containsItem(List<T> input, RuleBaseDTO ruleBaseDTO) {
+        if (ListUtil.isNotEmpty(input) && ruleBaseDTO != null) {
+            for (T t : input) {
+                String c = (String) CoreUtil.getFieldValue(t, "uniqueName"); // 标准名称
+                if (c.contains(ruleBaseDTO.getBaseLibName())) {
+                    return true;
                 }
             }
-            if (old_stand.size() > 0) {
-                for (String key : old_stand.keySet()) {
+        }
+        return false;
+    }
+
+    /**
+     * 比较名称是否匹配
+     *
+     * @param input
+     * @param ruleBaseDTO
+     * @param <T>
+     */
+    public <T> Map compareItem(List<T> input, RuleBaseDTO ruleBaseDTO) {
+        Map<String, Object> map = new LinkedHashMap<>();
+        boolean flag = false;
+        if (ruleBaseDTO == null || ListUtil.isEmpty(input)) {
+            map.put("flag", flag);
+            return map;
+        }
+        List<String> msgList = new ArrayList<>();
+        for (T t : input) {
+            String c = (String) CoreUtil.getFieldValue(t, "uniqueName"); // 标准名称
+            String c_name = (String) CoreUtil.getFieldValue(t, "name"); // 界面名称
+            if (CoreUtil.compareName(ruleBaseDTO, c)) {
+                msgList.add(c_name);
+                flag = true;
+            }
+        }
+        map.put("flag", flag);
+        map.put("msgList", msgList);
+        return map;
+    }
+
+    /**
+     * 比较名称是否匹配
+     *
+     * @param input
+     * @param ruleBaseDTO
+     * @param billMsgList
+     * @param conType
+     * @param ruleSimpleDTO
+     * @param <T>
+     */
+    public <T> void compareItemWithBill(List<T> input, RuleBaseDTO ruleBaseDTO, List<BillMsg> billMsgList,
+                                        String conType, RuleSimpleDTO ruleSimpleDTO) {
+        if (ListUtil.isNotEmpty(input)) {
+            for (T t : input) {
+                String c = (String) CoreUtil.getFieldValue(t, "uniqueName"); // 标准名称
+                String c_name = (String) CoreUtil.getFieldValue(t, "name"); // 界面名称
+                if (CoreUtil.compareName(ruleBaseDTO, c)) {
                     BillMsg commonBillMsg = MsgUtil.getCommonBillMsg(
-                            billNeoMaxDTO.getOrderName(), billNeoMaxDTO.getOrderStandName(),
-                            key, type, billNeoMaxDTO.getType());
+                            ruleSimpleDTO.getInputName(), ruleSimpleDTO.getLibName(),
+                            c_name, conType, ruleSimpleDTO.getLibTypeName());
                     billMsgList.add(commonBillMsg);
                 }
             }
         }
     }
 
+    /**
+     * 比较名称是否匹配
+     *
+     * @param input
+     * @param ruleBaseDTO
+     * @param highRiskList
+     * @param ruleSimpleDTO
+     * @param <T>
+     */
+    public <T> void compareItemWithHighRisk(List<T> input, RuleBaseDTO ruleBaseDTO, List<BillMsg> highRiskList, RuleSimpleDTO ruleSimpleDTO) {
+        if (ListUtil.isNotEmpty(input)) {
+            for (T t : input) {
+                String c = (String) CoreUtil.getFieldValue(t, "uniqueName"); // 标准名称
+                String c_name = (String) CoreUtil.getFieldValue(t, "name"); // 界面名称
+                if (CoreUtil.compareName(ruleBaseDTO, c)) {
+                    BillMsg billMsg = MsgUtil.getComplexOperationMsg(c_name, ruleSimpleDTO.getInputName(), ruleSimpleDTO.getLibTypeName());
+                    highRiskList.add(billMsg);
+                }
+            }
+        }
+    }
+
     /**
      * 无需重复开单项
      *
      * @param wordCrfDTO
-     * @param billNeoMaxDTO
+     * @param ruleBaseDTO
      * @param billMsgList
+     * @param ruleSimpleDTO
      */
-    public void needlessRepeatOrder(WordCrfDTO wordCrfDTO, BillNeoMaxDTO billNeoMaxDTO, List<BillMsg> billMsgList) {
-        List<NodeNeoDTO> needlessPacsOrder = billNeoMaxDTO.getNeedlessPacsOrder();
-        String orderStandName = billNeoMaxDTO.getOrderStandName();
-        for (NodeNeoDTO nodeNeoDTO : needlessPacsOrder) {
-            Map<String, List<Pacs>> map = EntityUtil.makeEntityListMap(wordCrfDTO.getPacs(), "uniqueName");
-            List<Pacs> pacsList = map.get(orderStandName);
-            if (ListUtil.isNotEmpty(pacsList)) {
-                sortByProperty(pacsList, "dateValue");
-                Pacs pacs = pacsList.get(pacsList.size() - 1);
-                String result = pacs.getResult();
-                if (StringUtil.isNotBlank(result) && StringUtil.isNotBlank(nodeNeoDTO.getRegex())
-                        && getRegexRes(result, nodeNeoDTO.getRegex())) {
-                    String dateValue = pacs.getDateValue(); // 结果日期
-                    String orderDateValue = billNeoMaxDTO.getDateValue(); // 开单项日期
-                    if (StringUtil.isNotBlank(dateValue) && StringUtil.isNotBlank(orderDateValue)) {
-                        Date dateValueDate = CatalogueUtil.parseStringDate(dateValue);
-                        Date orderDateValueDate = CatalogueUtil.parseStringDate(orderDateValue);
-                        if (dateValueDate != null && orderDateValueDate != null) {
-                            if (!CatalogueUtil.compareTime(dateValueDate, orderDateValueDate, 60L * 24 * 7)) {
-                                BillMsg commonBillMsg = MsgUtil.getNeedlessRepeatOrderMsg(
-                                        billNeoMaxDTO.getOrderName(), billNeoMaxDTO.getOrderStandName(),
-                                        pacs.getName(), billNeoMaxDTO.getType());
-                                billMsgList.add(commonBillMsg);
-                            }
+    public void needlessRepeatOrder(WordCrfDTO wordCrfDTO, RuleBaseDTO ruleBaseDTO, List<BillMsg> billMsgList, RuleSimpleDTO ruleSimpleDTO) {
+        String orderStandName = ruleBaseDTO.getBaseLibName();
+        Map<String, List<Pacs>> map = EntityUtil.makeEntityListMap(wordCrfDTO.getPacs(), "uniqueName");
+        List<Pacs> pacsList = map.get(orderStandName);
+        if (ListUtil.isNotEmpty(pacsList)) {
+            sortByProperty(pacsList, "dateValue");
+            Pacs pacs = pacsList.get(pacsList.size() - 1); // 按时间排序,取最后一条
+            String result = pacs.getResult();
+            if (StringUtil.isNotBlank(result) && StringUtil.isNotBlank(ruleBaseDTO.getBaseEqValue())
+                    && getRegexRes(result, ruleBaseDTO.getBaseEqValue())) {
+                String dateValue = pacs.getDateValue(); // 结果日期
+                String orderDateValue = ruleSimpleDTO.getDateValue(); // 开单项日期
+                if (StringUtil.isNotBlank(dateValue) && StringUtil.isNotBlank(orderDateValue)) {
+                    Date dateValueDate = CatalogueUtil.parseStringDate(dateValue);
+                    Date orderDateValueDate = CatalogueUtil.parseStringDate(orderDateValue);
+                    if (dateValueDate != null && orderDateValueDate != null) {
+                        if (!CatalogueUtil.compareTime(dateValueDate, orderDateValueDate, 60L * 24 * 7)) {
+                            BillMsg commonBillMsg = MsgUtil.getNeedlessRepeatOrderMsg(
+                                    ruleSimpleDTO.getInputName(), ruleSimpleDTO.getLibName(),
+                                    pacs.getName(), ruleSimpleDTO.getLibTypeName());
+                            billMsgList.add(commonBillMsg);
                         }
                     }
                 }
@@ -218,34 +276,30 @@ public class CommonRule {
      * 互斥开单项
      *
      * @param wordCrfDTO
+     * @param ruleBaseDTO
      * @param billMsgList
+     * @param ruleSimpleDTO
+     * @param set 用于记录:A与B不宜同时进行, B与A不宜同时进行 只能提示一个
      */
-    public void exclusionBill(List<BillNeoMaxDTO> billNeoMaxDTOList, WordCrfDTO wordCrfDTO, List<BillMsg> billMsgList) {
+    public void exclusionBill(WordCrfDTO wordCrfDTO, RuleBaseDTO ruleBaseDTO, List<BillMsg> billMsgList, RuleSimpleDTO ruleSimpleDTO, Set<String> set) {
         // 辅检开单项互斥
         List<Pacs> pacsOrder = wordCrfDTO.getPacsOrder();
-        Set<String> set = new LinkedHashSet<>();    // A与B不宜同时进行, B与A不宜同时进行 只能提示一个
         if (ListUtil.isNotEmpty(pacsOrder) && pacsOrder.size() > 1) {
             // 不同的辅检项目可能对应同一个uniqueName,提示显示多条
             Map<String, List<Pacs>> map = EntityUtil.makeEntityListMap(pacsOrder, "uniqueName");
-            for (BillNeoMaxDTO billNeoMaxDTO : billNeoMaxDTOList) {
-                List<NodeNeoDTO> nodeList = billNeoMaxDTO.getPacsOrder();
-                if (ListUtil.isNotEmpty(nodeList)) {
-                    for (NodeNeoDTO nodeNeoDTO : nodeList) {
-                        List<Pacs> orginNameList = map.get(nodeNeoDTO.getName());
-                        if (map.get(nodeNeoDTO.getName()) != null) {
-                            for (Pacs pacs : orginNameList) {
-                                String orginName = pacs.getName();
-                                if (!set.contains(billNeoMaxDTO.getOrderName() + "******" + orginName)) {
-                                    set.add(billNeoMaxDTO.getOrderName() + "******" + orginName);
-                                    set.add(orginName + "******" + billNeoMaxDTO.getOrderName());
-                                    BillMsg commonBillMsg = MsgUtil.getBillExclusionMsg(
-                                            billNeoMaxDTO.getOrderName(), orginName,
-                                            billNeoMaxDTO.getOrderName() + "," + orginName,
-                                            NeoEnum.exclusion.getName());
-                                    billMsgList.add(commonBillMsg);
-                                }
-                            }
-                        }
+            List<Pacs> orginNameList = map.get(ruleBaseDTO.getBaseLibName());
+            if (map.get(ruleBaseDTO.getBaseLibName()) != null) {
+                for (Pacs pacs : orginNameList) {
+                    String orginName = pacs.getName();
+                    // A与B不宜同时进行, B与A不宜同时进行 只能提示一个
+                    if (!set.contains(ruleSimpleDTO.getLibName() + "******" + orginName)) {
+                        set.add(ruleSimpleDTO.getLibName() + "******" + orginName);
+                        set.add(orginName + "******" + ruleSimpleDTO.getLibName());
+                        BillMsg commonBillMsg = MsgUtil.getBillExclusionMsg(
+                                ruleSimpleDTO.getInputName(), orginName,
+                                ruleSimpleDTO.getInputName() + "," + orginName,
+                                NeoEnum.exclusion.getName());
+                        billMsgList.add(commonBillMsg);
                     }
                 }
             }
@@ -326,6 +380,18 @@ public class CommonRule {
         highRiskList.add(billMsg);
     }
 
+    /**
+     * 高风险药品、手术
+     *
+     * @param ruleSimpleDTO
+     * @param highRiskList
+     */
+    public void highRisk(RuleSimpleDTO ruleSimpleDTO, List<BillMsg> highRiskList) {
+        BillMsg billMsg = MsgUtil.getCommonHighRiskMsg(ruleSimpleDTO.getInputName(),
+                ruleSimpleDTO.getMsg(), ruleSimpleDTO.getLibTypeName());
+        highRiskList.add(billMsg);
+    }
+
     /**
      * fa'zha
      *

+ 23 - 30
src/main/java/com/diagbot/rule/DrugRule.java

@@ -1,8 +1,8 @@
 package com.diagbot.rule;
 
 import com.diagbot.dto.BillMsg;
-import com.diagbot.dto.BillNeoMaxDTO;
-import com.diagbot.dto.NodeNeoDTO;
+import com.diagbot.dto.RuleBaseDTO;
+import com.diagbot.dto.RuleSimpleDTO;
 import com.diagbot.enums.RedisEnum;
 import com.diagbot.util.CoreUtil;
 import com.diagbot.util.ListUtil;
@@ -13,9 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 
 /**
  * @description: 实验室检查和辅助检查规则
@@ -29,46 +27,41 @@ public class DrugRule {
     RedisUtil redisUtil;
 
     /**
-     * 比较药品是否存在(图谱返回药品通用名或者药品分类,如果返回的是药品分类,再从redis获取药品通用名)
+     * 比较药品是否匹配(先根据baseLibType判断返回的是药品通用名还是药品分类,如果返回的是药品分类,从redis获取药品通用名)
      *
-     * @param drugList
      * @param inputList
-     * @return
+     * @param ruleBaseDTO
+     * @param billMsgList
+     * @param conType
+     * @param ruleSimpleDTO
+     * @param <T>
      */
-    public <T> void bill(List<NodeNeoDTO> drugList, List<T> inputList, BillNeoMaxDTO billNeoMaxDTO,
-                                               List<BillMsg> billMsgList, String type) {
-        Map<String, String> old_stand = new HashMap<>();
-        if (ListUtil.isNotEmpty(drugList) && ListUtil.isNotEmpty(inputList)) {
+    public <T> void bill(List<T> inputList, RuleBaseDTO ruleBaseDTO, List<BillMsg> billMsgList, String conType,
+                         RuleSimpleDTO ruleSimpleDTO) {
+        if (ListUtil.isNotEmpty(inputList)) {
             List<String> allDrug = new ArrayList<>();
-            for (NodeNeoDTO nodeNeoDTO : drugList) {
-                if ("药品".equals(nodeNeoDTO.getTermtype())) {
-                    allDrug.add(nodeNeoDTO.getName());
-                } else if ("药品类别".equals(nodeNeoDTO.getTermtype())){
-                    String drugType = nodeNeoDTO.getName();
-                    List<String> drugRedis = (List<String>)redisUtil.get(RedisEnum.drugType.getName() + drugType);
-                    if (ListUtil.isNotEmpty(drugRedis)) {
-                        allDrug.addAll(drugRedis);
-                    }
+            if (ruleBaseDTO.getBaseLibType().equals(301) || ruleBaseDTO.getBaseLibType().equals(302)
+                    || ruleBaseDTO.getBaseLibType().equals(303) || ruleBaseDTO.getBaseLibType().equals(304)) {
+                List<String> drugRedis = redisUtil.get(RedisEnum.drugType.getName() + ruleBaseDTO.getBaseLibName());
+                if (ListUtil.isNotEmpty(drugRedis)) {
+                    allDrug.addAll(drugRedis);
                 }
+            } else {
+                allDrug.add(ruleBaseDTO.getBaseLibName());
             }
             for (T d : inputList) {
                 String uniqueName = (String) CoreUtil.getFieldValue(d, "uniqueName");
                 String name = (String) CoreUtil.getFieldValue(d, "name");
                 if (StringUtils.isNotBlank(uniqueName) && allDrug.contains(uniqueName)) {
-                    old_stand.put(name, uniqueName);
-                }
-            }
-            if (old_stand.size() > 0) {
-                for (Map.Entry<String, String> d : old_stand.entrySet()) {
                     String message = "";
-                    if ("禁忌过敏药品".equals(type)) {
-                        message = d.getKey() + "过敏";
+                    if ("禁忌过敏药品".equals(conType)) {
+                        message = name + "过敏";
                     } else {
-                        message = "可能正在用药" + d.getKey();
+                        message = "可能正在用药" + name;
                     }
                     BillMsg commonBillMsg = MsgUtil.getCommonBillMsg(
-                            billNeoMaxDTO.getOrderName(), billNeoMaxDTO.getOrderStandName(),
-                            message, type, billNeoMaxDTO.getType());
+                            ruleSimpleDTO.getInputName(), ruleSimpleDTO.getLibName(),
+                            message, conType, ruleSimpleDTO.getLibTypeName());
                     billMsgList.add(commonBillMsg);
                 }
             }

+ 80 - 55
src/main/java/com/diagbot/rule/GroupRule.java

@@ -2,11 +2,12 @@ package com.diagbot.rule;
 
 import com.diagbot.biz.push.entity.Item;
 import com.diagbot.dto.BillMsg;
-import com.diagbot.dto.BillNeoMaxDTO;
-import com.diagbot.dto.NodeNeoDTO;
+import com.diagbot.dto.RuleBaseDTO;
+import com.diagbot.dto.RuleSimpleDTO;
 import com.diagbot.dto.WordCrfDTO;
 import com.diagbot.util.CoreUtil;
 import com.diagbot.util.MsgUtil;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 import java.util.Arrays;
@@ -24,68 +25,92 @@ import java.util.regex.Pattern;
 @Component
 public class GroupRule {
 
+    @Autowired
+    CommonRule commonRule;
+
+    /**
+     * 禁忌人群开单项
+     *
+     * @param wordCrfDTO
+     * @param ruleBaseDTO
+     * @param billMsgList
+     * @param conType
+     * @param ruleSimpleDTO
+     */
+    public void bill(WordCrfDTO wordCrfDTO, RuleBaseDTO ruleBaseDTO, List<BillMsg> billMsgList, String conType, RuleSimpleDTO ruleSimpleDTO) {
+        Map map = rule(wordCrfDTO, ruleBaseDTO);
+        if ((Boolean)map.get("flag")) {
+            BillMsg commonBillMsg = MsgUtil.getCommonBillMsg(
+                    ruleSimpleDTO.getInputName(), ruleSimpleDTO.getLibName(),
+                    ruleBaseDTO.getBaseLibName(), conType, ruleSimpleDTO.getLibTypeName());
+            billMsgList.add(commonBillMsg);
+        }
+    }
+
     /**
-     * 禁忌人群
+     * 人群规则判断
      *
      * @param wordCrfDTO
-     * @param billNeoMaxDTO
+     * @param ruleBaseDTO
      * @return
      */
-    public void bill(WordCrfDTO wordCrfDTO, BillNeoMaxDTO billNeoMaxDTO, List<BillMsg> billMsgList, String type) {
-        List<NodeNeoDTO> group = billNeoMaxDTO.getGroup();
+    public Map rule(WordCrfDTO wordCrfDTO, RuleBaseDTO ruleBaseDTO) {
+        Map res = new LinkedHashMap();
         Double age = wordCrfDTO.getAgeNum();
-        for (NodeNeoDTO node : group) {
-            // 妊娠目前从诊断里判断,包含“妊娠”
-            String symptom = wordCrfDTO.getSymptom(); // 现病史内容
-            String chief = wordCrfDTO.getChief(); // 主诉
-            String menstrual = wordCrfDTO.getMenstrual(); // 月经史
-
-            switch (node.getName()) {
-                case "妊娠":
-                    Map map = gravidityRule(wordCrfDTO);
-                    if (CoreUtil.getMapFlag(map) == true) {
-                        BillMsg commonBillMsg = MsgUtil.getCommonBillMsg(
-                                billNeoMaxDTO.getOrderName(), billNeoMaxDTO.getOrderStandName(),
-                                "妊娠", type, billNeoMaxDTO.getType());
-                        billMsgList.add(commonBillMsg);
-                    }
-                    break;
-                case "月经期":
-                    String regex = "月经第(([零一二三四五六七八九十]{0,3})||([0-9]{0,2}))天";
-                    Pattern pattern = Pattern.compile(regex);
-                    Matcher matcher = pattern.matcher(symptom);
-                    boolean rs = matcher.find();
-                    Matcher matcher1 = pattern.matcher(menstrual);
-                    boolean rs1 = matcher1.find();
-                    if (rs || rs1 || symptom.contains("经期") || menstrual.contains("经期")) {
-                        BillMsg commonBillMsg = MsgUtil.getCommonBillMsg(
-                                billNeoMaxDTO.getOrderName(), billNeoMaxDTO.getOrderStandName(),
-                                "月经期", type, billNeoMaxDTO.getType());
-                        billMsgList.add(commonBillMsg);
-                    }
-                    break;
-                case "幼儿":
-                    if (age != null) {
-                        if (age < 6.0D && 1.0D <= age) {
-                            BillMsg commonBillMsg = MsgUtil.getCommonBillMsg(
-                                    billNeoMaxDTO.getOrderName(), billNeoMaxDTO.getOrderStandName(),
-                                    "幼儿", type, billNeoMaxDTO.getType());
-                            billMsgList.add(commonBillMsg);
-                        }
+        // 妊娠目前从诊断里判断,包含“妊娠”
+        String symptom = wordCrfDTO.getSymptom(); // 现病史内容
+        String menstrual = wordCrfDTO.getMenstrual(); // 月经史
+        boolean flag = false;
+        switch (ruleBaseDTO.getBaseLibName()) {
+            case "妊娠":
+                Map map = gravidityRule(wordCrfDTO);
+                if (CoreUtil.getMapFlag(map) == true) {
+                    flag = true;
+                }
+                break;
+            case "流产":
+                flag = commonRule.containsItem(wordCrfDTO.getDiag(), ruleBaseDTO);
+                break;
+            case "月经期":
+                String regex = "月经第(([零一二三四五六七八九十]{0,3})||([0-9]{0,2}))天";
+                Pattern pattern = Pattern.compile(regex);
+                Matcher matcher = pattern.matcher(symptom);
+                boolean rs = matcher.find();
+                Matcher matcher1 = pattern.matcher(menstrual);
+                boolean rs1 = matcher1.find();
+                if (rs || rs1 || symptom.contains("经期") || menstrual.contains("经期")) {
+                    flag = true;
+                }
+                break;
+            case "幼儿":
+                if (age != null) {
+                    if (age < 6.0D && 1.0D <= age) {
+                        flag = true;
                     }
-                    break;
-                case "儿童":
-                    if (age != null) {
-                        if (age < 18.0D && age >= 6.0D) {
-                            BillMsg commonBillMsg = MsgUtil.getCommonBillMsg(
-                                    billNeoMaxDTO.getOrderName(), billNeoMaxDTO.getOrderStandName(),
-                                    "儿童", type, billNeoMaxDTO.getType());
-                            billMsgList.add(commonBillMsg);
-                        }
+                }
+                break;
+            case "儿童":
+                if (age != null) {
+                    if (age < 18.0D && age >= 6.0D) {
+                        flag = true;
                     }
-                    break;
-            }
+                }
+                break;
+            case "成人":
+                if (age >= 18) {
+                    flag = true;
+                }
+                break;
+            case "新生儿":
+                if (age <= 1) {
+                    flag = true;
+                }
+                break;
+            default: break;
         }
+        res.put("flag", flag);
+        res.put("msg", ruleBaseDTO.getBaseLibName());
+        return res;
     }
 
     /**

+ 221 - 28
src/main/java/com/diagbot/rule/LisRule.java

@@ -2,15 +2,17 @@ package com.diagbot.rule;
 
 import com.diagbot.biz.push.entity.Lis;
 import com.diagbot.dto.BillMsg;
-import com.diagbot.dto.BillNeoMaxDTO;
-import com.diagbot.dto.CriticalNeoDTO;
-import com.diagbot.dto.NodeNeoDTO;
+import com.diagbot.dto.LisOtherDTO;
+import com.diagbot.dto.RuleBaseDTO;
+import com.diagbot.dto.RuleSimpleDTO;
 import com.diagbot.dto.WordCrfDTO;
+import com.diagbot.enums.LibTypeEnum;
 import com.diagbot.enums.TypeEnum;
 import com.diagbot.util.CoreUtil;
 import com.diagbot.util.ListUtil;
 import com.diagbot.util.MsgUtil;
 import com.diagbot.util.StringUtil;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
 import java.util.List;
@@ -24,26 +26,196 @@ import java.util.Map;
 @Component
 public class LisRule {
 
+    @Autowired
+    GroupRule groupRule;
+    @Autowired
+    CommonRule commonRule;
+
     /**
      * 比较化验——开单合理性
      *
      * @param inputLis
-     * @param billNeoMaxDTO
-     * @return
+     * @param ruleBaseDTO
+     * @param billMsgList
+     * @param conType
+     * @param ruleSimpleDTO
+     */
+    public void bill(List<Lis> inputLis, RuleBaseDTO ruleBaseDTO, List<BillMsg> billMsgList, String conType, RuleSimpleDTO ruleSimpleDTO) {
+        if (ListUtil.isNotEmpty(inputLis) && StringUtil.isNotBlank(ruleBaseDTO.getBaseLibName())) {
+            for (Lis lis : inputLis) {
+                String uniqueName = lis.getUniqueName();
+                if (StringUtil.isNotBlank(uniqueName) && uniqueName.equals(ruleBaseDTO.getBaseLibName())) {
+                    Map<String, Object> map = CoreUtil.compareLis(ruleBaseDTO, lis);
+                    if ((Boolean) map.get("flag") == true) {
+                        BillMsg commonBillMsg = MsgUtil.getCommonBillMsg(ruleSimpleDTO.getInputName(),
+                                ruleSimpleDTO.getLibName(), (String) map.get("msg"), conType, ruleSimpleDTO.getLibTypeName());
+                        billMsgList.add(commonBillMsg);
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * 比较化验——高风险手术
+     *
+     * @param inputLis
+     * @param ruleBaseDTO
+     * @param highRiskList
+     * @param ruleSimpleDTO
+     */
+    public void highOperation(List<Lis> inputLis, RuleBaseDTO ruleBaseDTO, List<BillMsg> highRiskList, RuleSimpleDTO ruleSimpleDTO) {
+        if (ListUtil.isNotEmpty(inputLis) && StringUtil.isNotBlank(ruleBaseDTO.getBaseLibName())) {
+            for (Lis lis : inputLis) {
+                String uniqueName = lis.getUniqueName();
+                if (StringUtil.isNotBlank(uniqueName) && uniqueName.equals(ruleBaseDTO.getBaseLibName())) {
+                    Map<String, Object> map = CoreUtil.compareLis(ruleBaseDTO, lis);
+                    if ((Boolean) map.get("flag") == true) {
+                        BillMsg billMsg = MsgUtil.getComplexOperationMsg((String) map.get("msg"), ruleSimpleDTO.getInputName(), ruleSimpleDTO.getLibTypeName());
+                        highRiskList.add(billMsg);
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * 比较化验——其他值提醒
+     *
+     * @param lisBean
+     * @param ruleBaseDTOList
+     * @param otherList
+     * @param wordCrfDTO
+     */
+    public void otherLis(Lis lisBean, List<RuleBaseDTO> ruleBaseDTOList, List<BillMsg> otherList, WordCrfDTO wordCrfDTO) {
+        if (ListUtil.isEmpty(ruleBaseDTOList)) {
+            return ;
+        }
+        LisOtherDTO lisOtherDTO = new LisOtherDTO();
+        int i = 0;
+        for (RuleBaseDTO ruleBaseDTO : ruleBaseDTOList) {
+            if (LibTypeEnum.getEnum(ruleBaseDTO.getBaseLibType()) != null) { // 避免空指针
+                Map<String, Object> map = null;
+                switch (LibTypeEnum.getEnum(ruleBaseDTO.getBaseLibType())) {
+                    case lisDetail: // 化验细项
+                        if (ruleBaseDTO.getBaseLibName().equals(lisBean.getUniqueName())) {
+                            map = CoreUtil.compareLis(ruleBaseDTO, lisBean);
+                            if ((Boolean) map.get("flag") == true) {
+                                lisOtherDTO.setName((String) map.get("msg"));
+                                i++;
+                            }
+                        }
+                        break;
+                    case group: // 人群
+                        map = groupRule.rule(wordCrfDTO, ruleBaseDTO);
+                        if (CoreUtil.getMapFlag(map)) {
+                            lisOtherDTO.getGroupMsg().add((String)map.get("msg"));
+                            i++;
+                        }
+                        break;
+                    case disease: // 诊断
+                        map = commonRule.compareItem(wordCrfDTO.getDiag(), ruleBaseDTO);
+                        if (CoreUtil.getMapFlag(map)) {
+                            lisOtherDTO.setDiseaseMsg((List<String>)map.get("msgList"));
+                            i++;
+                        }
+                        break;
+                    case drug:
+                        map = commonRule.compareItem(wordCrfDTO.getDrug(), ruleBaseDTO);
+                        if (CoreUtil.getMapFlag(map)) {
+                            lisOtherDTO.setDrugMsg((List<String>)map.get("msgList"));
+                            i++;
+                        }
+                        break;
+                    default:
+                        break;
+                }
+            }
+        }
+        // 条件全部符合
+        if (i == ruleBaseDTOList.size()) {
+            if (StringUtil.isNotBlank(lisOtherDTO.getName())) {
+                if (ListUtil.isNotEmpty(lisOtherDTO.getDiseaseMsg())) {
+                    for (String str : lisOtherDTO.getDiseaseMsg()) {
+                        BillMsg billMsg = MsgUtil.getCommonOtherTipLisMsg(lisOtherDTO.getName(), str, TypeEnum.disease.getName());
+                        otherList.add(billMsg);
+                    }
+                }
+                if (ListUtil.isNotEmpty(lisOtherDTO.getDrugMsg())) {
+                    for (String str : lisOtherDTO.getDrugMsg()) {
+                        BillMsg billMsg = MsgUtil.getCommonOtherTipLisMsg(lisOtherDTO.getName(), str, TypeEnum.drug.getName());
+                        otherList.add(billMsg);
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * 比较化验——其他值提醒
+     *
+     * @param lisBean
+     * @param ruleBaseDTOList
+     * @param otherList
+     * @param wordCrfDTO
      */
-    public void bill(List<Lis> inputLis, BillNeoMaxDTO billNeoMaxDTO, List<BillMsg> billMsgList, String type) {
-        List<NodeNeoDTO> neoList = billNeoMaxDTO.getLis();
-        if(ListUtil.isNotEmpty(neoList) && ListUtil.isNotEmpty(inputLis)){
-            for (NodeNeoDTO neo : neoList) {
-                for (Lis lis : inputLis) {
-                    String val = lis.getUniqueName();
-                    if (StringUtil.isNotBlank(val) && val.equals(neo.getName())) {
-                        Map<String, Object> map = CoreUtil.compareLis(neo, lis);
-                        if ((Boolean) map.get("flag") == true) {
-                            BillMsg commonBillMsg = MsgUtil.getCommonBillMsg(billNeoMaxDTO.getOrderName(),
-                                    billNeoMaxDTO.getOrderStandName(), (String)map.get("msg"), type, billNeoMaxDTO.getType());
-                            billMsgList.add(commonBillMsg);
+    public void otherTransfusion(Lis lisBean, List<RuleBaseDTO> ruleBaseDTOList, String msg, List<BillMsg> otherList, WordCrfDTO wordCrfDTO) {
+        if (ListUtil.isEmpty(ruleBaseDTOList)) {
+            return ;
+        }
+        LisOtherDTO lisOtherDTO = new LisOtherDTO();
+        int i = 0;
+        for (RuleBaseDTO ruleBaseDTO : ruleBaseDTOList) {
+            if (LibTypeEnum.getEnum(ruleBaseDTO.getBaseLibType()) != null) { // 避免空指针
+                Map<String, Object> map = null;
+                switch (LibTypeEnum.getEnum(ruleBaseDTO.getBaseLibType())) {
+                    case lisDetail: // 化验细项
+                        if (ruleBaseDTO.getBaseLibName().equals(lisBean.getUniqueName())) {
+                            map = CoreUtil.compareLis(ruleBaseDTO, lisBean);
+                            if ((Boolean) map.get("flag") == true) {
+                                lisOtherDTO.setName(msg);
+                                i++;
+                            }
+                        }
+                        break;
+                    case disease: // 诊断
+                        map = commonRule.compareItem(wordCrfDTO.getDiag(), ruleBaseDTO);
+                        if (CoreUtil.getMapFlag(map)) {
+                            lisOtherDTO.setDiseaseMsg((List<String>)map.get("msgList"));
+                            i++;
+                        }
+                        break;
+                    case drug:
+                        map = commonRule.compareItem(wordCrfDTO.getDrug(), ruleBaseDTO);
+                        if (CoreUtil.getMapFlag(map)) {
+                            lisOtherDTO.setDrugMsg((List<String>)map.get("msgList"));
+                            i++;
+                        }
+                    case operation:
+                        map = commonRule.compareItem(wordCrfDTO.getOperation(), ruleBaseDTO);
+                        if (CoreUtil.getMapFlag(map)) {
+                            lisOtherDTO.setOperationMsg((List<String>)map.get("msgList"));
+                            i++;
                         }
+                        break;
+                    default:
+                        break;
+                }
+            }
+        }
+        // 条件全部符合
+        if (i == ruleBaseDTOList.size()) {
+            if (StringUtil.isNotBlank(lisOtherDTO.getName())) {
+                if (ListUtil.isNotEmpty(lisOtherDTO.getDiseaseMsg())) {
+                    for (String str : lisOtherDTO.getDiseaseMsg()) {
+                        BillMsg billMsg = MsgUtil.getCommonOtherTipLisMsg(lisOtherDTO.getName(), str, TypeEnum.disease.getName());
+                        otherList.add(billMsg);
+                    }
+                }
+                if (ListUtil.isNotEmpty(lisOtherDTO.getDrugMsg())) {
+                    for (String str : lisOtherDTO.getDrugMsg()) {
+                        BillMsg billMsg = MsgUtil.getCommonOtherTipLisMsg(lisOtherDTO.getName(), str, TypeEnum.drug.getName());
+                        otherList.add(billMsg);
                     }
                 }
             }
@@ -51,22 +223,43 @@ public class LisRule {
     }
 
     /**
-     * 比较化验——危急值
+     * 比较化验——危急值(多个条件)
      *
      * @param wordCrfDTO
-     * @param critical
+     * @param ruleBaseDTOList
+     * @param criticalList
      */
-    public void critical(WordCrfDTO wordCrfDTO, CriticalNeoDTO critical, List<BillMsg> criticalList) {
-        List<Lis> lisList = wordCrfDTO.getLis();
-        NodeNeoDTO nodeNeoDTO = critical.getCritical();
-        for (Lis bean : lisList) {
-            if (critical.getStandname().equals(bean.getUniqueName())) {
-                Map<String, Object> map = CoreUtil.compareLis(nodeNeoDTO, bean);
-                if ((Boolean) map.get("flag") == true) {
-                    BillMsg criticalMsg = MsgUtil.getCommonCriticalMsg((String) map.get("msg"), TypeEnum.lis.getName());
-                    criticalList.add(criticalMsg);
+    public void critical(Lis lisBean, List<RuleBaseDTO> ruleBaseDTOList, List<BillMsg> criticalList, WordCrfDTO wordCrfDTO) {
+        if (ListUtil.isEmpty(ruleBaseDTOList)) {
+            return ;
+        }
+        String msg = "";
+        int i = 0;
+        for (RuleBaseDTO ruleBaseDTO : ruleBaseDTOList) {
+            if (LibTypeEnum.getEnum(ruleBaseDTO.getBaseLibType()) != null) { // 避免空指针
+                switch (LibTypeEnum.getEnum(ruleBaseDTO.getBaseLibType())) {
+                    case lisDetail: // 化验细项
+                        if (ruleBaseDTO.getBaseLibName().equals(lisBean.getUniqueName())) {
+                            Map<String, Object> map = CoreUtil.compareLis(ruleBaseDTO, lisBean);
+                            if ((Boolean) map.get("flag") == true) {
+                                i++;
+                                msg = (String) map.get("msg");
+                            }
+                        }
+                        break;
+                    case group: // 人群
+                        Map map = groupRule.rule(wordCrfDTO, ruleBaseDTO);
+                        if (CoreUtil.getMapFlag(map)) {
+                            i++;
+                        }
+                        break;
+                    default: break;
                 }
             }
         }
+        if (i == ruleBaseDTOList.size()) {
+            BillMsg criticalMsg = MsgUtil.getCommonCriticalMsg(msg, TypeEnum.lis.getName());
+            criticalList.add(criticalMsg);
+        }
     }
 }

+ 16 - 20
src/main/java/com/diagbot/rule/MedEquRule.java

@@ -1,10 +1,9 @@
 package com.diagbot.rule;
 
 import com.diagbot.dto.BillMsg;
-import com.diagbot.dto.BillNeoMaxDTO;
-import com.diagbot.dto.NodeNeoDTO;
+import com.diagbot.dto.RuleBaseDTO;
+import com.diagbot.dto.RuleSimpleDTO;
 import com.diagbot.dto.WordCrfDTO;
-import com.diagbot.util.ListUtil;
 import com.diagbot.util.MsgUtil;
 import org.springframework.stereotype.Component;
 
@@ -22,28 +21,25 @@ public class MedEquRule {
      * 比较文本内容是否存在
      *
      * @param wordCrfDTO
-     * @param billNeoMaxDTO
+     * @param ruleBaseDTO
      * @param billMsgList
-     * @param type
+     * @param conType
+     * @param ruleSimpleDTO
      */
-    public void bill(WordCrfDTO wordCrfDTO, BillNeoMaxDTO billNeoMaxDTO, List<BillMsg> billMsgList, String type) {
+    public void bill(WordCrfDTO wordCrfDTO, RuleBaseDTO ruleBaseDTO, List<BillMsg> billMsgList, String conType,
+                     RuleSimpleDTO ruleSimpleDTO) {
         String chief = wordCrfDTO.getChief();
         String symptom = wordCrfDTO.getSymptom();
         String pasts = wordCrfDTO.getPasts();
-
-        List<NodeNeoDTO> medEquList = billNeoMaxDTO.getMeddevice();
-        if (ListUtil.isNotEmpty(medEquList)) {
-            for (NodeNeoDTO node : medEquList) {
-                boolean flag = false;
-                if (chief.contains(node.getName()) || symptom.contains(node.getName()) || pasts.contains(node.getName())) {
-                    flag = true;
-                }
-                if (flag) {
-                    BillMsg billMsg = MsgUtil.getBillMedEquMsg(billNeoMaxDTO.getOrderName(), billNeoMaxDTO.getOrderStandName(),
-                            node.getName(), type, billNeoMaxDTO.getType());
-                    billMsgList.add(billMsg);
-                }
-            }
+        boolean flag = false;
+        if (chief.contains(ruleBaseDTO.getBaseLibName()) || symptom.contains(ruleBaseDTO.getBaseLibName())
+                || pasts.contains(ruleBaseDTO.getBaseLibName())) {
+            flag = true;
+        }
+        if (flag) {
+            BillMsg billMsg = MsgUtil.getBillMedEquMsg(ruleSimpleDTO.getInputName(), ruleSimpleDTO.getLibName(),
+                    ruleBaseDTO.getBaseLibName(), conType, ruleSimpleDTO.getLibTypeName());
+            billMsgList.add(billMsg);
         }
     }
 }

+ 88 - 27
src/main/java/com/diagbot/rule/PacsRule.java

@@ -1,66 +1,127 @@
 package com.diagbot.rule;
 
 import com.diagbot.dto.BillMsg;
-import com.diagbot.dto.BillNeoMaxDTO;
-import com.diagbot.dto.CriticalNeoDTO;
-import com.diagbot.dto.NodeNeoDTO;
+import com.diagbot.dto.RuleBaseDTO;
+import com.diagbot.dto.RuleSimpleDTO;
+import com.diagbot.dto.WordCrfDTO;
+import com.diagbot.enums.LibTypeEnum;
 import com.diagbot.enums.TypeEnum;
 import com.diagbot.util.CoreUtil;
 import com.diagbot.util.ListUtil;
 import com.diagbot.util.MsgUtil;
 import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.stream.Collectors;
 
 /**
- * @description: 疾病规则
+ * @description: 辅检规则
  * @author: kwz
  * @time: 2020/8/3 14:47
  */
 @Component
 public class PacsRule {
 
+    @Autowired
+    AgeRule ageRule;
+    @Autowired
+    SexRule sexRule;
+    @Autowired
+    GroupRule groupRule;
+    @Autowired
+    CommonRule commonRule;
+
     /**
-     * 比较辅检——开单合理性
+     * 比较辅检名称——开单合理性
      *
-     * @param nodeList
      * @param inputList
-     * @return
+     * @param ruleBaseDTO
+     * @param billMsgList
+     * @param conType
+     * @param ruleSimpleDTO
+     * @param <T>
      */
-    public <T> void bill(List<NodeNeoDTO> nodeList, List<T> inputList, BillNeoMaxDTO billNeoMaxDTO, List<BillMsg> billMsgList, String type) {
-        Map<String, String> old_stand = new HashMap<>();
-        if (ListUtil.isNotEmpty(nodeList) && ListUtil.isNotEmpty(inputList)) {
-            List<String> dl = nodeList.stream().map(x -> x.getName()).collect(Collectors.toList());
+    public <T> void bill(List<T> inputList, RuleBaseDTO ruleBaseDTO, List<BillMsg> billMsgList, String conType,
+                         RuleSimpleDTO ruleSimpleDTO) {
+        if (ListUtil.isNotEmpty(inputList)) {
             for (T lis : inputList) {
                 String val = (String) CoreUtil.getFieldValue(lis, "uniqueName");
                 String val_name = (String) CoreUtil.getFieldValue(lis, "name");
-                if (StringUtils.isNotBlank(val) && dl.contains(val)) {
-                    old_stand.put(val_name, val);
+                if (StringUtils.isNotBlank(val) && CoreUtil.compareName(ruleBaseDTO, val)) {
+                    BillMsg commonBillMsg = MsgUtil.getCommonBillMsg(
+                            ruleSimpleDTO.getInputName(), ruleSimpleDTO.getLibName(),
+                            "已开" + val_name, conType, ruleSimpleDTO.getLibTypeName());
+                    billMsgList.add(commonBillMsg);
                 }
             }
         }
-        if (old_stand.size() > 0) {
-            for (Map.Entry<String, String> d : old_stand.entrySet()) {
-                BillMsg commonBillMsg = MsgUtil.getCommonBillMsg(
-                        billNeoMaxDTO.getOrderName(), billNeoMaxDTO.getOrderStandName(),
-                        "已开" + d.getKey(), type, billNeoMaxDTO.getType());
-                billMsgList.add(commonBillMsg);
-            }
-        }
     }
 
     /**
      * 比较辅检——危急值
      *
-     * @param critical
+     * @param contentList
      * @param criticalList
      */
-    public void critical(CriticalNeoDTO critical, List<BillMsg> criticalList) {
-        BillMsg commonBillMsg = MsgUtil.getCommonCriticalMsg(critical.getName(), TypeEnum.pacs.getName());
-        criticalList.add(commonBillMsg);
+    public void critical(List<String> contentList, List<BillMsg> criticalList) {
+        for (String s : contentList) {
+            BillMsg commonBillMsg = MsgUtil.getCommonCriticalMsg(s, TypeEnum.pacs.getName());
+            criticalList.add(commonBillMsg);
+        }
+    }
+
+    /**
+     * 比较辅检结果——其他提醒
+     *
+     * @param ruleBaseDTOList
+     * @param msg
+     * @param otherList
+     * @param wordCrfDTO
+     */
+    public void otherPacs(List<RuleBaseDTO> ruleBaseDTOList, String msg, List<BillMsg> otherList, WordCrfDTO wordCrfDTO) {
+        if (ListUtil.isEmpty(ruleBaseDTOList)) {
+            return ;
+        }
+        int i = 0;
+        for (RuleBaseDTO ruleBaseDTO : ruleBaseDTOList) {
+            if (LibTypeEnum.getEnum(ruleBaseDTO.getBaseLibType()) != null) { // 避免空指针
+                boolean flag = false;
+                switch (LibTypeEnum.getEnum(ruleBaseDTO.getBaseLibType())) {
+                    case age: // 年龄
+                        flag = ageRule.getFlag(wordCrfDTO, ruleBaseDTO);
+                        if (flag) {
+                            i++;
+                        }
+                        break;
+                    case sex: // 性别
+                        flag = sexRule.getFlag(wordCrfDTO, ruleBaseDTO);
+                        if (flag) {
+                            i++;
+                        }
+                        break;
+                    case group: // 人群
+                        Map map = groupRule.rule(wordCrfDTO, ruleBaseDTO);
+                        if (CoreUtil.getMapFlag(map)) {
+                            i++;
+                        }
+                        break;
+                    case pacsResult: // 辅检结果
+                        map = commonRule.compareItem(wordCrfDTO.getPacsLabel().getRes(), ruleBaseDTO);
+                        if (CoreUtil.getMapFlag(map)) {
+                            i++;
+                        }
+                        break;
+                    default:
+                        break;
+                }
+            }
+        }
+        // 条件全部符合
+        if (i == ruleBaseDTOList.size()) {
+            BillMsg otherMsg = MsgUtil.getCommonOtherTipPacsMsg(msg);
+            otherList.add(otherMsg);
+        }
     }
 }

+ 26 - 16
src/main/java/com/diagbot/rule/SexRule.java

@@ -1,8 +1,8 @@
 package com.diagbot.rule;
 
 import com.diagbot.dto.BillMsg;
-import com.diagbot.dto.BillNeoMaxDTO;
-import com.diagbot.dto.NodeNeoDTO;
+import com.diagbot.dto.RuleBaseDTO;
+import com.diagbot.dto.RuleSimpleDTO;
 import com.diagbot.dto.WordCrfDTO;
 import com.diagbot.util.MsgUtil;
 import com.diagbot.util.StringUtil;
@@ -22,13 +22,30 @@ public class SexRule {
      * 比较性别
      *
      * @param wordCrfDTO
-     * @param billNeoMaxDTO
+     * @param ruleBaseDTO
+     * @param billMsgList
+     * @param conType
+     * @param ruleSimpleDTO
+     */
+    public void bill(WordCrfDTO wordCrfDTO, RuleBaseDTO ruleBaseDTO, List<BillMsg> billMsgList, String conType,
+                     RuleSimpleDTO ruleSimpleDTO) {
+        if (getFlag(wordCrfDTO, ruleBaseDTO)) {
+            BillMsg billMsg = MsgUtil.getCommonBillMsg(ruleSimpleDTO.getInputName(), ruleSimpleDTO.getLibName(),
+                    ruleBaseDTO.getBaseLibName(), conType, ruleSimpleDTO.getLibTypeName());
+            billMsgList.add(billMsg);
+        }
+    }
+
+    /**
+     * 匹配规则——返回状态
+     *
+     * @param wordCrfDTO
+     * @param ruleBaseDTO
      * @return
      */
-    public void bill(WordCrfDTO wordCrfDTO, BillNeoMaxDTO billNeoMaxDTO, List<BillMsg> billMsgList, String type) {
-        NodeNeoDTO nodeNeoDTO = billNeoMaxDTO.getGender();
-        if (nodeNeoDTO != null && StringUtil.isNotBlank(nodeNeoDTO.getName()) && wordCrfDTO.getSex() != null) {
-            String sex = nodeNeoDTO.getName();
+    public boolean getFlag(WordCrfDTO wordCrfDTO, RuleBaseDTO ruleBaseDTO) {
+        String sex = ruleBaseDTO.getBaseLibName();
+        if (StringUtil.isNotBlank(sex) && wordCrfDTO.getSex() != null) {
             String sexStr = "";
             if (1 == wordCrfDTO.getSex()) {
                 sexStr = "男";
@@ -36,16 +53,9 @@ public class SexRule {
                 sexStr = "女";
             }
             if (sex.equals(sexStr)) {
-                if ("男".equals(sexStr)) {
-                    BillMsg billMsg = MsgUtil.getCommonBillMsg(billNeoMaxDTO.getOrderName(), billNeoMaxDTO.getOrderStandName(),
-                            "男", type, billNeoMaxDTO.getType());
-                    billMsgList.add(billMsg);
-                } else if ("女".equals(sexStr)) {
-                    BillMsg billMsg = MsgUtil.getCommonBillMsg(billNeoMaxDTO.getOrderName(), billNeoMaxDTO.getOrderStandName(),
-                            "女", type, billNeoMaxDTO.getType());
-                    billMsgList.add(billMsg);
-                }
+                return true;
             }
         }
+        return false;
     }
 }

+ 29 - 18
src/main/java/com/diagbot/rule/VitalRule.java

@@ -1,11 +1,10 @@
 package com.diagbot.rule;
 
 import com.diagbot.dto.BillMsg;
-import com.diagbot.dto.BillNeoMaxDTO;
-import com.diagbot.dto.NodeNeoDTO;
+import com.diagbot.dto.RuleBaseDTO;
+import com.diagbot.dto.RuleSimpleDTO;
 import com.diagbot.model.label.VitalLabel;
 import com.diagbot.util.CoreUtil;
-import com.diagbot.util.ListUtil;
 import com.diagbot.util.MsgUtil;
 import org.springframework.stereotype.Component;
 
@@ -21,25 +20,37 @@ import java.util.Map;
 public class VitalRule {
 
     /**
-     * 比较体征
+     * 比较体征——开单合理性
      *
      * @param vitalLabel
-     * @param billNeoMaxDTO
+     * @param ruleBaseDTO
      * @param billMsgList
-     * @param type 类型
-     * @return
+     * @param conType
+     * @param ruleSimpleDTO
      */
-    public void bill(VitalLabel vitalLabel, BillNeoMaxDTO billNeoMaxDTO, List<BillMsg> billMsgList, String type) {
-        List<NodeNeoDTO> neoList = billNeoMaxDTO.getVitals();
-        if(ListUtil.isNotEmpty(neoList)){
-            for (NodeNeoDTO neo : neoList) {
-                Map<String, Object> map = CoreUtil.compareVital(neo, vitalLabel);
-                if ((Boolean) map.get("flag") == true) {
-                    BillMsg commonBillMsg = MsgUtil.getCommonBillMsg(billNeoMaxDTO.getOrderName(),
-                            billNeoMaxDTO.getOrderStandName(), (String) map.get("msg"), type, billNeoMaxDTO.getType());
-                    billMsgList.add(commonBillMsg);
-                }
-            }
+    public void bill(VitalLabel vitalLabel, RuleBaseDTO ruleBaseDTO, List<BillMsg> billMsgList, String conType,
+                     RuleSimpleDTO ruleSimpleDTO) {
+        Map<String, Object> map = CoreUtil.compareVital(ruleBaseDTO, vitalLabel);
+        if ((Boolean) map.get("flag") == true) {
+            BillMsg commonBillMsg = MsgUtil.getCommonBillMsg(ruleSimpleDTO.getInputName(),
+                    ruleSimpleDTO.getLibName(), (String) map.get("msg"), conType, ruleSimpleDTO.getLibTypeName());
+            billMsgList.add(commonBillMsg);
+        }
+    }
+
+    /**
+     * 比较体征——高危手术
+     *
+     * @param vitalLabel
+     * @param ruleBaseDTO
+     * @param highRiskList
+     * @param ruleSimpleDTO
+     */
+    public void highOperation(VitalLabel vitalLabel, RuleBaseDTO ruleBaseDTO, List<BillMsg> highRiskList, RuleSimpleDTO ruleSimpleDTO) {
+        Map<String, Object> map = CoreUtil.compareVital(ruleBaseDTO, vitalLabel);
+        if ((Boolean) map.get("flag") == true) {
+            BillMsg billMsg = MsgUtil.getComplexOperationMsg((String) map.get("msg"), ruleSimpleDTO.getInputName(), ruleSimpleDTO.getLibTypeName());
+            highRiskList.add(billMsg);
         }
     }
 }

+ 136 - 69
src/main/java/com/diagbot/util/CoreUtil.java

@@ -3,6 +3,7 @@ package com.diagbot.util;
 import com.diagbot.biz.push.entity.Item;
 import com.diagbot.biz.push.entity.Lis;
 import com.diagbot.dto.NodeNeoDTO;
+import com.diagbot.dto.RuleBaseDTO;
 import com.diagbot.model.entity.BodyPart;
 import com.diagbot.model.entity.Clinical;
 import com.diagbot.model.entity.Negative;
@@ -155,7 +156,6 @@ public class CoreUtil {
      * @return : 父类中的属性值
      */
     public static Object getFieldValue(Object object, String fieldName){
-
         //根据 对象和属性名通过反射 调用上面的方法获取 Field对象
         Field field = getDeclaredField(object, fieldName) ;
 
@@ -169,7 +169,6 @@ public class CoreUtil {
         } catch(Exception e) {
             e.printStackTrace() ;
         }
-
         return null;
     }
 
@@ -181,7 +180,6 @@ public class CoreUtil {
      * @param value : 将要设置的值
      */
     public static void setFieldValue(Object object, String name, String standName, Map<String, String> value){
-
         //根据 对象和属性名通过反射 调用上面的方法获取 Field对象
         Field field = getDeclaredField(object, name) ;
 
@@ -227,7 +225,6 @@ public class CoreUtil {
     }
 
     public static void setFieldValue(Object object, String name, String standName,String unique, Map<String, String> value){
-
         //根据 对象和属性名通过反射 调用上面的方法获取 Field对象
         Field field = getDeclaredField(object, name) ;
         Field field1 = getDeclaredField(object, standName) ;
@@ -294,6 +291,45 @@ public class CoreUtil {
         return map;
     }
 
+    /**
+     * 比较化验是否匹配
+     *
+     * @param ruleBaseDTO
+     * @param lis
+     * @return
+     */
+    public static Map<String, Object> compareLis(RuleBaseDTO ruleBaseDTO, Lis lis) {
+        Map<String, Object> map = new LinkedHashMap<>();
+        boolean flag = false;
+        if (ruleBaseDTO == null || lis == null) {
+            map.put("flag", flag);
+            return map;
+        }
+        if (StringUtil.isNotBlank(lis.getOtherValue())) {
+            if (lis.getOtherValue().equals(ruleBaseDTO.getBaseEqValue())) {
+                // 套餐和明细名称一样,提示语只取其中一个
+                if (StringUtil.isNotBlank(lis.getName()) && lis.getName().equals(lis.getDetailName())) {
+                    map.put("msg", lis.getDetailName() + lis.getOtherValue());
+                } else {
+                    map.put("msg", lis.getName() + lis.getDetailName() + lis.getOtherValue());
+                }
+                flag = true;
+            }
+        } else if (lis.getValue() != null) {
+            double value = lis.getValue();
+            flag = compareNum(ruleBaseDTO, value);
+            if (flag) {
+                if (StringUtil.isNotBlank(lis.getName()) && lis.getName().equals(lis.getDetailName())) {
+                    map.put("msg", lis.getDetailName() + subZeroAndDot(String.valueOf(lis.getValue())));
+                } else {
+                    map.put("msg", lis.getName() + lis.getDetailName() + subZeroAndDot(String.valueOf(lis.getValue())));
+                }
+            }
+        }
+        map.put("flag", flag);
+        return map;
+    }
+
     /**
      * 比较化验是否匹配
      *
@@ -335,27 +371,26 @@ public class CoreUtil {
         return map;
     }
 
-
     /**
      * 比较查体是否匹配
      *
-     * @param nodeNeoDTO
+     * @param ruleBaseDTO
      * @param vitalLabel
      * @return
      */
-    public static Map<String, Object> compareVital(NodeNeoDTO nodeNeoDTO, VitalLabel vitalLabel) {
+    public static Map<String, Object> compareVital(RuleBaseDTO ruleBaseDTO, VitalLabel vitalLabel) {
         Map<String, Object> map = new LinkedHashMap<>();
         List<Vital> vitalList = vitalLabel.getVitals(); // 体征数据
         List<Clinical> clinicals = vitalLabel.getClinicals(); // 体征临床表现
         boolean flag = false;
-        if (nodeNeoDTO == null) {
+        if (ruleBaseDTO == null) {
             map.put("flag", flag);
             return map;
         }
-        if (nodeNeoDTO.getMax() == null && nodeNeoDTO.getMin() == null) {
+        if (StringUtil.isBlank(ruleBaseDTO.getBaseMaxValue()) && StringUtil.isBlank(ruleBaseDTO.getBaseMinValue())) {
             // 体征名称比较(例如:喉头水肿)
             for (Clinical clinical : clinicals) {
-                if (nodeNeoDTO.getName().contains(clinical.getStandName())) {
+                if (ruleBaseDTO.getBaseLibName().equals(clinical.getStandName())) {
                     map.put("msg", clinical.getName());
                     flag = true;
                     break;
@@ -365,17 +400,17 @@ public class CoreUtil {
             // 体征数值比较(例如:体温,血压)
             for (Vital vital : vitalList) {
                 List<Usual> usualList = vital.getUsualList();
-                if (nodeNeoDTO.getName().equals(vital.getStandName()) && vital.getPd() != null
+                if (ruleBaseDTO.getBaseLibName().equals(vital.getStandName()) && vital.getPd() != null
                         && StringUtil.isNotBlank(vital.getPd().getValue())) {
-                    flag = compareNum(nodeNeoDTO, Double.parseDouble(vital.getPd().getValue()));
+                    flag = compareNum(ruleBaseDTO, Double.parseDouble(vital.getPd().getValue()));
                     if (flag) {
                         map.put("msg", vital.getName() + subZeroAndDot(String.valueOf(vital.getPd().getValue())));
                         break;
                     }
-                } else if (ListUtil.isNotEmpty(usualList)) {
+                } else if (ListUtil.isNotEmpty(usualList)) { // 血压比较
                     for (Usual usual : usualList) {
-                        if (nodeNeoDTO.getName().equals(usual.getStandName())) {
-                            flag = compareNum(nodeNeoDTO, Double.parseDouble(usual.getValue()));
+                        if (ruleBaseDTO.getBaseLibName().equals(usual.getStandName())) {
+                            flag = compareNum(ruleBaseDTO, Double.parseDouble(usual.getValue()));
                             if (flag) {
                                 map.put("msg", vital.getName() + subZeroAndDot(String.valueOf(vital.getPd().getValue())));
                                 break;
@@ -391,28 +426,53 @@ public class CoreUtil {
     }
 
     /**
-     * 比较数值是否匹配
+     * 比较查体是否匹配
      *
      * @param nodeNeoDTO
-     * @param name
-     * @param standName
-     * @param value
+     * @param vitalLabel
      * @return
      */
-    public static Map<String, Object> compareNumWtihMap(NodeNeoDTO nodeNeoDTO, String name, String standName, String value) {
+    public static Map<String, Object> compareVital(NodeNeoDTO nodeNeoDTO, VitalLabel vitalLabel) {
         Map<String, Object> map = new LinkedHashMap<>();
+        List<Vital> vitalList = vitalLabel.getVitals(); // 体征数据
+        List<Clinical> clinicals = vitalLabel.getClinicals(); // 体征临床表现
         boolean flag = false;
-        if (nodeNeoDTO == null || StringUtil.isBlank(name) || StringUtil.isBlank(standName) || StringUtil.isBlank(value)) {
+        if (nodeNeoDTO == null) {
             map.put("flag", flag);
             return map;
         }
-        try {
-            flag = compareNum(nodeNeoDTO, Double.parseDouble(value));
-            if (flag) {
-                map.put("msg", name + subZeroAndDot(String.valueOf(value)));
+        if (nodeNeoDTO.getMax() == null && nodeNeoDTO.getMin() == null) {
+            // 体征名称比较(例如:喉头水肿)
+            for (Clinical clinical : clinicals) {
+                if (nodeNeoDTO.getName().contains(clinical.getStandName())) {
+                    map.put("msg", clinical.getName());
+                    flag = true;
+                    break;
+                }
+            }
+        } else {
+            // 体征数值比较(例如:体温,血压)
+            for (Vital vital : vitalList) {
+                List<Usual> usualList = vital.getUsualList();
+                if (nodeNeoDTO.getName().equals(vital.getStandName()) && vital.getPd() != null
+                        && StringUtil.isNotBlank(vital.getPd().getValue())) {
+                    flag = compareNum(nodeNeoDTO, Double.parseDouble(vital.getPd().getValue()));
+                    if (flag) {
+                        map.put("msg", vital.getName() + subZeroAndDot(String.valueOf(vital.getPd().getValue())));
+                        break;
+                    }
+                } else if (ListUtil.isNotEmpty(usualList)) {
+                    for (Usual usual : usualList) {
+                        if (nodeNeoDTO.getName().equals(usual.getStandName())) {
+                            flag = compareNum(nodeNeoDTO, Double.parseDouble(usual.getValue()));
+                            if (flag) {
+                                map.put("msg", vital.getName() + subZeroAndDot(String.valueOf(vital.getPd().getValue())));
+                                break;
+                            }
+                        }
+                    }
+                }
             }
-        } catch (Exception e) {
-            e.printStackTrace();
         }
 
         map.put("flag", flag);
@@ -420,51 +480,64 @@ public class CoreUtil {
     }
 
     /**
-     * 比较数值大小(int
+     * 比较数值大小(double
      *
-     * @param nodeNeoDTO
+     * @param ruleBaseDTO
      * @param value
      * @return
      */
-    public static boolean compareNum(NodeNeoDTO nodeNeoDTO, int value) {
+    public static boolean compareNum(RuleBaseDTO ruleBaseDTO, double value) {
         boolean flag = false;
-        BigDecimal min = nodeNeoDTO.getMin();
-        BigDecimal max = nodeNeoDTO.getMax();
+        Double min = null;
+        Double max = null;
+        boolean minFlag = false, maxFlag = false;
+        if (StringUtil.isNotBlank(ruleBaseDTO.getBaseMinValue())) {
+            min = Double.parseDouble(ruleBaseDTO.getBaseMinValue());
+        }
+        if (StringUtil.isNotBlank(ruleBaseDTO.getBaseMaxValue())) {
+            max = Double.parseDouble(ruleBaseDTO.getBaseMaxValue());
+        }
 
-        // 取区间
-        if (nodeNeoDTO.getValType() == 0) {
-            if (min != null && max != null) {
-                int minNeo = min.intValue();
-                int maxNeo = max.intValue();
-                if (minNeo <= value && value <= maxNeo) {
-                    flag = true;
+        if (max != null) {
+            if ("<".equals(ruleBaseDTO.getBaseMaxOperator())) {
+                if (value < max) {
+                    maxFlag = true;
                 }
-            } else if (min != null && max == null) {
-                int minNeo = min.intValue();
-                if (minNeo <= value) {
-                    flag = true;
+            } else if ("<=".equals(ruleBaseDTO.getBaseMaxOperator())){
+                if (value <= max) {
+                    maxFlag = true;
                 }
-            } else if (min == null && max != null) {
-                int maxNeo = max.intValue();
-                if (value <= maxNeo) {
-                    flag = true;
+            }
+        }
+        if (min != null) {
+            if (">".equals(ruleBaseDTO.getBaseMinOperator())) {
+                if (value > min) {
+                    minFlag = true;
+                }
+            } else if (">=".equals(ruleBaseDTO.getBaseMinOperator())){
+                if (value >= min) {
+                    minFlag = true;
                 }
             }
-        } else {
-            // 取两头
-            if (min != null) {
-                int minNeo = min.intValue();
-                if (value <= minNeo) {
+        }
+        if (min != null && max != null) {
+            if (min > max) { // 取两头数据
+                if (minFlag || maxFlag) {
                     flag = true;
                 }
-            }
-            // 取两头
-            if (max != null) {
-                int maxNeo = max.intValue();
-                if (value >= maxNeo) {
+            } else { // 取范围数据
+                if (minFlag && maxFlag) {
                     flag = true;
                 }
             }
+        } else if (min != null && max == null) {
+            if (minFlag) {
+                flag = true;
+            }
+        } else if (min == null && max != null) {
+            if (maxFlag) {
+                flag = true;
+            }
         }
         return flag;
     }
@@ -784,24 +857,18 @@ public class CoreUtil {
     }
 
     /**
-     * 比较node名称是否匹配
+     * 比较名称是否匹配
      *
-     * @param nodeNeoDTO
+     * @param ruleBaseDTO
      * @param input
      * @return
      */
-    public static Boolean compareNodeName(NodeNeoDTO nodeNeoDTO, String input) {
-        if (StringUtil.isBlank(input) || nodeNeoDTO == null || StringUtil.isBlank(nodeNeoDTO.getName())) {
+    public static Boolean compareName(RuleBaseDTO ruleBaseDTO, String input) {
+        if (StringUtil.isBlank(input) || ruleBaseDTO == null || StringUtil.isBlank(ruleBaseDTO.getBaseLibName())) {
             return false;
         }
-        if (nodeNeoDTO.getExactMatch() == 0) { // 精确匹配
-            if (input.equals(nodeNeoDTO.getName())) {
-                return true;
-            }
-        } else { // 模糊匹配
-            if (input.contains(nodeNeoDTO.getName())) {
-                return true;
-            }
+        if (input.equals(ruleBaseDTO.getBaseLibName())) {
+            return true;
         }
         return false;
     }

+ 0 - 20
src/main/java/com/diagbot/util/MsgUtil.java

@@ -48,26 +48,6 @@ public class MsgUtil {
         return billMsg;
     }
 
-    // /**
-    //  * 开单合理性通用提示信息
-    //  *
-    //  * @param orderName 原开单项
-    //  * @param orderStandName 标准开单项
-    //  * @param content 匹配内容
-    //  * @param type 类型
-    //  * @return
-    //  */
-    // public static BillMsg getCommonBillMsg(String orderName, String orderStandName, String content, String type) {
-    //     BillMsg billMsg = new BillMsg();
-    //     String msg = String.format("该患者%s,不宜开%s", content, orderName);
-    //     billMsg.setMsg(msg);
-    //     billMsg.setOrderName(orderName);
-    //     billMsg.setOrderStandName(orderStandName);
-    //     billMsg.setContent(content);
-    //     billMsg.setType(type);
-    //     return billMsg;
-    // }
-
     /**
      * 开单合理性通用提示信息
      *

+ 38 - 47
src/main/java/com/diagbot/util/RedisUtil.java

@@ -10,7 +10,11 @@ import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.data.redis.core.SessionCallback;
 import org.springframework.stereotype.Component;
 
-import java.util.*;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
@@ -26,18 +30,6 @@ public class RedisUtil {
     @Qualifier("redisTemplateForSimilar")
     RedisTemplate redisTemplate;
 
-    /**
-     * 获取指定类型的数据
-     *
-     * @param type
-     * @return
-     */
-    public Map<String, String> getValueByType(String type) {
-        Map<String, String> map = (Map<String, String>)redisTemplate.opsForValue().get(type);
-        return map;
-    }
-
-
     /**
      * 更新指定类型下的数据
      *
@@ -86,56 +78,56 @@ public class RedisUtil {
      *
      * @param key 键
      */
-    public Object get(String key) {
-        return redisTemplate.opsForValue().get(key);
+    public <T> T get(String key) {
+        return (T) redisTemplate.opsForValue().get(key);
     }
 
-    public List<Map<String,String>> get(List<String> keys) {
+    /**
+     * 根据正则key获取value列表
+     *
+     * @param pattern 键
+     */
+    public <T> List<T> getByRegex(String pattern) {
+        Set<String> keys = redisTemplate.keys(pattern);
+        return redisTemplate.opsForValue().multiGet(keys);
+    }
+
+    public List<Map<String, String>> get(List<String> keys) {
         return redisTemplate.executePipelined(new SessionCallback<Object>() {
             @Override
-            public Map<String,String> execute(RedisOperations redisOperations) throws DataAccessException {
-                for (String dis:keys) {
-                    redisOperations.opsForValue().get(RedisEnum.diseaseType.getName()+dis);
+            public Map<String, String> execute(RedisOperations redisOperations) throws DataAccessException {
+                for (String dis : keys) {
+                    redisOperations.opsForValue().get(RedisEnum.diseaseType.getName() + dis);
                 }
                 return null;
             }
         });
     }
 
-    public List<Map<String,String>> geth(List<String> keys) {
-        keys = keys.stream().map(x ->RedisEnum.diseaseType.getName()+x).collect(Collectors.toList());
-        List<Map<String,String>> list = redisTemplate.opsForValue().multiGet(keys);
+    public List<Map<String, String>> geth(List<String> keys) {
+        keys = keys.stream().map(x -> RedisEnum.diseaseType.getName() + x).collect(Collectors.toList());
+        List<Map<String, String>> list = redisTemplate.opsForValue().multiGet(keys);
         return list;
     }
 
-    public List<Map<String,String>> getSymptomNumOfDis(List<String> keys) {
-        keys = keys.stream().map(x ->RedisEnum.symptomNumType.getName()+x).collect(Collectors.toList());
-        List<Map<String,String>> list = redisTemplate.opsForValue().multiGet(keys);
+    public List<Map<String, String>> getSymptomNumOfDis(List<String> keys) {
+        keys = keys.stream().map(x -> RedisEnum.symptomNumType.getName() + x).collect(Collectors.toList());
+        List<Map<String, String>> list = redisTemplate.opsForValue().multiGet(keys);
         return list;
     }
 
-    public List<String> getSv(List<String> keys,String type) {
-        keys = keys.stream().map(x ->type+x).collect(Collectors.toList());
+    public List<String> getSv(List<String> keys, String type) {
+        keys = keys.stream().map(x -> type + x).collect(Collectors.toList());
         List<String> list = redisTemplate.opsForValue().multiGet(keys);
         return list;
     }
 
-
-    public List<Map<String,String>> getSf(List<String> keys,String type) {
-        keys = keys.stream().map(x ->type+x).collect(Collectors.toList());
-        List<Map<String,String>> list = redisTemplate.opsForValue().multiGet(keys);
+    public List<Map<String, String>> getSf(List<String> keys, String type) {
+        keys = keys.stream().map(x -> type + x).collect(Collectors.toList());
+        List<Map<String, String>> list = redisTemplate.opsForValue().multiGet(keys);
         return list;
     }
 
-    /**
-     * 根据指定key获取value
-     *
-     * @param key 键
-     */
-    public String getWithString(String key) {
-        return (String)redisTemplate.opsForValue().get(key);
-    }
-
     /**
      * 删除key
      *
@@ -263,6 +255,7 @@ public class RedisUtil {
 
     /**
      * 设置指定 key 的值
+     *
      * @param key
      * @param value
      */
@@ -276,7 +269,7 @@ public class RedisUtil {
      * @param keys
      * @return
      */
-    public List<String> multiGet(Collection<String> keys) {
+    public <T> List<T> multiGet(Collection<String> keys) {
         return redisTemplate.opsForValue().multiGet(keys);
     }
 
@@ -285,11 +278,9 @@ public class RedisUtil {
      *
      * @param key
      * @param value
-     * @param timeout
-     *            过期时间
-     * @param unit
-     *            时间单位, 天:TimeUnit.DAYS 小时:TimeUnit.HOURS 分钟:TimeUnit.MINUTES
-     *            秒:TimeUnit.SECONDS 毫秒:TimeUnit.MILLISECONDS
+     * @param timeout 过期时间
+     * @param unit    时间单位, 天:TimeUnit.DAYS 小时:TimeUnit.HOURS 分钟:TimeUnit.MINUTES
+     *                秒:TimeUnit.SECONDS 毫秒:TimeUnit.MILLISECONDS
      */
     public void setEx(String key, String value, long timeout, TimeUnit unit) {
         redisTemplate.opsForValue().set(key, value, timeout, unit);
@@ -300,7 +291,7 @@ public class RedisUtil {
      *
      * @param key
      * @param value
-     * @return 之前已经存在返回false,不存在返回true
+     * @return 之前已经存在返回false, 不存在返回true
      */
     public boolean setIfAbsent(String key, String value) {
         return redisTemplate.opsForValue().setIfAbsent(key, value);

+ 26 - 0
src/main/java/com/diagbot/vo/RuleVO.java

@@ -0,0 +1,26 @@
+package com.diagbot.vo;
+
+import lombok.Data;
+
+/**
+ * @description: 查询规则入参
+ * @author: zhoutg
+ * @time: 2020/7/29 9:57
+ */
+@Data
+public class RuleVO {
+    // 医院名称
+    private String inputName;
+    // 标准词
+    private String libName;
+    // 词性
+    private Integer libType;
+    // 类型名称
+    private String libTypeName;
+    // redis后缀,默认查开单项
+    private String suffix = "1";
+    // 时间
+    private String dateValue;
+    // 剂型
+    private String form;
+}