2025-07-06
datasetName <- "GiBleed"
requireEunomia(datasetName = datasetName)
con <- dbConnect(drv = duckdb(dbdir = eunomiaDir(datasetName = datasetName)))
cdm <- cdmFromCon(con = con, cdmSchema = "main", writeSchema = "main", cdmName = datasetName)
cdm
── # OMOP CDM reference (duckdb) of GiBleed ────────────────────────────────────
• omop tables: person, observation_period, visit_occurrence, visit_detail,
condition_occurrence, drug_exposure, procedure_occurrence, device_exposure,
measurement, observation, death, note, note_nlp, specimen, fact_relationship,
location, care_site, provider, payer_plan_period, cost, drug_era, dose_era,
condition_era, metadata, cdm_source, concept, vocabulary, domain,
concept_class, concept_relationship, relationship, concept_synonym,
concept_ancestor, source_to_concept_map, drug_strength
• cohort tables: -
• achilles tables: -
• other tables: -
Everything we do today uses Synthetic data
Indication Windows:
Treatments of interest:
cohortSet <- readCohortSet(path = "./cohorts")
cdm <- generateCohortSet(cdm = cdm, cohortSet = cohortSet, name = "cohort_table")
cohortCount(cdm$cohort_table)
# A tibble: 7 × 3
cohort_definition_id number_records number_subjects
<int> <int> <int>
1 1 2679 2679
2 2 2130 2130
3 3 1927 1927
4 4 2021 2021
5 5 1393 1393
6 6 1732 1732
7 7 17072 2686
# A tibble: 2 × 7
cohort_definition_id number_records number_subjects reason_id reason
<int> <int> <int> <int> <chr>
1 7 17072 2686 1 Qualifying init…
2 7 17072 2686 2 Cohort records …
# ℹ 2 more variables: excluded_records <int>, excluded_subjects <int>
cohorts <- cohortSet |>
select(cohortId = "cohort_definition_id", cohortName = "cohort_name") |>
mutate(type = c(rep("event", 6), "target"))
cohorts
# A tibble: 7 × 3
cohortId cohortName type
<int> <chr> <chr>
1 1 acetaminophen event
2 2 amoxicillin event
3 3 aspirin event
4 4 clavunate event
5 5 doxylamine event
6 6 penicillin_v event
7 7 viral_sinusitis target
weekPrior <- computePathways(
cohorts = cohorts,
cohortTableName = "cohort_table",
cdm = cdm,
analysisId = 1,
description = "Two weeks prior",
startAnchor = "startDate",
windowStart = -14,
endAnchor = "startDate",
windowEnd = -1,
minEraDuration = 5,
combinationWindow = 7,
minPostCombinationDuration = 5,
concatTargets = FALSE,
filterTreatments = "All"
)
-- Qualifying records for cohort definitions: 1, 2, 3, 4, 5, 6, 7
Records: 28954
Subjects: 2694
-- Removing records < minEraDuration (5)
Records: 28866
Subjects: 2686
>> Starting on target: 7 (viral_sinusitis)
-- Removing events outside window (startDate: -14 | startDate: -1)
Records: 50
Subjects: 48
-- splitEventCohorts
Records: 50
Subjects: 48
-- Collapsing eras, eraCollapse (30)
Records: 50
Subjects: 48
-- Iteration 1: minPostCombinationDuration (5), combinatinoWindow (7)
Records: 49
Subjects: 48
-- After Combination
Records: 49
Subjects: 48
-- filterTreatments (All)
Records: 49
Subjects: 48
-- Max path length (5)
Records: 49
Subjects: 48
-- treatment construction done
Records: 49
Subjects: 48
during <- computePathways(
cohorts = cohorts,
cohortTableName = "cohort_table",
cdm = cdm,
analysisId = 2,
description = "During",
startAnchor = "startDate",
windowStart = 0,
endAnchor = "endDate",
windowEnd = 0,
minEraDuration = 5,
combinationWindow = 7,
minPostCombinationDuration = 5,
concatTargets = FALSE,
filterTreatments = "All"
)
-- Qualifying records for cohort definitions: 1, 2, 3, 4, 5, 6, 7
Records: 28954
Subjects: 2694
-- Removing records < minEraDuration (5)
Records: 28866
Subjects: 2686
>> Starting on target: 7 (viral_sinusitis)
-- Removing events outside window (startDate: 0 | endDate: 0)
Records: 3506
Subjects: 1801
-- splitEventCohorts
Records: 3506
Subjects: 1801
-- Collapsing eras, eraCollapse (30)
Records: 3506
Subjects: 1801
-- Iteration 1: minPostCombinationDuration (5), combinatinoWindow (7)
Records: 1817
Subjects: 1801
-- Iteration 2: minPostCombinationDuration (5), combinatinoWindow (7)
Records: 1816
Subjects: 1801
-- After Combination
Records: 1816
Subjects: 1801
-- filterTreatments (All)
Records: 1816
Subjects: 1801
-- Max path length (5)
Records: 1816
Subjects: 1801
-- treatment construction done
Records: 1816
Subjects: 1801
after <- computePathways(
cohorts = cohorts,
cohortTableName = "cohort_table",
cdm = cdm,
analysisId = 3,
description = "Two weeks after",
startAnchor = "endDate",
windowStart = 0,
endAnchor = "endDate",
windowEnd = 14,
minEraDuration = 5,
combinationWindow = 7,
minPostCombinationDuration = 5,
concatTargets = FALSE,
filterTreatments = "All"
)
-- Qualifying records for cohort definitions: 1, 2, 3, 4, 5, 6, 7
Records: 28954
Subjects: 2694
-- Removing records < minEraDuration (5)
Records: 28866
Subjects: 2686
>> Starting on target: 7 (viral_sinusitis)
-- Removing events outside window (endDate: 0 | endDate: 14)
Records: 34
Subjects: 33
-- splitEventCohorts
Records: 34
Subjects: 33
-- Collapsing eras, eraCollapse (30)
Records: 34
Subjects: 33
-- Iteration 1: minPostCombinationDuration (5), combinatinoWindow (7)
Records: 33
Subjects: 33
-- After Combination
Records: 33
Subjects: 33
-- filterTreatments (All)
Records: 33
Subjects: 33
-- Max path length (5)
Records: 33
Subjects: 33
-- treatment construction done
Records: 33
Subjects: 33
duringRes$plotEventDuration()