378 lines
21 KiB
HTML
378 lines
21 KiB
HTML
{% extends 'layouts/base.html' %}
|
|
{% load i18n %}
|
|
|
|
{% block title %}{% trans "Complaints Registry" %} - PX360{% endblock %}
|
|
|
|
{% block extra_css %}
|
|
<style>
|
|
.status-resolved { background-color: #dcfce7; color: #166534; }
|
|
.status-pending { background-color: #fef9c3; color: #854d0e; }
|
|
.status-investigation { background-color: #e0f2fe; color: #075985; }
|
|
.status-escalated { background-color: #fee2e2; color: #991b1b; }
|
|
.filter-btn.active { background-color: #005696; color: white; }
|
|
.filter-btn:not(.active) { background-color: transparent; border: 1px solid #e2e8f0; color: #64748b; }
|
|
.filter-btn:not(.active):hover { background-color: #f8fafc; }
|
|
</style>
|
|
{% endblock %}
|
|
|
|
{% block content %}
|
|
<!-- Header -->
|
|
<header class="mb-6">
|
|
<div class="flex justify-between items-start">
|
|
<div>
|
|
<h1 class="text-2xl font-bold text-navy">{% trans "Complaints Registry" %}</h1>
|
|
<p class="text-sm text-slate mt-1">{% trans "Manage and monitor patient feedback in real-time" %}</p>
|
|
</div>
|
|
<div class="flex items-center gap-3">
|
|
<div class="relative group">
|
|
<i data-lucide="search" class="w-4 h-4 absolute left-3 top-1/2 -translate-y-1/2 text-slate group-focus-within:text-navy"></i>
|
|
<input type="text" id="searchInput" placeholder="{% trans 'Search ID, Name or Dept...' %}"
|
|
class="pl-10 pr-4 py-2.5 bg-slate-100 border-transparent border focus:border-navy/30 focus:bg-white rounded-xl text-sm outline-none w-64 transition-all">
|
|
</div>
|
|
{% if user.is_px_admin or user.is_hospital_admin %}
|
|
<a href="{% url 'complaints:complaint_create' %}" class="bg-navy text-white px-5 py-2.5 rounded-xl text-sm font-bold shadow-lg shadow-navy/20 hover:bg-blue flex items-center gap-2 transition">
|
|
<i data-lucide="plus" class="w-4 h-4"></i> {% trans "New Case" %}
|
|
</a>
|
|
<a href="{% url 'core:public_submit_landing' %}" class="bg-white text-navy border-2 border-navy/30 px-5 py-2.5 rounded-xl text-sm font-bold hover:bg-navy hover:text-white flex items-center gap-2 transition" target="_blank">
|
|
<i data-lucide="external-link" class="w-4 h-4"></i> {% trans "Public Form" %}
|
|
</a>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
</header>
|
|
|
|
<!-- Statistics Cards -->
|
|
<div class="grid grid-cols-4 gap-6 mb-6">
|
|
<div class="bg-white p-4 rounded-2xl border shadow-sm flex items-center gap-4">
|
|
<div class="p-3 bg-blue/10 rounded-xl">
|
|
<i data-lucide="layers" class="text-blue w-5 h-5"></i>
|
|
</div>
|
|
<div>
|
|
<p class="text-[10px] font-bold text-slate uppercase tracking-wider">{% trans "Total Received" %}</p>
|
|
<p class="text-xl font-black text-navy leading-tight">{{ stats.total }}</p>
|
|
</div>
|
|
</div>
|
|
<div class="bg-white p-4 rounded-2xl border shadow-sm flex items-center gap-4">
|
|
<div class="p-3 bg-green-50 rounded-xl">
|
|
<i data-lucide="check-circle" class="text-green-600 w-5 h-5"></i>
|
|
</div>
|
|
<div>
|
|
<p class="text-[10px] font-bold text-slate uppercase tracking-wider">{% trans "Resolved" %}</p>
|
|
<p class="text-xl font-black text-navy leading-tight">{{ stats.resolved }} <span class="text-xs text-green-600">({{ stats.resolved_percentage|floatformat:1 }}%)</span></p>
|
|
</div>
|
|
</div>
|
|
<div class="bg-white p-4 rounded-2xl border shadow-sm flex items-center gap-4">
|
|
<div class="p-3 bg-yellow-50 rounded-xl">
|
|
<i data-lucide="clock" class="text-yellow-600 w-5 h-5"></i>
|
|
</div>
|
|
<div>
|
|
<p class="text-[10px] font-bold text-slate uppercase tracking-wider">{% trans "Pending" %}</p>
|
|
<p class="text-xl font-black text-navy leading-tight">{{ stats.pending }}</p>
|
|
</div>
|
|
</div>
|
|
<div class="bg-white p-4 rounded-2xl border shadow-sm flex items-center gap-4">
|
|
<div class="p-3 bg-red-50 rounded-xl">
|
|
<i data-lucide="alert-triangle" class="text-red-500 w-5 h-5"></i>
|
|
</div>
|
|
<div>
|
|
<p class="text-[10px] font-bold text-slate uppercase tracking-wider">{% trans "TAT Alert" %}</p>
|
|
<p class="text-xl font-black text-navy leading-tight">{{ stats.overdue }} <span class="text-[10px] font-normal text-slate">{% trans "Over 72h" %}</span></p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Filter Tabs -->
|
|
<div class="bg-white px-6 py-4 rounded-t-2xl border-b flex items-center justify-between">
|
|
<div class="flex items-center gap-3">
|
|
<a href="?" class="filter-btn px-4 py-1.5 rounded-full text-xs font-semibold transition {% if not status_filter %}active{% endif %}">
|
|
{% trans "All Cases" %}
|
|
</a>
|
|
<a href="?status=open" class="filter-btn px-4 py-1.5 rounded-full text-xs font-semibold transition {% if status_filter == 'open' %}active{% endif %}">
|
|
{% trans "Pending" %}
|
|
</a>
|
|
<a href="?status=escalated" class="filter-btn px-4 py-1.5 rounded-full text-xs font-semibold transition {% if status_filter == 'escalated' %}active{% endif %}">
|
|
{% trans "Escalated" %}
|
|
</a>
|
|
<a href="?status=resolved" class="filter-btn px-4 py-1.5 rounded-full text-xs font-semibold transition {% if status_filter == 'resolved' %}active{% endif %}">
|
|
{% trans "Resolved" %}
|
|
</a>
|
|
<div class="h-4 w-[1px] bg-slate-200 mx-2"></div>
|
|
<button onclick="toggleFilters()" class="flex items-center gap-2 text-xs font-bold text-blue uppercase tracking-tight hover:underline">
|
|
<i data-lucide="filter" class="w-3 h-3"></i> {% trans "Advanced Filters" %}
|
|
</button>
|
|
</div>
|
|
<p class="text-[10px] font-bold text-slate uppercase">
|
|
{% trans "Showing:" %} <span class="text-navy">{{ complaints.start_index|default:0 }}-{{ complaints.end_index|default:0 }} {% trans "of" %} {{ complaints.paginator.count|default:0 }}</span>
|
|
</p>
|
|
</div>
|
|
|
|
<!-- Advanced Filters (Hidden by default) -->
|
|
<div id="advancedFilters" class="hidden bg-slate-50 px-6 py-4 border-b">
|
|
<form method="get" class="flex flex-wrap gap-4">
|
|
{% if status_filter %}
|
|
<input type="hidden" name="status" value="{{ status_filter }}">
|
|
{% endif %}
|
|
<div class="flex items-center gap-2">
|
|
<label class="text-xs font-bold text-slate uppercase">{% trans "Priority" %}</label>
|
|
<select name="priority" class="px-3 py-1.5 bg-white border rounded-lg text-xs">
|
|
<option value="">{% trans "All" %}</option>
|
|
<option value="low" {% if priority_filter == 'low' %}selected{% endif %}>{% trans "Low" %}</option>
|
|
<option value="medium" {% if priority_filter == 'medium' %}selected{% endif %}>{% trans "Medium" %}</option>
|
|
<option value="high" {% if priority_filter == 'high' %}selected{% endif %}>{% trans "High" %}</option>
|
|
<option value="critical" {% if priority_filter == 'critical' %}selected{% endif %}>{% trans "Critical" %}</option>
|
|
</select>
|
|
</div>
|
|
<div class="flex items-center gap-2">
|
|
<label class="text-xs font-bold text-slate uppercase">{% trans "Department" %}</label>
|
|
<select name="department" class="px-3 py-1.5 bg-white border rounded-lg text-xs">
|
|
<option value="">{% trans "All" %}</option>
|
|
{% for dept in departments %}
|
|
<option value="{{ dept.id }}" {% if department_filter == dept.id|stringformat:'s' %}selected{% endif %}>{{ dept.name }}</option>
|
|
{% endfor %}
|
|
</select>
|
|
</div>
|
|
<button type="submit" class="px-4 py-1.5 bg-navy text-white rounded-lg text-xs font-bold">{% trans "Apply" %}</button>
|
|
<a href="?" class="px-4 py-1.5 border rounded-lg text-xs font-semibold text-slate hover:bg-white">{% trans "Clear" %}</a>
|
|
</form>
|
|
</div>
|
|
|
|
<!-- Complaints Table -->
|
|
<div class="bg-white rounded-b-2xl shadow-sm border overflow-hidden">
|
|
<table class="w-full text-left border-collapse">
|
|
<thead class="bg-slate-50 border-b uppercase text-[10px] font-bold text-slate tracking-wider">
|
|
<tr>
|
|
<th class="px-6 py-4">{% trans "Complaint ID" %}</th>
|
|
<th class="px-6 py-4">{% trans "Patient Name" %}</th>
|
|
<th class="px-6 py-4">{% trans "Description" %}</th>
|
|
<th class="px-6 py-4">{% trans "Source" %}</th>
|
|
<th class="px-6 py-4">{% trans "Department" %}</th>
|
|
<th class="px-6 py-4">{% trans "Status" %}</th>
|
|
<th class="px-6 py-4 text-center">{% trans "Priority" %}</th>
|
|
<th class="px-6 py-4 text-right">{% trans "Actions" %}</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="text-sm divide-y divide-slate-100">
|
|
{% for complaint in complaints.object_list %}
|
|
<tr class="hover:bg-light/30 transition-colors cursor-pointer group" onclick="window.location.href='{% url 'complaints:complaint_detail' complaint.pk %}'">
|
|
<td class="px-6 py-4 font-bold text-navy">{{ complaint.reference_number }}</td>
|
|
<td class="px-6 py-4">
|
|
<div class="font-semibold text-slate-800">{{ complaint.patient.get_full_name|default:complaint.contact_name }}</div>
|
|
{% if complaint.patient %}
|
|
<div class="text-[10px] text-slate font-medium">{% trans "MRN:" %} {{ complaint.patient.mrn|default:"-" }}</div>
|
|
{% endif %}
|
|
</td>
|
|
<td class="px-6 py-4 max-w-xs" onclick="event.stopPropagation()">
|
|
<button onclick="showDescriptionModal('{{ complaint.reference_number|escapejs }}', `{{ complaint.description|escapejs }}`)"
|
|
class="text-slate-600 text-xs truncate text-left hover:text-navy hover:underline cursor-pointer flex items-center gap-1">
|
|
{{ complaint.description|truncatewords:10 }}
|
|
<i data-lucide="expand" class="w-3 h-3 flex-shrink-0 opacity-50"></i>
|
|
</button>
|
|
</td>
|
|
<td class="px-6 py-4">
|
|
{% if complaint.source %}
|
|
<span class="bg-slate-100 px-2 py-0.5 rounded text-[10px] font-bold text-slate-600">{{ complaint.source.name_en }}</span>
|
|
{% else %}
|
|
<span class="bg-slate-100 px-2 py-0.5 rounded text-[10px] font-bold text-slate-600">{{ complaint.get_complaint_source_type_display }}</span>
|
|
{% endif %}
|
|
</td>
|
|
<td class="px-6 py-4 text-slate-600">{{ complaint.department.name|default:"-" }}</td>
|
|
<td class="px-6 py-4">
|
|
{% if complaint.status == 'open' %}
|
|
<span class="status-pending px-2.5 py-1 rounded-full text-[10px] font-bold uppercase">{{ complaint.get_status_display }}</span>
|
|
{% elif complaint.status == 'in_progress' %}
|
|
<span class="status-investigation px-2.5 py-1 rounded-full text-[10px] font-bold uppercase">{% trans "Investigating" %}</span>
|
|
{% elif complaint.status == 'escalated' %}
|
|
<span class="status-escalated px-2.5 py-1 rounded-full text-[10px] font-bold uppercase">{{ complaint.get_status_display }}</span>
|
|
{% elif complaint.status == 'resolved' or complaint.status == 'closed' %}
|
|
<span class="status-resolved px-2.5 py-1 rounded-full text-[10px] font-bold uppercase">{{ complaint.get_status_display }}</span>
|
|
{% else %}
|
|
<span class="bg-slate-100 px-2.5 py-1 rounded-full text-[10px] font-bold uppercase text-slate-600">{{ complaint.get_status_display }}</span>
|
|
{% endif %}
|
|
</td>
|
|
<td class="px-6 py-4">
|
|
<div class="flex justify-center">
|
|
{% if complaint.priority == 'critical' %}
|
|
<span class="w-2 h-2 rounded-full bg-red-500 animate-pulse" title="{% trans 'Critical' %}"></span>
|
|
{% elif complaint.priority == 'high' %}
|
|
<span class="w-2 h-2 rounded-full bg-red-500" title="{% trans 'High' %}"></span>
|
|
{% elif complaint.priority == 'medium' %}
|
|
<span class="w-2 h-2 rounded-full bg-orange-500" title="{% trans 'Medium' %}"></span>
|
|
{% else %}
|
|
<span class="w-2 h-2 rounded-full bg-green-500" title="{% trans 'Low' %}"></span>
|
|
{% endif %}
|
|
</div>
|
|
</td>
|
|
<td class="px-6 py-4 text-right">
|
|
<div class="flex justify-end gap-2 opacity-0 group-hover:opacity-100 transition-opacity">
|
|
<a href="{% url 'complaints:complaint_detail' complaint.pk %}" class="p-1.5 text-navy hover:bg-white rounded border border-transparent hover:border-slate-200" title="{% trans 'View' %}">
|
|
<i data-lucide="eye" class="w-4 h-4"></i>
|
|
</a>
|
|
{% if can_edit %}
|
|
<a href="{% url 'complaints:complaint_assign' complaint.pk %}" class="p-1.5 text-blue hover:bg-white rounded border border-transparent hover:border-slate-200" title="{% trans 'Assign' %}">
|
|
<i data-lucide="user-plus" class="w-4 h-4"></i>
|
|
</a>
|
|
{% endif %}
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
{% empty %}
|
|
<tr>
|
|
<td colspan="8" class="px-6 py-12 text-center">
|
|
<i data-lucide="inbox" class="w-12 h-12 mx-auto text-slate-300 mb-3"></i>
|
|
<p class="text-slate">{% trans "No complaints found" %}</p>
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
|
|
<!-- Pagination -->
|
|
{% if complaints.has_other_pages %}
|
|
<div class="bg-slate-50 px-8 py-4 flex items-center justify-between border-t">
|
|
<div class="flex items-center gap-4">
|
|
<span class="text-xs text-slate font-medium">
|
|
{% trans "Showing" %} <span class="font-bold text-navy">{{ complaints.start_index }}-{{ complaints.end_index }}</span> {% trans "of" %} <span class="font-bold text-navy">{{ complaints.paginator.count }}</span> {% trans "entries" %}
|
|
</span>
|
|
<!-- Page Size Selector -->
|
|
<form method="get" class="flex items-center gap-2" id="pageSizeForm">
|
|
{% for key, value in request.GET.items %}
|
|
{% if key != 'page_size' and key != 'page' %}
|
|
<input type="hidden" name="{{ key }}" value="{{ value }}">
|
|
{% endif %}
|
|
{% endfor %}
|
|
<label class="text-xs text-slate">{% trans "Show" %}</label>
|
|
<select name="page_size" onchange="document.getElementById('pageSizeForm').submit()" class="px-2 py-1 bg-white border border-slate-200 rounded-lg text-xs focus:outline-none focus:ring-2 focus:ring-navy">
|
|
<option value="10" {% if complaints.paginator.per_page == 10 %}selected{% endif %}>10</option>
|
|
<option value="25" {% if complaints.paginator.per_page == 25 %}selected{% endif %}>25</option>
|
|
<option value="50" {% if complaints.paginator.per_page == 50 %}selected{% endif %}>50</option>
|
|
<option value="100" {% if complaints.paginator.per_page == 100 %}selected{% endif %}>100</option>
|
|
</select>
|
|
</form>
|
|
</div>
|
|
<div class="flex gap-2">
|
|
{% if complaints.has_previous %}
|
|
<a href="?page={{ complaints.previous_page_number }}{% for key, value in request.GET.items %}{% if key != 'page' %}&{{ key }}={{ value }}{% endif %}{% endfor %}"
|
|
class="w-8 h-8 flex items-center justify-center rounded-lg border bg-white hover:bg-slate-50 transition">
|
|
<i data-lucide="chevron-left" class="w-4 h-4 text-slate"></i>
|
|
</a>
|
|
{% else %}
|
|
<span class="w-8 h-8 flex items-center justify-center rounded-lg border bg-slate-100 text-slate-300 cursor-not-allowed">
|
|
<i data-lucide="chevron-left" class="w-4 h-4"></i>
|
|
</span>
|
|
{% endif %}
|
|
|
|
{% for num in complaints.paginator.page_range %}
|
|
{% if num == complaints.number %}
|
|
<span class="w-8 h-8 flex items-center justify-center rounded-lg bg-navy text-white text-xs font-bold">{{ num }}</span>
|
|
{% elif num > complaints.number|add:'-3' and num < complaints.number|add:'3' %}
|
|
<a href="?page={{ num }}{% for key, value in request.GET.items %}{% if key != 'page' %}&{{ key }}={{ value }}{% endif %}{% endfor %}"
|
|
class="w-8 h-8 flex items-center justify-center rounded-lg border bg-white hover:bg-slate-50 text-xs font-bold text-slate transition">
|
|
{{ num }}
|
|
</a>
|
|
{% elif num == 1 or num == complaints.paginator.num_pages %}
|
|
<a href="?page={{ num }}{% for key, value in request.GET.items %}{% if key != 'page' %}&{{ key }}={{ value }}{% endif %}{% endfor %}"
|
|
class="w-8 h-8 flex items-center justify-center rounded-lg border bg-white hover:bg-slate-50 text-xs font-bold text-slate transition">
|
|
{{ num }}
|
|
</a>
|
|
{% elif num == complaints.number|add:'-3' or num == complaints.number|add:'3' %}
|
|
<span class="w-8 h-8 flex items-center justify-center text-xs text-slate">...</span>
|
|
{% endif %}
|
|
{% endfor %}
|
|
|
|
{% if complaints.has_next %}
|
|
<a href="?page={{ complaints.next_page_number }}{% for key, value in request.GET.items %}{% if key != 'page' %}&{{ key }}={{ value }}{% endif %}{% endfor %}"
|
|
class="w-8 h-8 flex items-center justify-center rounded-lg border bg-white hover:bg-slate-50 transition">
|
|
<i data-lucide="chevron-right" class="w-4 h-4 text-slate"></i>
|
|
</a>
|
|
{% else %}
|
|
<span class="w-8 h-8 flex items-center justify-center rounded-lg border bg-slate-100 text-slate-300 cursor-not-allowed">
|
|
<i data-lucide="chevron-right" class="w-4 h-4"></i>
|
|
</span>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
|
|
<!-- Description Modal -->
|
|
<div id="descriptionModal" class="fixed inset-0 z-50 hidden items-center justify-center p-4" onclick="closeDescriptionModal(event)">
|
|
<div class="absolute inset-0 bg-black/50 backdrop-blur-sm"></div>
|
|
<div class="relative bg-white rounded-2xl shadow-2xl max-w-2xl w-full max-h-[80vh] overflow-hidden" onclick="event.stopPropagation()">
|
|
<div class="flex items-center justify-between px-6 py-4 border-b bg-slate-50">
|
|
<div class="flex items-center gap-3">
|
|
<div class="p-2 bg-navy/10 rounded-lg">
|
|
<i data-lucide="file-text" class="w-5 h-5 text-navy"></i>
|
|
</div>
|
|
<div>
|
|
<h3 class="font-bold text-navy">{% trans "Complaint Description" %}</h3>
|
|
<p id="modalReferenceNumber" class="text-xs text-slate font-mono"></p>
|
|
</div>
|
|
</div>
|
|
<button onclick="closeDescriptionModal()" class="p-2 hover:bg-slate-200 rounded-lg transition">
|
|
<i data-lucide="x" class="w-5 h-5 text-slate-500"></i>
|
|
</button>
|
|
</div>
|
|
<div class="p-6 overflow-y-auto max-h-[60vh]">
|
|
<p id="modalDescription" class="text-slate-700 text-sm leading-relaxed whitespace-pre-wrap"></p>
|
|
</div>
|
|
<div class="px-6 py-4 border-t bg-slate-50 flex justify-end">
|
|
<button onclick="closeDescriptionModal()" class="px-4 py-2 bg-navy text-white rounded-lg text-sm font-bold hover:bg-blue transition">
|
|
{% trans "Close" %}
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
function toggleFilters() {
|
|
const filters = document.getElementById('advancedFilters');
|
|
filters.classList.toggle('hidden');
|
|
}
|
|
|
|
// Description Modal Functions
|
|
function showDescriptionModal(referenceNumber, description) {
|
|
const modal = document.getElementById('descriptionModal');
|
|
const refNumber = document.getElementById('modalReferenceNumber');
|
|
const descEl = document.getElementById('modalDescription');
|
|
|
|
refNumber.textContent = referenceNumber;
|
|
descEl.textContent = description || '{% trans "No description available" %}';
|
|
|
|
modal.classList.remove('hidden');
|
|
modal.classList.add('flex');
|
|
document.body.style.overflow = 'hidden';
|
|
|
|
// Re-initialize lucide icons for the modal
|
|
if (typeof lucide !== 'undefined') {
|
|
lucide.createIcons();
|
|
}
|
|
}
|
|
|
|
function closeDescriptionModal(event) {
|
|
if (event && event.target !== event.currentTarget) return;
|
|
|
|
const modal = document.getElementById('descriptionModal');
|
|
modal.classList.add('hidden');
|
|
modal.classList.remove('flex');
|
|
document.body.style.overflow = '';
|
|
}
|
|
|
|
// Close modal on Escape key
|
|
document.addEventListener('keydown', function(e) {
|
|
if (e.key === 'Escape') {
|
|
closeDescriptionModal();
|
|
}
|
|
});
|
|
|
|
// Search functionality
|
|
document.getElementById('searchInput')?.addEventListener('keypress', function(e) {
|
|
if (e.key === 'Enter') {
|
|
const value = this.value;
|
|
if (value) {
|
|
window.location.href = '?search=' + encodeURIComponent(value);
|
|
}
|
|
}
|
|
});
|
|
</script>
|
|
{% endblock %}
|