Merge pull request #752 from hapifhir/gg-202202-various
Gg 202202 various
This commit is contained in:
commit
108651bc11
|
@ -1,7 +1,7 @@
|
|||
## Validator Changes
|
||||
|
||||
* no changes
|
||||
* No changes
|
||||
|
||||
## Other code changes
|
||||
|
||||
* no changes
|
||||
* fix expansions where inactive = false (was wrongly including inactive codes)
|
|
@ -666,10 +666,11 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte
|
|||
|
||||
|
||||
@Override
|
||||
public ValueSetExpansionOutcome expandVS(ConceptSetComponent inc, boolean hierarchical) throws TerminologyServiceException {
|
||||
public ValueSetExpansionOutcome expandVS(ConceptSetComponent inc, boolean hierarchical, boolean noInactive) throws TerminologyServiceException {
|
||||
ValueSet vs = new ValueSet();
|
||||
vs.setStatus(PublicationStatus.ACTIVE);
|
||||
vs.setCompose(new ValueSetComposeComponent());
|
||||
vs.getCompose().setInactive(!noInactive);
|
||||
vs.getCompose().getInclude().add(inc);
|
||||
CacheToken cacheToken = txCache.generateExpandToken(vs, hierarchical);
|
||||
ValueSetExpansionOutcome res;
|
||||
|
|
|
@ -124,6 +124,9 @@ public class CanonicalResourceManager<T extends CanonicalResource> {
|
|||
if (resource == null) {
|
||||
@SuppressWarnings("unchecked")
|
||||
T1 res = (T1) proxy.getResource();
|
||||
if (res == null) {
|
||||
throw new Error("Proxy loading a resource from "+packageInfo+" failed and returned null");
|
||||
}
|
||||
synchronized (this) {
|
||||
resource = res;
|
||||
}
|
||||
|
|
|
@ -547,7 +547,7 @@ public interface IWorkerContext {
|
|||
* @return
|
||||
* @throws FHIRException
|
||||
*/
|
||||
ValueSetExpansionOutcome expandVS(ConceptSetComponent inc, boolean hierarchical) throws TerminologyServiceException;
|
||||
ValueSetExpansionOutcome expandVS(ConceptSetComponent inc, boolean hierarchical, boolean noInactive) throws TerminologyServiceException;
|
||||
|
||||
Locale getLocale();
|
||||
|
||||
|
|
|
@ -6924,9 +6924,9 @@ The primary difference between a medicationusage and a medicationadministration
|
|||
return _4_1_0;
|
||||
if ("4.2.0".equals(codeString))
|
||||
return _4_2_0;
|
||||
if ("4.3.0-snapshot1".equals(codeString))
|
||||
if ("4.3.0-snapshot1".equalsIgnoreCase(codeString))
|
||||
return _4_3_0SNAPSHOT1;
|
||||
if ("4.3.0-cibuild".equals(codeString))
|
||||
if ("4.3.0-cibuild".equalsIgnoreCase(codeString))
|
||||
return _4_3_0CIBUILD;
|
||||
if ("4.4.0".equals(codeString))
|
||||
return _4_4_0;
|
||||
|
@ -6934,9 +6934,9 @@ The primary difference between a medicationusage and a medicationadministration
|
|||
return _4_5_0;
|
||||
if ("4.6.0".equals(codeString))
|
||||
return _4_6_0;
|
||||
if ("5.0.0-snapshot1".equals(codeString))
|
||||
if ("5.0.0-snapshot1".equalsIgnoreCase(codeString))
|
||||
return _5_0_0SNAPSHOT1;
|
||||
if ("5.0.0-cibuild".equals(codeString))
|
||||
if ("5.0.0-cibuild".equalsIgnoreCase(codeString))
|
||||
return _5_0_0CIBUILD;
|
||||
throw new FHIRException("Unknown FHIRVersion code '"+codeString+"'");
|
||||
}
|
||||
|
@ -7158,7 +7158,7 @@ public String toCode(int len) {
|
|||
|
||||
|
||||
public boolean isR4B() {
|
||||
return toCode().startsWith("4.1");
|
||||
return toCode().startsWith("4.1") ||toCode().startsWith("4.3");
|
||||
}
|
||||
|
||||
// end addition
|
||||
|
@ -7219,9 +7219,9 @@ public String toCode(int len) {
|
|||
return FHIRVersion._4_1_0;
|
||||
if ("4.2.0".equals(codeString))
|
||||
return FHIRVersion._4_2_0;
|
||||
if ("4.3.0-snapshot1".equals(codeString))
|
||||
if ("4.3.0-snapshot1".equalsIgnoreCase(codeString))
|
||||
return FHIRVersion._4_3_0SNAPSHOT1;
|
||||
if ("4.3.0-cibuild".equals(codeString))
|
||||
if ("4.3.0-cibuild".equalsIgnoreCase(codeString))
|
||||
return FHIRVersion._4_3_0CIBUILD;
|
||||
if ("4.4.0".equals(codeString))
|
||||
return FHIRVersion._4_4_0;
|
||||
|
@ -7229,9 +7229,9 @@ public String toCode(int len) {
|
|||
return FHIRVersion._4_5_0;
|
||||
if ("4.6.0".equals(codeString))
|
||||
return FHIRVersion._4_6_0;
|
||||
if ("5.0.0-snapshot1".equals(codeString))
|
||||
if ("5.0.0-snapshot1".equalsIgnoreCase(codeString))
|
||||
return FHIRVersion._5_0_0SNAPSHOT1;
|
||||
if ("5.0.0-cibuild".equals(codeString))
|
||||
if ("5.0.0-cibuild".equalsIgnoreCase(codeString))
|
||||
return FHIRVersion._5_0_0CIBUILD;
|
||||
throw new IllegalArgumentException("Unknown FHIRVersion code '"+codeString+"'");
|
||||
}
|
||||
|
|
|
@ -213,7 +213,7 @@ public class ValueSetRenderer extends TerminologyRenderer {
|
|||
XhtmlNode t = x.table( "codes");
|
||||
XhtmlNode tr = t.tr();
|
||||
if (doLevel)
|
||||
tr.td().b().tx("Lvl");
|
||||
tr.td().b().tx("Level");
|
||||
tr.td().attribute("style", "white-space:nowrap").b().tx("Code");
|
||||
if (doSystem)
|
||||
tr.td().b().tx("System");
|
||||
|
@ -242,7 +242,7 @@ public class ValueSetRenderer extends TerminologyRenderer {
|
|||
|
||||
addMapHeaders(tr, maps);
|
||||
for (ValueSetExpansionContainsComponent c : vs.getExpansion().getContains()) {
|
||||
addExpansionRowToTable(t, c, 0, doLevel, doSystem, doDefinition, maps, allCS, langs, doLangs);
|
||||
addExpansionRowToTable(t, c, 1, doLevel, doSystem, doDefinition, maps, allCS, langs, doLangs);
|
||||
}
|
||||
|
||||
// now, build observed languages
|
||||
|
@ -1165,7 +1165,7 @@ public class ValueSetRenderer extends TerminologyRenderer {
|
|||
ValueSetExpansionComponent vse = null;
|
||||
if (!context.isNoSlowLookup() && !getContext().getWorker().hasCache()) {
|
||||
try {
|
||||
ValueSetExpansionOutcome vso = getContext().getWorker().expandVS(inc, false);
|
||||
ValueSetExpansionOutcome vso = getContext().getWorker().expandVS(inc, false, false);
|
||||
ValueSet valueset = vso.getValueset();
|
||||
if (valueset == null)
|
||||
throw new TerminologyServiceException("Error Expanding ValueSet: "+vso.getError());
|
||||
|
|
|
@ -249,7 +249,7 @@ public class CodeSystemUtilities {
|
|||
public static boolean isInactive(CodeSystem cs, ConceptDefinitionComponent def) throws FHIRException {
|
||||
for (ConceptPropertyComponent p : def.getProperty()) {
|
||||
if ("status".equals(p.getCode()) && p.hasValueStringType())
|
||||
return "inactive".equals(p.getValueStringType());
|
||||
return "inactive".equals(p.getValueStringType().primitiveValue()) || "retired".equals(p.getValueStringType().primitiveValue());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -108,6 +108,8 @@ import org.hl7.fhir.r5.model.ValueSet.ValueSetExpansionParameterComponent;
|
|||
import org.hl7.fhir.r5.utils.ToolingExtensions;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
|
||||
import com.google.errorprone.annotations.NoAllocation;
|
||||
|
||||
public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetExpander {
|
||||
|
||||
public class PropertyFilter implements IConceptFilter {
|
||||
|
@ -201,10 +203,15 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx
|
|||
maxExpansionSize = theMaxExpansionSize;
|
||||
}
|
||||
|
||||
private ValueSetExpansionContainsComponent addCode(String system, String code, String display, ValueSetExpansionContainsComponent parent, List<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))
|
||||
return null;
|
||||
if (noInactive && inactive) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ValueSetExpansionContainsComponent n = new ValueSet.ValueSetExpansionContainsComponent();
|
||||
n.setSystem(system);
|
||||
n.setCode(code);
|
||||
|
@ -267,12 +274,12 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx
|
|||
return null;
|
||||
}
|
||||
|
||||
private void addCodeAndDescendents(ValueSetExpansionContainsComponent focus, ValueSetExpansionContainsComponent parent, Parameters expParams, List<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");
|
||||
ValueSetExpansionContainsComponent np = addCode(focus.getSystem(), focus.getCode(), focus.getDisplay(), parent,
|
||||
convert(focus.getDesignation()), expParams, focus.getAbstract(), focus.getInactive(), filters);
|
||||
convert(focus.getDesignation()), expParams, focus.getAbstract(), focus.getInactive(), filters, noInactive);
|
||||
for (ValueSetExpansionContainsComponent c : focus.getContains())
|
||||
addCodeAndDescendents(focus, np, expParams, filters);
|
||||
addCodeAndDescendents(focus, np, expParams, filters, noInactive);
|
||||
}
|
||||
|
||||
private List<ConceptDefinitionDesignationComponent> convert(List<ConceptReferenceDesignationComponent> designations) {
|
||||
|
@ -287,7 +294,7 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx
|
|||
return list;
|
||||
}
|
||||
|
||||
private void addCodeAndDescendents(CodeSystem cs, String system, ConceptDefinitionComponent def, ValueSetExpansionContainsComponent parent, Parameters expParams, List<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");
|
||||
if (exclusion != null) {
|
||||
if (exclusion.getCode().equals(def.getCode()))
|
||||
|
@ -298,30 +305,30 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx
|
|||
boolean abs = CodeSystemUtilities.isNotSelectable(cs, def);
|
||||
boolean inc = CodeSystemUtilities.isInactive(cs, def);
|
||||
if ((includeAbstract || !abs) && filterFunc.includeConcept(cs, def)) {
|
||||
np = addCode(system, def.getCode(), def.getDisplay(), parent, def.getDesignation(), expParams, abs, inc, filters);
|
||||
np = addCode(system, def.getCode(), def.getDisplay(), parent, def.getDesignation(), expParams, abs, inc, filters, noInactive);
|
||||
}
|
||||
for (ConceptDefinitionComponent c : def.getConcept()) {
|
||||
addCodeAndDescendents(cs, system, c, np, expParams, filters, exclusion, filterFunc);
|
||||
addCodeAndDescendents(cs, system, c, np, expParams, filters, exclusion, filterFunc, noInactive);
|
||||
}
|
||||
if (def.hasUserData(CodeSystemUtilities.USER_DATA_CROSS_LINK)) {
|
||||
List<ConceptDefinitionComponent> children = (List<ConceptDefinitionComponent>) def.getUserData(CodeSystemUtilities.USER_DATA_CROSS_LINK);
|
||||
for (ConceptDefinitionComponent c : children)
|
||||
addCodeAndDescendents(cs, system, c, np, expParams, filters, exclusion, filterFunc);
|
||||
addCodeAndDescendents(cs, system, c, np, expParams, filters, exclusion, filterFunc, noInactive);
|
||||
}
|
||||
} else {
|
||||
for (ConceptDefinitionComponent c : def.getConcept()) {
|
||||
addCodeAndDescendents(cs, system, c, null, expParams, filters, exclusion, filterFunc);
|
||||
addCodeAndDescendents(cs, system, c, null, expParams, filters, exclusion, filterFunc, noInactive);
|
||||
}
|
||||
if (def.hasUserData(CodeSystemUtilities.USER_DATA_CROSS_LINK)) {
|
||||
List<ConceptDefinitionComponent> children = (List<ConceptDefinitionComponent>) def.getUserData(CodeSystemUtilities.USER_DATA_CROSS_LINK);
|
||||
for (ConceptDefinitionComponent c : children)
|
||||
addCodeAndDescendents(cs, system, c, null, expParams, filters, exclusion, filterFunc);
|
||||
addCodeAndDescendents(cs, system, c, null, expParams, filters, exclusion, filterFunc, noInactive);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void addCodes(ValueSetExpansionComponent expand, List<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.getContains().size() > maxExpansionSize)
|
||||
throw failCostly("Too many codes to display (>" + Integer.toString(expand.getContains().size()) + ")");
|
||||
|
@ -330,7 +337,7 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx
|
|||
params.add(p);
|
||||
}
|
||||
|
||||
copyImportContains(expand.getContains(), null, expParams, filters);
|
||||
copyImportContains(expand.getContains(), null, expParams, filters, noInactive);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -354,7 +361,7 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx
|
|||
|
||||
CodeSystem cs = context.fetchCodeSystem(exc.getSystem());
|
||||
if ((cs == null || cs.getContent() != CodeSystemContentMode.COMPLETE) && context.supportsSystem(exc.getSystem())) {
|
||||
ValueSetExpansionOutcome vse = context.expandVS(exc, false);
|
||||
ValueSetExpansionOutcome vse = context.expandVS(exc, false, false);
|
||||
ValueSet valueset = vse.getValueset();
|
||||
if (valueset == null)
|
||||
throw failTSE("Error Expanding ValueSet: "+vse.getError());
|
||||
|
@ -474,11 +481,11 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx
|
|||
first = false;
|
||||
else
|
||||
canBeHeirarchy = false;
|
||||
includeCodes(inc, exp, expParams, canBeHeirarchy, extensions);
|
||||
includeCodes(inc, exp, expParams, canBeHeirarchy, compose.hasInactive() && !compose.getInactive(), extensions);
|
||||
}
|
||||
}
|
||||
|
||||
private ValueSet importValueSet(String value, ValueSetExpansionComponent exp, Parameters expParams) throws ETooCostly, TerminologyServiceException, FileNotFoundException, IOException, FHIRFormatError {
|
||||
private ValueSet importValueSet(String value, ValueSetExpansionComponent exp, Parameters expParams, boolean noInactive) throws ETooCostly, TerminologyServiceException, FileNotFoundException, IOException, FHIRFormatError {
|
||||
if (value == null)
|
||||
throw fail("unable to find value set with no identity");
|
||||
ValueSet vs = context.fetchResource(ValueSet.class, value);
|
||||
|
@ -489,6 +496,10 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx
|
|||
throw fail("Unable to find imported value set " + value);
|
||||
}
|
||||
}
|
||||
if (noInactive) {
|
||||
expParams = expParams.copy();
|
||||
expParams.addParameter("activeOnly", true);
|
||||
}
|
||||
ValueSetExpansionOutcome vso = new ValueSetExpanderSimple(context, allErrors).expand(vs, expParams);
|
||||
if (vso.getError() != null) {
|
||||
addErrors(vso.getAllErrors());
|
||||
|
@ -543,19 +554,19 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx
|
|||
}
|
||||
}
|
||||
|
||||
private void copyImportContains(List<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) {
|
||||
c.checkNoModifiers("Imported Expansion in Code System", "expanding");
|
||||
ValueSetExpansionContainsComponent np = addCode(c.getSystem(), c.getCode(), c.getDisplay(), parent, null, expParams, c.getAbstract(), c.getInactive(), filter);
|
||||
copyImportContains(c.getContains(), np, expParams, filter);
|
||||
ValueSetExpansionContainsComponent np = addCode(c.getSystem(), c.getCode(), c.getDisplay(), parent, null, expParams, c.getAbstract(), c.getInactive(), filter, noInactive);
|
||||
copyImportContains(c.getContains(), np, expParams, filter, noInactive);
|
||||
}
|
||||
}
|
||||
|
||||
private void includeCodes(ConceptSetComponent inc, ValueSetExpansionComponent exp, Parameters expParams, boolean heirarchical, List<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");
|
||||
List<ValueSet> imports = new ArrayList<ValueSet>();
|
||||
for (UriType imp : inc.getValueSet()) {
|
||||
imports.add(importValueSet(imp.getValue(), exp, expParams));
|
||||
imports.add(importValueSet(imp.getValue(), exp, expParams, noInactive));
|
||||
}
|
||||
|
||||
if (!inc.hasSystem()) {
|
||||
|
@ -564,19 +575,19 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx
|
|||
ValueSet base = imports.get(0);
|
||||
imports.remove(0);
|
||||
base.checkNoModifiers("Imported ValueSet", "expanding");
|
||||
copyImportContains(base.getExpansion().getContains(), null, expParams, imports);
|
||||
copyImportContains(base.getExpansion().getContains(), null, expParams, imports, noInactive);
|
||||
} else {
|
||||
CodeSystem cs = context.fetchCodeSystem(inc.getSystem());
|
||||
if (isServerSide(inc.getSystem()) || (cs == null || (cs.getContent() != CodeSystemContentMode.COMPLETE && cs.getContent() != CodeSystemContentMode.FRAGMENT))) {
|
||||
doServerIncludeCodes(inc, heirarchical, exp, imports, expParams, extensions);
|
||||
doServerIncludeCodes(inc, heirarchical, exp, imports, expParams, extensions, noInactive);
|
||||
} else {
|
||||
doInternalIncludeCodes(inc, exp, expParams, imports, cs);
|
||||
doInternalIncludeCodes(inc, exp, expParams, imports, cs, noInactive);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void doServerIncludeCodes(ConceptSetComponent inc, boolean heirarchical, ValueSetExpansionComponent exp, List<ValueSet> imports, Parameters expParams, List<Extension> extensions) throws FHIRException {
|
||||
ValueSetExpansionOutcome vso = context.expandVS(inc, heirarchical);
|
||||
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, noInactive);
|
||||
if (vso.getError() != null) {
|
||||
throw failTSE("Unable to expand imported value set: " + vso.getError());
|
||||
}
|
||||
|
@ -599,7 +610,7 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx
|
|||
}
|
||||
}
|
||||
for (ValueSetExpansionContainsComponent cc : vs.getExpansion().getContains()) {
|
||||
addCodeAndDescendents(cc, null, expParams, imports);
|
||||
addCodeAndDescendents(cc, null, expParams, imports, noInactive);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -612,7 +623,7 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx
|
|||
return false;
|
||||
}
|
||||
|
||||
public void doInternalIncludeCodes(ConceptSetComponent inc, ValueSetExpansionComponent exp, Parameters expParams, List<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 (context.isNoTerminologyServer())
|
||||
throw failTSE("Unable to find code system " + inc.getSystem().toString());
|
||||
|
@ -629,7 +640,7 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx
|
|||
if (inc.getConcept().size() == 0 && inc.getFilter().size() == 0) {
|
||||
// special case - add all the code system
|
||||
for (ConceptDefinitionComponent def : cs.getConcept()) {
|
||||
addCodeAndDescendents(cs, inc.getSystem(), def, null, expParams, imports, null, new AllConceptsFilter());
|
||||
addCodeAndDescendents(cs, inc.getSystem(), def, null, expParams, imports, null, new AllConceptsFilter(), noInactive);
|
||||
}
|
||||
if (cs.getContent() == CodeSystemContentMode.FRAGMENT) {
|
||||
addFragmentWarning(exp, cs);
|
||||
|
@ -658,7 +669,7 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx
|
|||
} else {
|
||||
inactive = CodeSystemUtilities.isInactive(cs, def);
|
||||
}
|
||||
addCode(inc.getSystem(), c.getCode(), !Utilities.noString(c.getDisplay()) ? c.getDisplay() : def == null ? null : def.getDisplay(), null, convertDesignations(c.getDesignation()), expParams, false, inactive, imports);
|
||||
addCode(inc.getSystem(), c.getCode(), !Utilities.noString(c.getDisplay()) ? c.getDisplay() : def == null ? null : def.getDisplay(), null, convertDesignations(c.getDesignation()), expParams, false, inactive, imports, noInactive);
|
||||
}
|
||||
}
|
||||
if (inc.getFilter().size() > 1) {
|
||||
|
@ -675,14 +686,14 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx
|
|||
ConceptDefinitionComponent def = getConceptForCode(cs.getConcept(), fc.getValue());
|
||||
if (def == null)
|
||||
throw failTSE("Code '" + fc.getValue() + "' not found in system '" + inc.getSystem() + "'");
|
||||
addCodeAndDescendents(cs, inc.getSystem(), def, null, expParams, imports, null, new AllConceptsFilter());
|
||||
addCodeAndDescendents(cs, inc.getSystem(), def, null, expParams, imports, null, new AllConceptsFilter(), noInactive);
|
||||
} else if ("concept".equals(fc.getProperty()) && fc.getOp() == FilterOperator.ISNOTA) {
|
||||
// special: all codes in the target code system that are not under the value
|
||||
ConceptDefinitionComponent defEx = getConceptForCode(cs.getConcept(), fc.getValue());
|
||||
if (defEx == null)
|
||||
throw failTSE("Code '" + fc.getValue() + "' not found in system '" + inc.getSystem() + "'");
|
||||
for (ConceptDefinitionComponent def : cs.getConcept()) {
|
||||
addCodeAndDescendents(cs, inc.getSystem(), def, null, expParams, imports, defEx, new AllConceptsFilter());
|
||||
addCodeAndDescendents(cs, inc.getSystem(), def, null, expParams, imports, defEx, new AllConceptsFilter(), noInactive);
|
||||
}
|
||||
} else if ("concept".equals(fc.getProperty()) && fc.getOp() == FilterOperator.DESCENDENTOF) {
|
||||
// special: all codes in the target code system under the value
|
||||
|
@ -690,11 +701,11 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx
|
|||
if (def == null)
|
||||
throw failTSE("Code '" + fc.getValue() + "' not found in system '" + inc.getSystem() + "'");
|
||||
for (ConceptDefinitionComponent c : def.getConcept())
|
||||
addCodeAndDescendents(cs, inc.getSystem(), c, null, expParams, imports, null, new AllConceptsFilter());
|
||||
addCodeAndDescendents(cs, inc.getSystem(), c, null, expParams, imports, null, new AllConceptsFilter(), noInactive);
|
||||
if (def.hasUserData(CodeSystemUtilities.USER_DATA_CROSS_LINK)) {
|
||||
List<ConceptDefinitionComponent> children = (List<ConceptDefinitionComponent>) def.getUserData(CodeSystemUtilities.USER_DATA_CROSS_LINK);
|
||||
for (ConceptDefinitionComponent c : children)
|
||||
addCodeAndDescendents(cs, inc.getSystem(), c, null, expParams, imports, null, new AllConceptsFilter());
|
||||
addCodeAndDescendents(cs, inc.getSystem(), c, null, expParams, imports, null, new AllConceptsFilter(), noInactive);
|
||||
}
|
||||
|
||||
} else if ("display".equals(fc.getProperty()) && fc.getOp() == FilterOperator.EQUAL) {
|
||||
|
@ -705,13 +716,13 @@ public class ValueSetExpanderSimple extends ValueSetWorker implements ValueSetEx
|
|||
if (isNotBlank(def.getDisplay()) && isNotBlank(fc.getValue())) {
|
||||
if (def.getDisplay().contains(fc.getValue())) {
|
||||
addCode(inc.getSystem(), def.getCode(), def.getDisplay(), null, def.getDesignation(), expParams, CodeSystemUtilities.isNotSelectable(cs, def), CodeSystemUtilities.isInactive(cs, def),
|
||||
imports);
|
||||
imports, noInactive);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (isDefinedProperty(cs, fc.getProperty())) {
|
||||
for (ConceptDefinitionComponent def : cs.getConcept()) {
|
||||
addCodeAndDescendents(cs, inc.getSystem(), def, null, expParams, imports, null, new PropertyFilter(fc, getPropertyDefinition(cs, fc.getProperty())));
|
||||
addCodeAndDescendents(cs, inc.getSystem(), def, null, expParams, imports, null, new PropertyFilter(fc, getPropertyDefinition(cs, fc.getProperty())), noInactive);
|
||||
}
|
||||
} else {
|
||||
throw fail("Search by property[" + fc.getProperty() + "] and op[" + fc.getOp() + "] is not supported yet");
|
||||
|
|
|
@ -108,12 +108,14 @@ public class TestingUtilities extends BaseTestingUtilities {
|
|||
public static SimpleWorkerContext getWorkerContext(NpmPackage npmPackage) throws Exception {
|
||||
SimpleWorkerContext swc = new SimpleWorkerContext.SimpleWorkerContextBuilder().withUserAgent(TestConstants.USER_AGENT).withTerminologyCachePath(TestConstants.TX_CACHE).fromPackage(npmPackage);
|
||||
TerminologyCache.setCacheErrors(true);
|
||||
swc.setAllowLoadingDuplicates(true);
|
||||
return swc;
|
||||
}
|
||||
|
||||
public static SimpleWorkerContext getWorkerContext(NpmPackage npmPackage, IWorkerContext.IContextResourceLoader loader) throws Exception {
|
||||
SimpleWorkerContext swc = new SimpleWorkerContext.SimpleWorkerContextBuilder().withUserAgent(TestConstants.USER_AGENT).withTerminologyCachePath(TestConstants.TX_CACHE).fromPackage(npmPackage, loader);
|
||||
TerminologyCache.setCacheErrors(true);
|
||||
swc.setAllowLoadingDuplicates(true);
|
||||
return swc;
|
||||
}
|
||||
|
||||
|
|
|
@ -235,6 +235,18 @@ public class FHIRPathEngine {
|
|||
}
|
||||
return res;
|
||||
}
|
||||
public boolean hasType(String tn) {
|
||||
if (type != null) {
|
||||
return tn.equals(type);
|
||||
} else {
|
||||
for (TypeRefComponent t : element.getType()) {
|
||||
if (tn.equals(t.getCode())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
private IWorkerContext worker;
|
||||
private IEvaluationContext hostServices;
|
||||
|
@ -5472,7 +5484,7 @@ public class FHIRPathEngine {
|
|||
* @throws PathEngineException
|
||||
* @throws DefinitionException
|
||||
*/
|
||||
public TypedElementDefinition evaluateDefinition(ExpressionNode expr, StructureDefinition profile, TypedElementDefinition element, StructureDefinition source) throws DefinitionException {
|
||||
public TypedElementDefinition evaluateDefinition(ExpressionNode expr, StructureDefinition profile, TypedElementDefinition element, StructureDefinition source, boolean dontWalkIntoReferences) throws DefinitionException {
|
||||
StructureDefinition sd = profile;
|
||||
TypedElementDefinition focus = null;
|
||||
boolean okToNotResolve = false;
|
||||
|
@ -5584,10 +5596,19 @@ public class FHIRPathEngine {
|
|||
} else {
|
||||
throw makeException(expr, I18nConstants.FHIRPATH_DISCRIMINATOR_CANT_FIND, expr.toString(), source.getUrl(), element.getElement().getId(), profile.getUrl());
|
||||
}
|
||||
} else if (expr.getInner() == null) {
|
||||
return focus;
|
||||
} else {
|
||||
return evaluateDefinition(expr.getInner(), sd, focus, profile);
|
||||
// gdg 26-02-2022. If we're walking towards a resolve() and we're on a reference, and we try to walk into the reference
|
||||
// then we don't do that. .resolve() is allowed on the Reference.reference, but the target of the reference will be defined
|
||||
// on the Reference, not the reference.reference.
|
||||
ExpressionNode next = expr.getInner();
|
||||
if (dontWalkIntoReferences && focus.hasType("Reference") && next != null && next.getKind() == Kind.Name && next.getName().equals("reference")) {
|
||||
next = next.getInner();
|
||||
}
|
||||
if (next == null) {
|
||||
return focus;
|
||||
} else {
|
||||
return evaluateDefinition(next, sd, focus, profile, dontWalkIntoReferences);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,13 +1,31 @@
|
|||
package org.hl7.fhir.r5.context;
|
||||
|
||||
import org.hl7.fhir.r5.model.*;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.ArgumentMatchers.argThat;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hl7.fhir.r5.model.CapabilityStatement;
|
||||
import org.hl7.fhir.r5.model.CodeableConcept;
|
||||
import org.hl7.fhir.r5.model.Coding;
|
||||
import org.hl7.fhir.r5.model.Enumerations;
|
||||
import org.hl7.fhir.r5.model.Parameters;
|
||||
import org.hl7.fhir.r5.model.TerminologyCapabilities;
|
||||
import org.hl7.fhir.r5.model.ValueSet;
|
||||
import org.hl7.fhir.r5.terminologies.TerminologyClient;
|
||||
import org.hl7.fhir.r5.terminologies.ValueSetCheckerSimple;
|
||||
import org.hl7.fhir.r5.terminologies.ValueSetExpander;
|
||||
import org.hl7.fhir.r5.terminologies.ValueSetExpanderSimple;
|
||||
import org.hl7.fhir.r5.utils.validation.ValidationContextCarrier;
|
||||
import org.hl7.fhir.utilities.ToolingClientLogger;
|
||||
import org.hl7.fhir.utilities.graphql.Value;
|
||||
import org.hl7.fhir.utilities.validation.ValidationOptions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -18,15 +36,6 @@ import org.mockito.Mockito;
|
|||
import org.mockito.Spy;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.mockito.ArgumentMatchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class SimpleWorkerContextTests {
|
||||
|
||||
|
@ -251,12 +260,13 @@ public class SimpleWorkerContextTests {
|
|||
ValueSet vs = new ValueSet();
|
||||
vs.setStatus(Enumerations.PublicationStatus.ACTIVE);
|
||||
vs.setCompose(new ValueSet.ValueSetComposeComponent());
|
||||
vs.getCompose().setInactive(true);
|
||||
vs.getCompose().getInclude().add(inc);
|
||||
|
||||
Mockito.doReturn(cacheToken).when(terminologyCache).generateExpandToken(argThat(new ValueSetMatcher(vs)),eq(true));
|
||||
Mockito.doReturn(expectedExpansionResult).when(terminologyCache).getExpansion(cacheToken);
|
||||
|
||||
ValueSetExpander.ValueSetExpansionOutcome actualExpansionResult = context.expandVS(inc, true);
|
||||
ValueSetExpander.ValueSetExpansionOutcome actualExpansionResult = context.expandVS(inc, true, false);
|
||||
|
||||
assertEquals(expectedExpansionResult, actualExpansionResult);
|
||||
|
||||
|
@ -273,6 +283,7 @@ public class SimpleWorkerContextTests {
|
|||
ValueSet vs = new ValueSet();
|
||||
vs.setStatus(Enumerations.PublicationStatus.ACTIVE);
|
||||
vs.setCompose(new ValueSet.ValueSetComposeComponent());
|
||||
vs.getCompose().setInactive(true);
|
||||
vs.getCompose().getInclude().add(inc);
|
||||
|
||||
Mockito.doReturn(cacheToken).when(terminologyCache).generateExpandToken(argThat(new ValueSetMatcher(vs)),eq(true));
|
||||
|
@ -285,7 +296,7 @@ public class SimpleWorkerContextTests {
|
|||
Mockito.doReturn(expectedValueSet).when(terminologyClient).expandValueset(argThat(new ValueSetMatcher(vs)),
|
||||
argThat(new ParametersMatcher(pInWithDependentResources)), eq(params));
|
||||
|
||||
ValueSetExpander.ValueSetExpansionOutcome actualExpansionResult = context.expandVS(inc, true);
|
||||
ValueSetExpander.ValueSetExpansionOutcome actualExpansionResult = context.expandVS(inc, true, false);
|
||||
|
||||
assertEquals(expectedValueSet, actualExpansionResult.getValueset());
|
||||
|
||||
|
|
|
@ -1,15 +1,9 @@
|
|||
package org.hl7.fhir.r5.context;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParser;
|
||||
import org.hl7.fhir.r5.formats.IParser;
|
||||
import org.hl7.fhir.r5.model.*;
|
||||
import org.hl7.fhir.r5.terminologies.ValueSetExpander;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
@ -25,8 +19,22 @@ import java.util.stream.Collectors;
|
|||
import java.util.stream.IntStream;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import org.hl7.fhir.r5.formats.IParser;
|
||||
import org.hl7.fhir.r5.model.CanonicalResource;
|
||||
import org.hl7.fhir.r5.model.CapabilityStatement;
|
||||
import org.hl7.fhir.r5.model.CodeableConcept;
|
||||
import org.hl7.fhir.r5.model.Coding;
|
||||
import org.hl7.fhir.r5.model.TerminologyCapabilities;
|
||||
import org.hl7.fhir.r5.model.ValueSet;
|
||||
import org.hl7.fhir.r5.terminologies.ValueSetExpander;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParser;
|
||||
|
||||
public class TerminologyCacheTests {
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -1,14 +1,11 @@
|
|||
package org.hl7.fhir.r5.formats;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
class FormatUtilitiesTest {
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.hl7.fhir.r5.model;
|
||||
|
||||
import org.hl7.fhir.r5.model.Base64BinaryType;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.hl7.fhir.r5.model;
|
||||
|
||||
import org.hl7.fhir.r5.model.BooleanType;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.hl7.fhir.r5.model;
|
||||
|
||||
import org.hl7.fhir.r5.model.CanonicalType;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.hl7.fhir.r5.model;
|
||||
|
||||
import org.hl7.fhir.r5.model.CodeType;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.hl7.fhir.r5.model;
|
||||
|
||||
import org.hl7.fhir.r5.model.DateTimeType;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.hl7.fhir.r5.model;
|
||||
|
||||
import org.hl7.fhir.r5.model.DateType;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.hl7.fhir.r5.model;
|
||||
|
||||
import org.hl7.fhir.r5.model.DecimalType;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.hl7.fhir.r5.model;
|
||||
|
||||
import org.hl7.fhir.r5.model.IdType;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.hl7.fhir.r5.model;
|
||||
|
||||
import org.hl7.fhir.r5.model.InstantType;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.hl7.fhir.r5.model;
|
||||
|
||||
import org.hl7.fhir.r5.model.IntegerType;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.hl7.fhir.r5.model;
|
||||
|
||||
import org.hl7.fhir.r5.model.MarkdownType;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.hl7.fhir.r5.model;
|
||||
|
||||
import org.hl7.fhir.r5.model.OidType;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.hl7.fhir.r5.model;
|
||||
|
||||
import org.hl7.fhir.r5.model.PositiveIntType;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.hl7.fhir.r5.model;
|
||||
|
||||
import org.hl7.fhir.r5.model.StringType;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.hl7.fhir.r5.model;
|
||||
|
||||
import org.hl7.fhir.r5.model.TimeType;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.hl7.fhir.r5.model;
|
||||
|
||||
import org.hl7.fhir.r5.model.UnsignedIntType;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.hl7.fhir.r5.model;
|
||||
|
||||
import org.hl7.fhir.r5.model.UriType;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.hl7.fhir.r5.model;
|
||||
|
||||
import org.hl7.fhir.r5.model.UrlType;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.hl7.fhir.r5.model;
|
||||
|
||||
import org.hl7.fhir.r5.model.UuidType;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
|
|
@ -25,7 +25,6 @@ import org.hl7.fhir.r5.model.Quantity;
|
|||
import org.hl7.fhir.r5.model.Resource;
|
||||
import org.hl7.fhir.r5.model.TypeDetails;
|
||||
import org.hl7.fhir.r5.model.ValueSet;
|
||||
import org.hl7.fhir.r5.test.FHIRPathTests.TestResultType;
|
||||
import org.hl7.fhir.r5.test.utils.TestingUtilities;
|
||||
import org.hl7.fhir.r5.utils.FHIRPathEngine;
|
||||
import org.hl7.fhir.r5.utils.FHIRPathEngine.IEvaluationContext;
|
||||
|
|
|
@ -1,51 +1,35 @@
|
|||
package org.hl7.fhir.r5.test;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.SystemUtils;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.exceptions.FHIRFormatError;
|
||||
import org.hl7.fhir.r5.context.IWorkerContext;
|
||||
import org.hl7.fhir.r5.elementmodel.Manager;
|
||||
import org.hl7.fhir.r5.elementmodel.Manager.FhirFormat;
|
||||
import org.hl7.fhir.r5.formats.IParser.OutputStyle;
|
||||
import org.hl7.fhir.r5.formats.JsonParser;
|
||||
import org.hl7.fhir.r5.formats.XmlParser;
|
||||
import org.hl7.fhir.r5.model.Base;
|
||||
import org.hl7.fhir.r5.model.DomainResource;
|
||||
import org.hl7.fhir.r5.model.Questionnaire;
|
||||
import org.hl7.fhir.r5.model.Resource;
|
||||
import org.hl7.fhir.r5.renderers.RendererFactory;
|
||||
import org.hl7.fhir.r5.renderers.ResourceRenderer;
|
||||
import org.hl7.fhir.r5.renderers.utils.ElementWrappers;
|
||||
import org.hl7.fhir.r5.renderers.utils.RenderingContext;
|
||||
import org.hl7.fhir.r5.renderers.utils.RenderingContext.ITypeParser;
|
||||
import org.hl7.fhir.r5.renderers.utils.RenderingContext.QuestionnaireRendererMode;
|
||||
import org.hl7.fhir.r5.renderers.utils.RenderingContext.ResourceRendererMode;
|
||||
import org.hl7.fhir.r5.test.NarrativeGenerationTests.TestTypeParser;
|
||||
import org.hl7.fhir.r5.test.utils.TestingUtilities;
|
||||
import org.hl7.fhir.utilities.TerminologyServiceOptions;
|
||||
import org.hl7.fhir.utilities.TextFile;
|
||||
import org.hl7.fhir.utilities.xhtml.XhtmlComposer;
|
||||
import org.hl7.fhir.utilities.xhtml.XhtmlNode;
|
||||
import org.hl7.fhir.utilities.xhtml.XhtmlParser;
|
||||
import org.hl7.fhir.utilities.xml.XMLUtil;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
|
|
@ -5,11 +5,7 @@ import java.io.FileOutputStream;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.FormatStyle;
|
||||
import java.util.Locale;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.hl7.fhir.exceptions.DefinitionException;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package org.hl7.fhir.r5.test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.r5.conformance.ProfileUtilities;
|
||||
import org.hl7.fhir.r5.model.Base;
|
||||
|
@ -13,9 +16,6 @@ import org.hl7.fhir.utilities.validation.ValidationMessage;
|
|||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ProfileUtilitiesTests {
|
||||
|
||||
// /**
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package org.hl7.fhir.r5.test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.r5.model.Enumerations;
|
||||
import org.hl7.fhir.r5.model.Extension;
|
||||
|
@ -7,8 +9,6 @@ import org.hl7.fhir.r5.model.Observation;
|
|||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class ResourceCopyTests {
|
||||
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@ import org.hl7.fhir.r5.formats.IParser.OutputStyle;
|
|||
import org.hl7.fhir.r5.formats.JsonParser;
|
||||
import org.hl7.fhir.r5.formats.XmlParser;
|
||||
import org.hl7.fhir.r5.model.Bundle;
|
||||
import org.hl7.fhir.r5.model.DateTimeType;
|
||||
import org.hl7.fhir.r5.model.DomainResource;
|
||||
import org.hl7.fhir.r5.model.Resource;
|
||||
import org.hl7.fhir.r5.renderers.RendererFactory;
|
||||
|
@ -27,7 +26,6 @@ import org.hl7.fhir.r5.renderers.utils.RenderingContext;
|
|||
import org.hl7.fhir.r5.renderers.utils.RenderingContext.ResourceRendererMode;
|
||||
import org.hl7.fhir.r5.test.utils.TestingUtilities;
|
||||
import org.hl7.fhir.r5.utils.EOperationOutcome;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class ResourceRoundTripTests {
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package org.hl7.fhir.r5.test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ import java.io.File;
|
|||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
@ -19,28 +18,27 @@ import org.hl7.fhir.exceptions.FHIRFormatError;
|
|||
import org.hl7.fhir.exceptions.PathEngineException;
|
||||
import org.hl7.fhir.r5.conformance.ProfileUtilities;
|
||||
import org.hl7.fhir.r5.conformance.ProfileUtilities.ProfileKnowledgeProvider;
|
||||
import org.hl7.fhir.r5.context.IWorkerContext.IContextResourceLoader;
|
||||
import org.hl7.fhir.r5.context.TestPackageLoader;
|
||||
import org.hl7.fhir.r5.formats.IParser.OutputStyle;
|
||||
import org.hl7.fhir.r5.formats.JsonParser;
|
||||
import org.hl7.fhir.r5.formats.XmlParser;
|
||||
import org.hl7.fhir.r5.model.Base;
|
||||
import org.hl7.fhir.r5.model.Bundle;
|
||||
import org.hl7.fhir.r5.model.ElementDefinition.ElementDefinitionBindingComponent;
|
||||
import org.hl7.fhir.r5.model.ExpressionNode.CollectionStatus;
|
||||
import org.hl7.fhir.r5.model.Resource;
|
||||
import org.hl7.fhir.r5.model.StructureDefinition;
|
||||
import org.hl7.fhir.r5.model.StructureDefinition.StructureDefinitionKind;
|
||||
import org.hl7.fhir.r5.model.StructureDefinition.TypeDerivationRule;
|
||||
import org.hl7.fhir.r5.model.TypeDetails;
|
||||
import org.hl7.fhir.r5.model.ValueSet;
|
||||
import org.hl7.fhir.r5.renderers.RendererFactory;
|
||||
import org.hl7.fhir.r5.renderers.utils.RenderingContext;
|
||||
import org.hl7.fhir.r5.renderers.utils.RenderingContext.ResourceRendererMode;
|
||||
import org.hl7.fhir.r5.model.TypeDetails;
|
||||
import org.hl7.fhir.r5.model.ValueSet;
|
||||
import org.hl7.fhir.r5.test.utils.TestingUtilities;
|
||||
import org.hl7.fhir.r5.utils.FHIRPathEngine;
|
||||
import org.hl7.fhir.r5.utils.FHIRPathEngine.IEvaluationContext;
|
||||
import org.hl7.fhir.r5.utils.validation.IResourceValidator;
|
||||
import org.hl7.fhir.r5.utils.XVerExtensionManager;
|
||||
import org.hl7.fhir.r5.utils.validation.IResourceValidator;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.npm.CommonPackages;
|
||||
import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager;
|
||||
|
@ -60,41 +58,6 @@ import org.xml.sax.SAXException;
|
|||
|
||||
public class SnapShotGenerationTests {
|
||||
|
||||
public class TestLoader implements IContextResourceLoader {
|
||||
|
||||
private String[] types;
|
||||
|
||||
public TestLoader(String[] types) {
|
||||
this.types = types;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bundle loadBundle(InputStream stream, boolean isJson) throws FHIRException, IOException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Resource loadResource(InputStream stream, boolean isJson) throws FHIRException, IOException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getTypes() {
|
||||
return types;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getResourcePath(Resource resource) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IContextResourceLoader getNewLoader(NpmPackage npm) {
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public enum TestFetchMode {
|
||||
INPUT,
|
||||
OUTPUT,
|
||||
|
@ -549,7 +512,7 @@ public class SnapShotGenerationTests {
|
|||
pu.setIds(test.getSource(), false);
|
||||
if (!TestingUtilities.context().hasPackage(CommonPackages.ID_XVER, CommonPackages.VER_XVER)) {
|
||||
NpmPackage npm = new FilesystemPackageCacheManager(true, ToolsVersion.TOOLS_VERSION).loadPackage(CommonPackages.ID_XVER, CommonPackages.VER_XVER);
|
||||
TestingUtilities.context().loadFromPackage(npm, new TestLoader(new String[]{"StructureDefinition"}), new String[]{"StructureDefinition"});
|
||||
TestingUtilities.context().loadFromPackage(npm, new TestPackageLoader(new String[]{"StructureDefinition"}), new String[]{"StructureDefinition"});
|
||||
}
|
||||
pu.setXver(new XVerExtensionManager(TestingUtilities.context()));
|
||||
if (test.isSort()) {
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package org.hl7.fhir.r5.test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.r5.context.SimpleWorkerContext;
|
||||
import org.hl7.fhir.r5.model.Base;
|
||||
|
@ -7,17 +10,14 @@ import org.hl7.fhir.r5.model.Coding;
|
|||
import org.hl7.fhir.r5.model.StructureMap;
|
||||
import org.hl7.fhir.r5.model.StructureMap.StructureMapGroupRuleTargetComponent;
|
||||
import org.hl7.fhir.r5.test.utils.TestingUtilities;
|
||||
import org.hl7.fhir.r5.utils.structuremap.StructureMapUtilities;
|
||||
import org.hl7.fhir.r5.utils.structuremap.ITransformerServices;
|
||||
import org.hl7.fhir.r5.utils.structuremap.StructureMapUtilities;
|
||||
import org.hl7.fhir.utilities.npm.FilesystemPackageCacheManager;
|
||||
import org.hl7.fhir.utilities.npm.ToolsVersion;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public class StructureMapUtilitiesTest implements ITransformerServices {
|
||||
|
||||
static private SimpleWorkerContext context;
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -4,8 +4,6 @@ import org.junit.jupiter.api.Assertions;
|
|||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class FHIRLexerTest {
|
||||
@Test
|
||||
@DisplayName("Test that a 'null' current value returns 'false' when FHIRLexer.isConstant() is called, and not NPE.")
|
||||
|
|
|
@ -1,9 +1,22 @@
|
|||
package org.hl7.fhir.r5.utils.client;
|
||||
|
||||
import okhttp3.Headers;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.internal.http2.Header;
|
||||
import org.hl7.fhir.r5.model.*;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.hl7.fhir.r5.model.Bundle;
|
||||
import org.hl7.fhir.r5.model.CapabilityStatement;
|
||||
import org.hl7.fhir.r5.model.Enumerations;
|
||||
import org.hl7.fhir.r5.model.IdType;
|
||||
import org.hl7.fhir.r5.model.Observation;
|
||||
import org.hl7.fhir.r5.model.OperationOutcome;
|
||||
import org.hl7.fhir.r5.model.Patient;
|
||||
import org.hl7.fhir.r5.model.Quantity;
|
||||
import org.hl7.fhir.r5.model.Reference;
|
||||
import org.hl7.fhir.r5.model.Resource;
|
||||
import org.hl7.fhir.r5.model.TerminologyCapabilities;
|
||||
import org.hl7.fhir.r5.utils.client.network.Client;
|
||||
import org.hl7.fhir.r5.utils.client.network.ResourceRequest;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
|
@ -13,11 +26,9 @@ import org.mockito.ArgumentCaptor;
|
|||
import org.mockito.ArgumentMatchers;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import okhttp3.Headers;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.internal.http2.Header;
|
||||
|
||||
class FHIRToolingClientTest {
|
||||
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
package org.hl7.fhir.r5.utils.client.network;
|
||||
|
||||
import okhttp3.internal.http2.Header;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import okhttp3.internal.http2.Header;
|
||||
|
||||
class ClientHeadersTest {
|
||||
|
||||
|
|
|
@ -1,21 +1,30 @@
|
|||
package org.hl7.fhir.r5.utils.client.network;
|
||||
|
||||
import okhttp3.HttpUrl;
|
||||
import okhttp3.mockwebserver.MockResponse;
|
||||
import okhttp3.mockwebserver.MockWebServer;
|
||||
import okhttp3.mockwebserver.RecordedRequest;
|
||||
import org.hl7.fhir.r5.context.HTMLClientLogger;
|
||||
import org.hl7.fhir.r5.formats.JsonParser;
|
||||
import org.hl7.fhir.r5.model.*;
|
||||
import org.junit.jupiter.api.*;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.hl7.fhir.r5.context.HTMLClientLogger;
|
||||
import org.hl7.fhir.r5.formats.JsonParser;
|
||||
import org.hl7.fhir.r5.model.Address;
|
||||
import org.hl7.fhir.r5.model.Enumerations;
|
||||
import org.hl7.fhir.r5.model.HumanName;
|
||||
import org.hl7.fhir.r5.model.Patient;
|
||||
import org.hl7.fhir.r5.model.Resource;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestInstance;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import okhttp3.HttpUrl;
|
||||
import okhttp3.mockwebserver.MockResponse;
|
||||
import okhttp3.mockwebserver.MockWebServer;
|
||||
import okhttp3.mockwebserver.RecordedRequest;
|
||||
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
class ClientTest {
|
||||
|
||||
|
|
|
@ -1,17 +1,15 @@
|
|||
package org.hl7.fhir.r5.utils.client.network;
|
||||
|
||||
import okhttp3.Headers;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hl7.fhir.r5.model.OperationOutcome;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import okhttp3.Headers;
|
||||
import okhttp3.Request;
|
||||
|
||||
class FhirRequestBuilderTest {
|
||||
|
||||
|
|
|
@ -39,7 +39,11 @@ class UtilitiesTest {
|
|||
@Test
|
||||
@DisplayName("Test Utilities.path maps temp directory correctly")
|
||||
public void testTempDirPath() throws IOException {
|
||||
Assertions.assertEquals(Utilities.path("[tmp]", TEST_TXT), getTempDirectory() + TEST_TXT);
|
||||
if (ToolGlobalSettings.hasTempPath()) {
|
||||
Assertions.assertEquals(Utilities.path("[tmp]", TEST_TXT), ToolGlobalSettings.getTempPath() +File.separator+ TEST_TXT);
|
||||
} else {
|
||||
Assertions.assertEquals(Utilities.path("[tmp]", TEST_TXT), getTempDirectory() + TEST_TXT);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -3405,13 +3405,17 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
|||
return elements;
|
||||
}
|
||||
|
||||
boolean dontFollowReference = false;
|
||||
|
||||
if (removeResolve) { // if we're doing profile slicing, we don't want to walk into the last resolve.. we need the profile on the source not the target
|
||||
if (discriminator.equals("resolve()")) {
|
||||
elements.add(element);
|
||||
return elements;
|
||||
}
|
||||
if (discriminator.endsWith(".resolve()"))
|
||||
if (discriminator.endsWith(".resolve()")) {
|
||||
discriminator = discriminator.substring(0, discriminator.length() - 10);
|
||||
dontFollowReference = true;
|
||||
}
|
||||
}
|
||||
|
||||
TypedElementDefinition ted = null;
|
||||
|
@ -3424,7 +3428,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
|||
throw new FHIRException(context.formatMessage(I18nConstants.DISCRIMINATOR_BAD_PATH, e.getMessage(), fp), e);
|
||||
}
|
||||
long t2 = System.nanoTime();
|
||||
ted = fpe.evaluateDefinition(expr, profile, new TypedElementDefinition(element), srcProfile);
|
||||
ted = fpe.evaluateDefinition(expr, profile, new TypedElementDefinition(element), srcProfile, dontFollowReference);
|
||||
timeTracker.sd(t2);
|
||||
if (ted != null)
|
||||
elements.add(ted.getElement());
|
||||
|
@ -3449,7 +3453,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
|||
}
|
||||
expr = fpe.parse(fp);
|
||||
t2 = System.nanoTime();
|
||||
ted = fpe.evaluateDefinition(expr, profile, new TypedElementDefinition(element), srcProfile);
|
||||
ted = fpe.evaluateDefinition(expr, profile, new TypedElementDefinition(element), srcProfile, dontFollowReference);
|
||||
timeTracker.sd(t2);
|
||||
if (ted != null)
|
||||
elements.add(ted.getElement());
|
||||
|
|
|
@ -27,7 +27,7 @@ import org.hl7.fhir.validation.instance.utils.IndexedElement;
|
|||
import org.hl7.fhir.validation.instance.utils.NodeStack;
|
||||
import org.hl7.fhir.validation.instance.utils.ValidatorHostContext;
|
||||
|
||||
public class BundleValidator extends BaseValidator{
|
||||
public class BundleValidator extends BaseValidator {
|
||||
public final static String URI_REGEX3 = "((http|https)://([A-Za-z0-9\\\\\\.\\:\\%\\$]*\\/)*)?(Account|ActivityDefinition|AllergyIntolerance|AdverseEvent|Appointment|AppointmentResponse|AuditEvent|Basic|Binary|BodySite|Bundle|CapabilityStatement|CarePlan|CareTeam|ChargeItem|Claim|ClaimResponse|ClinicalImpression|CodeSystem|Communication|CommunicationRequest|CompartmentDefinition|Composition|ConceptMap|Condition (aka Problem)|Consent|Contract|Coverage|DataElement|DetectedIssue|Device|DeviceComponent|DeviceMetric|DeviceRequest|DeviceUseStatement|DiagnosticReport|DocumentManifest|DocumentReference|EligibilityRequest|EligibilityResponse|Encounter|Endpoint|EnrollmentRequest|EnrollmentResponse|EpisodeOfCare|ExpansionProfile|ExplanationOfBenefit|FamilyMemberHistory|Flag|Goal|GraphDefinition|Group|GuidanceResponse|HealthcareService|ImagingManifest|ImagingStudy|Immunization|ImmunizationRecommendation|ImplementationGuide|Library|Linkage|List|Location|Measure|MeasureReport|Media|Medication|MedicationAdministration|MedicationDispense|MedicationRequest|MedicationStatement|MessageDefinition|MessageHeader|NamingSystem|NutritionOrder|Observation|OperationDefinition|OperationOutcome|Organization|Parameters|Patient|PaymentNotice|PaymentReconciliation|Person|PlanDefinition|Practitioner|PractitionerRole|Procedure|ProcedureRequest|ProcessRequest|ProcessResponse|Provenance|Questionnaire|QuestionnaireResponse|ReferralRequest|RelatedPerson|RequestGroup|ResearchStudy|ResearchSubject|RiskAssessment|Schedule|SearchParameter|Sequence|ServiceDefinition|Slot|Specimen|StructureDefinition|StructureMap|Subscription|Substance|SupplyDelivery|SupplyRequest|Task|TestScript|TestReport|ValueSet|VisionPrescription)\\/[A-Za-z0-9\\-\\.]{1,64}(\\/_history\\/[A-Za-z0-9\\-\\.]{1,64})?";
|
||||
private String serverBase;
|
||||
private InstanceValidator validator;
|
||||
|
|
|
@ -343,3 +343,12 @@ v: {
|
|||
"system" : "http://snomed.info/sct"
|
||||
}
|
||||
-------------------------------------------------------------------------------------
|
||||
{"code" : {
|
||||
"system" : "http://snomed.info/sct",
|
||||
"code" : "11181000146103"
|
||||
}, "valueSet" :null, "lang":"null", "useServer":"true", "useClient":"true", "guessSystem":"false", "valueSetMode":"ALL_CHECKS", "versionFlexible":"false"}####
|
||||
v: {
|
||||
"severity" : "error",
|
||||
"error" : "Unable to find code 11181000146103 in http://snomed.info/sct (version http://snomed.info/sct/900000000000207008/version/20210731); The code \"11181000146103\" is not valid in the system http://snomed.info/sct; The code provided (http://snomed.info/sct#11181000146103) is not valid in the value set 'All codes known to the system' (from http://tx.fhir.org/r3)"
|
||||
}
|
||||
-------------------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue