def create():
print('\n')
print("\n------------------------------\n")
con='yes'
while [Link]()=='YES':
f0=open('[Link]','a')
[Link]()
f=open('[Link]','r')
a=[Link]()
[Link]()
if a!='':
f1=open('[Link]','w')
b=int(a)+1
b=str(b)
x=b
if a=='':
a='1'
f1=open('[Link]','w')
[Link]('1')
[Link]()
x=a
print("enter the patient's no: ",x)
print('\n')
print('enter the patients details')
patname=input('enter the name of the patient:')
patfathersname=input("enter the name of the patient's father:")
patmothersname=input("enter the name of the patient's mother:")
patphoneno1=input('enter the first phone no:')
patphoneno2=input('enter the second phone no:')
patname='"'+patname+'"'
patfathersname='"'+patfathersname+'"'
patmothersname='"'+patmothersname+'"'
mycur1 = [Link]()
cc=input("DO you confirm the above entered data:")
if [Link]() == "YES":
A='insert into Patient_details
values('+x+','+patname+','+patfathersname+','+patmothersname+','+patphoneno1+','+pa
tphoneno2+');'
[Link](A)
[Link]()
f1=open('[Link]','w')
[Link](x)
[Link]()
if [Link]() == "NO":
x=int(x)-1
x=str(x)
f1=open('[Link]','w')
[Link](x)
[Link]()
con=input('\ndo u want to continue:')
print('\n')
if [Link]()=='NO':
print("\n------------------------------\n")
break
print('\n')
def view():
print("\n------------------------------\n")
con='Yes'
mycur1 = [Link]()
[Link]('select * from patient_details;')
rec= [Link]()
while [Link]()=='YES':
x=input("enter the patients no:")
L=len(rec)
for i in rec:
if i[0]==x:
print('\nThe details are:')
print('\n')
print('patient name :',i[1])
print('patient fathers name:',i[2])
print('patient mothers name:',i[3])
print('patient phone no1:',i[4])
print('patient phone no2:',i[5])
break
if i==rec[L-1]:
print('Patient Record Not Found')
con=input('\ndo u want to continue:')
print('\n')
if [Link]()=='NO':
print("\n------------------------------\n")
break
[Link]()
def consultation():
con='yes'
print("\n------------------------------\n")
while [Link]()=='YES':
import [Link]
con1 = [Link](host='localhost', user='root',
password='root')
mycur1 = [Link]()
con2 = [Link](host='localhost', user='root',
password='root')
mycur2 = [Link]()
conn=input('\[Link] New Consultation\[Link] Old Consultations\n\nEnter
your Choice:')
print('\n')
if conn=='1':
x=input("Enter The Patient's Number: ")
V='select patient_name from patient_details where patient_no = '+x+' ;'
x=x+'tb'
[Link]('use class96;')
[Link]()
[Link](V)
rec= [Link]()
[Link]()
z=rec[0][0]
y=input('enter the reason:')
time=input('Enter the Date(yyyy-mm-dd):')
[Link]('use class98;')
[Link]()
#[Link]('show databases;')
[Link]('show tables;')
dbs=[Link]()
l=len(dbs)
print(dbs)
cc='n'
for i in range(0,l):
if str(dbs[i][0])==x:
cc='y'
break
if cc=='n':
print(2)
V='CREATE TABLE '+x+' (patient_name VARCHAR(20),Date DATE,Illness
varchar(20));'
[Link](V)
[Link]()
A='insert into '+x+' values("'+[Link]()+'","'+time+'","'+[Link]()
+'");'
[Link](A)
[Link]()
print('\n')
if conn=='2':
[Link]('use class98;')
x=input("\nEnter The Patient's Number: ")
print('\n')
y=x+'tb'
V='select * from '+y+' ;'
[Link](V)
dbs=[Link]()
for i in dbs:
print(i[0],i[1],i[2])
print('\n')
S=input('Do u want to Continue:')
if [Link]()=='NO':
print("\n------------------------------\n")
break
print('\n')
def appointment(date):
coc='yes'
print("\n------------------------------\n")
while [Link]()=='YES':
con1 = [Link](host='localhost', user='root',
password='root')
mycur1 = [Link]()
con2 = [Link](host='localhost', user='root',
password='root')
mycur2 = [Link]()
conn=input('\[Link] a new appointment \[Link] the last appointment\
n3Add a Doctor Profile\n\nEnter your Choice:\n')
print('\n')
if conn=='1':
x=input("Enter The Patient's Number: ")
V='select patient_name from patient_details where patient_no = '+x+' ;'
[Link]('use class96;')
[Link]()
[Link](V)
rec= [Link]()
name=rec[0][0]
x1=input("Enter The Doctors Name: ")
x1=[Link]()
[Link]('use class94;')
[Link]('select Time from '+x1+';')
recd= [Link]()
L=len(recd)
if recd==[]:
time='8:00-8:15'
V='insert into '+x1+' values("'+[Link]()+'","'+[Link]()
+'","'+date+'","'+time+'");'
[Link](V)
[Link]()
if recd!=[]:
c=recd[L-1][0] #c is the last app str
time=c
times=[Link]('-')
etime=times[1]
etime=[Link](':')
hr=etime[0]
mins=etime[1]
mins=int(mins)+15
if mins==60:
hr=int(hr)+1
mins='00'
hr=str(hr)
time=str(hr)+':'+str(mins)
sumtime=etime[0]+':'+etime[1]
print('-------------------')
print('Time',sumtime,' to ',time)
print('-------------------')
time=sumtime+'-'+time
V='insert into '+x1+'
values("'+x+'","'+name+'","'+date+'","'+time+'");'
[Link](V)
[Link]()
coc=input('Do u want to Continue:')
if [Link]()=='NO':
break
if conn=='2':
[Link]('use class94')
x=input('Enter the Doctors Name:')
mycur1 = [Link]()
V='select * from '+x+';'
[Link](V)
rec= [Link]()
if rec==[]:
print('\nThere are no Appoinments\n')
L=len(rec)
if rec!=[]:
for i in rec:
print('\n',i[0],i[1],i[2],i[3],'\n')
coc=input('Do u want to Continue:')
if [Link]()=='NO':
break
if conn=='3':
x=input('Enter the Doctors Name:')
[Link]('show databases;')
dbs=[Link]()
l=len(dbs)
for i in range(0,l):
if str(dbs[i][0])=='class94':
break
if str(dbs[l-1][0])!='class94':
V='CREATE DATABASE class94;'
[Link](V)
[Link]()
[Link]('use class94;')
[Link]('show tables;')
dbs1=[Link]()
L=len(dbs1)
if dbs1==[]:
V = 'CREATE TABLE ' + x + ' (Patient_no VARCHAR(5), Name
varchar(20), Date DATE, Time varchar(10));'
[Link]('use class94;')
[Link](V)
[Link]()
else:
for i in range(0,L):
if str(dbs1[i][0])==x:
break
if str(dbs1[L-1][0])!=x:
[Link]('use class94;')
V = 'CREATE TABLE ' + x + ' (Patient_no VARCHAR(5), Name
varchar(20), Date DATE, Time varchar(10));'
[Link](V)
[Link]()
coc=input('Do u want to Continue:')
if [Link]()=='NO':
print("\n------------------------------\n")
break
import [Link]
con1 = [Link](host='localhost', user='root', password='root')
mycur1 = [Link]()
[Link]('show databases;')
dbs=[Link]()
l=len(dbs)
for i in range(0,l):
if str(dbs[i][0])=='class96':
[Link]('use class96;')
break
if str(dbs[l-1][0])!='class96' and i==l-1:
[Link]('create database class96;')
[Link]('use class96;')
break
[Link]('show tables;')
tbs=[Link]()
L=[]
for i in tbs:
[Link](str(i))
if "('patient_details',)" not in L:
V='CREATE TABLE Patient_details (patient_no varchar(5) PRIMARY KEY,patient_name
VARCHAR(20),patient_f_name VARCHAR(20),patient_m_name VARCHAR(20),patient_phone_no1
varchar(15),patient_phone_no2 varchar(15));'
[Link](V)
[Link]()
con2 = [Link](host='localhost', user='root', password='root')
mycur2 = [Link]()
[Link]('show databases;')
dbs2=[Link]()
if ('class98',) in dbs2:
[Link]('use class98;')
else:
[Link]('create database class98;')
[Link]('use class98;')
V='CREATE TABLE patient_consultations (patient_name VARCHAR(20),Date
DATE,Illness varchar(20));'
[Link](V)
[Link]()
maincon='true'
while maincon!='false':
print("\n------------------------------\n")
y=int(input('[Link] Patients Profile \[Link] Patients Profile \
[Link] \[Link] \[Link]\[Link]\n\nEnter Your choice:'))
print("\n------------------------------\n")
if y==1:
create()
if y==2:
view()
if y==3:
consultation()
if y==4:
f=open('[Link]','r')
date1=[Link]()
appointment(date1)
if y==6:
maincon='false'
if y==5:
date1=input('Enter the Date:')
f1=open('[Link]','w')
[Link](date1)
[Link]()
print('\n')