feat: règles métier T2A Phase 1 — exclusions diagnostiques, sévérité CMA et alertes codage

Ajout des règles d'exclusion symptôme (R00-R99) vs diagnostic précis (Chapitres I-XIV),
détection heuristique de sévérité CMA sur 25 racines CIM-10, et affichage des alertes
de codage dans le viewer Flask. 153 tests, 0 régression.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
dom
2026-02-11 08:53:14 +01:00
parent 12f4479cd2
commit 9df4465fef
8 changed files with 911 additions and 42 deletions

View File

@@ -4,6 +4,9 @@
{% block sidebar %}
<div class="group-title">Navigation</div>
<a href="/">Retour à la liste</a>
<div class="group-title" style="margin-top:1.5rem;">Actions</div>
<button id="reprocess-btn" style="width:100%;padding:0.6rem;background:#3b82f6;color:white;border:none;border-radius:0.375rem;cursor:pointer;font-size:0.875rem;font-weight:600;margin-bottom:0.5rem;">🔄 Relancer l'étude</button>
<div id="reprocess-status" style="font-size:0.75rem;padding:0.25rem;"></div>
{% endblock %}
{% block content %}
@@ -48,6 +51,18 @@
</div>
{% endif %}
{# ---- Alertes de codage ---- #}
{% if dossier.alertes_codage %}
<div class="card section" style="border-left:4px solid #f97316;background:#fff7ed;">
<h3 style="color:#c2410c;">Alertes de codage ({{ dossier.alertes_codage|length }})</h3>
<ul style="margin:0;padding-left:1.2rem;">
{% for alerte in dossier.alertes_codage %}
<li style="font-size:0.85rem;color:#9a3412;margin-bottom:0.25rem;">{{ alerte }}</li>
{% endfor %}
</ul>
</div>
{% endif %}
{# ---- Diagnostic principal ---- #}
{% if dossier.diagnostic_principal %}
{% set dp = dossier.diagnostic_principal %}
@@ -57,6 +72,10 @@
{% if dp.cim10_suggestion %}
<span class="badge" style="background:#dbeafe;color:#1d4ed8;font-size:0.85rem;">{{ dp.cim10_suggestion }}</span>
{{ dp.cim10_confidence | confidence_badge }}
{% if dp.est_cma %}<span class="badge" style="background:#fee2e2;color:#dc2626;font-size:0.75rem;">CMA</span>{% endif %}
{% if dp.niveau_severite == 'severe' %}<span class="badge" style="background:#fee2e2;color:#dc2626;font-size:0.75rem;">Sévère</span>
{% elif dp.niveau_severite == 'modere' %}<span class="badge" style="background:#fef3c7;color:#92400e;font-size:0.75rem;">Modéré</span>
{% elif dp.niveau_severite == 'leger' %}<span class="badge" style="background:#d1fae5;color:#065f46;font-size:0.75rem;">Léger</span>{% endif %}
{% endif %}
{% if dp.justification %}
<div style="margin-top:0.5rem;font-size:0.8rem;color:#475569;">{{ dp.justification }}</div>
@@ -78,13 +97,22 @@
<div class="card section">
<h3>Diagnostics associés ({{ dossier.diagnostics_associes|length }})</h3>
<table>
<thead><tr><th>Texte</th><th>CIM-10</th><th>Confiance</th><th>Justification</th></tr></thead>
<thead><tr><th>Texte</th><th>CIM-10</th><th>Confiance</th><th>Sévérité</th><th>Justification</th></tr></thead>
<tbody>
{% for das in dossier.diagnostics_associes %}
<tr>
<td>{{ das.texte }}</td>
<td>
{{ das.texte }}
{% if das.est_cma %}<span class="badge" style="background:#fee2e2;color:#dc2626;font-size:0.7rem;margin-left:0.3rem;">CMA</span>{% endif %}
</td>
<td>{% if das.cim10_suggestion %}<span class="badge" style="background:#dbeafe;color:#1d4ed8;">{{ das.cim10_suggestion }}</span>{% endif %}</td>
<td>{{ das.cim10_confidence | confidence_badge }}</td>
<td>
{% if das.niveau_severite == 'severe' %}<span class="badge" style="background:#fee2e2;color:#dc2626;">Sévère</span>
{% elif das.niveau_severite == 'modere' %}<span class="badge" style="background:#fef3c7;color:#92400e;">Modéré</span>
{% elif das.niveau_severite == 'leger' %}<span class="badge" style="background:#d1fae5;color:#065f46;">Léger</span>
{% else %}—{% endif %}
</td>
<td style="font-size:0.8rem;color:#475569;">{{ das.justification or '' }}</td>
</tr>
{% if das.sources_rag %}
@@ -111,13 +139,21 @@
<div class="card section">
<h3>Actes CCAM ({{ dossier.actes_ccam|length }})</h3>
<table>
<thead><tr><th>Texte</th><th>Code CCAM</th><th>Date</th></tr></thead>
<thead><tr><th>Texte</th><th>Code CCAM</th><th>Date</th><th>Validité</th></tr></thead>
<tbody>
{% for a in dossier.actes_ccam %}
<tr>
<td>{{ a.texte }}</td>
<td>{% if a.code_ccam_suggestion %}<span class="badge" style="background:#e0e7ff;color:#3730a3;">{{ a.code_ccam_suggestion }}</span>{% endif %}</td>
<td>{{ a.date or '' }}</td>
<td>
{% if a.validite == 'valide' %}<span class="badge" style="background:#d1fae5;color:#065f46;">Valide</span>
{% elif a.validite == 'obsolete' %}<span class="badge" style="background:#fee2e2;color:#dc2626;">Obsolète</span>
{% else %}—{% endif %}
{% for alerte in a.alertes %}
<div style="font-size:0.7rem;color:#dc2626;">{{ alerte }}</div>
{% endfor %}
</td>
</tr>
{% endfor %}
</tbody>
@@ -204,3 +240,38 @@
{% endif %}
{% endblock %}
{% block scripts %}
<script>
document.getElementById('reprocess-btn').addEventListener('click', async () => {
const btn = document.getElementById('reprocess-btn');
const status = document.getElementById('reprocess-status');
btn.disabled = true;
btn.textContent = 'Traitement en cours...';
status.textContent = '';
status.style.color = '#3b82f6';
try {
const response = await fetch('/reprocess/{{ filepath }}', { method: 'POST' });
const data = await response.json();
if (data.ok) {
status.textContent = '✓ ' + data.message;
status.style.color = '#16a34a';
setTimeout(() => location.reload(), 1500);
} else {
status.textContent = '✗ ' + (data.error || 'Erreur');
status.style.color = '#dc2626';
btn.disabled = false;
btn.textContent = 'Relancer l\'étude';
}
} catch (err) {
status.textContent = '✗ Erreur réseau';
status.style.color = '#dc2626';
btn.disabled = false;
btn.textContent = 'Relancer l\'étude';
}
});
</script>
{% endblock %}