-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin_interface.py
More file actions
129 lines (120 loc) · 4.67 KB
/
admin_interface.py
File metadata and controls
129 lines (120 loc) · 4.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
import sys
from models.doctors import add_doctor, get_all_doctors
from models.patient import get_all_patients
from models.appointment import get_all_appointments_admin
import time
ADMIN_USERNAME = "admin"
ADMIN_PASSWORD = "password"
def admin_login():
print("---- Admin Login ----")
username = input("Username: ").strip()
password = input("Password: ").strip()
if username == ADMIN_USERNAME and password == ADMIN_PASSWORD:
print("Login successful! Welcome, Admin.")
return True
else:
print("Invalid credentials. Access denied.")
return False
def admin_menu():
print("\n--- Admin Menu (GOD User) ---")
print("1. Add New Doctor")
print("2. View All Doctors")
print("3. View All Patients")
print("4. View All Appointments")
print("5. Generate Summary Report")
print("6. Logout")
print("--------------------")
return input("Select an option (1-6): ").strip()
def handle_admin_choice(choice):
match(choice):
case '1':
handle_add_doctor()
case '2':
handle_view_doctors()
case '3':
handle_view_patients()
case '4':
handle_view_appointments()
case '5':
handle_generate_report()
case '6':
print("👋 Admin logged out.")
return False
case _:
print("❗ Invalid choice. Please select a number from 1 to 6.")
return True
def handle_add_doctor():
print("\n--- Add New Doctor ---")
doctor_id = input("Doctor ID: ").strip()
first_name = input("First Name: ").strip()
last_name = input("Last Name: ").strip()
specialization = input("Specialization: ").strip()
phone_number = input("Phone Number: ").strip()
success = add_doctor(doctor_id, first_name, last_name, specialization, phone_number)
if success:
print(f"Dr. {first_name} {last_name} added successfully.")
else:
print("Failed to add doctor. Please try again.")
def handle_view_doctors():
print("\n--- All Doctors ---")
doctors = get_all_doctors()
if not doctors:
print("No doctors found.")
return
for doc in doctors:
print(f"ID: {doc['doctor_id']} | Dr. {doc['first_name']} {doc['last_name']} | Specialty: {doc['specialization']}")
def handle_view_patients():
print("\n--- All Patients ---")
patients = get_all_patients()
if not patients:
print("No patients found.")
return
for i, p in enumerate(patients, start=1):
print(f"{i}. ID: {p['patient_id']} | Name: {p['last_name']}, {p['first_name']} | Phone: {p['phone_number']} | Email: {p['email']}")
def handle_view_appointments():
print("\n--- All Appointments ---")
appointments = get_all_appointments_admin()
if not appointments:
print("No appointments found.")
return
for appt in appointments:
print(f"Appointment ID: {appt['appointment_id']} | Patient: {appt['patient_name']} | Doctor: Dr. {appt['doctor_name']} | Date: {appt['appointment_date']} | Time: {appt['appointment_time']} | Status: {appt['status']}")
def handle_generate_report():
print("\n--- Generating Summary Report ---")
doctors=get_all_doctors()
patients=get_all_patients()
appointments=get_all_appointments_admin()
if not appointments:
print("No appointments found to generate report.")
return
print("\n--- 1. OVERALL TOTALS ---")
print(f"Total Doctors Registered: {len(doctors)}")
print(f"Total Patients Registered: {len(patients)}")
print(f"Total Appointments Booked: {len(appointments)}")
print("\n--- 2. APPOINTMENT STATUS HISTORY ---")
status_counts = {}
for appt in appointments:
status = appt['status']
status_counts[status] = status_counts.get(status, 0) + 1
for status, count in status_counts.items():
print(f"Total '{status}' Appointments: {count}")
print("--- 3. DOCTOR ACTIVITY SUMMARY ---:")
doctor_activity = {}
for doc in doctors:
doctor_activity[doc['doctor_id']] = {
'name': f"Dr. {doc['last_name']}",
'count': 0
}
for appt in appointments:
doc_id = appt['doctor_id']
if doc_id in doctor_activity:
doctor_activity[doc_id]['count'] += 1
sorted_activity = sorted(doctor_activity.values(), key=lambda x: x['count'], reverse=True)
for activity in sorted_activity:
print(f"{activity['name']}: {activity['count']} appointments")
def run_admin_interface():
print("Welcome to the Hospital Appointment Management System (HAMS) Admin Interface")
if admin_login():
running = True
while running:
running = handle_admin_choice(admin_menu())