|
@@ -1554,13 +1554,145 @@ public class MappingConfigFacade extends MappingConfigServiceImpl {
|
|
|
+ "。导入取消,请修改后再试。\n");
|
|
|
}
|
|
|
|
|
|
+ originList = originList.stream().distinct().collect(Collectors.toList());
|
|
|
+ //原始数据为空
|
|
|
+ if (ListUtil.isEmpty(originList)) {
|
|
|
+ return errorList;
|
|
|
+ }
|
|
|
+
|
|
|
+ //标准术语校验
|
|
|
+ ConceptVO conceptVO = new ConceptVO();
|
|
|
+ conceptVO.setSource(MatchSourceEnum.StandWord.getKey());
|
|
|
+ conceptVO.setStatus(StatusEnum.Enable.getKey());
|
|
|
+ if (type.equals(ConceptTypeEnum.LisPack.getKey())) {
|
|
|
+ conceptVO.setType(ConceptTypeEnum.LisPack.getKey());
|
|
|
+ conceptVO.setNames(originList.stream()
|
|
|
+ .filter(i -> StringUtil.isBlank(i.getHisDetailName())
|
|
|
+ && StringUtil.isNotBlank(i.getUniqueName()))
|
|
|
+ .map(MappingConfigWrapper::getUniqueName)
|
|
|
+ .distinct()
|
|
|
+ .collect(Collectors.toList()));
|
|
|
+ RespDTO<List<IndexBatchDTO>> respDTO = cdssCoreClient.getConceptNames(conceptVO);
|
|
|
+ RespDTOUtil.respNGDealCover(respDTO, "标准术语校验失败");
|
|
|
+ Map<String, List<Long>> packMap = new HashMap<>();
|
|
|
+ packMap = respDTO.data.stream()
|
|
|
+ .collect(Collectors.groupingBy(IndexBatchDTO::getName,
|
|
|
+ Collectors.mapping(IndexBatchDTO::getId, Collectors.toList())));
|
|
|
+
|
|
|
+ conceptVO.setType(ConceptTypeEnum.Lis.getKey());
|
|
|
+ conceptVO.setNames(originList.stream()
|
|
|
+ .filter(i -> StringUtil.isNotBlank(i.getHisDetailName())
|
|
|
+ && StringUtil.isNotBlank(i.getUniqueName()))
|
|
|
+ .map(MappingConfigWrapper::getUniqueName)
|
|
|
+ .distinct()
|
|
|
+ .collect(Collectors.toList()));
|
|
|
+ Map<String, List<Long>> lisMap = new HashMap<>();
|
|
|
+ if (ListUtil.isNotEmpty(conceptVO.getNames())) {
|
|
|
+ respDTO = cdssCoreClient.getConceptNames(conceptVO);
|
|
|
+ RespDTOUtil.respNGDealCover(respDTO, "标准术语校验失败");
|
|
|
+ lisMap = respDTO.data.stream()
|
|
|
+ .collect(Collectors.groupingBy(IndexBatchDTO::getName,
|
|
|
+ Collectors.mapping(IndexBatchDTO::getId, Collectors.toList())));
|
|
|
+ }
|
|
|
+
|
|
|
+ for (MappingConfigWrapper item : originList) {
|
|
|
+ if (StringUtil.isBlank(item.getUniqueName())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (StringUtil.isBlank(item.getHisDetailName())) {
|
|
|
+ if (packMap.containsKey(item.getUniqueName())) {
|
|
|
+ item.setConceptId(packMap.get(item.getUniqueName()).get(0));
|
|
|
+ item.setIsMatch(1);
|
|
|
+ } else {
|
|
|
+ item.setIsMatch(0);
|
|
|
+ MappingConfigWrapper errorItem = new MappingConfigWrapper();
|
|
|
+ BeanUtils.copyProperties(item, errorItem);
|
|
|
+ errorItem.setIsMatch(null);
|
|
|
+ errorList.add(errorItem);
|
|
|
+ item.setUniqueName("");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (lisMap.containsKey(item.getUniqueName())) {
|
|
|
+ item.setConceptId(lisMap.get(item.getUniqueName()).get(0));
|
|
|
+ item.setIsMatch(1);
|
|
|
+ } else {
|
|
|
+ item.setIsMatch(0);
|
|
|
+ MappingConfigWrapper errorItem = new MappingConfigWrapper();
|
|
|
+ BeanUtils.copyProperties(item, errorItem);
|
|
|
+ errorItem.setIsMatch(null);
|
|
|
+ errorList.add(errorItem);
|
|
|
+ item.setUniqueName("");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ conceptVO.setType(type);
|
|
|
+ conceptVO.setNames(originList.stream()
|
|
|
+ .filter(i -> StringUtil.isNotBlank(i.getUniqueName()))
|
|
|
+ .map(MappingConfigWrapper::getUniqueName)
|
|
|
+ .distinct()
|
|
|
+ .collect(Collectors.toList()));
|
|
|
+ RespDTO<List<IndexBatchDTO>> respDTO = cdssCoreClient.getConceptNames(conceptVO);
|
|
|
+ if (RespDTOUtil.respIsOK(respDTO)) {
|
|
|
+ Map<String, List<Long>> map = respDTO.data.stream()
|
|
|
+ .collect(Collectors.groupingBy(IndexBatchDTO::getName,
|
|
|
+ Collectors.mapping(IndexBatchDTO::getId, Collectors.toList())));
|
|
|
+ for (MappingConfigWrapper item : originList) {
|
|
|
+ if (StringUtil.isBlank(item.getUniqueName())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (map.containsKey(item.getUniqueName())) {
|
|
|
+ item.setConceptId(map.get(item.getUniqueName()).get(0));
|
|
|
+ item.setIsMatch(1);
|
|
|
+ } else {
|
|
|
+ item.setIsMatch(0);
|
|
|
+ MappingConfigWrapper errorItem = new MappingConfigWrapper();
|
|
|
+ BeanUtils.copyProperties(item, errorItem);
|
|
|
+ errorItem.setIsMatch(null);
|
|
|
+ errorList.add(errorItem);
|
|
|
+ item.setUniqueName("");
|
|
|
+ //标准词校验不通过,剂型置空
|
|
|
+ if (StringUtil.isNotBlank(item.getForm())) {
|
|
|
+ item.setForm("");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //剂型校验
|
|
|
+ if (type.equals(ConceptTypeEnum.Drug.getKey())) {
|
|
|
+ conceptVO.setType(ConceptTypeEnum.Form.getKey());
|
|
|
+ conceptVO.setNames(originList.stream()
|
|
|
+ .filter(i -> StringUtil.isNotBlank(i.getForm()))
|
|
|
+ .map(MappingConfigWrapper::getForm)
|
|
|
+ .distinct()
|
|
|
+ .collect(Collectors.toList()));
|
|
|
+ RespDTO<List<IndexBatchDTO>> respDTO = cdssCoreClient.getConceptNames(conceptVO);
|
|
|
+ if (RespDTOUtil.respIsOK(respDTO)) {
|
|
|
+ Map<String, List<Long>> formMap = respDTO.data.stream()
|
|
|
+ .collect(Collectors.groupingBy(IndexBatchDTO::getName,
|
|
|
+ Collectors.mapping(IndexBatchDTO::getId, Collectors.toList())));
|
|
|
+ for (MappingConfigWrapper item : originList) {
|
|
|
+ if (StringUtil.isBlank(item.getForm())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (formMap.containsKey(item.getForm())) {
|
|
|
+ item.setFormConceptId(formMap.get(item.getForm()).get(0));
|
|
|
+ } else {
|
|
|
+ //标准词已匹配,剂型未匹配,不做错误数据,不改变匹配标志
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ originList = originList.stream().distinct().collect(Collectors.toList());
|
|
|
List<String> hisNames = originList
|
|
|
.stream()
|
|
|
.map(i -> i.getHisName())
|
|
|
.distinct()
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
- originList = originList.stream().distinct().collect(Collectors.toList());
|
|
|
List<MappingConfigWrapper> matchList
|
|
|
= originList.stream().filter(i -> StringUtil.isNotBlank(i.getUniqueName())).collect(Collectors.toList());
|
|
|
Map<String, List<MappingConfigWrapper>> matchMap
|
|
@@ -1579,6 +1711,7 @@ public class MappingConfigFacade extends MappingConfigServiceImpl {
|
|
|
= unMatchList.stream().collect(Collectors.groupingBy(i -> i.getHisName() + "_"
|
|
|
+ i.getHisCode() + "_"
|
|
|
+ i.getHisDetailName()));
|
|
|
+ //导入文件中同时存在已匹配未匹配数据,删除未匹配数据
|
|
|
Iterator<MappingConfigWrapper> it = unMatchList.iterator();
|
|
|
while (it.hasNext()) {
|
|
|
MappingConfigWrapper item = it.next();
|
|
@@ -1640,6 +1773,7 @@ public class MappingConfigFacade extends MappingConfigServiceImpl {
|
|
|
+ i.getHisDetailName()));
|
|
|
|
|
|
for (MappingConfigWrapper item : db_matchList) {
|
|
|
+ //导入文件中与数据库中存在完全一致的已匹配数据,删除数据库中的,把导入文件中的新增到数据库
|
|
|
String matchKey = item.getHisName() + "_"
|
|
|
+ item.getHisCode() + "_"
|
|
|
+ item.getHisDetailName() + "_"
|
|
@@ -1650,6 +1784,7 @@ public class MappingConfigFacade extends MappingConfigServiceImpl {
|
|
|
}
|
|
|
}
|
|
|
for (MappingConfigWrapper item : db_unMatchList) {
|
|
|
+ //导入文件中存在已匹配的数据,数据库中存在未匹配的,删除数据库中的,把导入文件中的新增到数据库
|
|
|
String matchKey = item.getHisName() + "_"
|
|
|
+ item.getHisCode() + "_"
|
|
|
+ item.getHisDetailName();
|
|
@@ -1677,159 +1812,15 @@ public class MappingConfigFacade extends MappingConfigServiceImpl {
|
|
|
tempList.addAll(matchList);
|
|
|
tempList.addAll(unMatchList);
|
|
|
|
|
|
- //标准术语校验
|
|
|
- ConceptVO conceptVO = new ConceptVO();
|
|
|
- conceptVO.setSource(MatchSourceEnum.StandWord.getKey());
|
|
|
- conceptVO.setStatus(StatusEnum.Enable.getKey());
|
|
|
- if (type.equals(ConceptTypeEnum.LisPack.getKey())) {
|
|
|
- conceptVO.setType(ConceptTypeEnum.LisPack.getKey());
|
|
|
- conceptVO.setNames(tempList.stream()
|
|
|
- .filter(i -> StringUtil.isBlank(i.getHisDetailName())
|
|
|
- && StringUtil.isNotBlank(i.getUniqueName()))
|
|
|
- .map(MappingConfigWrapper::getUniqueName)
|
|
|
- .distinct()
|
|
|
- .collect(Collectors.toList()));
|
|
|
- RespDTO<List<IndexBatchDTO>> respDTO = cdssCoreClient.getConceptNames(conceptVO);
|
|
|
- RespDTOUtil.respNGDealCover(respDTO, "标准术语校验失败");
|
|
|
- Map<String, List<Long>> packMap = new HashMap<>();
|
|
|
- packMap = respDTO.data.stream()
|
|
|
- .collect(Collectors.groupingBy(IndexBatchDTO::getName,
|
|
|
- Collectors.mapping(IndexBatchDTO::getId, Collectors.toList())));
|
|
|
-
|
|
|
- conceptVO.setType(ConceptTypeEnum.Lis.getKey());
|
|
|
- conceptVO.setNames(tempList.stream()
|
|
|
- .filter(i -> StringUtil.isNotBlank(i.getHisDetailName())
|
|
|
- && StringUtil.isNotBlank(i.getUniqueName()))
|
|
|
- .map(MappingConfigWrapper::getUniqueName)
|
|
|
- .distinct()
|
|
|
- .collect(Collectors.toList()));
|
|
|
- Map<String, List<Long>> lisMap = new HashMap<>();
|
|
|
- if (ListUtil.isNotEmpty(conceptVO.getNames())) {
|
|
|
- respDTO = cdssCoreClient.getConceptNames(conceptVO);
|
|
|
- RespDTOUtil.respNGDealCover(respDTO, "标准术语校验失败");
|
|
|
- lisMap = respDTO.data.stream()
|
|
|
- .collect(Collectors.groupingBy(IndexBatchDTO::getName,
|
|
|
- Collectors.mapping(IndexBatchDTO::getId, Collectors.toList())));
|
|
|
- }
|
|
|
-
|
|
|
- for (MappingConfigWrapper item : tempList) {
|
|
|
- if (StringUtil.isBlank(item.getUniqueName())) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (StringUtil.isBlank(item.getHisDetailName())) {
|
|
|
- if (packMap.containsKey(item.getUniqueName())) {
|
|
|
- item.setConceptId(packMap.get(item.getUniqueName()).get(0));
|
|
|
- item.setIsMatch(1);
|
|
|
- } else {
|
|
|
- item.setIsMatch(0);
|
|
|
- MappingConfigWrapper errorItem = new MappingConfigWrapper();
|
|
|
- BeanUtils.copyProperties(item, errorItem);
|
|
|
- errorItem.setIsMatch(null);
|
|
|
- errorList.add(errorItem);
|
|
|
- item.setUniqueName("");
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (lisMap.containsKey(item.getUniqueName())) {
|
|
|
- item.setConceptId(lisMap.get(item.getUniqueName()).get(0));
|
|
|
- item.setIsMatch(1);
|
|
|
- } else {
|
|
|
- item.setIsMatch(0);
|
|
|
- MappingConfigWrapper errorItem = new MappingConfigWrapper();
|
|
|
- BeanUtils.copyProperties(item, errorItem);
|
|
|
- errorItem.setIsMatch(null);
|
|
|
- errorList.add(errorItem);
|
|
|
- item.setUniqueName("");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- conceptVO.setType(type);
|
|
|
- conceptVO.setNames(tempList.stream()
|
|
|
- .filter(i -> StringUtil.isNotBlank(i.getUniqueName()))
|
|
|
- .map(MappingConfigWrapper::getUniqueName)
|
|
|
- .distinct()
|
|
|
- .collect(Collectors.toList()));
|
|
|
- RespDTO<List<IndexBatchDTO>> respDTO = cdssCoreClient.getConceptNames(conceptVO);
|
|
|
- if (RespDTOUtil.respIsOK(respDTO)) {
|
|
|
- Map<String, List<Long>> map = respDTO.data.stream()
|
|
|
- .collect(Collectors.groupingBy(IndexBatchDTO::getName,
|
|
|
- Collectors.mapping(IndexBatchDTO::getId, Collectors.toList())));
|
|
|
- for (MappingConfigWrapper item : tempList) {
|
|
|
- if (StringUtil.isBlank(item.getUniqueName())) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (map.containsKey(item.getUniqueName())) {
|
|
|
- item.setConceptId(map.get(item.getUniqueName()).get(0));
|
|
|
- item.setIsMatch(1);
|
|
|
- } else {
|
|
|
- item.setIsMatch(0);
|
|
|
- MappingConfigWrapper errorItem = new MappingConfigWrapper();
|
|
|
- BeanUtils.copyProperties(item, errorItem);
|
|
|
- item.setUniqueName("");
|
|
|
- //标准词校验不通过,剂型置空
|
|
|
- if (StringUtil.isNotBlank(item.getForm())) {
|
|
|
- item.setForm("");
|
|
|
- }
|
|
|
- errorItem.setIsMatch(null);
|
|
|
- errorList.add(errorItem);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //剂型校验
|
|
|
- if (type.equals(ConceptTypeEnum.Drug.getKey())) {
|
|
|
- conceptVO.setType(ConceptTypeEnum.Form.getKey());
|
|
|
- conceptVO.setNames(tempList.stream()
|
|
|
- .filter(i -> StringUtil.isNotBlank(i.getForm()))
|
|
|
- .map(MappingConfigWrapper::getForm)
|
|
|
- .distinct()
|
|
|
- .collect(Collectors.toList()));
|
|
|
- RespDTO<List<IndexBatchDTO>> respDTO = cdssCoreClient.getConceptNames(conceptVO);
|
|
|
- if (RespDTOUtil.respIsOK(respDTO)) {
|
|
|
- Map<String, List<Long>> formMap = respDTO.data.stream()
|
|
|
- .collect(Collectors.groupingBy(IndexBatchDTO::getName,
|
|
|
- Collectors.mapping(IndexBatchDTO::getId, Collectors.toList())));
|
|
|
- for (MappingConfigWrapper item : tempList) {
|
|
|
- if (StringUtil.isBlank(item.getForm())) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (formMap.containsKey(item.getForm())) {
|
|
|
- item.setFormConceptId(formMap.get(item.getForm()).get(0));
|
|
|
- } else {
|
|
|
- //标准词已匹配,剂型未匹配,不做错误数据
|
|
|
- /*if (item.getIsMatch().equals(1)) {
|
|
|
- item.setIsMatch(0);
|
|
|
- errorList.add(item);
|
|
|
- }*/
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
//重复数据过滤
|
|
|
tempList = tempList
|
|
|
.stream()
|
|
|
.distinct()
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
- //去除未匹配数据(数据校验导致匹配标志变化)
|
|
|
- matchList = tempList.stream().filter(i -> StringUtil.isNotBlank(i.getUniqueName())).collect(Collectors.toList());
|
|
|
- matchMap = matchList.stream().collect(Collectors.groupingBy(i -> i.getHisName() + "_"
|
|
|
- + i.getHisCode() + "_"
|
|
|
- + i.getHisDetailName()));
|
|
|
+ //生成保存数据
|
|
|
List<MappingConfig> saveList = Lists.newLinkedList();
|
|
|
for (MappingConfigWrapper item : tempList) {
|
|
|
- //检查标准术语校验后未匹配的数据是否有对应已匹配的数据,有则删除未匹配数据
|
|
|
- if (item.getIsMatch().equals(0)) {
|
|
|
- String key = item.getHisName() + "_" + item.getHisCode() + "_" + item.getHisDetailName();
|
|
|
- if (matchMap.containsKey(key)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (db_matchMap.containsKey(key)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- }
|
|
|
item.setHospitalId(hospitalId);
|
|
|
item.setType(type);
|
|
|
item.setCreator(userId);
|