Browse Source

Merge branch 'dev/pacsRule20210915' into develop

gaodm 3 years ago
parent
commit
6c7ecf42bf

+ 2 - 1
src/main/java/com/diagbot/facade/CommonFacade.java

@@ -30,6 +30,7 @@ import com.diagbot.model.label.PastLabel;
 import com.diagbot.model.label.PresentLabel;
 import com.diagbot.model.label.VitalLabel;
 import com.diagbot.rule.CommonRule;
+import com.diagbot.util.AgeUtil;
 import com.diagbot.util.BeanUtil;
 import com.diagbot.util.CoreUtil;
 import com.diagbot.util.ListUtil;
@@ -120,7 +121,7 @@ public class CommonFacade {
         if (searchData.getAgeNum() != null) {
             wordCrfDTO.setAgeNum(searchData.getAgeNum());
         } else {
-            wordCrfDTO.setAgeNum(CoreUtil.convertAge(searchData.getAge()));
+            wordCrfDTO.setAgeNum(AgeUtil.convertAge(searchData.getAge()));
         }
         wordCrfDTO.setAge(searchData.getAge());
         wordCrfDTO.setSex(searchData.getSex());

+ 2 - 1
src/main/java/com/diagbot/facade/PushFacade.java

@@ -13,6 +13,7 @@ import com.diagbot.exception.CommonErrorCode;
 import com.diagbot.exception.CommonException;
 import com.diagbot.model.entity.Diag;
 import com.diagbot.process.PushProcess;
+import com.diagbot.util.AgeUtil;
 import com.diagbot.util.CoreUtil;
 import com.diagbot.util.ListUtil;
 import com.diagbot.util.ParamUtil;
@@ -101,7 +102,7 @@ public class PushFacade {
     public PushDTO processAggreate(PushVO pushVo) {
         // 年龄容错处理
         if (pushVo.getAgeNum() == null) {
-            pushVo.setAgeNum(CoreUtil.convertAge(pushVo.getAge()));
+            pushVo.setAgeNum(AgeUtil.convertAge(pushVo.getAge()));
         }
         PushDTO pushDTO = new PushDTO();
         pushDTO = this.pushFacIcss(pushVo);

+ 29 - 2
src/main/java/com/diagbot/model/ai/process/EntityProcessPacs.java

@@ -6,9 +6,12 @@ import com.diagbot.model.ai.model.EntityEnum;
 import com.diagbot.model.ai.model.Lemma;
 import com.diagbot.model.entity.BodyPart;
 import com.diagbot.model.entity.Modification;
+import com.diagbot.model.entity.PD;
 import com.diagbot.model.entity.Pacs;
+import com.diagbot.model.entity.PacsNum;
 import com.diagbot.model.label.PacsLabel;
 import com.diagbot.util.ListUtil;
+import com.diagbot.util.StringUtil;
 import com.google.common.collect.Lists;
 
 import java.util.ArrayList;
@@ -69,8 +72,6 @@ public class EntityProcessPacs extends EntityProcess {
         }
         pacsLabel.setPacsResults(pacsResults);
 
-
-
         // 辅检诊断
         List<Lemma> pacsDisease = createEntityTree(aiOut, EntityEnum.DIEASE.toString());
         List<Pacs> disList = new ArrayList<>();
@@ -81,5 +82,31 @@ public class EntityProcessPacs extends EntityProcess {
             disList.add(dis);
         }
         pacsLabel.setDisease(disList);
+
+        // 辅检结果添加数值型结构
+        List<PacsNum> pacsNumList = Lists.newArrayList();
+        List<Lemma> vitalLemmas = createEntityTree(aiOut, EntityEnum.SIGN.toString()); // 辅检中的体征结果
+        for (Lemma lemma : vitalLemmas) {
+            if (lemma.isHaveChildren()) {
+                for (Lemma relationLemma : lemma.getRelationLemmas()) {
+                    if (relationLemma.getProperty().equals(EntityEnum.INDEX_VALUE.toString())) { // 体征结果
+                        String value = relationLemma.getText();
+                        if (StringUtil.isNotBlank(value)) {
+                            PacsNum pacsNum = new PacsNum();
+                            pacsNum.setName(lemma.getText());
+                            pacsNum.setStandName(lemma.getText());
+                            PD pd = new PD();
+                            String[] val_unit = new String[2];
+                            val_unit = extract_digit_new(value);
+                            pd.setValue(val_unit[0]);
+                            pd.setUnit(val_unit[1]);
+                            pacsNum.setPd(pd);
+                            pacsNumList.add(pacsNum);
+                        }
+                    }
+                }
+            }
+            pacsLabel.setPacsNumList(pacsNumList);
+        }
     }
 }

+ 13 - 0
src/main/java/com/diagbot/model/entity/PacsNum.java

@@ -0,0 +1,13 @@
+package com.diagbot.model.entity;
+
+import lombok.Data;
+
+/**
+ * @description: 辅检数值型
+ * @author: zhoutg
+ * @date: 2021/9/15 9:31
+ */
+@Data
+public class PacsNum extends General{
+    private PD pd;
+}

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

@@ -3,6 +3,7 @@ package com.diagbot.model.label;
 
 import com.diagbot.biz.push.entity.Item;
 import com.diagbot.model.entity.Pacs;
+import com.diagbot.model.entity.PacsNum;
 import lombok.Getter;
 import lombok.Setter;
 
@@ -24,4 +25,5 @@ public class PacsLabel extends GeneralLabel {
     private List<Pacs> disease = new ArrayList<>(); // 辅检提取的诊断
     private List<Item> res = new ArrayList<>(); // 描述文本 + 诊断
     private List<Item> item = new ArrayList<>(); // 所有的辅检项目
+    private List<PacsNum> pacsNumList = new ArrayList<>(); // 辅检所有的数值项目
 }

+ 72 - 0
src/main/java/com/diagbot/process/OtherTipProcess.java

@@ -14,7 +14,10 @@ import com.diagbot.enums.RedisEnum;
 import com.diagbot.enums.RuleTypeEnum;
 import com.diagbot.enums.TypeEnum;
 import com.diagbot.facade.CommonFacade;
+import com.diagbot.model.entity.PD;
+import com.diagbot.model.entity.PacsNum;
 import com.diagbot.model.label.PacsLabel;
+import com.diagbot.rule.AgeRule;
 import com.diagbot.rule.CommonRule;
 import com.diagbot.rule.GroupRule;
 import com.diagbot.rule.LisRule;
@@ -29,6 +32,7 @@ import com.diagbot.util.StringUtil;
 import com.diagbot.vo.RuleVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
+
 import java.util.Date;
 import java.util.List;
 
@@ -52,6 +56,8 @@ public class OtherTipProcess {
     PacsRule pacsRule;
     @Autowired
     RedisUtil redisUtil;
+    @Autowired
+    AgeRule ageRule;
 
     /**
      * 处理业务——化验
@@ -106,6 +112,72 @@ public class OtherTipProcess {
                 }
             }
         }
+
+        // TODO 后期删除 辅检数值型匹配
+        List<PacsNum> pacsNumList = pacsLabel.getPacsNumList();
+        for (PacsNum pacsNum : pacsNumList) {
+            if ("心率".equals(pacsNum.getStandName())) {
+                PD pd = pacsNum.getPd();
+                if (pd != null && StringUtil.isNotBlank(pd.getValue())) {
+                    double v = Double.parseDouble(pd.getValue());
+                    String content = pacsNum.getStandName() + pd.getValue() + pd.getUnit();
+                    Double ageNum = wordCrfDTO.getAgeNum();
+                    Double min = null, max = null;
+                    String suggest = "";
+                    if (ageNum < 0.019) {
+                        min = 110D;
+                        max = 170D;
+                        suggest = "年龄0-6天心率正常值为110-170bpm";
+                    } else if (ageNum < 0.164) {
+                        min = 90D;
+                        max = 160D;
+                        suggest = "年龄7-59天心率正常值为90-160bpm";
+                    } else if (ageNum < 2) {
+                        min = 90D;
+                        max = 150D;
+                        suggest = "年龄2-23月心率正常值为90-150bpm";
+                    } else if (ageNum < 3) {
+                        min = 80D;
+                        max = 140D;
+                        suggest = "年龄2-3岁心率正常值为80-140bpm";
+                    } else if (ageNum < 6) {
+                        min = 80D;
+                        max = 130D;
+                        suggest = "年龄3-5岁心率正常值为80-130bpm";
+                    } else if (ageNum < 11) {
+                        min = 70D;
+                        max = 120D;
+                        suggest = "年龄6-10岁心率正常值为70-120bpm";
+                    } else if (ageNum < 18) {
+                        min = 60D;
+                        max = 120D;
+                        suggest = "年龄11-17岁心率正常值为60-120bpm";
+                    } else if (ageNum <= 150) {
+                        min = 60D;
+                        max = 110D;
+                        suggest = "年龄18-150岁心率正常值为60-110bpm";
+                    }
+                    int flag = compareValue(min, max, v);
+                    if (flag == 0) {
+                        String msg = String.format("该患者%s,%s", content, suggest);
+                        BillMsg billMsg = new BillMsg();
+                        billMsg.setMsg(msg);
+                        billMsg.setContent(content);
+                        otherList.add(billMsg);
+                    }
+                }
+            }
+        }
+    }
+
+    public int compareValue(Double min, Double max, Double v) {
+        if (min == null || max == null || v == null) {
+            return -1;
+        }
+        if (v >= min && v <= max) {
+            return 1;
+        }
+        return 0;
     }
 
     /**

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

@@ -19,7 +19,6 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 
 import java.lang.reflect.Field;
-import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Date;
@@ -680,69 +679,6 @@ public class CoreUtil {
         debugMap.put(msg, error);
     }
 
-    /**
-     * 年龄字符串转换成double类型
-     *
-     * @param ageStr
-     * @return
-     */
-    public static Double convertAge(String ageStr) {
-        try {
-            // 防止程序出错
-            if (StringUtil.isEmpty(ageStr)) {
-                return 20.0;
-            }
-            // 数值,当成年龄处理
-            if (isNumbers(ageStr)) {
-                return Double.parseDouble(ageStr);
-            }
-            // 20日
-            if (ageStr.endsWith("日")) {
-                return getHalfUp((Double.parseDouble(ageStr.substring(0, ageStr.length() - 1))) / 365);
-            }
-            // 3岁
-            if (ageStr.endsWith("岁")) {
-                return Double.parseDouble(ageStr.substring(0, ageStr.length() - 1));
-            }
-            // 3岁7个月 | 3岁7月
-            if (ageSuiYue(ageStr)) {
-                String[] ageArr = new String[2];
-                int indexSui = ageStr.indexOf("岁");
-                ageArr[0] = ageStr.substring(0, indexSui);
-                if (ageStr.indexOf("个月") > -1) { // 3岁7个月
-                    ageArr[1] = ageStr.substring(indexSui + 1, ageStr.indexOf("个月"));
-                } else { // 3岁7月
-                    ageArr[1] = ageStr.substring(indexSui + 1, ageStr.indexOf("月"));
-                }
-                return Double.parseDouble(ageArr[0]) + getHalfUp(Double.parseDouble(ageArr[1]) / 12);
-            }
-            // 1.08月 | .11月 | 3月
-            if (ageYue(ageStr)) {
-                String noUnit = ageStr.substring(0, ageStr.length() - 1);
-                String[] ageArr = new String[2];
-                String[] splitArr = noUnit.split("\\.");
-                if (splitArr.length == 1) {
-                    ageArr[0] = splitArr[0];
-                } else if (splitArr.length == 2) {
-                    ageArr[0] = splitArr[0];
-                    ageArr[1] = splitArr[1];
-                }
-                Double daySum = 0.0D;
-                if (StringUtil.isNotBlank(ageArr[0])) {
-                    daySum += Double.parseDouble(ageArr[0]) * 30;
-                }
-                if (StringUtil.isNotBlank(ageArr[1])) {
-                    daySum += Double.parseDouble(ageArr[1]);
-                }
-                return getHalfUp(daySum / 365);
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-            return 20.0;
-        }
-        return 20.0;
-    }
-
     /**
      * 判断字符串是否 仅 包含数字
      *
@@ -765,40 +701,6 @@ public class CoreUtil {
         return str.matches(regex);
     }
 
-
-    /**
-     * 判断年龄字符串:xx月
-     *
-     * @param str
-     * @return
-     */
-    public static boolean ageYue(String str) {
-        String regex = "^[0-9]*[\\.]*[0-9]{1,2}月$";
-        return str.matches(regex);
-    }
-
-    /**
-     * 判断年龄字符串:3岁7个月
-     *
-     * @param str
-     * @return
-     */
-    public static boolean ageSuiYue(String str) {
-        String regex = "^[0-9]{1,3}岁[0-9]{1,2}个{0,1}月$";
-        return str.matches(regex);
-    }
-
-    /**
-     * 四舍五入保留2位小数
-     *
-     * @param ageStr
-     * @return
-     */
-    public static Double getHalfUp(Double ageStr) {
-        BigDecimal bg = new BigDecimal(String.valueOf(ageStr));
-        return bg.setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue();
-    }
-
     /**
      * 替换首位的标点符号(例如:既往史提取“铁)
      *