511 lines
31 KiB
HTML
511 lines
31 KiB
HTML
{% extends 'base.html' %}
|
|
{% load static %}
|
|
|
|
{% block title %}Bill {{ bill.bill_number }} - Billing{% endblock %}
|
|
|
|
{% block content %}
|
|
<div class="container-fluid">
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="d-flex justify-content-between align-items-center mb-4">
|
|
<div>
|
|
<h1 class="h3 mb-0">Medical Bill {{ bill.bill_number }}</h1>
|
|
<p class="text-muted mb-0">{{ bill.patient.get_full_name }} - MRN: {{ bill.patient.mrn }}</p>
|
|
</div>
|
|
<div class="btn-group">
|
|
<a href="{% url 'billing:bill_list' %}" class="btn btn-outline-secondary">
|
|
<i class="fas fa-arrow-left"></i> Back to Bills
|
|
</a>
|
|
{% if bill.status == 'DRAFT' %}
|
|
<form method="post" action="{% url 'billing:submit_bill' bill.bill_id %}" class="d-inline">
|
|
{% csrf_token %}
|
|
<button type="submit" class="btn btn-success">
|
|
<i class="fas fa-paper-plane"></i> Submit Bill
|
|
</button>
|
|
</form>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<!-- Bill Information -->
|
|
<div class="col-lg-8">
|
|
<div class="card mb-4">
|
|
<div class="card-header">
|
|
<h5 class="mb-0">Bill Information</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<table class="table table-borderless table-sm">
|
|
<tr>
|
|
<td><strong>Bill Number:</strong></td>
|
|
<td>{{ bill.bill_number }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td><strong>Bill Type:</strong></td>
|
|
<td>{{ bill.get_bill_type_display }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td><strong>Bill Date:</strong></td>
|
|
<td>{{ bill.bill_date|date:"M d, Y" }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td><strong>Due Date:</strong></td>
|
|
<td>
|
|
{{ bill.due_date|date:"M d, Y" }}
|
|
{% if bill.is_overdue %}
|
|
<span class="badge bg-danger ms-2">Overdue</span>
|
|
{% endif %}
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td><strong>Service Period:</strong></td>
|
|
<td>{{ bill.service_date_from|date:"M d, Y" }} - {{ bill.service_date_to|date:"M d, Y" }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td><strong>Payment Terms:</strong></td>
|
|
<td>{{ bill.get_payment_terms_display }}</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<table class="table table-borderless table-sm">
|
|
<tr>
|
|
<td><strong>Status:</strong></td>
|
|
<td>
|
|
{% if bill.status == 'DRAFT' %}
|
|
<span class="badge bg-secondary">Draft</span>
|
|
{% elif bill.status == 'PENDING' %}
|
|
<span class="badge bg-warning">Pending</span>
|
|
{% elif bill.status == 'SUBMITTED' %}
|
|
<span class="badge bg-info">Submitted</span>
|
|
{% elif bill.status == 'PARTIAL_PAID' %}
|
|
<span class="badge bg-primary">Partially Paid</span>
|
|
{% elif bill.status == 'PAID' %}
|
|
<span class="badge bg-success">Paid</span>
|
|
{% elif bill.status == 'OVERDUE' %}
|
|
<span class="badge bg-danger">Overdue</span>
|
|
{% elif bill.status == 'COLLECTIONS' %}
|
|
<span class="badge bg-dark">Collections</span>
|
|
{% elif bill.status == 'WRITTEN_OFF' %}
|
|
<span class="badge bg-secondary">Written Off</span>
|
|
{% elif bill.status == 'CANCELLED' %}
|
|
<span class="badge bg-secondary">Cancelled</span>
|
|
{% endif %}
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td><strong>Attending Provider:</strong></td>
|
|
<td>{{ bill.attending_provider.get_full_name|default:"Not assigned" }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td><strong>Billing Provider:</strong></td>
|
|
<td>{{ bill.billing_provider.get_full_name|default:"Not assigned" }}</td>
|
|
</tr>
|
|
{% if bill.encounter %}
|
|
<tr>
|
|
<td><strong>Encounter:</strong></td>
|
|
<td>{{ bill.encounter.encounter_number }}</td>
|
|
</tr>
|
|
{% endif %}
|
|
{% if bill.admission %}
|
|
<tr>
|
|
<td><strong>Admission:</strong></td>
|
|
<td>{{ bill.admission.admission_number }}</td>
|
|
</tr>
|
|
{% endif %}
|
|
<tr>
|
|
<td><strong>Days Outstanding:</strong></td>
|
|
<td>{{ bill.days_outstanding }} days</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
{% if bill.notes %}
|
|
<div class="mt-3">
|
|
<strong>Notes:</strong>
|
|
<p class="mt-2">{{ bill.notes }}</p>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Line Items -->
|
|
<div class="card mb-4">
|
|
<div class="card-header d-flex justify-content-between align-items-center">
|
|
<h5 class="mb-0">Line Items</h5>
|
|
<button class="btn btn-outline-primary btn-sm">
|
|
<i class="fas fa-plus"></i> Add Line Item
|
|
</button>
|
|
</div>
|
|
<div class="card-body p-0">
|
|
<div class="table-responsive">
|
|
<table class="table table-hover mb-0">
|
|
<thead class="table-light">
|
|
<tr>
|
|
<th>Line</th>
|
|
<th>Service Date</th>
|
|
<th>Service Code</th>
|
|
<th>Description</th>
|
|
<th>Category</th>
|
|
<th>Qty</th>
|
|
<th>Unit Price</th>
|
|
<th>Total</th>
|
|
<th>Status</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for item in line_items %}
|
|
<tr>
|
|
<td>{{ item.line_number }}</td>
|
|
<td>{{ item.service_date|date:"M d, Y" }}</td>
|
|
<td>{{ item.service_code }}</td>
|
|
<td>{{ item.service_description }}</td>
|
|
<td>
|
|
<span class="badge bg-secondary">{{ item.get_service_category_display }}</span>
|
|
</td>
|
|
<td>{{ item.quantity }}</td>
|
|
<td>${{ item.unit_price|floatformat:2 }}</td>
|
|
<td><strong>${{ item.total_price|floatformat:2 }}</strong></td>
|
|
<td>
|
|
{% if item.status == 'ACTIVE' %}
|
|
<span class="badge bg-success">Active</span>
|
|
{% elif item.status == 'DENIED' %}
|
|
<span class="badge bg-danger">Denied</span>
|
|
{% elif item.status == 'ADJUSTED' %}
|
|
<span class="badge bg-warning">Adjusted</span>
|
|
{% elif item.status == 'VOIDED' %}
|
|
<span class="badge bg-secondary">Voided</span>
|
|
{% endif %}
|
|
</td>
|
|
</tr>
|
|
{% empty %}
|
|
<tr>
|
|
<td colspan="9" class="text-center py-4">
|
|
<div class="text-muted">
|
|
<i class="fas fa-list fa-2x mb-2"></i>
|
|
<p>No line items found.</p>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Payments -->
|
|
<div class="card mb-4">
|
|
<div class="card-header d-flex justify-content-between align-items-center">
|
|
<h5 class="mb-0">Payments</h5>
|
|
<button class="btn btn-outline-success btn-sm" data-bs-toggle="modal" data-bs-target="#paymentModal">
|
|
<i class="fas fa-plus"></i> Add Payment
|
|
</button>
|
|
</div>
|
|
<div class="card-body p-0">
|
|
<div class="table-responsive">
|
|
<table class="table table-hover mb-0">
|
|
<thead class="table-light">
|
|
<tr>
|
|
<th>Payment Number</th>
|
|
<th>Date</th>
|
|
<th>Amount</th>
|
|
<th>Method</th>
|
|
<th>Source</th>
|
|
<th>Status</th>
|
|
<th>Received By</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for payment in payments %}
|
|
<tr>
|
|
<td>{{ payment.payment_number }}</td>
|
|
<td>{{ payment.payment_date|date:"M d, Y" }}</td>
|
|
<td><strong>${{ payment.payment_amount|floatformat:2 }}</strong></td>
|
|
<td>{{ payment.get_payment_method_display }}</td>
|
|
<td>{{ payment.get_payment_source_display }}</td>
|
|
<td>
|
|
{% if payment.status == 'PENDING' %}
|
|
<span class="badge bg-warning">Pending</span>
|
|
{% elif payment.status == 'PROCESSED' %}
|
|
<span class="badge bg-success">Processed</span>
|
|
{% elif payment.status == 'CLEARED' %}
|
|
<span class="badge bg-success">Cleared</span>
|
|
{% elif payment.status == 'BOUNCED' %}
|
|
<span class="badge bg-danger">Bounced</span>
|
|
{% elif payment.status == 'REVERSED' %}
|
|
<span class="badge bg-warning">Reversed</span>
|
|
{% elif payment.status == 'REFUNDED' %}
|
|
<span class="badge bg-info">Refunded</span>
|
|
{% endif %}
|
|
</td>
|
|
<td>{{ payment.received_by.get_full_name|default:"System" }}</td>
|
|
</tr>
|
|
{% empty %}
|
|
<tr>
|
|
<td colspan="7" class="text-center py-4">
|
|
<div class="text-muted">
|
|
<i class="fas fa-credit-card fa-2x mb-2"></i>
|
|
<p>No payments recorded.</p>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Insurance Claims -->
|
|
<div class="card">
|
|
<div class="card-header d-flex justify-content-between align-items-center">
|
|
<h5 class="mb-0">Insurance Claims</h5>
|
|
<div class="btn-group btn-group-sm">
|
|
{% if bill.primary_insurance %}
|
|
<form method="post" action="{% url 'billing:submit_insurance_claim' bill.bill_id %}" class="d-inline">
|
|
{% csrf_token %}
|
|
<input type="hidden" name="insurance_type" value="PRIMARY">
|
|
<button type="submit" class="btn btn-outline-primary">
|
|
<i class="fas fa-paper-plane"></i> Submit Primary
|
|
</button>
|
|
</form>
|
|
{% endif %}
|
|
{% if bill.secondary_insurance %}
|
|
<form method="post" action="{% url 'billing:submit_insurance_claim' bill.bill_id %}" class="d-inline">
|
|
{% csrf_token %}
|
|
<input type="hidden" name="insurance_type" value="SECONDARY">
|
|
<button type="submit" class="btn btn-outline-secondary">
|
|
<i class="fas fa-paper-plane"></i> Submit Secondary
|
|
</button>
|
|
</form>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
<div class="card-body p-0">
|
|
<div class="table-responsive">
|
|
<table class="table table-hover mb-0">
|
|
<thead class="table-light">
|
|
<tr>
|
|
<th>Claim Number</th>
|
|
<th>Type</th>
|
|
<th>Insurance</th>
|
|
<th>Submission Date</th>
|
|
<th>Billed Amount</th>
|
|
<th>Paid Amount</th>
|
|
<th>Patient Responsibility</th>
|
|
<th>Status</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for claim in insurance_claims %}
|
|
<tr>
|
|
<td>{{ claim.claim_number }}</td>
|
|
<td>{{ claim.get_claim_type_display }}</td>
|
|
<td>{{ claim.insurance_info.insurance_company }}</td>
|
|
<td>{{ claim.submission_date|date:"M d, Y" }}</td>
|
|
<td>${{ claim.billed_amount|floatformat:2 }}</td>
|
|
<td>${{ claim.paid_amount|floatformat:2 }}</td>
|
|
<td>${{ claim.patient_responsibility|floatformat:2 }}</td>
|
|
<td>
|
|
{% if claim.status == 'DRAFT' %}
|
|
<span class="badge bg-secondary">Draft</span>
|
|
{% elif claim.status == 'SUBMITTED' %}
|
|
<span class="badge bg-info">Submitted</span>
|
|
{% elif claim.status == 'PENDING' %}
|
|
<span class="badge bg-warning">Pending</span>
|
|
{% elif claim.status == 'PROCESSING' %}
|
|
<span class="badge bg-primary">Processing</span>
|
|
{% elif claim.status == 'PAID' %}
|
|
<span class="badge bg-success">Paid</span>
|
|
{% elif claim.status == 'DENIED' %}
|
|
<span class="badge bg-danger">Denied</span>
|
|
{% elif claim.status == 'REJECTED' %}
|
|
<span class="badge bg-danger">Rejected</span>
|
|
{% elif claim.status == 'APPEALED' %}
|
|
<span class="badge bg-warning">Appealed</span>
|
|
{% elif claim.status == 'VOIDED' %}
|
|
<span class="badge bg-secondary">Voided</span>
|
|
{% endif %}
|
|
</td>
|
|
</tr>
|
|
{% empty %}
|
|
<tr>
|
|
<td colspan="8" class="text-center py-4">
|
|
<div class="text-muted">
|
|
<i class="fas fa-file-medical fa-2x mb-2"></i>
|
|
<p>No insurance claims submitted.</p>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Sidebar -->
|
|
<div class="col-lg-4">
|
|
<!-- Financial Summary -->
|
|
<div class="card mb-4">
|
|
<div class="card-header">
|
|
<h5 class="mb-0">Financial Summary</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<table class="table table-borderless table-sm">
|
|
<tr>
|
|
<td>Subtotal:</td>
|
|
<td class="text-end">${{ bill.subtotal|floatformat:2 }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td>Tax Amount:</td>
|
|
<td class="text-end">${{ bill.tax_amount|floatformat:2 }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td>Discount:</td>
|
|
<td class="text-end">-${{ bill.discount_amount|floatformat:2 }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td>Adjustment:</td>
|
|
<td class="text-end">${{ bill.adjustment_amount|floatformat:2 }}</td>
|
|
</tr>
|
|
<tr class="border-top">
|
|
<td><strong>Total Amount:</strong></td>
|
|
<td class="text-end"><strong>${{ bill.total_amount|floatformat:2 }}</strong></td>
|
|
</tr>
|
|
<tr>
|
|
<td>Paid Amount:</td>
|
|
<td class="text-end text-success">${{ bill.paid_amount|floatformat:2 }}</td>
|
|
</tr>
|
|
<tr class="border-top">
|
|
<td><strong>Balance Due:</strong></td>
|
|
<td class="text-end">
|
|
<strong class="{% if bill.balance_amount > 0 %}text-warning{% else %}text-success{% endif %}">
|
|
${{ bill.balance_amount|floatformat:2 }}
|
|
</strong>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
{% if bill.balance_amount > 0 %}
|
|
<div class="mt-3">
|
|
<div class="progress">
|
|
<div class="progress-bar bg-success" role="progressbar"
|
|
style="width: {{ bill.payment_percentage }}%">
|
|
{{ bill.payment_percentage }}% Paid
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Payment Summary -->
|
|
<div class="card mb-4">
|
|
<div class="card-header">
|
|
<h5 class="mb-0">Payment Summary</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<table class="table table-borderless table-sm">
|
|
<tr>
|
|
<td>Total Payments:</td>
|
|
<td class="text-end">${{ payment_summary.total_payments|floatformat:2 }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td>Insurance Payments:</td>
|
|
<td class="text-end">${{ payment_summary.insurance_payments|floatformat:2 }}</td>
|
|
</tr>
|
|
<tr>
|
|
<td>Patient Payments:</td>
|
|
<td class="text-end">${{ payment_summary.patient_payments|floatformat:2 }}</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Insurance Information -->
|
|
{% if bill.primary_insurance or bill.secondary_insurance %}
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h5 class="mb-0">Insurance Information</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
{% if bill.primary_insurance %}
|
|
<div class="mb-3">
|
|
<h6>Primary Insurance</h6>
|
|
<p class="mb-1"><strong>{{ bill.primary_insurance.insurance_company }}</strong></p>
|
|
<p class="mb-1">Policy: {{ bill.primary_insurance.policy_number }}</p>
|
|
<p class="mb-0">Group: {{ bill.primary_insurance.group_number|default:"N/A" }}</p>
|
|
</div>
|
|
{% endif %}
|
|
{% if bill.secondary_insurance %}
|
|
<div>
|
|
<h6>Secondary Insurance</h6>
|
|
<p class="mb-1"><strong>{{ bill.secondary_insurance.insurance_company }}</strong></p>
|
|
<p class="mb-1">Policy: {{ bill.secondary_insurance.policy_number }}</p>
|
|
<p class="mb-0">Group: {{ bill.secondary_insurance.group_number|default:"N/A" }}</p>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Payment Modal -->
|
|
<div class="modal fade" id="paymentModal" tabindex="-1">
|
|
<div class="modal-dialog">
|
|
<div class="modal-content">
|
|
<form method="post" action="{% url 'billing:process_payment' bill.bill_id %}">
|
|
{% csrf_token %}
|
|
<div class="modal-header">
|
|
<h5 class="modal-title">Process Payment</h5>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<div class="mb-3">
|
|
<label for="payment_amount" class="form-label">Payment Amount</label>
|
|
<input type="number" step="0.01" name="payment_amount" id="payment_amount"
|
|
class="form-control" max="{{ bill.balance_amount }}" required>
|
|
<div class="form-text">Maximum: ${{ bill.balance_amount|floatformat:2 }}</div>
|
|
</div>
|
|
<div class="mb-3">
|
|
<label for="payment_method" class="form-label">Payment Method</label>
|
|
<select name="payment_method" id="payment_method" class="form-select" required>
|
|
<option value="CASH">Cash</option>
|
|
<option value="CHECK">Check</option>
|
|
<option value="CREDIT_CARD">Credit Card</option>
|
|
<option value="DEBIT_CARD">Debit Card</option>
|
|
<option value="BANK_TRANSFER">Bank Transfer</option>
|
|
<option value="ACH">ACH Transfer</option>
|
|
</select>
|
|
</div>
|
|
<div class="mb-3">
|
|
<label for="payment_source" class="form-label">Payment Source</label>
|
|
<select name="payment_source" id="payment_source" class="form-select" required>
|
|
<option value="PATIENT">Patient</option>
|
|
<option value="INSURANCE">Insurance</option>
|
|
<option value="GUARANTOR">Guarantor</option>
|
|
<option value="GOVERNMENT">Government</option>
|
|
<option value="CHARITY">Charity</option>
|
|
<option value="OTHER">Other</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
|
|
<button type="submit" class="btn btn-success">Process Payment</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endblock %}
|
|
|