@@ -25,20 +25,7 @@ class Code(str, Enum):
2525class UnauthorizedError (RuntimeError ):
2626 @staticmethod
2727 def to_operation_outcome () -> dict :
28- msg = f"Unauthorized request"
29- return create_operation_outcome (
30- resource_id = str (uuid .uuid4 ()),
31- severity = Severity .error ,
32- code = Code .forbidden ,
33- diagnostics = msg ,
34- )
35-
36-
37- @dataclass
38- class UnauthorizedVaxError (RuntimeError ):
39- @staticmethod
40- def to_operation_outcome () -> dict :
41- msg = "Unauthorized request for vaccine type"
28+ msg = "Unauthorized request"
4229 return create_operation_outcome (
4330 resource_id = str (uuid .uuid4 ()),
4431 severity = Severity .error ,
@@ -60,25 +47,6 @@ def to_operation_outcome() -> dict:
6047 )
6148
6249
63- @dataclass
64- class ResourceNotFoundError (RuntimeError ):
65- """Return this error when the requested FHIR resource does not exist"""
66-
67- resource_type : str
68- resource_id : str
69-
70- def __str__ (self ):
71- return f"{ self .resource_type } resource does not exist. ID: { self .resource_id } "
72-
73- def to_operation_outcome (self ) -> dict :
74- return create_operation_outcome (
75- resource_id = str (uuid .uuid4 ()),
76- severity = Severity .error ,
77- code = Code .not_found ,
78- diagnostics = self .__str__ (),
79- )
80-
81-
8250@dataclass
8351class ResourceFoundError (RuntimeError ):
8452 """Return this error when the requested FHIR resource does exist"""
@@ -117,71 +85,6 @@ def to_operation_outcome(self) -> dict:
11785 )
11886
11987
120- class MandatoryError (Exception ):
121- def __init__ (self , message = None ):
122- self .message = message
123-
124-
125- class ValidationError (RuntimeError ):
126- def to_operation_outcome (self ) -> dict :
127- pass
128-
129-
130- @dataclass
131- class InvalidPatientId (ValidationError ):
132- """Use this when NHS Number is invalid or doesn't exist"""
133-
134- patient_identifier : str
135-
136- def __str__ (self ):
137- return f"NHS Number: { self .patient_identifier } is invalid or it doesn't exist."
138-
139- def to_operation_outcome (self ) -> dict :
140- return create_operation_outcome (
141- resource_id = str (uuid .uuid4 ()),
142- severity = Severity .error ,
143- code = Code .server_error ,
144- diagnostics = self .__str__ (),
145- )
146-
147-
148- @dataclass
149- class InconsistentIdError (ValidationError ):
150- """Use this when the specified id in the message is inconsistent with the path
151- see: http://hl7.org/fhir/R4/http.html#update"""
152-
153- imms_id : str
154-
155- def __str__ (self ):
156- return f"The provided id:{ self .imms_id } doesn't match with the content of the message"
157-
158- def to_operation_outcome (self ) -> dict :
159- return create_operation_outcome (
160- resource_id = str (uuid .uuid4 ()),
161- severity = Severity .error ,
162- code = Code .server_error ,
163- diagnostics = self .__str__ (),
164- )
165-
166-
167- @dataclass
168- class CustomValidationError (ValidationError ):
169- """Custom validation error"""
170-
171- message : str
172-
173- def __str__ (self ):
174- return self .message
175-
176- def to_operation_outcome (self ) -> dict :
177- return create_operation_outcome (
178- resource_id = str (uuid .uuid4 ()),
179- severity = Severity .error ,
180- code = Code .invariant ,
181- diagnostics = self .__str__ (),
182- )
183-
184-
18588@dataclass
18689class IdentifierDuplicationError (RuntimeError ):
18790 """Fine grain validation"""
@@ -223,46 +126,3 @@ def create_operation_outcome(resource_id: str, severity: Severity, code: Code, d
223126 }
224127 ],
225128 }
226-
227-
228- @dataclass
229- class ParameterException (RuntimeError ):
230- message : str
231-
232- def __str__ (self ):
233- return self .message
234-
235-
236- class UnauthorizedSystemError (RuntimeError ):
237- def __init__ (self , message = "Unauthorized system" ):
238- super ().__init__ (message )
239- self .message = message
240-
241- def to_operation_outcome (self ) -> dict :
242- return create_operation_outcome (
243- resource_id = str (uuid .uuid4 ()),
244- severity = Severity .error ,
245- code = Code .forbidden ,
246- diagnostics = self .message ,
247- )
248-
249-
250- class MessageNotSuccessfulError (Exception ):
251- """
252- Generic error message for any scenario which either prevents sending to the Imms API, or which results in a
253- non-successful response from the Imms API
254- """
255-
256- def __init__ (self , message = None ):
257- self .message = message
258-
259-
260- class RecordProcessorError (Exception ):
261- """
262- Exception for re-raising exceptions which have already occurred in the Record Processor.
263- The diagnostics dictionary received from the Record Processor is passed to the exception as an argument
264- and is stored as an attribute.
265- """
266-
267- def __init__ (self , diagnostics_dictionary : dict ):
268- self .diagnostics_dictionary = diagnostics_dictionary
0 commit comments