ehrdata.io.omop.setup_obs#
- ehrdata.io.omop.setup_obs(backend_handle, observation_table, *, death_table=False)#
Setup the observation table for
EHRDataobject.For this, a table from the OMOP CDM which represents what a “row” in the
EHRDataobject should represent.This will be used to set that start timepoint for the time series data in the
EHRDataobject.Possible choices for the
observation_tableparameter are:"person": Create one row per personperson_idin thepersontable"person_cohort": Create one row per personsubject_idin a cohort in thecohorttable"person_observation_period": Create one row per observation_period_id in theobservation_periodtable"person_visit_occurrence": Create one row per visit_occurrence_id in thevisit_occurrencetable
Data characterizing the rows such as person demographics, and e.g. visit start and end dates are stored in the
.obsfield of the createdEHRDataobject. Notice a singleperson_idcan have multiple rows for e.g."person_visit_occurrence"if a person has multiple visit occurrences.Example: 1000 person_id in the
person_table, with 100 people having 1 visit occurrence, 100 people having 2 visit occurrences, and 800 people having no visit occurrences. Ifobservation_table = "person", the createdEHRDataobject will have 1000 rows. Ifobservation_table = "person_visit_occurrence", the createdEHRDataobject will have 300 rows.The possible choices affect what is taken as the “time 0” in the
setup_variables()andsetup_interval_variables()functions:If
"person", thebirth_datetimewill be used as “time 0”. Note: All persons must have valid (non-NULL)birth_datetimevalues when using this option withsetup_variables()andsetup_interval_variables().If
"person_cohort", thecohort_start_date(time)will be used as “time 0” in thesetup_variables()andsetup_interval_variables()functions.If
"person_observation_period", theobservation_period_start_date(time)will be used as “time 0” in thesetup_variables()andsetup_interval_variables()functions.If
"person_visit_occurrence", thevisit_start_date(time)will be used as “time 0” in thesetup_variables()andsetup_interval_variables()functions.
For
"person_cohort", thesubject_idof the cohort is considered to be theperson_idfor a join.- Parameters:
- backend_handle
DuckDBPyConnection The backend handle to the database.
- observation_table
Literal['person','person_cohort','person_observation_period','person_visit_occurrence'] The observation table to be used.
- death_table
bool(default:False) Whether to include the
deathtable. Theobservation_tablecreated will be left joined with thedeathtable as the right table.
- backend_handle
- Returns:
An
EHRDataobject with populated.obsfield.
Examples
>>> import ehrdata as ed >>> import duckdb >>> con_gi = duckdb.connect(database=":memory:", read_only=False) >>> ed.dt.gibleed_omop( ... con_gi, ... ) >>> edata_gi = ed.io.omop.setup_obs( >>> con_gi, >>> observation_table="person_observation_period", >>> ) >>> edata_gi