244 lines
15 KiB
HTML
244 lines
15 KiB
HTML
{% extends 'base.html' %}
|
|
{% load static %}
|
|
|
|
{% block title %}Cancel Appointment{% endblock %}
|
|
|
|
{% block content %}
|
|
<div id="content" class="app-content">
|
|
<div class="container">
|
|
<div class="row justify-content-center">
|
|
<div class="col-xl-8">
|
|
<ul class="breadcrumb">
|
|
<li class="breadcrumb-item"><a href="{% url 'core:dashboard' %}">Dashboard</a></li>
|
|
<li class="breadcrumb-item"><a href="{% url 'appointments:appointment_list' %}">Appointments</a></li>
|
|
<li class="breadcrumb-item"><a href="{% url 'appointments:appointment_detail' appointment.id %}">{{ appointment.patient.first_name }} {{ appointment.patient.last_name }}</a></li>
|
|
<li class="breadcrumb-item active">Cancel</li>
|
|
</ul>
|
|
|
|
<h1 class="page-header">Cancel Appointment</h1>
|
|
|
|
<!-- Appointment Info -->
|
|
<div class="card mb-4">
|
|
<div class="card-header">
|
|
<h4 class="card-title">Appointment Details</h4>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<div class="row mb-2">
|
|
<div class="col-4"><strong>Patient:</strong></div>
|
|
<div class="col-8">{{ appointment.patient.first_name }} {{ appointment.patient.last_name }}</div>
|
|
</div>
|
|
<div class="row mb-2">
|
|
<div class="col-4"><strong>Patient ID:</strong></div>
|
|
<div class="col-8">{{ appointment.patient.patient_id }}</div>
|
|
</div>
|
|
<div class="row mb-2">
|
|
<div class="col-4"><strong>Provider:</strong></div>
|
|
<div class="col-8">{{ appointment.provider.first_name }} {{ appointment.provider.last_name }}</div>
|
|
</div>
|
|
<div class="row mb-2">
|
|
<div class="col-4"><strong>Department:</strong></div>
|
|
<div class="col-8">{{ appointment.department.name }}</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<div class="row mb-2">
|
|
<div class="col-4"><strong>Date:</strong></div>
|
|
<div class="col-8">{{ appointment.appointment_date|date:"M d, Y" }}</div>
|
|
</div>
|
|
<div class="row mb-2">
|
|
<div class="col-4"><strong>Time:</strong></div>
|
|
<div class="col-8">{{ appointment.appointment_time|time:"g:i A" }}</div>
|
|
</div>
|
|
<div class="row mb-2">
|
|
<div class="col-4"><strong>Type:</strong></div>
|
|
<div class="col-8">{{ appointment.appointment_type.name }}</div>
|
|
</div>
|
|
<div class="row mb-2">
|
|
<div class="col-4"><strong>Status:</strong></div>
|
|
<div class="col-8">
|
|
{% if appointment.status == 'scheduled' %}
|
|
<span class="badge bg-info">Scheduled</span>
|
|
{% elif appointment.status == 'confirmed' %}
|
|
<span class="badge bg-success">Confirmed</span>
|
|
{% elif appointment.status == 'checked_in' %}
|
|
<span class="badge bg-primary">Checked In</span>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
{% if appointment.notes %}
|
|
<div class="row mt-3">
|
|
<div class="col-12">
|
|
<strong>Current Notes:</strong>
|
|
<p class="mt-2">{{ appointment.notes }}</p>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Cancellation Form -->
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h4 class="card-title">Cancellation Details</h4>
|
|
</div>
|
|
<div class="card-body">
|
|
{% if messages %}
|
|
{% for message in messages %}
|
|
<div class="alert alert-{{ message.tags }} alert-dismissible fade show" role="alert">
|
|
{{ message }}
|
|
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
|
|
</div>
|
|
{% endfor %}
|
|
{% endif %}
|
|
|
|
<div class="alert alert-warning">
|
|
<i class="fa fa-exclamation-triangle me-2"></i>
|
|
<strong>Warning:</strong> This action will permanently cancel the appointment. This cannot be undone.
|
|
</div>
|
|
|
|
<form method="post" class="form-horizontal">
|
|
{% csrf_token %}
|
|
|
|
<div class="row mb-3">
|
|
<label class="col-form-label col-md-3">Cancellation Reason <span class="text-danger">*</span></label>
|
|
<div class="col-md-9">
|
|
<select name="cancellation_reason" class="form-select" required>
|
|
<option value="">Select Reason</option>
|
|
<option value="patient_request" {% if form.cancellation_reason.value == 'patient_request' %}selected{% endif %}>Patient Request</option>
|
|
<option value="patient_illness" {% if form.cancellation_reason.value == 'patient_illness' %}selected{% endif %}>Patient Illness</option>
|
|
<option value="provider_unavailable" {% if form.cancellation_reason.value == 'provider_unavailable' %}selected{% endif %}>Provider Unavailable</option>
|
|
<option value="emergency" {% if form.cancellation_reason.value == 'emergency' %}selected{% endif %}>Emergency</option>
|
|
<option value="equipment_failure" {% if form.cancellation_reason.value == 'equipment_failure' %}selected{% endif %}>Equipment Failure</option>
|
|
<option value="weather" {% if form.cancellation_reason.value == 'weather' %}selected{% endif %}>Weather Conditions</option>
|
|
<option value="scheduling_error" {% if form.cancellation_reason.value == 'scheduling_error' %}selected{% endif %}>Scheduling Error</option>
|
|
<option value="insurance_issue" {% if form.cancellation_reason.value == 'insurance_issue' %}selected{% endif %}>Insurance Issue</option>
|
|
<option value="other" {% if form.cancellation_reason.value == 'other' %}selected{% endif %}>Other</option>
|
|
</select>
|
|
{% if form.cancellation_reason.errors %}
|
|
<div class="text-danger">{{ form.cancellation_reason.errors.0 }}</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row mb-3">
|
|
<label class="col-form-label col-md-3">Cancellation Notes</label>
|
|
<div class="col-md-9">
|
|
<textarea name="cancellation_notes" class="form-control" rows="4"
|
|
placeholder="Additional details about the cancellation">{{ form.cancellation_notes.value|default:'' }}</textarea>
|
|
{% if form.cancellation_notes.errors %}
|
|
<div class="text-danger">{{ form.cancellation_notes.errors.0 }}</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row mb-3">
|
|
<label class="col-form-label col-md-3">Cancellation Fee</label>
|
|
<div class="col-md-9">
|
|
<div class="input-group">
|
|
<span class="input-group-text">$</span>
|
|
<input type="number" name="cancellation_fee" class="form-control"
|
|
step="0.01" min="0" value="{{ form.cancellation_fee.value|default:'0.00' }}">
|
|
</div>
|
|
<small class="form-text text-muted">Enter cancellation fee if applicable</small>
|
|
{% if form.cancellation_fee.errors %}
|
|
<div class="text-danger">{{ form.cancellation_fee.errors.0 }}</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row mb-3">
|
|
<div class="col-md-9 offset-md-3">
|
|
<div class="form-check mb-2">
|
|
<input class="form-check-input" type="checkbox" name="notify_patient" id="notify_patient"
|
|
{% if form.notify_patient.value %}checked{% endif %}>
|
|
<label class="form-check-label" for="notify_patient">
|
|
Send cancellation notification to patient
|
|
</label>
|
|
</div>
|
|
<div class="form-check mb-2">
|
|
<input class="form-check-input" type="checkbox" name="offer_reschedule" id="offer_reschedule"
|
|
{% if form.offer_reschedule.value %}checked{% endif %}>
|
|
<label class="form-check-label" for="offer_reschedule">
|
|
Offer rescheduling options to patient
|
|
</label>
|
|
</div>
|
|
<div class="form-check">
|
|
<input class="form-check-input" type="checkbox" name="add_to_waitlist" id="add_to_waitlist"
|
|
{% if form.add_to_waitlist.value %}checked{% endif %}>
|
|
<label class="form-check-label" for="add_to_waitlist">
|
|
Add patient to waitlist for earlier appointments
|
|
</label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="col-md-9 offset-md-3">
|
|
<button type="submit" class="btn btn-danger" onclick="return confirm('Are you sure you want to cancel this appointment? This action cannot be undone.')">
|
|
<i class="fa fa-times me-2"></i>Cancel Appointment
|
|
</button>
|
|
<a href="{% url 'appointments:appointment_detail' appointment.id %}" class="btn btn-secondary ms-2">
|
|
<i class="fa fa-arrow-left me-2"></i>Go Back
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Cancellation Policy -->
|
|
<div class="card mt-4">
|
|
<div class="card-header">
|
|
<h4 class="card-title">Cancellation Policy</h4>
|
|
</div>
|
|
<div class="card-body">
|
|
<ul class="mb-0">
|
|
<li>Appointments cancelled with less than 24 hours notice may incur a cancellation fee</li>
|
|
<li>Emergency cancellations are exempt from cancellation fees</li>
|
|
<li>Patients will be notified of the cancellation via their preferred communication method</li>
|
|
<li>Cancelled appointments will be made available to other patients on the waitlist</li>
|
|
<li>Refunds for prepaid appointments will be processed according to the refund policy</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endblock %}
|
|
|
|
{% block js %}
|
|
<script>
|
|
$(document).ready(function() {
|
|
// Calculate cancellation fee based on notice period
|
|
var appointmentDate = new Date('{{ appointment.appointment_date|date:"Y-m-d" }} {{ appointment.appointment_time }}');
|
|
var now = new Date();
|
|
var hoursNotice = (appointmentDate - now) / (1000 * 60 * 60);
|
|
|
|
// Auto-set cancellation fee based on policy
|
|
if (hoursNotice < 24 && hoursNotice > 0) {
|
|
var reason = $('select[name="cancellation_reason"]').val();
|
|
if (reason !== 'emergency' && reason !== 'provider_unavailable') {
|
|
$('input[name="cancellation_fee"]').val('25.00');
|
|
}
|
|
}
|
|
|
|
// Update cancellation fee when reason changes
|
|
$('select[name="cancellation_reason"]').change(function() {
|
|
var reason = $(this).val();
|
|
if (reason === 'emergency' || reason === 'provider_unavailable') {
|
|
$('input[name="cancellation_fee"]').val('0.00');
|
|
} else if (hoursNotice < 24 && hoursNotice > 0) {
|
|
$('input[name="cancellation_fee"]').val('25.00');
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
{% endblock %}
|
|
|