Search for a Code in the Concept Table

search_code(
  code_pattern,
  ignore.case = FALSE,
  perl = FALSE,
  fixed = FALSE,
  useBytes = FALSE,
  vocab_schema = "omop_vocabulary",
  limit = NULL,
  conn,
  conn_fun = "connectAthena()",
  cache_only = FALSE,
  skip_cache = FALSE,
  override_cache = FALSE,
  verbose = TRUE,
  render_sql = TRUE,
  sleepTime = 1
)

Arguments

code_pattern

Regex pattern of code

conn

Connection object. If provided, diverts queries to the connection instead of the local Athena instance without caching features.

cache_only

Loads from the cache and does not query the database. A NULL object is returned if a resultset was not cached.

skip_cache

Skip the caching altogether and directly query the database.

override_cache

If TRUE, the cache will not be loaded and will be overwritten by a new query. For override_cache to take effect, skip_cache should be FALSE.

verbose

If TRUE, prints loading and querying operations messages to the console. Default: FALSE

render_sql

If TRUE, the SQL will be printed back in the console prior to execution. Default: FALSE

sleepTime

Argument for `Sys.sleep()` in between queries to allow for halting function execution, especially in cases where other chariot functions are executing multiple queries in succession and require cancellation.

Value

resultset as a dataframe with all column types as character and trimmed white space

Examples

if(interactive()){ search_code(code_pattern = "^C40") }
#> [2021-05-26 16:07:39] Connected to 'athena' #> [2021-05-26 16:07:39] Loading Cache... #> [2021-05-26 16:07:39] Cached SQL: SELECT * #> FROM omop_vocabulary.concept #> WHERE LOWER(concept_code) LIKE '%%c40%' #> [2021-05-26 16:07:39] Cached resultset found... #> [2021-05-26 16:07:39] Postgres connection to 'athena' closed
#> # A tibble: 179 x 10 #> concept_id concept_name domain_id vocabulary_id concept_class_id #> <int> <chr> <chr> <chr> <chr> #> 1 705913 prucalopride Drug MeSH Suppl Concept #> 2 979962 mintlactone Drug MeSH Suppl Concept #> 3 1036764 2-methoxy-4-prop-1-enylp… Drug MeSH Suppl Concept #> 4 1405897 Malignant neoplasm of bo… Condition ICD10CN ICD10 Hierarchy #> 5 1405898 Malignant neoplasm: Scap… Condition ICD10CN ICD10 code #> 6 1405899 Malignant neoplasm: Scap… Condition ICD10CN ICD10 code #> 7 1405900 Scapula cancer (machine … Condition ICD10CN ICD10 code #> 8 1405901 Humerus cancer (machine … Condition ICD10CN ICD10 code #> 9 1405902 Ulna cancer (machine tra… Condition ICD10CN ICD10 code #> 10 1405903 Radial bone cancer (mach… Condition ICD10CN ICD10 code #> # … with 169 more rows, and 5 more variables: standard_concept <chr>, #> # concept_code <chr>, valid_start_date <date>, valid_end_date <date>, #> # invalid_reason <chr>