| Type: | Package |
| Title: | Identify Characteristics of Patients in the OMOP Common Data Model |
| Version: | 1.6.0 |
| Maintainer: | Martí Català <marti.catalasabate@ndorms.ox.ac.uk> |
| Description: | Identify the characteristics of patients in data mapped to the Observational Medical Outcomes Partnership (OMOP) common data model. |
| License: | Apache License (≥ 2) |
| Encoding: | UTF-8 |
| Suggests: | bit64, CDMConnector (≥ 1.3.1), CodelistGenerator, CohortConstructor, covr, DBI, dbplyr, DT, duckdb (≥ 0.9.0), ggplot2, glue, gt, here, Hmisc, knitr, odbc, omock (≥ 0.7.0), patchwork, rmarkdown, RPostgres, scales, spelling, testthat (≥ 3.1.5), tictoc, withr |
| Imports: | cli, clock, dplyr, lifecycle, omopgenerics (≥ 1.3.1), purrr, rlang, stringr, tidyr |
| URL: | https://darwin-eu.github.io/PatientProfiles/ |
| BugReports: | https://github.com/darwin-eu/PatientProfiles/issues |
| Language: | en-US |
| Depends: | R (≥ 4.1.0) |
| Config/testthat/edition: | 3 |
| Config/testthat/parallel: | true |
| VignetteBuilder: | knitr |
| Config/roxygen2/version: | 8.0.0 |
| NeedsCompilation: | no |
| Packaged: | 2026-07-25 09:31:44 UTC; martics |
| Author: | Martí Català |
| Repository: | CRAN |
| Date/Publication: | 2026-07-25 11:30:02 UTC |
PatientProfiles: Identify Characteristics of Patients in the OMOP Common Data Model
Description
Identify the characteristics of patients in data mapped to the Observational Medical Outcomes Partnership (OMOP) common data model.
Author(s)
Maintainer: Martí Català marti.catalasabate@ndorms.ox.ac.uk (ORCID)
Authors:
Martí Català marti.catalasabate@ndorms.ox.ac.uk (ORCID)
Yuchen Guo yuchen.guo@ndorms.ox.ac.uk (ORCID)
Mike Du mike.du@ndorms.ox.ac.uk (ORCID)
Kim Lopez-Guell kim.lopez@spc.ox.ac.uk (ORCID)
Edward Burn edward.burn@ndorms.ox.ac.uk (ORCID)
Nuria Mercade-Besora nuria.mercadebesora@ndorms.ox.ac.uk (ORCID)
Other contributors:
Xintong Li xintong.li@ndorms.ox.ac.uk (ORCID) [contributor]
Xihang Chen xihang.chen@ndorms.ox.ac.uk (ORCID) [contributor]
See Also
Useful links:
Report bugs at https://github.com/darwin-eu/PatientProfiles/issues
Compute the age of the individuals at a certain date
Description
Compute the age of the individuals at a certain date
Usage
addAge(
x,
indexDate = "cohort_start_date",
ageName = "age",
ageGroup = NULL,
ageMissingMonth = 1,
ageMissingDay = 1,
ageImposeMonth = FALSE,
ageImposeDay = FALSE,
ageUnit = "years",
missingAgeGroupValue = "None",
name = NULL,
type = "numeric"
)
Arguments
x |
A table containing individuals in a CDM reference. |
indexDate |
Name of a date column in |
ageName |
Name of the age column to add. |
ageGroup |
If not |
ageMissingMonth |
Month of the year assigned when month of birth is missing. |
ageMissingDay |
Day of the month assigned when day of birth is missing. |
ageImposeMonth |
If |
ageImposeDay |
If |
ageUnit |
Unit in which to express age: |
missingAgeGroupValue |
Value to use when age is missing. |
name |
Name of the new table. If |
type |
Type of the created column(s). Counts, days, age, and observation
durations can be |
Value
tibble with the age column added.
Examples
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
cdm$cohort1 |>
addAge()
Query to add the age of the individuals at a certain date
Description
Same as addAge(), except query is not computed to a table.
Usage
addAgeQuery(
x,
indexDate = "cohort_start_date",
ageName = "age",
ageGroup = NULL,
ageMissingMonth = 1,
ageMissingDay = 1,
ageImposeMonth = FALSE,
ageImposeDay = FALSE,
ageUnit = "years",
missingAgeGroupValue = "None",
type = "numeric"
)
Arguments
x |
A table containing individuals in a CDM reference. |
indexDate |
Name of a date column in |
ageName |
Name of the age column to add. |
ageGroup |
If not |
ageMissingMonth |
Month of the year assigned when month of birth is missing. |
ageMissingDay |
Day of the month assigned when day of birth is missing. |
ageImposeMonth |
If |
ageImposeDay |
If |
ageUnit |
Unit in which to express age: |
missingAgeGroupValue |
Value to use when age is missing. |
type |
Type of the created column(s). Counts, days, age, and observation
durations can be |
Value
tibble with the age column added.
Examples
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
cdm$cohort1 |>
addAgeQuery()
Add the birth day of an individual to a table
Description
The function accounts for leap years and corrects the invalid dates to the next valid date.
Usage
addBirthday(
x,
birthday = 0,
birthdayName = "birthday",
ageMissingMonth = 1L,
ageMissingDay = 1L,
ageImposeMonth = FALSE,
ageImposeDay = FALSE,
ageUnit = "years",
name = NULL
)
Arguments
x |
A table containing individuals in a CDM reference. |
birthday |
Day of birth to add. |
birthdayName |
Name of the birthday column to add. |
ageMissingMonth |
Month of the year assigned when month of birth is missing. |
ageMissingDay |
Day of the month assigned when day of birth is missing. |
ageImposeMonth |
If |
ageImposeDay |
If |
ageUnit |
Unit in which to express age: |
name |
Name of the new table. If |
Value
The table with a new column containing the birth day.
Examples
library(PatientProfiles)
library(dplyr)
cdm <- mockPatientProfiles(source = "duckdb")
cdm$cohort1 |>
addBirthday() |>
glimpse()
cdm$cohort1 |>
addBirthday(birthday = 5, birthdayName = "bithday_5th") |>
glimpse()
Add the birth day of an individual to a table
Description
Same as
addBirthday(), except query is not computed to a table.
The function accounts for leap years and corrects the invalid dates to the next valid date.
Usage
addBirthdayQuery(
x,
birthdayName = "birthday",
birthday = 0,
ageMissingMonth = 1,
ageMissingDay = 1,
ageImposeMonth = FALSE,
ageImposeDay = FALSE,
ageUnit = "years"
)
Arguments
x |
A table containing individuals in a CDM reference. |
birthdayName |
Name of the birthday column to add. |
birthday |
Day of birth to add. |
ageMissingMonth |
Month of the year assigned when month of birth is missing. |
ageMissingDay |
Day of the month assigned when day of birth is missing. |
ageImposeMonth |
If |
ageImposeDay |
If |
ageUnit |
Unit in which to express age: |
Value
The table with a query that add the new column containing the birth day.
Examples
library(PatientProfiles)
library(dplyr)
cdm <- mockPatientProfiles(source = "duckdb")
cdm$cohort1 |>
addBirthdayQuery() |>
glimpse()
cdm$cohort1 |>
addBirthdayQuery(birthday = 5) |>
glimpse()
Categorize a numeric variable
Description
Categorize a numeric variable
Usage
addCategories(
x,
variable,
categories,
missingCategoryValue = "None",
overlap = FALSE,
includeLowerBound = TRUE,
includeUpperBound = TRUE,
name = NULL
)
Arguments
x |
A table containing individuals in a CDM reference. |
variable |
Target variable that we want to categorize. |
categories |
List of lists of named categories with lower and upper limit. |
missingCategoryValue |
Value to assign to those individuals not in any named category. If NULL or NA, missing values will not be changed. |
overlap |
TRUE if the categories given overlap. |
includeLowerBound |
Whether to include the lower bound in the group. |
includeUpperBound |
Whether to include the upper bound in the group. |
name |
Name of the new table. If |
Value
The x table with the categorical variable added.
Examples
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
result <- cdm$cohort1 |>
addAge() |>
addCategories(
variable = "age",
categories = list("age_group" = list(
"0 to 39" = c(0, 39), "40 to 79" = c(40, 79), "80 to 150" = c(80, 150)
))
)
Add cdm name
Description
Add cdm name
Usage
addCdmName(table, cdm = omopgenerics::cdmReference(table))
Arguments
table |
A table to process. |
cdm |
A |
Value
Table with an extra column with the cdm names
Examples
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
cdm$cohort1 |>
addCdmName()
Add the first or last cohort event and its date
Description
addCohortEventDate() finds the first or last event in each window.
When no event is observed before the applicable boundary, the event is
reported as "end_of_observation" if the observation period boundary is
reached or "censor" if the window boundary or censorDate is reached. The
date value represents that boundary.
Usage
addCohortEventDate(
x,
targetCohortTable,
targetCohortId = NULL,
indexDate = "cohort_start_date",
censorDate = NULL,
targetDate = "cohort_start_date",
order = "first",
window = c(0, Inf),
multipleEvents = NULL,
nameStyle = "{value}_{window_name}",
name = NULL
)
Arguments
x |
A table containing individuals in a CDM reference. |
targetCohortTable |
Name of the cohort table to intersect with. |
targetCohortId |
Cohort definition IDs to include from
|
indexDate |
Name of a date column in |
censorDate |
Date or name of a date column in |
targetDate |
Name or names of date columns in the target tables to use for the intersection. |
order |
Which record to use when multiple records occur in a window:
|
window |
Window or windows of time relative to |
multipleEvents |
How events occurring on the same date are handled. If
|
nameStyle |
Naming pattern for the added columns. It must contain
|
name |
Name of the new table. If |
Value
x with an event column and a date column for every window.
Examples
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
cdm$cohort1 |>
addCohortEventDate(targetCohortTable = "cohort2")
Add the first or last cohort event and its relative days
Description
addCohortEventDays() finds the first or last event in each window.
When no event is observed before the applicable boundary, the event is
reported as "end_of_observation" if the observation period boundary is
reached or "censor" if the window boundary or censorDate is reached. The
days value represents that boundary.
Usage
addCohortEventDays(
x,
targetCohortTable,
targetCohortId = NULL,
indexDate = "cohort_start_date",
censorDate = NULL,
targetDate = "cohort_start_date",
order = "first",
window = c(0, Inf),
multipleEvents = NULL,
nameStyle = "{value}_{window_name}",
name = NULL,
type = "numeric"
)
Arguments
x |
A table containing individuals in a CDM reference. |
targetCohortTable |
Name of the cohort table to intersect with. |
targetCohortId |
Cohort definition IDs to include from
|
indexDate |
Name of a date column in |
censorDate |
Date or name of a date column in |
targetDate |
Name or names of date columns in the target tables to use for the intersection. |
order |
Which record to use when multiple records occur in a window:
|
window |
Window or windows of time relative to |
multipleEvents |
How events occurring on the same date are handled. If
|
nameStyle |
Naming pattern for the added columns. It must contain
|
name |
Name of the new table. If |
type |
Type of the created column(s). Counts, days, age, and observation
durations can be |
Value
x with an event column and a days column of the requested type,
relative to indexDate, for every window.
Examples
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
cdm$cohort1 |>
addCohortEventDays(targetCohortTable = "cohort2")
It creates columns to indicate number of occurrences of intersection with a cohort
Description
It creates columns to indicate number of occurrences of intersection with a cohort
Usage
addCohortIntersectCount(
x,
targetCohortTable,
targetCohortId = NULL,
indexDate = "cohort_start_date",
censorDate = NULL,
targetStartDate = "cohort_start_date",
targetEndDate = "cohort_end_date",
window = list(c(0, Inf)),
nameStyle = "{cohort_name}_{window_name}",
name = NULL,
type = "numeric"
)
Arguments
x |
A table containing individuals in a CDM reference. |
targetCohortTable |
Name of the cohort table to intersect with. |
targetCohortId |
Cohort definition IDs to include from
|
indexDate |
Name of a date column in |
censorDate |
Date or name of a date column in |
targetStartDate |
Name or names of start-date columns in the target tables to use for the intersection. |
targetEndDate |
Name or names of end-date columns in the target tables
to use for the intersection. If |
window |
Window or windows of time relative to |
nameStyle |
Naming pattern for the added column or columns. It should
include the required formatting variables. If more than one |
name |
Name of the new table. If |
type |
Type of the created column(s). Counts, days, age, and observation
durations can be |
Value
The original table (x) with one added column per intersection with the desired cohort in a specific window. One column will be created for each combination of window and cohort. The value of the column will be the number of intersections in the desired window, or NA if the individual is not in observation at any time in the window.
Examples
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
cdm$cohort1 |>
addCohortIntersectCount(
targetCohortTable = "cohort2"
)
Date of cohorts that are present in a certain window
Description
Date of cohorts that are present in a certain window
Usage
addCohortIntersectDate(
x,
targetCohortTable,
targetCohortId = NULL,
indexDate = "cohort_start_date",
censorDate = NULL,
targetDate = "cohort_start_date",
order = "first",
window = c(0, Inf),
nameStyle = "{cohort_name}_{window_name}",
name = NULL
)
Arguments
x |
A table containing individuals in a CDM reference. |
targetCohortTable |
Name of the cohort table to intersect with. |
targetCohortId |
Cohort definition IDs to include from
|
indexDate |
Name of a date column in |
censorDate |
Date or name of a date column in |
targetDate |
Name or names of date columns in the target tables to use for the intersection. |
order |
Which record to use when multiple records occur in a window:
|
window |
Window or windows of time relative to |
nameStyle |
Naming pattern for the added column or columns. It should
include the required formatting variables. If more than one |
name |
Name of the new table. If |
Value
x along with additional columns for each cohort of interest.
Examples
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
cdm$cohort1 |>
addCohortIntersectDate(targetCohortTable = "cohort2")
It creates columns to indicate the number of days between the current table and a target cohort
Description
It creates columns to indicate the number of days between the current table and a target cohort
Usage
addCohortIntersectDays(
x,
targetCohortTable,
targetCohortId = NULL,
indexDate = "cohort_start_date",
censorDate = NULL,
targetDate = "cohort_start_date",
order = "first",
window = c(0, Inf),
nameStyle = "{cohort_name}_{window_name}",
name = NULL,
type = "numeric"
)
Arguments
x |
A table containing individuals in a CDM reference. |
targetCohortTable |
Name of the cohort table to intersect with. |
targetCohortId |
Cohort definition IDs to include from
|
indexDate |
Name of a date column in |
censorDate |
Date or name of a date column in |
targetDate |
Name or names of date columns in the target tables to use for the intersection. |
order |
Which record to use when multiple records occur in a window:
|
window |
Window or windows of time relative to |
nameStyle |
Naming pattern for the added column or columns. It should
include the required formatting variables. If more than one |
name |
Name of the new table. If |
type |
Type of the created column(s). Counts, days, age, and observation
durations can be |
Value
x along with additional columns for each cohort of interest.
Examples
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
cdm$cohort1 |>
addCohortIntersectDays(targetCohortTable = "cohort2")
It creates a column with the field of a desired intersection
Description
It creates a column with the field of a desired intersection
Usage
addCohortIntersectField(
x,
targetCohortTable,
field,
targetCohortId = NULL,
indexDate = "cohort_start_date",
censorDate = NULL,
targetDate = "cohort_start_date",
order = "first",
window = list(c(0, Inf)),
nameStyle = "{cohort_name}_{field}_{window_name}",
name = NULL,
type = "auto"
)
Arguments
x |
A table containing individuals in a CDM reference. |
targetCohortTable |
Name of the cohort table to intersect with. |
field |
Name or names of columns in the target tables to add to |
targetCohortId |
Cohort definition IDs to include from
|
indexDate |
Name of a date column in |
censorDate |
Date or name of a date column in |
targetDate |
Name or names of date columns in the target tables to use for the intersection. |
order |
Which record to use when multiple records occur in a window:
|
window |
Window or windows of time relative to |
nameStyle |
Naming pattern for the added column or columns. It should
include the required formatting variables. If more than one |
name |
Name of the new table. If |
type |
Type of the created column(s). Counts, days, age, and observation
durations can be |
Value
table with added columns with overlap information.
Examples
library(PatientProfiles)
library(dplyr)
cdm <- mockPatientProfiles(source = "duckdb")
cdm$cohort2 <- cdm$cohort2 |>
mutate(even = if_else(subject_id %% 2, "yes", "no")) |>
compute(name = "cohort2")
cdm$cohort1 |>
addCohortIntersectFlag(
targetCohortTable = "cohort2"
)
It creates columns to indicate the presence of cohorts
Description
It creates columns to indicate the presence of cohorts
Usage
addCohortIntersectFlag(
x,
targetCohortTable,
targetCohortId = NULL,
indexDate = "cohort_start_date",
censorDate = NULL,
targetStartDate = "cohort_start_date",
targetEndDate = "cohort_end_date",
window = list(c(0, Inf)),
nameStyle = "{cohort_name}_{window_name}",
name = NULL,
type = "numeric"
)
Arguments
x |
A table containing individuals in a CDM reference. |
targetCohortTable |
Name of the cohort table to intersect with. |
targetCohortId |
Cohort definition IDs to include from
|
indexDate |
Name of a date column in |
censorDate |
Date or name of a date column in |
targetStartDate |
Name or names of start-date columns in the target tables to use for the intersection. |
targetEndDate |
Name or names of end-date columns in the target tables
to use for the intersection. If |
window |
Window or windows of time relative to |
nameStyle |
Naming pattern for the added column or columns. It should
include the required formatting variables. If more than one |
name |
Name of the new table. If |
type |
Type of the created column(s). Counts, days, age, and observation
durations can be |
Value
The original table (x) with one added column per intersection with the desired cohort in a specific window. One column will be created for each combination of window and cohort. The value of the column can either indicate presence (1 or TRUE), no intersection (0 or FALSE), or NA if the individual is not in observation at any time of the window. The representation depends on type.
Examples
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
cdm$cohort1 |>
addCohortIntersectFlag(
targetCohortTable = "cohort2"
)
Add cohort name for each cohort_definition_id
Description
Add cohort name for each cohort_definition_id
Usage
addCohortName(cohort)
Arguments
cohort |
A |
Value
cohort with an extra column with the cohort names
Examples
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
cdm$cohort1 |>
addCohortName()
Add the first or last concept event and its date
Description
addConceptEventDate() finds the first or last event from a set of
concepts in each window. When no event is observed before the applicable
boundary, the event is reported as "end_of_observation" if the observation
period boundary is reached or "censor" if the window boundary or
censorDate is reached. The date value represents that boundary.
Usage
addConceptEventDate(
x,
conceptSet,
indexDate = "cohort_start_date",
censorDate = NULL,
targetDate = "event_start_date",
order = "first",
window = list(c(0, Inf)),
multipleEvents = NULL,
nameStyle = "{value}_{window_name}",
name = NULL
)
Arguments
x |
A table containing individuals in a CDM reference. |
conceptSet |
A named list of concept sets. |
indexDate |
Name of a date column in |
censorDate |
Date or name of a date column in |
targetDate |
Name or names of date columns in the target tables to use for the intersection. |
order |
Which record to use when multiple records occur in a window:
|
window |
Window or windows of time relative to |
multipleEvents |
How events occurring on the same date are handled. If
|
nameStyle |
Naming pattern for the added columns. It must contain
|
name |
Name of the new table. If |
Value
x with an event column and a date column for every window.
Examples
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
cdm$cohort1 |>
addConceptEventDate(conceptSet = list(acetaminophen = 1125315L))
Add the first or last concept event and its relative days
Description
addConceptEventDays() finds the first or last event from a set of
concepts in each window. When no event is observed before the applicable
boundary, the event is reported as "end_of_observation" if the observation
period boundary is reached or "censor" if the window boundary or
censorDate is reached. The days value represents that boundary.
Usage
addConceptEventDays(
x,
conceptSet,
indexDate = "cohort_start_date",
censorDate = NULL,
targetDate = "event_start_date",
order = "first",
window = list(c(0, Inf)),
multipleEvents = NULL,
nameStyle = "{value}_{window_name}",
name = NULL,
type = "numeric"
)
Arguments
x |
A table containing individuals in a CDM reference. |
conceptSet |
A named list of concept sets. |
indexDate |
Name of a date column in |
censorDate |
Date or name of a date column in |
targetDate |
Name or names of date columns in the target tables to use for the intersection. |
order |
Which record to use when multiple records occur in a window:
|
window |
Window or windows of time relative to |
multipleEvents |
How events occurring on the same date are handled. If
|
nameStyle |
Naming pattern for the added columns. It must contain
|
name |
Name of the new table. If |
type |
Type of the created column(s). Counts, days, age, and observation
durations can be |
Value
x with an event column and a days column of the requested type,
relative to indexDate, for every window.
Examples
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
cdm$cohort1 |>
addConceptEventDays(conceptSet = list(acetaminophen = 1125315L))
It creates column to indicate the count overlap information between a table and a concept
Description
It creates column to indicate the count overlap information between a table and a concept
Usage
addConceptIntersectCount(
x,
conceptSet,
indexDate = "cohort_start_date",
censorDate = NULL,
window = list(c(0, Inf)),
targetStartDate = "event_start_date",
targetEndDate = "event_end_date",
inObservation = TRUE,
nameStyle = "{concept_name}_{window_name}",
name = NULL,
type = "numeric"
)
Arguments
x |
A table containing individuals in a CDM reference. |
conceptSet |
A named list of concept sets. |
indexDate |
Name of a date column in |
censorDate |
Date or name of a date column in |
window |
Window or windows of time relative to |
targetStartDate |
Name or names of start-date columns in the target tables to use for the intersection. |
targetEndDate |
Name or names of end-date columns in the target tables
to use for the intersection. If |
inObservation |
If |
nameStyle |
Naming pattern for the added column or columns. It should
include the required formatting variables. If more than one |
name |
Name of the new table. If |
type |
Type of the created column(s). Counts, days, age, and observation
durations can be |
Value
The original table (x) with one added column per intersection with the desired conceptSet in a specific window. One column will be created for each combination of window and conceptSet. The value of the column will be the number of intersections in the desired window, or NA if the individual is not in observation at any time in the window.
Examples
library(PatientProfiles)
library(omopgenerics, warn.conflicts = TRUE)
library(dplyr, warn.conflicts = TRUE)
cdm <- mockPatientProfiles(source = "duckdb")
concept <- tibble(
concept_id = c(1125315),
domain_id = "Drug",
vocabulary_id = NA_character_,
concept_class_id = "Ingredient",
standard_concept = "S",
concept_code = NA_character_,
valid_start_date = as.Date("1900-01-01"),
valid_end_date = as.Date("2099-01-01"),
invalid_reason = NA_character_
) |>
mutate(concept_name = paste0("concept: ", .data$concept_id))
cdm <- insertTable(cdm, "concept", concept)
cdm$cohort1 |>
addConceptIntersectCount(conceptSet = list("acetaminophen" = 1125315))
It creates column to indicate the date overlap information between a table and a concept
Description
It creates column to indicate the date overlap information between a table and a concept
Usage
addConceptIntersectDate(
x,
conceptSet,
indexDate = "cohort_start_date",
censorDate = NULL,
window = list(c(0, Inf)),
targetDate = "event_start_date",
order = "first",
inObservation = TRUE,
nameStyle = "{concept_name}_{window_name}",
name = NULL
)
Arguments
x |
A table containing individuals in a CDM reference. |
conceptSet |
A named list of concept sets. |
indexDate |
Name of a date column in |
censorDate |
Date or name of a date column in |
window |
Window or windows of time relative to |
targetDate |
Name or names of date columns in the target tables to use for the intersection. |
order |
Which record to use when multiple records occur in a window:
|
inObservation |
If |
nameStyle |
Naming pattern for the added column or columns. It should
include the required formatting variables. If more than one |
name |
Name of the new table. If |
Value
table with added columns with overlap information
Examples
library(PatientProfiles)
library(omopgenerics, warn.conflicts = TRUE)
library(dplyr, warn.conflicts = TRUE)
cdm <- mockPatientProfiles(source = "duckdb")
concept <- tibble(
concept_id = c(1125315),
domain_id = "Drug",
vocabulary_id = NA_character_,
concept_class_id = "Ingredient",
standard_concept = "S",
concept_code = NA_character_,
valid_start_date = as.Date("1900-01-01"),
valid_end_date = as.Date("2099-01-01"),
invalid_reason = NA_character_
) |>
mutate(concept_name = paste0("concept: ", .data$concept_id))
cdm <- insertTable(cdm, "concept", concept)
cdm$cohort1 |>
addConceptIntersectDate(conceptSet = list("acetaminophen" = 1125315))
It creates column to indicate the days of difference from an index date to a concept
Description
It creates column to indicate the days of difference from an index date to a concept
Usage
addConceptIntersectDays(
x,
conceptSet,
indexDate = "cohort_start_date",
censorDate = NULL,
window = list(c(0, Inf)),
targetDate = "event_start_date",
order = "first",
inObservation = TRUE,
nameStyle = "{concept_name}_{window_name}",
name = NULL,
type = "numeric"
)
Arguments
x |
A table containing individuals in a CDM reference. |
conceptSet |
A named list of concept sets. |
indexDate |
Name of a date column in |
censorDate |
Date or name of a date column in |
window |
Window or windows of time relative to |
targetDate |
Name or names of date columns in the target tables to use for the intersection. |
order |
Which record to use when multiple records occur in a window:
|
inObservation |
If |
nameStyle |
Naming pattern for the added column or columns. It should
include the required formatting variables. If more than one |
name |
Name of the new table. If |
type |
Type of the created column(s). Counts, days, age, and observation
durations can be |
Value
table with added columns with overlap information
Examples
library(PatientProfiles)
library(omopgenerics, warn.conflicts = TRUE)
library(dplyr, warn.conflicts = TRUE)
cdm <- mockPatientProfiles(source = "duckdb")
concept <- tibble(
concept_id = c(1125315),
domain_id = "Drug",
vocabulary_id = NA_character_,
concept_class_id = "Ingredient",
standard_concept = "S",
concept_code = NA_character_,
valid_start_date = as.Date("1900-01-01"),
valid_end_date = as.Date("2099-01-01"),
invalid_reason = NA_character_
) |>
mutate(concept_name = paste0("concept: ", .data$concept_id))
cdm <- insertTable(cdm, "concept", concept)
cdm$cohort1 |>
addConceptIntersectDays(conceptSet = list("acetaminophen" = 1125315))
It adds a custom column (field) from the intersection with a certain table subsetted by concept id. In general it is used to add the first value of a certain measurement.
Description
It adds a custom column (field) from the intersection with a certain table subsetted by concept id. In general it is used to add the first value of a certain measurement.
Usage
addConceptIntersectField(
x,
conceptSet,
field,
indexDate = "cohort_start_date",
censorDate = NULL,
window = list(c(0, Inf)),
targetDate = "event_start_date",
order = "first",
inObservation = TRUE,
allowDuplicates = FALSE,
nameStyle = "{field}_{concept_name}_{window_name}",
name = NULL,
type = "auto"
)
Arguments
x |
A table containing individuals in a CDM reference. |
conceptSet |
A named list of concept sets. |
field |
Name or names of columns in the target tables to add to |
indexDate |
Name of a date column in |
censorDate |
Date or name of a date column in |
window |
Window or windows of time relative to |
targetDate |
Name or names of date columns in the target tables to use for the intersection. |
order |
Which record to use when multiple records occur in a window:
|
inObservation |
If |
allowDuplicates |
Whether to allow multiple records for the same person,
target, and date. If |
nameStyle |
Naming pattern for the added column or columns. It should
include the required formatting variables. If more than one |
name |
Name of the new table. If |
type |
Type of the created column(s). Counts, days, age, and observation
durations can be |
Value
Table with the field value obtained from the intersection
Examples
library(PatientProfiles)
library(omopgenerics, warn.conflicts = TRUE)
library(dplyr, warn.conflicts = TRUE)
cdm <- mockPatientProfiles(source = "duckdb")
concept <- tibble(
concept_id = c(1125315),
domain_id = "Drug",
vocabulary_id = NA_character_,
concept_class_id = "Ingredient",
standard_concept = "S",
concept_code = NA_character_,
valid_start_date = as.Date("1900-01-01"),
valid_end_date = as.Date("2099-01-01"),
invalid_reason = NA_character_
) |>
mutate(concept_name = paste0("concept: ", .data$concept_id))
cdm <- insertTable(cdm, "concept", concept)
cdm$cohort1 |>
addConceptIntersectField(
conceptSet = list("acetaminophen" = 1125315),
field = "drug_type_concept_id"
)
It creates column to indicate the flag overlap information between a table and a concept
Description
It creates column to indicate the flag overlap information between a table and a concept
Usage
addConceptIntersectFlag(
x,
conceptSet,
indexDate = "cohort_start_date",
censorDate = NULL,
window = list(c(0, Inf)),
targetStartDate = "event_start_date",
targetEndDate = "event_end_date",
inObservation = TRUE,
nameStyle = "{concept_name}_{window_name}",
name = NULL,
type = "numeric"
)
Arguments
x |
A table containing individuals in a CDM reference. |
conceptSet |
A named list of concept sets. |
indexDate |
Name of a date column in |
censorDate |
Date or name of a date column in |
window |
Window or windows of time relative to |
targetStartDate |
Name or names of start-date columns in the target tables to use for the intersection. |
targetEndDate |
Name or names of end-date columns in the target tables
to use for the intersection. If |
inObservation |
If |
nameStyle |
Naming pattern for the added column or columns. It should
include the required formatting variables. If more than one |
name |
Name of the new table. If |
type |
Type of the created column(s). Counts, days, age, and observation
durations can be |
Value
The original table (x) with one added column per intersection with the desired conceptSet in a specific window. One column will be created for each combination of window and conceptSet. The value of the column can either indicate presence (1 or TRUE), no intersection (0 or FALSE), or NA if the individual is not in observation at any time of the window. The representation depends on type.
Examples
library(PatientProfiles)
library(omopgenerics, warn.conflicts = TRUE)
library(dplyr, warn.conflicts = TRUE)
cdm <- mockPatientProfiles(source = "duckdb")
concept <- tibble(
concept_id = c(1125315),
domain_id = "Drug",
vocabulary_id = NA_character_,
concept_class_id = "Ingredient",
standard_concept = "S",
concept_code = NA_character_,
valid_start_date = as.Date("1900-01-01"),
valid_end_date = as.Date("2099-01-01"),
invalid_reason = NA_character_
) |>
mutate(concept_name = paste0("concept: ", .data$concept_id))
cdm <- insertTable(cdm, "concept", concept)
cdm$cohort1 |>
addConceptIntersectFlag(conceptSet = list("acetaminophen" = 1125315))
Add concept name for each concept_id
Description
Add concept name for each concept_id
Usage
addConceptName(table, column = NULL, nameStyle = "{column}_name")
Arguments
table |
A table to process. |
column |
Column to add the concept names from. If NULL any column that
its name ends with |
nameStyle |
Naming pattern for the added column or columns. It should
include the required formatting variables. If more than one |
Value
table with an extra column with the concept names.
Examples
library(PatientProfiles)
library(omock)
library(dplyr, warn.conflicts = FALSE)
cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb")
cdm$drug_exposure |>
addConceptName(column = "drug_concept_id", nameStyle = "drug_name") |>
glimpse()
cdm$drug_exposure |>
addConceptName() |>
glimpse()
Add a column with the individual birth date
Description
Add a column with the individual birth date
Usage
addDateOfBirth(
x,
dateOfBirthName = "date_of_birth",
missingDay = 1,
missingMonth = 1,
imposeDay = FALSE,
imposeMonth = FALSE,
name = NULL
)
Arguments
x |
A table containing individuals in a CDM reference. |
dateOfBirthName |
Name of the date-of-birth column to add. |
missingDay |
Day of the month assigned when day of birth is missing. |
missingMonth |
Month of the year assigned when month of birth is missing. |
imposeDay |
If |
imposeMonth |
If |
name |
Name of the new table. If |
Value
The function returns the table x with an extra column that contains the date of birth.
Examples
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
cdm$cohort1 |>
addDateOfBirth()
Query to add a column with the individual birth date
Description
Same as addDateOfBirth(), except query is not computed to a table.
Usage
addDateOfBirthQuery(
x,
dateOfBirthName = "date_of_birth",
missingDay = 1,
missingMonth = 1,
imposeDay = FALSE,
imposeMonth = FALSE
)
Arguments
x |
A table containing individuals in a CDM reference. |
dateOfBirthName |
Name of the date-of-birth column to add. |
missingDay |
Day of the month assigned when day of birth is missing. |
missingMonth |
Month of the year assigned when month of birth is missing. |
imposeDay |
If |
imposeMonth |
If |
Value
The function returns the table x with an extra column that contains the date of birth.
Examples
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
cdm$cohort1 |>
addDateOfBirthQuery()
Add date of death for individuals. Only death within the same observation
period than indexDate will be observed.
Description
Add date of death for individuals. Only death within the same observation
period than indexDate will be observed.
Usage
addDeathDate(
x,
indexDate = "cohort_start_date",
censorDate = NULL,
window = c(0, Inf),
deathDateName = "date_of_death",
name = NULL
)
Arguments
x |
A table containing individuals in a CDM reference. |
indexDate |
Name of a date column in |
censorDate |
Date or name of a date column in |
window |
Window or windows of time relative to |
deathDateName |
name of the new column to be added. |
name |
Name of the new table. If |
Value
table x with the added column with death information added.
Examples
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
cdm$cohort1 |>
addDeathDate()
Add days to death for individuals. Only death within the same observation
period than indexDate will be observed.
Description
Add days to death for individuals. Only death within the same observation
period than indexDate will be observed.
Usage
addDeathDays(
x,
indexDate = "cohort_start_date",
censorDate = NULL,
window = c(0, Inf),
deathDaysName = "days_to_death",
name = NULL,
type = "numeric"
)
Arguments
x |
A table containing individuals in a CDM reference. |
indexDate |
Name of a date column in |
censorDate |
Date or name of a date column in |
window |
Window or windows of time relative to |
deathDaysName |
name of the new column to be added. |
name |
Name of the new table. If |
type |
Type of the created column(s). Counts, days, age, and observation
durations can be |
Value
table x with the added column with death information added.
Examples
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
cdm$cohort1 |>
addDeathDays()
Add flag for death for individuals. Only death within the same observation
period than indexDate will be observed.
Description
Add flag for death for individuals. Only death within the same observation
period than indexDate will be observed.
Usage
addDeathFlag(
x,
indexDate = "cohort_start_date",
censorDate = NULL,
window = c(0, Inf),
deathFlagName = "death",
name = NULL,
type = "numeric"
)
Arguments
x |
A table containing individuals in a CDM reference. |
indexDate |
Name of a date column in |
censorDate |
Date or name of a date column in |
window |
Window or windows of time relative to |
deathFlagName |
name of the new column to be added. |
name |
Name of the new table. If |
type |
Type of the created column(s). Counts, days, age, and observation
durations can be |
Value
The original table (x) with one added column per window indicating whether the individual's death record intersects that window. The value of the column can either indicate presence (1 or TRUE), no intersection (0 or FALSE), or NA if the individual is not in observation at any time of the window. The representation depends on type.
Examples
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
cdm$cohort1 |>
addDeathFlag()
Compute demographic characteristics at a certain date
Description
Compute demographic characteristics at a certain date
Usage
addDemographics(
x,
indexDate = "cohort_start_date",
age = TRUE,
ageName = "age",
ageMissingMonth = 1,
ageMissingDay = 1,
ageImposeMonth = FALSE,
ageImposeDay = FALSE,
ageUnit = "years",
ageGroup = NULL,
missingAgeGroupValue = "None",
sex = TRUE,
sexName = "sex",
missingSexValue = "None",
priorObservation = TRUE,
priorObservationName = "prior_observation",
priorObservationType = "days",
futureObservation = TRUE,
futureObservationName = "future_observation",
futureObservationType = "days",
dateOfBirth = FALSE,
dateOfBirthName = "date_of_birth",
name = NULL,
type = "numeric"
)
Arguments
x |
A table containing individuals in a CDM reference. |
indexDate |
Name of a date column in |
age |
If |
ageName |
Name of the age column to add. |
ageMissingMonth |
Month of the year assigned when month of birth is missing. |
ageMissingDay |
Day of the month assigned when day of birth is missing. |
ageImposeMonth |
If |
ageImposeDay |
If |
ageUnit |
Unit in which to express age: |
ageGroup |
If not |
missingAgeGroupValue |
Value to use when age is missing. |
sex |
If |
sexName |
Name of the sex column to add. |
missingSexValue |
Value to use when sex is missing. |
priorObservation |
If |
priorObservationName |
Name of the prior-observation column to add. |
priorObservationType |
Whether to return a |
futureObservation |
If |
futureObservationName |
Name of the future-observation column to add. |
futureObservationType |
Whether to return a |
dateOfBirth |
If |
dateOfBirthName |
Name of the date-of-birth column to add. |
name |
Name of the new table. If |
type |
Type of the created column(s). Counts, days, age, and observation
durations can be |
Value
cohort table with the added demographic information columns.
Examples
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
cdm$cohort1 |>
addDemographics()
cdm$cohort1 |>
addDemographics(indexDate = as.Date("2010-01-01"))
Query to add demographic characteristics at a certain date
Description
Same as addDemographics(), except query is not computed to a table.
Usage
addDemographicsQuery(
x,
indexDate = "cohort_start_date",
age = TRUE,
ageName = "age",
ageMissingMonth = 1,
ageMissingDay = 1,
ageImposeMonth = FALSE,
ageImposeDay = FALSE,
ageUnit = "years",
ageGroup = NULL,
missingAgeGroupValue = "None",
sex = TRUE,
sexName = "sex",
missingSexValue = "None",
priorObservation = TRUE,
priorObservationName = "prior_observation",
priorObservationType = "days",
futureObservation = TRUE,
futureObservationName = "future_observation",
futureObservationType = "days",
dateOfBirth = FALSE,
dateOfBirthName = "date_of_birth",
type = "numeric"
)
Arguments
x |
A table containing individuals in a CDM reference. |
indexDate |
Name of a date column in |
age |
If |
ageName |
Name of the age column to add. |
ageMissingMonth |
Month of the year assigned when month of birth is missing. |
ageMissingDay |
Day of the month assigned when day of birth is missing. |
ageImposeMonth |
If |
ageImposeDay |
If |
ageUnit |
Unit in which to express age: |
ageGroup |
If not |
missingAgeGroupValue |
Value to use when age is missing. |
sex |
If |
sexName |
Name of the sex column to add. |
missingSexValue |
Value to use when sex is missing. |
priorObservation |
If |
priorObservationName |
Name of the prior-observation column to add. |
priorObservationType |
Whether to return a |
futureObservation |
If |
futureObservationName |
Name of the future-observation column to add. |
futureObservationType |
Whether to return a |
dateOfBirth |
If |
dateOfBirthName |
Name of the date-of-birth column to add. |
type |
Type of the created column(s). Counts, days, age, and observation
durations can be |
Value
cohort table with the added demographic information columns.
Examples
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
cdm$cohort1 |>
addDemographicsQuery()
Compute the number of days till the end of the observation period at a certain date
Description
Compute the number of days till the end of the observation period at a certain date
Usage
addFutureObservation(
x,
indexDate = "cohort_start_date",
futureObservationName = "future_observation",
futureObservationType = "days",
name = NULL,
type = "numeric"
)
Arguments
x |
A table containing individuals in a CDM reference. |
indexDate |
Name of a date column in |
futureObservationName |
Name of the future-observation column to add. |
futureObservationType |
Whether to return a |
name |
Name of the new table. If |
type |
Type of the created column(s). Counts, days, age, and observation
durations can be |
Value
cohort table with added column containing future observation of the individuals.
Examples
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
cdm$cohort1 |>
addFutureObservation()
Query to add the number of days till the end of the observation period at a certain date
Description
Same as addFutureObservation(), except query is not computed to a table.
Usage
addFutureObservationQuery(
x,
indexDate = "cohort_start_date",
futureObservationName = "future_observation",
futureObservationType = "days",
type = "numeric"
)
Arguments
x |
A table containing individuals in a CDM reference. |
indexDate |
Name of a date column in |
futureObservationName |
Name of the future-observation column to add. |
futureObservationType |
Whether to return a |
type |
Type of the created column(s). Counts, days, age, and observation
durations can be |
Value
cohort table with added column containing future observation of the individuals.
Examples
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
cdm$cohort1 |>
addFutureObservationQuery()
Indicate if a certain record is within the observation period
Description
Indicate if a certain record is within the observation period
Usage
addInObservation(
x,
indexDate = "cohort_start_date",
window = c(0, 0),
completeInterval = FALSE,
nameStyle = "in_observation",
name = NULL,
type = "numeric"
)
Arguments
x |
A table containing individuals in a CDM reference. |
indexDate |
Name of a date column in |
window |
Window or windows of time relative to |
completeInterval |
If |
nameStyle |
Naming pattern for the added column or columns. It should
include the required formatting variables. If more than one |
name |
Name of the new table. If |
type |
Type of the created column(s). Counts, days, age, and observation
durations can be |
Value
Cohort table with an added column assessing observation. Values are
1/TRUE in observation and 0/FALSE otherwise, according to type.
Examples
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
cdm$cohort1 |>
addInObservation()
Query to add a new column to indicate if a certain record is within the observation period
Description
Same as addInObservation(), except query is not computed to a table.
Usage
addInObservationQuery(
x,
indexDate = "cohort_start_date",
window = c(0, 0),
completeInterval = FALSE,
nameStyle = "in_observation",
type = "numeric"
)
Arguments
x |
A table containing individuals in a CDM reference. |
indexDate |
Name of a date column in |
window |
Window or windows of time relative to |
completeInterval |
If |
nameStyle |
Naming pattern for the added column or columns. It should
include the required formatting variables. If more than one |
type |
Type of the created column(s). Counts, days, age, and observation
durations can be |
Value
Cohort table with an added column assessing observation. Values are
1/TRUE in observation and 0/FALSE otherwise, according to type.
Examples
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
cdm$cohort1 |>
addInObservationQuery()
Add the ordinal number of the observation period associated that a given date is in.
Description
Add the ordinal number of the observation period associated that a given date is in.
Usage
addObservationPeriodId(
x,
indexDate = "cohort_start_date",
nameObservationPeriodId = "observation_period_id",
name = NULL
)
Arguments
x |
A table containing individuals in a CDM reference. |
indexDate |
Name of a date column in |
nameObservationPeriodId |
Name of the observation-period ID column to add. |
name |
Name of the new table. If |
Value
Table with the current observation period id added.
Examples
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
cdm$cohort1 |>
addObservationPeriodId()
Add the ordinal number of the observation period associated that a given date is in. Result is not computed, only query is added.
Description
Add the ordinal number of the observation period associated that a given date is in. Result is not computed, only query is added.
Usage
addObservationPeriodIdQuery(
x,
indexDate = "cohort_start_date",
nameObservationPeriodId = "observation_period_id"
)
Arguments
x |
A table containing individuals in a CDM reference. |
indexDate |
Name of a date column in |
nameObservationPeriodId |
Name of the observation-period ID column to add. |
Value
Table with the current observation period id added.
Examples
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
cdm$cohort1 |>
addObservationPeriodIdQuery()
Compute the number of days of prior observation in the current observation period at a certain date
Description
Compute the number of days of prior observation in the current observation period at a certain date
Usage
addPriorObservation(
x,
indexDate = "cohort_start_date",
priorObservationName = "prior_observation",
priorObservationType = "days",
name = NULL,
type = "numeric"
)
Arguments
x |
A table containing individuals in a CDM reference. |
indexDate |
Name of a date column in |
priorObservationName |
Name of the prior-observation column to add. |
priorObservationType |
Whether to return a |
name |
Name of the new table. If |
type |
Type of the created column(s). Counts, days, age, and observation
durations can be |
Value
cohort table with added column containing prior observation of the individuals.
Examples
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
cdm$cohort1 |>
addPriorObservation()
Query to add the number of days of prior observation in the current observation period at a certain date
Description
Same as addPriorObservation(), except query is not computed to a table.
Usage
addPriorObservationQuery(
x,
indexDate = "cohort_start_date",
priorObservationName = "prior_observation",
priorObservationType = "days",
type = "numeric"
)
Arguments
x |
A table containing individuals in a CDM reference. |
indexDate |
Name of a date column in |
priorObservationName |
Name of the prior-observation column to add. |
priorObservationType |
Whether to return a |
type |
Type of the created column(s). Counts, days, age, and observation
durations can be |
Value
cohort table with added column containing prior observation of the individuals.
Examples
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
cdm$cohort1 |>
addPriorObservationQuery()
Compute the sex of the individuals
Description
Compute the sex of the individuals
Usage
addSex(x, sexName = "sex", missingSexValue = "None", name = NULL)
Arguments
x |
A table containing individuals in a CDM reference. |
sexName |
Name of the sex column to add. |
missingSexValue |
Value to use when sex is missing. |
name |
Name of the new table. If |
Value
table x with the added column with sex information.
Examples
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
cdm$cohort1 |>
addSex()
Query to add the sex of the individuals
Description
Same as addSex(), except query is not computed to a table.
Usage
addSexQuery(x, sexName = "sex", missingSexValue = "None")
Arguments
x |
A table containing individuals in a CDM reference. |
sexName |
Name of the sex column to add. |
missingSexValue |
Value to use when sex is missing. |
Value
table x with the added column with sex information.
Examples
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
cdm$cohort1 |>
addSexQuery()
Compute number of intersect with an omop table.
Description
Compute number of intersect with an omop table.
Usage
addTableIntersectCount(
x,
tableName,
indexDate = "cohort_start_date",
censorDate = NULL,
window = list(c(0, Inf)),
targetStartDate = startDateColumn(tableName),
targetEndDate = endDateColumn(tableName),
inObservation = TRUE,
nameStyle = "{table_name}_{window_name}",
name = NULL,
type = "numeric"
)
Arguments
x |
A table containing individuals in a CDM reference. |
tableName |
Names of one or more OMOP CDM tables to intersect with. |
indexDate |
Name of a date column in |
censorDate |
Date or name of a date column in |
window |
Window or windows of time relative to |
targetStartDate |
Name or names of start-date columns in the target tables to use for the intersection. |
targetEndDate |
Name or names of end-date columns in the target tables
to use for the intersection. If |
inObservation |
If |
nameStyle |
Naming pattern for the added column or columns. It should
include the required formatting variables. If more than one |
name |
Name of the new table. If |
type |
Type of the created column(s). Counts, days, age, and observation
durations can be |
Value
The original table (x) with one added column per intersection with the desired table in a specific window. One column will be created for each combination of window and table. The value of the column will be the number of intersections in the desired window, or NA if the individual is not in observation at any time in the window.
Examples
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
cdm$cohort1 |>
addTableIntersectCount(tableName = "visit_occurrence")
Compute date of intersect with an omop table.
Description
Compute date of intersect with an omop table.
Usage
addTableIntersectDate(
x,
tableName,
indexDate = "cohort_start_date",
censorDate = NULL,
window = list(c(0, Inf)),
targetDate = startDateColumn(tableName),
inObservation = TRUE,
order = "first",
nameStyle = "{table_name}_{window_name}",
name = NULL
)
Arguments
x |
A table containing individuals in a CDM reference. |
tableName |
Names of one or more OMOP CDM tables to intersect with. |
indexDate |
Name of a date column in |
censorDate |
Date or name of a date column in |
window |
Window or windows of time relative to |
targetDate |
Name or names of date columns in the target tables to use for the intersection. |
inObservation |
If |
order |
Which record to use when multiple records occur in a window:
|
nameStyle |
Naming pattern for the added column or columns. It should
include the required formatting variables. If more than one |
name |
Name of the new table. If |
Value
table with added columns with intersect information.
Examples
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
cdm$cohort1 |>
addTableIntersectDate(tableName = "visit_occurrence")
Compute time to intersect with an omop table.
Description
Compute time to intersect with an omop table.
Usage
addTableIntersectDays(
x,
tableName,
indexDate = "cohort_start_date",
censorDate = NULL,
window = list(c(0, Inf)),
targetDate = startDateColumn(tableName),
inObservation = TRUE,
order = "first",
nameStyle = "{table_name}_{window_name}",
name = NULL,
type = "numeric"
)
Arguments
x |
A table containing individuals in a CDM reference. |
tableName |
Names of one or more OMOP CDM tables to intersect with. |
indexDate |
Name of a date column in |
censorDate |
Date or name of a date column in |
window |
Window or windows of time relative to |
targetDate |
Name or names of date columns in the target tables to use for the intersection. |
inObservation |
If |
order |
Which record to use when multiple records occur in a window:
|
nameStyle |
Naming pattern for the added column or columns. It should
include the required formatting variables. If more than one |
name |
Name of the new table. If |
type |
Type of the created column(s). Counts, days, age, and observation
durations can be |
Value
table with added columns with intersect information.
Examples
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
cdm$cohort1 |>
addTableIntersectDays(tableName = "visit_occurrence")
Intersecting the cohort with columns of an OMOP table of user's choice. It will add an extra column to the cohort, indicating the intersected entries with the target columns in a window of the user's choice.
Description
Intersecting the cohort with columns of an OMOP table of user's choice. It will add an extra column to the cohort, indicating the intersected entries with the target columns in a window of the user's choice.
Usage
addTableIntersectField(
x,
tableName,
field,
indexDate = "cohort_start_date",
censorDate = NULL,
window = list(c(0, Inf)),
targetDate = startDateColumn(tableName),
inObservation = TRUE,
order = "first",
allowDuplicates = FALSE,
nameStyle = "{table_name}_{field}_{window_name}",
name = NULL,
type = "auto"
)
Arguments
x |
A table containing individuals in a CDM reference. |
tableName |
Names of one or more OMOP CDM tables to intersect with. |
field |
Name or names of columns in the target tables to add to |
indexDate |
Name of a date column in |
censorDate |
Date or name of a date column in |
window |
Window or windows of time relative to |
targetDate |
Name or names of date columns in the target tables to use for the intersection. |
inObservation |
If |
order |
Which record to use when multiple records occur in a window:
|
allowDuplicates |
Whether to allow multiple records for the same person,
target, and date. If |
nameStyle |
Naming pattern for the added column or columns. It should
include the required formatting variables. If more than one |
name |
Name of the new table. If |
type |
Type of the created column(s). Counts, days, age, and observation
durations can be |
Value
table with added columns with intersect information.
Examples
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
cdm$cohort1 |>
addTableIntersectField(
tableName = "visit_occurrence",
field = "visit_concept_id",
order = "last",
window = c(-Inf, -1)
)
Compute a flag intersect with an omop table
Description
Compute a flag intersect with an omop table
Usage
addTableIntersectFlag(
x,
tableName,
indexDate = "cohort_start_date",
censorDate = NULL,
window = list(c(0, Inf)),
targetStartDate = startDateColumn(tableName),
targetEndDate = endDateColumn(tableName),
inObservation = TRUE,
nameStyle = "{table_name}_{window_name}",
name = NULL,
type = "numeric"
)
Arguments
x |
A table containing individuals in a CDM reference. |
tableName |
Names of one or more OMOP CDM tables to intersect with. |
indexDate |
Name of a date column in |
censorDate |
Date or name of a date column in |
window |
Window or windows of time relative to |
targetStartDate |
Name or names of start-date columns in the target tables to use for the intersection. |
targetEndDate |
Name or names of end-date columns in the target tables
to use for the intersection. If |
inObservation |
If |
nameStyle |
Naming pattern for the added column or columns. It should
include the required formatting variables. If more than one |
name |
Name of the new table. If |
type |
Type of the created column(s). Counts, days, age, and observation
durations can be |
Value
The original table (x) with one added column per intersection with the desired table in a specific window. One column will be created for each combination of window and table. The value of the column can either indicate presence (1 or TRUE), no intersection (0 or FALSE), or NA if the individual is not in observation at any time of the window. The representation depends on type.
Examples
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
cdm$cohort1 |>
addTableIntersectFlag(tableName = "visit_occurrence")
Helper for consistent documentation of age.
Description
Helper for consistent documentation of age.
Arguments
age |
If |
Helper for consistent documentation of ageGroup.
Description
Helper for consistent documentation of ageGroup.
Arguments
ageGroup |
If not |
Helper for consistent documentation of ageImposeDay.
Description
Helper for consistent documentation of ageImposeDay.
Arguments
ageImposeDay |
If |
Helper for consistent documentation of ageImposeMonth.
Description
Helper for consistent documentation of ageImposeMonth.
Arguments
ageImposeMonth |
If |
Helper for consistent documentation of ageMissingDay.
Description
Helper for consistent documentation of ageMissingDay.
Arguments
ageMissingDay |
Day of the month assigned when day of birth is missing. |
Helper for consistent documentation of ageMissingMonth.
Description
Helper for consistent documentation of ageMissingMonth.
Arguments
ageMissingMonth |
Month of the year assigned when month of birth is missing. |
Helper for consistent documentation of ageName.
Description
Helper for consistent documentation of ageName.
Arguments
ageName |
Name of the age column to add. |
Helper for consistent documentation of ageUnit.
Description
Helper for consistent documentation of ageUnit.
Arguments
ageUnit |
Unit in which to express age: |
Helper for consistent documentation of allowDuplicates.
Description
Helper for consistent documentation of allowDuplicates.
Arguments
allowDuplicates |
Whether to allow multiple records for the same person,
target, and date. If |
Show the available estimates that can be used for the different variable_type supported.
Description
Show the available estimates that can be used for the different variable_type supported.
Usage
availableEstimates(variableType = NULL, fullQuantiles = FALSE)
Arguments
variableType |
A set of variable types. |
fullQuantiles |
Whether to display the exact quantiles that can be computed or only the qXX to summarise all of them. |
Value
A tibble with the available estimates.
Examples
library(PatientProfiles)
availableEstimates()
availableEstimates("numeric")
availableEstimates(c("numeric", "categorical"))
Benchmark intersections and demographics functions for a certain source (cdm).
Description
Benchmark intersections and demographics functions for a certain source (cdm).
Usage
benchmarkPatientProfiles(cdm, n = 50000, iterations = 1)
Arguments
cdm |
A |
n |
Size of the synthetic cohorts used to benchmark. |
iterations |
Number of iterations to run the benchmark. |
Value
A summarise_result object with the summary statistics.
Helper for consistent documentation of birthday.
Description
Helper for consistent documentation of birthday.
Arguments
birthday |
Day of birth to add. |
Helper for consistent documentation of birthdayName.
Description
Helper for consistent documentation of birthdayName.
Arguments
birthdayName |
Name of the birthday column to add. |
Helper for consistent documentation of cdm.
Description
Helper for consistent documentation of cdm.
Arguments
cdm |
A |
Helper for consistent documentation of censorDate.
Description
Helper for consistent documentation of censorDate.
Arguments
censorDate |
Date or name of a date column in |
Helper for consistent documentation of cohort.
Description
Helper for consistent documentation of cohort.
Arguments
cohort |
A |
Helper for consistent documentation of completeInterval.
Description
Helper for consistent documentation of completeInterval.
Arguments
completeInterval |
If |
Helper for consistent documentation of conceptSet.
Description
Helper for consistent documentation of conceptSet.
Arguments
conceptSet |
A named list of concept sets. |
Helper for consistent documentation of dateOfBirth.
Description
Helper for consistent documentation of dateOfBirth.
Arguments
dateOfBirth |
If |
Helper for consistent documentation of dateOfBirthName.
Description
Helper for consistent documentation of dateOfBirthName.
Arguments
dateOfBirthName |
Name of the date-of-birth column to add. |
Get the name of the end date column for a certain table in the cdm
Description
Get the name of the end date column for a certain table in the cdm
Usage
endDateColumn(tableName)
Arguments
tableName |
Name of the table. |
Value
Name of the end date column in that table.
Examples
library(PatientProfiles)
endDateColumn("condition_occurrence")
Helper for consistent documentation of field.
Description
Helper for consistent documentation of field.
Arguments
field |
Name or names of columns in the target tables to add to |
Filter a cohort according to cohort_definition_id column, the result is not computed into a table. only a query is added. Used usually as internal functions of other packages.
Description
Filter a cohort according to cohort_definition_id column, the result is not computed into a table. only a query is added. Used usually as internal functions of other packages.
Usage
filterCohortId(cohort, cohortId = NULL)
Arguments
cohort |
A |
cohortId |
A vector with cohort ids. |
Value
A cohort_table object.
Filter the rows of a cdm_table to the ones in observation that indexDate
is in observation.
Description
Filter the rows of a cdm_table to the ones in observation that indexDate
is in observation.
Usage
filterInObservation(x, indexDate)
Arguments
x |
A table containing individuals in a CDM reference. |
indexDate |
Name of a date column in |
Value
A cdm_table that is a subset of the original table.
Examples
## Not run:
library(PatientProfiles)
library(omock)
cdm <- mockCdmFromDataset(datasetName = "GiBleed", source = "duckdb")
cdm$condition_occurrence |>
filterInObservation(indexDate = "condition_start_date")
## End(Not run)
Helper for consistent documentation of futureObservation.
Description
Helper for consistent documentation of futureObservation.
Arguments
futureObservation |
If |
Helper for consistent documentation of futureObservationName.
Description
Helper for consistent documentation of futureObservationName.
Arguments
futureObservationName |
Name of the future-observation column to add. |
Helper for consistent documentation of futureObservationType.
Description
Helper for consistent documentation of futureObservationType.
Arguments
futureObservationType |
Whether to return a |
Helper for consistent documentation of imposeDay.
Description
Helper for consistent documentation of imposeDay.
Arguments
imposeDay |
If |
Helper for consistent documentation of imposeMonth.
Description
Helper for consistent documentation of imposeMonth.
Arguments
imposeMonth |
If |
Helper for consistent documentation of inObservation.
Description
Helper for consistent documentation of inObservation.
Arguments
inObservation |
If |
Helper for consistent documentation of indexDate.
Description
Helper for consistent documentation of indexDate.
Arguments
indexDate |
Name of a date column in |
Helper for consistent documentation of missingAgeGroupValue.
Description
Helper for consistent documentation of missingAgeGroupValue.
Arguments
missingAgeGroupValue |
Value to use when age is missing. |
Helper for consistent documentation of missingDay.
Description
Helper for consistent documentation of missingDay.
Arguments
missingDay |
Day of the month assigned when day of birth is missing. |
Helper for consistent documentation of missingMonth.
Description
Helper for consistent documentation of missingMonth.
Arguments
missingMonth |
Month of the year assigned when month of birth is missing. |
Helper for consistent documentation of missingSexValue.
Description
Helper for consistent documentation of missingSexValue.
Arguments
missingSexValue |
Value to use when sex is missing. |
Deprecated
Description
Deprecated
Usage
mockDisconnect(cdm)
Arguments
cdm |
A |
It creates a mock database for testing PatientProfiles package
Description
It creates a mock database for testing PatientProfiles package
Usage
mockPatientProfiles(
numberIndividuals = 10,
...,
source = "local",
con = lifecycle::deprecated(),
writeSchema = lifecycle::deprecated(),
seed = lifecycle::deprecated()
)
Arguments
numberIndividuals |
Number of individuals to create in the cdm reference. |
... |
User self defined tables to put in cdm, it can input as many as the user want. |
source |
Source for the mock cdm, it can either be 'local' or 'duckdb'.
By default, vocabulary tables are populated from the GiBleed mock vocabulary
provided by omock. A user-provided |
con |
deprecated. |
writeSchema |
deprecated. |
seed |
deprecated. |
Value
A mock cdm_reference object created following user's specifications.
Examples
library(PatientProfiles)
cdm <- mockPatientProfiles()
Helper for consistent documentation of multipleEvents.
Description
Helper for consistent documentation of multipleEvents.
Arguments
multipleEvents |
How events occurring on the same date are handled. If
|
Helper for consistent documentation of name.
Description
Helper for consistent documentation of name.
Arguments
name |
Name of the new table. If |
Helper for consistent documentation of nameObservationPeriodId.
Description
Helper for consistent documentation of nameObservationPeriodId.
Arguments
nameObservationPeriodId |
Name of the observation-period ID column to add. |
Helper for consistent documentation of nameStyle.
Description
Helper for consistent documentation of nameStyle.
Arguments
nameStyle |
Naming pattern for the added column or columns. It should
include the required formatting variables. If more than one |
Helper for event-specific documentation of nameStyle.
Description
Helper for event-specific documentation of nameStyle.
Arguments
nameStyle |
Naming pattern for the added columns. It must contain
|
Helper for consistent documentation of order.
Description
Helper for consistent documentation of order.
Arguments
order |
Which record to use when multiple records occur in a window:
|
Helper for consistent documentation of priorObservation.
Description
Helper for consistent documentation of priorObservation.
Arguments
priorObservation |
If |
Helper for consistent documentation of priorObservationName.
Description
Helper for consistent documentation of priorObservationName.
Arguments
priorObservationName |
Name of the prior-observation column to add. |
Helper for consistent documentation of priorObservationType.
Description
Helper for consistent documentation of priorObservationType.
Arguments
priorObservationType |
Whether to return a |
Objects exported from other packages
Description
These objects are imported from other packages. Follow the links below to see their documentation.
- omopgenerics
Helper for consistent documentation of sex.
Description
Helper for consistent documentation of sex.
Arguments
sex |
If |
Helper for consistent documentation of sexName.
Description
Helper for consistent documentation of sexName.
Arguments
sexName |
Name of the sex column to add. |
Get the name of the source concept_id column for a certain table in the cdm
Description
Get the name of the source concept_id column for a certain table in the cdm
Usage
sourceConceptIdColumn(tableName)
Arguments
tableName |
Name of the table. |
Value
Name of the source_concept_id column in that table.
Examples
library(PatientProfiles)
sourceConceptIdColumn("condition_occurrence")
Get the name of the standard concept_id column for a certain table in the cdm
Description
Get the name of the standard concept_id column for a certain table in the cdm
Usage
standardConceptIdColumn(tableName)
Arguments
tableName |
Name of the table. |
Value
Name of the concept_id column in that table.
Examples
library(PatientProfiles)
standardConceptIdColumn("condition_occurrence")
Get the name of the start date column for a certain table in the cdm
Description
Get the name of the start date column for a certain table in the cdm
Usage
startDateColumn(tableName)
Arguments
tableName |
Name of the table. |
Value
Name of the start date column in that table.
Examples
library(PatientProfiles)
startDateColumn("condition_occurrence")
Summarise variables using a set of estimate functions. The output will be a formatted summarised_result object.
Description
Summarise variables using a set of estimate functions. The output will be a formatted summarised_result object.
Usage
summariseResult(
table,
group = list(),
includeOverallGroup = FALSE,
strata = list(),
includeOverallStrata = TRUE,
variables = NULL,
estimates = NULL,
counts = TRUE,
weights = NULL,
customEstimates = list()
)
Arguments
table |
A table to process. |
group |
List of groups to be considered. |
includeOverallGroup |
TRUE or FALSE. If TRUE, results for an overall group will be reported when a list of groups has been specified. |
strata |
List of the stratifications within each group to be considered. |
includeOverallStrata |
TRUE or FALSE. If TRUE, results for an overall strata will be reported when a list of strata has been specified. |
variables |
Variables to summarise, it can be a list to point to different set of estimate names. |
estimates |
Estimates to obtain, it can be a list to point to different set of variables. |
counts |
Whether to compute number of records and number of subjects. |
weights |
Name of the column in the table that contains the weights to be used when measuring the estimates. |
customEstimates |
Named list of custom functions. Each function must
accept a variable vector as its first argument and return one numeric value.
If |
Value
A summarised_result object with the summarised data of interest.
Examples
library(PatientProfiles)
cdm <- mockPatientProfiles(source = "duckdb")
x <- cdm$cohort1 |>
addDemographics()
# summarise all variables with default estimates
result <- summariseResult(x)
result
# get only counts of records and subjects
result <- summariseResult(x, variables = character())
result
# specify variables and estimates
result <- summariseResult(
table = x,
variables = c("cohort_start_date", "age"),
estimates = c("mean", "median", "density")
)
result
# different estimates for each variable
result <- summariseResult(
table = x,
variables = list(c("age", "prior_observation"), "sex"),
estimates = list(c("min", "max"), c("count", "percentage"))
)
# add a custom estimate
ess <- function(x) sum(x^2) / sum(x)
result <- summariseResult(
table = x,
variables = "age",
estimates = "ess",
customEstimates = list(ess = ess)
)
Helper for consistent documentation of table.
Description
Helper for consistent documentation of table.
Arguments
table |
A table to process. |
Helper for consistent documentation of tableName.
Description
Helper for consistent documentation of tableName.
Arguments
tableName |
Names of one or more OMOP CDM tables to intersect with. |
Helper for consistent documentation of targetCohortId.
Description
Helper for consistent documentation of targetCohortId.
Arguments
targetCohortId |
Cohort definition IDs to include from
|
Helper for consistent documentation of targetCohortTable.
Description
Helper for consistent documentation of targetCohortTable.
Arguments
targetCohortTable |
Name of the cohort table to intersect with. |
Helper for consistent documentation of targetDate.
Description
Helper for consistent documentation of targetDate.
Arguments
targetDate |
Name or names of date columns in the target tables to use for the intersection. |
Helper for consistent documentation of targetEndDate.
Description
Helper for consistent documentation of targetEndDate.
Arguments
targetEndDate |
Name or names of end-date columns in the target tables
to use for the intersection. If |
Helper for consistent documentation of targetStartDate.
Description
Helper for consistent documentation of targetStartDate.
Arguments
targetStartDate |
Name or names of start-date columns in the target tables to use for the intersection. |
Helper for consistent documentation of type.
Description
Helper for consistent documentation of type.
Arguments
type |
Type of the created column(s). Counts, days, age, and observation
durations can be |
Classify the variables between 5 types: "numeric", "categorical", "logical", "date", "integer", or NA.
Description
Classify the variables between 5 types: "numeric", "categorical", "logical", "date", "integer", or NA.
Usage
variableTypes(table)
Arguments
table |
A table to process. |
Value
Tibble with the variables type and classification.
Examples
library(PatientProfiles)
library(dplyr, warn.conflicts = TRUE)
x <- tibble(
person_id = c(1, 2),
start_date = as.Date(c("2020-05-02", "2021-11-19")),
asthma = c(0, 1)
)
variableTypes(x)
Helper for consistent documentation of window.
Description
Helper for consistent documentation of window.
Arguments
window |
Window or windows of time relative to |
Helper for consistent documentation of x.
Description
Helper for consistent documentation of x.
Arguments
x |
A table containing individuals in a CDM reference. |