feat(pipeline): complete healing and hardening of clinical reasoning and matching pipeline

- Implement soft dimensional compatibility and 3-way attribute logic (SUPPORTED, CONTRADICTED, UNKNOWN)
- Replace binary hardwall rejection with nuanced compatibility scoring
- Isolate context per diagnosis to prevent cross-condition contamination (MD Sec 41)
- Generalize disease families (liver sarcoma, net, asthma, acl) and category priors
- Add regex word boundary acuity checking and laterality alignment scoring in ranker
- Fix candidate sort by sorting on unconstrained multi-factor raw score before output clamping
- Preserve zero-modification immutability of local Database_2.xlsx
- Pass 100% of full regression test suite (158/158 tests) and ruff linting
This commit is contained in:
Abhinav Gupta
2026-10-06 14:43:16 +05:30
parent 1b09529534
commit 72d0da1c22
46 changed files with 6348 additions and 734 deletions
+7 -8
View File
@@ -2,6 +2,7 @@
import asyncio
import json
from datetime import datetime
from typing import Any
from uuid import uuid4
@@ -16,8 +17,6 @@ from medical_coding.ingestion.agent import ClinicalDocumentIngestionAgent
from medical_coding.ingestion.detector import DocumentFormat
from medical_coding.orchestration.pipeline import MedicalCodingPipeline
from medical_coding.pdf.extractor import PDFExtractor
from datetime import datetime
from medical_coding.schemas.enums import ExecutionStatus
from medical_coding.schemas.response import CodingResult
from medical_coding.ui.components import (
@@ -58,7 +57,7 @@ st.markdown(get_css(), unsafe_allow_html=True)
# Cached Singletons for Performance
# -----------------------------------------------------------------------------
@st.cache_resource(show_spinner=False)
def get_cached_pipeline(version: str = "v3.2") -> MedicalCodingPipeline:
def get_cached_pipeline(_version: str = "v3.2") -> MedicalCodingPipeline:
"""Return a cached singleton instance of the medical coding orchestrator."""
settings = get_settings()
return MedicalCodingPipeline(settings=settings)
@@ -149,11 +148,11 @@ def render_coding_session_results(
steps_data: list[dict[str, Any]],
thread_id: str,
document_id: str,
raw_text: str = "",
active_filename: str = "clinical_document.txt",
active_source_type: str = "text",
active_file_bytes: bytes | None = None,
min_score: float = 0.40,
_raw_text: str = "",
_active_filename: str = "clinical_document.txt",
_active_source_type: str = "text",
_active_file_bytes: bytes | None = None,
_min_score: float = 0.40,
) -> None:
"""Render complete diagnostics: Step Oversight Timeline, Failure/Success, KPIs, Diagnoses, and Exports."""
is_error = coding_result.status == ExecutionStatus.ERROR