患者导入
This commit is contained in:
parent
9b88db6b31
commit
0133f88bf2
Binary file not shown.
@ -219,6 +219,11 @@ public class Constants {
|
||||
*/
|
||||
public static final String OUTPATIENT = "outpatient";
|
||||
|
||||
/**
|
||||
* 门诊患者
|
||||
*/
|
||||
public static final String PATIENT_INFO_IMPORT = "patientInfoImport";
|
||||
|
||||
/**
|
||||
* 预住院
|
||||
*/
|
||||
|
||||
@ -86,4 +86,9 @@ public class HttpStatus
|
||||
* 接口未实现
|
||||
*/
|
||||
public static final int NOT_IMPLEMENTED = 501;
|
||||
|
||||
/**
|
||||
* 系统内部错误
|
||||
*/
|
||||
public static final int ERROR_TWO = 500_2;
|
||||
}
|
||||
|
||||
@ -140,6 +140,18 @@ public class AjaxResult extends HashMap<String, Object> {
|
||||
return new AjaxResult(code, msg, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回错误消息
|
||||
*
|
||||
* @param code 状态码
|
||||
* @param msg 返回内容
|
||||
* @param data 数据对象
|
||||
* @return 警告消息
|
||||
*/
|
||||
public static AjaxResult error(int code, String msg, Object data) {
|
||||
return new AjaxResult(code, msg, data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 方便链式调用
|
||||
*
|
||||
|
||||
@ -61,6 +61,9 @@ public class ImportDownloadController {
|
||||
case Constants.OUTPATIENT: // 门诊患者
|
||||
file = ResourceUtils.getFile("classpath:template/门诊患者信息导入表.xlsx");
|
||||
break;
|
||||
case Constants.PATIENT_INFO_IMPORT: // 门诊患者
|
||||
file = ResourceUtils.getFile("classpath:template/门诊随访记录 - 未随访.xlsx");
|
||||
break;
|
||||
}
|
||||
if (Objects.isNull(file)) {
|
||||
throw new ServiceException("下载导入模板文件失败,请联系管理员!");
|
||||
|
||||
@ -133,7 +133,7 @@ public class PatientInfoController extends BaseController {
|
||||
|
||||
@ApiOperation("患者信息导入")
|
||||
@PostMapping("/patientUpload")
|
||||
public AjaxResult patientUpload(MultipartFile file) throws Exception {
|
||||
public AjaxResult patientUpload(MultipartFile file, Integer records) throws Exception {
|
||||
//判断excel里面是否有数据/文件格式
|
||||
if (Objects.isNull(file) || StringUtils.isBlank(file.getOriginalFilename())) {
|
||||
return AjaxResult.error("请选择需要导入的文件!");
|
||||
@ -145,7 +145,7 @@ public class PatientInfoController extends BaseController {
|
||||
}
|
||||
ExcelUtil<PatientInfoImport> util = new ExcelUtil<>(PatientInfoImport.class);
|
||||
List<PatientInfoImport> list = util.importExcel(file.getInputStream());
|
||||
return patientInfoService.patientUpload(list);
|
||||
return patientInfoService.patientUpload(list, records);
|
||||
}
|
||||
|
||||
@ApiOperation("未识别科室名称导入")
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.xinelu.manage.domain.patientinfoimport;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.xinelu.common.annotation.Excel;
|
||||
import com.xinelu.common.core.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
@ -10,7 +11,7 @@ import lombok.NoArgsConstructor;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
@ -49,8 +50,9 @@ public class PatientInfoImport extends BaseEntity {
|
||||
* 就诊时间(门诊患者),时间格式:yyyy-MM-dd
|
||||
*/
|
||||
@ApiModelProperty(value = "就诊时间")
|
||||
@Excel(name = "就诊时间")
|
||||
private LocalDateTime visitDate;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "就诊时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private LocalDate visitDate;
|
||||
|
||||
/**
|
||||
* 门诊/住院号
|
||||
@ -63,7 +65,7 @@ public class PatientInfoImport extends BaseEntity {
|
||||
* 患者姓名
|
||||
*/
|
||||
@ApiModelProperty(value = "患者姓名")
|
||||
@Excel(name = "患者姓名")
|
||||
@Excel(name = "姓名")
|
||||
private String patientName;
|
||||
|
||||
/**
|
||||
@ -84,14 +86,14 @@ public class PatientInfoImport extends BaseEntity {
|
||||
* 主要诊断
|
||||
*/
|
||||
@ApiModelProperty(value = "主要诊断")
|
||||
@Excel(name = "诊断名称")
|
||||
@Excel(name = "诊断")
|
||||
private String mainDiagnosis;
|
||||
|
||||
/**
|
||||
* 患者电话
|
||||
*/
|
||||
@ApiModelProperty(value = "患者电话")
|
||||
@Excel(name = "手机号号码")
|
||||
@Excel(name = "联系电话")
|
||||
private String patientPhone;
|
||||
|
||||
/**
|
||||
|
||||
@ -147,7 +147,7 @@ public interface PatientInfoMapper {
|
||||
* @param list 集合
|
||||
* @return PatientInfo
|
||||
*/
|
||||
List<PatientInfo> selectPatientInfoByPatientName(@Param("list") List<PatientInfoImport> list);
|
||||
List<PatientInfo> selectPatientInfoByPatientName(@Param("list") List<PatientInfoImport> list, @Param("nowDate") LocalDate nowDate);
|
||||
|
||||
/**
|
||||
* 新增患者信息
|
||||
|
||||
@ -96,7 +96,7 @@ public interface IPatientInfoService {
|
||||
* @param list 患者信息结合
|
||||
* @return AjaxResult
|
||||
*/
|
||||
AjaxResult patientUpload(List<PatientInfoImport> list);
|
||||
AjaxResult patientUpload(List<PatientInfoImport> list,Integer records);
|
||||
|
||||
/**
|
||||
* 未识别科室名称导入
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.xinelu.manage.service.patientinfo.impl;
|
||||
|
||||
import com.xinelu.common.annotation.DataScope;
|
||||
import com.xinelu.common.constant.HttpStatus;
|
||||
import com.xinelu.common.constant.SignRecordServiceStatusConstants;
|
||||
import com.xinelu.common.core.domain.AjaxResult;
|
||||
import com.xinelu.common.core.domain.entity.SysUser;
|
||||
@ -39,6 +40,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
@ -317,28 +319,25 @@ public class PatientInfoServiceImpl implements IPatientInfoService {
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public AjaxResult patientUpload(List<PatientInfoImport> list) {
|
||||
public AjaxResult patientUpload(List<PatientInfoImport> list, Integer records) {
|
||||
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() + " 格式不正确,请重新录入!");
|
||||
List<PatientInfoImport> collect = list.stream().filter(Objects::nonNull).filter(item -> StringUtils.isEmpty(item.getPatientName()) || StringUtils.isEmpty(item.getPatientPhone()) || StringUtils.isEmpty(item.getDeptAlias()) || Objects.isNull(item.getVisitDate())).collect(Collectors.toList());
|
||||
if (CollectionUtils.isNotEmpty(collect)) {
|
||||
return AjaxResult.error("请填写完整!");
|
||||
}
|
||||
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<PatientInfoImport> regexPhoneList = list.stream().filter(item -> StringUtils.isNotBlank(item.getPatientPhone())).filter(item -> BooleanUtils.isFalse(regexUtil.regexPhone(item.getPatientPhone()))).collect(Collectors.toList());
|
||||
if (CollectionUtils.isNotEmpty(regexPhoneList)) {
|
||||
return AjaxResult.error(HttpStatus.ERROR_TWO, "手机号号码格式不正确,请重新录入!", regexPhoneList);
|
||||
}
|
||||
//导入重复
|
||||
//导入重复过滤
|
||||
List<PatientInfoImport> distinctCollect = list.stream().filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
||||
if (list.size() != distinctCollect.size()) {
|
||||
List<PatientInfoImport> contains = list.stream().filter(item -> !distinctCollect.contains(item)).collect(Collectors.toList());
|
||||
return AjaxResult.error("导入数据重复", contains);
|
||||
}
|
||||
LocalDate nowDate = LocalDate.now();
|
||||
//与数据库重复
|
||||
List<PatientInfo> patientInfos = patientInfoMapper.selectPatientInfoByPatientName(list);
|
||||
if (CollectionUtils.isEmpty(patientInfos)) {
|
||||
return AjaxResult.error("有" + patientInfos.size() + "条记录当天已导入,是否继续导入");
|
||||
List<PatientInfo> patientInfos = new ArrayList<>();
|
||||
if (Objects.isNull(records) || records == 1) {
|
||||
patientInfos = patientInfoMapper.selectPatientInfoByPatientName(list, nowDate);
|
||||
}
|
||||
//sn
|
||||
String sn = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
|
||||
@ -350,22 +349,36 @@ public class PatientInfoServiceImpl implements IPatientInfoService {
|
||||
}
|
||||
department.setHospitalAgencyId(sysUser.getHospitalAgencyId());
|
||||
List<Department> departmentList = departmentMapper.selectDepartmentNameCount(department);
|
||||
if (CollectionUtils.isEmpty(departmentList)) {
|
||||
return AjaxResult.error("该账号所属医院无下级科室,请先维护所属医院的下级科室信息!");
|
||||
}
|
||||
PatientInfoImportVO patientInfoImportVO = new PatientInfoImportVO();
|
||||
List<DeptAliasVO> deptAliasVOS = new ArrayList<>();
|
||||
//组装数据
|
||||
for (PatientInfoImport patientInfoImport : list) {
|
||||
List<PatientInfoImport> patientInfoImportList = new ArrayList<>();
|
||||
//选择自动去除当日重复记录
|
||||
for (PatientInfoImport patientInfoImport : distinctCollect) {
|
||||
if (CollectionUtils.isNotEmpty(patientInfos)) {
|
||||
List<PatientInfo> collect1 = patientInfos.stream().filter(Objects::nonNull).filter(item -> patientInfoImport.getPatientName().equals(item.getPatientName()) && patientInfoImport.getPatientPhone().equals(item.getPatientPhone())).collect(Collectors.toList());
|
||||
if (CollectionUtils.isNotEmpty(collect1)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
//判断是否有科室名称或别名一致
|
||||
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());
|
||||
//医院有科室且名称一致塞值,不一致取数据返回,医院没科室科室数据返回
|
||||
if (CollectionUtils.isNotEmpty(departmentList)) {
|
||||
Department equalsDepartment = departmentList.stream().filter(Objects::nonNull)
|
||||
.filter(item -> patientInfoImport.getDeptAlias().equals(item.getDepartmentName()) || (StringUtils.isNotEmpty(item.getDepartmentAbbreviation()) && item.getDepartmentAbbreviation().contains(patientInfoImport.getDeptAlias()))).findFirst().orElse(new Department());
|
||||
if (Objects.nonNull(equalsDepartment.getId())) {
|
||||
patientInfoImport.setDepartmentId(equalsDepartment.getId());
|
||||
patientInfoImport.setDepartmentName(patientInfoImport.getDepartmentName());
|
||||
patientInfoImportList.add(patientInfoImport);
|
||||
} else {
|
||||
DeptAliasVO deptAliasVO = new DeptAliasVO();
|
||||
deptAliasVO.setSn(sn);
|
||||
deptAliasVO.setDeptAlias(patientInfoImport.getDeptAlias());
|
||||
deptAliasVOS.add(deptAliasVO);
|
||||
}
|
||||
} else {
|
||||
DeptAliasVO deptAliasVO = new DeptAliasVO();
|
||||
deptAliasVO.setSn(sn);
|
||||
@ -373,15 +386,16 @@ public class PatientInfoServiceImpl implements IPatientInfoService {
|
||||
deptAliasVOS.add(deptAliasVO);
|
||||
}
|
||||
}
|
||||
List<PatientInfoImport> patientInfoImports = new ArrayList<>(list);
|
||||
//组装返回数据
|
||||
List<PatientInfoImport> patientInfoImports = new ArrayList<>(patientInfoImportList);
|
||||
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());
|
||||
deptAliasVOS = deptAliasVOS.stream().filter(Objects::nonNull).filter(item -> Objects.nonNull(item.getDeptAlias())).distinct().collect(Collectors.toList());
|
||||
patientInfoImportVO.setDeptAliasVOS(deptAliasVOS);
|
||||
}
|
||||
//新增缓存表
|
||||
int insertCount = patientInfoImportMapper.insertPatientInfoImportList(list);
|
||||
int insertCount = patientInfoImportMapper.insertPatientInfoImportList(patientInfoImportList);
|
||||
if (insertCount <= 0) {
|
||||
return AjaxResult.error("导入失败,请联系管理员!");
|
||||
}
|
||||
@ -389,16 +403,19 @@ public class PatientInfoServiceImpl implements IPatientInfoService {
|
||||
if (CollectionUtils.isNotEmpty(deptAliasVOS)) {
|
||||
return AjaxResult.success("科室名称不存在", patientInfoImportVO);
|
||||
} else {
|
||||
int i = patientInfoMapper.insertPatientInfoList(list);
|
||||
//新增患者表
|
||||
int i = patientInfoMapper.insertPatientInfoList(patientInfoImportList);
|
||||
if (i <= 0) {
|
||||
return AjaxResult.error("导入失败,请联系管理员!");
|
||||
}
|
||||
List<PatientInfoImport> patientInfoIds = new ArrayList<>(list);
|
||||
int residentCount = residentInfoMapper.insertResidentInfoList(list);
|
||||
//新增居民表
|
||||
List<PatientInfoImport> patientInfoIds = new ArrayList<>(patientInfoImportList);
|
||||
int residentCount = residentInfoMapper.insertResidentInfoList(patientInfoImportList);
|
||||
if (residentCount <= 0) {
|
||||
return AjaxResult.error("导入失败,请联系管理员!");
|
||||
}
|
||||
List<PatientInfoImport> residentIds = new ArrayList<>(list);
|
||||
//新增就诊记录表
|
||||
List<PatientInfoImport> residentIds = new ArrayList<>(patientInfoImportList);
|
||||
List<PatientVisitRecord> 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());
|
||||
@ -406,14 +423,6 @@ public class PatientInfoServiceImpl implements IPatientInfoService {
|
||||
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());
|
||||
@ -456,6 +465,7 @@ public class PatientInfoServiceImpl implements IPatientInfoService {
|
||||
if (CollectionUtils.isEmpty(departmentList)) {
|
||||
return AjaxResult.error("该账号所属医院无下级科室,请先维护所属医院的下级科室信息!");
|
||||
}
|
||||
//科室组装别名
|
||||
List<Department> departments = new ArrayList<>();
|
||||
for (Department department1 : departmentList) {
|
||||
Department deptAliasdepartment = new Department();
|
||||
@ -474,16 +484,19 @@ public class PatientInfoServiceImpl implements IPatientInfoService {
|
||||
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<PatientInfoImport> patientInfoIds = new ArrayList<>(patientInfoImports);
|
||||
int residentCount = residentInfoMapper.insertResidentInfoList(patientInfoImports);
|
||||
if (residentCount <= 0) {
|
||||
@ -497,14 +510,6 @@ public class PatientInfoServiceImpl implements IPatientInfoService {
|
||||
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());
|
||||
|
||||
@ -861,13 +861,15 @@
|
||||
<select id="selectPatientInfoByPatientName" resultType="com.xinelu.manage.domain.patientinfo.PatientInfo">
|
||||
select
|
||||
patient_name,
|
||||
patient_phone
|
||||
patient_phone,
|
||||
create_time
|
||||
from patient_info
|
||||
<where>
|
||||
(patient_name, patient_phone) IN
|
||||
<foreach item="list" index="index" collection="item" open="(" separator="," close=")">
|
||||
<foreach item="list" index="index" collection="list" open="(" separator="," close=")">
|
||||
(#{list.patientName}, #{list.patientPhone})
|
||||
</foreach>
|
||||
AND date_format(create_time,'%y%m%d') = date_format(#{nowDate},'%y%m%d')
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
@ -215,7 +215,7 @@
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<insert id="insertResidentInfoList" useGeneratedKeys="true" keyProperty="id">
|
||||
<insert id="insertResidentInfoList" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into resident_info(
|
||||
patient_name,
|
||||
patient_phone,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user