Skip to main content

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 as pass.
  • 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: The scan_id of the scan that decided the verdict, chosen deterministically (most recent study_date, then scan_id), or None — 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 under evidence.criteria, each entry an EligibilityCriterion carrying a config_fields map — {config_field: {operator: operand}} for the criteria-matching config input(s) that produced it (operators gt/gte/lt/lte/eq/ne, plus in/nin whose operand is a list of candidate values; every typed MethodFilter criterion carries {config_field: {}}) — which makes the evidence self-describing and is what evidence_mapping is built from. Each entry also carries grain/provenance, which are None for a legacy row written before provenance tagging, and unit (the value's unit, None when 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 within evidence.criteria it relates to, so a caller can resolve an input field to its evidence entry without scanning. Rebuilt from each criterion's config_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 the column_criteria key, 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 served patient_level_eligibility row'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. None is 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 serve None, and none of them means the others.
  • eligibility_score: This patient-trial's resolved criteria_tree root score, or — for a trial with no ranked branch to compute one from — a status-derived fallback: 1.0/0.5/0.0 for eligible/unknown/ineligible respectively (see _fallback_score_for_status in patient_eligibility_task). None only for a row written before this field existed. A ranking signal only, entirely separate from status: a real score could still leave an ineligible patient with a high score, or an eligible one with a low one — the fallback cannot, since it's derived from status directly.

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 eligibility_score : float | None
  • 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.

Variables​

  • static model_config