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
9 changes: 9 additions & 0 deletions sandbox/api/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@
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"
)
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"
Expand Down
11 changes: 10 additions & 1 deletion sandbox/api/get_consent.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
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_PERFORMER,
GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT_INCLUDE_BOTH,
GET_CONSENT__MULTIPLE_RELATIONSHIPS,
GET_CONSENT__MULTIPLE_RELATIONSHIPS_INCLUDE_BOTH,
GET_CONSENT__MULTIPLE_RELATIONSHIPS_INCLUDE_PATIENT,
Expand Down Expand Up @@ -63,7 +66,13 @@ 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,
GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT_INCLUDE_PERFORMER,
)
# Filtering
elif performer_identifier == "9000000017":
return check_for_consent_filtering(
Expand Down
25 changes: 20 additions & 5 deletions sandbox/api/tests/test_get_consent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -153,6 +148,26 @@ 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: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",
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",
Expand Down
2 changes: 1 addition & 1 deletion sandbox/api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
@@ -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: 4
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
Loading