You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: support program-stage data element values in TE aggregate analytics [DHIS2-21763]
Extend /api/analytics/trackedEntities/aggregate/{tet} so the value request
param can be a program-stage data element (event value), not only a tracked
entity attribute.
Event data-element values are multi-valued per tracked entity (one row per
event in analytics_te_event_<tet>), so a naive join fans out and makes GROUP BY
count events instead of tracked entities. Collapse each TE's events for the
stage to a single chosen row via row_number() and LEFT JOIN it back at TE
grain.
Copy file name to clipboardExpand all lines: dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/trackedentity/TrackedEntityAggregateService.java
Copy file name to clipboardExpand all lines: dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/trackedentity/TrackedEntityQueryParams.java
+11-2Lines changed: 11 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -53,9 +53,18 @@ public class TrackedEntityQueryParams {
53
53
54
54
/**
55
55
* The numeric tracked entity attribute the aggregation function of an aggregate query applies to.
56
-
* When null, an aggregate query counts tracked entity instances.
56
+
* When null, the aggregate query either counts tracked entity instances or aggregates over an
57
+
* {@link #eventValue}. At most one of {@code attributeValue} and {@code eventValue} is non-null.
57
58
*/
58
-
privatefinalTrackedEntityAttributevalue;
59
+
privatefinalTrackedEntityAttributeattributeValue;
60
+
61
+
/**
62
+
* The numeric program-stage data element the aggregation function of an aggregate query applies
63
+
* to, collapsed to one chosen event per tracked entity. When null, the aggregate query either
64
+
* counts tracked entity instances or aggregates over an {@link #attributeValue}. At most one of
65
+
* {@code attributeValue} and {@code eventValue} is non-null.
66
+
*/
67
+
privatefinalEventValueeventValue;
59
68
60
69
/** The aggregation function applied to the value column of an aggregate query. */
Copy file name to clipboardExpand all lines: dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/trackedentity/TrackedEntityQueryRequestMapper.java
0 commit comments