0% found this document useful (0 votes)
4 views115 pages

Hospital Management Python Source Code

The document contains Python source code for a Hospital Management System, which includes database configuration, admin functionalities, and backup/restore capabilities. Key features include managing employee and patient data, updating records, and generating reports on earnings and notifications. The system utilizes PostgreSQL for data management and provides functions for CRUD operations on various entities within the hospital context.

Uploaded by

dev.cstiwari
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views115 pages

Hospital Management Python Source Code

The document contains Python source code for a Hospital Management System, which includes database configuration, admin functionalities, and backup/restore capabilities. Key features include managing employee and patient data, updating records, and generating reports on earnings and notifications. The system utilizes PostgreSQL for data management and provides functions for CRUD operations on various entities within the hospital context.

Uploaded by

dev.cstiwari
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Hospital Management System - Python Source Code

DB_config.py
import constant
HOST = constant.grab_constant(True,"HOST")
PORT = int(constant.grab_constant(True,"PORT"))
ADMIN_DATABASE = constant.grab_constant(True,"ADMIN_DATABASE")
DATABASE = constant.grab_constant(True,"DATABASE")
USER = constant.grab_constant(True,"USER")
PASSWORD = constant.grab_constant(True,"PASSWORD")

def admin_config():
config_dict = {"host":HOST, "port":PORT, "database":ADMIN_DATABASE,
"user":USER, "password":PASSWORD}
return config_dict

def config():
config_dict = {"host":HOST, "port":PORT, "database":DATABASE, "user":USER,
"password":PASSWORD}
return config_dict

[Link]
import psycopg2
from doctor import salary as doctor_salary
from patient import cost as patient_cost
from employee import salary as employee_salary
from DB_config import config
import constant

def see_info(logged_in,category,username):
if logged_in:
username = [Link]().lower()
with [Link](**config()) as info_check:
cur1 = info_check.cursor()
[Link](f"""
SELECT * FROM {category} WHERE username = '{username}';
""")
info = [Link]()
[Link]()
info_check.close()
return info

def update_db(category, username, fieldname, updated_value, logged_in):


if logged_in:
date = "DATE" if fieldname == "date_of_birth" else ""
with [Link](**config()) as updating:
cur1 = [Link]()
[Link](f"""
UPDATE {category} SET {fieldname} = '{updated_value}' WHERE
username = {date}'{username}';
""")
print([Link])
[Link]()
[Link]()
[Link]()
return "Database Updated"

def recent_notifications(username, logged_in, limit = 1):


if logged_in:
with [Link](**config()) as latest:
cur1 = [Link]()
[Link]("""
SELECT notifications FROM admin WHERE username = %s;
""", [username])
notifications_string = [Link]()[0][0]
list_of_notifications = notifications_string.split(", ")
[Link]()
[Link]()
return list_of_notifications[-limit:] if limit <
len(list_of_notifications) else list_of_notifications[-
len(list_of_notifications):]

def add_notification(notification, category, receiver_username, logged_in):


if logged_in:
with [Link](**config()) as add_notifications:
cur1 = add_notifications.cursor()
[Link](f"""
SELECT notifications FROM {category} WHERE username =
'{receiver_username}';
""")
notifications_string = [Link]()[0][0]
list_of_notifications = notifications_string.split(", ")
list_of_notifications.append(notification)
new_notifications_string = ", ".join(list_of_notifications)
[Link]()
cur2 = add_notifications.cursor()
[Link](f"""
UPDATE {category} SET notifications =
'{new_notifications_string}' WHERE username = '{receiver_username}';
""")
print([Link])
[Link]()
add_notifications.commit()
add_notifications.close()
return "Notification Added"

def total_earning(logged_in):
if logged_in:
initial_earning = 0
with [Link](**config()) as earning:
cur1 = [Link]()
[Link]("""
SELECT username FROM employee;
""")
list_of_employee = [Link]()
[Link]()
earned_from_employee = 0
for row in list_of_employee:
earned_from_employee += int(employee_salary(row[0],True)[1])
initial_earning += earned_from_employee
cur2 = [Link]()
[Link]("""
SELECT username FROM patient;
""")
list_of_patient = [Link]()
[Link]()
earned_from_patient = 0
for row in list_of_patient:
earned_from_patient += int(patient_cost(row[0],True)[1])
initial_earning += earned_from_patient
initial_earning -=
int(constant.grab_constant(True,"FIXED_COST_OF_HOSPITAL"))

given_to_employees = 0
cur3 = [Link]()
[Link]("""
SELECT salary FROM employee WHERE work_of_doctors LIKE '%admin
%';
""")
salary_list = [Link]()
for salary in salary_list:
given_to_employees += int(salary[0])
[Link]()
initial_earning -= given_to_employees

employee_pre_salary = int(doctor_salary("hpt", True)[1])


initial_earning -= employee_pre_salary

[Link]()
return (earned_from_employee, earned_from_patient,
int(constant.grab_constant(True,"FIXED_COST_OF_HOSPITAL")), employee_pre_salary,
given_to_employees, initial_earning)

def add_employee(employee_username, logged_in):


if logged_in:
with [Link](**config()) as adding_employee:
cur0 = adding_employee.cursor()
[Link]("""
SELECT work_of_doctors FROM employee WHERE username = %s;
""", [employee_username])

work_of_doctors = [Link]()[0][0]
work_of_doctors += ", " + "admin"
[Link]()

cur1 = adding_employee.cursor()
[Link]("""
UPDATE employee SET work_of_doctors = %s WHERE username = %s;
""", [work_of_doctors, employee_username])
print([Link])
[Link]()
adding_employee.commit()
adding_employee.close()
return "Employee Added"

def see_my_employee(logged_in):
if logged_in:
with [Link](**config()) as my_employee:
cur1 = my_employee.cursor()
[Link]("""
SELECT username, fullname, email, date_of_birth, work, salary
FROM employee WHERE work_of_doctors LIKE '%admin%'
""")
list_of_employees = [Link]()
# print part
# for row in list_of_employees:
# print("Username:", row[0], "\tFullname:", row[1], "\tEmail:",
row[2], "\tWork:", row[3], "\tSalary:", row[4])
[Link]()
my_employee.close()
return list_of_employees

def remove_employee(employee_username, logged_in):


if logged_in:
with [Link](**config()) as removing_employee:
cur0 = removing_employee.cursor()
[Link]("""
SELECT work_of_doctors FROM employee WHERE username = %s;
""", [employee_username])

work_of_doctors_string = [Link]()[0][0]
work_of_doctors_list = work_of_doctors_string.split(", ")

work_of_doctors_list.remove("admin")
new_work_of_doctors_string = ", ".join(work_of_doctors_list)
[Link]()

cur1 = removing_employee.cursor()
[Link]("""
UPDATE employee SET work_of_doctors = %s WHERE username = %s;
""", [new_work_of_doctors_string, employee_username])
print([Link])
[Link]()
removing_employee.commit()
removing_employee.close()
return "Employee Removed"
def show_all_doctor(logged_in):
if logged_in:
with [Link](**config()) as doctor:
cur1 = [Link]()
[Link]("""
SELECT username, fullname, email, date_of_birth, specialty,
price FROM doctor;
""")
rows = [Link]()
new_rows = []
for row in rows:
row = list(row)
[Link](doctor_salary(row[0],True)[2])
new_rows.append(row)
# print(part)
# for row in rows:
# print("Username:", row[0], "\tFullname:", row[1], "\tEmail:",
row[2], "\tspecialty:", row[3], "\tPrice:", row[4], "\tTotal Earned:", row[5])
[Link]()
[Link]()
return new_rows

def show_all_patient(logged_in):
if logged_in:
with [Link](**config()) as patient:
cur1 = [Link]()
[Link]("""
SELECT username, fullname, email, date_of_birth, problem,
requested_doctor_username, approved_doctor_username FROM patient;
""")
rows = [Link]()
new_rows = []
for row in rows:
row = list(row)
[Link](patient_cost(row[0], True)[2])
new_rows.append(row)
# print part
# for row in rows:
# print("Username:", row[0], "\tFullname:", row[1], "\tEmail:",
row[2], "\tProblem:", row[3], "\tRequested:", row[4], "\tApproved:", row[5], "\
tTotal Cost:", row[6])
[Link]()
[Link]()
return new_rows

def show_all_employee(logged_in):
if logged_in:
with [Link](**config()) as employee:
cur1 = [Link]()
[Link]("""
SELECT username, fullname, email, date_of_birth, work,
work_of_doctors, salary FROM employee;
""")
rows = [Link]()
new_rows = []
for row in rows:
row = list(row)
[Link](employee_salary(row[0],True)[2])
new_rows.append(row)
# print part
# for row in rows:
# print("Username:", row[0], "\tFullname:", row[1], "\tEmail:",
row[2], "\tWork:", row[3], "\tDoctors:", row[4], "\tSalary:", row[5], "\tTotal
Earned:", row[6])
[Link]()
[Link]()
return new_rows

def all_doctor_username(logged_in):
if logged_in:
with [Link](**config()) as doctor:
cur1 = [Link]()
[Link]("""
SELECT username FROM doctor;
""")
rows = [Link]()
new_rows = []
for row in rows:
new_rows.append(row[0])
[Link]()
[Link]()
return new_rows

def all_patient_username(logged_in):
if logged_in:
with [Link](**config()) as patient:
cur1 = [Link]()
[Link]("""
SELECT username FROM patient;
""")
rows = [Link]()
new_rows = []
for row in rows:
new_rows.append(row[0])
[Link]()
[Link]()
return new_rows

def all_employee_username(logged_in):
if logged_in:
with [Link](**config()) as employee:
cur1 = [Link]()
[Link]("""
SELECT username FROM employee;
""")
rows = [Link]()
new_rows = []
for row in rows:
new_rows.append(row[0])
[Link]()
[Link]()
return new_rows

def remove_doctor_parmanently(doctor_username, logged_in, final_decision =


False):
if final_decision and logged_in:
with [Link](**config()) as remove_doctor:
cur1 = remove_doctor.cursor()
[Link]("""
DELETE FROM doctor WHERE username = %s;
""", [doctor_username])
print([Link])
remove_doctor.commit()
[Link]()
remove_doctor.close()
return "Doctor Parmanently Removed"

def remove_patient_parmanently(patient_username, logged_in, final_decision =


False):
if final_decision and logged_in:
with [Link](**config()) as remove_patient:
cur1 = remove_patient.cursor()
[Link]("""
DELETE FROM patient WHERE username = %s;
""", [patient_username])
print([Link])
remove_patient.commit()
[Link]()
remove_patient.close()
return "Patient Parmanently Removed"

def remove_employee_parmanently(employee_username, logged_in, final_decision =


False):
if final_decision and logged_in:
with [Link](**config()) as remove_employee:
cur1 = remove_employee.cursor()
[Link]("""
DELETE FROM employee WHERE username = %s;
""", [employee_username])
print([Link])
remove_employee.commit()
[Link]()
remove_employee.close()
return "Employee Parmanently Removed"
def patient_joins_doctor(logged_in, left = False):
join_type = "LEFT JOIN" if left else "JOIN"
if logged_in:
with [Link](**config()) as viewer:
cur_first = [Link]()
cur_first.execute("""
DROP VIEW IF EXISTS final_view;
""")
cur_first.close()
[Link]()

cur0 = [Link]()
[Link]("""
DROP VIEW IF EXISTS patient_view;
""")
[Link]()
[Link]()

cur1 = [Link]()
[Link]("""
CREATE VIEW patient_view AS SELECT username, fullname, email,
date_of_birth, problem, approved_doctor_username, appointment_timestamp FROM
patient WHERE approved_doctor_username != 'hpt';
""")
[Link]()

cur2 = [Link]()
[Link]("""
DROP VIEW IF EXISTS doctor_view;
""")
[Link]()
[Link]()

cur3 = [Link]()
[Link]("""
CREATE VIEW doctor_view AS SELECT username AS doctor_username,
fullname AS doctor_fullname, email AS doctor_email, specialty, price FROM
doctor;
""")
[Link]()

[Link]()
[Link]()

with [Link](**config()) as joiner:

cur1 = [Link]()
[Link](f"""
CREATE VIEW final_view AS (SELECT * FROM patient_view
{join_type} doctor_view ON patient_view.approved_doctor_username =
doctor_view.doctor_username);
""")
[Link]()
[Link]()
[Link]()

with [Link](**config()) as final:


cur1 = [Link]()
[Link]("""
SELECT username, fullname, email, problem,
appointment_timestamp, doctor_username, doctor_fullname, doctor_email,
specialty, price FROM final_view;
""")
rows = [Link]()
[Link]()

# print part
# for row in rows:
# print(row)

[Link]()
return rows

backup_restore.py
import psycopg2
from DB_config import config
from constant import MAIN_FILE

def backup_to_csv(logged_in):
if logged_in:
with [Link](**config()) as backup:
ADMIN_FILE = [Link](MAIN_FILE, "backup_&_restore_folder",
"[Link]")
DOCTOR_FILE = [Link](MAIN_FILE, "backup_&_restore_folder",
"[Link]")
PATIENT_FILE = [Link](MAIN_FILE, "backup_&_restore_folder",
"[Link]")
EMPLOYEE_FILE = [Link](MAIN_FILE, "backup_&_restore_folder",
"[Link]")

cur0 = [Link]()
[Link]("""
COPY (SELECT * FROM admin) TO %s DELIMITER ',' CSV;
""", [ADMIN_FILE])
[Link]()

cur1 = [Link]()
[Link]("""
COPY (SELECT * FROM doctor) TO %s DELIMITER ',' CSV;
""", [DOCTOR_FILE])
[Link]()

cur2 = [Link]()
[Link]("""
COPY (SELECT * FROM patient) TO %s DELIMITER ',' CSV;
""", [PATIENT_FILE])
[Link]()
cur3 = [Link]()
[Link]("""
COPY (SELECT * FROM employee) TO %s DELIMITER ',' CSV;
""", [EMPLOYEE_FILE])
[Link]()

[Link]()
[Link]()
return "Backup Successful"

def restore_from_csv(logged_in):
if logged_in:
with [Link](**config()) as restore:
ADMIN_FILE = [Link](MAIN_FILE, "backup_&_restore_folder",
"[Link]")
DOCTOR_FILE = [Link](MAIN_FILE, "backup_&_restore_folder",
"[Link]")
PATIENT_FILE = [Link](MAIN_FILE, "backup_&_restore_folder",
"[Link]")
EMPLOYEE_FILE = [Link](MAIN_FILE, "backup_&_restore_folder",
"[Link]")

cur0 = [Link]()
[Link]("""
COPY admin FROM %s DELIMITER ',' CSV NULL AS '';
""", [ADMIN_FILE])
[Link]()

cur1 = [Link]()
[Link]("""
COPY doctor FROM %s DELIMITER ',' CSV NULL AS '';
""", [DOCTOR_FILE])
[Link]()

cur2 = [Link]()
[Link]("""
COPY patient FROM %s DELIMITER ',' CSV NULL AS '';
""", [PATIENT_FILE])
[Link]()

cur3 = [Link]()
[Link]("""
COPY employee FROM %s DELIMITER ',' CSV NULL AS '';
""", [EMPLOYEE_FILE])
[Link]()

[Link]()
[Link]()
return "Restoration Successful"
[Link]
MAIN_FILE = [Link]()
CONSTANT_FILE = [Link](MAIN_FILE, "backup_&_restore_folder",
"[Link]")
constants ={}
condition = True
with open(CONSTANT_FILE, "r") as read_constant:
while condition:
try:
reader = read_constant.readline()
reader_split = [Link](",")
name, value = reader_split
constants[name] = value[:-1]
except:
condition = False

def grab_constant(logged_in, name):


if logged_in:
name = [Link]()
value = [Link](name)
return value

def set_constant(logged_in, constants_dict):


with open(CONSTANT_FILE, "w") as write_constant:
for key, value in constants_dict.items():
write_constant.write([Link]() + "," + value + "\n")

[Link]
import psycopg2
from DB_config import config
import constant
import webbrowser as web

def recent_notifications(username, logged_in, limit = 1):


if logged_in:
with [Link](**config()) as latest:
cur1 = [Link]()
[Link]("""
SELECT notifications FROM doctor WHERE username = %s;
""", [username])
notifications_string = [Link]()[0][0]
list_of_notifications = notifications_string.split(", ")
[Link]()
[Link]()
return list_of_notifications[-limit:] if limit <
len(list_of_notifications) else list_of_notifications[-
len(list_of_notifications):]

def notify_admin(notification, my_username, admin_username, logged_in):


if logged_in:
with [Link](**config()) as add_notifications:
cur1 = add_notifications.cursor()
[Link](f"""
SELECT notifications FROM admin WHERE username =
'{admin_username}';
""")
notifications_string = [Link]()[0][0]
list_of_notifications = notifications_string.split(", ")
notification = "From: " + my_username + " " + notification
list_of_notifications.append(notification)
new_notifications_string = ", ".join(list_of_notifications)
[Link]()
cur2 = add_notifications.cursor()
[Link](f"""
UPDATE admin SET notifications = '{new_notifications_string}'
WHERE username = '{admin_username}';
""")
print([Link])
[Link]()
add_notifications.commit()
add_notifications.close()
return "Notification Added"

def salary(username, logged_in):


if logged_in:
with [Link](**config()) as my_salary:
cur0 = my_salary.cursor()
[Link]("""
SELECT * FROM patient WHERE approved_doctor_username = %s;
""", [username])

total_patient = len([Link]())
[Link]()

cur1 = my_salary.cursor()
[Link]("""
SELECT price FROM doctor WHERE username = %s;
""", [username])

my_price = [Link]()[0][0]
[Link]()
total_earning = total_patient * int(my_price)

cur2 = my_salary.cursor()
[Link](f"""
SELECT salary FROM employee WHERE work_of_doctors LIKE '%
{username}%';
""")
salary_list = [Link]()
total_cost = 0
if username == "hpt":
for salary in salary_list:
total_cost +=
(int(salary[0])*int(constant.grab_constant(True,"PRE_SALARY")))//100
else:
for salary in salary_list:
total_cost += int(salary[0])
[Link]()

nit_salary = total_earning - total_cost

my_salary.close()
return (total_earning, total_cost, nit_salary)

def show_all_employee(logged_in):
if logged_in:
with [Link](**config()) as all_employee:
cur1 = all_employee.cursor()
[Link]("""
SELECT username, fullname, email, date_of_birth, work, salary
FROM employee;
""")

rows = [Link]()
# print part
# for row in rows:
# print("Username:", row[0], "\tFullname:", row[1], "\tEmail:",
row[2], "\tSalary:", row[3])
[Link]()
all_employee.close()
return rows

def add_employee(my_username, employee_username, logged_in):


if logged_in:
with [Link](**config()) as adding_employee:
cur0 = adding_employee.cursor()
[Link]("""
SELECT work_of_doctors FROM employee WHERE username = %s;
""", [employee_username])

temporary = [Link]()
work_of_doctors = temporary[0][0]
work_of_doctors += ", " + my_username
[Link]()

cur1 = adding_employee.cursor()
[Link]("""
UPDATE employee SET work_of_doctors = %s WHERE username = %s;
""", [work_of_doctors, employee_username])
print([Link])
[Link]()
adding_employee.commit()
adding_employee.close()
return "Employee Added"

def see_my_employee(username, logged_in):


if logged_in:
with [Link](**config()) as my_employee:
cur1 = my_employee.cursor()
[Link](f"""
SELECT username, fullname, email, date_of_birth, work, salary
FROM employee WHERE work_of_doctors LIKE '%{username}%'
""")
list_of_employees = [Link]()
# print part
# for row in list_of_employees:
# print("Username:", row[0], "\tFullname:", row[1], "\tEmail:",
row[2], "\tWork:", row[3], "\tSalary:", row[4])
[Link]()
my_employee.close()
return list_of_employees

def remove_employee(my_username, employee_username, logged_in):


if logged_in:
with [Link](**config()) as removing_employee:
cur0 = removing_employee.cursor()
[Link]("""
SELECT work_of_doctors FROM employee WHERE username = %s;
""", [employee_username])

work_of_doctors_string = [Link]()[0][0]
work_of_doctors_list = work_of_doctors_string.split(", ")

work_of_doctors_list.remove(my_username)
new_work_of_doctors_string = ", ".join(work_of_doctors_list)
[Link]()

cur1 = removing_employee.cursor()
[Link]("""
UPDATE employee SET work_of_doctors = %s WHERE username = %s;
""", [new_work_of_doctors_string, employee_username])
print([Link])
[Link]()
removing_employee.commit()
removing_employee.close()
return "Employee Removed"

def see_all_requested_patient(username, logged_in):


if logged_in:
with [Link](**config()) as all_requested_patient:
cur0 = all_requested_patient.cursor()
[Link]("""
SELECT username, fullname, email, date_of_birth, problem FROM
patient WHERE requested_doctor_username = %s;
""", [username])

rows = [Link]()
# print part
# for row in rows:
# print("Username:", row[0], "\tFullname:", row[1], "\tEmail:",
row[2], "\tProblem:", row[3])
[Link]()
all_requested_patient.close()
return rows

def see_all_patients_of_my_specialty(username, logged_in):


if logged_in:
with [Link](**config()) as all_under_specialty:
cur0 = all_under_specialty.cursor()
[Link]("""
SELECT specialty FROM doctor WHERE username = %s;
""", [username])
specialty = str([Link]()[0][0]).lower()
[Link]()

cur1 = all_under_specialty.cursor()
[Link]("""
SELECT username, fullname, email, date_of_birth,
requested_doctor_username, approved_doctor_username FROM patient WHERE problem =
%s;
""", [specialty])

rows = [Link]()
# for row in rows:
# print("Username:", row[0], "\tFullname:", row[1], "\tEmail:",
row[2], "\tRequested Doctor:", row[3], "\tApproved Doctor:", row[4])
[Link]()
all_under_specialty.close()
return rows

def see_my_patient(username, logged_in):


if logged_in:
with [Link](**config()) as my_patient:
cur0 = my_patient.cursor()
[Link]("""
SELECT username, fullname, email, date_of_birth, problem,
appointment_timestamp FROM patient WHERE approved_doctor_username = %s;
""", [username])

rows = [Link]()
# print part
# for row in rows:
# print("Username:", row[0], "\tFullname:", row[1], "\tEmail:",
row[2], "\tProblem:", row[3])
[Link]()
my_patient.close()
return rows

def see_patients_report(patient_username,report_name,logged_in):
if logged_in:
with [Link](**config()) as report:
cur1 = [Link]()
[Link]("""
SELECT reports FROM patient WHERE username = %s;
""", [patient_username])
reports_string = [Link]()[0][0]
reports_list = reports_string.split("+++")
for reports_substring in reports_list:
report_tuple_without_b = reports_substring[1:-1]
report_sublist = report_tuple_without_b.split("++")
name = report_sublist[0]
url = report_sublist[1]
if [Link]() == report_name.lower():
[Link](url)
return ("Opening",name,"In Web Browser")

def remove_patient(patient_username, logged_in):


if logged_in:
with [Link](**config()) as removing_patient:
cur0 = removing_patient.cursor()
[Link]("""
UPDATE patient SET approved_doctor_username = %s,
appointment_timestamp = %s WHERE username = %s;
""", [None, None, patient_username])
print([Link])
[Link]()
removing_patient.commit()
removing_patient.close()
return "Patient Removed"

[Link]
import psycopg2
from DB_config import config
from constant import grab_constant
import datetime

def recent_notifications(username, logged_in, limit = 1):


if logged_in:
with [Link](**config()) as latest:
cur1 = [Link]()
[Link]("""
SELECT notifications FROM employee WHERE username = %s;
""", [username])
notifications_string = [Link]()[0][0]
list_of_notifications = notifications_string.split(", ")
[Link]()
[Link]()
return list_of_notifications[-limit:] if limit <
len(list_of_notifications) else list_of_notifications[-
len(list_of_notifications):]

def notify_admin(notification, my_username, admin_username, logged_in):


if logged_in:
with [Link](**config()) as add_notifications:
cur1 = add_notifications.cursor()
[Link](f"""
SELECT notifications FROM admin WHERE username =
'{admin_username}';
""")
notifications_string = [Link]()[0][0]
list_of_notifications = notifications_string.split(", ")
notification = "From: " + my_username + " " + notification
list_of_notifications.append(notification)
new_notifications_string = ", ".join(list_of_notifications)
[Link]()
cur2 = add_notifications.cursor()
[Link](f"""
UPDATE admin SET notifications = '{new_notifications_string}'
WHERE username = '{admin_username}';
""")
print([Link])
[Link]()
add_notifications.commit()
add_notifications.close()
return "Notification Added"

def salary(username, logged_in):


if logged_in:
with [Link](**config()) as my_salary:
cur1 = my_salary.cursor()
[Link]("""
SELECT work_of_doctors, salary FROM employee WHERE username =
%s;
""", [username])
bucket = [Link]()[0]
string_of_doctors = bucket[0]
my_price = bucket[1]
[Link]()
list_of_doctors = string_of_doctors.split(", ")
number_of_doctors = len(list_of_doctors)

if "hpt" in list_of_doctors:
initial_salary = (number_of_doctors * my_price) -
(my_price*(100-int(grab_constant(True,"PRE_SALARY"))))//100
else:
initial_salary = number_of_doctors * my_price
hospital_cost = (initial_salary * int(grab_constant(True,
"CUT_FROM_EMPLOYEE"))) // 100
final_salary = initial_salary - hospital_cost

my_salary.close()
return (initial_salary, hospital_cost, final_salary)

def isreceptionist(username, logged_in):


if logged_in:
with [Link](**config()) as reception:
cur1 = [Link]()
[Link]("""
SELECT work FROM employee WHERE username = %s;
""", [username])
work = [Link]()[0][0]
[Link]()
[Link]()
if [Link]() == "receptionist":
return True
else:
return False

def appoint_doctor(my_username, doctor_username, patient_username,


appointment_timestamp, logged_in):
if logged_in and isreceptionist(my_username, logged_in):
formated_date = [Link](appointment_timestamp, "%Y-
%m-%d %H:%M:%S")
with [Link](**config()) as adding_patient:
cur0 = adding_patient.cursor()
[Link]("""
UPDATE patient SET approved_doctor_username = %s,
appointment_timestamp = TIMESTAMP %s WHERE username = %s;
""", [doctor_username, formated_date, patient_username])
print([Link])
[Link]()
adding_patient.commit()
adding_patient.close()
return "Succesfully Appointed"

def see_my_doctors(username, logged_in):


if logged_in:
with [Link](**config()) as my_doctor:
cur1 = my_doctor.cursor()
[Link]("""
SELECT work_of_doctors FROM employee WHERE username = %s;
""", [username])
string_of_doctors = [Link]()[0][0]
[Link]()
list_of_doctors = string_of_doctors.split(", ")

doctors_bucket = []
for doctor_username in list_of_doctors:
cur2 = my_doctor.cursor()
if doctor_username != "admin":
[Link]("""
SELECT username, fullname, email, date_of_birth,
specialty FROM doctor WHERE username = %s;
""", [doctor_username])
temporary = [Link]()
doctors_bucket.append(temporary[0])
[Link]()
else:
doctors_bucket.append(('adm',
'admin','admin@[Link]',"2004-12-28", 'all'))
# print part
# for row in doctors_bucket:
# print("Username:", row[0], "\tFullname:", row[1], "\tEmail:",
row[2], "\tspecialty:", row[3])

my_doctor.close()
return doctors_bucket

[Link]
# All Imports
import kivy
from [Link] import App
from [Link] import ObjectProperty
from [Link] import FloatLayout
from [Link] import GridLayout
from [Link] import Builder
from [Link] import Window
from [Link] import Screen, ScreenManager
from [Link] import Popup
import webbrowser as web
from [Link] import Widget
from [Link] import Color
from [Link] import Line
from [Link] import Label
from [Link] import Button
from [Link] import Carousel
from [Link] import Image
from [Link] import SlideTransition
from [Link] import NoTransition
from [Link] import Config
from [Link] import TextInput
from [Link] import Rectangle
from [Link] import ScrollView
from [Link] import runTouchApp

import setup_engine
import login
import constant
import admin
import datetime
import doctor
import patient
import employee

# Common Classes and Window Configuration


class WindowManager(ScreenManager):
pass

class Holder():
username = "Default"
logged_in = True
counter = 0
pre_counter = 0

[Link]('graphics', 'height', 600)


[Link]('graphics', 'width', 800)
[Link]('graphics', 'resizable', 0)
[Link]()

# SignUp Classes
class GetStarted(Screen):
first_start = True if (constant.grab_constant(True, "IS_START")=="0") else
False
def start_program(self):
if GetStarted.first_start:
[Link] = SlideTransition(direction = "up")
[Link] = "ConstantFixing"
else:
[Link] = SlideTransition(direction = "up")
[Link] = "PatientSignUp"

def go_to_website(self):
web.open_new_tab("[Link]

class ConstantFixing(Screen):
host = ObjectProperty()
port = ObjectProperty()
user = ObjectProperty()
password = ObjectProperty()
cut_from_patient = ObjectProperty()
cut_from_employee = ObjectProperty()
fixed_cost_of_hospital = ObjectProperty()
pre_salary = ObjectProperty()
doctor_max_checkup_price = ObjectProperty()
employee_max_salary = ObjectProperty()
hospital_year = ObjectProperty()
hospital_total_bed = ObjectProperty()
hospital_remaining_bed = ObjectProperty()
hospital_total_employee = ObjectProperty()
hospital_total_doctor = ObjectProperty()
hospital_total_patient = ObjectProperty()
hospital_current_patient = ObjectProperty()
hospital_motto = ObjectProperty()
hospital_location = ObjectProperty()
hospital_title = ObjectProperty()
restore_previous = ObjectProperty()
def set_constant_function(self):
try:
constants_bucket = dict()
constants_bucket["HOST"] = [Link]
constants_bucket["PORT"] = [Link]
constants_bucket["ADMIN_DATABASE"] = "postgres"
constants_bucket["DATABASE"] ="hms"
constants_bucket["USER"] = [Link]
constants_bucket["PASSWORD"] = [Link]
constants_bucket["CUT_FROM_PATIENT"] = self.cut_from_patient.text
constants_bucket["CUT_FROM_EMPLOYEE"] = self.cut_from_employee.text
constants_bucket["FIXED_COST_OF_HOSPITAL"] =
self.fixed_cost_of_hospital.text
constants_bucket["PRE_SALARY"] = self.pre_salary.text
constants_bucket["DOCTOR_MAX_CHECKUP_PRICE"] =
self.doctor_max_checkup_price.text
constants_bucket["EMPLOYEE_MAX_SALARY"] =
self.employee_max_salary.text
constants_bucket["HOSPITAL_YEAR"] = self.hospital_year.text
constants_bucket["HOSPITAL_TOTAL_BED"] =
self.hospital_total_bed.text
constants_bucket["HOSPITAL_REMAINING_BED"] =
self.hospital_remaining_bed.text
constants_bucket["HOSPITAL_TOTAL_EMPLOYEE"] =
self.hospital_total_employee.text
constants_bucket["HOSPITAL_TOTAL_DOCTOR"] =
self.hospital_total_doctor.text
constants_bucket["HOSPITAL_TOTAL_PATIENT"] =
self.hospital_total_patient.text
constants_bucket["HOSPITAL_CURRENT_PATIENT"] =
self.hospital_current_patient.text
constants_bucket["HOSPITAL_MOTTO"] = self.hospital_motto.text
constants_bucket["HOSPITAL_LOCATION"] = self.hospital_location.text
constants_bucket["HOSPITAL_TITLE"] = self.hospital_title.text
constants_bucket["IS_START"] = "1"
constant.set_constant(True, constants_bucket)
[Link]()
if self.restore_previous.text == "yes":
setup_engine.start_program()
except:
show_ConstantFixingPop()

[Link] = "localhost"
[Link] = "5432"
[Link] = "postgres"
[Link] = "12345678"
self.cut_from_patient.text = "50"
self.cut_from_employee.text = "20"
self.fixed_cost_of_hospital.text = "5000"
self.pre_salary.text = "10"
self.doctor_max_checkup_price.text = "4000"
self.employee_max_salary.text = "15000"
self.hospital_year.text = "2004"
self.hospital_total_bed.text = "200"
self.hospital_remaining_bed.text = "120"
self.hospital_total_employee.text = "16"
self.hospital_total_doctor.text = "10"
self.hospital_total_patient.text = "2000"
self.hospital_current_patient.text = "40"
self.hospital_motto.text = "serve the nation at large"
self.hospital_location.text = "Dhaka-Bangladesh"
self.hospital_title.text = "The AS8 Hospital"
self.restore_previous.text = "no"

def proceed(self):
[Link] = SlideTransition(direction = "up")
[Link] = "PatientSignUp"

class ConstantFixingPop(FloatLayout):
pass

def show_ConstantFixingPop():
show = ConstantFixingPop()
popup_window = Popup(title = "Constant Fixing Error", content = show,
size_hint = (0.6, 0.3))
popup_window.open()

class AdminSignUp(Screen):
username = ObjectProperty()
fullname = ObjectProperty()
email = ObjectProperty()
date_of_birth = ObjectProperty()
password = ObjectProperty()

def signup_to_database(self):
try:
category = "admin"
username = [Link]().lower()
fullname = [Link]().title()
email = [Link]()
date_of_birth = self.date_of_birth.[Link]()
password = [Link]()

[Link](category, username, fullname, email, date_of_birth,


password)
[Link] = "AdminLogin"
except:
show_SignUpPop()

[Link] = ""
[Link] = ""
[Link] = ""
self.date_of_birth.text = "YYYY-MM-DD"
[Link] = ""

class DoctorSignUp(Screen):
username = ObjectProperty()
fullname = ObjectProperty()
email = ObjectProperty()
date_of_birth = ObjectProperty()
password = ObjectProperty()
specialty = ObjectProperty()
price = ObjectProperty()

def signup_to_database(self):
try:
category = "doctor"
username = [Link]().lower()
fullname = [Link]().title()
email = [Link]()
date_of_birth = self.date_of_birth.[Link]()
password = [Link]()
specialty = [Link]().lower()
price = int([Link]())

[Link](category, username, fullname, email, date_of_birth,


password, specialty, price)
[Link] = "DoctorLogin"
except:
show_SignUpPop()

[Link] = ""
[Link] = ""
[Link] = ""
self.date_of_birth.text = "YYYY-MM-DD"
[Link] = ""
[Link] = ""
[Link] = ""

class PatientSignUp(Screen):
username = ObjectProperty()
fullname = ObjectProperty()
email = ObjectProperty()
date_of_birth = ObjectProperty()
password = ObjectProperty()
problem = ObjectProperty()

def signup_to_database(self):
try:
category = "patient"
username = [Link]().lower()
fullname = [Link]().title()
email = [Link]()
date_of_birth = self.date_of_birth.[Link]()
password = [Link]()
problem = [Link]().lower()

[Link](category, username, fullname, email, date_of_birth,


password, problem)
[Link] = "PatientLogin"
except:
show_SignUpPop()

[Link] = ""
[Link] = ""
[Link] = ""
self.date_of_birth.text = "YYYY-MM-DD"
[Link] = ""
[Link] = ""

class EmployeeSignUp(Screen):
username = ObjectProperty()
fullname = ObjectProperty()
email = ObjectProperty()
date_of_birth = ObjectProperty()
password = ObjectProperty()
work = ObjectProperty()
salary = ObjectProperty()

def signup_to_database(self):
try:
category = "employee"
username = [Link]().lower()
fullname = [Link]().title()
email = [Link]()
date_of_birth = self.date_of_birth.[Link]()
password = [Link]()
work = [Link]().lower()
salary = int([Link]())

[Link](category, username, fullname, email, date_of_birth,


password, work, salary)
[Link] = "EmployeeLogin"
except:
show_SignUpPop()

[Link] = ""
[Link] = ""
[Link] = ""
self.date_of_birth.text = "YYYY-MM-DD"
[Link] = ""
[Link] = ""
[Link] = ""

class SignUpPop(FloatLayout):
pass
def show_SignUpPop():
show = SignUpPop()
popup_window = Popup(title = "SignUp Error", content = show, size_hint =
(0.6, 0.3))
popup_window.open()

# Login Classes
class AdminLogin(Screen):
username = ObjectProperty()
password = ObjectProperty()

def login_to_database(self):
try:
category = "admin"
username = [Link]().lower()
[Link] = username
password = [Link]()

logged_in = [Link](category,username,password)
if logged_in:
[Link] = "AdminAfterLogin"
else:
show_LoginPop()
except:
show_LoginPop()

[Link] = ""
[Link] = ""

class DoctorLogin(Screen):
username = ObjectProperty()
password = ObjectProperty()

def login_to_database(self):
try:
category = "doctor"
username = [Link]().lower()
[Link] = username
password = [Link]()

logged_in = [Link](category,username,password)
if logged_in:
[Link] = "DoctorAfterLogin"
else:
show_LoginPop()
except:
show_LoginPop()

[Link] = ""
[Link] = ""

class PatientLogin(Screen):
username = ObjectProperty()
password = ObjectProperty()

def login_to_database(self):
try:
category = "patient"
username = [Link]().lower()
[Link] = username
password = [Link]()

logged_in = [Link](category,username,password)
print(logged_in)
if logged_in:
[Link] = "PatientAfterLogin"
else:
show_LoginPop()
except:
show_LoginPop()

[Link] = ""
[Link] = ""

class EmployeeLogin(Screen):
username = ObjectProperty()
password = ObjectProperty()

def login_to_database(self):
try:
category = "employee"
username = [Link]().lower()
[Link] = username
password = [Link]()

logged_in = [Link](category,username,password)
if logged_in:
[Link] = "EmployeeAfterLogin"
else:
show_LoginPop()
except:
show_LoginPop()

[Link] = ""
[Link] = ""

class LoginPop(FloatLayout):
pass

def show_LoginPop():
show = LoginPop()
popup_window = Popup(title = "Login Error", content = show, size_hint =
(0.6, 0.3))
popup_window.open()

# After Login
# Common Functions
def go_to_website(instance):
web.open_new_tab("[Link]

# AboutHospital class
class AboutHospital(Screen):
def __init__(self,**kwargs):
super().__init__(**kwargs)
with [Link]:
Color(51/255, 153/255, 255/255,1,mode="rgba")
Line(points = ((0, 580),(1000, 580)), width = 50)
Line(points = ((0, 0),(1000, 0)), width = 35)
[Link] = Label(text="About Hospital", font_size=40, color=(1,1,1,1))
[Link].pos_hint= {"x":0.05, "top": 1.45}
self.add_widget([Link])

[Link] = Button(background_normal="resources/short_logo.png",
background_down="resources/short_logo.png")
[Link].size_hint = (None, None)
[Link] = 120
[Link] = 90
[Link] = (0,0,0,1)
[Link].pos_hint = {"x": 0.1, "top": 1.02}
self.add_widget([Link])

self.close_button = Button(background_normal="resources/[Link]",
background_down="resources/close_down.png")
self.close_button.size_hint = (None, None)
self.close_button.width = 60
self.close_button.height = 60
self.close_button.color = (0,0,0,1)
self.close_button.pos_hint = {"x": 0.85, "top": 0.99}
self.add_widget(self.close_button)
self.close_button.bind(on_release = self.go_back)

[Link] = Label(text="Built with Python, PostgreSQL, Psycopg2, and


Kivy", font_size=13, color=(1,1,1,1))
[Link].pos_hint = {"x":-0.27, "top": 0.525}
self.add_widget([Link])

[Link]= Button(text="About Creator: Ahammad Shawki 8",


font_size=13, color=(1,1,1,1))
[Link].pos_hint = {"x":0.7, "top": 0.05}
[Link].size_hint = (0.28,0.05)
[Link].background_color = (1,1,1,0)
self.add_widget([Link])
[Link](on_press = go_to_website)

self.hospital_name_label =
Label(text=constant.grab_constant(True,"HOSPITAL_TITLE").upper(), font_size=20,
color=(0,0,0,1))
self.hospital_name_label.pos_hint = {"x":0.21, "top": 1.2}
self.add_widget(self.hospital_name_label)

self.hospital_motto_label =
Label(text=constant.grab_constant(True,"HOSPITAL_MOTTO").upper(), font_size=18,
color=(51/255, 153/255, 255/255,1))
self.hospital_motto_label.pos_hint = {"x":0.255, "top": 1.16}
self.add_widget(self.hospital_motto_label)

self.hospital_location_label =
Label(text=constant.grab_constant(True,"HOSPITAL_LOCATION"), font_size=13,
color=(0,0,0,1))
self.hospital_location_label.pos_hint = {"x":0.17, "top": 1.13}
self.add_widget(self.hospital_location_label)

self.hospital_info_label = Label(text=""" Our Hospital is a well-


known hospital of the country. It provides quality treatment for patients
and it has a qualified doctor's faculty. All of the employees are also
hardworking.
This hospital also provides an efficient GUI that can be used from any
device.
Some more information about our hospital:""", font_size=13,
color=(0,0,0,1))
self.hospital_info_label.pos_hint = {"x":0.01, "top": 0.98}
self.add_widget(self.hospital_info_label)

self.info_grid = GridLayout()
self.info_grid.cols = 2
self.info_grid.size_hint = 0.6,0.25
self.info_grid.pos_hint = {"x": 0.25, "top": 0.4}
self.year_name = Label(text= "Founded in:", color = (0,0,0,1),
font_size=13)
self.info_grid.add_widget(self.year_name)
self.year_value = Label(text= constant.grab_constant(True,
"HOSPITAL_YEAR"), color = (0,0,0,1), font_size=13)
self.info_grid.add_widget(self.year_value)
self.total_bed_name = Label(text= "Total Bed Number:", color =
(0,0,0,1), font_size=13)
self.info_grid.add_widget(self.total_bed_name)
self.total_bed_value = Label(text=
constant.grab_constant(True,"HOSPITAL_TOTAL_BED"), color = (0,0,0,1),
font_size=13)
self.info_grid.add_widget(self.total_bed_value)
self.remainning_bed_name = Label(text= "Number of Available Beds:",
color = (0,0,0,1), font_size=13)
self.info_grid.add_widget(self.remainning_bed_name)
self.remainning_bed_value = Label(text=
constant.grab_constant(True,"HOSPITAL_REMAINING_BED"), color = (0,0,0,1),
font_size=13)
self.info_grid.add_widget(self.remainning_bed_value)
self.doctors_number_name = Label(text= "Total Doctors:", color =
(0,0,0,1), font_size=13)
self.info_grid.add_widget(self.doctors_number_name)
self.doctors_number_value = Label(text=
constant.grab_constant(True,"HOSPITAL_TOTAL_DOCTOR"), color = (0,0,0,1),
font_size=13)
self.info_grid.add_widget(self.doctors_number_value)
self.patient_number_name = Label(text= "Total Treated Patient:", color =
(0,0,0,1), font_size=13)
self.info_grid.add_widget(self.patient_number_name)
self.patient_number_value = Label(text=
constant.grab_constant(True,"HOSPITAL_TOTAL_PATIENT"), color = (0,0,0,1),
font_size=13)
self.info_grid.add_widget(self.patient_number_value)
self.patient_current_name = Label(text= "Number of Current Patient:",
color = (0,0,0,1), font_size=13)
self.info_grid.add_widget(self.patient_current_name)
self.patient_current_value = Label(text=
constant.grab_constant(True,"HOSPITAL_CURRENT_PATIENT"), color = (0,0,0,1),
font_size=13)
self.info_grid.add_widget(self.patient_current_value)
self.employee_number_name = Label(text= "Total Employee:", color =
(0,0,0,1), font_size=13)
self.info_grid.add_widget(self.employee_number_name)
self.employee_number_value = Label(text=
constant.grab_constant(True,"HOSPITAL_TOTAL_EMPLOYEE"), color = (0,0,0,1),
font_size=13)
self.info_grid.add_widget(self.employee_number_value)
self.add_widget(self.info_grid)

def go_back(self, instance):


pass

# Subclasses of AboutHospital class


class AdminAboutHospital(AboutHospital):
def go_back(self, instance):
[Link] = SlideTransition(direction = "right")
[Link] = "AdminAfterLogin"

class DoctorAboutHospital(AboutHospital):
def go_back(self, instance):
[Link] = SlideTransition(direction = "right")
[Link] = "DoctorAfterLogin"

class PatientAboutHospital(AboutHospital):
def go_back(self, instance):
[Link] = SlideTransition(direction = "right")
[Link] = "PatientAfterLogin"

class EmployeeAboutHospital(AboutHospital):
def go_back(self, instance):
[Link] = SlideTransition(direction = "right")
[Link] = "EmployeeAfterLogin"

# Documentation class
class Documentation(Screen):
def __init__(self, **kwargs):
super().__init__(**kwargs)

[Link] = self.find_my_category()
with [Link]:
Color(51/255, 153/255, 255/255,1,mode="rgba")
Line(points = ((0, 580),(1000, 580)), width = 50)
Line(points = ((0, 0),(1000, 0)), width = 35)
[Link] = Label(text=[Link]()+ " Documentaion",
font_size=40, color=(1,1,1,1))
[Link].pos_hint= {"x":0.05, "top": 1.45}
self.add_widget([Link])

[Link] = Button(background_normal="resources/short_logo.png",
background_down="resources/short_logo.png")
[Link].size_hint = (None, None)
[Link] = 120
[Link] = 90
[Link] = (0,0,0,1)
[Link].pos_hint = {"x": 0.1, "top": 1.02}
self.add_widget([Link])

self.close_button = Button(background_normal="resources/[Link]",
background_down="resources/close_down.png")
self.close_button.size_hint = (None, None)
self.close_button.width = 60
self.close_button.height = 60
self.close_button.color = (0,0,0,1)
self.close_button.pos_hint = {"x": 0.85, "top": 0.99}
self.add_widget(self.close_button)
self.close_button.bind(on_release = self.go_back)

[Link] = Label(text="Built with Python, PostgreSQL, Psycopg2, and


Kivy", font_size=13, color=(1,1,1,1))
[Link].pos_hint = {"x":-0.27, "top": 0.525}
self.add_widget([Link])

[Link]= Button(text="About Creator: Ahammad Shawki 8",


font_size=13, color=(1,1,1,1))
[Link].pos_hint = {"x":0.7, "top": 0.05}
[Link].size_hint = (0.28,0.05)
[Link].background_color = (1,1,1,0)
self.add_widget([Link])
[Link](on_press = go_to_website)

self.instruction_label = Label(text="Read this documentation clearly and


perform your tasks:", font_size=18, color=(51/255, 153/255, 255/255,1))
self.instruction_label.pos_hint = {"x":-0.1, "top": 1}
self.add_widget(self.instruction_label)

self.instruction_body = Label(text=self.all_instructions(), font_size =


14, color = (0,0,0,1))
self.instruction_body.size_hint = 0.8 , 0.5
self.instruction_body.pos_hint = {"x":0.1, "top": 0.57}
self.add_widget(self.instruction_body)

def go_back(self):
pass

def find_my_category(self):
return "Doctor"

def all_instructions(self):
return "Default"

# Subclasses of Documentation class


class AdminDocumentation(Documentation):
def go_back(self, instance):
[Link] = SlideTransition(direction = "right")
[Link] = "AdminAfterLogin"

def find_my_category(self):
return "admin"

def all_instructions(self):
text = """
00. SignUp or Login to the application to use it.
01. Send others notification using + button.
02. See all of your notification as well as profile.
03. In "Functions" secion, you have a set of functions.
04. Use those functions providing necessary information.
05. In "Settings" you can edit your profile.
06. Read more about the hospital in "About Hospital" section.
07. You are currently reading the docs in the "Documentation" section.
08. Visit creators webpage by clicking on his name at the bottom-right
corner.
09. Promote this "Hospital Management System" application in social
network.
10. Be active in your workflow and have a great day.
"""
return text
class DoctorDocumentation(Documentation):
def go_back(self, instance):
[Link] = SlideTransition(direction = "right")
[Link] = "DoctorAfterLogin"

def find_my_category(self):
return "doctor"

def all_instructions(self):
text = """
00. SignUp or Login to the application to use it.
01. Send notifications to admin using + button.
02. See all of your notification as well as profile.
03. In "Functions" secion, you have a set of functions.
04. Use those functions providing necessary information.
05. In "Settings" you can edit your profile.
06. Read more about the hospital in "About Hospital" section.
07. You are currently reading the docs in the "Documentation" section.
08. Visit creators webpage by clicking on his name at the bottom-right
corner.
09. Promote this "Hospital Management System" application in social
network.
10. Be active in your workflow and have a great day.
"""
return text

class PatientDocumentation(Documentation):
def go_back(self, instance):
[Link] = SlideTransition(direction = "right")
[Link] = "PatientAfterLogin"

def find_my_category(self):
return "patient"

def all_instructions(self):
text = """
00. SignUp or Login to the application to use it.
01. Send notifications to admin using + button.
02. See all of your notification as well as profile.
03. In "Functions" secion, you have a set of functions.
04. Use those functions providing necessary information.
05. In "Settings" you can edit your profile.
06. Read more about the hospital in "About Hospital" section.
07. You are currently reading the docs in the "Documentation" section.
08. Visit creators webpage by clicking on his name at the bottom-right
corner.
09. Promote this "Hospital Management System" application in social
network.
10. Be active in your workflow and have a great day.
"""
return text

class EmployeeDocumentation(Documentation):
def go_back(self, instance):
[Link] = SlideTransition(direction = "right")
[Link] = "EmployeeAfterLogin"

def find_my_category(self):
return "employee"

def all_instructions(self):
text = """
00. SignUp or Login to the application to use it.
01. Send notifications to admin using + button.
02. See all of your notification as well as profile.
03. In "Functions" secion, you have a set of functions.
04. Use those functions providing necessary information.
05. In "Settings" you can edit your profile.
06. Read more about the hospital in "About Hospital" section.
07. You are currently reading the docs in the "Documentation" section.
08. Visit creators webpage by clicking on his name at the bottom-right
corner.
09. Promote this "Hospital Management System" application in social
network.
10. Be active in your workflow and have a great day.
"""
return text

# Profile class
class Profile(Screen):
def __init__(self, **kwargs):
super().__init__(**kwargs)

[Link] = self.find_my_username()
[Link] = self.find_my_category()
if [Link] == "admin":
[Link], [Link], self.date_of_birth, *others =
self.get_my_profile([Link], [Link])[0][1:]
[Link], [Link] = others
elif [Link] == "doctor":
[Link], [Link], self.date_of_birth, *others =
self.get_my_profile([Link], [Link])[0][1:]
[Link], [Link], [Link], [Link] =
others
elif [Link] == "patient":
[Link], [Link], self.date_of_birth, *others =
self.get_my_profile([Link], [Link])[0][1:]
[Link], [Link], self.requested_doctor_username,
self.approved_doctor_username, self.appointment_timestamp, [Link],
[Link] = others
else:
[Link], [Link], self.date_of_birth, *others =
self.get_my_profile([Link], [Link])[0][1:]
[Link], [Link], self.work_of_doctors, [Link],
[Link] = others

with [Link]:
Color(51/255, 153/255, 255/255,1,mode="rgba")
Line(points = ((0, 580),(1000, 580)), width = 50)
Line(points = ((0, 0),(1000, 0)), width = 35)
[Link] = Label(text=self.find_my_category().capitalize()+ "
Profile", font_size=40, color=(1,1,1,1))
[Link].pos_hint= {"x":0.05, "top": 1.45}
self.add_widget([Link])

[Link] = Button(background_normal="resources/short_logo.png",
background_down="resources/short_logo.png")
[Link].size_hint = (None, None)
[Link] = 120
[Link] = 90
[Link] = (0,0,0,1)
[Link].pos_hint = {"x": 0.1, "top": 1.02}
self.add_widget([Link])

self.close_button = Button(background_normal="resources/[Link]",
background_down="resources/close_down.png")
self.close_button.size_hint = (None, None)
self.close_button.width = 60
self.close_button.height = 60
self.close_button.color = (0,0,0,1)
self.close_button.pos_hint = {"x": 0.85, "top": 0.99}
self.add_widget(self.close_button)
self.close_button.bind(on_release = self.go_back)

[Link] = Label(text="Built with Python, PostgreSQL, Psycopg2, and


Kivy", font_size=13, color=(1,1,1,1))
[Link].pos_hint = {"x":-0.27, "top": 0.525}
self.add_widget([Link])

[Link]= Button(text="About Creator: Ahammad Shawki 8",


font_size=13, color=(1,1,1,1))
[Link].pos_hint = {"x":0.7, "top": 0.05}
[Link].size_hint = (0.28,0.05)
[Link].background_color = (1,1,1,0)
self.add_widget([Link])
[Link](on_press = go_to_website)

self.info_grid = GridLayout()
self.info_grid.cols = 2
self.info_grid.size_hint = 0.6,0.3
self.info_grid.pos_hint = {"x": 0.2, "top": 0.5}
self.username_name = Label(text = "Username:", color = (0,0,0,1),
font_size=13)
self.info_grid.add_widget(self.username_name)
self.username_value = Label(text = [Link], color = (0,0,0,1),
font_size=13)
self.info_grid.add_widget(self.username_value)
self.fullname_name = Label(text = "Fullname:", color = (0,0,0,1),
font_size=13)
self.info_grid.add_widget(self.fullname_name)
self.fullname_value = Label(text = [Link], color = (0,0,0,1),
font_size=13)
self.info_grid.add_widget(self.fullname_value)
self.email_name = Label(text = "Email Address:", color = (0,0,0,1),
font_size=13)
self.info_grid.add_widget(self.email_name)
self.email_value = Label(text = [Link], color = (0,0,0,1),
font_size=13)
self.info_grid.add_widget(self.email_value)
self.date_of_birth_name = Label(text = "Date of Birth", color =
(0,0,0,1), font_size=13)
self.info_grid.add_widget(self.date_of_birth_name)
self.date_of_birth_value = Label(text =
[Link](self.date_of_birth, format = "%d %b,%Y" ), color =
(0,0,0,1), font_size=13)
self.info_grid.add_widget(self.date_of_birth_value)
if [Link] == "doctor":
self.specialty_name = Label(text = "Specialty:", color = (0,0,0,1),
font_size=13)
self.info_grid.add_widget(self.specialty_name)
self.specialty_value = Label(text = [Link], color =
(0,0,0,1), font_size=13)
self.info_grid.add_widget(self.specialty_value)
self.price_name = Label(text = "Per CheckUp Fee:", color =
(0,0,0,1), font_size=13)
self.info_grid.add_widget(self.price_name)
self.price_value = Label(text = str([Link]), color = (0,0,0,1),
font_size=13)
self.info_grid.add_widget(self.price_value)
elif [Link] == "patient":
self.problem_name = Label(text = "Problem:", color = (0,0,0,1),
font_size=13)
self.info_grid.add_widget(self.problem_name)
self.problem_value = Label(text = [Link], color = (0,0,0,1),
font_size=13)
self.info_grid.add_widget(self.problem_value)
self.requested_doctor_username_name = Label(text = "Requested
Doctor:", color = (0,0,0,1), font_size=13)
self.info_grid.add_widget(self.requested_doctor_username_name)
self.requested_doctor_username_value = Label(text =
(self.requested_doctor_username if not self.requested_doctor_username==None else
"None"), color = (0,0,0,1), font_size=13)
self.info_grid.add_widget(self.requested_doctor_username_value)
self.approved_doctor_username_name = Label(text = "Approved
Doctor:", color = (0,0,0,1), font_size=13)
self.info_grid.add_widget(self.approved_doctor_username_name)
self.approved_doctor_username_value = Label(text =
(self.approved_doctor_username if not self.approved_doctor_username==None else
"None"), color = (0,0,0,1), font_size=13)
self.info_grid.add_widget(self.approved_doctor_username_value)
self.appointment_timestamp_name = Label(text = "Appointment
Timestamp:", color = (0,0,0,1), font_size=13)
self.info_grid.add_widget(self.appointment_timestamp_name)
self.appointment_timestamp_value =
Label(text=([Link](self.appointment_timestamp, format="%d
%b, %Y %H:%M:%S") if self.appointment_timestamp != None else "None"), color =
(0,0,0,1), font_size=13)
self.info_grid.add_widget(self.appointment_timestamp_value)
self.reports_name = Label(text = "Reports:", color = (0,0,0,1),
font_size=13)
self.info_grid.add_widget(self.reports_name)
self.report_bucket = [Link]("+++")
self.report_string = [[Link]("++", ",") for item in
self.report_bucket]
self.reports_value = Label(text = str(self.report_string), color =
(0,0,0,1), font_size=13)
self.info_grid.add_widget(self.reports_value)
elif [Link] =="employee":
self.work_name = Label(text = "Work:", color = (0,0,0,1),
font_size=13)
self.info_grid.add_widget(self.work_name)
self.work_value = Label(text = [Link], color = (0,0,0,1),
font_size=13)
self.info_grid.add_widget(self.work_value)
self.work_of_doctors_name = Label(text = "Work of Doctors:", color =
(0,0,0,1), font_size=13)
self.info_grid.add_widget(self.work_of_doctors_name)
self.work_of_doctors_value = Label(text = self.work_of_doctors,
color = (0,0,0,1), font_size=13)
self.info_grid.add_widget(self.work_of_doctors_value)
self.salary_name = Label(text = "Salary:", color = (0,0,0,1),
font_size=13)
self.info_grid.add_widget(self.salary_name)
self.salary_value = Label(text = str([Link]), color =
(0,0,0,1), font_size=13)
self.info_grid.add_widget(self.salary_value)
self.add_widget(self.info_grid)

def get_my_profile(self, username, category):


return admin.see_info(True, category, username)

def find_my_category(self):
return "doctor"

def find_my_username(self):
return "hpt"

def go_back(self):
pass

# Subclasses of Profile class


class AdminProfile(Profile):
def find_my_category(self):
return "admin"

def find_my_username(self):
return [Link]
def go_back(self, instance):
for screen in [Link]:
if [Link] == "AdminProfile":
[Link](screen)
[Link] = SlideTransition(direction = "right")
[Link] = "AdminAfterLogin"

class DoctorProfile(Profile):
def find_my_category(self):
return "doctor"

def find_my_username(self):
return [Link]

def go_back(self, instance):


for screen in [Link]:
if [Link] == "DoctorProfile":
[Link](screen)
[Link] = SlideTransition(direction = "right")
[Link] = "DoctorAfterLogin"

class PatientProfile(Profile):
def find_my_category(self):
return "patient"

def find_my_username(self):
return [Link]

def go_back(self, instance):


for screen in [Link]:
if [Link] == "PatientProfile":
[Link](screen)
[Link] = SlideTransition(direction = "right")
[Link] = "PatientAfterLogin"

class EmployeeProfile(Profile):
def find_my_category(self):
return "employee"

def find_my_username(self):
return [Link]

def go_back(self, instance):


for screen in [Link]:
if [Link] == "EmployeeProfile":
[Link](screen)
[Link] = SlideTransition(direction = "right")
[Link] = "EmployeeAfterLogin"
# Notifications class
class Notifications(Screen):
def __init__(self, **kwargs):
super().__init__(**kwargs)

[Link] = self.find_my_username()
[Link] = self.find_my_category()
[Link] = self.get_my_notification([Link],
[Link])

with [Link]:
Color(51/255, 153/255, 255/255,1,mode="rgba")
Line(points = ((0, 580),(1000, 580)), width = 50)
Line(points = ((0, 0),(1000, 0)), width = 35)
[Link] = Label(text=self.find_my_category().capitalize()+ "
Notifications", font_size=40, color=(1,1,1,1))
[Link].pos_hint= {"x":0.05, "top": 1.45}
self.add_widget([Link])

[Link] = Button(background_normal="resources/short_logo.png",
background_down="resources/short_logo.png")
[Link].size_hint = (None, None)
[Link] = 120
[Link] = 90
[Link] = (0,0,0,1)
[Link].pos_hint = {"x": 0.1, "top": 1.02}
self.add_widget([Link])

self.close_button = Button(background_normal="resources/[Link]",
background_down="resources/close_down.png")
self.close_button.size_hint = (None, None)
self.close_button.width = 60
self.close_button.height = 60
self.close_button.color = (0,0,0,1)
self.close_button.pos_hint = {"x": 0.85, "top": 0.99}
self.add_widget(self.close_button)
self.close_button.bind(on_release = self.go_back)

[Link] = Label(text="Built with Python, PostgreSQL, Psycopg2, and


Kivy", font_size=13, color=(1,1,1,1))
[Link].pos_hint = {"x":-0.27, "top": 0.525}
self.add_widget([Link])

[Link]= Button(text="About Creator: Ahammad Shawki 8",


font_size=13, color=(1,1,1,1))
[Link].pos_hint = {"x":0.7, "top": 0.05}
[Link].size_hint = (0.28,0.05)
[Link].background_color = (1,1,1,0)
self.add_widget([Link])
[Link](on_press = go_to_website)

self.info_grid = GridLayout()
self.info_grid.cols = 1
self.info_grid.pos_hint = {"x": 0.2, "top": 0.5}
self.note_length = len([Link])
if self.note_length > 6:
[Link] = 0.3
elif self.note_length > 3:
[Link] = 0.2
else:
[Link] = 0.1
self.info_grid.size_hint = 0.6, [Link]

for item in [Link]:


self.new_notice = Label(text=str(item), color=(0,0,0,1),
font_size=13)
self.info_grid.add_widget(self.new_notice)

self.add_widget(self.info_grid)

def get_my_notification(self, username, category):


return "Default"

def find_my_category(self):
return "doctor"

def find_my_username(self):
return "hpt"

def go_back(self):
pass

# Subclasses of Notifications class


class AdminNotifications(Notifications):
def find_my_category(self):
return "admin"

def find_my_username(self):
return [Link]

def go_back(self, instance):


for screen in [Link]:
if [Link] == "AdminNotifications":
[Link](screen)
[Link] = SlideTransition(direction = "right")
[Link] = "AdminAfterLogin"

def get_my_notification(self, username, category):


return admin.recent_notifications(username, True, limit = 10)

class DoctorNotifications(Notifications):
def find_my_category(self):
return "doctor"

def find_my_username(self):
return [Link]

def go_back(self, instance):


for screen in [Link]:
if [Link] == "DoctorNotifications":
[Link](screen)
[Link] = SlideTransition(direction = "right")
[Link] = "DoctorAfterLogin"

def get_my_notification(self, username, category):


return doctor.recent_notifications(username, True, limit = 10)

class PatientNotifications(Notifications):
def find_my_category(self):
return "patient"

def find_my_username(self):
return [Link]

def go_back(self, instance):


for screen in [Link]:
if [Link] == "PatientNotifications":
[Link](screen)
[Link] = SlideTransition(direction = "right")
[Link] = "PatientAfterLogin"

def get_my_notification(self, username, category):


return patient.recent_notifications(username, True, limit = 10)

class EmployeeNotifications(Notifications):
def find_my_category(self):
return "employee"

def find_my_username(self):
return [Link]

def go_back(self, instance):


for screen in [Link]:
if [Link] == "EmployeeNotifications":
[Link](screen)
[Link] = SlideTransition(direction = "right")
[Link] = "EmployeeAfterLogin"

def get_my_notification(self, username, category):


return employee.recent_notifications(username, True, limit = 10)

# AddNotifications class
class AddNotifications(Screen):
receiver = ObjectProperty()
body = ObjectProperty()
receiver_category = ObjectProperty()
def __init__(self, **kwargs):
super().__init__(**kwargs)

[Link] = self.find_my_username()
[Link] = self.find_my_category()
with [Link]:
Color(51/255, 153/255, 255/255,1,mode="rgba")
Line(points = ((0, 580),(1000, 580)), width = 50)
Line(points = ((0, 0),(1000, 0)), width = 35)
[Link] = Label(text=self.find_my_category().capitalize()+ " Add
Notifications", font_size=40, color=(1,1,1,1))
[Link].pos_hint= {"x":0.05, "top": 1.45}
self.add_widget([Link])

[Link] = Button(background_normal="resources/short_logo.png",
background_down="resources/short_logo.png")
[Link].size_hint = (None, None)
[Link] = 120
[Link] = 90
[Link] = (0,0,0,1)
[Link].pos_hint = {"x": 0.1, "top": 1.02}
self.add_widget([Link])

self.close_button = Button(background_normal="resources/[Link]",
background_down="resources/close_down.png")
self.close_button.size_hint = (None, None)
self.close_button.width = 60
self.close_button.height = 60
self.close_button.color = (0,0,0,1)
self.close_button.pos_hint = {"x": 0.85, "top": 0.99}
self.add_widget(self.close_button)
self.close_button.bind(on_release = self.go_back)

[Link] = Label(text="Built with Python, PostgreSQL, Psycopg2, and


Kivy", font_size=13, color=(1,1,1,1))
[Link].pos_hint = {"x":-0.27, "top": 0.525}
self.add_widget([Link])

[Link]= Button(text="About Creator: Ahammad Shawki 8",


font_size=13, color=(1,1,1,1))
[Link].pos_hint = {"x":0.7, "top": 0.05}
[Link].size_hint = (0.28,0.05)
[Link].background_color = (1,1,1,0)
self.add_widget([Link])
[Link](on_press = go_to_website)

self.info_grid = GridLayout()
self.info_grid.cols = 2
self.info_grid.pos_hint = {"x": 0.2, "top": 0.7}
self.info_grid.size_hint = 0.6, 0.3
if [Link] == "admin":
self.receiver_username_name = Label(text= "Receiver's username:",
font_size=15, color = (0,0,0,1))
self.info_grid.add_widget(self.receiver_username_name)
self.receiver_username_value = TextInput(multiline = False)
self.info_grid.add_widget(self.receiver_username_value)
self.receiver_category_name = Label(text= "Receiver's category:",
font_size=15, color = (0,0,0,1))
self.info_grid.add_widget(self.receiver_category_name)
self.receiver_category_value = TextInput(multiline = False)
self.info_grid.add_widget(self.receiver_category_value)
else:
self.receiver_username_name = Label(text= "Admin's username:",
font_size=15, color = (0,0,0,1))
self.info_grid.add_widget(self.receiver_username_name)
self.receiver_username_value = TextInput(multiline = False)
self.info_grid.add_widget(self.receiver_username_value)
self.notification_body_name = Label(text= "Notification's Body: ",
font_size=15, color = (0,0,0,1))
self.info_grid.add_widget(self.notification_body_name)
self.notification_body_value = TextInput(multiline = False)
self.info_grid.add_widget(self.notification_body_value)
self.add_widget(self.info_grid)

[Link] = Button(text = "Send")


[Link].font_size = 18
[Link] = (1, 1, 1,1)
[Link] = True
[Link].background_color = (0/255, 153/255, 204/255, 1)
[Link].size_hint = (0.3,0.08)
[Link].pos_hint = {"x":0.36, "top": 0.2}
self.add_widget([Link])
[Link](on_release = self.pre_notifications)

def pre_notifications(self, instance):


receiver = self.receiver_username_value.text
body = self.notification_body_value.text
username = [Link]

self.send_notifications(body, receiver, username)

self.receiver_username_value.text = ""
self.notification_body_value.text = ""

def send_notifications(self,body,receiver,username):
return "Default"

def find_my_category(self):
return "doctor"

def find_my_username(self):
return "hpt"

def go_back(self):
pass
# Subclasses of AddNotifications class
class AdminAddNotifications(AddNotifications):
def find_my_category(self):
return "admin"

def find_my_username(self):
return [Link]

def go_back(self, instance):


for screen in [Link]:
if [Link] == "AdminAddNotifications":
[Link](screen)
[Link] = SlideTransition(direction = "right")
[Link] = "AdminAfterLogin"

def pre_notifications(self, instance):


receiver = self.receiver_username_value.text
receiver_cat = self.receiver_category_value.text
body = self.notification_body_value.text
username = [Link]

self.send_notifications(body, receiver, username, receiver_cat)

self.receiver_username_value.text = ""
self.notification_body_value.text = ""
self.receiver_category_value.text = ""

def send_notifications(self, body, receiver, username, category):


[Link] = body
[Link] = receiver
[Link] = username
[Link] = category

try:
admin.add_notification(body,category,receiver, True)
except:
show_NotificationPop()

class DoctorAddNotifications(AddNotifications):
def find_my_category(self):
return "doctor"

def find_my_username(self):
return [Link]

def go_back(self, instance):


for screen in [Link]:
if [Link] == "DoctorAddNotifications":
[Link](screen)
[Link] = SlideTransition(direction = "right")
[Link] = "DoctorAfterLogin"

def send_notifications(self, body, receiver, username):


[Link] = body
[Link] = receiver
[Link] = username

try:
return doctor.notify_admin([Link], [Link], [Link],
True)
except:
show_NotificationPop()

class PatientAddNotifications(AddNotifications):
def find_my_category(self):
return "patient"

def find_my_username(self):
return [Link]

def go_back(self, instance):


for screen in [Link]:
if [Link] == "PatientAddNotifications":
[Link](screen)
[Link] = SlideTransition(direction = "right")
[Link] = "PatientAfterLogin"

def send_notifications(self, body, receiver, username):


[Link] = body
[Link] = receiver
[Link] = username

try:
return patient.notify_admin([Link], [Link], [Link],
True)
except:
show_NotificationPop()

class EmployeeAddNotifications(AddNotifications):
def find_my_category(self):
return "employee"

def find_my_username(self):
return [Link]

def go_back(self, instance):


for screen in [Link]:
if [Link] == "EmployeeAddNotifications":
[Link](screen)
[Link] = SlideTransition(direction = "right")
[Link] = "EmployeeAfterLogin"

def send_notifications(self, body, receiver, username):


[Link] = body
[Link] = receiver
[Link] = username
try:
return employee.notify_admin([Link], [Link],
[Link], True)
except:
show_NotificationPop()

class NotificationPop(FloatLayout):
pass

def show_NotificationPop():
show = NotificationPop()
popup_window = Popup(title = "Add Notification Error", content = show,
size_hint = (0.6, 0.3))
popup_window.open()

# Settings class
class Settings(Screen):
def __init__(self, **kwargs):
super().__init__(**kwargs)

[Link] = self.find_my_username()
[Link] = self.find_my_category()
with [Link]:
Color(1, 1, 1,1,mode="rgba")
Rectangle(pos = [Link], size = (800,600))
Color(51/255, 153/255, 255/255,1,mode="rgba")
Line(points = ((0, 580),(1000, 580)), width = 50)
Line(points = ((0, 0),(1000, 0)), width = 35)
[Link] = Label(text=self.find_my_category().capitalize()+ "
Settings", font_size=40, color=(1,1,1,1))
[Link].pos_hint= {"x":0.05, "top": 1.45}
self.add_widget([Link])

[Link] = Image(source='resources/settings_pic.png', size_hint=


(0.7,0.3), pos_hint= {"x": 0.16, "top": 0.85})
self.add_widget([Link])

[Link] = Button(background_normal="resources/short_logo.png",
background_down="resources/short_logo.png")
[Link].size_hint = (None, None)
[Link] = 120
[Link] = 90
[Link] = (0,0,0,1)
[Link].pos_hint = {"x": 0.1, "top": 1.02}
self.add_widget([Link])

self.close_button = Button(background_normal="resources/[Link]",
background_down="resources/close_down.png")
self.close_button.size_hint = (None, None)
self.close_button.width = 60
self.close_button.height = 60
self.close_button.color = (0,0,0,1)
self.close_button.pos_hint = {"x": 0.85, "top": 0.99}
self.add_widget(self.close_button)
self.close_button.bind(on_release = self.go_back)

[Link] = Label(text="Built with Python, PostgreSQL, Psycopg2, and


Kivy", font_size=13, color=(1,1,1,1))
[Link].pos_hint = {"x":-0.27, "top": 0.525}
self.add_widget([Link])

[Link]= Button(text="About Creator: Ahammad Shawki 8",


font_size=13, color=(1,1,1,1))
[Link].pos_hint = {"x":0.7, "top": 0.05}
[Link].size_hint = (0.28,0.05)
[Link].background_color = (1,1,1,0)
self.add_widget([Link])
[Link](on_press = go_to_website)

[Link] = Label(text= "Only change the profile values which you need
to change. Otherswise, leave it blank.", font_size=15, color = (51/255, 153/255,
255/255,1))
[Link].pos_hint = {"x": 0.015, "top": 1}
self.add_widget([Link])

self.info_grid = GridLayout()
self.info_grid.cols = 2
self.info_grid.pos_hint = {"x": 0.2, "top": 0.45}
self.info_grid.size_hint = 0.6, 0.2

self.fullname_name = Label(text= "Fullname:", font_size=15, color =


(0,0,0,1))
self.info_grid.add_widget(self.fullname_name)
self.fullname_value = TextInput(multiline = False)
self.info_grid.add_widget(self.fullname_value)
self.email_name = Label(text= "Email Address:", font_size=15, color =
(0,0,0,1))
self.info_grid.add_widget(self.email_name)
self.email_value = TextInput(multiline = False)
self.info_grid.add_widget(self.email_value)
self.date_of_birth_name = Label(text= "Date of Birth:", font_size=15,
color = (0,0,0,1))
self.info_grid.add_widget(self.date_of_birth_name)
self.date_of_birth_value = TextInput(multiline = False)
self.info_grid.add_widget(self.date_of_birth_value)
self.add_widget(self.info_grid)

[Link] = Button(text = "Save Settings")


[Link].font_size = 18
[Link] = (1, 1, 1, 1)
[Link] = True
[Link].background_color = (0/255, 153/255, 204/255, 1)
[Link].size_hint = (0.3,0.08)
[Link].pos_hint = {"x":0.36, "top": 0.175}
self.add_widget([Link])
[Link](on_release = self.save_settings)

def find_my_category(self):
return "doctor"

def find_my_username(self):
return "hpt"

def go_back(self):
pass

def save_settings(self, instance):


fullname = self.fullname_value.text
email = self.email_value.text
date_of_birth = self.date_of_birth_value.text

fullname_pass = False
email_pass = False
date_of_birth_pass = False

if fullname != "":
fullname_pass = True
if email != "":
email_pass = True
if date_of_birth != "":
date_of_birth_pass = True

if fullname_pass:
admin.update_db([Link], [Link], "fullname", fullname,
True)
if email_pass:
admin.update_db([Link], [Link], "email", email, True)
if date_of_birth_pass:
admin.update_db([Link], [Link], "date_of_birth",
date_of_birth, True)

# Settings sub classes


class AdminSettings(Settings):
def find_my_category(self):
return "admin"

def find_my_username(self):
return [Link]

def go_back(self, instance):


for screen in [Link]:
if [Link] == "AdminSettings":
[Link](screen)
[Link] = SlideTransition(direction = "right")
[Link] = "AdminAfterLogin"
class DoctorSettings(Settings):
def find_my_category(self):
return "doctor"

def find_my_username(self):
return [Link]

def go_back(self, instance):


for screen in [Link]:
if [Link] == "DoctorSettings":
[Link](screen)
[Link] = SlideTransition(direction = "right")
[Link] = "DoctorAfterLogin"

class PatientSettings(Settings):
def find_my_category(self):
return "patient"

def find_my_username(self):
return [Link]

def go_back(self, instance):


for screen in [Link]:
if [Link] == "PatientSettings":
[Link](screen)
[Link] = SlideTransition(direction = "right")
[Link] = "PatientAfterLogin"

class EmployeeSettings(Settings):
def find_my_category(self):
return "employee"

def find_my_username(self):
return [Link]

def go_back(self, instance):


for screen in [Link]:
if [Link] == "EmployeeSettings":
[Link](screen)
[Link] = SlideTransition(direction = "right")
[Link] = "EmployeeAfterLogin"

# Admin Functions
class AdminFunctions(Screen):
def __init__(self, **kwargs):
super().__init__(**kwargs)

[Link] = self.find_my_username()
[Link] = "admin"
with [Link]:
Color(1, 1, 1,1,mode="rgba")
Rectangle(pos = [Link], size = (800,600))
Color(51/255, 153/255, 255/255,1,mode="rgba")
Line(points = ((0, 580),(1000, 580)), width = 50)
Line(points = ((0, 0),(1000, 0)), width = 35)
[Link] = Label(text="Admin Functions", font_size=40,
color=(1,1,1,1))
[Link].pos_hint= {"x":0.05, "top": 1.45}
self.add_widget([Link])

[Link] = Button(background_normal="resources/short_logo.png",
background_down="resources/short_logo.png")
[Link].size_hint = (None, None)
[Link] = 120
[Link] = 90
[Link] = (0,0,0,1)
[Link].pos_hint = {"x": 0.1, "top": 1.02}
self.add_widget([Link])

self.close_button = Button(background_normal="resources/[Link]",
background_down="resources/close_down.png")
self.close_button.size_hint = (None, None)
self.close_button.width = 60
self.close_button.height = 60
self.close_button.color = (0,0,0,1)
self.close_button.pos_hint = {"x": 0.85, "top": 0.99}
self.add_widget(self.close_button)
self.close_button.bind(on_release = self.go_back)

[Link] = Label(text="Built with Python, PostgreSQL, Psycopg2, and


Kivy", font_size=13, color=(1,1,1,1))
[Link].pos_hint = {"x":-0.27, "top": 0.525}
self.add_widget([Link])

[Link]= Button(text="About Creator: Ahammad Shawki 8",


font_size=13, color=(1,1,1,1))
[Link].pos_hint = {"x":0.7, "top": 0.05}
[Link].size_hint = (0.28,0.05)
[Link].background_color = (1,1,1,0)
self.add_widget([Link])
[Link](on_press = go_to_website)

self.info_grid = GridLayout()
self.info_grid.cols = 1
self.info_grid.pos_hint = {"x": 0.2, "top": 0.82}
self.info_grid.size_hint = 0.6, 0.7

self.total_earning_button = Button(text="Total Earning",


background_color = (0/255, 153/255, 204/255, 1), color= (1,1,1,1), font_size =
14)
self.total_earning_button.bind(on_release = lambda
x:self.set_function("total_earning_function"))
self.info_grid.add_widget(self.total_earning_button)
self.add_employee_button = Button(text="Add Employee", background_color
= (0.75, 0.75, 0.75, 1), color= (1,1,1,1), font_size = 14)
self.add_employee_button.bind(on_release = lambda
x:self.set_function("add_employee_function"))
self.info_grid.add_widget(self.add_employee_button)
self.see_my_employee_button = Button(text="See My Employee",
background_color = (0/255, 153/255, 204/255, 1), color= (1,1,1,1), font_size =
14)
self.see_my_employee_button.bind(on_release = lambda
x:self.set_function("see_my_employee_function"))
self.info_grid.add_widget(self.see_my_employee_button)
self.remove_employee_button = Button(text="Remove Employee",
background_color = (0.75, 0.75, 0.75, 1), color= (1,1,1,1), font_size = 14)
self.info_grid.add_widget(self.remove_employee_button)
self.remove_employee_button.bind(on_release = lambda
x:self.set_function("remove_employee_function"))
self.show_all_doctor_button = Button(text="Show All Doctor",
background_color = (0/255, 153/255, 204/255, 1), color= (1,1,1,1), font_size =
14)
self.info_grid.add_widget(self.show_all_doctor_button)
self.show_all_doctor_button.bind(on_release = lambda
x:self.set_function("show_all_doctor_function"))
self.show_all_patient_button = Button(text="Show All Patient",
background_color = (0.75, 0.75, 0.75, 1), color= (1,1,1,1), font_size = 14)
self.info_grid.add_widget(self.show_all_patient_button)
self.show_all_patient_button.bind(on_release = lambda
x:self.set_function("show_all_patient_function"))
self.show_all_employee_button = Button(text="Show All Employee",
background_color = (0/255, 153/255, 204/255, 1), color= (1,1,1,1), font_size =
14)
self.info_grid.add_widget(self.show_all_employee_button)
self.show_all_employee_button.bind(on_release = lambda
x:self.set_function("show_all_employee_function"))
self.remove_doctor_parmanently_button = Button(text="Remove Doctor
Parmanently", background_color = (0.75, 0.75, 0.75, 1), color= (1,1,1,1),
font_size = 14)
self.info_grid.add_widget(self.remove_doctor_parmanently_button)
self.remove_doctor_parmanently_button.bind(on_release = lambda
x:self.set_function("remove_doctor_parmanently_function"))
self.remove_patient_parmanently_button = Button(text="Remove Patient
Parmanently", background_color = (0/255, 153/255, 204/255, 1), color= (1,1,1,1),
font_size = 14)
self.info_grid.add_widget(self.remove_patient_parmanently_button)
self.remove_patient_parmanently_button.bind(on_release = lambda
x:self.set_function("remove_patient_parmanently_function"))
self.remove_employee_parmanently_button = Button(text="Remove Employee
Parmanently", background_color = (0.75, 0.75, 0.75, 1), color= (1,1,1,1),
font_size = 14)
self.info_grid.add_widget(self.remove_employee_parmanently_button)
self.remove_employee_parmanently_button.bind(on_release = lambda
x:self.set_function("remove_employee_parmanently_function"))
self.patient_joins_doctor_button = Button(text="Patient Joins Doctor",
background_color = (0/255, 153/255, 204/255, 1), color= (1,1,1,1), font_size =
14)
self.info_grid.add_widget(self.patient_joins_doctor_button)
self.patient_joins_doctor_button.bind(on_release = lambda
x:self.set_function("patient_joins_doctor_function"))

self.add_widget(self.info_grid)

def find_my_username(self):
return [Link]

def go_back(self, instance):


for screen in [Link]:
if [Link] == "AdminFunctions":
[Link](screen)
[Link] = SlideTransition(direction = "right")
[Link] = "AdminAfterLogin"

def set_function(self, function_name):


sm.add_widget(AdminDisplayFunction(function_name,
name="AdminDisplayFunction"))
[Link] = SlideTransition(direction = "left")
[Link] = "AdminDisplayFunction"

class AdminDisplayFunction(Screen):
def __init__(self, function_name, **kwargs):
super().__init__(**kwargs)

[Link] = self.find_my_username()
[Link] = "admin"
self.function_name = function_name
with [Link]:
Color(1, 1, 1,1,mode="rgba")
Rectangle(pos = [Link], size = (800,600))
Color(51/255, 153/255, 255/255,1,mode="rgba")
Line(points = ((0, 580),(1000, 580)), width = 50)
Line(points = ((0, 0),(1000, 0)), width = 35)
[Link] = Label(text="Admin Functions", font_size=40,
color=(1,1,1,1))
[Link].pos_hint= {"x":0.05, "top": 1.45}
self.add_widget([Link])

[Link] = Button(background_normal="resources/short_logo.png",
background_down="resources/short_logo.png")
[Link].size_hint = (None, None)
[Link] = 120
[Link] = 90
[Link] = (0,0,0,1)
[Link].pos_hint = {"x": 0.1, "top": 1.02}
self.add_widget([Link])

self.close_button = Button(background_normal="resources/[Link]",
background_down="resources/close_down.png")
self.close_button.size_hint = (None, None)
self.close_button.width = 60
self.close_button.height = 60
self.close_button.color = (0,0,0,1)
self.close_button.pos_hint = {"x": 0.85, "top": 0.99}
self.add_widget(self.close_button)
self.close_button.bind(on_release = self.go_back)

[Link] = Label(text="Built with Python, PostgreSQL, Psycopg2, and


Kivy", font_size=13, color=(1,1,1,1))
[Link].pos_hint = {"x":-0.27, "top": 0.525}
self.add_widget([Link])

[Link]= Button(text="About Creator: Ahammad Shawki 8",


font_size=13, color=(1,1,1,1))
[Link].pos_hint = {"x":0.7, "top": 0.05}
[Link].size_hint = (0.28,0.05)
[Link].background_color = (1,1,1,0)
self.add_widget([Link])
[Link](on_press = go_to_website)

if self.function_name == "total_earning_function":
final_function = self.total_earning_function
elif self.function_name == "add_employee_function":
final_function = self.add_employee_function
elif self.function_name == "see_my_employee_function":
final_function = self.see_my_employee_function
elif self.function_name == "remove_employee_function":
final_function = self.remove_employee_function
elif self.function_name == "show_all_doctor_function":
final_function = self.show_all_doctor_function
elif self.function_name == "show_all_patient_function":
final_function = self.show_all_patient_function
elif self.function_name == "show_all_employee_function":
final_function = self.show_all_employee_function
elif self.function_name == "remove_doctor_parmanently_function":
final_function = self.remove_doctor_parmanently_function
elif self.function_name == "remove_patient_parmanently_function":
final_function = self.remove_patient_parmanently_function
elif self.function_name == "remove_employee_parmanently_function":
final_function = self.remove_employee_parmanently_function
else:
final_function = self.patient_joins_doctor_function

[Link], size_hint, pos_hint = final_function()


[Link].size_hint = size_hint
[Link].pos_hint = pos_hint
self.add_widget([Link])
if (self.function_name == "show_all_patient_function") or
(self.function_name == "patient_joins_doctor_function"):
self.previous_button = Button()
self.previous_button.font_size = 18
self.previous_button.color = (1, 1, 1, 1)
self.previous_button.italic = True
self.previous_button.background_color = (1,1,1,0)
self.previous_button.size_hint = (0, 0)
self.previous_button.pos_hint = {"x":0.05, "top": 0.14}
self.add_widget(self.previous_button)
self.previous_button.bind(on_release = lambda x:
self.next_button_function(function_name), on_press = lambda x:
self.add_Holder_counter(-1))

self.next_button = Button(text = "Next")


self.next_button.font_size = 18
self.next_button.color = (1, 1, 1, 1)
self.next_button.italic = True
self.next_button.background_color = (0/255, 153/255, 204/255, 1)
self.next_button.size_hint = (0.1,0.05)
self.next_button.pos_hint = {"x":0.85, "top": 0.14}
self.add_widget(self.next_button)
self.next_button.bind(on_release = lambda x:
self.next_button_function(function_name))
[Link] += 1

def next_button_function(self,function_name):
self.remove_widget(self.previous_button)
self.remove_widget(self.next_button)

if self.function_name == "total_earning_function":
final_function = self.total_earning_function
elif self.function_name == "add_employee_function":
final_function = self.add_employee_function
elif self.function_name == "see_my_employee_function":
final_function = self.see_my_employee_function
elif self.function_name == "remove_employee_function":
final_function = self.remove_employee_function
elif self.function_name == "show_all_doctor_function":
final_function = self.show_all_doctor_function
elif self.function_name == "show_all_patient_function":
final_function = self.show_all_patient_function
elif self.function_name == "show_all_employee_function":
final_function = self.show_all_employee_function
elif self.function_name == "remove_doctor_parmanently_function":
final_function = self.remove_doctor_parmanently_function
elif self.function_name == "remove_patient_parmanently_function":
final_function = self.remove_patient_parmanently_function
elif self.function_name == "remove_employee_parmanently_function":
final_function = self.remove_employee_parmanently_function
else:
final_function = self.patient_joins_doctor_function

self.remove_widget(self.info_grid)
[Link], size_hint, pos_hint = final_function()
[Link].size_hint = size_hint
[Link].pos_hint = pos_hint
self.add_widget([Link])
if (self.function_name == "show_all_patient_function") or
(self.function_name == "patient_joins_doctor_function"):
if [Link] != 0:
self.previous_button = Button(text = "Previous")
self.previous_button.font_size = 18
self.previous_button.color = (1, 1, 1, 1)
self.previous_button.italic = True
self.previous_button.background_color = (0/255, 153/255,
204/255, 1)
self.previous_button.size_hint = (0.1,0.05)
self.previous_button.pos_hint = {"x":0.05, "top": 0.14}
self.add_widget(self.previous_button)
self.previous_button.bind(on_release = lambda x:
self.next_button_function(function_name), on_press = lambda x:
self.add_Holder_counter(-1))

if [Link] != -1:
self.next_button = Button(text = "Next")
self.next_button.font_size = 18
self.next_button.color = (1, 1, 1, 1)
self.next_button.italic = True
self.next_button.background_color = (0/255, 153/255, 204/255, 1)
self.next_button.size_hint = (0.1,0.05)
self.next_button.pos_hint = {"x":0.85, "top": 0.14}
self.add_widget(self.next_button)
self.next_button.bind(on_release = lambda x:
self.next_button_function(function_name), on_press = lambda x :
self.add_Holder_counter(1))

def add_Holder_counter(self,add_int):
if [Link] == -1:
[Link] = Holder.pre_counter
[Link] += add_int

def find_my_username(self):
return [Link]

def go_back(self, instance):


for screen in [Link]:
if [Link] == "AdminDisplayFunction":
[Link](screen)
[Link] = SlideTransition(direction = "right")
[Link] = "AdminFunctions"
[Link] = 0

def total_earning_function(self):
total_earning_list = admin.total_earning(True)
earned_from_employee = total_earning_list[0]
earned_from_patient = total_earning_list[1]
fixed_cost_of_hospital = total_earning_list[2]
employee_pre_salary = total_earning_list[3]
given_to_employees = total_earning_list[4]
initial_earning = total_earning_list[5]

self.info_grid = GridLayout()
self.info_grid.cols = 2
size_hint = 0.6, 0.5
pos_hint = {"x": 0.2, "top": 0.715}

self.label1 = Label(text = "Earned From Employee", color = (0,0,0,1),


font_size = 16)
self.info_grid.add_widget(self.label1)
self.label2 = Label(text = "+" + str(earned_from_employee), color =
(0,0,0,1), font_size = 16)
self.info_grid.add_widget(self.label2)
self.label3 = Label(text = "Earned From Patient", color = (0,0,0,1),
font_size = 16)
self.info_grid.add_widget(self.label3)
self.label4 = Label(text = "+" + str(earned_from_patient), color =
(0,0,0,1), font_size = 16)
self.info_grid.add_widget(self.label4)
self.label5 = Label(text = "Fixed Cost of Hospital", color = (0,0,0,1),
font_size = 16)
self.info_grid.add_widget(self.label5)
self.label6 = Label(text = "-" + str(fixed_cost_of_hospital), color =
(0,0,0,1), font_size = 16)
self.info_grid.add_widget(self.label6)
self.label7 = Label(text = "Employee_pre_salary", color = (0,0,0,1),
font_size = 16)
self.info_grid.add_widget(self.label7)
self.label8 = Label(text = "-" + str(employee_pre_salary), color =
(0,0,0,1), font_size = 16)
self.info_grid.add_widget(self.label8)
self.label9 = Label(text = "Given to Employees", color = (0,0,0,1),
font_size = 16)
self.info_grid.add_widget(self.label9)
self.label10 = Label(text = "-" + str(given_to_employees), color =
(0,0,0,1), font_size = 16)
self.info_grid.add_widget(self.label10)
self.label11 = Label(text = "Final Earning", color = (0,0,0,1),
font_size = 16)
self.info_grid.add_widget(self.label11)
self.label12 = Label(text = str(initial_earning), color = (0,0,0,1),
font_size = 16)
self.info_grid.add_widget(self.label12)

return (self.info_grid, size_hint, pos_hint)

def add_employee_function(self):
def current_function():
try:
admin.add_employee(self.employee_username.text, True)
except:
show_add_employee_popup()
self.employee_username.text = ""

def show_add_employee_popup():
popup_layout = FloatLayout()
first_line = Label(text = "Sorry, Something went Wrong :(",
size_hint= (0.6, 0.2), pos_hint= {"x": 0.2, "top":0.9})
popup_layout.add_widget(first_line)
second_line = Label(text="Invalid Username", size_hint= (0.6, 0.2),
pos_hint= {"x": 0.21, "top":0.5})
popup_layout.add_widget(second_line)
popup_window = Popup(title = "Add Employee Error", content =
popup_layout, size_hint = (0.6, 0.3))
popup_window.open()

self.info_grid = GridLayout()
self.info_grid.cols = 1
size_hint = 0.6, 0.2
pos_hint = {"x": 0.2, "top": 0.6}

[Link] = Label(text = "Enter the Employee Username You Want to


Add", color = (0,0,0,1), font_size = 16)
self.info_grid.add_widget([Link])
self.employee_username = TextInput(multiline = False)
self.info_grid.add_widget(self.employee_username)

[Link] = Button(text = "Submit")


[Link].font_size = 18
[Link] = (1, 1, 1, 1)
[Link] = True
[Link].background_color = (0/255, 153/255, 204/255, 1)
[Link].size_hint = (0.3,0.08)
[Link].pos_hint = {"x":0.36, "top": 0.175}
self.add_widget([Link])
[Link](on_release = lambda x: current_function())

return (self.info_grid, size_hint, pos_hint)

def see_my_employee_function(self):
self.info_grid = GridLayout()
self.info_grid.cols = 6
pos_hint = {"x": 0.05, "top": 0.75}

employee_infos = admin.see_my_employee(True)
if len(employee_infos) > 7:
size_hint = 0.9, 0.6
elif len(employee_infos) > 3:
size_hint = 0.9, 0.45
else:
size_hint = 0.9, 0.2

self.username_topic = Button(text = "Username", font_size = 15, color =


(1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.username_topic)
self.fullname_topic = Button(text = "Fullname", font_size = 15, color =
(1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.fullname_topic)
self.email_topic = Button(text = "Email", font_size = 15, color =
(1,1,1,1), background_color = (0/255, 153/255, 204/255, 1), size_hint_x=None,
width=200)
self.info_grid.add_widget(self.email_topic)
self.date_of_birth_topic = Button(text = "Date of Birth", font_size =
15, color = (1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.date_of_birth_topic)
self.work_topic = Button(text = "Work", font_size = 15, color =
(1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.work_topic)
self.salary_topic = Button(text = "Salary", font_size = 15, color =
(1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.salary_topic)

for employee in employee_infos:


self.username_info = Label(text = str(employee[0]), font_size = 12,
color = (0,0,0,1))
self.info_grid.add_widget(self.username_info)
self.fullname_info = Label(text = str(employee[1]), font_size = 12,
color = (0,0,0,1))
self.info_grid.add_widget(self.fullname_info)
self.email_info = Label(text = str(employee[2]), font_size = 12,
color = (0,0,0,1), size_hint_x=None, width=200)
self.info_grid.add_widget(self.email_info)
self.date_of_birth_info = Label(text = str(employee[3]), font_size =
12, color = (0,0,0,1))
self.info_grid.add_widget(self.date_of_birth_info)
self.work_info = Label(text = str(employee[4]), font_size = 12,
color = (0,0,0,1))
self.info_grid.add_widget(self.work_info)
self.salary_info = Label(text = str(employee[5]), font_size = 12,
color = (0,0,0,1))
self.info_grid.add_widget(self.salary_info)

return (self.info_grid, size_hint, pos_hint)

def remove_employee_function(self):
def current_function():
try:
admin.remove_employee(self.employee_username.text, True)
except:
show_remove_employee_popup()
self.employee_username.text = ""

def show_remove_employee_popup():
popup_layout = FloatLayout()
first_line = Label(text = "Sorry, Something went Wrong :(",
size_hint= (0.6, 0.2), pos_hint= {"x": 0.2, "top":0.9})
popup_layout.add_widget(first_line)
second_line = Label(text="Invalid Username", size_hint= (0.6, 0.2),
pos_hint= {"x": 0.21, "top":0.5})
popup_layout.add_widget(second_line)
popup_window = Popup(title = "Remove Employee Error", content =
popup_layout, size_hint = (0.6, 0.3))
popup_window.open()

self.info_grid = GridLayout()
self.info_grid.cols = 1
size_hint = 0.6, 0.2
pos_hint = {"x": 0.2, "top": 0.6}

[Link] = Label(text = "Enter the Employee Username You Want to


Remove", color = (0,0,0,1), font_size = 16)
self.info_grid.add_widget([Link])
self.employee_username = TextInput(multiline = False)
self.info_grid.add_widget(self.employee_username)

[Link] = Button(text = "Submit")


[Link].font_size = 18
[Link] = (1, 1, 1, 1)
[Link] = True
[Link].background_color = (0/255, 153/255, 204/255, 1)
[Link].size_hint = (0.3,0.08)
[Link].pos_hint = {"x":0.36, "top": 0.175}
self.add_widget([Link])
[Link](on_release = lambda x: current_function())

return (self.info_grid, size_hint, pos_hint)

def show_all_doctor_function(self):
self.info_grid = GridLayout()
self.info_grid.cols = 7
pos_hint = {"x": 0.05, "top": 0.85}

user_infos = admin.show_all_doctor(True)
if len(user_infos) > 15:
size_hint = 0.9, 0.8
elif len(user_infos) > 8:
size_hint = 0.9, 0.5
else:
size_hint = 0.9, 0.3

self.username_topic = Button(text = "Username", font_size = 14, color =


(1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.username_topic)
self.fullname_topic = Button(text = "Fullname", font_size = 14, color =
(1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.fullname_topic)
self.email_topic = Button(text = "Email", font_size = 14, color =
(1,1,1,1), background_color = (0/255, 153/255, 204/255, 1), size_hint_x=None,
width=200)
self.info_grid.add_widget(self.email_topic)
self.date_of_birth_topic = Button(text = "Date of Birth", font_size =
14, color = (1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.date_of_birth_topic)
self.specialty_topic = Button(text = "Specialty", font_size = 14, color
= (1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.specialty_topic)
self.price_topic = Button(text = "Price", font_size = 14, color =
(1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.price_topic)
self.total_earned_topic = Button(text = "Total Earned", font_size = 14,
color = (1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.total_earned_topic)

for user in user_infos:


self.username_info = Label(text = str(user[0]), font_size = 12,
color = (0,0,0,1))
self.info_grid.add_widget(self.username_info)
self.fullname_info = Label(text = str(user[1]), font_size = 12,
color = (0,0,0,1))
self.info_grid.add_widget(self.fullname_info)
self.email_info = Label(text = str(user[2]), font_size = 12, color =
(0,0,0,1), size_hint_x=None, width=200)
self.info_grid.add_widget(self.email_info)
self.date_of_birth_info = Label(text = str(user[3]), font_size = 12,
color = (0,0,0,1))
self.info_grid.add_widget(self.date_of_birth_info)
self.specialty_info = Label(text = str(user[4]), font_size = 12,
color = (0,0,0,1))
self.info_grid.add_widget(self.specialty_info)
self.price_info = Label(text = str(user[5]), font_size = 12, color =
(0,0,0,1))
self.info_grid.add_widget(self.price_info)
self.total_earned_info = Label(text = str(user[6]), font_size = 12,
color = (0,0,0,1))
self.info_grid.add_widget(self.total_earned_info)

return (self.info_grid, size_hint, pos_hint)

def show_all_patient_function(self):
self.info_grid = GridLayout()
self.info_grid.cols = 8
pos_hint = {"x": 0.05, "top": 0.85}
counter = [Link]

old_user_infos = admin.show_all_patient(True)
user_infos = old_user_infos[counter*15 : counter*15 + 15]
if len(old_user_infos) < (counter*15+15):
Holder.pre_counter = [Link]
[Link] = -1
size_hint = 0.9,0.7
if len(user_infos) < 5:
size_hint = 0.9, 0.35

self.username_topic = Button(text = "Username", font_size = 14, color =


(1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.username_topic)
self.fullname_topic = Button(text = "Fullname", font_size = 14, color =
(1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.fullname_topic)
self.email_topic = Button(text = "Email", font_size = 14, color =
(1,1,1,1), background_color = (0/255, 153/255, 204/255, 1), size_hint_x=None,
width=200)
self.info_grid.add_widget(self.email_topic)
self.date_of_birth_topic = Button(text = "D O B", font_size = 14, color
= (1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.date_of_birth_topic)
self.problem_topic = Button(text = "Problem", font_size = 14, color =
(1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.problem_topic)
self.requested_doctor_username_topic = Button(text = "Requested",
font_size = 14, color = (1,1,1,1), background_color = (0/255, 153/255, 204/255,
1))
self.info_grid.add_widget(self.requested_doctor_username_topic)
self.approved_doctor_username_topic = Button(text = "Approved",
font_size = 14, color = (1,1,1,1), background_color = (0/255, 153/255, 204/255,
1))
self.info_grid.add_widget(self.approved_doctor_username_topic)
self.total_cost_topic = Button(text = "Cost", font_size = 14, color =
(1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.total_cost_topic)

for user in user_infos:


self.username_info = Label(text = str(user[0]), font_size = 12,
color = (0,0,0,1))
self.info_grid.add_widget(self.username_info)
self.fullname_info = Label(text = str(user[1]), font_size = 12,
color = (0,0,0,1))
self.info_grid.add_widget(self.fullname_info)
self.email_info = Label(text = str(user[2]), font_size = 12, color =
(0,0,0,1), size_hint_x=None, width=200)
self.info_grid.add_widget(self.email_info)
self.date_of_birth_info = Label(text = str(user[3]), font_size = 12,
color = (0,0,0,1))
self.info_grid.add_widget(self.date_of_birth_info)
self.problem_info = Label(text = str(user[4]), font_size = 12, color
= (0,0,0,1))
self.info_grid.add_widget(self.problem_info)
self.requested_doctor_username_info = Label(text = str(user[5]),
font_size = 12, color = (0,0,0,1))
self.info_grid.add_widget(self.requested_doctor_username_info)
self.approved_doctor_username_info = Label(text = str(user[6]),
font_size = 12, color = (0,0,0,1))
self.info_grid.add_widget(self.approved_doctor_username_info)
self.total_cost_info = Label(text = str(user[7]), font_size = 12,
color = (0,0,0,1))
self.info_grid.add_widget(self.total_cost_info)

return (self.info_grid, size_hint, pos_hint)

def show_all_employee_function(self):
self.info_grid = GridLayout()
self.info_grid.cols = 8
pos_hint = {"x": 0.05, "top": 0.85}

user_infos = admin.show_all_employee(True)
if len(user_infos) > 20:
size_hint = 0.9, 8
elif len(user_infos) > 10:
size_hint = 0.9, 0.6
else:
size_hint = 0.9, 0.35

self.username_topic = Button(text = "Username", font_size = 14, color =


(1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.username_topic)
self.fullname_topic = Button(text = "Fullname", font_size = 14, color =
(1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.fullname_topic)
self.email_topic = Button(text = "Email", font_size = 14, color =
(1,1,1,1), background_color = (0/255, 153/255, 204/255, 1), size_hint_x=None,
width=200)
self.info_grid.add_widget(self.email_topic)
self.date_of_birth_topic = Button(text = "D O B", font_size = 14, color
= (1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.date_of_birth_topic)
self.work_topic = Button(text = "Work", font_size = 14, color =
(1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.work_topic)
self.work_of_doctors_topic = Button(text = "W O D", font_size = 14,
color = (1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.work_of_doctors_topic)
self.salary_topic = Button(text = "Salary", font_size = 14, color =
(1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.salary_topic)
self.total_earned_topic = Button(text = "Earned", font_size = 14, color
= (1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.total_earned_topic)

for user in user_infos:


self.username_info = Label(text = str(user[0]), font_size = 12,
color = (0,0,0,1))
self.info_grid.add_widget(self.username_info)
self.fullname_info = Label(text = str(user[1]), font_size = 12,
color = (0,0,0,1))
self.info_grid.add_widget(self.fullname_info)
self.email_info = Label(text = str(user[2]), font_size = 12, color =
(0,0,0,1), size_hint_x=None, width=200)
self.info_grid.add_widget(self.email_info)
self.date_of_birth_info = Label(text = str(user[3]), font_size = 12,
color = (0,0,0,1))
self.info_grid.add_widget(self.date_of_birth_info)
self.work_info = Label(text = str(user[4]), font_size = 12, color =
(0,0,0,1))
self.info_grid.add_widget(self.work_info)
self.work_of_doctors_info = Label(text = str(user[5]), font_size =
12, color = (0,0,0,1))
self.info_grid.add_widget(self.work_of_doctors_info)
self.salary_info = Label(text = str(user[6]), font_size = 12, color
= (0,0,0,1))
self.info_grid.add_widget(self.salary_info)
self.total_earned_info = Label(text = str(user[7]), font_size = 12,
color = (0,0,0,1))
self.info_grid.add_widget(self.total_earned_info)
return (self.info_grid, size_hint, pos_hint)

def remove_doctor_parmanently_function(self):
def current_function():
if self.final_decision_answer.text == "yes":
final_decision = True
else:
final_decision = False

if self.doctor_username.text not in admin.all_doctor_username(True):


show_remove_doctor_parmanently_popup()
else:
admin.remove_doctor_parmanently(self.doctor_username.text, True,
final_decision)

self.doctor_username.text = ""
self.final_decision_answer.text = ""

def show_remove_doctor_parmanently_popup():
popup_layout = FloatLayout()
first_line = Label(text = "Sorry, Something went Wrong :(",
size_hint= (0.6, 0.2), pos_hint= {"x": 0.2, "top":0.9})
popup_layout.add_widget(first_line)
second_line = Label(text="Invalid Username", size_hint= (0.6, 0.2),
pos_hint= {"x": 0.21, "top":0.5})
popup_layout.add_widget(second_line)
popup_window = Popup(title = "Remove Doctor Parmanently Error",
content = popup_layout, size_hint = (0.6, 0.3))
popup_window.open()

self.info_grid = GridLayout()
self.info_grid.cols = 2
size_hint = 0.6, 0.2
pos_hint = {"x": 0.2, "top": 0.65}

[Link] = Label(text = "Doctor Username", color = (0,0,0,1),


font_size = 16)
self.info_grid.add_widget([Link])
self.doctor_username = TextInput(multiline = False)
self.info_grid.add_widget(self.doctor_username)
self.final_decision_question = Label(text = "Are You Sure? (yes/no)",
color = (0,0,0,1), font_size = 16)
self.info_grid.add_widget(self.final_decision_question)
self.final_decision_answer = TextInput(multiline = False)
self.info_grid.add_widget(self.final_decision_answer)

[Link] = Button(text = "Submit")


[Link].font_size = 18
[Link] = (1, 1, 1, 1)
[Link] = True
[Link].background_color = (0/255, 153/255, 204/255, 1)
[Link].size_hint = (0.3,0.08)
[Link].pos_hint = {"x":0.36, "top": 0.175}
self.add_widget([Link])
[Link](on_release = lambda x: current_function())

return (self.info_grid, size_hint, pos_hint)

def remove_patient_parmanently_function(self):
def current_function():
if self.final_decision_answer.text == "yes":
final_decision = True
else:
final_decision = False

if self.patient_username.text not in
admin.all_patient_username(True):
show_remove_patient_parmanently_popup()
else:
admin.remove_patient_parmanently(self.patient_username.text,
True, final_decision)

self.patient_username.text = ""
self.final_decision_answer.text = ""

def show_remove_patient_parmanently_popup():
popup_layout = FloatLayout()
first_line = Label(text = "Sorry, Something went Wrong :(",
size_hint= (0.6, 0.2), pos_hint= {"x": 0.2, "top":0.9})
popup_layout.add_widget(first_line)
second_line = Label(text="Invalid Username", size_hint= (0.6, 0.2),
pos_hint= {"x": 0.21, "top":0.5})
popup_layout.add_widget(second_line)
popup_window = Popup(title = "Remove Patient Parmanently Error",
content = popup_layout, size_hint = (0.6, 0.3))
popup_window.open()

self.info_grid = GridLayout()
self.info_grid.cols = 2
size_hint = 0.6, 0.2
pos_hint = {"x": 0.2, "top": 0.65}

[Link] = Label(text = "Patient Username", color = (0,0,0,1),


font_size = 16)
self.info_grid.add_widget([Link])
self.patient_username = TextInput(multiline = False)
self.info_grid.add_widget(self.patient_username)
self.final_decision_question = Label(text = "Are You Sure? (yes/no)",
color = (0,0,0,1), font_size = 16)
self.info_grid.add_widget(self.final_decision_question)
self.final_decision_answer = TextInput(multiline = False)
self.info_grid.add_widget(self.final_decision_answer)

[Link] = Button(text = "Submit")


[Link].font_size = 18
[Link] = (1, 1, 1, 1)
[Link] = True
[Link].background_color = (0/255, 153/255, 204/255, 1)
[Link].size_hint = (0.3,0.08)
[Link].pos_hint = {"x":0.36, "top": 0.175}
self.add_widget([Link])
[Link](on_release = lambda x: current_function())

return (self.info_grid, size_hint, pos_hint)

def remove_employee_parmanently_function(self):
def current_function():
if self.final_decision_answer.text == "yes":
final_decision = True
else:
final_decision = False

if self.employee_username.text not in
admin.all_employee_username(True):
show_remove_employee_parmanently_popup()
else:
admin.remove_employee_parmanently(self.employee_username.text,
True, final_decision)

self.employee_username.text = ""
self.final_decision_answer.text = ""

def show_remove_employee_parmanently_popup():
popup_layout = FloatLayout()
first_line = Label(text = "Sorry, Something went Wrong :(",
size_hint= (0.6, 0.2), pos_hint= {"x": 0.2, "top":0.9})
popup_layout.add_widget(first_line)
second_line = Label(text="Invalid Username", size_hint= (0.6, 0.2),
pos_hint= {"x": 0.21, "top":0.5})
popup_layout.add_widget(second_line)
popup_window = Popup(title = "Remove Employee Parmanently Error",
content = popup_layout, size_hint = (0.6, 0.3))
popup_window.open()

self.info_grid = GridLayout()
self.info_grid.cols = 2
size_hint = 0.6, 0.2
pos_hint = {"x": 0.2, "top": 0.65}

[Link] = Label(text = "Employee Username", color = (0,0,0,1),


font_size = 16)
self.info_grid.add_widget([Link])
self.employee_username = TextInput(multiline = False)
self.info_grid.add_widget(self.employee_username)
self.final_decision_question = Label(text = "Are You Sure? (yes/no)",
color = (0,0,0,1), font_size = 16)
self.info_grid.add_widget(self.final_decision_question)
self.final_decision_answer = TextInput(multiline = False)
self.info_grid.add_widget(self.final_decision_answer)

[Link] = Button(text = "Submit")


[Link].font_size = 18
[Link] = (1, 1, 1, 1)
[Link] = True
[Link].background_color = (0/255, 153/255, 204/255, 1)
[Link].size_hint = (0.3,0.08)
[Link].pos_hint = {"x":0.36, "top": 0.175}
self.add_widget([Link])
[Link](on_release = lambda x: current_function())

return (self.info_grid, size_hint, pos_hint)

def patient_joins_doctor_function(self):
self.info_grid = GridLayout()
self.info_grid.cols = 6
pos_hint = {"x": 0.05, "top": 0.85}
counter = [Link]

old_user_infos = admin.patient_joins_doctor(True)
user_infos = old_user_infos[counter*15 : counter*15 + 15]
if len(old_user_infos) < (counter*15+15):
Holder.pre_counter = [Link]
[Link] = -1
size_hint = 0.9,0.7
if len(user_infos) < 5:
size_hint = 0.9, 0.35

self.username_topic = Button(text = "Username", font_size = 14, color =


(1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.username_topic)
self.fullname_topic = Button(text = "Fullname", font_size = 14, color =
(1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.fullname_topic)
self.problem_topic = Button(text = "Problem", font_size = 14, color =
(1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.problem_topic)
self.appointment_topic = Button(text = "Appoint Date", font_size = 14,
color = (1,1,1,1), background_color = (0/255, 153/255, 204/255, 1),
size_hint_x=None, width=200)
self.info_grid.add_widget(self.appointment_topic)
self.dusername_topic = Button(text = "D Username", font_size = 14, color
= (1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.dusername_topic)
self.dfullname_topic = Button(text = "D Fullname", font_size = 14, color
= (1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.dfullname_topic)

for user in user_infos:


self.username_info = Label(text = str(user[0]), font_size = 12,
color = (0,0,0,1))
self.info_grid.add_widget(self.username_info)
self.fullname_info = Label(text = str(user[1]), font_size = 12,
color = (0,0,0,1))
self.info_grid.add_widget(self.fullname_info)
self.problem_info = Label(text = str(user[3]), font_size = 12, color
= (0,0,0,1))
self.info_grid.add_widget(self.problem_info)
self.appoint_info = Label(text = str(user[4]), font_size = 12, color
= (0,0,0,1), size_hint_x=None, width=200)
self.info_grid.add_widget(self.appoint_info)
self.dusername_info = Label(text = str(user[5]), font_size = 12,
color = (0,0,0,1))
self.info_grid.add_widget(self.dusername_info)
self.dfullname_info = Label(text = str(user[6]), font_size = 12,
color = (0,0,0,1))
self.info_grid.add_widget(self.dfullname_info)
return (self.info_grid, size_hint, pos_hint)

# Doctor Functions
class DoctorFunctions(Screen):
def __init__(self, **kwargs):
super().__init__(**kwargs)

[Link] = self.find_my_username()
[Link] = "doctor"
with [Link]:
Color(1, 1, 1,1,mode="rgba")
Rectangle(pos = [Link], size = (800,600))
Color(51/255, 153/255, 255/255,1,mode="rgba")
Line(points = ((0, 580),(1000, 580)), width = 50)
Line(points = ((0, 0),(1000, 0)), width = 35)
[Link] = Label(text="Doctor Functions", font_size=40,
color=(1,1,1,1))
[Link].pos_hint= {"x":0.05, "top": 1.45}
self.add_widget([Link])

[Link] = Button(background_normal="resources/short_logo.png",
background_down="resources/short_logo.png")
[Link].size_hint = (None, None)
[Link] = 120
[Link] = 90
[Link] = (0,0,0,1)
[Link].pos_hint = {"x": 0.1, "top": 1.02}
self.add_widget([Link])

self.close_button = Button(background_normal="resources/[Link]",
background_down="resources/close_down.png")
self.close_button.size_hint = (None, None)
self.close_button.width = 60
self.close_button.height = 60
self.close_button.color = (0,0,0,1)
self.close_button.pos_hint = {"x": 0.85, "top": 0.99}
self.add_widget(self.close_button)
self.close_button.bind(on_release = self.go_back)

[Link] = Label(text="Built with Python, PostgreSQL, Psycopg2, and


Kivy", font_size=13, color=(1,1,1,1))
[Link].pos_hint = {"x":-0.27, "top": 0.525}
self.add_widget([Link])

[Link]= Button(text="About Creator: Ahammad Shawki 8",


font_size=13, color=(1,1,1,1))
[Link].pos_hint = {"x":0.7, "top": 0.05}
[Link].size_hint = (0.28,0.05)
[Link].background_color = (1,1,1,0)
self.add_widget([Link])
[Link](on_press = go_to_website)

self.info_grid = GridLayout()
self.info_grid.cols = 1
self.info_grid.pos_hint = {"x": 0.2, "top": 0.82}
self.info_grid.size_hint = 0.6, 0.7

self.salary_button = Button(text="Salary", background_color = (0/255,


153/255, 204/255, 1), color= (1,1,1,1), font_size = 14)
self.info_grid.add_widget(self.salary_button)
self.salary_button.bind(on_release = lambda x:
self.set_function("salary_function"))
self.show_all_employee_button = Button(text="Show All Employee",
background_color = (0.75, 0.75, 0.75, 1), color= (1,1,1,1), font_size = 14)
self.info_grid.add_widget(self.show_all_employee_button)
self.show_all_employee_button.bind(on_release = lambda x:
self.set_function("show_all_employee_function"))
self.add_employee_button = Button(text="Add Employee", background_color
= (0/255, 153/255, 204/255, 1), color= (1,1,1,1), font_size = 14)
self.info_grid.add_widget(self.add_employee_button)
self.add_employee_button.bind(on_release = lambda x:
self.set_function("add_employee_function"))
self.see_my_employee_button = Button(text="See My Employee",
background_color = (0.75, 0.75, 0.75, 1), color= (1,1,1,1), font_size = 14)
self.info_grid.add_widget(self.see_my_employee_button)
self.see_my_employee_button.bind(on_release = lambda x:
self.set_function("see_my_employee_function"))
self.remove_employee_button = Button(text="Remove Employee",
background_color = (0/255, 153/255, 204/255, 1), color= (1,1,1,1), font_size =
14)
self.info_grid.add_widget(self.remove_employee_button)
self.remove_employee_button.bind(on_release = lambda x:
self.set_function("remove_employee_function"))
self.see_all_requested_patient_button = Button(text="See All Requested
Patient", background_color = (0.75, 0.75, 0.75, 1), color= (1,1,1,1), font_size
= 14)
self.info_grid.add_widget(self.see_all_requested_patient_button)
self.see_all_requested_patient_button.bind(on_release = lambda x:
self.set_function("see_all_requested_patient_function"))
self.see_all_patients_of_my_specialty_button = Button(text="See All
Patients of My Specialty", background_color = (0/255, 153/255, 204/255, 1),
color= (1,1,1,1), font_size = 14)
self.info_grid.add_widget(self.see_all_patients_of_my_specialty_button)
self.see_all_patients_of_my_specialty_button.bind(on_release = lambda x:
self.set_function("see_all_patients_of_my_specialty_function"))
self.see_my_patient_button = Button(text="See My Patient",
background_color = (0.75, 0.75, 0.75, 1), color= (1,1,1,1), font_size = 14)
self.info_grid.add_widget(self.see_my_patient_button)
self.see_my_patient_button.bind(on_release = lambda x:
self.set_function("see_my_patient_function"))
self.see_patients_report_button = Button(text="See Patients Report",
background_color = (0/255, 153/255, 204/255, 1), color= (1,1,1,1), font_size =
14)
self.info_grid.add_widget(self.see_patients_report_button)
self.see_patients_report_button.bind(on_release = lambda x:
self.set_function("see_patients_report_function"))
self.remove_patient_button = Button(text="Remove Patient",
background_color = (0.75, 0.75, 0.75, 1), color= (1,1,1,1), font_size = 14)
self.info_grid.add_widget(self.remove_patient_button)
self.remove_patient_button.bind(on_release = lambda x:
self.set_function("remove_patient_function"))

self.add_widget(self.info_grid)

def find_my_username(self):
return [Link]

def go_back(self, instance):


for screen in [Link]:
if [Link] == "DoctorFunctions":
[Link](screen)
[Link] = SlideTransition(direction = "right")
[Link] = "DoctorAfterLogin"

def set_function(self, function_name):


sm.add_widget(DoctorDisplayFunction(function_name,
name="DoctorDisplayFunction"))
[Link] = SlideTransition(direction = "left")
[Link] = "DoctorDisplayFunction"

class DoctorDisplayFunction(Screen):
def __init__(self, function_name, **kwargs):
super().__init__(**kwargs)

[Link] = self.find_my_username()
[Link] = "doctor"
self.function_name = function_name
with [Link]:
Color(1, 1, 1,1,mode="rgba")
Rectangle(pos = [Link], size = (800,600))
Color(51/255, 153/255, 255/255,1,mode="rgba")
Line(points = ((0, 580),(1000, 580)), width = 50)
Line(points = ((0, 0),(1000, 0)), width = 35)
[Link] = Label(text="Doctor Functions", font_size=40,
color=(1,1,1,1))
[Link].pos_hint= {"x":0.05, "top": 1.45}
self.add_widget([Link])

[Link] = Button(background_normal="resources/short_logo.png",
background_down="resources/short_logo.png")
[Link].size_hint = (None, None)
[Link] = 120
[Link] = 90
[Link] = (0,0,0,1)
[Link].pos_hint = {"x": 0.1, "top": 1.02}
self.add_widget([Link])

self.close_button = Button(background_normal="resources/[Link]",
background_down="resources/close_down.png")
self.close_button.size_hint = (None, None)
self.close_button.width = 60
self.close_button.height = 60
self.close_button.color = (0,0,0,1)
self.close_button.pos_hint = {"x": 0.85, "top": 0.99}
self.add_widget(self.close_button)
self.close_button.bind(on_release = self.go_back)

[Link] = Label(text="Built with Python, PostgreSQL, Psycopg2, and


Kivy", font_size=13, color=(1,1,1,1))
[Link].pos_hint = {"x":-0.27, "top": 0.525}
self.add_widget([Link])

[Link]= Button(text="About Creator: Ahammad Shawki 8",


font_size=13, color=(1,1,1,1))
[Link].pos_hint = {"x":0.7, "top": 0.05}
[Link].size_hint = (0.28,0.05)
[Link].background_color = (1,1,1,0)
self.add_widget([Link])
[Link](on_press = go_to_website)

if self.function_name == "salary_function":
final_function = self.salary_function
elif self.function_name == "show_all_employee_function":
final_function = self.show_all_employee_function
elif self.function_name == "add_employee_function":
final_function = self.add_employee_function
elif self.function_name == "see_my_employee_function":
final_function = self.see_my_employee_function
elif self.function_name == "remove_employee_function":
final_function = self.remove_employee_function
elif self.function_name == "see_all_requested_patient_function":
final_function = self.see_all_requested_patient_function
elif self.function_name == "see_all_patients_of_my_specialty_function":
final_function = self.see_all_patients_of_my_specialty_function
elif self.function_name == "see_my_patient_function":
final_function = self.see_my_patient_function
elif self.function_name == "see_patients_report_function":
final_function = self.see_patients_report_function
else:
final_function = self.remove_patient_function

[Link], size_hint, pos_hint = final_function()


[Link].size_hint = size_hint
[Link].pos_hint = pos_hint
self.add_widget([Link])

def find_my_username(self):
return [Link]

def go_back(self, instance):


for screen in [Link]:
if [Link] == "DoctorDisplayFunction":
[Link](screen)
[Link] = SlideTransition(direction = "right")
[Link] = "DoctorFunctions"
[Link] = 0

def salary_function(self):
total_earning_list = [Link]([Link], True)
total_earning = total_earning_list[0]
total_cost = total_earning_list[1]
nit_salary = total_earning_list[2]

self.info_grid = GridLayout()
self.info_grid.cols = 2
size_hint = 0.6, 0.3
pos_hint = {"x": 0.2, "top": 0.6}

self.label1 = Label(text = "Total Earning", color = (0,0,0,1), font_size


= 16)
self.info_grid.add_widget(self.label1)
self.label2 = Label(text = "+" + str(total_earning), color = (0,0,0,1),
font_size = 16)
self.info_grid.add_widget(self.label2)
self.label3 = Label(text = "Total Cost", color = (0,0,0,1), font_size =
16)
self.info_grid.add_widget(self.label3)
self.label4 = Label(text = "-" + str(total_cost), color = (0,0,0,1),
font_size = 16)
self.info_grid.add_widget(self.label4)
self.label5 = Label(text = "Nit Salary", color = (0,0,0,1), font_size =
16)
self.info_grid.add_widget(self.label5)
self.label6 = Label(text = str(nit_salary), color = (0,0,0,1), font_size
= 16)
self.info_grid.add_widget(self.label6)

return (self.info_grid, size_hint, pos_hint)

def show_all_employee_function(self):
self.info_grid = GridLayout()
self.info_grid.cols = 6
pos_hint = {"x": 0.05, "top": 0.85}
user_infos = doctor.show_all_employee(True)
if len(user_infos) > 20:
size_hint = 0.9, 8
elif len(user_infos) > 10:
size_hint = 0.9, 0.6
else:
size_hint = 0.9, 0.35

self.username_topic = Button(text = "Username", font_size = 14, color =


(1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.username_topic)
self.fullname_topic = Button(text = "Fullname", font_size = 14, color =
(1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.fullname_topic)
self.email_topic = Button(text = "Email", font_size = 14, color =
(1,1,1,1), background_color = (0/255, 153/255, 204/255, 1), size_hint_x=None,
width=200)
self.info_grid.add_widget(self.email_topic)
self.date_of_birth_topic = Button(text = "D O B", font_size = 14, color
= (1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.date_of_birth_topic)
self.work_topic = Button(text = "Work", font_size = 14, color =
(1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.work_topic)
self.salary_topic = Button(text = "Salary", font_size = 14, color =
(1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.salary_topic)

for user in user_infos:


self.username_info = Label(text = str(user[0]), font_size = 12,
color = (0,0,0,1))
self.info_grid.add_widget(self.username_info)
self.fullname_info = Label(text = str(user[1]), font_size = 12,
color = (0,0,0,1))
self.info_grid.add_widget(self.fullname_info)
self.email_info = Label(text = str(user[2]), font_size = 12, color =
(0,0,0,1), size_hint_x=None, width=200)
self.info_grid.add_widget(self.email_info)
self.date_of_birth_info = Label(text = str(user[3]), font_size = 12,
color = (0,0,0,1))
self.info_grid.add_widget(self.date_of_birth_info)
self.work_info = Label(text = str(user[4]), font_size = 12, color =
(0,0,0,1))
self.info_grid.add_widget(self.work_info)
self.salary_info = Label(text = str(user[5]), font_size = 12, color
= (0,0,0,1))
self.info_grid.add_widget(self.salary_info)

return (self.info_grid, size_hint, pos_hint)

def add_employee_function(self):
def current_function():
try:
doctor.add_employee([Link],self.employee_username.text,
True)
except:
show_add_employee_popup()
self.employee_username.text = ""

def show_add_employee_popup():
popup_layout = FloatLayout()
first_line = Label(text = "Sorry, Something went Wrong :(",
size_hint= (0.6, 0.2), pos_hint= {"x": 0.2, "top":0.9})
popup_layout.add_widget(first_line)
second_line = Label(text="Invalid Username", size_hint= (0.6, 0.2),
pos_hint= {"x": 0.21, "top":0.5})
popup_layout.add_widget(second_line)
popup_window = Popup(title = "Add Employee Error", content =
popup_layout, size_hint = (0.6, 0.3))
popup_window.open()

self.info_grid = GridLayout()
self.info_grid.cols = 1
size_hint = 0.6, 0.2
pos_hint = {"x": 0.2, "top": 0.6}

[Link] = Label(text = "Enter the Employee Username You Want to


Add", color = (0,0,0,1), font_size = 16)
self.info_grid.add_widget([Link])
self.employee_username = TextInput(multiline = False)
self.info_grid.add_widget(self.employee_username)

[Link] = Button(text = "Submit")


[Link].font_size = 18
[Link] = (1, 1, 1, 1)
[Link] = True
[Link].background_color = (0/255, 153/255, 204/255, 1)
[Link].size_hint = (0.3,0.08)
[Link].pos_hint = {"x":0.36, "top": 0.175}
self.add_widget([Link])
[Link](on_release = lambda x: current_function())

return (self.info_grid, size_hint, pos_hint)

def see_my_employee_function(self):
self.info_grid = GridLayout()
self.info_grid.cols = 6
pos_hint = {"x": 0.05, "top": 0.75}

employee_infos = doctor.see_my_employee([Link],True)
if len(employee_infos) > 7:
size_hint = 0.9, 0.6
elif len(employee_infos) > 3:
size_hint = 0.9, 0.45
else:
size_hint = 0.9, 0.2
self.username_topic = Button(text = "Username", font_size = 15, color =
(1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.username_topic)
self.fullname_topic = Button(text = "Fullname", font_size = 15, color =
(1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.fullname_topic)
self.email_topic = Button(text = "Email", font_size = 15, color =
(1,1,1,1), background_color = (0/255, 153/255, 204/255, 1), size_hint_x=None,
width=200)
self.info_grid.add_widget(self.email_topic)
self.date_of_birth_topic = Button(text = "Date of Birth", font_size =
15, color = (1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.date_of_birth_topic)
self.work_topic = Button(text = "Work", font_size = 15, color =
(1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.work_topic)
self.salary_topic = Button(text = "Salary", font_size = 15, color =
(1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.salary_topic)

for employee in employee_infos:


self.username_info = Label(text = str(employee[0]), font_size = 12,
color = (0,0,0,1))
self.info_grid.add_widget(self.username_info)
self.fullname_info = Label(text = str(employee[1]), font_size = 12,
color = (0,0,0,1))
self.info_grid.add_widget(self.fullname_info)
self.email_info = Label(text = str(employee[2]), font_size = 12,
color = (0,0,0,1), size_hint_x=None, width=200)
self.info_grid.add_widget(self.email_info)
self.date_of_birth_info = Label(text = str(employee[3]), font_size =
12, color = (0,0,0,1))
self.info_grid.add_widget(self.date_of_birth_info)
self.work_info = Label(text = str(employee[4]), font_size = 12,
color = (0,0,0,1))
self.info_grid.add_widget(self.work_info)
self.salary_info = Label(text = str(employee[5]), font_size = 12,
color = (0,0,0,1))
self.info_grid.add_widget(self.salary_info)

return (self.info_grid, size_hint, pos_hint)

def remove_employee_function(self):
def current_function():
try:
doctor.remove_employee([Link],
self.employee_username.text, True)
except:
show_remove_employee_popup()
self.employee_username.text = ""

def show_remove_employee_popup():
popup_layout = FloatLayout()
first_line = Label(text = "Sorry, Something went Wrong :(",
size_hint= (0.6, 0.2), pos_hint= {"x": 0.2, "top":0.9})
popup_layout.add_widget(first_line)
second_line = Label(text="Invalid Username", size_hint= (0.6, 0.2),
pos_hint= {"x": 0.21, "top":0.5})
popup_layout.add_widget(second_line)
popup_window = Popup(title = "Remove Employee Error", content =
popup_layout, size_hint = (0.6, 0.3))
popup_window.open()

self.info_grid = GridLayout()
self.info_grid.cols = 1
size_hint = 0.6, 0.2
pos_hint = {"x": 0.2, "top": 0.6}

[Link] = Label(text = "Enter the Employee Username You Want to


Remove", color = (0,0,0,1), font_size = 16)
self.info_grid.add_widget([Link])
self.employee_username = TextInput(multiline = False)
self.info_grid.add_widget(self.employee_username)

[Link] = Button(text = "Submit")


[Link].font_size = 18
[Link] = (1, 1, 1, 1)
[Link] = True
[Link].background_color = (0/255, 153/255, 204/255, 1)
[Link].size_hint = (0.3,0.08)
[Link].pos_hint = {"x":0.36, "top": 0.175}
self.add_widget([Link])
[Link](on_release = lambda x: current_function())

return (self.info_grid, size_hint, pos_hint)

def see_all_requested_patient_function(self):
self.info_grid = GridLayout()
self.info_grid.cols = 5
pos_hint = {"x": 0.05, "top": 0.75}

patient_infos = doctor.see_all_requested_patient([Link],True)
if len(patient_infos) > 7:
size_hint = 0.9, 0.6
elif len(patient_infos) > 3:
size_hint = 0.9, 0.45
else:
size_hint = 0.9, 0.2

self.username_topic = Button(text = "Username", font_size = 15, color =


(1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.username_topic)
self.fullname_topic = Button(text = "Fullname", font_size = 15, color =
(1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.fullname_topic)
self.email_topic = Button(text = "Email", font_size = 15, color =
(1,1,1,1), background_color = (0/255, 153/255, 204/255, 1), size_hint_x=None,
width=200)
self.info_grid.add_widget(self.email_topic)
self.date_of_birth_topic = Button(text = "Date of Birth", font_size =
15, color = (1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.date_of_birth_topic)
self.problem_topic = Button(text = "Problem", font_size = 15, color =
(1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.problem_topic)

for patient in patient_infos:


self.username_info = Label(text = str(patient[0]), font_size = 12,
color = (0,0,0,1))
self.info_grid.add_widget(self.username_info)
self.fullname_info = Label(text = str(patient[1]), font_size = 12,
color = (0,0,0,1))
self.info_grid.add_widget(self.fullname_info)
self.email_info = Label(text = str(patient[2]), font_size = 12,
color = (0,0,0,1), size_hint_x=None, width=200)
self.info_grid.add_widget(self.email_info)
self.date_of_birth_info = Label(text = str(patient[3]), font_size =
12, color = (0,0,0,1))
self.info_grid.add_widget(self.date_of_birth_info)
self.problem_info = Label(text = str(patient[4]), font_size = 12,
color = (0,0,0,1))
self.info_grid.add_widget(self.problem_info)

return (self.info_grid, size_hint, pos_hint)

def see_all_patients_of_my_specialty_function(self):
self.info_grid = GridLayout()
self.info_grid.cols = 6
pos_hint = {"x": 0.05, "top": 0.75}

patient_infos =
doctor.see_all_patients_of_my_specialty([Link],True)
if len(patient_infos) > 7:
size_hint = 0.9, 0.6
elif len(patient_infos) > 3:
size_hint = 0.9, 0.45
else:
size_hint = 0.9, 0.2

self.username_topic = Button(text = "Username", font_size = 15, color =


(1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.username_topic)
self.fullname_topic = Button(text = "Fullname", font_size = 15, color =
(1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.fullname_topic)
self.email_topic = Button(text = "Email", font_size = 15, color =
(1,1,1,1), background_color = (0/255, 153/255, 204/255, 1), size_hint_x=None,
width=200)
self.info_grid.add_widget(self.email_topic)
self.date_of_birth_topic = Button(text = "Date of Birth", font_size =
15, color = (1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.date_of_birth_topic)
self.requested_topic = Button(text = "Requested", font_size = 15, color
= (1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.requested_topic)
self.approved_topic = Button(text = "Approved", font_size = 15, color =
(1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.approved_topic)

for patient in patient_infos:


self.username_info = Label(text = str(patient[0]), font_size = 12,
color = (0,0,0,1))
self.info_grid.add_widget(self.username_info)
self.fullname_info = Label(text = str(patient[1]), font_size = 12,
color = (0,0,0,1))
self.info_grid.add_widget(self.fullname_info)
self.email_info = Label(text = str(patient[2]), font_size = 12,
color = (0,0,0,1), size_hint_x=None, width=200)
self.info_grid.add_widget(self.email_info)
self.date_of_birth_info = Label(text = str(patient[3]), font_size =
12, color = (0,0,0,1))
self.info_grid.add_widget(self.date_of_birth_info)
self.requested_info = Label(text = str(patient[4]), font_size = 12,
color = (0,0,0,1))
self.info_grid.add_widget(self.requested_info)
self.approved_info = Label(text = str(patient[4]), font_size = 12,
color = (0,0,0,1))
self.info_grid.add_widget(self.approved_info)

return (self.info_grid, size_hint, pos_hint)

def see_my_patient_function(self):
self.info_grid = GridLayout()
self.info_grid.cols = 6
pos_hint = {"x": 0.05, "top": 0.75}

patient_infos = doctor.see_my_patient([Link],True)
if len(patient_infos) > 7:
size_hint = 0.9, 0.6
elif len(patient_infos) > 3:
size_hint = 0.9, 0.45
else:
size_hint = 0.9, 0.2

self.username_topic = Button(text = "Username", font_size = 15, color =


(1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.username_topic)
self.fullname_topic = Button(text = "Fullname", font_size = 15, color =
(1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.fullname_topic)
self.email_topic = Button(text = "Email", font_size = 15, color =
(1,1,1,1), background_color = (0/255, 153/255, 204/255, 1), size_hint_x=None,
width=200)
self.info_grid.add_widget(self.email_topic)
self.date_of_birth_topic = Button(text = "Date of Birth", font_size =
15, color = (1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.date_of_birth_topic)
self.problem_topic = Button(text = "Problem", font_size = 15, color =
(1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.problem_topic)
self.appointment_timestamp_topic = Button(text = "Appoint TS", font_size
= 15, color = (1,1,1,1), background_color = (0/255, 153/255, 204/255, 1),
size_hint_x=None, width=150)
self.info_grid.add_widget(self.appointment_timestamp_topic)

for patient in patient_infos:


self.username_info = Label(text = str(patient[0]), font_size = 12,
color = (0,0,0,1))
self.info_grid.add_widget(self.username_info)
self.fullname_info = Label(text = str(patient[1]), font_size = 12,
color = (0,0,0,1))
self.info_grid.add_widget(self.fullname_info)
self.email_info = Label(text = str(patient[2]), font_size = 12,
color = (0,0,0,1), size_hint_x=None, width=200)
self.info_grid.add_widget(self.email_info)
self.date_of_birth_info = Label(text = str(patient[3]), font_size =
12, color = (0,0,0,1))
self.info_grid.add_widget(self.date_of_birth_info)
self.problem_info = Label(text = str(patient[4]), font_size = 12,
color = (0,0,0,1))
self.info_grid.add_widget(self.problem_info)
self.appointment_timestamp_info = Label(text = str(patient[5]),
font_size = 12, color = (0,0,0,1), size_hint_x=None, width=150)
self.info_grid.add_widget(self.appointment_timestamp_info)

return (self.info_grid, size_hint, pos_hint)

def see_patients_report_function(self):
def current_function():
try:
doctor.see_patients_report(self.patient_username.text,
self.report_name.text, True)
except:
show_see_patients_report_popup()
self.patient_username.text = ""
self.report_name.text = ""

def show_see_patients_report_popup():
popup_layout = FloatLayout()
first_line = Label(text = "Sorry, Something went Wrong :(",
size_hint= (0.6, 0.2), pos_hint= {"x": 0.2, "top":0.9})
popup_layout.add_widget(first_line)
second_line = Label(text="Invalid Username or Report Name",
size_hint= (0.6, 0.2), pos_hint= {"x": 0.21, "top":0.5})
popup_layout.add_widget(second_line)
popup_window = Popup(title = "Show Patient Report Error", content =
popup_layout, size_hint = (0.6, 0.3))
popup_window.open()

self.info_grid = GridLayout()
self.info_grid.cols = 2
size_hint = 0.6, 0.2
pos_hint = {"x": 0.2, "top": 0.62}

[Link] = Label(text = "Patient Username", color = (0,0,0,1),


font_size = 16)
self.info_grid.add_widget([Link])
self.patient_username = TextInput(multiline = False)
self.info_grid.add_widget(self.patient_username)

self.question2 = Label(text = "Report Name", color = (0,0,0,1),


font_size = 16)
self.info_grid.add_widget(self.question2)
self.report_name = TextInput(multiline = False)
self.info_grid.add_widget(self.report_name)

[Link] = Button(text = "Submit")


[Link].font_size = 18
[Link] = (1, 1, 1, 1)
[Link] = True
[Link].background_color = (0/255, 153/255, 204/255, 1)
[Link].size_hint = (0.3,0.08)
[Link].pos_hint = {"x":0.36, "top": 0.175}
self.add_widget([Link])
[Link](on_release = lambda x: current_function())

return (self.info_grid, size_hint, pos_hint)

def remove_patient_function(self):
def current_function():
try:
doctor.remove_patient(self.patient_username.text, True)
except:
show_remove_patient_popup()
self.patient_username.text = ""

def show_remove_patient_popup():
popup_layout = FloatLayout()
first_line = Label(text = "Sorry, Something went Wrong :(",
size_hint= (0.6, 0.2), pos_hint= {"x": 0.2, "top":0.9})
popup_layout.add_widget(first_line)
second_line = Label(text="Invalid Username", size_hint= (0.6, 0.2),
pos_hint= {"x": 0.21, "top":0.5})
popup_layout.add_widget(second_line)
popup_window = Popup(title = "Remove Patient Error", content =
popup_layout, size_hint = (0.6, 0.3))
popup_window.open()

self.info_grid = GridLayout()
self.info_grid.cols = 1
size_hint = 0.6, 0.2
pos_hint = {"x": 0.2, "top": 0.6}

[Link] = Label(text = "Enter the Patient Username You Want to


Remove", color = (0,0,0,1), font_size = 16)
self.info_grid.add_widget([Link])
self.patient_username = TextInput(multiline = False)
self.info_grid.add_widget(self.patient_username)

[Link] = Button(text = "Submit")


[Link].font_size = 18
[Link] = (1, 1, 1, 1)
[Link] = True
[Link].background_color = (0/255, 153/255, 204/255, 1)
[Link].size_hint = (0.3,0.08)
[Link].pos_hint = {"x":0.36, "top": 0.175}
self.add_widget([Link])
[Link](on_release = lambda x: current_function())

return (self.info_grid, size_hint, pos_hint)

# Patient Functions
class PatientFunctions(Screen):
def __init__(self, **kwargs):
super().__init__(**kwargs)

[Link] = self.find_my_username()
[Link] = "patient"
with [Link]:
Color(1, 1, 1,1,mode="rgba")
Rectangle(pos = [Link], size = (800,600))
Color(51/255, 153/255, 255/255,1,mode="rgba")
Line(points = ((0, 580),(1000, 580)), width = 50)
Line(points = ((0, 0),(1000, 0)), width = 35)
[Link] = Label(text="Patient Functions", font_size=40,
color=(1,1,1,1))
[Link].pos_hint= {"x":0.05, "top": 1.45}
self.add_widget([Link])

[Link] = Button(background_normal="resources/short_logo.png",
background_down="resources/short_logo.png")
[Link].size_hint = (None, None)
[Link] = 120
[Link] = 90
[Link] = (0,0,0,1)
[Link].pos_hint = {"x": 0.1, "top": 1.02}
self.add_widget([Link])

self.close_button = Button(background_normal="resources/[Link]",
background_down="resources/close_down.png")
self.close_button.size_hint = (None, None)
self.close_button.width = 60
self.close_button.height = 60
self.close_button.color = (0,0,0,1)
self.close_button.pos_hint = {"x": 0.85, "top": 0.99}
self.add_widget(self.close_button)
self.close_button.bind(on_release = self.go_back)

[Link] = Label(text="Built with Python, PostgreSQL, Psycopg2, and


Kivy", font_size=13, color=(1,1,1,1))
[Link].pos_hint = {"x":-0.27, "top": 0.525}
self.add_widget([Link])

[Link]= Button(text="About Creator: Ahammad Shawki 8",


font_size=13, color=(1,1,1,1))
[Link].pos_hint = {"x":0.7, "top": 0.05}
[Link].size_hint = (0.28,0.05)
[Link].background_color = (1,1,1,0)
self.add_widget([Link])
[Link](on_press = go_to_website)

self.info_grid = GridLayout()
self.info_grid.cols = 1
self.info_grid.pos_hint = {"x": 0.2, "top": 0.82}
self.info_grid.size_hint = 0.6, 0.7

self.cost_button = Button(text="Total Cost", background_color = (0/255,


153/255, 204/255, 1), color= (1,1,1,1), font_size = 14)
self.info_grid.add_widget(self.cost_button)
self.cost_button.bind(on_release = lambda x:
self.set_function("cost_function"))
self.remaining_appointment_time_button = Button(text="Remaining
Appointment Time", background_color = (0.75, 0.75, 0.75, 1), color= (1,1,1,1),
font_size = 14)
self.info_grid.add_widget(self.remaining_appointment_time_button)
self.remaining_appointment_time_button.bind(on_release = lambda x:
self.set_function("remaining_appointment_time_function"))
self.add_report_button = Button(text="Add Report", background_color =
(0/255, 153/255, 204/255, 1), color= (1,1,1,1), font_size = 14)
self.info_grid.add_widget(self.add_report_button)
self.add_report_button.bind(on_release = lambda x:
self.set_function("add_report_function"))
self.see_all_doctors_for_my_problem_button = Button(text="See All
Doctors for My Problem", background_color = (0.75, 0.75, 0.75, 1), color=
(1,1,1,1), font_size = 14)
self.info_grid.add_widget(self.see_all_doctors_for_my_problem_button)
self.see_all_doctors_for_my_problem_button.bind(on_release = lambda x:
self.set_function("see_all_doctors_for_my_problem_function"))
self.request_doctor_button = Button(text="Request Doctor",
background_color = (0/255, 153/255, 204/255, 1), color= (1,1,1,1), font_size =
14)
self.info_grid.add_widget(self.request_doctor_button)
self.request_doctor_button.bind(on_release = lambda x:
self.set_function("request_doctor_function"))
self.remove_request_button = Button(text="Remove Request",
background_color = (0.75, 0.75, 0.75, 1), color= (1,1,1,1), font_size = 14)
self.info_grid.add_widget(self.remove_request_button)
self.remove_request_button.bind(on_release = lambda x:
self.set_function("remove_request_function"))
self.see_my_doctors_stat_button = Button(text="See My Doctors Stat",
background_color = (0/255, 153/255, 204/255, 1), color= (1,1,1,1), font_size =
14)
self.info_grid.add_widget(self.see_my_doctors_stat_button)
self.see_my_doctors_stat_button.bind(on_release = lambda x:
self.set_function("see_my_doctors_stat_function"))

self.add_widget(self.info_grid)

def find_my_username(self):
return [Link]

def go_back(self, instance):


for screen in [Link]:
if [Link] == "PatientFunctions":
[Link](screen)
[Link] = SlideTransition(direction = "right")
[Link] = "PatientAfterLogin"

def set_function(self, function_name):


sm.add_widget(PatientDisplayFunction(function_name,
name="PatientDisplayFunction"))
[Link] = SlideTransition(direction = "left")
[Link] = "PatientDisplayFunction"

class PatientDisplayFunction(Screen):
def __init__(self, function_name, **kwargs):
super().__init__(**kwargs)

[Link] = self.find_my_username()
[Link] = "patient"
self.function_name = function_name
with [Link]:
Color(1, 1, 1,1,mode="rgba")
Rectangle(pos = [Link], size = (800,600))
Color(51/255, 153/255, 255/255,1,mode="rgba")
Line(points = ((0, 580),(1000, 580)), width = 50)
Line(points = ((0, 0),(1000, 0)), width = 35)
[Link] = Label(text="Patient Functions", font_size=40,
color=(1,1,1,1))
[Link].pos_hint= {"x":0.05, "top": 1.45}
self.add_widget([Link])

[Link] = Button(background_normal="resources/short_logo.png",
background_down="resources/short_logo.png")
[Link].size_hint = (None, None)
[Link] = 120
[Link] = 90
[Link] = (0,0,0,1)
[Link].pos_hint = {"x": 0.1, "top": 1.02}
self.add_widget([Link])

self.close_button = Button(background_normal="resources/[Link]",
background_down="resources/close_down.png")
self.close_button.size_hint = (None, None)
self.close_button.width = 60
self.close_button.height = 60
self.close_button.color = (0,0,0,1)
self.close_button.pos_hint = {"x": 0.85, "top": 0.99}
self.add_widget(self.close_button)
self.close_button.bind(on_release = self.go_back)

[Link] = Label(text="Built with Python, PostgreSQL, Psycopg2, and


Kivy", font_size=13, color=(1,1,1,1))
[Link].pos_hint = {"x":-0.27, "top": 0.525}
self.add_widget([Link])

[Link]= Button(text="About Creator: Ahammad Shawki 8",


font_size=13, color=(1,1,1,1))
[Link].pos_hint = {"x":0.7, "top": 0.05}
[Link].size_hint = (0.28,0.05)
[Link].background_color = (1,1,1,0)
self.add_widget([Link])
[Link](on_press = go_to_website)

if self.function_name == "cost_function":
final_function = self.cost_function
elif self.function_name == "remaining_appointment_time_function":
final_function = self.remaining_appointment_time_function
elif self.function_name == "add_report_function":
final_function = self.add_report_function
elif self.function_name == "see_all_doctors_for_my_problem_function":
final_function = self.see_all_doctors_for_my_problem_function
elif self.function_name == "request_doctor_function":
final_function = self.request_doctor_function
elif self.function_name == "remove_request_function":
final_function = self.remove_request_function
else:
final_function = self.see_my_doctors_stat_function

[Link], size_hint, pos_hint = final_function()


[Link].size_hint = size_hint
[Link].pos_hint = pos_hint
self.add_widget([Link])

def find_my_username(self):
return [Link]

def go_back(self, instance):


for screen in [Link]:
if [Link] == "PatientDisplayFunction":
[Link](screen)
[Link] = SlideTransition(direction = "right")
[Link] = "PatientFunctions"
[Link] = 0

def cost_function(self):
total_earning_list = [Link]([Link], True)
doctor_charge = total_earning_list[0]
hospital_charge = total_earning_list[1]
total_charge = total_earning_list[2]

self.info_grid = GridLayout()
self.info_grid.cols = 2
size_hint = 0.6, 0.3
pos_hint = {"x": 0.2, "top": 0.6}

self.label1 = Label(text = "Doctor's Charge:", color = (0,0,0,1),


font_size = 16)
self.info_grid.add_widget(self.label1)
self.label2 = Label(text = "+" + str(doctor_charge), color = (0,0,0,1),
font_size = 16)
self.info_grid.add_widget(self.label2)
self.label3 = Label(text = "Hospital's Charge:", color = (0,0,0,1),
font_size = 16)
self.info_grid.add_widget(self.label3)
self.label4 = Label(text = "+" + str(hospital_charge), color =
(0,0,0,1), font_size = 16)
self.info_grid.add_widget(self.label4)
self.label5 = Label(text = "Total Charge:", color = (0,0,0,1), font_size
= 16)
self.info_grid.add_widget(self.label5)
self.label6 = Label(text = str(total_charge), color = (0,0,0,1),
font_size = 16)
self.info_grid.add_widget(self.label6)

return (self.info_grid, size_hint, pos_hint)

def remaining_appointment_time_function(self):
timestamp = str(patient.remaining_appointment_time([Link],
True))

day, time = [Link](", ")


hour, minute, sec = [Link](":")

self.info_grid = GridLayout()
self.info_grid.cols = 2
size_hint = 0.6, 0.3
pos_hint = {"x": 0.2, "top": 0.62}

self.label1 = Label(text = "Day:", color = (0,0,0,1), font_size = 16)


self.info_grid.add_widget(self.label1)
self.label2 = Label(text = str(day), color = (0,0,0,1), font_size = 16)
self.info_grid.add_widget(self.label2)
self.label3 = Label(text = "Hour:", color = (0,0,0,1), font_size = 16)
self.info_grid.add_widget(self.label3)
self.label4 = Label(text = str(hour) + " hours", color = (0,0,0,1),
font_size = 16)
self.info_grid.add_widget(self.label4)
self.label5 = Label(text = "Minute:", color = (0,0,0,1), font_size = 16)
self.info_grid.add_widget(self.label5)
self.label6 = Label(text = str(minute)+ " minutes", color = (0,0,0,1),
font_size = 16)
self.info_grid.add_widget(self.label6)

return (self.info_grid, size_hint, pos_hint)

def add_report_function(self):
def current_function():
if self.report_name.text == "" or self.report_url.text == "":
show_add_report_popup()
try:
patient.add_report(self.report_name.text, self.report_url.text,
[Link], True)
except:
show_add_report_popup()
self.report_name.text = ""
self.report_url.text = ""

def show_add_report_popup():
popup_layout = FloatLayout()
first_line = Label(text = "Sorry, Something went Wrong :(",
size_hint= (0.6, 0.2), pos_hint= {"x": 0.2, "top":0.9})
popup_layout.add_widget(first_line)
second_line = Label(text="Invalid Username or Report Name",
size_hint= (0.6, 0.2), pos_hint= {"x": 0.21, "top":0.5})
popup_layout.add_widget(second_line)
popup_window = Popup(title = "Add Report Error", content =
popup_layout, size_hint = (0.6, 0.3))
popup_window.open()

self.info_grid = GridLayout()
self.info_grid.cols = 2
size_hint = 0.6, 0.2
pos_hint = {"x": 0.2, "top": 0.62}

self.question1 = Label(text = "Report Name", color = (0,0,0,1),


font_size = 16)
self.info_grid.add_widget(self.question1)
self.report_name = TextInput(multiline = False)
self.info_grid.add_widget(self.report_name)

self.question2 = Label(text = "Report Url", color = (0,0,0,1), font_size


= 16)
self.info_grid.add_widget(self.question2)
self.report_url = TextInput(multiline = False)
self.info_grid.add_widget(self.report_url)

[Link] = Button(text = "Submit")


[Link].font_size = 18
[Link] = (1, 1, 1, 1)
[Link] = True
[Link].background_color = (0/255, 153/255, 204/255, 1)
[Link].size_hint = (0.3,0.08)
[Link].pos_hint = {"x":0.36, "top": 0.175}
self.add_widget([Link])
[Link](on_release = lambda x: current_function())
return (self.info_grid, size_hint, pos_hint)

def see_all_doctors_for_my_problem_function(self):
self.info_grid = GridLayout()
self.info_grid.cols = 5
pos_hint = {"x": 0.05, "top": 0.75}

doctor_infos =
patient.see_all_doctors_for_my_problem([Link],True)
if len(doctor_infos) > 7:
size_hint = 0.9, 0.6
elif len(doctor_infos) > 3:
size_hint = 0.9, 0.45
else:
size_hint = 0.9, 0.2

self.username_topic = Button(text = "Username", font_size = 15, color =


(1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.username_topic)
self.fullname_topic = Button(text = "Fullname", font_size = 15, color =
(1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.fullname_topic)
self.email_topic = Button(text = "Email", font_size = 15, color =
(1,1,1,1), background_color = (0/255, 153/255, 204/255, 1), size_hint_x=None,
width=200)
self.info_grid.add_widget(self.email_topic)
self.date_of_birth_topic = Button(text = "Date of Birth", font_size =
15, color = (1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.date_of_birth_topic)
self.salary_topic = Button(text = "Salary", font_size = 15, color =
(1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.salary_topic)

for doctor in doctor_infos:


self.username_info = Label(text = str(doctor[0]), font_size = 12,
color = (0,0,0,1))
self.info_grid.add_widget(self.username_info)
self.fullname_info = Label(text = str(doctor[1]), font_size = 12,
color = (0,0,0,1))
self.info_grid.add_widget(self.fullname_info)
self.email_info = Label(text = str(doctor[2]), font_size = 12, color
= (0,0,0,1), size_hint_x=None, width=200)
self.info_grid.add_widget(self.email_info)
self.date_of_birth_info = Label(text = str(doctor[3]), font_size =
12, color = (0,0,0,1))
self.info_grid.add_widget(self.date_of_birth_info)
self.salary_info = Label(text = str(doctor[4]), font_size = 12,
color = (0,0,0,1))
self.info_grid.add_widget(self.salary_info)

return (self.info_grid, size_hint, pos_hint)

def request_doctor_function(self):
def current_function():
try:
patient.request_doctor([Link],self.doctor_username.text,
True)
except:
show_request_doctor_popup()
self.doctor_username.text = ""

def show_request_doctor_popup():
popup_layout = FloatLayout()
first_line = Label(text = "Sorry, Something went Wrong :(",
size_hint= (0.6, 0.2), pos_hint= {"x": 0.2, "top":0.9})
popup_layout.add_widget(first_line)
second_line = Label(text="Invalid Username", size_hint= (0.6, 0.2),
pos_hint= {"x": 0.21, "top":0.5})
popup_layout.add_widget(second_line)
popup_window = Popup(title = "Request Doctor Error", content =
popup_layout, size_hint = (0.6, 0.3))
popup_window.open()

self.info_grid = GridLayout()
self.info_grid.cols = 1
size_hint = 0.6, 0.2
pos_hint = {"x": 0.2, "top": 0.6}

[Link] = Label(text = "Enter the Doctor Username You Want to


Request", color = (0,0,0,1), font_size = 16)
self.info_grid.add_widget([Link])
self.doctor_username = TextInput(multiline = False)
self.info_grid.add_widget(self.doctor_username)

[Link] = Button(text = "Submit")


[Link].font_size = 18
[Link] = (1, 1, 1, 1)
[Link] = True
[Link].background_color = (0/255, 153/255, 204/255, 1)
[Link].size_hint = (0.3,0.08)
[Link].pos_hint = {"x":0.36, "top": 0.175}
self.add_widget([Link])
[Link](on_release = lambda x: current_function())

return (self.info_grid, size_hint, pos_hint)

def remove_request_function(self):
patient.remove_request([Link], True)

self.info_grid = Label(text = "Successfully removed request :)",


font_size = 25, color = (0/255, 153/255, 204/255, 1))
size_hint = 0,0
pos_hint = {"x": 0.52, "top": 0.5}

return(self.info_grid, size_hint, pos_hint)


def see_my_doctors_stat_function(self):
self.info_grid = GridLayout()
self.info_grid.cols = 2
pos_hint = {"x": 0.31, "top": 0.65}

doctor_info = patient.see_my_doctors_stat([Link],True)
size_hint = 0.5, 0.4

self.username_topic = Button(text = "Username", font_size = 15, color =


(1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.username_topic)
self.username_info = Label(text = str(doctor_info[0]), font_size = 12,
color = (0,0,0,1))
self.info_grid.add_widget(self.username_info)
self.fullname_topic = Button(text = "Fullname", font_size = 15, color =
(1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.fullname_topic)
self.fullname_info = Label(text = str(doctor_info[1]), font_size = 12,
color = (0,0,0,1))
self.info_grid.add_widget(self.fullname_info)
self.email_topic = Button(text = "Email", font_size = 15, color =
(1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.email_topic)
self.email_info = Label(text = str(doctor_info[2]), font_size = 12,
color = (0,0,0,1))
self.info_grid.add_widget(self.email_info)
self.date_of_birth_topic = Button(text = "Date of Birth", font_size =
15, color = (1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.date_of_birth_topic)
self.date_of_birth_info = Label(text = str(doctor_info[3]), font_size =
12, color = (0,0,0,1))
self.info_grid.add_widget(self.date_of_birth_info)
self.salary_topic = Button(text = "Salary", font_size = 15, color =
(1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.salary_topic)
self.salary_info = Label(text = str(doctor_info[4]), font_size = 12,
color = (0,0,0,1))
self.info_grid.add_widget(self.salary_info)
self.appointment_timestamp_topic = Button(text = "Appointment
Timestamp", font_size = 15, color = (1,1,1,1), background_color = (0/255,
153/255, 204/255, 1))
self.info_grid.add_widget(self.appointment_timestamp_topic)
self.appointment_timestamp_info = Label(text = str(doctor_info[5]),
font_size = 12, color = (0,0,0,1))
self.info_grid.add_widget(self.appointment_timestamp_info)

return (self.info_grid, size_hint, pos_hint)

# Employee Functions
class EmployeeFunctions(Screen):
def __init__(self, **kwargs):
super().__init__(**kwargs)

[Link] = self.find_my_username()
[Link] = "employee"
self.is_receptionist = [Link]([Link], True)
with [Link]:
Color(1, 1, 1,1,mode="rgba")
Rectangle(pos = [Link], size = (800,600))
Color(51/255, 153/255, 255/255,1,mode="rgba")
Line(points = ((0, 580),(1000, 580)), width = 50)
Line(points = ((0, 0),(1000, 0)), width = 35)
[Link] = Label(text="Employee Functions", font_size=40,
color=(1,1,1,1))
[Link].pos_hint= {"x":0.05, "top": 1.45}
self.add_widget([Link])

[Link] = Button(background_normal="resources/short_logo.png",
background_down="resources/short_logo.png")
[Link].size_hint = (None, None)
[Link] = 120
[Link] = 90
[Link] = (0,0,0,1)
[Link].pos_hint = {"x": 0.1, "top": 1.02}
self.add_widget([Link])

self.close_button = Button(background_normal="resources/[Link]",
background_down="resources/close_down.png")
self.close_button.size_hint = (None, None)
self.close_button.width = 60
self.close_button.height = 60
self.close_button.color = (0,0,0,1)
self.close_button.pos_hint = {"x": 0.85, "top": 0.99}
self.add_widget(self.close_button)
self.close_button.bind(on_release = self.go_back)

[Link] = Label(text="Built with Python, PostgreSQL, Psycopg2, and


Kivy", font_size=13, color=(1,1,1,1))
[Link].pos_hint = {"x":-0.27, "top": 0.525}
self.add_widget([Link])

[Link]= Button(text="About Creator: Ahammad Shawki 8",


font_size=13, color=(1,1,1,1))
[Link].pos_hint = {"x":0.7, "top": 0.05}
[Link].size_hint = (0.28,0.05)
[Link].background_color = (1,1,1,0)
self.add_widget([Link])
[Link](on_press = go_to_website)

self.info_grid = GridLayout()
self.info_grid.cols = 1
self.info_grid.pos_hint = {"x": 0.2, "top": 0.82}
self.info_grid.size_hint = 0.6, 0.7

self.salary_button = Button(text="Salary", background_color = (0/255,


153/255, 204/255, 1), color= (1,1,1,1), font_size = 14)
self.info_grid.add_widget(self.salary_button)
self.salary_button.bind(on_release = lambda x:
self.set_function("salary_function"))
self.see_my_doctors_button = Button(text="See My Doctors",
background_color = (0.75, 0.75, 0.75, 1), color= (1,1,1,1), font_size = 14)
self.info_grid.add_widget(self.see_my_doctors_button)
self.see_my_doctors_button.bind(on_release = lambda x:
self.set_function("see_my_doctors_function"))
if self.is_receptionist:
self.appoint_doctor_button = Button(text="Appoint Doctor",
background_color = (0/255, 153/255, 204/255, 1), color= (1,1,1,1), font_size =
14)
self.info_grid.add_widget(self.appoint_doctor_button)
self.appoint_doctor_button.bind(on_release = lambda x:
self.set_function("appoint_doctor_function"))

self.add_widget(self.info_grid)

def find_my_username(self):
return [Link]

def go_back(self, instance):


for screen in [Link]:
if [Link] == "EmployeeFunctions":
[Link](screen)
[Link] = SlideTransition(direction = "right")
[Link] = "EmployeeAfterLogin"

def set_function(self, function_name):


sm.add_widget(EmployeeDisplayFunction(function_name,
name="EmployeeDisplayFunction"))
[Link] = SlideTransition(direction = "left")
[Link] = "EmployeeDisplayFunction"

class EmployeeDisplayFunction(Screen):
def __init__(self, function_name, **kwargs):
super().__init__(**kwargs)

[Link] = self.find_my_username()
[Link] = "employee"
self.function_name = function_name
with [Link]:
Color(1, 1, 1,1,mode="rgba")
Rectangle(pos = [Link], size = (800,600))
Color(51/255, 153/255, 255/255,1,mode="rgba")
Line(points = ((0, 580),(1000, 580)), width = 50)
Line(points = ((0, 0),(1000, 0)), width = 35)
[Link] = Label(text="Employee Functions", font_size=40,
color=(1,1,1,1))
[Link].pos_hint= {"x":0.05, "top": 1.45}
self.add_widget([Link])
[Link] = Button(background_normal="resources/short_logo.png",
background_down="resources/short_logo.png")
[Link].size_hint = (None, None)
[Link] = 120
[Link] = 90
[Link] = (0,0,0,1)
[Link].pos_hint = {"x": 0.1, "top": 1.02}
self.add_widget([Link])

self.close_button = Button(background_normal="resources/[Link]",
background_down="resources/close_down.png")
self.close_button.size_hint = (None, None)
self.close_button.width = 60
self.close_button.height = 60
self.close_button.color = (0,0,0,1)
self.close_button.pos_hint = {"x": 0.85, "top": 0.99}
self.add_widget(self.close_button)
self.close_button.bind(on_release = self.go_back)

[Link] = Label(text="Built with Python, PostgreSQL, Psycopg2, and


Kivy", font_size=13, color=(1,1,1,1))
[Link].pos_hint = {"x":-0.27, "top": 0.525}
self.add_widget([Link])

[Link]= Button(text="About Creator: Ahammad Shawki 8",


font_size=13, color=(1,1,1,1))
[Link].pos_hint = {"x":0.7, "top": 0.05}
[Link].size_hint = (0.28,0.05)
[Link].background_color = (1,1,1,0)
self.add_widget([Link])
[Link](on_press = go_to_website)

if self.function_name == "salary_function":
final_function = self.salary_function
elif self.function_name == "see_my_doctors_function":
final_function = self.see_my_doctors_function
else:
final_function = self.appoint_doctor_function

[Link], size_hint, pos_hint = final_function()


[Link].size_hint = size_hint
[Link].pos_hint = pos_hint
self.add_widget([Link])

def find_my_username(self):
return [Link]

def go_back(self, instance):


for screen in [Link]:
if [Link] == "EmployeeDisplayFunction":
[Link](screen)
[Link] = SlideTransition(direction = "right")
[Link] = "EmployeeFunctions"
[Link] = 0

def salary_function(self):
total_earning_list = [Link]([Link], True)
initial_salary = total_earning_list[0]
hospital_cost = total_earning_list[1]
nit_salary = total_earning_list[2]

self.info_grid = GridLayout()
self.info_grid.cols = 2
size_hint = 0.6, 0.3
pos_hint = {"x": 0.2, "top": 0.6}

self.label1 = Label(text = "Initial Salary", color = (0,0,0,1),


font_size = 16)
self.info_grid.add_widget(self.label1)
self.label2 = Label(text = "+" + str(initial_salary), color = (0,0,0,1),
font_size = 16)
self.info_grid.add_widget(self.label2)
self.label3 = Label(text = "Hospital Cost", color = (0,0,0,1), font_size
= 16)
self.info_grid.add_widget(self.label3)
self.label4 = Label(text = "-" + str(hospital_cost), color = (0,0,0,1),
font_size = 16)
self.info_grid.add_widget(self.label4)
self.label5 = Label(text = "Nit Salary", color = (0,0,0,1), font_size =
16)
self.info_grid.add_widget(self.label5)
self.label6 = Label(text = str(nit_salary), color = (0,0,0,1), font_size
= 16)
self.info_grid.add_widget(self.label6)

return (self.info_grid, size_hint, pos_hint)

def see_my_doctors_function(self):
self.info_grid = GridLayout()
self.info_grid.cols = 5
pos_hint = {"x": 0.05, "top": 0.75}

doctor_infos = employee.see_my_doctors([Link],True)
if len(doctor_infos) > 7:
size_hint = 0.9, 0.6
elif len(doctor_infos) > 3:
size_hint = 0.9, 0.45
else:
size_hint = 0.9, 0.2

self.username_topic = Button(text = "Username", font_size = 15, color =


(1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.username_topic)
self.fullname_topic = Button(text = "Fullname", font_size = 15, color =
(1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.fullname_topic)
self.email_topic = Button(text = "Email", font_size = 15, color =
(1,1,1,1), background_color = (0/255, 153/255, 204/255, 1), size_hint_x=None,
width=200)
self.info_grid.add_widget(self.email_topic)
self.date_of_birth_topic = Button(text = "Date of Birth", font_size =
15, color = (1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.date_of_birth_topic)
self.specialty_topic = Button(text = "Specialty", font_size = 15, color
= (1,1,1,1), background_color = (0/255, 153/255, 204/255, 1))
self.info_grid.add_widget(self.specialty_topic)

for doctor in doctor_infos:


self.username_info = Label(text = str(doctor[0]), font_size = 12,
color = (0,0,0,1))
self.info_grid.add_widget(self.username_info)
self.fullname_info = Label(text = str(doctor[1]), font_size = 12,
color = (0,0,0,1))
self.info_grid.add_widget(self.fullname_info)
self.email_info = Label(text = str(doctor[2]), font_size = 12, color
= (0,0,0,1), size_hint_x=None, width=200)
self.info_grid.add_widget(self.email_info)
self.date_of_birth_info = Label(text = str(doctor[3]), font_size =
12, color = (0,0,0,1))
self.info_grid.add_widget(self.date_of_birth_info)
self.specialty_info = Label(text = str(doctor[4]), font_size = 12,
color = (0,0,0,1))
self.info_grid.add_widget(self.specialty_info)

return (self.info_grid, size_hint, pos_hint)

def appoint_doctor_function(self):
def current_function():
try:
employee.appoint_doctor([Link],
self.doctor_username.text, self.patient_username.text,
self.appointment_timestamp.text, True)
except:
show_appoint_doctor_popup()
self.doctor_username.text = ""
self.patient_username.text = ""
self.appointment_timestamp.text = "YYYY-MM-DD HH:MM:SS"

def show_appoint_doctor_popup():
popup_layout = FloatLayout()
first_line = Label(text = "Sorry, Something went Wrong :(",
size_hint= (0.6, 0.2), pos_hint= {"x": 0.2, "top":0.9})
popup_layout.add_widget(first_line)
second_line = Label(text="Invalid Username or Date Format",
size_hint= (0.6, 0.2), pos_hint= {"x": 0.21, "top":0.5})
popup_layout.add_widget(second_line)
popup_window = Popup(title = "Appoint Doctor Error", content =
popup_layout, size_hint = (0.6, 0.3))
popup_window.open()
self.info_grid = GridLayout()
self.info_grid.cols = 2
size_hint = 0.6, 0.2
pos_hint = {"x": 0.2, "top": 0.65}

self.question1 = Label(text = "Doctor Username:", color = (0,0,0,1),


font_size = 16)
self.info_grid.add_widget(self.question1)
self.doctor_username = TextInput(multiline = False)
self.info_grid.add_widget(self.doctor_username)

self.question2 = Label(text = "Patient Username:", color = (0,0,0,1),


font_size = 16)
self.info_grid.add_widget(self.question2)
self.patient_username = TextInput(multiline = False)
self.info_grid.add_widget(self.patient_username)

self.question3 = Label(text = "Appointment Timestamp:", color =


(0,0,0,1), font_size = 16)
self.info_grid.add_widget(self.question3)
self.appointment_timestamp = TextInput(text = "YYYY-MM-DD HH:MM:SS",
multiline = False)
self.info_grid.add_widget(self.appointment_timestamp)

[Link] = Button(text = "Submit")


[Link].font_size = 18
[Link] = (1, 1, 1, 1)
[Link] = True
[Link].background_color = (0/255, 153/255, 204/255, 1)
[Link].size_hint = (0.3,0.08)
[Link].pos_hint = {"x":0.36, "top": 0.175}
self.add_widget([Link])
[Link](on_release = lambda x: current_function())

return (self.info_grid, size_hint, pos_hint)

# AdminAfterLogin Class
class AdminAfterLogin(Screen, Widget):
def __init__(self,**kwargs):
super().__init__(**kwargs)
with [Link]:
Color(51/255, 153/255, 255/255,1,mode="rgba")
Line(points = ((0, 580),(1000, 580)), width = 50)
Line(points = ((0, 0),(1000, 0)), width = 35)
Color(0.4, 0.4, 0.4,1,mode="rgba")
Line(points = ((410, 80),(410, 280)), width = 2)
Line(points = ((180, 175),(620, 175)), width = 2)
[Link] = Label(text="Admin Panel", font_size=40, color=(1,1,1,1))
[Link].pos_hint= {"top": 1.45}
self.add_widget([Link])

self.add_notifications_button =
Button(background_normal="resources/add_notifications.png",
background_down="resources/add_notifications_down.png")
self.add_notifications_button.size_hint = (None, None)
self.add_notifications_button.width = 70
self.add_notifications_button.height = 70
self.add_notifications_button.color = (0,0,0,1)
self.add_notifications_button.pos_hint = {"x": 0.72, "top": 1}
self.add_widget(self.add_notifications_button)
self.add_notifications_button.bind(on_release =
self.go_to_add_notifications)

self.notifications_button =
Button(background_normal="resources/[Link]",
background_down="resources/notifications_down.png")
self.notifications_button.size_hint = (None, None)
self.notifications_button.width = 70
self.notifications_button.height = 70
self.notifications_button.color = (0,0,0,1)
self.notifications_button.pos_hint = {"x": 0.80, "top": 1}
self.add_widget(self.notifications_button)
self.notifications_button.bind(on_release = self.go_to_notifications)

self.profile_button = Button(background_normal="resources/[Link]",
background_down="resources/profile_down.png")
self.profile_button.size_hint = (None, None)
self.profile_button.width = 70
self.profile_button.height = 70
self.profile_button.color = (0,0,0,1)
self.profile_button.pos_hint = {"x": 0.88, "top": 1}
self.add_widget(self.profile_button)
self.profile_button.bind(on_release = self.go_to_profile)

[Link] = Button(background_normal="resources/short_logo.png",
background_down="resources/short_logo.png")
[Link].size_hint = (None, None)
[Link] = 120
[Link] = 90
[Link] = (0,0,0,1)
[Link].pos_hint = {"x": 0.1, "top": 1.02}
self.add_widget([Link])

[Link] = Label(text="Built with Python, PostgreSQL, Psycopg2, and


Kivy", font_size=13, color=(1,1,1,1))
[Link].pos_hint = {"x":-0.27, "top": 0.525}
self.add_widget([Link])

[Link] = Button(text="About Creator: Ahammad Shawki 8",


font_size=13, color=(1,1,1,1))
[Link].pos_hint = {"x":0.7, "top": 0.05}
[Link].size_hint = (0.28,0.05)
[Link].background_color = (1,1,1,0)
self.add_widget([Link])
[Link](on_press = go_to_website)

self.functions_label = Label(text="Functions", font_size=15,


color=(0,0,0,1))
self.functions_label.pos_hint = {"x":-0.19, "top": 0.82}
self.add_widget(self.functions_label)

self.about_hospital_label = Label(text="About Hospital", font_size=15,


color=(0,0,0,1))
self.about_hospital_label.pos_hint = {"x":-0.187, "top": 0.61}
self.add_widget(self.about_hospital_label)

self.settings_label = Label(text="Settings", font_size=15,


color=(0,0,0,1))
self.settings_label.pos_hint = {"x":0.213, "top": 0.825}
self.add_widget(self.settings_label)

self.documentation_label = Label(text="Documentation", font_size=15,


color=(0,0,0,1))
self.documentation_label.pos_hint = {"x":0.215, "top": 0.615}
self.add_widget(self.documentation_label)

def go_to_profile(self, instance):


sm.add_widget(AdminProfile(name = "AdminProfile"))
[Link] = SlideTransition(direction = "left")
[Link] = "AdminProfile"

def go_to_notifications(self, instance):


sm.add_widget(AdminNotifications(name = "AdminNotifications"))
[Link] = SlideTransition(direction = "left")
[Link] = "AdminNotifications"

def go_to_add_notifications(self, instance):


sm.add_widget(AdminAddNotifications(name = "AdminAddNotifications"))
[Link] = SlideTransition(direction = "left")
[Link] = "AdminAddNotifications"

def go_to_settings(self):
[Link] = (1,1,1,1)
sm.add_widget(AdminSettings(name = "AdminSettings"))
[Link] = SlideTransition(direction = "left")
[Link] = "AdminSettings"

def go_to_functions(self):
sm.add_widget(AdminFunctions(name = "AdminFunctions"))
[Link] = SlideTransition(direction = "left")
[Link] = "AdminFunctions"

# DoctorAfterLogin Class
class DoctorAfterLogin(Screen, Widget):
def __init__(self,**kwargs):
super().__init__(**kwargs)
with [Link]:
Color(51/255, 153/255, 255/255,1,mode="rgba")
Line(points = ((0, 580),(1000, 580)), width = 50)
Line(points = ((0, 0),(1000, 0)), width = 35)
Color(0.4, 0.4, 0.4,1,mode="rgba")
Line(points = ((410, 80),(410, 280)), width = 2)
Line(points = ((180, 175),(620, 175)), width = 2)
[Link] = Label(text="Doctor Panel", font_size=40, color=(1,1,1,1))
[Link].pos_hint= {"top": 1.45}
self.add_widget([Link])

self.add_notifications_button =
Button(background_normal="resources/add_notifications.png",
background_down="resources/add_notifications_down.png")
self.add_notifications_button.size_hint = (None, None)
self.add_notifications_button.width = 70
self.add_notifications_button.height = 70
self.add_notifications_button.color = (0,0,0,1)
self.add_notifications_button.pos_hint = {"x": 0.72, "top": 1}
self.add_widget(self.add_notifications_button)
self.add_notifications_button.bind(on_release =
self.go_to_add_notifications)

self.notifications_button =
Button(background_normal="resources/[Link]",
background_down="resources/notifications_down.png")
self.notifications_button.size_hint = (None, None)
self.notifications_button.width = 70
self.notifications_button.height = 70
self.notifications_button.color = (0,0,0,1)
self.notifications_button.pos_hint = {"x": 0.80, "top": 1}
self.add_widget(self.notifications_button)
self.notifications_button.bind(on_release = self.go_to_notifications)

self.profile_button = Button(background_normal="resources/[Link]",
background_down="resources/profile_down.png")
self.profile_button.size_hint = (None, None)
self.profile_button.width = 70
self.profile_button.height = 70
self.profile_button.color = (0,0,0,1)
self.profile_button.pos_hint = {"x": 0.88, "top": 1}
self.add_widget(self.profile_button)
self.profile_button.bind(on_release = self.go_to_profile)

[Link] = Button(background_normal="resources/short_logo.png",
background_down="resources/short_logo.png")
[Link].size_hint = (None, None)
[Link] = 120
[Link] = 90
[Link] = (0,0,0,1)
[Link].pos_hint = {"x": 0.1, "top": 1.02}
self.add_widget([Link])
[Link] = Label(text="Built with Python, PostgreSQL, Psycopg2, and
Kivy", font_size=13, color=(1,1,1,1))
[Link].pos_hint = {"x":-0.27, "top": 0.525}
self.add_widget([Link])

[Link] = Button(text="About Creator: Ahammad Shawki 8",


font_size=13, color=(1,1,1,1))
[Link].pos_hint = {"x":0.7, "top": 0.05}
[Link].size_hint = (0.28,0.05)
[Link].background_color = (1,1,1,0)
self.add_widget([Link])
[Link](on_press = go_to_website)

self.functions_label = Label(text="Functions", font_size=15,


color=(0,0,0,1))
self.functions_label.pos_hint = {"x":-0.19, "top": 0.82}
self.add_widget(self.functions_label)

self.about_hospital_label = Label(text="About Hospital", font_size=15,


color=(0,0,0,1))
self.about_hospital_label.pos_hint = {"x":-0.187, "top": 0.61}
self.add_widget(self.about_hospital_label)

self.settings_label = Label(text="Settings", font_size=15,


color=(0,0,0,1))
self.settings_label.pos_hint = {"x":0.213, "top": 0.825}
self.add_widget(self.settings_label)

self.documentation_label = Label(text="Documentation", font_size=15,


color=(0,0,0,1))
self.documentation_label.pos_hint = {"x":0.215, "top": 0.615}
self.add_widget(self.documentation_label)

def go_to_profile(self, instance):


sm.add_widget(DoctorProfile(name = "DoctorProfile"))
[Link] = SlideTransition(direction = "left")
[Link] = "DoctorProfile"

def go_to_notifications(self, instance):


sm.add_widget(DoctorNotifications(name = "DoctorNotifications"))
[Link] = SlideTransition(direction = "left")
[Link] = "DoctorNotifications"

def go_to_add_notifications(self, instance):


sm.add_widget(DoctorAddNotifications(name = "DoctorAddNotifications"))
[Link] = SlideTransition(direction = "left")
[Link] = "DoctorAddNotifications"

def go_to_settings(self):
sm.add_widget(DoctorSettings(name = "DoctorSettings"))
[Link] = SlideTransition(direction = "left")
[Link] = "DoctorSettings"

def go_to_functions(self):
sm.add_widget(DoctorFunctions(name = "DoctorFunctions"))
[Link] = SlideTransition(direction = "left")
[Link] = "DoctorFunctions"

# PatientAfterLogin Class
class PatientAfterLogin(Screen, Widget):
def __init__(self,**kwargs):
super().__init__(**kwargs)
with [Link]:
Color(51/255, 153/255, 255/255,1,mode="rgba")
Line(points = ((0, 580),(1000, 580)), width = 50)
Line(points = ((0, 0),(1000, 0)), width = 35)
Color(0.4, 0.4, 0.4,1,mode="rgba")
Line(points = ((410, 80),(410, 280)), width = 2)
Line(points = ((180, 175),(620, 175)), width = 2)
[Link] = Label(text="Patient Panel", font_size=40, color=(1,1,1,1))
[Link].pos_hint= {"top": 1.45}
self.add_widget([Link])

self.add_notifications_button =
Button(background_normal="resources/add_notifications.png",
background_down="resources/add_notifications_down.png")
self.add_notifications_button.size_hint = (None, None)
self.add_notifications_button.width = 70
self.add_notifications_button.height = 70
self.add_notifications_button.color = (0,0,0,1)
self.add_notifications_button.pos_hint = {"x": 0.72, "top": 1}
self.add_widget(self.add_notifications_button)
self.add_notifications_button.bind(on_release =
self.go_to_add_notifications)

self.notifications_button =
Button(background_normal="resources/[Link]",
background_down="resources/notifications_down.png")
self.notifications_button.size_hint = (None, None)
self.notifications_button.width = 70
self.notifications_button.height = 70
self.notifications_button.color = (0,0,0,1)
self.notifications_button.pos_hint = {"x": 0.80, "top": 1}
self.add_widget(self.notifications_button)
self.notifications_button.bind(on_release = self.go_to_notifications)

self.profile_button = Button(background_normal="resources/[Link]",
background_down="resources/profile_down.png")
self.profile_button.size_hint = (None, None)
self.profile_button.width = 70
self.profile_button.height = 70
self.profile_button.color = (0,0,0,1)
self.profile_button.pos_hint = {"x": 0.88, "top": 1}
self.add_widget(self.profile_button)
self.profile_button.bind(on_release = self.go_to_profile)
[Link] = Button(background_normal="resources/short_logo.png",
background_down="resources/short_logo.png")
[Link].size_hint = (None, None)
[Link] = 120
[Link] = 90
[Link] = (0,0,0,1)
[Link].pos_hint = {"x": 0.1, "top": 1.02}
self.add_widget([Link])

[Link] = Label(text="Built with Python, PostgreSQL, Psycopg2, and


Kivy", font_size=13, color=(1,1,1,1))
[Link].pos_hint = {"x":-0.27, "top": 0.525}
self.add_widget([Link])

[Link] = Button(text="About Creator: Ahammad Shawki 8",


font_size=13, color=(1,1,1,1))
[Link].pos_hint = {"x":0.7, "top": 0.05}
[Link].size_hint = (0.28,0.05)
[Link].background_color = (1,1,1,0)
self.add_widget([Link])
[Link](on_press = go_to_website)

self.functions_label = Label(text="Functions", font_size=15,


color=(0,0,0,1))
self.functions_label.pos_hint = {"x":-0.19, "top": 0.82}
self.add_widget(self.functions_label)

self.about_hospital_label = Label(text="About Hospital", font_size=15,


color=(0,0,0,1))
self.about_hospital_label.pos_hint = {"x":-0.187, "top": 0.61}
self.add_widget(self.about_hospital_label)

self.settings_label = Label(text="Settings", font_size=15,


color=(0,0,0,1))
self.settings_label.pos_hint = {"x":0.213, "top": 0.825}
self.add_widget(self.settings_label)

self.documentation_label = Label(text="Documentation", font_size=15,


color=(0,0,0,1))
self.documentation_label.pos_hint = {"x":0.215, "top": 0.615}
self.add_widget(self.documentation_label)

def go_to_profile(self, instance):


sm.add_widget(PatientProfile(name = "PatientProfile"))
[Link] = SlideTransition(direction = "left")
[Link] = "PatientProfile"

def go_to_notifications(self, instance):


sm.add_widget(PatientNotifications(name = "PatientNotifications"))
[Link] = SlideTransition(direction = "left")
[Link] = "PatientNotifications"

def go_to_add_notifications(self, instance):


sm.add_widget(PatientAddNotifications(name = "PatientAddNotifications"))
[Link] = SlideTransition(direction = "left")
[Link] = "PatientAddNotifications"

def go_to_settings(self):
sm.add_widget(PatientSettings(name = "PatientSettings"))
[Link] = SlideTransition(direction = "left")
[Link] = "PatientSettings"

def go_to_functions(self):
sm.add_widget(PatientFunctions(name = "PatientFunctions"))
[Link] = SlideTransition(direction = "left")
[Link] = "PatientFunctions"

# EmployeeAfterLogin Class
class EmployeeAfterLogin(Screen, Widget):
def __init__(self,**kwargs):
super().__init__(**kwargs)
with [Link]:
Color(51/255, 153/255, 255/255,1,mode="rgba")
Line(points = ((0, 580),(1000, 580)), width = 50)
Line(points = ((0, 0),(1000, 0)), width = 35)
Color(0.4, 0.4, 0.4,1,mode="rgba")
Line(points = ((410, 80),(410, 280)), width = 2)
Line(points = ((180, 175),(620, 175)), width = 2)
[Link] = Label(text="Employee Panel", font_size=40, color=(1,1,1,1))
[Link].pos_hint= {"top": 1.45}
self.add_widget([Link])

self.add_notifications_button =
Button(background_normal="resources/add_notifications.png",
background_down="resources/add_notifications_down.png")
self.add_notifications_button.size_hint = (None, None)
self.add_notifications_button.width = 70
self.add_notifications_button.height = 70
self.add_notifications_button.color = (0,0,0,1)
self.add_notifications_button.pos_hint = {"x": 0.72, "top": 1}
self.add_widget(self.add_notifications_button)
self.add_notifications_button.bind(on_release =
self.go_to_add_notifications)

self.notifications_button =
Button(background_normal="resources/[Link]",
background_down="resources/notifications_down.png")
self.notifications_button.size_hint = (None, None)
self.notifications_button.width = 70
self.notifications_button.height = 70
self.notifications_button.color = (0,0,0,1)
self.notifications_button.pos_hint = {"x": 0.80, "top": 1}
self.add_widget(self.notifications_button)
self.notifications_button.bind(on_release = self.go_to_notifications)
self.profile_button = Button(background_normal="resources/[Link]",
background_down="resources/profile_down.png")
self.profile_button.size_hint = (None, None)
self.profile_button.width = 70
self.profile_button.height = 70
self.profile_button.color = (0,0,0,1)
self.profile_button.pos_hint = {"x": 0.88, "top": 1}
self.add_widget(self.profile_button)
self.profile_button.bind(on_release = self.go_to_profile)

[Link] = Button(background_normal="resources/short_logo.png",
background_down="resources/short_logo.png")
[Link].size_hint = (None, None)
[Link] = 120
[Link] = 90
[Link] = (0,0,0,1)
[Link].pos_hint = {"x": 0.1, "top": 1.02}
self.add_widget([Link])

[Link] = Label(text="Built with Python, PostgreSQL, Psycopg2, and


Kivy", font_size=13, color=(1,1,1,1))
[Link].pos_hint = {"x":-0.27, "top": 0.525}
self.add_widget([Link])

[Link] = Button(text="About Creator: Ahammad Shawki 8",


font_size=13, color=(1,1,1,1))
[Link].pos_hint = {"x":0.7, "top": 0.05}
[Link].size_hint = (0.28,0.05)
[Link].background_color = (1,1,1,0)
self.add_widget([Link])
[Link](on_press = go_to_website)

self.functions_label = Label(text="Functions", font_size=15,


color=(0,0,0,1))
self.functions_label.pos_hint = {"x":-0.19, "top": 0.82}
self.add_widget(self.functions_label)

self.about_hospital_label = Label(text="About Hospital", font_size=15,


color=(0,0,0,1))
self.about_hospital_label.pos_hint = {"x":-0.187, "top": 0.61}
self.add_widget(self.about_hospital_label)

self.settings_label = Label(text="Settings", font_size=15,


color=(0,0,0,1))
self.settings_label.pos_hint = {"x":0.213, "top": 0.825}
self.add_widget(self.settings_label)

self.documentation_label = Label(text="Documentation", font_size=15,


color=(0,0,0,1))
self.documentation_label.pos_hint = {"x":0.215, "top": 0.615}
self.add_widget(self.documentation_label)

def go_to_profile(self, instance):


sm.add_widget(EmployeeProfile(name = "EmployeeProfile"))
[Link] = SlideTransition(direction = "left")
[Link] = "EmployeeProfile"

def go_to_notifications(self, instance):


sm.add_widget(EmployeeNotifications(name = "EmployeeNotifications"))
[Link] = SlideTransition(direction = "left")
[Link] = "EmployeeNotifications"

def go_to_add_notifications(self, instance):


sm.add_widget(EmployeeAddNotifications(name =
"EmployeeAddNotifications"))
[Link] = SlideTransition(direction = "left")
[Link] = "EmployeeAddNotifications"

def go_to_settings(self):
sm.add_widget(EmployeeSettings(name = "EmployeeSettings"))
[Link] = SlideTransition(direction = "left")
[Link] = "EmployeeSettings"

def go_to_functions(self):
sm.add_widget(EmployeeFunctions(name = "EmployeeFunctions"))
[Link] = SlideTransition(direction = "left")
[Link] = "EmployeeFunctions"

# Some tasks before the running the file


kv = Builder.load_file("[Link]")
sm = WindowManager(transition = SlideTransition())
screens = [
GetStarted(name="GetStarted"), ConstantFixing(name="ConstantFixing"),
AdminSignUp(name="AdminSignUp"), DoctorSignUp(name="DoctorSignUp"),
PatientSignUp(name="PatientSignUp"), EmployeeSignUp(name="EmployeeSignUp"),
AdminLogin(name="AdminLogin"), DoctorLogin(name="DoctorLogin"),
PatientLogin(name="PatientLogin"), EmployeeLogin(name="EmployeeLogin"),
AboutHospital(name="AboutHospital"), Documentation(name="Documentation"),
AdminAfterLogin(name="AdminAfterLogin"),
AdminAboutHospital(name="AdminAboutHospital"),
AdminDocumentation(name="AdminDocumentation"),
DoctorAfterLogin(name="DoctorAfterLogin"),
DoctorAboutHospital(name="DoctorAboutHospital"),
DoctorDocumentation(name="DoctorDocumentation"),
PatientAfterLogin(name="PatientAfterLogin"),
PatientAboutHospital(name="PatientAboutHospital"),
PatientDocumentation(name="PatientDocumentation"),
EmployeeAfterLogin(name="EmployeeAfterLogin"),
EmployeeAboutHospital(name="EmployeeAboutHospital"),
EmployeeDocumentation(name="EmployeeDocumentation"),
Profile(name="Profile"), Notifications(name="Notifications"),
AddNotifications(name="AddNotifications"), Settings(name="Settings")
]
for screen in screens:
sm.add_widget(screen)
[Link] = "GetStarted"

# Main Class
class HMSApp(App):
def build(self):
[Link] = (1,1,1,1)
return sm

# Running the entire file


if __name__ == "__main__":
HMSApp().run()

[Link]
import psycopg2
import os
from getpass import getpass
from DB_config import config
import datetime

def DB_pass(username, category):


with [Link](**config()) as find_pass:
cur1 = find_pass.cursor()
[Link](f"""
SELECT password FROM {category} WHERE username =
'{[Link]()}';
""")
rows = [Link]()
[Link]()
find_pass.close()
return rows[0][0]

def login(category, username, password):


logged_in = False
if password == DB_pass(username,category):
logged_in = True
return logged_in

def signup(category, *args):


if category == "admin":
username, fullname, email, date_of_birth, password = args
date_of_birth = [Link](date_of_birth,"%Y-%m-%d")
notifications = "Logged in"

with [Link](**config()) as default_admin:


cur0 = default_admin.cursor()
[Link]("""
INSERT INTO admin (
username,
fullname,
email,
date_of_birth,
password,
notifications
)
VALUES (
%s, %s, %s, DATE %s, %s, %s
) ON CONFLICT(username) DO NOTHING;
""", (username, fullname, email, date_of_birth, password,
notifications))

elif category == "doctor":


username, fullname, email, date_of_birth, password, specialty, price =
args
date_of_birth = [Link](date_of_birth.strip(),"%Y-%m-
%d")
notifications = "Logged in"

with [Link](**config()) as doctor_signup:


cur1 = doctor_signup.cursor()
[Link]("""
INSERT INTO doctor (
username,
fullname,
email,
date_of_birth,
password,
specialty,
price,
notifications
)
VALUES (
%s, %s, %s, DATE %s, %s, %s, %s, %s
) ON CONFLICT(username) DO NOTHING;
""", (username, fullname, email, date_of_birth, password, specialty,
price, notifications))
print([Link])
print("Successfully Signed Up")
[Link]()
doctor_signup.commit()
doctor_signup.close()

elif category == "patient":


username, fullname, email, date_of_birth, password, problem = args
date_of_birth = [Link](date_of_birth.strip(),"%Y-%m-
%d")
reports = "(initial_registration+
+This_frontend_url_will_be_generated_automatically)"
notifications = "Logged in"
requested_doctor_username = None
appointment_timestamp = None
approved_doctor_username = "hpt"

with [Link](**config()) as patient_signup:


cur1 = patient_signup.cursor()
[Link]("""
INSERT INTO patient (
username,
fullname,
email,
date_of_birth,
password,
problem,
requested_doctor_username,
approved_doctor_username,
appointment_timestamp,
reports,
notifications
)
VALUES (
%s, %s, %s, DATE %s, %s, %s, %s, %s, %s, %s, %s
) ON CONFLICT(username) DO NOTHING;
""", (username, fullname, email, date_of_birth, password, problem,
requested_doctor_username, approved_doctor_username, appointment_timestamp,
reports, notifications))
print([Link])
print("Successfully Signed Up")
[Link]()
patient_signup.commit()
patient_signup.close()

else:
username, fullname, email, date_of_birth, password, work, salary = args
date_of_birth = [Link](date_of_birth.strip(),"%Y-%m-
%d")
work_of_doctors = "hpt"
notifications = "Logged in"

with [Link](**config()) as employee_signup:


cur1 = employee_signup.cursor()
[Link]("""
INSERT INTO employee (
username,
fullname,
email,
date_of_birth,
password,
work,
work_of_doctors,
salary,
notifications
)
VALUES (
%s, %s, %s, DATE %s, %s, %s, %s, %s, %s
);
""", (username, fullname, email, date_of_birth, password, work,
work_of_doctors, salary, notifications))
print([Link])
print("Successfully Signed Up")
[Link]()
employee_signup.commit()
employee_signup.close()

return True

[Link]
import psycopg2
import os
import doctor
import patient
import employee
import login
import admin
import constant
import setup_engine
import backup_restore
import kivy

print([Link].__version__)

[Link]
import psycopg2
from constant import grab_constant
from DB_config import config
import datetime

def remaining_appointment_time(username, logged_in):


if logged_in:
with [Link](**config()) as remaining:
cur1 = [Link]()
[Link]("""
SELECT appointment_timestamp FROM patient WHERE username = %s;
""", [username])
appointment_timestamp = [Link]()[0][0]
if appointment_timestamp != None:
remaining_time = appointment_timestamp - [Link]()
else:
remaining_time = "Your appointment isn't fixed yet."
[Link]()
[Link]()
return remaining_time

def recent_notifications(username, logged_in, limit = 1):


if logged_in:
with [Link](**config()) as latest:
cur1 = [Link]()
[Link]("""
SELECT notifications FROM patient WHERE username = %s;
""", [username])
notifications_string = [Link]()[0][0]
list_of_notifications = notifications_string.split(", ")
[Link]()
[Link]()
return list_of_notifications[-limit:] if limit <
len(list_of_notifications) else list_of_notifications[-
len(list_of_notifications):]

def notify_admin(notification, my_username, admin_username, logged_in):


if logged_in:
with [Link](**config()) as add_notifications:
cur1 = add_notifications.cursor()
[Link](f"""
SELECT notifications FROM admin WHERE username =
'{admin_username}';
""")
notifications_string = [Link]()[0][0]
list_of_notifications = notifications_string.split(", ")
notification = "From: " + my_username + " " + notification
list_of_notifications.append(notification)
new_notifications_string = ", ".join(list_of_notifications)
[Link]()
cur2 = add_notifications.cursor()
[Link](f"""
UPDATE admin SET notifications = '{new_notifications_string}'
WHERE username = '{admin_username}';
""")
print([Link])
[Link]()
add_notifications.commit()
add_notifications.close()
return "Notification Added"

def cost(username, logged_in):


if logged_in:
with [Link](**config()) as total_cost:
cur1 = total_cost.cursor()
[Link]("""
SELECT approved_doctor_username FROM patient WHERE username =
%s;
""", [username])
approved_doctor_username = [Link]()[0][0]
print(approved_doctor_username)
[Link]()

cur2 = total_cost.cursor()
if approved_doctor_username != "hpt":
[Link]("""
SELECT price FROM doctor WHERE username = %s;
""", [approved_doctor_username])
doctors_salary = int([Link]()[0][0])
final_cost = (doctors_salary * (100 +
int(grab_constant(True,"CUT_FROM_PATIENT"))))//100
else:
doctors_salary = 0
final_cost = 0

total_cost.close()
hospital_cost = final_cost - doctors_salary

return (doctors_salary, hospital_cost, final_cost)

def add_report(report_name, report_url, username, logged_in):


if logged_in:
with [Link](**config()) as add_reports:
cur1 = add_reports.cursor()
[Link]("""
SELECT reports FROM patient WHERE username = %s;
""", [username])
reports_string = [Link]()[0][0]
reports_info = "(" + report_name + "++" + report_url + ")"
reports_string += "+++" + str(reports_info)
[Link]()
cur2 = add_reports.cursor()
[Link]("""
UPDATE patient SET reports = %s WHERE username = %s;
""", [reports_string, username])
print([Link])
[Link]()
add_reports.commit()
add_reports.close()
return "Report Added"

def see_all_doctors_for_my_problem(username, logged_in):


if logged_in:
with [Link](**config()) as doctors_as_problem:
cur1 = doctors_as_problem.cursor()
[Link]("""
SELECT problem FROM patient WHERE username = %s;
""", [username])
problem = [Link]()[0][0]
[Link]()

cur2 = doctors_as_problem.cursor()
[Link]("""
SELECT username, fullname, email, date_of_birth, price FROM
doctor WHERE specialty = %s;
""", [problem])
rows = [Link]()
# print part
# for row in rows:
# print("Username:", row[0], "\tFullname:", row[1], "\tEmail:",
row[2], "\tPrice:", row[3])
[Link]()
doctors_as_problem.close()
return rows

def request_doctor(my_username, doctor_username, logged_in):


if logged_in:
with [Link](**config()) as requesting_doctor:
cur1 = requesting_doctor.cursor()
[Link]("""
UPDATE patient SET requested_doctor_username = %s WHERE username
= %s;
""", [doctor_username, my_username])
print([Link])
[Link]()
requesting_doctor.commit()
requesting_doctor.close()
return "Successfully Requested"

def remove_request(my_username, logged_in):


if logged_in:
with [Link](**config()) as removing_request:
cur1 = removing_request.cursor()
[Link]("""
UPDATE patient SET requested_doctor_username = NULL WHERE
username = %s;
""", [my_username])
print([Link])
[Link]()
removing_request.commit()
removing_request.close()
return "Request Removed"

def see_my_doctors_stat(username, logged_in):


if logged_in:
with [Link](**config()) as my_doctor:
cur1 = my_doctor.cursor()
[Link]("""
SELECT approved_doctor_username, appointment_timestamp FROM
patient WHERE username = %s;
""", [username])
temp = [Link]()[0]
approved_doctor_username = temp[0]
appointment_timestamp = temp[1]
[Link]()

cur2 = my_doctor.cursor()
[Link]("""
SELECT username, fullname, email, date_of_birth, specialty,
price FROM doctor WHERE username = %s;
""", [approved_doctor_username])

rows = list([Link]()[0])
[Link](appointment_timestamp)
# print part
# for row in rows:
# print("Doctor's Information")
# print("Fullname:", row[1])
# print("Email:", row[2])
# print("specialty:", row[3])
# print("Price:", row[4])
# print("Appointment Timestamp:", row[5])
[Link]()
my_doctor.close()
return rows

setup_engine.py
import psycopg2
from [Link] import ISOLATION_LEVEL_AUTOCOMMIT
import constant
from DB_config import config, admin_config
from backup_restore import restore_from_csv

def start_program():
delete_database(True,True)
create_database(True)
delete_admin_table(True,True)
create_admin_table(True)
delete_doctor_table(True,True)
create_doctor_table(True)
delete_employee_table(True,True)
create_employee_table(True)
delete_patient_table(True,True)
create_patient_table(True)
add_unique_constraint(True)
add_check_constraint(True)
restore_from_csv(True)
return "You are ready to go!"

def create_database(logged_in):
if logged_in:
with [Link](**admin_config()) as database_creator:
database_creator.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT)
cur1 = database_creator.cursor()
[Link]("""
CREATE DATABASE hms;
""")
print([Link])
[Link]()
database_creator.commit()
database_creator.close()
return "Database Created"

def delete_database(logged_in, final_decision = False):


if final_decision and logged_in:
with [Link](**admin_config()) as database_deleter:
database_deleter.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT)
cur1 = database_deleter.cursor()
[Link]("""
DROP DATABASE IF EXISTS hms;
""")
print([Link])
[Link]()
database_deleter.commit()
database_deleter.close()
return "Database Deleted"

def create_admin_table(logged_in):
if logged_in:
with [Link](**config()) as create_admin:
cur1 = create_admin.cursor()
[Link]("""
CREATE TABLE admin (
username VARCHAR(5) NOT NULL PRIMARY KEY,
fullname TEXT NOT NULL,
email VARCHAR(32) NOT NULL,
date_of_birth DATE NOT NULL,
password VARCHAR(15) NOT NULL,
notifications TEXT NOT NULL
);
""")
print([Link])
[Link]()
create_admin.commit()
create_admin.close()
return "Admin Table Created"

def delete_admin_table(logged_in, final_decision = False):


if final_decision and logged_in:
with [Link](**config()) as delete_admin:
cur0 = delete_admin.cursor()
[Link]("""
DROP TABLE IF EXISTS admin;
""")
print([Link])
[Link]()
delete_admin.commit()
delete_admin.close()
return "Admin Table Deleted"

def create_doctor_table(logged_in):
if logged_in:
with [Link](**config()) as create_doctor:
cur1 = create_doctor.cursor()
[Link]("""
CREATE TABLE doctor (
username VARCHAR(5) NOT NULL PRIMARY KEY,
fullname TEXT NOT NULL,
email VARCHAR(32) NOT NULL,
date_of_birth DATE NOT NULL,
password VARCHAR(5) NOT NULL,
specialty TEXT NOT NULL,
price INT NOT NULL,
notifications TEXT NOT NULL
);
""")
print([Link])
[Link]()
create_doctor.commit()
create_doctor.close()
return "Doctor Table Created"

def delete_doctor_table( logged_in, final_decision = False):


if final_decision and logged_in:
with [Link](**config()) as delete_doctor:
cur0 = delete_doctor.cursor()
[Link]("""
DROP TABLE IF EXISTS doctor;
""")
print([Link])
[Link]()
delete_doctor.commit()
delete_doctor.close()
return "Doctor Table Deleted"

def create_patient_table(logged_in):
if logged_in:
with [Link](**config()) as create_patient:
cur1 = create_patient.cursor()
[Link]("""
CREATE TABLE patient (
username VARCHAR(5) NOT NULL PRIMARY KEY,
fullname TEXT NOT NULL,
email VARCHAR(32) NOT NULL,
date_of_birth DATE NOT NULL,
password VARCHAR(5) NOT NULL,
problem TEXT NOT NULL,
requested_doctor_username VARCHAR(5),
approved_doctor_username VARCHAR(5) REFERENCES doctor
(username),
appointment_timestamp TIMESTAMP,
reports TEXT,
notifications TEXT NOT NULL
);
""")
print([Link])
[Link]()
create_patient.commit()
create_patient.close()
return "Patient Table Created"
def delete_patient_table(logged_in, final_decision = False):
if final_decision and logged_in:
with [Link](**config()) as delete_patient:
cur0 = delete_patient.cursor()
[Link]("""
DROP TABLE IF EXISTS patient;
""")
print([Link])
[Link]()
delete_patient.commit()
delete_patient.close()
return "Patient Table Deleted"

def create_employee_table(logged_in):
if logged_in:
with [Link](**config()) as create_employee:
cur1 = create_employee.cursor()
[Link]("""
CREATE TABLE employee (
username VARCHAR(5) NOT NULL PRIMARY KEY,
fullname TEXT NOT NULL,
email VARCHAR(32) NOT NULL,
date_of_birth DATE NOT NULL,
password VARCHAR(5) NOT NULL,
work TEXT NOT NULL,
work_of_doctors TEXT,
salary INT NOT NULL,
notifications TEXT NOT NULL
);
""")
print([Link])
[Link]()
create_employee.commit()
create_employee.close()
return "Employee Table Created"

def delete_employee_table(logged_in, final_decision = False):


if final_decision and logged_in:
with [Link](**config()) as delete_employee:
cur0 = delete_employee.cursor()
[Link]("""
DROP TABLE IF EXISTS employee;
""")
print([Link])
[Link]()
delete_employee.commit()
delete_employee.close()
return "Employee Table Deleted"

def add_unique_constraint(logged_in):
if logged_in:
with [Link](**config()) as admin_constraint:
cur1 = admin_constraint.cursor()
[Link]("""
ALTER TABLE admin ADD CONSTRAINT unique_admin_email
UNIQUE(email);
""")
[Link]()
admin_constraint.commit()
admin_constraint.close()

with [Link](**config()) as doctor_constraint:


cur1 = doctor_constraint.cursor()
[Link]("""
ALTER TABLE doctor ADD CONSTRAINT unique_doctor_email
UNIQUE(email);
""")
[Link]()
doctor_constraint.commit()
doctor_constraint.close()

with [Link](**config()) as employee_constraint:


cur1 = employee_constraint.cursor()
[Link]("""
ALTER TABLE employee ADD CONSTRAINT unique_employee_email
UNIQUE(email);
""")
[Link]()
employee_constraint.commit()
employee_constraint.close()

with [Link](**config()) as patient_constraint:


cur1 = patient_constraint.cursor()
[Link]("""
ALTER TABLE patient ADD CONSTRAINT unique_patient_email
UNIQUE(email);
""")
[Link]()
patient_constraint.commit()
patient_constraint.close()

def add_check_constraint(logged_in):
if logged_in:
with [Link](**config()) as doctor_salary_constraint:
cur1 = doctor_salary_constraint.cursor()
[Link](f"""
ALTER TABLE doctor ADD CONSTRAINT doctor_price_check_constraint
CHECK(price < {int(constant.grab_constant(True,"DOCTOR_MAX_CHECKUP_PRICE"))})
""")
doctor_salary_constraint.commit()
doctor_salary_constraint.close()

with [Link](**config()) as employee_salary_constraint:


cur1 = employee_salary_constraint.cursor()
[Link](f"""
ALTER TABLE employee ADD CONSTRAINT
employee_salary_check_constraint CHECK(salary <
{int(constant.grab_constant(True,"EMPLOYEE_MAX_SALARY"))})
""")
employee_salary_constraint.commit()
employee_salary_constraint.close()

You might also like