381 lines
19 KiB
HTML
381 lines
19 KiB
HTML
{% extends "base.html" %}
|
|
{% load static %}
|
|
|
|
{% block title %}Delete Discharge Record{% endblock %}
|
|
|
|
{% block content %}
|
|
<div class="d-flex align-items-center mb-3">
|
|
<div>
|
|
<ol class="breadcrumb">
|
|
<li class="breadcrumb-item"><a href="{% url 'inpatients:dashboard' %}">Inpatients</a></li>
|
|
<li class="breadcrumb-item"><a href="{% url 'inpatients:discharge_list' %}">Discharges</a></li>
|
|
<li class="breadcrumb-item"><a href="{% url 'inpatients:discharge_detail' object.pk %}">Discharge #{{ object.pk }}</a></li>
|
|
<li class="breadcrumb-item active">Delete</li>
|
|
</ol>
|
|
<h1 class="page-header mb-0">Delete Discharge Record</h1>
|
|
</div>
|
|
<div class="ms-auto">
|
|
<a href="{% url 'inpatients:discharge_detail' object.pk %}" class="btn btn-secondary">
|
|
<i class="fas fa-arrow-left me-2"></i>Back to Discharge
|
|
</a>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row justify-content-center">
|
|
<div class="col-xl-8">
|
|
<div class="card">
|
|
<div class="card-header bg-danger text-white">
|
|
<h4 class="card-title mb-0">
|
|
<i class="fas fa-exclamation-triangle me-2"></i>
|
|
Confirm Discharge Record Deletion
|
|
</h4>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="alert alert-warning">
|
|
<h5 class="alert-heading">
|
|
<i class="fas fa-exclamation-triangle me-2"></i>
|
|
Are you sure you want to delete this discharge record?
|
|
</h5>
|
|
<p class="mb-0">
|
|
This action cannot be undone. The discharge record and all associated data will be permanently removed from the system.
|
|
</p>
|
|
</div>
|
|
|
|
<!-- Discharge Details -->
|
|
<div class="row mb-4">
|
|
<div class="col-md-6">
|
|
<div class="card bg-light">
|
|
<div class="card-body">
|
|
<h6 class="card-title">
|
|
<i class="fas fa-user-injured me-2"></i>Patient Information
|
|
</h6>
|
|
<div class="mb-2">
|
|
<strong>Patient:</strong> {{ object.admission.patient.get_full_name }}
|
|
</div>
|
|
<div class="mb-2">
|
|
<strong>MRN:</strong> {{ object.admission.patient.medical_record_number }}
|
|
</div>
|
|
<div class="mb-2">
|
|
<strong>DOB:</strong> {{ object.admission.patient.date_of_birth|date:"M d, Y" }}
|
|
</div>
|
|
<div>
|
|
<strong>Age:</strong> {{ object.admission.patient.age }} years
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<div class="card bg-light">
|
|
<div class="card-body">
|
|
<h6 class="card-title">
|
|
<i class="fas fa-sign-out-alt me-2"></i>Discharge Information
|
|
</h6>
|
|
<div class="mb-2">
|
|
<strong>Discharge Date:</strong> {{ object.discharge_date|date:"M d, Y g:i A" }}
|
|
</div>
|
|
<div class="mb-2">
|
|
<strong>Discharge Type:</strong> {{ object.get_discharge_type_display }}
|
|
</div>
|
|
<div class="mb-2">
|
|
<strong>Status:</strong>
|
|
<span class="badge bg-{% if object.status == 'completed' %}success{% elif object.status == 'pending' %}warning{% else %}info{% endif %}">
|
|
{{ object.get_status_display }}
|
|
</span>
|
|
</div>
|
|
<div>
|
|
<strong>Discharge ID:</strong> {{ object.pk }}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Admission Details -->
|
|
<div class="row mb-4">
|
|
<div class="col-12">
|
|
<div class="card bg-light">
|
|
<div class="card-body">
|
|
<h6 class="card-title">
|
|
<i class="fas fa-hospital me-2"></i>Related Admission Information
|
|
</h6>
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<div class="mb-2">
|
|
<strong>Admission Date:</strong> {{ object.admission.admission_date|date:"M d, Y g:i A" }}
|
|
</div>
|
|
<div class="mb-2">
|
|
<strong>Length of Stay:</strong> {{ object.length_of_stay }} days
|
|
</div>
|
|
<div>
|
|
<strong>Ward:</strong> {{ object.admission.ward.name }}
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<div class="mb-2">
|
|
<strong>Bed:</strong> {{ object.admission.bed.bed_number }}
|
|
</div>
|
|
<div class="mb-2">
|
|
<strong>Attending Physician:</strong> {{ object.admission.attending_physician.get_full_name }}
|
|
</div>
|
|
<div>
|
|
<strong>Admission Diagnosis:</strong> {{ object.admission.primary_diagnosis }}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
{% if object.discharge_summary %}
|
|
<div class="row mb-4">
|
|
<div class="col-12">
|
|
<div class="card bg-light">
|
|
<div class="card-body">
|
|
<h6 class="card-title">
|
|
<i class="fas fa-file-medical me-2"></i>Discharge Summary
|
|
</h6>
|
|
<div class="alert alert-info mb-0">
|
|
{{ object.discharge_summary|truncatewords:50 }}
|
|
{% if object.discharge_summary|wordcount > 50 %}
|
|
<div class="mt-2">
|
|
<small class="text-muted">Summary truncated for display...</small>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
|
|
{% if object.discharge_medications.exists %}
|
|
<div class="row mb-4">
|
|
<div class="col-12">
|
|
<div class="card bg-light">
|
|
<div class="card-body">
|
|
<h6 class="card-title">
|
|
<i class="fas fa-pills me-2"></i>Discharge Medications
|
|
</h6>
|
|
<div class="row">
|
|
{% for medication in object.discharge_medications.all|slice:":6" %}
|
|
<div class="col-md-6 mb-2">
|
|
<div class="d-flex align-items-center">
|
|
<i class="fas fa-pill text-primary me-2"></i>
|
|
<div>
|
|
<strong>{{ medication.medication.name }}</strong>
|
|
<div class="small text-muted">{{ medication.dosage }} - {{ medication.frequency }}</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endfor %}
|
|
{% if object.discharge_medications.count > 6 %}
|
|
<div class="col-12">
|
|
<small class="text-muted">And {{ object.discharge_medications.count|add:"-6" }} more medications...</small>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<!-- Deletion Form -->
|
|
<form method="post">
|
|
{% csrf_token %}
|
|
|
|
<div class="mb-3">
|
|
<label for="deletion_reason" class="form-label">
|
|
<strong>Reason for Deletion *</strong>
|
|
</label>
|
|
<select class="form-select" id="deletion_reason" name="deletion_reason" required>
|
|
<option value="">Select a reason</option>
|
|
<option value="data_error">Data Entry Error</option>
|
|
<option value="duplicate_record">Duplicate Record</option>
|
|
<option value="patient_request">Patient Request</option>
|
|
<option value="privacy_compliance">Privacy Compliance</option>
|
|
<option value="system_error">System Error</option>
|
|
<option value="incorrect_discharge">Incorrect Discharge</option>
|
|
<option value="administrative">Administrative Correction</option>
|
|
<option value="other">Other</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label for="deletion_notes" class="form-label">
|
|
<strong>Additional Notes</strong>
|
|
</label>
|
|
<textarea class="form-control"
|
|
id="deletion_notes"
|
|
name="deletion_notes"
|
|
rows="3"
|
|
placeholder="Provide additional details about why this discharge record is being deleted..."></textarea>
|
|
<div class="form-text">
|
|
These notes will be recorded for audit purposes and compliance.
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-check mb-3">
|
|
<input class="form-check-input"
|
|
type="checkbox"
|
|
id="confirm_deletion"
|
|
name="confirm_deletion"
|
|
required>
|
|
<label class="form-check-label" for="confirm_deletion">
|
|
I understand that this action cannot be undone and confirm the deletion of this discharge record.
|
|
</label>
|
|
</div>
|
|
|
|
<div class="form-check mb-3">
|
|
<input class="form-check-input"
|
|
type="checkbox"
|
|
id="notify_stakeholders"
|
|
name="notify_stakeholders">
|
|
<label class="form-check-label" for="notify_stakeholders">
|
|
Notify relevant stakeholders (attending physician, nursing staff, billing department) about this deletion.
|
|
</label>
|
|
</div>
|
|
|
|
<div class="alert alert-info">
|
|
<h6 class="alert-heading">
|
|
<i class="fas fa-info-circle me-2"></i>What happens when you delete this discharge record?
|
|
</h6>
|
|
<ul class="mb-0">
|
|
<li>The discharge record will be permanently removed from the system</li>
|
|
<li>The associated admission will be marked as "active" again</li>
|
|
<li>The patient's bed will be marked as occupied</li>
|
|
<li>Discharge medications and instructions will be deleted</li>
|
|
<li>Billing records may be affected and require manual adjustment</li>
|
|
<li>This action will be logged in the audit trail</li>
|
|
<li>Follow-up appointments may need to be rescheduled</li>
|
|
<li>Insurance claims may need to be updated</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<div class="d-flex justify-content-between">
|
|
<a href="{% url 'inpatients:discharge_detail' object.pk %}" class="btn btn-secondary">
|
|
<i class="fas fa-times me-2"></i>Cancel
|
|
</a>
|
|
<button type="submit" class="btn btn-danger" onclick="return confirmDeletion()">
|
|
<i class="fas fa-trash me-2"></i>Delete Discharge Record
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Impact Warning -->
|
|
{% if object.status == 'completed' %}
|
|
<div class="card mt-4">
|
|
<div class="card-header bg-warning text-dark">
|
|
<h5 class="card-title mb-0">
|
|
<i class="fas fa-exclamation-triangle me-2"></i>
|
|
Important Considerations
|
|
</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="alert alert-warning">
|
|
<strong>Completed Discharge:</strong> This discharge has been completed. Deleting it may affect:
|
|
<ul class="mb-0 mt-2">
|
|
<li>Billing and insurance claims that have already been processed</li>
|
|
<li>Quality metrics and hospital statistics</li>
|
|
<li>Regulatory reporting requirements</li>
|
|
<li>Patient care continuity and follow-up schedules</li>
|
|
</ul>
|
|
</div>
|
|
|
|
{% if object.follow_up_appointments.exists %}
|
|
<div class="alert alert-info">
|
|
<strong>Follow-up Appointments:</strong> This discharge has {{ object.follow_up_appointments.count }} associated follow-up appointment{{ object.follow_up_appointments.count|pluralize }}.
|
|
These may need to be rescheduled or cancelled.
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<!-- Related Information -->
|
|
<div class="card mt-4">
|
|
<div class="card-header">
|
|
<h5 class="card-title">
|
|
<i class="fas fa-link me-2"></i>
|
|
Related Information
|
|
</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<h6>Discharge Details</h6>
|
|
<ul class="list-unstyled">
|
|
<li><strong>Discharge ID:</strong> {{ object.pk }}</li>
|
|
<li><strong>Created:</strong> {{ object.created_at|date:"M d, Y g:i A" }}</li>
|
|
<li><strong>Last Updated:</strong> {{ object.updated_at|date:"M d, Y g:i A" }}</li>
|
|
<li><strong>Created By:</strong> {{ object.created_by.get_full_name|default:"System" }}</li>
|
|
</ul>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<h6>System Information</h6>
|
|
<ul class="list-unstyled">
|
|
<li><strong>Admission ID:</strong> {{ object.admission.pk }}</li>
|
|
<li><strong>Patient ID:</strong> {{ object.admission.patient.pk }}</li>
|
|
{% if object.discharge_medications.exists %}
|
|
<li><strong>Medications:</strong> {{ object.discharge_medications.count }} prescribed</li>
|
|
{% endif %}
|
|
{% if object.follow_up_appointments.exists %}
|
|
<li><strong>Follow-ups:</strong> {{ object.follow_up_appointments.count }} scheduled</li>
|
|
{% endif %}
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
function confirmDeletion() {
|
|
const reason = document.getElementById('deletion_reason').value;
|
|
const confirmed = document.getElementById('confirm_deletion').checked;
|
|
|
|
if (!reason) {
|
|
alert('Please select a reason for deletion.');
|
|
return false;
|
|
}
|
|
|
|
if (!confirmed) {
|
|
alert('Please confirm that you understand this action cannot be undone.');
|
|
return false;
|
|
}
|
|
|
|
const dischargeId = "{{ object.pk }}";
|
|
const patientName = "{{ object.admission.patient.get_full_name }}";
|
|
const dischargeDate = "{{ object.discharge_date|date:'M d, Y' }}";
|
|
|
|
const message = `Are you absolutely sure you want to delete this discharge record?\n\nPatient: ${patientName}\nDischarge Date: ${dischargeDate}\nDischarge ID: ${dischargeId}\n\nThis action cannot be undone and may affect billing, statistics, and patient care continuity.`;
|
|
|
|
return confirm(message);
|
|
}
|
|
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
// Auto-focus on deletion reason
|
|
document.getElementById('deletion_reason').focus();
|
|
|
|
// Show/hide additional notes based on reason
|
|
const reasonSelect = document.getElementById('deletion_reason');
|
|
const notesTextarea = document.getElementById('deletion_notes');
|
|
|
|
reasonSelect.addEventListener('change', function() {
|
|
if (this.value === 'other') {
|
|
notesTextarea.required = true;
|
|
notesTextarea.placeholder = 'Please specify the reason for deletion...';
|
|
} else {
|
|
notesTextarea.required = false;
|
|
notesTextarea.placeholder = 'Provide additional details about why this discharge record is being deleted...';
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
{% endblock %}
|
|
|