Skip to content

Commit 3155018

Browse files
Merge branch 'master' into bug/NPA-4705/Validate-Extension-for-POST-Consent
2 parents 08c1cb6 + 6dd0e2e commit 3155018

File tree

5 files changed

+27
-0
lines changed

5 files changed

+27
-0
lines changed

sandbox/api/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
PATCH_CONSENT__INVALID_PATCH_FORMAT = f"{PATCH_CONSENT__DIRECTORY}errors/invalid_patch_format.yaml"
6060
PATCH_CONSENT__INVALID_PATH = f"{PATCH_CONSENT__DIRECTORY}errors/invalid_path.yaml"
6161
PATCH_CONSENT__INVALID_STATUS_CODE = f"{PATCH_CONSENT__DIRECTORY}errors/invalid_status_code.yaml"
62+
PATCH_CONSENT__INVALID_STATUS_REASON = f"{PATCH_CONSENT__DIRECTORY}errors/invalid_status_reason.yaml"
6263
PATCH_CONSENT__RESOURCE_NOT_FOUND = f"{PATCH_CONSENT__DIRECTORY}errors/resource_not_found.yaml"
6364
PATCH_CONSENT__INVALID_STATE_TRANSITION = f"{PATCH_CONSENT__DIRECTORY}errors/invalid_state_transition.yaml"
6465

sandbox/api/patch_consent.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
PATCH_CONSENT__INVALID_STATUS_CODE,
1010
PATCH_CONSENT__RESOURCE_NOT_FOUND,
1111
PATCH_CONSENT__SUCCESS,
12+
PATCH_CONSENT__INVALID_STATUS_REASON,
1213
)
1314
from .utils import generate_response_from_example
1415

@@ -58,6 +59,10 @@ def patch_consent_response(identifier: str) -> Union[dict, tuple]:
5859
# Invalid state transition
5960
return generate_response_from_example(PATCH_CONSENT__INVALID_STATE_TRANSITION, 422)
6061

62+
elif identifier == "4b6792be":
63+
# Invalid status reason
64+
return generate_response_from_example(PATCH_CONSENT__INVALID_STATUS_REASON, 422)
65+
6166
else:
6267
# Resource not found
6368
return generate_response_from_example(PATCH_CONSENT__RESOURCE_NOT_FOUND, 404)

sandbox/api/tests/test_patch_consent.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
PATCH_CONSENT__INVALID_STATUS_CODE,
1212
PATCH_CONSENT__RESOURCE_NOT_FOUND,
1313
PATCH_CONSENT__SUCCESS,
14+
PATCH_CONSENT__INVALID_STATUS_REASON,
1415
)
1516

1617
CONSENT_API_ENDPOINT = "/FHIR/R4/Consent"
@@ -25,6 +26,7 @@
2526
("3a2679eb", PATCH_CONSENT__INVALID_PATCH_FORMAT, 400),
2627
("94df7c8f", PATCH_CONSENT__INVALID_PATH, 400),
2728
("2a7b736d", PATCH_CONSENT__INVALID_STATUS_CODE, 422),
29+
("4b6792be", PATCH_CONSENT__INVALID_STATUS_REASON, 422),
2830
("6fb4361b", PATCH_CONSENT__INVALID_STATE_TRANSITION, 422),
2931
("xxxxxxxx", PATCH_CONSENT__RESOURCE_NOT_FOUND, 404),
3032
("12345678", PATCH_CONSENT__RESOURCE_NOT_FOUND, 404),
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
PatchConsentInvalidStatusReasonError:
2+
summary: Bad request invalid status reason
3+
description: 422 error response for a request with an invalid status reason
4+
value:
5+
issue:
6+
- code: invalid
7+
diagnostics: "Invalid status reason."
8+
details:
9+
coding:
10+
- code: "INVALID_STATUS_REASON"
11+
display: "Status reason is invalid."
12+
system: "https://fhir.nhs.uk/R4/CodeSystem/ValidatedRelationships-ErrorOrWarningCode"
13+
version: '1'
14+
severity: error
15+
resourceType: "OperationOutcome"

specification/validated-relationships-service-api.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,7 @@ paths:
724724
| Invalid patch format | Malformed JSON patch document, request with id '3a2679eb' | HTTP Status 400 and INVALID_PATCH_FORMAT error response |
725725
| Invalid path | Patch targeting non-existent element, request with id '94df7c8f' | HTTP Status 400 and INVALID_PATCH_PATH error response |
726726
| Invalid status code | Patch with invalid status value, request with id '2a7b736d' | HTTP Status 422 and INVALID_STATUS_CODE error response |
727+
| Invalid status reason | Patch with invalid status reason value, request with id '4b6792be' | HTTP Status 422 and INVALID_STATUS_REASON error response |
727728
| Resource not found | Patch for non-existent Consent, request with an id not listed here | HTTP Status 404 and RESOURCE_NOT_FOUND error response |
728729
| Invalid state transition | Patch attempting invalid status change, request with id '6fb4361b' | HTTP Status 422 and INVALID_STATE_TRANSITION error response |
729730
parameters:
@@ -807,6 +808,7 @@ paths:
807808
| 415 | `UNSUPPORTED_MEDIA` | Unsupported media type. |
808809
| 422 | `INVALID_PATCH_PATH` | Invalid patch path. |
809810
| 422 | `INVALID_STATUS_CODE` | Invalid status code. |
811+
| 422 | `INVALID_STATUS_REASON` | Invalid status reason. |
810812
| 422 | `INVALID_STATE_TRANSITION` | Invalid state transition. |
811813
| 422 | `INVALID_LEGAL_BASIS_CODE` | Invalid legal basis code. |
812814
| 422 | `INVALID_END_DATE` | End date is invalid. |
@@ -824,6 +826,8 @@ paths:
824826
$ref: "./examples/responses/PATCH_Consent/errors/invalid_path.yaml#/PatchConsentInvalidPathError"
825827
patchConsentInvalidStatusCodeError:
826828
$ref: "./examples/responses/PATCH_Consent/errors/invalid_status_code.yaml#/PatchConsentInvalidStatusCodeError"
829+
PatchConsentInvalidStatusReasonError:
830+
$ref: "./examples/responses/PATCH_Consent/errors/invalid_status_reason.yaml#/PatchConsentInvalidStatusReasonError"
827831
patchConsentInvalidStateTransitionError:
828832
$ref: "./examples/responses/PATCH_Consent/errors/invalid_state_transition.yaml#/PatchConsentInvalidStateTransitionError"
829833
"5XX":

0 commit comments

Comments
 (0)