This commit is contained in:
dotasek 2024-11-27 08:05:19 -05:00 committed by GitHub
commit 574c52fde6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 75 additions and 4 deletions

View File

@ -208,5 +208,10 @@ public class SearchParamExtractorR4 extends BaseSearchParamExtractor implements
public ValueSet resolveValueSet(FHIRPathEngine engine, Object appContext, String url) { public ValueSet resolveValueSet(FHIRPathEngine engine, Object appContext, String url) {
return null; return null;
} }
@Override
public boolean paramIsType(String name, int index) {
return false;
}
} }
} }

View File

@ -196,6 +196,7 @@ import org.hl7.fhir.r5.utils.validation.constants.BindingKind;
import org.hl7.fhir.r5.utils.validation.constants.ContainedReferenceValidationPolicy; import org.hl7.fhir.r5.utils.validation.constants.ContainedReferenceValidationPolicy;
import org.hl7.fhir.r5.utils.validation.constants.ReferenceValidationPolicy; import org.hl7.fhir.r5.utils.validation.constants.ReferenceValidationPolicy;
import org.hl7.fhir.utilities.validation.ValidationMessage; import org.hl7.fhir.utilities.validation.ValidationMessage;
import org.hl7.fhir.validation.instance.advisor.BasePolicyAdvisorForFullValidation;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Order;
@ -1075,6 +1076,18 @@ public abstract class BaseJpaR4Test extends BaseJpaTest implements ITestDataBuil
public ReferenceValidationPolicy getReferencePolicy() { public ReferenceValidationPolicy getReferencePolicy() {
return ReferenceValidationPolicy.IGNORE; return ReferenceValidationPolicy.IGNORE;
} }
@Override
public IValidationPolicyAdvisor getPolicyAdvisor() {
return new BasePolicyAdvisorForFullValidation(getReferencePolicy());
}
@Override
public IValidationPolicyAdvisor setPolicyAdvisor(IValidationPolicyAdvisor policyAdvisor) {
return null;
}
} }

View File

@ -76,7 +76,7 @@ public class MdmRuleValidatorTest extends BaseR4Test {
try { try {
setMdmRuleJson("bad-rules-bad-fhirpath.json"); setMdmRuleJson("bad-rules-bad-fhirpath.json");
fail(); } catch (ConfigurationException e) { fail(); } catch (ConfigurationException e) {
assertThat(e.getMessage()).startsWith(Msg.code(1518) + "MatchField [given-name] resourceType [Patient] has failed FHIRPath evaluation. Error in ?? at 1, 1: The name blurst is not a valid function name"); assertThat(e.getMessage()).startsWith(Msg.code(1518) + "MatchField [given-name] resourceType [Patient] has failed FHIRPath evaluation. Error @1, 1: The name blurst is not a valid function name");
} }
} }

View File

@ -31,6 +31,7 @@ import org.hl7.fhir.r5.utils.validation.constants.BindingKind;
import org.hl7.fhir.r5.utils.validation.constants.ContainedReferenceValidationPolicy; import org.hl7.fhir.r5.utils.validation.constants.ContainedReferenceValidationPolicy;
import org.hl7.fhir.r5.utils.validation.constants.ReferenceValidationPolicy; import org.hl7.fhir.r5.utils.validation.constants.ReferenceValidationPolicy;
import org.hl7.fhir.utilities.validation.ValidationMessage; import org.hl7.fhir.utilities.validation.ValidationMessage;
import org.hl7.fhir.validation.instance.advisor.BasePolicyAdvisorForFullValidation;
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;
@ -123,6 +124,16 @@ public class ValidatorPolicyAdvisor implements IValidationPolicyAdvisor {
return false; return false;
} }
@Override
public IValidationPolicyAdvisor getPolicyAdvisor() {
return new BasePolicyAdvisorForFullValidation(getReferencePolicy());
}
@Override
public IValidationPolicyAdvisor setPolicyAdvisor(IValidationPolicyAdvisor policyAdvisor) {
return null;
}
@Override @Override
public ReferenceValidationPolicy getReferencePolicy() { public ReferenceValidationPolicy getReferencePolicy() {
return ReferenceValidationPolicy.IGNORE; return ReferenceValidationPolicy.IGNORE;

View File

@ -15,6 +15,7 @@ import org.hl7.fhir.common.hapi.validation.validator.VersionSpecificWorkerContex
import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.r5.elementmodel.Element; import org.hl7.fhir.r5.elementmodel.Element;
import org.hl7.fhir.r5.utils.XVerExtensionManager; import org.hl7.fhir.r5.utils.XVerExtensionManager;
import org.hl7.fhir.r5.utils.validation.ValidatorSession;
import org.hl7.fhir.validation.instance.InstanceValidator; import org.hl7.fhir.validation.instance.InstanceValidator;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -56,7 +57,7 @@ public class ValidatorResourceFetcherTest extends BaseTest {
InstanceValidator v = new InstanceValidator( InstanceValidator v = new InstanceValidator(
wrappedWorkerContext, wrappedWorkerContext,
new FhirInstanceValidator.NullEvaluationContext(), new FhirInstanceValidator.NullEvaluationContext(),
new XVerExtensionManager(null)); new XVerExtensionManager(null), new ValidatorSession());
RequestDetails r = new SystemRequestDetails(); RequestDetails r = new SystemRequestDetails();
// test // test
Element returnedResource = fetcher.fetch(v, r,"http://www.test-url-for-questionnaire.com/Questionnaire/test-id|1.0.0"); Element returnedResource = fetcher.fetch(v, r,"http://www.test-url-for-questionnaire.com/Questionnaire/test-id|1.0.0");

View File

@ -40,6 +40,7 @@ import org.hl7.fhir.utilities.validation.ValidationOptions;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@ -449,6 +450,29 @@ public final class HapiWorkerContext extends I18nBase implements IWorkerContext
return retVal; return retVal;
} }
public <T extends Resource> List<T> fetchResourcesByType(Class<T> theClass) {
List<T> res = new ArrayList<>();
if (theClass == StructureDefinition.class) {
res.addAll((Collection<? extends T>) getStructures());
}
return res;
}
public <T extends Resource> T fetchResource(Class<T> class_, String uri, Resource source) {
return fetchResource(class_, uri);
}
@Override
public List<StructureDefinition> fetchTypeDefinitions(String n) {
List<StructureDefinition> types = new ArrayList<>();
for (StructureDefinition sd : allStructures()) {
if (n.equals(sd.getTypeTail())) {
types.add(sd);
}
}
return types;
}
@Override @Override
public org.hl7.fhir.r4.model.Resource fetchResourceById(String theType, String theUri) { public org.hl7.fhir.r4.model.Resource fetchResourceById(String theType, String theUri) {
throw new UnsupportedOperationException(Msg.code(282)); throw new UnsupportedOperationException(Msg.code(282));

View File

@ -158,6 +158,11 @@ public class FhirPathR4 implements IFhirPath {
public ValueSet resolveValueSet(FHIRPathEngine engine, Object appContext, String url) { public ValueSet resolveValueSet(FHIRPathEngine engine, Object appContext, String url) {
return null; return null;
} }
@Override
public boolean paramIsType(String name, int index) {
return false;
}
}); });
} }

View File

@ -11,6 +11,7 @@ import org.hl7.fhir.r5.utils.validation.constants.BindingKind;
import org.hl7.fhir.r5.utils.validation.constants.ContainedReferenceValidationPolicy; import org.hl7.fhir.r5.utils.validation.constants.ContainedReferenceValidationPolicy;
import org.hl7.fhir.r5.utils.validation.constants.ReferenceValidationPolicy; import org.hl7.fhir.r5.utils.validation.constants.ReferenceValidationPolicy;
import org.hl7.fhir.utilities.validation.ValidationMessage; import org.hl7.fhir.utilities.validation.ValidationMessage;
import org.hl7.fhir.validation.instance.advisor.BasePolicyAdvisorForFullValidation;
import java.util.Arrays; import java.util.Arrays;
import java.util.EnumSet; import java.util.EnumSet;
@ -91,6 +92,16 @@ public class FhirDefaultPolicyAdvisor implements IValidationPolicyAdvisor {
return false; return false;
} }
@Override
public IValidationPolicyAdvisor getPolicyAdvisor() {
return new BasePolicyAdvisorForFullValidation(getReferencePolicy());
}
@Override
public IValidationPolicyAdvisor setPolicyAdvisor(IValidationPolicyAdvisor policyAdvisor) {
return null;
}
@Override @Override
public ReferenceValidationPolicy getReferencePolicy() { public ReferenceValidationPolicy getReferencePolicy() {
return ReferenceValidationPolicy.IGNORE; return ReferenceValidationPolicy.IGNORE;

View File

@ -19,6 +19,7 @@ import org.hl7.fhir.r5.model.StructureDefinition;
import org.hl7.fhir.r5.utils.XVerExtensionManager; import org.hl7.fhir.r5.utils.XVerExtensionManager;
import org.hl7.fhir.r5.utils.validation.IValidationPolicyAdvisor; import org.hl7.fhir.r5.utils.validation.IValidationPolicyAdvisor;
import org.hl7.fhir.r5.utils.validation.IValidatorResourceFetcher; import org.hl7.fhir.r5.utils.validation.IValidatorResourceFetcher;
import org.hl7.fhir.r5.utils.validation.ValidatorSession;
import org.hl7.fhir.r5.utils.validation.constants.BestPracticeWarningLevel; import org.hl7.fhir.r5.utils.validation.constants.BestPracticeWarningLevel;
import org.hl7.fhir.r5.utils.validation.constants.IdStatus; import org.hl7.fhir.r5.utils.validation.constants.IdStatus;
import org.hl7.fhir.utilities.i18n.I18nConstants; import org.hl7.fhir.utilities.i18n.I18nConstants;
@ -119,7 +120,7 @@ class ValidatorWrapper {
FHIRPathEngine.IEvaluationContext evaluationCtx = new FhirInstanceValidator.NullEvaluationContext(); FHIRPathEngine.IEvaluationContext evaluationCtx = new FhirInstanceValidator.NullEvaluationContext();
XVerExtensionManager xverManager = new XVerExtensionManager(theWorkerContext); XVerExtensionManager xverManager = new XVerExtensionManager(theWorkerContext);
try { try {
v = new InstanceValidator(theWorkerContext, evaluationCtx, xverManager); v = new InstanceValidator(theWorkerContext, evaluationCtx, xverManager, new ValidatorSession());
} catch (Exception e) { } catch (Exception e) {
throw new ConfigurationException(Msg.code(648) + e.getMessage(), e); throw new ConfigurationException(Msg.code(648) + e.getMessage(), e);
} }

View File

@ -967,7 +967,7 @@
</licenses> </licenses>
<properties> <properties>
<fhir_core_version>6.4.0</fhir_core_version> <fhir_core_version>6.4.4</fhir_core_version>
<spotless_version>2.41.1</spotless_version> <spotless_version>2.41.1</spotless_version>
<surefire_jvm_args>-Dfile.encoding=UTF-8 -Xmx2048m</surefire_jvm_args> <surefire_jvm_args>-Dfile.encoding=UTF-8 -Xmx2048m</surefire_jvm_args>