-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuildings.py
More file actions
265 lines (216 loc) · 7.82 KB
/
buildings.py
File metadata and controls
265 lines (216 loc) · 7.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
from abc import ABC, abstractmethod
from curses import wrapper
import time as tm
import helper_classes as hc
import sender
class Building(ABC):
__number_of_buildings: int = 0
def __init__(self) :
self._id: str = str()
Building.__number_of_buildings += 1
def get_id(self) -> str:
return self._id
@staticmethod
def get_number_of_buildings() -> int:
return Building.__number_of_buildings
@abstractmethod
def view_information(self):
pass
class Department(Building):
__number_of_departments: int = 0
def __init__(self, name: str, services_offered: list) -> None:
super().__init__()
self._name: str = name
self._services_offered = services_offered
self._head_of_department = str()
self._doctors_list = list()
Department.__number_of_departments += 1
self._id = hc.helper_functions.generate_id("DEP", Department.get_number_of_departments())
# Getter methods
def get_name(self) -> str:
return self._name
def get_services_offered(self) -> list:
return self._services_offered
def get_head_of_department(self) -> str:
return self._head_of_department
def get_doctors_list(self) -> list:
return self._doctors_list
# Setter methods
def set_department_name(self, name: str) -> None:
self._name = name
def set_head_of_department(self, head_of_department: str) -> None:
self._head_of_department = head_of_department
def add_doctor(self, doctor) -> None:
self._doctors_list.append(doctor)
def remove_doctor(self, win, doctor_id):
idx = -1
for i, doctor in enumerate(self._doctors_list):
if doctor.get_id() == doctor_id:
idx = i
break
if idx == -1:
hc.helper_functions.display_error(win, "Can't Find This Doctor")
tm.sleep(3)
else:
del self._doctors_list[idx]
hc.helper_functions.display_success_message(win, "Doctor Removed Successfully")
sender.send_message(
f"Doctor was Removed from Department [ID: {self.get_id()}]"
)
tm.sleep(3)
def view_doctors_list(self):
hc.helper_functions.display_page_heading("Doctors List Page")
def run(stdscr):
headings = ["Name", "Age", "Gender", "Specialization"]
cols_width = [40, 6, 8, 30]
data = list()
for doctor in self._doctors_list:
data.append([
doctor.get_name(), doctor.get_age(),
doctor.get_gender(), doctor.get_specialization()
])
hc.helper_functions.display_table(
stdscr,
6,
"Doctors List:",
headings,
data,
cols_width
)
wrapper(run)
def add_service(self, service: str) -> None:
self._services_offered.append(service)
def view_information(self):
def run(stdscr):
headings = ["Department Data"]
cols_width = [30, 120]
data = [
["ID", self.get_id()],
["Name", self.get_name()],
["Head of Department", self.get_head_of_department()],
["Services Offered", str(self.get_services_offered())[1:-1].replace("'", "")]
]
hc.helper_functions.display_table(
stdscr,
6,
"Department Information:",
headings,
data,
cols_width
)
wrapper(run)
@staticmethod
def get_number_of_departments() -> int:
return Department.__number_of_departments
class Pharmacy(Building):
__number_of_pharmacies: int = 0
def __init__(self, pharmacy_name, pharmacist_name) -> None:
super().__init__()
self._pharmacy_name = pharmacy_name
self._pharmacist_name = pharmacist_name
self._medicine_stock = dict()
self._prescriptions_list = list()
Pharmacy.__number_of_pharmacies += 1
self._id = hc.helper_functions.generate_id("PHR", Pharmacy.get_number_of_pharmacies())
def get_pharmacy_name(self):
return self._pharmacy_name
def get_pharmacist_name(self):
return self._pharmacist_name
def add_medicine_stock(self, medicine_name: str, quantity:int) -> None:
if medicine_name in self._medicine_stock:
self._medicine_stock[medicine_name] += quantity
else:
self._medicine_stock[medicine_name] = quantity
def check_stock(self, medicine_name):
return self._medicine_stock.get(medicine_name, 0)
def dispense_medication(self, prescription):
for item in prescription:
if self._medicine_stock.get(item[0], 0) < item[1]:
return False
for item in prescription:
self._medicine_stock[item[0]] -= item[1]
self._prescriptions_list.append(prescription)
return True
def view_stock(self):
hc.helper_functions.display_page_heading("View Stock Page")
def run(stdscr):
headings = ["Medicine Name", "Quantity"]
cols_width = [20, 12]
data = list()
for item in self._medicine_stock:
data.append([item, self._medicine_stock[item]])
hc.helper_functions.display_table(
stdscr,
6,
"Current Stock:",
headings,
data,
cols_width
)
wrapper(run)
def view_information(self):
def run(stdscr):
headings = ["Pharmacy Data"]
cols_width = [30, 60]
data = [
["ID", self.get_id()],
["Pharmacy Name", self.get_pharmacy_name()],
["Pharmacist Name", self.get_pharmacist_name()],
]
hc.helper_functions.display_table(
stdscr,
6,
"Pharmacy Information:",
headings,
data,
cols_width
)
wrapper(run)
@staticmethod
def get_number_of_pharmacies() -> int:
return Pharmacy.__number_of_pharmacies
class Ward(Building):
__number_of_wards: int = 0
def __init__(self, room_type) -> None:
super().__init__()
self._room_type = room_type
self._availability = True
self._patient = None
Ward.__number_of_wards += 1
self._id = hc.helper_functions.generate_id("WRD", Ward.get_number_of_wards())
def get_room_type(self):
return self._room_type
def check_availability(self):
return self._availability
def assign_room(self, patient):
self._patient = patient
self._availability = False
def discharge_patient(self):
self._patient = None
self._availability = True
def view_information(self):
def run(stdscr):
headings = ["Ward Data"]
cols_width = [30, 60]
patient_id, patient_name = None, None
if self._patient:
patient_id, patient_name = self._patient.get_id(), self._patient.get_name()
data = [
["ID", self.get_id()],
["Room Type", self.get_room_type()],
["Availability", self.check_availability()],
["Assigned Patient ID", patient_id],
["Assigned Patient Name", patient_name]
]
hc.helper_functions.display_table(
stdscr,
6,
"Ward Information:",
headings,
data,
cols_width
)
wrapper(run)
@staticmethod
def get_number_of_wards() -> int:
return Ward.__number_of_wards