|
@@ -5,11 +5,15 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.lantone.common.api.CommonResult;
|
|
|
+import com.lantone.common.enums.IsDeleteEnum;
|
|
|
import com.lantone.common.exception.Asserts;
|
|
|
import com.lantone.common.util.BeanUtil;
|
|
|
+import com.lantone.common.util.DateUtil;
|
|
|
import com.lantone.common.util.ListUtil;
|
|
|
import com.lantone.common.util.StringUtil;
|
|
|
+import com.lantone.common.util.SysUserUtils;
|
|
|
import com.lantone.daqe.dto.ExportImportDiseaseErrDTO;
|
|
|
+import com.lantone.daqe.dto.GetDiseaseInfoByIdDTO;
|
|
|
import com.lantone.daqe.dto.GetDiseasePageDTO;
|
|
|
import com.lantone.daqe.dto.GetMatchingDiseasePageDTO;
|
|
|
import com.lantone.daqe.entity.DiseaseInfo;
|
|
@@ -18,6 +22,7 @@ import com.lantone.daqe.service.impl.DiseaseInfoServiceImpl;
|
|
|
import com.lantone.daqe.util.ExcelUtils;
|
|
|
import com.lantone.daqe.vo.AddDiseaseVO;
|
|
|
import com.lantone.daqe.vo.DelDiseaseByIdVO;
|
|
|
+import com.lantone.daqe.vo.GetDiseaseInfoByIdVO;
|
|
|
import com.lantone.daqe.vo.GetDiseasePageVO;
|
|
|
import com.lantone.daqe.vo.GetMatchingDiseasePageVO;
|
|
|
import com.lantone.daqe.vo.ImportDiseaseVO;
|
|
@@ -49,6 +54,11 @@ public class DiseaseManagementFacade {
|
|
|
@Autowired
|
|
|
private DiseaseInfoServiceImpl diseaseInfoServiceImpl;
|
|
|
|
|
|
+ //医院诊断名称长度限制
|
|
|
+ private int diseaseNameLength = 30;
|
|
|
+ //ICD-10编码长度限制
|
|
|
+ private int icd10Length = 30;
|
|
|
+
|
|
|
public IPage<GetDiseasePageDTO> getDiseasePage(GetDiseasePageVO getDiseasePageVO) {
|
|
|
Page<GetDiseasePageDTO> getDiseasePageDTOPage = new Page<>();
|
|
|
|
|
@@ -140,9 +150,10 @@ public class DiseaseManagementFacade {
|
|
|
if (ListUtil.isEmpty(diagnoseExcelVOS)) {
|
|
|
Asserts.fail("Excel文件为空");
|
|
|
}
|
|
|
+ Long hospitalId = SysUserUtils.getCurrentHospitalId();
|
|
|
//数据规范校验
|
|
|
List<ExportImportDiseaseErrDTO> errExports = new ArrayList<>();
|
|
|
- if (checkData(diagnoseExcelVOS, errExports)) {
|
|
|
+ if (checkData(diagnoseExcelVOS, errExports, hospitalId)) {
|
|
|
String fileName = "诊断标准词匹配信息导入异常.xls";
|
|
|
ExcelUtils.exportExcelUser(errExports, null, "sheet1", ExportImportDiseaseErrDTO.class, fileName, response);
|
|
|
} else {
|
|
@@ -150,6 +161,13 @@ public class DiseaseManagementFacade {
|
|
|
List<ImportDiseaseVO> temp = delRepeat(diagnoseExcelVOS);
|
|
|
//导入
|
|
|
List<DiseaseInfo> insert = BeanUtil.listCopyTo(temp, DiseaseInfo.class);
|
|
|
+ //拼装 医院id、创建时间、更新时间
|
|
|
+ insert.stream().forEach(diseaseInfo -> {
|
|
|
+ diseaseInfo.setHospitalId(hospitalId != null ? hospitalId : 0);
|
|
|
+ diseaseInfo.setGmtCreate(DateUtil.now());
|
|
|
+ diseaseInfo.setCreator(SysUserUtils.getCurrentPrincipleId() != null ? SysUserUtils.getCurrentPrincipleId() + "" : "0");
|
|
|
+ diseaseInfo.setGmtModified(DateUtil.now());
|
|
|
+ });
|
|
|
boolean out = diseaseInfoServiceImpl.saveBatch(insert);
|
|
|
CommonResult<String> outMsg = null;
|
|
|
response.setContentType("text/html;charset=utf-8");
|
|
@@ -175,35 +193,83 @@ public class DiseaseManagementFacade {
|
|
|
* @param errExports 导出异常
|
|
|
* @Return java.lang.Boolean
|
|
|
*/
|
|
|
- private Boolean checkData(List<ImportDiseaseVO> diagnoseExcelVOS, List<ExportImportDiseaseErrDTO> errExports) {
|
|
|
+ private Boolean checkData(List<ImportDiseaseVO> diagnoseExcelVOS, List<ExportImportDiseaseErrDTO> errExports, Long hospitalId) {
|
|
|
AtomicBoolean errorFlog = new AtomicBoolean(false);
|
|
|
+ //获取数据库数据 判断医院诊断名称和ICD-10编码值用于重复校验
|
|
|
+ List<DiseaseInfo> diseaseInfos = diseaseInfoFacade.list(new QueryWrapper<DiseaseInfo>()
|
|
|
+ .eq(hospitalId != null, "hospital_id", hospitalId)
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey()));
|
|
|
+ List<String> diseaseNames = diseaseInfos.stream().map(DiseaseInfo::getName).collect(Collectors.toList());
|
|
|
+ List<String> icd10s = diseaseInfos.stream().map(DiseaseInfo::getIcd10).collect(Collectors.toList());
|
|
|
diagnoseExcelVOS.stream().forEach(importDiseaseVO -> {
|
|
|
ExportImportDiseaseErrDTO exportImportDiseaseErrDTO = new ExportImportDiseaseErrDTO();
|
|
|
BeanUtil.copyProperties(importDiseaseVO, exportImportDiseaseErrDTO);
|
|
|
StringBuffer errMsg = new StringBuffer();
|
|
|
- //数据校验
|
|
|
+ //数据校验(非空和过长、库中已存在)
|
|
|
+ //name
|
|
|
if (StringUtil.isEmpty(importDiseaseVO.getName())) {
|
|
|
- errMsg.append("医院诊断名称为空").append(";");
|
|
|
+ errMsg.append("【医院诊断名称】未填写").append(";");
|
|
|
errorFlog.set(true);
|
|
|
- }
|
|
|
- if (StringUtil.isEmpty(importDiseaseVO.getStandard())) {
|
|
|
- errMsg.append("标准诊断名称为空").append(";");
|
|
|
+ } else if (importDiseaseVO.getName().length() > diseaseNameLength) {
|
|
|
+ errMsg.append("【医院诊断名称】过长").append(";");
|
|
|
+ errorFlog.set(true);
|
|
|
+ } else if (diseaseNames.contains(importDiseaseVO.getName())) {
|
|
|
+ errMsg.append("该诊断已存在,无法重复导入。").append(";");
|
|
|
errorFlog.set(true);
|
|
|
}
|
|
|
+
|
|
|
+ //icd10
|
|
|
+ if (StringUtil.isNotEmpty(importDiseaseVO.getIcd10())) {
|
|
|
+ if (importDiseaseVO.getIcd10().length() > icd10Length) {
|
|
|
+ errMsg.append("【ICD-10编码】过长").append(";");
|
|
|
+ errorFlog.set(true);
|
|
|
+ } else if (icd10s.contains(importDiseaseVO.getIcd10())) {
|
|
|
+ errMsg.append("该ICD-10编码已存在,无法重复导入。").append(";");
|
|
|
+ errorFlog.set(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
exportImportDiseaseErrDTO.setErrMsg(errMsg.toString());
|
|
|
errExports.add(exportImportDiseaseErrDTO);
|
|
|
+
|
|
|
});
|
|
|
return errorFlog.get();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 通过医院诊断名称去重
|
|
|
+ *
|
|
|
+ * @param diagnoseExcelVOS
|
|
|
+ * @Return java.util.List<com.lantone.daqe.vo.ImportDiseaseVO>
|
|
|
+ */
|
|
|
private List<ImportDiseaseVO> delRepeat(List<ImportDiseaseVO> diagnoseExcelVOS) {
|
|
|
- //通过标准词去重
|
|
|
+
|
|
|
+ //通过医院诊断名称去重
|
|
|
LinkedHashMap<String, ImportDiseaseVO> tempMap = diagnoseExcelVOS.stream()
|
|
|
.collect(Collectors.toMap(ImportDiseaseVO::getName, ImportDiseaseVO -> ImportDiseaseVO, (k1, k2) -> k1, LinkedHashMap::new));
|
|
|
return tempMap.values().stream().collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 匹配诊断信息列表
|
|
|
+ *
|
|
|
+ * @param getMatchingDiseasePageVO
|
|
|
+ * @Return com.baomidou.mybatisplus.core.metadata.IPage<com.lantone.daqe.dto.GetMatchingDiseasePageDTO>
|
|
|
+ */
|
|
|
public IPage<GetMatchingDiseasePageDTO> getMatchingDiseasePage(GetMatchingDiseasePageVO getMatchingDiseasePageVO) {
|
|
|
+
|
|
|
return diseaseInfoFacade.getBaseMapper().getMatchingDiseasePage(getMatchingDiseasePageVO);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 已匹配信息查看
|
|
|
+ *
|
|
|
+ * @param getDiseaseInfoByIdVO
|
|
|
+ * @Return com.lantone.daqe.dto.GetDiseaseInfoByIdDTO
|
|
|
+ */
|
|
|
+ public GetDiseaseInfoByIdDTO getDiseaseInfoById(GetDiseaseInfoByIdVO getDiseaseInfoByIdVO) {
|
|
|
+ GetDiseaseInfoByIdDTO out = new GetDiseaseInfoByIdDTO();
|
|
|
+ BeanUtils.copyProperties(diseaseInfoFacade.getById(getDiseaseInfoByIdVO.getId()), out);
|
|
|
+ out.setIsMapping(StringUtil.isBlank(out.getStandard()) ? "未匹配" : "已匹配");
|
|
|
+ return out;
|
|
|
+ }
|
|
|
}
|