From 2dfa87ebbb17c26fa91942c63a8b1777feb0cc3a Mon Sep 17 00:00:00 2001 From: Ellie Bound <175816742+ellie-bound1-NHSD@users.noreply.github.com> Date: Fri, 2 May 2025 11:35:46 +0100 Subject: [PATCH 1/4] NPA-4831: Add examples to spec for multiple proxy relationships for patient with includes paramater --- ...nships-single-patient-include-patient.yaml | 135 ++++++++++++ ...gle-patient-include-performer-patient.yaml | 201 ++++++++++++++++++ .../validated-relationships-service-api.yaml | 46 ++-- 3 files changed, 360 insertions(+), 22 deletions(-) create mode 100644 specification/examples/responses/GET_Consent/multiple-relationships-single-patient-include-patient.yaml create mode 100644 specification/examples/responses/GET_Consent/multiple-relationships-single-patient-include-performer-patient.yaml diff --git a/specification/examples/responses/GET_Consent/multiple-relationships-single-patient-include-patient.yaml b/specification/examples/responses/GET_Consent/multiple-relationships-single-patient-include-patient.yaml new file mode 100644 index 00000000..f0a8deed --- /dev/null +++ b/specification/examples/responses/GET_Consent/multiple-relationships-single-patient-include-patient.yaml @@ -0,0 +1,135 @@ +ConsentMultipleRelationshipsSinglePatientIncludePatientBundle: + summary: Multiple relationships (multiple proxy relationships with single patient) + description: A Bundle containing multiple proxy relationships with single patient, including patient details. + value: + 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/Patient/A3CC67E2 + resource: + resourceType: Patient + id: A3CC67E2 + identifier: + - system: 'https://fhir.nhs.uk/Id/nhs-number' + value: '9000000100' + - system: 'https://placeholder.fhir.nhs.uk/Id/local-gp-patient-identifier' + value: ABC1234567 + name: + - id: '123456' + use: usual + period: + start: '2020-01-01' + end: '2021-12-31' + given: + - Samantha + family: Adams + prefix: + - Miss + birthDate: '1963-11-02' + generalPractitioner: + - type: Organization + identifier: + value: ODS12345 + system: 'https://fhir.nhs.uk/Id/ods-organization-code' + search: + mode: include + - 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: '9000000021' + 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: '9000000022' + verificationDate: '2024-07-21T17:32:28Z' + search: + mode: match diff --git a/specification/examples/responses/GET_Consent/multiple-relationships-single-patient-include-performer-patient.yaml b/specification/examples/responses/GET_Consent/multiple-relationships-single-patient-include-performer-patient.yaml new file mode 100644 index 00000000..8357668a --- /dev/null +++ b/specification/examples/responses/GET_Consent/multiple-relationships-single-patient-include-performer-patient.yaml @@ -0,0 +1,201 @@ +ConsentMultipleRelationshipsSinglePatientIncludePerformerPatientBundle: + summary: Multiple relationships (multiple proxy relationships with single patient) + description: A Bundle containing multiple proxy relationships with single patient, including patient and proxy details. + value: + 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/Patient/A3CC67E2 + resource: + resourceType: Patient + id: A3CC67E2 + identifier: + - system: 'https://fhir.nhs.uk/Id/nhs-number' + value: '9000000100' + - system: 'https://placeholder.fhir.nhs.uk/Id/local-gp-patient-identifier' + value: ABC1234567 + name: + - id: '123456' + use: usual + period: + start: '2020-01-01' + end: '2021-12-31' + given: + - Samantha + family: Adams + prefix: + - Miss + birthDate: '1963-11-02' + generalPractitioner: + - type: Organization + identifier: + value: ODS12345 + system: 'https://fhir.nhs.uk/Id/ods-organization-code' + search: + mode: include + - fullUrl: https://api.service.nhs.uk/validated-relationships/FHIR/R4/RelatedPerson/BE974742 + resource: + resourceType: RelatedPerson + id: BE974742 + identifier: + - system: 'https://fhir.nhs.uk/Id/nhs-number' + value: '9000000020' + - system: 'https://placeholder.fhir.nhs.uk/Id/local-gp-patient-identifier' + value: ABC0000003 + patient: + type: Patient + identifier: + system: 'https://fhir.nhs.uk/Id/nhs-number' + value: '9000000100' + relationship: + - coding: + - system: 'http://terminology.hl7.org/CodeSystem/v3-RoleCode' + code: PRN + display: parent + - system: 'http://terminology.hl7.org/CodeSystem/v3-RoleCode' + code: MTH + display: mother + search: + mode: include + - 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/RelatedPerson/BE974742 + resource: + resourceType: RelatedPerson + id: BE974742 + identifier: + - system: 'https://fhir.nhs.uk/Id/nhs-number' + value: '9000000021' + - system: 'https://placeholder.fhir.nhs.uk/Id/local-gp-patient-identifier' + value: ABC0000003 + patient: + type: Patient + identifier: + system: 'https://fhir.nhs.uk/Id/nhs-number' + value: '9000000100' + relationship: + - coding: + - system: 'http://terminology.hl7.org/CodeSystem/v3-RoleCode' + code: Personal + display: Personal relationship with the patient + search: + mode: include + - 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: '9000000021' + verificationDate: '2024-07-21T17:32:28Z' + search: + mode: match + - fullUrl: https://api.service.nhs.uk/validated-relationships/FHIR/R4/RelatedPerson/BE974742 + resource: + resourceType: RelatedPerson + id: BE974742 + identifier: + - system: 'https://fhir.nhs.uk/Id/nhs-number' + value: '9000000022' + - system: 'https://placeholder.fhir.nhs.uk/Id/local-gp-patient-identifier' + value: ABC0000003 + patient: + type: Patient + identifier: + system: 'https://fhir.nhs.uk/Id/nhs-number' + value: '9000000100' + relationship: + - coding: + - system: 'http://terminology.hl7.org/CodeSystem/v3-RoleCode' + code: Personal + display: Personal relationship with the patient + search: + mode: include + - 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: '9000000022' + verificationDate: '2024-07-21T17:32:28Z' + search: + mode: match diff --git a/specification/validated-relationships-service-api.yaml b/specification/validated-relationships-service-api.yaml index 41194130..4d99d639 100644 --- a/specification/validated-relationships-service-api.yaml +++ b/specification/validated-relationships-service-api.yaml @@ -447,28 +447,30 @@ paths: ## Sandbox test scenarios - | Scenario | Request | Response | - | -------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------- | - | Multiple proxy relationships filtered by 'active' status including details | `performer:identifier`=`9000000017` and `_include` = `Consent:patient` and `_include` = `Consent:proxy` and `status`=`active` | HTTP Status 200 Bundle containing a multiple active proxy relationships including performer and patient details | - | Multiple proxy relationships filtered by 'inactive' status | `performer:identifier`=`9000000017` and `status`=`inactive` | HTTP Status 200 Bundle containing a multiple inactive proxy relationships | - | Multiple proxy relationships filtered by 'proposed' and 'active' status | `performer:identifier`=`9000000017` and `status`=`proposed,active` | HTTP Status 200 Bundle containing a multiple proposed and active proxy relationships | - | Multiple proxy relationships without filtering and details | `performer:identifier`=`9000000022` | HTTP Status 200 Bundle containing a multiple proxy relationships without details | - | Multiple proxy relationships including performer details | `performer:identifier`=`9000000022` and `_include` = `Consent:performer` | HTTP Status 200 Bundle containing a multiple proxy relationships including performer details | - | Multiple proxy relationships including patient details | `performer:identifier`=`9000000022` and `_include` = `Consent:patient` | HTTP Status 200 Bundle containing a multiple proxy relationships including patient details | - | Multiple proxy relationships including performer and patient details | `performer:identifier`=`9000000022` and `_include` = `Consent:patient` and `_include` = `Consent:proxy` | HTTP Status 200 Bundle containing a multiple proxy relationships including performer and patient details | - | Multiple proxy relationships, single patient | `patient:identifier`=`9000000100` | HTTP Status 200 Bundle containing a multiple proxy relationships including performer and patient details | - | No proxy relationships | `performer:identifier`=`9000000025` and `_include` = `Consent:patient` and `_include` = `Consent:proxy` and `status` = `active` | HTTP Status 200 empty bundle | - | A single proxy relationship between consenting adults | `performer:identifier`=`9000000010` and/or `patient:identifier`=`9000000005` | HTTP Status 200 Bundle containing a single proxy relationship | - | A single proxy relationship between consenting adults including details | `performer:identifier`=`9000000010` and/or `patient:identifier`=`9000000005` and `_include` = `Consent:patient` and `_include` = `Consent:proxy` | HTTP Status 200 Bundle containing a single proxy relationship including performer and patient details | - | 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 | - | A single proxy relationship between a mother and child including details | `performer:identifier`=`9000000019` and/or `patient:identifier`=`9000000009` and `_include` = `Consent:patient` and `_include` = `Consent:proxy` | HTTP Status 200 Bundle containing a single proxy relationship including performer and patient details | - | Invalid status parameter | `performer:identifier`=`9000000019` and/or `patient:identifier`=`9000000009` and `status` = `test` | HTTP Status 422 and INVALID_VALUE error response | - | Invalid include parameter | `performer:identifier`=`9000000019` and/or `patient:identifier`=`9000000009` and `_include` = `test` | HTTP Status 422 and INVALID_VALUE error response | - | Missing identifier | `patient:identifier`=`9000000009` | HTTP Status 400 and MISSING_IDENTIFIER_VALUE error response | - | Invalid identifier | `identifier`=`900000000` Note: This identifier is 9 characters long, too short to be NHS Number | HTTP Status 422 and INVALID_IDENTIFIER_VALUE error response | - | Invalid identifier system | `identifier`=`https://fhir.nhs.uk/Id/nhs-number/9730675929` | HTTP Status 422 and INVALID_IDENTIFIER_SYSTEM error response | - | No performer record found | `identifier`=`9000000999` | HTTP Status 404 and INVALIDATED_RESOURCE error response | - | GP Practice not found | `identifier`=`9000000012` | HTTP Status 404 and GP_PRACTICE_NOT_FOUND error response | + | Scenario | Request | Response | + | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------- | + | Multiple proxy relationships filtered by 'active' status including details | `performer:identifier`=`9000000017` and `_include` = `Consent:patient` and `_include` = `Consent:proxy` and `status`=`active` | HTTP Status 200 Bundle containing a multiple active proxy relationships including performer and patient details | + | Multiple proxy relationships filtered by 'inactive' status | `performer:identifier`=`9000000017` and `status`=`inactive` | HTTP Status 200 Bundle containing a multiple inactive proxy relationships | + | Multiple proxy relationships filtered by 'proposed' and 'active' status | `performer:identifier`=`9000000017` and `status`=`proposed,active` | HTTP Status 200 Bundle containing a multiple proposed and active proxy relationships | + | Multiple proxy relationships without filtering and details | `performer:identifier`=`9000000022` | HTTP Status 200 Bundle containing a multiple proxy relationships without details | + | Multiple proxy relationships including performer details | `performer:identifier`=`9000000022` and `_include` = `Consent:performer` | HTTP Status 200 Bundle containing a multiple proxy relationships including performer details | + | Multiple proxy relationships including patient details | `performer:identifier`=`9000000022` and `_include` = `Consent:patient` | HTTP Status 200 Bundle containing a multiple proxy relationships including patient details | + | Multiple proxy relationships including performer and patient details | `performer:identifier`=`9000000022` and `_include` = `Consent:patient` and `_include` = `Consent:proxy` | HTTP Status 200 Bundle containing a multiple proxy relationships including performer and patient details | + | Multiple proxy relationships, single patient | `patient:identifier`=`9000000100` | HTTP Status 200 Bundle containing a multiple proxy relationships including performer and patient details | + | Multiple proxy relationships, single patient, including patient details | `patient:identifier`=`9000000100` and `_include` = `Consent:patient` | HTTP Status 200 Bundle containing a multiple proxy relationships including patient details | + | Multiple proxy relationships, single patient, including performer and patient details | `patient:identifier`=`9000000100` and `_include` = `Consent:patient` and `_include` = `Consent:proxy` | HTTP Status 200 Bundle containing a multiple proxy relationships including performer and patient details | + | No proxy relationships | `performer:identifier`=`9000000025` and `_include` = `Consent:patient` and `_include` = `Consent:proxy` and `status` = `active` | HTTP Status 200 empty bundle | + | A single proxy relationship between consenting adults | `performer:identifier`=`9000000010` and/or `patient:identifier`=`9000000005` | HTTP Status 200 Bundle containing a single proxy relationship | + | A single proxy relationship between consenting adults including details | `performer:identifier`=`9000000010` and/or `patient:identifier`=`9000000005` and `_include` = `Consent:patient` and `_include` = `Consent:proxy` | HTTP Status 200 Bundle containing a single proxy relationship including performer and patient details | + | 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 | + | A single proxy relationship between a mother and child including details | `performer:identifier`=`9000000019` and/or `patient:identifier`=`9000000009` and `_include` = `Consent:patient` and `_include` = `Consent:proxy` | HTTP Status 200 Bundle containing a single proxy relationship including performer and patient details | + | Invalid status parameter | `performer:identifier`=`9000000019` and/or `patient:identifier`=`9000000009` and `status` = `test` | HTTP Status 422 and INVALID_VALUE error response | + | Invalid include parameter | `performer:identifier`=`9000000019` and/or `patient:identifier`=`9000000009` and `_include` = `test` | HTTP Status 422 and INVALID_VALUE error response | + | Missing identifier | `patient:identifier`=`9000000009` | HTTP Status 400 and MISSING_IDENTIFIER_VALUE error response | + | Invalid identifier | `identifier`=`900000000` Note: This identifier is 9 characters long, too short to be NHS Number | HTTP Status 422 and INVALID_IDENTIFIER_VALUE error response | + | Invalid identifier system | `identifier`=`https://fhir.nhs.uk/Id/nhs-number/9730675929` | HTTP Status 422 and INVALID_IDENTIFIER_SYSTEM error response | + | No performer record found | `identifier`=`9000000999` | HTTP Status 404 and INVALIDATED_RESOURCE error response | + | GP Practice not found | `identifier`=`9000000012` | HTTP Status 404 and GP_PRACTICE_NOT_FOUND error response | ### Sandbox constraints - Headers are not tested. `X-IM1-Connection-Params`, `X-Request-ID` and `X-Correlation-ID` are disregarded. From 473ad2361ded4c42fe97bbe53b2175c8ef933c5d Mon Sep 17 00:00:00 2001 From: Ellie Bound <175816742+ellie-bound1-NHSD@users.noreply.github.com> Date: Fri, 2 May 2025 11:47:29 +0100 Subject: [PATCH 2/4] NPA-4831: Updated sandbox to account for new includes scenarios --- sandbox/api/constants.py | 6 ++++++ sandbox/api/get_consent.py | 9 ++++++++- sandbox/api/tests/test_get_consent.py | 20 +++++++++++++++----- sandbox/api/utils.py | 2 +- 4 files changed, 30 insertions(+), 7 deletions(-) diff --git a/sandbox/api/constants.py b/sandbox/api/constants.py index 87f08f5c..5b46ae36 100644 --- a/sandbox/api/constants.py +++ b/sandbox/api/constants.py @@ -49,6 +49,12 @@ GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT = ( f"{GET_CONSENT__DIRECTORY}multiple-relationships-single-patient.yaml" ) +GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT_INCLUDE_PATIENT = ( + f"{GET_CONSENT__DIRECTORY}multiple-relationships-single-patient-include-patient.yaml" +) +GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT_INCLUDE_BOTH = ( + f"{GET_CONSENT__DIRECTORY}multiple-relationships-single-patient-include-performer-patient.yaml" +) # POST Consent POST_CONSENT__DIRECTORY = "./api/examples/POST_Consent/" POST_CONSENT__SUCCESS = f"{POST_CONSENT__DIRECTORY}success.yaml" diff --git a/sandbox/api/get_consent.py b/sandbox/api/get_consent.py index 3b04941a..4cc2a7e8 100644 --- a/sandbox/api/get_consent.py +++ b/sandbox/api/get_consent.py @@ -8,6 +8,8 @@ GET_CONSENT__FILTERED_RELATIONSHIPS_STATUS_INACTIVE, GET_CONSENT__FILTERED_RELATIONSHIPS_STATUS_PROPOSED_ACTIVE, GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT, + GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT_INCLUDE_PATIENT, + GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT_INCLUDE_BOTH, GET_CONSENT__MULTIPLE_RELATIONSHIPS, GET_CONSENT__MULTIPLE_RELATIONSHIPS_INCLUDE_BOTH, GET_CONSENT__MULTIPLE_RELATIONSHIPS_INCLUDE_PATIENT, @@ -63,7 +65,12 @@ def get_consent_response() -> Union[dict, tuple]: GET_CONSENT__SINGLE_MOTHER_CHILD_RELATIONSHIP_INCLUDE_BOTH, ) elif patient_identifier == "9000000100": - return generate_response_from_example(GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT, 200) + return check_for_consent_include_params( + _include, + GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT, + GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT_INCLUDE_BOTH, + GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT_INCLUDE_PATIENT, + ) # Filtering elif performer_identifier == "9000000017": return check_for_consent_filtering( diff --git a/sandbox/api/tests/test_get_consent.py b/sandbox/api/tests/test_get_consent.py index c5fa6ff5..2c58fa3e 100644 --- a/sandbox/api/tests/test_get_consent.py +++ b/sandbox/api/tests/test_get_consent.py @@ -21,11 +21,6 @@ "./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") @@ -153,6 +148,21 @@ def test_get_consent_returns_expected_responses__mocked_get_consent( "./api/examples/GET_Consent/single-mother-child-relationship-include-performer-patient.yaml", 200, ), + ( + "patient:identifier=9000000100", # Multiple relationships single patient + "./api/examples/GET_Consent/multiple-relationships-single-patient.yaml", + 200, + ), + ( + "patient:identifier=9000000100&_include=Consent:patient", + "./api/examples/GET_Consent/multiple-relationships-single-patient-include-patient.yaml", + 200, + ), + ( + "patient:identifier=9000000100&_include=Consent:performer&_include=Consent:patient", + "./api/examples/GET_Consent/multiple-relationships-single-patient-include-performer-patient.yaml", + 200, + ), ( "performer:identifier=9000000017&status=test", # Invalid status parameter error "./api/examples/GET_Consent/errors/invalid-status-parameter.yaml", diff --git a/sandbox/api/utils.py b/sandbox/api/utils.py index 2c08195b..601b0d6c 100644 --- a/sandbox/api/utils.py +++ b/sandbox/api/utils.py @@ -248,7 +248,7 @@ def check_for_consent_include_params( logger.error("No consent performer example provided") return generate_response_from_example(INTERNAL_SERVER_ERROR_EXAMPLE, 500) elif _include == [CONSENT_PATIENT]: - if include_performer_response_yaml: + if include_patient_response_yaml: return generate_response_from_example(include_patient_response_yaml, 200) else: logger.error("No consent:patient example provided") From a026d71b488edb1263ada2a936078295784e8a31 Mon Sep 17 00:00:00 2001 From: Ellie Bound <175816742+ellie-bound1-NHSD@users.noreply.github.com> Date: Fri, 2 May 2025 12:14:12 +0100 Subject: [PATCH 3/4] NPA-4831: Add a new scenaio for _include=Consent:performer --- sandbox/api/constants.py | 3 + sandbox/api/get_consent.py | 2 + sandbox/api/tests/test_get_consent.py | 5 + ...hips-single-patient-include-performer.yaml | 173 ++++++++++++++++++ .../validated-relationships-service-api.yaml | 49 ++--- 5 files changed, 208 insertions(+), 24 deletions(-) create mode 100644 specification/examples/responses/GET_Consent/multiple-relationships-single-patient-include-performer.yaml diff --git a/sandbox/api/constants.py b/sandbox/api/constants.py index 5b46ae36..b5930479 100644 --- a/sandbox/api/constants.py +++ b/sandbox/api/constants.py @@ -49,6 +49,9 @@ GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT = ( f"{GET_CONSENT__DIRECTORY}multiple-relationships-single-patient.yaml" ) +GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT_INCLUDE_PERFORMER = ( + f"{GET_CONSENT__DIRECTORY}multiple-relationships-single-patient-include-performer.yaml" +) GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT_INCLUDE_PATIENT = ( f"{GET_CONSENT__DIRECTORY}multiple-relationships-single-patient-include-patient.yaml" ) diff --git a/sandbox/api/get_consent.py b/sandbox/api/get_consent.py index 4cc2a7e8..df34839d 100644 --- a/sandbox/api/get_consent.py +++ b/sandbox/api/get_consent.py @@ -9,6 +9,7 @@ GET_CONSENT__FILTERED_RELATIONSHIPS_STATUS_PROPOSED_ACTIVE, GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT, GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT_INCLUDE_PATIENT, + GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT_INCLUDE_PERFORMER, GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT_INCLUDE_BOTH, GET_CONSENT__MULTIPLE_RELATIONSHIPS, GET_CONSENT__MULTIPLE_RELATIONSHIPS_INCLUDE_BOTH, @@ -70,6 +71,7 @@ def get_consent_response() -> Union[dict, tuple]: GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT, GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT_INCLUDE_BOTH, GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT_INCLUDE_PATIENT, + GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT_INCLUDE_PERFORMER, ) # Filtering elif performer_identifier == "9000000017": diff --git a/sandbox/api/tests/test_get_consent.py b/sandbox/api/tests/test_get_consent.py index 2c58fa3e..c027b4d9 100644 --- a/sandbox/api/tests/test_get_consent.py +++ b/sandbox/api/tests/test_get_consent.py @@ -153,6 +153,11 @@ def test_get_consent_returns_expected_responses__mocked_get_consent( "./api/examples/GET_Consent/multiple-relationships-single-patient.yaml", 200, ), + ( + "patient:identifier=9000000100&_include=Consent:performer", + "./api/examples/GET_Consent/multiple-relationships-single-patient-include-performer.yaml", + 200, + ), ( "patient:identifier=9000000100&_include=Consent:patient", "./api/examples/GET_Consent/multiple-relationships-single-patient-include-patient.yaml", diff --git a/specification/examples/responses/GET_Consent/multiple-relationships-single-patient-include-performer.yaml b/specification/examples/responses/GET_Consent/multiple-relationships-single-patient-include-performer.yaml new file mode 100644 index 00000000..a4ca08e8 --- /dev/null +++ b/specification/examples/responses/GET_Consent/multiple-relationships-single-patient-include-performer.yaml @@ -0,0 +1,173 @@ +ConsentMultipleRelationshipsSinglePatientIncludePerformerPatientBundle: + summary: Multiple relationships (multiple proxy relationships with single patient) + description: A Bundle containing multiple proxy relationships with single patient, including proxy details. + value: + 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/RelatedPerson/BE974742 + resource: + resourceType: RelatedPerson + id: BE974742 + identifier: + - system: 'https://fhir.nhs.uk/Id/nhs-number' + value: '9000000020' + - system: 'https://placeholder.fhir.nhs.uk/Id/local-gp-patient-identifier' + value: ABC0000003 + patient: + type: Patient + identifier: + system: 'https://fhir.nhs.uk/Id/nhs-number' + value: '9000000100' + relationship: + - coding: + - system: 'http://terminology.hl7.org/CodeSystem/v3-RoleCode' + code: PRN + display: parent + - system: 'http://terminology.hl7.org/CodeSystem/v3-RoleCode' + code: MTH + display: mother + search: + mode: include + - 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/RelatedPerson/BE974742 + resource: + resourceType: RelatedPerson + id: BE974742 + identifier: + - system: 'https://fhir.nhs.uk/Id/nhs-number' + value: '9000000021' + - system: 'https://placeholder.fhir.nhs.uk/Id/local-gp-patient-identifier' + value: ABC0000003 + patient: + type: Patient + identifier: + system: 'https://fhir.nhs.uk/Id/nhs-number' + value: '9000000100' + relationship: + - coding: + - system: 'http://terminology.hl7.org/CodeSystem/v3-RoleCode' + code: Personal + display: Personal relationship with the patient + search: + mode: include + - 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: '9000000021' + verificationDate: '2024-07-21T17:32:28Z' + search: + mode: match + - fullUrl: https://api.service.nhs.uk/validated-relationships/FHIR/R4/RelatedPerson/BE974742 + resource: + resourceType: RelatedPerson + id: BE974742 + identifier: + - system: 'https://fhir.nhs.uk/Id/nhs-number' + value: '9000000022' + - system: 'https://placeholder.fhir.nhs.uk/Id/local-gp-patient-identifier' + value: ABC0000003 + patient: + type: Patient + identifier: + system: 'https://fhir.nhs.uk/Id/nhs-number' + value: '9000000100' + relationship: + - coding: + - system: 'http://terminology.hl7.org/CodeSystem/v3-RoleCode' + code: Personal + display: Personal relationship with the patient + search: + mode: include + - 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: '9000000022' + verificationDate: '2024-07-21T17:32:28Z' + search: + mode: match diff --git a/specification/validated-relationships-service-api.yaml b/specification/validated-relationships-service-api.yaml index 4d99d639..4ac3c86e 100644 --- a/specification/validated-relationships-service-api.yaml +++ b/specification/validated-relationships-service-api.yaml @@ -447,30 +447,31 @@ paths: ## Sandbox test scenarios - | Scenario | Request | Response | - | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------- | - | Multiple proxy relationships filtered by 'active' status including details | `performer:identifier`=`9000000017` and `_include` = `Consent:patient` and `_include` = `Consent:proxy` and `status`=`active` | HTTP Status 200 Bundle containing a multiple active proxy relationships including performer and patient details | - | Multiple proxy relationships filtered by 'inactive' status | `performer:identifier`=`9000000017` and `status`=`inactive` | HTTP Status 200 Bundle containing a multiple inactive proxy relationships | - | Multiple proxy relationships filtered by 'proposed' and 'active' status | `performer:identifier`=`9000000017` and `status`=`proposed,active` | HTTP Status 200 Bundle containing a multiple proposed and active proxy relationships | - | Multiple proxy relationships without filtering and details | `performer:identifier`=`9000000022` | HTTP Status 200 Bundle containing a multiple proxy relationships without details | - | Multiple proxy relationships including performer details | `performer:identifier`=`9000000022` and `_include` = `Consent:performer` | HTTP Status 200 Bundle containing a multiple proxy relationships including performer details | - | Multiple proxy relationships including patient details | `performer:identifier`=`9000000022` and `_include` = `Consent:patient` | HTTP Status 200 Bundle containing a multiple proxy relationships including patient details | - | Multiple proxy relationships including performer and patient details | `performer:identifier`=`9000000022` and `_include` = `Consent:patient` and `_include` = `Consent:proxy` | HTTP Status 200 Bundle containing a multiple proxy relationships including performer and patient details | - | Multiple proxy relationships, single patient | `patient:identifier`=`9000000100` | HTTP Status 200 Bundle containing a multiple proxy relationships including performer and patient details | - | Multiple proxy relationships, single patient, including patient details | `patient:identifier`=`9000000100` and `_include` = `Consent:patient` | HTTP Status 200 Bundle containing a multiple proxy relationships including patient details | - | Multiple proxy relationships, single patient, including performer and patient details | `patient:identifier`=`9000000100` and `_include` = `Consent:patient` and `_include` = `Consent:proxy` | HTTP Status 200 Bundle containing a multiple proxy relationships including performer and patient details | - | No proxy relationships | `performer:identifier`=`9000000025` and `_include` = `Consent:patient` and `_include` = `Consent:proxy` and `status` = `active` | HTTP Status 200 empty bundle | - | A single proxy relationship between consenting adults | `performer:identifier`=`9000000010` and/or `patient:identifier`=`9000000005` | HTTP Status 200 Bundle containing a single proxy relationship | - | A single proxy relationship between consenting adults including details | `performer:identifier`=`9000000010` and/or `patient:identifier`=`9000000005` and `_include` = `Consent:patient` and `_include` = `Consent:proxy` | HTTP Status 200 Bundle containing a single proxy relationship including performer and patient details | - | 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 | - | A single proxy relationship between a mother and child including details | `performer:identifier`=`9000000019` and/or `patient:identifier`=`9000000009` and `_include` = `Consent:patient` and `_include` = `Consent:proxy` | HTTP Status 200 Bundle containing a single proxy relationship including performer and patient details | - | Invalid status parameter | `performer:identifier`=`9000000019` and/or `patient:identifier`=`9000000009` and `status` = `test` | HTTP Status 422 and INVALID_VALUE error response | - | Invalid include parameter | `performer:identifier`=`9000000019` and/or `patient:identifier`=`9000000009` and `_include` = `test` | HTTP Status 422 and INVALID_VALUE error response | - | Missing identifier | `patient:identifier`=`9000000009` | HTTP Status 400 and MISSING_IDENTIFIER_VALUE error response | - | Invalid identifier | `identifier`=`900000000` Note: This identifier is 9 characters long, too short to be NHS Number | HTTP Status 422 and INVALID_IDENTIFIER_VALUE error response | - | Invalid identifier system | `identifier`=`https://fhir.nhs.uk/Id/nhs-number/9730675929` | HTTP Status 422 and INVALID_IDENTIFIER_SYSTEM error response | - | No performer record found | `identifier`=`9000000999` | HTTP Status 404 and INVALIDATED_RESOURCE error response | - | GP Practice not found | `identifier`=`9000000012` | HTTP Status 404 and GP_PRACTICE_NOT_FOUND error response | + | Scenario | Request | Response | + | --------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------- | + | Multiple proxy relationships filtered by 'active' status including details | `performer:identifier`=`9000000017` and `_include` = `Consent:patient` and `_include` = `Consent:performer` and `status`=`active` | HTTP Status 200 Bundle containing a multiple active proxy relationships including performer and patient details | + | Multiple proxy relationships filtered by 'inactive' status | `performer:identifier`=`9000000017` and `status`=`inactive` | HTTP Status 200 Bundle containing a multiple inactive proxy relationships | + | Multiple proxy relationships filtered by 'proposed' and 'active' status | `performer:identifier`=`9000000017` and `status`=`proposed,active` | HTTP Status 200 Bundle containing a multiple proposed and active proxy relationships | + | Multiple proxy relationships without filtering and details | `performer:identifier`=`9000000022` | HTTP Status 200 Bundle containing a multiple proxy relationships without details | + | Multiple proxy relationships including performer details | `performer:identifier`=`9000000022` and `_include` = `Consent:performer` | HTTP Status 200 Bundle containing a multiple proxy relationships including performer details | + | Multiple proxy relationships including patient details | `performer:identifier`=`9000000022` and `_include` = `Consent:patient` | HTTP Status 200 Bundle containing a multiple proxy relationships including patient details | + | Multiple proxy relationships including performer and patient details | `performer:identifier`=`9000000022` and `_include` = `Consent:patient` and `_include` = `Consent:performer` | HTTP Status 200 Bundle containing a multiple proxy relationships including performer and patient details | + | Multiple proxy relationships, single patient | `patient:identifier`=`9000000100` | HTTP Status 200 Bundle containing a multiple proxy relationships including performer and patient details | + | Multiple proxy relationships, single patient, including proxy details | `patient:identifier`=`9000000100` and `_include` = `Consent:performer` | HTTP Status 200 Bundle containing a multiple proxy relationships including proxy details | + | Multiple proxy relationships, single patient, including patient details | `patient:identifier`=`9000000100` and `_include` = `Consent:patient` | HTTP Status 200 Bundle containing a multiple proxy relationships including patient details | + | Multiple proxy relationships, single patient, including proxy and patient details | `patient:identifier`=`9000000100` and `_include` = `Consent:patient` and `_include` = `Consent:performer` | HTTP Status 200 Bundle containing a multiple proxy relationships including proxy and patient details | + | No proxy relationships | `performer:identifier`=`9000000025` and `_include` = `Consent:patient` and `_include` = `Consent:performer` and `status` = `active` | HTTP Status 200 empty bundle | + | A single proxy relationship between consenting adults | `performer:identifier`=`9000000010` and/or `patient:identifier`=`9000000005` | HTTP Status 200 Bundle containing a single proxy relationship | + | A single proxy relationship between consenting adults including details | `performer:identifier`=`9000000010` and/or `patient:identifier`=`9000000005` and `_include` = `Consent:patient` and `_include` = `Consent:proxy` | HTTP Status 200 Bundle containing a single proxy relationship including performer and patient details | + | 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 | + | A single proxy relationship between a mother and child including details | `performer:identifier`=`9000000019` and/or `patient:identifier`=`9000000009` and `_include` = `Consent:patient` and `_include` = `Consent:proxy` | HTTP Status 200 Bundle containing a single proxy relationship including performer and patient details | + | Invalid status parameter | `performer:identifier`=`9000000019` and/or `patient:identifier`=`9000000009` and `status` = `test` | HTTP Status 422 and INVALID_VALUE error response | + | Invalid include parameter | `performer:identifier`=`9000000019` and/or `patient:identifier`=`9000000009` and `_include` = `test` | HTTP Status 422 and INVALID_VALUE error response | + | Missing identifier | `patient:identifier`=`9000000009` | HTTP Status 400 and MISSING_IDENTIFIER_VALUE error response | + | Invalid identifier | `identifier`=`900000000` Note: This identifier is 9 characters long, too short to be NHS Number | HTTP Status 422 and INVALID_IDENTIFIER_VALUE error response | + | Invalid identifier system | `identifier`=`https://fhir.nhs.uk/Id/nhs-number/9730675929` | HTTP Status 422 and INVALID_IDENTIFIER_SYSTEM error response | + | No performer record found | `identifier`=`9000000999` | HTTP Status 404 and INVALIDATED_RESOURCE error response | + | GP Practice not found | `identifier`=`9000000012` | HTTP Status 404 and GP_PRACTICE_NOT_FOUND error response | ### Sandbox constraints - Headers are not tested. `X-IM1-Connection-Params`, `X-Request-ID` and `X-Correlation-ID` are disregarded. From 5450e7cc34dcf514677e01c5ebec048cf26ec7c7 Mon Sep 17 00:00:00 2001 From: Ellie Bound <175816742+ellie-bound1-NHSD@users.noreply.github.com> Date: Fri, 2 May 2025 13:17:14 +0100 Subject: [PATCH 4/4] NPA-4831: Update example responses to have correct total for bundle --- .../multiple-relationships-single-patient-include-patient.yaml | 2 +- ...-relationships-single-patient-include-performer-patient.yaml | 2 +- ...multiple-relationships-single-patient-include-performer.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/specification/examples/responses/GET_Consent/multiple-relationships-single-patient-include-patient.yaml b/specification/examples/responses/GET_Consent/multiple-relationships-single-patient-include-patient.yaml index f0a8deed..c38620f8 100644 --- a/specification/examples/responses/GET_Consent/multiple-relationships-single-patient-include-patient.yaml +++ b/specification/examples/responses/GET_Consent/multiple-relationships-single-patient-include-patient.yaml @@ -4,7 +4,7 @@ ConsentMultipleRelationshipsSinglePatientIncludePatientBundle: value: resourceType: Bundle timestamp: '2020-08-26T14:00:00+00:00' - total: 3 + total: 4 type: searchset entry: - fullUrl: https://api.service.nhs.uk/validated-relationships/FHIR/R4/Patient/A3CC67E2 diff --git a/specification/examples/responses/GET_Consent/multiple-relationships-single-patient-include-performer-patient.yaml b/specification/examples/responses/GET_Consent/multiple-relationships-single-patient-include-performer-patient.yaml index 8357668a..d418b01a 100644 --- a/specification/examples/responses/GET_Consent/multiple-relationships-single-patient-include-performer-patient.yaml +++ b/specification/examples/responses/GET_Consent/multiple-relationships-single-patient-include-performer-patient.yaml @@ -4,7 +4,7 @@ ConsentMultipleRelationshipsSinglePatientIncludePerformerPatientBundle: value: resourceType: Bundle timestamp: '2020-08-26T14:00:00+00:00' - total: 3 + total: 7 type: searchset entry: - fullUrl: https://api.service.nhs.uk/validated-relationships/FHIR/R4/Patient/A3CC67E2 diff --git a/specification/examples/responses/GET_Consent/multiple-relationships-single-patient-include-performer.yaml b/specification/examples/responses/GET_Consent/multiple-relationships-single-patient-include-performer.yaml index a4ca08e8..66629777 100644 --- a/specification/examples/responses/GET_Consent/multiple-relationships-single-patient-include-performer.yaml +++ b/specification/examples/responses/GET_Consent/multiple-relationships-single-patient-include-performer.yaml @@ -4,7 +4,7 @@ ConsentMultipleRelationshipsSinglePatientIncludePerformerPatientBundle: value: resourceType: Bundle timestamp: '2020-08-26T14:00:00+00:00' - total: 3 + total: 6 type: searchset entry: - fullUrl: https://api.service.nhs.uk/validated-relationships/FHIR/R4/RelatedPerson/BE974742