Skip to content

Commit fe18e96

Browse files
Merge pull request #199 from NHSDigital/dev/NPA-4831/Update-Sandbox-with-Examples-for-Includes-Patient-Detials-Multiple-Relationships
NPA-4831: Update Sandbox with Examples for _includes Patient Details When Multiple Proxy Relationships
2 parents 76d9ab4 + 5450e7c commit fe18e96

8 files changed

+574
-29
lines changed

sandbox/api/constants.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@
4949
GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT = (
5050
f"{GET_CONSENT__DIRECTORY}multiple-relationships-single-patient.yaml"
5151
)
52+
GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT_INCLUDE_PERFORMER = (
53+
f"{GET_CONSENT__DIRECTORY}multiple-relationships-single-patient-include-performer.yaml"
54+
)
55+
GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT_INCLUDE_PATIENT = (
56+
f"{GET_CONSENT__DIRECTORY}multiple-relationships-single-patient-include-patient.yaml"
57+
)
58+
GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT_INCLUDE_BOTH = (
59+
f"{GET_CONSENT__DIRECTORY}multiple-relationships-single-patient-include-performer-patient.yaml"
60+
)
5261
# POST Consent
5362
POST_CONSENT__DIRECTORY = "./api/examples/POST_Consent/"
5463
POST_CONSENT__SUCCESS = f"{POST_CONSENT__DIRECTORY}success.yaml"

sandbox/api/get_consent.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
GET_CONSENT__FILTERED_RELATIONSHIPS_STATUS_INACTIVE,
99
GET_CONSENT__FILTERED_RELATIONSHIPS_STATUS_PROPOSED_ACTIVE,
1010
GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT,
11+
GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT_INCLUDE_PATIENT,
12+
GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT_INCLUDE_PERFORMER,
13+
GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT_INCLUDE_BOTH,
1114
GET_CONSENT__MULTIPLE_RELATIONSHIPS,
1215
GET_CONSENT__MULTIPLE_RELATIONSHIPS_INCLUDE_BOTH,
1316
GET_CONSENT__MULTIPLE_RELATIONSHIPS_INCLUDE_PATIENT,
@@ -63,7 +66,13 @@ def get_consent_response() -> Union[dict, tuple]:
6366
GET_CONSENT__SINGLE_MOTHER_CHILD_RELATIONSHIP_INCLUDE_BOTH,
6467
)
6568
elif patient_identifier == "9000000100":
66-
return generate_response_from_example(GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT, 200)
69+
return check_for_consent_include_params(
70+
_include,
71+
GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT,
72+
GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT_INCLUDE_BOTH,
73+
GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT_INCLUDE_PATIENT,
74+
GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT_INCLUDE_PERFORMER,
75+
)
6776
# Filtering
6877
elif performer_identifier == "9000000017":
6978
return check_for_consent_filtering(

sandbox/api/tests/test_get_consent.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@
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-
),
2924
],
3025
)
3126
@patch("sandbox.api.get_consent.generate_response_from_example")
@@ -153,6 +148,26 @@ def test_get_consent_returns_expected_responses__mocked_get_consent(
153148
"./api/examples/GET_Consent/single-mother-child-relationship-include-performer-patient.yaml",
154149
200,
155150
),
151+
(
152+
"patient:identifier=9000000100", # Multiple relationships single patient
153+
"./api/examples/GET_Consent/multiple-relationships-single-patient.yaml",
154+
200,
155+
),
156+
(
157+
"patient:identifier=9000000100&_include=Consent:performer",
158+
"./api/examples/GET_Consent/multiple-relationships-single-patient-include-performer.yaml",
159+
200,
160+
),
161+
(
162+
"patient:identifier=9000000100&_include=Consent:patient",
163+
"./api/examples/GET_Consent/multiple-relationships-single-patient-include-patient.yaml",
164+
200,
165+
),
166+
(
167+
"patient:identifier=9000000100&_include=Consent:performer&_include=Consent:patient",
168+
"./api/examples/GET_Consent/multiple-relationships-single-patient-include-performer-patient.yaml",
169+
200,
170+
),
156171
(
157172
"performer:identifier=9000000017&status=test", # Invalid status parameter error
158173
"./api/examples/GET_Consent/errors/invalid-status-parameter.yaml",

sandbox/api/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ def check_for_consent_include_params(
248248
logger.error("No consent performer example provided")
249249
return generate_response_from_example(INTERNAL_SERVER_ERROR_EXAMPLE, 500)
250250
elif _include == [CONSENT_PATIENT]:
251-
if include_performer_response_yaml:
251+
if include_patient_response_yaml:
252252
return generate_response_from_example(include_patient_response_yaml, 200)
253253
else:
254254
logger.error("No consent:patient example provided")
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
ConsentMultipleRelationshipsSinglePatientIncludePatientBundle:
2+
summary: Multiple relationships (multiple proxy relationships with single patient)
3+
description: A Bundle containing multiple proxy relationships with single patient, including patient details.
4+
value:
5+
resourceType: Bundle
6+
timestamp: '2020-08-26T14:00:00+00:00'
7+
total: 4
8+
type: searchset
9+
entry:
10+
- fullUrl: https://api.service.nhs.uk/validated-relationships/FHIR/R4/Patient/A3CC67E2
11+
resource:
12+
resourceType: Patient
13+
id: A3CC67E2
14+
identifier:
15+
- system: 'https://fhir.nhs.uk/Id/nhs-number'
16+
value: '9000000100'
17+
- system: 'https://placeholder.fhir.nhs.uk/Id/local-gp-patient-identifier'
18+
value: ABC1234567
19+
name:
20+
- id: '123456'
21+
use: usual
22+
period:
23+
start: '2020-01-01'
24+
end: '2021-12-31'
25+
given:
26+
- Samantha
27+
family: Adams
28+
prefix:
29+
- Miss
30+
birthDate: '1963-11-02'
31+
generalPractitioner:
32+
- type: Organization
33+
identifier:
34+
value: ODS12345
35+
system: 'https://fhir.nhs.uk/Id/ods-organization-code'
36+
search:
37+
mode: include
38+
- fullUrl: https://api.service.nhs.uk/validated-relationships/FHIR/R4/Consent/BBCC67E9
39+
resource:
40+
resourceType: Consent
41+
id: BBCC67E9
42+
status: active
43+
scope:
44+
coding:
45+
- system: 'http://terminology.hl7.org/CodeSystem/consentscope'
46+
code: patient-privacy
47+
display: Privacy Consent
48+
text: Patient Privacy Consent
49+
category:
50+
- coding:
51+
- system: 'http://terminology.hl7.org/CodeSystem/v3-ActCode'
52+
code: INFA
53+
display: Information Access
54+
text: Information Access Consent
55+
patient:
56+
identifier:
57+
system: 'https://fhir.nhs.uk/Id/nhs-number'
58+
value: '9000000100'
59+
dateTime: '2024-07-21T17:32:28Z'
60+
performer:
61+
- identifier:
62+
system: 'https://fhir.nhs.uk/Id/nhs-number'
63+
value: '9000000020'
64+
search:
65+
mode: match
66+
- fullUrl: https://api.service.nhs.uk/validated-relationships/FHIR/R4/Consent/WWCC67T1
67+
resource:
68+
resourceType: Consent
69+
id: WWCC67T1
70+
status: active
71+
scope:
72+
coding:
73+
- system: 'http://terminology.hl7.org/CodeSystem/consentscope'
74+
code: patient-privacy
75+
display: Privacy Consent
76+
text: Patient Privacy Consent
77+
category:
78+
- coding:
79+
- system: 'http://terminology.hl7.org/CodeSystem/v3-ActCode'
80+
code: INFA
81+
display: Information Access
82+
text: Information Access Consent
83+
patient:
84+
identifier:
85+
system: 'https://fhir.nhs.uk/Id/nhs-number'
86+
value: '9000000100'
87+
dateTime: '2024-07-21T17:32:28Z'
88+
performer:
89+
- identifier:
90+
system: 'https://fhir.nhs.uk/Id/nhs-number'
91+
value: '9000000021'
92+
verification:
93+
- verified: true
94+
verifiedWith:
95+
identifier:
96+
system: 'https://fhir.nhs.uk/Id/nhs-number'
97+
value: '9000000021'
98+
verificationDate: '2024-07-21T17:32:28Z'
99+
search:
100+
mode: match
101+
- fullUrl: https://api.service.nhs.uk/validated-relationships/FHIR/R4/Consent/AATD11A1
102+
resource:
103+
resourceType: Consent
104+
id: AATD11A1
105+
status: inactive
106+
scope:
107+
coding:
108+
- system: 'http://terminology.hl7.org/CodeSystem/consentscope'
109+
code: patient-privacy
110+
display: Privacy Consent
111+
text: Patient Privacy Consent
112+
category:
113+
- coding:
114+
- system: 'http://terminology.hl7.org/CodeSystem/v3-ActCode'
115+
code: INFA
116+
display: Information Access
117+
text: Information Access Consent
118+
patient:
119+
identifier:
120+
system: 'https://fhir.nhs.uk/Id/nhs-number'
121+
value: '9000000100'
122+
dateTime: '2024-07-21T17:32:28Z'
123+
performer:
124+
- identifier:
125+
system: 'https://fhir.nhs.uk/Id/nhs-number'
126+
value: '9000000022'
127+
verification:
128+
- verified: true
129+
verifiedWith:
130+
identifier:
131+
system: 'https://fhir.nhs.uk/Id/nhs-number'
132+
value: '9000000022'
133+
verificationDate: '2024-07-21T17:32:28Z'
134+
search:
135+
mode: match

0 commit comments

Comments
 (0)