Skip to content

Commit 4fad9db

Browse files
NRL-1491 Add tests for in context launch document pointers
1 parent 289501e commit 4fad9db

File tree

3 files changed

+121
-1
lines changed

3 files changed

+121
-1
lines changed

layer/nrlf/core/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ def coding_value(self):
687687
CONTENT_RETRIEVAL_CODE_MAP = {
688688
"Direct": "Direct",
689689
"SSP": "Spine Secure Proxy",
690-
"NDR": "Large Document Retrieval",
690+
"LDR": "Large Document Retrieval",
691691
"InContext": "Direct using In-Context",
692692
}
693693
CONTENT_FORMAT_CODE_URL = "https://fhir.nhs.uk/England/CodeSystem/England-NRLFormatCode"

layer/nrlf/core/tests/test_validators.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1884,6 +1884,7 @@ def test_validate_content_stability_extension_display_mismatch(code, display):
18841884
("SSP", "Spine Secure Proxy"),
18851885
("Direct", "Direct"),
18861886
("LDR", "Large Document Retrieval"),
1887+
("InContext", "Direct using In-Context"),
18871888
],
18881889
)
18891890
def test_validate_retrieval_mechanism_extension_valid(code, display):
@@ -1911,3 +1912,45 @@ def test_validate_retrieval_mechanism_extension_display_mismatch(code, display):
19111912
in issue.diagnostics
19121913
for issue in validator.result.issues
19131914
)
1915+
1916+
1917+
def test_validate_structured_format_with_text_html_for_incontext_launch():
1918+
validator = DocumentReferenceValidator()
1919+
document_ref_data = load_document_reference_json("Y05868-736253002-Valid")
1920+
1921+
# Set up for direct in-context launch
1922+
document_ref_data["content"][0]["attachment"]["contentType"] = "text/html"
1923+
document_ref_data["content"][0]["format"] = {
1924+
"system": "https://fhir.nhs.uk/England/CodeSystem/England-NRLFormatCode",
1925+
"code": "urn:nhs-ic:structured",
1926+
"display": "Structured Document",
1927+
}
1928+
document_ref_data["content"][0]["extension"] = [
1929+
{
1930+
"url": "https://fhir.nhs.uk/England/StructureDefinition/Extension-England-RetrievalMechanism",
1931+
"valueCodeableConcept": {
1932+
"coding": [
1933+
{
1934+
"system": "https://fhir.nhs.uk/England/CodeSystem/England-RetrievalMechanism",
1935+
"code": "InContext",
1936+
"display": "Direct using In-Context",
1937+
}
1938+
]
1939+
},
1940+
},
1941+
{
1942+
"url": "https://fhir.nhs.uk/England/StructureDefinition/Extension-England-ContentStability",
1943+
"valueCodeableConcept": {
1944+
"coding": [
1945+
{
1946+
"system": "https://fhir.nhs.uk/England/CodeSystem/England-NRLContentStability",
1947+
"code": "dynamic",
1948+
"display": "Dynamic",
1949+
}
1950+
]
1951+
},
1952+
},
1953+
]
1954+
1955+
result = validator.validate(document_ref_data)
1956+
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)