Skip to content

Commit aa1c4be

Browse files
NRL-1149 Add validation for type coding system/code
1 parent 764af14 commit aa1c4be

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
@@ -383,6 +383,16 @@ def _validate_type(self, model: DocumentReference):
383383
)
384384
return
385385

386+
type_id = f"{coding.system}|{coding.code}"
387+
if type_id not in TYPE_ATTRIBUTES.keys():
388+
self.result.add_error(
389+
issue_code="value",
390+
error_code="INVALID_RESOURCE",
391+
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)",
392+
field="type.coding[0].code",
393+
)
394+
return
395+
386396
type_attributes = TYPE_ATTRIBUTES.get(type_id, {})
387397
if coding.display != type_attributes.get("display"):
388398
self.result.add_error(

0 commit comments

Comments
 (0)