479 lines
26 KiB
HTML
479 lines
26 KiB
HTML
{% extends "base.html" %}
|
|
{% load static %}
|
|
|
|
{% block title %}Delete Emergency Contact - 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:emergency_contact_list' %}">Emergency Contacts</a></li>
|
|
<li class="breadcrumb-item active">Delete Confirmation</li>
|
|
</ol>
|
|
<!-- END breadcrumb -->
|
|
|
|
<!-- BEGIN page-header -->
|
|
<h1 class="page-header">
|
|
Delete Emergency Contact
|
|
<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 Contact 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 emergency contact. This action cannot be undone and may impact patient safety and care coordination.</p>
|
|
</div>
|
|
|
|
<div class="row mb-4">
|
|
<div class="col-md-6">
|
|
<h6>Contact Details:</h6>
|
|
<table class="table table-borderless">
|
|
<tr>
|
|
<td class="fw-bold" width="150">Name:</td>
|
|
<td>{{ object.name }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">Relationship:</td>
|
|
<td>{{ object.get_relationship_display }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">Phone:</td>
|
|
<td>{{ object.phone_number|default:"Not provided" }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">Email:</td>
|
|
<td>{{ object.email|default:"Not provided" }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">Priority:</td>
|
|
<td>
|
|
{% if object.is_primary %}
|
|
<span class="badge bg-warning">
|
|
<i class="fa fa-star me-1"></i>Primary Contact
|
|
</span>
|
|
{% else %}
|
|
<span class="badge bg-secondary">Secondary Contact</span>
|
|
{% endif %}
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">Medical Decisions:</td>
|
|
<td>
|
|
{% if object.can_make_medical_decisions %}
|
|
<span class="badge bg-success">
|
|
<i class="fa fa-check me-1"></i>Authorized
|
|
</span>
|
|
{% else %}
|
|
<span class="badge bg-danger">
|
|
<i class="fa fa-times me-1"></i>Not Authorized
|
|
</span>
|
|
{% endif %}
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<h6>Patient Information:</h6>
|
|
<table class="table table-borderless">
|
|
<tr>
|
|
<td class="fw-bold" width="150">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">Contact Added:</td>
|
|
<td>{{ object.created_at|date:"M d, Y H:i" }}</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>
|
|
|
|
<!-- 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>Patient Safety:</strong> Emergency contact information will be removed from patient record</li>
|
|
<li><strong>Care Coordination:</strong> Healthcare team will lose access to this contact method</li>
|
|
<li><strong>Emergency Situations:</strong> Contact will not be reachable during medical emergencies</li>
|
|
<li><strong>Medical Decisions:</strong> {% if object.can_make_medical_decisions %}Authorized decision-maker will be removed{% else %}No impact on medical decision-making{% endif %}</li>
|
|
<li><strong>Communication:</strong> Routine updates and notifications will not be sent to this contact</li>
|
|
<li><strong>Audit Trail:</strong> Contact history and communication logs will be preserved</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<!-- Primary Contact Warning -->
|
|
{% if object.is_primary %}
|
|
<div class="alert alert-danger mb-4">
|
|
<h6 class="alert-heading">
|
|
<i class="fa fa-star me-2"></i>Primary Contact Warning
|
|
</h6>
|
|
<p class="mb-2">This is the patient's primary emergency contact. Deleting it will:</p>
|
|
<ul class="mb-0">
|
|
<li>Remove the main point of contact for emergencies</li>
|
|
<li>Require designation of a new primary contact</li>
|
|
<li>Impact emergency notification protocols</li>
|
|
<li>Potentially delay critical communications</li>
|
|
</ul>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<!-- Medical Decision Authority Warning -->
|
|
{% if object.can_make_medical_decisions %}
|
|
<div class="alert alert-danger mb-4">
|
|
<h6 class="alert-heading">
|
|
<i class="fa fa-user-md me-2"></i>Medical Decision Authority Warning
|
|
</h6>
|
|
<p class="mb-2">This contact is authorized to make medical decisions. Deleting it will:</p>
|
|
<ul class="mb-0">
|
|
<li>Remove an authorized medical decision-maker</li>
|
|
<li>Impact consent processes for medical procedures</li>
|
|
<li>Require identification of alternative decision-makers</li>
|
|
<li>Potentially delay medical care requiring consent</li>
|
|
</ul>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<!-- Only Contact Warning -->
|
|
{% if object.patient.emergency_contacts.count == 1 %}
|
|
<div class="alert alert-danger mb-4">
|
|
<h6 class="alert-heading">
|
|
<i class="fa fa-exclamation-triangle me-2"></i>Only Emergency Contact Warning
|
|
</h6>
|
|
<p class="mb-2">This is the patient's only emergency contact. Deleting it will:</p>
|
|
<ul class="mb-0">
|
|
<li>Leave the patient without any emergency contacts</li>
|
|
<li>Create a critical gap in emergency communication</li>
|
|
<li>Violate hospital policies requiring emergency contacts</li>
|
|
<li>Potentially compromise patient safety protocols</li>
|
|
<li>Require immediate addition of a replacement contact</li>
|
|
</ul>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<!-- Minor Patient Warning -->
|
|
{% if object.patient.age < 18 %}
|
|
<div class="alert alert-warning mb-4">
|
|
<h6 class="alert-heading">
|
|
<i class="fa fa-child me-2"></i>Minor Patient Warning
|
|
</h6>
|
|
<p class="mb-0">This patient is a minor ({{ object.patient.age }} years old). Emergency contacts are especially critical for pediatric patients and their legal guardians.</p>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<!-- Other Emergency Contacts -->
|
|
{% if object.patient.emergency_contacts.count > 1 %}
|
|
<div class="alert alert-info mb-4">
|
|
<h6 class="alert-heading">
|
|
<i class="fa fa-users me-2"></i>Other Emergency Contacts
|
|
</h6>
|
|
<p class="mb-2">Patient has {{ object.patient.emergency_contacts.count|add:"-1" }} other emergency contact(s):</p>
|
|
<ul class="mb-0">
|
|
{% for contact in object.patient.emergency_contacts.all %}
|
|
{% if contact.pk != object.pk %}
|
|
<li>
|
|
{{ contact.name }} ({{ contact.get_relationship_display }})
|
|
{% if contact.is_primary %} - <strong>Primary</strong>{% endif %}
|
|
{% if contact.can_make_medical_decisions %} - <strong>Medical Decisions</strong>{% endif %}
|
|
</li>
|
|
{% endif %}
|
|
{% endfor %}
|
|
</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.patient.emergency_contacts.count|add:"-1" }}</div>
|
|
<div class="small text-muted">Remaining Contacts</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<div class="text-center p-3 border rounded">
|
|
<div class="fs-24px fw-bold text-warning">{% if object.is_primary %}1{% else %}0{% endif %}</div>
|
|
<div class="small text-muted">Primary Status</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.can_make_medical_decisions %}1{% else %}0{% endif %}</div>
|
|
<div class="small text-muted">Medical Authority</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.patient.age }}</div>
|
|
<div class="small text-muted">Patient Age</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:emergency_contact_update' object.pk %}" class="text-decoration-none">
|
|
Update contact information
|
|
</a>
|
|
</li>
|
|
<li class="mb-2">
|
|
<i class="fa fa-star text-warning me-2"></i>
|
|
{% if object.is_primary %}
|
|
Remove primary status
|
|
{% else %}
|
|
Make this the primary contact
|
|
{% endif %}
|
|
</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:emergency_contact_create' %}?patient={{ object.patient.pk }}" class="text-decoration-none">
|
|
Add a replacement contact first
|
|
</a>
|
|
</li>
|
|
<li class="mb-2">
|
|
<i class="fa fa-pause text-secondary me-2"></i>
|
|
Mark contact as inactive
|
|
</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 emergency contact and cannot be undone
|
|
</label>
|
|
</div>
|
|
|
|
{% if object.is_primary %}
|
|
<div class="form-check mb-3">
|
|
<input class="form-check-input" type="checkbox" id="confirm-primary" required>
|
|
<label class="form-check-label" for="confirm-primary">
|
|
I acknowledge that this is the primary emergency contact and deleting it will impact emergency protocols
|
|
</label>
|
|
</div>
|
|
{% endif %}
|
|
|
|
{% if object.can_make_medical_decisions %}
|
|
<div class="form-check mb-3">
|
|
<input class="form-check-input" type="checkbox" id="confirm-medical" required>
|
|
<label class="form-check-label" for="confirm-medical">
|
|
I acknowledge that this contact is authorized for medical decisions and deleting it will impact consent processes
|
|
</label>
|
|
</div>
|
|
{% endif %}
|
|
|
|
{% if object.patient.emergency_contacts.count == 1 %}
|
|
<div class="form-check mb-3">
|
|
<input class="form-check-input" type="checkbox" id="confirm-only" required>
|
|
<label class="form-check-label" for="confirm-only">
|
|
I acknowledge that this is the patient's only emergency contact and deleting it will leave them without emergency contacts
|
|
</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_CONTACT">Duplicate contact</option>
|
|
<option value="INCORRECT_INFORMATION">Incorrect information</option>
|
|
<option value="CONTACT_UNAVAILABLE">Contact no longer available</option>
|
|
<option value="PATIENT_REQUEST">Patient request</option>
|
|
<option value="RELATIONSHIP_ENDED">Relationship ended</option>
|
|
<option value="CONTACT_DECEASED">Contact deceased</option>
|
|
<option value="REPLACED_BY_OTHER">Replaced by another contact</option>
|
|
<option value="PRIVACY_CONCERNS">Privacy concerns</option>
|
|
<option value="ADMINISTRATIVE_ERROR">Administrative error</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 emergency contact is being deleted..."></textarea>
|
|
</div>
|
|
|
|
{% if object.is_primary and object.patient.emergency_contacts.count > 1 %}
|
|
<div class="mb-3">
|
|
<label class="form-label">New Primary Contact</label>
|
|
<select class="form-select" name="new_primary_contact">
|
|
<option value="">Select new primary contact...</option>
|
|
{% for contact in object.patient.emergency_contacts.all %}
|
|
{% if contact.pk != object.pk %}
|
|
<option value="{{ contact.pk }}">{{ contact.name }} ({{ contact.get_relationship_display }})</option>
|
|
{% endif %}
|
|
{% endfor %}
|
|
</select>
|
|
<div class="form-text">If this is the primary contact, select a replacement primary contact.</div>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<div class="form-check">
|
|
<input class="form-check-input" type="checkbox" name="backup_contact" id="backup-contact" checked>
|
|
<label class="form-check-label" for="backup-contact">
|
|
Backup contact information before deletion
|
|
</label>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<div class="form-check">
|
|
<input class="form-check-input" type="checkbox" name="notify_patient" id="notify-patient">
|
|
<label class="form-check-label" for="notify-patient">
|
|
Notify patient of contact removal
|
|
</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_protocols" id="update-protocols" checked>
|
|
<label class="form-check-label" for="update-protocols">
|
|
Update emergency protocols
|
|
</label>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<div class="form-check">
|
|
<input class="form-check-input" type="checkbox" name="preserve_logs" id="preserve-logs" checked>
|
|
<label class="form-check-label" for="preserve-logs">
|
|
Preserve communication logs
|
|
</label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Action Buttons -->
|
|
<div class="d-flex justify-content-between mt-4">
|
|
<div>
|
|
<a href="{% url 'patients:emergency_contact_detail' object.pk %}" class="btn btn-secondary">
|
|
<i class="fa fa-arrow-left me-2"></i>Cancel
|
|
</a>
|
|
<a href="{% url 'patients:emergency_contact_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 Emergency Contact
|
|
</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 the emergency contact "{{ object.name }}"?';
|
|
confirmText += '\n\nPatient: {{ object.patient.get_full_name }}';
|
|
confirmText += '\nRelationship: {{ object.get_relationship_display }}';
|
|
{% if object.is_primary %}
|
|
confirmText += '\n\nWARNING: This is the PRIMARY emergency contact!';
|
|
{% endif %}
|
|
{% if object.can_make_medical_decisions %}
|
|
confirmText += '\n\nWARNING: This contact is authorized for MEDICAL DECISIONS!';
|
|
{% endif %}
|
|
{% if object.patient.emergency_contacts.count == 1 %}
|
|
confirmText += '\n\nWARNING: This is the patient\'s ONLY emergency contact!';
|
|
{% endif %}
|
|
confirmText += '\n\nThis action cannot be undone and may impact patient safety.';
|
|
|
|
if (!confirm(confirmText)) {
|
|
e.preventDefault();
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
{% endblock %}
|
|
|