Skip to contents

CRANstatus codecov.io R-CMD-check Lifecycle:Experimental

WARNING: This package is under development.

  • addDailyDose function works for the following patterns in the drug_strength table:
amount amount_unit numerator numerator_unit denominator denominator_unit
concentration formulation: quantity * numerator / days exposed
- - number international unit number milligram
- - number international unit number milliliter
- - number milliequivalent number milliliter
- - number milligram number Actuation
- - number milligram number liter
- - number milligram number milligram
- - number milligram number milliliter
- - number milligram number square centimeter
- - number milliliter number milligram
- - number milliliter number milliliter
- - number unit number Actuation
- - number unit number milligram
- - number unit number milliliter
- - number unit number square centimeter
- - number international unit - milligram
- - number international unit - milliliter
- - number mega-international unit - milliliter
- - number milliequivalent - milligram
- - number milliequivalent - milliliter
- - number milligram - Actuation
- - number milligram - liter
- - number milligram - milligram
- - number milligram - milliliter
- - number milligram - square centimeter
- - number milliliter - milligram
- - number milliliter - milliliter
- - number unit - Actuation
- - number unit - milligram
- - number unit - milliliter
- - number unit - square centimeter
fixed amount formulation: quantity * amount / days exposed
number international unit - - - -
number microgram - - - -
number milliequivalent - - - -
number milligram - - - -
number milliliter - - - -
number unit - - - -
time based no denominator: 24 * numerator
- - number microgram - hour
- - number milligram - hour
time based with denominator: if (denominator>24) {numerator * 24 / denominator} else {numerator}
- - number microgram number hour
- - number milligram number hour
- - number unit number hour

Package overview

DrugUtilisation contains functions to instantiate and characterize the cohorts used in a Drug Utilisation Study in the OMOP common data model. Main functionalities are:

  • Create DrugUtilisation cohorts

  • Add indications to this cohort

  • Add the dosage of a certain ingredient (subseted for a list of drugs)

  • Calculate the daily dose

  • Create Concept based cohorts

  • Read concepts from json files

  • Summarise the drug use in a certain cohort

  • Summarise the indications in a certain cohort

  • Summarise the patients characteristics in a certain cohort

  • Summarise the patients large scale characterics in a certain cohort

Example

First, we need to create a cdm reference for the data we´ll be using. Here we´ll generate an example with simulated data, but to see how you would set this up for your database please consult the CDMConnector package connection examples.

The package also provides a functionality to generate a mockDrugUtilisation cdm reference:

library(DrugUtilisation)
cdm <- mockDrugUtilisation(numberIndividual = 100)

Create a cohort of drug use

To create a cohort we will need a conceptList, this can be read from json files:

conceptList <- readConceptList(here::here("Concepts"), cdm)

Or we can build our own list using other packages (e.g. CodelistGenerator)

library(CodelistGenerator)
#> Warning: package 'CodelistGenerator' was built under R version 4.2.3
conceptList <- getDrugIngredientCodes(cdm, "acetaminophen")
conceptList
#> 
#> ── 1 codelist ──────────────────────────────────────────────────────────────────
#> 
#> - acetaminophen (4 codes)

To generate the cohort of drug use we will use generateDrugUtilisationCohortSet:

cdm <- generateDrugUtilisationCohortSet(
  cdm = cdm,
  name = "dus_cohort",
  conceptSet = conceptList,
  limit = "first",
  priorObservation = 365,
  gapEra = 30,
  priorUseWashout = 0,
  imputeDuration = "none", 
  durationRange = c(0, Inf)
)

Cohort attributes

The generated cohort will have the GeneratedCohortSet as seen in CDMConnector

class(cdm[["dus_cohort"]])
#> [1] "cohort_table"          "GeneratedCohortSet"    "cdm_table"            
#> [4] "tbl_duckdb_connection" "tbl_dbi"               "tbl_sql"              
#> [7] "tbl_lazy"              "tbl"

Cohort set:

library(CDMConnector)
library(dplyr)
#> Warning: package 'dplyr' was built under R version 4.2.3
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
settings(cdm[["dus_cohort"]]) %>% glimpse()
#> Rows: 1
#> Columns: 11
#> $ cohort_definition_id    <int> 1
#> $ cohort_name             <chr> "acetaminophen"
#> $ duration_range_min      <chr> "0"
#> $ duration_range_max      <chr> "Inf"
#> $ impute_duration         <chr> "none"
#> $ gap_era                 <chr> "30"
#> $ prior_use_washout       <chr> "0"
#> $ prior_observation       <chr> "365"
#> $ cohort_date_range_start <chr> NA
#> $ cohort_date_range_end   <chr> NA
#> $ limit                   <chr> "first"

Cohort count:

cohortCount(cdm[["dus_cohort"]])
#> # A tibble: 1 × 3
#>   cohort_definition_id number_records number_subjects
#>                  <int>          <int>           <int>
#> 1                    1             35              35

Cohort attrition:

attrition(cdm[["dus_cohort"]]) %>% glimpse()
#> Rows: 4
#> Columns: 7
#> $ cohort_definition_id <int> 1, 1, 1, 1
#> $ number_records       <int> 71, 70, 41, 35
#> $ number_subjects      <int> 62, 62, 35, 35
#> $ reason_id            <int> 1, 2, 3, 4
#> $ reason               <chr> "Initial qualifying events", "join exposures sepa…
#> $ excluded_records     <int> 0, 1, 29, 6
#> $ excluded_subjects    <int> 0, 0, 27, 0

Indication

Indications will always be cohorts. An option that the package has is to create concept based cohorts using generateConceptCohortSet.

indications <- list(headache = 378253, influenza = 4266367)
cdm <- generateConceptCohortSet(cdm, indications, "indications_cohort")
cohortCount(cdm[["indications_cohort"]])
#> # A tibble: 2 × 3
#>   cohort_definition_id number_records number_subjects
#>                  <int>          <int>           <int>
#> 1                    1             52              52
#> 2                    2             46              46

Then we can add the indication using the function addIndication. That will add a new column for each indication gap and indication.

x <- cdm[["dus_cohort"]] %>%
  addIndication(
    cdm = cdm, indicationCohortName = "indications_cohort", indicationGap = c(0, 30, 365), 
    unknownIndicationTable = c("condition_occurrence")
  )
#> Warning: The `cdm` argument of `addIndication()` is deprecated as of DrugUtilisation
#> 0.5.0.
#> This warning is displayed once every 8 hours.
#> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
#> generated.
glimpse(x)
#> Rows: ??
#> Columns: 16
#> Database: DuckDB v0.10.0 [martics@Windows 10 x64:R 4.2.1/:memory:]
#> $ cohort_definition_id         <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,…
#> $ subject_id                   <int> 23, 40, 45, 51, 87, 95, 29, 47, 93, 26, 9…
#> $ cohort_start_date            <date> 2003-10-29, 2018-11-15, 2017-07-03, 2017…
#> $ cohort_end_date              <date> 2003-11-27, 2020-03-07, 2018-07-06, 2017…
#> $ indication_gap_0_headache    <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
#> $ indication_gap_0_influenza   <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
#> $ indication_gap_0_none        <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,…
#> $ indication_gap_0_unknown     <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
#> $ indication_gap_30_headache   <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
#> $ indication_gap_30_influenza  <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
#> $ indication_gap_30_none       <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,…
#> $ indication_gap_30_unknown    <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
#> $ indication_gap_365_influenza <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0,…
#> $ indication_gap_365_headache  <dbl> 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
#> $ indication_gap_365_none      <dbl> 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0,…
#> $ indication_gap_365_unknown   <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,…

We can combine the indications in a single column using the indicationToStrata() function. This column can be used as stratification of the results if needed:

x <- x %>% indicationToStrata(keep = TRUE)
glimpse(x)
#> Rows: ??
#> Columns: 19
#> Database: DuckDB v0.10.0 [martics@Windows 10 x64:R 4.2.1/:memory:]
#> $ cohort_definition_id         <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,…
#> $ subject_id                   <int> 23, 40, 45, 51, 87, 95, 29, 47, 93, 26, 9…
#> $ cohort_start_date            <date> 2003-10-29, 2018-11-15, 2017-07-03, 2017…
#> $ cohort_end_date              <date> 2003-11-27, 2020-03-07, 2018-07-06, 2017…
#> $ indication_gap_0_headache    <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
#> $ indication_gap_0_influenza   <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
#> $ indication_gap_0_none        <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,…
#> $ indication_gap_0_unknown     <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
#> $ indication_gap_30_headache   <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
#> $ indication_gap_30_influenza  <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
#> $ indication_gap_30_none       <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,…
#> $ indication_gap_30_unknown    <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
#> $ indication_gap_365_influenza <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0,…
#> $ indication_gap_365_headache  <dbl> 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,…
#> $ indication_gap_365_none      <dbl> 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0,…
#> $ indication_gap_365_unknown   <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,…
#> $ indication_gap_0             <chr> "None", "None", "None", "None", "None", "…
#> $ indication_gap_30            <chr> "None", "None", "None", "None", "None", "…
#> $ indication_gap_365           <chr> "None", "None", "None", "Headache", "None…
table(x %>% pull("indication_gap_365"))
#> 
#>  Headache Influenza      None   Unknown 
#>         2         3        27         3

Summarise the indication

We can summarise the indication results using the summariseIndication function:

summariseIndication(x, cdm)
#> Warning: The `functions` argument of `summariseResult()` is deprecated as of
#> PatientProfiles 0.7.0.
#> ℹ Please use the `estimates` argument instead.
#> ℹ The deprecated feature was likely used in the DrugUtilisation package.
#>   Please report the issue to the authors.
#> This warning is displayed once every 8 hours.
#> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
#> generated.
#> ℹ The following estimates will be computed:
#> • indication_gap_0_headache: count, percentage
#> • indication_gap_0_influenza: count, percentage
#> • indication_gap_0_none: count, percentage
#> • indication_gap_0_unknown: count, percentage
#> • indication_gap_30_headache: count, percentage
#> • indication_gap_30_influenza: count, percentage
#> • indication_gap_30_none: count, percentage
#> • indication_gap_30_unknown: count, percentage
#> • indication_gap_365_influenza: count, percentage
#> • indication_gap_365_headache: count, percentage
#> • indication_gap_365_none: count, percentage
#> • indication_gap_365_unknown: count, percentage
#> • indication_gap_0: count, percentage
#> • indication_gap_30: count, percentage
#> • indication_gap_365: count, percentage
#> → Start summary of data, at 2024-04-04 15:44:18
#> 
#> ✔ Summary finished, at 2024-04-04 15:44:18
#> # A tibble: 42 × 16
#>    result_id cdm_name result_type        package_name package_version group_name
#>        <int> <chr>    <chr>              <chr>        <chr>           <chr>     
#>  1         1 DUS MOCK summarised_indica… DrugUtilisa… 0.5.3           cohort_na…
#>  2         1 DUS MOCK summarised_indica… DrugUtilisa… 0.5.3           cohort_na…
#>  3         1 DUS MOCK summarised_indica… DrugUtilisa… 0.5.3           cohort_na…
#>  4         1 DUS MOCK summarised_indica… DrugUtilisa… 0.5.3           cohort_na…
#>  5         1 DUS MOCK summarised_indica… DrugUtilisa… 0.5.3           cohort_na…
#>  6         1 DUS MOCK summarised_indica… DrugUtilisa… 0.5.3           cohort_na…
#>  7         1 DUS MOCK summarised_indica… DrugUtilisa… 0.5.3           cohort_na…
#>  8         1 DUS MOCK summarised_indica… DrugUtilisa… 0.5.3           cohort_na…
#>  9         1 DUS MOCK summarised_indica… DrugUtilisa… 0.5.3           cohort_na…
#> 10         1 DUS MOCK summarised_indica… DrugUtilisa… 0.5.3           cohort_na…
#> # ℹ 32 more rows
#> # ℹ 10 more variables: group_level <chr>, strata_name <chr>,
#> #   strata_level <chr>, variable_name <chr>, variable_level <chr>,
#> #   estimate_name <chr>, estimate_type <chr>, estimate_value <chr>,
#> #   additional_name <chr>, additional_level <chr>
summariseIndication(x, cdm) %>% glimpse()
#> ℹ The following estimates will be computed:
#> • indication_gap_0_headache: count, percentage
#> • indication_gap_0_influenza: count, percentage
#> • indication_gap_0_none: count, percentage
#> • indication_gap_0_unknown: count, percentage
#> • indication_gap_30_headache: count, percentage
#> • indication_gap_30_influenza: count, percentage
#> • indication_gap_30_none: count, percentage
#> • indication_gap_30_unknown: count, percentage
#> • indication_gap_365_influenza: count, percentage
#> • indication_gap_365_headache: count, percentage
#> • indication_gap_365_none: count, percentage
#> • indication_gap_365_unknown: count, percentage
#> • indication_gap_0: count, percentage
#> • indication_gap_30: count, percentage
#> • indication_gap_365: count, percentage
#> → Start summary of data, at 2024-04-04 15:44:19
#> 
#> ✔ Summary finished, at 2024-04-04 15:44:19
#> Rows: 42
#> Columns: 16
#> $ result_id        <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,…
#> $ cdm_name         <chr> "DUS MOCK", "DUS MOCK", "DUS MOCK", "DUS MOCK", "DUS …
#> $ result_type      <chr> "summarised_indication", "summarised_indication", "su…
#> $ package_name     <chr> "DrugUtilisation", "DrugUtilisation", "DrugUtilisatio…
#> $ package_version  <chr> "0.5.3", "0.5.3", "0.5.3", "0.5.3", "0.5.3", "0.5.3",…
#> $ group_name       <chr> "cohort_name", "cohort_name", "cohort_name", "cohort_…
#> $ group_level      <chr> "acetaminophen", "acetaminophen", "acetaminophen", "a…
#> $ strata_name      <chr> "overall", "overall", "overall", "overall", "overall"…
#> $ strata_level     <chr> "overall", "overall", "overall", "overall", "overall"…
#> $ variable_name    <chr> "number records", "number subjects", "Indication on i…
#> $ variable_level   <chr> NA, NA, "Headache", "Headache", "Influenza", "Influen…
#> $ estimate_name    <chr> "count", "count", "count", "percentage", "count", "pe…
#> $ estimate_type    <chr> "integer", "integer", "integer", "percentage", "integ…
#> $ estimate_value   <chr> "35", "35", "0", "0", "0", "0", "35", "100", "0", "0"…
#> $ additional_name  <chr> "overall", "overall", "overall", "overall", "overall"…
#> $ additional_level <chr> "overall", "overall", "overall", "overall", "overall"…

Add strata

All summarise functions have the option to add strata. Strata will always point to preexisting columns. Here we can see an example where we create a age_group and sex columns using PatientProfiles and then we use it as strata

library(PatientProfiles)
x <- x %>%
  addAge(cdm, ageGroup = list(c(0, 19), c(20, 39), c(40, 59), c(60, 79), c(80, 150))) %>%
  addSex(cdm)
#> Warning: The `cdm` argument of `addSex()` is deprecated as of PatientProfiles 0.6.0.
#> This warning is displayed once every 8 hours.
#> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
#> generated.
#> Warning: The `cdm` argument of `addAge()` is deprecated as of PatientProfiles 0.6.0.
#> This warning is displayed once every 8 hours.
#> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
#> generated.
summariseIndication(x, cdm, strata = list("age_group", "sex", c("age_group", "sex")))
#> ℹ The following estimates will be computed:
#> • indication_gap_0_headache: count, percentage
#> • indication_gap_0_influenza: count, percentage
#> • indication_gap_0_none: count, percentage
#> • indication_gap_0_unknown: count, percentage
#> • indication_gap_30_headache: count, percentage
#> • indication_gap_30_influenza: count, percentage
#> • indication_gap_30_none: count, percentage
#> • indication_gap_30_unknown: count, percentage
#> • indication_gap_365_influenza: count, percentage
#> • indication_gap_365_headache: count, percentage
#> • indication_gap_365_none: count, percentage
#> • indication_gap_365_unknown: count, percentage
#> • indication_gap_0: count, percentage
#> • indication_gap_30: count, percentage
#> • indication_gap_365: count, percentage
#> → Start summary of data, at 2024-04-04 15:44:21
#> 
#> ✔ Summary finished, at 2024-04-04 15:44:22
#> # A tibble: 430 × 16
#>    result_id cdm_name result_type        package_name package_version group_name
#>        <int> <chr>    <chr>              <chr>        <chr>           <chr>     
#>  1         1 DUS MOCK summarised_indica… DrugUtilisa… 0.5.3           cohort_na…
#>  2         1 DUS MOCK summarised_indica… DrugUtilisa… 0.5.3           cohort_na…
#>  3         1 DUS MOCK summarised_indica… DrugUtilisa… 0.5.3           cohort_na…
#>  4         1 DUS MOCK summarised_indica… DrugUtilisa… 0.5.3           cohort_na…
#>  5         1 DUS MOCK summarised_indica… DrugUtilisa… 0.5.3           cohort_na…
#>  6         1 DUS MOCK summarised_indica… DrugUtilisa… 0.5.3           cohort_na…
#>  7         1 DUS MOCK summarised_indica… DrugUtilisa… 0.5.3           cohort_na…
#>  8         1 DUS MOCK summarised_indica… DrugUtilisa… 0.5.3           cohort_na…
#>  9         1 DUS MOCK summarised_indica… DrugUtilisa… 0.5.3           cohort_na…
#> 10         1 DUS MOCK summarised_indica… DrugUtilisa… 0.5.3           cohort_na…
#> # ℹ 420 more rows
#> # ℹ 10 more variables: group_level <chr>, strata_name <chr>,
#> #   strata_level <chr>, variable_name <chr>, variable_level <chr>,
#> #   estimate_name <chr>, estimate_type <chr>, estimate_value <chr>,
#> #   additional_name <chr>, additional_level <chr>
summariseIndication(x, cdm, strata = list("age_group", "sex", c("age_group", "sex"))) %>% glimpse()
#> ℹ The following estimates will be computed:
#> • indication_gap_0_headache: count, percentage
#> • indication_gap_0_influenza: count, percentage
#> • indication_gap_0_none: count, percentage
#> • indication_gap_0_unknown: count, percentage
#> • indication_gap_30_headache: count, percentage
#> • indication_gap_30_influenza: count, percentage
#> • indication_gap_30_none: count, percentage
#> • indication_gap_30_unknown: count, percentage
#> • indication_gap_365_influenza: count, percentage
#> • indication_gap_365_headache: count, percentage
#> • indication_gap_365_none: count, percentage
#> • indication_gap_365_unknown: count, percentage
#> • indication_gap_0: count, percentage
#> • indication_gap_30: count, percentage
#> • indication_gap_365: count, percentage
#> → Start summary of data, at 2024-04-04 15:44:22
#> 
#> ✔ Summary finished, at 2024-04-04 15:44:23
#> Rows: 430
#> Columns: 16
#> $ result_id        <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,…
#> $ cdm_name         <chr> "DUS MOCK", "DUS MOCK", "DUS MOCK", "DUS MOCK", "DUS …
#> $ result_type      <chr> "summarised_indication", "summarised_indication", "su…
#> $ package_name     <chr> "DrugUtilisation", "DrugUtilisation", "DrugUtilisatio…
#> $ package_version  <chr> "0.5.3", "0.5.3", "0.5.3", "0.5.3", "0.5.3", "0.5.3",…
#> $ group_name       <chr> "cohort_name", "cohort_name", "cohort_name", "cohort_…
#> $ group_level      <chr> "acetaminophen", "acetaminophen", "acetaminophen", "a…
#> $ strata_name      <chr> "overall", "overall", "overall", "overall", "overall"…
#> $ strata_level     <chr> "overall", "overall", "overall", "overall", "overall"…
#> $ variable_name    <chr> "number records", "number subjects", "Indication on i…
#> $ variable_level   <chr> NA, NA, "Headache", "Headache", "Influenza", "Influen…
#> $ estimate_name    <chr> "count", "count", "count", "percentage", "count", "pe…
#> $ estimate_type    <chr> "integer", "integer", "integer", "percentage", "integ…
#> $ estimate_value   <chr> "35", "35", "0", "0", "0", "0", "35", "100", "0", "0"…
#> $ additional_name  <chr> "overall", "overall", "overall", "overall", "overall"…
#> $ additional_level <chr> "overall", "overall", "overall", "overall", "overall"…

Daily dose

We can compute daily dose for a certain ingredient from a subset of drug_exposure or the whole drug exposure (can be very computationally expensive).

#cdm[["drug_exposure"]] %>%
#  addDailyDose(ingredientConceptId = 1125315) %>%
#  glimpse()

Coverage

Currently you can evaluate the coverage of daily dose for a conceptList or overall using dailyDoseCoverage. You can restrict to a certain ingredient, otherwise the result will be stratified by ingredient.

#dailyDoseCoverage(cdm = cdm, sample = NULL, ingredient = NULL, conceptList = NULL) 

DrugUse

You can add columns related to the drug use using addDrugUse. You always have to provide a reference ingredient.

#x <- x %>%
#  addDrugUse(
#    cdm = cdm,
#    ingredientConceptId = 1125315,
#    initialDailyDose = TRUE,
#    numberExposures = TRUE,
#    duration = TRUE,
#    cumulativeDose = TRUE,
#    numberEras = TRUE
#  )

Summarise the drug use

You can summarise the drug use using summariseDrugUse function

#summariseDrugUse(x, cdm)

Summarise patient characteristics

You can summarise the patient characteristics with summariseCharacteristics function:

summariseCharacteristics(
  x, cdm, ageGroup = list(c(0, 24), c(25, 49), c(50, 74), c(75, 150)),
  tableIntersect = list(
    "Visits" = list(
      tableName = "visit_occurrence", value = "count", window = c(-365, 0)
    )
  ),
  cohortIntersect = list(
    "Indications" = list(
      targetCohortTable  = "indications_cohort", value = "flag", 
      window = c(-365, 0)
    )
  )
)
#> Warning: The `cdm` argument of `summariseCharacteristics()` is deprecated as of
#> PatientProfiles 0.6.0.
#> This warning is displayed once every 8 hours.
#> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
#> generated.
#> ℹ adding demographics columns
#> ℹ adding table intersect columns for table: visit_occurrence
#> ℹ adding cohort intersect columns for table: indications_cohort
#> ℹ summarising data
#> ✔ summariseCharacteristics finished!
#> # A tibble: 66 × 16
#>    result_id cdm_name result_type        package_name package_version group_name
#>        <int> <chr>    <chr>              <chr>        <chr>           <chr>     
#>  1         1 DUS MOCK summarised_charac… PatientProf… 0.7.0           cohort_na…
#>  2         1 DUS MOCK summarised_charac… PatientProf… 0.7.0           cohort_na…
#>  3         1 DUS MOCK summarised_charac… PatientProf… 0.7.0           cohort_na…
#>  4         1 DUS MOCK summarised_charac… PatientProf… 0.7.0           cohort_na…
#>  5         1 DUS MOCK summarised_charac… PatientProf… 0.7.0           cohort_na…
#>  6         1 DUS MOCK summarised_charac… PatientProf… 0.7.0           cohort_na…
#>  7         1 DUS MOCK summarised_charac… PatientProf… 0.7.0           cohort_na…
#>  8         1 DUS MOCK summarised_charac… PatientProf… 0.7.0           cohort_na…
#>  9         1 DUS MOCK summarised_charac… PatientProf… 0.7.0           cohort_na…
#> 10         1 DUS MOCK summarised_charac… PatientProf… 0.7.0           cohort_na…
#> # ℹ 56 more rows
#> # ℹ 10 more variables: group_level <chr>, strata_name <chr>,
#> #   strata_level <chr>, variable_name <chr>, variable_level <chr>,
#> #   estimate_name <chr>, estimate_type <chr>, estimate_value <chr>,
#> #   additional_name <chr>, additional_level <chr>

Summarise patients large scale characteristics

You can summarise the patient characteristics with summariseLargeScaleCharacteristics function:

summariseLargeScaleCharacteristics(
  cohort = x, 
  window = list(c(-Inf, Inf)), 
  eventInWindow = "condition_occurrence", 
  episodeInWindow = "drug_exposure"
)
#> # A tibble: 32 × 16
#>    result_id cdm_name result_type        package_name package_version group_name
#>        <int> <chr>    <chr>              <chr>        <chr>           <chr>     
#>  1         1 DUS MOCK summarised_large_… PatientProf… 0.7.0           overall   
#>  2         1 DUS MOCK summarised_large_… PatientProf… 0.7.0           overall   
#>  3         1 DUS MOCK summarised_large_… PatientProf… 0.7.0           overall   
#>  4         1 DUS MOCK summarised_large_… PatientProf… 0.7.0           cohort_na…
#>  5         1 DUS MOCK summarised_large_… PatientProf… 0.7.0           cohort_na…
#>  6         1 DUS MOCK summarised_large_… PatientProf… 0.7.0           cohort_na…
#>  7         1 DUS MOCK summarised_large_… PatientProf… 0.7.0           cohort_na…
#>  8         1 DUS MOCK summarised_large_… PatientProf… 0.7.0           cohort_na…
#>  9         1 DUS MOCK summarised_large_… PatientProf… 0.7.0           cohort_na…
#> 10         2 DUS MOCK summarised_large_… PatientProf… 0.7.0           overall   
#> # ℹ 22 more rows
#> # ℹ 10 more variables: group_level <chr>, strata_name <chr>,
#> #   strata_level <chr>, variable_name <chr>, variable_level <chr>,
#> #   estimate_name <chr>, estimate_type <chr>, estimate_value <chr>,
#> #   additional_name <chr>, additional_level <chr>