Просмотр исходного кода

Merge remote-tracking branch 'origin/master'

MarkHuang 4 лет назад
Родитель
Сommit
fe5918aa83

+ 2 - 0
src/main/java/com/diagbot/dto/IndicationDTO.java

@@ -20,6 +20,8 @@ public class IndicationDTO {
     private List<BillMsg> billMsgList = new ArrayList<>();
     // 高危药品、手术
     private List<BillMsg> highRiskList = new ArrayList<>();
+    // 特殊指标提醒
+    private List<BillMsg> specialList = new ArrayList<>();
     // 记录调试信息
     private Map<String, Object> debug = new LinkedHashMap<>();
 }

+ 2 - 0
src/main/java/com/diagbot/dto/PushDTO.java

@@ -31,4 +31,6 @@ public class PushDTO {
     private List<PushBaseDTO> complications = new ArrayList<>();
     //诊断
     private Map<String, List<PushBaseDTO>> dis;
+    //一般治疗
+    private List<TreatDTO> generaTreat = new ArrayList<>();
 }

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

@@ -0,0 +1,22 @@
+package com.diagbot.dto;
+
+import com.diagbot.biz.push.entity.Item;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+
+/**
+ * @Description:
+ * @author: gaodm
+ * @time: 2020/8/28 16:21
+ */
+@Getter
+@Setter
+public class TreatDTO extends Item {
+
+    /**
+     * 明细
+     */
+    List<TreatDetailDTO> details;
+}

+ 29 - 0
src/main/java/com/diagbot/dto/TreatDetailDTO.java

@@ -0,0 +1,29 @@
+package com.diagbot.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description:
+ * @author: gaodm
+ * @time: 2020/8/28 16:22
+ */
+@Getter
+@Setter
+public class TreatDetailDTO {
+    /**
+     * 提示明细标题
+     */
+    private String title;
+
+    /**
+     * 提示明细内容
+     */
+    private String content;
+
+    /**
+     * 纯文本
+     */
+    private String text;
+
+}

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

@@ -90,7 +90,7 @@ public class BeHospitalizedAI extends ModelAI {
                 presentLabel.setText(presentText);
                 presentLabel.setAiText(presentText);
                 wordCrfDTO.setPresentLabel(presentLabel);
-                putContent(crfContent, medicalTextType.get(7), presentText, Content.present);
+                putContent(crfContent, medicalTextType.get(5), presentText, Content.present);
             }
             /* 既往史 */
             if (StringUtils.isNotBlank(inputInfo.getPasts())) {

+ 5 - 2
src/main/java/com/diagbot/model/ai/model/EntityEnum.java

@@ -6,9 +6,9 @@ package com.diagbot.model.ai.model;
  * @Date: 2019/12/17 9:58
  */
 public enum EntityEnum {
-    CLINICAL_FEATURE("临床表现"), DIEASE("疾病名称"), BODY("身体部位"), SIGN("体征"), INDEX_VALUE("指标值"),
+    CLINICAL_FEATURE("临床表现"), DIEASE("疾病名称"), BODY("身体部位"), SIGN("体征"), INDEX_VALUE("指标值"),LABORATORY_BIG("实验室检查-套餐-细项-实验室检查"),
     LABORATORY("实验室检查"), LABORATORY_VALUE("实验室检查值"), AUXILIARY_EXAMINATION("辅助检查"), AUXILIARY_DESCRIPT("辅助检查描述"),
-    NEGATIVE("否定"), POSSIBLE("可能的"), TIME("时间"), CAUSE("诱因"), MODIFICATION("修饰"),
+    NEGATIVE("否定"), POSSIBLE("可能的"), LABORATORY_ITEM("实验室检查大项"), TIME("时间"), CAUSE("诱因"), MODIFICATION("修饰"),
     PROPERTY("性质"), DEGREE("程度"), AGGRAVATE("加重情况"), RELIEF("缓解情况"), BEHOSPITALIZEDWAY("入院途径"),
     TREND("趋势"), FREQUENCY("频率"), QUANTITY("数量"), SIZE("尺寸"), CURE("治疗"), TREAT_MENT("治疗或治疗目的"), DRUG("药物名称"),
     DOSE("药品剂量"), OPERATION("手术名称"), GENERAL("一般情况"), GENERAL_DESCRIPT("一般情况描述"),
@@ -67,6 +67,9 @@ public enum EntityEnum {
             case "实验室检查值":
                 entityEnum = EntityEnum.LABORATORY_VALUE;
                 break;
+            case "实验室检查大项":
+                entityEnum = EntityEnum.LABORATORY_ITEM;
+                break;
             case "辅助检查":
                 entityEnum = EntityEnum.AUXILIARY_EXAMINATION;
                 break;

+ 95 - 1
src/main/java/com/diagbot/model/ai/process/EntityProcessLis.java

@@ -1,21 +1,42 @@
 package com.diagbot.model.ai.process;
 
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.diagbot.model.ai.model.EntityEnum;
 import com.diagbot.model.entity.Lis;
 import com.diagbot.model.entity.LisValue;
 import com.diagbot.model.entity.PD;
+import com.diagbot.util.ListUtil;
 import org.apache.commons.lang3.StringUtils;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 public class EntityProcessLis extends EntityProcess {
     public List<Lis> extractEntity(JSONObject outputs) {
         List<Lis> lises = new ArrayList<>();
         Lis lis = null;
         List<Map<String, String>> lisEntityList = processJson(outputs, EntityEnum.LABORATORY.toString());
+        lisEntityList = lisEntityList.stream().filter(x -> x.containsKey(EntityEnum.LABORATORY_VALUE.toString())).collect(Collectors.toList());
+        Map<String, List<String>> detail_name = processLisoutputs(outputs);
+        if(ListUtil.isNotEmpty(lisEntityList)){
+            for (Map<String, String> c:lisEntityList) {
+                String detailName = c.get(EntityEnum.LABORATORY.toString());
+                String value = c.get(EntityEnum.LABORATORY_VALUE.toString());
+                for(Map.Entry<String, List<String>> f:detail_name.entrySet()){
+                    String name = f.getKey();
+                    List<String> details = f.getValue();
+                    if(details.contains(detailName)){
+                        c.put(EntityEnum.LABORATORY_ITEM.toString(),name);
+                        break;
+                    }
+                }
+            }
+        }
+        lisEntityList = lisEntityList.stream().filter(x -> x.containsKey(EntityEnum.LABORATORY_ITEM.toString())).collect(Collectors.toList());
         for (Map<String, String> lisEntityMap : lisEntityList) {
             if (StringUtils.isEmpty(lisEntityMap.get(EntityEnum.LABORATORY.toString()))) {
                 continue;
@@ -24,6 +45,11 @@ public class EntityProcessLis extends EntityProcess {
             for (String key : lisEntityMap.keySet()) {
                 String entity = StringUtils.isEmpty(lisEntityMap.get(key)) ? "" : lisEntityMap.get(key);
                 switch (EntityEnum.parseOfValue(key)) {
+                    case LABORATORY_ITEM:
+                        LisValue big = new LisValue();
+                        big.setName(entity);
+                        lis.setBigItem(big);
+                        break;
                     case LABORATORY:
                         lis.setName(entity);
                         break;
@@ -35,7 +61,7 @@ public class EntityProcessLis extends EntityProcess {
                         String value = entity;
                         String[] val_unit = new String[2];
                         if (value.trim().length() > 0) {
-                            val_unit = extract_digit(value);
+                            val_unit = extract_digit_new(value);
                         }
                         pd.setValue(val_unit[0]);
                         pd.setUnit(val_unit[1]);
@@ -47,4 +73,72 @@ public class EntityProcessLis extends EntityProcess {
         }
         return lises;
     }
+
+    private Map<String,List<String>> processLisoutputs(JSONObject outputs){
+        JSONObject annotation = outputs.getJSONObject("annotation");
+        JSONArray entitys = annotation.getJSONArray("T");
+        JSONArray relations = annotation.getJSONArray("R");
+        //把name为实验室检查的id和value拿出来
+        Map<Integer,String> id_value = new HashMap<>();
+
+        for (int i = 0; i < entitys.size(); i++) {
+            if (StringUtils.isEmpty(entitys.get(i).toString())) {
+                continue;
+            }
+            JSONObject entity = entitys.getJSONObject(i);
+            String name = entity.getString("name");
+            int id = entity.getIntValue("id");
+            String value = entity.getString("value");
+            if(EntityEnum.LABORATORY.toString().equals(name)){
+                id_value.put(id,value);
+            }
+        }
+        //遍历关系,把name为LABORATORY_BIG的from和to拿出来
+        Map<Integer,List<Integer>> from_to = new HashMap<>();
+        for (int i = 0; i < relations.size(); i++) {
+            if (StringUtils.isEmpty(relations.get(i).toString())) {
+                continue;
+            }
+            JSONObject relationsJSONObject = relations.getJSONObject(i);
+            if(EntityEnum.LABORATORY_BIG.toString().equals(relationsJSONObject.getString("name"))){
+                int from = relationsJSONObject.getIntValue("from");
+                int to = relationsJSONObject.getIntValue("to");
+                if(from_to.containsKey(from)){
+                    List<Integer> toList = from_to.get(from);
+                    toList.add(to);
+                    from_to.put(from,toList);
+                }else {
+                    List<Integer> toList = new ArrayList<>();
+                    toList.add(to);
+                    from_to.put(from,toList);
+                }
+            }
+        }
+        //组装化验的大小项
+        Map<String,List<String>> detail_name = new HashMap<>();
+        if(from_to.size()>0 && id_value.size()>0){
+            for(Map.Entry<Integer,List<Integer>> ft:from_to.entrySet()){
+                Integer big = ft.getKey();
+                List<Integer> details = ft.getValue();
+                for (Integer id:details) {
+                    if(id_value.containsKey(big)&& id_value.containsKey(id)){
+//                    detail_name.put(id_value.get(ft.getValue()),id_value.get(ft.getKey()));
+                        if(detail_name.containsKey(id_value.get(big))){
+                            List<String> detailList = detail_name.get(id_value.get(big));
+                            if(!detailList.contains(id_value.get(id))){
+                                detailList.add(id_value.get(id));
+                            }
+                            detail_name.put(id_value.get(big),detailList);
+                        }else {
+                            List<String> detailList = new ArrayList<>();
+                            detailList.add(id_value.get(id));
+                            detail_name.put(id_value.get(big),detailList);
+                        }
+                    }
+                }
+
+            }
+        }
+        return detail_name;
+    }
 }

+ 1 - 0
src/main/java/com/diagbot/model/entity/Lis.java

@@ -13,6 +13,7 @@ import lombok.Setter;
 @Getter
 @Setter
 public class Lis extends General {
+    private LisValue bigItem;//化验大项
     private LisValue lisValue;
     private PD pd;
 

+ 9 - 4
src/main/java/com/diagbot/process/BillProcess.java

@@ -1,5 +1,6 @@
 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;
@@ -8,7 +9,6 @@ import com.diagbot.dto.WordCrfDTO;
 import com.diagbot.enums.NeoEnum;
 import com.diagbot.facade.NeoFacade;
 import com.diagbot.model.entity.Clinical;
-import com.diagbot.model.entity.Diag;
 import com.diagbot.model.entity.GeneralDesc;
 import com.diagbot.model.entity.Medicine;
 import com.diagbot.model.entity.Operation;
@@ -56,6 +56,8 @@ public class BillProcess {
                 BeanUtil.copyProperties(billNeoDTO.getLisBillNeoDTO(), billNeoMaxDTO);
             } else if (billNeoDTO.getPacsBillNeoDTO() != null) {
                 BeanUtil.copyProperties(billNeoDTO.getPacsBillNeoDTO(), billNeoMaxDTO);
+            } else if (billNeoDTO.getOperationBillNeoDTO() != null) {
+                BeanUtil.copyProperties(billNeoDTO.getOperationBillNeoDTO(), billNeoMaxDTO);
             }
             billNeoMaxDTO.setOrderName(billNeoDTO.getName()); // 开单名称
             billNeoMaxDTO.setOrderStandName(billNeoDTO.getStandname()); // 开单标准名称
@@ -112,7 +114,7 @@ public class BillProcess {
             // }
             // 测试数据结束
 
-            // System.out.println(billNeoMaxDTO);
+            System.out.println(billNeoMaxDTO);
             billNeoMaxDTOList.add(billNeoMaxDTO);
         }
         processRule(billNeoMaxDTOList, wordCrfDTO, res);
@@ -131,7 +133,7 @@ public class BillProcess {
         List<Vital> vitals = wordCrfDTO.getVitalLabel().getVitals();
 
         // 诊断数据
-        List<Diag> diags = diagLabel.getDiags();
+        List<Item> diags = wordCrfDTO.getDiag();
 
         // 手术数据
         List<Operation> operations_present = presentLabel.getOperations();
@@ -157,7 +159,7 @@ public class BillProcess {
             AgeRule.compareAgeWithBill(wordCrfDTO, bill, billMsgList, NeoEnum.ageNeoDTO.getName());
 
             // 诊断
-            CommonRule.compareNameWithBill(bill.getDisease(), diags, bill, billMsgList, NeoEnum.disease.getName());
+            CommonRule.compareItemWithBill(bill.getDisease(), diags, bill, billMsgList, NeoEnum.disease.getName());
 
             // 化验
             LisRule.compareLisWithBill(wordCrfDTO.getLis(), bill, billMsgList, NeoEnum.lis.getName());
@@ -179,6 +181,9 @@ public class BillProcess {
 
             // 服用药品(现病史一般情况后的药品)
             DrugRule.compareDrugWithBill(bill.getOralmeds(), takeMedicine(presentLabel), bill, billMsgList, drugMap, NeoEnum.oralmeds.getName());
+
+            // 禁用人群
+            // GroupRule.compareGroupWithBill(wordCrfDTO, bill, billMsgList, NeoEnum.group.getName());
         }
 
         // 24小时重复开单项

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

@@ -37,6 +37,7 @@ public class CommonRule {
      *
      * @param neoList 图谱结构
      * @param inputLises 界面元素
+     * @param billNeoMaxDTO 开单项名称,开单项标准名称
      * @return
      */
     public static <T> void compareNameWithBill(List<NodeNeoDTO> neoList, List<T> inputLises, BillNeoMaxDTO billNeoMaxDTO, List<BillMsg> billMsgList, String type) {
@@ -64,6 +65,36 @@ public class CommonRule {
         }
     }
 
+    /**
+     * 比较界面元素是否在图谱中存在(匹配名称)
+     *
+     * @param neoList 图谱结构
+     * @param input 界面元素
+     * @param billNeoMaxDTO 开单项名称,开单项标准名称
+     * @return
+     */
+    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());
+            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)) {
+                    old_stand.put(c_name, c);
+                }
+            }
+            if (old_stand.size() > 0) {
+                for (String key : old_stand.keySet()) {
+                    BillMsg commonBillMsg = CoreUtil.getCommonBillMsg(
+                            billNeoMaxDTO.getOrderName(), billNeoMaxDTO.getOrderStandName(),
+                            key, type);
+                    billMsgList.add(commonBillMsg);
+                }
+            }
+        }
+    }
+
     /**
      * 24小时重复开单总入口
      *

+ 28 - 0
src/main/java/com/diagbot/rule/GroupRule.java

@@ -0,0 +1,28 @@
+package com.diagbot.rule;
+
+import com.diagbot.dto.BillMsg;
+import com.diagbot.dto.BillNeoMaxDTO;
+import com.diagbot.dto.NodeNeoDTO;
+import com.diagbot.dto.WordCrfDTO;
+
+import java.util.List;
+
+/**
+ * @description: 人群规则
+ * @author: zhoutg
+ * @time: 2020/8/3 14:47
+ */
+public class GroupRule {
+
+    /**
+     * 年龄比较
+     *
+     * @param wordCrfDTO
+     * @param billNeoMaxDTO
+     * @return
+     */
+    public static void compareGroupWithBill(WordCrfDTO wordCrfDTO, BillNeoMaxDTO billNeoMaxDTO, List<BillMsg> billMsgList, String type) {
+        NodeNeoDTO ageNeoDTO = billNeoMaxDTO.getAgeNeoDTO();
+        // TODO 妊娠禁忌
+    }
+}

+ 1 - 1
src/main/java/com/diagbot/vo/IndicationPushVO.java

@@ -16,7 +16,7 @@ import java.util.List;
 @Setter
 public class IndicationPushVO extends SearchData {
     /**
-     * 规则类型(1:危急值提醒,2:开单合理项,3:高危药品、手术
+     * 规则类型(1:危急值提醒,2:开单合理项,3:高危药品、手术,4:特殊指标提醒
      */
     @NotBlank(message = "ruleType不能为空")
     private String ruleType = "";

+ 1 - 1
src/main/java/com/diagbot/vo/PushVO.java

@@ -12,7 +12,7 @@ import lombok.Setter;
 @Setter
 public class PushVO extends SearchData {
     /**
-     * 推理类型(1:症状,4:查体结果,5:检验,6:检查,7:诊断,8:药品,9:手术)
+     * 推理类型(1:症状,4:查体结果,5:检验,6:检查,7:诊断,8:药品,9:手术,10:一般治疗
      */
     private String featureType = "";
 }

+ 2 - 2
src/main/java/com/diagbot/web/CoreController.java

@@ -33,14 +33,14 @@ public class CoreController {
     @Autowired
     private PushFacade pushFacade;
 
-    @ApiOperation(value = "开单合理性API[zhoutg]", notes = "ruleType(1:危急值提醒,2:开单合理项,3:高危药品、手术)")
+    @ApiOperation(value = "开单合理性API[zhoutg]", notes = "ruleType(1:危急值提醒,2:开单合理项,3:高危药品、手术,4:特殊指标提醒)")
     @PostMapping("/indication")
     public RespDTO<IndicationDTO> indication(@Valid @RequestBody IndicationPushVO indicationPushVO) {
         IndicationDTO indicationDTO = indicationFacade.indicationFac(indicationPushVO);
         return RespDTO.onSuc(indicationDTO);
     }
 
-     @ApiOperation(value = "推送API[zhoutg]", notes = "featureType 类型(多选必填),1:症状,4:查体结果,5:检验,6:检查,7:诊断,8:药品,9:手术")
+     @ApiOperation(value = "推送API[zhoutg]", notes = "featureType 类型(多选必填),1:症状,4:查体结果,5:检验,6:检查,7:诊断,8:药品,9:手术,10:一般治疗")
      @PostMapping("/push")
      public RespDTO<PushDTO> push(@RequestBody PushVO pushVo) {
          PushDTO pushDTO = pushFacade.pushFac(pushVo);