Phase 4 - Final Report
Phase 4 - Final Report
Phase 4 - Final Report
Contents
1
2.1
2.2
2.3
Domains ........................................................................................................................................ 4
2.4
Database Scripts............................................................................................................................ 7
3.2
Database Usage........................................................................................................................... 10
Description
Medical staff that directly uses the EMR such as Doctor, Secretary, or Medical Assistant.
The client being treated, tested, or otherwise handled by the User(s) during a Visit.
Visit
Record
Digitally recorded information regarding a single patient Visit. Includes notes and metrics like
patient vitals.
Referral
An optional component of a given record. If needed, the Doctor may refer the patient to an
outside business for a therapy, lab, x-ray, or other medical service.
2.1.1 User
2.1.2 Visit
2.1.3 Patient
2.1.4 Record
2.1.5 Referral
A referral contains a set of vitals taken from the patient during the visit
A referral references a record
A referral can be (disjoint) types: Lab, X-Ray, or Therapy
2.3 Domains
The domains for every attribute in the EMR model are shown below, categorized by data type.
Establishing and adhering to well-defined attribute domains is crucial to a well-constructed database with
domain integrity.
2.3.1 Keys
All key attributes below were implemented at the database level using unique integer objects.
User: id, secretary_id [fk], ma_id [fk], doc_id [fk]
2.3.2 Decimals
All decimal attributes below were implemented at the database level using float objects.
Record: weight, height, BMI, heartRate, bloodPressure, pulseOxidation, temperature
2.3.3 Text
All text attributes below were implemented at the database level using varchar objects.
User: name (Last), name (First), password, userType
Patient: name (Last), name (First), phone (home), phone (cell)
Record: reason, physicianNotes
Referral: businessName, referralType
2.4.1 Normalization
All tables in Figure 3 satisfy 2NF in that every tables non-key attributes are fully functionally dependent
on the tables primary key. All tables satisfy 3NF in that they satisfy 2NF and contain no transitive
dependencies.
VALUES
('2014-11-19 20:27:30', TRUE,
(SELECT idUser FROM User WHERE fName='Phil' AND lName='McGraw' AND userType='Doctor'),
(SELECT idPatient FROM Patient WHERE fName='James' AND lName='Cary' AND dob='1991-09-09')
);
INSERT INTO Visit
(dt, isAppt, fkStaff, fkPatient)
VALUES
('2014-11-20 20:27:30', TRUE,
(SELECT idUser FROM User WHERE fName='Lexi' AND lName='Cox' AND userType='MedicalAssistant'),
(SELECT idPatient FROM Patient WHERE fName='Andrew' AND lName='Watson' AND dob='1991-06-26')
);
INSERT INTO Visit
(dt, isAppt, fkStaff, fkPatient)
VALUES
('2014-11-21 20:27:30', TRUE,
(SELECT idUser FROM User WHERE fName='Lexi' AND lName='Cox' AND userType='MedicalAssistant'),
(SELECT idPatient FROM Patient WHERE fName='Kyle' AND lName='McCleary' AND dob='1991-06-26')
);
-- Kyle's second appointment is a walkin (isAppt = false)
INSERT INTO Visit
(dt, isAppt, fkStaff, fkPatient)
VALUES
('2014-11-22 20:27:30', FALSE,
(SELECT idUser FROM User WHERE fName='Snookie' AND lName='Snook' AND userType='Secretary'),
(SELECT idPatient FROM Patient WHERE fName='Kyle' AND lName='McCleary' AND dob='1991-06-26')
);
-- Insert a record per visit
INSERT INTO Record
(reason, notes, weight, height, bmi, hr, bp, pulseOx, temp, fkVisit)
VALUES
("Standard checkup", "vitals good", 160.0, 6.0, 18.0, 60, 120, 0.97, 98.6,
(SELECT idVisit FROM Visit WHERE dt='2014-11-18 20:27:30')
);
INSERT INTO Record
(reason, notes, weight, height, bmi, hr, bp, pulseOx, temp, fkVisit)
VALUES
("Regular checkup", "patient healthy. advised to quit vaping.", 150.0, 5.9, 20, 70, 122, 0.98, 98.0,
(SELECT idVisit FROM Visit WHERE dt='2014-11-19 20:27:30')
);
INSERT INTO Record
(reason, notes, weight, height, bmi, hr, bp, pulseOx, temp, fkVisit)
VALUES
("knee pain", "recurring knee pain follow-up", 180.0, 6.0, 20, 65, 118, 0.98, 98.5,
(SELECT idVisit FROM Visit WHERE dt='2014-11-20 20:27:30')
);
INSERT INTO Record
(reason, notes, weight, height, bmi, hr, bp, pulseOx, temp, fkVisit)
VALUES
("6 month checkup", "patient complained of fever", 215, 6.3, 19.0, 85, 125, 0.99, 102.0,
(SELECT idVisit FROM Visit WHERE dt='2014-11-21 20:27:30')
);
INSERT INTO Record
(reason, notes, weight, height, bmi, hr, bp, pulseOx, temp, fkVisit)
VALUES
("fever follow-up", "Fever still high. Referring to Fever Specialists", 215, 6.3, 19.0, 85, 125, 0.99, 104,
(SELECT idVisit FROM Visit WHERE dt='2014-11-22 20:27:30')
);
-- Insert a referral for Kyle. He needs to see a specialist
INSERT INTO Referral
(dt, businessName, referralType, fkVisit)
VALUES
(NOW(), "Fever Specialists", "General",
(SELECT idVisit FROM Visit WHERE dt='2014-11-22 20:27:30')
);
Figure 5 - Example Column Options shows the sort of options that are necessary when populating the
attributes of types INT, BOOL, and DATETIME. Other options included VARCHAR() and BLOB for text DATE
for dates, and FLOAT for various patient vitals.
Figure 6 - Example Foreign Keys Options shows the mapping of foreign keys with cascading options.
Figure 7 - Example Indexes Options shows the creation of necessary indices for mapping foreign keys to
primary keys.
Figure 10 - Patient Selection shows selection of patients by lName, dob (2 results), and phoneHome.
Figure 11 - Visit Selection shows the visits that occurred later than 2014-11-20. Note that the first result
has a timestamp later than the assumed 00:00:00.
Figure 12 - Advanced Patient/Visit interaction shows the retrieval of the full name of patients whose DOB
is 1991-06-26 and have had at least one visit.
Figure 14 - Love Triangle Part 2 shows the epic conclusion of our story. Lexi, having rocked Phils socks just
days before his marriage to Snookie, quits in outrage after her demotion to secretary.
enough to get us to the point of being able to create our schemas. Workbench proved to be a very handy
tool for us as it aided in the creation of not only our schema but also the population and query scripts to
verify proper database functionality. After the scripts were created and the database populated we then
were able to go back and create ERD diagrams with the software to ensure everything was implemented
correctly and that we had followed all of our project guidelines and business rules.
One of the most frustrating parts of the project, as is true with most group projects, was the
coordination of the group members in order to meet project deadlines. However this was a very small
price to pay for the valuable knowledge we gained in learning about MySQL and the workbench software.
Going through all the database creation steps from schema modeling to front-end application
development has helped all of us in understanding of the material learned in the course, and should help
even more outside the classroom. Had we started the process back in September we probably would have
started using the MySQL software from the very first phase of the project. The software can be an
immensely powerful tool in the modeling of a database as much as it is in its creation.