ds_aggregate {pathling}R Documentation

Execute an aggregate query

Description

Executes an aggregate query over FHIR data. The query calculates summary values based on aggregations and groupings of FHIR resources.

Usage

ds_aggregate(
  ds,
  subject_resource,
  aggregations,
  groupings = NULL,
  filters = NULL
)

Arguments

ds

The DataSource object containing the data to be queried.

subject_resource

A string representing the type of FHIR resource to aggregate data from.

aggregations

A named list of FHIRPath expressions that calculate a summary value from each grouping. The expressions must be singular.

groupings

An optional named list of FHIRPath expressions that determine which groupings the resources should be counted within.

filters

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.

Value

A Spark DataFrame containing the aggregated data.

See Also

Pathling documentation - Aggregate

Other FHIRPath queries: ds_extract()

Examples


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')
)
pathling_disconnect(pc)


[Package pathling version 7.0.0 Index]