Shared CTE foundation for analytics queries.
Produces three CTEs:
base_runs
run_scores
run_data
Both the metrics and review-dashboard analytics layers build on top of run_data.
Shared CTE foundation for analytics queries.
Produces three CTEs:
base_runs— deduplicated (latest run per patient × template) with metadata; patients with no runs appear with NULL run columns when no run-specific filters (dateRange, auditTemplateIds) are active.run_scores— per-run pass/total/pct aggregates (excludes summary + not_applicable)run_data—base_runsenriched with score columnsBoth the metrics and review-dashboard analytics layers build on top of
run_data.