Skip to main content

ehr_listing

The EHR patient listing a background run's cohort was drawn from.

An EHR-only task's cohort is the pod's EHR patient listing, served through the $ehr_patients context provider (bitfount.flows.dag.context). A step that reports on the cohort needs to say which listing that was and how current it is, which its own inputs cannot tell it. This is that description, injected as a runtime parameter. It is built in bitfount.flows.dag.ehr_listing, because reading the listing needs the flows layer, which no step imports.

Classes​

EHRPatientListing​

class EHRPatientListing(    listing_key: str,    snapshot_key: str,    completed_at: datetime,    patients_listed: int,    stale: bool,    truncated_latest: bool,):

The listing snapshot a run's $ehr_patients references resolve to.

Attributes

  • listing_key: The pod's listing, keyed on its EHR.
  • snapshot_key: The ehr_patient_ids partition holding the snapshot.
  • completed_at: When the listing run that produced the snapshot finished.
  • patients_listed: Distinct patient IDs the snapshot holds.
  • stale: Whether the snapshot was older than ehr_patient_listing_max_age when the run read it. A stale snapshot is still served; the pod submits a fresh listing alongside.
  • truncated_latest: Whether the newest finished listing run was cut short by a pagination failure, so a newer but incomplete listing exists and this older complete one was served in its place.

Variables​

  • listing_key : str
  • patients_listed : int
  • snapshot_key : str
  • stale : bool
  • truncated_latest : bool

Methods​


age_seconds​

def age_seconds(self, now: datetime | None = None) ‑> float:

Return how many seconds ago the snapshot's listing run finished.

Arguments

  • now: The current time. Defaults to now, in UTC.

Returns The snapshot's age in seconds.