query {admiral}R Documentation

Create an query object

Description

A query object defines a query, e.g., a Standard MedDRA Query (SMQ), a Standardized Drug Grouping (SDG), or a customized query (CQ). It is used as input to create_query_data().

Usage

query(prefix, name = auto, id = NULL, add_scope_num = FALSE, definition = NULL)

Arguments

prefix

The value is used to populate VAR_PREFIX in the output dataset of create_query_data(), e.g., "SMQ03"

name

The value is used to populate QUERY_NAME in the output dataset of create_query_data(). If the auto keyword is specified, the variable is set to the name of the query in the SMQ/SDG database.

Permitted Values: A character scalar or the auto keyword. The auto keyword is permitted only for queries which are defined by an smq_select() or sdg_select() object.

id

The value is used to populate QUERY_ID in the output dataset of create_query_data(). If the auto keyword is specified, the variable is set to the id of the query in the SMQ/SDG database.

Permitted Values: A integer scalar or the auto keyword. The auto keyword is permitted only for queries which are defined by an smq_select() or sdg_select() object.

add_scope_num

Determines if QUERY_SCOPE_NUM in the output dataset of create_query_data() is populated

If the parameter is set to TRUE, the definition must be an smq_select() object.

Default: FALSE

Permitted Values: TRUE, FALSE

definition

Definition of terms belonging to the query

There are four different ways to define the terms:

  • An smq_select() object is specified to select a query from the SMQ database.

  • An sdg_select() object is specified to select a query from the SDG database.

  • A data frame with columns TERM_LEVEL and TERM_NAME or TERM_ID can be specified to define the terms of a customized query. The TERM_LEVEL should be set to the name of the variable which should be used to select the terms, e.g., "AEDECOD" or "AELLTCD". TERM_LEVEL does not need to be constant within a query. For example a query can be based on AEDECOD and AELLT.

    If TERM_LEVEL refers to a character variable, TERM_NAME should be set to the value the variable. If it refers to a numeric variable, TERM_ID should be set to the value of the variable. If only character variables or only numeric variables are used, TERM_ID or TERM_NAME respectively can be omitted.

  • A list of data frames and smq_select() objects can be specified to define a customized query based on custom terms and SMQs. The data frames must have the same structure as described for the previous item.

Permitted Values: an smq_select() object, an sdg_select() object, a data frame, or a list of data frames and smq_select() objects.

Value

An object of class query.

Author(s)

Stefan Bundfuss

See Also

create_query_data(), smq_select(), sdg_select(), Queries Dataset Documentation

Source Specifications: assert_db_requirements(), assert_terms(), assert_valid_queries(), censor_source(), date_source(), death_event, derive_var_dthcaus(), event_source(), extend_source_datasets(), filter_date_sources(), format.sdg_select(), format.smq_select(), list_tte_source_objects(), params(), sdg_select(), smq_select(), tte_source(), validate_query(), validate_sdg_select(), validate_smq_select()

Examples


# create a query for an SMQ
library(tibble)
library(magrittr, warn.conflicts = FALSE)
library(dplyr, warn.conflicts = FALSE)

query(
  prefix = "SMQ02",
  id = auto,
  definition = smq_select(
    name = "Pregnancy and neonatal topics (SMQ)",
    scope = "NARROW"
  )
)

# create a query for an SDG
query(
  prefix = "SDG01",
  id = auto,
  definition = sdg_select(
    name = "5-aminosalicylates for ulcerative colitis"
  )
)

# creating a query for a customized query
cqterms <- tribble(
  ~TERM_NAME, ~TERM_ID,
  "APPLICATION SITE ERYTHEMA", 10003041L,
  "APPLICATION SITE PRURITUS", 10003053L
) %>%
  mutate(TERM_LEVEL = "AEDECOD")

query(
  prefix = "CQ01",
  name = "Application Site Issues",
  definition = cqterms
)

# creating a customized query based on SMQs and additional terms
query(
  prefix = "CQ03",
  name = "Special issues of interest",
  definition = list(
    cqterms,
    smq_select(
      name = "Pregnancy and neonatal topics (SMQ)",
      scope = "NARROW"
    ),
    smq_select(
      id = 8050L,
      scope = "BROAD"
    )
  )
)

[Package admiral version 0.8.4 Index]