305 lines
15 KiB
HTML
305 lines
15 KiB
HTML
{% extends "base.html" %}
|
|
{% load static %}
|
|
|
|
{% block title %}Delete Bill {{ object.bill_number }} - {{ block.super }}{% endblock %}
|
|
|
|
{% block content %}
|
|
<div class="container-fluid">
|
|
<!-- Page Header -->
|
|
<div class="d-flex justify-content-between align-items-center mb-4">
|
|
<div>
|
|
<h1 class="h3 mb-1 text-danger">
|
|
<i class="fas fa-exclamation-triangle me-2"></i>Delete Medical Bill
|
|
</h1>
|
|
<nav aria-label="breadcrumb">
|
|
<ol class="breadcrumb mb-0">
|
|
<li class="breadcrumb-item"><a href="{% url 'billing:dashboard' %}">Billing</a></li>
|
|
<li class="breadcrumb-item"><a href="{% url 'billing:bill_list' %}">Medical Bills</a></li>
|
|
<li class="breadcrumb-item"><a href="{% url 'billing:bill_detail' object.bill_id %}">{{ object.bill_number }}</a></li>
|
|
<li class="breadcrumb-item active">Delete</li>
|
|
</ol>
|
|
</nav>
|
|
</div>
|
|
<div class="btn-group">
|
|
<a href="{% url 'billing:bill_detail' object.bill_id %}" class="btn btn-outline-secondary">
|
|
<i class="fas fa-arrow-left me-2"></i>Back to Bill
|
|
</a>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row justify-content-center">
|
|
<div class="col-lg-8">
|
|
<!-- Warning Alert -->
|
|
<div class="alert alert-danger mb-4">
|
|
<div class="d-flex align-items-center">
|
|
<div class="me-3">
|
|
<i class="fas fa-exclamation-triangle fa-2x"></i>
|
|
</div>
|
|
<div>
|
|
<h5 class="alert-heading mb-1">Warning: Permanent Deletion</h5>
|
|
<p class="mb-0">
|
|
You are about to permanently delete this medical bill. This action cannot be undone and will remove all associated data.
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Bill Information Card -->
|
|
<div class="card mb-4">
|
|
<div class="card-header bg-light">
|
|
<h5 class="mb-0">
|
|
<i class="fas fa-file-invoice me-2"></i>Bill to be Deleted
|
|
</h5>
|
|
</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">Bill Number:</td>
|
|
<td>{{ object.bill_number }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">Patient:</td>
|
|
<td>{{ object.patient.get_full_name }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">MRN:</td>
|
|
<td>{{ object.patient.mrn }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">Bill Date:</td>
|
|
<td>{{ object.bill_date|date:"M d, Y" }}</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<table class="table table-borderless table-sm">
|
|
<tr>
|
|
<td class="fw-bold">Total Amount:</td>
|
|
<td class="fw-bold text-primary">${{ object.total_amount|floatformat:2 }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">Status:</td>
|
|
<td>
|
|
{% if object.status == 'DRAFT' %}
|
|
<span class="badge bg-secondary">Draft</span>
|
|
{% elif object.status == 'PENDING' %}
|
|
<span class="badge bg-warning">Pending</span>
|
|
{% elif object.status == 'SUBMITTED' %}
|
|
<span class="badge bg-info">Submitted</span>
|
|
{% elif object.status == 'PARTIAL_PAID' %}
|
|
<span class="badge bg-primary">Partially Paid</span>
|
|
{% elif object.status == 'PAID' %}
|
|
<span class="badge bg-success">Paid</span>
|
|
{% elif object.status == 'OVERDUE' %}
|
|
<span class="badge bg-danger">Overdue</span>
|
|
{% elif object.status == 'COLLECTIONS' %}
|
|
<span class="badge bg-dark">Collections</span>
|
|
{% elif object.status == 'WRITTEN_OFF' %}
|
|
<span class="badge bg-secondary">Written Off</span>
|
|
{% elif object.status == 'CANCELLED' %}
|
|
<span class="badge bg-secondary">Cancelled</span>
|
|
{% endif %}
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">Created:</td>
|
|
<td>{{ object.created_at|date:"M d, Y" }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="fw-bold">Last Updated:</td>
|
|
<td>{{ object.updated_at|date:"M d, Y" }}</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Impact Assessment -->
|
|
<div class="card mb-4">
|
|
<div class="card-header bg-warning text-dark">
|
|
<h5 class="mb-0">
|
|
<i class="fas fa-impact me-2"></i>Deletion Impact
|
|
</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<h6 class="fw-bold text-danger">Will be Deleted:</h6>
|
|
<ul class="list-unstyled">
|
|
<li><i class="fas fa-times text-danger me-2"></i>Bill record and all line items</li>
|
|
<li><i class="fas fa-times text-danger me-2"></i>{{ object.payment_set.count }} associated payment(s)</li>
|
|
<li><i class="fas fa-times text-danger me-2"></i>{{ object.insuranceclaim_set.count }} insurance claim(s)</li>
|
|
<li><i class="fas fa-times text-danger me-2"></i>All billing history and notes</li>
|
|
<li><i class="fas fa-times text-danger me-2"></i>Financial reporting data</li>
|
|
</ul>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<h6 class="fw-bold text-success">Will be Preserved:</h6>
|
|
<ul class="list-unstyled">
|
|
<li><i class="fas fa-check text-success me-2"></i>Patient record and information</li>
|
|
<li><i class="fas fa-check text-success me-2"></i>Medical records and encounters</li>
|
|
<li><i class="fas fa-check text-success me-2"></i>Insurance information</li>
|
|
<li><i class="fas fa-check text-success me-2"></i>Provider and staff records</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Deletion Restrictions -->
|
|
{% if object.status not in 'DRAFT,CANCELLED' %}
|
|
<div class="card mb-4">
|
|
<div class="card-header bg-danger text-white">
|
|
<h5 class="mb-0">
|
|
<i class="fas fa-ban me-2"></i>Deletion Restrictions
|
|
</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="alert alert-warning">
|
|
<h6 class="alert-heading">Cannot Delete This Bill</h6>
|
|
<p class="mb-2">This bill cannot be deleted because:</p>
|
|
<ul class="mb-0">
|
|
{% if object.status == 'PAID' %}
|
|
<li>The bill has been paid in full</li>
|
|
{% endif %}
|
|
{% if object.status == 'PARTIAL_PAID' %}
|
|
<li>The bill has received partial payments</li>
|
|
{% endif %}
|
|
{% if object.status == 'SUBMITTED' %}
|
|
<li>The bill has been submitted to the patient</li>
|
|
{% endif %}
|
|
{% if object.status == 'OVERDUE' %}
|
|
<li>The bill is overdue and may be in collections</li>
|
|
{% endif %}
|
|
{% if object.status == 'COLLECTIONS' %}
|
|
<li>The bill is currently in collections</li>
|
|
{% endif %}
|
|
{% if object.insuranceclaim_set.exists %}
|
|
<li>Insurance claims have been submitted for this bill</li>
|
|
{% endif %}
|
|
</ul>
|
|
</div>
|
|
<div class="text-center">
|
|
<a href="{% url 'billing:bill_detail' object.bill_id %}" class="btn btn-primary">
|
|
<i class="fas fa-arrow-left me-2"></i>Return to Bill Details
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% else %}
|
|
<!-- Confirmation Form -->
|
|
<div class="card">
|
|
<div class="card-header bg-danger text-white">
|
|
<h5 class="mb-0">
|
|
<i class="fas fa-trash me-2"></i>Confirm Deletion
|
|
</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<form method="post">
|
|
{% csrf_token %}
|
|
|
|
<!-- Confirmation Checkbox -->
|
|
<div class="form-check mb-3">
|
|
<input class="form-check-input" type="checkbox" id="confirmDeletion" required>
|
|
<label class="form-check-label fw-bold" for="confirmDeletion">
|
|
I understand that this action is permanent and cannot be undone
|
|
</label>
|
|
</div>
|
|
|
|
<!-- Reason for Deletion -->
|
|
<div class="mb-3">
|
|
<label for="deletionReason" class="form-label fw-bold">Reason for Deletion *</label>
|
|
<select class="form-select" id="deletionReason" name="deletion_reason" required>
|
|
<option value="">Select a reason...</option>
|
|
<option value="DUPLICATE">Duplicate bill created in error</option>
|
|
<option value="INCORRECT_PATIENT">Incorrect patient assigned</option>
|
|
<option value="INCORRECT_SERVICES">Incorrect services billed</option>
|
|
<option value="BILLING_ERROR">Billing error or mistake</option>
|
|
<option value="CANCELLED_SERVICE">Service was cancelled</option>
|
|
<option value="OTHER">Other (specify in notes)</option>
|
|
</select>
|
|
</div>
|
|
|
|
<!-- Additional Notes -->
|
|
<div class="mb-4">
|
|
<label for="deletionNotes" class="form-label fw-bold">Additional Notes</label>
|
|
<textarea class="form-control" id="deletionNotes" name="deletion_notes" rows="3" placeholder="Provide additional details about why this bill is being deleted..."></textarea>
|
|
</div>
|
|
|
|
<!-- Final Warning -->
|
|
<div class="alert alert-danger">
|
|
<div class="d-flex align-items-center">
|
|
<i class="fas fa-exclamation-triangle fa-2x me-3"></i>
|
|
<div>
|
|
<h6 class="alert-heading mb-1">Final Warning</h6>
|
|
<p class="mb-0">
|
|
Once you click "Delete Bill", this bill and all associated data will be permanently removed from the system.
|
|
This action cannot be reversed.
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Action Buttons -->
|
|
<div class="d-flex justify-content-between">
|
|
<a href="{% url 'billing:bill_detail' object.bill_id %}" class="btn btn-outline-secondary">
|
|
<i class="fas fa-times me-2"></i>Cancel
|
|
</a>
|
|
<button type="submit" class="btn btn-danger" id="deleteButton" disabled>
|
|
<i class="fas fa-trash me-2"></i>Delete Bill Permanently
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
// Enable delete button only when confirmation is checked
|
|
document.getElementById('confirmDeletion').addEventListener('change', function() {
|
|
const deleteButton = document.getElementById('deleteButton');
|
|
const reasonSelect = document.getElementById('deletionReason');
|
|
|
|
if (this.checked && reasonSelect.value) {
|
|
deleteButton.disabled = false;
|
|
} else {
|
|
deleteButton.disabled = true;
|
|
}
|
|
});
|
|
|
|
// Also check when reason is selected
|
|
document.getElementById('deletionReason').addEventListener('change', function() {
|
|
const deleteButton = document.getElementById('deleteButton');
|
|
const confirmCheckbox = document.getElementById('confirmDeletion');
|
|
|
|
if (this.value && confirmCheckbox.checked) {
|
|
deleteButton.disabled = false;
|
|
} else {
|
|
deleteButton.disabled = true;
|
|
}
|
|
});
|
|
|
|
// Final confirmation before submission
|
|
document.querySelector('form').addEventListener('submit', function(e) {
|
|
const billNumber = '{{ object.bill_number }}';
|
|
const confirmation = confirm(
|
|
`Are you absolutely sure you want to delete bill ${billNumber}?\n\n` +
|
|
'This action is PERMANENT and cannot be undone.\n\n' +
|
|
'Click OK to proceed with deletion, or Cancel to abort.'
|
|
);
|
|
|
|
if (!confirmation) {
|
|
e.preventDefault();
|
|
return false;
|
|
}
|
|
});
|
|
</script>
|
|
{% endblock %}
|
|
|