|
@@ -6,10 +6,12 @@ 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.ArrayList;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
public class PreProcess {
|
|
@@ -21,6 +23,10 @@ public class PreProcess {
|
|
|
private static String pos = "阳性";
|
|
|
private static String neg = "阴性";
|
|
|
|
|
|
+ private List<Map<String, Object>> vitlist = new ArrayList<>();
|
|
|
+ private String[] vitkeyset = {"index", "value", "unit"};
|
|
|
+ private String[] bptype = {"血压","收缩压","舒张压","/"};
|
|
|
+
|
|
|
/**
|
|
|
* 处理临床数据
|
|
|
*
|
|
@@ -48,7 +54,9 @@ public class PreProcess {
|
|
|
try {
|
|
|
Map<String, List<Rule>> rule = ApplicationCacheUtil.get_rule_filter_map();
|
|
|
|
|
|
- reminder = applytolis(sData, rule);
|
|
|
+ reminder = applytolis(sData.getLisArr(), rule);
|
|
|
+
|
|
|
+ applytovital(sData.getVital(), rule);
|
|
|
|
|
|
ruleResponse.setMedicalIndications(reminder);
|
|
|
|
|
@@ -59,11 +67,10 @@ public class PreProcess {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private List<MedicalIndication> applytolis(SearchData sData, Map<String, List<Rule>> rule) {
|
|
|
+ private List<MedicalIndication> applytolis(List<LisDetail> lisarr, Map<String, List<Rule>> rule) {
|
|
|
|
|
|
List<MedicalIndication> reminder = new ArrayList<>();
|
|
|
try {
|
|
|
- List<LisDetail> lisarr = sData.getLisArr();
|
|
|
String name;
|
|
|
String detail;
|
|
|
|
|
@@ -72,7 +79,7 @@ public class PreProcess {
|
|
|
// name = lis.getName();
|
|
|
String key = detail;
|
|
|
if (rule.get(key) != null) {
|
|
|
- reminder.addAll(compare(rule.get(key), lis));
|
|
|
+ reminder.addAll(comparelis(rule.get(key), lis));
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -83,11 +90,68 @@ public class PreProcess {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private List<MedicalIndication> compare(List<Rule> rules, LisDetail lis) {
|
|
|
+ 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();
|
|
|
+ for (String key: obj.keySet()) {
|
|
|
+ System.out.print(key + ": " + obj.get(key).toString() + "\t");
|
|
|
+ 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<>();
|
|
|
- boolean minmatch, maxmatch;
|
|
|
- Double minval, maxval;
|
|
|
- String minop, maxop, minunit, maxunit;
|
|
|
|
|
|
try {
|
|
|
String detailname = lis.getDetailName();
|
|
@@ -95,6 +159,38 @@ public class PreProcess {
|
|
|
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.getMin_operator().equals("=") && otherval.contains(rule.getMin_value())) {
|