knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

Package Load

library(OncoRegimenFinder)
library(fantasia)
conn <- fantasia::connectOMOP()

Parameters

It is recommended that the parameters are centralized at the start of execution to ensure that arguments remain consistent across all function calls.

# Schema of Source Person and Drug Exposure Tables
cdmDatabaseSchema = "omop_cdm_2"

# Output Schema and Tables
writeDatabaseSchema = "patelm9"
cohortTable = "oncoregimenfinder_cohort"
regimenTable = "oncoregimenfinder_regimen"
regimenStagingTable = "oncoregimenfinder_regimen_staging"
vocabularyTable = "oncoregimenfinder_vocabulary"
regimenIngredientTable= "oncoregimenfinder_regimen_ingredients"

# OMOP Vocabulary Drug Classes to filter Drug Exposures for
drug_classification_id_input = c(21601387,
                                35807188,
                                35807277,
                                35807189)

# Date difference when assessing for drug combinations in the Drug Exposures table
date_lag_input = 30
regimen_repeats = 5

Steps

  1. Cohort, Regimen, and a copy of Regimen as "Regimen Staging" Tables are written. Tables that are already present in the schema are copied to a new table appended with the date.
  2. Regimen Table undergoes further processing by combining overlapping instances of an ingredient start date and +/- the date lag input over the number of regimen repeats desired.
  3. A Separate Vocabulary Table is created that maps the HemOnc Regimen Concept Name to string aggregates of the individual Component Concept Names
  4. A final Regimen Ingredient Table joins the Vocabulary Table with the Regimen Table to map drug combinations derived from this algorithm back to HemOnc and other OMOP Concepts

Create Cohort, Regimen and Regimen Staging Tables

OncoRegimenFinder::buildCohortRegimenTable(conn = conn,
                                           cdmDatabaseSchema = "omop_cdm_2",
                                           writeDatabaseSchema = "patelm9",
                                           cohortTable = "oncoregimenfinder_cohort",
                                           regimenTable = "oncoregimenfinder_regimen",
                                           drug_classification_id_input = c(21601387,
                                                                            35807188,
                                                                            35807277,
                                                                            35807189))
Cohort Table

The Cohort Table includes the Person Id, Drug Exposure Id with Start and End Dates, and Ingredient representing that Drug Exposure filtered for all descendants of the Drug Classification Concept Id argument.

cohortTable <-
  pg13::query(conn = conn,
              sql_statement = pg13::buildQuery(schema = "patelm9",
                                               tableName = "oncoregimenfinder_cohort",
                                               n = 20,
                                               n_type = "random"))

print(cohortTable)
Regimen Staging Table

The Regimen and Regimen Staging Tables, are identical to one another at this point, are a subset of Cohort Table of the Person Id, Drug Exposure Id, Ingredient Name, and the Start Date of exposure to that Ingredient. The Regimen Table will be processed further while the Regimen Staging Table serves as a reference back to the Regimen Table's original state before being processed by algorithm.

regimenStagingTable <-
  pg13::query(conn = conn,
              sql_statement = pg13::buildQuery(schema = "patelm9",
                                               tableName = "oncoregimenfinder_regimen_staging",
                                               n = 20,
                                               n_type = "random"))

print(regimenStagingTable)

Processing the Regimen Table

The Regimen Table is grouped by Person Id, Drug Exposure Id, Ingredient and Ingredient Start Date and joined onto itself based on overlapping window of time by +/= the Date Lag Input parameter and iterated on based on the Regimen Repeats given.

OncoRegimenFinder::processRegimenTable(conn = conn,
                    writeDatabaseSchema = "patelm9",
                    regimenTable = "oncoregimenfinder_regimen",
                    date_lag_input = 30,
                    regimen_repeats = 5)
Regimen Table
regimenTable <-
  pg13::query(conn = conn,
              sql_statement = pg13::buildQuery(schema = "patelm9",
                                               tableName = "oncoregimenfinder_regimen",
                                               n = 20,
                                               n_type = "random"))

print(regimenTable)

Create Vocabulary Table

OncoRegimenFinder::createVocabTable(conn = conn,
                                    writeDatabaseSchema = "patelm9",
                                    cdmDatabaseSchema = "omop_cdm_2",
                                    vocabularyTable = "oncoregimenfinder_vocabulary")
Vocabulary Table
vocabularyTable <-
  pg13::query(conn = conn,
              sql_statement = pg13::buildQuery(schema = "patelm9",
                                               tableName = "oncoregimenfinder_vocabulary",
                                               n = 20,
                                               n_type = "random"))

print(vocabularyTable)

Final Step: Creating the Regimen Ingredient Table

createRegimenIngrTable(conn = conn,
                       writeDatabaseSchema = "patelm9",
                       cohortTable = "oncoregimenfinder_cohort",
                       regimenTable = "oncoregimenfinder_regimen",
                       regimenIngredientTable = "oncoregimenfinder_regimen_ingredients",
                       vocabularyTable = "oncoregimenfinder_vocabulary")
Regimen Ingredient Table
regimenIngrTable <-
  pg13::query(conn = conn,
              sql_statement = pg13::buildQuery(schema = "patelm9",
                                               tableName = "oncoregimenfinder_regimen_ingredients",
                                               n = 20,
                                               n_type = "random"))

print(regimenIngrTable)
fantasia::dcOMOP(conn = conn,
                 remove = TRUE)


meerapatelmd/OncoRegimenFinder documentation built on Jan. 1, 2021, 9:25 a.m.