diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 16e5152e8..7b06c6ab5 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -4,4 +4,4 @@ ## Other code changes -* fix various rendering issues from core spec +* no changes \ No newline at end of file diff --git a/org.hl7.fhir.convertors/pom.xml b/org.hl7.fhir.convertors/pom.xml index e31ec043f..4a8f14076 100644 --- a/org.hl7.fhir.convertors/pom.xml +++ b/org.hl7.fhir.convertors/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.6.35 + 5.6.37-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.dstu2/pom.xml b/org.hl7.fhir.dstu2/pom.xml index 93f5679c5..e31fd4a19 100644 --- a/org.hl7.fhir.dstu2/pom.xml +++ b/org.hl7.fhir.dstu2/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.6.35 + 5.6.37-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.dstu2016may/pom.xml b/org.hl7.fhir.dstu2016may/pom.xml index 697d2a970..7bb4e757d 100644 --- a/org.hl7.fhir.dstu2016may/pom.xml +++ b/org.hl7.fhir.dstu2016may/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.6.35 + 5.6.37-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.dstu3/pom.xml b/org.hl7.fhir.dstu3/pom.xml index 25569ca06..f2da5a89d 100644 --- a/org.hl7.fhir.dstu3/pom.xml +++ b/org.hl7.fhir.dstu3/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.6.35 + 5.6.37-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.dstu3/src/main/java/org/hl7/fhir/dstu3/utils/FHIRPathEngine.java b/org.hl7.fhir.dstu3/src/main/java/org/hl7/fhir/dstu3/utils/FHIRPathEngine.java index 7794fc858..54191747f 100644 --- a/org.hl7.fhir.dstu3/src/main/java/org/hl7/fhir/dstu3/utils/FHIRPathEngine.java +++ b/org.hl7.fhir.dstu3/src/main/java/org/hl7/fhir/dstu3/utils/FHIRPathEngine.java @@ -2219,7 +2219,7 @@ public class FHIRPathEngine { if (!Utilities.noString(f)) { - if (exp.getParameters().size() != 2) { + if (exp.getParameters().size() == 2) { String t = convertToString(execute(context, focus, exp.getParameters().get(0), true)); String r = convertToString(execute(context, focus, exp.getParameters().get(1), true)); diff --git a/org.hl7.fhir.dstu3/src/test/java/org/hl7/fhir/dstu3/utils/FhirPathTests.java b/org.hl7.fhir.dstu3/src/test/java/org/hl7/fhir/dstu3/utils/FhirPathTests.java new file mode 100644 index 000000000..f595e238a --- /dev/null +++ b/org.hl7.fhir.dstu3/src/test/java/org/hl7/fhir/dstu3/utils/FhirPathTests.java @@ -0,0 +1,61 @@ +package org.hl7.fhir.dstu3.utils; + +import org.hl7.fhir.dstu3.context.IWorkerContext; +import org.hl7.fhir.dstu3.model.Base; +import org.hl7.fhir.dstu3.model.ExpressionNode; +import org.hl7.fhir.dstu3.model.StringType; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.junit.jupiter.MockitoExtension; + +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.times; + +@ExtendWith(MockitoExtension.class) +public class FhirPathTests { + + @Mock + IWorkerContext iWorkerContext; + + @Mock + Object appContext; + + @Mock + Base resource; + + @Mock + Base base; + + @Test + public void testFuncReplaceParamSize() { + FHIRPathEngine engine = Mockito.spy(new FHIRPathEngine(iWorkerContext)); + + ExpressionNode expressionNode = new ExpressionNode(0); + expressionNode.setKind(ExpressionNode.Kind.Function); + expressionNode.setFunction(ExpressionNode.Function.Replace); + + ExpressionNode expressionNodeB = new ExpressionNode(1); + expressionNodeB.setKind(ExpressionNode.Kind.Function); + expressionNodeB.setFunction(ExpressionNode.Function.Empty); + + ExpressionNode expressionNodeC = new ExpressionNode(2); + expressionNodeC.setKind(ExpressionNode.Kind.Function); + expressionNodeC.setFunction(ExpressionNode.Function.Empty); + + expressionNode.getParameters().add(expressionNodeB); + expressionNode.getParameters().add(expressionNodeC); + List result = engine.evaluate(appContext, resource, base, expressionNode); + + assertEquals(1, result.size()); + Base onlyResult = result.get(0); + assertTrue(onlyResult instanceof StringType); + assertEquals("base", ((StringType)result.get(0)).asStringValue()); + Mockito.verify(engine, times(2)).convertToString(any()); + } +} \ No newline at end of file diff --git a/org.hl7.fhir.r4/pom.xml b/org.hl7.fhir.r4/pom.xml index f4d43de96..b5a55706f 100644 --- a/org.hl7.fhir.r4/pom.xml +++ b/org.hl7.fhir.r4/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.6.35 + 5.6.37-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/model/FhirPublication.java b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/model/FhirPublication.java index bc8dfe581..6ccf8fd4b 100644 --- a/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/model/FhirPublication.java +++ b/org.hl7.fhir.r4/src/main/java/org/hl7/fhir/r4/model/FhirPublication.java @@ -49,7 +49,7 @@ public enum FhirPublication { R4; public static FhirPublication fromCode(String v) { - if (VersionUtilities.isR4Ver(v)) + if (VersionUtilities.isR2Ver(v)) return FhirPublication.DSTU2; if ("1.0".equals(v)) return FhirPublication.DSTU2; diff --git a/org.hl7.fhir.r4b/pom.xml b/org.hl7.fhir.r4b/pom.xml index a06b23830..5ed3f9ff0 100644 --- a/org.hl7.fhir.r4b/pom.xml +++ b/org.hl7.fhir.r4b/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.6.35 + 5.6.37-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.r5/pom.xml b/org.hl7.fhir.r5/pom.xml index d31503c1b..34bd8e422 100644 --- a/org.hl7.fhir.r5/pom.xml +++ b/org.hl7.fhir.r5/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.6.35 + 5.6.37-SNAPSHOT ../pom.xml 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 4ae77cd7c..9114a51b9 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 @@ -666,10 +666,11 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte @Override - public ValueSetExpansionOutcome expandVS(ConceptSetComponent inc, boolean hierarchical) throws TerminologyServiceException { + public ValueSetExpansionOutcome expandVS(ConceptSetComponent inc, boolean hierarchical, boolean noInactive) throws TerminologyServiceException { ValueSet vs = new ValueSet(); vs.setStatus(PublicationStatus.ACTIVE); vs.setCompose(new ValueSetComposeComponent()); + vs.getCompose().setInactive(!noInactive); vs.getCompose().getInclude().add(inc); CacheToken cacheToken = txCache.generateExpandToken(vs, hierarchical); ValueSetExpansionOutcome res; diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/CanonicalResourceManager.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/CanonicalResourceManager.java index a781cc776..34da6eb7a 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/CanonicalResourceManager.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/CanonicalResourceManager.java @@ -124,6 +124,9 @@ public class CanonicalResourceManager { if (resource == null) { @SuppressWarnings("unchecked") T1 res = (T1) proxy.getResource(); + if (res == null) { + throw new Error("Proxy loading a resource from "+packageInfo+" failed and returned null"); + } synchronized (this) { resource = res; } 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 ae95c7b40..242856766 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 @@ -547,7 +547,7 @@ public interface IWorkerContext { * @return * @throws FHIRException */ - ValueSetExpansionOutcome expandVS(ConceptSetComponent inc, boolean hierarchical) throws TerminologyServiceException; + ValueSetExpansionOutcome expandVS(ConceptSetComponent inc, boolean hierarchical, boolean noInactive) throws TerminologyServiceException; Locale getLocale(); diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/Enumerations.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/Enumerations.java index 7728bc7ca..8aedc92c1 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/Enumerations.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/Enumerations.java @@ -6925,9 +6925,9 @@ The primary difference between a medicationusage and a medicationadministration return _4_1_0; if ("4.2.0".equals(codeString)) return _4_2_0; - if ("4.3.0-snapshot1".equals(codeString)) + if ("4.3.0-snapshot1".equalsIgnoreCase(codeString)) return _4_3_0SNAPSHOT1; - if ("4.3.0-cibuild".equals(codeString)) + if ("4.3.0-cibuild".equalsIgnoreCase(codeString)) return _4_3_0CIBUILD; if ("4.4.0".equals(codeString)) return _4_4_0; @@ -6935,9 +6935,9 @@ The primary difference between a medicationusage and a medicationadministration return _4_5_0; if ("4.6.0".equals(codeString)) return _4_6_0; - if ("5.0.0-snapshot1".equals(codeString)) + if ("5.0.0-snapshot1".equalsIgnoreCase(codeString)) return _5_0_0SNAPSHOT1; - if ("5.0.0-cibuild".equals(codeString)) + if ("5.0.0-cibuild".equalsIgnoreCase(codeString)) return _5_0_0CIBUILD; throw new FHIRException("Unknown FHIRVersion code '"+codeString+"'"); } @@ -7160,7 +7160,7 @@ public String toCode(int len) { public boolean isR4B() { - return toCode().startsWith("4.1"); + return toCode().startsWith("4.1") ||toCode().startsWith("4.3"); } // end addition @@ -7222,9 +7222,9 @@ public String toCode(int len) { return FHIRVersion._4_1_0; if ("4.2.0".equals(codeString)) return FHIRVersion._4_2_0; - if ("4.3.0-snapshot1".equals(codeString)) + if ("4.3.0-snapshot1".equalsIgnoreCase(codeString)) return FHIRVersion._4_3_0SNAPSHOT1; - if ("4.3.0-cibuild".equals(codeString)) + if ("4.3.0-cibuild".equalsIgnoreCase(codeString)) return FHIRVersion._4_3_0CIBUILD; if ("4.4.0".equals(codeString)) return FHIRVersion._4_4_0; @@ -7232,9 +7232,9 @@ public String toCode(int len) { return FHIRVersion._4_5_0; if ("4.6.0".equals(codeString)) return FHIRVersion._4_6_0; - if ("5.0.0-snapshot1".equals(codeString)) + if ("5.0.0-snapshot1".equalsIgnoreCase(codeString)) return FHIRVersion._5_0_0SNAPSHOT1; - if ("5.0.0-cibuild".equals(codeString)) + if ("5.0.0-cibuild".equalsIgnoreCase(codeString)) return FHIRVersion._5_0_0CIBUILD; throw new IllegalArgumentException("Unknown FHIRVersion code '"+codeString+"'"); } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/LiquidRenderer.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/LiquidRenderer.java index 78893a2b4..bc8eb4caa 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/LiquidRenderer.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/LiquidRenderer.java @@ -32,12 +32,30 @@ public class LiquidRenderer extends ResourceRenderer { this.rcontext = rcontext; this.liquidTemplate = liquidTemplate; } + + /** + * This class provides an implementation of the ILiquidEngineIncludeResolver that makes use of the + * template provider available in the rendering context to support resolving includes. + */ + private class LiquidRendererIncludeResolver implements LiquidEngine.ILiquidEngineIncludeResolver { + public LiquidRendererIncludeResolver(RenderingContext context) { + this.context = context; + } + + private RenderingContext context; + + @Override + public String fetchInclude(LiquidEngine engine, String name) { + return context.getTemplateProvider().findTemplate(context, name); + } + } @Override public boolean render(XhtmlNode x, Resource r) throws FHIRFormatError, DefinitionException, IOException, FHIRException, EOperationOutcome { LiquidEngine engine = new LiquidEngine(context.getWorker(), context.getServices()); XhtmlNode xn; try { + engine.setIncludeResolver(new LiquidRendererIncludeResolver(context)); LiquidDocument doc = engine.parse(liquidTemplate, "template"); String html = engine.evaluate(doc, r, rcontext); xn = new XhtmlParser().parseFragment(html); diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/ValueSetRenderer.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/ValueSetRenderer.java index 869a19907..3e07a1819 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/ValueSetRenderer.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/renderers/ValueSetRenderer.java @@ -213,7 +213,7 @@ public class ValueSetRenderer extends TerminologyRenderer { XhtmlNode t = x.table( "codes"); XhtmlNode tr = t.tr(); if (doLevel) - tr.td().b().tx("Lvl"); + tr.td().b().tx("Level"); tr.td().attribute("style", "white-space:nowrap").b().tx("Code"); if (doSystem) tr.td().b().tx("System"); @@ -242,7 +242,7 @@ public class ValueSetRenderer extends TerminologyRenderer { addMapHeaders(tr, maps); for (ValueSetExpansionContainsComponent c : vs.getExpansion().getContains()) { - addExpansionRowToTable(t, c, 0, doLevel, doSystem, doDefinition, maps, allCS, langs, doLangs); + addExpansionRowToTable(t, c, 1, doLevel, doSystem, doDefinition, maps, allCS, langs, doLangs); } // now, build observed languages @@ -1165,7 +1165,7 @@ public class ValueSetRenderer extends TerminologyRenderer { ValueSetExpansionComponent vse = null; if (!context.isNoSlowLookup() && !getContext().getWorker().hasCache()) { try { - ValueSetExpansionOutcome vso = getContext().getWorker().expandVS(inc, false); + ValueSetExpansionOutcome vso = getContext().getWorker().expandVS(inc, false, false); ValueSet valueset = vso.getValueset(); if (valueset == null) throw new TerminologyServiceException("Error Expanding ValueSet: "+vso.getError()); diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/CodeSystemUtilities.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/CodeSystemUtilities.java index b64be0281..5d8cea6a5 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/CodeSystemUtilities.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/CodeSystemUtilities.java @@ -249,7 +249,7 @@ public class CodeSystemUtilities { public static boolean isInactive(CodeSystem cs, ConceptDefinitionComponent def) throws FHIRException { for (ConceptPropertyComponent p : def.getProperty()) { if ("status".equals(p.getCode()) && p.hasValueStringType()) - return "inactive".equals(p.getValueStringType()); + return "inactive".equals(p.getValueStringType().primitiveValue()) || "retired".equals(p.getValueStringType().primitiveValue()); } return false; } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ValueSetExpanderSimple.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ValueSetExpanderSimple.java index bd45f5cac..1bfe96ff6 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ValueSetExpanderSimple.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/terminologies/ValueSetExpanderSimple.java @@ -108,6 +108,8 @@ import org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionParameterComponent; import org.hl7.fhir.r5.utils.ToolingExtensions; import org.hl7.fhir.utilities.Utilities; +import com.google.errorprone.annotations.NoAllocation; + public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetExpander { public class PropertyFilter implements IConceptFilter { @@ -201,10 +203,15 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx maxExpansionSize = theMaxExpansionSize; } - private ValueSetExpansionContainsComponent addCode(String system, String code, String display, ValueSetExpansionContainsComponent parent, List designations, Parameters expParams, boolean isAbstract, boolean inactive, List filters) { + private ValueSetExpansionContainsComponent addCode(String system, String code, String display, ValueSetExpansionContainsComponent parent, List designations, Parameters expParams, + boolean isAbstract, boolean inactive, List filters, boolean noInactive) { if (filters != null && !filters.isEmpty() && !filterContainsCode(filters, system, code)) return null; + if (noInactive && inactive) { + return null; + } + ValueSetExpansionContainsComponent n = new ValueSet.ValueSetExpansionContainsComponent(); n.setSystem(system); n.setCode(code); @@ -267,12 +274,12 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx return null; } - private void addCodeAndDescendents(ValueSetExpansionContainsComponent focus, ValueSetExpansionContainsComponent parent, Parameters expParams, List filters) throws FHIRException { + private void addCodeAndDescendents(ValueSetExpansionContainsComponent focus, ValueSetExpansionContainsComponent parent, Parameters expParams, List filters, boolean noInactive) throws FHIRException { focus.checkNoModifiers("Expansion.contains", "expanding"); ValueSetExpansionContainsComponent np = addCode(focus.getSystem(), focus.getCode(), focus.getDisplay(), parent, - convert(focus.getDesignation()), expParams, focus.getAbstract(), focus.getInactive(), filters); + convert(focus.getDesignation()), expParams, focus.getAbstract(), focus.getInactive(), filters, noInactive); for (ValueSetExpansionContainsComponent c : focus.getContains()) - addCodeAndDescendents(focus, np, expParams, filters); + addCodeAndDescendents(focus, np, expParams, filters, noInactive); } private List convert(List designations) { @@ -287,7 +294,7 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx return list; } - private void addCodeAndDescendents(CodeSystem cs, String system, ConceptDefinitionComponent def, ValueSetExpansionContainsComponent parent, Parameters expParams, List filters, ConceptDefinitionComponent exclusion, IConceptFilter filterFunc) throws FHIRException { + private void addCodeAndDescendents(CodeSystem cs, String system, ConceptDefinitionComponent def, ValueSetExpansionContainsComponent parent, Parameters expParams, List filters, ConceptDefinitionComponent exclusion, IConceptFilter filterFunc, boolean noInactive) throws FHIRException { def.checkNoModifiers("Code in Code System", "expanding"); if (exclusion != null) { if (exclusion.getCode().equals(def.getCode())) @@ -298,30 +305,30 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx boolean abs = CodeSystemUtilities.isNotSelectable(cs, def); boolean inc = CodeSystemUtilities.isInactive(cs, def); if ((includeAbstract || !abs) && filterFunc.includeConcept(cs, def)) { - np = addCode(system, def.getCode(), def.getDisplay(), parent, def.getDesignation(), expParams, abs, inc, filters); + np = addCode(system, def.getCode(), def.getDisplay(), parent, def.getDesignation(), expParams, abs, inc, filters, noInactive); } for (ConceptDefinitionComponent c : def.getConcept()) { - addCodeAndDescendents(cs, system, c, np, expParams, filters, exclusion, filterFunc); + addCodeAndDescendents(cs, system, c, np, expParams, filters, exclusion, filterFunc, noInactive); } if (def.hasUserData(CodeSystemUtilities.USER_DATA_CROSS_LINK)) { List children = (List) def.getUserData(CodeSystemUtilities.USER_DATA_CROSS_LINK); for (ConceptDefinitionComponent c : children) - addCodeAndDescendents(cs, system, c, np, expParams, filters, exclusion, filterFunc); + addCodeAndDescendents(cs, system, c, np, expParams, filters, exclusion, filterFunc, noInactive); } } else { for (ConceptDefinitionComponent c : def.getConcept()) { - addCodeAndDescendents(cs, system, c, null, expParams, filters, exclusion, filterFunc); + addCodeAndDescendents(cs, system, c, null, expParams, filters, exclusion, filterFunc, noInactive); } if (def.hasUserData(CodeSystemUtilities.USER_DATA_CROSS_LINK)) { List children = (List) def.getUserData(CodeSystemUtilities.USER_DATA_CROSS_LINK); for (ConceptDefinitionComponent c : children) - addCodeAndDescendents(cs, system, c, null, expParams, filters, exclusion, filterFunc); + addCodeAndDescendents(cs, system, c, null, expParams, filters, exclusion, filterFunc, noInactive); } } } - private void addCodes(ValueSetExpansionComponent expand, List params, Parameters expParams, List filters) throws ETooCostly, FHIRException { + private void addCodes(ValueSetExpansionComponent expand, List params, Parameters expParams, List filters, boolean noInactive) throws ETooCostly, FHIRException { if (expand != null) { if (expand.getContains().size() > maxExpansionSize) throw failCostly("Too many codes to display (>" + Integer.toString(expand.getContains().size()) + ")"); @@ -330,7 +337,7 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx params.add(p); } - copyImportContains(expand.getContains(), null, expParams, filters); + copyImportContains(expand.getContains(), null, expParams, filters, noInactive); } } @@ -354,7 +361,7 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx CodeSystem cs = context.fetchCodeSystem(exc.getSystem()); if ((cs == null || cs.getContent() != CodeSystemContentMode.COMPLETE) && context.supportsSystem(exc.getSystem())) { - ValueSetExpansionOutcome vse = context.expandVS(exc, false); + ValueSetExpansionOutcome vse = context.expandVS(exc, false, false); ValueSet valueset = vse.getValueset(); if (valueset == null) throw failTSE("Error Expanding ValueSet: "+vse.getError()); @@ -474,11 +481,11 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx first = false; else canBeHeirarchy = false; - includeCodes(inc, exp, expParams, canBeHeirarchy, extensions); + includeCodes(inc, exp, expParams, canBeHeirarchy, compose.hasInactive() && !compose.getInactive(), extensions); } } - private ValueSet importValueSet(String value, ValueSetExpansionComponent exp, Parameters expParams) throws ETooCostly, TerminologyServiceException, FileNotFoundException, IOException, FHIRFormatError { + private ValueSet importValueSet(String value, ValueSetExpansionComponent exp, Parameters expParams, boolean noInactive) throws ETooCostly, TerminologyServiceException, FileNotFoundException, IOException, FHIRFormatError { if (value == null) throw fail("unable to find value set with no identity"); ValueSet vs = context.fetchResource(ValueSet.class, value); @@ -489,6 +496,10 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx throw fail("Unable to find imported value set " + value); } } + if (noInactive) { + expParams = expParams.copy(); + expParams.addParameter("activeOnly", true); + } ValueSetExpansionOutcome vso = new ValueSetExpanderSimple(context, allErrors).expand(vs, expParams); if (vso.getError() != null) { addErrors(vso.getAllErrors()); @@ -543,19 +554,19 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx } } - private void copyImportContains(List list, ValueSetExpansionContainsComponent parent, Parameters expParams, List filter) throws FHIRException { + private void copyImportContains(List list, ValueSetExpansionContainsComponent parent, Parameters expParams, List filter, boolean noInactive) throws FHIRException { for (ValueSetExpansionContainsComponent c : list) { c.checkNoModifiers("Imported Expansion in Code System", "expanding"); - ValueSetExpansionContainsComponent np = addCode(c.getSystem(), c.getCode(), c.getDisplay(), parent, null, expParams, c.getAbstract(), c.getInactive(), filter); - copyImportContains(c.getContains(), np, expParams, filter); + ValueSetExpansionContainsComponent np = addCode(c.getSystem(), c.getCode(), c.getDisplay(), parent, null, expParams, c.getAbstract(), c.getInactive(), filter, noInactive); + copyImportContains(c.getContains(), np, expParams, filter, noInactive); } } - private void includeCodes(ConceptSetComponent inc, ValueSetExpansionComponent exp, Parameters expParams, boolean heirarchical, List extensions) throws ETooCostly, FileNotFoundException, IOException, FHIRException { + private void includeCodes(ConceptSetComponent inc, ValueSetExpansionComponent exp, Parameters expParams, boolean heirarchical, boolean noInactive, List extensions) throws ETooCostly, FileNotFoundException, IOException, FHIRException { inc.checkNoModifiers("Compose.include", "expanding"); List imports = new ArrayList(); for (UriType imp : inc.getValueSet()) { - imports.add(importValueSet(imp.getValue(), exp, expParams)); + imports.add(importValueSet(imp.getValue(), exp, expParams, noInactive)); } if (!inc.hasSystem()) { @@ -564,19 +575,19 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx ValueSet base = imports.get(0); imports.remove(0); base.checkNoModifiers("Imported ValueSet", "expanding"); - copyImportContains(base.getExpansion().getContains(), null, expParams, imports); + copyImportContains(base.getExpansion().getContains(), null, expParams, imports, noInactive); } else { CodeSystem cs = context.fetchCodeSystem(inc.getSystem()); if (isServerSide(inc.getSystem()) || (cs == null || (cs.getContent() != CodeSystemContentMode.COMPLETE && cs.getContent() != CodeSystemContentMode.FRAGMENT))) { - doServerIncludeCodes(inc, heirarchical, exp, imports, expParams, extensions); + doServerIncludeCodes(inc, heirarchical, exp, imports, expParams, extensions, noInactive); } else { - doInternalIncludeCodes(inc, exp, expParams, imports, cs); + doInternalIncludeCodes(inc, exp, expParams, imports, cs, noInactive); } } } - private void doServerIncludeCodes(ConceptSetComponent inc, boolean heirarchical, ValueSetExpansionComponent exp, List imports, Parameters expParams, List extensions) throws FHIRException { - ValueSetExpansionOutcome vso = context.expandVS(inc, heirarchical); + private void doServerIncludeCodes(ConceptSetComponent inc, boolean heirarchical, ValueSetExpansionComponent exp, List imports, Parameters expParams, List extensions, boolean noInactive) throws FHIRException { + ValueSetExpansionOutcome vso = context.expandVS(inc, heirarchical, noInactive); if (vso.getError() != null) { throw failTSE("Unable to expand imported value set: " + vso.getError()); } @@ -599,7 +610,7 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx } } for (ValueSetExpansionContainsComponent cc : vs.getExpansion().getContains()) { - addCodeAndDescendents(cc, null, expParams, imports); + addCodeAndDescendents(cc, null, expParams, imports, noInactive); } } @@ -612,7 +623,7 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx return false; } - public void doInternalIncludeCodes(ConceptSetComponent inc, ValueSetExpansionComponent exp, Parameters expParams, List imports, CodeSystem cs) throws NoTerminologyServiceException, TerminologyServiceException, FHIRException { + public void doInternalIncludeCodes(ConceptSetComponent inc, ValueSetExpansionComponent exp, Parameters expParams, List imports, CodeSystem cs, boolean noInactive) throws NoTerminologyServiceException, TerminologyServiceException, FHIRException { if (cs == null) { if (context.isNoTerminologyServer()) throw failTSE("Unable to find code system " + inc.getSystem().toString()); @@ -629,7 +640,7 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx if (inc.getConcept().size() == 0 && inc.getFilter().size() == 0) { // special case - add all the code system for (ConceptDefinitionComponent def : cs.getConcept()) { - addCodeAndDescendents(cs, inc.getSystem(), def, null, expParams, imports, null, new AllConceptsFilter()); + addCodeAndDescendents(cs, inc.getSystem(), def, null, expParams, imports, null, new AllConceptsFilter(), noInactive); } if (cs.getContent() == CodeSystemContentMode.FRAGMENT) { addFragmentWarning(exp, cs); @@ -658,7 +669,7 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx } else { inactive = CodeSystemUtilities.isInactive(cs, def); } - addCode(inc.getSystem(), c.getCode(), !Utilities.noString(c.getDisplay()) ? c.getDisplay() : def == null ? null : def.getDisplay(), null, convertDesignations(c.getDesignation()), expParams, false, inactive, imports); + addCode(inc.getSystem(), c.getCode(), !Utilities.noString(c.getDisplay()) ? c.getDisplay() : def == null ? null : def.getDisplay(), null, convertDesignations(c.getDesignation()), expParams, false, inactive, imports, noInactive); } } if (inc.getFilter().size() > 1) { @@ -675,14 +686,14 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx ConceptDefinitionComponent def = getConceptForCode(cs.getConcept(), fc.getValue()); if (def == null) throw failTSE("Code '" + fc.getValue() + "' not found in system '" + inc.getSystem() + "'"); - addCodeAndDescendents(cs, inc.getSystem(), def, null, expParams, imports, null, new AllConceptsFilter()); + addCodeAndDescendents(cs, inc.getSystem(), def, null, expParams, imports, null, new AllConceptsFilter(), noInactive); } else if ("concept".equals(fc.getProperty()) && fc.getOp() == FilterOperator.ISNOTA) { // special: all codes in the target code system that are not under the value ConceptDefinitionComponent defEx = getConceptForCode(cs.getConcept(), fc.getValue()); if (defEx == null) throw failTSE("Code '" + fc.getValue() + "' not found in system '" + inc.getSystem() + "'"); for (ConceptDefinitionComponent def : cs.getConcept()) { - addCodeAndDescendents(cs, inc.getSystem(), def, null, expParams, imports, defEx, new AllConceptsFilter()); + addCodeAndDescendents(cs, inc.getSystem(), def, null, expParams, imports, defEx, new AllConceptsFilter(), noInactive); } } else if ("concept".equals(fc.getProperty()) && fc.getOp() == FilterOperator.DESCENDENTOF) { // special: all codes in the target code system under the value @@ -690,11 +701,11 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx if (def == null) throw failTSE("Code '" + fc.getValue() + "' not found in system '" + inc.getSystem() + "'"); for (ConceptDefinitionComponent c : def.getConcept()) - addCodeAndDescendents(cs, inc.getSystem(), c, null, expParams, imports, null, new AllConceptsFilter()); + addCodeAndDescendents(cs, inc.getSystem(), c, null, expParams, imports, null, new AllConceptsFilter(), noInactive); if (def.hasUserData(CodeSystemUtilities.USER_DATA_CROSS_LINK)) { List children = (List) def.getUserData(CodeSystemUtilities.USER_DATA_CROSS_LINK); for (ConceptDefinitionComponent c : children) - addCodeAndDescendents(cs, inc.getSystem(), c, null, expParams, imports, null, new AllConceptsFilter()); + addCodeAndDescendents(cs, inc.getSystem(), c, null, expParams, imports, null, new AllConceptsFilter(), noInactive); } } else if ("display".equals(fc.getProperty()) && fc.getOp() == FilterOperator.EQUAL) { @@ -705,13 +716,13 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx if (isNotBlank(def.getDisplay()) && isNotBlank(fc.getValue())) { if (def.getDisplay().contains(fc.getValue())) { addCode(inc.getSystem(), def.getCode(), def.getDisplay(), null, def.getDesignation(), expParams, CodeSystemUtilities.isNotSelectable(cs, def), CodeSystemUtilities.isInactive(cs, def), - imports); + imports, noInactive); } } } } else if (isDefinedProperty(cs, fc.getProperty())) { for (ConceptDefinitionComponent def : cs.getConcept()) { - addCodeAndDescendents(cs, inc.getSystem(), def, null, expParams, imports, null, new PropertyFilter(fc, getPropertyDefinition(cs, fc.getProperty()))); + addCodeAndDescendents(cs, inc.getSystem(), def, null, expParams, imports, null, new PropertyFilter(fc, getPropertyDefinition(cs, fc.getProperty())), noInactive); } } else { throw fail("Search by property[" + fc.getProperty() + "] and op[" + fc.getOp() + "] is not supported yet"); diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/test/utils/TestingUtilities.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/test/utils/TestingUtilities.java index 78af02088..a6636f734 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/test/utils/TestingUtilities.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/test/utils/TestingUtilities.java @@ -108,12 +108,14 @@ public class TestingUtilities extends BaseTestingUtilities { public static SimpleWorkerContext getWorkerContext(NpmPackage npmPackage) throws Exception { SimpleWorkerContext swc = new SimpleWorkerContext.SimpleWorkerContextBuilder().withUserAgent(TestConstants.USER_AGENT).withTerminologyCachePath(TestConstants.TX_CACHE).fromPackage(npmPackage); TerminologyCache.setCacheErrors(true); + swc.setAllowLoadingDuplicates(true); return swc; } public static SimpleWorkerContext getWorkerContext(NpmPackage npmPackage, IWorkerContext.IContextResourceLoader loader) throws Exception { SimpleWorkerContext swc = new SimpleWorkerContext.SimpleWorkerContextBuilder().withUserAgent(TestConstants.USER_AGENT).withTerminologyCachePath(TestConstants.TX_CACHE).fromPackage(npmPackage, loader); TerminologyCache.setCacheErrors(true); + swc.setAllowLoadingDuplicates(true); return swc; } 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 1239685a8..2f2cbad89 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 @@ -235,6 +235,18 @@ public class FHIRPathEngine { } return res; } + public boolean hasType(String tn) { + if (type != null) { + return tn.equals(type); + } else { + for (TypeRefComponent t : element.getType()) { + if (tn.equals(t.getCode())) { + return true; + } + } + return false; + } + } } private IWorkerContext worker; private IEvaluationContext hostServices; @@ -5472,7 +5484,7 @@ public class FHIRPathEngine { * @throws PathEngineException * @throws DefinitionException */ - public TypedElementDefinition evaluateDefinition(ExpressionNode expr, StructureDefinition profile, TypedElementDefinition element, StructureDefinition source) throws DefinitionException { + public TypedElementDefinition evaluateDefinition(ExpressionNode expr, StructureDefinition profile, TypedElementDefinition element, StructureDefinition source, boolean dontWalkIntoReferences) throws DefinitionException { StructureDefinition sd = profile; TypedElementDefinition focus = null; boolean okToNotResolve = false; @@ -5584,10 +5596,19 @@ public class FHIRPathEngine { } else { throw makeException(expr, I18nConstants.FHIRPATH_DISCRIMINATOR_CANT_FIND, expr.toString(), source.getUrl(), element.getElement().getId(), profile.getUrl()); } - } else if (expr.getInner() == null) { - return focus; } else { - return evaluateDefinition(expr.getInner(), sd, focus, profile); + // gdg 26-02-2022. If we're walking towards a resolve() and we're on a reference, and we try to walk into the reference + // then we don't do that. .resolve() is allowed on the Reference.reference, but the target of the reference will be defined + // on the Reference, not the reference.reference. + ExpressionNode next = expr.getInner(); + if (dontWalkIntoReferences && focus.hasType("Reference") && next != null && next.getKind() == Kind.Name && next.getName().equals("reference")) { + next = next.getInner(); + } + if (next == null) { + return focus; + } else { + return evaluateDefinition(next, sd, focus, profile, dontWalkIntoReferences); + } } } diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/context/SimpleWorkerContextTests.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/context/SimpleWorkerContextTests.java index a032328fc..78d5dfa4d 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/context/SimpleWorkerContextTests.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/context/SimpleWorkerContextTests.java @@ -1,13 +1,31 @@ package org.hl7.fhir.r5.context; -import org.hl7.fhir.r5.model.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyBoolean; +import static org.mockito.ArgumentMatchers.argThat; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; + +import java.io.IOException; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +import org.hl7.fhir.r5.model.CapabilityStatement; +import org.hl7.fhir.r5.model.CodeableConcept; +import org.hl7.fhir.r5.model.Coding; +import org.hl7.fhir.r5.model.Enumerations; +import org.hl7.fhir.r5.model.Parameters; +import org.hl7.fhir.r5.model.TerminologyCapabilities; +import org.hl7.fhir.r5.model.ValueSet; import org.hl7.fhir.r5.terminologies.TerminologyClient; import org.hl7.fhir.r5.terminologies.ValueSetCheckerSimple; import org.hl7.fhir.r5.terminologies.ValueSetExpander; import org.hl7.fhir.r5.terminologies.ValueSetExpanderSimple; import org.hl7.fhir.r5.utils.validation.ValidationContextCarrier; import org.hl7.fhir.utilities.ToolingClientLogger; -import org.hl7.fhir.utilities.graphql.Value; import org.hl7.fhir.utilities.validation.ValidationOptions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -18,15 +36,6 @@ import org.mockito.Mockito; import org.mockito.Spy; import org.mockito.junit.jupiter.MockitoExtension; -import java.io.IOException; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.ArgumentMatchers.*; -import static org.mockito.Mockito.*; - @ExtendWith(MockitoExtension.class) public class SimpleWorkerContextTests { @@ -251,12 +260,13 @@ public class SimpleWorkerContextTests { ValueSet vs = new ValueSet(); vs.setStatus(Enumerations.PublicationStatus.ACTIVE); vs.setCompose(new ValueSet.ValueSetComposeComponent()); + vs.getCompose().setInactive(true); vs.getCompose().getInclude().add(inc); Mockito.doReturn(cacheToken).when(terminologyCache).generateExpandToken(argThat(new ValueSetMatcher(vs)),eq(true)); Mockito.doReturn(expectedExpansionResult).when(terminologyCache).getExpansion(cacheToken); - ValueSetExpander.ValueSetExpansionOutcome actualExpansionResult = context.expandVS(inc, true); + ValueSetExpander.ValueSetExpansionOutcome actualExpansionResult = context.expandVS(inc, true, false); assertEquals(expectedExpansionResult, actualExpansionResult); @@ -273,6 +283,7 @@ public class SimpleWorkerContextTests { ValueSet vs = new ValueSet(); vs.setStatus(Enumerations.PublicationStatus.ACTIVE); vs.setCompose(new ValueSet.ValueSetComposeComponent()); + vs.getCompose().setInactive(true); vs.getCompose().getInclude().add(inc); Mockito.doReturn(cacheToken).when(terminologyCache).generateExpandToken(argThat(new ValueSetMatcher(vs)),eq(true)); @@ -285,7 +296,7 @@ public class SimpleWorkerContextTests { Mockito.doReturn(expectedValueSet).when(terminologyClient).expandValueset(argThat(new ValueSetMatcher(vs)), argThat(new ParametersMatcher(pInWithDependentResources)), eq(params)); - ValueSetExpander.ValueSetExpansionOutcome actualExpansionResult = context.expandVS(inc, true); + ValueSetExpander.ValueSetExpansionOutcome actualExpansionResult = context.expandVS(inc, true, false); assertEquals(expectedValueSet, actualExpansionResult.getValueset()); diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/context/TerminologyCacheTests.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/context/TerminologyCacheTests.java index 665c0fe21..57fbcbcd9 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/context/TerminologyCacheTests.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/context/TerminologyCacheTests.java @@ -1,15 +1,9 @@ package org.hl7.fhir.r5.context; -import com.google.gson.JsonElement; -import com.google.gson.JsonParser; -import org.hl7.fhir.r5.formats.IParser; -import org.hl7.fhir.r5.model.*; -import org.hl7.fhir.r5.terminologies.ValueSetExpander; -import org.hl7.fhir.utilities.validation.ValidationMessage; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.File; import java.io.IOException; @@ -25,8 +19,22 @@ import java.util.stream.Collectors; import java.util.stream.IntStream; import java.util.stream.Stream; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.Mockito.mock; +import org.hl7.fhir.r5.formats.IParser; +import org.hl7.fhir.r5.model.CanonicalResource; +import org.hl7.fhir.r5.model.CapabilityStatement; +import org.hl7.fhir.r5.model.CodeableConcept; +import org.hl7.fhir.r5.model.Coding; +import org.hl7.fhir.r5.model.TerminologyCapabilities; +import org.hl7.fhir.r5.model.ValueSet; +import org.hl7.fhir.r5.terminologies.ValueSetExpander; +import org.hl7.fhir.utilities.validation.ValidationMessage; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import com.google.gson.JsonElement; +import com.google.gson.JsonParser; public class TerminologyCacheTests { diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/context/TestPackageLoader.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/context/TestPackageLoader.java new file mode 100644 index 000000000..17c1a4724 --- /dev/null +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/context/TestPackageLoader.java @@ -0,0 +1,46 @@ +package org.hl7.fhir.r5.context; + +import java.io.IOException; +import java.io.InputStream; + +import org.hl7.fhir.exceptions.FHIRException; +import org.hl7.fhir.r5.context.IWorkerContext.IContextResourceLoader; +import org.hl7.fhir.r5.formats.JsonParser; +import org.hl7.fhir.r5.formats.XmlParser; +import org.hl7.fhir.r5.model.Bundle; +import org.hl7.fhir.r5.model.Resource; +import org.hl7.fhir.utilities.npm.NpmPackage; + +public class TestPackageLoader implements IContextResourceLoader { + + private String[] types; + + public TestPackageLoader(String[] types) { + this.types = types; + } + + @Override + public Bundle loadBundle(InputStream stream, boolean isJson) throws FHIRException, IOException { + return null; + } + + @Override + public Resource loadResource(InputStream stream, boolean isJson) throws FHIRException, IOException { + return isJson ? new JsonParser().parse(stream) : new XmlParser().parse(stream); + } + + @Override + public String[] getTypes() { + return types; + } + + @Override + public String getResourcePath(Resource resource) { + return null; + } + + @Override + public IContextResourceLoader getNewLoader(NpmPackage npm) { + return this; + } +} diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/formats/FormatUtilitiesTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/formats/FormatUtilitiesTest.java index b7ab1d337..c9a1358ec 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/formats/FormatUtilitiesTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/formats/FormatUtilitiesTest.java @@ -1,14 +1,11 @@ package org.hl7.fhir.r5.formats; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; - import java.util.stream.Stream; -import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; class FormatUtilitiesTest { diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/Base64BinaryTypeNullTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/Base64BinaryTypeNullTest.java index 0723e2dea..8ff29d60d 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/Base64BinaryTypeNullTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/Base64BinaryTypeNullTest.java @@ -1,6 +1,5 @@ package org.hl7.fhir.r5.model; -import org.hl7.fhir.r5.model.Base64BinaryType; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/BooleanTypeNullTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/BooleanTypeNullTest.java index 996407241..2b9581f4f 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/BooleanTypeNullTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/BooleanTypeNullTest.java @@ -1,6 +1,5 @@ package org.hl7.fhir.r5.model; -import org.hl7.fhir.r5.model.BooleanType; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/CanonicalTypeNullTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/CanonicalTypeNullTest.java index 769329872..54a56d768 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/CanonicalTypeNullTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/CanonicalTypeNullTest.java @@ -1,6 +1,5 @@ package org.hl7.fhir.r5.model; -import org.hl7.fhir.r5.model.CanonicalType; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/CodeTypeNullTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/CodeTypeNullTest.java index 894a576cb..93d640a96 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/CodeTypeNullTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/CodeTypeNullTest.java @@ -1,6 +1,5 @@ package org.hl7.fhir.r5.model; -import org.hl7.fhir.r5.model.CodeType; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/DateTimeTypeNullTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/DateTimeTypeNullTest.java index b4d2e17db..0a95c80de 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/DateTimeTypeNullTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/DateTimeTypeNullTest.java @@ -1,6 +1,5 @@ package org.hl7.fhir.r5.model; -import org.hl7.fhir.r5.model.DateTimeType; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/DateTypeNullTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/DateTypeNullTest.java index 6681a8995..5b4015d87 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/DateTypeNullTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/DateTypeNullTest.java @@ -1,6 +1,5 @@ package org.hl7.fhir.r5.model; -import org.hl7.fhir.r5.model.DateType; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/DecimalTypeNullTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/DecimalTypeNullTest.java index ca8881c54..6efbb92c3 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/DecimalTypeNullTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/DecimalTypeNullTest.java @@ -1,6 +1,5 @@ package org.hl7.fhir.r5.model; -import org.hl7.fhir.r5.model.DecimalType; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/IdTypeNullTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/IdTypeNullTest.java index b7680ac05..d91fbe21c 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/IdTypeNullTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/IdTypeNullTest.java @@ -1,6 +1,5 @@ package org.hl7.fhir.r5.model; -import org.hl7.fhir.r5.model.IdType; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/InstantTypeNullTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/InstantTypeNullTest.java index d9c5f0dce..b303ec222 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/InstantTypeNullTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/InstantTypeNullTest.java @@ -1,6 +1,5 @@ package org.hl7.fhir.r5.model; -import org.hl7.fhir.r5.model.InstantType; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/IntegerTypeNullTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/IntegerTypeNullTest.java index 3fe977703..58555803b 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/IntegerTypeNullTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/IntegerTypeNullTest.java @@ -1,6 +1,5 @@ package org.hl7.fhir.r5.model; -import org.hl7.fhir.r5.model.IntegerType; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/MarkdownTypeNullTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/MarkdownTypeNullTest.java index 1b2013d48..28e9a1848 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/MarkdownTypeNullTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/MarkdownTypeNullTest.java @@ -1,6 +1,5 @@ package org.hl7.fhir.r5.model; -import org.hl7.fhir.r5.model.MarkdownType; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/OidTypeNullTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/OidTypeNullTest.java index 3ef231f5c..d02a9f483 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/OidTypeNullTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/OidTypeNullTest.java @@ -1,6 +1,5 @@ package org.hl7.fhir.r5.model; -import org.hl7.fhir.r5.model.OidType; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/PositiveIntTypeNullTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/PositiveIntTypeNullTest.java index 7dab39822..3cdbff26b 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/PositiveIntTypeNullTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/PositiveIntTypeNullTest.java @@ -1,6 +1,5 @@ package org.hl7.fhir.r5.model; -import org.hl7.fhir.r5.model.PositiveIntType; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/StringTypeNullTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/StringTypeNullTest.java index abcf5ceeb..4176484a6 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/StringTypeNullTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/StringTypeNullTest.java @@ -1,6 +1,5 @@ package org.hl7.fhir.r5.model; -import org.hl7.fhir.r5.model.StringType; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/TimeTypeNullTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/TimeTypeNullTest.java index a5b7ac07b..34355d75c 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/TimeTypeNullTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/TimeTypeNullTest.java @@ -1,6 +1,5 @@ package org.hl7.fhir.r5.model; -import org.hl7.fhir.r5.model.TimeType; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/UnsignedIntTypeNullTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/UnsignedIntTypeNullTest.java index 328f8f332..db28b9aec 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/UnsignedIntTypeNullTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/UnsignedIntTypeNullTest.java @@ -1,6 +1,5 @@ package org.hl7.fhir.r5.model; -import org.hl7.fhir.r5.model.UnsignedIntType; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/UriTypeNullTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/UriTypeNullTest.java index 5f11135cf..695b2d81c 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/UriTypeNullTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/UriTypeNullTest.java @@ -1,6 +1,5 @@ package org.hl7.fhir.r5.model; -import org.hl7.fhir.r5.model.UriType; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/UrlTypeNullTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/UrlTypeNullTest.java index dbf171c7c..9c9e8efde 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/UrlTypeNullTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/UrlTypeNullTest.java @@ -1,6 +1,5 @@ package org.hl7.fhir.r5.model; -import org.hl7.fhir.r5.model.UrlType; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/UuidTypeNullTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/UuidTypeNullTest.java index 51ac87cfd..2f2534211 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/UuidTypeNullTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/model/UuidTypeNullTest.java @@ -1,6 +1,5 @@ package org.hl7.fhir.r5.model; -import org.hl7.fhir.r5.model.UuidType; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/FHIRPathTests.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/FHIRPathTests.java index 7fe3a1645..2b8ef374d 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/FHIRPathTests.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/FHIRPathTests.java @@ -25,7 +25,6 @@ import org.hl7.fhir.r5.model.Quantity; import org.hl7.fhir.r5.model.Resource; import org.hl7.fhir.r5.model.TypeDetails; import org.hl7.fhir.r5.model.ValueSet; -import org.hl7.fhir.r5.test.FHIRPathTests.TestResultType; import org.hl7.fhir.r5.test.utils.TestingUtilities; import org.hl7.fhir.r5.utils.FHIRPathEngine; import org.hl7.fhir.r5.utils.FHIRPathEngine.IEvaluationContext; diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/NarrativeGenerationTests.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/NarrativeGenerationTests.java index f2e3ee3df..2a25ab3de 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/NarrativeGenerationTests.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/NarrativeGenerationTests.java @@ -1,51 +1,35 @@ package org.hl7.fhir.r5.test; -import java.io.BufferedReader; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.FileReader; import java.io.IOException; import java.time.ZoneId; -import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.List; import java.util.stream.Stream; import javax.xml.parsers.ParserConfigurationException; -import org.apache.commons.io.IOUtils; -import org.apache.commons.lang3.SystemUtils; import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.FHIRFormatError; import org.hl7.fhir.r5.context.IWorkerContext; import org.hl7.fhir.r5.elementmodel.Manager; import org.hl7.fhir.r5.elementmodel.Manager.FhirFormat; -import org.hl7.fhir.r5.formats.IParser.OutputStyle; import org.hl7.fhir.r5.formats.JsonParser; import org.hl7.fhir.r5.formats.XmlParser; import org.hl7.fhir.r5.model.Base; -import org.hl7.fhir.r5.model.DomainResource; -import org.hl7.fhir.r5.model.Questionnaire; import org.hl7.fhir.r5.model.Resource; import org.hl7.fhir.r5.renderers.RendererFactory; -import org.hl7.fhir.r5.renderers.ResourceRenderer; import org.hl7.fhir.r5.renderers.utils.ElementWrappers; import org.hl7.fhir.r5.renderers.utils.RenderingContext; import org.hl7.fhir.r5.renderers.utils.RenderingContext.ITypeParser; -import org.hl7.fhir.r5.renderers.utils.RenderingContext.QuestionnaireRendererMode; import org.hl7.fhir.r5.renderers.utils.RenderingContext.ResourceRendererMode; -import org.hl7.fhir.r5.test.NarrativeGenerationTests.TestTypeParser; import org.hl7.fhir.r5.test.utils.TestingUtilities; import org.hl7.fhir.utilities.TerminologyServiceOptions; import org.hl7.fhir.utilities.TextFile; import org.hl7.fhir.utilities.xhtml.XhtmlComposer; import org.hl7.fhir.utilities.xhtml.XhtmlNode; -import org.hl7.fhir.utilities.xhtml.XhtmlParser; import org.hl7.fhir.utilities.xml.XMLUtil; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/NarrativeGeneratorTests.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/NarrativeGeneratorTests.java index e48ff819e..4a92d9c93 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/NarrativeGeneratorTests.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/NarrativeGeneratorTests.java @@ -5,11 +5,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.time.ZoneId; -import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; -import java.time.format.FormatStyle; -import java.util.Locale; -import java.util.TimeZone; import org.hl7.fhir.exceptions.DefinitionException; import org.hl7.fhir.exceptions.FHIRException; diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ProfileUtilitiesTests.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ProfileUtilitiesTests.java index d1bf6def0..fcaca80cb 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ProfileUtilitiesTests.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ProfileUtilitiesTests.java @@ -1,5 +1,8 @@ package org.hl7.fhir.r5.test; +import java.util.ArrayList; +import java.util.List; + import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.r5.conformance.ProfileUtilities; import org.hl7.fhir.r5.model.Base; @@ -13,9 +16,6 @@ import org.hl7.fhir.utilities.validation.ValidationMessage; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -import java.util.ArrayList; -import java.util.List; - public class ProfileUtilitiesTests { // /** diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ResourceCopyTests.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ResourceCopyTests.java index e333626d1..9e702ccb7 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ResourceCopyTests.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ResourceCopyTests.java @@ -1,5 +1,7 @@ package org.hl7.fhir.r5.test; +import java.io.IOException; + import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.r5.model.Enumerations; import org.hl7.fhir.r5.model.Extension; @@ -7,8 +9,6 @@ import org.hl7.fhir.r5.model.Observation; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -import java.io.IOException; - public class ResourceCopyTests { diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ResourceRoundTripTests.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ResourceRoundTripTests.java index a3620607b..f69340efb 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ResourceRoundTripTests.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ResourceRoundTripTests.java @@ -19,7 +19,6 @@ import org.hl7.fhir.r5.formats.IParser.OutputStyle; import org.hl7.fhir.r5.formats.JsonParser; import org.hl7.fhir.r5.formats.XmlParser; import org.hl7.fhir.r5.model.Bundle; -import org.hl7.fhir.r5.model.DateTimeType; import org.hl7.fhir.r5.model.DomainResource; import org.hl7.fhir.r5.model.Resource; import org.hl7.fhir.r5.renderers.RendererFactory; @@ -27,7 +26,6 @@ import org.hl7.fhir.r5.renderers.utils.RenderingContext; import org.hl7.fhir.r5.renderers.utils.RenderingContext.ResourceRendererMode; import org.hl7.fhir.r5.test.utils.TestingUtilities; import org.hl7.fhir.r5.utils.EOperationOutcome; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; public class ResourceRoundTripTests { diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ResourceTests.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ResourceTests.java index 1bdd2815f..f4d97151a 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ResourceTests.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/ResourceTests.java @@ -1,6 +1,8 @@ package org.hl7.fhir.r5.test; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.IOException; diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/SnapShotGenerationTests.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/SnapShotGenerationTests.java index 8c06c149a..1d2c4c96f 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/SnapShotGenerationTests.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/SnapShotGenerationTests.java @@ -4,7 +4,6 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; -import java.io.InputStream; import java.util.ArrayList; import java.util.List; import java.util.stream.Stream; @@ -19,28 +18,27 @@ import org.hl7.fhir.exceptions.FHIRFormatError; import org.hl7.fhir.exceptions.PathEngineException; import org.hl7.fhir.r5.conformance.ProfileUtilities; import org.hl7.fhir.r5.conformance.ProfileUtilities.ProfileKnowledgeProvider; -import org.hl7.fhir.r5.context.IWorkerContext.IContextResourceLoader; +import org.hl7.fhir.r5.context.TestPackageLoader; import org.hl7.fhir.r5.formats.IParser.OutputStyle; import org.hl7.fhir.r5.formats.JsonParser; import org.hl7.fhir.r5.formats.XmlParser; import org.hl7.fhir.r5.model.Base; -import org.hl7.fhir.r5.model.Bundle; import org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent; import org.hl7.fhir.r5.model.ExpressionNode.CollectionStatus; import org.hl7.fhir.r5.model.Resource; import org.hl7.fhir.r5.model.StructureDefinition; import org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind; import org.hl7.fhir.r5.model.StructureDefinition.TypeDerivationRule; +import org.hl7.fhir.r5.model.TypeDetails; +import org.hl7.fhir.r5.model.ValueSet; import org.hl7.fhir.r5.renderers.RendererFactory; import org.hl7.fhir.r5.renderers.utils.RenderingContext; import org.hl7.fhir.r5.renderers.utils.RenderingContext.ResourceRendererMode; -import org.hl7.fhir.r5.model.TypeDetails; -import org.hl7.fhir.r5.model.ValueSet; import org.hl7.fhir.r5.test.utils.TestingUtilities; import org.hl7.fhir.r5.utils.FHIRPathEngine; import org.hl7.fhir.r5.utils.FHIRPathEngine.IEvaluationContext; -import org.hl7.fhir.r5.utils.validation.IResourceValidator; import org.hl7.fhir.r5.utils.XVerExtensionManager; +import org.hl7.fhir.r5.utils.validation.IResourceValidator; import org.hl7.fhir.utilities.Utilities; import org.hl7.fhir.utilities.npm.CommonPackages; import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager; @@ -60,41 +58,6 @@ import org.xml.sax.SAXException; public class SnapShotGenerationTests { - public class TestLoader implements IContextResourceLoader { - - private String[] types; - - public TestLoader(String[] types) { - this.types = types; - } - - @Override - public Bundle loadBundle(InputStream stream, boolean isJson) throws FHIRException, IOException { - return null; - } - - @Override - public Resource loadResource(InputStream stream, boolean isJson) throws FHIRException, IOException { - return null; - } - - @Override - public String[] getTypes() { - return types; - } - - @Override - public String getResourcePath(Resource resource) { - return null; - } - - @Override - public IContextResourceLoader getNewLoader(NpmPackage npm) { - return this; - } - - } - public enum TestFetchMode { INPUT, OUTPUT, @@ -549,7 +512,7 @@ public class SnapShotGenerationTests { pu.setIds(test.getSource(), false); if (!TestingUtilities.context().hasPackage(CommonPackages.ID_XVER, CommonPackages.VER_XVER)) { NpmPackage npm = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION).loadPackage(CommonPackages.ID_XVER, CommonPackages.VER_XVER); - TestingUtilities.context().loadFromPackage(npm, new TestLoader(new String[]{"StructureDefinition"}), new String[]{"StructureDefinition"}); + TestingUtilities.context().loadFromPackage(npm, new TestPackageLoader(new String[]{"StructureDefinition"}), new String[]{"StructureDefinition"}); } pu.setXver(new XVerExtensionManager(TestingUtilities.context())); if (test.isSort()) { diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/StructureMapUtilitiesTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/StructureMapUtilitiesTest.java index 65602d1eb..5cc6871c8 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/StructureMapUtilitiesTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/StructureMapUtilitiesTest.java @@ -1,5 +1,8 @@ package org.hl7.fhir.r5.test; +import java.io.IOException; +import java.util.List; + import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.r5.context.SimpleWorkerContext; import org.hl7.fhir.r5.model.Base; @@ -7,17 +10,14 @@ import org.hl7.fhir.r5.model.Coding; import org.hl7.fhir.r5.model.StructureMap; import org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleTargetComponent; import org.hl7.fhir.r5.test.utils.TestingUtilities; -import org.hl7.fhir.r5.utils.structuremap.StructureMapUtilities; import org.hl7.fhir.r5.utils.structuremap.ITransformerServices; +import org.hl7.fhir.r5.utils.structuremap.StructureMapUtilities; import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager; import org.hl7.fhir.utilities.npm.ToolsVersion; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import java.io.IOException; -import java.util.List; - public class StructureMapUtilitiesTest implements ITransformerServices { static private SimpleWorkerContext context; diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/VocabTests.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/VocabTests.java new file mode 100644 index 000000000..0cb27a1b4 --- /dev/null +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/test/VocabTests.java @@ -0,0 +1,162 @@ +package org.hl7.fhir.r5.test; + +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Stream; + +import javax.xml.parsers.ParserConfigurationException; + +import org.hl7.fhir.exceptions.FHIRException; +import org.hl7.fhir.exceptions.FHIRFormatError; +import org.hl7.fhir.r5.context.IWorkerContext; +import org.hl7.fhir.r5.context.TestPackageLoader; +import org.hl7.fhir.r5.formats.IParser.OutputStyle; +import org.hl7.fhir.r5.formats.JsonParser; +import org.hl7.fhir.r5.formats.XmlParser; +import org.hl7.fhir.r5.model.Base; +import org.hl7.fhir.r5.model.Resource; +import org.hl7.fhir.r5.model.ValueSet; +import org.hl7.fhir.r5.renderers.utils.RenderingContext.ITypeParser; +import org.hl7.fhir.r5.terminologies.ValueSetExpander.ValueSetExpansionOutcome; +import org.hl7.fhir.r5.test.utils.TestingUtilities; +import org.hl7.fhir.utilities.TextFile; +import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager; +import org.hl7.fhir.utilities.npm.NpmPackage; +import org.hl7.fhir.utilities.npm.ToolsVersion; +import org.hl7.fhir.utilities.xml.XMLUtil; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.xml.sax.SAXException; + +public class VocabTests { + + public enum TestType { + Expansion; + } + + public class TestTypeParser implements ITypeParser { + + @Override + public Base parseType(String xml, String type) throws FHIRFormatError, IOException, FHIRException { + return new org.hl7.fhir.r5.formats.XmlParser().parseType(xml, type); + } + } + + private static IWorkerContext context; + + public static class TestDetails { + private String id; + private Map parameters = new HashMap<>(); + private String source; + private String target; + private TestType type; + + + public TestDetails(Element test) { + super(); + id = test.getAttribute("id"); + source = XMLUtil.getNamedChildValue(test, "source"); + target = XMLUtil.getNamedChildValue(test, "target"); + type = TestType.Expansion; + } + + public String getId() { + return id; + } + + public Map getParameters() { + return parameters; + } + + public String getSource() { + return source; + } + + public String getTarget() { + return target; + } + + public TestType getType() { + return type; + } + + } + + public static Stream data() throws ParserConfigurationException, IOException, FHIRFormatError, SAXException { + Document tests = XMLUtil.parseToDom(TestingUtilities.loadTestResource("r5", "vocab", "manifest.xml")); + Element test = XMLUtil.getFirstChild(tests.getDocumentElement()); + List objects = new ArrayList<>(); + while (test != null && test.getNodeName().equals("test")) { + TestDetails t = new TestDetails(test); + objects.add(Arguments.of(t.getId(), t)); + test = XMLUtil.getNextSibling(test); + } + return objects.stream(); + } + + @BeforeAll + public static void setUp() throws FileNotFoundException, FHIRException, IOException { + context = TestingUtilities.context(); + if (!context.hasPackage("hl7.terminology", null)) { + + NpmPackage utg = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION).loadPackage("hl7.terminology"); + System.out.println("Loading THO: "+utg.name()+"#"+utg.version()); + context.loadFromPackage(utg, new TestPackageLoader(new String[]{"CodeSystem", "ValueSet"})); + } + } + + @ParameterizedTest(name = "{index}: file {0}") + @MethodSource("data") + public void test(String id, TestDetails test) throws Exception { + + Resource source; + if (test.getSource().endsWith(".json")) { + source = (Resource) new JsonParser().parse(TestingUtilities.loadTestResourceStream("r5", "vocab", test.getSource())); + } else { + source = (Resource) new XmlParser().parse(TestingUtilities.loadTestResourceStream("r5", "vocab", test.getSource())); + } + + Resource target; + if (test.getTarget().endsWith(".json")) { + target = (Resource) new JsonParser().parse(TestingUtilities.loadTestResourceStream("r5", "vocab", test.getTarget())); + } else { + target = (Resource) new XmlParser().parse(TestingUtilities.loadTestResourceStream("r5", "vocab", test.getTarget())); + } + + if (test.getType() == TestType.Expansion) { + testExpansion(test, (ValueSet) source, (ValueSet) target); + } else { + Assertions.fail("not done yet"); + } + + + } + + private void testExpansion(TestDetails test, ValueSet sourceVS, ValueSet targetVS) throws Exception { + ValueSetExpansionOutcome outcome = context.expandVS(sourceVS, false, test.getParameters().containsKey("hierarchical")); + if (outcome.isOk()) { + outcome.getValueset().getExpansion().setIdentifier(null); + outcome.getValueset().getExpansion().setTimestamp(null); + String target = new XmlParser().setOutputStyle(OutputStyle.PRETTY).composeString(targetVS); + String output = new XmlParser().setOutputStyle(OutputStyle.PRETTY).composeString(outcome.getValueset()); + String tfn = TestingUtilities.tempFile("vocab", test.getId() + ".target.html"); + String ofn = TestingUtilities.tempFile("vocab", test.getId() + ".output.html"); + TextFile.stringToFile(target, tfn); + TextFile.stringToFile(output, ofn); + String msg = TestingUtilities.checkXMLIsSame(ofn, tfn); + Assertions.assertTrue(msg == null, "Output does not match expected: "+msg); + } else { + Assertions.fail("Expansion Failed: "+outcome.getError()); + } + } + +} \ No newline at end of file diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/FHIRLexerTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/FHIRLexerTest.java index 771c53348..73637fcde 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/FHIRLexerTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/FHIRLexerTest.java @@ -4,8 +4,6 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.*; - class FHIRLexerTest { @Test @DisplayName("Test that a 'null' current value returns 'false' when FHIRLexer.isConstant() is called, and not NPE.") diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/client/FHIRToolingClientTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/client/FHIRToolingClientTest.java index cc352cbc1..66370d072 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/client/FHIRToolingClientTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/client/FHIRToolingClientTest.java @@ -1,9 +1,22 @@ package org.hl7.fhir.r5.utils.client; -import okhttp3.Headers; -import okhttp3.Request; -import okhttp3.internal.http2.Header; -import org.hl7.fhir.r5.model.*; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.ArrayList; +import java.util.Arrays; + +import org.hl7.fhir.r5.model.Bundle; +import org.hl7.fhir.r5.model.CapabilityStatement; +import org.hl7.fhir.r5.model.Enumerations; +import org.hl7.fhir.r5.model.IdType; +import org.hl7.fhir.r5.model.Observation; +import org.hl7.fhir.r5.model.OperationOutcome; +import org.hl7.fhir.r5.model.Patient; +import org.hl7.fhir.r5.model.Quantity; +import org.hl7.fhir.r5.model.Reference; +import org.hl7.fhir.r5.model.Resource; +import org.hl7.fhir.r5.model.TerminologyCapabilities; import org.hl7.fhir.r5.utils.client.network.Client; import org.hl7.fhir.r5.utils.client.network.ResourceRequest; import org.junit.jupiter.api.Assertions; @@ -13,11 +26,9 @@ import org.mockito.ArgumentCaptor; import org.mockito.ArgumentMatchers; import org.mockito.Mockito; -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.Arrays; +import okhttp3.Headers; +import okhttp3.Request; +import okhttp3.internal.http2.Header; class FHIRToolingClientTest { diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/client/network/ClientHeadersTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/client/network/ClientHeadersTest.java index 239c67069..7f102bf73 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/client/network/ClientHeadersTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/client/network/ClientHeadersTest.java @@ -1,14 +1,15 @@ package org.hl7.fhir.r5.utils.client.network; -import okhttp3.internal.http2.Header; +import java.util.Arrays; +import java.util.List; + import org.hl7.fhir.exceptions.FHIRException; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import java.util.Arrays; -import java.util.List; +import okhttp3.internal.http2.Header; class ClientHeadersTest { diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/client/network/ClientTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/client/network/ClientTest.java index cfca89294..a9e5657ae 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/client/network/ClientTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/client/network/ClientTest.java @@ -1,21 +1,30 @@ package org.hl7.fhir.r5.utils.client.network; -import okhttp3.HttpUrl; -import okhttp3.mockwebserver.MockResponse; -import okhttp3.mockwebserver.MockWebServer; -import okhttp3.mockwebserver.RecordedRequest; -import org.hl7.fhir.r5.context.HTMLClientLogger; -import org.hl7.fhir.r5.formats.JsonParser; -import org.hl7.fhir.r5.model.*; -import org.junit.jupiter.api.*; -import org.mockito.Mockito; - import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; import java.util.Random; import java.util.concurrent.TimeUnit; +import org.hl7.fhir.r5.context.HTMLClientLogger; +import org.hl7.fhir.r5.formats.JsonParser; +import org.hl7.fhir.r5.model.Address; +import org.hl7.fhir.r5.model.Enumerations; +import org.hl7.fhir.r5.model.HumanName; +import org.hl7.fhir.r5.model.Patient; +import org.hl7.fhir.r5.model.Resource; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.mockito.Mockito; + +import okhttp3.HttpUrl; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; +import okhttp3.mockwebserver.RecordedRequest; + @TestInstance(TestInstance.Lifecycle.PER_CLASS) class ClientTest { diff --git a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/client/network/FhirRequestBuilderTest.java b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/client/network/FhirRequestBuilderTest.java index f7723339a..b56909bdd 100644 --- a/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/client/network/FhirRequestBuilderTest.java +++ b/org.hl7.fhir.r5/src/test/java/org/hl7/fhir/r5/utils/client/network/FhirRequestBuilderTest.java @@ -1,17 +1,15 @@ package org.hl7.fhir.r5.utils.client.network; -import okhttp3.Headers; -import okhttp3.OkHttpClient; -import okhttp3.Request; +import java.util.List; +import java.util.Map; + import org.hl7.fhir.r5.model.OperationOutcome; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import java.util.HashMap; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import okhttp3.Headers; +import okhttp3.Request; class FhirRequestBuilderTest { diff --git a/org.hl7.fhir.report/pom.xml b/org.hl7.fhir.report/pom.xml index a486a788a..0de887735 100644 --- a/org.hl7.fhir.report/pom.xml +++ b/org.hl7.fhir.report/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.6.35 + 5.6.37-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.utilities/pom.xml b/org.hl7.fhir.utilities/pom.xml index 0ecab94eb..11840b91e 100644 --- a/org.hl7.fhir.utilities/pom.xml +++ b/org.hl7.fhir.utilities/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.6.35 + 5.6.37-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.utilities/src/test/java/org/hl7/fhir/utilities/UtilitiesTest.java b/org.hl7.fhir.utilities/src/test/java/org/hl7/fhir/utilities/UtilitiesTest.java index dc403a90e..c4486ac72 100644 --- a/org.hl7.fhir.utilities/src/test/java/org/hl7/fhir/utilities/UtilitiesTest.java +++ b/org.hl7.fhir.utilities/src/test/java/org/hl7/fhir/utilities/UtilitiesTest.java @@ -39,7 +39,11 @@ class UtilitiesTest { @Test @DisplayName("Test Utilities.path maps temp directory correctly") public void testTempDirPath() throws IOException { - Assertions.assertEquals(Utilities.path("[tmp]", TEST_TXT), getTempDirectory() + TEST_TXT); + if (ToolGlobalSettings.hasTempPath()) { + Assertions.assertEquals(Utilities.path("[tmp]", TEST_TXT), ToolGlobalSettings.getTempPath() +File.separator+ TEST_TXT); + } else { + Assertions.assertEquals(Utilities.path("[tmp]", TEST_TXT), getTempDirectory() + TEST_TXT); + } } @Test diff --git a/org.hl7.fhir.validation.cli/pom.xml b/org.hl7.fhir.validation.cli/pom.xml index 062c66791..be9782aed 100644 --- a/org.hl7.fhir.validation.cli/pom.xml +++ b/org.hl7.fhir.validation.cli/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.6.35 + 5.6.37-SNAPSHOT ../pom.xml diff --git a/org.hl7.fhir.validation/pom.xml b/org.hl7.fhir.validation/pom.xml index 45006315e..ba7b4fbde 100644 --- a/org.hl7.fhir.validation/pom.xml +++ b/org.hl7.fhir.validation/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir org.hl7.fhir.core - 5.6.35 + 5.6.37-SNAPSHOT ../pom.xml 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 fdc6782d5..54c748c7a 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 @@ -3405,13 +3405,17 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat return elements; } + boolean dontFollowReference = false; + if (removeResolve) { // if we're doing profile slicing, we don't want to walk into the last resolve.. we need the profile on the source not the target if (discriminator.equals("resolve()")) { elements.add(element); return elements; } - if (discriminator.endsWith(".resolve()")) + if (discriminator.endsWith(".resolve()")) { discriminator = discriminator.substring(0, discriminator.length() - 10); + dontFollowReference = true; + } } TypedElementDefinition ted = null; @@ -3424,7 +3428,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat throw new FHIRException(context.formatMessage(I18nConstants.DISCRIMINATOR_BAD_PATH, e.getMessage(), fp), e); } long t2 = System.nanoTime(); - ted = fpe.evaluateDefinition(expr, profile, new TypedElementDefinition(element), srcProfile); + ted = fpe.evaluateDefinition(expr, profile, new TypedElementDefinition(element), srcProfile, dontFollowReference); timeTracker.sd(t2); if (ted != null) elements.add(ted.getElement()); @@ -3449,7 +3453,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat } expr = fpe.parse(fp); t2 = System.nanoTime(); - ted = fpe.evaluateDefinition(expr, profile, new TypedElementDefinition(element), srcProfile); + ted = fpe.evaluateDefinition(expr, profile, new TypedElementDefinition(element), srcProfile, dontFollowReference); timeTracker.sd(t2); if (ted != null) elements.add(ted.getElement()); diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/type/BundleValidator.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/type/BundleValidator.java index 2ab7ab597..68238431a 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/type/BundleValidator.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/type/BundleValidator.java @@ -27,7 +27,7 @@ import org.hl7.fhir.validation.instance.utils.IndexedElement; import org.hl7.fhir.validation.instance.utils.NodeStack; import org.hl7.fhir.validation.instance.utils.ValidatorHostContext; -public class BundleValidator extends BaseValidator{ +public class BundleValidator extends BaseValidator { public final static String URI_REGEX3 = "((http|https)://([A-Za-z0-9\\\\\\.\\:\\%\\$]*\\/)*)?(Account|ActivityDefinition|AllergyIntolerance|AdverseEvent|Appointment|AppointmentResponse|AuditEvent|Basic|Binary|BodySite|Bundle|CapabilityStatement|CarePlan|CareTeam|ChargeItem|Claim|ClaimResponse|ClinicalImpression|CodeSystem|Communication|CommunicationRequest|CompartmentDefinition|Composition|ConceptMap|Condition (aka Problem)|Consent|Contract|Coverage|DataElement|DetectedIssue|Device|DeviceComponent|DeviceMetric|DeviceRequest|DeviceUseStatement|DiagnosticReport|DocumentManifest|DocumentReference|EligibilityRequest|EligibilityResponse|Encounter|Endpoint|EnrollmentRequest|EnrollmentResponse|EpisodeOfCare|ExpansionProfile|ExplanationOfBenefit|FamilyMemberHistory|Flag|Goal|GraphDefinition|Group|GuidanceResponse|HealthcareService|ImagingManifest|ImagingStudy|Immunization|ImmunizationRecommendation|ImplementationGuide|Library|Linkage|List|Location|Measure|MeasureReport|Media|Medication|MedicationAdministration|MedicationDispense|MedicationRequest|MedicationStatement|MessageDefinition|MessageHeader|NamingSystem|NutritionOrder|Observation|OperationDefinition|OperationOutcome|Organization|Parameters|Patient|PaymentNotice|PaymentReconciliation|Person|PlanDefinition|Practitioner|PractitionerRole|Procedure|ProcedureRequest|ProcessRequest|ProcessResponse|Provenance|Questionnaire|QuestionnaireResponse|ReferralRequest|RelatedPerson|RequestGroup|ResearchStudy|ResearchSubject|RiskAssessment|Schedule|SearchParameter|Sequence|ServiceDefinition|Slot|Specimen|StructureDefinition|StructureMap|Subscription|Substance|SupplyDelivery|SupplyRequest|Task|TestScript|TestReport|ValueSet|VisionPrescription)\\/[A-Za-z0-9\\-\\.]{1,64}(\\/_history\\/[A-Za-z0-9\\-\\.]{1,64})?"; private String serverBase; private InstanceValidator validator; diff --git a/org.hl7.fhir.validation/src/test/resources/txCache/3.0.2/snomed.cache b/org.hl7.fhir.validation/src/test/resources/txCache/3.0.2/snomed.cache index 054313479..4d4ad75b9 100644 --- a/org.hl7.fhir.validation/src/test/resources/txCache/3.0.2/snomed.cache +++ b/org.hl7.fhir.validation/src/test/resources/txCache/3.0.2/snomed.cache @@ -343,3 +343,12 @@ v: { "system" : "http://snomed.info/sct" } ------------------------------------------------------------------------------------- +{"code" : { + "system" : "http://snomed.info/sct", + "code" : "11181000146103" +}, "valueSet" :null, "lang":"null", "useServer":"true", "useClient":"true", "guessSystem":"false", "valueSetMode":"ALL_CHECKS", "versionFlexible":"false"}#### +v: { + "severity" : "error", + "error" : "Unable to find code 11181000146103 in http://snomed.info/sct (version http://snomed.info/sct/900000000000207008/version/20210731); The code \"11181000146103\" is not valid in the system http://snomed.info/sct; The code provided (http://snomed.info/sct#11181000146103) is not valid in the value set 'All codes known to the system' (from http://tx.fhir.org/r3)" +} +------------------------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index 9da7768a4..cfce9bbe8 100644 --- a/pom.xml +++ b/pom.xml @@ -14,12 +14,12 @@ HAPI FHIR --> org.hl7.fhir.core - 5.6.35 + 5.6.37-SNAPSHOT pom 5.4.0 - 1.1.89 + 1.1.90 5.7.1 1.7.1 3.0.0-M5