create_query_data {admiral}R Documentation

Creates a queries dataset as input dataset to the dataset_queries argument in derive_vars_query()

Description

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.

Usage

create_query_data(
  queries,
  meddra_version = NULL,
  whodd_version = NULL,
  get_smq_fun = NULL,
  get_sdg_fun = NULL
)

Arguments

queries

List of queries

A list of query() objects is expected.

meddra_version

MedDRA version

The MedDRA version used for coding the terms in the AE dataset should be specified. If any of the queries is a SMQ or a customized query including a SMQ, the parameter needs to be specified.

Permitted Values: A character string (the expected format is company-specific)

whodd_version

WHO Drug Dictionary version

The version of the WHO Drug Dictionary used for coding the terms in the CM dataset should be specified. If any of the queries is a SDG, the parameter needs to be specified.

Permitted Values: A character string (the expected format is company-specific)

get_smq_fun

Function which returns the terms of an SMQ

For each query specified for the queries parameter which refers to an SMQ (i.e., those where the definition field is set to a smq_select() object or a list which contains at least one smq_select() object) the specified function is called to retrieve the terms defining the query. This function is not provided by admiral as it is company specific, i.e., it has to be implemented at company level.

The function must return a dataset with all the terms defining the SMQ. The output dataset must contain the following variables.

  • TERM_LEVEL: the variable to be used for defining a term of the SMQ, e.g., AEDECOD

  • TERM_NAME: the name of the term if the variable TERM_LEVEL is referring to is character

  • TERM_ID the numeric id of the term if the variable TERM_LEVEL is referring to is numeric

  • QUERY_NAME: the name of the SMQ. The values must be the same for all observations.

The function must provide the following parameters

  • smq_select: A smq_select() object.

  • version: The MedDRA version. The value specified for the meddra_version in the create_query_data() call is passed to this parameter.

  • keep_id: If set to TRUE, the output dataset must contain the QUERY_ID variable. The variable must be set to the numeric id of the SMQ.

  • temp_env: A temporary environment is passed to this parameter. It can be used to store data which is used for all SMQs in the create_query_data() call. For example if the SMQs need to be read from a database all SMQs can be read and stored in the environment when the first SMQ is handled. For the other SMQs the terms can be retrieved from the environment instead of accessing the database again.

get_sdg_fun

Function which returns the terms of an SDG

For each query specified for the queries parameter which refers to an SDG the specified function is called to retrieve the terms defining the query. This function is not provided by admiral as it is company specific, i.e., it has to be implemented at company level.

The function must return a dataset with all the terms defining the SDG. The output dataset must contain the following variables.

  • TERM_LEVEL: the variable to be used for defining a term of the SDG, e.g., CMDECOD

  • TERM_NAME: the name of the term if the variable TERM_LEVEL is referring to is character

  • TERM_ID the numeric id of the term if the variable TERM_LEVEL is referring to is numeric

  • QUERY_NAME: the name of the SDG. The values must be the same for all observations.

The function must provide the following parameters

  • sdg_select: A sdg_select() object.

  • version: The WHO drug dictionary version. The value specified for the whodd_version in the create_query_data() call is passed to this parameter.

  • keep_id: If set to TRUE, the output dataset must contain the QUERY_ID variable. The variable must be set to the numeric id of the SDG.

  • temp_env: A temporary environment is passed to this parameter. It can be used to store data which is used for all SDGs in the create_query_data() call. For example if the SDGs need to be read from a database all SDGs can be read and stored in the environment when the first SDG is handled. For the other SDGs the terms can be retrieved from the environment instead of accessing the database again.

Details

For each query() object listed in the queries argument, the terms belonging to the query (TERM_LEVEL, TERM_NAME, TERM_ID) are determined with respect to the definition field of the query: if the definition field of the query() object is

The following variables (as described in Queries Dataset Documentation) are created:

Value

A dataset to be used as input dataset to the dataset_queries argument in derive_vars_query()

Author(s)

Stefan Bundfuss

See Also

derive_vars_query(), query(), smq_select(), sdg_select(), Queries Dataset Documentation

OCCDS Functions: create_single_dose_dataset(), derive_vars_atc(), derive_vars_query(), get_terms_from_db()

Examples

library(tibble)
library(magrittr, warn.conflicts = FALSE)
library(dplyr, warn.conflicts = FALSE)
library(admiral.test)
library(admiral)

# creating a query dataset for a customized query
cqterms <- tribble(
  ~TERM_NAME, ~TERM_ID,
  "APPLICATION SITE ERYTHEMA", 10003041L,
  "APPLICATION SITE PRURITUS", 10003053L
) %>%
  mutate(TERM_LEVEL = "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 = smq_select(
    name = "Pregnancy and neonatal topics (SMQ)",
    scope = "NARROW"
  )
)

bilismq <- query(
  prefix = "SMQ04",
  definition = smq_select(
    id = 20000121L,
    scope = "BROAD"
  )
)

# The get_smq_terms function from admiral.test is used for this example.
# In a real application a company-specific function must be used.
create_query_data(
  queries = list(pregsmq, bilismq),
  get_smq_fun = admiral.test:::get_smq_terms,
  meddra_version = "20.1"
)

# create a query dataset for SDGs
sdg <- query(
  prefix = "SDG01",
  id = auto,
  definition = sdg_select(
    name = "5-aminosalicylates for ulcerative colitis"
  )
)

# The get_sdg_terms function from admiral.test is used for this example.
# In a real application a company-specific function must be used.
create_query_data(
  queries = list(sdg),
  get_sdg_fun = admiral.test:::get_sdg_terms,
  whodd_version = "2019-09"
)

# creating a query dataset for a customized query including SMQs
# The get_smq_terms function from admiral.test 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(
        smq_select(
          name = "Pregnancy and neonatal topics (SMQ)",
          scope = "NARROW"
        ),
        cqterms
      )
    )
  ),
  get_smq_fun = admiral.test:::get_smq_terms,
  meddra_version = "20.1"
)

[Package admiral version 0.8.4 Index]