| | |
| | | package com.smartor.service.impl; |
| | | |
| | | import java.io.FileNotFoundException; |
| | | import java.io.FileOutputStream; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | 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.DateUtils; |
| | | import com.ruoyi.common.utils.DtoConversionUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.smartor.domain.BaseTag; |
| | | import com.smartor.domain.PatArchivetag; |
| | | import com.smartor.domain.PatUpInfoVO; |
| | | import com.smartor.domain.*; |
| | | import com.smartor.mapper.BaseTagMapper; |
| | | import com.smartor.mapper.PatArchivetagMapper; |
| | | import com.smartor.service.IPatMedInhospService; |
| | | import com.smartor.service.IPatMedOuthospService; |
| | | import com.smartor.service.IPatMedPhysicalService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | 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.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import com.smartor.mapper.PatArchiveMapper; |
| | | import com.smartor.domain.PatArchive; |
| | | import com.smartor.service.IPatArchiveService; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | |
| | | * @author smartor |
| | | * @date 2023-03-04 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class PatArchiveServiceImpl implements IPatArchiveService { |
| | | @Autowired |
| | |
| | | |
| | | @Autowired |
| | | private PatArchivetagMapper patArchivetagMapper; |
| | | |
| | | @Autowired |
| | | private IPatMedInhospService patMedInhospService; |
| | | |
| | | @Autowired |
| | | private IPatMedOuthospService patMedOuthospService; |
| | | |
| | | @Autowired |
| | | private IPatMedPhysicalService patMedPhysicalService; |
| | | |
| | | @Autowired |
| | | private RedisCache redisCache; |
| | | |
| | | |
| | | /** |
| | |
| | | return patArchiveMapper.selectPatArchiveList(patArchive); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 新增患者档案 |
| | | * |
| | |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int insertPatArchive(PatArchive patArchive) { |
| | | public Integer insertPatArchive(PatArchive patArchive) { |
| | | patArchive.setCreateTime(DateUtils.getNowDate()); |
| | | return patArchiveMapper.insertPatArchive(patArchive); |
| | | 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(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 修改患者档案 |
| | | * 新增或修改患者档信息 |
| | | * |
| | | * @param patArchive 患者档案 |
| | | * @param patArchiveVO 新增或修改患者档信息 |
| | | * @return 结果 |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public int updatePatArchive(PatArchive patArchive) { |
| | | patArchive.setUpdateTime(DateUtils.getNowDate()); |
| | | return patArchiveMapper.updatePatArchive(patArchive); |
| | | public Boolean saveOrUpdatePatInfo(PatArchiveVO patArchiveVO) { |
| | | //通过isoperation来判断是否新增 |
| | | PatArchive patArchive = DtoConversionUtils.sourceToTarget(patArchiveVO, PatArchive.class); |
| | | if (patArchiveVO.getIsoperation() != null && patArchiveVO.getIsoperation() == 1 || patArchiveVO.getPatid() == 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) { |
| | | //修改 |
| | | patArchiveVO.setIsoperation(2); |
| | | patArchiveMapper.updatePatArchive(patArchive); |
| | | } |
| | | |
| | | if (CollectionUtils.isNotEmpty(patArchiveVO.getTagList())) { |
| | | //处理标签(新增、删除) |
| | | for (PatArchivetag patArchivetag : patArchiveVO.getTagList()) { |
| | | if (patArchivetag.getIsoperation() != null && patArchivetag.getIsoperation() == 1 || patArchivetag.getIsoperation() == null && patArchiveVO.getIsoperation() == 1) { |
| | | //新增 |
| | | patArchivetag.setUpdateBy(null); |
| | | patArchivetag.setCreateTime(new Date()); |
| | | patArchivetag.setPatid(patArchive.getId()); |
| | | patArchivetagMapper.insertPatArchivetag(patArchivetag); |
| | | } else if (patArchivetag.getIsoperation() != null && patArchivetag.getIsoperation() == 3 || patArchivetag.getIsoperation() == null && patArchiveVO.getIsoperation() == 3) { |
| | | patArchivetag.setDelFlag("1"); |
| | | //删除 |
| | | log.info("标签的id为:{}", patArchivetag.getTagid()); |
| | | patArchivetagMapper.deletePatArchivetagById(patArchivetag); |
| | | } |
| | | } |
| | | |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | @Override |
| | | @Transactional |
| | | public PatUpInfoVO importFilehandle(String username, MultipartFile file) { |
| | | public PatUpInfoVO importFilehandle(SysUser user, String tags, MultipartFile file) { |
| | | System.out.println("start : " + System.currentTimeMillis() / 1000); |
| | | PatUpInfoVO patUpInfoVO = new PatUpInfoVO(); |
| | | Integer successNum = 0; |
| | | Integer failNum = 0; |
| | | //需要处理的总行数 |
| | | int lastRowNum = 0; |
| | | |
| | | List<PatArchive> errorpatArchiveList = new ArrayList<>(); |
| | | final List<PatArchive> errorpatArchiveList = new ArrayList<>(); |
| | | //创建线程池 |
| | | ExecutorService pool = Executors.newFixedThreadPool(10); |
| | | try { |
| | | Workbook workbook = new XSSFWorkbook(file.getInputStream()); |
| | | Sheet sheet = workbook.getSheetAt(0); |
| | | |
| | | for (int i = sheet.getFirstRowNum() + 1; i < sheet.getLastRowNum(); i++) { |
| | | Row row = sheet.getRow(i); |
| | | //如果行为空,进行下一次循环 |
| | | if (ObjectUtils.isEmpty(row)) { |
| | | continue; |
| | | } |
| | | PatArchive patArchive = new PatArchive(); |
| | | if (ObjectUtils.isEmpty(row.getCell(3)) || StringUtils.isEmpty(row.getCell(3).toString())) { |
| | | addRemark("身份证号为空", patArchive); |
| | | } else { |
| | | patArchive.setIccardno(row.getCell(3).toString()); |
| | | //根据身份证,先去患者管理表里看看有没有这个人,如果有这个人,也不需要插入患者表 |
| | | List<PatArchive> patArchiveList1 = patArchiveMapper.selectPatArchiveList(patArchive); |
| | | if (patArchiveList1.size() > 0) { |
| | | patArchive.setRemark("该患者已存在"); |
| | | //获取文件里的总行数 |
| | | lastRowNum = sheet.getLastRowNum(); |
| | | //将文件里的数据分成10份 |
| | | int partsize = lastRowNum / 10; |
| | | for (int i = 0; i < 10; i++) { |
| | | int start = i * partsize + 1; |
| | | int end = (i + 1) * partsize; |
| | | |
| | | pool.execute(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | for (int j = start; j <= end; j++) { |
| | | List<PatArchive> patArchives = new ArrayList<>(); |
| | | String name = Thread.currentThread().getName(); |
| | | Row row = sheet.getRow(j); |
| | | //如果行为空,进行下一次循环 |
| | | if (ObjectUtils.isEmpty(row)) { |
| | | continue; |
| | | } |
| | | PatArchive patArchive = new PatArchive(); |
| | | if (ObjectUtils.isEmpty(row.getCell(6)) || StringUtils.isEmpty(row.getCell(6).toString())) { |
| | | addRemark("证件号码为空", patArchive); |
| | | } else { |
| | | patArchive.setIdcardno(row.getCell(6).toString()); |
| | | //根据身份证,先去患者管理表里看看有没有这个人,如果有这个人,也不需要插入患者表 |
| | | // (这一块查询会影响整体的速度,需要优化) |
| | | List<PatArchive> patArchiveList1 = patArchiveMapper.selectPatArchiveList(patArchive); |
| | | if (patArchiveList1.size() > 0) { |
| | | patArchive.setRemark("该患者已存在"); |
| | | } |
| | | } |
| | | |
| | | //判断姓名是否为空 |
| | | if (Objects.isNull(row.getCell(0)) || StringUtils.isEmpty(row.getCell(0).toString())) { |
| | | addRemark("姓名为空", patArchive); |
| | | } else { |
| | | patArchive.setName(row.getCell(0).toString()); |
| | | } |
| | | |
| | | //判断性别是否为空 |
| | | if (ObjectUtils.isEmpty(row.getCell(1)) || StringUtils.isEmpty(row.getCell(1).toString())) { |
| | | addRemark("性别为空", patArchive); |
| | | } else { |
| | | patArchive.setSex(row.getCell(1).toString().equals("男") ? 1L : 2L); |
| | | } |
| | | |
| | | //判断证件类型是否为空 |
| | | if (ObjectUtils.isEmpty(row.getCell(2)) || StringUtils.isEmpty(row.getCell(2).toString())) { |
| | | addRemark("证件类型为空", patArchive); |
| | | } else { |
| | | patArchive.setIdcardtype(row.getCell(2).toString()); |
| | | } |
| | | |
| | | //判断籍贯是否为空 |
| | | if (ObjectUtils.isEmpty(row.getCell(3)) || StringUtils.isEmpty(row.getCell(3).toString())) { |
| | | patArchive.setNativePlace(null); |
| | | } else { |
| | | patArchive.setNativePlace(row.getCell(3).toString()); |
| | | } |
| | | |
| | | //判断居住地是否为空 |
| | | if (ObjectUtils.isEmpty(row.getCell(4)) || StringUtils.isEmpty(row.getCell(4).toString())) { |
| | | patArchive.setPlaceOfResidence(null); |
| | | } else { |
| | | patArchive.setPlaceOfResidence(row.getCell(4).toString()); |
| | | } |
| | | |
| | | //判断居住地是否为空 |
| | | if (ObjectUtils.isEmpty(row.getCell(5)) || StringUtils.isEmpty(row.getCell(5).toString())) { |
| | | patArchive.setBirthplace(null); |
| | | } else { |
| | | patArchive.setBirthplace(row.getCell(5).toString()); |
| | | } |
| | | |
| | | //判断出生日期是否为空 |
| | | if (ObjectUtils.isEmpty(row.getCell(7)) || StringUtils.isEmpty(row.getCell(7).toString())) { |
| | | // addRemark("出生日期为空", patArchive); |
| | | patArchive.setBirthdate(null); |
| | | } else { |
| | | //格式转换,转成日期 |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); |
| | | Date javaDate = new Date(); |
| | | if (row.getCell(7).getCellType().toString().equals("NUMERIC")) { |
| | | javaDate = HSSFDateUtil.getJavaDate(row.getCell(7).getNumericCellValue()); |
| | | } else { |
| | | try { |
| | | javaDate = dateFormat.parse(row.getCell(7).toString()); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | dateFormat.format(javaDate); |
| | | patArchive.setBirthdate(javaDate); |
| | | } |
| | | |
| | | //判断年龄是否为空 |
| | | if (ObjectUtils.isEmpty(row.getCell(8)) || StringUtils.isEmpty(row.getCell(8).toString())) { |
| | | patArchive.setAge(null); |
| | | } else { |
| | | patArchive.setAge(Long.valueOf(row.getCell(8).toString())); |
| | | } |
| | | |
| | | //判断本人联系是否为空,和长度是否正确 |
| | | if (ObjectUtils.isEmpty(row.getCell(12)) || StringUtils.isEmpty(row.getCell(12).toString())) { |
| | | addRemark("本人联系电话为空", patArchive); |
| | | } else { |
| | | //格式转换,转成文本 |
| | | if (row.getCell(12).getCellType().toString().equals("NUMERIC")) { |
| | | String cellData = String.valueOf((long) row.getCell(12).getNumericCellValue()); |
| | | patArchive.setTelcode(cellData); |
| | | } else { |
| | | DataFormatter dataFormatter = new DataFormatter(); |
| | | String cellValue = dataFormatter.formatCellValue(row.getCell(12)); |
| | | patArchive.setTelcode(cellValue); |
| | | } |
| | | } |
| | | |
| | | //判断亲属联系方式是否为空,长度是否正确 |
| | | if (ObjectUtils.isEmpty(row.getCell(13)) || StringUtils.isEmpty(row.getCell(13).toString())) { |
| | | // addRemark("亲属联系方式为空", patArchive); |
| | | patArchive.setRelativetelcode(null); |
| | | } else { |
| | | //格式转换,转成文本 |
| | | if (row.getCell(13).getCellType().toString().equals("NUMERIC")) { |
| | | String cellData = String.valueOf((long) row.getCell(13).getNumericCellValue()); |
| | | patArchive.setRelativetelcode(cellData); |
| | | } else { |
| | | DataFormatter dataFormatter = new DataFormatter(); |
| | | String cellValue = dataFormatter.formatCellValue(row.getCell(13)); |
| | | patArchive.setRelativetelcode(cellValue); |
| | | } |
| | | } |
| | | //判断民族是否为空 |
| | | if (ObjectUtils.isEmpty(row.getCell(14)) || StringUtils.isEmpty(row.getCell(14).toString())) { |
| | | patArchive.setNation(null); |
| | | } else { |
| | | patArchive.setNation(row.getCell(14).toString()); |
| | | } |
| | | |
| | | //患都标签是否为空 |
| | | if (ObjectUtils.isEmpty(row.getCell(17)) || StringUtils.isEmpty(row.getCell(17).toString())) { |
| | | patArchive.setTag(tags); |
| | | } else { |
| | | if (StringUtils.isNotEmpty(tags)) { |
| | | patArchive.setTag(row.getCell(17).toString() + "," + tags); |
| | | } else { |
| | | patArchive.setTag(row.getCell(17).toString()); |
| | | } |
| | | } |
| | | |
| | | //判断备注是否为空 |
| | | if (!StringUtils.isEmpty(patArchive.getRemark())) { |
| | | //如果备注字段不为空,说有该患者填写有问题 |
| | | errorpatArchiveList.add(patArchive); |
| | | continue; |
| | | } |
| | | |
| | | patArchive.setUploadTime(new Date()); |
| | | patArchive.setIsupload(0L); |
| | | //往患者表里新增,并获取到新增ID |
| | | patArchives.add(patArchive); |
| | | int i1 = patArchiveMapper.insertPatArchive(patArchives); |
| | | |
| | | // // 根据标签名查询出标签信息 |
| | | // String s = patArchive.getTag(); |
| | | // String[] split = s.split(","); |
| | | // for (String tagName : split) { |
| | | // BaseTag baseTag = new BaseTag(); |
| | | // baseTag.setTagname(tagName); |
| | | // List<BaseTag> baseTags = baseTagMapper.selectBaseTagList(baseTag); |
| | | // |
| | | // //如果该标签为空,现标签管理没有出现过的新标签时,自动将标签添加到"标签管理"未分类“中。编辑人为导入账号 |
| | | // if (CollectionUtils.isEmpty(baseTags)) { |
| | | // baseTag = new BaseTag(); |
| | | // baseTag.setTagcategoryid(1L); |
| | | // baseTag.setTagname(tagName); |
| | | // baseTag.setOrgid(user.getDeptId().toString()); |
| | | // baseTag.setDelFlag("0"); |
| | | // baseTag.setCreateBy(user.getUserName()); |
| | | // baseTag.setCreateTime(new Date()); |
| | | // baseTag.setCreateBy(user.getUserName()); |
| | | // baseTag.setCreateTime(new Date()); |
| | | // baseTagMapper.insertBaseTag(baseTag); |
| | | // } else { |
| | | // baseTag = baseTags.get(0); |
| | | // } |
| | | // |
| | | // // 新增患者档案标签 |
| | | // PatArchivetag patArchivetag = DtoConversionUtils.sourceToTarget(baseTag, PatArchivetag.class); |
| | | // patArchivetag.setUpdateBy(user.getUserName()); |
| | | // patArchivetag.setCreateTime(new Date()); |
| | | // patArchivetag.setPatid(patArchive.getPatid()); |
| | | // patArchivetagMapper.insertPatArchivetag(patArchivetag); |
| | | // } |
| | | |
| | | patArchives.clear(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //判断姓名是否为空 |
| | | if (Objects.isNull(row.getCell(0)) || StringUtils.isEmpty(row.getCell(0).toString())) { |
| | | addRemark("姓名为空", patArchive); |
| | | } else { |
| | | patArchive.setName(row.getCell(0).toString()); |
| | | } |
| | | |
| | | //判断性别是否为空 |
| | | |
| | | if (ObjectUtils.isEmpty(row.getCell(1)) || StringUtils.isEmpty(row.getCell(1).toString())) { |
| | | addRemark("性别为空", patArchive); |
| | | } else { |
| | | patArchive.setSex(row.getCell(1).toString().equals("男") ? 1L : 2L); |
| | | } |
| | | |
| | | //判断证件类型是否为空 |
| | | if (ObjectUtils.isEmpty(row.getCell(2)) || StringUtils.isEmpty(row.getCell(2).toString())) { |
| | | addRemark("证件类型为空", patArchive); |
| | | } else { |
| | | patArchive.setIccardtype(row.getCell(2).toString()); |
| | | } |
| | | |
| | | //判断出生日期是否为空 |
| | | if (ObjectUtils.isEmpty(row.getCell(4)) || StringUtils.isEmpty(row.getCell(4).toString())) { |
| | | addRemark("出生日期为空", patArchive); |
| | | } else { |
| | | //格式转换,转成日期 |
| | | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd"); |
| | | Date javaDate = new Date(); |
| | | if (row.getCell(4).getCellType().toString().equals("NUMERIC")) { |
| | | javaDate = HSSFDateUtil.getJavaDate(row.getCell(4).getNumericCellValue()); |
| | | } else { |
| | | javaDate = new Date(row.getCell(4).toString()); |
| | | } |
| | | dateFormat.format(javaDate); |
| | | patArchive.setBirthdate(javaDate); |
| | | } |
| | | |
| | | //判断本人联系是否为空,和长度是否正确 |
| | | if (ObjectUtils.isEmpty(row.getCell(5)) || StringUtils.isEmpty(row.getCell(5).toString())) { |
| | | addRemark("本人联系电话为空", patArchive); |
| | | } else { |
| | | //格式转换,转成文本 |
| | | if (row.getCell(5).getCellType().toString().equals("NUMERIC")) { |
| | | String cellData = String.valueOf((long) row.getCell(5).getNumericCellValue()); |
| | | patArchive.setTelcode(cellData); |
| | | } else { |
| | | DataFormatter dataFormatter = new DataFormatter(); |
| | | String cellValue = dataFormatter.formatCellValue(row.getCell(5)); |
| | | patArchive.setTelcode(cellValue); |
| | | } |
| | | } |
| | | |
| | | //判断亲属联系方式是否为空,长度是否正确 |
| | | if (ObjectUtils.isEmpty(row.getCell(6)) || StringUtils.isEmpty(row.getCell(6).toString())) { |
| | | addRemark("亲属联系方式为空", patArchive); |
| | | } else { |
| | | //格式转换,转成文本 |
| | | if (row.getCell(6).getCellType().toString().equals("NUMERIC")) { |
| | | String cellData = String.valueOf((long) row.getCell(6).getNumericCellValue()); |
| | | patArchive.setRelativetelcode(cellData); |
| | | } else { |
| | | DataFormatter dataFormatter = new DataFormatter(); |
| | | String cellValue = dataFormatter.formatCellValue(row.getCell(6)); |
| | | patArchive.setRelativetelcode(cellValue); |
| | | } |
| | | } |
| | | |
| | | //患都标签是否为空 |
| | | if (ObjectUtils.isEmpty(row.getCell(7))) { |
| | | addRemark("患者标签为空", patArchive); |
| | | } else { |
| | | patArchive.setTag(row.getCell(7).toString()); |
| | | } |
| | | |
| | | //判断备注是否为空 |
| | | if (!StringUtils.isEmpty(patArchive.getRemark())) { |
| | | //如果备注字段不为空,说有该患者填写有问题 |
| | | errorpatArchiveList.add(patArchive); |
| | | failNum = failNum + 1; |
| | | continue; |
| | | } |
| | | |
| | | //往患者表里新增,并获取到新增ID |
| | | patArchiveMapper.insertPatArchive(patArchive); |
| | | |
| | | //根据标签名查询出标签信息 |
| | | String s = row.getCell(7).toString(); |
| | | String[] split = s.split(","); |
| | | for (String tagName : split) { |
| | | BaseTag baseTag = new BaseTag(); |
| | | baseTag.setTagname(tagName); |
| | | List<BaseTag> baseTags = baseTagMapper.selectBaseTagList(baseTag); |
| | | BaseTag baseTag1 = baseTags.get(0); |
| | | |
| | | // 新增患者档案标签 |
| | | PatArchivetag patArchivetag = DtoConversionUtils.sourceToTarget(baseTag1, PatArchivetag.class); |
| | | patArchivetag.setUpdateBy(username); |
| | | patArchivetag.setCreateTime(new Date()); |
| | | patArchivetag.setPatid(patArchive.getPatid()); |
| | | patArchivetagMapper.insertPatArchivetag(patArchivetag); |
| | | } |
| | | successNum = successNum + 1; |
| | | }); |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | patUpInfoVO.setFailNum(failNum); |
| | | patUpInfoVO.setSuccessNum(successNum); |
| | | pool.shutdown(); |
| | | Boolean aa = true; |
| | | d: |
| | | while (aa) { |
| | | boolean terminated = pool.isTerminated(); |
| | | if (terminated) { |
| | | aa = false; |
| | | continue d; |
| | | } |
| | | } |
| | | |
| | | if (errorpatArchiveList.size() != 0) { |
| | | patUpInfoVO.setSuccessNum(lastRowNum - errorpatArchiveList.size()); |
| | | patUpInfoVO.setFailNum(errorpatArchiveList.size()); |
| | | } else { |
| | | patUpInfoVO.setSuccessNum(lastRowNum == 0 ? 0 : lastRowNum); |
| | | patUpInfoVO.setFailNum(0); |
| | | } |
| | | patUpInfoVO.setPatArchiveList(errorpatArchiveList); |
| | | return patUpInfoVO; |
| | | } |
| | |
| | | return "导出成功"; |
| | | } |
| | | |
| | | @Override |
| | | public List<PatArchive> patInfoByContion(PatArchiveReq patArchive) { |
| | | List<PatArchive> patArchives = new ArrayList<>(); |
| | | |
| | | //根据条件获取患者信息 |
| | | // List<PatArchive> patArchiveList = patArchiveMapper.patInfoByContion(patArchive); |
| | | List<PatArchive> patArchiveList = new ArrayList<>(); |
| | | |
| | | if (patArchive.getEndtime() != null) { |
| | | //出院时间只有住院才有 |
| | | patArchive.setAllhosp(1L); |
| | | } |
| | | |
| | | if (patArchive.getAllhosp() != null && patArchive.getAllhosp() == 0) { |
| | | List<PatArchive> 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); |
| | | if (CollectionUtils.isNotEmpty(patArchives1)) { |
| | | patArchiveList.addAll(patArchives1); |
| | | } |
| | | } else if (patArchive.getAllhosp() != null && patArchive.getAllhosp() == 2) { |
| | | List<PatArchive> 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); |
| | | if (CollectionUtils.isNotEmpty(patArchives3)) { |
| | | patArchiveList.addAll(patArchives3); |
| | | } |
| | | } |
| | | |
| | | |
| | | //根据患者ID进行分组 |
| | | Map<Long, List<PatArchive>> listMap = patArchiveList.stream().collect(Collectors.groupingBy(PatArchive::getId)); |
| | | |
| | | //对数据进行封装 |
| | | for (List<PatArchive> list : listMap.values()) { |
| | | PatArchive patArchive1 = new PatArchive(); |
| | | Set<PatArchivetag> stringList = new HashSet<>(); |
| | | for (int i = 0; i < list.size(); i++) { |
| | | if (i == 0) { |
| | | patArchive1 = DtoConversionUtils.sourceToTarget(list.get(0), PatArchive.class); |
| | | //将标签置空,不空也没有问题 |
| | | patArchive1.setTag(""); |
| | | } |
| | | //将查出的tag,放到patArchive1里的TagList中 |
| | | PatArchivetag patArchivetag = new PatArchivetag(); |
| | | patArchivetag.setTagname(list.get(i).getTag()); |
| | | patArchivetag.setTagid(list.get(i).getTagid()); |
| | | stringList.add(patArchivetag); |
| | | } |
| | | patArchive1.setTagList(stringList.stream().collect(Collectors.toList())); |
| | | patArchives.add(patArchive1); |
| | | } |
| | | |
| | | return patArchives; |
| | | } |
| | | |
| | | @Override |
| | | public List<PatArchivetagAndPatientInfo> patTagByContion(List<Long> tagids) { |
| | | List<PatArchivetagAndPatientInfo> patArchivetagAndPatientInfos = new ArrayList<>(); |
| | | if (tagids.size() > 0) { |
| | | for (int i = 0; i < tagids.size(); i++) { |
| | | PatArchivetag patArchivetag = new PatArchivetag(); |
| | | patArchivetag.setTagid(tagids.get(i)); |
| | | //获取患者patid |
| | | List<PatArchivetag> patArchivetags1 = patArchivetagMapper.selectPatArchivetagAndBaseTagList(patArchivetag); |
| | | for (int j = 0; j < patArchivetags1.size(); j++) { |
| | | PatArchivetagAndPatientInfo patArchivetagAndPatientInfo = DtoConversionUtils.sourceToTarget(patArchivetags1.get(j), PatArchivetagAndPatientInfo.class); |
| | | PatArchive patArchive = new PatArchive(); |
| | | patArchive.setId(patArchivetagAndPatientInfo.getPatid()); |
| | | List<PatArchive> patArchiveList = patArchiveMapper.selectPatArchiveList(patArchive); |
| | | patArchivetagAndPatientInfo.setPatNum(patArchiveList.size()); |
| | | // patArchivetagAndPatientInfo.setPatArchives(patArchiveList); |
| | | patArchivetagAndPatientInfos.add(patArchivetagAndPatientInfo); |
| | | } |
| | | } |
| | | } else { |
| | | PatArchivetag patArchivetag = new PatArchivetag(); |
| | | //获取患者patid |
| | | List<PatArchivetag> patArchivetags1 = patArchivetagMapper.selectPatArchivetagAndBaseTagList(patArchivetag); |
| | | for (int j = 0; j < patArchivetags1.size(); j++) { |
| | | PatArchivetagAndPatientInfo patArchivetagAndPatientInfo = DtoConversionUtils.sourceToTarget(patArchivetags1.get(j), PatArchivetagAndPatientInfo.class); |
| | | PatArchive patArchive = new PatArchive(); |
| | | patArchive.setId(patArchivetagAndPatientInfo.getPatid()); |
| | | List<PatArchive> patArchiveList = patArchiveMapper.selectPatArchiveList(patArchive); |
| | | // patArchivetagAndPatientInfo.setPatArchives(patArchiveList); |
| | | patArchivetagAndPatientInfo.setPatNum(patArchiveList.size()); |
| | | patArchivetagAndPatientInfos.add(patArchivetagAndPatientInfo); |
| | | } |
| | | } |
| | | return patArchivetagAndPatientInfos; |
| | | } |
| | | |
| | | @Override |
| | | public List<PatArchivetagAndPatientInfo> patInfoByTag(List<Long> tagids) { |
| | | |
| | | |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public List<Object> getUserTreatmentInfo(String pid, String type) { |
| | | if (StringUtils.isEmpty(pid) || StringUtils.isEmpty(type)) { |
| | | throw new BaseException("入参为空,请检查入参"); |
| | | } |
| | | List<Object> objectList = new ArrayList<>(); |
| | | |
| | | //通过患者获取门诊信息 |
| | | PatMedInhosp patMedInhosp = new PatMedInhosp(); |
| | | patMedInhosp.setInhospno(pid); |
| | | List<PatMedInhosp> patMedInhosps = patMedInhospService.selectPatMedInhospList(patMedInhosp); |
| | | objectList.addAll(patMedInhosps); |
| | | |
| | | |
| | | return null; |
| | | } |
| | | |
| | | private void getdata(Row row, PatArchive patArchive, Boolean head) { |
| | | if (head) { |
| | | row.createCell(0).setCellValue("姓名"); |
| | |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd"); |
| | | row.createCell(0).setCellValue(patArchive.getName()); |
| | | row.createCell(1).setCellValue(patArchive.getSex() == 1 ? "男" : "女"); |
| | | row.createCell(2).setCellValue(patArchive.getIccardtype()); |
| | | row.createCell(3).setCellValue(patArchive.getIccardno()); |
| | | row.createCell(2).setCellValue(patArchive.getIdcardtype()); |
| | | row.createCell(3).setCellValue(patArchive.getIdcardno()); |
| | | if (ObjectUtils.isNotEmpty(patArchive.getBirthdate())) { |
| | | row.createCell(4).setCellValue(simpleDateFormat.format(patArchive.getBirthdate()).toString()); |
| | | } |