models
A patient as the API serves them.
The summary, their trials' statuses, and the rows the listings and the trial queue are made of.
Classes
CandidateCounts
class CandidateCounts(**data: Any):A trial's candidates, bucketed by the site's review status.
One trial's recruitment funnel: the candidates still to review
(to_review), a count per review status a site user can record, and
rejected for the patients ruled out. to_review is the review queue's own
count — every other patient the trial has a review for appears in a bucket
below — so the trial's candidates are to_review plus the three positive
buckets. Every count is over patients with an identity row, so it matches
what a listing of that bucket serves.
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
enrolled : int
- static
model_config
- static
rejected : int
- static
screening : int
- static
suitable_for_screening : int
- static
to_review : int
EligibilityCounts
class EligibilityCounts(**data: Any):Per-trial patient counts by eligibility status.
The three buckets partition the trial's effective cohort — its
patient_eligibility rows overridden by any site review, plus patients
reviewed for the trial that has no analysis row for them — so they sum to
that trial's cohort size, not to the pod's total patient count.
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.
PatientList
class PatientList(**data: Any):Envelope for the patient list endpoint.
The endpoint is paginated server-side: items holds the requested page,
and total is the count of all patients matching the search/filter
before pagination — so a client can render "page X of Y".
Arguments
items: The patient summaries on the requested page.total: The number of matching patients before pagination.
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.
PatientSummary
class PatientSummary(**data: Any):Summary view of a patient for list and detail endpoints.
Both endpoints serve this same shape.
Arguments
bitfount_patient_id: The Bitfount patient ID.ehr_patient_id: The EHR patient ID, if known.name: The patient's display name, as stored. Names are reduced to"Given Family"when the record is written, whether they came from the EHR or from a scan, so vendor-specific forms such as DICOM'sFAMILY^GIVEN^MIDDLEdo not reach this field. A name that could not be parsed is stored — and served — unchanged. Not normalised here.trial_statuses: Every trial the patient has a verdict for, split by that verdict. Unaffected by the list endpoint'seligible_trialsfilter: a listing narrowed to one trial still reports each patient's verdicts across every trial the pod publishes. A trial the site has reviewed is bucketed by what the review maps to (suitable_for_screening/screening/enrolled→eligible,rejected→ineligible), whatever the analysis concluded.eligible_trials: Deprecated — readtrial_statuses.eligible, which this repeats exactly. Still served, and still the full eligible set regardless of any filter.mrns: The patient's medical record number(s), if known.practitioner_name: The patient's associated medical practitioner as the EHR reports it, orNoneif no run has fetched one.last_analysed_image_date: When the patient's most recently analysed image was processed, orNoneif no image has been analysed for them yet. An aware UTC timestamp — the maximumprocessed_atover the patient's scan rows, so it is a processing time, not a capture time.
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
bitfount_patient_id : str
- static
ehr_patient_id : str | None
- static
last_analysed_image_date : datetime.datetime | None
- static
model_config
- static
mrns : list[str]
- static
name : str
- static
practitioner_name : str | None
- static
trial_statuses : TrialStatuses
-
eligible_trials : list[ScoredTrial]- The patient'seligibletrials, repeatingtrial_statuses.eligible.Derived rather than stored so the two cannot disagree while both are served.
Returns:
trial_statuses.eligible.
ReviewState
class ReviewState(*args, **kwds):Which of a trial's patients a listing covers, by the site's review of them.
reviewed and unreviewed are exclusive groups: a patient with a review
that decides a verdict is reviewed; every other patient is unreviewed.
all is every group, reviewed patients first. The groups are listed in
declaration order, and all stays last and means every group above it, so
a group added later is part of all without further change.
Ancestors
Variables
- static
ALL
- static
REVIEWED
- static
UNREVIEWED
groups : tuple[ReviewState, ...]- The groups this state lists, in listing order.
ScoredTrial
class ScoredTrial(**data: Any):One trial a patient has a verdict for, alongside its ranking score.
Carries no verdict of its own: these sit under the status that produced
them (TrialStatuses), so the field that would say eligible is the
bucket this is in.
Arguments
trial_id: The trial (project) ID.eligibility_score: This patient-trial's resolvedcriteria_treeroot score, or a status-derived fallback (1.0/0.5/0.0for eligible/unknown/ineligible) for a trial with no ranked branch to compute one from;Noneonly for a row written before this field existed. A ranking signal only, entirely separate from eligibility itself: a patient can beineligiblewith a high score (a strong match on a soft criterion that still failed a hard gate). SeeEligibilityEvidence.eligibility_score.
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.
TrialPatientList
class TrialPatientList(**data: Any):Envelope for one trial's patient list.
Paginated as PatientList is: items holds the requested page, and
total is the count of all admitted patients before pagination.
Arguments
items: The patients on the requested page.total: The number of admitted patients before pagination.
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.
TrialPatientSummary
class TrialPatientSummary(**data: Any):A patient in one trial's listing, with their criteria counts for it.
Arguments
criteria_counts: The patient's protocol criteria for the listed trial, counted by state.Nonewhen the patient's evidence for the trial has nocriteria_tree, or a tree with no protocol criteria.review: The site's review of the patient for the listed trial.Nonefor an unreviewed patient (one with no review).notes: The text of every live note the site wrote about the patient for the listed trial, oldest first: those written with a review and standalone ones. Empty when there are none.
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
criteria_counts : CriteriaCounts | None
- static
model_config
- static
notes : list[str]
- static
review : PatientReviewSummary | None
-
eligible_trials : list[ScoredTrial]- The patient'seligibletrials, repeatingtrial_statuses.eligible.Derived rather than stored so the two cannot disagree while both are served.
Returns:
trial_statuses.eligible.
TrialStatuses
class TrialStatuses(**data: Any):A patient's trials, split by the verdict each one reached.
The three buckets partition the trials the patient has a rollup row for.
A trial absent from all three is one this patient was never evaluated
against — no published patient_eligibility partition for it, or no row
for this patient in it — which is not the same as a failed verdict.
Arguments
eligible: Trials the patient iseligiblefor, ascending bytrial_id.ineligible: Trials the patient isineligiblefor, same ordering.unknown: Trials whose verdict for this patient isunknown, same ordering. A verdict that could not be reached (missing data), not a trial that was never run.
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
eligible : list[ScoredTrial]
- static
ineligible : list[ScoredTrial]
- static
model_config
- static
unknown : list[ScoredTrial]