| | |
| | | import java.io.FileOutputStream; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | | import java.time.Period; |
| | | import java.time.ZoneId; |
| | | import java.time.temporal.ChronoUnit; |
| | | import java.util.*; |
| | | import java.util.concurrent.ExecutorService; |
| | | import java.util.concurrent.Executors; |
| | |
| | | private PatArchivecontactMapper patArchivecontactMapper; |
| | | |
| | | @Autowired |
| | | private IPatMedPhysicalService patMedPhysicalService; |
| | | private PatMedOuthospMapper patMedOuthospMapper; |
| | | |
| | | @Autowired |
| | | private RedisCache redisCache; |
| | |
| | | } |
| | | } else if (patArchiveReq.getAllhosp() != null && patArchiveReq.getAllhosp() == 2) { |
| | | // 查看住院 1 查看门诊 2 查看体检 3 |
| | | List<PatArchiveOthreInfo> patArchives2 = patArchiveMapper.selectPatArchiveInfoByOuthosp(patArchiveReq); |
| | | if (CollectionUtils.isNotEmpty(patArchives2)) { |
| | | patArchiveList.addAll(patArchives2); |
| | | // List<PatArchiveOthreInfo> patArchives2 = patArchiveMapper.selectPatArchiveInfoByOuthosp(patArchiveReq); |
| | | List<PatArchiveOthreInfo> patientInfoQC = getPatientInfoUtils(patArchiveReq); |
| | | |
| | | if (CollectionUtils.isNotEmpty(patientInfoQC)) { |
| | | patArchiveList.addAll(patientInfoQC); |
| | | } |
| | | } else if (patArchiveReq.getAllhosp() != null && patArchiveReq.getAllhosp() == 3) { |
| | | // 查看住院 1 查看门诊 2 查看体检 3 |
| | |
| | | patArchiveList.addAll(patArchives1); |
| | | } |
| | | } else if (patArchive.getAllhosp() != null && patArchive.getAllhosp() == 2) { |
| | | List<PatArchiveOthreInfo> patArchives2 = patArchiveMapper.selectPatArchiveInfoByOuthosp(patArchive); |
| | | if (CollectionUtils.isNotEmpty(patArchives2)) { |
| | | patArchiveList.addAll(patArchives2); |
| | | List<PatArchiveOthreInfo> patientInfoUtils = getPatientInfoUtils(patArchive); |
| | | if (CollectionUtils.isNotEmpty(patientInfoUtils)) { |
| | | patArchiveList.addAll(patientInfoUtils); |
| | | } |
| | | } else if (patArchive.getAllhosp() != null && patArchive.getAllhosp() == 3) { |
| | | List<PatArchiveOthreInfo> patArchives3 = patArchiveMapper.selectPatArchiveInfoByPhysical(patArchive); |
| | |
| | | |
| | | List<PatArchive> patArchiveList1 = DtoConversionUtils.sourceToTarget(patArchiveList, PatArchive.class); |
| | | //给患者联系人赋值 |
| | | // for (PatArchive pa : patArchives) { |
| | | for (PatArchive pa : patArchiveList1) { |
| | | PatArchivecontact patArchivecontact = new PatArchivecontact(); |
| | | patArchivecontact.setPatid(pa.getId()); |
| | | pa.setPatArchivecontactList(patArchivecontactMapper.selectPatArchivecontactList(patArchivecontact)); |
| | | Map<String, String> map = calculateAge(pa.getBirthdate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate(), LocalDate.now()); |
| | | pa.setAge(StringUtils.isNotEmpty(map.get("age")) ? Long.valueOf(map.get("age")) : null); |
| | | pa.setAgeUnit(map.get("ageUnit") != null ? map.get("ageUnit") : ""); |
| | | } |
| | | |
| | | return patArchiveList1; |
| | |
| | | } |
| | | } else if (patArchiveReq.getAllhosp() != null && patArchiveReq.getAllhosp() == 2) { |
| | | // 查看住院 1 查看门诊 2 查看体检 3 查看出院 4 |
| | | List<PatArchiveOthreInfo> patArchives2 = patArchiveMapper.selectPatArchiveInfoByOuthospQC(patArchiveReq); |
| | | if (CollectionUtils.isNotEmpty(patArchives2)) { |
| | | patArchiveList.addAll(patArchives2); |
| | | List<PatArchiveOthreInfo> patArchives2 = new ArrayList<>(); |
| | | // List<PatArchiveOthreInfo> patArchives2 = patArchiveMapper.selectPatArchiveInfoByOuthospQC(patArchiveReq); |
| | | |
| | | //门急诊信息,采用分表查询(先查门急诊的存储过程,再查患者基本信息表,关联条件:patid) |
| | | List<PatArchiveOthreInfo> patientInfoUtils = getPatientInfoUtils(patArchiveReq); |
| | | if (CollectionUtils.isNotEmpty(patientInfoUtils)) { |
| | | patArchiveList.addAll(patientInfoUtils); |
| | | } |
| | | } else if (patArchiveReq.getAllhosp() != null && patArchiveReq.getAllhosp() == 3) { |
| | | // 查看住院 1 查看门诊 2 查看体检 3 查看出院 4 |
| | |
| | | * @return |
| | | */ |
| | | // @Override |
| | | |
| | | /** |
| | | * 获取患者信息总数(去重) |
| | | * |
| | |
| | | count = patArchiveMapper.countPatArchiveInfoByInhospQC(patArchiveReq); |
| | | } else if (patArchiveReq.getAllhosp() != null && patArchiveReq.getAllhosp() == 2) { |
| | | // 查看住院 1 查看门诊 2 查看体检 3 查看出院 4 |
| | | count = patArchiveMapper.countPatArchiveInfoByOuthospQC(patArchiveReq); |
| | | // count = patArchiveMapper.countPatArchiveInfoByOuthospQC(patArchiveReq); |
| | | PatMedOuthospQueryReq req = new PatMedOuthospQueryReq(); |
| | | String deptcodes = CollectionUtils.isEmpty(patArchiveReq.getLeaveldeptcodes()) ? null : String.join(",", patArchiveReq.getLeaveldeptcodes()); |
| | | String leavehospitaldistrictcodes = CollectionUtils.isEmpty(patArchiveReq.getLeavehospitaldistrictcodes()) ? null : String.join(",", patArchiveReq.getLeavehospitaldistrictcodes()); |
| | | req.setDeptcode(deptcodes); |
| | | req.setHospitaldistrictcode(leavehospitaldistrictcodes); |
| | | req.setOrgid(patArchiveReq.getOrgid()); |
| | | req.setDrname(StringUtils.isNotEmpty(patArchiveReq.getDrname()) ? patArchiveReq.getDrname() : null); |
| | | req.setPatname(StringUtils.isNotEmpty(patArchiveReq.getName()) ? patArchiveReq.getName() : null); |
| | | req.setDiagname(StringUtils.isNotEmpty(patArchiveReq.getLeavediagname()) ? patArchiveReq.getLeavediagname() : null); |
| | | count = patMedOuthospMapper.callSpQueryOuthospCount(req); |
| | | |
| | | |
| | | } else if (patArchiveReq.getAllhosp() != null && patArchiveReq.getAllhosp() == 3) { |
| | | // 查看住院 1 查看门诊 2 查看体检 3 查看出院 4 |
| | | count = patArchiveMapper.countPatArchiveInfoByPhysicalQC(patArchiveReq); |
| | |
| | | |
| | | return count; |
| | | } |
| | | |
| | | private List<PatArchiveOthreInfo> getPatientInfoUtils(PatArchiveReq patArchiveReq) { |
| | | List<PatArchiveOthreInfo> patArchiveList = new ArrayList<>(); |
| | | |
| | | //门急诊信息,采用分表查询(先查门急诊的存储过程,再查患者基本信息表,关联条件:patid) |
| | | PatMedOuthospQueryReq req = new PatMedOuthospQueryReq(); |
| | | String deptcodes = CollectionUtils.isEmpty(patArchiveReq.getLeaveldeptcodes()) ? null : String.join(",", patArchiveReq.getLeaveldeptcodes()); |
| | | String leavehospitaldistrictcodes = CollectionUtils.isEmpty(patArchiveReq.getLeavehospitaldistrictcodes()) ? null : String.join(",", patArchiveReq.getLeavehospitaldistrictcodes()); |
| | | req.setDeptcode(deptcodes); |
| | | req.setHospitaldistrictcode(leavehospitaldistrictcodes); |
| | | req.setOrgid(patArchiveReq.getOrgid()); |
| | | req.setDrname(StringUtils.isNotEmpty(patArchiveReq.getDrname()) ? patArchiveReq.getDrname() : null); |
| | | req.setPatname(StringUtils.isNotEmpty(patArchiveReq.getName()) ? patArchiveReq.getName() : null); |
| | | req.setDiagname(StringUtils.isNotEmpty(patArchiveReq.getLeavediagname()) ? patArchiveReq.getLeavediagname() : null); |
| | | req.setPageNum(patArchiveReq.getPageNum() == null ? null : patArchiveReq.getPageNum()); |
| | | req.setPageSize(patArchiveReq.getPageSize() == null ? null : patArchiveReq.getPageSize()); |
| | | List<PatMedOuthosp> patMedOuthosps = patMedOuthospMapper.callSpQueryOuthosp(req); |
| | | for (PatMedOuthosp patMedOuthosp : patMedOuthosps) { |
| | | PatArchive patArchive = patArchiveMapper.selectPatArchiveByPatid(patMedOuthosp.getPatid()); |
| | | PatArchiveOthreInfo patArchiveOthreInfo = DtoConversionUtils.sourceToTarget(patArchive, PatArchiveOthreInfo.class); |
| | | patArchiveOthreInfo.setDeptcode(patMedOuthosp.getDeptcode()); |
| | | patArchiveOthreInfo.setDeptname(patMedOuthosp.getDeptname()); |
| | | patArchiveOthreInfo.setDrcode(patMedOuthosp.getDrcode()); |
| | | patArchiveOthreInfo.setDrname(patMedOuthosp.getDrname()); |
| | | patArchiveList.add(patArchiveOthreInfo); |
| | | } |
| | | return patArchiveList; |
| | | } |
| | | |
| | | public Map<String, String> calculateAge(LocalDate birthdate, LocalDate today) { |
| | | if (birthdate == null || today.isBefore(birthdate)) { |
| | | return null; |
| | | } |
| | | Map<String, String> ageMap = new HashMap<>(); |
| | | |
| | | Period period = Period.between(birthdate, today); |
| | | long totalDays = ChronoUnit.DAYS.between(birthdate, today); |
| | | long totalMonths = ChronoUnit.MONTHS.between(birthdate, today); |
| | | |
| | | int years = period.getYears(); |
| | | int months = period.getMonths(); |
| | | int days = period.getDays(); |
| | | |
| | | String ageUnit; |
| | | Integer age; |
| | | String ageUnit2 = null; |
| | | Integer age2 = null; |
| | | |
| | | if (totalDays < 90) { |
| | | // 小于 1 个月,按天计算 |
| | | ageUnit = "天"; |
| | | age = (int) totalDays; |
| | | ageMap.put("age", age != null ? age.toString() : null); |
| | | ageMap.put("ageUnit", ageUnit); |
| | | ageMap.put("age2", null); |
| | | ageMap.put("ageUnit2", null); |
| | | } else if (totalMonths < 36) { |
| | | // 小于 1 年,按月 + 天计算 |
| | | ageUnit = "月"; |
| | | age = (int) totalMonths; |
| | | ageUnit2 = "天"; |
| | | age2 = days; |
| | | ageMap.put("age", age != null ? age.toString() : null); |
| | | ageMap.put("ageUnit", ageUnit); |
| | | ageMap.put("age2", age2 != null ? age2.toString() : null); |
| | | ageMap.put("ageUnit2", ageUnit2); |
| | | } else { |
| | | // 大于 1 年,按年 + 月计算 |
| | | ageUnit = "岁"; |
| | | age = years; |
| | | ageUnit2 = "月"; |
| | | age2 = months; |
| | | ageMap.put("age", age != null ? age.toString() : null); |
| | | ageMap.put("ageUnit", ageUnit); |
| | | ageMap.put("age2", age2 != null ? age2.toString() : null); |
| | | ageMap.put("ageUnit2", ageUnit2); |
| | | } |
| | | |
| | | return ageMap; |
| | | } |
| | | } |
| | | |