feat: ajout viewer Flask CIM-10 avec config Ollama centralisée et chronométrage

Ajoute une interface web Flask pour visualiser les dossiers médicaux CIM-10,
avec temps de traitement par PDF, sélecteur de modèle Ollama, et centralisation
de la config Ollama dans src/config.py.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
dom
2026-02-10 20:11:07 +01:00
parent fc68fc6f6b
commit 037d255aa0
10 changed files with 721 additions and 7 deletions

View File

@@ -0,0 +1,206 @@
{% extends "base.html" %}
{% block title %}{{ dossier.source_file or filepath }}{% endblock %}
{% block sidebar %}
<div class="group-title">Navigation</div>
<a href="/">Retour à la liste</a>
{% endblock %}
{% block content %}
<a class="back" href="/">&larr; Retour à la liste</a>
{# ---- En-tête ---- #}
<div class="card" style="margin-top:1rem;">
<h2>{{ dossier.source_file or filepath }}</h2>
<div class="info-grid">
{% if dossier.document_type %}
<div class="info-item">
<label>Type de document</label>
<span class="badge" style="background:#e0e7ff;color:#3730a3;">{{ dossier.document_type }}</span>
</div>
{% endif %}
{% if dossier.processing_time_s is not none %}
<div class="info-item">
<label>Temps de traitement</label>
<span>{{ dossier.processing_time_s }}s</span>
</div>
{% endif %}
</div>
</div>
{# ---- Séjour ---- #}
{% set s = dossier.sejour %}
{% if s.sexe or s.age or s.date_entree or s.date_sortie or s.duree_sejour is not none or s.imc or s.poids or s.taille %}
<div class="card section">
<h3>Séjour</h3>
<div class="info-grid">
{% if s.sexe %}<div class="info-item"><label>Sexe</label><span>{{ s.sexe }}</span></div>{% endif %}
{% if s.age is not none %}<div class="info-item"><label>Âge</label><span>{{ s.age }} ans</span></div>{% endif %}
{% if s.date_entree %}<div class="info-item"><label>Entrée</label><span>{{ s.date_entree }}</span></div>{% endif %}
{% if s.date_sortie %}<div class="info-item"><label>Sortie</label><span>{{ s.date_sortie }}</span></div>{% endif %}
{% if s.duree_sejour is not none %}<div class="info-item"><label>Durée</label><span>{{ s.duree_sejour }} jour(s)</span></div>{% endif %}
{% if s.mode_entree %}<div class="info-item"><label>Mode entrée</label><span>{{ s.mode_entree }}</span></div>{% endif %}
{% if s.mode_sortie %}<div class="info-item"><label>Mode sortie</label><span>{{ s.mode_sortie }}</span></div>{% endif %}
{% if s.poids %}<div class="info-item"><label>Poids</label><span>{{ s.poids }} kg</span></div>{% endif %}
{% if s.taille %}<div class="info-item"><label>Taille</label><span>{{ s.taille }} cm</span></div>{% endif %}
{% if s.imc %}<div class="info-item"><label>IMC</label><span>{{ s.imc }}</span></div>{% endif %}
</div>
</div>
{% endif %}
{# ---- Diagnostic principal ---- #}
{% if dossier.diagnostic_principal %}
{% set dp = dossier.diagnostic_principal %}
<div class="card section">
<h3>Diagnostic principal</h3>
<div style="font-size:0.95rem;margin-bottom:0.5rem;">{{ dp.texte }}</div>
{% 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 }}
{% endif %}
{% if dp.justification %}
<div style="margin-top:0.5rem;font-size:0.8rem;color:#475569;">{{ dp.justification }}</div>
{% endif %}
{% if dp.sources_rag %}
<details>
<summary>Sources RAG ({{ dp.sources_rag|length }})</summary>
{% for src in dp.sources_rag %}
<pre>{{ src.document }}{% if src.code %} — {{ src.code }}{% endif %}{% if src.page %} [p.{{ src.page }}]{% endif %}
{{ src.extrait or '' }}</pre>
{% endfor %}
</details>
{% endif %}
</div>
{% endif %}
{# ---- Diagnostics associés ---- #}
{% if dossier.diagnostics_associes %}
<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>
<tbody>
{% for das in dossier.diagnostics_associes %}
<tr>
<td>{{ das.texte }}</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 style="font-size:0.8rem;color:#475569;">{{ das.justification or '' }}</td>
</tr>
{% if das.sources_rag %}
<tr>
<td colspan="4" style="padding:0 0.75rem 0.5rem;">
<details>
<summary>Sources RAG ({{ das.sources_rag|length }})</summary>
{% for src in das.sources_rag %}
<pre>{{ src.document }}{% if src.code %} — {{ src.code }}{% endif %}{% if src.page %} [p.{{ src.page }}]{% endif %}
{{ src.extrait or '' }}</pre>
{% endfor %}
</details>
</td>
</tr>
{% endif %}
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
{# ---- Actes CCAM ---- #}
{% if dossier.actes_ccam %}
<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>
<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>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
{# ---- Biologie clé ---- #}
{% if dossier.biologie_cle %}
<div class="card section">
<h3>Biologie clé ({{ dossier.biologie_cle|length }})</h3>
<table>
<thead><tr><th>Test</th><th>Valeur</th><th>Anomalie</th></tr></thead>
<tbody>
{% for b in dossier.biologie_cle %}
<tr{% if b.anomalie %} class="anomalie"{% endif %}>
<td>{{ b.test }}</td>
<td>{{ b.valeur or '' }}</td>
<td>{% if b.anomalie %}<span class="badge" style="background:#fee2e2;color:#dc2626;">Oui</span>{% else %}—{% endif %}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
{# ---- Imagerie ---- #}
{% if dossier.imagerie %}
<div class="card section">
<h3>Imagerie ({{ dossier.imagerie|length }})</h3>
{% for img in dossier.imagerie %}
<div style="margin-bottom:0.5rem;">
<strong>{{ img.type }}</strong>
{% if img.score %} — Score : {{ img.score }}{% endif %}
{% if img.conclusion %}
<div style="font-size:0.85rem;color:#475569;">{{ img.conclusion }}</div>
{% endif %}
</div>
{% endfor %}
</div>
{% endif %}
{# ---- Traitements de sortie ---- #}
{% if dossier.traitements_sortie %}
<div class="card section">
<h3>Traitements de sortie ({{ dossier.traitements_sortie|length }})</h3>
<table>
<thead><tr><th>Médicament</th><th>Posologie</th><th>Code ATC</th></tr></thead>
<tbody>
{% for t in dossier.traitements_sortie %}
<tr>
<td>{{ t.medicament }}</td>
<td>{{ t.posologie or '' }}</td>
<td>{% if t.code_atc %}<span class="badge" style="background:#e0e7ff;color:#3730a3;">{{ t.code_atc }}</span>{% endif %}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
{# ---- Antécédents ---- #}
{% if dossier.antecedents %}
<div class="card section">
<h3>Antécédents ({{ dossier.antecedents|length }})</h3>
<ul class="bullet">
{% for a in dossier.antecedents %}
<li>{{ a }}</li>
{% endfor %}
</ul>
</div>
{% endif %}
{# ---- Complications ---- #}
{% if dossier.complications %}
<div class="card section">
<h3>Complications ({{ dossier.complications|length }})</h3>
<ul class="bullet">
{% for c in dossier.complications %}
<li>{{ c }}</li>
{% endfor %}
</ul>
</div>
{% endif %}
{% endblock %}