Commit Graph

246 Commits

Author SHA1 Message Date
Andrew Charlwood 0cb63146dd docs: update progress.txt with iteration 20 (Task 7.3 complete — sidebar restructure) 2026-02-06 15:31:00 +00:00
Andrew Charlwood 7aa49b0d6b refactor: restructure sidebar with chart views, remove placeholder items (Task 7.3)
- Remove non-functional sidebar items: Cost Analysis, Export Data
- Remove filter trigger items: Drug/Trust/Directory Selection, Indications
- Add Chart Views section: Icicle Chart (active), Sankey Diagram (disabled), Timeline (disabled)
- Remove tab row from chart_card.py (chart view selection now in sidebar)
- Remove open_drawer callback (sidebar no longer has filter triggers)
- Add .sidebar__item--disabled CSS class
2026-02-06 15:29:53 +00:00
Andrew Charlwood 74c243c8a2 docs: update progress.txt with iteration 19 (Task 7.2 complete — filter fix) 2026-02-06 15:24:59 +00:00
Andrew Charlwood 00627a7299 fix: preserve ancestor nodes in drug/directorate filters to prevent broken icicle hierarchy (Task 7.2)
Drug filter WHERE clause used `drug_sequence IS NULL` to keep ancestor nodes,
but levels 0-2 have empty string '' not NULL. Changed to level-based gating:
- Drug filter: `(level < 3 OR drug_sequence LIKE ...)`
- Directorate filter: `(level < 2 OR directory IN (...) OR directory IS NULL OR directory = '')`
- Trust filter was already correct (had `OR trust_name = ''`)
2026-02-06 15:24:09 +00:00
Andrew Charlwood d38c5515fe docs: update progress.txt with iteration 18 (Task 7.1 complete — duplicate ID fix) 2026-02-06 15:19:57 +00:00
Andrew Charlwood 7be136ac87 fix: resolve DuplicateIdError by including search_term in drug-fragment badge IDs (Task 7.1)
Badge IDs changed from f"{directorate}|{frag}" to f"{directorate}|{search_term}|{frag}"
to handle fragments appearing under multiple indications within the same directorate.
Callback parsing updated to use rsplit("|", 1)[-1] for the 3-part key.
2026-02-06 15:19:18 +00:00
Andrew Charlwood 54b4a0f743 docs: update all documentation for Dash migration (Phase 6)
Rewrote README.md, USER_GUIDE.md, and DEPLOYMENT.md to reflect
the Dash application. Updated RALPH_PROMPT.md, guardrails.md, and
DESIGN_SYSTEM.md to remove Reflex references. All non-archive
documentation now reflects the current Dash + DMC architecture.
2026-02-06 14:54:12 +00:00
Andrew Charlwood 4cb5641c2d docs: update progress.txt with iteration 16 (Task 5.4 complete — migration done) 2026-02-06 14:36:39 +00:00
Andrew Charlwood fe8642dfaf feat: remove Reflex, archive old app, update docs for Dash migration (Task 5.4)
- Remove reflex dependency from pyproject.toml
- Move pathways_app/ and rxconfig.py to archive/
- Update CLAUDE.md: Dash app structure, callback chain, run command
- All completion criteria validated (10/10 pass)
2026-02-06 14:35:43 +00:00
Andrew Charlwood 7a4f9ce567 docs: update progress.txt with iteration 15 (Task 5.3 complete) 2026-02-06 14:23:14 +00:00
Andrew Charlwood e877268805 feat: add data freshness indicator with relative time and patient count (Task 5.3) 2026-02-06 14:21:45 +00:00
Andrew Charlwood b739d47e18 docs: update progress.txt with iteration 14 (Task 5.2 complete) 2026-02-06 14:17:30 +00:00
Andrew Charlwood 5593d08062 feat: add loading spinner, empty state, and error handling to chart area (Task 5.2) 2026-02-06 14:16:26 +00:00
Andrew Charlwood 4540e110e1 docs: update progress.txt with iteration 13 (Task 5.1 complete) 2026-02-06 14:10:39 +00:00
Andrew Charlwood f0505ee43e feat: add trust selection to drawer with filter wiring (Task 5.1) 2026-02-06 14:09:36 +00:00
Andrew Charlwood e8145867c1 docs: update progress.txt with iteration 12 (Task 4.2 complete) 2026-02-06 14:00:21 +00:00
Andrew Charlwood fe76e5a313 feat: add drawer callbacks for drug selection, fragment matching, and clear (Task 4.2) 2026-02-06 13:59:00 +00:00
Andrew Charlwood b5d32224e2 docs: update progress.txt with iteration 11 (Task 4.1 complete) 2026-02-06 13:52:52 +00:00
Andrew Charlwood 5dc552f8c5 feat: add dmc.Drawer drug browser with directorate cards and drug chips (Task 4.1) 2026-02-06 13:51:24 +00:00
Andrew Charlwood 0e4184541a docs: update progress.txt with iteration 10 (Task 3.4 complete) 2026-02-06 13:45:13 +00:00
Andrew Charlwood 40ce7fc5f9 feat: add icicle chart rendering with NHS colorscale and dynamic titles (Task 3.4)
- Add create_icicle_from_nodes() to src/visualization/plotly_generator.py
  accepting list-of-dicts from dcc.Store with NHS blue gradient colorscale,
  10-field customdata, and matching text/hover templates from Reflex version
- Add update_chart callback to dash_app/callbacks/chart.py rendering
  go.Icicle figure from chart-data store with dynamic subtitle
- Title generation helper mirrors Reflex _generate_pathway_chart_title()
2026-02-06 13:44:13 +00:00
Andrew Charlwood ac731780b5 docs: update progress.txt with iteration 9 (Task 3.3 complete) 2026-02-06 13:39:22 +00:00
Andrew Charlwood 9c971c083b feat: add KPI update callback with formatted patient/drug/cost display (Task 3.3) 2026-02-06 13:38:11 +00:00
Andrew Charlwood f5486fc79e docs: update progress.txt with iteration 8 (Task 3.2 complete) 2026-02-06 13:34:26 +00:00
Andrew Charlwood ad9fa1cfec feat: add pathway data loading callback bridging filters to chart-data (Task 3.2) 2026-02-06 13:33:31 +00:00
Andrew Charlwood dcdc987063 docs: update progress.txt with iteration 7 (Task 3.1 complete) 2026-02-06 13:30:32 +00:00
Andrew Charlwood eda35c7168 feat: add reference data loading and filter state callbacks (Task 3.1) 2026-02-06 13:29:30 +00:00
Andrew Charlwood d896c63dc5 docs: update progress.txt with iteration 6 (Task 2.3 complete) 2026-02-06 13:24:48 +00:00
Andrew Charlwood 3568e03fc2 feat: add footer component and complete Phase 2 static layout (Task 2.3) 2026-02-06 13:24:33 +00:00
Andrew Charlwood 07a9d00538 docs: update progress.txt with iteration 5 (Task 2.2 complete) 2026-02-06 13:20:55 +00:00
Andrew Charlwood 307563bb31 feat: add KPI row, filter bar, and chart card components (Task 2.2) 2026-02-06 13:20:42 +00:00
Andrew Charlwood 5ebe75ad13 docs: update progress.txt with iteration 4 (Task 2.1 complete) 2026-02-06 13:14:25 +00:00
Andrew Charlwood bdc1690f0f feat: add header and sidebar components for Dash layout (Task 2.1)
- header.py: NHS branded top bar with logo, title, breadcrumb,
  data freshness indicators (record count + last updated with IDs
  for callback updates)
- sidebar.py: Navigation with 7 items across Analysis/Reports
  sections, SVG icons via data URI, Drug Selection and Indications
  items have IDs for drawer open callbacks (Phase 4)
- app.py: Assembles header + sidebar + main content placeholder
- nhs.css: Added .sidebar__icon rule for img-based SVG icons
2026-02-06 13:13:03 +00:00
Andrew Charlwood 76549420a0 feat: add directorate card tree builder for drug browser drawer (Task 1.2) 2026-02-06 13:06:29 +00:00
Andrew Charlwood b71748fa7d feat: add shared pathway query functions for Dash data access (Task 1.1)
Extract load_data() and load_pathway_data() logic from Reflex AppState
into standalone functions in src/data_processing/pathway_queries.py.
Create thin dash_app/data/queries.py wrapper with DB_PATH resolution.
2026-02-06 13:02:34 +00:00
Andrew Charlwood 1c3ece6480 feat: create dash_app skeleton with nhs.css and MantineProvider (Phase 0)
- dash_app/ directory structure: app.py, assets/, data/, components/, callbacks/, utils/
- run_dash.py entry point at project root
- Added dash>=2.14.0 and dash-mantine-components>=0.14.0 to pyproject.toml
- app.py: Dash app with MantineProvider wrapper and 3 dcc.Store components
- nhs.css: extracted from 01_nhs_classic.html (sans mock icicle CSS)
- Validated: app starts cleanly at localhost:8050
2026-02-06 12:57:47 +00:00
Andrew Charlwood 76838887e6 refactor: reorganize repository to src/ layout
Move 6 packages (core, config, data_processing, analysis, visualization, cli)
into src/ to reduce root clutter. Merge tools/data.py into
data_processing/transforms.py. Move docs to docs/.

Path resolution via .pth file (setup_dev.py), pytest pythonpath config,
and sys.path bootstrap in rxconfig.py and CLI entry points.

Clean up pyproject.toml deps (remove stale pins, add snowflake-connector-python).
Fix tomllib import for Python 3.10 compatibility.

All 113 tests pass.
2026-02-06 12:03:48 +00:00
Andrew Charlwood 1581b1d3dd docs: update CLAUDE.md to reflect slimmed database architecture
Remove references to deleted tables (fact_interventions,
mv_patient_treatment_summary, ref_drug_snomed_mapping, processed_files),
deleted files (patient_data.py, load_snomed_mapping.py), and removed
classes (SQLiteDataLoader). Update package structure, data loaders,
database schema, fallback chain, and AppState descriptions.
2026-02-06 09:39:19 +00:00
Andrew Charlwood 778ed99ef6 refactor: slim pathways.db from 351 MB to 3.5 MB by removing unused tables
Drop fact_interventions (440K rows), mv_patient_treatment_summary (35K rows),
ref_drug_snomed_mapping (144K rows), and processed_files — all unused since
the app moved to pre-computed pathway_nodes.

Key changes:
- Rewrite load_data() to source from pathway_nodes + pathway_refresh_log
- Remove 7 dead methods and 8 dead state vars from pathways_app.py
- Delete patient_data.py, load_snomed_mapping.py, test_large_dataset_performance.py
- Remove SQLiteDataLoader (depended on fact_interventions)
- Remove file tracking schema (processed_files tracked fact_interventions loads)
- Remove legacy diagnosis functions from diagnosis_lookup.py
- Add source_row_count migration for pathway_refresh_log
- Clean all cross-references in __init__.py, data_source.py, migrate.py
2026-02-06 08:51:03 +00:00
Andrew Charlwood bb93c1673e chore: archive unused files and move legacy code to can_delete
archive/ — unused reference files (no active code references):
  - LookupSearchTermCleanedDrugName.csv, condition_directorate_mapping.csv
  - na_directory_rows.csv (diagnostic output), ta-recommendations.xlsx
  - snomed_indication_mapping_query.sql (source for embedded SQL)
  - IMPROVEMENT_RECOMMENDATIONS.md, power query.pq

archive/can_delete/ — legacy code and logs safe to remove:
  - dashboard_gui.py (replaced by Reflex app)
  - pathways_app_old.py.bak (old backup)
  - Ralph loop iteration logs (iterations 2-8)
2026-02-06 01:01:02 +00:00
Andrew Charlwood a31907aa1f feat: complete drug-aware indication matching and cleanup app_v2
- Remove app_v2.py (consolidated into pathways_app.py), fix __init__ import
- Add DimSearchTerm.csv, drug_indication_clusters.csv, drug_snomed_mapping_enriched.csv
  as reference data for SNOMED-based indication matching
- Add snomed_indication_mapping_query.sql (source for embedded cluster mapping)
- Update DESIGN_SYSTEM.md, RALPH_PROMPT.md, ralph.ps1, uv.lock
2026-02-06 00:33:29 +00:00
Andrew Charlwood f3bba6dfab docs: complete Phase 4 validation — full refresh and data verification (Task 4.1-4.3)
Full refresh: 2,947 nodes (1,101 directory + 1,846 indication) in 738s.
Validation: RA/asthma drugs correctly grouped, fallback labels present,
directory charts unchanged, Reflex compiles. All completion criteria met.
2026-02-06 00:12:53 +00:00
Andrew Charlwood b674543878 docs: update progress.txt with Iteration 6 results (Task 3.2) 2026-02-05 23:55:26 +00:00
Andrew Charlwood c6e426e36c fix: increase network timeout and batch size for GP lookup queries (Task 3.2)
Dry run test revealed GP lookup queries timing out at 30s (connection_timeout
in snowflake.toml). Increased to 600s. Also increased batch_size from 500 to
5000 — query time is ~40s regardless of batch size (CTE compilation overhead),
so larger batches reduce total time from ~50min to ~6min for 36K patients.

Dry run results: 91.8% GP match rate, 49.3% drug-indication match rate,
42,072 modified UPIDs, 1,846 pathway nodes across 6 date filters.
2026-02-05 23:55:12 +00:00
Andrew Charlwood 73088b063b docs: update progress.txt with Iteration 5 results (Task 3.1) 2026-02-05 23:11:14 +00:00
Andrew Charlwood 920570b437 feat: integrate drug-aware indication matching into refresh pipeline (Task 3.1)
Replace old per-patient indication matching in refresh_pathways.py with
drug-aware matching via assign_drug_indications(). Each drug is now
cross-referenced against both the patient's GP diagnoses AND the
DimSearchTerm.csv drug mapping. GP codes restricted to HCD data window
via earliest_hcd_date parameter.
2026-02-05 23:11:01 +00:00
Andrew Charlwood d9891c8991 docs: update progress.txt with Iteration 4 results (Task 2.1 + 2.2) 2026-02-05 23:06:27 +00:00
Andrew Charlwood 408976e001 feat: add assign_drug_indications() for drug-aware indication matching (Task 2.1 + 2.2) 2026-02-05 23:05:40 +00:00
Andrew Charlwood 947b87a331 docs: update progress.txt with Iteration 3 results (Task 1.1) 2026-02-05 23:01:15 +00:00
Andrew Charlwood c93417f0e7 feat: return ALL GP matches with code_frequency in get_patient_indication_groups (Task 1.1)
- Replace QUALIFY ROW_NUMBER()=1 with GROUP BY + COUNT(*) to return all matching
  Search_Terms per patient instead of just the most recent
- Add earliest_hcd_date parameter to restrict GP codes to HCD data window
- Return code_frequency column (count of matching SNOMED codes per Search_Term)
  for use as tiebreaker in drug-aware indication matching
- Update empty DataFrame returns to match new column format
2026-02-05 23:01:01 +00:00