|
@@ -170,37 +170,32 @@ public class PushFacade {
|
|
|
public PushDTO pushInner(PushVO pushVO, Integer mode) {
|
|
|
PushDTO pushDTO = new PushDTO();
|
|
|
SearchData Data = assembleData(pushVO);
|
|
|
- // ResponseData data = pushAI(searchData);
|
|
|
ResponseData data = pushAipt(Data);
|
|
|
|
|
|
+ //大数据返回内容
|
|
|
+ List<FeatureRate> dis = data.getDis();
|
|
|
+
|
|
|
String featureType = pushVO.getFeatureType();
|
|
|
String[] featureTypes = featureType.split(",|,");
|
|
|
Set<String> featureTypeSet = new HashSet(Arrays.asList(featureTypes));
|
|
|
|
|
|
- List<FeatureRate> symptom = data.getSymptom();
|
|
|
- List<FeatureRate> dis = data.getDis();
|
|
|
- List<FeatureRate> pacs = data.getPacs();
|
|
|
- List<FeatureRate> labs = data.getLabs();
|
|
|
- List<FeatureRate> other = data.getHistory();
|
|
|
- Map<String, JSONObject> treat = data.getTreat();
|
|
|
-
|
|
|
- Map<String, Object> symptomMap = list2Map(symptom);
|
|
|
- Map<String, Object> labMap = list2Map(labs);
|
|
|
- Map<String, Object> pacsMap = list2Map(pacs);
|
|
|
- Map<String, Object> otherMap = list2Map(other);
|
|
|
-
|
|
|
//症状 标签列表
|
|
|
if (featureTypeSet.contains(String.valueOf(QuestionTypeEnum.Symptom.getKey()))) {
|
|
|
- //文本模式不推症状,仅结构化模式推症状
|
|
|
- //if (mode.equals(InputModeEnum.Structured.getKey())) {
|
|
|
- List<QuestionDTO> symptomDTO = getTagListByMap(symptomMap, pushVO, QuestionTypeEnum.Symptom.getKey());
|
|
|
- pushDTO.setSymptom(symptomDTO);
|
|
|
- //}
|
|
|
+ List<FeatureRate> symptom = data.getSymptom();
|
|
|
+ if (ListUtil.isNotEmpty(symptom)) {
|
|
|
+ List<String> nameList = symptom.stream().map(featureRate -> featureRate.getFeatureName()).collect(Collectors.toList());
|
|
|
+ List<QuestionDTO> symptomDTO = getTagList(nameList, pushVO, QuestionTypeEnum.Symptom.getKey());
|
|
|
+ pushDTO.setSymptom(symptomDTO);
|
|
|
+ }
|
|
|
}
|
|
|
//其他史 标签列表
|
|
|
if (featureTypeSet.contains(String.valueOf(QuestionTypeEnum.Other.getKey()))) {
|
|
|
- List<QuestionDTO> otherDTO = getTagListByMap(otherMap, pushVO, QuestionTypeEnum.Other.getKey());
|
|
|
- pushDTO.setOther(otherDTO);
|
|
|
+ List<FeatureRate> other = data.getHistory();
|
|
|
+ if (ListUtil.isNotEmpty(other)) {
|
|
|
+ List<String> nameList = other.stream().map(featureRate -> featureRate.getFeatureName()).collect(Collectors.toList());
|
|
|
+ List<QuestionDTO> otherDTO = getTagList(nameList, pushVO, QuestionTypeEnum.Other.getKey());
|
|
|
+ pushDTO.setOther(otherDTO);
|
|
|
+ }
|
|
|
}
|
|
|
//查体 返回模板(标签列表)
|
|
|
if (featureTypeSet.contains(String.valueOf(QuestionTypeEnum.Vital.getKey()))) {
|
|
@@ -215,73 +210,87 @@ public class PushFacade {
|
|
|
}
|
|
|
//化验 标签列表
|
|
|
if (featureTypeSet.contains(String.valueOf(QuestionTypeEnum.Lis.getKey()))) {
|
|
|
- //公表项转套餐项
|
|
|
- Map<String, List<String>> lisMapping = lisMappingFacade.getLisMappingByUniqueName();
|
|
|
- Map<String, Object> mealLabMap = new LinkedHashMap<>();
|
|
|
- for (Map.Entry<String, Object> entry : labMap.entrySet()) {
|
|
|
- if (ListUtil.isNotEmpty(lisMapping.get(entry.getKey()))) {
|
|
|
- //匹配出多个套餐项默认取第一个
|
|
|
- mealLabMap.put(lisMapping.get(entry.getKey()).get(0), null);
|
|
|
+ List<FeatureRate> labs = data.getLabs();
|
|
|
+ if (ListUtil.isNotEmpty(labs)) {
|
|
|
+ //公表项转套餐项
|
|
|
+ Map<String, List<String>> lisMapping = lisMappingFacade.getLisMappingByUniqueName();
|
|
|
+ List<String> nameList = Lists.newLinkedList();
|
|
|
+ for (FeatureRate featureRate : labs) {
|
|
|
+ if (ListUtil.isNotEmpty(lisMapping.get(featureRate.getFeatureName()))) {
|
|
|
+ //匹配出多个套餐项默认取第一个
|
|
|
+ String name = lisMapping.get(featureRate.getFeatureName()).get(0);
|
|
|
+ if (nameList.contains(name)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ nameList.add(name);
|
|
|
+ }
|
|
|
}
|
|
|
+ List<QuestionDTO> labDTO = getTagList(nameList, pushVO, QuestionTypeEnum.Lis.getKey());
|
|
|
+ pushDTO.setLab(labDTO);
|
|
|
}
|
|
|
- List<QuestionDTO> labDTO = getTagListByMap(mealLabMap, pushVO, QuestionTypeEnum.Lis.getKey());
|
|
|
- pushDTO.setLab(labDTO);
|
|
|
}
|
|
|
|
|
|
//辅检 标签列表
|
|
|
if (featureTypeSet.contains(String.valueOf(QuestionTypeEnum.Pacs.getKey()))) {
|
|
|
- List<QuestionDTO> pacsDTO = getTagListByMap(pacsMap, pushVO, QuestionTypeEnum.Pacs.getKey());
|
|
|
- pushDTO.setPacs(pacsDTO);
|
|
|
+ List<FeatureRate> pacs = data.getPacs();
|
|
|
+ if (ListUtil.isNotEmpty(pacs)) {
|
|
|
+ List<String> nameList = pacs.stream().map(featureRate -> featureRate.getFeatureName()).collect(Collectors.toList());
|
|
|
+ List<QuestionDTO> pacsDTO = getTagList(nameList, pushVO, QuestionTypeEnum.Pacs.getKey());
|
|
|
+ pushDTO.setPacs(pacsDTO);
|
|
|
+ }
|
|
|
}
|
|
|
//诊断 返回分类+标签列表
|
|
|
if (featureTypeSet.contains(String.valueOf(QuestionTypeEnum.Disease.getKey()))) {
|
|
|
- Map<String, List<QuestionDTO>> disMapDTO = new LinkedHashMap<>();
|
|
|
- Map<String, List<FeatureRate>> disFeatureMap = new LinkedHashMap<>();
|
|
|
- //警惕
|
|
|
- List<String> diseaseNameList = dis.stream().map(disease -> disease.getFeatureName()).collect(Collectors.toList());
|
|
|
- Map<String, String> highRiskMap = new HashMap<>();
|
|
|
- highRiskMap.put("disease", String.join(",", diseaseNameList));
|
|
|
- SearchData searchData = new SearchData();
|
|
|
- searchData.setDiag(String.join(",", diseaseNameList));
|
|
|
- Response<GdbResponse> graphRes = bigDataServiceClient.highRiskPageData(searchData);
|
|
|
- if (graphRes != null) {
|
|
|
- Map<String, String> graphResult = graphRes.getData().getResult();
|
|
|
- if (graphResult.size() > 0) {
|
|
|
- Map<String, Object> disMap = new LinkedHashMap<>();
|
|
|
- for (Map.Entry<String, String> entry : graphResult.entrySet()) {
|
|
|
- if (entry.getValue().equals("1")) {
|
|
|
- disMap.put(entry.getKey(), "");
|
|
|
+ if (ListUtil.isNotEmpty(dis)) {
|
|
|
+ List<String> nameList = dis.stream().map(featureRate -> featureRate.getFeatureName()).collect(Collectors.toList());
|
|
|
+ Map<String, List<QuestionDTO>> disMapDTO = new LinkedHashMap<>();
|
|
|
+ Map<String, List<FeatureRate>> disFeatureMap = new LinkedHashMap<>();
|
|
|
+ //警惕
|
|
|
+ Map<String, String> highRiskMap = new HashMap<>();
|
|
|
+ highRiskMap.put("disease", String.join(",", nameList));
|
|
|
+ SearchData searchData = new SearchData();
|
|
|
+ searchData.setDiag(String.join(",", nameList));
|
|
|
+ Response<GdbResponse> graphRes = bigDataServiceClient.highRiskPageData(searchData);
|
|
|
+ if (graphRes != null) {
|
|
|
+ Map<String, String> graphResult = graphRes.getData().getResult();
|
|
|
+ if (graphResult.size() > 0) {
|
|
|
+ List<String> hrNameList = Lists.newLinkedList();
|
|
|
+ for (Map.Entry<String, String> entry : graphResult.entrySet()) {
|
|
|
+ if (entry.getValue().equals("1")) {
|
|
|
+ hrNameList.add(entry.getKey());
|
|
|
+ }
|
|
|
}
|
|
|
+ List<QuestionDTO> disDTO = getTagList(hrNameList, pushVO, QuestionTypeEnum.Disease.getKey());
|
|
|
+ disMapDTO.put("警惕", disDTO);
|
|
|
}
|
|
|
- List<QuestionDTO> disDTO = getTagListByMap(disMap, pushVO, QuestionTypeEnum.Disease.getKey());
|
|
|
- disMapDTO.put("警惕", disDTO);
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- //诊断分类
|
|
|
- for (FeatureRate featureRate : dis) {
|
|
|
- if (StringUtil.isBlank(featureRate.getDesc())) {
|
|
|
- featureRate.setDesc("{\"可能诊断\":\"\"}");
|
|
|
- }
|
|
|
- Map<String, Object> descMap = FastJsonUtils.getJsonToMap(featureRate.getDesc());
|
|
|
- for (String disClass : descMap.keySet()) {
|
|
|
- List<FeatureRate> featureRateList = Lists.newLinkedList();
|
|
|
- if (disFeatureMap.get(disClass) != null) {
|
|
|
- featureRateList = disFeatureMap.get(disClass);
|
|
|
+ //诊断分类
|
|
|
+ for (FeatureRate featureRate : dis) {
|
|
|
+ if (StringUtil.isBlank(featureRate.getDesc())) {
|
|
|
+ featureRate.setDesc("{\"可能诊断\":\"\"}");
|
|
|
+ }
|
|
|
+ Map<String, Object> descMap = FastJsonUtils.getJsonToMap(featureRate.getDesc());
|
|
|
+ for (String disClass : descMap.keySet()) {
|
|
|
+ List<FeatureRate> featureRateList = Lists.newLinkedList();
|
|
|
+ if (disFeatureMap.get(disClass) != null) {
|
|
|
+ featureRateList = disFeatureMap.get(disClass);
|
|
|
+ }
|
|
|
+ featureRateList.add(featureRate);
|
|
|
+ disFeatureMap.put(disClass, featureRateList);
|
|
|
}
|
|
|
- featureRateList.add(featureRate);
|
|
|
- disFeatureMap.put(disClass, featureRateList);
|
|
|
}
|
|
|
+ for (Map.Entry<String, List<FeatureRate>> entry : disFeatureMap.entrySet()) {
|
|
|
+ List<String> nameListByDisClass = entry.getValue().stream().map(featureRate -> featureRate.getFeatureName()).collect(Collectors.toList());
|
|
|
+ List<QuestionDTO> disDTO = getTagList(nameListByDisClass, pushVO, QuestionTypeEnum.Disease.getKey());
|
|
|
+ disMapDTO.put(entry.getKey(), disDTO);
|
|
|
+ }
|
|
|
+ pushDTO.setDis(disMapDTO);
|
|
|
}
|
|
|
- for (Map.Entry<String, List<FeatureRate>> entry : disFeatureMap.entrySet()) {
|
|
|
- Map<String, Object> disMap = list2Map(entry.getValue());
|
|
|
- List<QuestionDTO> disDTO = getTagListByMap(disMap, pushVO, QuestionTypeEnum.Disease.getKey());
|
|
|
- disMapDTO.put(entry.getKey(), disDTO);
|
|
|
- }
|
|
|
- pushDTO.setDis(disMapDTO);
|
|
|
}
|
|
|
//治疗方案
|
|
|
if (featureTypeSet.contains(String.valueOf(QuestionTypeEnum.Drug.getKey()))) {
|
|
|
+ Map<String, JSONObject> treat = data.getTreat();
|
|
|
if (pushVO.getDiseaseId() == null) {
|
|
|
throw new CommonException(CommonErrorCode.PARAM_ERROR, "请输入诊断id");
|
|
|
}
|
|
@@ -295,36 +304,35 @@ public class PushFacade {
|
|
|
/**
|
|
|
* 获取返回结果标签
|
|
|
*
|
|
|
- * @param map
|
|
|
+ * @param nameList
|
|
|
* @param pushVO
|
|
|
* @param type
|
|
|
* @return
|
|
|
*/
|
|
|
- public List<QuestionDTO> getTagListByMap(Map<String, Object> map, PushVO pushVO, Integer type) {
|
|
|
+ public List<QuestionDTO> getTagList(List<String> nameList, PushVO pushVO, Integer type) {
|
|
|
List<QuestionDTO> questionDTOList = Lists.newLinkedList();
|
|
|
QueryWrapper<QuestionInfo> questionInfoQueryWrapper = new QueryWrapper();
|
|
|
questionInfoQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey()).
|
|
|
- in("tag_name", map.keySet()).
|
|
|
+ in("tag_name", nameList).
|
|
|
eq("type", type);
|
|
|
List<QuestionInfo> questionInfoList = questionFacade.list(questionInfoQueryWrapper);
|
|
|
Map<String, QuestionInfo> questionMap = EntityUtil.makeEntityMap(questionInfoList, "tagName");
|
|
|
- for (Map.Entry<String, Object> entry : map.entrySet()) {
|
|
|
+ for (String name : nameList) {
|
|
|
QuestionDTO questionDTO = new QuestionDTO();
|
|
|
- if (questionMap.get(entry.getKey()) != null) {
|
|
|
+ if (questionMap.get(name) != null) {
|
|
|
QuestionVO questionVO = new QuestionVO();
|
|
|
questionVO.setAge(pushVO.getAge());
|
|
|
questionVO.setSexType(pushVO.getSex());
|
|
|
- questionVO.setId(questionMap.get(entry.getKey()).getId());
|
|
|
+ questionVO.setId(questionMap.get(name).getId());
|
|
|
questionDTO = questionFacade.getById(questionVO);
|
|
|
- if (questionDTO == null || (!questionDTO.getSubType().equals(0))) {
|
|
|
+ if (questionDTO == null || questionDTO.getId() == null) {
|
|
|
questionDTO = new QuestionDTO();
|
|
|
- questionDTO.setTagName(entry.getKey());
|
|
|
- questionDTO.setName(entry.getKey());
|
|
|
+ questionDTO.setTagName(name);
|
|
|
+ questionDTO.setName(name);
|
|
|
}
|
|
|
-
|
|
|
} else {
|
|
|
- questionDTO.setTagName(entry.getKey());
|
|
|
- questionDTO.setName(entry.getKey());
|
|
|
+ questionDTO.setTagName(name);
|
|
|
+ questionDTO.setName(name);
|
|
|
}
|
|
|
questionDTOList.add(questionDTO);
|
|
|
}
|
|
@@ -368,21 +376,6 @@ public class PushFacade {
|
|
|
return pushKYJDTO;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 将list 转换成 map
|
|
|
- *
|
|
|
- * @param list
|
|
|
- * @return
|
|
|
- */
|
|
|
- public Map<String, Object> list2Map(List<FeatureRate> list) {
|
|
|
- Map<String, Object> map = new LinkedHashMap<>();
|
|
|
- for (FeatureRate featureRate : list) {
|
|
|
- map.put(featureRate.getFeatureName(), null);
|
|
|
- }
|
|
|
- return map;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* 快易检结果预处理
|
|
|
*
|