hospital-management/templates/patients/consents/consent_form_confirm_delete.html
2025-08-12 13:33:25 +03:00

495 lines
26 KiB
HTML

{% extends "base.html" %}
{% load static %}
{% block title %}Delete Consent Form - Patients{% endblock %}
{% block content %}
<!-- BEGIN breadcrumb -->
<ol class="breadcrumb float-xl-end">
<li class="breadcrumb-item"><a href="{% url 'core:dashboard' %}">Dashboard</a></li>
<li class="breadcrumb-item"><a href="{% url 'patients:patient_list' %}">Patients</a></li>
<li class="breadcrumb-item"><a href="{% url 'patients:consent_form_list' %}">Consent Forms</a></li>
<li class="breadcrumb-item"><a href="{% url 'patients:consent_form_detail' object.pk %}">{{ object.title|truncatechars:20 }}</a></li>
<li class="breadcrumb-item active">Delete Confirmation</li>
</ol>
<!-- END breadcrumb -->
<!-- BEGIN page-header -->
<h1 class="page-header">
Delete Consent Form
<small>Confirmation Required</small>
</h1>
<!-- END page-header -->
<div class="row justify-content-center">
<div class="col-xl-8">
<!-- BEGIN panel -->
<div class="panel panel-inverse">
<div class="panel-heading">
<h4 class="panel-title">
<i class="fa fa-exclamation-triangle text-warning me-2"></i>
Confirm Form Deletion
</h4>
</div>
<div class="panel-body">
<div class="alert alert-warning">
<h6 class="alert-heading">Warning</h6>
<p class="mb-0">You are about to delete this consent form template. This action cannot be undone and may impact patient consent management and legal compliance.</p>
</div>
<div class="row mb-4">
<div class="col-md-6">
<h6>Form Details:</h6>
<table class="table table-borderless">
<tr>
<td class="fw-bold" width="120">Title:</td>
<td>{{ object.title }}</td>
</tr>
<tr>
<td class="fw-bold">Category:</td>
<td>
<span class="badge bg-{% if object.category == 'SURGICAL' %}danger{% elif object.category == 'TREATMENT' %}primary{% elif object.category == 'RESEARCH' %}info{% elif object.category == 'PRIVACY' %}dark{% elif object.category == 'FINANCIAL' %}success{% else %}secondary{% endif %}">
{{ object.get_category_display }}
</span>
</td>
</tr>
<tr>
<td class="fw-bold">Status:</td>
<td>
<span class="badge bg-{% if object.status == 'ACTIVE' %}success{% elif object.status == 'DRAFT' %}warning{% elif object.status == 'REVIEW' %}info{% elif object.status == 'ARCHIVED' %}secondary{% else %}danger{% endif %}">
{{ object.get_status_display }}
</span>
</td>
</tr>
<tr>
<td class="fw-bold">Version:</td>
<td><span class="badge bg-light text-dark">v{{ object.version }}</span></td>
</tr>
<tr>
<td class="fw-bold">Created:</td>
<td>{{ object.created_at|date:"M d, Y H:i" }}</td>
</tr>
<tr>
<td class="fw-bold">Created By:</td>
<td>{{ object.created_by.get_full_name }}</td>
</tr>
</table>
</div>
<div class="col-md-6">
<h6>Usage Information:</h6>
<table class="table table-borderless">
<tr>
<td class="fw-bold" width="120">Required:</td>
<td>
{% if object.is_required %}
<span class="text-danger">
<i class="fa fa-exclamation-triangle me-1"></i>Required
</span>
{% else %}
<span class="text-muted">Optional</span>
{% endif %}
</td>
</tr>
<tr>
<td class="fw-bold">Signed:</td>
<td><strong>{{ object.signed_count }}</strong> times</td>
</tr>
<tr>
<td class="fw-bold">Pending:</td>
<td><strong>{{ object.pending_count }}</strong> signatures</td>
</tr>
<tr>
<td class="fw-bold">Effective:</td>
<td>{{ object.effective_date|date:"M d, Y"|default:"Not set" }}</td>
</tr>
<tr>
<td class="fw-bold">Expiration:</td>
<td>
{% if object.has_expiration %}
{{ object.expiration_days }} days
{% else %}
No expiration
{% endif %}
</td>
</tr>
<tr>
<td class="fw-bold">Last Updated:</td>
<td>{{ object.updated_at|date:"M d, Y H:i" }}</td>
</tr>
</table>
</div>
</div>
<!-- Form Content Preview -->
<div class="card mb-4">
<div class="card-header">
<h6 class="card-title mb-0">Form Content Preview</h6>
</div>
<div class="card-body">
<div class="form-preview" style="max-height: 200px; overflow-y: auto;">
{{ object.content|truncatewords:100|safe }}
</div>
{% if object.content|wordcount > 100 %}
<div class="text-muted mt-2">
<small>Content truncated for preview. Full form contains {{ object.content|wordcount }} words.</small>
</div>
{% endif %}
</div>
</div>
<!-- Impact Assessment -->
<div class="alert alert-info mb-4">
<h6 class="alert-heading">
<i class="fa fa-info-circle me-2"></i>Impact Assessment
</h6>
<ul class="mb-0">
<li><strong>Template Removal:</strong> Form template will be permanently removed from the system</li>
<li><strong>Existing Signatures:</strong> Previously signed forms will remain in patient records</li>
<li><strong>Pending Signatures:</strong> Any pending signature requests will be cancelled</li>
<li><strong>Legal Compliance:</strong> Ensure deletion complies with consent management policies</li>
<li><strong>Patient Care:</strong> May impact ability to obtain required consents</li>
<li><strong>Audit Trail:</strong> Deletion will be logged for compliance purposes</li>
</ul>
</div>
<!-- Required Form Warning -->
{% if object.is_required %}
<div class="alert alert-danger mb-4">
<h6 class="alert-heading">
<i class="fa fa-exclamation-triangle me-2"></i>Required Form Warning
</h6>
<p class="mb-2">This is a required consent form. Deleting it will:</p>
<ul class="mb-0">
<li>Remove a mandatory consent requirement for all patients</li>
<li>Potentially impact patient admission and treatment processes</li>
<li>May violate institutional consent policies</li>
<li>Could affect legal compliance and patient safety protocols</li>
<li>Impact ability to provide certain treatments or procedures</li>
</ul>
</div>
{% endif %}
<!-- Active Form Warning -->
{% if object.status == 'ACTIVE' %}
<div class="alert alert-danger mb-4">
<h6 class="alert-heading">
<i class="fa fa-check-circle me-2"></i>Active Form Warning
</h6>
<p class="mb-2">This form is currently active. Deleting it will:</p>
<ul class="mb-0">
<li>Remove an active consent form from patient workflows</li>
<li>Cancel any pending signature requests</li>
<li>Potentially disrupt ongoing patient consent processes</li>
<li>May impact scheduled procedures requiring this consent</li>
<li>Could affect patient care continuity</li>
</ul>
</div>
{% endif %}
<!-- Signed Forms Warning -->
{% if object.signed_count > 0 %}
<div class="alert alert-warning mb-4">
<h6 class="alert-heading">
<i class="fa fa-signature me-2"></i>Signed Forms Warning
</h6>
<p class="mb-2">This form has been signed {{ object.signed_count }} time{{ object.signed_count|pluralize }}. Deleting it will:</p>
<ul class="mb-0">
<li>Remove the template but preserve existing signed forms</li>
<li>Prevent future use of this consent form</li>
<li>May impact ability to track consent form versions</li>
<li>Could affect consent renewal processes</li>
<li>May impact reporting and compliance tracking</li>
</ul>
</div>
{% endif %}
<!-- Pending Signatures Warning -->
{% if object.pending_count > 0 %}
<div class="alert alert-warning mb-4">
<h6 class="alert-heading">
<i class="fa fa-clock me-2"></i>Pending Signatures Warning
</h6>
<p class="mb-2">This form has {{ object.pending_count }} pending signature{{ object.pending_count|pluralize }}. Deleting it will:</p>
<ul class="mb-0">
<li>Cancel all pending signature requests</li>
<li>Notify patients and staff of cancellation</li>
<li>May delay patient care or procedures</li>
<li>Could require alternative consent arrangements</li>
<li>May impact scheduled appointments or treatments</li>
</ul>
</div>
{% endif %}
<!-- Expiration Warning -->
{% if object.has_expiration %}
<div class="alert alert-info mb-4">
<h6 class="alert-heading">
<i class="fa fa-calendar me-2"></i>Expiration Information
</h6>
<p class="mb-2">This form has expiration settings ({{ object.expiration_days }} days). Deleting it will:</p>
<ul class="mb-0">
<li>Remove automatic expiration tracking for this consent type</li>
<li>Cancel any scheduled renewal reminders</li>
<li>May impact consent renewal workflows</li>
<li>Could affect compliance monitoring</li>
</ul>
</div>
{% endif %}
<!-- Related Data Summary -->
<div class="row mb-4">
<div class="col-md-3">
<div class="text-center p-3 border rounded">
<div class="fs-24px fw-bold text-primary">{{ object.content|wordcount }}</div>
<div class="small text-muted">Words</div>
</div>
</div>
<div class="col-md-3">
<div class="text-center p-3 border rounded">
<div class="fs-24px fw-bold text-success">{{ object.signed_count }}</div>
<div class="small text-muted">Signed</div>
</div>
</div>
<div class="col-md-3">
<div class="text-center p-3 border rounded">
<div class="fs-24px fw-bold text-warning">{{ object.pending_count }}</div>
<div class="small text-muted">Pending</div>
</div>
</div>
<div class="col-md-3">
<div class="text-center p-3 border rounded">
<div class="fs-24px fw-bold text-info">v{{ object.version }}</div>
<div class="small text-muted">Version</div>
</div>
</div>
</div>
<!-- Alternative Actions -->
<div class="card border-secondary mb-4">
<div class="card-header bg-light">
<h6 class="card-title mb-0">
<i class="fa fa-lightbulb me-2"></i>Alternative Actions
</h6>
</div>
<div class="card-body">
<p class="card-text">Consider these alternatives instead of deletion:</p>
<div class="row">
<div class="col-md-6">
<ul class="list-unstyled">
<li class="mb-2">
<i class="fa fa-edit text-primary me-2"></i>
<a href="{% url 'patients:consent_form_update' object.pk %}" class="text-decoration-none">
Edit form content or settings
</a>
</li>
<li class="mb-2">
<i class="fa fa-archive text-warning me-2"></i>
Archive form instead of deleting
</li>
</ul>
</div>
<div class="col-md-6">
<ul class="list-unstyled">
<li class="mb-2">
<i class="fa fa-copy text-success me-2"></i>
Create new version instead of deleting
</li>
<li class="mb-2">
<i class="fa fa-pause text-info me-2"></i>
Deactivate form temporarily
</li>
</ul>
</div>
</div>
</div>
</div>
<!-- Deletion Form -->
<form method="post" id="delete-form">
{% csrf_token %}
<div class="card border-danger">
<div class="card-header bg-danger text-white">
<h6 class="card-title mb-0">
<i class="fa fa-trash me-2"></i>Deletion Confirmation
</h6>
</div>
<div class="card-body">
<div class="form-check mb-3">
<input class="form-check-input" type="checkbox" id="confirm-understanding" required>
<label class="form-check-label" for="confirm-understanding">
I understand that this action will permanently delete the consent form template and cannot be undone
</label>
</div>
{% if object.is_required %}
<div class="form-check mb-3">
<input class="form-check-input" type="checkbox" id="confirm-required" required>
<label class="form-check-label" for="confirm-required">
I acknowledge that this is a required form and deleting it may impact patient care processes
</label>
</div>
{% endif %}
{% if object.status == 'ACTIVE' %}
<div class="form-check mb-3">
<input class="form-check-input" type="checkbox" id="confirm-active" required>
<label class="form-check-label" for="confirm-active">
I acknowledge that this is an active form and deleting it will disrupt current workflows
</label>
</div>
{% endif %}
{% if object.signed_count > 0 %}
<div class="form-check mb-3">
<input class="form-check-input" type="checkbox" id="confirm-signed" required>
<label class="form-check-label" for="confirm-signed">
I acknowledge that this form has been signed and deleting it may impact consent tracking
</label>
</div>
{% endif %}
{% if object.pending_count > 0 %}
<div class="form-check mb-3">
<input class="form-check-input" type="checkbox" id="confirm-pending" required>
<label class="form-check-label" for="confirm-pending">
I acknowledge that deleting this form will cancel {{ object.pending_count }} pending signature{{ object.pending_count|pluralize }}
</label>
</div>
{% endif %}
<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="DUPLICATE_FORM">Duplicate form</option>
<option value="OUTDATED_CONTENT">Outdated content</option>
<option value="LEGAL_REQUIREMENT">Legal requirement</option>
<option value="POLICY_CHANGE">Policy change</option>
<option value="SUPERSEDED">Superseded by newer form</option>
<option value="ADMINISTRATIVE_ERROR">Administrative error</option>
<option value="COMPLIANCE_ISSUE">Compliance issue</option>
<option value="QUALITY_IMPROVEMENT">Quality improvement</option>
<option value="OTHER">Other</option>
</select>
</div>
<div class="mb-3">
<label class="form-label">Additional Notes <span class="text-danger">*</span></label>
<textarea class="form-control" name="deletion_notes" rows="3" required
placeholder="Provide detailed explanation for why this consent form is being deleted..."></textarea>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-check">
<input class="form-check-input" type="checkbox" name="backup_form" id="backup-form" checked>
<label class="form-check-label" for="backup-form">
Backup form content before deletion
</label>
</div>
</div>
<div class="col-md-6">
<div class="form-check">
<input class="form-check-input" type="checkbox" name="notify_users" id="notify-users" checked>
<label class="form-check-label" for="notify-users">
Notify users of form deletion
</label>
</div>
</div>
</div>
<div class="row mt-2">
<div class="col-md-6">
<div class="form-check">
<input class="form-check-input" type="checkbox" name="cancel_pending" id="cancel-pending" checked>
<label class="form-check-label" for="cancel-pending">
Cancel pending signature requests
</label>
</div>
</div>
<div class="col-md-6">
<div class="form-check">
<input class="form-check-input" type="checkbox" name="preserve_audit_trail" id="preserve-audit" checked>
<label class="form-check-label" for="preserve-audit">
Preserve audit trail
</label>
</div>
</div>
</div>
</div>
</div>
<!-- Action Buttons -->
<div class="d-flex justify-content-between mt-4">
<div>
<a href="{% url 'patients:consent_form_detail' object.pk %}" class="btn btn-secondary">
<i class="fa fa-arrow-left me-2"></i>Cancel
</a>
<a href="{% url 'patients:consent_form_update' object.pk %}" class="btn btn-primary ms-2">
<i class="fa fa-edit me-2"></i>Edit Instead
</a>
</div>
<button type="submit" class="btn btn-danger" id="delete-btn" disabled>
<i class="fa fa-trash me-2"></i>Delete Consent Form
</button>
</div>
</form>
</div>
</div>
<!-- END panel -->
</div>
</div>
{% endblock %}
{% block js %}
<script>
$(document).ready(function() {
// Enable/disable delete button based on checkboxes
function updateDeleteButton() {
var allChecked = true;
$('input[type="checkbox"][required]').each(function() {
if (!$(this).is(':checked')) {
allChecked = false;
return false;
}
});
var reasonSelected = $('select[name="deletion_reason"]').val() !== '';
var notesProvided = $('textarea[name="deletion_notes"]').val().trim() !== '';
$('#delete-btn').prop('disabled', !(allChecked && reasonSelected && notesProvided));
}
// Check on checkbox change
$('input[type="checkbox"], select[name="deletion_reason"], textarea[name="deletion_notes"]').on('change input', updateDeleteButton);
// Form submission confirmation
$('#delete-form').on('submit', function(e) {
var confirmText = 'Are you absolutely sure you want to delete this consent form?';
confirmText += '\n\nTitle: {{ object.title }}';
confirmText += '\nCategory: {{ object.get_category_display }}';
confirmText += '\nStatus: {{ object.get_status_display }}';
{% if object.is_required %}
confirmText += '\n\nWARNING: This is a REQUIRED form!';
{% endif %}
{% if object.status == 'ACTIVE' %}
confirmText += '\n\nWARNING: This form is currently ACTIVE!';
{% endif %}
{% if object.signed_count > 0 %}
confirmText += '\n\nWARNING: This form has been signed {{ object.signed_count }} time{{ object.signed_count|pluralize }}!';
{% endif %}
{% if object.pending_count > 0 %}
confirmText += '\n\nWARNING: This will cancel {{ object.pending_count }} pending signature{{ object.pending_count|pluralize }}!';
{% endif %}
confirmText += '\n\nThis action cannot be undone and may impact patient consent processes.';
if (!confirm(confirmText)) {
e.preventDefault();
}
});
});
</script>
{% endblock %}