Skip to content

Commit d48ab5a

Browse files
NRL-518 Move content fhir url strings to constants
1 parent 22523d9 commit d48ab5a

File tree

4 files changed

+31
-10
lines changed

4 files changed

+31
-10
lines changed

layer/nrlf/core/constants.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,3 +185,10 @@ def coding_value(self):
185185

186186

187187
SYSTEM_SHORT_IDS = {"http://snomed.info/sct": "SCT", "https://nicip.nhs.uk": "NICIP"}
188+
CONTENT_STABILITY_EXTENSION_URL = (
189+
"https://fhir.nhs.uk/England/StructureDefinition/Extension-England-ContentStability"
190+
)
191+
CONTENT_STABILITY_SYSTEM_URL = (
192+
"https://fhir.nhs.uk/England/CodeSystem/England-NRLContentStability"
193+
)
194+
CONTENT_FORMAT_CODE_URL = "https://fhir.nhs.uk/England/CodeSystem/England-NRLFormatCode"

layer/nrlf/core/errors.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from pydantic import ValidationError
44
from pydantic_core import ErrorDetails
55

6+
from nrlf.core.constants import CONTENT_FORMAT_CODE_URL, CONTENT_STABILITY_SYSTEM_URL
67
from nrlf.core.response import Response
78
from nrlf.core.types import CodeableConcept
89
from nrlf.producer.fhir.r4 import model as producer_model
@@ -25,9 +26,9 @@ def append_value_set_url(loc_string: str) -> str:
2526

2627
if "content" in loc_string:
2728
if "extension" in loc_string:
28-
return ". See ValueSet: https://fhir.nhs.uk/England/CodeSystem/England-NRLContentStability"
29+
return f". See ValueSet: {CONTENT_STABILITY_SYSTEM_URL}"
2930
if "format" in loc_string:
30-
return ". See ValueSet: https://fhir.nhs.uk/England/CodeSystem/England-NRLFormatCode"
31+
return f". See ValueSet: {CONTENT_FORMAT_CODE_URL}"
3132

3233
return ""
3334

tests/features/utils/data.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
from layer.nrlf.core.constants import CATEGORY_ATTRIBUTES, TYPE_ATTRIBUTES
1+
from layer.nrlf.core.constants import (
2+
CATEGORY_ATTRIBUTES,
3+
CONTENT_FORMAT_CODE_URL,
4+
CONTENT_STABILITY_EXTENSION_URL,
5+
CONTENT_STABILITY_SYSTEM_URL,
6+
TYPE_ATTRIBUTES,
7+
)
28
from nrlf.producer.fhir.r4.model import (
39
Attachment,
410
CodeableConcept,
@@ -43,18 +49,18 @@ def create_test_document_reference(items: dict) -> DocumentReference:
4349
format=NRLFormatCode(
4450
system=items.get(
4551
"formatSystem",
46-
"https://fhir.nhs.uk/England/CodeSystem/England-NRLFormatCode",
52+
CONTENT_FORMAT_CODE_URL,
4753
),
4854
code=items.get("formatCode", "urn:nhs-ic:unstructured"),
4955
display=items.get("formatDisplay", "Unstructured Document"),
5056
),
5157
extension=[
5258
ContentStabilityExtension(
53-
url="https://fhir.nhs.uk/England/StructureDefinition/Extension-England-ContentStability",
59+
url=CONTENT_STABILITY_EXTENSION_URL,
5460
valueCodeableConcept=ContentStabilityExtensionValueCodeableConcept(
5561
coding=[
5662
ContentStabilityExtensionCoding(
57-
system="https://fhir.nhs.uk/England/CodeSystem/England-NRLContentStability",
63+
system=CONTENT_STABILITY_SYSTEM_URL,
5864
code="static",
5965
display="Static",
6066
)

tests/smoke/setup.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
from nrlf.core.constants import TYPE_ATTRIBUTES, Categories, PointerTypes
1+
from nrlf.core.constants import (
2+
CONTENT_FORMAT_CODE_URL,
3+
CONTENT_STABILITY_EXTENSION_URL,
4+
CONTENT_STABILITY_SYSTEM_URL,
5+
TYPE_ATTRIBUTES,
6+
Categories,
7+
PointerTypes,
8+
)
29
from nrlf.producer.fhir.r4.model import (
310
Attachment,
411
CodeableConcept,
@@ -37,17 +44,17 @@ def build_document_reference(
3744
url=content_url,
3845
),
3946
format=NRLFormatCode(
40-
system="https://fhir.nhs.uk/England/CodeSystem/England-NRLFormatCode",
47+
system=CONTENT_FORMAT_CODE_URL,
4148
code="urn:nhs-ic:unstructured",
4249
display="Unstructured Document",
4350
),
4451
extension=[
4552
ContentStabilityExtension(
46-
url="https://fhir.nhs.uk/England/StructureDefinition/Extension-England-ContentStability",
53+
url=CONTENT_STABILITY_EXTENSION_URL,
4754
valueCodeableConcept=ContentStabilityExtensionValueCodeableConcept(
4855
coding=[
4956
ContentStabilityExtensionCoding(
50-
system="https://fhir.nhs.uk/England/CodeSystem/England-NRLContentStability",
57+
system=CONTENT_STABILITY_SYSTEM_URL,
5158
code="static",
5259
display="Static",
5360
)

0 commit comments

Comments
 (0)