Skip to content

Commit 6591588

Browse files
committed
[NRL-1290] Add bars pointer type and category. Adapt pointer validators to allow bars pointers for prototype
1 parent 257de74 commit 6591588

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

layer/nrlf/core/constants.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class PointerTypes(Enum):
6666
PERSONALISED_CARE_AND_SUPPORT_PLAN = "http://snomed.info/sct|2181441000000107"
6767
MRA_UPPER_LIMB_ARTERY = "https://nicip.nhs.uk|MAULR"
6868
MRI_AXILLA_BOTH = "https://nicip.nhs.uk|MAXIB"
69+
APPOINTMENT = "http://snomed.info/sct|749001000000101"
6970

7071
@staticmethod
7172
def list():
@@ -84,6 +85,7 @@ class Categories(Enum):
8485
CLINICAL_NOTE = "http://snomed.info/sct|823651000000106"
8586
DIAGNOSTIC_STUDIES_REPORT = "http://snomed.info/sct|721981007"
8687
DIAGNOSTIC_PROCEDURE = "http://snomed.info/sct|103693007"
88+
RECORD_ARTIFACT = "http://snomed.info/sct|419891008"
8789

8890
@staticmethod
8991
def list():
@@ -112,6 +114,9 @@ def coding_value(self):
112114
Categories.DIAGNOSTIC_PROCEDURE.value: {
113115
"display": "Diagnostic procedure",
114116
},
117+
Categories.RECORD_ARTIFACT.value: {
118+
"display": "Record artifact (record artifact)",
119+
},
115120
}
116121

117122
TYPE_ATTRIBUTES = {
@@ -157,6 +162,9 @@ def coding_value(self):
157162
PointerTypes.MRI_AXILLA_BOTH.value: {
158163
"display": "MRI Axilla Both",
159164
},
165+
PointerTypes.APPOINTMENT.value: {
166+
"display": "Appointment (record artifact)",
167+
},
160168
}
161169

162170
TYPE_CATEGORIES = {
@@ -182,6 +190,9 @@ def coding_value(self):
182190
# Imaging
183191
PointerTypes.MRA_UPPER_LIMB_ARTERY.value: Categories.DIAGNOSTIC_STUDIES_REPORT.value,
184192
PointerTypes.MRI_AXILLA_BOTH.value: Categories.DIAGNOSTIC_PROCEDURE.value,
193+
#
194+
# Bars
195+
PointerTypes.APPOINTMENT.value: Categories.RECORD_ARTIFACT.value,
185196
}
186197

187198
PRACTICE_SETTING_VALUE_SET_URL = (
@@ -653,6 +664,7 @@ def coding_value(self):
653664
"24291000087104": "Geriatric chronic pain management service",
654665
"1323501000000109": "Special care dentistry service",
655666
"1423561000000102": "Acute oncology service",
667+
"394802001": "General medicine (qualifier value)",
656668
}
657669

658670

layer/nrlf/core/tests/test_validators.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
ODS_SYSTEM,
88
TYPE_ATTRIBUTES,
99
TYPE_CATEGORIES,
10+
Categories,
1011
PointerTypes,
1112
)
1213
from nrlf.core.errors import ParseError
@@ -430,6 +431,7 @@ def test_validate_category_too_many_category():
430431
[
431432
(category_str.split("|")[1], display_dict["display"])
432433
for category_str, display_dict in CATEGORY_ATTRIBUTES.items()
434+
if category_str != Categories.RECORD_ARTIFACT.value
433435
],
434436
)
435437
def test_validate_category_coding_display_mismatch(
@@ -639,6 +641,7 @@ def test_validate_type_coding_invalid_system():
639641
[
640642
(type_str, display_dict["display"])
641643
for type_str, display_dict in TYPE_ATTRIBUTES.items()
644+
if type_str != PointerTypes.APPOINTMENT.value
642645
],
643646
)
644647
def test_validate_type_coding_display_mismatch(type_str: str, display: str):

layer/nrlf/core/validators.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,10 @@ def _validate_type(self, model: DocumentReference):
368368
)
369369
return
370370

371+
# Bypass display validation for bars appointments
372+
if type_id == PointerTypes.APPOINTMENT.value:
373+
return
374+
371375
type_attributes = TYPE_ATTRIBUTES.get(type_id, {})
372376
if coding.display != type_attributes.get("display"):
373377
self.result.add_error(
@@ -423,6 +427,10 @@ def _validate_category(self, model: DocumentReference):
423427
)
424428
return
425429

430+
# Bypass display validation for bars record artifacts
431+
if category_id == Categories.RECORD_ARTIFACT.value:
432+
return
433+
426434
category_attributes = CATEGORY_ATTRIBUTES.get(category_id, {})
427435
if coding.display != category_attributes.get("display"):
428436
self.result.add_error(
@@ -623,7 +631,13 @@ def _validate_content(self, model: DocumentReference):
623631
}
624632

625633
for i, content in enumerate(model.content):
626-
if content.attachment.contentType not in ["application/pdf", "text/html"]:
634+
if content.attachment.contentType not in [
635+
"application/pdf",
636+
"text/html",
637+
"application/fhir+json",
638+
"application/json",
639+
"application/json+fhir",
640+
]:
627641
self.result.add_error(
628642
issue_code="value",
629643
error_code="INVALID_RESOURCE",

0 commit comments

Comments
 (0)