feat: temporal trends CLI script + Dash tab (Task D.1)

D.1a: cli/compute_trends.py — standalone CLI that imports existing pipeline
functions to replay pathway computation for ~10 historical 6-month endpoints.
Creates pathway_trends table via CREATE TABLE IF NOT EXISTS.

D.1b: Trends tab (10th PP tab) with metric toggle (patients/cost/cost_pp_pa).
Query gracefully returns empty when table doesn't exist, figure shows
instruction message to run compute_trends.
This commit is contained in:
Andrew Charlwood
2026-02-07 18:24:34 +00:00
parent d892c9fba8
commit d0404aa18a
7 changed files with 603 additions and 32 deletions
+10
View File
@@ -30,6 +30,7 @@ from data_processing.pathway_queries import (
get_drug_network as _get_drug_network,
get_drug_timeline as _get_drug_timeline,
get_dosing_distribution as _get_dosing_distribution,
get_trend_data as _get_trend_data,
)
DB_PATH = Path(__file__).resolve().parents[2] / "data" / "pathways.db"
@@ -249,3 +250,12 @@ def get_dosing_distribution(
) -> list[dict]:
"""Average administered dose counts per drug."""
return _get_dosing_distribution(DB_PATH, date_filter_id, chart_type, directory, trust)
def get_trend_data(
metric: str = "patients",
directory: Optional[str] = None,
drug: Optional[str] = None,
) -> list[dict]:
"""Time-series trend data from pathway_trends table."""
return _get_trend_data(DB_PATH, metric, directory, drug)