Skip to content

Commit 9f44e02

Browse files
committed
NRL-519 include practice setting in integration tests
1 parent aed5ca6 commit 9f44e02

File tree

2 files changed

+112
-93
lines changed

2 files changed

+112
-93
lines changed

tests/features/producer/createDocumentReference-success.feature

Lines changed: 87 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ Feature: Producer - createDocumentReference - Success Scenarios
66
| system | value |
77
| http://snomed.info/sct | 736253002 |
88
When producer 'ANGY1' creates a DocumentReference with values:
9-
| property | value |
10-
| subject | 9278693472 |
11-
| status | current |
12-
| type | 736253002 |
13-
| category | 734163000 |
14-
| custodian | ANGY1 |
15-
| author | HAR1 |
16-
| url | https://example.org/my-doc.pdf |
9+
| property | value |
10+
| subject | 9278693472 |
11+
| status | current |
12+
| type | 736253002 |
13+
| category | 734163000 |
14+
| custodian | ANGY1 |
15+
| author | HAR1 |
16+
| url | https://example.org/my-doc.pdf |
17+
| practiceSetting | 788002001 |
1718
Then the response status code is 201
1819
And the response is an OperationOutcome with 1 issue
1920
And the OperationOutcome contains the issue:
@@ -36,14 +37,15 @@ Feature: Producer - createDocumentReference - Success Scenarios
3637
And the response has a Location header
3738
And the Location header starts with '/producer/FHIR/R4/DocumentReference/ANGY1-'
3839
And the resource in the Location header exists with values:
39-
| property | value |
40-
| subject | 9278693472 |
41-
| status | current |
42-
| type | 736253002 |
43-
| category | 734163000 |
44-
| custodian | ANGY1 |
45-
| author | HAR1 |
46-
| url | https://example.org/my-doc.pdf |
40+
| property | value |
41+
| subject | 9278693472 |
42+
| status | current |
43+
| type | 736253002 |
44+
| category | 734163000 |
45+
| custodian | ANGY1 |
46+
| author | HAR1 |
47+
| url | https://example.org/my-doc.pdf |
48+
| practiceSetting | 788002001 |
4749

4850
# # NRL-766 Resolve custodian suffix issues
4951
# Scenario: Successfully create a Document Pointer (care plan) with custodian suffix
@@ -97,26 +99,28 @@ Feature: Producer - createDocumentReference - Success Scenarios
9799
| system | value |
98100
| http://snomed.info/sct | 736253002 |
99101
And a DocumentReference resource exists with values:
100-
| property | value |
101-
| id | ANGY1-111-SupercedeDocRefTest1 |
102-
| subject | 9278693472 |
103-
| status | current |
104-
| type | 736253002 |
105-
| category | 734163000 |
106-
| contentType | application/pdf |
107-
| url | https://example.org/my-doc.pdf |
108-
| custodian | ANGY1 |
109-
| author | HAR1 |
102+
| property | value |
103+
| id | ANGY1-111-SupercedeDocRefTest1 |
104+
| subject | 9278693472 |
105+
| status | current |
106+
| type | 736253002 |
107+
| category | 734163000 |
108+
| contentType | application/pdf |
109+
| url | https://example.org/my-doc.pdf |
110+
| custodian | ANGY1 |
111+
| author | HAR1 |
112+
| practiceSetting | 788002001 |
110113
When producer 'ANGY1' creates a DocumentReference with values:
111-
| property | value |
112-
| subject | 9278693472 |
113-
| status | current |
114-
| type | 736253002 |
115-
| category | 734163000 |
116-
| custodian | ANGY1 |
117-
| author | HAR1 |
118-
| url | https://example.org/newdoc.pdf |
119-
| supercedes | ANGY1-111-SupercedeDocRefTest1 |
114+
| property | value |
115+
| subject | 9278693472 |
116+
| status | current |
117+
| type | 736253002 |
118+
| category | 734163000 |
119+
| custodian | ANGY1 |
120+
| author | HAR1 |
121+
| url | https://example.org/newdoc.pdf |
122+
| supercedes | ANGY1-111-SupercedeDocRefTest1 |
123+
| practiceSetting | 788002001 |
120124
Then the response status code is 201
121125
And the response is an OperationOutcome with 1 issue
122126
And the OperationOutcome contains the issue:
@@ -139,14 +143,15 @@ Feature: Producer - createDocumentReference - Success Scenarios
139143
And the response has a Location header
140144
And the Location header starts with '/producer/FHIR/R4/DocumentReference/ANGY1-'
141145
And the resource in the Location header exists with values:
142-
| property | value |
143-
| subject | 9278693472 |
144-
| status | current |
145-
| type | 736253002 |
146-
| category | 734163000 |
147-
| custodian | ANGY1 |
148-
| author | HAR1 |
149-
| url | https://example.org/newdoc.pdf |
146+
| property | value |
147+
| subject | 9278693472 |
148+
| status | current |
149+
| type | 736253002 |
150+
| category | 734163000 |
151+
| custodian | ANGY1 |
152+
| author | HAR1 |
153+
| url | https://example.org/newdoc.pdf |
154+
| practiceSetting | 788002001 |
150155
And the resource with id 'ANGY1-111-SupercedeDocRefTest1' does not exist
151156

152157
# Create document reference with relatesTo - not code='replaces'
@@ -157,14 +162,15 @@ Feature: Producer - createDocumentReference - Success Scenarios
157162
| system | value |
158163
| http://snomed.info/sct | <pointer-type> |
159164
When producer 'ANGY1' creates a DocumentReference with values:
160-
| property | value |
161-
| subject | 9278693472 |
162-
| status | current |
163-
| type | <pointer-type> |
164-
| category | <pointer-category> |
165-
| custodian | ANGY1 |
166-
| author | HAR1 |
167-
| url | https://example.org/my-doc.pdf |
165+
| property | value |
166+
| subject | 9278693472 |
167+
| status | current |
168+
| type | <pointer-type> |
169+
| category | <pointer-category> |
170+
| custodian | ANGY1 |
171+
| author | HAR1 |
172+
| url | https://example.org/my-doc.pdf |
173+
| practiceSetting | 788002001 |
168174
Then the response status code is 201
169175
And the response is an OperationOutcome with 1 issue
170176
And the OperationOutcome contains the issue:
@@ -229,15 +235,16 @@ Feature: Producer - createDocumentReference - Success Scenarios
229235
| https://nicip.nhs.uk | MAULR |
230236
| https://nicip.nhs.uk | MAXIB |
231237
When producer 'ANGY1' creates a DocumentReference with values:
232-
| property | value |
233-
| subject | 9278693472 |
234-
| status | current |
235-
| type | MAULR |
236-
| type_system | https://nicip.nhs.uk |
237-
| category | 721981007 |
238-
| custodian | ANGY1 |
239-
| author | HAR1 |
240-
| url | https://example.org/my-doc.pdf |
238+
| property | value |
239+
| subject | 9278693472 |
240+
| status | current |
241+
| type | MAULR |
242+
| type_system | https://nicip.nhs.uk |
243+
| category | 721981007 |
244+
| custodian | ANGY1 |
245+
| author | HAR1 |
246+
| url | https://example.org/my-doc.pdf |
247+
| practiceSetting | 788002001 |
241248
Then the response status code is 201
242249
And the response is an OperationOutcome with 1 issue
243250
And the OperationOutcome contains the issue:
@@ -260,25 +267,27 @@ Feature: Producer - createDocumentReference - Success Scenarios
260267
And the response has a Location header
261268
And the Location header starts with '/producer/FHIR/R4/DocumentReference/ANGY1-'
262269
And the resource in the Location header exists with values:
263-
| property | value |
264-
| subject | 9278693472 |
265-
| status | current |
266-
| type | MAULR |
267-
| type_system | https://nicip.nhs.uk |
268-
| category | 721981007 |
269-
| custodian | ANGY1 |
270-
| author | HAR1 |
271-
| url | https://example.org/my-doc.pdf |
270+
| property | value |
271+
| subject | 9278693472 |
272+
| status | current |
273+
| type | MAULR |
274+
| type_system | https://nicip.nhs.uk |
275+
| category | 721981007 |
276+
| custodian | ANGY1 |
277+
| author | HAR1 |
278+
| url | https://example.org/my-doc.pdf |
279+
| practiceSetting | 788002001 |
272280
When producer 'ANGY1' creates a DocumentReference with values:
273-
| property | value |
274-
| subject | 9278693472 |
275-
| status | current |
276-
| type | MAXIB |
277-
| type_system | https://nicip.nhs.uk |
278-
| category | 103693007 |
279-
| custodian | ANGY1 |
280-
| author | HAR1 |
281-
| url | https://example.org/my-doc.pdf |
281+
| property | value |
282+
| subject | 9278693472 |
283+
| status | current |
284+
| type | MAXIB |
285+
| type_system | https://nicip.nhs.uk |
286+
| category | 103693007 |
287+
| custodian | ANGY1 |
288+
| author | HAR1 |
289+
| url | https://example.org/my-doc.pdf |
290+
| practiceSetting | 788002001 |
282291
Then the response status code is 201
283292
And the response is an OperationOutcome with 1 issue
284293
And the OperationOutcome contains the issue:

tests/features/utils/data.py

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
from layer.nrlf.core.constants import CATEGORY_ATTRIBUTES, TYPE_ATTRIBUTES
1+
from layer.nrlf.core.constants import (
2+
CATEGORY_ATTRIBUTES,
3+
SNOMED_PRACTICE_SETTINGS,
4+
SNOMED_SYSTEM_URL,
5+
TYPE_ATTRIBUTES,
6+
)
27
from nrlf.producer.fhir.r4.model import (
38
Attachment,
49
CodeableConcept,
@@ -36,24 +41,13 @@ def create_test_document_reference(items: dict) -> DocumentReference:
3641
)
3742
)
3843
],
39-
context=DocumentReferenceContext(
40-
practiceSetting=CodeableConcept(
41-
coding=[
42-
Coding(
43-
system="http://snomed.info/sct",
44-
code="390826005",
45-
display="Mental health caregiver support",
46-
)
47-
]
48-
)
49-
),
5044
)
5145

5246
if items.get("id"):
5347
base_doc_ref.id = items["id"]
5448

5549
if type_code := items.get("type"):
56-
type_system = items.get("type_system", "http://snomed.info/sct")
50+
type_system = items.get("type_system", SNOMED_SYSTEM_URL)
5751
type_str = f"{type_system}|{type_code}"
5852
type_display = items.get(
5953
"type_display", TYPE_ATTRIBUTES.get(type_str, {}).get("display")
@@ -90,13 +84,13 @@ def create_test_document_reference(items: dict) -> DocumentReference:
9084

9185
if items.get("category"):
9286
category_display = CATEGORY_ATTRIBUTES.get(
93-
f"http://snomed.info/sct|{items['category']}", {}
87+
f"SNOMED_SYSTEM_URL|{items['category']}", {}
9488
).get("display")
9589
base_doc_ref.category = [
9690
CodeableConcept(
9791
coding=[
9892
Coding(
99-
system="http://snomed.info/sct",
93+
system=SNOMED_SYSTEM_URL,
10094
code=items["category"],
10195
display=category_display,
10296
)
@@ -118,6 +112,22 @@ def create_test_document_reference(items: dict) -> DocumentReference:
118112
)
119113
]
120114

115+
if practice_setting_code := items.get("practiceSetting"):
116+
practice_setting_display = SNOMED_PRACTICE_SETTINGS.get(
117+
str(practice_setting_code), "Unknown practice setting"
118+
)
119+
base_doc_ref.context = DocumentReferenceContext(
120+
practiceSetting=CodeableConcept(
121+
coding=[
122+
Coding(
123+
system=SNOMED_SYSTEM_URL,
124+
code=str(practice_setting_code),
125+
display=practice_setting_display,
126+
)
127+
]
128+
)
129+
)
130+
121131
return base_doc_ref
122132

123133

0 commit comments

Comments
 (0)