flip_api.private_services.receive_cohort_results
Attributes
Functions
|
Collapse a trust-side error string to a safe enum category. |
|
Saves the individual cohort results from a single trust for a specific query. |
|
Aggregates cohort results for a specific query_id across all trusts and saves the aggregated statistics. |
|
Receives cohort query results from a single trust, saves them, |
Module Contents
- flip_api.private_services.receive_cohort_results.router
- flip_api.private_services.receive_cohort_results._ALLOWED_TRUST_ERROR_CATEGORIES: frozenset[str]
- flip_api.private_services.receive_cohort_results._redact_trust_error(raw: str | None) str
Collapse a trust-side error string to a safe enum category.
- Parameters:
raw (str | None) – The error string the trust reported on the failed cohort task, if any.
- Returns:
One of
_ALLOWED_TRUST_ERROR_CATEGORIES.internal_erroris the default for anything unrecognised — includingNone, raw psycopg traceback fragments, and wrapped"500: ..."strings the trust-api gateway constructs from upstream HTTPException bodies.- Return type:
str
- flip_api.private_services.receive_cohort_results._save_individual_result(db: sqlmodel.Session, cohort_results: flip_api.domain.schemas.private.OmopCohortResults) None
Saves the individual cohort results from a single trust for a specific query.
- Parameters:
db (Session) – Database session.
cohort_results (OmopCohortResults) – The cohort results to save.
- Returns:
None
- Raises:
HTTPException – If there is an error while saving the cohort results to the database.
- flip_api.private_services.receive_cohort_results._aggregate_and_save_results(db: sqlmodel.Session, query_id: uuid.UUID) None
Aggregates cohort results for a specific query_id across all trusts and saves the aggregated statistics.
- Parameters:
db (Session) – Database session.
query_id (UUID) – The ID of the query to aggregate results for.
- Returns:
None
- Raises:
HTTPException – If there is an error during aggregation or saving the aggregated stats to the database.
- flip_api.private_services.receive_cohort_results.receive_cohort_results_endpoint(cohort_results: flip_api.domain.schemas.private.OmopCohortResults, db: sqlmodel.Session = Depends(get_session), authenticated_trust: flip_api.db.models.main_models.Trust = Depends(authenticate_trust)) dict[str, str]
Receives cohort query results from a single trust, saves them, then re-aggregates and saves the overall statistics for the query.
- Parameters:
cohort_results (OmopCohortResults) – The cohort results sent by the trust.
db (Session) – Database session.
authenticated_trust (Trust) – Trust resolved from the API key by the dependency.
- Returns:
A message indicating successful processing of cohort results.
- Return type:
dict[str, str]
- Raises:
HTTPException – If there is an error during processing, saving individual results, or aggregating results.