models
The evidence the analysis serves for a patient on a trial.
The criteria it applied, the verdict they came to, and the counts a candidate's row shows.
Classes
CriteriaCounts
class CriteriaCounts(**data: Any):How many of a trial's protocol criteria reached each state for a patient.
Counts the protocol criteria of the patient's served criteria_tree: on
each branch, the highest node with an item_number and a resolved
criterion_type. A criterion with parts ("5a", "5b") counts once, by its
own state, except that one whose pass rests on a part Bitfount does not
analyse counts as not_assessed. The keys are the tree's state values.
Arguments
pass_: Criteria that passed. Served aspass.fail: Criteria that failed.unknown: Criteria that could not be decided, which a person has to verify.not_assessed: Criteria that Bitfount does not analyse, for example informed consent, and criteria whose pass rests on a part it does not analyse.
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.
Variables
- static
fail : int
- static
model_config
- static
not_assessed : int
- static
pass_ : int
- static
unknown : int
EligibilityEvidence
class EligibilityEvidence(**data: Any):Eligibility evidence for a patient on a specific trial.
Mirrors the patient_eligibility row: status and determined_by_scan are
the row's own columns, and evidence is a JSON object holding the
per-criterion calculated values under a criteria sub-map.
Arguments
bitfount_patient_id: The Bitfount patient ID.project_id: The trial (project) ID.status: Overall eligibility status for the patient on this trial.determined_by_scan: Thescan_idof the scan that decided the verdict, chosen deterministically (most recentstudy_date, thenscan_id), orNone— e.g. a patient with no qualifying scan, which is also why the evidence map can then hold patient-grain criteria only.evidence: Typed object of per-criterion calculated evidence underevidence.criteria, each entry anEligibilityCriterioncarrying aconfig_fieldsmap —{config_field: {operator: operand}}for the criteria-matching config input(s) that produced it (operatorsgt/gte/lt/lte/eq/ne, plusin/ninwhose operand is a list of candidate values; every typedMethodFiltercriterion carries{config_field: {}}) — which makes the evidence self-describing and is whatevidence_mappingis built from. Each entry also carriesgrain/provenance, which areNonefor a legacy row written before provenance tagging, andunit(the value's unit,Nonewhen unitless or written before units were recorded).evidence_mapping: Convenience map from each criteria-matching config input field (e.g.total_ga_area_lower_bound) to the criterion key withinevidence.criteriait relates to, so a caller can resolve an input field to its evidence entry without scanning. Rebuilt from each criterion'sconfig_fields. A range criterion's lower + upper bound both map to the one merged criterion. Only fields whose criterion is present in this evidence are included. Not injective in one case: every generic criterion shares thecolumn_criteriakey, so with several configured this names only one of them.ehr_retrieved_at: When this patient's EHR data underlying this trial's verdict was retrieved — the servedpatient_level_eligibilityrow's own stored retrieval time, not recomputed at read time. Under best-effort EHR serving, a run that could not reach the EHR serves each patient's last stored row rather than aborting, so a verdict can be computed from EHR data that is now stale; this is how old it is.Noneis several situations a consumer must not conflate: a row written before this field was recorded, a patient with no EHR row at all (e.g. a scan-only trial, or a patient the EHR leg never evaluated), and a patient whose EHR lookup was attempted and retrieved nothing (no EHR data, so no retrieval time to report) — all serveNone, and none of them means the others.eligibility_score: This patient-trial's resolvedcriteria_treeroot score, or — for a trial with no ranked branch to compute one from — a status-derived fallback:1.0/0.5/0.0foreligible/unknown/ineligiblerespectively (see_fallback_score_for_statusinpatient_eligibility_task).Noneonly for a row written before this field existed. A ranking signal only, entirely separate fromstatus: a real score could still leave anineligiblepatient with a high score, or aneligibleone with a low one — the fallback cannot, since it's derived fromstatusdirectly.
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.
Variables
- static
bitfount_patient_id : str
- static
determined_by_scan : str | None
- static
ehr_retrieved_at : datetime.datetime | None
- static
eligibility_score : float | None
- static
evidence : EligibilityEvidenceBody
- static
evidence_mapping : dict[str, str]
- static
model_config
- static
project_id : str
- static
status : bitfount.cache.types._eligibility_shared.EligibilityStatus
EligibilityEvidenceBody
class EligibilityEvidenceBody(**data: Any):The evidence object: per-criterion entries under criteria.
criteria is keyed by output_field, and each entry repeats its own key in
output_field. Only criteria in force for the run appear, so the absence of a
key means "not configured", never "passed". The key set is open — a generic
column_criteria contributes an arbitrary column name.
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.