|
@@ -1,8 +1,12 @@
|
|
|
package com.diagbot.facade;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.diagbot.client.AuthServiceClient;
|
|
|
import com.diagbot.entity.BehospitalInfo;
|
|
|
+import com.diagbot.entity.DoctorAdvice;
|
|
|
+import com.diagbot.entity.HomeDiagnoseInfo;
|
|
|
import com.diagbot.entity.HomePage;
|
|
|
+import com.diagbot.entity.MedCrisisInfo;
|
|
|
import com.diagbot.entity.MedicalRecordContent;
|
|
|
import com.diagbot.exception.CommonErrorCode;
|
|
|
import com.diagbot.exception.CommonException;
|
|
@@ -23,6 +27,9 @@ import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
/**
|
|
|
* @Description:
|
|
|
* @Author:zhoutg
|
|
@@ -67,31 +74,73 @@ public class DataImportFacade {
|
|
|
* @return
|
|
|
*/
|
|
|
public Boolean dataImportFacade(DataImportVO dataImportVO) {
|
|
|
+ Long hospitalId = dataImportVO.getHospitalId();
|
|
|
// 病历信息导入
|
|
|
- if (ListUtil.isNotEmpty(dataImportVO.getBehospitalInfoList())) {
|
|
|
- // 加密
|
|
|
- for (BehospitalInfo behospitalInfo : dataImportVO.getBehospitalInfoList()) {
|
|
|
- // 姓名
|
|
|
- if (StringUtil.isNotBlank(behospitalInfo.getName())) {
|
|
|
- behospitalInfo.setName(behospitalInfo.getName().substring(0, 1) + "**");
|
|
|
+ List<BehospitalInfo> behospitalInfoList = dataImportVO.getBehospitalInfoList();
|
|
|
+ if (ListUtil.isNotEmpty(behospitalInfoList)) {
|
|
|
+ List<String> behospitalCodeList = behospitalInfoList.stream().map(r -> r.getBehospitalCode()).collect(Collectors.toList());
|
|
|
+ if (ListUtil.isNotEmpty(behospitalCodeList)) {
|
|
|
+ // 先删除
|
|
|
+ behospitalInfoService.remove(new QueryWrapper<BehospitalInfo>()
|
|
|
+ .eq("hospital_id", hospitalId)
|
|
|
+ .in("behospital_code", behospitalCodeList)
|
|
|
+ );
|
|
|
+ // 加密
|
|
|
+ for (BehospitalInfo behospitalInfo : behospitalInfoList) {
|
|
|
+ // 姓名
|
|
|
+ if (StringUtil.isNotBlank(behospitalInfo.getName())) {
|
|
|
+ behospitalInfo.setName(behospitalInfo.getName().substring(0, 1) + "**");
|
|
|
+ }
|
|
|
}
|
|
|
+ behospitalInfoService.saveBatch(behospitalInfoList);
|
|
|
}
|
|
|
- behospitalInfoService.saveOrUpdateBatch(dataImportVO.getBehospitalInfoList());
|
|
|
}
|
|
|
+
|
|
|
// 危急值信息
|
|
|
- if (ListUtil.isNotEmpty(dataImportVO.getMedCrisisInfoList())) {
|
|
|
- medCrisisInfoService.saveOrUpdateBatch(dataImportVO.getMedCrisisInfoList());
|
|
|
+ List<MedCrisisInfo> medCrisisInfoList = dataImportVO.getMedCrisisInfoList();
|
|
|
+ if (ListUtil.isNotEmpty(medCrisisInfoList)) {
|
|
|
+ List<String> recIdList = medCrisisInfoList.stream().map(r -> r.getRecId()).collect(Collectors.toList());
|
|
|
+ if (ListUtil.isNotEmpty(recIdList)) {
|
|
|
+ // 先删除
|
|
|
+ medCrisisInfoService.remove(new QueryWrapper<MedCrisisInfo>()
|
|
|
+ .eq("hospital_id", hospitalId)
|
|
|
+ .in("rec_id", recIdList)
|
|
|
+ );
|
|
|
+ medCrisisInfoService.saveBatch(medCrisisInfoList);
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
// 病人医嘱
|
|
|
- if (ListUtil.isNotEmpty(dataImportVO.getDoctorAdviceList())) {
|
|
|
- doctorAdviceService.saveOrUpdateBatch(dataImportVO.getDoctorAdviceList());
|
|
|
+ List<DoctorAdvice> doctorAdviceList = dataImportVO.getDoctorAdviceList();
|
|
|
+ if (ListUtil.isNotEmpty(doctorAdviceList)) {
|
|
|
+ List<String> doctorAdviceIdList = doctorAdviceList.stream().map(r -> r.getDoctorAdviceId()).collect(Collectors.toList());
|
|
|
+ if (ListUtil.isNotEmpty(doctorAdviceIdList)) {
|
|
|
+ // 先删除
|
|
|
+ doctorAdviceService.remove(new QueryWrapper<DoctorAdvice>()
|
|
|
+ .eq("hospital_id", hospitalId)
|
|
|
+ .in("doctor_advice_id", doctorAdviceIdList)
|
|
|
+ );
|
|
|
+ doctorAdviceService.saveOrUpdateBatch(doctorAdviceList);
|
|
|
+ }
|
|
|
}
|
|
|
- // 病案首页诊断
|
|
|
- if (ListUtil.isNotEmpty(dataImportVO.getHomeDiagnoseInfoList())) {
|
|
|
- homeDiagnoseInfoService.saveOrUpdateBatch(dataImportVO.getHomeDiagnoseInfoList());
|
|
|
+
|
|
|
+ // 病案首页诊断 TODO
|
|
|
+ List<HomeDiagnoseInfo> homeDiagnoseInfoList = dataImportVO.getHomeDiagnoseInfoList();
|
|
|
+ if (ListUtil.isNotEmpty(homeDiagnoseInfoList)) {
|
|
|
+ List<String> ids = homeDiagnoseInfoList.stream().map(r -> r.getHomePageId()).collect(Collectors.toList());
|
|
|
+ if (ListUtil.isNotEmpty(ids)) {
|
|
|
+ // 先删除 TODO
|
|
|
+ // homeDiagnoseInfoService.remove(new QueryWrapper<HomeDiagnoseInfo>()
|
|
|
+ // .eq("hospital_id", hospitalId)
|
|
|
+ // .in("doctor_advice_id", ids)
|
|
|
+ // );
|
|
|
+ homeDiagnoseInfoService.saveOrUpdateBatch(homeDiagnoseInfoList);
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
// 病案首页
|
|
|
- if (ListUtil.isNotEmpty(dataImportVO.getHomePageList())) {
|
|
|
+ List<HomePage> homePageList = dataImportVO.getHomePageList();
|
|
|
+ if (ListUtil.isNotEmpty(homePageList)) {
|
|
|
// 加密
|
|
|
for (HomePage homePage : dataImportVO.getHomePageList()) {
|
|
|
// 姓名
|
|
@@ -119,8 +168,9 @@ public class DataImportFacade {
|
|
|
homePage.setContactPhone(homePage.getContactPhone().substring(0, 1) + "**");
|
|
|
}
|
|
|
}
|
|
|
- homePageService.saveOrUpdateBatch(dataImportVO.getHomePageList());
|
|
|
+ homePageService.saveBatch(homePageList);
|
|
|
}
|
|
|
+
|
|
|
// 病案首页手术信息
|
|
|
if (ListUtil.isNotEmpty(dataImportVO.getHomeOperationInfoList())) {
|
|
|
homeOperationInfoService.saveOrUpdateBatch(dataImportVO.getHomeOperationInfoList());
|