Skip to content

Commit 3a37732

Browse files
committed
[NRL-1279] Add sample pointer unit tests and initial sample from Orion
1 parent 968d39b commit 3a37732

File tree

3 files changed

+143
-0
lines changed

3 files changed

+143
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import os
2+
3+
import pytest
4+
5+
from nrlf.consumer.fhir.r4.model import DocumentReference as ConsumerDocumentReference
6+
from nrlf.core.validators import DocumentReferenceValidator
7+
from nrlf.producer.fhir.r4.model import DocumentReference as ProducerDocumentReference
8+
9+
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")]
13+
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
18+
19+
20+
def test_sample_pointer_as_consumer(sample_pointer_data: str):
21+
docref = ConsumerDocumentReference.model_validate_json(sample_pointer_data)
22+
23+
validator = DocumentReferenceValidator()
24+
result = validator.validate(data=docref)
25+
26+
assert result.is_valid
27+
28+
29+
def test_sample_pointer_as_producer(sample_pointer_data: str):
30+
docref = ProducerDocumentReference.model_validate_json(sample_pointer_data)
31+
32+
validator = DocumentReferenceValidator()
33+
result = validator.validate(data=docref)
34+
35+
assert result.is_valid

tests/data/samples/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Supplier sample data
2+
3+
This directory contains sample pointer data from our suppliers. Samples have
4+
been sourced directly from suppliers or anonymised from live data.
5+
6+
To add a new sample to this folder, follow these steps:
7+
8+
- Remove any real PII from the DocumentReference data (NHS numbers, URLs, ids etc)
9+
- Add the DocumentReference data to a .json file with a name describing the
10+
supplier and the pointer type, something like <ODSCode>_<PointerType>_<other-unique-info>.json
11+
- Run the tests to verify that the pointer works with our model and validators
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
{
2+
"resourceType": "DocumentReference",
3+
"id": "YGM91-b5a1aef1-a3ee-4c38-be31-e98968fe7ae9",
4+
"masterIdentifier": {
5+
"system": "urn:ietf:rfc:3986",
6+
"value": "b5a1aef1-a3ee-4c38-be31-e98968fe7ae9"
7+
},
8+
"status": "current",
9+
"type": {
10+
"coding": [
11+
{
12+
"system": "http://snomed.info/sct",
13+
"code": "736253002",
14+
"display": "Mental health crisis plan"
15+
}
16+
]
17+
},
18+
"category": [
19+
{
20+
"coding": [
21+
{
22+
"system": "http://snomed.info/sct",
23+
"code": "734163000",
24+
"display": "Care plan"
25+
}
26+
]
27+
}
28+
],
29+
"subject": {
30+
"identifier": {
31+
"system": "https://fhir.nhs.uk/Id/nhs-number",
32+
"value": "9658218873"
33+
}
34+
},
35+
"author": [
36+
{
37+
"identifier": {
38+
"system": "https://fhir.nhs.uk/Id/ods-organization-code",
39+
"value": "YGM91"
40+
}
41+
}
42+
],
43+
"custodian": {
44+
"identifier": {
45+
"system": "https://fhir.nhs.uk/Id/ods-organization-code",
46+
"value": "YGM91"
47+
}
48+
},
49+
"content": [
50+
{
51+
"extension": [
52+
{
53+
"url": "https://fhir.nhs.uk/England/StructureDefinition/Extension-England-ContentStability",
54+
"valueCodeableConcept": {
55+
"coding": [
56+
{
57+
"system": "https://fhir.nhs.uk/England/CodeSystem/England-NRLContentStability",
58+
"code": "dynamic",
59+
"display": "Dynamic"
60+
}
61+
]
62+
}
63+
}
64+
],
65+
"attachment": {
66+
"contentType": "application/pdf",
67+
"language": "en",
68+
"url": "ssp://endpoint.nrlproducer.thirdparty.nhs.uk/nrl/content",
69+
"title": "Treatment Escalation Plan"
70+
},
71+
"format": {
72+
"system": "https://fhir.nhs.uk/England/CodeSystem/England-NRLFormatCode",
73+
"code": "urn:nhs-ic:unstructured",
74+
"display": "Unstructured Document"
75+
}
76+
}
77+
],
78+
"context": {
79+
"practiceSetting": {
80+
"coding": [
81+
{
82+
"system": "http://snomed.info/sct",
83+
"code": "92221000000103",
84+
"display": "Mental health home treatment team"
85+
}
86+
]
87+
},
88+
"related": [
89+
{
90+
"identifier": {
91+
"system": "https://fhir.nhs.uk/Id/nhsSpineASID",
92+
"value": "012345678910"
93+
}
94+
}
95+
]
96+
}
97+
}

0 commit comments

Comments
 (0)