hospital-management/templates/operating_theatre/cases/surgical_case_confirm_delete.html
2025-08-12 13:33:25 +03:00

497 lines
27 KiB
HTML

{% extends "base.html" %}
{% load static %}
{% block title %}Delete Surgical Case - Operating Theatre{% 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 'operating_theatre:dashboard' %}">Operating Theatre</a></li>
<li class="breadcrumb-item"><a href="{% url 'operating_theatre:surgical_case_list' %}">Surgical Cases</a></li>
<li class="breadcrumb-item active">Delete Confirmation</li>
</ol>
<!-- END breadcrumb -->
<!-- BEGIN page-header -->
<h1 class="page-header">
Delete Surgical Case
<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 Case 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 surgical case. This action cannot be undone and will significantly impact patient care, surgical scheduling, and hospital operations.</p>
</div>
<div class="row mb-4">
<div class="col-md-6">
<h6>Case Details:</h6>
<table class="table table-borderless">
<tr>
<td class="fw-bold" width="150">Case Number:</td>
<td><code>{{ object.case_number }}</code></td>
</tr>
<tr>
<td class="fw-bold">Patient:</td>
<td>{{ object.patient.get_full_name }}</td>
</tr>
<tr>
<td class="fw-bold">Patient ID:</td>
<td>{{ object.patient.patient_id }}</td>
</tr>
<tr>
<td class="fw-bold">Procedure:</td>
<td>{{ object.procedure_name }}</td>
</tr>
<tr>
<td class="fw-bold">Primary Surgeon:</td>
<td>{{ object.primary_surgeon.get_full_name }}</td>
</tr>
<tr>
<td class="fw-bold">Operating Room:</td>
<td>{{ object.operating_room.name }}</td>
</tr>
<tr>
<td class="fw-bold">Priority:</td>
<td>
<span class="badge bg-{% if object.priority == 'EMERGENCY' %}danger{% elif object.priority == 'URGENT' %}warning{% else %}primary{% endif %}">
{{ object.get_priority_display }}
</span>
</td>
</tr>
<tr>
<td class="fw-bold">Status:</td>
<td>
<span class="badge bg-{% if object.status == 'SCHEDULED' %}info{% elif object.status == 'IN_PROGRESS' %}warning{% elif object.status == 'COMPLETED' %}success{% else %}secondary{% endif %}">
{{ object.get_status_display }}
</span>
</td>
</tr>
</table>
</div>
<div class="col-md-6">
<h6>Scheduling Information:</h6>
<table class="table table-borderless">
<tr>
<td class="fw-bold" width="150">Scheduled Date:</td>
<td>{{ object.scheduled_start_time|date:"M d, Y" }}</td>
</tr>
<tr>
<td class="fw-bold">Scheduled Time:</td>
<td>{{ object.scheduled_start_time|time:"H:i" }} - {{ object.scheduled_end_time|time:"H:i" }}</td>
</tr>
<tr>
<td class="fw-bold">Duration:</td>
<td>{{ object.estimated_duration }} minutes</td>
</tr>
<tr>
<td class="fw-bold">Surgery Type:</td>
<td>{{ object.get_surgery_type_display }}</td>
</tr>
<tr>
<td class="fw-bold">Created:</td>
<td>{{ object.created_at|date:"M d, Y H:i" }}</td>
</tr>
{% if object.actual_start_time %}
<tr>
<td class="fw-bold">Started:</td>
<td>{{ object.actual_start_time|date:"M d, Y H:i" }}</td>
</tr>
{% endif %}
{% if object.actual_end_time %}
<tr>
<td class="fw-bold">Completed:</td>
<td>{{ object.actual_end_time|date:"M d, Y H:i" }}</td>
</tr>
{% endif %}
</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 Care:</strong> Surgery scheduling and patient preparation will be affected</li>
<li><strong>Surgical Team:</strong> {{ object.surgical_team.count|add:"2" }} team members will be impacted</li>
<li><strong>Operating Room:</strong> Room {{ object.operating_room.name }} schedule will be freed</li>
<li><strong>Equipment:</strong> {{ object.equipment_required.count }} equipment reservations will be cancelled</li>
<li><strong>Supplies:</strong> {{ object.supplies_required.count }} supply allocations will be released</li>
<li><strong>Billing:</strong> Associated billing records and insurance pre-authorizations will be affected</li>
<li><strong>Audit Trail:</strong> Case history and documentation will be permanently lost</li>
</ul>
</div>
<!-- Status-Specific Warnings -->
{% if object.status == 'IN_PROGRESS' %}
<div class="alert alert-danger mb-4">
<h6 class="alert-heading">
<i class="fa fa-exclamation-triangle me-2"></i>Surgery In Progress Warning
</h6>
<p class="mb-2">This surgery is currently in progress. Deleting it will:</p>
<ul class="mb-0">
<li>Disrupt ongoing surgical procedures</li>
<li>Create confusion in the operating room</li>
<li>Potentially compromise patient safety</li>
<li>Violate surgical documentation requirements</li>
<li>Impact real-time monitoring and tracking</li>
</ul>
</div>
{% endif %}
{% if object.status == 'COMPLETED' %}
<div class="alert alert-danger mb-4">
<h6 class="alert-heading">
<i class="fa fa-check-circle me-2"></i>Completed Surgery Warning
</h6>
<p class="mb-2">This surgery has been completed. Deleting it will:</p>
<ul class="mb-0">
<li>Remove critical surgical documentation</li>
<li>Impact medical record integrity and continuity of care</li>
<li>Affect quality assurance and outcome tracking</li>
<li>Potentially violate regulatory and accreditation requirements</li>
<li>Compromise billing and insurance claim processing</li>
<li>Remove important data for surgical statistics and reporting</li>
</ul>
</div>
{% endif %}
{% if object.priority == 'EMERGENCY' %}
<div class="alert alert-danger mb-4">
<h6 class="alert-heading">
<i class="fa fa-ambulance me-2"></i>Emergency Surgery Warning
</h6>
<p class="mb-0">This is an emergency surgery case. Deleting emergency cases may violate hospital protocols and regulatory requirements for emergency care documentation.</p>
</div>
{% endif %}
{% if object.priority == 'URGENT' %}
<div class="alert alert-warning mb-4">
<h6 class="alert-heading">
<i class="fa fa-clock me-2"></i>Urgent Surgery Warning
</h6>
<p class="mb-0">This is an urgent surgery case. Deleting urgent cases may significantly impact patient care timelines and should only be done in exceptional circumstances.</p>
</div>
{% endif %}
<!-- Surgical Team Impact -->
{% if object.surgical_team.count > 0 %}
<div class="alert alert-warning mb-4">
<h6 class="alert-heading">
<i class="fa fa-users me-2"></i>Surgical Team Impact
</h6>
<p class="mb-2">This case involves {{ object.surgical_team.count|add:"2" }} team members:</p>
<ul class="mb-0">
<li>Primary Surgeon: {{ object.primary_surgeon.get_full_name }}</li>
{% if object.anesthesiologist %}
<li>Anesthesiologist: {{ object.anesthesiologist.get_full_name }}</li>
{% endif %}
{% for team_member in object.surgical_team.all %}
<li>{{ team_member.role }}: {{ team_member.staff_member.get_full_name }}</li>
{% endfor %}
</ul>
<p class="mt-2 mb-0">All team members will need to be notified of the cancellation.</p>
</div>
{% endif %}
<!-- Equipment and Supplies Impact -->
{% if object.equipment_required.count > 0 or object.supplies_required.count > 0 %}
<div class="alert alert-info mb-4">
<h6 class="alert-heading">
<i class="fa fa-tools me-2"></i>Equipment & Supplies Impact
</h6>
<div class="row">
{% if object.equipment_required.count > 0 %}
<div class="col-md-6">
<p class="mb-1"><strong>Equipment ({{ object.equipment_required.count }} items):</strong></p>
<ul class="small mb-0">
{% for equipment in object.equipment_required.all|slice:":5" %}
<li>{{ equipment.name }}</li>
{% endfor %}
{% if object.equipment_required.count > 5 %}
<li class="text-muted">+{{ object.equipment_required.count|add:"-5" }} more items...</li>
{% endif %}
</ul>
</div>
{% endif %}
{% if object.supplies_required.count > 0 %}
<div class="col-md-6">
<p class="mb-1"><strong>Supplies ({{ object.supplies_required.count }} items):</strong></p>
<ul class="small mb-0">
{% for supply in object.supplies_required.all|slice:":5" %}
<li>{{ supply.item.name }} ({{ supply.quantity }})</li>
{% endfor %}
{% if object.supplies_required.count > 5 %}
<li class="text-muted">+{{ object.supplies_required.count|add:"-5" }} more items...</li>
{% endif %}
</ul>
</div>
{% endif %}
</div>
</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.surgical_team.count|add:"2" }}</div>
<div class="small text-muted">Team Members</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.equipment_required.count }}</div>
<div class="small text-muted">Equipment Items</div>
</div>
</div>
<div class="col-md-3">
<div class="text-center p-3 border rounded">
<div class="fs-24px fw-bold text-info">{{ object.supplies_required.count }}</div>
<div class="small text-muted">Supply Items</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.estimated_duration }}</div>
<div class="small text-muted">Minutes</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-times text-warning me-2"></i>
<a href="{% url 'operating_theatre:surgical_case_cancel' object.pk %}" class="text-decoration-none">
Cancel the surgery
</a>
</li>
<li class="mb-2">
<i class="fa fa-calendar text-info me-2"></i>
<a href="{% url 'operating_theatre:surgical_case_reschedule' object.pk %}" class="text-decoration-none">
Reschedule the surgery
</a>
</li>
</ul>
</div>
<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 'operating_theatre:surgical_case_update' object.pk %}" class="text-decoration-none">
Modify the case details
</a>
</li>
<li class="mb-2">
<i class="fa fa-pause text-secondary me-2"></i>
Put case on hold
</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 surgical case and cannot be undone
</label>
</div>
{% if object.status == 'IN_PROGRESS' %}
<div class="form-check mb-3">
<input class="form-check-input" type="checkbox" id="confirm-in-progress" required>
<label class="form-check-label" for="confirm-in-progress">
I acknowledge that this surgery is in progress and deleting it may compromise patient safety
</label>
</div>
{% endif %}
{% if object.status == 'COMPLETED' %}
<div class="form-check mb-3">
<input class="form-check-input" type="checkbox" id="confirm-completed" required>
<label class="form-check-label" for="confirm-completed">
I acknowledge that this surgery is completed and deleting it will remove critical medical documentation
</label>
</div>
{% endif %}
{% if object.priority == 'EMERGENCY' %}
<div class="form-check mb-3">
<input class="form-check-input" type="checkbox" id="confirm-emergency" required>
<label class="form-check-label" for="confirm-emergency">
I understand that this is an emergency case and deleting it may violate regulatory requirements
</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_CASE">Duplicate case</option>
<option value="WRONG_PATIENT">Wrong patient</option>
<option value="WRONG_PROCEDURE">Wrong procedure</option>
<option value="PATIENT_REFUSAL">Patient refusal</option>
<option value="MEDICAL_CONTRAINDICATION">Medical contraindication</option>
<option value="SURGEON_UNAVAILABLE">Surgeon unavailable</option>
<option value="EQUIPMENT_FAILURE">Equipment failure</option>
<option value="ADMINISTRATIVE_ERROR">Administrative error</option>
<option value="INSURANCE_DENIAL">Insurance denial</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 surgical case 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_case" id="backup-case" checked>
<label class="form-check-label" for="backup-case">
Backup case information 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" checked>
<label class="form-check-label" for="notify-team">
Notify surgical team members
</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="notify_patient" id="notify-patient" checked>
<label class="form-check-label" for="notify-patient">
Notify patient of cancellation
</label>
</div>
</div>
<div class="col-md-6">
<div class="form-check">
<input class="form-check-input" type="checkbox" name="release_resources" id="release-resources" checked>
<label class="form-check-label" for="release-resources">
Release equipment and supplies
</label>
</div>
</div>
</div>
</div>
</div>
<!-- Action Buttons -->
<div class="d-flex justify-content-between mt-4">
<div>
<a href="{% url 'operating_theatre:surgical_case_detail' object.pk %}" class="btn btn-secondary">
<i class="fa fa-arrow-left me-2"></i>Cancel
</a>
<a href="{% url 'operating_theatre:surgical_case_cancel' object.pk %}" class="btn btn-warning ms-2">
<i class="fa fa-times me-2"></i>Cancel Surgery Instead
</a>
</div>
<button type="submit" class="btn btn-danger" id="delete-btn" disabled>
<i class="fa fa-trash me-2"></i>Delete Surgical Case
</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 surgical case "{{ object.case_number }}"?';
confirmText += '\n\nPatient: {{ object.patient.get_full_name }}';
confirmText += '\nProcedure: {{ object.procedure_name }}';
{% if object.status == 'IN_PROGRESS' %}
confirmText += '\n\nWARNING: This surgery is IN PROGRESS!';
{% endif %}
{% if object.status == 'COMPLETED' %}
confirmText += '\n\nWARNING: This surgery is COMPLETED and contains critical medical documentation!';
{% endif %}
{% if object.priority == 'EMERGENCY' %}
confirmText += '\n\nWARNING: This is an EMERGENCY case!';
{% endif %}
confirmText += '\n\nThis action cannot be undone and will impact patient care.';
if (!confirm(confirmText)) {
e.preventDefault();
}
});
});
</script>
{% endblock %}