Skip to content

Commit 5e8f108

Browse files
NRL-1554 Add test for two retrieval mechanisms
1 parent f526df8 commit 5e8f108

File tree

1 file changed

+97
-0
lines changed

1 file changed

+97
-0
lines changed

layer/nrlf/core/tests/test_validators.py

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1630,3 +1630,100 @@ def test_validate_content_multiple_content_retrieval_extensions():
16301630
"diagnostics": "Invalid content retrieval extension: Extension must have one content retrieval extension, see: ('https://fhir.nhs.uk/England/ValueSet/England-RetrievalMechanism')",
16311631
"expression": ["content[0].extension"],
16321632
}
1633+
1634+
1635+
def test_validate_two_content_with_different_retrieval_mechanisms():
1636+
"""Test that two content items with different retrieval mechanisms are valid."""
1637+
validator = DocumentReferenceValidator()
1638+
document_ref_data = load_document_reference_json("Y05868-736253002-Valid")
1639+
1640+
unstructured_format = {
1641+
"system": "https://fhir.nhs.uk/England/CodeSystem/England-NRLFormatCode",
1642+
"code": "urn:nhs-ic:unstructured",
1643+
"display": "Unstructured Document",
1644+
}
1645+
1646+
static_content_stability = {
1647+
"url": "https://fhir.nhs.uk/England/StructureDefinition/Extension-England-ContentStability",
1648+
"valueCodeableConcept": {
1649+
"coding": [
1650+
{
1651+
"system": "https://fhir.nhs.uk/England/CodeSystem/England-NRLContentStability",
1652+
"code": "static",
1653+
"display": "Static",
1654+
}
1655+
]
1656+
},
1657+
}
1658+
1659+
# Add retrieval mechanism extension to the first content item, ssp
1660+
first_content = {
1661+
"attachment": {
1662+
"contentType": "application/pdf",
1663+
"url": "ssp://example.com/document1.pdf",
1664+
},
1665+
"format": unstructured_format,
1666+
"extension": [
1667+
{
1668+
"url": "https://fhir.nhs.uk/England/StructureDefinition/Extension-England-RetrievalMechanism",
1669+
"valueCodeableConcept": {
1670+
"coding": [
1671+
{
1672+
"system": "https://fhir.nhs.uk/England/CodeSystem/England-RetrievalMechanism",
1673+
"code": "SSP",
1674+
"display": "Spine Secure Proxy",
1675+
}
1676+
]
1677+
},
1678+
},
1679+
static_content_stability,
1680+
],
1681+
}
1682+
1683+
document_ref_data["content"] = [first_content]
1684+
1685+
# Add valid ASID identifier in context.related
1686+
document_ref_data["context"]["related"] = [
1687+
{
1688+
"identifier": {
1689+
"system": "https://fhir.nhs.uk/Id/nhsSpineASID",
1690+
"value": "123456789012",
1691+
}
1692+
}
1693+
]
1694+
1695+
result = validator.validate(document_ref_data)
1696+
1697+
assert result.is_valid is True
1698+
assert len(result.issues) == 0
1699+
1700+
# Add a second content item with a different retrieval mechanism
1701+
second_content = {
1702+
"attachment": {
1703+
"contentType": "application/pdf",
1704+
"url": "http://example.com/document2.pdf",
1705+
},
1706+
"format": unstructured_format,
1707+
"extension": [
1708+
{
1709+
"url": "https://fhir.nhs.uk/England/StructureDefinition/Extension-England-RetrievalMechanism",
1710+
"valueCodeableConcept": {
1711+
"coding": [
1712+
{
1713+
"system": "https://fhir.nhs.uk/England/CodeSystem/England-RetrievalMechanism",
1714+
"code": "Direct",
1715+
"display": "Direct",
1716+
}
1717+
]
1718+
},
1719+
},
1720+
static_content_stability,
1721+
],
1722+
}
1723+
1724+
document_ref_data["content"].append(second_content)
1725+
1726+
result = validator.validate(document_ref_data)
1727+
1728+
assert result.is_valid is True
1729+
assert len(result.issues) == 0

0 commit comments

Comments
 (0)