feat: add indication pathway processing functions (Task 2.3)

- Add generate_icicle_chart_indication() to pathway_analyzer.py
  - Variant that uses indication_df instead of directory_df
  - Groups by Trust → Search_Term → Drug → Pathway
  - Accepts indication_df mapping UPID → Indication_Group

- Add process_indication_pathway_for_date_filter() to pathway_pipeline.py
  - Processes indication-based pathway for a single date filter
  - Uses generate_icicle_chart_indication() for hierarchy building

- Add extract_indication_fields() to pathway_pipeline.py
  - Extracts trust_name, search_term, drug_sequence from ids column
  - Similar to extract_denormalized_fields() but for indication charts

- Update convert_to_records() with chart_type parameter
  - Includes chart_type column in output records
  - Supports "directory" and "indication" values

- Add ChartType type alias (Literal["directory", "indication"])

- Update __all__ exports with new functions
This commit is contained in:
Andrew Charlwood
2026-02-05 14:32:28 +00:00
parent aabe4bf45d
commit 7cbc648c6d
3 changed files with 352 additions and 6 deletions
+8 -3
View File
@@ -90,13 +90,18 @@ python -m reflex compile
- [x] Verify: Migration adds column, existing data defaults to "directory"
### 2.3 Create Indication Pathway Processing
- [ ] Add `process_indication_pathways()` to `pathway_pipeline.py`:
- [x] Add `process_indication_pathway_for_date_filter()` to `pathway_pipeline.py`:
- Group by: Trust → Search_Term → Drug → Pathway
- For unmatched patients: use directorate name as Search_Term fallback
- Output: Same structure as directory pathways but with indication grouping
- [ ] Add `extract_indication_fields()` for denormalized columns:
- [x] Add `generate_icicle_chart_indication()` to `pathway_analyzer.py`:
- Variant of `generate_icicle_chart()` that uses indication_df instead of directory_df
- Takes `indication_df` parameter mapping UPID → Indication_Group
- [x] Add `extract_indication_fields()` for denormalized columns:
- Extract: trust_name, search_term (or fallback_directorate), drug_sequence
- [ ] Verify: Process sample data, check hierarchy structure
- [x] Update `convert_to_records()` to include `chart_type` parameter
- [x] Add `ChartType` type alias ("directory" | "indication")
- [x] Verify: Code compiles, imports work correctly
---