"""Render cross-marker interpretation patterns for the health report UI.""" from __future__ import annotations import html from src.interpretation import build_interpretation def patterns_html(tests: list[dict]) -> str: """Render ONLY the cross-marker patterns as an HTML block (empty string if none). Designed to sit alongside an existing per-marker report (e.g. the knowledge-graph health report) so it adds cross-marker reasoning — anemia picture, liver cluster, lipid risk — without duplicating per-marker interpretation. """ interp = build_interpretation(tests) if not interp.patterns: return "" def esc(value: object) -> str: return html.escape(str(value)) cards = "".join( '
' f'{esc(p.name)}
' f'{esc(p.note)}
' for p in interp.patterns ) return ( '
' '

Patterns across your markers

' '
' 'How several results may relate to one another — educational, not a diagnosis.
' f"{cards}" f'
{esc(interp.disclaimer)}
' "
" )