Files
Agentic-ICD-Code-Matcher/diagnostic_pipeline_report.json
T
Abhinav Gupta c161b09095 fix(pipeline): implement comprehensive improvements across five key areas on noise-fix
- Area 1: Complete clinical inventory generation with compound concept decomposition (secondary to/due to), laterality preservation, and deduplication
- Area 2: First-class assertion, negation, entity typing, and CMS Guideline I.B.4 integral symptom suppression
- Area 3: Semantic code validation beyond database existence via reverse attribute matching and specificity downgrading
- Area 4: Strict UHDDS primary vs secondary role separation with complete deduplication and HTML escape rendering in Streamlit components
- Area 5: Exact clinical provenance preservation and 6-metric diagnostic scorecard with comprehensive regression tests
2026-10-09 10:42:54 +05:30

799 lines
29 KiB
JSON

{
"total_test_cases": 6,
"metrics_scorecard": {
"clinical_concept_recall_pct": 100.0,
"role_classification_accuracy_pct": 100.0,
"code_accuracy_pct": 100.0,
"false_positive_count": 0,
"abstention_quality_pct": 75.0,
"candidate_retrieval_recall_pct": 100.0
},
"results": [
{
"case_id": "CASE-01-STANDARD-ADMISSION",
"title": "Inpatient Discharge (Acute Systolic HF, T2DM, HTN)",
"status": "PARTIAL_SUCCESS",
"primary_diagnosis": {
"code": "I50.21",
"description": "Acute systolic (congestive) heart failure",
"confidence_score": 1.0
},
"secondary_diagnoses": [
{
"code": "E11.9",
"description": "Type 2 diabetes mellitus without complications",
"confidence_score": 1.0
},
{
"code": "I10",
"description": "Essential (primary) hypertension",
"confidence_score": 1.0
}
],
"abstention_count": 2,
"abstentions": [
{
"diagnosis": "Resolved seasonal allergic rhinitis.",
"reason": "EXCLUDED_BY_NEGATION",
"detail": "Excluded from coding: [PAST_MEDICAL_HISTORY] Past Medical History alone without documented inpatient evaluation, monitoring, or therapy.",
"stage": "CLASSIFICATION"
},
{
"diagnosis": "Severe acute shortness of breath and peripheral edema",
"reason": "EXCLUDED_BY_NEGATION",
"detail": "Symptom integral to the primary diagnosis 'Acute systolic heart failure'; excluded under CMS Guideline I.B.4: \"Severe acute shortness of breath and peripheral edema\".",
"stage": "CLASSIFICATION"
}
],
"audit_trail_sample": [
{
"document_id": "CASE-01-STANDARD-ADMISSION",
"diagnosis_id": "646a44fd-ac0f-40c0-a4bf-942b17ad5a93",
"raw_term": "Resolved seasonal allergic rhinitis.",
"evidence": "2. Resolved seasonal allergic rhinitis.",
"context": {
"certainty": "CONFIRMED",
"temporality": "HISTORICAL",
"negation": "AFFIRMATIVE",
"acuity": "UNSPECIFIED"
},
"classification": {
"role": "EXCLUDED",
"is_billable": false,
"reason": "Excluded from coding: [PAST_MEDICAL_HISTORY] Past Medical History alone without documented inpatient evaluation, monitoring, or therapy."
},
"retrieved_candidates": [],
"selected_candidate": {
"code": null,
"description": null,
"confidence": 0.0,
"reason": "Candidate pool was empty; no matching local ICD code.",
"decision": "ABSTAINED"
},
"validation": {
"status": "REJECTED_OR_ABSTAINED",
"checks": []
},
"final_result": {
"code": null,
"description": null,
"role": null
}
},
{
"document_id": "CASE-01-STANDARD-ADMISSION",
"diagnosis_id": "63234a99-98be-4ca7-803c-55b90d5de9e2",
"raw_term": "Acute systolic heart failure",
"evidence": "1. Acute systolic heart failure - Patient admitted with acute exacerbation of systolic congestive heart failure. Echo demonstrated EF 20%. Treated with intravenous furosemide diuresis with marked symptomatic improvement.",
"context": {
"certainty": "CONFIRMED",
"temporality": "CURRENT",
"negation": "AFFIRMATIVE",
"acuity": "ACUTE"
},
"classification": {
"role": "PRIMARY",
"is_billable": true,
"reason": "Designated as Primary Diagnosis under UHDDS Guidelines (chief condition established after study to be responsible for occasioning admission). Documented evidence: \"1. Acute systolic heart failure - Patient admitted with acute exacerbation of systolic congestive heart failure. Echo demonstrated EF 20%. Treated with intravenous furosemide diuresis with marked symptomatic improvement.\". Clinical criteria: Explicitly documented as PRIMARY/PRINCIPAL DIAGNOSIS by provider (+10.0); Explicitly documented under discharge / final diagnoses (+5.0); Active intravenous / intensive therapeutic management administered (+2.0); Acute presentation (+2.0); Confirmed diagnostic certainty (+1.0)."
},
"retrieved_candidates": [
{
"code": "I50.21",
"description": "Acute systolic (congestive) heart failure",
"score": 0.9148
},
{
"code": "I50.23",
"description": "Acute on chronic systolic (congestive) heart failure",
"score": 0.85
},
{
"code": "I50.20",
"description": "Unspecified systolic (congestive) heart failure",
"score": 0.85
},
{
"code": "I50.22",
"description": "Chronic systolic (congestive) heart failure",
"score": 0.85
},
{
"code": "I50.89",
"description": "Other heart failure",
"score": 0.85
},
{
"code": "I50.9",
"description": "Heart failure, unspecified",
"score": 0.85
},
{
"code": "I50.31",
"description": "Acute diastolic (congestive) heart failure",
"score": 0.75
},
{
"code": "I50.33",
"description": "Acute on chronic diastolic (congestive) heart failure",
"score": 0.75
},
{
"code": "I50.82",
"description": "Biventricular heart failure",
"score": 0.75
},
{
"code": "I50.30",
"description": "Unspecified diastolic (congestive) heart failure",
"score": 0.75
},
{
"code": "I50.32",
"description": "Chronic diastolic (congestive) heart failure",
"score": 0.7714
},
{
"code": "I50.811",
"description": "Acute right heart failure",
"score": 0.7291
},
{
"code": "I50.41",
"description": "Acute combined systolic (congestive) and diastolic (congestive) heart failure",
"score": 0.7197
},
{
"code": "I50.43",
"description": "Acute on chronic combined systolic (congestive) and diastolic (congestive) heart failure",
"score": 0.6894
},
{
"code": "I50.813",
"description": "Acute on chronic right heart failure",
"score": 0.65
},
{
"code": "I50.40",
"description": "Unspecified combined systolic (congestive) and diastolic (congestive) heart failure",
"score": 0.65
},
{
"code": "I50.42",
"description": "Chronic combined systolic (congestive) and diastolic (congestive) heart failure",
"score": 0.65
},
{
"code": "I50.812",
"description": "Chronic right heart failure",
"score": 0.65
},
{
"code": "I50.810",
"description": "Right heart failure, unspecified",
"score": 0.7714
},
{
"code": "I50.1",
"description": "Left ventricular failure, unspecified",
"score": 0.7357
},
{
"code": "I50.84",
"description": "End stage heart failure",
"score": 0.55
},
{
"code": "I50.83",
"description": "High output heart failure",
"score": 0.55
},
{
"code": "I50.814",
"description": "Right heart failure due to left heart failure",
"score": 0.5818
},
{
"code": "T86.22",
"description": "Heart transplant failure",
"score": 0.545
},
{
"code": "I09.81",
"description": "Rheumatic heart failure",
"score": 0.5266
}
],
"selected_candidate": {
"code": "I50.21",
"description": "Acute systolic (congestive) heart failure",
"confidence": 1.0,
"reason": "Candidate 'I50.21' (Acute systolic (congestive) heart failure) best supported by documentation (core diagnostic entity match (3/3), acute acuity match).",
"decision": "ACCEPTED"
},
"validation": {
"status": "PASSED",
"checks": [
{
"rule_name": "CatalogExistence",
"passed": true,
"details": "Code 'I50.21' exists in local authoritative catalog."
},
{
"rule_name": "TerminalSpecificity",
"passed": true,
"details": "Code 'I50.21' is at terminal billable specificity."
},
{
"rule_name": "SemanticAttributeMatch",
"passed": true,
"details": "All clinical qualifiers in 'I50.21' (Acute systolic (congestive) heart failure) are supported by documentation."
}
]
},
"final_result": {
"code": "I50.21",
"description": "Acute systolic (congestive) heart failure",
"role": "PRIMARY"
}
}
]
},
{
"case_id": "CASE-02-UNSUPPORTED-SPECIFICITY",
"title": "General Heart Failure Mention Without Subtype Specificity",
"status": "PARTIAL_SUCCESS",
"primary_diagnosis": {
"code": "I50.9",
"description": "Heart failure, unspecified",
"confidence_score": 1.0
},
"secondary_diagnoses": [],
"abstention_count": 1,
"abstentions": [
{
"diagnosis": "Fatigue and peripheral edema",
"reason": "EXCLUDED_BY_NEGATION",
"detail": "Symptom integral to the primary diagnosis 'Heart failure'; excluded under CMS Guideline I.B.4: \"Fatigue and peripheral edema\".",
"stage": "CLASSIFICATION"
}
],
"audit_trail_sample": [
{
"document_id": "CASE-02-UNSUPPORTED-SPECIFICITY",
"diagnosis_id": "dfc003b4-249f-4089-9363-3540bf930a44",
"raw_term": "Heart failure",
"evidence": "1. Heart failure - Patient has documented history of heart failure. Maintenance oral furosemide was continued. No echocardiogram was performed during admission and ejection fraction was not documented.",
"context": {
"certainty": "CONFIRMED",
"temporality": "CURRENT",
"negation": "AFFIRMATIVE",
"acuity": "ACUTE"
},
"classification": {
"role": "PRIMARY",
"is_billable": true,
"reason": "Designated as Primary Diagnosis under UHDDS Guidelines (chief condition established after study to be responsible for occasioning admission). Documented evidence: \"1. Heart failure - Patient has documented history of heart failure. Maintenance oral furosemide was continued. No echocardiogram was performed during admission and ejection fraction was not documented.\". Clinical criteria: Explicitly documented as PRIMARY/PRINCIPAL DIAGNOSIS by provider (+10.0); Explicitly documented under discharge / final diagnoses (+5.0); Active intravenous / intensive therapeutic management administered (+2.0); Confirmed diagnostic certainty (+1.0)."
},
"retrieved_candidates": [
{
"code": "I50.89",
"description": "Other heart failure",
"score": 0.8643
},
{
"code": "I50.9",
"description": "Heart failure, unspecified",
"score": 0.85
},
{
"code": "I50.82",
"description": "Biventricular heart failure",
"score": 0.817
},
{
"code": "I50.21",
"description": "Acute systolic (congestive) heart failure",
"score": 0.75
},
{
"code": "I50.31",
"description": "Acute diastolic (congestive) heart failure",
"score": 0.75
},
{
"code": "I50.20",
"description": "Unspecified systolic (congestive) heart failure",
"score": 0.75
},
{
"code": "I50.30",
"description": "Unspecified diastolic (congestive) heart failure",
"score": 0.75
},
{
"code": "I50.22",
"description": "Chronic systolic (congestive) heart failure",
"score": 0.75
},
{
"code": "I50.32",
"description": "Chronic diastolic (congestive) heart failure",
"score": 0.75
},
{
"code": "I50.23",
"description": "Acute on chronic systolic (congestive) heart failure",
"score": 0.8
},
{
"code": "I50.33",
"description": "Acute on chronic diastolic (congestive) heart failure",
"score": 0.8
},
{
"code": "I50.811",
"description": "Acute right heart failure",
"score": 0.7825
},
{
"code": "I50.812",
"description": "Chronic right heart failure",
"score": 0.7741
},
{
"code": "I50.813",
"description": "Acute on chronic right heart failure",
"score": 0.7003
},
{
"code": "I50.810",
"description": "Right heart failure, unspecified",
"score": 0.7747
},
{
"code": "I50.1",
"description": "Left ventricular failure, unspecified",
"score": 0.75
},
{
"code": "I50.84",
"description": "End stage heart failure",
"score": 0.7992
},
{
"code": "I50.83",
"description": "High output heart failure",
"score": 0.7825
},
{
"code": "I50.40",
"description": "Unspecified combined systolic (congestive) and diastolic (congestive) heart failure",
"score": 0.8
},
{
"code": "I50.41",
"description": "Acute combined systolic (congestive) and diastolic (congestive) heart failure",
"score": 0.8
},
{
"code": "I50.42",
"description": "Chronic combined systolic (congestive) and diastolic (congestive) heart failure",
"score": 0.8
},
{
"code": "I50.43",
"description": "Acute on chronic combined systolic (congestive) and diastolic (congestive) heart failure",
"score": 0.8
},
{
"code": "I50.814",
"description": "Right heart failure due to left heart failure",
"score": 0.8905
},
{
"code": "T86.22",
"description": "Heart transplant failure",
"score": 0.8459
},
{
"code": "I09.81",
"description": "Rheumatic heart failure",
"score": 0.8197
}
],
"selected_candidate": {
"code": "I50.9",
"description": "Heart failure, unspecified",
"confidence": 1.0,
"reason": "Candidate 'I50.9' (Heart failure, unspecified) best supported by documentation (core diagnostic entity match (2/2), canonical base/unspecified code for general documentation).",
"decision": "ACCEPTED"
},
"validation": {
"status": "PASSED",
"checks": [
{
"rule_name": "CatalogExistence",
"passed": true,
"details": "Code 'I50.9' exists in local authoritative catalog."
},
{
"rule_name": "TerminalSpecificity",
"passed": true,
"details": "Code 'I50.9' is at terminal billable specificity."
},
{
"rule_name": "SemanticAttributeMatch",
"passed": true,
"details": "All clinical qualifiers in 'I50.9' (Heart failure, unspecified) are supported by documentation."
}
]
},
"final_result": {
"code": "I50.9",
"description": "Heart failure, unspecified",
"role": "PRIMARY"
}
},
{
"document_id": "CASE-02-UNSUPPORTED-SPECIFICITY",
"diagnosis_id": "3a2b3c82-236a-4703-83ac-ede1c8405c95",
"raw_term": "Fatigue and peripheral edema",
"evidence": "Fatigue and peripheral edema",
"context": {
"certainty": "CONFIRMED",
"temporality": "HISTORICAL",
"negation": "AFFIRMATIVE",
"acuity": "UNSPECIFIED"
},
"classification": {
"role": "EXCLUDED",
"is_billable": false,
"reason": "Symptom integral to the primary diagnosis 'Heart failure'; excluded under CMS Guideline I.B.4: \"Fatigue and peripheral edema\"."
},
"retrieved_candidates": [],
"selected_candidate": {
"code": null,
"description": null,
"confidence": 0.0,
"reason": "Candidate pool was empty; no matching local ICD code.",
"decision": "ABSTAINED"
},
"validation": {
"status": "REJECTED_OR_ABSTAINED",
"checks": []
},
"final_result": {
"code": null,
"description": null,
"role": null
}
}
]
},
{
"case_id": "CASE-03-RULED-OUT-CONDITION",
"title": "Ruled-Out Acute Condition (Myocardial Infarction)",
"status": "PARTIAL_SUCCESS",
"primary_diagnosis": {
"code": "R07.4",
"description": "Chest pain, unspecified",
"confidence_score": 1.0
},
"secondary_diagnoses": [],
"abstention_count": 1,
"abstentions": [
{
"diagnosis": "Non-cardiac chest pain",
"reason": "EXCLUDED_BY_NEGATION",
"detail": "Excluded from coding: [DISCHARGE_DIAGNOSES] Definitively ruled out during hospital stay based on diagnostic evaluation.",
"stage": "CLASSIFICATION"
}
],
"audit_trail_sample": [
{
"document_id": "CASE-03-RULED-OUT-CONDITION",
"diagnosis_id": "8d3e3f9e-7073-4d62-8dae-89a57681c902",
"raw_term": "Non-cardiac chest pain",
"evidence": "1. Non-cardiac chest pain - Evaluated for acute coronary syndrome. Acute myocardial infarction was definitively ruled out by serial negative high-sensitivity troponins and normal ECG.",
"context": {
"certainty": "CONFIRMED",
"temporality": "HISTORICAL",
"negation": "AFFIRMATIVE",
"acuity": "UNSPECIFIED"
},
"classification": {
"role": "EXCLUDED",
"is_billable": false,
"reason": "Excluded from coding: [DISCHARGE_DIAGNOSES] Definitively ruled out during hospital stay based on diagnostic evaluation."
},
"retrieved_candidates": [],
"selected_candidate": {
"code": null,
"description": null,
"confidence": 0.0,
"reason": "Candidate pool was empty; no matching local ICD code.",
"decision": "ABSTAINED"
},
"validation": {
"status": "REJECTED_OR_ABSTAINED",
"checks": []
},
"final_result": {
"code": null,
"description": null,
"role": null
}
},
{
"document_id": "CASE-03-RULED-OUT-CONDITION",
"diagnosis_id": "68ef741c-4b87-4804-a3a8-4250ef31430b",
"raw_term": "Acute substernal chest discomfort",
"evidence": "Acute substernal chest discomfort",
"context": {
"certainty": "CONFIRMED",
"temporality": "CURRENT",
"negation": "AFFIRMATIVE",
"acuity": "ACUTE"
},
"classification": {
"role": "PRIMARY",
"is_billable": true,
"reason": "Designated as Primary Diagnosis under UHDDS Guidelines (chief condition established after study to be responsible for occasioning admission). Documented evidence: \"Acute substernal chest discomfort\". Clinical criteria: Explicitly documented as PRIMARY/PRINCIPAL DIAGNOSIS by provider (+10.0); Explicitly documented under discharge / final diagnoses (+5.0); Acute presentation (+2.0); Confirmed diagnostic certainty (+1.0); Symptom / manifestation accompanying presentation (-2.0)."
},
"retrieved_candidates": [
{
"code": "R07.3",
"description": "Other chest pain",
"score": 0.85
},
{
"code": "R07.89",
"description": "Other chest pain",
"score": 0.85
},
{
"code": "R07.4",
"description": "Chest pain, unspecified",
"score": 0.85
},
{
"code": "R07.9",
"description": "Chest pain, unspecified",
"score": 0.85
},
{
"code": "D57.01",
"description": "Hb-SS disease with acute chest syndrome",
"score": 0.85
},
{
"code": "R07.1",
"description": "Chest pain on breathing",
"score": 0.75
},
{
"code": "G89.18",
"description": "Other acute postprocedural pain",
"score": 0.75
},
{
"code": "G89.11",
"description": "Acute pain due to trauma",
"score": 0.75
},
{
"code": "G89.12",
"description": "Acute post-thoracotomy pain",
"score": 0.75
},
{
"code": "G89.3",
"description": "Neoplasm related pain (acute) (chronic)",
"score": 0.75
},
{
"code": "L03.323",
"description": "Acute lymphangitis of chest wall",
"score": 0.75
},
{
"code": "J06.0",
"description": "Acute laryngopharyngitis",
"score": 0.75
},
{
"code": "H53.149",
"description": "Visual discomfort, unspecified",
"score": 0.75
},
{
"code": "D57.811",
"description": "Other sickle-cell disorders with acute chest syndrome",
"score": 0.65
},
{
"code": "D57.211",
"description": "Sickle-cell/Hb-C disease with acute chest syndrome",
"score": 0.65
},
{
"code": "D57.411",
"description": "Sickle-cell thalassemia, unspecified, with acute chest syndrome",
"score": 0.55
},
{
"code": "H53.143",
"description": "Visual discomfort, bilateral",
"score": 0.55
},
{
"code": "D57.451",
"description": "Sickle-cell thalassemia beta plus with acute chest syndrome",
"score": 0.5
},
{
"code": "D57.431",
"description": "Sickle-cell thalassemia beta zero with acute chest syndrome",
"score": 0.5
},
{
"code": "99465",
"description": "Delivery/birthing room resuscitation, provision of positive pressure ventilation and/or chest compressions in the presence of acute inadequate ventilation and/or cardiac output",
"score": 0.5
},
{
"code": "H53.141",
"description": "Visual discomfort, right eye",
"score": 0.5
},
{
"code": "H53.142",
"description": "Visual discomfort, left eye",
"score": 0.5
},
{
"code": "60271",
"description": "Thyroidectomy, including substernal thyroid; cervical approach",
"score": 0.5
},
{
"code": "74022",
"description": "Radiologic examination, abdomen; complete acute abdomen series, including supine, erect, and/or decubitus views, single view chest",
"score": 0.5
},
{
"code": "60270",
"description": "Thyroidectomy, including substernal thyroid; sternal split or transthoracic approach",
"score": 0.5
}
],
"selected_candidate": {
"code": "R07.4",
"description": "Chest pain, unspecified",
"confidence": 1.0,
"reason": "Candidate 'R07.4' (Chest pain, unspecified) best supported by documentation (core diagnostic entity match (2/3), unspecified code when specific detail (substernal) is documented).",
"decision": "ACCEPTED"
},
"validation": {
"status": "PASSED",
"checks": [
{
"rule_name": "CatalogExistence",
"passed": true,
"details": "Code 'R07.4' exists in local authoritative catalog."
},
{
"rule_name": "TerminalSpecificity",
"passed": true,
"details": "Code 'R07.4' is at terminal billable specificity."
},
{
"rule_name": "SemanticAttributeMatch",
"passed": true,
"details": "All clinical qualifiers in 'R07.4' (Chest pain, unspecified) are supported by documentation."
}
]
},
"final_result": {
"code": "R07.4",
"description": "Chest pain, unspecified",
"role": "PRIMARY"
}
}
]
},
{
"case_id": "CASE-04-HISTORICAL-PMH-ONLY",
"title": "Past Medical History Without Inpatient Care (Remote CVA)",
"status": "SUCCESS",
"primary_diagnosis": null,
"secondary_diagnoses": [],
"abstention_count": 0,
"abstentions": [],
"audit_trail_sample": [
{
"document_id": "CASE-04-HISTORICAL-PMH-ONLY",
"diagnosis_id": "e82ab099-e910-45f7-8696-2fd0557fc238",
"raw_term": "Remote stroke in 2014 without residual neurological deficit.",
"evidence": "1. Remote stroke in 2014 without residual neurological deficit.",
"context": {
"certainty": "CONFIRMED",
"temporality": "HISTORICAL",
"negation": "AFFIRMATIVE",
"acuity": "UNSPECIFIED"
},
"classification": {
"role": "EXCLUDED",
"is_billable": false,
"reason": "Excluded from coding: [PAST_MEDICAL_HISTORY] Past Medical History alone without documented inpatient evaluation, monitoring, or therapy."
},
"retrieved_candidates": [],
"selected_candidate": null,
"validation": {
"status": "REJECTED_OR_ABSTAINED",
"checks": []
},
"final_result": {
"code": null,
"description": null,
"role": null
}
}
]
},
{
"case_id": "CASE-05-EMPTY-DOCUMENT",
"title": "Empty / Whitespace-Only Document",
"status": "ABSTAINED",
"primary_diagnosis": null,
"secondary_diagnoses": [],
"abstention_count": 1,
"abstentions": [
{
"diagnosis": null,
"reason": "INSUFFICIENT_CLINICAL_EVIDENCE",
"detail": "Input document text, PDF, and image sources are all empty or missing.",
"stage": "VALIDATION"
}
],
"audit_trail_sample": []
},
{
"case_id": "CASE-06-NON-CLINICAL-GIBBERISH",
"title": "Non-Clinical Gibberish Text",
"status": "ABSTAINED",
"primary_diagnosis": null,
"secondary_diagnoses": [],
"abstention_count": 1,
"abstentions": [
{
"diagnosis": null,
"reason": "INSUFFICIENT_CLINICAL_EVIDENCE",
"detail": "No clinical diagnosis mentions identified in document.",
"stage": "EXTRACTION"
}
],
"audit_trail_sample": []
}
]
}