Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Develop a Python interface for your SQL database. Include a menu to search, update, and view reports. CREATE SCHEMA healthcare; use healthcare; CREATE TABLE Patient

Develop a Python interface for your SQL database. Include a menu to search, update, and view reports.
CREATE SCHEMA healthcare;
use healthcare;
CREATE TABLE Patient (
Patient_ID INT PRIMARY KEY,
Patient_Name VARCHAR(255) NOT NULL,
Patient_Address VARCHAR(255) NOT NULL,
Contact VARCHAR(255) NOT NULL,
Insurance VARCHAR(255) NOT NULL
);
CREATE TABLE Doctor (
Doctor_ID INT PRIMARY KEY,
Name VARCHAR(255) NOT NULL,
Specialization VARCHAR(255) NOT NULL,
Contact VARCHAR(255) NOT NULL
);
CREATE TABLE Appointment (
Record_ID INT PRIMARY KEY,
Patient_ID INT,
Doctor_ID INT,
Date DATETIME NOT NULL,
FOREIGN KEY (Patient_ID) REFERENCES Patient(Patient_ID),
FOREIGN KEY (Doctor_ID) REFERENCES Doctor(Doctor_ID)
);
CREATE TABLE MedicalRecord (
Record_ID INT PRIMARY KEY,
Patient_ID INT,
Diagnosis VARCHAR(255) NOT NULL,
Treatment VARCHAR(255) NOT NULL,
FOREIGN KEY (Patient_ID) REFERENCES Patient(Patient_ID)
);
CREATE TABLE Billing (
Billing_ID INT PRIMARY KEY,
Record_ID INT,
Patient_ID INT,
TotalAmount DECIMAL(10,2) NOT NULL,
PaymentStatus VARCHAR(255) NOT NULL,
FOREIGN KEY (Record_ID) REFERENCES MedicalRecord(Record_ID),
FOREIGN KEY (Patient_ID) REFERENCES Patient(Patient_ID)
);
ALTER TABLE MedicalRecord
ADD CONSTRAINT FK_MedicalRecord_Appointment
FOREIGN KEY (Record_ID)
REFERENCES Appointment(Record_ID);
INSERT INTO Patient (Patient_ID, Patient_Name, Patient_Address, Contact, Insurance)
VALUES
(1, 'John Doe', '123 Main St, Anytown, CA 91234','555-123-4567', 'Aetna'),
(2, 'Jane Smith', '456 Elm St, Anytown, CA 91234','555-987-6543', 'Blue Cross Blue
Shield'),
(3, 'Mike Jones', '789 Oak St, Anytown, CA 91234','555-234-5678', 'Cigna'),
(4, 'Alice Lee', '1011 Cedar St, Anytown, CA 91234','555-345-6789',
'UnitedHealthcare'),
(5, 'Bob Brown', '1213 Walnut St, Anytown, CA 91234','555-456-7890', 'Humana');
INSERT INTO Doctor (Doctor_ID, Name, Specialization, Contact)
VALUES
(1,'Dr. Smith', 'General Medicine', '555-555-1212'),
(2,'Dr. Jones', 'Cardiology', '555-555-2323'),
(3,'Dr. Lee', 'Dermatology', '555-555-3434'),
(4,'Dr. Brown', 'Neurology', '555-555-4545'),
(5,'Dr. Williams', 'Orthopedics', '555-555-5656');
INSERT INTO Appointment (Record_ID, Patient_ID, Doctor_ID, Date)
VALUES
(1,1,1,'2023-10-26'),
(2,2,3,'2023-11-02'),
(3,3,2,'2023-11-09'),
(4,4,4,'2023-11-16'),
(5,5,5,'2023-11-23'),
(6,1,2,'2023-12-07'),
(7,3,1,'2023-12-14'),
(8,5,4,'2023-12-21');
INSERT INTO MedicalRecord (Record_ID, Patient_ID, Diagnosis, Treatment)
VALUES
(1,1, 'Hypertension', 'Medications, lifestyle changes'),
(2,2, 'Eczema', 'Topical steroids, emollients'),
(3,3, 'Anxiety', 'Therapy, medication'),
(4,4, 'Migraine headaches', 'Pain medication, preventive medication'),
(5,5, 'Knee pain', 'Physical therapy, pain medication');
INSERT INTO Billing (BillingID, Record_ID, Patient_ID, TotalAmount, PaymentStatus)
VALUES
(1,1,1,200.00, 'Paid'),
(2,2,2,150.00, 'Paid'),
(3,3,3,100.00, 'Paid'),
(4,4,4,250.00, 'Paid'),
(5,5,5,300.00, 'Paid'),
(6,6,1,175.00, 'Paid'),
(7,7,3,125.00, 'Paid'),
(8,8,5,225.00, 'Paid');
SELECT * FROM Patient;
SELECT * FROM Patient WHERE Patient_Address LIKE '%Anytown, CA%';
SELECT * FROM Patient WHERE Insurance = 'Blue Cross Blue Shield';
UPDATE Doctor SET Name ='Dr. Johnson' WHERE Doctor_ID =2;
UPDATE Doctor SET Contact ='555-555-2323' WHERE Doctor_ID =2;
UPDATE Doctor SET Specialization = 'Cardiology' WHERE Doctor_ID =2;
INSERT INTO Appointment (Record_ID, Patient_ID, Doctor_ID, Date)
VALUES
(9,4,2,'2024-02-17');
SELECT Patient.Patient_Name, SUM(Billing.TotalAmount) AS TotalBilling
FROM Patient
JOIN MedicalRecord ON Patient.Patient_ID = MedicalRecord.Patient_ID
JOIN Billing ON MedicalRecord.Record_ID = Billing.Record_ID
WHERE Patient.Patient_ID =2;
SHOW INDEX FROM Doctor;
SHOW INDEX FROM Appointment;
SHOW INDEX FROM Billing;

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions