378 lines
19 KiB
HTML
378 lines
19 KiB
HTML
{% extends "base.html" %}
|
|
{% load static %}
|
|
|
|
{% block title %}Delete Surgery - {{ object.procedure_name }}{% 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 'inpatients:dashboard' %}">Inpatients</a></li>
|
|
<li class="breadcrumb-item"><a href="{% url 'inpatients:surgery_list' %}">Surgeries</a></li>
|
|
<li class="breadcrumb-item"><a href="{% url 'inpatients:surgery_detail' object.pk %}">{{ object.procedure_name }}</a></li>
|
|
<li class="breadcrumb-item active">Delete</li>
|
|
</ol>
|
|
<!-- END breadcrumb -->
|
|
|
|
<!-- BEGIN page-header -->
|
|
<h1 class="page-header">
|
|
<i class="fa fa-exclamation-triangle text-danger me-2"></i>
|
|
Delete Surgery
|
|
</h1>
|
|
<!-- END page-header -->
|
|
|
|
<div class="row">
|
|
<div class="col-xl-8">
|
|
<!-- BEGIN panel -->
|
|
<div class="panel panel-inverse">
|
|
<div class="panel-heading">
|
|
<h4 class="panel-title">Confirm Surgery Deletion</h4>
|
|
<div class="panel-heading-btn">
|
|
<a href="javascript:;" class="btn btn-xs btn-icon btn-default" data-toggle="panel-expand"><i class="fa fa-expand"></i></a>
|
|
</div>
|
|
</div>
|
|
<div class="panel-body">
|
|
<div class="alert alert-danger">
|
|
<h5><i class="fa fa-exclamation-triangle me-2"></i>Warning: Permanent Deletion</h5>
|
|
<p class="mb-0">
|
|
You are about to permanently delete this surgery record. This action cannot be undone and will remove all associated data.
|
|
</p>
|
|
</div>
|
|
|
|
<!-- Surgery Information -->
|
|
<div class="card mb-4">
|
|
<div class="card-header bg-light">
|
|
<h6 class="card-title mb-0">Surgery to be Deleted</h6>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<table class="table table-borderless table-sm">
|
|
<tr>
|
|
<td class="fw-bold" width="140">Patient:</td>
|
|
<td>{{ object.patient.get_full_name }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">Procedure:</td>
|
|
<td>{{ object.procedure_name }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">Surgeon:</td>
|
|
<td>Dr. {{ object.surgeon.get_full_name }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">Status:</td>
|
|
<td>
|
|
<span class="badge bg-{{ object.get_status_color }}">
|
|
{{ object.get_status_display }}
|
|
</span>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<table class="table table-borderless table-sm">
|
|
<tr>
|
|
<td class="fw-bold" width="140">Scheduled Date:</td>
|
|
<td>{{ object.scheduled_date|date:"M d, Y" }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">Start Time:</td>
|
|
<td>{{ object.scheduled_start_time|time:"H:i" }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">Operating Room:</td>
|
|
<td>{{ object.operating_room|default:"Not assigned" }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">Urgency:</td>
|
|
<td>
|
|
<span class="badge bg-{{ object.get_urgency_color }}">
|
|
{{ object.get_urgency_level_display }}
|
|
</span>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Impact Assessment -->
|
|
<div class="card mb-4">
|
|
<div class="card-header bg-warning bg-opacity-10">
|
|
<h6 class="card-title mb-0 text-warning">
|
|
<i class="fa fa-exclamation-triangle me-2"></i>Impact Assessment
|
|
</h6>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<h6>Data to be Deleted:</h6>
|
|
<ul class="list-unstyled">
|
|
<li><i class="fa fa-check text-danger me-2"></i>Surgery record and all details</li>
|
|
<li><i class="fa fa-check text-danger me-2"></i>Pre-operative notes</li>
|
|
<li><i class="fa fa-check text-danger me-2"></i>Operative notes (if any)</li>
|
|
<li><i class="fa fa-check text-danger me-2"></i>Post-operative notes (if any)</li>
|
|
<li><i class="fa fa-check text-danger me-2"></i>Team assignments</li>
|
|
<li><i class="fa fa-check text-danger me-2"></i>Special instructions</li>
|
|
</ul>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<h6>Potential Consequences:</h6>
|
|
<ul class="list-unstyled">
|
|
<li><i class="fa fa-exclamation text-warning me-2"></i>Loss of surgical history</li>
|
|
<li><i class="fa fa-exclamation text-warning me-2"></i>Billing record inconsistencies</li>
|
|
<li><i class="fa fa-exclamation text-warning me-2"></i>Audit trail gaps</li>
|
|
<li><i class="fa fa-exclamation text-warning me-2"></i>Team schedule disruption</li>
|
|
<li><i class="fa fa-exclamation text-warning me-2"></i>Operating room availability changes</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
|
|
{% if object.status == 'completed' %}
|
|
<div class="alert alert-danger mt-3">
|
|
<strong>Critical Warning:</strong> This surgery has been completed. Deleting completed surgical records may violate medical record retention policies and regulatory requirements.
|
|
</div>
|
|
{% endif %}
|
|
|
|
{% if object.status == 'in_progress' %}
|
|
<div class="alert alert-danger mt-3">
|
|
<strong>Critical Warning:</strong> This surgery is currently in progress. Deleting an active surgery record is not recommended and may cause system inconsistencies.
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Alternative Actions -->
|
|
<div class="card mb-4">
|
|
<div class="card-header bg-info bg-opacity-10">
|
|
<h6 class="card-title mb-0 text-info">
|
|
<i class="fa fa-lightbulb me-2"></i>Alternative Actions
|
|
</h6>
|
|
</div>
|
|
<div class="card-body">
|
|
<p>Consider these alternatives instead of permanent deletion:</p>
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<div class="d-grid gap-2">
|
|
{% if object.status == 'scheduled' %}
|
|
<a href="{% url 'inpatients:surgery_update_status' object.pk %}?status=cancelled" class="btn btn-warning btn-sm">
|
|
<i class="fa fa-times me-2"></i>Cancel Surgery
|
|
</a>
|
|
{% endif %}
|
|
<a href="{% url 'inpatients:surgery_update' object.pk %}" class="btn btn-primary btn-sm">
|
|
<i class="fa fa-edit me-2"></i>Edit Surgery Details
|
|
</a>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<div class="d-grid gap-2">
|
|
<button class="btn btn-secondary btn-sm" onclick="archiveSurgery()">
|
|
<i class="fa fa-archive me-2"></i>Archive Surgery
|
|
</button>
|
|
<a href="{% url 'inpatients:surgery_detail' object.pk %}" class="btn btn-info btn-sm">
|
|
<i class="fa fa-eye me-2"></i>Review Details
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Deletion Form -->
|
|
<form method="post" id="delete-form">
|
|
{% csrf_token %}
|
|
|
|
{% if object.status == 'completed' %}
|
|
<div class="mb-3">
|
|
<label class="form-label" for="deletion_reason">Reason for Deletion <span class="text-danger">*</span></label>
|
|
<textarea class="form-control" id="deletion_reason" name="deletion_reason" rows="3" required
|
|
placeholder="Please provide a detailed reason for deleting this completed surgery record..."></textarea>
|
|
<div class="form-text">Required for completed surgeries due to regulatory compliance.</div>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<div class="form-check mb-4">
|
|
<input class="form-check-input" type="checkbox" id="confirm_deletion" name="confirm_deletion" required>
|
|
<label class="form-check-label fw-bold text-danger" for="confirm_deletion">
|
|
I understand that this action is permanent and cannot be undone
|
|
</label>
|
|
</div>
|
|
|
|
<div class="d-flex justify-content-between">
|
|
<a href="{% url 'inpatients:surgery_detail' object.pk %}" class="btn btn-default">
|
|
<i class="fa fa-arrow-left me-2"></i>Cancel
|
|
</a>
|
|
<button type="submit" class="btn btn-danger" id="delete-btn" disabled>
|
|
<i class="fa fa-trash me-2"></i>Delete Surgery Permanently
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
<!-- END panel -->
|
|
</div>
|
|
|
|
<div class="col-xl-4">
|
|
<!-- BEGIN panel -->
|
|
<div class="panel panel-inverse">
|
|
<div class="panel-heading">
|
|
<h4 class="panel-title">Deletion Guidelines</h4>
|
|
<div class="panel-heading-btn">
|
|
<a href="javascript:;" class="btn btn-xs btn-icon btn-default" data-toggle="panel-expand"><i class="fa fa-expand"></i></a>
|
|
<a href="javascript:;" class="btn btn-xs btn-icon btn-default" data-toggle="panel-collapse"><i class="fa fa-minus"></i></a>
|
|
</div>
|
|
</div>
|
|
<div class="panel-body">
|
|
<div class="alert alert-info">
|
|
<h6><i class="fa fa-info-circle me-2"></i>When to Delete</h6>
|
|
<ul class="mb-0 small">
|
|
<li>Duplicate entries created by error</li>
|
|
<li>Test records in development environment</li>
|
|
<li>Records created with incorrect patient information</li>
|
|
<li>Scheduled surgeries that were never performed</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<div class="alert alert-warning">
|
|
<h6><i class="fa fa-exclamation-triangle me-2"></i>When NOT to Delete</h6>
|
|
<ul class="mb-0 small">
|
|
<li>Completed surgical procedures</li>
|
|
<li>Surgeries with billing records</li>
|
|
<li>Records required for legal documentation</li>
|
|
<li>Procedures with complications or incidents</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<div class="alert alert-success">
|
|
<h6><i class="fa fa-shield me-2"></i>Data Protection</h6>
|
|
<ul class="mb-0 small">
|
|
<li>All deletions are logged for audit purposes</li>
|
|
<li>User permissions are verified before deletion</li>
|
|
<li>Backup copies may exist in system archives</li>
|
|
<li>Regulatory compliance is maintained</li>
|
|
</ul>
|
|
</div>
|
|
|
|
{% if object.status == 'completed' %}
|
|
<div class="alert alert-danger">
|
|
<h6><i class="fa fa-exclamation-circle me-2"></i>Compliance Notice</h6>
|
|
<p class="mb-0 small">
|
|
Deleting completed surgical records may violate healthcare regulations.
|
|
Ensure you have proper authorization and documented justification.
|
|
</p>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
<!-- END panel -->
|
|
|
|
<!-- BEGIN panel -->
|
|
<div class="panel panel-inverse">
|
|
<div class="panel-heading">
|
|
<h4 class="panel-title">Surgery Team</h4>
|
|
<div class="panel-heading-btn">
|
|
<a href="javascript:;" class="btn btn-xs btn-icon btn-default" data-toggle="panel-expand"><i class="fa fa-expand"></i></a>
|
|
<a href="javascript:;" class="btn btn-xs btn-icon btn-default" data-toggle="panel-collapse"><i class="fa fa-minus"></i></a>
|
|
</div>
|
|
</div>
|
|
<div class="panel-body">
|
|
<div class="small">
|
|
<div class="mb-2">
|
|
<strong>Primary Surgeon:</strong><br>
|
|
Dr. {{ object.surgeon.get_full_name }}
|
|
</div>
|
|
|
|
{% if object.assistant_surgeons.exists %}
|
|
<div class="mb-2">
|
|
<strong>Assistant Surgeons:</strong><br>
|
|
{% for surgeon in object.assistant_surgeons.all %}
|
|
Dr. {{ surgeon.get_full_name }}{% if not forloop.last %}, {% endif %}
|
|
{% endfor %}
|
|
</div>
|
|
{% endif %}
|
|
|
|
{% if object.anesthesiologist %}
|
|
<div class="mb-2">
|
|
<strong>Anesthesiologist:</strong><br>
|
|
Dr. {{ object.anesthesiologist.get_full_name }}
|
|
</div>
|
|
{% endif %}
|
|
|
|
{% if object.scrub_nurses.exists %}
|
|
<div class="mb-2">
|
|
<strong>Scrub Nurses:</strong><br>
|
|
{% for nurse in object.scrub_nurses.all %}
|
|
{{ nurse.get_full_name }}{% if not forloop.last %}, {% endif %}
|
|
{% endfor %}
|
|
</div>
|
|
{% endif %}
|
|
|
|
{% if object.circulating_nurses.exists %}
|
|
<div class="mb-2">
|
|
<strong>Circulating Nurses:</strong><br>
|
|
{% for nurse in object.circulating_nurses.all %}
|
|
{{ nurse.get_full_name }}{% if not forloop.last %}, {% endif %}
|
|
{% endfor %}
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- END panel -->
|
|
</div>
|
|
</div>
|
|
{% endblock %}
|
|
|
|
{% block js %}
|
|
<script>
|
|
$(document).ready(function() {
|
|
// Enable delete button only when confirmation is checked
|
|
$('#confirm_deletion').on('change', function() {
|
|
$('#delete-btn').prop('disabled', !this.checked);
|
|
});
|
|
|
|
// Form submission confirmation
|
|
$('#delete-form').on('submit', function(e) {
|
|
{% if object.status == 'completed' %}
|
|
if (!$('#deletion_reason').val().trim()) {
|
|
e.preventDefault();
|
|
toastr.error('Please provide a reason for deleting this completed surgery record.');
|
|
return false;
|
|
}
|
|
{% endif %}
|
|
|
|
if (!confirm('Are you absolutely sure you want to permanently delete this surgery record? This action cannot be undone.')) {
|
|
e.preventDefault();
|
|
return false;
|
|
}
|
|
});
|
|
});
|
|
|
|
function archiveSurgery() {
|
|
if (confirm('Archive this surgery record instead of deleting it?')) {
|
|
$.ajax({
|
|
url: '{% url "inpatients:surgery_archive" object.pk %}',
|
|
method: 'POST',
|
|
data: {
|
|
'csrfmiddlewaretoken': '{{ csrf_token }}'
|
|
},
|
|
success: function(response) {
|
|
if (response.success) {
|
|
toastr.success('Surgery archived successfully');
|
|
window.location.href = '{% url "inpatients:surgery_list" %}';
|
|
} else {
|
|
toastr.error('Failed to archive surgery');
|
|
}
|
|
},
|
|
error: function() {
|
|
toastr.error('An error occurred while archiving the surgery');
|
|
}
|
|
});
|
|
}
|
|
}
|
|
</script>
|
|
{% endblock %}
|
|
|