Bump core version to 5.2.16 (#2308)
* Bump core library version * Test fix * Build fixes * Some test fixes * One more bit of docs * Build fix * Test fix * Test fix * Docs fix
This commit is contained in:
parent
a538ed571a
commit
14b0688f69
|
@ -32,9 +32,11 @@ import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.function.Supplier;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||||
|
@ -116,15 +118,33 @@ public interface IValidationSupport {
|
||||||
* Loads a resource needed by the validation (a StructureDefinition, or a
|
* Loads a resource needed by the validation (a StructureDefinition, or a
|
||||||
* ValueSet)
|
* ValueSet)
|
||||||
*
|
*
|
||||||
* @param theClass The type of the resource to load
|
* <p>
|
||||||
|
* Note: Since 5.3.0, {@literal theClass} can be {@literal null}
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param theClass The type of the resource to load, or <code>null</code> to return any resource with the given canonical URI
|
||||||
* @param theUri The resource URI
|
* @param theUri The resource URI
|
||||||
* @return Returns the resource, or <code>null</code> if no resource with the
|
* @return Returns the resource, or <code>null</code> if no resource with the
|
||||||
* given URI can be found
|
* given URI can be found
|
||||||
*/
|
*/
|
||||||
default <T extends IBaseResource> T fetchResource(Class<T> theClass, String theUri) {
|
@SuppressWarnings("unchecked")
|
||||||
Validate.notNull(theClass, "theClass must not be null or blank");
|
default <T extends IBaseResource> T fetchResource(@Nullable Class<T> theClass, String theUri) {
|
||||||
Validate.notBlank(theUri, "theUri must not be null or blank");
|
Validate.notBlank(theUri, "theUri must not be null or blank");
|
||||||
|
|
||||||
|
if (theClass == null) {
|
||||||
|
Supplier<IBaseResource>[] sources = new Supplier[]{
|
||||||
|
() -> fetchStructureDefinition(theUri),
|
||||||
|
() -> fetchValueSet(theUri),
|
||||||
|
() -> fetchCodeSystem(theUri)
|
||||||
|
};
|
||||||
|
return (T) Arrays
|
||||||
|
.stream(sources)
|
||||||
|
.map(t -> t.get())
|
||||||
|
.filter(t -> t != null)
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
switch (getFhirContext().getResourceType(theClass)) {
|
switch (getFhirContext().getResourceType(theClass)) {
|
||||||
case "StructureDefinition":
|
case "StructureDefinition":
|
||||||
return theClass.cast(fetchStructureDefinition(theUri));
|
return theClass.cast(fetchStructureDefinition(theUri));
|
||||||
|
@ -249,6 +269,25 @@ public interface IValidationSupport {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
enum IssueSeverity {
|
||||||
|
/**
|
||||||
|
* The issue caused the action to fail, and no further checking could be performed.
|
||||||
|
*/
|
||||||
|
FATAL,
|
||||||
|
/**
|
||||||
|
* The issue is sufficiently important to cause the action to fail.
|
||||||
|
*/
|
||||||
|
ERROR,
|
||||||
|
/**
|
||||||
|
* The issue is not important enough to cause the action to fail, but may cause it to be performed suboptimally or in a way that is not as desired.
|
||||||
|
*/
|
||||||
|
WARNING,
|
||||||
|
/**
|
||||||
|
* The issue has no relation to the degree of success of the action.
|
||||||
|
*/
|
||||||
|
INFORMATION
|
||||||
|
}
|
||||||
|
|
||||||
class ConceptDesignation {
|
class ConceptDesignation {
|
||||||
private String myLanguage;
|
private String myLanguage;
|
||||||
private String myUseSystem;
|
private String myUseSystem;
|
||||||
|
@ -365,25 +404,6 @@ public interface IValidationSupport {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum IssueSeverity {
|
|
||||||
/**
|
|
||||||
* The issue caused the action to fail, and no further checking could be performed.
|
|
||||||
*/
|
|
||||||
FATAL,
|
|
||||||
/**
|
|
||||||
* The issue is sufficiently important to cause the action to fail.
|
|
||||||
*/
|
|
||||||
ERROR,
|
|
||||||
/**
|
|
||||||
* The issue is not important enough to cause the action to fail, but may cause it to be performed suboptimally or in a way that is not as desired.
|
|
||||||
*/
|
|
||||||
WARNING,
|
|
||||||
/**
|
|
||||||
* The issue has no relation to the degree of success of the action.
|
|
||||||
*/
|
|
||||||
INFORMATION
|
|
||||||
}
|
|
||||||
|
|
||||||
class CodeValidationResult {
|
class CodeValidationResult {
|
||||||
private String myCode;
|
private String myCode;
|
||||||
private String myMessage;
|
private String myMessage;
|
||||||
|
|
|
@ -66,6 +66,9 @@ public class ChangelogFilesTest {
|
||||||
// this one is optional
|
// this one is optional
|
||||||
boolean haveIssue = fieldNames.remove("issue");
|
boolean haveIssue = fieldNames.remove("issue");
|
||||||
|
|
||||||
|
// this one is optional
|
||||||
|
fieldNames.remove("backport");
|
||||||
|
|
||||||
assertThat("Invalid element in " + next + ": " + fieldNames, fieldNames, empty());
|
assertThat("Invalid element in " + next + ": " + fieldNames, fieldNames, empty());
|
||||||
|
|
||||||
if (haveIssue) {
|
if (haveIssue) {
|
||||||
|
|
|
@ -46,9 +46,12 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
import javax.transaction.Transactional;
|
import javax.transaction.Transactional;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import static org.apache.commons.lang3.StringUtils.isBlank;
|
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||||
|
|
||||||
|
@ -104,13 +107,36 @@ public class JpaPersistedResourceValidationSupport implements IValidationSupport
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings({"unchecked", "unused"})
|
@SuppressWarnings({"unchecked", "unused"})
|
||||||
public <T extends IBaseResource> T fetchResource(Class<T> theClass, String theUri) {
|
public <T extends IBaseResource> T fetchResource(@Nullable Class<T> theClass, String theUri) {
|
||||||
if (isBlank(theUri)) {
|
if (isBlank(theUri)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
String key = theClass.getSimpleName() + " " + theUri;
|
String key = theClass + " " + theUri;
|
||||||
IBaseResource fetched = myLoadCache.get(key, t -> {
|
IBaseResource fetched = myLoadCache.get(key, t -> doFetchResource(theClass, theUri));
|
||||||
|
|
||||||
|
if (fetched == myNoMatch) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (T) fetched;
|
||||||
|
}
|
||||||
|
|
||||||
|
private <T extends IBaseResource> IBaseResource doFetchResource(@Nullable Class<T> theClass, String theUri) {
|
||||||
|
if (theClass == null) {
|
||||||
|
Supplier<IBaseResource>[] fetchers = new Supplier[]{
|
||||||
|
() -> doFetchResource(ValueSet.class, theUri),
|
||||||
|
() -> doFetchResource(CodeSystem.class, theUri),
|
||||||
|
() -> doFetchResource(StructureDefinition.class, theUri)
|
||||||
|
};
|
||||||
|
return Arrays
|
||||||
|
.stream(fetchers)
|
||||||
|
.map(t -> t.get())
|
||||||
|
.filter(t -> t != myNoMatch)
|
||||||
|
.findFirst()
|
||||||
|
.orElse(myNoMatch);
|
||||||
|
}
|
||||||
|
|
||||||
IdType id = new IdType(theUri);
|
IdType id = new IdType(theUri);
|
||||||
boolean localReference = false;
|
boolean localReference = false;
|
||||||
if (id.hasBaseUrl() == false && id.hasIdPart() == true) {
|
if (id.hasBaseUrl() == false && id.hasIdPart() == true) {
|
||||||
|
@ -207,13 +233,6 @@ public class JpaPersistedResourceValidationSupport implements IValidationSupport
|
||||||
}
|
}
|
||||||
|
|
||||||
return search.getResources(0, 1).get(0);
|
return search.getResources(0, 1).get(0);
|
||||||
});
|
|
||||||
|
|
||||||
if (fetched == myNoMatch) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (T) fetched;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -32,13 +32,13 @@ import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||||
import org.hl7.fhir.r4.model.IdType;
|
import org.hl7.fhir.r4.model.IdType;
|
||||||
import org.hl7.fhir.r5.elementmodel.Element;
|
import org.hl7.fhir.r5.elementmodel.Element;
|
||||||
import org.hl7.fhir.r5.elementmodel.JsonParser;
|
import org.hl7.fhir.r5.elementmodel.JsonParser;
|
||||||
|
import org.hl7.fhir.r5.model.CanonicalResource;
|
||||||
import org.hl7.fhir.r5.utils.IResourceValidator;
|
import org.hl7.fhir.r5.utils.IResourceValidator;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
public class ValidatorResourceFetcher implements IResourceValidator.IValidatorResourceFetcher {
|
public class ValidatorResourceFetcher implements IResourceValidator.IValidatorResourceFetcher {
|
||||||
|
@ -61,7 +61,6 @@ public class ValidatorResourceFetcher implements IResourceValidator.IValidatorRe
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("ConstantConditions")
|
|
||||||
@Override
|
@Override
|
||||||
public Element fetch(Object appContext, String theUrl) throws FHIRException {
|
public Element fetch(Object appContext, String theUrl) throws FHIRException {
|
||||||
|
|
||||||
|
@ -94,13 +93,13 @@ public class ValidatorResourceFetcher implements IResourceValidator.IValidatorRe
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean resolveURL(Object appContext, String path, String url) throws IOException, FHIRException {
|
public boolean resolveURL(Object appContext, String path, String url, String type) throws FHIRException {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte[] fetchRaw(String url) throws IOException {
|
public byte[] fetchRaw(String url) {
|
||||||
return new byte[0];
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -108,4 +107,14 @@ public class ValidatorResourceFetcher implements IResourceValidator.IValidatorRe
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CanonicalResource fetchCanonicalResource(String url) {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean fetchesCanonicalResource(String url) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,7 +144,7 @@ public class FhirResourceDaoDstu2ValidateTest extends BaseJpaDstu2Test {
|
||||||
} catch (PreconditionFailedException e) {
|
} catch (PreconditionFailedException e) {
|
||||||
String ooString = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome());
|
String ooString = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome());
|
||||||
ourLog.info(ooString);
|
ourLog.info(ooString);
|
||||||
assertThat(ooString, containsString("Profile reference 'http://example.com/StructureDefinition/testValidateResourceContainingProfileDeclarationInvalid' could not be resolved, so has not been checked"));
|
assertThat(ooString, containsString("Profile reference 'http://example.com/StructureDefinition/testValidateResourceContainingProfileDeclarationInvalid' has not been checked because it is unknown"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -333,7 +333,7 @@ public class FhirResourceDaoDstu3ValidateTest extends BaseJpaDstu3Test {
|
||||||
OperationOutcome oo = (OperationOutcome) e.getOperationOutcome();
|
OperationOutcome oo = (OperationOutcome) e.getOperationOutcome();
|
||||||
String outputString = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo);
|
String outputString = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo);
|
||||||
ourLog.info(outputString);
|
ourLog.info(outputString);
|
||||||
assertThat(outputString, containsString("Profile reference 'http://example.com/StructureDefinition/testValidateResourceContainingProfileDeclarationInvalid' could not be resolved, so has not been checked"));
|
assertThat(outputString, containsString("Profile reference 'http://example.com/StructureDefinition/testValidateResourceContainingProfileDeclarationInvalid' has not been checked because it is unknown"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1138,7 +1138,7 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test {
|
||||||
org.hl7.fhir.r4.model.OperationOutcome oo = (org.hl7.fhir.r4.model.OperationOutcome) e.getOperationOutcome();
|
org.hl7.fhir.r4.model.OperationOutcome oo = (org.hl7.fhir.r4.model.OperationOutcome) e.getOperationOutcome();
|
||||||
String outputString = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo);
|
String outputString = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo);
|
||||||
ourLog.info(outputString);
|
ourLog.info(outputString);
|
||||||
assertThat(outputString, containsString("Profile reference 'http://example.com/StructureDefinition/testValidateResourceContainingProfileDeclarationInvalid' could not be resolved, so has not been checked"));
|
assertThat(outputString, containsString("Profile reference 'http://example.com/StructureDefinition/testValidateResourceContainingProfileDeclarationInvalid' has not been checked because it is unknown"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1174,7 +1174,7 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test {
|
||||||
org.hl7.fhir.r4.model.OperationOutcome oo = (org.hl7.fhir.r4.model.OperationOutcome) e.getOperationOutcome();
|
org.hl7.fhir.r4.model.OperationOutcome oo = (org.hl7.fhir.r4.model.OperationOutcome) e.getOperationOutcome();
|
||||||
String outputString = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo);
|
String outputString = myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(oo);
|
||||||
ourLog.info(outputString);
|
ourLog.info(outputString);
|
||||||
assertThat(outputString, containsString("Profile reference 'http://example.com/StructureDefinition/testValidateResourceContainingProfileDeclarationInvalid' could not be resolved, so has not been checked"));
|
assertThat(outputString, containsString("Profile reference 'http://example.com/StructureDefinition/testValidateResourceContainingProfileDeclarationInvalid' has not been checked because it is unknown"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2403,7 +2403,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
||||||
String respString = IOUtils.toString(resp.getEntity().getContent(), Charsets.UTF_8);
|
String respString = IOUtils.toString(resp.getEntity().getContent(), Charsets.UTF_8);
|
||||||
ourLog.info(respString);
|
ourLog.info(respString);
|
||||||
assertEquals(412, resp.getStatusLine().getStatusCode());
|
assertEquals(412, resp.getStatusLine().getStatusCode());
|
||||||
assertThat(respString, containsString("Profile reference 'http://foo/structuredefinition/myprofile' could not be resolved, so has not been checked"));
|
assertThat(respString, containsString("Profile reference 'http://foo/structuredefinition/myprofile' has not been checked because it is unknown"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ import org.apache.http.client.methods.CloseableHttpResponse;
|
||||||
import org.apache.http.client.methods.HttpGet;
|
import org.apache.http.client.methods.HttpGet;
|
||||||
import org.apache.http.impl.client.CloseableHttpClient;
|
import org.apache.http.impl.client.CloseableHttpClient;
|
||||||
import org.hl7.fhir.instance.model.api.IIdType;
|
import org.hl7.fhir.instance.model.api.IIdType;
|
||||||
|
import org.hl7.fhir.r4.model.Coding;
|
||||||
import org.hl7.fhir.r4.model.Patient;
|
import org.hl7.fhir.r4.model.Patient;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
@ -95,6 +96,19 @@ public class FhirPathFilterInterceptorTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFilteredResponse_ExpressionReturnsExtension() throws IOException {
|
||||||
|
createPatient();
|
||||||
|
|
||||||
|
HttpGet request = new HttpGet(myPatientId + "?_fhirpath=Patient.extension('http://hl7.org/fhir/us/core/StructureDefinition/us-core-race')&_pretty=true");
|
||||||
|
try (CloseableHttpResponse response = myHttpClient.execute(request)) {
|
||||||
|
String responseText = IOUtils.toString(response.getEntity().getContent(), Charsets.UTF_8);
|
||||||
|
ourLog.info("Response:\n{}", responseText);
|
||||||
|
assertThat(responseText, containsString("\"url\": \"http://hl7.org/fhir/us/core/StructureDefinition/us-core-race\""));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testFilteredResponse_ExpressionReturnsResource() throws IOException {
|
public void testFilteredResponse_ExpressionReturnsResource() throws IOException {
|
||||||
createPatient();
|
createPatient();
|
||||||
|
@ -159,6 +173,11 @@ public class FhirPathFilterInterceptorTest {
|
||||||
|
|
||||||
private void createPatient() {
|
private void createPatient() {
|
||||||
Patient p = new Patient();
|
Patient p = new Patient();
|
||||||
|
p.addExtension()
|
||||||
|
.setUrl("http://hl7.org/fhir/us/core/StructureDefinition/us-core-race")
|
||||||
|
.addExtension()
|
||||||
|
.setUrl("ombCategory")
|
||||||
|
.setValue(new Coding("urn:oid:2.16.840.1.113883.6.238", "2106-3", "White"));
|
||||||
p.setActive(true);
|
p.setActive(true);
|
||||||
p.addIdentifier().setSystem("http://identifiers/1").setValue("value-1");
|
p.addIdentifier().setSystem("http://identifiers/1").setValue("value-1");
|
||||||
p.addIdentifier().setSystem("http://identifiers/2").setValue("value-2");
|
p.addIdentifier().setSystem("http://identifiers/2").setValue("value-2");
|
||||||
|
|
|
@ -287,6 +287,11 @@ public final class HapiWorkerContext extends I18nBase implements IWorkerContext
|
||||||
return myCtx.getVersion().getVersion().getFhirVersionString();
|
return myCtx.getVersion().getVersion().getFhirVersionString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSpecUrl() {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UcumService getUcumService() {
|
public UcumService getUcumService() {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
|
@ -302,6 +307,11 @@ public final class HapiWorkerContext extends I18nBase implements IWorkerContext
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<String> getCodeSystemsUsed() {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TranslationServices translator() {
|
public TranslationServices translator() {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
|
|
|
@ -6,14 +6,13 @@ import ca.uhn.fhir.context.support.IValidationSupport;
|
||||||
import ca.uhn.fhir.context.support.ValidationSupportContext;
|
import ca.uhn.fhir.context.support.ValidationSupportContext;
|
||||||
import com.github.benmanes.caffeine.cache.Cache;
|
import com.github.benmanes.caffeine.cache.Cache;
|
||||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
|
||||||
import org.hl7.fhir.instance.model.api.IBase;
|
|
||||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
@ -64,8 +63,8 @@ public class CachingValidationSupport extends BaseValidationSupportWrapper imple
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T extends IBaseResource> T fetchResource(Class<T> theClass, String theUri) {
|
public <T extends IBaseResource> T fetchResource(@Nullable Class<T> theClass, String theUri) {
|
||||||
return loadFromCache(myCache, "fetchResource " + theClass.getName() + " " + theUri,
|
return loadFromCache(myCache, "fetchResource " + theClass + " " + theUri,
|
||||||
t -> super.fetchResource(theClass, theUri));
|
t -> super.fetchResource(theClass, theUri));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ public class FhirInstanceValidator extends BaseValidatorBridge implements IInsta
|
||||||
private boolean noExtensibleWarnings = false;
|
private boolean noExtensibleWarnings = false;
|
||||||
private boolean noBindingMsgSuppressed = false;
|
private boolean noBindingMsgSuppressed = false;
|
||||||
private volatile VersionSpecificWorkerContextWrapper myWrappedWorkerContext;
|
private volatile VersionSpecificWorkerContextWrapper myWrappedWorkerContext;
|
||||||
private boolean errorForUnknownProfiles;
|
private boolean errorForUnknownProfiles = true;
|
||||||
private boolean assumeValidRestReferences;
|
private boolean assumeValidRestReferences;
|
||||||
private List<String> myExtensionDomains = Collections.emptyList();
|
private List<String> myExtensionDomains = Collections.emptyList();
|
||||||
private IResourceValidator.IValidatorResourceFetcher validatorResourceFetcher;
|
private IResourceValidator.IValidatorResourceFetcher validatorResourceFetcher;
|
||||||
|
|
|
@ -61,6 +61,9 @@ public class HapiToHl7OrgDstu2ValidatingSupportWrapper extends BaseValidationSup
|
||||||
}
|
}
|
||||||
|
|
||||||
private Class<? extends IBaseResource> translateTypeToHapi(Class<? extends IBaseResource> theCodeSystemType) {
|
private Class<? extends IBaseResource> translateTypeToHapi(Class<? extends IBaseResource> theCodeSystemType) {
|
||||||
|
if (theCodeSystemType == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
String resName = getFhirContext().getResourceType(theCodeSystemType);
|
String resName = getFhirContext().getResourceType(theCodeSystemType);
|
||||||
return myHapiCtx.getResourceDefinition(resName).getImplementingClass();
|
return myHapiCtx.getResourceDefinition(resName).getImplementingClass();
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ import org.hl7.fhir.r5.elementmodel.Manager;
|
||||||
import org.hl7.fhir.r5.model.StructureDefinition;
|
import org.hl7.fhir.r5.model.StructureDefinition;
|
||||||
import org.hl7.fhir.r5.utils.FHIRPathEngine;
|
import org.hl7.fhir.r5.utils.FHIRPathEngine;
|
||||||
import org.hl7.fhir.r5.utils.IResourceValidator;
|
import org.hl7.fhir.r5.utils.IResourceValidator;
|
||||||
|
import org.hl7.fhir.r5.utils.XVerExtensionManager;
|
||||||
import org.hl7.fhir.utilities.validation.ValidationMessage;
|
import org.hl7.fhir.utilities.validation.ValidationMessage;
|
||||||
import org.hl7.fhir.validation.instance.InstanceValidator;
|
import org.hl7.fhir.validation.instance.InstanceValidator;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -103,8 +104,9 @@ class ValidatorWrapper {
|
||||||
public List<ValidationMessage> validate(IWorkerContext theWorkerContext, IValidationContext<?> theValidationContext) {
|
public List<ValidationMessage> validate(IWorkerContext theWorkerContext, IValidationContext<?> theValidationContext) {
|
||||||
InstanceValidator v;
|
InstanceValidator v;
|
||||||
FHIRPathEngine.IEvaluationContext evaluationCtx = new FhirInstanceValidator.NullEvaluationContext();
|
FHIRPathEngine.IEvaluationContext evaluationCtx = new FhirInstanceValidator.NullEvaluationContext();
|
||||||
|
XVerExtensionManager xverManager = new XVerExtensionManager(theWorkerContext);
|
||||||
try {
|
try {
|
||||||
v = new InstanceValidator(theWorkerContext, evaluationCtx);
|
v = new InstanceValidator(theWorkerContext, evaluationCtx, xverManager);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ConfigurationException(e);
|
throw new ConfigurationException(e);
|
||||||
}
|
}
|
||||||
|
@ -193,7 +195,12 @@ class ValidatorWrapper {
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message.endsWith("' could not be resolved, so has not been checked") && next.getLevel() == ValidationMessage.IssueSeverity.WARNING) {
|
if (
|
||||||
|
myErrorForUnknownProfiles &&
|
||||||
|
next.getLevel() == ValidationMessage.IssueSeverity.WARNING &&
|
||||||
|
message.contains("Profile reference '") &&
|
||||||
|
message.contains("' has not been checked because it is unknown")
|
||||||
|
) {
|
||||||
next.setLevel(ValidationMessage.IssueSeverity.ERROR);
|
next.setLevel(ValidationMessage.IssueSeverity.ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,13 +81,15 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo
|
||||||
fetchResourceName = "ValueSet";
|
fetchResourceName = "ValueSet";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Class<? extends IBaseResource> fetchResourceType = myValidationSupportContext.getRootValidationSupport().getFhirContext().getResourceDefinition(fetchResourceName).getImplementingClass();
|
|
||||||
IBaseResource fetched = myValidationSupportContext.getRootValidationSupport().fetchResource(fetchResourceType, key.getUri());
|
|
||||||
|
|
||||||
if (fetched == null) {
|
Class<? extends IBaseResource> fetchResourceType;
|
||||||
return null;
|
if (fetchResourceName.equals("Resource")) {
|
||||||
|
fetchResourceType = null;
|
||||||
|
} else {
|
||||||
|
fetchResourceType = myValidationSupportContext.getRootValidationSupport().getFhirContext().getResourceDefinition(fetchResourceName).getImplementingClass();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IBaseResource fetched = myValidationSupportContext.getRootValidationSupport().fetchResource(fetchResourceType, key.getUri());
|
||||||
|
|
||||||
Resource canonical = myModelConverter.toCanonical(fetched);
|
Resource canonical = myModelConverter.toCanonical(fetched);
|
||||||
|
|
||||||
|
@ -425,6 +427,11 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo
|
||||||
return myValidationSupportContext.getRootValidationSupport().getFhirContext().getVersion().getVersion().getFhirVersionString();
|
return myValidationSupportContext.getRootValidationSupport().getFhirContext().getVersion().getVersion().getFhirVersionString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSpecUrl() {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasCache() {
|
public boolean hasCache() {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
|
@ -440,6 +447,11 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<String> getCodeSystemsUsed() {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<org.hl7.fhir.r5.model.StructureMap> listTransforms() {
|
public List<org.hl7.fhir.r5.model.StructureMap> listTransforms() {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
|
|
|
@ -664,6 +664,8 @@ public class FhirInstanceValidatorDstu3Test {
|
||||||
} else if (t.getMessage().contains("ValueSet as a URI SHALL start with http:// or https:// or urn:")) {
|
} else if (t.getMessage().contains("ValueSet as a URI SHALL start with http:// or https:// or urn:")) {
|
||||||
// Some DSTU3 structures have missing binding information
|
// Some DSTU3 structures have missing binding information
|
||||||
return false;
|
return false;
|
||||||
|
} else if (t.getMessage().contains("The valueSet reference http://www.rfc-editor.org/bcp/bcp13.txt on element")) {
|
||||||
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1135,7 +1137,7 @@ public class FhirInstanceValidatorDstu3Test {
|
||||||
myInstanceVal.setValidationSupport(myValidationSupport);
|
myInstanceVal.setValidationSupport(myValidationSupport);
|
||||||
ValidationResult output = myVal.validateWithResult(input);
|
ValidationResult output = myVal.validateWithResult(input);
|
||||||
List<SingleValidationMessage> errors = logResultsAndReturnNonInformationalOnes(output);
|
List<SingleValidationMessage> errors = logResultsAndReturnNonInformationalOnes(output);
|
||||||
assertThat(errors.toString(), containsString("Profile reference 'http://foo/structuredefinition/myprofile' could not be resolved, so has not been checked"));
|
assertThat(errors.toString(), containsString("Profile reference 'http://foo/structuredefinition/myprofile' has not been checked because it is unknown"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -1314,7 +1316,7 @@ public class FhirInstanceValidatorDstu3Test {
|
||||||
myInstanceVal.setValidatorResourceFetcher(resourceFetcher);
|
myInstanceVal.setValidatorResourceFetcher(resourceFetcher);
|
||||||
myVal.validateWithResult(input);
|
myVal.validateWithResult(input);
|
||||||
|
|
||||||
verify(resourceFetcher, times(3)).resolveURL(any(), anyString(), anyString());
|
verify(resourceFetcher, times(3)).resolveURL(any(), anyString(), anyString(), anyString());
|
||||||
verify(resourceFetcher, times(4)).validationPolicy(any(), anyString(), anyString());
|
verify(resourceFetcher, times(4)).validationPolicy(any(), anyString(), anyString());
|
||||||
verify(resourceFetcher, times(4)).fetch(any(), anyString());
|
verify(resourceFetcher, times(4)).fetch(any(), anyString());
|
||||||
}
|
}
|
||||||
|
|
|
@ -254,7 +254,7 @@ public class QuestionnaireResponseValidatorDstu3Test {
|
||||||
errors = myVal.validateWithResult(qa);
|
errors = myVal.validateWithResult(qa);
|
||||||
errors = stripBindingHasNoSourceMessage(errors);
|
errors = stripBindingHasNoSourceMessage(errors);
|
||||||
ourLog.info(errors.toString());
|
ourLog.info(errors.toString());
|
||||||
assertThat(errors.toString(), containsString("Unknown code: http://codesystems.com/system / code1 - QuestionnaireResponse.item[0].answer[0].value.ofType(Coding)"));
|
assertThat(errors.toString(), containsString("Unknown code: http://codesystems.com/system / code1 for 'http://codesystems.com/system#code1'"));
|
||||||
assertThat(errors.toString(), containsString("QuestionnaireResponse.item[0].answer[0]"));
|
assertThat(errors.toString(), containsString("QuestionnaireResponse.item[0].answer[0]"));
|
||||||
|
|
||||||
// Unhandled system
|
// Unhandled system
|
||||||
|
|
|
@ -1152,7 +1152,7 @@ public class FhirInstanceValidatorR4Test extends BaseTest {
|
||||||
List<SingleValidationMessage> errors = logResultsAndReturnNonInformationalOnes(output);
|
List<SingleValidationMessage> errors = logResultsAndReturnNonInformationalOnes(output);
|
||||||
|
|
||||||
assertEquals(1, errors.size());
|
assertEquals(1, errors.size());
|
||||||
assertEquals("Profile reference 'http://foo/structuredefinition/myprofile' could not be resolved, so has not been checked", errors.get(0).getMessage());
|
assertEquals("Profile reference 'http://foo/structuredefinition/myprofile' has not been checked because it is unknown", errors.get(0).getMessage());
|
||||||
assertEquals(ResultSeverityEnum.ERROR, errors.get(0).getSeverity());
|
assertEquals(ResultSeverityEnum.ERROR, errors.get(0).getSeverity());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1402,7 +1402,7 @@ public class FhirInstanceValidatorR4Test extends BaseTest {
|
||||||
myInstanceVal.setValidatorResourceFetcher(resourceFetcher);
|
myInstanceVal.setValidatorResourceFetcher(resourceFetcher);
|
||||||
myVal.validateWithResult(encoded);
|
myVal.validateWithResult(encoded);
|
||||||
|
|
||||||
verify(resourceFetcher, times(15)).resolveURL(any(), anyString(), anyString());
|
verify(resourceFetcher, times(15)).resolveURL(any(), anyString(), anyString(), anyString());
|
||||||
verify(resourceFetcher, times(12)).validationPolicy(any(), anyString(), anyString());
|
verify(resourceFetcher, times(12)).validationPolicy(any(), anyString(), anyString());
|
||||||
verify(resourceFetcher, times(12)).fetch(any(), anyString());
|
verify(resourceFetcher, times(12)).fetch(any(), anyString());
|
||||||
}
|
}
|
||||||
|
|
|
@ -432,8 +432,8 @@ public class FhirInstanceValidatorR5Test {
|
||||||
myInstanceVal.setValidatorResourceFetcher(resourceFetcher);
|
myInstanceVal.setValidatorResourceFetcher(resourceFetcher);
|
||||||
myVal.validateWithResult(input);
|
myVal.validateWithResult(input);
|
||||||
|
|
||||||
verify(resourceFetcher, times(13)).resolveURL(any(), anyString(), anyString());
|
verify(resourceFetcher, times(13)).resolveURL(any(), anyString(), anyString(), anyString());
|
||||||
verify(resourceFetcher, times(3)).validationPolicy(any(), anyString(), anyString());
|
verify(resourceFetcher, times(4)).validationPolicy(any(), anyString(), anyString());
|
||||||
verify(resourceFetcher, times(3)).fetch(any(), anyString());
|
verify(resourceFetcher, times(3)).fetch(any(), anyString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -794,7 +794,7 @@ public class FhirInstanceValidatorR5Test {
|
||||||
myInstanceVal.setValidationSupport(myValidationSupport);
|
myInstanceVal.setValidationSupport(myValidationSupport);
|
||||||
ValidationResult output = myVal.validateWithResult(input);
|
ValidationResult output = myVal.validateWithResult(input);
|
||||||
List<SingleValidationMessage> errors = logResultsAndReturnNonInformationalOnes(output);
|
List<SingleValidationMessage> errors = logResultsAndReturnNonInformationalOnes(output);
|
||||||
assertThat(errors.toString(), containsString("Profile reference 'http://foo/structuredefinition/myprofile' could not be resolved, so has not been checked"));
|
assertThat(errors.toString(), containsString("Profile reference 'http://foo/structuredefinition/myprofile' has not been checked because it is unknown"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
2
pom.xml
2
pom.xml
|
@ -712,7 +712,7 @@
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
|
||||||
<fhir_core_version>5.2.0</fhir_core_version>
|
<fhir_core_version>5.2.16</fhir_core_version>
|
||||||
<ucum_version>1.0.3</ucum_version>
|
<ucum_version>1.0.3</ucum_version>
|
||||||
|
|
||||||
<surefire_jvm_args>-Dfile.encoding=UTF-8 -Xmx2048m</surefire_jvm_args>
|
<surefire_jvm_args>-Dfile.encoding=UTF-8 -Xmx2048m</surefire_jvm_args>
|
||||||
|
|
Loading…
Reference in New Issue