| | |
| | | package com.smartor.service.impl; |
| | | |
| | | import java.io.FileOutputStream; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.concurrent.ExecutorService; |
| | | import java.util.concurrent.Executors; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.core.redis.RedisCache; |
| | | import com.ruoyi.common.exception.base.BaseException; |
| | |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.smartor.domain.*; |
| | | import com.smartor.mapper.BaseTagMapper; |
| | | import com.smartor.mapper.PatArchiveMapper; |
| | | import com.smartor.mapper.PatArchivetagMapper; |
| | | import com.smartor.service.IPatArchiveService; |
| | | import com.smartor.service.IPatMedInhospService; |
| | | import com.smartor.service.IPatMedOuthospService; |
| | | import com.smartor.service.IPatMedPhysicalService; |
| | |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.apache.poi.hssf.usermodel.HSSFDateUtil; |
| | | import org.apache.poi.ss.usermodel.*; |
| | | import org.apache.poi.ss.usermodel.DataFormatter; |
| | | import org.apache.poi.ss.usermodel.Row; |
| | | import org.apache.poi.ss.usermodel.Sheet; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import com.smartor.mapper.PatArchiveMapper; |
| | | import com.smartor.service.IPatArchiveService; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.FileOutputStream; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.concurrent.ExecutorService; |
| | | import java.util.concurrent.Executors; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 患者档案Service业务层处理 |
| | |
| | | @Override |
| | | public Integer insertPatArchive(PatArchive patArchive) { |
| | | patArchive.setCreateTime(DateUtils.getNowDate()); |
| | | List<PatArchive> patArchives = new ArrayList<>(); |
| | | patArchives.add(patArchive); |
| | | patArchiveMapper.insertPatArchive(patArchives); |
| | | if (CollectionUtils.isNotEmpty(patArchives)) { |
| | | patArchives.get(0).getId(); |
| | | log.info("患者id为: {}", patArchives.get(0).getId()); |
| | | return patArchives.get(0).getId().intValue(); |
| | | patArchiveMapper.insertPatArchiveSingle(patArchive); |
| | | return patArchive.getId().intValue(); |
| | | } |
| | | |
| | | @Override |
| | | public Boolean update(PatArchive patArchive) { |
| | | int i = patArchiveMapper.updatePatArchive(patArchive); |
| | | if (i != 1) { |
| | | return false; |
| | | } |
| | | return null; |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | |
| | | public Boolean saveOrUpdatePatInfo(PatArchiveVO patArchiveVO) { |
| | | //通过isoperation来判断是否新增 |
| | | PatArchive patArchive = DtoConversionUtils.sourceToTarget(patArchiveVO, PatArchive.class); |
| | | if (patArchiveVO.getIsoperation() != null && patArchiveVO.getIsoperation() == 1 || patArchiveVO.getPatid() == null) { |
| | | if (patArchiveVO.getIsoperation() != null && patArchiveVO.getIsoperation() == 1 || patArchiveVO.getId() == null) { |
| | | //新增 |
| | | List<PatArchive> patArchives = new ArrayList<>(); |
| | | patArchive.setUpdateTime(DateUtils.getNowDate()); |
| | | patArchives.add(patArchive); |
| | | patArchiveMapper.insertPatArchive(patArchives); |
| | | } else if (patArchiveVO.getIsoperation() != null && patArchiveVO.getIsoperation() == 2 || patArchiveVO.getPatid() != null) { |
| | | } else if (patArchiveVO.getIsoperation() != null && patArchiveVO.getIsoperation() == 2 || patArchiveVO.getId() != null) { |
| | | //修改 |
| | | patArchiveVO.setIsoperation(2); |
| | | patArchiveMapper.updatePatArchive(patArchive); |
| | |
| | | public int deletePatArchiveByPatid(Long patid) { |
| | | return patArchiveMapper.deletePatArchiveByPatid(patid); |
| | | } |
| | | |
| | | /** |
| | | * 获取患者信息 |
| | | * |
| | | * @param patArchiveReq |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<PatArchiveOthreInfo> getPatientInfo(PatArchiveReq patArchiveReq) { |
| | | if (CollectionUtils.isEmpty(patArchiveReq.getLeavehospitaldistrictcodes()) || patArchiveReq.getLeavehospitaldistrictcodes().size() == 0) { |
| | | patArchiveReq.setLeavehospitaldistrictcodes(null); |
| | | } |
| | | if (CollectionUtils.isEmpty(patArchiveReq.getLeaveldeptcodes()) || patArchiveReq.getLeaveldeptcodes().size() == 0) { |
| | | patArchiveReq.setLeaveldeptcodes(null); |
| | | } |
| | | |
| | | List<PatArchiveOthreInfo> patArchiveList = new ArrayList<>(); |
| | | if (patArchiveReq.getAllhosp() != null && patArchiveReq.getAllhosp() == 1) { |
| | | // 查看住院 1 查看门诊 2 查看体检 3 |
| | | List<PatArchiveOthreInfo> patArchives1 = patArchiveMapper.selectPatArchiveInfoByInhosp(patArchiveReq); |
| | | if (CollectionUtils.isNotEmpty(patArchives1)) { |
| | | patArchiveList.addAll(patArchives1); |
| | | } |
| | | } else if (patArchiveReq.getAllhosp() != null && patArchiveReq.getAllhosp() == 2) { |
| | | // 查看住院 1 查看门诊 2 查看体检 3 |
| | | List<PatArchiveOthreInfo> patArchives2 = patArchiveMapper.selectPatArchiveInfoByOuthosp(patArchiveReq); |
| | | if (CollectionUtils.isNotEmpty(patArchives2)) { |
| | | patArchiveList.addAll(patArchives2); |
| | | } |
| | | } else if (patArchiveReq.getAllhosp() != null && patArchiveReq.getAllhosp() == 3) { |
| | | // 查看住院 1 查看门诊 2 查看体检 3 |
| | | List<PatArchiveOthreInfo> patArchives3 = patArchiveMapper.selectPatArchiveInfoByPhysical(patArchiveReq); |
| | | if (CollectionUtils.isNotEmpty(patArchives3)) { |
| | | patArchiveList.addAll(patArchives3); |
| | | } |
| | | } |
| | | |
| | | return patArchiveList; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | @Transactional |
| | |
| | | |
| | | //根据条件获取患者信息 |
| | | // List<PatArchive> patArchiveList = patArchiveMapper.patInfoByContion(patArchive); |
| | | List<PatArchive> patArchiveList = new ArrayList<>(); |
| | | List<PatArchiveOthreInfo> patArchiveList = new ArrayList<>(); |
| | | |
| | | if (patArchive.getEndtime() != null) { |
| | | //出院时间只有住院才有 |
| | |
| | | } |
| | | |
| | | if (patArchive.getAllhosp() != null && patArchive.getAllhosp() == 0) { |
| | | List<PatArchive> patArchives0 = patArchiveMapper.selectPatArchiveInfoByAllhosp(patArchive); |
| | | List<PatArchiveOthreInfo> patArchives0 = patArchiveMapper.selectPatArchiveInfoByAllhosp(patArchive); |
| | | if (CollectionUtils.isNotEmpty(patArchives0)) { |
| | | patArchiveList.addAll(patArchives0); |
| | | } |
| | | } else if (patArchive.getAllhosp() != null && patArchive.getAllhosp() == 1) { |
| | | List<PatArchive> patArchives1 = patArchiveMapper.selectPatArchiveInfoByInhosp(patArchive); |
| | | List<PatArchiveOthreInfo> patArchives1 = patArchiveMapper.selectPatArchiveInfoByInhosp(patArchive); |
| | | if (CollectionUtils.isNotEmpty(patArchives1)) { |
| | | patArchiveList.addAll(patArchives1); |
| | | } |
| | | } else if (patArchive.getAllhosp() != null && patArchive.getAllhosp() == 2) { |
| | | List<PatArchive> patArchives2 = patArchiveMapper.selectPatArchiveInfoByOuthosp(patArchive); |
| | | List<PatArchiveOthreInfo> patArchives2 = patArchiveMapper.selectPatArchiveInfoByOuthosp(patArchive); |
| | | if (CollectionUtils.isNotEmpty(patArchives2)) { |
| | | patArchiveList.addAll(patArchives2); |
| | | } |
| | | } else if (patArchive.getAllhosp() != null && patArchive.getAllhosp() == 3) { |
| | | List<PatArchive> patArchives3 = patArchiveMapper.selectPatArchiveInfoByPhysical(patArchive); |
| | | List<PatArchiveOthreInfo> patArchives3 = patArchiveMapper.selectPatArchiveInfoByPhysical(patArchive); |
| | | if (CollectionUtils.isNotEmpty(patArchives3)) { |
| | | patArchiveList.addAll(patArchives3); |
| | | } |
| | | } |
| | | |
| | | |
| | | //根据患者ID进行分组 |
| | | Map<Long, List<PatArchive>> listMap = patArchiveList.stream().collect(Collectors.groupingBy(PatArchive::getId)); |
| | | Map<Long, List<PatArchiveOthreInfo>> listMap = patArchiveList.stream().collect(Collectors.groupingBy(PatArchiveOthreInfo::getId)); |
| | | |
| | | //对数据进行封装 |
| | | for (List<PatArchive> list : listMap.values()) { |
| | | for (List<PatArchiveOthreInfo> list : listMap.values()) { |
| | | PatArchive patArchive1 = new PatArchive(); |
| | | Set<PatArchivetag> stringList = new HashSet<>(); |
| | | for (int i = 0; i < list.size(); i++) { |