北大口腔挂号有多难大家都很清楚,今天就让ChatGPT写一个挂号程序,可惜挂号部分写得太潦草,跟没写一样:

import datetime

class PekingUniversityStomatologyHospital:
    def __init__(self):
        self.departments = ["口腔科", "牙周病科", "口腔颌面外科"]
        self.doctors = {
            "口腔科": ["张医生", "王医生"],
            "牙周病科": ["李医生", "赵医生"],
            "口腔颌面外科": ["陈医生", "刘医生"]
        }
        self.appointment_records = []

    def get_departments(self):
        return self.departments

    def get_doctors(self, department):
        return self.doctors.get(department, [])

    def make_appointment(self, department, doctor, date, time):
        appointment_info = {
            "Department": department,
            "Doctor": doctor,
            "DateTime": datetime.datetime.strptime(f"{date} {time}", "%Y-%m-%d %H:%M"),
            "Status": "Scheduled"  # 预约状态可根据实际情况添加更多状态
        }
        self.appointment_records.append(appointment_info)
        return appointment_info

# 使用示例
hospital = PekingUniversityStomatologyHospital()

# 获取科室列表
departments_list = hospital.get_departments()
print("科室列表:", departments_list)

# 获取口腔科医生列表
dentistry_doctors_list = hospital.get_doctors("口腔科")
print("口腔科医生列表:", dentistry_doctors_list)

# 挂号
appointment_info = hospital.make_appointment("口腔科", "张医生", "2023-01-01", "09:00")
print("挂号成功:", appointment_info)

# 查看挂号记录
print("挂号记录:", hospital.appointment_records)

By coriva

Leave a Reply

Your email address will not be published. Required fields are marked *