赞
踩
点击获取源码资源
基于C++实现的医院管理系统,分为管理员与医护人员登录两个部分,可以作为课程设计使用。
**
**
**
**
**
**
void firstWindow()
{int n;
printf("\n\n\n\n\n\n");
printf(" **********欢迎使用患者住院管理系统**********\n");
Sleep(1000);
while(1)
{
n=secondWindow();
switch(n)
{case 1:{int d;d=adminLand();
switch(d)
{case 1:{
while(1)
{int m;m=adminWindow();
switch(m)
{case 1:AddthePatientInfo(&tListInfo);break;
case 2:SavetheInfo(&tListInfo);break;
case 3:ModifythePatientInfo(&tListInfo);break;
case 4:FindtheInfo(&tListInfo);break;
case 5:DeletetheInfo(&tListInfo);break;
case 6:tkeychange();break;
case 7:endWindow();break;
}
if(m>7)break;
}
}
break;
default:endWindow(); break;}
break;}
case 2: {int e;e=doctorLand();
switch(e)
{ case 1:{ while(1)
{
int f;f=doctorWindow();
switch(f)
{case 1:AddtheCaseInfo(&tListInfo);break;
case 2:ModifytheCaseInfo(&tListInfo);break;
case 3:tkeychange();break;
case 4:FindtheInfo(&tListInfo);break;
case 5:endWindow();break;
case 6:SavetheInfo(&tListInfo);break;
}
if(f>6)break;
}
}break;
case 2:{int n;n=nurseWindow();
switch(n)
{case 1:FindtheInfo(&tListInfo);break;
case 2:tkeychange();break;
case 3:endWindow();break;
}
}break;
}break;
}
case 3:manage();break;
case 4:clear();break;
case 5:ghostsave();break;
case 6:ghostload();break;
case 7:endWindow();break;
}
}
}
/*
登录选择页面
*/
int secondWindow()
{
system("cls");
cout<<"\n\n\n\n\n";
cout<<" ===================================================="<<endl;
cout<<" | |"<<endl;
cout<<" | 欢迎使用患者住院管理系统! |"<<endl;
cout<<" | |"<<endl;
cout<<" ===================================================="<<endl;
cout<<" | |"<<endl;
cout<<" | |"<<endl;
cout<<" | 1.管理员登录 |"<<endl;
cout<<" | 2.医护人员登陆 |"<<endl;
cout<<" | 3.病人住院管理子系统 |"<<endl;
cout<<" | 4.系统初始化 |"<<endl;
cout<<" | 5.系统备份 |"<<endl;
cout<<" | 6.系统还原 |"<<endl;
cout<<" | 7.退出 |"<<endl;
cout<<" | 请选择相应数字 |"<<endl;
cout<<" | |"<<endl;
cout<<" ===================================================="<<endl;
while(scanf("%d",&a)!=EOF)
{
system("cls");
if(a==1||a==2||a==3||a==4||a==5||a==6)return a;
else
{
cout<<"\n\n\n\n\n\n\n\n";
cout<<" ===================================================="<<endl;
cout<<" | |"<<endl;
cout<<" | 错误输入! 请重新选择! |"<<endl;
cout<<" | |"<<endl;
cout<<" ===================================================="<<endl;
Sleep(1500);
system("cls");
cout<<"\n\n\n\n\n";
cout<<" ===================================================="<<endl;
cout<<" | |"<<endl;
cout<<" | 欢迎使用患者住院管理系统! |"<<endl;
cout<<" | |"<<endl;
cout<<" ===================================================="<<endl;
cout<<" | |"<<endl;
cout<<" | |"<<endl;
cout<<" | 1.管理员登录 |"<<endl;
cout<<" | 2.医护人员登陆 |"<<endl;
cout<<" | 3.病人住院管理子系统 |"<<endl;
cout<<" | 4.系统初始化 |"<<endl;
cout<<" | 5.系统备份 |"<<endl;
cout<<" | 6.系统还原 |"<<endl;
cout<<" | 7.退出 |"<<endl;
cout<<" | 请选择相应数字 |"<<endl;
cout<<" | |"<<endl;
cout<<" ===================================================="<<endl;
}
}
return a;
}
int adminLand()
{
system("cls");
char admin[20],password[20],passwordr[20] ={0};
int filelength = 0;//计算文件长度
ifstream fin;
fin.open("密码.txt",ios::in);
fin.seekg(0,ios::end);
filelength = fin.tellg();//求文件长
fin.seekg(0);//求出文件长度后指针需要归零
fin.read((char*)&passwordr,filelength);
fin.close();
// cout<<passwordr<<filelength<<endl;//测试读取内容
cout<<"\n\n\n";
cout<<" ===================================================="<<endl;
cout<<" | |"<<endl;
cout<<" | 欢迎使用患者住院管理系统! |"<<endl;
cout<<" | |"<<endl;
cout<<" ===================================================="<<endl;
cout<<endl;
cout<<" ===================================================="<<endl;
cout<<" | |"<<endl;
cout<<" | 请输入您的用户名: |"<<endl;
cout<<" | |"<<endl;
cout<<" ===================================================="<<endl;
cin>>admin;cout<<endl;
cout<<" ===================================================="<<endl;
cout<<" | |"<<endl;
cout<<" | 密码: |"<<endl;
cout<<" | |"<<endl;
cout<<" ===================================================="<<endl;
cin>>password;int i=0;int c;
while(1)
{
if(strcmp(admin,"Admin")==0 && strcmp(password,passwordr)== 0)
{
cout<<"\n\n\n\n\n\n\n";
cout<<" ===================================================="<<endl;
cout<<" | |"<<endl;
cout<<" | 欢迎登陆! |"<<endl;
cout<<" | |"<<endl;
cout<<" ===================================================="<<endl;
getch();c=1;
break;}
else
{
cout<<"\n\n\n\n\n\n";
cout<<" ===================================================="<<endl;
cout<<" | |"<<endl;
cout<<" | 账号或密码错误! |"<<endl;
cout<<" | |"<<endl;
cout<<" | 您还有"<<2-i<<"次机会 |"<<endl;
cout<<" | |"<<endl;
cout<<" ===================================================="<<endl;
i++;
Sleep(1000);
system("cls");
cout<<"\n\n\n\n\n\n\n";
cout<<" ===================================================="<<endl;
cout<<" | |"<<endl;
cout<<" | 请输入您的用户名: |"<<endl;
cout<<" | |"<<endl;
cout<<" ===================================================="<<endl;
cin>>admin;cout<<endl;
cout<<" ===================================================="<<endl;
cout<<" | |"<<endl;
cout<<" | 密码: |"<<endl;
cout<<" | |"<<endl;
cout<<" ===================================================="<<endl;
cin>>password;
if(i==2){ break;}
}
}
return c;
}
int adminWindow()
{
system("cls");
cout<<"\n\n\n\n";
cout<<" ===================================================="<<endl;
cout<<" | |"<<endl;
cout<<" | 欢迎使用患者住院管理系统! |"<<endl;
cout<<" | |"<<endl;
cout<<" ===================================================="<<endl;
cout<<" | |"<<endl;
cout<<" | 管理信息 |"<<endl;
cout<<" | |"<<endl;
cout<<" | 1.患者信息的录入 |"<<endl;
cout<<" | 2.患者信息的保存 |"<<endl;
cout<<" | 3.患者信息的修改 |"<<endl;
cout<<" | 4.患者信息的查询 |"<<endl;
cout<<" | 5.患者信息的删除 |"<<endl;
cout<<" | 6.密码修改 |"<<endl;
cout<<" | 7.退出 |"<<endl;
cout<<" | 请选择相应数字 |"<<endl;
cout<<" | |"<<endl;
cout<<" ===================================================="<<endl;
int b;while(scanf("%d",&b)!=EOF)
{
system("cls");
if(b>=1&&b<=9)return b;
else
{
cout<<"\n\n\n\n\n\n\n\n";
cout<<" ===================================================="<<endl;
cout<<" | |"<<endl;
cout<<" | 错误输入! 请重新选择! |"<<endl;
cout<<" | |"<<endl;
cout<<" ===================================================="<<endl;
Sleep(1500);
system("cls");
cout<<"\n\n\n\n";
cout<<" ===================================================="<<endl;
cout<<" | |"<<endl;
cout<<" | 欢迎使用患者住院管理系统! |"<<endl;
cout<<" | |"<<endl;
cout<<" ===================================================="<<endl;
cout<<" | |"<<endl;
cout<<" | 1.患者信息的录入 |"<<endl;
cout<<" | 2.患者信息的保存 |"<<endl;
cout<<" | 3.患者信息的修改 |"<<endl;
cout<<" | 4.患者信息的查询 |"<<endl;
cout<<" | 5.患者信息的删除 |"<<endl;
cout<<" | 6.密码修改 |"<<endl;
cout<<" | 7.退出 |"<<endl;
cout<<" | 请选择相应数字 |"<<endl;
cout<<" | |"<<endl;
cout<<" ===================================================="<<endl;
}
}
return b;}
int doctorLand()
{
system("cls");
char admin[20],password[20],passwordr[20] ={0};
int filelength = 0;//计算文件长度
ifstream fin;
fin.open("密码.txt",ios::in);
fin.seekg(0,ios::end);
filelength = fin.tellg();//求文件长
fin.seekg(0);//求出文件长度后指针需要归零
fin.read((char*)&passwordr,filelength);
fin.close();
// cout<<passwordr<<filelength<<endl;//测试读取内容
cout<<" ===================================================="<<endl;
cout<<" | |"<<endl;
cout<<" | 欢迎使用患者住院管理系统! |"<<endl;
cout<<" | |"<<endl;
cout<<" ===================================================="<<endl;
cout<<endl;
cout<<" ===================================================="<<endl;
cout<<" | |"<<endl;
cout<<" | 请输入您的用户名: |"<<endl;
cout<<" | |"<<endl;
cout<<" ===================================================="<<endl;
cin>>admin;cout<<endl;
cout<<" ===================================================="<<endl;
cout<<" | |"<<endl;
cout<<" | 密码: |"<<endl;
cout<<" | |"<<endl;
cout<<" ===================================================="<<endl;
cin>>password;int i=0;int c;
while(1)
{
if((admin[0]=='D'||admin[0]=='N')&&(admin[1]*100+admin[2]*10+admin[3]>=1|| admin[1]*100+admin[2]*10+admin[3]<=500)&& strcmp(password,passwordr)== 0)
{
cout<<"\n\n\n\n\n\n\n";
cout<<" ===================================================="<<endl;
cout<<" | |"<<endl;
cout<<" | 欢迎登陆! |"<<endl;
cout<<" | |"<<endl;
cout<<" ===================================================="<<endl;
getch();c=1;
break;
}
else
{
cout<<"\n\n\n\n\n\n";
cout<<" ===================================================="<<endl;
cout<<" | |"<<endl;
cout<<" | 账号或密码错误! |"<<endl;
cout<<" | |"<<endl;
cout<<" | 您还有"<<2-i<<"次机会 |"<<endl;
cout<<" | |"<<endl;
cout<<" ===================================================="<<endl;
i++;
Sleep(1000);
system("cls");
cout<<" ===================================================="<<endl;
cout<<" | |"<<endl;
cout<<" | 欢迎使用患者住院管理系统! |"<<endl;
cout<<" | |"<<endl;
cout<<" ===================================================="<<endl;
cout<<endl;
cout<<" ===================================================="<<endl;
cout<<" | |"<<endl;
cout<<" | 请输入您的用户名: |"<<endl;
cout<<" | |"<<endl;
cout<<" ===================================================="<<endl;
cin>>admin;cout<<endl;
cout<<" ===================================================="<<endl;
cout<<" | |"<<endl;
cout<<" | 密码: |"<<endl;
cout<<" | |"<<endl;
cout<<" ===================================================="<<endl;
cin>>password;
if(i==2){ break;}
}
}
int d;if(c==1){if(admin[0]=='D')d=1;
if(admin[0]=='N')d=2;
}
return d;
}
int doctorWindow()
{
system("cls");
cout<<"\n\n\n\n\n\n";
cout<<" ===================================================="<<endl;
cout<<" | |"<<endl;
cout<<" | 欢迎使用患者住院管理系统! |"<<endl;
cout<<" | |"<<endl;
cout<<" ===================================================="<<endl;
cout<<" | |"<<endl;
cout<<" | 请选择相应数字: |"<<endl;
cout<<" | 1.录入患者病历信息 |"<<endl;
cout<<" | 2.修改患者病历信息 |"<<endl;
cout<<" | 3.修改密码 |"<<endl;
cout<<" | 4.查看患者信息 |"<<endl;
cout<<" | 5.退出系统 |"<<endl;
cout<<" | 6.保存患者病历信息 |"<<endl;
cout<<" | |"<<endl;
cout<<" ===================================================="<<endl;
while(scanf("%d",&a)!=EOF)
{
system("cls");
if(a==1||a==2||a==3||a==4||a==5||a==6)return a;
else
{
cout<<"\n\n\n\n\n\n\n\n";
cout<<" ===================================================="<<endl;
cout<<" | |"<<endl;
cout<<" | 错误输入! 请重新选择! |"<<endl;
cout<<" | |"<<endl;
cout<<" ===================================================="<<endl;
Sleep(1500);
system("cls");
cout<<"\n\n\n\n\n\n";
cout<<" ===================================================="<<endl;
cout<<" | |"<<endl;
cout<<" | 欢迎使用患者住院管理系统! |"<<endl;
cout<<" | |"<<endl;
cout<<" ===================================================="<<endl;
cout<<" | |"<<endl;
cout<<" | 请选择相应数字: |"<<endl;
cout<<" | 1.录入患者病历信息 |"<<endl;
cout<<" | 2.修改患者病历信息 |"<<endl;
cout<<" | 3.修改密码 |"<<endl;
cout<<" | 4.查看患者信息 |"<<endl;
cout<<" | 5.退出系统 |"<<endl;
cout<<" | 6.保存患者病历信息 |"<<endl;
cout<<" | |"<<endl;
cout<<" ===================================================="<<endl;
}
}
return a;
}
int nurseWindow()
{
system("cls");
cout<<"\n\n\n\n\n\n\n";
cout<<" ===================================================="<<endl;
cout<<" | |"<<endl;
cout<<" | 欢迎使用患者住院管理系统! |"<<endl;
cout<<" | |"<<endl;
cout<<" ===================================================="<<endl;
cout<<" | |"<<endl;
cout<<" | 请选择相应数字: |"<<endl;
cout<<" | 1.患者信息查询 |"<<endl;
cout<<" | 2.密码修改 |"<<endl;
cout<<" | 3.退出 |"<<endl;
cout<<" | |"<<endl;
cout<<" ===================================================="<<endl;
while(scanf("%d",&a)!=EOF)
{
system("cls");
if(a==1||a==2||a==3)return a;
else
{
cout<<"\n\n\n\n\n\n\n";
cout<<" ===================================================="<<endl;
cout<<" | |"<<endl;
cout<<" | 错误输入! 请重新选择! |"<<endl;
cout<<" | |"<<endl;
cout<<" ===================================================="<<endl;
Sleep(1500);
system("cls");
cout<<"\n\n\n\n\n\n\n";
cout<<" ===================================================="<<endl;
cout<<" | |"<<endl;
cout<<" | 欢迎使用患者住院管理系统! |"<<endl;
cout<<" | |"<<endl;
cout<<" ===================================================="<<endl;
cout<<" | |"<<endl;
cout<<" | 请选择相应数字: |"<<endl;
cout<<" | 1.患者信息查询 |"<<endl;
cout<<" | 2.密码修改 |"<<endl;
cout<<" | 3.退出 |"<<endl;
cout<<" | |"<<endl;
cout<<" ===================================================="<<endl;
}
}
return 0;
}
void tkeychange()
{
char a[20],p[20];int k;
cout<<"请输入新密码"<<endl;
cin>>a;
cout<<"请重新输入新密码"<<endl;
cin>>p;
for( k=0;a[k];k++);
k++;
if(strcmp(a,p)==0)
{ ofstream f;
f.open("密码.txt",ios::out);
f.write((char*)a,k);
f.close();
cout<<"修改成功"<<endl;
}
return;
}
void clear()
{
system("cls");
int k;
cout<<"\n\n\n\n\n";
cout<<" ===================================================="<<endl;
cout<<" | |"<<endl;
cout<<" | 欢迎使用患者住院管理系统! |"<<endl;
cout<<" | |"<<endl;
cout<<" ===================================================="<<endl;
cout<<" | |"<<endl;
cout<<" | 确定要初始化系统么?是(1)/ 否(0) |"<<endl;
cout<<" | |"<<endl;
cout<<" ===================================================="<<endl;
cin>>k;
cout<<" ===================================================="<<endl;
cout<<"\n";
try
{
if(k!=0&&k!=1)
throw "error";
}
catch(...)
{
cout<<"输入错误!按任意键退出系统"<<endl;
getch();
exit(1);
}
if(k == 1)
{
ofstream fout;
fout.open("Info.txt",ios::out|ios::trunc); //清除文件中所有的数据
fout.close();
cout<<" ===================================================="<<endl;
cout<<" | |"<<endl;
cout<<" | 系统已经初始化,按任意键退出系统 |"<<endl;
cout<<" | |"<<endl;
cout<<" ===================================================="<<endl;
getch();
}
else if(k==0)
{
cout<<" ===================================================="<<endl;
cout<<" | |"<<endl;
cout<<" | 按任意键退出系统 |"<<endl;
cout<<" | |"<<endl;
cout<<" ===================================================="<<endl;
getch();
}
}
void ghostsave()
{
system("cls");
int t;
cout<<"\n\n\n\n\n";
cout<<" ======================================================="<<endl;
cout<<" | |"<<endl;
cout<<" | 欢迎使用患者住院管理系统! |"<<endl;
cout<<" | |"<<endl;
cout<<" ======================================================="<<endl;
cout<<" | |"<<endl;
cout<<" | 确定要备份系统么?是(1)/ 否(0) |"<<endl;
cout<<" | |"<<endl;
cout<<" ======================================================="<<endl;
cin>>t;
cout<<" ======================================================="<<endl;
try
{
if(t!=0&&t!=1)
throw "error";
}
catch(...)
{
cout<<" 输入错误!按任意键退出系统 "<<endl;
getch();
exit(1);
}
if(t == 1)
{
char ch;
ifstream fin;
fin.open("Info.txt"); //清除文件中所有的数据
ofstream fout;
fout.open("InfoGhost.txt");
while(fin.get(ch))
{
fout<<ch;
}
fin.close();
fout.close();
cout<<" ======================================================="<<endl;
cout<<" | |"<<endl;
cout<<" | 系统已经备份,按任意键退出系统. |"<<endl;
cout<<" | |"<<endl;
cout<<" ======================================================="<<endl;
getch();
}
else if(a==0)
{
cout<<" ======================================================="<<endl;
cout<<" | |"<<endl;
cout<<" | 按任意键退出系统. |"<<endl;
cout<<" | |"<<endl;
cout<<" ======================================================="<<endl;
getch();
}
exit(1);
}
void ghostload()
{
system("cls");
int h;
cout<<"\n\n\n\n\n";
cout<<" ======================================================"<<endl;
cout<<" | |"<<endl;
cout<<" | 欢迎使用患者住院管理系统! |"<<endl;
cout<<" | |"<<endl;
cout<<" ======================================================"<<endl;
cout<<" | |"<<endl;
cout<<" | 确定要还原系统么?是(1)/ 否(0) |"<<endl;
cout<<" | |"<<endl;
cout<<" ======================================================"<<endl;
cin>>h;
cout<<" ======================================================"<<endl;
try
{
if(h!=0&&h!=1)
throw "error";
}
catch(...)
{
cout<<"输入错误!按任意键退出系统"<<endl;
getch();
exit(1);
}
if(h == 1)
{
char ch;
ofstream fout;
fout.open("Info.txt"); //清除文件中所有的数据
ifstream fin;
fin.open("InfoGhost1.txt");
while(fin.get(ch))
{
fout<<ch;
}
fin.close();
fout.close();
cout<<" ======================================================"<<endl;
cout<<" | |"<<endl;
cout<<" | 系统已经还原,按任意键退出系统. |"<<endl;
cout<<" | |"<<endl;
cout<<" ======================================================"<<endl;
getch();
}
else if(a==0)
{
cout<<" ======================================================"<<endl;
cout<<" | |"<<endl;
cout<<" | 按任意键退出系统. |"<<endl;
cout<<" | |"<<endl;
cout<<" ======================================================"<<endl;
getch();
}
exit(1);
}
class PatientInfo //患者信息,包括基本信息和住院信息
{
public:
char name[Max]; //姓名
int age; //年龄
char sex[Max]; //性别
char job[Max]; //职业
char marriage[Max]; //婚姻状况
char Id[Max]; //房间号和床号(****+**)第一位为楼层,第二位为科室,三四位为房间号,五六位为床号
char record[Max]; //病历号
char inTime[Max]; //入院时间
char outTime[Max]; //出院时间
char wage[Max]; //治疗费用
char mainDoctor[Max]; //主治医师
PatientInfo()
{
memset(name,0,Max);
age=0;
memset(sex,0,Max);
memset(job,0,Max);
memset(marriage,0,Max);
memset(Id,0,Max);
memset(record,0,Max);
memset(inTime,0,Max);
memset(outTime,0,Max);
memset(wage,0,Max);
memset(mainDoctor,0,Max);
}
};
class CaseInfo
{
public:
char illness[Max]; /*病史*/
char result[Max]; /*诊断结果*/
char medicine[Max]; // 用药情况
char ill[Max]; //实时病况
char time[Max]; //检查日期
char man[Max]; // 当日负责人
CaseInfo()
{
memset(illness,0,Max);
memset(result,0,Max);
memset(medicine,0,Max);
memset(ill,0,Max);
memset(time,0,Max);
memset(man,0,Max);
}
};
class Info:public PatientInfo,public CaseInfo
{
public:
bool flag;
Info(){flag=false;}
};
void ReadData(tList<Info> *tListInfo)//读取数据库
{
char max[Max];
ifstream ifile("Info.txt",ios_base::in); //创建一个输出文件流对象
if (!ifile)
{
cerr << "读取时打开文件出错!" << endl;
}
Info info;
while(ifile.getline(max,Max)) //遍历文本,读取数据
{
ifile.getline(max,Max);
strcpy(info.name,max);//读取姓名
memset(max,0,Max);
ifile.getline(max,Max);//读取年龄
info.age=atoi(max);
memset(max,0,Max);
ifile.getline(max,Max);//读取性别
strcpy(info.sex,max);
memset(max,0,Max);
ifile.getline(max,Max);//读取职业
strcpy(info.job,max);
memset(max,0,Max);
ifile.getline(max,Max);//读取婚姻状况
strcpy(info.marriage,max);
memset(max,0,Max);
ifile.getline(max,Max);//读取房间号和床号
strcpy(info.Id,max);
memset(max,0,Max);
ifile.getline(max,Max);//读取病历号
strcpy(info.record,max);
memset(max,0,Max);
ifile.getline(max,Max);//读取入院时间
strcpy(info.inTime,max);
memset(max,0,Max);
ifile.getline(max,Max);//读取出院时间
strcpy(info.outTime,max);
memset(max,0,Max);
ifile.getline(max,Max);//读取所有费用
strcpy(info.wage,max);
ifile.getline(max,Max);//读取主治医生
strcpy(info.mainDoctor,max);
memset(max,0,Max);
info.flag=true;
tListInfo->Insert(info);
ifile.getline(max,Max);
strcpy(info.illness,max);
memset(max,0,Max);
ifile.getline(max,Max);
strcpy(info.result,max);
memset(max,0,Max);
ifile.getline(max,Max);
strcpy(info.ill,max);
memset(max,0,Max);
ifile.getline(max,Max);
strcpy(info.medicine,max);
memset(max,0,Max);
ifile.getline(max,Max);
strcpy(info.time,max);
memset(max,0,Max);
ifile.getline(max,Max);
strcpy(info.man,max);
memset(max,0,Max);
info.flag=true;
tListInfo->Insert(info);
}
cout<<"读取数据成功!\n\n";
ifile.close();//关闭文件
return;
}
void AddthePatientInfo(tList<Info> *tListInfo)// 患者信息录入
{
Info tempInfo; //定义临时患者
cout<<"下面开始添加患者信息\n";
cout<<"请输入入住的患者姓名:";
cin>>tempInfo.name; //读入患者姓名
cout<<"请输入入住的患者年龄:";
cin>>tempInfo.age; //读入患者年龄
cout<<"请输入入住的患者性别:";
cin>>tempInfo.sex; //读入患者性别
cout<<"请输入入住的患者职业:";
cin>>tempInfo.job; //读入患者职业
cout<<"请输入入住的患者婚姻状况:";
cin>>tempInfo.marriage; //读入患者婚姻状况
cout<<"请输入入住的患者病房编号:";
cin>>tempInfo.Id; //读入病房编号
cout<<"请输入患者病历号:";
cin>>tempInfo.record; //读入患者病历号
cout<<"请输入患者入院时间:";
cin>>tempInfo.inTime; //读入患者入院时间
cout<<"请输入患者出院时间:";
cin>>tempInfo.outTime; //读入患者出院时间
cout<<"请输入患者住院期间各种费用:";
cin>>tempInfo.wage; //读入住院期间各种费用
cout<<"请输入患者主治医师:";
cin>>tempInfo.mainDoctor; //读入患者主治医师
tempInfo.flag=true;
tListInfo->Insert(tempInfo);
cout<<"添加成功!\n";
system("pause"); //pause:停顿,终止
system("cls");
return;
}
void AddtheCaseInfo(tList<Info> *tListInfo)// 患者病历信息录入
{
char Record[Max];
cout<<"\n请输入你要录入的患者病历号:";
cin>>Record; //读取患者病历号
bool flag=false;
cNode<Info> *p;
p=tListInfo->head->next;
while(p)
{
if(strcmp(p->data.record,Record)==0 && p->data.flag)
{
flag=true;
break;
}
p=p->next;
}
if(flag==true)
{ Info tempInfo; //定义临时患者
cout<<"下面开始添加患者信息\n";
cout<<"请输入患者病史(填写以前是否患过类似病症写入‘是’或‘否’:";
cin>>tempInfo.illness;
cout<<"请输入患者的诊断结果(中间请不要使用空格符号):";
cin>>tempInfo.result;
cout<<"请输入患者的用药情况(中间请不要使用空格符号):";
cin>>tempInfo.medicine;
cout<<"请输入入患者的实时病况(中间请不要使用空格符号):";
cin>>tempInfo.ill;
cout<<"请输入检查日期(例如2013年7月20日中间请不要使用空格符号):";
cin>>tempInfo.time;
cout<<"请输入当日负责人姓名:";
cin>>tempInfo.man;
tempInfo.flag=true;
cout<<"添加成功!\n";
tListInfo->Insert(tempInfo);
system("pause"); //pause:停顿,终止
system("cls");
return;
}
}
void SavetheInfo(tList<Info> *tListInfo) //保存数据
{
int i=0;
ofstream ofile("Info.txt",ios_base::out); //创建一个输入文件流对象
if (!ofile)
{
cerr << "保存时打开文件出错!" << endl;
}
cNode<Info> *p;
p=tListInfo->head->next;
while(p)
{
//从内存中读取数据,存到外盘
if(p->data.flag)
{
ofile<<"\n";
ofile<<(p->data).name<<"\n";
ofile<<(p->data).age <<"\n";
ofile<<(p->data).sex<<"\n";
ofile<<(p->data).job<<"\n";
ofile<<(p->data).marriage<<"\n";
ofile<<(p->data).Id<<"\n";
ofile<<(p->data).record<<"\n";
ofile<<(p->data).inTime<<"\n";
ofile<<(p->data).outTime<<"\n";
ofile<<(p->data).wage<<"\n";
ofile<<(p->data).mainDoctor<<"\n";
ofile<<(p->data).illness<<"\n";
ofile<<(p->data).ill<<"\n";
ofile<<(p->data).medicine<<"\n";
ofile<<(p->data).result<<"\n";
ofile<<(p->data).time<<"\n";
ofile<<(p->data).man<<"\n";
}
p=p->next;
}
cout<<"保存数据成功!\n";
ofile.close();
system("pause");
system("cls");
return;
}
void ModifythePatientInfo(tList<Info> *tListInfo) //修改患者信息
{
char Record[Max];
cout<<"\n请输入你要修改的患者病历号:";
cin>>Record; //读取患者病历号
bool flag=false;
cNode<Info> *p;
p=tListInfo->head->next;
while(p)
{
if(strcmp(p->data.record,Record)==0 && p->data.flag)
{
flag=true;
break;
}
p=p->next;
}
if(flag==true)
{//显示屏幕//让所有的数据都紧跟在制表符后面输出。
cout<<"找到了,该患者当前信息是:\n";
cout<<"\n\n患者姓名:"<<(p->data).name<<"\n\t患者年龄:"<<(p->data).age<<"\n\t\t患者性别:"<<(p->data).sex<<"\n\t\t患者职业:"<<(p->data).job<<"\n\t\t患者婚姻状况:"<<(p->data).marriage;
cout<<"\n\t\t病房编号:"<<(p->data).Id<<"\n\t\t患者病历号:"<<(p->data).record<<"\n\t\t患者入院时间:"<<(p->data).inTime<<"\n\t\t患者出院时间:"<<(p->data).outTime;
cout<<"\n\t\t住院期间各种费用:"<<(p->data).wage<<"\n\t\t患者主治医师:"<<(p->data).mainDoctor;
cout<<"\n下面开始修改该客房的信息:\n";
Info tempInfo;
cout<<"请输入入住的患者姓名:";
cin>>tempInfo.name; //读入患者姓名
cout<<"请输入入住的患者年龄:";
cin>>tempInfo.age; //读入患者年龄
cout<<"请输入入住的患者性别:";
cin>>tempInfo.sex; //读入患者性别
cout<<"请输入入住的患者职业:";
cin>>tempInfo.job; //读入患者职业
cout<<"请输入入住的患者婚姻状况:";
cin>>tempInfo.marriage; //读入患者婚姻状况
cout<<"请输入入住的患者病房编号:";
cin>>tempInfo.Id; //读入病房编号
cout<<"请输入患者病历号:";
cin>>tempInfo.record; //读入患者病历号
cout<<"请输入患者入院时间:";
cin>>tempInfo.inTime; //读入患者入院时间
cout<<"请输入患者出院时间:";
cin>>tempInfo.outTime; //读入患者出院时间
cout<<"请输入患者住院期间各种费用:";
cin>>tempInfo.wage; //读入住院期间费用
cout<<"请输入患者主治医师:";
cin>>tempInfo.mainDoctor; //读入患者主治医师
tempInfo.flag=true;
p->data=tempInfo;
cout<<"修改成功!";
}
cout<<endl;
system("pause");
system("cls");
return;
}
void ModifytheCaseInfo(tList<Info>*tListInfo) //修改患者病历信息
{
char Record[Max];
cout<<"\n请输入你要修改的患者病历号:";
cin>>Record; //读取患者病历号
bool flag=false;
cNode<Info> *p;
p=tListInfo->head->next;
while(p)
{
if((p->data).record==Record && p->data.flag)
{
flag=true;
break;
}
p=p->next;
}
if(flag==true)
{//显示屏幕//让所有的数据都紧跟在制表符后面输出。
cout<<"找到了,该患者当前信息是:\n";
cout<<"\n\n患者病史:"<<(p->data).illness<<endl;
cout<<"\n\n患者诊断结果:"<<(p->data).result<<endl;
cout<<"\n\n患者用药情况:"<<(p->data).medicine<<endl;
cout<<"\n\n患者实时情况:"<<(p->data).ill<<endl;
cout<<"\n\n检查日期:"<<(p->data).time<<endl;
cout<<"\n\n当日负责人姓名:"<<(p->data).man<<endl;
cout<<"\n下面开始修改该患者的信息:\n";
Info tempInfo;
cout<<"请输入患者病史:";
cin>>tempInfo.illness;
cout<<"请输入患者诊断结果:";
cin>>tempInfo.result;
cout<<"请输入患者的用药情况(中间请不要使用空格符号):";
cin>>tempInfo.medicine;
cout<<"请输入入患者的实时病况(中间请不要使用空格符号):";
cin>>tempInfo.ill;
cout<<"请输入检查日期(例如2013年7月20日中间请不要使用空格符号):";
cin>>tempInfo.time;
cout<<"请输入当日负责人姓名:";
cin>>tempInfo.man;
tempInfo.flag=true;
p->data=tempInfo;
cout<<"修改成功!";
}
else cout<<"对不起,您查找的患者不存在";
cout<<endl;
system("pause");
system("cls");
return;
}
//查找 --按照病历号、病房+床号、患者姓名
void FindtheInfoByR(tList<Info> *tListInfo)//根据病历号查找
{
char Record[Max];
cout<<"\n请输入你要查找的患者病历号:";
cin>>Record; //读取患者病历号
bool flag=false;
cNode<Info> *p;
p=tListInfo->head->next;
while(p)
{
if(strcmp(p->data.record,Record)==0 && p->data.flag)
{
flag=true;
break;
}
p=p->next;
}
if(flag==false) cout<<"对不起,没有符合该标准的病人!\n"; //如果找不到
else //如果找到了
{
cout<<"找到了,该患者当前信息是:\n";
cout<<"\n\n患者姓名:"<<(p->data).name<<"\t患者年龄:"<<(p->data).age<<"\n\t\t患者性别:"<<(p->data).sex<<"\n\t\t患者职业:"<<(p->data).job<<"\n\t\t患者婚姻状况:"<<(p->data).marriage;
cout<<"\n\t\t病房编号:"<<(p->data).Id<<"\n\t\t患者病历号:"<<(p->data).record<<"\n\t\t患者入院时间:"<<(p->data).inTime<<"\n\t\t患者出院时间:"<<(p->data).outTime;
cout<<"\n\t\t住院期间各种费用:"<<(p->data).wage<<"\n\t\t患者主治医师:"<<(p->data).mainDoctor;
cout<<"\n\n患者病史:"<<(p->data).illness<<endl;
cout<<"\n\n患者诊断结果:"<<(p->data).result<<endl;
cout<<"\n\n患者用药情况:"<<(p->data).medicine<<endl;
cout<<"\n\n患者实时情况:"<<(p->data).ill<<endl;
cout<<"\n\n检查日期:"<<(p->data).time<<endl;
cout<<"\n\n当日负责人姓名:"<<(p->data).man<<endl;
}
cout<<endl;
system("pause");
system("cls"); //清屏
return;
}
void FindtheInfoByI(tList<Info> *tListInfo)//根据病房号查找
{
char id[Max];
cout<<"\n请输入你要查找的患者病历号:";
cin>>id; //读取患者病房号
bool flag=false;
cNode<Info> *p;
p=tListInfo->head->next;
while(p)
{
if(strcmp(p->data.Id,id)==0 && p->data.flag)
{
flag=true;
break;
}
p=p->next;
}
if(flag==false) cout<<"对不起,没有符合该标准的病人!\n"; //如果找不到
else //如果找到了
{
cout<<"找到了,该患者当前信息是:\n";
cout<<"\n\n患者姓名:"<<(p->data).name<<"\t患者年龄:"<<(p->data).age<<"\n\t\t患者性别:"<<(p->data).sex<<"\n\t\t患者职业:"<<(p->data).job<<"\n\t\t患者婚姻状况:"<<(p->data).marriage;
cout<<"\n\t\t病房编号:"<<(p->data).Id<<"\n\t\t患者病历号:"<<(p->data).record<<"\n\t\t患者入院时间:"<<(p->data).inTime<<"\n\t\t患者出院时间:"<<(p->data).outTime;
cout<<"\n\t\t住院期间各种费用:"<<(p->data).wage<<"\n\t\t患者主治医师:"<<(p->data).mainDoctor;
cout<<"\n\n患者病史:"<<(p->data).illness<<endl;
cout<<"\n\n患者诊断结果:"<<(p->data).result<<endl;
cout<<"\n\n患者用药情况:"<<(p->data).medicine<<endl;
cout<<"\n\n患者实时情况:"<<(p->data).ill<<endl;
cout<<"\n\n检查日期:"<<(p->data).time<<endl;
cout<<"\n\n当日负责人姓名:"<<(p->data).man<<endl;
}
cout<<endl;
system("pause");
system("cls"); //清屏
return;
}
void FindtheInfoByN(tList<Info> *tListInfo)//根据患者姓名查找
{
char Name[Max];
cout<<"\n请输入你要查找的患者姓名:";
cin>>Name; //读取患者姓名
bool flag=false;
cNode<Info> *p;
p=tListInfo->head->next;
while(p)
{
if(strcmp(p->data.name,Name)==0 && p->data.flag)
{
flag=true;
break;
}
p=p->next;
}
if(flag==false) cout<<"对不起,没有符合该标准的病人!\n"; //如果找不到
else //如果找到了
{
cout<<"找到了,该患者当前信息是:\n";
cout<<"\n\n患者姓名:"<<(p->data).name<<"\t患者年龄:"<<(p->data).age<<"\n\t\t患者性别:"<<(p->data).sex<<"\n\t\t患者职业:"<<(p->data).job<<"\n\t\t患者婚姻状况:"<<(p->data).marriage;
cout<<"\n\t\t病房编号:"<<(p->data).Id<<"\n\t\t患者病历号:"<<(p->data).record<<"\n\t\t患者入院时间:"<<(p->data).inTime<<"\n\t\t患者出院时间:"<<(p->data).outTime;
cout<<"\n\t\t住院期间各种费用:"<<(p->data).wage<<"\n\t\t患者主治医师:"<<(p->data).mainDoctor;
cout<<"\n\n患者病史:"<<(p->data).illness<<endl;
cout<<"\n\n患者诊断结果:"<<(p->data).result<<endl;
cout<<"\n\n患者用药情况:"<<(p->data).medicine<<endl;
cout<<"\n\n患者实时情况:"<<(p->data).ill<<endl;
cout<<"\n\n检查日期:"<<(p->data).time<<endl;
cout<<"\n\n当日负责人姓名:"<<(p->data).man<<endl;
}
cout<<endl;
system("pause");
system("cls"); //清屏
return;
}
void FindtheInfo(tList<Info> *tListInfo)//查找患者信息
{
system("cls");
while(1)
{
cout<<"\n\n\n\n";
cout<<" 1:按患者病历号查询\n\n";
cout<<" 2:按患者病房号查询\n\n";
cout<<" 3:按患者姓名查询\n\n";
cout<<" 4:退出查询\n\n";
cout<<"请你选择相应数字:";
int choose=0;
cin>>choose;
switch(choose) //根据用户选择
{
case 1:FindtheInfoByR(tListInfo); //按患者病历号查询
break;
case 2:FindtheInfoByI(tListInfo); //按患者病房号查询
break;
case 3:FindtheInfoByN(tListInfo); //按患者姓名查询
break;
case 4:
system("cls");
return; //退出查询
default:break;
}
}
return;
}
void DeletetheInfo(tList<Info> *tListInfo) //删除患者信息
{
char Record[Max];
cout<<"\n请输入你要查找的病例号:";
cin>>Record; //读取病例号
bool flag=false;
int count=0;
cNode<Info> *p;
p=tListInfo->head->next;
while(p)
{
if(strcmp(p->data.record,Record)==0 && p->data.flag)
{
count++;
flag=true;
break;
}
p=p->next;
}
if(flag==false) cout<<"对不起,你所查找的患者信息无法删除!\n";//如果不能删
else //如果能删
{
count--;
cout<<"找到了,该患者的相关信息是:\n";
cout<<"\n\n患者姓名:"<<(p->data).name<<"\t患者年龄:"<<(p->data).age<<"\n\t\t患者性别:"<<(p->data).sex<<"\n\t\t患者职业:"<<(p->data).job<<"\n\t\t患者婚姻状况:"<<(p->data).marriage;
cout<<"\n\t\t病房编号:"<<(p->data).Id<<"\n\t\t患者病历号:"<<(p->data).record<<"\n\t\t患者入院时间:"<<(p->data).inTime<<"\n\t\t患者出院时间:"<<(p->data).outTime;
cout<<"\n\t\t住院期间各种费用:"<<(p->data).wage<<"\n\t\t患者主治医师:"<<(p->data).mainDoctor;
cout<<"\n\t\t患者病史:"<<(p->data).illness<<endl;
cout<<"\n\t\t患者诊断结果:"<<(p->data).result<<endl;
cout<<"\n\t\t患者用药情况:"<<(p->data).medicine<<endl;
cout<<"\n\t\t患者实时情况:"<<(p->data).ill<<endl;
cout<<"\n\t\t检查日期:"<<(p->data).time<<endl;
cout<<"\n\t\t当日负责人姓名:"<<(p->data).man<<endl;
cout<<endl;
(p->data).flag=false;
cout<<"该病房的信息删除成功!\n";
}
cout<<endl;
system("pause");
system("cls");
return;
}
struct expenditure //定义结构体
{
double bed;
double treatment;
double medicine;
double transfusion;
double operation;
double aggregate;
};
struct stufferer
{
int date;
string name;
string sex;
int age;
double num;
string depart;
double room;
expenditure charge;
struct stufferer *next;
};
//---------------------------------------------------------------
void manage()
{
struct stufferer *stu,*stuff;
string sname;
Date();
cout<<"\n\n\n\n\n";
cout<<" ===================================================="<<endl;
cout<<" | |"<<endl;
cout<<" | 欢迎使用患者住院管理子系统! |"<<endl;
cout<<" | |"<<endl;
cout<<" ===================================================="<<endl;
cout<<" | |"<<endl;
cout<<" | |"<<endl;
cout<<" | 1.在院病人信息库 |"<<endl;
cout<<" | 2.退出 |"<<endl;
cout<<" | |"<<endl;
cout<<" ===================================================="<<endl;
cout<<"请选择: ";
for(;;)
{ cin>>file;
if(file=='1'||file=='2'||file=='0')break;
cout<<"错误! 重新选择: "<<endl;
}
if(file!='0')
{ stu=creat();
if(file=='1') stu=sort(stu);
print(stu);
for(;;)
{ if(file=='1')
cout<<" ============================================="<<endl
<<" | 查找(1) - 添加(2) - 删除(3) - 退出(0) |"<<endl
<<" ============================================="<<endl;
else
cout<<" ============================================="<<endl
<<" | 查找(1) - 删除(3) - 退出(0) |"<<endl
<<" ============================================="<<endl;
cout<<"选择操作: ";
cin>>choose;
if(choose=='3')
{
cout<<"选择删除操作!"<<endl<<"请输入姓名:";
cin>>sname;
stu=Delete(stu,sname);
print(stu);
}
else if(choose=='2'&&file=='1')
{
cout<<"选择添加操作!"<<endl<<"请输入一组病人信息:( 取消操作,请输入 0 ! )"<<endl;
stuff=new(stufferer);
stuff->date=indate;cout<<"住院日期:"<<indate<<endl;
cout<<" 姓 名 :";cin>>stuff->name;if(stuff->name=="0"){cout<<"取消添加操作!"<<endl;continue;}
cout<<" 性 别 :";cin>>stuff->sex;if(stuff->sex=="0"){cout<<"取消添加操作!"<<endl;continue;}
cout<<" 年 龄 :";cin>>stuff->age;if(stuff->age==0){cout<<"取消添加操作!"<<endl;continue;}
cout<<" 科 室 :";cin>>stuff->depart;if(stuff->age==0){cout<<"取消添加操作!"<<endl;continue;}
cout<<" 病房号 :";cin>>stuff->room;if(stuff->age==0){cout<<"取消添加操作!"<<endl;continue;}
cout<<" 床位号 :";cin>>stuff->num;if(stuff->age==0){cout<<"取消添加操作!"<<endl;continue;}
cout<<" 床位费 :";cin>>stuff->charge.bed;
cout<<" 治疗费 :";cin>>stuff->charge.treatment;
cout<<" 药材费 :";cin>>stuff->charge.medicine;
cout<<" 输液费 :";cin>>stuff->charge.transfusion;
cout<<" 手术费 :";cin>>stuff->charge.operation;
stuff->charge.aggregate=stuff->charge.bed+stuff->charge.treatment+stuff->charge.medicine+stuff->charge.transfusion+stuff->charge.operation;
cout<<"添加成功!"<<endl<<endl;
stu=insert(stu,stuff);
print(stu);
}
else if(choose=='1')
{
cout<<"选择查找操作!"<<endl<<"请输入姓名:";
cin>>sname;
stu=lookup(stu,sname);
if(file=='1')stu=sort(stu);
print(stu);
}
else if(choose=='0')
break;
else
cout<<"错误! 重新选择:"<<endl;
}
fileprint(stu);
conserve(stu);
cout<<"数据已输出并保存!"<<endl;
}
cout<<"感谢使用!"<<endl;
}
//---------------------------------------------------------------
struct stufferer *creat() //创建链表函数
{
struct stufferer *head,*p1,*p2;
head=NULL;
ifstream indata;
if(file=='1')
{ indata.open("1.txt");
cout<<"已调入在院病人信息库 !"<<endl;
}
cout<<setw(72)<<todaydate<<endl;
p1=new(stufferer);
p2=p1;
indata>>p1->date>>p1->name>>p1->sex>>p1->age>>p1->depart>>p1->room>>p1->num>>p1->charge.bed>>p1->charge.treatment
>>p1->charge.medicine>>p1->charge.transfusion>>p1->charge.operation;
p1->charge.aggregate=p1->charge.bed+p1->charge.treatment+p1->charge.medicine+p1->charge.transfusion+p1->charge.operation;
while(p1->date!=0)
{
n++;
if(n==1) head=p1;
else p2->next=p1;
p2=p1;
p1=new(stufferer);
indata>>p1->date>>p1->name>>p1->sex>>p1->age>>p1->depart>>p1->room>>p1->num>>p1->charge.bed>>p1->charge.treatment
>>p1->charge.medicine>>p1->charge.transfusion>>p1->charge.operation;
p1->charge.aggregate=p1->charge.bed+p1->charge.treatment+p1->charge.medicine+p1->charge.transfusion+p1->charge.operation;
}
delete(p1);
p2->next=NULL;
indata.close();
return(head);
}
//---------------------------------------------------------------
void print(struct stufferer *out) //输出链表函数
{
struct stufferer *p=out;
if(p==NULL) return;
if(file=='1')cout<<NOB<<endl;
else cout<<NOC<<endl;
do
{ cout<<setw(8)<<p->date<<setw(6)<<p->name<<setw(4)<<p->sex<<setw(5)<<p->age<<setw(6)<<p->depart<<setw(4)<<p->room<<setw(3)<<p->num<<setw(7)<<p->charge.bed
<<setw(7)<<p->charge.treatment<<setw(7)<<p->charge.medicine<<setw(7)<<p->charge.transfusion
<<setw(7)<<p->charge.operation<<setw(8)<<p->charge.aggregate<<endl;
p=p->next;
}while(p!=NULL);
cout<<endl<<endl;
}
//---------------------------------------------------------------
void fileprint(struct stufferer *out) //文件输出函数
{
struct stufferer *p=out;
ofstream outdata;
if(file=='1'){outdata.open("在院病人信息输出文件.txt");outdata<<NOB<<endl;}
if(p==NULL) return;
do
{ outdata<<setw(8)<<p->date<<setw(6)<<p->name<<setw(4)<<p->sex<<setw(5)<<p->age<<setw(6)<<p->depart<<setw(4)<<p->room<<setw(3)<<p->num<<setw(7)<<p->charge.bed
<<setw(7)<<p->charge.treatment<<setw(7)<<p->charge.medicine<<setw(7)<<p->charge.transfusion
<<setw(7)<<p->charge.operation<<setw(8)<<p->charge.aggregate<<endl;
p=p->next;
}while(p!=NULL);
outdata<<endl<<setw(67)<<todaydate<<endl;
outdata.close();
}
//---------------------------------------------------------------
struct stufferer *Delete(struct stufferer *head,string sname) //删除结点函数
{
char y_or_n;
struct stufferer *p1=head,*p2;
while(sname!=p1->name&&p1->next!=NULL)
{
p2=p1;
p1=p1->next;
}
if(sname==p1->name)
{ if(file=='1')cout<<NOB<<endl;
else cout<<NOC<<endl;
cout<<setw(8)<<p1->date<<setw(6)<<p1->name<<setw(4)<<p1->sex<<setw(5)<<p1->age<<setw(6)<<p1->depart<<setw(4)<<p1->room<<setw(3)<<p1->num<<setw(7)<<p1->charge.bed
<<setw(7)<<p1->charge.treatment<<setw(7)<<p1->charge.medicine<<setw(7)<<p1->charge.transfusion
<<setw(7)<<p1->charge.operation<<setw(8)<<p1->charge.aggregate<<endl<<endl;
for(;;)
{ cout<<"确认删除?(Y/N)";
cin>>y_or_n;
if(y_or_n=='Y'||y_or_n=='y')
{ cout<<"删除操作成功!"<<endl;
break;
}
else if(y_or_n=='N'||y_or_n=='n')
{ cout<<"取消删除操作!"<<endl;
return(head);
}
}
if(p1==head)
head=p1->next;
else
p2->next=p1->next;
n--;
}
else
cout<<sname<<"不存在!"<<endl;
return(head);
}
//---------------------------------------------------------------
struct stufferer *insert(struct stufferer *head,struct stufferer *stuff) //插入链表函数
{
struct stufferer *p0,*p1,*p2;
p1=head;
p0=stuff;
if(head==NULL)
{head=p0;p0->next=NULL;}
else
while((p0->date>p1->date)&&(p1->next!=NULL))
{ p2=p1;
p1=p1->next;
}
if(p0->date<=p1->date)
{ if(head==p1) head=p0;
else p2->next=p0;
p0->next=p1;
}
else
{ p1->next=p0;
p0->next=NULL;
}
n++;
return(head);
}
//---------------------------------------------------------------
struct stufferer *sort(struct stufferer *head) //结点排序函数
{
struct stufferer *p[40],*p1,*p2;
struct stufferer *temp;
int i=0,k=0;
p1=head;p2=p1;
while(p1!=NULL)
{ p[i]=p1;
p1=p1->next;
i++;
}
for(i=0;i<n;i++)
for(k=0;k<n-i-1;k++)
if(p[k]->date>p[k+1]->date)
{ temp=p[k];
p[k]=p[k+1];
p[k+1]=temp;
}
head=p[0];
for(i=0;i<n;i++)
p[i]->next=p[i+1];
p[n-1]->next=NULL;
return(head);
}
//---------------------------------------------------------------
struct stufferer *lookup(struct stufferer *head,string sname) //查找处理结点函数
{
struct stufferer *p1,*p2;
p1=head;
while(sname!=p1->name&&p1->next!=NULL)
{ p2=p1;
p1=p1->next;
}
if(sname==p1->name)
for(;;)
{ if(file=='1')cout<<NOB<<endl;
else cout<<NOC<<endl;
cout<<setw(8)<<p1->date<<setw(6)<<p1->name<<setw(4)<<p1->sex<<setw(5)<<p1->age<<setw(6)<<p1->depart<<setw(4)<<p1->room<<setw(3)<<p1->num<<setw(7)<<p1->charge.bed
<<setw(7)<<p1->charge.treatment<<setw(7)<<p1->charge.medicine<<setw(7)<<p1->charge.transfusion
<<setw(7)<<p1->charge.operation<<setw(8)<<p1->charge.aggregate<<endl<<endl;
cout<<"选择操作(想修改个人信息请选择1,想修改费用信息请选择2,退出修改请选择0):";
cin>>choose;
if(choose=='1'&&file=='1')
{ int temp;string stemp;
cout<<"选择个人信息修改操作:(取消,请输入"<<" 0 "<<"!)"<<endl;
cout<<" 姓 名 :";cin>>stemp;if(stemp!="0")p1->name=stemp;
cout<<" 性 别 :";cin>>stemp;if(stemp!="0")p1->sex=stemp;
cout<<" 年 龄 :";cin>>temp;if(temp!=0)p1->age=temp;
cout<<" 科 室 :";cin>>stemp;if(stemp!="0")p1->depart=stemp;
cout<<" 病房号 :";cin>>temp;if(temp!=0)p1->room=temp;
cout<<" 床位号 :";cin>>temp; if(temp!=0)p1->num=temp;
}
else if(choose=='2'&&file=='1')
{ float increment;
cout<<"选择费用信息修改操作 :"<<endl;
cout<<" 床位费 :"<<p1->charge.bed<<"+";cin>>increment;p1->charge.bed=p1->charge.bed+increment;
cout<<" 治疗费 :"<<p1->charge.treatment<<"+";cin>>increment;p1->charge.treatment=p1->charge.treatment+increment;
cout<<" 药材费 :"<<p1->charge.medicine<<"+";cin>>increment;p1->charge.medicine=p1->charge.medicine+increment;
cout<<" 输液费 :"<<p1->charge.transfusion<<"+";cin>>increment;p1->charge.transfusion=p1->charge.transfusion+increment;
cout<<" 手术费 :"<<p1->charge.operation<<"+";cin>>increment;p1->charge.operation=p1->charge.operation+increment;
p1->charge.aggregate=p1->charge.bed+p1->charge.treatment+p1->charge.medicine+p1->charge.transfusion+p1->charge.operation;
}
else if(choose=='0')
break;
else
cout<<"错误! 重新选择:"<<endl;
}
else
cout<<"所查找病人不存在!"<<endl;
return(head);
}
//---------------------------------------------------------------
void conserve(struct stufferer *out) //保存数据函数
{
struct stufferer *p=out;
ofstream outdata;
if(file=='1')outdata.open("在院病人信息存档文件.txt");
if(p==NULL) return;
do
{
outdata<<p->date<<" "<<p->name<<" "<<p->sex<<" "<<p->age<<" "<<p->depart<<" "<<p->room<<" "<<p->num<<" "<<p->charge.bed
<<" "<<p->charge.treatment<<" "<<p->charge.medicine<<" "<<p->charge.transfusion
<<" "<<p->charge.operation<<endl;
p=p->next;
}while(p!=NULL);
for(int i=0,k=0;i<8;i++)
outdata<<k<<" ";
outdata.close();
}
//---------------------------------------------------------------
void Date() //调用日历日期函数
{
time_t t;
string year,month,day;
int i,m;
time(&t);
switch(ctime(&t)[4])
{ case 'J':switch(ctime(&t)[6])
{ case 'n':switch(ctime(&t)[5])
{ case 'e':month="01";m=1;break;
case 'u':month="06";m=6;break;
}break;
case 'l':month="07";m=7;break;
}break;
case 'F':month="02";m=2;break;
case 'M':switch(ctime(&t)[6])
{ case 'r':month="03";m=3;break;
case 'y':month="05";m=5;break;
}break;
case 'A':switch(ctime(&t)[6])
{ case 'r':month="04";m=4;break;
case 'g':month="08";m=8;break;
}break;
case 'S':month="09";m=9;break;
case 'O':month="10";m=10;break;
case 'N':month="11";m=11;break;
case 'D':month="12";m=12;break;
}
for(i=8;i<=9;i++)
{day+=ctime(&t)[i];indate+=(int(ctime(&t)[i])-48)*pow(10,9-i);}
for(i=20;i<=23;i++)
{year+=ctime(&t)[i];indate+=(int(ctime(&t)[i])-48)*pow(10,27-i);}
todaydate=year+"-"+month+"-"+day;
indate+=m*100;
outdate=year+month+day;
}
int main()
{
ReadData(&tListInfo);
firstWindow();
tListInfo.Create(); //创建链表
return 0;
}
在这里插入代码片
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。