|
|
@@ -17,6 +17,7 @@ import org.springframework.stereotype.Component;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.atomic.AtomicInteger;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
@@ -92,19 +93,7 @@ public class PcaStatsAnalyse implements CommonHistoryStats {
|
|
|
//根据病号对输注进行划分
|
|
|
groupByTime.forEach((k,histories)->{
|
|
|
if(CollectionUtil.isNotEmpty(histories)){
|
|
|
- Map<String, Integer> pcaTotalCountByPatient = histories.parallelStream()
|
|
|
- .collect(
|
|
|
- Collectors.groupingBy(CombineHistoryResult::getPatientId,
|
|
|
- Collectors.summingInt(CombineHistoryResult::getPcaTotalCount))
|
|
|
- );
|
|
|
- List<CombineHistoryResult> values = new ArrayList<>();
|
|
|
- pcaTotalCountByPatient.forEach((patientId,pcaTotalCount)->{
|
|
|
- CombineHistoryResult value = new CombineHistoryResult();
|
|
|
- value.setPcaTotalCount(pcaTotalCount);
|
|
|
- value.setPatientId(patientId);
|
|
|
- values.add(value);
|
|
|
- });
|
|
|
- groupByTimeAndPatient.put(k,values);
|
|
|
+ groupByTimeAndPatient.put(k,groupByPatient(histories));
|
|
|
}
|
|
|
});
|
|
|
|
|
|
@@ -179,19 +168,7 @@ public class PcaStatsAnalyse implements CommonHistoryStats {
|
|
|
//根据病号对输注进行划分,计算人均次数
|
|
|
groupByTime.forEach((k,histories)->{
|
|
|
if(CollectionUtil.isNotEmpty(histories)){
|
|
|
- Map<String, Integer> pcaTotalCountByPatient = histories.parallelStream()
|
|
|
- .collect(
|
|
|
- Collectors.groupingBy(CombineHistoryResult::getPatientId,
|
|
|
- Collectors.summingInt(CombineHistoryResult::getPcaTotalCount))
|
|
|
- );
|
|
|
- List<CombineHistoryResult> values = new ArrayList<>();
|
|
|
- pcaTotalCountByPatient.forEach((patientId,pcaTotalCount)->{
|
|
|
- CombineHistoryResult value = new CombineHistoryResult();
|
|
|
- value.setPcaTotalCount(pcaTotalCount);
|
|
|
- value.setPatientId(patientId);
|
|
|
- values.add(value);
|
|
|
- });
|
|
|
- groupByTimeAndPatient.put(k,values);
|
|
|
+ groupByTimeAndPatient.put(k,groupByTimeAndPatient.put(k,groupByPatient(histories)));
|
|
|
}
|
|
|
});
|
|
|
|
|
|
@@ -206,7 +183,7 @@ public class PcaStatsAnalyse implements CommonHistoryStats {
|
|
|
long total=0;
|
|
|
long pcaValidTotalCount=0;
|
|
|
long pcaInvalidTotalCount=0;
|
|
|
- List<CombineHistoryResult> personalPcaResults = Optional.ofNullable(groupByTimeAndPatient.get(timeRange)).orElse(new ArrayList<>());
|
|
|
+ List<CombineHistoryResult> personalPcaResults =groupByPatient(combineResults);
|
|
|
|
|
|
for (CombineHistoryResult combineResult : personalPcaResults) {
|
|
|
Integer validCount = Optional.ofNullable(combineResult.getPcaValidCount()).orElse(0);
|
|
|
@@ -231,4 +208,33 @@ public class PcaStatsAnalyse implements CommonHistoryStats {
|
|
|
|
|
|
return Arrays.asList(result);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 描述: 根据病号对结果进行划分
|
|
|
+ * @author lifang
|
|
|
+ * @date 2022/7/23 15:21
|
|
|
+ * @param sources
|
|
|
+ * @return List<CombineHistoryResult> 一个病人信息占据一个CombineHistoryResult,包括PCA信息
|
|
|
+ */
|
|
|
+ private List<CombineHistoryResult> groupByPatient(List<CombineHistoryResult> sources){
|
|
|
+ List<CombineHistoryResult> result = new ArrayList<>();
|
|
|
+ Map<String, List<CombineHistoryResult>> patientMap = sources.parallelStream()
|
|
|
+ .collect(
|
|
|
+ Collectors.groupingBy(CombineHistoryResult::getPatientId));
|
|
|
+ patientMap.forEach((patientId,histories)->{
|
|
|
+ CombineHistoryResult value = new CombineHistoryResult();
|
|
|
+ AtomicInteger pcaValidCount=new AtomicInteger(0);
|
|
|
+ AtomicInteger pcaInValidCount=new AtomicInteger(0);
|
|
|
+ histories.forEach(history->{
|
|
|
+ pcaValidCount.addAndGet(history.getPcaValidCount());
|
|
|
+ pcaInValidCount.addAndGet(history.getPcaInvalidCount());
|
|
|
+ });
|
|
|
+ value.setPcaValidCount(pcaValidCount.get());
|
|
|
+ value.setPcaInvalidCount(pcaInValidCount.get());
|
|
|
+ value.setPatientId(patientId);
|
|
|
+ result.add(value);
|
|
|
+ });
|
|
|
+ return result;
|
|
|
+ }
|
|
|
}
|