This commit is contained in:
zhuangyuanke 2024-12-31 17:10:08 +08:00
parent f88b28b243
commit b54fee7a77
2 changed files with 195 additions and 184 deletions

View File

@ -113,29 +113,30 @@ public class PatientInfoServiceImpl implements IPatientInfoService {
return patientInfoMapper.selectPatientInfoList(patientInfo); return patientInfoMapper.selectPatientInfoList(patientInfo);
} }
/** /**
* @description 患者管理患者档案列表 * @param patientInfo 患者信息查询传输对象
* @param patientInfo 患者信息查询传输对象 * @return 患者信息集合
* @return 患者信息集合 * @description 患者管理患者档案列表
* @Author haown * @Author haown
* @Date 2024-08-05 14:46 * @Date 2024-08-05 14:46
*/ */
@DataScope(agencyAlias = "p", userAlias = "p.attending_physician_id") @DataScope(agencyAlias = "p", userAlias = "p.attending_physician_id")
@Override public List<PatientInfoVo> getPatientList(PatientInfoDto patientInfo) { @Override
List<PatientInfoVo> patientInfoVoList = patientInfoMapper.getPatientList(patientInfo); public List<PatientInfoVo> getPatientList(PatientInfoDto patientInfo) {
return patientInfoVoList; List<PatientInfoVo> patientInfoVoList = patientInfoMapper.getPatientList(patientInfo);
} return patientInfoVoList;
}
/** /**
* 查询患者信息列表 * 查询患者信息列表
* *
* @param patientInfo 患者信息 * @param patientInfo 患者信息
* @return 患者信息 * @return 患者信息
*/ */
@Override @Override
public List<PatientInfo> selectAllPatientList(PatientInfoDto patientInfo) { public List<PatientInfo> selectAllPatientList(PatientInfoDto patientInfo) {
return patientInfoMapper.selectPatientInfoList(patientInfo); return patientInfoMapper.selectPatientInfoList(patientInfo);
} }
/** /**
* 新增患者信息 * 新增患者信息
@ -146,63 +147,63 @@ public class PatientInfoServiceImpl implements IPatientInfoService {
@Override @Override
@Transactional @Transactional
public PatientInfo insertPatientInfo(PatientInfo patientInfo) { public PatientInfo insertPatientInfo(PatientInfo patientInfo) {
if (StringUtils.isBlank(patientInfo.getCardNo())) { if (StringUtils.isBlank(patientInfo.getCardNo())) {
throw new ServiceException("请输入身份证号"); throw new ServiceException("请输入身份证号");
} }
// 根据身份证号+机构id判断用户信息是否存在 // 根据身份证号+机构id判断用户信息是否存在
PatientInfoDto patientQuery = new PatientInfoDto(); PatientInfoDto patientQuery = new PatientInfoDto();
patientQuery.setCardNo(patientInfo.getCardNo()); patientQuery.setCardNo(patientInfo.getCardNo());
patientQuery.setHospitalAgencyId(patientInfo.getHospitalAgencyId()); patientQuery.setHospitalAgencyId(patientInfo.getHospitalAgencyId());
List<PatientInfo> patientList = patientInfoMapper.selectPatientInfoList(patientQuery); List<PatientInfo> patientList = patientInfoMapper.selectPatientInfoList(patientQuery);
boolean exist = false; boolean exist = false;
if(CollectionUtils.isNotEmpty(patientList)) { if (CollectionUtils.isNotEmpty(patientList)) {
PatientInfo patientOld = patientList.get(0); PatientInfo patientOld = patientList.get(0);
patientInfo.setId(patientOld.getId()); patientInfo.setId(patientOld.getId());
exist = true; exist = true;
} else { } else {
patientInfo.setCreateTime(LocalDateTime.now()); patientInfo.setCreateTime(LocalDateTime.now());
patientInfo.setCreateBy(SecurityUtils.getLoginUser().getUser().getNickName()); patientInfo.setCreateBy(SecurityUtils.getLoginUser().getUser().getNickName());
} }
patientInfo.setDelFlag(0); patientInfo.setDelFlag(0);
// 根据身份证号计算性别出生日期 // 根据身份证号计算性别出生日期
if (patientInfo.getBirthDate() == null) { if (patientInfo.getBirthDate() == null) {
patientInfo.setBirthDate(BaseUtil.getBirthday(patientInfo.getCardNo())); patientInfo.setBirthDate(BaseUtil.getBirthday(patientInfo.getCardNo()));
} }
if (StringUtils.isBlank(patientInfo.getSex())) { if (StringUtils.isBlank(patientInfo.getSex())) {
patientInfo.setSex(BaseUtil.getGender(patientInfo.getCardNo())); patientInfo.setSex(BaseUtil.getGender(patientInfo.getCardNo()));
} }
// 先根据身份证号查询是否有该居民 // 先根据身份证号查询是否有该居民
ResidentInfo residentQuery = new ResidentInfo(); ResidentInfo residentQuery = new ResidentInfo();
residentQuery.setCardNo(patientInfo.getCardNo()); residentQuery.setCardNo(patientInfo.getCardNo());
List<ResidentInfo> residentList = residentInfoMapper.selectResidentInfoList(residentQuery); List<ResidentInfo> residentList = residentInfoMapper.selectResidentInfoList(residentQuery);
// 身份证号没查到居民通过手机号查询居民 // 身份证号没查到居民通过手机号查询居民
if (CollectionUtils.isEmpty(residentList) && StringUtils.isNotBlank(patientInfo.getPatientPhone())) { if (CollectionUtils.isEmpty(residentList) && StringUtils.isNotBlank(patientInfo.getPatientPhone())) {
residentQuery.setCardNo(null); residentQuery.setCardNo(null);
residentQuery.setPatientPhone(patientInfo.getPatientPhone()); residentQuery.setPatientPhone(patientInfo.getPatientPhone());
residentList = residentInfoMapper.selectResidentInfoList(residentQuery); residentList = residentInfoMapper.selectResidentInfoList(residentQuery);
} }
ResidentInfo residentInfo = new ResidentInfo(); ResidentInfo residentInfo = new ResidentInfo();
BeanUtils.copyBeanProp(residentInfo, patientInfo); BeanUtils.copyBeanProp(residentInfo, patientInfo);
if (CollectionUtils.isEmpty(residentList)) { if (CollectionUtils.isEmpty(residentList)) {
// 新增居民 // 新增居民
residentInfoMapper.insertResidentInfo(residentInfo); residentInfoMapper.insertResidentInfo(residentInfo);
patientInfo.setResidentId(residentInfo.getId()); patientInfo.setResidentId(residentInfo.getId());
} else { } else {
// 修改居民信息 // 修改居民信息
residentInfo.setId(residentList.get(0).getId()); residentInfo.setId(residentList.get(0).getId());
residentInfoMapper.updateResidentInfo(residentInfo); residentInfoMapper.updateResidentInfo(residentInfo);
patientInfo.setResidentId(residentList.get(0).getId()); patientInfo.setResidentId(residentList.get(0).getId());
} }
// 患者来源 // 患者来源
if (StringUtils.isBlank(patientInfo.getPatientSource())) { if (StringUtils.isBlank(patientInfo.getPatientSource())) {
patientInfo.setPatientSource(PatientSourceEnum.MANAGE_END.name()); patientInfo.setPatientSource(PatientSourceEnum.MANAGE_END.name());
} }
if (exist) { if (exist) {
patientInfoMapper.updatePatientInfoSelective(patientInfo); patientInfoMapper.updatePatientInfoSelective(patientInfo);
} else { } else {
patientInfoMapper.insertPatientInfo(patientInfo); patientInfoMapper.insertPatientInfo(patientInfo);
} }
return patientInfo; return patientInfo;
} }
/** /**
@ -213,56 +214,57 @@ public class PatientInfoServiceImpl implements IPatientInfoService {
*/ */
@Override @Override
public PatientInfo updatePatientInfo(PatientInfo patientInfo) { public PatientInfo updatePatientInfo(PatientInfo patientInfo) {
if (StringUtils.isBlank(patientInfo.getCardNo())) { if (StringUtils.isBlank(patientInfo.getCardNo())) {
throw new ServiceException("请输入身份证号"); throw new ServiceException("请输入身份证号");
} }
// 根据身份证号计算性别出生日期 // 根据身份证号计算性别出生日期
patientInfo.setBirthDate(BaseUtil.getBirthday(patientInfo.getCardNo())); patientInfo.setBirthDate(BaseUtil.getBirthday(patientInfo.getCardNo()));
patientInfo.setSex(BaseUtil.getGender(patientInfo.getCardNo())); patientInfo.setSex(BaseUtil.getGender(patientInfo.getCardNo()));
ResidentInfo residentInfo = new ResidentInfo(); ResidentInfo residentInfo = new ResidentInfo();
if (patientInfo.getResidentId() != null) { if (patientInfo.getResidentId() != null) {
residentInfo = residentInfoMapper.selectResidentInfoById(patientInfo.getResidentId()); residentInfo = residentInfoMapper.selectResidentInfoById(patientInfo.getResidentId());
BeanUtils.copyBeanProp(residentInfo, patientInfo); BeanUtils.copyBeanProp(residentInfo, patientInfo);
residentInfo.setId(patientInfo.getResidentId()); residentInfo.setId(patientInfo.getResidentId());
residentInfoMapper.updateResidentInfo(residentInfo); residentInfoMapper.updateResidentInfo(residentInfo);
} else { } else {
// 先根据身份证号查询是否有该居民 // 先根据身份证号查询是否有该居民
ResidentInfo residentQuery = new ResidentInfo(); ResidentInfo residentQuery = new ResidentInfo();
residentQuery.setCardNo(patientInfo.getCardNo()); residentQuery.setCardNo(patientInfo.getCardNo());
List<ResidentInfo> residentList = residentInfoMapper.selectResidentInfoList(residentQuery); List<ResidentInfo> residentList = residentInfoMapper.selectResidentInfoList(residentQuery);
// 身份证号没查到居民通过手机号查询居民 // 身份证号没查到居民通过手机号查询居民
if (CollectionUtils.isEmpty(residentList) && StringUtils.isNotBlank(patientInfo.getPatientPhone())) { if (CollectionUtils.isEmpty(residentList) && StringUtils.isNotBlank(patientInfo.getPatientPhone())) {
residentQuery.setCardNo(null); residentQuery.setCardNo(null);
residentQuery.setPatientPhone(patientInfo.getPatientPhone()); residentQuery.setPatientPhone(patientInfo.getPatientPhone());
residentList = residentInfoMapper.selectResidentInfoList(residentQuery); residentList = residentInfoMapper.selectResidentInfoList(residentQuery);
} }
if (CollectionUtils.isNotEmpty(residentList)) { if (CollectionUtils.isNotEmpty(residentList)) {
Long residentId = residentList.get(0).getId(); Long residentId = residentList.get(0).getId();
residentInfo = residentList.get(0); residentInfo = residentList.get(0);
BeanUtils.copyBeanProp(residentInfo, patientInfo); BeanUtils.copyBeanProp(residentInfo, patientInfo);
residentInfo.setId(residentId); residentInfo.setId(residentId);
residentInfoMapper.updateResidentInfo(residentInfo); residentInfoMapper.updateResidentInfo(residentInfo);
} else { } else {
BeanUtils.copyBeanProp(residentInfo, patientInfo); BeanUtils.copyBeanProp(residentInfo, patientInfo);
residentInfo.setId(null); residentInfo.setId(null);
residentInfoMapper.insertResidentInfo(residentInfo); residentInfoMapper.insertResidentInfo(residentInfo);
} }
patientInfo.setResidentId(residentInfo.getId()); patientInfo.setResidentId(residentInfo.getId());
} }
patientInfo.setUpdateBy(SecurityUtils.getLoginUser().getUser().getNickName()); patientInfo.setUpdateBy(SecurityUtils.getLoginUser().getUser().getNickName());
patientInfo.setUpdateTime(LocalDateTime.now()); patientInfo.setUpdateTime(LocalDateTime.now());
patientInfo.setDelFlag(0); patientInfo.setDelFlag(0);
patientInfoMapper.updatePatientInfoSelective(patientInfo); patientInfoMapper.updatePatientInfoSelective(patientInfo);
return patientInfo; return patientInfo;
} }
@Override public PatientInfo updateBaseInfo(PatientBaseInfoDto patientInfo) { @Override
PatientInfo patientInfo1 = patientInfoMapper.selectPatientInfoById(patientInfo.getId()); public PatientInfo updateBaseInfo(PatientBaseInfoDto patientInfo) {
BeanUtils.copyBeanProp(patientInfo1, patientInfo); PatientInfo patientInfo1 = patientInfoMapper.selectPatientInfoById(patientInfo.getId());
return updatePatientInfo(patientInfo1); BeanUtils.copyBeanProp(patientInfo1, patientInfo);
} return updatePatientInfo(patientInfo1);
}
/** /**
* 批量删除患者信息 * 批量删除患者信息
* *
* @param ids 需要删除的患者信息主键 * @param ids 需要删除的患者信息主键
@ -271,55 +273,57 @@ public class PatientInfoServiceImpl implements IPatientInfoService {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public int deletePatientInfoByIds(Long[] ids) { public int deletePatientInfoByIds(Long[] ids) {
int flag = 0; int flag = 0;
for (Long id : ids) { for (Long id : ids) {
PatientInfo patientInfo = patientInfoMapper.selectPatientInfoById(id); PatientInfo patientInfo = patientInfoMapper.selectPatientInfoById(id);
// 查询关联的就诊记录是否已签约 // 查询关联的就诊记录是否已签约
if (patientInfo.getSignPatientRecordId() != null && StringUtils.equals(SignRecordServiceStatusConstants.SERVICE_CENTER, patientInfo.getServiceStatus())) { if (patientInfo.getSignPatientRecordId() != null && StringUtils.equals(SignRecordServiceStatusConstants.SERVICE_CENTER, patientInfo.getServiceStatus())) {
SignPatientRecord signPatientRecord = signPatientRecordMapper.selectByPrimaryKey(patientInfo.getSignPatientRecordId()); SignPatientRecord signPatientRecord = signPatientRecordMapper.selectByPrimaryKey(patientInfo.getSignPatientRecordId());
if (ObjectUtils.isNotEmpty(signPatientRecord) && Objects.equals(patientInfo.getPatientVisitRecordId(), signPatientRecord.getPatientVisitRecordId()) && signPatientRecord.getDelFlag() == 0) { if (ObjectUtils.isNotEmpty(signPatientRecord) && Objects.equals(patientInfo.getPatientVisitRecordId(), signPatientRecord.getPatientVisitRecordId()) && signPatientRecord.getDelFlag() == 0) {
throw new ServiceException("该居民已签约不能删除该就诊记录!"); throw new ServiceException("该居民已签约不能删除该就诊记录!");
} }
} }
patientVisitRecordService.deletePatientVisitRecordById(patientInfo.getPatientVisitRecordId()); patientVisitRecordService.deletePatientVisitRecordById(patientInfo.getPatientVisitRecordId());
// 根据患者最新一条就诊记录修改患者状态 // 根据患者最新一条就诊记录修改患者状态
PatientVisitRecordDto patientVisitRecordDto = new PatientVisitRecordDto(); PatientVisitRecordDto patientVisitRecordDto = new PatientVisitRecordDto();
patientVisitRecordDto.setHospitalAgencyId(patientInfo.getHospitalAgencyId()); patientVisitRecordDto.setHospitalAgencyId(patientInfo.getHospitalAgencyId());
patientVisitRecordDto.setPatientId(id); patientVisitRecordDto.setPatientId(id);
PatientVisitRecord patientVisitRecord = patientVisitRecordService.getLastRecord(patientVisitRecordDto); PatientVisitRecord patientVisitRecord = patientVisitRecordService.getLastRecord(patientVisitRecordDto);
if (ObjectUtils.isEmpty(patientVisitRecord)) { if (ObjectUtils.isEmpty(patientVisitRecord)) {
setVisitInfoNull(patientInfo); setVisitInfoNull(patientInfo);
} else { } else {
BeanUtils.copyBeanProp(patientInfo, patientVisitRecord); BeanUtils.copyBeanProp(patientInfo, patientVisitRecord);
patientInfo.setId(id); patientInfo.setId(id);
patientInfo.setPatientVisitRecordId(patientVisitRecord.getId()); patientInfo.setPatientVisitRecordId(patientVisitRecord.getId());
// 设置patientType // 设置patientType
patientVisitRecordService.setPatientType(patientInfo, patientVisitRecord); patientVisitRecordService.setPatientType(patientInfo, patientVisitRecord);
} }
patientInfo.setPatientType(null); patientInfo.setPatientType(null);
flag += patientInfoMapper.updatePatientInfo(patientInfo); flag += patientInfoMapper.updatePatientInfo(patientInfo);
} }
return flag; return flag;
} }
/** /**
* 设置患者就诊信息为空 * 设置患者就诊信息为空
* @param patientInfo 患者信息 *
*/ * @param patientInfo 患者信息
private void setVisitInfoNull(PatientInfo patientInfo){ */
patientInfo.setVisitDate(null); private void setVisitInfoNull(PatientInfo patientInfo) {
patientInfo.setPatientType(null); patientInfo.setVisitDate(null);
patientInfo.setPatientVisitRecordId(null); patientInfo.setPatientType(null);
patientInfo.setVisitMethod(null); patientInfo.setPatientVisitRecordId(null);
patientInfo.setAdmissionTime(null); patientInfo.setVisitMethod(null);
patientInfo.setDischargeTime(null); patientInfo.setAdmissionTime(null);
patientInfo.setAttendingPhysicianId(null); patientInfo.setDischargeTime(null);
patientInfo.setAttendingPhysicianName(null); patientInfo.setAttendingPhysicianId(null);
patientInfo.setResponsibleNurse(null); patientInfo.setAttendingPhysicianName(null);
patientInfo.setMainDiagnosis(null); patientInfo.setResponsibleNurse(null);
patientInfo.setVisitSerialNumber(null); patientInfo.setMainDiagnosis(null);
patientInfo.setInHospitalNumber(null); patientInfo.setVisitSerialNumber(null);
} patientInfo.setInHospitalNumber(null);
}
/** /**
* 删除患者信息 * 删除患者信息
* *
@ -350,7 +354,7 @@ public class PatientInfoServiceImpl implements IPatientInfoService {
} }
//如果要导入的数据列表为空直接返回 //如果要导入的数据列表为空直接返回
if (CollectionUtils.isEmpty(list) || list.size() == 0) { if (CollectionUtils.isEmpty(list) || list.size() == 0) {
return AjaxResult.error("导入数据列表不能为空!" ); return AjaxResult.error("导入数据列表不能为空!");
} }
//如果存在 患者姓名或手机号或科室或就诊日期为空的情况直接返回 //如果存在 患者姓名或手机号或科室或就诊日期为空的情况直接返回
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()); 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());
@ -385,7 +389,7 @@ public class PatientInfoServiceImpl implements IPatientInfoService {
//组装数据 //组装数据
List<PatientInfoImport> patientInfoImportList = new ArrayList<>(); List<PatientInfoImport> patientInfoImportList = new ArrayList<>();
//要导入的居民信息列表 //要导入的居民信息列表
List<PatientInfoImport> patientInfoImportList_forResident = new ArrayList<>(); List<PatientInfoImport> patientInfoImportList_forResident = new ArrayList<>();
for (PatientInfoImport patientInfoImport : distinctCollect) { for (PatientInfoImport patientInfoImport : distinctCollect) {
//选择自动去除当日重复记录 //选择自动去除当日重复记录
// if (CollectionUtils.isNotEmpty(residentInfos)) { // if (CollectionUtils.isNotEmpty(residentInfos)) {
@ -485,9 +489,8 @@ public class PatientInfoServiceImpl implements IPatientInfoService {
//设置导入记录ID //设置导入记录ID
item.setPatientInfoImportId(item.getId()); item.setPatientInfoImportId(item.getId());
//居民信息去重 //居民信息去重
if(residentInfos.stream().filter(residentInfo -> residentInfo.getPatientName().equals(item.getPatientName()) if (residentInfos.stream().filter(residentInfo -> residentInfo.getPatientName().equals(item.getPatientName())
&& residentInfo.getPatientPhone().equals(item.getPatientPhone())).collect(Collectors.toSet()).size()==0) && residentInfo.getPatientPhone().equals(item.getPatientPhone())).collect(Collectors.toSet()).size() == 0) {
{
patientInfoImportList_forResident.add(item); patientInfoImportList_forResident.add(item);
} }
//如果已存在 //如果已存在
@ -498,21 +501,28 @@ public class PatientInfoServiceImpl implements IPatientInfoService {
} }
} }
); );
if(patientInfoImportList_forResident.size()>0) { if (patientInfoImportList_forResident.size() > 0) {
int residentCount = residentInfoMapper.insertResidentInfoList(patientInfoImportList_forResident); int residentCount = residentInfoMapper.insertResidentInfoList(patientInfoImportList_forResident);
if (residentCount <= 0) { if (residentCount <= 0) {
log.info("居民表新增失败!"); log.info("居民表新增失败!");
return AjaxResult.error("居民信息新增失败;"); return AjaxResult.error("居民信息新增失败;");
} }
//设置居民ID patientInfoImportList_forResident.forEach(item ->
patientInfoImportList.forEach(item -> item.setResidentId(item.getId())); {
patientInfoImportList.stream().filter(item2 -> item2.getPatientName().equals(item.getPatientName())
&& item2.getPatientPhone().equals(item.getPatientPhone())).findFirst().orElse(new PatientInfoImport())
.setResidentId(item.getId());
}
);
} }
//endregion //endregion
//设置为门诊患者 //设置为门诊患者
patientInfoImportList.forEach(item -> patientInfoImportList.forEach(item ->
{item.setPatientType(PatientTypeEnum.OUTPATIENT.getInfo()); {
item.setVisitMethod(VisitMethodConstants.OUTPATIENT_SERVICE);}); item.setPatientType(PatientTypeEnum.OUTPATIENT.getInfo());
item.setVisitMethod(VisitMethodConstants.OUTPATIENT_SERVICE);
});
//新增患者表 //新增患者表
int i = patientInfoMapper.insertPatientInfoList(patientInfoImportList); int i = patientInfoMapper.insertPatientInfoList(patientInfoImportList);
if (i <= 0) { if (i <= 0) {
@ -651,7 +661,8 @@ public class PatientInfoServiceImpl implements IPatientInfoService {
patientInfoImports.forEach(item -> item.setResidentId(item.getId())); patientInfoImports.forEach(item -> item.setResidentId(item.getId()));
//设置为门诊患者 //设置为门诊患者
patientInfoImports.forEach(item -> patientInfoImports.forEach(item ->
{item.setPatientType(PatientTypeEnum.OUTPATIENT.getInfo()); {
item.setPatientType(PatientTypeEnum.OUTPATIENT.getInfo());
item.setVisitMethod(VisitMethodConstants.OUTPATIENT_SERVICE); item.setVisitMethod(VisitMethodConstants.OUTPATIENT_SERVICE);
}); });

View File

@ -906,7 +906,7 @@
) values ) values
<foreach item="PatientInfoImport" index="index" collection="list" separator=","> <foreach item="PatientInfoImport" index="index" collection="list" separator=",">
( (
#{PatientInfoImport.id}, #{PatientInfoImport.residentId},
#{PatientInfoImport.patientInfoImportId}, #{PatientInfoImport.patientInfoImportId},
#{PatientInfoImport.visitDate}, #{PatientInfoImport.visitDate},
#{PatientInfoImport.inHospitalNumber}, #{PatientInfoImport.inHospitalNumber},