Function
age_at_index
def age_at_index(database: str, index_date: sql.dataframe.DataFrame)
-
Description
The age_at_index function calculates the age at an already defined index date of all patients in a cohort.
Inputs
-
database - database name to use
-
index_date - user defined table with two columns
-
patient id
-
index_date
-
Returns
-
a spark dataframe with two columns
-
patient_id
-
age_at_index: defined as the year of the date in the index_date column of the index_date input minus year_of_birth from the database patient table
- if patients don’t have an index date or a year_of_birth, return null for that patient_id
-
Example
age_at_index = tnx.age_at_index(database=db, index_date=index_date)
-