|
@@ -1,23 +1,40 @@
|
|
|
package com.diagbot.facade;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
-import com.diagbot.biz.push.entity.Item;
|
|
|
import com.diagbot.biz.push.entity.Lis;
|
|
|
import com.diagbot.client.ChiefPresentSimilarityServiceClient;
|
|
|
import com.diagbot.client.StandConvertServiceClient;
|
|
|
-import com.diagbot.dto.*;
|
|
|
+import com.diagbot.dto.BillNeoDTO;
|
|
|
+import com.diagbot.dto.CriticalNeoDTO;
|
|
|
+import com.diagbot.dto.HighRiskNeoDTO;
|
|
|
+import com.diagbot.dto.NeoPushDTO;
|
|
|
+import com.diagbot.dto.NodeNeoDTO;
|
|
|
+import com.diagbot.dto.OtherTipNeoDTO;
|
|
|
+import com.diagbot.dto.OtherTipPacsNeoDTO;
|
|
|
+import com.diagbot.dto.OtherTipTransfusionNeoDTO;
|
|
|
+import com.diagbot.dto.PushBaseDTO;
|
|
|
+import com.diagbot.dto.StandConvertCrfBatchDTO;
|
|
|
+import com.diagbot.dto.StandConvertCrfDTO;
|
|
|
+import com.diagbot.dto.WordCrfDTO;
|
|
|
import com.diagbot.entity.node.LisRemind;
|
|
|
import com.diagbot.entity.node.Medicine;
|
|
|
import com.diagbot.entity.node.Symptom;
|
|
|
import com.diagbot.entity.node.YiBaoDiseaseName;
|
|
|
+import com.diagbot.enums.RedisEnum;
|
|
|
import com.diagbot.enums.StandConvertEnum;
|
|
|
import com.diagbot.exception.CommonErrorCode;
|
|
|
import com.diagbot.exception.CommonException;
|
|
|
import com.diagbot.repository.*;
|
|
|
import com.diagbot.util.ListUtil;
|
|
|
+import com.diagbot.util.NeoUtil;
|
|
|
import com.diagbot.util.RedisUtil;
|
|
|
import com.diagbot.util.StringUtil;
|
|
|
-import com.diagbot.vo.*;
|
|
|
+import com.diagbot.vo.BillNeoVO;
|
|
|
+import com.diagbot.vo.CriticalNeoVO;
|
|
|
+import com.diagbot.vo.Drug;
|
|
|
+import com.diagbot.vo.NeoPushVO;
|
|
|
+import com.diagbot.vo.StandConvert;
|
|
|
+import com.diagbot.vo.StandConvertCrfVO;
|
|
|
import com.diagbot.vo.neoPushEntity.ChiefPushVo;
|
|
|
import com.diagbot.vo.neoPushEntity.Diag;
|
|
|
import com.diagbot.vo.neoPushEntity.PresentPushVo;
|
|
@@ -33,7 +50,14 @@ import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.text.DecimalFormat;
|
|
|
-import java.util.*;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Collection;
|
|
|
+import java.util.Collections;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Iterator;
|
|
|
+import java.util.LinkedHashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
import java.util.stream.Stream;
|
|
@@ -128,7 +152,7 @@ public class NeoFacade {
|
|
|
|
|
|
// 加载药品缓存
|
|
|
for (String key : res.keySet()) {
|
|
|
- redisUtil.updateValueByType("药品分类_" + key, res.get(key));
|
|
|
+ redisUtil.updateValue(RedisEnum.drugType.getName() + key, res.get(key));
|
|
|
}
|
|
|
return res;
|
|
|
}
|
|
@@ -246,7 +270,7 @@ public class NeoFacade {
|
|
|
}
|
|
|
symptoms = Stream.of(symptom_chief,symptom_present).flatMap(Collection::stream).distinct().collect(Collectors.toList());
|
|
|
//症状推疾病
|
|
|
- List<String> allDis_bySymptom = getDisBySymptom(symptoms);
|
|
|
+ List<String> allDis_bySymptom = getDisBySymptom(symptoms,age,sex);
|
|
|
allDis.addAll(allDis_bySymptom);
|
|
|
//体征推出的疾病
|
|
|
//化验推出的疾病辅检
|
|
@@ -310,12 +334,12 @@ public class NeoFacade {
|
|
|
return neoPushDTOS;
|
|
|
}
|
|
|
|
|
|
- public List<String> getDisBySymptom(List<String> symptoms){
|
|
|
+ public List<String> getDisBySymptom(List<String> symptoms,Integer age,Integer sex){
|
|
|
List<String> symptomCache = getSymptomCache();
|
|
|
//取交集
|
|
|
symptoms.retainAll(symptomCache);
|
|
|
long start = System.currentTimeMillis();
|
|
|
- List<String> allDis_bySymptom = pushDis(symptomNameRepository, symptoms);
|
|
|
+ List<String> allDis_bySymptom = pushDis(symptomNameRepository, symptoms,age,sex);
|
|
|
long end = System.currentTimeMillis();
|
|
|
return allDis_bySymptom;
|
|
|
}
|
|
@@ -328,9 +352,10 @@ public class NeoFacade {
|
|
|
* @param symptoms
|
|
|
* @return
|
|
|
*/
|
|
|
- public List<String> pushDis(SymptomNameRepository symptomNameRepository,List<String> symptoms){
|
|
|
+ public List<String> pushDis(SymptomNameRepository symptomNameRepository,List<String> symptoms,Integer age,Integer sex){
|
|
|
List<String> allDis = Lists.newArrayList();
|
|
|
- if(ListUtil.isNotEmpty(symptoms)){
|
|
|
+
|
|
|
+ /*if(ListUtil.isNotEmpty(symptoms)){
|
|
|
symptoms.parallelStream().forEach(x ->{
|
|
|
List<Symptom> byNameIs = symptomNameRepository.findByNameIs(x);
|
|
|
if(ListUtil.isNotEmpty(byNameIs)){
|
|
@@ -340,7 +365,15 @@ public class NeoFacade {
|
|
|
allDis.addAll(diseases);
|
|
|
}
|
|
|
});
|
|
|
- }
|
|
|
+ }*/
|
|
|
+ List<Symptom> byNameIn = symptomNameRepository.findByNameIn(symptoms);
|
|
|
+ /*List<YiBaoDiseaseName> collect = byNameIn.stream()
|
|
|
+ .map(x -> x.getDisease().stream().filter(z -> NeoUtil.matchBasic(z,sex,age)).collect(Collectors.toList()))
|
|
|
+ .flatMap(List::stream).collect(Collectors.toList());*/
|
|
|
+
|
|
|
+ allDis = byNameIn.stream()
|
|
|
+ .map(z -> z.getDisease().stream().filter(o -> NeoUtil.matchBasic(o,sex,age)).map(y -> y.getName()).collect(Collectors.toList())).flatMap(List::stream)
|
|
|
+ .collect(Collectors.toList());
|
|
|
return allDis;
|
|
|
}
|
|
|
|
|
@@ -771,14 +804,14 @@ public class NeoFacade {
|
|
|
Map<String, Map<String, String>> map = new LinkedHashMap<>();
|
|
|
|
|
|
List<StandConvertCrfVO> standConvertCrfVOList = new ArrayList<>();
|
|
|
- List<String> clinicalConList = getConvertList(standConvert.getClinicalList(), StandConvertEnum.symptom.getName(), standConvertCrfVOList);
|
|
|
- List<String> operationConList = getConvertList(standConvert.getOperationList(), StandConvertEnum.operation.getName(), standConvertCrfVOList);
|
|
|
- List<String> drugConList = getConvertList(standConvert.getDrugList(), StandConvertEnum.drug.getName(), standConvertCrfVOList);
|
|
|
- List<String> vitallConList = getConvertList(standConvert.getVitalList(), StandConvertEnum.vital.getName(), standConvertCrfVOList);
|
|
|
- List<String> diseaseConList = getConvertList(standConvert.getDiaglList(), StandConvertEnum.disease.getName(), standConvertCrfVOList);
|
|
|
- List<String> pacsConList = getConvertList(standConvert.getPacsList(), StandConvertEnum.pacs.getName(), standConvertCrfVOList);
|
|
|
- List<String> lisConList = getConvertList(standConvert.getLisList(), StandConvertEnum.lis.getName(), standConvertCrfVOList);
|
|
|
- List<String> transfusionConList = getConvertList(standConvert.getTransfusionList(), StandConvertEnum.transfusion.getName(), standConvertCrfVOList);
|
|
|
+ List<String> clinicalConList = getConvertList(standConvert.getClinicalList(), StandConvertEnum.symptom.toString(), standConvertCrfVOList);
|
|
|
+ List<String> operationConList = getConvertList(standConvert.getOperationList(), StandConvertEnum.operation.toString(), standConvertCrfVOList);
|
|
|
+ List<String> drugConList = getConvertList(standConvert.getDrugList(), StandConvertEnum.drug.toString(), standConvertCrfVOList);
|
|
|
+ List<String> vitallConList = getConvertList(standConvert.getVitalList(), StandConvertEnum.vital.toString(), standConvertCrfVOList);
|
|
|
+ List<String> diseaseConList = getConvertList(standConvert.getDiaglList(), StandConvertEnum.disease.toString(), standConvertCrfVOList);
|
|
|
+ List<String> pacsConList = getConvertList(standConvert.getPacsList(), StandConvertEnum.pacs.toString(), standConvertCrfVOList);
|
|
|
+ List<String> lisConList = getConvertList(standConvert.getLisList(), StandConvertEnum.lis.toString(), standConvertCrfVOList);
|
|
|
+ List<String> transfusionConList = getConvertList(standConvert.getTransfusionList(), StandConvertEnum.transfusion.toString(), standConvertCrfVOList);
|
|
|
|
|
|
StandConvertCrfBatchDTO standConvertCrfBatchDTO = null;
|
|
|
try {
|
|
@@ -787,14 +820,14 @@ public class NeoFacade {
|
|
|
throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "标准词转换【服务器】挂了!" + e.getMessage());
|
|
|
}
|
|
|
Map<String, Map<String, StandConvertCrfDTO>> crfMap = standConvertCrfBatchDTO.getData();
|
|
|
- getConvertMap(crfMap, StandConvertEnum.symptom.getName(), clinicalConList, standConvert.getClinicalList(), map);
|
|
|
- getConvertMap(crfMap, StandConvertEnum.operation.getName(), operationConList, standConvert.getOperationList(), map);
|
|
|
- getConvertMap(crfMap, StandConvertEnum.drug.getName(), drugConList, standConvert.getDrugList(), map);
|
|
|
- getConvertMap(crfMap, StandConvertEnum.vital.getName(), vitallConList, standConvert.getVitalList(), map);
|
|
|
- getConvertMap(crfMap, StandConvertEnum.disease.getName(), diseaseConList, standConvert.getDiaglList(), map);
|
|
|
- getConvertMap(crfMap, StandConvertEnum.pacs.getName(), pacsConList, standConvert.getPacsList(), map);
|
|
|
- getConvertMap(crfMap, StandConvertEnum.lis.getName(), lisConList, standConvert.getLisList(), map);
|
|
|
- getConvertMap(crfMap, StandConvertEnum.transfusion.getName(), transfusionConList, standConvert.getTransfusionList(), map);
|
|
|
+ getConvertMap(crfMap, StandConvertEnum.symptom.toString(), clinicalConList, map);
|
|
|
+ getConvertMap(crfMap, StandConvertEnum.operation.toString(), operationConList, map);
|
|
|
+ getConvertMap(crfMap, StandConvertEnum.drug.toString(), drugConList, map);
|
|
|
+ getConvertMap(crfMap, StandConvertEnum.vital.toString(), vitallConList, map);
|
|
|
+ getConvertMap(crfMap, StandConvertEnum.disease.toString(), diseaseConList, map);
|
|
|
+ getConvertMap(crfMap, StandConvertEnum.pacs.toString(), pacsConList, map);
|
|
|
+ getConvertMap(crfMap, StandConvertEnum.lis.toString(), lisConList, map);
|
|
|
+ getConvertMap(crfMap, StandConvertEnum.transfusion.toString(), transfusionConList, map);
|
|
|
|
|
|
return map;
|
|
|
}
|
|
@@ -812,14 +845,10 @@ public class NeoFacade {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- // 从redis获取对应的内容
|
|
|
- Map<String, String> redisMap = redisUtil.getValueByType(type);
|
|
|
- if (redisMap == null) {
|
|
|
- redisMap = new LinkedHashMap<>();
|
|
|
- }
|
|
|
if (ListUtil.isNotEmpty(wordList)) {
|
|
|
for (String s : wordList) {
|
|
|
- if (StringUtil.isBlank(redisMap.get(s))) {
|
|
|
+ String value = redisUtil.getWithString(type + "Conv:" + s);
|
|
|
+ if (StringUtil.isBlank(value)) {
|
|
|
StandConvertCrfVO standConvertCrfVO = new StandConvertCrfVO();
|
|
|
standConvertCrfVO.setWord_type(type);
|
|
|
standConvertCrfVO.setWord(s);
|
|
@@ -839,60 +868,40 @@ public class NeoFacade {
|
|
|
* @param crfDTO
|
|
|
* @param type
|
|
|
* @param convertList
|
|
|
- * @param orginList
|
|
|
* @param map
|
|
|
*/
|
|
|
public void getConvertMap(Map<String, Map<String, StandConvertCrfDTO>> crfDTO, String type, List<String> convertList,
|
|
|
- List<String> orginList, Map<String, Map<String, String>> map) {
|
|
|
- if (ListUtil.isEmpty(orginList)) {
|
|
|
+ Map<String, Map<String, String>> map) {
|
|
|
+ if (ListUtil.isEmpty(convertList)) {
|
|
|
return ;
|
|
|
}
|
|
|
Map<String, StandConvertCrfDTO> crfMap = crfDTO.get(type);
|
|
|
Map<String, String> typeMap = new LinkedHashMap<>();
|
|
|
- Boolean updateRedis = false;
|
|
|
|
|
|
- // 从redis获取对应的内容
|
|
|
- Map<String, String> redisMap = redisUtil.getValueByType(type);
|
|
|
- if (redisMap == null) {
|
|
|
- redisMap = new LinkedHashMap<>();
|
|
|
- }
|
|
|
- for (String s : orginList) {
|
|
|
- if (redisMap.containsKey(s)) {
|
|
|
- typeMap.put(s, redisMap.get(s));
|
|
|
- } else if (crfMap != null) {
|
|
|
+ for (String s : convertList) {
|
|
|
+ String lastS = s;
|
|
|
+ if (crfMap != null) {
|
|
|
StandConvertCrfDTO standConvertCrfDTO = crfMap.get(s);
|
|
|
if (standConvertCrfDTO != null) {
|
|
|
- List<Map<String,String>> list = standConvertCrfDTO.getStandard_words();
|
|
|
+ List<Map<String, String>> list = standConvertCrfDTO.getStandard_words();
|
|
|
if (ListUtil.isEmpty(list)) {
|
|
|
- redisMap.put(s, s);
|
|
|
- typeMap.put(s, s);
|
|
|
+ redisUtil.updateValue(type + "Conv:" + s, s);
|
|
|
} else {
|
|
|
String rateStr = standConvertCrfDTO.getStandard_words().get(0).get("rate");
|
|
|
BigDecimal rate = new BigDecimal(rateStr);
|
|
|
int flag = rate.compareTo(new BigDecimal(standConvertRate));
|
|
|
if (flag < 0) {
|
|
|
- redisMap.put(s, s); // rate 小于阈值
|
|
|
- typeMap.put(s, s);
|
|
|
+ redisUtil.updateValue(type + "Conv:" + s, s);
|
|
|
} else {
|
|
|
- redisMap.put(s, standConvertCrfDTO.getStandard_words().get(0).get("standard_word"));
|
|
|
- typeMap.put(s, standConvertCrfDTO.getStandard_words().get(0).get("standard_word"));
|
|
|
+ redisUtil.updateValue(type + "Conv:" + s, standConvertCrfDTO.getStandard_words().get(0).get("standard_word"));
|
|
|
+ lastS = standConvertCrfDTO.getStandard_words().get(0).get("standard_word");
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
- redisMap.put(s, s); // 找不到就认为是标准词
|
|
|
- typeMap.put(s, s); // 找不到就认为是标准词
|
|
|
+ redisUtil.updateValue(type + "Conv:" + s, s);
|
|
|
}
|
|
|
- updateRedis = true;
|
|
|
- } else {
|
|
|
- redisMap.put(s, s); // 找不到就认为是标准词
|
|
|
- typeMap.put(s, s); // 找不到就认为是标准词
|
|
|
- updateRedis = true;
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- // 更新redis
|
|
|
- if (updateRedis) {
|
|
|
- redisUtil.updateValueByType(redisMap, type);
|
|
|
+ typeMap.put(s, lastS);
|
|
|
}
|
|
|
map.put(type, typeMap);
|
|
|
}
|