Executes an aggregate query over FHIR data. The query calculates summary values based on aggregations and groupings of FHIR resources.
ds_aggregate(
ds,
subject_resource,
aggregations,
groupings = NULL,
filters = NULL
)
The DataSource object containing the data to be queried.
A string representing the type of FHIR resource to aggregate data from.
A named list of FHIRPath expressions that calculate a summary value from each grouping. The expressions must be singular.
An optional named list of FHIRPath expressions that determine which groupings the resources should be counted within.
An optional sequence of FHIRPath expressions that can be evaluated against each resource in the data set to determine whether it is included within the result. The expression must evaluate to a Boolean value. Multiple filters are combined using logical AND operation.
A Spark DataFrame containing the aggregated data.
Pathling documentation - Aggregate
Other FHIRPath queries:
ds_extract()
pc <- pathling_connect()
data_source <- pc %>% pathling_read_ndjson(pathling_examples('ndjson'))
data_source %>% ds_aggregate('Patient',
aggregations = c(patientCount='count()', 'id.count()'),
groupings = c('gender', givenName='name.given'),
filters = c('birthDate > @1950-01-01')
)
#> # Source: table<`sparklyr_tmp_5d01a806_d1f4_42e9_9b9c_098dee8d6cf2`> [9 x 4]
#> # Database: spark_connection
#> gender givenName patientCount `id.count()`
#> <chr> <chr> <dbl> <dbl>
#> 1 female Karina848 1 2
#> 2 female Su690 1 1
#> 3 male Gilberto712 1 1
#> 4 male Pedro316 1 1
#> 5 male Guy979 1 1
#> 6 male Shirley182 1 1
#> 7 female Ophelia894 1 1
#> 8 female Cherryl901 1 1
#> 9 male Seymour882 1 1
pathling_disconnect(pc)