Bladeren bron

Merge remote-tracking branch 'origin/push-dev-preprocess' into push-grade

louhr 5 jaren geleden
bovenliggende
commit
e98214a092

+ 7 - 2
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.*;
@@ -125,6 +126,10 @@ public class AlgorithmController extends BaseController {
         AlgorithmCore core = new AlgorithmCore();
         ResponseData bigDataResponseData = core.algorithm(request, searchData);
 
+        logger.info("开始规则转换......");
+        PreProcess prepro = new PreProcess();
+        searchData = prepro.processClinicalData(searchData);
+
         GraphCalculate graphCalculate = new GraphCalculate();
         ResponseData graphResponseData = graphCalculate.calculate(request, searchData);
         if (graphResponseData.getDis().size() > 0) {
@@ -172,11 +177,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);
         }
 

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

@@ -0,0 +1,68 @@
+package org.diagbot.push.convert;
+
+import org.diagbot.common.work.LisDetail;
+import org.diagbot.common.work.SearchData;
+
+import java.util.List;
+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 = "阴性";
+
+    /**
+     * 处理临床数据
+     *
+     * @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;
+    }
+
+    private List<LisDetail> processLis(List<LisDetail> lisArr) {
+        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;
+    }
+}