library(CDMConnector)
library(dplyr)
library(PatientProfiles)
# For this example we will use GiBleed data set
::downloadEunomiaData(datasetName = "GiBleed")
CDMConnector<- DBI::dbConnect(duckdb::duckdb(), eunomia_dir())
db
<- cdmFromCon(db, cdmSchema = "main", writeSchema = "main")
cdm
<- cdm |>
cdm generate_concept_cohort_set(concept_set = list("gi_bleed" = 192671),
limit = "all",
end = 30,
name = "gi_bleed",
overwrite = TRUE) |>
generate_concept_cohort_set(concept_set = list("acetaminophen" = c(1125315,
1127078,
1127433,
40229134,
40231925,
40162522,
19133768)),
limit = "all",
# end = "event_end_date",
name = "acetaminophen",
overwrite = TRUE)
9 Working with cohorts
9.1 Cohort intersections
PatientProfiles::addCohortIntersect()
9.2 Intersection between two cohorts
9.3 Set up
9.3.1 Flag
$gi_bleed <- cdm$gi_bleed |>
cdmaddCohortIntersectFlag(targetCohortTable = "acetaminophen",
window = list(c(-Inf, -1), c(0,0), c(1, Inf)))
$gi_bleed |>
cdmsummarise(acetaminophen_prior = sum(acetaminophen_minf_to_m1),
acetaminophen_index = sum(acetaminophen_0_to_0),
acetaminophen_post = sum(acetaminophen_1_to_inf)) |>
collect()
# A tibble: 1 × 3
acetaminophen_prior acetaminophen_index acetaminophen_post
<dbl> <dbl> <dbl>
1 467 467 476
9.3.2 Count
9.3.3 Date and times
9.4 Intersection between a cohort and tables with patient data
10 Further reading
- …