report ()

ugliestharrasΛογισμικό & κατασκευή λογ/κού

4 Νοε 2013 (πριν από 3 χρόνια και 5 μήνες)

97 εμφανίσεις

RFID Patient Tagging and Database System





April 2004


Department of Electronic Engineering


RFID

P
ATIENT
T
AGGING AND
D
ATABASE
S
YSTEM


F
INAL
Y
EAR
P
ROJECT
R
EPORT


Student:

Martin O’Halloran




Supervisor: Martin Glavin



Date: A
pril 2004



RFID Patient Tagging and Database System





April 2004

ACKNOWLEDGEMENTS


I would like to thank the department technicians, Aodh Dalton, Myles Meehan and
Martin Burke for their assistance throughout this project.


I would also like to thank my supervisor, Martin Glavin, for giving me the help and
insight I needed, and for giving me the liberty to develop this project.


Finally, I would like to express my gratitude to Connaught Electronics Ltd for their
continued assistance and support throughout this project.



































RFID Patient Tagging and Database System





April 2004

ABST
RACT


This paper proposes the use of a Radio Frequency Identification (RFID) tagging
system, coupled with a web
-
based database, to facilitate the centralisation of patient
records within the hospital environment. RFID carries data in suitable transponders
,
generally known as tags and receives data by an RFID reader at a suitable time and
place to satisfy particular application needs. This paper proposes a system for the
identification of hospital patients using RFID. The tag holds a unique patient
identifi
er, which is used to retrieve the patient details from a web
-
based database. The
merging of RFID technologies and the advances in web
-
based database systems
provides standardised and centralised hospital records, with a strong emphasis on data
security.

Th
is project merges many different technologies including the following:



RFID



Wi
-
Fi (
Wireless Fidelity)




Linux



HTML (HyperText Mark
-
up Language)



PHP (
PHP Hypertext Pre
-
processor)



SQL (Structured Query Language)


This document will first introduce these tech
nologies, before showing how they have
been implemented in this project.
















RFID Patient Tagging and Database System





April 2004

ACKNOWLEDGEMENTS

................................
................................
................................
...................

2

ABSTRACT

................................
................................
................................
................................
............

3

1.

INTRODUCTION
................................
................................
................................
.........................

6

1.1 INTRODUCTION

................................
................................
................................
............................

6

1.2 OVERVIEW OF THE
SYSTEM

................................
................................
................................
....

6

1.3 PROBLEMS TO BE C
ONSIDERED

................................
................................
.............................

7

2.

RESEARCH

................................
................................
................................
................................
..

8

2.1 INTRODUCTION

................................
................................
................................
............................

8

2.1 INFORMATION RECO
RDED BY DOCTORS

................................
................................
...........

8

Patient History

................................
................................
................................
................................

8

Examinations

................................
................................
................................
................................
..

9

Special Investigations

................................
................................
................................
.....................

9

2.2 INFORMATION RECO
RDED BY NURSES

................................
................................
...............

9

General Observations

................................
................................
................................
.....................

9

Neurological Observations

................................
................................
................................
.............

9

3. RFID

................................
................................
................................
................................
..................

11

3.1

INTRODUCTION TO RFID

................................
................................
................................

11

3.2 TYPES OF RFID SY
STEMS

................................
................................
................................
........

11

3.2.1 Radio Frequency

................................
................................
................................
..................

11

Low Frequency RFID

................................
................................
................................
..............................

12

Medium Frequency RFID

................................
................................
................................
........................

12

High Frequency RFID

................................
................................
................................
..............................

12

3.2.2 Modulation

................................
................................
................................
...........................

13

Electromagnetic coupling

................................
................................
................................
.........................

13

Propagating Electromagnetic Waves

................................
................................
................................
........

14

3.2.3 T
ypes of RFID Tag

................................
................................
................................
...............

14

Active Tags

................................
................................
................................
................................
..............

14

Passive Tags

................................
................................
................................
................................
.............

15

3.3 RFID TAG STRUCT
URE

................................
................................
................................
.............

15

3.4 RFID READER STRU
CTURE

................................
................................
................................
.....

16

3.5 RFID COMMUNICATI
ON

................................
................................
................................
...........

17

4.

TECHN
OLOGIES EMPLOYED IN
THE SYSTEM

................................
..............................

19

4.1

LINUX

................................
................................
................................
................................
.....

19

4.2 APACHE

................................
................................
................................
................................
.........

20

4.3 PHP

................................
................................
................................
................................
..................

22

4.4

VISUAL BASIC

................................
................................
................................
.....................

23

4.4.1 INTRODUCTION

................................
................................
................................
.......................

23

4.4.2 ADVANTAGES OFF
ERED B
Y VISUAL BASIC
................................
................................
....

23

5. SERVER
-
SIDE SETUP AND INSTA
LLATION

................................
................................
..........

24

5.1 INTRODUCTION

................................
................................
................................
..........................

24

5.2 INSTALLATION OF
LINUX

................................
................................
................................
.......

24

5.2.1 Initial Installation Process

................................
................................
................................
...

24

5.2.1 Post
-
Installation Configuration

................................
................................
...........................

25

5.3 APACHE INSTALLAT
ION AND CONFIGURATIO
N

................................
............................

25

5.3.1 Installation

................................
................................
................................
...........................

25

RFID Patient Tagging and Database System





April 2004

5.3.2 Apache Confi
guration

................................
................................
................................
..........

25

5.3.2 Apache Testing

................................
................................
................................
.....................

26

5.4 MYSQL INSTALLATI
ON

................................
................................
................................
............

26

5.4.1 My
SQL Installation

................................
................................
................................
..............

26

5.4.2 MySQL Testing

................................
................................
................................
.....................

27

5.5 PHP INSTALLATION

AND CONFIGURATION

................................
................................
.....

28

5.5.1 Introduction
................................
................................
................................
..........................

28

5.5.2 Installation

................................
................................
................................
...........................

28

5.5.3 Configuration

................................
................................
................................
.......................

28

5.5.4 Testing

................................
................................
................................
................................
..

29

6. VISUAL BASIC CLIE
NT APPLICATION

................................
................................
...................

30

6.1 INTRODUCTION

................................
................................
................................
..........................

30

6.2 COMMUNICATION WI
TH THE RFID READER

................................
................................
...

30

6.2.1 Introduction
................................
................................
................................
..........................

30

6.2.2 RFID reader serial protocol definition

................................
................................
................

30

6.2.2.1 Request packet format

................................
................................
................................
..................

30

6.2.2.2 Response packet format

................................
................................
................................
...............

31

6.2.2.
3 Request commands

................................
................................
................................
.......................

32

6.2.2.4 Request Command Flags

................................
................................
................................
..............

32

6.2.2.5 Response Command Flags

................................
................................
................................
...........

33

6.2.3 MSComm communication control

................................
................................
........................

33

6.2.3.1 Initial MSComm setup

................................
................................
................................
.................

33

6.2.3.2 Reading the RFID tag number

................................
................................
................................
......

33

6.3 CLIENT LOGIN SYS
TEM

................................
................................
................................
...........

39

6.4 USER
-
TYPE SPECIFIC CONTRO
LS

................................
................................
.........................

41


6.5 UPDATIN
G PATIENT INFORMATIO
N
................................
................................
....................

42

6.6 VIEWING PATIENT
INFORMATION

................................
................................
......................

44



7.

PHP AND MYSQL DATABA
SE DEVELOPMENT
................................
...............................

46

7.1 INTRODUCTION

................................
................................
................................
..........................

46

7.2 MYSQL DATABASE S
ETUP

................................
................................
................................
.......

47

7.2.1 Information to be stored

................................
................................
................................
.......

47

7.2.2 Information to be stored

................................
................................
................................
.......

47

7.2.3 Organising the information

................................
................................
................................
..

49

7.2.4 Establishin
g the relationship between the data tables

................................
.........................

50

7.2.5 Building the database
................................
................................
................................
...........

51

7.3 PHP

................................
................................
................................
................................
..................

53

7.3.1 Application of PHP

................................
................................
................................
..............

53

7.3.2.1 User login verification

................................
................................
................................
..................

54

7.3.2.2 Uploading Patient Personal Information

................................
................................
......................

55

7.3.2.3 Uploading Patient Medical Details

................................
................................
...............................

57

7.3.2.4 Uploading the doctor’s diagnosis

................................
................................
................................
.

61

7.3.2.5 Uploading Multimedia information

................................
................................
..............................

63

7.3.2.6 Retrieving patient personal information

................................
................................
.......................

64

7.3.2.7 Display Med
ical Details

................................
................................
................................
...............

65

7.3.2.8 Retrieval and display of nurses’ observations

................................
................................
..............

65

7.3.2.9 Retrieving and displaying Multimedia data

................................
................................
..................

67

7.3.2.10 Displaying Past medical records

................................
................................
................................

68

RFID Patient Tagging and Database System





April 2004

1.

INTRODUCTION



1.1 INTRODUCTION


In general, patient medical records in hospital are currently paper based. They are
ofte
n compiled in an ad
-
hoc manner, with recorded details varying between doctors.
This project details a solution that attempts to homogenise hospital records by
merging RFID and web
-
based database technologies. The solution standardises the
recorded data, a
nd provides a database that can be accessed by authorised personnel.


Current systems [1] offer solutions whereby the patient data is held on the RFID tag,
which restricts the amount of patient data that can be stored, due to limited memory
on the tag. Th
is paper proposes a solution that will resolve this issue. The RFID tag
will only store a unique Personal Identification Number (PIN), which identifies the
patient’s records within the web
-
based database.


1.2 OVERVIEW OF THE
SYSTEM


The systems structure
is as follows: Each patient’s records are associated with a
unique identifier. This identifier is stored on a transponder attached to the patient’s
wrist. Doctors, nurses and administration personnel are allowed access the database
using a PDA (Personal Di
gital Assistant) or tablet PC enabled with a wireless network
card, as shown in figure 1.1. The RFID tag is read, and the identifier is passed over
the wireless network to the centralised server. The server searches the database and
dynamically generates a

web page containing the relevant patient information.
Medical personnel are then be authorised to view and update the patient details. The
information contained in the database comprises text and multimedia data. The
structure of the system can be describ
ed as client
-
server architecture. The client
consists of the PDA while the server includes the web server and database, as shown
in figure 1.1. The client code handles communication with the RFID reader and also

RFID Patient Tagging and Database System





April 2004

handles the viewing of patient records. The
server software deals with the storage and
retrieval of patient information.


Patient With RFID
Transponder
PDA To
View And
Update
Patient
Information
Web-Server
And
DataBase
RFID
Interface
Wi-Fi
Interface

Figure
1
: Overview of the system



1.3 PROBLEMS TO BE C
ONSIDERED


The client software has to fulfil the following functional
ity:




It must interface with the RFID reader read the RFID tag.



It must be able to communicate with the Web
-
server.



It must incorporate a web
-
browser for the viewing and updating of patient
information.


The server software must incorporate the following f
unctionality:




It must be secure.



It must store all the patient information in an efficient manner.



It must allow the patient information to be easily viewed and updated
through the generation of dynamic web pages.

RFID Patient Tagging and Database System





April 2004


2.

RESEARCH


2.1 INTRODUCTION


The ma
in objective of any database is to accurately reflect the information it models.
That is to say, the database should hold information that is both relevant and useful.
With this is mind, the next step involved establishing what patient information was
main
tained by medical personnel in hospitals. The findings of the research are
outlined below.


2.1 INFORMATION RECO
RDED BY
DOCTORS


After several meeting with hospital interns, the following is a list of the general
patient details recorded by doctors:


Patie
nt History



Presenting Compliant
: Symptoms that the patient is complaining of and the
duration of these symptoms (brief 2
-
3 lines only)



History of Presenting Complaint
: Further questioning of the presenting
complaint e.g. when did the symptoms first present

themselves



Family History
: illnesses of family members.



Social History
: Information such as does the patient smoke, units of alcohol
consumed per day, does the patient live alone, etc



Past Medical History
: Present or previous medical history.



Past surgica
l history



Any Allergies



Current Medication



Review of Systems: quick questioning of all the other organ systems


RFID Patient Tagging and Database System





April 2004

Examinations



Patient respiratory examination.



Inspection: Check the chest for scars, over
-
expansion, muscle wasting,
etc.



Palpation test



Percuss
ion test


Special Investigations



Blood test



Blood culture



ECG



X
-
rays


2.2 INFORMATION RECO
RDED BY NURSES

The following outlines the information recorded by nursing staff on a daily basis
(nurses’ observations):

General Observations

The following are the st
andard patient observations as recorded by nurses daily:



Pulse



Oxygen intake (if any)



Risk of pressure sores (Waterlow scale)



Fluid Intake



Fluid Output



Blood sugar level (if the patient is diabetic)

Neurological Observations

If the patient has had a head i
njury, or a stroke, or a similar injury, then the following
neurological observations should be taken:



Blood pressure



Pulse



Respirations



Temperature



Glasgow coma scale reading

RFID Patient Tagging and Database System





April 2004

RFID Patient Tagging and Database System





April 2004

3. RFID


3.1

INTRODUCTION TO RFID


Radio Frequency Identification (RFID) syste
ms were originally developed in the
1960’s for automatic data capture based on radio frequency transmissions to identify
rail carriages, personnel, and animals. Radio Frequency Identification (RFID) used
electromagnetic energy as a medium for communication
. The two basic components,
a reader and a transponder, are connected to a host computer that controls the reader.
The transponder consists of a single unit containing a radio receiver and transmitter.
When the transponder receives a signal from the unit r
eader, it responds by
transmitting its unique identification code and any other data that is requested in the
form of a serial data stream.

.
The object of any RFID system is to carry data in
suitable transponders, generally known as tags, and to retrieve
data at a suitable time
and place to satisfy particular application needs. Data within a tag may provide
identification for an item in manufacture, goods in transit, object location information,
the identity of a vehicle, or animal identification. In addit
ion to tags, the system
requires a means of reading or interrogating the tags, and some means of
communicating the data to a host computer.


3.2
TYPES OF RFID SYSTEM
S


RFID systems can be classified according to the radio frequency used, the type of
modul
ation used to communicate and the type of tag used in the system.


3.2.1 Radio Frequency

The radio frequency is defined as the frequency of the sine wave generated by the
reader to send a request to the tag. C
arrier wave frequency is of primary importance

in
determining data transfer rates. In practical terms the rate of data transfer is influenced
primarily by the frequency of the carrier wave used to carry the data between the tag
and its reader. Generally speaking the higher the frequency the higher the

data transfer
RFID Patient Tagging and Database System





April 2004

that can be achieved. Three frequency ranges are generally pre
-
defined in RFID
systems as low, intermediate (medium) and high as shown in Table 3.1.


Frequency Range

Frequency

Low

100
-
500 kHz

Intermediate

10
-
15 MHz

High

2.4
-
5.8 GHz


Tab
le 3.
1

: RFID frequency bands


Low Frequency RFID

The advantage of low frequency RFID is that unlike high frequency RFID systems,
they do not require a line of sight between the transponder and the reader antenna.
They have an opera
ting range of between 1 and 3 metres. They can use low power
levels, therefore making them more acceptable for licensing. The transponders are
quite inexpensive, and the low frequency allows for reads through non
-
metallics.



Medium Frequency RFID

Medium f
requency RFID (typically 13.56 MHz) is used in
Emergency Action
Notification

(EAS) systems and ISM (Industrial, Scientific and Medical) applications.
They have a medium read range, medium data transfer rate, but are less able to permit
solids. While the me
dium frequency RFID systems are more orientation sensitive than
the low frequency system, they still do not require a line of sight between the reader
and the transponder.


High Frequency RFID

High frequency RFID (typically >900 MHz) is less acceptable int
ernationally due to
licensing issues. These systems are available with operating ranges of 30 metres or
more. However, to obtain these ranges, high power levels are required. The ability of
these transponders to read through solids is very limited, and it
is generally accepted
that a line of sight is required between the transponder and the reader unit. The
advantage of the high frequency RFID systems is that they have very high data
transfer rates afforded to them by the very high carrier frequency.


RFID Patient Tagging and Database System





April 2004

3.2.
2 Modulation

Transfer

of data between tags and a reader is wireless. Two modulation methods
distinguish and categorise RFID systems; one based upon close proximity
electromagnetic or inductive coupling, as shown in figure 2, and one based upon
propagating
electromagnetic waves, as shown in figure 3. Coupling is via ‘antenna’
structures that form an integral feature in both tags and readers
.


Electromagnetic coupling

Electromagnetic couplings systems are systems in which a magnetic field is used as a
means o
f transferring data or power. Electromagnetic coupling techniques are
generally applied to RFID systems operating in the low to medium frequency bands,
with relatively short reading distances. Inductive coupling is basically a means of
conveying radio freq
uency energy via an oscillatory high frequency magnetic field.
The reader antenna loop and the tag coil windings establish a loosely connected
“space transformer” resulting in power transfer across short bidirectional reading
distances. Maximum power trans
fer between the reader antenna coil and the tag coil
occurs when the two coupled coils are placed or aligned in the same plane.


MAGNETIC FIELD
RFID READER
RFID
TRANSPONDER
TRANSPONDER
ANTENNA
READER
ANTENNA

Figure
2
: Electromagnetic coupling



RFID Patient Tagging and Database System





April 2004

Propagating Electromagnetic Waves

RFID READER
RFID TAG
TAG
ANTENNNA
READER
ANTENNA
Propagating
EM wave
Modulated
Waveform

Figure
3
.2: Propagating Electromagnetic waves



3.2.3 Types of RFID Tag


Tags are classified by the manner in which they derive their operating power, even
though the power levels required are invariably
very small (micro to milli
-
watts).
Tags are either passive or active, the designation being determined entirely by the
manner in which the device derives its power.

Active Tags

An internal battery powers active tags. The use of a battery means that a seale
d active
transponder has a finite lifetime. However, a suitable cell coupled to suitable low
power circuitry can ensure functionality for as long as ten or more years, depending
upon the operating temperatures, read/write cycles and usage. Active tags usua
lly
send data back to the reader with power generated from the tag. The trade
-
off is
greater size and greater cost compared with passive tags.

RFID Patient Tagging and Database System





April 2004

Passive Tags

Passive tags operate without an internal battery, deriving the power to operate from
the magnetic fi
eld generated by the reader. Passive tags have shorter read ranges than
active tags and require a higher
-
powered reader. Passive tags are also constrained in
their capacity to store data and the ability to perform well in electromagnetically noisy
environm
ents due to the fact that they don’t have a local power supply and are more
vulnerable to noise. However, passive tags offer advantages in terms of cost and life
span. They generally have much longer lifetime and are lower in price than active
transponders
. Passive tags use modulated backscatter to communicate with the RFID
reader.

3.3 RFID TAG STRUCTU
RE

The function of the tag is to respond to a request for the data it carries. Figure 4 shows
the basic structure of the RFID transponder, with its analogue f
ront
-
end, coupled with
its back
-
end digital circuitry. The transponder memory may comprise Read
-
Only
Memory (ROM), Random Access Memory (RAM) and non
-
volatile programmable
memory for data storage depending upon the type and complexity of the device. The
no
n
-
volatile programmable memory is typically Electrically Erasable Programmable
Read Only Memory (EEPROM). It is used to store the transponder data and must be
non
-
volatile to ensure that the data is retained when the device is in its quiescent or
power
-
sav
ing "sleep" state


RFID Patient Tagging and Database System





April 2004

ANALOGUE
CIRCUITRY
DATA TRANSFER
POWER SUPPLY
DIGITAL CIRCUITRY
CONTROL LOGIC
SECURITY LOGIC
INTERNAL LOGIC
MICROPROCESSOR
NON-VOLATILE
MEMORY
EEPROM
FLASH
READ ONLY
MEMORY
ROM
RANDOM
ACCESS
MEMORY
RAM

Figure
4
: Basic Structure of an RFID transponder


3.4 RFID READER STRU
CTURE

RFID readers are usually a microcontroller
-
based unit with a wound output coil, peak
detector hardware, com
parators, and firmware to control the unit. The overall function
of an RFID reader is to provide the means of communicating with the tags and
facilitating data transfer. Functions performed by the reader may include quite
sophisticated signal conditioning,

parity error checking and correction. Once the
signal from a transponder has been correctly received and decoded, algorithms may
be applied to decide whether the signal is a repeat transmission, and may then instruct
the transponder to cease transmitting.

This is known as the "Command Response
Protocol" and is used to circumvent the problem of reading multiple tags in a short
space of time. Using interrogators in this way is sometimes referred to as "Hands
Down Polling". An alternative, more secure, but sl
ower tag polling technique is called
"Hands Up Polling" which involves the interrogator looking for tags with specific
identities, and interrogating them in turn. This is contention management, and a
variety of techniques have been developed to improve the

process of batch reading. A
further approach may use multiple readers, multiplexed into one interrogator, but with
attendant increases in costs


RFID Patient Tagging and Database System





April 2004

3.5 RFID COMMUNICATI
ON


Active tags actually send data back to the reader with radio power derived from the
ta
gs internally battery. Passive tags on the other hand, use modulated backscatter
(MBS) to respond to the reader’s request. Backscatter is a
method

of "reflecting" the
carrier wave and putting a signal into that reflection. Backscatter is achieved by
modula
ting the radar
-
cross section of the tag antenna. The tag modifies the reflected
wave by altering the tag feed
-
point impedance. This amplitude modulated reflected
wave hence communicates the data back to the reader as shown in figure 3.3.

RFID READER
RFID TAG
TAG
ANTENNNA
TRANSPONDER
ANTENNA
RFID READER
RFID TAG
TAG
ANTENNNA
Tx Wave
Backscatter
TRANSPONDER
ANTENNA
1
0
1
0

Figure 3.3 RFID Communication through backscattering

RFID Patient Tagging and Database System





April 2004


RFID Patient Tagging and Database System





April 2004

4.

TECHNOLOGIES EMPLOYE
D IN THE
SYSTEM


4.1

LINUX

Linux is one of the most important operating systems worldwide due to its large
support base. UNIX was original
ly developed as a multi
-
tasking mainframe computer
operating system in the 1970s. Linux is a freely distributable version of UNIX
developed primarily by Linus Torvalds at the University of Helsinki in Finland. Linux
is a complete multitasking, multi
-
user o
perating system. The Linux kernel is known as
a monolithic kernel as opposed to a micro
-
kernel, in that all the device drivers are part
of the kernel. The Linux kernel is developed to use the special protected
-
mode
features of the Intel 80x86 processors. L
inux also supports networking through two
primary
networking protocols TCP (Transmission Control Protocol) and UUCP
(Unix
-
To
-
Unix Copy Protocol)
. Most TCP networks use Ethernet as the physical
network transport. Linux supports many popular Ethernet cards a
nd interfaces for
personal computers. Linux has many advantages as a Web server
-

it runs for long
periods of without needing rebooting, and apache, the most popular Web server, runs
much better on Linux than on the Windows operating system. Apache is
auto
matically installed when you install most Linux distributions. Most distributions
of Linux now come with support for MySQL (my Structured Query Language) and
PHP (PHP: Hypertext Pre
-
processor) included. MySQL is a fast, easy to use
Relational Database Mana
gement System (RDBMS) very popular with Web
developers. PHP is a scripting language designed specifically for use on the Web.

RFID Patient Tagging and Database System





April 2004

4.2 APACHE


Apache server is one of the most popular Web service applications. Apache is a
powerful, flexible, HTTP/1.1 complian
t web server. It is highly configurable and
extensible with third
-
party modules. Users can further customise Apache by writing
modules using the Apache module. Apache implements the following features:




Database Management (DBM) databases for authenticatio
n that allows the
user to set up password
-
protected pages with large numbers of authorized
users, without bogging down the server.




Customized responses to errors and problems which allows you to set up files,
or even CGI scripts, which are returned by th
e server in response to errors and
problems




Unlimited flexible URL rewriting and aliasing meaning Apache has no fixed
limit on the numbers of Aliases and Redirects which may be declared in the
config

files. In addition, a powerful rewriting engine can be
used to solve most
URL manipulation problems.




Virtual Hosts which are often referred to as multi
-
homed servers. This allows
the server to distinguish between requests made to different IP addresses or
names (mapped to the same machine). Apache also offers

dynamically
configurable mass
-
virtual hosting.




Apache can be configured to generate reliable piped logs, such as an error log.
In addition, on most UNIX architectures, Apache can send log files to a pipe,
allowing for log rotation, hit filtering, real
-
t
ime splitting of multiple vhosts
into separate logs, and asynchronous DNS (Domain Naming Service)
resolving on the fly.




RFID Patient Tagging and Database System





April 2004

4.3 MYSQL

Structured Query Language (SQL) is the de
-
facto standard programming language for
creating, updating and retrieving info
rmation that is stored in relational database
management system.
A relational database is a database divided into logical units
called tables, where tables are related to one another within the database. A relational
database allows large complex data to b
e broken down into logical, smaller, more
manageable units. Tables are related to each other through a common key (data value)
in a relational database.
SQL is a formal programming language. Speed was he
developer’s main focus when SQL was being developed.

MySQL is a fast easy to use RDMS. MySQL is easier to install and use than its
commercial competitors and the fact that MySQL is open source is strongly in its
favour. MySQL is available via the General Public License (GPU). MySQL consists
of a MySQL serve
r, several utility programs that assist the administration of the
MySQL databases. MySQL’s main advantages include the following:



It is pre
-
packaged with most Linux distributions

.




It’s quite easy to use: you can interact with a MySQL database using a few

simple statements from the SQL language.




It’s very fast: MySQL’s developers’ main goal was speed; consequently the
software was designed from the beginning with speed in mind.




It’s free via the GNU General Public License.



RFID Patient Tagging and Database System





April 2004

4.3 PHP


PHP is a scriptin
g language designed specifically for use on the Web. PHP is a server
-
side scripting language which was developed for dynamic Web sites and applications.
It is an embedded scripting language, which means that PHP code is embedded in
HTML code.
PHP scripts c
an parse data submitted by HTML forms, communicate
with databases, and make complex calculations on the fly. PHP is very fast because
the freely available source code is compiled into the Apache Web server. A PHP
script is executed as part of the Web serve
r process and requires no forking, often a
criticism of Common Gateway Interface (CGI) scripts.
PHP interacts with the
database by invoking SQL commands, and displays the results in dynamically
generated Web pages. PHP provides the application part and MYS
QL provides the
database part of a Web database application. PHP is used to move data into and out of
the MYSQL database. PHP is also
suitable for more complicated tasks such as parsing
and verifying data that the user has entered into an HTML form
. PHP’s
advantages
include the following:




It’s free via the GNU General Public License (GPL).




It’s fast due to the fact that it’s embedded into the HTML code.





It’s designed to support databases including functionality designed to interact
with specific databas
es. It negates the need for the user to need to know the
technical details required to communicate with a database.




It’s quite easy to use in that it only contains elements of a programming
language needed to interact with a database and to generate dynam
ic web
-
pages.



RFID Patient Tagging and Database System





April 2004

4.4

VISUAL BASIC

4.4.1 INTRODUCTION


Visual Basic is currently one of the most widely used visual programming languages
used to develop stand
-
alone windows applications. Visual Basic allows for the rapid
development of custom designed appl
ications modelled on the full range of window
features. Visual Basic provides for the building of very easy to use and intuitive user
interfaces. Using Visual Basic you can create quality user
-
interfaces by positioning
re
-
useable components directly into f
orms. Functionality is then added by linking
code to these components.


4.4.2 ADVANTAGES OFF
ERED BY VISUAL
BASIC


Visual Basic has many advantages that make it amenable for use in this project. The
advantages include the following:




Visual Basic as a pro
gramming language is relatively simple. Its structure is
quite straightforward.




The Visual Basic Integrated Development Environment (IDE) allows for
Rapid Application Development (RAD). It ideal for the development of
Graphical User Interfaces (GUI).




The

online MSDM libraries provide a comprehensive interactive and context
-
sensitive online help system.




Visual Basic is a component Integration language. It allows for the integration
of the Microsoft Component Object Model (COM). COM components can be
there
fore embedded into your application’s user interface.


RFID Patient Tagging and Database System





April 2004


5. SERVER
-
SIDE SETUP AND
INSTALLATION


5.1 INTRODUCTION


This chapter outlines the procedure involved in setting up a Linux web server. It
describes the general steps involved in the Linux installat
ion, and the various modules
that need to be added.


5.2 INSTALLATION OF
LINUX


5.2.1 Initial Installation Process

There are many companies offering different distributions of Linux. The Linux
distribution chosen fro this project was Red Hat Linux The inst
allation of Red Hat
Linux is quite straightforward. Linux can be installed conveniently from a CD
-
ROM.
Red Hat Linux offers various installation configurations depending on the application
for which the machine is being used. The configuration chosen was “
Server” as the
machine was to be used as a web
-
server. The installation options were chosen as
follows:



Hard
-
disk partitioning:

Automatic Partitioning



Security options:

High



Package Groups:

GNOME and KDE (graphical desktops)



Account Configuration:

Root pa
ssword was entered and created new user:
king, password: fake_password



X configuration video card and monitor:
Automatic


RFID Patient Tagging and Database System





April 2004

5.2.1 Post
-
Installation Configuration

Before working with Red Hat’s distribution of Linux, it is necessary to configure your
search pa
th. This is to allow for the fact that Red Hat’s distribution of Linux does not
include the current directory. For example you compile a program called testProgram,
and you type testProgram, the shell returns an error saying the program could not be
found.

Without configuring the search path it becomes necessary to explicitly specify
the current directory i.e. to execute the program you need to type


. /testProgram

This can be easily fixed by editing the shell profile file

/root/.bash profile

and appending
‘.’ to the end of the line which sets PATH. You must log out before
this shell change takes effect.


5.3 APACHE INSTALLAT
ION AND
CONFIGURATION


5.3.1 Installation

The installation of Apache is quite straight
-
forward. If Linux was installed with the
“server
” configuration, Apache will be already installed. If Apache is not installed
automatically, it is necessary to download the Apache source code and compile the
code on your machine.

5.3.2 Apache Configuration

Apache can be configured almost entirely using
the configuration file httpd.conf. This
file can be located in the
/etc/httpd/conf

directory. The contents of the configuration
file include the following settings

The ServerRoot setting indicates the top of the directory tree under which the server's
conf
iguration, error, and log files are kept.


S
ERVER
R
OOT
"/
ETC
/
HTTPD
"


The Listen setting allows you to bind Apache to specific IP addresses and/or ports, in
addition to the default. In this case Apache is bound to the standard httpd port 80:

RFID Patient Tagging and Database System





April 2004

L
ISTEN
80



Extr
a modules have to be loaded using the “LoadModule” command, so the modules
functionality can be used. The PHP module is loaded below:

L
OAD
M
ODULE PHP
4_
MODULE LIBEXEC
/
LIBPHP
4.
SO



The document root setting specifies out of which directory you will server you
r
documents i.e. the directory in which your HTML (Hyper
-
Text Mark
-
up Language)
and PHP files are stored:


D
OCUMENT
R
OOT
"/
VAR
/
WWW
/
HTML
"


ErrorLog is the location of the directory that will contain the error logs:


E
RROR
L
OG LOGS
/
ERROR
_
LOG


The LogLevel sett
ing controls the number of error messages sent to the error log:


L
OG
L
EVEL DEBUG



5.3.2 Apache Testing

In order to test Apache, you must first start apache. To start apache type:

/
ETC
/
RC
.
D
/
INIT
.
D
/
HTTPD START

To test if Apache is running properly type

M
OZ
ILLA HTTP
://
LOACLHOST

If Apache is working properly you will be presented with an Apache test page.

5.4 MYSQL

INSTALLATION


5.4.1 MySQL Installation

A MySQL Red Hat Package (RPM) can be used to install the RDBMS on a Linux
machine. The RPM for MySQL is u
sually located on the Red Hat installation disks.
The MySQL RPM is installed as follows:


RFID Patient Tagging and Database System





April 2004



Change to the directory to where you want MySQL to be installed. Save the
RPM into this directory. The directory should hold two files, similar to the
following:


M
Y
S
QL

-
4.23.45.
-
1.
I
386.
RPM AND
M
Y
SQL
-
CLIENT
-
4.23.45
-
1.
I
186.
RPM
.




Install the RPM by typing the following:


R
PM

I
M
Y
SQL

-

4.23.45.
-
1.
I
386.
RPM
M
Y
SQL
-
CLIENT
-
4.23.45
-
1.
I
186.
RPM
.


These commands install the RPM packages. It creates the data directory as follows:



VAR
/
LIB
/
MYSQL


and sets the MySQL account and group name that you need. It starts the MySQL
server. Finally it edits the


/
ETC
/
RC
.
D
/
INIT
.
D


file so that the MySQL server starts automatically at boot time.


5.4.2 MySQL Testing

To test MySQL type the fo
llowing:


BIN
/
MYSQLADMIN

VERSION


This command should return the MySQL version number, provided MySQL is
functioning properly.


RFID Patient Tagging and Database System





April 2004

5.5 PHP INSTALLATION

AND
CONFIGURATION

5.5.1 Introduction

There are two methods of installing PHP. You can install it as a stan
dalone interpreter
or as a module in Apache, depending on its intended application. In this case PHP is
used to interact with a database and create dynamic web pages, so it should be
installed as an Apache module. Before installing PHP, you must ensure the

mod_so
apache module is installed, by typing the following command:

H
TTPD
-
L


If mod_so is installed the following message will be displayed:

C
OMPILED IN MODULES
:

C
ORE
.
C

P
REFORK
.
C

HTTP
_
CORE
.
C

MOD
_
SO
.
C

5.5.2 Installation

The following steps describe the in
stallation process:



Download the PHP source code from PHP website



Save it to the appropriate directory



Unpack the tarball (similar to a zip file) file



Change to the new directory that was created.



Type the following command to configure PHP:

CONFIGURE

WI
TH
-
MYSQL

WITH
-
APX

ENABLE
-
TRANS
-
ID



Type the following command:

MAKE



Type the following command:

MAKE INSTALL


5.5.3 Configuration

In order for Apache to recognise the PHP files, change have to me made to the
httpd.conf file. You must tell Apache what f
ile types might contain PHP code. You
can do this by adding the following entry into the httpd.conf file:

A
DD
T
YPE APPLICATION
/
X
-
HTTPD
-
PHP
.

PHP

RFID Patient Tagging and Database System





April 2004

This tells Apache to expect PHP code in files with a .html or .php file extension

You must also tell apache to
load the PHP module on start up.

L
OAD
M
ODULE PHP
4_
MODULE LIBEXEC
/
LIBPHP
4.
SO
.


5.5.4 Testing

To test PHP the following PHP file (test.php) was created:

</php

echo “PHP is working correctly”;

?>

Next save this file on the server. Point the browser at the tes
t.php. PHP is working
properly if the “PHP is working correctly” string is displayed in the browser window.

RFID Patient Tagging and Database System





April 2004

6. VISUAL BASIC CLIE
NT APPLICATION


6.1 INTRODUCTION

The client application has two main functions. It must interface with the RFID reader
and it

must display the dynamically generated web pages sent from the server.


6.2 COMMUNICATION WI
TH THE RFID
READER

6.2.1 Introduction

The RFID reader used in this project is the Texas Instrument’s S6350 midrange
reader. This reader operates at a frequency of

13.56 MHz. The S6350 is designed to
operate in a host based reader system. It receives a command from the host and it
handles all the RF and digital functionality required in communicating with the RFID
tag. The communication between the host and the rea
der is over a serial cable (RS
-
232). The host always initiates the communication between the host and the reader.

6.2.2 RFID reader serial protocol definition

The RFID reader module communicates at the RS
-
232 level. Its baud rate can be set
to 9600, 19200,

38400 or 57600 baud. It uses 1 start bit, 8 data bits and no parity.
There are two types of packets, request and responses. A request packet is a command
sent from the host to the reader module. A response is the resulting answer sent from
the reader to t
he host. Every request has a corresponding response. The format of the
request packet is shown below.

6.2.2.1 Request packet format

Start Of
Frame
(1 byte)
Length Of
Whole
Packet
(2 bytes
LSB first)
Node
Address
(2 bytes)
Command
Flags
(1 Byte)
Command
(1 Byte)
Data
(varied
length)
BCC
(2 bytes)

Figure 6.1: Format of request packet

RFID Patient Tagging and Database System





April 2004

1.

Start of Frame: This one byte indicates the start of the f
rame. It should contain
the value 01
hex

2.

Length: These two bytes describes the total length (in bytes) of the frame,
including the SOF byte.

3.

Node Address: 2 bytes used for upward compatibility, always set to 0000
hex

4.

Command Flag: Significance of this byte d
epends on the contents of the
Command byte. The command byte combined with the command flag dictate
the action to be taken by the reader.

5.

Command: This byte value, combined with the command flag dictates the
action to be taken by the reader.

6.

Data: The size

of the data bytes depends on the command because it contains
the parameters of the command.

7.

BCC: These two bytes contain LRC check bits. These check bits are used to
validate the request when it arrives at the reader.

6.2.2.2 Response packet format

Start Of
Frame
(1 byte)
Length Of
Whole
Packet
(2 bytes
LSB first)
Node
Address
(2 bytes)
Command
Flags
(1 Byte)
Command
(1 Byte)
Data
(varied
length)
BCC
(2 bytes)

Figure 6.2: Format of response packet


1.

Start of Frame: This one byte indicates the start of the frame. It should
contain the value 01
hex

2.

Length: These two bytes describes the total length (in bytes) of the frame,
including the SOF by
te.

3.

Node Address: 2 bytes used for upward compatibility, always set to
0000
hex

4.

Command Flag: Significance of this byte depends on the contents of the
Command byte. The command byte combined with the command flag
dictate the action to be taken by the reader
.

5.

Command: This byte value, combined with the command flag dictates the
action to be taken by the reader.

RFID Patient Tagging and Database System





April 2004

6.

Data: The size of the data bytes depends on the command because it
contains the parameters of the command. Its length is between 0 and 23
bytes long.

7.

BCC: These two bytes contain LRC check bits. These check bits are used
to validate the request when it arrives at the reader.


6.2.2.3 Request commands

The command is one byte in length. There are five possible commands, which are
described below:

Read Bl
ock (02
hex
):

This command reads one block of data. If the address flag is not
set, then the data bytes just contain the block number to be read. If the address flag is
set, the address is read from the data section, as well as the block number.

Write Block

(03

hex
):

This command writes one block of data. If the address flag is
not set then the data section just contains the block number and the data to be written.
If the address flag is set then the data section contains the address of the tag, the block
nu
mber and the data to be written.

Lock Block (04

hex
):

This command locks a single block of data. If the address flag is
not set, then the data section contains the block number to be locked. If the address
flag is set then the data section contains the add
ress of the tag and the block number to
be locked.

Read Transponder Details (05

hex
)
: This command reads the transponder details,
such as the transponder ID and the version number. If the address flag is not set, then
data section is clear. If the address
flag is set then the data section contains the tag
address.

Special Read Block Command (
0F

hex
): For this command the flag is not used. The
data section contains a single byte. This byte describes which blocks should be read.
If none of the bits in the dat
a byte are set then the reader returns the SID of the tag.

6.2.2.4 Request Command Flags

The command flags, coupled with the command, dictate what action the reader should
take.

Bits (0
-
3 and 5
-
7):

These bits are reserved for future use, and should all be

set to 0 by
default.

RFID Patient Tagging and Database System





April 2004

Bit 4:

This is the address flag. If this bit is set, then the action is only performed on
the tag whose address matches that specified in the data section of the packet.

6.2.2.5 Response Command Flags

The command flags in the response

packet are used solely for error checking.


Bits (0
-
3 and 5
-
7):
These bits are reserved for future use and should not be set. These
bits should all be set to 0.

Bit 4:
This is the error flag. If the flag is set then the request command contained
errors. T
he data section of the response packet contains the error code.

6.2.3 MSComm communication control

The Visual Basic MSComm control provides an interface, through which one can
establish a connection to a serial port. The Visual Basic communication control
provides an API which allows the user to set and monitor properties and events of the
communications control. The API provides a high level of abstraction from the bit
level serial communication, making serial communication quite easy.

6.2.3.1 Initial MSCo
mm setup

The first step in adding serial communication to the application is to add the
MSComm component to the application form. After adding the component it is
necessary to set the properties of the control:

'Initilise comm control

If (MSComm1.PortOpen
= False) Then
'if comm port isn't already open


MSComm1.CommPort = 1

' Port 1 is Comm1


MSComm1.Settings = "57600,N,8,1"
'baud rate = 57600, parity none,8 data bits, 1 stop bit


MSComm1.PortOpen = True

'open the comm port

End If

The MSComm setting sets the baud rate to 57600, the parity to none, the data bits to 8
and the stop bits to 1. It sets the COM port to 1 and opens the port for communication.


6.2.3.2 Reading the RFID tag number

Before the
Reader will read the tag and return the tag number, t must receive a read
request from the host. The read command must follow the request packet format
outline above:

RFID Patient Tagging and Database System





April 2004

Start Of
Frame
(1 byte)
Length Of
Whole
Packet
(2 bytes
LSB first)
Node
Address
(2 bytes)
Command
Flags
(1 Byte)
Command
(1 Byte)
Data
(varied
length)
BCC
(2 bytes)
01
0000
0000
00
02
01
BCC
(2 bytes)

The process of creating and sending the command is as follow
s:


1.

This command read block 1 of the RFID in non
-
addressable mode. The BCC
bits have to be calculated before the packet can be sent to the RFID reader.
The checkLRC function calculates the LRC bits and they are appended to the
original command string:


Cal
l CheckLRC(sCmdString, sLRC)


’call function to calculate the check bits


sTemp = sCmdString & sLRC


'reassemble string to be sent, by adding the LRC

sCmdString = ""




'reset the command string


2.

The checkLRC function is outlined below:

Public Sub C
heckLRC(sCmdString, sLRC)


‘Declare the variables


Dim LRC As Long


Dim i As Integer


Dim ByteVal As String


Dim HNibble As Byte


Dim LNibble As Byte


Dim MSByte As String


Dim LSByte As String



Dim sTemp As String




' Start value


LRC = &H0&






'The first step is to convert the string to decimal


For i = 1 To Len(sCmdString) Step 2



' Step thru characters


' If the value is between A and F, i.e. between 10 and 16



If Mid$(sCmdString, i, 1)

>= "A" And Mid$(sCmdString, i, 1) <= "F" Then




'get the first character, find its ansi code,



'minus 55 to get its decimal equivalent, and multiply by 16



'because its the upper nibble of the byte





HNibble = (Asc(Mid$(sCmdString, i, 1))
-

55) * 16


Else





'Otherwise if the value is between 0 and 9




'find its ANSI code, minus 48 to get its decimal equivalent

RFID Patient Tagging and Database System





April 2004




'and mult
iply by 16 because its the upper nibble of the byte




HNibble = (Asc(Mid$(sCmdString, i, 1))
-

48) * 16




End If




'Get the next value


' If the value is between

A and F, i.e. between 10 and 16



If Mid$(sCmdString, i + 1, 1) >= "A" And Mid$(sCmdString, i + 1, 1) <= "F" Then


'get the first character, find its ansi code,



'minus 55 to get its decimal equivalent






LNibble = (Asc(Mid$(sCmdString, i + 1, 1))
-

55)


Else



'Otherwise if the value is

between 0 and 9




'find its ANSI code, minus 48 to get its decimal equivalent





LNibble = (Asc(Mid$(sCmdString, i + 1, 1))
-

48)


End If




'Byteval holds th
e sum of the two nibbles (byteval is a decimal)


ByteVal = (HNibble + LNibble)




'Perform XOR operation


LRC = LRC Xor ByteVal



Next i




'some string manipulation


'convert the LRC to hex


sTemp = Hex(LRC)




'if the hex representation is only 1 hex character


'add a preceding "0" to the string and assign the new string to LSByte



If Len(sTemp) = 1 Then



LSByte = "0" & sTemp



Else



'otherwise stemp to LSByte directly


LSByte = sTemp



End If




'Assign MSByte as the 1's compliment of the LRC


MSByte = Hex(LRC X
or &HFF)




'add a proceding "0" to the MSbyte string, if necessary


If Len(MSByte) = 1 Then


MSByte = "0" & MSByte


End If




'append and assign the LSByte and MSByte to the sLRC


sLRC = LSBy
te & MSByte


End Sub

3.

The new command string is then converted to binary:




RFID Patient Tagging and Database System





April 2004

‘take two characters at a time

For i = 1 To Len(sTemp) Step 2


‘if character is between A and F

‘convert to ANSI, minus 55 to get decimal,

‘ then multiply by 16 because if the uppe
r nibble


If Mid$(sTemp, i, 1) >= "A" And Mid$(sTemp, i, 1) <= "F" Then


HNibble = (Asc(Mid$(sTemp, i, 1))
-

55) * 16



‘if character is between 0 and 9

‘convert to ANSI, minus 48 to get decimal,

‘ then multiply by 16 because if t
he upper nibble


Else


HNibble = (Asc(Mid$(sTemp, i, 1))
-

48) * 16


End If


‘if character is between A and F

‘convert to ANSI, minus 55 to get decimal,


If Mid$(sTemp, i + 1, 1) >= "A" And Mid$(sTemp, i + 1, 1) <= "F" Then


LNib
ble = (Asc(Mid$(sTemp, i + 1, 1))
-

55)


Else


‘if character is between 0 and 9

‘convert to ANSI, minus 48 to get decimal,



LNibble = (Asc(Mid$(sTemp, i + 1, 1))
-

48)


End If

‘reconstruct command string



sCmdString = sCmdString

& Chr$(HNibble + LNibble)




Next i


4.

Send the command string and start a timer to wait for a response


' Initialise TIMEOUT timer


lstartTime = Timer

‘Clear the receive buffer


MSComm1.InBufferCount = 0

' Specify binary data in
put


MSComm1.InputMode = comInputModeBinary

' Input first 6 characters


MSComm1.InputLen = 6

‘Send command string to the reader


MSComm1.Output = sC
mdString




' Loop until 6 characters are received or 1 second has elapsed


Do Until MSComm1.InBufferCount >= 6 Or ltimeNow > lstartTime + 1


DoEvents



ltimeNow = Timer



Loop


RFID Patient Tagging and Database System





April 2004

5.

Get the response and convert it back to hex :


' Get response


Buffer = MSComm1.Input


'

Assign Variant to Byte array


Aarray = Buffer

‘nTemp will hold the number of elements in the array


nTemp = UBound(Aarray)


If nTemp > 2 Then









' Convert to Hex


For i = 0 To (nTemp)


sHexChars = Hex$(Aarray(i))


‘If the len
gth is 1, add a proceding 1

If Len(sHexChars) = 1 Then

sResponse = sResponse + ("0" & sHexChars)


Else

‘otherwise just add the sHexChars directly



sResponse = sResponse + sHexChars


End If


Next i


6.

Get the rest of the response:


'Set up MSComm to get rest (nLength
-

6) of response.


MSComm1.InputLen = nLength
-

6


Do Until MSComm1.InBufferCount >= (nLen
gth
-

6) Or ltimeNow > lstartTime + 1




Do nothing and get the current time used in the DO loop for comparison


DoEvents



ltimeNow = Timer



Loop


' Assign Input buffer to variant Buffer


Buffer = MSComm1.Input

' Assign
Buffer to array


Aarray = Buffer

' Find length of array (bytes)


nTemp = UBound(Aarray)

' Convert to Hex string



For i = 0 To (nTemp)

RFID Patient Tagging and Database System





April 2004

sHexChars = Hex$(Aarray(i))



If Len(sHexChars) = 1 Then



' Add extra "0" to single hex chars


sResponse = sResponse + ("0" & sHexChars)


Else

‘otherwise assign sResponse directly


sResponse = sResponse + sHexChars


End If


Next i


7.

To verify the response is error free call the checkLRC function:

' Calculate LCR Check

Call CheckLRC(Left$(sResponse, Len(sResponse)
-

4), sLRC)

‘If the LRC is not ok, assign an error to sTag



If (sLRC <> Right$(sResponse
, 4)) Then


sTag = " Bad Checksum"


Else

‘Otherwise assign sResponse to stag (no errors)


sTag = sResponse


End If


8.

If the tag has been read and no errors have occurred then the

string will have a
length of 30. If this is the case, extract the tag number from the response string
and assign it to the Tagnum variable:


‘if the response packet is the correct length, it contains no errors

If (Len(sTag) = 30) Then


'sTag is the str
ing representation of the response


‘extract the 8 digit RFID tag number from the response string


TagNum = Mid(sTag, 15, 8)

End if


The RFID tag number has now been read and stored and can be used to reference
patient records within the web
-
based dat
abase. If the reader was unable to read the
tag, an error message will be displayed and the user must try to read the tag again.

RFID Patient Tagging and Database System





April 2004

6.3 CLIENT LOGIN SYS
TEM

The login system on the server
-
side simply takes the username and password, queries
the database, and l
inks to the appropriate page depending on the query result. If the
user’s a doctor, it links to doctor.php, a nurse to nurse.php, the administrator to
admin.php and an unauthorised user to incorrectlogin.html. The client application
must present a login GU
I (Graphical User Interface) where the user can enter their
login details:


The Visual Basic code must take the user name and password, pass them to the server
for querying, and then wait for a response from the server. The process is as follows:


Build a

URL with the user name and password and send it to the server:

‘Initialise variables

Dim loginString As String

‘Build login URL encoding the username and password into the URL


loginString = "http://excelsior/~king/login.php" + "?" + "u=" + UserName + "&
" + "p=" +
Password

‘Navigate the web
-
browser to the URL specified to verify login


Form1.WebBrowser1.Navigate (loginString)


Wait for 1 second to allow the server to query the database and link to the appropriate
page:

‘Initialise Variables

Dim lstartT
ime As Long

Dim ltimeNow As Long

lstartTime = Timer

‘loop until 1 second has passed

Do Until (ltimeNow > lstartTime + 1)


DoEvents


ltimeNow = Timer


Loop


RFID Patient Tagging and Database System





April 2004

Next, the web br
owser location URL to see which page it has been forwarded to, then
set the user variables:

‘Examine the web browser URL, if the browser has forwarded to doctor.php the user is
‘a doctor, if the browser has forwarded onto nurse.php the user is a nurse, etc
.


If (Form1.WebBrowser1.LocationURL = "http://excelsior/~king/doctor.php") Then

‘set the usertype variable

‘set the login flag to true

‘hide the login dialog

‘call the login function



usertype = "doctor"


LoginSucceeded = True


Me.Hi
de


Call Login


End If



If (Form1.WebBrowser1.LocationURL = "http://excelsior/~king/nurse.php") Then

‘set the usertype variable

‘set the login flag to true

‘hide the login dialog

‘call the login function


usertype = "nurse"


LoginSucceeded = True


Me.Hide


Call Login


End If




If (Form1.WebBrowser1.LocationURL = "http://excelsior/~king/admin.php") Then

‘set the usertype variable

‘set the login flag to true

‘hide the login dialog

‘call
the login function



usertype = "admin"


LoginSucceeded = True


Me.Hide


Call Login


End If


‘if the username and password are incorrect

If (Form1.WebBrowser1.LocationURL = "http://excelsior/~king/incorrectLo
gin.html") Then

RFID Patient Tagging and Database System





April 2004



‘Present a message box saying the login was unsuccessful

MsgBox "Invalid Password, try again!", , "Login"



‘display the login dialog once again

Password.SetFocus



SendKeys "{Home}+{End}"


End If

End Sub


6.4 USE
R
-
TYPE SPECIFIC CONTRO
LS

The system must grant different privileges to different users when updating patient
information. The doctor should be allowed to update a patient’s diagnosis and basic
medical records. A nurse should be allowed to view, but not upd
ate the diagnosis and
basic medical records. A nurse should have sufficient privileges which allow the
nurse to update a patient’s daily observations.

This is achieved as follows:

The Visual basic code only displays the controls that should be used by the

specific
user
-
type:

‘if the usertype is “doctor”, set up the doctors GUI

If (frmLogin.usertype = "doctor") Then


cmdUpdatePatientInfo.Visible = True


cmdGetInfo.Visible = True


PatientTag = TagNum


cmdReadTag.Visible = False



cmdCloseStay.Visible = False


End If


‘if the usertype is “nurse”, set up the nurses’ GUI


If (frmLogin.usertype = "nurse") Then


cmdGetInfo.Visible = True


cmdUpdatePatientInfo.Visible = True


PatientTag
= TagNum


cmdReadTag.Visible = False


cmdCloseStay.Visible = False


End If





RFID Patient Tagging and Database System





April 2004

‘if the usertype is “admin”, set up the administrators GUI


If (frmLogin.usertype = "admin") Then


cmdUpdatePatientI
nfo.Visible = True


cmdGetInfo.Visible = True


PatientTag = TagNum


cmdReadTag.Visible = False


cmdCloseStay.Visible = True


End If





6.5 UPDATING PATIENT

INFORMATION

To update medical de
tails, the user must click the update button. They are then
presented with an update frame containing the following buttons:



Personal Details



Medical Details



Multimedia Details



Diagnosis

RFID Patient Tagging and Database System





April 2004



Nurses’ Observations (This is the only section which can be updated b
y
nurses)

When the button is clicked the web
-
browser’s URL is set to the appropriate address,
and the RFID tag number is encoded to the URL:

The appropriate web pages are displayed within the web
-
browser:

Private Sub UpdateMedicalDetails_Click()

‘Create a
string containing the appropriate URL and encode the tag number into the
‘URL

Dim UrlString As String


UrlString = "http://excelsior/~king/MedicalDetailsForm.php" + "?" + "number=" +
TagNum


WebBrowser1.Navigate (UrlString)

‘Call a function to refres
h the web
-
page


Call refreshWeb

End Sub






RFID Patient Tagging and Database System





April 2004



6.6 VIEWING PATIENT
INFORMATION

To view medical details, the user must click the
Get Patient Details

button. They are
then presented with an viewing frame containing the following buttons:



Perso
nal Details



Medical Details



Multimedia Details



Diagnosis



Nurses’ Observations

When the button is clicked the web
-
browser’s URL is set to the appropriate address,
and the RFID tag number is encoded to the URL:


Private Sub getMedicalDetails_Click()

‘Create
a string containing the appropriate URL and encode the tag number into the
‘URL


Dim UrlString As String


UrlString = "http://excelsior/~king/RetrieveMedicalInfo.php" + "?" + "number=" +
TagNum


WebBrowser1.Navigate (UrlString)

‘call a function to re
fresh the web page


Call refreshWeb

End Sub

RFID Patient Tagging and Database System





April 2004





RFID Patient Tagging and Database System





April 2004

7.

PHP AND MYSQL DATABA
SE
DEVELOPMENT


7.1 INTRODUCTION


PHP and MySQL are a natural combination for web
-
based database applications.
MySQL provides the database component, while PHP accesses the dat
abase and
generates dynamic web pages to interact with the user. The system must allow the
medical personnel to store and retrieve medical information. The system must allow
the medical personnel to view previous medical information. This led to the idea o
f a
hospital “stay” which would encompass all medical information relating to a patient
stay in a hospital. A stay is defined as the period of time between their first admission
and their eventual discharge. The basic structure of the stay object is define
d below:

Medical Details
Nurses’ Observations
Patient Stay Object

Figure 7.1 Patient Stay Object


RFID Patient Tagging and Database System





April 2004

7.2 MYSQL DATABASE S
ETUP


7.2.1 Information to be stored

After determining what exactly the database should hold in chapter 2, the next step is