医院管理系统.docx
- 文档编号:18361427
- 上传时间:2023-08-16
- 格式:DOCX
- 页数:56
- 大小:25.42KB
医院管理系统.docx
《医院管理系统.docx》由会员分享,可在线阅读,更多相关《医院管理系统.docx(56页珍藏版)》请在冰点文库上搜索。
医院管理系统
#include"iostream"
usingnamespacestd;
#include"fstream"
#include"string"
classdoctor;
classtime;
template
voidcreateb(T*p)
{p->create2();}
classPerson//定义人类
{public:
Person(intbh,stringxm,stringks)
{bh=bh;name=xm;subject=ks;}
Person(){}
intbh;
protected:
stringxingbie;
stringname;
stringsubject;
};
classtime//定义时间类
{public:
intyear;
intmonth;
intday;
intweek;
voidcreatetime()//创建时间函数
{cout<<"请输入现在时间:
__年__月__日星期__"< cin>>year>>month>>day>>week; } }; /*-----------------------------------定义药品类-----------------------------------------*/ classmedicine { protected: timein_time; timeout_time; stringname; stringzhonglei; doubleprice; doubleamount; public: intbh; staticmedicine*h,*pr; staticintn; medicine*next; voidcreate2()//初始化函数 {h->next=NULL; pr->next=NULL;} voidcreate(medicine*p)//创建结点 {if(n==0) pr=h; cout<<"输入编号: "; cin>>bh; cout<<"输入名称: "; cin>>name; cout<<"输入种类: "; cin>>zhonglei; if(zhonglei=="中药"||zhonglei=="zhongyao")//判断种类是否为中药/西药 { cout<<"输入价格/斤: "; cin>>price; cout<<"输入重量(斤): "; cin>>amount; cout<<"输入入库时间: "; cin>>in_time.year>>in_time.month>>in_time.day; ofstreamstorefile1("medicine.txt",ios_base: : app);//写入文件操作 storefile1< < storefile1.close(); } if(zhonglei=="西药"||zhonglei=="xiyao") { cout<<"输入价格: "; cin>>price; cout<<"输入数目: "; cin>>amount; cout<<"输入入库时间: "; cin>>in_time.year>>in_time.month>>in_time.day; cout<<"过期时间: "; cin>>out_time.year>>out_time.month>>out_time.day;cout< ofstreamstorefile1("medicine.txt",ios_base: : app);//写入文件操作 storefile1< < < storefile1.close(); } p->next=pr->next; pr->next=p; pr=p; pr->next=NULL; n++; cout<<"*****************添加成功*****************"< } friendvoiddel(intaDate);//根据编号删除结点 friendvoidbaocun1();//保存修改数据函数 voidshow()//打印数据 { cout<<"编号: "< cout<<"名称: "< cout<<"输入种类: "< if(zhonglei=="中药"||zhonglei=="zhongyao") { cout<<"价格/斤: "< cout<<"重量(斤): "< cout<<"入库时间: "< } else { cout<<"价格: "< cout<<"数目: "< cout<<"入库时间: "< cout<<"过期时间: "< } cout<<"*********查找结束*****************"< } voidshowall()//打印所有数据 { medicine*q=newmedicine; q=h->next; while(q) { q->show(); q=q->next; } } /*--------------------------定义友元函数-----------------*/ friendvoidsearch(intaDate);//搜索函数 friendvoidkouchu(stringname2,doubleshumu);//根据药品名称扣除药品函数 frienddoublejijia(stringname2,doubleshumu);//根据药品名称计算价格函数 friendvoidgqcx(intbhy,time&nowtime);//过期查询函数 friendvoidcreate2(intm);//从文件导入数据函数 template friendvoidcreateb(T*p); /*--------------------------定义友元函数------------------*/ stringjude(time&nowtime)//判断药品是否过期 { if(nowtime.year>out_time.year) return"过期"; elseif(out_time.year==nowtime.year&&nowtime.month>out_time.month) return"过期"; elseif(out_time.year==nowtime.year&&out_time.month==nowtime.month&&nowtime.day>out_time.day) return"过期"; elsereturn"未过期"; cout<<"**************判断完成****************"< } }; /*-----------------------------------定义药品类-----------------------------------------*/ intpanduan1()//判断药品文件内行数 { charch; intm=0; ifstreamin("medicine.txt",ios: : binary); while((ch=in.get())! =EOF) { if(ch=='\n') m++; } in.close(); returnm; } intpanduan2()//判断医生文件内函数 { charch; intm=0; ifstreamin("doctor.txt",ios: : binary); while((ch=in.get())! =EOF) { if(ch=='\n') m++; } in.close(); returnm; } intpanduan3()//判断病人文件内函数 { charch; intm=0; ifstreamin("bingren.txt",ios: : binary); while((ch=in.get())! =EOF) { if(ch=='\n') m++; } in.close(); returnm; } voidcreate2(intm)//从文件导入数据函数 { stringa; ifstreamin("medicine.txt",ios: : binary); for(inti=0;i { medicine*p=newmedicine; if(p->n==0) { p->pr=p->h; } /*----------从文件中读取数据存入结点-------*/ in>>p->bh; getline(in,a,''); getline(in,p->name,''); getline(in,p->zhonglei,''); in>>p->price; getline(in,a,''); in>>p->amount; getline(in,a,''); if(p->zhonglei=="西药"||p->zhonglei=="xiyao") {in>>p->in_time.year;getline(in,a,''); in>>p->in_time.month;getline(in,a,''); in>>p->in_time.day;getline(in,a,''); in>>p->out_time.year;getline(in,a,''); in>>p->out_time.month;getline(in,a,''); in>>p->out_time.day; } if(p->zhonglei=="中药"||p->zhonglei=="zhongyao") { in>>p->in_time.year;getline(in,a,''); in>>p->in_time.month;getline(in,a,''); in>>p->in_time.day; } /*----------从文件中读取数据存入结点-------*/ p->next=p->pr->next; p->pr->next=p; p->pr=p; p->pr->next=NULL; p->n++; } } voidgqcx(intbhy,time&nowtime)//过期查询函数 { medicine*p=newmedicine; medicine*q=newmedicine; p=p->h; doublea=1.1; while(p->bh! =bhy&&p->next! =NULL)//查找结点a { q=p; p=p->next; } if(p->bh==bhy)//若有结点a { cout< if(p->jude(nowtime)=="过期") del(bhy); } elsethrowa; cout<<"*****************查询结束**********************"< } doublejijia(stringname2,doubleshumu)//根据药品名称计算总价 { doublejiage; inta=1; medicine*p=newmedicine; medicine*q=newmedicine; p=p->h; while(p->name! =name2&&p->next! =NULL)//查找结点a { q=p; p=p->next; } if(p->name==name2)//若有结点a { jiage=shumu*p->price; } elsethrowa; returnjiage; cout<<"*****************计价成功*******************"< } voidkouchu(stringname2,doubleshumu)//根据药品名称扣除药品 { medicine*p=newmedicine; medicine*q=newmedicine; p=p->h; inta=1; while(p->name! =name2&&p->next! =NULL)//查找结点a { q=p; p=p->next; } if(p->name==name2)//若有结点a { p->amount=p->amount-shumu; } elsethrowa; } voidsearch(intaDate)//搜索药品信息 { medicine*p=newmedicine; medicine*q=newmedicine; p=p->h; doublea=1.1; while(p->bh! =aDate&&p->next! =NULL)//查找结点a { q=p; p=p->next; } if(p->bh==aDate)//若有结点a { p->show(); } elsethrowa; cout<<"*******************查找结束*****************"< } voiddel(intaDate)//根据编号删除结点 { medicine*p=newmedicine; medicine*q=newmedicine; p=p->h; doublea=1.1; if(p==NULL)//若是空表 return; if(p->bh==aDate)//若a是第一个结点 { p->h=p->next; deletep; p->n--; cout<<"***************删除成功****************"< } else { while(p->bh! =aDate&&p->next! =NULL)//查找结点a { q=p; p=p->next; } if(p->bh==aDate)//若有结点a { q->next=p->next; deletep; p->n--; cout<<"**************删除成功************"< } elsethrowa; } } intmedicine: : n=0; medicine*medicine: : h=newmedicine; medicine*medicine: : pr=newmedicine; classbingren: virtualpublicPerson { protected: intbh; stringsgks; stringsgys; stringyb; stringbingqing; doublefy; string*yp; stringzhuangtai; double*sl; inta; public: staticbingren*h,*pr; staticintn; bingren*next; voidcreate2() { h->next=NULL; pr->next=NULL; } voidcreate(bingren*p)//创建结点 { if(n==0) pr=h; bh=n; a=0; zhuangtai="未收费"; bingqing="未看病"; sgys="未挂号"; cout<<"编号: "< cout<<"输入姓名: "; cin>>name; cout<<"输入性别: "; cin>>xingbie; cout<<"输入所挂科室: "; cin>>sgks; cout<<"是否医保对象: "; cin>>yb; if(yb=="是"||yb=="shi") fy=2.5; else fy=5; p->next=pr->next; pr->next=p; pr=p; pr->next=NULL; n++; ofstreamstorefile1("bingren.txt",ios_base: : app); storefile1< for(inti=0;i storefile1< storefile1< cout<<"****************添加成功********************"< } friendvoiddelbr(intaDate);//根据编号删除结点 friendvoidsearchbr(intaDate);//根据编号查找 friendvoidkaiyao(intaDate);//根据编号开药 friendvoidkanbing(intysbh);//判断病情 friendvoidshoufei(intaDate);//收费 friendvoidcreate4(intm);//从文件中导入数据 friendvoidbaocun2();//将数据保存入文件 voidxuanzeys(time&nowtime); voidshow()//打印数据 {cout<<"编号: "< cout<<"姓名: "< cout<<"性别: "< cout<<"所挂科室: "< cout<<"所挂医生: "< cout<<"是否医保: "< cout<<"病情:
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 医院 管理 系统