You are on page 1of 10

CS22311- DATABASE MANAGEMENT SYSTEM LABORATORY

Ex NO.:
12 DATE:

MINI PROJECT

HOSPITAL MANAGEMENT SYSTEM

AIM:

To implement a hospital management system.

ALGORITHM:

1. Database Configuration:

- Establish a connection to a MySQL database hosted locally.

- Create and configure tables for the following key entities:

- Admin: To store admin login credentials (username and password).

- availability of room for patient: To track room availability, including the total number of
rooms, rooms available, and rooms reserved.

- Booker: books room for patient by mentioning patient_name,phoneno,address,DOB,room no and


reason for appointment.

- Populate the Admin and RoomCheck tables with initial data to ensure system functionality.

- Set up a database trigger to automatically update room availability in the RoomCheck table when
a booker books a room.

2. Graphical User Interface (GUI) Functionality:

- Define several key functions to handle different aspects of the GUI and Hosiptal
management system:

- admin_login: This function is responsible for the admin login process, where admin
credentials are checked, and access to room and booker details is granted upon successful
authentication.

- check_room_availability: Implement a function that allows users to check room availability.


If rooms are available, this function calls the book_room function, offering booker an opportunity
to book a room.

- book_room: This function manages the bookers room booking process. It collects and
validates patients (name, phone number, email, number of days, and room number), saving the
details to the Booker table if the room number is within the specified range.

3. Main Application Window Setup:


Roll no.: 2127220501107 Page | 1
- Create the primary tkinter window (referred to as root) for the Hosiptal management system.

- Set the window title and size to ensure an appealing and user-friendly interface.

4. User Interface Design:

- Define and position GUI components, including labels, buttons, and entry fields, within the
main tkinter window (root). This design ensures a clear and visually pleasing user experience.

5. Admin Login Functionality:

- Implement the admin login functionality in the admin_login function. When triggered, it opens
a separate window for admin login, allowing administrators to log in using their username and
password. Upon successful login, access to room and booker details is granted.

6. Room Availability Check:

- Develop the check_room_availability function, which allows users to inquire about room
availability. If rooms are available, the function calls the book_room function, prompting booker to
book a room for patient. It also provides feedback about room availability to the booker.

7. Room Booking Feature:

- Implement the booking process for patient within the book_patient function. When called, it
creates a dedicated window for guests to enter their information, such as name, phone number,
email, number of days, and room number. The function validates the room number to ensure it falls
within the allowable range (1-10) before saving the patient details to the Booker table.

8. Main Event Loop Initialization:

- Start the primary tkinter event loop (root.mainloop()) to initiate the GUI application. This
event loop is responsible for handling user interactions, ensuring smooth system operation.

PROGRAM/ QUERIES:

while (True):

print("""

================================

Welcome To CityHospital

================================

""")

Roll no.: 2127220501107 Page | 2


# creating database connectivity

import mysql.connector

passwd = str(input("Enter the Password Please!!:"))

mysql = mysql.connector.connect(

host="localhost", user="root", passwd="qwerty")

mycursor = mysql.cursor()

mycursor.execute("create database if not exists city_hospitals")

mycursor.execute("use city_hospitals")

# creating the tables we need

mycursor.execute(

"create table if not exists patient_detail(name varchar(30) primary key,sex varchar(15),age


int(3),address varchar(50),contact varchar(15))")

mycursor.execute("create table if not exists doctor_details(name varchar(30) primary


key,specialisation varchar(40),age int(2),address varchar(30),contact varchar(15),fees
int(10),monthly_salary int(10))")

mycursor.execute(

"create table if not exists nurse_details(name varchar(30) primary key,age int(2),address


varchar(30),contact varchar(15),monthly_salary int(10))")

mycursor.execute(

"create table if not exists other_workers_details(name varchar(30) primary key,age


int(2),address varchar(30),contact varchar(15),monthly_salary int(10))")

# creating table for storing the username and password of the user

mycursor.execute(

"create table if not exists user_data(username varchar(30) primary key,password


varchar(30) default'000')")

while (True):

print("""

1. Sign In

2. Registration

""")

Roll no.: 2127220501107 Page | 3


r = int(input("enter your choice:"))

if r == 2:

print("""

=======================================

!!!!!!!!!!Register Yourself!!!!!!!!

=======================================

""")

u = input("Input your username!!:")

p = input("Input the password (Password must be strong!!!:")

mycursor.execute(

"insert into user_data values('" + u + "','" + p +

"')") mysql.commit()

print("""

============================================

!!Well Done!!Registration Done Successfully!!

============================================

""")

x = input("enter any key to continue:")

# IF USER WANTS TO LOGIN

elif r == 1:

print("""

==================================

!!!!!!!! {{Sign In}} !!!!!!!!!!

==================================

""")

un = input("Enter Username!!:")

ps = input("Enter Password!!:")

mycursor.execute(

"select password from user_data where username='" + un + "'")

Roll no.: 2127220501107 Page | 4


row = mycursor.fetchall()

for i in row:

a = list(i)

if a[0] == str(ps):

while (True):

print("""

1.Administration

2.Patient(Details)

3.Sign Out

""")

a = int(input("ENTER YOUR CHOICE:"))

if a == 1:

print("""

1. Display the details

2. Add a new member

3. Delete a member

4. Make an exit

""")

b = int(input("Enter your Choice:"))

# details

if b == 1:

print("""

1. Doctors Details

2. Nurse Details

3. Others

""")

c = int(input("Enter your Choice:"))

if c == 1:

mycursor.execute(

Roll no.: 2127220501107 Page | 5


"select * from doctor_details")

row = mycursor.fetchall()

for i in row:

b=0

v = list(i)

k = ["NAME", "SPECIALISATION", "AGE", "ADDRESS",


"CONTACT", "FEES",

"MONTHLY_SALARY"]

d = dict(zip(k,

v)) print(d)

# displays nurses

details elif c == 2:

mycursor.execute(

"select * from nurse_details")

row = mycursor.fetchall()

for i in row:

v = list(i)

k = ["NAME", "SPECIALISATION", "AGE",

"ADDRESS", "CONTACT", "MONTHLY_SALARY"]

d = dict(zip(k,

v)) print(d)

# displays worker

details elif c == 3:

mycursor.execute(

"select * from other_workers_details")

row = mycursor.fetchall()

for i in row:

v = list(i)

k = ["NAME", "SPECIALISATION", "AGE",

"ADDRESS", "CONTACT""MONTHLY_SALARY"]

d = dict(zip(k,

v)) print(d)

# IF USER WANTS TO ENTER DETAILS

Roll no.: 2127220501107 Page | 6


elif b == 2:

print("""

1. Doctor Details

2. Nurse Details

3. Others

""")

SAMPLE INPUT/OUTPUT:

Roll no.: 2127220501107 Page | 7


Roll no.: 2127220501107 Page | 8
Roll no.: 2127220501107 Page | 9
RESULT:

Thus the Hosiptal Management System model has been executed and Output generated
successfully.

Roll no.: 2127220501107 Page | 10

You might also like