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.
This commit is contained in:
@@ -49,7 +49,7 @@ DOSAGE_FORM_PATTERNS = [
|
||||
PRESCRIPTION_SYNTAX_PATTERNS = [
|
||||
r"\b(?:\d+\s*(?:mg|mcg|gm|g|ml|iu|units?|tablets?|capsules?|pills?|puffs?|drops?))\b",
|
||||
r"\b(?:po|iv|im|sc|prn|daily|od|bd|bid|tds|tid|qid|sos|hs|at\s+bedtime|before\s+meals?|after\s+meals?|subcutaneously|orally|topically)\b",
|
||||
r"^\s*(?:take|apply|instill|inhale|inject|infuse|give)\b",
|
||||
r"^\s*(?:take|apply|instill|inhale|inject|infuse|give|initiated|started\s+on)\b",
|
||||
]
|
||||
|
||||
# 4. Section headers, document metadata, allergy statements, and non-diagnostic observations
|
||||
@@ -63,6 +63,10 @@ METADATA_PATTERNS = [
|
||||
r"^\s*chief\s+complaint\b",
|
||||
r"^\s*discharge\s+medications?\b",
|
||||
r"^\s*investigations?\b",
|
||||
r"^\s*pertinent\s+negatives?\b",
|
||||
r"^\s*negations?(?:\s*/\s*audit)?\b",
|
||||
r"^\s*documentation\s+audit\b",
|
||||
r"^\s*final\s+coding\s+summary\b",
|
||||
r"^\s*general\s+condition\b",
|
||||
r"^\s*physical\s+examination\b",
|
||||
# Allergy statements and negative metadata (Section 3)
|
||||
|
||||
Reference in New Issue
Block a user