Query to add demographic characteristics at a certain date
Source:R/addDemographicsQuery.R
addDemographicsQuery.Rd
`r lifecycle::badge("experimental")` 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,
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"
)
Arguments
- x
Table with individuals in the cdm.
- indexDate
Variable in x that contains the date to compute the demographics characteristics.
- age
TRUE or FALSE. If TRUE, age will be calculated relative to indexDate.
- ageName
Age variable name.
- ageMissingMonth
Month of the year assigned to individuals with missing month of birth.
- ageMissingDay
day of the month assigned to individuals with missing day of birth.
- ageImposeMonth
TRUE or FALSE. Whether the month of the date of birth will be considered as missing for all the individuals.
- ageImposeDay
TRUE or FALSE. Whether the day of the date of birth will be considered as missing for all the individuals.
- ageGroup
if not NULL, a list of ageGroup vectors.
- missingAgeGroupValue
Value to include if missing age.
- sex
TRUE or FALSE. If TRUE, sex will be identified.
- sexName
Sex variable name.
- missingSexValue
Value to include if missing sex.
- priorObservation
TRUE or FALSE. If TRUE, days of between the start of the current observation period and the indexDate will be calculated.
- priorObservationName
Prior observation variable name.
- priorObservationType
Whether to return a "date" or the number of "days".
- futureObservation
TRUE or FALSE. If TRUE, days between the indexDate and the end of the current observation period will be calculated.
- futureObservationName
Future observation variable name.
- futureObservationType
Whether to return a "date" or the number of "days".
- dateOfBirth
TRUE or FALSE, if true the date of birth will be return.
- dateOfBirthName
dateOfBirth column name.
Examples
# \donttest{
library(PatientProfiles)
cdm <- mockPatientProfiles()
cdm$cohort1 %>%
addDemographicsQuery()
#> # Source: SQL [10 x 8]
#> # Database: DuckDB v1.1.2 [unknown@Linux 6.5.0-1025-azure:R 4.4.2/:memory:]
#> cohort_definition_id subject_id cohort_start_date cohort_end_date age sex
#> <int> <int> <date> <date> <int> <chr>
#> 1 3 1 1983-04-25 1993-07-26 23 Male
#> 2 1 2 1905-10-24 1908-08-13 3 Male
#> 3 3 3 1921-01-15 1924-04-30 2 Fema…
#> 4 2 4 1950-06-13 1950-07-10 45 Male
#> 5 3 5 1979-06-02 1981-09-09 4 Fema…
#> 6 1 6 1946-05-25 1971-02-17 25 Fema…
#> 7 2 7 1947-04-22 1962-11-15 18 Fema…
#> 8 1 8 2009-05-22 2015-03-29 32 Male
#> 9 2 9 1960-02-10 1960-04-23 36 Fema…
#> 10 3 10 1995-12-11 1997-12-04 15 Fema…
#> # ℹ 2 more variables: prior_observation <int>, future_observation <int>
mockDisconnect(cdm = cdm)
# }