Skip to content

Commit 001742a

Browse files
Merge pull request #214 from NHSDigital/dev/NPA-5088/Update-Consent-id-to-be-UUID
NPA-5088: Update Consent id to be UUID in Spec and Sandbox Examples
2 parents 0da3c05 + e54fabe commit 001742a

File tree

5 files changed

+43
-57
lines changed

5 files changed

+43
-57
lines changed

sandbox/api/patch_consent.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
logger = getLogger(__name__)
1818

1919

20-
def patch_consent_response(identifier: str) -> Union[dict, tuple]:
20+
def patch_consent_response(id: str) -> Union[dict, tuple]:
2121
"""Sandbox API for PATCH /Consent
2222
2323
Args:
24-
identifier (str): Consent identifier to be patched
24+
id (str): Consent id to be patched
2525
2626
Returns:
2727
Union[dict, tuple]: Response for PATCH /Consent
@@ -31,38 +31,38 @@ def patch_consent_response(identifier: str) -> Union[dict, tuple]:
3131
# Validate body - validation is beyond the scope of the sandbox.
3232
# Assume all requests are valid
3333

34-
if identifier == "c6f48e4d":
34+
if id == "c512b0db-6702-43ee-8c21-bbded2552da9":
3535
# Successful status update
3636
return generate_response_from_example(PATCH_CONSENT__SUCCESS, 200)
3737

38-
elif identifier == "0c56a594":
38+
elif id == "6b71ac92-baa3-4b76-b0f5-a601257e2722":
3939
# Successful end date for a role
4040
return generate_response_from_example(PATCH_CONSENT__SUCCESS, 200)
4141

42-
elif identifier == "b02ea26c":
42+
elif id == "43003db8-ffcd-4bd6-ab2f-b49b9656f9e5":
4343
# Multiple valid changes
4444
return generate_response_from_example(PATCH_CONSENT__SUCCESS, 200)
4545

46-
elif identifier == "3a2679eb":
46+
elif id == "849ea584-2318-471b-a24c-cee1b5ad0137":
4747
# Invalid patch format
4848
return generate_response_from_example(PATCH_CONSENT__INVALID_PATCH_FORMAT, 400)
4949

50-
elif identifier == "94df7c8f":
50+
elif id == "01abb0c5-b1ac-499d-9655-9cd0b8d3588f":
5151
# Invalid path
5252
return generate_response_from_example(PATCH_CONSENT__INVALID_PATH, 400)
5353

54-
elif identifier == "2a7b736d":
54+
elif id == "78c35330-fa2f-4934-a5dd-fff847f38de5":
5555
# Invalid status code
5656
return generate_response_from_example(PATCH_CONSENT__INVALID_STATUS_CODE, 422)
5757

58-
elif identifier == "6fb4361b":
59-
# Invalid state transition
60-
return generate_response_from_example(PATCH_CONSENT__INVALID_STATE_TRANSITION, 422)
61-
62-
elif identifier == "4b6792be":
58+
elif id == "51fb4df5-815a-45cd-8427-04d6558336b7":
6359
# Invalid status reason
6460
return generate_response_from_example(PATCH_CONSENT__INVALID_STATUS_REASON, 422)
6561

62+
elif id == "7b7f47b8-96e5-43eb-b733-283bf1449f2c":
63+
# Invalid state transition
64+
return generate_response_from_example(PATCH_CONSENT__INVALID_STATE_TRANSITION, 422)
65+
6666
else:
6767
# Resource not found
6868
return generate_response_from_example(PATCH_CONSENT__RESOURCE_NOT_FOUND, 404)

sandbox/api/post_consent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def post_consent_response() -> Union[dict, tuple]:
3232
# Successful parent-child proxy creation
3333
# Successful adult-adult proxy creation
3434
if patient_identifier == "9000000009" or patient_identifier == "9000000017":
35-
header = {"location": f"{CONSENT_APP_BASE_PATH}/{patient_identifier}"}
35+
header = {"location": f"{CONSENT_APP_BASE_PATH}/90b9863e-e33c-4895-a333-fd0ea0e23205"}
3636
response = generate_response_from_example(POST_CONSENT__SUCCESS, 201, headers=header)
3737

3838
# Duplicate relationship

sandbox/api/tests/test_patch_consent.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
@pytest.mark.parametrize(
2121
("nhs_num", "response_file_name", "status_code"),
2222
[
23-
("c6f48e4d", PATCH_CONSENT__SUCCESS, 200),
24-
("0c56a594", PATCH_CONSENT__SUCCESS, 200),
25-
("b02ea26c", PATCH_CONSENT__SUCCESS, 200),
26-
("3a2679eb", PATCH_CONSENT__INVALID_PATCH_FORMAT, 400),
27-
("94df7c8f", PATCH_CONSENT__INVALID_PATH, 400),
28-
("2a7b736d", PATCH_CONSENT__INVALID_STATUS_CODE, 422),
29-
("4b6792be", PATCH_CONSENT__INVALID_STATUS_REASON, 422),
30-
("6fb4361b", PATCH_CONSENT__INVALID_STATE_TRANSITION, 422),
23+
("c512b0db-6702-43ee-8c21-bbded2552da9", PATCH_CONSENT__SUCCESS, 200),
24+
("6b71ac92-baa3-4b76-b0f5-a601257e2722", PATCH_CONSENT__SUCCESS, 200),
25+
("43003db8-ffcd-4bd6-ab2f-b49b9656f9e5", PATCH_CONSENT__SUCCESS, 200),
26+
("849ea584-2318-471b-a24c-cee1b5ad0137", PATCH_CONSENT__INVALID_PATCH_FORMAT, 400),
27+
("01abb0c5-b1ac-499d-9655-9cd0b8d3588f", PATCH_CONSENT__INVALID_PATH, 400),
28+
("78c35330-fa2f-4934-a5dd-fff847f38de5", PATCH_CONSENT__INVALID_STATUS_CODE, 422),
29+
("51fb4df5-815a-45cd-8427-04d6558336b7", PATCH_CONSENT__INVALID_STATUS_REASON, 422),
30+
("7b7f47b8-96e5-43eb-b733-283bf1449f2c", PATCH_CONSENT__INVALID_STATE_TRANSITION, 422),
3131
("xxxxxxxx", PATCH_CONSENT__RESOURCE_NOT_FOUND, 404),
3232
("12345678", PATCH_CONSENT__RESOURCE_NOT_FOUND, 404),
3333
],

sandbox/api/tests/test_post_consent.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@
1414

1515

1616
@pytest.mark.parametrize(
17-
("nhs_num", "response_file_name", "status_code", "location"),
17+
("nhs_num", "response_file_name", "status_code", "id"),
1818
[
1919
(
2020
"9000000009",
2121
POST_CONSENT__SUCCESS,
2222
201,
23-
"https://sandbox.api.service.nhs.uk/validated-relationships/FHIR/R4/Consent/9000000009",
23+
"90b9863e-e33c-4895-a333-fd0ea0e23205",
2424
),
2525
(
2626
"9000000017",
2727
POST_CONSENT__SUCCESS,
2828
201,
29-
"https://sandbox.api.service.nhs.uk/validated-relationships/FHIR/R4/Consent/9000000017",
29+
"90b9863e-e33c-4895-a333-fd0ea0e23205",
3030
),
3131
("9000000000", POST_CONSENT__PERFORMER_IDENTIFIER_ERROR, 422, None),
3232
("9000000049", POST_CONSENT__DUPLICATE_RELATIONSHIP_ERROR, 409, None),
@@ -37,7 +37,7 @@ def test_post_consent_when_valid_returns_expected_response(
3737
mock_generate_response_from_example: MagicMock,
3838
response_file_name: str,
3939
nhs_num: str,
40-
location: str,
40+
id: str,
4141
client: object,
4242
status_code: int,
4343
) -> None:
@@ -51,9 +51,11 @@ def test_post_consent_when_valid_returns_expected_response(
5151
json = {"performer": [{"identifier": {"value": nhs_num}}]}
5252
response = client.post(CONSENT_API_ENDPOINT, json=json)
5353
# Assert
54-
if location is not None:
54+
if id is not None:
5555
mock_generate_response_from_example.assert_called_once_with(
56-
response_file_name, status_code, headers={"location": location}
56+
response_file_name,
57+
status_code,
58+
headers={"location": f"https://sandbox.api.service.nhs.uk/validated-relationships/FHIR/R4/Consent/{id}"},
5759
)
5860
else:
5961
mock_generate_response_from_example.assert_called_once_with(response_file_name, status_code)

specification/validated-relationships-service-api.yaml

Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ paths:
653653
location:
654654
schema:
655655
type: string
656-
example: https://sandbox.api.service.nhs.uk/validated-relationships/FHIR/R4/Consent/9000000009
656+
example: https://sandbox.api.service.nhs.uk/validated-relationships/FHIR/R4/Consent/90b9863e-e33c-4895-a333-fd0ea0e23205
657657
description: URL for the newly created proxy role
658658
content:
659659
application/fhir+json:
@@ -841,35 +841,19 @@ paths:
841841
842842
See the postman collection for example requests.
843843
844-
| Scenario | Request | Response |
845-
| ------------------------------- | --------------------------------------------------------------------- | ------------------------------------------------------------- |
846-
| Successful status update | Valid patch changing status to 'active', request with id 'c6f48e4d' | HTTP Status 200 and OperationOutcome |
847-
| Successful access level update | Valid patch modifying the role end date, request with id '0c56a594' | HTTP Status 200 and OperationOutcome |
848-
| Multiple valid changes | Valid patch with multiple operations, request with id 'b02ea26c' | HTTP Status 200 and OperationOutcome |
849-
| Invalid patch format | Malformed JSON patch document, request with id '3a2679eb' | HTTP Status 400 and INVALID_PATCH_FORMAT error response |
850-
| Invalid path | Patch targeting non-existent element, request with id '94df7c8f' | HTTP Status 400 and INVALID_PATCH_PATH error response |
851-
| Invalid status code | Patch with invalid status value, request with id '2a7b736d' | HTTP Status 422 and INVALID_STATUS_CODE error response |
852-
| Invalid status reason | Patch with invalid status reason value, request with id '4b6792be' | HTTP Status 422 and INVALID_STATUS_REASON error response |
853-
| Resource not found | Patch for non-existent Consent, request with an id not listed here | HTTP Status 404 and RESOURCE_NOT_FOUND error response |
854-
| Invalid state transition | Patch attempting invalid status change, request with id '6fb4361b' | HTTP Status 422 and INVALID_STATE_TRANSITION error response |
844+
| Scenario | Request | Response |
845+
| ------------------------------- | ----------------------------------------------------------------------------------------------- | ------------------------------------------------------------- |
846+
| Successful status update | Valid patch changing status to 'active', request with id 'c512b0db-6702-43ee-8c21-bbded2552da9' | HTTP Status 200 and OperationOutcome |
847+
| Successful access level update | Valid patch modifying the role end date, request with id '6b71ac92-baa3-4b76-b0f5-a601257e2722' | HTTP Status 200 and OperationOutcome |
848+
| Multiple valid changes | Valid patch with multiple operations, request with id '43003db8-ffcd-4bd6-ab2f-b49b9656f9e5' | HTTP Status 200 and OperationOutcome |
849+
| Invalid patch format | Malformed JSON patch document, request with id '849ea584-2318-471b-a24c-cee1b5ad0137' | HTTP Status 400 and INVALID_PATCH_FORMAT error response |
850+
| Invalid path | Patch targeting non-existent element, request with id '01abb0c5-b1ac-499d-9655-9cd0b8d3588f' | HTTP Status 400 and INVALID_PATCH_PATH error response |
851+
| Invalid status code | Patch with invalid status value, request with id '78c35330-fa2f-4934-a5dd-fff847f38de5' | HTTP Status 422 and INVALID_STATUS_CODE error response |
852+
| Invalid status reason | Patch with invalid status reason value, request with id '51fb4df5-815a-45cd-8427-04d6558336b7' | HTTP Status 422 and INVALID_STATUS_REASON error response |
853+
| Resource not found | Patch for non-existent Consent, request with an id not listed here | HTTP Status 404 and RESOURCE_NOT_FOUND error response |
854+
| Invalid state transition | Patch attempting invalid status change, request with id '7b7f47b8-96e5-43eb-b733-283bf1449f2c' | HTTP Status 422 and INVALID_STATE_TRANSITION error response |
855855
parameters:
856-
# Change id parameter to Component ConsentID when NPA-5088 is complete
857-
- name: id
858-
in: path
859-
required: true
860-
description: The logical id of the Consent resource to update
861-
schema:
862-
type: string
863-
examples:
864-
statusUpdate:
865-
value: c6f48e4d
866-
summary: Update consent status
867-
updateProvision:
868-
value: 0c56a594
869-
summary: Set an end date for a role
870-
multipleUpdates:
871-
value: b02ea26c
872-
summary: Set status to active with an end date
856+
- $ref: "#/components/parameters/ConsentID"
873857
requestBody:
874858
required: true
875859
content:

0 commit comments

Comments
 (0)