feat: enrichissement contre-argumentation CPAM — libellés CIM-10, RAG ciblé, reprocess complet

- Résolution des libellés CIM-10 pour les codes contestés (dp_ucr, da_ucr, dr_ucr)
- Fallback DP depuis dp_ucr quand le pipeline n'extrait pas de diagnostic principal
- Troncature arg_ucr augmentée de 200 à 500 chars pour conserver les citations de règles
- Requête RAG 4 : définitions CIM-10 (inclusion/exclusion) des codes contestés
- Requête RAG 5 : extraction et recherche des règles nommées (RègleT7, Annexe, etc.)
- Cap résultats RAG de 10 à 12 pour absorber les nouvelles requêtes
- Reprocess viewer : pipeline complet (fusion + GHM + CPAM) pour dossiers multi-PDF
- Affichage structuré response_data dans le viewer (analyse, preuves, références)
- 7 nouveaux tests CPAM, 6 nouveaux tests viewer

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
dom
2026-02-17 23:24:10 +01:00
parent 94fa4e5f3b
commit bc0ccbef7c
7 changed files with 464 additions and 51 deletions

View File

@@ -2,7 +2,7 @@
import pytest
from src.viewer.app import create_app, compute_group_stats, severity_badge, format_duration
from src.viewer.app import create_app, compute_group_stats, severity_badge, format_duration, format_cpam_text
from src.config import DossierMedical, Diagnostic, ActeCCAM
@@ -104,6 +104,40 @@ class TestIndexPageLoads:
assert b"Dossiers" in response.data
class TestFormatCpamText:
def test_plain_text(self):
result = format_cpam_text("Un simple paragraphe.")
assert "<p" in result
assert "Un simple paragraphe." in result
def test_bullet_list(self):
result = format_cpam_text("- Premier argument\n- Deuxième argument")
assert "<ul" in result
assert "<li>Premier argument</li>" in result
assert "<li>Deuxième argument</li>" in result
def test_mixed_text_and_bullets(self):
text = "Introduction\n- Point A\n- Point B\nConclusion"
result = format_cpam_text(text)
assert "<p" in result
assert "<ul" in result
assert "<li>Point A</li>" in result
assert "Conclusion" in result
def test_none_input(self):
result = format_cpam_text(None)
assert result == ""
def test_empty_input(self):
result = format_cpam_text("")
assert result == ""
def test_html_escaping(self):
result = format_cpam_text("Test <script>alert('xss')</script>")
assert "<script>" not in result
assert "&lt;script&gt;" in result
class TestDetailPageLoads:
def test_detail_page_404(self, client):
"""Un fichier inexistant retourne 404."""