flip_api.private_services.receive_cohort_results

Attributes

router

Functions

_save_individual_result(→ None)

Saves the individual cohort results from a single trust for a specific query.

_aggregate_and_save_results(→ None)

Aggregates cohort results for a specific query_id across all trusts and saves the aggregated statistics.

receive_cohort_results_endpoint(, authenticated_trust, ...)

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._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: str = 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 (str) – Authenticated trust name (validated by 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.