#!/usr/bin/env python3
"""Initialize Mum's X-Ray Scan Appointments at Hampton Park Clinic"""

from datetime import datetime, timedelta
import json

# Get next Tuesday and Thursday from current date
def get_next_weekday_days():
    """Returns the days offset (in days) for next Tuesday and Thursday"""
    today = datetime.now().weekday()  # Monday=0, Sunday=6
    
    # Calculate days until next Tuesday
    tuesdays_offset = ((1 - today) % 7) + 1 if today != 0 else 1
    
    # Calculate days until next Thursday (3 days after Tuesday)
    thursdays_offset = (tuesdays_offset + 3) % 7
    
    return tuesdays_offset, thursdays_offset

# Get the appointment dates
tuesday_days, thursday_days = get_next_weekday_days()
today = datetime.now()
tuesday = today + timedelta(days=tuesday_days)
thursday = today + timedelta(days=thursday_days)

# Format date for display and internal use
tuesday_str = tuesday.strftime('%Y-%m-%d')
thursday_str = thursday.strftime('%Y-%m-%d')

appointments_data = {
    "appointments": [
        {
            "id": 1,
            "title": "Mum's X-Ray Scan - Tuesday",
            "start_time": f"{tuesday_str} 11:00",
            "end_time": f"{tuesday_str} 12:00",
            "description": "X-ray scan appointment at Hampton Park Clinic",
            "memo": {
                "content": "📍 Location: Hampton Park Clinic\n⏰ Time: 11:00 AM (3-hour appointment block)\n📋 Bring: ID card, insurance card, previous X-rays if available\n👕 Wear comfortable clothes\n⏱️ Arrive 15 minutes early for check-in",
                "important": True
            },
            "createdAt": datetime.now().isoformat()
        },
        {
            "id": 2,
            "title": "Mum's X-Ray Scan - Thursday",
            "start_time": f"{thursday_str} 11:00",
            "end_time": f"{thursday_str} 12:00",
            "description": "X-ray scan appointment at Hampton Park Clinic",
            "memo": {
                "content": "📍 Location: Hampton Park Clinic\n⏰ Time: 11:00 AM (3-hour appointment block)\n📋 Bring: ID card, insurance card, previous X-rays if available\n👕 Wear comfortable clothes\n⏱️ Arrive 15 minutes early for check-in",
                "important": True
            },
            "createdAt": datetime.now().isoformat()
        }
    ],
    "memos": [
        {
            "id": 200,
            "title": "Mum's X-Ray Scans - Hampton Park Clinic",
            "content": "📅 Appointments scheduled for next Tuesday AND Thursday at 11:00 AM\n🏥 Location: Hampton Park Clinic\n💡 Bring all necessary documents and previous medical records\n✅ Marked as Important Notes",
            "important": True,
            "category": "appointment"
        },
        {
            "id": 201,
            "title": "Hampton Park Clinic - Contact Info",
            "content": "Remember to check in online if required. Arrive at least 15 minutes before your appointment time.",
            "important": False,
            "category": "appointment"
        }
    ]
}

# Save to JSON file for reference
with open('/root/.hermes/dashboard/hermes_dashboard/mums_appointments_data.json', 'w') as f:
    json.dump(appointments_data, f, indent=2)

print("=" * 60)
print("MUM'S X-RAY SCAN APPOINTMENTS CREATED")
print("=" * 60)
print(f"Tuesday Appointment: {tuesday.strftime('%A, %B %d, %Y') } at 11:00 AM")
print(f"Thursday Appointment: {thursday.strftime('%A, %B %d, %Y')} at 11:00 AM")
print(f"Location: Hampton Park Clinic")
print("=" * 60)
print("\nAppointments saved to:")
print("- /root/.hermes/dashboard/hermes_dashboard/mums_appointments_data.json")
print("\nThese appointments will appear on your dashboard calendar!")
print("=" * 60)
