Interfacing A Medical Record database With Matlab.pdfDocument Transcript
AHSC OBGYN Database 1
Interfacing a medical record database with Matlab
Stylianos A. Andreou
Abstract—Interfacing Matlab with a medical record database in
order to improve the scientific procedure on data analysis in
biophotonics and cancer research.
S CIENTISTS perform multiple experiments and
measurements before they come to any conclusion. For
such cases the best way to use the data is to
upload/download the data of a database directly from/into an
% RISK STATUS HISTORY
analysis software package such as Matlab. STUDY
II. DATABASE OVERVIEW
We have developed a medical research database based on
MySQL and PHP for research projects in Gynecologic SPECIMEN
Oncology. This database will serve as a model for clinical (BIOPSY)
studies as well as animal studies in oncology. Currently the
OBGYN database has a web interface where the operator can
create a patient entry and add the required information. The
link for the database is http://studydb.obgyn.arizona.edu. CONCRETE
Fig. 1. Welcome screen of the OBGYN database
The organization structure of the database it follows the block
diagram of Fig2. Each patient can have a historical record,
current risk factor and can be involved in many studies. For
Fig. 2. Block diagram for a single patient in the database. Red blocks indicate
each study the patient can have multiple specimens (biopsies) the fields that Matlab add to the database.
involved in the research and each specimen can have multiple
measurements on different locations. For each measurement
the database will hold the actual location of measurement on III. USING THE DATABASE
the specimen, the location of the file with the data analysis, a Once you are in the web interface of the database you can use
diagnosis based on the measurement, the modality used in this the side menu on the left of the screen.
measurement and statistical results based on the analysis of
the measurement. Matlab can access the database to create or Login: In order to be able gain access on the database first you
modify these entries for each measurement. Moreover, it can have to login.
retrieve information from the database for further analysis or
Manuscript received April 28, 2005.
S. A Andreou is with the Electrical Engineering Department, University
of Arizona, Tucson, AZ 85719 USA, (e-mail: firstname.lastname@example.org).
AHSC OBGYN Database 2
In order to add more studies you will need to access the
administration site of the database. You can access the site
under http://studydb.obgyn.arizona.edu/weblox . Note that
Fig. 3. Login screen of the OBGYN database. you will need to have administratively privileges to access this
Once you are on the administration site you can add extra
Add Patient: Once you select to add a new patient, the system studies to the database by selecting the Manage studies menu
automatically creates an entry in the system using an id on the left and then Add Study link. In the new screen you
number based on acceding ordering from 1000. will have to add the full name of the study (ex. 02-133 In-
Fig. 4. Add Patient screen of the OBGYN database.
On the right-top corner you can see the id of the patient you
have just added. All the modifications you will do in the Fig. 7. Administration screen of the OBGYN database. You can add extra
database will correspond to that id. studies by selecting the Manage studies menu and then Add study.
Choose Patient: You can choose the patient by typing his id in History: Each patient can have his own historical record being
the field box. Again all the modifications you will do in the stored in the database. Once the history record is created all
database will correspond to that id. the unknown fields have by default either the value “-1” or
“Don’t know”. Currently the history is geared towards
Manage Patients: Using this option you can look over some demographic variables related to ovarian and breast cancer.
basic info for each patient and moreover you can activate the
user you want.
Fig. 8. History screen for a patient in the OBGYN database.
Fig. 5. Manage Patient screen of the OBGYN database. Risk status: For each patient a risk status for developing
cancer can be assigned. The risk status is a percentile value
For each user you can see if he already has historical record in based on a genetic counselors interview with the patient.
the database, his risk factor based on a percentage scale, the External software packages are used to assess the patients risk,
number of specimens (biopsies) he is currently involved and often determined by family history or known genetic
the date the patient was added to the database. mutations. If the patient is involved in many studies the worst
risk status is assigned. In some cases the risk status is only an
Manage Studies: Once the user is in the database you can add indication between low risk and high risk, for example when
him to multiple studies. Studies currently exist in the database the complete risk analysis by software could be conducted.
are: 02-113 In-Vivo Spectroscopy, 02-133 In-Vitro For low risk status a 0.1% value is assigned and for high risk
Spectroscopy and 02-31 In-Vivo Imaging. status a 99% value. In the case of no available data, the
patient’s status is a 0% value by default. Any value higher
than 100% in the risk status indicates that the patient has a
Fig. 6. Manage Studies screen of the OBGYN database.
AHSC OBGYN Database 3
with the database. In the case that a patient or a certain biopsy
Fig. 9. Risk status screen for a patient in the OBGYN database. are not already in the database matlab cannot proceed and a
warning message is given. When a filename is already exist
Add Specimen: A patient can have multiple specimens for a certain biopsy a warning message is given, the procedure
involved in each study that his enrolled. In order to add a new continues, however an entry is created in the log file. The log
specimen you have to select the type of the tissue on which file is located in Matlab’s main directory and it monitors all
the biopsy is taking place and the study that the particular the overrides that have been occurred in the database.
biopsy is part of.
VI. MATLAB CODE
% filename: string of filename and it's location
%Imports data into MYSQL database from Matlab.
% Host and database can me modified
% default: host='studydb.obgyn.arizona.edu';
% database='use sandbox';
Fig. 10. Add specimen screen for a patient in the OBGYN database. % Stylianos Andreou
% University of Arizona, March 2005
Once you add the specimen an id number is generated
automatically. This id has to be used in the filename generated
%Host and Database
during the spectroscopy measurement. host='studydb.obgyn.arizona.edu';
%You need to have this in your file
%retrieve user's login & pass
login = input('login:','s');
pass = input('password: ','s');
% Connect to a database.
Fig. 11. Specimen Listing screen for a patient in the OBGYN database. mysql('open',host,login,pass);
% Check the database status.
% Select Database
There two ways to interface Matlab with a database. One way mysql(database);
is to use the Database toolbox that comes with Matlab. The
other approach is to write a client program, a dll file, which %retrieve the ID of the user
implements the specific MySQL protocol. Then you can
execute queries using standard Structured Query Language %convert ID to MYSQL ID
For the purposes of this project a MySQL client  for Matlab
%check if the patient exist
that handles the interaction was used. patientexist=mysql(['select ID from patient where
if (isempty(patientexist)== 1)
error(['Patient "' num2str(id), '" does not
V. MATLAB exist. You can only modify fields in existing
The filename is given during the spectroscopy measurement end
and it follows a standard form (ex. “O_FL_23640A.eem”). %retrieve tissue ID
The initial letters “O_FL_” correspond to the type of the tissueid=filename(9:length(filename)-5);
measurement and the next 3 digits correspond to patient’s id.
%check if the biopsy exist
The next two digits are for the measurement number and the tissueidexist=mysql(['select ID from specimen where
last letter correspond to measurement’s location on the ID="',num2str(tissueid),'" &&
specimen. Once the filename is given the Matlab function can PATIENT_ID="',num2str(id),'"']);
identify and create the necessary fields into the database. %Give error if does not
Using exportdb(“filename.eem”) it will automatically connect if (isempty(tissueidexist)== 1)
to the database add the patient and then close the connection
AHSC OBGYN Database 4
error(['Biopsy "' num2str(tissueid), '" does between the database’s increasing id and hardcopies (1000 →
not exist for Patient "' num2str(id), '". You can
only modify fields in existing biopsies"']); 200).
end A future expansion of the database to cover a future
%Retrive measurement's location research in animals will require access in the source code of
location=filename(11); the web interface which is not available at the moment.
%Check if the current location exist
The history record needs to be updated to accept the age of
fileid=mysql(['select ID from measurement where the patient. Again an access to the web interface source code
SPECIMEN_ID="',num2str(tissueid),'" && is needed.
A function/interface for exporting data from the database
%if current location exist create a log entry for analysis and statistical purposes is under development.
if (isempty(fileid)== 0)
%retrieve existing file location
IMAGE_FILE_LOCATION from measurement where
ID="',num2str(fileid),'"']);  “MySQL and Matlab”
%give a warning message
disp('Warning: An entry existed for this
location and has been replaced')
ovdate = date;
%retrieve the study for this measurement
studyid=mysql(['select study_id from
specimen where PATIENT_ID="',num2str(id),'" &&
study=mysql(['select study_number from
study where ID="',num2str(studyid),'"']);
%retrieve the tissue for this measurement
biopsyid=mysql(['select tissue_id from
specimen where PATIENT_ID="',num2str(id),'"&&
biopsy=mysql(['select NAME from tissue
%update log file
f = fopen('studydblog.txt','a');
fprintf(f,[ovdate ': For patient
(',num2str(id),') in ',char(study), ' '
,char(biopsy), ' location ',location, ' replaced
file n' ,oldfilename, ' with ' ,[StartDir
%import the new file location for this
measurement into MYSQL
filelocation=['update measurement set
IMAGE_FILE_LOCATION="',[StartDir filename],'" where
%otherwise add new measurement for that location
mysql(['insert into measurement
%end current session
All the patients must be added in the database from the
beginning because patients must be in the database even if
they do not exist in the hardcopies in order to have a relation