Files
t2a_v2/src/viewer/templates/base.html
dom 40934fdc39 feat: traçabilité source systématique + viewer interactif
Ajoute source_page/source_excerpt à tous les types (biologie, imagerie,
traitements, actes CCAM, antécédents, complications). Convertit antecedents
et complications en types structurés (Antecedent/Complication) avec
validators backward-compat pour les vieux JSON. Étend _apply_source_tracking
à tous les éléments du dossier. Ajoute un endpoint /api/source-text/ et un
modal interactif dans le viewer avec surlignage du texte source.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-18 20:59:50 +01:00

453 lines
12 KiB
HTML

<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{% block title %}Viewer CIM-10{% endblock %} — T2A</title>
<style>
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
background: #f1f5f9;
color: #1e293b;
display: flex;
min-height: 100vh;
}
/* Sidebar */
.sidebar {
width: 280px;
min-width: 280px;
background: #1e293b;
color: #e2e8f0;
display: flex;
flex-direction: column;
position: fixed;
top: 0;
left: 0;
bottom: 0;
overflow-y: auto;
}
.sidebar-header {
padding: 1.25rem 1rem;
border-bottom: 1px solid #334155;
}
.sidebar-header h1 {
font-size: 1.1rem;
color: #f1f5f9;
font-weight: 700;
}
.sidebar-header p {
font-size: 0.75rem;
color: #94a3b8;
margin-top: 0.25rem;
}
.sidebar-nav {
flex: 1;
padding: 0.75rem 0;
overflow-y: auto;
}
.sidebar-nav .group-title {
padding: 0.5rem 1rem 0.25rem;
font-size: 0.65rem;
text-transform: uppercase;
letter-spacing: 0.08em;
color: #94a3b8;
font-weight: 700;
}
.sidebar-nav a {
display: block;
padding: 0.4rem 1rem;
color: #cbd5e1;
text-decoration: none;
font-size: 0.8rem;
font-weight: 600;
border-left: 3px solid transparent;
transition: all 0.15s;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.sidebar-nav a:hover {
color: #f8fafc;
background: #334155;
border-left-color: #3b82f6;
}
.sidebar-nav a.sidebar-fusionne {
color: #60a5fa;
font-weight: 700;
}
/* Search */
.sidebar-search {
padding: 0.75rem 1rem 0.5rem;
border-bottom: 1px solid #334155;
}
.sidebar-search input {
width: 100%;
padding: 0.45rem 0.6rem;
border-radius: 6px;
border: 1px solid #475569;
background: #0f172a;
color: #e2e8f0;
font-size: 0.8rem;
outline: none;
transition: border-color 0.15s;
}
.sidebar-search input::placeholder { color: #64748b; }
.sidebar-search input:focus { border-color: #3b82f6; }
/* Admin section */
.sidebar-admin {
padding: 1rem;
border-top: 1px solid #334155;
font-size: 0.8rem;
}
.sidebar-admin label {
display: block;
margin-bottom: 0.35rem;
font-weight: 600;
color: #cbd5e1;
font-size: 0.7rem;
text-transform: uppercase;
letter-spacing: 0.05em;
}
.sidebar-admin select {
width: 100%;
padding: 0.4rem;
border-radius: 6px;
border: 1px solid #475569;
background: #0f172a;
color: #e2e8f0;
font-size: 0.8rem;
margin-bottom: 0.5rem;
}
.sidebar-admin button {
width: 100%;
padding: 0.45rem;
border-radius: 6px;
border: none;
background: #3b82f6;
color: #fff;
font-size: 0.8rem;
font-weight: 600;
cursor: pointer;
transition: background 0.15s;
}
.sidebar-admin button:hover { background: #2563eb; }
.sidebar-admin .status-msg {
margin-top: 0.35rem;
font-size: 0.7rem;
min-height: 1rem;
}
/* Main content */
.main {
margin-left: 280px;
flex: 1;
padding: 2rem;
}
/* Utilities */
.card {
background: #fff;
border-radius: 10px;
box-shadow: 0 1px 3px rgba(0,0,0,0.08);
padding: 1.25rem;
margin-bottom: 1rem;
}
.badge {
display: inline-block;
padding: 2px 8px;
border-radius: 9999px;
font-size: 0.7rem;
font-weight: 600;
}
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th, td { text-align: left; padding: 0.5rem 0.75rem; border-bottom: 1px solid #e2e8f0; }
th { font-weight: 600; color: #475569; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; }
tr.anomalie { background: #fef2f2; }
details { margin-top: 0.35rem; }
details summary {
cursor: pointer;
font-size: 0.75rem;
color: #3b82f6;
}
details pre {
font-size: 0.75rem;
background: #f8fafc;
padding: 0.5rem;
border-radius: 6px;
margin-top: 0.25rem;
white-space: pre-wrap;
word-break: break-word;
}
h2 { font-size: 1.1rem; margin-bottom: 0.75rem; color: #0f172a; }
h3 { font-size: 0.95rem; margin-bottom: 0.5rem; color: #334155; }
.info-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
gap: 0.75rem;
}
.info-item label { display: block; font-size: 0.7rem; color: #64748b; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.info-item span { font-size: 0.9rem; }
.section { margin-bottom: 1.5rem; }
ul.bullet { list-style: disc; padding-left: 1.5rem; font-size: 0.85rem; }
ul.bullet li { margin-bottom: 0.25rem; }
a.back { font-size: 0.85rem; color: #3b82f6; text-decoration: none; }
a.back:hover { text-decoration: underline; }
/* Badges compteurs */
.badge-count {
display: inline-flex;
align-items: center;
gap: 0.2rem;
padding: 2px 8px;
border-radius: 9999px;
font-size: 0.7rem;
font-weight: 600;
}
.badge-das { background: #dbeafe; color: #1d4ed8; }
.badge-actes { background: #e0e7ff; color: #3730a3; }
.badge-alertes { background: #ffedd5; color: #c2410c; }
.badge-cma { background: #fee2e2; color: #dc2626; }
.badge-regroup { background: #f0fdf4; color: #166534; font-size: 0.65rem; }
.badge-fusion { background: #ede9fe; color: #5b21b6; }
/* Alertes non-cumul (rouge) vs standard (orange) */
.alerte-noncumul { color: #dc2626; font-weight: 600; }
.alerte-standard { color: #9a3412; }
/* Source files */
.source-files { font-size: 0.8rem; color: #64748b; margin-top: 0.5rem; }
.source-files code { background: #f1f5f9; padding: 1px 4px; border-radius: 3px; }
/* Spinner animation */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
display: inline-block;
width: 14px;
height: 14px;
border: 2px solid rgba(255,255,255,0.3);
border-top-color: #fff;
border-radius: 50%;
animation: spin 0.8s linear infinite;
}
/* Source tracking badges */
.src-btn {
display: inline-block;
padding: 1px 6px;
border-radius: 9999px;
font-size: 0.65rem;
font-weight: 600;
background: #e0f2fe;
color: #0369a1;
border: 1px solid #bae6fd;
cursor: pointer;
margin-left: 0.3rem;
vertical-align: middle;
transition: background 0.15s;
}
.src-btn:hover { background: #bae6fd; }
/* Source modal */
#source-modal {
display: none;
position: fixed;
inset: 0;
z-index: 9999;
background: rgba(0,0,0,0.5);
padding: 2rem;
}
#source-modal-inner {
background: #fff;
border-radius: 12px;
max-width: 900px;
margin: 0 auto;
max-height: 90vh;
display: flex;
flex-direction: column;
box-shadow: 0 8px 30px rgba(0,0,0,0.2);
}
#source-header {
padding: 1rem 1.25rem;
border-bottom: 1px solid #e2e8f0;
font-weight: 700;
font-size: 0.9rem;
color: #0f172a;
display: flex;
justify-content: space-between;
align-items: center;
}
#source-content {
flex: 1;
overflow-y: auto;
padding: 1.25rem;
font-size: 0.85rem;
line-height: 1.6;
white-space: pre-wrap;
word-break: break-word;
color: #334155;
}
#source-content mark {
background: #fef08a;
padding: 2px 0;
border-radius: 2px;
}
#source-close-btn {
padding: 0.4rem 1rem;
background: #64748b;
color: #fff;
border: none;
border-radius: 6px;
cursor: pointer;
font-size: 0.8rem;
font-weight: 600;
}
#source-close-btn:hover { background: #475569; }
</style>
</head>
<body>
<!-- Sidebar -->
<aside class="sidebar">
<div class="sidebar-header">
<h1>T2A Viewer</h1>
<p>Visualisation CIM-10</p>
</div>
<div class="sidebar-search">
<input type="text" id="sidebar-search" placeholder="Rechercher un dossier…" autocomplete="off">
</div>
<nav class="sidebar-nav" id="sidebar-nav">
{% block sidebar %}{% endblock %}
</nav>
<div class="sidebar-admin" style="border-top:1px solid #334155;padding:0.5rem 1rem;">
<a href="/dashboard" style="display:block;color:#cbd5e1;text-decoration:none;font-size:0.8rem;font-weight:600;padding:0.35rem 0;transition:color 0.15s;"
onmouseover="this.style.color='#f8fafc'" onmouseout="this.style.color='#cbd5e1'">
Dashboard
</a>
<a href="/cpam" style="display:block;color:#cbd5e1;text-decoration:none;font-size:0.8rem;font-weight:600;padding:0.35rem 0;transition:color 0.15s;"
onmouseover="this.style.color='#f8fafc'" onmouseout="this.style.color='#cbd5e1'">
Contrôles CPAM
</a>
<a href="/admin/referentiels" style="display:block;color:#cbd5e1;text-decoration:none;font-size:0.8rem;font-weight:600;padding:0.35rem 0;transition:color 0.15s;"
onmouseover="this.style.color='#f8fafc'" onmouseout="this.style.color='#cbd5e1'">
Référentiels RAG
</a>
<a href="/validation" style="display:block;color:#fbbf24;text-decoration:none;font-size:0.8rem;font-weight:600;padding:0.35rem 0;transition:color 0.15s;"
onmouseover="this.style.color='#fde68a'" onmouseout="this.style.color='#fbbf24'">
Validation DIM
</a>
</div>
<div class="sidebar-admin">
<label for="model-select">Modèle Ollama</label>
<select id="model-select"><option>Chargement…</option></select>
<button id="model-apply">Appliquer</button>
<div class="status-msg" id="model-status"></div>
</div>
</aside>
<!-- Main -->
<div class="main">
{% block content %}{% endblock %}
</div>
<script>
(function() {
const sel = document.getElementById('model-select');
const btn = document.getElementById('model-apply');
const status = document.getElementById('model-status');
function loadModels() {
fetch('/admin/models')
.then(r => r.json())
.then(d => {
sel.innerHTML = '';
if (d.models && d.models.length) {
d.models.forEach(m => {
const opt = document.createElement('option');
opt.value = m;
opt.textContent = m;
if (m === d.current) opt.selected = true;
sel.appendChild(opt);
});
} else {
sel.innerHTML = '<option>Aucun modèle</option>';
}
})
.catch(() => { sel.innerHTML = '<option>Erreur</option>'; });
}
btn.addEventListener('click', function() {
const model = sel.value;
if (!model || model === 'Aucun modèle' || model === 'Erreur') return;
status.textContent = '…';
status.style.color = '#94a3b8';
fetch('/admin/models', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({model: model})
})
.then(r => r.json())
.then(d => {
if (d.ok) {
status.textContent = 'Modèle appliqué';
status.style.color = '#16a34a';
} else {
status.textContent = d.error || 'Erreur';
status.style.color = '#dc2626';
}
})
.catch(() => {
status.textContent = 'Erreur réseau';
status.style.color = '#dc2626';
});
});
loadModels();
})();
// Sidebar search filter
(function() {
const input = document.getElementById('sidebar-search');
const nav = document.getElementById('sidebar-nav');
if (!input || !nav) return;
input.addEventListener('input', function() {
const q = this.value.toLowerCase().trim();
const groups = nav.querySelectorAll('.group-title');
groups.forEach(function(groupEl) {
// Collect all sibling links until next group-title
const links = [];
let next = groupEl.nextElementSibling;
while (next && !next.classList.contains('group-title')) {
if (next.tagName === 'A') links.push(next);
next = next.nextElementSibling;
}
if (!q) {
groupEl.style.display = '';
links.forEach(function(a) { a.style.display = ''; });
return;
}
const groupMatch = groupEl.textContent.toLowerCase().includes(q);
let anyLinkMatch = false;
links.forEach(function(a) {
const match = groupMatch || a.textContent.toLowerCase().includes(q);
a.style.display = match ? '' : 'none';
if (match) anyLinkMatch = true;
});
groupEl.style.display = (groupMatch || anyLinkMatch) ? '' : 'none';
});
});
})();
</script>
{% block scripts %}{% endblock %}
</body>
</html>