Selaa lähdekoodia

Merge remote-tracking branch 'origin/push-grade' into push-186server

# Conflicts:
#	graph/src/main/resources/bolt.properties
#	graphdb/src/main/resources/application.yml
MarkHuang 5 vuotta sitten
vanhempi
commit
b06e6b5a76
23 muutettua tiedostoa jossa 1033 lisäystä ja 22 poistoa
  1. 52 0
      bigdata-web/src/main/java/org/diagbot/bigdata/common/ApplicationCacheUtil.java
  2. 1 1
      bigdata-web/src/main/java/org/diagbot/bigdata/controller/AlgorithmController.java
  3. 4 2
      bigdata-web/src/main/java/org/diagbot/bigdata/work/AlgorithmCore.java
  4. 64 3
      common-push/src/main/java/org/diagbot/common/push/cache/CacheFileManager.java
  5. 79 0
      common-push/src/main/java/org/diagbot/common/push/filter/PreResult.java
  6. 45 0
      common-push/src/main/java/org/diagbot/common/push/filter/PretreatmentFilter.java
  7. 88 0
      common-push/src/main/java/org/diagbot/common/push/filter/pretreat/Pretreatment.java
  8. 41 0
      common-push/src/main/java/org/diagbot/common/push/filter/pretreat/PretreatmentLis.java
  9. 17 0
      common-push/src/main/java/org/diagbot/common/push/filter/pretreat/PretreatmentSymptom.java
  10. 17 0
      common-push/src/main/java/org/diagbot/common/push/filter/pretreat/PretreatmentVital.java
  11. 8 0
      common-service/src/main/java/org/diagbot/common/javabean/MedicalIndication.java
  12. 1 1
      common-service/src/main/java/org/diagbot/common/javabean/MedicalIndicationDetail.java
  13. 59 0
      common-service/src/main/java/org/diagbot/common/javabean/Rule.java
  14. 30 0
      common-service/src/main/java/org/diagbot/common/work/SearchData.java
  15. 42 5
      graph-web/src/main/java/org/diagbot/graphWeb/work/GraphCalculate.java
  16. 48 1
      graph/src/main/java/org/diagbot/graph/jdbc/Neo4jAPI.java
  17. 2 2
      graph/src/main/resources/bolt.properties
  18. 2 2
      graphdb/src/main/resources/application.yml
  19. 40 1
      nlp/src/main/java/org/diagbot/nlp/util/NlpUtil.java
  20. 7 0
      pom.xml
  21. 10 4
      push-web/src/main/java/org/diagbot/push/controller/AlgorithmController.java
  22. 1 0
      push-web/src/main/java/org/diagbot/push/controller/CacheFileManagerController.java
  23. 375 0
      push-web/src/main/java/org/diagbot/push/convert/PreProcess.java

+ 52 - 0
bigdata-web/src/main/java/org/diagbot/bigdata/common/ApplicationCacheUtil.java

@@ -2,6 +2,7 @@ package org.diagbot.bigdata.common;
 
 import org.diagbot.bigdata.dao.model.ResultMappingFilter;
 import org.diagbot.bigdata.util.BigDataConstants;
+import org.diagbot.common.javabean.Rule;
 import org.diagbot.nlp.participle.ParticipleUtil;
 import org.diagbot.nlp.participle.cfg.Configuration;
 import org.diagbot.nlp.participle.cfg.DefaultConfig;
@@ -30,6 +31,10 @@ public class ApplicationCacheUtil {
     public static Map<String, Map<String, ResultMappingFilter>> doc_result_mapping_filter_map = null;
     //诊断依据标准词
     public static Map<String, List<Map<String, String>>> kl_result_mapping_standword_map = null;
+    // 规则
+    public static Map<String, List<Rule>> rule_filter_map = null;
+    public static Map<String, List<Rule>> kl_rule_filter_map = null;
+
 
     public static Map<String, Map<String, String>> getStandard_info_synonym_map() {
         if (standard_info_synonym_map == null) {
@@ -214,6 +219,53 @@ public class ApplicationCacheUtil {
         return kl_result_mapping_standword_map;
     }
 
+    public static Map<String, List<Rule>> get_rule_filter_map() {
+        if (rule_filter_map == null || rule_filter_map.size() == 0) {
+            create_rule_filter_map();
+        }
+        return rule_filter_map;
+    }
+
+    public static void create_rule_filter_map() {
+        rule_filter_map = new HashMap<>();
+        List<Rule> rulelist;
+        Map<String, String> rule;
+        String key;
+
+        String[] labels = {"set_name","idx_name","min_operator","min_value","min_unit",
+                "max_operator","max_value","max_unit","eq_operator","eq_value","eq_unit","remind"};
+
+        Configuration configuration = new DefaultConfig();
+        List<String> fileContents = configuration.readFileContents("rule_filter.dict");
+
+        for (String line:fileContents) {
+            rule = new HashMap<>();
+            String[] content = line.split("\\|");
+            if (labels.length == content.length) {
+//                for (int i=0; i<labels.length; i++) {
+//                    rule.put(labels[i], content[i]);
+//                }
+//                key = content[0] + "--" + content[1];
+                key = content[1];
+                if (rule_filter_map.get(key) == null) {
+                    rule_filter_map.put(key, new ArrayList<>());
+                }
+                rulelist = rule_filter_map.get(key);
+                rulelist.add(new Rule(content));
+            }
+        }
+    }
+
+    public static void create_kl_rule_filter_map() {
+        kl_rule_filter_map = new HashMap<>();
+
+        Configuration configuration = new DefaultConfig();
+        List<String> fileContents = configuration.readFileContents("bigdata_rule_filter.dict");
+        for (String line:fileContents) {
+            String[] content = line.split("\\|");
+        }
+    }
+
     public static void setProterty(Lexeme lexeme) {
         for (String featureType : lexeme.getProperty().split(",")) {
             switch (featureType) {

+ 1 - 1
bigdata-web/src/main/java/org/diagbot/bigdata/controller/AlgorithmController.java

@@ -34,7 +34,7 @@ public class AlgorithmController extends BaseController {
     public Response<ResponseData> algorithm(HttpServletRequest request, SearchData searchData) throws Exception {
         Response<ResponseData> response = new Response();
         AlgorithmCore core = new AlgorithmCore();
-        ResponseData responseData = core.algorithm(request, searchData);
+        ResponseData responseData = core.algorithm(request, searchData, null);
         response.setData(responseData);
         return response;
     }

+ 4 - 2
bigdata-web/src/main/java/org/diagbot/bigdata/work/AlgorithmCore.java

@@ -25,8 +25,10 @@ import java.util.*;
  **/
 public class AlgorithmCore {
     Logger logger = LoggerFactory.getLogger(AlgorithmCore.class);
-    public ResponseData algorithm(HttpServletRequest request, SearchData searchData) throws Exception {
-        ResponseData responseData = new ResponseData();
+    public ResponseData algorithm(HttpServletRequest request, SearchData searchData, ResponseData responseData) throws Exception {
+        if (responseData == null) {
+            responseData = new ResponseData();
+        }
         //录入文本处理,包括提取特征、推送类型转换等
         ParamsDataProxy paramsDataProxy = new ParamsDataProxy();
         logger.info("页面文本信息:" + searchData.getSymptom());

+ 64 - 3
common-push/src/main/java/org/diagbot/common/push/cache/CacheFileManager.java

@@ -5,6 +5,7 @@ import org.diagbot.pub.utils.PropertiesUtil;
 import org.diagbot.pub.utils.security.EncrypDES;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.util.StringUtils;
 
 import java.io.File;
 import java.io.FileWriter;
@@ -23,14 +24,14 @@ public class CacheFileManager {
 
     private String user = "root";
     private String password = "lantone";
-    private String url = "jdbc:mysql://192.168.2.121:3306/med?useUnicode=true&characterEncoding=UTF-8";
+    private String url = "jdbc:mysql://192.168.2.236:3306/med?useUnicode=true&characterEncoding=UTF-8";
 
     private String path = "";
 
     public static void main(String[] args) {
         CacheFileManager cacheFileManager = new CacheFileManager();
-        String p = cacheFileManager.getClass().getClassLoader().getResource("").getPath();
-        p = "d:/cache_file/";
+        PropertiesUtil propertiesUtil = new PropertiesUtil("nlp.properties");
+        String p = propertiesUtil.getProperty("cache.file.dir");
         File file = new File(p);
         if (!file.exists()) {
             file.mkdirs();
@@ -328,6 +329,66 @@ public class CacheFileManager {
                 fw.write("\n");
             }
             fw.close();
+
+            //规则过滤信息
+            sql = "SELECT set_name, idx_name, min_operator, min_value, min_unit, max_operator, " +
+                    " max_value, max_unit, eq_operator, eq_value, eq_unit, remind FROM kl_rule ";
+            st = conn.createStatement();
+            rs = st.executeQuery(sql);
+            fw = new FileWriter(path + "rule_filter.dict");
+            String r6, r7, r8, r9, r10, r11, r12;
+            while (rs.next()) {
+                r1 = rs.getString(1);
+                r2 = rs.getString(2);
+                r3 = rs.getString(3);
+                r4 = rs.getString(4);
+                r5 = rs.getString(5);
+                r6 = rs.getString(6);
+                r7 = rs.getString(7);
+                r8 = rs.getString(8);
+                r9 = rs.getString(9);
+                r10 = rs.getString(10);
+                r11 = rs.getString(11);
+                r12 = rs.getString(12);
+                fw.write(encrypDES.encrytor(r1+ "|" + r2 + "|" + r3 + "|" + r4 + "|" + r5
+                        + "|" + r6 + "|" + r7 + "|" + r8 + "|" + r9 + "|" + r10 + "|" + r11 + "|" + r12));
+                fw.write("\n");
+            }
+            fw.close();
+
+//            //规则过滤信息
+//            sql = "SELECT idx_name, set_name, set_status, min_value, max_value, standard_value, " +
+//                    " , unit, concept_text, crisis_status, remind FROM kl_rule_new ";
+//            st = conn.createStatement();
+//            rs = st.executeQuery(sql);
+//            fw = new FileWriter(path + "bigdata_rule_filter.dict");
+//            String r10;
+//            while (rs.next()) {
+//                r1 = rs.getString(1);
+//                r2 = rs.getString(2);
+//                r3 = rs.getString(3);
+//                r4 = rs.getString(4);
+//                r5 = rs.getString(5);
+//                r6 = rs.getString(6);
+//                r7 = rs.getString(7);
+//                r8 = rs.getString(8);
+//                r9 = rs.getString(9);
+//                r10 = rs.getString(10);
+//                r1 = StringUtils.isEmpty(r1)?"":r1;
+//                r2 = StringUtils.isEmpty(r1)?"":r2;
+//                r3 = StringUtils.isEmpty(r1)?"":r3;
+//                r4 = StringUtils.isEmpty(r1)?"":r4;
+//                r5 = StringUtils.isEmpty(r1)?"":r5;
+//                r6 = StringUtils.isEmpty(r1)?"":r6;
+//                r7 = StringUtils.isEmpty(r1)?"":r7;
+//                r8 = StringUtils.isEmpty(r1)?"":r8;
+//                r9 = StringUtils.isEmpty(r1)?"":r9;
+//                r10 = StringUtils.isEmpty(r1)?"":r10;
+//                fw.write(encrypDES.encrytor(r1+ "|" + r2 + "|" + r3 + "|" + r4 + "|" + r5
+//                        + "|" + r6 + "|" + r7 + "|" + r8 + "|" + r9 + "|" + r10));
+//                fw.write("\n");
+//            }
+//            fw.close();
         } catch (IOException ioe) {
             ioe.printStackTrace();
         } catch (SQLException sqle) {

+ 79 - 0
common-push/src/main/java/org/diagbot/common/push/filter/PreResult.java

@@ -0,0 +1,79 @@
+package org.diagbot.common.push.filter;
+
+/**
+ * Created by louhr on 2019/8/31.
+ */
+public class PreResult {
+    private String detailName;
+    private String uniqueName;
+    private Double maxValue;
+    private Double minValue;
+    private String name;
+    private String otherValue;
+    private String units;
+    private Double value;
+
+    public String getDetailName() {
+        return detailName;
+    }
+
+    public void setDetailName(String detailName) {
+        this.detailName = detailName;
+    }
+
+    public String getUniqueName() {
+        return uniqueName;
+    }
+
+    public void setUniqueName(String uniqueName) {
+        this.uniqueName = uniqueName;
+    }
+
+    public Double getMaxValue() {
+        return maxValue;
+    }
+
+    public void setMaxValue(Double maxValue) {
+        this.maxValue = maxValue;
+    }
+
+    public Double getMinValue() {
+        return minValue;
+    }
+
+    public void setMinValue(Double minValue) {
+        this.minValue = minValue;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getOtherValue() {
+        return otherValue;
+    }
+
+    public void setOtherValue(String otherValue) {
+        this.otherValue = otherValue;
+    }
+
+    public String getUnits() {
+        return units;
+    }
+
+    public void setUnits(String units) {
+        this.units = units;
+    }
+
+    public Double getValue() {
+        return value;
+    }
+
+    public void setValue(Double value) {
+        this.value = value;
+    }
+}

+ 45 - 0
common-push/src/main/java/org/diagbot/common/push/filter/PretreatmentFilter.java

@@ -0,0 +1,45 @@
+package org.diagbot.common.push.filter;
+
+
+import org.diagbot.common.push.filter.pretreat.Pretreatment;
+import org.diagbot.common.push.filter.pretreat.PretreatmentSymptom;
+import org.diagbot.common.push.filter.pretreat.PretreatmentVital;
+import org.diagbot.common.work.SearchData;
+import org.springframework.util.StringUtils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class PretreatmentFilter {
+    public void crisisFilter(SearchData searchData) throws java.io.IOException {
+        //将数值类型内容全部转换为标准术语  依据kl_rule提供规则
+
+        List<PreResult> allPreResultList = new ArrayList<>();
+        //症状数据
+        if (!StringUtils.isEmpty(searchData.getSymptom())) {
+            searchData.setSymptom(add2PreResultList(new PretreatmentSymptom(), searchData.getSymptom(), allPreResultList));
+        }
+        //体征数据
+        if (!StringUtils.isEmpty(searchData.getVital())) {
+            searchData.setVital(add2PreResultList(new PretreatmentVital(), searchData.getVital(), allPreResultList));
+        }
+        //lis文本非结构化数据
+        if (!StringUtils.isEmpty(searchData.getLis())) {
+            searchData.setLis(add2PreResultList(new PretreatmentVital(), searchData.getLis(), allPreResultList));
+        }
+        //pacs数据
+        if (!StringUtils.isEmpty(searchData.getPacs())) {
+            searchData.setPacs(add2PreResultList(new PretreatmentVital(), searchData.getPacs(), allPreResultList));
+        }
+    }
+
+    private String add2PreResultList(Pretreatment pretreatment, String content, List<PreResult> allPreResultList) throws java.io.IOException {
+        List<PreResult> preResultList = pretreatment.analyze(content);
+        if (preResultList != null) {
+            allPreResultList.addAll(preResultList);
+
+
+        }
+        return content;
+    }
+}

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

@@ -0,0 +1,88 @@
+package org.diagbot.common.push.filter.pretreat;
+
+import org.diagbot.common.push.filter.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.springframework.util.StringUtils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created by louhr on 2019/8/31.
+ */
+public abstract class Pretreatment {
+    protected NegativeEnum[] nees_time_and_unit = new NegativeEnum[]{NegativeEnum.EVENT_TIME, NegativeEnum.UNIT};
+
+    protected int cursor = 0;
+
+    public abstract List<PreResult> analyze(String content) throws java.io.IOException;
+
+    abstract PreResult createPreResult(LexemePath<Lexeme> lexemes, Lexeme lexeme, int index);
+
+    protected List<PreResult> analyzeDefault(String content) throws java.io.IOException{
+        LexemePath<Lexeme> lexemes = ParticipleUtil.participle(content);
+
+        List<PreResult> preResultList = new ArrayList<>();
+        for (int i = 0; i < lexemes.size(); i++) {
+            Lexeme l = lexemes.get(i);
+            if (NlpUtil.isFeature(l.getProperty(), nees_time_and_unit)) {
+                PreResult result = data2Object(lexemes, l, i, l.getProperty());
+                if (result != null) {
+                    preResultList.add(result);
+                }
+            }
+        }
+        return preResultList;
+    }
+
+    protected PreResult data2Object(LexemePath<Lexeme> lexemes, Lexeme lexeme, int index, String property) {
+        if (index < 2) {
+            return null;
+        }
+        return createPreResult(lexemes, lexeme, index);
+    }
+
+    public PreResult createDefaultPreResult(LexemePath<Lexeme> lexemes, Lexeme lexeme, int 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(value);
+        result.setUnits(lexeme.getText());
+        result.setDetailName(text);
+        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 ("×".equals(leftLexeme.getText())) {
+            if  (cursor <= 0) return -1;
+            cursor--;
+            leftLexeme = lexemes.get(cursor);
+        }
+        if (NlpUtil.isNumberString(leftLexeme)) {
+            return NlpUtil.numberText2value(leftLexeme);
+        }
+        return -1;
+    }
+
+    protected String findBodyValue(LexemePath<Lexeme> lexemes, Lexeme lexeme, int index) {
+        if (cursor > 0) cursor--;
+        Lexeme leftLexeme = lexemes.get(cursor);
+        if (NlpUtil.isFeature(leftLexeme.getProperty(), new NegativeEnum[]{NegativeEnum.VITAL_INDEX,
+                NegativeEnum.VITAL_INDEX_VALUE, NegativeEnum.VITAL_RESULT, NegativeEnum.SYMPTOM})) {
+            return leftLexeme.getText();
+        }
+        return null;
+    }
+}

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

@@ -0,0 +1,41 @@
+package org.diagbot.common.push.filter.pretreat;
+
+import org.diagbot.common.push.filter.PreResult;
+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 PretreatmentLis extends Pretreatment {
+    public List<PreResult> analyze(String content) throws java.io.IOException{
+        return super.analyzeDefault(content);
+    }
+
+    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;
+        //继续往前找化验明细项
+        if (cursor > 0) cursor--;
+        Lexeme leftLexeme = lexemes.get(cursor);
+        if (NlpUtil.isFeature(leftLexeme.getProperty(), new NegativeEnum[]{NegativeEnum.LIS_NAME})) {
+            result.setDetailName(leftLexeme.getText());
+        } 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(leftLexeme.getText());
+                break;
+            }
+            position--;
+        }
+        return result;
+    }
+}

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

@@ -0,0 +1,17 @@
+package org.diagbot.common.push.filter.pretreat;
+
+import org.diagbot.common.push.filter.PreResult;
+import org.diagbot.nlp.participle.word.Lexeme;
+import org.diagbot.nlp.participle.word.LexemePath;
+
+import java.util.List;
+
+public class PretreatmentSymptom extends Pretreatment {
+    public List<PreResult> analyze(String content) throws java.io.IOException{
+        return super.analyzeDefault(content);
+    }
+
+    public PreResult createPreResult(LexemePath<Lexeme> lexemes, Lexeme lexeme, int index) {
+        return super.createDefaultPreResult(lexemes, lexeme, index);
+    }
+}

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

@@ -0,0 +1,17 @@
+package org.diagbot.common.push.filter.pretreat;
+
+import org.diagbot.common.push.filter.PreResult;
+import org.diagbot.nlp.participle.word.Lexeme;
+import org.diagbot.nlp.participle.word.LexemePath;
+
+import java.util.List;
+
+public class PretreatmentVital extends Pretreatment {
+    public List<PreResult> analyze(String content) throws java.io.IOException{
+        return super.analyzeDefault(content);
+    }
+
+    public PreResult createPreResult(LexemePath<Lexeme> lexemes, Lexeme lexeme, int index) {
+        return super.createDefaultPreResult(lexemes, lexeme, index);
+    }
+}

+ 8 - 0
common-service/src/main/java/org/diagbot/common/javabean/MedicalIndication.java

@@ -7,6 +7,7 @@ import java.util.List;
  */
 public class MedicalIndication {
     private String name;
+    private String rule;
     private List<MedicalIndicationDetail> details;
 
     public String getName() {
@@ -17,6 +18,12 @@ public class MedicalIndication {
         this.name = name;
     }
 
+    public String getRule() {
+        return rule;
+    }
+
+    public void setRule(String rule) { this.rule = rule; }
+
     public List<MedicalIndicationDetail> getDetails() {
         return details;
     }
@@ -24,4 +31,5 @@ public class MedicalIndication {
     public void setDetails(List<MedicalIndicationDetail> details) {
         this.details = details;
     }
+
 }

+ 1 - 1
common-service/src/main/java/org/diagbot/common/javabean/MedicalIndicationDetail.java

@@ -3,7 +3,7 @@ package org.diagbot.common.javabean;
 import com.alibaba.fastjson.JSONObject;
 
 public class MedicalIndicationDetail {
-    private Integer type;//1-量表,2-公式,3-其他指标
+    private Integer type;//1-量表,2-公式,3-其他指标,4-危急值
     private JSONObject content;
 
     public Integer getType() {

+ 59 - 0
common-service/src/main/java/org/diagbot/common/javabean/Rule.java

@@ -0,0 +1,59 @@
+package org.diagbot.common.javabean;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 触发规则
+ * @author Mark Huang
+ * @since 27/08/2019
+ */
+@Getter
+@Setter
+public class Rule {
+    // 套餐名称
+    private String set_name;
+    // 指标名称
+    private String idx_name;
+    // 最小值操作符
+    private String min_operator;
+    // 最小值
+    private String min_value;
+    // 最小值单位
+    private String min_unit;
+    // 最大值操作符
+    private String max_operator;
+    // 最大值
+    private String max_value;
+    // 最大值单位
+    private String max_unit;
+    // 相等操作符
+    private String eq_operator;
+    // 等于值
+    private String eq_value;
+    // 等于值单位
+    private String eq_unit;
+    // 推送名称
+    private String remind;
+
+    public Rule() { }
+
+    public Rule(String[] elements) {
+//        Rule rule = new Rule();
+
+        if (elements.length == 12) {
+            this.set_name = (null == elements[0])?"":elements[0];
+            this.idx_name = (null == elements[1])?"":elements[1];
+            this.min_operator = (null == elements[2])?"":elements[2];
+            this.min_value = (null == elements[3])?"":elements[3];
+            this.min_unit = (null == elements[4])?"":elements[4];
+            this.max_operator = (null == elements[5])?"":elements[5];
+            this.max_value = (null == elements[6])?"":elements[6];
+            this.max_unit = (null == elements[7])?"":elements[7];
+            this.eq_operator = (null == elements[8])?"":elements[8];
+            this.eq_value = (null == elements[9])?"":elements[9];
+            this.eq_unit = (null == elements[10])?"":elements[10];
+            this.remind = (null == elements[11])?"":elements[11];
+        }
+    }
+}

+ 30 - 0
common-service/src/main/java/org/diagbot/common/work/SearchData.java

@@ -32,6 +32,12 @@ public class SearchData {
     protected String diag = "";
     protected String past = "";
     protected String other = "";
+    //当前开单lis项目
+    protected String lisOrder = "";
+    //当前开单pacs项目
+    protected String pacsOrder = "";
+    //当前开单其他 预留
+    protected String otherOrder = "";
     //大数据推送诊断结果信息
     protected List<FeatureRate> pushDiags = new ArrayList<>();
 
@@ -262,4 +268,28 @@ public class SearchData {
     public void setGraphInputs(Map<String, Map<String, String>> graphInputs) {
         this.graphInputs = graphInputs;
     }
+
+    public String getLisOrder() {
+        return lisOrder;
+    }
+
+    public void setLisOrder(String lisOrder) {
+        this.lisOrder = lisOrder;
+    }
+
+    public String getPacsOrder() {
+        return pacsOrder;
+    }
+
+    public void setPacsOrder(String pacsOrder) {
+        this.pacsOrder = pacsOrder;
+    }
+
+    public String getOtherOrder() {
+        return otherOrder;
+    }
+
+    public void setOtherOrder(String otherOrder) {
+        this.otherOrder = otherOrder;
+    }
 }

+ 42 - 5
graph-web/src/main/java/org/diagbot/graphWeb/work/GraphCalculate.java

@@ -47,8 +47,7 @@ public class GraphCalculate {
         int age = searchData.getAge();
         String sex = searchData.getSex();
         logger.info("前端传来的年龄为 :"+age+" 前端传来的性别为 :"+sex);
-        //获取缓存
-//        Map<String, String> lexionCache = CacheUtil.getLexionCache();
+
         Map<String, Map<String, String>> sexAgeCache = CacheUtil.getSexAgeCache();
         Map<String, Map<String, String>> inputs = searchData.getGraphInputs();
         Set<String> ss = new HashSet<>();
@@ -152,14 +151,19 @@ public class GraphCalculate {
                 responseData.setManagementEvaluation(mangementEvaluation1);
             }
         }
-
+        String pacsOrder = searchData.getPacsOrder();
         //指标推送
         if (featureTypeList.contains("22") ) {
+            List<MedicalIndication> pacsMi = getPacsMi(pacsOrder, inputList,webDiag);
             //查找指标
             Set<String> indSet = neo4jAPI.getInd((String[]) inputList.toArray(new String[inputList.size()]));
             logger.info("featureTypeList 包含22,走指标推送!!!,图谱推出的指标为:" + indSet);
-            List<MedicalIndication> idn = neo4jAPI.getIdn(indSet, age, sex);
-            responseData.setMedicalIndications(idn);
+            if(indSet.contains("肾功能不全")){
+                List<MedicalIndication> idn = neo4jAPI.getIdn(indSet, age, sex);
+                pacsMi.addAll(idn);
+                responseData.setMedicalIndications(pacsMi);
+            }
+            responseData.setMedicalIndications(pacsMi);
 
         }
 
@@ -170,6 +174,39 @@ public class GraphCalculate {
         System.out.println("Total takes: " + (System.currentTimeMillis()-starttime)/1000d + 's');
         return responseData;
     }
+    public List<MedicalIndication> getPacsMi(String pacsOrder,List<String> inputList,String webDiag){
+        if(StringUtils.isNotEmpty(webDiag)){
+            String[] webDiagsplits = webDiag.split(",|,|、|;|:|;");
+            for (String wd:webDiagsplits
+                 ) {
+                inputList.add(wd);
+            }
+        }
+
+        List<MedicalIndication> pacsMi = new ArrayList<>();
+        Map<String, String> newInd = neo4jAPI.getNewInd((String[]) inputList.toArray(new String[inputList.size()]));
+        if(StringUtils.isNotEmpty(pacsOrder)){
+            String[] pacsOrders = pacsOrder.split(",|,");
+            for (String pacs:pacsOrders) {
+                if(newInd.containsKey(pacs)){
+                    String causes = newInd.get(pacs);
+                    MedicalIndication m = new MedicalIndication();
+                    List<MedicalIndicationDetail> mds = new ArrayList<>();
+                    MedicalIndicationDetail medicalIndicationDetail = new MedicalIndicationDetail();
+                    medicalIndicationDetail.setType(4);
+                    JSONObject jsonObject = new JSONObject();
+                    jsonObject.put("name", causes);
+                    jsonObject.put("controlType",2);
+                    medicalIndicationDetail.setContent(jsonObject);
+                    mds.add(medicalIndicationDetail);
+                    m.setName("不建议做:"+pacs);
+                    m.setDetails(mds);
+                    pacsMi.add(m);
+                }
+            }
+        }
+        return pacsMi;
+    }
 //    诊断过滤
     public void filterDis(List<FeatureRate> graphFeatureRates,String sex,Integer age) throws Exception {
         if(neo4jAPI == null){

+ 48 - 1
graph/src/main/java/org/diagbot/graph/jdbc/Neo4jAPI.java

@@ -1146,7 +1146,54 @@ public class Neo4jAPI {
         }
     }
 
-
+    /**
+     * 指标推送,检查预警
+     */
+    public Map<String,String> getNewInd(String[] keys) {
+        //查找指标推送
+        Map<String ,String> indMap = new HashMap<>();
+        List<String> fildList = new ArrayList<>();
+        for (String fild : keys) {
+            fildList.add("\"" + fild.trim() + "\"");
+        }
+        logger.info("根据 " + fildList + " 这些词推送指标!!!");
+        Session session = null;
+        StatementResult result = null;
+        String query = "";
+        try {
+            session = driver.session(AccessMode.WRITE);
+            //第一步查询输入的词所在number
+            query = "match(t:Temporary)-[r:属于]->(n:NewCondition)-[r1:诊断依据]->(n1:NewCondition)-[r2:拟诊]->(n2:NewIndicators) \n" +
+                    "where t.name in "+fildList+" return n2.name as name";
+            System.out.println(query);
+            result = session.run(query);
+            while (result.hasNext()) {
+                Record record = result.next();
+                String newIndName = record.get("name").toString();
+                StringBuffer s = new StringBuffer();
+                query = "match(n2:NewIndicators)-[r:表现]->(t:Temporary) where n2.name="+newIndName+" return collect(t.name) as names";
+                StatementResult sr = session.run(query);
+                while (sr.hasNext()){
+                    Record next = sr.next();
+                    List<Object> names = next.get("names").asList();
+                    if(names.size()>0){
+                        for (Object o:names) {
+
+                            if(fildList.indexOf("\""+o.toString()+"\"") >= 0){
+                                s.append(o.toString().replace("\"", ""));
+                            }
+                        }
+                    }
+                }
+                indMap.put(newIndName.replace("\"", ""),s.toString());
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            CloseSession(session);
+            return indMap;
+        }
+    }
     /**
      * 多疾病下治疗方案
      *

+ 2 - 2
graph/src/main/resources/bolt.properties

@@ -5,7 +5,7 @@ pass_235 = diagbot@20180822
 
 # neo4j bolt credentials
 #\u7EBF\u4E0A\u4F7F\u7528
-bolt.uri=bolt://192.168.2.233
+bolt.uri=bolt://192.168.2.234
 bolt.user=neo4j
 bolt.passwd=root
 
@@ -87,7 +87,7 @@ searchDifferentialDiagnose=match(d:Disease)-[r:\u9274\u522B\u8BCA\u65AD]->(h) wh
 searchEmergency=match(d:Disease) where d.name in disList return d.name as emDis,d.emergency as em
 
 #\u67E5\u627E\u6307\u6807\u7684\u8BED\u53E5
-searchIndication=match (n:Condition)-[r:\u786E\u8BCA|:\u62DF\u8BCA]->(m:Indicators)\n \
+    searchIndication=match (n:Condition)-[r:\u786E\u8BCA|:\u62DF\u8BCA]->(m:Indicators)\n \
 where n.name in fildList\n \
 with distinct m,r\n \
 return m.name as name

+ 2 - 2
graphdb/src/main/resources/application.yml

@@ -6,14 +6,14 @@ spring:
     active: local
   data:
     neo4j:
-      uri: bolt://192.168.2.233:7687
+      uri: bolt://192.168.2.234:7687
       username: neo4j
       password: root
 
 # 驱动配置信息
   datasource:
     driver-class-name: org.neo4j.jdbc.Driver
-    url: jdbc:neo4j:http://192.168.2.233:7474
+    url: jdbc:neo4j:http://192.168.2.234:7474
     username: neo4j
     password: root
     #定义初始连接数

+ 40 - 1
nlp/src/main/java/org/diagbot/nlp/util/NlpUtil.java

@@ -2,7 +2,7 @@ package org.diagbot.nlp.util;
 
 import org.diagbot.nlp.participle.word.Lexeme;
 
-import java.util.Arrays;
+import java.util.*;
 
 /**
  * @Auther: fyeman
@@ -11,6 +11,20 @@ import java.util.Arrays;
  */
 public class NlpUtil {
 
+    private static List numtextList = new ArrayList(Arrays.asList("数", "多", "半", "一", "二", "三", "四", "五", "六", "七", "八", "九", "十"));
+    private static  Map<String, String> numtextMap = new HashMap<String, String>(){{
+        put("一","1");
+        put("二","2");
+        put("三","3");
+        put("四","4");
+        put("五","5");
+        put("六","6");
+        put("七","7");
+        put("八","8");
+        put("九","9");
+        put("十","10");
+    }};
+
     public static String[] extendsSymbol(String[] origin, String[] extend_symbols) {
         String[] symbols = new String[origin.length + extend_symbols.length];
         System.arraycopy(origin, 0, symbols, 0, origin.length);
@@ -33,6 +47,31 @@ public class NlpUtil {
         return false;
     }
 
+    public static double numberText2value(Lexeme l) {
+        double value = 0.0;
+        if (numtextList.contains(l.getText())) {
+            if ("数".equals(l.getText()) || "多".equals(l.getText())) {     //数年直接按5年处理
+                value = 5;
+            } else if ("半".equals(l.getText())) {
+                value = 0.5;
+            } else {
+                value = Double.valueOf(numtextMap.get(l.getText()));
+            }
+        } else {
+            try {
+                value = Double.valueOf(l.getText());
+            } catch (Exception nfe) {
+                if (l.getText().indexOf("-") > -1) {
+                    try {
+                        value = Double.valueOf(l.getText().split("-")[0]);
+                    } catch (Exception e) {
+                    }
+                }
+            }
+        }
+        return value;
+    }
+
     public static boolean isFeature(String property, NegativeEnum[] features) {
         if (property == null) {
             return false;

+ 7 - 0
pom.xml

@@ -253,6 +253,13 @@
             <artifactId>fastjson</artifactId>
             <version>1.2.46</version>
         </dependency>
+
+        <!-- https://mvnrepository.com/artifact/org.mongodb/bson -->
+        <dependency>
+            <groupId>org.mongodb</groupId>
+            <artifactId>bson</artifactId>
+            <version>3.10.1</version>
+        </dependency>
     </dependencies>
 
     <!-- .properties xml进行打包 -->

+ 10 - 4
push-web/src/main/java/org/diagbot/push/controller/AlgorithmController.java

@@ -29,6 +29,7 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.ResponseBody;
+import org.diagbot.push.convert.PreProcess;
 
 import javax.servlet.http.HttpServletRequest;
 import java.util.*;
@@ -120,10 +121,15 @@ public class AlgorithmController extends BaseController {
     }
 
     public Response<ResponseData> combine(HttpServletRequest request, SearchData searchData) throws Exception {
+        logger.info("开始规则转换......");
+        PreProcess prepro = new PreProcess();
+        searchData = prepro.processClinicalData(searchData);
+        ResponseData RuleResponseData = prepro.applyrules(searchData);
+
         logger.info("开始推送服务......");
         Response<ResponseData> response = new Response();
         AlgorithmCore core = new AlgorithmCore();
-        ResponseData bigDataResponseData = core.algorithm(request, searchData);
+        ResponseData bigDataResponseData = core.algorithm(request, searchData, RuleResponseData);
 
         GraphCalculate graphCalculate = new GraphCalculate();
         ResponseData graphResponseData = graphCalculate.calculate(request, searchData);
@@ -157,7 +163,7 @@ public class AlgorithmController extends BaseController {
         List<MedicalIndication> medicalIndications = graphResponseData.getMedicalIndications();
         if (medicalIndications != null && medicalIndications.size() > 0) {
             logger.info("指标推送!!!!!!!!!");
-            bigDataResponseData.setMedicalIndications(medicalIndications);
+           bigDataResponseData.getMedicalIndications().addAll(medicalIndications);
         }
         //推送管理评估
         bigDataResponseData.setManagementEvaluation(graphResponseData.getManagementEvaluation());
@@ -172,11 +178,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)){
+        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)){
+        if(featureList.contains(Constants.feature_type_vital) && vitals.size() > 0){
             bigDataResponseData.setVitals(vitals);
         }
 

+ 1 - 0
push-web/src/main/java/org/diagbot/push/controller/CacheFileManagerController.java

@@ -43,6 +43,7 @@ public class CacheFileManagerController extends BaseController {
         ApplicationCacheUtil.createDoc_result_mapping_diag_map();
         ApplicationCacheUtil.createDoc_result_mapping_filter_map();
         ApplicationCacheUtil.createKl_result_mapping_standword_map();
+        ApplicationCacheUtil.create_rule_filter_map();
         return response;
     }
 }

+ 375 - 0
push-web/src/main/java/org/diagbot/push/convert/PreProcess.java

@@ -0,0 +1,375 @@
+package org.diagbot.push.convert;
+
+import com.alibaba.fastjson.JSONObject;
+import org.diagbot.bigdata.common.ApplicationCacheUtil;
+import org.diagbot.common.javabean.MedicalIndication;
+import org.diagbot.common.javabean.MedicalIndicationDetail;
+import org.diagbot.common.javabean.Rule;
+import org.diagbot.common.work.LisDetail;
+import org.diagbot.common.work.ResponseData;
+import org.diagbot.common.work.SearchData;
+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.Constants;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+public class PreProcess {
+
+    private static String up = "升高";
+    private static String down = "降低";
+    private static String normal = "正常";
+
+    private static String pos = "阳性";
+    private static String neg = "阴性";
+
+    private List<Map<String, Object>> vitlist = new ArrayList<>();
+    private List<Map<String, Object>> pacslist = new ArrayList<>();
+    private String[] vitkeyset = {"index", "value", "unit"};
+    private String[] bptype = {"血压","收缩压","舒张压","/"};
+
+    /**
+     * 处理临床数据
+     *
+     * @param searchdata
+     * @return ResponseData
+     */
+    public SearchData processClinicalData(SearchData searchdata) {
+        SearchData sData = searchdata;
+
+        sData.setLisArr(processLis(sData.getLisArr()));
+
+        if (sData.getLisArr().size() > 0) {
+            List<String> otherVal = sData.getLisArr().stream().map(lisArr -> lisArr.getOtherValue()).collect(Collectors.toList());
+            sData.setLis(String.join(",", otherVal));
+        }
+
+        return sData;
+    }
+
+    public ResponseData applyrules(SearchData sData) {
+
+        ResponseData ruleResponse = new ResponseData();
+
+        List<MedicalIndication> reminder;
+        try {
+            Map<String, List<Rule>> rule = ApplicationCacheUtil.get_rule_filter_map();
+
+            // 用规则处理化验结果
+            reminder = applytolis(sData.getLisArr(), rule);
+
+            // 用规则处理辅检结果
+            reminder.addAll(applytopacs(sData.getPacs(), rule));
+
+            // 用规则处理体征结果
+            reminder.addAll(applytovital(sData.getVital(), rule));
+
+            ruleResponse.setMedicalIndications(reminder);
+
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        } finally {
+            return ruleResponse;
+        }
+    }
+
+    private List<MedicalIndication> applytolis(List<LisDetail> lisarr, Map<String, List<Rule>> rule) {
+
+        List<MedicalIndication> reminder = new ArrayList<>();
+        try {
+            String name;
+            String detail;
+
+            for (LisDetail lis : lisarr) {
+                detail = lis.getDetailName();
+//                name = lis.getName();
+                String key = detail;
+                if (rule.get(key) != null) {
+                    reminder.addAll(comparelis(rule.get(key), lis));
+                }
+            }
+
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        } finally {
+            return reminder;
+        }
+    }
+
+    private List<MedicalIndication> applytopacs(String pacs, Map<String, List<Rule>> rule) {
+        List<MedicalIndication> reminder = new ArrayList<>();
+
+        try {
+            Set<String> pacsResultList = new HashSet<>();
+            Lexeme lexeme;
+            LexemePath<Lexeme> lexemes = ParticipleUtil.participle(pacs);
+            for (int i = 0; i < lexemes.size(); i++) {
+                lexeme = lexemes.get(i);
+                List<String> propetys = Arrays.asList(lexeme.getProperty().split(","));
+                if (lexeme.getText().trim().length() > 0) {
+                    if(propetys.contains(Constants.word_property_PACS_Result)){
+                        pacsResultList.add(lexeme.getText());
+                    }
+                }
+            }
+            if(pacsResultList.size()>0){
+                for (String pacsResult:pacsResultList) {
+                    if(rule.containsKey(pacsResult)){
+                        List<Rule> rules = rule.get(pacsResult);
+
+                        List<MedicalIndicationDetail> mds = new ArrayList<>();
+                        MedicalIndicationDetail medicalIndicationDetail = new MedicalIndicationDetail();
+                        medicalIndicationDetail.setType(4);
+                        JSONObject jsonObject = new JSONObject();
+                        jsonObject.put("controlType",2);
+                        jsonObject.put("name",pacsResult);
+                        medicalIndicationDetail.setContent(jsonObject);
+                        mds.add(medicalIndicationDetail);
+                        MedicalIndication medicalIndication = new MedicalIndication();
+                        medicalIndication.setName(rules.get(0).getIdx_name()+","+rules.get(0).getRemind());
+                        medicalIndication.setDetails(mds);
+                        reminder.add(medicalIndication);
+                    }
+                }
+            }
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        } finally {
+            return reminder;
+        }
+    }
+
+    private List<MedicalIndication> applytovital(String vital, Map<String, List<Rule>> rule) {
+
+        List<MedicalIndication> reminder = new ArrayList<>();
+
+        try {
+            Map<String, Object> vitobj = new HashMap<>();
+            Lexeme lexeme;
+            LexemePath<Lexeme> lexemes = ParticipleUtil.participle(vital);
+            for (int i=0; i<lexemes.size(); i++) {
+                lexeme = lexemes.get(i);
+                if (lexeme.getText().trim().length() > 0) {
+                    if (lexeme.getProperty().equals(Constants.word_property_vital_idx)) {
+                        vitobj = new HashMap<>();
+                        vitobj.put(vitkeyset[0], lexeme.getText());
+                    } else if (lexeme.getProperty().equals(Constants.word_property_number) &&
+                            vitobj.get(vitkeyset[0]) != null) {
+                        vitobj.put(vitkeyset[1], lexeme.getText());
+                    } else if (lexeme.getProperty().equals(Constants.word_property_unit) &&
+                            vitobj.get(vitkeyset[1]) != null) {
+                        vitobj.put(vitkeyset[2], lexeme.getText());
+
+                        if (vitobj.get(vitkeyset[0]).toString().equals(bptype[0]) &&
+                                vitobj.get(vitkeyset[1]).toString().contains(bptype[3])) {
+                            String[] idx = Arrays.asList(bptype).subList(1,3).toArray(new String[2]);
+                            String[] vals = vitobj.get(vitkeyset[1]).toString().split(bptype[3]);
+                            String unit = vitobj.get(vitkeyset[2]).toString();
+
+                            if (idx.length == vals.length) {
+                                for (int j=0; j<idx.length; j++) {
+                                    vitobj = new HashMap<>();
+                                    vitobj.put(vitkeyset[0], idx[j]);
+                                    vitobj.put(vitkeyset[1], vals[j]);
+                                    vitobj.put(vitkeyset[2], unit);
+                                    vitlist.add(vitobj);
+                                }
+                            }
+                        } else {
+                            vitlist.add(vitobj);
+                        }
+                    }
+                }
+//                System.out.println(lexeme.getText() + ": " + lexeme.getProperty());
+            }
+
+            for (Map<String, Object> obj : vitlist) {
+                String idx = obj.get(vitkeyset[0]).toString();
+                if (rule.get(idx) != null) {
+                    reminder.addAll(comparevit(rule.get(idx), obj));
+                }
+            }
+            System.out.println("\n");
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        } finally {
+            return reminder;
+        }
+    }
+
+
+    private List<MedicalIndication> comparelis(List<Rule> rules, LisDetail lis) {
+        List<MedicalIndication> reminder = new ArrayList<>();
+
+        try {
+            String detailname = lis.getDetailName();
+            Double numval = lis.getValue();
+            String unit = lis.getUnits();
+            String otherval = lis.getOtherValue();
+
+            reminder = compare(rules, reminder, detailname, numval, unit, otherval);
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        } finally {
+            return reminder;
+        }
+    }
+
+    private List<MedicalIndication> comparevit(List<Rule> rules, Map<String, Object> vit) {
+        List<MedicalIndication> reminder = new ArrayList<>();
+
+        try {
+            String detailname = vit.get(vitkeyset[0]).toString();
+            Double numval = Double.valueOf(vit.get(vitkeyset[1]).toString());
+            String unit = vit.get(vitkeyset[2]).toString();
+            String otherval = "";
+
+            reminder = compare(rules, reminder, detailname, numval, unit, otherval);
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        } finally {
+            return reminder;
+        }
+    }
+
+    private List<MedicalIndication> compare(List<Rule> rules, List<MedicalIndication> reminder,
+                                            String detailname, Double numval, String unit, String otherval) {
+        boolean minmatch, maxmatch;
+        Double minval, maxval;
+        String minop, maxop, minunit, maxunit;
+
+        try {
+            if (null == numval && otherval.trim().length() > 0) {
+                for (Rule rule : rules) {
+                    if (rule.getEq_operator().equals("=") && otherval.contains(rule.getEq_value())) {
+                        StringBuffer rulesContent = new StringBuffer();
+                        StringBuffer append = rulesContent.append(rule.getIdx_name()).append(rule.getMin_operator()).append(rule.getMin_value()).append(rule.getMin_unit())
+                                .append(rule.getMax_operator()).append(rule.getMax_value()).append(rule.getMax_unit())
+                                .append(rule.getEq_operator()).append(rule.getEq_value()).append(rule.getEq_unit());
+                        MedicalIndication medind = new MedicalIndication();
+                        List<MedicalIndicationDetail> k = new ArrayList<>();
+                        MedicalIndicationDetail mid = new MedicalIndicationDetail();
+                        JSONObject jsonObject = new JSONObject();
+//                        jsonObject.put("name",detailname + ": " + otherval+ ", " +rule.getRemind());
+                        jsonObject.put("name",append.toString());
+                        jsonObject.put("controlType",2);
+                        mid.setType(4);
+                        mid.setContent(jsonObject);
+                        k.add(mid);
+                        medind.setName(rule.getRemind());
+                        medind.setDetails(k);
+                        medind.setRule(append.toString());
+                        reminder.add(medind);
+
+                        System.out.println(medind.getRule() + " -> " + medind.getName());
+                    }
+                }
+            } else if (String.valueOf(numval).trim().length() > 0 && unit.length() > 0){
+                for (Rule rule : rules) {
+                    minmatch = maxmatch = false;
+                    minval = (rule.getMin_value().length()==0)?0:Double.valueOf(rule.getMin_value());
+                    maxval = (rule.getMax_value().length()==0)?0:Double.valueOf(rule.getMax_value());
+                    minunit = rule.getMin_unit();
+                    maxunit = rule.getMax_unit();
+                    minop = rule.getMin_operator();
+                    maxop = rule.getMax_operator();
+
+                    if ( String.valueOf(minval).trim().length() > 0) {
+                        if (minunit.equals(unit) ) {
+                            switch (minop) {
+                                case ">":
+                                    if (numval > minval) { minmatch = true; }
+                                    break;
+                                case ">=":
+                                    if (numval >= minval) { minmatch = true; }
+                                    break;
+                            }
+                        } else { minmatch = false; }
+                    } else { minmatch = false; }
+
+                    if (String.valueOf(maxval).trim().length() > 0 ) {
+                        if (maxunit.equals(unit) ) {
+                            switch (maxop) {
+                                case "<":
+                                    if (numval < maxval) {
+                                        maxmatch = true;
+                                    }
+                                    break;
+                                case "<=":
+                                    if (numval <= maxval) {
+                                        maxmatch = true;
+                                    }
+                                    break;
+                            }
+                        } else { maxmatch = false; }
+                    } else { maxmatch = false; }
+
+                    if (minmatch  || maxmatch) {
+                        StringBuffer rulesContent = new StringBuffer();
+                        StringBuffer append = rulesContent.append(rule.getIdx_name()).append(rule.getMin_operator()).append(rule.getMin_value()).append(rule.getMin_unit())
+                                .append(rule.getMax_operator()).append(rule.getMax_value()).append(rule.getMax_unit());
+
+                        MedicalIndication medind = new MedicalIndication();
+                        List<MedicalIndicationDetail> k = new ArrayList<>();
+                        MedicalIndicationDetail mid = new MedicalIndicationDetail();
+                        JSONObject jsonObject = new JSONObject();
+//                        jsonObject.put("name",detailname + ": " + numval + " " + unit+ "," +rule.getRemind());
+                        jsonObject.put("name", append.toString());
+                        jsonObject.put("controlType",2);
+                        mid.setType(4);
+                        mid.setContent(jsonObject);
+                        k.add(mid);
+                        medind.setName(rule.getRemind());
+                        medind.setDetails(k);
+                        medind.setRule(append.toString());
+                        reminder.add(medind);
+
+                        System.out.println(medind.getRule() + " -> " + medind.getName());
+                    }
+                }
+            }
+
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        } finally {
+            return reminder;
+        }
+    }
+
+    private List<LisDetail> processLis(List<LisDetail> lisArr) {
+        if (lisArr == null) {
+            return new ArrayList<>();
+        }
+        if (lisArr.size() == 0) {
+            return lisArr;
+        }
+
+        String Otherval = "";
+
+        for (int i = 0; i < lisArr.size(); i++) {
+            LisDetail lisres = lisArr.get(i);
+
+//            Otherval = (lisres.getOtherValue().trim().length() > 0) ? lisres.getOtherValue().trim() + "\n" : "";
+            Otherval = lisres.getOtherValue();
+
+            if (Otherval.indexOf(pos) >= 0 || Otherval.indexOf(neg) >= 0) {
+                lisres.setOtherValue(lisres.getDetailName() + Otherval);
+            } else {
+                Otherval = (Otherval.trim().length() > 0) ? Otherval.trim() + "\n" : "";
+                if (lisres.getValue() == null) {
+                    continue;
+                } else if (lisres.getMaxValue() != null && lisres.getValue() > lisres.getMaxValue()) {
+                    lisres.setOtherValue(Otherval + lisres.getDetailName() + up);
+                } else if (lisres.getMinValue() != null && lisres.getValue() < lisres.getMinValue()) {
+                    lisres.setOtherValue(Otherval + lisres.getDetailName() + down);
+                } else {
+                    lisres.setOtherValue(Otherval + lisres.getDetailName() + normal);
+                }
+            }
+        }
+
+        return lisArr;
+    }
+}