100% found this document useful (5 votes)
4K views

Hospital Management System

computer science python and mysql project

Uploaded by

venkatesh jothi
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
100% found this document useful (5 votes)
4K views

Hospital Management System

computer science python and mysql project

Uploaded by

venkatesh jothi
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/ 34

VELAMMAL VIDHYASHRAM

MAMBAKKAM

COMPUTER SCIENCE
Topic: Hospital Management System

Academic year: 2021-2022

Done By:
M.Yuvalakshmi

XII-‘A’
BONAFIDE CERTIFICATE
This is to certify that this COMPUTER SCIENCE Project on the topic

Hospital Management System has been successfullly completed by

M.YUVALAKSHMI of class XI A, Roll.no…………………... at Velammal

Vidhyashram, Mambakkam, for the partial fulfilment of this project as a

part of All India Senior School Certificate Examination-CBSE, New Delhi

for the academicYear 2021 - 2022.

Date: ……………………..

Signature of Principal Signature of the Guide

Signature of the Signature of the


Internal Examiner External Examiner
ACKNOWLEDGEMENT:
I wish to express my deep gratitude and sincere thanks to the Senior Principal Mr.R.Arul
Kumar, VelammalVidhyashram,Mambakkam for his encouragement given to me and for
all the facilities that he provided for this project work. I sincerely appreciate this
magnanimity by taking me into his fold for which I shall remain indebted to him.

I extend my hearty thanks to Miss.Dhivya Rajendran,Computer Science Teacher, who


guided me to the successful completion of this project. I take this opportunity to express
my deep sense of gratitude for her valuable guidance, constant encouragement, immense
motivation, which sustained my efforts at all the stage of this project work.

I would like to thank my lab assistant, lab in charge and technical staffs for providing
correct information which makes the completion of this project work in an excellent way.

I can’t forget to offer my sincere thanks to parents, and also to my classmates who helped
me to carry out this project work successful and for their valuable advice and support,
which received from them time to time.
TABLE OF CONTENT:
1. ABSTRACT
2. SYSTEM CONFIGURATION
3. INTRODUCTION
PYTHON

MYSQL

4. RELATION BETWEEN PYTHON AND MYSQL


5.DATABASE CONNECTIVITY

6. LIBRARIES AND FUNCTIONS USED


7. MYSQL QUERIES USED IN THIS PROJECT
8. SOURCE CODE
9. OUTPUT (SCREENSHOT)
10. BACK END (MYSQL)
11. CONCLUSION
12. BIBILOGRAPHY
ABSTRACT:
This project Hospital Management system includes registration of patients,
storing their details into the system, and also computerized billing in the pharmacy, and
labs. The software has the facility to give a unique id for every patient and stores the
clinical details of every patient and hospital tests done automatically. It includes a search
facility to know the current status of each patient. User can search details of a patient
using the id. The Hospital Management System can be entered without using a username
and password. It is accessible either by an administrator or receptionist or by anyone who
has got the source code. Only they can add data into the database. The data can be
retrieved easily. The interface is very user-friendly. The data are also available for
personal use and makes the data processing very fast.

SYSTEM CONFIGURATION:
HARDWARE CONFIGURATION
Microsoft windows 7 professional/windows 8/windows 8.2:
 Processor : Intel Core i5 or equivalent
 Memory : 2 GB (32-bit), 4 GB (64-bit)
 Disk space : 1.5 GB of free disk space

SOFTWARE REQUIREMENTS
 1 GB RAM (2 GB+ recommended)
 9-58 GB free hard disk space depending on edition and configuration, including
space required for temporary files
 DVD-ROM drive (if installing from a Media Kit DVD)
 Basic GPU – Any vendor DirectX 9.0 class or better (Pixel Shader Level 2)
 Intel® Pentium® or compatible, 1.6 GHz minimum (2GHz+ recommended)
 1024x768 or higher-resolution monitor
 MOUSE OR OTHER POINTING DEVICE
INTRODUCTION:

PYTHON:
Python is a high-level, interpreted scripting language developed in the late 1980s by Guido van
Rossum at the National Research Institute for Mathematics and Computer Science in the
Netherlands. The initial version was published at the alt.sources newsgroup in 1991, and version
was released in 1994.
Python 2.0 was released in 2000, and the 2.x versions were the prevalent releases until December
2008. At that time, the development team made the decision to release version 3.0, which
contained a few relatively small but significant changes that were not backward compatible with
the 2.x versions. Python 2 and 3 are very similar, and some features of Python 3 have been
backported to Python 2. But in general, they remain not quite compatible.
Both Python 2 and 3 have continued to be maintained and developed, with periodic release
updates for both. As of this writing, the most recent versions available are 2.7.15 and 3.6.5.
However, an official End of life of January 1,2020 has been established for Python 2, after which
time it will no longer be maintained. If you are a newcomer to Python, it is recommended that you
focus on Python 3, as this tutorial will do.
Python is still maintained by a core development team at the Institute, and Guido is still in charge,
having been given the title of BDFL (Benevolent Dictator For Life) by the Python community.
The name Python, by the way, derives not from the snake, but from the British comedy troupe
Monty Python’s Flying Circus, of which Guido was, and presumably still is, a fan. It is common to
find references to Monty Python sketches and movies scattered throughout the Python
documentation.

Python is Popular
Python has been growing in popularity over the last few years. The 2018 Stack Overflow
Developer Survey ranked Python as the 7th most popular and the number one most wanted
technology of the year. World-class software development countries around the globe use Python
every single day.According to research by Dice Python is also one of the hottest skills to have and
the most popular programming language in the world based on the Popularity of programming
Language Index.

Python is Interpreted
Many languages are compiled, meaning the source code you create needs to be translated into
machine code, the language of your computer’s processor, before it can be run. Programs written
in an interpreted language are passed straight to an interpreter that runs them directly.
This makes for a quicker development cycle because you just type in your code and run it, without
the intermediate compilation step.
One potential downside to interpreted languages is execution speed. Programs that are compiled
into the native language of the computer processor tend to run more quickly than interpreted
programs. For some applications that are particularly computationally intensive, like graphics
processing or intense number crunching, this can be limiting.
In practice, however, for most programs, the difference in execution speed is measured in
milliseconds, or seconds at most, and not appreciably noticeable to a human user. The expediency
of coding in an interpreted language is typically worth it for most applications.

Python is Free
The Python interpreter is developed under an OSI-approved open-source license, making it free to
install, use, and distribute, even for commercial purposes.
A version of the interpreter is available for virtually any platform there is, including all flavors of
Unix, Windows, macOS, smartphones and tablets, and probably anything else you ever heard of.
A version even exists for the half dozen people remaining who use OS/2.
Python is Portable
Because Python code is interpreted and not compiled into native machine instructions, code
written for one platform will work on any other platform that has the Python interpreter installed.
(This is true of any interpreted language, not just Python.)

Python is Simple
As programming languages go, Python is relatively uncluttered, and the developers have
deliberately kept it that way.
A rough estimate of the complexity of a language can be gleaned from the number of keywords or
reserved words in the language. These are words that are reserved for special meaning by the
compiler or interpreter because they designate specific built-in functionality of the language.
Python 3 has 33 keywords, and Python 2 has 31. By contrast, C++ has 62, Java has 53, and Visual
Basic has more than 120, though these latter examples probably vary somewhat by
implementation or dialect.

MYSQL:
Database Management System & Types of DBMS:

A Database Management System(DBMS) is a software application that interacts with


the user, applications and the database itself to capture and analyze data.The data stored in
the database can be modified, retrieved and deleted, and can be of any type like strings,
numbers, images etc.

Types of DBMS:
There are mainly 4 types of DBMS, which are Hierarchical, Relational, Network, and
Object-Oriented DBMS.

Hierarchical DBMS:As the name suggests, this type of DBMS has a style of predecessor-
successor type of relationship. So, it has a structure similar to that of a tree, wherein the
nodes represent records and the branches of the tree represent fields.

Relational DBMS (RDBMS): This type of DBMS, uses a structure that allows the users to
identify and access data in relation to another piece of data in the database.

Network DBMS: This type of DBMS supports many to many relations wherein multiple
member records can be linked.
Object-oriented DBMS: This type of DBMS uses small individual software called objects.
Each object contains a piece of data, and the instructions for the actions to be done with
the data.

Structured Query Language (SQL)


SQL is the core of a relational database which is used for accessing and managing the
database. By using SQL, you can add, update or delete rows of data, retrieve subsets of
information,modify databases and perform many actions. The different subsets of SQL are
as follows:
 DDL (Data Definition Language) –It allows you to perform various operations on
the database such as CREATE, ALTER and DELETE objects.
 DML (Data Manipulation Language)– It allows you to access and manipulate data.
It helps you to insert, update, delete and retrieve data from the database.
 DCL (Data Control Language)– It allows you to control access to the database.
Example – Grant or Revoke access permissions.
 TCL(Transaction Control Language) – It allows you to deal with the transaction of
the database. Example – Commit, Rollback, Savepoint, Set Transaction.

MySQL & its Features


MySQL is an open-source relational database management system that works on many
platforms. It provides multi-user access to support many storage engines and is backed by
Oracle. So,you can buy a commercial license version from Oracle to get premium support
services.
The features of MySQL are as follows:
Ease of Management –The software very easily gets downloaded and also uses an event
scheduler to schedule the tasks automatically.
 Robust Transactional Support –Holds the ACID (Atomicity, Consistency,
Isolation, Durability) property, and also allows distributed multi-version support.
 Comprehensive Application Development –MySQL has plugin libraries to embed
the database into any application. It also supports stored procedures, triggers,
functions, views and many more for application development. You can refer to the
RDS Tutorial, to understand Amazon’s RDBMS.
 High Performance –Provides fast load utilities with distinct memory caches and
table index partitioning.
 Low Total Cost Of Ownership –This reduces licensing costs and hardware
expenditures.
 Open Source & 24 * 7 Support –This RDBMS can be used on any platform and
offers 24*7 support for open source and enterprise edition.
 Secure Data Protection –MySQL supports powerful mechanisms to ensure that
only authorized users have access to the databases.
 High Availability –MySQL can run high-speed master/slave replication
configurations and it offers cluster servers.
 Scalability & Flexibility –With MySQL you can run deeply embedded applications
and create data warehouses holding a humongous amount of data.

MySQL Data Types


 Numeric – This data type includes integers of various sizes, floating-point(real) of
various precisions and formatted numbers.
 Character-string – These data types either have a fixed, or a varying number of
characters. This data type also has a variable-length string called CHARACTER
LARGE OBJECT(CLOB) which is used to specify columns that have large text
values.
 Bit-string – These data types are either of a fixed length or varying length of bits.
There is also a variable-length bit string data type called BINARY LARGE
OBJECT(BLOB), which is available to specify columns that have large binary
values, such as images.
 Boolean –This data type has TRUE or FALSE values. Since SQL, has NULL
values, a three-valued logic is used, which is UNKNOWN.
 Date & Time –The DATE data type has: YEAR, MONTH, and DAY in the form
YYYY-MM-DD. Similarly, the TIME data type has the components HOUR,
MINUTE, and SECOND in the form HH:MM: SS. These formats can change based
on the requirement.
 Timestamp & Interval –The TIMESTAMP data type includes a minimum of six
positions, for decimal fractions of seconds and an optional WITH TIME ZONE
qualifier in addition to the DATE and TIME fields. The INTERVAL data type
mentions a relative value that can be used to increment or decrement an absolute
value of a date, time, or timestamp.
Python MySQL Database Connection:
Arguments required to connect MySQL from Python
You need to know the following detail of the MySQL server to perform the connection
from Python.
 Username – i.e., the username that you use to work with MySQL Server. The
default username for the MySQL database is a root
 Password – Password is given by the user at the time of installing the
MySQLdatabase. If you are using root then you won’t need the password.
 Host Name – is the server name or Ip address on which MySQL is running. if
youare running on localhost, then you can use localhost, or it’s IP, i.e. 127.0.0.0
 Database Name – Database name to which you want to connect.

READ Operation

READ Operation on any database means to fetch some useful information from the
database.

Once our database connection is established, you are ready to make a query into this
database. You can use either fetchone() method to fetch single record or fetchall()
method to fetech multiple values from a database table.

 fetchone() − It fetches the next row of a query result set. A result set is an object
that is returned when a cursor object is used to query a table.

 fetchall()
− It fetches all the rows in a result set. If some rows have already been
extracted from the result set, then it retrieves the remaining rows from the result
set.
DATABASE CONNECTIVITY:
Steps to connect MySQL database in Python using MySQL Connector
Python
1. Install MySQL Connector Python using pip.
2. Use the mysql.connector.connect()method of MySQL Connector Python with
required parameters to connect MySQL.
3. Use the connection object returned by a connect()method to create a cursor object
to perform Database Operations.
4. The cursor.execute()to execute SQL queries from Python.
5. Close the Cursor object using a cursor.close() and MySQL database connection
using connection.close() after your work completes.
6. Catch Exception if any that may occur during this process.
LIBRARIES AND FUNCTIONS USED:
1. TKINTER - Tkinter is the standard GUI library for Python. Python when
combined with Tkinter provides a fast and easy way to create GUI
applications. Tkinter provides a powerful object-oriented interface to the Tk
GUI toolkit.

2. RANDOM - RANDINT() – Returns a random number between the given range

3. MYSQL.CONNECTOR – It enables Python programs to access MySQL databases, tables.

FUNCTIONS USED:

1. SearchId() – Used to search each patient’s information by using their id.


2. IdBar() – Used to display the searched patient’s barcode.
3. __init__( ) – Used to initialize the attributes of the class.
4. Add_new_data() – Adds new data when patient ’s entry is new .
5. update() - Used when there is any updation in any patient’s information.
6. fetch_data() – Fetches all the informations of the mentioned patient.
7. get_cursor() – Retrives all informations of the patient when cursor clicks on
the information of the patient.

8. iprescription() – Used when we want to get the prescription of the patient.


9. delete() – Used to delete the mentioned patient.
10. clear() – Used to clear all the information on the screen and start a new record.
11. Exit() -- Used to exit the program and it asks yes/no option for exit.
MYSQL QUERIES USED IN THIS PROJECT:
1. create database hospital;
2. use hospital;
3. create table patients_details ( Patient_Id int primary key, Patient_Name
varchar(45), Gender varchar(45), Date_of_Birth date, Age int, NHS_Number int,
Problem varchar(45), Medicine varchar(45),Ref_No varchar(45), Side_Effect
varchar(45), Doc_visit int, Medi_fee int, Room_fee int,Totall_bill int);

4. show tables;
5. insert into patients_details values(50002,”devi”,”female”,”1996-04-16”,25,235354,
“pheumonia”,”amoxillin”,”BGF545”,”head ache”,300,300,0,600);
6. select * from patients_details;
7. select * from patients_details where Patient_Id=50002;
8. delete from patients_details where Patient_Id =50012;

SOURCE CODE:
from tkinter import *
from tkinter import ttk
import random
from tkinter import messagebox
import mysql.connector as m
from mysql.connector.errors import DatabaseError

root=Tk()

#===============================TEXTVARIABLES===================================

PatientId=StringVar()
PatientName=StringVar()
Gender=StringVar()
DateOfBirth=StringVar()
Age=StringVar()
NhsNumber=StringVar()
Problem=StringVar()
Medicine=StringVar()
ref=StringVar()
SideEffect=StringVar()
Doc_visit=StringVar()
Medi_fee=StringVar()
Room_fee=StringVar()
Total_bill=StringVar()

SearchPatientId=StringVar()
PatientIdBar=StringVar()

#=================================DEFINING CLASS==================================

class Hospital:

def __init__(self,root):
self.root = root
self.root.title("Hospital Management System")
self.img=PhotoImage(file='C:\\Users\\mail2\\OneDrive\\Desktop\\New folder (2)\\medical-
assistance.png')
self.root.iconphoto(False,self.img)
self.root.geometry("1360x700+0+0")
self.root.configure(background="#FFB0AB")

#=====================================FRAMES====================================

MainFrame= Frame(self.root,bd=10,width=1364,height=720, relief= RIDGE,bg="#FFB0AB")


MainFrame.grid()

TitleFrames=Frame(MainFrame,bd=7,width=1320,height=100,relief=RIDGE)
TitleFrames.grid(row=0,column=0)

SearchFrame= Frame(MainFrame,bd=7,width=1340,height=50, relief= RIDGE)


SearchFrame.grid(row=1,column=0)

#==========================================================================

MidFrame=Frame(MainFrame,bd=5,width=1340,height=520,relief=RIDGE,bg="#FFB0AB")
MidFrame.grid(row=3,column=0)

DataFrame= Frame(MidFrame,bd=5,relief=RIDGE)
DataFrame.place(x=0,y=0,width=1330,height=300)

DataFrameLeft=LabelFrame(DataFrame,bd=5,relief=RIDGE,padx=10,font=("times new
roman",12,"bold"),
text="Patient Information")
DataFrameLeft.place(x=0,y=6,width=950,height=275)

DataFrameRight=LabelFrame(DataFrame,bd=5,relief=RIDGE,padx=10,font=("times new
roman",12,"bold"),
text="Prescription")
DataFrameRight.place(x=955,y=6,width=356,height=275)
#==============================================================================

Buttonframe=Frame(MidFrame,bd=7,relief=RIDGE)
Buttonframe.place(x=0,y=300,width=1330,height=50)

Treeviewframe=ttk.Frame(MidFrame,relief=RIDGE)
Treeviewframe.place(x=0,y=350,width=1330,height=160)

#==========================TITLE FRAME FILLING ====================================

self.labeltitle=Label(TitleFrames,text=
" HOSPITAL MANAGEMENTSYSTEM",fg="black",bg="#FFB0AB", font=("Cambria",35,"bold"))
self.labeltitle.grid(row=0,column=0,padx=10)

self.labelAPPLE=Label(TitleFrames,font=('c39hrp36dltt',60),text="APPLE DOG",fg="black")
self.labelAPPLE.grid(row=0,column=1,padx=100)

#===============================EXIT FUNCTION===================================
def Exit():
Exit=messagebox.askyesno("Hospital Management System","Are you sure you wanna Exit?")
if Exit>0:
root.destroy()
return
#==============================ID BAR CODE FUNCTION=============================
def IdBar():
idpay=random.randint(50000,70000)
idbc=("patient id" + str(idpay))
PatientIdBar.set(idbc)

#=============================SEARCH FRAME FILLING=================================

self.lblBarCode=Label(SearchFrame,font=("Cambria",12,"bold"),text="ID Bar Code")


self.lblBarCode.grid(row=0,column=0,padx=4,sticky=W)
self.txtBarCode=Entry(SearchFrame,font=("CCode39",13),width=29 ,
textvariable=PatientIdBar,justify='center')
self.txtBarCode.grid(row=0,column=1,padx=37)

#==========================================================================

self.txtSearch=Entry(SearchFrame,font=("Cambria",16,"bold"),width=39,
textvariable=SearchPatientId,justify='right')
self.txtSearch.grid(row=0,column=2)
self.btnSearch=Button(SearchFrame,pady=1,padx=29,bd=4, font=("Cambria",12,"bold"),
width=13,height=1,bg="#FFB0AB",
fg="black", text="Search ID").grid(row=0,column=3,padx=1)

#=============================DATA FRAME LEFT FILLING==============================

self.PatientId=Label(DataFrameLeft,font=("arial",12,"bold"),text="Patient Id:",bd=5)
self.PatientId.grid(row=0,column=0,sticky=W,padx=2)
self.PatientId=Entry(DataFrameLeft,font=("arial",12),bd=5,textvariable=PatientId,width=30)
self.PatientId.grid(row=0,column=1)

self.PatientName=Label(DataFrameLeft,font=("arial",12,"bold"),text="Patient Name:",bd=5)
self.PatientName.grid(row=1,column=0,sticky=W,padx=2)
self.PatientName=Entry(DataFrameLeft,font=("arial",12),bd=5,textvariable=PatientName,width=30)
self.PatientName.grid(row=1,column=1)

#================combo box===============================

self.Gender=Label(DataFrameLeft,font=("arial",12,"bold"),text="Gender:",bd=6)
self.Gender.grid(row=2,column=0,sticky=W,padx=2)
self.cboGender=ttk.Combobox(DataFrameLeft,font=("arial",12),textvariable=Gender,width=29,
state="readonly")
self.cboGender['values']=(" ","Female","Male")
self.cboGender.current(0)
self.cboGender.grid(row=2,column=1)

#========================================================

self.DateOfBirth=Label(DataFrameLeft,font=("arial",12,"bold"),text="Date of Birth:",bd=5)
self.DateOfBirth.grid(row=3,column=0,sticky=W,padx=2)
self.DateOfBirth=Entry(DataFrameLeft,font=("arial",12),bd=5,textvariable=DateOfBirth,width=30)
self.DateOfBirth.grid(row=3,column=1)

self.Age=Label(DataFrameLeft,font=("arial",12,"bold"),text="Age:",bd=5)
self.Age.grid(row=4,column=0,sticky=W,padx=2)
self.Age=Entry(DataFrameLeft,font=("arial",12),bd=5,textvariable=Age,width=30)
self.Age.grid(row=4,column=1)

self.NhsNumber=Label(DataFrameLeft,font=("arial",12,"bold"),text="NHS Number:",bd=5)
self.NhsNumber.grid(row=5,column=0,sticky=W,padx=2)
self.NhsNumber=Entry(DataFrameLeft,font=("arial",12),bd=5,textvariable=NhsNumber,width=30)
self.NhsNumber.grid(row=5,column=1)

self.Problem=Label(DataFrameLeft,font=("arial",12,"bold"),text="Problem:",bd=5)
self.Problem.grid(row=6,column=0,sticky=W,padx=2)
self.Problem=Entry(DataFrameLeft,font=("arial",12),bd=5,textvariable=Problem,width=30)
self.Problem.grid(row=6,column=1)

#================combo box===============================

self.Medicine=Label(DataFrameLeft,font=("arial",12,"bold"),text="Medicine:",bd=5)
self.Medicine.grid(row=0,column=2,sticky=W,padx=2)

self.cboMedicine=ttk.Combobox(DataFrameLeft,textvariable=Medicine,state="readonly",
font=("arial",12),width=33)

self.cboMedicine['value']=(" ","Beclomethasone","Primaquine","Amlodipine","Phenytoin",
"Amxicillin","Mesna","Metformin","Ibuprofen","Paraceptamol")
self.cboMedicine.current(0)
self.cboMedicine.grid(row=0,column=3)
#=========================================================

self.ref=Label(DataFrameLeft,font=("arial",12,"bold"),text="Ref No:",bd=5)
self.ref.grid(row=1,column=2,sticky=W,padx=2)
self.ref=Entry(DataFrameLeft,font=("arial",12),bd=5,textvariable=ref,width=35)
self.ref.grid(row=1,column=3)

self.SideEffect=Label(DataFrameLeft,font=("arial",12,"bold"),text="Side Effect:",bd=5)
self.SideEffect.grid(row=2,column=2,sticky=W,padx=2)
self.SideEffect=Entry(DataFrameLeft,font=("arial",12),bd=5,textvariable=SideEffect,width=35)
self.SideEffect.grid(row=2,column=3)

self.Doc_visit=Label(DataFrameLeft,font=("arial",12,"bold"),text="Doctor visit:",bd=5)
self.Doc_visit.grid(row=3,column=2,sticky=W,padx=2)
self.Doc_visit=Entry(DataFrameLeft,font=("arial",12),bd=5,textvariable=Doc_visit,width=35)
self.Doc_visit.grid(row=3,column=3)

self.Medi_fee=Label(DataFrameLeft,font=("arial",12,"bold"),text="Medicine Fee:",bd=5)
self.Medi_fee.grid(row=4,column=2,sticky=W,padx=2)
self.Medi_fee=Entry(DataFrameLeft,font=("arial",12),bd=5,textvariable=Medi_fee,width=35)
self.Medi_fee.grid(row=4,column=3)

self.Room_fee=Label(DataFrameLeft,font=("arial",12,"bold"),text="Room Fee:",bd=5)
self.Room_fee.grid(row=5,column=2,sticky=W,padx=2)
self.Room_fee=Entry(DataFrameLeft,font=("arial",12),bd=5,textvariable=Room_fee,width=35)
self.Room_fee.grid(row=5,column=3)

self.Total_bill=Label(DataFrameLeft,font=("arial",12,"bold"),text="Total bill:",bd=5)
self.Total_bill.grid(row=6,column=2,sticky=W,padx=2)
self.Total_bill=Entry(DataFrameLeft,font=("arial",12),bd=5,textvariable=Total_bill,width=35)
self.Total_bill.grid(row=6,column=3)
#============================DATA FRAME RIGHT FILLING============================

self.txtPrescription=Text(DataFrameRight,font=("arial",11,"bold"),width=40,height=12,
padx=2,pady=6)
self.txtPrescription.grid(row=0,column=0)

#=========================FUNCTIONALITY DEACLARATYION===========================

#=============================ADD NEW DATA ============================


def Add_new_data():
if PatientId.get()=="" or ref.get()=="":
messagebox.showerror("Error","All fields are required")
else:
conn=m.connect(host="localhost",username="root",passwd="0912",database="hospital")
mc=conn.cursor()
mc.execute("insert into patients_details values(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
,(

PatientId.get(),
PatientName.get(),
Gender.get(),
DateOfBirth.get(),
Age.get(),
NhsNumber.get(),
Problem.get(),
Medicine.get(),
ref.get(),
SideEffect.get(),
Doc_visit.get(),
Medi_fee.get(),
Room_fee.get(),
Total_bill.get()
))
conn.commit()
fetch_data()
IdBar()
conn.close()
messagebox.showinfo('Success!',"Redcord has been Inserted")

#=============================UPDATE ===========================

def update():
conn=m.connect(host="localhost",username="root",passwd="0912",database="hospital")
mc=conn.cursor()
mc.execute("Update patients_details set Patient_Name=%s,Gender=%s,Date_of_Birth=%s,Age=%s,

NHS_Number=%s,Problem=%s,Medicine=%s,Ref_No=%s,Side_Effect=%s,Doc_visit=%s,Medi_fee=%s,R
oom_fee=%s,
Total_bill=%s where Patient_Id=%s",(

PatientName.get(),
Gender.get(),
DateOfBirth.get(),
Age.get(),
NhsNumber.get(),
Problem.get(),
Medicine.get(),
ref.get(),
SideEffect.get(),
Doc_visit.get(),
Medi_fee.get(),
Room_fee.get(),
Total_bill.get(),
PatientId.get()
))
conn.commit()
fetch_data()
IdBar()
clear()
conn.close()
messagebox.showinfo("Data Entry Form","Record Successfully Updated!")

#==================================FETCH DATA ========================


def fetch_data():

conn=m.connect(host="localhost",username="root",passwd="0912",database="hospital")
mc=conn.cursor()
mc.execute("select * from patients_details")
rs=mc.fetchall()
if len(rs)!=0:
self.hospital_table.delete(*self.hospital_table.get_children())
for i in rs:
self.hospital_table.insert("",END,values=i)
conn.commit()
conn.close()

#============================GET CURSOR =========================

def get_cursor(event=""):
cursor_row=self.hospital_table.focus()
content=self.hospital_table.item(cursor_row)
row=content['values']

PatientId.set(row[0])
PatientName.set(row[1])
Gender.set(row[2])
DateOfBirth.set(row[3])
Age.set(row[4])
NhsNumber.set(row[5])
Problem.set(row[6])
Medicine.set(row[7])
ref.set(row[8])
SideEffect.set(row[9])
Doc_visit.set(row[10])
Medi_fee.set(row[11])
Room_fee.set(row[12])
Total_bill.set(row[13])

IdBar()

#=========================PRESCRIPTION ==========================

def iPrescription():
self.txtPrescription.insert(END,"Patient Id\t\t\t: " +PatientId.get() +"\n")
self.txtPrescription.insert(END,"Patient Name\t\t\t: " +PatientName.get() +"\n")
self.txtPrescription.insert(END,"Gender\t\t\t: " +Gender.get() + "\n")
self.txtPrescription.insert(END,"Date Of Birth\t\t\t: " +DateOfBirth.get() +"\n")
self.txtPrescription.insert(END,"Age\t\t\t: " +Age.get() + "\n")
self.txtPrescription.insert(END,"NHS Number\t\t\t: " +NhsNumber.get() +"\n")
self.txtPrescription.insert(END,"Problem\t\t\t: " +Problem.get() +"\n")
self.txtPrescription.insert(END,"Medicine\t\t\t: " +Medicine.get() +"\n")
self.txtPrescription.insert(END,"ref\t\t\t: " +ref.get() + "\n")
self.txtPrescription.insert(END,"SideEffect\t\t\t: " +SideEffect.get() +"\n")
self.txtPrescription.insert(END,"Doc_visit\t\t\t: " +Doc_visit.get() +"\n")
self.txtPrescription.insert(END,"Medi_fee\t\t\t: " +Medi_fee.get() +"\n")
self.txtPrescription.insert(END,"Room_fee\t\t\t: " +Room_fee.get() +"\n")
self.txtPrescription.insert(END,"Total_bill\t\t\t: " +Total_bill.get() +"\n")
fetch_data()

#===========================DELETE =============================

def delete():
if PatientId.get()=="" or ref.get()=="":
messagebox.showerror("Error","First select the member")
else:
conn=m.connect(host="localhost",username="root",passwd="0912",
database="hospital")
mc=conn.cursor()
querry="delete from patients_details where Patient_Id=%s "
value=(PatientId.get(),)
mc.execute(querry,value)
conn.commit()
fetch_data()
clear()
conn.close()

messagebox.showinfo("Delete","patient has been successfully deleted")

#========================= CLEAR =====================================

def clear():
PatientId.set("")
PatientName.set("")
Gender.set("")
DateOfBirth.set("")
Age.set("")
NhsNumber.set("")
Problem.set("")
Medicine.set("")
ref.set("")
SideEffect.set("")
Doc_visit.set("")
Medi_fee.set("")
Room_fee.set("")
Total_bill.set("")
self.txtPrescription.delete("1.0",END)
SearchPatientId.set("")
PatientIdBar.set("")

#==========================SEARCH ID============================

def searchId():
try:
conn=m.connect(host="localhost",username="root",passwd="0912",
database="hospital")
mc=conn.cursor()
q="select * from Patients_details where Patient_Id=%s"
value=(SearchPatientId.get(),)
mc.execute(q,value)
row=mc.fetchone()

PatientId.set(row[0])
PatientName.set(row[1])
Gender.set(row[2])
DateOfBirth.set(row[3])
Age.set(row[4])
NhsNumber.set(row[5])
Problem.set(row[6])
Medicine.set(row[7])
ref.set(row[8])
SideEffect.set(row[9])
Doc_visit.set(row[10])
Medi_fee.set(row[11])
Room_fee.set(row[12])
Total_bill.set(row[13])

conn.commit()
except:
messagebox.showinfo("Data Entry Form","No such record found!")

conn.close()
IdBar()
fetch_data()

#==========================SEARCH FRAME FILLING=============================

self.lblBarCode=Label(SearchFrame,font=("Cambria",12,"bold"),text="ID Bar Code")


self.lblBarCode.grid(row=0,column=0,padx=4,sticky=W)
self.txtBarCode=Entry(SearchFrame,font=("CCode39",13),width=29 ,
textvariable=PatientIdBar,justify='center')
self.txtBarCode.grid(row=0,column=1,padx=37)

#=================================================================

self.txtSearch=Entry(SearchFrame,font=("Cambria",16,"bold"),width=39,
textvariable=SearchPatientId,justify='right')
self.txtSearch.grid(row=0,column=2)
self.btnSearch=Button(SearchFrame,pady=1,padx=29,bd=4, font=("Cambria",12,"bold"),
command=searchId,width=13,height=1,bg="#FFB0AB",fg="black",
text="Search ID").grid(row=0,column=3,padx=1)

#========================BUTTON FRAME FILLING===============================

self.btnPrescription=Button(Buttonframe,bd=2,text="Prescription",bg="#FFB0AB",fg="black",
font=("arial",13,"bold"),width=15,padx=29,command=iPrescription)
self.btnPrescription.grid(row=0,column=0,padx=1)
self.btnPrescriptionData=Button(Buttonframe,bd=2,text="Add Data",bg="#FFB0AB",fg="black",
font=("arial",13,"bold"),width=16,height=1,padx=29,command=Add_new_data)
self.btnPrescriptionData.grid(row=0,column=1,padx=2)

self.btnUpdate=Button(Buttonframe,bd=2,text="Update",bg="#FFB0AB",fg="black",
font=("arial",13,"bold"),width=14,padx=29,pady=1,command=update)
self.btnUpdate.grid(row=0,column=2,padx=2)

self.btnDelete=Button(Buttonframe,bd=2,text="Delete",bg="#FFB0AB",fg="black",
font=("arial",13,"bold"),width=15,height=1,padx=29,pady=1,command=delete)
self.btnDelete.grid(row=0,column=3,padx=2)

self.btnClear=Button(Buttonframe,bd=2,text="Clear",bg="#FFB0AB",fg="black",
font=("arial",13,"bold"),width=15,height=1,padx=29,pady=1,command=clear)
self.btnClear.grid(row=0,column=4,padx=2)

self.btnExit=Button(Buttonframe,bd=2,text="Exit",bg="#FFB0AB",fg="black",
font=("arial",13,"bold"),width=15,height=1,padx=29,pady=1,command=Exit)
self.btnExit.grid(row=0,column=5,padx=4)

#=======================TREEVIEW FRAME FILLING=============================

scroll_x=Scrollbar(Treeviewframe,orient=HORIZONTAL)
scroll_y=Scrollbar(Treeviewframe,orient=VERTICAL)

self.hospital_table=ttk.Treeview(Treeviewframe,height=12,
column=("PatientId","PatientName","Gender","DateOfBirth","Age","NhsNumber",
"Problem","Medicine","ref","SideEffect","Doc_visit","Medi_fee","Room_fee","Total_bill"),
yscrollcommand=scroll_y.set,xscrollcommand=scroll_x.set)

scroll_x.pack(side=BOTTOM,fill=X)
scroll_y.pack(side=RIGHT,fill=Y)

scroll_x.config(command=self.hospital_table.xview)

scroll_y.config(command=self.hospital_table.yview)

self.hospital_table.heading("PatientId",text="Patient Id")
self.hospital_table.heading("PatientName",text="Patient Name")
self.hospital_table.heading("Gender",text="Gender")
self.hospital_table.heading("DateOfBirth",text="Date of Birth")
self.hospital_table.heading("Age",text="Age")
self.hospital_table.heading("NhsNumber",text="NHS Number")
self.hospital_table.heading("Problem",text="Problem")
self.hospital_table.heading("Medicine",text="Medicine")
self.hospital_table.heading("ref",text="Ref No")
self.hospital_table.heading("SideEffect",text="Side Effect")
self.hospital_table.heading("Room_fee",text="Room Fee")
self.hospital_table.heading("Total_bill",text="Total bill")
self.hospital_table.heading("Doc_visit",text="Doctor visit")
self.hospital_table.heading("Medi_fee",text="Medicine Fee")
self.hospital_table["show"]="headings"

self.hospital_table.column("PatientId",width=70,minwidth=150)
self.hospital_table.column("PatientName",width=140,minwidth=150)

self.hospital_table.column("Gender",width=85,minwidth=100)
self.hospital_table.column("DateOfBirth",width=105,minwidth=110)
self.hospital_table.column("Age",width=105,minwidth=110)
self.hospital_table.column("NhsNumber",width=105,minwidth=110)
self.hospital_table.column("Problem",width=150,minwidth=160)
self.hospital_table.column("Medicine",width=140,minwidth=150)
self.hospital_table.column("ref",width=100,minwidth=120)
self.hospital_table.column("SideEffect",width=90,minwidth=120)
self.hospital_table.column("Room_fee",width=80,minwidth=110)
self.hospital_table.column("Total_bill",width=80,minwidth=120)
self.hospital_table.column("Doc_visit",width=80,minwidth=100)
self.hospital_table.column("Medi_fee",width=60,minwidth=170)

self.hospital_table.pack(fill=BOTH,expand=1)
self.hospital_table.bind("<ButtonRelease-1>",get_cursor)

fetch_data()

if __name__=="__main__":
ob=Hospital(root)
root.mainloop()
OUTPUT:
In the above, the record got successfully inserted. You can see the record where arrow is
pointing .
Now the age 25 in record 20020, has now successfully updated as 50.
Now the record 50020 has got successfully deleted.
At last it asks whether u want to exit the program or not. If you click “no”, it wont get exit, if
you click ”yes”, it exits the program.

BACK END :
CONCLUSION:
Taking into account all the mentioned details, we can make the conclusion that
the hospital management system is the inevitable part of the lifecycle of the modern
medical institution.

It automates numerous daily operations and enables smooth interactions of the users.
Developing the hospital system software is a great opportunity to create the distinct,
efficient and fast delivering healthcare model.

Implementation of hospital management system project helps to store all the kinds of
records, provide coordination and user communication, implement policies, improve day-
to-day operations, arrange the supply chain, manage financial and human resources, and
market hospital services.

This beneficial decision covers the needs of the patients, staff and hospital authorities
and simplifies their interactions. It has become the usual approach to manage the
hospital. Many clinics have already experienced its advantages and continue developing
new hospital management system project modules.

The hospital system software is a great solution for any medical institution. It also saves
the time of the administrator.

This makes the system easy to handle and feasible for finding the omission with updating
at the same time.

If filed a query to search or update in a manual system, it will take a lot of time to process
the query and make a report which is a tedious job.

This computerized system store all the data in the database which makes it easy to fetch
and update whenever needed.
BIBILOGRAPHY:
Computer Science With Python by Sumita Arora for Class 11& 12

 https://youtu.be/HrWJzzfU9Z0 - Tkinter management system

 https://www.w3schools.com/PYTHON/PYTHON_MYSQL_
GETSTARTED.ASP – Python and MySQL Tutorial

 https://youtu.be/YR3h2CY21-U - Tkinter GUI tutorial

 https://youtu.be/r7sEF40JI4w - Bar code

 https://youtu.be/ZxbigM_AouI - Icon for title in GUI

 https://youtu.be/VT8hV6rH4Gk - Scroll bar

 https://PYTHONSPOT.COM/MYSQL-WITH-PYTHON/ - Mysql with python tutorial

You might also like