6004 DBMS CA2 Project
6004 DBMS CA2 Project
NEW PANVEL
PROJECT REPORT ON
“Hospital Management System”
IN PARTIAL FULFILLMENT OF
PROJECT GUIDE
Prof. Shubhangi Pawar
SUBMITTED BY: AYAAN SAKYA
Details about the continuous Assessment 2/Project work = portfolio tracking application
/4
Total
/15
● Inform the class the rubric format and the method of evaluation.
Co-ordinator,
Shubhangi
Pawar
Hospital management system
OBJECTIVES:-
The Main objective behind this system is to create a website for the patients to
book the appointments for their visit to the doctors. The doctors can also use this
website to check their patient bookings. This project is an attempt to make a mini
hospital management system for the doctors and the patients .This project which
also use the database to store the patient as well as doctors data , bookings, ids ,
diseases etc.
REQUIREMENTS:-
1. Xampp
2. PhpMyAdmin
3. VS code
4. Frontend Languages:- html , css
5. Backend Languages:-Python, php
6. Mysql
7. Some Images for background
A) Install Xampp
2.Patients
3.test
4.trigr
5.user
D) Frontend Languages:-
HTML
Base.html
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1,
shrink-to-fit=no">
<title>
{% block title %}
{% endblock title %}
</title>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<a class="navbar-brand" href="/">H.M.S</a>
<button class="navbar-toggler" type="button" data-
toggle="collapse" data-target="#navbarSupportedContent" aria-
controls="navbarSupportedContent" aria-expanded="false" aria-
label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
{% if current_user.usertype=="Doctor" %}
<li class="nav-item">
<a class="nav-link" href="/doctors">Doctors</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/bookings">Booking
Details</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/details">Patients
Details</a>
</li>
{% else %}
<li class="nav-item">
<a class="nav-link" href="/patients">Patients
Booking</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/bookings">Booking
Details</a>
</li>
{% endif %}
{% if current_user.is_authenticated %}
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#"
id="navbarDropdown" role="button" data-toggle="dropdown" aria-
haspopup="true" aria-expanded="false">
Welcome {{current_user.username}}
</a>
<div class="dropdown-menu" aria-
labelledby="navbarDropdown">
<a class="dropdown-item"
href="/logout">Logout</a>
</div>
</li>
{% else %}
</div>
</li>
{% endif %}
</ul>
<form class="form-inline my-2 my-lg-0" action="/search"
method="post">
<input class="form-control mr-sm-2" type="search"
placeholder="Department" name="search" aria-label="Search">
<button class="btn btn-outline-light my-2 my-sm-0"
type="submit">Search</button>
</form>
</div>
</nav>
{% block body %}
{% endblock body %}
</body>
</html>
Booking.html
{% extends 'base.html' %}
{% block title %}
Booking
{% endblock title %}
{% block body %}
{% with messages=get_flashed_messages(with_categories=true) %}
{% if messages %}
{% for category, message in messages %}
<div class="alert alert-{{category}} alert-dismissible fade show"
role="alert">
{{message}}
<button type="button" class="close" data-dismiss="alert" aria-
label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
{% endfor %}
{% endif %}
{% endwith %}
<table class="table">
<thead class="thead-light">
<tr>
<th scope="col">PID</th>
<th scope="col">EMAIL</th>
<th scope="col">NAME</th>
<th scope="col">GENDER</th>
<th scope="col">SLOT</th>
<th scope="col">DISEASE</th>
<th scope="col">DATE</th>
<th scope="col">TIME</th>
<th scope="col">D.DEPARTMENT</th>
<th scope="col">PHONE NUMBER</th>
<th scope="col">EDIT</th>
<th scope="col">DELETE</th>
</tr>
</thead>
<tbody>
{% for post in query %}
<tr>
<th scope="row">{{post.pid}}</th>
<td>{{post.email}}</td>
<td>{{post.name}}</td>
<td>{{post.gender}}</td>
<td>{{post.slot}}</td>
<td>{{post.disease}}</td>
<td>{{post.date}}</td>
<td>{{post.time}}</td>
<td>{{post.dept}}</td>
<td>{{post.number}}</td>
<td><a href="/edit/{{post.pid}}"><button class="btn btn-
success">Edit </button> </a> </td>
<td><a href="/delete/{{post.pid}}"><button onclick="return
confirm('Are you sure to Delete data');" class="btn btn-
success">Delete </button> </a> </td>
</tr>
{% endfor %}
</tbody>
</table>
{% endblock body %}
Doctor.html
{% extends 'base.html' %}
{% block title %}
Doctors
{% endblock title %}
{% block body %}
<div class="container">
<div class="row">
<div class="col-md-4"></div>
<div class="col-md-4">
{% with messages=get_flashed_messages(with_categories=true) %}
{% if messages %}
{% for category, message in messages %}
{% endfor %}
{% endif %}
{% endwith %}
<br>
<h2 class="text-center text-white bg-dark">Doctors Booking</h2>
<br>
<form action="/doctors" method="post" class="jumbotron">
<div class="form-group">
<input type="email" class="form-control" name="email"
value={{current_user.email}} required>
</div>
<div class="form-group">
</div>
<div class="form-group">
</div>
</form>
</div>
<div class="col-md-4"></div>
</div>
</div>
{% endblock body %}
Edit.html
{% extends 'base.html' %}
{% block title %}
Edit Patient BOOKING
{% endblock title %}
{% block body %}
<div class="row">
<div class="col-md-4">
</div>
<div class="col-md-4">
<br>
<div class="form-group">
</div>
<div class="form-group">
</div>
<div class="form-group">
</select>
</div>
<div class="form-group">
</select>
</div>
<div class="form-group">
</div>
<div class="form-group">
<input type="date" class="form-control" value={{posts.date}}
name="date" placeholder="date" required>
</div>
<div class="form-group">
</div>
<div class="form-group">
</div>
<div class="form-group">
</div>
</div>
<div class="col-md-4"></div>
</div>
{% endblock body %}
Index.html
{% extends 'base.html' %}
{% block title %}
HOME
{% endblock title %}
{% block body %}
{% with messages=get_flashed_messages(with_categories=true) %}
{% if messages %}
{% for category, message in messages %}
<div class="alert alert-{{category}} alert-dismissible fade show"
role="alert">
{{message}}
{% endfor %}
{% endif %}
{% endwith %}
{% endblock body %}
Login.html
{% extends 'base.html' %}
{% block title %}
Login
{% endblock title %}
{% block body %}
<div class="container mt-3">
<div class="row">
<div class="col-md-4">
</div>
{% with messages=get_flashed_messages(with_categories=true) %}
{% if messages %}
{% for category, message in messages %}
{% endfor %}
{% endif %}
{% endwith %}
<div class="form-group">
<label for="email">Email Address</label>
<input type="email" class="form-control" id="email" name="email"
required>
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" class="form-control" id="password"
name="password" required>
</div>
<br>
Not a User <a href="/signup">Signup</a>
</div>
<div class="col-md-4">
</div>
</div>
</div>
{% endblock body %}
Patient.html
{% extends 'base.html' %}
{% block title %}
Patients Booking
{% endblock title %}
{% block body %}
<div class="col-md-5">
<div class="card" style="width: 18rem;">
<img src="static/images/doc.jpg" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">HOSPITAL DOCTORS</h6>
<p class="card-text">Doctors Names</p>
</div>
<ul class="list-group list-group-flush">
<li class="list-group-item">Cras justo odio</li>
<li class="list-group-item">Dapibus ac facilisis in</li>
<li class="list-group-item">Vestibulum at eros</li>
</ul>
<div class="card-body">
<a href="#" class="card-link">Contact Us</a>
<a href="#" class="card-link">About US</a>
</div>
</div>
</div>
<div class="col-md-5">
{% with messages=get_flashed_messages(with_categories=true) %}
{% if messages %}
{% for category, message in messages %}
{% endfor %}
{% endif %}
{% endwith %}
</div>
<div class="form-group">
</div>
<div class="form-group">
</select>
</div>
<div class="form-group">
</select>
</div>
<div class="form-group">
</div>
<div class="form-group">
</div>
<div class="form-group">
<div class="form-group">
<div class="form-group">
</div>
</div>
</div>
</div>
{% endblock body %}
Signup.html
{% extends 'base.html' %}
{% block title %}
Signup
{% endblock title %}
{% block body %}
<div class="container mt-3">
<div class="row">
<div class="col-md-4">
</div>
{% with messages=get_flashed_messages(with_categories=true) %}
{% if messages %}
{% for category, message in messages %}
{% endfor %}
{% endif %}
{% endwith %}
<div class="form-group">
<label for="username">UserName</label>
<input type="text" class="form-control" id="username" name="username"
required >
</div>
<div class="form-group">
<div class="form-group">
<label for="email">Email Address</label>
<input type="email" class="form-control" id="email" name="email"
required>
<small id="emailHelp" class="form-text text-muted">We'll never share
your email with anyone else.</small>
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" class="form-control" id="password"
name="password" required>
</div>
</div>
<div class="col-md-4">
</div>
</div>
</div>
{% endblock body %}
Triggers.html
{% extends 'base.html' %}
{% block title %}
Trigers
{% endblock title %}
{% block body %}
{% with messages=get_flashed_messages(with_categories=true) %}
{% if messages %}
{% for category, message in messages %}
{% endfor %}
{% endif %}
{% endwith %}
</tr>
</thead>
<tbody>
{% for post in posts %}
<tr>
<th scope="row">{{post.tid}}</th>
<td>{{post.pid}}</td>
<td>{{post.email}}</td>
<td>{{post.name}}</td>
<td>{{post.action}}</td>
<td>{{post.timestamp}}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endblock body %}
CSS
Virtualregister.css
.section-title {
text-align: center;
/* padding-bottom: 30px; */
}
.pricing .row {
padding-top: 0px;
}
.card {
margin-top: 57px;
border-radius: 8px 40px 40px 8px;
transition: all 0.5s ease-in-out;
box-shadow: 1px 0px 8px 2px greenyellow;
}
.bg-dark {
background-color: #63d471;
background-image: linear-gradient(315deg, #63d471 0%, #233329 74%);
}
label {
color: white;
margin-top: 15px;
font-family: 'Itim', cursive;
}
.jumbotron {
background-color: #63d471;
background-image: linear-gradient(315deg, #63d471 0%, #233329 74%);
}
#gender {
width: 300px;
}
#slot {
width: 300px;
}
#dept {
width: 300px;
}
.form-group input {
width: 300px;
border: none;
/* border-bottom: 1px solid purple; */
border-bottom: 2px solid green;
outline: none;
font-size: 22px;
margin-bottom: 5px;
font-family: 'Itim', cursive;
}
option {
width: 400px;
border: none;
border-bottom: 2px solid green;
outline: none;
font-size: 22px;
margin-bottom: 5px;
}
.form-group input:hover {
background-color: ghostwhite;
}
#btn {
background-color: #63d471;
background-image: linear-gradient(315deg, #63d471 0%, #233329 74%);
border-radius: 15px;
border: none;
position: relative;
width: 300px;
}
#btn:hover {
background-color: white;
color: white;
}
E) Backend Languages:-
Python:-
Main.py
# MY db connection
local_server= True
app = Flask(__name__)
app.secret_key='hmsprojects'
# this is for getting unique user access
login_manager=LoginManager(app)
login_manager.login_view='login'
# app.config.update(
# MAIL_SERVER='smtp.gmail.com',
# MAIL_PORT='465',
# MAIL_USE_SSL=True,
# MAIL_USERNAME="add your gmail-id",
# MAIL_PASSWORD="add your gmail-password"
# )
# mail = Mail(app)
@login_manager.user_loader
def load_user(user_id):
return User.query.get(int(user_id))
#
app.config['SQLALCHEMY_DATABASE_URL']='mysql://username:password@localhos
t/databas_table_name'
app.config['SQLALCHEMY_DATABASE_URI']='mysql://root:@localhost/hmdbms'
db=SQLAlchemy(app)
class User(UserMixin,db.Model):
id=db.Column(db.Integer,primary_key=True)
username=db.Column(db.String(50))
usertype=db.Column(db.String(50))
email=db.Column(db.String(50),unique=True)
password=db.Column(db.String(1000))
class Patients(db.Model):
pid=db.Column(db.Integer,primary_key=True)
email=db.Column(db.String(50))
name=db.Column(db.String(50))
gender=db.Column(db.String(50))
slot=db.Column(db.String(50))
disease=db.Column(db.String(50))
time=db.Column(db.String(50),nullable=False)
date=db.Column(db.String(50),nullable=False)
dept=db.Column(db.String(50))
number=db.Column(db.String(50))
class Doctors(db.Model):
did=db.Column(db.Integer,primary_key=True)
email=db.Column(db.String(50))
doctorname=db.Column(db.String(50))
dept=db.Column(db.String(50))
class Trigr(db.Model):
tid=db.Column(db.Integer,primary_key=True)
pid=db.Column(db.Integer)
email=db.Column(db.String(50))
name=db.Column(db.String(50))
action=db.Column(db.String(50))
timestamp=db.Column(db.String(50))
@app.route('/doctors',methods=['POST','GET'])
def doctors():
if request.method=="POST":
email=request.form.get('email')
doctorname=request.form.get('doctorname')
dept=request.form.get('dept')
return render_template('doctor.html')
@app.route('/patients',methods=['POST','GET'])
@login_required
def patient():
# doct=db.engine.execute("SELECT * FROM `doctors`")
doct=Doctors.query.all()
if request.method=="POST":
email=request.form.get('email')
name=request.form.get('name')
gender=request.form.get('gender')
slot=request.form.get('slot')
disease=request.form.get('disease')
time=request.form.get('time')
date=request.form.get('date')
dept=request.form.get('dept')
number=request.form.get('number')
# subject="HOSPITAL MANAGEMENT SYSTEM"
if len(number)<10 or len(number)>10:
flash("Please give 10 digit number")
return render_template('patient.html',doct=doct)
query=Patients(email=email,name=name,gender=gender,slot=slot,disease=dise
ase,time=time,date=date,dept=dept,number=number)
db.session.add(query)
db.session.commit()
# mail.send_message(subject, sender=params['gmail-user'],
recipients=[email],body=f"YOUR bOOKING IS CONFIRMED THANKS FOR CHOOSING
US \nYour Entered Details are :\nName: {name}\nSlot: {slot}")
flash("Booking Confirmed","info")
return render_template('patient.html',doct=doct)
@app.route('/bookings')
@login_required
def bookings():
em=current_user.email
if current_user.usertype=="Doctor":
# query=db.engine.execute(f"SELECT * FROM `patients`")
query=Patients.query.all()
return render_template('booking.html',query=query)
else:
# query=db.engine.execute(f"SELECT * FROM `patients` WHERE
email='{em}'")
query=Patients.query.filter_by(email=em)
print(query)
return render_template('booking.html',query=query)
@app.route("/edit/<string:pid>",methods=['POST','GET'])
@login_required
def edit(pid):
if request.method=="POST":
email=request.form.get('email')
name=request.form.get('name')
gender=request.form.get('gender')
slot=request.form.get('slot')
disease=request.form.get('disease')
time=request.form.get('time')
date=request.form.get('date')
dept=request.form.get('dept')
number=request.form.get('number')
# db.engine.execute(f"UPDATE `patients` SET `email` = '{email}',
`name` = '{name}', `gender` = '{gender}', `slot` = '{slot}', `disease` =
'{disease}', `time` = '{time}', `date` = '{date}', `dept` = '{dept}',
`number` = '{number}' WHERE `patients`.`pid` = {pid}")
post=Patients.query.filter_by(pid=pid).first()
post.email=email
post.name=name
post.gender=gender
post.slot=slot
post.disease=disease
post.time=time
post.date=date
post.dept=dept
post.number=number
db.session.commit()
flash("Slot is Updates","success")
return redirect('/bookings')
posts=Patients.query.filter_by(pid=pid).first()
return render_template('edit.html',posts=posts)
@app.route("/delete/<string:pid>",methods=['POST','GET'])
@login_required
def delete(pid):
# db.engine.execute(f"DELETE FROM `patients` WHERE
`patients`.`pid`={pid}")
query=Patients.query.filter_by(pid=pid).first()
db.session.delete(query)
db.session.commit()
flash("Slot Deleted Successful","danger")
return redirect('/bookings')
@app.route('/signup',methods=['POST','GET'])
def signup():
if request.method == "POST":
username=request.form.get('username')
usertype=request.form.get('usertype')
email=request.form.get('email')
password=request.form.get('password')
user=User.query.filter_by(email=email).first()
encpassword=generate_password_hash(password)
if user:
flash("Email Already Exist","warning")
return render_template('/signup.html')
myquery=User(username=username,usertype=usertype,email=email,password=enc
password)
db.session.add(myquery)
db.session.commit()
flash("Signup Succes Please Login","success")
return render_template('login.html')
return render_template('signup.html')
@app.route('/login',methods=['POST','GET'])
def login():
if request.method == "POST":
email=request.form.get('email')
password=request.form.get('password')
user=User.query.filter_by(email=email).first()
return render_template('login.html')
@app.route('/logout')
@login_required
def logout():
logout_user()
flash("Logout SuccessFul","warning")
return redirect(url_for('login'))
@app.route('/test')
def test():
try:
Test.query.all()
return 'My database is Connected'
except:
return 'My db is not Connected'
@app.route('/details')
@login_required
def details():
posts=Trigr.query.all()
# posts=db.engine.execute("SELECT * FROM `trigr`")
return render_template('trigers.html',posts=posts)
@app.route('/search',methods=['POST','GET'])
@login_required
def search():
if request.method=="POST":
query=request.form.get('search')
dept=Doctors.query.filter_by(dept=query).first()
name=Doctors.query.filter_by(doctorname=query).first()
if name:
flash("Doctor is Available","info")
else:
app.run(debug=True)
C) MySql
Hms.sql
--
-- Database: `hms`
--
-- --------------------------------------------------------
--
-- Table structure for table `doctors`
--
--
-- Dumping data for table `doctors`
--
-- --------------------------------------------------------
--
-- Table structure for table `patients`
--
--
-- Dumping data for table `patients`
--
--
-- Triggers `patients`
--
DELIMITER $$
CREATE TRIGGER `PatientDelete` BEFORE DELETE ON `patients` FOR EACH ROW
INSERT INTO trigr VALUES(null,OLD.pid,OLD.email,OLD.name,'PATIENT
DELETED',NOW())
$$
DELIMITER ;
DELIMITER $$
CREATE TRIGGER `PatientUpdate` AFTER UPDATE ON `patients` FOR EACH ROW
INSERT INTO trigr VALUES(null,NEW.pid,NEW.email,NEW.name,'PATIENT
UPDATED',NOW())
$$
DELIMITER ;
DELIMITER $$
CREATE TRIGGER `patientinsertion` AFTER INSERT ON `patients` FOR EACH ROW
INSERT INTO trigr VALUES(null,NEW.pid,NEW.email,NEW.name,'PATIENT
INSERTED',NOW())
$$
DELIMITER ;
-- --------------------------------------------------------
--
-- Table structure for table `test`
--
-- --------------------------------------------------------
--
-- Table structure for table `trigr`
--
--
-- Dumping data for table `trigr`
--
-- --------------------------------------------------------
--
-- Table structure for table `user`
--
--
-- Dumping data for table `user`
--
--
-- Indexes for dumped tables
--
--
-- Indexes for table `doctors`
--
ALTER TABLE `doctors`
ADD PRIMARY KEY (`did`);
--
-- Indexes for table `patients`
--
ALTER TABLE `patients`
ADD PRIMARY KEY (`pid`);
--
-- Indexes for table `test`
--
ALTER TABLE `test`
ADD PRIMARY KEY (`id`);
--
-- Indexes for table `trigr`
--
ALTER TABLE `trigr`
ADD PRIMARY KEY (`tid`);
--
-- Indexes for table `user`
--
ALTER TABLE `user`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `email` (`email`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `doctors`
--
ALTER TABLE `doctors`
MODIFY `did` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
--
-- AUTO_INCREMENT for table `patients`
--
ALTER TABLE `patients`
MODIFY `pid` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=18;
--
-- AUTO_INCREMENT for table `test`
--
ALTER TABLE `test`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=12;
--
-- AUTO_INCREMENT for table `trigr`
--
ALTER TABLE `trigr`
MODIFY `tid` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=20;
--
-- AUTO_INCREMENT for table `user`
--
ALTER TABLE `user`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=16;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
I also used some images for the websites which I will show in the output
of the project
Some requirements.txt
Flask==1.1.2
Flask-Mail==0.9.1
Flask-SQLAlchemy==2.4.3
future==0.18.2
Jinja2==2.11.2
jmespath==0.9.5
Js2Py==0.70
MarkupPy==1.14
MarkupSafe==1.1.1
mysqlclient==2.0.1
Naked==0.1.31
packaging==20.4
Pillow==7.1.1
pipenv==2018.11.26
pipwin==0.5.0
pyttsx3==2.90
pytz==2020.1
pywin32==228
SQLAlchemy==1.3.17
sqlparse==0.3.1
OUTPUT:-
Go to main.py and run the command the output it will show will be
In this click on the following link
Details
Now my account is created it will also show in the database like this
For edit
It will give me update page
After updating
Vice versa you can update anyother details about your things
Now even doctors can make their account as patients and see their
appointment routines (same as patients)
Here I am signing up as the doctor
I successfully logged in
Here I can see all the patient details by clicking on patient details button
Its showing the stored doctor name (professor doctor name as a user)
THANK YOU