Notes:
-
What problem does it solve?: It automates and streamlines appointment scheduling for healthcare professionals, improving efficiency and reducing scheduling errors.
-
How can businesses or users benefit from customizing the code?: Clinics can integrate this with existing calendar systems or patient management systems.
-
How can businesses or users adopt the solution further, if needed?: Businesses can adapt this solution to integrate with user interfaces or email notification systems for reminders.
Python Code:
from datetime import datetime, timedelta
class AppointmentScheduler:
def __init__(self):
self.appointments = []
def schedule_appointment(self, patient_name, date_time):
self.appointments.append({
'patient_name': patient_name,
'date_time': date_time
})
def view_appointments(self):
return self.appointments
def available_slots(self, start_date, end_date, slot_duration=30):
current_time = start_date
slots = []
while current_time <= end_date:
slots.append(current_time)
current_time += timedelta(minutes=slot_duration)
return slots
# Example Usage
scheduler = AppointmentScheduler()
# Get available slots for today
today = datetime.now().date()
start_time = datetime.combine(today, datetime.min.time())
end_time = start_time + timedelta(hours=8)
available_slots = scheduler.available_slots(start_time, end_time)
print("Available Slots:", available_slots)
# Schedule an appointment
scheduler.schedule_appointment('Jane Doe', available_slots[0])
print("Appointments:", scheduler.view_appointments())
No comments:
Post a Comment