Prechádzať zdrojové kódy

Merge remote-tracking branch 'origin/push-lis-convert' into push-lis

louhr 5 rokov pred
rodič
commit
056cecaa6e
21 zmenil súbory, kde vykonal 260 pridanie a 156 odobranie
  1. 1 1
      algorithm/src/main/resources/algorithm.properties
  2. 0 6
      common-push/pom.xml
  3. 2 0
      common-push/src/main/java/org/diagbot/common/push/bean/SearchData.java
  4. 0 93
      common-push/src/main/java/org/diagbot/common/push/filter/pretreat/PretreatmentLis.java
  5. 2 11
      common-push/src/main/java/org/diagbot/common/push/filter/rule/PretreatmentRule.java
  6. 2 2
      common-push/src/main/java/org/diagbot/common/push/work/RelationExtractionUtil.java
  7. 1 2
      graph-web/src/main/java/org/diagbot/graphWeb/work/GraphCalculate.java
  8. 17 0
      nlp/src/main/java/org/diagbot/nlp/rule/analyze/RuleAnalyze.java
  9. 1 1
      common-push/src/main/java/org/diagbot/common/push/bean/PreResult.java
  10. 2 2
      common-push/src/main/java/org/diagbot/common/push/filter/pretreat/Pretreatment.java
  11. 2 2
      common-push/src/main/java/org/diagbot/common/push/filter/pretreat/PretreatmentDiag.java
  12. 86 0
      nlp/src/main/java/org/diagbot/nlp/rule/pretreat/PretreatmentLis.java
  13. 2 2
      common-push/src/main/java/org/diagbot/common/push/filter/pretreat/PretreatmentMakeList.java
  14. 2 4
      common-push/src/main/java/org/diagbot/common/push/filter/pretreat/PretreatmentNormal.java
  15. 2 2
      common-push/src/main/java/org/diagbot/common/push/filter/pretreat/PretreatmentOther.java
  16. 2 3
      common-push/src/main/java/org/diagbot/common/push/filter/pretreat/PretreatmentPacs.java
  17. 2 2
      common-push/src/main/java/org/diagbot/common/push/filter/pretreat/PretreatmentSymptom.java
  18. 2 2
      common-push/src/main/java/org/diagbot/common/push/filter/pretreat/PretreatmentVital.java
  19. 36 20
      push-web/src/main/java/org/diagbot/push/controller/AlgorithmController.java
  20. 0 1
      rule/src/main/java/org/diagbot/rule/crisis/CrisisApplication.java
  21. 96 0
      rule/src/main/java/org/diagbot/rule/lis/LisApplication.java

+ 1 - 1
algorithm/src/main/resources/algorithm.properties

@@ -2,7 +2,7 @@
 
 #basicPath=E:/project/push/algorithm/src/main/models/model_version_replacement/model
 basicPath=/opt/models/dev/models/model_version_replacement/model
-#basicPath=E:/re_models/model_version_replacement/model
+#basicPath=F:/models/model_version_replacement/model
 
 ############################### current model version ################################
 diagnosisPredict.version=outpatient_556_IOE_1

+ 0 - 6
common-push/pom.xml

@@ -28,12 +28,6 @@
             <artifactId>nlp</artifactId>
             <version>1.0.0</version>
         </dependency>
-
-        <dependency>
-            <groupId>org.diagbot</groupId>
-            <artifactId>common-service</artifactId>
-            <version>1.0.0</version>
-        </dependency>
     </dependencies>
 
     <build>

+ 2 - 0
common-push/src/main/java/org/diagbot/common/push/bean/SearchData.java

@@ -1,5 +1,7 @@
 package org.diagbot.common.push.bean;
 
+import org.diagbot.nlp.rule.module.PreResult;
+
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;

+ 0 - 93
common-push/src/main/java/org/diagbot/common/push/filter/pretreat/PretreatmentLis.java

@@ -1,93 +0,0 @@
-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.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 {
-        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.setOtherValue(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);
-        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.LIS_NAME})) {
-            result.setDetailName(NlpUtil.concept(leftLexeme, NegativeEnum.LIS_NAME));
-        } else if (NlpUtil.isFeature(leftLexeme.getProperty(), new NegativeEnum[]{NegativeEnum.PUB_NAME})) {
-            result.setUniqueName(NlpUtil.concept(leftLexeme, NegativeEnum.PUB_NAME));
-        } else {
-            return null;
-        }
-
-        //查找化验套餐
-        int position = cursor - 1;
-        while (position > -1) {
-            leftLexeme = lexemes.get(position);
-            if (NlpUtil.isFeature(leftLexeme.getProperty(), new NegativeEnum[]{NegativeEnum.LIS_TYPE})) {
-                result.setName(NlpUtil.concept(leftLexeme, NegativeEnum.LIS_TYPE));
-                break;
-            }
-            position--;
-        }
-
-        if (StringUtils.isEmpty(result.getUniqueName())){
-            if (StringUtils.isNotEmpty(result.getDetailName()) && StringUtils.isNotEmpty(result.getName())){
-                result.setUniqueName(result.getName() + "--" + result.getDetailName());
-            } else if (StringUtils.isNotEmpty(result.getDetailName())){
-                result.setUniqueName(result.getDetailName());
-            } else if (StringUtils.isNotEmpty(result.getName())){
-                result.setUniqueName(result.getName());
-            } else {
-                return null;
-            }
-        }
-
-        return result;
-    }
-
-    public String findBodyValue(LexemePath<Lexeme> lexemes, Lexeme lexeme, int index) {
-        return null;
-    }
-}

+ 2 - 11
common-push/src/main/java/org/diagbot/common/push/filter/rule/PretreatmentRule.java

@@ -1,13 +1,11 @@
 package org.diagbot.common.push.filter.rule;
 
 
-import org.diagbot.common.push.bean.PreResult;
-import org.diagbot.common.push.bean.ResponseData;
 import org.diagbot.common.push.bean.Rule;
 import org.diagbot.common.push.bean.SearchData;
 import org.diagbot.common.push.cache.ApplicationCacheUtil;
-import org.diagbot.common.push.filter.pretreat.*;
-import org.diagbot.pub.Constants;
+import org.diagbot.nlp.rule.module.PreResult;
+import org.diagbot.nlp.rule.pretreat.*;
 import org.springframework.util.StringUtils;
 
 import java.io.IOException;
@@ -63,13 +61,6 @@ public class PretreatmentRule {
         return add2PreResultList(preResultList, content, ruleType, searchData);
     }
 
-    public static void main(String[] args) throws IOException {
-        PretreatmentRule pretreatmentRule = new PretreatmentRule();
-        SearchData searchData = new SearchData();
-        searchData.setSymptom("钠(Na)110mmol/L");
-        pretreatmentRule.rule(searchData);
-    }
-
     private String add2PreResultList(List<PreResult> preResultList, String content, String ruleType, SearchData searchData) throws java.io.IOException {
         Map<String, List<Rule>> kl_rule_filter_map = ApplicationCacheUtil.getKl_rule_filter_map();
         //符合条件的规则

+ 2 - 2
common-push/src/main/java/org/diagbot/common/push/work/RelationExtractionUtil.java

@@ -61,9 +61,9 @@ public class RelationExtractionUtil {
             }
             if (isExist(sb.toString())) {
                 Map<String, String> map = new HashMap<>();
-                map.put("featureType", "5");
+                map.put("featureType", Constants.feature_type_pacs);
                 map.put("featureName", sb.toString());
-                map.put("property", "17");
+                map.put("property", Constants.word_property_PACS_Result);
                 map.put("concept", sb.toString());
                 //全是有
                 map.put("negative", Constants.default_negative);

+ 1 - 2
graph-web/src/main/java/org/diagbot/graphWeb/work/GraphCalculate.java

@@ -5,7 +5,6 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import org.apache.commons.lang3.StringUtils;
 import org.diagbot.common.push.bean.FeatureRate;
-import org.diagbot.common.push.bean.PreResult;
 import org.diagbot.common.push.bean.ResponseData;
 import org.diagbot.common.push.bean.SearchData;
 import org.diagbot.common.push.bean.neo4j.Filnlly;
@@ -19,7 +18,7 @@ import org.diagbot.graph.jdbc.Neo4jAPI;
 import javax.servlet.http.HttpServletRequest;
 import java.util.*;
 
-import org.diagbot.graphWeb.util.MapValueComparator;
+import org.diagbot.nlp.rule.module.PreResult;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 

+ 17 - 0
nlp/src/main/java/org/diagbot/nlp/rule/analyze/RuleAnalyze.java

@@ -0,0 +1,17 @@
+package org.diagbot.nlp.rule.analyze;
+
+import org.diagbot.nlp.rule.module.PreResult;
+import org.diagbot.nlp.rule.pretreat.Pretreatment;
+import org.diagbot.nlp.rule.pretreat.PretreatmentLis;
+
+import java.util.List;
+
+/**
+ * Created by louhr on 2019/9/25.
+ */
+public class RuleAnalyze {
+    public List<PreResult> lisConvert(String content) throws java.io.IOException {
+        Pretreatment pretreatment = new PretreatmentLis();
+        return pretreatment.analyze(content);
+    }
+}

+ 1 - 1
common-push/src/main/java/org/diagbot/common/push/bean/PreResult.java

@@ -1,4 +1,4 @@
-package org.diagbot.common.push.bean;
+package org.diagbot.nlp.rule.module;
 
 /**
  * Created by louhr on 2019/8/31.

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

@@ -1,9 +1,9 @@
-package org.diagbot.common.push.filter.pretreat;
+package org.diagbot.nlp.rule.pretreat;
 
-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.rule.module.PreResult;
 import org.diagbot.nlp.util.NegativeEnum;
 import org.diagbot.nlp.util.NlpUtil;
 import org.springframework.util.StringUtils;

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

@@ -1,9 +1,9 @@
-package org.diagbot.common.push.filter.pretreat;
+package org.diagbot.nlp.rule.pretreat;
 
-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.rule.module.PreResult;
 import org.diagbot.nlp.util.NegativeEnum;
 import org.diagbot.nlp.util.NlpUtil;
 

+ 86 - 0
nlp/src/main/java/org/diagbot/nlp/rule/pretreat/PretreatmentLis.java

@@ -0,0 +1,86 @@
+package org.diagbot.nlp.rule.pretreat;
+
+import org.diagbot.nlp.participle.ParticipleUtil;
+import org.diagbot.nlp.participle.word.Lexeme;
+import org.diagbot.nlp.participle.word.LexemePath;
+import org.diagbot.nlp.rule.module.PreResult;
+import org.diagbot.nlp.util.NegativeEnum;
+import org.diagbot.nlp.util.NlpUtil;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class PretreatmentLis extends Pretreatment {
+    private String join_symbols = ";:;:";
+    protected NegativeEnum[] lis_result = new NegativeEnum[]{NegativeEnum.LIS_RESULT};
+    protected NegativeEnum[] lis_name = new NegativeEnum[]{NegativeEnum.LIS_NAME};
+    protected NegativeEnum[] lis_type = new NegativeEnum[]{NegativeEnum.LIS_TYPE};
+
+    public List<PreResult> analyze(String content) throws java.io.IOException {
+        List<PreResult> preResults = new ArrayList<>();
+        LexemePath<Lexeme> lexemes = ParticipleUtil.participle(content);
+        for (int i = 0; i < lexemes.size(); i++) {
+            Lexeme l = lexemes.get(i);
+            if (NlpUtil.isFeature(l.getProperty(), lis_name)) {
+                cursor = i;
+                PreResult result = new PreResult();
+                result.setDetailName(NlpUtil.concept(l, NegativeEnum.LIS_NAME));
+                result = createPreResult(lexemes, result, i);
+                if (result != null) {
+                    preResults.add(result);
+                }
+            }
+        }
+        return preResults;
+    }
+
+    public PreResult createPreResult(LexemePath<Lexeme> lexemes, Lexeme lexeme, int index) {
+        return null;
+    }
+
+    public PreResult createPreResult(LexemePath<Lexeme> lexemes, PreResult result, int index) {
+        Lexeme leftLexeme;
+        //往前查找化验套餐
+        int position = index - 1;
+        while (position > -1) {
+            leftLexeme = lexemes.get(position);
+            if (NlpUtil.isFeature(leftLexeme.getProperty(), lis_type)) {
+                result.setName(NlpUtil.concept(leftLexeme, NegativeEnum.LIS_TYPE));
+                break;
+            }
+            position--;
+        }
+        //往后查找化验结果
+        int max_find_step = 10;
+        if (index ==  lexemes.size() - 1) return null;
+        position = index++;
+        Lexeme rightLexeme;
+        while (position < (index + max_find_step) &&  position < lexemes.size()) {
+            rightLexeme = lexemes.get(position);
+            //遇上数字查找是否有单位
+            if (NlpUtil.isNumberString(rightLexeme)) {
+                result.setValue(rightLexeme.getText());
+                //继续找单位
+                int offset = 1;
+                while (offset < max_find_step && position + offset < lexemes.size()) {
+                    rightLexeme = lexemes.get(position + offset);
+                    if (NlpUtil.isFeature(rightLexeme.getProperty(), nees_time_and_unit)) {
+                        result.setUnits(rightLexeme.getText());
+                        break;
+                    }
+                    offset++;
+                }
+                break;
+            } else if (NlpUtil.isFeature(rightLexeme.getProperty(), lis_result)) {  //化验结果
+                result.setValue(rightLexeme.getText());
+                break;
+            }
+            position++;
+        }
+        return result;
+    }
+
+    public String findBodyValue(LexemePath<Lexeme> lexemes, Lexeme lexeme, int index) {
+        return null;
+    }
+}

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

@@ -1,9 +1,9 @@
-package org.diagbot.common.push.filter.pretreat;
+package org.diagbot.nlp.rule.pretreat;
 
-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.rule.module.PreResult;
 import org.diagbot.nlp.util.NegativeEnum;
 import org.diagbot.nlp.util.NlpUtil;
 

+ 2 - 4
common-push/src/main/java/org/diagbot/common/push/filter/pretreat/PretreatmentNormal.java

@@ -1,11 +1,9 @@
-package org.diagbot.common.push.filter.pretreat;
+package org.diagbot.nlp.rule.pretreat;
 
-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 org.diagbot.nlp.rule.module.PreResult;
 
 import java.util.List;
 

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

@@ -1,9 +1,9 @@
-package org.diagbot.common.push.filter.pretreat;
+package org.diagbot.nlp.rule.pretreat;
 
-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.rule.module.PreResult;
 import org.diagbot.nlp.util.NegativeEnum;
 import org.diagbot.nlp.util.NlpUtil;
 

+ 2 - 3
common-push/src/main/java/org/diagbot/common/push/filter/pretreat/PretreatmentPacs.java

@@ -1,12 +1,11 @@
-package org.diagbot.common.push.filter.pretreat;
+package org.diagbot.nlp.rule.pretreat;
 
-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.rule.module.PreResult;
 import org.diagbot.nlp.util.NegativeEnum;
 import org.diagbot.nlp.util.NlpUtil;
-import org.springframework.util.StringUtils;
 
 import java.util.List;
 

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

@@ -1,9 +1,9 @@
-package org.diagbot.common.push.filter.pretreat;
+package org.diagbot.nlp.rule.pretreat;
 
-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.rule.module.PreResult;
 import org.diagbot.nlp.util.NegativeEnum;
 import org.diagbot.nlp.util.NlpUtil;
 

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

@@ -1,9 +1,9 @@
-package org.diagbot.common.push.filter.pretreat;
+package org.diagbot.nlp.rule.pretreat;
 
-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.rule.module.PreResult;
 import org.diagbot.nlp.util.NegativeEnum;
 import org.diagbot.nlp.util.NlpUtil;
 

+ 36 - 20
push-web/src/main/java/org/diagbot/push/controller/AlgorithmController.java

@@ -14,6 +14,9 @@ import org.diagbot.common.push.filter.rule.PretreatmentRule;
 import org.diagbot.common.push.work.ParamsDataProxy;
 import org.diagbot.graphWeb.work.GraphCalculate;
 import org.diagbot.graphWeb.work.LisPacsCalculate;
+import org.diagbot.nlp.rule.analyze.RuleAnalyze;
+import org.diagbot.nlp.rule.pretreat.Pretreatment;
+import org.diagbot.nlp.rule.pretreat.PretreatmentLis;
 import org.diagbot.nlp.util.Constants;
 import org.diagbot.nlp.util.NlpCache;
 import org.diagbot.pub.api.Response;
@@ -22,6 +25,7 @@ import org.diagbot.pub.utils.PropertiesUtil;
 import org.diagbot.pub.utils.http.HttpApi;
 import org.diagbot.pub.web.BaseController;
 import org.diagbot.rule.crisis.CrisisApplication;
+import org.diagbot.rule.lis.LisApplication;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Controller;
@@ -49,7 +53,7 @@ public class AlgorithmController extends BaseController {
         listView = "/pages/algorithm/list.html";
     }
 
-    @RequestMapping({"/index"})
+    @RequestMapping({ "/index" })
     public String index() {
         return listView;
     }
@@ -72,7 +76,7 @@ public class AlgorithmController extends BaseController {
         Response<ResponseData> response = new Response<>();
 
         MysqlJdbc nlpJdbc = new MysqlJdbc("root", "diagbot@20180822", "jdbc:mysql://192.168.2.235:3306/med-s?useUnicode=true&characterEncoding=UTF-8");
-        List<Map<String, String>> data = nlpJdbc.query("doc_info_validate", new String[]{"pk_dcpv", "present", "diag", "sex", "age"}, "");
+        List<Map<String, String>> data = nlpJdbc.query("doc_info_validate", new String[] { "pk_dcpv", "present", "diag", "sex", "age" }, "");
 
         Map<String, String> diags = NlpCache.getStandard_info_synonym_map().get(Constants.word_property_diagnose);
 
@@ -122,6 +126,14 @@ public class AlgorithmController extends BaseController {
     public Response<ResponseData> combine(HttpServletRequest request, SearchData searchData) throws Exception {
         ResponseData responseData = new ResponseData();
         logger.info("开始推送服务......");
+        LisApplication lisApplication = new LisApplication();
+        if ((searchData.getLisArr() == null || searchData.getLisArr().size() == 0)
+                && StringUtils.isNotEmpty(searchData.getLis())) {
+            Pretreatment pretreatment = new PretreatmentLis();
+            searchData.setLisArr(pretreatment.analyze(searchData.getLis()));
+        }
+        lisApplication.lisConvert(searchData.getLisArr(),searchData);
+
         Response<ResponseData> response = new Response();
         //一些基本信息预处理 如年龄 性别
         ParamsDataProxy paramsDataProxy = new ParamsDataProxy();
@@ -170,11 +182,13 @@ public class AlgorithmController extends BaseController {
         Map<String, List<CrisisDetail>> crisisDetails = responseData.getCrisisDetails();
         List<MedicalIndication> crisisDetailsList = this.getCrisisDetails(crisisDetails);
         List<MedicalIndication> medicalIndications = graphResponseData.getMedicalIndications();
-        if (medicalIndications == null) medicalIndications = new ArrayList<>();
+        if (medicalIndications == null) {
+            medicalIndications = new ArrayList<>();
+        }
         medicalIndications.addAll(crisisDetailsList);
         if (medicalIndications != null && medicalIndications.size() > 0) {
             logger.info("指标推送!!!!!!!!!");
-//           bigDataResponseData.getMedicalIndications().addAll(medicalIndications);
+            //           bigDataResponseData.getMedicalIndications().addAll(medicalIndications);
             bigDataResponseData.setMedicalIndications(medicalIndications);
         }
 
@@ -191,11 +205,11 @@ public class AlgorithmController extends BaseController {
         Map<String, String> vitalCache = CacheUtil.getVitalCache();
         List<String> featureList = Arrays.asList(searchData.getFeatureTypes());
         List<FeatureRate> vitals = graphResponseData.getVitals();
-        if(featureList.contains(Constants.feature_type_vital_index) && this.getVital(vitalCache,vitals).size() > 0){
-            bigDataResponseData.setVitals(this.getVital(vitalCache,vitals));
+        if (featureList.contains(Constants.feature_type_vital_index) && this.getVital(vitalCache, vitals).size() > 0) {
+            bigDataResponseData.setVitals(this.getVital(vitalCache, vitals));
 
         }
-        if(featureList.contains(Constants.feature_type_vital) && vitals.size() > 0){
+        if (featureList.contains(Constants.feature_type_vital) && vitals.size() > 0) {
             bigDataResponseData.setVitals(vitals);
         }
 
@@ -211,23 +225,24 @@ public class AlgorithmController extends BaseController {
 
     /**
      * 包装输出的危急值
+     *
      * @param crisisDetails
      * @return
      */
-    public List<MedicalIndication> getCrisisDetails(Map<String, List<CrisisDetail>> crisisDetails){
+    public List<MedicalIndication> getCrisisDetails(Map<String, List<CrisisDetail>> crisisDetails) {
         List<MedicalIndication> crisisDetailList = new ArrayList<>();
-        for(Map.Entry<String, List<CrisisDetail>> entry : crisisDetails.entrySet()) {
-            for (CrisisDetail crisisDetail:entry.getValue()) {
+        for (Map.Entry<String, List<CrisisDetail>> entry : crisisDetails.entrySet()) {
+            for (CrisisDetail crisisDetail : entry.getValue()) {
                 String originText = crisisDetail.getOriginText();//文本输入的数据
                 String remindText = crisisDetail.getRemindText();//危机警示指标
                 String standardText = crisisDetail.getStandardText();//评判标准
-                if(StringUtils.isNotEmpty(remindText)){
+                if (StringUtils.isNotEmpty(remindText)) {
                     MedicalIndication medicalIndication = new MedicalIndication();
                     List<MedicalIndicationDetail> crisisMid = new ArrayList<>();
                     MedicalIndicationDetail medicalIndicationDetail = new MedicalIndicationDetail();
                     JSONObject jsonObject = new JSONObject();
-                    jsonObject.put("controlType",2);
-                    jsonObject.put("name",standardText);
+                    jsonObject.put("controlType", 2);
+                    jsonObject.put("name", standardText);
                     medicalIndicationDetail.setType(4);
                     medicalIndicationDetail.setContent(jsonObject);
                     crisisMid.add(medicalIndicationDetail);
@@ -240,26 +255,27 @@ public class AlgorithmController extends BaseController {
         return crisisDetailList;
     }
 
-    public List<FeatureRate> getVital(Map<String, String> vitalCache,List<FeatureRate> vitals){
+    public List<FeatureRate> getVital(Map<String, String> vitalCache, List<FeatureRate> vitals) {
         Set<String> vitalSet = new LinkedHashSet<>();
         List<FeatureRate> vitalList = new ArrayList<>();
-        if(vitals != null){
-            for (FeatureRate f:vitals) {
+        if (vitals != null) {
+            for (FeatureRate f : vitals) {
                 String s = vitalCache.get(f.getFeatureName());
-                if(StringUtils.isNotEmpty(s)){
+                if (StringUtils.isNotEmpty(s)) {
                     vitalSet.add(s);
                 }
             }
         }
-        if(vitalSet != null){
-            for (String vi:vitalSet) {
-                FeatureRate featureRate= new FeatureRate();
+        if (vitalSet != null) {
+            for (String vi : vitalSet) {
+                FeatureRate featureRate = new FeatureRate();
                 featureRate.setFeatureName(vi);
                 vitalList.add(featureRate);
             }
         }
         return vitalList;
     }
+
     public Response<ResponseData> algorithm(HttpServletRequest request, SearchData searchData) throws Exception {
         Response<ResponseData> response = new Response();
 

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

@@ -1,7 +1,6 @@
 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;

+ 96 - 0
rule/src/main/java/org/diagbot/rule/lis/LisApplication.java

@@ -0,0 +1,96 @@
+package org.diagbot.rule.lis;
+
+import org.diagbot.common.push.bean.SearchData;
+import org.diagbot.nlp.rule.module.PreResult;
+import org.diagbot.nlp.util.Constants;
+import org.springframework.util.StringUtils;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @Description:
+ * @Author: HUJING
+ * @Date: 2019/9/25 13:33
+ */
+public class LisApplication {
+    private static String up = "升高";
+    private static String down = "降低";
+    private static String normal = "正常";
+
+    public void lisConvert(List<PreResult> preResultList, SearchData searchData) {
+        if (preResultList != null) {
+            for (PreResult result : preResultList) {
+                String covertValue = "";
+                if (!StringUtils.isEmpty(result.getUniqueName())) {
+                    //value是数值类型则进行转换
+                    if (!StringUtils.isEmpty(result.getValue()) && isNumber(result.getValue())) {
+                        if (!StringUtils.isEmpty(result.getMaxValue()) && !StringUtils.isEmpty(result.getMinValue())
+                                && isNormal(result.getValue(), result.getMaxValue(), result.getMinValue())) {
+                            covertValue = result.getUniqueName() + normal;
+                        } else if (!StringUtils.isEmpty(result.getMaxValue())
+                                && compareMax(result.getValue(), result.getMaxValue())) {
+                            covertValue = result.getUniqueName() + up;
+                        } else if (!StringUtils.isEmpty(result.getMinValue())
+                                && compareMin(result.getValue(), result.getMinValue())) {
+                            covertValue = result.getUniqueName() + down;
+                        }
+                    } else if (!StringUtils.isEmpty(result.getOtherValue())){
+                        //otherValue是文本类型则直接与UniqueName拼接
+                        covertValue = result.getUniqueName() + result.getOtherValue();
+                    }
+                }
+
+                Map<String, String> map = new HashMap<>();
+                map.put("featureType", Constants.feature_type_lis);
+                map.put("featureName", covertValue);
+                map.put("property", Constants.word_property_LIS_Result);
+                map.put("concept", covertValue);
+                //全是有
+                map.put("negative", Constants.default_negative);
+                if (searchData.getInputs().get(map.get("featureName")) == null) {
+                    searchData.getInputs().put(map.get("featureName"), map);
+                }
+            }
+        }
+    }
+
+
+    private boolean isNormal(String value, String maxValue, String minValue) {
+        try {
+            return Double.valueOf(value) < Double.valueOf(maxValue) && Double.valueOf(value) > Double.valueOf(minValue);
+        } catch (Exception e) {
+        }
+        return false;
+    }
+
+    private boolean compareMin(String value, String minValue) {
+        try {
+            return Double.valueOf(value) < Double.valueOf(minValue);
+        } catch (Exception e) {
+        }
+        return false;
+    }
+
+    private boolean compareMax(String value, String maxValue) {
+        try {
+            return Double.valueOf(value) > Double.valueOf(maxValue);
+        } catch (Exception e) {
+        }
+        return false;
+    }
+
+    public static boolean isNumber(String value) {
+        if (StringUtils.isEmpty(value)) {
+            return false;
+        }
+        for (char c : value.toCharArray()) {
+            if (c >= '0' && c <= '9') {
+                return true;
+            }
+        }
+        return false;
+    }
+}