darwin-eu / darwin-eu/DrugUtilisation

How to add route information to cohort?

Open
#17 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
R
Stars
1
Forks
1
Avg merge
17m
Merged PRs (30d)
1

Description

Hi,

I was wondering what is the best way to add route information to a cohort?

```r
j01c_desc <- getATCCodes(cdm = cdm,
level = "ATC 3rd",
name = "BETA-LACTAM ANTIBACTERIALS, PENICILLINS",
type = "codelist")

cdm <- generateDrugUtilisationCohortSet(
cdm = cdm,
name = "beta_lactam_penicillins_exposures",
conceptSet = j01c_desc,
gapEra = 0,
daysPrescribed = TRUE,
numberExposures = TRUE
)
```

At this point the rows have been collapsed down to subject_id, start_date, end_date, so I can't join it back to drug exposure to get the route.

I can do it manually like this:

```r
cdm$drug_exposure %>%
inner_join(
cdm$visit_occurrence %>%
filter(visit_concept_id %in% c(9201, 262)),
by = join_by("visit_occurrence_id", within(drug_exposure_start_date, drug_exposure_end_date, visit_start_date, visit_end_date))
) %>%
left_join(
cdm$concept %>%
select(
route_concept_id = concept_id,
route_name = concept_name
),
by = "route_concept_id"
) %>%
filter(drug_concept_id %in% j01c_desc$J01C_beta_lactam_antibacterials_penicillins ) %>%
group_by(route_name) %>%
summarise(n_persons = n_distinct(person_id.x),
n_visits = n_distinct(visit_occurrence_id))
```

But ideally I would like to include this per row in the cohort and then use CohortCharacteristics::summariseCharacteristics & tableCharacteristics to summarize this along with other variables. I also have multiple cohorts (based on j01c_desc, j01d_desc, j01e_desc etc.)

Any advice would be appreciated,

Thank you!

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.