From 89de2b1068d7542a85ead429f5b6abd9fc17f0c8 Mon Sep 17 00:00:00 2001 From: dotasek Date: Wed, 13 Dec 2023 17:57:09 -0500 Subject: [PATCH] Bump to core 6.2.6 + fix compilation errors --- .../context/support/IValidationSupport.java | 10 +- .../canonical/VersionCanonicalizer.java | 3 +- .../extractor/SearchParamExtractorDstu3.java | 2 +- .../extractor/SearchParamExtractorR4.java | 38 +++++-- .../extractor/SearchParamExtractorR4B.java | 38 +++++-- .../extractor/SearchParamExtractorR5.java | 43 +++++-- hapi-fhir-server-mdm/pom.xml | 6 + .../dstu3/hapi/ctx/HapiWorkerContext.java | 7 +- .../dstu3/hapi/fluentpath/FhirPathDstu3.java | 8 +- .../fhir/r4/hapi/ctx/HapiWorkerContext.java | 33 ++++++ .../fhir/r4/hapi/fluentpath/FhirPathR4.java | 44 +++++--- .../fhir/r4b/hapi/fhirpath/FhirPathR4B.java | 44 +++++--- .../fhir/r5/hapi/ctx/HapiWorkerContext.java | 98 +++++++++++++++- .../hl7/fhir/r5/hapi/fhirpath/FhirPathR5.java | 49 +++++--- ...oryTerminologyServerValidationSupport.java | 2 +- .../FHIRPathResourceGeneratorR4.java | 4 +- .../validator/FhirInstanceValidator.java | 41 +++++-- .../validator/ValidatorWrapper.java | 2 +- .../VersionSpecificWorkerContextWrapper.java | 106 +++++++++++++++++- .../FhirInstanceValidatorDstu3Test.java | 2 +- .../fhir/dstu3/utils/FhirPathEngineTest.java | 2 +- .../fhir/r4/utils/FhirPathEngineR4Test.java | 1 + .../FhirInstanceValidatorR4Test.java | 2 +- .../r4/validation/HapiWorkerContextTest.java | 4 +- .../FhirInstanceValidatorR4BTest.java | 2 +- pom.xml | 2 +- 26 files changed, 486 insertions(+), 107 deletions(-) diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/support/IValidationSupport.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/support/IValidationSupport.java index 967aeb3a549..da3b4165e32 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/support/IValidationSupport.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/support/IValidationSupport.java @@ -747,14 +747,18 @@ public interface IValidationSupport { private final IBaseResource myValueSet; private final String myError; - public ValueSetExpansionOutcome(String theError) { + private boolean myErrorIsFromServer; + + public ValueSetExpansionOutcome(String theError, boolean theErrorIsFromServer) { myValueSet = null; myError = theError; + myErrorIsFromServer = theErrorIsFromServer; } public ValueSetExpansionOutcome(IBaseResource theValueSet) { myValueSet = theValueSet; myError = null; + myErrorIsFromServer = false; } public String getError() { @@ -764,6 +768,10 @@ public interface IValidationSupport { public IBaseResource getValueSet() { return myValueSet; } + + public boolean getErrorIsFromServer() { + return myErrorIsFromServer; + } } class LookupCodeResult { diff --git a/hapi-fhir-converter/src/main/java/ca/uhn/hapi/converters/canonical/VersionCanonicalizer.java b/hapi-fhir-converter/src/main/java/ca/uhn/hapi/converters/canonical/VersionCanonicalizer.java index 83941fa05d2..4b531100344 100644 --- a/hapi-fhir-converter/src/main/java/ca/uhn/hapi/converters/canonical/VersionCanonicalizer.java +++ b/hapi-fhir-converter/src/main/java/ca/uhn/hapi/converters/canonical/VersionCanonicalizer.java @@ -250,7 +250,8 @@ public class VersionCanonicalizer { String packageUserData = (String) theResource.getUserData("package"); if (packageUserData != null) { retVal.setUserData("package", packageUserData); - retVal.setSourcePackage(new PackageInformation(packageUserData, new Date())); + retVal.setSourcePackage(new PackageInformation( + packageUserData, theResource.getStructureFhirVersionEnum().getFhirVersionString(), new Date())); } return retVal; } diff --git a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorDstu3.java b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorDstu3.java index f1e87737f5b..a4487d407dd 100644 --- a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorDstu3.java +++ b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorDstu3.java @@ -26,9 +26,9 @@ import ca.uhn.fhir.rest.server.util.ISearchParamRegistry; import com.google.common.annotations.VisibleForTesting; import jakarta.annotation.PostConstruct; import org.hl7.fhir.dstu3.context.IWorkerContext; +import org.hl7.fhir.dstu3.fhirpath.FHIRPathEngine; import org.hl7.fhir.dstu3.hapi.ctx.HapiWorkerContext; import org.hl7.fhir.dstu3.model.Base; -import org.hl7.fhir.dstu3.utils.FHIRPathEngine; import org.hl7.fhir.instance.model.api.IBase; import java.util.ArrayList; diff --git a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorR4.java b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorR4.java index bc82a49e0ca..2d953a0ae50 100644 --- a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorR4.java +++ b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorR4.java @@ -31,16 +31,16 @@ import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.PathEngineException; import org.hl7.fhir.instance.model.api.IBase; import org.hl7.fhir.r4.context.IWorkerContext; +import org.hl7.fhir.r4.fhirpath.ExpressionNode; +import org.hl7.fhir.r4.fhirpath.FHIRPathEngine; +import org.hl7.fhir.r4.fhirpath.FHIRPathUtilityClasses.FunctionDetails; +import org.hl7.fhir.r4.fhirpath.TypeDetails; import org.hl7.fhir.r4.hapi.ctx.HapiWorkerContext; import org.hl7.fhir.r4.model.Base; -import org.hl7.fhir.r4.model.ExpressionNode; import org.hl7.fhir.r4.model.IdType; import org.hl7.fhir.r4.model.Resource; import org.hl7.fhir.r4.model.ResourceType; -import org.hl7.fhir.r4.model.TypeDetails; import org.hl7.fhir.r4.model.ValueSet; -import org.hl7.fhir.r4.utils.FHIRPathEngine; -import org.hl7.fhir.r4.utils.FHIRPathUtilityClasses.FunctionDetails; import java.util.Collections; import java.util.HashMap; @@ -105,13 +105,16 @@ public class SearchParamExtractorR4 extends BaseSearchParamExtractor implements private final Map myResourceTypeToStub = Collections.synchronizedMap(new HashMap<>()); @Override - public List resolveConstant(Object appContext, String name, boolean beforeContext) + public List resolveConstant( + FHIRPathEngine engine, Object appContext, String name, boolean beforeContext, boolean explicitConstant) throws PathEngineException { return Collections.emptyList(); } @Override - public TypeDetails resolveConstantType(Object appContext, String name) throws PathEngineException { + public TypeDetails resolveConstantType( + FHIRPathEngine engine, Object appContext, String name, boolean explicitConstant) + throws PathEngineException { return null; } @@ -121,24 +124,34 @@ public class SearchParamExtractorR4 extends BaseSearchParamExtractor implements } @Override - public FunctionDetails resolveFunction(String functionName) { + public FunctionDetails resolveFunction(FHIRPathEngine engine, String functionName) { return null; } @Override - public TypeDetails checkFunction(Object appContext, String functionName, List parameters) + public TypeDetails checkFunction( + FHIRPathEngine engine, + Object appContext, + String functionName, + TypeDetails focus, + List parameters) throws PathEngineException { return null; } @Override public List executeFunction( - Object appContext, List focus, String functionName, List> parameters) { + FHIRPathEngine engine, + Object appContext, + List focus, + String functionName, + List> parameters) { return null; } @Override - public Base resolveReference(Object theAppContext, String theUrl, Base theRefContext) throws FHIRException { + public Base resolveReference(FHIRPathEngine engine, Object theAppContext, String theUrl, Base refContext) + throws FHIRException { Base retVal = resolveResourceInBundleWithPlaceholderId(theAppContext, theUrl); if (retVal != null) { return retVal; @@ -186,12 +199,13 @@ public class SearchParamExtractorR4 extends BaseSearchParamExtractor implements } @Override - public boolean conformsToProfile(Object appContext, Base item, String url) throws FHIRException { + public boolean conformsToProfile(FHIRPathEngine engine, Object appContext, Base item, String url) + throws FHIRException { return false; } @Override - public ValueSet resolveValueSet(Object appContext, String url) { + public ValueSet resolveValueSet(FHIRPathEngine engine, Object appContext, String url) { return null; } } diff --git a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorR4B.java b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorR4B.java index 4add6601f1f..6efa62d63ed 100644 --- a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorR4B.java +++ b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorR4B.java @@ -31,16 +31,16 @@ import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.PathEngineException; import org.hl7.fhir.instance.model.api.IBase; import org.hl7.fhir.r4b.context.IWorkerContext; +import org.hl7.fhir.r4b.fhirpath.ExpressionNode; +import org.hl7.fhir.r4b.fhirpath.FHIRPathEngine; +import org.hl7.fhir.r4b.fhirpath.FHIRPathUtilityClasses.FunctionDetails; +import org.hl7.fhir.r4b.fhirpath.TypeDetails; import org.hl7.fhir.r4b.hapi.ctx.HapiWorkerContext; import org.hl7.fhir.r4b.model.Base; -import org.hl7.fhir.r4b.model.ExpressionNode; import org.hl7.fhir.r4b.model.IdType; import org.hl7.fhir.r4b.model.Resource; import org.hl7.fhir.r4b.model.ResourceType; -import org.hl7.fhir.r4b.model.TypeDetails; import org.hl7.fhir.r4b.model.ValueSet; -import org.hl7.fhir.r4b.utils.FHIRPathEngine; -import org.hl7.fhir.r4b.utils.FHIRPathUtilityClasses.FunctionDetails; import java.util.Collections; import java.util.HashMap; @@ -105,13 +105,16 @@ public class SearchParamExtractorR4B extends BaseSearchParamExtractor implements private final Map myResourceTypeToStub = Collections.synchronizedMap(new HashMap<>()); @Override - public List resolveConstant(Object appContext, String name, boolean beforeContext) + public List resolveConstant( + FHIRPathEngine engine, Object appContext, String name, boolean beforeContext, boolean explicitConstant) throws PathEngineException { return Collections.emptyList(); } @Override - public TypeDetails resolveConstantType(Object appContext, String name) throws PathEngineException { + public TypeDetails resolveConstantType( + FHIRPathEngine engine, Object appContext, String name, boolean explicitConstant) + throws PathEngineException { return null; } @@ -121,24 +124,34 @@ public class SearchParamExtractorR4B extends BaseSearchParamExtractor implements } @Override - public FunctionDetails resolveFunction(String functionName) { + public FunctionDetails resolveFunction(FHIRPathEngine engine, String functionName) { return null; } @Override - public TypeDetails checkFunction(Object appContext, String functionName, List parameters) + public TypeDetails checkFunction( + FHIRPathEngine engine, + Object appContext, + String functionName, + TypeDetails focus, + List parameters) throws PathEngineException { return null; } @Override public List executeFunction( - Object appContext, List focus, String functionName, List> parameters) { + FHIRPathEngine engine, + Object appContext, + List focus, + String functionName, + List> parameters) { return null; } @Override - public Base resolveReference(Object theAppContext, String theUrl, Base refContext) throws FHIRException { + public Base resolveReference(FHIRPathEngine engine, Object theAppContext, String theUrl, Base refContext) + throws FHIRException { Base retVal = resolveResourceInBundleWithPlaceholderId(theAppContext, theUrl); if (retVal != null) { return retVal; @@ -186,12 +199,13 @@ public class SearchParamExtractorR4B extends BaseSearchParamExtractor implements } @Override - public boolean conformsToProfile(Object appContext, Base item, String url) throws FHIRException { + public boolean conformsToProfile(FHIRPathEngine engine, Object appContext, Base item, String url) + throws FHIRException { return false; } @Override - public ValueSet resolveValueSet(Object appContext, String url) { + public ValueSet resolveValueSet(FHIRPathEngine engine, Object appContext, String url) { return null; } } diff --git a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorR5.java b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorR5.java index 44625b53a97..2eb8cc71d0c 100644 --- a/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorR5.java +++ b/hapi-fhir-jpaserver-searchparam/src/main/java/ca/uhn/fhir/jpa/searchparam/extractor/SearchParamExtractorR5.java @@ -30,16 +30,16 @@ import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.PathEngineException; import org.hl7.fhir.instance.model.api.IBase; import org.hl7.fhir.r5.context.IWorkerContext; +import org.hl7.fhir.r5.fhirpath.ExpressionNode; +import org.hl7.fhir.r5.fhirpath.FHIRPathEngine; +import org.hl7.fhir.r5.fhirpath.FHIRPathUtilityClasses.FunctionDetails; +import org.hl7.fhir.r5.fhirpath.TypeDetails; import org.hl7.fhir.r5.hapi.ctx.HapiWorkerContext; import org.hl7.fhir.r5.model.Base; -import org.hl7.fhir.r5.model.ExpressionNode; import org.hl7.fhir.r5.model.IdType; import org.hl7.fhir.r5.model.Resource; import org.hl7.fhir.r5.model.ResourceType; -import org.hl7.fhir.r5.model.TypeDetails; import org.hl7.fhir.r5.model.ValueSet; -import org.hl7.fhir.r5.utils.FHIRPathEngine; -import org.hl7.fhir.r5.utils.FHIRPathUtilityClasses.FunctionDetails; import java.util.Collections; import java.util.HashMap; @@ -102,13 +102,16 @@ public class SearchParamExtractorR5 extends BaseSearchParamExtractor implements private final Map myResourceTypeToStub = Collections.synchronizedMap(new HashMap<>()); @Override - public List resolveConstant(Object appContext, String name, boolean beforeContext) + public List resolveConstant( + FHIRPathEngine engine, Object appContext, String name, boolean beforeContext, boolean explicitConstant) throws PathEngineException { return Collections.emptyList(); } @Override - public TypeDetails resolveConstantType(Object appContext, String name) throws PathEngineException { + public TypeDetails resolveConstantType( + FHIRPathEngine engine, Object appContext, String name, boolean explicitConstant) + throws PathEngineException { return null; } @@ -118,24 +121,34 @@ public class SearchParamExtractorR5 extends BaseSearchParamExtractor implements } @Override - public FunctionDetails resolveFunction(String functionName) { + public FunctionDetails resolveFunction(FHIRPathEngine engine, String functionName) { return null; } @Override - public TypeDetails checkFunction(Object appContext, String functionName, List parameters) + public TypeDetails checkFunction( + FHIRPathEngine engine, + Object appContext, + String functionName, + TypeDetails focus, + List parameters) throws PathEngineException { return null; } @Override public List executeFunction( - Object appContext, List focus, String functionName, List> parameters) { + FHIRPathEngine engine, + Object appContext, + List focus, + String functionName, + List> parameters) { return null; } @Override - public Base resolveReference(Object appContext, String theUrl, Base refContext) throws FHIRException { + public Base resolveReference(FHIRPathEngine engine, Object appContext, String theUrl, Base refContext) + throws FHIRException { Base retVal = resolveResourceInBundleWithPlaceholderId(appContext, theUrl); if (retVal != null) { return retVal; @@ -183,13 +196,19 @@ public class SearchParamExtractorR5 extends BaseSearchParamExtractor implements } @Override - public boolean conformsToProfile(Object appContext, Base item, String url) throws FHIRException { + public boolean conformsToProfile(FHIRPathEngine engine, Object appContext, Base item, String url) + throws FHIRException { return false; } @Override - public ValueSet resolveValueSet(Object theO, String theS) { + public ValueSet resolveValueSet(FHIRPathEngine engine, Object appContext, String url) { return null; } + + @Override + public boolean paramIsType(String name, int index) { + return false; + } } } diff --git a/hapi-fhir-server-mdm/pom.xml b/hapi-fhir-server-mdm/pom.xml index 6e163215517..178d7d29575 100644 --- a/hapi-fhir-server-mdm/pom.xml +++ b/hapi-fhir-server-mdm/pom.xml @@ -78,6 +78,12 @@ info.debatty java-string-similarity 1.2.1 + + + net.jcip + jcip-annotations + + org.springframework diff --git a/hapi-fhir-structures-dstu3/src/main/java/org/hl7/fhir/dstu3/hapi/ctx/HapiWorkerContext.java b/hapi-fhir-structures-dstu3/src/main/java/org/hl7/fhir/dstu3/hapi/ctx/HapiWorkerContext.java index 9b2f1096929..7b6f58cf7b7 100644 --- a/hapi-fhir-structures-dstu3/src/main/java/org/hl7/fhir/dstu3/hapi/ctx/HapiWorkerContext.java +++ b/hapi-fhir-structures-dstu3/src/main/java/org/hl7/fhir/dstu3/hapi/ctx/HapiWorkerContext.java @@ -31,6 +31,7 @@ import org.hl7.fhir.dstu3.terminologies.ValueSetExpander; import org.hl7.fhir.dstu3.utils.INarrativeGenerator; import org.hl7.fhir.dstu3.utils.validation.IResourceValidator; import org.hl7.fhir.exceptions.FHIRException; +import org.hl7.fhir.utilities.FhirPublication; import org.hl7.fhir.utilities.i18n.I18nBase; import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity; import org.hl7.fhir.utilities.validation.ValidationOptions; @@ -313,7 +314,8 @@ public final class HapiWorkerContext extends I18nBase implements IWorkerContext @Override public ValidationResult validateCode(String theSystem, String theCode, String theDisplay) { - ValidationOptions options = new ValidationOptions(); + ValidationOptions options = new ValidationOptions(FhirPublication.fromCode( + myValidationSupport.getFhirContext().getVersion().toString())); IValidationSupport.CodeValidationResult result = myValidationSupport.validateCode( new ValidationSupportContext(myValidationSupport), convertConceptValidationOptions(options), @@ -351,7 +353,8 @@ public final class HapiWorkerContext extends I18nBase implements IWorkerContext public ValidationResult validateCode(String theSystem, String theCode, String theDisplay, ValueSet theVs) { IValidationSupport.CodeValidationResult outcome; - ValidationOptions options = new ValidationOptions(); + ValidationOptions options = new ValidationOptions(FhirPublication.fromCode( + myValidationSupport.getFhirContext().getVersion().toString())); if (isNotBlank(theVs.getUrl())) { outcome = myValidationSupport.validateCode( new ValidationSupportContext(myValidationSupport), diff --git a/hapi-fhir-structures-dstu3/src/main/java/org/hl7/fhir/dstu3/hapi/fluentpath/FhirPathDstu3.java b/hapi-fhir-structures-dstu3/src/main/java/org/hl7/fhir/dstu3/hapi/fluentpath/FhirPathDstu3.java index e7dfd0d1c9b..a1e84c1bc26 100644 --- a/hapi-fhir-structures-dstu3/src/main/java/org/hl7/fhir/dstu3/hapi/fluentpath/FhirPathDstu3.java +++ b/hapi-fhir-structures-dstu3/src/main/java/org/hl7/fhir/dstu3/hapi/fluentpath/FhirPathDstu3.java @@ -7,13 +7,13 @@ import ca.uhn.fhir.fhirpath.IFhirPath; import ca.uhn.fhir.fhirpath.IFhirPathEvaluationContext; import ca.uhn.fhir.i18n.Msg; import jakarta.annotation.Nonnull; +import org.hl7.fhir.dstu3.fhirpath.ExpressionNode; +import org.hl7.fhir.dstu3.fhirpath.FHIRPathEngine; +import org.hl7.fhir.dstu3.fhirpath.FHIRPathUtilityClasses.FunctionDetails; +import org.hl7.fhir.dstu3.fhirpath.TypeDetails; import org.hl7.fhir.dstu3.hapi.ctx.HapiWorkerContext; import org.hl7.fhir.dstu3.model.Base; -import org.hl7.fhir.dstu3.model.ExpressionNode; import org.hl7.fhir.dstu3.model.IdType; -import org.hl7.fhir.dstu3.model.TypeDetails; -import org.hl7.fhir.dstu3.utils.FHIRPathEngine; -import org.hl7.fhir.dstu3.utils.FHIRPathUtilityClasses.FunctionDetails; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.PathEngineException; import org.hl7.fhir.instance.model.api.IBase; diff --git a/hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/hapi/ctx/HapiWorkerContext.java b/hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/hapi/ctx/HapiWorkerContext.java index ed09a4bf5ec..47d60c81744 100644 --- a/hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/hapi/ctx/HapiWorkerContext.java +++ b/hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/hapi/ctx/HapiWorkerContext.java @@ -410,6 +410,12 @@ public final class HapiWorkerContext extends I18nBase implements IWorkerContext } } + @Override + public T fetchResource( + Class theClass, String theUri, String theVersion) { + return fetchResource(theClass, theUri + "|" + theVersion); + } + @Override public T fetchResourceWithException(Class theClass, String theUri) throws FHIRException { @@ -454,4 +460,31 @@ public final class HapiWorkerContext extends I18nBase implements IWorkerContext } return retVal; } + + @Override + public boolean isPrimitiveType(String theType) { + return List.of( + "boolean", + "integer", + "integer64", + "string", + "decimal", + "uri", + "base64Binary", + "instant", + "date", + "dateTime", + "time", + "code", + "oid", + "id", + "markdown", + "unsignedInt", + "positiveInt", + "uuid", + "xhtml", + "url", + "canonical") + .contains(theType); + } } diff --git a/hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/hapi/fluentpath/FhirPathR4.java b/hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/hapi/fluentpath/FhirPathR4.java index 5c492e158e3..2c04412d4b8 100644 --- a/hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/hapi/fluentpath/FhirPathR4.java +++ b/hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/hapi/fluentpath/FhirPathR4.java @@ -10,14 +10,14 @@ import jakarta.annotation.Nonnull; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.PathEngineException; import org.hl7.fhir.instance.model.api.IBase; +import org.hl7.fhir.r4.fhirpath.ExpressionNode; +import org.hl7.fhir.r4.fhirpath.FHIRPathEngine; +import org.hl7.fhir.r4.fhirpath.FHIRPathUtilityClasses.FunctionDetails; +import org.hl7.fhir.r4.fhirpath.TypeDetails; import org.hl7.fhir.r4.hapi.ctx.HapiWorkerContext; import org.hl7.fhir.r4.model.Base; -import org.hl7.fhir.r4.model.ExpressionNode; import org.hl7.fhir.r4.model.IdType; -import org.hl7.fhir.r4.model.TypeDetails; import org.hl7.fhir.r4.model.ValueSet; -import org.hl7.fhir.r4.utils.FHIRPathEngine; -import org.hl7.fhir.r4.utils.FHIRPathUtilityClasses.FunctionDetails; import java.util.List; import java.util.Optional; @@ -94,13 +94,20 @@ public class FhirPathR4 implements IFhirPath { myEngine.setHostServices(new FHIRPathEngine.IEvaluationContext() { @Override - public List resolveConstant(Object appContext, String name, boolean beforeContext) + public List resolveConstant( + FHIRPathEngine engine, + Object appContext, + String name, + boolean beforeContext, + boolean explicitConstant) throws PathEngineException { return null; } @Override - public TypeDetails resolveConstantType(Object appContext, String name) throws PathEngineException { + public TypeDetails resolveConstantType( + FHIRPathEngine engine, Object appContext, String name, boolean explicitConstant) + throws PathEngineException { return null; } @@ -110,34 +117,45 @@ public class FhirPathR4 implements IFhirPath { } @Override - public FunctionDetails resolveFunction(String functionName) { + public FunctionDetails resolveFunction(FHIRPathEngine engine, String functionName) { return null; } @Override - public TypeDetails checkFunction(Object appContext, String functionName, List parameters) + public TypeDetails checkFunction( + FHIRPathEngine engine, + Object appContext, + String functionName, + TypeDetails focus, + List parameters) throws PathEngineException { return null; } @Override public List executeFunction( - Object appContext, List focus, String functionName, List> parameters) { + FHIRPathEngine engine, + Object appContext, + List focus, + String functionName, + List> parameters) { return null; } @Override - public Base resolveReference(Object appContext, String theUrl, Base theRefContext) throws FHIRException { - return (Base) theEvaluationContext.resolveReference(new IdType(theUrl), theRefContext); + public Base resolveReference(FHIRPathEngine engine, Object appContext, String url, Base refContext) + throws FHIRException { + return (Base) theEvaluationContext.resolveReference(new IdType(url), refContext); } @Override - public boolean conformsToProfile(Object appContext, Base item, String url) throws FHIRException { + public boolean conformsToProfile(FHIRPathEngine engine, Object appContext, Base item, String url) + throws FHIRException { return false; } @Override - public ValueSet resolveValueSet(Object appContext, String url) { + public ValueSet resolveValueSet(FHIRPathEngine engine, Object appContext, String url) { return null; } }); diff --git a/hapi-fhir-structures-r4b/src/main/java/org/hl7/fhir/r4b/hapi/fhirpath/FhirPathR4B.java b/hapi-fhir-structures-r4b/src/main/java/org/hl7/fhir/r4b/hapi/fhirpath/FhirPathR4B.java index 8d7d3c5ff9d..fd5570b6f33 100644 --- a/hapi-fhir-structures-r4b/src/main/java/org/hl7/fhir/r4b/hapi/fhirpath/FhirPathR4B.java +++ b/hapi-fhir-structures-r4b/src/main/java/org/hl7/fhir/r4b/hapi/fhirpath/FhirPathR4B.java @@ -10,14 +10,14 @@ import jakarta.annotation.Nonnull; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.PathEngineException; import org.hl7.fhir.instance.model.api.IBase; +import org.hl7.fhir.r4b.fhirpath.ExpressionNode; +import org.hl7.fhir.r4b.fhirpath.FHIRPathEngine; +import org.hl7.fhir.r4b.fhirpath.FHIRPathUtilityClasses.FunctionDetails; +import org.hl7.fhir.r4b.fhirpath.TypeDetails; import org.hl7.fhir.r4b.hapi.ctx.HapiWorkerContext; import org.hl7.fhir.r4b.model.Base; -import org.hl7.fhir.r4b.model.ExpressionNode; import org.hl7.fhir.r4b.model.IdType; -import org.hl7.fhir.r4b.model.TypeDetails; import org.hl7.fhir.r4b.model.ValueSet; -import org.hl7.fhir.r4b.utils.FHIRPathEngine; -import org.hl7.fhir.r4b.utils.FHIRPathUtilityClasses.FunctionDetails; import java.util.List; import java.util.Optional; @@ -91,13 +91,20 @@ public class FhirPathR4B implements IFhirPath { myEngine.setHostServices(new FHIRPathEngine.IEvaluationContext() { @Override - public List resolveConstant(Object appContext, String name, boolean beforeContext) + public List resolveConstant( + FHIRPathEngine engine, + Object appContext, + String name, + boolean beforeContext, + boolean explicitConstant) throws PathEngineException { return null; } @Override - public TypeDetails resolveConstantType(Object appContext, String name) throws PathEngineException { + public TypeDetails resolveConstantType( + FHIRPathEngine engine, Object appContext, String name, boolean explicitConstant) + throws PathEngineException { return null; } @@ -107,34 +114,45 @@ public class FhirPathR4B implements IFhirPath { } @Override - public FunctionDetails resolveFunction(String functionName) { + public FunctionDetails resolveFunction(FHIRPathEngine engine, String functionName) { return null; } @Override - public TypeDetails checkFunction(Object appContext, String functionName, List parameters) + public TypeDetails checkFunction( + FHIRPathEngine engine, + Object appContext, + String functionName, + TypeDetails focus, + List parameters) throws PathEngineException { return null; } @Override public List executeFunction( - Object appContext, List focus, String functionName, List> parameters) { + FHIRPathEngine engine, + Object appContext, + List focus, + String functionName, + List> parameters) { return null; } @Override - public Base resolveReference(Object appContext, String theUrl, Base refContext) throws FHIRException { - return (Base) theEvaluationContext.resolveReference(new IdType(theUrl), refContext); + public Base resolveReference(FHIRPathEngine engine, Object appContext, String url, Base refContext) + throws FHIRException { + return (Base) theEvaluationContext.resolveReference(new IdType(url), refContext); } @Override - public boolean conformsToProfile(Object appContext, Base item, String url) throws FHIRException { + public boolean conformsToProfile(FHIRPathEngine engine, Object appContext, Base item, String url) + throws FHIRException { return false; } @Override - public ValueSet resolveValueSet(Object appContext, String url) { + public ValueSet resolveValueSet(FHIRPathEngine engine, Object appContext, String url) { return null; } }); diff --git a/hapi-fhir-structures-r5/src/main/java/org/hl7/fhir/r5/hapi/ctx/HapiWorkerContext.java b/hapi-fhir-structures-r5/src/main/java/org/hl7/fhir/r5/hapi/ctx/HapiWorkerContext.java index 8346eec71c3..d6721ec5fa4 100644 --- a/hapi-fhir-structures-r5/src/main/java/org/hl7/fhir/r5/hapi/ctx/HapiWorkerContext.java +++ b/hapi-fhir-structures-r5/src/main/java/org/hl7/fhir/r5/hapi/ctx/HapiWorkerContext.java @@ -13,6 +13,8 @@ import org.apache.commons.lang3.Validate; import org.fhir.ucum.UcumService; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.TerminologyServiceException; +import org.hl7.fhir.r5.context.IContextResourceLoader; +import org.hl7.fhir.r5.context.ILoggingService; import org.hl7.fhir.r5.context.IWorkerContext; import org.hl7.fhir.r5.context.IWorkerContextManager; import org.hl7.fhir.r5.model.CodeSystem; @@ -30,8 +32,11 @@ import org.hl7.fhir.r5.model.ValueSet; import org.hl7.fhir.r5.model.ValueSet.ConceptSetComponent; import org.hl7.fhir.r5.profilemodel.PEBuilder; import org.hl7.fhir.r5.terminologies.expansion.ValueSetExpansionOutcome; +import org.hl7.fhir.r5.terminologies.utilities.CodingValidationRequest; +import org.hl7.fhir.r5.terminologies.utilities.ValidationResult; import org.hl7.fhir.r5.utils.validation.IResourceValidator; import org.hl7.fhir.r5.utils.validation.ValidationContextCarrier; +import org.hl7.fhir.utilities.FhirPublication; import org.hl7.fhir.utilities.TimeTracker; import org.hl7.fhir.utilities.TranslationServices; import org.hl7.fhir.utilities.i18n.I18nBase; @@ -90,6 +95,16 @@ public final class HapiWorkerContext extends I18nBase implements IWorkerContext } } + @Override + public CodeSystem fetchCodeSystem(String system, FhirPublication fhirVersion) { + throw new UnsupportedOperationException(Msg.code(2462)); + } + + @Override + public CodeSystem fetchCodeSystem(String system, String version, FhirPublication fhirVersion) { + throw new UnsupportedOperationException(Msg.code(2463)); + } + @Override public CodeSystem fetchSupplementedCodeSystem(String theS) { return null; @@ -100,6 +115,16 @@ public final class HapiWorkerContext extends I18nBase implements IWorkerContext return null; } + @Override + public CodeSystem fetchSupplementedCodeSystem(String system, FhirPublication fhirVersion) { + throw new UnsupportedOperationException(Msg.code(2464)); + } + + @Override + public CodeSystem fetchSupplementedCodeSystem(String system, String version, FhirPublication fhirVersion) { + throw new UnsupportedOperationException(Msg.code(2465)); + } + @Override public List getResourceNames() { List result = new ArrayList<>(); @@ -110,6 +135,11 @@ public final class HapiWorkerContext extends I18nBase implements IWorkerContext return result; } + @Override + public List getResourceNames(FhirPublication fhirVersion) { + throw new UnsupportedOperationException(Msg.code(2466)); + } + @Override public IResourceValidator newValidator() { throw new UnsupportedOperationException(Msg.code(206)); @@ -130,6 +160,11 @@ public final class HapiWorkerContext extends I18nBase implements IWorkerContext } } + @Override + public boolean supportsSystem(String system, FhirPublication fhirVersion) throws TerminologyServiceException { + throw new UnsupportedOperationException(Msg.code(2467)); + } + @Override public ValidationResult validateCode(ValidationOptions theOptions, CodeableConcept theCode, ValueSet theVs) { for (Coding next : theCode.getCoding()) { @@ -264,7 +299,8 @@ public final class HapiWorkerContext extends I18nBase implements IWorkerContext input.getCompose().addInclude(theInc); IValidationSupport.ValueSetExpansionOutcome output = myValidationSupport.expandValueSet(new ValidationSupportContext(myValidationSupport), null, input); - return new ValueSetExpansionOutcome((ValueSet) output.getValueSet(), output.getError(), null); + return new ValueSetExpansionOutcome( + (ValueSet) output.getValueSet(), output.getError(), null, output.getErrorIsFromServer()); } @Override @@ -322,11 +358,31 @@ public final class HapiWorkerContext extends I18nBase implements IWorkerContext return fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/" + typeName); } + @Override + public boolean isPrimitiveType(String s) { + throw new UnsupportedOperationException(Msg.code(2456)); + } + + @Override + public boolean isDataType(String s) { + throw new UnsupportedOperationException(Msg.code(2457)); + } + + @Override + public StructureDefinition fetchTypeDefinition(String typeName, FhirPublication fhirVersion) { + throw new UnsupportedOperationException(Msg.code(2458)); + } + @Override public List fetchTypeDefinitions(String n) { throw new UnsupportedOperationException(Msg.code(234)); } + @Override + public List fetchTypeDefinitions(String n, FhirPublication fhirPublication) { + throw new UnsupportedOperationException(Msg.code(2459)); + } + @Override public T fetchResourceRaw(Class class_, String uri) { return fetchResource(class_, uri); @@ -343,6 +399,10 @@ public final class HapiWorkerContext extends I18nBase implements IWorkerContext } } + public T fetchResource(Class class_, String uri, FhirPublication fhirVersion) { + throw new UnsupportedOperationException(Msg.code(2460)); + } + @Override public T fetchResourceWithException(Class theClass, String theUri) throws FHIRException { @@ -364,21 +424,47 @@ public final class HapiWorkerContext extends I18nBase implements IWorkerContext return fetchResource(theClass, theUri + "|" + theVersion); } + @Override + public T fetchResource( + Class class_, String uri, String version, FhirPublication fhirVersion) { + throw new UnsupportedOperationException(Msg.code(2461)); + } + @Override public T fetchResource(Class class_, String uri, Resource canonicalForSource) { return fetchResource(class_, uri); } + @Override + public List fetchResourcesByType(Class class_, FhirPublication fhirVersion) { + throw new UnsupportedOperationException(Msg.code(2468)); + } + @Override public org.hl7.fhir.r5.model.Resource fetchResourceById(String theType, String theUri) { throw new UnsupportedOperationException(Msg.code(226)); } + @Override + public Resource fetchResourceById(String type, String uri, FhirPublication fhirVersion) { + throw new UnsupportedOperationException(Msg.code(2469)); + } + @Override public boolean hasResource(Class theClass_, String theUri) { throw new UnsupportedOperationException(Msg.code(227)); } + @Override + public boolean hasResource(Class class_, String uri, Resource sourceOfReference) { + throw new UnsupportedOperationException(Msg.code(2470)); + } + + @Override + public boolean hasResource(Class class_, String uri, FhirPublication fhirVersion) { + throw new UnsupportedOperationException(Msg.code(2471)); + } + @Override public void cacheResource(org.hl7.fhir.r5.model.Resource theRes) throws FHIRException { throw new UnsupportedOperationException(Msg.code(228)); @@ -397,6 +483,11 @@ public final class HapiWorkerContext extends I18nBase implements IWorkerContext return myCtx.getResourceTypes(); } + @Override + public Set getResourceNamesAsSet(FhirPublication fhirVersion) { + throw new UnsupportedOperationException(Msg.code(2472)); + } + @Override public ValueSetExpansionOutcome expandVS( Resource src, ElementDefinitionBindingComponent theBinding, boolean theCacheOk, boolean theHierarchical) @@ -518,4 +609,9 @@ public final class HapiWorkerContext extends I18nBase implements IWorkerContext public void setForPublication(boolean b) { throw new UnsupportedOperationException(Msg.code(2350)); } + + @Override + public Set urlsForOid(boolean codeSystem, String oid) { + throw new UnsupportedOperationException(Msg.code(2473)); + } } diff --git a/hapi-fhir-structures-r5/src/main/java/org/hl7/fhir/r5/hapi/fhirpath/FhirPathR5.java b/hapi-fhir-structures-r5/src/main/java/org/hl7/fhir/r5/hapi/fhirpath/FhirPathR5.java index 6321e9a9bb2..d0d33f403f5 100644 --- a/hapi-fhir-structures-r5/src/main/java/org/hl7/fhir/r5/hapi/fhirpath/FhirPathR5.java +++ b/hapi-fhir-structures-r5/src/main/java/org/hl7/fhir/r5/hapi/fhirpath/FhirPathR5.java @@ -10,14 +10,14 @@ import jakarta.annotation.Nonnull; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.PathEngineException; import org.hl7.fhir.instance.model.api.IBase; +import org.hl7.fhir.r5.fhirpath.ExpressionNode; +import org.hl7.fhir.r5.fhirpath.FHIRPathEngine; +import org.hl7.fhir.r5.fhirpath.FHIRPathUtilityClasses; +import org.hl7.fhir.r5.fhirpath.TypeDetails; import org.hl7.fhir.r5.hapi.ctx.HapiWorkerContext; import org.hl7.fhir.r5.model.Base; -import org.hl7.fhir.r5.model.ExpressionNode; import org.hl7.fhir.r5.model.IdType; -import org.hl7.fhir.r5.model.TypeDetails; import org.hl7.fhir.r5.model.ValueSet; -import org.hl7.fhir.r5.utils.FHIRPathEngine; -import org.hl7.fhir.r5.utils.FHIRPathUtilityClasses; import java.util.List; import java.util.Optional; @@ -92,13 +92,20 @@ public class FhirPathR5 implements IFhirPath { myEngine.setHostServices(new FHIRPathEngine.IEvaluationContext() { @Override - public List resolveConstant(Object appContext, String name, boolean beforeContext) + public List resolveConstant( + FHIRPathEngine engine, + Object appContext, + String name, + boolean beforeContext, + boolean explicitConstant) throws PathEngineException { return null; } @Override - public TypeDetails resolveConstantType(Object appContext, String name) throws PathEngineException { + public TypeDetails resolveConstantType( + FHIRPathEngine engine, Object appContext, String name, boolean explicitConstant) + throws PathEngineException { return null; } @@ -108,36 +115,52 @@ public class FhirPathR5 implements IFhirPath { } @Override - public FHIRPathUtilityClasses.FunctionDetails resolveFunction(String functionName) { + public FHIRPathUtilityClasses.FunctionDetails resolveFunction(FHIRPathEngine engine, String functionName) { return null; } @Override - public TypeDetails checkFunction(Object appContext, String functionName, List parameters) + public TypeDetails checkFunction( + FHIRPathEngine engine, + Object appContext, + String functionName, + TypeDetails focus, + List parameters) throws PathEngineException { return null; } @Override public List executeFunction( - Object appContext, List focus, String functionName, List> parameters) { + FHIRPathEngine engine, + Object appContext, + List focus, + String functionName, + List> parameters) { return null; } @Override - public Base resolveReference(Object appContext, String theUrl, Base refContext) throws FHIRException { - return (Base) theEvaluationContext.resolveReference(new IdType(theUrl), refContext); + public Base resolveReference(FHIRPathEngine engine, Object appContext, String url, Base refContext) + throws FHIRException { + return (Base) theEvaluationContext.resolveReference(new IdType(url), refContext); } @Override - public boolean conformsToProfile(Object appContext, Base item, String url) throws FHIRException { + public boolean conformsToProfile(FHIRPathEngine engine, Object appContext, Base item, String url) + throws FHIRException { return false; } @Override - public ValueSet resolveValueSet(Object appContext, String url) { + public ValueSet resolveValueSet(FHIRPathEngine engine, Object appContext, String url) { return null; } + + @Override + public boolean paramIsType(String name, int index) { + return false; + } }); } diff --git a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/InMemoryTerminologyServerValidationSupport.java b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/InMemoryTerminologyServerValidationSupport.java index 84c4657a51e..65fbda9c56a 100644 --- a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/InMemoryTerminologyServerValidationSupport.java +++ b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/InMemoryTerminologyServerValidationSupport.java @@ -134,7 +134,7 @@ public class InMemoryTerminologyServerValidationSupport implements IValidationSu expansionR5 = expandValueSetToCanonical( theValidationSupportContext, theValueSetToExpand, theWantSystemAndVersion, theWantCode); } catch (ExpansionCouldNotBeCompletedInternallyException e) { - return new ValueSetExpansionOutcome(e.getMessage()); + return new ValueSetExpansionOutcome(e.getMessage(), false); } if (expansionR5 == null) { return null; diff --git a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/validator/FHIRPathResourceGeneratorR4.java b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/validator/FHIRPathResourceGeneratorR4.java index c092dd751f9..7a481ee4e20 100644 --- a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/validator/FHIRPathResourceGeneratorR4.java +++ b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/validator/FHIRPathResourceGeneratorR4.java @@ -8,10 +8,10 @@ import ca.uhn.fhir.context.RuntimePrimitiveDatatypeDefinition; import org.hl7.fhir.instance.model.api.IBase; import org.hl7.fhir.instance.model.api.ICompositeType; import org.hl7.fhir.instance.model.api.IPrimitiveType; +import org.hl7.fhir.r4.fhirpath.ExpressionNode; +import org.hl7.fhir.r4.fhirpath.FHIRPathEngine; import org.hl7.fhir.r4.hapi.ctx.HapiWorkerContext; -import org.hl7.fhir.r4.model.ExpressionNode; import org.hl7.fhir.r4.model.Resource; -import org.hl7.fhir.r4.utils.FHIRPathEngine; import java.util.ArrayList; import java.util.HashMap; diff --git a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/validator/FhirInstanceValidator.java b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/validator/FhirInstanceValidator.java index 3c46a5ab904..a80af43aec7 100644 --- a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/validator/FhirInstanceValidator.java +++ b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/validator/FhirInstanceValidator.java @@ -10,11 +10,11 @@ import jakarta.annotation.Nonnull; import org.apache.commons.lang3.Validate; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.PathEngineException; +import org.hl7.fhir.r5.fhirpath.FHIRPathEngine; +import org.hl7.fhir.r5.fhirpath.FHIRPathUtilityClasses.FunctionDetails; +import org.hl7.fhir.r5.fhirpath.TypeDetails; import org.hl7.fhir.r5.model.Base; -import org.hl7.fhir.r5.model.TypeDetails; import org.hl7.fhir.r5.model.ValueSet; -import org.hl7.fhir.r5.utils.FHIRPathEngine; -import org.hl7.fhir.r5.utils.FHIRPathUtilityClasses.FunctionDetails; import org.hl7.fhir.r5.utils.validation.IValidationPolicyAdvisor; import org.hl7.fhir.r5.utils.validation.IValidatorResourceFetcher; import org.hl7.fhir.r5.utils.validation.constants.BestPracticeWarningLevel; @@ -288,13 +288,16 @@ public class FhirInstanceValidator extends BaseValidatorBridge implements IInsta public static class NullEvaluationContext implements FHIRPathEngine.IEvaluationContext { @Override - public List resolveConstant(Object appContext, String name, boolean beforeContext) + public List resolveConstant( + FHIRPathEngine engine, Object appContext, String name, boolean beforeContext, boolean explicitConstant) throws PathEngineException { return Collections.emptyList(); } @Override - public TypeDetails resolveConstantType(Object appContext, String name) throws PathEngineException { + public TypeDetails resolveConstantType( + FHIRPathEngine engine, Object appContext, String name, boolean explicitConstant) + throws PathEngineException { return null; } @@ -304,35 +307,51 @@ public class FhirInstanceValidator extends BaseValidatorBridge implements IInsta } @Override - public FunctionDetails resolveFunction(String functionName) { + public FunctionDetails resolveFunction(FHIRPathEngine engine, String functionName) { return null; } @Override - public TypeDetails checkFunction(Object appContext, String functionName, List parameters) + public TypeDetails checkFunction( + FHIRPathEngine engine, + Object appContext, + String functionName, + TypeDetails focus, + List parameters) throws PathEngineException { return null; } @Override public List executeFunction( - Object appContext, List focus, String functionName, List> parameters) { + FHIRPathEngine engine, + Object appContext, + List focus, + String functionName, + List> parameters) { return null; } @Override - public Base resolveReference(Object appContext, String url, Base refContext) throws FHIRException { + public Base resolveReference(FHIRPathEngine engine, Object appContext, String url, Base refContext) + throws FHIRException { return null; } @Override - public boolean conformsToProfile(Object appContext, Base item, String url) throws FHIRException { + public boolean conformsToProfile(FHIRPathEngine engine, Object appContext, Base item, String url) + throws FHIRException { return false; } @Override - public ValueSet resolveValueSet(Object appContext, String url) { + public ValueSet resolveValueSet(FHIRPathEngine engine, Object appContext, String url) { return null; } + + @Override + public boolean paramIsType(String name, int index) { + return false; + } } } diff --git a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/validator/ValidatorWrapper.java b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/validator/ValidatorWrapper.java index f8e0c9bda89..8aa0b5a659b 100644 --- a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/validator/ValidatorWrapper.java +++ b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/validator/ValidatorWrapper.java @@ -14,8 +14,8 @@ import org.apache.commons.io.input.ReaderInputStream; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.r5.context.IWorkerContext; import org.hl7.fhir.r5.elementmodel.Manager; +import org.hl7.fhir.r5.fhirpath.FHIRPathEngine; import org.hl7.fhir.r5.model.StructureDefinition; -import org.hl7.fhir.r5.utils.FHIRPathEngine; import org.hl7.fhir.r5.utils.XVerExtensionManager; import org.hl7.fhir.r5.utils.validation.IValidationPolicyAdvisor; import org.hl7.fhir.r5.utils.validation.IValidatorResourceFetcher; diff --git a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/validator/VersionSpecificWorkerContextWrapper.java b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/validator/VersionSpecificWorkerContextWrapper.java index 340dcfc775c..b2229fd728c 100644 --- a/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/validator/VersionSpecificWorkerContextWrapper.java +++ b/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/validator/VersionSpecificWorkerContextWrapper.java @@ -19,6 +19,8 @@ import org.fhir.ucum.UcumService; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.TerminologyServiceException; import org.hl7.fhir.instance.model.api.IBaseResource; +import org.hl7.fhir.r5.context.IContextResourceLoader; +import org.hl7.fhir.r5.context.ILoggingService; import org.hl7.fhir.r5.context.IWorkerContext; import org.hl7.fhir.r5.context.IWorkerContextManager; import org.hl7.fhir.r5.model.CodeSystem; @@ -30,9 +32,12 @@ import org.hl7.fhir.r5.model.StructureDefinition; import org.hl7.fhir.r5.model.ValueSet; import org.hl7.fhir.r5.profilemodel.PEBuilder; import org.hl7.fhir.r5.terminologies.expansion.ValueSetExpansionOutcome; +import org.hl7.fhir.r5.terminologies.utilities.CodingValidationRequest; import org.hl7.fhir.r5.terminologies.utilities.TerminologyServiceErrorClass; +import org.hl7.fhir.r5.terminologies.utilities.ValidationResult; import org.hl7.fhir.r5.utils.validation.IResourceValidator; import org.hl7.fhir.r5.utils.validation.ValidationContextCarrier; +import org.hl7.fhir.utilities.FhirPublication; import org.hl7.fhir.utilities.TimeTracker; import org.hl7.fhir.utilities.TranslationServices; import org.hl7.fhir.utilities.i18n.I18nBase; @@ -313,7 +318,7 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo String error = expanded.getError(); TerminologyServiceErrorClass result = null; - return new ValueSetExpansionOutcome(convertedResult, error, result); + return new ValueSetExpansionOutcome(convertedResult, error, result, expanded.getErrorIsFromServer()); } @Override @@ -373,6 +378,16 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo } } + @Override + public CodeSystem fetchCodeSystem(String system, FhirPublication fhirVersion) { + return null; + } + + @Override + public CodeSystem fetchCodeSystem(String system, String version, FhirPublication fhirVersion) { + return null; + } + @Override public CodeSystem fetchSupplementedCodeSystem(String system) { return null; @@ -383,6 +398,16 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo return null; } + @Override + public CodeSystem fetchSupplementedCodeSystem(String system, FhirPublication fhirVersion) { + return null; + } + + @Override + public CodeSystem fetchSupplementedCodeSystem(String system, String version, FhirPublication fhirVersion) { + return null; + } + @Override public T fetchResourceRaw(Class class_, String uri) { return fetchResource(class_, uri); @@ -407,6 +432,11 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo throw new UnsupportedOperationException(Msg.code(666)); } + @Override + public Resource fetchResourceById(String type, String uri, FhirPublication fhirVersion) { + return null; + } + @Override public T fetchResourceWithException(Class class_, String uri) throws FHIRException { T retVal = fetchResource(class_, uri); @@ -422,11 +452,27 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo return fetchResource(class_, uri + "|" + version); } + @Override + public T fetchResource(Class class_, String uri, FhirPublication fhirVersion) { + return null; + } + + @Override + public T fetchResource( + Class class_, String uri, String version, FhirPublication fhirVersion) { + return null; + } + @Override public T fetchResource(Class class_, String uri, Resource canonicalForSource) { return fetchResource(class_, uri); } + @Override + public List fetchResourcesByType(Class class_, FhirPublication fhirVersion) { + return null; + } + @Override public T fetchResourceWithException(Class class_, String uri, Resource sourceOfReference) throws FHIRException { @@ -441,6 +487,11 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo .getResourceTypes()); } + @Override + public List getResourceNames(FhirPublication fhirVersion) { + return null; + } + @Override public Set getResourceNamesAsSet() { return myValidationSupportContext @@ -449,11 +500,21 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo .getResourceTypes(); } + @Override + public Set getResourceNamesAsSet(FhirPublication fhirVersion) { + return null; + } + @Override public StructureDefinition fetchTypeDefinition(String typeName) { return fetchResource(StructureDefinition.class, "http://hl7.org/fhir/StructureDefinition/" + typeName); } + @Override + public StructureDefinition fetchTypeDefinition(String typeName, FhirPublication fhirVersion) { + return null; + } + @Override public List fetchTypeDefinitions(String typeName) { List allStructures = new ArrayList<>(allStructures()); @@ -461,6 +522,29 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo return allStructures; } + @Override + public List fetchTypeDefinitions(String n, FhirPublication fhirVersion) { + return null; + } + + @Override + public boolean isPrimitiveType(String s) { + List allStructures = new ArrayList<>(allStructures()); + return allStructures.stream() + .filter(structureDefinition -> + structureDefinition.getKind() == StructureDefinition.StructureDefinitionKind.PRIMITIVETYPE) + .anyMatch(structureDefinition -> s.equals(structureDefinition.getType())); + } + + @Override + public boolean isDataType(String s) { + List allStructures = new ArrayList<>(allStructures()); + return allStructures.stream() + .filter(structureDefinition -> + structureDefinition.getKind() == StructureDefinition.StructureDefinitionKind.COMPLEXTYPE) + .anyMatch(structureDefinition -> s.equals(structureDefinition.getType())); + } + @Override public UcumService getUcumService() { throw new UnsupportedOperationException(Msg.code(676)); @@ -486,6 +570,16 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo throw new UnsupportedOperationException(Msg.code(680)); } + @Override + public boolean hasResource(Class class_, String uri, Resource sourceOfReference) { + return false; + } + + @Override + public boolean hasResource(Class class_, String uri, FhirPublication fhirVersion) { + return false; + } + @Override public boolean isNoTerminologyServer() { return false; @@ -523,6 +617,11 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo .isCodeSystemSupported(myValidationSupportContext, system); } + @Override + public boolean supportsSystem(String system, FhirPublication fhirVersion) throws TerminologyServiceException { + return false; + } + @Override public TranslationServices translator() { throw new UnsupportedOperationException(Msg.code(688)); @@ -701,6 +800,11 @@ public class VersionSpecificWorkerContextWrapper extends I18nBase implements IWo throw new UnsupportedOperationException(Msg.code(2351)); } + @Override + public Set urlsForOid(boolean codeSystem, String oid) { + return null; + } + public static ConceptValidationOptions convertConceptValidationOptions(ValidationOptions theOptions) { ConceptValidationOptions retVal = new ConceptValidationOptions(); if (theOptions.isGuessSystem()) { diff --git a/hapi-fhir-validation/src/test/java/org/hl7/fhir/dstu3/hapi/validation/FhirInstanceValidatorDstu3Test.java b/hapi-fhir-validation/src/test/java/org/hl7/fhir/dstu3/hapi/validation/FhirInstanceValidatorDstu3Test.java index 86b6f028ad8..3e971a8c688 100644 --- a/hapi-fhir-validation/src/test/java/org/hl7/fhir/dstu3/hapi/validation/FhirInstanceValidatorDstu3Test.java +++ b/hapi-fhir-validation/src/test/java/org/hl7/fhir/dstu3/hapi/validation/FhirInstanceValidatorDstu3Test.java @@ -21,6 +21,7 @@ import org.hl7.fhir.common.hapi.validation.support.SnapshotGeneratingValidationS import org.hl7.fhir.common.hapi.validation.support.ValidationSupportChain; import org.hl7.fhir.common.hapi.validation.validator.FhirInstanceValidator; import org.hl7.fhir.dstu3.hapi.ctx.HapiWorkerContext; +import org.hl7.fhir.dstu3.fhirpath.FHIRPathEngine; import org.hl7.fhir.dstu3.model.Base; import org.hl7.fhir.dstu3.model.BooleanType; import org.hl7.fhir.dstu3.model.Bundle; @@ -52,7 +53,6 @@ import org.hl7.fhir.dstu3.model.StructureDefinition; import org.hl7.fhir.dstu3.model.StructureDefinition.StructureDefinitionKind; import org.hl7.fhir.dstu3.model.ValueSet; import org.hl7.fhir.dstu3.model.ValueSet.ValueSetExpansionComponent; -import org.hl7.fhir.dstu3.utils.FHIRPathEngine; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.r5.utils.validation.IValidationPolicyAdvisor; import org.hl7.fhir.r5.utils.validation.IValidatorResourceFetcher; diff --git a/hapi-fhir-validation/src/test/java/org/hl7/fhir/dstu3/utils/FhirPathEngineTest.java b/hapi-fhir-validation/src/test/java/org/hl7/fhir/dstu3/utils/FhirPathEngineTest.java index d524e0387b3..cbb0113fb59 100644 --- a/hapi-fhir-validation/src/test/java/org/hl7/fhir/dstu3/utils/FhirPathEngineTest.java +++ b/hapi-fhir-validation/src/test/java/org/hl7/fhir/dstu3/utils/FhirPathEngineTest.java @@ -6,13 +6,13 @@ import ca.uhn.fhir.util.TestUtil; import org.hl7.fhir.dstu3.hapi.ctx.HapiWorkerContext; import org.hl7.fhir.dstu3.model.Base; import org.hl7.fhir.dstu3.model.BooleanType; -import org.hl7.fhir.dstu3.model.ContactPoint; import org.hl7.fhir.dstu3.model.DateTimeType; import org.hl7.fhir.dstu3.model.Observation; import org.hl7.fhir.dstu3.model.Patient; import org.hl7.fhir.dstu3.model.Reference; import org.hl7.fhir.dstu3.model.Specimen; import org.hl7.fhir.dstu3.model.StringType; +import org.hl7.fhir.dstu3.fhirpath.FHIRPathEngine; import org.hl7.fhir.exceptions.FHIRException; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; diff --git a/hapi-fhir-validation/src/test/java/org/hl7/fhir/r4/utils/FhirPathEngineR4Test.java b/hapi-fhir-validation/src/test/java/org/hl7/fhir/r4/utils/FhirPathEngineR4Test.java index cb4029ab6e6..d503bf66621 100644 --- a/hapi-fhir-validation/src/test/java/org/hl7/fhir/r4/utils/FhirPathEngineR4Test.java +++ b/hapi-fhir-validation/src/test/java/org/hl7/fhir/r4/utils/FhirPathEngineR4Test.java @@ -6,6 +6,7 @@ import ca.uhn.fhir.util.TestUtil; import org.hl7.fhir.dstu3.utils.FhirPathEngineTest; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.instance.model.api.IPrimitiveType; +import org.hl7.fhir.r4.fhirpath.FHIRPathEngine; import org.hl7.fhir.r4.hapi.ctx.HapiWorkerContext; import org.hl7.fhir.r4.model.Base; import org.hl7.fhir.r4.model.BooleanType; diff --git a/hapi-fhir-validation/src/test/java/org/hl7/fhir/r4/validation/FhirInstanceValidatorR4Test.java b/hapi-fhir-validation/src/test/java/org/hl7/fhir/r4/validation/FhirInstanceValidatorR4Test.java index 7f29442a01a..486a5d5fc67 100644 --- a/hapi-fhir-validation/src/test/java/org/hl7/fhir/r4/validation/FhirInstanceValidatorR4Test.java +++ b/hapi-fhir-validation/src/test/java/org/hl7/fhir/r4/validation/FhirInstanceValidatorR4Test.java @@ -68,7 +68,7 @@ import org.hl7.fhir.r4.model.StructureDefinition.StructureDefinitionKind; import org.hl7.fhir.r4.model.ValueSet; import org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionComponent; import org.hl7.fhir.r4.terminologies.ValueSetExpander; -import org.hl7.fhir.r4.utils.FHIRPathEngine; +import org.hl7.fhir.r4.fhirpath.FHIRPathEngine; import org.hl7.fhir.r5.elementmodel.JsonParser; import org.hl7.fhir.r5.test.utils.ClassesLoadedFlags; import org.hl7.fhir.r5.utils.validation.IValidationPolicyAdvisor; diff --git a/hapi-fhir-validation/src/test/java/org/hl7/fhir/r4/validation/HapiWorkerContextTest.java b/hapi-fhir-validation/src/test/java/org/hl7/fhir/r4/validation/HapiWorkerContextTest.java index df14ec8ccbd..19eb927f051 100644 --- a/hapi-fhir-validation/src/test/java/org/hl7/fhir/r4/validation/HapiWorkerContextTest.java +++ b/hapi-fhir-validation/src/test/java/org/hl7/fhir/r4/validation/HapiWorkerContextTest.java @@ -13,6 +13,7 @@ import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.r4.context.IWorkerContext; import org.hl7.fhir.r4.hapi.ctx.HapiWorkerContext; import org.hl7.fhir.r4.model.ValueSet; +import org.hl7.fhir.utilities.FhirPublication; import org.hl7.fhir.utilities.validation.ValidationOptions; import org.junit.jupiter.api.Test; import org.springframework.core.io.Resource; @@ -57,7 +58,8 @@ public class HapiWorkerContextTest extends BaseTest { // Built-in Codes vs.setUrl("http://hl7.org/fhir/ValueSet/fm-status"); - ValidationOptions options = new ValidationOptions().withGuessSystem(); + ValidationOptions options = new ValidationOptions(FhirPublication.fromCode( + workerCtx.getVersion().toString())).withGuessSystem(); outcome = workerCtx.validateCode(options, "active", vs); assertEquals(true, outcome.isOk(), outcome.getMessage()); diff --git a/hapi-fhir-validation/src/test/java/org/hl7/fhir/r4b/validation/FhirInstanceValidatorR4BTest.java b/hapi-fhir-validation/src/test/java/org/hl7/fhir/r4b/validation/FhirInstanceValidatorR4BTest.java index f700c6e6744..086b46f68c9 100644 --- a/hapi-fhir-validation/src/test/java/org/hl7/fhir/r4b/validation/FhirInstanceValidatorR4BTest.java +++ b/hapi-fhir-validation/src/test/java/org/hl7/fhir/r4b/validation/FhirInstanceValidatorR4BTest.java @@ -61,7 +61,7 @@ import org.hl7.fhir.r4b.model.StructureDefinition.StructureDefinitionKind; import org.hl7.fhir.r4b.model.ValueSet; import org.hl7.fhir.r4b.model.ValueSet.ValueSetExpansionComponent; import org.hl7.fhir.r4b.terminologies.ValueSetExpander; -import org.hl7.fhir.r4b.utils.FHIRPathEngine; +import org.hl7.fhir.r4b.fhirpath.FHIRPathEngine; import org.hl7.fhir.r5.test.utils.ClassesLoadedFlags; import org.hl7.fhir.r5.utils.validation.IValidationPolicyAdvisor; import org.hl7.fhir.r5.utils.validation.IValidatorResourceFetcher; diff --git a/pom.xml b/pom.xml index 9c84fe29e1c..468524dcc60 100644 --- a/pom.xml +++ b/pom.xml @@ -897,7 +897,7 @@ - 6.1.2.2 + 6.2.6 2.41.1 -Dfile.encoding=UTF-8 -Xmx2048m