Skip to content

Commit

Permalink
Reduce severity of failed membership checks
Browse files Browse the repository at this point in the history
For extensible and preferred binding we now emit these messages with a
severity of INFORMATIONAL instead of WARNING.

Signed-off-by: Lee Surprenant <lmsurpre@us.ibm.com>
  • Loading branch information
lmsurpre committed Dec 1, 2021
1 parent 5bae423 commit 73548cf
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -268,15 +268,15 @@ private void generateIssue(ValidationOutcome outcome, EvaluationContext evaluati
* @param strength the binding strength
*/
private void generateIssue(String message, EvaluationContext evaluationContext, FHIRPathElementNode elementNode, String strength) {
IssueSeverity severity = ("extensible".equals(strength) || "preferred".equals(strength)) ? IssueSeverity.WARNING : IssueSeverity.ERROR;
IssueSeverity severity = ("required".equals(strength)) ? IssueSeverity.ERROR : IssueSeverity.INFORMATION;
generateIssue(evaluationContext, severity, IssueType.CODE_INVALID, message, elementNode.path());
}

private Collection<FHIRPathNode> membershipCheckFailed(EvaluationContext evaluationContext, FHIRPathElementNode elementNode, String url, String strength) {
if ("extensible".equals(strength) || "preferred".equals(strength)) {
String prefix = evaluationContext.hasConstraint() ? evaluationContext.getConstraint().id() + ": " : "";
String description = prefix + "The concept in this element " + ("extensible".equals(strength) ? "must" : "should") + " be from the specified value set '" + url + "' if possible";
generateIssue(evaluationContext, IssueSeverity.WARNING, IssueType.CODE_INVALID, description, elementNode.path());
String description = prefix + "A code in this element " + ("extensible".equals(strength) ? "must" : "should") + " be from the specified value set '" + url + "' if possible";
generateIssue(evaluationContext, IssueSeverity.INFORMATION, IssueType.CODE_INVALID, description, elementNode.path());
return SINGLETON_TRUE;
}
return SINGLETON_FALSE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public void testMemberOfFunction8() throws Exception {

Assert.assertEquals(evaluationContext.getIssues().size(), 2);
Issue issue = evaluationContext.getIssues().get(0);
Assert.assertEquals(issue.getSeverity(), IssueSeverity.WARNING);
Assert.assertEquals(issue.getSeverity(), IssueSeverity.INFORMATION);
Assert.assertEquals(issue.getCode(), IssueType.CODE_INVALID);
Assert.assertEquals(result, SINGLETON_TRUE);
}
Expand All @@ -150,7 +150,7 @@ public void testMemberOfFunction9() throws Exception {

Assert.assertEquals(evaluationContext.getIssues().size(), 2);
Issue issue = evaluationContext.getIssues().get(0);
Assert.assertEquals(issue.getSeverity(), IssueSeverity.WARNING);
Assert.assertEquals(issue.getSeverity(), IssueSeverity.INFORMATION);
Assert.assertEquals(issue.getCode(), IssueType.CODE_INVALID);
Assert.assertEquals(result, SINGLETON_TRUE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,29 +155,33 @@ public void testValidator() throws Exception {
)).build();
issues = FHIRValidator.validator().validate(device);
assertEquals(FHIRValidationUtil.countErrors(issues), 0);
assertEquals(FHIRValidationUtil.countWarnings(issues), 2);
assertEquals(FHIRValidationUtil.countWarnings(issues), 0);
assertEquals(FHIRValidationUtil.countInformation(issues), 2);

// Warning for type
device = buildDevice().toBuilder()
.type(CodeableConcept.builder().coding(Coding.builder().system(Uri.of(ValidationSupport.BCP_47_URN)).code(Code.of("tlh")).build()).build()).build();
issues = FHIRValidator.validator().validate(device);
assertEquals(FHIRValidationUtil.countErrors(issues), 0);
assertEquals(FHIRValidationUtil.countWarnings(issues), 1);
assertEquals(FHIRValidationUtil.countWarnings(issues), 0);
assertEquals(FHIRValidationUtil.countInformation(issues), 1);

// Error for type
device = buildDevice().toBuilder()
.type(CodeableConcept.builder().coding(Coding.builder().system(Uri.of(ValidationSupport.BCP_47_URN)).code(Code.of("invalidLanguage")).build()).build()).build();
issues = FHIRValidator.validator().validate(device);
assertEquals(FHIRValidationUtil.countErrors(issues), 2);
assertEquals(FHIRValidationUtil.countWarnings(issues), 1);
assertEquals(FHIRValidationUtil.countWarnings(issues), 0);
assertEquals(FHIRValidationUtil.countInformation(issues), 1);

// Warning and error for specialization.systemType
device = buildDevice().toBuilder().specialization(Arrays.asList(
Specialization.builder().systemType(CodeableConcept.builder().coding(Coding.builder().system(Uri.of(ValidationSupport.BCP_47_URN)).code(Code.of("tlh")).build()).build()).build(),
Specialization.builder().systemType(CodeableConcept.builder().coding(Coding.builder().system(Uri.of(ValidationSupport.BCP_47_URN)).code(Code.of("invalidSystem")).build()).build()).build())).build();
issues = FHIRValidator.validator().validate(device);
assertEquals(FHIRValidationUtil.countErrors(issues), 2);
assertEquals(FHIRValidationUtil.countWarnings(issues), 2);
assertEquals(FHIRValidationUtil.countWarnings(issues), 0);
assertEquals(FHIRValidationUtil.countInformation(issues), 2);

// Warning and error for safety
device = buildDevice().toBuilder().safety(Arrays.asList(
Expand All @@ -186,58 +190,63 @@ public void testValidator() throws Exception {
)).build();
issues = FHIRValidator.validator().validate(device);
assertEquals(FHIRValidationUtil.countErrors(issues), 2);
assertEquals(FHIRValidationUtil.countWarnings(issues), 2);
assertEquals(FHIRValidationUtil.countWarnings(issues), 0);
assertEquals(FHIRValidationUtil.countInformation(issues), 2);

// Warning for test-language-primary-extension
device = buildDevice().toBuilder()
.extension(Collections.singletonList(Extension.builder().url("http://ibm.com/fhir/StructureDefinition/test-language-primary-extension")
.value(CodeableConcept.builder().coding(Coding.builder().system(Uri.of(ValidationSupport.BCP_47_URN)).code(Code.of("tlh")).build()).build()).build())).build();
issues = FHIRValidator.validator().validate(device);
issues.forEach(System.out::println);
assertEquals(FHIRValidationUtil.countErrors(issues), 0);
assertEquals(FHIRValidationUtil.countWarnings(issues), 1);
assertEquals(FHIRValidationUtil.countWarnings(issues), 0);
assertEquals(FHIRValidationUtil.countInformation(issues), 1);

// Error for test-language-primary-extension
device = buildDevice().toBuilder()
.extension(Collections.singletonList(Extension.builder().url("http://ibm.com/fhir/StructureDefinition/test-language-primary-extension")
.value(CodeableConcept.builder().coding(Coding.builder().system(Uri.of(ValidationSupport.BCP_47_URN)).code(Code.of("invalidLanguage")).build()).build()).build())).build();
issues = FHIRValidator.validator().validate(device);
assertEquals(FHIRValidationUtil.countErrors(issues), 2);
assertEquals(FHIRValidationUtil.countWarnings(issues), 1);
assertEquals(FHIRValidationUtil.countInformation(issues), 1);
assertEquals(FHIRValidationUtil.countWarnings(issues), 0);
assertEquals(FHIRValidationUtil.countInformation(issues), 2);

// Warning for test-language-secondary-extension
device = buildDevice().toBuilder()
.extension(Collections.singletonList(Extension.builder().url("http://ibm.com/fhir/StructureDefinition/test-language-secondary-extension")
.value(Coding.builder().system(Uri.of(ValidationSupport.BCP_47_URN)).code(Code.of("tlh")).build()).build())).build();
issues = FHIRValidator.validator().validate(device);
assertEquals(FHIRValidationUtil.countErrors(issues), 0);
assertEquals(FHIRValidationUtil.countWarnings(issues), 2);
assertEquals(FHIRValidationUtil.countWarnings(issues), 0);
assertEquals(FHIRValidationUtil.countInformation(issues), 2);

// Error for test-language-secondary-extension
device = buildDevice().toBuilder()
.extension(Collections.singletonList(Extension.builder().url("http://ibm.com/fhir/StructureDefinition/test-language-secondary-extension")
.value(Coding.builder().system(Uri.of(ValidationSupport.BCP_47_URN)).code(Code.of("invalidLanguage")).build()).build())).build();
issues = FHIRValidator.validator().validate(device);
assertEquals(FHIRValidationUtil.countErrors(issues), 2);
assertEquals(FHIRValidationUtil.countWarnings(issues), 2);
assertEquals(FHIRValidationUtil.countInformation(issues), 1);
assertEquals(FHIRValidationUtil.countWarnings(issues), 0);
assertEquals(FHIRValidationUtil.countInformation(issues), 3);

// Warning for test-language-tertiary-extension
device = buildDevice().toBuilder()
.extension(Collections.singletonList(Extension.builder().url("http://ibm.com/fhir/StructureDefinition/test-language-tertiary-extension")
.value(Code.of("tlh")).build())).build();
issues = FHIRValidator.validator().validate(device);
assertEquals(FHIRValidationUtil.countErrors(issues), 0);
assertEquals(FHIRValidationUtil.countWarnings(issues), 2);
assertEquals(FHIRValidationUtil.countWarnings(issues), 0);
assertEquals(FHIRValidationUtil.countInformation(issues), 2);

// Error for test-language-tertiary-extension
device = buildDevice().toBuilder()
.extension(Collections.singletonList(Extension.builder().url("http://ibm.com/fhir/StructureDefinition/test-language-tertiary-extension")
.value(Code.of("invalidLanguage")).build())).build();
issues = FHIRValidator.validator().validate(device);
System.out.println(issues);
assertEquals(FHIRValidationUtil.countErrors(issues), 2);
assertEquals(FHIRValidationUtil.countWarnings(issues), 2);
assertEquals(FHIRValidationUtil.countWarnings(issues), 0);
assertEquals(FHIRValidationUtil.countInformation(issues), 3);
}

/**
Expand Down

0 comments on commit 73548cf

Please sign in to comment.