Skip to content

Commit aa18111

Browse files
NRL-1491 Add tests for in context launch document pointers
1 parent 064db0d commit aa18111

File tree

2 files changed

+119
-0
lines changed

2 files changed

+119
-0
lines changed

layer/nrlf/core/tests/test_validators.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1780,3 +1780,45 @@ def test_validate_content_retrieval_lowercase_urls():
17801780
"diagnostics": "Invalid content retrieval extension (content[0].extension[0].url: Input should be 'https://fhir.nhs.uk/England/StructureDefinition/Extension-England-RetrievalMechanism', see: https://fhir.nhs.uk/England/ValueSet/England-RetrievalMechanism)",
17811781
"expression": ["content[0].extension[0].url"],
17821782
}
1783+
1784+
1785+
def test_validate_structured_format_with_text_html_for_incontext_launch():
1786+
validator = DocumentReferenceValidator()
1787+
document_ref_data = load_document_reference_json("Y05868-736253002-Valid")
1788+
1789+
# Set up for direct in-context launch
1790+
document_ref_data["content"][0]["attachment"]["contentType"] = "text/html"
1791+
document_ref_data["content"][0]["format"] = {
1792+
"system": "https://fhir.nhs.uk/England/CodeSystem/England-NRLFormatCode",
1793+
"code": "urn:nhs-ic:structured",
1794+
"display": "Structured Document",
1795+
}
1796+
document_ref_data["content"][0]["extension"] = [
1797+
{
1798+
"url": "https://fhir.nhs.uk/England/StructureDefinition/Extension-England-RetrievalMechanism",
1799+
"valueCodeableConcept": {
1800+
"coding": [
1801+
{
1802+
"system": "https://fhir.nhs.uk/England/CodeSystem/England-RetrievalMechanism",
1803+
"code": "InContext",
1804+
"display": "Direct using In-Context",
1805+
}
1806+
]
1807+
},
1808+
},
1809+
{
1810+
"url": "https://fhir.nhs.uk/England/StructureDefinition/Extension-England-ContentStability",
1811+
"valueCodeableConcept": {
1812+
"coding": [
1813+
{
1814+
"system": "https://fhir.nhs.uk/England/CodeSystem/England-NRLContentStability",
1815+
"code": "dynamic",
1816+
"display": "Dynamic",
1817+
}
1818+
]
1819+
},
1820+
},
1821+
]
1822+
1823+
result = validator.validate(document_ref_data)
1824+
assert result.is_valid is True

tests/features/producer/createDocumentReference-success.feature

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,3 +491,80 @@ Feature: Producer - createDocumentReference - Success Scenarios
491491
| content[1].attachment.url | https://example.org/doc2.pdf |
492492
| content[1].extension[1].valueCodeableConcept.coding[0].code | SSP |
493493
| content[1].extension[1].valueCodeableConcept.coding[0].display | Spine Secure Proxy |
494+
495+
Scenario: Successfully create a Document Pointer with InContext retrieval mechanism and structured format
496+
Given the application 'DataShare' (ID 'z00z-y11y-x22x') is registered to access the API
497+
And the organisation 'TSTCUS' is authorised to access pointer types:
498+
| system | value |
499+
| http://snomed.info/sct | 1363501000000100 |
500+
When producer 'TSTCUS' requests creation of a DocumentReference with default test values except 'content' is:
501+
"""
502+
"content": [
503+
{
504+
"attachment": {
505+
"contentType": "text/html",
506+
"url": "https://example.org/incontext-launch.html"
507+
},
508+
"format": {
509+
"system": "https://fhir.nhs.uk/England/CodeSystem/England-NRLFormatCode",
510+
"code": "urn:nhs-ic:structured",
511+
"display": "Structured Document"
512+
},
513+
"extension": [
514+
{
515+
"url": "https://fhir.nhs.uk/England/StructureDefinition/Extension-England-ContentStability",
516+
"valueCodeableConcept": {
517+
"coding": [
518+
{
519+
"system": "https://fhir.nhs.uk/England/CodeSystem/England-NRLContentStability",
520+
"code": "dynamic",
521+
"display": "Dynamic"
522+
}
523+
]
524+
}
525+
},
526+
{
527+
"url": "https://fhir.nhs.uk/England/StructureDefinition/Extension-England-RetrievalMechanism",
528+
"valueCodeableConcept": {
529+
"coding": [
530+
{
531+
"system": "https://fhir.nhs.uk/England/CodeSystem/England-RetrievalMechanism",
532+
"code": "InContext",
533+
"display": "Direct using In-Context"
534+
}
535+
]
536+
}
537+
}
538+
]
539+
}
540+
]
541+
"""
542+
Then the response status code is 201
543+
And the response is an OperationOutcome with 1 issue
544+
And the OperationOutcome contains the issue:
545+
"""
546+
{
547+
"severity": "information",
548+
"code": "informational",
549+
"details": {
550+
"coding": [
551+
{
552+
"system": "https://fhir.nhs.uk/ValueSet/NRL-ResponseCode",
553+
"code": "RESOURCE_CREATED",
554+
"display": "Resource created"
555+
}
556+
]
557+
},
558+
"diagnostics": "The document has been created"
559+
}
560+
"""
561+
And the response has a Location header
562+
And the Location header starts with '/producer/FHIR/R4/DocumentReference/TSTCUS-'
563+
And the resource in the Location header exists with values:
564+
| property | value |
565+
| content[0].attachment.url | https://example.org/incontext-launch.html |
566+
| content[0].attachment.contentType | text/html |
567+
| content[0].format.code | urn:nhs-ic:structured |
568+
| content[0].format.display | Structured Document |
569+
| content[0].extension[1].valueCodeableConcept.coding[0].code | InContext |
570+
| content[0].extension[1].valueCodeableConcept.coding[0].display | Direct using In-Context |

0 commit comments

Comments
 (0)