Skip to main content

schema

SQLAlchemy ORM for the patient_eligibility cache table (v2).

One row per (patient, trial), keyed by task_hash. evidence_json is the rolled-up view whose scan-level criteria all come from the single determined_by_scan (coherent, no cross-eye cherry-picking). Declares its own local Base (isolated MetaData) carrying the shared nullable tags column.

evidence_json bears PHI (clinical values per criterion) and is stored plaintext.

v1 -> v2 is additive, as the invariant in bitfount.cache.types requires: v2 adds the nullable eligibility_score column and changes nothing else. A row written under v1 arrives with it NULL, which is what the column already means by NULL ("no ranking signal recorded for this row"), so the hop needs no data migration and no backfill.

eligibility_score is the criteria_tree's resolved root score (see bitfount.steps.criteria_matching_types.evaluate_criterion_tree), combined across a patient's scans and their own patient-level evaluation by patient_eligibility_task — a ranking signal only, entirely separate from status: a patient could be ineligible with a high score (a strong match on a soft criterion that nonetheless failed a hard gate) or eligible with no score at all.

Older-format trials have no ranked criteria_tree branch at all (or no criteria_tree whatsoever), so there is no real score to write for them. patient_eligibility_task then falls back to a status-derived placeholder instead — see _fallback_score_for_status — a permanent behaviour for those trials, not a temporary one. NULL means only "a row written under v1, before this column existed."

Classes​

Base​

class Base(**kwargs: Any):

Local declarative base for patient_eligibility v2.

Owns an isolated MetaData and carries the shared nullable tags JSON column that every ORM in this version inherits.

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance's class are allowed. These could be, for example, any mapped columns or relationships.

Variables​

  • static metadata
  • static registry
  • static tags : sqlalchemy.orm.base.Mapped[dict[str, typing.Any] | None]

PatientEligibility​

class PatientEligibility(**kwargs):

SQLAlchemy model for the patient_eligibility table.

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance's class are allowed. These could be, for example, any mapped columns or relationships.

Variables​

  • bitfount_patient_id : Union[sqlalchemy.orm.attributes.InstrumentedAttribute[+_T_co], +_T_co]
  • created_date : Union[sqlalchemy.orm.attributes.InstrumentedAttribute[+_T_co], +_T_co]
  • determined_by_scan : Union[sqlalchemy.orm.attributes.InstrumentedAttribute[+_T_co], +_T_co]
  • eligibility_score : Union[sqlalchemy.orm.attributes.InstrumentedAttribute[+_T_co], +_T_co]
  • evidence_json : Union[sqlalchemy.orm.attributes.InstrumentedAttribute[+_T_co], +_T_co]
  • processed_at : Union[sqlalchemy.orm.attributes.InstrumentedAttribute[+_T_co], +_T_co]
  • project_id : Union[sqlalchemy.orm.attributes.InstrumentedAttribute[+_T_co], +_T_co]
  • run_id : Union[sqlalchemy.orm.attributes.InstrumentedAttribute[+_T_co], +_T_co]
  • status : Union[sqlalchemy.orm.attributes.InstrumentedAttribute[+_T_co], +_T_co]
  • tags : Union[sqlalchemy.orm.attributes.InstrumentedAttribute[+_T_co], +_T_co]
  • task_hash : Union[sqlalchemy.orm.attributes.InstrumentedAttribute[+_T_co], +_T_co]