SlideShare uma empresa Scribd logo
1 de 30
FirstCare Medical Center
Marissa Maturo, Davian Nolan, Joseph O’Donohue, Tyreik Williams
Group 9
Table of Contents
Executive Summary.................................................................................................................................................................................... 3
Entity Relationship Diagram ...................................................................................................................................................................... 4
Data Dictionary........................................................................................................................................................................................... 5
Employee Entity..........................................................................................................................................................................................................................................................5
Physician Entity...........................................................................................................................................................................................................................................................6
Patient Entity................................................................................................................................................................................................................................................................7
Nurse Entity ..................................................................................................................................................................................................................................................................8
Pharmacist Entity.......................................................................................................................................................................................................................................................8
Prescription Entity.....................................................................................................................................................................................................................................................9
Drug Entity..................................................................................................................................................................................................................................................................10
DrugOrder Entity.....................................................................................................................................................................................................................................................11
Vendor Entity.............................................................................................................................................................................................................................................................11
MedicalCenter Entity..............................................................................................................................................................................................................................................12
Administrator Entity ..............................................................................................................................................................................................................................................12
Appointment Entity ................................................................................................................................................................................................................................................13
Assignment Entity ...................................................................................................................................................................................................................................................14
SQL Transact............................................................................................................................................................................................. 15
Queries (A-H) - Test Cases on FirstCare Medical Center’s New Database Management System. ........................................................................................15
Davian’s Query......................................................................................................................................................................................................................................................22
Tyreik’s Query.......................................................................................................................................................................................................................................................23
Marissa’s Query........................................................................................................................................................................................Error!Bookmarknot defined.
Joe’s Query..............................................................................................................................................................................................................................................................24
Table Definitions......................................................................................................................................................................................................................................................24
Executive Summary
Dr. Robert Slate is the owner and President of FirstCare Medical Centers, Inc, a small chain of medical centers in Alcoa, Florida. The
company was originally founded as a single center five years ago, but has since expanded to four centers in five years. The centers act as a middle
ground between traditional physician practices and hospital emergency rooms. Most of the patients treated at FirstCare make appointments in
advance but walk-in patients are also accepted if time slots are available. The centers are open from 9am to 7pm Monday through Friday and are
closed on weekends and holidays.
As the size of the business has increased, Dr. Slate decided it is time to automate the way his centers do business to maximize efficiency and
keep up with insurance company and government requirements. He has requested an automated system be created to track and maintain
personnel and patient information as well as a number of other functions. The systemwill need to be able to print the following: a weekly schedule
for each doctor, daily appointment schedules for each center, and patient profile cards. The systemwill also need to track total revenues generated
by medical care appointments and total expenditures for items purchased through wholesale vendors as well as enabling direct mail marketing of
targeted patients. For customers upon request it would need to provide itemized yearly lists of medical care (appointment) expenses and also
prescription purchases for income tax reporting purposes. For the pharmacy at the medical centers the systemwould need to automatically
generate prescription numbers and prices and record all information associated with the filing of the prescription, generate prescription labels and
patient receipts for the medications dispended, and generate detailed customer receipts (appointment or prescription) for insurance claims when
applicable. Also, it must generate a daily dispended drug log and a separate log of dispensed controlled substances, which must be kept to meet
DPR and DEA requirements. Also, to generate drug reorder reports for items that have fallen below their minimum stock amounts, help prevent
pharmacist and nurse licenses fromexpiring without being noticed.
Entity Relationship Diagram
Employee
MedCenter
Assignment Physician
Administrator
Appointment
Patient
Nurse
Pharmacist
Vendor
DrugOrder
Prescription
Drug
EmployeeSSN
EmployeeType
EmployeeFirstName
EmployeeMiddleInitial
EmployeeLastName
EmployeeStreetAddress
EmployeeCity
EmployeeZipCode
EmployeeState
EmployeePhoneNumber
MedCenterIDPK
MedCenterName
MedCenterAddress
MedCenter_Phone
AdminIDFK
AssignmentDate
AssignmentStart
AssistmentEnd
PhysicianDEANumberPK
PhysicianFirstName
PhysicianLastName
PhysicianSpecialty
PhysicianPagerNumber
AdminIDPK
AdminJobTitle
EmployeeIDFK
ApptIDPK
ApptDuration
ApptCharge
ApptReason
ApptTime
PatientIDPK
PatientInsuranceStatus
PatientFirstName
MedCenterIDFK
PatientLastName
PatientZipCode
PatientCity
PatientStreetName
PatientState
PatientPhoneNumber
NurseLicNumberPK
EmployeeIDFK
NurseLicExpDate
PharmacistLicNumberPK
EmployeeIDFK
PharmacistLicExpDate
VendorIDPK
VendorName
VendorPhoneNumber
DrugOrderIDPK
DrugOrderDate
DrugOrderCost
PrescriptionIDPK
PrescriptionInstructions
PrescriptionQuantity
DrugNDCNumberPK
DrugNameStrength
DrugUse
PrescriptionPriceCharged
DrugLegalClass
DrugAWP
DrugUnit
DrugSize
VendorFaxNumber
DrugOrderActualCost
DrugOrderArrivalDate
VendorIDFK
AssignmentIDPK
MedCenterIDFK
DrugNDCNumberFK
PatientIDFK
PhysicianDEANumberFK
PatientIDFK
PhysicianDEANumberFK
PhysicianDEANumberFK
EmployeeIDPK
PharmacistLicNumberFK
DrugActualQty
DrugInvenMin
DrugOrderQty
DrugOrderDeliveredQty
DrugNDCNumberFK
Data Dictionary
Employee Entity
Entity Description: Personnel employed by the FirstCare Medical Center. No employee works at more than one center.
ColumnName ColumnDescription Data
Type
Data
Format
Field
Size
Example Primary
Key
Nullable Unique FK References
Employee_ID A unique 5-digitidentifier
assignedtoeachemployee.
Integer ####### 7 12345 TRUE FALSE TRUE
EmployeeSSN A unique nine digitidentifier
issuedtoindividualsbythe Social
SecurityAdministration.
Varchar ###-##-#### 11 123-82-397 FALSE FALSE TRUE
EmployeeFirstName The employee’slegal firstname Varchar 50 John FALSE FALSE FALSE
EmployeeMiddleInitial The firstletterof an employee’s
middle name.
Varchar 1 A FALSE TRUE FALSE
EmployeeLastName The legal lastname of an
employee.
VarChar 50 Smith FALSE FALSE FALSE
EmployeeStreetAddress The streetaddressof an
employee’shome orapartment.
Varchar 60 275 Mount
Carmel
Avenue
FALSE FALSE FALSE
EmployeeCity The city where the employee’s
streetaddressislocated
Varchar 25 Hamden FALSE FALSE FALSE
EmployeeState The State where anemployee’s
residence islocated.
Varchar 2 CT FALSE FALSE FALSE
EmployeeZipCode A five digitpostal code issuedby
USPS,it determinesthe exact
geographical areaof an
employee’sresidence
Varchar 5 06492 FALSE FALSE FALSE
EmployeePhone A mobile andorlandline phone
numberthatcan be usedto
contact an employee.
Varchar (###)###-
####
14 (203)-518-
0000
FALSE FALSE FALSE
Physician Entity
EntityDescription:AnindividualcontractedbyFirstCare whoisqualifiedandlicensedtopractice medicine inthe state. Physiciansare notconsideredemployees
of FirstCare Medical, they are independent contractors.
ColumnName ColumnDescription Data
Type
Data
Format
Field
Size
Example Primary
Key
Nullable Unique FK
References
PhysicianDEANumber ID assignedtolicensedphysicians
by the Federal DrugEnforcement
Administration.The firstletteris
alwaysA or B and the second
letteristhe firstletterof the
physician’slastname.
Varchar AC####### AC####### TRUE FALSE TRUE
PhysicianFirstName The employee’sfull legal first
name.
Varchar 75 John FALSE FALSE FALSE
PhysicianLastName The last name of the physician. Varchar 25 Craig FALSE FALSE FALSE
PhysicianPagerNumber The Physician’sassignedpager
number.
Varchar ###-##-
####
11 932-33-
2934
FALSE FALSE TRUE
PhysicianSpecialty Branchesof medicine,which a
physicianisanexpert.
Varchar 50 Cardiology,
Orthopedist
FALSE FALSE FALSE
Patient Entity
Entity Description: The patients that come into be treated at FirstCare Medical Center.
ColumnName ColumnDescription Data
Type
Data
Format
FieldSize Example Primary Key Nullable Unique FK
References
PatientID A unique six digitidentifier
assignedonce toeach
patient.The firstdigit the
FirstCare centerthe patient
was firstseen.
Varchar 123456 6 123456 TRUE FALSE TRUE
PatientInsurnceStatus Yes or No Varchar Yes 3 Yes FALSE FALSE FALSE
PatientFirstName The personal andor legal
name usedbefore the last
name
Varchar 20 John FALSE FALSE FALSE
PatientLastName The surname of the patient Varchar Smith FALSE FALSE FALSE
PatientStreetName The streetaddressof the
patient’shome
Varchar 25 275
Mount
Carmel
Ave
FALSE FALSE FALSE
PatientCity The city where the patient
lives
Varchar 20 Hamden FALSE FALSE FALSE
PatientState The state where the
patientlives
Varchar 2 CT FALSE FALSE FALSE
PatientZipCode The zip code of where the
patientlives
Varchar 5 06518 FALSE FALSE FALSE
PatientPhoneNumber The phone numberof the
patienteithermobile or
landline.
Varchar 10 (203) 123-
4434
FALSE FALSE FALSE
Nurse Entity
Entity Description: Registered nurse that FirstCare employs. FirstCare keeps track of the employee’s RN license number and expiration date to
ensure they don’t expire. The license needs to be renewed every two years.
ColumnName ColumnDescription Data
Type
Data
Format
Field
Size
Example Primary Key Nullable Unique FK
References
NurseLicNumber A personwhoistrainedand
licensedtocare for the sickor
infirm
Varchar RN####### 9 123-82-397 TRUE FALSE TRUE
NurseLicExpDate Nurse’slicenseexpirationdate Date YYYY-MM-
DD
2013-02-12 FALSE FALSE FALSE
MedCenterID The centerwhere the nurse is
assignedtowork.
Varchar 1 3 FALSE FALSE TRUE MedCenter
Entity
EmployeeID A unique 5digitidentifierassigned
to each employee.
Integer ###### 5 12345 FALSE FALSE TRUE Employee
Entity
Pharmacist Entity
Entity Description: On site employee who is licensed and authorized to fill prescriptions for patients of FirstCare Medical
ColumnName ColumnDescription Data
Type
Data
Format
Field
Size
Example Primary Key Nullable Unique FK
References
PharmacistLicNumber A nine characteralpha-numeric
identifierassignedbythe
Departmentof Professional
Regulation. ItstartswithPS.
Varchar PS####### 9 123-82-397 TRUE FALSE TRUE
PharmacistLicExpDate The Pharmacist’sLicense Expiration
date
Date YYYY-MM-
DD
2014-02-14 FALSE FALSE FALSE
MedCenterID The centerwhere the nurse is
assignedtowork.
Varchar 1 3 FALSE FALSE TRUE MedCenter
Entity
EmployeeID A unique 5digitidentifierassigned
to each employee.
Integer ###### 5 12345 FALSE FALSE TRUE Employee
Entity
Prescription Entity
Entity Description: Prescription order filled by a pharmacist for a patient as prescribed by a physician.
ColumnName ColumnDescription Data
Type
Data
Format
Field
Size
Example Primary
Key
Nullable Unique FK
References
PrescriptionID Starts withthe lettersignifying
whichof the centerpharmacies
filledthe prescription.(A=1,
B=2, C=3, D=4) followedbya
five digitsequential number
Varchar A##### 6 A00003 TRUE FALSE TRUE
PrescriptionInstructions Instructionsonuse forthe
prescription
Varchar 100 Apply
topical
cream to
chest
only.
FALSE FALSE FALSE
PrescriptionQuantity Numberof the drugs dispensed. Varchar XXX FALSE FALSE FALSE
PrescriptionPriceCharged Wholesale costof the
medicationplusa$3 dispensing
fee.Formedicationsthatdonot
require aprescription,the price
iswholesale costplus30%.
Varchar $XXXX.XX FALSE FALSE FALSE
DrugNDCNumber A numberassignedbydrug
manufacturersthatshows the
manufacturercode,product
code,and package code.
Varchar 11 1234-
5678-911
TRUE FALSE TRUE Drug Entity
PatientID Patientthatthe prescriptionis
beingfilledfor
Varchar 6 PatientEntity
PhysicianDEANumber ID assignedtolicensed
physiciansbythe Federal Drug
EnforcementAdministration.
The firstletterisalwaysA or B
and the secondletteristhe first
letterof the physician’slast
name.
Varchar AC####### AC#####
##
FALSE FALSE TRUE Physician
Entity
PharmacistLicNumber A unique setof numberthat
Identifythe pharmacist
Varchar 9 Pharmacist
Entity
Drug Entity
Entity Description: Description of drugs carried by the FirstCare Medical Centers pharmacy
ColumnName ColumnDescription Data
Type
Data
Format
Field
Size
Example Primary Key Nullable Unique FK
References
DrugNDCNumber A numberassignedbydrug
manufacturersthatshowsthe
manufacturercode,productcode,
and package code.
Varchar 11 1234-5678-
911
TRUE FALSE TRUE
DrugNameStrength The drug name and strength Varchar Drug name,
strength
25 Zoloft, 50
mg
FALSE FALSE FALSE
DrugUse Antibiotic,analgesic,
antihypertensive,etc.
Varchar 25 Antibiotic FALSE FALSE FALSE
DrugLegalClass LabeledasOTC, prescriptiononly,
controlled substance (subclass
listed)
Varchar N-# 3 C-2 FALSE FALSE FALSE
DrugAWP Each drug’s average wholesale
price
Decimal FALSE FALSE FALSE
DrugUnit Tablet,gram,milliliter,etc Decimal (10,2) mg FALSE FALSE FALSE
DrugSize Package size Decimal (10,2) 25 FALSE FALSE FALSE
DrugActualQty How muchof eachdrug is instock
at any time.
Integer 5 30 FALSE FALSE FALSE
DrugInvenMin The minimumlevelof eachdrug
that mustbe instock at all times.
Integer 5 20 FALSE FALSE FALSE
DrugOrder Entity
Entity Description: Drug orders sent to vendors for FirstCare Medical Center’s pharmacies
ColumnName ColumnDescription Data
Type
Data
Format
Field
Size
Example Primary Key Nullable Unique FK
References
DrugOrderID An alpha-numericidentifier
assignedtoeachorder
Varchar # - #### 1-1234 TRUE FALSE TRUE
DrugOrderCost Cost of the drug order. Money 4 FALSE FALSE FALSE
DrugOrderDate Date the drugsare ordered. Date MM-DD-
YYYY
2014-12-02 FALSE FALSE FALSE
DrugOrderQty The numberof packagesof each
drug that isordered.
Integer FALSE FALSE FALSE
DrugOrderDeliveredQty The numberof packagesof each
drug delivered
Integer FALSE FALSE FALSE
DrugOrderArrivalDate The date that the dug order
arrived.
Date MM-DD
YYYY-
11 2015-12-09 FALSE FALSE FALSE
DrugOrderActualCost The actual cost of the drug order. Money FALSE FALSE FALSE
VendorID Each vendorisassigneda unique,
sequential,VendorIDnumber.
Varchar N# TRUE FALSE TRUE Vendor
Entity
Vendor Entity
Entity Description: Information about the Vendors used to fill Drug Orders.
Column Name Column Description Data Type Data Format Field
Size
Example Primary Key Nullable Unique FK References
VendorID Each vendor is assigned a unique,
sequential,Vendor ID number.
Varchar N# TRUE FALSE TRUE
VendorName The company name of the
vendor.
Varchar NNNNN 30 Johnson
Drug
Company
FALSE FALSE FALSE
VendorPhoneNumber The vendor’s phone number Varchar ### - ### -
####
12 293-483-
4839
FALSE FALSE FALSE
VendorFaxNumber The vendor’s fax number Varchar ### - ### -
####
12 223-342-
4928
FALSE FALSE FALSE
MedicalCenter Entity
Entity Description: Building where health care, research, staff support, and ancillary services are provided.
ColumnName ColumnDescription Data
Type
Data
Format
Field
Size
Example Primary
Key
Nullable Unique FK References
MedCenterID Each of the four FirstCare centershas
a unique CenterIDnumbered1-4
Varchar 1 4 TRUE FALSE TRUE
MedCenterName The name of the medical center Varchar 30 Alcoa FirstCare
Medical Center
FALSE FALSE FALSE
MedCenterAddress The physical addressof the medical
center.
Varchar 25 35 Smith
Street, West
Palm, FL
FALSE FALSE FALSE
MedCenterPhone The medical center’sphone number Varchar 12 641-348-8837 FALSE FALSE FALSE
AdminID A unique nine digitidentifierissuedto
the administratorof eachmedical
center.Each centerhas onlyone
administrator
Varchar ##-#### 5 34631 FALSE FALSE TRUE Administrator
Entity
Administrator Entity
Entity Description: Each center has one administrator for each center.
ColumnName ColumnDescription Data Type Data Format Field
Size
Example Primary
Key
Nullable Unique FK References
AdminID Administrator’sIDthatisunique to
them
Varchar 5 TRUE FALSE TRUE
AdminJobTitle Specificjobtitle (manager,clerk,
receptionist,etc)
Varchar 20 FALSE FALSE FALSE
EmployeeID A unique 5-digitidentifierassigned
to each employee.
Integer ####### 7 12345 FALSE FALSE TRUE Employee Entity
MedCenterID The MedCenterIDof whichthe
Administratorworks
Varchar 1 3 FALSE FALSE FALSE MedicalCenter
Entity
Appointment Entity
Entity Description: Appointments made by patients to be seen at FirstCare Medical Center
ColumnName ColumnDescription Data Type Data
Format
Field
Size
Example Primary Key Nullable Unique FK
References
ApptID The firstdigitisthe centernumber
the appointmentwasmade for
and the nextsix digitsare assigned
sequentially.
Varchar 1234567 7 1234567 TRUE FALSE TRUE
ApptDuration The durationof the appointment Varchar 50 2 15 minutes FALSE FALSE FALSE
ApptTime The time of the appointment.
Appointmentsare made inhalf
hour increments
Time HH:MM:
SS
01:12:00 FALSE FALSE FALSE
ApptCharge Typical fixedfee ofrappointmet is
$35. Sometimesthe center
managermay increase fee fora
longerthantypical appointment.
All deesare the direct
responsibilityof the patient.
smallmoney $XXX.XX 3 $35 FALSE FALSE FALSE
ApptReason Reasonwhythe patientis
schedulingthe appointment.
Varchar 50 Sore
throat,
stuffy nose
FALSE FALSE FALSE
PatientID A unique six digitidentifier
assignedonce toeach patient.The
firstdigit the FirstCare centerthe
patientwasfirstseen.
Varchar 123456 6 123456 FALSE FALSE TRUE Patient
Entity
PhysicianDEANumber ID assignedtolicensedphysicians
by the Federal DrugEnforcement
Administration.The firstletteris
alwaysA or B and the second
letteristhe firstletterof the
physician’slastname.
Varchar AC#####
##
AC####### FALSE FALSE TRUE Physician
Entity
Assignment Entity
Entity Description: The assignments each Physician has for the day.
ColumnName ColumnDescription Data
Type
Data Format Field
Size
Example Primary Key Nullable Unique FK
References
AssignmentID A unique 7digitnumberthat
identifieseachphysician’sdaily
assignment.Theycanbe assigned
to more than one medcenterper
day.
Integer ####### 7 1234567 TRUE FALSE TRUE
AssignmentDate The date of the physician’s
assignments
Date YYYY-MM-DD 2014-12-
01
FALSE FALSE FALSE
AssignmentStart The start time of the assignment Time HH:MM:SS 10:30:00 FALSE FALSE FALSE
AssignmentEnd The time the assignmentshould
be finished.
Time HH:MM:SS 11:00:00 FALSE FALSE FALSE
MedCenterID The medical center’sID(numbers
1-4)
Varchar 1 1 FALSE FALSE FALSE Medical
Center Entity
PhysicianDEANumber ID assignedtolicensedphysicians
by the Federal DrugEnforcement
Administration.The firstletteris
alwaysA or B and the second
letteristhe firstletterof the
physician’slastname.
Varchar AC####### 9 AC12345
67
TRUE FALSE TRUE Physician
Entity
SQL Transact
Queries (A-H) - TestCaseson FirstCare Medical Center’sNewDatabase Management System.
Below were some of the test cases utilized by the systemdevelopers, where a set of conditions were employed to test the database and its
functionality in the FirstCare Medical business environment. These tests gave the developers insight and answered the question: did the new
system fulfill the business requirements outlined by Mr. Slate and FirstCare Medical, and are the features developed working at their optimum level?
To be assured that all business requirements were met, our systemdesign team decided that it would be best to perform at least two test cases on
each functional requirement.
If you (Mr. Slate) or any member of your team or organization has any questions or concerns about the new system, please do not hesitate to
contact us. It was a great pleasure working with FirstCare and we truly hope that we fulfilled your business needs.
Query A- Use ofan Aggregate Function
Case: Shannon in the billing department needs to submit a claimto the insurance company. The claimis for Norma Howard, a regular patient at
FirstCare. Her PatientID is 123458. Please find the amount she was billed for each appointment, and the PhysicianDEANumber /s of the Doctor /s
who treated her.
What is the total dollar amount of the claim we must submit to Aetna?
Marissa’s Unique Query
To meet growing demand for FirstCare Medical services, Mr. Slate is planning on opening another medical center. His team needs to know the total
number of licensed physicians and pharmacists that are currently on staff.
Query B- Usesan Outer Join
The DEA has accused a FirstCare Medical physician of illegally prescribing Xanax for his friends and not his patients. They look to do a complete and
thorough investigation and charge this individual while withholding their name from the public. The DEA has ordered FirstCare to provide a list of
all patients treated at the facility; including the drugs they have been prescribed. The agency has stated that they will carefully analyze medical
record to find and any strange discrepancies. Please provide the DEA with the information they request.
Query C- Joins at least 3 tables
Richard’smotherLawandais onthe phone andwantsto knowthe name and the strengthof the drugthat her sonwasprescribed.She justgotfromher son’s
camp counselorthatherson isbehavingerraticallyandshe knowsit’snotlike himanditmustbe somethingthatone of our Physiciansgave him.Pleaseresearch
the drug Richardwas prescribed.She doesn’tthe name of the physicianhersonsaw,butshe doesknowthat hispatientIDnumberis ‘123456’. We cannot
affordanotherlawsuit,please findthe name,strengthandlegal class of the drugprescribed.
It seems it wasn’t the medication, Richard has problems.
Query D- Uses a sub query
When trying to use the system, it is essential to note that sub queries can be used as alternatives to joins. Below are cases of how this applies.
What is the First and Last name of the Patient with the ID Number 123488?
Well Mr. George Perkins is furious; he’s on the phone right now with a secretary demanding to speak to Mr. Slate. He says that he has been a
patient with FirstCare Medical Center since we opened and is claiming that we charged him an outlandish fee, far more than we charged anyone
else for a short 25-minute consultation. Is this true, did we really charge Mr. Perkins, one of our most loyal customers more than anyone else?
Mr. Slater would like to get in touch with the Physician who treated Mr. Perkins. Please find the name and pager number for the Doctor, Mr. Slater
needs to meet with him/ her in his office immediately.
Query E- Uses a SQL Function
SELECT PatientID from Patient Where PatientLastName Like ‘J%’ or PatientFirstName Like ‘J5’;
Query F- Contains at least 5 conditions
Yale University is doing a study on certain the insurance demographics in certain. They are reaching out to FirstCare Medical Center for data to use
within their research. They want to know the names and phone numbers of all uninsured patients located in HI or MI, live between zip codes 10000
and 80000, and also have their last name begin with the letter "M".
Query G- Utilizes a View
Query H- Creates a trigger
When pharmacists dispense medication, then need to update Drug levels for inventory purposes. This triggers an update.
SQL Trigger Code:
create trigger trigger_t09
on Prescription after insert
as
update Drug
set DrugActualQty= DrugActualQty- (select PrescriptionQty from inserted)
where Drug.DrugNDCNnumber =(select DrugNDCNnumber from inserted);
alter table Drug
alter column DrugActualQty decimal (10, 2);
alter table prescription
alter column PrescriptionQty decimal (10, 2);
alter table drug
alter column DrugInvMin decimal (10, 2);
select * from prescription
insert into Prescription
values ('#00999E', 'dont take with alcholo', 10 ,41.64, '66715-6843', '123459', 'XV123456', 14268);
SELECT * FROM DRUG
WHERE DrugNDCNnumber= '66715-6843'
Davian’s Query
Tyreik’s Query
The process of how drugs get administered by health care facilities has recently fascinated the Quinnipiac University Poll. They would like to know
what are top 10 most common drugs that are prescribed more than their average and the amount each how been prescribed.
CREATE VIEW PrescriptionsAbove Average AS
SELECT PrescriptionID,PrescriptionQuantity
FROMPrescription
WHERE PrescriptionQuantity>(SELECTAVG(PrescriptionQuantity)FROMPrescription);
CREATE VIEW top ten AS
SELECT PrescriptionID
FROM [Prescription Above Average]
Where PrescriptionQuantity>(SELECT top 10 FROM Prescription)
GROUP BY PrescriptionQuantity;
Joe’s Query
FirstCare Medical Center is under investigation by the DEA for illegally distributing Adderall, the only AntiHyper Intensive Drug they prescribe. The
DEA wants to know the first name, last name, and employee id of any pharmacist who placed an order for adderall with an average wholesale price
above $7000.
Table Definitions
Thissectionincludesthe code of all tablescreated,droppedandmodified.
Create Table Employee (
EmployeeIDvarchar(50) primarykeynot null,
EmployeeSSN varchar(100) UNIQUE not null,
EmployeeFirstName varchar(70) not null,
EmployeeMiddleInitial varchar(4),
EmployeeLastName varchar(70) not null,
EmployeeStreetAddressvarchar(100) not null,
EmployeeCityvarchar(100) notnull,
EmployeeStatechar(2) not null,
EmployeeZipvarchar(15) notnull,
EmployeePhonevarchar(30) notnull,
);
Create Table Pharmacist(
PharmacistLicNumvbervarchar(30) primarykeynot null,
PharmacistExpDate DATEnotnull,
EmployeeIDvarchar(50) not null,
foreignkey(EmployeeID) referencesEmployee (EmployeeID),
);
Create Table Physician(
PhysicianDEANumbervarchar(30) primarykeynotnull,
PhysicianNamevarchar(25) not null,
PhysicianLastName varchar(25) not null,
PhysicianPagerNumbervarchar(11) not null,
PhysicianSpecialtyvarchar(30) not null,
);
Create table MedicalCenter(
MedCenterIDintprimarykeynotnull,
MedCenterName varchar(30) notnull,
AdminIDvarchar(5) not null,
MedCenterAddressvarchar(25) not null,
MedCenterPhone varchar(12) not null,
foreignkey(AdminID) referencesAdministrator(AdminID),
);
Create table Administrator(
AdminIDvarchar(5) primarykeynotnull,
AdminJobTitle varchar(20) notnull,
MedCenterIDintnotnull,);
ALTER TABLE Administrator
ADD CONSTRAINTMedCenterIDFOREIGN KEY(MedCenterID)
REFERENCES MedicalCenter(MedCenterID),
);
Create table Nurse (
NurseLicNumbervarchar(9) primarykeynot null,
EmployeeIDintnotnull,
NurseLicExpDate DATEnotnull,
MedCenterIDintnotnull,
foreignkey(EmployeeID) referencesEmployee (EmployeeID),
foreignkey(MedCenterID) referencesMedicalCenter(MedCenterID),
);
Create table Patient(
PatientIDvarchar(6) primarykeynotnull,
PatientInsuranceBitnotnull,
PatientFirstName varchar(25) notnull,
PatientLastName varchar(25) notnull,
PatientStreetName varchar(25) not null,
PatientCityvarchar(25) not null,
PatientState varchar(2) not null,
PatientZipCode varchar(5) notnull,
PatientPhoneNumbervarchar(15)notnull),
;
Create table Assignment(
AssignmentIDintegerprimarykeynotnull,
AssignmentDateDateTimenotnull,
AssigntmentStarttime notnull,
AssignmentEndDateTime notnull,
MedCenterIDintnotnull,
PhysicianDEANumbervarchar(9) not null,
foreignkey(MedCenterID) referencesMedicalCenter(MedCenterID),
foreignkey(PhysicianDEANumber) referencesPhysician(PhysicianDEANumber),
foreignkey(MedCenterID) referencesMedicalCenter(MedCenterID)
);
Create table Appointment(
ApptIDintegerprimarykeynotnull,
ApptDurationtime notnull,
ApptTime time notnull,
ApptCharge moneynotnull,
ApptReasonvarchar(50) not null,
PatientIDvarchar(6) notnull,
PhysicianDEANumbervarchar(9) not null,
foreignkey(PatientID) referencesPatient(PatientID),
foreignkey(PhysicianDEANumber) referencesPhysician(PhysicianDEANumber)
);
Create Table Pharmacist(
PharmacistLicNumvbervarchar(30) primarykeynot null,
PharmacistExpDate DATEnotnull,
EmployeeIDvarchar(30) not null,
);
Create Table Physician(
PhysicianDEANumbervarchar(30) primarykeynotnull,
PhysicianNamevarchar(100) not null,
PhysicianLastName varchar(100) notnull,
PhysicianPagerNumbervarchar(25) not null,
PhysicianSpecialtyvarchar(30) not null,
);
Create table Patient(
PatientIDvarchar(25) primarykeynot null,
PatientInsuranceBitnotnull,
PatientFirstName varchar(100) not null,
PatientLastName varchar(100) not null,
PatientStreetName varchar(100) notnull,
PatientCityvarchar(100) notnull,
PatientState char(2) not null,
PatientZipCode char(5) notnull,
PatientPhoneNumbervarchar(25)notnull);
Create table Appointment (
ApptIDvarchar (25) primarykeynot null,
ApptDurationvarchar(25) not null,
ApptTime datetimenotnull,
ApptCharge moneynotnull,
ApptReasonvarchar(50) not null,
PatientIDvarchar(25) not null,
PhysicianDEANumbervarchar(30) not null,
foreignkey(PatientID) referencesPatient(PatientID),
foreignkey(PhysicianDEANumber) referencesPhysician(PhysicianDEANumber)
);
Create table Administrator(
AdminIDvarchar(25) primarykeynot null,
AdminJobTitle varchar(20) notnull,
MedCenterIDvarchar(25)notnull,);
Create table MedicalCenter
(MedCenterIDvarchar(25) primarykeynot null,
MedCenterName varchar(30) notnull,
AdminIDvarchar(25) not null,
MedCenterAddressvarchar(100) notnull,
MedCenterPhone varchar(25) not null,
foreignkey(AdminID) referencesAdministrator(AdminID)
);
ALTER TABLE Administrator
ADD CONSTRAINTMedCenterIDFOREIGN KEY(MedCenterID)
REFERENCES MedicalCenter(MedCenterID);
Create table Assignment(
AssignmentIDvarchar(30) primarykeynot null,
AssignmentDateDate notnull,
AssigntmentStartdate notnull,
AssignmentEndDate notnull,
MedCenterIDvarchar(25) not null,
PhysicianDEANumbervarchar(30) notnull,
foreignkey(MedCenterID) referencesMedicalCenter(MedCenterID),
foreignkey(PhysicianDEANumber) referencesPhysician(PhysicianDEANumber),
foreignkey(MedCenterID) referencesMedicalCenter(MedCenterID)
);
Create table Nurse (
NurseLicNumbervarchar(30) primarykeynotnull,
EmployeeIDvarchar(50) not null,
NurseLicExpDate DATEnotnull,
MedCenterIDvarchar(25) not null,);
create table Vendor(
VendorIDvarchar(10) primarykeynot null,
VendorName varchar(70) notnull,
VendorPhoneNumbervarchar(30) notnull,
VendorFaxNumbervarchar(30) null,
);
create table Drug (
DrugNDCNnumbervarchar(30) primarykeynotnull,
DrugNameStrengthvarchar(30) notnull,
DrugUse varchar(70) not null,
DrugLegalClassvarchar(10) notnull,
DrugAWPmoneynotnull,
DrugUnitvarchar(10) not null,
DrugSize decimal(10,2) notnull,
DrugActualQtyvarchar(20) not null,
DrugInvMinvarchar(20) notnull,
);
create DrugOrder(
DrugOrderIDvarchar(25) primarykeynotnull,
DrugOrderCostmoney(4) notnull,
DrugOrderDate date(11) notnull,
DrugOrderQtyvarchar (50) notnull,
DrugOrderDeliveredQtyvarchar(50) notnull,
DrugOrderArrivalDatedate(11) notnull,
DrugOrderActualCostmoney(4) notnull,
VendorIDvarchar(10) not null,
);
create table Prescription(
PrescriptionIDvarhar(6) primarykeynotnull,
PrescriptionInstructionsvarchar(100) notnull,
PrescriptionQuantityvarchar(3) not null,
PrescriptionPriceCharge varchar(8) notnull,
DrugNDCNNumbervarchar(11) not null,
PatientIDvarchar(25) not null,
PhysicianDEANumbervarchar(30) notnull,
PharmicistLicNumbervarchar(30) notnull,
);
Create table MedicalCenter(
MedCenterIDvarchar(25) primarykeynot null,
MedCenterName varchar(30) notnull,
AdminIDvarchar(25) not null,
MedCenterAddressvarchar(100) notnull,
MedCenterPhone varchar(25) not null
);

Mais conteúdo relacionado

Mais procurados

Hotel managementsystemcorrectfinalsrs
Hotel managementsystemcorrectfinalsrsHotel managementsystemcorrectfinalsrs
Hotel managementsystemcorrectfinalsrs
vidya_shankar
 
Airport flight schedule System UML diagrams
Airport flight schedule System UML diagramsAirport flight schedule System UML diagrams
Airport flight schedule System UML diagrams
uow
 
Future scope of alumni project
Future scope of alumni projectFuture scope of alumni project
Future scope of alumni project
Archana Deoli
 

Mais procurados (20)

Airline Management System [for presentation]
Airline Management System [for presentation]Airline Management System [for presentation]
Airline Management System [for presentation]
 
Airline Reservation System - Software Engineering
Airline Reservation System - Software EngineeringAirline Reservation System - Software Engineering
Airline Reservation System - Software Engineering
 
Hotel managementsystemcorrectfinalsrs
Hotel managementsystemcorrectfinalsrsHotel managementsystemcorrectfinalsrs
Hotel managementsystemcorrectfinalsrs
 
Online Examinition System
Online Examinition SystemOnline Examinition System
Online Examinition System
 
Travel and Tour Advisory
Travel and Tour AdvisoryTravel and Tour Advisory
Travel and Tour Advisory
 
Final Year Projects (Computer Science 2013) - Syed Ubaid Ali Jafri
Final Year Projects (Computer Science 2013) - Syed Ubaid Ali JafriFinal Year Projects (Computer Science 2013) - Syed Ubaid Ali Jafri
Final Year Projects (Computer Science 2013) - Syed Ubaid Ali Jafri
 
Android Security
Android SecurityAndroid Security
Android Security
 
Seminar report SMART HEALTH PREDICTION
Seminar report SMART HEALTH PREDICTIONSeminar report SMART HEALTH PREDICTION
Seminar report SMART HEALTH PREDICTION
 
Android Hacking
Android HackingAndroid Hacking
Android Hacking
 
TOURISM AND TRAVELLING MANAGEMENT SYSTEM
TOURISM AND TRAVELLING MANAGEMENT SYSTEMTOURISM AND TRAVELLING MANAGEMENT SYSTEM
TOURISM AND TRAVELLING MANAGEMENT SYSTEM
 
ONLINE VOTING SYSTEM FINAL.pptx
ONLINE VOTING SYSTEM FINAL.pptxONLINE VOTING SYSTEM FINAL.pptx
ONLINE VOTING SYSTEM FINAL.pptx
 
Airport flight schedule System UML diagrams
Airport flight schedule System UML diagramsAirport flight schedule System UML diagrams
Airport flight schedule System UML diagrams
 
Feasibility studytemplate
Feasibility studytemplateFeasibility studytemplate
Feasibility studytemplate
 
tour management system
tour management systemtour management system
tour management system
 
Presentation On Online Airline Ticket Booking Project Planning
Presentation On Online Airline Ticket Booking Project PlanningPresentation On Online Airline Ticket Booking Project Planning
Presentation On Online Airline Ticket Booking Project Planning
 
Online rto management system
Online rto management system Online rto management system
Online rto management system
 
Future scope of alumni project
Future scope of alumni projectFuture scope of alumni project
Future scope of alumni project
 
An Online Food Ordering Service
An Online Food Ordering ServiceAn Online Food Ordering Service
An Online Food Ordering Service
 
Three Level Security System Using Image Based Aunthentication
Three Level Security System Using Image Based AunthenticationThree Level Security System Using Image Based Aunthentication
Three Level Security System Using Image Based Aunthentication
 
Jenis Layanan & Macam Sistem Operasi Jaringan
Jenis Layanan & Macam Sistem Operasi JaringanJenis Layanan & Macam Sistem Operasi Jaringan
Jenis Layanan & Macam Sistem Operasi Jaringan
 

Destaque

Creating Data-driven Strategies to Improve Hospital Outcomes: A Case Manager'...
Creating Data-driven Strategies to Improve Hospital Outcomes: A Case Manager'...Creating Data-driven Strategies to Improve Hospital Outcomes: A Case Manager'...
Creating Data-driven Strategies to Improve Hospital Outcomes: A Case Manager'...
Conifer Health Solutions
 
ER DIAGRAM TO RELATIONAL SCHEMA MAPPING
ER DIAGRAM TO RELATIONAL SCHEMA MAPPING ER DIAGRAM TO RELATIONAL SCHEMA MAPPING
ER DIAGRAM TO RELATIONAL SCHEMA MAPPING
ARADHYAYANA
 

Destaque (12)

Creating Data-driven Strategies to Improve Hospital Outcomes: A Case Manager'...
Creating Data-driven Strategies to Improve Hospital Outcomes: A Case Manager'...Creating Data-driven Strategies to Improve Hospital Outcomes: A Case Manager'...
Creating Data-driven Strategies to Improve Hospital Outcomes: A Case Manager'...
 
Data dictionary
Data dictionaryData dictionary
Data dictionary
 
Data dictionaries
Data dictionariesData dictionaries
Data dictionaries
 
Information gathering interactive methods
Information gathering interactive methodsInformation gathering interactive methods
Information gathering interactive methods
 
Metadata lecture(9 17-14)
Metadata lecture(9 17-14)Metadata lecture(9 17-14)
Metadata lecture(9 17-14)
 
Data Dictionary
Data DictionaryData Dictionary
Data Dictionary
 
Data dictionary
Data dictionaryData dictionary
Data dictionary
 
What is a DATA DICTIONARY?
What is a DATA DICTIONARY?What is a DATA DICTIONARY?
What is a DATA DICTIONARY?
 
Systems Analyst and Design - Data Dictionary
Systems Analyst and Design -  Data DictionarySystems Analyst and Design -  Data Dictionary
Systems Analyst and Design - Data Dictionary
 
SAP ABAP data dictionary
SAP ABAP data dictionarySAP ABAP data dictionary
SAP ABAP data dictionary
 
Data dictionary
Data dictionaryData dictionary
Data dictionary
 
ER DIAGRAM TO RELATIONAL SCHEMA MAPPING
ER DIAGRAM TO RELATIONAL SCHEMA MAPPING ER DIAGRAM TO RELATIONAL SCHEMA MAPPING
ER DIAGRAM TO RELATIONAL SCHEMA MAPPING
 

Semelhante a 351_dbproject

Guidance for Industry Patient-Reported Outcome Measures: Use in Medical Produ...
Guidance for Industry Patient-Reported Outcome Measures: Use in Medical Produ...Guidance for Industry Patient-Reported Outcome Measures: Use in Medical Produ...
Guidance for Industry Patient-Reported Outcome Measures: Use in Medical Produ...
CRF Health
 
DRG_Registration_Form 20140826 shortened
DRG_Registration_Form 20140826 shortenedDRG_Registration_Form 20140826 shortened
DRG_Registration_Form 20140826 shortened
DEBRA ELLIOTT
 
Part 2-ACONDUCT A STRATEGIC GAP ANALYSIS AND IDENTIFY MAJOR ISSU.docx
Part 2-ACONDUCT A STRATEGIC GAP ANALYSIS AND IDENTIFY MAJOR ISSU.docxPart 2-ACONDUCT A STRATEGIC GAP ANALYSIS AND IDENTIFY MAJOR ISSU.docx
Part 2-ACONDUCT A STRATEGIC GAP ANALYSIS AND IDENTIFY MAJOR ISSU.docx
herbertwilson5999
 
Health Information Technology
Health Information TechnologyHealth Information Technology
Health Information Technology
Dillan Brewer
 
Running head John hopkins financial1John hopkins financial1.docx
Running head John hopkins financial1John hopkins financial1.docxRunning head John hopkins financial1John hopkins financial1.docx
Running head John hopkins financial1John hopkins financial1.docx
cowinhelen
 
Meaningful Use Step-By- Step
Meaningful Use Step-By- StepMeaningful Use Step-By- Step
Meaningful Use Step-By- Step
Carl Turso
 
Arm annual report_2014
Arm annual report_2014Arm annual report_2014
Arm annual report_2014
John Redaelli
 
Emerging Payment Models Whitepaper
Emerging Payment Models WhitepaperEmerging Payment Models Whitepaper
Emerging Payment Models Whitepaper
Ulrich Neumann, FRSA
 
Abc Rx Newsletter Emp
Abc Rx Newsletter EmpAbc Rx Newsletter Emp
Abc Rx Newsletter Emp
EPeralta210
 

Semelhante a 351_dbproject (20)

Interoperability: HIEs and the Future of Homecare
Interoperability: HIEs and the Future of HomecareInteroperability: HIEs and the Future of Homecare
Interoperability: HIEs and the Future of Homecare
 
Case 1 Report
Case 1 ReportCase 1 Report
Case 1 Report
 
Tk sample business plan
Tk   sample business planTk   sample business plan
Tk sample business plan
 
Guidance for Industry Patient-Reported Outcome Measures: Use in Medical Produ...
Guidance for Industry Patient-Reported Outcome Measures: Use in Medical Produ...Guidance for Industry Patient-Reported Outcome Measures: Use in Medical Produ...
Guidance for Industry Patient-Reported Outcome Measures: Use in Medical Produ...
 
DRG_Registration_Form 20140826 shortened
DRG_Registration_Form 20140826 shortenedDRG_Registration_Form 20140826 shortened
DRG_Registration_Form 20140826 shortened
 
Part 2-ACONDUCT A STRATEGIC GAP ANALYSIS AND IDENTIFY MAJOR ISSU.docx
Part 2-ACONDUCT A STRATEGIC GAP ANALYSIS AND IDENTIFY MAJOR ISSU.docxPart 2-ACONDUCT A STRATEGIC GAP ANALYSIS AND IDENTIFY MAJOR ISSU.docx
Part 2-ACONDUCT A STRATEGIC GAP ANALYSIS AND IDENTIFY MAJOR ISSU.docx
 
Anesthesia Business Consultants Summer 2014 Communique
Anesthesia Business Consultants Summer 2014 CommuniqueAnesthesia Business Consultants Summer 2014 Communique
Anesthesia Business Consultants Summer 2014 Communique
 
Anesthesia Business Consultants: Communique winter 2013
Anesthesia Business Consultants: Communique winter 2013Anesthesia Business Consultants: Communique winter 2013
Anesthesia Business Consultants: Communique winter 2013
 
A New Approach at Conducting Post-Market Drug Safety Surveillance
A New Approach at Conducting Post-Market Drug Safety SurveillanceA New Approach at Conducting Post-Market Drug Safety Surveillance
A New Approach at Conducting Post-Market Drug Safety Surveillance
 
Health Information Technology
Health Information TechnologyHealth Information Technology
Health Information Technology
 
2012 Small Employer Health Insurance Survey Ehealthinsurance
2012 Small Employer Health Insurance Survey Ehealthinsurance2012 Small Employer Health Insurance Survey Ehealthinsurance
2012 Small Employer Health Insurance Survey Ehealthinsurance
 
Running head John hopkins financial1John hopkins financial1.docx
Running head John hopkins financial1John hopkins financial1.docxRunning head John hopkins financial1John hopkins financial1.docx
Running head John hopkins financial1John hopkins financial1.docx
 
Evaluation & management for coding & billing
Evaluation & management for coding & billingEvaluation & management for coding & billing
Evaluation & management for coding & billing
 
Primary Health Care Systems: Thailand
Primary Health Care Systems: ThailandPrimary Health Care Systems: Thailand
Primary Health Care Systems: Thailand
 
Meaningful Use Step-By- Step
Meaningful Use Step-By- StepMeaningful Use Step-By- Step
Meaningful Use Step-By- Step
 
Anesthesia Business Consultants: Communique winter11
Anesthesia Business Consultants: Communique winter11Anesthesia Business Consultants: Communique winter11
Anesthesia Business Consultants: Communique winter11
 
Arm annual report_2014
Arm annual report_2014Arm annual report_2014
Arm annual report_2014
 
Emerging Payment Models Whitepaper
Emerging Payment Models WhitepaperEmerging Payment Models Whitepaper
Emerging Payment Models Whitepaper
 
Pharmacy management system Requirement Analysis and Elicitation Document
Pharmacy management system Requirement Analysis and Elicitation Document Pharmacy management system Requirement Analysis and Elicitation Document
Pharmacy management system Requirement Analysis and Elicitation Document
 
Abc Rx Newsletter Emp
Abc Rx Newsletter EmpAbc Rx Newsletter Emp
Abc Rx Newsletter Emp
 

351_dbproject

  • 1. FirstCare Medical Center Marissa Maturo, Davian Nolan, Joseph O’Donohue, Tyreik Williams Group 9
  • 2. Table of Contents Executive Summary.................................................................................................................................................................................... 3 Entity Relationship Diagram ...................................................................................................................................................................... 4 Data Dictionary........................................................................................................................................................................................... 5 Employee Entity..........................................................................................................................................................................................................................................................5 Physician Entity...........................................................................................................................................................................................................................................................6 Patient Entity................................................................................................................................................................................................................................................................7 Nurse Entity ..................................................................................................................................................................................................................................................................8 Pharmacist Entity.......................................................................................................................................................................................................................................................8 Prescription Entity.....................................................................................................................................................................................................................................................9 Drug Entity..................................................................................................................................................................................................................................................................10 DrugOrder Entity.....................................................................................................................................................................................................................................................11 Vendor Entity.............................................................................................................................................................................................................................................................11 MedicalCenter Entity..............................................................................................................................................................................................................................................12 Administrator Entity ..............................................................................................................................................................................................................................................12 Appointment Entity ................................................................................................................................................................................................................................................13 Assignment Entity ...................................................................................................................................................................................................................................................14 SQL Transact............................................................................................................................................................................................. 15 Queries (A-H) - Test Cases on FirstCare Medical Center’s New Database Management System. ........................................................................................15 Davian’s Query......................................................................................................................................................................................................................................................22 Tyreik’s Query.......................................................................................................................................................................................................................................................23 Marissa’s Query........................................................................................................................................................................................Error!Bookmarknot defined. Joe’s Query..............................................................................................................................................................................................................................................................24 Table Definitions......................................................................................................................................................................................................................................................24
  • 3. Executive Summary Dr. Robert Slate is the owner and President of FirstCare Medical Centers, Inc, a small chain of medical centers in Alcoa, Florida. The company was originally founded as a single center five years ago, but has since expanded to four centers in five years. The centers act as a middle ground between traditional physician practices and hospital emergency rooms. Most of the patients treated at FirstCare make appointments in advance but walk-in patients are also accepted if time slots are available. The centers are open from 9am to 7pm Monday through Friday and are closed on weekends and holidays. As the size of the business has increased, Dr. Slate decided it is time to automate the way his centers do business to maximize efficiency and keep up with insurance company and government requirements. He has requested an automated system be created to track and maintain personnel and patient information as well as a number of other functions. The systemwill need to be able to print the following: a weekly schedule for each doctor, daily appointment schedules for each center, and patient profile cards. The systemwill also need to track total revenues generated by medical care appointments and total expenditures for items purchased through wholesale vendors as well as enabling direct mail marketing of targeted patients. For customers upon request it would need to provide itemized yearly lists of medical care (appointment) expenses and also prescription purchases for income tax reporting purposes. For the pharmacy at the medical centers the systemwould need to automatically generate prescription numbers and prices and record all information associated with the filing of the prescription, generate prescription labels and patient receipts for the medications dispended, and generate detailed customer receipts (appointment or prescription) for insurance claims when applicable. Also, it must generate a daily dispended drug log and a separate log of dispensed controlled substances, which must be kept to meet DPR and DEA requirements. Also, to generate drug reorder reports for items that have fallen below their minimum stock amounts, help prevent pharmacist and nurse licenses fromexpiring without being noticed.
  • 4. Entity Relationship Diagram Employee MedCenter Assignment Physician Administrator Appointment Patient Nurse Pharmacist Vendor DrugOrder Prescription Drug EmployeeSSN EmployeeType EmployeeFirstName EmployeeMiddleInitial EmployeeLastName EmployeeStreetAddress EmployeeCity EmployeeZipCode EmployeeState EmployeePhoneNumber MedCenterIDPK MedCenterName MedCenterAddress MedCenter_Phone AdminIDFK AssignmentDate AssignmentStart AssistmentEnd PhysicianDEANumberPK PhysicianFirstName PhysicianLastName PhysicianSpecialty PhysicianPagerNumber AdminIDPK AdminJobTitle EmployeeIDFK ApptIDPK ApptDuration ApptCharge ApptReason ApptTime PatientIDPK PatientInsuranceStatus PatientFirstName MedCenterIDFK PatientLastName PatientZipCode PatientCity PatientStreetName PatientState PatientPhoneNumber NurseLicNumberPK EmployeeIDFK NurseLicExpDate PharmacistLicNumberPK EmployeeIDFK PharmacistLicExpDate VendorIDPK VendorName VendorPhoneNumber DrugOrderIDPK DrugOrderDate DrugOrderCost PrescriptionIDPK PrescriptionInstructions PrescriptionQuantity DrugNDCNumberPK DrugNameStrength DrugUse PrescriptionPriceCharged DrugLegalClass DrugAWP DrugUnit DrugSize VendorFaxNumber DrugOrderActualCost DrugOrderArrivalDate VendorIDFK AssignmentIDPK MedCenterIDFK DrugNDCNumberFK PatientIDFK PhysicianDEANumberFK PatientIDFK PhysicianDEANumberFK PhysicianDEANumberFK EmployeeIDPK PharmacistLicNumberFK DrugActualQty DrugInvenMin DrugOrderQty DrugOrderDeliveredQty DrugNDCNumberFK
  • 5. Data Dictionary Employee Entity Entity Description: Personnel employed by the FirstCare Medical Center. No employee works at more than one center. ColumnName ColumnDescription Data Type Data Format Field Size Example Primary Key Nullable Unique FK References Employee_ID A unique 5-digitidentifier assignedtoeachemployee. Integer ####### 7 12345 TRUE FALSE TRUE EmployeeSSN A unique nine digitidentifier issuedtoindividualsbythe Social SecurityAdministration. Varchar ###-##-#### 11 123-82-397 FALSE FALSE TRUE EmployeeFirstName The employee’slegal firstname Varchar 50 John FALSE FALSE FALSE EmployeeMiddleInitial The firstletterof an employee’s middle name. Varchar 1 A FALSE TRUE FALSE EmployeeLastName The legal lastname of an employee. VarChar 50 Smith FALSE FALSE FALSE EmployeeStreetAddress The streetaddressof an employee’shome orapartment. Varchar 60 275 Mount Carmel Avenue FALSE FALSE FALSE EmployeeCity The city where the employee’s streetaddressislocated Varchar 25 Hamden FALSE FALSE FALSE EmployeeState The State where anemployee’s residence islocated. Varchar 2 CT FALSE FALSE FALSE EmployeeZipCode A five digitpostal code issuedby USPS,it determinesthe exact geographical areaof an employee’sresidence Varchar 5 06492 FALSE FALSE FALSE EmployeePhone A mobile andorlandline phone numberthatcan be usedto contact an employee. Varchar (###)###- #### 14 (203)-518- 0000 FALSE FALSE FALSE
  • 6. Physician Entity EntityDescription:AnindividualcontractedbyFirstCare whoisqualifiedandlicensedtopractice medicine inthe state. Physiciansare notconsideredemployees of FirstCare Medical, they are independent contractors. ColumnName ColumnDescription Data Type Data Format Field Size Example Primary Key Nullable Unique FK References PhysicianDEANumber ID assignedtolicensedphysicians by the Federal DrugEnforcement Administration.The firstletteris alwaysA or B and the second letteristhe firstletterof the physician’slastname. Varchar AC####### AC####### TRUE FALSE TRUE PhysicianFirstName The employee’sfull legal first name. Varchar 75 John FALSE FALSE FALSE PhysicianLastName The last name of the physician. Varchar 25 Craig FALSE FALSE FALSE PhysicianPagerNumber The Physician’sassignedpager number. Varchar ###-##- #### 11 932-33- 2934 FALSE FALSE TRUE PhysicianSpecialty Branchesof medicine,which a physicianisanexpert. Varchar 50 Cardiology, Orthopedist FALSE FALSE FALSE
  • 7. Patient Entity Entity Description: The patients that come into be treated at FirstCare Medical Center. ColumnName ColumnDescription Data Type Data Format FieldSize Example Primary Key Nullable Unique FK References PatientID A unique six digitidentifier assignedonce toeach patient.The firstdigit the FirstCare centerthe patient was firstseen. Varchar 123456 6 123456 TRUE FALSE TRUE PatientInsurnceStatus Yes or No Varchar Yes 3 Yes FALSE FALSE FALSE PatientFirstName The personal andor legal name usedbefore the last name Varchar 20 John FALSE FALSE FALSE PatientLastName The surname of the patient Varchar Smith FALSE FALSE FALSE PatientStreetName The streetaddressof the patient’shome Varchar 25 275 Mount Carmel Ave FALSE FALSE FALSE PatientCity The city where the patient lives Varchar 20 Hamden FALSE FALSE FALSE PatientState The state where the patientlives Varchar 2 CT FALSE FALSE FALSE PatientZipCode The zip code of where the patientlives Varchar 5 06518 FALSE FALSE FALSE PatientPhoneNumber The phone numberof the patienteithermobile or landline. Varchar 10 (203) 123- 4434 FALSE FALSE FALSE
  • 8. Nurse Entity Entity Description: Registered nurse that FirstCare employs. FirstCare keeps track of the employee’s RN license number and expiration date to ensure they don’t expire. The license needs to be renewed every two years. ColumnName ColumnDescription Data Type Data Format Field Size Example Primary Key Nullable Unique FK References NurseLicNumber A personwhoistrainedand licensedtocare for the sickor infirm Varchar RN####### 9 123-82-397 TRUE FALSE TRUE NurseLicExpDate Nurse’slicenseexpirationdate Date YYYY-MM- DD 2013-02-12 FALSE FALSE FALSE MedCenterID The centerwhere the nurse is assignedtowork. Varchar 1 3 FALSE FALSE TRUE MedCenter Entity EmployeeID A unique 5digitidentifierassigned to each employee. Integer ###### 5 12345 FALSE FALSE TRUE Employee Entity Pharmacist Entity Entity Description: On site employee who is licensed and authorized to fill prescriptions for patients of FirstCare Medical ColumnName ColumnDescription Data Type Data Format Field Size Example Primary Key Nullable Unique FK References PharmacistLicNumber A nine characteralpha-numeric identifierassignedbythe Departmentof Professional Regulation. ItstartswithPS. Varchar PS####### 9 123-82-397 TRUE FALSE TRUE PharmacistLicExpDate The Pharmacist’sLicense Expiration date Date YYYY-MM- DD 2014-02-14 FALSE FALSE FALSE MedCenterID The centerwhere the nurse is assignedtowork. Varchar 1 3 FALSE FALSE TRUE MedCenter Entity EmployeeID A unique 5digitidentifierassigned to each employee. Integer ###### 5 12345 FALSE FALSE TRUE Employee Entity
  • 9. Prescription Entity Entity Description: Prescription order filled by a pharmacist for a patient as prescribed by a physician. ColumnName ColumnDescription Data Type Data Format Field Size Example Primary Key Nullable Unique FK References PrescriptionID Starts withthe lettersignifying whichof the centerpharmacies filledthe prescription.(A=1, B=2, C=3, D=4) followedbya five digitsequential number Varchar A##### 6 A00003 TRUE FALSE TRUE PrescriptionInstructions Instructionsonuse forthe prescription Varchar 100 Apply topical cream to chest only. FALSE FALSE FALSE PrescriptionQuantity Numberof the drugs dispensed. Varchar XXX FALSE FALSE FALSE PrescriptionPriceCharged Wholesale costof the medicationplusa$3 dispensing fee.Formedicationsthatdonot require aprescription,the price iswholesale costplus30%. Varchar $XXXX.XX FALSE FALSE FALSE DrugNDCNumber A numberassignedbydrug manufacturersthatshows the manufacturercode,product code,and package code. Varchar 11 1234- 5678-911 TRUE FALSE TRUE Drug Entity PatientID Patientthatthe prescriptionis beingfilledfor Varchar 6 PatientEntity PhysicianDEANumber ID assignedtolicensed physiciansbythe Federal Drug EnforcementAdministration. The firstletterisalwaysA or B and the secondletteristhe first letterof the physician’slast name. Varchar AC####### AC##### ## FALSE FALSE TRUE Physician Entity PharmacistLicNumber A unique setof numberthat Identifythe pharmacist Varchar 9 Pharmacist Entity
  • 10. Drug Entity Entity Description: Description of drugs carried by the FirstCare Medical Centers pharmacy ColumnName ColumnDescription Data Type Data Format Field Size Example Primary Key Nullable Unique FK References DrugNDCNumber A numberassignedbydrug manufacturersthatshowsthe manufacturercode,productcode, and package code. Varchar 11 1234-5678- 911 TRUE FALSE TRUE DrugNameStrength The drug name and strength Varchar Drug name, strength 25 Zoloft, 50 mg FALSE FALSE FALSE DrugUse Antibiotic,analgesic, antihypertensive,etc. Varchar 25 Antibiotic FALSE FALSE FALSE DrugLegalClass LabeledasOTC, prescriptiononly, controlled substance (subclass listed) Varchar N-# 3 C-2 FALSE FALSE FALSE DrugAWP Each drug’s average wholesale price Decimal FALSE FALSE FALSE DrugUnit Tablet,gram,milliliter,etc Decimal (10,2) mg FALSE FALSE FALSE DrugSize Package size Decimal (10,2) 25 FALSE FALSE FALSE DrugActualQty How muchof eachdrug is instock at any time. Integer 5 30 FALSE FALSE FALSE DrugInvenMin The minimumlevelof eachdrug that mustbe instock at all times. Integer 5 20 FALSE FALSE FALSE
  • 11. DrugOrder Entity Entity Description: Drug orders sent to vendors for FirstCare Medical Center’s pharmacies ColumnName ColumnDescription Data Type Data Format Field Size Example Primary Key Nullable Unique FK References DrugOrderID An alpha-numericidentifier assignedtoeachorder Varchar # - #### 1-1234 TRUE FALSE TRUE DrugOrderCost Cost of the drug order. Money 4 FALSE FALSE FALSE DrugOrderDate Date the drugsare ordered. Date MM-DD- YYYY 2014-12-02 FALSE FALSE FALSE DrugOrderQty The numberof packagesof each drug that isordered. Integer FALSE FALSE FALSE DrugOrderDeliveredQty The numberof packagesof each drug delivered Integer FALSE FALSE FALSE DrugOrderArrivalDate The date that the dug order arrived. Date MM-DD YYYY- 11 2015-12-09 FALSE FALSE FALSE DrugOrderActualCost The actual cost of the drug order. Money FALSE FALSE FALSE VendorID Each vendorisassigneda unique, sequential,VendorIDnumber. Varchar N# TRUE FALSE TRUE Vendor Entity Vendor Entity Entity Description: Information about the Vendors used to fill Drug Orders. Column Name Column Description Data Type Data Format Field Size Example Primary Key Nullable Unique FK References VendorID Each vendor is assigned a unique, sequential,Vendor ID number. Varchar N# TRUE FALSE TRUE VendorName The company name of the vendor. Varchar NNNNN 30 Johnson Drug Company FALSE FALSE FALSE VendorPhoneNumber The vendor’s phone number Varchar ### - ### - #### 12 293-483- 4839 FALSE FALSE FALSE VendorFaxNumber The vendor’s fax number Varchar ### - ### - #### 12 223-342- 4928 FALSE FALSE FALSE
  • 12. MedicalCenter Entity Entity Description: Building where health care, research, staff support, and ancillary services are provided. ColumnName ColumnDescription Data Type Data Format Field Size Example Primary Key Nullable Unique FK References MedCenterID Each of the four FirstCare centershas a unique CenterIDnumbered1-4 Varchar 1 4 TRUE FALSE TRUE MedCenterName The name of the medical center Varchar 30 Alcoa FirstCare Medical Center FALSE FALSE FALSE MedCenterAddress The physical addressof the medical center. Varchar 25 35 Smith Street, West Palm, FL FALSE FALSE FALSE MedCenterPhone The medical center’sphone number Varchar 12 641-348-8837 FALSE FALSE FALSE AdminID A unique nine digitidentifierissuedto the administratorof eachmedical center.Each centerhas onlyone administrator Varchar ##-#### 5 34631 FALSE FALSE TRUE Administrator Entity Administrator Entity Entity Description: Each center has one administrator for each center. ColumnName ColumnDescription Data Type Data Format Field Size Example Primary Key Nullable Unique FK References AdminID Administrator’sIDthatisunique to them Varchar 5 TRUE FALSE TRUE AdminJobTitle Specificjobtitle (manager,clerk, receptionist,etc) Varchar 20 FALSE FALSE FALSE EmployeeID A unique 5-digitidentifierassigned to each employee. Integer ####### 7 12345 FALSE FALSE TRUE Employee Entity MedCenterID The MedCenterIDof whichthe Administratorworks Varchar 1 3 FALSE FALSE FALSE MedicalCenter Entity
  • 13. Appointment Entity Entity Description: Appointments made by patients to be seen at FirstCare Medical Center ColumnName ColumnDescription Data Type Data Format Field Size Example Primary Key Nullable Unique FK References ApptID The firstdigitisthe centernumber the appointmentwasmade for and the nextsix digitsare assigned sequentially. Varchar 1234567 7 1234567 TRUE FALSE TRUE ApptDuration The durationof the appointment Varchar 50 2 15 minutes FALSE FALSE FALSE ApptTime The time of the appointment. Appointmentsare made inhalf hour increments Time HH:MM: SS 01:12:00 FALSE FALSE FALSE ApptCharge Typical fixedfee ofrappointmet is $35. Sometimesthe center managermay increase fee fora longerthantypical appointment. All deesare the direct responsibilityof the patient. smallmoney $XXX.XX 3 $35 FALSE FALSE FALSE ApptReason Reasonwhythe patientis schedulingthe appointment. Varchar 50 Sore throat, stuffy nose FALSE FALSE FALSE PatientID A unique six digitidentifier assignedonce toeach patient.The firstdigit the FirstCare centerthe patientwasfirstseen. Varchar 123456 6 123456 FALSE FALSE TRUE Patient Entity PhysicianDEANumber ID assignedtolicensedphysicians by the Federal DrugEnforcement Administration.The firstletteris alwaysA or B and the second letteristhe firstletterof the physician’slastname. Varchar AC##### ## AC####### FALSE FALSE TRUE Physician Entity
  • 14. Assignment Entity Entity Description: The assignments each Physician has for the day. ColumnName ColumnDescription Data Type Data Format Field Size Example Primary Key Nullable Unique FK References AssignmentID A unique 7digitnumberthat identifieseachphysician’sdaily assignment.Theycanbe assigned to more than one medcenterper day. Integer ####### 7 1234567 TRUE FALSE TRUE AssignmentDate The date of the physician’s assignments Date YYYY-MM-DD 2014-12- 01 FALSE FALSE FALSE AssignmentStart The start time of the assignment Time HH:MM:SS 10:30:00 FALSE FALSE FALSE AssignmentEnd The time the assignmentshould be finished. Time HH:MM:SS 11:00:00 FALSE FALSE FALSE MedCenterID The medical center’sID(numbers 1-4) Varchar 1 1 FALSE FALSE FALSE Medical Center Entity PhysicianDEANumber ID assignedtolicensedphysicians by the Federal DrugEnforcement Administration.The firstletteris alwaysA or B and the second letteristhe firstletterof the physician’slastname. Varchar AC####### 9 AC12345 67 TRUE FALSE TRUE Physician Entity
  • 15. SQL Transact Queries (A-H) - TestCaseson FirstCare Medical Center’sNewDatabase Management System. Below were some of the test cases utilized by the systemdevelopers, where a set of conditions were employed to test the database and its functionality in the FirstCare Medical business environment. These tests gave the developers insight and answered the question: did the new system fulfill the business requirements outlined by Mr. Slate and FirstCare Medical, and are the features developed working at their optimum level? To be assured that all business requirements were met, our systemdesign team decided that it would be best to perform at least two test cases on each functional requirement. If you (Mr. Slate) or any member of your team or organization has any questions or concerns about the new system, please do not hesitate to contact us. It was a great pleasure working with FirstCare and we truly hope that we fulfilled your business needs. Query A- Use ofan Aggregate Function Case: Shannon in the billing department needs to submit a claimto the insurance company. The claimis for Norma Howard, a regular patient at FirstCare. Her PatientID is 123458. Please find the amount she was billed for each appointment, and the PhysicianDEANumber /s of the Doctor /s who treated her.
  • 16. What is the total dollar amount of the claim we must submit to Aetna? Marissa’s Unique Query To meet growing demand for FirstCare Medical services, Mr. Slate is planning on opening another medical center. His team needs to know the total number of licensed physicians and pharmacists that are currently on staff. Query B- Usesan Outer Join The DEA has accused a FirstCare Medical physician of illegally prescribing Xanax for his friends and not his patients. They look to do a complete and thorough investigation and charge this individual while withholding their name from the public. The DEA has ordered FirstCare to provide a list of all patients treated at the facility; including the drugs they have been prescribed. The agency has stated that they will carefully analyze medical record to find and any strange discrepancies. Please provide the DEA with the information they request.
  • 17. Query C- Joins at least 3 tables Richard’smotherLawandais onthe phone andwantsto knowthe name and the strengthof the drugthat her sonwasprescribed.She justgotfromher son’s camp counselorthatherson isbehavingerraticallyandshe knowsit’snotlike himanditmustbe somethingthatone of our Physiciansgave him.Pleaseresearch the drug Richardwas prescribed.She doesn’tthe name of the physicianhersonsaw,butshe doesknowthat hispatientIDnumberis ‘123456’. We cannot affordanotherlawsuit,please findthe name,strengthandlegal class of the drugprescribed.
  • 18. It seems it wasn’t the medication, Richard has problems. Query D- Uses a sub query When trying to use the system, it is essential to note that sub queries can be used as alternatives to joins. Below are cases of how this applies. What is the First and Last name of the Patient with the ID Number 123488?
  • 19. Well Mr. George Perkins is furious; he’s on the phone right now with a secretary demanding to speak to Mr. Slate. He says that he has been a patient with FirstCare Medical Center since we opened and is claiming that we charged him an outlandish fee, far more than we charged anyone else for a short 25-minute consultation. Is this true, did we really charge Mr. Perkins, one of our most loyal customers more than anyone else? Mr. Slater would like to get in touch with the Physician who treated Mr. Perkins. Please find the name and pager number for the Doctor, Mr. Slater needs to meet with him/ her in his office immediately. Query E- Uses a SQL Function SELECT PatientID from Patient Where PatientLastName Like ‘J%’ or PatientFirstName Like ‘J5’;
  • 20. Query F- Contains at least 5 conditions Yale University is doing a study on certain the insurance demographics in certain. They are reaching out to FirstCare Medical Center for data to use within their research. They want to know the names and phone numbers of all uninsured patients located in HI or MI, live between zip codes 10000 and 80000, and also have their last name begin with the letter "M".
  • 22. Query H- Creates a trigger When pharmacists dispense medication, then need to update Drug levels for inventory purposes. This triggers an update. SQL Trigger Code: create trigger trigger_t09 on Prescription after insert as update Drug set DrugActualQty= DrugActualQty- (select PrescriptionQty from inserted) where Drug.DrugNDCNnumber =(select DrugNDCNnumber from inserted); alter table Drug alter column DrugActualQty decimal (10, 2); alter table prescription alter column PrescriptionQty decimal (10, 2); alter table drug alter column DrugInvMin decimal (10, 2); select * from prescription insert into Prescription
  • 23. values ('#00999E', 'dont take with alcholo', 10 ,41.64, '66715-6843', '123459', 'XV123456', 14268); SELECT * FROM DRUG WHERE DrugNDCNnumber= '66715-6843' Davian’s Query Tyreik’s Query The process of how drugs get administered by health care facilities has recently fascinated the Quinnipiac University Poll. They would like to know what are top 10 most common drugs that are prescribed more than their average and the amount each how been prescribed. CREATE VIEW PrescriptionsAbove Average AS SELECT PrescriptionID,PrescriptionQuantity FROMPrescription WHERE PrescriptionQuantity>(SELECTAVG(PrescriptionQuantity)FROMPrescription); CREATE VIEW top ten AS SELECT PrescriptionID FROM [Prescription Above Average] Where PrescriptionQuantity>(SELECT top 10 FROM Prescription) GROUP BY PrescriptionQuantity;
  • 24. Joe’s Query FirstCare Medical Center is under investigation by the DEA for illegally distributing Adderall, the only AntiHyper Intensive Drug they prescribe. The DEA wants to know the first name, last name, and employee id of any pharmacist who placed an order for adderall with an average wholesale price above $7000. Table Definitions Thissectionincludesthe code of all tablescreated,droppedandmodified.
  • 25. Create Table Employee ( EmployeeIDvarchar(50) primarykeynot null, EmployeeSSN varchar(100) UNIQUE not null, EmployeeFirstName varchar(70) not null, EmployeeMiddleInitial varchar(4), EmployeeLastName varchar(70) not null, EmployeeStreetAddressvarchar(100) not null, EmployeeCityvarchar(100) notnull, EmployeeStatechar(2) not null, EmployeeZipvarchar(15) notnull, EmployeePhonevarchar(30) notnull, ); Create Table Pharmacist( PharmacistLicNumvbervarchar(30) primarykeynot null, PharmacistExpDate DATEnotnull, EmployeeIDvarchar(50) not null, foreignkey(EmployeeID) referencesEmployee (EmployeeID), ); Create Table Physician( PhysicianDEANumbervarchar(30) primarykeynotnull, PhysicianNamevarchar(25) not null, PhysicianLastName varchar(25) not null, PhysicianPagerNumbervarchar(11) not null, PhysicianSpecialtyvarchar(30) not null, ); Create table MedicalCenter( MedCenterIDintprimarykeynotnull, MedCenterName varchar(30) notnull, AdminIDvarchar(5) not null, MedCenterAddressvarchar(25) not null, MedCenterPhone varchar(12) not null, foreignkey(AdminID) referencesAdministrator(AdminID), ); Create table Administrator( AdminIDvarchar(5) primarykeynotnull, AdminJobTitle varchar(20) notnull,
  • 26. MedCenterIDintnotnull,); ALTER TABLE Administrator ADD CONSTRAINTMedCenterIDFOREIGN KEY(MedCenterID) REFERENCES MedicalCenter(MedCenterID), ); Create table Nurse ( NurseLicNumbervarchar(9) primarykeynot null, EmployeeIDintnotnull, NurseLicExpDate DATEnotnull, MedCenterIDintnotnull, foreignkey(EmployeeID) referencesEmployee (EmployeeID), foreignkey(MedCenterID) referencesMedicalCenter(MedCenterID), ); Create table Patient( PatientIDvarchar(6) primarykeynotnull, PatientInsuranceBitnotnull, PatientFirstName varchar(25) notnull, PatientLastName varchar(25) notnull, PatientStreetName varchar(25) not null, PatientCityvarchar(25) not null, PatientState varchar(2) not null, PatientZipCode varchar(5) notnull, PatientPhoneNumbervarchar(15)notnull), ; Create table Assignment( AssignmentIDintegerprimarykeynotnull, AssignmentDateDateTimenotnull, AssigntmentStarttime notnull, AssignmentEndDateTime notnull, MedCenterIDintnotnull, PhysicianDEANumbervarchar(9) not null, foreignkey(MedCenterID) referencesMedicalCenter(MedCenterID), foreignkey(PhysicianDEANumber) referencesPhysician(PhysicianDEANumber), foreignkey(MedCenterID) referencesMedicalCenter(MedCenterID) ); Create table Appointment(
  • 27. ApptIDintegerprimarykeynotnull, ApptDurationtime notnull, ApptTime time notnull, ApptCharge moneynotnull, ApptReasonvarchar(50) not null, PatientIDvarchar(6) notnull, PhysicianDEANumbervarchar(9) not null, foreignkey(PatientID) referencesPatient(PatientID), foreignkey(PhysicianDEANumber) referencesPhysician(PhysicianDEANumber) ); Create Table Pharmacist( PharmacistLicNumvbervarchar(30) primarykeynot null, PharmacistExpDate DATEnotnull, EmployeeIDvarchar(30) not null, ); Create Table Physician( PhysicianDEANumbervarchar(30) primarykeynotnull, PhysicianNamevarchar(100) not null, PhysicianLastName varchar(100) notnull, PhysicianPagerNumbervarchar(25) not null, PhysicianSpecialtyvarchar(30) not null, ); Create table Patient( PatientIDvarchar(25) primarykeynot null, PatientInsuranceBitnotnull, PatientFirstName varchar(100) not null, PatientLastName varchar(100) not null, PatientStreetName varchar(100) notnull, PatientCityvarchar(100) notnull, PatientState char(2) not null, PatientZipCode char(5) notnull, PatientPhoneNumbervarchar(25)notnull); Create table Appointment ( ApptIDvarchar (25) primarykeynot null, ApptDurationvarchar(25) not null, ApptTime datetimenotnull,
  • 28. ApptCharge moneynotnull, ApptReasonvarchar(50) not null, PatientIDvarchar(25) not null, PhysicianDEANumbervarchar(30) not null, foreignkey(PatientID) referencesPatient(PatientID), foreignkey(PhysicianDEANumber) referencesPhysician(PhysicianDEANumber) ); Create table Administrator( AdminIDvarchar(25) primarykeynot null, AdminJobTitle varchar(20) notnull, MedCenterIDvarchar(25)notnull,); Create table MedicalCenter (MedCenterIDvarchar(25) primarykeynot null, MedCenterName varchar(30) notnull, AdminIDvarchar(25) not null, MedCenterAddressvarchar(100) notnull, MedCenterPhone varchar(25) not null, foreignkey(AdminID) referencesAdministrator(AdminID) ); ALTER TABLE Administrator ADD CONSTRAINTMedCenterIDFOREIGN KEY(MedCenterID) REFERENCES MedicalCenter(MedCenterID); Create table Assignment( AssignmentIDvarchar(30) primarykeynot null, AssignmentDateDate notnull, AssigntmentStartdate notnull, AssignmentEndDate notnull, MedCenterIDvarchar(25) not null, PhysicianDEANumbervarchar(30) notnull, foreignkey(MedCenterID) referencesMedicalCenter(MedCenterID), foreignkey(PhysicianDEANumber) referencesPhysician(PhysicianDEANumber), foreignkey(MedCenterID) referencesMedicalCenter(MedCenterID) ); Create table Nurse ( NurseLicNumbervarchar(30) primarykeynotnull, EmployeeIDvarchar(50) not null,
  • 29. NurseLicExpDate DATEnotnull, MedCenterIDvarchar(25) not null,); create table Vendor( VendorIDvarchar(10) primarykeynot null, VendorName varchar(70) notnull, VendorPhoneNumbervarchar(30) notnull, VendorFaxNumbervarchar(30) null, ); create table Drug ( DrugNDCNnumbervarchar(30) primarykeynotnull, DrugNameStrengthvarchar(30) notnull, DrugUse varchar(70) not null, DrugLegalClassvarchar(10) notnull, DrugAWPmoneynotnull, DrugUnitvarchar(10) not null, DrugSize decimal(10,2) notnull, DrugActualQtyvarchar(20) not null, DrugInvMinvarchar(20) notnull, ); create DrugOrder( DrugOrderIDvarchar(25) primarykeynotnull, DrugOrderCostmoney(4) notnull, DrugOrderDate date(11) notnull, DrugOrderQtyvarchar (50) notnull, DrugOrderDeliveredQtyvarchar(50) notnull, DrugOrderArrivalDatedate(11) notnull, DrugOrderActualCostmoney(4) notnull, VendorIDvarchar(10) not null, ); create table Prescription( PrescriptionIDvarhar(6) primarykeynotnull, PrescriptionInstructionsvarchar(100) notnull, PrescriptionQuantityvarchar(3) not null, PrescriptionPriceCharge varchar(8) notnull, DrugNDCNNumbervarchar(11) not null, PatientIDvarchar(25) not null, PhysicianDEANumbervarchar(30) notnull,
  • 30. PharmicistLicNumbervarchar(30) notnull, ); Create table MedicalCenter( MedCenterIDvarchar(25) primarykeynot null, MedCenterName varchar(30) notnull, AdminIDvarchar(25) not null, MedCenterAddressvarchar(100) notnull, MedCenterPhone varchar(25) not null );