HH/templates/emails/px_digest_weekly.html
2026-04-08 17:13:35 +03:00

191 lines
9.5 KiB
HTML

{% load i18n %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PX360 {{ period_label }} Digest</title>
<style>
body { margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #f1f5f9; }
.wrapper { width: 100%; padding: 20px; }
.container { max-width: 640px; margin: 0 auto; background: #ffffff; border-radius: 12px; overflow: hidden; }
.header { background: linear-gradient(135deg, #005696, #007bbd); color: #ffffff; padding: 32px 24px; text-align: center; }
.header h1 { margin: 0 0 8px; font-size: 24px; font-weight: 700; }
.header p { margin: 0; font-size: 14px; opacity: 0.9; }
.content { padding: 24px; }
.kpi-grid { display: table; width: 100%; margin-bottom: 24px; }
.kpi-row { display: table-row; }
.kpi-card { display: table-cell; width: 33%; padding: 12px; text-align: center; vertical-align: top; }
.kpi-value { font-size: 28px; font-weight: 800; color: #1e293b; }
.kpi-label { font-size: 11px; font-weight: 600; color: #64748b; text-transform: uppercase; letter-spacing: 0.5px; }
.section { margin-bottom: 24px; padding-bottom: 24px; border-bottom: 1px solid #e2e8f0; }
.section:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.section h2 { font-size: 18px; font-weight: 700; color: #005696; margin: 0 0 12px; }
.section p { font-size: 14px; color: #475569; line-height: 1.6; margin: 0 0 8px; }
.badge { display: inline-block; padding: 4px 12px; border-radius: 9999px; font-size: 12px; font-weight: 600; }
.badge-green { background: #eef6fb; color: #005696; }
.badge-orange { background: #eef6fb; color: #005696; }
.badge-red { background: #eef6fb; color: #005696; }
.finding { font-size: 13px; color: #475569; padding: 6px 0; }
.finding::before { content: "✓ "; color: #005696; font-weight: bold; }
.recommendation { font-size: 13px; color: #475569; padding: 6px 12px; background: #f8fafc; border-radius: 6px; margin: 4px 0; border-left: 3px solid #005696; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { background: #f8fafc; padding: 8px 12px; text-align: left; font-size: 11px; font-weight: 700; color: #64748b; text-transform: uppercase; }
table.data td { padding: 8px 12px; border-bottom: 1px solid #e2e8f0; color: #1e293b; }
.footer { background: #f8fafc; padding: 16px 24px; text-align: center; font-size: 12px; color: #94a3b8; }
.footer a { color: #005696; text-decoration: none; }
</style>
</head>
<body>
<div class="wrapper">
<div class="container">
<!-- Header -->
<div class="header">
<h1>PX360 {% if period == 'weekly' %}Weekly{% else %}Monthly{% endif %} Digest</h1>
<p>{{ period_label }}</p>
{% if hospital_name %}<p style="margin-top:4px;">{{ hospital_name }}</p>{% endif %}
</div>
<div class="content">
<!-- AI Executive Summary -->
{% if summary %}
<div class="section">
<h2>🤖 AI Executive Summary</h2>
<p>{{ summary.summary_en }}</p>
{% if summary.key_findings_en %}
<div style="margin-top: 12px;">
{% for f in summary.key_findings_en %}
<div class="finding">{{ f }}</div>
{% endfor %}
</div>
{% endif %}
{% if summary.risk_level %}
<div style="margin-top: 12px;">
<span class="badge {% if summary.risk_level == 'high' %}badge-red{% elif summary.risk_level == 'medium' %}badge-orange{% else %}badge-green{% endif %}">
{{ summary.risk_level|title }} Risk
</span>
</div>
{% endif %}
</div>
{% endif %}
<!-- Key Metrics -->
<div class="section">
<h2>📊 Key Metrics</h2>
<table class="kpi-grid">
<tr class="kpi-row">
<td class="kpi-card">
<div class="kpi-value">{{ metrics.total_complaints|default:"—" }}</div>
<div class="kpi-label">Complaints</div>
</td>
<td class="kpi-card">
<div class="kpi-value">{{ metrics.sla_compliance|default:"—" }}%</div>
<div class="kpi-label">SLA Compliance</div>
</td>
<td class="kpi-card">
<div class="kpi-value">{{ metrics.nps_score|default:"—" }}</div>
<div class="kpi-label">NPS Score</div>
</td>
</tr>
<tr class="kpi-row">
<td class="kpi-card">
<div class="kpi-value">{{ metrics.avg_survey_score|default:"—" }}</div>
<div class="kpi-label">Avg Survey</div>
</td>
<td class="kpi-card">
<div class="kpi-value">{{ metrics.total_actions|default:"—" }}</div>
<div class="kpi-label">Actions</div>
</td>
<td class="kpi-card">
<div class="kpi-value">{{ metrics.avg_resolution_hours|default:"—" }}h</div>
<div class="kpi-label">Avg Resolution</div>
</td>
</tr>
</table>
</div>
<!-- Early Warnings -->
{% if early_warnings %}
<div class="section">
<h2>⚠️ Early Warning Alerts</h2>
<table class="data">
<thead>
<tr>
<th>Department</th>
<th>Risk</th>
<th>Level</th>
<th>Signals</th>
</tr>
</thead>
<tbody>
{% for dept in early_warnings %}
<tr>
<td>{{ dept.department_name }}</td>
<td>{{ dept.risk_score }}%</td>
<td>
{% if dept.risk_level == 'critical' %}🔴 Critical
{% elif dept.risk_level == 'high' %}🟠 High
{% elif dept.risk_level == 'medium' %}🟡 Medium
{% else %}🟢 Low{% endif %}
</td>
<td>{{ dept.active_signals }}/5</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
<!-- AI Recommendations -->
{% if recommendations %}
<div class="section">
<h2>💡 AI Recommendations</h2>
{% for rec in recommendations %}
<div style="margin-bottom: 12px;">
<strong style="font-size: 14px; color: #1e293b;">
{% if rec.priority == 'critical' %}🔴{% elif rec.priority == 'high' %}🟠{% elif rec.priority == 'medium' %}🟡{% else %}🟢{% endif %}
{{ rec.category }}
<span style="font-weight: 400; color: #64748b;">({{ rec.complaint_count }} complaints)</span>
</strong>
<p style="font-size: 13px; margin: 4px 0;">{{ rec.problem_summary_en }}</p>
{% if rec.recommended_actions_en %}
{% for action in rec.recommended_actions_en %}
<div class="recommendation">→ {{ action }}</div>
{% endfor %}
{% endif %}
</div>
{% endfor %}
</div>
{% endif %}
<!-- Arabic Summary -->
{% if summary and summary.summary_ar %}
<div class="section" dir="rtl" style="text-align: right;">
<h2>الملخص العربي</h2>
<p style="font-family: 'Segoe UI', Tahoma, Arial, sans-serif;">{{ summary.summary_ar }}</p>
{% if summary.key_findings_ar %}
<div style="margin-top: 12px;">
{% for f in summary.key_findings_ar %}
<div class="finding">{{ f }}</div>
{% endfor %}
</div>
{% endif %}
</div>
{% endif %}
</div>
<!-- Footer -->
<div class="footer">
<p>This report was automatically generated by PX360 — Patient Experience Analytics Platform</p>
<p>
<a href="{{ dashboard_url }}">View Full Dashboard</a> &middot;
<a href="{{ command_center_url }}">Command Center</a>
</p>
<p style="margin-top: 8px;">&copy; {% now "Y" %} Al Hammadi Hospital. All rights reserved.</p>
<p style="margin-top: 4px; font-size: 11px; color: #999;">Powered by <a href="https://tenhal.sa" style="color: #005696;">tenhal.sa</a></p>
</div>
</div>
</div>
</body>
</html>