From ced32805b3a8fe9b82957c513003b39019db8e52 Mon Sep 17 00:00:00 2001 From: Abhinav Gupta Date: Thu, 8 Oct 2026 13:50:56 +0530 Subject: [PATCH] fix(pipeline): complete database-grounded recall, exact evidence extraction, and Streamlit image width on extraction-fix --- src/medical_coding/ui/app.py | 4 ++-- tests/test_icd_matching_regression.py | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/medical_coding/ui/app.py b/src/medical_coding/ui/app.py index a48c25a..269e56e 100644 --- a/src/medical_coding/ui/app.py +++ b/src/medical_coding/ui/app.py @@ -438,7 +438,7 @@ with tab1: col_img, col_txt = st.columns([1, 1]) with col_img: st.markdown("##### 🖼️ Uploaded Clinical Screenshot") - st.image(active_file_bytes, caption=active_filename, use_container_width=True) + st.image(active_file_bytes, caption=active_filename, width="stretch") with col_txt: st.markdown("##### 📄 OCR Extracted Discharge Summary") clinical_text = st.text_area("Extracted Text (Editable):", value=clinical_text, height=350) @@ -603,7 +603,7 @@ with tab1: col_img, col_txt = st.columns([1, 1]) with col_img: st.markdown("##### 🖼️ Synthetic Clinical Screenshot") - st.image(active_file_bytes, caption=active_filename, use_container_width=True) + st.image(active_file_bytes, caption=active_filename, width="stretch") with col_txt: st.markdown("##### 📄 OCR Extracted Text") clinical_text = st.text_area("Extracted Document Content:", value=clinical_text, height=350) diff --git a/tests/test_icd_matching_regression.py b/tests/test_icd_matching_regression.py index 94da31a..6908c5c 100644 --- a/tests/test_icd_matching_regression.py +++ b/tests/test_icd_matching_regression.py @@ -127,3 +127,29 @@ async def test_regression_ruled_out_condition_abstains() -> None: assert len(appendicitis_abstentions) > 0 or ( res.primary_diagnosis and "adenitis" in res.primary_diagnosis.raw_term.lower() ) + + +@pytest.mark.asyncio +async def test_regression_oncology_and_pmh_comorbidities() -> None: + """Documented oncology primary with active chronic PMH comorbidities and clinical examination.""" + doc = """ + FINAL DIAGNOSIS: + Metastatic carcinoma left breast + + CLINICAL EXAMINATION: Patient alert and responsive Temperature : 97.02°F pulse: 100 beats per minute Respiratory rate : 20 cycles per minute BP: 145/84 mmHg SPO2: 96% on room air RS : AEBE CVS : S1, S2 heard well CNS : NAD PA : Soft, non tender COURSE IN THE HOSPITAL AND DISCUSSION: Patient was admitted with above mentioned complaints. + + Admitted for further management PERSONAL HISTORY: Known case of hypertension and asthma, on medication. + """ + res = await process_clinical_document(source=doc, document_id="doc-reg-onc-pmh") + assert res is not None + assert res.primary_diagnosis is not None + assert res.primary_diagnosis.code == "C50.912" + assert "left" in res.primary_diagnosis.description.lower() + assert res.primary_diagnosis.raw_term == "Metastatic carcinoma left breast" + + sec_codes = {s.code for s in res.secondary_diagnoses} + assert "I10" in sec_codes + assert "J45.909" in sec_codes + assert "Z71.1" not in sec_codes + assert len(res.secondary_diagnoses) == 2 +