Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
225 changes: 222 additions & 3 deletions postman/Validate Relationship Service Sandbox.postman_collection.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"info": {
"_postman_id": "ab2b3bfb-f318-4111-b6c5-658952be5b85",
"name": "Validate Relationship Service Sandbox 11/04/25",
"_postman_id": "a5dcb0b1-ad72-4665-942e-2041cc61e26d",
"name": "Validate Relationship Service Sandbox 01/05/25",
"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)",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"_exporter_id": "34042403",
"_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"
"_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"
},
"item": [
{
Expand Down Expand Up @@ -3563,6 +3563,225 @@
},
"response": []
},
{
"name": "Multiple proxy relationships single patient",
"event": [
{
"listen": "test",
"script": {
"exec": [
"const expectedResponseBody = {",
" \"resourceType\": \"Bundle\",",
" \"timestamp\": \"2020-08-26T14:00:00+00:00\",",
" \"total\": 3,",
" \"type\": \"searchset\",",
" \"entry\": [",
" {",
" \"fullUrl\": \"https://api.service.nhs.uk/validated-relationships/FHIR/R4/Consent/BBCC67E9\",",
" \"resource\": {",
" \"resourceType\": \"Consent\",",
" \"id\": \"BBCC67E9\",",
" \"status\": \"active\",",
" \"scope\": {",
" \"coding\": [",
" {",
" \"system\": \"http://terminology.hl7.org/CodeSystem/consentscope\",",
" \"code\": \"patient-privacy\",",
" \"display\": \"Privacy Consent\"",
" }",
" ],",
" \"text\": \"Patient Privacy Consent\"",
" },",
" \"category\": [",
" {",
" \"coding\": [",
" {",
" \"system\": \"http://terminology.hl7.org/CodeSystem/v3-ActCode\",",
" \"code\": \"INFA\",",
" \"display\": \"Information Access\"",
" }",
" ],",
" \"text\": \"Information Access Consent\"",
" }",
" ],",
" \"patient\": {",
" \"identifier\": {",
" \"system\": \"https://fhir.nhs.uk/Id/nhs-number\",",
" \"value\": \"9000000100\"",
" }",
" },",
" \"dateTime\": \"2024-07-21T17:32:28Z\",",
" \"performer\": [",
" {",
" \"identifier\": {",
" \"system\": \"https://fhir.nhs.uk/Id/nhs-number\",",
" \"value\": \"9000000020\"",
" }",
" }",
" ]",
" },",
" \"search\": {",
" \"mode\": \"match\"",
" }",
" },",
" {",
" \"fullUrl\": \"https://api.service.nhs.uk/validated-relationships/FHIR/R4/Consent/WWCC67T1\",",
" \"resource\": {",
" \"resourceType\": \"Consent\",",
" \"id\": \"WWCC67T1\",",
" \"status\": \"active\",",
" \"scope\": {",
" \"coding\": [",
" {",
" \"system\": \"http://terminology.hl7.org/CodeSystem/consentscope\",",
" \"code\": \"patient-privacy\",",
" \"display\": \"Privacy Consent\"",
" }",
" ],",
" \"text\": \"Patient Privacy Consent\"",
" },",
" \"category\": [",
" {",
" \"coding\": [",
" {",
" \"system\": \"http://terminology.hl7.org/CodeSystem/v3-ActCode\",",
" \"code\": \"INFA\",",
" \"display\": \"Information Access\"",
" }",
" ],",
" \"text\": \"Information Access Consent\"",
" }",
" ],",
" \"patient\": {",
" \"identifier\": {",
" \"system\": \"https://fhir.nhs.uk/Id/nhs-number\",",
" \"value\": \"9000000100\"",
" }",
" },",
" \"dateTime\": \"2024-07-21T17:32:28Z\",",
" \"performer\": [",
" {",
" \"identifier\": {",
" \"system\": \"https://fhir.nhs.uk/Id/nhs-number\",",
" \"value\": \"9000000021\"",
" }",
" }",
" ],",
" \"verification\": [",
" {",
" \"verified\": true,",
" \"verifiedWith\": {",
" \"identifier\": {",
" \"system\": \"https://fhir.nhs.uk/Id/nhs-number\",",
" \"value\": \"9000000005\"",
" }",
" },",
" \"verificationDate\": \"2024-07-21T17:32:28Z\"",
" }",
" ]",
" },",
" \"search\": {",
" \"mode\": \"match\"",
" }",
" },",
" {",
" \"fullUrl\": \"https://api.service.nhs.uk/validated-relationships/FHIR/R4/Consent/AATD11A1\",",
" \"resource\": {",
" \"resourceType\": \"Consent\",",
" \"id\": \"AATD11A1\",",
" \"status\": \"inactive\",",
" \"scope\": {",
" \"coding\": [",
" {",
" \"system\": \"http://terminology.hl7.org/CodeSystem/consentscope\",",
" \"code\": \"patient-privacy\",",
" \"display\": \"Privacy Consent\"",
" }",
" ],",
" \"text\": \"Patient Privacy Consent\"",
" },",
" \"category\": [",
" {",
" \"coding\": [",
" {",
" \"system\": \"http://terminology.hl7.org/CodeSystem/v3-ActCode\",",
" \"code\": \"INFA\",",
" \"display\": \"Information Access\"",
" }",
" ],",
" \"text\": \"Information Access Consent\"",
" }",
" ],",
" \"patient\": {",
" \"identifier\": {",
" \"system\": \"https://fhir.nhs.uk/Id/nhs-number\",",
" \"value\": \"9000000100\"",
" }",
" },",
" \"dateTime\": \"2024-07-21T17:32:28Z\",",
" \"performer\": [",
" {",
" \"identifier\": {",
" \"system\": \"https://fhir.nhs.uk/Id/nhs-number\",",
" \"value\": \"9000000022\"",
" }",
" }",
" ],",
" \"verification\": [",
" {",
" \"verified\": true,",
" \"verifiedWith\": {",
" \"identifier\": {",
" \"system\": \"https://fhir.nhs.uk/Id/nhs-number\",",
" \"value\": \"9000000006\"",
" }",
" },",
" \"verificationDate\": \"2024-07-21T17:32:28Z\"",
" }",
" ]",
" },",
" \"search\": {",
" \"mode\": \"match\"",
" }",
" }",
" ]",
"}",
"",
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"pm.test(\"Should have correct response body\", () => {",
" const responseJson = pm.response.json();",
" pm.expect(responseJson).to.eql(expectedResponseBody);",
"});"
],
"type": "text/javascript",
"packages": {}
}
}
],
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{api_base_url}}/Consent?patient:identifier=9000000100",
"host": [
"{{api_base_url}}"
],
"path": [
"Consent"
],
"query": [
{
"key": "patient:identifier",
"value": "9000000100"
}
]
}
},
"response": []
},
{
"name": "No relationships",
"event": [
Expand Down
4 changes: 3 additions & 1 deletion sandbox/api/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@
f"{GET_CONSENT__DIRECTORY}single-mother-child-relationship-include-performer-patient.yaml"
)
GET_CONSENT__STATUS_PARAM_INVALID = f"{GET_CONSENT__DIRECTORY}errors/invalid-status-parameter.yaml"

GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT = (
f"{GET_CONSENT__DIRECTORY}multiple-relationships-single-patient.yaml"
)
# POST Consent
POST_CONSENT__DIRECTORY = "./api/examples/POST_Consent/"
POST_CONSENT__SUCCESS = f"{POST_CONSENT__DIRECTORY}success.yaml"
Expand Down
9 changes: 7 additions & 2 deletions sandbox/api/get_consent.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
GET_CONSENT__FILTERED_RELATIONSHIPS_STATUS_ACTIVE,
GET_CONSENT__FILTERED_RELATIONSHIPS_STATUS_INACTIVE,
GET_CONSENT__FILTERED_RELATIONSHIPS_STATUS_PROPOSED_ACTIVE,
GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT,
GET_CONSENT__MULTIPLE_RELATIONSHIPS,
GET_CONSENT__MULTIPLE_RELATIONSHIPS_INCLUDE_BOTH,
GET_CONSENT__MULTIPLE_RELATIONSHIPS_INCLUDE_PATIENT,
Expand Down Expand Up @@ -43,23 +44,26 @@ def get_consent_response() -> Union[dict, tuple]:
return errors

performer_identifier = remove_system(request.args.get("performer:identifier"))
patient_identifier = remove_system(request.args.get("patient:identifier"))
status = request.args.getlist("status")
_include = request.args.getlist("_include")

# Single consenting adult relationship
if performer_identifier == "9000000010":
if performer_identifier == "9000000010" or patient_identifier == "9000000005":
return check_for_consent_include_params(
_include,
GET_CONSENT__SINGLE_CONSENTING_ADULT_RELATIONSHIP,
GET_CONSENT__SINGLE_CONSENTING_ADULT_RELATIONSHIP_INCLUDE_BOTH,
)
# Single mother child relationship
elif performer_identifier == "9000000019":
elif performer_identifier == "9000000019" or patient_identifier == "9000000009":
return check_for_consent_include_params(
_include,
GET_CONSENT__SINGLE_MOTHER_CHILD_RELATIONSHIP,
GET_CONSENT__SINGLE_MOTHER_CHILD_RELATIONSHIP_INCLUDE_BOTH,
)
elif patient_identifier == "9000000100":
return generate_response_from_example(GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT, 200)
# Filtering
elif performer_identifier == "9000000017":
return check_for_consent_filtering(
Expand All @@ -69,6 +73,7 @@ def get_consent_response() -> Union[dict, tuple]:
GET_CONSENT__FILTERED_RELATIONSHIPS_STATUS_INACTIVE,
GET_CONSENT__FILTERED_RELATIONSHIPS_STATUS_PROPOSED_ACTIVE,
)

elif performer_identifier == "9000000022":
return check_for_consent_include_params(
_include,
Expand Down
47 changes: 46 additions & 1 deletion sandbox/api/tests/test_get_consent.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
"./api/examples/errors/invalidated-resource.yaml",
404,
),
(
"patient:identifier=9000000100", # Multiple relationships single patient
"./api/examples/GET_Consent/multiple-relationships-single-patient.yaml",
200,
),
],
)
@patch("sandbox.api.get_consent.generate_response_from_example")
Expand Down Expand Up @@ -89,7 +94,17 @@ def test_get_consent_returns_expected_responses__mocked_get_consent(
200,
),
(
"performer:identifier=9000000010",
"performer:identifier=9000000010", # performer:identifier resulting in single adult relationship
"./api/examples/GET_Consent/single-consenting-adult-relationship.yaml",
200,
),
(
"patient:identifier=9000000005",
"./api/examples/GET_Consent/single-consenting-adult-relationship.yaml",
200,
),
(
"performer:identifier=9000000010&patient:identifier=9000000005",
"./api/examples/GET_Consent/single-consenting-adult-relationship.yaml",
200,
),
Expand All @@ -98,16 +113,46 @@ def test_get_consent_returns_expected_responses__mocked_get_consent(
"./api/examples/GET_Consent/single-consenting-adult-relationship-include-performer-patient.yaml",
200,
),
(
"patient:identifier=9000000005&_include=Consent:performer&_include=Consent:patient",
"./api/examples/GET_Consent/single-consenting-adult-relationship-include-performer-patient.yaml",
200,
),
(
"performer:identifier=9000000010&patient:identifier=9000000005&_include=Consent:performer&_include=Consent:patient", # noqa: E501
"./api/examples/GET_Consent/single-consenting-adult-relationship-include-performer-patient.yaml",
200,
),
(
"performer:identifier=9000000019",
"./api/examples/GET_Consent/single-mother-child-relationship.yaml",
200,
),
(
"patient:identifier=9000000009",
"./api/examples/GET_Consent/single-mother-child-relationship.yaml",
200,
),
(
"performer:identifier=9000000019&patient:identifier=9000000009",
"./api/examples/GET_Consent/single-mother-child-relationship.yaml",
200,
),
(
"performer:identifier=9000000019&_include=Consent:performer&_include=Consent:patient",
"./api/examples/GET_Consent/single-mother-child-relationship-include-performer-patient.yaml",
200,
),
(
"patient:identifier=9000000009&_include=Consent:performer&_include=Consent:patient",
"./api/examples/GET_Consent/single-mother-child-relationship-include-performer-patient.yaml",
200,
),
(
"performer:identifier=9000000019&patient:identifier=9000000009&_include=Consent:performer&_include=Consent:patient", # noqa: E501
"./api/examples/GET_Consent/single-mother-child-relationship-include-performer-patient.yaml",
200,
),
(
"performer:identifier=9000000017&status=test", # Invalid status parameter error
"./api/examples/GET_Consent/errors/invalid-status-parameter.yaml",
Expand Down
Loading