diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/service/patientinfo/impl/PatientInfoServiceImpl.java b/postdischarge-manage/src/main/java/com/xinelu/manage/service/patientinfo/impl/PatientInfoServiceImpl.java index c0fb188e..20ae4f73 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/service/patientinfo/impl/PatientInfoServiceImpl.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/service/patientinfo/impl/PatientInfoServiceImpl.java @@ -478,7 +478,7 @@ public class PatientInfoServiceImpl implements IPatientInfoService { //科室名称全符合新增患者表,否则返回数据 if (CollectionUtils.isNotEmpty(deptAliasVOS)) { return AjaxResult.error("科室名称不存在", patientInfoImportVO); - } else { + } //region 新增居民表 patientInfoImportList.forEach(item -> { @@ -520,8 +520,8 @@ public class PatientInfoServiceImpl implements IPatientInfoService { item.setVisitMethod(VisitMethodConstants.OUTPATIENT_SERVICE); }); //新增患者表 - int i = patientInfoMapper.insertPatientInfoList(patientInfoImportList); - if (i <= 0) { + int insertPatientInfo = patientInfoMapper.insertPatientInfoList(patientInfoImportList); + if (insertPatientInfo <= 0) { log.info("患者表新增失败!"); return AjaxResult.error("患者信息新增失败;"); } @@ -560,7 +560,7 @@ public class PatientInfoServiceImpl implements IPatientInfoService { patientInfoMapper.updatePatientInfoSelective(patientInfo); } //endregion - } + PatientInfoImportMain patientInfoImportMainSn = new PatientInfoImportMain(); patientInfoImportMainSn.setSn(sn); patientInfoImportMainSn.setImportStatus(ImportStatusEnum.FINISHED.getInfo()); @@ -649,14 +649,18 @@ public class PatientInfoServiceImpl implements IPatientInfoService { } } //新增居民表 - int residentCount = residentInfoMapper.insertResidentInfoList(insertResidentInfo); - if (residentCount <= 0) { - return AjaxResult.error("已完成数据导入!导入成功0条记录;失败" + patientInfoImportVO.getCount() + "条记录。"); + if (CollectionUtils.isNotEmpty(insertResidentInfo) || insertResidentInfo.size() != 0){ + int residentCount = residentInfoMapper.insertResidentInfoList(insertResidentInfo); + if (residentCount <= 0) { + return AjaxResult.error("已完成数据导入!导入成功0条记录;失败" + patientInfoImportVO.getCount() + "条记录。"); + } + insertResidentInfo.forEach(item -> { patientInfoImports.stream().filter(patientInfoImport -> patientInfoImport.getPatientName().equals(item.getPatientName()) + && patientInfoImport.getPatientPhone().equals(item.getPatientPhone())).findFirst().orElse(new PatientInfoImport()).setResidentId(item.getId()); + } + ); } - patientInfoImports.forEach(item -> item.setResidentId(item.getId())); //设置为门诊患者 - patientInfoImports.forEach(item -> - { + patientInfoImports.forEach(item -> { item.setPatientType(PatientTypeEnum.OUTPATIENT.getInfo()); item.setVisitMethod(VisitMethodConstants.OUTPATIENT_SERVICE); }); @@ -684,6 +688,19 @@ public class PatientInfoServiceImpl implements IPatientInfoService { if (patientVisitRecordCount <= 0) { return AjaxResult.error("已完成数据导入!导入成功0条记录;失败" + patientInfoImportVO.getCount() + "条记录。"); } + // 更新 患者信息表中 的 最近一次问诊记录id + for (PatientInfoImport patientInfoImport : patientInfoImports) { + //获取患者的最近一次就诊ID + PatientVisitRecordDto patientVisitRecordDto = new PatientVisitRecordDto(); + patientVisitRecordDto.setPatientId(patientInfoImport.getPatientInfoId()); + PatientVisitRecord patientVisitRecord = patientVisitRecordMapper.getLastRecord(patientVisitRecordDto); + PatientInfo patientInfo = new PatientInfo(); + patientInfo.setId(patientInfoImport.getPatientInfoId()); + // 修改患者最近一次就诊记录id + patientInfo.setPatientVisitRecordId(patientVisitRecord.getId()); + patientInfoMapper.updatePatientInfoSelective(patientInfo); + } + //endregion PatientInfoImportMain patientInfoImportMainSn = new PatientInfoImportMain(); patientInfoImportMainSn.setSn(patientInfoImportVO.getSn()); patientInfoImportMainSn.setImportStatus(ImportStatusEnum.FINISHED.getInfo());