Browse Source

推送量表

zhoutg 4 years ago
parent
commit
99812e766e

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

@@ -30,6 +30,8 @@ public class PushDTO {
     private List<PushBaseDTO> medicines = Lists.newArrayList();
     // 并发症
     private List<PushBaseDTO> complications = Lists.newArrayList();
+    // 量表
+    private List<PushBaseDTO> scale = Lists.newArrayList();
     //诊断
     private Map<String, List<PushBaseDTO>> dis = new LinkedHashMap<>();
     //一般治疗

+ 1 - 0
src/main/java/com/diagbot/enums/RelationshipEnum.java

@@ -18,6 +18,7 @@ public enum RelationshipEnum implements KeyedNamed {
     R506(506,"疾病相关药物治疗"),
     R507(507,"疾病相关手术治疗"),
     R508(508,"疾病相关鉴别诊断"),
+    R509(509,"疾病相关量表"),
     R600(600,"相关子类");
 
     @Setter

+ 11 - 0
src/main/java/com/diagbot/process/PushProcess.java

@@ -683,6 +683,14 @@ public class PushProcess {
                 pushDTO.setOperations(generatePushBaseDTO(list, length)); // 放入对象返回
             }
         }
+        // 量表
+        if (ruleTypeList.contains("11")) {
+            if (map.get(LexiconEnum.Scale.getKey()) != null) {
+                List<String> list = map.get(LexiconEnum.Scale.getKey()).stream().map(r -> r.getSonName()).collect(Collectors.toList());
+                // CoreUtil.removeRepeat(list, filterMap.get(StandConvertEnum.operation.toString())); // 过滤界面已有
+                pushDTO.setScale(generatePushBaseDTO(list, length)); // 放入对象返回
+            }
+        }
     }
 
     /**
@@ -757,6 +765,9 @@ public class PushProcess {
             if (ruleTypeList.contains("9")) {
                 relationType.add(RelationshipEnum.R507.getKey()); // 手术
             }
+            if (ruleTypeList.contains("11")) {
+                relationType.add(RelationshipEnum.R509.getKey()); // 量表
+            }
             reverseVO.setRelationType(relationType);
         }
         return reverseVO;

+ 9 - 10
src/main/java/com/diagbot/util/CoreUtil.java

@@ -30,7 +30,7 @@ import java.util.Set;
 import java.util.stream.Collectors;
 
 /**
- * @description:
+ * @description: core工具类
  * @author: zhoutg
  * @time: 2020/7/30 15:18
  */
@@ -114,7 +114,6 @@ public class CoreUtil {
         } catch (Exception e) {
             e.printStackTrace();
         }
-
     }
 
     /**
@@ -128,7 +127,6 @@ public class CoreUtil {
         return setPropertyList(list, "name", "standName", map);
     }
 
-
     /**
      * 循环向上转型, 获取对象的 DeclaredField
      *
@@ -138,9 +136,7 @@ public class CoreUtil {
      */
     public static Field getDeclaredField(Object object, String fieldName) {
         Field field = null;
-
         Class<?> clazz = object.getClass();
-
         for (; clazz != Object.class; clazz = clazz.getSuperclass()) {
             try {
                 field = clazz.getDeclaredField(fieldName);
@@ -150,12 +146,11 @@ public class CoreUtil {
                 //如果这里的异常打印或者往外抛,则就不会执行clazz = clazz.getSuperclass(),最后就不会进入到父类中了
             }
         }
-
         return null;
     }
 
     /**
-     * 直接读取对象的属性值, 忽略 private/protected 修饰符, 也不经过 getter
+     * 获取对象的属性值,直接使用getDeclaredFields()方法只能获取当前类声明的字段,需要递归向上获取
      *
      * @param object    : 子类对象
      * @param fieldName : 父类中的属性名
@@ -165,6 +160,9 @@ public class CoreUtil {
         try {
             //根据 对象和属性名通过反射 调用上面的方法获取 Field对象
             Field field = getDeclaredField(object, fieldName);
+            if (field == null) {
+                return null;
+            }
             //抑制Java对其的检查
             field.setAccessible(true);
             //获取 object 中 field 所代表的属性值
@@ -186,10 +184,11 @@ public class CoreUtil {
     public static void setFieldValue(Object object, String name, String standName, Map<String, String> value) {
         //根据 对象和属性名通过反射 调用上面的方法获取 Field对象
         Field field = getDeclaredField(object, name);
-
-        //抑制Java对其的检查
+        if (field == null) {
+            return;
+        }
+        //抑制Java对其的检查field.setAccessible(true);
         field.setAccessible(true);
-
         try {
             //将 object 中 field 所代表的值 设置为 value
             String key = (String) field.get(object);

+ 114 - 0
src/main/java/com/diagbot/util/RegexUtil.java

@@ -0,0 +1,114 @@
+package com.diagbot.util;
+
+import com.google.common.collect.Lists;
+
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * @author zhoutg
+ * @Description: 正则匹配工具类
+ * @date 2020-12-16 11:28
+ */
+public class RegexUtil {
+
+    /**
+     * 判断字符串是否数值(正), ex: 10|20.1|0.83|10.|.99
+     *
+     * @param str
+     * @return
+     */
+    public static boolean isNumbers(String str) {
+        String regex = "[0-9]+|([0-9]+\\.)+[0-9]*|[0-9]*(\\.[0-9]+)+";
+        return str.matches(regex);
+    }
+
+    /**
+     * 是否有符合的数据(公共方法)
+     *
+     * @param content 文本内容
+     * @param regex   表达式
+     * @return
+     */
+    public static Boolean getRegexRes(String content, String regex) {
+        // 是否有符合的数据
+        try {
+            if (StringUtil.isBlank(content) || StringUtil.isBlank(regex)) {
+                return false;
+            }
+            Pattern pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
+            Matcher matcher = pattern.matcher(content);
+            if (matcher.find()) {
+                return true;
+            }
+        } catch (Exception e) {
+            return false;
+        }
+        return false;
+    }
+
+    /**
+     * 根据正则获取指定分组数据
+     *
+     * @param content  文本内容
+     * @param regex    表达式
+     * @param groupNum 获取第几个内容
+     * @return
+     */
+    public static String getRegexData(String content, String regex, Integer groupNum) {
+        // 获取符合的数据
+        try {
+            if (StringUtil.isBlank(content)) {
+                return "";
+            }
+            Pattern pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
+            Matcher matcher = pattern.matcher(content);
+            if (matcher.find() && matcher.groupCount() >= groupNum) {
+                return matcher.group(groupNum);
+            } else {
+                return "";
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return "";
+    }
+
+    /**
+     * 根据正则获取指定所有分组数据
+     *
+     * @param content
+     * @param regex
+     * @return
+     */
+    public static List<String> getRegexData(String content, String regex) {
+        List<String> list = Lists.newArrayList();
+        try {
+            if (StringUtil.isBlank(content)) {
+                return list;
+            }
+            Pattern pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
+            Matcher matcher = pattern.matcher(content);
+            if (matcher.find()) {
+                for (int i = 1; i <= matcher.groupCount(); i++) {
+                    list.add(matcher.group(i));
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return list;
+    }
+
+    /**
+     * 测试
+     *
+     * @param args
+     */
+    public static void main(String[] args) {
+        String regex1 = "(血小板计数)\\s*(\\d+(\\.\\d+)?)";
+        // System.out.println(getRegexData("血小板计数  30.3", regex1, 2));
+        System.out.println(getRegexData("血小板计数  30.3", regex1));
+    }
+}

+ 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:手术,10:一般治疗)
+     * 推理类型(1:症状,4:查体结果,5:检验,6:检查,7:诊断,8:药品,9:手术,10:一般治疗,11:量表
      */
     private String featureType = "";
 }

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

@@ -42,7 +42,7 @@ public class CoreController {
         return RespDTO.onSuc(indicationDTO);
     }
 
-    @ApiOperation(value = "推送API[zhoutg]", notes = "featureType 类型(多选必填),1:症状,4:查体结果,5:检验,6:检查,7:诊断,8:药品,9:手术,10:一般治疗")
+    @ApiOperation(value = "推送API[zhoutg]", notes = "featureType 类型(多选必填),1:症状,4:查体结果,5:检验,6:检查,7:诊断,8:药品,9:手术,10:一般治疗, 11:量表")
     @PostMapping("/push")
     public RespDTO<PushDTO> push(@RequestBody PushVO pushVo) {
         PushDTO pushDTO = pushFacade.pushFac(pushVo);