Skip to content

Commit b092475

Browse files
committed
NPA-4474 Add examples for new status codes
NPA-4474 Add examples for new status codes
1 parent a7726f4 commit b092475

File tree

7 files changed

+48
-17
lines changed

7 files changed

+48
-17
lines changed

sandbox/api/constants.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,11 @@
4242
CONSENT__SINGLE_CONSENTING_ADULT_RELATIONSHIP = (
4343
f"{CONSENT__DIRECTORY}single-consenting-adult-relationship.yaml"
4444
)
45-
CONSENT__SINGLE_CONSENTING_ADULT_RELATIONSHIP_INCLUDE_BOTH = (
46-
f"{CONSENT__DIRECTORY}single-consenting-adult-relationship-include-performer-patient.yaml"
47-
)
45+
CONSENT__SINGLE_CONSENTING_ADULT_RELATIONSHIP_INCLUDE_BOTH = f"{CONSENT__DIRECTORY}single-consenting-adult-relationship-include-performer-patient.yaml"
4846
CONSENT__SINGLE_MOTHER_CHILD_RELATIONSHIP = (
4947
f"{CONSENT__DIRECTORY}single-mother-child-relationship.yaml"
5048
)
51-
CONSENT__SINGLE_MOTHER_CHILD_RELATIONSHIP_INCLUDE_BOTH = (
52-
f"{CONSENT__DIRECTORY}single-mother-child-relationship-include-performer-patient.yaml"
53-
)
49+
CONSENT__SINGLE_MOTHER_CHILD_RELATIONSHIP_INCLUDE_BOTH = f"{CONSENT__DIRECTORY}single-mother-child-relationship-include-performer-patient.yaml"
5450
CONSENT__STATUS_PARAM_INVALID = (
5551
f"{CONSENT__DIRECTORY}errors/invalid-status-parameter.yaml"
5652
)

sandbox/api/utils.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ def check_for_related_person_errors(request: Request) -> Optional[tuple]:
5858
return generate_response_from_example(RELATED__ERROR_IDENTIFIER_SYSTEM, 400)
5959

6060

61+
GET_CONSENT_ERRORS = "./api/examples/GET_Consent/errors"
62+
63+
6164
def check_for_consent_errors(request: Request) -> Optional[tuple]:
6265
"""Check for errors in the request headers and arguments for a Get /Consent
6366
@@ -73,12 +76,12 @@ def check_for_consent_errors(request: Request) -> Optional[tuple]:
7376

7477
if not identifier:
7578
return generate_response_from_example(
76-
"./api/examples/GET_Consent/errors/missing-identifier.yaml", 400
79+
f"{GET_CONSENT_ERRORS}/missing-identifier.yaml", 400
7780
)
7881
elif identifier and len(identifier_without_system) != 10:
7982
# invalid identifier
8083
return generate_response_from_example(
81-
"./api/examples/GET_Consent/errors/invalid-identifier.yaml", 400
84+
f"{GET_CONSENT_ERRORS}/invalid-identifier.yaml", 422
8285
)
8386
elif (
8487
isinstance(identifier, str)
@@ -87,7 +90,7 @@ def check_for_consent_errors(request: Request) -> Optional[tuple]:
8790
):
8891
# invalid identifier system
8992
return generate_response_from_example(
90-
"./api/examples/GET_Consent/errors/invalid-identifier-system.yaml", 400
93+
f"{GET_CONSENT_ERRORS}/invalid-identifier-system.yaml", 422
9194
)
9295

9396

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
DownstreamServiceError:
2+
summary: Downstream Service Error
3+
description: An unexpected condition was encountered in a downstream service preventing the server from fulfilling the request.
4+
value:
5+
issue:
6+
- code: invalid
7+
diagnostics: "Downstream Service Error - Failed to generate response is present in the response"
8+
details:
9+
coding:
10+
- code: "DOWNSTREAM_SERVICE_ERROR"
11+
display: "Failed to generate response"
12+
system: "https://fhir.nhs.uk/R4/CodeSystem/ValidatedRelationships-ErrorOrWarningCode"
13+
version: "1"
14+
severity: error
15+
resourceType: "OperationOutcome"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
GPPracticeNotFoundError:
2+
summary: GP Practice not found
3+
description: 404 GP Practice not found error response bundle
4+
value:
5+
issue:
6+
- code: processing
7+
details:
8+
coding:
9+
- system: "https://fhir.nhs.uk/R4/CodeSystem/ValidatedRelationships-ErrorOrWarningCode"
10+
version: "1"
11+
code: "GP_PRACTICE_NOT_FOUND"
12+
display: "GP Practice could not be found - invalid resources cannot be retrieved"
13+
severity: error
14+
resourceType: "OperationOutcome"

specification/examples/responses/GET_Consent/errors/invalid-identifier-system.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
ConsentInvalidIdentifierSystemError:
22
summary: Bad request identifier system invalid
3-
description: 400 error response bundle for an invalid system of the identifier
3+
description: 422 error response bundle for an invalid system of the identifier
44
value:
55
issue:
66
- code: invalid

specification/examples/responses/GET_Consent/errors/invalid-status-parameter.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
ConsentInvalidStatusParameterError:
22
summary: Bad request status param invalid
3-
description: 400 error response bundle for an invalid status parameter
3+
description: 422 error response bundle for an invalid status parameter
44
value:
55
issue:
66
- code: invalid

specification/validated-relationships-service-api.yaml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -379,11 +379,11 @@ paths:
379379
| A single proxy relationship between consenting adults including details | `performer:identifier`=`9000000010` and `_include` = `Consent:patient` and `_include` = `Consent:proxy` | HTTP Status 200 Bundle containing a single proxy relationship including performer and patient details |
380380
| A single proxy relationship between a mother and child | `performer:identifier`=`9000000019` | HTTP Status 200 Bundle containing a single proxy relationship |
381381
| A single proxy relationship between a mother and child including details | `performer:identifier`=`9000000019` and `_include` = `Consent:patient` and `_include` = `Consent:proxy` | HTTP Status 200 Bundle containing a single proxy relationship including performer and patient details |
382-
| Invalid status parameter | `performer:identifier`=`9000000019` and `status` = `test` | HTTP Status 400 and INVALID_VALUE error response |
383-
| Invalid include parameter | `performer:identifier`=`9000000019` and `_include` = `test` | HTTP Status 400 and INVALID_VALUE error response |
382+
| Invalid status parameter | `performer:identifier`=`9000000019` and `status` = `test` | HTTP Status 422 and INVALID_VALUE error response |
383+
| Invalid include parameter | `performer:identifier`=`9000000019` and `_include` = `test` | HTTP Status 422 and INVALID_VALUE error response |
384384
| Missing identifier | `patient:identifier`=`9000000009` | HTTP Status 400 and MISSING_IDENTIFIER_VALUE error response |
385-
| Invalid identifier | `identifier`=`900000000` Note: This identifier is 9 characters long, too short to be NHS Number | HTTP Status 400 and INVALID_IDENTIFIER_VALUE error response |
386-
| Invalid identifier system | `identifier`=`https://fhir.nhs.uk/Id/nhs-number/9730675929` | HTTP Status 400 and INVALID_IDENTIFIER_SYSTEM error response |
385+
| Invalid identifier | `identifier`=`900000000` Note: This identifier is 9 characters long, too short to be NHS Number | HTTP Status 422 and INVALID_IDENTIFIER_VALUE error response |
386+
| Invalid identifier system | `identifier`=`https://fhir.nhs.uk/Id/nhs-number/9730675929` | HTTP Status 422 and INVALID_IDENTIFIER_SYSTEM error response |
387387
| No performer record found | `identifier`=`9000000999` | HTTP Status 404 and INVALIDATED_RESOURCE error response |
388388
389389
operationId: get-consent
@@ -465,13 +465,15 @@ paths:
465465
$ref: "./examples/responses/errors/invalidated-resource.yaml#/InvalidatedResourceError"
466466
ConsentInvalidStatusParameterError:
467467
$ref: "./examples/responses/GET_Consent/errors/invalid-status-parameter.yaml#/ConsentInvalidStatusParameterError"
468+
GPPracticeNotFoundError:
469+
$ref: "./examples/responses/GET_Consent/errors/gp-practice-not-found.yaml#/GPPracticeNotFoundError"
468470
InvalidIncludeParameterError:
469471
$ref: "./examples/responses/errors/invalid-include-parameter.yaml#/InvalidIncludeParameterError"
470472
"5XX":
471473
description: |
472474
Errors will be returned for the first error encountered in the request. An error occurred as follows:
473475
474-
| HTTP status | Error code | Description |
476+
| HTTP status | Error code | Description |
475477
| ----------- | ---------------------------------- | ------------------------------------------------------------ |
476478
| 500 | `SERVER_ERROR` | An unexpected internal server error has occurred. |
477479
| 503 | `DOWNSTREAM_SERVICE_ERROR` | A downsteam service has failed, request cannot be completed. |
@@ -483,7 +485,8 @@ paths:
483485
examples:
484486
InternalServerError:
485487
$ref: "./examples/responses/errors/internal-server-error.yaml#/InternalServerError"
486-
488+
DownstreamServiceError:
489+
$ref: "./examples/responses/GET_Consent/errors/downstream-service-error.yaml#/DownstreamServiceError"
487490
post:
488491
summary: Create a proxy role
489492
description: |

0 commit comments

Comments
 (0)