Skip to content

Commit 9d37f6b

Browse files
committed
[NRL-1279] Fix up unit test for sample pointer. Add redacted live sample pointers
1 parent 3a37732 commit 9d37f6b

18 files changed

+1987
-15
lines changed

layer/nrlf/core/tests/test_sample_pointers.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,30 @@
77
from nrlf.producer.fhir.r4.model import DocumentReference as ProducerDocumentReference
88

99

10-
@pytest.fixture
11-
def sample_pointer_data() -> str:
12-
json_files = [f for f in os.listdir("./tests/data/samples") if f.endswith(".json")]
10+
def sample_pointer_files() -> list[str]:
11+
return [f for f in os.listdir("./tests/data/samples") if f.endswith(".json")]
1312

14-
for file in json_files:
15-
with open(f"./tests/data/samples/{file}", "r") as f:
16-
pointer_data = f.read()
17-
yield pointer_data
1813

14+
def load_sample_pointer_data(pointer_file: str) -> str:
15+
with open(f"./tests/data/samples/{pointer_file}", "r") as f:
16+
return f.read()
1917

20-
def test_sample_pointer_as_consumer(sample_pointer_data: str):
21-
docref = ConsumerDocumentReference.model_validate_json(sample_pointer_data)
2218

23-
validator = DocumentReferenceValidator()
24-
result = validator.validate(data=docref)
19+
@pytest.mark.parametrize("sample_pointer_file", sample_pointer_files())
20+
def test_sample_pointer_as_consumer(sample_pointer_file: str):
21+
sample_pointer_data = load_sample_pointer_data(sample_pointer_file)
22+
23+
docref = ConsumerDocumentReference.model_validate_json(sample_pointer_data)
24+
result = DocumentReferenceValidator().validate(data=docref)
2525

2626
assert result.is_valid
2727

2828

29-
def test_sample_pointer_as_producer(sample_pointer_data: str):
30-
docref = ProducerDocumentReference.model_validate_json(sample_pointer_data)
29+
@pytest.mark.parametrize("sample_pointer_file", sample_pointer_files())
30+
def test_sample_pointer_as_producer(sample_pointer_file: str):
31+
sample_pointer_data = load_sample_pointer_data(sample_pointer_file)
3132

32-
validator = DocumentReferenceValidator()
33-
result = validator.validate(data=docref)
33+
docref = ProducerDocumentReference.model_validate_json(sample_pointer_data)
34+
result = DocumentReferenceValidator().validate(data=docref)
3435

3536
assert result.is_valid
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
{
2+
"resourceType": "DocumentReference",
3+
"id": "11X-c2a99222-eb50-4451-ad6e-1e951627800e",
4+
"meta": {
5+
"lastUpdated": "2025-02-10T16:48:27.326Z"
6+
},
7+
"masterIdentifier": {
8+
"system": "urn:ietf:rfc:3986",
9+
"value": "mid_c2a99222-eb50-4451-ad6e-1e951627800e"
10+
},
11+
"status": "current",
12+
"type": {
13+
"coding": [
14+
{
15+
"system": "http://snomed.info/sct",
16+
"code": "736366004",
17+
"display": "Advance care plan"
18+
}
19+
]
20+
},
21+
"category": [
22+
{
23+
"coding": [
24+
{
25+
"system": "http://snomed.info/sct",
26+
"code": "734163000",
27+
"display": "Care plan"
28+
}
29+
]
30+
}
31+
],
32+
"subject": {
33+
"identifier": {
34+
"system": "https://fhir.nhs.uk/Id/nhs-number",
35+
"value": "9999999999"
36+
}
37+
},
38+
"date": "2025-02-10T16:48:27.326Z",
39+
"author": [
40+
{
41+
"identifier": {
42+
"system": "https://fhir.nhs.uk/Id/ods-organization-code",
43+
"value": "L85012"
44+
}
45+
}
46+
],
47+
"custodian": {
48+
"identifier": {
49+
"system": "https://fhir.nhs.uk/Id/ods-organization-code",
50+
"value": "11X"
51+
}
52+
},
53+
"content": [
54+
{
55+
"attachment": {
56+
"contentType": "application/pdf",
57+
"url": "ssp://content.test.local/content",
58+
"creation": "2025-02-10T16:48:27.326Z"
59+
},
60+
"format": {
61+
"system": "https://fhir.nhs.uk/England/CodeSystem/England-NRLFormatCode",
62+
"code": "urn:nhs-ic:unstructured",
63+
"display": "Unstructured Document"
64+
},
65+
"extension": [
66+
{
67+
"valueCodeableConcept": {
68+
"coding": [
69+
{
70+
"system": "https://fhir.nhs.uk/England/CodeSystem/England-NRLContentStability",
71+
"code": "static",
72+
"display": "Static"
73+
}
74+
]
75+
},
76+
"url": "https://fhir.nhs.uk/England/StructureDefinition/Extension-England-ContentStability"
77+
}
78+
]
79+
}
80+
],
81+
"context": {
82+
"period": {
83+
"start": "2025-02-10T16:48:27.326Z"
84+
},
85+
"practiceSetting": {
86+
"coding": [
87+
{
88+
"system": "http://snomed.info/sct",
89+
"code": "1060971000000108",
90+
"display": "General practice service"
91+
}
92+
]
93+
},
94+
"related": [
95+
{
96+
"identifier": {
97+
"system": "https://fhir.nhs.uk/Id/nhsSpineASID",
98+
"value": "012345678910"
99+
}
100+
}
101+
]
102+
}
103+
}
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
{
2+
"resourceType": "DocumentReference",
3+
"id": "11X-c2a99222-eb50-4451-ad6e-1e951627800e",
4+
"meta": {
5+
"lastUpdated": "2025-02-10T16:48:27.327Z"
6+
},
7+
"masterIdentifier": {
8+
"system": "urn:ietf:rfc:3986",
9+
"value": "mid_c2a99222-eb50-4451-ad6e-1e951627800e"
10+
},
11+
"status": "current",
12+
"type": {
13+
"coding": [
14+
{
15+
"system": "http://snomed.info/sct",
16+
"code": "2181441000000107",
17+
"display": "Personalised Care and Support Plan"
18+
}
19+
]
20+
},
21+
"category": [
22+
{
23+
"coding": [
24+
{
25+
"system": "http://snomed.info/sct",
26+
"code": "734163000",
27+
"display": "Care plan"
28+
}
29+
]
30+
}
31+
],
32+
"subject": {
33+
"identifier": {
34+
"system": "https://fhir.nhs.uk/Id/nhs-number",
35+
"value": "9999999999"
36+
}
37+
},
38+
"date": "2025-02-10T16:48:27.327Z",
39+
"author": [
40+
{
41+
"identifier": {
42+
"system": "https://fhir.nhs.uk/Id/ods-organization-code",
43+
"value": "L85609"
44+
}
45+
}
46+
],
47+
"custodian": {
48+
"identifier": {
49+
"system": "https://fhir.nhs.uk/Id/ods-organization-code",
50+
"value": "11X"
51+
}
52+
},
53+
"content": [
54+
{
55+
"attachment": {
56+
"contentType": "application/pdf",
57+
"url": "ssp://content.test.local/content",
58+
"creation": "2025-02-10T16:48:27.327Z"
59+
},
60+
"format": {
61+
"system": "https://fhir.nhs.uk/England/CodeSystem/England-NRLFormatCode",
62+
"code": "urn:nhs-ic:unstructured",
63+
"display": "Unstructured Document"
64+
},
65+
"extension": [
66+
{
67+
"valueCodeableConcept": {
68+
"coding": [
69+
{
70+
"system": "https://fhir.nhs.uk/England/CodeSystem/England-NRLContentStability",
71+
"code": "static",
72+
"display": "Static"
73+
}
74+
]
75+
},
76+
"url": "https://fhir.nhs.uk/England/StructureDefinition/Extension-England-ContentStability"
77+
}
78+
]
79+
}
80+
],
81+
"context": {
82+
"period": {
83+
"start": "2025-02-10T16:48:27.327Z"
84+
},
85+
"practiceSetting": {
86+
"coding": [
87+
{
88+
"system": "http://snomed.info/sct",
89+
"code": "1060971000000108",
90+
"display": "General practice service"
91+
}
92+
]
93+
},
94+
"related": [
95+
{
96+
"identifier": {
97+
"system": "https://fhir.nhs.uk/Id/nhsSpineASID",
98+
"value": "012345678910"
99+
}
100+
}
101+
]
102+
}
103+
}
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
{
2+
"resourceType": "DocumentReference",
3+
"id": "11X-c2a99222-eb50-4451-ad6e-1e951627800e",
4+
"meta": {
5+
"lastUpdated": "2025-02-10T16:48:27.327Z"
6+
},
7+
"masterIdentifier": {
8+
"system": "urn:ietf:rfc:3986",
9+
"value": "mid_c2a99222-eb50-4451-ad6e-1e951627800e"
10+
},
11+
"status": "current",
12+
"type": {
13+
"coding": [
14+
{
15+
"system": "http://snomed.info/sct",
16+
"code": "735324008",
17+
"display": "Treatment escalation plan"
18+
}
19+
]
20+
},
21+
"category": [
22+
{
23+
"coding": [
24+
{
25+
"system": "http://snomed.info/sct",
26+
"code": "734163000",
27+
"display": "Care plan"
28+
}
29+
]
30+
}
31+
],
32+
"subject": {
33+
"identifier": {
34+
"system": "https://fhir.nhs.uk/Id/nhs-number",
35+
"value": "9999999999"
36+
}
37+
},
38+
"date": "2025-02-10T16:48:27.327Z",
39+
"author": [
40+
{
41+
"identifier": {
42+
"system": "https://fhir.nhs.uk/Id/ods-organization-code",
43+
"value": "L85023"
44+
}
45+
}
46+
],
47+
"custodian": {
48+
"identifier": {
49+
"system": "https://fhir.nhs.uk/Id/ods-organization-code",
50+
"value": "11X"
51+
}
52+
},
53+
"content": [
54+
{
55+
"attachment": {
56+
"contentType": "application/pdf",
57+
"url": "ssp://content.test.local/content",
58+
"creation": "2025-02-10T16:48:27.327Z"
59+
},
60+
"format": {
61+
"system": "https://fhir.nhs.uk/England/CodeSystem/England-NRLFormatCode",
62+
"code": "urn:nhs-ic:unstructured",
63+
"display": "Unstructured Document"
64+
},
65+
"extension": [
66+
{
67+
"valueCodeableConcept": {
68+
"coding": [
69+
{
70+
"system": "https://fhir.nhs.uk/England/CodeSystem/England-NRLContentStability",
71+
"code": "static",
72+
"display": "Static"
73+
}
74+
]
75+
},
76+
"url": "https://fhir.nhs.uk/England/StructureDefinition/Extension-England-ContentStability"
77+
}
78+
]
79+
}
80+
],
81+
"context": {
82+
"period": {
83+
"start": "2025-02-10T16:48:27.327Z"
84+
},
85+
"practiceSetting": {
86+
"coding": [
87+
{
88+
"system": "http://snomed.info/sct",
89+
"code": "1060971000000108",
90+
"display": "General practice service"
91+
}
92+
]
93+
},
94+
"related": [
95+
{
96+
"identifier": {
97+
"system": "https://fhir.nhs.uk/Id/nhsSpineASID",
98+
"value": "012345678910"
99+
}
100+
}
101+
]
102+
}
103+
}

0 commit comments

Comments
 (0)