Bladeren bron

Merge remote-tracking branch 'origin/gdb' into gdb

MarkHuang 4 jaren geleden
bovenliggende
commit
59823eeedd

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

@@ -29,7 +29,7 @@ public class CacheDeleteInit implements CommandLineRunner {
         cacheFacade.clear();
         log.info("CDSS-CORE服务启动清除redis缓存成功!");
 
-        neoFacade.getDrugCache();
-        log.info("CDSS-CORE服务启动加载药品缓存成功!");
+        // neoFacade.getDrugCache();
+        // log.info("CDSS-CORE服务启动加载药品缓存成功!");
     }
 }

+ 56 - 0
src/main/java/com/diagbot/enums/StaticTypeEnum.java

@@ -0,0 +1,56 @@
+package com.diagbot.enums;
+
+import com.diagbot.core.KeyedNamed;
+import lombok.Setter;
+
+/**
+ * @Description: 静态信息类型
+ * @author: gaodm
+ * @time: 2020/9/3 20:16
+ */
+public enum StaticTypeEnum implements KeyedNamed {
+
+    DIS(1, "医保ICD_10疾病"),
+    DRUG(2, "药品通用名"),
+    LISMIX(3, "实验室检查套餐"),
+    LIS(4, "实验室检查"),
+    PACS(5, "辅助检查"),
+    OPT(6, "手术和操作");
+
+    @Setter
+    private int key;
+
+    @Setter
+    private String name;
+
+    StaticTypeEnum(int key, String name) {
+        this.key = key;
+        this.name = name;
+    }
+
+    public static StaticTypeEnum getEnum(int key) {
+        for (StaticTypeEnum item : StaticTypeEnum.values()) {
+            if (item.key == key) {
+                return item;
+            }
+        }
+        return null;
+    }
+
+    public static String getName(int key) {
+        StaticTypeEnum item = getEnum(key);
+        return item != null ? item.name : null;
+    }
+
+    @Override
+    public int getKey() {
+        return key;
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+
+}

+ 2 - 1
src/main/java/com/diagbot/enums/TypeEnum.java

@@ -17,7 +17,8 @@ public enum TypeEnum implements KeyedNamed {
     drug(4, "药品"),
     clinical(5, "临床表现"),
     operation(6, "手术"),
-    vital(7, "查体");
+    vital(7, "查体"),
+    transfusion(8, "输血");
 
     @Setter
     private int key;

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

@@ -75,6 +75,7 @@ public class CommonFacade {
         }
         aiAnalyze.aiProcess(searchData, wordCrfDTO);
 
+        // 处理现病史中的化验和辅检,放入结构化
         processPresentLisPacs(wordCrfDTO);
         return wordCrfDTO;
     }
@@ -133,6 +134,8 @@ public class CommonFacade {
                     .map(x -> x.getName()).collect(Collectors.toList());
             allPacs.addAll(pacss_unique);
         }
+        allPacs.addAll(wordCrfDTO.getPacs().stream().filter(x -> StringUtils.isBlank(x.getUniqueName()))
+                .map(x -> x.getName()).collect(Collectors.toList()));
         //开单检查
         allPacs.addAll(wordCrfDTO.getPacsOrder().stream().filter(z -> StringUtils.isBlank(z.getUniqueName())).map(x -> x.getName()).collect(Collectors.toList()));
         standConvert.setPacsList(allPacs);
@@ -140,6 +143,7 @@ public class CommonFacade {
         List<String> drugList = new ArrayList<>();
         //1、现病史中的药品
         drugList.addAll(CoreUtil.getPropertyList(presentLabel.getMedicines()));
+        drugList.addAll(CoreUtil.getPropertyList(presentLabel.getTakeMedicine()));
         //2、既往史(药物过敏)
         drugList.addAll(CoreUtil.getPropertyList(pastLabel.getAllergyMedicines()));
         //3、开单药品
@@ -191,6 +195,7 @@ public class CommonFacade {
         CoreUtil.setPropertyList(wordCrfDTO.getDiag(),"name", "uniqueName", map.get(StandConvertEnum.disease.getName()));
         //药品回填
         CoreUtil.setPropertyList(presentLabel.getMedicines(), map.get(StandConvertEnum.drug.getName()));
+        CoreUtil.setPropertyList(presentLabel.getTakeMedicine(), map.get(StandConvertEnum.drug.getName()));
         CoreUtil.setPropertyList(pastLabel.getAllergyMedicines(), map.get(StandConvertEnum.drug.getName()));
         CoreUtil.setPropertyList(wordCrfDTO.getDrugOrder(),"name", "uniqueName", map.get(StandConvertEnum.drug.getName()));
         //化验回填
@@ -198,6 +203,7 @@ public class CommonFacade {
         CoreUtil.setPropertyList(wordCrfDTO.getLisOrder(), "name", "detailName", "uniqueName", map.get(StandConvertEnum.lis.getName()));
         //辅助检查回填
         CoreUtil.setPropertyList(pacsNews, "name", "uniqueName", map.get(StandConvertEnum.pacs.getName()));
+        CoreUtil.setPropertyList(wordCrfDTO.getPacs(), "name", "uniqueName", map.get(StandConvertEnum.pacs.getName()));
         CoreUtil.setPropertyList(wordCrfDTO.getPacsOrder(), "name", "uniqueName", map.get(StandConvertEnum.pacs.getName()));
         //体征回填
         CoreUtil.setPropertyList(vitalLabel.getVitals(), map.get(StandConvertEnum.vital.getName()));
@@ -297,7 +303,6 @@ public class CommonFacade {
             Map<String, Map<String, Map<String, Long>>> configMap = lisConfigFacade.getConfigMap(wordCrfDTO.getHospitalId(), lisNames, null);
             if(configMap.size() > 0){
                 lises.stream().forEach(x ->{
-
                     String bigName = x.getBigItem().getName();//大项名
                     String detailName = x.getName();//小项名
                     String value = x.getPd().getValue();
@@ -305,38 +310,31 @@ public class CommonFacade {
                     if(configMap.containsKey(bigName)){
                         Map<String, Map<String, Long>> uniqueDetailMap = configMap.get(bigName);
                         if(uniqueDetailMap.containsKey(detailName)){
-
                             List<String> uniques = uniqueDetailMap.get(detailName).keySet().stream().collect(Collectors.toList());//所有的公表项
                             if(ListUtil.isNotEmpty(uniques)){
                                 List<Lis> lisStream = uniques.stream().map(z -> {
-                                    Lis lis = new Lis();
-                                    lis.setDetailName(detailName);
-                                    lis.setName(bigName);
-                                    lis.setUniqueName(z);
-                                    lis.setValue(Double.parseDouble(value));
-                                    lis.setUnits(unit);
-                                    return lis;
+                                    return getLis(bigName, detailName, value, unit, z);
                                 }).collect(Collectors.toList());
                                 lisList.addAll(lisStream);
                             }
-
                         }else {
-                            Lis lis = getLis(bigName, detailName, value, unit);
+                            Lis lis = getLis(bigName, detailName, value, unit, null);
                             lisList.add(lis);
                         }
                     }else {
-                        Lis lis = getLis(bigName, detailName, value, unit);
+                        Lis lis = getLis(bigName, detailName, value, unit, null);
                         lisList.add(lis);
                     }
                 });
             }else {
                 lises.stream().forEach(x ->{
-                    Lis lis = getLis(x.getBigItem().getName(), x.getName(), x.getPd().getValue(), x.getPd().getUnit());
+                    Lis lis = getLis(x.getBigItem().getName(), x.getName(), x.getPd().getValue(), x.getPd().getUnit(), null);
                     lisList.add(lis);
                 });
             }
         }
         //处理辅检
+        List<com.diagbot.biz.push.entity.Pacs> pacs = new ArrayList<>();
         List<PacsNew> packagePacs = new ArrayList<>();
         List<PacsNew> pacsNewList = wordCrfDTO.getPresentLabel().getPacsNewList();
         if(ListUtil.isNotEmpty(pacsNewList)){
@@ -358,26 +356,53 @@ public class CommonFacade {
                             return pan;
                         }).collect(Collectors.toList());
                         packagePacs.addAll(collect);
+                        collect.forEach(x ->{
+                            com.diagbot.biz.push.entity.Pacs p = new com.diagbot.biz.push.entity.Pacs();
+                            p.setName(x.getName());
+                            p.setUniqueName(x.getUniqueName());
+                            pacs.add(p);
+                        });
+                    }else {
+                        PacsNew pan = new PacsNew();
+                        pan.setName(name);
+                        pan.setPacsResults(pacsResults);
+                        pan.setDisease(disease);
+                        packagePacs.add(pan);
+                        com.diagbot.biz.push.entity.Pacs p = new com.diagbot.biz.push.entity.Pacs();
+                        p.setName(name);
+                        pacs.add(p);
                     }
                 });
             }else {
                 packagePacs.addAll(pacsNewList);
+                pacsNewList.forEach(x ->{
+                    com.diagbot.biz.push.entity.Pacs p = new com.diagbot.biz.push.entity.Pacs();
+                    p.setName(x.getName());
+                    pacs.add(p);
+                });
             }
         }
+        if(ListUtil.isNotEmpty(pacs)){
+            wordCrfDTO.getPacs().addAll(pacs);
+        }
+
         wordCrfDTO.getLis().addAll(lisList);
-        wordCrfDTO.setLis(wordCrfDTO.getLis());
 
         PacsLabel pacsLabel = wordCrfDTO.getPacsLabel();
         pacsLabel.getPacsNewList().addAll(packagePacs);
-        wordCrfDTO.setPacsLabel(pacsLabel);
     }
 
-    private Lis getLis(String bigName, String detailName, String value, String unit) {
+    private Lis getLis(String bigName, String detailName, String value, String unit, String uniqueName) {
         Lis lis = new Lis();
         lis.setUnits(unit);
-        lis.setValue(Double.parseDouble(value));
+        if(StringUtils.isBlank(unit)){
+            lis.setOtherValue(value);
+        }else {
+            lis.setValue(Double.parseDouble(value));
+        }
         lis.setDetailName(detailName);
         lis.setName(bigName);
+        lis.setUniqueName(uniqueName);
         return lis;
     }
 }

+ 1 - 0
src/main/java/com/diagbot/facade/IndicationFacade.java

@@ -103,6 +103,7 @@ public class IndicationFacade {
 
         // 输入调试信息
         CoreUtil.getDebugStr(l1, "本次调用总计耗时", res.getDebug());
+        CoreUtil.getDebugObject("数据", res.getDebug(), wordCrfDTO);
         return res;
     }
 }

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

@@ -443,6 +443,9 @@ public class NeoFacade {
      */
     public void getConvertMap(Map<String, Map<String, StandConvertCrfDTO>> crfDTO, String type, List<String> convertList,
                               List<String> orginList, Map<String, Map<String, String>> map) {
+        if (ListUtil.isEmpty(orginList)) {
+            return ;
+        }
         Map<String, StandConvertCrfDTO> crfMap = crfDTO.get(type);
         Map<String, String> typeMap = new LinkedHashMap<>();
         Boolean updateRedis = false;

+ 28 - 2
src/main/java/com/diagbot/model/ai/BeHospitalizedAI.java

@@ -307,8 +307,9 @@ public class BeHospitalizedAI extends ModelAI {
         presentLabel.setText(wordCrfDTO.getPresentLabel().getText());
         List<Lis> lis = loadLises(aiOut);
         presentLabel.setLises(lis);
-//        EntityProcessPacsNew entityProcessPacsNew = new EntityProcessPacsNew();
-//        entityProcessPacsNew.extractEntity(aiOut, wordCrfDTO.getPacsLabel());
+        //服用药品
+        List<Medicine> medicines = takeMedicine(presentLabel);
+        presentLabel.setTakeMedicine(medicines);
         wordCrfDTO.setPresentLabel(presentLabel);
     }
 
@@ -677,4 +678,29 @@ public class BeHospitalizedAI extends ModelAI {
             }
         }
     }
+
+    /**
+     * 一般情况以后的药品
+     * @param presentLabel
+     */
+    public List<Medicine> takeMedicine(PresentLabel presentLabel){
+        List<Medicine> takems = new ArrayList<>();
+        List<GeneralDesc> generals = presentLabel.getGenerals();
+        List<Medicine> medicines = presentLabel.getMedicines();
+        if (generals.size() > 0) {
+            String presentText = presentLabel.getText();
+            if (StringUtils.isNotBlank(presentText) && medicines != null && medicines.size() > 0) {
+                String lastGeneral = generals.get(generals.size() - 1).getName();
+                int lastGeneralIndex = presentText.lastIndexOf(lastGeneral);
+                for (Medicine medicine : medicines) {
+                    /* 现病史中一般情况之后的药品名称,并且不包含不详 */
+                    int medicine_index = presentText.indexOf(medicine.getName());
+                    if (medicine_index > lastGeneralIndex && !medicine.getName().contains("不详")) {
+                        takems.add(medicine);
+                    }
+                }
+            }
+        }
+        return takems;
+    }
 }

+ 2 - 0
src/main/java/com/diagbot/model/label/PresentLabel.java

@@ -41,6 +41,8 @@ public class PresentLabel extends GeneralLabel {
     private BeHospitalizedWay beHospitalizedWay;
     //现病史中所有时间实体存入
     private List<PD> pds = new ArrayList<>();
+    //现病史一般情况之后的服用药品
+    List<Medicine> takeMedicine = new ArrayList<>();
 
     public <T> void add(List<T> list, T obj) {
         list.add(obj);

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

@@ -1,26 +1,15 @@
 package com.diagbot.process;
 
 import com.diagbot.biz.push.entity.Item;
-import com.diagbot.dto.BillMsg;
-import com.diagbot.dto.BillNeoDTO;
-import com.diagbot.dto.BillNeoMaxDTO;
-import com.diagbot.dto.IndicationDTO;
-import com.diagbot.dto.WordCrfDTO;
+import com.diagbot.dto.*;
 import com.diagbot.enums.NeoEnum;
 import com.diagbot.facade.NeoFacade;
-import com.diagbot.model.entity.*;
+import com.diagbot.model.entity.Clinical;
+import com.diagbot.model.entity.Operation;
 import com.diagbot.model.label.*;
-import com.diagbot.rule.AgeRule;
-import com.diagbot.rule.CommonRule;
-import com.diagbot.rule.DrugRule;
-import com.diagbot.rule.GroupRule;
-import com.diagbot.rule.LisRule;
-import com.diagbot.rule.PacsRule;
-import com.diagbot.rule.SexRule;
-import com.diagbot.rule.VitalRule;
+import com.diagbot.rule.*;
 import com.diagbot.util.BeanUtil;
 import com.diagbot.util.ListUtil;
-import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
@@ -131,7 +120,7 @@ public class BillProcess {
 
         //辅助检查描述
         PacsLabel pacsLabel = wordCrfDTO.getPacsLabel();
-        List<Item> pacsNewList = new ArrayList<>();
+        List<Item> pacsDescList = new ArrayList<>();
         pacsLabel.getPacsNewList().stream().filter(x -> ListUtil.isNotEmpty(x.getPacsResults()) || ListUtil.isNotEmpty(x.getDisease())).forEach(
                 x ->{
                     List<String> pacsResults = x.getPacsResults().stream().map(pacr -> pacr.getStandName()).collect(Collectors.toList());
@@ -141,7 +130,7 @@ public class BillProcess {
                         Item item = new Item();
                         item.setName(z);
                         item.setUniqueName(z);
-                        pacsNewList.add(item);
+                        pacsDescList.add(item);
                     });
                 }
         );
@@ -191,13 +180,13 @@ public class BillProcess {
             DrugRule.compareDrugWithBill(bill.getAllergicmeds(), pastLabel.getAllergyMedicines(), bill, billMsgList, drugMap, NeoEnum.allergicmeds.getName());
 
             // 服用药品(现病史一般情况后的药品)
-            DrugRule.compareDrugWithBill(bill.getOralmeds(), takeMedicine(presentLabel), bill, billMsgList, drugMap, NeoEnum.oralmeds.getName());
+            DrugRule.compareDrugWithBill(bill.getOralmeds(), presentLabel.getTakeMedicine(), bill, billMsgList, drugMap, NeoEnum.oralmeds.getName());
 
             // 禁用人群
             GroupRule.compareGroupWithBill(wordCrfDTO, bill, billMsgList, NeoEnum.group.getName());
 
             // 禁用辅助检查描述
-            CommonRule.compareItemWithBill(bill.getPacsDesc(), pacsNewList, bill, billMsgList, NeoEnum.pacsDesc.getName());
+            CommonRule.compareItemWithBill(bill.getPacsDesc(), pacsDescList, bill, billMsgList, NeoEnum.pacsDesc.getName());
         }
 
         // 24小时重复开单项
@@ -205,28 +194,4 @@ public class BillProcess {
         indicationDTO.setBillMsgList(billMsgList);
     }
 
-    /**
-     * 一般情况以后的药品
-     * @param presentLabel
-     */
-    public List<Medicine> takeMedicine(PresentLabel presentLabel){
-        List<Medicine> takems = new ArrayList<>();
-        List<GeneralDesc> generals = presentLabel.getGenerals();
-        List<Medicine> medicines = presentLabel.getMedicines();
-        if (generals.size() > 0) {
-            String presentText = presentLabel.getText();
-            if (StringUtils.isNotBlank(presentText) && medicines != null && medicines.size() > 0) {
-                String lastGeneral = generals.get(generals.size() - 1).getName();
-                int lastGeneralIndex = presentText.lastIndexOf(lastGeneral);
-                for (Medicine medicine : medicines) {
-                    /* 现病史中一般情况之后的药品名称,并且不包含不详 */
-                    int medicine_index = presentText.indexOf(medicine.getName());
-                    if (medicine_index > lastGeneralIndex && !medicine.getName().contains("不详")) {
-                        takems.add(medicine);
-                    }
-                }
-            }
-        }
-        return takems;
-    }
 }

+ 21 - 134
src/main/java/com/diagbot/rule/CommonRule.java

@@ -1,8 +1,5 @@
 package com.diagbot.rule;
 
-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.BillMsg;
 import com.diagbot.dto.BillNeoMaxDTO;
 import com.diagbot.dto.NodeNeoDTO;
@@ -76,11 +73,11 @@ public class CommonRule {
     public static <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)) {
-            List<String> dl = neoList.stream().map(x -> x.getName()).collect(Collectors.toList());
+            List<String> neoName = neoList.stream().map(x -> x.getName()).collect(Collectors.toList());
             for (T d : input) {
                 String c = (String) CoreUtil.getFieldValue(d, "uniqueName");
                 String c_name = (String) CoreUtil.getFieldValue(d, "name");
-                if (StringUtils.isNotBlank(c) && dl.contains(c)) {
+                if (StringUtils.isNotBlank(c) && neoName.contains(c)) {
                     old_stand.put(c_name, c);
                 }
             }
@@ -102,127 +99,13 @@ public class CommonRule {
      * @param billMsgList
      */
     public static void repeat24Bill(WordCrfDTO wordCrfDTO, List<BillMsg> billMsgList) {
-        repeat24BillWithLisType(billMsgList, wordCrfDTO.getLisOrder(), TypeEnum.lis.getName()); // 化验重复开单
-        repeat24BillWithPacsType(billMsgList, wordCrfDTO.getPacsOrder(), TypeEnum.pacs.getName()); // 辅检重复开单
+        repeat24BillWithType(billMsgList, wordCrfDTO.getLisOrder(), TypeEnum.lis.getName()); // 化验重复开单
+        repeat24BillWithType(billMsgList, wordCrfDTO.getPacsOrder(), TypeEnum.pacs.getName()); // 辅检重复开单
         repeat24BillWithType(billMsgList, wordCrfDTO.getDrugOrder(), TypeEnum.drug.getName()); // 药品重复开单
         repeat24BillWithType(billMsgList, wordCrfDTO.getOperationOrder(), TypeEnum.operation.getName()); // 手术重复开单
+        repeat24BillWithType(billMsgList, wordCrfDTO.getTransfusionOrder(), TypeEnum.transfusion.getName()); // 输血重复开单
     }
 
-    /**
-     * 24小时重复开单入口(化验)
-     *
-     * @param billMsgList
-     * @param itemList
-     * @param type
-     */
-    public static <T> void repeat24BillWithPacsType(List<BillMsg> billMsgList, List<Pacs> itemList, String type) {
-        if (ListUtil.isEmpty(itemList)) {
-            return ;
-        }
-        Map<String, List<Pacs>> map = EntityUtil.makeEntityListMap(itemList, "uniqueName");
-        for (String key : map.keySet()) {
-            List<Pacs> items = map.get(key);
-
-            // 个数大于2个才比较
-            if (ListUtil.isNotEmpty(items) && items.size() > 1) {
-                // items 按照时间排序
-                Collections.sort(items, new Comparator<Pacs>() {
-                    @Override
-                    public int compare(Pacs o1, Pacs o2) {
-                        if (StringUtil.isBlank(o1.getDateValue()) || StringUtil.isBlank(o2.getDateValue())) {
-                            return -1;
-                        } else {
-                            return o1.getDateValue().compareTo(o2.getDateValue());
-                        }
-                    }
-                });
-
-                // 比较时间是否在24小时内
-                List<Date> dateList = new ArrayList<>();
-                for (Pacs it : items) {
-                    if (StringUtil.isNotBlank(it.getDateValue())) {
-                        Date cur = CatalogueUtil.parseStringDate(it.getDateValue());
-                        // 如果为null,说明日期格式出错,不比较
-                        if (cur != null) {
-                            if (ListUtil.isNotEmpty(dateList)) {
-                                Date last = dateList.get(dateList.size() - 1);
-                                if (!CatalogueUtil.compareTime(last, cur, 60L * 24)) {
-                                    BillMsg commonBillMsg = CoreUtil.getBillMsg24Repeat(
-                                            it.getName(), it.getUniqueName(),
-                                            it.getName(), type);
-                                    billMsgList.add(commonBillMsg);
-                                    break;
-                                } else {
-                                    dateList.add(cur);
-                                }
-                            } else {
-                                dateList.add(cur);
-                            }
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-    /**
-     * 24小时重复开单入口(化验)
-     *
-     * @param billMsgList
-     * @param itemList
-     * @param type
-     */
-    public static <T> void repeat24BillWithLisType(List<BillMsg> billMsgList, List<Lis> itemList, String type) {
-        if (ListUtil.isEmpty(itemList)) {
-            return ;
-        }
-        Map<String, List<Lis>> map = EntityUtil.makeEntityListMap(itemList, "uniqueName");
-        for (String key : map.keySet()) {
-            List<Lis> items = map.get(key);
-
-            // 个数大于2个才比较
-            if (ListUtil.isNotEmpty(items) && items.size() > 1) {
-                // items 按照时间排序
-                Collections.sort(items, new Comparator<Lis>() {
-                    @Override
-                    public int compare(Lis o1, Lis o2) {
-                        if (StringUtil.isBlank(o1.getDateValue()) || StringUtil.isBlank(o2.getDateValue())) {
-                            return -1;
-                        } else {
-                            return o1.getDateValue().compareTo(o2.getDateValue());
-                        }
-                    }
-                });
-
-                // 比较时间是否在24小时内
-                List<Date> dateList = new ArrayList<>();
-                for (Lis it : items) {
-                    if (StringUtil.isNotBlank(it.getDateValue())) {
-                        Date cur = CatalogueUtil.parseStringDate(it.getDateValue());
-                        // 如果为null,说明日期格式出错,不比较
-                        if (cur != null) {
-                            if (ListUtil.isNotEmpty(dateList)) {
-                                Date last = dateList.get(dateList.size() - 1);
-                                if (!CatalogueUtil.compareTime(last, cur, 60L * 24)) {
-                                    BillMsg commonBillMsg = CoreUtil.getBillMsg24Repeat(
-                                            it.getName(), it.getUniqueName(),
-                                            it.getName(), type);
-                                    billMsgList.add(commonBillMsg);
-                                    break;
-                                } else {
-                                    dateList.add(cur);
-                                }
-                            } else {
-                                dateList.add(cur);
-                            }
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-
     /**
      * 24小时重复开单入口
      *
@@ -230,41 +113,45 @@ public class CommonRule {
      * @param itemList
      * @param type
      */
-    public static void repeat24BillWithType(List<BillMsg> billMsgList, List<Item> itemList, String type) {
+    public static <T> void repeat24BillWithType(List<BillMsg> billMsgList, List<T> itemList, String type) {
         if (ListUtil.isEmpty(itemList)) {
             return ;
         }
-        Map<String, List<Item>> map = EntityUtil.makeEntityListMap(itemList, "uniqueName");
+        Map<String, List<T>> map = EntityUtil.makeEntityListMap(itemList, "uniqueName");
         for (String key : map.keySet()) {
-            List<Item> items = map.get(key);
+            List<T> items = map.get(key);
 
             // 个数大于2个才比较
             if (ListUtil.isNotEmpty(items) && items.size() > 1) {
                 // items 按照时间排序
-                Collections.sort(items, new Comparator<Item>() {
+                Collections.sort(items, new Comparator<T>() {
                     @Override
-                    public int compare(Item o1, Item o2) {
-                        if (StringUtil.isBlank(o1.getDateValue()) || StringUtil.isBlank(o2.getDateValue())) {
+                    public int compare(T o1, T o2) {
+                        String o1Str = (String)CoreUtil.getFieldValue(o1, "dateValue");
+                        String o2Str = (String)CoreUtil.getFieldValue(o2, "dateValue");
+                        if (StringUtil.isBlank(o1Str) || StringUtil.isBlank(o2Str)) {
                             return -1;
                         } else {
-                            return o1.getDateValue().compareTo(o2.getDateValue());
+                            return o1Str.compareTo(o2Str);
                         }
                     }
                 });
 
                 // 比较时间是否在24小时内
                 List<Date> dateList = new ArrayList<>();
-                for (Item it : items) {
-                    if (StringUtil.isNotBlank(it.getDateValue())) {
-                        Date cur = CatalogueUtil.parseStringDate(it.getDateValue());
+                for (T it : items) {
+                    String dateValue = (String)CoreUtil.getFieldValue(it, "dateValue");
+                    if (StringUtil.isNotBlank(dateValue)) {
+                        Date cur = CatalogueUtil.parseStringDate(dateValue);
                         // 如果为null,说明日期格式出错,不比较
                         if (cur != null) {
                             if (ListUtil.isNotEmpty(dateList)) {
                                 Date last = dateList.get(dateList.size() - 1);
                                 if (!CatalogueUtil.compareTime(last, cur, 60L * 24)) {
+                                    String name = (String)CoreUtil.getFieldValue(it, "name");
+                                    String uniqueName = (String)CoreUtil.getFieldValue(it, "uniqueName");
                                     BillMsg commonBillMsg = CoreUtil.getBillMsg24Repeat(
-                                            it.getName(), it.getUniqueName(),
-                                            it.getName(), type);
+                                            name, uniqueName, name, type);
                                     billMsgList.add(commonBillMsg);
                                     break;
                                 } else {

+ 19 - 55
src/main/java/com/diagbot/rule/DrugRule.java

@@ -6,13 +6,13 @@ import com.diagbot.dto.NodeNeoDTO;
 import com.diagbot.model.entity.Negative;
 import com.diagbot.util.CoreUtil;
 import com.diagbot.util.ListUtil;
+import com.diagbot.util.StringUtil;
 import org.apache.commons.lang3.StringUtils;
 
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.stream.Collectors;
 
 /**
  * @description: 实验室检查和辅助检查规则
@@ -22,70 +22,34 @@ import java.util.stream.Collectors;
 public class DrugRule {
 
     /**
-     * 比较药品是否存在(图谱返回的是药品通用名,直接比较)
+     * 比较药品是否存在(图谱返回药品通用名或者药品分类,如果返回的是药品分类,再从redis获取药品通用名)
      *
-     * @param drugLises
-     * @param inputLises
+     * @param drugList
+     * @param inputList
      * @return
      */
-    public static <T> void compareDrugWithBill(List<NodeNeoDTO> drugLises, List<T> inputLises, BillNeoMaxDTO billNeoMaxDTO,
+    public static <T> void compareDrugWithBill(List<NodeNeoDTO> drugList, List<T> inputList, BillNeoMaxDTO billNeoMaxDTO,
                                                List<BillMsg> billMsgList, Map<String, List<String>> drugMap, String type) {
         Map<String, String> old_stand = new HashMap<>();
-        if (ListUtil.isNotEmpty(drugLises) && ListUtil.isNotEmpty(inputLises)) {
-            List<String> allDrug = drugLises.stream().map(x -> x.getName()).collect(Collectors.toList());
-            for (T d : inputLises) {
-                Negative val = (Negative) CoreUtil.getFieldValue(d, "negative");
-                if (val == null) {
-                    String c = (String) CoreUtil.getFieldValue(d, "standName");
-                    String c_name = (String) CoreUtil.getFieldValue(d, "name");
-                    if (StringUtils.isNotBlank(c) && allDrug.contains(c)) {
-                        old_stand.put(c_name, c);
-                    }
-                }
-            }
-            if (old_stand.size() > 0) {
-                for (Map.Entry<String, String> d : old_stand.entrySet()) {
-                    String message = "";
-                    if ("禁忌过敏药品".equals(type)) {
-                        message = d.getKey() + "过敏";
-                    } else {
-                        message = "已开" + d.getKey();
+        if (ListUtil.isNotEmpty(drugList) && ListUtil.isNotEmpty(inputList)) {
+            List<String> allDrug = new ArrayList<>();
+            for (NodeNeoDTO nodeNeoDTO : drugList) {
+                if (StringUtil.isBlank(nodeNeoDTO.getTermtype()) || "药品".equals(nodeNeoDTO.getTermtype())) {
+                    allDrug.add(nodeNeoDTO.getName());
+                } else if ("药品分类".equals(nodeNeoDTO.getTermtype())){
+                    String drugType = nodeNeoDTO.getName();
+                    if (drugMap.get(drugType) != null) {
+                        allDrug.addAll(drugMap.get(drugType));
                     }
-                    BillMsg commonBillMsg = CoreUtil.getCommonBillMsg(
-                            billNeoMaxDTO.getOrderName(), billNeoMaxDTO.getOrderStandName(),
-                            message, type);
-                    billMsgList.add(commonBillMsg);
-                }
-            }
-        }
-    }
-
-
-    /**
-     * 比较药品是否存在(图谱返回的是药品大类,需要从缓存中获取大类对应的药品名称)
-     *
-     * @param drugLises
-     * @param inputLises
-     * @return
-     */
-    public static <T> void compareDrugWithBillWithType(List<NodeNeoDTO> drugLises, List<T> inputLises, BillNeoMaxDTO billNeoMaxDTO,
-                                               List<BillMsg> billMsgList, Map<String, List<String>> drugMap, String type) {
-        Map<String, String> old_stand = new HashMap<>();
-        if (ListUtil.isNotEmpty(drugLises) && ListUtil.isNotEmpty(inputLises)) {
-            List<String> drugType = drugLises.stream().map(x -> x.getName()).collect(Collectors.toList());
-            List<String> allDrug = new ArrayList<>(); // 所有的药品名称
-            for (String drugT : drugType) {
-                if (drugMap.get(drugT) != null) {
-                    allDrug.addAll(drugMap.get(drugT));
                 }
             }
-            for (T d : inputLises) {
+            for (T d : inputList) {
                 Negative val = (Negative) CoreUtil.getFieldValue(d, "negative");
                 if (val == null) {
-                    String c = (String) CoreUtil.getFieldValue(d, "standName");
-                    String c_name = (String) CoreUtil.getFieldValue(d, "name");
-                    if (StringUtils.isNotBlank(c) && allDrug.contains(c)) {
-                        old_stand.put(c_name, c);
+                    String standName = (String) CoreUtil.getFieldValue(d, "standName");
+                    String name = (String) CoreUtil.getFieldValue(d, "name");
+                    if (StringUtils.isNotBlank(standName) && allDrug.contains(standName)) {
+                        old_stand.put(name, standName);
                     }
                 }
             }

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

@@ -9,6 +9,8 @@ import com.diagbot.model.entity.Vital;
 import com.diagbot.model.label.VitalLabel;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
 
 import java.lang.reflect.Field;
 import java.math.BigDecimal;
@@ -23,8 +25,16 @@ import java.util.Map;
  * @time: 2020/7/30 15:18
  */
 @Slf4j
+@Component
 public class CoreUtil {
 
+    public static Boolean debugFlag;
+
+    @Value("${debugFlag}")
+    public void setDebugFlag(Boolean debugFlag) {
+        CoreUtil.debugFlag = debugFlag;
+    }
+
     /**
      * 将列表中属性对应的值以list形式返回
      *
@@ -603,6 +613,18 @@ public class CoreUtil {
         debugMap.put(msg,  + (end - start) / 1000.0 + "秒");
     }
 
+    /**
+     * 输出调试信息
+     *
+     * @param msg
+     * @param debugMap
+     */
+    public static void getDebugObject(String msg, Map<String, Object> debugMap, Object obj) {
+        if (debugFlag) {
+            debugMap.put(msg, obj);
+        }
+    }
+
     /**
      * 输出调试信息
      *

+ 1 - 1
src/main/java/com/diagbot/web/EntityController.java

@@ -18,7 +18,7 @@ import java.util.Map;
  * @time: 2018/8/30 10:12
  */
 @RestController
-@RequestMapping("/entity")
+@RequestMapping("/graph/entity")
 @Api(value = "实体API", tags = { "实体API" })
 @SuppressWarnings("unchecked")
 public class EntityController {

+ 3 - 1
src/main/resources/application-dev.yml

@@ -153,4 +153,6 @@ ChiefPresentSimilarity:
 
 StandConvert:
   url: http://192.168.3.150:23232
-  rate: 0.9
+  rate: 0.9
+
+debugFlag: true

+ 3 - 1
src/main/resources/application-local.yml

@@ -153,4 +153,6 @@ ChiefPresentSimilarity:
 
 StandConvert:
   url: http://192.168.3.150:23232
-  rate: 0.9
+  rate: 0.9
+
+debugFlag: true

+ 3 - 1
src/main/resources/application-pre.yml

@@ -153,4 +153,6 @@ ChiefPresentSimilarity:
 
 StandConvert:
   url: http://192.168.3.150:23232
-  rate: 0.9
+  rate: 0.9
+
+debugFlag: true

+ 2 - 0
src/main/resources/application-pro.yml

@@ -156,3 +156,5 @@ ChiefPresentSimilarity:
 StandConvert:
   url: http://192.168.3.150:23232
   rate: 0.9
+
+debugFlag: true

+ 3 - 1
src/main/resources/application-test.yml

@@ -153,4 +153,6 @@ ChiefPresentSimilarity:
 
 StandConvert:
   url: http://192.168.3.150:23232
-  rate: 0.9
+  rate: 0.9
+
+debugFlag: true