fix(validation): implement prioritized surgical oncology repair plan and semantic code validation
- Fix UI crash NameError: name 'Path' is not defined in medical_coding.ui.app - Item 1: Enforce semantic code validation first; reject laterality and anatomical site mismatches even if active and billable - Item 2: Segregate surgical procedures from diagnosis inventory (mastectomy, salpingo-oophorectomy in procedures, blocked from secondary diagnoses) - Item 3: Capture structured oncology context preserving histology, grade, ER/PR/HER2 receptors, Ki-67, and treatment response - Item 4: Extract operative findings separately with UHDDS eligibility gate (incidental findings excluded from secondary diagnosis coding) - Item 5: Ground audit claims in evidence-based semantic checks (LateralityMatch, AnatomicalSiteMatch, SemanticAttributeMatch) - Item 6: Accelerate candidate retrieval latency via query-level caching in HybridICDRetriever - Add UI presentation cards for procedures, structured oncology, operative findings, and enhanced audit trails - Add comprehensive test suite in tests/test_surgical_oncology_repair.py
This commit is contained in:
@@ -50,6 +50,7 @@ class HybridICDRetriever(BaseICDRetriever):
|
||||
|
||||
self.min_score_threshold = min_score_threshold
|
||||
self.default_top_k = default_top_k
|
||||
self._query_cache: dict[tuple[str, int, float, str | None], list[ICDCandidate]] = {}
|
||||
|
||||
def retrieve(
|
||||
self,
|
||||
@@ -77,6 +78,11 @@ class HybridICDRetriever(BaseICDRetriever):
|
||||
if not clean_query:
|
||||
return []
|
||||
|
||||
# Check in-memory query cache for instant sub-millisecond retrieval
|
||||
cache_key = (clean_query.lower(), k, threshold, system)
|
||||
if hasattr(self, "_query_cache") and cache_key in self._query_cache:
|
||||
return [c.model_copy() for c in self._query_cache[cache_key]]
|
||||
|
||||
# Retrieve candidates from both local engines with an expanded initial window
|
||||
search_window = max(k * 10, 350)
|
||||
lexical_hits = self.lexical_retriever.retrieve(clean_query, top_k=search_window)
|
||||
@@ -187,6 +193,12 @@ class HybridICDRetriever(BaseICDRetriever):
|
||||
threshold,
|
||||
clean_query,
|
||||
)
|
||||
|
||||
if hasattr(self, "_query_cache"):
|
||||
if len(self._query_cache) >= 1000:
|
||||
self._query_cache.clear()
|
||||
self._query_cache[cache_key] = [c.model_copy() for c in top_candidates]
|
||||
|
||||
return top_candidates
|
||||
|
||||
def retrieve_multi_system(
|
||||
|
||||
Reference in New Issue
Block a user