浏览代码

Lis结果做转换(数值转换成升高、降低、正常,文本直接存入otherValue)

hujing 5 年之前
父节点
当前提交
3c03e485fd

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

@@ -1,8 +1,8 @@
 ################################ model basic url ###################################
 
 #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=/opt/models/dev/models/model_version_replacement/model
+basicPath=F:/models/model_version_replacement/model
 
 ############################### current model version ################################
 diagnosisPredict.version=outpatient_556_IOE_1

+ 0 - 7
common-push/src/main/java/org/diagbot/common/push/filter/rule/PretreatmentRule.java

@@ -61,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);

+ 35 - 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,13 @@ 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) {
+            lisApplication.lisConvert(searchData.getLisArr());
+        } else if (searchData.getLis() != null) {
+            Pretreatment pretreatment = new PretreatmentLis();
+            lisApplication.lisConvert(pretreatment.analyze(searchData.getLis()));
+        }
         Response<ResponseData> response = new Response();
         //一些基本信息预处理 如年龄 性别
         ParamsDataProxy paramsDataProxy = new ParamsDataProxy();
@@ -170,11 +181,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 +204,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 +224,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 +254,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();
 

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

@@ -0,0 +1,77 @@
+package org.diagbot.rule.lis;
+
+import org.diagbot.nlp.rule.module.PreResult;
+import org.springframework.util.StringUtils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @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 List<PreResult> lisConvert(List<PreResult> preResultList) {
+        if (preResultList != null) {
+            for (PreResult result : preResultList) {
+                if (isNumber(result.getValue())) {
+                    if (!StringUtils.isEmpty(result.getMaxValue()) && !StringUtils.isEmpty(result.getMinValue())
+                            && isNormal(result.getValue(), result.getMaxValue(), result.getMinValue())) {
+                        result.setOtherValue(result.getUniqueName() + normal);
+                    } else if (!StringUtils.isEmpty(result.getMaxValue())
+                            && compareMax(result.getValue(), result.getMaxValue())) {
+                        result.setOtherValue(result.getUniqueName() + up);
+                    } else if (!StringUtils.isEmpty(result.getMinValue())
+                            && compareMin(result.getValue(), result.getMinValue())) {
+                        result.setOtherValue(result.getUniqueName() + down);
+                    }
+                } else {
+                    result.setOtherValue(result.getValue());
+                }
+            }
+        }
+        return preResultList;
+    }
+
+
+    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;
+    }
+}