Browse Source

Merge remote-tracking branch 'origin/push-grade-rule' into push-dev-pacs

louhr 5 years atrás
parent
commit
a3f9e45de0

+ 2 - 0
common-push/src/main/java/org/diagbot/common/push/filter/pretreat/Pretreatment.java

@@ -80,4 +80,6 @@ public abstract class Pretreatment {
         }
         return -1;
     }
+
+
 }

+ 26 - 5
common-push/src/main/java/org/diagbot/common/push/filter/pretreat/PretreatmentLis.java

@@ -1,25 +1,47 @@
 package org.diagbot.common.push.filter.pretreat;
 
+import org.apache.commons.lang3.StringUtils;
 import org.diagbot.common.push.bean.PreResult;
+import org.diagbot.nlp.participle.ParticipleUtil;
 import org.diagbot.nlp.participle.word.Lexeme;
 import org.diagbot.nlp.participle.word.LexemePath;
 import org.diagbot.nlp.util.NegativeEnum;
 import org.diagbot.nlp.util.NlpUtil;
 
-import java.lang.reflect.Array;
 import java.util.List;
 
 public class PretreatmentLis extends Pretreatment {
     private String join_symbols = ";:;:";
+    protected NegativeEnum[] lisResult = new NegativeEnum[]{NegativeEnum.LIS_RESULT};
 
-    public List<PreResult> analyze(String content) throws java.io.IOException{
-        return super.analyzeDefault(content);
+    public List<PreResult> analyze(String content) throws java.io.IOException {
+        List<PreResult> preResults = super.analyzeDefault(content);
+        LexemePath<Lexeme> lexemes = ParticipleUtil.participle(content);
+        for (int i = 0; i < lexemes.size(); i++) {
+            Lexeme l = lexemes.get(i);
+            if (NlpUtil.isFeature(l.getProperty(), lisResult)) {
+                cursor = i;
+                PreResult result = new PreResult();
+                result = findPreResultPub(lexemes, result);
+                if (result != null) {
+                    result.setValue(l.getText());
+                    preResults.add(result);
+                }
+            }
+        }
+        return preResults;
     }
 
     public PreResult createPreResult(LexemePath<Lexeme> lexemes, Lexeme lexeme, int index) {
         PreResult result = new PreResult();
         double value = findNumberValue(lexemes, lexeme, index);
         if (value == -1) return null;
+        result.setValue(String.valueOf(value));
+        result.setUnits(lexeme.getText());
+        return findPreResultPub(lexemes, result);
+    }
+
+    public PreResult findPreResultPub(LexemePath<Lexeme> lexemes, PreResult result) {
         //继续往前找化验明细项
         if (cursor > 0) cursor--;
         Lexeme leftLexeme = lexemes.get(cursor);
@@ -48,8 +70,7 @@ public class PretreatmentLis extends Pretreatment {
             }
             position--;
         }
-        result.setValue(String.valueOf(value));
-        result.setUnits(lexeme.getText());
+
         return result;
     }
 

+ 83 - 6
common-push/src/main/java/org/diagbot/common/push/filter/pretreat/PretreatmentPacs.java

@@ -6,13 +6,16 @@ import org.diagbot.nlp.participle.word.Lexeme;
 import org.diagbot.nlp.participle.word.LexemePath;
 import org.diagbot.nlp.util.NegativeEnum;
 import org.diagbot.nlp.util.NlpUtil;
+import org.springframework.util.StringUtils;
 
 import java.util.List;
 
 public class PretreatmentPacs extends Pretreatment {
-    protected NegativeEnum[] nees_pacs_result = new NegativeEnum[]{NegativeEnum.PACS_RESULT};
-    protected NegativeEnum[] nees_pacs_name = new NegativeEnum[]{NegativeEnum.PACS_NAME};
-    public List<PreResult> analyze(String content) throws java.io.IOException{
+    protected NegativeEnum[] nees_pacs_result = new NegativeEnum[] { NegativeEnum.PACS_RESULT };
+    protected NegativeEnum[] nees_pacs_name = new NegativeEnum[] { NegativeEnum.PACS_NAME };
+    private String join_symbols = ";:;:";
+
+    public List<PreResult> analyze(String content) throws java.io.IOException {
         List<PreResult> preResultList = super.analyzeDefault(content);
         //pacs除了数值型需要转, 还需要对部分检查结果提取,以便做危机警示
         LexemePath<Lexeme> lexemes = ParticipleUtil.participle(content);
@@ -34,18 +37,92 @@ public class PretreatmentPacs extends Pretreatment {
                     }
                     c--;
                 }
-
+            } else if (NlpUtil.isFeature(l.getProperty(), nees_time_and_unit) && i > 0) {
+                PreResult result = data2Object(lexemes, l, i, l.getProperty());
+                if (result != null) {
+                    preResultList.add(result);
+                }
             }
         }
-
         return preResultList;
     }
 
     public PreResult createPreResult(LexemePath<Lexeme> lexemes, Lexeme lexeme, int index) {
-        return super.createDefaultPreResult(lexemes, lexeme, index);
+        double value = findNumberValue(lexemes, lexeme, index);
+        if (value == -1) {
+            return null;
+        }
+//        //继续往前找本体
+//        String text = findBodyValue(lexemes, lexeme, index);
+//        if (StringUtils.isEmpty(text)) {
+//            return null;
+//        }
+        PreResult result = new PreResult();
+        result.setValue(String.valueOf(value));
+        result.setUnits(lexeme.getText());
+        return getPreResultPub(lexemes, result);
     }
 
     public String findBodyValue(LexemePath<Lexeme> lexemes, Lexeme lexeme, int index) {
         return null;
     }
+
+    public PreResult getPreResultPub(LexemePath<Lexeme> lexemes, PreResult result) {
+        //继续往前找辅检明细项
+        if (cursor > 0) {
+            cursor--;
+        }
+        Lexeme leftLexeme = lexemes.get(cursor);
+        if (join_symbols.contains(leftLexeme.getText())) {
+            if (cursor > 0) {
+                cursor--;
+                leftLexeme = lexemes.get(cursor);
+            } else {
+                return null;
+            }
+        }
+        if (NlpUtil.isFeature(leftLexeme.getProperty(), new NegativeEnum[] { NegativeEnum.PACS_NAME })) {
+            result.setDetailName(NlpUtil.concept(leftLexeme, NegativeEnum.PACS_NAME));
+        } else if (NlpUtil.isFeature(leftLexeme.getProperty(), new NegativeEnum[] { NegativeEnum.PACS_NAME })) {
+            result.setUniqueName(NlpUtil.concept(leftLexeme, NegativeEnum.PACS_NAME));
+        } else {
+            return null;
+        }
+        return result;
+    }
+
+    protected double findNumberValue(LexemePath<Lexeme> lexemes, Lexeme lexeme, int index) {
+        if (index < 1) {
+            return -1;
+        }
+        cursor = index - 1;
+        Lexeme leftLexeme = lexemes.get(cursor);
+        if (isNumberString(leftLexeme)) {
+            String[] numbersSplit = leftLexeme.getText().split("\\*");
+            try {
+                if (numbersSplit.length == 2) {
+                    return Double.valueOf(numbersSplit[0]) * Double.valueOf(numbersSplit[1]);
+                } else if (numbersSplit.length == 3) {
+                    return Double.valueOf(numbersSplit[0]) * Double.valueOf(numbersSplit[1])
+                            * Double.valueOf(numbersSplit[2]);
+                } else {
+                    return -1;
+                }
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+        return -1;
+    }
+
+    public static boolean isNumberString(Lexeme l) {
+        if (l == null) {
+            return false;
+        }
+        if (NlpUtil.isFeature(l.getProperty(), new NegativeEnum[] { NegativeEnum.DIGITS })
+                && l.getText().indexOf("*") != -1) {
+            return true;
+        }
+        return false;
+    }
 }

+ 22 - 0
rule/src/main/java/org/diagbot/rule/crisis/CrisisApplication.java

@@ -1,6 +1,7 @@
 package org.diagbot.rule.crisis;
 
 import org.diagbot.common.push.bean.CrisisDetail;
+import org.diagbot.common.push.bean.PreResult;
 import org.diagbot.common.push.bean.Rule;
 import org.diagbot.common.push.bean.RuleApp;
 import org.diagbot.common.push.bean.SearchData;
@@ -77,4 +78,25 @@ public class CrisisApplication {
         }
         return crisisMap;
     }
+
+    private String mergeStandardText(Rule rule) {
+        //标准值最优先匹配
+        StringBuffer sb = new StringBuffer();
+        if (org.apache.commons.lang3.StringUtils.isNotEmpty(rule.getEq_value())) {
+            sb.append(rule.getPub_name()).append(rule.getEq_operator()).append(rule.getEq_value());
+        } else if (org.apache.commons.lang3.StringUtils.isNotEmpty(rule.getMax_value()) && org.apache.commons.lang3.StringUtils.isNotEmpty(rule.getMin_value())) {
+            sb.append(rule.getPub_name()).append(rule.getMin_operator()).append(rule.getMin_value())
+                    .append(rule.getMin_unit()).append(";")
+                    .append(rule.getPub_name()).append(rule.getMax_operator()).append(rule.getMax_value())
+                    .append(rule.getMax_unit());
+        } else if (org.apache.commons.lang3.StringUtils.isNotEmpty(rule.getMin_value())) {
+            sb.append(rule.getPub_name()).append(rule.getMin_operator()).append(rule.getMin_value())
+                    .append(rule.getMin_unit());
+        } else if (org.apache.commons.lang3.StringUtils.isNotEmpty(rule.getMax_value())) {
+            sb.append(rule.getPub_name()).append(rule.getMax_operator()).append(rule.getMax_value())
+                    .append(rule.getMax_unit());
+        }
+        return sb.toString();
+    }
+
 }