imaging_api.services_external.data_access

Attributes

DATA_ACCESS_API_URL

Classes

AccessionIdsRequest

Request model for the Data Access API to fetch a cohort's accession IDs.

Functions

get_accession_ids(→ list[str])

Calls the data-access-api /cohort/accession-ids endpoint and returns the

Module Contents

imaging_api.services_external.data_access.DATA_ACCESS_API_URL
class imaging_api.services_external.data_access.AccessionIdsRequest

Bases: pydantic.BaseModel

Request model for the Data Access API to fetch a cohort’s accession IDs.

encrypted_project_id: str
query: str
async imaging_api.services_external.data_access.get_accession_ids(encrypted_project_id: str, query: str) list[str]

Calls the data-access-api /cohort/accession-ids endpoint and returns the list of accession IDs for the cohort.

The endpoint projects the cohort query to the accession_id column server-side, so no other patient attributes leave the trust’s data store.

Parameters:
  • encrypted_project_id (str) – The encrypted project ID.

  • query (str) – The SQL query to execute.

Returns:

The accession IDs returned by the cohort query, in query order.

Return type:

list[str]

Raises:

RuntimeError – If the HTTP call to the Data Access API fails (network error or non-2xx response).