-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch.py
82 lines (73 loc) · 2.96 KB
/
search.py
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
from server import centreManager, userManager
from centreManager import CentreManager
from userManager import UserManager
def searchFiles(searchTerm, option):
found = False
searchTerm = searchTerm.lower()
if (option == "healthCentre" or option == "suburb"):
resultArray = []
resultDict = {}
if (option == "healthCentre"):
centres = centreManager.searchHealthCentresByName(searchTerm)
else:
centres = centreManager.searchHealthCentresBySuburb(searchTerm)
if centres:
for centre in centres:
found = True
resultDict["typeCentre"] = centre.getCentreType()
resultDict["abn"] = centre.getABN()
resultDict["name"] = centre.getName()
resultDict["phone"] = centre.getPhone()
resultDict["suburb"] = centre.getSuburb()
resultArray.append(resultDict.copy())
if found == True:
returnDict = [found, resultArray]
return returnDict
else:
returnDict = [found, []]
return returnDict
elif (option == "healthProvider" or option == "service"):
resultArray = []
resultDict = {}
if option == "healthProvider":
providers = userManager.searchID(searchTerm)
else:
providers = userManager.searchProfession(searchTerm)
if providers:
for provider in providers:
centres = provider.getListOfCentres()
for centre in centres:
found = True
returnArray = searchFiles(centre.getName(), "healthCentre")
returnDict = returnArray[1][0]
returnDict["user"] = provider.get_id()
returnDict["service"] = provider.getProfession()
resultArray.append(returnDict)
if found == True:
returnDict = [found, resultArray]
return returnDict
else:
returnDict = [found, []]
return returnDict
elif (option == "healthcareDomain"):
resultArray = []
resultDict = {}
providers = userManager.searchExpertise(searchTerm)
if providers:
for provider in providers:
centres = provider.getListOfCentres()
for centre in centres:
found = True
returnArray = searchFiles(centre.getName(), "healthCentre")
returnDict = returnArray[1][0]
returnDict["user"] = provider.get_id()
returnDict["healthcareDomain"] = provider.get_expertise()
resultArray.append(returnDict)
if found == True:
returnDict = [found, resultArray]
return returnDict
else:
returnDict = [found, []]
return returnDict
if __name__ == '__main__':
print(str(searchFiles("Hospital", "healthCentre")))