|
@@ -1,6 +1,5 @@
|
|
|
package org.diagbot.service.impl;
|
|
|
|
|
|
-import org.apache.commons.collections4.IterableUtils;
|
|
|
import org.diagbot.entity.node.LIS;
|
|
|
import org.diagbot.entity.node.Symptom;
|
|
|
import org.diagbot.mapper.KnowledgeMapper;
|
|
@@ -10,6 +9,8 @@ import org.diagbot.entity.node.Disease;
|
|
|
import org.diagbot.entity.node.base.BaseNode;
|
|
|
import org.apache.commons.collections4.IteratorUtils;
|
|
|
import org.diagbot.repository.*;
|
|
|
+import org.diagbot.vo.domain.FeatureRate;
|
|
|
+import org.diagbot.vo.domain.SearchData;
|
|
|
import org.neo4j.driver.v1.types.Node;
|
|
|
import org.neo4j.driver.v1.types.Path;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -19,7 +20,6 @@ import org.springframework.data.domain.Sort;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.*;
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
@Service
|
|
@@ -173,30 +173,106 @@ public class KnowledgeServiceImpl implements KnowledgeService {
|
|
|
return ndlist;
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public List<Map<String, Object>> findHighRiskDisease(QueryVo queryVo) {
|
|
|
- List<Map<String, Object>> hrlist = diseaseRepository.findHighRiskDisease(queryVo.getDiseaselist());
|
|
|
- return hrlist;
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
public Map<String, Object> getHighRiskDisease(SearchData searchData) {
|
|
|
String diag = searchData.getDiag();
|
|
|
String[] diseaseArray = diag.split(",|,|、");
|
|
|
List<String> diseaseList = Arrays.asList(diseaseArray);
|
|
|
-
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
List<Map<String, Object>> list = baseNodeRepository.getHighRisk(diseaseList);
|
|
|
-
|
|
|
for (Map hrmap:list) {
|
|
|
String name = hrmap.get("name").toString();
|
|
|
String risk = hrmap.get("risk").toString();
|
|
|
map.put(name, risk);
|
|
|
}
|
|
|
-
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Map<String, List<FeatureRate>> getLisPacs(SearchData searchData) {
|
|
|
+ Map<String, List<FeatureRate>> lisPacsFeature = new HashMap<>();
|
|
|
+ String webDiag = searchData.getDiag();
|
|
|
+ List<String> webDiagList = Arrays.asList(webDiag.split(",|,|、"));
|
|
|
+ List<FeatureRate> bigdataDiagFeature = searchData.getPushDiags();
|
|
|
+ List<String> bigdataDiagList =new LinkedList<>();
|
|
|
+ if(bigdataDiagFeature.size()>0){
|
|
|
+ for (FeatureRate fe:bigdataDiagFeature) {
|
|
|
+ if("neo4j".equals(fe.getRate())){
|
|
|
+ bigdataDiagList.add(fe.getFeatureName());
|
|
|
+ }else {
|
|
|
+ bigdataDiagList.add(fe.getFeatureName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (String web: webDiagList ) {
|
|
|
+ for (int i=0;i<bigdataDiagList.size();i++ ) {
|
|
|
+ if(bigdataDiagList.get(i).equals(web)){
|
|
|
+ bigdataDiagList.remove(bigdataDiagList.get(i));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Map<String, Set<String>> weblisPacs =null;
|
|
|
+ Map<String, Set<String>> biglisPacs =null;
|
|
|
+ if(webDiagList !=null && webDiagList.size()>0){
|
|
|
+ weblisPacs = processLisPacs(webDiagList);
|
|
|
+ }
|
|
|
+ if(bigdataDiagList !=null && bigdataDiagList.size()>0){
|
|
|
+ biglisPacs = processLisPacs(bigdataDiagList);
|
|
|
+ }
|
|
|
+ Set<String> lis =null;
|
|
|
+ Set<String> pacs =null;
|
|
|
+ //如果界面有诊断
|
|
|
+ if(weblisPacs !=null && weblisPacs.values().size()>0){
|
|
|
+ lis = weblisPacs.get("LIS");
|
|
|
+ pacs = weblisPacs.get("PACS");
|
|
|
+ if(biglisPacs !=null && biglisPacs.values().size()>0){
|
|
|
+ Set<String> bl = biglisPacs.get("LIS");
|
|
|
+ Set<String> bp= biglisPacs.get("PACS");
|
|
|
+ lis.addAll(bl);
|
|
|
+ pacs.addAll(bp);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ lis = biglisPacs.get("LIS");
|
|
|
+ pacs = biglisPacs.get("PACS");
|
|
|
+ }
|
|
|
+ ArrayList<FeatureRate> lisFeature = new ArrayList<>();
|
|
|
+ ArrayList<FeatureRate> pacsFeature = new ArrayList<>();
|
|
|
+ for (String l:lis) {
|
|
|
+ FeatureRate featureRate = new FeatureRate();
|
|
|
+ featureRate.setFeatureName(l);
|
|
|
+ lisFeature.add(featureRate);
|
|
|
+ }
|
|
|
+ for (String p:pacs) {
|
|
|
+ FeatureRate featureRate = new FeatureRate();
|
|
|
+ featureRate.setFeatureName(p);
|
|
|
+ pacsFeature.add(featureRate);
|
|
|
+ }
|
|
|
+ lisPacsFeature.put("lisList",lisFeature);
|
|
|
+ lisPacsFeature.put("pacsList",pacsFeature);
|
|
|
+ return lisPacsFeature;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Map<String, Set<String>> processLisPacs(List<String> webDiagList) {
|
|
|
+ Map<String, Set<String>> lisPacsMap = new HashMap<>();
|
|
|
+ List<String> lisArray = new ArrayList<>();
|
|
|
+ List<String> pacsArray = new ArrayList<>();
|
|
|
+ List<Map<String, Object>> lisPacsList = baseNodeRepository.getLisPacsList(webDiagList);
|
|
|
+ if(lisPacsList !=null && lisPacsList.size()>0){
|
|
|
+ for (Map<String, Object> f:lisPacsList) {
|
|
|
+ String label = f.get("label").toString();
|
|
|
+ String name = f.get("name").toString();
|
|
|
+ if("LIS".equals(label)){
|
|
|
+ lisArray.add(name);
|
|
|
+ }else if("PACS".equals(label)){
|
|
|
+ pacsArray.add(name);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ lisPacsMap.put("LIS",processList(lisArray));
|
|
|
+ lisPacsMap.put("PACS",processList(pacsArray));
|
|
|
+ return lisPacsMap;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public List<Map<String, Object>> getRecommendItem(QueryVo queryVo) {
|
|
|
List<Map<String, Object>> llist = relationRepository.getRecommendItem(queryVo.getDiseaselist());
|
|
@@ -273,4 +349,34 @@ public class KnowledgeServiceImpl implements KnowledgeService {
|
|
|
return path;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据出现次数排序,去重
|
|
|
+ * @param list
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Set<String> processList(List<String> list) {
|
|
|
+ Set<String> resultSet = new LinkedHashSet<>();
|
|
|
+ Map<String, Integer> featuerInt = new HashMap<String, Integer>();
|
|
|
+ for (String d : list) {
|
|
|
+ if (featuerInt.containsKey(d)) {
|
|
|
+ featuerInt.put(d, featuerInt.get(d) + 1);
|
|
|
+ } else {
|
|
|
+ featuerInt.put(d, 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<Map.Entry<String, Integer>> reslist = new ArrayList<Map.Entry<String, Integer>>(featuerInt.entrySet());
|
|
|
+ Collections.sort(reslist, new Comparator<Map.Entry<String, Integer>>() {
|
|
|
+ @Override
|
|
|
+ public int compare(Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2) {
|
|
|
+ return o2.getValue().compareTo(o1.getValue());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ for (Map.Entry<String, Integer> f : reslist
|
|
|
+ ) {
|
|
|
+ //排好序的set
|
|
|
+ resultSet.add(f.getKey());
|
|
|
+ }
|
|
|
+ return resultSet;
|
|
|
+ }
|
|
|
+
|
|
|
}
|