Browse Source

规则处理

zhoutg 3 years ago
parent
commit
98a4fd6109

+ 1 - 0
src/main/java/com/diagbot/config/RedisConfigurer.java

@@ -114,6 +114,7 @@ public class RedisConfigurer extends CachingConfigurerSupport {
         ObjectMapper om = new ObjectMapper();
         ObjectMapper om = new ObjectMapper();
         om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
         om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
         om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
         om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
+        // om.setSerializationInclusion(JsonInclude.Include.NON_EMPTY); // 空值不会序列化,从而减少序列化空间,提升效率
         jackson2JsonRedisSerializer.setObjectMapper(om);
         jackson2JsonRedisSerializer.setObjectMapper(om);
         return jackson2JsonRedisSerializer;
         return jackson2JsonRedisSerializer;
     }
     }

+ 33 - 0
src/main/java/com/diagbot/dto/BillDTO.java

@@ -0,0 +1,33 @@
+package com.diagbot.dto;
+
+import com.google.common.collect.Lists;
+import lombok.Data;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @Description: 开单提示语
+ * @Author:zhoutg
+ * @time: 2020/8/12 15:53
+ */
+@Data
+public class BillDTO {
+    // 通用匹配内容
+    private String content;
+    // 禁忌类型
+    private String conType = "";
+    // 匹配条数
+    private int matchNum = 0;
+    // 性别拼接提示语
+    private String sexMsg = "";
+    // 年龄拼接提示语
+    private String ageMsg = "";
+    // 诊断拼接提示语
+    private List<String> diseaseMsg = Lists.newArrayList();
+    // 人群拼接提示语
+    private String groupMsg = "";
+
+
+    private List<String> lisMsg = new ArrayList<>(); // 化验拼接提示语——暂无数据
+}

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

@@ -19,4 +19,8 @@ public class RuleExtDTO extends RuleDTO{
     private String libTypeName;
     private String libTypeName;
     // // 剂型
     // // 剂型
     private String form;
     private String form;
+    // 给药途径医院名称
+    private String routeName;
+    // 给药途径标准名称
+    private String routeUniqueName;
 }
 }

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

@@ -1,7 +1,10 @@
 package com.diagbot.dto;
 package com.diagbot.dto;
 
 
+import com.google.common.collect.Lists;
 import lombok.Data;
 import lombok.Data;
 
 
+import java.util.List;
+
 /**
 /**
  * @Description: 规则扩展类
  * @Description: 规则扩展类
  * @author: zhoutg
  * @author: zhoutg
@@ -19,6 +22,10 @@ public class RuleSimpleDTO {
     private String libTypeName;
     private String libTypeName;
     // 剂型
     // 剂型
     private String form;
     private String form;
+    // 给药途径医院名称
+    private String routeName;
+    // 给药途径标准名称
+    private String routeUniqueName;
     // 提示语
     // 提示语
     private String msg;
     private String msg;
     // 界面匹配内容
     // 界面匹配内容
@@ -28,6 +35,13 @@ public class RuleSimpleDTO {
     // 项目名称(目前用于辅检项目名称)
     // 项目名称(目前用于辅检项目名称)
     private String structName = "";
     private String structName = "";
 
 
+    // 匹配条数
+    private int matchNum = 0;
+    // 界面匹配内容列表
+    private List<String> contentList = Lists.newArrayList();
+    // 给药途径是否匹配
+    private boolean routeMatch = false;
+
     public RuleSimpleDTO() {
     public RuleSimpleDTO() {
     }
     }
 
 

+ 3 - 0
src/main/java/com/diagbot/facade/BillFacade.java

@@ -84,6 +84,9 @@ public class BillFacade {
                 ruleVO.setLibType(LexiconEnum.Medicine.getKey());
                 ruleVO.setLibType(LexiconEnum.Medicine.getKey());
                 ruleVO.setLibTypeName(TypeEnum.drug.getName());
                 ruleVO.setLibTypeName(TypeEnum.drug.getName());
                 ruleVO.setDateValue(item.getDateValue());
                 ruleVO.setDateValue(item.getDateValue());
+                ruleVO.setForm(item.getForm());
+                ruleVO.setRouteName(item.getRouteName());
+                ruleVO.setRouteUniqueName(item.getRouteUniqueName());
                 ruleVOList.add(ruleVO);
                 ruleVOList.add(ruleVO);
             }
             }
         }
         }

+ 8 - 93
src/main/java/com/diagbot/process/BillProcess.java

@@ -1,6 +1,5 @@
 package com.diagbot.process;
 package com.diagbot.process;
 
 
-import com.diagbot.biz.push.entity.Item;
 import com.diagbot.dto.BillMsg;
 import com.diagbot.dto.BillMsg;
 import com.diagbot.dto.IndicationDTO;
 import com.diagbot.dto.IndicationDTO;
 import com.diagbot.dto.RuleBaseDTO;
 import com.diagbot.dto.RuleBaseDTO;
@@ -8,15 +7,13 @@ import com.diagbot.dto.RuleConditionDTO;
 import com.diagbot.dto.RuleExtDTO;
 import com.diagbot.dto.RuleExtDTO;
 import com.diagbot.dto.RuleSimpleDTO;
 import com.diagbot.dto.RuleSimpleDTO;
 import com.diagbot.dto.WordCrfDTO;
 import com.diagbot.dto.WordCrfDTO;
-import com.diagbot.enums.BaseTypeEnum;
 import com.diagbot.enums.ConEnum;
 import com.diagbot.enums.ConEnum;
 import com.diagbot.enums.LexiconEnum;
 import com.diagbot.enums.LexiconEnum;
 import com.diagbot.enums.RuleTypeEnum;
 import com.diagbot.enums.RuleTypeEnum;
 import com.diagbot.facade.CommonFacade;
 import com.diagbot.facade.CommonFacade;
 import com.diagbot.facade.NeoFacade;
 import com.diagbot.facade.NeoFacade;
-import com.diagbot.model.entity.Clinical;
-import com.diagbot.model.entity.Operation;
 import com.diagbot.rule.AgeRule;
 import com.diagbot.rule.AgeRule;
+import com.diagbot.rule.BillRule;
 import com.diagbot.rule.CommonRule;
 import com.diagbot.rule.CommonRule;
 import com.diagbot.rule.DrugRule;
 import com.diagbot.rule.DrugRule;
 import com.diagbot.rule.GroupRule;
 import com.diagbot.rule.GroupRule;
@@ -26,6 +23,7 @@ import com.diagbot.rule.PacsRule;
 import com.diagbot.rule.SexRule;
 import com.diagbot.rule.SexRule;
 import com.diagbot.rule.VitalRule;
 import com.diagbot.rule.VitalRule;
 import com.diagbot.util.BeanUtil;
 import com.diagbot.util.BeanUtil;
+import com.diagbot.util.CoreUtil;
 import com.diagbot.vo.RuleVO;
 import com.diagbot.vo.RuleVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Component;
@@ -64,30 +62,13 @@ public class BillProcess {
     MedEquRule medEquRule;
     MedEquRule medEquRule;
     @Autowired
     @Autowired
     CommonFacade commonFacade;
     CommonFacade commonFacade;
+    @Autowired
+    BillRule billRule;
 
 
     // 规则处理
     // 规则处理
     public void processRule(List<RuleVO> ruleVOList, WordCrfDTO wordCrfDTO, IndicationDTO indicationDTO) {
     public void processRule(List<RuleVO> ruleVOList, WordCrfDTO wordCrfDTO, IndicationDTO indicationDTO) {
         List<BillMsg> billMsgList = indicationDTO.getBillMsgList();
         List<BillMsg> billMsgList = indicationDTO.getBillMsgList();
         Set<String> set = new LinkedHashSet<>();    // A与B不宜同时进行, B与A不宜同时进行 只能提示一个
         Set<String> set = new LinkedHashSet<>();    // A与B不宜同时进行, B与A不宜同时进行 只能提示一个
-        /**---------------------------数据统一处理开始--------------------------------- */
-        // 【过敏药品数据来源】
-        List<Item> allergyMedicines = commonFacade.getDrugAllergySource(wordCrfDTO);
-
-        // 【药品数据来源】(主诉、现病史、既往史、结构化药品)
-        List<Item> medicineAll = wordCrfDTO.getDrugSource();
-
-        // 【诊断数据来源】
-        List<Item> diags = wordCrfDTO.getDiagSource();
-
-        // 【辅检结果数据来源】
-        List<Item> pacsDescList = wordCrfDTO.getPacsLabel().getRes();
-
-        // 【手术数据来源】
-        List<Operation> operationsSource = commonFacade.getOperationSource(wordCrfDTO);
-
-        // 【临床表现数据来源】(主诉、现病史)
-        List<Clinical> clinicals = commonFacade.getClinicalSource(wordCrfDTO);
-        /**---------------------------数据统一处理结束--------------------------------- */
         for (RuleVO ruleVO : ruleVOList) {
         for (RuleVO ruleVO : ruleVOList) {
             /** 1、获取开单项相关数据 */
             /** 1、获取开单项相关数据 */
             RuleExtDTO ruleExtDTO = commonFacade.getRuleData(ruleVO);
             RuleExtDTO ruleExtDTO = commonFacade.getRuleData(ruleVO);
@@ -100,81 +81,15 @@ public class BillProcess {
             BeanUtil.copyProperties(ruleExtDTO, ruleSimpleDTO);
             BeanUtil.copyProperties(ruleExtDTO, ruleSimpleDTO);
 
 
             /** 3、规则处理 */
             /** 3、规则处理 */
+            RuleTypeEnum ruleTypeEnum = RuleTypeEnum.getEnum(ruleExtDTO.getRuleType());
             List<RuleConditionDTO> ruleConditionDTOList = ruleExtDTO.getRuleConditionDTOList();
             List<RuleConditionDTO> ruleConditionDTOList = ruleExtDTO.getRuleConditionDTOList();
             for (RuleConditionDTO ruleConditionDTO : ruleConditionDTOList) {
             for (RuleConditionDTO ruleConditionDTO : ruleConditionDTOList) {
+                CoreUtil.resetRuleSimple(ruleSimpleDTO); // 重置
                 ruleSimpleDTO.setMsg(ruleConditionDTO.getMsg());
                 ruleSimpleDTO.setMsg(ruleConditionDTO.getMsg());
                 List<RuleBaseDTO> ruleBaseDTOList = ruleConditionDTO.getRuleBaseDTOList();
                 List<RuleBaseDTO> ruleBaseDTOList = ruleConditionDTO.getRuleBaseDTOList();
-                switch (RuleTypeEnum.getEnum(ruleExtDTO.getRuleType())) {
+                switch (ruleTypeEnum) {
                     case bill: // redis 数据以 _1结尾
                     case bill: // redis 数据以 _1结尾
-                        for (RuleBaseDTO ruleBaseDTO : ruleBaseDTOList) {
-                            if (LexiconEnum.getEnum(ruleBaseDTO.getBaseLibType()) != null) { // 避免空指针
-                                switch (LexiconEnum.getEnum(ruleBaseDTO.getBaseLibType())) {
-                                    case Gender: // 性别
-                                        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 LisName: // 化验开单互斥
-                                        commonRule.exclusionBillOrder(wordCrfDTO.getLisOrder(), ruleBaseDTO, billMsgList, ConEnum.exclusion.getName(), ruleSimpleDTO, set);
-                                        commonRule.exclusionBillStruct(wordCrfDTO.getLis(), ruleBaseDTO, billMsgList, ConEnum.exclusion.getName(), ruleSimpleDTO, set);
-                                        break;
-                                    case LisSubName: // 化验结果
-                                        lisRule.bill(wordCrfDTO.getLis(), ruleBaseDTO, billMsgList, ConEnum.lis.getName(), ruleSimpleDTO);
-                                        break;
-                                    case VitalResult: //体格检查结果
-                                    case Vital: // 体格检查项目
-                                        vitalRule.bill(wordCrfDTO.getVitalLabel(), ruleBaseDTO, billMsgList, ConEnum.vitals.getName(), ruleSimpleDTO);
-                                        break;
-                                    case PacsName: // 辅助检查项目
-                                    case PacsSubName: // 辅助检查子项目
-                                        if (ruleBaseDTO.getBaseType() != null && ruleBaseDTO.getBaseType().equals(BaseTypeEnum.B5.getKey())) {
-                                            // 开单项互斥
-                                            commonRule.exclusionBillOrder(wordCrfDTO.getPacsOrder(), ruleBaseDTO, billMsgList, ConEnum.exclusion.getName(), ruleSimpleDTO, set);
-                                            commonRule.exclusionBillStruct(wordCrfDTO.getPacs(), ruleBaseDTO, billMsgList, ConEnum.exclusion.getName(), ruleSimpleDTO, set);
-                                        } else {
-                                            // 辅检项目,暂无数据
-                                            pacsRule.bill(wordCrfDTO.getPacs(), ruleBaseDTO, billMsgList, ConEnum.pacs.getName(), ruleSimpleDTO);
-                                        }
-                                        break;
-                                    case Symptom: // 临床表现
-                                        commonRule.compareNameWithBill(clinicals, ruleBaseDTO, billMsgList, ConEnum.clinicfindings.getName(), ruleSimpleDTO);
-                                        break;
-                                    case Operation: // 手术(既往史、现病史、医嘱手术)
-                                        commonRule.compareNameWithBill(operationsSource, ruleBaseDTO, billMsgList, ConEnum.operations.getName(), ruleSimpleDTO);
-                                        break;
-                                    case Medicine:
-                                    case MedChemClass:
-                                    case MedZhiLiaoClass:
-                                    case MedYaoLiClass:
-                                    case MedJiePouClass:
-                                        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 Allergen: // 其他过敏原
-                                        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 Device: // 禁忌医疗器械及物品
-                                        medEquRule.bill(wordCrfDTO, ruleBaseDTO, billMsgList, ConEnum.medEqu.getName(), ruleSimpleDTO);
-                                        break;
-                                    default:
-                                        break;
-                                }
-                            }
-                        }
+                        billRule.bill(wordCrfDTO, ruleBaseDTOList, billMsgList, ruleSimpleDTO, set);
                         break;
                         break;
                     case repeat:  // redis 数据以 _6结尾
                     case repeat:  // redis 数据以 _6结尾
                         for (RuleBaseDTO ruleBaseDTO : ruleBaseDTOList) {
                         for (RuleBaseDTO ruleBaseDTO : ruleBaseDTOList) {

+ 9 - 12
src/main/java/com/diagbot/rule/AgeRule.java

@@ -4,10 +4,10 @@ import com.diagbot.dto.BillMsg;
 import com.diagbot.dto.RuleBaseDTO;
 import com.diagbot.dto.RuleBaseDTO;
 import com.diagbot.dto.RuleSimpleDTO;
 import com.diagbot.dto.RuleSimpleDTO;
 import com.diagbot.dto.WordCrfDTO;
 import com.diagbot.dto.WordCrfDTO;
+import com.diagbot.enums.ConEnum;
 import com.diagbot.util.CoreUtil;
 import com.diagbot.util.CoreUtil;
-import com.diagbot.util.MsgNewUtil;
 import com.diagbot.util.MsgUtil;
 import com.diagbot.util.MsgUtil;
-import org.springframework.beans.factory.annotation.Autowired;
+import com.google.common.collect.Lists;
 import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Component;
 
 
 import java.util.List;
 import java.util.List;
@@ -20,26 +20,23 @@ import java.util.List;
 @Component
 @Component
 public class AgeRule {
 public class AgeRule {
 
 
-    @Autowired
-    MsgNewUtil msgNewUtil;
-
     /**
     /**
      * 比较年龄——开单项
      * 比较年龄——开单项
      *
      *
      * @param wordCrfDTO
      * @param wordCrfDTO
      * @param ruleBaseDTO
      * @param ruleBaseDTO
-     * @param billMsgList
-     * @param conType
      * @param ruleSimpleDTO
      * @param ruleSimpleDTO
      */
      */
-    public void bill(WordCrfDTO wordCrfDTO, RuleBaseDTO ruleBaseDTO, List<BillMsg> billMsgList, String conType, RuleSimpleDTO ruleSimpleDTO) {
+    public Boolean bill(WordCrfDTO wordCrfDTO, RuleBaseDTO ruleBaseDTO, RuleSimpleDTO ruleSimpleDTO) {
         Boolean flag = getFlag(wordCrfDTO, ruleBaseDTO);
         Boolean flag = getFlag(wordCrfDTO, ruleBaseDTO);
         if (flag) {
         if (flag) {
-            ruleSimpleDTO.setContent(wordCrfDTO.getAge());
-            ruleSimpleDTO.setConType(conType);
-            BillMsg billMsg = msgNewUtil.getCommonBillMsg(ruleSimpleDTO);
-            CoreUtil.addBeanToList(billMsgList, billMsg);
+            List<String> contentList = Lists.newArrayList();
+            if (!contentList.contains(wordCrfDTO.getAge())) {
+                contentList.add(wordCrfDTO.getAge());
+            }
+            CoreUtil.setListAndType(ruleSimpleDTO, contentList, ConEnum.age.getName());
         }
         }
+        return flag;
     }
     }
 
 
     /**
     /**

+ 180 - 0
src/main/java/com/diagbot/rule/BillRule.java

@@ -0,0 +1,180 @@
+package com.diagbot.rule;
+
+import com.diagbot.biz.push.entity.Item;
+import com.diagbot.dto.BillMsg;
+import com.diagbot.dto.RuleBaseDTO;
+import com.diagbot.dto.RuleSimpleDTO;
+import com.diagbot.dto.WordCrfDTO;
+import com.diagbot.enums.BaseTypeEnum;
+import com.diagbot.enums.ConEnum;
+import com.diagbot.enums.LexiconEnum;
+import com.diagbot.facade.CommonFacade;
+import com.diagbot.model.entity.Clinical;
+import com.diagbot.model.entity.Operation;
+import com.diagbot.util.ListUtil;
+import com.diagbot.util.MsgNewUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+import java.util.Set;
+
+/**
+ * @description: 开单规则
+ * @author: zhoutg
+ * @time: 2020/8/3 14:47
+ */
+@Component
+public class BillRule {
+
+    @Autowired
+    SexRule sexRule;
+    @Autowired
+    AgeRule ageRule;
+    @Autowired
+    MsgNewUtil msgNewUtil;
+    @Autowired
+    CommonRule commonRule;
+    @Autowired
+    LisRule lisRule;
+    @Autowired
+    PacsRule pacsRule;
+    @Autowired
+    VitalRule vitalRule;
+    @Autowired
+    GroupRule groupRule;
+    @Autowired
+    MedEquRule medEquRule;
+    @Autowired
+    CommonFacade commonFacade;
+    @Autowired
+    DrugRule drugRule;
+    @Autowired
+    RouteRule routeRule;
+    @Autowired
+    FormRule formRule;
+
+    /**
+     * 开单规则总入口
+     *
+     * @param wordCrfDTO
+     * @param ruleBaseDTOList
+     * @param billMsgList
+     * @param ruleSimpleDTO
+     */
+    public void bill(WordCrfDTO wordCrfDTO, List<RuleBaseDTO> ruleBaseDTOList, List<BillMsg> billMsgList, RuleSimpleDTO ruleSimpleDTO, Set<String> set) {
+        if (ListUtil.isEmpty(ruleBaseDTOList)) {
+            return;
+        }
+        /**---------------------------数据统一处理开始--------------------------------- */
+        // 【过敏药品数据来源】
+        List<Item> allergyMedicines = commonFacade.getDrugAllergySource(wordCrfDTO);
+        // 【药品数据来源】(主诉、现病史、既往史、结构化药品)
+        List<Item> medicineAll = wordCrfDTO.getDrugSource();
+        // 【诊断数据来源】
+        List<Item> diags = wordCrfDTO.getDiagSource();
+        // 【辅检结果数据来源】
+        List<Item> pacsDescList = wordCrfDTO.getPacsLabel().getRes();
+        // 【手术数据来源】
+        List<Operation> operationsSource = commonFacade.getOperationSource(wordCrfDTO);
+        // 【临床表现数据来源】(主诉、现病史)
+        List<Clinical> clinicals = commonFacade.getClinicalSource(wordCrfDTO);
+        /**---------------------------数据统一处理结束--------------------------------- */
+
+        for (RuleBaseDTO ruleBaseDTO : ruleBaseDTOList) {
+            boolean flag = false;
+            boolean flag1 = false, flag2 = false; // 定义多个变量
+            if (LexiconEnum.getEnum(ruleBaseDTO.getBaseLibType()) != null) { // 避免空指针
+                switch (LexiconEnum.getEnum(ruleBaseDTO.getBaseLibType())) {
+                    case Gender: // 性别
+                        flag = sexRule.bill(wordCrfDTO, ruleBaseDTO, ruleSimpleDTO);
+                        break;
+                    case Age: // 年龄
+                        flag = ageRule.bill(wordCrfDTO, ruleBaseDTO, ruleSimpleDTO);
+                        break;
+                    case Disease: // 诊断
+                        flag = commonRule.compareItemWithBill(diags, ruleBaseDTO, ruleSimpleDTO, ConEnum.disease.getName());
+                        break;
+                    case LisName: // 化验开单互斥
+                        flag1 = commonRule.exclusionBillOrder(wordCrfDTO.getLisOrder(), ruleBaseDTO, ruleSimpleDTO, ConEnum.exclusion.getName(), set);
+                        flag2 = commonRule.exclusionBillStruct(wordCrfDTO.getLis(), ruleBaseDTO, ruleSimpleDTO, ConEnum.exclusion.getName(), set);
+                        if (flag1 || flag2) {
+                            flag = true;
+                        }
+                        break;
+                    case LisSubName: // 化验结果
+                        flag = lisRule.bill(wordCrfDTO.getLis(), ruleBaseDTO, ruleSimpleDTO);
+                        break;
+                    case VitalResult: //体格检查结果
+                    case Vital: // 体格检查项目
+                        flag = vitalRule.bill(wordCrfDTO.getVitalLabel(), ruleBaseDTO, ruleSimpleDTO);
+                        break;
+                    case PacsName: // 辅助检查项目
+                    case PacsSubName: // 辅助检查子项目
+                        if (ruleBaseDTO.getBaseType() != null && ruleBaseDTO.getBaseType().equals(BaseTypeEnum.B5.getKey())) {
+                            // 开单项互斥
+                            flag1 = commonRule.exclusionBillOrder(wordCrfDTO.getPacsOrder(), ruleBaseDTO, ruleSimpleDTO, ConEnum.exclusion.getName(), set);
+                            flag2 = commonRule.exclusionBillStruct(wordCrfDTO.getPacs(), ruleBaseDTO, ruleSimpleDTO, ConEnum.exclusion.getName(), set);
+                            if (flag1 || flag2) {
+                                flag = true;
+                            }
+                        } else {
+                            // 辅检项目,暂无数据
+                            flag = pacsRule.bill(wordCrfDTO.getPacs(), ruleBaseDTO, ruleSimpleDTO, ConEnum.pacs.getName());
+                        }
+                        break;
+                    case Symptom: // 临床表现
+                        flag = commonRule.compareNameWithBill(clinicals, ruleBaseDTO, ruleSimpleDTO, ConEnum.clinicfindings.getName());
+                        break;
+                    case Operation: // 手术(既往史、现病史、医嘱手术)
+                        flag = commonRule.compareNameWithBill(operationsSource, ruleBaseDTO, ruleSimpleDTO, ConEnum.operations.getName());
+                        break;
+                    case Medicine: // 药品通用名
+                    case MedChemClass: // 药品化学物质类别
+                    case MedZhiLiaoClass: // 药品治疗学类别
+                    case MedYaoLiClass: // 药品药理学类别
+                    case MedJiePouClass: // 药品解剖学类别
+                        if (ruleBaseDTO.getBaseType().equals(4)) {
+                            // 禁忌过敏药品(既往史)
+                            flag = drugRule.bill(allergyMedicines, ruleBaseDTO, ruleSimpleDTO, ConEnum.allergicmeds.getName());
+                        } else {
+                            // 服用药品(主诉、现病史、既往史、结构化药品)
+                            flag = drugRule.bill(medicineAll, ruleBaseDTO, ruleSimpleDTO, ConEnum.oralmeds.getName());
+                        }
+                        break;
+                    case Allergen: // 其他过敏原
+                        flag = drugRule.bill(allergyMedicines, ruleBaseDTO, ruleSimpleDTO, ConEnum.otherAllergy.getName());
+                        break;
+                    case Group: // 禁忌人群
+                        flag = groupRule.bill(wordCrfDTO, ruleBaseDTO, ruleSimpleDTO);
+                        break;
+                    case PacsResult: // 禁用辅助检查结果
+                        flag = commonRule.compareItemWithBill(pacsDescList, ruleBaseDTO, ruleSimpleDTO, ConEnum.pacsDesc.getName());
+                        break;
+                    case Device: // 禁忌医疗器械及物品
+                        flag = medEquRule.bill(wordCrfDTO, ruleBaseDTO, ruleSimpleDTO);
+                        break;
+                    case AdministrationRoute: // 给药途径
+                        flag = routeRule.bill(ruleBaseDTO, ruleSimpleDTO);
+                        break;
+                    case Form: // 药品剂型
+                        flag = formRule.bill(ruleBaseDTO, ruleSimpleDTO);
+                        break;
+                    default:
+                        break;
+                }
+            }
+            // 有任一条件不满足,直接退出
+            if (!flag) {
+                return;
+            }
+        }
+
+        // 提示语处理
+        for (String content : ruleSimpleDTO.getContentList()) {
+            ruleSimpleDTO.setContent(content);
+            msgNewUtil.getCommonBillMsg(ruleSimpleDTO, billMsgList);
+        }
+    }
+
+}

+ 59 - 40
src/main/java/com/diagbot/rule/CommonRule.java

@@ -73,13 +73,14 @@ public class CommonRule {
      *
      *
      * @param input
      * @param input
      * @param ruleBaseDTO
      * @param ruleBaseDTO
-     * @param billMsgList
-     * @param conType
      * @param ruleSimpleDTO
      * @param ruleSimpleDTO
+     * @param conType
      * @param <T>
      * @param <T>
+     * @return
      */
      */
-    public <T> void compareNameWithBill(List<T> input, RuleBaseDTO ruleBaseDTO, List<BillMsg> billMsgList,
-                                        String conType, RuleSimpleDTO ruleSimpleDTO) {
+    public <T> Boolean compareNameWithBill(List<T> input, RuleBaseDTO ruleBaseDTO, RuleSimpleDTO ruleSimpleDTO, String conType) {
+        boolean flag = false;
+        List<String> contentList = Lists.newArrayList();
         if (ListUtil.isNotEmpty(input)) {
         if (ListUtil.isNotEmpty(input)) {
             for (T d : input) {
             for (T d : input) {
                 Negative val = (Negative) CoreUtil.getFieldValue(d, "negative");
                 Negative val = (Negative) CoreUtil.getFieldValue(d, "negative");
@@ -87,14 +88,18 @@ public class CommonRule {
                     String standName = (String) CoreUtil.getFieldValue(d, "standName");
                     String standName = (String) CoreUtil.getFieldValue(d, "standName");
                     String name = (String) CoreUtil.getFieldValue(d, "name");
                     String name = (String) CoreUtil.getFieldValue(d, "name");
                     if (StringUtils.isNotBlank(standName) && CoreUtil.compareName(ruleBaseDTO, standName)) {
                     if (StringUtils.isNotBlank(standName) && CoreUtil.compareName(ruleBaseDTO, standName)) {
-                        ruleSimpleDTO.setContent(name);
-                        ruleSimpleDTO.setConType(conType);
-                        BillMsg billMsg = msgNewUtil.getCommonBillMsg(ruleSimpleDTO);
-                        CoreUtil.addBeanToList(billMsgList, billMsg);
+                        if (!contentList.contains(name)) {
+                            contentList.add(name);
+                        }
+                        flag = true;
                     }
                     }
                 }
                 }
             }
             }
         }
         }
+        if (flag) {
+            CoreUtil.setListAndType(ruleSimpleDTO, contentList, conType);
+        }
+        return flag;
     }
     }
 
 
     /**
     /**
@@ -172,25 +177,28 @@ public class CommonRule {
      *
      *
      * @param input
      * @param input
      * @param ruleBaseDTO
      * @param ruleBaseDTO
-     * @param billMsgList
-     * @param conType
      * @param ruleSimpleDTO
      * @param ruleSimpleDTO
      * @param <T>
      * @param <T>
      */
      */
-    public <T> void compareItemWithBill(List<T> input, RuleBaseDTO ruleBaseDTO, List<BillMsg> billMsgList,
-                                        String conType, RuleSimpleDTO ruleSimpleDTO) {
+    public <T> Boolean compareItemWithBill(List<T> input, RuleBaseDTO ruleBaseDTO, RuleSimpleDTO ruleSimpleDTO, String conType) {
+        boolean flag = false;
+        List<String> contentList = Lists.newArrayList();
         if (ListUtil.isNotEmpty(input)) {
         if (ListUtil.isNotEmpty(input)) {
             for (T t : input) {
             for (T t : input) {
-                String uniqueName = (String) CoreUtil.getFieldValue(t, "uniqueName"); // 标准名称
-                String inputName = (String) CoreUtil.getFieldValue(t, "name"); // 界面名称
+                String uniqueName = ReflectUtil.getProperty(t, "uniqueName"); // 标准名称
+                String inputName = ReflectUtil.getProperty(t, "name"); // 界面名称
                 if (CoreUtil.compareName(ruleBaseDTO, uniqueName)) {
                 if (CoreUtil.compareName(ruleBaseDTO, uniqueName)) {
-                    ruleSimpleDTO.setContent(inputName);
-                    ruleSimpleDTO.setConType(conType);
-                    BillMsg billMsg = msgNewUtil.getCommonBillMsg(ruleSimpleDTO);
-                    CoreUtil.addBeanToList(billMsgList, billMsg);
+                    if (!contentList.contains(inputName)) {
+                        contentList.add(inputName);
+                    }
+                    flag = true;
                 }
                 }
             }
             }
         }
         }
+        if (flag) {
+            CoreUtil.setListAndType(ruleSimpleDTO, contentList, conType);
+        }
+        return flag;
     }
     }
 
 
     /**
     /**
@@ -263,8 +271,7 @@ public class CommonRule {
                 if (flag == 1) {
                 if (flag == 1) {
                     ruleSimpleDTO.setContent(result);
                     ruleSimpleDTO.setContent(result);
                     ruleSimpleDTO.setConType(conType);
                     ruleSimpleDTO.setConType(conType);
-                    BillMsg billMsg = msgNewUtil.getCommonBillMsg(ruleSimpleDTO);
-                    CoreUtil.addBeanToList(billMsgList, billMsg);
+                    msgNewUtil.getCommonBillMsg(ruleSimpleDTO, billMsgList);
                 }
                 }
             }
             }
         }
         }
@@ -293,8 +300,7 @@ public class CommonRule {
                 if (flag == 1) { // 有效期范围内
                 if (flag == 1) { // 有效期范围内
                     ruleSimpleDTO.setContent(matchDTO.getContent());
                     ruleSimpleDTO.setContent(matchDTO.getContent());
                     ruleSimpleDTO.setConType(conType);
                     ruleSimpleDTO.setConType(conType);
-                    BillMsg billMsg = msgNewUtil.getCommonBillMsg(ruleSimpleDTO);
-                    CoreUtil.addBeanToList(billMsgList, billMsg);
+                    msgNewUtil.getCommonBillMsg(ruleSimpleDTO, billMsgList);
                 }
                 }
             }
             }
         }
         }
@@ -366,18 +372,21 @@ public class CommonRule {
      *
      *
      * @param orderList     开单列表
      * @param orderList     开单列表
      * @param ruleBaseDTO
      * @param ruleBaseDTO
-     * @param billMsgList
      * @param ruleSimpleDTO
      * @param ruleSimpleDTO
+     * @param conType
      * @param set           用于记录:A与B不宜同时进行, B与A不宜同时进行 只能提示一个
      * @param set           用于记录:A与B不宜同时进行, B与A不宜同时进行 只能提示一个
+     * @param <T>
      */
      */
-    public <T> void exclusionBillOrder(List<T> orderList, RuleBaseDTO ruleBaseDTO, List<BillMsg> billMsgList, String conType, RuleSimpleDTO ruleSimpleDTO, Set<String> set) {
+    public <T> Boolean exclusionBillOrder(List<T> orderList, RuleBaseDTO ruleBaseDTO, RuleSimpleDTO ruleSimpleDTO, String conType, Set<String> set) {
+        boolean flag = false;
+        List<String> contentList = Lists.newArrayList();
         if (ListUtil.isNotEmpty(orderList) && orderList.size() > 1) {
         if (ListUtil.isNotEmpty(orderList) && orderList.size() > 1) {
             String baseLibName = ruleBaseDTO.getBaseLibName(); // 互斥名称
             String baseLibName = ruleBaseDTO.getBaseLibName(); // 互斥名称
             String libName = ruleSimpleDTO.getLibName(); // 标准名称
             String libName = ruleSimpleDTO.getLibName(); // 标准名称
             String inputName = ruleSimpleDTO.getInputName(); // 医院名称
             String inputName = ruleSimpleDTO.getInputName(); // 医院名称
             // 加入集合后,会出现自己与自己互斥的数据,这些数据不提示
             // 加入集合后,会出现自己与自己互斥的数据,这些数据不提示
             if (libName.equals(baseLibName)) {
             if (libName.equals(baseLibName)) {
-                return;
+                return flag;
             }
             }
             // 不同的项目可能对应同一个uniqueName,提示显示多条
             // 不同的项目可能对应同一个uniqueName,提示显示多条
             Map<String, List<T>> map = EntityUtil.makeEntityListMap(orderList, "uniqueName");
             Map<String, List<T>> map = EntityUtil.makeEntityListMap(orderList, "uniqueName");
@@ -389,14 +398,18 @@ public class CommonRule {
                     if (!set.contains(inputName + CommonEnum.splitSymbol.getName() + orginName)) {
                     if (!set.contains(inputName + CommonEnum.splitSymbol.getName() + orginName)) {
                         set.add(inputName + CommonEnum.splitSymbol.getName() + orginName);
                         set.add(inputName + CommonEnum.splitSymbol.getName() + orginName);
                         set.add(orginName + CommonEnum.splitSymbol.getName() + inputName);
                         set.add(orginName + CommonEnum.splitSymbol.getName() + inputName);
-                        ruleSimpleDTO.setContent(orginName);
-                        ruleSimpleDTO.setConType(conType);
-                        BillMsg billMsg = msgNewUtil.getCommonBillMsg(ruleSimpleDTO);
-                        CoreUtil.addBeanToList(billMsgList, billMsg);
+                        if (!contentList.contains(orginName)) {
+                            contentList.add(orginName);
+                        }
+                        flag = true;
                     }
                     }
                 }
                 }
             }
             }
         }
         }
+        if (flag) {
+            CoreUtil.setListAndType(ruleSimpleDTO, contentList, conType);
+        }
+        return flag;
     }
     }
 
 
     /**
     /**
@@ -404,17 +417,21 @@ public class CommonRule {
      *
      *
      * @param orderList     开单列表
      * @param orderList     开单列表
      * @param ruleBaseDTO
      * @param ruleBaseDTO
-     * @param billMsgList
+     * @param conType
      * @param ruleSimpleDTO
      * @param ruleSimpleDTO
      * @param set           用于记录:A与B不宜同时进行, B与A不宜同时进行 只能提示一个
      * @param set           用于记录:A与B不宜同时进行, B与A不宜同时进行 只能提示一个
+     * @param <T>
+     * @return
      */
      */
-    public <T> void exclusionBillStruct(List<T> orderList, RuleBaseDTO ruleBaseDTO, List<BillMsg> billMsgList, String conType, RuleSimpleDTO ruleSimpleDTO, Set<String> set) {
+    public <T> Boolean exclusionBillStruct(List<T> orderList, RuleBaseDTO ruleBaseDTO, RuleSimpleDTO ruleSimpleDTO, String conType, Set<String> set) {
+        boolean flag = false;
+        List<String> contentList = Lists.newArrayList();
         if (ListUtil.isNotEmpty(orderList)) {
         if (ListUtil.isNotEmpty(orderList)) {
             String baseLibName = ruleBaseDTO.getBaseLibName(); // 互斥名称
             String baseLibName = ruleBaseDTO.getBaseLibName(); // 互斥名称
             String libName = ruleSimpleDTO.getLibName(); // 标准名称
             String libName = ruleSimpleDTO.getLibName(); // 标准名称
             // 加入集合后,会出现自己与自己互斥的数据,这些数据不提示
             // 加入集合后,会出现自己与自己互斥的数据,这些数据不提示
             if (libName.equals(baseLibName)) {
             if (libName.equals(baseLibName)) {
-                return;
+                return flag;
             }
             }
             // 不同的项目可能对应同一个uniqueName,提示显示多条
             // 不同的项目可能对应同一个uniqueName,提示显示多条
             Map<String, List<T>> map = EntityUtil.makeEntityListMap(orderList, "uniqueName");
             Map<String, List<T>> map = EntityUtil.makeEntityListMap(orderList, "uniqueName");
@@ -440,16 +457,20 @@ public class CommonRule {
                             if (!set.contains(libName + CommonEnum.splitSymbol.getName() + orginName)) {
                             if (!set.contains(libName + CommonEnum.splitSymbol.getName() + orginName)) {
                                 set.add(libName + CommonEnum.splitSymbol.getName() + orginName);
                                 set.add(libName + CommonEnum.splitSymbol.getName() + orginName);
                                 set.add(orginName + CommonEnum.splitSymbol.getName() + libName);
                                 set.add(orginName + CommonEnum.splitSymbol.getName() + libName);
-                                ruleSimpleDTO.setContent(orginName);
-                                ruleSimpleDTO.setConType(conType);
-                                BillMsg billMsg = msgNewUtil.getCommonBillMsg(ruleSimpleDTO);
-                                CoreUtil.addBeanToList(billMsgList, billMsg);
+                                if (!contentList.contains(orginName)) {
+                                    contentList.add(orginName);
+                                }
+                                flag = true;
                             }
                             }
                         }
                         }
                     }
                     }
                 }
                 }
             }
             }
         }
         }
+        if (flag) {
+            CoreUtil.setListAndType(ruleSimpleDTO, contentList, conType);
+        }
+        return flag;
     }
     }
 
 
     /**
     /**
@@ -505,8 +526,7 @@ public class CommonRule {
                                     String name = (String) CoreUtil.getFieldValue(it, "name");
                                     String name = (String) CoreUtil.getFieldValue(it, "name");
                                     String uniqueName = (String) CoreUtil.getFieldValue(it, "uniqueName");
                                     String uniqueName = (String) CoreUtil.getFieldValue(it, "uniqueName");
                                     RuleSimpleDTO ruleSimpleDTO = new RuleSimpleDTO(name, uniqueName, type, name, conType);
                                     RuleSimpleDTO ruleSimpleDTO = new RuleSimpleDTO(name, uniqueName, type, name, conType);
-                                    BillMsg billMsg = msgNewUtil.getCommonBillMsg(ruleSimpleDTO);
-                                    CoreUtil.addBeanToList(billMsgList, billMsg);
+                                    msgNewUtil.getCommonBillMsg(ruleSimpleDTO, billMsgList);
                                     break;
                                     break;
                                 }
                                 }
                             }
                             }
@@ -557,8 +577,7 @@ public class CommonRule {
                                 getFrquenceType(ReflectUtil.getProperty(it, "frequency"))
                                 getFrquenceType(ReflectUtil.getProperty(it, "frequency"))
                                         .equals(getFrquenceType(ReflectUtil.getProperty(it, "frequency")))) {
                                         .equals(getFrquenceType(ReflectUtil.getProperty(it, "frequency")))) {
                             RuleSimpleDTO ruleSimpleDTO = new RuleSimpleDTO(orderName, orderUniqueName, type, orderName, conType);
                             RuleSimpleDTO ruleSimpleDTO = new RuleSimpleDTO(orderName, orderUniqueName, type, orderName, conType);
-                            BillMsg billMsg = msgNewUtil.getCommonBillMsg(ruleSimpleDTO);
-                            CoreUtil.addBeanToList(billMsgList, billMsg);
+                            msgNewUtil.getCommonBillMsg(ruleSimpleDTO, billMsgList);
                             break;
                             break;
                         }
                         }
                     }
                     }

+ 12 - 12
src/main/java/com/diagbot/rule/DrugRule.java

@@ -1,14 +1,13 @@
 package com.diagbot.rule;
 package com.diagbot.rule;
 
 
-import com.diagbot.dto.BillMsg;
 import com.diagbot.dto.RuleBaseDTO;
 import com.diagbot.dto.RuleBaseDTO;
 import com.diagbot.dto.RuleSimpleDTO;
 import com.diagbot.dto.RuleSimpleDTO;
 import com.diagbot.enums.LexiconEnum;
 import com.diagbot.enums.LexiconEnum;
 import com.diagbot.enums.RedisEnum;
 import com.diagbot.enums.RedisEnum;
 import com.diagbot.util.CoreUtil;
 import com.diagbot.util.CoreUtil;
 import com.diagbot.util.ListUtil;
 import com.diagbot.util.ListUtil;
-import com.diagbot.util.MsgNewUtil;
 import com.diagbot.util.RedisUtil;
 import com.diagbot.util.RedisUtil;
+import com.google.common.collect.Lists;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Component;
@@ -26,21 +25,18 @@ public class DrugRule {
 
 
     @Autowired
     @Autowired
     RedisUtil redisUtil;
     RedisUtil redisUtil;
-    @Autowired
-    MsgNewUtil msgNewUtil;
 
 
     /**
     /**
      * 比较药品是否匹配(先根据baseLibType判断返回的是药品通用名还是药品分类,如果返回的是药品分类,从redis获取药品通用名)
      * 比较药品是否匹配(先根据baseLibType判断返回的是药品通用名还是药品分类,如果返回的是药品分类,从redis获取药品通用名)
      *
      *
      * @param inputList
      * @param inputList
      * @param ruleBaseDTO
      * @param ruleBaseDTO
-     * @param billMsgList
-     * @param conType
      * @param ruleSimpleDTO
      * @param ruleSimpleDTO
      * @param <T>
      * @param <T>
      */
      */
-    public <T> void bill(List<T> inputList, RuleBaseDTO ruleBaseDTO, List<BillMsg> billMsgList, String conType,
-                         RuleSimpleDTO ruleSimpleDTO) {
+    public <T> Boolean bill(List<T> inputList, RuleBaseDTO ruleBaseDTO, RuleSimpleDTO ruleSimpleDTO, String conType) {
+        boolean flag = false;
+        List<String> contentList = Lists.newArrayList();
         if (ListUtil.isNotEmpty(inputList)) {
         if (ListUtil.isNotEmpty(inputList)) {
             List<String> allDrug = new ArrayList<>();
             List<String> allDrug = new ArrayList<>();
             if (ruleBaseDTO.getBaseLibType().equals(LexiconEnum.MedChemClass.getKey())
             if (ruleBaseDTO.getBaseLibType().equals(LexiconEnum.MedChemClass.getKey())
@@ -58,12 +54,16 @@ public class DrugRule {
                 String uniqueName = (String) CoreUtil.getFieldValue(d, "uniqueName");
                 String uniqueName = (String) CoreUtil.getFieldValue(d, "uniqueName");
                 String name = (String) CoreUtil.getFieldValue(d, "name");
                 String name = (String) CoreUtil.getFieldValue(d, "name");
                 if (StringUtils.isNotBlank(uniqueName) && allDrug.contains(uniqueName)) {
                 if (StringUtils.isNotBlank(uniqueName) && allDrug.contains(uniqueName)) {
-                    ruleSimpleDTO.setContent(name);
-                    ruleSimpleDTO.setConType(conType);
-                    BillMsg billMsg = msgNewUtil.getCommonBillMsg(ruleSimpleDTO);
-                    CoreUtil.addBeanToList(billMsgList, billMsg);
+                    if (!contentList.contains(name)) {
+                        contentList.add(name);
+                    }
+                    flag = true;
                 }
                 }
             }
             }
         }
         }
+        if (flag) {
+            CoreUtil.setListAndType(ruleSimpleDTO, contentList, conType);
+        }
+        return flag;
     }
     }
 }
 }

+ 40 - 0
src/main/java/com/diagbot/rule/FormRule.java

@@ -0,0 +1,40 @@
+package com.diagbot.rule;
+
+import com.diagbot.dto.RuleBaseDTO;
+import com.diagbot.dto.RuleSimpleDTO;
+import com.diagbot.util.CoreUtil;
+import com.google.common.collect.Lists;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+/**
+ * @description: 剂型规则
+ * @author: zhoutg
+ * @time: 2020/8/3 14:47
+ */
+@Component
+public class FormRule {
+
+    /**
+     * 比较名称是否匹配——开单
+     *
+     * @param ruleBaseDTO
+     * @param ruleSimpleDTO
+     * @param <T>
+     */
+    public <T> Boolean bill(RuleBaseDTO ruleBaseDTO, RuleSimpleDTO ruleSimpleDTO) {
+        List<String> contentList = Lists.newArrayList();
+        String name = ruleSimpleDTO.getForm(); // 药品剂型
+        boolean flag = CoreUtil.compareName(ruleBaseDTO, name);
+        if (flag) {
+            if (!contentList.contains(name)) {
+                contentList.add(name);
+            }
+            if (ruleSimpleDTO != null) {
+                ruleSimpleDTO.setMatchNum(ruleSimpleDTO.getMatchNum() + 1);
+            }
+        }
+        return flag;
+    }
+}

+ 10 - 12
src/main/java/com/diagbot/rule/GroupRule.java

@@ -1,13 +1,12 @@
 package com.diagbot.rule;
 package com.diagbot.rule;
 
 
 import com.diagbot.biz.push.entity.Item;
 import com.diagbot.biz.push.entity.Item;
-import com.diagbot.dto.BillMsg;
 import com.diagbot.dto.RuleBaseDTO;
 import com.diagbot.dto.RuleBaseDTO;
 import com.diagbot.dto.RuleSimpleDTO;
 import com.diagbot.dto.RuleSimpleDTO;
 import com.diagbot.dto.WordCrfDTO;
 import com.diagbot.dto.WordCrfDTO;
+import com.diagbot.enums.ConEnum;
 import com.diagbot.util.CoreUtil;
 import com.diagbot.util.CoreUtil;
 import com.diagbot.util.ListUtil;
 import com.diagbot.util.ListUtil;
-import com.diagbot.util.MsgNewUtil;
 import com.diagbot.util.RegexUtil;
 import com.diagbot.util.RegexUtil;
 import com.diagbot.util.StringUtil;
 import com.diagbot.util.StringUtil;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Lists;
@@ -29,26 +28,25 @@ public class GroupRule {
 
 
     @Autowired
     @Autowired
     CommonRule commonRule;
     CommonRule commonRule;
-    @Autowired
-    MsgNewUtil msgNewUtil;
 
 
     /**
     /**
      * 禁忌人群开单项
      * 禁忌人群开单项
      *
      *
      * @param wordCrfDTO
      * @param wordCrfDTO
      * @param ruleBaseDTO
      * @param ruleBaseDTO
-     * @param billMsgList
-     * @param conType
      * @param ruleSimpleDTO
      * @param ruleSimpleDTO
      */
      */
-    public void bill(WordCrfDTO wordCrfDTO, RuleBaseDTO ruleBaseDTO, List<BillMsg> billMsgList, String conType, RuleSimpleDTO ruleSimpleDTO) {
+    public Boolean bill(WordCrfDTO wordCrfDTO, RuleBaseDTO ruleBaseDTO, RuleSimpleDTO ruleSimpleDTO) {
         Map map = rule(wordCrfDTO, ruleBaseDTO);
         Map map = rule(wordCrfDTO, ruleBaseDTO);
-        if (CoreUtil.getMapFlag(map)) {
-            ruleSimpleDTO.setContent(ruleBaseDTO.getBaseLibName());
-            ruleSimpleDTO.setConType(conType);
-            BillMsg billMsg = msgNewUtil.getCommonBillMsg(ruleSimpleDTO);
-            CoreUtil.addBeanToList(billMsgList, billMsg);
+        boolean flag = CoreUtil.getMapFlag(map);
+        if (flag) {
+            List<String> contentList = Lists.newArrayList();
+            if (!contentList.contains(ruleBaseDTO.getBaseLibName())) {
+                contentList.add(ruleBaseDTO.getBaseLibName());
+            }
+            CoreUtil.setListAndType(ruleSimpleDTO, contentList, ConEnum.group.getName());
         }
         }
+        return flag;
     }
     }
 
 
     /**
     /**

+ 13 - 7
src/main/java/com/diagbot/rule/LisRule.java

@@ -8,6 +8,7 @@ import com.diagbot.dto.MatchDTO;
 import com.diagbot.dto.RuleBaseDTO;
 import com.diagbot.dto.RuleBaseDTO;
 import com.diagbot.dto.RuleSimpleDTO;
 import com.diagbot.dto.RuleSimpleDTO;
 import com.diagbot.dto.WordCrfDTO;
 import com.diagbot.dto.WordCrfDTO;
+import com.diagbot.enums.ConEnum;
 import com.diagbot.enums.LexiconEnum;
 import com.diagbot.enums.LexiconEnum;
 import com.diagbot.enums.TypeEnum;
 import com.diagbot.enums.TypeEnum;
 import com.diagbot.util.CoreUtil;
 import com.diagbot.util.CoreUtil;
@@ -15,6 +16,7 @@ import com.diagbot.util.ListUtil;
 import com.diagbot.util.MsgNewUtil;
 import com.diagbot.util.MsgNewUtil;
 import com.diagbot.util.MsgUtil;
 import com.diagbot.util.MsgUtil;
 import com.diagbot.util.StringUtil;
 import com.diagbot.util.StringUtil;
+import com.google.common.collect.Lists;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Component;
 
 
@@ -46,22 +48,26 @@ public class LisRule {
      *
      *
      * @param inputLis
      * @param inputLis
      * @param ruleBaseDTO
      * @param ruleBaseDTO
-     * @param billMsgList
-     * @param conType
      * @param ruleSimpleDTO
      * @param ruleSimpleDTO
      */
      */
-    public void bill(List<Lis> inputLis, RuleBaseDTO ruleBaseDTO, List<BillMsg> billMsgList, String conType, RuleSimpleDTO ruleSimpleDTO) {
+    public Boolean bill(List<Lis> inputLis, RuleBaseDTO ruleBaseDTO, RuleSimpleDTO ruleSimpleDTO) {
+        boolean flag = false;
+        List<String> contentList = Lists.newArrayList();
         if (ListUtil.isNotEmpty(inputLis) && StringUtil.isNotBlank(ruleBaseDTO.getBaseLibName())) {
         if (ListUtil.isNotEmpty(inputLis) && StringUtil.isNotBlank(ruleBaseDTO.getBaseLibName())) {
             for (Lis lis : inputLis) {
             for (Lis lis : inputLis) {
                 MatchDTO matchDTO = CoreUtil.compareLis(ruleBaseDTO, lis);
                 MatchDTO matchDTO = CoreUtil.compareLis(ruleBaseDTO, lis);
                 if (matchDTO != null) {
                 if (matchDTO != null) {
-                    ruleSimpleDTO.setContent(matchDTO.getContent());
-                    ruleSimpleDTO.setConType(conType);
-                    BillMsg billMsg = msgNewUtil.getCommonBillMsg(ruleSimpleDTO);
-                    CoreUtil.addBeanToList(billMsgList, billMsg);
+                    if (!contentList.contains(matchDTO.getContent())) {
+                        contentList.add(matchDTO.getContent());
+                    }
+                    flag = true;
                 }
                 }
             }
             }
         }
         }
+        if (flag) {
+            CoreUtil.setListAndType(ruleSimpleDTO, contentList, ConEnum.lis.getName());
+        }
+        return flag;
     }
     }
 
 
     /**
     /**

+ 9 - 14
src/main/java/com/diagbot/rule/MedEquRule.java

@@ -1,12 +1,11 @@
 package com.diagbot.rule;
 package com.diagbot.rule;
 
 
-import com.diagbot.dto.BillMsg;
 import com.diagbot.dto.RuleBaseDTO;
 import com.diagbot.dto.RuleBaseDTO;
 import com.diagbot.dto.RuleSimpleDTO;
 import com.diagbot.dto.RuleSimpleDTO;
 import com.diagbot.dto.WordCrfDTO;
 import com.diagbot.dto.WordCrfDTO;
+import com.diagbot.enums.ConEnum;
 import com.diagbot.util.CoreUtil;
 import com.diagbot.util.CoreUtil;
-import com.diagbot.util.MsgNewUtil;
-import org.springframework.beans.factory.annotation.Autowired;
+import com.google.common.collect.Lists;
 import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Component;
 
 
 import java.util.List;
 import java.util.List;
@@ -19,33 +18,29 @@ import java.util.List;
 @Component
 @Component
 public class MedEquRule {
 public class MedEquRule {
 
 
-    @Autowired
-    MsgNewUtil msgNewUtil;
-
     /**
     /**
      * 比较文本内容是否存在
      * 比较文本内容是否存在
      *
      *
      * @param wordCrfDTO
      * @param wordCrfDTO
      * @param ruleBaseDTO
      * @param ruleBaseDTO
-     * @param billMsgList
-     * @param conType
      * @param ruleSimpleDTO
      * @param ruleSimpleDTO
      */
      */
-    public void bill(WordCrfDTO wordCrfDTO, RuleBaseDTO ruleBaseDTO, List<BillMsg> billMsgList, String conType,
-                     RuleSimpleDTO ruleSimpleDTO) {
+    public Boolean bill(WordCrfDTO wordCrfDTO, RuleBaseDTO ruleBaseDTO, RuleSimpleDTO ruleSimpleDTO) {
         String chief = wordCrfDTO.getChief();
         String chief = wordCrfDTO.getChief();
         String symptom = wordCrfDTO.getSymptom();
         String symptom = wordCrfDTO.getSymptom();
         String pasts = wordCrfDTO.getPasts();
         String pasts = wordCrfDTO.getPasts();
         boolean flag = false;
         boolean flag = false;
+        List<String> contentList = Lists.newArrayList();
         if (chief.contains(ruleBaseDTO.getBaseLibName()) || symptom.contains(ruleBaseDTO.getBaseLibName())
         if (chief.contains(ruleBaseDTO.getBaseLibName()) || symptom.contains(ruleBaseDTO.getBaseLibName())
                 || pasts.contains(ruleBaseDTO.getBaseLibName())) {
                 || pasts.contains(ruleBaseDTO.getBaseLibName())) {
+            if (!contentList.contains(ruleBaseDTO.getBaseLibName())) {
+                contentList.add(ruleBaseDTO.getBaseLibName());
+            }
             flag = true;
             flag = true;
         }
         }
         if (flag) {
         if (flag) {
-            ruleSimpleDTO.setContent(ruleBaseDTO.getBaseLibName());
-            ruleSimpleDTO.setConType(conType);
-            BillMsg billMsg = msgNewUtil.getCommonBillMsg(ruleSimpleDTO);
-            CoreUtil.addBeanToList(billMsgList, billMsg);
+            CoreUtil.setListAndType(ruleSimpleDTO, contentList, ConEnum.medEqu.getName());
         }
         }
+        return flag;
     }
     }
 }
 }

+ 5 - 4
src/main/java/com/diagbot/rule/OtherRule.java

@@ -12,7 +12,6 @@ import com.diagbot.enums.TypeEnum;
 import com.diagbot.model.entity.AllergyMedicine;
 import com.diagbot.model.entity.AllergyMedicine;
 import com.diagbot.model.entity.Negative;
 import com.diagbot.model.entity.Negative;
 import com.diagbot.model.label.PastLabel;
 import com.diagbot.model.label.PastLabel;
-import com.diagbot.util.CoreUtil;
 import com.diagbot.util.ListUtil;
 import com.diagbot.util.ListUtil;
 import com.diagbot.util.MsgNewUtil;
 import com.diagbot.util.MsgNewUtil;
 import com.diagbot.util.RedisUtil;
 import com.diagbot.util.RedisUtil;
@@ -21,6 +20,7 @@ import com.diagbot.vo.Drug;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Lists;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Component;
+
 import java.util.List;
 import java.util.List;
 import java.util.Map;
 import java.util.Map;
 
 
@@ -38,7 +38,9 @@ public class OtherRule {
     RedisUtil redisUtil;
     RedisUtil redisUtil;
 
 
     /**
     /**
-     * 过敏原自身过敏,如果规则已维护,就不再比较;如果没有维护,比较是否与自身过敏
+     * redis存储自身对自身过敏规则的数据,防止因为提示语不一样而出现多条,
+     * 如果规则已维护自身过敏的规则,就不再比较;
+     * 如果没有维护,比较过敏原是否与开单项同名
      *
      *
      * @param
      * @param
      * @return
      * @return
@@ -66,8 +68,7 @@ public class OtherRule {
                         ruleSimpleDTO.setLibTypeName(TypeEnum.drug.getName());
                         ruleSimpleDTO.setLibTypeName(TypeEnum.drug.getName());
                         ruleSimpleDTO.setContent(name);
                         ruleSimpleDTO.setContent(name);
                         ruleSimpleDTO.setConType(ConEnum.allergicmeds.getName());
                         ruleSimpleDTO.setConType(ConEnum.allergicmeds.getName());
-                        BillMsg billMsg = msgNewUtil.getCommonBillMsg(ruleSimpleDTO);
-                        CoreUtil.addBeanToList(res.getBillMsgList(), billMsg);
+                        msgNewUtil.getCommonBillMsg(ruleSimpleDTO, res.getBillMsgList());
                     }
                     }
                 }
                 }
             }
             }

+ 13 - 8
src/main/java/com/diagbot/rule/PacsRule.java

@@ -14,6 +14,7 @@ import com.diagbot.util.CoreUtil;
 import com.diagbot.util.ListUtil;
 import com.diagbot.util.ListUtil;
 import com.diagbot.util.MsgNewUtil;
 import com.diagbot.util.MsgNewUtil;
 import com.diagbot.util.MsgUtil;
 import com.diagbot.util.MsgUtil;
+import com.google.common.collect.Lists;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Component;
@@ -46,25 +47,29 @@ public class PacsRule {
      *
      *
      * @param inputList
      * @param inputList
      * @param ruleBaseDTO
      * @param ruleBaseDTO
-     * @param billMsgList
-     * @param conType
      * @param ruleSimpleDTO
      * @param ruleSimpleDTO
+     * @param conType
      * @param <T>
      * @param <T>
      */
      */
-    public <T> void bill(List<T> inputList, RuleBaseDTO ruleBaseDTO, List<BillMsg> billMsgList, String conType,
-                         RuleSimpleDTO ruleSimpleDTO) {
+    public <T> Boolean bill(List<T> inputList, RuleBaseDTO ruleBaseDTO, RuleSimpleDTO ruleSimpleDTO, String conType) {
+        boolean flag = false;
+        List<String> contentList = Lists.newArrayList();
         if (ListUtil.isNotEmpty(inputList)) {
         if (ListUtil.isNotEmpty(inputList)) {
             for (T bean : inputList) {
             for (T bean : inputList) {
                 String uniqueName = (String) CoreUtil.getFieldValue(bean, "uniqueName");
                 String uniqueName = (String) CoreUtil.getFieldValue(bean, "uniqueName");
                 String name = (String) CoreUtil.getFieldValue(bean, "name");
                 String name = (String) CoreUtil.getFieldValue(bean, "name");
                 if (StringUtils.isNotBlank(uniqueName) && CoreUtil.compareName(ruleBaseDTO, uniqueName)) {
                 if (StringUtils.isNotBlank(uniqueName) && CoreUtil.compareName(ruleBaseDTO, uniqueName)) {
-                    ruleSimpleDTO.setContent(name);
-                    ruleSimpleDTO.setConType(conType);
-                    BillMsg billMsg = msgNewUtil.getCommonBillMsg(ruleSimpleDTO);
-                    CoreUtil.addBeanToList(billMsgList, billMsg);
+                    if (!contentList.contains(name)) {
+                        contentList.add(name);
+                    }
+                    flag = true;
                 }
                 }
             }
             }
         }
         }
+        if (flag) {
+            CoreUtil.setListAndType(ruleSimpleDTO, contentList, conType);
+        }
+        return flag;
     }
     }
 
 
     /**
     /**

+ 42 - 0
src/main/java/com/diagbot/rule/RouteRule.java

@@ -0,0 +1,42 @@
+package com.diagbot.rule;
+
+import com.diagbot.dto.RuleBaseDTO;
+import com.diagbot.dto.RuleSimpleDTO;
+import com.diagbot.util.CoreUtil;
+import com.google.common.collect.Lists;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+/**
+ * @description: 给药途径规则
+ * @author: zhoutg
+ * @time: 2020/8/3 14:47
+ */
+@Component
+public class RouteRule {
+
+    /**
+     * 比较名称是否匹配——开单
+     *
+     * @param ruleBaseDTO
+     * @param ruleSimpleDTO
+     * @param <T>
+     */
+    public <T> Boolean bill(RuleBaseDTO ruleBaseDTO, RuleSimpleDTO ruleSimpleDTO) {
+        List<String> contentList = Lists.newArrayList();
+        String routeUniqueName = ruleSimpleDTO.getRouteUniqueName(); // 给药途径标准名称
+        String inputName = ruleSimpleDTO.getRouteName();  // 给药途径医院名称
+        boolean flag = CoreUtil.compareName(ruleBaseDTO, routeUniqueName);
+        if (flag) {
+            if (!contentList.contains(inputName)) {
+                contentList.add(inputName);
+            }
+            if (ruleSimpleDTO != null ) {
+                ruleSimpleDTO.setMatchNum(ruleSimpleDTO.getMatchNum()+ 1);
+                ruleSimpleDTO.setRouteMatch(true);
+            }
+        }
+        return flag;
+    }
+}

+ 11 - 15
src/main/java/com/diagbot/rule/SexRule.java

@@ -1,13 +1,12 @@
 package com.diagbot.rule;
 package com.diagbot.rule;
 
 
-import com.diagbot.dto.BillMsg;
 import com.diagbot.dto.RuleBaseDTO;
 import com.diagbot.dto.RuleBaseDTO;
 import com.diagbot.dto.RuleSimpleDTO;
 import com.diagbot.dto.RuleSimpleDTO;
 import com.diagbot.dto.WordCrfDTO;
 import com.diagbot.dto.WordCrfDTO;
+import com.diagbot.enums.ConEnum;
 import com.diagbot.util.CoreUtil;
 import com.diagbot.util.CoreUtil;
-import com.diagbot.util.MsgNewUtil;
 import com.diagbot.util.StringUtil;
 import com.diagbot.util.StringUtil;
-import org.springframework.beans.factory.annotation.Autowired;
+import com.google.common.collect.Lists;
 import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Component;
 
 
 import java.util.List;
 import java.util.List;
@@ -20,26 +19,23 @@ import java.util.List;
 @Component
 @Component
 public class SexRule {
 public class SexRule {
 
 
-    @Autowired
-    MsgNewUtil msgNewUtil;
-
     /**
     /**
      * 比较性别
      * 比较性别
      *
      *
      * @param wordCrfDTO
      * @param wordCrfDTO
      * @param ruleBaseDTO
      * @param ruleBaseDTO
-     * @param billMsgList
-     * @param conType
      * @param ruleSimpleDTO
      * @param ruleSimpleDTO
      */
      */
-    public void bill(WordCrfDTO wordCrfDTO, RuleBaseDTO ruleBaseDTO, List<BillMsg> billMsgList, String conType,
-                     RuleSimpleDTO ruleSimpleDTO) {
-        if (getFlag(wordCrfDTO, ruleBaseDTO)) {
-            ruleSimpleDTO.setContent(ruleBaseDTO.getBaseLibName());
-            ruleSimpleDTO.setConType(conType);
-            BillMsg billMsg = msgNewUtil.getCommonBillMsg(ruleSimpleDTO);
-            CoreUtil.addBeanToList(billMsgList, billMsg);
+    public Boolean bill(WordCrfDTO wordCrfDTO, RuleBaseDTO ruleBaseDTO, RuleSimpleDTO ruleSimpleDTO) {
+        boolean flag = getFlag(wordCrfDTO, ruleBaseDTO);
+        if (flag) {
+            List<String> contentList = Lists.newArrayList();
+            if (!contentList.contains(ruleBaseDTO.getBaseLibName())) {
+                contentList.add(ruleBaseDTO.getBaseLibName());
+            }
+            CoreUtil.setListAndType(ruleSimpleDTO, contentList, ConEnum.gender.getName());
         }
         }
+        return flag;
     }
     }
 
 
     /**
     /**

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

@@ -3,11 +3,10 @@ package com.diagbot.rule;
 import com.diagbot.dto.BillMsg;
 import com.diagbot.dto.BillMsg;
 import com.diagbot.dto.RuleBaseDTO;
 import com.diagbot.dto.RuleBaseDTO;
 import com.diagbot.dto.RuleSimpleDTO;
 import com.diagbot.dto.RuleSimpleDTO;
+import com.diagbot.enums.ConEnum;
 import com.diagbot.model.label.VitalLabel;
 import com.diagbot.model.label.VitalLabel;
 import com.diagbot.util.CoreUtil;
 import com.diagbot.util.CoreUtil;
-import com.diagbot.util.MsgNewUtil;
 import com.diagbot.util.MsgUtil;
 import com.diagbot.util.MsgUtil;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Component;
 
 
 import java.util.List;
 import java.util.List;
@@ -21,28 +20,22 @@ import java.util.Map;
 @Component
 @Component
 public class VitalRule {
 public class VitalRule {
 
 
-    @Autowired
-    MsgNewUtil msgNewUtil;
-
     /**
     /**
      * 比较体征——开单合理性
      * 比较体征——开单合理性
      *
      *
      * @param vitalLabel
      * @param vitalLabel
      * @param ruleBaseDTO
      * @param ruleBaseDTO
-     * @param billMsgList
-     * @param conType
      * @param ruleSimpleDTO
      * @param ruleSimpleDTO
      */
      */
-    public void bill(VitalLabel vitalLabel, RuleBaseDTO ruleBaseDTO, List<BillMsg> billMsgList, String conType,
-                     RuleSimpleDTO ruleSimpleDTO) {
+    public Boolean bill(VitalLabel vitalLabel, RuleBaseDTO ruleBaseDTO, RuleSimpleDTO ruleSimpleDTO) {
+        Boolean flag = false;
         Map<String, Object> map = CoreUtil.compareVital(ruleBaseDTO, vitalLabel);
         Map<String, Object> map = CoreUtil.compareVital(ruleBaseDTO, vitalLabel);
-        List<String> msgList = CoreUtil.getMapMsgList(map);
-        for (String s : msgList) {
-            ruleSimpleDTO.setContent(s);
-            ruleSimpleDTO.setConType(conType);
-            BillMsg billMsg = msgNewUtil.getCommonBillMsg(ruleSimpleDTO);
-            CoreUtil.addBeanToList(billMsgList, billMsg);
+        if (CoreUtil.getMapFlag(map)) {
+            List<String> msgList = CoreUtil.getMapMsgList(map);
+            CoreUtil.setListAndType(ruleSimpleDTO, msgList, ConEnum.vitals.getName());
+            flag = true;
         }
         }
+        return flag;
     }
     }
 
 
     /**
     /**

+ 43 - 0
src/main/java/com/diagbot/util/CoreUtil.java

@@ -4,6 +4,7 @@ import com.diagbot.biz.push.entity.Item;
 import com.diagbot.biz.push.entity.Lis;
 import com.diagbot.biz.push.entity.Lis;
 import com.diagbot.dto.MatchDTO;
 import com.diagbot.dto.MatchDTO;
 import com.diagbot.dto.RuleBaseDTO;
 import com.diagbot.dto.RuleBaseDTO;
+import com.diagbot.dto.RuleSimpleDTO;
 import com.diagbot.enums.CommonEnum;
 import com.diagbot.enums.CommonEnum;
 import com.diagbot.enums.LexiconEnum;
 import com.diagbot.enums.LexiconEnum;
 import com.diagbot.model.entity.BodyPart;
 import com.diagbot.model.entity.BodyPart;
@@ -1252,6 +1253,48 @@ public class CoreUtil {
         return flag;
         return flag;
     }
     }
 
 
+    // /**
+    //  * 对内容和禁忌类型赋值
+    //  *
+    //  * @param ruleSimpleDTO
+    //  */
+    // public static void setContentAndType(RuleSimpleDTO ruleSimpleDTO, String content, String conType) {
+    //     if (ruleSimpleDTO != null ) {
+    //         ruleSimpleDTO.setMatchNum(ruleSimpleDTO.getMatchNum()+ 1);
+    //         ruleSimpleDTO.setContent(content);
+    //         ruleSimpleDTO.setConType(conType);
+    //     }
+    // }
+
+    /**
+     * 对内容和禁忌类型赋值
+     * @param ruleSimpleDTO
+     * @param contentList
+     * @param conType
+     */
+    public static void setListAndType(RuleSimpleDTO ruleSimpleDTO, List<String> contentList, String conType) {
+        if (ruleSimpleDTO != null ) {
+            ruleSimpleDTO.setMatchNum(ruleSimpleDTO.getMatchNum()+ 1);
+            ruleSimpleDTO.setContentList(contentList);
+            ruleSimpleDTO.setConType(conType);
+        }
+    }
+
+    /**
+     * 重置RuleSimple
+     *
+     * @param ruleSimpleDTO
+     */
+    public static void resetRuleSimple(RuleSimpleDTO ruleSimpleDTO) {
+        if (ruleSimpleDTO != null ) {
+            ruleSimpleDTO.setMatchNum(0);
+            ruleSimpleDTO.setContentList(Lists.newArrayList());
+            ruleSimpleDTO.setConType("");
+            ruleSimpleDTO.setConType("");
+        }
+    }
+
+
     public static void main(String[] args) {
     public static void main(String[] args) {
         System.out.println(isNumbers("1.1"));
         System.out.println(isNumbers("1.1"));
         System.out.println(isNumbers("1.."));
         System.out.println(isNumbers("1.."));

+ 61 - 0
src/main/java/com/diagbot/util/ExcelUtils.java

@@ -24,11 +24,13 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.MultipartFile;
 
 
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpServletResponse;
+import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStream;
+import java.io.OutputStream;
 import java.net.URLEncoder;
 import java.net.URLEncoder;
 import java.util.Collection;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashMap;
@@ -36,6 +38,8 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.List;
 import java.util.Map;
 import java.util.Map;
 import java.util.NoSuchElementException;
 import java.util.NoSuchElementException;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
 
 
 /**
 /**
  * @Description: excel 导入导出工具类
  * @Description: excel 导入导出工具类
@@ -483,5 +487,62 @@ public class ExcelUtils {
         }
         }
     }
     }
 
 
+    /**
+     * 生成Workbook
+     *
+     * @param list
+     * @param title
+     * @param sheetName
+     * @param pojoClass
+     * @return
+     */
+    public static Workbook generateWorkBook(List<?> list, String title, String sheetName, Class<?> pojoClass) {
+        Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(title, sheetName), pojoClass, list);
+        return workbook;
+    }
 
 
+    /**
+     * 导出压缩文件,包含多个sheet
+     *
+     * @param workbookList
+     * @param response
+     * @param fileName
+     */
+    public static void exportMultiExcel(List<Workbook> workbookList, HttpServletResponse response, String fileName) {
+        OutputStream out = null;
+        ZipOutputStream zos = null;
+        try {
+            response.setContentType("application/octet-stream");
+            response.setHeader("Connection", "close"); // 表示不能用浏览器直接打开
+            response.setHeader("Accept-Ranges", "bytes");// 告诉客户端允许断点续传多线程连接下载
+            response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8"));
+            response.setCharacterEncoding("UTF-8");
+
+            out = response.getOutputStream();
+            zos = new ZipOutputStream(out);
+            for (Workbook workbook : workbookList) {
+                ZipEntry entry = new ZipEntry(workbook.getSheetName(0));
+                // 编写新的zip条目,并将流定位到条目数据的开头
+                zos.putNextEntry(entry);
+                //workBook.write会指定关闭数据流,直接用workbook.write(zos),下次就会抛出zos已被关闭的异常,所以用ByteArrayOutputStream来拷贝一下。
+                ByteArrayOutputStream bos = new ByteArrayOutputStream();
+                // workbook写入bos
+                workbook.write(bos);
+                // bos写入zos
+                bos.writeTo(zos);
+                zos.closeEntry();
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            if (zos != null) {
+                try {
+                    zos.flush();
+                    zos.close();
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+    }
 }
 }

+ 12 - 2
src/main/java/com/diagbot/util/MsgNewUtil.java

@@ -9,6 +9,8 @@ import com.diagbot.enums.RedisEnum;
 import com.diagbot.enums.TypeEnum;
 import com.diagbot.enums.TypeEnum;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Component;
+
+import java.util.List;
 import java.util.Map;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentHashMap;
 
 
@@ -34,7 +36,7 @@ public class MsgNewUtil {
      * @param ruleSimpleDTO
      * @param ruleSimpleDTO
      * @return
      * @return
      */
      */
-    public BillMsg getCommonBillMsg(RuleSimpleDTO ruleSimpleDTO) {
+    public void getCommonBillMsg(RuleSimpleDTO ruleSimpleDTO, List<BillMsg> billMsgList) {
         String orderName = ruleSimpleDTO.getInputName(); // 医院名称
         String orderName = ruleSimpleDTO.getInputName(); // 医院名称
         String orderStandName = ruleSimpleDTO.getLibName(); // 标准名称
         String orderStandName = ruleSimpleDTO.getLibName(); // 标准名称
         String orderType = ruleSimpleDTO.getLibTypeName(); // 开单项类型
         String orderType = ruleSimpleDTO.getLibTypeName(); // 开单项类型
@@ -53,11 +55,18 @@ public class MsgNewUtil {
                 && content.startsWith("具有") && msg.startsWith("该患者具有")) {
                 && content.startsWith("具有") && msg.startsWith("该患者具有")) {
             msg = msg.replace("具有", "");
             msg = msg.replace("具有", "");
         }
         }
+        // 给药途径替换
+        if (ruleSimpleDTO.isRouteMatch()) {
+            msg = msg.replace("[给药途径]", ruleSimpleDTO.getRouteName());
+        } else {
+            msg = msg.replace("[给药途径]", "");
+        }
         if (StringUtil.isNotBlank(unionMsg)) {
         if (StringUtil.isNotBlank(unionMsg)) {
             msg = msg.replace("[原因及建议]", "," + unionMsg);
             msg = msg.replace("[原因及建议]", "," + unionMsg);
         } else {
         } else {
             msg = msg.replace("[原因及建议]", "");
             msg = msg.replace("[原因及建议]", "");
         }
         }
+
         // [性别取反]标签替换
         // [性别取反]标签替换
         if (ConEnum.gender.getName().equals(conType)) {
         if (ConEnum.gender.getName().equals(conType)) {
             if ("男".equals(content)) {
             if ("男".equals(content)) {
@@ -77,7 +86,8 @@ public class MsgNewUtil {
         billMsg.setOrderStandName(orderStandName);
         billMsg.setOrderStandName(orderStandName);
         billMsg.setContent(content);
         billMsg.setContent(content);
         billMsg.setType(conType);
         billMsg.setType(conType);
-        return billMsg;
+
+        CoreUtil.addBeanToList(billMsgList, billMsg);
     }
     }
 
 
     /**
     /**

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

@@ -23,4 +23,8 @@ public class RuleVO {
     private String dateValue;
     private String dateValue;
     // 剂型
     // 剂型
     private String form;
     private String form;
+    // 给药途径医院名称
+    private String routeName;
+    // 给药途径标准名称
+    private String routeUniqueName;
 }
 }