449 lines
14 KiB
HTML
449 lines
14 KiB
HTML
{% extends 'base.html' %}
|
|
{% load static %}
|
|
|
|
{% block title %}Delete Waiting Queue - {{ queue.name }}{% endblock %}
|
|
|
|
{% block css %}
|
|
<style>
|
|
.delete-warning {
|
|
background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
|
|
color: white;
|
|
border-radius: 0.5rem;
|
|
padding: 2rem;
|
|
margin-bottom: 2rem;
|
|
}
|
|
|
|
.warning-icon {
|
|
width: 80px;
|
|
height: 80px;
|
|
border-radius: 50%;
|
|
background: rgba(255, 255, 255, 0.2);
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
margin: 0 auto 1.5rem;
|
|
font-size: 2rem;
|
|
}
|
|
|
|
.queue-info {
|
|
background: white;
|
|
border: 1px solid #dee2e6;
|
|
border-radius: 0.5rem;
|
|
padding: 1.5rem;
|
|
margin-bottom: 1.5rem;
|
|
}
|
|
|
|
.info-item {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
padding: 0.75rem 0;
|
|
border-bottom: 1px solid #f8f9fa;
|
|
}
|
|
|
|
.info-item:last-child {
|
|
border-bottom: none;
|
|
}
|
|
|
|
.info-label {
|
|
font-weight: 600;
|
|
color: #495057;
|
|
}
|
|
|
|
.info-value {
|
|
color: #6c757d;
|
|
}
|
|
|
|
.impact-warning {
|
|
background: #fff3cd;
|
|
border: 1px solid #ffeaa7;
|
|
border-radius: 0.375rem;
|
|
padding: 1rem;
|
|
margin-bottom: 1.5rem;
|
|
}
|
|
|
|
.impact-item {
|
|
display: flex;
|
|
align-items: center;
|
|
margin-bottom: 0.5rem;
|
|
}
|
|
|
|
.impact-item:last-child {
|
|
margin-bottom: 0;
|
|
}
|
|
|
|
.impact-icon {
|
|
color: #856404;
|
|
margin-right: 0.5rem;
|
|
}
|
|
|
|
.confirmation-section {
|
|
background: #f8f9fa;
|
|
border: 1px solid #dee2e6;
|
|
border-radius: 0.375rem;
|
|
padding: 1.5rem;
|
|
margin-bottom: 1.5rem;
|
|
}
|
|
|
|
.queue-type-badge {
|
|
padding: 0.25rem 0.75rem;
|
|
border-radius: 0.25rem;
|
|
font-size: 0.75rem;
|
|
font-weight: 600;
|
|
text-transform: uppercase;
|
|
}
|
|
|
|
.type-provider { background: #d4edda; color: #155724; }
|
|
.type-specialty { background: #d1ecf1; color: #0c5460; }
|
|
.type-location { background: #fff3cd; color: #856404; }
|
|
.type-procedure { background: #f8d7da; color: #721c24; }
|
|
.type-emergency { background: #f5c6cb; color: #721c24; }
|
|
|
|
.status-badge {
|
|
padding: 0.25rem 0.5rem;
|
|
border-radius: 0.25rem;
|
|
font-size: 0.75rem;
|
|
font-weight: 600;
|
|
}
|
|
|
|
.status-active { background: #d4edda; color: #155724; }
|
|
.status-inactive { background: #f8d7da; color: #721c24; }
|
|
|
|
@media (max-width: 768px) {
|
|
.delete-warning {
|
|
padding: 1.5rem;
|
|
}
|
|
|
|
.warning-icon {
|
|
width: 60px;
|
|
height: 60px;
|
|
font-size: 1.5rem;
|
|
}
|
|
|
|
.info-item {
|
|
flex-direction: column;
|
|
align-items: flex-start;
|
|
gap: 0.25rem;
|
|
}
|
|
}
|
|
</style>
|
|
{% endblock %}
|
|
|
|
{% block content %}
|
|
<div class="container">
|
|
<!-- Page Header -->
|
|
<div class="d-flex align-items-center mb-3">
|
|
<div>
|
|
<ol class="breadcrumb">
|
|
<li class="breadcrumb-item"><a href="{% url 'core:dashboard' %}">Dashboard</a></li>
|
|
<li class="breadcrumb-item"><a href="{% url 'appointments:dashboard' %}">Appointments</a></li>
|
|
<li class="breadcrumb-item"><a href="{% url 'appointments:waiting_queue_list' %}">Waiting Queues</a></li>
|
|
<li class="breadcrumb-item"><a href="{% url 'appointments:waiting_queue_detail' queue.pk %}">{{ queue.name }}</a></li>
|
|
<li class="breadcrumb-item active">Delete</li>
|
|
</ol>
|
|
<h1 class="page-header mb-0">
|
|
<i class="fas fa-trash me-2"></i>Delete Waiting Queue
|
|
</h1>
|
|
</div>
|
|
<div class="ms-auto">
|
|
<a href="{% url 'appointments:waiting_queue_detail' queue.pk %}" class="btn btn-outline-secondary">
|
|
<i class="fas fa-arrow-left me-1"></i>Back to Queue
|
|
</a>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Delete Warning -->
|
|
<div class="delete-warning text-center">
|
|
<div class="warning-icon">
|
|
<i class="fas fa-exclamation-triangle"></i>
|
|
</div>
|
|
<h3 class="mb-3">Are you sure you want to delete this waiting queue?</h3>
|
|
<p class="mb-0 opacity-75">
|
|
This action cannot be undone. All queue entries and associated data will be permanently removed.
|
|
</p>
|
|
</div>
|
|
|
|
<!-- Queue Information -->
|
|
<div class="queue-info">
|
|
<h5 class="mb-3">
|
|
<i class="fas fa-info-circle me-2"></i>Queue Information
|
|
</h5>
|
|
|
|
<div class="info-item">
|
|
<span class="info-label">Queue Name:</span>
|
|
<span class="info-value fw-bold">{{ queue.name }}</span>
|
|
</div>
|
|
|
|
<div class="info-item">
|
|
<span class="info-label">Queue Type:</span>
|
|
<span class="queue-type-badge type-{{ queue.queue_type|lower }}">
|
|
{{ queue.get_queue_type_display }}
|
|
</span>
|
|
</div>
|
|
|
|
<div class="info-item">
|
|
<span class="info-label">Status:</span>
|
|
<span class="status-badge status-{% if queue.is_active %}active{% else %}inactive{% endif %}">
|
|
{% if queue.is_active %}Active{% else %}Inactive{% endif %}
|
|
</span>
|
|
</div>
|
|
|
|
{% if queue.specialty %}
|
|
<div class="info-item">
|
|
<span class="info-label">Specialty:</span>
|
|
<span class="info-value">{{ queue.specialty }}</span>
|
|
</div>
|
|
{% endif %}
|
|
|
|
{% if queue.location %}
|
|
<div class="info-item">
|
|
<span class="info-label">Location:</span>
|
|
<span class="info-value">{{ queue.location }}</span>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<div class="info-item">
|
|
<span class="info-label">Current Queue Size:</span>
|
|
<span class="info-value">{{ queue.current_queue_size }} patients</span>
|
|
</div>
|
|
|
|
<div class="info-item">
|
|
<span class="info-label">Maximum Capacity:</span>
|
|
<span class="info-value">{{ queue.max_queue_size }} patients</span>
|
|
</div>
|
|
|
|
<div class="info-item">
|
|
<span class="info-label">Assigned Providers:</span>
|
|
<span class="info-value">{{ queue.providers.count }} provider{{ queue.providers.count|pluralize }}</span>
|
|
</div>
|
|
|
|
<div class="info-item">
|
|
<span class="info-label">Created:</span>
|
|
<span class="info-value">{{ queue.created_at|date:"M d, Y g:i A" }}</span>
|
|
</div>
|
|
|
|
<div class="info-item">
|
|
<span class="info-label">Last Updated:</span>
|
|
<span class="info-value">{{ queue.updated_at|date:"M d, Y g:i A" }}</span>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Impact Warning -->
|
|
{% if queue.current_queue_size > 0 or queue.providers.count > 0 %}
|
|
<div class="impact-warning">
|
|
<h6 class="mb-3">
|
|
<i class="fas fa-exclamation-triangle text-warning me-2"></i>
|
|
Deletion Impact
|
|
</h6>
|
|
|
|
{% if queue.current_queue_size > 0 %}
|
|
<div class="impact-item">
|
|
<i class="fas fa-users impact-icon"></i>
|
|
<span>{{ queue.current_queue_size }} patient{{ queue.current_queue_size|pluralize }} currently in queue will be removed</span>
|
|
</div>
|
|
{% endif %}
|
|
|
|
{% if queue.providers.count > 0 %}
|
|
<div class="impact-item">
|
|
<i class="fas fa-user-md impact-icon"></i>
|
|
<span>{{ queue.providers.count }} assigned provider{{ queue.providers.count|pluralize }} will be unassigned</span>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<div class="impact-item">
|
|
<i class="fas fa-chart-line impact-icon"></i>
|
|
<span>All historical queue data and statistics will be permanently lost</span>
|
|
</div>
|
|
|
|
<div class="impact-item">
|
|
<i class="fas fa-clock impact-icon"></i>
|
|
<span>Any scheduled queue operations will be cancelled</span>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<!-- Current Queue Entries -->
|
|
{% if queue_entries %}
|
|
<div class="card mb-4">
|
|
<div class="card-header">
|
|
<h6 class="mb-0">
|
|
<i class="fas fa-list me-2"></i>
|
|
Current Queue Entries ({{ queue_entries|length }})
|
|
</h6>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="table-responsive">
|
|
<table class="table table-sm">
|
|
<thead>
|
|
<tr>
|
|
<th>Position</th>
|
|
<th>Patient</th>
|
|
<th>Joined</th>
|
|
<th>Status</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for entry in queue_entries %}
|
|
<tr>
|
|
<td>
|
|
<span class="badge bg-primary">{{ entry.queue_position }}</span>
|
|
</td>
|
|
<td>
|
|
<div class="fw-bold">{{ entry.patient.get_full_name }}</div>
|
|
<small class="text-muted">ID: {{ entry.patient.patient_id }}</small>
|
|
</td>
|
|
<td>
|
|
<div>{{ entry.joined_at|time:"g:i A" }}</div>
|
|
<small class="text-muted">{{ entry.joined_at|timesince }} ago</small>
|
|
</td>
|
|
<td>
|
|
<span class="badge bg-warning">{{ entry.get_status_display }}</span>
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<!-- Confirmation Section -->
|
|
<div class="confirmation-section">
|
|
<h6 class="mb-3">
|
|
<i class="fas fa-check-circle me-2"></i>
|
|
Confirmation Required
|
|
</h6>
|
|
|
|
<div class="form-check mb-3">
|
|
<input class="form-check-input" type="checkbox" id="confirmUnderstand">
|
|
<label class="form-check-label" for="confirmUnderstand">
|
|
I understand that this action cannot be undone
|
|
</label>
|
|
</div>
|
|
|
|
<div class="form-check mb-3">
|
|
<input class="form-check-input" type="checkbox" id="confirmPatients">
|
|
<label class="form-check-label" for="confirmPatients">
|
|
I understand that all patients in the queue will be removed
|
|
</label>
|
|
</div>
|
|
|
|
<div class="form-check mb-3">
|
|
<input class="form-check-input" type="checkbox" id="confirmData">
|
|
<label class="form-check-label" for="confirmData">
|
|
I understand that all queue data and statistics will be permanently lost
|
|
</label>
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label for="confirmationText" class="form-label">
|
|
Type <strong>"{{ queue.name }}"</strong> to confirm deletion:
|
|
</label>
|
|
<input type="text" class="form-control" id="confirmationText"
|
|
placeholder="Enter queue name to confirm">
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Action Buttons -->
|
|
<div class="d-flex justify-content-between align-items-center">
|
|
<div>
|
|
<small class="text-muted">
|
|
<i class="fas fa-info-circle me-1"></i>
|
|
This action requires administrator privileges
|
|
</small>
|
|
</div>
|
|
<div>
|
|
<a href="{% url 'appointments:waiting_queue_detail' queue.pk %}" class="btn btn-outline-secondary me-2">
|
|
<i class="fas fa-times me-1"></i>Cancel
|
|
</a>
|
|
<form method="post" class="d-inline" id="deleteForm">
|
|
{% csrf_token %}
|
|
<button type="submit" class="btn btn-danger" id="deleteButton" disabled>
|
|
<i class="fas fa-trash me-1"></i>Delete Queue Permanently
|
|
</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endblock %}
|
|
|
|
{% block js %}
|
|
<script>
|
|
$(document).ready(function() {
|
|
const queueName = "{{ queue.name }}";
|
|
const $deleteButton = $('#deleteButton');
|
|
const $confirmUnderstand = $('#confirmUnderstand');
|
|
const $confirmPatients = $('#confirmPatients');
|
|
const $confirmData = $('#confirmData');
|
|
const $confirmationText = $('#confirmationText');
|
|
|
|
function checkConfirmation() {
|
|
const allChecked = $confirmUnderstand.is(':checked') &&
|
|
$confirmPatients.is(':checked') &&
|
|
$confirmData.is(':checked');
|
|
const textMatches = $confirmationText.val().trim() === queueName;
|
|
|
|
$deleteButton.prop('disabled', !(allChecked && textMatches));
|
|
}
|
|
|
|
// Check confirmation status on any change
|
|
$confirmUnderstand.on('change', checkConfirmation);
|
|
$confirmPatients.on('change', checkConfirmation);
|
|
$confirmData.on('change', checkConfirmation);
|
|
$confirmationText.on('input', checkConfirmation);
|
|
|
|
// Form submission confirmation
|
|
$('#deleteForm').on('submit', function(e) {
|
|
if (!$deleteButton.prop('disabled')) {
|
|
if (!confirm('Are you absolutely sure you want to delete this waiting queue? This action cannot be undone.')) {
|
|
e.preventDefault();
|
|
}
|
|
} else {
|
|
e.preventDefault();
|
|
showAlert('error', 'Please complete all confirmation requirements before deleting.');
|
|
}
|
|
});
|
|
|
|
// Prevent accidental navigation
|
|
{#let formSubmitted = false;#}
|
|
{#$('#deleteForm').on('submit', function() {#}
|
|
{# formSubmitted = true;#}
|
|
{# });#}
|
|
|
|
$(window).on('beforeunload', function(e) {
|
|
if (!formSubmitted && ($confirmUnderstand.is(':checked') ||
|
|
$confirmPatients.is(':checked') ||
|
|
$confirmData.is(':checked') ||
|
|
$confirmationText.val().trim())) {
|
|
const message = 'You have started the deletion process. Are you sure you want to leave?';
|
|
e.returnValue = message;
|
|
return message;
|
|
}
|
|
});
|
|
});
|
|
|
|
function showAlert(type, message) {
|
|
const alertClass = type === 'success' ? 'alert-success' : 'alert-danger';
|
|
const alertHtml = `
|
|
<div class="alert ${alertClass} alert-dismissible fade show" role="alert">
|
|
${message}
|
|
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
|
|
</div>
|
|
`;
|
|
|
|
// Remove existing alerts
|
|
$('.alert').remove();
|
|
|
|
// Add new alert at the top of content
|
|
$('#content').prepend(alertHtml);
|
|
|
|
// Auto-dismiss after 5 seconds
|
|
setTimeout(function() {
|
|
$('.alert').fadeOut();
|
|
}, 5000);
|
|
}
|
|
</script>
|
|
{% endblock %}
|
|
|