0% found this document useful (0 votes)
79 views

Comp Project (Debojit Das)

The document describes a database project for a COVID-19 hospital using SQLite3 in Python. It details the database structure, modules used, and screenshots of the program's outputs like patient registration and updating their COVID status.

Uploaded by

Debojit Das
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
0% found this document useful (0 votes)
79 views

Comp Project (Debojit Das)

The document describes a database project for a COVID-19 hospital using SQLite3 in Python. It details the database structure, modules used, and screenshots of the program's outputs like patient registration and updating their COVID status.

Uploaded by

Debojit Das
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/ 47

Computer Project

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.

Screenshot 15 : Current Patient Display after sent for Testing.


Screenshot 16 : Log Out from one account (Medical Staff Account) and Log In to another
account (Laboratory Staff Account) and Display of Patients who need to be tested.
Screenshot 17 : Updating Covid -19 Status of tested Patients.
Screenshot 18 and 19 : Post Covid Status Update Automated Email is Sent to Patient and
Patient's Attendant / Family Member
Screenshot 20 : As soon as Patient Covid Status is Updated. Patient who need to be tested
table is updated automatically.
Screenshot 21 : Current Patient Table after Covid -19 Status Updation
Screenshot 22, 23 and 24 : Update Patient Health
Screenshot 25 : Current Patient Table Display after Health Report Update
Screenshot 26 and 27 : Patient Sent for Discharge by Doctor (any medical Staff) and
Discharged from Hospital by Receptionist
Screenshot 28 : Updated Discharged Patient List

Screenshot 29 : Current Patient Tables No More Display the Discharged Patients.


Screenshot 30 : LOG - IN as Management / Administrative Staff and Display of Current
Hospital Staff
Screenshot 31 : Termination of Employment of Hospital Staff and Display of Updated Staff
List. The Terminated Staff can no longer Log - into the system.
Screenshot 32 : Display Information of a Particular Patient
Bibilography

Acknowledgement

Apart from the efforts of me, the success of any project depends largely on the
encouragement and guidelines of many others.

I would like to express my special thanks of gratitude to my Computer Teacher Mr.


Devashis Chakraborty for their able guidance and support in completing my project. This
project would not have completed without sir's enormous help and worthy experience.
I express deep sense of gratitude to almighty God for giving me strength for the
successful completion of the project.
Speical thanks to some of my very worthy friends whom I consulted whenever I had
doubts.

2
The project also exposed me to great depths of programming and I got to learn a lot from
it.

With Regards
Debojit Das

(Student at Delhi Public School Siliguri)

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 :

Provides a registration system for doctors to register from the main


hospital to the Covid ward.

Provides a patient database system that can be accessed by the Hospital


Staff.

The patient database provides the receptionist staff to admit and


discharge a patient

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

Disk space: 1 GB (Recommended 2GB to 3GB)

Ram : 4GB

Keyboard and Mouse

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)

Front End - Python 3.6 or Higher

Back End - SQLite 3

Install twilio and tabulate modules in python.

Database Structure

Table Name : Medical_Staff

Field Name Data Type Size Constraint

Hospita_ID CHAR 15 PRIMARY KEY

Name VARCHAR 50

Department VARCHAR 50
Phone_Number INT 10

Email_Address VARCHAR 30

Address VARCHAR 150

Date_of_Joining CHAR 15
Passcode INT 4

4
💡 Medical_Staff table stores the details for all Hospital_Staff (Receptionists,
Doctors, Laboratory Staff, etc.

Table Name : Patient_TableA

Field Name Data Type Size Constraint Default


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 PATIENT STILL ADMITTED

Covid_Type CHAR 15 NOT UPDATED YET

Covid_Status CHAR 10 NOT UPDATED YET

Symptoms CHAR 20 NOT UPDATED YET

💡 Patient_TableA stores all the Patient Details

Table Name : Patient_Table05

Field Name Data Type Size


Patient_ID CHAR 15

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

Table Name : Attendant_TableA

Field Name Data Type Size Constraint


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

💡 Attendant_TableA stores the details of the Patient's Attendant.

Table Name : Discharge_Table09

Field Name Data Type Size Constraint


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

6
Field Name Data Type Size Constraint

Attendant_Phone_Number INT 10

💡 Discharge_Table stores the data of Discharged Patients.

Table Name : Discharge_Table05

Field Name Data Type Size

Patient_ID CHAR 15

💡 Discharge_Table05 stores only the Patient_Id of the patients who need to


be discharged. Further Table Joins are used with other Tables to perform
some other functions.

Other Elements Used in Project


CSV File : Hospital_IDs

7
💡 This CSV file contains the Hospital_IDs. Only people with these IDs can
register in the Covid Ward.

Binary File : PD

💡 This Binary File contains the hospital password.

8
Text File : ABC

💡 This text file contains the last automatically generated Patient-Id.

Modules Used in Coding

SQLite3  :  SQLite3 module provides an SQL interface which is shipped by


default with Python.
Random : Random module allows to generate random numbers, strings, etc.
Datetime : Datetime module supplies classes to work with date and time.
CSV : csv module implements classes to read and write tabular data in CSV
format.
Smtplib :  smtplib module defines an SMTP client session object that can be
used to send mail to  any Internet machine. This also comes bundled with
Python.

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_m1(pn): #This Function was used as an alternative to otp_m(pn).


pn=str(pn) #otp_m(pn) uses twilio trial account api which has some restricti
ons.
otp = random.randint(10000,99999)
print(otp)
return otp

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)

def create(HI,Name,Dept,PhNo,EA,Adr,DJ,PC): #Creates Table Medical_Staff & take i


nput.
con=sqlite3.connect("Hospital.db")
cur=con.cursor()
cur.execute("""CREATE TABLE IF NOT EXISTS Medical_Staff
(Hospital_ID CHAR(15) PRIMARY KEY,
Name VARCHAR(50),
Department VARCHAR(50),
Phone_Number INT(10),
Email_Address VARCHAR(30),
Address VARCHAR(150),
Date_of_Joining CHAR(15),
Passcode INT(4));""")

cur.execute("INSERT INTO Medical_Staff VALUES (?,?,?,?,?,?,?,?);",(HI,Name,De


pt,PhNo,EA,Adr,DJ,PC))
con.commit()
con.close()
print("Your data has been successfully uploaded on the system.")
print("You can now login To COVID-19 Ward Medical System.")

11
print("")
First()

def discharge(HI): #Creates Discharge_Table09 and transfers data from Patient_Tab


leA
con=sqlite3.connect("Hospital.db") #Also Deletes the data from Discharge_Tabl
e05
l=[]
l3=[]
cur=con.cursor()
cur.execute("Select Patient_ID,Name,Age,Sex,Phone_Number,Email_Address, Addre
ss,Date_of_Admit from Patient_TableA where Patient_Id=?;",(HI,))
rs=cur.fetchall()
for i in rs:
l.append(i)
k=l[0]

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()

def disdisplay(): #Displays the Discharge_Table09


con=sqlite3.connect("Hospital.db")
l=[]
cur=con.cursor()
cur.execute("SELECT * from Discharge_Table09;")
rs=cur.fetchall()

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()

def display_without_passcode(): #Display Medical_Staff without passcode column.


con=sqlite3.connect("Hospital.db")
l=[]
cur=con.cursor()
cur.execute("SELECT Hospital_ID, Name, Department, Phone_Number, Email_Addres
s, Address, Date_of_Joining FROM Medical_Staff;")
rs=cur.fetchall()
for i in rs:
l.append(i)
print(tabulate((l) ,headers=['Hopital ID', 'Name','Department','Phone Numbe
r','Email_Address','Address','Date of Joining']))
con.commit()
con.close()

def display_with_passcode(): #Display Medical_Staff with passcode column.


con=sqlite3.connect("Hospital.db")
l=[]
cur=con.cursor()
cur.execute("SELECT * FROM Medical_Staff;")
rs=cur.fetchall()
for i in rs:
l.append(i)
print(tabulate((l) ,headers=['Hopital ID', 'Name','Department','Phone Numbe
r','Email_Address','Address','Date of Joining','Passcode']))
con.commit()
con.close()

def create0(Patient_ID,Name,Age,Sex,Phone_Number,Email_Address, Address,Date_of_A


dmit,Name0,Phone_Number0,Email_Address0, Address0 ,Relationship_To_Patient):
con=sqlite3.connect("Hospital.db") #Create Patient_TableA and inputs Data
cur=con.cursor()
cur.execute("""CREATE TABLE IF NOT EXISTS Patient_TableA
(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) DEFAULT "PATIENT STILL ADMITTED",
Covid_Type CHAR(15) DEFAULT "NOT UPDATED YET",
Covid_Status CHAR(10)DEFAULT "NOT UPDATED YET",
Symptoms CHAR(20)DEFAULT "NOT UPDATED YET");""")

cur.execute("INSERT INTO Patient_TableA (Patient_ID, Name, Age, Sex, Phone_Nu


mber, Email_Address, Address, Date_of_Admit) VALUES (?,?,?,?,?,?,?,?);",(Patient_
ID,Name,Age,Sex,Phone_Number,Email_Address,Address,Date_of_Admit))

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));""")

cur0.execute("INSERT INTO Attendant_TableA VALUES (?,?,?,?,?,?);",(Patient_I


D,Name0,Phone_Number0,Email_Address0, Address0 ,Relationship_To_Patient))
con.commit()
con.close()
print("Your data has been successfully uploaded on the system.")
print("")

def crea0(): #Takes input for Patient_TableA


print("")
file = open("H:\\Python\\Computer Project\\ABC.txt","r")
z=file.read()
ino=(z[2:6])
ino=int(ino)
if int(ino)==9999:
if (z[1])=="Z":
alpha=ord(z[0])+1
newnumber=chr(alpha)+'A'+'0000'
print(newnumber)
else:
gama=ord(z[1])+1
newnumber=z[0]+chr(gama)+'0000'
print(newnumber)
else:
beta=int(ino)+1
beta=str(beta)
newnumber=z[0:2]+beta.zfill(3)
file.close()

file = open("H:\\Python\\Computer Project\\ABC.txt","w")


file.write(newnumber)
file.close()
A=newnumber
B=input("Enter the Name of the Patient : ")
C=int(input("Enter the age of the Patient : "))
D=input("Sex of the Patient : ")
E=int(input("Enter the Phone Number of the Patient : "))
F=input("Enter the Email-Address of the Patient : ")
G=input("Enter the Address of the Patient : ")
today = date.today()
H=today.strftime("%d/%m/%y")
I=input("Enter the Name of the Patient's Attendant : ")
J=int(input("Enter the Phone Number of the Patient's Attendant : "))
K=input("Enter the Email-Address of the Patient's Attendant : ")
L=input("Enter the Address of the Patient's Attendant : ")
M=input("Enter the Relationship of the Attendant to the Patient : ")
create0(A,B,C,D,E,F,G,H,I,J,K,L,M)

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."

server = smtplib.SMTP('smtp.gmail.com', 587)


server.starttls()
server.login(sender_email, password)
server.sendmail(sender_email, rec_email, message1)
return message

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)

def Registration(): #Registration Function for Medical Staff Registration


file=open("PD.bin","rb")
b=(file.read())
b=b.decode("utf-8") #Converting Bytes Literals to String#
k=1
file.close()
while k==1:
print("")
Pass=input("Enter the Hospital Password:")
if Pass == b:
break
else:
print("You have entered an Invalid Password:")
continue
print("")
with open("Hospital_IDs.csv", encoding='utf-8-sig') as csv_file:
csv_reader = csv.reader(csv_file)
data=list(csv_reader)
county=0
length=len(data)
lk=0
while lk==0:
HI=input("Enter Your Hospital ID:")
for i in data:
if i[0]==HI:
lk=1
print("Hospital_ID Matched")
print("")
else:
county+=1
if county==length:
print("Invalid Hospital_ID")

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

PhNo=input("Enter Your Phone Number: ")


EL= EA()
otp=Email_Sending(EL)
Adr=input("Enter Your Address:")
p=0
while p==0:
print("")
OTP=input("Enter the OTP Rrecieved on your Email Address:")
if OTP==otp:
print("Registration Successfull !!!")
break
else:
print("You have entered an invalid OTP")
print("")
rp=input("Do you want to reset your Email Address? (Y/N) :")
if rp == "Y" or rp == "y":
EL = EA()
otp=Email_Sending(EL)
elif rp == "N" or rp == "n":
res=input("Do you want your OTP to be resent? (Y/N) :")
if res == "Y" or res == "y":
otp=Email_Sending(EL)
else:

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)

def remove(): #Remove Data from Patient_Table05


con=sqlite3.connect("Hospital.db")
cur=con.cursor()
r=input("Enter the Patient ID : ")
cur.execute("""DELETE FROM Patient_Table05 where Patient_ID =?;""",(r,))
con.commit()
con.close()

def patient_display(): #Display Patient_TableA without Covid-Status and Health Re


port
con=sqlite3.connect("Hospital.db")
l=[]
cur=con.cursor()
cur.execute("""SELECT Patient_Id, Name, Age, Sex, Phone_Number,
Email_Address, Address Date_of_Admit from Patient_TableA where 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', 'Date of Admit',]))
print("")
con.commit()
con.close()

def particular_patient(HI): #Display data of a particular patient.


con=sqlite3.connect("Hospital.db")
l=[]
lp=[]
cur=con.cursor()
cur.execute("""SELECT * from Patient_TableA where Patient_Id=?;""",(HI,))
rs=cur.fetchall()
for i in rs:
l.append(i)
k=l[0]
print("Name of patient : ",k[1])
print("Age of the patient : ",k[2])
print("Sex of the patient : ",k[3])
print("Phone Number of the patient : ",k[4])
print("Email Address of the patient : ",k[5])
print("Address of the patient : ",k[6])
print("Date of Admit of the Patient : ",k[7])
print("Date of Discharge : ", k[8])
print("Covid Type : ", k[9])
print("Covid Status : ", k[10])
print("Symptoms : ", k[11])
print("")
cur5=con.cursor()

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()

def atten(): #Display Attendant Information


con=sqlite3.connect("Hospital.db")
l=[]
cur=con.cursor()
cur.execute("""Select Patient_TableA.Patient_Id, Patient_TableA.Name, Attenda
nt_TableA.Name, Attendant_TableA.Phone_Number,
Attendant_TableA.Email_Address, Attendant_TableA.Address, Relationship_To_Pat
ient from Patient_TableA LEFT JOIN Attendant_TableA on
Patient_TableA.Patient_Id = Attendant_TableA.Patient_Id;""")
rs=cur.fetchall()
for i in rs:
l.append(i)
print(tabulate((l) , headers=['Patient ID','Patient Name','Attendant Name','A
ttendant Phone Number','Attendant Email Address','Attendant Address','Attendant R
elationship to Patient']))
print("")
con.commit()
con.close()

def patient_display0(): #Display Patient_TableA without Health Report


con=sqlite3.connect("Hospital.db")
l=[]
cur=con.cursor()
cur.execute("""SELECT Patient_Id, Name, Age, Sex, Phone_Number,
Email_Address, Address, Date_of_Admit, Covid_Status from Patient_TableA where Dat
e_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', 'Date of Admit','Covid Status',]))
print("")
con.commit()
con.close()

def patient_display1(): #Display Patient_TableA with Covid-Status and Health Repo


rt
con=sqlite3.connect("Hospital.db")
l=[]
cur=con.cursor()
cur.execute("SELECT Patient_ID, Name, Age, Sex, Phone_Number, Email_Address,
Address, Date_of_Admit, Covid_Status, Covid_Type, Symptoms from Patient_TableA w

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()

def Testing_Table(): #Create Patient_Table05 and input Data


l=[] #Update Covid Status of Patient_TableA
con=sqlite3.connect("Hospital.db")
cur=con.cursor()
cur0=con.cursor()
cur8=con.cursor()
cur0.execute("SELECT Patient_ID from Patient_TableA;")
rs=cur0.fetchall()
for i in rs:
l.append(i)
listoutput=[i[0] for i in l]
k=input("Enter the Patient Id of the patient whom you want to send for testin
g:")
if k in listoutput:
cur.execute("""CREATE TABLE IF NOT EXISTS Patient_Table05
(Patient_ID CHAR(15));""")
cur0.execute("INSERT INTO Patient_Table05 VALUES (?);",(k,))
cur8.execute("""Update Patient_TableA
SET Covid_Status = 'Sent For Testing' WHERE Patient_Id = ?;""",(k,))
con.commit()
con.close()
print("Patient Successfully Sent For Testing")
print("")
else:
print("We couldn't find any patient with that Patient_Id. Please try agai
n.")
print("")
con.close()
Medical_Staff()

def Discharge_Table(): #Create Discharge_Table05 and input data.


l=[]
con=sqlite3.connect("Hospital.db")
cur=con.cursor()
cur7=con.cursor()
cur0=con.cursor()
cur.execute("SELECT Patient_ID from Patient_TableA;")
rs=cur.fetchall()
for i in rs:
l.append(i)
listoutput=[i[0] for i in l]
k=input("Enter the Patient ID of the patient whom you want to send for discha
rge : ")
if k in listoutput:
cur7.execute("""CREATE TABLE IF NOT EXISTS Discharge_Table05 (Patient_ID

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()

def discharge_display(): #Display Data of Patients who need to be discharged.


con=sqlite3.connect("Hospital.db")
l=[]
cur=con.cursor()
cur.execute("""Select Patient_TableA.Patient_ID, Name, Age, Sex, Phone_Numbe
r, Email_Address, Address, Date_of_Admit from Discharge_Table05
LEFT JOIN Patient_TableA ON Discharge_Table05.Patient_Id = Patient_TableA.Patient
_Id;""")
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', 'Date of Admit',]))
con.commit()
con.close()
print("")

def laboratorytestingjoin(): #Display data of patient who neeed to be tested.


con=sqlite3.connect("Hospital.db")
l=[]
cur=con.cursor()
cur.execute("""Select Patient_TableA.Patient_ID, Name, Age, Sex, Phone_Numbe
r, Email_Address, Address, Date_of_Admit from Patient_Table05
LEFT JOIN Patient_TableA ON Patient_Table05.Patient_Id = Patient_TableA.Patient_I
d;""")
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', 'Date of Admit',]))
con.commit()
con.close()
print("")

def status(): #Update Covid_Status Report


k=input("Enter the Patient Id of the patient whose Covid-19 Report you want t
o update : ")
con=sqlite3.connect("Hospital.db")
print("Enter 1 if the Patient tested positive for Covid-19")
print("Enter 2 if the Patient tested negative for Covid-19")
hola=int(input("Enter Your Response : "))
if hola==1:
a='Positive'
elif hola==2:
a='Negative'

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()

def status0(): #Update Covid Health Report


con=sqlite3.connect("Hospital.db")
cur=con.cursor()
k=input("Enter the Patient Id of the patient whose Health Report you want to
update : ")
print("Enter 1 to update Symptoms Report.")
print("Enter 2 to update Covid Type Report.")
print("Enter 3 to update both Symptoms and Covid Type Report.")
hola=int(input("Enter your Choice : "))
if hola==1:
print("")
print("Enter 1 if the patient has no Symptoms.")
print("Enter 2 if the patient has mild Sympotoms.")
print("Enter 3 if the patient has severe Sympotoms.")
print("Enter 4 if the patient has highly severe Sympotoms.")
respon=int(input("Enter your Response : "))
print("")
if respon==1:
a='No Symptoms'
cur.execute("Update Patient_TableA SET Symptoms = ? WHERE Patient_Id
= ?;",(a,k))
con.commit()
con.close()
elif respon==2:
a='Mild Symptoms'
cur.execute("Update Patient_TableA SET Symptoms = ? WHERE Patient_Id
= ?;",(a,k))
con.commit()
con.close()
elif respon==3:
a='Severe Symptoms'
cur.execute("Update Patient_TableA SET Symptoms = ? WHERE Patient_Id
= ?;",(a,k))
con.commit()
con.close()
elif respon==4:
a='Highly Severe Symptoms.'
cur.execute("Update Patient_TableA SET Symptoms = ? WHERE Patient_Id
= ?;",(a,k))
con.commit()
con.close()
elif respon==5:
a='Corona Negative'
cur.execute("Update Patient_TableA SET Symptoms = ? WHERE Patient_Id

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("")

def Laboratory_Staff(): #Menu Bar of Laboratory Staff


print("Enter 1 to view the patients who need to be tested.")
print("Enter 2 to update the patient testing report.")
print("Enter 3 to Log-Out.")
kola=int(input("Enter your choice:"))
print("")
if kola==1:
laboratorytestingjoin()
elif kola==2:
status()
elif kola==3:
First()
Laboratory_Staff()

def Receptionist_Staff(): #Menu Bar of Receptionist Staff


print("Enter 1 for patient(s) registration.")
print("Enter 2 to discharge a patient.")
print("Enter 3 to view current registered patient list.")

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()

def Medical_Staff(): #Menu Bar for Medical_Staff


print("Enter 1 to view current patient list without Health Report.")
print("Enter 2 to view current patient list with Health Report.")
print("Enter 3 to update patient health.")
print("Enter 4 to send a patient for testing.")
print("Enter 5 to send a patient for discharge.")
print("Enter 6 to Log-Out.")
kola=int(input("Enter your choice:"))
print("")
if kola==4:
Testing_Table()
elif kola==1:
patient_display0()
elif kola==3:
status0()
elif kola==2:
patient_display1()
elif kola==5:
Discharge_Table()

25
elif kola==6:
First()
else:
print("Invalid Input")
Medical_Staff()

def Termination(): #Function for Termination of Employment


con=sqlite3.connect("Hospital.db")
cur=con.cursor()
r=input("Enter the Hospital ID of the Staff whose employment you want to term
inate : ")
cur.execute("Delete from Medical_Staff where Hospital_Id=?;""",(r,))
print("The Employment of the Staff has been successfully terminated.")
print("")
con.commit()
con.close()

def Administrative_Staff(): #Menu Bar for Administrative Staff


print("Enter 1 to view full current patient list.")
print("Enter 2 to view current Hospital_Staff list.")
print("Enter 3 to terminate Employment contract.")
print("Enter 4 to display discharged patient list.")
print("Enter 5 to Log-Out.")
kola=int(input("Enter your choice:"))
print("")
if kola==2:
display_with_passcode()
print("")
elif kola==5:
First()
elif kola==1:
patient_display1()
elif kola==3:
Termination()
elif kola==4:
disdisplay()
else:
print("Invalid Input")

Administrative_Staff()

def display(): #Check if Hospital_Id is registered.


print("")
idk=input("Enter the Hospital ID:")
con=sqlite3.connect("Hospital.db")
l=[]
cur=con.cursor()
cur.execute("SELECT Hospital_ID FROM Medical_Staff;")
rs=cur.fetchall()
for i in rs:
l.append(i)
listoutput=[i[0] for i in l]
if idk in listoutput:
return idk
else:

26
print("We couldn't match the ID you entered with our Database. Please Reg
ister and Try Again")
First()
con.commit()

def displayboard(a): #Displays Name Designation when Hospital_ID is entered.


print("")
name=a
con=sqlite3.connect("Hospital.db")
cur=con.cursor()
cur.execute("SELECT Name, Department FROM Medical_Staff where Hospital_ID =
?;",(name,))
rs=cur.fetchall()
for a, b in rs:
print("Greetings ", a)
print("Department : ", b)
return b
print("")

def authentication(ok): #Authenticate Passcode and OTP


name=ok
con=sqlite3.connect("Hospital.db")
cur=con.cursor()
l=[]
l0=[]
cur=con.cursor()
cur.execute("SELECT Passcode FROM Medical_Staff where Hospital_ID = ?;",(nam
e,))
cur0=con.cursor()
cur0.execute("SELECT Phone_Number FROM Medical_Staff where Hospital_ID = ?;",
(name,))
rs=cur.fetchall()
for i in rs:
l.append(i)
listoutput=[i[0] for i in l]
passo=listoutput[0]
print(passo)
rs0=cur0.fetchall()
for i in rs0:
l0.append(i)
listoutput0=[i[0] for i in l0]
passo0=listoutput0[0]
print("")
passi=int(input("Enter Your Passcode:"))
if passo==passi:
otp=otp_m1(passo0)
iotp=int(input("Enter the OTP Sent on your registered Mobile Number:"))
if iotp==otp:
print("Log-In Successful")
else:
print("Log-In Failed")
authentication(name)
else:
print("Log-In Failed")
authentication(name)

def First(): #Main Function

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.

Note : In the further screenshots you will


find I will be printing the OTP . Since I am
using the Trial Edition of the Twilio
Account OTP can only be sent to certain
registered numbers. To send OTP to any
any phone number one needs to purchase
the Twilio Subscription.

For Demonstration purposes and ease of


work this step has been taken.

Furthermore OTP sent to Email and


Passcode will also be printed for ease of
work.

Screenshot 6, 7, 8 : Patient Registration

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

Screenshot 12 : Log IN as a Medical Staff

34
Screenshot 13 : Patient Display with and without Health Report

Screenshot 14 : Patient Sent for COVID - 19 Testing.

35
Screenshot 15 : Current Patient Display after sent for Testing.

Screenshot 16 : Log Out from one account (Medical Staff


Account) and Log In to another account (Laboratory Staff
Account) and Display of Patients who need to be tested.

36
Screenshot 17 : Updating Covid -19 Status of tested Patients.

Screenshot 18 and 19 : Post Covid Status Update Automated


Email is Sent to Patient and Patient's Attendant / Family
Member

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

Screenshot 22, 23 and 24 : Update Patient Health

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

Screenshot 29 : Current Patient Tables No More Display the


Discharged Patients.

42
Screenshot 30 : LOG - IN as Management / Administrative Staff
and Display of Current Hospital Staff

Screenshot 31 : Termination of Employment of Hospital Staff


and Display of Updated Staff List. The Terminated Staff can no
longer Log - into the system.

43
Screenshot 32 : Display Information of a Particular Patient

44
Bibilography

1. Textbook for CBSE Class XII Computer Science with Python By : Preeti Aroroa .

2. https://stackoverflow.com/ (Used this site as a reference whenever I came across


an error in my code which after many failed attempts couldn't solve by myself).

3. https://www.w3resource.com/python-exercises/ (Used as a reference site for


Syntax and other utilities).

4. https://www.twilio.com/docs/libraries/python (Used to download their API


module).

5. https://pypi.org/project/tabulate/ (Used to dowonload tabulate module).

6. https://www.notion.so/ (Used it to prepare the Project File and other


management works).

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 !

You might also like