relative_form_query: Create form query of type 'ABSOLUTE'

Description Usage Arguments Value Examples

View source: R/form_queries.R

Description

Creates query of type 'ABSOLUTE'

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
relative_form_query(
  query_id,
  before_queries = NULL,
  after_queries = NULL,
  before_concept_ids = NULL,
  after_concept_ids = NULL,
  connection = NULL,
  resolution = "COMPLETE",
  time_unit = "QUARTERS",
  time_count_before = 1,
  time_count_after = 1,
  index_selector = "EARLIEST",
  index_placement = "BEFORE"
)

Arguments

query_id

query_id for query that defines population

before_queries

list of queries for time before index date (type 'CONCEPT_QUERY' - from create_query function)

after_queries

list of queries for time after index date (type 'CONCEPT_QUERY' - from create_query function)

before_concept_ids

list of concept ids to use instead of before_queries

after_concept_ids

list of concept ids to use instead of after_queries

connection

connection object is needed when using concept_ids

resolution

time resolution of output - 'COMPLETE', 'YEARS', 'QUARTERS'

time_unit

time unit of for before and after date range

  • 'QUARTERS', 'DAYS'

time_count_before

number of time units in date range before index date

time_count_after

number of time units in date range after index date

index_selector

specifies how the index date will be retrieved from date range per person - 'EARLIEST', 'RANDOM', 'LATEST'

index_placement

specifies if time unit of index date is counted to before date range, after date range or if it lies inbetween.

  • 'BEFORE', 'NEUTRAL', 'AFTER'

Value

relative form query

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Step 1. Get query id that represents group of people
# a) Take query id from return value of execute_query function (Example)
concept_id = "fdb_destatis.alter"
query = concept_to_query(concept_id, connection = connection,
                         start_date="2017-01-01", end_date="2017-01-31")
query_id = execute_query(connection, query)

# b) Get query id from from query label
query_id = query_label_to_id(connection, "query-label")

# Step 2. Create Form Query

## Absolute Form
form_query = absolute_form_query(query_id,
                                 concept_ids = list("fdb_destatis.alter",
                                                    "fdb_destatis.geschlecht"),
                                 connection=connection,
                                 start_date="2017-01-01", end_date="2017-01-31")

## Relative Form
form_query = relative_form_query(query_id,
                                 before_concept_ids = list("fdb_destatis.alter",
                                                    "fdb_destatis.geschlecht"),
                                 after_concept_ids = list("fdb_destatis.alter",
                                                           "fdb_destatis.geschlecht"),
                                 connection=connection,
                                 start_date="2017-01-01", end_date="2017-01-31")

# Step 3. Execute form_query
form_query_id = execute_query(connection, form_query)

# Step 4. Get query result
data = get_query_result(connection, form_query_id)

ingef/cqapiR documentation built on Dec. 20, 2021, 7:02 p.m.