Skip to content

Commit 54055c4

Browse files
authored
NPA-5537: Add Default Legal Basis (#264)
# Pull Request ## 🧾 Ticket Link <!-- Add the Jira ticket link here --> https://nhsd-jira.digital.nhs.uk/browse/NPA-5537 --- ## 📄 Description/Summary of Changes <!-- Describe the changes made in this PR. Include the purpose/scope/impact of the changes --> - New spec for unknown legal basis - Updated tests - Updated get_consent.py - Updated postman spec --- ## 🧪 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 --> - Ran new test in postman --- ## 🧪 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 682e850 commit 54055c4

File tree

7 files changed

+227
-10
lines changed

7 files changed

+227
-10
lines changed

postman/Validated Relationship Service Sandbox.postman_collection.json

Lines changed: 146 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
{
22
"info": {
3-
"_postman_id": "e45a02c2-af60-4d4c-b790-c6708ae0f214",
4-
"name": "Validated Relationship Service Sandbox 03/11/25",
3+
"_postman_id": "4fd91043-1337-4f8b-92c9-96c597b343c8",
4+
"name": "Validated Relationship Service Sandbox 04/11/25",
55
"description": "This Postman collection includes example scenarios for each of the Validated Relationship Service (VRS) API endpoints, covering both valid and invalid request scenarios.\n\nThe collection is pointed towards the VRS sandbox environment, which will return a specific example response based on the request sent. All data shown in the requests or responses is test data.\n\nOur sandbox environment only covers the scenarios listed in the Postman collection and is open access. It does not allow you to test authorisation or any scenarios beyond the ones documented.\n\nFull specification is available at [https://digital.nhs.uk/developer/api-catalogue/validated-relationship-service](https://digital.nhs.uk/developer/api-catalogue/validated-relationship-service)",
66
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
7-
"_exporter_id": "44536620",
8-
"_collection_link": "https://l44444-2379.postman.co/workspace/aac72fed-09cc-4a02-a0b4-9429fb546dba/collection/44536620-e45a02c2-af60-4d4c-b790-c6708ae0f214?action=share&source=collection_link&creator=44536620"
7+
"_exporter_id": "26376766"
98
},
109
"item": [
1110
{
@@ -7351,6 +7350,144 @@
73517350
},
73527351
"response": []
73537352
},
7353+
{
7354+
"name": "Single mother-child relationship unknown legal basis",
7355+
"event": [
7356+
{
7357+
"listen": "test",
7358+
"script": {
7359+
"exec": [
7360+
"const expectedResponseBody = {",
7361+
" \"resourceType\": \"Bundle\",",
7362+
" \"timestamp\": \"2020-08-26T14:00:00+00:00\",",
7363+
" \"total\": 1,",
7364+
" \"type\": \"searchset\",",
7365+
" \"link\": [",
7366+
" {",
7367+
" \"relation\": \"self\",",
7368+
" \"url\": \"https://sandbox.api.service.nhs.uk/validated-relationships/FHIR/R4/Consent?performer:identifier=9000000111\"",
7369+
" }",
7370+
" ],",
7371+
" \"entry\": [",
7372+
" {",
7373+
" \"fullUrl\": \"https://api.service.nhs.uk/validated-relationships/FHIR/R4/Consent/AF974742\",",
7374+
" \"resource\": {",
7375+
" \"resourceType\": \"Consent\",",
7376+
" \"id\": \"AF974742\",",
7377+
" \"status\": \"active\",",
7378+
" \"scope\": {",
7379+
" \"coding\": [",
7380+
" {",
7381+
" \"system\": \"http://terminology.hl7.org/CodeSystem/consentscope\",",
7382+
" \"code\": \"patient-privacy\",",
7383+
" \"display\": \"Privacy Consent\"",
7384+
" }",
7385+
" ],",
7386+
" \"text\": \"Patient Privacy Consent\"",
7387+
" },",
7388+
" \"category\": [",
7389+
" {",
7390+
" \"coding\": [",
7391+
" {",
7392+
" \"system\": \"http://terminology.hl7.org/CodeSystem/v3-ActCode\",",
7393+
" \"code\": \"INFA\",",
7394+
" \"display\": \"Information Access\"",
7395+
" }",
7396+
" ],",
7397+
" \"text\": \"Information Access Consent\"",
7398+
" }",
7399+
" ],",
7400+
" \"patient\": {",
7401+
" \"identifier\": {",
7402+
" \"system\": \"https://fhir.nhs.uk/Id/nhs-number\",",
7403+
" \"value\": \"9000000119\"",
7404+
" }",
7405+
" },",
7406+
" \"dateTime\": \"2024-07-21T17:32:28Z\",",
7407+
" \"performer\": [",
7408+
" {",
7409+
" \"identifier\": {",
7410+
" \"system\": \"https://fhir.nhs.uk/Id/nhs-number\",",
7411+
" \"value\": \"9000000111\"",
7412+
" }",
7413+
" }",
7414+
" ],",
7415+
" \"policy\": [",
7416+
" {",
7417+
" \"authority\": \"https://www.england.nhs.uk\",",
7418+
" \"uri\": \"REPLACE_WITH_LINK_TO_PUBLISHED_NATIONAL_PROXY_STANDARD\",",
7419+
" \"code\": \"unknown\",",
7420+
" \"display\": \"Unknown legal basis\"",
7421+
" }",
7422+
" ],",
7423+
" \"provision\": {",
7424+
" \"actor\": [",
7425+
" {",
7426+
" \"reference\": {",
7427+
" \"identifier\": {",
7428+
" \"system\": \"https://fhir.nhs.uk/Id/nhs-number\",",
7429+
" \"value\": \"9000000111\"",
7430+
" },",
7431+
" \"type\": \"RelatedPerson\"",
7432+
" },",
7433+
" \"role\": {",
7434+
" \"coding\": [",
7435+
" {",
7436+
" \"code\": \"unknown\",",
7437+
" \"display\": \"Unknown\",",
7438+
" \"system\": \"https://fhir.nhs.uk/CodeSystem/proxy-legal-basis\"",
7439+
" }",
7440+
" ]",
7441+
" }",
7442+
" }",
7443+
" ],",
7444+
" \"period\": {",
7445+
" \"start\": \"2025-02-11\",",
7446+
" \"end\": \"2026-02-11\"",
7447+
" }",
7448+
" }",
7449+
" },",
7450+
" \"search\": {",
7451+
" \"mode\": \"match\"",
7452+
" }",
7453+
" }",
7454+
" ]",
7455+
"}",
7456+
"",
7457+
"pm.test(\"Status code is 200\", function () {",
7458+
" pm.response.to.have.status(200);",
7459+
"});",
7460+
"",
7461+
"pm.test(\"Should have correct response body\", () => {",
7462+
" const responseJson = pm.response.json();",
7463+
" pm.expect(responseJson).to.eql(expectedResponseBody);",
7464+
"});"
7465+
],
7466+
"type": "text/javascript"
7467+
}
7468+
}
7469+
],
7470+
"request": {
7471+
"method": "GET",
7472+
"header": [],
7473+
"url": {
7474+
"raw": "{{api_base_url}}/Consent?performer:identifier=9000000111",
7475+
"host": [
7476+
"{{api_base_url}}"
7477+
],
7478+
"path": [
7479+
"Consent"
7480+
],
7481+
"query": [
7482+
{
7483+
"key": "performer:identifier",
7484+
"value": "9000000111"
7485+
}
7486+
]
7487+
}
7488+
},
7489+
"response": []
7490+
},
73547491
{
73557492
"name": "No performer record found",
73567493
"event": [
@@ -10166,7 +10303,6 @@
1016610303
"listen": "prerequest",
1016710304
"script": {
1016810305
"type": "text/javascript",
10169-
"packages": {},
1017010306
"exec": [
1017110307
""
1017210308
]
@@ -10176,7 +10312,6 @@
1017610312
"listen": "test",
1017710313
"script": {
1017810314
"type": "text/javascript",
10179-
"packages": {},
1018010315
"exec": [
1018110316
"pm.test(\"Response has FHIR content type\", () => {",
1018210317
" pm.expect(pm.response.headers.get('Content-Type')).to.include('application/fhir+json');",
@@ -10189,6 +10324,11 @@
1018910324
{
1019010325
"key": "api_base_url",
1019110326
"value": "https://sandbox.api.service.nhs.uk/validated-relationships/FHIR/R4"
10327+
},
10328+
{
10329+
"value": "",
10330+
"type": "string",
10331+
"disabled": true
1019210332
}
1019310333
]
1019410334
}

sandbox/api/constants.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@
7171
GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT_INCLUDE_BOTH = (
7272
f"{GET_CONSENT__DIRECTORY}multiple-relationships-single-patient-include-performer-patient.yaml"
7373
)
74+
GET_CONSENT__SINGLE_MOTHER_CHILD_RELATIONSHIP_UNKNOWN_LEGAL_BASIS = (
75+
f"{GET_CONSENT__DIRECTORY}single-mother-child-relationship-unknown-legal-basis.yaml"
76+
)
7477

7578
# GET Consent by ID
7679
GET_CONSENT_BY_ID__INVALID_ID_ERROR = f"{GET_CONSENT__DIRECTORY}ID/errors/invalid-id.yaml"

sandbox/api/get_consent.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
GET_CONSENT__SINGLE_MOTHER_CHILD_RELATIONSHIP_INCLUDE_BOTH,
2323
INTERNAL_SERVER_ERROR_EXAMPLE,
2424
INVALIDATED_RESOURCE,
25+
GET_CONSENT__SINGLE_MOTHER_CHILD_RELATIONSHIP_UNKNOWN_LEGAL_BASIS,
2526
)
2627
from .utils import (
2728
check_for_consent_filtering,
@@ -65,6 +66,13 @@ def get_consent_response() -> Union[dict, tuple]:
6566
GET_CONSENT__SINGLE_MOTHER_CHILD_RELATIONSHIP,
6667
GET_CONSENT__SINGLE_MOTHER_CHILD_RELATIONSHIP_INCLUDE_BOTH,
6768
)
69+
# Single mother-child relationship with unknown legal basis
70+
elif performer_identifier == "9000000111" or patient_identifier == "9000000119":
71+
return check_for_consent_include_params(
72+
_include,
73+
GET_CONSENT__SINGLE_MOTHER_CHILD_RELATIONSHIP_UNKNOWN_LEGAL_BASIS,
74+
)
75+
6876
elif patient_identifier == "9000000100":
6977
return check_for_consent_include_params(
7078
_include,

sandbox/api/tests/test_get_consent.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,11 @@ def test_get_consent_returns_expected_responses__mocked_get_consent(
168168
"./api/examples/GET_Consent/multiple-relationships-single-patient-include-performer-patient.yaml",
169169
200,
170170
),
171+
(
172+
"performer:identifier=9000000111&patient:identifier=9000000119",
173+
"./api/examples/GET_Consent/single-mother-child-relationship-unknown-legal-basis.yaml",
174+
200,
175+
),
171176
(
172177
"performer:identifier=9000000017&status=test", # Invalid status parameter error
173178
"./api/examples/GET_Consent/errors/invalid-status-parameter.yaml",

sandbox/api/utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ def generate_response_from_example(example_path: str, status_code: int, headers:
229229
def check_for_consent_include_params(
230230
_include: List[str],
231231
include_none_response_yaml: str,
232-
include_both_response_yaml: str,
232+
include_both_response_yaml: str = None,
233233
include_patient_response_yaml: str = None,
234234
include_performer_response_yaml: str = None,
235235
) -> Response:
@@ -238,7 +238,8 @@ def check_for_consent_include_params(
238238
Args:
239239
_include (List[str]): The include parameters supplied to the request
240240
include_none_response_yaml (str): Bundle to return when include params are empty
241-
include_both_response_yaml (str): Bundle to return when include param is Consent:performer,Consent:patient
241+
include_both_response_yaml (str): (optional) Bundle to return when include param
242+
is Consent:performer,Consent:patient
242243
include_patient_response_yaml (str): (optional) Bundle to return when include param is Consent:patient
243244
include_performer_response_yaml (str): (optional) Bundle to return when include param is Consent:performer
244245
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
ConsentSingleAdultChildRelationshipUnknownLegalBasisBundle:
2+
summary: Single adult-child proxy relationship with unknown legal basis
3+
description: A Bundle containing a single proxy relationship between an adult and child where the legal basis is unknown
4+
value:
5+
resourceType: Bundle
6+
timestamp: '2020-08-26T14:00:00+00:00'
7+
total: 1
8+
type: searchset
9+
link:
10+
- relation: self
11+
url: https://sandbox.api.service.nhs.uk/validated-relationships/FHIR/R4/Consent?performer:identifier=9000000111
12+
entry:
13+
- fullUrl: https://api.service.nhs.uk/validated-relationships/FHIR/R4/Consent/AF974742
14+
resource:
15+
resourceType: Consent
16+
id: AF974742
17+
status: active
18+
scope:
19+
coding:
20+
- system: 'http://terminology.hl7.org/CodeSystem/consentscope'
21+
code: patient-privacy
22+
display: Privacy Consent
23+
text: Patient Privacy Consent
24+
category:
25+
- coding:
26+
- system: 'http://terminology.hl7.org/CodeSystem/v3-ActCode'
27+
code: INFA
28+
display: Information Access
29+
text: Information Access Consent
30+
patient:
31+
identifier:
32+
system: 'https://fhir.nhs.uk/Id/nhs-number'
33+
value: '9000000119'
34+
dateTime: '2024-07-21T17:32:28Z'
35+
performer:
36+
- identifier:
37+
system: 'https://fhir.nhs.uk/Id/nhs-number'
38+
value: '9000000111'
39+
policy:
40+
- authority: https://www.england.nhs.uk
41+
uri: REPLACE_WITH_LINK_TO_PUBLISHED_NATIONAL_PROXY_STANDARD
42+
code: unknown
43+
display: Unknown legal basis
44+
provision:
45+
actor:
46+
- reference:
47+
identifier:
48+
system: https://fhir.nhs.uk/Id/nhs-number
49+
value: '9000000111'
50+
type: RelatedPerson
51+
role:
52+
coding:
53+
- code: unknown
54+
display: Unknown
55+
system: https://fhir.nhs.uk/CodeSystem/proxy-legal-basis
56+
period:
57+
start: '2025-02-11'
58+
end: '2026-02-11'
59+
search:
60+
mode: match

specification/validated-relationships-service-api.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,7 @@ info:
141141
* only covers a limited set of scenarios
142142
* is open access, so does not allow you to test authorisation
143143
144-
[<img src="https://run.pstmn.io/button.svg" alt="Run In Postman" style="width: 128px; height: 32px;">](https://app.getpostman.com/run-collection/44536620-e45a02c2-af60-4d4c-b790-c6708ae0f214?action=collection%2Ffork&source=rip_markdown&collection-url=entityId%3D44536620-e45a02c2-af60-4d4c-b790-c6708ae0f214%26entityType%3Dcollection%26workspaceId%3D65d46c77-2ee2-4fb0-92de-2ec03857a9e6)
145-
144+
[<img src="https://run.pstmn.io/button.svg" alt="Run In Postman" style="width: 128px; height: 32px;">](https://app.getpostman.com/run-collection/26376766-4fd91043-1337-4f8b-92c9-96c597b343c8?action=collection%2Ffork&collection-url=entityId%3D26376766-4fd91043-1337-4f8b-92c9-96c597b343c8%26entityType%3Dcollection%26workspaceId%3D8fc7bffa-055c-43e2-b94b-da0fdce3aa4b)
146145
### Integration testing
147146
148147
Our [integration test environment](https://digital.nhs.uk/developer/guides-and-documentation/testing#integration-testing)
@@ -563,6 +562,7 @@ paths:
563562
| A single proxy relationship between consenting adults including details | `performer:identifier=9000000010` and/or `patient:identifier=9000000005&_include=Consent:patient&_include=Consent:proxy` | HTTP Status 200 Bundle containing a single proxy relationship including performer and patient details |
564563
| A single proxy relationship between a mother and child | `performer:identifier=9000000019` and/or `patient:identifier=9000000009` | HTTP Status 200 Bundle containing a single proxy relationship |
565564
| A single proxy relationship between a mother and child including details | `performer:identifier=9000000019` and/or `patient:identifier=9000000009&_include=Consent:patient&_include=Consent:proxy` | HTTP Status 200 Bundle containing a single proxy relationship including performer and patient details |
565+
| A single proxy relationship between a mother and child with legal basis unknown | `performer:identifier=9000000111` and/or `patient:identifier=9000000119` | HTTP Status 200 Bundle containing a single proxy relationship with legal basis unknown |
566566
| Invalid status parameter | `performer:identifier=9000000019` and/or `patient:identifier=9000000009&status=test` | HTTP Status 422 and INVALID_PARAMETER error response |
567567
| Invalid include parameter | `performer:identifier=9000000019` and/or `patient:identifier=9000000009&_include=test` | HTTP Status 422 and INVALID_PARAMETER error response |
568568
| Missing identifier | `patient:identifier=9000000009` | HTTP Status 400 and MISSING_IDENTIFIER_VALUE error response |

0 commit comments

Comments
 (0)