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

521 lines
28 KiB
HTML

{% extends "base.html" %}
{% load static %}
{% block title %}Delete Patient Note - 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:patient_detail' object.patient.pk %}">{{ object.patient.get_full_name }}</a></li>
<li class="breadcrumb-item"><a href="{% url 'patients:patient_note_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 Patient Note
<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 Note 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 patient note. This action cannot be undone and may impact patient care documentation and clinical records.</p>
</div>
<div class="row mb-4">
<div class="col-md-6">
<h6>Note 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 == 'CLINICAL' %}primary{% elif object.category == 'URGENT' %}danger{% elif object.category == 'FOLLOW_UP' %}warning{% else %}secondary{% endif %}">
{{ object.get_category_display }}
</span>
</td>
</tr>
<tr>
<td class="fw-bold">Priority:</td>
<td>
<span class="badge bg-{% if object.priority == 'URGENT' %}danger{% elif object.priority == 'HIGH' %}warning{% elif object.priority == 'NORMAL' %}success{% else %}secondary{% endif %}">
{{ object.get_priority_display }}
</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>
{% if object.follow_up_date %}
<tr>
<td class="fw-bold">Follow-up:</td>
<td>
{{ object.follow_up_date|date:"M d, Y" }}
{% if object.is_follow_up_overdue %}
<br><small class="text-danger">Overdue</small>
{% elif object.is_follow_up_due_soon %}
<br><small class="text-warning">Due Soon</small>
{% endif %}
</td>
</tr>
{% endif %}
</table>
</div>
<div class="col-md-6">
<h6>Patient Information:</h6>
<table class="table table-borderless">
<tr>
<td class="fw-bold" width="120">Patient:</td>
<td>{{ object.patient.get_full_name }}</td>
</tr>
<tr>
<td class="fw-bold">Patient ID:</td>
<td><code>{{ object.patient.patient_id }}</code></td>
</tr>
<tr>
<td class="fw-bold">DOB:</td>
<td>{{ object.patient.date_of_birth|date:"M d, Y" }}</td>
</tr>
<tr>
<td class="fw-bold">Age:</td>
<td>{{ object.patient.age }} years</td>
</tr>
<tr>
<td class="fw-bold">Last Updated:</td>
<td>{{ object.updated_at|date:"M d, Y H:i" }}</td>
</tr>
{% if object.is_confidential %}
<tr>
<td class="fw-bold">Confidential:</td>
<td>
<span class="badge bg-danger">
<i class="fa fa-lock me-1"></i>Yes
</span>
</td>
</tr>
{% endif %}
</table>
</div>
</div>
<!-- Note Content Preview -->
<div class="card mb-4">
<div class="card-header">
<h6 class="card-title mb-0">Note Content Preview</h6>
</div>
<div class="card-body">
<div class="note-preview" style="max-height: 200px; overflow-y: auto;">
{{ object.content|truncatewords:100|linebreaks }}
</div>
{% if object.content|wordcount > 100 %}
<div class="text-muted mt-2">
<small>Content truncated for preview. Full note 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>Clinical Documentation:</strong> Note will be permanently removed from patient's clinical record</li>
<li><strong>Audit Trail:</strong> Deletion will be logged for compliance and audit purposes</li>
<li><strong>Follow-up Actions:</strong> Any pending follow-up actions will be cancelled</li>
<li><strong>References:</strong> Other notes or documents referencing this note may be affected</li>
<li><strong>Legal Compliance:</strong> Ensure deletion complies with medical record retention policies</li>
<li><strong>Care Continuity:</strong> May impact understanding of patient's care history</li>
</ul>
</div>
<!-- Clinical Note Warning -->
{% if object.category == 'CLINICAL' %}
<div class="alert alert-danger mb-4">
<h6 class="alert-heading">
<i class="fa fa-stethoscope me-2"></i>Clinical Note Warning
</h6>
<p class="mb-2">This is a clinical note. Deleting it will:</p>
<ul class="mb-0">
<li>Remove important clinical documentation from patient record</li>
<li>Potentially impact continuity of care</li>
<li>Affect clinical decision-making for future treatments</li>
<li>May violate medical record retention requirements</li>
<li>Could impact legal or insurance proceedings</li>
</ul>
</div>
{% endif %}
<!-- Urgent Priority Warning -->
{% if object.priority == 'URGENT' %}
<div class="alert alert-danger mb-4">
<h6 class="alert-heading">
<i class="fa fa-exclamation-triangle me-2"></i>Urgent Priority Warning
</h6>
<p class="mb-2">This note is marked as urgent. Deleting it will:</p>
<ul class="mb-0">
<li>Remove urgent clinical information from patient record</li>
<li>Potentially impact immediate patient care decisions</li>
<li>Remove critical alerts or warnings for care team</li>
<li>May affect patient safety protocols</li>
<li>Could impact emergency care procedures</li>
</ul>
</div>
{% endif %}
<!-- Confidential Note Warning -->
{% if object.is_confidential %}
<div class="alert alert-warning mb-4">
<h6 class="alert-heading">
<i class="fa fa-lock me-2"></i>Confidential Note Warning
</h6>
<p class="mb-2">This is a confidential note. Deleting it will:</p>
<ul class="mb-0">
<li>Permanently remove sensitive patient information</li>
<li>Impact privacy-protected documentation</li>
<li>May affect specialized care protocols</li>
<li>Could impact legal or compliance requirements</li>
</ul>
</div>
{% endif %}
<!-- Follow-up Warning -->
{% if object.follow_up_date %}
<div class="alert alert-warning mb-4">
<h6 class="alert-heading">
<i class="fa fa-calendar me-2"></i>Follow-up Action Warning
</h6>
<p class="mb-2">This note has a scheduled follow-up on {{ object.follow_up_date|date:"M d, Y" }}. Deleting it will:</p>
<ul class="mb-0">
<li>Cancel the scheduled follow-up action</li>
<li>Remove follow-up instructions and context</li>
<li>Potentially impact patient care continuity</li>
<li>May require rescheduling or alternative arrangements</li>
{% if object.is_follow_up_overdue %}
<li><strong>Note:</strong> This follow-up is already overdue</li>
{% elif object.is_follow_up_due_soon %}
<li><strong>Note:</strong> This follow-up is due soon</li>
{% endif %}
</ul>
</div>
{% endif %}
<!-- Attachments Warning -->
{% if object.attachments.exists %}
<div class="alert alert-info mb-4">
<h6 class="alert-heading">
<i class="fa fa-paperclip me-2"></i>Attachments Information
</h6>
<p class="mb-2">This note has {{ object.attachments.count }} attachment{{ object.attachments.count|pluralize }}:</p>
<ul class="mb-0">
{% for attachment in object.attachments.all %}
<li>{{ attachment.name }} ({{ attachment.file_size|filesizeformat }})</li>
{% endfor %}
</ul>
<p class="mt-2 mb-0"><strong>Note:</strong> All attachments will also be permanently deleted.</p>
</div>
{% endif %}
<!-- Related Notes Information -->
{% if related_notes_count > 0 %}
<div class="alert alert-info mb-4">
<h6 class="alert-heading">
<i class="fa fa-link me-2"></i>Related Notes Information
</h6>
<p class="mb-0">This patient has {{ related_notes_count }} other note{{ related_notes_count|pluralize }} that may reference or relate to this note. Consider reviewing them before deletion.</p>
</div>
{% endif %}
<!-- Recent Activity -->
{% if object.updated_at != object.created_at %}
<div class="alert alert-info mb-4">
<h6 class="alert-heading">
<i class="fa fa-history me-2"></i>Recent Activity
</h6>
<p class="mb-0">This note was recently updated on {{ object.updated_at|date:"M d, Y H:i" }}. Ensure all recent changes are properly documented elsewhere if needed.</p>
</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-warning">{{ object.attachments.count }}</div>
<div class="small text-muted">Attachments</div>
</div>
</div>
<div class="col-md-3">
<div class="text-center p-3 border rounded">
<div class="fs-24px fw-bold text-info">{% if object.follow_up_date %}1{% else %}0{% endif %}</div>
<div class="small text-muted">Follow-ups</div>
</div>
</div>
<div class="col-md-3">
<div class="text-center p-3 border rounded">
<div class="fs-24px fw-bold text-success">{{ related_notes_count|default:0 }}</div>
<div class="small text-muted">Related Notes</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:patient_note_update' object.pk %}" class="text-decoration-none">
Edit note content or details
</a>
</li>
<li class="mb-2">
<i class="fa fa-archive text-warning me-2"></i>
Archive note instead of deleting
</li>
</ul>
</div>
<div class="col-md-6">
<ul class="list-unstyled">
<li class="mb-2">
<i class="fa fa-plus text-success me-2"></i>
<a href="{% url 'patients:patient_note_create' %}?patient={{ object.patient.pk }}" class="text-decoration-none">
Create corrective note instead
</a>
</li>
<li class="mb-2">
<i class="fa fa-flag text-info me-2"></i>
Mark note as outdated or superseded
</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 patient note and cannot be undone
</label>
</div>
{% if object.category == 'CLINICAL' %}
<div class="form-check mb-3">
<input class="form-check-input" type="checkbox" id="confirm-clinical" required>
<label class="form-check-label" for="confirm-clinical">
I acknowledge that this is a clinical note and deleting it may impact patient care documentation
</label>
</div>
{% endif %}
{% if object.priority == 'URGENT' %}
<div class="form-check mb-3">
<input class="form-check-input" type="checkbox" id="confirm-urgent" required>
<label class="form-check-label" for="confirm-urgent">
I acknowledge that this is an urgent note and deleting it may impact patient safety
</label>
</div>
{% endif %}
{% if object.is_confidential %}
<div class="form-check mb-3">
<input class="form-check-input" type="checkbox" id="confirm-confidential" required>
<label class="form-check-label" for="confirm-confidential">
I acknowledge that this is a confidential note and deleting it will permanently remove sensitive information
</label>
</div>
{% endif %}
{% if object.follow_up_date %}
<div class="form-check mb-3">
<input class="form-check-input" type="checkbox" id="confirm-followup" required>
<label class="form-check-label" for="confirm-followup">
I acknowledge that deleting this note will cancel the scheduled follow-up action
</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_NOTE">Duplicate note</option>
<option value="INCORRECT_INFORMATION">Incorrect information</option>
<option value="PATIENT_REQUEST">Patient request</option>
<option value="PRIVACY_CONCERN">Privacy concern</option>
<option value="SUPERSEDED">Superseded by newer note</option>
<option value="ADMINISTRATIVE_ERROR">Administrative error</option>
<option value="LEGAL_REQUIREMENT">Legal requirement</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 patient note 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_note" id="backup-note" checked>
<label class="form-check-label" for="backup-note">
Backup note content before deletion
</label>
</div>
</div>
<div class="col-md-6">
<div class="form-check">
<input class="form-check-input" type="checkbox" name="notify_team" id="notify-team">
<label class="form-check-label" for="notify-team">
Notify care team of note 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="update_patient_record" id="update-record" checked>
<label class="form-check-label" for="update-record">
Update patient record summary
</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:patient_note_detail' object.pk %}" class="btn btn-secondary">
<i class="fa fa-arrow-left me-2"></i>Cancel
</a>
<a href="{% url 'patients:patient_note_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 Patient Note
</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 patient note?';
confirmText += '\n\nTitle: {{ object.title }}';
confirmText += '\nPatient: {{ object.patient.get_full_name }}';
confirmText += '\nCreated: {{ object.created_at|date:"M d, Y H:i" }}';
{% if object.category == 'CLINICAL' %}
confirmText += '\n\nWARNING: This is a CLINICAL note!';
{% endif %}
{% if object.priority == 'URGENT' %}
confirmText += '\n\nWARNING: This note is marked as URGENT!';
{% endif %}
{% if object.is_confidential %}
confirmText += '\n\nWARNING: This is a CONFIDENTIAL note!';
{% endif %}
{% if object.follow_up_date %}
confirmText += '\n\nWARNING: This note has a scheduled follow-up!';
{% endif %}
confirmText += '\n\nThis action cannot be undone and may impact patient care.';
if (!confirm(confirmText)) {
e.preventDefault();
}
});
});
</script>
{% endblock %}