Skip to content
Open
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
3 changes: 3 additions & 0 deletions layer/nrlf/core/tests/test_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -1198,6 +1198,9 @@ def test_validate_content_format_invalid_code_for_structured_document():
}


@pytest.mark.skip(
reason="Disabling temporarily as the validation rule is now allowed (but only for NRL-1966)"
)
def test_validate_content_format_invalid_code_for_contact_details():
validator = DocumentReferenceValidator()
document_ref_data = load_document_reference_json("Y05868-736253002-Valid")
Expand Down
6 changes: 5 additions & 1 deletion layer/nrlf/core/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,20 +287,20 @@
diagnostics=f"Invalid ASID value '{asid_value}'. A single ASID consisting of 12 digits can be provided in the context.related field.",
field=f"context.related[{idx}].identifier.value",
)
return

Check warning on line 290 in layer/nrlf/core/validators.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this redundant return.

See more on https://sonarcloud.io/project/issues?id=NHSDigital_NRLF&issues=AZy9BQR9C2mJGV9gcnq-&open=AZy9BQR9C2mJGV9gcnq-&pullRequest=1162

def _validate_ssp_asid(self, model: DocumentReference):
"""
Validate that the document contains a valid ASID in the context.related field when the content contains an SSP URL
"""

ssp_content = any(
[
content
for content in model.content
if content.attachment.url.startswith("ssp://")
]
)

Check warning on line 303 in layer/nrlf/core/validators.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Unpack this comprehension expression

See more on https://sonarcloud.io/project/issues?id=NHSDigital_NRLF&issues=AZy9BQR9C2mJGV9gcnrA&open=AZy9BQR9C2mJGV9gcnrA&pullRequest=1162

logger.log(LogReference.VALIDATOR001, step="ssp_content_and_asid_exists")

Expand Down Expand Up @@ -338,7 +338,7 @@
diagnostics="Missing ASID identifier. context.related must contain a single valid ASID identifier when content contains an SSP URL",
field="context.related",
)
return

Check warning on line 341 in layer/nrlf/core/validators.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this redundant return.

See more on https://sonarcloud.io/project/issues?id=NHSDigital_NRLF&issues=AZy9BQR9C2mJGV9gcnq_&open=AZy9BQR9C2mJGV9gcnq_&pullRequest=1162

def _validate_type(self, model: DocumentReference):
"""
Expand Down Expand Up @@ -395,7 +395,7 @@
issue_code="business-rule",
error_code="UNPROCESSABLE_ENTITY",
diagnostics=f"Invalid category length: {len(model.category)} Category must only contain a single value",
field=f"category",

Check warning on line 398 in layer/nrlf/core/validators.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add replacement fields or use a normal string instead of an f-string.

See more on https://sonarcloud.io/project/issues?id=NHSDigital_NRLF&issues=AZy9BQR9C2mJGV9gcnrB&open=AZy9BQR9C2mJGV9gcnrB&pullRequest=1162
)
return

Expand All @@ -406,7 +406,7 @@
issue_code="business-rule",
error_code="UNPROCESSABLE_ENTITY",
diagnostics=f"Invalid category coding length: {len(model.category[0].coding)} Category Coding must only contain a single value",
field=f"category[0].coding",

Check warning on line 409 in layer/nrlf/core/validators.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add replacement fields or use a normal string instead of an f-string.

See more on https://sonarcloud.io/project/issues?id=NHSDigital_NRLF&issues=AZy9BQR9C2mJGV9gcnrC&open=AZy9BQR9C2mJGV9gcnrC&pullRequest=1162
)
return

Expand Down Expand Up @@ -473,7 +473,11 @@
if (
content.attachment.contentType == "text/html"
and content.format.code
not in ["urn:nhs-ic:record-contact", "urn:nhs-ic:structured"]
not in [
"urn:nhs-ic:record-contact",
"urn:nhs-ic:structured",
"urn:nhs-ic:unstructured",
]
):
self.result.add_error(
issue_code="business-rule",
Expand Down Expand Up @@ -652,9 +656,9 @@
diagnostics=f"Invalid author value: '{identifier.value}' Author value must be less than 13 characters",
field="author[0].identifier.value",
)
return

Check warning on line 659 in layer/nrlf/core/validators.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this redundant return.

See more on https://sonarcloud.io/project/issues?id=NHSDigital_NRLF&issues=AZy9BQR9C2mJGV9gcnrD&open=AZy9BQR9C2mJGV9gcnrD&pullRequest=1162

def _validate_practiceSetting(self, model: DocumentReference):

Check warning on line 661 in layer/nrlf/core/validators.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename method "_validate_practiceSetting" to match the regular expression ^[a-z_][a-z0-9_]*$.

See more on https://sonarcloud.io/project/issues?id=NHSDigital_NRLF&issues=AZy9BQR9C2mJGV9gcnrE&open=AZy9BQR9C2mJGV9gcnrE&pullRequest=1162
"""
Validate the practice setting field contains an appropriate coding system and code.
"""
Expand Down Expand Up @@ -716,7 +720,7 @@
diagnostics=f"Invalid practice setting coding: display {practice_setting_display} does not match the expected display for {practice_setting_value} Practice Setting coding is bound to value set {PRACTICE_SETTING_VALUE_SET_URL}",
field="context.practiceSetting.coding[0]",
)
return

Check warning on line 723 in layer/nrlf/core/validators.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this redundant return.

See more on https://sonarcloud.io/project/issues?id=NHSDigital_NRLF&issues=AZy9BQR9C2mJGV9gcnrF&open=AZy9BQR9C2mJGV9gcnrF&pullRequest=1162

def _validate_content(self, model: DocumentReference):
"""
Expand Down
Loading