医院挂号系统.docx

上传人:b****4 文档编号:4834300 上传时间:2023-05-07 格式:DOCX 页数:61 大小:334.35KB
下载 相关 举报
医院挂号系统.docx_第1页
第1页 / 共61页
医院挂号系统.docx_第2页
第2页 / 共61页
医院挂号系统.docx_第3页
第3页 / 共61页
医院挂号系统.docx_第4页
第4页 / 共61页
医院挂号系统.docx_第5页
第5页 / 共61页
医院挂号系统.docx_第6页
第6页 / 共61页
医院挂号系统.docx_第7页
第7页 / 共61页
医院挂号系统.docx_第8页
第8页 / 共61页
医院挂号系统.docx_第9页
第9页 / 共61页
医院挂号系统.docx_第10页
第10页 / 共61页
医院挂号系统.docx_第11页
第11页 / 共61页
医院挂号系统.docx_第12页
第12页 / 共61页
医院挂号系统.docx_第13页
第13页 / 共61页
医院挂号系统.docx_第14页
第14页 / 共61页
医院挂号系统.docx_第15页
第15页 / 共61页
医院挂号系统.docx_第16页
第16页 / 共61页
医院挂号系统.docx_第17页
第17页 / 共61页
医院挂号系统.docx_第18页
第18页 / 共61页
医院挂号系统.docx_第19页
第19页 / 共61页
医院挂号系统.docx_第20页
第20页 / 共61页
亲,该文档总共61页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

医院挂号系统.docx

《医院挂号系统.docx》由会员分享,可在线阅读,更多相关《医院挂号系统.docx(61页珍藏版)》请在冰点文库上搜索。

医院挂号系统.docx

医院挂号系统

醫院掛號系統

一:

系統功能、輸入資料、與輸出資料:

醫院掛號系統是一個可以讓病人線上掛號並查詢掛號紀錄的系統,為了簡化系統的複雜度,我們做了以下的假設:

1.診別資料是給定的,不可新增;診別資料只包含兩樣資訊:

診別編號與診別名字。

2.醫生資料是給定的,不可新增;醫生資料只包含兩樣資訊:

醫生編號與醫生名字。

3.藥物資料是給定的,不可新增;藥物資料只包含兩樣資訊:

藥物編號與藥物名字。

4.可新增病人資料;病人資料只包含兩樣資訊:

病人編號與病人名字。

5.可新增掛號資料;掛號資料包含幾樣資訊:

掛號編號、病人編號、病人名字、診別編號、診別名字、醫生編號、醫生名字、藥物編號、藥物名字與掛號日期;掛號時,一旦某病人選擇了某診別與某醫生,則系統將根據該診別與該醫生自動配置對應的藥物。

有了以上的假設,我們應該要有以下這些檔案:

診別檔:

用來提供診別資訊,檔案的每一行應包含兩個欄位:

診別編號與診別名字。

subjects.log:

1骨科

2眼科

3SARS專科

醫生檔:

用來提供醫生資訊,檔案的每一行應包含兩個欄位:

醫生編號與醫生名字。

doctors.log:

1林莊傑

2許家榮

3蕭博文

4林芳伶

5陳明江

6盧瑞鵬

藥物檔:

用來提供藥物資訊,檔案的每一行應包含兩個欄位:

藥物編號與藥物名字。

medicines.log:

1鐵牛運功散

2十八銅人行氣散

3福祿壽健兒寶

4愛之味麥仔茶

5統一埔里礦泉水

6黑松沙士

7東北三寶-人參,貂皮,烏拉草

8天山雪蓮

9含笑半步癲

比對檔:

用來提供比對資訊,所謂的比對資訊就是哪科診別配上哪位醫生則開哪種藥物,檔案的每一行應包含四個欄位:

比對編號、診別編號、醫生編號與藥物編號。

matches.log:

1111

2122

3133

4144

5225

6236

7247

8258

9339

10341

11352

12363

病人檔:

用來提供病人資訊,檔案的每一行應包含兩個欄位:

病人編號與病人名字。

patients.log:

12吳柏宏

15黃俊育

19石凌霖

掛號檔:

用來提供掛號資訊,檔案的每一行應包含幾個欄位:

掛號編號、病人編號、病人名字、診別編號、診別名字、醫生編號、醫生名字、藥物編號、藥物名字與掛號日期。

reports.log:

1

12

吳柏宏

1

骨科

2

許家榮

2

十八銅人行氣散

2003/01/01

2

15

黃俊育

2

眼科

4

林芳伶

7

東北三寶-人參,貂皮,烏拉草

2003/02/02

3

19

石凌霖

3

SARS專科

6

盧瑞鵬

3

福祿壽健兒寶

2003/03/03

二:

應用層面說明:

醫院掛號系統不僅可用在醫院掛號上,也可用在其它具比對性質的系統上。

三:

資料結構說明:

為了處理這些複雜的資料,我們定義了六種資料結構來處理資料與資料之間複雜的關係:

1.儲存診別資料的資料結構(SUBJECT):

SUBJECT

欄位意義

欄位名稱

診別編號

intid

診別名稱

charname[80]

2.儲存醫生資料的資料結構(DOCTOR):

DOCTOR

欄位意義

欄位名稱

醫生編號

intid

醫生名稱

charname[80]

3.儲存藥物資料的資料結構(MEDICINE):

MEDICINE

欄位意義

欄位名稱

藥物編號

intid

藥物名稱

charname[80]

4.儲存比對資料的資料結構(MATCH):

MATCH

欄位意義

欄位名稱

比對編號

intid

診別編號

intsubject_id

醫生編號

intdoctor_id

藥物編號

intmedicine_id

5.儲存病人資料的資料結構(PATIENT):

PATIENT

欄位意義

欄位名稱

病人編號

intid

病人名稱

charname[80]

6.儲存掛號資料的資料結構(REPORT):

REPORT

欄位意義

欄位名稱

掛號編號

intid

病人編號

intpatient_id

病人名稱

chatpatient_name[80]

診別編號

intsubject_id

診別名稱

charsubject_name[80]

醫生編號

intdoctor_id

醫生名稱

chardoctor_name[80]

藥物編號

intmedicine_id

藥物名稱

charmedicine_name[80]

掛號日期

chardate[80]

四:

主程式與副程式剖析:

1.主程式main():

功能:

允許使用者輸入選項(1.新增病人資料,2.掛號,3.查詢某病人的就診紀錄,4.查詢某醫生的看診紀錄,或5.結束程式),並執行該選項的功能。

流程圖:

其中掛號功能比較複雜,因為我們必須判斷1.某病人編號是否存在2.某病人所掛號的某醫生是否有看某診別3.某醫生看某診別時所開的藥物的編號。

流程圖:

程式碼:

main()

{

FILE*fp_subjects;//診別檔

FILE*fp_doctors;//醫生檔

FILE*fp_medicines;//藥物檔

FILE*fp_matches;//比對檔

FILE*fp_patients;//病人檔

FILE*fp_reports;//掛號檔

structSUBJECTsubjects[SUBJECTS_NUM+1],sub;//診別資料

structDOCTORdoctors[DOCTORS_NUM+1],doc;//醫生資料

structMEDICINEmedicines[MEDICINES_NUM+1],med;//藥物資料

structMATCHmatches[MATCHES_NUM+1],mat;//比對資料

structPATIENTpatients[PATIENTS_NUM+1],pat;//病人資料

structREPORTreports[REPORTS_NUM+1],rep;//掛號資料

intpos_sub;//診別資料位置

intpos_doc;//醫生資料位置

intpos_med;//藥物資料位置

intpos_mat;//比對資料位置

intpos_pat;//病人資料位置

intpos_rep;//掛號資料位置

intchoice,result;//選項與選項執行結果

if(!

(fp_subjects=fopen(SUBJECTS_FILE,"r")))//開啟診別檔

{

printf("無法開啟診別檔,程式終止!

");

printf("\n");

exit

(1);

}

if(!

(fp_doctors=fopen(DOCTORS_FILE,"r")))//開啟醫生檔

{

printf("無法開啟醫生檔,程式終止!

");

printf("\n");

exit

(1);

}

if(!

(fp_medicines=fopen(MEDICINES_FILE,"r")))//開啟藥物檔

{

printf("無法開啟藥物檔,程式終止!

");

printf("\n");

exit

(1);

}

if(!

(fp_matches=fopen(MATCHES_FILE,"r")))//開啟比對檔

{

printf("無法開啟比對檔,程式終止!

");

printf("\n");

exit

(1);

}

if(!

(fp_patients=fopen(PATIENTS_FILE,"r")))//開啟病人檔

{

fp_patients=fopen(PATIENTS_FILE,"w");

}

if(!

(fp_reports=fopen(REPORTS_FILE,"r")))//開啟掛號檔

{

fp_reports=fopen(REPORTS_FILE,"w");

}

initSubjects(subjects);//初始化診別資料

initDoctors(doctors);//初始化醫生資料

initMedicines(medicines);//初始化藥物資料

initMatches(matches);//初始化比對資料

initPatients(patients);//初始化病人資料

initReports(reports);//初始化掛號資料

loadSubjects(subjects,fp_subjects);//載入診別資料

loadDoctors(doctors,fp_doctors);//載入醫生資料

loadMedicines(medicines,fp_medicines);//載入藥物資料

loadMatches(matches,fp_matches);//載入比對資料

loadPatients(patients,fp_patients);//載入病人資料

loadReports(reports,fp_reports);//載入掛號資料

fclose(fp_subjects);

fclose(fp_doctors);

fclose(fp_medicines);

fclose(fp_matches);

fclose(fp_patients);

fclose(fp_reports);

while

(1)

{

printf("*****************主選單*****************");

printf("\n");

printf("****************************************");

printf("\n");

printf("1.新增病人資料");

printf("\n");

printf("2.掛號");

printf("\n");

printf("3.查詢某病人的就診紀錄");

printf("\n");

printf("4.查詢某醫生的看診紀錄");

printf("\n");

printf("5.結束");

printf("\n");

printf("****************************************");

printf("\n");

printf("請選擇>");

scanf("%d",&choice);//輸入選項

switch(choice)

{

case1:

//新增病人資料

printf("請輸入病人編號>");

scanf("%d",&pat.id);

printf("請輸入病人名字>");

scanf("%s",&pat.name);

if(searchPatient(patients,pat.id)>0)

{

printf("病人資料重複!

");

printf("\n");

}

else

{

if(addPatient(patients,pat)>0)

{

printf("新增病人資料成功\!

");

printf("\n");

}

else

{

printf("病人資料已滿!

");

printf("\n");

}

}

break;

case2:

//掛號

printf("請輸入病人編號>");

scanf("%d",&rep.patient_id);//輸入病人編號

pos_pat=searchPatient(patients,rep.patient_id);

if(pos_pat>0)//如果有此病人編號

{

printf("請輸入掛號日期(ex.2002/04/20)>");

scanf("%s",&rep.date);//輸入掛號日期

showSubjects(subjects);

printf("請輸入診別編號>");

scanf("%d",&rep.subject_id);//輸入診別編號

showDoctors(doctors);

printf("請輸入醫生編號>");

scanf("%d",&rep.doctor_id);//輸入醫生編號

pos_mat=searchMatch(matches,rep.subject_id,rep.doctor_id);

if(pos_mat>0)//如果此醫生有看此診別

{

//找出此診別在診別資料中的位置

pos_sub=searchSubject(subjects,matches[pos_mat].subject_id);

//找出此醫生在醫生資料中的位置

pos_doc=searchDoctor(doctors,matches[pos_mat].doctor_id);

//找出此醫生看此診別時所開的藥物在藥物資料中的位置

pos_med=searchMedicine(medicines,matches[pos_mat].medicine_id);

//找出此病人名字

strcpy(rep.patient_name,patients[pos_pat].name);

//找出此診別名字

strcpy(rep.subject_name,subjects[pos_sub].name);

//找出此醫生名字

strcpy(rep.doctor_name,doctors[pos_doc].name);

//找出此藥物編號

rep.medicine_id=medicines[pos_med].id;

//找出此藥物名字

strcpy(rep.medicine_name,medicines[pos_med].name);

//掛號

if(addReport(reports,rep)>0)

{

printf("新增掛號資料成功\!

");

printf("\n");

}

else

{

printf("掛號資料已滿!

");

printf("\n");

}

}

else//如果此醫生不看此診別

{

printf("此醫生不看此診別!

");

printf("\n");

}

}

else//如果無此病人編號

{

printf("無此病人編號!

");

printf("\n");

}

break;

case3:

//查詢某病人的就診紀錄

printf("請輸入病人編號>");

scanf("%d",&pat.id);

if(searchPatient(patients,pat.id)>0)

{

queryByPatient(reports,pat.id);

}

else

{

printf("無此病人編號!

");

printf("\n");

}

break;

case4:

//查詢某醫生的看診紀錄

showDoctors(doctors);

printf("請輸入醫生編號>");

scanf("%d",&doc.id);

if(searchDoctor(doctors,doc.id)>0)

{

queryByDoctor(reports,doc.id);

}

else

{

printf("無此醫生編號!

");

printf("\n");

}

break;

case5:

//結束程式

fp_patients=fopen(PATIENTS_FILE,"w");

fp_reports=fopen(REPORTS_FILE,"w");

savePatients(patients,fp_patients);

saveReports(reports,fp_reports);

fclose(fp_patients);

fclose(fp_reports);

exit

(1);

break;

default:

//無效的選項

printf("無效的選項!

");

printf("\n");

break;

}

}

}

2.副程式initSubjects(),initDoctors(),initMedicines(),initMatches(),initPatients(),initReports():

功能:

初始化資料,在此僅舉initSubjects()與initDoctors()兩個例子,其它例子與這兩個例子相似。

流程圖:

程式碼:

//初始化診別資料

voidinitSubjects(structSUBJECTsubjects[])

{

inti;

for(i=1;i<=SUBJECTS_NUM;i++)

{

subjects[i].id=-1;

}

}

//初始化醫生資料

voidinitDoctors(structDOCTORdoctors[])

{

inti;

for(i=1;i<=DOCTORS_NUM;i++)

{

doctors[i].id=-1;

}

}

3.副程式loadSubjects(),loadDoctors(),loadMedicines(),loadMatches(),loadPatients(),loadReports():

功能:

載入資料,在此僅舉loadSubjects()與loadDoctors()兩個例子,其它例子與這兩個例子相似。

流程圖:

程式碼:

//載入診別資料,回傳載入資料筆數

intloadSubjects(structSUBJECTsubjects[],FILE*fp)

{

intcount;

count=0;

while(!

feof(fp))

{

count=count+1;

fscanf(fp,"%d\t%s\n",&subjects[count].id,&subjects[count].name);

}

returncount;

}

//載入醫生資料,回傳載入資料筆數

intloadDoctors(structDOCTORdoctors[],FILE*fp)

{

intcount;

count=0;

while(!

feof(fp))

{

count=count+1;

fscanf(fp,"%d\t%s\n",&doctors[count].id,&doctors[count].name);

}

returncount;

}

4.副程式searchSubject(),searchDoctor(),searchMedicine(),searchPatient():

功能:

搜尋診別資料,搜尋醫生資料,搜尋藥物資料,與搜尋病人資料;搜尋的條件為搜尋符合的編號的資料;如搜尋診別資料為搜尋符合的診別編號的資料。

流程圖:

程式碼:

//搜尋診別資料,回傳診別資料位置

intsearchSubject(structSUBJECTsubjects[],intid)

{

intindex;

for(index=1;index<=SUBJECTS_NUM&&subjects[index].id!

=-1;index++)

{

if(subjects[index].id==id)

{

returnindex;

}

}

return-1;

}

//搜尋醫生資料,回傳醫生資料位置

intsearchDoctor(structDOCTORdoctors[],intid)

{

intindex;

for(index=1;index<=DOCTORS_NUM&&doctors[index].id!

=-1;index++)

{

if(doctors[index].id==id)

{

returnindex;

}

}

return-1;

}

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 人文社科 > 军事政治

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2