Skip to content

Commit 05b54c3

Browse files
NRL-505 Revert to previous error response as it is part of the query
1 parent 46708f9 commit 05b54c3

File tree

5 files changed

+33
-9
lines changed

5 files changed

+33
-9
lines changed

api/consumer/countDocumentReference/count_document_reference.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def handler(
2929
logger.log(
3030
LogReference.CONCOUNT001, subject_identifier=params.subject_identifier
3131
)
32-
return SpineErrorResponse.UNPROCESSABLE_ENTITY(
32+
return SpineErrorResponse.INVALID_IDENTIFIER_VALUE(
3333
diagnostics="Invalid NHS number provided in the query parameters",
3434
expression="subject:identifier",
3535
)

api/consumer/countDocumentReference/tests/test_count_document_reference.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def test_count_document_reference_invalid_nhs_number():
100100
body = result.pop("body")
101101

102102
assert result == {
103-
"statusCode": "422",
103+
"statusCode": "400",
104104
"headers": default_response_headers(),
105105
"isBase64Encoded": False,
106106
}
@@ -111,13 +111,13 @@ def test_count_document_reference_invalid_nhs_number():
111111
"issue": [
112112
{
113113
"severity": "error",
114-
"code": "business-rule",
114+
"code": "invalid",
115115
"details": {
116116
"coding": [
117117
{
118118
"system": "https://fhir.nhs.uk/ValueSet/Spine-ErrorOrWarningCode-1",
119-
"code": "UNPROCESSABLE_ENTITY",
120-
"display": "Unprocessable Entity",
119+
"code": "INVALID_IDENTIFIER_VALUE",
120+
"display": "Invalid identifier value",
121121
}
122122
]
123123
},

layer/nrlf/core/codes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,6 @@ class SpineErrorConcept(_CodeableConcept):
5555
"INVALID_PARAMETER": "Invalid parameter",
5656
"MESSAGE_NOT_WELL_FORMED": "Message not well formed",
5757
"MISSING_OR_INVALID_HEADER": "There is a required header missing or invalid",
58+
"INVALID_IDENTIFIER_VALUE": "Invalid identifier value",
5859
"UNPROCESSABLE_ENTITY": "Unprocessable Entity",
5960
}

layer/nrlf/core/response.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,29 @@ def ACCESS_DENIED(cls, diagnostics: str = "Access denied") -> "Response":
149149
statusCode="403",
150150
)
151151

152+
@classmethod
153+
def INVALID_IDENTIFIER_VALUE(
154+
cls,
155+
diagnostics: str = "Invalid identifier value",
156+
expression: str | None = None,
157+
):
158+
return cls.from_issues(
159+
issues=[
160+
producer_model.OperationOutcomeIssue(
161+
severity="error",
162+
code="invalid",
163+
details=SpineErrorConcept.from_code("INVALID_IDENTIFIER_VALUE"),
164+
diagnostics=diagnostics,
165+
expression=(
166+
[producer_model.ExpressionItem(root=expression)]
167+
if expression
168+
else None
169+
),
170+
)
171+
],
172+
statusCode="400",
173+
)
174+
152175
@classmethod
153176
def INVALID_NHS_NUMBER(
154177
cls, diagnostics: str = "Invalid NHS number", expression: str | None = None

tests/features/consumer/countDocumentReference-failure.feature

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,18 @@ Feature: Consumer - countDocumentReference - Failure Scenarios
3434
When consumer 'RX898' counts DocumentReferences with parameters:
3535
| parameter | value |
3636
| subject:identifier | https://fhir.nhs.uk/Id/nhs-number\|123 |
37-
Then the response status code is 422
37+
Then the response status code is 400
3838
And the response is an OperationOutcome with 1 issue
3939
And the OperationOutcome contains the issue:
4040
"""
4141
{
4242
"severity": "error",
43-
"code": "business-rule",
43+
"code": "invalid",
4444
"details": {
4545
"coding": [{
4646
"system": "https://fhir.nhs.uk/ValueSet/Spine-ErrorOrWarningCode-1",
47-
"code": "UNPROCESSABLE_ENTITY",
48-
"display": "Unprocessable Entity"
47+
"code": "INVALID_IDENTIFIER_VALUE",
48+
"display": "Invalid identifier value"
4949
}]
5050
},
5151
"diagnostics": "Invalid NHS number provided in the query parameters",

0 commit comments

Comments
 (0)