View source: R/create_query_data.R
create_query_data | R Documentation |
dataset_queries
argument in
derive_vars_query()
Creates a queries dataset as input dataset to the dataset_queries
argument
in the derive_vars_query()
function as defined in the Queries Dataset Documentation.
create_query_data(queries, version = NULL, get_terms_fun = NULL)
queries |
List of queries A list of |
version |
Dictionary version The dictionary version used for coding the terms should be specified. If any of the queries is a basket (SMQ, SDG, ....) or a customized query including a basket, the parameter needs to be specified. Permitted Values: A character string (the expected format is company-specific) |
get_terms_fun |
Function which returns the terms For each query specified for the The function must return a dataset with all the terms defining the basket. The output dataset must contain the following variables.
The function must provide the following parameters
|
For each query()
object listed in the queries
argument, the terms belonging
to the query (SRCVAR
, TERMCHAR
, TERMNUM
) are determined with respect
to the definition
field of the query: if the definition field of the
query()
object is
a basket_select()
object, the terms are read from the basket
database by calling the function specified for the get_terms_fun
parameter.
a data frame, the terms stored in the data frame are used.
a list of data frames and basket_select()
objects, all terms from
the data frames and all terms read from the basket database referenced by the
basket_select()
objects are collated.
The following variables (as described in Queries Dataset Documentation) are created:
PREFIX
: Prefix of the variables to be created by
derive_vars_query()
as specified by the prefix
element.
GRPNAME
: Name of the query as specified by the name
element.
GRPID
: Id of the query as specified by the id
element. If the id
element is not specified for a query, the variable is set to NA
. If the
id
element is not specified for any query, the variable is not created.
SCOPE
: scope of the query as specified by the scope
element of
the basket_select()
object. For queries not defined by a basket_select()
object, the variable is set to NA
. If none of the queries is defined by a
basket_select()
object, the variable is not created.
SCOPEN
: numeric scope of the query. It is set to 1
if the
scope is broad. Otherwise it is set to 2
. If the add_scope_num
element
equals FALSE
, the variable is set to NA
. If the add_scope_num
element
equals FALSE
for all baskets or none of the queries is an basket , the variable
is not created.
SRCVAR
: Name of the variable used to identify the terms.
TERMCHAR
: Value of the term variable if it is a character variable.
TERMNUM
: Value of the term variable if it is a numeric variable.
VERSION
: Set to the value of the version
argument. If it is not
specified, the variable is not created.
A dataset to be used as input dataset to the dataset_queries
argument in derive_vars_query()
derive_vars_query()
, query()
, basket_select()
, Queries Dataset Documentation
Creating auxiliary datasets:
consolidate_metadata()
,
create_period_dataset()
,
create_single_dose_dataset()
library(tibble)
library(dplyr, warn.conflicts = FALSE)
library(pharmaversesdtm)
library(admiral)
# creating a query dataset for a customized query
cqterms <- tribble(
~TERMCHAR, ~TERMNUM,
"APPLICATION SITE ERYTHEMA", 10003041L,
"APPLICATION SITE PRURITUS", 10003053L
) %>%
mutate(SRCVAR = "AEDECOD")
cq <- query(
prefix = "CQ01",
name = "Application Site Issues",
definition = cqterms
)
create_query_data(queries = list(cq))
# create a query dataset for SMQs
pregsmq <- query(
prefix = "SMQ02",
id = auto,
definition = basket_select(
name = "Pregnancy and neonatal topics (SMQ)",
scope = "NARROW",
type = "smq"
)
)
bilismq <- query(
prefix = "SMQ04",
definition = basket_select(
id = 20000121L,
scope = "BROAD",
type = "smq"
)
)
# The get_terms function from pharmaversesdtm is used for this example.
# In a real application a company-specific function must be used.
create_query_data(
queries = list(pregsmq, bilismq),
get_terms_fun = pharmaversesdtm:::get_terms,
version = "20.1"
)
# create a query dataset for SDGs
sdg <- query(
prefix = "SDG01",
id = auto,
definition = basket_select(
name = "5-aminosalicylates for ulcerative colitis",
scope = NA_character_,
type = "sdg"
)
)
# The get_terms function from pharmaversesdtm is used for this example.
# In a real application a company-specific function must be used.
create_query_data(
queries = list(sdg),
get_terms_fun = pharmaversesdtm:::get_terms,
version = "2019-09"
)
# creating a query dataset for a customized query including SMQs
# The get_terms function from pharmaversesdtm is used for this example.
# In a real application a company-specific function must be used.
create_query_data(
queries = list(
query(
prefix = "CQ03",
name = "Special issues of interest",
definition = list(
basket_select(
name = "Pregnancy and neonatal topics (SMQ)",
scope = "NARROW",
type = "smq"
),
cqterms
)
)
),
get_terms_fun = pharmaversesdtm:::get_terms,
version = "20.1"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.