2025-08-12 13:33:25 +03:00

236 lines
14 KiB
HTML

{% extends "base.html" %}
{% load static %}
{% block title %}Incident Reports - {{ block.super }}{% endblock %}
{% block content %}
<div class="container-fluid">
<!-- Page Header -->
<div class="row mb-4">
<div class="col-12">
<div class="d-flex justify-content-between align-items-center">
<div>
<h2><i class="fas fa-exclamation-triangle me-2"></i>Incident Reports</h2>
<p class="text-muted">Track and manage patient safety incidents and adverse events</p>
</div>
<div>
<a href="{% url 'quality:dashboard' %}" class="btn btn-outline-secondary">
<i class="fas fa-arrow-left me-2"></i>Back to Dashboard
</a>
</div>
</div>
</div>
</div>
<!-- Filters -->
<div class="row mb-4">
<div class="col-12">
<div class="card">
<div class="card-body">
<form method="get" class="row g-3">
<div class="col-md-3">
<label for="type" class="form-label">Incident Type</label>
<select name="type" id="type" class="form-select">
<option value="">All Types</option>
{% for value, label in incident_types %}
<option value="{{ value }}" {% if incident_type == value %}selected{% endif %}>{{ label }}</option>
{% endfor %}
</select>
</div>
<div class="col-md-2">
<label for="severity" class="form-label">Severity</label>
<select name="severity" id="severity" class="form-select">
<option value="">All Severities</option>
{% for value, label in severities %}
<option value="{{ value }}" {% if severity == value %}selected{% endif %}>{{ label }}</option>
{% endfor %}
</select>
</div>
<div class="col-md-2">
<label for="status" class="form-label">Status</label>
<select name="status" id="status" class="form-select">
<option value="">All Statuses</option>
{% for value, label in statuses %}
<option value="{{ value }}" {% if status == value %}selected{% endif %}>{{ label }}</option>
{% endfor %}
</select>
</div>
<div class="col-md-4">
<label for="search" class="form-label">Search</label>
<input type="text" name="search" id="search" class="form-control"
value="{{ search }}" placeholder="Search incidents...">
</div>
<div class="col-md-1">
<label class="form-label">&nbsp;</label>
<button type="submit" class="btn btn-primary w-100">
<i class="fas fa-search"></i>
</button>
</div>
</form>
</div>
</div>
</div>
</div>
<!-- Incidents List -->
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-header">
<h5 class="card-title mb-0">
<i class="fas fa-list me-2"></i>Incident Reports
<span class="badge bg-primary ms-2">{{ page_obj.paginator.count }}</span>
</h5>
</div>
<div class="card-body">
{% if page_obj %}
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th>Incident #</th>
<th>Title</th>
<th>Type</th>
<th>Severity</th>
<th>Patient</th>
<th>Location</th>
<th>Status</th>
<th>Assigned To</th>
<th>Date</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for incident in page_obj %}
<tr>
<td>
<strong class="text-primary">{{ incident.incident_number }}</strong>
</td>
<td>
<strong>{{ incident.title }}</strong><br>
<small class="text-muted">{{ incident.description|truncatechars:50 }}</small>
</td>
<td>
<span class="badge bg-info">{{ incident.get_incident_type_display }}</span>
</td>
<td>
{% if incident.severity == 'NO_HARM' %}
<span class="badge bg-success">{{ incident.get_severity_display }}</span>
{% elif incident.severity == 'MINOR_HARM' %}
<span class="badge bg-warning">{{ incident.get_severity_display }}</span>
{% elif incident.severity == 'MODERATE_HARM' %}
<span class="badge bg-warning">{{ incident.get_severity_display }}</span>
{% elif incident.severity == 'SEVERE_HARM' %}
<span class="badge bg-danger">{{ incident.get_severity_display }}</span>
{% elif incident.severity == 'DEATH' %}
<span class="badge bg-dark">{{ incident.get_severity_display }}</span>
{% else %}
<span class="badge bg-secondary">{{ incident.get_severity_display }}</span>
{% endif %}
</td>
<td>
{% if incident.patient %}
<strong>{{ incident.patient.get_full_name }}</strong><br>
<small class="text-muted">{{ incident.patient.patient_id }}</small>
{% else %}
<span class="text-muted">No patient</span>
{% endif %}
</td>
<td>
{% if incident.location %}
{{ incident.location }}
{% else %}
<span class="text-muted">Not specified</span>
{% endif %}
</td>
<td>
{% if incident.status == 'REPORTED' %}
<span class="badge bg-primary">{{ incident.get_status_display }}</span>
{% elif incident.status == 'UNDER_INVESTIGATION' %}
<span class="badge bg-warning">{{ incident.get_status_display }}</span>
{% elif incident.status == 'RESOLVED' %}
<span class="badge bg-success">{{ incident.get_status_display }}</span>
{% elif incident.status == 'CLOSED' %}
<span class="badge bg-secondary">{{ incident.get_status_display }}</span>
{% else %}
<span class="badge bg-secondary">{{ incident.get_status_display }}</span>
{% endif %}
</td>
<td>
{% if incident.assigned_to %}
<strong>{{ incident.assigned_to.get_full_name }}</strong>
{% else %}
<span class="text-muted">Unassigned</span>
{% endif %}
</td>
<td>
{{ incident.incident_date|date:"M d, Y" }}<br>
<small class="text-muted">{{ incident.incident_time|time:"H:i" }}</small>
</td>
<td>
<div class="btn-group btn-group-sm" role="group">
<button type="button" class="btn btn-outline-primary" title="View Details">
<i class="fas fa-eye"></i>
</button>
<button type="button" class="btn btn-outline-warning" title="Assign">
<i class="fas fa-user-plus"></i>
</button>
<button type="button" class="btn btn-outline-secondary" title="Edit">
<i class="fas fa-edit"></i>
</button>
</div>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<!-- Pagination -->
{% if page_obj.has_other_pages %}
<nav aria-label="Incidents pagination">
<ul class="pagination justify-content-center">
{% if page_obj.has_previous %}
<li class="page-item">
<a class="page-link" href="?page=1{% if search %}&search={{ search }}{% endif %}{% if incident_type %}&type={{ incident_type }}{% endif %}{% if severity %}&severity={{ severity }}{% endif %}{% if status %}&status={{ status }}{% endif %}">First</a>
</li>
<li class="page-item">
<a class="page-link" href="?page={{ page_obj.previous_page_number }}{% if search %}&search={{ search }}{% endif %}{% if incident_type %}&type={{ incident_type }}{% endif %}{% if severity %}&severity={{ severity }}{% endif %}{% if status %}&status={{ status }}{% endif %}">Previous</a>
</li>
{% endif %}
<li class="page-item active">
<span class="page-link">
Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }}
</span>
</li>
{% if page_obj.has_next %}
<li class="page-item">
<a class="page-link" href="?page={{ page_obj.next_page_number }}{% if search %}&search={{ search }}{% endif %}{% if incident_type %}&type={{ incident_type }}{% endif %}{% if severity %}&severity={{ severity }}{% endif %}{% if status %}&status={{ status }}{% endif %}">Next</a>
</li>
<li class="page-item">
<a class="page-link" href="?page={{ page_obj.paginator.num_pages }}{% if search %}&search={{ search }}{% endif %}{% if incident_type %}&type={{ incident_type }}{% endif %}{% if severity %}&severity={{ severity }}{% endif %}{% if status %}&status={{ status }}{% endif %}">Last</a>
</li>
{% endif %}
</ul>
</nav>
{% endif %}
{% else %}
<div class="text-center py-5">
<i class="fas fa-exclamation-triangle fa-3x text-muted mb-3"></i>
<h5 class="text-muted">No Incident Reports Found</h5>
<p class="text-muted">No incident reports match your current filters.</p>
<a href="{% url 'quality:incident_list' %}" class="btn btn-outline-primary">
Clear Filters
</a>
</div>
{% endif %}
</div>
</div>
</div>
</div>
</div>
{% endblock %}