TreatmentPatterns

Maarten van Kessel

2025-07-06

Installation

Setup

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: -

Disclaimer

Everything we do today uses Synthetic data

Study Question

Patterns of treatments before, during, and after Viral Sinusitis

Indication Windows:

  1. Two weeks prior Viral Sinusitis
  2. During Viral Sinusitis
  3. Two weeks after Viral Sinusitis

Treatments of interest:

  1. Acetaminophen
  2. Amoxicillin
  3. Aspirin
  4. Clavunate
  5. Doxylamine
  6. Penicillin V

Patterns of treatments before, during, and after Viral Sinusitis

TreatmentPatterns options

Interfacing with the CDM

  • cohorts: Table dictating which cohort is of what type.
  • cohortTableName: Name of the cohort table(s) to use.
  • CDM interface: Either through CDMConnector or DatabaseConnector

Interfacing with the CDM

CDMConnector

  • cdm: CDM-reference to use.

DatabaseConnector

  • connectionDetails: ConnectionDetails object.
  • cdmSchema: Schema where the CDM resides.
  • resultSchema: Schema where the cohort table resides.
  • tempEmulationSchema: Temp schema.

Analysis Information

  • analysisId: ID to identify the analysis.
  • description: Description of the analysis.

Windowing

  • startAnchor: Anchor on Start or End date.
  • windowStart: Offset of startAnchor.
  • endAnchor: Anchor on Start or End date.
  • windowEnd: Offset of endAnchor.

Pathway construction

  • minEraDuration: Minimum duration of events.
  • combinationWindow: Minimum overlap between events to be considered a combination event.
  • minPostCombinationDuration: Minimum duration of (combination) events to keep after combining events.
  • concatTargets: Should multiple targets be concatenated, or treated as separate events?
  • filterTreatments: Which events should we consider?

Execution

Generating Cohorts

cohortSet <- readCohortSet(path = "./cohorts")

cdm <- generateCohortSet(cdm = cdm, cohortSet = cohortSet, name = "cohort_table")

Cohort Counts

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

Viral Sinusitis Attrition

attrition(cdm$cohort_table) |>
  # ID 7 == Viral Sinusitis
  filter(cohort_definition_id == 7)
# 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>

Target and Events

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

Two Weeks Prior to Viral Sinusitis

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 Viral Sinusitis

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

Two Weeks After Viral Sinusitis

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

Exporting

priorRes <- export(weekPrior, minCellCount = 5, censorType = "remove")
duringRes <- export(during, minCellCount = 5, censorType = "remove")
afterRes <- export(after, minCellCount = 5, censorType = "remove")

Counts

data.frame(
  label = c("Week Prior", "During", "Week Post"),
  count = c(
    sum(priorRes$treatment_pathways$freq),
    sum(duringRes$treatment_pathways$freq),
    sum(afterRes$treatment_pathways$freq)
  )
)
       label count
1 Week Prior    49
2     During  1814
3  Week Post    33

Sunburst Plots

Two weeks Prior

Legend

During

Legend

Two weeks after

Legend

Event time

duringRes$plotEventDuration()

Conclusion

  1. Significantly less use of treatments of interest two weeks before and after Viral Sinusitis.
  2. Pattern of use of treatments in period before and after Viral Sinusitis seems similar.
  3. Treatment during Viral Sinusitis is dominated by Amoxicillin + Clavunate (7 day overlap) with 93% with Clavunate as monotherapy following up with 5.9%. Both do not occur outside the Viral Sinusitis window.
  4. Clavunate and Acetaminophen were used as a second-line treatment, but in a negotiable amount of subjects.