Bläddra i källkod

Merge remote-tracking branch 'origin/push-grade' into push-test

kongwz 5 år sedan
förälder
incheckning
ea5dfb7964

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

@@ -233,7 +233,7 @@ public class ApplicationCacheUtil {
         String key;
 
         String[] labels = {"set_name","idx_name","min_operator","min_value","min_unit",
-                "max_operator","max_value","max_unit","remind"};
+                "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");

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

@@ -332,11 +332,11 @@ public class CacheFileManager {
 
             //规则过滤信息
             sql = "SELECT set_name, idx_name, min_operator, min_value, min_unit, max_operator, " +
-                    " max_value, max_unit, remind FROM kl_rule ";
+                    " 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;
+            String r6, r7, r8, r9, r10, r11, r12;
             while (rs.next()) {
                 r1 = rs.getString(1);
                 r2 = rs.getString(2);
@@ -347,8 +347,11 @@ public class CacheFileManager {
                 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));
+                        + "|" + r6 + "|" + r7 + "|" + r8 + "|" + r9 + "|" + r10 + "|" + r11 + "|" + r12));
                 fw.write("\n");
             }
             fw.close();

+ 19 - 10
common-service/src/main/java/org/diagbot/common/javabean/Rule.java

@@ -27,6 +27,12 @@ public class Rule {
     private String max_value;
     // 最大值单位
     private String max_unit;
+    // 相等操作符
+    private String eq_operator;
+    // 等于值
+    private String eq_value;
+    // 等于值单位
+    private String eq_unit;
     // 推送名称
     private String remind;
 
@@ -35,16 +41,19 @@ public class Rule {
     public Rule(String[] elements) {
 //        Rule rule = new Rule();
 
-        if (elements.length == 9) {
-            this.set_name = elements[0];
-            this.idx_name = elements[1];
-            this.min_operator = elements[2];
-            this.min_value = elements[3];
-            this.min_unit = elements[4];
-            this.max_operator = elements[5];
-            this.max_value = elements[6];
-            this.max_unit = elements[7];
-            this.remind = elements[8];
+        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];
         }
     }
 }

+ 80 - 20
push-web/src/main/java/org/diagbot/push/convert/PreProcess.java

@@ -26,6 +26,7 @@ public class PreProcess {
     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 = {"血压","收缩压","舒张压","/"};
 
@@ -56,8 +57,13 @@ public class PreProcess {
         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);
@@ -92,6 +98,49 @@ public class PreProcess {
         }
     }
 
+    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",rules.get(0).getIdx_name()+":"+rules.get(0).getRemind());
+                        medicalIndicationDetail.setContent(jsonObject);
+                        mds.add(medicalIndicationDetail);
+                        MedicalIndication medicalIndication = new MedicalIndication();
+                        medicalIndication.setName(pacsResult);
+                        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<>();
@@ -194,10 +243,11 @@ public class PreProcess {
         try {
             if (null == numval && otherval.trim().length() > 0) {
                 for (Rule rule : rules) {
-                    if (rule.getMin_operator().equals("=") && otherval.contains(rule.getMin_value())) {
+                    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.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();
@@ -210,6 +260,7 @@ public class PreProcess {
                         k.add(mid);
                         medind.setName(rule.getRemind());
                         medind.setDetails(k);
+                        medind.setRule(append.toString());
                         reminder.add(medind);
 
                         System.out.println(medind.getRule() + " -> " + medind.getName());
@@ -225,26 +276,34 @@ public class PreProcess {
                     minop = rule.getMin_operator();
                     maxop = rule.getMax_operator();
 
-                    if ( String.valueOf(minval).trim().length() > 0 && minunit.equals(unit) ) {
-                        switch (minop) {
-                            case ">":
-                                if (numval > minval) { minmatch = true; }
-                                break;
-                            case ">=":
-                                if (numval >= minval) { minmatch = true; }
-                                break;
-                        }
+                    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 && maxunit.equals(unit) ) {
-                        switch (maxop) {
-                            case "<":
-                                if (numval < maxval) { maxmatch = true; }
-                                break;
-                            case "<=":
-                                if (numval <= maxval) { maxmatch = true; }
-                                break;
-                        }
+                    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) {
@@ -264,6 +323,7 @@ public class PreProcess {
                         k.add(mid);
                         medind.setName(rule.getRemind());
                         medind.setDetails(k);
+                        medind.setRule(append.toString());
                         reminder.add(medind);
 
                         System.out.println(medind.getRule() + " -> " + medind.getName());