1、基于MYSQL的医院综合信息管理系统设计报告样本数据库实验报告医院综合信息管理系统专 业 班 级 组 长 组 员 指引教师 内容提纲 :本系统是一种基于MYSQL而建立医院综合信息管理系统。用Microsoft Visual Studio 结合MYSQL开发了3个模块。涉及有人员信息管理,门诊信息管理,收费信息管理。其中人员信息管理其中有医生信息管理,病人信息管理和药物信息管理。门诊信息管理其中则具有就诊信息管理,病人处方管理。这3模块基本实现了医院综合信息管理系统需求。【核心词】:Microsoft Visual Studio ,MYSQL,人员信息管理,门诊信息管理,收费信息管理一、需求分
2、析:整个医院综合信息管理系统可分为三个子系统:人员信息管理系统,门诊信息管理系统,收费信息管理系统。1.1人员信息管理系统人员信息管理即对于人和物品管理,人则包括医生及医护人员,就诊病人,尚有药物等。咱们需要对她们基本信息进行记录,并且还要具备增长,删除,修改,查询等基本功能,因此我建立了一种基本信息管理模块来专门解决。我也在数据库中相应了三张表:doctor,patient,durg以便对人员信息管理信息进行存储。1.2门诊信息管理系统对于就诊信息管理,病人看病后会产生新数据,例如医生对病人诊断信息,以及药物处方信息。而与其相应则是我做门诊信息管理,其中我做了两个窗口,一种是诊断信息窗口,重
3、要实现对诊断信息储存;另一种是处方信息窗口,有增长、删除、修改药物等功能。然后我另做了一种查询窗口,以便病人查询自己处方记录。相应数据库,我做了两张表:diagnosis,prescription。1.3收费信息管理系统对于收费信息管理,病人拿处处方后,就会取药,付款。则我需要对其总价进行计算,再者就是对于药物库存进行修改。于是相应规定我做了一种收费前台。虽然在数据库中没有相应相应表。可是它操作重要是对prescription读取,以及对durg库存修改。二、系统分析:整个医院综合信息管理系统可分为三个子系统:人员信息管理系统,门诊信息管理系统,收费信息管理系统。2.1系统功能简介2. 1.
4、1 人员信息管理系统功能对医生、病人、药物基本信息进行增长,删除,修改,查询等基本功能2. 1. 2 门诊信息管理系统功能对就诊信息存储功能和对处方信息进行增长、删除、修改药物等基本功能3. 2. 3 收费信息管理系统对医疗费用进行总和计算功能和对药物库存进行修改功能2.2功能模块系统重要功能模块图如下:三、数据库设计:3.1 E-R图:3.1.1医生信息doctor E-R图3.1.2病人信息patient E-R图3.1.3药物信息drug E-R图3.1.4诊断信息diagnosis E-R图3.1.5处方信息prescription E-R图3.1.6实体间重要关系E-R图3.2数据字
5、典:表1:doctor:表2:patient表3:durg表4:diagnosis表5:prescription四、前台设计:4.1.医生信息管理:4.2.病人信息管理:4.3.药物信息管理:4.4.诊断界面:4.5.处方界面:4.6.病人处方查询:4.7.收费信息管理:五、程序调试成果:1.主界面:2.添加功能:实当代码:void CEmployeeDlg:OnBnClickedOk() / TODO:在此添加控件告知解决程序代码 /CDialogEx:OnOK(); UpdateData(true); if(m_number.IsEmpty() MessageBox(CString(编号不
6、能为空”); return; if(m_name.IsEmpty() MessageBox(CString(名称不能为空!); return; if(m_idcard.IsEmpty() MessageBox(CString(省份证号码不能为空!); return; CADOConn m_AdoConn; m_AdoConn.OnInitADOConn(); _bstr_t sql; sql = select* from doctor; _RecordsetPtr m_pRecordset; m_pRecordset=m_AdoConn.GetRecordSet(sql); try m_pRe
7、cordset-AddNew();/添加新行 m_pRecordset-PutCollect(employeeno,(_bstr_t)m_number); m_pRecordset-PutCollect(name,(_bstr_t)m_name); m_pRecordset-PutCollect(sex,(_bstr_t)m_sex); m_pRecordset-PutCollect(age,(_bstr_t)m_age); m_pRecordset-PutCollect(native,(_bstr_t)m_native); m_pRecordset-PutCollect(nation,(_b
8、str_t)m_nation); m_pRecordset-PutCollect(office,(_bstr_t)m_office); m_pRecordset-PutCollect(position,(_bstr_t)m_position); m_pRecordset-PutCollect(idcard,(_bstr_t)m_idcard); m_pRecordset-PutCollect(phone,(_bstr_t)m_phone); m_pRecordset-Update();/更新数据库 m_AdoConn.ExitConnect();/断开数据库连接 catch(.) Messag
9、eBox(CString(操作失败); return; MessageBox(CString(保存成功); m_grid.DeleteAllItems();/删除grid中本来数据 CString str; str=select* from doctor; AddToGrid(str);/重新遍历2.修改功能:实当代码:void CEmployeeDlg:OnBnClickedChange() / TODO:在此添加控件告知解决程序代码 UpdateData(true); CADOConn m_AdoConn; m_AdoConn.OnInitADOConn(); CString tempSq
10、l; tempSql.Format(CString(UPDATEmydb.doctorSET name=%s,sex=%s,age=%s,native=%s,nation=%s,office=%s,position=%s,idcard=%s,phone=%sWHERE employeeno=%s),m_name,m_sex,m_age,m_native,m_nation,m_office,m_position,m_idcard,m_phone,m_number); m_AdoConn.ExecuteSQL(_bstr_t)tempSql); m_AdoConn.ExitConnect(); M
11、essageBox(CString(修改成功.); m_grid.DeleteAllItems();/删除grid中本来数据 CString str; str=select* from doctor; AddToGrid(str);/重新遍历3删除功能:代码实现:void CEmployeeDlg:OnBnClickedDelete() / TODO:在此添加控件告知解决程序代码 UpdateData(true); CADOConn m_AdoConn; m_AdoConn.OnInitADOConn(); CString tempSql; tempSql.Format(CString(del
12、ete from doctor where employeeno = %s),m_number); CString tenpstr; tenpstr.Format(CString(与否要删除%s记录),m_name); if(MessageBox(tenpstr,CString(提示),MB_OKCANCEL)=IDOK) m_AdoConn.ExecuteSQL(_bstr_t)tempSql); m_AdoConn.ExitConnect(); MessageBox(CString(删除成功.); m_grid.DeleteAllItems();/删除grid中本来数据 CString s
13、tr; str=select* from doctor; AddToGrid(str);/重新遍历 4.查询功能:实当代码:void CEmployeeDlg:OnBnClickedSelect() / TODO:在此添加控件告知解决程序代码 m_grid.DeleteAllItems(); UpdateData(true); CString str1,str2; int num1,num2; num1=m_combo.GetCurSel(); if(0=num1) GetDlgItem(IDC_EDIT_CONTENT)-GetWindowText(str1); str2=CString(s
14、elect* from doctor where employeeno like )+CString()+str1+CString(); AddToGrid(str2);/ 遍历功能信息记录 if(1=num1) GetDlgItem(IDC_EDIT_CONTENT)-GetWindowText(str1); str2=CString(select* from doctor where name like )+CString()+str1+CString(); AddToGrid(str2);/ 遍历功能信息记录 if(2=num1) GetDlgItem(IDC_EDIT_CONTENT)
15、-GetWindowText(str1); str2=CString(select* from doctor where office like )+CString()+str1+CString(); AddToGrid(str2);/ 遍历功能信息记录 if(3=num1) GetDlgItem(IDC_EDIT_CONTENT)-GetWindowText(str1); str2=CString(select* from doctor where position like )+CString()+str1+CString(); AddToGrid(str2);/ 遍历功能信息记录 if(
16、4=num1) GetDlgItem(IDC_EDIT_CONTENT)-GetWindowText(str1); str2=CString(select* from doctor where idcard like )+CString()+str1+CString(); AddToGrid(str2);/ 遍历功能信息记录 if(5=num1) GetDlgItem(IDC_EDIT_CONTENT)-GetWindowText(str1); str2=select* from doctor order by employeeno DESC; AddToGrid(str2);/ 遍历功能信息
17、记录 5.诊断界面:6.处方界面:7.处方查询:8.付款界面:9.修改库存:对比图:付款前:付款后:六、总结:通过这次数据库大作业,咱们熟悉了vs数据库ADO编程。对于它添加,修改,删除环节均有了较大理解。在本次作业当中遇到两大问题。一是:数据库连接问题,本来开始准备用access做后台,可是不懂得为什么我电脑始终连接不上,于是改用了MYAQL连接。二是:在是使用记录集指针问题_RecordsetPtr m_pRecordset,在实现添加,删除,修改,查询等操作时,只能执行一次就浮现指针无效成果。最后发现是在连接数据库时没有初始化COM,因此导致有指针无效成果。然后,最让我开心是,是实现总价
18、计算。我是用两个数组,amount20,和price20记住数量和单价,运用for循环计算总价。然后,就是在 vs中字符之间转换也是咱们应当注意问题。总之,这次实验,让咱们学到了许多课本上学不到知识,也锻炼了咱们思考问题,解决问题能力。附录:医院综合信息管理系统源代码/ ADOConn.cpp :实现文献/#include stdafx.h#include hospital.h#include ADOConn.h/ CADOConnCADOConn:CADOConn()CADOConn:CADOConn()/ CADOConn 成员函数bool CADOConn:OnInitADOConn(v
19、oid) HRESULT hr; :CoInitialize(NULL); try hr=m_pDBConnection.CreateInstance(ADODB.Connection); if(SUCCEEDED(hr) m_pDBConnection-ConnectionTimeout=3; /设立连接字符串 _bstr_t strConnection=Driver=MySQL ODBC 5.2 Unicode Driver;SERVER=127.0.0.1;DATABASE=mydb;UID=root;PASSWORD=123456;PORT=3306; hr=m_pDBConnecti
20、on-Open(strConnection,adModeUnknown); catch(_com_error e)/捕获异常 CString temp; temp.Format(CString(连接数据库错误信息:%s),e.ErrorMessage(); :MessageBox(NULL,temp,CString(提示信息),NULL); return false; return false;/ 断开数据库连接void CADOConn:ExitConnect(void) if (m_pRecordset!=NULL) m_pRecordset-Close(); m_pDBConnectio
21、n-Close(); /释放环境 :CoUninitialize();/ 获取记录集_RecordsetPtr& CADOConn:GetRecordSet(_bstr_t bstrSQL) try if(m_pDBConnection=NULL) OnInitADOConn(); m_pRecordset.CreateInstance(_uuidof(Recordset); m_pRecordset-Open(bstrSQL,m_pDBConnection.GetInterfacePtr(),adOpenDynamic,adLockOptimistic,adCmdText); catch(_
22、com_error e) CString temp; temp.Format(CString(读取数据库错误信息:%s),e.ErrorMessage(); :MessageBox(NULL,temp,CString(提示信息),NULL); return m_pRecordset;/ 执行SQL语句bool CADOConn:ExecuteSQL(_bstr_t bstrSQL) _variant_t RecordsAffected; try if(m_pDBConnection=NULL) OnInitADOConn(); m_pDBConnection-Execute(bstrSQL,N
23、ULL,adCmdText); return true; catch(_com_error e) CString temp; temp.Format(CString(执行SQL语句错误信息:%s),e.Description(); :MessageBox(NULL,temp,CString(提示信息),NULL); return false; / 返回记录集对象指针SQL执行函数_RecordsetPtr CADOConn:ExcuteSQLObj(_bstr_t bstrSQL) try if(m_pDBConnection=NULL) OnInitADOConn(); m_pRecords
24、et=m_pDBConnection-Execute(bstrSQL,NULL,adCmdText); catch(_com_error e) CString temp; m_pRecordset=NULL; temp.Format(CString(执行SQL语句错误信息:%s),e.ErrorMessage(); :MessageBox(NULL,temp,CString(提示信息),NULL); return m_pRecordset;/ PrescriptionDlg.cpp :实现文献/处方:万淑妍#include stdafx.h#include hospital.h#include
25、 PrescriptionDlg.h#include afxdialogex.h#include ADOConn.h/ CPrescriptionDlg 对话框IMPLEMENT_DYNAMIC(CPrescriptionDlg,CDialogEx)CPrescriptionDlg:CPrescriptionDlg(CWnd* pParent /*=NULL*/) :CDialogEx(CPrescriptionDlg:IDD,pParent) m_patientno = _T(); m_amount = _T(); m_name = _T(); m_no = 0;CPrescriptionD
26、lg:CPrescriptionDlg()void CPrescriptionDlg:DoDataExchange(CDataExchange* pDX) CDialogEx:DoDataExchange(pDX); DDX_Control(pDX,IDC_LIST1,m_grid); DDX_Text(pDX,IDC_PATIENTNO,m_patientno); DDX_Text(pDX,IDC_AMOUNT,m_amount); DDX_Text(pDX,IDC_DURGNAME,m_name); DDX_Control(pDX,IDC_DATETIMEPICKER1,m_time);B
27、EGIN_MESSAGE_MAP(CPrescriptionDlg,CDialogEx) ON_BN_CLICKED(IDOK,&CPrescriptionDlg:OnBnClickedOk) ON_BN_CLICKED(IDC_CHANGE,&CPrescriptionDlg:OnBnClickedChange) ON_NOTIFY(NM_CLICK,IDC_LIST1,&CPrescriptionDlg:OnNMClickList1) ON_BN_CLICKED(IDC_DELETE,&CPrescriptionDlg:OnBnClickedDelete) ON_BN_CLICKED(ID
28、C_CLEAR,&CPrescriptionDlg:OnBnClickedClear)END_MESSAGE_MAP()/ CPrescriptionDlg 消息解决程序BOOL CPrescriptionDlg:OnInitDialog() CDialogEx:OnInitDialog(); / TODO: 在此添加额外初始化 flag=0; return TRUE; / return TRUE unless you set the focus to a control / 异常:OCX 属性页应返回 FALSEvoid CPrescriptionDlg:AddToGrid(CString str) CADOConn m_AdoConn; m_AdoConn.OnInitADOConn(); CString sql; sql.Format(str); _RecordsetPtr m_pRecordset; m_pRecordset = m_AdoConn.GetRecordSet(_bstr_t)sql); while(m_AdoConn.m_pRecordset-adoEOF=0)