task
Prefect task for pre-computing EHR data during the background flow.
Extracts patient demographic and code data from the EHR datasource and
persists the combined records to the ehr_data cache table. Two modes
are supported, selected via EHRQueryConfig.mode:
"filename" (default)
Patients are resolved from imaging file metadata (name + DOB columns
on the datasource).
"patient_id_cache"
Patients are resolved by ID streamed from a cache accessor wired in
via the step's inputs: block — typically the output of
ehr_patient_lister.
Module
Functions
ehr_criteria_query_task
def ehr_criteria_query_task( ehr_data_resource: EHRDataResource | None, cache: CacheProtocol, task_hash: str, config: EHRQueryConfig | None = None, datasource: BaseSource | None = None, filenames: list[str] | None = None, patient_ids: CacheAccessor | None = None,) ‑> EHRQueryResult:Extract and cache EHR data for the current run.
Arguments
ehr_data_resource: Configured EHR resource (NextGen or FHIR R4).cache: Cache backend to writeehr_datarows to.task_hash: Hash identifying the current task run; written into every row so re-runs upsert viasession.merge.config: Step config.config.modeselects between filename-driven and patient-ID-cache-driven lookups,config.fetch_appointmentscontrols whether appointment and encounter history is fetched, andconfig.observation_codes/config.observation_categoriesfetch coded Observations matching those codes/categories (merged and deduplicated when both are set). If neither is set, every core FHIR observation-category (ALL_OBSERVATION_CATEGORIES) is fetched by default — seeEHRQueryConfig's docstring. Whenconfigitself isNonethe defaults are used so existing programmatic callers do not have to pass one.datasource: Imaging datasource. Required in"filename"mode.filenames: Imaging file IDs to process. Required in"filename"mode.patient_ids: Cache accessor over theehr_patient_idstable (typically wired fromehr_patient_lister.cachein the YAML). Required in"patient_id_cache"mode.