Skip to content

Commit 9170bad

Browse files
NRL-1149 Add validation for type coding system/code
1 parent 2c879ec commit 9170bad

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

layer/nrlf/core/validators.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,16 @@ def _validate_type(self, model: DocumentReference):
370370
)
371371
return
372372

373+
type_id = f"{coding.system}|{coding.code}"
374+
if type_id not in TYPE_ATTRIBUTES.keys():
375+
self.result.add_error(
376+
issue_code="value",
377+
error_code="INVALID_RESOURCE",
378+
diagnostics=f"Invalid type code: {coding.code} Type must be a member of the England-NRLRecordCategory value set (https://fhir.nhs.uk/England/CodeSystem/England-NRLRecordType)",
379+
field="type.coding[0].code",
380+
)
381+
return
382+
373383
type_attributes = TYPE_ATTRIBUTES.get(type_id, {})
374384
if coding.display != type_attributes.get("display"):
375385
self.result.add_error(

0 commit comments

Comments
 (0)