Skip to content

Commit cc03a14

Browse files
authored
Merge pull request #195 from NHSDigital/dev/NPA-4922_GET_Consent_Patient_Identifier_Sandbox_Scenarios
NPA-4922 `GET /Consent` Patient Identifier Sandbox Scenarios
2 parents 7ef7a93 + 771c1bb commit cc03a14

File tree

9 files changed

+453
-69
lines changed

9 files changed

+453
-69
lines changed

postman/Validate Relationship Service Sandbox.postman_collection.json

Lines changed: 222 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"info": {
3-
"_postman_id": "ab2b3bfb-f318-4111-b6c5-658952be5b85",
4-
"name": "Validate Relationship Service Sandbox 11/04/25",
3+
"_postman_id": "a5dcb0b1-ad72-4665-942e-2041cc61e26d",
4+
"name": "Validate Relationship Service Sandbox 01/05/25",
55
"description": "Example usage of the Validate Relationship Service (VRS) sandbox.\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",
77
"_exporter_id": "34042403",
8-
"_collection_link": "https://www.postman.com/jackplowman2/workspace/validate-relationship-service-sandbox-11-04-25/collection/34042403-ab2b3bfb-f318-4111-b6c5-658952be5b85?action=share&source=collection_link&creator=34042403"
8+
"_collection_link": "https://www.postman.com/jackplowman2/validate-relationship-service-sandbox-01-05-25/collection/jcpiqj2/validate-relationship-service-sandbox-01-05-25?action=share&source=collection_link&creator=34042403"
99
},
1010
"item": [
1111
{
@@ -3563,6 +3563,225 @@
35633563
},
35643564
"response": []
35653565
},
3566+
{
3567+
"name": "Multiple proxy relationships single patient",
3568+
"event": [
3569+
{
3570+
"listen": "test",
3571+
"script": {
3572+
"exec": [
3573+
"const expectedResponseBody = {",
3574+
" \"resourceType\": \"Bundle\",",
3575+
" \"timestamp\": \"2020-08-26T14:00:00+00:00\",",
3576+
" \"total\": 3,",
3577+
" \"type\": \"searchset\",",
3578+
" \"entry\": [",
3579+
" {",
3580+
" \"fullUrl\": \"https://api.service.nhs.uk/validated-relationships/FHIR/R4/Consent/BBCC67E9\",",
3581+
" \"resource\": {",
3582+
" \"resourceType\": \"Consent\",",
3583+
" \"id\": \"BBCC67E9\",",
3584+
" \"status\": \"active\",",
3585+
" \"scope\": {",
3586+
" \"coding\": [",
3587+
" {",
3588+
" \"system\": \"http://terminology.hl7.org/CodeSystem/consentscope\",",
3589+
" \"code\": \"patient-privacy\",",
3590+
" \"display\": \"Privacy Consent\"",
3591+
" }",
3592+
" ],",
3593+
" \"text\": \"Patient Privacy Consent\"",
3594+
" },",
3595+
" \"category\": [",
3596+
" {",
3597+
" \"coding\": [",
3598+
" {",
3599+
" \"system\": \"http://terminology.hl7.org/CodeSystem/v3-ActCode\",",
3600+
" \"code\": \"INFA\",",
3601+
" \"display\": \"Information Access\"",
3602+
" }",
3603+
" ],",
3604+
" \"text\": \"Information Access Consent\"",
3605+
" }",
3606+
" ],",
3607+
" \"patient\": {",
3608+
" \"identifier\": {",
3609+
" \"system\": \"https://fhir.nhs.uk/Id/nhs-number\",",
3610+
" \"value\": \"9000000100\"",
3611+
" }",
3612+
" },",
3613+
" \"dateTime\": \"2024-07-21T17:32:28Z\",",
3614+
" \"performer\": [",
3615+
" {",
3616+
" \"identifier\": {",
3617+
" \"system\": \"https://fhir.nhs.uk/Id/nhs-number\",",
3618+
" \"value\": \"9000000020\"",
3619+
" }",
3620+
" }",
3621+
" ]",
3622+
" },",
3623+
" \"search\": {",
3624+
" \"mode\": \"match\"",
3625+
" }",
3626+
" },",
3627+
" {",
3628+
" \"fullUrl\": \"https://api.service.nhs.uk/validated-relationships/FHIR/R4/Consent/WWCC67T1\",",
3629+
" \"resource\": {",
3630+
" \"resourceType\": \"Consent\",",
3631+
" \"id\": \"WWCC67T1\",",
3632+
" \"status\": \"active\",",
3633+
" \"scope\": {",
3634+
" \"coding\": [",
3635+
" {",
3636+
" \"system\": \"http://terminology.hl7.org/CodeSystem/consentscope\",",
3637+
" \"code\": \"patient-privacy\",",
3638+
" \"display\": \"Privacy Consent\"",
3639+
" }",
3640+
" ],",
3641+
" \"text\": \"Patient Privacy Consent\"",
3642+
" },",
3643+
" \"category\": [",
3644+
" {",
3645+
" \"coding\": [",
3646+
" {",
3647+
" \"system\": \"http://terminology.hl7.org/CodeSystem/v3-ActCode\",",
3648+
" \"code\": \"INFA\",",
3649+
" \"display\": \"Information Access\"",
3650+
" }",
3651+
" ],",
3652+
" \"text\": \"Information Access Consent\"",
3653+
" }",
3654+
" ],",
3655+
" \"patient\": {",
3656+
" \"identifier\": {",
3657+
" \"system\": \"https://fhir.nhs.uk/Id/nhs-number\",",
3658+
" \"value\": \"9000000100\"",
3659+
" }",
3660+
" },",
3661+
" \"dateTime\": \"2024-07-21T17:32:28Z\",",
3662+
" \"performer\": [",
3663+
" {",
3664+
" \"identifier\": {",
3665+
" \"system\": \"https://fhir.nhs.uk/Id/nhs-number\",",
3666+
" \"value\": \"9000000021\"",
3667+
" }",
3668+
" }",
3669+
" ],",
3670+
" \"verification\": [",
3671+
" {",
3672+
" \"verified\": true,",
3673+
" \"verifiedWith\": {",
3674+
" \"identifier\": {",
3675+
" \"system\": \"https://fhir.nhs.uk/Id/nhs-number\",",
3676+
" \"value\": \"9000000005\"",
3677+
" }",
3678+
" },",
3679+
" \"verificationDate\": \"2024-07-21T17:32:28Z\"",
3680+
" }",
3681+
" ]",
3682+
" },",
3683+
" \"search\": {",
3684+
" \"mode\": \"match\"",
3685+
" }",
3686+
" },",
3687+
" {",
3688+
" \"fullUrl\": \"https://api.service.nhs.uk/validated-relationships/FHIR/R4/Consent/AATD11A1\",",
3689+
" \"resource\": {",
3690+
" \"resourceType\": \"Consent\",",
3691+
" \"id\": \"AATD11A1\",",
3692+
" \"status\": \"inactive\",",
3693+
" \"scope\": {",
3694+
" \"coding\": [",
3695+
" {",
3696+
" \"system\": \"http://terminology.hl7.org/CodeSystem/consentscope\",",
3697+
" \"code\": \"patient-privacy\",",
3698+
" \"display\": \"Privacy Consent\"",
3699+
" }",
3700+
" ],",
3701+
" \"text\": \"Patient Privacy Consent\"",
3702+
" },",
3703+
" \"category\": [",
3704+
" {",
3705+
" \"coding\": [",
3706+
" {",
3707+
" \"system\": \"http://terminology.hl7.org/CodeSystem/v3-ActCode\",",
3708+
" \"code\": \"INFA\",",
3709+
" \"display\": \"Information Access\"",
3710+
" }",
3711+
" ],",
3712+
" \"text\": \"Information Access Consent\"",
3713+
" }",
3714+
" ],",
3715+
" \"patient\": {",
3716+
" \"identifier\": {",
3717+
" \"system\": \"https://fhir.nhs.uk/Id/nhs-number\",",
3718+
" \"value\": \"9000000100\"",
3719+
" }",
3720+
" },",
3721+
" \"dateTime\": \"2024-07-21T17:32:28Z\",",
3722+
" \"performer\": [",
3723+
" {",
3724+
" \"identifier\": {",
3725+
" \"system\": \"https://fhir.nhs.uk/Id/nhs-number\",",
3726+
" \"value\": \"9000000022\"",
3727+
" }",
3728+
" }",
3729+
" ],",
3730+
" \"verification\": [",
3731+
" {",
3732+
" \"verified\": true,",
3733+
" \"verifiedWith\": {",
3734+
" \"identifier\": {",
3735+
" \"system\": \"https://fhir.nhs.uk/Id/nhs-number\",",
3736+
" \"value\": \"9000000006\"",
3737+
" }",
3738+
" },",
3739+
" \"verificationDate\": \"2024-07-21T17:32:28Z\"",
3740+
" }",
3741+
" ]",
3742+
" },",
3743+
" \"search\": {",
3744+
" \"mode\": \"match\"",
3745+
" }",
3746+
" }",
3747+
" ]",
3748+
"}",
3749+
"",
3750+
"pm.test(\"Status code is 200\", function () {",
3751+
" pm.response.to.have.status(200);",
3752+
"});",
3753+
"",
3754+
"pm.test(\"Should have correct response body\", () => {",
3755+
" const responseJson = pm.response.json();",
3756+
" pm.expect(responseJson).to.eql(expectedResponseBody);",
3757+
"});"
3758+
],
3759+
"type": "text/javascript",
3760+
"packages": {}
3761+
}
3762+
}
3763+
],
3764+
"request": {
3765+
"method": "GET",
3766+
"header": [],
3767+
"url": {
3768+
"raw": "{{api_base_url}}/Consent?patient:identifier=9000000100",
3769+
"host": [
3770+
"{{api_base_url}}"
3771+
],
3772+
"path": [
3773+
"Consent"
3774+
],
3775+
"query": [
3776+
{
3777+
"key": "patient:identifier",
3778+
"value": "9000000100"
3779+
}
3780+
]
3781+
}
3782+
},
3783+
"response": []
3784+
},
35663785
{
35673786
"name": "No relationships",
35683787
"event": [

sandbox/api/constants.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@
4646
f"{GET_CONSENT__DIRECTORY}single-mother-child-relationship-include-performer-patient.yaml"
4747
)
4848
GET_CONSENT__STATUS_PARAM_INVALID = f"{GET_CONSENT__DIRECTORY}errors/invalid-status-parameter.yaml"
49-
49+
GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT = (
50+
f"{GET_CONSENT__DIRECTORY}multiple-relationships-single-patient.yaml"
51+
)
5052
# POST Consent
5153
POST_CONSENT__DIRECTORY = "./api/examples/POST_Consent/"
5254
POST_CONSENT__SUCCESS = f"{POST_CONSENT__DIRECTORY}success.yaml"

sandbox/api/get_consent.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
GET_CONSENT__FILTERED_RELATIONSHIPS_STATUS_ACTIVE,
88
GET_CONSENT__FILTERED_RELATIONSHIPS_STATUS_INACTIVE,
99
GET_CONSENT__FILTERED_RELATIONSHIPS_STATUS_PROPOSED_ACTIVE,
10+
GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT,
1011
GET_CONSENT__MULTIPLE_RELATIONSHIPS,
1112
GET_CONSENT__MULTIPLE_RELATIONSHIPS_INCLUDE_BOTH,
1213
GET_CONSENT__MULTIPLE_RELATIONSHIPS_INCLUDE_PATIENT,
@@ -43,23 +44,26 @@ def get_consent_response() -> Union[dict, tuple]:
4344
return errors
4445

4546
performer_identifier = remove_system(request.args.get("performer:identifier"))
47+
patient_identifier = remove_system(request.args.get("patient:identifier"))
4648
status = request.args.getlist("status")
4749
_include = request.args.getlist("_include")
4850

4951
# Single consenting adult relationship
50-
if performer_identifier == "9000000010":
52+
if performer_identifier == "9000000010" or patient_identifier == "9000000005":
5153
return check_for_consent_include_params(
5254
_include,
5355
GET_CONSENT__SINGLE_CONSENTING_ADULT_RELATIONSHIP,
5456
GET_CONSENT__SINGLE_CONSENTING_ADULT_RELATIONSHIP_INCLUDE_BOTH,
5557
)
5658
# Single mother child relationship
57-
elif performer_identifier == "9000000019":
59+
elif performer_identifier == "9000000019" or patient_identifier == "9000000009":
5860
return check_for_consent_include_params(
5961
_include,
6062
GET_CONSENT__SINGLE_MOTHER_CHILD_RELATIONSHIP,
6163
GET_CONSENT__SINGLE_MOTHER_CHILD_RELATIONSHIP_INCLUDE_BOTH,
6264
)
65+
elif patient_identifier == "9000000100":
66+
return generate_response_from_example(GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT, 200)
6367
# Filtering
6468
elif performer_identifier == "9000000017":
6569
return check_for_consent_filtering(
@@ -69,6 +73,7 @@ def get_consent_response() -> Union[dict, tuple]:
6973
GET_CONSENT__FILTERED_RELATIONSHIPS_STATUS_INACTIVE,
7074
GET_CONSENT__FILTERED_RELATIONSHIPS_STATUS_PROPOSED_ACTIVE,
7175
)
76+
7277
elif performer_identifier == "9000000022":
7378
return check_for_consent_include_params(
7479
_include,

sandbox/api/tests/test_get_consent.py

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@
2121
"./api/examples/errors/invalidated-resource.yaml",
2222
404,
2323
),
24+
(
25+
"patient:identifier=9000000100", # Multiple relationships single patient
26+
"./api/examples/GET_Consent/multiple-relationships-single-patient.yaml",
27+
200,
28+
),
2429
],
2530
)
2631
@patch("sandbox.api.get_consent.generate_response_from_example")
@@ -89,7 +94,17 @@ def test_get_consent_returns_expected_responses__mocked_get_consent(
8994
200,
9095
),
9196
(
92-
"performer:identifier=9000000010",
97+
"performer:identifier=9000000010", # performer:identifier resulting in single adult relationship
98+
"./api/examples/GET_Consent/single-consenting-adult-relationship.yaml",
99+
200,
100+
),
101+
(
102+
"patient:identifier=9000000005",
103+
"./api/examples/GET_Consent/single-consenting-adult-relationship.yaml",
104+
200,
105+
),
106+
(
107+
"performer:identifier=9000000010&patient:identifier=9000000005",
93108
"./api/examples/GET_Consent/single-consenting-adult-relationship.yaml",
94109
200,
95110
),
@@ -98,16 +113,46 @@ def test_get_consent_returns_expected_responses__mocked_get_consent(
98113
"./api/examples/GET_Consent/single-consenting-adult-relationship-include-performer-patient.yaml",
99114
200,
100115
),
116+
(
117+
"patient:identifier=9000000005&_include=Consent:performer&_include=Consent:patient",
118+
"./api/examples/GET_Consent/single-consenting-adult-relationship-include-performer-patient.yaml",
119+
200,
120+
),
121+
(
122+
"performer:identifier=9000000010&patient:identifier=9000000005&_include=Consent:performer&_include=Consent:patient", # noqa: E501
123+
"./api/examples/GET_Consent/single-consenting-adult-relationship-include-performer-patient.yaml",
124+
200,
125+
),
101126
(
102127
"performer:identifier=9000000019",
103128
"./api/examples/GET_Consent/single-mother-child-relationship.yaml",
104129
200,
105130
),
131+
(
132+
"patient:identifier=9000000009",
133+
"./api/examples/GET_Consent/single-mother-child-relationship.yaml",
134+
200,
135+
),
136+
(
137+
"performer:identifier=9000000019&patient:identifier=9000000009",
138+
"./api/examples/GET_Consent/single-mother-child-relationship.yaml",
139+
200,
140+
),
106141
(
107142
"performer:identifier=9000000019&_include=Consent:performer&_include=Consent:patient",
108143
"./api/examples/GET_Consent/single-mother-child-relationship-include-performer-patient.yaml",
109144
200,
110145
),
146+
(
147+
"patient:identifier=9000000009&_include=Consent:performer&_include=Consent:patient",
148+
"./api/examples/GET_Consent/single-mother-child-relationship-include-performer-patient.yaml",
149+
200,
150+
),
151+
(
152+
"performer:identifier=9000000019&patient:identifier=9000000009&_include=Consent:performer&_include=Consent:patient", # noqa: E501
153+
"./api/examples/GET_Consent/single-mother-child-relationship-include-performer-patient.yaml",
154+
200,
155+
),
111156
(
112157
"performer:identifier=9000000017&status=test", # Invalid status parameter error
113158
"./api/examples/GET_Consent/errors/invalid-status-parameter.yaml",

0 commit comments

Comments
 (0)