341 lines
17 KiB
HTML
341 lines
17 KiB
HTML
{% extends "base.html" %}
|
|
{% load static %}
|
|
|
|
{% block title %}Delete Report Template - {{ object.name }}{% endblock %}
|
|
|
|
{% block content %}
|
|
<div class="d-flex align-items-center mb-3">
|
|
<div>
|
|
<ol class="breadcrumb">
|
|
<li class="breadcrumb-item"><a href="{% url 'radiology:dashboard' %}">Radiology</a></li>
|
|
<li class="breadcrumb-item"><a href="{% url 'radiology:report_template_list' %}">Templates</a></li>
|
|
<li class="breadcrumb-item"><a href="{% url 'radiology:report_template_detail' object.pk %}">{{ object.name }}</a></li>
|
|
<li class="breadcrumb-item active">Delete</li>
|
|
</ol>
|
|
<h1 class="page-header mb-0">Delete Report Template</h1>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="col-xl-8">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h4 class="card-title">
|
|
<i class="fas fa-exclamation-triangle text-danger me-2"></i>
|
|
Confirm Deletion
|
|
</h4>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="alert alert-warning">
|
|
<h5><i class="fas fa-exclamation-triangle me-2"></i>Warning</h5>
|
|
<p class="mb-0">You are about to permanently delete this report template. This action cannot be undone and will affect future report creation.</p>
|
|
</div>
|
|
|
|
<!-- Template Information -->
|
|
<div class="row mb-4">
|
|
<div class="col-md-6">
|
|
<h6 class="text-muted mb-2">Template Information</h6>
|
|
<table class="table table-sm">
|
|
<tr>
|
|
<td class="fw-bold">Name:</td>
|
|
<td>{{ object.name }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">Modality:</td>
|
|
<td>{{ object.get_modality_display }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">Category:</td>
|
|
<td>{{ object.get_category_display }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">Body Part:</td>
|
|
<td>{{ object.body_part|default:"Not specified" }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">Status:</td>
|
|
<td>
|
|
<span class="badge bg-{% if object.is_active %}success{% else %}secondary{% endif %}">
|
|
{% if object.is_active %}Active{% else %}Inactive{% endif %}
|
|
</span>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<h6 class="text-muted mb-2">Usage Statistics</h6>
|
|
<table class="table table-sm">
|
|
<tr>
|
|
<td class="fw-bold">Total Uses:</td>
|
|
<td>{{ object.usage_count|default:0 }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">This Month:</td>
|
|
<td>{{ object.monthly_usage|default:0 }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">Last Used:</td>
|
|
<td>{{ object.last_used|date:"M d, Y"|default:"Never" }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">Created:</td>
|
|
<td>{{ object.created_at|date:"M d, Y" }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">Created By:</td>
|
|
<td>{{ object.created_by.get_full_name|default:"System" }}</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- High Usage Warning -->
|
|
{% if object.usage_count > 50 %}
|
|
<div class="alert alert-danger">
|
|
<h6><i class="fas fa-chart-line me-2"></i>High Usage Template</h6>
|
|
<p class="mb-0">This template has been used {{ object.usage_count }} times. Deleting it may significantly impact workflow efficiency and report consistency.</p>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<!-- Default Template Warning -->
|
|
{% if object.is_default %}
|
|
<div class="alert alert-danger">
|
|
<h6><i class="fas fa-star me-2"></i>Default Template Warning</h6>
|
|
<p class="mb-0">This is the default template for {{ object.get_modality_display }}. Deleting it will require setting a new default template.</p>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<!-- Active Template Warning -->
|
|
{% if object.is_active %}
|
|
<div class="alert alert-warning">
|
|
<h6><i class="fas fa-power-off me-2"></i>Active Template</h6>
|
|
<p class="mb-0">This template is currently active and available for use. Consider deactivating it first before deletion.</p>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<!-- Impact Assessment -->
|
|
<div class="alert alert-info">
|
|
<h6><i class="fas fa-info-circle me-2"></i>Deletion Impact</h6>
|
|
<ul class="mb-0">
|
|
<li><strong>Report Creation:</strong> Template will no longer be available for new reports</li>
|
|
<li><strong>Existing Reports:</strong> Reports created with this template will not be affected</li>
|
|
<li><strong>Workflow:</strong> Users may need to select alternative templates</li>
|
|
<li><strong>Consistency:</strong> Standardized reporting for this modality may be impacted</li>
|
|
<li><strong>Training:</strong> Staff may need retraining on alternative templates</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<!-- Template Preview -->
|
|
<div class="card bg-light">
|
|
<div class="card-header">
|
|
<h6 class="card-title mb-0">Template Preview</h6>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<h6 class="text-muted">Technique:</h6>
|
|
<p class="small">{{ object.technique|truncatewords:20 }}</p>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<h6 class="text-muted">Findings Template:</h6>
|
|
<p class="small">{{ object.findings_template|truncatewords:20 }}</p>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<h6 class="text-muted">Impression Template:</h6>
|
|
<p class="small">{{ object.impression_template|truncatewords:20 }}</p>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<h6 class="text-muted">Recommendations:</h6>
|
|
<p class="small">{{ object.recommendations_template|truncatewords:20|default:"None specified" }}</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Alternative Actions -->
|
|
<div class="card bg-light mt-3">
|
|
<div class="card-body">
|
|
<h6 class="card-title">Alternative Actions</h6>
|
|
<p class="card-text">Consider these alternatives to deletion:</p>
|
|
<div class="btn-group-vertical w-100" role="group">
|
|
<a href="{% url 'radiology:report_template_update' object.pk %}" class="btn btn-outline-primary btn-sm">
|
|
<i class="fas fa-edit me-2"></i>Edit Template Content
|
|
</a>
|
|
<button type="button" class="btn btn-outline-warning btn-sm" onclick="deactivateTemplate()">
|
|
<i class="fas fa-pause me-2"></i>Deactivate Template (Recommended)
|
|
</button>
|
|
<button type="button" class="btn btn-outline-info btn-sm" onclick="archiveTemplate()">
|
|
<i class="fas fa-archive me-2"></i>Archive Template
|
|
</button>
|
|
<button type="button" class="btn btn-outline-secondary btn-sm" onclick="duplicateTemplate()">
|
|
<i class="fas fa-copy me-2"></i>Create Backup Copy
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-xl-4">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h4 class="card-title">Deletion Confirmation</h4>
|
|
</div>
|
|
<div class="card-body">
|
|
<form method="post">
|
|
{% csrf_token %}
|
|
|
|
<div class="mb-3">
|
|
<label class="form-label">Reason for Deletion <span class="text-danger">*</span></label>
|
|
<select class="form-select" name="deletion_reason" required>
|
|
<option value="">Select reason...</option>
|
|
<option value="obsolete">Template Obsolete</option>
|
|
<option value="duplicate">Duplicate Template</option>
|
|
<option value="error">Template Error</option>
|
|
<option value="policy_change">Policy Change</option>
|
|
<option value="low_usage">Low Usage</option>
|
|
<option value="replacement">Replaced by New Template</option>
|
|
<option value="other">Other</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="mb-3" id="replacementTemplate" style="display: none;">
|
|
<label class="form-label">Replacement Template</label>
|
|
<select class="form-select" name="replacement_template">
|
|
<option value="">Select replacement...</option>
|
|
{% for template in alternative_templates %}
|
|
<option value="{{ template.pk }}">{{ template.name }}</option>
|
|
{% endfor %}
|
|
</select>
|
|
<div class="form-text">Recommended alternative template</div>
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label class="form-label">Additional Notes</label>
|
|
<textarea class="form-control" name="deletion_notes" rows="3" placeholder="Provide additional context for this deletion..."></textarea>
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<div class="form-check">
|
|
<input class="form-check-input" type="checkbox" id="confirmBackup" required>
|
|
<label class="form-check-label" for="confirmBackup">
|
|
I confirm that a backup copy has been created if needed
|
|
</label>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<div class="form-check">
|
|
<input class="form-check-input" type="checkbox" id="confirmNotification" required>
|
|
<label class="form-check-label" for="confirmNotification">
|
|
I confirm that affected users have been notified
|
|
</label>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<div class="form-check">
|
|
<input class="form-check-input" type="checkbox" id="confirmUnderstand" required>
|
|
<label class="form-check-label" for="confirmUnderstand">
|
|
I understand this action cannot be undone
|
|
</label>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="d-grid gap-2">
|
|
<button type="submit" class="btn btn-danger" id="deleteBtn" disabled>
|
|
<i class="fas fa-trash me-2"></i>Delete Template
|
|
</button>
|
|
<a href="{% url 'radiology:report_template_detail' object.pk %}" class="btn btn-secondary">
|
|
<i class="fas fa-times me-2"></i>Cancel
|
|
</a>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Contact Information -->
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h4 class="card-title">Need Help?</h4>
|
|
</div>
|
|
<div class="card-body">
|
|
<p class="card-text">If you're unsure about deleting this template, contact:</p>
|
|
<ul class="list-unstyled">
|
|
<li><i class="fas fa-user-md me-2"></i><strong>Chief Radiologist:</strong> ext. 2100</li>
|
|
<li><i class="fas fa-cog me-2"></i><strong>IT Support:</strong> ext. 3000</li>
|
|
<li><i class="fas fa-users me-2"></i><strong>Training Coordinator:</strong> ext. 2250</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
const reasonSelect = document.querySelector('select[name="deletion_reason"]');
|
|
const replacementDiv = document.getElementById('replacementTemplate');
|
|
const confirmBackup = document.getElementById('confirmBackup');
|
|
const confirmNotification = document.getElementById('confirmNotification');
|
|
const confirmUnderstand = document.getElementById('confirmUnderstand');
|
|
const deleteBtn = document.getElementById('deleteBtn');
|
|
|
|
// Show replacement template field when "replacement" is selected
|
|
reasonSelect.addEventListener('change', function() {
|
|
if (this.value === 'replacement') {
|
|
replacementDiv.style.display = 'block';
|
|
} else {
|
|
replacementDiv.style.display = 'none';
|
|
}
|
|
updateDeleteButton();
|
|
});
|
|
|
|
function updateDeleteButton() {
|
|
const allChecked = confirmBackup.checked && confirmNotification.checked && confirmUnderstand.checked;
|
|
const reasonSelected = reasonSelect.value !== '';
|
|
deleteBtn.disabled = !(allChecked && reasonSelected);
|
|
}
|
|
|
|
confirmBackup.addEventListener('change', updateDeleteButton);
|
|
confirmNotification.addEventListener('change', updateDeleteButton);
|
|
confirmUnderstand.addEventListener('change', updateDeleteButton);
|
|
reasonSelect.addEventListener('change', updateDeleteButton);
|
|
});
|
|
|
|
function deactivateTemplate() {
|
|
if (confirm('Deactivate this template instead of deleting it?')) {
|
|
fetch('{% url "radiology:report_template_detail" object.pk %}', {
|
|
method: 'PATCH',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
'X-CSRFToken': document.querySelector('[name=csrfmiddlewaretoken]').value
|
|
},
|
|
body: JSON.stringify({is_active: false})
|
|
})
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
if (data.success) {
|
|
window.location.href = '{% url "radiology:report_template_detail" object.pk %}';
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
function archiveTemplate() {
|
|
if (confirm('Archive this template instead of deleting it?')) {
|
|
window.location.href = '{% url "radiology:report_template_detail" object.pk %}?action=archive';
|
|
}
|
|
}
|
|
|
|
function duplicateTemplate() {
|
|
if (confirm('Create a backup copy of this template before deletion?')) {
|
|
window.location.href = '{% url "radiology:report_template_create" %}?duplicate={{ object.pk }}';
|
|
}
|
|
}
|
|
</script>
|
|
{% endblock %}
|
|
|