Untitled

 avatar
unknown
plain_text
a year ago
1.8 kB
4
Indexable
class Doctor:
    def __init__(self, name, specialty):
        self.name = name
        self.specialty = specialty
        self.available_slots = []

    def add_available_slot(self, date, time):
        self.available_slots.append((date, time))

    def display_available_slots(self):
        print(f"Available slots for Dr. {self.name} ({self.specialty}):")
        for slot in self.available_slots:
            print(f"Date: {slot[0]}, Time: {slot[1]}")

class Patient:
    def __init__(self, name, email):
        self.name = name
        self.email = email

class AppointmentScheduler:
    def __init__(self):
        self.doctors = {}

    def add_doctor(self, doctor):
        self.doctors[doctor.name] = doctor

    def schedule_appointment(self, patient, doctor_name, date, time):
        if doctor_name in self.doctors:
            if (date, time) in self.doctors[doctor_name].available_slots:
                print(f"Appointment scheduled for {patient.name} with Dr. {doctor_name} on {date} at {time}.")
                # Additional logic for appointment confirmation, reminders, etc. can be added here
            else:
                print("Slot not available.")
        else:
            print("Doctor not found.")

# Example usage:
if __name__ == "__main__":
    scheduler = AppointmentScheduler()

    doctor1 = Doctor("John Doe", "Cardiologist")
    doctor1.add_available_slot("2024-04-07", "10:00 AM")
    doctor1.add_available_slot("2024-04-08", "02:00 PM")
    scheduler.add_doctor(doctor1)

    patient1 = Patient("Alice Smith", "alice@example.com")

    scheduler.schedule_appointment(patient1, "John Doe", "2024-04-07", "10:00 AM")
    scheduler.schedule_appointment(patient1, "John Doe", "2024-04-08", "02:00 PM")
    scheduler.schedule_appointment(patient1, "Jane Smith", "2024-04-08", "02:00 PM")
Editor is loading...
Leave a Comment