0% found this document useful (0 votes)
12 views4 pages

Experiment-11-Hospital_Management_System

**Hospital Management System** A Hospital Management System (HMS) is software designed to manage hospital operations efficiently. It integrates patient registration, doctor management, appointment scheduling, and billing into a unified system. HMS improves patient care by reducing manual errors, enabling quick access to medical records, and streamlining workflows. It supports storing and retrieving data securely, ensuring data integrity and privacy. With real-time tracking of appointments and

Uploaded by

instafill148
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views4 pages

Experiment-11-Hospital_Management_System

**Hospital Management System** A Hospital Management System (HMS) is software designed to manage hospital operations efficiently. It integrates patient registration, doctor management, appointment scheduling, and billing into a unified system. HMS improves patient care by reducing manual errors, enabling quick access to medical records, and streamlining workflows. It supports storing and retrieving data securely, ensuring data integrity and privacy. With real-time tracking of appointments and

Uploaded by

instafill148
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Experiment - 11

Hospital Management System


Step 1: Database Design

1. `patients`: Stores patient information.


2. `doctors`: Stores doctor information.
3. `appointments`: Links patients and doctors for scheduled visits.
4. `departments`: Stores hospital department information.
5. `medications`: Stores prescribed medications for patients.

Patients Table

CREATE TABLE patients (


patient_id NUMBER GENERATED BY DEFAULT AS IDENTITY PRIMARY
KEY,
first_name VARCHAR2(50),
last_name VARCHAR2(50),
dob DATE,
gender VARCHAR2(10),
phone VARCHAR2(15),
address VARCHAR2(255)
);

Doctors Table

CREATE TABLE doctors (


doctor_id NUMBER GENERATED BY DEFAULT AS IDENTITY PRIMARY
KEY,
first_name VARCHAR2(50),
last_name VARCHAR2(50),
specialization VARCHAR2(100),
phone VARCHAR2(15),
department_id NUMBER,
FOREIGN KEY (department_id) REFERENCES
departments(department_id)
);
Departments Table

CREATE TABLE departments (


department_id NUMBER GENERATED BY DEFAULT AS IDENTITY
PRIMARY KEY,
department_name VARCHAR2(100)
);

Appointments Table

CREATE TABLE appointments (


appointment_id NUMBER GENERATED BY DEFAULT AS IDENTITY
PRIMARY KEY,
patient_id NUMBER,
doctor_id NUMBER,
appointment_date DATE DEFAULT SYSDATE,
diagnosis VARCHAR2(255),
FOREIGN KEY (patient_id) REFERENCES patients(patient_id),
FOREIGN KEY (doctor_id) REFERENCES doctors(doctor_id)
);

Medications Table

CREATE TABLE medications (


medication_id NUMBER GENERATED BY DEFAULT AS IDENTITY
PRIMARY KEY,
patient_id NUMBER,
prescription_date DATE DEFAULT SYSDATE,
medication_details VARCHAR2(255),
FOREIGN KEY (patient_id) REFERENCES patients(patient_id)
);

Step 2: Sample Data

-- Insert Departments
INSERT INTO departments (department_name) VALUES ('Cardiology');
INSERT INTO departments (department_name) VALUES ('Neurology');
INSERT INTO departments (department_name) VALUES ('Orthopedics');

-- Insert Doctors
INSERT INTO doctors (first_name, last_name, specialization, phone,
department_id)
VALUES ('John', 'Doe', 'Cardiologist', '1234567890', 1);
INSERT INTO doctors (first_name, last_name, specialization, phone,
department_id)
VALUES ('Jane', 'Smith', 'Neurologist', '0987654321', 2);

-- Insert Patients
INSERT INTO patients (first_name, last_name, dob, gender, phone, address)
VALUES ('Alice', 'Brown', DATE '1985-06-25', 'Female', '5551234567', '123
Elm St');
INSERT INTO patients (first_name, last_name, dob, gender, phone, address)
VALUES ('Bob', 'Davis', DATE '1990-11-13', 'Male', '5557654321', '456 Oak
St');

-- Insert Appointments
INSERT INTO appointments (patient_id, doctor_id, appointment_date,
diagnosis)
VALUES (1, 1, SYSDATE, 'Heart Checkup');
INSERT INTO appointments (patient_id, doctor_id, appointment_date,
diagnosis)
VALUES (2, 2, SYSDATE, 'Neurological Consultation');

-- Insert Medications
INSERT INTO medications (patient_id, medication_details)
VALUES (1, 'Aspirin 100mg daily');
INSERT INTO medications (patient_id, medication_details)
VALUES (2, 'Neurobion 500mg daily');

Step 3: Queries
Retrieve Patient Details

SELECT patient_id, first_name, last_name, dob, gender, phone, address


FROM patients;

Retrieve Appointment Details

SELECT a.appointment_id, p.first_name || ' ' || p.last_name AS patient_name,


d.first_name || ' ' || d.last_name AS doctor_name, a.appointment_date,
a.diagnosis
FROM appointments a
JOIN patients p ON a.patient_id = p.patient_id
JOIN doctors d ON a.doctor_id = d.doctor_id;

Retrieve Medications for a Patient

SELECT m.medication_id, p.first_name || ' ' || p.last_name AS patient_name,


m.medication_details, m.prescription_date
FROM medications m
JOIN patients p ON m.patient_id = p.patient_id;

You might also like