基于RFID,QT,MYSQL开发的医疗电子病历系统

没事做,跟着模版随便做了一个电子病历系统,功能很简陋,界面也不太好看,各位大神看到别见怪啊~

功能包括有通过RFID读写器读取S50卡中的卡号把病人详细信息存入数据库、通过RFID读写器读取S50卡把病人的详细信息从数据库中进行读取并显示到QT程序界面上、在QT程序中进行病人信息的查询,包括修改与删除、计费功能(通过读取卡号,可进行对账户的充值与扣费)

随着物联网技术的成熟,物联网可以应用到各方各面,无论家居,农业,医疗等等都可以利用到物联网技术。而物联网技术的核心技术有:应用技术、网络技术和感知技术。我们所设计的系统正正利用了物联网的核心技术:感知技术中的RFID。在以前,病人去医院看病必须带上病历,而纸质不易保存,易潮,易脏。于是我们设计的电子病历既解决了纸质病历的问题,更加在此中增加了结算和电子钱包的功能。

电子病历是高质量,更快捷,更方便的医疗系统,电子病历不仅可以用于病人的随身携带,而且只需要带一张不到20克的卡,就可以不带钱去看医生。电子病历系统更加合理化,信息化,对医院也便于统计和整理病人数据。所以电子病历对医院和病人都有着莫大的好处,电子病历在当今社会是发展趋势。

1.  用户:

(1)       随身携带:轻便,简单。

(2)       电子钱包:预存费用,方便结算。

2.  医生:

(1)       过往病史:方便医生对症下药,对过往病史、过敏病史清楚了解。

(2)       记录病历:写入数据库,节约资源。

3.  管理员:

(1)       用户管理:用户的增加,删除,修改,查询。

(2)       余额管理:用户余额的增加与减少。

管理员登陆相关代码:

dialog.h

#ifndef DIALOG_H

#define DIALOG_H

#include <QDialog>

namespace Ui {

class Dialog;

}

class Dialog : public QDialog

{

Q_OBJECT

public:

explicit Dialog(QWidget *parent = 0);

~Dialog();

private slots:

void on_login_clicked();

void on_cancel_clicked();

private:

Ui::Dialog *ui;

};

#endif // DIALOG_H

dialog.cpp

#include "dialog.h"

#include "ui_dialog.h"

#include"QMessageBox"

#include"mainwindow.h"

Dialog::Dialog(QWidget *parent) :

QDialog(parent),

ui(new Ui::Dialog)

{

ui->setupUi(this);

}

Dialog::~Dialog()

{

delete ui;

}

void Dialog::on_login_clicked()

{

if(ui->username->text().trimmed()=="admin" && ui->password->text().trimmed()=="admin")

{

MainWindow *m=new MainWindow;

m->show();

this->hide();

}

else

{

QMessageBox::critical(this,"error",tr("用户名或密码出错!"));

}

}

void Dialog::on_cancel_clicked()

{

this->close();

}

RFID读卡界面相关代码:

reader.h

#ifndef    READER_H

#define READER_H

//#include "function.h"

#include <QLibrary>

#include <QDebug>

#include "function.h"

class Reader

{

public:

Reader(QWidget *parent);

~Reader();

bool LoadDll();

bool CloseDll();

MF_Read_Func MF_Read;

MF_Write_Func MF_Write;

MF_InitValue_Func MF_InitValue;

MF_Dec_Func MF_Dec;

MF_Inc_Func MF_Inc;

MF_Halt_Func MF_Halt;

MF_Getsnr_Func MF_Getsnr;

ControlBuzzer_Func ControlBuzzer;

ControlLED_Func ControlLED;

GetVersionNum_Func GetVersionNum;

SetSerNum_Func SetSerNum;

GetSerNum_Func GetSerNum;

TypeB_Request_Func TypeB_Request;

TYPEB_SFZSNR_Func TYPEB_SFZSNR;

TypeB_TransCOS_Func TypeB_TransCOS;

UL_Request_Func UL_Request;

UL_HLRead_Func UL_HLRead;

UL_HLWrite_Func UL_HLWrite;

ISO15693_Inventory_Func ISO15693_Inventory;

ISO15693_Read_Func ISO15693_Read;

ISO15693_Write_Func ISO15693_Write;

ISO15693_GetSysInfo_Func ISO15693_GetSysInfo;

ISO15693_Lock_Func ISO15693_Lock;

ISO15693_Select_Func ISO15693_Select;

ISO15693_WriteAFI_Func ISO15693_WriteAFI;

ISO15693_LockAFI_Func ISO15693_LockAFI;

ISO15693_WriteDSFID_Func ISO15693_WriteDSFID;

ISO15693_LockDSFID_Func ISO15693_LockDSFID;

ISO15693_GetMulSecurity_Func ISO15693_GetMulSecurity;

private:

QLibrary *functionLib;

int DeviceAddress;

};

#endif

reader.cpp

#include "reader.h"

#include<QMessageBox>

Reader::Reader(QWidget *parent)

{

DeviceAddress = 0;

functionLib = new QLibrary("function.dll");

if (!LoadDll())

{

QMessageBox::critical(parent,"Error",QString::fromLocal8Bit("???function.dll???"));

}

}

Reader::~Reader()

{

CloseDll();

}

bool Reader::LoadDll()

{

if ( !functionLib->load() )

{

qDebug()<<"Failed to load function.dll";

return false;

}

qDebug()<<"Succeed to load function.dll";

MF_Read        = (MF_Read_Func)functionLib->resolve("MF_Read");

MF_Write       = (MF_Write_Func)functionLib->resolve("MF_Write");

MF_InitValue   = (MF_InitValue_Func)functionLib->resolve("MF_InitValue");

MF_Dec         = (MF_Dec_Func)functionLib->resolve("MF_Dec");

MF_Inc         = (MF_Inc_Func)functionLib->resolve("MF_Inc");

MF_Halt        = (MF_Halt_Func)functionLib->resolve("MF_Halt");

MF_Getsnr      = (MF_Getsnr_Func)functionLib->resolve("MF_Getsnr");

ControlLED           = (ControlLED_Func)functionLib->resolve("ControlLED");

ControlBuzzer        = (ControlBuzzer_Func)functionLib->resolve("ControlBuzzer");

GetVersionNum        = (GetVersionNum_Func)functionLib->resolve("GetVersionNum");

SetSerNum            = (SetSerNum_Func)functionLib->resolve("SetSerNum");

GetSerNum            = (GetSerNum_Func)functionLib->resolve("GetSerNum");

TypeB_Request        = (TypeB_Request_Func)functionLib->resolve("TypeB_Request");

TYPEB_SFZSNR         = (TYPEB_SFZSNR_Func)functionLib->resolve("TYPEB_SFZSNR");

TypeB_TransCOS          = (TypeB_TransCOS_Func)functionLib->resolve("TypeB_TransCOS");

ISO15693_Inventory            = (ISO15693_Inventory_Func)functionLib->resolve("ISO15693_Inventory");

ISO15693_Read                   = (ISO15693_Read_Func)functionLib->resolve("ISO15693_Read");

ISO15693_Write                  = (ISO15693_Write_Func)functionLib->resolve("ISO15693_Write");

ISO15693_GetSysInfo   = (ISO15693_GetSysInfo_Func)functionLib->resolve("ISO15693_GetSysInfo");

ISO15693_Lock                   = (ISO15693_Lock_Func)functionLib->resolve("ISO15693_Lock");

ISO15693_Select                 = (ISO15693_Select_Func)functionLib->resolve("ISO15693_Select");

ISO15693_WriteAFI            = (ISO15693_WriteAFI_Func)functionLib->resolve("ISO15693_WriteAFI");

ISO15693_LockAFI             = (ISO15693_LockAFI_Func)functionLib->resolve("ISO15693_LockAFI");

ISO15693_WriteDSFID = (ISO15693_WriteDSFID_Func)functionLib->resolve("ISO15693_WriteDSFID");

ISO15693_LockDSFID  = (ISO15693_LockDSFID_Func)functionLib->resolve("ISO15693_LockDSFID");

ISO15693_GetMulSecurity=(ISO15693_GetMulSecurity_Func)functionLib->resolve("ISO15693_GetMulSecurity");

UL_Request           = (UL_Request_Func)functionLib->resolve("UL_Request");

UL_HLRead            = (UL_HLRead_Func)functionLib->resolve("UL_HLRead");

UL_HLWrite           = (UL_HLWrite_Func)functionLib->resolve("UL_HLWrite");

if(//14443A

MF_Read        == NULL       ||

MF_Write            == NULL       ||

MF_InitValue       == NULL       ||

MF_Dec              == NULL       ||

MF_Inc               == NULL       ||

MF_Getsnr          == NULL       ||

MF_Halt             == NULL       ||

SetSerNum            == NULL       ||

GetSerNum           == NULL       ||

ControlLED           == NULL       ||

ControlBuzzer        == NULL       ||

GetVersionNum      == NULL       ||

TypeB_Request      == NULL       ||

TYPEB_SFZSNR   == NULL       ||

TypeB_TransCOS   == NULL       ||

ISO15693_Inventory     == NULL ||

ISO15693_Read            == NULL||

ISO15693_Write           == NULL ||

ISO15693_GetSysInfo == NULL ||

ISO15693_Lock            == NULL ||

ISO15693_Select          == NULL ||

ISO15693_WriteAFI     == NULL ||

ISO15693_LockAFI      == NULL ||

ISO15693_WriteDSFID == NULL ||

ISO15693_LockDSFID  == NULL ||

UL_Request                 == NULL  ||

UL_HLRead                 == NULL  ||

UL_HLWrite                 == NULL)

{

qDebug()<<"Failed to resolve function";

return false;

}

qDebug()<<"Succeed to resolve function";

return true;

}

bool Reader::CloseDll()

{

if(functionLib)

{

functionLib->unload();

return true;

}

return false;

}

showsick.h

#ifndef SHOWALLSICK_H

#define SHOWALLSICK_H

#include <QDialog>

#include <QtSql>

namespace Ui {

class ShowAllSick;

}

class ShowAllSick : public QDialog

{

Q_OBJECT

public:

explicit ShowAllSick(QWidget *parent = 0);

~ShowAllSick();

void connectMySql();

private slots:

void on_delete_2_clicked();

void on_update_clicked();

void on_insert_clicked();

void gettotalrecords();

void showdata();

void on_select_clicked();

void on_first_clicked();

void on_next_clicked();

void on_pre_clicked();

void on_last_clicked();

void on_go_clicked();

private:

Ui::ShowAllSick *ui;

QSqlTableModel *tablemodel;

int page;

int records;

int totalrecords;

int totalpages;};

#endif // SHOWALLSICK_H

showsick.cpp

#include "showsick.h"

#include "ui_showsick.h"

#include<QMessageBox>

showsick::showsick(QWidget *parent) :

QDialog(parent),

ui(new Ui::showsick)

{

ui->setupUi(this);

//timer read rfid

timer=new QTimer;

connect(timer,SIGNAL(timeout()),this,SLOT(readcardid()));

//rfid

cardReader = new Reader(this);

//mysql

connectMySql();

}

showsick::~ showsick ()

{

delete ui;

}

void showsick::on_read_clicked()

{

if(ui->id->text()=="")

{

timer->start(1000);

ui->read->setEnabled(false);

}

QSqlQuery query;

query.prepare("select no,sex,intro intro,image from tbl_sick where id=?");

query.addBindValue(ui->id->text());

query.exec();

if(query.next())

{

ui->no->setText(query.value(0).toString());

ui->sex->setText(query.value(1).toString());

ui->intro->setText(query.value(2).toString());

QPixmap photo;

photo.loadFromData(query.value(3).toByteArray());

ui->img->setPixmap(photo.scaled(ui->img->size()));

}}

void showsick::on_stop_clicked()

{

timer->stop();

ui->read->setEnabled(true);

}

//读取卡号

void showsick::readcardid()

{

unsigned int cardid;

unsigned char snr[7];

unsigned char mode =00;

int result = cardReader->UL_Request(mode, snr);

if(result==0)

{

cardid= (snr[0]<<24) |(snr[1]<<16) | (snr[2]<<8) | (snr[3]);

//根据读出的卡号查询数据

showdata(cardid);    }}

//rfid beer

void showsick::beer()

{

int freq =20;

int duration = 1;

unsigned char buffer;

int result = cardReader->ControlBuzzer(freq, duration, &buffer);}

//mysql

void showsick::connectMySql()

{

QSqlDatabase db =QSqlDatabase::addDatabase("QMYSQL"); // becomes the new default connection

db.setUserName("root");//用户名

db.setPassword("root");//密码

db.setHostName("172.16.170.47");

db.setDatabaseName("book");//数据库名

db.setConnectOptions("CLIENT_SSL=1;CLIENT_IGNORE_SPACE=1");//使用SSL

db.setPort(3306);//端口

if(db.open())

{

QMessageBox::information(this,"open","OK!");

}

else

{

QMessageBox::information(this,"open","False");

}

}

//mysql

void showsick::showdata(unsigned int cardid)

{

//根据读出的卡号查询数据

QSqlQuery query;

query.prepare("SELECT id,no,sex,intro,image FROM tbl_sick WHERE rfidno = ?");

query.addBindValue(QString::number(cardid,16));

query.exec();

while (query.next())

{

if (query.isNull(0) == false)

{

//显示病人数据

ui->id->setText(query.value(0).toString());//身份证

ui->no->setText(query.value(1).toString());//姓名

ui->intro->setText(query.value(2).toString());//病症

ui->sex->setText(query.value(3).toString());//性别

//显示病人头像

QPixmap photo;

photo.loadFromData(query.value(3).toByteArray());

ui->img->setPixmap(photo.scaled(ui->img->size()));

qDebug()<<"Query success";

beer();         }

else

{

qDebug()<<"Query failed";

}     }}

显示全部病人信息界面:

showallsick.h

#ifndef SHOWALLSICK_H

#define SHOWALLSICK_H

#include <QDialog>

//mysql

#include <QtSql>

namespace Ui {

class ShowAllSick;}

class ShowAllSick : public QDialog

{

Q_OBJECT

public:

explicit ShowAllSick(QWidget *parent = 0);

~ShowAllSick();

void connectMySql();

private slots:

void on_delete_2_clicked();

void on_update_clicked();

void on_insert_clicked();

void gettotalrecords();

void showdata();

void on_select_clicked();

void on_first_clicked();

void on_next_clicked();

void on_pre_clicked();

void on_last_clicked();

void on_go_clicked();

private:

Ui::ShowAllSick *ui;

QSqlTableModel *tablemodel;

int page;

int records;

int totalrecords;

int totalpages;};

#endif // SHOWALLSICK_H

showallsick.cpp

#include "showallsick.h"

#include "ui_showallsick.h"

#include"sickinfo.h"

#include"updatesickinfo.h"

#include<QMessageBox>

QString globaldata;

ShowAllSick::ShowAllSick(QWidget *parent) :

QDialog(parent),

ui(new Ui::ShowAllSick)

{

ui->setupUi(this);

ui->tableView->horizontalHeader()->setResizeMode(QHeaderView::Stretch);

connectMySql();

tablemodel=new QSqlTableModel(this);

tablemodel->setTable("tbl_sick");

tablemodel->setEditStrategy(QSqlTableModel::OnFieldChange);

tablemodel->select();

tablemodel->removeColumn(8);

tablemodel->setHeaderData(0,Qt::Horizontal,QObject::tr("卡号"));

tablemodel->setHeaderData(1,Qt::Horizontal,QObject::tr("姓名"));

tablemodel->setHeaderData(2,Qt::Horizontal,QObject::tr("身份证号"));

tablemodel->setHeaderData(3,Qt::Horizontal,QObject::tr("性别"));

tablemodel->setHeaderData(4,Qt::Horizontal,QObject::tr("出生日期"));

tablemodel->setHeaderData(5,Qt::Horizontal,QObject::tr("病症"));

tablemodel->setHeaderData(6,Qt::Horizontal,QObject::tr("照片"));

tablemodel->setHeaderData(7,Qt::Horizontal,QObject::tr("余额"));

ui->tableView->setModel(tablemodel);}

ShowAllSick::~ShowAllSick()

{

delete ui;

}

//mysql

void ShowAllSick::connectMySql()

{

QSqlDatabase db =QSqlDatabase::addDatabase("QMYSQL"); // becomes the new default connection

db.setUserName("root");//用户名

db.setPassword("root");//密码

db.setHostName("172.16.170.47");

db.setDatabaseName("book");//数据库名

db.setConnectOptions("CLIENT_SSL=1;CLIENT_IGNORE_SPACE=1");//使用SSL

db.setPort(3306);//端口

if(!db.open())

{

QMessageBox::information(this,"open","False");

}}

void ShowAllSick::on_delete_2_clicked()

{

QItemSelectionModel *selections = ui->tableView->selectionModel();

QModelIndexList selected = selections->selectedIndexes();

QSqlQuery query;

int ok = QMessageBox::warning(this,QObject::tr("删除当前行!"),QObject::tr("确定删除当前行?"),

QMessageBox::Yes,QMessageBox::No);

if(ok==QMessageBox::Yes)

{

foreach (QModelIndex index, selected)

{

QString no=index.sibling(index.row(),0).data().toString();

query.prepare("delete from tbl_sick where rfidno =?");

query.addBindValue(no);

query.exec();        }

tablemodel->select();

}}

void ShowAllSick::on_update_clicked()

{

int curRow = ui->tableView->currentIndex().row();

QModelIndex index = ui->tableView->currentIndex();

globaldata=index.sibling(curRow,2).data().toString();

UpdateSickInfo *updatesickinfo=new UpdateSickInfo;

updatesickinfo->show();}

void ShowAllSick::on_insert_clicked()

{

SickInfo *sickinfo=new SickInfo;

sickinfo->show();

sickinfo->resize(600,450);

}

void ShowAllSick::on_select_clicked(){

QString id=ui->id->text().trimmed();

if(id!="")    {

tablemodel->setFilter(QString("id=%1").arg(id));

tablemodel->select();

}else{

tablemodel->setTable("tbl_sick");

tablemodel->select();

}}

void ShowAllSick::gettotalrecords()

{

QSqlQuery query;

query.clear();

query.exec("select count(*) from tbl_sick");

query.next();

totalrecords=query.value(0).toInt();

records=ui->record->text().toInt();

totalpages=(totalrecords%records)?(totalrecords/records)+1:(totalrecords/records);

ui->totalpage->setText("totalpage:"+QString::number(totalpages));}

void ShowAllSick::showdata()

{

QString strFilter = QString("1=1 LIMIT %1,%2;").arg(0).arg(records);

tablemodel->setFilter(strFilter);

tablemodel->select();

ui->tableView->setModel(tablemodel);

}

void ShowAllSick::on_first_clicked()

{

showdata();

ui->page->setText("1");}

void ShowAllSick::on_next_clicked()

{

page=ui->page->text().trimmed().toInt();

records=ui->record->text().trimmed().toInt();

if(page<totalpages)

{

QString strFilter = QString("1=1 LIMIT %1,%2;").arg(page*records).arg(records);

tablemodel->setFilter(strFilter);

tablemodel->select();

ui->tableView->setModel(tablemodel);

ui->page->setText(QString::number(page+1));

}}

void ShowAllSick::on_pre_clicked()

{

page=ui->page->text().trimmed().toInt();

records=ui->record->text().trimmed().toInt();

if(page>1)    {

QString strFilter = QString("1=1 LIMIT %1,%2;").arg((page-2)*records).arg(records);

tablemodel->setFilter(strFilter);

tablemodel->select();

ui->tableView->setModel(tablemodel);

ui->page->setText(QString::number(page-1));

}}

void ShowAllSick::on_last_clicked(){

records=ui->record->text().trimmed().toInt();

int lastpages=(totalrecords%records)?(totalrecords/records):(totalrecords/records)-1;

QString strFilter=QString("1=1 LIMIT %1,%2").arg((lastpages)*records).arg(records);

tablemodel->setFilter(strFilter);

tablemodel->select();

ui->tableView->setModel(tablemodel);

ui->page->setText(QString::number(lastpages+1));}

void ShowAllSick::on_go_clicked(){

page=ui->page->text().trimmed().toInt();

records=ui->record->text().trimmed().toInt();

totalpages=(totalrecords%records)?(totalrecords/records)+1:(totalrecords/records);

if(page<=totalpages)    {

QString strFilter=QString("1=1 LIMIT %1,%2").arg((page-1)*records).arg(records);

tablemodel->setFilter(strFilter);

tablemodel->select();

ui->tableView->setModel(tablemodel);

}else{

QString strFilter=QString("1=1 LIMIT %1,%2;").arg(0).arg(records);

tablemodel->setFilter(strFilter);

tablemodel->select();

ui->tableView->setModel(tablemodel);

ui->page->setText("1");    }

ui->totalpage->setText(tr("totalpage:")+QString::number(totalpages));}

增加用户数据:

sickinfo.c

#ifndef SICKINFO_H

#define SICKINFO_H

#include <QDialog>

//rfid

#include"reader.h"

//mysql

#include <QtSql>

namespace Ui {

class SickInfo;}

class SickInfo : public QDialog{

Q_OBJECT

public:

explicit SickInfo(QWidget *parent = 0);

~SickInfo();

//rfid

void beer();

//mysql

void connectMySql();

private slots:

void on_ok_clicked();

void on_openimage_clicked();

void on_readcard_clicked();

private:

Ui::SickInfo *ui;

QString fileName;

//rfid

Reader *cardReader;

//mysql

QSqlDatabase db;

};

sickinfo.cpp

#endif // SICKINFO_H

#include "sickinfo.h"

#include "ui_sickinfo.h"

#include<QMessageBox>

#include<QFileDialog>

SickInfo::SickInfo(QWidget *parent) :

QDialog(parent),

ui(new Ui::SickInfo){

ui->setupUi(this);

//rfid

cardReader = new Reader(this);

//mysql

connectMySql();}

SickInfo::~SickInfo()

{

delete ui;

}

//mysql的save

void SickInfo::on_ok_clicked()

{

QString s="";

s.append(ui->rfidno->text()+"\n");

s.append(ui->no->text()+"\n");

s.append(ui->id->text()+"\n");

s.append(fileName+"\n");

s.append(ui->sex->checkedButton()->text()+"\n");

s.append(ui->birthday->text()+"\n");

s.append(ui->textEdit->toPlainText());

QMessageBox::information(this,tr("infromation"),tr("%1").arg(s));    //读取数据

QString rfidno=ui->rfidno->text().trimmed();

QString no=ui->no->text().trimmed();

QString id=ui->id->text().trimmed();

QString sex=ui->sex->checkedButton()->text().trimmed();

QString birthday=ui->birthday->text();

QString intro=ui->textEdit->toPlainText();

//读取图片数据为二进制数据

QByteArray bytes;

QBuffer buffer(&bytes);

buffer.open(QIODevice::WriteOnly);

ui->img->pixmap()->save(&buffer, "PNG");

QByteArray data;

QFile* file=new QFile(fileName);

file->open(QIODevice::ReadOnly);

data = file->readAll();

file->close();

QVariant var(data);

//mysql的insert操作

QSqlQuery query;

bool value;

query.prepare("insert into tbl_sick(rfidno,no,id,sex,intro,birthday,image) values(?,?,?,?,?,?,?)");

query.addBindValue(rfidno);

query.addBindValue(no);

query.addBindValue(id);

query.addBindValue(sex);

query.addBindValue(intro);

query.addBindValue(birthday);

query.addBindValue(var);

value=query.exec();

if(value)      {

QMessageBox::information(this,"adduser","Add user successed!");

}

else

{

QMessageBox::information(this,"adduser","Add user failed!");

}}

void SickInfo::on_openimage_clicked()

{

fileName = QFileDialog::getOpenFileName(this,

tr("Open File"), QDir::currentPath());

if (!fileName.isEmpty())

{

QMessageBox::information(this, tr("Image Viewer"),

tr("path: %1.").arg(fileName));

QImage image(fileName);

if (image.isNull())

{

QMessageBox::information(this, tr("Image Viewer"),

tr("Cannot load %1.").arg(fileName));

return;

}

//ui->img->setPixmap(QPixmap::fromImage(image));

ui->img->setPixmap(QPixmap(fileName).scaled(ui->img->size()));        }}

//rfid

void SickInfo::on_readcard_clicked()

{

unsigned int cardid;

unsigned char snr[7];

unsigned char mode =00;

int result = cardReader->UL_Request(mode, snr);

if(result==0)

{

cardid= (snr[0]<<24) |(snr[1]<<16) | (snr[2]<<8) | (snr[3]);

ui->rfidno->setText(QString::number(cardid,16));

beer();    }}

//rfid

void SickInfo::beer()

{

int freq =20;

int duration = 1;

unsigned char buffer;

int result = cardReader->ControlBuzzer(freq, duration, &buffer);

}//mysql

void SickInfo::connectMySql(){

QSqlDatabase db =QSqlDatabase::addDatabase("QMYSQL"); // becomes the new default connection

db.setUserName("root");//用户名

db.setPassword("root");//密码

db.setHostName("172.16.170.47");

db.setDatabaseName("book");//数据库名

db.setConnectOptions("CLIENT_SSL=1;CLIENT_IGNORE_SPACE=1");//使用SSL

db.setPort(3306);//端口

if(db.open())    {

QMessageBox::information(this,"open","OK!");

}

else

{

QMessageBox::information(this,"open","False");

}}

更新病人资料:

updatesickinfo.c

#ifndef UPDATESICKINFO_H

#define UPDATESICKINFO_H

#include <QDialog>

//rfid

#include"reader.h"

//mysql

#include <QtSql>

namespace Ui {

class UpdateSickInfo;

}

class UpdateSickInfo : public QDialog

{

Q_OBJECT

public:

explicit UpdateSickInfo(QWidget *parent = 0);

~UpdateSickInfo();

void connectMySql();

void beer();

private slots:

void on_openimage_clicked();

void on_readcard_clicked();

void on_ok_clicked();

private:

Ui::UpdateSickInfo *ui;

QString fileName;    //rfid

Reader *cardReader;

};

#endif // UPDATESICKINFO_H

updatesickinfo.cpp

#include "updatesickinfo.h"

#include "ui_updatesickinfo.h"

#include<QDebug>

#include<QMessageBox>

#include<QFileDialog>

extern QString globaldata;

UpdateSickInfo::UpdateSickInfo(QWidget *parent) :

QDialog(parent),

ui(new Ui::UpdateSickInfo)

{

ui->setupUi(this);

//rfid

cardReader = new Reader(this);

//mysql读数据

QSqlQuery query;

query.prepare("select * from tbl_sick where id=?");

query.addBindValue(globaldata);

if(query.exec())    {

query.next();

ui->rfidno->setText(query.value(0).toString());

ui->no->setText(query.value(1).toString());

ui->id->setText(query.value(2).toString());

ui->birthday->setDateTime(query.value(4).toDateTime());

ui->textEdit->setText(query.value(5).toString());        //显示学生头像

QPixmap photo;

photo.loadFromData(query.value(6).toByteArray());

ui->img->setPixmap(photo.scaled(ui->img->size()));  }}

UpdateSickInfo::~UpdateSickInfo()

{

delete ui;

}

//mysql的save

void UpdateSickInfo::on_ok_clicked()

{

QString s="";

s.append(ui->rfidno->text()+"\n");

s.append(ui->no->text()+"\n");

s.append(ui->id->text()+"\n");

s.append(fileName+"\n");

s.append(ui->sex->checkedButton()->text()+"\n");

s.append(ui->birthday->text()+"\n");

s.append(ui->textEdit->toPlainText());

QMessageBox::information(this,tr("infromation"),tr("%1").arg(s));

//读取数据

QString rfidno=ui->rfidno->text().trimmed();

QString no=ui->no->text().trimmed();

QString id=ui->id->text().trimmed();

QString sex=ui->sex->checkedButton()->text().trimmed();

QString birthday=ui->birthday->text();

QString intro=ui->textEdit->toPlainText();

//读取图片数据为二进制数据

QByteArray bytes;

QBuffer buffer(&bytes);

buffer.open(QIODevice::WriteOnly);

ui->img->pixmap()->save(&buffer, "PNG");

QByteArray data;

QFile* file=new QFile(fileName);

file->open(QIODevice::ReadOnly);

data = file->readAll();

file->close();

QVariant var(data);

//mysql的insert操作

QSqlQuery query;

bool value;

query.prepare("update tbl_sick set rfidno=?,no=?,sex=?,birthday=?,intro=?,image=? where id=?");

query.addBindValue(rfidno);

query.addBindValue(no);

query.addBindValue(sex);

query.addBindValue(birthday);

query.addBindValue(intro);

query.addBindValue(var);

query.addBindValue(id);

value=query.exec();

if(value)    {

QMessageBox::information(this,"adduser","update user successed!");

}else{

QMessageBox::information(this,"adduser","update user failed!");

}}

void UpdateSickInfo::on_openimage_clicked()

{

fileName = QFileDialog::getOpenFileName(this,

tr("Open File"), QDir::currentPath());

if (!fileName.isEmpty())

{

QMessageBox::information(this, tr("Image Viewer"),

tr("path: %1.").arg(fileName));

QImage image(fileName);

if (image.isNull())

{

QMessageBox::information(this, tr("Image Viewer"),

tr("Cannot load %1.").arg(fileName));

return;

}

//ui->img->setPixmap(QPixmap::fromImage(image));

ui->img->setPixmap(QPixmap(fileName).scaled(ui->img->size()));        }}

//rfid

void UpdateSickInfo::on_readcard_clicked()

{

unsigned int cardid;

unsigned char snr[7];

unsigned char mode =00;

int result = cardReader->UL_Request(mode, snr);

if(result==0)    {

cardid= (snr[0]<<24) |(snr[1]<<16) | (snr[2]<<8) | (snr[3]);

ui->rfidno->setText(QString::number(cardid,16));

beer();

}}

//rfid

void UpdateSickInfo::beer()

{

int freq =20;

int duration = 1;

unsigned char buffer;

int result = cardReader->ControlBuzzer(freq, duration, &buffer);}

//mysql

void UpdateSickInfo::connectMySql()

{

QSqlDatabase db =QSqlDatabase::addDatabase("QMYSQL"); // becomes the new default connection

db.setUserName("root");//用户名

db.setPassword("root");//密码

db.setHostName("172.16.170.47");

db.setDatabaseName("book");//数据库名

db.setConnectOptions("CLIENT_SSL=1;CLIENT_IGNORE_SPACE=1");//使用SSL

db.setPort(3306);//端口

if(!db.open())    {

QMessageBox::information(this,"open","False");    }

}

1)        管理者登录页面:

2)        系统首界面:

3)        增加用户资料界面:

4)        RFID读取用户资料界面:

5)        操作全部用户资料界面:

6)        用户充值扣费界面:

时间: 2024-12-11 16:26:06

基于RFID,QT,MYSQL开发的医疗电子病历系统的相关文章

.NET 开发电子病历系统(EMR)

医疗行业信息化特点 随着信息技术的发展,以互联网为依托的健康教育.医疗信息查询.电子健康档案.电子处方.等多种形式的医疗健康服务悄然改变着传统医疗服务模式.病历是病人在医院诊断治疗全过程的原始记录,它包含有首页.病程记录.检查检验结果.医嘱.手术记录.护理记录等等.而随着医疗行业信息系统(HIS)的推行,电子病历系统也是整个行业最为关注的一个大的功能模块,是以电子化方式管理的有关个人终生健康状态和医疗保健行为的信息,涉及病人信息的采集.存储.传输.处理和利用的所有过程信息. 电子病历系统优势优点

电子病历系统安全性-加密解密

一.基本信息 标题:电子病历管理系统及其加密技术的设计与实现 时间:2018 出版源:中国知网 领域分类:电子病历系统.加密.解密 二.研究背景 电子病历管理系统的安全性如何保证?如何进行加密与解密? 三.研究内容 1.本系统采取常用"数字信封"技术的方式同时在加密技术上选择安全性比较高的高级加密标(Advanced E n c r y p t i o n S t a n d a r d ,AES),加密方式. 2.何利用加密方式保证电子病历的安全进行讨论 (1)首先为了保证电子病历信

基于Node.js+MySQL开发的开源微信小程序B2C商城(页面高仿网易严选)

高仿网易严选的微信小程序商城(微信小程序客户端) 界面高仿网易严选商城(主要是2016年wap版) 测试数据采集自网易严选商城 功能和数据库参考ecshop 服务端api基于Node.js+ThinkJS+MySQL 计划添加基于Vue.js的后台管理系统.PC版.Wap版 GitHub: https://github.com/tumobi/nideshop-mini-program 项目截图 首页 专题 分类 商品列表 商品详情 购物车 订单中心 功能列表 首页 分类首页.分类商品.新品首发.

NideShop:基于Node.js+MySQL开发的微信小程序商城开源啦

高仿网易严选的微信小程序商城(微信小程序客户端) 界面高仿网易严选商城(主要是2016年wap版) 测试数据采集自网易严选商城 服务端api基于Node.js+ThinkJS+MySQL 计划添加基于Vue.js的后台管理系统.PC版.Wap版 GitHub:https://github.com/tumobi/nideshop-mini-program 项目截图 功能列表 首页 分类首页.分类商品.新品首发.人气推荐商品页面 商品详情页面,包含加入购物车.收藏商品.商品评论功能 搜索功能 专题功

基于MT7688模块的开发笔记7——给Ubuntu系统添加samba服务

有的Ubuntu系统不能通过虚拟机的文件夹共享功能实现Windows与Ubuntu之间的文件共享,可以通过安装samba实现这个功能,主要步骤如下,供参考.经过测试,我的Ubuntu12.4.2系统已经可以实现在Windows下访问Ubuntu系统中的文件夹,当然Ubuntu12.4.2是可以通过虚拟机共享功能访问Windows中文件夹.有了这个功能后,就可以将Ubuntu中编译的文件共享到Windows. 一.更新源 [email protected]:~$ su Password: [ema

大数据项目实践:基于hadoop+spark+mongodb+mysql开发医院临床知识库系统

一.前言 从20世纪90年代数字化医院概念提出到至今的20多年时间,数字化医院(Digital Hospital)在国内各大医院飞速的普及推广发展,并取得骄人成绩.不但有数字化医院管理信息系统(HIS).影像存档和通信系统(PACS).电子病历系统(EMR)和区域医疗卫生服务(GMIS)等成功实施与普及推广,而且随着日新月异的计算机技术和网络技术的革新,进一步为数字化医院带来新的交互渠道譬如:远程医疗服务,网上挂号预约. 随着IT技术的飞速发展,80%以上的三级医院都相继建立了自己的医院信息系统

航天七三一医院护理电子病历的设计与实施

中图分类号:TP3                                                         论文编号: 专业硕士学位论文   航天七三一医院护理电 子病历的设计与实施 作者姓名 学科专业  软件工程 指导教师 培养院系  软件学院 The Design and Implementation of Aerospace 731 hospital electronic nursing record system   A Dissertation Submitte

一种电子病历系统软件框架思想

袁永福 2016-5-9 电子病历系统到底采用B/S还是C/S架构是一个长期争论的话题.而在业界两种架构的应用范围谁也不占有显著优势. 在此笔者提出一种BS和CS混合的架构,以下是其原理图: 在该结构中主要部分有 WEB服务器 这是系统的核心.大多数的业务流程运行在WEB服务器中.采用ASP.NET开发,直连数据库. WEB服务器包含系统功能 API集合,以远程调用的方式向PC客户端软件提供功能支持. 还包含ASPX页面,向移动设备提供功能支持. PC机客户端 PC机客户端为一个轻量级的客户端软

电子病历,到底是用BS还是CS

袁永福 2014-8-19 前言:前几天下午去开发医疗软件的S公司,旁听了他们的内部技术讨论会议.他们目前的电子病历是B/S架构,会上一群人讨论起用C/S重构电子病历系统的可行性,于是引出了本文的题目:电子病历,到底是用B/S还是C/S. 电子病历等医疗信息化系统到底是用B/S模式还是C/S模式.这是一个长期以来困扰着许多甲方和乙方的基础性的技术问题.过去困扰了,现在还在困扰,估计将来还会困扰. 这个问题真的是可以花开两朵,各表一枝了.首先说说B/S模式. B/S模式最为称赞的特点就是部署.维护