Skip to content

Commit 6f51938

Browse files
authored
NPA-6153: Create Update Proxy Role Grantor Field (#300)
# Pull Request ## 🧾 Ticket Link <!-- Add the Jira ticket link here --> https://nhsd-jira.digital.nhs.uk/browse/NPA-6153 --- ## 📄 Description/Summary of Changes <!-- Describe the changes made in this PR. Include the purpose/scope/impact of the changes --> - Added grantor validation logic to ensure active proxy roles contain a valid ODS code in the grantor extension with correct FHIR structure and identifier system - Updated spec files - Updated sandbox code for relevant endpoints and added unit test scenarios --- ## 🧪 Developer Testing Carried Out <!-- Describe what tests (automated/unit/manual etc.) have been done for the ticket. Include: --> <!-- - Any tests added/updated --> <!-- - Evidence that each acceptance criterion from the Jira ticket is met --> - <!-- Add bullet points for testing instructions --> - <!-- Add bullet points for testing instructions --> - <!-- Add bullet points for testing instructions --> --- ## 🧪 Reviewer Testing Required <!-- Describe how to test the changes that have been made in the ticket. Include: --> <!-- - Testing environment details (e.g. sandbox/local setup) --> <!-- - Steps to verify the changes --> - [ ] <!-- Add bullet points for testing instructions --> - [ ] <!-- Add bullet points for testing instructions --> - [ ] <!-- Add bullet points for testing instructions --> --- ## ✅ Developer Checklist <!-- Complete before submitting the PR --> - [x] PR title follows the format: `NPA-XXXX: <short-description>` - [x] Branch name follows the convention: `<type>/NPA-XXXX/<short-description>` - [x] Commit messages follow the template: `NPA-XXXX: <short-description>` - [x] All acceptance criteria from the Jira ticket are addressed - [x] Automated tests (unit/integration/API/infrastructure etc. tests) are added or updated - [x] Assignees and appropriate labels (e.g. `terraform`, `documentation`) are added --- ## 👀 Reviewer Checklist <!-- To be completed by the reviewer --> - [ ] Changes meet the acceptance criteria of the Jira ticket - [ ] Code is able to be merged (no conflicts and adheres to coding standards) - [ ] Sufficient test evidence is provided (manual and/or automated) - [ ] Infrastructure/operational/build changes are validated (if applicable) --- ## 🚀 Post-merge <!-- Actions to complete after merging --> After merging and deploying changes to the sandbox, Postman collection or spec examples please run the Run Postman collection workflow. This will run the tests within the collection to check that the sandbox is working as expected once deployed.
1 parent 913d059 commit 6f51938

File tree

35 files changed

+1817
-157
lines changed

35 files changed

+1817
-157
lines changed

.github/pull_request_template.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ https://nhsd-jira.digital.nhs.uk/browse/NPA-XXXX
3636
<!-- - Testing environment details (e.g. sandbox/local setup) -->
3737
<!-- - Steps to verify the changes -->
3838

39-
- [ ] <!-- Add bullet points for testing instructions -->
40-
- [ ] <!-- Add bullet points for testing instructions -->
41-
- [ ] <!-- Add bullet points for testing instructions -->
39+
- <!-- Add bullet points for testing instructions -->
40+
- <!-- Add bullet points for testing instructions -->
41+
- <!-- Add bullet points for testing instructions -->
4242

4343
---
4444

postman/validated_relationship_service.integration.postman_collection.json

Lines changed: 959 additions & 148 deletions
Large diffs are not rendered by default.

postman/validated_relationship_service.sandbox.postman_collection.json

Lines changed: 463 additions & 3 deletions
Large diffs are not rendered by default.

sandbox/api/constants.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@
8383
POST_CONSENT__SUCCESS = f"{POST_CONSENT__DIRECTORY}success.yaml"
8484
POST_CONSENT__DUPLICATE_RELATIONSHIP_ERROR = f"{POST_CONSENT__DIRECTORY}errors/duplicate_relationship_error.yaml"
8585
POST_CONSENT__MISSING_FREE_TEXT_FOR_OTHER = f"{POST_CONSENT__DIRECTORY}errors/missing_free_text_for_other.yaml"
86+
POST_CONSENT__MISSING_GRANTOR = f"{POST_CONSENT__DIRECTORY}errors/missing_grantor.yaml"
87+
POST_CONSENT__INVALID_GRANTOR_VALUE = f"{POST_CONSENT__DIRECTORY}errors/invalid_grantor_identifier_value.yaml"
88+
POST_CONSENT__INVALID_GRANTOR_SYSTEM = f"{POST_CONSENT__DIRECTORY}errors/invalid_grantor_identifier_system.yaml"
89+
POST_CONSENT__MISSING_GRANTOR_REFERENCE = f"{POST_CONSENT__DIRECTORY}errors/missing_grantor_reference.yaml"
8690

8791
# PATCH Consent
8892
PATCH_CONSENT__DIRECTORY = "./api/examples/PATCH_Consent/"
@@ -94,6 +98,7 @@
9498
PATCH_CONSENT__RESOURCE_NOT_FOUND = f"{PATCH_CONSENT__DIRECTORY}errors/resource_not_found.yaml"
9599
PATCH_CONSENT__INVALID_STATE_TRANSITION = f"{PATCH_CONSENT__DIRECTORY}errors/invalid_state_transition.yaml"
96100
PATCH_CONSENT__MISSING_FREE_TEXT_FOR_OTHER = f"{PATCH_CONSENT__DIRECTORY}errors/missing_free_text_for_other.yaml"
101+
PATCH_CONSENT__MISSING_GRANTOR_FOR_ACTIVE = f"{PATCH_CONSENT__DIRECTORY}errors/missing_grantor_for_active_status.yaml"
97102

98103
# POST QuestionnaireResponse
99104
POST_QUESTIONNAIRE_RESPONSE_DIRECTORY = "./api/examples/POST_QuestionnaireResponse/"

sandbox/api/patch_consent.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
PATCH_CONSENT__SUCCESS,
1212
PATCH_CONSENT__INVALID_STATUS_REASON,
1313
PATCH_CONSENT__MISSING_FREE_TEXT_FOR_OTHER,
14+
PATCH_CONSENT__MISSING_GRANTOR_FOR_ACTIVE,
1415
)
1516
from .utils import generate_response_from_example
1617

@@ -82,6 +83,10 @@ def patch_consent_response(id: str) -> Union[dict, tuple]:
8283
# Non-OTHER reason code WITH free text (should succeed)
8384
return generate_response_from_example(PATCH_CONSENT__SUCCESS, 200)
8485

86+
elif id == "90957744-b971-496e-b7c3-ab971868ce14":
87+
# PATCH to activate proxy role without providing grantor extension
88+
return generate_response_from_example(PATCH_CONSENT__MISSING_GRANTOR_FOR_ACTIVE, 400)
89+
8590
else:
8691
# Resource not found
8792
return generate_response_from_example(PATCH_CONSENT__RESOURCE_NOT_FOUND, 404)

sandbox/api/post_consent.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
POST_CONSENT__DUPLICATE_RELATIONSHIP_ERROR,
99
POST_CONSENT__SUCCESS,
1010
POST_CONSENT__MISSING_FREE_TEXT_FOR_OTHER,
11+
POST_CONSENT__MISSING_GRANTOR,
12+
POST_CONSENT__INVALID_GRANTOR_VALUE,
13+
POST_CONSENT__INVALID_GRANTOR_SYSTEM,
14+
POST_CONSENT__MISSING_GRANTOR_REFERENCE,
1115
)
1216
from .utils import generate_response_from_example
1317

@@ -59,6 +63,22 @@ def post_consent_response() -> Union[dict, tuple]:
5963
header = {"location": f"{CONSENT_APP_BASE_PATH}/c3d4e5f6-a7b8-4901-c2d3-e4f5a6b7c8d9"}
6064
response = generate_response_from_example(POST_CONSENT__SUCCESS, 201, headers=header)
6165

66+
elif patient_identifier == "9000000054":
67+
# Missing grantor entirely when active
68+
response = generate_response_from_example(POST_CONSENT__MISSING_GRANTOR, 400)
69+
70+
elif patient_identifier == "9000000055":
71+
# Invalid/empty ODS code
72+
response = generate_response_from_example(POST_CONSENT__INVALID_GRANTOR_VALUE, 422)
73+
74+
elif patient_identifier == "9000000056":
75+
# Wrong system
76+
response = generate_response_from_example(POST_CONSENT__INVALID_GRANTOR_SYSTEM, 422)
77+
78+
elif patient_identifier == "9000000057":
79+
# Missing valueReference/identifier
80+
response = generate_response_from_example(POST_CONSENT__MISSING_GRANTOR_REFERENCE, 400)
81+
6282
else:
6383
# Out of scope errors
6484
raise ValueError("Invalid Request")

sandbox/api/tests/test_patch_consent.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
PATCH_CONSENT__SUCCESS,
1414
PATCH_CONSENT__INVALID_STATUS_REASON,
1515
PATCH_CONSENT__MISSING_FREE_TEXT_FOR_OTHER,
16+
PATCH_CONSENT__MISSING_GRANTOR_FOR_ACTIVE,
1617
)
1718

1819
CONSENT_API_ENDPOINT = "/FHIR/R4/Consent"
@@ -50,6 +51,11 @@
5051
PATCH_CONSENT__MISSING_FREE_TEXT_FOR_OTHER,
5152
400,
5253
),
54+
(
55+
"90957744-b971-496e-b7c3-ab971868ce14",
56+
PATCH_CONSENT__MISSING_GRANTOR_FOR_ACTIVE,
57+
400,
58+
),
5359
(
5460
"a1b2c3d4-e5f6-4789-a0b1-c2d3e4f5a6b7",
5561
PATCH_CONSENT__SUCCESS,

sandbox/api/tests/test_post_consent.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
POST_CONSENT__DUPLICATE_RELATIONSHIP_ERROR,
99
POST_CONSENT__SUCCESS,
1010
POST_CONSENT__MISSING_FREE_TEXT_FOR_OTHER,
11+
POST_CONSENT__MISSING_GRANTOR,
12+
POST_CONSENT__INVALID_GRANTOR_VALUE,
13+
POST_CONSENT__INVALID_GRANTOR_SYSTEM,
14+
POST_CONSENT__MISSING_GRANTOR_REFERENCE,
1115
)
1216

1317
CONSENT_API_ENDPOINT = "/FHIR/R4/Consent"
@@ -35,6 +39,30 @@
3539
400,
3640
None,
3741
),
42+
(
43+
"9000000054",
44+
POST_CONSENT__MISSING_GRANTOR,
45+
400,
46+
None,
47+
),
48+
(
49+
"9000000055",
50+
POST_CONSENT__INVALID_GRANTOR_VALUE,
51+
422,
52+
None,
53+
),
54+
(
55+
"9000000056",
56+
POST_CONSENT__INVALID_GRANTOR_SYSTEM,
57+
422,
58+
None,
59+
),
60+
(
61+
"9000000057",
62+
POST_CONSENT__MISSING_GRANTOR_REFERENCE,
63+
400,
64+
None,
65+
),
3866
(
3967
"9000000051",
4068
POST_CONSENT__SUCCESS,

specification/examples/requests/POST_Consent/adult_to_adult_proxy_creation.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,9 @@ ConsentAdultToAdultGuardianRequest:
4646
identifier:
4747
system: https://fhir.nhs.uk/Id/nhs-number
4848
value: '9000000017'
49+
- url: http://hl7.org/fhir/5.0/StructureDefinition/extension-Consent.grantor
50+
valueReference:
51+
identifier:
52+
system: https://fhir.nhs.uk/Id/ods-organization-code
53+
value: "G8101234"
54+

specification/examples/requests/POST_Consent/parent_child_proxy_creation.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,8 @@ ConsentParentChildProxyCreationRequest:
4747
identifier:
4848
system: https://fhir.nhs.uk/Id/nhs-number
4949
value: '9000000009'
50+
- url: http://hl7.org/fhir/5.0/StructureDefinition/extension-Consent.grantor
51+
valueReference:
52+
identifier:
53+
system: https://fhir.nhs.uk/Id/ods-organization-code
54+
value: "G8101234"

0 commit comments

Comments
 (0)