Skip to content
This repository was archived by the owner on May 5, 2021. It is now read-only.

Commit 0f1455b

Browse files
Feature 2920 add outcome time to statistics (SORMAS-Foundation#3421)
* SORMAS-Foundation#3237: Only show facility categories that allow a permanent residence when selecting home in locations * SORMAS-Foundation#2920: Add outcome time to statistics
1 parent 0d5053c commit 0f1455b

8 files changed

Lines changed: 240 additions & 5 deletions

File tree

sormas-api/src/main/java/de/symeda/sormas/api/caze/CaseFacade.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ Map<PresentCondition, Long> getCaseCountPerPersonCondition(
115115

116116
Date getOldestCaseReportDate();
117117

118+
Date getOldestCaseOutcomeDate();
119+
118120
boolean isArchived(String caseUuid);
119121

120122
boolean isDeleted(String caseUuid);

sormas-api/src/main/java/de/symeda/sormas/api/statistics/StatisticsCaseAttribute.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,18 @@ public enum StatisticsCaseAttribute {
4545
StatisticsCaseSubAttribute.EPI_WEEK_OF_YEAR,
4646
StatisticsCaseSubAttribute.DATE_RANGE),
4747

48+
OUTCOME_TIME(StatisticsCaseAttributeGroup.TIME,
49+
false,
50+
true,
51+
StatisticsCaseSubAttribute.YEAR,
52+
StatisticsCaseSubAttribute.QUARTER,
53+
StatisticsCaseSubAttribute.MONTH,
54+
StatisticsCaseSubAttribute.EPI_WEEK,
55+
StatisticsCaseSubAttribute.QUARTER_OF_YEAR,
56+
StatisticsCaseSubAttribute.MONTH_OF_YEAR,
57+
StatisticsCaseSubAttribute.EPI_WEEK_OF_YEAR,
58+
StatisticsCaseSubAttribute.DATE_RANGE),
59+
4860
JURISDICTION(StatisticsCaseAttributeGroup.PLACE,
4961
true,
5062
true,

sormas-api/src/main/java/de/symeda/sormas/api/statistics/StatisticsCaseCriteria.java

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,31 @@ public class StatisticsCaseCriteria implements Serializable {
4646

4747
private List<Year> onsetYears;
4848
private List<Year> reportYears;
49+
private List<Year> outcomeYears;
4950
private List<Quarter> onsetQuarters;
5051
private List<Quarter> reportQuarters;
52+
private List<Quarter> outcomeQuarters;
5153
private List<Month> onsetMonths;
5254
private List<Month> reportMonths;
55+
private List<Month> outcomeMonths;
5356
private List<EpiWeek> onsetEpiWeeks;
5457
private List<EpiWeek> reportEpiWeeks;
58+
private List<EpiWeek> outcomeEpiWeeks;
5559
private List<QuarterOfYear> onsetQuartersOfYear;
5660
private List<QuarterOfYear> reportQuartersOfYear;
61+
private List<QuarterOfYear> outcomeQuartersOfYear;
5762
private List<MonthOfYear> onsetMonthsOfYear;
5863
private List<MonthOfYear> reportMonthsOfYear;
64+
private List<MonthOfYear> outcomeMonthsOfYear;
5965
private List<EpiWeek> onsetEpiWeeksOfYear;
6066
private List<EpiWeek> reportEpiWeeksOfYear;
67+
private List<EpiWeek> outcomeEpiWeeksOfYear;
6168
private Date onsetDateFrom;
6269
private Date onsetDateTo;
6370
private Date reportDateFrom;
6471
private Date reportDateTo;
72+
private Date outcomeDateFrom;
73+
private Date outcomeDateTo;
6574
private List<Sex> sexes;
6675
private Boolean sexUnknown;
6776
private List<IntegerRange> ageIntervals;
@@ -88,6 +97,10 @@ public List<Year> getReportYears() {
8897
return reportYears;
8998
}
9099

100+
public List<Year> getOutcomeYears() {
101+
return outcomeYears;
102+
}
103+
91104
public List<Quarter> getOnsetQuarters() {
92105
return onsetQuarters;
93106
}
@@ -96,6 +109,10 @@ public List<Quarter> getReportQuarters() {
96109
return reportQuarters;
97110
}
98111

112+
public List<Quarter> getOutcomeQuarters() {
113+
return outcomeQuarters;
114+
}
115+
99116
public List<Month> getOnsetMonths() {
100117
return onsetMonths;
101118
}
@@ -104,6 +121,10 @@ public List<Month> getReportMonths() {
104121
return reportMonths;
105122
}
106123

124+
public List<Month> getOutcomeMonths() {
125+
return outcomeMonths;
126+
}
127+
107128
public List<EpiWeek> getOnsetEpiWeeks() {
108129
return onsetEpiWeeks;
109130
}
@@ -112,6 +133,10 @@ public List<EpiWeek> getReportEpiWeeks() {
112133
return reportEpiWeeks;
113134
}
114135

136+
public List<EpiWeek> getOutcomeEpiWeeks() {
137+
return outcomeEpiWeeks;
138+
}
139+
115140
public List<QuarterOfYear> getOnsetQuartersOfYear() {
116141
return onsetQuartersOfYear;
117142
}
@@ -120,6 +145,10 @@ public List<QuarterOfYear> getReportQuartersOfYear() {
120145
return reportQuartersOfYear;
121146
}
122147

148+
public List<QuarterOfYear> getOutcomeQuartersOfYear() {
149+
return outcomeQuartersOfYear;
150+
}
151+
123152
public List<MonthOfYear> getOnsetMonthsOfYear() {
124153
return onsetMonthsOfYear;
125154
}
@@ -128,6 +157,10 @@ public List<MonthOfYear> getReportMonthsOfYear() {
128157
return reportMonthsOfYear;
129158
}
130159

160+
public List<MonthOfYear> getOutcomeMonthsOfYear() {
161+
return outcomeMonthsOfYear;
162+
}
163+
131164
public List<EpiWeek> getOnsetEpiWeeksOfYear() {
132165
return onsetEpiWeeksOfYear;
133166
}
@@ -136,6 +169,10 @@ public List<EpiWeek> getReportEpiWeeksOfYear() {
136169
return reportEpiWeeksOfYear;
137170
}
138171

172+
public List<EpiWeek> getOutcomeEpiWeeksOfYear() {
173+
return outcomeEpiWeeksOfYear;
174+
}
175+
139176
public Date getOnsetDateFrom() {
140177
return onsetDateFrom;
141178
}
@@ -152,6 +189,14 @@ public Date getReportDateTo() {
152189
return reportDateTo;
153190
}
154191

192+
public Date getOutcomeDateFrom() {
193+
return outcomeDateFrom;
194+
}
195+
196+
public Date getOutcomeDateTo() {
197+
return outcomeDateTo;
198+
}
199+
155200
public List<Sex> getSexes() {
156201
return sexes;
157202
}
@@ -228,6 +273,9 @@ public StatisticsCaseCriteria years(List<Year> years, StatisticsCaseAttribute ma
228273
case REPORT_TIME:
229274
this.reportYears = years;
230275
break;
276+
case OUTCOME_TIME:
277+
this.outcomeYears = years;
278+
break;
231279
default:
232280
throw new IllegalArgumentException(mainAttribute.toString());
233281
}
@@ -243,6 +291,9 @@ public StatisticsCaseCriteria quarters(List<Quarter> quarters, StatisticsCaseAtt
243291
case REPORT_TIME:
244292
this.reportQuarters = quarters;
245293
break;
294+
case OUTCOME_TIME:
295+
this.outcomeQuarters = quarters;
296+
break;
246297
default:
247298
throw new IllegalArgumentException(mainAttribute.toString());
248299
}
@@ -258,6 +309,9 @@ public StatisticsCaseCriteria months(List<Month> months, StatisticsCaseAttribute
258309
case REPORT_TIME:
259310
this.reportMonths = months;
260311
break;
312+
case OUTCOME_TIME:
313+
this.outcomeMonths = months;
314+
break;
261315
default:
262316
throw new IllegalArgumentException(mainAttribute.toString());
263317
}
@@ -273,6 +327,9 @@ public StatisticsCaseCriteria epiWeeks(List<EpiWeek> epiWeeks, StatisticsCaseAtt
273327
case REPORT_TIME:
274328
this.reportEpiWeeks = epiWeeks;
275329
break;
330+
case OUTCOME_TIME:
331+
this.outcomeEpiWeeks = epiWeeks;
332+
break;
276333
default:
277334
throw new IllegalArgumentException(mainAttribute.toString());
278335
}
@@ -288,6 +345,9 @@ public StatisticsCaseCriteria quartersOfYear(List<QuarterOfYear> quartersOfYear,
288345
case REPORT_TIME:
289346
this.reportQuartersOfYear = quartersOfYear;
290347
break;
348+
case OUTCOME_TIME:
349+
this.outcomeQuartersOfYear = quartersOfYear;
350+
break;
291351
default:
292352
throw new IllegalArgumentException(mainAttribute.toString());
293353
}
@@ -303,6 +363,9 @@ public StatisticsCaseCriteria monthsOfYear(List<MonthOfYear> monthsOfYear, Stati
303363
case REPORT_TIME:
304364
this.reportMonthsOfYear = monthsOfYear;
305365
break;
366+
case OUTCOME_TIME:
367+
this.outcomeMonthsOfYear = monthsOfYear;
368+
break;
306369
default:
307370
throw new IllegalArgumentException(mainAttribute.toString());
308371
}
@@ -318,6 +381,9 @@ public StatisticsCaseCriteria epiWeeksOfYear(List<EpiWeek> epiWeeksOfYear, Stati
318381
case REPORT_TIME:
319382
this.reportEpiWeeksOfYear = epiWeeksOfYear;
320383
break;
384+
case OUTCOME_TIME:
385+
this.outcomeEpiWeeksOfYear = epiWeeksOfYear;
386+
break;
321387
default:
322388
throw new IllegalArgumentException(mainAttribute.toString());
323389
}
@@ -335,6 +401,10 @@ public StatisticsCaseCriteria dateRange(Date from, Date to, StatisticsCaseAttrib
335401
this.reportDateFrom = from;
336402
this.reportDateTo = to;
337403
break;
404+
case OUTCOME_TIME:
405+
this.outcomeDateFrom = from;
406+
this.outcomeDateTo = to;
407+
break;
338408
default:
339409
throw new IllegalArgumentException(mainAttribute.toString());
340410
}
@@ -455,6 +525,8 @@ public List<? extends StatisticsGroupingKey> getFilterValuesForGrouping(
455525
return onsetYears;
456526
case REPORT_TIME:
457527
return reportYears;
528+
case OUTCOME_TIME:
529+
return outcomeYears;
458530
default:
459531
throw new IllegalArgumentException(attribute.toString());
460532
}
@@ -464,6 +536,8 @@ public List<? extends StatisticsGroupingKey> getFilterValuesForGrouping(
464536
return onsetQuarters;
465537
case REPORT_TIME:
466538
return reportQuarters;
539+
case OUTCOME_TIME:
540+
return outcomeQuarters;
467541
default:
468542
throw new IllegalArgumentException(attribute.toString());
469543
}
@@ -473,6 +547,8 @@ public List<? extends StatisticsGroupingKey> getFilterValuesForGrouping(
473547
return onsetMonths;
474548
case REPORT_TIME:
475549
return reportMonths;
550+
case OUTCOME_TIME:
551+
return outcomeMonths;
476552
default:
477553
throw new IllegalArgumentException(attribute.toString());
478554
}
@@ -482,6 +558,8 @@ public List<? extends StatisticsGroupingKey> getFilterValuesForGrouping(
482558
return onsetEpiWeeks;
483559
case REPORT_TIME:
484560
return reportEpiWeeks;
561+
case OUTCOME_TIME:
562+
return outcomeEpiWeeks;
485563
default:
486564
throw new IllegalArgumentException(attribute.toString());
487565
}
@@ -491,6 +569,8 @@ public List<? extends StatisticsGroupingKey> getFilterValuesForGrouping(
491569
return onsetQuartersOfYear;
492570
case REPORT_TIME:
493571
return reportQuartersOfYear;
572+
case OUTCOME_TIME:
573+
return outcomeQuartersOfYear;
494574
default:
495575
throw new IllegalArgumentException(attribute.toString());
496576
}
@@ -500,6 +580,8 @@ public List<? extends StatisticsGroupingKey> getFilterValuesForGrouping(
500580
return onsetMonthsOfYear;
501581
case REPORT_TIME:
502582
return reportMonthsOfYear;
583+
case OUTCOME_TIME:
584+
return outcomeMonthsOfYear;
503585
default:
504586
throw new IllegalArgumentException(attribute.toString());
505587
}
@@ -509,6 +591,8 @@ public List<? extends StatisticsGroupingKey> getFilterValuesForGrouping(
509591
return onsetEpiWeeksOfYear;
510592
case REPORT_TIME:
511593
return reportEpiWeeksOfYear;
594+
case OUTCOME_TIME:
595+
return outcomeEpiWeeksOfYear;
512596
default:
513597
throw new IllegalArgumentException(attribute.toString());
514598
}

sormas-api/src/main/java/de/symeda/sormas/api/statistics/StatisticsHelper.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,9 @@ public static List<StatisticsGroupingKey> getTimeGroupingKeys(StatisticsCaseAttr
217217
case REPORT_TIME:
218218
oldestCaseDate = FacadeProvider.getCaseFacade().getOldestCaseReportDate();
219219
break;
220+
case OUTCOME_TIME:
221+
oldestCaseDate = FacadeProvider.getCaseFacade().getOldestCaseOutcomeDate();
222+
break;
220223
default:
221224
return new ArrayList<>();
222225
}

sormas-api/src/main/resources/enum.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -829,6 +829,7 @@ StatisticsCaseAttribute.CLASSIFICATION = Classification
829829
StatisticsCaseAttribute.DISEASE = Disease
830830
StatisticsCaseAttribute.ONSET_TIME = Onset time
831831
StatisticsCaseAttribute.OUTCOME = Outcome
832+
StatisticsCaseAttribute.OUTCOME_TIME = Outcome time
832833
StatisticsCaseAttribute.JURISDICTION = Region / District / Community / Facility
833834
StatisticsCaseAttribute.REPORT_TIME = Report time
834835
StatisticsCaseAttribute.REPORTING_USER_ROLE = Reporting user role

sormas-backend/src/main/java/de/symeda/sormas/backend/caze/CaseFacadeEjb.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2705,6 +2705,19 @@ public Date getOldestCaseReportDate() {
27052705
return em.createQuery(cq).getSingleResult();
27062706
}
27072707

2708+
@Override
2709+
public Date getOldestCaseOutcomeDate() {
2710+
2711+
CriteriaBuilder cb = em.getCriteriaBuilder();
2712+
CriteriaQuery<Timestamp> cq = cb.createQuery(Timestamp.class);
2713+
Root<Case> from = cq.from(Case.class);
2714+
2715+
final Path<Timestamp> reportDate = from.get(Case.OUTCOME_DATE);
2716+
cq.select(cb.least(reportDate));
2717+
cq.where(cb.greaterThan(from.get(Case.OUTCOME_DATE), DateHelper.getDateZero(2000, 1, 1)));
2718+
return em.createQuery(cq).getSingleResult();
2719+
}
2720+
27082721
@Override
27092722
public boolean isArchived(String caseUuid) {
27102723

0 commit comments

Comments
 (0)