📅  最后修改于: 2023-12-03 14:59:51.185000             🧑  作者: Mango
本程序是基于C++语言开发的医院管理系统,旨在帮助医院轻松管理病人信息、医生信息、药品信息以及病历信息等,提高医院工作效率。
// 添加病人信息
void AddPatient() {
patient p, *q;
cout << "请输入病人信息:" << endl;
cout << "病人编号:";
cin >> p.patientId;
cout << "病人姓名:";
cin >> p.patientName;
cout << "病人性别:";
cin >> p.sex;
cout << "病人年龄:";
cin >> p.age;
cout << "病人电话:";
cin >> p.phone;
q = FindPatient(p.patientId);
if (q) {
cout << "该病人已存在!" << endl;
return;
}
if (patientList == NULL) {
p.next = NULL;
patientList = &p;
} else {
q = patientList;
while (q->next) {
q = q->next;
}
p.next = NULL;
q->next = &p;
}
SavePatient();
cout << "添加成功!" << endl;
}
// 删除病人信息
void DeletePatient() {
int patientId;
cout << "请输入需要删除的病人编号:";
cin >> patientId;
patient* p = FindPatient(patientId);
if (p == NULL) {
cout << "该病人不存在!" << endl;
return;
}
if (p == patientList) {
patientList = p->next;
} else {
patient* q = patientList;
while (q->next != p) {
q = q->next;
}
q->next = p->next;
}
free(p);
SavePatient();
cout << "删除成功!" << endl;
}
// 修改病人信息
void ModifyPatient() {
int patientId;
cout << "请输入需要修改的病人编号:";
cin >> patientId;
patient* p = FindPatient(patientId);
if (p == NULL) {
cout << "该病人不存在!" << endl;
return;
}
cout << "请输入修改后的信息:" << endl;
cout << "病人姓名:";
cin >> p->patientName;
cout << "病人性别:";
cin >> p->sex;
cout << "病人年龄:";
cin >> p->age;
cout << "病人电话:";
cin >> p->phone;
SavePatient();
cout << "修改成功!" << endl;
}
// 查询病人信息
void QueryPatient() {
int patientId;
cout << "请输入需要查询的病人编号:";
cin >> patientId;
patient* p = FindPatient(patientId);
if (p == NULL) {
cout << "该病人不存在!" << endl;
return;
}
cout << "病人信息:" << endl;
cout << "编号\t姓名\t性别\t年龄\t电话" << endl;
cout << p->patientId << "\t" << p->patientName << "\t" << p->sex << "\t" << p->age << "\t" << p->phone << endl;
}
// 根据病人年龄生成报表
void PatientAgeReport() {
int age, count = 0;
cout << "请输入查询条件(病人年龄):";
cin >> age;
patient* p = patientList;
cout << "编号\t姓名\t性别\t年龄\t电话" << endl;
while (p) {
if (p->age == age) {
cout << p->patientId << "\t" << p->patientName << "\t" << p->sex << "\t" << p->age << "\t" << p->phone << endl;
count++;
}
p = p->next;
}
cout << "共查询到" << count << "条记录!" << endl;
}
// 根据医生姓名生成报表
void DoctorNameReport() {
string doctorName;
int count = 0;
cout << "请输入查询条件(医生姓名):";
cin >> doctorName;
doctor* p = doctorList;
cout << "编号\t姓名\t等级\t专业领域\t电话" << endl;
while (p) {
if (p->doctorName == doctorName) {
cout << p->doctorId << "\t" << p->doctorName << "\t" << p->level << "\t" << p->specialty << "\t" << p->phone << endl;
count++;
}
p = p->next;
}
cout << "共查询到" << count << "条记录!" << endl;
}