class Patient: def __init__(self, name, age, gender, address, phone_number): self.name = name self.age = age self.gender = gender self.address = address self.phone_number = phone_number class Appointment: def __init__(self, patient, date, time): self.patient = patient self.date = date self.time = time class ClinicManagementSystem: def __init__(self): self.patients = [] self.appointments = [] def add_patient(self, name, age, gender, address, phone_number): patient = Patient(name, age, gender, address, phone_number) self.patients.append(patient) print("Patient added successfully.") def schedule_appointment(self, patient_name, date, time): patient = next((p for p in self.patients if p.name == patient_name), None) if patient: appointment = Appointment(patient, date, time) self.appointments.append(appointment) print("Appointment scheduled successfully.") else: print("Patient not found.") def view_appointments(self): if self.appointments: for appointment in self.appointments: print(f"Patient: {appointment.patient.name}") print(f"Date: {appointment.date}") print(f"Time: {appointment.time}") print("----------------------") else: print("No appointments found.") def view_patients(self): if self.patients: for patient in self.patients: print(f"Name: {patient.name}") print(f"Age: {patient.age}") print(f"Gender: {patient.gender}") print(f"Address: {patient.address}") print(f"Phone Number: {patient.phone_number}") print("----------------------") else: print("No patients found.") # Usage example clinic = ClinicManagementSystem() # Add patients clinic.add_patient("John Doe", 30, "Male", "123 Main St", "123-456-7890") clinic.add_patient("Jane Smith", 25, "Female", "456 Elm St", "987-654-3210") # Schedule appointments clinic.schedule_appointment("John Doe", "2023-06-12", "10:00 AM") clinic.schedule_appointment("Jane Smith", "2023-06-15", "2:30 PM") # View patients and appointments clinic.view_patients() clinic.view_appointments()
In this example, we have three classes: Patient, Appointment, and ClinicManagementSystem. The Patient class represents the patient information, the Appointment class represents an appointment with a patient, and the ClinicManagementSystem class is responsible for managing patients and appointments.
You can create patients using the add_patient method, schedule appointments using the schedule_appointment method, and view the list of patients and appointments using the view_patients and view_appointments methods, respectively.
Note that this is a simplified implementation and may not include all the features and error handling that a real clinic management system would have. It's meant to serve as a starting point for your project. You can expand upon this code by adding more functionality as per your requirements