-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworking_with_cohorts.qmd
65 lines (47 loc) · 1.97 KB
/
working_with_cohorts.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
## Working with cohorts
## Cohort intersections
PatientProfiles::addCohortIntersect()
## Intersection between two cohorts
## Set up
```{r, warning=FALSE, message=FALSE}
library(CDMConnector)
library(dplyr)
library(PatientProfiles)
# For this example we will use GiBleed data set
CDMConnector::downloadEunomiaData(datasetName = "GiBleed")
db <- DBI::dbConnect(duckdb::duckdb(), eunomia_dir())
cdm <- cdmFromCon(db, cdmSchema = "main", writeSchema = "main")
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)
```
### Flag
```{r, warning=FALSE, message=FALSE}
cdm$gi_bleed <- cdm$gi_bleed |>
addCohortIntersectFlag(targetCohortTable = "acetaminophen",
window = list(c(-Inf, -1), c(0,0), c(1, Inf)))
cdm$gi_bleed |>
summarise(acetaminophen_prior = sum(acetaminophen_minf_to_m1),
acetaminophen_index = sum(acetaminophen_0_to_0),
acetaminophen_post = sum(acetaminophen_1_to_inf)) |>
collect()
```
### Count
### Date and times
## Intersection between a cohort and tables with patient data
# Further reading
- ...