Merge branch 'master' of https://github.com/hapifhir/org.hl7.fhir.core into R4B-datatypes-and-xml-cleanup

# Conflicts:
#	org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/Enumerations.java
This commit is contained in:
Lloyd McKenzie 2022-03-04 22:01:48 -07:00
commit 074da98066
68 changed files with 530 additions and 232 deletions

View File

@ -4,4 +4,4 @@
## Other code changes ## Other code changes
* fix various rendering issues from core spec * no changes

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>org.hl7.fhir.core</artifactId> <artifactId>org.hl7.fhir.core</artifactId>
<version>5.6.35</version> <version>5.6.37-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>org.hl7.fhir.core</artifactId> <artifactId>org.hl7.fhir.core</artifactId>
<version>5.6.35</version> <version>5.6.37-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>org.hl7.fhir.core</artifactId> <artifactId>org.hl7.fhir.core</artifactId>
<version>5.6.35</version> <version>5.6.37-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>org.hl7.fhir.core</artifactId> <artifactId>org.hl7.fhir.core</artifactId>
<version>5.6.35</version> <version>5.6.37-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -2219,7 +2219,7 @@ public class FHIRPathEngine {
if (!Utilities.noString(f)) { 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 t = convertToString(execute(context, focus, exp.getParameters().get(0), true));
String r = convertToString(execute(context, focus, exp.getParameters().get(1), true)); String r = convertToString(execute(context, focus, exp.getParameters().get(1), true));

View File

@ -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<Base> 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());
}
}

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>org.hl7.fhir.core</artifactId> <artifactId>org.hl7.fhir.core</artifactId>
<version>5.6.35</version> <version>5.6.37-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -49,7 +49,7 @@ public enum FhirPublication {
R4; R4;
public static FhirPublication fromCode(String v) { public static FhirPublication fromCode(String v) {
if (VersionUtilities.isR4Ver(v)) if (VersionUtilities.isR2Ver(v))
return FhirPublication.DSTU2; return FhirPublication.DSTU2;
if ("1.0".equals(v)) if ("1.0".equals(v))
return FhirPublication.DSTU2; return FhirPublication.DSTU2;

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>org.hl7.fhir.core</artifactId> <artifactId>org.hl7.fhir.core</artifactId>
<version>5.6.35</version> <version>5.6.37-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>org.hl7.fhir.core</artifactId> <artifactId>org.hl7.fhir.core</artifactId>
<version>5.6.35</version> <version>5.6.37-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -666,10 +666,11 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
@Override @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(); ValueSet vs = new ValueSet();
vs.setStatus(PublicationStatus.ACTIVE); vs.setStatus(PublicationStatus.ACTIVE);
vs.setCompose(new ValueSetComposeComponent()); vs.setCompose(new ValueSetComposeComponent());
vs.getCompose().setInactive(!noInactive);
vs.getCompose().getInclude().add(inc); vs.getCompose().getInclude().add(inc);
CacheToken cacheToken = txCache.generateExpandToken(vs, hierarchical); CacheToken cacheToken = txCache.generateExpandToken(vs, hierarchical);
ValueSetExpansionOutcome res; ValueSetExpansionOutcome res;

View File

@ -124,6 +124,9 @@ public class CanonicalResourceManager<T extends CanonicalResource> {
if (resource == null) { if (resource == null) {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
T1 res = (T1) proxy.getResource(); T1 res = (T1) proxy.getResource();
if (res == null) {
throw new Error("Proxy loading a resource from "+packageInfo+" failed and returned null");
}
synchronized (this) { synchronized (this) {
resource = res; resource = res;
} }

View File

@ -547,7 +547,7 @@ public interface IWorkerContext {
* @return * @return
* @throws FHIRException * @throws FHIRException
*/ */
ValueSetExpansionOutcome expandVS(ConceptSetComponent inc, boolean hierarchical) throws TerminologyServiceException; ValueSetExpansionOutcome expandVS(ConceptSetComponent inc, boolean hierarchical, boolean noInactive) throws TerminologyServiceException;
Locale getLocale(); Locale getLocale();

View File

@ -6925,9 +6925,9 @@ The primary difference between a medicationusage and a medicationadministration
return _4_1_0; return _4_1_0;
if ("4.2.0".equals(codeString)) if ("4.2.0".equals(codeString))
return _4_2_0; return _4_2_0;
if ("4.3.0-snapshot1".equals(codeString)) if ("4.3.0-snapshot1".equalsIgnoreCase(codeString))
return _4_3_0SNAPSHOT1; return _4_3_0SNAPSHOT1;
if ("4.3.0-cibuild".equals(codeString)) if ("4.3.0-cibuild".equalsIgnoreCase(codeString))
return _4_3_0CIBUILD; return _4_3_0CIBUILD;
if ("4.4.0".equals(codeString)) if ("4.4.0".equals(codeString))
return _4_4_0; return _4_4_0;
@ -6935,9 +6935,9 @@ The primary difference between a medicationusage and a medicationadministration
return _4_5_0; return _4_5_0;
if ("4.6.0".equals(codeString)) if ("4.6.0".equals(codeString))
return _4_6_0; return _4_6_0;
if ("5.0.0-snapshot1".equals(codeString)) if ("5.0.0-snapshot1".equalsIgnoreCase(codeString))
return _5_0_0SNAPSHOT1; return _5_0_0SNAPSHOT1;
if ("5.0.0-cibuild".equals(codeString)) if ("5.0.0-cibuild".equalsIgnoreCase(codeString))
return _5_0_0CIBUILD; return _5_0_0CIBUILD;
throw new FHIRException("Unknown FHIRVersion code '"+codeString+"'"); throw new FHIRException("Unknown FHIRVersion code '"+codeString+"'");
} }
@ -7160,7 +7160,7 @@ public String toCode(int len) {
public boolean isR4B() { public boolean isR4B() {
return toCode().startsWith("4.1"); return toCode().startsWith("4.1") ||toCode().startsWith("4.3");
} }
// end addition // end addition
@ -7222,9 +7222,9 @@ public String toCode(int len) {
return FHIRVersion._4_1_0; return FHIRVersion._4_1_0;
if ("4.2.0".equals(codeString)) if ("4.2.0".equals(codeString))
return FHIRVersion._4_2_0; return FHIRVersion._4_2_0;
if ("4.3.0-snapshot1".equals(codeString)) if ("4.3.0-snapshot1".equalsIgnoreCase(codeString))
return FHIRVersion._4_3_0SNAPSHOT1; return FHIRVersion._4_3_0SNAPSHOT1;
if ("4.3.0-cibuild".equals(codeString)) if ("4.3.0-cibuild".equalsIgnoreCase(codeString))
return FHIRVersion._4_3_0CIBUILD; return FHIRVersion._4_3_0CIBUILD;
if ("4.4.0".equals(codeString)) if ("4.4.0".equals(codeString))
return FHIRVersion._4_4_0; return FHIRVersion._4_4_0;
@ -7232,9 +7232,9 @@ public String toCode(int len) {
return FHIRVersion._4_5_0; return FHIRVersion._4_5_0;
if ("4.6.0".equals(codeString)) if ("4.6.0".equals(codeString))
return FHIRVersion._4_6_0; return FHIRVersion._4_6_0;
if ("5.0.0-snapshot1".equals(codeString)) if ("5.0.0-snapshot1".equalsIgnoreCase(codeString))
return FHIRVersion._5_0_0SNAPSHOT1; return FHIRVersion._5_0_0SNAPSHOT1;
if ("5.0.0-cibuild".equals(codeString)) if ("5.0.0-cibuild".equalsIgnoreCase(codeString))
return FHIRVersion._5_0_0CIBUILD; return FHIRVersion._5_0_0CIBUILD;
throw new IllegalArgumentException("Unknown FHIRVersion code '"+codeString+"'"); throw new IllegalArgumentException("Unknown FHIRVersion code '"+codeString+"'");
} }

View File

@ -33,11 +33,29 @@ public class LiquidRenderer extends ResourceRenderer {
this.liquidTemplate = liquidTemplate; 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 @Override
public boolean render(XhtmlNode x, Resource r) throws FHIRFormatError, DefinitionException, IOException, FHIRException, EOperationOutcome { public boolean render(XhtmlNode x, Resource r) throws FHIRFormatError, DefinitionException, IOException, FHIRException, EOperationOutcome {
LiquidEngine engine = new LiquidEngine(context.getWorker(), context.getServices()); LiquidEngine engine = new LiquidEngine(context.getWorker(), context.getServices());
XhtmlNode xn; XhtmlNode xn;
try { try {
engine.setIncludeResolver(new LiquidRendererIncludeResolver(context));
LiquidDocument doc = engine.parse(liquidTemplate, "template"); LiquidDocument doc = engine.parse(liquidTemplate, "template");
String html = engine.evaluate(doc, r, rcontext); String html = engine.evaluate(doc, r, rcontext);
xn = new XhtmlParser().parseFragment(html); xn = new XhtmlParser().parseFragment(html);

View File

@ -213,7 +213,7 @@ public class ValueSetRenderer extends TerminologyRenderer {
XhtmlNode t = x.table( "codes"); XhtmlNode t = x.table( "codes");
XhtmlNode tr = t.tr(); XhtmlNode tr = t.tr();
if (doLevel) if (doLevel)
tr.td().b().tx("Lvl"); tr.td().b().tx("Level");
tr.td().attribute("style", "white-space:nowrap").b().tx("Code"); tr.td().attribute("style", "white-space:nowrap").b().tx("Code");
if (doSystem) if (doSystem)
tr.td().b().tx("System"); tr.td().b().tx("System");
@ -242,7 +242,7 @@ public class ValueSetRenderer extends TerminologyRenderer {
addMapHeaders(tr, maps); addMapHeaders(tr, maps);
for (ValueSetExpansionContainsComponent c : vs.getExpansion().getContains()) { 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 // now, build observed languages
@ -1165,7 +1165,7 @@ public class ValueSetRenderer extends TerminologyRenderer {
ValueSetExpansionComponent vse = null; ValueSetExpansionComponent vse = null;
if (!context.isNoSlowLookup() && !getContext().getWorker().hasCache()) { if (!context.isNoSlowLookup() && !getContext().getWorker().hasCache()) {
try { try {
ValueSetExpansionOutcome vso = getContext().getWorker().expandVS(inc, false); ValueSetExpansionOutcome vso = getContext().getWorker().expandVS(inc, false, false);
ValueSet valueset = vso.getValueset(); ValueSet valueset = vso.getValueset();
if (valueset == null) if (valueset == null)
throw new TerminologyServiceException("Error Expanding ValueSet: "+vso.getError()); throw new TerminologyServiceException("Error Expanding ValueSet: "+vso.getError());

View File

@ -249,7 +249,7 @@ public class CodeSystemUtilities {
public static boolean isInactive(CodeSystem cs, ConceptDefinitionComponent def) throws FHIRException { public static boolean isInactive(CodeSystem cs, ConceptDefinitionComponent def) throws FHIRException {
for (ConceptPropertyComponent p : def.getProperty()) { for (ConceptPropertyComponent p : def.getProperty()) {
if ("status".equals(p.getCode()) && p.hasValueStringType()) 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; return false;
} }

View File

@ -108,6 +108,8 @@ import org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionParameterComponent;
import org.hl7.fhir.r5.utils.ToolingExtensions; import org.hl7.fhir.r5.utils.ToolingExtensions;
import org.hl7.fhir.utilities.Utilities; import org.hl7.fhir.utilities.Utilities;
import com.google.errorprone.annotations.NoAllocation;
public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetExpander { public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetExpander {
public class PropertyFilter implements IConceptFilter { public class PropertyFilter implements IConceptFilter {
@ -201,10 +203,15 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx
maxExpansionSize = theMaxExpansionSize; maxExpansionSize = theMaxExpansionSize;
} }
private ValueSetExpansionContainsComponent addCode(String system, String code, String display, ValueSetExpansionContainsComponent parent, List<ConceptDefinitionDesignationComponent> designations, Parameters expParams, boolean isAbstract, boolean inactive, List<ValueSet> filters) { private ValueSetExpansionContainsComponent addCode(String system, String code, String display, ValueSetExpansionContainsComponent parent, List<ConceptDefinitionDesignationComponent> designations, Parameters expParams,
boolean isAbstract, boolean inactive, List<ValueSet> filters, boolean noInactive) {
if (filters != null && !filters.isEmpty() && !filterContainsCode(filters, system, code)) if (filters != null && !filters.isEmpty() && !filterContainsCode(filters, system, code))
return null; return null;
if (noInactive && inactive) {
return null;
}
ValueSetExpansionContainsComponent n = new ValueSet.ValueSetExpansionContainsComponent(); ValueSetExpansionContainsComponent n = new ValueSet.ValueSetExpansionContainsComponent();
n.setSystem(system); n.setSystem(system);
n.setCode(code); n.setCode(code);
@ -267,12 +274,12 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx
return null; return null;
} }
private void addCodeAndDescendents(ValueSetExpansionContainsComponent focus, ValueSetExpansionContainsComponent parent, Parameters expParams, List<ValueSet> filters) throws FHIRException { private void addCodeAndDescendents(ValueSetExpansionContainsComponent focus, ValueSetExpansionContainsComponent parent, Parameters expParams, List<ValueSet> filters, boolean noInactive) throws FHIRException {
focus.checkNoModifiers("Expansion.contains", "expanding"); focus.checkNoModifiers("Expansion.contains", "expanding");
ValueSetExpansionContainsComponent np = addCode(focus.getSystem(), focus.getCode(), focus.getDisplay(), parent, 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()) for (ValueSetExpansionContainsComponent c : focus.getContains())
addCodeAndDescendents(focus, np, expParams, filters); addCodeAndDescendents(focus, np, expParams, filters, noInactive);
} }
private List<ConceptDefinitionDesignationComponent> convert(List<ConceptReferenceDesignationComponent> designations) { private List<ConceptDefinitionDesignationComponent> convert(List<ConceptReferenceDesignationComponent> designations) {
@ -287,7 +294,7 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx
return list; return list;
} }
private void addCodeAndDescendents(CodeSystem cs, String system, ConceptDefinitionComponent def, ValueSetExpansionContainsComponent parent, Parameters expParams, List<ValueSet> filters, ConceptDefinitionComponent exclusion, IConceptFilter filterFunc) throws FHIRException { private void addCodeAndDescendents(CodeSystem cs, String system, ConceptDefinitionComponent def, ValueSetExpansionContainsComponent parent, Parameters expParams, List<ValueSet> filters, ConceptDefinitionComponent exclusion, IConceptFilter filterFunc, boolean noInactive) throws FHIRException {
def.checkNoModifiers("Code in Code System", "expanding"); def.checkNoModifiers("Code in Code System", "expanding");
if (exclusion != null) { if (exclusion != null) {
if (exclusion.getCode().equals(def.getCode())) if (exclusion.getCode().equals(def.getCode()))
@ -298,30 +305,30 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx
boolean abs = CodeSystemUtilities.isNotSelectable(cs, def); boolean abs = CodeSystemUtilities.isNotSelectable(cs, def);
boolean inc = CodeSystemUtilities.isInactive(cs, def); boolean inc = CodeSystemUtilities.isInactive(cs, def);
if ((includeAbstract || !abs) && filterFunc.includeConcept(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()) { 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)) { if (def.hasUserData(CodeSystemUtilities.USER_DATA_CROSS_LINK)) {
List<ConceptDefinitionComponent> children = (List<ConceptDefinitionComponent>) def.getUserData(CodeSystemUtilities.USER_DATA_CROSS_LINK); List<ConceptDefinitionComponent> children = (List<ConceptDefinitionComponent>) def.getUserData(CodeSystemUtilities.USER_DATA_CROSS_LINK);
for (ConceptDefinitionComponent c : children) for (ConceptDefinitionComponent c : children)
addCodeAndDescendents(cs, system, c, np, expParams, filters, exclusion, filterFunc); addCodeAndDescendents(cs, system, c, np, expParams, filters, exclusion, filterFunc, noInactive);
} }
} else { } else {
for (ConceptDefinitionComponent c : def.getConcept()) { 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)) { if (def.hasUserData(CodeSystemUtilities.USER_DATA_CROSS_LINK)) {
List<ConceptDefinitionComponent> children = (List<ConceptDefinitionComponent>) def.getUserData(CodeSystemUtilities.USER_DATA_CROSS_LINK); List<ConceptDefinitionComponent> children = (List<ConceptDefinitionComponent>) def.getUserData(CodeSystemUtilities.USER_DATA_CROSS_LINK);
for (ConceptDefinitionComponent c : children) 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<ValueSetExpansionParameterComponent> params, Parameters expParams, List<ValueSet> filters) throws ETooCostly, FHIRException { private void addCodes(ValueSetExpansionComponent expand, List<ValueSetExpansionParameterComponent> params, Parameters expParams, List<ValueSet> filters, boolean noInactive) throws ETooCostly, FHIRException {
if (expand != null) { if (expand != null) {
if (expand.getContains().size() > maxExpansionSize) if (expand.getContains().size() > maxExpansionSize)
throw failCostly("Too many codes to display (>" + Integer.toString(expand.getContains().size()) + ")"); 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); 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()); CodeSystem cs = context.fetchCodeSystem(exc.getSystem());
if ((cs == null || cs.getContent() != CodeSystemContentMode.COMPLETE) && context.supportsSystem(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(); ValueSet valueset = vse.getValueset();
if (valueset == null) if (valueset == null)
throw failTSE("Error Expanding ValueSet: "+vse.getError()); throw failTSE("Error Expanding ValueSet: "+vse.getError());
@ -474,11 +481,11 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx
first = false; first = false;
else else
canBeHeirarchy = false; 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) if (value == null)
throw fail("unable to find value set with no identity"); throw fail("unable to find value set with no identity");
ValueSet vs = context.fetchResource(ValueSet.class, value); 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); 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); ValueSetExpansionOutcome vso = new ValueSetExpanderSimple(context, allErrors).expand(vs, expParams);
if (vso.getError() != null) { if (vso.getError() != null) {
addErrors(vso.getAllErrors()); addErrors(vso.getAllErrors());
@ -543,19 +554,19 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx
} }
} }
private void copyImportContains(List<ValueSetExpansionContainsComponent> list, ValueSetExpansionContainsComponent parent, Parameters expParams, List<ValueSet> filter) throws FHIRException { private void copyImportContains(List<ValueSetExpansionContainsComponent> list, ValueSetExpansionContainsComponent parent, Parameters expParams, List<ValueSet> filter, boolean noInactive) throws FHIRException {
for (ValueSetExpansionContainsComponent c : list) { for (ValueSetExpansionContainsComponent c : list) {
c.checkNoModifiers("Imported Expansion in Code System", "expanding"); 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); ValueSetExpansionContainsComponent np = addCode(c.getSystem(), c.getCode(), c.getDisplay(), parent, null, expParams, c.getAbstract(), c.getInactive(), filter, noInactive);
copyImportContains(c.getContains(), np, expParams, filter); copyImportContains(c.getContains(), np, expParams, filter, noInactive);
} }
} }
private void includeCodes(ConceptSetComponent inc, ValueSetExpansionComponent exp, Parameters expParams, boolean heirarchical, List<Extension> extensions) throws ETooCostly, FileNotFoundException, IOException, FHIRException { private void includeCodes(ConceptSetComponent inc, ValueSetExpansionComponent exp, Parameters expParams, boolean heirarchical, boolean noInactive, List<Extension> extensions) throws ETooCostly, FileNotFoundException, IOException, FHIRException {
inc.checkNoModifiers("Compose.include", "expanding"); inc.checkNoModifiers("Compose.include", "expanding");
List<ValueSet> imports = new ArrayList<ValueSet>(); List<ValueSet> imports = new ArrayList<ValueSet>();
for (UriType imp : inc.getValueSet()) { for (UriType imp : inc.getValueSet()) {
imports.add(importValueSet(imp.getValue(), exp, expParams)); imports.add(importValueSet(imp.getValue(), exp, expParams, noInactive));
} }
if (!inc.hasSystem()) { if (!inc.hasSystem()) {
@ -564,19 +575,19 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx
ValueSet base = imports.get(0); ValueSet base = imports.get(0);
imports.remove(0); imports.remove(0);
base.checkNoModifiers("Imported ValueSet", "expanding"); base.checkNoModifiers("Imported ValueSet", "expanding");
copyImportContains(base.getExpansion().getContains(), null, expParams, imports); copyImportContains(base.getExpansion().getContains(), null, expParams, imports, noInactive);
} else { } else {
CodeSystem cs = context.fetchCodeSystem(inc.getSystem()); CodeSystem cs = context.fetchCodeSystem(inc.getSystem());
if (isServerSide(inc.getSystem()) || (cs == null || (cs.getContent() != CodeSystemContentMode.COMPLETE && cs.getContent() != CodeSystemContentMode.FRAGMENT))) { 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 { } else {
doInternalIncludeCodes(inc, exp, expParams, imports, cs); doInternalIncludeCodes(inc, exp, expParams, imports, cs, noInactive);
} }
} }
} }
private void doServerIncludeCodes(ConceptSetComponent inc, boolean heirarchical, ValueSetExpansionComponent exp, List<ValueSet> imports, Parameters expParams, List<Extension> extensions) throws FHIRException { private void doServerIncludeCodes(ConceptSetComponent inc, boolean heirarchical, ValueSetExpansionComponent exp, List<ValueSet> imports, Parameters expParams, List<Extension> extensions, boolean noInactive) throws FHIRException {
ValueSetExpansionOutcome vso = context.expandVS(inc, heirarchical); ValueSetExpansionOutcome vso = context.expandVS(inc, heirarchical, noInactive);
if (vso.getError() != null) { if (vso.getError() != null) {
throw failTSE("Unable to expand imported value set: " + vso.getError()); 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()) { 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; return false;
} }
public void doInternalIncludeCodes(ConceptSetComponent inc, ValueSetExpansionComponent exp, Parameters expParams, List<ValueSet> imports, CodeSystem cs) throws NoTerminologyServiceException, TerminologyServiceException, FHIRException { public void doInternalIncludeCodes(ConceptSetComponent inc, ValueSetExpansionComponent exp, Parameters expParams, List<ValueSet> imports, CodeSystem cs, boolean noInactive) throws NoTerminologyServiceException, TerminologyServiceException, FHIRException {
if (cs == null) { if (cs == null) {
if (context.isNoTerminologyServer()) if (context.isNoTerminologyServer())
throw failTSE("Unable to find code system " + inc.getSystem().toString()); 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) { if (inc.getConcept().size() == 0 && inc.getFilter().size() == 0) {
// special case - add all the code system // special case - add all the code system
for (ConceptDefinitionComponent def : cs.getConcept()) { 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) { if (cs.getContent() == CodeSystemContentMode.FRAGMENT) {
addFragmentWarning(exp, cs); addFragmentWarning(exp, cs);
@ -658,7 +669,7 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx
} else { } else {
inactive = CodeSystemUtilities.isInactive(cs, def); 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) { if (inc.getFilter().size() > 1) {
@ -675,14 +686,14 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx
ConceptDefinitionComponent def = getConceptForCode(cs.getConcept(), fc.getValue()); ConceptDefinitionComponent def = getConceptForCode(cs.getConcept(), fc.getValue());
if (def == null) if (def == null)
throw failTSE("Code '" + fc.getValue() + "' not found in system '" + inc.getSystem() + "'"); 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) { } else if ("concept".equals(fc.getProperty()) && fc.getOp() == FilterOperator.ISNOTA) {
// special: all codes in the target code system that are not under the value // special: all codes in the target code system that are not under the value
ConceptDefinitionComponent defEx = getConceptForCode(cs.getConcept(), fc.getValue()); ConceptDefinitionComponent defEx = getConceptForCode(cs.getConcept(), fc.getValue());
if (defEx == null) if (defEx == null)
throw failTSE("Code '" + fc.getValue() + "' not found in system '" + inc.getSystem() + "'"); throw failTSE("Code '" + fc.getValue() + "' not found in system '" + inc.getSystem() + "'");
for (ConceptDefinitionComponent def : cs.getConcept()) { 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) { } else if ("concept".equals(fc.getProperty()) && fc.getOp() == FilterOperator.DESCENDENTOF) {
// special: all codes in the target code system under the value // 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) if (def == null)
throw failTSE("Code '" + fc.getValue() + "' not found in system '" + inc.getSystem() + "'"); throw failTSE("Code '" + fc.getValue() + "' not found in system '" + inc.getSystem() + "'");
for (ConceptDefinitionComponent c : def.getConcept()) 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)) { if (def.hasUserData(CodeSystemUtilities.USER_DATA_CROSS_LINK)) {
List<ConceptDefinitionComponent> children = (List<ConceptDefinitionComponent>) def.getUserData(CodeSystemUtilities.USER_DATA_CROSS_LINK); List<ConceptDefinitionComponent> children = (List<ConceptDefinitionComponent>) def.getUserData(CodeSystemUtilities.USER_DATA_CROSS_LINK);
for (ConceptDefinitionComponent c : children) 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) { } 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 (isNotBlank(def.getDisplay()) && isNotBlank(fc.getValue())) {
if (def.getDisplay().contains(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), 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())) { } else if (isDefinedProperty(cs, fc.getProperty())) {
for (ConceptDefinitionComponent def : cs.getConcept()) { 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 { } else {
throw fail("Search by property[" + fc.getProperty() + "] and op[" + fc.getOp() + "] is not supported yet"); throw fail("Search by property[" + fc.getProperty() + "] and op[" + fc.getOp() + "] is not supported yet");

View File

@ -108,12 +108,14 @@ public class TestingUtilities extends BaseTestingUtilities {
public static SimpleWorkerContext getWorkerContext(NpmPackage npmPackage) throws Exception { public static SimpleWorkerContext getWorkerContext(NpmPackage npmPackage) throws Exception {
SimpleWorkerContext swc = new SimpleWorkerContext.SimpleWorkerContextBuilder().withUserAgent(TestConstants.USER_AGENT).withTerminologyCachePath(TestConstants.TX_CACHE).fromPackage(npmPackage); SimpleWorkerContext swc = new SimpleWorkerContext.SimpleWorkerContextBuilder().withUserAgent(TestConstants.USER_AGENT).withTerminologyCachePath(TestConstants.TX_CACHE).fromPackage(npmPackage);
TerminologyCache.setCacheErrors(true); TerminologyCache.setCacheErrors(true);
swc.setAllowLoadingDuplicates(true);
return swc; return swc;
} }
public static SimpleWorkerContext getWorkerContext(NpmPackage npmPackage, IWorkerContext.IContextResourceLoader loader) throws Exception { 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); SimpleWorkerContext swc = new SimpleWorkerContext.SimpleWorkerContextBuilder().withUserAgent(TestConstants.USER_AGENT).withTerminologyCachePath(TestConstants.TX_CACHE).fromPackage(npmPackage, loader);
TerminologyCache.setCacheErrors(true); TerminologyCache.setCacheErrors(true);
swc.setAllowLoadingDuplicates(true);
return swc; return swc;
} }

View File

@ -235,6 +235,18 @@ public class FHIRPathEngine {
} }
return res; 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 IWorkerContext worker;
private IEvaluationContext hostServices; private IEvaluationContext hostServices;
@ -5472,7 +5484,7 @@ public class FHIRPathEngine {
* @throws PathEngineException * @throws PathEngineException
* @throws DefinitionException * @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; StructureDefinition sd = profile;
TypedElementDefinition focus = null; TypedElementDefinition focus = null;
boolean okToNotResolve = false; boolean okToNotResolve = false;
@ -5584,10 +5596,19 @@ public class FHIRPathEngine {
} else { } else {
throw makeException(expr, I18nConstants.FHIRPATH_DISCRIMINATOR_CANT_FIND, expr.toString(), source.getUrl(), element.getElement().getId(), profile.getUrl()); throw makeException(expr, I18nConstants.FHIRPATH_DISCRIMINATOR_CANT_FIND, expr.toString(), source.getUrl(), element.getElement().getId(), profile.getUrl());
} }
} else if (expr.getInner() == null) { } else {
// 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; return focus;
} else { } else {
return evaluateDefinition(expr.getInner(), sd, focus, profile); return evaluateDefinition(next, sd, focus, profile, dontWalkIntoReferences);
}
} }
} }

View File

@ -1,13 +1,31 @@
package org.hl7.fhir.r5.context; 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.TerminologyClient;
import org.hl7.fhir.r5.terminologies.ValueSetCheckerSimple; import org.hl7.fhir.r5.terminologies.ValueSetCheckerSimple;
import org.hl7.fhir.r5.terminologies.ValueSetExpander; import org.hl7.fhir.r5.terminologies.ValueSetExpander;
import org.hl7.fhir.r5.terminologies.ValueSetExpanderSimple; import org.hl7.fhir.r5.terminologies.ValueSetExpanderSimple;
import org.hl7.fhir.r5.utils.validation.ValidationContextCarrier; import org.hl7.fhir.r5.utils.validation.ValidationContextCarrier;
import org.hl7.fhir.utilities.ToolingClientLogger; import org.hl7.fhir.utilities.ToolingClientLogger;
import org.hl7.fhir.utilities.graphql.Value;
import org.hl7.fhir.utilities.validation.ValidationOptions; import org.hl7.fhir.utilities.validation.ValidationOptions;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -18,15 +36,6 @@ import org.mockito.Mockito;
import org.mockito.Spy; import org.mockito.Spy;
import org.mockito.junit.jupiter.MockitoExtension; 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) @ExtendWith(MockitoExtension.class)
public class SimpleWorkerContextTests { public class SimpleWorkerContextTests {
@ -251,12 +260,13 @@ public class SimpleWorkerContextTests {
ValueSet vs = new ValueSet(); ValueSet vs = new ValueSet();
vs.setStatus(Enumerations.PublicationStatus.ACTIVE); vs.setStatus(Enumerations.PublicationStatus.ACTIVE);
vs.setCompose(new ValueSet.ValueSetComposeComponent()); vs.setCompose(new ValueSet.ValueSetComposeComponent());
vs.getCompose().setInactive(true);
vs.getCompose().getInclude().add(inc); vs.getCompose().getInclude().add(inc);
Mockito.doReturn(cacheToken).when(terminologyCache).generateExpandToken(argThat(new ValueSetMatcher(vs)),eq(true)); Mockito.doReturn(cacheToken).when(terminologyCache).generateExpandToken(argThat(new ValueSetMatcher(vs)),eq(true));
Mockito.doReturn(expectedExpansionResult).when(terminologyCache).getExpansion(cacheToken); 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); assertEquals(expectedExpansionResult, actualExpansionResult);
@ -273,6 +283,7 @@ public class SimpleWorkerContextTests {
ValueSet vs = new ValueSet(); ValueSet vs = new ValueSet();
vs.setStatus(Enumerations.PublicationStatus.ACTIVE); vs.setStatus(Enumerations.PublicationStatus.ACTIVE);
vs.setCompose(new ValueSet.ValueSetComposeComponent()); vs.setCompose(new ValueSet.ValueSetComposeComponent());
vs.getCompose().setInactive(true);
vs.getCompose().getInclude().add(inc); vs.getCompose().getInclude().add(inc);
Mockito.doReturn(cacheToken).when(terminologyCache).generateExpandToken(argThat(new ValueSetMatcher(vs)),eq(true)); 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)), Mockito.doReturn(expectedValueSet).when(terminologyClient).expandValueset(argThat(new ValueSetMatcher(vs)),
argThat(new ParametersMatcher(pInWithDependentResources)), eq(params)); 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()); assertEquals(expectedValueSet, actualExpansionResult.getValueset());

View File

@ -1,15 +1,9 @@
package org.hl7.fhir.r5.context; package org.hl7.fhir.r5.context;
import com.google.gson.JsonElement; import static org.junit.jupiter.api.Assertions.assertEquals;
import com.google.gson.JsonParser; import static org.junit.jupiter.api.Assertions.assertFalse;
import org.hl7.fhir.r5.formats.IParser; import static org.junit.jupiter.api.Assertions.assertNull;
import org.hl7.fhir.r5.model.*; import static org.junit.jupiter.api.Assertions.assertTrue;
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 java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -25,8 +19,22 @@ import java.util.stream.Collectors;
import java.util.stream.IntStream; import java.util.stream.IntStream;
import java.util.stream.Stream; import java.util.stream.Stream;
import static org.junit.jupiter.api.Assertions.*; import org.hl7.fhir.r5.formats.IParser;
import static org.mockito.Mockito.mock; 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 { public class TerminologyCacheTests {

View File

@ -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;
}
}

View File

@ -1,14 +1,11 @@
package org.hl7.fhir.r5.formats; 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 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 { class FormatUtilitiesTest {

View File

@ -1,6 +1,5 @@
package org.hl7.fhir.r5.model; package org.hl7.fhir.r5.model;
import org.hl7.fhir.r5.model.Base64BinaryType;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;

View File

@ -1,6 +1,5 @@
package org.hl7.fhir.r5.model; package org.hl7.fhir.r5.model;
import org.hl7.fhir.r5.model.BooleanType;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;

View File

@ -1,6 +1,5 @@
package org.hl7.fhir.r5.model; package org.hl7.fhir.r5.model;
import org.hl7.fhir.r5.model.CanonicalType;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;

View File

@ -1,6 +1,5 @@
package org.hl7.fhir.r5.model; package org.hl7.fhir.r5.model;
import org.hl7.fhir.r5.model.CodeType;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;

View File

@ -1,6 +1,5 @@
package org.hl7.fhir.r5.model; package org.hl7.fhir.r5.model;
import org.hl7.fhir.r5.model.DateTimeType;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;

View File

@ -1,6 +1,5 @@
package org.hl7.fhir.r5.model; package org.hl7.fhir.r5.model;
import org.hl7.fhir.r5.model.DateType;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;

View File

@ -1,6 +1,5 @@
package org.hl7.fhir.r5.model; package org.hl7.fhir.r5.model;
import org.hl7.fhir.r5.model.DecimalType;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;

View File

@ -1,6 +1,5 @@
package org.hl7.fhir.r5.model; package org.hl7.fhir.r5.model;
import org.hl7.fhir.r5.model.IdType;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;

View File

@ -1,6 +1,5 @@
package org.hl7.fhir.r5.model; package org.hl7.fhir.r5.model;
import org.hl7.fhir.r5.model.InstantType;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;

View File

@ -1,6 +1,5 @@
package org.hl7.fhir.r5.model; package org.hl7.fhir.r5.model;
import org.hl7.fhir.r5.model.IntegerType;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;

View File

@ -1,6 +1,5 @@
package org.hl7.fhir.r5.model; package org.hl7.fhir.r5.model;
import org.hl7.fhir.r5.model.MarkdownType;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;

View File

@ -1,6 +1,5 @@
package org.hl7.fhir.r5.model; package org.hl7.fhir.r5.model;
import org.hl7.fhir.r5.model.OidType;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;

View File

@ -1,6 +1,5 @@
package org.hl7.fhir.r5.model; package org.hl7.fhir.r5.model;
import org.hl7.fhir.r5.model.PositiveIntType;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;

View File

@ -1,6 +1,5 @@
package org.hl7.fhir.r5.model; package org.hl7.fhir.r5.model;
import org.hl7.fhir.r5.model.StringType;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;

View File

@ -1,6 +1,5 @@
package org.hl7.fhir.r5.model; package org.hl7.fhir.r5.model;
import org.hl7.fhir.r5.model.TimeType;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;

View File

@ -1,6 +1,5 @@
package org.hl7.fhir.r5.model; package org.hl7.fhir.r5.model;
import org.hl7.fhir.r5.model.UnsignedIntType;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;

View File

@ -1,6 +1,5 @@
package org.hl7.fhir.r5.model; package org.hl7.fhir.r5.model;
import org.hl7.fhir.r5.model.UriType;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;

View File

@ -1,6 +1,5 @@
package org.hl7.fhir.r5.model; package org.hl7.fhir.r5.model;
import org.hl7.fhir.r5.model.UrlType;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;

View File

@ -1,6 +1,5 @@
package org.hl7.fhir.r5.model; package org.hl7.fhir.r5.model;
import org.hl7.fhir.r5.model.UuidType;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;

View File

@ -25,7 +25,6 @@ import org.hl7.fhir.r5.model.Quantity;
import org.hl7.fhir.r5.model.Resource; import org.hl7.fhir.r5.model.Resource;
import org.hl7.fhir.r5.model.TypeDetails; import org.hl7.fhir.r5.model.TypeDetails;
import org.hl7.fhir.r5.model.ValueSet; 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.test.utils.TestingUtilities;
import org.hl7.fhir.r5.utils.FHIRPathEngine; import org.hl7.fhir.r5.utils.FHIRPathEngine;
import org.hl7.fhir.r5.utils.FHIRPathEngine.IEvaluationContext; import org.hl7.fhir.r5.utils.FHIRPathEngine.IEvaluationContext;

View File

@ -1,51 +1,35 @@
package org.hl7.fhir.r5.test; 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.io.IOException;
import java.time.ZoneId; import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Stream; import java.util.stream.Stream;
import javax.xml.parsers.ParserConfigurationException; 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.FHIRException;
import org.hl7.fhir.exceptions.FHIRFormatError; import org.hl7.fhir.exceptions.FHIRFormatError;
import org.hl7.fhir.r5.context.IWorkerContext; import org.hl7.fhir.r5.context.IWorkerContext;
import org.hl7.fhir.r5.elementmodel.Manager; import org.hl7.fhir.r5.elementmodel.Manager;
import org.hl7.fhir.r5.elementmodel.Manager.FhirFormat; 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.JsonParser;
import org.hl7.fhir.r5.formats.XmlParser; import org.hl7.fhir.r5.formats.XmlParser;
import org.hl7.fhir.r5.model.Base; 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.model.Resource;
import org.hl7.fhir.r5.renderers.RendererFactory; 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.ElementWrappers;
import org.hl7.fhir.r5.renderers.utils.RenderingContext; 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.ITypeParser;
import org.hl7.fhir.r5.renderers.utils.RenderingContext.QuestionnaireRendererMode;
import org.hl7.fhir.r5.renderers.utils.RenderingContext.ResourceRendererMode; 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.r5.test.utils.TestingUtilities;
import org.hl7.fhir.utilities.TerminologyServiceOptions; import org.hl7.fhir.utilities.TerminologyServiceOptions;
import org.hl7.fhir.utilities.TextFile; import org.hl7.fhir.utilities.TextFile;
import org.hl7.fhir.utilities.xhtml.XhtmlComposer; import org.hl7.fhir.utilities.xhtml.XhtmlComposer;
import org.hl7.fhir.utilities.xhtml.XhtmlNode; import org.hl7.fhir.utilities.xhtml.XhtmlNode;
import org.hl7.fhir.utilities.xhtml.XhtmlParser;
import org.hl7.fhir.utilities.xml.XMLUtil; import org.hl7.fhir.utilities.xml.XMLUtil;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource; import org.junit.jupiter.params.provider.MethodSource;

View File

@ -5,11 +5,7 @@ import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.time.ZoneId; import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter; 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.DefinitionException;
import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.FHIRException;

View File

@ -1,5 +1,8 @@
package org.hl7.fhir.r5.test; package org.hl7.fhir.r5.test;
import java.util.ArrayList;
import java.util.List;
import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r5.conformance.ProfileUtilities; import org.hl7.fhir.r5.conformance.ProfileUtilities;
import org.hl7.fhir.r5.model.Base; 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.Assertions;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.List;
public class ProfileUtilitiesTests { public class ProfileUtilitiesTests {
// /** // /**

View File

@ -1,5 +1,7 @@
package org.hl7.fhir.r5.test; package org.hl7.fhir.r5.test;
import java.io.IOException;
import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r5.model.Enumerations; import org.hl7.fhir.r5.model.Enumerations;
import org.hl7.fhir.r5.model.Extension; 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.Assertions;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import java.io.IOException;
public class ResourceCopyTests { public class ResourceCopyTests {

View File

@ -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.JsonParser;
import org.hl7.fhir.r5.formats.XmlParser; import org.hl7.fhir.r5.formats.XmlParser;
import org.hl7.fhir.r5.model.Bundle; 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.DomainResource;
import org.hl7.fhir.r5.model.Resource; import org.hl7.fhir.r5.model.Resource;
import org.hl7.fhir.r5.renderers.RendererFactory; 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.renderers.utils.RenderingContext.ResourceRendererMode;
import org.hl7.fhir.r5.test.utils.TestingUtilities; import org.hl7.fhir.r5.test.utils.TestingUtilities;
import org.hl7.fhir.r5.utils.EOperationOutcome; import org.hl7.fhir.r5.utils.EOperationOutcome;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
public class ResourceRoundTripTests { public class ResourceRoundTripTests {

View File

@ -1,6 +1,8 @@
package org.hl7.fhir.r5.test; 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; import java.io.IOException;

View File

@ -4,7 +4,6 @@ import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Stream; 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.exceptions.PathEngineException;
import org.hl7.fhir.r5.conformance.ProfileUtilities; import org.hl7.fhir.r5.conformance.ProfileUtilities;
import org.hl7.fhir.r5.conformance.ProfileUtilities.ProfileKnowledgeProvider; 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.IParser.OutputStyle;
import org.hl7.fhir.r5.formats.JsonParser; import org.hl7.fhir.r5.formats.JsonParser;
import org.hl7.fhir.r5.formats.XmlParser; import org.hl7.fhir.r5.formats.XmlParser;
import org.hl7.fhir.r5.model.Base; 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.ElementDefinition.ElementDefinitionBindingComponent;
import org.hl7.fhir.r5.model.ExpressionNode.CollectionStatus; import org.hl7.fhir.r5.model.ExpressionNode.CollectionStatus;
import org.hl7.fhir.r5.model.Resource; import org.hl7.fhir.r5.model.Resource;
import org.hl7.fhir.r5.model.StructureDefinition; import org.hl7.fhir.r5.model.StructureDefinition;
import org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind; import org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind;
import org.hl7.fhir.r5.model.StructureDefinition.TypeDerivationRule; 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.RendererFactory;
import org.hl7.fhir.r5.renderers.utils.RenderingContext; import org.hl7.fhir.r5.renderers.utils.RenderingContext;
import org.hl7.fhir.r5.renderers.utils.RenderingContext.ResourceRendererMode; 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.test.utils.TestingUtilities;
import org.hl7.fhir.r5.utils.FHIRPathEngine; import org.hl7.fhir.r5.utils.FHIRPathEngine;
import org.hl7.fhir.r5.utils.FHIRPathEngine.IEvaluationContext; 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.XVerExtensionManager;
import org.hl7.fhir.r5.utils.validation.IResourceValidator;
import org.hl7.fhir.utilities.Utilities; import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.utilities.npm.CommonPackages; import org.hl7.fhir.utilities.npm.CommonPackages;
import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager; import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager;
@ -60,41 +58,6 @@ import org.xml.sax.SAXException;
public class SnapShotGenerationTests { 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 { public enum TestFetchMode {
INPUT, INPUT,
OUTPUT, OUTPUT,
@ -549,7 +512,7 @@ public class SnapShotGenerationTests {
pu.setIds(test.getSource(), false); pu.setIds(test.getSource(), false);
if (!TestingUtilities.context().hasPackage(CommonPackages.ID_XVER, CommonPackages.VER_XVER)) { 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); 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())); pu.setXver(new XVerExtensionManager(TestingUtilities.context()));
if (test.isSort()) { if (test.isSort()) {

View File

@ -1,5 +1,8 @@
package org.hl7.fhir.r5.test; package org.hl7.fhir.r5.test;
import java.io.IOException;
import java.util.List;
import org.hl7.fhir.exceptions.FHIRException; import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r5.context.SimpleWorkerContext; import org.hl7.fhir.r5.context.SimpleWorkerContext;
import org.hl7.fhir.r5.model.Base; 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;
import org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleTargetComponent; import org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleTargetComponent;
import org.hl7.fhir.r5.test.utils.TestingUtilities; 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.ITransformerServices;
import org.hl7.fhir.r5.utils.structuremap.StructureMapUtilities;
import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager; import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager;
import org.hl7.fhir.utilities.npm.ToolsVersion; import org.hl7.fhir.utilities.npm.ToolsVersion;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.util.List;
public class StructureMapUtilitiesTest implements ITransformerServices { public class StructureMapUtilitiesTest implements ITransformerServices {
static private SimpleWorkerContext context; static private SimpleWorkerContext context;

View File

@ -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<String, String> 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<String, String> getParameters() {
return parameters;
}
public String getSource() {
return source;
}
public String getTarget() {
return target;
}
public TestType getType() {
return type;
}
}
public static Stream<Arguments> data() throws ParserConfigurationException, IOException, FHIRFormatError, SAXException {
Document tests = XMLUtil.parseToDom(TestingUtilities.loadTestResource("r5", "vocab", "manifest.xml"));
Element test = XMLUtil.getFirstChild(tests.getDocumentElement());
List<Arguments> 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());
}
}
}

View File

@ -4,8 +4,6 @@ import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class FHIRLexerTest { class FHIRLexerTest {
@Test @Test
@DisplayName("Test that a 'null' current value returns 'false' when FHIRLexer.isConstant() is called, and not NPE.") @DisplayName("Test that a 'null' current value returns 'false' when FHIRLexer.isConstant() is called, and not NPE.")

View File

@ -1,9 +1,22 @@
package org.hl7.fhir.r5.utils.client; package org.hl7.fhir.r5.utils.client;
import okhttp3.Headers; import java.io.IOException;
import okhttp3.Request; import java.net.URI;
import okhttp3.internal.http2.Header; import java.net.URISyntaxException;
import org.hl7.fhir.r5.model.*; 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.Client;
import org.hl7.fhir.r5.utils.client.network.ResourceRequest; import org.hl7.fhir.r5.utils.client.network.ResourceRequest;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
@ -13,11 +26,9 @@ import org.mockito.ArgumentCaptor;
import org.mockito.ArgumentMatchers; import org.mockito.ArgumentMatchers;
import org.mockito.Mockito; import org.mockito.Mockito;
import java.io.IOException; import okhttp3.Headers;
import java.net.URI; import okhttp3.Request;
import java.net.URISyntaxException; import okhttp3.internal.http2.Header;
import java.util.ArrayList;
import java.util.Arrays;
class FHIRToolingClientTest { class FHIRToolingClientTest {

View File

@ -1,14 +1,15 @@
package org.hl7.fhir.r5.utils.client.network; 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.hl7.fhir.exceptions.FHIRException;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import java.util.Arrays; import okhttp3.internal.http2.Header;
import java.util.List;
class ClientHeadersTest { class ClientHeadersTest {

View File

@ -1,21 +1,30 @@
package org.hl7.fhir.r5.utils.client.network; 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.io.IOException;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.util.Random; import java.util.Random;
import java.util.concurrent.TimeUnit; 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) @TestInstance(TestInstance.Lifecycle.PER_CLASS)
class ClientTest { class ClientTest {

View File

@ -1,17 +1,15 @@
package org.hl7.fhir.r5.utils.client.network; package org.hl7.fhir.r5.utils.client.network;
import okhttp3.Headers; import java.util.List;
import okhttp3.OkHttpClient; import java.util.Map;
import okhttp3.Request;
import org.hl7.fhir.r5.model.OperationOutcome; import org.hl7.fhir.r5.model.OperationOutcome;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import java.util.HashMap; import okhttp3.Headers;
import java.util.HashMap; import okhttp3.Request;
import java.util.List;
import java.util.Map;
class FhirRequestBuilderTest { class FhirRequestBuilderTest {

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>org.hl7.fhir.core</artifactId> <artifactId>org.hl7.fhir.core</artifactId>
<version>5.6.35</version> <version>5.6.37-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>org.hl7.fhir.core</artifactId> <artifactId>org.hl7.fhir.core</artifactId>
<version>5.6.35</version> <version>5.6.37-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -39,8 +39,12 @@ class UtilitiesTest {
@Test @Test
@DisplayName("Test Utilities.path maps temp directory correctly") @DisplayName("Test Utilities.path maps temp directory correctly")
public void testTempDirPath() throws IOException { public void testTempDirPath() throws IOException {
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); Assertions.assertEquals(Utilities.path("[tmp]", TEST_TXT), getTempDirectory() + TEST_TXT);
} }
}
@Test @Test
@DisplayName("Test Utilities.path maps user directory correctly") @DisplayName("Test Utilities.path maps user directory correctly")

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>org.hl7.fhir.core</artifactId> <artifactId>org.hl7.fhir.core</artifactId>
<version>5.6.35</version> <version>5.6.37-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>ca.uhn.hapi.fhir</groupId> <groupId>ca.uhn.hapi.fhir</groupId>
<artifactId>org.hl7.fhir.core</artifactId> <artifactId>org.hl7.fhir.core</artifactId>
<version>5.6.35</version> <version>5.6.37-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

View File

@ -3405,13 +3405,17 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
return elements; 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 (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()")) { if (discriminator.equals("resolve()")) {
elements.add(element); elements.add(element);
return elements; return elements;
} }
if (discriminator.endsWith(".resolve()")) if (discriminator.endsWith(".resolve()")) {
discriminator = discriminator.substring(0, discriminator.length() - 10); discriminator = discriminator.substring(0, discriminator.length() - 10);
dontFollowReference = true;
}
} }
TypedElementDefinition ted = null; 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); throw new FHIRException(context.formatMessage(I18nConstants.DISCRIMINATOR_BAD_PATH, e.getMessage(), fp), e);
} }
long t2 = System.nanoTime(); 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); timeTracker.sd(t2);
if (ted != null) if (ted != null)
elements.add(ted.getElement()); elements.add(ted.getElement());
@ -3449,7 +3453,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
} }
expr = fpe.parse(fp); expr = fpe.parse(fp);
t2 = System.nanoTime(); 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); timeTracker.sd(t2);
if (ted != null) if (ted != null)
elements.add(ted.getElement()); elements.add(ted.getElement());

View File

@ -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.NodeStack;
import org.hl7.fhir.validation.instance.utils.ValidatorHostContext; 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})?"; 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 String serverBase;
private InstanceValidator validator; private InstanceValidator validator;

View File

@ -343,3 +343,12 @@ v: {
"system" : "http://snomed.info/sct" "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)"
}
-------------------------------------------------------------------------------------

View File

@ -14,12 +14,12 @@
HAPI FHIR HAPI FHIR
--> -->
<artifactId>org.hl7.fhir.core</artifactId> <artifactId>org.hl7.fhir.core</artifactId>
<version>5.6.35</version> <version>5.6.37-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<properties> <properties>
<hapi_fhir_version>5.4.0</hapi_fhir_version> <hapi_fhir_version>5.4.0</hapi_fhir_version>
<validator_test_case_version>1.1.89</validator_test_case_version> <validator_test_case_version>1.1.90</validator_test_case_version>
<junit_jupiter_version>5.7.1</junit_jupiter_version> <junit_jupiter_version>5.7.1</junit_jupiter_version>
<junit_platform_launcher_version>1.7.1</junit_platform_launcher_version> <junit_platform_launcher_version>1.7.1</junit_platform_launcher_version>
<maven_surefire_version>3.0.0-M5</maven_surefire_version> <maven_surefire_version>3.0.0-M5</maven_surefire_version>