diff --git a/postdischarge-admin/src/main/resources/template/满意度调查系统资料.xlsx b/postdischarge-admin/src/main/resources/template/满意度调查系统资料.xlsx new file mode 100644 index 00000000..082a2af3 Binary files /dev/null and b/postdischarge-admin/src/main/resources/template/满意度调查系统资料.xlsx differ diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/controller/patientinfo/PatientInfoController.java b/postdischarge-manage/src/main/java/com/xinelu/manage/controller/patientinfo/PatientInfoController.java index 866cca24..74929d49 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/controller/patientinfo/PatientInfoController.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/controller/patientinfo/PatientInfoController.java @@ -1,6 +1,7 @@ package com.xinelu.manage.controller.patientinfo; import com.xinelu.common.annotation.Log; +import com.xinelu.common.constant.Constants; import com.xinelu.common.core.controller.BaseController; import com.xinelu.common.core.domain.AjaxResult; import com.xinelu.common.core.domain.R; @@ -8,24 +9,23 @@ import com.xinelu.common.core.page.TableDataInfo; import com.xinelu.common.enums.BusinessType; import com.xinelu.common.utils.poi.ExcelUtil; import com.xinelu.manage.domain.patientinfo.PatientInfo; +import com.xinelu.manage.domain.patientinfoimport.PatientInfoImport; import com.xinelu.manage.dto.patientinfo.PatientBaseInfoDto; import com.xinelu.manage.dto.patientinfo.PatientInfoDto; import com.xinelu.manage.service.patientinfo.IPatientInfoService; import com.xinelu.manage.vo.patientinfo.PatientInfoVo; +import com.xinelu.manage.vo.patientinfoimport.PatientInfoImportVO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; -import java.util.List; +import org.apache.commons.lang3.StringUtils; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import java.util.List; +import java.util.Objects; /** * 患者信息Controller @@ -131,4 +131,26 @@ public class PatientInfoController extends BaseController { return toAjax(patientInfoService.deletePatientInfoByIds(ids)); } + @ApiOperation("患者信息导入") + @PostMapping("/patientUpload") + public AjaxResult patientUpload(MultipartFile file) throws Exception { + //判断excel里面是否有数据/文件格式 + if (Objects.isNull(file) || StringUtils.isBlank(file.getOriginalFilename())) { + return AjaxResult.error("请选择需要导入的文件!"); + } + // 获取文件名 + String orgName = file.getOriginalFilename(); + if (!orgName.endsWith(Constants.XLSX) && !orgName.endsWith(Constants.XLS)) { + return AjaxResult.error("导入文件格式不正确,请导入xlsx或xls格式的文件!"); + } + ExcelUtil util = new ExcelUtil<>(PatientInfoImport.class); + List list = util.importExcel(file.getInputStream()); + return patientInfoService.patientUpload(list); + } + + @ApiOperation("未识别科室名称导入") + @PostMapping("/secondaryUpload") + public AjaxResult secondaryUpload(PatientInfoImportVO patientInfoImportVO) { + return patientInfoService.secondaryUpload(patientInfoImportVO); + } } diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/domain/patientinfo/PatientInfo.java b/postdischarge-manage/src/main/java/com/xinelu/manage/domain/patientinfo/PatientInfo.java index a9e16a97..fed5c1e6 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/domain/patientinfo/PatientInfo.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/domain/patientinfo/PatientInfo.java @@ -344,4 +344,12 @@ public class PatientInfo extends BaseEntity { /** 删除标识,0:未删除,1:已删除 */ private Integer delFlag; + @ApiModelProperty(value = "导入流水号") + private String sn; + + @ApiModelProperty(value = "年龄") + private Integer age; + + @ApiModelProperty(value = "导入患者表id") + private Integer patientInfoImportId; } diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/domain/patientinfoimport/PatientInfoImport.java b/postdischarge-manage/src/main/java/com/xinelu/manage/domain/patientinfoimport/PatientInfoImport.java new file mode 100644 index 00000000..2c03579a --- /dev/null +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/domain/patientinfoimport/PatientInfoImport.java @@ -0,0 +1,155 @@ +package com.xinelu.manage.domain.patientinfoimport; + +import com.xinelu.common.annotation.Excel; +import com.xinelu.common.core.domain.BaseEntity; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import java.time.LocalDateTime; +import java.util.Objects; + +/** + * 患者导入表对象 patient_info_import + * + * @author xinelu + * @date 2024-11-26 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@ApiModel(value = "患者导入表对象", description = "patient_info_import") +public class PatientInfoImport extends BaseEntity { + private static final long serialVersionUID = 1L; + + /** + * 主键id + */ + private Long id; + + /** + * 序号 + */ + @ApiModelProperty(value = "序号") + @Excel(name = "序号") + private Long orderNum; + + /** + * 科室名称(别名) + */ + @ApiModelProperty(value = "科室名称") + @Excel(name = "科室名称") + private String deptAlias; + + /** + * 就诊时间(门诊患者),时间格式:yyyy-MM-dd + */ + @ApiModelProperty(value = "就诊时间") + @Excel(name = "就诊时间") + private LocalDateTime visitDate; + + /** + * 门诊/住院号 + */ + @ApiModelProperty(value = "门诊/住院号") + @Excel(name = "就诊号") + private String inHospitalNumber; + + /** + * 患者姓名 + */ + @ApiModelProperty(value = "患者姓名") + @Excel(name = "患者姓名") + private String patientName; + + /** + * 身份证号 + */ + @ApiModelProperty(value = "身份证号") + @Excel(name = "身份证号") + private String cardNo; + + /** + * 年龄 + */ + @ApiModelProperty(value = "年龄") + @Excel(name = "年龄") + private Integer age; + + /** + * 主要诊断 + */ + @ApiModelProperty(value = "主要诊断") + @Excel(name = "诊断名称") + private String mainDiagnosis; + + /** + * 患者电话 + */ + @ApiModelProperty(value = "患者电话") + @Excel(name = "手机号号码") + private String patientPhone; + + /** + * 匹配的科室ID + */ + @ApiModelProperty(value = "匹配的科室ID") + @Excel(name = "匹配的科室ID") + private Long departmentId; + + /** + * 匹配的科室名称 + */ + @ApiModelProperty(value = "匹配的科室名称") + @Excel(name = "科室名称") + private String departmentName; + + /** + * 流水号 + */ + @ApiModelProperty(value = "流水号") + @Excel(name = "流水号") + private String sn; + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PatientInfoImport that = (PatientInfoImport) o; + return Objects.equals(patientName, that.patientName) && Objects.equals(patientPhone, that.patientPhone); + } + + @Override + public int hashCode() { + return Objects.hash(patientName, patientPhone); + } + + @Override + public String toString() { + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("orderNum", getOrderNum()) + .append("deptAlias", getDeptAlias()) + .append("visitDate", getVisitDate()) + .append("inHospitalNumber", getInHospitalNumber()) + .append("patientName", getPatientName()) + .append("cardNo", getCardNo()) + .append("age", getAge()) + .append("mainDiagnosis", getMainDiagnosis()) + .append("patientPhone", getPatientPhone()) + .append("departmentId", getDepartmentId()) + .append("departmentName", getDepartmentName()) + .append("sn", getSn()) + .append("createTime", getCreateTime()) + .append("createBy", getCreateBy()) + .toString(); + } +} diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/department/DepartmentMapper.java b/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/department/DepartmentMapper.java index 92a0e381..bc08a92b 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/department/DepartmentMapper.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/department/DepartmentMapper.java @@ -153,4 +153,12 @@ public interface DepartmentMapper { * @return int */ List selectDepartmentNameCount(Department department); + + /** + * 批量修改科室别名 + * + * @param departmentList + * @return int + */ + int updateDepartmentListByIds(List departmentList); } diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/patientinfo/PatientInfoMapper.java b/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/patientinfo/PatientInfoMapper.java index 3dcb0fc5..9aa82744 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/patientinfo/PatientInfoMapper.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/patientinfo/PatientInfoMapper.java @@ -1,6 +1,7 @@ package com.xinelu.manage.mapper.patientinfo; import com.xinelu.manage.domain.patientinfo.PatientInfo; +import com.xinelu.manage.domain.patientinfoimport.PatientInfoImport; import com.xinelu.manage.domain.residentinfo.ResidentInfo; import com.xinelu.manage.dto.patientinfo.PatientInfoDto; import com.xinelu.manage.vo.patientinfo.PatientBaseInfoVo; @@ -139,4 +140,20 @@ public interface PatientInfoMapper { * @return int */ int selectPatientSignServiceCount(); + + /** + * 批量查询患者信息 + * + * @param list 集合 + * @return PatientInfo + */ + List selectPatientInfoByPatientName(@Param("list") List list); + + /** + * 新增患者信息 + * + * @param patientInfo 患者信息 + * @return 结果 + */ + int insertPatientInfoList(List patientInfo); } diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/patientinfoimport/PatientInfoImportMapper.java b/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/patientinfoimport/PatientInfoImportMapper.java new file mode 100644 index 00000000..daf40426 --- /dev/null +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/patientinfoimport/PatientInfoImportMapper.java @@ -0,0 +1,77 @@ +package com.xinelu.manage.mapper.patientinfoimport; + +import com.xinelu.manage.domain.patientinfoimport.PatientInfoImport; + +import java.util.List; + +/** + * 导入患者暂存表Mapper接口 + * + * @author xinelu + * @date 2024-11-27 + */ +public interface PatientInfoImportMapper { + /** + * 查询导入患者暂存表 + * + * @param id 导入患者暂存表主键 + * @return 导入患者暂存表 + */ + PatientInfoImport selectPatientInfoImportById(Long id); + + /** + * 查询导入患者暂存表列表 + * + * @param patientInfoImport 导入患者暂存表 + * @return 导入患者暂存表集合 + */ + List selectPatientInfoImportList(PatientInfoImport patientInfoImport); + + /** + * 新增导入患者暂存表 + * + * @param patientInfoImport 导入患者暂存表 + * @return 结果 + */ + int insertPatientInfoImport(PatientInfoImport patientInfoImport); + + /** + * 修改导入患者暂存表 + * + * @param patientInfoImport 导入患者暂存表 + * @return 结果 + */ + int updatePatientInfoImport(PatientInfoImport patientInfoImport); + + /** + * 删除导入患者暂存表 + * + * @param id 导入患者暂存表主键 + * @return 结果 + */ + int deletePatientInfoImportById(Long id); + + /** + * 批量删除导入患者暂存表 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + int deletePatientInfoImportByIds(Long[] ids); + + /** + * 新增导入患者暂存表 + * + * @param patientInfoImport 导入患者暂存表 + * @return 结果 + */ + int insertPatientInfoImportList(List patientInfoImport); + + /** + * 根据序列号查询数据 + * + * @param sn 序列号 + * @return PatientInfoImport + */ + List selectPatientInfoImportBySn(String sn); +} \ No newline at end of file diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/residentinfo/ResidentInfoMapper.java b/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/residentinfo/ResidentInfoMapper.java index 70ed372c..97157ac2 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/residentinfo/ResidentInfoMapper.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/mapper/residentinfo/ResidentInfoMapper.java @@ -1,5 +1,6 @@ package com.xinelu.manage.mapper.residentinfo; +import com.xinelu.manage.domain.patientinfoimport.PatientInfoImport; import com.xinelu.manage.domain.residentinfo.ResidentInfo; import org.apache.ibatis.annotations.Param; @@ -85,4 +86,12 @@ public interface ResidentInfoMapper { * @return 结果 */ int updateResidentInfoOpenid(ResidentInfo residentInfo); + + /** + * 批量新增居民信息 + * + * @param patientInfoImports 居民信息 + * @return 结果 + */ + int insertResidentInfoList(List patientInfoImports); } diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/service/patientinfo/IPatientInfoService.java b/postdischarge-manage/src/main/java/com/xinelu/manage/service/patientinfo/IPatientInfoService.java index e55ecea2..0e108466 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/service/patientinfo/IPatientInfoService.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/service/patientinfo/IPatientInfoService.java @@ -1,9 +1,13 @@ package com.xinelu.manage.service.patientinfo; +import com.xinelu.common.core.domain.AjaxResult; import com.xinelu.manage.domain.patientinfo.PatientInfo; +import com.xinelu.manage.domain.patientinfoimport.PatientInfoImport; import com.xinelu.manage.dto.patientinfo.PatientBaseInfoDto; import com.xinelu.manage.dto.patientinfo.PatientInfoDto; import com.xinelu.manage.vo.patientinfo.PatientInfoVo; +import com.xinelu.manage.vo.patientinfoimport.PatientInfoImportVO; + import java.util.List; /** @@ -85,4 +89,20 @@ public interface IPatientInfoService { * @return 结果 */ int deletePatientInfoById(Long id); + + /** + * 患者导入 + * + * @param list 患者信息结合 + * @return AjaxResult + */ + AjaxResult patientUpload(List list); + + /** + * 未识别科室名称导入 + * + * @param patientInfoImportVO + * @return AjaxResult + */ + AjaxResult secondaryUpload(PatientInfoImportVO patientInfoImportVO); } 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 d3c3391c..8cf9c0ab 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 @@ -2,34 +2,50 @@ package com.xinelu.manage.service.patientinfo.impl; import com.xinelu.common.annotation.DataScope; import com.xinelu.common.constant.SignRecordServiceStatusConstants; +import com.xinelu.common.core.domain.AjaxResult; +import com.xinelu.common.core.domain.entity.SysUser; import com.xinelu.common.enums.PatientSourceEnum; import com.xinelu.common.exception.ServiceException; import com.xinelu.common.utils.BaseUtil; import com.xinelu.common.utils.SecurityUtils; import com.xinelu.common.utils.StringUtils; import com.xinelu.common.utils.bean.BeanUtils; +import com.xinelu.common.utils.regex.RegexUtil; +import com.xinelu.manage.domain.department.Department; import com.xinelu.manage.domain.patientinfo.PatientInfo; +import com.xinelu.manage.domain.patientinfoimport.PatientInfoImport; import com.xinelu.manage.domain.patientvisitrecord.PatientVisitRecord; import com.xinelu.manage.domain.residentinfo.ResidentInfo; import com.xinelu.manage.domain.signpatientrecord.SignPatientRecord; import com.xinelu.manage.dto.patientinfo.PatientBaseInfoDto; import com.xinelu.manage.dto.patientinfo.PatientInfoDto; import com.xinelu.manage.dto.patientvisitrecord.PatientVisitRecordDto; +import com.xinelu.manage.mapper.department.DepartmentMapper; import com.xinelu.manage.mapper.patientinfo.PatientInfoMapper; +import com.xinelu.manage.mapper.patientinfoimport.PatientInfoImportMapper; +import com.xinelu.manage.mapper.patientvisitrecord.PatientVisitRecordMapper; import com.xinelu.manage.mapper.residentinfo.ResidentInfoMapper; import com.xinelu.manage.mapper.signpatientrecord.SignPatientRecordMapper; import com.xinelu.manage.service.patientinfo.IPatientInfoService; import com.xinelu.manage.service.patientvisitrecord.IPatientVisitRecordService; import com.xinelu.manage.vo.patientinfo.PatientInfoVo; -import java.time.LocalDateTime; -import java.util.List; -import java.util.Objects; -import javax.annotation.Resource; +import com.xinelu.manage.vo.patientinfoimport.DeptAliasVO; +import com.xinelu.manage.vo.patientinfoimport.PatientInfoImportVO; +import com.xinelu.system.mapper.SysUserMapper; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.ObjectUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import javax.annotation.Resource; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + /** * 患者信息Service业务层处理 * @@ -41,12 +57,22 @@ public class PatientInfoServiceImpl implements IPatientInfoService { @Resource private PatientInfoMapper patientInfoMapper; - @Resource - private ResidentInfoMapper residentInfoMapper; - @Resource - private IPatientVisitRecordService patientVisitRecordService; - @Resource - private SignPatientRecordMapper signPatientRecordMapper; + @Resource + private ResidentInfoMapper residentInfoMapper; + @Resource + private IPatientVisitRecordService patientVisitRecordService; + @Resource + private SignPatientRecordMapper signPatientRecordMapper; + @Resource + private SysUserMapper sysUserMapper; + @Resource + private DepartmentMapper departmentMapper; + @Resource + private PatientInfoImportMapper patientInfoImportMapper; + @Resource + private PatientVisitRecordMapper patientVisitRecordMapper; + @Resource + private RegexUtil regexUtil; /** * 查询患者信息 @@ -288,4 +314,209 @@ public class PatientInfoServiceImpl implements IPatientInfoService { public int deletePatientInfoById(Long id) { return patientInfoMapper.deletePatientInfoById(id); } + + @Transactional(rollbackFor = Exception.class) + @Override + public AjaxResult patientUpload(List list) { + if (CollectionUtils.isEmpty(list) || list.size() == 0) { + return AjaxResult.error("导入用户数据不能为空!"); + } + PatientInfoImport regexPhone = list.stream().filter(item -> StringUtils.isNotBlank(item.getPatientPhone())).filter(item -> BooleanUtils.isFalse(regexUtil.regexPhone(item.getPatientPhone()))).findFirst().orElse(new PatientInfoImport()); + if (StringUtils.isNotBlank(regexPhone.getPatientPhone())) { + return AjaxResult.error("手机号号码:" + regexPhone.getPatientPhone() + " 格式不正确,请重新录入!"); + } + PatientInfoImport regexCardNo = list.stream().filter(item -> StringUtils.isNotBlank(item.getCardNo())).filter(item -> BooleanUtils.isFalse(regexUtil.regexCardNo(item.getCardNo()))).findFirst().orElse(new PatientInfoImport()); + if (StringUtils.isNotBlank(regexCardNo.getCardNo())) { + return AjaxResult.error("身份证号:" + regexCardNo.getCardNo() + " 格式不正确,请重新录入!"); + } + //导入重复 + List distinctCollect = list.stream().filter(Objects::nonNull).distinct().collect(Collectors.toList()); + if (list.size() != distinctCollect.size()) { + List contains = list.stream().filter(item -> !distinctCollect.contains(item)).collect(Collectors.toList()); + return AjaxResult.error("导入数据重复", contains); + } + //与数据库重复 + List patientInfos = patientInfoMapper.selectPatientInfoByPatientName(list); + if (CollectionUtils.isEmpty(patientInfos)) { + return AjaxResult.error("有" + patientInfos.size() + "条记录当天已导入,是否继续导入"); + } + //sn + String sn = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")); + //登录用户科室信息 + SysUser sysUser = sysUserMapper.selectUserById(SecurityUtils.getUserId()); + Department department = new Department(); + if (Objects.isNull(sysUser.getHospitalAgencyId())) { + return AjaxResult.error("该账号无所属医院信息,请先添加该账号所属的医院信息!"); + } + department.setHospitalAgencyId(sysUser.getHospitalAgencyId()); + List departmentList = departmentMapper.selectDepartmentNameCount(department); + if (CollectionUtils.isEmpty(departmentList)) { + return AjaxResult.error("该账号所属医院无下级科室,请先维护所属医院的下级科室信息!"); + } + PatientInfoImportVO patientInfoImportVO = new PatientInfoImportVO(); + List deptAliasVOS = new ArrayList<>(); + //组装数据 + for (PatientInfoImport patientInfoImport : list) { + //判断是否有科室名称或别名一致 + Department equalsDepartment = departmentList.stream().filter(Objects::nonNull).filter(item -> patientInfoImport.getDeptAlias().equals(item.getDepartmentName()) || item.getDepartmentAbbreviation().contains(patientInfoImport.getDeptAlias())).findFirst().orElse(new Department()); + patientInfoImport.setSn(sn); + patientInfoImport.setCreateBy(SecurityUtils.getUsername()); + patientInfoImport.setCreateTime(LocalDateTime.now()); + //一致塞值,不一致取数据返回 + if (Objects.nonNull(equalsDepartment.getId())) { + patientInfoImport.setDepartmentId(equalsDepartment.getId()); + patientInfoImport.setDepartmentName(patientInfoImport.getDepartmentName()); + } else { + DeptAliasVO deptAliasVO = new DeptAliasVO(); + deptAliasVO.setSn(sn); + deptAliasVO.setDeptAlias(patientInfoImport.getDeptAlias()); + deptAliasVOS.add(deptAliasVO); + } + } + List patientInfoImports = new ArrayList<>(list); + patientInfoImportVO.setSn(sn); + patientInfoImportVO.setDepartments(departmentList); + if (CollectionUtils.isNotEmpty(deptAliasVOS)) { + deptAliasVOS = deptAliasVOS.stream().filter(Objects::nonNull).filter(item -> Objects.nonNull(item.getDepartmentId())).distinct().collect(Collectors.toList()); + patientInfoImportVO.setDeptAliasVOS(deptAliasVOS); + } + //新增缓存表 + int insertCount = patientInfoImportMapper.insertPatientInfoImportList(list); + if (insertCount <= 0) { + return AjaxResult.error("导入失败,请联系管理员!"); + } + //科室名称全符合新增患者表,否则返回数据 + if (CollectionUtils.isNotEmpty(deptAliasVOS)) { + return AjaxResult.success("科室名称不存在", patientInfoImportVO); + } else { + int i = patientInfoMapper.insertPatientInfoList(list); + if (i <= 0) { + return AjaxResult.error("导入失败,请联系管理员!"); + } + List patientInfoIds = new ArrayList<>(list); + int residentCount = residentInfoMapper.insertResidentInfoList(list); + if (residentCount <= 0) { + return AjaxResult.error("导入失败,请联系管理员!"); + } + List residentIds = new ArrayList<>(list); + List patientVisitRecords = new ArrayList<>(); + for (PatientInfoImport patientInfoImport : patientInfoImports) { + PatientInfoImport patientInfoId = patientInfoIds.stream().filter(Objects::nonNull).filter(item -> patientInfoImport.getPatientName().equals(item.getPatientName()) && patientInfoImport.getPatientPhone().equals(item.getPatientPhone())).findFirst().orElse(new PatientInfoImport()); + PatientInfoImport residentId = residentIds.stream().filter(Objects::nonNull).filter(item -> patientInfoImport.getPatientName().equals(item.getPatientName()) && patientInfoImport.getPatientPhone().equals(item.getPatientPhone())).findFirst().orElse(new PatientInfoImport()); + PatientVisitRecord patientVisitRecord = new PatientVisitRecord(); + patientVisitRecord.setPatientId(patientInfoId.getId()); + patientVisitRecord.setResidentId(residentId.getId()); +// patientVisitRecord.setVisitDate(patientInfoImport.getVisitDate()); +// patientVisitRecord.setCardNo(patientInfoImport.getCardNo()); +// patientVisitRecord.setAge(patientInfoImport.getAge()); +// patientVisitRecord.setMainDiagnosis(patientInfoImport.getMainDiagnosis()); +// patientVisitRecord.setPatientPhone(patientInfoImport.getPatientPhone()); +// patientVisitRecord.setPatientName(patientInfoImport.getPatientName()); +// patientVisitRecord.setDepartmentId(patientInfoImport.getDepartmentId()); +// patientVisitRecord.setDepartmentName(patientInfoImport.getDepartmentName()); + BeanUtils.copyProperties(patientInfoImport, patientVisitRecord); + patientVisitRecord.setDelFlag(0); + patientVisitRecord.setHospitalAgencyId(departmentList.get(0).getHospitalAgencyId()); + patientVisitRecord.setHospitalAgencyName(departmentList.get(0).getHospitalAgencyName()); + patientVisitRecord.setCreateBy(SecurityUtils.getUsername()); + patientVisitRecord.setCreateTime(LocalDateTime.now()); + patientVisitRecords.add(patientVisitRecord); + } + int patientVisitRecordCount = patientVisitRecordMapper.insertBatch(patientVisitRecords); + if (patientVisitRecordCount <= 0) { + return AjaxResult.error("导入失败,请联系管理员!"); + } + } + return AjaxResult.success(); + } + + @Transactional(rollbackFor = Exception.class) + @Override + public AjaxResult secondaryUpload(PatientInfoImportVO patientInfoImportVO) { + if (Objects.isNull(patientInfoImportVO) || CollectionUtils.isEmpty(patientInfoImportVO.getDeptAliasVOS()) || StringUtils.isEmpty(patientInfoImportVO.getSn())) { + return AjaxResult.success(); + } + //根据sn查询数据 + List patientInfoImports = patientInfoImportMapper.selectPatientInfoImportBySn(patientInfoImportVO.getSn()); + for (PatientInfoImport patientInfoImport : patientInfoImports) { + if (StringUtils.isEmpty(patientInfoImport.getDepartmentName()) || Objects.isNull(patientInfoImport.getDepartmentId())) { + DeptAliasVO deptAliasVO = patientInfoImportVO.getDeptAliasVOS().stream().filter(Objects::nonNull).filter(item -> StringUtils.isNotBlank(item.getDepartmentName()) && StringUtils.isNotEmpty(item.getDeptAlias()) && patientInfoImport.getDeptAlias().equals(item.getDeptAlias())).findFirst().orElse(new DeptAliasVO()); + patientInfoImport.setDepartmentId(deptAliasVO.getDepartmentId()); + patientInfoImport.setDepartmentName(deptAliasVO.getDepartmentName()); + } + } + //科室、医院 + SysUser sysUser = sysUserMapper.selectUserById(SecurityUtils.getUserId()); + Department department = new Department(); + if (Objects.isNull(sysUser.getHospitalAgencyId())) { + return AjaxResult.error("该账号无所属医院信息,请先添加该账号所属的医院信息!"); + } + department.setHospitalAgencyId(sysUser.getHospitalAgencyId()); + List departmentList = departmentMapper.selectDepartmentNameCount(department); + if (CollectionUtils.isEmpty(departmentList)) { + return AjaxResult.error("该账号所属医院无下级科室,请先维护所属医院的下级科室信息!"); + } + List departments = new ArrayList<>(); + for (Department department1 : departmentList) { + Department deptAliasdepartment = new Department(); + DeptAliasVO deptAliasVO = patientInfoImportVO.getDeptAliasVOS().stream().filter(Objects::nonNull).filter(item -> department1.getDepartmentName().equals(item.getDepartmentName())).findFirst().orElse(new DeptAliasVO()); + if (Objects.nonNull(deptAliasVO.getDeptAlias()) && StringUtils.isNotEmpty(department1.getDepartmentAbbreviation())) { + deptAliasdepartment.setDepartmentAbbreviation(department1.getDepartmentAbbreviation() + "|" + deptAliasVO.getDeptAlias()); + deptAliasdepartment.setId(department1.getId()); + deptAliasdepartment.setUpdateBy(SecurityUtils.getUsername()); + deptAliasdepartment.setUpdateTime(LocalDateTime.now()); + departments.add(deptAliasdepartment); + } else if (Objects.nonNull(deptAliasVO.getDeptAlias()) && StringUtils.isEmpty(department1.getDepartmentAbbreviation())) { + department1.setDepartmentAbbreviation(deptAliasVO.getDeptAlias()); + deptAliasdepartment.setId(department1.getId()); + deptAliasdepartment.setUpdateBy(SecurityUtils.getUsername()); + deptAliasdepartment.setUpdateTime(LocalDateTime.now()); + departments.add(deptAliasdepartment); + } + } + if (CollectionUtils.isNotEmpty(departments)) { + int i = departmentMapper.updateDepartmentListByIds(departments); + if (i <= 0) { + return AjaxResult.error("导入失败,请联系管理员!"); + } + } + int i = patientInfoMapper.insertPatientInfoList(patientInfoImports); + if (i <= 0) { + return AjaxResult.error("导入失败,请联系管理员!"); + } + List patientInfoIds = new ArrayList<>(patientInfoImports); + int residentCount = residentInfoMapper.insertResidentInfoList(patientInfoImports); + if (residentCount <= 0) { + return AjaxResult.error("导入失败,请联系管理员!"); + } + List residentIds = new ArrayList<>(patientInfoImports); + List patientVisitRecords = new ArrayList<>(); + for (PatientInfoImport patientInfoImport : patientInfoImports) { + PatientInfoImport patientInfoId = patientInfoIds.stream().filter(Objects::nonNull).filter(item -> patientInfoImport.getPatientName().equals(item.getPatientName()) && patientInfoImport.getPatientPhone().equals(item.getPatientPhone())).findFirst().orElse(new PatientInfoImport()); + PatientInfoImport residentId = residentIds.stream().filter(Objects::nonNull).filter(item -> patientInfoImport.getPatientName().equals(item.getPatientName()) && patientInfoImport.getPatientPhone().equals(item.getPatientPhone())).findFirst().orElse(new PatientInfoImport()); + PatientVisitRecord patientVisitRecord = new PatientVisitRecord(); + patientVisitRecord.setPatientId(patientInfoId.getId()); + patientVisitRecord.setResidentId(residentId.getId()); +// patientVisitRecord.setVisitDate(patientInfoImport.getVisitDate()); +// patientVisitRecord.setCardNo(patientInfoImport.getCardNo()); +// patientVisitRecord.setAge(patientInfoImport.getAge()); +// patientVisitRecord.setMainDiagnosis(patientInfoImport.getMainDiagnosis()); +// patientVisitRecord.setPatientPhone(patientInfoImport.getPatientPhone()); +// patientVisitRecord.setPatientName(patientInfoImport.getPatientName()); +// patientVisitRecord.setDepartmentId(patientInfoImport.getDepartmentId()); +// patientVisitRecord.setDepartmentName(patientInfoImport.getDepartmentName()); + BeanUtils.copyProperties(patientInfoImport, patientVisitRecord); + patientVisitRecord.setDelFlag(0); + patientVisitRecord.setHospitalAgencyId(department.getHospitalAgencyId()); + patientVisitRecord.setHospitalAgencyName(department.getHospitalAgencyName()); + patientVisitRecord.setCreateBy(SecurityUtils.getUsername()); + patientVisitRecord.setCreateTime(LocalDateTime.now()); + patientVisitRecords.add(patientVisitRecord); + } + int patientVisitRecordCount = patientVisitRecordMapper.insertBatch(patientVisitRecords); + if (patientVisitRecordCount <= 0) { + return AjaxResult.error("导入失败,请联系管理员!"); + } + return AjaxResult.success(); + } } diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/vo/patientinfo/PatientBaseInfoVo.java b/postdischarge-manage/src/main/java/com/xinelu/manage/vo/patientinfo/PatientBaseInfoVo.java index d32f008a..c9a00661 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/vo/patientinfo/PatientBaseInfoVo.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/vo/patientinfo/PatientBaseInfoVo.java @@ -52,4 +52,7 @@ public class PatientBaseInfoVo { @ApiModelProperty(value = "住址") @Excel(name = "住址") private String address; + + @ApiModelProperty(value = "年龄") + private Integer age; } diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/vo/patientinfo/PatientInfoVo.java b/postdischarge-manage/src/main/java/com/xinelu/manage/vo/patientinfo/PatientInfoVo.java index d4865a82..4a0b9d8c 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/vo/patientinfo/PatientInfoVo.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/vo/patientinfo/PatientInfoVo.java @@ -244,4 +244,7 @@ public class PatientInfoVo { @ApiModelProperty(value = "下次任务执行时间") @JsonFormat(pattern = "yyyy-MM-dd") private LocalDateTime nextTaskTime; + + @ApiModelProperty(value = "年龄") + private Integer age; } diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/vo/patientinfoimport/DeptAliasVO.java b/postdischarge-manage/src/main/java/com/xinelu/manage/vo/patientinfoimport/DeptAliasVO.java new file mode 100644 index 00000000..d4e60ddb --- /dev/null +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/vo/patientinfoimport/DeptAliasVO.java @@ -0,0 +1,57 @@ +package com.xinelu.manage.vo.patientinfoimport; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Objects; + +/** + * 科室别名集合 + * + * @author zh + * @date 2024-11-26 + */ +@Data +public class DeptAliasVO { + + /** + * 科室名称(别名) + */ + @ApiModelProperty(value = "科室名称") + private String deptAlias; + + /** + * 匹配的科室ID + */ + @ApiModelProperty(value = "匹配的科室ID") + private Long departmentId; + + /** + * 匹配的科室名称 + */ + @ApiModelProperty(value = "匹配的科室名称") + private String departmentName; + + /** + * 流水号 + */ + @ApiModelProperty(value = "流水号") + private String sn; + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DeptAliasVO that = (DeptAliasVO) o; + return Objects.equals(deptAlias, that.deptAlias); + } + + @Override + public int hashCode() { + return Objects.hash(deptAlias); + } +} diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/vo/patientinfoimport/PatientInfoImportVO.java b/postdischarge-manage/src/main/java/com/xinelu/manage/vo/patientinfoimport/PatientInfoImportVO.java new file mode 100644 index 00000000..de8cd15e --- /dev/null +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/vo/patientinfoimport/PatientInfoImportVO.java @@ -0,0 +1,35 @@ +package com.xinelu.manage.vo.patientinfoimport; + +import com.xinelu.common.core.domain.BaseEntity; +import com.xinelu.manage.domain.department.Department; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.List; + +/** + * 科室对象 + * + * @author zh + * @date 2024-11-26 + */ +@EqualsAndHashCode(callSuper = true) +@Data +public class PatientInfoImportVO extends BaseEntity { + private static final long serialVersionUID = 1L; + + /** + * 序列号 + */ + private String sn; + + /** + * 科室别名集合 + */ + private List deptAliasVOS; + + /** + * 科室集合 + */ + private List departments; +} diff --git a/postdischarge-manage/src/main/resources/mapper/manage/department/DepartmentMapper.xml b/postdischarge-manage/src/main/resources/mapper/manage/department/DepartmentMapper.xml index f298ce16..fad8da1c 100644 --- a/postdischarge-manage/src/main/resources/mapper/manage/department/DepartmentMapper.xml +++ b/postdischarge-manage/src/main/resources/mapper/manage/department/DepartmentMapper.xml @@ -4,7 +4,7 @@ "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - + @@ -61,7 +61,7 @@ from department - @@ -334,7 +334,7 @@ d.department_code - insert into department @@ -492,7 +492,7 @@ - + update department parent_department_id = @@ -571,7 +571,7 @@ where id = #{id} - + update department parent_department_id = #{parentDepartmentId}, @@ -633,4 +633,14 @@ + + + + update department + + department_abbreviation =#{item.departmentAbbreviation}, + + where id = #{item.id} + + \ No newline at end of file diff --git a/postdischarge-manage/src/main/resources/mapper/manage/patientinfo/PatientInfoMapper.xml b/postdischarge-manage/src/main/resources/mapper/manage/patientinfo/PatientInfoMapper.xml index 50c26bba..0c41c575 100644 --- a/postdischarge-manage/src/main/resources/mapper/manage/patientinfo/PatientInfoMapper.xml +++ b/postdischarge-manage/src/main/resources/mapper/manage/patientinfo/PatientInfoMapper.xml @@ -46,6 +46,9 @@ + + + @@ -96,6 +99,9 @@ p.patient_source, p.surgical_name, p.del_flag, + p.sn, + p.patient_info_import_id, + p.age, p.create_by, p.create_time, p.update_by, @@ -228,6 +234,7 @@ p.sign_patient_record_id, p.visit_date AS visit_date, p.patient_source AS patient_source, + p.age AS age, CASE WHEN isnull( p.sign_patient_record_id) THEN '新建' WHEN sign.service_status = 'INTENTIONAL_SIGNING' THEN '意向签约' @@ -379,7 +386,8 @@ birth_date, card_no, sex, - address + address, + age from patient_info where id = #{id} @@ -784,7 +792,7 @@ - SELECT id, patient_name, @@ -849,4 +857,54 @@ where del_flag = 0 and service_status = 'SERVICE_CENTER' + + + + + insert into patient_info( + patient_info_import_id, + visit_date, + in_hospital_number, + patient_name, + card_no, + age, + main_diagnosis, + patient_phone, + department_id, + department_name, + sn, + del_flag, + create_time, + create_by + ) values + + ( + #{PatientInfoImport.id}, + #{PatientInfoImport.visitDate}, + #{PatientInfoImport.inHospitalNumber}, + #{PatientInfoImport.patientName}, + #{PatientInfoImport.cardNo}, + #{PatientInfoImport.age}, + #{PatientInfoImport.mainDiagnosis}, + #{PatientInfoImport.patientPhone}, + #{PatientInfoImport.departmentId}, + #{PatientInfoImport.departmentName}, + #{PatientInfoImport.sn}, + 0, + #{PatientInfoImport.createTime}, + #{PatientInfoImport.createBy} + ) + + diff --git a/postdischarge-manage/src/main/resources/mapper/manage/patientinfoimport/PatientInfoImportMapper.xml b/postdischarge-manage/src/main/resources/mapper/manage/patientinfoimport/PatientInfoImportMapper.xml new file mode 100644 index 00000000..983ecf45 --- /dev/null +++ b/postdischarge-manage/src/main/resources/mapper/manage/patientinfoimport/PatientInfoImportMapper.xml @@ -0,0 +1,267 @@ + + + + + + + + + + + + + + + + + + + + + + + + select id, + order_num, + dept_alias, + visit_date, + in_hospital_number, + patient_name, + card_no, + age, + main_diagnosis, + patient_phone, + department_id, + department_name, + sn, + create_time, + create_by + from patient_info_import + + + + + + + + insert into patient_info_import + + id, + + order_num, + + dept_alias, + + visit_date, + + in_hospital_number, + + patient_name, + + card_no, + + age, + + main_diagnosis, + + patient_phone, + + department_id, + + department_name, + + sn, + + create_time, + + create_by, + + + + #{id}, + + #{orderNum}, + + #{deptAlias}, + + #{visitDate}, + + #{inHospitalNumber}, + + #{patientName}, + + #{cardNo}, + + #{age}, + + #{mainDiagnosis}, + + #{patientPhone}, + + #{departmentId}, + + #{departmentName}, + + #{sn}, + + #{createTime}, + + #{createBy}, + + + + + + update patient_info_import + + order_num = + #{orderNum}, + + dept_alias = + #{deptAlias}, + + visit_date = + #{visitDate}, + + in_hospital_number = + #{inHospitalNumber}, + + patient_name = + #{patientName}, + + card_no = + #{cardNo}, + + age = + #{age}, + + main_diagnosis = + #{mainDiagnosis}, + + patient_phone = + #{patientPhone}, + + department_id = + #{departmentId}, + + department_name = + #{departmentName}, + + sn = + #{sn}, + + create_time = + #{createTime}, + + create_by = + #{createBy}, + + + where id = #{id} + + + + delete + from patient_info_import + where id = #{id} + + + + delete from patient_info_import where id in + + #{id} + + + + + insert into patient_info_import( + order_num, + dept_alias, + visit_date, + in_hospital_number, + patient_name, + card_no, + age, + main_diagnosis, + patient_phone, + department_id, + department_name, + sn, + create_time, + create_by + ) values + + ( + #{PatientInfoImport.orderNum}, + #{PatientInfoImport.deptAlias}, + #{PatientInfoImport.visitDate}, + #{PatientInfoImport.inHospitalNumber}, + #{PatientInfoImport.patientName}, + #{PatientInfoImport.cardNo}, + #{PatientInfoImport.age}, + #{PatientInfoImport.mainDiagnosis}, + #{PatientInfoImport.patientPhone}, + #{PatientInfoImport.departmentId}, + #{PatientInfoImport.departmentName}, + #{PatientInfoImport.sn}, + #{PatientInfoImport.createTime}, + #{PatientInfoImport.createBy} + ) + + + + + \ No newline at end of file diff --git a/postdischarge-manage/src/main/resources/mapper/manage/residentinfo/ResidentInfoMapper.xml b/postdischarge-manage/src/main/resources/mapper/manage/residentinfo/ResidentInfoMapper.xml index 762c29e6..f06c6410 100644 --- a/postdischarge-manage/src/main/resources/mapper/manage/residentinfo/ResidentInfoMapper.xml +++ b/postdischarge-manage/src/main/resources/mapper/manage/residentinfo/ResidentInfoMapper.xml @@ -124,7 +124,7 @@ - + update resident_info patient_name = @@ -214,4 +214,25 @@ + + + insert into resident_info( + patient_name, + patient_phone, + card_no, + del_flag, + create_by, + create_time + ) values + + ( + #{PatientInfoImport.patientName}, + #{PatientInfoImport.patientPhone}, + #{PatientInfoImport.cardNo}, + 0, + #{PatientInfoImport.createBy}, + #{PatientInfoImport.createTime} + ) + + \ No newline at end of file