|
@@ -1,5 +1,6 @@
|
|
|
package com.diagbot.facade;
|
|
|
|
|
|
+import cn.afterturn.easypoi.exception.excel.ExcelImportException;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
@@ -44,6 +45,7 @@ import com.diagbot.vo.IdVO;
|
|
|
import com.diagbot.vo.KllisDetailVO;
|
|
|
import com.diagbot.vo.MappingConfigPageVO;
|
|
|
import com.diagbot.vo.MappingConfigVO;
|
|
|
+import com.diagbot.vo.PrecDataVO;
|
|
|
import com.diagbot.vo.RetrievalVO;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
@@ -97,31 +99,43 @@ public class MappingConfigFacade extends MappingConfigServiceImpl {
|
|
|
RespDTO<List<IndexBatchDTO>> respDTO = null;
|
|
|
|
|
|
//todo 标准词转conceptId
|
|
|
+ List<Long> conceptIds = Lists.newLinkedList();
|
|
|
if (StringUtil.isNotBlank(mappingConfigPageVO.getUniqueName())) {
|
|
|
filterVO.setInputStr(mappingConfigPageVO.getUniqueName());
|
|
|
respDTO = cdssCoreClient.filter(filterVO);
|
|
|
- if (RespDTOUtil.respIsOK(respDTO) && ListUtil.isNotEmpty(respDTO.data)) {
|
|
|
- mappingConfigPageVO.setConceptIds(respDTO.data
|
|
|
- .stream()
|
|
|
- .map(IndexBatchDTO::getId)
|
|
|
- .distinct()
|
|
|
- .collect(Collectors.toList()));
|
|
|
+ if (RespDTOUtil.respIsOK(respDTO)) {
|
|
|
+ if (ListUtil.isNotEmpty(respDTO.data)) {
|
|
|
+ conceptIds.addAll(respDTO.data
|
|
|
+ .stream()
|
|
|
+ .map(IndexBatchDTO::getId)
|
|
|
+ .distinct()
|
|
|
+ .collect(Collectors.toList()));
|
|
|
+ } else {
|
|
|
+ conceptIds.add(-1L);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ mappingConfigPageVO.setConceptIds(conceptIds);
|
|
|
|
|
|
//todo 药品剂型转 conceptId
|
|
|
+ List<Long> formConceptIds = Lists.newLinkedList();
|
|
|
if (StringUtil.isNotBlank(mappingConfigPageVO.getForm())) {
|
|
|
filterVO.setInputStr(mappingConfigPageVO.getForm());
|
|
|
respDTO = cdssCoreClient.filter(filterVO);
|
|
|
- if (RespDTOUtil.respIsOK(respDTO) && ListUtil.isNotEmpty(respDTO.data)) {
|
|
|
- mappingConfigPageVO.setFormConceptIds(respDTO.data
|
|
|
- .stream()
|
|
|
- .filter(i -> i.getType().equals(ConceptTypeEnum.Form.getKey()))
|
|
|
- .map(IndexBatchDTO::getId)
|
|
|
- .distinct()
|
|
|
- .collect(Collectors.toList()));
|
|
|
+ if (RespDTOUtil.respIsOK(respDTO)) {
|
|
|
+ if (ListUtil.isNotEmpty(respDTO.data)) {
|
|
|
+ formConceptIds.addAll(respDTO.data
|
|
|
+ .stream()
|
|
|
+ .filter(i -> i.getType().equals(ConceptTypeEnum.Form.getKey()))
|
|
|
+ .map(IndexBatchDTO::getId)
|
|
|
+ .distinct()
|
|
|
+ .collect(Collectors.toList()));
|
|
|
+ } else {
|
|
|
+ formConceptIds.add(-1L);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ mappingConfigPageVO.setFormConceptIds(formConceptIds);
|
|
|
|
|
|
//todo 多条匹配
|
|
|
if (mappingConfigPageVO.getIsMatch() != null && mappingConfigPageVO.getIsMatch().equals(2)) {
|
|
@@ -290,61 +304,70 @@ public class MappingConfigFacade extends MappingConfigServiceImpl {
|
|
|
*
|
|
|
* @param file
|
|
|
* @param type
|
|
|
+ * @param source 1-预匹配,2-导入
|
|
|
* @return
|
|
|
*/
|
|
|
- public List<MappingConfigWrapper> readImportData(MultipartFile file, Integer type) {
|
|
|
+ public List<MappingConfigWrapper> readImportData(MultipartFile file, Integer type, Integer source) {
|
|
|
List<MappingConfigWrapper> originList = Lists.newLinkedList();
|
|
|
- switch (type) {
|
|
|
- case 1:
|
|
|
- List<LisConfig> lisConfigList = ExcelUtils.importExcel(file, 0, 1, LisConfig.class);
|
|
|
- originList = BeanUtil.listCopyTo(lisConfigList, MappingConfigWrapper.class);
|
|
|
- break;
|
|
|
- case 3:
|
|
|
- List<PacsConfig> pacsConfigList = ExcelUtils.importExcel(file, 0, 1, PacsConfig.class);
|
|
|
- originList = BeanUtil.listCopyTo(pacsConfigList, MappingConfigWrapper.class);
|
|
|
- break;
|
|
|
- case 4:
|
|
|
- List<DiseaseConfig> diseaseConfigList = ExcelUtils.importExcel(file, 0, 1, DiseaseConfig.class);
|
|
|
- originList = BeanUtil.listCopyTo(diseaseConfigList, MappingConfigWrapper.class);
|
|
|
- break;
|
|
|
- case 5:
|
|
|
- List<DrugConfig> drugConfigList = ExcelUtils.importExcel(file, 1, 1, DrugConfig.class);
|
|
|
- originList = BeanUtil.listCopyTo(drugConfigList, MappingConfigWrapper.class);
|
|
|
- break;
|
|
|
- case 6:
|
|
|
- List<OperationConfig> operationConfigList = ExcelUtils.importExcel(file, 0, 1, OperationConfig.class);
|
|
|
- originList = BeanUtil.listCopyTo(operationConfigList, MappingConfigWrapper.class);
|
|
|
- break;
|
|
|
- case 7:
|
|
|
- List<DeptConfig> deptConfigList = ExcelUtils.importExcel(file, 0, 1, DeptConfig.class);
|
|
|
- originList = BeanUtil.listCopyTo(deptConfigList, MappingConfigWrapper.class);
|
|
|
- break;
|
|
|
- case 8:
|
|
|
- List<TransfusionConfig> transfusionConfigList = ExcelUtils.importExcel(file, 0, 1, TransfusionConfig.class);
|
|
|
- originList = BeanUtil.listCopyTo(transfusionConfigList, MappingConfigWrapper.class);
|
|
|
- break;
|
|
|
- case 10:
|
|
|
- List<ScaleConfig> scaleConfigList = ExcelUtils.importExcel(file, 0, 1, ScaleConfig.class);
|
|
|
- originList = BeanUtil.listCopyTo(scaleConfigList, MappingConfigWrapper.class);
|
|
|
- break;
|
|
|
- case 11:
|
|
|
- List<NurseConfig> nurseConfigList = ExcelUtils.importExcel(file, 0, 1, NurseConfig.class);
|
|
|
- originList = BeanUtil.listCopyTo(nurseConfigList, MappingConfigWrapper.class);
|
|
|
- break;
|
|
|
- case 12:
|
|
|
- List<TcmdiseaseConfig> tcmdiseaseConfigList = ExcelUtils.importExcel(file, 0, 1, TcmdiseaseConfig.class);
|
|
|
- originList = BeanUtil.listCopyTo(tcmdiseaseConfigList, MappingConfigWrapper.class);
|
|
|
- break;
|
|
|
- case 13:
|
|
|
- List<TcmsyndromeConfig> tcmsyndromeConfigList = ExcelUtils.importExcel(file, 0, 1, TcmsyndromeConfig.class);
|
|
|
- originList = BeanUtil.listCopyTo(tcmsyndromeConfigList, MappingConfigWrapper.class);
|
|
|
- break;
|
|
|
- case 14:
|
|
|
- List<AnesthesiaConfig> anesthesiaConfigList = ExcelUtils.importExcel(file, 0, 1, AnesthesiaConfig.class);
|
|
|
- originList = BeanUtil.listCopyTo(anesthesiaConfigList, MappingConfigWrapper.class);
|
|
|
- break;
|
|
|
- default:
|
|
|
- break;
|
|
|
+ try {
|
|
|
+ switch (type) {
|
|
|
+ case 1:
|
|
|
+ List<LisConfig> lisConfigList = ExcelUtils.importExcel(file, 0, 1, LisConfig.class);
|
|
|
+ originList = BeanUtil.listCopyTo(lisConfigList, MappingConfigWrapper.class);
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ List<PacsConfig> pacsConfigList = ExcelUtils.importExcel(file, 0, 1, PacsConfig.class);
|
|
|
+ originList = BeanUtil.listCopyTo(pacsConfigList, MappingConfigWrapper.class);
|
|
|
+ break;
|
|
|
+ case 4:
|
|
|
+ List<DiseaseConfig> diseaseConfigList = ExcelUtils.importExcel(file, 0, 1, DiseaseConfig.class);
|
|
|
+ originList = BeanUtil.listCopyTo(diseaseConfigList, MappingConfigWrapper.class);
|
|
|
+ break;
|
|
|
+ case 5:
|
|
|
+ List<DrugConfig> drugConfigList = ExcelUtils.importExcel(file, 1, 1, DrugConfig.class);
|
|
|
+ originList = BeanUtil.listCopyTo(drugConfigList, MappingConfigWrapper.class);
|
|
|
+ break;
|
|
|
+ case 6:
|
|
|
+ List<OperationConfig> operationConfigList = ExcelUtils.importExcel(file, 0, 1, OperationConfig.class);
|
|
|
+ originList = BeanUtil.listCopyTo(operationConfigList, MappingConfigWrapper.class);
|
|
|
+ break;
|
|
|
+ case 7:
|
|
|
+ List<DeptConfig> deptConfigList = ExcelUtils.importExcel(file, 0, 1, DeptConfig.class);
|
|
|
+ originList = BeanUtil.listCopyTo(deptConfigList, MappingConfigWrapper.class);
|
|
|
+ break;
|
|
|
+ case 8:
|
|
|
+ List<TransfusionConfig> transfusionConfigList = ExcelUtils.importExcel(file, 0, 1, TransfusionConfig.class);
|
|
|
+ originList = BeanUtil.listCopyTo(transfusionConfigList, MappingConfigWrapper.class);
|
|
|
+ break;
|
|
|
+ case 10:
|
|
|
+ List<ScaleConfig> scaleConfigList = ExcelUtils.importExcel(file, 0, 1, ScaleConfig.class);
|
|
|
+ originList = BeanUtil.listCopyTo(scaleConfigList, MappingConfigWrapper.class);
|
|
|
+ break;
|
|
|
+ case 11:
|
|
|
+ List<NurseConfig> nurseConfigList = ExcelUtils.importExcel(file, 0, 1, NurseConfig.class);
|
|
|
+ originList = BeanUtil.listCopyTo(nurseConfigList, MappingConfigWrapper.class);
|
|
|
+ break;
|
|
|
+ case 12:
|
|
|
+ List<TcmdiseaseConfig> tcmdiseaseConfigList = ExcelUtils.importExcel(file, 0, 1, TcmdiseaseConfig.class);
|
|
|
+ originList = BeanUtil.listCopyTo(tcmdiseaseConfigList, MappingConfigWrapper.class);
|
|
|
+ break;
|
|
|
+ case 13:
|
|
|
+ List<TcmsyndromeConfig> tcmsyndromeConfigList = ExcelUtils.importExcel(file, 0, 1, TcmsyndromeConfig.class);
|
|
|
+ originList = BeanUtil.listCopyTo(tcmsyndromeConfigList, MappingConfigWrapper.class);
|
|
|
+ break;
|
|
|
+ case 14:
|
|
|
+ List<AnesthesiaConfig> anesthesiaConfigList = ExcelUtils.importExcel(file, 0, 1, AnesthesiaConfig.class);
|
|
|
+ originList = BeanUtil.listCopyTo(anesthesiaConfigList, MappingConfigWrapper.class);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ } catch (ExcelImportException e) {
|
|
|
+
|
|
|
+ } catch (CommonException e) {
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "校验失败,请使用模板进行数据" + (source == 1 ? "预匹配" : "导入"));
|
|
|
+ } catch (Exception e) {
|
|
|
+
|
|
|
}
|
|
|
return originList;
|
|
|
}
|
|
@@ -356,7 +379,7 @@ public class MappingConfigFacade extends MappingConfigServiceImpl {
|
|
|
* @return
|
|
|
*/
|
|
|
public Boolean dataVerify(MultipartFile file, Integer type) {
|
|
|
- List<MappingConfigWrapper> originList = readImportData(file, type);
|
|
|
+ List<MappingConfigWrapper> originList = readImportData(file, type, 1);
|
|
|
List<MappingConfigWrapper> retList = precDataProcess(originList, type);
|
|
|
return true;
|
|
|
}
|
|
@@ -369,7 +392,7 @@ public class MappingConfigFacade extends MappingConfigServiceImpl {
|
|
|
* @param response
|
|
|
*/
|
|
|
public void precDataMatch(MultipartFile file, Integer type, HttpServletResponse response) {
|
|
|
- List<MappingConfigWrapper> originList = readImportData(file, type);
|
|
|
+ List<MappingConfigWrapper> originList = readImportData(file, type, 1);
|
|
|
List<MappingConfigWrapper> retList = precDataProcess(originList, type);
|
|
|
exportExcel(response, retList, type, "关联数据(预匹配)");
|
|
|
}
|
|
@@ -382,11 +405,26 @@ public class MappingConfigFacade extends MappingConfigServiceImpl {
|
|
|
* @return
|
|
|
*/
|
|
|
public List<MappingConfigWrapper> precDataMatch_remote(MultipartFile file, Integer type) {
|
|
|
- List<MappingConfigWrapper> originList = readImportData(file, type);
|
|
|
+ List<MappingConfigWrapper> originList = readImportData(file, type, 1);
|
|
|
List<MappingConfigWrapper> retList = precDataProcess(originList, type);
|
|
|
return retList;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 预匹配(非文件匹配)
|
|
|
+ *
|
|
|
+ * @param precDataVO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public List<MappingConfigWrapper> precData(PrecDataVO precDataVO) {
|
|
|
+ if (ListUtil.isEmpty(precDataVO.getOriginList())) {
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "请确认术语列表不为空");
|
|
|
+ }
|
|
|
+ List<MappingConfigWrapper> originList = BeanUtil.listCopyTo(precDataVO.getOriginList(), MappingConfigWrapper.class);
|
|
|
+ List<MappingConfigWrapper> data = precDataProcess(originList, precDataVO.getType());
|
|
|
+ return data;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 预匹配数据处理
|
|
|
*
|
|
@@ -399,29 +437,71 @@ public class MappingConfigFacade extends MappingConfigServiceImpl {
|
|
|
List<MappingConfigWrapper> standardList = Lists.newLinkedList();
|
|
|
List<MappingConfigWrapper> synonymsList = Lists.newLinkedList();
|
|
|
List<MappingConfigWrapper> codeList = Lists.newLinkedList();
|
|
|
+ List<MappingConfigWrapper> historyList = Lists.newLinkedList();
|
|
|
+ List<MappingConfigWrapper> drugList = Lists.newLinkedList();
|
|
|
+
|
|
|
+ //去除空行
|
|
|
+ /*originList = originList.stream()
|
|
|
+ .filter(MappingConfigWrapper::nonNull)
|
|
|
+ .collect(Collectors.toList());*/
|
|
|
|
|
|
//数据完整性校验
|
|
|
+ List<Integer> emptyNumList = Lists.newLinkedList();
|
|
|
+ Integer rowId = 1;
|
|
|
for (MappingConfigWrapper item : originList) {
|
|
|
+ ++rowId;
|
|
|
//过滤医院术语名称为空的条目
|
|
|
- if (StringUtil.isNotBlank(item.getHisName())) {
|
|
|
- item.setHisName(item.getHisName().trim());
|
|
|
+ if (type.equals(ConceptTypeEnum.LisPack.getKey())) {
|
|
|
+ if (StringUtil.isBlank(item.getHisName())
|
|
|
+ && StringUtil.isBlank(item.getHisDetailName())) {
|
|
|
+ continue;
|
|
|
+ } else if (StringUtil.isBlank(item.getHisName())
|
|
|
+ && StringUtil.isNotBlank(item.getHisDetailName())) {
|
|
|
+ emptyNumList.add(rowId);
|
|
|
+ }
|
|
|
+ } else if (type.equals(ConceptTypeEnum.Disease.getKey())
|
|
|
+ || type.equals(ConceptTypeEnum.Operation.getKey())
|
|
|
+ || type.equals(ConceptTypeEnum.Tcmdisease.getKey())
|
|
|
+ || type.equals(ConceptTypeEnum.Tcmsyndrome.getKey())) {
|
|
|
+ if (StringUtil.isBlank(item.getHisName())
|
|
|
+ && StringUtil.isBlank(item.getCode())) {
|
|
|
+ continue;
|
|
|
+ } else if (StringUtil.isBlank(item.getHisName())
|
|
|
+ && StringUtil.isNotBlank(item.getCode())) {
|
|
|
+ emptyNumList.add(rowId);
|
|
|
+ }
|
|
|
} else {
|
|
|
- continue;
|
|
|
+ if (StringUtil.isNotBlank(item.getHisName())) {
|
|
|
+ item.setHisName(item.getHisName().trim());
|
|
|
+ } else {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
}
|
|
|
if (StringUtil.isNotBlank(item.getHisDetailName())) {
|
|
|
item.setHisDetailName(item.getHisDetailName().trim());
|
|
|
} else {
|
|
|
item.setHisDetailName("");
|
|
|
}
|
|
|
+
|
|
|
if (StringUtil.isNotBlank(item.getHisCode())) {
|
|
|
item.setHisCode(item.getHisCode().trim());
|
|
|
} else {
|
|
|
item.setHisCode("");
|
|
|
}
|
|
|
item.setUniqueName("");
|
|
|
+ item.setIsMatch(0);
|
|
|
+ item.setSource(null);
|
|
|
dataList.add(item);
|
|
|
}
|
|
|
|
|
|
+ //医院术语名称不允许为空
|
|
|
+ if (ListUtil.isNotEmpty(emptyNumList)) {
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "预匹配失败,上传文件内行("
|
|
|
+ + emptyNumList.stream().map(Object::toString)
|
|
|
+ .collect(Collectors.joining("、"))
|
|
|
+ + ")医院术语" + (type.equals(ConceptTypeEnum.LisPack.getKey()) ? "的检验套餐项" : "") + "不可为空。\n");
|
|
|
+ }
|
|
|
+
|
|
|
if (ListUtil.isEmpty(dataList)) {
|
|
|
return retList;
|
|
|
}
|
|
@@ -613,7 +693,7 @@ public class MappingConfigFacade extends MappingConfigServiceImpl {
|
|
|
|
|
|
for (MappingConfigWrapper item : codeList) {
|
|
|
if (item.getIsMatch() != null && item.getIsMatch().equals(1)) {
|
|
|
- retList.add(item);
|
|
|
+ historyList.add(item);
|
|
|
continue;
|
|
|
}
|
|
|
if (configMap.containsKey(item.getHisName())) {
|
|
@@ -621,7 +701,7 @@ public class MappingConfigFacade extends MappingConfigServiceImpl {
|
|
|
if (subMap != null && subMap.size() > 0) {
|
|
|
Map<String, List<String>> thirdMap = subMap.get(item.getHisDetailName());
|
|
|
if (thirdMap == null || thirdMap.size() == 0) {
|
|
|
- retList.add(item);
|
|
|
+ historyList.add(item);
|
|
|
continue;
|
|
|
}
|
|
|
for (Map.Entry<String, List<String>> thirdEntry : thirdMap.entrySet()) {
|
|
@@ -633,28 +713,95 @@ public class MappingConfigFacade extends MappingConfigServiceImpl {
|
|
|
if (type.equals(ConceptTypeEnum.Drug.getKey())) {
|
|
|
List<String> forms = thirdEntry.getValue();
|
|
|
if (ListUtil.isEmpty(forms)) {
|
|
|
- retList.add(historyItem);
|
|
|
+ historyList.add(historyItem);
|
|
|
} else {
|
|
|
for (String form : forms) {
|
|
|
MappingConfigWrapper formItem = new MappingConfigWrapper();
|
|
|
BeanUtil.copyProperties(historyItem, formItem);
|
|
|
formItem.setForm(form);
|
|
|
- retList.add(formItem);
|
|
|
+ historyList.add(formItem);
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
- retList.add(historyItem);
|
|
|
+ historyList.add(historyItem);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
- retList.add(item);
|
|
|
+ historyList.add(item);
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
- retList = BeanUtil.listCopyTo(codeList, MappingConfigWrapper.class);
|
|
|
+ historyList = BeanUtil.listCopyTo(codeList, MappingConfigWrapper.class);
|
|
|
}
|
|
|
|
|
|
+ //药品关联标准词、同义词匹配数据增加历史数据剂型
|
|
|
+ if (type.equals(ConceptTypeEnum.Drug.getKey())) {
|
|
|
+ List<String> hisDrugNames = historyList.stream()
|
|
|
+ .filter(i -> i.getIsMatch() != null
|
|
|
+ && i.getIsMatch().equals(1)
|
|
|
+ && i.getSource() != null
|
|
|
+ && (i.getSource().equals(MatchSourceEnum.StandWord.getKey())))
|
|
|
+ .map(MappingConfigWrapper::getHisName)
|
|
|
+ .distinct()
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ hisDrugNames.addAll(historyList.stream()
|
|
|
+ .filter(i -> i.getIsMatch() != null
|
|
|
+ && i.getIsMatch().equals(1)
|
|
|
+ && i.getSource() != null
|
|
|
+ && i.getSource().equals(MatchSourceEnum.SynonymsWord.getKey()))
|
|
|
+ .map(MappingConfigWrapper::getUniqueName)
|
|
|
+ .distinct()
|
|
|
+ .collect(Collectors.toList()));
|
|
|
+ if (ListUtil.isNotEmpty(hisDrugNames)) {
|
|
|
+ Map<String, Map<String, Map<String, List<String>>>> configMap = groupByHisNameWithName(hisDrugNames, type, null);
|
|
|
+ for (MappingConfigWrapper item : historyList) {
|
|
|
+ if (item.getIsMatch() != null && item.getIsMatch().equals(1)
|
|
|
+ && item.getSource() != null
|
|
|
+ && (item.getSource().equals(MatchSourceEnum.StandWord.getKey())
|
|
|
+ || item.getSource().equals(MatchSourceEnum.SynonymsWord.getKey()))) {
|
|
|
+ if ((item.getSource().equals(MatchSourceEnum.StandWord.getKey())
|
|
|
+ && configMap.containsKey(item.getHisName()))
|
|
|
+ || (item.getSource().equals(MatchSourceEnum.SynonymsWord.getKey())
|
|
|
+ && configMap.containsKey(item.getUniqueName()))) {
|
|
|
+ Map<String, Map<String, List<String>>> subMap
|
|
|
+ = configMap.get(item.getSource().equals(MatchSourceEnum.StandWord.getKey())
|
|
|
+ ? item.getHisName()
|
|
|
+ : item.getUniqueName());
|
|
|
+ if (subMap != null && subMap.size() > 0) {
|
|
|
+ Map<String, List<String>> thirdMap = subMap.get(item.getHisDetailName());
|
|
|
+ if (thirdMap == null || thirdMap.size() == 0) {
|
|
|
+ drugList.add(item);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ List<String> forms = thirdMap.get(item.getUniqueName());
|
|
|
+ if (ListUtil.isEmpty(forms)) {
|
|
|
+ drugList.add(item);
|
|
|
+ } else {
|
|
|
+ for (String form : forms) {
|
|
|
+ MappingConfigWrapper formItem = new MappingConfigWrapper();
|
|
|
+ BeanUtil.copyProperties(item, formItem);
|
|
|
+ formItem.setForm(form);
|
|
|
+ drugList.add(formItem);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ drugList.add(item);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ drugList.add(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ drugList = BeanUtil.listCopyTo(historyList, MappingConfigWrapper.class);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ drugList = BeanUtil.listCopyTo(historyList, MappingConfigWrapper.class);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ retList = BeanUtil.listCopyTo(drugList, MappingConfigWrapper.class);
|
|
|
for (MappingConfigWrapper item : retList) {
|
|
|
if (item.getIsMatch() == null) {
|
|
|
item.setIsMatch(0);
|
|
@@ -663,6 +810,7 @@ public class MappingConfigFacade extends MappingConfigServiceImpl {
|
|
|
|
|
|
//添加编码
|
|
|
retList = addCodes(retList, type);
|
|
|
+ retList = retList.stream().distinct().collect(Collectors.toList());
|
|
|
return retList;
|
|
|
}
|
|
|
|
|
@@ -683,7 +831,7 @@ public class MappingConfigFacade extends MappingConfigServiceImpl {
|
|
|
if (StringUtil.isBlank(userId)) {
|
|
|
userId = "0";
|
|
|
}
|
|
|
- List<MappingConfigWrapper> originList = readImportData(file, type);
|
|
|
+ List<MappingConfigWrapper> originList = readImportData(file, type, 2);
|
|
|
if (ListUtil.isEmpty(originList)) {
|
|
|
throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "校验失败,导入数据不能为空");
|
|
|
}
|
|
@@ -795,8 +943,6 @@ public class MappingConfigFacade extends MappingConfigServiceImpl {
|
|
|
it.remove();
|
|
|
}
|
|
|
}
|
|
|
- tempList.addAll(matchList);
|
|
|
- tempList.addAll(unMatchList);
|
|
|
|
|
|
// 验证数据是否已存在,已存在的先删除
|
|
|
// 没id的删除重新插入,有id的更新
|
|
@@ -859,7 +1005,24 @@ public class MappingConfigFacade extends MappingConfigServiceImpl {
|
|
|
deleteIds.add(item.getId());
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ //数据库中已存在匹配项,去除导入文件中未匹配项
|
|
|
+ it = unMatchList.iterator();
|
|
|
+ while (it.hasNext()) {
|
|
|
+ MappingConfigWrapper item = it.next();
|
|
|
+ String matchKey = item.getHisName() + "_"
|
|
|
+ + item.getHisCode() + "_"
|
|
|
+ + item.getHisDetailName();
|
|
|
+ if (db_matchMap.containsKey(matchKey)) {
|
|
|
+ it.remove();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+ //过滤后的导入结果集
|
|
|
+ tempList.addAll(matchList);
|
|
|
+ tempList.addAll(unMatchList);
|
|
|
+
|
|
|
//标准术语校验
|
|
|
ConceptVO conceptVO = new ConceptVO();
|
|
|
conceptVO.setSource(MatchSourceEnum.StandWord.getKey());
|
|
@@ -980,7 +1143,10 @@ public class MappingConfigFacade extends MappingConfigServiceImpl {
|
|
|
idListVO.setIds(deleteIds);
|
|
|
deleteRecords(idListVO);
|
|
|
List<MappingConfig> saveList = BeanUtil.listCopyTo(tempList, MappingConfig.class);
|
|
|
- mappingConfigService.saveOrUpdateBatch(saveList);
|
|
|
+ saveList = saveList.stream().distinct().collect(Collectors.toList());
|
|
|
+ if (ListUtil.isNotEmpty(saveList)) {
|
|
|
+ mappingConfigService.saveOrUpdateBatch(saveList);
|
|
|
+ }
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
@@ -1052,6 +1218,10 @@ public class MappingConfigFacade extends MappingConfigServiceImpl {
|
|
|
.eq("is_match", 1);
|
|
|
if (StringUtil.isNotBlank(mappingConfigVO.getHisDetailName())) {
|
|
|
queryWrapper.eq("his_detail_name", mappingConfigVO.getHisDetailName());
|
|
|
+ } else {
|
|
|
+ queryWrapper.and(i -> i.isNull("his_detail_name")
|
|
|
+ .or()
|
|
|
+ .eq("his_detail_name", ""));
|
|
|
}
|
|
|
|
|
|
List<MappingConfig> list = this.list(queryWrapper);
|
|
@@ -1093,6 +1263,19 @@ public class MappingConfigFacade extends MappingConfigServiceImpl {
|
|
|
queryWrapper
|
|
|
.eq("his_detail_name", mappingConfig.getHisDetailName());
|
|
|
}
|
|
|
+ if (StringUtil.isBlank(mappingConfig.getHisCode())) {
|
|
|
+ queryWrapper.and(i -> i.isNull("his_code")
|
|
|
+ .or()
|
|
|
+ .eq("his_code", ""));
|
|
|
+ } else {
|
|
|
+ queryWrapper
|
|
|
+ .eq("his_code", mappingConfig.getHisCode());
|
|
|
+ }
|
|
|
+ if (mappingConfig.getFormConceptId() != null) {
|
|
|
+ queryWrapper.eq("form_concept_id", mappingConfig.getFormConceptId());
|
|
|
+ } else {
|
|
|
+ queryWrapper.isNull("form_concept_id");
|
|
|
+ }
|
|
|
if (mappingConfig.getFormConceptId() != null) {
|
|
|
queryWrapper.eq("form_concept_id", mappingConfig.getFormConceptId());
|
|
|
}
|
|
@@ -1148,6 +1331,19 @@ public class MappingConfigFacade extends MappingConfigServiceImpl {
|
|
|
} else {
|
|
|
queryWrapper.eq("his_detail_name", mappingConfig.getHisDetailName());
|
|
|
}
|
|
|
+ if (StringUtil.isBlank(mappingConfig.getHisCode())) {
|
|
|
+ queryWrapper.and(i -> i.isNull("his_code")
|
|
|
+ .or()
|
|
|
+ .eq("his_code", ""));
|
|
|
+ } else {
|
|
|
+ queryWrapper
|
|
|
+ .eq("his_code", mappingConfig.getHisCode());
|
|
|
+ }
|
|
|
+ if (mappingConfig.getFormConceptId() != null) {
|
|
|
+ queryWrapper.eq("form_concept_id", mappingConfig.getFormConceptId());
|
|
|
+ } else {
|
|
|
+ queryWrapper.isNull("form_concept_id");
|
|
|
+ }
|
|
|
MappingConfig oldRecord = this.getOne(queryWrapper, false);
|
|
|
if (mappingConfig.getId() == null
|
|
|
&& oldRecord != null) {
|
|
@@ -1182,6 +1378,14 @@ public class MappingConfigFacade extends MappingConfigServiceImpl {
|
|
|
} else {
|
|
|
qwUnMaptch.eq("his_detail_name", mappingConfig.getHisDetailName());
|
|
|
}
|
|
|
+ if (StringUtil.isBlank(mappingConfig.getHisCode())) {
|
|
|
+ qwUnMaptch.and(i -> i.isNull("his_code")
|
|
|
+ .or()
|
|
|
+ .eq("his_code", ""));
|
|
|
+ } else {
|
|
|
+ qwUnMaptch
|
|
|
+ .eq("his_code", mappingConfig.getHisCode());
|
|
|
+ }
|
|
|
this.remove(qwUnMaptch);
|
|
|
|
|
|
mappingConfig.setIsMatch(1);
|