本系统旨在为诊所提供一个全面的管理解决方案,包括患者管理、医生管理、预约挂号和病历管理。通过该系统,诊所可以更高效地处理患者信息、医生信息、预约和病历记录,提高管理效率和服务质量。
1 患者管理模块
2 医生管理模块
3 预约挂号模块
4 病历管理模块
5 报表管理模块
根据需求分析,设计系统的类和数据结构,包括:Patient类、Doctor类、Appointment类、MedicalRecord类。
将系统划分为患者管理模块、医生管理模块、预约挂号模块、病历管理模块等,分别实现这些模块的功能。
3. 功能实现
患者管理模块
医生管理模块
预约挂号模块
病历管理模块
报表管理模块
4. 用户界面设计
设计菜单,使用Python的**input()**函数获取用户输入,并调用相应的功能函数。
系统启动后,首先进入系统主界面,等待用户输入命令选择相应的功能。
患者管理
在主菜单选择“患者管理”:
class Patient:
def __init__(self, id, name, age):
self.id = id
self.name = name
self.age = age
class Doctor:
def __init__(self, id, name, specialization):
self.id = id
self.name = name
self.specialization = specialization
class Appointment:
def __init__(self, patient, doctor, date):
self.patient = patient
self.doctor = doctor
self.date = date
class MedicalRecord:
def __init__(self, patient, symptoms, diagnosis):
self.patient = patient
self.symptoms = symptoms
self.diagnosis = diagnosis
定义诊所管理系统类,并对实体类进行初始化。
class ClinicManagementSystem:
def __init__(self):
self.patients = []
self.doctors = []
self.appointments = []
self.medical_records = []
实现患者信息的添加、查看、更新和删除功能函数。
def add_patient(self, id, name, age):
patient = Patient(id, name, age)
self.patients.append(patient)
print(f"成功添加患者:{name}。")
def view_patients(self):
print("\n患者信息:")
for patient in self.patients:
print(f"ID:{patient.id},姓名:{patient.name},年龄:{patient.age}")
def update_patient(self, patient_id, new_name, new_age):
patient = next((p for p in self.patients if p.id == patient_id), None)
if patient:
patient.name = new_name
patient.age = new_age
print(f"成功更新患者 {patient_id} 的信息。")
else:
print("未找到患者。")
def delete_patient(self, patient_id):
patient = next((p for p in self.patients if p.id == patient_id), None)
if patient:
self.patients.remove(patient)
print(f"成功删除患者 {patient_id} 的信息。")
else:
print("未找到患者。")
实现医生信息的添加、查看、更新和删除功能函数。
def add_doctor(self, id, name, specialization):
doctor = Doctor(id, name, specialization)
self.doctors.append(doctor)
print(f"成功添加医生:{name}。")
def view_doctors(self):
print("\n医生信息:")
for doctor in self.doctors:
print(f"ID:{doctor.id},姓名:{doctor.name},专业:{doctor.specialization}")
def update_doctor(self, doctor_id, new_name, new_specialization):
doctor = next((d for d in self.doctors if d.id == doctor_id), None)
if doctor:
doctor.name = new_name
doctor.specialization = new_specialization
print(f"成功更新医生 {doctor_id} 的信息。")
else:
print("未找到医生。")
def delete_doctor(self, doctor_id):
doctor = next((d for d in self.doctors if d.id == doctor_id), None)
if doctor:
self.doctors.remove(doctor)
print(f"成功删除医生 {doctor_id} 的信息。")
else:
print("未找到医生。")
实现预约信息的添加、查看、更新和删除功能函数。
def make_appointment(self, patient_id, doctor_id, date):
patient = next((p for p in self.patients if p.id == patient_id), None)
doctor = next((d for d in self.doctors if d.id == doctor_id), None)
if patient and doctor:
appointment = Appointment(patient, doctor, date)
self.appointments.append(appointment)
print(f"成功为患者 {patient.name} 预约了 {doctor.name} 医生在 {date} 的门诊。")
else:
print("未找到患者或医生。")
def view_appointments(self):
print("\n预约信息:")
for appointment in self.appointments:
print(f"患者:{appointment.patient.name},医生:{appointment.doctor.name},日期:{appointment.date}")
def update_appointment(self, patient_id, doctor_id, new_date):
appointment = next(
(a for a in self.appointments if a.patient.id == patient_id and a.doctor.id == doctor_id), None
)
if appointment:
appointment.date = new_date
print(f"成功更新患者 {patient_id} 与医生 {doctor_id} 的预约信息。")
else:
print("未找到预约信息。")
def delete_appointment(self, patient_id, doctor_id):
appointment = next(
(a for a in self.appointments if a.patient.id == patient_id and a.doctor.id == doctor_id), None
)
if appointment:
self.appointments.remove(appointment)
print(f"成功删除患者 {patient_id} 与医生 {doctor_id} 的预约信息。")
else:
print("未找到预约信息。")
实现病历信息的添加、查看、更新功能函数。
def create_medical_record(self, patient_id, symptoms, diagnosis):
patient = next((p for p in self.patients if p.id == patient_id), None)
if patient:
medical_record = MedicalRecord(patient, symptoms, diagnosis)
self.medical_records.append(medical_record)
print(f"成功为患者 {patient.name} 创建了病历记录。")
else:
print("未找到患者。")
def view_medical_records(self):
print("\n病历记录:")
for record in self.medical_records:
print(f"患者:{record.patient.name},症状:{record.symptoms},诊断:{record.diagnosis}")
def update_medical_record(self, patient_id, new_symptoms, new_diagnosis):
record = next((r for r in self.medical_records if r.patient.id == patient_id), None)
if record:
record.symptoms = new_symptoms
record.diagnosis = new_diagnosis
print(f"成功更新患者 {patient_id} 的病历记录。")
else:
print("未找到病历记录。")
实现各模块报表统计功能函数。
def generate_patient_report(self):
print("\n患者报表:")
print(f"总患者数量:{len(self.patients)}")
def generate_doctor_report(self):
print("\n医生报表:")
print(f"总医生数量:{len(self.doctors)}")
for doctor in self.doctors:
appointments_count = sum(1 for a in self.appointments if a.doctor.id == doctor.id)
print(f"医生 {doctor.name} 的预约数量:{appointments_count}")
def generate_appointment_report(self):
print("\n预约报表:")
print(f"总预约数量:{len(self.appointments)}")
在子菜单中分别调用各功能函数
def display_report_menu(self):
while True:
print("\n报表统计管理菜单:")
print("1. 生成患者报表")
print("2. 生成医生报表")
print("3. 生成预约报表")
print("4. 返回主菜单")
choice = input("请选择操作 (1-4): ")
if choice == "1":
self.generate_patient_report()
elif choice == "2":
self.generate_doctor_report()
elif choice == "3":
self.generate_appointment_report()
elif choice == "4":
break
else:
print("无效的选择,请重新输入。")
def patient_menu(self):
while True:
print("\n患者管理菜单:")
print("1. 添加患者")
print("2. 查看患者")
print("3. 更新患者信息")
print("4. 删除患者")
print("5. 返回主菜单")
choice = input("请输入您的选择: ")
if choice == "1":
id = input("输入患者ID: ")
name = input("输入患者姓名: ")
age = input("输入患者年龄: ")
self.add_patient(id, name, age)
elif choice == "2":
self.view_patients()
elif choice == "3":
patient_id = input("输入要更新的患者ID: ")
new_name = input("输入新患者姓名: ")
new_age = input("输入新患者年龄: ")
self.update_patient(patient_id, new_name, new_age)
elif choice == "4":
patient_id = input("输入要删除的患者ID: ")
self.delete_patient(patient_id)
elif choice == "5":
break
else:
print("无效的选择,请重试。")
def doctor_menu(self):
while True:
print("\n医生管理菜单:")
print("1. 添加医生")
print("2. 查看医生")
print("3. 更新医生信息")
print("4. 删除医生")
print("5. 返回主菜单")
choice = input("请输入您的选择: ")
if choice == "1":
id = input("输入医生ID: ")
name = input("输入医生姓名: ")
specialization = input("输入医生专业: ")
self.add_doctor(id, name, specialization)
elif choice == "2":
self.view_doctors()
elif choice == "3":
doctor_id = input("输入要更新的医生ID: ")
new_name = input("输入新医生姓名: ")
new_specialization = input("输入新医生专业: ")
self.update_doctor(doctor_id, new_name, new_specialization)
elif choice == "4":
doctor_id = input("输入要删除的医生ID: ")
self.delete_doctor(doctor_id)
elif choice == "5":
break
else:
print("无效的选择,请重试。")
def appointment_menu(self):
while True:
print("\n预约管理菜单:")
print("1. 预约挂号")
print("2. 查看预约记录")
print("3. 更新预约信息")
print("4. 取消预约")
print("5. 返回主菜单")
choice = input("请输入您的选择: ")
if choice == "1":
patient_id = input("输入患者ID: ")
doctor_id = input("输入医生ID: ")
date = input("输入预约日期: ")
self.make_appointment(patient_id, doctor_id, date)
elif choice == "2":
self.view_appointments()
elif choice == "3":
patient_id = input("输入患者ID: ")
doctor_id = input("输入医生ID: ")
new_date = input("输入新的预约日期: ")
self.update_appointment(patient_id, doctor_id, new_date)
elif choice == "4":
patient_id = input("输入患者ID: ")
doctor_id = input("输入医生ID: ")
self.delete_appointment(patient_id, doctor_id)
elif choice == "5":
break
else:
print("无效的选择,请重试。")
def medical_record_menu(self):
while True:
print("\n病历管理菜单:")
print("1. 创建病历记录")
print("2. 查看病历记录")
print("3. 更新病历记录")
print("4. 返回主菜单")
choice = input("请输入您的选择: ")
if choice == "1":
patient_id = input("输入患者ID: ")
symptoms = input("输入症状: ")
diagnosis = input("输入诊断: ")
self.create_medical_record(patient_id, symptoms, diagnosis)
elif choice == "2":
self.view_medical_records()
elif choice == "3":
patient_id = input("输入患者ID: ")
new_symptoms = input("输入新的症状: ")
new_diagnosis = input("输入新的诊断: ")
self.update_medical_record(patient_id, new_symptoms, new_diagnosis)
elif choice == "4":
break
else:
print("无效的选择,请重试!")
# 主程序
clinic_system = ClinicManagementSystem()
while True:
print('诊所管理系统管理'.center(20,'-'))
print("主菜单:")
print("1. 患者管理")
print("2. 医生管理")
print("3. 预约管理")
print("4. 病历管理")
print("5. 报表统计")
print("6. 退出")
choice = input("请输入您的选择: ")
if choice == "1":
clinic_system.patient_menu()
elif choice == "2":
clinic_system.doctor_menu()
elif choice == "3":
clinic_system.appointment_menu()
elif choice == "4":
clinic_system.medical_record_menu()
elif choice == "5":
clinic_system.display_report_menu()
elif choice == "6":
print("退出诊所管理系统,再见!")
break
else:
print("无效的选择,请重试!")
class Patient:
def __init__(self, id, name, age):
self.id = id
self.name = name
self.age = age
class Doctor:
def __init__(self, id, name, specialization):
self.id = id
self.name = name
self.specialization = specialization
class Appointment:
def __init__(self, patient, doctor, date):
self.patient = patient
self.doctor = doctor
self.date = date
class MedicalRecord:
def __init__(self, patient, symptoms, diagnosis):
self.patient = patient
self.symptoms = symptoms
self.diagnosis = diagnosis
class ClinicManagementSystem:
def __init__(self):
self.patients = []
self.doctors = []
self.appointments = []
self.medical_records = []
def add_patient(self, id, name, age):
patient = Patient(id, name, age)
self.patients.append(patient)
print(f"成功添加患者:{name}。")
def view_patients(self):
print("\n患者信息:")
for patient in self.patients:
print(f"ID:{patient.id},姓名:{patient.name},年龄:{patient.age}")
def update_patient(self, patient_id, new_name, new_age):
patient = next((p for p in self.patients if p.id == patient_id), None)
if patient:
patient.name = new_name
patient.age = new_age
print(f"成功更新患者 {patient_id} 的信息。")
else:
print("未找到患者。")
def delete_patient(self, patient_id):
patient = next((p for p in self.patients if p.id == patient_id), None)
if patient:
self.patients.remove(patient)
print(f"成功删除患者 {patient_id} 的信息。")
else:
print("未找到患者。")
def add_doctor(self, id, name, specialization):
doctor = Doctor(id, name, specialization)
self.doctors.append(doctor)
print(f"成功添加医生:{name}。")
def view_doctors(self):
print("\n医生信息:")
for doctor in self.doctors:
print(f"ID:{doctor.id},姓名:{doctor.name},专业:{doctor.specialization}")
def update_doctor(self, doctor_id, new_name, new_specialization):
doctor = next((d for d in self.doctors if d.id == doctor_id), None)
if doctor:
doctor.name = new_name
doctor.specialization = new_specialization
print(f"成功更新医生 {doctor_id} 的信息。")
else:
print("未找到医生。")
def delete_doctor(self, doctor_id):
doctor = next((d for d in self.doctors if d.id == doctor_id), None)
if doctor:
self.doctors.remove(doctor)
print(f"成功删除医生 {doctor_id} 的信息。")
else:
print("未找到医生。")
def make_appointment(self, patient_id, doctor_id, date):
patient = next((p for p in self.patients if p.id == patient_id), None)
doctor = next((d for d in self.doctors if d.id == doctor_id), None)
if patient and doctor:
appointment = Appointment(patient, doctor, date)
self.appointments.append(appointment)
print(f"成功为患者 {patient.name} 预约了 {doctor.name} 医生在 {date} 的门诊。")
else:
print("未找到患者或医生。")
def view_appointments(self):
print("\n预约信息:")
for appointment in self.appointments:
print(f"患者:{appointment.patient.name},医生:{appointment.doctor.name},日期:{appointment.date}")
def update_appointment(self, patient_id, doctor_id, new_date):
appointment = next(
(a for a in self.appointments if a.patient.id == patient_id and a.doctor.id == doctor_id), None
)
if appointment:
appointment.date = new_date
print(f"成功更新患者 {patient_id} 与医生 {doctor_id} 的预约信息。")
else:
print("未找到预约信息。")
def delete_appointment(self, patient_id, doctor_id):
appointment = next(
(a for a in self.appointments if a.patient.id == patient_id and a.doctor.id == doctor_id), None
)
if appointment:
self.appointments.remove(appointment)
print(f"成功删除患者 {patient_id} 与医生 {doctor_id} 的预约信息。")
else:
print("未找到预约信息。")
def create_medical_record(self, patient_id, symptoms, diagnosis):
patient = next((p for p in self.patients if p.id == patient_id), None)
if patient:
medical_record = MedicalRecord(patient, symptoms, diagnosis)
self.medical_records.append(medical_record)
print(f"成功为患者 {patient.name} 创建了病历记录。")
else:
print("未找到患者。")
def view_medical_records(self):
print("\n病历记录:")
for record in self.medical_records:
print(f"患者:{record.patient.name},症状:{record.symptoms},诊断:{record.diagnosis}")
def update_medical_record(self, patient_id, new_symptoms, new_diagnosis):
record = next((r for r in self.medical_records if r.patient.id == patient_id), None)
if record:
record.symptoms = new_symptoms
record.diagnosis = new_diagnosis
print(f"成功更新患者 {patient_id} 的病历记录。")
else:
print("未找到病历记录。")
def generate_patient_report(self):
print("\n患者报表:")
print(f"总患者数量:{len(self.patients)}")
def generate_doctor_report(self):
print("\n医生报表:")
print(f"总医生数量:{len(self.doctors)}")
for doctor in self.doctors:
appointments_count = sum(1 for a in self.appointments if a.doctor.id == doctor.id)
print(f"医生 {doctor.name} 的预约数量:{appointments_count}")
def generate_appointment_report(self):
print("\n预约报表:")
print(f"总预约数量:{len(self.appointments)}")
def display_report_menu(self):
while True:
print("\n报表统计管理菜单:")
print("1. 生成患者报表")
print("2. 生成医生报表")
print("3. 生成预约报表")
print("4. 返回主菜单")
choice = input("请选择操作 (1-4): ")
if choice == "1":
self.generate_patient_report()
elif choice == "2":
self.generate_doctor_report()
elif choice == "3":
self.generate_appointment_report()
elif choice == "4":
break
else:
print("无效的选择,请重新输入。")
def patient_menu(self):
while True:
print("\n患者管理菜单:")
print("1. 添加患者")
print("2. 查看患者")
print("3. 更新患者信息")
print("4. 删除患者")
print("5. 返回主菜单")
choice = input("请输入您的选择: ")
if choice == "1":
id = input("输入患者ID: ")
name = input("输入患者姓名: ")
age = input("输入患者年龄: ")
self.add_patient(id, name, age)
elif choice == "2":
self.view_patients()
elif choice == "3":
patient_id = input("输入要更新的患者ID: ")
new_name = input("输入新患者姓名: ")
new_age = input("输入新患者年龄: ")
self.update_patient(patient_id, new_name, new_age)
elif choice == "4":
patient_id = input("输入要删除的患者ID: ")
self.delete_patient(patient_id)
elif choice == "5":
break
else:
print("无效的选择,请重试。")
def doctor_menu(self):
while True:
print("\n医生管理菜单:")
print("1. 添加医生")
print("2. 查看医生")
print("3. 更新医生信息")
print("4. 删除医生")
print("5. 返回主菜单")
choice = input("请输入您的选择: ")
if choice == "1":
id = input("输入医生ID: ")
name = input("输入医生姓名: ")
specialization = input("输入医生专业: ")
self.add_doctor(id, name, specialization)
elif choice == "2":
self.view_doctors()
elif choice == "3":
doctor_id = input("输入要更新的医生ID: ")
new_name = input("输入新医生姓名: ")
new_specialization = input("输入新医生专业: ")
self.update_doctor(doctor_id, new_name, new_specialization)
elif choice == "4":
doctor_id = input("输入要删除的医生ID: ")
self.delete_doctor(doctor_id)
elif choice == "5":
break
else:
print("无效的选择,请重试。")
def appointment_menu(self):
while True:
print("\n预约管理菜单:")
print("1. 预约挂号")
print("2. 查看预约记录")
print("3. 更新预约信息")
print("4. 取消预约")
print("5. 返回主菜单")
choice = input("请输入您的选择: ")
if choice == "1":
patient_id = input("输入患者ID: ")
doctor_id = input("输入医生ID: ")
date = input("输入预约日期: ")
self.make_appointment(patient_id, doctor_id, date)
elif choice == "2":
self.view_appointments()
elif choice == "3":
patient_id = input("输入患者ID: ")
doctor_id = input("输入医生ID: ")
new_date = input("输入新的预约日期: ")
self.update_appointment(patient_id, doctor_id, new_date)
elif choice == "4":
patient_id = input("输入患者ID: ")
doctor_id = input("输入医生ID: ")
self.delete_appointment(patient_id, doctor_id)
elif choice == "5":
break
else:
print("无效的选择,请重试。")
def medical_record_menu(self):
while True:
print("\n病历管理菜单:")
print("1. 创建病历记录")
print("2. 查看病历记录")
print("3. 更新病历记录")
print("4. 返回主菜单")
choice = input("请输入您的选择: ")
if choice == "1":
patient_id = input("输入患者ID: ")
symptoms = input("输入症状: ")
diagnosis = input("输入诊断: ")
self.create_medical_record(patient_id, symptoms, diagnosis)
elif choice == "2":
self.view_medical_records()
elif choice == "3":
patient_id = input("输入患者ID: ")
new_symptoms = input("输入新的症状: ")
new_diagnosis = input("输入新的诊断: ")
self.update_medical_record(patient_id, new_symptoms, new_diagnosis)
elif choice == "4":
break
else:
print("无效的选择,请重试!")
# 主程序
clinic_system = ClinicManagementSystem()
while True:
print('诊所管理系统管理'.center(20,'-'))
print("主菜单:")
print("1. 患者管理")
print("2. 医生管理")
print("3. 预约管理")
print("4. 病历管理")
print("5. 报表统计")
print("6. 退出")
choice = input("请输入您的选择: ")
if choice == "1":
clinic_system.patient_menu()
elif choice == "2":
clinic_system.doctor_menu()
elif choice == "3":
clinic_system.appointment_menu()
elif choice == "4":
clinic_system.medical_record_menu()
elif choice == "5":
clinic_system.display_report_menu()
elif choice == "6":
print("退出诊所管理系统,再见!")
break
else:
print("无效的选择,请重试!")