-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdata.py
More file actions
162 lines (144 loc) · 3.98 KB
/
data.py
File metadata and controls
162 lines (144 loc) · 3.98 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
from enum import Enum
from typing import Iterable
class UserAuthenticationLevel(Enum):
"""
Enum capturing the different supported authentication assurance levels supported for user-restricted access.
"""
AAL3 = "aal3"
AAL2 = "aal2"
AAL1 = "aal1"
class Actor(Enum):
# User ID, org code, business function, IAL, AAL, OBO User ID (optional)
RC = (
"555073103100",
"D82106",
"REFERRING_CLINICIAN",
"3",
UserAuthenticationLevel.AAL3,
)
RCA = (
"555031998104",
"D82106",
"REFERRING_CLINICIAN_ADMIN",
"3",
UserAuthenticationLevel.AAL3,
)
RA = (
"555031998103",
"D82106",
"REFERRING_ADMIN",
"3",
UserAuthenticationLevel.AAL3,
)
SPC = (
"555032006106",
"RCD",
"SERVICE_PROVIDER_CLINICIAN",
"3",
UserAuthenticationLevel.AAL3,
)
SPA = (
"555032006103",
"RCD",
"SERVICE_PROVIDER_ADMIN",
"3",
UserAuthenticationLevel.AAL3,
)
SPCA = (
"555031998104",
"RCD",
"SERVICE_PROVIDER_CLINICIAN_ADMIN",
"3",
UserAuthenticationLevel.AAL3,
"555031999105",
)
RC_DEV = (
"021600556514",
"R69",
"REFERRING_CLINICIAN",
"3",
UserAuthenticationLevel.AAL3,
)
RC_INSUFFICIENT_IAL = (
"555031999105",
"D82106",
"REFERRING_CLINICIAN",
"2",
UserAuthenticationLevel.AAL3,
)
AAL2_USER = (
"656005750109",
"RCD",
"REFERRING_CLINICIAN",
"3",
UserAuthenticationLevel.AAL2,
)
AAL1_USER = (
"656005750110",
"RCD",
"REFERRING_CLINICIAN",
"3",
UserAuthenticationLevel.AAL1,
)
@property
def user_id(self):
return self.value[0]
@property
def org_code(self):
return self.value[1]
@property
def business_function(self):
return self.value[2]
@property
def id_assurance_level(self):
return self.value[3]
@property
def authentication_assurance_level(self) -> UserAuthenticationLevel:
return self.value[4]
@property
def obo_user_id(self):
if len(self.value) < 6:
return None
return self.value[5]
def is_referrer(self):
return self.business_function in [
"REFERRING_CLINICIAN",
"REFERRING_CLINICIAN_ADMIN",
"REFERRING_ADMIN",
]
@classmethod
def all(
cls,
required_business_functions: Iterable[str] = [
"REFERRING_CLINICIAN",
"REFERRING_CLINICIAN_ADMIN",
"REFERRING_ADMIN",
"SERVICE_PROVIDER_CLINICIAN",
"SERVICE_PROVIDER_CLINICIAN_ADMIN",
"SERVICE_PROVIDER_ADMIN",
],
) -> Iterable["Actor"]:
"""
Utility function for retrieving all Actor instances.
:param required_business_functions: detail that only Actor instances with one of the provided business functions should be included.
Defaults to all business functions (meaning that all Actor instances are returned).
"""
return [
actor
for actor in cls
if actor.business_function in required_business_functions
]
class RenamedHeader(Enum):
CORRELATION_ID = ("x-correlation-id", "nhsd-correlation-id")
BUSINESS_FUNCTION = ("nhsd-ers-business-function", "x-ers-business-function")
ODS_CODE = ("NHSD-End-User-Organisation-ODS", "x-ers-ods-code")
FILENAME = ("nhsd-ers-file-name", "x-ers-xapi-meta-file_name")
COMM_RULE_ORG = ("nhsd-ers-comm-rule-org", "x-ers-xapi-comm-rule-org")
REFERRAL_ID = ("nhsd-ers-referral-id", "x-ers-xapi-meta-intended_ubrn")
OBO_USER_ID = ("nhsd-ers-on-behalf-of-user-id", "x-ers-obo-user-id")
@property
def original(self):
return self.value[0]
@property
def renamed(self):
return self.value[1]