患者导入

This commit is contained in:
zhangheng 2024-12-02 13:50:51 +08:00
parent 6dbd0185f7
commit 637dd44f09
7 changed files with 57 additions and 44 deletions

View File

@ -117,6 +117,14 @@ public class PatientInfoImport extends BaseEntity {
@Excel(name = "流水号") @Excel(name = "流水号")
private String sn; private String sn;
@ApiModelProperty(value = "导入人员所属机构ID")
@Excel(name = "导入人员所属机构ID")
private Long hospitalAgencyId;
@ApiModelProperty(value = "所属医院名称")
@Excel(name = "所属医院名称")
private String hospitalAgencyName;
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) { if (this == o) {

View File

@ -101,7 +101,7 @@ public interface IPatientInfoService {
/** /**
* 未识别科室名称导入 * 未识别科室名称导入
* *
* @param patientInfoImportVO * @param patientInfoImportVO 未识别科室集合
* @return AjaxResult * @return AjaxResult
*/ */
AjaxResult secondaryUpload(PatientInfoImportVO patientInfoImportVO); AjaxResult secondaryUpload(PatientInfoImportVO patientInfoImportVO);

View File

@ -20,7 +20,6 @@ import com.xinelu.manage.domain.patientinfoimportmain.PatientInfoImportMain;
import com.xinelu.manage.domain.patientvisitrecord.PatientVisitRecord; import com.xinelu.manage.domain.patientvisitrecord.PatientVisitRecord;
import com.xinelu.manage.domain.residentinfo.ResidentInfo; import com.xinelu.manage.domain.residentinfo.ResidentInfo;
import com.xinelu.manage.domain.signpatientrecord.SignPatientRecord; import com.xinelu.manage.domain.signpatientrecord.SignPatientRecord;
import com.xinelu.manage.dto.agency.AgencyTreeDto;
import com.xinelu.manage.dto.patientinfo.PatientBaseInfoDto; import com.xinelu.manage.dto.patientinfo.PatientBaseInfoDto;
import com.xinelu.manage.dto.patientinfo.PatientInfoDto; import com.xinelu.manage.dto.patientinfo.PatientInfoDto;
import com.xinelu.manage.dto.patientvisitrecord.PatientVisitRecordDto; import com.xinelu.manage.dto.patientvisitrecord.PatientVisitRecordDto;
@ -34,7 +33,6 @@ import com.xinelu.manage.mapper.residentinfo.ResidentInfoMapper;
import com.xinelu.manage.mapper.signpatientrecord.SignPatientRecordMapper; import com.xinelu.manage.mapper.signpatientrecord.SignPatientRecordMapper;
import com.xinelu.manage.service.patientinfo.IPatientInfoService; import com.xinelu.manage.service.patientinfo.IPatientInfoService;
import com.xinelu.manage.service.patientvisitrecord.IPatientVisitRecordService; import com.xinelu.manage.service.patientvisitrecord.IPatientVisitRecordService;
import com.xinelu.manage.vo.agency.AgencyVO;
import com.xinelu.manage.vo.patientinfo.PatientInfoVo; import com.xinelu.manage.vo.patientinfo.PatientInfoVo;
import com.xinelu.manage.vo.patientinfoimport.DeptAliasVO; import com.xinelu.manage.vo.patientinfoimport.DeptAliasVO;
import com.xinelu.manage.vo.patientinfoimport.PatientInfoImportVO; import com.xinelu.manage.vo.patientinfoimport.PatientInfoImportVO;
@ -327,6 +325,12 @@ public class PatientInfoServiceImpl implements IPatientInfoService {
return patientInfoMapper.deletePatientInfoById(id); return patientInfoMapper.deletePatientInfoById(id);
} }
/**
* 患者导入
*
* @param list 患者信息结合
* @return AjaxResult
*/
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Override @Override
public AjaxResult patientUpload(List<PatientInfoImport> list, Integer records, String orgName) { public AjaxResult patientUpload(List<PatientInfoImport> list, Integer records, String orgName) {
@ -343,33 +347,30 @@ public class PatientInfoServiceImpl implements IPatientInfoService {
} }
//导入重复过滤 //导入重复过滤
List<PatientInfoImport> distinctCollect = list.stream().filter(Objects::nonNull).distinct().collect(Collectors.toList()); List<PatientInfoImport> distinctCollect = list.stream().filter(Objects::nonNull).distinct().collect(Collectors.toList());
LocalDate nowDate = LocalDate.now();
//与数据库重复 //与数据库重复
List<PatientInfo> patientInfos = new ArrayList<>(); List<PatientInfo> patientInfos = new ArrayList<>();
if (Objects.isNull(records) || records == 1) { if (Objects.isNull(records) || records == 1) {
LocalDate nowDate = LocalDate.now();
patientInfos = patientInfoMapper.selectPatientInfoByPatientName(list, nowDate); patientInfos = patientInfoMapper.selectPatientInfoByPatientName(list, nowDate);
} }
//sn //sn
String sn = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss")); String sn = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
//登录用户科室信息 //登录用户科室信息
SysUser sysUser = sysUserMapper.selectUserById(SecurityUtils.getUserId()); SysUser sysUser = sysUserMapper.selectUserById(SecurityUtils.getUserId());
AgencyTreeDto agencyTreeDto = new AgencyTreeDto(); Agency agency = agencyMapper.selectAgencyById(sysUser.getHospitalAgencyId());
agencyTreeDto.setAgencyAndChild("1"); if (Objects.isNull(agency) || StringUtils.isEmpty(agency.getNodeType())) {
agencyTreeDto.setId(sysUser.getHospitalAgencyId());
List<AgencyVO> agencyVOS = agencyMapper.selectAgencyVOList(agencyTreeDto);
Department department = new Department();
if (Objects.isNull(sysUser.getHospitalAgencyId())) {
return AjaxResult.error("该账号无所属医院信息,请先添加该账号所属的医院信息!"); return AjaxResult.error("该账号无所属医院信息,请先添加该账号所属的医院信息!");
} }
Department department = new Department();
department.setHospitalAgencyId(sysUser.getHospitalAgencyId()); department.setHospitalAgencyId(sysUser.getHospitalAgencyId());
List<Department> departmentList = departmentMapper.selectDepartmentNameCount(department); List<Department> departmentList = departmentMapper.selectDepartmentNameCount(department);
PatientInfoImportVO patientInfoImportVO = new PatientInfoImportVO(); PatientInfoImportVO patientInfoImportVO = new PatientInfoImportVO();
List<DeptAliasVO> deptAliasVOS = new ArrayList<>(); List<DeptAliasVO> deptAliasVOS = new ArrayList<>();
//组装数据 //组装数据
List<PatientInfoImport> patientInfoImportList = new ArrayList<>(); List<PatientInfoImport> patientInfoImportList = new ArrayList<>();
//选择自动去除当日重复记录
for (PatientInfoImport patientInfoImport : distinctCollect) { for (PatientInfoImport patientInfoImport : distinctCollect) {
if (CollectionUtils.isNotEmpty(patientInfos)) { //选择自动去除当日重复记录
if (CollectionUtils.isNotEmpty(patientInfos) && (Objects.isNull(records) || records == 1)) {
List<PatientInfo> collect1 = patientInfos.stream().filter(Objects::nonNull).filter(item -> patientInfoImport.getPatientName().equals(item.getPatientName()) && patientInfoImport.getPatientPhone().equals(item.getPatientPhone())).collect(Collectors.toList()); 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)) { if (CollectionUtils.isNotEmpty(collect1)) {
continue; continue;
@ -379,6 +380,8 @@ public class PatientInfoServiceImpl implements IPatientInfoService {
patientInfoImport.setSn(sn); patientInfoImport.setSn(sn);
patientInfoImport.setCreateBy(SecurityUtils.getUsername()); patientInfoImport.setCreateBy(SecurityUtils.getUsername());
patientInfoImport.setCreateTime(LocalDateTime.now()); patientInfoImport.setCreateTime(LocalDateTime.now());
patientInfoImport.setHospitalAgencyId(agency.getId());
patientInfoImport.setHospitalAgencyName(agency.getAgencyName());
//医院有科室且名称一致塞值不一致取数据返回医院没科室科室数据返回 //医院有科室且名称一致塞值不一致取数据返回医院没科室科室数据返回
if (CollectionUtils.isNotEmpty(departmentList)) { if (CollectionUtils.isNotEmpty(departmentList)) {
Department equalsDepartment = departmentList.stream().filter(Objects::nonNull) Department equalsDepartment = departmentList.stream().filter(Objects::nonNull)
@ -418,11 +421,9 @@ public class PatientInfoServiceImpl implements IPatientInfoService {
patientInfoImportMain.setCreateBy(SecurityUtils.getUsername()); patientInfoImportMain.setCreateBy(SecurityUtils.getUsername());
patientInfoImportMain.setCreateTime(LocalDateTime.now()); patientInfoImportMain.setCreateTime(LocalDateTime.now());
patientInfoImportMain.setSn(sn); patientInfoImportMain.setSn(sn);
patientInfoImportMain.setHospitalAgencyId(department.getHospitalAgencyId()); patientInfoImportMain.setHospitalAgencyId(agency.getId());
patientInfoImportMain.setFileName(orgName); patientInfoImportMain.setFileName(orgName);
if (CollectionUtils.isNotEmpty(departmentList)) { patientInfoImportMain.setHospitalAgencyName(agency.getAgencyName());
patientInfoImportMain.setHospitalAgencyName(departmentList.get(0).getHospitalAgencyName());
}
patientInfoImportMainMapper.insertPatientInfoImportMain(patientInfoImportMain); patientInfoImportMainMapper.insertPatientInfoImportMain(patientInfoImportMain);
//科室名称全符合新增患者表否则返回数据 //科室名称全符合新增患者表否则返回数据
if (CollectionUtils.isNotEmpty(deptAliasVOS)) { if (CollectionUtils.isNotEmpty(deptAliasVOS)) {
@ -450,8 +451,8 @@ public class PatientInfoServiceImpl implements IPatientInfoService {
patientVisitRecord.setResidentId(residentId.getId()); patientVisitRecord.setResidentId(residentId.getId());
BeanUtils.copyProperties(patientInfoImport, patientVisitRecord); BeanUtils.copyProperties(patientInfoImport, patientVisitRecord);
patientVisitRecord.setDelFlag(0); patientVisitRecord.setDelFlag(0);
patientVisitRecord.setHospitalAgencyId(departmentList.get(0).getHospitalAgencyId()); patientVisitRecord.setHospitalAgencyId(agency.getId());
patientVisitRecord.setHospitalAgencyName(departmentList.get(0).getHospitalAgencyName()); patientVisitRecord.setHospitalAgencyName(agency.getAgencyName());
patientVisitRecord.setCreateBy(SecurityUtils.getUsername()); patientVisitRecord.setCreateBy(SecurityUtils.getUsername());
patientVisitRecord.setCreateTime(LocalDateTime.now()); patientVisitRecord.setCreateTime(LocalDateTime.now());
patientVisitRecords.add(patientVisitRecord); patientVisitRecords.add(patientVisitRecord);
@ -464,12 +465,30 @@ public class PatientInfoServiceImpl implements IPatientInfoService {
return AjaxResult.success(); return AjaxResult.success();
} }
/**
* 未识别科室名称导入
*
* @param patientInfoImportVO 未识别科室集合
* @return AjaxResult
*/
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Override @Override
public AjaxResult secondaryUpload(PatientInfoImportVO patientInfoImportVO) { public AjaxResult secondaryUpload(PatientInfoImportVO patientInfoImportVO) {
if (Objects.isNull(patientInfoImportVO) || CollectionUtils.isEmpty(patientInfoImportVO.getDeptAliasVOS()) || StringUtils.isEmpty(patientInfoImportVO.getSn())) { if (Objects.isNull(patientInfoImportVO) || CollectionUtils.isEmpty(patientInfoImportVO.getDeptAliasVOS()) || StringUtils.isEmpty(patientInfoImportVO.getSn())) {
return AjaxResult.success(); return AjaxResult.success();
} }
//科室医院
SysUser sysUser = sysUserMapper.selectUserById(SecurityUtils.getUserId());
Agency agency = agencyMapper.selectAgencyById(sysUser.getHospitalAgencyId());
if (Objects.isNull(agency)) {
return AjaxResult.error("该账号无所属医院信息,请先添加该账号所属的医院信息!");
}
Department department = new Department();
department.setHospitalAgencyId(sysUser.getHospitalAgencyId());
List<Department> departmentList = departmentMapper.selectDepartmentNameCount(department);
if (CollectionUtils.isEmpty(departmentList)) {
return AjaxResult.error("该账号所属医院无下级科室,请先维护所属医院的下级科室信息!");
}
//根据sn查询数据 //根据sn查询数据
List<PatientInfoImport> patientInfoImports = patientInfoImportMapper.selectPatientInfoImportBySn(patientInfoImportVO.getSn()); List<PatientInfoImport> patientInfoImports = patientInfoImportMapper.selectPatientInfoImportBySn(patientInfoImportVO.getSn());
for (PatientInfoImport patientInfoImport : patientInfoImports) { for (PatientInfoImport patientInfoImport : patientInfoImports) {
@ -479,17 +498,6 @@ public class PatientInfoServiceImpl implements IPatientInfoService {
patientInfoImport.setDepartmentName(deptAliasVO.getDepartmentName()); 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<Department> departmentList = departmentMapper.selectDepartmentNameCount(department);
if (CollectionUtils.isEmpty(departmentList)) {
return AjaxResult.error("该账号所属医院无下级科室,请先维护所属医院的下级科室信息!");
}
//科室组装别名 //科室组装别名
List<Department> departments = new ArrayList<>(); List<Department> departments = new ArrayList<>();
for (Department department1 : departmentList) { for (Department department1 : departmentList) {
@ -537,8 +545,8 @@ public class PatientInfoServiceImpl implements IPatientInfoService {
patientVisitRecord.setResidentId(residentId.getId()); patientVisitRecord.setResidentId(residentId.getId());
BeanUtils.copyProperties(patientInfoImport, patientVisitRecord); BeanUtils.copyProperties(patientInfoImport, patientVisitRecord);
patientVisitRecord.setDelFlag(0); patientVisitRecord.setDelFlag(0);
patientVisitRecord.setHospitalAgencyId(department.getHospitalAgencyId()); patientVisitRecord.setHospitalAgencyId(agency.getId());
patientVisitRecord.setHospitalAgencyName(department.getHospitalAgencyName()); patientVisitRecord.setHospitalAgencyName(agency.getAgencyName());
patientVisitRecord.setCreateBy(SecurityUtils.getUsername()); patientVisitRecord.setCreateBy(SecurityUtils.getUsername());
patientVisitRecord.setCreateTime(LocalDateTime.now()); patientVisitRecord.setCreateTime(LocalDateTime.now());
patientVisitRecords.add(patientVisitRecord); patientVisitRecords.add(patientVisitRecord);

View File

@ -514,15 +514,4 @@
</if> </if>
</where> </where>
</select> </select>
<select id="selectAgencyHigherLevelList" resultType="com.xinelu.manage.domain.agency.Agency">
select higher.id higherId,
higher.agency_name higherAgencyName,
this.id thisId,
this.agency_name thisAgencyName
from agency higher,
agency this
WHERE this.parent_id = higher.id
AND this.id = #{id}
</select>
</mapper> </mapper>

View File

@ -887,6 +887,8 @@
department_name, department_name,
sn, sn,
del_flag, del_flag,
hospital_agency_id,
hospital_agency_name,
create_time, create_time,
create_by create_by
) values ) values
@ -904,6 +906,8 @@
#{PatientInfoImport.departmentName}, #{PatientInfoImport.departmentName},
#{PatientInfoImport.sn}, #{PatientInfoImport.sn},
0, 0,
#{PatientInfoImport.hospitalAgencyId},
#{PatientInfoImport.hospitalAgencyName},
#{PatientInfoImport.createTime}, #{PatientInfoImport.createTime},
#{PatientInfoImport.createBy} #{PatientInfoImport.createBy}
) )

View File

@ -237,7 +237,9 @@
department_name, department_name,
sn, sn,
create_time, create_time,
create_by create_by,
hospital_agency_id,
hospital_agency_name
) values ) values
<foreach item="PatientInfoImport" index="index" collection="list" separator=","> <foreach item="PatientInfoImport" index="index" collection="list" separator=",">
( (
@ -254,7 +256,9 @@
#{PatientInfoImport.departmentName}, #{PatientInfoImport.departmentName},
#{PatientInfoImport.sn}, #{PatientInfoImport.sn},
#{PatientInfoImport.createTime}, #{PatientInfoImport.createTime},
#{PatientInfoImport.createBy} #{PatientInfoImport.createBy},
#{PatientInfoImport.hospitalAgencyId},
#{PatientInfoImport.hospitalAgencyName}
) )
</foreach> </foreach>
</insert> </insert>