资源描述
数据库实验报告
医院综合信息管理系统
专 业
班 级
组 长
组 员
指引教师
目录
一、 需求分析: 2
1.1人员信息管理系统 2
1.2门诊信息管理系统 3
1.3收费信息管理系统 3
二、系统分析: 3
2.1系统功能简介 3
2.2功能模块 3
三、数据库设计: 4
3.1 E-R图: 4
3.2数据字典: 6
四、前台设计: 8
4.1.医生信息管理: 8
4.2.病人信息管理: 8
4.3.药物信息管理: 9
4.4.诊断界面: 10
4.5.处方界面: 10
4.6.病人处方查询: 10
4.7.收费信息管理: 11
五、程序调试成果: 12
六、总结: 22
内容提纲 :
本系统是一种基于MYSQL而建立医院综合信息管理系统。用Microsoft Visual Studio 结合MYSQL开发了3个模块。涉及有人员信息管理,门诊信息管理,收费信息管理。其中人员信息管理其中有医生信息管理,病人信息管理和药物信息管理。门诊信息管理其中则具有就诊信息管理,病人处方管理。这3模块基本实现了医院综合信息管理系统需求。
【核心词】:Microsoft Visual Studio ,MYSQL,人员信息管理,门诊信息管理,收费信息管理
一、 需求分析:
整个医院综合信息管理系统可分为三个子系统:人员信息管理系统,门诊信息管理系统,收费信息管理系统。
1.1人员信息管理系统
人员信息管理即对于人和物品管理,人则包括医生及医护人员,就诊病人,尚有药物等。咱们需要对她们基本信息进行记录,并且还要具备增长,删除,修改,查询等基本功能,因此我建立了一种基本信息管理模块来专门解决。我也在数据库中相应了三张表:doctor,patient,durg以便对人员信息管理信息进行存储。
1.2门诊信息管理系统
对于就诊信息管理,病人看病后会产生新数据,例如医生对病人诊断信息,以及药物处方信息。而与其相应则是我做门诊信息管理,其中我做了两个窗口,一种是诊断信息窗口,重要实现对诊断信息储存;另一种是处方信息窗口,有增长、删除、修改药物等功能。然后我另做了一种查询窗口,以便病人查询自己处方记录。相应数据库,我做了两张表:diagnosis,prescription。
1.3收费信息管理系统
对于收费信息管理,病人拿处处方后,就会取药,付款。则我需要对其总价进行计算,再者就是对于药物库存进行修改。于是相应规定我做了一种收费前台。虽然在数据库中没有相应相应表。可是它操作重要是对prescription读取,以及对durg库存修改。
二、系统分析:
整个医院综合信息管理系统可分为三个子系统:人员信息管理系统,门诊信息管理系统,收费信息管理系统。
2.1系统功能简介
2. 1. 1 人员信息管理系统功能
对医生、病人、药物基本信息进行增长,删除,修改,查询等基本功能
2. 1. 2 门诊信息管理系统功能
对就诊信息存储功能和对处方信息进行增长、删除、修改药物等基本功能
3. 2. 3 收费信息管理系统
对医疗费用进行总和计算功能和对药物库存进行修改功能
2.2功能模块
系统重要功能模块图如下:
医院综合信息管理系统
人员信息管理系统
门诊信息管理系统
收费信息管理系统
医生信息管理
病人信息管理
药物信息管理
就诊信息管理
病人处方管理
收费信息管理
药物库存管理
三、数据库设计:
3.1 E-R图:
3.1.1医生信息doctor E-R图
name
sex
age
employno
phone
doctor
3.1.2病人信息patient E-R图
name
sex
age
patientno
no
phone
patient
3.1.3药物信息drug E-R图
drug
drugno
no
name
no
price
no
inventory
no
3.1.4诊断信息diagnosis E-R图
diagnosis
diagnosisno
no
no
employno
no
patientno
no
condition
no
3.1.5处方信息prescription E-R图
prescription
prescription
no
no
no
patientno
no
name
no
time
no
account
3.1.6实体间重要关系E-R图
Doctor
Paitient
Durg
Diagnosis
Prescription
N
1
1
1
1
1
1
1
3.2数据字典:
表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("编号不能为空”));
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_pRecordset->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",(_bstr_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(...)
{
MessageBox(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 tempSql;
tempSql.Format(CString("UPDATE`mydb`.`doctor`SET `name`='%s',`sex`='%s',`age`='%s',`native`='%s',`nation`='%s',`office`='%s',`position`='%s',`idcard`='%s',`phone`='%s'WHERE `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();
MessageBox(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("delete 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 str;
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("select* 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)->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(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);// 遍历功能信息记录
}
}
5.诊断界面:
6.处方界面:
7.处方查询:
8.付款界面:
9.修改库存:
对比图:
付款前:
付款后:
六、总结:
通过这次数据库大作业,咱们熟悉了vs数据库ADO编程。对于它添加,修改,删除环节均有了较大理解。在本次作业当中遇到两大问题。一是:数据库连接问题,本来开始准备用access做后台,可是不懂得为什么我电脑始终连接不上,于是改用了MYAQL连接。二是:在是使用记录集指针问题_RecordsetPtr m_pRecordset,在实现添加,删除,修改,查询等操作时,只能执行一次就浮现指针无效成果。最后发现是在连接数据库时没有初始化COM,因此导致有指针无效成果。然后,最让我开心是,是实现总价计算。我是用两个数组,amount[20],和price[20]记住数量和单价,运用for循环计算总价。然后,就是在 vs中字符之间转换也是咱们应当注意问题。
总之,这次实验,让咱们学到了许多课本上学不到知识,也锻炼了咱们思考问题,解决问题能力。
附录:医院综合信息管理系统源代码
// ADOConn.cpp :实现文献
//
#include "stdafx.h"
#include "hospital.h"
#include "ADOConn.h"
// CADOConn
CADOConn::CADOConn()
{
}
CADOConn::~CADOConn()
{
}
// CADOConn 成员函数
bool CADOConn::OnInitADOConn(void)
{
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_pDBConnection->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_pDBConnection->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(_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,NULL,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_pRecordset=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 "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;
}
CPrescriptionDlg::~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);
}
BEGIN_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(IDC_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 属性页应返回 FALSE
}
void 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)
{
m_grid.InsertItem(0,CString(""));
m_grid.SetItemText(0,0,(CString)(char*)(_bstr_t)m_pRecordset->GetCollect("prescriptionno"));
m_grid.SetItemText(0,1,(CString)(char*)(_bstr_t)m_pRecordset->GetCollect("patientno"));
m_grid.SetItemText(0,2,(CString)(char*)(_bstr_t)m_pRecordset->GetCollect("name"));
m_grid.SetItemText(0,3,(CString)(char*)(_bstr_t)m_pRecordset->GetCollect("amount"));
m_grid.SetItemText(0,4,(CString)(char*)(_bstr_t)m_pRecordset->GetCollect("time"));
m_pRecordset->MoveNext();
}
m_AdoConn.ExitConnect();
UpdateData(true);
}
void CPrescriptionDlg::OnBnClickedOk()
{
// TODO:在此添加控件告知解决程序代码
//CDialogEx::OnOK();
m_no=1;
if(flag==0)
{
m_grid.SetExtendedStyle(LVS_EX_FLATSB
|LVS_EX_FULLROWSELECT
|LVS_EX_HEADERDRAGDROP
|LVS_EX_ONECLICKACTIVATE
|LVS_EX_GRIDLINES);
m_grid.InsertColumn(0,CString("处方编号"),LVCFMT_LEFT,100,0);
m_grid.InsertColumn(1,CString("病人编号"),LVCFMT_LEFT,100,1);
m_grid.InsertColumn(2,CString("药物名称"),LVCFMT_LEFT,100,2);
m_grid.InsertColumn(3,CString("使用数量"),LVCFMT_LEFT,100,3);
m_grid.InsertColumn(4,CString("用药时间"),LVCFMT_LEFT,100,4);
flag= !flag;
//自动编号
CADOConn m_AdoConn;
m_AdoConn.OnInitADOConn();
_bstr_t sql;
sql = "select prescriptionno from prescription";
_RecordsetPtr m_pRecordset;
m_pRecordset = m_AdoConn.GetRecordSet((_bstr_t)sql);
while(m_AdoConn.m_pRecordset->adoEOF==0)
{
if(m_no<(int)_ttoi((CString)(char*)(_bstr_t)m_pRecordset->GetCollect("prescriptionno")))
m_no=(int)_ttoi((CString)(char*)(_bstr_t)m_pRecordset->GetCollect("prescriptionno"));
m_pRecordset->MoveNext();
}
m_AdoConn.ExitConnect();
m_no++;
CString str,str1;
GetDlgItem(IDC_PATIENTNO)->GetWindowText(str1);
str=CString("select* from prescription where patientno like ")+CString("'")+str1+CString("'");
AddToGrid(str);// 遍历员工信息记录
}
UpdateData(true);
if(m_patientno.IsEmpty())
{
MessageBox(CString("病人编号不能为空!"));
return;
}
if(m_name.IsEmpty())
{
MessageBox(CString("名称不能为空!"));
return;
}
CADOConn m_AdoConn;
m_AdoConn.OnInitADOConn();
_bstr_t sql;
sql = "select * from prescription";
_RecordsetPtr m_pRecordset;
m_pRecordset=m_AdoConn.GetRecordSet(sql);
//获取工作时间
CTime time;
m_time.GetTime(time);
COleDateTime convert_time;
convert_time.SetDate(time.GetYear(),time.GetMonth(),time.GetDay());
try
{
m_pRecordset->AddNew();//添加新行
m_pRecordset->PutCollect("patientno",(_bstr_t)m_patientno);
m_pRecordset->PutCollect("name",(_bstr_t)m_name);
m_pRecordset->PutCollect("amount",(_bstr_t)m_amount);
m_pRecordset->PutCollect("time",(_variant_t)convert_time);
m_pRecordset->PutCollect("prescriptionno",(_bstr_t)m_no);
m_pRecordset->Update();//更新数据库
m_AdoConn.ExitConnect();//断开数据库连接
}
catch(...)
{
MessageBox(CString("操作失败"));
return;
}
MessageBox(CString("保存成功."));
m_grid.DeleteAllItems();//删除grid中本来数据
CString str,str1;
GetDlgItem(IDC_PATIENTNO)->GetWindowText(str1);
str=CString("select* from prescription where patientno like ")+CString("'")+str1+CString("'");
AddToGrid(str);// 遍历员工信息记录
}
void CPrescriptionDlg::OnBnClickedChange()
{
// TODO:在此添加控件告知解决程序代码
UpdateData(true);
CADOConn m_AdoConn;
m_AdoConn.OnInitADOConn();//创立连接
CString tempSql; //删除字符类型为CString
CString sextemp;
//获取用药时间
CTime time;
m_time.GetTime(time);
COleDateTime convert_time;
convert_time.SetDate(time.GetYear(),time.GetMonth(),time.GetDay());
CString timetemp = convert_time.Format();
tempSql.Format(CString("update mydb.prescription set name='%s',amount='%s',time='%s' where name = '%s'"),m_patientno,m_amount,timetemp,m_name);
m_AdoConn.ExecuteSQL((_bstr_t)tempSql);
m_AdoConn.ExitConnect();
MessageBox(CString("修改成功."));
m_grid.DeleteAllItems();//
展开阅读全文