Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions api/consumer/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1015,10 +1015,16 @@ components:
- "https://fhir.nhs.uk/England/CodeSystem/England-RetrievalMechanism"
code:
type: string
enum: ["SSP", "Direct", "LDR"]
enum: ["SSP", "Direct", "LDR", "InContext"]
display:
type: string
enum: ["Spine Secure Proxy", "Direct", "Large Document Retrieval"]
enum:
[
"Spine Secure Proxy",
"Direct",
"Large Document Retrieval",
"Direct using In-Context",
]
required:
- system
- code
Expand Down
10 changes: 8 additions & 2 deletions api/producer/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1671,10 +1671,16 @@ components:
- "https://fhir.nhs.uk/England/CodeSystem/England-RetrievalMechanism"
code:
type: string
enum: ["SSP", "Direct", "LDR"]
enum: ["SSP", "Direct", "LDR", "InContext"]
display:
type: string
enum: ["Spine Secure Proxy", "Direct", "Large Document Retrieval"]
enum:
[
"Spine Secure Proxy",
"Direct",
"Large Document Retrieval",
"Direct using In-Context",
]
required:
- system
- code
Expand Down
9 changes: 7 additions & 2 deletions layer/nrlf/consumer/fhir/r4/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,13 @@ class ContentStabilityExtensionCoding(Coding):

class RetrievalMechanismExtensionCoding(Coding):
system: Literal["https://fhir.nhs.uk/England/CodeSystem/England-RetrievalMechanism"]
code: Literal["SSP", "Direct", "LDR"]
display: Literal["Spine Secure Proxy", "Direct", "Large Document Retrieval"]
code: Literal["SSP", "Direct", "LDR", "InContext"]
display: Literal[
"Spine Secure Proxy",
"Direct",
"Large Document Retrieval",
"Direct using In-Context",
]


class NRLFormatCode(Coding):
Expand Down
1 change: 1 addition & 0 deletions layer/nrlf/core/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,7 @@ def coding_value(self):
"Direct": "Direct",
"SSP": "Spine Secure Proxy",
"LDR": "Large Document Retrieval",
"InContext": "Direct using In-Context",
}
CONTENT_FORMAT_CODE_URL = "https://fhir.nhs.uk/England/CodeSystem/England-NRLFormatCode"
CONTENT_FORMAT_CODE_MAP = {
Expand Down
43 changes: 43 additions & 0 deletions layer/nrlf/core/tests/test_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -1884,6 +1884,7 @@ def test_validate_content_stability_extension_display_mismatch(code, display):
("SSP", "Spine Secure Proxy"),
("Direct", "Direct"),
("LDR", "Large Document Retrieval"),
("InContext", "Direct using In-Context"),
],
)
def test_validate_retrieval_mechanism_extension_valid(code, display):
Expand Down Expand Up @@ -1911,3 +1912,45 @@ def test_validate_retrieval_mechanism_extension_display_mismatch(code, display):
in issue.diagnostics
for issue in validator.result.issues
)


def test_validate_structured_format_with_text_html_for_incontext_launch():
validator = DocumentReferenceValidator()
document_ref_data = load_document_reference_json("Y05868-736253002-Valid")

# Set up for direct in-context launch
document_ref_data["content"][0]["attachment"]["contentType"] = "text/html"
document_ref_data["content"][0]["format"] = {
"system": "https://fhir.nhs.uk/England/CodeSystem/England-NRLFormatCode",
"code": "urn:nhs-ic:structured",
"display": "Structured Document",
}
document_ref_data["content"][0]["extension"] = [
{
"url": "https://fhir.nhs.uk/England/StructureDefinition/Extension-England-RetrievalMechanism",
"valueCodeableConcept": {
"coding": [
{
"system": "https://fhir.nhs.uk/England/CodeSystem/England-RetrievalMechanism",
"code": "InContext",
"display": "Direct using In-Context",
}
]
},
},
{
"url": "https://fhir.nhs.uk/England/StructureDefinition/Extension-England-ContentStability",
"valueCodeableConcept": {
"coding": [
{
"system": "https://fhir.nhs.uk/England/CodeSystem/England-NRLContentStability",
"code": "dynamic",
"display": "Dynamic",
}
]
},
},
]

result = validator.validate(document_ref_data)
assert result.is_valid is True
3 changes: 2 additions & 1 deletion layer/nrlf/core/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,8 @@ def _validate_content_format(self, model: DocumentReference):
for i, content in enumerate(model.content):
if (
content.attachment.contentType == "text/html"
and content.format.code != "urn:nhs-ic:record-contact"
and content.format.code
not in ["urn:nhs-ic:record-contact", "urn:nhs-ic:structured"]
):
self.result.add_error(
issue_code="business-rule",
Expand Down
9 changes: 7 additions & 2 deletions layer/nrlf/producer/fhir/r4/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,13 @@ class ContentStabilityExtensionCoding(Coding):

class RetrievalMechanismExtensionCoding(Coding):
system: Literal["https://fhir.nhs.uk/England/CodeSystem/England-RetrievalMechanism"]
code: Literal["SSP", "Direct", "LDR"]
display: Literal["Spine Secure Proxy", "Direct", "Large Document Retrieval"]
code: Literal["SSP", "Direct", "LDR", "InContext"]
display: Literal[
"Spine Secure Proxy",
"Direct",
"Large Document Retrieval",
"Direct using In-Context",
]


class NRLFormatCode(Coding):
Expand Down
9 changes: 7 additions & 2 deletions layer/nrlf/producer/fhir/r4/strict_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,13 @@ class ContentStabilityExtensionCoding(Coding):

class RetrievalMechanismExtensionCoding(Coding):
system: Literal["https://fhir.nhs.uk/England/CodeSystem/England-RetrievalMechanism"]
code: Literal["SSP", "Direct", "LDR"]
display: Literal["Spine Secure Proxy", "Direct", "Large Document Retrieval"]
code: Literal["SSP", "Direct", "LDR", "InContext"]
display: Literal[
"Spine Secure Proxy",
"Direct",
"Large Document Retrieval",
"Direct using In-Context",
]


class NRLFormatCode(Coding):
Expand Down
11 changes: 9 additions & 2 deletions resources/fhir/NRLF-Retrieval-CodeSystem.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"resourceType": "CodeSystem",
"id": "England-RetrievalMechanismNRL",
"url": "https://fhir.nhs.uk/England/CodeSystem/England-RetrievalMechanismNRL",
"version": "1.0.1",
"version": "1.1.0",
"name": "EnglandRetrievalMechanismNRL",
"title": "England Retrieval MechanismNRL",
"status": "draft",
Expand Down Expand Up @@ -40,7 +40,14 @@
{
"code": "Direct",
"display": "Direct",
"definition": "This document can be directly retrieved via HTTP(s) at its public URL."
"definition": "This document can be directly retrieved via HTTP(s) at its public URL.",
"concept": [
{
"code": "InContext",
"display": "Direct using In-Context",
"definition": "This document can be retrieved in-context via the In-Context launch mechanism."
}
]
},
{
"code": "Proxy",
Expand Down
6 changes: 5 additions & 1 deletion resources/fhir/NRLF-RetrievalMechanism-ValueSet.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"resourceType": "ValueSet",
"id": "England-RetrievalMechanism",
"url": "https://fhir.nhs.uk/England/ValueSet/England-RetrievalMechanism",
"version": "1.0.1",
"version": "1.1.0",
"name": "EnglandRetrievalMechanism",
"status": "draft",
"date": "2025-02-28",
Expand Down Expand Up @@ -33,6 +33,10 @@
{
"code": "LDR",
"display": "Large Document Retrieval"
},
{
"code": "InContext",
"display": "Direct using In-Context"
}
]
}
Expand Down
107 changes: 107 additions & 0 deletions tests/data/samples/SYNTHETIC_IN_CONTEXT_LAUNCH_EXAMPLE.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
{
"resourceType": "DocumentReference",
"id": "INCTX-197ca0ca-f547-42b6-a68c-99b75a3a2df5",
"meta": {
"lastUpdated": "2025-02-10T16:48:27.326Z"
},
"masterIdentifier": {
"system": "urn:ietf:rfc:3986",
"value": "mid_197ca0ca-f547-42b6-a68c-99b75a3a2df5"
},
"status": "current",
"type": {
"coding": [
{
"system": "http://snomed.info/sct",
"code": "736253002",
"display": "Mental health crisis plan"
}
]
},
"category": [
{
"coding": [
{
"system": "http://snomed.info/sct",
"code": "734163000",
"display": "Care plan"
}
]
}
],
"subject": {
"identifier": {
"system": "https://fhir.nhs.uk/Id/nhs-number",
"value": "9999999999"
}
},
"date": "2025-02-10T16:48:27.326Z",
"author": [
{
"identifier": {
"system": "https://fhir.nhs.uk/Id/ods-organization-code",
"value": "L85012"
}
}
],
"custodian": {
"identifier": {
"system": "https://fhir.nhs.uk/Id/ods-organization-code",
"value": "INCTX"
}
},
"content": [
{
"attachment": {
"contentType": "text/html",
"url": "https://supplier.inctxlaunch.example/content",
"creation": "2025-02-10T16:48:27.326Z"
},
"format": {
"system": "https://fhir.nhs.uk/England/CodeSystem/England-NRLFormatCode",
"code": "urn:nhs-ic:structured",
"display": "Structured Document"
},
"extension": [
{
"valueCodeableConcept": {
"coding": [
{
"system": "https://fhir.nhs.uk/England/CodeSystem/England-NRLContentStability",
"code": "dynamic",
"display": "Dynamic"
}
]
},
"url": "https://fhir.nhs.uk/England/StructureDefinition/Extension-England-ContentStability"
},
{
"valueCodeableConcept": {
"coding": [
{
"system": "https://fhir.nhs.uk/England/CodeSystem/England-RetrievalMechanism",
"code": "InContext",
"display": "Direct using In-Context"
}
]
},
"url": "https://fhir.nhs.uk/England/StructureDefinition/Extension-England-RetrievalMechanism"
}
]
}
],
"context": {
"period": {
"start": "2025-02-10T16:48:27.326Z"
},
"practiceSetting": {
"coding": [
{
"system": "http://snomed.info/sct",
"code": "1060971000000108",
"display": "General practice service"
}
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1369,7 +1369,7 @@ Feature: Producer - createDocumentReference - Failure Scenarios
}
]
},
"diagnostics": "Invalid content retrieval extension (content[0].extension[0].valueCodeableConcept.coding[0].code: Input should be 'SSP', 'Direct' or 'LDR', see: https://fhir.nhs.uk/England/ValueSet/England-RetrievalMechanism)",
"diagnostics": "Invalid content retrieval extension (content[0].extension[0].valueCodeableConcept.coding[0].code: Input should be 'SSP', 'Direct', 'LDR' or 'InContext', see: https://fhir.nhs.uk/England/ValueSet/England-RetrievalMechanism)",
"expression": ["content[0].extension[0].valueCodeableConcept.coding[0].code"]
}
"""
Expand Down Expand Up @@ -1436,7 +1436,7 @@ Feature: Producer - createDocumentReference - Failure Scenarios
}
]
},
"diagnostics": "Invalid content retrieval extension (content[0].extension[0].valueCodeableConcept.coding[0].display: Input should be 'Spine Secure Proxy', 'Direct' or 'Large Document Retrieval', see: https://fhir.nhs.uk/England/ValueSet/England-RetrievalMechanism)",
"diagnostics": "Invalid content retrieval extension (content[0].extension[0].valueCodeableConcept.coding[0].display: Input should be 'Spine Secure Proxy', 'Direct', 'Large Document Retrieval' or 'Direct using In-Context', see: https://fhir.nhs.uk/England/ValueSet/England-RetrievalMechanism)",
"expression": ["content[0].extension[0].valueCodeableConcept.coding[0].display"]
}
"""
Expand Down
Loading
Loading