feat: add get_directorate_from_diagnosis() function (Task 2.1)

- Added DirectorateAssignment dataclass for return type
- Added get_directorate_from_diagnosis() function to diagnosis_lookup.py
- Logic: Try diagnosis-based lookup first (direct SNOMED match)
- Returns FALLBACK source if no match found, letting caller handle fallback
- Extracts PatientPseudonym from UPID (last part after provider code)
- Updated __all__ exports with new dataclass and function
- Tested: function handles no-match cases correctly
This commit is contained in:
Andrew Charlwood
2026-02-05 14:19:18 +00:00
parent b44d22de2c
commit 506769470d
2 changed files with 118 additions and 3 deletions
+3 -3
View File
@@ -72,12 +72,12 @@ python -m reflex compile
## Phase 2: Pathway Processing Updates
### 2.1 Update Directorate Assignment Logic
- [ ] Modify `tools/data.py` `department_identification()` or create wrapper:
- [x] Modify `tools/data.py` `department_identification()` or create wrapper:
- Add `get_directorate_from_diagnosis(upid, drug_name, connector)` function
- Logic: Try diagnosis-based first → fallback to department_identification()
- Return: (directorate, source) where source is "DIAGNOSIS" or "FALLBACK"
- [ ] Track assignment source for metrics (how many diagnosis-based vs fallback)
- [ ] Verify: Test with sample patient data
- [x] Track assignment source for metrics (how many diagnosis-based vs fallback)
- [x] Verify: Test with sample patient data
### 2.2 Add Chart Type Support to Schema
- [ ] Add `chart_type` column to `pathway_nodes` table: