MultipleOccurrencesPhenotype
Bases: Phenotype
CodelistPhenotype is a class that looks for N occurrences of a event (from an EventTable). In this Phenotype, the returned VALUE is equal to the number of occurrences of the event passing all filters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the phenotype. |
required |
phenotype
|
Phenotype
|
The phenotype events to look for. |
required |
n_occurrences
|
int
|
The minimum number of occurrences to look for. |
2
|
date_range
|
DateRangeFilter
|
A date range filter to apply. |
None
|
relative_time_range
|
RelativeTimeRangeFilter
|
A relative time range filter to apply. |
None
|
return_date
|
Specifies whether to return the 'first' or 'last' event date. Default is 'first'. |
'first'
|
Example
codelist = Codelist(name="example_codelist", codes=[...])
date_range = DateRangeFilter(min_date="2020-01-01", max_date="2020-12-31")
phenotype = CodelistPhenotype(
name="example_phenotype",
domain="CONDITION_OCCURRENCE",
codelist=codelist,
date_range=date_range,
return_date='first'
)
tables = {"CONDITION_OCCURRENCE": example_code_table}
multiple_occurrences = MultipleOccurrencesPhenotype(
phenotype=phenotype,
n_occurrences=2,
return_date='second')
result_table = multiple_occurrences.execute(tables)
display(result_table)
Source code in phenex/phenotypes/multiple_occurrences_phenotype.py
namespaced_table
property
A PhenotypeTable has generic column names 'person_id', 'boolean', 'event_date', and 'value'. The namespaced_table appends the phenotype name to all of these columns. This is useful when joining multiple phenotype tables together.
Returns:
Name | Type | Description |
---|---|---|
table |
Table
|
The namespaced table for the current phenotype. |
execute(tables)
Executes the phenotype computation for the current object and its children. This method recursively iterates over the children of the current object and calls their execute method if their table attribute is None.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tables
|
Dict[str, PhenexTable]
|
A dictionary mapping table names to PhenexTable objects. See phenex.mappers.DomainsDictionary.get_mapped_tables(). |
required |
Returns:
Name | Type | Description |
---|---|---|
table |
PhenotypeTable
|
The resulting phenotype table containing the required columns. The PhenotypeTable will contain the columns: PERSON_ID, EVENT_DATE, VALUE. DATE is determined by the return_date parameter. VALUE is different for each phenotype. For example, AgePhenotype will return the age in the VALUE column. A MeasurementPhenotype will return the observed value for the measurement. See the specific phenotype of interest to understand more. |