首页 医院挂号系统设计

医院挂号系统设计

举报
开通vip

医院挂号系统设计医院挂号系统设计 医院挂号系统 一: 系统功能、输入数据、与输出数据: 医院挂号系统是一个可以让病人在线挂号并查询挂号纪录的系统,为了简化系统的复杂度,我们做了以下的假设: 1. 诊别数据是给定的,不可新增;诊别数据只包含两样信息: 诊别编号与诊别 名字。 2. 医生资料是给定的,不可新增;医生数据只包含两样信息: 医生编号与医生 名字。 3. 药物资料是给定的,不可新增;药物数据只包含两样信息: 药物编号与药物 名字。 4. 可新增病人资料;病人数据只包含两样信息: 病人编号与病人名字。 5. 可新...

医院挂号系统设计
医院挂号系统设计 医院挂号系统 一: 系统功能、输入数据、与输出数据: 医院挂号系统是一个可以让病人在线挂号并查询挂号纪录的系统,为了简化系统的复杂度,我们做了以下的假设: 1. 诊别数据是给定的,不可新增;诊别数据只包含两样信息: 诊别编号与诊别 名字。 2. 医生资料是给定的,不可新增;医生数据只包含两样信息: 医生编号与医生 名字。 3. 药物资料是给定的,不可新增;药物数据只包含两样信息: 药物编号与药物 名字。 4. 可新增病人资料;病人数据只包含两样信息: 病人编号与病人名字。 5. 可新增挂号数据;挂号数据包含几样信息: 挂号编号、病人编号、病人名字、 诊别编号、诊别名字、医生编号、医生名字、药物编号、药物名字与挂号日 期;挂号时,一旦某病人选择了某诊别与某医生,则系统将根据该诊别与该 医生自动配置对应的药物。 有了以上的假设,我们应该要有以下这些档案: 诊别档: 用来提供诊别信息,档案的每一行应包含两个字段: 诊别编号与诊别名字。 subjects.log: 1 骨科 2 眼科 3 SARS专科 医生檔: 用来提供医生信息,档案的每一行应包含两个字段: 医生编号与医生名 5-90 字。 doctors.log: 1 林庄杰 2 许家荣 3 萧博文 4 林芳伶 5 陈明江 6 卢瑞鹏 药物檔: 用来提供药物信息,档案的每一行应包含两个字段: 药物编号与药物名 字。 medicines.log: 1 铁牛运功散 2 十八铜人行气散 3 福禄寿健儿宝 4 爱之味麦仔茶 5 统一埔里矿泉水 6 黑松沙士 7 东北三宝-人参,貂皮,乌拉草 8 天山雪莲 9 含笑半步癫 比对檔: 用来提供比对信息,所谓的比对信息就是哪科诊别配上哪位医生则开哪 种药物,档案的每一行应包含四个字段: 比对编号、诊别编号、医生编号与药物 编号。 matches.log: 1 1 1 1 2 1 2 2 3 1 3 3 4 1 4 4 5 2 2 5 6 2 3 6 5-91 7 2 4 7 8 2 5 8 9 3 3 9 10 3 4 1 11 3 5 2 12 3 6 3 病人檔: 用来提供病人信息,档案的每一行应包含两个字段: 病人编号与病人名字。 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 5-92 字段意义 字段名称 诊别编号 int id 诊别名称 char name[80] 2. 储存医生数据的数据结构(DOCTOR): DOCTOR 字段意义 字段名称 医生编号 int id 医生名称 char name[80] 3. 储存药物数据的数据结构(MEDICINE): MEDICINE 字段意义 字段名称 药物编号 int id 药物名称 char name[80] 4. 储存比对数据的数据结构(MATCH): MATCH 字段意义 字段名称 比对编号 int id 诊别编号 int subject_id 医生编号 int doctor_id 药物编号 int medicine_id 5. 储存病人数据的数据结构(PATIENT): PATIENT 字段意义 字段名称 病人编号 int id 病人名称 char name[80] 6. 储存挂号数据的数据结构(REPORT): REPORT 5-93 字段意义 字段名称 挂号编号 int id 病人编号 int patient_id 病人名称 chat patient_name[80] 诊别编号 int subject_id 诊别名称 char subject_name[80] 医生编号 int doctor_id 医生名称 char doctor_name[80] 药物编号 int medicine_id 药物名称 char medicine_name[80] 挂号日期 char date[80] 四: 主程序与子程序剖析: 1.主程序main(): 功能: 允许使用者输入选项(1.新增病人资料,2.挂号,3.查询某病人的就诊 纪录,4.查询某医生的看诊纪录,或5.结束程序),并执行该选项的功 能。 流程 快递问题件怎么处理流程河南自建厂房流程下载关于规范招聘需求审批流程制作流程表下载邮件下载流程设计 图: 5-94 主程式main()開始 開啟 診別檔若有任何檔 醫生檔案無法開啟主程式結束 藥物檔則結束程式 比對檔 開啟若有任何檔開啟 病人檔案無法開啟新的病人檔 掛號檔則開啟新檔新的掛號檔 初始化資 料 從檔案載 入資料 輸入選項 查詢某病查詢某醫儲存資料新增病人掛號人的就診生的看診無效的選項並資料紀錄紀錄結束程式 主程式結束 其中挂号功能比较复杂,因为我们必须判断1.某病人编号是否存在2.某病人所挂号的某医生是否有看某诊别3.某医生看某诊别时所开的药物的编号。 流程图 破产流程图 免费下载数据库流程图下载数据库流程图下载研究框架流程图下载流程图下载word : 5-95 掛號 Given病人編號 是否有此病人編號? searchPatient()副程式 Yes 輸入 掛號日期 診別編號 醫生編號 是否該醫生有看該診別? searchMatch()副程式 Yes 找出該診別在診別資料中 的位置 searchSubject()副程式找出該醫生在醫生資料中 No的位置 searchDoctor()副程式找出該醫生看該診別時所 開的藥物在藥物資料中的No位置 searchMedicine()副程式 執行掛號 addReport()副程式 掛號結束 程序代码: main() { 5-96 FILE * fp_subjects; //诊别档 FILE * fp_doctors; //医生档 FILE * fp_medicines; //药物档 FILE * fp_matches; //比对档 FILE * fp_patients; //病人檔 FILE * fp_reports; //挂号档 struct SUBJECT subjects[SUBJECTS_NUM+1], sub; //诊别资料 struct DOCTOR doctors[DOCTORS_NUM+1], doc; //医生资料 struct MEDICINE medicines[MEDICINES_NUM+1], med; //药物资料 struct MATCH matches[MATCHES_NUM+1], mat; //比对数据 struct PATIENT patients[PATIENTS_NUM+1], pat; //病人资料 struct REPORT reports[REPORTS_NUM+1], rep; //挂号数据 int pos_sub; //诊别数据位置 int pos_doc; //医生数据位置 int pos_med; //药物数据位置 int pos_mat; //比对数据位置 int pos_pat; //病人数据位置 int pos_rep; //挂号数据位置 int choice, 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("无法开启药物文件, 程序终止!"); 5-97 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); 5-98 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 ) { case 1 : //新增病人资料 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 ) { 5-99 printf("新增病人资料成功\!"); printf("\n"); } else { printf("病人资料已满!"); printf("\n"); } } break; case 2 : //挂号 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); //找出此医生名字 5-100 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; case 3 : //查询某病人的就诊纪录 printf("请输入病人编号> "); scanf("%d", &pat.id); if ( searchPatient(patients, pat.id)>0 ) { queryByPatient(reports, pat.id); } else { 5-101 printf("无此病人编号!"); printf("\n"); } break; case 4 : //查询某医生的看诊纪录 showDoctors(doctors); printf("请输入医生编号> "); scanf("%d", &doc.id); if ( searchDoctor(doctors, doc.id)>0 ) { queryByDoctor(reports, doc.id); } else { printf("无此医生编号!"); printf("\n"); } break; case 5 : //结束程序 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(): 5-102 功能: 初始化资料,在此仅举initSubjects()与initDoctors()两个例子,其它例 子与这两个例子相似。 流程图: 初始化診別資料的初始化醫生資料的 副程式開始副程式開始 initSubjects(subjects[])initDoctors(doctors[]) 從第1筆開始從第1筆開始 i = 1i = 1 下一筆下一筆 i = i+1i = i+1 到第到第 SUBJECTS_NUM筆結給定初始值DOCTORS_NUM筆結給定初始值YesYes束subjects[i].id = -1束doctors[i].id = -1 i<=SUBJECTS_NUMi<=DOCTORS_NUM NoNo 副程式結束副程式結束 程序代码: //初始化诊别资料 void initSubjects(struct SUBJECT subjects[]) { int i; for (i=1; i<=SUBJECTS_NUM; i++) { subjects[i].id = -1; } } //初始化医生资料 void initDoctors(struct DOCTOR doctors[]) { int i; for (i=1; i<=DOCTORS_NUM; i++) { doctors[i].id = -1; 5-103 } } 3.子程序loadSubjects(),loadDoctors(),loadMedicines(),loadMatches(), loadPatients(),loadReports(): 功能: 加载数据,在此仅举loadSubjects()与loadDoctors()两个例子,其它例 子与这两个例子相似。 流程图: 載入診別資料的載入醫生資料的 副程式開始副程式開始 loadSubjects(subjects[], fp)loadDoctors(doctors[], fp) count = 0count = 0 載入第count筆資料載入第count筆資料 尚未讀到檔尾Yescount = count+1尚未讀到檔尾Yescount = count+1 NoNo 副程式結束副程式結束 return countreturn count 程序代码: //加载诊别数据, 回传加载数据笔数 int loadSubjects(struct SUBJECT subjects[], FILE * fp) { int count; count = 0; while( !feof(fp) ) { count = count + 1; fscanf(fp, "%d\t%s\n", &subjects[count].id, &subjects[count].name); } 5-104 return count; } //加载医生数据, 回传加载数据笔数 int loadDoctors(struct DOCTOR doctors[], FILE * fp) { int count; count = 0; while( !feof(fp) ) { count = count + 1; fscanf(fp, "%d\t%s\n", &doctors[count].id, &doctors[count].name); } return count; } 4.子程序searchSubject(),searchDoctor(),searchMedicine(),searchPatient(): 功能: 搜寻诊别数据,搜寻医生数据,搜寻药物数据,与搜寻病人数据;搜寻 的条件为搜寻符合的编号的数据;如搜寻诊别数据为搜寻符合的诊别编 号的数据。 流程图: 5-105 搜尋診別資料的搜尋醫生資料的 副程式開始副程式開始 searchSubject(subjects[], id)searchDoctor(doctors[], id) 從第一筆開始從第一筆開始 index = 1index = 1 下一筆下一筆 index = index+1index = index+1 NoNo index<=SUBJECTS_NUM是否找到index<=DOCTORS_NUM是否找到 且Yessubjects[index].id且Yesdoctors[index].id= subjects[index].id!=-1==iddoctors[index].id!=-1=id NoYesNoYes 副程式結束副程式結束副程式結束副程式結束 return -1return indexreturn -1return index 搜尋藥物資料的搜尋病人資料的 副程式開始副程式開始 searchMedicine(medicines[], id)searchPatient(patients[], id) 從第一筆開始從第一筆開始 index = 1index = 1 下一筆下一筆 index = index+1index = index+1 NoNo index<=MEDICINES_NUM是否找到index<=PATIENTS_NUM是否找到 且Yesmedicines[index].i且Yespatients[index].id= medicines[index].id!=-1d==idpatients[index].id!=-1=id NoYesNoYes 副程式結束副程式結束副程式結束副程式結束 return -1return indexreturn -1return index 程序代码: //搜寻诊别数据, 回传诊别数据位置 int searchSubject(struct SUBJECT subjects[], int id) { int index; for (index=1; index<=SUBJECTS_NUM && subjects[index].id!=-1 ; index++) { if ( subjects[index].id==id ) { 5-106 return index; } } return -1; } //搜寻医生数据, 回传医生数据位置 int searchDoctor(struct DOCTOR doctors[], int id) { int index; for (index=1; index<=DOCTORS_NUM && doctors[index].id!=-1 ; index++) { if ( doctors[index].id==id ) { return index; } } return -1; } //搜寻药物数据, 回传药物数据位置 int searchMedicine(struct MEDICINE medicines[], int id) { int index; for (index=1; index<=MEDICINES_NUM && medicines[index].id!=-1 ; index++) { if ( medicines[index].id==id ) { return index; } } return -1; } //搜寻病人数据, 回传病人数据位置 int searchPatient(struct PATIENT patients[], int id) { int index; 5-107 for (index=1; index<=PATIENTS_NUM && patients[index].id!=-1 ; index++) { if ( patients[index].id==id ) { return index; } } return -1; } 5.子程序searchMatch(): 功能: 搜寻比对数据;搜寻的条件与前述4个不太一样,为搜寻同时符合的诊 别编号与医生编号的资料,也就是说,搜寻是否有某医生且看某诊别的 资料。 流程图: 搜尋比對資料的 副程式開始 searchMatch(matches[], sid, did) 從第1筆開始 index = 1 下一筆 index = index+1 No index<=MATCHES_NUMmatches[index].subject_id==sid 且Yes且 matches[index].id!=-1matches[index].doctor_id==did NoYes 副程式結束副程式結束 return -1return index 程序代码: 5-108 //搜寻比对数据, 回传比对数据位置 int searchMatch(struct MATCH matches[], int sid, int did) { int index; for (index=1; index<=MATCHES_NUM && matches[index].id!=-1 ; index++) { if ( matches[index].subject_id==sid && matches[index].doctor_id==did ) { return index; } } return -1; } 6.子程序addPatient(),addReport(): 功能: 新增病人数据与新增挂号数据。 流程图: 新增病人資料的新增掛號資料的 副程式開始副程式開始 addPatient(patients[], pat)addReport(reports[], rep) i = 1i = 1 i = i+1i = i+1 NoNo i<=PATIENTS_NUMYespatients[i].id==-1i<=REPORTS_NUMYesreports[i].id==-1 YesYes rep.id = ipatients[i] = patNoNoreports[i] = rep 副程式結束副程式結束副程式結束副程式結束 return -1return 1return -1return 1 程序代码: 5-109 //新增病人资料, 回传成功与否 int addPatient(struct PATIENT patients[], struct PATIENT pat) { int i; for (i=1; i<=PATIENTS_NUM; i++) { if ( patients[i].id==-1 ) { patients[i] = pat; return 1; } } return -1; } //新增挂号资料, 回传成功与否 int addReport(struct REPORT reports[], struct REPORT rep) { int i; for (i=1; i<=REPORTS_NUM; i++) { if ( reports[i].id==-1 ) { rep.id = i; reports[i] = rep; return 1; } } return -1; } 7.子程序queryByPatient(),queryByDoctor(): 功能: 查询某病人的就诊纪录与查询某医生的看诊纪录。 流程图: 5-110 查詢某病人的就診紀錄的查詢某醫生的看診紀錄的副程式開始副程式開始queryByPatient(reports[], id)queryByDoctor(reports[], id) count = 0count = 0 i = 1i = 1 i = i+1i = i+1 NoNo是否第i筆資料的病是否第i筆資料的醫i<=REPORTS_NUMi<=REPORTS_NUM人為該病人生為該醫生且Yes且Yesreports[i].patient_id=reports[i].doctor_id==reports[i].id!=-1reports[i].id!=-1=ididYesYes 顯示第i筆資料顯示第i筆資料NoNo 副程式結束副程式結束count = count+1count = count+1return countreturn count 程序代码: //查询某病人的就诊纪录, 回传显示数据笔数 int queryByPatient(struct REPORT reports[], int id) { int count, i; printf("病人名字\t诊别名字\t医生名字\t药物名字\t挂号日期\n"); count = 0; for (i=1; i<=REPORTS_NUM && reports[i].id!=-1 ; i++) { if ( reports[i].patient_id==id ) { printf("%s\t%s\t%s\t%s\t%s\n", reports[i].patient_name, reports[i].subject_name, reports[i].doctor_name, reports[i].medicine_name, reports[i].date); count = count + 1; } } 5-111 return count; } //查询某医生的看诊纪录, 回传显示数据笔数 int queryByDoctor(struct REPORT reports[], int id) { int count, i; printf("病人名字\t诊别名字\t医生名字\t药物名字\t挂号日期\n"); count = 0; for (i=1; i<=REPORTS_NUM && reports[i].id!=-1 ; i++) { if ( reports[i].doctor_id==id ) { printf("%s\t%s\t%s\t%s\t%s\n", reports[i].patient_name, reports[i].subject_name, reports[i].doctor_name, reports[i].medicine_name, reports[i].date); count = count + 1; } } return count; } 8.子程序showSubjects(),showDoctors(): 功能: 显示诊别数据与显示医生数据。 流程图: 5-112 顯示診別資料的顯示醫生資料的 副程式開始副程式開始 showSubjects(subjects[])showDoctors(doctors[]) count = 1count = 1 count = count+1count = count+1 count<=SUBJECTS_NUMcount<=DOCTORS_NUM 且Yes顯示第count筆資料Yes且Yes顯示第count筆資料Yes subjects[count].id!=-1doctors[count].id!=-1 NoNo 副程式結束副程式結束 return count-1return count-1 程序代码: //显示诊别数据, 回传显示数据笔数 int showSubjects(struct SUBJECT subjects[]) { int count; printf("诊别编号\t诊别名字\n"); for (count=1; count<=SUBJECTS_NUM && subjects[count].id!=-1 ; count++) { printf("%d\t%s\n", subjects[count].id, subjects[count].name); } return count-1; } //显示医生数据, 回传显示数据笔数 int showDoctors(struct DOCTOR doctors[]) { int count; printf("医生编号\t医生名字\n"); for (count=1; count<=DOCTORS_NUM && doctors[count].id!=-1 ; count++) { printf("%d\t%s\n", doctors[count].id, doctors[count].name); } return count-1; } 5-113 9.子程序savePatients(),saveReports(): 功能: 储存病人数据与储存挂号数据。 流程图: 儲存病人資料的儲存掛號資料的 副程式開始副程式開始 savePatients(patients[], fp)saveReports(reports[], fp) count = 1count = 1 count = count+1count = count+1 count<=PATIENTS_NUMcount<=REPORTS_NUM 且Yes儲存第count筆資料Yes且Yes儲存第count筆資料Yes patients[count].id!=-1reports[count].id!=-1 NoNo 副程式結束副程式結束 return count-1return count-1 程序代码: //储存病人数据, 回传储存数据笔数 int savePatients(struct PATIENT patients[], FILE * fp) { int count; for (count=1; count<=PATIENTS_NUM && patients[count].id!=-1 ; count++) { fprintf(fp, "%d\t%s\n", patients[count].id, patients[count].name); } return count-1; } //储存挂号数据, 回传储存数据笔数 int saveReports(struct REPORT reports[], FILE * fp) { int count; for (count=1; count<=REPORTS_NUM && reports[count].id!=-1 ; count++) 5-114 { fprintf(fp, "%d\t%d\t%s\t%d\t%s\t%d\t%s\t%d\t%s\t%s\n", reports[count].id, reports[count].patient_id, reports[count].patient_name, reports[count].subject_id, reports[count].subject_name, reports[count].doctor_id, reports[count].doctor_name, reports[count].medicine_id, reports[count].medicine_name, reports[count].date); } return count-1; } 五: 程序执行范例: 执行程序: anonymous@ccsun >a.out 一开始,程序会显示主选单: *****************主选单***************** **************************************** 1. 新增病人资料 2. 挂号 3. 查询某病人的就诊纪录 4. 查询某医生的看诊纪录 5. 结束 **************************************** 新增三名病人资料: *****************主选单***************** **************************************** 1. 新增病人资料 5-115 2. 挂号 3. 查询某病人的就诊纪录 4. 查询某医生的看诊纪录 5. 结束 **************************************** 请选择> 1 请输入病人编号> 12 请输入病人名字> 吴柏宏 新增病人资料成功! *****************主选单***************** **************************************** 1. 新增病人资料 2. 挂号 3. 查询某病人的就诊纪录 4. 查询某医生的看诊纪录 5. 结束 **************************************** 请选择> 1 请输入病人编号> 15 请输入病人名字> 黄俊育 新增病人资料成功! *****************主选单***************** **************************************** 1. 新增病人资料 2. 挂号 3. 查询某病人的就诊纪录 4. 查询某医生的看诊纪录 5. 结束 **************************************** 请选择> 1 请输入病人编号> 19 请输入病人名字> 石凌霖 新增病人资料成功! 新增三笔挂号数据: *****************主选单***************** **************************************** 5-116 1. 新增病人资料 2. 挂号 3. 查询某病人的就诊纪录 4. 查询某医生的看诊纪录 5. 结束 **************************************** 请选择> 2 请输入病人编号> 12 请输入挂号日期 (ex.2002/04/20) > 2003/01/01 诊别编号 诊别名字 1 骨科 2 眼科 3 SARS专科 请输入诊别编号> 1 医生编号 医生名字 1 林庄杰 2 许家荣 3 萧博文 4 林芳伶 5 陈明江 6 卢瑞鹏 请输入医生编号> 2 新增挂号资料成功! *****************主选单***************** **************************************** 1. 新增病人资料 2. 挂号 3. 查询某病人的就诊纪录 4. 查询某医生的看诊纪录 5. 结束 **************************************** 请选择> 2 请输入病人编号> 15 请输入挂号日期 (ex.2002/04/20) > 2003/02/02 诊别编号 诊别名字 1 骨科 2 眼科 3 SARS专科 5-117 请输入诊别编号> 2 医生编号 医生名字 1 林庄杰 2 许家荣 3 萧博文 4 林芳伶 5 陈明江 6 卢瑞鹏 请输入医生编号> 4 新增挂号资料成功! *****************主选单***************** **************************************** 1. 新增病人资料 2. 挂号 3. 查询某病人的就诊纪录 4. 查询某医生的看诊纪录 5. 结束 **************************************** 请选择> 2 请输入病人编号> 19 请输入挂号日期 (ex.2002/04/20) > 2003/03/03 诊别编号 诊别名字 1 骨科 2 眼科 3 SARS专科 请输入诊别编号> 3 医生编号 医生名字 1 林庄杰 2 许家荣 3 萧博文 4 林芳伶 5 陈明江 6 卢瑞鹏 请输入医生编号> 6 新增挂号资料成功! 结束: 5-118 *****************主选单***************** **************************************** 1. 新增病人资料 2. 挂号 3. 查询某病人的就诊纪录 4. 查询某医生的看诊纪录 5. 结束 **************************************** 请选择> 5 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 六: 完整的程序代码: #include #include #define SUBJECTS_FILE "subjects.log" //诊别档 #define DOCTORS_FILE "doctors.log" //医生档 #define MEDICINES_FILE "medicines.log" //药物档 #define MATCHES_FILE "matches.log" //比对档 #define PATIENTS_FILE "patients.log" //病人檔 #define REPORTS_FILE "reports.log" //挂号档 #define SUBJECTS_NUM 10 //诊别资料最大数目 #define DOCTORS_NUM 50 //医生资料最大数目 #define MEDICINES_NUM 100 //药物资料最大数目 #define MATCHES_NUM 500 //比对数据最大数目 5-119 #define PATIENTS_NUM 1000 //病人资料最大数目 #define REPORTS_NUM 5000 //挂号资料最大数目 struct SUBJECT //诊别资料 { int id; //诊别编号 char name[80]; //诊别名字 }; struct DOCTOR //医生资料 { int id; //医生编号 char name[80]; //医生名字 }; struct MEDICINE //药物资料 { int id; //药物编号 char name[80]; //药物名字 }; struct MATCH //比对数据 { int id; //比对编号 int subject_id; //诊别编号 int doctor_id; //医生编号 int medicine_id; //药物编号 }; struct PATIENT //病人资料 { int id; //病人编号 char name[80]; //病人名字 }; struct REPORT //挂号数据 { int id; //挂号编号 int patient_id; //病人编号 char patient_name[80]; //病人名字 int subject_id; //诊别编号 char subject_name[80]; //诊别名字 int doctor_id; //医生编号 5-120 char doctor_name[80]; //医生名字 int medicine_id; //药物编号 char medicine_name[80]; //药物名字 char date[80]; //挂号日期 }; //初始化诊别资料 void initSubjects(struct SUBJECT subjects[]); //初始化医生资料 void initDoctors(struct DOCTOR doctors[]); //初始化药物资料 void initMedicines(struct MEDICINE medicines[]); //初始化比对数据 void initMatches(struct MATCH matches[]); //初始化病人资料 void initPatients(struct PATIENT patients[]); //初始化挂号数据 void initReports(struct REPORT reports[]); //加载诊别数据, 回传加载数据笔数 int loadSubjects(struct SUBJECT subjects[], FILE * fp); //加载医生数据, 回传加载数据笔数 int loadDoctors(struct DOCTOR doctors[], FILE * fp); //加载药物数据, 回传加载数据笔数 int loadMedicines(struct MEDICINE medicines[], FILE * fp); //加载比对数据, 回传加载数据笔数 int loadMatches(struct MATCH matches[], FILE * fp); //加载病人数据, 回传加载数据笔数 int loadPatients(struct PATIENT patients[], FILE * fp); //加载挂号数据, 回传加载数据笔数 int loadReports(struct REPORT reports[], FILE * fp); //搜寻诊别数据, 回传诊别数据位置 int searchSubject(struct SUBJECT subjects[], int id); //搜寻医生数据, 回传医生数据位置 int searchDoctor(struct DOCTOR doctors[], int id); //搜寻药物数据, 回传药物数据位置 int searchMedicine(struct MEDICINE medicines[], int id); 5-121 //搜寻比对数据, 回传比对数据位置 int searchMatch(struct MATCH matches[], int sid, int did); //搜寻病人数据, 回传病人数据位置 int searchPatient(struct PATIENT patients[], int id); //新增病人资料, 回传成功与否 int addPatient(struct PATIENT patients[], struct PATIENT pat); //新增挂号资料, 回传成功与否 int addReport(struct REPORT reports[], struct REPORT rep); //查询某病人的就诊纪录, 回传显示数据笔数 int queryByPatient(struct REPORT reports[], int id); //查询某医生的看诊纪录, 回传显示数据笔数 int queryByDoctor(struct REPORT reports[], int id); //显示诊别数据, 回传显示数据笔数 int showSubjects(struct SUBJECT subjects[]); //显示医生数据, 回传显示数据笔数 int showDoctors(struct DOCTOR doctors[]); //储存病人数据, 回传储存数据笔数 int savePatients(struct PATIENT patients[], FILE * fp); //储存挂号数据, 回传储存数据笔数 int saveReports(struct REPORT reports[], FILE * fp); main() { FILE * fp_subjects; //诊别档 FILE * fp_doctors; //医生档 FILE * fp_medicines; //药物档 FILE * fp_matches; //比对档 FILE * fp_patients; //病人檔 FILE * fp_reports; //挂号档 struct SUBJECT subjects[SUBJECTS_NUM+1], sub; //诊别资料 struct DOCTOR doctors[DOCTORS_NUM+1], doc; //医生资料 struct MEDICINE medicines[MEDICINES_NUM+1], med; //药物资料 struct MATCH matches[MATCHES_NUM+1], mat; //比对数据 5-122 struct PATIENT patients[PATIENTS_NUM+1], pat; //病人资料 struct REPORT reports[REPORTS_NUM+1], rep; //挂号数据 int pos_sub; //诊别数据位置 int pos_doc; //医生数据位置 int pos_med; //药物数据位置 int pos_mat; //比对数据位置 int pos_pat; //病人数据位置 int pos_rep; //挂号数据位置 int choice, 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")) ) //开启病人档 { 5-123 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"); 5-124 printf("3. 查询某病人的就诊纪录"); printf("\n"); printf("4. 查询某医生的看诊纪录"); printf("\n"); printf("5. 结束"); printf("\n"); printf("****************************************"); printf("\n"); printf("请选择> "); scanf("%d", &choice); //输入选项 switch ( choice ) { case 1 : //新增病人资料 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; case 2 : //挂号 5-125 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"); } 5-126 else { printf("挂号数据已满!"); printf("\n"); } } else //如果此医生不看此诊别 { printf("此医生不看此诊别!"); printf("\n"); } } else //如果无此病人编号 { printf("无此病人编号!"); printf("\n"); } break; case 3 : //查询某病人的就诊纪录 printf("请输入病人编号> "); scanf("%d", &pat.id); if ( searchPatient(patients, pat.id)>0 ) { queryByPatient(reports, pat.id); } else { printf("无此病人编号!"); printf("\n"); } break; case 4 : //查询某医生的看诊纪录 showDoctors(doctors); printf("请输入医生编号> "); scanf("%d", &doc.id); if ( searchDoctor(doctors, doc.id)>0 ) { queryByDoctor(reports, doc.id); 5-127 } else { printf("无此医生编号!"); printf("\n"); } break; case 5 : //结束程序 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; } } } //初始化诊别资料 void initSubjects(struct SUBJECT subjects[]) { int i; for (i=1; i<=SUBJECTS_NUM; i++) { subjects[i].id = -1; } } //初始化医生资料 void initDoctors(struct DOCTOR doctors[]) { int i; 5-128 for (i=1; i<=DOCTORS_NUM; i++) { doctors[i].id = -1; } } //初始化药物资料 void initMedicines(struct MEDICINE medicines[]) { int i; for (i=1; i<=MEDICINES_NUM; i++) { medicines[i].id = -1; } } //初始化比对数据 void initMatches(struct MATCH matches[]) { int i; for (i=1; i<=MATCHES_NUM; i++) { matches[i].id = -1; } } //初始化病人资料 void initPatients(struct PATIENT patients[]) { int i; for (i=1; i<=PATIENTS_NUM; i++) { patients[i].id = -1; } } //初始化挂号数据 void initReports(struct REPORT reports[]) 5-129 { int i; for (i=1; i<=REPORTS_NUM; i++) { reports[i].id = -1; } } //加载诊别数据, 回传加载数据笔数 int loadSubjects(struct SUBJECT subjects[], FILE * fp) { int count; count = 0; while( !feof(fp) ) { count = count + 1; fscanf(fp, "%d\t%s\n", &subjects[count].id, &subjects[count].name); } return count; } //加载医生数据, 回传加载数据笔数 int loadDoctors(struct DOCTOR doctors[], FILE * fp) { int count; count = 0; while( !feof(fp) ) { count = count + 1; fscanf(fp, "%d\t%s\n", &doctors[count].id, &doctors[count].name); } return count; } //加载药物数据, 回传加载数据笔数 int loadMedicines(struct MEDICINE medicines[], FILE * fp) { int count; 5-130 count = 0; while( !feof(fp) ) { count = count + 1; fscanf(fp, "%d\t%s\n", &medicines[count].id, &medicines[count].name); } return count; } //加载比对数据, 回传加载数据笔数 int loadMatches(struct MATCH matches[], FILE * fp) { int count; count = 0; while( !feof(fp) ) { count = count + 1; fscanf(fp, "%d\t%d\t%d\t%d\n", &matches[count].id, &matches[count].subject_id, &matches[count].doctor_id, &matches[count].medicine_id); } return count; } //加载病人数据, 回传加载数据笔数 int loadPatients(struct PATIENT patients[], FILE * fp) { int count; count = 0; while( !feof(fp) ) { count = count + 1; fscanf(fp, "%d\t%s\n", &patients[count].id, &patients[count].name); } return count; } 5-131 //加载挂号数据, 回传加载数据笔数 int loadReports(struct REPORT reports[], FILE * fp) { int count; count = 0; while( !feof(fp) ) { count = count + 1; fscanf(fp, "%d\t%d\t%s\t%d\t%s\t%d\t%s\t%d\t%s\t%s\n", &reports[count].id, &reports[count].patient_id, &reports[count].patient_name, &reports[count].subject_id, &reports[count].subject_name, &reports[count].doctor_id, &reports[count].doctor_name, &reports[count].medicine_id, &reports[count].medicine_name, &reports[count].date); } return count; } //搜寻诊别数据, 回传诊别数据位置 int searchSubject(struct SUBJECT subjects[], int id) { int index; for (index=1; index<=SUBJECTS_NUM && subjects[index].id!=-1 ; index++) { if ( subjects[index].id==id ) { return index; } } return -1; } 5-132 //搜寻医生数据, 回传医生数据位置 int searchDoctor(struct DOCTOR doctors[], int id) { int index; for (index=1; index<=DOCTORS_NUM && doctors[index].id!=-1 ; index++) { if ( doctors[index].id==id ) { return index; } } return -1; } //搜寻药物数据, 回传药物数据位置 int searchMedicine(struct MEDICINE medicines[], int id) { int index; for (index=1; index<=MEDICINES_NUM && medicines[index].id!=-1 ; index++) { if ( medicines[index].id==id ) { return index; } } return -1; } //搜寻比对数据, 回传比对数据位置 int searchMatch(struct MATCH matches[], int sid, int did) { int index; for (index=1; index<=MATCHES_NUM && matches[index].id!=-1 ; index++) { if ( matches[index].subject_id==sid && matches[index].doctor_id==did ) { return index; } 5-133 } return -1; } //搜寻病人数据, 回传病人数据位置 int searchPatient(struct PATIENT patients[], int id) { int index; for (index=1; index<=PATIENTS_NUM && patients[index].id!=-1 ; index++) { if ( patients[index].id==id ) { return index; } } return -1; } //新增病人资料, 回传成功与否 int addPatient(struct PATIENT patients[], struct PATIENT pat) { int i; for (i=1; i<=PATIENTS_NUM; i++) { if ( patients[i].id==-1 ) { patients[i] = pat; return 1; } } return -1; } //新增挂号资料, 回传成功与否 int addReport(struct REPORT reports[], struct REPORT rep) { int i; for (i=1; i<=REPORTS_NUM; i++) 5-134 { if ( reports[i].id==-1 ) { rep.id = i; reports[i] = rep; return 1; } } return -1; } //查询某病人的就诊纪录, 回传显示数据笔数 int queryByPatient(struct REPORT reports[], int id) { int count, i; printf("病人名字\t诊别名字\t医生名字\t药物名字\t挂号日期\n"); count = 0; for (i=1; i<=REPORTS_NUM && reports[i].id!=-1 ; i++) { if ( reports[i].patient_id==id ) { printf("%s\t%s\t%s\t%s\t%s\n", reports[i].patient_name, reports[i].subject_name, reports[i].doctor_name, reports[i].medicine_name, reports[i].date); count = count + 1; } } return count; } //查询某医生的看诊纪录, 回传显示数据笔数 int queryByDoctor(struct REPORT reports[], int id) { int count, i; printf("病人名字\t诊别名字\t医生名字\t药物名字\t挂号日期\n"); count = 0; 5-135 for (i=1; i<=REPORTS_NUM && reports[i].id!=-1 ; i++) { if ( reports[i].doctor_id==id ) { printf("%s\t%s\t%s\t%s\t%s\n", reports[i].patient_name, reports[i].subject_name, reports[i].doctor_name, reports[i].medicine_name, reports[i].date); count = count + 1; } } return count; } //显示诊别数据, 回传显示数据笔数 int showSubjects(struct SUBJECT subjects[]) { int count; printf("诊别编号\t诊别名字\n"); for (count=1; count<=SUBJECTS_NUM && subjects[count].id!=-1 ; count++) { printf("%d\t%s\n", subjects[count].id, subjects[count].name); } return count-1; } //显示医生数据, 回传显示数据笔数 int showDoctors(struct DOCTOR doctors[]) { int count; printf("医生编号\t医生名字\n"); for (count=1; count<=DOCTORS_NUM && doctors[count].id!=-1 ; count++) { printf("%d\t%s\n", doctors[count].id, doctors[count].name); } return count-1; } 5-136 //储存病人数据, 回传储存数据笔数 int savePatients(struct PATIENT patients[], FILE * fp) { int count; for (count=1; count<=PATIENTS_NUM && patients[count].id!=-1 ; count++) { fprintf(fp, "%d\t%s\n", patients[count].id, patients[count].name); } return count-1; } //储存挂号数据, 回传储存数据笔数 int saveReports(struct REPORT reports[], FILE * fp) { int count; for (count=1; count<=REPORTS_NUM && reports[count].id!=-1 ; count++) { fprintf(fp, "%d\t%d\t%s\t%d\t%s\t%d\t%s\t%d\t%s\t%s\n", reports[count].id, reports[count].patient_id, reports[count].patient_name, reports[count].subject_id, reports[count].subject_name, reports[count].doctor_id, reports[count].doctor_name, reports[count].medicine_id, reports[count].medicine_name, reports[count].date); } return count-1; } 5-137
本文档为【医院挂号系统设计】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_212655
暂无简介~
格式:doc
大小:120KB
软件:Word
页数:66
分类:
上传时间:2018-03-18
浏览量:72