|
@@ -6,6 +6,7 @@ import com.diagbot.dto.BillMsg;
|
|
import com.diagbot.dto.MedClassMedDTO;
|
|
import com.diagbot.dto.MedClassMedDTO;
|
|
import com.diagbot.dto.RuleDTO;
|
|
import com.diagbot.dto.RuleDTO;
|
|
import com.diagbot.entity.KlConcept;
|
|
import com.diagbot.entity.KlConcept;
|
|
|
|
+import com.diagbot.entity.KlRuleBase;
|
|
import com.diagbot.entity.ResultRule;
|
|
import com.diagbot.entity.ResultRule;
|
|
import com.diagbot.enums.ConEnum;
|
|
import com.diagbot.enums.ConEnum;
|
|
import com.diagbot.enums.IsDeleteEnum;
|
|
import com.diagbot.enums.IsDeleteEnum;
|
|
@@ -47,6 +48,8 @@ public class MedRuleConvertFacade {
|
|
private KlRuleFacade klRuleFacade;
|
|
private KlRuleFacade klRuleFacade;
|
|
@Autowired
|
|
@Autowired
|
|
private KlRelationFacade klRelationFacade;
|
|
private KlRelationFacade klRelationFacade;
|
|
|
|
+ @Autowired
|
|
|
|
+ private KlRuleBaseFacade klRuleBaseFacade;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private LisConfigFacade lisConfigFacade;
|
|
private LisConfigFacade lisConfigFacade;
|
|
@@ -197,7 +200,7 @@ public class MedRuleConvertFacade {
|
|
result.setRuleBaseInputValue(random_int(1, 6, true, false).toString());
|
|
result.setRuleBaseInputValue(random_int(1, 6, true, false).toString());
|
|
break;
|
|
break;
|
|
case "儿童":
|
|
case "儿童":
|
|
- result.setRuleBaseInputValue(random_int(1, 6, true, false).toString());
|
|
|
|
|
|
+ result.setRuleBaseInputValue(random_int(6, 18, true, false).toString());
|
|
break;
|
|
break;
|
|
case "成人":
|
|
case "成人":
|
|
result.setRuleBaseInputValue(random_int(18, 200, true, false).toString());
|
|
result.setRuleBaseInputValue(random_int(18, 200, true, false).toString());
|
|
@@ -451,7 +454,7 @@ public class MedRuleConvertFacade {
|
|
for (String conflictDisease : conflictDiseases) {
|
|
for (String conflictDisease : conflictDiseases) {
|
|
ResultRule convertResult = new ResultRule();
|
|
ResultRule convertResult = new ResultRule();
|
|
BeanUtil.copyProperties(result, convertResult);
|
|
BeanUtil.copyProperties(result, convertResult);
|
|
- convertResult.setReferenceValue(convertResult.getRuleBaseLibType() + "_" + convertResult.getRuleBaseLibName() + "_" + convertResult.getRuleBaseLibName());
|
|
|
|
|
|
+ convertResult.setReferenceValue(convertResult.getRuleBaseLibType() + "_" + convertResult.getRuleBaseLibTypeName() + "_" + convertResult.getRuleBaseLibName());
|
|
convertResult.setRuleBaseLibName(conflictDisease);
|
|
convertResult.setRuleBaseLibName(conflictDisease);
|
|
convertResult.setRuleBaseLibType(LexiconEnum.Disease.getKey());
|
|
convertResult.setRuleBaseLibType(LexiconEnum.Disease.getKey());
|
|
convertResult.setRuleBaseLibTypeName(LexiconEnum.Disease.getName());
|
|
convertResult.setRuleBaseLibTypeName(LexiconEnum.Disease.getName());
|
|
@@ -507,76 +510,84 @@ public class MedRuleConvertFacade {
|
|
for (Map.Entry<Long, List<ResultRule>> entry : billMappingMap.entrySet()) {
|
|
for (Map.Entry<Long, List<ResultRule>> entry : billMappingMap.entrySet()) {
|
|
Map<Integer, List<ResultRule>> tempMap = new HashMap<>();
|
|
Map<Integer, List<ResultRule>> tempMap = new HashMap<>();
|
|
Integer num = 1;
|
|
Integer num = 1;
|
|
- for (ResultRule result : entry.getValue()) {
|
|
|
|
|
|
+ for (int i = 0; i < entry.getValue().size(); i++) {
|
|
|
|
+ //for (ResultRule result : entry.getValue()) {
|
|
|
|
+ ResultRule result = entry.getValue().get(i);
|
|
List<ResultRule> tempList = Lists.newLinkedList();
|
|
List<ResultRule> tempList = Lists.newLinkedList();
|
|
- if (result.getRuleLibType().equals(LexiconEnum.Medicine.getKey())) {
|
|
|
|
- List<ResultRule> mappingList = getMappingResult_medicine(result, drugConfigMap, 1);
|
|
|
|
- if (result.getRuleLibType().equals(result.getRuleBaseLibType())
|
|
|
|
- && result.getRuleLibName().equals(result.getRuleBaseLibName())) {
|
|
|
|
- mappingList.forEach(item -> {
|
|
|
|
- item.setRuleBaseHisName(item.getRuleHisName());
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- tempList.addAll(mappingList);
|
|
|
|
- } else if (result.getRuleLibType().equals(LexiconEnum.Operation.getKey())) {
|
|
|
|
- List<ResultRule> mappingList = getMappingResult(result, operationConfigMap, 1);
|
|
|
|
- if (result.getRuleLibType().equals(result.getRuleBaseLibType())
|
|
|
|
- && result.getRuleLibName().equals(result.getRuleBaseLibName())) {
|
|
|
|
- mappingList.forEach(item -> {
|
|
|
|
- item.setRuleBaseHisName(item.getRuleHisName());
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- tempList.addAll(mappingList);
|
|
|
|
- } else if (result.getRuleLibType().equals(LexiconEnum.LisName.getKey())) {
|
|
|
|
- List<ResultRule> mappingList = getMappingResult_lis(result, lisConfigMap, 1);
|
|
|
|
- if (result.getRuleLibType().equals(result.getRuleBaseLibType())
|
|
|
|
- && result.getRuleLibName().equals(result.getRuleBaseLibName())) {
|
|
|
|
- mappingList.forEach(item -> {
|
|
|
|
- item.setRuleBaseHisName(item.getRuleHisName());
|
|
|
|
- item.setRuleBaseHisDetailName(item.getRuleHisDetailName());
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- tempList.addAll(mappingList);
|
|
|
|
- } else if (result.getRuleLibType().equals(LexiconEnum.LisSubName.getKey())) {
|
|
|
|
- List<ResultRule> mappingList = getMappingResult_lis(result, lisConfigMap, 1);
|
|
|
|
- if (result.getRuleLibType().equals(result.getRuleBaseLibType())
|
|
|
|
- && result.getRuleLibName().equals(result.getRuleBaseLibName())) {
|
|
|
|
- mappingList.forEach(item -> {
|
|
|
|
- item.setRuleBaseHisName(item.getRuleHisName());
|
|
|
|
- item.setRuleBaseHisDetailName(item.getRuleHisDetailName());
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- tempList.addAll(mappingList);
|
|
|
|
- } else if (result.getRuleLibType().equals(LexiconEnum.PacsName.getKey())) {
|
|
|
|
- List<ResultRule> mappingList = getMappingResult(result, pacsConfigMap, 1);
|
|
|
|
- if (result.getRuleLibType().equals(result.getRuleBaseLibType())
|
|
|
|
- && result.getRuleLibName().equals(result.getRuleBaseLibName())) {
|
|
|
|
- mappingList.forEach(item -> {
|
|
|
|
- item.setRuleBaseHisName(item.getRuleHisName());
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- tempList.addAll(mappingList);
|
|
|
|
- } else if (result.getRuleLibType().equals(LexiconEnum.PacsSubName.getKey())) {
|
|
|
|
- List<ResultRule> mappingList = getMappingResult(result, pacsConfigMap, 1);
|
|
|
|
- if (result.getRuleLibType().equals(result.getRuleBaseLibType())
|
|
|
|
- && result.getRuleLibName().equals(result.getRuleBaseLibName())) {
|
|
|
|
- mappingList.forEach(item -> {
|
|
|
|
- item.setRuleBaseHisName(item.getRuleHisName());
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- tempList.addAll(mappingList);
|
|
|
|
- } else if (result.getRuleLibType().equals(LexiconEnum.Transfusion.getKey())) {
|
|
|
|
- List<ResultRule> mappingList = getMappingResult(result, transfusionConfigMap, 1);
|
|
|
|
- if (result.getRuleLibType().equals(result.getRuleBaseLibType())
|
|
|
|
- && result.getRuleLibName().equals(result.getRuleBaseLibName())) {
|
|
|
|
- mappingList.forEach(item -> {
|
|
|
|
- item.setRuleBaseHisName(item.getRuleHisName());
|
|
|
|
- });
|
|
|
|
|
|
+ if (i == 0) {
|
|
|
|
+ if (result.getRuleLibType().equals(LexiconEnum.Medicine.getKey())) {
|
|
|
|
+ List<ResultRule> mappingList = getMappingResult_medicine(result, drugConfigMap, 1);
|
|
|
|
+ if (result.getRuleLibType().equals(result.getRuleBaseLibType())
|
|
|
|
+ && result.getRuleLibName().equals(result.getRuleBaseLibName())) {
|
|
|
|
+ mappingList.forEach(item -> {
|
|
|
|
+ item.setRuleBaseHisName(item.getRuleHisName());
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ tempList.addAll(mappingList);
|
|
|
|
+ } else if (result.getRuleLibType().equals(LexiconEnum.Operation.getKey())) {
|
|
|
|
+ List<ResultRule> mappingList = getMappingResult(result, operationConfigMap, 1);
|
|
|
|
+ if (result.getRuleLibType().equals(result.getRuleBaseLibType())
|
|
|
|
+ && result.getRuleLibName().equals(result.getRuleBaseLibName())) {
|
|
|
|
+ mappingList.forEach(item -> {
|
|
|
|
+ item.setRuleBaseHisName(item.getRuleHisName());
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ tempList.addAll(mappingList);
|
|
|
|
+ } else if (result.getRuleLibType().equals(LexiconEnum.LisName.getKey())) {
|
|
|
|
+ List<ResultRule> mappingList = getMappingResult_lis(result, lisConfigMap, 1);
|
|
|
|
+ if (result.getRuleLibType().equals(result.getRuleBaseLibType())
|
|
|
|
+ && result.getRuleLibName().equals(result.getRuleBaseLibName())) {
|
|
|
|
+ mappingList.forEach(item -> {
|
|
|
|
+ item.setRuleBaseHisName(item.getRuleHisName());
|
|
|
|
+ item.setRuleBaseHisDetailName(item.getRuleHisDetailName());
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ tempList.addAll(mappingList);
|
|
|
|
+ } else if (result.getRuleLibType().equals(LexiconEnum.LisSubName.getKey())) {
|
|
|
|
+ List<ResultRule> mappingList = getMappingResult_lis(result, lisConfigMap, 1);
|
|
|
|
+ if (result.getRuleLibType().equals(result.getRuleBaseLibType())
|
|
|
|
+ && result.getRuleLibName().equals(result.getRuleBaseLibName())) {
|
|
|
|
+ mappingList.forEach(item -> {
|
|
|
|
+ item.setRuleBaseHisName(item.getRuleHisName());
|
|
|
|
+ item.setRuleBaseHisDetailName(item.getRuleHisDetailName());
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ tempList.addAll(mappingList);
|
|
|
|
+ } else if (result.getRuleLibType().equals(LexiconEnum.PacsName.getKey())) {
|
|
|
|
+ List<ResultRule> mappingList = getMappingResult(result, pacsConfigMap, 1);
|
|
|
|
+ if (result.getRuleLibType().equals(result.getRuleBaseLibType())
|
|
|
|
+ && result.getRuleLibName().equals(result.getRuleBaseLibName())) {
|
|
|
|
+ mappingList.forEach(item -> {
|
|
|
|
+ item.setRuleBaseHisName(item.getRuleHisName());
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ tempList.addAll(mappingList);
|
|
|
|
+ } else if (result.getRuleLibType().equals(LexiconEnum.PacsSubName.getKey())) {
|
|
|
|
+ List<ResultRule> mappingList = getMappingResult(result, pacsConfigMap, 1);
|
|
|
|
+ if (result.getRuleLibType().equals(result.getRuleBaseLibType())
|
|
|
|
+ && result.getRuleLibName().equals(result.getRuleBaseLibName())) {
|
|
|
|
+ mappingList.forEach(item -> {
|
|
|
|
+ item.setRuleBaseHisName(item.getRuleHisName());
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ tempList.addAll(mappingList);
|
|
|
|
+ } else if (result.getRuleLibType().equals(LexiconEnum.Transfusion.getKey())) {
|
|
|
|
+ List<ResultRule> mappingList = getMappingResult(result, transfusionConfigMap, 1);
|
|
|
|
+ if (result.getRuleLibType().equals(result.getRuleBaseLibType())
|
|
|
|
+ && result.getRuleLibName().equals(result.getRuleBaseLibName())) {
|
|
|
|
+ mappingList.forEach(item -> {
|
|
|
|
+ item.setRuleBaseHisName(item.getRuleHisName());
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ tempList.addAll(mappingList);
|
|
|
|
+ } else if (result.getRuleLibType().equals(LexiconEnum.PacsResult.getKey())) {
|
|
|
|
+ tempList.add(result);
|
|
|
|
+ } else {
|
|
|
|
+ tempList.add(result);
|
|
}
|
|
}
|
|
- tempList.addAll(mappingList);
|
|
|
|
- } else if (result.getRuleLibType().equals(LexiconEnum.PacsResult.getKey())) {
|
|
|
|
- tempList.add(result);
|
|
|
|
} else {
|
|
} else {
|
|
|
|
+ result.setRuleHisName(entry.getValue().get(0).getRuleHisName());
|
|
|
|
+ result.setRuleHisDetailName(entry.getValue().get(0).getRuleHisDetailName());
|
|
tempList.add(result);
|
|
tempList.add(result);
|
|
}
|
|
}
|
|
tempMap.put(num++, tempList);
|
|
tempMap.put(num++, tempList);
|
|
@@ -727,10 +738,85 @@ public class MedRuleConvertFacade {
|
|
.collect(Collectors.toList()));
|
|
.collect(Collectors.toList()));
|
|
|
|
|
|
//带子条件的规则
|
|
//带子条件的规则
|
|
- Map<Long, List<RuleDTO>> ruleIdMap = list.stream()
|
|
|
|
|
|
+ List<RuleDTO> listWithCond = list.stream()
|
|
.filter(i -> i.getHasSubCond() != null && i.getHasSubCond().equals(1))
|
|
.filter(i -> i.getHasSubCond() != null && i.getHasSubCond().equals(1))
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ if (ListUtil.isEmpty(listWithCond)) {
|
|
|
|
+ return retList;
|
|
|
|
+ }
|
|
|
|
+ List<Long> ruleBaseIds = listWithCond.stream()
|
|
|
|
+ .map(i -> i.getRuleBaseId())
|
|
|
|
+ .distinct()
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ List<KlRuleBase> ruleBaseList = klRuleBaseFacade.list(new QueryWrapper<KlRuleBase>()
|
|
|
|
+ .in("id", ruleBaseIds));
|
|
|
|
+ Map<Long, String> ruleBaseMap = ruleBaseList.stream()
|
|
|
|
+ .collect(Collectors.toMap(k -> k.getId(), v -> v.getConceptId() + "_"
|
|
|
|
+ + v.getType() + "_"
|
|
|
|
+ + v.getMaxOperator() + "_"
|
|
|
|
+ + v.getMaxValue() + "_"
|
|
|
|
+ + v.getMaxUnit() + "_"
|
|
|
|
+ + v.getMinOperator() + "_"
|
|
|
|
+ + v.getMinValue() + "_"
|
|
|
|
+ + v.getMinUnit() + "_"
|
|
|
|
+ + v.getEqOperator() + "_"
|
|
|
|
+ + v.getEqValue() + "_"
|
|
|
|
+ + v.getEqUnit()));
|
|
|
|
+ /*Map<String, String> sameCondMap = ruleBaseList.stream()
|
|
|
|
+ .collect(Collectors.groupingBy(k -> k.getConceptId() + "_"
|
|
|
|
+ + k.getType() + "_"
|
|
|
|
+ + k.getMaxOperator() + "_"
|
|
|
|
+ + k.getMaxValue() + "_"
|
|
|
|
+ + k.getMaxUnit() + "_"
|
|
|
|
+ + k.getMinOperator() + "_"
|
|
|
|
+ + k.getMinValue() + "_"
|
|
|
|
+ + k.getMinUnit() + "_"
|
|
|
|
+ + k.getEqOperator() + "_"
|
|
|
|
+ + k.getEqValue() + "_"
|
|
|
|
+ + k.getEqUnit(),
|
|
|
|
+ Collectors.mapping(v -> v.getId().toString(), Collectors.joining("|"))));
|
|
|
|
+ Map<String, Boolean> usedCondMap = new HashMap<>();
|
|
|
|
+ for (Map.Entry<String, String> entry : sameCondMap.entrySet()) {
|
|
|
|
+ usedCondMap.put(entry.getValue(), false);
|
|
|
|
+ }*/
|
|
|
|
+
|
|
|
|
+ Map<Long, List<RuleDTO>> ruleIdMap = listWithCond.stream()
|
|
.collect(Collectors.groupingBy(RuleDTO::getRuleId));
|
|
.collect(Collectors.groupingBy(RuleDTO::getRuleId));
|
|
- //Map<ruleId,Map<groupType_ruleBaseId,RuleDTO>>
|
|
|
|
|
|
+ Map<Long, Map<String, RuleDTO>> baseNestMap = new HashMap<>();
|
|
|
|
+ Map<Long, String> baseCondMap = new HashMap<>();
|
|
|
|
+ for (Map.Entry<Long, List<RuleDTO>> entry : ruleIdMap.entrySet()) {
|
|
|
|
+ Map<String, RuleDTO> subMap = new HashMap<>();
|
|
|
|
+ for (RuleDTO result : entry.getValue()) {
|
|
|
|
+ subMap.put(ruleBaseMap.get(result.getRuleBaseId()), result);
|
|
|
|
+ }
|
|
|
|
+ baseNestMap.put(entry.getKey(), subMap);
|
|
|
|
+ baseCondMap.put(entry.getKey(), subMap.keySet().stream().sorted().collect(Collectors.joining("|")));
|
|
|
|
+ }
|
|
|
|
+ Map<String, List<Long>> baseReversedMap = new HashMap<>();
|
|
|
|
+ for (Map.Entry<Long, String> entry : baseCondMap.entrySet()) {
|
|
|
|
+ List<Long> ruleIds = Lists.newLinkedList();
|
|
|
|
+ if (baseReversedMap.containsKey(entry.getValue())) {
|
|
|
|
+ ruleIds = baseReversedMap.get(entry.getValue());
|
|
|
|
+ }
|
|
|
|
+ ruleIds.add(entry.getKey());
|
|
|
|
+ baseReversedMap.put(entry.getValue(), ruleIds);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for (Map.Entry<String, List<Long>> entry : baseReversedMap.entrySet()) {
|
|
|
|
+ if (ListUtil.isEmpty(entry.getValue())) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ Integer num = 0;
|
|
|
|
+ List<String> baseIdList = Arrays.asList(entry.getKey().split("\\|"));
|
|
|
|
+ for (Long ruleId : entry.getValue()) {
|
|
|
|
+ retList.add(baseNestMap.get(ruleId).get(baseIdList.get(num++)));
|
|
|
|
+ if (num == baseIdList.size()) {
|
|
|
|
+ num = 0;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /*//Map<ruleId,Map<groupType_ruleBaseId,RuleDTO>>
|
|
Map<Long, Map<String, RuleDTO>> nestMap = new HashMap<>();
|
|
Map<Long, Map<String, RuleDTO>> nestMap = new HashMap<>();
|
|
//Map<ruleId,groupType_ruleBaseId|groupType_ruleBaseId|groupType_ruleBaseId……>
|
|
//Map<ruleId,groupType_ruleBaseId|groupType_ruleBaseId|groupType_ruleBaseId……>
|
|
Map<Long, String> conditionMap = new HashMap<>();
|
|
Map<Long, String> conditionMap = new HashMap<>();
|
|
@@ -743,6 +829,7 @@ public class MedRuleConvertFacade {
|
|
.map(i -> i.getGroupType() + "_" + i.getRuleBaseId())
|
|
.map(i -> i.getGroupType() + "_" + i.getRuleBaseId())
|
|
.collect(Collectors.joining("|")));
|
|
.collect(Collectors.joining("|")));
|
|
}
|
|
}
|
|
|
|
+
|
|
//Map<groupType_ruleBaseId,List<ruleId>
|
|
//Map<groupType_ruleBaseId,List<ruleId>
|
|
Map<String, List<Long>> reversedMap = new HashMap<>();
|
|
Map<String, List<Long>> reversedMap = new HashMap<>();
|
|
for (Map.Entry<Long, String> entry : conditionMap.entrySet()) {
|
|
for (Map.Entry<Long, String> entry : conditionMap.entrySet()) {
|
|
@@ -766,7 +853,7 @@ public class MedRuleConvertFacade {
|
|
num = 0;
|
|
num = 0;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ }*/
|
|
|
|
|
|
return retList;
|
|
return retList;
|
|
}
|
|
}
|