From e5fbec5fedb13d80f0d3cf3da591240dddcdee11 Mon Sep 17 00:00:00 2001 From: haown <454902499@qq.com> Date: Fri, 8 Nov 2024 09:32:48 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E6=9F=A5=E8=AF=A2=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/statistics/FollowUpRateDto.java | 4 +- .../impl/StatisticsServiceImpl.java | 108 +++++++++++++----- .../PatientVisitRecordStatisticVo.java | 6 + .../vo/statistics/FollowUpDetailVo.java | 34 +++++- .../PatientVisitRecordMapper.xml | 2 +- .../ShortMessageSendRecordMapper.xml | 2 +- .../SignPatientManageRouteNodeMapper.xml | 4 +- 7 files changed, 119 insertions(+), 41 deletions(-) diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/dto/statistics/FollowUpRateDto.java b/postdischarge-manage/src/main/java/com/xinelu/manage/dto/statistics/FollowUpRateDto.java index 6919408d..2e4012b6 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/dto/statistics/FollowUpRateDto.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/dto/statistics/FollowUpRateDto.java @@ -19,14 +19,14 @@ public class FollowUpRateDto { * 开始月份 */ @ApiModelProperty("开始月份") - @DateTimeFormat(pattern = "yyyy-MM") + @DateTimeFormat(pattern = "yyyy-MM-dd") private LocalDate startDate; /** * 结束月份 */ @ApiModelProperty("结束月份") - @DateTimeFormat(pattern = "yyyy-MM") + @DateTimeFormat(pattern = "yyyy-MM-dd") private LocalDate endDate; /** diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/service/statistics/impl/StatisticsServiceImpl.java b/postdischarge-manage/src/main/java/com/xinelu/manage/service/statistics/impl/StatisticsServiceImpl.java index 8012abf4..6f220e5d 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/service/statistics/impl/StatisticsServiceImpl.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/service/statistics/impl/StatisticsServiceImpl.java @@ -128,6 +128,7 @@ public class StatisticsServiceImpl implements IStatisticsService { rateTrendVo.setCommonPatientSuccessRate(monthObj.getCommonPatientSuccessRate()); rateTrendVoList.add(rateTrendVo); + numTrendVo.setFollowUpMonth(month); numTrendVo.setAiPatientNum(monthObj.getAiPatientNum()); numTrendVo.setCommonPatientNum(monthObj.getCommonPatientNum()); @@ -153,26 +154,34 @@ public class StatisticsServiceImpl implements IStatisticsService { */ @Override public List getFollowUpDetail(FollowUpRateDto queryDto) { + if (queryDto.getStartDate() == null) { + queryDto.setStartDate(LocalDate.now().withDayOfYear(1)); + } + if (queryDto.getEndDate() == null) { + queryDto.setEndDate(LocalDate.now()); + } List retList = new ArrayList<>(); - FollowUpDetailVo followUpDetailVo = new FollowUpDetailVo(); - // 总计行预留位置 - retList.set(0, followUpDetailVo); // 就诊患者列表查询 List patientVisitList = patientVisitRecordMapper.getVisitPatientList(queryDto); // 随访计划列表查询 List planList = signPatientManageRouteNodeMapper.getFollowUpPlan(queryDto); if (StringUtils.equals(queryDto.getType(), "dept")) { + FollowUpDetailVo firstRow = new FollowUpDetailVo(); + firstRow.setRowName("总计"); + // 总计行预留位置 + retList.add(0, firstRow); + // 就诊患者列表按照科室分组 Map> groupByDept = new HashMap<>(); if (CollectionUtils.isNotEmpty(patientVisitList)) { - groupByDept = patientVisitList.stream().collect(Collectors.groupingBy(PatientVisitRecordStatisticVo::getDepartmentId)); + groupByDept = patientVisitList.stream().filter(item -> item.getDepartmentId() != null).collect(Collectors.groupingBy(PatientVisitRecordStatisticVo::getDepartmentId)); } Map> planGroupByDept = new HashMap<>(); if (CollectionUtils.isNotEmpty(planList)) { // 随访计划列表按照科室分组 - planGroupByDept = planList.stream().collect(Collectors.groupingBy(PatientFollowUpPlanVo::getDepartmentId)); + planGroupByDept = planList.stream().filter(item-> item.getDepartmentId() != null).collect(Collectors.groupingBy(PatientFollowUpPlanVo::getDepartmentId)); } // 查询机构、科室、医生列表 Agency agencyQuery = new Agency(); @@ -185,6 +194,7 @@ public class StatisticsServiceImpl implements IStatisticsService { deptQuery.setNodeType(NodeTypeEnum.DEPARTMENT.getInfo()); List deptList = departmentService.selectDepartmentList(deptQuery); for (Department dept : deptList) { + FollowUpDetailVo followUpDetailVo = new FollowUpDetailVo(); followUpDetailVo.setRowName(dept.getDepartmentName()); // 就诊人数 List deptVisitList = groupByDept.get(dept.getId()); @@ -201,27 +211,43 @@ public class StatisticsServiceImpl implements IStatisticsService { List userList = userService.selectUserList(userQuery); List childrenList = new ArrayList<>(); - Map> patientGroupByDoctor = deptVisitList.stream().collect(Collectors.groupingBy(PatientVisitRecordStatisticVo::getAttendingPhysicianId)); - Map> planGroupByDoctor = deptPlanList.stream().collect(Collectors.groupingBy(PatientFollowUpPlanVo::getAttendingPhysicianId)); + Map> patientGroupByDoctor = new HashMap<>(); + Map> planGroupByDoctor = new HashMap<>(); + if (CollectionUtils.isNotEmpty(deptVisitList)) { + patientGroupByDoctor = deptVisitList.stream().filter(item-> item.getAttendingPhysicianId() != null).collect(Collectors.groupingBy(PatientVisitRecordStatisticVo::getAttendingPhysicianId)); + } + if (CollectionUtils.isNotEmpty(deptPlanList)) { + planGroupByDoctor = deptPlanList.stream().filter(item-> item.getAttendingPhysicianId() != null).collect(Collectors.groupingBy(PatientFollowUpPlanVo::getAttendingPhysicianId)); + } for (SysUser user : userList) { FollowUpDetailVo childRow = new FollowUpDetailVo(); childRow.setRowName(user.getNickName()); - // 医生就诊人数 - childRow.setPatientNum(CollectionUtils.isEmpty(patientGroupByDoctor.get(user.getUserId())) ? 0 : planGroupByDoctor.get(user.getUserId()).size()); + List doctorPatientList = patientGroupByDoctor.get(user.getUserId()); + if (CollectionUtils.isEmpty(doctorPatientList)) { + childRow.setPatientNum(0); + } else { + Map> doctorGroupByPatient = doctorPatientList.stream().collect(Collectors.groupingBy(PatientVisitRecordStatisticVo::getPatientId)); + // 医生就诊人数 + childRow.setPatientNum(CollectionUtils.isEmpty(doctorPatientList) ? 0 : doctorGroupByPatient.keySet().size()); + } + // 医生统计随访计划人数、随访覆盖率、随访成功人数、随访成功率 - List doctorPlanList = planGroupByDoctor.get(dept.getId()); + List doctorPlanList = planGroupByDoctor.get(user.getUserId()); getFollowUpDetailVo(doctorPlanList, childRow); childrenList.add(childRow); } followUpDetailVo.setChilderenList(childrenList); retList.add(followUpDetailVo); + + // 计算总计行 + getTotalRow(firstRow, retList); } } - } else if (StringUtils.equals(queryDto.getType(), "date")){ + } else if (StringUtils.equals(queryDto.getType(), "date")) { // 日期列表 List months = new ArrayList<>(); LocalDate startDate = queryDto.getStartDate(); @@ -241,12 +267,30 @@ public class StatisticsServiceImpl implements IStatisticsService { planGroupByExecuteDate = planList.stream().collect(Collectors.groupingBy(PatientFollowUpPlanVo::getExecuteMonthStr)); } for (String month : months) { + FollowUpDetailVo followUpDetailVo = new FollowUpDetailVo(); + followUpDetailVo.setRowName(month); + // 就诊人数 + followUpDetailVo.setPatientNum(groupByVisitDate.getOrDefault(month, new ArrayList<>()).size()); + // 有随访计划人数 + //followUpDetailVo.setFollowUpNum(planGroupByExecuteDate.getOrDefault(month, new ArrayList<>()).size()); + // 随访覆盖率 + //followUpDetailVo.setFollowUpCoverRate(new BigDecimal(followUpDetailVo.getFollowUpNum()).divide(new BigDecimal(followUpDetailVo.getPatientNum()), 2, RoundingMode.HALF_UP).multiply(new BigDecimal("100"))); + // 随访计划人数、随访覆盖率、随访成功人数、随访成功率 + getFollowUpDetailVo(planGroupByExecuteDate.getOrDefault(month, new ArrayList<>()), followUpDetailVo); + // 按随访方式统计 + List phoneDialRecordVoList = phoneDialRecordMapper.getPhoneDialStatistic(queryDto); + // 统计AI电话拨打次数、AI电话拨打次数成功率、人工电话拨打次数、人工电话拨打次数成功率 + FollowUpRateVo followUpRateVo = getFollowUpRateVo(phoneDialRecordVoList); + followUpDetailVo.setAiNum(followUpRateVo.getAiNum()); + followUpDetailVo.setAiSuccessRate(followUpRateVo.getAiSuccessRate()); + followUpDetailVo.setCommonNum(followUpRateVo.getCommonNum()); + followUpDetailVo.setCommonSuccessRate(followUpRateVo.getCommonSuccessRate()); + + retList.add(followUpDetailVo); } } - // 计算总计行 - getTotalRow(retList); return retList; } @@ -281,7 +325,7 @@ public class StatisticsServiceImpl implements IStatisticsService { // AI拨打人数成功率 if (CollectionUtils.isNotEmpty(aiSuccessList)) { Map> aiSuccessGroupByPatient = aiSuccessList.stream().collect(Collectors.groupingBy(PhoneDialRecordVo::getPatientId)); - retObj.setAiSuccessRate(new BigDecimal(aiSuccessGroupByPatient.keySet().size()).divide(new BigDecimal(retObj.getAiPatientNum()), 2, RoundingMode.HALF_UP).multiply(new BigDecimal("100"))); + retObj.setAiPatientSuccessRate(new BigDecimal(aiSuccessGroupByPatient.keySet().size()).divide(new BigDecimal(retObj.getAiPatientNum()), 2, RoundingMode.HALF_UP).multiply(new BigDecimal("100"))); } } @@ -300,7 +344,7 @@ public class StatisticsServiceImpl implements IStatisticsService { // 人工拨打人数成功率 if (CollectionUtils.isNotEmpty(commonSuccessList)) { Map> commonSuccessGroupByPatient = commonSuccessList.stream().collect(Collectors.groupingBy(PhoneDialRecordVo::getPatientId)); - retObj.setCommonSuccessRate(new BigDecimal(commonSuccessGroupByPatient.keySet().size()).divide(new BigDecimal(retObj.getCommonPatientNum()), 2, RoundingMode.HALF_UP).multiply(new BigDecimal("100"))); + retObj.setCommonPatientSuccessRate(new BigDecimal(commonSuccessGroupByPatient.keySet().size()).divide(new BigDecimal(retObj.getCommonPatientNum()), 2, RoundingMode.HALF_UP).multiply(new BigDecimal("100"))); } } return retObj; @@ -314,7 +358,7 @@ public class StatisticsServiceImpl implements IStatisticsService { * @Date 2024-11-4 11:13 */ private FollowUpDetailVo getFollowUpDetailVo(List planList, FollowUpDetailVo followUpDetailVo) { - if (followUpDetailVo.getPatientNum() == 0) { + if (followUpDetailVo.getPatientNum() == 0 || CollectionUtils.isEmpty(planList)) { followUpDetailVo.setFollowUpNum(0); followUpDetailVo.setFollowUpCoverRate(BigDecimal.ZERO); followUpDetailVo.setFollowUpSuccessNum(0); @@ -344,21 +388,25 @@ public class StatisticsServiceImpl implements IStatisticsService { * @Author haown * @Date 2024-11-4 11:29 */ - private List getTotalRow(List followUpDetailVoList) { - for (FollowUpDetailVo retObj : followUpDetailVoList) { - retObj.setRowName("总计"); - // 就诊人数 - retObj.setPatientNum(followUpDetailVoList.stream().map(FollowUpDetailVo::getPatientNum).reduce(Integer::sum).get()); - // 随访计划人数 - retObj.setFollowUpNum(followUpDetailVoList.stream().map(FollowUpDetailVo::getFollowUpNum).reduce(Integer::sum).get()); - // 随访覆盖率 - retObj.setFollowUpCoverRate(new BigDecimal(retObj.getFollowUpNum()).divide(new BigDecimal(retObj.getPatientNum()), 2, RoundingMode.HALF_UP).multiply(new BigDecimal("100"))); - // 随访成功人数 - retObj.setFollowUpSuccessNum(followUpDetailVoList.stream().map(FollowUpDetailVo::getFollowUpSuccessNum).reduce(Integer::sum).get()); - // 随访成功率 - retObj.setFollowUpCoverRate(new BigDecimal(retObj.getFollowUpSuccessNum()).divide(new BigDecimal(retObj.getPatientNum()), 2, RoundingMode.HALF_UP).multiply(new BigDecimal("100"))); - followUpDetailVoList.set(0, retObj); + private List getTotalRow(FollowUpDetailVo firstRow, List followUpDetailVoList) { + firstRow.setRowName("总计"); + // 就诊人数 + firstRow.setPatientNum(followUpDetailVoList.stream().map(FollowUpDetailVo::getPatientNum).reduce(Integer::sum).get()); + // 随访计划人数 + firstRow.setFollowUpNum(followUpDetailVoList.stream().map(FollowUpDetailVo::getFollowUpNum).reduce(Integer::sum).get()); + // 随访覆盖率 + if (firstRow.getPatientNum() != null && firstRow.getPatientNum() > 0) { + firstRow.setFollowUpCoverRate(new BigDecimal(firstRow.getFollowUpNum()).divide(new BigDecimal(firstRow.getPatientNum()), 2, RoundingMode.HALF_UP).multiply(new BigDecimal("100"))); } + + // 随访成功人数 + firstRow.setFollowUpSuccessNum(followUpDetailVoList.stream().map(FollowUpDetailVo::getFollowUpSuccessNum).reduce(Integer::sum).get()); + // 随访成功率 + if (firstRow.getPatientNum() != null && firstRow.getPatientNum() > 0) { + firstRow.setFollowUpSuccessRate(new BigDecimal(firstRow.getFollowUpSuccessNum()).divide(new BigDecimal(firstRow.getPatientNum()), 2, RoundingMode.HALF_UP).multiply(new BigDecimal("100"))); + } + followUpDetailVoList.set(0, firstRow); return followUpDetailVoList; } + } diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/vo/patientvisitrecord/PatientVisitRecordStatisticVo.java b/postdischarge-manage/src/main/java/com/xinelu/manage/vo/patientvisitrecord/PatientVisitRecordStatisticVo.java index fc88fc74..f4fb73e6 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/vo/patientvisitrecord/PatientVisitRecordStatisticVo.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/vo/patientvisitrecord/PatientVisitRecordStatisticVo.java @@ -13,6 +13,12 @@ import lombok.Data; @Data public class PatientVisitRecordStatisticVo { + /** + * 患者主键 + */ + @ApiModelProperty(value = "患者主键") + private Long patientId; + /** * 所属医院id */ diff --git a/postdischarge-manage/src/main/java/com/xinelu/manage/vo/statistics/FollowUpDetailVo.java b/postdischarge-manage/src/main/java/com/xinelu/manage/vo/statistics/FollowUpDetailVo.java index 970030b6..79fdc347 100644 --- a/postdischarge-manage/src/main/java/com/xinelu/manage/vo/statistics/FollowUpDetailVo.java +++ b/postdischarge-manage/src/main/java/com/xinelu/manage/vo/statistics/FollowUpDetailVo.java @@ -22,31 +22,55 @@ public class FollowUpDetailVo { * 就诊/出院患者人数 */ @ApiModelProperty("就诊/出院患者人数") - private Integer patientNum; + private Integer patientNum = 0; /** * 有随访计划人数 */ @ApiModelProperty("有随访计划人数") - private Integer followUpNum; + private Integer followUpNum = 0; /** * 随访覆盖率 */ @ApiModelProperty("随访覆盖率") - private BigDecimal followUpCoverRate; + private BigDecimal followUpCoverRate = BigDecimal.ZERO; /** * 随访成功人数 */ @ApiModelProperty("随访成功人数") - private Integer followUpSuccessNum; + private Integer followUpSuccessNum = 0; /** * 随访成功率 */ @ApiModelProperty("随访成功率") - private BigDecimal followUpSuccessRate; + private BigDecimal followUpSuccessRate = BigDecimal.ZERO; + + /** + * AI电话拨打次数 + */ + @ApiModelProperty("AI电话拨打次数") + private Integer aiNum = 0; + + /** + * AI电话拨打成功率 + */ + @ApiModelProperty("AI电话拨打成功率") + private BigDecimal aiSuccessRate = BigDecimal.ZERO; + + /** + * 人工电话拨打次数 + */ + @ApiModelProperty("人工电话拨打次数") + private Integer commonNum = 0; + + /** + * 人工电话拨打成功率 + */ + @ApiModelProperty("人工电话拨打成功率") + private BigDecimal commonSuccessRate = BigDecimal.ZERO; /** * 下一级随访明细表 diff --git a/postdischarge-manage/src/main/resources/mapper/manage/patientvisitrecord/PatientVisitRecordMapper.xml b/postdischarge-manage/src/main/resources/mapper/manage/patientvisitrecord/PatientVisitRecordMapper.xml index 694e1462..d1ad68ec 100644 --- a/postdischarge-manage/src/main/resources/mapper/manage/patientvisitrecord/PatientVisitRecordMapper.xml +++ b/postdischarge-manage/src/main/resources/mapper/manage/patientvisitrecord/PatientVisitRecordMapper.xml @@ -502,7 +502,7 @@