import sqlite3
# Define the database file
DATABASE = 'hospital_management.db'
def add_sample_data():
conn = sqlite3.connect(DATABASE)
conn.row_factory = sqlite3.Row
cursor = conn.cursor()
# Insert Hospitals
hospitals = [
('City Hospital', '123 Main St, Anytown'),
('Greenwood Medical Center', '456 Elm St, Greenfield'),
('Sunshine Clinic', '789 Oak St, Sunnyville'),
('HealthPlus Hospital', '101 Maple St, Healthtown')
]
cursor.executemany('''
INSERT OR IGNORE INTO Hospitals (name, address) VALUES (?, ?)
''', hospitals)
# Insert Departments
departments = [
('Cardiology', 'Heart-related issues', 1),
('ENT', 'Ear, Nose, and Throat', 1),
('Gastroenterology', 'Digestive system issues', 2),
('Neurology', 'Brain and nervous system', 2),
('Orthopedics', 'Bone and joint issues', 3),
('Pediatrics', 'Children’s health', 3),
('Oncology', 'Cancer treatment', 4),
('Rheumatology', 'Autoimmune diseases', 4),
('Pulmonology', 'Lung issues', 1),
('Urology', 'Urinary tract and male reproductive organs', 4)
]
cursor.executemany('''
INSERT OR IGNORE INTO Departments (name, description, hospital_id) VALUES
(?, ?, ?)
''', departments)
# Insert Beds for each Department (example: 10 beds per department)
cursor.execute('SELECT id FROM Departments')
department_ids = [row['id'] for row in cursor.fetchall()]
beds = []
for dept_id in department_ids:
for _ in range(10): # Assuming 10 beds per department
beds.append((dept_id, False, None))
cursor.executemany('''
INSERT INTO Beds (department_id, is_occupied, patient_id) VALUES (?, ?, ?)
''', beds)
conn.commit()
conn.close()
if __name__ == "__main__":
add_sample_data()