forked from Minor-lazer/Algorithms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclinicFeeCalc.py
More file actions
66 lines (53 loc) · 2.02 KB
/
clinicFeeCalc.py
File metadata and controls
66 lines (53 loc) · 2.02 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
class Doctor:
def __init__(self,doctorId,doctorName,specialization,consultationFee):
self.doctorId=doctorId
self.doctorName=doctorName
self.specialization=specialization
self.consultationFee=consultationFee
class Hospital:
def __init__(self,doctorDB):
self.doctorDB=doctorDB
def searchByDoctorName(self,doc_name):
list_matches=[]
for i in self.doctorDB.keys():
if self.doctorDB[i].doctorName==doc_name:
list_matches=list_matches+[self.doctorDB[i]]
return list_matches
def calculateConsultationFeeBySpecialization(self,doc_spec):
fees=0
for i in self.doctorDB.keys():
if self.doctorDB[i].specialization==doc_spec:
fees=fees+self.doctorDB[i].consultationFee
return fees
if __name__=="__main__":
n=int(input("No of doctor in the clinic: "))
lis=[]
for j in range(n):
doctorId=int(input(f"{j+1} no. doctors id: "))
doctorName=input(f"{j+1} no. Doctor's name: ")
specialization=input(f"{j+1} no. Doctor's specialization: ")
consultationFee=int(input(f"{j+1} no. Doctor's consultation fee: "))
obj=[Doctor(doctorId,doctorName,specialization,consultationFee)]
lis=lis+obj
doctorDB={}
c=1
for k in lis:
doctorDB[c]=k
c=c+1
hospital=Hospital(doctorDB)
search_doc_name=input("Give the doctor's name to know the info: ")
search_by_spec=input("Give your required specification: ")
doctor_info=hospital.searchByDoctorName(search_doc_name)
if len(doctor_info)==0:
print("No Doctor Exists with the given DoctorName")
else:
for i in doctor_info:
print(i.doctorId)
print(i.doctorName)
print(i.specialization)
print(i.consultationFee)
fee=hospital.calculateConsultationFeeBySpecialization(search_by_spec)
if fee==0:
print("No Doctor with the given specialization")
else:
print(fee)