onconova.research.schemas.cohort
CohortQueryEntity
module-attribute
¶
Enumeration of case-related resource entities for cohort queries.
CohortQueryFilter
module-attribute
¶
Enumeration of available filter operators for cohort queries.
Cohort
¶
Bases: CohortCreate
, MetadataMixin
population
class-attribute
instance-attribute
¶
CohortContribution
¶
Bases: Schema
Schema representing a user's contribution to a cohort.
Attributes:
Name | Type | Description |
---|---|---|
contributor |
str
|
Username or identifier of the contributing user. |
contributions |
int
|
The number of records or actions contributed by this user. |
CohortCreate
¶
Bases: BaseSchema
__orm_model__
class-attribute
instance-attribute
¶
casesIds
class-attribute
instance-attribute
¶
excludeCriteria
class-attribute
instance-attribute
¶
externalSource
class-attribute
instance-attribute
¶
externalSourceId
class-attribute
instance-attribute
¶
frozenSetIds
class-attribute
instance-attribute
¶
includeCriteria
class-attribute
instance-attribute
¶
manualChoicesIds
class-attribute
instance-attribute
¶
name
class-attribute
instance-attribute
¶
projectId
class-attribute
instance-attribute
¶
CohortFilters
¶
Bases: create_filters_schema(schema=Cohort, name='CohortFilters')
createdBy
class-attribute
instance-attribute
¶
CohortRule
¶
Bases: Schema
Represents a rule for cohort selection, specifying an entity and a set of filters.
Attributes:
Name | Type | Description |
---|---|---|
entity |
CohortQueryEntity
|
The case-related resource to which the rule applies. |
filters |
List[CohortRuleFilter]
|
A list of filters to be applied to the resource. |
entity
class-attribute
instance-attribute
¶
filters
class-attribute
instance-attribute
¶
convert_to_query()
¶
Converts the cohort filters into Django Q objects for querying the database.
Iterates over the filters defined in the cohort, applies the corresponding operator to each filter, and combines them using logical AND. If the entity is a PatientCase, yields the combined Q object directly. Otherwise, constructs a subquery that filters related PatientCase objects and yields a Q object representing the existence of such cases.
Yields:
Type | Description |
---|---|
Q
|
Iterator[Q]: An iterator of Django Q objects representing the query for the cohort. |
Source code in onconova/research/schemas/cohort.py
CohortRuleFilter
¶
Bases: Schema
Schema representing a filter rule for cohort queries.
Attributes:
Name | Type | Description |
---|---|---|
field |
str
|
Dot-separated path of the resource field (e.g. 'medications.drug'). |
operator |
CohortQueryFilter
|
Name of the filter operator to be applied to the field. |
value |
Any
|
Filter value to be applied to the field using the rule's operator. |
db_value |
Any
|
Returns the value formatted for database queries. If the value is a dictionary with 'unit' and 'value', it converts it using |
db_field |
Any
|
Converts the dot-separated field path into Django ORM double-underscore syntax (e.g. 'medications.drug' -> 'medications__drug'). |
CohortRuleset
¶
Bases: Schema
Represents a set of cohort rules combined by a logical condition (AND/OR).
Attributes:
Name | Type | Description |
---|---|---|
condition |
RulesetCondition
|
Logical condition used to chain the rules within the ruleset. |
rules |
List[Union[CohortRule, CohortRuleset]]
|
List of rules or nested rulesets that define the fields and values to use for filtering. |
condition
class-attribute
instance-attribute
¶
rules
class-attribute
instance-attribute
¶
convert_to_query()
¶
Converts the ruleset into a Django Q object query iterator.
Iterates through each rule in the ruleset, combining their queries using the specified logical condition (AND/OR). For each rule, its query is combined with the accumulated query using the condition. The final combined query is yielded as an iterator.
Returns:
Type | Description |
---|---|
Iterator[Q]
|
Iterator[Q]: An iterator yielding the combined Q object representing the ruleset's logic. |
Source code in onconova/research/schemas/cohort.py
CohortTraitAverage
¶
Bases: Schema
Schema representing the average and standard deviation of a trait within a cohort.
Attributes:
Name | Type | Description |
---|---|---|
average |
float
|
The mean value for the cohort trait. |
standardDeviation |
Optional[float]
|
The standard deviation for the cohort trait, if applicable. May be None. |
CohortTraitCounts
¶
Bases: Schema
Schema representing the count and percentage of records for a specific cohort trait category.
Attributes:
Name | Type | Description |
---|---|---|
category |
str
|
The category or group label for the cohort trait value. |
counts |
int
|
The number of records in this category. |
percentage |
float
|
The percentage of the total cohort population in this category. |
CohortTraitMedian
¶
CohortTraits
¶
Bases: Schema
Schema representing key traits and distributions within a patient cohort.
Attributes:
Name | Type | Description |
---|---|---|
age |
CohortTraitMedian
|
Median age of individuals in the cohort. |
dataCompletion |
CohortTraitMedian
|
Median percentage of completed data per patient. |
overallSurvival |
Nullable[CohortTraitMedian]
|
Median overall survival time in the cohort, if available. |
genders |
List[CohortTraitCounts]
|
Distribution of genders within the cohort. |
neoplasticSites |
List[CohortTraitCounts]
|
Distribution of neoplastic (tumor) sites in the cohort. |
therapyLines |
List[CohortTraitCounts]
|
Distribution of therapy lines received by patients in the cohort. |
consentStatus |
List[CohortTraitCounts]
|
Distribution of consent statuses for data use among cohort participants. |
age
class-attribute
instance-attribute
¶
consentStatus
class-attribute
instance-attribute
¶
dataCompletion
class-attribute
instance-attribute
¶
genders
class-attribute
instance-attribute
¶
neoplasticSites
class-attribute
instance-attribute
¶
overallSurvival
class-attribute
instance-attribute
¶
therapyLines
class-attribute
instance-attribute
¶
ExportedCohortDefinition
¶
Bases: ExportMetadata
Represents an exported cohort definition along with its export metadata.
Attributes:
Name | Type | Description |
---|---|---|
definition |
CohortCreateSchema
|
The cohort definition, including its title and description. |