hospital-management/templates/laboratory/tests/lab_test_confirm_delete.html
2025-08-12 13:33:25 +03:00

355 lines
16 KiB
HTML

{% extends "base.html" %}
{% load static %}
{% block title %}Deactivate Lab Test - {{ lab_test.test_name }} - {{ block.super }}{% endblock %}
{% block content %}
<div class="container-fluid">
<!-- Page Header -->
<div class="d-flex justify-content-between align-items-center mb-4">
<div>
<h1 class="h3 mb-1 text-danger">
<i class="fas fa-exclamation-triangle me-2"></i>Deactivate Lab Test
</h1>
<nav aria-label="breadcrumb">
<ol class="breadcrumb mb-0">
<li class="breadcrumb-item"><a href="{% url 'core:dashboard' %}">Dashboard</a></li>
<li class="breadcrumb-item"><a href="{% url 'laboratory:dashboard' %}">Laboratory</a></li>
<li class="breadcrumb-item"><a href="{% url 'laboratory:lab_test_list' %}">Lab Tests</a></li>
<li class="breadcrumb-item"><a href="{% url 'laboratory:lab_test_detail' lab_test.pk %}">{{ lab_test.test_name }}</a></li>
<li class="breadcrumb-item active">Deactivate</li>
</ol>
</nav>
</div>
</div>
<div class="row justify-content-center">
<div class="col-lg-8">
<!-- Warning Card -->
<div class="card border-danger">
<div class="card-header bg-danger text-white">
<h5 class="mb-0">
<i class="fas fa-exclamation-triangle me-2"></i>Confirm Lab Test Deactivation
</h5>
</div>
<div class="card-body">
<div class="alert alert-danger">
<h6 class="alert-heading">
<i class="fas fa-info-circle me-2"></i>Important Information
</h6>
<p class="mb-0">
You are about to deactivate the lab test <strong>"{{ lab_test.test_name }}"</strong>.
This action will make the test unavailable for new orders but will preserve all historical data.
</p>
</div>
<!-- Test Information -->
<div class="row mb-4">
<div class="col-md-6">
<h6 class="fw-semibold text-muted mb-3">Test Details</h6>
<table class="table table-borderless table-sm">
<tr>
<td class="fw-semibold text-muted">Test Name:</td>
<td>{{ lab_test.test_name }}</td>
</tr>
<tr>
<td class="fw-semibold text-muted">Test Code:</td>
<td>{{ lab_test.test_code }}</td>
</tr>
<tr>
<td class="fw-semibold text-muted">Category:</td>
<td>{{ lab_test.get_category_display }}</td>
</tr>
<tr>
<td class="fw-semibold text-muted">Price:</td>
<td>${{ lab_test.price|floatformat:2 }}</td>
</tr>
<tr>
<td class="fw-semibold text-muted">Created:</td>
<td>{{ lab_test.created_at|date:"M d, Y" }}</td>
</tr>
</table>
</div>
<div class="col-md-6">
<h6 class="fw-semibold text-muted mb-3">Impact Assessment</h6>
<div class="row g-3">
<div class="col-6">
<div class="text-center p-3 bg-light rounded">
<div class="h5 mb-1 text-primary">{{ total_orders }}</div>
<small class="text-muted">Total Orders</small>
</div>
</div>
<div class="col-6">
<div class="text-center p-3 bg-light rounded">
<div class="h5 mb-1 text-warning">{{ pending_orders }}</div>
<small class="text-muted">Pending Orders</small>
</div>
</div>
<div class="col-6">
<div class="text-center p-3 bg-light rounded">
<div class="h5 mb-1 text-info">{{ reference_ranges }}</div>
<small class="text-muted">Reference Ranges</small>
</div>
</div>
<div class="col-6">
<div class="text-center p-3 bg-light rounded">
<div class="h5 mb-1 text-success">{{ qc_records }}</div>
<small class="text-muted">QC Records</small>
</div>
</div>
</div>
</div>
</div>
<!-- Consequences -->
<div class="mb-4">
<h6 class="fw-semibold text-muted mb-3">What happens when you deactivate this test:</h6>
<div class="row">
<div class="col-md-6">
<div class="list-group list-group-flush">
<div class="list-group-item border-0 px-0">
<i class="fas fa-check text-success me-2"></i>
<strong>Preserved:</strong> All historical orders and results
</div>
<div class="list-group-item border-0 px-0">
<i class="fas fa-check text-success me-2"></i>
<strong>Preserved:</strong> Reference ranges and QC records
</div>
<div class="list-group-item border-0 px-0">
<i class="fas fa-check text-success me-2"></i>
<strong>Preserved:</strong> Billing and financial data
</div>
</div>
</div>
<div class="col-md-6">
<div class="list-group list-group-flush">
<div class="list-group-item border-0 px-0">
<i class="fas fa-times text-danger me-2"></i>
<strong>Disabled:</strong> New order creation
</div>
<div class="list-group-item border-0 px-0">
<i class="fas fa-times text-danger me-2"></i>
<strong>Hidden:</strong> From active test lists
</div>
<div class="list-group-item border-0 px-0">
<i class="fas fa-times text-danger me-2"></i>
<strong>Disabled:</strong> Test scheduling
</div>
</div>
</div>
</div>
</div>
<!-- Pending Orders Warning -->
{% if pending_orders > 0 %}
<div class="alert alert-warning">
<h6 class="alert-heading">
<i class="fas fa-exclamation-triangle me-2"></i>Pending Orders Warning
</h6>
<p class="mb-2">
This test has <strong>{{ pending_orders }} pending order(s)</strong>.
Deactivating the test will not affect these existing orders, but you should consider:
</p>
<ul class="mb-0">
<li>Completing all pending orders before deactivation</li>
<li>Notifying laboratory staff about the deactivation</li>
<li>Ensuring alternative tests are available if needed</li>
</ul>
</div>
{% endif %}
<!-- Reactivation Note -->
<div class="alert alert-info">
<h6 class="alert-heading">
<i class="fas fa-info-circle me-2"></i>Reactivation
</h6>
<p class="mb-0">
This test can be reactivated later by editing the test details and setting the status to "Active".
All historical data will remain intact.
</p>
</div>
<!-- Confirmation Form -->
<form method="post" class="mt-4">
{% csrf_token %}
<div class="form-check mb-3">
<input class="form-check-input" type="checkbox" id="confirmDeactivation" required>
<label class="form-check-label fw-semibold" for="confirmDeactivation">
I understand the consequences of deactivating this lab test
</label>
</div>
<div class="form-check mb-4">
<input class="form-check-input" type="checkbox" id="confirmPendingOrders"
{% if pending_orders == 0 %}checked disabled{% else %}required{% endif %}>
<label class="form-check-label fw-semibold" for="confirmPendingOrders">
{% if pending_orders > 0 %}
I acknowledge there are {{ pending_orders }} pending order(s) for this test
{% else %}
No pending orders to consider
{% endif %}
</label>
</div>
<div class="d-flex justify-content-between">
<a href="{% url 'laboratory:lab_test_detail' lab_test.pk %}" class="btn btn-secondary">
<i class="fas fa-arrow-left me-2"></i>Cancel
</a>
<button type="submit" class="btn btn-danger" id="deactivateBtn" disabled>
<i class="fas fa-ban me-2"></i>Deactivate Lab Test
</button>
</div>
</form>
</div>
</div>
<!-- Alternative Actions -->
<div class="card mt-4">
<div class="card-header">
<h5 class="mb-0">
<i class="fas fa-lightbulb me-2"></i>Alternative Actions
</h5>
</div>
<div class="card-body">
<div class="row">
<div class="col-md-4">
<div class="text-center p-3">
<i class="fas fa-edit fa-2x text-primary mb-2"></i>
<h6>Edit Test</h6>
<p class="text-muted small">Modify test parameters without deactivating</p>
<a href="{% url 'laboratory:lab_test_update' lab_test.pk %}" class="btn btn-outline-primary btn-sm">
Edit Test
</a>
</div>
</div>
<div class="col-md-4">
<div class="text-center p-3">
<i class="fas fa-copy fa-2x text-success mb-2"></i>
<h6>Duplicate Test</h6>
<p class="text-muted small">Create a new version of this test</p>
<a href="{% url 'laboratory:lab_test_create' %}?duplicate={{ lab_test.pk }}" class="btn btn-outline-success btn-sm">
Duplicate Test
</a>
</div>
</div>
<div class="col-md-4">
<div class="text-center p-3">
<i class="fas fa-archive fa-2x text-warning mb-2"></i>
<h6>Archive Test</h6>
<p class="text-muted small">Move to archived tests section</p>
<button class="btn btn-outline-warning btn-sm" onclick="archiveTest()">
Archive Test
</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
const confirmDeactivation = document.getElementById('confirmDeactivation');
const confirmPendingOrders = document.getElementById('confirmPendingOrders');
const deactivateBtn = document.getElementById('deactivateBtn');
function updateButtonState() {
const allChecked = confirmDeactivation.checked && confirmPendingOrders.checked;
deactivateBtn.disabled = !allChecked;
}
confirmDeactivation.addEventListener('change', updateButtonState);
confirmPendingOrders.addEventListener('change', updateButtonState);
// Initial state check
updateButtonState();
});
function archiveTest() {
if (confirm('Are you sure you want to archive this test? This will move it to the archived tests section.')) {
// Archive test functionality
fetch(`{% url 'laboratory:lab_test_archive' lab_test.pk %}`, {
method: 'POST',
headers: {
'X-CSRFToken': document.querySelector('[name=csrfmiddlewaretoken]').value,
'Content-Type': 'application/json',
},
})
.then(response => response.json())
.then(data => {
if (data.success) {
window.location.href = '{% url "laboratory:lab_test_list" %}';
} else {
alert('Error archiving test: ' + data.error);
}
})
.catch(error => {
console.error('Error:', error);
alert('An error occurred while archiving the test.');
});
}
}
// Prevent accidental form submission
document.querySelector('form').addEventListener('submit', function(e) {
if (!confirm('Are you absolutely sure you want to deactivate this lab test?')) {
e.preventDefault();
}
});
</script>
<style>
.list-group-item {
background-color: transparent;
}
.form-check-input:checked {
background-color: #dc3545;
border-color: #dc3545;
}
.alert {
border-left: 4px solid;
}
.alert-danger {
border-left-color: #dc3545;
}
.alert-warning {
border-left-color: #ffc107;
}
.alert-info {
border-left-color: #0dcaf0;
}
.card.border-danger {
border-width: 2px;
}
@media (max-width: 768px) {
.row.justify-content-center {
margin: 0;
}
.col-lg-8 {
padding: 0 15px;
}
.table-responsive {
font-size: 0.875rem;
}
.d-flex.justify-content-between {
flex-direction: column;
gap: 1rem;
}
}
</style>
{% endblock %}