|
|
|
|
@ -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<FollowUpDetailVo> getFollowUpDetail(FollowUpRateDto queryDto) {
|
|
|
|
|
if (queryDto.getStartDate() == null) {
|
|
|
|
|
queryDto.setStartDate(LocalDate.now().withDayOfYear(1));
|
|
|
|
|
}
|
|
|
|
|
if (queryDto.getEndDate() == null) {
|
|
|
|
|
queryDto.setEndDate(LocalDate.now());
|
|
|
|
|
}
|
|
|
|
|
List<FollowUpDetailVo> retList = new ArrayList<>();
|
|
|
|
|
FollowUpDetailVo followUpDetailVo = new FollowUpDetailVo();
|
|
|
|
|
// 总计行预留位置
|
|
|
|
|
retList.set(0, followUpDetailVo);
|
|
|
|
|
// 就诊患者列表查询
|
|
|
|
|
List<PatientVisitRecordStatisticVo> patientVisitList = patientVisitRecordMapper.getVisitPatientList(queryDto);
|
|
|
|
|
// 随访计划列表查询
|
|
|
|
|
List<PatientFollowUpPlanVo> planList = signPatientManageRouteNodeMapper.getFollowUpPlan(queryDto);
|
|
|
|
|
|
|
|
|
|
if (StringUtils.equals(queryDto.getType(), "dept")) {
|
|
|
|
|
FollowUpDetailVo firstRow = new FollowUpDetailVo();
|
|
|
|
|
firstRow.setRowName("总计");
|
|
|
|
|
// 总计行预留位置
|
|
|
|
|
retList.add(0, firstRow);
|
|
|
|
|
|
|
|
|
|
// 就诊患者列表按照科室分组
|
|
|
|
|
Map<Long, List<PatientVisitRecordStatisticVo>> 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<Long, List<PatientFollowUpPlanVo>> 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<Department> deptList = departmentService.selectDepartmentList(deptQuery);
|
|
|
|
|
for (Department dept : deptList) {
|
|
|
|
|
FollowUpDetailVo followUpDetailVo = new FollowUpDetailVo();
|
|
|
|
|
followUpDetailVo.setRowName(dept.getDepartmentName());
|
|
|
|
|
// 就诊人数
|
|
|
|
|
List<PatientVisitRecordStatisticVo> deptVisitList = groupByDept.get(dept.getId());
|
|
|
|
|
@ -201,24 +211,40 @@ public class StatisticsServiceImpl implements IStatisticsService {
|
|
|
|
|
List<SysUser> userList = userService.selectUserList(userQuery);
|
|
|
|
|
List<FollowUpDetailVo> childrenList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
Map<Long, List<PatientVisitRecordStatisticVo>> patientGroupByDoctor = deptVisitList.stream().collect(Collectors.groupingBy(PatientVisitRecordStatisticVo::getAttendingPhysicianId));
|
|
|
|
|
Map<Long, List<PatientFollowUpPlanVo>> planGroupByDoctor = deptPlanList.stream().collect(Collectors.groupingBy(PatientFollowUpPlanVo::getAttendingPhysicianId));
|
|
|
|
|
Map<Long, List<PatientVisitRecordStatisticVo>> patientGroupByDoctor = new HashMap<>();
|
|
|
|
|
Map<Long, List<PatientFollowUpPlanVo>> 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());
|
|
|
|
|
|
|
|
|
|
List<PatientVisitRecordStatisticVo> doctorPatientList = patientGroupByDoctor.get(user.getUserId());
|
|
|
|
|
if (CollectionUtils.isEmpty(doctorPatientList)) {
|
|
|
|
|
childRow.setPatientNum(0);
|
|
|
|
|
} else {
|
|
|
|
|
Map<Long, List<PatientVisitRecordStatisticVo>> doctorGroupByPatient = doctorPatientList.stream().collect(Collectors.groupingBy(PatientVisitRecordStatisticVo::getPatientId));
|
|
|
|
|
// 医生就诊人数
|
|
|
|
|
childRow.setPatientNum(CollectionUtils.isEmpty(patientGroupByDoctor.get(user.getUserId())) ? 0 : planGroupByDoctor.get(user.getUserId()).size());
|
|
|
|
|
childRow.setPatientNum(CollectionUtils.isEmpty(doctorPatientList) ? 0 : doctorGroupByPatient.keySet().size());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 医生统计随访计划人数、随访覆盖率、随访成功人数、随访成功率
|
|
|
|
|
List<PatientFollowUpPlanVo> doctorPlanList = planGroupByDoctor.get(dept.getId());
|
|
|
|
|
List<PatientFollowUpPlanVo> 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")) {
|
|
|
|
|
@ -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<PhoneDialRecordVo> 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<Long, List<PhoneDialRecordVo>> 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<Long, List<PhoneDialRecordVo>> 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<PatientFollowUpPlanVo> 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<FollowUpDetailVo> getTotalRow(List<FollowUpDetailVo> followUpDetailVoList) {
|
|
|
|
|
for (FollowUpDetailVo retObj : followUpDetailVoList) {
|
|
|
|
|
retObj.setRowName("总计");
|
|
|
|
|
private List<FollowUpDetailVo> getTotalRow(FollowUpDetailVo firstRow, List<FollowUpDetailVo> followUpDetailVoList) {
|
|
|
|
|
firstRow.setRowName("总计");
|
|
|
|
|
// 就诊人数
|
|
|
|
|
retObj.setPatientNum(followUpDetailVoList.stream().map(FollowUpDetailVo::getPatientNum).reduce(Integer::sum).get());
|
|
|
|
|
firstRow.setPatientNum(followUpDetailVoList.stream().map(FollowUpDetailVo::getPatientNum).reduce(Integer::sum).get());
|
|
|
|
|
// 随访计划人数
|
|
|
|
|
retObj.setFollowUpNum(followUpDetailVoList.stream().map(FollowUpDetailVo::getFollowUpNum).reduce(Integer::sum).get());
|
|
|
|
|
firstRow.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);
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|