criteria
The criterion taxonomy: what an analysis verdict is made of.
An eligibility verdict rests on criteria, and every criterion is structurally the same — a value, a unit, a grain, where it came from — whatever family it belongs to. The families differ in which of those fields are populated, and are declared here as narrowings of the base model so the contract can publish each as its own named schema rather than leaving the differences to prose.
Classes
AppointmentCriterion
class AppointmentCriterion(**data: Any):Variant: appointment history / current patient.
Patient-grain, EHR-provenance MethodFilters reading the appointment and
encounter columns together, so value is always null.
-
Current patientrecords{"current_patient_months": {"lte": <months>}}, the recency window it enforces. The filter compares appointment dates against a cutoff derived from that window rather than comparing a month count, so read the pair as the configured window, not as a comparison reproducible fromvalue. -
Appointment historyrecords an empty operator map: it has two operands (years,min_per_year) under one config field, and the map holds one operand per operator token. Read both from the task config. -
Appointment history(appointment_history) — the history spansyearsyears and each of those years holds at leastmin_per_yearappointments. One criterion, not two. -
Current patient(current_patient_months) — an appointment within the last N months.
Both are unknown — never fail — when the ehr_query step ran without
fetch_appointments, or when the appointment records were only partly
readable.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Ancestors
Variables
- static
config_fields : dict[typing.Literal['appointment_history', 'current_patient_months'], dict[CriterionOperator, bool | int | float | str | list[typing.Any] | None]]
- static
family : Literal[<CriterionFamily.APPOINTMENT: 'appointment'>]
- static
grain : Literal[<CriterionGrain.PATIENT: 'patient'>]
- static
model_config
- static
output_field : Literal['Appointment history', 'Current patient']
- static
provenance : Literal[<CriterionProvenance.EHR: 'ehr'>, <CriterionProvenance.UNKNOWN: 'unknown'>]
- static
unit : None
- static
value : None
-
tree_columns : dict[str, bitfount.cache.types._eligibility_shared.TreeColumnMeasurement] | None- Read-only data descriptor used to emit a runtime deprecation warning before accessing a deprecated field.Attributes: msg: The deprecation message to be emitted. wrapped_property: The property instance if the deprecated field is a computed field, or
None. field_name: The name of the field being deprecated.
CodeListCriterion
class CodeListCriterion(**data: Any):Variant: an EHR code list (conditions / procedures).
A MethodFilter outcome whose value is its CodeMatchEvidence — the codes
that actually drove this patient's verdict — rather than a scalar. null when
the code column was absent, since nothing was inspected; an empty payload would
imply the codes were checked and found wanting.
matched_codes holds every code that qualified, ascending by code, each
tagged with the scope that qualified it. The same code can appear more than
once, with a different date, text or doses. A code that matched but
decided nothing is absent: one ruled out by its recency window, and one whose
inferred laterality disagreed with the scan eye. pending_laterality_review
and pending_date_review appear only when matched_codes is empty — once
something qualified, the criterion is settled and a code awaiting review is
moot.
The config field records the whole configured code list as its operand, under
the code_match operator: {"conditions_inclusion": {"code_match": ["H35.31", "H35.3*"]}}. Entries are literal codes and regex patterns, so the pair tells a
consumer what was checked.
code_match rather than in/nin deliberately. Those tokens promise the
verdict is reproducible by testing the recorded operand for membership, and it
is not: the real predicate matches literal-or-regex against two separately
configured lists (any-eye codes short-circuit; study-eye codes qualify only when
the scan laterality is known and the code's inferred laterality includes it),
with a third config input deciding the verdict when a study-eye code matches but
its own laterality is indeterminate. The operand says what was checked; the
token stops a consumer claiming how.
fail on an inclusion list means no qualifying code was found; on an
exclusion list it means an excluded code matched. unknown means the code
column was absent or unevaluable (e.g. the EHR step did not run), never that
the patient has no codes.
A study-eye variant (conditions_inclusion_study_eye,
conditions_exclusion_study_eye, procedures_exclusion_study_eye) folds into
this same criterion under its non-suffixed config key, so it is not separately
visible — and since an outcome carries one config field, the recorded operand is
the any-eye list alone; those study-eye codes are not keyed anywhere in the
evidence. Neither are eligible_on_*_codes_lat_unknown or
code_exclusion_time_windows, which modify this filter rather than producing
their own criterion.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Ancestors
Variables
- static
config_fields : dict[typing.Literal['conditions_inclusion', 'conditions_exclusion', 'procedures_inclusion', 'procedures_exclusion'], dict[CriterionOperator, bool | int | float | str | list[typing.Any] | None]]
- static
family : Literal[<CriterionFamily.CODE_LIST: 'code_list'>]
- static
grain : Literal[<CriterionGrain.PATIENT: 'patient'>]
- static
model_config
- static
output_field : Literal['Conditions inclusion', 'Conditions exclusion', 'Procedures inclusion', 'Procedures exclusion']
- static
provenance : Literal[<CriterionProvenance.EHR: 'ehr'>, <CriterionProvenance.SUPPLIED: 'supplied'>, <CriterionProvenance.UNKNOWN: 'unknown'>]
- static
unit : None
- static
value : CodeMatchEvidence | None
-
tree_columns : dict[str, bitfount.cache.types._eligibility_shared.TreeColumnMeasurement] | None- Read-only data descriptor used to emit a runtime deprecation warning before accessing a deprecated field.Attributes: msg: The deprecation message to be emitted. wrapped_property: The property instance if the deprecated field is a computed field, or
None. field_name: The name of the field being deprecated.
CompoundScanCriterion
class CompoundScanCriterion(**data: Any):Variant: a compound scan rule (drusen OR-signal, N-scan run).
A scan-grain MethodFilter whose verdict spans several columns, so it has no
single value.
The two members differ in whether their bound is recorded:
-
Drusen inclusionrecords{"drusen_threshold": {"gte": <threshold>}}— the filter tests each drusen probability against exactly that threshold. -
A
<Display Name> N-scancriterion records an empty operator map. Its bound cannot be stated as one comparison: the filter compares a scan count againstceil(typical_width_micrometers / slice_thickness), so the configured width is in different units from the quantity compared, and the threshold applied moves per row with the scan's slice thickness. Read the width from the task config; do not read the empty map as "unbounded". -
Drusen inclusion— passes when any of the hard/soft/confluent drusen probabilities is at or abovedrusen_threshold. The per-subtype thresholds are separateScanMetricCriterionentries on their own probability columns, not part of this one. -
<Display Name> N-scan— fails when the biomarker spans a long enough consecutive-B-scan run. One per configured N-scan width, overDiffuse Edema,Epiretinal Fibrosis,Intraretinal fluid (IRF),Subretinal Fluid (SRF),Subretinal Hyperreflective Material (SHRM)andDiabetic Macular Edema.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Ancestors
Variables
- static
family : Literal[<CriterionFamily.COMPOUND_SCAN: 'compound_scan'>]
- static
grain : Literal[<CriterionGrain.SCAN: 'scan'>]
- static
model_config
- static
provenance : Literal[<CriterionProvenance.SCAN: 'scan'>, <CriterionProvenance.UNKNOWN: 'unknown'>]
- static
unit : None
- static
value : None
-
tree_columns : dict[str, bitfount.cache.types._eligibility_shared.TreeColumnMeasurement] | None- Read-only data descriptor used to emit a runtime deprecation warning before accessing a deprecated field.Attributes: msg: The deprecation message to be emitted. wrapped_property: The property instance if the deprecated field is a computed field, or
None. field_name: The name of the field being deprecated.
EligibilityCriterion
class EligibilityCriterion(**data: Any):One criterion's served evidence entry (mirrors stored CriterionEvidence).
The value type of evidence.criteria, and the schema every entry validates
against. Entries are structurally uniform but fall into families, each published
as a narrowing schema of this one and listed under this schema's x-variants;
x-family-variants maps a family tag to the schema documenting it.
Classify an entry by family. It is the wire tag naming which variant
applies, declared by the criterion's producer rather than inferred, so a
consumer does not have to pattern-match output_field spellings or guess from
whether value is None. It is not a strict discriminator: a criterion
produced by a hand-authored task-config ColumnFilter, and any row written
before the tag was recorded, carry family: null. Handle that case; for those
rows only, fall back to output_field and config_fields.
Arguments
status: The criterion state.nais in the vocabulary but is never written into a stored evidence map, so expect onlypass/fail/unknown.output_field: The criterion's logical field name, and its key inevidence.criteriatoo (the two always agree). Either a produced column name (total_ga_area,Age (yrs),cst_mean_um) or a human-readable filter name for a compound criterion (Conditions inclusion,Drusen inclusion,Subretinal Fluid (SRF) N-scan).value: The observed value, orNoneif missing/not applicable. A scalar for the column-backed families, and aCodeMatchEvidenceobject for a code-list criterion — the codes that drove this patient's verdict. One field for every shape of observed value; readfamilyto know which to expect. The configured code list is served as well, but as the operand underconfig_fields, not here.
None is four distinct situations, indistinguishable from the value alone — use family and status to tell them apart: a non-code-list MethodFilter criterion, an absent target column, a NaN/NaT cell, and a non-finite float mapped to null on write (NaN and inf are not valid JSON).
config_fields:{config_field: {operator: operand}}for the config input(s) that produced this criterion. Only bounds in force for the run appear. An empty operator map means "no comparison recorded", not "no comparison made"; exactly two criteria carry one — the N-scan runs andappointment_history, neither of which can state its bound as a single comparison (seeCompoundScanCriterionandAppointmentCriterion). The whole map is empty for a criterion with no mapped config field and for a legacy row written before the field existed.grain: Where the verdict is decided:patient(once for the patient),organ(for each assessment, because the verdict depends on which eye is the study eye, with no scan data needed) orscan(needs the scan's own data).Nonefor a legacy row written before provenance tagging. A row written beforeorganexisted saysscanfor an eye-scoped EHR criterion.provenance: The source axis (scan/ehr), orNonefor a legacy row.unit: Thevalue's display unit (e.g."mm²","nL"), orNonewhen the criterion is unitless, its column carries no catalogued unit, or the row was written before units were recorded.family: The criterion's semantic family — the tag naming which variant below applies.Nonefor a criterion built from a hand-authored task-configColumnFilter, and for a row written before the tag existed.tree_columns: Deprecated. Usetreeinstead: each node'sstate, and each leaf'sfindings.
Served on the criteria_tree entry only, and None everywhere else: the value measured on this row for each leaf the tree addresses. The tree is one entry carrying the root verdict, since its leaves are combined by its own AND/OR/NOT structure and must never be re-ANDed by a consumer reading the criteria map flatly; these say what that verdict was reached on. Measurements, not verdicts: apply each leaf's own operator (from the task definition) to the value named here.
Keys are chosen by the task definition. A leaf carrying an evidence_id is keyed by it verbatim, whatever the leaf's type — the name a trial's author picked for the reading.
A column leaf naming no evidence_id falls back to its column name (total_ga_area), which identifies it, and its value is a scalar.
A code-addressed leaf — one whose tree node names code, observation, medication, allergy or device rather than a column — is absent unless it carries an evidence_id. Neither its node nor its column identifies it: its column is a container of code entries every leaf of its kind shares, and its codes do not separate sibling bands reading one code set while admitting different ranges. So a trial wanting its acuity bands reported names each one, and a trial that names none serves no acuity measurement at all. Match a key as a whole string; it is an identifier, not a structure to parse.
Such a leaf's value is a CodeMatchEvidence object: its matched_codes name the codes that qualified, and its matched_values carry the readings, each with its own unit, for a criterion whose verdict turned on one. The entry's own unit is null for those — a container column has no single unit.
Every provenance appears, ehr and supplied included. A tree leaf is never served as its own entry in the criteria map, so a named leaf left out here would be reported nowhere. A leaf the run could not measure is absent rather than null, so "not measured" stays distinguishable from "measured as nothing" — of several bands over one reading, only the band that matched reports.
tree: Only on thecriteria_treeentry, and not in the response on any other entry. The trial'scriteria_treeas the task configured it, with the result of each node. Walk it to show each protocol criterion and its result.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Subclasses
Variables
- static
config_fields : dict[str, dict[CriterionOperator, bool | int | float | str | list[typing.Any] | None]]
- static
family : CriterionFamily | None
- static
grain : CriterionGrain | None
- static
model_config
- static
output_field : str
- static
provenance : CriterionProvenance | None
- static
status : CriterionState
- static
tree : AnnotatedTreeNode | None
- static
unit : str | None
- static
value : bool | int | float | str | list[typing.Any] | dict[str, typing.Any] | None
-
tree_columns : dict[str, bitfount.cache.types._eligibility_shared.TreeColumnMeasurement] | None- Read-only data descriptor used to emit a runtime deprecation warning before accessing a deprecated field.Attributes: msg: The deprecation message to be emitted. wrapped_property: The property instance if the deprecated field is a computed field, or
None. field_name: The name of the field being deprecated.
GenericColumnCriterion
class GenericColumnCriterion(**data: Any):Variant: a generic column_criteria scalar comparison.
The escape hatch — a config-declared comparison against any produced column
by name. output_field is that column name, so it is open-ended: do not
enumerate it client-side.
This is the only variant whose value can be a bool or a str, and the only
one whose axes are genuinely unconstrained: grain is resolved from the field
catalog (or the column's provenance, else defaults to scan), and provenance
from the column's source.
Every generic criterion shares the single column_criteria config key, with
two consequences worth coding against:
evidence_mapping["column_criteria"]can name only one criterion. With several generic criteria configured, the rest are reachable only byoutput_field.- Two generic criteria on one column merge into one entry, and if they also share an operator token the evidence keeps only the last threshold (the pod logs a warning).
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Ancestors
Subclasses
Variables
- static
config_fields : dict[typing.Literal['column_criteria'], dict[CriterionOperator, bool | int | float | str | list[typing.Any] | None]]
- static
family : Literal[<CriterionFamily.GENERIC_COLUMN: 'generic_column'>]
- static
model_config
-
tree_columns : dict[str, bitfount.cache.types._eligibility_shared.TreeColumnMeasurement] | None- Read-only data descriptor used to emit a runtime deprecation warning before accessing a deprecated field.Attributes: msg: The deprecation message to be emitted. wrapped_property: The property instance if the deprecated field is a computed field, or
None. field_name: The name of the field being deprecated.
GenericMethodCriterion
class GenericMethodCriterion(**data: Any):Variant: a generic column_criteria glob / collection-membership test.
A generic criterion that could not be a vectorised column comparison, so it
ran as a MethodFilter and carries value: null even though it targets a
single column. Three routes land here:
- a
strcolumn whose criterion value contains a*wildcard (per-row glob matching), - a
collection-dtype column (Previous Appointments Info,Previous Encounters Info), where membership is tested inside the cell rather than against it, and - an operator illegal for the column's catalogued dtype. That criterion is
deliberately not dropped — a dropped criterion would leave the row falsely
unconstrained — but degrades to
unknownfor every row.
Conditions and Procedures are collection-dtype too but are not a
route here: a generic membership criterion on an EHR code column is refused
outright and produces no criterion at all, because those cells hold code
objects rather than bare values. Use the typed
conditions_/procedures_ code lists, which produce a CodeListCriterion.
All three routes need the column's catalogued dtype, so a criterion on an uncatalogued column cannot reach the collection or illegal-operator routes — only the glob route, which is decided by the criterion value alone.
Unlike the other MethodFilter variants, config_fields.column_criteria does
carry an operator token and operand here, the generic criterion knowing its
own operator. For in/not in that operand is the whole candidate list.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Ancestors
Variables
- static
family : Literal[<CriterionFamily.GENERIC_METHOD: 'generic_method'>]
- static
model_config
- static
value : None
-
tree_columns : dict[str, bitfount.cache.types._eligibility_shared.TreeColumnMeasurement] | None- Read-only data descriptor used to emit a runtime deprecation warning before accessing a deprecated field.Attributes: msg: The deprecation message to be emitted. wrapped_property: The property instance if the deprecated field is a computed field, or
None. field_name: The name of the field being deprecated.
LegacyCriterion
class LegacyCriterion(**data: Any):Variant: a row written before provenance/unit tagging.
grain, provenance and unit are null, and config_fields is empty —
which also makes the row's evidence_mapping empty, since that is rebuilt
purely from config_fields. A client must not require any of these fields to
be populated.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Ancestors
Variables
- static
grain : None
- static
model_config
- static
provenance : None
- static
unit : None
-
tree_columns : dict[str, bitfount.cache.types._eligibility_shared.TreeColumnMeasurement] | None- Read-only data descriptor used to emit a runtime deprecation warning before accessing a deprecated field.Attributes: msg: The deprecation message to be emitted. wrapped_property: The property instance if the deprecated field is a computed field, or
None. field_name: The name of the field being deprecated.
PatientMetricCriterion
class PatientMetricCriterion(**data: Any):Variant: a numeric comparison against a patient-grain column.
The patient-grain counterpart to ScanMetricCriterion: same ColumnFilter
shape and same config_fields structure, one entry per applied bound, but
evaluated once per patient rather than once per scan.
Today its only member is Age (yrs), which is why output_field pins that
one literal — the family is named for the kind of criterion rather than the
field, so a second patient-grain numeric criterion widens the literal instead
of needing a new family.
Age is also the one criterion that routinely crosses the two axes, which is
why provenance is left unpinned here: ehr when age came from an EHR
date_of_birth, scan when it was computed from a DICOM birth date. Always
unitless.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Ancestors
Variables
- static
family : Literal[<CriterionFamily.PATIENT_METRIC: 'patient_metric'>]
- static
grain : Literal[<CriterionGrain.PATIENT: 'patient'>]
- static
model_config
- static
output_field : Literal['Age (yrs)']
- static
unit : None
- static
value : int | None
-
tree_columns : dict[str, bitfount.cache.types._eligibility_shared.TreeColumnMeasurement] | None- Read-only data descriptor used to emit a runtime deprecation warning before accessing a deprecated field.Attributes: msg: The deprecation message to be emitted. wrapped_property: The property instance if the deprecated field is a computed field, or
None. field_name: The name of the field being deprecated.
ScanMetricCriterion
class ScanMetricCriterion(**data: Any):Variant: a numeric comparison against a produced scan-metric column.
A ColumnFilter outcome. grain is scan, value is numeric, and there is
one config_fields key per applied bound — a two-sided range merges into this
single entry.
output_field is one of:
- GA:
total_ga_area(mm²),largest_lesion_size(mm²),distance_from_fovea_centre(mm),max_cnv_probability(unitless). - Biomarker areas:
<label>_area(mm²), over the area-eligible segmentation labels. - Biomarker probabilities:
max_<label>_probability(unitless), over the segmentation labels plus the model classification pathologies (wet_amd,dry_amd,geographic_atrophy, ...). - CST/GCC:
cst_mean_um(µm),gcc_mean_superior,gcc_mean_inferior(unitless — the algorithm does not document a unit). - Fluid volumes (
nL):fluid_subretinal_fluid_volume,fluid_intraretinal_cystoid_fluid_volume,fluid_serous_rpe_detachment_volume,fluid_total_fluid_volume.
Bound directions, for reading config_fields: GA area and lesion size are
exclusive (gt/lt); CNV is lt; fovea distance and every CST/GCC/fluid
range are inclusive (gte/lte); the lte biomarker thresholds
(hypertransmission, neurosensory retina atrophy, hard exudates, wet AMD) are
exclusionary; the drusen thresholds are gte inclusion signals; and
exclude_foveal_ga records {"ne": 0.0} on distance_from_fovea_centre.
provenance is unknown when the run built the criterion without a
datasource context, or the target column was absent from the provenance map.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Ancestors
Variables
- static
family : Literal[<CriterionFamily.SCAN_METRIC: 'scan_metric'>]
- static
grain : Literal[<CriterionGrain.SCAN: 'scan'>]
- static
model_config
- static
provenance : Literal[<CriterionProvenance.SCAN: 'scan'>, <CriterionProvenance.UNKNOWN: 'unknown'>]
- static
value : int | float | None
-
tree_columns : dict[str, bitfount.cache.types._eligibility_shared.TreeColumnMeasurement] | None- Read-only data descriptor used to emit a runtime deprecation warning before accessing a deprecated field.Attributes: msg: The deprecation message to be emitted. wrapped_property: The property instance if the deprecated field is a computed field, or
None. field_name: The name of the field being deprecated.