FHIR Chat · 5.1.0 FhirInstanceValidator not allowing unknown profiles · hapi

Stream: hapi

Topic: 5.1.0 FhirInstanceValidator not allowing unknown profiles


view this post on Zulip Juuso Oksanen (Sep 29 2020 at 11:09):

Hi.

We ran to an issue where the FhirInstanceValidator (and by proxy ValidatorWrapper and InstanceValidator) always considers an unknown profile reference as IssueType.ERROR.

The following culprit seems to be the lines 182-184 in the ValidatorWrapper-class:

        if (message.endsWith("' could not be resolved, so has not been checked") && next.getLevel() == ValidationMessage.IssueSeverity.WARNING) {
            next.setLevel(ValidationMessage.IssueSeverity.ERROR);
        }

FhirInstanceValidator has a method we can use in the registration process called setErrorForUnknownProfiles(boolean errorForUnknownProfiles), but this set boolean is not accessed or referred anywhere in the business logic of the FhirInstanceValidator/ValidatorWrapper/InstanceValidator-class. The boolean is simply set as a value for the new instance of ValidatorWrapper and InstanceValidator.

I believe I can deal with this error by handling this validation result specifically after all the validations have been run.

However, is this behavior intended for the FhirInstanceValidator?

view this post on Zulip Eeva Turkka (Oct 13 2020 at 08:36):

I wrote a junit test for this, and as you say it looks like the setErrorForUknownProfiles doesn't seem to do anything, the test fails with the profile error.

@Test
public void validateResource() throws  IOException {

    FhirContext r4Context = FhirContext.forR4();

    FhirValidator validator = new FhirValidator(r4Context);

    ValidationSupportChain validationSupportChain = new ValidationSupportChain(
        new DefaultProfileValidationSupport(r4Context),
        new InMemoryTerminologyServerValidationSupport(r4Context),
        new CommonCodeSystemsTerminologyService(r4Context),
        new SnapshotGeneratingValidationSupport(r4Context));

    FhirInstanceValidator instanceValidator = new FhirInstanceValidator(validationSupportChain);
    validator.registerValidatorModule(instanceValidator);
    instanceValidator.setErrorForUnknownProfiles(false);

    ValidationResult res = validator.validateWithResult(new  Observation().setStatus(ObservationStatus.FINAL).setCode(new CodeableConcept(new Coding("baz", "baa", "123"))).setMeta(new Meta().addProfile("http://foobar")));

    assertEquals("Profile reference 'http://foobar' could not be resolved, so has not been checked", res.getMessages().get(0));
    assertEquals(1, res.getMessages().size());
    assertTrue(res.isSuccessful());
}

view this post on Zulip Ken Sinn (Feb 24 2021 at 16:17):

Wondering if there have been any updates on this, and whether there is a way to circumvent errors being thrown for unknown/unresolvable profile URLs during validation. Does this behaviour also apply for unknown/unresolvable extension URLs?


Last updated: Apr 12 2022 at 19:14 UTC