Skip to content

Commit ea890f7

Browse files
authored
Merge pull request #155 from NHSDigital/dev/NPA-4513_Update_Status_Codes
NPA-4513 Update POST /FHIR/R4/Consent 4XX Status Codes
2 parents 4a55eae + 2ebef66 commit ea890f7

File tree

3 files changed

+26
-25
lines changed

3 files changed

+26
-25
lines changed

sandbox/api/app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def post_consent() -> Union[dict, tuple]:
150150

151151
# Invalid access level
152152
elif patient_identifier == "9000000025":
153-
response = generate_response_from_example(POST_CONSENT__INVALID_ACCESS_LEVEL_ERROR, 400)
153+
response = generate_response_from_example(POST_CONSENT__INVALID_ACCESS_LEVEL_ERROR, 403)
154154

155155
# Missing required evidence
156156
elif patient_identifier == "9000000033":
@@ -166,7 +166,7 @@ def post_consent() -> Union[dict, tuple]:
166166

167167
# Invalid performer NHS number
168168
elif patient_identifier == "9000000000":
169-
response = generate_response_from_example(POST_CONSENT__PERFORMER_IDENTIFIER_ERROR, 400)
169+
response = generate_response_from_example(POST_CONSENT__PERFORMER_IDENTIFIER_ERROR, 422)
170170

171171
else:
172172
# Out of scope errors

sandbox/api/tests/test_app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,11 @@ def test_get_consent(
201201
201,
202202
"https://sandbox.api.service.nhs.uk/validated-relationships/FHIR/R4/Consent/9000000017",
203203
),
204-
("9000000000", POST_CONSENT__PERFORMER_IDENTIFIER_ERROR, 400, None),
204+
("9000000000", POST_CONSENT__PERFORMER_IDENTIFIER_ERROR, 422, None),
205205
("9000000049", POST_CONSENT__DUPLICATE_RELATIONSHIP_ERROR, 409, None),
206206
("9000000041", POST_CONSENT__INVALID_PATIENT_AGE_ERROR, 422, None),
207207
("9000000033", POST_CONSENT__INVALID_EVIDENCE_ERROR, 422, None),
208-
("9000000025", POST_CONSENT__INVALID_ACCESS_LEVEL_ERROR, 400, None),
208+
("9000000025", POST_CONSENT__INVALID_ACCESS_LEVEL_ERROR, 403, None),
209209
],
210210
)
211211
@patch(f"{APP_FILE_PATH}.generate_response_from_example")

specification/validated-relationships-service-api.yaml

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -438,8 +438,8 @@ paths:
438438
439439
| HTTP status | Error code | Description |
440440
| ----------- | --------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
441-
| 400 | `MISSING_VALUE` | Missing header or parameter. For details, see the `diagnostics` field. |
442-
| 400 | `INVALID_VALUE` | Invalid header. For details, see the `diagnostics` field. |
441+
| 400 | `MISSING_VALUE` | Missing header or parameter. For details, see the `diagnostics` field. |
442+
| 400 | `INVALID_VALUE` | Invalid header. For details, see the `diagnostics` field. |
443443
| 400 | `MISSING_IDENTIFIER_VALUE` | Missing performer NHS number. |
444444
| 400 | `NOT_SUPPORTED` | The request is not currently supported. |
445445
| 401 | `ACCESS_DENIED` | Missing or invalid OAuth 2.0 bearer token in request. |
@@ -450,7 +450,7 @@ paths:
450450
| 408 | `TIMEOUT` | Request timed out. |
451451
| 422 | `INVALID_IDENTIFIER_SYSTEM` | Invalid identifier system. |
452452
| 422 | `INVALID_IDENTIFIER_VALUE` | Malformed performer NHS number. |
453-
| 422 | `INVALID_PARAMETER` | Invalid parameter. For details, see the `diagnostics` field. |
453+
| 422 | `INVALID_PARAMETER` | Invalid parameter. For details, see the `diagnostics` field. |
454454
| 429 | `THROTTLED` | You have exceeded your application's [rate limit](https://digital.nhs.uk/developer/guides-and-documentation/reference-guide#rate-limits). |
455455
456456
content:
@@ -507,8 +507,8 @@ paths:
507507
| --------------------------------------- | ---------------------------------------------------------------------------------------------------------- | --------------------------------------------------------- |
508508
| Successful parent-child proxy creation | Valid request with a legal basis of parental responsibility, with performer identifier value of 9000000009 | HTTP Status 201 and OperationOutcome response |
509509
| Successful adult-adult proxy creation | Valid request with legal basis of consent, with performer identifier value of 9000000017 | HTTP Status 201 and OperationOutcome response |
510-
| Invalid performer NHS number | Request with invalid NHS number format, with performer identifier value of 9000000000 | HTTP Status 400 and INVALID_NHS_NUMBER error response |
511-
| Invalid access level | Request with undefined access level code, with performer identifier value of 9000000025 | HTTP Status 400 and INVALID_ACCESS_LEVEL error response |
510+
| Invalid access level | Request with undefined access level code, with performer identifier value of 9000000025 | HTTP Status 403 and INVALID_ACCESS_LEVEL error response |
511+
| Invalid performer NHS number | Request with invalid NHS number format, with performer identifier value of 9000000000 | HTTP Status 422 and INVALID_NHS_NUMBER error response |
512512
| Missing required evidence | Request without evidence of responsibility, with performer identifier value of 9000000033 | HTTP Status 422 and MISSING_EVIDENCE error response |
513513
| Patient age validation failure | Request for child proxy where child is over 16, with performer identifier value of 9000000041 | HTTP Status 422 and INVALID_PATIENT_AGE error response |
514514
| Duplicate relationship | Request for relationship that already exists, with performer identifier value of 9000000049 | HTTP Status 409 and DUPLICATE_RELATIONSHIP error response |
@@ -545,8 +545,23 @@ paths:
545545
examples:
546546
postConsentSuccess:
547547
$ref: "./examples/responses/POST_Consent/success.yaml#/PostConsentSuccess"
548-
"400":
549-
description: Invalid request
548+
"4XX":
549+
description: |
550+
Errors will be returned for the first error encountered in the request. An error occurred as follows:
551+
552+
| HTTP status | Error code | Description |
553+
| ----------- | --------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
554+
| 401 | `ACCESS_DENIED` | Missing or invalid OAuth 2.0 bearer token in request. |
555+
| 403 | `FORBIDDEN` | Access denied to resource. |
556+
| 403 | `INVALID_ACCESS_LEVEL` | Invalid authorisation access level |
557+
| 404 | `INVALIDATED_RESOURCE` | Resource that has been marked as invalid was requested - invalid resources cannot be retrieved |
558+
| 408 | `TIMEOUT` | Request timed out. |
559+
| 409 | `DUPLICATE_RELATIONSHIP` | Conflict with requested proxy role. |
560+
| 422 | `INVALID_NHS_NUMBER` | Invalid NHS number. |
561+
| 422 | `INVALID_PATIENT_AGE` | Patient age is invalid. |
562+
| 422 | `MISSING_EVIDENCE` | Evidence of responsibility is missing. |
563+
| 429 | `THROTTLED` | You have exceeded your application's [rate limit](https://digital.nhs.uk/developer/guides-and-documentation/reference-guide#rate-limits). |
564+
550565
content:
551566
application/fhir+json:
552567
schema:
@@ -556,24 +571,10 @@ paths:
556571
$ref: "./examples/responses/POST_Consent/errors/invalid_performer_identifier_error.yaml#/PostConsentInvalidPerformerIdentifierError"
557572
postConsentInvalidAccessLevel:
558573
$ref: "./examples/responses/POST_Consent/errors/invalid_access_level_error.yaml#/PostConsentInvalidAccessLevelError"
559-
"422":
560-
description: Business rule validation failed
561-
content:
562-
application/fhir+json:
563-
schema:
564-
$ref: "#/components/schemas/OperationOutcome"
565-
examples:
566574
postConsentMissingEvidence:
567575
$ref: "./examples/responses/POST_Consent/errors/invalid_evidence_error.yaml#/PostConsentInvalidEvidenceError"
568576
postConsentInvalidPatientAge:
569577
$ref: "./examples/responses/POST_Consent/errors/invalid_patient_age_error.yaml#/PostConsentInvalidPatientAgeError"
570-
"409":
571-
description: "Conflict with requested proxy role"
572-
content:
573-
application/fhir+json:
574-
schema:
575-
$ref: "#/components/schemas/OperationOutcome"
576-
examples:
577578
postConsentDuplicateRelationship:
578579
$ref: "./examples/responses/POST_Consent/errors/duplicate_relationship_error.yaml#/PostConsentDuplicateRelationshipError"
579580

0 commit comments

Comments
 (0)