Comp Project (Debojit Das)
Comp Project (Debojit Das)
2020 21
Topic : Covid-19 Hospital
Database Management System
using SQLite3 Python
💻
Index
Index
Acknowledgement
Introduction
Hardware and Software Requirements
Hardware Requirements
Software Requirements
Database Structure
Other Elements Used in Project
CSV File : Hospital_IDs
Binary File : PD
Text File : ABC
Modules Used in Coding
Menu Navigation
Code
OUTPUT
Screenshot 1 and 2 : Registration
Screenshot 3 : OTP Received on Email for Registration
Screenshot 4 : LOG - IN After Registration and Current Registered Patient Display
Screenshot 5 : OTP Received on Registered Mobile.
Screenshot 6, 7, 8 : Patient Registration
Screenshot 9 : Current Patient Registered List Display (Without Covid-19 Status)
Screenshot 10 : Current Patient Registered List Display (With Covid-19 Status)
1
Screenshot 11 : Patient Attendant's Display and Discharged Patient Display
Screenshot 12 : Log IN as a Medical Staff
Screenshot 13 : Patient Display with and without Health Report
Screenshot 14 : Patient Sent for COVID - 19 Testing.
Acknowledgement
Apart from the efforts of me, the success of any project depends largely on the
encouragement and guidelines of many others.
2
The project also exposed me to great depths of programming and I got to learn a lot from
it.
With Regards
Debojit Das
Introduction
Mayo World Health Clinic, a renowned hospital has opened a Covid Ward to
address the present pandemic situation. The Covid Ward lacks a Hospital
Management System and the following project aims to solve this issue. The
following project deals to solve the following issues :
The doctors and laboratory Staff can also update status about patient’s
health through the patient database.
An emailing service has also been set up to send emails to the patient and
patient’s family about their Covid Test.
Security features like OTP for login and registration of the medical staff
have been incorporated to provide a safe and secure hospital
management system.
Note : All the names and information contained in the project is fictitious and
relation of the information to the real world is just a matter of coincidence.
3
Hardware and Software Requirements
Hardware Requirements
Processors: Intel Atom® processor or Intel® Core™ i3 processor or higher
Ram : 4GB
Software Requirements
Operating System : Windows 7 or 10. Mac OS X 10.11 or higher, 64-bit. Linux:
RHEL 6/7, 64-bit (almost all libraries also work in Ubuntu)
Database Structure
Name VARCHAR 50
Department VARCHAR 50
Phone_Number INT 10
Email_Address VARCHAR 30
Date_of_Joining CHAR 15
Passcode INT 4
4
💡 Medical_Staff table stores the details for all Hospital_Staff (Receptionists,
Doctors, Laboratory Staff, etc.
Name VARCHAR 50
Age INT 3
Sex CHAR 15
Phone_Number INT 10
Email_Address VARCHAR 30
Date_of_Admit CHAR 15
Date_of_Discharge CHAR 15 PATIENT STILL ADMITTED
5
💡 Patient_Table05 Stores the Patient_IDs of the Patients who are sent for
testing. Further Table Joins are used with other Tables to Display Data
Name VARCHAR 50
Phone_Number INT 10
Email_Address VARCHAR 30
Address VARCHAR 150
Name VARCHAR 50
Age INT 3
Sex CHAR 15
Phone_Number INT 10
Email_Address VARCHAR 30
Address VARCHAR 150
Date_of_Admit CHAR 15
Date_of_Discharge CHAR 15
Attendant_Name VARCHAR 50
6
Field Name Data Type Size Constraint
Attendant_Phone_Number INT 10
Patient_ID CHAR 15
7
💡 This CSV file contains the Hospital_IDs. Only people with these IDs can
register in the Covid Ward.
Binary File : PD
8
Text File : ABC
The following modules have to be installed they don’t come bundled with
python :
tabulate : This module is used to print tabular data in nicely formatted tables.
9
twilio : a web application programming interface (API) that software
developers can use to add communications such as phone calling, messaging,
video and two-factor authentication into their Python applications.
Menu Navigation
When the user (Hospital_Staff) enters the Hospita_Id. The Program provides the
options depending upon the designation of the Hospital_Staff.
10
Code
import sqlite3
import random
import smtplib
import string
import csv
from datetime import datetime
from datetime import date
from tabulate import tabulate
from twilio.rest import Client
def otp_m(pn): # Generates OTPs for Login using twilio API module.
pn=str(pn)
otp = random.randint(10000,99999)
account_sid = 'AC14663c0eb4b2ef0e7b3341b4487f39c5'
auth_token = '028aacd0ad899a4646ec52ff1d14a6df'
client = Client(account_sid, auth_token)
message = client.messages.create(
body='Your OTP to enter the Mayo World Medical Hospital is '+str(otp) + " Ple
ase note the following message has been sent for testing purposes.",
from_='+12028314843',
to='+91'+pn
)
return(otp)
11
print("")
First()
cur3=con.cursor()
cur3.execute("Select Name, Phone_Number from Attendant_TableA where Patient_I
d=?;",(HI,))
rs3=cur3.fetchall()
for i in rs3:
l3.append(i)
k3=l3[0]
cur0=con.cursor()
cur0.execute("""CREATE TABLE IF NOT EXISTS Discharge_Table09
(Patient_ID CHAR(15) PRIMARY KEY,
Name VARCHAR(50),
Age INT(3),
Sex CHAR(15),
Phone_Number INT(10),
Email_Address VARCHAR(30),
Address VARCHAR(150),
Date_of_Admit CHAR(15),
Date_of_Discharge CHAR(15),
Attendant_Name VARCHAR(50),
Attendant_Phone_Number INT(10));""")
today = date.today()
DJ= today.strftime("%d/%m/%y")
cur9=con.cursor()
cur9.execute("INSERT INTO Discharge_Table09 VALUES (?,?,?,?,?,?,?,?,?,?,?);",
(k[0],k[1],k[2],k[3],k[4],k[5],k[6],k[7],DJ,k3[0],k3[1]))
cur10=con.cursor()
cur10.execute("Delete from Discharge_Table05 where Patient_Id=?;""",(HI,))
print("The patient has been successfully discharged from the Hospital.")
cur19=con.cursor()
cur19.execute("""Update Patient_TableA
SET Date_of_Discharge = ? WHERE Patient_Id = ?;""",(DJ,HI))
con.commit()
con.close()
12
for i in rs:
l.append(i)
print(tabulate((l) ,headers=['Patient ID','Name','Age','Sex','Phone No.','Ema
il_Address','Address','Admit Date','Discharge Date','Attend. Name','Attend.Ph N
o.']))
print("")
con.commit()
con.close()
13
cur0=con.cursor()
cur0.execute("""CREATE TABLE IF NOT EXISTS Attendant_TableA
(Patient_ID CHAR(15) PRIMARY KEY,
Name VARCHAR(50),
Phone_Number INT(10),
Email_Address VARCHAR(30),
Address VARCHAR(150),
Relationship_To_Patient VARCHAR(25));""")
14
def Email_Sending(EA): #Send Email using Gmail API containing registration OTP
sender_email = "[email protected]"
rec_email = EA
password = "Das12345"
def randomStringwithDigitsAndSymbols(stringLength=10):
password_characters = string.ascii_letters + string.digits
return ''.join(random.choice(password_characters) for i in range(stri
ngLength))
message = randomStringwithDigitsAndSymbols(5)
print(message)
message1 ="This is the OTP you need to enter to register yourself in the COVI
D-19 WARD of Mayo World Health Medical Hospital "+message +" Please note that the
following mail has been sent for testing purposes."
def Email_SendingP(HI,EA): #Send Email using Gmail API containing Covid Test Repo
rt
sender_email = "[email protected]"
con=sqlite3.connect("Hospital.db")
l=[]
l0=[]
l1=[]
l2=[]
cur=con.cursor()
cur0=con.cursor()
cur1=con.cursor()
cur2=con.cursor()
cur.execute("Select Email_Address from Patient_TableA where Patient_Id=?;",(H
I,))
cur0.execute("Select Name from Patient_TableA where Patient_Id=?;",(HI,))
cur1.execute("Select Email_Address from Attendant_TableA where Patient_Id
=?;",(HI,))
cur2.execute("Select Name from Attendant_TableA where Patient_Id=?;",(HI,))
rs=cur.fetchall()
rs0=cur0.fetchall()
rs1=cur1.fetchall()
rs2=cur2.fetchall()
for i in rs:
l.append(i)
for i in rs0:
l0.append(i)
for i in rs1:
l1.append(i)
for i in rs2:
l2.append(i)
listoutput=[i[0] for i in l]
listoutput0=[i[0] for i in l0]
listoutput1=[i[0] for i in l1]
listoutput2=[i[0] for i in l2]
password = "Das12345"
server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
15
server.login(sender_email, password)
if EA==1:
rec_email1 = listoutput
rec_email0 = listoutput1
message1 = "Greeting, " + listoutput0[0] +" This is to inform you that yo
u have been tested postitive for Covid-19. Please note that this email has been s
ent for testing purposes."
message0 = "Greeting, " + listoutput2[0] +" This is to inform you that "
+listoutput0[0]+" has tested postitive for Covid-19. Please note that this email
has been sent for testing purposes."
server.sendmail(sender_email, rec_email1, message1)
server.sendmail(sender_email, rec_email0, message0)
elif EA==2:
rec_email1 = listoutput
rec_email0 = listoutput1
message1 = "Greeting , " + listoutput0[0] +" This is to inform you that y
ou have been tested negative for Covid-19. Please note that this email has been s
ent for testing purposes."
message0 = "Greeting , " + listoutput2[0] +" This is to inform you that
"+listoutput0[0]+" has tested negative for Covid-19. Please note that this email
has been sent for testing purposes."
server.sendmail(sender_email, rec_email1, message1)
server.sendmail(sender_email, rec_email0, message0)
16
print("")
county=0
csv_file.close
Name=input("What is Your Name? ")
print("")
def respon():
print("Let me know the Department where you work: ")
print("Enter 1 for Receptionist Staff")
print("Enter 2 for Nursing Staff")
print("Enter 3 for Medical Practitioner / Student")
print("Enter 4 for Junior Doctor")
print("Enter 5 for Senior Doctor")
print("Enter 6 for Laboratory Official")
print("Enter 7 for Management / Administrative Staff")
Type=int(input("Enter Your Choice: "))
l=["Receptionist Staff","Nursing Staff","Medical Practitioner / Studen
t","Junior Doctor","Senior Doctor","Laboratory Official","Management / Administra
tive Staff"]
for i in range(0,len(l)+1):
if i==Type-1:
Dept=(l[i])
return Dept
if Type-1<7:
continue
else:
print("Invalid_Input")
print("")
respon()
Dept = respon()
print("")
def EA():
EA=str(input("Enter Your Email Address: "))
return EA
17
quit()
PC = random.randint(1000,9999)
print("")
print("Please remember this 4-digit Passcode, you will require it during Log-
IN: ",PC)
print("")
today = date.today()
DJ= today.strftime("%d/%m/%y")
create(HI,Name,Dept,PhNo,EL,Adr,DJ,PC)
18
cur5.execute("""SELECT * from Attendant_TableA where Patient_Id=?;""",(HI,))
rs5=cur5.fetchall()
for i in rs5:
lp.append(i)
o=lp[0]
print("Name of the Patient's Attendant : ",o[1])
print("Phone number of Patient's Attendant : ",o[2])
print("Email Address of Patient's Attendant : ",o[3])
print("Address of Patient's Attendant : ",o[4])
print("Relationship of the Attendant to the Patient : ",o[5])
print("")
con.commit()
con.close()
19
here Date_of_Discharge = 'PATIENT STILL ADMITTED';")
rs=cur.fetchall()
for i in rs:
l.append(i)
print(tabulate((l) ,headers=['Patient_ID', 'Name', 'Age', 'Sex', 'Phone_Numbe
r', 'Email_Address', 'Address', 'Admit Date','Covid Status','Covid Type','Symptom
s']))
print("")
con.commit()
con.close()
20
CHAR(15));""")
cur0.execute("INSERT into Discharge_Table05 VALUES (?);",(k,))
con.commit()
con.close()
print("Patient Succssfully Sent for Discharge.")
print("")
else:
print("We couldn't find any patient with that Patient_Id. Please try agai
n")
Medical_Staff()
con.commit()
con.close()
21
else:
print("Invalid Input")
status()
Email_SendingP(k,hola)
cur=con.cursor()
cur0=con.cursor()
cur.execute("""Update Patient_TableA
SET Covid_Status = ? WHERE Patient_Id = ?;""",(a,k))
print("Your Response has been successfully uploaded")
print("")
cur0.execute("""DELETE FROM Patient_Table05 where Patient_ID =?;""",(k,))
con.commit()
con.close()
22
= ?;",(a,k))
con.commit()
con.close()
elif hola==2:
print("")
print("Enter 1 if the patient is asymptomatic.")
print("Enter 2 if the patient is syptomatic.")
print("Enter 3 if the patient is Corona Negative.")
respon=int(input("Enter your Response : "))
print("")
if respon==1:
a='Asymptomatic'
cur.execute("Update Patient_TableA SET Covid_Type = ? WHERE Patient_I
d = ?;",(a,k))
con.commit()
con.close()
elif respon==2:
a='Symptomatic'
cur.execute("Update Patient_TableA SET Covid_Type = ? WHERE Patient_I
d = ?;",(a,k))
con.commit()
con.close()
elif respon==3:
a='Corona Negative'
cur.execute("Update Patient_TableA SET Covid_Type = ? WHERE Patient_I
d = ?;",(a,k))
con.commit()
con.close()
else:
print("Invalid Input")
status0()
elif hola==3:
print("")
print("Enter 1 if the patient has no Symptoms.")
print("Enter 2 if the patient has mild Symptoms.")
print("Enter 3 if the patient has severe Sympotoms.")
print("Enter 4 if the patient has highly severe Sympotoms.")
print("Enter 5 if the patient is Corona Negative.")
respon0=int(input("Enter your Response : "))
print("")
if respon0==1:
a='No Symptoms'
cur.execute("Update Patient_TableA SET Symptoms = ? WHERE Patient_Id
= ?;",(a,k))
elif respon0==2:
a='Mild Symptoms'
cur.execute("Update Patient_TableA SET Symptoms = ? WHERE Patient_Id
= ?;",(a,k))
elif respon0==3:
a='Severe Symptoms'
cur.execute("Update Patient_TableA SET Symptoms = ? WHERE Patient_Id
= ?;",(a,k))
elif respon0==4:
a='Highly Severe Symptoms'
cur.execute("Update Patient_TableA SET Symptoms = ? WHERE Patient_Id
= ?;",(a,k))
elif respon0==5:
a='Corona Negative'
23
cur.execute("Update Patient_TableA SET Symptoms = ? WHERE Patient_Id
= ?;",(a,k))
else:
print("Invalid Input")
status0()
print("")
print("Enter 1 if the patient is asymptomatic.")
print("Enter 2 if the patient is syptomatic.")
print("Enter 3 if the patient is Corona Negative.")
respon1=int(input("Enter your Response : "))
print("")
if respon1==1:
a='Asymptomatic'
cur.execute("Update Patient_TableA SET Covid_Type = ? WHERE Patient_I
d = ?;",(a,k))
con.commit()
con.close()
elif respon1==2:
a='Symptomatic'
cur.execute("Update Patient_TableA SET Covid_Type = ? WHERE Patient_I
d = ?;",(a,k))
con.commit()
con.close()
elif respon1==3:
a='Corona Negative'
cur.execute("Update Patient_TableA SET Covid_Type = ? WHERE Patient_I
d = ?;",(a,k))
con.commit()
con.close()
else:
print("Invalid Input")
status0()
print("")
else:
print("Invalid Input")
status0()
print("")
24
print("Enter 4 to view current patient list with Covid-19 Status.")
print("Enter 5 to view patient details for a particular patient.")
print("Enter 6 to view attendant's list.")
print("Enter 7 to view discharged patient list.")
print("Enter 8 to Log-Out.")
kola=int(input("Enter your choice:"))
print("")
if kola==1:
timesd=int(input("Enter the number of entries you want to make : "))
for i in range (0,timesd):
crea0()
elif kola==3:
patient_display()
elif kola==4:
patient_display0()
elif kola==2:
print("")
print("The following patient needs to be discharged :-")
print("")
discharge_display()
print("")
pki=input("Enter the Patient_Id of the Patient who needs to be discharged
: ")
discharge(pki)
print("")
elif kola==5:
olas=input("Enter the Patient_Id : ")
particular_patient(olas)
elif kola==6:
atten()
elif kola==7:
disdisplay()
elif kola==8:
First()
else:
print("Invalid Input")
Receptionist_Staff()
25
elif kola==6:
First()
else:
print("Invalid Input")
Medical_Staff()
Administrative_Staff()
26
print("We couldn't match the ID you entered with our Database. Please Reg
ister and Try Again")
First()
con.commit()
27
print("Welcome to Mayo World Health Hospital")
now = datetime.now()
print(now.strftime("%B %d, %Y %I:%M: %p"))
print("")
print("Enter 1 For Log-In.")
print("Enter 2 For Registration.")
print("Enter 3 to Exit.")
try:
response1= int(input("Please Enter Your Response : "))
if response1 == 1:
ok=display()
ola=displayboard(ok)
authentication(ok)
print("")
if ola == "Receptionist Staff":
Receptionist_Staff()
elif ola == "Management / Administrative Staff":
Administrative_Staff()
elif ola == "Medical Practitioner / Student":
Medical_Staff()
elif ola == "Junior Doctor":
Medical_Staff()
elif ola == "Senior Doctor":
Medical_Staff()
elif ola == "Nursing Staff":
Medical_Staff()
elif ola == "Laboratory Official":
Laboratory_Staff()
elif response1 == 2:
Registration()
elif response1== 3:
exit()
elif response1 !=1 and response1 !=2 and response !=3:
print("Invalid Input")
First()
except ValueError:
print("Invalid Input")
First()
First()
OUTPUT
Screenshot 1 and 2 : Registration
28
Screenshot 3 : OTP Received on Email for Registration
29
Screenshot 4 : LOG - IN After Registration and Current
Registered Patient Display
30
Screenshot 5 : OTP Received on Registered Mobile.
31
Screenshot 9 : Current Patient Registered List Display (Without
Covid-19 Status)
32
Screenshot 10 : Current Patient Registered List Display (With
Covid-19 Status)
33
Screenshot 11 : Patient Attendant's Display and Discharged
Patient Display
34
Screenshot 13 : Patient Display with and without Health Report
35
Screenshot 15 : Current Patient Display after sent for Testing.
36
Screenshot 17 : Updating Covid -19 Status of tested Patients.
37
Screenshot 20 : As soon as Patient Covid Status is Updated.
Patient who need to be tested table is updated automatically.
38
Screenshot 21 : Current Patient Table after Covid -19 Status
Updation
39
Screenshot 25 : Current Patient Table Display after Health
Report Update
40
Screenshot 26 and 27 : Patient Sent for Discharge by Doctor
(any medical Staff) and Discharged from Hospital by
Receptionist
41
Screenshot 28 : Updated Discharged Patient List
42
Screenshot 30 : LOG - IN as Management / Administrative Staff
and Display of Current Hospital Staff
43
Screenshot 32 : Display Information of a Particular Patient
44
Bibilography
1. Textbook for CBSE Class XII Computer Science with Python By : Preeti Aroroa .
7. Project Idea is totally based on imagination and some help was taken through
contacting some of my father's friend who work at Sikkim Manipal Hospital.
45
Thank You !