From eb23fcc5e45c36f1c2f7bca9aa5b68b1b7aa0810 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Mon, 17 Aug 2020 23:53:54 +1000 Subject: [PATCH] more config for validator (#309) * fix up POMs * fixes for main build to use packages * more config for validator * more options for validation version comparison --- .../fhir/r5/context/SimpleWorkerContext.java | 4 ++-- .../hl7/fhir/r5/utils/IResourceValidator.java | 5 +++-- .../hl7/fhir/utilities/VersionUtilities.java | 21 +++++++++++++------ .../instance/InstanceValidator.java | 11 ++++++++++ .../instance/type/ValueSetValidator.java | 2 +- 5 files changed, 32 insertions(+), 11 deletions(-) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/SimpleWorkerContext.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/SimpleWorkerContext.java index efef85aa6..d8112ff25 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/SimpleWorkerContext.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/SimpleWorkerContext.java @@ -101,7 +101,7 @@ import ca.uhn.fhir.parser.DataFormatException; public class SimpleWorkerContext extends BaseWorkerContext implements IWorkerContext, ProfileKnowledgeProvider { - public class PackageResourceLoader extends CanonicalResourceProxy { + public static class PackageResourceLoader extends CanonicalResourceProxy { private String filename; private IContextResourceLoader loader; @@ -429,7 +429,7 @@ public class SimpleWorkerContext extends BaseWorkerContext implements IWorkerCon loadedPackages.add(pi.id()+"#"+pi.version()); - if (types.length == 0 && loader != null) { + if ((types == null || types.length == 0) && loader != null) { types = loader.getTypes(); } if (VersionUtilities.isR2Ver(pi.fhirVersion()) || !pi.canLazyLoad()) { diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/IResourceValidator.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/IResourceValidator.java index 03375b01a..af64ffcb5 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/IResourceValidator.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/IResourceValidator.java @@ -132,8 +132,6 @@ public interface IResourceValidator { OPTIONAL, REQUIRED, PROHIBITED } - - /** * how much to check displays for coded elements * @return @@ -214,6 +212,8 @@ public interface IResourceValidator { public boolean isCrumbTrails(); public void setCrumbTrails(boolean crumbTrails); + public boolean isValidateValueSetCodesOnTxServer(); + public void setValidateValueSetCodesOnTxServer(boolean value); /** * Bundle validation rules allow for requesting particular entries in a bundle get validated against particular profiles @@ -223,6 +223,7 @@ public interface IResourceValidator { * @return */ public List getBundleValidationRules(); + /** * Validate suite * diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/VersionUtilities.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/VersionUtilities.java index c17a684e5..d6630d87b 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/VersionUtilities.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/VersionUtilities.java @@ -147,13 +147,22 @@ public class VersionUtilities { } public static boolean versionsCompatible(String v1, String v2) { - String mm1 = getMajMin(v1); - String mm2 = getMajMin(v2); - if (mm1 == null || mm2 == null) { - return false; - } else { - return mm1.equals(mm2); + String[] v1l = v1.split("\\|"); + String[] v2l = v2.split("\\|"); + for (String vs1 : v1l) { + for (String vs2 : v2l) { + String mm1 = getMajMin(vs1); + String mm2 = getMajMin(vs2); + if (mm1 == null || mm2 == null) { + return false; + } else { + if (mm1.equals(mm2)) { + return true; + } + } + } } + return false; } public static boolean isCorePackage(String s) { diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/InstanceValidator.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/InstanceValidator.java index 7fd0a2537..0b97f42b9 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/InstanceValidator.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/InstanceValidator.java @@ -365,6 +365,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat private ProfileUtilities profileUtilities; private boolean crumbTrails; private List bundleValidationRules = new ArrayList<>(); + private boolean validateValueSetCodesOnTxServer; public InstanceValidator(IWorkerContext theContext, IEvaluationContext hostServices) { super(theContext); @@ -4824,4 +4825,14 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat return bundleValidationRules ; } + @Override + public boolean isValidateValueSetCodesOnTxServer() { + return validateValueSetCodesOnTxServer; + } + + @Override + public void setValidateValueSetCodesOnTxServer(boolean value) { + this.validateValueSetCodesOnTxServer = value; + } + } \ No newline at end of file diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/type/ValueSetValidator.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/type/ValueSetValidator.java index 354de77e1..a10173f81 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/type/ValueSetValidator.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/type/ValueSetValidator.java @@ -114,7 +114,7 @@ public class ValueSetValidator extends BaseValidator { } cc++; } - if (batch.size() > 0) { + if (parent.isValidateValueSetCodesOnTxServer() && batch.size() > 0) { long t = System.currentTimeMillis(); if (parent.isDebug()) { System.out.println(" : Validate "+batch.size()+" codes from "+system+" for "+vsid);