|
@@ -17,6 +17,8 @@ import cn.hutool.core.date.DateUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
import java.util.*;
|
|
|
+import java.util.function.Function;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
@@ -51,19 +53,19 @@ public class PatientLossDataStatisticServiceImpl implements PatientLossDataStati
|
|
|
if (null == endDate || endDate.after(now)) {
|
|
|
endDate = now;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
while (!startDate.after(endDate)) {
|
|
|
// 查询挂号流失信息
|
|
|
- List<DoctorDwdRegisterRecordVO> registerRecordVOs = doctorDwdPatientDataBizService.queryRegisterLossList(DateUtil.offsetDay(startDate, -registerLossDay), DateUtil.offsetDay(startDate, -registerLossDay+1));
|
|
|
+ List<DoctorDwdRegisterRecordVO> registerRecordVOs = doctorDwdPatientDataBizService.queryRegisterLossList(DateUtil.offsetDay(startDate, -registerLossDay), DateUtil.offsetDay(startDate, -registerLossDay + 1));
|
|
|
// 保存流失数据
|
|
|
if (CollUtil.isNotEmpty(registerRecordVOs)) {
|
|
|
// 校验当天同部门已就诊
|
|
|
Map<String, List<DoctorDwdRegisterRecordVO>> regVisMap = new HashMap<>();
|
|
|
Set<String> patientIds = new HashSet<>();
|
|
|
- registerRecordVOs.forEach(vo-> patientIds.add(vo.getPatientId()));
|
|
|
- List<DoctorDwdRegisterRecordVO> regVisList = doctorDwdPatientDataBizService.queryRegisterVisitList(patientIds, DateUtil.offsetDay(startDate, -registerLossDay), DateUtil.offsetDay(startDate, -registerLossDay+1));
|
|
|
+ registerRecordVOs.forEach(vo -> patientIds.add(vo.getPatientId()));
|
|
|
+ List<DoctorDwdRegisterRecordVO> regVisList = doctorDwdPatientDataBizService.queryRegisterVisitList(patientIds, DateUtil.offsetDay(startDate, -registerLossDay), DateUtil.offsetDay(startDate, -registerLossDay + 1));
|
|
|
if (CollUtil.isNotEmpty(regVisList)) {
|
|
|
- regVisList.forEach(vo->{
|
|
|
+ regVisList.forEach(vo -> {
|
|
|
String mapKey = StrUtil.format("{}_{}", vo.getPatientId(), vo.getDepartmentCodeStandard());
|
|
|
if (regVisMap.containsKey(mapKey)) {
|
|
|
List<DoctorDwdRegisterRecordVO> mapList = regVisMap.get(mapKey);
|
|
@@ -98,7 +100,7 @@ public class PatientLossDataStatisticServiceImpl implements PatientLossDataStati
|
|
|
patientLossDataBizService.saveBatch(saveList);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
startDate = DateUtil.offsetDay(startDate, 1);
|
|
|
}
|
|
|
}
|
|
@@ -112,15 +114,15 @@ public class PatientLossDataStatisticServiceImpl implements PatientLossDataStati
|
|
|
if (null == endDate || endDate.after(now)) {
|
|
|
endDate = now;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
while (!startDate.after(endDate)) {
|
|
|
// 查询就诊流失信息
|
|
|
- List<PatientVisitRecordClientBO> visitRecordVOs = doctorDwdPatientDataBizService.queryVisitLossList(DateUtil.offsetDay(startDate, -visitLossDay), DateUtil.offsetDay(startDate, -visitLossDay+1));
|
|
|
+ List<PatientVisitRecordClientBO> visitRecordVOs = doctorDwdPatientDataBizService.queryVisitLossList(DateUtil.offsetDay(startDate, -visitLossDay), DateUtil.offsetDay(startDate, -visitLossDay + 1));
|
|
|
|
|
|
// 保存流失数据
|
|
|
if (CollUtil.isNotEmpty(visitRecordVOs)) {
|
|
|
List<PatientLossAddDTO> saveList = new ArrayList<>();
|
|
|
-
|
|
|
+
|
|
|
visitRecordVOs.forEach(i -> {
|
|
|
PatientLossAddDTO loss = new PatientLossAddDTO();
|
|
|
loss.setDeptId(i.getDepartmentCodeStandard());
|
|
@@ -129,10 +131,10 @@ public class PatientLossDataStatisticServiceImpl implements PatientLossDataStati
|
|
|
loss.setType(PatientLossConstant.LossType.Visit.getCode());
|
|
|
loss.setDataSourceId(i.getId());
|
|
|
loss.setDataSourceDate(i.getVisitDate());
|
|
|
-
|
|
|
+
|
|
|
saveList.add(loss);
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
if (CollUtil.isNotEmpty(saveList)) {
|
|
|
patientLossDataBizService.saveBatch(saveList);
|
|
|
}
|
|
@@ -152,15 +154,18 @@ public class PatientLossDataStatisticServiceImpl implements PatientLossDataStati
|
|
|
if (null == endDate || endDate.after(now)) {
|
|
|
endDate = now;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
while (!startDate.after(endDate)) {
|
|
|
+ DateTime dateTime = DateUtil.offsetDay(startDate, -inHospitalLostDay);
|
|
|
+ DateTime dateTime1 = DateUtil.offsetDay(startDate, -inHospitalLostDay + 1);
|
|
|
// 查询住院流失信息
|
|
|
- List<PatientInpatientReserveClientBO> inpatientRecordVOs = doctorDwdPatientDataBizService.queryInpatientLossList(DateUtil.offsetDay(startDate, -inHospitalLostDay), DateUtil.offsetDay(startDate, -inHospitalLostDay+1), inHospitalLostDay);
|
|
|
-
|
|
|
+ List<PatientInpatientReserveClientBO> inpatientRecordVOs = doctorDwdPatientDataBizService.queryInpatientLossList(dateTime, dateTime1, inHospitalLostDay);
|
|
|
+
|
|
|
+
|
|
|
// 保存流失数据
|
|
|
if (CollUtil.isNotEmpty(inpatientRecordVOs)) {
|
|
|
List<PatientLossAddDTO> saveList = new ArrayList<>();
|
|
|
-
|
|
|
+
|
|
|
inpatientRecordVOs.forEach(i -> {
|
|
|
PatientLossAddDTO loss = new PatientLossAddDTO();
|
|
|
loss.setDeptId(i.getAdmitDepartmentCodeStandard());
|
|
@@ -169,12 +174,13 @@ public class PatientLossDataStatisticServiceImpl implements PatientLossDataStati
|
|
|
loss.setType(PatientLossConstant.LossType.Inpatient.getCode());
|
|
|
loss.setDataSourceId(i.getId());
|
|
|
loss.setDataSourceDate(i.getApplyDate());
|
|
|
-
|
|
|
+
|
|
|
saveList.add(loss);
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
if (CollUtil.isNotEmpty(saveList)) {
|
|
|
- patientLossDataBizService.saveBatch(saveList);
|
|
|
+ List<PatientLossAddDTO> patientLossAddDTOS = duplicateRemoval(saveList);
|
|
|
+ patientLossDataBizService.saveBatch(patientLossAddDTOS);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -182,4 +188,19 @@ public class PatientLossDataStatisticServiceImpl implements PatientLossDataStati
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 去重
|
|
|
+ *
|
|
|
+ * @param saveList
|
|
|
+ */
|
|
|
+ private List<PatientLossAddDTO> duplicateRemoval(List<PatientLossAddDTO> saveList) {
|
|
|
+ List<PatientLossAddDTO> collect = saveList.stream().collect(Collectors.toMap(PatientLossAddDTO::getPatientId,
|
|
|
+ Function.identity(),
|
|
|
+ (existing, replacement) -> existing,
|
|
|
+ LinkedHashMap::new)).values()
|
|
|
+ .stream()
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ return collect;
|
|
|
+ }
|
|
|
+
|
|
|
}
|