ehr_listing
Resolving the EHR patient listing snapshot a run's $ehr_patients serves.
A run serves the newest complete snapshot, stale or not, and never submits a
listing; the pod does (BackgroundDAGHandler.prepare_ehr_listing). With no
complete snapshot, a background run ends without running a step, and the pod
resubmits it once the listing completes; the interactive phase fails.
Module
Functions
awaiting_ehr_listing
def awaiting_ehr_listing( cache: CacheProtocol, task_hash: str, dag_name: str, project_id: str | None,) ‑> bool:Return whether a lineage's newest run stood down for a missing listing.
Arguments
cache: The pod's background cache.task_hash: The datasource-level task hash.dag_name: The lineage's background DAG name, its runs'type.project_id: The lineage's project.
Returns
Whether the most recently started run of the lineage carries
AWAITING_EHR_LISTING_TAG.
dag_consumes_ehr_patients
def dag_consumes_ehr_patients(steps: Iterable[DAGStep]) ‑> bool:Return whether any of steps reads $ehr_patients.
Arguments
steps: Parsed steps of one or both phases.
Returns Whether a listing must be served to run them.
flow_spec_consumes_ehr_patients
def flow_spec_consumes_ehr_patients(raw: Mapping[str, Any]) ‑> bool:Return whether a raw, unparsed flow spec reads $ehr_patients.
For the pod, which holds flow specs as the Hub sent them and must not parse one (and so import every step it names) just to decide whether to list. Absent or malformed sections read as not reading it.
Arguments
raw: The flow spec as recorded inflow_specs.
Returns Whether either phase has a step input naming the provider.
pending_ehr_listing
def pending_ehr_listing( steps: Iterable[DAGStep], cache: CacheProtocol, ehr_config: EHRConfig | None,) ‑> str | None:Return the listing a background run must stand down for, if any.
A background run reading $ehr_patients before any listing of the pod's
EHR has completed ends without running a step rather than waiting for one.
A wait would hold the project's only deployment slot, and a large EHR takes
hours to list. The pod resubmits the run once the listing completes
(awaiting_ehr_listing).
Arguments
steps: The background phase's steps.cache: The pod's background cache.ehr_config: The pod's EHR configuration.
Returns
The missing listing's key, or None when no step reads the listing, the
pod has no EHR (which assembling the run reports), or a complete
snapshot exists.
resolve_ehr_patient_listing
def resolve_ehr_patient_listing( *, cache: CacheProtocol, ehr_config: EHRConfig, phase: ListingPhase, max_age: timedelta | None = None,) ‑> EHRPatientListing:Return the listing snapshot a run serves as $ehr_patients.
Arguments
cache: The pod's background cache.ehr_config: The pod's EHR configuration, which keys the listing.phase: The DAG phase resolving the listing.max_age: The age beyond which a snapshot is stale. Defaults toehr_patient_listing_max_age.
Returns The newest complete snapshot, flagged stale when it is.
Raises
EHRPatientListingUnavailableError: If no listing has completed. A background run normally stood down earlier (pending_ehr_listing).