Skip to main content

v1

CSV report step v1.

Module

Submodules

Functions

task_fn

def task_fn(    datasource: BaseSource,    config: CSVReportConfig,    csv_report_df: pandas.core.frame.DataFrame,    filenames: list[str],    task_id: str,    ga_metrics: dict[str, GAMetricsWithFovea | None] | CacheAccessor | None = None,    ehr_patient_data: CacheAccessor | None = None,    encryption_key: bytes | None = None,    sorting_columns: Optional[list[str]] = None,)> CSVReportResult:

Generate CSV report using composable pure functions.

Adapts to the datasource grain. For a FileSystemIterableSource the report's demographic/source columns come from get_data_for_files (keyed by filename) and the eligibility projection is merged on ORIGINAL_FILENAME_METADATA_COLUMN. For any other datasource (the EHR grain) the demographics live on the EHR patient frame criteria_matching matched against — not the null datasource — so they are sourced from ehr_patient_data and the projection is merged on EHR_BITFOUNT_PATIENT_ID_COL.

Arguments

  • datasource: The datasource providing source data for the report.
  • config: CSV report configuration (includes trial_name and the rename_columns map).
  • csv_report_df: DataFrame with metrics/results to report on. Typically tabulate_criteria_outcomes's eligibility projection, keyed by the grain's merge column.
  • filenames: List of file IDs being reported.
  • task_id: Task run ID.
  • ga_metrics: Optional GA metrics, re-assembled into columns (e.g. distance from fovea) that GA-metric-dependent CSV extensions consume. Either an in-memory {filename: GAMetricsWithFovea | None} map (same-phase producer) or the ga_calculation.cache accessor (when GA calculation ran in the background); None when the flow has no GA-metrics producer. Only meaningful on the file-system grain.
  • ehr_patient_data: The EHR patient frame to source demographics from on the non-file-system grain (the same table criteria_matching matched against). Ignored for a FileSystemIterableSource.
  • encryption_key: Optional encryption key for encrypted CSV output.
  • sorting_columns: Optional columns to sort the final CSV by.

Returns CSVReportResult indicating success.

Classes

Config

class Config(**data: Any):

Config for the CSV report generation step.

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 csv_extensions : list[str]
  • static model_config
  • static produce_matched_only : bool
  • static rename_columns : dict[str, str]
  • static trial_name : str

Result

class Result(**data: Any):

Result of a CSV report task.

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 model_config
  • static success : bool