#1412 - fix out of memory issues
This commit is contained in:
parent
7f88be7600
commit
ac33590b96
|
@ -37,7 +37,9 @@ import org.hl7.fhir.dstu3.model.TimeType;
|
|||
import org.hl7.fhir.dstu3.model.TypeDetails;
|
||||
import org.hl7.fhir.dstu3.model.TypeDetails.ProfiledType;
|
||||
import org.hl7.fhir.dstu3.utils.FHIRLexer.FHIRLexerException;
|
||||
import org.hl7.fhir.dstu3.utils.FHIRPathEngine.IEvaluationContext.FunctionDetails;
|
||||
import org.hl7.fhir.dstu3.utils.FHIRPathUtilityClasses.FunctionDetails;
|
||||
import org.hl7.fhir.dstu3.utils.FHIRPathUtilityClasses.ExecutionContext;
|
||||
import org.hl7.fhir.dstu3.utils.FHIRPathUtilityClasses.ExecutionTypeContext;
|
||||
import org.hl7.fhir.exceptions.DefinitionException;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.exceptions.PathEngineException;
|
||||
|
@ -93,27 +95,7 @@ public class FHIRPathEngine {
|
|||
// if the fhir path expressions are allowed to use constants beyond those defined in the specification
|
||||
// the application can implement them by providing a constant resolver
|
||||
public interface IEvaluationContext {
|
||||
public class FunctionDetails {
|
||||
private String description;
|
||||
private int minParameters;
|
||||
private int maxParameters;
|
||||
public FunctionDetails(String description, int minParameters, int maxParameters) {
|
||||
super();
|
||||
this.description = description;
|
||||
this.minParameters = minParameters;
|
||||
this.maxParameters = maxParameters;
|
||||
}
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
public int getMinParameters() {
|
||||
return minParameters;
|
||||
}
|
||||
public int getMaxParameters() {
|
||||
return maxParameters;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A constant reference - e.g. a reference to a name that must be resolved in context.
|
||||
|
@ -554,63 +536,6 @@ public class FHIRPathEngine {
|
|||
return "";
|
||||
}
|
||||
|
||||
private class ExecutionContext {
|
||||
private Object appInfo;
|
||||
private Base resource;
|
||||
private Base context;
|
||||
private Base thisItem;
|
||||
private Map<String, Base> aliases;
|
||||
|
||||
public ExecutionContext(Object appInfo, Base resource, Base context, Map<String, Base> aliases, Base thisItem) {
|
||||
this.appInfo = appInfo;
|
||||
this.context = context;
|
||||
this.resource = resource;
|
||||
this.aliases = aliases;
|
||||
this.thisItem = thisItem;
|
||||
}
|
||||
public Base getResource() {
|
||||
return resource;
|
||||
}
|
||||
public Base getThisItem() {
|
||||
return thisItem;
|
||||
}
|
||||
public void addAlias(String name, List<Base> focus) throws FHIRException {
|
||||
if (aliases == null)
|
||||
aliases = new HashMap<String, Base>();
|
||||
else
|
||||
aliases = new HashMap<String, Base>(aliases); // clone it, since it's going to change
|
||||
if (focus.size() > 1)
|
||||
throw new FHIRException("Attempt to alias a collection, not a singleton");
|
||||
aliases.put(name, focus.size() == 0 ? null : focus.get(0));
|
||||
}
|
||||
public Base getAlias(String name) {
|
||||
return aliases == null ? null : aliases.get(name);
|
||||
}
|
||||
}
|
||||
|
||||
private class ExecutionTypeContext {
|
||||
private Object appInfo;
|
||||
private String resource;
|
||||
private String context;
|
||||
private TypeDetails thisItem;
|
||||
|
||||
|
||||
public ExecutionTypeContext(Object appInfo, String resource, String context, TypeDetails thisItem) {
|
||||
super();
|
||||
this.appInfo = appInfo;
|
||||
this.resource = resource;
|
||||
this.context = context;
|
||||
this.thisItem = thisItem;
|
||||
|
||||
}
|
||||
public String getResource() {
|
||||
return resource;
|
||||
}
|
||||
public TypeDetails getThisItem() {
|
||||
return thisItem;
|
||||
}
|
||||
}
|
||||
|
||||
private ExpressionNode parseExpression(FHIRLexer lexer, boolean proximal) throws FHIRLexerException {
|
||||
ExpressionNode result = new ExpressionNode(lexer.nextId());
|
||||
SourceLocation c = lexer.getCurrentStartLocation();
|
||||
|
@ -1048,7 +973,7 @@ public class FHIRPathEngine {
|
|||
} else if (constant.startsWith("%")) {
|
||||
return resolveConstant(context, constant);
|
||||
} else if (constant.startsWith("@")) {
|
||||
return processDateConstant(context.appInfo, constant.substring(1));
|
||||
return processDateConstant(context.getAppInfo(), constant.substring(1));
|
||||
} else {
|
||||
return new StringType(constant);
|
||||
}
|
||||
|
@ -1081,11 +1006,11 @@ public class FHIRPathEngine {
|
|||
else if (s.equals("%ucum"))
|
||||
return new StringType("http://unitsofmeasure.org");
|
||||
else if (s.equals("%resource")) {
|
||||
if (context.resource == null)
|
||||
if (context.getResource() == null)
|
||||
throw new PathEngineException("Cannot use %resource in this context");
|
||||
return context.resource;
|
||||
return context.getResource();
|
||||
} else if (s.equals("%context")) {
|
||||
return context.context;
|
||||
return context.getContext();
|
||||
} else if (s.equals("%us-zip"))
|
||||
return new StringType("[0-9]{5}(-[0-9]{4}){0,1}");
|
||||
else if (s.startsWith("%\"vs-"))
|
||||
|
@ -1097,7 +1022,7 @@ public class FHIRPathEngine {
|
|||
else if (hostServices == null)
|
||||
throw new PathEngineException("Unknown fixed constant '"+s+"'");
|
||||
else
|
||||
return hostServices.resolveConstant(context.appInfo, s.substring(1));
|
||||
return hostServices.resolveConstant(context.getAppInfo(), s.substring(1));
|
||||
}
|
||||
|
||||
|
||||
|
@ -1776,11 +1701,11 @@ public class FHIRPathEngine {
|
|||
else if (s.equals("%ucum"))
|
||||
return new TypeDetails(CollectionStatus.SINGLETON, "string");
|
||||
else if (s.equals("%resource")) {
|
||||
if (context.resource == null)
|
||||
if (context.getResource() == null)
|
||||
throw new PathEngineException("%resource cannot be used in this context");
|
||||
return new TypeDetails(CollectionStatus.SINGLETON, context.resource);
|
||||
return new TypeDetails(CollectionStatus.SINGLETON, context.getResource());
|
||||
} else if (s.equals("%context")) {
|
||||
return new TypeDetails(CollectionStatus.SINGLETON, context.context);
|
||||
return new TypeDetails(CollectionStatus.SINGLETON, context.getContext());
|
||||
} else if (s.equals("%map-codes"))
|
||||
return new TypeDetails(CollectionStatus.SINGLETON, "string");
|
||||
else if (s.equals("%us-zip"))
|
||||
|
@ -1794,7 +1719,7 @@ public class FHIRPathEngine {
|
|||
else if (hostServices == null)
|
||||
throw new PathEngineException("Unknown fixed constant type for '"+s+"'");
|
||||
else
|
||||
return hostServices.resolveConstantType(context.appInfo, s);
|
||||
return hostServices.resolveConstantType(context.getAppInfo(), s);
|
||||
}
|
||||
|
||||
private List<Base> execute(ExecutionContext context, Base item, ExpressionNode exp, boolean atEntry) throws FHIRException {
|
||||
|
@ -1804,8 +1729,8 @@ public class FHIRPathEngine {
|
|||
result.add(item);
|
||||
} else
|
||||
getChildrenByName(item, exp.getName(), result);
|
||||
if (result.size() == 0 && atEntry && context.appInfo != null) {
|
||||
Base temp = hostServices.resolveConstant(context.appInfo, exp.getName());
|
||||
if (result.size() == 0 && atEntry && context.getAppInfo() != null) {
|
||||
Base temp = hostServices.resolveConstant(context.getAppInfo(), exp.getName());
|
||||
if (temp != null) {
|
||||
result.add(temp);
|
||||
}
|
||||
|
@ -1816,7 +1741,7 @@ public class FHIRPathEngine {
|
|||
private TypeDetails executeContextType(ExecutionTypeContext context, String name) throws PathEngineException, DefinitionException {
|
||||
if (hostServices == null)
|
||||
throw new PathEngineException("Unable to resolve context reference since no host services are provided");
|
||||
return hostServices.resolveConstantType(context.appInfo, name);
|
||||
return hostServices.resolveConstantType(context.getAppInfo(), name);
|
||||
}
|
||||
|
||||
private TypeDetails executeType(String type, ExpressionNode exp, boolean atEntry) throws PathEngineException, DefinitionException {
|
||||
|
@ -2003,7 +1928,7 @@ public class FHIRPathEngine {
|
|||
checkParamTypes(exp.getFunction().toCode(), paramTypes, new TypeDetails(CollectionStatus.SINGLETON, "string"));
|
||||
return focus;
|
||||
case Custom : {
|
||||
return hostServices.checkFunction(context.appInfo, exp.getName(), paramTypes);
|
||||
return hostServices.checkFunction(context.getAppInfo(), exp.getName(), paramTypes);
|
||||
}
|
||||
default:
|
||||
break;
|
||||
|
@ -2120,7 +2045,7 @@ public class FHIRPathEngine {
|
|||
List<List<Base>> params = new ArrayList<List<Base>>();
|
||||
for (ExpressionNode p : exp.getParameters())
|
||||
params.add(execute(context, focus, p, true));
|
||||
return hostServices.executeFunction(context.appInfo, exp.getName(), params);
|
||||
return hostServices.executeFunction(context.getAppInfo(), exp.getName(), params);
|
||||
}
|
||||
default:
|
||||
throw new Error("not Implemented yet");
|
||||
|
@ -2181,11 +2106,11 @@ public class FHIRPathEngine {
|
|||
|
||||
|
||||
private ExecutionContext changeThis(ExecutionContext context, Base newThis) {
|
||||
return new ExecutionContext(context.appInfo, context.resource, context.context, context.aliases, newThis);
|
||||
return new ExecutionContext(context.getAppInfo(), context.getResource(), context.getContext(), context.getAliases(), newThis);
|
||||
}
|
||||
|
||||
private ExecutionTypeContext changeThis(ExecutionTypeContext context, TypeDetails newThis) {
|
||||
return new ExecutionTypeContext(context.appInfo, context.resource, context.context, newThis);
|
||||
return new ExecutionTypeContext(context.getAppInfo(), context.getResource(), context.getContext(), newThis);
|
||||
}
|
||||
|
||||
|
||||
|
@ -2467,13 +2392,13 @@ public class FHIRPathEngine {
|
|||
}
|
||||
Base res = null;
|
||||
if (s.startsWith("#")) {
|
||||
Property p = context.resource.getChildByName("contained");
|
||||
Property p = context.getResource().getChildByName("contained");
|
||||
for (Base c : p.getValues()) {
|
||||
if (s.equals(c.getIdBase()))
|
||||
res = c;
|
||||
}
|
||||
} else if (hostServices != null) {
|
||||
res = hostServices.resolveReference(context.appInfo, s);
|
||||
res = hostServices.resolveReference(context.getAppInfo(), s);
|
||||
}
|
||||
if (res != null)
|
||||
result.add(res);
|
||||
|
@ -2699,7 +2624,7 @@ public class FHIRPathEngine {
|
|||
return makeBoolean(!convertToBoolean(focus));
|
||||
}
|
||||
|
||||
public class ElementDefinitionMatch {
|
||||
private class ElementDefinitionMatch {
|
||||
private ElementDefinition definition;
|
||||
private String fixedType;
|
||||
public ElementDefinitionMatch(ElementDefinition definition, String fixedType) {
|
||||
|
|
|
@ -0,0 +1,110 @@
|
|||
package org.hl7.fhir.dstu3.utils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hl7.fhir.dstu3.model.Base;
|
||||
import org.hl7.fhir.dstu3.model.TypeDetails;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
|
||||
public class FHIRPathUtilityClasses {
|
||||
|
||||
|
||||
public static class ExecutionContext {
|
||||
private Object appInfo;
|
||||
private Base resource;
|
||||
private Base context;
|
||||
private Base thisItem;
|
||||
private Map<String, Base> aliases;
|
||||
|
||||
public ExecutionContext(Object appInfo, Base resource, Base context, Map<String, Base> aliases, Base thisItem) {
|
||||
this.appInfo = appInfo;
|
||||
this.context = context;
|
||||
this.resource = resource;
|
||||
this.aliases = aliases;
|
||||
this.thisItem = thisItem;
|
||||
}
|
||||
public Base getResource() {
|
||||
return resource;
|
||||
}
|
||||
public Base getThisItem() {
|
||||
return thisItem;
|
||||
}
|
||||
public void addAlias(String name, List<Base> focus) throws FHIRException {
|
||||
if (aliases == null)
|
||||
aliases = new HashMap<String, Base>();
|
||||
else
|
||||
aliases = new HashMap<String, Base>(aliases); // clone it, since it's going to change
|
||||
if (focus.size() > 1)
|
||||
throw new FHIRException("Attempt to alias a collection, not a singleton");
|
||||
aliases.put(name, focus.size() == 0 ? null : focus.get(0));
|
||||
}
|
||||
public Base getAlias(String name) {
|
||||
return aliases == null ? null : aliases.get(name);
|
||||
}
|
||||
public Object getAppInfo() {
|
||||
return appInfo;
|
||||
}
|
||||
public Base getContext() {
|
||||
return context;
|
||||
}
|
||||
public Map<String, Base> getAliases() {
|
||||
return aliases;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class ExecutionTypeContext {
|
||||
private Object appInfo;
|
||||
private String resource;
|
||||
private String context;
|
||||
private TypeDetails thisItem;
|
||||
|
||||
|
||||
public ExecutionTypeContext(Object appInfo, String resource, String context, TypeDetails thisItem) {
|
||||
super();
|
||||
this.appInfo = appInfo;
|
||||
this.resource = resource;
|
||||
this.context = context;
|
||||
this.thisItem = thisItem;
|
||||
|
||||
}
|
||||
public String getResource() {
|
||||
return resource;
|
||||
}
|
||||
public TypeDetails getThisItem() {
|
||||
return thisItem;
|
||||
}
|
||||
public Object getAppInfo() {
|
||||
return appInfo;
|
||||
}
|
||||
public String getContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static class FunctionDetails {
|
||||
private String description;
|
||||
private int minParameters;
|
||||
private int maxParameters;
|
||||
public FunctionDetails(String description, int minParameters, int maxParameters) {
|
||||
super();
|
||||
this.description = description;
|
||||
this.minParameters = minParameters;
|
||||
this.maxParameters = maxParameters;
|
||||
}
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
public int getMinParameters() {
|
||||
return minParameters;
|
||||
}
|
||||
public int getMaxParameters() {
|
||||
return maxParameters;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -108,6 +108,7 @@ import org.hl7.fhir.dstu3.model.ValueSet.ValueSetExpansionContainsComponent;
|
|||
import org.hl7.fhir.dstu3.terminologies.ValueSetExpander.ValueSetExpansionOutcome;
|
||||
import org.hl7.fhir.dstu3.utils.FHIRLexer.FHIRLexerException;
|
||||
import org.hl7.fhir.dstu3.utils.FHIRPathEngine.IEvaluationContext;
|
||||
import org.hl7.fhir.dstu3.utils.FHIRPathUtilityClasses.FunctionDetails;
|
||||
import org.hl7.fhir.exceptions.DefinitionException;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.exceptions.FHIRFormatError;
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.hl7.fhir.dstu3.test.support.TestingUtilities;
|
|||
import org.hl7.fhir.dstu3.utils.CodingUtilities;
|
||||
import org.hl7.fhir.dstu3.utils.FHIRPathEngine;
|
||||
import org.hl7.fhir.dstu3.utils.FHIRPathEngine.IEvaluationContext;
|
||||
import org.hl7.fhir.dstu3.utils.FHIRPathUtilityClasses.FunctionDetails;
|
||||
import org.hl7.fhir.exceptions.DefinitionException;
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.exceptions.FHIRFormatError;
|
||||
|
|
|
@ -56,7 +56,10 @@ import org.hl7.fhir.r4.model.TypeDetails;
|
|||
import org.hl7.fhir.r4.model.TypeDetails.ProfiledType;
|
||||
import org.hl7.fhir.r4.model.ValueSet;
|
||||
import org.hl7.fhir.r4.utils.FHIRLexer.FHIRLexerException;
|
||||
import org.hl7.fhir.r4.utils.FHIRPathEngine.IEvaluationContext.FunctionDetails;
|
||||
import org.hl7.fhir.r4.utils.FHIRPathUtilityClasses.FHIRConstant;
|
||||
import org.hl7.fhir.r4.utils.FHIRPathUtilityClasses.ClassTypeInfo;
|
||||
import org.hl7.fhir.r4.utils.FHIRPathUtilityClasses.TypedElementDefinition;
|
||||
import org.hl7.fhir.r4.utils.FHIRPathUtilityClasses.FunctionDetails;
|
||||
import org.hl7.fhir.utilities.CommaSeparatedStringBuilder;
|
||||
import org.hl7.fhir.utilities.MergedList;
|
||||
import org.hl7.fhir.utilities.MergedList.MergeNode;
|
||||
|
@ -110,167 +113,6 @@ public class FHIRPathEngine {
|
|||
private enum Equality {
|
||||
Null, True, False
|
||||
}
|
||||
|
||||
private class FHIRConstant extends Base {
|
||||
|
||||
private static final long serialVersionUID = -8933773658248269439L;
|
||||
private String value;
|
||||
|
||||
public FHIRConstant(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String fhirType() {
|
||||
return "%constant";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void listChildren(List<Property> result) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdBase() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIdBase(String value) {
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String primitiveValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Base copy() {
|
||||
throw new Error("Not Implemented");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class ClassTypeInfo extends Base {
|
||||
private static final long serialVersionUID = 4909223114071029317L;
|
||||
private Base instance;
|
||||
|
||||
public ClassTypeInfo(Base instance) {
|
||||
super();
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String fhirType() {
|
||||
return "ClassInfo";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void listChildren(List<Property> result) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdBase() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIdBase(String value) {
|
||||
}
|
||||
|
||||
public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
|
||||
if (name.equals("name")) {
|
||||
return new Base[] { new StringType(getName()) };
|
||||
} else if (name.equals("namespace")) {
|
||||
return new Base[] { new StringType(getNamespace()) };
|
||||
} else {
|
||||
return super.getProperty(hash, name, checkValid);
|
||||
}
|
||||
}
|
||||
|
||||
private String getNamespace() {
|
||||
if ((instance instanceof Resource)) {
|
||||
return "FHIR";
|
||||
} else if (!(instance instanceof Element) || ((Element) instance).isDisallowExtensions()) {
|
||||
return "System";
|
||||
} else {
|
||||
return "FHIR";
|
||||
}
|
||||
}
|
||||
|
||||
private String getName() {
|
||||
if ((instance instanceof Resource)) {
|
||||
return instance.fhirType();
|
||||
} else if (!(instance instanceof Element) || ((Element) instance).isDisallowExtensions()) {
|
||||
return Utilities.capitalize(instance.fhirType());
|
||||
} else {
|
||||
return instance.fhirType();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Base copy() {
|
||||
throw new Error("Not Implemented");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class TypedElementDefinition {
|
||||
private ElementDefinition element;
|
||||
private String type;
|
||||
private StructureDefinition src;
|
||||
|
||||
public TypedElementDefinition(StructureDefinition src, ElementDefinition element, String type) {
|
||||
super();
|
||||
this.element = element;
|
||||
this.type = type;
|
||||
this.src = src;
|
||||
}
|
||||
|
||||
public TypedElementDefinition(ElementDefinition element) {
|
||||
super();
|
||||
this.element = element;
|
||||
}
|
||||
|
||||
public ElementDefinition getElement() {
|
||||
return element;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public List<TypeRefComponent> getTypes() {
|
||||
List<TypeRefComponent> res = new ArrayList<ElementDefinition.TypeRefComponent>();
|
||||
for (TypeRefComponent tr : element.getType()) {
|
||||
if (type == null || type.equals(tr.getCode())) {
|
||||
res.add(tr);
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
public StructureDefinition getSrc() {
|
||||
return src;
|
||||
}
|
||||
}
|
||||
|
||||
private IWorkerContext worker;
|
||||
private IEvaluationContext hostServices;
|
||||
private StringBuilder log = new StringBuilder();
|
||||
|
@ -292,31 +134,7 @@ public class FHIRPathEngine {
|
|||
// defined in the specification
|
||||
// the application can implement them by providing a constant resolver
|
||||
public interface IEvaluationContext {
|
||||
public class FunctionDetails {
|
||||
private String description;
|
||||
private int minParameters;
|
||||
private int maxParameters;
|
||||
|
||||
public FunctionDetails(String description, int minParameters, int maxParameters) {
|
||||
super();
|
||||
this.description = description;
|
||||
this.minParameters = minParameters;
|
||||
this.maxParameters = maxParameters;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public int getMinParameters() {
|
||||
return minParameters;
|
||||
}
|
||||
|
||||
public int getMaxParameters() {
|
||||
return maxParameters;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A constant reference - e.g. a reference to a name that must be resolved in
|
||||
|
@ -6129,7 +5947,7 @@ public class FHIRPathEngine {
|
|||
return result;
|
||||
}
|
||||
|
||||
public class ElementDefinitionMatch {
|
||||
private class ElementDefinitionMatch {
|
||||
private ElementDefinition definition;
|
||||
private String fixedType;
|
||||
|
||||
|
|
|
@ -0,0 +1,210 @@
|
|||
package org.hl7.fhir.r4.utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.r4.model.Base;
|
||||
import org.hl7.fhir.r4.model.Element;
|
||||
import org.hl7.fhir.r4.model.ElementDefinition;
|
||||
import org.hl7.fhir.r4.model.IntegerType;
|
||||
import org.hl7.fhir.r4.model.Property;
|
||||
import org.hl7.fhir.r4.model.Resource;
|
||||
import org.hl7.fhir.r4.model.StringType;
|
||||
import org.hl7.fhir.r4.model.StructureDefinition;
|
||||
import org.hl7.fhir.r4.model.TypeDetails;
|
||||
import org.hl7.fhir.r4.model.ElementDefinition.TypeRefComponent;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.i18n.I18nConstants;
|
||||
|
||||
public class FHIRPathUtilityClasses {
|
||||
|
||||
|
||||
public static class FHIRConstant extends Base {
|
||||
|
||||
private static final long serialVersionUID = -8933773658248269439L;
|
||||
private String value;
|
||||
|
||||
public FHIRConstant(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String fhirType() {
|
||||
return "%constant";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void listChildren(List<Property> result) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdBase() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIdBase(String value) {
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String primitiveValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Base copy() {
|
||||
throw new Error("Not Implemented");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class ClassTypeInfo extends Base {
|
||||
private static final long serialVersionUID = 4909223114071029317L;
|
||||
private Base instance;
|
||||
|
||||
public ClassTypeInfo(Base instance) {
|
||||
super();
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String fhirType() {
|
||||
return "ClassInfo";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void listChildren(List<Property> result) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdBase() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIdBase(String value) {
|
||||
}
|
||||
|
||||
public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
|
||||
if (name.equals("name")) {
|
||||
return new Base[] { new StringType(getName()) };
|
||||
} else if (name.equals("namespace")) {
|
||||
return new Base[] { new StringType(getNamespace()) };
|
||||
} else {
|
||||
return super.getProperty(hash, name, checkValid);
|
||||
}
|
||||
}
|
||||
|
||||
private String getNamespace() {
|
||||
if ((instance instanceof Resource)) {
|
||||
return "FHIR";
|
||||
} else if (!(instance instanceof Element) || ((Element) instance).isDisallowExtensions()) {
|
||||
return "System";
|
||||
} else {
|
||||
return "FHIR";
|
||||
}
|
||||
}
|
||||
|
||||
private String getName() {
|
||||
if ((instance instanceof Resource)) {
|
||||
return instance.fhirType();
|
||||
} else if (!(instance instanceof Element) || ((Element) instance).isDisallowExtensions()) {
|
||||
return Utilities.capitalize(instance.fhirType());
|
||||
} else {
|
||||
return instance.fhirType();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Base copy() {
|
||||
throw new Error("Not Implemented");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class TypedElementDefinition {
|
||||
private ElementDefinition element;
|
||||
private String type;
|
||||
private StructureDefinition src;
|
||||
|
||||
public TypedElementDefinition(StructureDefinition src, ElementDefinition element, String type) {
|
||||
super();
|
||||
this.element = element;
|
||||
this.type = type;
|
||||
this.src = src;
|
||||
}
|
||||
|
||||
public TypedElementDefinition(ElementDefinition element) {
|
||||
super();
|
||||
this.element = element;
|
||||
}
|
||||
|
||||
public ElementDefinition getElement() {
|
||||
return element;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public List<TypeRefComponent> getTypes() {
|
||||
List<TypeRefComponent> res = new ArrayList<ElementDefinition.TypeRefComponent>();
|
||||
for (TypeRefComponent tr : element.getType()) {
|
||||
if (type == null || type.equals(tr.getCode())) {
|
||||
res.add(tr);
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
public StructureDefinition getSrc() {
|
||||
return src;
|
||||
}
|
||||
}
|
||||
|
||||
public static class FunctionDetails {
|
||||
private String description;
|
||||
private int minParameters;
|
||||
private int maxParameters;
|
||||
|
||||
public FunctionDetails(String description, int minParameters, int maxParameters) {
|
||||
super();
|
||||
this.description = description;
|
||||
this.minParameters = minParameters;
|
||||
this.maxParameters = maxParameters;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public int getMinParameters() {
|
||||
return minParameters;
|
||||
}
|
||||
|
||||
public int getMaxParameters() {
|
||||
return maxParameters;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -46,6 +46,7 @@ import org.hl7.fhir.r4.model.TypeDetails;
|
|||
import org.hl7.fhir.r4.model.ValueSet;
|
||||
import org.hl7.fhir.r4.utils.FHIRPathEngine.ExpressionNodeWithOffset;
|
||||
import org.hl7.fhir.r4.utils.FHIRPathEngine.IEvaluationContext;
|
||||
import org.hl7.fhir.r4.utils.FHIRPathUtilityClasses.FunctionDetails;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
|
||||
public class LiquidEngine implements IEvaluationContext {
|
||||
|
|
|
@ -114,6 +114,7 @@ import org.hl7.fhir.r4.model.ValueSet.ValueSetExpansionContainsComponent;
|
|||
import org.hl7.fhir.r4.terminologies.ValueSetExpander.ValueSetExpansionOutcome;
|
||||
import org.hl7.fhir.r4.utils.FHIRLexer.FHIRLexerException;
|
||||
import org.hl7.fhir.r4.utils.FHIRPathEngine.IEvaluationContext;
|
||||
import org.hl7.fhir.r4.utils.FHIRPathUtilityClasses.FunctionDetails;
|
||||
import org.hl7.fhir.r4.utils.validation.IResourceValidator;
|
||||
import org.hl7.fhir.utilities.CommaSeparatedStringBuilder;
|
||||
import org.hl7.fhir.utilities.TerminologyServiceOptions;
|
||||
|
|
|
@ -34,6 +34,7 @@ import org.hl7.fhir.r4.model.ValueSet;
|
|||
import org.hl7.fhir.r4.test.utils.TestingUtilities;
|
||||
import org.hl7.fhir.r4.utils.FHIRPathEngine;
|
||||
import org.hl7.fhir.r4.utils.FHIRPathEngine.IEvaluationContext;
|
||||
import org.hl7.fhir.r4.utils.FHIRPathUtilityClasses.FunctionDetails;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.xml.XMLUtil;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
|
|
|
@ -33,6 +33,7 @@ import org.hl7.fhir.r4.model.ValueSet;
|
|||
import org.hl7.fhir.r4.test.utils.TestingUtilities;
|
||||
import org.hl7.fhir.r4.utils.FHIRPathEngine;
|
||||
import org.hl7.fhir.r4.utils.FHIRPathEngine.IEvaluationContext;
|
||||
import org.hl7.fhir.r4.utils.FHIRPathUtilityClasses.FunctionDetails;
|
||||
import org.hl7.fhir.r4.utils.NarrativeGenerator;
|
||||
import org.hl7.fhir.r4.utils.validation.IResourceValidator;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.hl7.fhir.r4b.model.Tuple;
|
|||
import org.hl7.fhir.r4b.model.TypeDetails;
|
||||
import org.hl7.fhir.r4b.model.ValueSet;
|
||||
import org.hl7.fhir.r4b.utils.FHIRPathEngine.IEvaluationContext;
|
||||
import org.hl7.fhir.r4b.utils.FHIRPathUtilityClasses.FunctionDetails;
|
||||
import org.hl7.fhir.r4b.utils.LiquidEngine;
|
||||
import org.hl7.fhir.r4b.utils.LiquidEngine.LiquidDocument;
|
||||
import org.hl7.fhir.utilities.TextFile;
|
||||
|
|
|
@ -57,7 +57,10 @@ import org.hl7.fhir.r4b.model.TypeDetails;
|
|||
import org.hl7.fhir.r4b.model.TypeDetails.ProfiledType;
|
||||
import org.hl7.fhir.r4b.model.ValueSet;
|
||||
import org.hl7.fhir.r4b.utils.FHIRLexer.FHIRLexerException;
|
||||
import org.hl7.fhir.r4b.utils.FHIRPathEngine.IEvaluationContext.FunctionDetails;
|
||||
import org.hl7.fhir.r4b.utils.FHIRPathUtilityClasses.FHIRConstant;
|
||||
import org.hl7.fhir.r4b.utils.FHIRPathUtilityClasses.ClassTypeInfo;
|
||||
import org.hl7.fhir.r4b.utils.FHIRPathUtilityClasses.TypedElementDefinition;
|
||||
import org.hl7.fhir.r4b.utils.FHIRPathUtilityClasses.FunctionDetails;
|
||||
import org.hl7.fhir.utilities.CommaSeparatedStringBuilder;
|
||||
import org.hl7.fhir.utilities.MergedList;
|
||||
import org.hl7.fhir.utilities.MergedList.MergeNode;
|
||||
|
@ -112,160 +115,6 @@ public class FHIRPathEngine {
|
|||
Null, True, False
|
||||
}
|
||||
|
||||
private class FHIRConstant extends Base {
|
||||
|
||||
private static final long serialVersionUID = -8933773658248269439L;
|
||||
private String value;
|
||||
|
||||
public FHIRConstant(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String fhirType() {
|
||||
return "%constant";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void listChildren(List<Property> result) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdBase() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIdBase(String value) {
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String primitiveValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Base copy() {
|
||||
throw new Error("Not Implemented");
|
||||
}
|
||||
}
|
||||
|
||||
private class ClassTypeInfo extends Base {
|
||||
private static final long serialVersionUID = 4909223114071029317L;
|
||||
private Base instance;
|
||||
|
||||
public ClassTypeInfo(Base instance) {
|
||||
super();
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String fhirType() {
|
||||
return "ClassInfo";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void listChildren(List<Property> result) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdBase() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIdBase(String value) {
|
||||
}
|
||||
|
||||
public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
|
||||
if (name.equals("name")) {
|
||||
return new Base[] { new StringType(getName()) };
|
||||
} else if (name.equals("namespace")) {
|
||||
return new Base[] { new StringType(getNamespace()) };
|
||||
} else {
|
||||
return super.getProperty(hash, name, checkValid);
|
||||
}
|
||||
}
|
||||
|
||||
private String getNamespace() {
|
||||
if ((instance instanceof Resource)) {
|
||||
return "FHIR";
|
||||
} else if (!(instance instanceof Element) || ((Element) instance).isDisallowExtensions()) {
|
||||
return "System";
|
||||
} else {
|
||||
return "FHIR";
|
||||
}
|
||||
}
|
||||
|
||||
private String getName() {
|
||||
if ((instance instanceof Resource)) {
|
||||
return instance.fhirType();
|
||||
} else if (!(instance instanceof Element) || ((Element) instance).isDisallowExtensions()) {
|
||||
return Utilities.capitalize(instance.fhirType());
|
||||
} else {
|
||||
return instance.fhirType();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Base copy() {
|
||||
throw new Error("Not Implemented");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class TypedElementDefinition {
|
||||
private ElementDefinition element;
|
||||
private String type;
|
||||
|
||||
public TypedElementDefinition(ElementDefinition element, String type) {
|
||||
super();
|
||||
this.element = element;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public TypedElementDefinition(ElementDefinition element) {
|
||||
super();
|
||||
this.element = element;
|
||||
}
|
||||
|
||||
public ElementDefinition getElement() {
|
||||
return element;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public List<TypeRefComponent> getTypes() {
|
||||
List<TypeRefComponent> res = new ArrayList<ElementDefinition.TypeRefComponent>();
|
||||
for (TypeRefComponent tr : element.getType()) {
|
||||
if (type == null || type.equals(tr.getCode())) {
|
||||
res.add(tr);
|
||||
}
|
||||
}
|
||||
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;
|
||||
private StringBuilder log = new StringBuilder();
|
||||
|
@ -288,32 +137,7 @@ public class FHIRPathEngine {
|
|||
// defined in the specification
|
||||
// the application can implement them by providing a constant resolver
|
||||
public interface IEvaluationContext {
|
||||
public class FunctionDetails {
|
||||
private String description;
|
||||
private int minParameters;
|
||||
private int maxParameters;
|
||||
|
||||
public FunctionDetails(String description, int minParameters, int maxParameters) {
|
||||
super();
|
||||
this.description = description;
|
||||
this.minParameters = minParameters;
|
||||
this.maxParameters = maxParameters;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public int getMinParameters() {
|
||||
return minParameters;
|
||||
}
|
||||
|
||||
public int getMaxParameters() {
|
||||
return maxParameters;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A constant reference - e.g. a reference to a name that must be resolved in
|
||||
* context. The % will be removed from the constant name before this is invoked.
|
||||
|
@ -6126,7 +5950,7 @@ public class FHIRPathEngine {
|
|||
return result;
|
||||
}
|
||||
|
||||
public class ElementDefinitionMatch {
|
||||
private class ElementDefinitionMatch {
|
||||
private ElementDefinition definition;
|
||||
private String fixedType;
|
||||
|
||||
|
|
|
@ -0,0 +1,198 @@
|
|||
package org.hl7.fhir.r4b.utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.r4b.model.Base;
|
||||
import org.hl7.fhir.r4b.model.Element;
|
||||
import org.hl7.fhir.r4b.model.ElementDefinition;
|
||||
import org.hl7.fhir.r4b.model.Property;
|
||||
import org.hl7.fhir.r4b.model.Resource;
|
||||
import org.hl7.fhir.r4b.model.StringType;
|
||||
import org.hl7.fhir.r4b.model.ElementDefinition.TypeRefComponent;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
|
||||
public class FHIRPathUtilityClasses {
|
||||
|
||||
public static class FHIRConstant extends Base {
|
||||
|
||||
private static final long serialVersionUID = -8933773658248269439L;
|
||||
private String value;
|
||||
|
||||
public FHIRConstant(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String fhirType() {
|
||||
return "%constant";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void listChildren(List<Property> result) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdBase() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIdBase(String value) {
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String primitiveValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Base copy() {
|
||||
throw new Error("Not Implemented");
|
||||
}
|
||||
}
|
||||
|
||||
public static class ClassTypeInfo extends Base {
|
||||
private static final long serialVersionUID = 4909223114071029317L;
|
||||
private Base instance;
|
||||
|
||||
public ClassTypeInfo(Base instance) {
|
||||
super();
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String fhirType() {
|
||||
return "ClassInfo";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void listChildren(List<Property> result) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdBase() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIdBase(String value) {
|
||||
}
|
||||
|
||||
public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
|
||||
if (name.equals("name")) {
|
||||
return new Base[] { new StringType(getName()) };
|
||||
} else if (name.equals("namespace")) {
|
||||
return new Base[] { new StringType(getNamespace()) };
|
||||
} else {
|
||||
return super.getProperty(hash, name, checkValid);
|
||||
}
|
||||
}
|
||||
|
||||
private String getNamespace() {
|
||||
if ((instance instanceof Resource)) {
|
||||
return "FHIR";
|
||||
} else if (!(instance instanceof Element) || ((Element) instance).isDisallowExtensions()) {
|
||||
return "System";
|
||||
} else {
|
||||
return "FHIR";
|
||||
}
|
||||
}
|
||||
|
||||
private String getName() {
|
||||
if ((instance instanceof Resource)) {
|
||||
return instance.fhirType();
|
||||
} else if (!(instance instanceof Element) || ((Element) instance).isDisallowExtensions()) {
|
||||
return Utilities.capitalize(instance.fhirType());
|
||||
} else {
|
||||
return instance.fhirType();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Base copy() {
|
||||
throw new Error("Not Implemented");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class TypedElementDefinition {
|
||||
private ElementDefinition element;
|
||||
private String type;
|
||||
|
||||
public TypedElementDefinition(ElementDefinition element, String type) {
|
||||
super();
|
||||
this.element = element;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public TypedElementDefinition(ElementDefinition element) {
|
||||
super();
|
||||
this.element = element;
|
||||
}
|
||||
|
||||
public ElementDefinition getElement() {
|
||||
return element;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public List<TypeRefComponent> getTypes() {
|
||||
List<TypeRefComponent> res = new ArrayList<ElementDefinition.TypeRefComponent>();
|
||||
for (TypeRefComponent tr : element.getType()) {
|
||||
if (type == null || type.equals(tr.getCode())) {
|
||||
res.add(tr);
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class FunctionDetails {
|
||||
private String description;
|
||||
private int minParameters;
|
||||
private int maxParameters;
|
||||
|
||||
public FunctionDetails(String description, int minParameters, int maxParameters) {
|
||||
super();
|
||||
this.description = description;
|
||||
this.minParameters = minParameters;
|
||||
this.maxParameters = maxParameters;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public int getMinParameters() {
|
||||
return minParameters;
|
||||
}
|
||||
|
||||
public int getMaxParameters() {
|
||||
return maxParameters;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -49,6 +49,7 @@ import org.hl7.fhir.r4b.model.TypeDetails;
|
|||
import org.hl7.fhir.r4b.model.ValueSet;
|
||||
import org.hl7.fhir.r4b.utils.FHIRPathEngine.ExpressionNodeWithOffset;
|
||||
import org.hl7.fhir.r4b.utils.FHIRPathEngine.IEvaluationContext;
|
||||
import org.hl7.fhir.r4b.utils.FHIRPathUtilityClasses.FunctionDetails;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.i18n.I18nConstants;
|
||||
import org.hl7.fhir.utilities.xhtml.NodeType;
|
||||
|
|
|
@ -9,6 +9,7 @@ import org.hl7.fhir.r4b.model.Resource;
|
|||
import org.hl7.fhir.r4b.model.TypeDetails;
|
||||
import org.hl7.fhir.r4b.model.ValueSet;
|
||||
import org.hl7.fhir.r4b.utils.FHIRPathEngine;
|
||||
import org.hl7.fhir.r4b.utils.FHIRPathUtilityClasses.FunctionDetails;
|
||||
import org.hl7.fhir.r4b.utils.validation.IResourceValidator;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage;
|
||||
|
||||
|
|
|
@ -68,6 +68,7 @@ import org.hl7.fhir.r4b.utils.FHIRLexer;
|
|||
import org.hl7.fhir.r4b.utils.FHIRLexer.FHIRLexerException;
|
||||
import org.hl7.fhir.r4b.utils.FHIRPathEngine;
|
||||
import org.hl7.fhir.r4b.utils.FHIRPathEngine.IEvaluationContext;
|
||||
import org.hl7.fhir.r4b.utils.FHIRPathUtilityClasses.FunctionDetails;
|
||||
import org.hl7.fhir.r4b.utils.ToolingExtensions;
|
||||
import org.hl7.fhir.r4b.utils.validation.IResourceValidator;
|
||||
import org.hl7.fhir.utilities.CommaSeparatedStringBuilder;
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.hl7.fhir.r4b.test.FHIRPathTests.TestResultType;
|
|||
import org.hl7.fhir.r4b.test.utils.TestingUtilities;
|
||||
import org.hl7.fhir.r4b.utils.FHIRPathEngine;
|
||||
import org.hl7.fhir.r4b.utils.FHIRPathEngine.IEvaluationContext;
|
||||
import org.hl7.fhir.r4b.utils.FHIRPathUtilityClasses.FunctionDetails;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.xml.XMLUtil;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
|
|
|
@ -39,6 +39,7 @@ import org.hl7.fhir.r4b.model.ValueSet;
|
|||
import org.hl7.fhir.r4b.test.utils.TestingUtilities;
|
||||
import org.hl7.fhir.r4b.utils.FHIRPathEngine;
|
||||
import org.hl7.fhir.r4b.utils.FHIRPathEngine.IEvaluationContext;
|
||||
import org.hl7.fhir.r4b.utils.FHIRPathUtilityClasses.FunctionDetails;
|
||||
import org.hl7.fhir.r4b.utils.validation.IResourceValidator;
|
||||
import org.hl7.fhir.r4b.utils.XVerExtensionManager;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.hl7.fhir.r5.model.Tuple;
|
|||
import org.hl7.fhir.r5.model.TypeDetails;
|
||||
import org.hl7.fhir.r5.model.ValueSet;
|
||||
import org.hl7.fhir.r5.utils.FHIRPathEngine.IEvaluationContext;
|
||||
import org.hl7.fhir.r5.utils.FHIRPathUtilityClasses.FunctionDetails;
|
||||
import org.hl7.fhir.r5.utils.LiquidEngine;
|
||||
import org.hl7.fhir.r5.utils.LiquidEngine.LiquidDocument;
|
||||
import org.hl7.fhir.utilities.TextFile;
|
||||
|
|
|
@ -61,7 +61,10 @@ import org.hl7.fhir.r5.model.TypeDetails;
|
|||
import org.hl7.fhir.r5.model.TypeDetails.ProfiledType;
|
||||
import org.hl7.fhir.r5.model.ValueSet;
|
||||
import org.hl7.fhir.r5.utils.FHIRLexer.FHIRLexerException;
|
||||
import org.hl7.fhir.r5.utils.FHIRPathEngine.IEvaluationContext.FunctionDetails;
|
||||
import org.hl7.fhir.r5.utils.FHIRPathUtilityClasses.FHIRConstant;
|
||||
import org.hl7.fhir.r5.utils.FHIRPathUtilityClasses.ClassTypeInfo;
|
||||
import org.hl7.fhir.r5.utils.FHIRPathUtilityClasses.FunctionDetails;
|
||||
import org.hl7.fhir.r5.utils.FHIRPathUtilityClasses.TypedElementDefinition;
|
||||
import org.hl7.fhir.utilities.CommaSeparatedStringBuilder;
|
||||
import org.hl7.fhir.utilities.MarkDownProcessor;
|
||||
import org.hl7.fhir.utilities.MergedList;
|
||||
|
@ -115,157 +118,7 @@ import ca.uhn.fhir.util.ElementUtil;
|
|||
public class FHIRPathEngine {
|
||||
|
||||
private enum Equality { Null, True, False }
|
||||
|
||||
private class FHIRConstant extends Base {
|
||||
|
||||
private static final long serialVersionUID = -8933773658248269439L;
|
||||
private String value;
|
||||
|
||||
public FHIRConstant(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String fhirType() {
|
||||
return "%constant";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void listChildren(List<Property> result) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdBase() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIdBase(String value) {
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String primitiveValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Base copy() {
|
||||
throw new Error("Not Implemented");
|
||||
}
|
||||
}
|
||||
|
||||
private class ClassTypeInfo extends Base {
|
||||
private static final long serialVersionUID = 4909223114071029317L;
|
||||
private Base instance;
|
||||
|
||||
public ClassTypeInfo(Base instance) {
|
||||
super();
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String fhirType() {
|
||||
return "ClassInfo";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void listChildren(List<Property> result) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdBase() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIdBase(String value) {
|
||||
}
|
||||
|
||||
public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
|
||||
if (name.equals("name")) {
|
||||
return new Base[]{new StringType(getName())};
|
||||
} else if (name.equals("namespace")) {
|
||||
return new Base[]{new StringType(getNamespace())};
|
||||
} else {
|
||||
return super.getProperty(hash, name, checkValid);
|
||||
}
|
||||
}
|
||||
|
||||
private String getNamespace() {
|
||||
if ((instance instanceof Resource)) {
|
||||
return "FHIR";
|
||||
} else if (!(instance instanceof Element) || ((Element)instance).isDisallowExtensions()) {
|
||||
return "System";
|
||||
} else {
|
||||
return "FHIR";
|
||||
}
|
||||
}
|
||||
|
||||
private String getName() {
|
||||
if ((instance instanceof Resource)) {
|
||||
return instance.fhirType();
|
||||
} else if (!(instance instanceof Element) || ((Element)instance).isDisallowExtensions()) {
|
||||
return Utilities.capitalize(instance.fhirType());
|
||||
} else {
|
||||
return instance.fhirType();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Base copy() {
|
||||
throw new Error("Not Implemented");
|
||||
}
|
||||
}
|
||||
|
||||
public static class TypedElementDefinition {
|
||||
private ElementDefinition element;
|
||||
private String type;
|
||||
private StructureDefinition src;
|
||||
public TypedElementDefinition(StructureDefinition src, ElementDefinition element, String type) {
|
||||
super();
|
||||
this.element = element;
|
||||
this.type = type;
|
||||
this.src = src;
|
||||
}
|
||||
public TypedElementDefinition(ElementDefinition element) {
|
||||
super();
|
||||
this.element = element;
|
||||
}
|
||||
public ElementDefinition getElement() {
|
||||
return element;
|
||||
}
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
public List<TypeRefComponent> getTypes() {
|
||||
List<TypeRefComponent> res = new ArrayList<ElementDefinition.TypeRefComponent>();
|
||||
for (TypeRefComponent tr : element.getType()) {
|
||||
if (type == null || type.equals(tr.getCode())) {
|
||||
res.add(tr);
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
public StructureDefinition getSrc() {
|
||||
return src;
|
||||
}
|
||||
}
|
||||
|
||||
private IWorkerContext worker;
|
||||
private IEvaluationContext hostServices;
|
||||
private StringBuilder log = new StringBuilder();
|
||||
|
@ -286,27 +139,6 @@ public class FHIRPathEngine {
|
|||
// if the fhir path expressions are allowed to use constants beyond those defined in the specification
|
||||
// the application can implement them by providing a constant resolver
|
||||
public interface IEvaluationContext {
|
||||
public class FunctionDetails {
|
||||
private String description;
|
||||
private int minParameters;
|
||||
private int maxParameters;
|
||||
public FunctionDetails(String description, int minParameters, int maxParameters) {
|
||||
super();
|
||||
this.description = description;
|
||||
this.minParameters = minParameters;
|
||||
this.maxParameters = maxParameters;
|
||||
}
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
public int getMinParameters() {
|
||||
return minParameters;
|
||||
}
|
||||
public int getMaxParameters() {
|
||||
return maxParameters;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* A constant reference - e.g. a reference to a name that must be resolved in context.
|
||||
|
@ -5909,7 +5741,7 @@ public class FHIRPathEngine {
|
|||
return result;
|
||||
}
|
||||
|
||||
public class ElementDefinitionMatch {
|
||||
private class ElementDefinitionMatch {
|
||||
private ElementDefinition definition;
|
||||
private ElementDefinition sourceDefinition; // if there was a content reference
|
||||
private String fixedType;
|
||||
|
|
|
@ -0,0 +1,192 @@
|
|||
package org.hl7.fhir.r5.utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.r5.model.Base;
|
||||
import org.hl7.fhir.r5.model.Element;
|
||||
import org.hl7.fhir.r5.model.ElementDefinition;
|
||||
import org.hl7.fhir.r5.model.Property;
|
||||
import org.hl7.fhir.r5.model.Resource;
|
||||
import org.hl7.fhir.r5.model.StringType;
|
||||
import org.hl7.fhir.r5.model.StructureDefinition;
|
||||
import org.hl7.fhir.r5.model.ElementDefinition.TypeRefComponent;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
|
||||
public class FHIRPathUtilityClasses {
|
||||
|
||||
public static class FHIRConstant extends Base {
|
||||
|
||||
private static final long serialVersionUID = -8933773658248269439L;
|
||||
private String value;
|
||||
|
||||
public FHIRConstant(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String fhirType() {
|
||||
return "%constant";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void listChildren(List<Property> result) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdBase() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIdBase(String value) {
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String primitiveValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Base copy() {
|
||||
throw new Error("Not Implemented");
|
||||
}
|
||||
}
|
||||
|
||||
public static class ClassTypeInfo extends Base {
|
||||
private static final long serialVersionUID = 4909223114071029317L;
|
||||
private Base instance;
|
||||
|
||||
public ClassTypeInfo(Base instance) {
|
||||
super();
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String fhirType() {
|
||||
return "ClassInfo";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void listChildren(List<Property> result) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdBase() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIdBase(String value) {
|
||||
}
|
||||
|
||||
public Base[] getProperty(int hash, String name, boolean checkValid) throws FHIRException {
|
||||
if (name.equals("name")) {
|
||||
return new Base[]{new StringType(getName())};
|
||||
} else if (name.equals("namespace")) {
|
||||
return new Base[]{new StringType(getNamespace())};
|
||||
} else {
|
||||
return super.getProperty(hash, name, checkValid);
|
||||
}
|
||||
}
|
||||
|
||||
private String getNamespace() {
|
||||
if ((instance instanceof Resource)) {
|
||||
return "FHIR";
|
||||
} else if (!(instance instanceof Element) || ((Element)instance).isDisallowExtensions()) {
|
||||
return "System";
|
||||
} else {
|
||||
return "FHIR";
|
||||
}
|
||||
}
|
||||
|
||||
private String getName() {
|
||||
if ((instance instanceof Resource)) {
|
||||
return instance.fhirType();
|
||||
} else if (!(instance instanceof Element) || ((Element)instance).isDisallowExtensions()) {
|
||||
return Utilities.capitalize(instance.fhirType());
|
||||
} else {
|
||||
return instance.fhirType();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Base copy() {
|
||||
throw new Error("Not Implemented");
|
||||
}
|
||||
}
|
||||
|
||||
public static class TypedElementDefinition {
|
||||
private ElementDefinition element;
|
||||
private String type;
|
||||
private StructureDefinition src;
|
||||
public TypedElementDefinition(StructureDefinition src, ElementDefinition element, String type) {
|
||||
super();
|
||||
this.element = element;
|
||||
this.type = type;
|
||||
this.src = src;
|
||||
}
|
||||
public TypedElementDefinition(ElementDefinition element) {
|
||||
super();
|
||||
this.element = element;
|
||||
}
|
||||
public ElementDefinition getElement() {
|
||||
return element;
|
||||
}
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
public List<TypeRefComponent> getTypes() {
|
||||
List<TypeRefComponent> res = new ArrayList<ElementDefinition.TypeRefComponent>();
|
||||
for (TypeRefComponent tr : element.getType()) {
|
||||
if (type == null || type.equals(tr.getCode())) {
|
||||
res.add(tr);
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
public StructureDefinition getSrc() {
|
||||
return src;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class FunctionDetails {
|
||||
private String description;
|
||||
private int minParameters;
|
||||
private int maxParameters;
|
||||
public FunctionDetails(String description, int minParameters, int maxParameters) {
|
||||
super();
|
||||
this.description = description;
|
||||
this.minParameters = minParameters;
|
||||
this.maxParameters = maxParameters;
|
||||
}
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
public int getMinParameters() {
|
||||
return minParameters;
|
||||
}
|
||||
public int getMaxParameters() {
|
||||
return maxParameters;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -46,6 +46,7 @@ import org.hl7.fhir.r5.model.TypeDetails;
|
|||
import org.hl7.fhir.r5.model.ValueSet;
|
||||
import org.hl7.fhir.r5.utils.FHIRPathEngine.ExpressionNodeWithOffset;
|
||||
import org.hl7.fhir.r5.utils.FHIRPathEngine.IEvaluationContext;
|
||||
import org.hl7.fhir.r5.utils.FHIRPathUtilityClasses.FunctionDetails;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.i18n.I18nConstants;
|
||||
import org.hl7.fhir.utilities.xhtml.NodeType;
|
||||
|
|
|
@ -9,6 +9,7 @@ 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.utils.FHIRPathEngine;
|
||||
import org.hl7.fhir.r5.utils.FHIRPathUtilityClasses.FunctionDetails;
|
||||
import org.hl7.fhir.r5.utils.validation.IResourceValidator;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage;
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ import org.hl7.fhir.r5.model.*;
|
|||
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.FHIRPathUtilityClasses.FunctionDetails;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.xml.XMLUtil;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
|
|
|
@ -40,6 +40,7 @@ import org.hl7.fhir.r5.renderers.utils.RenderingContext.ResourceRendererMode;
|
|||
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.FHIRPathUtilityClasses.FunctionDetails;
|
||||
import org.hl7.fhir.r5.utils.XVerExtensionManager;
|
||||
import org.hl7.fhir.r5.utils.validation.IResourceValidator;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
|
|
|
@ -155,7 +155,8 @@ import org.hl7.fhir.r5.utils.BuildExtensions;
|
|||
import org.hl7.fhir.r5.utils.FHIRLexer.FHIRLexerException;
|
||||
import org.hl7.fhir.r5.utils.FHIRPathEngine;
|
||||
import org.hl7.fhir.r5.utils.FHIRPathEngine.IEvaluationContext;
|
||||
import org.hl7.fhir.r5.utils.FHIRPathEngine.TypedElementDefinition;
|
||||
import org.hl7.fhir.r5.utils.FHIRPathUtilityClasses.FunctionDetails;
|
||||
import org.hl7.fhir.r5.utils.FHIRPathUtilityClasses.TypedElementDefinition;
|
||||
import org.hl7.fhir.r5.utils.ResourceUtilities;
|
||||
import org.hl7.fhir.r5.utils.ToolingExtensions;
|
||||
import org.hl7.fhir.r5.utils.XVerExtensionManager;
|
||||
|
|
|
@ -37,6 +37,7 @@ import org.hl7.fhir.r5.renderers.utils.RenderingContext.ResourceRendererMode;
|
|||
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.FHIRPathUtilityClasses.FunctionDetails;
|
||||
import org.hl7.fhir.r5.utils.validation.IResourceValidator;
|
||||
import org.hl7.fhir.utilities.Utilities;
|
||||
import org.hl7.fhir.utilities.validation.ValidationMessage;
|
||||
|
|
|
@ -52,6 +52,7 @@ 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.FHIRPathUtilityClasses.FunctionDetails;
|
||||
import org.hl7.fhir.r5.utils.OperationOutcomeUtilities;
|
||||
import org.hl7.fhir.r5.utils.validation.BundleValidationRule;
|
||||
import org.hl7.fhir.r5.utils.validation.IResourceValidator;
|
||||
|
|
Loading…
Reference in New Issue