|
@@ -0,0 +1,226 @@
|
|
|
+package com.diagbot.facade;
|
|
|
+
|
|
|
+import com.diagbot.client.AuthServiceClient;
|
|
|
+import com.diagbot.entity.BehospitalInfo;
|
|
|
+import com.diagbot.entity.HomePage;
|
|
|
+import com.diagbot.entity.MedicalRecordContent;
|
|
|
+import com.diagbot.exception.CommonErrorCode;
|
|
|
+import com.diagbot.exception.CommonException;
|
|
|
+import com.diagbot.service.BehospitalInfoService;
|
|
|
+import com.diagbot.service.DoctorAdviceService;
|
|
|
+import com.diagbot.service.HomeDiagnoseInfoService;
|
|
|
+import com.diagbot.service.HomeOperationInfoService;
|
|
|
+import com.diagbot.service.HomePageService;
|
|
|
+import com.diagbot.service.MedCrisisInfoService;
|
|
|
+import com.diagbot.service.MedicalRecordContentService;
|
|
|
+import com.diagbot.service.MedicalRecordService;
|
|
|
+import com.diagbot.util.EncrypDES;
|
|
|
+import com.diagbot.util.ListUtil;
|
|
|
+import com.diagbot.util.StringUtil;
|
|
|
+import com.diagbot.vo.DataImportVO;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @Description:
|
|
|
+ * @Author:zhoutg
|
|
|
+ * @time: 2018/11/23 11:37
|
|
|
+ */
|
|
|
+@Component
|
|
|
+public class DataImportFacade {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ @Qualifier("behospitalInfoServiceImpl")
|
|
|
+ BehospitalInfoService behospitalInfoService;
|
|
|
+ @Autowired
|
|
|
+ @Qualifier("medCrisisInfoServiceImpl")
|
|
|
+ MedCrisisInfoService medCrisisInfoService;
|
|
|
+ @Autowired
|
|
|
+ @Qualifier("doctorAdviceServiceImpl")
|
|
|
+ DoctorAdviceService doctorAdviceService;
|
|
|
+ @Autowired
|
|
|
+ @Qualifier("homeDiagnoseInfoServiceImpl")
|
|
|
+ HomeDiagnoseInfoService homeDiagnoseInfoService;
|
|
|
+ @Autowired
|
|
|
+ @Qualifier("homePageServiceImpl")
|
|
|
+ HomePageService homePageService;
|
|
|
+ @Autowired
|
|
|
+ @Qualifier("homeOperationInfoServiceImpl")
|
|
|
+ HomeOperationInfoService homeOperationInfoService;
|
|
|
+ @Autowired
|
|
|
+ @Qualifier("medicalRecordServiceImpl")
|
|
|
+ MedicalRecordService medicalRecordService;
|
|
|
+ @Autowired
|
|
|
+ @Qualifier("medicalRecordContentServiceImpl")
|
|
|
+ MedicalRecordContentService medicalRecordContentService;
|
|
|
+ @Autowired
|
|
|
+ AuthServiceClient authServiceClient;
|
|
|
+ @Value("${encrypt.enable}")
|
|
|
+ Boolean encryptFlag;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 数据导入
|
|
|
+ *
|
|
|
+ * @param dataImportVO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Boolean dataImportFacade(DataImportVO dataImportVO) {
|
|
|
+ // 病历信息导入
|
|
|
+ if (ListUtil.isNotEmpty(dataImportVO.getBehospitalInfoList())) {
|
|
|
+ // 加密
|
|
|
+ for (BehospitalInfo behospitalInfo : dataImportVO.getBehospitalInfoList()) {
|
|
|
+ // 姓名
|
|
|
+ if (StringUtil.isNotBlank(behospitalInfo.getName())) {
|
|
|
+ behospitalInfo.setName(behospitalInfo.getName().substring(0, 1) + "**");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ behospitalInfoService.saveOrUpdateBatch(dataImportVO.getBehospitalInfoList());
|
|
|
+ }
|
|
|
+ // 危急值信息
|
|
|
+ if (ListUtil.isNotEmpty(dataImportVO.getMedCrisisInfoList())) {
|
|
|
+ medCrisisInfoService.saveOrUpdateBatch(dataImportVO.getMedCrisisInfoList());
|
|
|
+ }
|
|
|
+ // 病人医嘱
|
|
|
+ if (ListUtil.isNotEmpty(dataImportVO.getDoctorAdviceList())) {
|
|
|
+ doctorAdviceService.saveOrUpdateBatch(dataImportVO.getDoctorAdviceList());
|
|
|
+ }
|
|
|
+ // 病案首页诊断
|
|
|
+ if (ListUtil.isNotEmpty(dataImportVO.getHomeDiagnoseInfoList())) {
|
|
|
+ homeDiagnoseInfoService.saveOrUpdateBatch(dataImportVO.getHomeDiagnoseInfoList());
|
|
|
+ }
|
|
|
+ // 病案首页
|
|
|
+ if (ListUtil.isNotEmpty(dataImportVO.getHomePageList())) {
|
|
|
+ // 加密
|
|
|
+ for (HomePage homePage : dataImportVO.getHomePageList()) {
|
|
|
+ // 姓名
|
|
|
+ if (StringUtil.isNotBlank(homePage.getName())) {
|
|
|
+ homePage.setName(homePage.getName().substring(0, 1) + "**");
|
|
|
+ }
|
|
|
+ // 身份证
|
|
|
+ if (StringUtil.isNotBlank(homePage.getIdentityCardNo())) {
|
|
|
+ homePage.setIdentityCardNo(homePage.getIdentityCardNo().substring(0, 1) + "*****************");
|
|
|
+ }
|
|
|
+ // 现住址电话
|
|
|
+ if (StringUtil.isNotBlank(homePage.getCurPhone())) {
|
|
|
+ homePage.setCurPhone(homePage.getCurPhone().substring(0, 1) + "**");
|
|
|
+ }
|
|
|
+ // 工作单位电话
|
|
|
+ if (StringUtil.isNotBlank(homePage.getWorkPhone())) {
|
|
|
+ homePage.setWorkPhone(homePage.getWorkPhone().substring(0, 1) + "**");
|
|
|
+ }
|
|
|
+ // 联系人姓名
|
|
|
+ if (StringUtil.isNotBlank(homePage.getContactName())) {
|
|
|
+ homePage.setContactName(homePage.getContactName().substring(0, 1) + "**");
|
|
|
+ }
|
|
|
+ // 联系人电话
|
|
|
+ if (StringUtil.isNotBlank(homePage.getContactPhone())) {
|
|
|
+ homePage.setContactPhone(homePage.getContactPhone().substring(0, 1) + "**");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ homePageService.saveOrUpdateBatch(dataImportVO.getHomePageList());
|
|
|
+ }
|
|
|
+ // 病案首页手术信息
|
|
|
+ if (ListUtil.isNotEmpty(dataImportVO.getHomeOperationInfoList())) {
|
|
|
+ homeOperationInfoService.saveOrUpdateBatch(dataImportVO.getHomeOperationInfoList());
|
|
|
+ }
|
|
|
+ // 文书信息
|
|
|
+ if (ListUtil.isNotEmpty(dataImportVO.getMedicalRecordList())) {
|
|
|
+ medicalRecordService.saveOrUpdateBatch(dataImportVO.getMedicalRecordList());
|
|
|
+ }
|
|
|
+ // 文书明细信息
|
|
|
+ if (ListUtil.isNotEmpty(dataImportVO.getMedicalRecordContentList())) {
|
|
|
+ // 加密数据
|
|
|
+ if (encryptFlag) {
|
|
|
+ String recId = "";
|
|
|
+ try {
|
|
|
+ EncrypDES encrypDES = new EncrypDES();
|
|
|
+ for (MedicalRecordContent medicalRecordContent : dataImportVO.getMedicalRecordContentList()) {
|
|
|
+ recId = medicalRecordContent.getRecId();
|
|
|
+ if (StringUtil.isNotBlank(medicalRecordContent.getXmlText())) {
|
|
|
+ medicalRecordContent.setXmlText(encrypDES.encrytor(medicalRecordContent.getXmlText()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "加密xml错误!recId=【" + recId + "】");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ medicalRecordContentService.saveOrUpdateBatch(dataImportVO.getMedicalRecordContentList(), 100);
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 模拟测试数据
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Boolean test() {
|
|
|
+ int size = 100;
|
|
|
+ Long hospitalId = 8L;
|
|
|
+ int random = (int)(Math.random() * 100);
|
|
|
+
|
|
|
+ DataImportVO dataImportVO = new DataImportVO();
|
|
|
+
|
|
|
+ // // 病历信息
|
|
|
+ // List<BehospitalInfo> behospitalInfoList = behospitalInfoService.list(new QueryWrapper<BehospitalInfo>()
|
|
|
+ // .ne("hospital_id", hospitalId)
|
|
|
+ // .last(" limit " + size)
|
|
|
+ // );
|
|
|
+ // behospitalInfoList.forEach(r -> { r.setHospitalId(hospitalId); r.setBehospitalCode(r.getBehospitalCode() + random); });
|
|
|
+ // dataImportVO.setBehospitalInfoList(behospitalInfoList);
|
|
|
+ //
|
|
|
+ // // 医嘱信息
|
|
|
+ // List<DoctorAdvice> doctorAdviceList = doctorAdviceService.list(new QueryWrapper<DoctorAdvice>()
|
|
|
+ // .ne("hospital_id", hospitalId)
|
|
|
+ // .last(" limit " + size)
|
|
|
+ // );
|
|
|
+ // doctorAdviceList.forEach(r -> {r.setHospitalId(hospitalId); r.setBehospitalCode(r.getBehospitalCode() + random);});
|
|
|
+ // dataImportVO.setDoctorAdviceList(doctorAdviceList);
|
|
|
+ //
|
|
|
+ // // 病案首页诊断
|
|
|
+ // List<HomeDiagnoseInfo> homeDiagnoseInfoList = homeDiagnoseInfoService.list(new QueryWrapper<HomeDiagnoseInfo>()
|
|
|
+ // .ne("hospital_id", hospitalId)
|
|
|
+ // .last(" limit " + size)
|
|
|
+ // );
|
|
|
+ // homeDiagnoseInfoList.forEach(r -> {r.setHospitalId(hospitalId); r.setHomePageId(r.getHomePageId() + random);});
|
|
|
+ // dataImportVO.setHomeDiagnoseInfoList(homeDiagnoseInfoList);
|
|
|
+ //
|
|
|
+ // // 病案首页
|
|
|
+ // List<HomePage> homePageList = homePageService.list(new QueryWrapper<HomePage>()
|
|
|
+ // .ne("hospital_id", hospitalId)
|
|
|
+ // .last(" limit " + size)
|
|
|
+ // );
|
|
|
+ // homePageList.forEach(r -> {r.setHospitalId(hospitalId); r.setBehospitalCode(r.getBehospitalCode() + random);});
|
|
|
+ // dataImportVO.setHomePageList(homePageList);
|
|
|
+ //
|
|
|
+ // // 病案首页手术信息
|
|
|
+ // List<HomeOperationInfo> homeOperationInfoList = homeOperationInfoService.list(new QueryWrapper<HomeOperationInfo>()
|
|
|
+ // .ne("hospital_id", hospitalId)
|
|
|
+ // .last(" limit " + size)
|
|
|
+ // );
|
|
|
+ // homeOperationInfoList.forEach(r -> {r.setHospitalId(hospitalId); r.setHomePageId(r.getHomePageId() + random);});
|
|
|
+ // dataImportVO.setHomeOperationInfoList(homeOperationInfoList);
|
|
|
+ //
|
|
|
+ // // 文书信息
|
|
|
+ // List<MedicalRecord> medicalRecordList = medicalRecordService.list(new QueryWrapper<MedicalRecord>()
|
|
|
+ // .ne("hospital_id", hospitalId)
|
|
|
+ // .last(" limit " + size)
|
|
|
+ // );
|
|
|
+ // medicalRecordList.forEach(r -> {r.setHospitalId(hospitalId); r.setBehospitalCode(r.getBehospitalCode() + random);});
|
|
|
+ // dataImportVO.setMedicalRecordList(medicalRecordList);
|
|
|
+
|
|
|
+ // // 文书明细信息
|
|
|
+ // List<MedicalRecordContent> medicalRecordContentList = medicalRecordContentService.list(new QueryWrapper<MedicalRecordContent>()
|
|
|
+ // .ne("hospital_id", hospitalId)
|
|
|
+ // .last(" limit " + size)
|
|
|
+ // );
|
|
|
+ // medicalRecordContentList.forEach(r -> {r.setHospitalId(hospitalId); r.setRecId(r.getRecId() + random);});
|
|
|
+ // dataImportVO.setMedicalRecordContentList(medicalRecordContentList);
|
|
|
+
|
|
|
+ authServiceClient.dataimport(dataImportVO);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+}
|