@@ -66,51 +66,41 @@ def to_operation_outcome() -> dict:
6666
6767
6868@dataclass
69- class UnauthorizedVaxOnRecordError (RuntimeError ):
70- @staticmethod
71- def to_operation_outcome () -> dict :
72- msg = "Unauthorized request for vaccine type present in the stored immunization resource"
73- return create_operation_outcome (
74- resource_id = str (uuid .uuid4 ()),
75- severity = Severity .error ,
76- code = Code .forbidden ,
77- diagnostics = msg ,
78- )
79-
80-
81- class MandatoryError (Exception ):
82- def __init__ (self , message = None ):
83- self .message = message
69+ class ResourceVersionNotProvided (RuntimeError ):
70+ """Return this error when client has failed to provide the FHIR resource version where required"""
8471
72+ resource_type : str
8573
86- @dataclass
87- class InvalidImmunizationId (ApiValidationError ):
88- """Use this when the unique Immunization ID is invalid"""
74+ def __str__ (self ):
75+ return f"Validation errors: { self .resource_type } resource version not specified in the request headers"
8976
9077 def to_operation_outcome (self ) -> dict :
9178 return create_operation_outcome (
9279 resource_id = str (uuid .uuid4 ()),
9380 severity = Severity .error ,
94- code = Code .invalid ,
95- diagnostics = "Validation errors: the provided event ID is either missing or not in the expected format." ,
81+ code = Code .invariant ,
82+ diagnostics = self . __str__ () ,
9683 )
9784
9885
9986@dataclass
100- class InvalidPatientId (ApiValidationError ):
101- """Use this when NHS Number is invalid or doesn't exist"""
102-
103- patient_identifier : str
87+ class ParameterException (RuntimeError ):
88+ message : str
10489
10590 def __str__ (self ):
106- return f"NHS Number: { self .patient_identifier } is invalid or it doesn't exist."
91+ return self .message
92+
93+
94+ @dataclass
95+ class InvalidImmunizationId (ApiValidationError ):
96+ """Use this when the unique Immunization ID is invalid"""
10797
10898 def to_operation_outcome (self ) -> dict :
10999 return create_operation_outcome (
110100 resource_id = str (uuid .uuid4 ()),
111101 severity = Severity .error ,
112- code = Code .server_error ,
113- diagnostics = self . __str__ () ,
102+ code = Code .invalid ,
103+ diagnostics = "Validation errors: the provided event ID is either missing or not in the expected format." ,
114104 )
115105
116106
@@ -130,18 +120,6 @@ def to_operation_outcome(self) -> dict:
130120 )
131121
132122
133- @dataclass
134- class InconsistentIdentifierError (ApiValidationError ):
135- """Use this when the local identifier in the payload does not match the existing identifier for the update."""
136-
137- msg : str
138-
139- def to_operation_outcome (self ) -> dict :
140- return create_operation_outcome (
141- resource_id = str (uuid .uuid4 ()), severity = Severity .error , code = Code .invariant , diagnostics = self .msg
142- )
143-
144-
145123@dataclass
146124class InconsistentIdError (ApiValidationError ):
147125 """Use this when the specified id in the message is inconsistent with the path
@@ -164,21 +142,6 @@ def to_operation_outcome(self) -> dict:
164142 )
165143
166144
167- @dataclass
168- class InconsistentResourceVersion (ApiValidationError ):
169- """Use this when the resource version in the request and actual resource version do not match"""
170-
171- message : str
172-
173- def to_operation_outcome (self ) -> dict :
174- return create_operation_outcome (
175- resource_id = str (uuid .uuid4 ()),
176- severity = Severity .error ,
177- code = Code .invariant ,
178- diagnostics = self .message ,
179- )
180-
181-
182145@dataclass
183146class InvalidJsonError (RuntimeError ):
184147 """Raised when client provides an invalid JSON payload"""
0 commit comments