{% extends 'base.html' %} {% block content %}
Total Appointments{{ stats.total_appointments }}
Upcoming{{ stats.upcoming }}
Completed{{ stats.completed }}
Cancelled{{ stats.cancelled }}

Notifications

Recent reminders and appointment updates for your account.

{% if notifications %}
{% for notification in notifications %}
{{ notification.title }} {{ notification.message }} {{ notification.created_at.strftime('%Y-%m-%d %H:%M') }}
{% if not notification.is_read %}
{% else %} Read {% endif %}
{% endfor %}
{% else %}

No notifications yet.

{% endif %}

Book a New Appointment

Choose one of the suggested open slots first, or use the manual fallback if needed.

These options are generated from active doctor schedules and already avoid booked times.

Upcoming Visits

Your next scheduled appointments appear here for quick review.

{% if upcoming_appointments %}
{% for a in upcoming_appointments %} {% set doctor = doctor_lookup.get(a.doctor_id) %}
{{ doctor.full_name if doctor else 'Doctor #' ~ a.doctor_id }} {{ a.scheduled_time.strftime('%Y-%m-%d %H:%M') }} · {{ a.duration_minutes }} mins Reason: {{ a.reason or 'Not provided' }} {{ 'Doctor confirmed' if a.is_confirmed else 'Awaiting doctor confirmation' }} {% if a.notes %} Latest notes: {{ a.notes }} {% endif %}
{{ a.status.value.replace('_', ' ') }}
{% endfor %}
{% else %}

No upcoming appointments yet.

{% endif %}

Doctor Availability

Check each doctor's specialty, weekly schedule, and next open time before booking or rescheduling.

Clear
{% if doctor_availability %}
{% for entry in doctor_availability %}
{{ entry.doctor.full_name }} {{ entry.doctor.specialty or 'General Practice' }} {{ entry.active_slot_count }} active weekly slot{% if entry.active_slot_count != 1 %}s{% endif %}
{{ 'Open for booking' if entry.next_open_slot else 'No openings yet' }}
{% if entry.next_open_slot %}
Next open slot {{ entry.next_open_slot.scheduled_time.strftime('%a %d %b %Y %H:%M') }}
{% else %}

No open slot in the next {{ availability_window_days }} days.

{% endif %}
Weekly schedule
{% for schedule in entry.schedule_lines %} {{ schedule }} {% else %} No active schedule published {% endfor %}
{% if entry.leave_blocks %}
Upcoming unavailable periods
{% for leave in entry.leave_blocks[:3] %} {{ leave.start_date.strftime('%d %b %H:%M') }} → {{ leave.end_date.strftime('%d %b %H:%M') }} {% endfor %}
{% endif %} {% if entry.open_slot_choices %}
Open times you can book now
{% for option in entry.open_slot_choices %} {{ option.scheduled_time.strftime('%a %d %b · %H:%M') }} {% endfor %}
{% endif %}
{% endfor %}
{% else %}

No active doctors match the current search or specialty filter.

{% endif %}
{% if visit_notes %}

Recent Visit Notes

Review the latest notes left by doctors after completed visits.

{% for a in visit_notes %} {% set doctor = doctor_lookup.get(a.doctor_id) %}
{{ doctor.full_name if doctor else 'Doctor #' ~ a.doctor_id }}
{{ a.scheduled_time.strftime('%Y-%m-%d %H:%M') }}
{% if a.diagnosis %}
Diagnosis: {{ a.diagnosis }}
{% endif %} {% if a.prescription %}
Advice / Prescription: {{ a.prescription }}
{% endif %} {% if a.follow_up_date %}
Follow-up: {{ a.follow_up_date.strftime('%Y-%m-%d %H:%M') }}
{% endif %}

{{ a.notes }}

{% endfor %}
{% endif %}

Appointment History

Cancel or reschedule any appointment that is still marked as scheduled.

{% if appointments %}
{% for a in appointments %} {% set doctor = doctor_lookup.get(a.doctor_id) %} {% set availability = availability_lookup.get(a.doctor_id) %} {% endfor %}
ID Doctor When Status Reason / Notes Actions
{{ a.id }}
{{ doctor.full_name if doctor else 'Doctor #' ~ a.doctor_id }} {{ doctor.email if doctor else 'Archived doctor' }}
{{ a.scheduled_time.strftime('%Y-%m-%d %H:%M') }} {{ a.status.value.replace('_', ' ') }}
{{ a.reason or 'No reason provided' }} {{ 'Doctor confirmed' if a.is_confirmed else 'Awaiting doctor confirmation' }} {{ a.notes or 'No consultation notes yet' }} {% if a.diagnosis %}Diagnosis: {{ a.diagnosis }}{% endif %} {% if a.prescription %}Advice / Prescription: {{ a.prescription }}{% endif %} {% if a.follow_up_date %}Follow-up: {{ a.follow_up_date.strftime('%Y-%m-%d %H:%M') }}{% endif %}
{% if a.status.value == 'scheduled' %}
{% if availability and availability.next_open_slot %} Next open slot: {{ availability.next_open_slot.scheduled_time.strftime('%a %d %b %H:%M') }} {% endif %}
{% else %} No further action {% endif %}
{% else %}

No appointments recorded yet. Use the booking form to schedule your first visit.

{% endif %}
{% endblock %}