From c57f578f03277b1eac06927df378a65c03c41f52 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Tue, 6 Aug 2019 07:33:48 +1000 Subject: [PATCH] Move TerminologyServiceOptions to Utilities. --- .../hl7/fhir/r5/conformance/ProfileUtilities.java | 2 +- .../hl7/fhir/r5/context/BaseWorkerContext.java | 15 ++++++++++----- .../org/hl7/fhir/r5/context/IWorkerContext.java | 2 +- .../org/hl7/fhir/r5/context/TerminologyCache.java | 2 +- .../r5/terminologies/ValueSetCheckerSimple.java | 1 + .../org/hl7/fhir/r5/utils/FHIRPathEngine.java | 2 +- .../org/hl7/fhir/r5/utils/NarrativeGenerator.java | 2 +- .../hl7/fhir/r5/utils/StructureMapUtilities.java | 2 +- .../utilities}/TerminologyServiceOptions.java | 12 +----------- .../hl7/fhir/r5/validation/InstanceValidator.java | 2 +- 10 files changed, 19 insertions(+), 23 deletions(-) rename {org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies => org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities}/TerminologyServiceOptions.java (80%) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/ProfileUtilities.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/ProfileUtilities.java index 8424b0b6a..791f450de 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/ProfileUtilities.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/ProfileUtilities.java @@ -84,7 +84,6 @@ import org.hl7.fhir.r5.model.UriType; import org.hl7.fhir.r5.model.ValueSet; import org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionComponent; import org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent; -import org.hl7.fhir.r5.terminologies.TerminologyServiceOptions; import org.hl7.fhir.r5.terminologies.ValueSetExpander.ValueSetExpansionOutcome; import org.hl7.fhir.r5.utils.NarrativeGenerator; import org.hl7.fhir.r5.utils.ToolingExtensions; @@ -92,6 +91,7 @@ import org.hl7.fhir.r5.utils.TranslatingUtilities; import org.hl7.fhir.r5.utils.formats.CSVWriter; import org.hl7.fhir.r5.utils.formats.XLSXWriter; import org.hl7.fhir.utilities.CommaSeparatedStringBuilder; +import org.hl7.fhir.utilities.TerminologyServiceOptions; import org.hl7.fhir.utilities.Utilities; import org.hl7.fhir.utilities.validation.ValidationMessage; import org.hl7.fhir.utilities.validation.ValidationMessage.Source; 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 8e79ce9f1..bc0efda82 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 @@ -69,13 +69,13 @@ import org.hl7.fhir.r5.model.ValueSet; import org.hl7.fhir.r5.model.ValueSet.ConceptSetComponent; import org.hl7.fhir.r5.model.ValueSet.ValueSetComposeComponent; import org.hl7.fhir.r5.terminologies.TerminologyClient; -import org.hl7.fhir.r5.terminologies.TerminologyServiceOptions; import org.hl7.fhir.r5.terminologies.ValueSetCheckerSimple; import org.hl7.fhir.r5.terminologies.ValueSetExpander.TerminologyServiceErrorClass; import org.hl7.fhir.r5.terminologies.ValueSetExpander.ValueSetExpansionOutcome; import org.hl7.fhir.r5.terminologies.ValueSetExpanderSimple; import org.hl7.fhir.r5.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; @@ -526,8 +526,7 @@ public abstract class BaseWorkerContext implements IWorkerContext { pIn.addParameter().setName("coding").setValue(code); if (implySystem) pIn.addParameter().setName("implySystem").setValue(new BooleanType(true)); - if (options != null) - options.updateParameters(pIn); + setTerminologyOptions(options, pIn); res = validateOnServer(vs, pIn); } catch (Exception e) { res = new ValidationResult(IssueSeverity.ERROR, e.getMessage() == null ? e.getClass().getName() : e.getMessage()).setTxLink(txLog == null ? null : txLog.getLastId()); @@ -537,6 +536,13 @@ public abstract class BaseWorkerContext implements IWorkerContext { return res; } + private void setTerminologyOptions(TerminologyServiceOptions options, Parameters pIn) { + if (options != null) { + if (!Utilities.noString(options.getLanguage())) + pIn.addParameter("displayLanguage", options.getLanguage()); + } + } + @Override public ValidationResult validateCode(TerminologyServiceOptions options, CodeableConcept code, ValueSet vs) { CacheToken cacheToken = txCache.generateValidationToken(options, code, vs); @@ -560,8 +566,7 @@ public abstract class BaseWorkerContext implements IWorkerContext { try { Parameters pIn = new Parameters(); pIn.addParameter().setName("codeableConcept").setValue(code); - if (options != null) - options.updateParameters(pIn); + setTerminologyOptions(options, pIn); res = validateOnServer(vs, pIn); } catch (Exception e) { res = new ValidationResult(IssueSeverity.ERROR, e.getMessage() == null ? e.getClass().getName() : e.getMessage()).setTxLink(txLog.getLastId()); 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 30fb3dfb0..095071022 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 @@ -44,11 +44,11 @@ import org.hl7.fhir.r5.model.StructureDefinition; import org.hl7.fhir.r5.model.StructureMap; import org.hl7.fhir.r5.model.ValueSet; import org.hl7.fhir.r5.model.ValueSet.ConceptSetComponent; -import org.hl7.fhir.r5.terminologies.TerminologyServiceOptions; import org.hl7.fhir.r5.terminologies.ValueSetExpander.TerminologyServiceErrorClass; 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.ValidationMessage.IssueSeverity; diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/TerminologyCache.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/TerminologyCache.java index 387c087d7..52642d609 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/TerminologyCache.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/TerminologyCache.java @@ -43,10 +43,10 @@ import org.hl7.fhir.r5.model.ValueSet; 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.r5.terminologies.TerminologyServiceOptions; import org.hl7.fhir.r5.terminologies.ValueSetExpander.TerminologyServiceErrorClass; import org.hl7.fhir.r5.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; 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 659661a0b..8dfb89064 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 @@ -44,6 +44,7 @@ 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.validation.ValidationMessage.IssueSeverity; public class ValueSetCheckerSimple implements ValueSetChecker { diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/FHIRPathEngine.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/FHIRPathEngine.java index a8d41eb5b..8855976ca 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/FHIRPathEngine.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/FHIRPathEngine.java @@ -17,9 +17,9 @@ import org.hl7.fhir.r5.model.ExpressionNode.*; import org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind; import org.hl7.fhir.r5.model.StructureDefinition.TypeDerivationRule; import org.hl7.fhir.r5.model.TypeDetails.ProfiledType; -import org.hl7.fhir.r5.terminologies.TerminologyServiceOptions; import org.hl7.fhir.r5.utils.FHIRLexer.FHIRLexerException; import org.hl7.fhir.r5.utils.FHIRPathEngine.IEvaluationContext.FunctionDetails; +import org.hl7.fhir.utilities.TerminologyServiceOptions; import org.hl7.fhir.utilities.Utilities; import java.math.BigDecimal; diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/NarrativeGenerator.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/NarrativeGenerator.java index b039992af..07bc9eff8 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/NarrativeGenerator.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/NarrativeGenerator.java @@ -175,13 +175,13 @@ import org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionComponent; import org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent; import org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionParameterComponent; import org.hl7.fhir.r5.terminologies.CodeSystemUtilities; -import org.hl7.fhir.r5.terminologies.TerminologyServiceOptions; import org.hl7.fhir.r5.terminologies.ValueSetExpander.ValueSetExpansionOutcome; import org.hl7.fhir.r5.utils.FHIRPathEngine.IEvaluationContext; import org.hl7.fhir.r5.utils.LiquidEngine.LiquidDocument; import org.hl7.fhir.r5.utils.NarrativeGenerator.ILiquidTemplateProvider; import org.hl7.fhir.utilities.CommaSeparatedStringBuilder; import org.hl7.fhir.utilities.MarkDownProcessor; +import org.hl7.fhir.utilities.TerminologyServiceOptions; import org.hl7.fhir.utilities.MarkDownProcessor.Dialect; import org.hl7.fhir.utilities.Utilities; import org.hl7.fhir.utilities.xhtml.NodeType; diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/StructureMapUtilities.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/StructureMapUtilities.java index a39a63444..27352afb0 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/StructureMapUtilities.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/StructureMapUtilities.java @@ -102,11 +102,11 @@ import org.hl7.fhir.r5.model.TypeDetails.ProfiledType; import org.hl7.fhir.r5.model.UriType; import org.hl7.fhir.r5.model.ValueSet; import org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent; -import org.hl7.fhir.r5.terminologies.TerminologyServiceOptions; import org.hl7.fhir.r5.terminologies.ValueSetExpander.ValueSetExpansionOutcome; import org.hl7.fhir.r5.utils.FHIRLexer.FHIRLexerException; import org.hl7.fhir.r5.utils.FHIRPathEngine.IEvaluationContext; import org.hl7.fhir.utilities.CommaSeparatedStringBuilder; +import org.hl7.fhir.utilities.TerminologyServiceOptions; import org.hl7.fhir.utilities.Utilities; import org.hl7.fhir.utilities.validation.ValidationMessage; import org.hl7.fhir.utilities.xhtml.NodeType; diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/TerminologyServiceOptions.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/TerminologyServiceOptions.java similarity index 80% rename from org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/TerminologyServiceOptions.java rename to org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/TerminologyServiceOptions.java index 73008f5d6..fcaa9b5cb 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/TerminologyServiceOptions.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/TerminologyServiceOptions.java @@ -1,4 +1,4 @@ -package org.hl7.fhir.r5.terminologies; +package org.hl7.fhir.utilities; /*- * #%L @@ -20,10 +20,6 @@ package org.hl7.fhir.r5.terminologies; * #L% */ - -import org.fhir.ucum.Utilities; -import org.hl7.fhir.r5.model.Parameters; - public class TerminologyServiceOptions { private String language; @@ -48,10 +44,4 @@ public class TerminologyServiceOptions { return "\"lang\":\""+language+"\""; } - public void updateParameters(Parameters pIn) { - if (!Utilities.noString(language)) - pIn.addParameter("displayLanguage", language); - - } - } diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/InstanceValidator.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/InstanceValidator.java index 14106c6c0..e852c20a2 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/InstanceValidator.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/InstanceValidator.java @@ -122,7 +122,6 @@ import org.hl7.fhir.r5.model.TypeDetails; import org.hl7.fhir.r5.model.UriType; import org.hl7.fhir.r5.model.ValueSet; import org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionContainsComponent; -import org.hl7.fhir.r5.terminologies.TerminologyServiceOptions; import org.hl7.fhir.r5.test.utils.TestingUtilities; import org.hl7.fhir.r5.utils.FHIRLexer.FHIRLexerException; import org.hl7.fhir.r5.utils.FHIRPathEngine; @@ -134,6 +133,7 @@ import org.hl7.fhir.r5.utils.ValidationProfileSet.ProfileRegistration; import org.hl7.fhir.r5.utils.Version; import org.hl7.fhir.r5.validation.EnableWhenEvaluator.QStack; import org.hl7.fhir.utilities.CommaSeparatedStringBuilder; +import org.hl7.fhir.utilities.TerminologyServiceOptions; import org.hl7.fhir.utilities.Utilities; import org.hl7.fhir.utilities.Utilities.DecimalStatus; import org.hl7.fhir.utilities.validation.ValidationMessage;