├── .gitignore
├── .vscode
├── launch.json
└── settings.json
├── DB_config.py
├── Documentation.pdf
├── LICENSE
├── README.md
├── admin.py
├── backup_&_restore_folder
├── admin.csv
├── constant.csv
├── doctor.csv
├── employee.csv
└── patient.csv
├── backup_restore.py
├── constant.py
├── doctor.py
├── employee.py
├── frontend.kv
├── frontend.py
├── login.py
├── main.py
├── patient.py
├── poster.jpg
├── requirements.txt
├── resources
├── GENERATOR.pptx
├── add_notifications.png
├── add_notifications_down.png
├── carousel1.png
├── carousel2.png
├── carousel3.png
├── close.png
├── close_down.png
├── docs.png
├── docs_down.png
├── documentation_class.png
├── functions.png
├── functions_down.png
├── hms_logo.png
├── hospital.png
├── hospital_down.png
├── hospital_illus.jpg
├── notifications.png
├── notifications_down.png
├── notifications_pic.png
├── profile.png
├── profile_down.png
├── profile_pic.jpg
├── settings.jpg
├── settings_down.jpg
├── settings_pic.png
├── short_logo.png
├── ss1.png
├── ss2.png
├── ss3.png
├── ss4.png
├── ss5.png
└── ss6.png
└── setup_engine.py
/.gitignore:
--------------------------------------------------------------------------------
1 | # Byte-compiled / optimized / DLL files
2 | __pycache__/
3 | *.py[cod]
4 | *$py.class
5 |
6 | # C extensions
7 | *.so
8 |
9 | # Distribution / packaging
10 | .Python
11 | build/
12 | develop-eggs/
13 | dist/
14 | downloads/
15 | eggs/
16 | .eggs/
17 | lib/
18 | lib64/
19 | parts/
20 | sdist/
21 | var/
22 | wheels/
23 | pip-wheel-metadata/
24 | share/python-wheels/
25 | *.egg-info/
26 | .installed.cfg
27 | *.egg
28 | MANIFEST
29 |
30 | # PyInstaller
31 | # Usually these files are written by a python script from a template
32 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
33 | *.manifest
34 | *.spec
35 |
36 | # Installer logs
37 | pip-log.txt
38 | pip-delete-this-directory.txt
39 |
40 | # Unit test / coverage reports
41 | htmlcov/
42 | .tox/
43 | .nox/
44 | .coverage
45 | .coverage.*
46 | .cache
47 | nosetests.xml
48 | coverage.xml
49 | *.cover
50 | *.py,cover
51 | .hypothesis/
52 | .pytest_cache/
53 |
54 | # Translations
55 | *.mo
56 | *.pot
57 |
58 | # Django stuff:
59 | *.log
60 | local_settings.py
61 | db.sqlite3
62 | db.sqlite3-journal
63 |
64 | # Flask stuff:
65 | instance/
66 | .webassets-cache
67 |
68 | # Scrapy stuff:
69 | .scrapy
70 |
71 | # Sphinx documentation
72 | docs/_build/
73 |
74 | # PyBuilder
75 | target/
76 |
77 | # Jupyter Notebook
78 | .ipynb_checkpoints
79 |
80 | # IPython
81 | profile_default/
82 | ipython_config.py
83 |
84 | # pyenv
85 | .python-version
86 |
87 | # pipenv
88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies
90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not
91 | # install all needed dependencies.
92 | #Pipfile.lock
93 |
94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow
95 | __pypackages__/
96 |
97 | # Celery stuff
98 | celerybeat-schedule
99 | celerybeat.pid
100 |
101 | # SageMath parsed files
102 | *.sage.py
103 |
104 | # Environments
105 | .env
106 | .venv
107 | env/
108 | venv/
109 | ENV/
110 | env.bak/
111 | venv.bak/
112 |
113 | # Spyder project settings
114 | .spyderproject
115 | .spyproject
116 |
117 | # Rope project settings
118 | .ropeproject
119 |
120 | # mkdocs documentation
121 | /site
122 |
123 | # mypy
124 | .mypy_cache/
125 | .dmypy.json
126 | dmypy.json
127 |
128 | # Pyre type checker
129 | .pyre/
130 |
--------------------------------------------------------------------------------
/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5 | "version": "0.2.0",
6 | "configurations": [
7 | {
8 | "name": "Python: Current File",
9 | "type": "python",
10 | "request": "launch",
11 | "program": "${file}",
12 | "console": "integratedTerminal"
13 | }
14 | ]
15 | }
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "sqltools.connections": [
3 | {
4 | "previewLimit": 50,
5 | "server": "localhost",
6 | "port": 5432,
7 | "askForPassword": true,
8 | "driver": "PostgreSQL",
9 | "name": "Hospital Management System",
10 | "database": "hms",
11 | "username": "postgres"
12 | }
13 | ]
14 | }
--------------------------------------------------------------------------------
/DB_config.py:
--------------------------------------------------------------------------------
1 | import constant
2 | HOST = constant.grab_constant(True,"HOST")
3 | PORT = int(constant.grab_constant(True,"PORT"))
4 | ADMIN_DATABASE = constant.grab_constant(True,"ADMIN_DATABASE")
5 | DATABASE = constant.grab_constant(True,"DATABASE")
6 | USER = constant.grab_constant(True,"USER")
7 | PASSWORD = constant.grab_constant(True,"PASSWORD")
8 |
9 |
10 | def admin_config():
11 | config_dict = {"host":HOST, "port":PORT, "database":ADMIN_DATABASE, "user":USER, "password":PASSWORD}
12 | return config_dict
13 |
14 |
15 | def config():
16 | config_dict = {"host":HOST, "port":PORT, "database":DATABASE, "user":USER, "password":PASSWORD}
17 | return config_dict
--------------------------------------------------------------------------------
/Documentation.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahammadshawki8/Hospital-Management-System/de0c1bce97f57ceeae301e034d383a522fe67939/Documentation.pdf
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 Ahammad Shawki
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 
2 | # Hospital-Management-System
3 | 🏥 The hospital management system (HMS) is integrated software that handles different directions of clinic workflows. It manages the smooth healthcare performance along with administrative, medical, legal, and financial control. That is a cornerstone for the successful operation of the healthcare facility.
4 |
5 | This application has both the backend and the frontend part of a hospital management system. You can use the backend application if you have any frontend graphical user interface of a hospital management system. In that case, you will need to use the [main.py](main.py) file for glue code. This HMS application is completely designed in Python for specifically PostgreSQL Database.
6 |
7 | Psycopg2 and Kivy module is used for creating the database connection and frontend part. Here different algorithms have been implanted from the developer’s point of view. It is suitable for a mid-level hospital or clinic. Working strategy plays a vital role to keep this application running smoothly.
8 |
9 | *If you want to use this application in your project, first [contact me](mailto:@ahammadshawki8@gmail.com).*
10 |
11 |
12 |
13 | # How to use
14 | - Download the frameworks and libraries mentioned in [requirements.txt](requirements.txt)
15 | - Download the [zip file](https://codeload.github.com/ahammadshawki8/Hospital-Management-System/zip/main) of this repository
16 | - See the [demo]() video
17 | - Run the [frontend.py](frontend.py) file
18 | - Enjoy using this application
19 | - If you find any difficulty or have any suggestion for future updates, create an [issue](https://github.com/ahammadshawki8/Hospital-Management-System/issues)
20 |
21 |
22 |
23 | # Modules & Functions
24 | ## [main.py](main.py)
25 | - Have zero function, will be used for glue code.
26 | ## [constant.py](constant.py)
27 | - grab_constant
28 | - set_constant
29 |
30 | ## [DB_config.py](DB_config.py)
31 | - admin_config
32 | - config
33 |
34 | ## [backup_restore.py](backup_restore.py)
35 | - backup_to_csv
36 | - restore_from_csv
37 |
38 | ## [setup_engine](setup_engine.py)
39 | - start_program
40 | - create_database
41 | - delete_database
42 | - create_admin_table
43 | - delete_admin_table
44 | - create_doctor_table
45 | - delete_doctor_table
46 | - create_patient_table
47 | - delete_patient_table
48 | - create_employee_table
49 | - delete_employee_table
50 | - add_unique_constraint
51 | - add_check_constraint
52 |
53 | ## [login.py](login.py)
54 | - DB_pass
55 | - login
56 | - signup
57 |
58 | ## [admin.py](admin.py)
59 | - see_info
60 | - update_db
61 | - recent_notifications
62 | - add_notification
63 | - total_earning
64 | - add_employee
65 | - see_my_employee
66 | - remove_employee
67 | - show_all_doctor
68 | - show_all_patient
69 | - show_all_employee
70 | - all_doctor_username
71 | - all_patient_username
72 | - all_employee_username
73 | - remove_doctor_parmanently
74 | - remove_patient_parmanently
75 | - remove_employee_parmanently
76 | - patient_joins_doctor
77 |
78 | ## [doctor.py](doctor.py)
79 | - recent_notifications
80 | - notify_admin
81 | - salary
82 | - show_all_employee
83 | - add_employee
84 | - see_my_employee
85 | - remove_employee
86 | - see_all_requested_patient
87 | - see_all_patients_of_my_speciality
88 | - see_my_patient
89 | - see_patients_report
90 | - remove_patient
91 |
92 | ## [patient.py](patient.py)
93 | - remaining_appointment_time
94 | - recent_notifications
95 | - notify_admin
96 | - cost
97 | - add_report
98 | - see_all_doctors_for_my_problem
99 | - request_doctor
100 | - remove_request
101 | - see_my_doctors_stat
102 |
103 | ## [employee.py](employee.py)
104 | - recent_notifications
105 | - notify_admin
106 | - salary
107 | - isreceptionist
108 | - appoint_doctor
109 | - see_my_doctors
110 |
111 | ## [frontend.py](frontend.py) & [frontend.kv](frontend.kv)
112 | - used for the frontend part, contains multiple classes and functions and also glue code.
113 |
114 | ## [resources](resorces/)
115 | - contains images and other resources
116 |
117 | ## [backup_&_restore_folder](backup_&_restore_folder)
118 | - contains multiple csv file which is vital for the backup and restore process of the application.
119 |
120 |
121 |
122 | # License
123 | Details can be found in [LICENSE](LICENSE)
124 |
125 |
126 |
127 | # Some ScreenShots
128 | 
129 |
130 |
131 | 
132 |
133 |
134 | 
135 |
136 |
137 | 
138 |
139 |
140 | 
141 |
142 |
143 | 
144 |
--------------------------------------------------------------------------------
/admin.py:
--------------------------------------------------------------------------------
1 | import psycopg2
2 | from doctor import salary as doctor_salary
3 | from patient import cost as patient_cost
4 | from employee import salary as employee_salary
5 | from DB_config import config
6 | import constant
7 |
8 |
9 | def see_info(logged_in,category,username):
10 | if logged_in:
11 | username = username.strip().lower()
12 | with psycopg2.connect(**config()) as info_check:
13 | cur1 = info_check.cursor()
14 | cur1.execute(f"""
15 | SELECT * FROM {category} WHERE username = '{username}';
16 | """)
17 | info = cur1.fetchall()
18 | cur1.close()
19 | info_check.close()
20 | return info
21 |
22 |
23 | def update_db(category, username, fieldname, updated_value, logged_in):
24 | if logged_in:
25 | date = "DATE" if fieldname == "date_of_birth" else ""
26 | with psycopg2.connect(**config()) as updating:
27 | cur1 = updating.cursor()
28 | cur1.execute(f"""
29 | UPDATE {category} SET {fieldname} = '{updated_value}' WHERE username = {date}'{username}';
30 | """)
31 | print(cur1.statusmessage)
32 | cur1.close()
33 | updating.commit()
34 | updating.close()
35 | return "Database Updated"
36 |
37 |
38 | def recent_notifications(username, logged_in, limit = 1):
39 | if logged_in:
40 | with psycopg2.connect(**config()) as latest:
41 | cur1 = latest.cursor()
42 | cur1.execute("""
43 | SELECT notifications FROM admin WHERE username = %s;
44 | """, [username])
45 | notifications_string = cur1.fetchall()[0][0]
46 | list_of_notifications = notifications_string.split(", ")
47 | cur1.close()
48 | latest.close()
49 | return list_of_notifications[-limit:] if limit < len(list_of_notifications) else list_of_notifications[-len(list_of_notifications):]
50 |
51 |
52 | def add_notification(notification, category, receiver_username, logged_in):
53 | if logged_in:
54 | with psycopg2.connect(**config()) as add_notifications:
55 | cur1 = add_notifications.cursor()
56 | cur1.execute(f"""
57 | SELECT notifications FROM {category} WHERE username = '{receiver_username}';
58 | """)
59 | notifications_string = cur1.fetchall()[0][0]
60 | list_of_notifications = notifications_string.split(", ")
61 | list_of_notifications.append(notification)
62 | new_notifications_string = ", ".join(list_of_notifications)
63 | cur1.close()
64 | cur2 = add_notifications.cursor()
65 | cur2.execute(f"""
66 | UPDATE {category} SET notifications = '{new_notifications_string}' WHERE username = '{receiver_username}';
67 | """)
68 | print(cur2.statusmessage)
69 | cur2.close()
70 | add_notifications.commit()
71 | add_notifications.close()
72 | return "Notification Added"
73 |
74 |
75 | def total_earning(logged_in):
76 | if logged_in:
77 | initial_earning = 0
78 | with psycopg2.connect(**config()) as earning:
79 | cur1 = earning.cursor()
80 | cur1.execute("""
81 | SELECT username FROM employee;
82 | """)
83 | list_of_employee = cur1.fetchall()
84 | cur1.close()
85 | earned_from_employee = 0
86 | for row in list_of_employee:
87 | earned_from_employee += int(employee_salary(row[0],True)[1])
88 | initial_earning += earned_from_employee
89 | cur2 = earning.cursor()
90 | cur2.execute("""
91 | SELECT username FROM patient;
92 | """)
93 | list_of_patient = cur2.fetchall()
94 | cur2.close()
95 | earned_from_patient = 0
96 | for row in list_of_patient:
97 | earned_from_patient += int(patient_cost(row[0],True)[1])
98 | initial_earning += earned_from_patient
99 | initial_earning -= int(constant.grab_constant(True,"FIXED_COST_OF_HOSPITAL"))
100 |
101 | given_to_employees = 0
102 | cur3 = earning.cursor()
103 | cur3.execute("""
104 | SELECT salary FROM employee WHERE work_of_doctors LIKE '%admin%';
105 | """)
106 | salary_list = cur3.fetchall()
107 | for salary in salary_list:
108 | given_to_employees += int(salary[0])
109 | cur3.close()
110 | initial_earning -= given_to_employees
111 |
112 | employee_pre_salary = int(doctor_salary("hpt", True)[1])
113 | initial_earning -= employee_pre_salary
114 |
115 | earning.close()
116 | return (earned_from_employee, earned_from_patient, int(constant.grab_constant(True,"FIXED_COST_OF_HOSPITAL")), employee_pre_salary, given_to_employees, initial_earning)
117 |
118 |
119 | def add_employee(employee_username, logged_in):
120 | if logged_in:
121 | with psycopg2.connect(**config()) as adding_employee:
122 | cur0 = adding_employee.cursor()
123 | cur0.execute("""
124 | SELECT work_of_doctors FROM employee WHERE username = %s;
125 | """, [employee_username])
126 |
127 | work_of_doctors = cur0.fetchall()[0][0]
128 | work_of_doctors += ", " + "admin"
129 | cur0.close()
130 |
131 | cur1 = adding_employee.cursor()
132 | cur1.execute("""
133 | UPDATE employee SET work_of_doctors = %s WHERE username = %s;
134 | """, [work_of_doctors, employee_username])
135 | print(cur1.statusmessage)
136 | cur1.close()
137 | adding_employee.commit()
138 | adding_employee.close()
139 | return "Employee Added"
140 |
141 |
142 | def see_my_employee(logged_in):
143 | if logged_in:
144 | with psycopg2.connect(**config()) as my_employee:
145 | cur1 = my_employee.cursor()
146 | cur1.execute("""
147 | SELECT username, fullname, email, date_of_birth, work, salary FROM employee WHERE work_of_doctors LIKE '%admin%'
148 | """)
149 | list_of_employees = cur1.fetchall()
150 | # print part
151 | # for row in list_of_employees:
152 | # print("Username:", row[0], "\tFullname:", row[1], "\tEmail:", row[2], "\tWork:", row[3], "\tSalary:", row[4])
153 | cur1.close()
154 | my_employee.close()
155 | return list_of_employees
156 |
157 |
158 | def remove_employee(employee_username, logged_in):
159 | if logged_in:
160 | with psycopg2.connect(**config()) as removing_employee:
161 | cur0 = removing_employee.cursor()
162 | cur0.execute("""
163 | SELECT work_of_doctors FROM employee WHERE username = %s;
164 | """, [employee_username])
165 |
166 | work_of_doctors_string = cur0.fetchall()[0][0]
167 | work_of_doctors_list = work_of_doctors_string.split(", ")
168 |
169 | work_of_doctors_list.remove("admin")
170 | new_work_of_doctors_string = ", ".join(work_of_doctors_list)
171 | cur0.close()
172 |
173 | cur1 = removing_employee.cursor()
174 | cur1.execute("""
175 | UPDATE employee SET work_of_doctors = %s WHERE username = %s;
176 | """, [new_work_of_doctors_string, employee_username])
177 | print(cur1.statusmessage)
178 | cur1.close()
179 | removing_employee.commit()
180 | removing_employee.close()
181 | return "Employee Removed"
182 |
183 |
184 | def show_all_doctor(logged_in):
185 | if logged_in:
186 | with psycopg2.connect(**config()) as doctor:
187 | cur1 = doctor.cursor()
188 | cur1.execute("""
189 | SELECT username, fullname, email, date_of_birth, specialty, price FROM doctor;
190 | """)
191 | rows = cur1.fetchall()
192 | new_rows = []
193 | for row in rows:
194 | row = list(row)
195 | row.append(doctor_salary(row[0],True)[2])
196 | new_rows.append(row)
197 | # print(part)
198 | # for row in rows:
199 | # print("Username:", row[0], "\tFullname:", row[1], "\tEmail:", row[2], "\tspecialty:", row[3], "\tPrice:", row[4], "\tTotal Earned:", row[5])
200 | cur1.close()
201 | doctor.close()
202 | return new_rows
203 |
204 |
205 | def show_all_patient(logged_in):
206 | if logged_in:
207 | with psycopg2.connect(**config()) as patient:
208 | cur1 = patient.cursor()
209 | cur1.execute("""
210 | SELECT username, fullname, email, date_of_birth, problem, requested_doctor_username, approved_doctor_username FROM patient;
211 | """)
212 | rows = cur1.fetchall()
213 | new_rows = []
214 | for row in rows:
215 | row = list(row)
216 | row.append(patient_cost(row[0], True)[2])
217 | new_rows.append(row)
218 | # print part
219 | # for row in rows:
220 | # print("Username:", row[0], "\tFullname:", row[1], "\tEmail:", row[2], "\tProblem:", row[3], "\tRequested:", row[4], "\tApproved:", row[5], "\tTotal Cost:", row[6])
221 | cur1.close()
222 | patient.close()
223 | return new_rows
224 |
225 |
226 | def show_all_employee(logged_in):
227 | if logged_in:
228 | with psycopg2.connect(**config()) as employee:
229 | cur1 = employee.cursor()
230 | cur1.execute("""
231 | SELECT username, fullname, email, date_of_birth, work, work_of_doctors, salary FROM employee;
232 | """)
233 | rows = cur1.fetchall()
234 | new_rows = []
235 | for row in rows:
236 | row = list(row)
237 | row.append(employee_salary(row[0],True)[2])
238 | new_rows.append(row)
239 | # print part
240 | # for row in rows:
241 | # print("Username:", row[0], "\tFullname:", row[1], "\tEmail:", row[2], "\tWork:", row[3], "\tDoctors:", row[4], "\tSalary:", row[5], "\tTotal Earned:", row[6])
242 | cur1.close()
243 | employee.close()
244 | return new_rows
245 |
246 |
247 | def all_doctor_username(logged_in):
248 | if logged_in:
249 | with psycopg2.connect(**config()) as doctor:
250 | cur1 = doctor.cursor()
251 | cur1.execute("""
252 | SELECT username FROM doctor;
253 | """)
254 | rows = cur1.fetchall()
255 | new_rows = []
256 | for row in rows:
257 | new_rows.append(row[0])
258 | cur1.close()
259 | doctor.close()
260 | return new_rows
261 |
262 |
263 | def all_patient_username(logged_in):
264 | if logged_in:
265 | with psycopg2.connect(**config()) as patient:
266 | cur1 = patient.cursor()
267 | cur1.execute("""
268 | SELECT username FROM patient;
269 | """)
270 | rows = cur1.fetchall()
271 | new_rows = []
272 | for row in rows:
273 | new_rows.append(row[0])
274 | cur1.close()
275 | patient.close()
276 | return new_rows
277 |
278 |
279 | def all_employee_username(logged_in):
280 | if logged_in:
281 | with psycopg2.connect(**config()) as employee:
282 | cur1 = employee.cursor()
283 | cur1.execute("""
284 | SELECT username FROM employee;
285 | """)
286 | rows = cur1.fetchall()
287 | new_rows = []
288 | for row in rows:
289 | new_rows.append(row[0])
290 | cur1.close()
291 | employee.close()
292 | return new_rows
293 |
294 |
295 | def remove_doctor_parmanently(doctor_username, logged_in, final_decision = False):
296 | if final_decision and logged_in:
297 | with psycopg2.connect(**config()) as remove_doctor:
298 | cur1 = remove_doctor.cursor()
299 | cur1.execute("""
300 | DELETE FROM doctor WHERE username = %s;
301 | """, [doctor_username])
302 | print(cur1.statusmessage)
303 | remove_doctor.commit()
304 | cur1.close()
305 | remove_doctor.close()
306 | return "Doctor Parmanently Removed"
307 |
308 |
309 | def remove_patient_parmanently(patient_username, logged_in, final_decision = False):
310 | if final_decision and logged_in:
311 | with psycopg2.connect(**config()) as remove_patient:
312 | cur1 = remove_patient.cursor()
313 | cur1.execute("""
314 | DELETE FROM patient WHERE username = %s;
315 | """, [patient_username])
316 | print(cur1.statusmessage)
317 | remove_patient.commit()
318 | cur1.close()
319 | remove_patient.close()
320 | return "Patient Parmanently Removed"
321 |
322 |
323 | def remove_employee_parmanently(employee_username, logged_in, final_decision = False):
324 | if final_decision and logged_in:
325 | with psycopg2.connect(**config()) as remove_employee:
326 | cur1 = remove_employee.cursor()
327 | cur1.execute("""
328 | DELETE FROM employee WHERE username = %s;
329 | """, [employee_username])
330 | print(cur1.statusmessage)
331 | remove_employee.commit()
332 | cur1.close()
333 | remove_employee.close()
334 | return "Employee Parmanently Removed"
335 |
336 |
337 | def patient_joins_doctor(logged_in, left = False):
338 | join_type = "LEFT JOIN" if left else "JOIN"
339 | if logged_in:
340 | with psycopg2.connect(**config()) as viewer:
341 | cur_first = viewer.cursor()
342 | cur_first.execute("""
343 | DROP VIEW IF EXISTS final_view;
344 | """)
345 | cur_first.close()
346 | viewer.commit()
347 |
348 | cur0 = viewer.cursor()
349 | cur0.execute("""
350 | DROP VIEW IF EXISTS patient_view;
351 | """)
352 | cur0.close()
353 | viewer.commit()
354 |
355 | cur1 = viewer.cursor()
356 | cur1.execute("""
357 | 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';
358 | """)
359 | cur1.close()
360 |
361 | cur2 = viewer.cursor()
362 | cur2.execute("""
363 | DROP VIEW IF EXISTS doctor_view;
364 | """)
365 | cur2.close()
366 | viewer.commit()
367 |
368 | cur3 = viewer.cursor()
369 | cur3.execute("""
370 | CREATE VIEW doctor_view AS SELECT username AS doctor_username, fullname AS doctor_fullname, email AS doctor_email, specialty, price FROM doctor;
371 | """)
372 | cur3.close()
373 |
374 | viewer.commit()
375 | viewer.close()
376 |
377 | with psycopg2.connect(**config()) as joiner:
378 |
379 | cur1 = joiner.cursor()
380 | cur1.execute(f"""
381 | CREATE VIEW final_view AS (SELECT * FROM patient_view {join_type} doctor_view ON patient_view.approved_doctor_username = doctor_view.doctor_username);
382 | """)
383 | cur1.close()
384 | joiner.commit()
385 | joiner.close()
386 |
387 | with psycopg2.connect(**config()) as final:
388 | cur1 = final.cursor()
389 | cur1.execute("""
390 | SELECT username, fullname, email, problem, appointment_timestamp, doctor_username, doctor_fullname, doctor_email, specialty, price FROM final_view;
391 | """)
392 | rows = cur1.fetchall()
393 | cur1.close()
394 |
395 | # print part
396 | # for row in rows:
397 | # print(row)
398 |
399 | joiner.close()
400 | return rows
--------------------------------------------------------------------------------
/backup_&_restore_folder/admin.csv:
--------------------------------------------------------------------------------
1 | ad1,Hospital Admin,admin@hospital.com,2004-12-28,12345,Logged in
2 |
--------------------------------------------------------------------------------
/backup_&_restore_folder/constant.csv:
--------------------------------------------------------------------------------
1 | HOST,localhost
2 | PORT,5432
3 | ADMIN_DATABASE,postgres
4 | DATABASE,hms
5 | USER,postgres
6 | PASSWORD,12345
7 | CUT_FROM_PATIENT,50
8 | CUT_FROM_EMPLOYEE,20
9 | FIXED_COST_OF_HOSPITAL,5000
10 | PRE_SALARY,10
11 | DOCTOR_MAX_CHECKUP_PRICE,4000
12 | EMPLOYEE_MAX_SALARY,15000
13 | HOSPITAL_YEAR,2004
14 | HOSPITAL_TOTAL_BED,200
15 | HOSPITAL_REMAINING_BED,120
16 | HOSPITAL_TOTAL_EMPLOYEE,16
17 | HOSPITAL_TOTAL_DOCTOR,10
18 | HOSPITAL_TOTAL_PATIENT,2000
19 | HOSPITAL_CURRENT_PATIENT,40
20 | HOSPITAL_MOTTO,serve the nation at large
21 | HOSPITAL_LOCATION,Dhaka-Bangladesh
22 | HOSPITAL_TITLE,The AS8 Hospital
23 | IS_START,1
24 |
--------------------------------------------------------------------------------
/backup_&_restore_folder/doctor.csv:
--------------------------------------------------------------------------------
1 | hpt,Basic Hospital,info@hospital.com,1990-05-01,12345,all,0,This is the default account of hospital.
2 | brm,Byram Marflitt,bmarflitt0@uol.com.br,1990-05-02,YthQS,eye,1000,Logged In
3 | hbt,Hedda Bulteel,hbulteel1@opensource.org,1990-05-03,T3wcY,eye,1500,Logged In
4 | lrc,Lorrin Cruce,lcruce2@dot.gov,1990-05-04,yoTVI,skin,1000,Logged In
5 | jlg,Joletta Gettins,jgettins3@domainmarket.com,1990-05-05,KkZsH,bone,2000,Logged In
6 | coz,Codee Ovize,covize4@friendfeed.com,1990-05-06,zVVsn,internal,1000,Logged In
7 | mrh,Mavra Haggerwood,mhaggerwood5@hibu.com,1990-05-07,plRgV,internal,1000,Logged In
8 | ddb,Danie Dumbreck,ddumbreck6@vk.com,1990-05-08,m1dLP,internal,1000,Logged In
9 | ssc,Scot Sincock,ssincock7@taobao.com,1990-05-09,ISpDJ,brain,2000,Logged In
10 | ehb,Eberhard Brittin,ebrittin8@google.com,1990-05-10,tbpR8,brain,2000,Logged In
11 | btc,Bekki Titchen,btitchen9@w3.org,1990-05-11,4C4zr,skin,1500,Logged In
12 |
--------------------------------------------------------------------------------
/backup_&_restore_folder/employee.csv:
--------------------------------------------------------------------------------
1 | lfb,Lefty Blease,lblease0@tiny.cc,1980-02-01,bf6xP,Receptionist,hpt,4000,Logged In
2 | rbn,Rockey Brignall,rbrignall1@bigcartel.com,1980-02-02,Z5iUz,Receptionist,hpt,4000,Logged In
3 | jch,Jayson Chapelhow,jchapelhow2@vimeo.com,1980-02-03,K2Yja,Cleaner,hpt,2000,Logged In
4 | jjf,Jeanna Jefferies,jjefferies3@google.org,1980-02-04,c3VLv,Cleaner,hpt,2000,Logged In
5 | cfc,Cindi Fincher,cfincher4@joomla.org,1980-02-05,hIFgL,Cleaner,hpt,2000,Logged In
6 | ckc,Coop Kitcatt,ckitcatt5@parallels.com,1980-02-06,2JbzS,Assistant,hpt,4000,Logged In
7 | cdb,Claudette Brace,cbrace6@ustream.tv,1980-02-07,T9zho,Assistant,hpt,4000,Logged In
8 | adb,Alano Boyde,aboyde7@uol.com.br,1980-02-08,H5x7U,Assistant,hpt,4000,Logged In
9 | jnr,Janelle Rooms,jrooms8@cocolog-nifty.com,1980-02-09,QbPB0,Assistant,hpt,4000,Logged In
10 | dmq,Dagmar MacQuist,dmacquist9@goodreads.com,1980-02-10,pCpvI,Assistant,hpt,4000,Logged In
11 | emn,Emelyne McNutt,emcnutta@springer.com,1980-02-11,NL7NG,Nurse,hpt,3500,Logged In
12 | grt,Germain Robotham,grobothamb@techcrunch.com,1980-02-12,b52gT,Guard,hpt,3000,Logged In
13 | rbl,Rey Bailey,rbaileyc@stanford.edu,1980-02-13,YM2RU,Guard,hpt,3000,Logged In
14 | vrn,Vinnie Renard,vrenardd@accuweather.com,1980-02-14,3zrQS,Nurse,hpt,3500,Logged In
15 | vrs,Vanya Rossi,vrossie@uol.com.br,1980-02-15,LR5Kh,Nurse,hpt,3500,Logged In
16 | aha,Ahamed Akbar,ahakbar22@gmail.com,1981-08-19,mike9,Admin,hpt,10000,Logged In
17 |
--------------------------------------------------------------------------------
/backup_&_restore_folder/patient.csv:
--------------------------------------------------------------------------------
1 | nrs,Neron Sutheran,nsutheran0@mediafire.com,1985-04-01,zMou5,eye,,hpt,,(initial_registration++This_frontend_url_will_be_generated_automatically),Logged In
2 | cst,Carson Tansill,ctansill1@nasa.gov,1985-04-02,4MiUo,eye,,hpt,,(initial_registration++This_frontend_url_will_be_generated_automatically),Logged In
3 | lbs,Lambert Shwenn,lshwenn2@solutions.com,1985-04-03,ZHG8c,eye,,hpt,,(initial_registration++This_frontend_url_will_be_generated_automatically),Logged In
4 | bth,Bertrando Hooks,bhooks3@seattletimes.com,1985-04-04,TLbbA,eye,,hpt,,(initial_registration++This_frontend_url_will_be_generated_automatically),Logged In
5 | vgg,Vito Gogan,vgogan4@squarespace.com,1985-04-05,jXtzX,eye,,hpt,,(initial_registration++This_frontend_url_will_be_generated_automatically),Logged In
6 | ctz,Courtney Zupo,czupo5@irs.gov,1985-04-06,DVr6I,eye,,hpt,,(initial_registration++This_frontend_url_will_be_generated_automatically),Logged In
7 | tth,Titus Handrik,thandrik6@baidu.com,1985-04-07,LF0ev,eye,,hpt,,(initial_registration++This_frontend_url_will_be_generated_automatically),Logged In
8 | erc,Emmerich Claxton,eclaxton7@opera.com,1985-04-08,vIIIl,eye,,hpt,,(initial_registration++This_frontend_url_will_be_generated_automatically),Logged In
9 | kml,Karlee Menlove,kmenlove8@businessweek.com,1985-04-09,tICEq,eye,,hpt,,(initial_registration++This_frontend_url_will_be_generated_automatically),Logged In
10 | vdl,Virgie Donnelly,vdonnelly9@google.cn,1985-04-10,r5ipb,eye,,hpt,,(initial_registration++This_frontend_url_will_be_generated_automatically),Logged In
11 | mtc,Maitilde Cereceres,mcereceresa@weather.com,1985-04-11,IGvXp,eye,,hpt,,(initial_registration++This_frontend_url_will_be_generated_automatically),Logged In
12 | abc,Ab Connechy,aconnechyb@va.gov,1985-04-12,f1bFf,eye,,hpt,,(initial_registration++This_frontend_url_will_be_generated_automatically),Logged In
13 | sjr,Sonnnie Jennrich,sjennrichc@dropbox.com,1985-04-13,IoqmB,eye,,hpt,,(initial_registration++This_frontend_url_will_be_generated_automatically),Logged In
14 | zsd,Zola Spurden,zspurdend@rediff.com,1985-04-14,lapXn,skin,,hpt,,(initial_registration++This_frontend_url_will_be_generated_automatically),Logged In
15 | abb,Alaster Budibent,abudibente@mlb.com,1985-04-15,hdcrb,skin,,hpt,,(initial_registration++This_frontend_url_will_be_generated_automatically),Logged In
16 | ccs,Cirillo Simson,csimsonf@merriam-webster.com,1985-04-16,l3EKn,skin,,hpt,,(initial_registration++This_frontend_url_will_be_generated_automatically),Logged In
17 | ggj,Georgeanne Jarman,gjarmang@elpais.com,1985-04-17,lZA7N,skin,,hpt,,(initial_registration++This_frontend_url_will_be_generated_automatically),Logged In
18 | lmq,Lucho MacQueen,lmacqueenh@wufoo.com,1985-04-18,LQh4z,skin,,hpt,,(initial_registration++This_frontend_url_will_be_generated_automatically),Logged In
19 | mwb,Maximilian Winterborne,mbornei@lulu.com,1985-04-19,8MZuC,skin,,hpt,,(initial_registration++This_frontend_url_will_be_generated_automatically),Logged In
20 | rrt,Renae Redington,rredingtonj@smh.com.au,1985-04-20,DG39k,skin,,hpt,,(initial_registration++This_frontend_url_will_be_generated_automatically),Logged In
21 | dmg,Darrick Montgomery,dmontgomery0@google.nl,1985-04-21,jrngD,skin,,hpt,,(initial_registration++This_frontend_url_will_be_generated_automatically),Logged In
22 | ryh,Rayna Huws,rhuws1@lulu.com,1985-04-22,JvETw,internal,,hpt,,(initial_registration++This_frontend_url_will_be_generated_automatically),Logged In
23 | tsc,Torr Scocroft,tscocroft2@time.com,1985-04-23,ICBTW,internal,,hpt,,(initial_registration++This_frontend_url_will_be_generated_automatically),Logged In
24 | bdw,Bendite Wray,bwray3@hexun.com,1985-04-24,LP0vw,internal,,hpt,,(initial_registration++This_frontend_url_will_be_generated_automatically),Logged In
25 | tmr,Tarrah Magrannell,tmagrannell4@163.com,1985-04-25,h5asQ,internal,,hpt,,(initial_registration++This_frontend_url_will_be_generated_automatically),Logged In
26 | mal,Marlo Andreoletti,mandreoletti5@baidu.com,1985-04-26,Z97b7,internal,,hpt,,(initial_registration++This_frontend_url_will_be_generated_automatically),Logged In
27 | mlq,Melamie Quail,mquail6@theatlantic.com,1985-04-27,sKcIp,internal,,hpt,,(initial_registration++This_frontend_url_will_be_generated_automatically),Logged In
28 | stk,Shellie Threlkeld,sthrelkeld7@npr.org,1984-07-01,O5CoT,internal,,hpt,,(initial_registration++This_frontend_url_will_be_generated_automatically),Logged In
29 | pym,Parrnell Yushmanov,pyushmanov8@walmart.com,1984-07-02,yQsCD,internal,,hpt,,(initial_registration++This_frontend_url_will_be_generated_automatically),Logged In
30 | jdn,Jodee Northidge,jnorthidge9@uiuc.edu,1984-07-03,zIJGf,internal,,hpt,,(initial_registration++This_frontend_url_will_be_generated_automatically),Logged In
31 | gbd,Geralda Bernardi,gbernardia@sun.com,1984-07-04,eyUnr,internal,,hpt,,(initial_registration++This_frontend_url_will_be_generated_automatically),Logged In
32 | thf,Taryn Hartford,thartfordb@state.tx.us,1984-07-05,8ZwjC,internal,,hpt,,(initial_registration++This_frontend_url_will_be_generated_automatically),Logged In
33 | wpb,Wandie Philbrick,wphilbrickc@times.co.uk,1984-07-06,zHpJH,internal,,hpt,,(initial_registration++This_frontend_url_will_be_generated_automatically),Logged In
34 | cll,Charlotta Lummus,clummusd@woothemes.com,1984-07-07,qNsLm,brain,,hpt,,(initial_registration++This_frontend_url_will_be_generated_automatically),Logged In
35 | sjs,Stevana Jacobsson,sjacobssone@ucoz.com,1984-07-08,g8sZ5,brain,,hpt,,(initial_registration++This_frontend_url_will_be_generated_automatically),Logged In
36 | cbb,Camellia Banbrigge,cbanbrief@amazon.com,1984-07-09,kDWqM,brain,,hpt,,(initial_registration++This_frontend_url_will_be_generated_automatically),Logged In
37 | sfg,Selene Fillgate,sfillgateg@gov.uk,1984-07-10,AXgld,bone,,hpt,,(initial_registration++This_frontend_url_will_be_generated_automatically),Logged In
38 | shd,Sheff Duce,sduceh@usgs.gov,1984-07-11,ykOuc,bone,,hpt,,(initial_registration++This_frontend_url_will_be_generated_automatically),Logged In
39 | aml,Arabele McLeoid,amcledi@whitehouse.gov,1984-07-12,zlUPS,bone,,hpt,,(initial_registration++This_frontend_url_will_be_generated_automatically),Logged In
40 | nlp,Noelani Paintain,npaintainj@post.com,1984-07-13,CLyh6,bone,,hpt,,(initial_registration++This_frontend_url_will_be_generated_automatically),Logged In
41 |
--------------------------------------------------------------------------------
/backup_restore.py:
--------------------------------------------------------------------------------
1 | import psycopg2
2 | from DB_config import config
3 | from constant import MAIN_FILE
4 |
5 |
6 | def backup_to_csv(logged_in):
7 | if logged_in:
8 | with psycopg2.connect(**config()) as backup:
9 | ADMIN_FILE = os.path.join(MAIN_FILE, "backup_&_restore_folder", "admin.csv")
10 | DOCTOR_FILE = os.path.join(MAIN_FILE, "backup_&_restore_folder", "doctor.csv")
11 | PATIENT_FILE = os.path.join(MAIN_FILE, "backup_&_restore_folder", "patient.csv")
12 | EMPLOYEE_FILE = os.path.join(MAIN_FILE, "backup_&_restore_folder", "employee.csv")
13 |
14 | cur0 = backup.cursor()
15 | cur0.execute("""
16 | COPY (SELECT * FROM admin) TO %s DELIMITER ',' CSV;
17 | """, [ADMIN_FILE])
18 | cur0.close()
19 |
20 | cur1 = backup.cursor()
21 | cur1.execute("""
22 | COPY (SELECT * FROM doctor) TO %s DELIMITER ',' CSV;
23 | """, [DOCTOR_FILE])
24 | cur1.close()
25 |
26 | cur2 = backup.cursor()
27 | cur2.execute("""
28 | COPY (SELECT * FROM patient) TO %s DELIMITER ',' CSV;
29 | """, [PATIENT_FILE])
30 | cur2.close()
31 |
32 | cur3 = backup.cursor()
33 | cur3.execute("""
34 | COPY (SELECT * FROM employee) TO %s DELIMITER ',' CSV;
35 | """, [EMPLOYEE_FILE])
36 | cur3.close()
37 |
38 | backup.commit()
39 | backup.close()
40 | return "Backup Successful"
41 |
42 |
43 | def restore_from_csv(logged_in):
44 | if logged_in:
45 | with psycopg2.connect(**config()) as restore:
46 | ADMIN_FILE = os.path.join(MAIN_FILE, "backup_&_restore_folder", "admin.csv")
47 | DOCTOR_FILE = os.path.join(MAIN_FILE, "backup_&_restore_folder", "doctor.csv")
48 | PATIENT_FILE = os.path.join(MAIN_FILE, "backup_&_restore_folder", "patient.csv")
49 | EMPLOYEE_FILE = os.path.join(MAIN_FILE, "backup_&_restore_folder", "employee.csv")
50 |
51 | cur0 = restore.cursor()
52 | cur0.execute("""
53 | COPY admin FROM %s DELIMITER ',' CSV NULL AS '';
54 | """, [ADMIN_FILE])
55 | cur0.close()
56 |
57 | cur1 = restore.cursor()
58 | cur1.execute("""
59 | COPY doctor FROM %s DELIMITER ',' CSV NULL AS '';
60 | """, [DOCTOR_FILE])
61 | cur1.close()
62 |
63 | cur2 = restore.cursor()
64 | cur2.execute("""
65 | COPY patient FROM %s DELIMITER ',' CSV NULL AS '';
66 | """, [PATIENT_FILE])
67 | cur2.close()
68 |
69 | cur3 = restore.cursor()
70 | cur3.execute("""
71 | COPY employee FROM %s DELIMITER ',' CSV NULL AS '';
72 | """, [EMPLOYEE_FILE])
73 | cur3.close()
74 |
75 | restore.commit()
76 | restore.close()
77 | return "Restoration Successful"
78 |
--------------------------------------------------------------------------------
/constant.py:
--------------------------------------------------------------------------------
1 | MAIN_FILE = os.getcwd()
2 | CONSTANT_FILE = os.path.join(MAIN_FILE, "backup_&_restore_folder", "constant.csv")
3 | constants ={}
4 | condition = True
5 | with open(CONSTANT_FILE, "r") as read_constant:
6 | while condition:
7 | try:
8 | reader = read_constant.readline()
9 | reader_split = reader.split(",")
10 | name, value = reader_split
11 | constants[name] = value[:-1]
12 | except:
13 | condition = False
14 |
15 | def grab_constant(logged_in, name):
16 | if logged_in:
17 | name = name.upper()
18 | value = constants.get(name)
19 | return value
20 |
21 | def set_constant(logged_in, constants_dict):
22 | with open(CONSTANT_FILE, "w") as write_constant:
23 | for key, value in constants_dict.items():
24 | write_constant.write(key.upper() + "," + value + "\n")
25 |
--------------------------------------------------------------------------------
/doctor.py:
--------------------------------------------------------------------------------
1 | import psycopg2
2 | from DB_config import config
3 | import constant
4 | import webbrowser as web
5 |
6 |
7 | def recent_notifications(username, logged_in, limit = 1):
8 | if logged_in:
9 | with psycopg2.connect(**config()) as latest:
10 | cur1 = latest.cursor()
11 | cur1.execute("""
12 | SELECT notifications FROM doctor WHERE username = %s;
13 | """, [username])
14 | notifications_string = cur1.fetchall()[0][0]
15 | list_of_notifications = notifications_string.split(", ")
16 | cur1.close()
17 | latest.close()
18 | return list_of_notifications[-limit:] if limit < len(list_of_notifications) else list_of_notifications[-len(list_of_notifications):]
19 |
20 |
21 | def notify_admin(notification, my_username, admin_username, logged_in):
22 | if logged_in:
23 | with psycopg2.connect(**config()) as add_notifications:
24 | cur1 = add_notifications.cursor()
25 | cur1.execute(f"""
26 | SELECT notifications FROM admin WHERE username = '{admin_username}';
27 | """)
28 | notifications_string = cur1.fetchall()[0][0]
29 | list_of_notifications = notifications_string.split(", ")
30 | notification = "From: " + my_username + " " + notification
31 | list_of_notifications.append(notification)
32 | new_notifications_string = ", ".join(list_of_notifications)
33 | cur1.close()
34 | cur2 = add_notifications.cursor()
35 | cur2.execute(f"""
36 | UPDATE admin SET notifications = '{new_notifications_string}' WHERE username = '{admin_username}';
37 | """)
38 | print(cur2.statusmessage)
39 | cur2.close()
40 | add_notifications.commit()
41 | add_notifications.close()
42 | return "Notification Added"
43 |
44 |
45 | def salary(username, logged_in):
46 | if logged_in:
47 | with psycopg2.connect(**config()) as my_salary:
48 | cur0 = my_salary.cursor()
49 | cur0.execute("""
50 | SELECT * FROM patient WHERE approved_doctor_username = %s;
51 | """, [username])
52 |
53 | total_patient = len(cur0.fetchall())
54 | cur0.close()
55 |
56 | cur1 = my_salary.cursor()
57 | cur1.execute("""
58 | SELECT price FROM doctor WHERE username = %s;
59 | """, [username])
60 |
61 | my_price = cur1.fetchall()[0][0]
62 | cur1.close()
63 | total_earning = total_patient * int(my_price)
64 |
65 | cur2 = my_salary.cursor()
66 | cur2.execute(f"""
67 | SELECT salary FROM employee WHERE work_of_doctors LIKE '%{username}%';
68 | """)
69 | salary_list = cur2.fetchall()
70 | total_cost = 0
71 | if username == "hpt":
72 | for salary in salary_list:
73 | total_cost += (int(salary[0])*int(constant.grab_constant(True,"PRE_SALARY")))//100
74 | else:
75 | for salary in salary_list:
76 | total_cost += int(salary[0])
77 | cur2.close()
78 |
79 | nit_salary = total_earning - total_cost
80 |
81 | my_salary.close()
82 | return (total_earning, total_cost, nit_salary)
83 |
84 |
85 | def show_all_employee(logged_in):
86 | if logged_in:
87 | with psycopg2.connect(**config()) as all_employee:
88 | cur1 = all_employee.cursor()
89 | cur1.execute("""
90 | SELECT username, fullname, email, date_of_birth, work, salary FROM employee;
91 | """)
92 |
93 | rows = cur1.fetchall()
94 | # print part
95 | # for row in rows:
96 | # print("Username:", row[0], "\tFullname:", row[1], "\tEmail:", row[2], "\tSalary:", row[3])
97 | cur1.close()
98 | all_employee.close()
99 | return rows
100 |
101 |
102 | def add_employee(my_username, employee_username, logged_in):
103 | if logged_in:
104 | with psycopg2.connect(**config()) as adding_employee:
105 | cur0 = adding_employee.cursor()
106 | cur0.execute("""
107 | SELECT work_of_doctors FROM employee WHERE username = %s;
108 | """, [employee_username])
109 |
110 | temporary = cur0.fetchall()
111 | work_of_doctors = temporary[0][0]
112 | work_of_doctors += ", " + my_username
113 | cur0.close()
114 |
115 | cur1 = adding_employee.cursor()
116 | cur1.execute("""
117 | UPDATE employee SET work_of_doctors = %s WHERE username = %s;
118 | """, [work_of_doctors, employee_username])
119 | print(cur1.statusmessage)
120 | cur1.close()
121 | adding_employee.commit()
122 | adding_employee.close()
123 | return "Employee Added"
124 |
125 |
126 | def see_my_employee(username, logged_in):
127 | if logged_in:
128 | with psycopg2.connect(**config()) as my_employee:
129 | cur1 = my_employee.cursor()
130 | cur1.execute(f"""
131 | SELECT username, fullname, email, date_of_birth, work, salary FROM employee WHERE work_of_doctors LIKE '%{username}%'
132 | """)
133 | list_of_employees = cur1.fetchall()
134 | # print part
135 | # for row in list_of_employees:
136 | # print("Username:", row[0], "\tFullname:", row[1], "\tEmail:", row[2], "\tWork:", row[3], "\tSalary:", row[4])
137 | cur1.close()
138 | my_employee.close()
139 | return list_of_employees
140 |
141 |
142 | def remove_employee(my_username, employee_username, logged_in):
143 | if logged_in:
144 | with psycopg2.connect(**config()) as removing_employee:
145 | cur0 = removing_employee.cursor()
146 | cur0.execute("""
147 | SELECT work_of_doctors FROM employee WHERE username = %s;
148 | """, [employee_username])
149 |
150 | work_of_doctors_string = cur0.fetchall()[0][0]
151 | work_of_doctors_list = work_of_doctors_string.split(", ")
152 |
153 | work_of_doctors_list.remove(my_username)
154 | new_work_of_doctors_string = ", ".join(work_of_doctors_list)
155 | cur0.close()
156 |
157 | cur1 = removing_employee.cursor()
158 | cur1.execute("""
159 | UPDATE employee SET work_of_doctors = %s WHERE username = %s;
160 | """, [new_work_of_doctors_string, employee_username])
161 | print(cur1.statusmessage)
162 | cur1.close()
163 | removing_employee.commit()
164 | removing_employee.close()
165 | return "Employee Removed"
166 |
167 |
168 | def see_all_requested_patient(username, logged_in):
169 | if logged_in:
170 | with psycopg2.connect(**config()) as all_requested_patient:
171 | cur0 = all_requested_patient.cursor()
172 | cur0.execute("""
173 | SELECT username, fullname, email, date_of_birth, problem FROM patient WHERE requested_doctor_username = %s;
174 | """, [username])
175 |
176 | rows = cur0.fetchall()
177 | # print part
178 | # for row in rows:
179 | # print("Username:", row[0], "\tFullname:", row[1], "\tEmail:", row[2], "\tProblem:", row[3])
180 | cur0.close()
181 | all_requested_patient.close()
182 | return rows
183 |
184 |
185 | def see_all_patients_of_my_specialty(username, logged_in):
186 | if logged_in:
187 | with psycopg2.connect(**config()) as all_under_specialty:
188 | cur0 = all_under_specialty.cursor()
189 | cur0.execute("""
190 | SELECT specialty FROM doctor WHERE username = %s;
191 | """, [username])
192 | specialty = str(cur0.fetchall()[0][0]).lower()
193 | cur0.close()
194 |
195 | cur1 = all_under_specialty.cursor()
196 | cur1.execute("""
197 | SELECT username, fullname, email, date_of_birth, requested_doctor_username, approved_doctor_username FROM patient WHERE problem = %s;
198 | """, [specialty])
199 |
200 | rows = cur1.fetchall()
201 | # for row in rows:
202 | # print("Username:", row[0], "\tFullname:", row[1], "\tEmail:", row[2], "\tRequested Doctor:", row[3], "\tApproved Doctor:", row[4])
203 | cur1.close()
204 | all_under_specialty.close()
205 | return rows
206 |
207 |
208 | def see_my_patient(username, logged_in):
209 | if logged_in:
210 | with psycopg2.connect(**config()) as my_patient:
211 | cur0 = my_patient.cursor()
212 | cur0.execute("""
213 | SELECT username, fullname, email, date_of_birth, problem, appointment_timestamp FROM patient WHERE approved_doctor_username = %s;
214 | """, [username])
215 |
216 | rows = cur0.fetchall()
217 | # print part
218 | # for row in rows:
219 | # print("Username:", row[0], "\tFullname:", row[1], "\tEmail:", row[2], "\tProblem:", row[3])
220 | cur0.close()
221 | my_patient.close()
222 | return rows
223 |
224 |
225 | def see_patients_report(patient_username,report_name,logged_in):
226 | if logged_in:
227 | with psycopg2.connect(**config()) as report:
228 | cur1 = report.cursor()
229 | cur1.execute("""
230 | SELECT reports FROM patient WHERE username = %s;
231 | """, [patient_username])
232 | reports_string = cur1.fetchall()[0][0]
233 | reports_list = reports_string.split("+++")
234 | for reports_substring in reports_list:
235 | report_tuple_without_b = reports_substring[1:-1]
236 | report_sublist = report_tuple_without_b.split("++")
237 | name = report_sublist[0]
238 | url = report_sublist[1]
239 | if name.lower() == report_name.lower():
240 | web.open(url)
241 | return ("Opening",name,"In Web Browser")
242 |
243 |
244 | def remove_patient(patient_username, logged_in):
245 | if logged_in:
246 | with psycopg2.connect(**config()) as removing_patient:
247 | cur0 = removing_patient.cursor()
248 | cur0.execute("""
249 | UPDATE patient SET approved_doctor_username = %s, appointment_timestamp = %s WHERE username = %s;
250 | """, [None, None, patient_username])
251 | print(cur0.statusmessage)
252 | cur0.close()
253 | removing_patient.commit()
254 | removing_patient.close()
255 | return "Patient Removed"
--------------------------------------------------------------------------------
/employee.py:
--------------------------------------------------------------------------------
1 | import psycopg2
2 | from DB_config import config
3 | from constant import grab_constant
4 | import datetime
5 |
6 |
7 | def recent_notifications(username, logged_in, limit = 1):
8 | if logged_in:
9 | with psycopg2.connect(**config()) as latest:
10 | cur1 = latest.cursor()
11 | cur1.execute("""
12 | SELECT notifications FROM employee WHERE username = %s;
13 | """, [username])
14 | notifications_string = cur1.fetchall()[0][0]
15 | list_of_notifications = notifications_string.split(", ")
16 | cur1.close()
17 | latest.close()
18 | return list_of_notifications[-limit:] if limit < len(list_of_notifications) else list_of_notifications[-len(list_of_notifications):]
19 |
20 |
21 | def notify_admin(notification, my_username, admin_username, logged_in):
22 | if logged_in:
23 | with psycopg2.connect(**config()) as add_notifications:
24 | cur1 = add_notifications.cursor()
25 | cur1.execute(f"""
26 | SELECT notifications FROM admin WHERE username = '{admin_username}';
27 | """)
28 | notifications_string = cur1.fetchall()[0][0]
29 | list_of_notifications = notifications_string.split(", ")
30 | notification = "From: " + my_username + " " + notification
31 | list_of_notifications.append(notification)
32 | new_notifications_string = ", ".join(list_of_notifications)
33 | cur1.close()
34 | cur2 = add_notifications.cursor()
35 | cur2.execute(f"""
36 | UPDATE admin SET notifications = '{new_notifications_string}' WHERE username = '{admin_username}';
37 | """)
38 | print(cur2.statusmessage)
39 | cur2.close()
40 | add_notifications.commit()
41 | add_notifications.close()
42 | return "Notification Added"
43 |
44 |
45 | def salary(username, logged_in):
46 | if logged_in:
47 | with psycopg2.connect(**config()) as my_salary:
48 | cur1 = my_salary.cursor()
49 | cur1.execute("""
50 | SELECT work_of_doctors, salary FROM employee WHERE username = %s;
51 | """, [username])
52 | bucket = cur1.fetchall()[0]
53 | string_of_doctors = bucket[0]
54 | my_price = bucket[1]
55 | cur1.close()
56 | list_of_doctors = string_of_doctors.split(", ")
57 | number_of_doctors = len(list_of_doctors)
58 |
59 | if "hpt" in list_of_doctors:
60 | initial_salary = (number_of_doctors * my_price) - (my_price*(100-int(grab_constant(True,"PRE_SALARY"))))//100
61 | else:
62 | initial_salary = number_of_doctors * my_price
63 | hospital_cost = (initial_salary * int(grab_constant(True, "CUT_FROM_EMPLOYEE"))) // 100
64 | final_salary = initial_salary - hospital_cost
65 |
66 | my_salary.close()
67 | return (initial_salary, hospital_cost, final_salary)
68 |
69 |
70 | def isreceptionist(username, logged_in):
71 | if logged_in:
72 | with psycopg2.connect(**config()) as reception:
73 | cur1 = reception.cursor()
74 | cur1.execute("""
75 | SELECT work FROM employee WHERE username = %s;
76 | """, [username])
77 | work = cur1.fetchall()[0][0]
78 | cur1.close()
79 | reception.close()
80 | if work.lower() == "receptionist":
81 | return True
82 | else:
83 | return False
84 |
85 |
86 | def appoint_doctor(my_username, doctor_username, patient_username, appointment_timestamp, logged_in):
87 | if logged_in and isreceptionist(my_username, logged_in):
88 | formated_date = datetime.datetime.strptime(appointment_timestamp, "%Y-%m-%d %H:%M:%S")
89 | with psycopg2.connect(**config()) as adding_patient:
90 | cur0 = adding_patient.cursor()
91 | cur0.execute("""
92 | UPDATE patient SET approved_doctor_username = %s, appointment_timestamp = TIMESTAMP %s WHERE username = %s;
93 | """, [doctor_username, formated_date, patient_username])
94 | print(cur0.statusmessage)
95 | cur0.close()
96 | adding_patient.commit()
97 | adding_patient.close()
98 | return "Succesfully Appointed"
99 |
100 |
101 | def see_my_doctors(username, logged_in):
102 | if logged_in:
103 | with psycopg2.connect(**config()) as my_doctor:
104 | cur1 = my_doctor.cursor()
105 | cur1.execute("""
106 | SELECT work_of_doctors FROM employee WHERE username = %s;
107 | """, [username])
108 | string_of_doctors = cur1.fetchall()[0][0]
109 | cur1.close()
110 | list_of_doctors = string_of_doctors.split(", ")
111 |
112 | doctors_bucket = []
113 | for doctor_username in list_of_doctors:
114 | cur2 = my_doctor.cursor()
115 | if doctor_username != "admin":
116 | cur2.execute("""
117 | SELECT username, fullname, email, date_of_birth, specialty FROM doctor WHERE username = %s;
118 | """, [doctor_username])
119 | temporary = cur2.fetchall()
120 | doctors_bucket.append(temporary[0])
121 | cur2.close()
122 | else:
123 | doctors_bucket.append(('adm', 'admin','admin@as8hospitals.gov',"2004-12-28", 'all'))
124 |
125 | # print part
126 | # for row in doctors_bucket:
127 | # print("Username:", row[0], "\tFullname:", row[1], "\tEmail:", row[2], "\tspecialty:", row[3])
128 |
129 | my_doctor.close()
130 | return doctors_bucket
--------------------------------------------------------------------------------
/frontend.kv:
--------------------------------------------------------------------------------
1 | # All imports
2 | #:import NoTransition kivy.uix.screenmanager.NoTransition
3 | #:import SlideTransition kivy.uix.screenmanager.SlideTransition
4 |
5 |
6 |
7 |
8 | # SignUp Classes
9 | :
10 | name: "GetStarted"
11 | FloatLayout:
12 | Image:
13 | source: 'resources/hms_logo.png'
14 | size_hint: (0.8,0.525)
15 | pos_hint: {"x": 0.11, "top": 0.85}
16 |
17 | Button:
18 | text: "Lets Start!"
19 | font_size: 15
20 | color: (1, 1, 1,1)
21 | italic: True
22 | background_color: (0/255, 153/255, 204/255, 1)
23 | size_hint: (0.3,0.08)
24 | pos_hint: {"x":0.36, "top": 0.35}
25 | on_release:
26 | root.start_program()
27 |
28 | Button:
29 | text: "Ahammad Shawki 8"
30 | font_size: 15
31 | color: (51/255, 153/255, 255/255,1)
32 | underline: True
33 | background_color: (1,1,1,0)
34 | size_hint: (0.3,0.08)
35 | pos_hint: {"x":0.36, "top": 0.2}
36 | on_release:
37 | root.go_to_website()
38 |
39 |
40 |
41 | :
42 | name: "ConstantFixing"
43 |
44 | host: HOST
45 | port: PORT
46 | user: USER
47 | password: PASSWORD
48 | cut_from_patient: CUT_FROM_PATIENT
49 | cut_from_employee: CUT_FROM_EMPLOYEE
50 | fixed_cost_of_hospital: FIXED_COST_OF_HOSPITAL
51 | pre_salary: PRE_SALARY
52 | doctor_max_checkup_price: DOCTOR_MAX_CHECKUP_PRICE
53 | employee_max_salary: EMPLOYEE_MAX_SALARY
54 | hospital_year: HOSPITAL_YEAR
55 | hospital_total_bed: HOSPITAL_TOTAL_BED
56 | hospital_remaining_bed: HOSPITAL_REMAINING_BED
57 | hospital_total_employee: HOSPITAL_TOTAL_EMPLOYEE
58 | hospital_total_doctor: HOSPITAL_TOTAL_DOCTOR
59 | hospital_total_patient: HOSPITAL_TOTAL_PATIENT
60 | hospital_current_patient: HOSPITAL_CURRENT_PATIENT
61 | hospital_motto: HOSPITAL_MOTTO
62 | hospital_location: HOSPITAL_LOCATION
63 | hospital_title: HOSPITAL_TITLE
64 | restore_previous: RESTORE_PREVIOUS
65 |
66 | FloatLayout:
67 | Label:
68 | text: "INITIALLY SETTING UP FEW CONSTANTS"
69 | font_size: 30
70 | color: (0.4, 0.4, 0.4,1)
71 | pos_hint: {"top": 1.45}
72 |
73 |
74 | GridLayout:
75 | cols: 2
76 | size_hint: (0.6,0.84)
77 | pos_hint: {"x":0.2, "top": 0.92}
78 | Label:
79 | text: "HOST: "
80 | color: (51/255, 153/255, 255/255,1)
81 | font_size: 10
82 | TextInput:
83 | id: HOST
84 | text: "localhost"
85 | multiline: False
86 | background_color: (1,1,1,1)
87 | font_size: 10
88 |
89 | Label:
90 | text: "PORT: "
91 | font_size: 10
92 | color: (51/255, 153/255, 255/255,1)
93 | TextInput:
94 | id: PORT
95 | text: "5432"
96 | multiline: False
97 | font_size: 10
98 |
99 | Label:
100 | text: "USER: "
101 | color: (51/255, 153/255, 255/255,1)
102 | font_size: 10
103 | TextInput:
104 | id: USER
105 | text: "postgres"
106 | multiline: False
107 | font_size: 10
108 |
109 | Label:
110 | text: "PASSWORD: "
111 | color: (51/255, 153/255, 255/255,1)
112 | font_size: 10
113 | TextInput:
114 | id: PASSWORD
115 | password: True
116 | multiline: False
117 | font_size: 10
118 |
119 | Label:
120 | text: "CUT_FROM_PATIENT : "
121 | color: (51/255, 153/255, 255/255,1)
122 | font_size: 10
123 | TextInput:
124 | id: CUT_FROM_PATIENT
125 | text: "50"
126 | multiline: False
127 | font_size: 10
128 |
129 | Label:
130 | text: "CUT_FROM_EMPLOYEE: "
131 | color: (51/255, 153/255, 255/255,1)
132 | font_size: 10
133 | TextInput:
134 | id: CUT_FROM_EMPLOYEE
135 | text: "20"
136 | multiline: False
137 | font_size: 10
138 |
139 | Label:
140 | text: "FIXED_COST_OF_HOSPITAL: "
141 | color: (51/255, 153/255, 255/255,1)
142 | font_size: 10
143 | TextInput:
144 | id: FIXED_COST_OF_HOSPITAL
145 | text: "5000"
146 | multiline: False
147 | font_size: 10
148 |
149 | Label:
150 | text: "PRE_SALARY: "
151 | color: (51/255, 153/255, 255/255,1)
152 | font_size: 10
153 | TextInput:
154 | id: PRE_SALARY
155 | text: "10"
156 | multiline: False
157 | font_size: 10
158 |
159 | Label:
160 | text: "DOCTOR_MAX_CHECKUP_PRICE: "
161 | color: (51/255, 153/255, 255/255,1)
162 | font_size: 10
163 | TextInput:
164 | id: DOCTOR_MAX_CHECKUP_PRICE
165 | text: "4000"
166 | multiline: False
167 | font_size: 10
168 |
169 | Label:
170 | text: "EMPLOYEE_MAX_SALARY: "
171 | color: (51/255, 153/255, 255/255,1)
172 | font_size: 10
173 | TextInput:
174 | id: EMPLOYEE_MAX_SALARY
175 | text: "15000"
176 | multiline: False
177 | font_size: 10
178 |
179 | Label:
180 | text: "HOSPITAL_YEAR: "
181 | color: (51/255, 153/255, 255/255,1)
182 | font_size: 10
183 | TextInput:
184 | id: HOSPITAL_YEAR
185 | text: "2004"
186 | multiline: False
187 | font_size: 10
188 |
189 | Label:
190 | text: "HOSPITAL_TOTAL_BED: "
191 | color: (51/255, 153/255, 255/255,1)
192 | font_size: 10
193 | TextInput:
194 | id: HOSPITAL_TOTAL_BED
195 | text: "200"
196 | multiline: False
197 | font_size: 10
198 |
199 | Label:
200 | text: "HOSPITAL_REMAINING_BED: "
201 | color: (51/255, 153/255, 255/255,1)
202 | font_size: 10
203 | TextInput:
204 | id: HOSPITAL_REMAINING_BED
205 | text: "120"
206 | multiline: False
207 | font_size: 10
208 |
209 | Label:
210 | text: "HOSPITAL_TOTAL_EMPLOYEE: "
211 | color: (51/255, 153/255, 255/255,1)
212 | font_size: 10
213 | TextInput:
214 | id: HOSPITAL_TOTAL_EMPLOYEE
215 | text: "16"
216 | multiline: False
217 | font_size: 10
218 |
219 | Label:
220 | text: "HOSPITAL_TOTAL_DOCTOR: "
221 | color: (51/255, 153/255, 255/255,1)
222 | font_size: 10
223 | TextInput:
224 | id: HOSPITAL_TOTAL_DOCTOR
225 | text: "10"
226 | multiline: False
227 | font_size: 10
228 |
229 | Label:
230 | text: "HOSPITAL_TOTAL_PATIENT: "
231 | color: (51/255, 153/255, 255/255,1)
232 | font_size: 10
233 | TextInput:
234 | id: HOSPITAL_TOTAL_PATIENT
235 | text: "2000"
236 | multiline: False
237 | font_size: 10
238 |
239 | Label:
240 | text: "HOSPITAL_CURRENT_PATIENT: "
241 | color: (51/255, 153/255, 255/255,1)
242 | font_size: 10
243 | TextInput:
244 | id: HOSPITAL_CURRENT_PATIENT
245 | text: "40"
246 | multiline: False
247 | font_size: 10
248 |
249 | Label:
250 | text: "HOSPITAL_MOTTO: "
251 | color: (51/255, 153/255, 255/255,1)
252 | font_size: 10
253 | TextInput:
254 | id: HOSPITAL_MOTTO
255 | text: "serve the nation at large"
256 | multiline: False
257 | font_size: 10
258 |
259 | Label:
260 | text: "HOSPITAL_LOCATION: "
261 | color: (51/255, 153/255, 255/255,1)
262 | font_size: 10
263 | TextInput:
264 | id: HOSPITAL_LOCATION
265 | text: "Dhaka-Bangladesh"
266 | multiline: False
267 | font_size: 10
268 |
269 | Label:
270 | text: "HOSPITAL_TITLE: "
271 | color: (51/255, 153/255, 255/255,1)
272 | font_size: 10
273 | TextInput:
274 | id: HOSPITAL_TITLE
275 | text: "The AS8 Hospital"
276 | multiline: False
277 | font_size: 10
278 |
279 | Label:
280 | text: "RESTORE_PREVIOUS(yes/no): "
281 | color: (51/255, 153/255, 255/255,1)
282 | font_size: 10
283 | TextInput:
284 | id: RESTORE_PREVIOUS
285 | text: "no"
286 | multiline: False
287 | font_size: 10
288 |
289 | Button:
290 | text: "Done"
291 | font_size: 14
292 | color: (1, 1, 1,1)
293 | italic: True
294 | background_color: (0/255, 153/255, 204/255, 1)
295 | size_hint: (0.25,0.06)
296 | pos_hint: {"x":0.36, "top": 0.07}
297 | on_release:
298 | root.set_constant_function()
299 |
300 |
301 | :
302 | Label:
303 | text: "Sorry, Something went Wrong :("
304 | size_hint: 0.6, 0.2
305 | pos_hint: {"x": 0.2, "top":0.9}
306 | Label:
307 | text: "Please read the docs and try again"
308 | size_hint: 0.6, 0.2
309 | pos_hint: {"x": 0.2, "top":0.7}
310 |
311 |
312 |
313 |
314 | :
315 | name: "AdminSignUp"
316 |
317 | username: username
318 | fullname: fullname
319 | email: email
320 | date_of_birth: date_of_birth
321 | password: password
322 |
323 | FloatLayout:
324 | Label:
325 | text: "SignUp Form"
326 | font_size: 30
327 | color: (0.4, 0.4, 0.4,1)
328 | pos_hint: {"top": 1.4}
329 |
330 | Label:
331 | text: "Choose Your Category"
332 | font_size: 20
333 | color: (51/255, 153/255, 255/255,1)
334 | pos_hint: {"top": 1.34}
335 |
336 | Button:
337 | id: admin_category
338 | text: "Admin"
339 | color: (51/255, 153/255, 255/255,1)
340 | size_hint: (0.2,0.08)
341 | pos_hint: {"x":0.1, "top": 0.81}
342 |
343 | Button:
344 | id: doctor_category
345 | text: "Doctor"
346 | size_hint: (0.2,0.08)
347 | pos_hint: {"x":0.3, "top": 0.81}
348 | on_release:
349 | app.root.transition = NoTransition()
350 | app.root.current = "DoctorSignUp"
351 |
352 | Button:
353 | id: patient_category
354 | text: "Patient"
355 | size_hint: (0.2,0.08)
356 | pos_hint: {"x":0.5, "top": 0.81}
357 | on_release:
358 | app.root.transition = NoTransition()
359 | app.root.current = "PatientSignUp"
360 |
361 | Button:
362 | id: employee_category
363 | text: "Employee"
364 | size_hint: (0.2,0.08)
365 | pos_hint: {"x":0.7, "top": 0.81}
366 | on_release:
367 | app.root.transition = NoTransition()
368 | app.root.current = "EmployeeSignUp"
369 |
370 | GridLayout:
371 | cols: 2
372 | size_hint: (0.6,0.4)
373 | pos_hint: {"x":0.2, "top": 0.7}
374 | Label:
375 | text: "Username: "
376 | color: (51/255, 153/255, 255/255,1)
377 | TextInput:
378 | id: username
379 | multiline: False
380 | background_color: (1,1,1,1)
381 |
382 | Label:
383 | text: "Fullname: "
384 | color: (51/255, 153/255, 255/255,1)
385 | TextInput:
386 | id: fullname
387 | multiline: False
388 |
389 | Label:
390 | text: "Email: "
391 | color: (51/255, 153/255, 255/255,1)
392 | TextInput:
393 | id: email
394 | multiline: False
395 |
396 | Label:
397 | text: "Date of Birth: "
398 | color: (51/255, 153/255, 255/255,1)
399 | TextInput:
400 | id: date_of_birth
401 | text: "YYYY-MM-DD"
402 | multiline: False
403 |
404 | Label:
405 | text: "Password: "
406 | color: (51/255, 153/255, 255/255,1)
407 | TextInput:
408 | id: password
409 | password: True
410 | multiline: False
411 |
412 |
413 | Button:
414 | text: "Already have an account? Log in."
415 | font_size: 15
416 | color: (51/255, 153/255, 255/255,1)
417 | background_color: (1,1,1,0)
418 | underline: True
419 | size_hint: (0.3,0.08)
420 | pos_hint: {"x":0.36, "top": 0.25}
421 | on_release:
422 | app.root.transition = SlideTransition(direction = "left")
423 | app.root.current = "AdminLogin"
424 |
425 | Button:
426 | text: "Submit"
427 | font_size: 18
428 | color: (1, 1, 1,1)
429 | italic: True
430 | background_color: (0/255, 153/255, 204/255, 1)
431 | size_hint: (0.3,0.08)
432 | pos_hint: {"x":0.36, "top": 0.15}
433 | on_release:
434 | app.root.transition = SlideTransition(direction = "left")
435 | root.signup_to_database()
436 |
437 |
438 | :
439 | name: "DoctorSignUp"
440 |
441 | username: username
442 | fullname: fullname
443 | email: email
444 | date_of_birth: date_of_birth
445 | password: password
446 | specialty: specialty
447 | price: price
448 |
449 | FloatLayout:
450 | Label:
451 | text: "SignUp Form"
452 | font_size: 30
453 | color: (0.4, 0.4, 0.4,1)
454 | pos_hint: {"top": 1.4}
455 |
456 | Label:
457 | text: "Choose Your Category"
458 | font_size: 20
459 | color: (51/255, 153/255, 255/255,1)
460 | pos_hint: {"top": 1.34}
461 |
462 | Button:
463 | id: admin_category
464 | text: "Admin"
465 | size_hint: (0.2,0.08)
466 | pos_hint: {"x":0.1, "top": 0.81}
467 | on_release:
468 | app.root.transition = NoTransition()
469 | app.root.current = "AdminSignUp"
470 |
471 | Button:
472 | id: doctor_category
473 | text: "Doctor"
474 | color: (51/255, 153/255, 255/255,1)
475 | size_hint: (0.2,0.08)
476 | pos_hint: {"x":0.3, "top": 0.81}
477 |
478 | Button:
479 | id: patient_category
480 | text: "Patient"
481 | size_hint: (0.2,0.08)
482 | pos_hint: {"x":0.5, "top": 0.81}
483 | on_release:
484 | app.root.transition = NoTransition()
485 | app.root.current = "PatientSignUp"
486 |
487 | Button:
488 | id: employee_category
489 | text: "Employee"
490 | size_hint: (0.2,0.08)
491 | pos_hint: {"x":0.7, "top": 0.81}
492 | on_release:
493 | app.root.transition = NoTransition()
494 | app.root.current = "EmployeeSignUp"
495 |
496 | GridLayout:
497 | cols: 2
498 | size_hint: (0.6,0.4)
499 | pos_hint: {"x":0.2, "top": 0.7}
500 | Label:
501 | text: "Username: "
502 | color: (51/255, 153/255, 255/255,1)
503 | TextInput:
504 | id: username
505 | multiline: False
506 | background_color: (1,1,1,1)
507 |
508 | Label:
509 | text: "Fullname: "
510 | color: (51/255, 153/255, 255/255,1)
511 | TextInput:
512 | id: fullname
513 | multiline: False
514 |
515 | Label:
516 | text: "Email: "
517 | color: (51/255, 153/255, 255/255,1)
518 | TextInput:
519 | id: email
520 | multiline: False
521 |
522 | Label:
523 | text: "Date of Birth: "
524 | color: (51/255, 153/255, 255/255,1)
525 | TextInput:
526 | id: date_of_birth
527 | text: "YYYY-MM-DD"
528 | multiline: False
529 |
530 | Label:
531 | text: "Password: "
532 | color: (51/255, 153/255, 255/255,1)
533 | TextInput:
534 | id: password
535 | password: True
536 | multiline: False
537 |
538 | Label:
539 | text: "Specialty: "
540 | color: (51/255, 153/255, 255/255,1)
541 | TextInput:
542 | id: specialty
543 | multiline: False
544 |
545 | Label:
546 | text: "CheckUp Price: "
547 | color: (51/255, 153/255, 255/255,1)
548 | TextInput:
549 | id: price
550 | multiline: False
551 |
552 | Button:
553 | text: "Already have an account? Log in."
554 | font_size: 15
555 | color: (51/255, 153/255, 255/255,1)
556 | background_color: (1,1,1,0)
557 | underline: True
558 | size_hint: (0.3,0.08)
559 | pos_hint: {"x":0.36, "top": 0.25}
560 | on_release:
561 | app.root.transition = SlideTransition(direction = "left")
562 | app.root.current = "DoctorLogin"
563 |
564 | Button:
565 | text: "Submit"
566 | font_size: 18
567 | color: (1, 1, 1,1)
568 | italic: True
569 | background_color: (0/255, 153/255, 204/255, 1)
570 | size_hint: (0.3,0.08)
571 | pos_hint: {"x":0.36, "top": 0.15}
572 | on_release:
573 | app.root.transition = SlideTransition(direction = "left")
574 | root.signup_to_database()
575 |
576 |
577 | :
578 | name: "PatientSignUp"
579 |
580 | username: username
581 | fullname: fullname
582 | email: email
583 | date_of_birth: date_of_birth
584 | password: password
585 | problem: problem
586 |
587 | FloatLayout:
588 | Label:
589 | text: "SignUp Form"
590 | font_size: 30
591 | color: (0.4, 0.4, 0.4,1)
592 | pos_hint: {"top": 1.4}
593 |
594 | Label:
595 | text: "Choose Your Category"
596 | font_size: 20
597 | color: (51/255, 153/255, 255/255,1)
598 | pos_hint: {"top": 1.34}
599 |
600 | Button:
601 | id: admin_category
602 | text: "Admin"
603 | size_hint: (0.2,0.08)
604 | pos_hint: {"x":0.1, "top": 0.81}
605 | on_release:
606 | app.root.transition = NoTransition()
607 | app.root.current = "AdminSignUp"
608 |
609 | Button:
610 | id: doctor_category
611 | text: "Doctor"
612 | size_hint: (0.2,0.08)
613 | pos_hint: {"x":0.3, "top": 0.81}
614 | on_release:
615 | app.root.transition = NoTransition()
616 | app.root.current = "DoctorSignUp"
617 |
618 | Button:
619 | id: patient_category
620 | text: "Patient"
621 | color: (51/255, 153/255, 255/255,1)
622 | size_hint: (0.2,0.08)
623 | pos_hint: {"x":0.5, "top": 0.81}
624 |
625 |
626 | Button:
627 | id: employee_category
628 | text: "Employee"
629 | size_hint: (0.2,0.08)
630 | pos_hint: {"x":0.7, "top": 0.81}
631 | on_release:
632 | app.root.transition = NoTransition()
633 | app.root.current = "EmployeeSignUp"
634 |
635 | GridLayout:
636 | cols: 2
637 | size_hint: (0.6,0.4)
638 | pos_hint: {"x":0.2, "top": 0.7}
639 | Label:
640 | text: "Username: "
641 | color: (51/255, 153/255, 255/255,1)
642 | TextInput:
643 | id: username
644 | multiline: False
645 | background_color: (1,1,1,1)
646 |
647 | Label:
648 | text: "Fullname: "
649 | color: (51/255, 153/255, 255/255,1)
650 | TextInput:
651 | id: fullname
652 | multiline: False
653 |
654 | Label:
655 | text: "Email: "
656 | color: (51/255, 153/255, 255/255,1)
657 | TextInput:
658 | id: email
659 | multiline: False
660 |
661 | Label:
662 | text: "Date of Birth: "
663 | color: (51/255, 153/255, 255/255,1)
664 | TextInput:
665 | id: date_of_birth
666 | text: "YYYY-MM-DD"
667 | multiline: False
668 |
669 | Label:
670 | text: "Password: "
671 | color: (51/255, 153/255, 255/255,1)
672 | TextInput:
673 | id: password
674 | password: True
675 | multiline: False
676 |
677 | Label:
678 | text: "Problem: "
679 | color: (51/255, 153/255, 255/255,1)
680 | TextInput:
681 | id: problem
682 | multiline: False
683 |
684 | Button:
685 | id: btn
686 | text: "Already have an account? Log in."
687 | font_size: 15
688 | color: (51/255, 153/255, 255/255,1)
689 | background_color: (1,1,1,0)
690 | underline: True
691 | size_hint: (0.3,0.08)
692 | pos_hint: {"x":0.36, "top": 0.25}
693 | on_release:
694 | app.root.transition = SlideTransition(direction = "left")
695 | app.root.current = "PatientLogin"
696 |
697 | Button:
698 | text: "Submit"
699 | font_size: 18
700 | color: (1, 1, 1,1)
701 | italic: True
702 | background_color: (0/255, 153/255, 204/255, 1)
703 | size_hint: (0.3,0.08)
704 | pos_hint: {"x":0.36, "top": 0.15}
705 | on_release:
706 | app.root.transition = SlideTransition(direction = "left")
707 | root.signup_to_database()
708 |
709 |
710 | :
711 | name: "EmployeeSignUp"
712 |
713 | username: username
714 | fullname: fullname
715 | email: email
716 | date_of_birth: date_of_birth
717 | password: password
718 | work: work
719 | salary: salary
720 |
721 | FloatLayout:
722 | Label:
723 | text: "SignUp Form"
724 | font_size: 30
725 | color: (0.4, 0.4, 0.4,1)
726 | pos_hint: {"top": 1.4}
727 |
728 | Label:
729 | text: "Choose Your Category"
730 | font_size: 20
731 | color: (51/255, 153/255, 255/255,1)
732 | pos_hint: {"top": 1.34}
733 |
734 | Button:
735 | id: admin_category
736 | text: "Admin"
737 | size_hint: (0.2,0.08)
738 | pos_hint: {"x":0.1, "top": 0.81}
739 | on_release:
740 | app.root.transition = NoTransition()
741 | app.root.current = "AdminSignUp"
742 |
743 | Button:
744 | id: doctor_category
745 | text: "Doctor"
746 | size_hint: (0.2,0.08)
747 | pos_hint: {"x":0.3, "top": 0.81}
748 | on_release:
749 | app.root.transition = NoTransition()
750 | app.root.current = "DoctorSignUp"
751 |
752 | Button:
753 | id: patient_category
754 | text: "Patient"
755 | size_hint: (0.2,0.08)
756 | pos_hint: {"x":0.5, "top": 0.81}
757 | on_release:
758 | app.root.transition = NoTransition()
759 | app.root.current = "PatientSignUp"
760 |
761 | Button:
762 | id: employee_category
763 | text: "Employee"
764 | color: (51/255, 153/255, 255/255,1)
765 | size_hint: (0.2,0.08)
766 | pos_hint: {"x":0.7, "top": 0.81}
767 |
768 | GridLayout:
769 | cols: 2
770 | size_hint: (0.6,0.4)
771 | pos_hint: {"x":0.2, "top": 0.7}
772 | Label:
773 | text: "Username: "
774 | color: (51/255, 153/255, 255/255,1)
775 | TextInput:
776 | id: username
777 | multiline: False
778 | background_color: (1,1,1,1)
779 |
780 | Label:
781 | text: "Fullname: "
782 | color: (51/255, 153/255, 255/255,1)
783 | TextInput:
784 | id: fullname
785 | multiline: False
786 |
787 | Label:
788 | text: "Email: "
789 | color: (51/255, 153/255, 255/255,1)
790 | TextInput:
791 | id: email
792 | multiline: False
793 |
794 | Label:
795 | text: "Date of Birth: "
796 | color: (51/255, 153/255, 255/255,1)
797 | TextInput:
798 | id: date_of_birth
799 | text: "YYYY-MM-DD"
800 | multiline: False
801 |
802 | Label:
803 | text: "Password: "
804 | color: (51/255, 153/255, 255/255,1)
805 | TextInput:
806 | id: password
807 | password: True
808 | multiline: False
809 |
810 | Label:
811 | text: "Work: "
812 | color: (51/255, 153/255, 255/255,1)
813 | TextInput:
814 | id: work
815 | multiline: False
816 |
817 | Label:
818 | text: "Salary: "
819 | color: (51/255, 153/255, 255/255,1)
820 | TextInput:
821 | id: salary
822 | multiline: False
823 |
824 | Button:
825 | text: "Already have an account? Log in."
826 | font_size: 15
827 | color: (51/255, 153/255, 255/255,1)
828 | background_color: (1,1,1,0)
829 | underline: True
830 | size_hint: (0.3,0.08)
831 | pos_hint: {"x":0.36, "top": 0.25}
832 | on_release:
833 | app.root.transition = SlideTransition(direction = "left")
834 | app.root.current = "EmployeeLogin"
835 |
836 | Button:
837 | text: "Submit"
838 | font_size: 18
839 | color: (1, 1, 1,1)
840 | italic: True
841 | background_color: (0/255, 153/255, 204/255, 1)
842 | size_hint: (0.3,0.08)
843 | pos_hint: {"x":0.36, "top": 0.15}
844 | on_release:
845 | app.root.transition = SlideTransition(direction = "left")
846 | root.signup_to_database()
847 |
848 |
849 | :
850 | Label:
851 | text: "Sorry, Something went Wrong :("
852 | size_hint: 0.6, 0.2
853 | pos_hint: {"x": 0.2, "top":0.9}
854 | Label:
855 | text: "Please read the docs and try again"
856 | size_hint: 0.6, 0.2
857 | pos_hint: {"x": 0.2, "top":0.7}
858 |
859 |
860 |
861 |
862 |
863 |
864 | # Login Classes
865 | :
866 | name: "AdminLogin"
867 |
868 | username: username
869 | password: password
870 |
871 | FloatLayout:
872 | Label:
873 | text: "Admin Login Form"
874 | font_size: 30
875 | color: (0.4, 0.4, 0.4,1)
876 | pos_hint: {"x": 0.02,"top": 1.25}
877 |
878 |
879 | GridLayout:
880 | cols: 2
881 | size_hint: (0.6,0.18)
882 | pos_hint: {"x":0.15, "top": 0.65}
883 | Label:
884 | text: "Username: "
885 | color: (51/255, 153/255, 255/255,1)
886 | TextInput:
887 | id: username
888 | multiline: False
889 | background_color: (1,1,1,1)
890 |
891 | Label:
892 | text: "Password: "
893 | color: (51/255, 153/255, 255/255,1)
894 | TextInput:
895 | id: password
896 | password: True
897 | multiline: False
898 |
899 | Button:
900 | text: "Don't have an account? Sign Up."
901 | font_size: 15
902 | color: (51/255, 153/255, 255/255,1)
903 | background_color: (1,1,1,0)
904 | underline: True
905 | size_hint: (0.3,0.08)
906 | pos_hint: {"x":0.36, "top": 0.35}
907 | on_release:
908 | app.root.transition = SlideTransition(direction="right")
909 | app.root.current = "AdminSignUp"
910 |
911 | Button:
912 | text: "Submit"
913 | font_size: 18
914 | color: (1, 1, 1,1)
915 | italic: True
916 | background_color: (0/255, 153/255, 204/255, 1)
917 | size_hint: (0.3,0.08)
918 | pos_hint: {"x":0.36, "top": 0.25}
919 | on_release:
920 | app.root.transition = SlideTransition(direction = "left")
921 | root.login_to_database()
922 |
923 |
924 | :
925 | name: "DoctorLogin"
926 |
927 | username: username
928 | password: password
929 |
930 | FloatLayout:
931 | Label:
932 | text: "Doctor Login Form"
933 | font_size: 30
934 | color: (0.4, 0.4, 0.4,1)
935 | pos_hint: {"x": 0.02,"top": 1.25}
936 |
937 |
938 | GridLayout:
939 | cols: 2
940 | size_hint: (0.6,0.18)
941 | pos_hint: {"x":0.15, "top": 0.65}
942 | Label:
943 | text: "Username: "
944 | color: (51/255, 153/255, 255/255,1)
945 | TextInput:
946 | id: username
947 | multiline: False
948 | background_color: (1,1,1,1)
949 |
950 | Label:
951 | text: "Password: "
952 | color: (51/255, 153/255, 255/255,1)
953 | TextInput:
954 | id: password
955 | password: True
956 | multiline: False
957 |
958 | Button:
959 | text: "Don't have an account? Sign Up."
960 | font_size: 15
961 | color: (51/255, 153/255, 255/255,1)
962 | background_color: (1,1,1,0)
963 | underline: True
964 | size_hint: (0.3,0.08)
965 | pos_hint: {"x":0.36, "top": 0.35}
966 | on_release:
967 | app.root.transition = SlideTransition(direction="right")
968 | app.root.current = "DoctorSignUp"
969 |
970 | Button:
971 | text: "Submit"
972 | font_size: 18
973 | color: (1, 1, 1,1)
974 | italic: True
975 | background_color: (0/255, 153/255, 204/255, 1)
976 | size_hint: (0.3,0.08)
977 | pos_hint: {"x":0.36, "top": 0.25}
978 | on_release:
979 | app.root.transition = SlideTransition(direction = "left")
980 | root.login_to_database()
981 |
982 |
983 | :
984 | name: "PatientLogin"
985 |
986 | username: username
987 | password: password
988 |
989 | FloatLayout:
990 | Label:
991 | text: "Patient Login Form"
992 | font_size: 30
993 | color: (0.4, 0.4, 0.4,1)
994 | pos_hint: {"x": 0.02,"top": 1.25}
995 |
996 |
997 | GridLayout:
998 | cols: 2
999 | size_hint: (0.6,0.18)
1000 | pos_hint: {"x":0.15, "top": 0.65}
1001 | Label:
1002 | text: "Username: "
1003 | color: (51/255, 153/255, 255/255,1)
1004 | TextInput:
1005 | id: username
1006 | multiline: False
1007 | background_color: (1,1,1,1)
1008 |
1009 | Label:
1010 | text: "Password: "
1011 | color: (51/255, 153/255, 255/255,1)
1012 | TextInput:
1013 | id: password
1014 | password: True
1015 | multiline: False
1016 |
1017 | Button:
1018 | text: "Don't have an account? Sign Up."
1019 | font_size: 15
1020 | color: (51/255, 153/255, 255/255,1)
1021 | background_color: (1,1,1,0)
1022 | underline: True
1023 | size_hint: (0.3,0.08)
1024 | pos_hint: {"x":0.36, "top": 0.35}
1025 | on_release:
1026 | app.root.transition = SlideTransition(direction="right")
1027 | app.root.current = "PatientSignUp"
1028 |
1029 | Button:
1030 | text: "Submit"
1031 | font_size: 18
1032 | color: (1, 1, 1,1)
1033 | italic: True
1034 | background_color: (0/255, 153/255, 204/255, 1)
1035 | size_hint: (0.3,0.08)
1036 | pos_hint: {"x":0.36, "top": 0.25}
1037 | on_release:
1038 | app.root.transition = SlideTransition(direction = "left")
1039 | root.login_to_database()
1040 |
1041 |
1042 | :
1043 | name: "EmployeeLogin"
1044 |
1045 | username: username
1046 | password: password
1047 |
1048 | FloatLayout:
1049 | Label:
1050 | text: "Employee Login Form"
1051 | font_size: 30
1052 | color: (0.4, 0.4, 0.4,1)
1053 | pos_hint: {"x": 0.02,"top": 1.25}
1054 |
1055 |
1056 | GridLayout:
1057 | cols: 2
1058 | size_hint: (0.6,0.18)
1059 | pos_hint: {"x":0.15, "top": 0.65}
1060 | Label:
1061 | text: "Username: "
1062 | color: (51/255, 153/255, 255/255,1)
1063 | TextInput:
1064 | id: username
1065 | multiline: False
1066 | background_color: (1,1,1,1)
1067 |
1068 | Label:
1069 | text: "Password: "
1070 | color: (51/255, 153/255, 255/255,1)
1071 | TextInput:
1072 | id: password
1073 | password: True
1074 | multiline: False
1075 |
1076 | Button:
1077 | text: "Don't have an account? Sign Up."
1078 | font_size: 15
1079 | color: (51/255, 153/255, 255/255,1)
1080 | background_color: (1,1,1,0)
1081 | underline: True
1082 | size_hint: (0.3,0.08)
1083 | pos_hint: {"x":0.36, "top": 0.35}
1084 | on_release:
1085 | app.root.transition = SlideTransition(direction="right")
1086 | app.root.current = "EmployeeSignUp"
1087 |
1088 | Button:
1089 | text: "Submit"
1090 | font_size: 18
1091 | color: (1, 1, 1,1)
1092 | italic: True
1093 | background_color: (0/255, 153/255, 204/255, 1)
1094 | size_hint: (0.3,0.08)
1095 | pos_hint: {"x":0.36, "top": 0.25}
1096 | on_release:
1097 | app.root.transition = SlideTransition(direction = "left")
1098 | root.login_to_database()
1099 |
1100 |
1101 | :
1102 | Label:
1103 | text: "Sorry, Something went Wrong :("
1104 | size_hint: 0.6, 0.2
1105 | pos_hint: {"x": 0.2, "top":0.9}
1106 | Label:
1107 | text: "Invalid Username or Password"
1108 | size_hint: 0.6, 0.2
1109 | pos_hint: {"x": 0.2, "top":0.7}
1110 |
1111 |
1112 |
1113 |
1114 |
1115 |
1116 | # After Login Classes
1117 | :
1118 | name: "Temporary"
1119 |
1120 | Label:
1121 | text: "Successfully Logged In"
1122 | font_size: 30
1123 | color: (0.4, 0.4, 0.4,1)
1124 | pos_hint: {"x": 0.02,"top": 0.6}
1125 |
1126 |
1127 | :
1128 | name: "AboutHospital"
1129 |
1130 | FloatLayout:
1131 | Image:
1132 | source: 'resources/hospital_illus.jpg'
1133 | size_hint: (0.5,0.325)
1134 | pos_hint: {"x": 0.08, "top": 0.85}
1135 |
1136 |
1137 | :
1138 | name: "Documentation"
1139 |
1140 | FloatLayout:
1141 | Image:
1142 | source: 'resources/documentation_class.png'
1143 | size_hint: (0.7,0.3)
1144 | pos_hint: {"x": 0.1, "top": 0.85}
1145 |
1146 |
1147 | :
1148 | name: "Profile"
1149 |
1150 | FloatLayout:
1151 | Image:
1152 | source: 'resources/profile_pic.jpg'
1153 | size_hint: (0.7,0.3)
1154 | pos_hint: {"x": 0.16, "top": 0.85}
1155 |
1156 |
1157 | :
1158 | name: "Notifications"
1159 |
1160 | FloatLayout:
1161 | Image:
1162 | source: 'resources/notifications_pic.png'
1163 | size_hint: (0.7,0.3)
1164 | pos_hint: {"x": 0.16, "top": 0.85}
1165 |
1166 | :
1167 | Label:
1168 | text: "Sorry, Something went Wrong :("
1169 | size_hint: 0.6, 0.2
1170 | pos_hint: {"x": 0.2, "top":0.9}
1171 | Label:
1172 | text:
1173 | """ Invalid Username or Category. \nPlease read the docs and try again"""
1174 | size_hint: 0.6, 0.2
1175 | pos_hint: {"x": 0.21, "top":0.5}
1176 |
1177 |
1178 |
1179 | # AdminAfterLogin Class
1180 | :
1181 | name: "AdminAfterLogin"
1182 |
1183 | FloatLayout:
1184 |
1185 | Button:
1186 | size_hint: (None, None)
1187 | width: 150
1188 | height: self.width
1189 | pos_hint: {"x": 0.22, "top": 0.55}
1190 | background_normal: "resources/functions.png"
1191 | background_down: "resources/functions_down.png"
1192 | on_release: root.go_to_functions()
1193 |
1194 | Button:
1195 | size_hint: (None, None)
1196 | width: 150
1197 | height: self.width
1198 | pos_hint: {"x": 0.62, "top": 0.55}
1199 | background_normal: "resources/settings.jpg"
1200 | background_down: "resources/settings_down.jpg"
1201 | on_release: root.go_to_settings()
1202 |
1203 |
1204 | Button:
1205 | size_hint: (None, None)
1206 | width: 150
1207 | height: self.width
1208 | pos_hint: {"x": 0.22, "top": 0.32}
1209 | background_normal: "resources/hospital.png"
1210 | background_down: "resources/hospital_down.png"
1211 | on_release:
1212 | app.root.transition = SlideTransition(direction="left")
1213 | app.root.current = "AdminAboutHospital"
1214 |
1215 | Button:
1216 | size_hint: (None, None)
1217 | width: 150
1218 | height: self.width
1219 | pos_hint: {"x": 0.62, "top": 0.32}
1220 | background_normal: "resources/docs.png"
1221 | background_down: "resources/docs_down.png"
1222 | on_release:
1223 | app.root.transition = SlideTransition(direction="left")
1224 | app.root.current = "AdminDocumentation"
1225 |
1226 |
1227 | Carousel:
1228 | direction: "right"
1229 | size_hint: (None, None)
1230 | width: 600
1231 | height: 200
1232 | pos_hint: {"x": 0.13, "top": 0.85}
1233 | loop: True
1234 | scroll_timeout: 100
1235 | Image:
1236 | source: "resources/carousel1.png"
1237 | Image:
1238 | source: "resources/carousel2.png"
1239 | Image:
1240 | source: "resources/carousel3.png"
1241 |
1242 |
1243 |
1244 |
1245 | # DoctorAfterLogin Classes
1246 | :
1247 | name: "DoctorAfterLogin"
1248 |
1249 | FloatLayout:
1250 |
1251 | Button:
1252 | size_hint: (None, None)
1253 | width: 150
1254 | height: self.width
1255 | pos_hint: {"x": 0.22, "top": 0.55}
1256 | background_normal: "resources/functions.png"
1257 | background_down: "resources/functions_down.png"
1258 | on_release: root.go_to_functions()
1259 |
1260 | Button:
1261 | size_hint: (None, None)
1262 | width: 150
1263 | height: self.width
1264 | pos_hint: {"x": 0.62, "top": 0.55}
1265 | background_normal: "resources/settings.jpg"
1266 | background_down: "resources/settings_down.jpg"
1267 | on_release: root.go_to_settings()
1268 |
1269 | Button:
1270 | size_hint: (None, None)
1271 | width: 150
1272 | height: self.width
1273 | pos_hint: {"x": 0.22, "top": 0.32}
1274 | background_normal: "resources/hospital.png"
1275 | background_down: "resources/hospital_down.png"
1276 | on_release:
1277 | app.root.transition = SlideTransition(direction="left")
1278 | app.root.current = "DoctorAboutHospital"
1279 |
1280 | Button:
1281 | size_hint: (None, None)
1282 | width: 150
1283 | height: self.width
1284 | pos_hint: {"x": 0.62, "top": 0.32}
1285 | background_normal: "resources/docs.png"
1286 | background_down: "resources/docs_down.png"
1287 | on_release:
1288 | app.root.transition = SlideTransition(direction="left")
1289 | app.root.current = "DoctorDocumentation"
1290 |
1291 | Carousel:
1292 | direction: "right"
1293 | size_hint: (None, None)
1294 | width: 600
1295 | height: 200
1296 | pos_hint: {"x": 0.13, "top": 0.85}
1297 | loop: True
1298 | scroll_timeout: 100
1299 | Image:
1300 | source: "resources/carousel1.png"
1301 | Image:
1302 | source: "resources/carousel2.png"
1303 | Image:
1304 | source: "resources/carousel3.png"
1305 |
1306 |
1307 |
1308 |
1309 | # PatientAfterLogin Classes
1310 | :
1311 | name: "PatientAfterLogin"
1312 |
1313 | FloatLayout:
1314 |
1315 | Button:
1316 | size_hint: (None, None)
1317 | width: 150
1318 | height: self.width
1319 | pos_hint: {"x": 0.22, "top": 0.55}
1320 | background_normal: "resources/functions.png"
1321 | background_down: "resources/functions_down.png"
1322 | on_release: root.go_to_functions()
1323 |
1324 | Button:
1325 | size_hint: (None, None)
1326 | width: 150
1327 | height: self.width
1328 | pos_hint: {"x": 0.62, "top": 0.55}
1329 | background_normal: "resources/settings.jpg"
1330 | background_down: "resources/settings_down.jpg"
1331 | on_release: root.go_to_settings()
1332 |
1333 | Button:
1334 | size_hint: (None, None)
1335 | width: 150
1336 | height: self.width
1337 | pos_hint: {"x": 0.22, "top": 0.32}
1338 | background_normal: "resources/hospital.png"
1339 | background_down: "resources/hospital_down.png"
1340 | on_release:
1341 | app.root.transition = SlideTransition(direction="left")
1342 | app.root.current = "PatientAboutHospital"
1343 |
1344 | Button:
1345 | size_hint: (None, None)
1346 | width: 150
1347 | height: self.width
1348 | pos_hint: {"x": 0.62, "top": 0.32}
1349 | background_normal: "resources/docs.png"
1350 | background_down: "resources/docs_down.png"
1351 | on_release:
1352 | app.root.transition = SlideTransition(direction="left")
1353 | app.root.current = "PatientDocumentation"
1354 |
1355 | Carousel:
1356 | direction: "right"
1357 | size_hint: (None, None)
1358 | width: 600
1359 | height: 200
1360 | pos_hint: {"x": 0.13, "top": 0.85}
1361 | loop: True
1362 | scroll_timeout: 100
1363 | Image:
1364 | source: "resources/carousel1.png"
1365 | Image:
1366 | source: "resources/carousel2.png"
1367 | Image:
1368 | source: "resources/carousel3.png"
1369 |
1370 |
1371 |
1372 |
1373 | # EmployeeAfterLogin Classes
1374 | :
1375 | name: "EmployeeAfterLogin"
1376 |
1377 | FloatLayout:
1378 | Button:
1379 | size_hint: (None, None)
1380 | width: 150
1381 | height: self.width
1382 | pos_hint: {"x": 0.22, "top": 0.55}
1383 | background_normal: "resources/functions.png"
1384 | background_down: "resources/functions_down.png"
1385 | on_release: root.go_to_functions()
1386 |
1387 | Button:
1388 | size_hint: (None, None)
1389 | width: 150
1390 | height: self.width
1391 | pos_hint: {"x": 0.62, "top": 0.55}
1392 | background_normal: "resources/settings.jpg"
1393 | background_down: "resources/settings_down.jpg"
1394 | on_release: root.go_to_settings()
1395 |
1396 | Button:
1397 | size_hint: (None, None)
1398 | width: 150
1399 | height: self.width
1400 | pos_hint: {"x": 0.22, "top": 0.32}
1401 | background_normal: "resources/hospital.png"
1402 | background_down: "resources/hospital_down.png"
1403 | on_release:
1404 | app.root.transition = SlideTransition(direction="left")
1405 | app.root.current = "EmployeeAboutHospital"
1406 |
1407 | Button:
1408 | size_hint: (None, None)
1409 | width: 150
1410 | height: self.width
1411 | pos_hint: {"x": 0.62, "top": 0.32}
1412 | background_normal: "resources/docs.png"
1413 | background_down: "resources/docs_down.png"
1414 | on_release:
1415 | app.root.transition = SlideTransition(direction="left")
1416 | app.root.current = "EmployeeDocumentation"
1417 |
1418 | Carousel:
1419 | direction: "right"
1420 | size_hint: (None, None)
1421 | width: 600
1422 | height: 200
1423 | pos_hint: {"x": 0.13, "top": 0.85}
1424 | loop: True
1425 | scroll_timeout: 100
1426 | Image:
1427 | source: "resources/carousel1.png"
1428 | Image:
1429 | source: "resources/carousel2.png"
1430 | Image:
1431 | source: "resources/carousel3.png"
1432 |
--------------------------------------------------------------------------------
/login.py:
--------------------------------------------------------------------------------
1 | import psycopg2
2 | import os
3 | from getpass import getpass
4 | from DB_config import config
5 | import datetime
6 |
7 |
8 | def DB_pass(username, category):
9 | with psycopg2.connect(**config()) as find_pass:
10 | cur1 = find_pass.cursor()
11 | cur1.execute(f"""
12 | SELECT password FROM {category} WHERE username = '{username.lower()}';
13 | """)
14 | rows = cur1.fetchall()
15 | cur1.close()
16 | find_pass.close()
17 | return rows[0][0]
18 |
19 |
20 | def login(category, username, password):
21 | logged_in = False
22 | if password == DB_pass(username,category):
23 | logged_in = True
24 | return logged_in
25 |
26 |
27 | def signup(category, *args):
28 | if category == "admin":
29 | username, fullname, email, date_of_birth, password = args
30 | date_of_birth = datetime.datetime.strptime(date_of_birth,"%Y-%m-%d")
31 | notifications = "Logged in"
32 |
33 | with psycopg2.connect(**config()) as default_admin:
34 | cur0 = default_admin.cursor()
35 | cur0.execute("""
36 | INSERT INTO admin (
37 | username,
38 | fullname,
39 | email,
40 | date_of_birth,
41 | password,
42 | notifications
43 | )
44 | VALUES (
45 | %s, %s, %s, DATE %s, %s, %s
46 | ) ON CONFLICT(username) DO NOTHING;
47 | """, (username, fullname, email, date_of_birth, password, notifications))
48 |
49 |
50 | elif category == "doctor":
51 | username, fullname, email, date_of_birth, password, specialty, price = args
52 | date_of_birth = datetime.datetime.strptime(date_of_birth.strip(),"%Y-%m-%d")
53 | notifications = "Logged in"
54 |
55 | with psycopg2.connect(**config()) as doctor_signup:
56 | cur1 = doctor_signup.cursor()
57 | cur1.execute("""
58 | INSERT INTO doctor (
59 | username,
60 | fullname,
61 | email,
62 | date_of_birth,
63 | password,
64 | specialty,
65 | price,
66 | notifications
67 | )
68 | VALUES (
69 | %s, %s, %s, DATE %s, %s, %s, %s, %s
70 | ) ON CONFLICT(username) DO NOTHING;
71 | """, (username, fullname, email, date_of_birth, password, specialty, price, notifications))
72 | print(cur1.statusmessage)
73 | print("Successfully Signed Up")
74 | cur1.close()
75 | doctor_signup.commit()
76 | doctor_signup.close()
77 |
78 | elif category == "patient":
79 | username, fullname, email, date_of_birth, password, problem = args
80 | date_of_birth = datetime.datetime.strptime(date_of_birth.strip(),"%Y-%m-%d")
81 | reports = "(initial_registration++This_frontend_url_will_be_generated_automatically)"
82 | notifications = "Logged in"
83 | requested_doctor_username = None
84 | appointment_timestamp = None
85 | approved_doctor_username = "hpt"
86 |
87 | with psycopg2.connect(**config()) as patient_signup:
88 | cur1 = patient_signup.cursor()
89 | cur1.execute("""
90 | INSERT INTO patient (
91 | username,
92 | fullname,
93 | email,
94 | date_of_birth,
95 | password,
96 | problem,
97 | requested_doctor_username,
98 | approved_doctor_username,
99 | appointment_timestamp,
100 | reports,
101 | notifications
102 | )
103 | VALUES (
104 | %s, %s, %s, DATE %s, %s, %s, %s, %s, %s, %s, %s
105 | ) ON CONFLICT(username) DO NOTHING;
106 | """, (username, fullname, email, date_of_birth, password, problem, requested_doctor_username, approved_doctor_username, appointment_timestamp, reports, notifications))
107 | print(cur1.statusmessage)
108 | print("Successfully Signed Up")
109 | cur1.close()
110 | patient_signup.commit()
111 | patient_signup.close()
112 |
113 | else:
114 | username, fullname, email, date_of_birth, password, work, salary = args
115 | date_of_birth = datetime.datetime.strptime(date_of_birth.strip(),"%Y-%m-%d")
116 | work_of_doctors = "hpt"
117 | notifications = "Logged in"
118 |
119 | with psycopg2.connect(**config()) as employee_signup:
120 | cur1 = employee_signup.cursor()
121 | cur1.execute("""
122 | INSERT INTO employee (
123 | username,
124 | fullname,
125 | email,
126 | date_of_birth,
127 | password,
128 | work,
129 | work_of_doctors,
130 | salary,
131 | notifications
132 | )
133 | VALUES (
134 | %s, %s, %s, DATE %s, %s, %s, %s, %s, %s
135 | );
136 | """, (username, fullname, email, date_of_birth, password, work, work_of_doctors, salary, notifications))
137 | print(cur1.statusmessage)
138 | print("Successfully Signed Up")
139 | cur1.close()
140 | employee_signup.commit()
141 | employee_signup.close()
142 |
143 | return True
--------------------------------------------------------------------------------
/main.py:
--------------------------------------------------------------------------------
1 | import psycopg2
2 | import os
3 | import doctor
4 | import patient
5 | import employee
6 | import login
7 | import admin
8 | import constant
9 | import setup_engine
10 | import backup_restore
11 | import kivy
12 |
13 |
14 | print(kivy.deps.__version__)
--------------------------------------------------------------------------------
/patient.py:
--------------------------------------------------------------------------------
1 | import psycopg2
2 | from constant import grab_constant
3 | from DB_config import config
4 | import datetime
5 |
6 |
7 | def remaining_appointment_time(username, logged_in):
8 | if logged_in:
9 | with psycopg2.connect(**config()) as remaining:
10 | cur1 = remaining.cursor()
11 | cur1.execute("""
12 | SELECT appointment_timestamp FROM patient WHERE username = %s;
13 | """, [username])
14 | appointment_timestamp = cur1.fetchall()[0][0]
15 | if appointment_timestamp != None:
16 | remaining_time = appointment_timestamp - datetime.datetime.now()
17 | else:
18 | remaining_time = "Your appointment isn't fixed yet."
19 | cur1.close()
20 | remaining.close()
21 | return remaining_time
22 |
23 | def recent_notifications(username, logged_in, limit = 1):
24 | if logged_in:
25 | with psycopg2.connect(**config()) as latest:
26 | cur1 = latest.cursor()
27 | cur1.execute("""
28 | SELECT notifications FROM patient WHERE username = %s;
29 | """, [username])
30 | notifications_string = cur1.fetchall()[0][0]
31 | list_of_notifications = notifications_string.split(", ")
32 | cur1.close()
33 | latest.close()
34 | return list_of_notifications[-limit:] if limit < len(list_of_notifications) else list_of_notifications[-len(list_of_notifications):]
35 |
36 |
37 | def notify_admin(notification, my_username, admin_username, logged_in):
38 | if logged_in:
39 | with psycopg2.connect(**config()) as add_notifications:
40 | cur1 = add_notifications.cursor()
41 | cur1.execute(f"""
42 | SELECT notifications FROM admin WHERE username = '{admin_username}';
43 | """)
44 | notifications_string = cur1.fetchall()[0][0]
45 | list_of_notifications = notifications_string.split(", ")
46 | notification = "From: " + my_username + " " + notification
47 | list_of_notifications.append(notification)
48 | new_notifications_string = ", ".join(list_of_notifications)
49 | cur1.close()
50 | cur2 = add_notifications.cursor()
51 | cur2.execute(f"""
52 | UPDATE admin SET notifications = '{new_notifications_string}' WHERE username = '{admin_username}';
53 | """)
54 | print(cur2.statusmessage)
55 | cur2.close()
56 | add_notifications.commit()
57 | add_notifications.close()
58 | return "Notification Added"
59 |
60 |
61 | def cost(username, logged_in):
62 | if logged_in:
63 | with psycopg2.connect(**config()) as total_cost:
64 | cur1 = total_cost.cursor()
65 | cur1.execute("""
66 | SELECT approved_doctor_username FROM patient WHERE username = %s;
67 | """, [username])
68 | approved_doctor_username = cur1.fetchall()[0][0]
69 | print(approved_doctor_username)
70 | cur1.close()
71 |
72 | cur2 = total_cost.cursor()
73 | if approved_doctor_username != "hpt":
74 | cur2.execute("""
75 | SELECT price FROM doctor WHERE username = %s;
76 | """, [approved_doctor_username])
77 | doctors_salary = int(cur2.fetchall()[0][0])
78 | final_cost = (doctors_salary * (100 + int(grab_constant(True,"CUT_FROM_PATIENT"))))//100
79 | else:
80 | doctors_salary = 0
81 | final_cost = 0
82 |
83 | total_cost.close()
84 | hospital_cost = final_cost - doctors_salary
85 |
86 | return (doctors_salary, hospital_cost, final_cost)
87 |
88 |
89 | def add_report(report_name, report_url, username, logged_in):
90 | if logged_in:
91 | with psycopg2.connect(**config()) as add_reports:
92 | cur1 = add_reports.cursor()
93 | cur1.execute("""
94 | SELECT reports FROM patient WHERE username = %s;
95 | """, [username])
96 | reports_string = cur1.fetchall()[0][0]
97 | reports_info = "(" + report_name + "++" + report_url + ")"
98 | reports_string += "+++" + str(reports_info)
99 | cur1.close()
100 | cur2 = add_reports.cursor()
101 | cur2.execute("""
102 | UPDATE patient SET reports = %s WHERE username = %s;
103 | """, [reports_string, username])
104 | print(cur2.statusmessage)
105 | cur2.close()
106 | add_reports.commit()
107 | add_reports.close()
108 | return "Report Added"
109 |
110 |
111 | def see_all_doctors_for_my_problem(username, logged_in):
112 | if logged_in:
113 | with psycopg2.connect(**config()) as doctors_as_problem:
114 | cur1 = doctors_as_problem.cursor()
115 | cur1.execute("""
116 | SELECT problem FROM patient WHERE username = %s;
117 | """, [username])
118 | problem = cur1.fetchall()[0][0]
119 | cur1.close()
120 |
121 | cur2 = doctors_as_problem.cursor()
122 | cur2.execute("""
123 | SELECT username, fullname, email, date_of_birth, price FROM doctor WHERE specialty = %s;
124 | """, [problem])
125 | rows = cur2.fetchall()
126 | # print part
127 | # for row in rows:
128 | # print("Username:", row[0], "\tFullname:", row[1], "\tEmail:", row[2], "\tPrice:", row[3])
129 | cur2.close()
130 | doctors_as_problem.close()
131 | return rows
132 |
133 |
134 | def request_doctor(my_username, doctor_username, logged_in):
135 | if logged_in:
136 | with psycopg2.connect(**config()) as requesting_doctor:
137 | cur1 = requesting_doctor.cursor()
138 | cur1.execute("""
139 | UPDATE patient SET requested_doctor_username = %s WHERE username = %s;
140 | """, [doctor_username, my_username])
141 | print(cur1.statusmessage)
142 | cur1.close()
143 | requesting_doctor.commit()
144 | requesting_doctor.close()
145 | return "Successfully Requested"
146 |
147 |
148 | def remove_request(my_username, logged_in):
149 | if logged_in:
150 | with psycopg2.connect(**config()) as removing_request:
151 | cur1 = removing_request.cursor()
152 | cur1.execute("""
153 | UPDATE patient SET requested_doctor_username = NULL WHERE username = %s;
154 | """, [my_username])
155 | print(cur1.statusmessage)
156 | cur1.close()
157 | removing_request.commit()
158 | removing_request.close()
159 | return "Request Removed"
160 |
161 |
162 | def see_my_doctors_stat(username, logged_in):
163 | if logged_in:
164 | with psycopg2.connect(**config()) as my_doctor:
165 | cur1 = my_doctor.cursor()
166 | cur1.execute("""
167 | SELECT approved_doctor_username, appointment_timestamp FROM patient WHERE username = %s;
168 | """, [username])
169 | temp = cur1.fetchall()[0]
170 | approved_doctor_username = temp[0]
171 | appointment_timestamp = temp[1]
172 | cur1.close()
173 |
174 | cur2 = my_doctor.cursor()
175 | cur2.execute("""
176 | SELECT username, fullname, email, date_of_birth, specialty, price FROM doctor WHERE username = %s;
177 | """, [approved_doctor_username])
178 |
179 | rows = list(cur2.fetchall()[0])
180 | rows.append(appointment_timestamp)
181 | # print part
182 | # for row in rows:
183 | # print("Doctor's Information")
184 | # print("Fullname:", row[1])
185 | # print("Email:", row[2])
186 | # print("specialty:", row[3])
187 | # print("Price:", row[4])
188 | # print("Appointment Timestamp:", row[5])
189 | cur2.close()
190 | my_doctor.close()
191 | return rows
--------------------------------------------------------------------------------
/poster.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahammadshawki8/Hospital-Management-System/de0c1bce97f57ceeae301e034d383a522fe67939/poster.jpg
--------------------------------------------------------------------------------
/requirements.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahammadshawki8/Hospital-Management-System/de0c1bce97f57ceeae301e034d383a522fe67939/requirements.txt
--------------------------------------------------------------------------------
/resources/GENERATOR.pptx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahammadshawki8/Hospital-Management-System/de0c1bce97f57ceeae301e034d383a522fe67939/resources/GENERATOR.pptx
--------------------------------------------------------------------------------
/resources/add_notifications.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahammadshawki8/Hospital-Management-System/de0c1bce97f57ceeae301e034d383a522fe67939/resources/add_notifications.png
--------------------------------------------------------------------------------
/resources/add_notifications_down.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahammadshawki8/Hospital-Management-System/de0c1bce97f57ceeae301e034d383a522fe67939/resources/add_notifications_down.png
--------------------------------------------------------------------------------
/resources/carousel1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahammadshawki8/Hospital-Management-System/de0c1bce97f57ceeae301e034d383a522fe67939/resources/carousel1.png
--------------------------------------------------------------------------------
/resources/carousel2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahammadshawki8/Hospital-Management-System/de0c1bce97f57ceeae301e034d383a522fe67939/resources/carousel2.png
--------------------------------------------------------------------------------
/resources/carousel3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahammadshawki8/Hospital-Management-System/de0c1bce97f57ceeae301e034d383a522fe67939/resources/carousel3.png
--------------------------------------------------------------------------------
/resources/close.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahammadshawki8/Hospital-Management-System/de0c1bce97f57ceeae301e034d383a522fe67939/resources/close.png
--------------------------------------------------------------------------------
/resources/close_down.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahammadshawki8/Hospital-Management-System/de0c1bce97f57ceeae301e034d383a522fe67939/resources/close_down.png
--------------------------------------------------------------------------------
/resources/docs.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahammadshawki8/Hospital-Management-System/de0c1bce97f57ceeae301e034d383a522fe67939/resources/docs.png
--------------------------------------------------------------------------------
/resources/docs_down.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahammadshawki8/Hospital-Management-System/de0c1bce97f57ceeae301e034d383a522fe67939/resources/docs_down.png
--------------------------------------------------------------------------------
/resources/documentation_class.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahammadshawki8/Hospital-Management-System/de0c1bce97f57ceeae301e034d383a522fe67939/resources/documentation_class.png
--------------------------------------------------------------------------------
/resources/functions.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahammadshawki8/Hospital-Management-System/de0c1bce97f57ceeae301e034d383a522fe67939/resources/functions.png
--------------------------------------------------------------------------------
/resources/functions_down.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahammadshawki8/Hospital-Management-System/de0c1bce97f57ceeae301e034d383a522fe67939/resources/functions_down.png
--------------------------------------------------------------------------------
/resources/hms_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahammadshawki8/Hospital-Management-System/de0c1bce97f57ceeae301e034d383a522fe67939/resources/hms_logo.png
--------------------------------------------------------------------------------
/resources/hospital.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahammadshawki8/Hospital-Management-System/de0c1bce97f57ceeae301e034d383a522fe67939/resources/hospital.png
--------------------------------------------------------------------------------
/resources/hospital_down.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahammadshawki8/Hospital-Management-System/de0c1bce97f57ceeae301e034d383a522fe67939/resources/hospital_down.png
--------------------------------------------------------------------------------
/resources/hospital_illus.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahammadshawki8/Hospital-Management-System/de0c1bce97f57ceeae301e034d383a522fe67939/resources/hospital_illus.jpg
--------------------------------------------------------------------------------
/resources/notifications.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahammadshawki8/Hospital-Management-System/de0c1bce97f57ceeae301e034d383a522fe67939/resources/notifications.png
--------------------------------------------------------------------------------
/resources/notifications_down.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahammadshawki8/Hospital-Management-System/de0c1bce97f57ceeae301e034d383a522fe67939/resources/notifications_down.png
--------------------------------------------------------------------------------
/resources/notifications_pic.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahammadshawki8/Hospital-Management-System/de0c1bce97f57ceeae301e034d383a522fe67939/resources/notifications_pic.png
--------------------------------------------------------------------------------
/resources/profile.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahammadshawki8/Hospital-Management-System/de0c1bce97f57ceeae301e034d383a522fe67939/resources/profile.png
--------------------------------------------------------------------------------
/resources/profile_down.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahammadshawki8/Hospital-Management-System/de0c1bce97f57ceeae301e034d383a522fe67939/resources/profile_down.png
--------------------------------------------------------------------------------
/resources/profile_pic.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahammadshawki8/Hospital-Management-System/de0c1bce97f57ceeae301e034d383a522fe67939/resources/profile_pic.jpg
--------------------------------------------------------------------------------
/resources/settings.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahammadshawki8/Hospital-Management-System/de0c1bce97f57ceeae301e034d383a522fe67939/resources/settings.jpg
--------------------------------------------------------------------------------
/resources/settings_down.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahammadshawki8/Hospital-Management-System/de0c1bce97f57ceeae301e034d383a522fe67939/resources/settings_down.jpg
--------------------------------------------------------------------------------
/resources/settings_pic.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahammadshawki8/Hospital-Management-System/de0c1bce97f57ceeae301e034d383a522fe67939/resources/settings_pic.png
--------------------------------------------------------------------------------
/resources/short_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahammadshawki8/Hospital-Management-System/de0c1bce97f57ceeae301e034d383a522fe67939/resources/short_logo.png
--------------------------------------------------------------------------------
/resources/ss1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahammadshawki8/Hospital-Management-System/de0c1bce97f57ceeae301e034d383a522fe67939/resources/ss1.png
--------------------------------------------------------------------------------
/resources/ss2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahammadshawki8/Hospital-Management-System/de0c1bce97f57ceeae301e034d383a522fe67939/resources/ss2.png
--------------------------------------------------------------------------------
/resources/ss3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahammadshawki8/Hospital-Management-System/de0c1bce97f57ceeae301e034d383a522fe67939/resources/ss3.png
--------------------------------------------------------------------------------
/resources/ss4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahammadshawki8/Hospital-Management-System/de0c1bce97f57ceeae301e034d383a522fe67939/resources/ss4.png
--------------------------------------------------------------------------------
/resources/ss5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahammadshawki8/Hospital-Management-System/de0c1bce97f57ceeae301e034d383a522fe67939/resources/ss5.png
--------------------------------------------------------------------------------
/resources/ss6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ahammadshawki8/Hospital-Management-System/de0c1bce97f57ceeae301e034d383a522fe67939/resources/ss6.png
--------------------------------------------------------------------------------
/setup_engine.py:
--------------------------------------------------------------------------------
1 | import psycopg2
2 | from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT
3 | import constant
4 | from DB_config import config, admin_config
5 | from backup_restore import restore_from_csv
6 |
7 | def start_program():
8 | delete_database(True,True)
9 | create_database(True)
10 | delete_admin_table(True,True)
11 | create_admin_table(True)
12 | delete_doctor_table(True,True)
13 | create_doctor_table(True)
14 | delete_employee_table(True,True)
15 | create_employee_table(True)
16 | delete_patient_table(True,True)
17 | create_patient_table(True)
18 | add_unique_constraint(True)
19 | add_check_constraint(True)
20 | restore_from_csv(True)
21 | return "You are ready to go!"
22 |
23 |
24 | def create_database(logged_in):
25 | if logged_in:
26 | with psycopg2.connect(**admin_config()) as database_creator:
27 | database_creator.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT)
28 | cur1 = database_creator.cursor()
29 | cur1.execute("""
30 | CREATE DATABASE hms;
31 | """)
32 | print(cur1.statusmessage)
33 | cur1.close()
34 | database_creator.commit()
35 | database_creator.close()
36 | return "Database Created"
37 |
38 |
39 | def delete_database(logged_in, final_decision = False):
40 | if final_decision and logged_in:
41 | with psycopg2.connect(**admin_config()) as database_deleter:
42 | database_deleter.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT)
43 | cur1 = database_deleter.cursor()
44 | cur1.execute("""
45 | DROP DATABASE IF EXISTS hms;
46 | """)
47 | print(cur1.statusmessage)
48 | cur1.close()
49 | database_deleter.commit()
50 | database_deleter.close()
51 | return "Database Deleted"
52 |
53 |
54 | def create_admin_table(logged_in):
55 | if logged_in:
56 | with psycopg2.connect(**config()) as create_admin:
57 | cur1 = create_admin.cursor()
58 | cur1.execute("""
59 | CREATE TABLE admin (
60 | username VARCHAR(5) NOT NULL PRIMARY KEY,
61 | fullname TEXT NOT NULL,
62 | email VARCHAR(32) NOT NULL,
63 | date_of_birth DATE NOT NULL,
64 | password VARCHAR(15) NOT NULL,
65 | notifications TEXT NOT NULL
66 | );
67 | """)
68 | print(cur1.statusmessage)
69 | cur1.close()
70 | create_admin.commit()
71 | create_admin.close()
72 | return "Admin Table Created"
73 |
74 |
75 | def delete_admin_table(logged_in, final_decision = False):
76 | if final_decision and logged_in:
77 | with psycopg2.connect(**config()) as delete_admin:
78 | cur0 = delete_admin.cursor()
79 | cur0.execute("""
80 | DROP TABLE IF EXISTS admin;
81 | """)
82 | print(cur0.statusmessage)
83 | cur0.close()
84 | delete_admin.commit()
85 | delete_admin.close()
86 | return "Admin Table Deleted"
87 |
88 |
89 | def create_doctor_table(logged_in):
90 | if logged_in:
91 | with psycopg2.connect(**config()) as create_doctor:
92 | cur1 = create_doctor.cursor()
93 | cur1.execute("""
94 | CREATE TABLE doctor (
95 | username VARCHAR(5) NOT NULL PRIMARY KEY,
96 | fullname TEXT NOT NULL,
97 | email VARCHAR(32) NOT NULL,
98 | date_of_birth DATE NOT NULL,
99 | password VARCHAR(5) NOT NULL,
100 | specialty TEXT NOT NULL,
101 | price INT NOT NULL,
102 | notifications TEXT NOT NULL
103 | );
104 | """)
105 | print(cur1.statusmessage)
106 | cur1.close()
107 | create_doctor.commit()
108 | create_doctor.close()
109 | return "Doctor Table Created"
110 |
111 |
112 | def delete_doctor_table( logged_in, final_decision = False):
113 | if final_decision and logged_in:
114 | with psycopg2.connect(**config()) as delete_doctor:
115 | cur0 = delete_doctor.cursor()
116 | cur0.execute("""
117 | DROP TABLE IF EXISTS doctor;
118 | """)
119 | print(cur0.statusmessage)
120 | cur0.close()
121 | delete_doctor.commit()
122 | delete_doctor.close()
123 | return "Doctor Table Deleted"
124 |
125 |
126 | def create_patient_table(logged_in):
127 | if logged_in:
128 | with psycopg2.connect(**config()) as create_patient:
129 | cur1 = create_patient.cursor()
130 | cur1.execute("""
131 | CREATE TABLE patient (
132 | username VARCHAR(5) NOT NULL PRIMARY KEY,
133 | fullname TEXT NOT NULL,
134 | email VARCHAR(32) NOT NULL,
135 | date_of_birth DATE NOT NULL,
136 | password VARCHAR(5) NOT NULL,
137 | problem TEXT NOT NULL,
138 | requested_doctor_username VARCHAR(5),
139 | approved_doctor_username VARCHAR(5) REFERENCES doctor (username),
140 | appointment_timestamp TIMESTAMP,
141 | reports TEXT,
142 | notifications TEXT NOT NULL
143 | );
144 | """)
145 | print(cur1.statusmessage)
146 | cur1.close()
147 | create_patient.commit()
148 | create_patient.close()
149 | return "Patient Table Created"
150 |
151 |
152 | def delete_patient_table(logged_in, final_decision = False):
153 | if final_decision and logged_in:
154 | with psycopg2.connect(**config()) as delete_patient:
155 | cur0 = delete_patient.cursor()
156 | cur0.execute("""
157 | DROP TABLE IF EXISTS patient;
158 | """)
159 | print(cur0.statusmessage)
160 | cur0.close()
161 | delete_patient.commit()
162 | delete_patient.close()
163 | return "Patient Table Deleted"
164 |
165 |
166 | def create_employee_table(logged_in):
167 | if logged_in:
168 | with psycopg2.connect(**config()) as create_employee:
169 | cur1 = create_employee.cursor()
170 | cur1.execute("""
171 | CREATE TABLE employee (
172 | username VARCHAR(5) NOT NULL PRIMARY KEY,
173 | fullname TEXT NOT NULL,
174 | email VARCHAR(32) NOT NULL,
175 | date_of_birth DATE NOT NULL,
176 | password VARCHAR(5) NOT NULL,
177 | work TEXT NOT NULL,
178 | work_of_doctors TEXT,
179 | salary INT NOT NULL,
180 | notifications TEXT NOT NULL
181 | );
182 | """)
183 | print(cur1.statusmessage)
184 | cur1.close()
185 | create_employee.commit()
186 | create_employee.close()
187 | return "Employee Table Created"
188 |
189 |
190 |
191 | def delete_employee_table(logged_in, final_decision = False):
192 | if final_decision and logged_in:
193 | with psycopg2.connect(**config()) as delete_employee:
194 | cur0 = delete_employee.cursor()
195 | cur0.execute("""
196 | DROP TABLE IF EXISTS employee;
197 | """)
198 | print(cur0.statusmessage)
199 | cur0.close()
200 | delete_employee.commit()
201 | delete_employee.close()
202 | return "Employee Table Deleted"
203 |
204 |
205 | def add_unique_constraint(logged_in):
206 | if logged_in:
207 | with psycopg2.connect(**config()) as admin_constraint:
208 | cur1 = admin_constraint.cursor()
209 | cur1.execute("""
210 | ALTER TABLE admin ADD CONSTRAINT unique_admin_email UNIQUE(email);
211 | """)
212 | cur1.close()
213 | admin_constraint.commit()
214 | admin_constraint.close()
215 |
216 | with psycopg2.connect(**config()) as doctor_constraint:
217 | cur1 = doctor_constraint.cursor()
218 | cur1.execute("""
219 | ALTER TABLE doctor ADD CONSTRAINT unique_doctor_email UNIQUE(email);
220 | """)
221 | cur1.close()
222 | doctor_constraint.commit()
223 | doctor_constraint.close()
224 |
225 | with psycopg2.connect(**config()) as employee_constraint:
226 | cur1 = employee_constraint.cursor()
227 | cur1.execute("""
228 | ALTER TABLE employee ADD CONSTRAINT unique_employee_email UNIQUE(email);
229 | """)
230 | cur1.close()
231 | employee_constraint.commit()
232 | employee_constraint.close()
233 |
234 | with psycopg2.connect(**config()) as patient_constraint:
235 | cur1 = patient_constraint.cursor()
236 | cur1.execute("""
237 | ALTER TABLE patient ADD CONSTRAINT unique_patient_email UNIQUE(email);
238 | """)
239 | cur1.close()
240 | patient_constraint.commit()
241 | patient_constraint.close()
242 |
243 |
244 | def add_check_constraint(logged_in):
245 | if logged_in:
246 | with psycopg2.connect(**config()) as doctor_salary_constraint:
247 | cur1 = doctor_salary_constraint.cursor()
248 | cur1.execute(f"""
249 | ALTER TABLE doctor ADD CONSTRAINT doctor_price_check_constraint CHECK(price < {int(constant.grab_constant(True,"DOCTOR_MAX_CHECKUP_PRICE"))})
250 | """)
251 | doctor_salary_constraint.commit()
252 | doctor_salary_constraint.close()
253 |
254 | with psycopg2.connect(**config()) as employee_salary_constraint:
255 | cur1 = employee_salary_constraint.cursor()
256 | cur1.execute(f"""
257 | ALTER TABLE employee ADD CONSTRAINT employee_salary_check_constraint CHECK(salary < {int(constant.grab_constant(True,"EMPLOYEE_MAX_SALARY"))})
258 | """)
259 | employee_salary_constraint.commit()
260 | employee_salary_constraint.close()
--------------------------------------------------------------------------------