fix(pipeline): word-boundary site matching, historical exclusion, trauma code gate, and retrieval fallback hardening
- ranker.py: Use \b word boundaries in has_matching_site to prevent 'fibula'
matching inside 'calcaneofibular' (fixes S93.412A beating S93.422A).
Add traumatic S/T code gate (-0.40) for non-trauma documentation.
- classifier.py: Expanded acuity detection (sepsis, infarction, STEMI/NSTEMI).
Added pure-symptom suppression when definitive diagnoses are available.
Improved primary/secondary classification reasons with evidence quotes.
Fixed organism detection to exclude sepsis from supplementary code penalty.
- clinical_extractor.py: Detect historical/resolved diagnoses and mark with
HISTORICAL role, zero relevance, and -50 admitting score. Added section
types (PERTINENT_NEGATIVES, ASSESSMENT, PLAN). Fix sentence splitting to
preserve decimal numbers (e.g. 101.4F). Skip metadata section headers.
- nodes.py: Refactored retrieval to use lexical_retriever for expansion
queries and BM25 fallback (eliminates 80k-row full scan).
- tokenizer.py: Extended CLINICAL_MORPHOLOGY with renal/kidney/nephropathy,
injury/failure, infarction/infarct/STEMI/NSTEMI mappings.
- clinical_gate.py: Added pertinent negatives, documentation audit, and
final coding summary to metadata patterns. Extended prescription syntax.
- reverse_attributes.py: Added coronary/artery/vessel/wall/vein to
non-specificity words for better attribute extraction.
- pipeline.py: Extract failed node name from traceback for error reporting.
- schemas/icd.py: Added 'fallback_token_scan' and 'vector_numpy' retrieval methods.