-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.py
More file actions
184 lines (161 loc) · 5.34 KB
/
code.py
File metadata and controls
184 lines (161 loc) · 5.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
import getpass
from mysql.connector import MySQLConnection, Error
from tabulate import tabulate
cnx = MySQLConnection(
user='root',
password='1234',
host='127.0.0.1',
port=3307,
database='emr'
)
cursor = cnx.cursor()
currentUser = None
def call_stored_procedure(procedureName, args=[]):
cursor.callproc(procedureName, args)
resultSet = []
for result in cursor.stored_results():
columns = [col[0] for col in result.description]
resultSet = result.fetchall()
return [resultSet, columns]
def verify_dentist_login(email, password):
global currentUser
try:
emailId = email
pwd = password
result = call_stored_procedure("dentistLogin",[email, password])
if(len(result)):
currentUser = result[0]
return True
else:
return False
except Error as e:
print(e)
def verify_patient_login(email, password):
global currentUser
try:
emailId = email
pwd = password
result = call_stored_procedure("patientLogin",[email, password])
if(len(result)):
currentUser = result[0]
return True
else:
return False
except Error as e:
print(e)
def dentist_login():
email = input("Email: ")
password = getpass.getpass("Password: ")
if verify_dentist_login(email, password):
print("Login successful!\n")
return True
else:
print("Invalid email or password.")
return False
def patient_login():
email = input("Email: ")
password = getpass.getpass("Password: ")
if verify_patient_login(email, password):
print("Login successful!\n")
return True
else:
print("Invalid email or password.")
return False
def printTable(arr):
records = arr[0]
columns = arr[1]
print("\n")
print(tabulate(records, columns))
print("\n")
def main_menu():
print("Select from the following options:")
print("1. Enter Dentist Portal")
print("2. Enter Patient Portal")
print("3. Exit Application")
def dentist_menu():
print("Dentist Portal:")
print("1. Browse All Scheduled Appointments")
print("2. Check My Upcoming Appointments")
print("3. Access Patient Database")
print("4. Review My Patient Visits")
print("5. Sign Out")
def patient_menu():
print("Patient Portal:")
print("1. Check My Upcoming Appointments")
print("2. Review My Prescription History")
print("3. Find a Dentist")
print("4. Sign Out")
def view_all_appointments():
printTable(call_stored_procedure("viewAllAppointments"))
def view_dentist_appointments():
if currentUser is not None and len(currentUser) > 0:
printTable(call_stored_procedure("viewAppointmentsOfDentist", [currentUser[0][0]]))
else:
print("No user logged in or user information is incomplete.")
def view_patient_appointments():
if currentUser is not None:
printTable(call_stored_procedure("viewAppointmentsOfPatient", [currentUser[0][0]]))
else:
print("Please log in first.")
def view_all_patients():
printTable(call_stored_procedure("viewAllPatients"))
def view_all_doctors():
printTable(call_stored_procedure("viewAllDentists"))
def view_patient_prescriptions():
if currentUser is not None:
printTable(call_stored_procedure("viewPrescriptionOfPatient", [currentUser[0][0]]))
else:
print("Please log in first.")
def view_my_patients():
if currentUser is not None:
printTable(call_stored_procedure("viewPatientsOfDentist", [currentUser[0][0]]))
else:
print("Please log in first.")
def view_billing():
# retrieve and display billing information for logged in user
pass
# main program flow
while True:
main_menu()
choice = input("Option: ")
if choice == "1":
if dentist_login():
while True:
dentist_menu()
option = input("Option: ")
if option == "1":
view_all_appointments()
elif option == "2":
view_dentist_appointments()
elif option == "3":
view_all_patients()
elif option == "4":
view_my_patients()
elif option == "5":
print("Logging out.")
break
else:
print("Invalid option.")
elif choice == "2":
if patient_login():
while True:
patient_menu()
option = input("Option: ")
if option == "1":
view_patient_appointments()
elif option == "2":
view_patient_prescriptions()
elif option == "3":
view_all_doctors()
elif option == "4":
print("Logging out.")
break
else:
print("Invalid option.")
elif choice == "3":
print("Exiting...")
break
else:
print("Invalid choice")
cursor.close()
cnx.close()