feat: update AppState to query pre-computed pathway_nodes (Task 3.1)

- Add dropdown state for date filters (selected_initiated, selected_last_seen)
- Add date_filter_id computed property combining the two selections
- Add load_pathway_data() method to query pathway_nodes table
- Add recalculate_parent_totals() for filtered hierarchies
- Update all filter handlers to call load_pathway_data()
- Update KPI calculations from root node data

Phase 3 Reflex integration: Task 3.1 complete
This commit is contained in:
Andrew Charlwood
2026-02-05 00:26:21 +00:00
parent 0a13ba550e
commit 7948ca7da3
2 changed files with 2104 additions and 1989 deletions
+10 -5
View File
@@ -103,15 +103,20 @@ cd pathways_app && timeout 60 python -m reflex run 2>&1 | head -30
## Phase 3: Reflex Integration
### 3.1 Update AppState
- [ ] Replace date picker state with dropdown state:
- [x] Replace date picker state with dropdown state:
- `selected_initiated: str = "all"` ("all", "1yr", "2yr")
- `selected_last_seen: str = "6mo"` ("6mo", "12mo")
- [ ] Add `date_filter_id` computed property: `f"{selected_initiated}_{selected_last_seen}"`
- [ ] Rewrite `load_pathway_data()` to query `pathway_nodes` table:
- Added `initiated_options` and `last_seen_options` for dropdown rendering
- Added `set_initiated_filter()` and `set_last_seen_filter()` event handlers
- [x] Add `date_filter_id` computed property: `f"{selected_initiated}_{selected_last_seen}"`
- [x] Rewrite `load_pathway_data()` to query `pathway_nodes` table:
- Base filter: `WHERE date_filter_id = ?`
- Trust/directory/drug filters on denormalized columns
- [ ] Add `recalculate_parent_totals()` for filtered hierarchies
- [ ] Update KPI calculations from root node data
- Updated all filter handlers to call `load_pathway_data()` instead of `apply_filters()`
- [x] Add `recalculate_parent_totals()` for filtered hierarchies
- [x] Update KPI calculations from root node data
- KPIs now extracted from root node (level 0) in pathway_nodes
- `unique_patients`, `total_cost`, `total_drugs` updated from query results
### 3.2 Update Icicle Figure
- [ ] Update `icicle_figure` computed property to use all pathway_nodes columns
+2094 -1984
View File
File diff suppressed because it is too large Load Diff