diff --git a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/context/BaseWorkerContext.java b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/context/BaseWorkerContext.java index 2b57812aa..75a4b365a 100644 --- a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/context/BaseWorkerContext.java +++ b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/context/BaseWorkerContext.java @@ -45,17 +45,21 @@ import org.hl7.fhir.r4.terminologies.ValueSetExpander.ValueSetExpansionOutcome; import org.hl7.fhir.r4.terminologies.ValueSetExpanderSimple; import org.hl7.fhir.r4.utils.ToolingExtensions; import org.hl7.fhir.utilities.OIDUtils; -import org.hl7.fhir.utilities.TerminologyServiceOptions; import org.hl7.fhir.utilities.TranslationServices; import org.hl7.fhir.utilities.Utilities; import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity; import org.hl7.fhir.utilities.validation.ValidationMessage.IssueType; +import org.hl7.fhir.utilities.validation.ValidationOptions; import java.io.FileNotFoundException; import java.io.IOException; -import java.util.*; - -import static org.apache.commons.lang3.StringUtils.isNotBlank; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; public abstract class BaseWorkerContext implements IWorkerContext { @@ -438,25 +442,25 @@ public abstract class BaseWorkerContext implements IWorkerContext { // --- validate code ------------------------------------------------------------------------------- @Override - public ValidationResult validateCode(TerminologyServiceOptions options, String system, String code, String display) { + public ValidationResult validateCode(ValidationOptions options, String system, String code, String display) { Coding c = new Coding(system, code, display); return validateCode(options, c, null); } @Override - public ValidationResult validateCode(TerminologyServiceOptions options, String system, String code, String display, ValueSet vs) { + public ValidationResult validateCode(ValidationOptions options, String system, String code, String display, ValueSet vs) { Coding c = new Coding(system, code, display); return validateCode(options, c, vs); } @Override - public ValidationResult validateCode(TerminologyServiceOptions options, String code, ValueSet vs) { + public ValidationResult validateCode(ValidationOptions options, String code, ValueSet vs) { Coding c = new Coding(null, code, null); return doValidateCode(options, c, vs, true); } @Override - public ValidationResult validateCode(TerminologyServiceOptions options, String system, String code, String display, ConceptSetComponent vsi) { + public ValidationResult validateCode(ValidationOptions options, String system, String code, String display, ConceptSetComponent vsi) { Coding c = new Coding(system, code, display); ValueSet vs = new ValueSet(); vs.setUrl(Utilities.makeUuidUrn()); @@ -465,11 +469,11 @@ public abstract class BaseWorkerContext implements IWorkerContext { } @Override - public ValidationResult validateCode(TerminologyServiceOptions options, Coding code, ValueSet vs) { + public ValidationResult validateCode(ValidationOptions options, Coding code, ValueSet vs) { return doValidateCode(options, code, vs, false); } - public ValidationResult doValidateCode(TerminologyServiceOptions options, Coding code, ValueSet vs, boolean implySystem) { + public ValidationResult doValidateCode(ValidationOptions options, Coding code, ValueSet vs, boolean implySystem) { CacheToken cacheToken = txCache != null ? txCache.generateValidationToken(options, code, vs) : null; ValidationResult res = null; if (txCache != null) @@ -511,7 +515,7 @@ public abstract class BaseWorkerContext implements IWorkerContext { return res; } - private void setTerminologyOptions(TerminologyServiceOptions options, Parameters pIn) { + private void setTerminologyOptions(ValidationOptions options, Parameters pIn) { if (options != null) { if (!Utilities.noString(options.getLanguage())) pIn.addParameter("displayLanguage", options.getLanguage()); @@ -519,7 +523,7 @@ public abstract class BaseWorkerContext implements IWorkerContext { } @Override - public ValidationResult validateCode(TerminologyServiceOptions options, CodeableConcept code, ValueSet vs) { + public ValidationResult validateCode(ValidationOptions options, CodeableConcept code, ValueSet vs) { CacheToken cacheToken = txCache.generateValidationToken(options, code, vs); ValidationResult res = txCache.getValidation(cacheToken); if (res != null) diff --git a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/context/IWorkerContext.java b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/context/IWorkerContext.java index 352b22927..765379522 100644 --- a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/context/IWorkerContext.java +++ b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/context/IWorkerContext.java @@ -51,6 +51,7 @@ import org.hl7.fhir.r4.utils.IResourceValidator; import org.hl7.fhir.utilities.TerminologyServiceOptions; import org.hl7.fhir.utilities.TranslationServices; import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity; +import org.hl7.fhir.utilities.validation.ValidationOptions; /** @@ -376,7 +377,7 @@ public interface IWorkerContext { * @param display * @return */ - public ValidationResult validateCode(TerminologyServiceOptions options, String system, String code, String display); + public ValidationResult validateCode(ValidationOptions options, String system, String code, String display); /** * Validation of a code - consult the terminology service @@ -392,10 +393,10 @@ public interface IWorkerContext { * @param display * @return */ - public ValidationResult validateCode(TerminologyServiceOptions options, String system, String code, String display, ValueSet vs); - public ValidationResult validateCode(TerminologyServiceOptions options, String code, ValueSet vs); - public ValidationResult validateCode(TerminologyServiceOptions options, Coding code, ValueSet vs); - public ValidationResult validateCode(TerminologyServiceOptions options, CodeableConcept code, ValueSet vs); + public ValidationResult validateCode(ValidationOptions options, String system, String code, String display, ValueSet vs); + public ValidationResult validateCode(ValidationOptions options, String code, ValueSet vs); + public ValidationResult validateCode(ValidationOptions options, Coding code, ValueSet vs); + public ValidationResult validateCode(ValidationOptions options, CodeableConcept code, ValueSet vs); /** * Validation of a code - consult the terminology service @@ -411,7 +412,7 @@ public interface IWorkerContext { * @param display * @return */ - public ValidationResult validateCode(TerminologyServiceOptions options, String system, String code, String display, ConceptSetComponent vsi); + public ValidationResult validateCode(ValidationOptions options, String system, String code, String display, ConceptSetComponent vsi); /** * returns the recommended tla for the type diff --git a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/context/TerminologyCache.java b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/context/TerminologyCache.java index b5f7df446..3939dc4f5 100644 --- a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/context/TerminologyCache.java +++ b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/context/TerminologyCache.java @@ -46,7 +46,6 @@ import org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionContainsComponent; import org.hl7.fhir.r4.terminologies.ValueSetExpander.TerminologyServiceErrorClass; import org.hl7.fhir.r4.terminologies.ValueSetExpander.ValueSetExpansionOutcome; import org.hl7.fhir.utilities.CommaSeparatedStringBuilder; -import org.hl7.fhir.utilities.TerminologyServiceOptions; import org.hl7.fhir.utilities.TextFile; import org.hl7.fhir.utilities.Utilities; import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity; @@ -55,6 +54,7 @@ import com.google.gson.JsonElement; import com.google.gson.JsonNull; import com.google.gson.JsonObject; import com.google.gson.JsonPrimitive; +import org.hl7.fhir.utilities.validation.ValidationOptions; /** * This implements a two level cache. @@ -112,7 +112,7 @@ public class TerminologyCache { load(); } - public CacheToken generateValidationToken(TerminologyServiceOptions options, Coding code, ValueSet vs) { + public CacheToken generateValidationToken(ValidationOptions options, Coding code, ValueSet vs) { CacheToken ct = new CacheToken(); if (code.hasSystem()) ct.name = getNameForSystem(code.getSystem()); @@ -130,7 +130,7 @@ public class TerminologyCache { return ct; } - public CacheToken generateValidationToken(TerminologyServiceOptions options, CodeableConcept code, ValueSet vs) { + public CacheToken generateValidationToken(ValidationOptions options, CodeableConcept code, ValueSet vs) { CacheToken ct = new CacheToken(); for (Coding c : code.getCoding()) { if (c.hasSystem()) diff --git a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/terminologies/ValueSetCheckerSimple.java b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/terminologies/ValueSetCheckerSimple.java index 084d4dd40..ceb1b70e6 100644 --- a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/terminologies/ValueSetCheckerSimple.java +++ b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/terminologies/ValueSetCheckerSimple.java @@ -30,8 +30,8 @@ import org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionComponent; import org.hl7.fhir.r4.model.CodeSystem.ConceptDefinitionDesignationComponent; import org.hl7.fhir.r4.model.ValueSet.*; import org.hl7.fhir.utilities.CommaSeparatedStringBuilder; -import org.hl7.fhir.utilities.TerminologyServiceOptions; import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity; +import org.hl7.fhir.utilities.validation.ValidationOptions; import java.util.ArrayList; import java.util.HashMap; @@ -43,9 +43,9 @@ public class ValueSetCheckerSimple implements ValueSetChecker { private ValueSet valueset; private IWorkerContext context; private Map inner = new HashMap<>(); - private TerminologyServiceOptions options; + private ValidationOptions options; - public ValueSetCheckerSimple(TerminologyServiceOptions options, ValueSet source, IWorkerContext context) { + public ValueSetCheckerSimple(ValidationOptions options, ValueSet source, IWorkerContext context) { this.valueset = source; this.context = context; this.options = options; diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java index 14e7deb92..867f39771 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java @@ -83,7 +83,6 @@ import org.hl7.fhir.r5.terminologies.ValueSetExpanderSimple; import org.hl7.fhir.r5.utils.ToolingExtensions; import org.hl7.fhir.r5.utils.client.ToolingClientLogger; import org.hl7.fhir.utilities.OIDUtils; -import org.hl7.fhir.utilities.TerminologyServiceOptions; import org.hl7.fhir.utilities.TranslationServices; import org.hl7.fhir.utilities.Utilities; import org.hl7.fhir.utilities.VersionUtilities; diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/IWorkerContext.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/IWorkerContext.java index 242055e44..0b500b26e 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/IWorkerContext.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/IWorkerContext.java @@ -51,7 +51,6 @@ import org.hl7.fhir.r5.terminologies.ValueSetExpander.TerminologyServiceErrorCla import org.hl7.fhir.r5.terminologies.ValueSetExpander.ValueSetExpansionOutcome; import org.hl7.fhir.r5.utils.INarrativeGenerator; import org.hl7.fhir.r5.utils.IResourceValidator; -import org.hl7.fhir.utilities.TerminologyServiceOptions; import org.hl7.fhir.utilities.TranslationServices; import org.hl7.fhir.utilities.validation.ValidationOptions; import org.hl7.fhir.utilities.validation.ValidationMessage.IssueSeverity; diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ValueSetCheckerSimple.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ValueSetCheckerSimple.java index bca063a1d..2cefc64ce 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ValueSetCheckerSimple.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ValueSetCheckerSimple.java @@ -45,7 +45,6 @@ import org.hl7.fhir.r5.model.ValueSet.ConceptSetComponent; import org.hl7.fhir.r5.model.ValueSet.ConceptSetFilterComponent; import org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent; import org.hl7.fhir.utilities.CommaSeparatedStringBuilder; -import org.hl7.fhir.utilities.TerminologyServiceOptions; import org.hl7.fhir.utilities.Utilities; import org.hl7.fhir.utilities.validation.ValidationOptions; import org.hl7.fhir.utilities.validation.ValidationOptions.ValueSetMode; diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/BaseValidator.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/BaseValidator.java index c95e1f364..1a0b6e97a 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/BaseValidator.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/BaseValidator.java @@ -171,7 +171,8 @@ public class BaseValidator { */ protected boolean hint(List errors, IssueType type, int line, int col, String path, boolean thePass, String msg) { if (!thePass) { - addValidationMessage(errors, type, line, col, path, msg, IssueSeverity.INFORMATION); + String message = formatMessage(msg); + addValidationMessage(errors, type, line, col, path, message, IssueSeverity.INFORMATION); } return thePass; } 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 f6a1dd599..c85dcde3d 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 @@ -2018,7 +2018,8 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat long t = System.nanoTime(); ValidationResult vr = null; if (binding.getStrength() != BindingStrength.EXAMPLE) { - vr = context.validateCode(new ValidationOptions(stack.workingLang), value, vs); + ValidationOptions options = new ValidationOptions(stack.workingLang).guessSystem(); + vr = context.validateCode(options, value, vs); } txTime = txTime + (System.nanoTime() - t); if (vr != null && !vr.isOk()) {