Revise FHIRPath API so hosts can evaluate expressions in custom functions
This commit is contained in:
parent
1534a5b6eb
commit
40c996828a
|
@ -59,6 +59,7 @@ import org.hl7.fhir.r4.utils.FHIRLexer.FHIRLexerException;
|
|||
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.FHIRPathEngine;
|
||||
import org.hl7.fhir.r4.utils.FHIRPathUtilityClasses.FunctionDetails;
|
||||
import org.hl7.fhir.utilities.CommaSeparatedStringBuilder;
|
||||
import org.hl7.fhir.utilities.MergedList;
|
||||
|
@ -150,9 +151,9 @@ public class FHIRPathEngine {
|
|||
* @return the value of the reference (or null, if it's not valid, though can
|
||||
* throw an exception if desired)
|
||||
*/
|
||||
public List<Base> resolveConstant(Object appContext, String name, boolean beforeContext) throws PathEngineException;
|
||||
public List<Base> resolveConstant(FHIRPathEngine engine, Object appContext, String name, boolean beforeContext, boolean explicitConstant) throws PathEngineException;
|
||||
|
||||
public TypeDetails resolveConstantType(Object appContext, String name) throws PathEngineException;
|
||||
public TypeDetails resolveConstantType(FHIRPathEngine engine, Object appContext, String name, boolean explicitConstant) throws PathEngineException;
|
||||
|
||||
/**
|
||||
* when the .log() function is called
|
||||
|
@ -169,7 +170,7 @@ public class FHIRPathEngine {
|
|||
* @param functionName
|
||||
* @return null if the function is not known
|
||||
*/
|
||||
public FunctionDetails resolveFunction(String functionName);
|
||||
public FunctionDetails resolveFunction(FHIRPathEngine engine, String functionName);
|
||||
|
||||
/**
|
||||
* Check the function parameters, and throw an error if they are incorrect, or
|
||||
|
@ -179,7 +180,7 @@ public class FHIRPathEngine {
|
|||
* @param parameters
|
||||
* @return
|
||||
*/
|
||||
public TypeDetails checkFunction(Object appContext, String functionName, List<TypeDetails> parameters)
|
||||
public TypeDetails checkFunction(FHIRPathEngine engine, Object appContext, String functionName, TypeDetails focus, List<TypeDetails> parameters)
|
||||
throws PathEngineException;
|
||||
|
||||
/**
|
||||
|
@ -188,7 +189,7 @@ public class FHIRPathEngine {
|
|||
* @param parameters
|
||||
* @return
|
||||
*/
|
||||
public List<Base> executeFunction(Object appContext, List<Base> focus, String functionName,
|
||||
public List<Base> executeFunction(FHIRPathEngine engine, Object appContext, List<Base> focus, String functionName,
|
||||
List<List<Base>> parameters);
|
||||
|
||||
/**
|
||||
|
@ -200,14 +201,14 @@ public class FHIRPathEngine {
|
|||
* @return
|
||||
* @throws FHIRException
|
||||
*/
|
||||
public Base resolveReference(Object appContext, String url, Base refContext) throws FHIRException;
|
||||
public Base resolveReference(FHIRPathEngine engine, Object appContext, String url, Base refContext) throws FHIRException;
|
||||
|
||||
public boolean conformsToProfile(Object appContext, Base item, String url) throws FHIRException;
|
||||
public boolean conformsToProfile(FHIRPathEngine engine, Object appContext, Base item, String url) throws FHIRException;
|
||||
|
||||
/*
|
||||
* return the value set referenced by the url, which has been used in memberOf()
|
||||
*/
|
||||
public ValueSet resolveValueSet(Object appContext, String url);
|
||||
public ValueSet resolveValueSet(FHIRPathEngine engine, Object appContext, String url);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1032,7 +1033,7 @@ public class FHIRPathEngine {
|
|||
FunctionDetails details = null;
|
||||
if (f == null) {
|
||||
if (hostServices != null) {
|
||||
details = hostServices.resolveFunction(result.getName());
|
||||
details = hostServices.resolveFunction(this, result.getName());
|
||||
}
|
||||
if (details == null) {
|
||||
throw lexer.error("The name " + result.getName() + " is not a valid function name");
|
||||
|
@ -1473,7 +1474,7 @@ public class FHIRPathEngine {
|
|||
work.addAll(work2);
|
||||
break;
|
||||
case Constant:
|
||||
work.addAll(resolveConstant(context, exp.getConstant(), false, exp));
|
||||
work.addAll(resolveConstant(context, exp.getConstant(), false, exp, true));
|
||||
break;
|
||||
case Group:
|
||||
work2 = execute(context, focus, exp.getGroup(), atEntry);
|
||||
|
@ -1563,7 +1564,7 @@ public class FHIRPathEngine {
|
|||
} else if (atEntry && exp.getName().equals("$index")) {
|
||||
result.addType(TypeDetails.FP_Integer);
|
||||
} else if (atEntry && focus == null) {
|
||||
result.update(executeContextType(context, exp.getName(), exp));
|
||||
result.update(executeContextType(context, exp.getName(), exp, false));
|
||||
} else {
|
||||
for (String s : focus.getTypes()) {
|
||||
result.update(executeType(s, exp, atEntry));
|
||||
|
@ -1582,7 +1583,7 @@ public class FHIRPathEngine {
|
|||
result.addType(TypeDetails.FP_Quantity);
|
||||
break;
|
||||
case Constant:
|
||||
result.update(resolveConstantType(context, exp.getConstant(), exp));
|
||||
result.update(resolveConstantType(context, exp.getConstant(), exp, true));
|
||||
break;
|
||||
case Group:
|
||||
result.update(executeType(context, focus, exp.getGroup(), atEntry));
|
||||
|
@ -1612,8 +1613,7 @@ public class FHIRPathEngine {
|
|||
return result;
|
||||
}
|
||||
|
||||
private List<Base> resolveConstant(ExecutionContext context, Base constant, boolean beforeContext,
|
||||
ExpressionNode expr) throws PathEngineException {
|
||||
private List<Base> resolveConstant(ExecutionContext context, Base constant, boolean beforeContext, ExpressionNode expr, boolean explicitConstant) throws PathEngineException {
|
||||
if (constant == null) {
|
||||
return new ArrayList<Base>();
|
||||
}
|
||||
|
@ -1622,7 +1622,7 @@ public class FHIRPathEngine {
|
|||
}
|
||||
FHIRConstant c = (FHIRConstant) constant;
|
||||
if (c.getValue().startsWith("%")) {
|
||||
return resolveConstant(context, c.getValue(), beforeContext, expr);
|
||||
return resolveConstant(context, c.getValue(), beforeContext, expr, explicitConstant);
|
||||
} else if (c.getValue().startsWith("@")) {
|
||||
return new ArrayList<Base>(Arrays.asList(processDateConstant(context.appInfo, c.getValue().substring(1), expr)));
|
||||
} else {
|
||||
|
@ -1692,7 +1692,7 @@ public class FHIRPathEngine {
|
|||
}
|
||||
}
|
||||
|
||||
private List<Base> resolveConstant(ExecutionContext context, String s, boolean beforeContext, ExpressionNode expr)
|
||||
private List<Base> resolveConstant(ExecutionContext context, String s, boolean beforeContext, ExpressionNode expr, boolean explicitConstant)
|
||||
throws PathEngineException {
|
||||
if (s.equals("%sct")) {
|
||||
return new ArrayList<Base>(Arrays.asList(new StringType("http://snomed.info/sct").noExtensions()));
|
||||
|
@ -1726,7 +1726,7 @@ public class FHIRPathEngine {
|
|||
} else if (hostServices == null) {
|
||||
throw makeException(expr, I18nConstants.FHIRPATH_UNKNOWN_CONSTANT, s);
|
||||
} else {
|
||||
return hostServices.resolveConstant(context.appInfo, s.substring(1), beforeContext);
|
||||
return hostServices.resolveConstant(this, context.appInfo, s.substring(1), beforeContext, explicitConstant);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2549,7 +2549,7 @@ public class FHIRPathEngine {
|
|||
throws FHIRException {
|
||||
boolean ans = false;
|
||||
String url = right.get(0).primitiveValue();
|
||||
ValueSet vs = hostServices != null ? hostServices.resolveValueSet(context.appInfo, url)
|
||||
ValueSet vs = hostServices != null ? hostServices.resolveValueSet(this, context.appInfo, url)
|
||||
: worker.fetchResource(ValueSet.class, url);
|
||||
if (vs != null) {
|
||||
for (Base l : left) {
|
||||
|
@ -3079,7 +3079,7 @@ public class FHIRPathEngine {
|
|||
return result;
|
||||
}
|
||||
|
||||
private TypeDetails resolveConstantType(ExecutionTypeContext context, Base constant, ExpressionNode expr)
|
||||
private TypeDetails resolveConstantType(ExecutionTypeContext context, Base constant, ExpressionNode expr, boolean explicitConstant)
|
||||
throws PathEngineException {
|
||||
if (constant instanceof BooleanType) {
|
||||
return new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_Boolean);
|
||||
|
@ -3090,7 +3090,7 @@ public class FHIRPathEngine {
|
|||
} else if (constant instanceof Quantity) {
|
||||
return new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_Quantity);
|
||||
} else if (constant instanceof FHIRConstant) {
|
||||
return resolveConstantType(context, ((FHIRConstant) constant).getValue(), expr);
|
||||
return resolveConstantType(context, ((FHIRConstant) constant).getValue(), expr, explicitConstant);
|
||||
} else if (constant == null) {
|
||||
return new TypeDetails(CollectionStatus.SINGLETON);
|
||||
} else {
|
||||
|
@ -3098,7 +3098,7 @@ public class FHIRPathEngine {
|
|||
}
|
||||
}
|
||||
|
||||
private TypeDetails resolveConstantType(ExecutionTypeContext context, String s, ExpressionNode expr)
|
||||
private TypeDetails resolveConstantType(ExecutionTypeContext context, String s, ExpressionNode expr, boolean explicitConstant)
|
||||
throws PathEngineException {
|
||||
if (s.startsWith("@")) {
|
||||
if (s.startsWith("@T")) {
|
||||
|
@ -3137,7 +3137,7 @@ public class FHIRPathEngine {
|
|||
} else if (hostServices == null) {
|
||||
throw makeException(expr, I18nConstants.FHIRPATH_UNKNOWN_CONSTANT, s);
|
||||
} else {
|
||||
return hostServices.resolveConstantType(context.appInfo, s);
|
||||
return hostServices.resolveConstantType(this, context.appInfo, s, explicitConstant);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3146,7 +3146,7 @@ public class FHIRPathEngine {
|
|||
List<Base> result = new ArrayList<Base>();
|
||||
if (atEntry && context.appInfo != null && hostServices != null) {
|
||||
// we'll see if the name matches a constant known by the context.
|
||||
List<Base> temp = hostServices.resolveConstant(context.appInfo, exp.getName(), true);
|
||||
List<Base> temp = hostServices.resolveConstant(this, context.appInfo, exp.getName(), true, false);
|
||||
if (!temp.isEmpty()) {
|
||||
result.addAll(temp);
|
||||
return result;
|
||||
|
@ -3177,7 +3177,7 @@ public class FHIRPathEngine {
|
|||
// constant known by the context.
|
||||
// (if the name does match, and the user wants to get the constant value,
|
||||
// they'll have to try harder...
|
||||
result.addAll(hostServices.resolveConstant(context.appInfo, exp.getName(), false));
|
||||
result.addAll(hostServices.resolveConstant(this, context.appInfo, exp.getName(), false, false));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -3186,12 +3186,12 @@ public class FHIRPathEngine {
|
|||
return null;
|
||||
}
|
||||
|
||||
private TypeDetails executeContextType(ExecutionTypeContext context, String name, ExpressionNode expr)
|
||||
private TypeDetails executeContextType(ExecutionTypeContext context, String name, ExpressionNode expr, boolean explicitConstant)
|
||||
throws PathEngineException, DefinitionException {
|
||||
if (hostServices == null) {
|
||||
throw makeException(expr, I18nConstants.FHIRPATH_HO_HOST_SERVICES, "Context Reference");
|
||||
}
|
||||
return hostServices.resolveConstantType(context.appInfo, name);
|
||||
return hostServices.resolveConstantType(this, context.appInfo, name, explicitConstant);
|
||||
}
|
||||
|
||||
private TypeDetails executeType(String type, ExpressionNode exp, boolean atEntry)
|
||||
|
@ -3607,7 +3607,7 @@ public class FHIRPathEngine {
|
|||
}
|
||||
|
||||
case Custom: {
|
||||
return hostServices.checkFunction(context.appInfo, exp.getName(), paramTypes);
|
||||
return hostServices.checkFunction(this, context.appInfo, exp.getName(), focus, paramTypes);
|
||||
}
|
||||
default:
|
||||
break;
|
||||
|
@ -3932,7 +3932,7 @@ public class FHIRPathEngine {
|
|||
for (ExpressionNode p : exp.getParameters()) {
|
||||
params.add(execute(context, focus, p, true));
|
||||
}
|
||||
return hostServices.executeFunction(context.appInfo, focus, exp.getName(), params);
|
||||
return hostServices.executeFunction(this, context.appInfo, focus, exp.getName(), params);
|
||||
}
|
||||
default:
|
||||
throw new Error("not Implemented yet");
|
||||
|
@ -4605,7 +4605,7 @@ public class FHIRPathEngine {
|
|||
}
|
||||
|
||||
String url = nl.get(0).primitiveValue();
|
||||
ValueSet vs = hostServices != null ? hostServices.resolveValueSet(context.appInfo, url)
|
||||
ValueSet vs = hostServices != null ? hostServices.resolveValueSet(this, context.appInfo, url)
|
||||
: worker.fetchResource(ValueSet.class, url);
|
||||
if (vs == null) {
|
||||
return new ArrayList<Base>();
|
||||
|
@ -5210,7 +5210,7 @@ public class FHIRPathEngine {
|
|||
}
|
||||
} else if (hostServices != null) {
|
||||
try {
|
||||
res = hostServices.resolveReference(context.appInfo, s, refContext);
|
||||
res = hostServices.resolveReference(this, context.appInfo, s, refContext);
|
||||
} catch (Exception e) {
|
||||
res = null;
|
||||
}
|
||||
|
@ -5740,7 +5740,7 @@ public class FHIRPathEngine {
|
|||
result.add(new BooleanType(false).noExtensions());
|
||||
} else {
|
||||
String url = convertToString(execute(context, focus, expr.getParameters().get(0), true));
|
||||
result.add(new BooleanType(hostServices.conformsToProfile(context.appInfo, focus.get(0), url)).noExtensions());
|
||||
result.add(new BooleanType(hostServices.conformsToProfile(this, context.appInfo, focus.get(0), url)).noExtensions());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -369,21 +369,21 @@ public class LiquidEngine implements IEvaluationContext {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<Base> resolveConstant(Object appContext, String name, boolean beforeContext) throws PathEngineException {
|
||||
public List<Base> resolveConstant(FHIRPathEngine engine, Object appContext, String name, boolean beforeContext, boolean explicitConstant) throws PathEngineException {
|
||||
LiquidEngineContext ctxt = (LiquidEngineContext) appContext;
|
||||
if (ctxt.vars.containsKey(name))
|
||||
return new ArrayList<>(Arrays.asList(ctxt.vars.get(name)));
|
||||
if (externalHostServices == null)
|
||||
return null;
|
||||
return externalHostServices.resolveConstant(ctxt.externalContext, name, beforeContext);
|
||||
return externalHostServices.resolveConstant(engine, ctxt.externalContext, name, beforeContext, explicitConstant);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeDetails resolveConstantType(Object appContext, String name) throws PathEngineException {
|
||||
public TypeDetails resolveConstantType(FHIRPathEngine engine, Object appContext, String name, boolean explicitConstant) throws PathEngineException {
|
||||
if (externalHostServices == null)
|
||||
return null;
|
||||
LiquidEngineContext ctxt = (LiquidEngineContext) appContext;
|
||||
return externalHostServices.resolveConstantType(ctxt.externalContext, name);
|
||||
return externalHostServices.resolveConstantType(engine, ctxt.externalContext, name, explicitConstant);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -394,51 +394,51 @@ public class LiquidEngine implements IEvaluationContext {
|
|||
}
|
||||
|
||||
@Override
|
||||
public FunctionDetails resolveFunction(String functionName) {
|
||||
public FunctionDetails resolveFunction(FHIRPathEngine engine, String functionName) {
|
||||
if (externalHostServices == null)
|
||||
return null;
|
||||
return externalHostServices.resolveFunction(functionName);
|
||||
return externalHostServices.resolveFunction(engine, functionName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeDetails checkFunction(Object appContext, String functionName, List<TypeDetails> parameters)
|
||||
public TypeDetails checkFunction(FHIRPathEngine engine, Object appContext, String functionName, TypeDetails focus, List<TypeDetails> parameters)
|
||||
throws PathEngineException {
|
||||
if (externalHostServices == null)
|
||||
return null;
|
||||
LiquidEngineContext ctxt = (LiquidEngineContext) appContext;
|
||||
return externalHostServices.checkFunction(ctxt.externalContext, functionName, parameters);
|
||||
return externalHostServices.checkFunction(engine, ctxt.externalContext, functionName, focus, parameters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Base> executeFunction(Object appContext, List<Base> focus, String functionName,
|
||||
public List<Base> executeFunction(FHIRPathEngine engine, Object appContext, List<Base> focus, String functionName,
|
||||
List<List<Base>> parameters) {
|
||||
if (externalHostServices == null)
|
||||
return null;
|
||||
LiquidEngineContext ctxt = (LiquidEngineContext) appContext;
|
||||
return externalHostServices.executeFunction(ctxt.externalContext, focus, functionName, parameters);
|
||||
return externalHostServices.executeFunction(engine, ctxt.externalContext, focus, functionName, parameters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Base resolveReference(Object appContext, String url, Base base) throws FHIRException {
|
||||
public Base resolveReference(FHIRPathEngine engine, Object appContext, String url, Base base) throws FHIRException {
|
||||
if (externalHostServices == null)
|
||||
return null;
|
||||
LiquidEngineContext ctxt = (LiquidEngineContext) appContext;
|
||||
return resolveReference(ctxt.externalContext, url, base);
|
||||
return resolveReference(engine, ctxt.externalContext, url, base);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean conformsToProfile(Object appContext, Base item, String url) throws FHIRException {
|
||||
public boolean conformsToProfile(FHIRPathEngine engine, Object appContext, Base item, String url) throws FHIRException {
|
||||
if (externalHostServices == null)
|
||||
return false;
|
||||
LiquidEngineContext ctxt = (LiquidEngineContext) appContext;
|
||||
return conformsToProfile(ctxt.externalContext, item, url);
|
||||
return conformsToProfile(engine, ctxt.externalContext, item, url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueSet resolveValueSet(Object appContext, String url) {
|
||||
public ValueSet resolveValueSet(FHIRPathEngine engine, Object appContext, String url) {
|
||||
LiquidEngineContext ctxt = (LiquidEngineContext) appContext;
|
||||
if (externalHostServices != null)
|
||||
return externalHostServices.resolveValueSet(ctxt.externalContext, url);
|
||||
return externalHostServices.resolveValueSet(engine, ctxt.externalContext, url);
|
||||
else
|
||||
return engine.getWorker().fetchResource(ValueSet.class, url);
|
||||
}
|
||||
|
|
|
@ -177,7 +177,7 @@ public class StructureMapUtilities {
|
|||
|
||||
private class FHIRPathHostServices implements IEvaluationContext {
|
||||
|
||||
public List<Base> resolveConstant(Object appContext, String name, boolean beforeContext)
|
||||
public List<Base> resolveConstant(FHIRPathEngine engine, Object appContext, String name, boolean beforeContext, boolean explicitConstant)
|
||||
throws PathEngineException {
|
||||
Variables vars = (Variables) appContext;
|
||||
Base res = vars.get(VariableMode.INPUT, name);
|
||||
|
@ -190,7 +190,7 @@ public class StructureMapUtilities {
|
|||
}
|
||||
|
||||
@Override
|
||||
public TypeDetails resolveConstantType(Object appContext, String name) throws PathEngineException {
|
||||
public TypeDetails resolveConstantType(FHIRPathEngine engine, Object appContext, String name, boolean explicitConstant) throws PathEngineException {
|
||||
if (!(appContext instanceof VariablesForProfiling))
|
||||
throw new Error(
|
||||
"Internal Logic Error (wrong type '" + appContext.getClass().getName() + "' in resolveConstantType)");
|
||||
|
@ -207,31 +207,31 @@ public class StructureMapUtilities {
|
|||
}
|
||||
|
||||
@Override
|
||||
public FunctionDetails resolveFunction(String functionName) {
|
||||
public FunctionDetails resolveFunction(FHIRPathEngine engine, String functionName) {
|
||||
return null; // throw new Error("Not Implemented Yet");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeDetails checkFunction(Object appContext, String functionName, List<TypeDetails> parameters)
|
||||
public TypeDetails checkFunction(FHIRPathEngine engine, Object appContext, String functionName, TypeDetails focus, List<TypeDetails> parameters)
|
||||
throws PathEngineException {
|
||||
throw new Error("Not Implemented Yet");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Base> executeFunction(Object appContext, List<Base> focus, String functionName,
|
||||
public List<Base> executeFunction(FHIRPathEngine engine, Object appContext, List<Base> focus, String functionName,
|
||||
List<List<Base>> parameters) {
|
||||
throw new Error("Not Implemented Yet");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Base resolveReference(Object appContext, String url, Base base) throws FHIRException {
|
||||
public Base resolveReference(FHIRPathEngine engine, Object appContext, String url, Base base) throws FHIRException {
|
||||
if (services == null)
|
||||
return null;
|
||||
return services.resolveReference(appContext, url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean conformsToProfile(Object appContext, Base item, String url) throws FHIRException {
|
||||
public boolean conformsToProfile(FHIRPathEngine engine, Object appContext, Base item, String url) throws FHIRException {
|
||||
IResourceValidator val = worker.newValidator();
|
||||
List<ValidationMessage> valerrors = new ArrayList<ValidationMessage>();
|
||||
if (item instanceof Resource) {
|
||||
|
@ -245,7 +245,7 @@ public class StructureMapUtilities {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ValueSet resolveValueSet(Object appContext, String url) {
|
||||
public ValueSet resolveValueSet(FHIRPathEngine engine, Object appContext, String url) {
|
||||
throw new Error("Not Implemented Yet");
|
||||
}
|
||||
|
||||
|
|
|
@ -58,14 +58,14 @@ public class FHIRPathTests {
|
|||
public class FHIRPathTestEvaluationServices implements IEvaluationContext {
|
||||
|
||||
@Override
|
||||
public List<Base> resolveConstant(Object appContext, String name, boolean beforeContext)
|
||||
public List<Base> resolveConstant(FHIRPathEngine engine, Object appContext, String name, boolean beforeContext, boolean explicitConstant)
|
||||
throws PathEngineException {
|
||||
throw new NotImplementedException(
|
||||
"Not done yet (FHIRPathTestEvaluationServices.resolveConstant), when item is element");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeDetails resolveConstantType(Object appContext, String name) throws PathEngineException {
|
||||
public TypeDetails resolveConstantType(FHIRPathEngine engine, Object appContext, String name, boolean explicitConstant) throws PathEngineException {
|
||||
throw new NotImplementedException(
|
||||
"Not done yet (FHIRPathTestEvaluationServices.resolveConstantType), when item is element");
|
||||
}
|
||||
|
@ -76,34 +76,34 @@ public class FHIRPathTests {
|
|||
}
|
||||
|
||||
@Override
|
||||
public FunctionDetails resolveFunction(String functionName) {
|
||||
public FunctionDetails resolveFunction(FHIRPathEngine engine, String functionName) {
|
||||
throw new NotImplementedException(
|
||||
"Not done yet (FHIRPathTestEvaluationServices.resolveFunction), when item is element (for " + functionName
|
||||
+ ")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeDetails checkFunction(Object appContext, String functionName, List<TypeDetails> parameters)
|
||||
public TypeDetails checkFunction(FHIRPathEngine engine, Object appContext, String functionName, TypeDetails focus, List<TypeDetails> parameters)
|
||||
throws PathEngineException {
|
||||
throw new NotImplementedException(
|
||||
"Not done yet (FHIRPathTestEvaluationServices.checkFunction), when item is element");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Base> executeFunction(Object appContext, List<Base> focus, String functionName,
|
||||
public List<Base> executeFunction(FHIRPathEngine engine, Object appContext, List<Base> focus, String functionName,
|
||||
List<List<Base>> parameters) {
|
||||
throw new NotImplementedException(
|
||||
"Not done yet (FHIRPathTestEvaluationServices.executeFunction), when item is element");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Base resolveReference(Object appContext, String url, Base base) throws FHIRException {
|
||||
public Base resolveReference(FHIRPathEngine engine, Object appContext, String url, Base base) throws FHIRException {
|
||||
throw new NotImplementedException(
|
||||
"Not done yet (FHIRPathTestEvaluationServices.resolveReference), when item is element");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean conformsToProfile(Object appContext, Base item, String url) throws FHIRException {
|
||||
public boolean conformsToProfile(FHIRPathEngine engine, Object appContext, Base item, String url) throws FHIRException {
|
||||
if (url.equals("http://hl7.org/fhir/StructureDefinition/Patient"))
|
||||
return true;
|
||||
if (url.equals("http://hl7.org/fhir/StructureDefinition/Person"))
|
||||
|
@ -113,7 +113,7 @@ public class FHIRPathTests {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ValueSet resolveValueSet(Object appContext, String url) {
|
||||
public ValueSet resolveValueSet(FHIRPathEngine engine, Object appContext, String url) {
|
||||
return TestingUtilities.context().fetchResource(ValueSet.class, url);
|
||||
}
|
||||
|
||||
|
@ -323,7 +323,7 @@ public class FHIRPathTests {
|
|||
final String DUMMY_CONSTANT_2 = "dummyConstant2";
|
||||
fp.setHostServices(new FHIRPathTestEvaluationServices() {
|
||||
@Override
|
||||
public List<Base> resolveConstant(Object appContext, String name, boolean beforeContext)
|
||||
public List<Base> resolveConstant(FHIRPathEngine engine, Object appContext, String name, boolean beforeContext, boolean explicitConstant)
|
||||
throws PathEngineException {
|
||||
|
||||
return Arrays.asList(new StringType(DUMMY_CONSTANT_1).noExtensions(),
|
||||
|
|
|
@ -300,13 +300,13 @@ public class SnapShotGenerationTests {
|
|||
|
||||
// FHIRPath methods
|
||||
@Override
|
||||
public List<Base> resolveConstant(Object appContext, String name, boolean beforeContext)
|
||||
public List<Base> resolveConstant(FHIRPathEngine engine, Object appContext, String name, boolean beforeContext, boolean explicitConstant)
|
||||
throws PathEngineException {
|
||||
throw new Error("Not implemented yet");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeDetails resolveConstantType(Object appContext, String name) throws PathEngineException {
|
||||
public TypeDetails resolveConstantType(FHIRPathEngine engine, Object appContext, String name, boolean explicitConstant) throws PathEngineException {
|
||||
throw new Error("Not implemented yet");
|
||||
}
|
||||
|
||||
|
@ -317,14 +317,14 @@ public class SnapShotGenerationTests {
|
|||
}
|
||||
|
||||
@Override
|
||||
public FunctionDetails resolveFunction(String functionName) {
|
||||
public FunctionDetails resolveFunction(FHIRPathEngine engine, String functionName) {
|
||||
if ("fixture".equals(functionName))
|
||||
return new FunctionDetails("Access a fixture defined in the testing context", 0, 1);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeDetails checkFunction(Object appContext, String functionName, List<TypeDetails> parameters)
|
||||
public TypeDetails checkFunction(FHIRPathEngine engine, Object appContext, String functionName, TypeDetails focus, List<TypeDetails> parameters)
|
||||
throws PathEngineException {
|
||||
if ("fixture".equals(functionName))
|
||||
return new TypeDetails(CollectionStatus.SINGLETON, TestingUtilities.context().getResourceNamesAsSet());
|
||||
|
@ -332,7 +332,7 @@ public class SnapShotGenerationTests {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<Base> executeFunction(Object appContext, List<Base> focus, String functionName,
|
||||
public List<Base> executeFunction(FHIRPathEngine engine, Object appContext, List<Base> focus, String functionName,
|
||||
List<List<Base>> parameters) {
|
||||
if ("fixture".equals(functionName)) {
|
||||
String id = fp.convertToString(parameters.get(0));
|
||||
|
@ -348,13 +348,13 @@ public class SnapShotGenerationTests {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Base resolveReference(Object appContext, String url, Base base) {
|
||||
public Base resolveReference(FHIRPathEngine engine, Object appContext, String url, Base base) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean conformsToProfile(Object appContext, Base item, String url) throws FHIRException {
|
||||
public boolean conformsToProfile(FHIRPathEngine engine, Object appContext, Base item, String url) throws FHIRException {
|
||||
IResourceValidator val = TestingUtilities.context().newValidator();
|
||||
List<ValidationMessage> valerrors = new ArrayList<ValidationMessage>();
|
||||
if (item instanceof Resource) {
|
||||
|
@ -381,7 +381,7 @@ public class SnapShotGenerationTests {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ValueSet resolveValueSet(Object appContext, String url) {
|
||||
public ValueSet resolveValueSet(FHIRPathEngine engine, Object appContext, String url) {
|
||||
throw new Error("Not implemented yet");
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ import java.util.Set;
|
|||
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.exceptions.PathEngineException;
|
||||
import org.hl7.fhir.r4b.utils.FHIRPathEngine;
|
||||
import org.hl7.fhir.r4b.comparison.CodeSystemComparer.CodeSystemComparison;
|
||||
import org.hl7.fhir.r4b.comparison.ProfileComparer.ProfileComparison;
|
||||
import org.hl7.fhir.r4b.comparison.ResourceComparer.PlaceHolderComparison;
|
||||
|
@ -231,7 +232,7 @@ public class ComparisonRenderer implements IEvaluationContext {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<Base> resolveConstant(Object appContext, String name, boolean beforeContext) throws PathEngineException {
|
||||
public List<Base> resolveConstant(FHIRPathEngine engine, Object appContext, String name, boolean beforeContext, boolean explicitConstant) throws PathEngineException {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Base> vars = (Map<String, Base>) appContext;
|
||||
List<Base> res = new ArrayList<>();
|
||||
|
@ -242,7 +243,7 @@ public class ComparisonRenderer implements IEvaluationContext {
|
|||
}
|
||||
|
||||
@Override
|
||||
public TypeDetails resolveConstantType(Object appContext, String name) throws PathEngineException {
|
||||
public TypeDetails resolveConstantType(FHIRPathEngine engine, Object appContext, String name, boolean explicitConstant) throws PathEngineException {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Base> vars = (Map<String, Base>) appContext;
|
||||
Base b = vars.get(name);
|
||||
|
@ -255,34 +256,34 @@ public class ComparisonRenderer implements IEvaluationContext {
|
|||
}
|
||||
|
||||
@Override
|
||||
public FunctionDetails resolveFunction(String functionName) {
|
||||
public FunctionDetails resolveFunction(FHIRPathEngine engine, String functionName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeDetails checkFunction(Object appContext, String functionName, List<TypeDetails> parameters)
|
||||
public TypeDetails checkFunction(FHIRPathEngine engine, Object appContext, String functionName, TypeDetails focus, List<TypeDetails> parameters)
|
||||
throws PathEngineException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Base> executeFunction(Object appContext, List<Base> focus, String functionName,
|
||||
public List<Base> executeFunction(FHIRPathEngine engine, Object appContext, List<Base> focus, String functionName,
|
||||
List<List<Base>> parameters) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Base resolveReference(Object appContext, String url, Base refContext) throws FHIRException {
|
||||
public Base resolveReference(FHIRPathEngine engine, Object appContext, String url, Base refContext) throws FHIRException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean conformsToProfile(Object appContext, Base item, String url) throws FHIRException {
|
||||
public boolean conformsToProfile(FHIRPathEngine engine, Object appContext, Base item, String url) throws FHIRException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueSet resolveValueSet(Object appContext, String url) {
|
||||
public ValueSet resolveValueSet(FHIRPathEngine engine, Object appContext, String url) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -152,9 +152,9 @@ public class FHIRPathEngine {
|
|||
* @return the value of the reference (or null, if it's not valid, though can
|
||||
* throw an exception if desired)
|
||||
*/
|
||||
public List<Base> resolveConstant(Object appContext, String name, boolean beforeContext) throws PathEngineException;
|
||||
public List<Base> resolveConstant(FHIRPathEngine engine, Object appContext, String name, boolean beforeContext, boolean explicitConstant) throws PathEngineException;
|
||||
|
||||
public TypeDetails resolveConstantType(Object appContext, String name) throws PathEngineException;
|
||||
public TypeDetails resolveConstantType(FHIRPathEngine engine, Object appContext, String name, boolean explicitConstant) throws PathEngineException;
|
||||
|
||||
/**
|
||||
* when the .log() function is called
|
||||
|
@ -171,7 +171,7 @@ public class FHIRPathEngine {
|
|||
* @param functionName
|
||||
* @return null if the function is not known
|
||||
*/
|
||||
public FunctionDetails resolveFunction(String functionName);
|
||||
public FunctionDetails resolveFunction(FHIRPathEngine engine, String functionName);
|
||||
|
||||
/**
|
||||
* Check the function parameters, and throw an error if they are incorrect, or
|
||||
|
@ -181,7 +181,7 @@ public class FHIRPathEngine {
|
|||
* @param parameters
|
||||
* @return
|
||||
*/
|
||||
public TypeDetails checkFunction(Object appContext, String functionName, List<TypeDetails> parameters)
|
||||
public TypeDetails checkFunction(FHIRPathEngine engine, Object appContext, String functionName, TypeDetails focus, List<TypeDetails> parameters)
|
||||
throws PathEngineException;
|
||||
|
||||
/**
|
||||
|
@ -190,7 +190,7 @@ public class FHIRPathEngine {
|
|||
* @param parameters
|
||||
* @return
|
||||
*/
|
||||
public List<Base> executeFunction(Object appContext, List<Base> focus, String functionName,
|
||||
public List<Base> executeFunction(FHIRPathEngine engine, Object appContext, List<Base> focus, String functionName,
|
||||
List<List<Base>> parameters);
|
||||
|
||||
/**
|
||||
|
@ -202,14 +202,14 @@ public class FHIRPathEngine {
|
|||
* @return
|
||||
* @throws FHIRException
|
||||
*/
|
||||
public Base resolveReference(Object appContext, String url, Base refContext) throws FHIRException;
|
||||
public Base resolveReference(FHIRPathEngine engine, Object appContext, String url, Base refContext) throws FHIRException;
|
||||
|
||||
public boolean conformsToProfile(Object appContext, Base item, String url) throws FHIRException;
|
||||
public boolean conformsToProfile(FHIRPathEngine engine, Object appContext, Base item, String url) throws FHIRException;
|
||||
|
||||
/*
|
||||
* return the value set referenced by the url, which has been used in memberOf()
|
||||
*/
|
||||
public ValueSet resolveValueSet(Object appContext, String url);
|
||||
public ValueSet resolveValueSet(FHIRPathEngine engine, Object appContext, String url);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1034,7 +1034,7 @@ public class FHIRPathEngine {
|
|||
FunctionDetails details = null;
|
||||
if (f == null) {
|
||||
if (hostServices != null) {
|
||||
details = hostServices.resolveFunction(result.getName());
|
||||
details = hostServices.resolveFunction(this, result.getName());
|
||||
}
|
||||
if (details == null) {
|
||||
throw lexer.error("The name " + result.getName() + " is not a valid function name");
|
||||
|
@ -1474,7 +1474,7 @@ public class FHIRPathEngine {
|
|||
work.addAll(work2);
|
||||
break;
|
||||
case Constant:
|
||||
work.addAll(resolveConstant(context, exp.getConstant(), false, exp));
|
||||
work.addAll(resolveConstant(context, exp.getConstant(), false, exp, true));
|
||||
break;
|
||||
case Group:
|
||||
work2 = execute(context, focus, exp.getGroup(), atEntry);
|
||||
|
@ -1564,7 +1564,7 @@ public class FHIRPathEngine {
|
|||
} else if (atEntry && exp.getName().equals("$index")) {
|
||||
result.addType(TypeDetails.FP_Integer);
|
||||
} else if (atEntry && focus == null) {
|
||||
result.update(executeContextType(context, exp.getName(), exp));
|
||||
result.update(executeContextType(context, exp.getName(), exp, false));
|
||||
} else {
|
||||
for (String s : focus.getTypes()) {
|
||||
result.update(executeType(s, exp, atEntry));
|
||||
|
@ -1583,7 +1583,7 @@ public class FHIRPathEngine {
|
|||
result.addType(TypeDetails.FP_Quantity);
|
||||
break;
|
||||
case Constant:
|
||||
result.update(resolveConstantType(context, exp.getConstant(), exp));
|
||||
result.update(resolveConstantType(context, exp.getConstant(), exp, true));
|
||||
break;
|
||||
case Group:
|
||||
result.update(executeType(context, focus, exp.getGroup(), atEntry));
|
||||
|
@ -1614,7 +1614,7 @@ public class FHIRPathEngine {
|
|||
}
|
||||
|
||||
private List<Base> resolveConstant(ExecutionContext context, Base constant, boolean beforeContext,
|
||||
ExpressionNode expr) throws PathEngineException {
|
||||
ExpressionNode expr, boolean explicitConstant) throws PathEngineException {
|
||||
if (constant == null) {
|
||||
return new ArrayList<Base>();
|
||||
}
|
||||
|
@ -1623,7 +1623,7 @@ public class FHIRPathEngine {
|
|||
}
|
||||
FHIRConstant c = (FHIRConstant) constant;
|
||||
if (c.getValue().startsWith("%")) {
|
||||
return resolveConstant(context, c.getValue(), beforeContext, expr);
|
||||
return resolveConstant(context, c.getValue(), beforeContext, expr, explicitConstant);
|
||||
} else if (c.getValue().startsWith("@")) {
|
||||
return new ArrayList<Base>(Arrays.asList(processDateConstant(context.appInfo, c.getValue().substring(1), expr)));
|
||||
} else {
|
||||
|
@ -1693,7 +1693,7 @@ public class FHIRPathEngine {
|
|||
}
|
||||
}
|
||||
|
||||
private List<Base> resolveConstant(ExecutionContext context, String s, boolean beforeContext, ExpressionNode expr)
|
||||
private List<Base> resolveConstant(ExecutionContext context, String s, boolean beforeContext, ExpressionNode expr, boolean explicitConstant)
|
||||
throws PathEngineException {
|
||||
if (s.equals("%sct")) {
|
||||
return new ArrayList<Base>(Arrays.asList(new StringType("http://snomed.info/sct").noExtensions()));
|
||||
|
@ -1727,7 +1727,7 @@ public class FHIRPathEngine {
|
|||
} else if (hostServices == null) {
|
||||
throw makeException(expr, I18nConstants.FHIRPATH_UNKNOWN_CONSTANT, s);
|
||||
} else {
|
||||
return hostServices.resolveConstant(context.appInfo, s.substring(1), beforeContext);
|
||||
return hostServices.resolveConstant(this, context.appInfo, s.substring(1), beforeContext, explicitConstant);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2550,7 +2550,7 @@ public class FHIRPathEngine {
|
|||
throws FHIRException {
|
||||
boolean ans = false;
|
||||
String url = right.get(0).primitiveValue();
|
||||
ValueSet vs = hostServices != null ? hostServices.resolveValueSet(context.appInfo, url)
|
||||
ValueSet vs = hostServices != null ? hostServices.resolveValueSet(this, context.appInfo, url)
|
||||
: worker.fetchResource(ValueSet.class, url);
|
||||
if (vs != null) {
|
||||
for (Base l : left) {
|
||||
|
@ -3081,7 +3081,7 @@ public class FHIRPathEngine {
|
|||
return result;
|
||||
}
|
||||
|
||||
private TypeDetails resolveConstantType(ExecutionTypeContext context, Base constant, ExpressionNode expr)
|
||||
private TypeDetails resolveConstantType(ExecutionTypeContext context, Base constant, ExpressionNode expr, boolean explicitConstant)
|
||||
throws PathEngineException {
|
||||
if (constant instanceof BooleanType) {
|
||||
return new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_Boolean);
|
||||
|
@ -3092,7 +3092,7 @@ public class FHIRPathEngine {
|
|||
} else if (constant instanceof Quantity) {
|
||||
return new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_Quantity);
|
||||
} else if (constant instanceof FHIRConstant) {
|
||||
return resolveConstantType(context, ((FHIRConstant) constant).getValue(), expr);
|
||||
return resolveConstantType(context, ((FHIRConstant) constant).getValue(), expr, explicitConstant);
|
||||
} else if (constant == null) {
|
||||
return new TypeDetails(CollectionStatus.SINGLETON);
|
||||
} else {
|
||||
|
@ -3100,7 +3100,7 @@ public class FHIRPathEngine {
|
|||
}
|
||||
}
|
||||
|
||||
private TypeDetails resolveConstantType(ExecutionTypeContext context, String s, ExpressionNode expr)
|
||||
private TypeDetails resolveConstantType(ExecutionTypeContext context, String s, ExpressionNode expr, boolean explicitConstant)
|
||||
throws PathEngineException {
|
||||
if (s.startsWith("@")) {
|
||||
if (s.startsWith("@T")) {
|
||||
|
@ -3139,7 +3139,7 @@ public class FHIRPathEngine {
|
|||
} else if (hostServices == null) {
|
||||
throw makeException(expr, I18nConstants.FHIRPATH_UNKNOWN_CONSTANT, s);
|
||||
} else {
|
||||
return hostServices.resolveConstantType(context.appInfo, s);
|
||||
return hostServices.resolveConstantType(this, context.appInfo, s, explicitConstant);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3148,7 +3148,7 @@ public class FHIRPathEngine {
|
|||
List<Base> result = new ArrayList<Base>();
|
||||
if (atEntry && context.appInfo != null && hostServices != null) {
|
||||
// we'll see if the name matches a constant known by the context.
|
||||
List<Base> temp = hostServices.resolveConstant(context.appInfo, exp.getName(), true);
|
||||
List<Base> temp = hostServices.resolveConstant(this, context.appInfo, exp.getName(), true, false);
|
||||
if (!temp.isEmpty()) {
|
||||
result.addAll(temp);
|
||||
return result;
|
||||
|
@ -3179,7 +3179,7 @@ public class FHIRPathEngine {
|
|||
// constant known by the context.
|
||||
// (if the name does match, and the user wants to get the constant value,
|
||||
// they'll have to try harder...
|
||||
result.addAll(hostServices.resolveConstant(context.appInfo, exp.getName(), false));
|
||||
result.addAll(hostServices.resolveConstant(this, context.appInfo, exp.getName(), false, false));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -3188,12 +3188,12 @@ public class FHIRPathEngine {
|
|||
return null;
|
||||
}
|
||||
|
||||
private TypeDetails executeContextType(ExecutionTypeContext context, String name, ExpressionNode expr)
|
||||
private TypeDetails executeContextType(ExecutionTypeContext context, String name, ExpressionNode expr, boolean explicitConstant)
|
||||
throws PathEngineException, DefinitionException {
|
||||
if (hostServices == null) {
|
||||
throw makeException(expr, I18nConstants.FHIRPATH_HO_HOST_SERVICES, "Context Reference");
|
||||
}
|
||||
return hostServices.resolveConstantType(context.appInfo, name);
|
||||
return hostServices.resolveConstantType(this, context.appInfo, name, explicitConstant);
|
||||
}
|
||||
|
||||
private TypeDetails executeType(String type, ExpressionNode exp, boolean atEntry)
|
||||
|
@ -3609,7 +3609,7 @@ public class FHIRPathEngine {
|
|||
}
|
||||
|
||||
case Custom: {
|
||||
return hostServices.checkFunction(context.appInfo, exp.getName(), paramTypes);
|
||||
return hostServices.checkFunction(this, context.appInfo, exp.getName(), focus, paramTypes);
|
||||
}
|
||||
default:
|
||||
break;
|
||||
|
@ -3934,7 +3934,7 @@ public class FHIRPathEngine {
|
|||
for (ExpressionNode p : exp.getParameters()) {
|
||||
params.add(execute(context, focus, p, true));
|
||||
}
|
||||
return hostServices.executeFunction(context.appInfo, focus, exp.getName(), params);
|
||||
return hostServices.executeFunction(this, context.appInfo, focus, exp.getName(), params);
|
||||
}
|
||||
default:
|
||||
throw new Error("not Implemented yet");
|
||||
|
@ -4607,7 +4607,7 @@ public class FHIRPathEngine {
|
|||
}
|
||||
|
||||
String url = nl.get(0).primitiveValue();
|
||||
ValueSet vs = hostServices != null ? hostServices.resolveValueSet(context.appInfo, url)
|
||||
ValueSet vs = hostServices != null ? hostServices.resolveValueSet(this, context.appInfo, url)
|
||||
: worker.fetchResource(ValueSet.class, url);
|
||||
if (vs == null) {
|
||||
return new ArrayList<Base>();
|
||||
|
@ -5213,7 +5213,7 @@ public class FHIRPathEngine {
|
|||
}
|
||||
} else if (hostServices != null) {
|
||||
try {
|
||||
res = hostServices.resolveReference(context.appInfo, s, refContext);
|
||||
res = hostServices.resolveReference(this, context.appInfo, s, refContext);
|
||||
} catch (Exception e) {
|
||||
res = null;
|
||||
}
|
||||
|
@ -5743,7 +5743,7 @@ public class FHIRPathEngine {
|
|||
result.add(new BooleanType(false).noExtensions());
|
||||
} else {
|
||||
String url = convertToString(execute(context, focus, expr.getParameters().get(0), true));
|
||||
result.add(new BooleanType(hostServices.conformsToProfile(context.appInfo, focus.get(0), url)).noExtensions());
|
||||
result.add(new BooleanType(hostServices.conformsToProfile(this, context.appInfo, focus.get(0), url)).noExtensions());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -738,7 +738,7 @@ public class LiquidEngine implements IEvaluationContext {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<Base> resolveConstant(Object appContext, String name, boolean beforeContext) throws PathEngineException {
|
||||
public List<Base> resolveConstant(FHIRPathEngine engine, Object appContext, String name, boolean beforeContext, boolean explicitConstant) throws PathEngineException {
|
||||
LiquidEngineContext ctxt = (LiquidEngineContext) appContext;
|
||||
if (ctxt.loopVars.containsKey(name))
|
||||
return new ArrayList<Base>(Arrays.asList(ctxt.loopVars.get(name)));
|
||||
|
@ -746,15 +746,15 @@ public class LiquidEngine implements IEvaluationContext {
|
|||
return new ArrayList<Base>(Arrays.asList(ctxt.globalVars.get(name)));
|
||||
if (externalHostServices == null)
|
||||
return new ArrayList<Base>();
|
||||
return externalHostServices.resolveConstant(ctxt.externalContext, name, beforeContext);
|
||||
return externalHostServices.resolveConstant(engine, ctxt.externalContext, name, beforeContext, explicitConstant);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeDetails resolveConstantType(Object appContext, String name) throws PathEngineException {
|
||||
public TypeDetails resolveConstantType(FHIRPathEngine engine, Object appContext, String name, boolean explicitConstant) throws PathEngineException {
|
||||
if (externalHostServices == null)
|
||||
return null;
|
||||
LiquidEngineContext ctxt = (LiquidEngineContext) appContext;
|
||||
return externalHostServices.resolveConstantType(ctxt.externalContext, name);
|
||||
return externalHostServices.resolveConstantType(engine, ctxt.externalContext, name, explicitConstant);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -765,49 +765,49 @@ public class LiquidEngine implements IEvaluationContext {
|
|||
}
|
||||
|
||||
@Override
|
||||
public FunctionDetails resolveFunction(String functionName) {
|
||||
public FunctionDetails resolveFunction(FHIRPathEngine engine, String functionName) {
|
||||
if (externalHostServices == null)
|
||||
return null;
|
||||
return externalHostServices.resolveFunction(functionName);
|
||||
return externalHostServices.resolveFunction(engine, functionName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeDetails checkFunction(Object appContext, String functionName, List<TypeDetails> parameters) throws PathEngineException {
|
||||
public TypeDetails checkFunction(FHIRPathEngine engine, Object appContext, String functionName, TypeDetails focus, List<TypeDetails> parameters) throws PathEngineException {
|
||||
if (externalHostServices == null)
|
||||
return null;
|
||||
LiquidEngineContext ctxt = (LiquidEngineContext) appContext;
|
||||
return externalHostServices.checkFunction(ctxt.externalContext, functionName, parameters);
|
||||
return externalHostServices.checkFunction(engine, ctxt.externalContext, functionName, focus, parameters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Base> executeFunction(Object appContext, List<Base> focus, String functionName, List<List<Base>> parameters) {
|
||||
public List<Base> executeFunction(FHIRPathEngine engine, Object appContext, List<Base> focus, String functionName, List<List<Base>> parameters) {
|
||||
if (externalHostServices == null)
|
||||
return null;
|
||||
LiquidEngineContext ctxt = (LiquidEngineContext) appContext;
|
||||
return externalHostServices.executeFunction(ctxt.externalContext, focus, functionName, parameters);
|
||||
return externalHostServices.executeFunction(engine, ctxt.externalContext, focus, functionName, parameters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Base resolveReference(Object appContext, String url, Base refContext) throws FHIRException {
|
||||
public Base resolveReference(FHIRPathEngine engine, Object appContext, String url, Base refContext) throws FHIRException {
|
||||
if (externalHostServices == null)
|
||||
return null;
|
||||
LiquidEngineContext ctxt = (LiquidEngineContext) appContext;
|
||||
return resolveReference(ctxt.externalContext, url, refContext);
|
||||
return resolveReference(engine, ctxt.externalContext, url, refContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean conformsToProfile(Object appContext, Base item, String url) throws FHIRException {
|
||||
public boolean conformsToProfile(FHIRPathEngine engine, Object appContext, Base item, String url) throws FHIRException {
|
||||
if (externalHostServices == null)
|
||||
return false;
|
||||
LiquidEngineContext ctxt = (LiquidEngineContext) appContext;
|
||||
return conformsToProfile(ctxt.externalContext, item, url);
|
||||
return conformsToProfile(engine, ctxt.externalContext, item, url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueSet resolveValueSet(Object appContext, String url) {
|
||||
public ValueSet resolveValueSet(FHIRPathEngine engine, Object appContext, String url) {
|
||||
LiquidEngineContext ctxt = (LiquidEngineContext) appContext;
|
||||
if (externalHostServices != null)
|
||||
return externalHostServices.resolveValueSet(ctxt.externalContext, url);
|
||||
return externalHostServices.resolveValueSet(engine, ctxt.externalContext, url);
|
||||
else
|
||||
return engine.getWorker().fetchResource(ValueSet.class, url);
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ public class FHIRPathHostServices implements FHIRPathEngine.IEvaluationContext {
|
|||
this.structureMapUtilities = structureMapUtilities;
|
||||
}
|
||||
|
||||
public List<Base> resolveConstant(Object appContext, String name, boolean beforeContext) throws PathEngineException {
|
||||
public List<Base> resolveConstant(FHIRPathEngine engine, Object appContext, String name, boolean beforeContext, boolean explicitConstant) throws PathEngineException {
|
||||
Variables vars = (Variables) appContext;
|
||||
Base res = vars.get(VariableMode.INPUT, name);
|
||||
if (res == null)
|
||||
|
@ -36,7 +36,7 @@ public class FHIRPathHostServices implements FHIRPathEngine.IEvaluationContext {
|
|||
}
|
||||
|
||||
@Override
|
||||
public TypeDetails resolveConstantType(Object appContext, String name) throws PathEngineException {
|
||||
public TypeDetails resolveConstantType(FHIRPathEngine engine, Object appContext, String name, boolean explicitConstant) throws PathEngineException {
|
||||
if (!(appContext instanceof VariablesForProfiling))
|
||||
throw new Error(
|
||||
"Internal Logic Error (wrong type '" + appContext.getClass().getName() + "' in resolveConstantType)");
|
||||
|
@ -53,24 +53,24 @@ public class FHIRPathHostServices implements FHIRPathEngine.IEvaluationContext {
|
|||
}
|
||||
|
||||
@Override
|
||||
public FunctionDetails resolveFunction(String functionName) {
|
||||
public FunctionDetails resolveFunction(FHIRPathEngine engine, String functionName) {
|
||||
return null; // throw new Error("Not Implemented Yet");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeDetails checkFunction(Object appContext, String functionName, List<TypeDetails> parameters)
|
||||
public TypeDetails checkFunction(FHIRPathEngine engine, Object appContext, String functionName, TypeDetails focus, List<TypeDetails> parameters)
|
||||
throws PathEngineException {
|
||||
throw new Error("Not Implemented Yet");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Base> executeFunction(Object appContext, List<Base> focus, String functionName,
|
||||
public List<Base> executeFunction(FHIRPathEngine engine, Object appContext, List<Base> focus, String functionName,
|
||||
List<List<Base>> parameters) {
|
||||
throw new Error("Not Implemented Yet");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Base resolveReference(Object appContext, String url, Base refContext) throws FHIRException {
|
||||
public Base resolveReference(FHIRPathEngine engine, Object appContext, String url, Base refContext) throws FHIRException {
|
||||
if (structureMapUtilities.getServices() == null)
|
||||
return null;
|
||||
return structureMapUtilities.getServices().resolveReference(appContext, url);
|
||||
|
@ -84,7 +84,7 @@ public class FHIRPathHostServices implements FHIRPathEngine.IEvaluationContext {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean conformsToProfile(Object appContext, Base item, String url) throws FHIRException {
|
||||
public boolean conformsToProfile(FHIRPathEngine engine, Object appContext, Base item, String url) throws FHIRException {
|
||||
IResourceValidator val = structureMapUtilities.getWorker().newValidator();
|
||||
List<ValidationMessage> valerrors = new ArrayList<ValidationMessage>();
|
||||
if (item instanceof Resource) {
|
||||
|
@ -100,7 +100,7 @@ public class FHIRPathHostServices implements FHIRPathEngine.IEvaluationContext {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ValueSet resolveValueSet(Object appContext, String url) {
|
||||
public ValueSet resolveValueSet(FHIRPathEngine engine, Object appContext, String url) {
|
||||
throw new Error("Not Implemented Yet");
|
||||
}
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ public class StructureMapUtilities {
|
|||
|
||||
private class FHIRPathHostServices implements IEvaluationContext {
|
||||
|
||||
public List<Base> resolveConstant(Object appContext, String name, boolean beforeContext)
|
||||
public List<Base> resolveConstant(FHIRPathEngine engine, Object appContext, String name, boolean beforeContext, boolean explicitConstant)
|
||||
throws PathEngineException {
|
||||
Variables vars = (Variables) appContext;
|
||||
List<Base> list = new ArrayList<Base>();
|
||||
|
@ -126,7 +126,7 @@ public class StructureMapUtilities {
|
|||
}
|
||||
|
||||
@Override
|
||||
public TypeDetails resolveConstantType(Object appContext, String name) throws PathEngineException {
|
||||
public TypeDetails resolveConstantType(FHIRPathEngine engine, Object appContext, String name, boolean explicitConstant) throws PathEngineException {
|
||||
if (!(appContext instanceof VariablesForProfiling))
|
||||
throw new Error(
|
||||
"Internal Logic Error (wrong type '" + appContext.getClass().getName() + "' in resolveConstantType)");
|
||||
|
@ -143,31 +143,31 @@ public class StructureMapUtilities {
|
|||
}
|
||||
|
||||
@Override
|
||||
public FunctionDetails resolveFunction(String functionName) {
|
||||
public FunctionDetails resolveFunction(FHIRPathEngine engine, String functionName) {
|
||||
return null; // throw new Error("Not Implemented Yet");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeDetails checkFunction(Object appContext, String functionName, List<TypeDetails> parameters)
|
||||
public TypeDetails checkFunction(FHIRPathEngine engine, Object appContext, String functionName, TypeDetails focus, List<TypeDetails> parameters)
|
||||
throws PathEngineException {
|
||||
throw new Error("Not Implemented Yet");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Base> executeFunction(Object appContext, List<Base> focus, String functionName,
|
||||
public List<Base> executeFunction(FHIRPathEngine engine, Object appContext, List<Base> focus, String functionName,
|
||||
List<List<Base>> parameters) {
|
||||
throw new Error("Not Implemented Yet");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Base resolveReference(Object appContext, String url, Base base) throws FHIRException {
|
||||
public Base resolveReference(FHIRPathEngine engine, Object appContext, String url, Base base) throws FHIRException {
|
||||
if (services == null)
|
||||
return null;
|
||||
return services.resolveReference(appContext, url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean conformsToProfile(Object appContext, Base item, String url) throws FHIRException {
|
||||
public boolean conformsToProfile(FHIRPathEngine engine, Object appContext, Base item, String url) throws FHIRException {
|
||||
IResourceValidator val = worker.newValidator();
|
||||
List<ValidationMessage> valerrors = new ArrayList<ValidationMessage>();
|
||||
if (item instanceof Resource) {
|
||||
|
@ -181,7 +181,7 @@ public class StructureMapUtilities {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ValueSet resolveValueSet(Object appContext, String url) {
|
||||
public ValueSet resolveValueSet(FHIRPathEngine engine, Object appContext, String url) {
|
||||
throw new Error("Not Implemented Yet");
|
||||
}
|
||||
|
||||
|
|
|
@ -44,14 +44,14 @@ public class FHIRPathTests {
|
|||
public class FHIRPathTestEvaluationServices implements IEvaluationContext {
|
||||
|
||||
@Override
|
||||
public List<Base> resolveConstant(Object appContext, String name, boolean beforeContext)
|
||||
public List<Base> resolveConstant(FHIRPathEngine engine, Object appContext, String name, boolean beforeContext, boolean explicitConstant)
|
||||
throws PathEngineException {
|
||||
throw new NotImplementedException(
|
||||
"Not done yet (FHIRPathTestEvaluationServices.resolveConstant), when item is element");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeDetails resolveConstantType(Object appContext, String name) throws PathEngineException {
|
||||
public TypeDetails resolveConstantType(FHIRPathEngine engine, Object appContext, String name, boolean explicitConstant) throws PathEngineException {
|
||||
throw new NotImplementedException(
|
||||
"Not done yet (FHIRPathTestEvaluationServices.resolveConstantType), when item is element");
|
||||
}
|
||||
|
@ -62,34 +62,34 @@ public class FHIRPathTests {
|
|||
}
|
||||
|
||||
@Override
|
||||
public FunctionDetails resolveFunction(String functionName) {
|
||||
public FunctionDetails resolveFunction(FHIRPathEngine engine, String functionName) {
|
||||
throw new NotImplementedException(
|
||||
"Not done yet (FHIRPathTestEvaluationServices.resolveFunction), when item is element (for " + functionName
|
||||
+ ")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeDetails checkFunction(Object appContext, String functionName, List<TypeDetails> parameters)
|
||||
public TypeDetails checkFunction(FHIRPathEngine engine, Object appContext, String functionName, TypeDetails focus, List<TypeDetails> parameters)
|
||||
throws PathEngineException {
|
||||
throw new NotImplementedException(
|
||||
"Not done yet (FHIRPathTestEvaluationServices.checkFunction), when item is element");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Base> executeFunction(Object appContext, List<Base> focus, String functionName,
|
||||
public List<Base> executeFunction(FHIRPathEngine engine, Object appContext, List<Base> focus, String functionName,
|
||||
List<List<Base>> parameters) {
|
||||
throw new NotImplementedException(
|
||||
"Not done yet (FHIRPathTestEvaluationServices.executeFunction), when item is element");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Base resolveReference(Object appContext, String url, Base refContext) throws FHIRException {
|
||||
public Base resolveReference(FHIRPathEngine engine, Object appContext, String url, Base refContext) throws FHIRException {
|
||||
throw new NotImplementedException(
|
||||
"Not done yet (FHIRPathTestEvaluationServices.resolveReference), when item is element");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean conformsToProfile(Object appContext, Base item, String url) throws FHIRException {
|
||||
public boolean conformsToProfile(FHIRPathEngine engine, Object appContext, Base item, String url) throws FHIRException {
|
||||
if (url.equals("http://hl7.org/fhir/StructureDefinition/Patient"))
|
||||
return true;
|
||||
if (url.equals("http://hl7.org/fhir/StructureDefinition/Person"))
|
||||
|
@ -99,7 +99,7 @@ public class FHIRPathTests {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ValueSet resolveValueSet(Object appContext, String url) {
|
||||
public ValueSet resolveValueSet(FHIRPathEngine engine, Object appContext, String url) {
|
||||
return TestingUtilities.context().fetchResource(ValueSet.class, url);
|
||||
}
|
||||
|
||||
|
@ -310,7 +310,7 @@ public class FHIRPathTests {
|
|||
final String DUMMY_CONSTANT_2 = "dummyConstant2";
|
||||
fp.setHostServices(new FHIRPathTestEvaluationServices() {
|
||||
@Override
|
||||
public List<Base> resolveConstant(Object appContext, String name, boolean beforeContext)
|
||||
public List<Base> resolveConstant(FHIRPathEngine engine, Object appContext, String name, boolean beforeContext, boolean explicitConstant)
|
||||
throws PathEngineException {
|
||||
|
||||
return Arrays.asList(new StringType(DUMMY_CONSTANT_1).noExtensions(),
|
||||
|
|
|
@ -368,13 +368,13 @@ public class SnapShotGenerationTests {
|
|||
|
||||
// FHIRPath methods
|
||||
@Override
|
||||
public List<Base> resolveConstant(Object appContext, String name, boolean beforeContext)
|
||||
public List<Base> resolveConstant(FHIRPathEngine engine, Object appContext, String name, boolean beforeContext, boolean explicitConstant)
|
||||
throws PathEngineException {
|
||||
throw new Error("Not implemented yet");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeDetails resolveConstantType(Object appContext, String name) throws PathEngineException {
|
||||
public TypeDetails resolveConstantType(FHIRPathEngine engine, Object appContext, String name, boolean explicitConstant) throws PathEngineException {
|
||||
throw new Error("Not implemented yet");
|
||||
}
|
||||
|
||||
|
@ -385,14 +385,14 @@ public class SnapShotGenerationTests {
|
|||
}
|
||||
|
||||
@Override
|
||||
public FunctionDetails resolveFunction(String functionName) {
|
||||
public FunctionDetails resolveFunction(FHIRPathEngine engine, String functionName) {
|
||||
if ("fixture".equals(functionName))
|
||||
return new FunctionDetails("Access a fixture defined in the testing context", 0, 1);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeDetails checkFunction(Object appContext, String functionName, List<TypeDetails> parameters)
|
||||
public TypeDetails checkFunction(FHIRPathEngine engine, Object appContext, String functionName, TypeDetails focus, List<TypeDetails> parameters)
|
||||
throws PathEngineException {
|
||||
if ("fixture".equals(functionName))
|
||||
return new TypeDetails(CollectionStatus.SINGLETON, TestingUtilities.context().getResourceNamesAsSet());
|
||||
|
@ -400,7 +400,7 @@ public class SnapShotGenerationTests {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<Base> executeFunction(Object appContext, List<Base> focus, String functionName,
|
||||
public List<Base> executeFunction(FHIRPathEngine engine, Object appContext, List<Base> focus, String functionName,
|
||||
List<List<Base>> parameters) {
|
||||
if ("fixture".equals(functionName)) {
|
||||
String id = fp.convertToString(parameters.get(0));
|
||||
|
@ -416,13 +416,13 @@ public class SnapShotGenerationTests {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Base resolveReference(Object appContext, String url, Base refContext) {
|
||||
public Base resolveReference(FHIRPathEngine engine, Object appContext, String url, Base refContext) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean conformsToProfile(Object appContext, Base item, String url) throws FHIRException {
|
||||
public boolean conformsToProfile(FHIRPathEngine engine, Object appContext, Base item, String url) throws FHIRException {
|
||||
IResourceValidator val = TestingUtilities.context().newValidator();
|
||||
List<ValidationMessage> valerrors = new ArrayList<ValidationMessage>();
|
||||
if (item instanceof Resource) {
|
||||
|
@ -451,7 +451,7 @@ public class SnapShotGenerationTests {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ValueSet resolveValueSet(Object appContext, String url) {
|
||||
public ValueSet resolveValueSet(FHIRPathEngine engine, Object appContext, String url) {
|
||||
throw new Error("Not implemented yet");
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ import java.util.Set;
|
|||
|
||||
import org.hl7.fhir.exceptions.FHIRException;
|
||||
import org.hl7.fhir.exceptions.PathEngineException;
|
||||
import org.hl7.fhir.r5.utils.FHIRPathEngine;
|
||||
import org.hl7.fhir.r5.comparison.CapabilityStatementComparer.CapabilityStatementComparison;
|
||||
import org.hl7.fhir.r5.comparison.CodeSystemComparer.CodeSystemComparison;
|
||||
import org.hl7.fhir.r5.comparison.ResourceComparer.PlaceHolderComparison;
|
||||
|
@ -255,7 +256,7 @@ public class ComparisonRenderer implements IEvaluationContext {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<Base> resolveConstant(Object appContext, String name, boolean beforeContext) throws PathEngineException {
|
||||
public List<Base> resolveConstant(FHIRPathEngine engine, Object appContext, String name, boolean beforeContext, boolean explicitConstant) throws PathEngineException {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Base> vars = (Map<String, Base>) appContext;
|
||||
List<Base> res = new ArrayList<>();
|
||||
|
@ -266,7 +267,7 @@ public class ComparisonRenderer implements IEvaluationContext {
|
|||
}
|
||||
|
||||
@Override
|
||||
public TypeDetails resolveConstantType(Object appContext, String name) throws PathEngineException {
|
||||
public TypeDetails resolveConstantType(FHIRPathEngine engine, Object appContext, String name, boolean explicitConstant) throws PathEngineException {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Base> vars = (Map<String, Base>) appContext;
|
||||
Base b = vars.get(name);
|
||||
|
@ -279,32 +280,32 @@ public class ComparisonRenderer implements IEvaluationContext {
|
|||
}
|
||||
|
||||
@Override
|
||||
public FunctionDetails resolveFunction(String functionName) {
|
||||
public FunctionDetails resolveFunction(FHIRPathEngine engine, String functionName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeDetails checkFunction(Object appContext, String functionName, List<TypeDetails> parameters) throws PathEngineException {
|
||||
public TypeDetails checkFunction(FHIRPathEngine engine, Object appContext, String functionName, TypeDetails focus, List<TypeDetails> parameters) throws PathEngineException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Base> executeFunction(Object appContext, List<Base> focus, String functionName, List<List<Base>> parameters) {
|
||||
public List<Base> executeFunction(FHIRPathEngine engine, Object appContext, List<Base> focus, String functionName, List<List<Base>> parameters) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Base resolveReference(Object appContext, String url, Base refContext) throws FHIRException {
|
||||
public Base resolveReference(FHIRPathEngine engine, Object appContext, String url, Base refContext) throws FHIRException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean conformsToProfile(Object appContext, Base item, String url) throws FHIRException {
|
||||
public boolean conformsToProfile(FHIRPathEngine engine, Object appContext, Base item, String url) throws FHIRException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueSet resolveValueSet(Object appContext, String url) {
|
||||
public ValueSet resolveValueSet(FHIRPathEngine engine, Object appContext, String url) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -153,8 +153,8 @@ public class FHIRPathEngine {
|
|||
* @param beforeContext - whether this is being called before the name is resolved locally, or not
|
||||
* @return the value of the reference (or null, if it's not valid, though can throw an exception if desired)
|
||||
*/
|
||||
public List<Base> resolveConstant(Object appContext, String name, boolean beforeContext) throws PathEngineException;
|
||||
public TypeDetails resolveConstantType(Object appContext, String name) throws PathEngineException;
|
||||
public List<Base> resolveConstant(FHIRPathEngine engine, Object appContext, String name, boolean beforeContext, boolean explicitConstant) throws PathEngineException;
|
||||
public TypeDetails resolveConstantType(FHIRPathEngine engine, Object appContext, String name, boolean explicitConstant) throws PathEngineException;
|
||||
|
||||
/**
|
||||
* when the .log() function is called
|
||||
|
@ -171,7 +171,7 @@ public class FHIRPathEngine {
|
|||
* @param functionName
|
||||
* @return null if the function is not known
|
||||
*/
|
||||
public FunctionDetails resolveFunction(String functionName);
|
||||
public FunctionDetails resolveFunction(FHIRPathEngine engine, String functionName);
|
||||
|
||||
/**
|
||||
* Check the function parameters, and throw an error if they are incorrect, or return the type for the function
|
||||
|
@ -179,7 +179,7 @@ public class FHIRPathEngine {
|
|||
* @param parameters
|
||||
* @return
|
||||
*/
|
||||
public TypeDetails checkFunction(Object appContext, String functionName, List<TypeDetails> parameters) throws PathEngineException;
|
||||
public TypeDetails checkFunction(FHIRPathEngine engine, Object appContext, String functionName, TypeDetails focus, List<TypeDetails> parameters) throws PathEngineException;
|
||||
|
||||
/**
|
||||
* @param appContext
|
||||
|
@ -187,7 +187,7 @@ public class FHIRPathEngine {
|
|||
* @param parameters
|
||||
* @return
|
||||
*/
|
||||
public List<Base> executeFunction(Object appContext, List<Base> focus, String functionName, List<List<Base>> parameters);
|
||||
public List<Base> executeFunction(FHIRPathEngine engine, Object appContext, List<Base> focus, String functionName, List<List<Base>> parameters);
|
||||
|
||||
/**
|
||||
* Implementation of resolve() function. Passed a string, return matching resource, if one is known - else null
|
||||
|
@ -196,14 +196,14 @@ public class FHIRPathEngine {
|
|||
* @return
|
||||
* @throws FHIRException
|
||||
*/
|
||||
public Base resolveReference(Object appContext, String url, Base refContext) throws FHIRException;
|
||||
public Base resolveReference(FHIRPathEngine engine, Object appContext, String url, Base refContext) throws FHIRException;
|
||||
|
||||
public boolean conformsToProfile(Object appContext, Base item, String url) throws FHIRException;
|
||||
public boolean conformsToProfile(FHIRPathEngine engine, Object appContext, Base item, String url) throws FHIRException;
|
||||
|
||||
/*
|
||||
* return the value set referenced by the url, which has been used in memberOf()
|
||||
*/
|
||||
public ValueSet resolveValueSet(Object appContext, String url);
|
||||
public ValueSet resolveValueSet(FHIRPathEngine engine, Object appContext, String url);
|
||||
|
||||
/**
|
||||
* For the moment, there can only be one parameter if it's a type parameter
|
||||
|
@ -1112,7 +1112,7 @@ public class FHIRPathEngine {
|
|||
FunctionDetails details = null;
|
||||
if (f == null) {
|
||||
if (hostServices != null) {
|
||||
details = hostServices.resolveFunction(result.getName());
|
||||
details = hostServices.resolveFunction(this, result.getName());
|
||||
}
|
||||
if (details == null) {
|
||||
throw lexer.error("The name "+result.getName()+" is not a valid function name");
|
||||
|
@ -1536,7 +1536,7 @@ public class FHIRPathEngine {
|
|||
} else if (atEntry && exp.getName().equals("$index")) {
|
||||
result.addType(TypeDetails.FP_Integer);
|
||||
} else if (atEntry && focus == null) {
|
||||
result.update(executeContextType(context, exp.getName(), exp));
|
||||
result.update(executeContextType(context, exp.getName(), exp, false));
|
||||
} else {
|
||||
for (String s : focus.getTypes()) {
|
||||
result.update(executeType(s, exp, atEntry, focus, elementDependencies));
|
||||
|
@ -1560,7 +1560,7 @@ public class FHIRPathEngine {
|
|||
result.addType(TypeDetails.FP_Quantity);
|
||||
break;
|
||||
case Constant:
|
||||
result.update(resolveConstantType(context, exp.getConstant(), exp));
|
||||
result.update(resolveConstantType(context, exp.getConstant(), exp, true));
|
||||
break;
|
||||
case Group:
|
||||
result.update(executeType(context, focus, exp.getGroup(), elementDependencies, atEntry, canBeNone, exp));
|
||||
|
@ -1612,7 +1612,7 @@ public class FHIRPathEngine {
|
|||
}
|
||||
FHIRConstant c = (FHIRConstant) constant;
|
||||
if (c.getValue().startsWith("%")) {
|
||||
return resolveConstant(context, c.getValue(), beforeContext, expr);
|
||||
return resolveConstant(context, c.getValue(), beforeContext, expr, true);
|
||||
} else if (c.getValue().startsWith("@")) {
|
||||
return new ArrayList<Base>(Arrays.asList(processDateConstant(context.appInfo, c.getValue().substring(1), expr)));
|
||||
} else {
|
||||
|
@ -1683,7 +1683,7 @@ public class FHIRPathEngine {
|
|||
}
|
||||
|
||||
|
||||
private List<Base> resolveConstant(ExecutionContext context, String s, boolean beforeContext, ExpressionNode expr) throws PathEngineException {
|
||||
private List<Base> resolveConstant(ExecutionContext context, String s, boolean beforeContext, ExpressionNode expr, boolean explicitConstant) throws PathEngineException {
|
||||
if (s.equals("%sct")) {
|
||||
return new ArrayList<Base>(Arrays.asList(new StringType("http://snomed.info/sct").noExtensions()));
|
||||
} else if (s.equals("%loinc")) {
|
||||
|
@ -1713,7 +1713,7 @@ public class FHIRPathEngine {
|
|||
} else if (hostServices == null) {
|
||||
throw makeException(expr, I18nConstants.FHIRPATH_UNKNOWN_CONSTANT, s);
|
||||
} else {
|
||||
return hostServices.resolveConstant(context.appInfo, s.substring(1), beforeContext);
|
||||
return hostServices.resolveConstant(this, context.appInfo, s.substring(1), beforeContext, explicitConstant);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2532,7 +2532,7 @@ public class FHIRPathEngine {
|
|||
private List<Base> opMemberOf(ExecutionContext context, List<Base> left, List<Base> right, ExpressionNode expr) throws FHIRException {
|
||||
boolean ans = false;
|
||||
String url = right.get(0).primitiveValue();
|
||||
ValueSet vs = hostServices != null ? hostServices.resolveValueSet(context.appInfo, url) : worker.fetchResource(ValueSet.class, url);
|
||||
ValueSet vs = hostServices != null ? hostServices.resolveValueSet(this, context.appInfo, url) : worker.fetchResource(ValueSet.class, url);
|
||||
if (vs != null) {
|
||||
for (Base l : left) {
|
||||
if (Utilities.existsInList(l.fhirType(), "code", "string", "uri")) {
|
||||
|
@ -3031,7 +3031,7 @@ public class FHIRPathEngine {
|
|||
}
|
||||
|
||||
|
||||
private TypeDetails resolveConstantType(ExecutionTypeContext context, Base constant, ExpressionNode expr) throws PathEngineException {
|
||||
private TypeDetails resolveConstantType(ExecutionTypeContext context, Base constant, ExpressionNode expr, boolean explicitConstant) throws PathEngineException {
|
||||
if (constant instanceof BooleanType) {
|
||||
return new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_Boolean);
|
||||
} else if (constant instanceof IntegerType) {
|
||||
|
@ -3041,7 +3041,7 @@ public class FHIRPathEngine {
|
|||
} else if (constant instanceof Quantity) {
|
||||
return new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_Quantity);
|
||||
} else if (constant instanceof FHIRConstant) {
|
||||
return resolveConstantType(context, ((FHIRConstant) constant).getValue(), expr);
|
||||
return resolveConstantType(context, ((FHIRConstant) constant).getValue(), expr, explicitConstant);
|
||||
} else if (constant == null) {
|
||||
return new TypeDetails(CollectionStatus.SINGLETON);
|
||||
} else {
|
||||
|
@ -3049,7 +3049,7 @@ public class FHIRPathEngine {
|
|||
}
|
||||
}
|
||||
|
||||
private TypeDetails resolveConstantType(ExecutionTypeContext context, String s, ExpressionNode expr) throws PathEngineException {
|
||||
private TypeDetails resolveConstantType(ExecutionTypeContext context, String s, ExpressionNode expr, boolean explicitConstant) throws PathEngineException {
|
||||
if (s.startsWith("@")) {
|
||||
if (s.startsWith("@T")) {
|
||||
return new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_Time);
|
||||
|
@ -3087,7 +3087,7 @@ public class FHIRPathEngine {
|
|||
} else if (hostServices == null) {
|
||||
throw makeException(expr, I18nConstants.FHIRPATH_UNKNOWN_CONSTANT, s);
|
||||
} else {
|
||||
return hostServices.resolveConstantType(context.appInfo, s);
|
||||
return hostServices.resolveConstantType(this, context.appInfo, s, explicitConstant);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3095,7 +3095,7 @@ public class FHIRPathEngine {
|
|||
List<Base> result = new ArrayList<Base>();
|
||||
if (atEntry && context.appInfo != null && hostServices != null) {
|
||||
// we'll see if the name matches a constant known by the context.
|
||||
List<Base> temp = hostServices.resolveConstant(context.appInfo, exp.getName(), true);
|
||||
List<Base> temp = hostServices.resolveConstant(this, context.appInfo, exp.getName(), true, false);
|
||||
if (!temp.isEmpty()) {
|
||||
result.addAll(temp);
|
||||
return result;
|
||||
|
@ -3123,7 +3123,7 @@ public class FHIRPathEngine {
|
|||
if (atEntry && context.appInfo != null && hostServices != null && result.isEmpty()) {
|
||||
// well, we didn't get a match on the name - we'll see if the name matches a constant known by the context.
|
||||
// (if the name does match, and the user wants to get the constant value, they'll have to try harder...
|
||||
result.addAll(hostServices.resolveConstant(context.appInfo, exp.getName(), false));
|
||||
result.addAll(hostServices.resolveConstant(this, context.appInfo, exp.getName(), false, false));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -3133,11 +3133,11 @@ public class FHIRPathEngine {
|
|||
}
|
||||
|
||||
|
||||
private TypeDetails executeContextType(ExecutionTypeContext context, String name, ExpressionNode expr) throws PathEngineException, DefinitionException {
|
||||
private TypeDetails executeContextType(ExecutionTypeContext context, String name, ExpressionNode expr, boolean explicitConstant) throws PathEngineException, DefinitionException {
|
||||
if (hostServices == null) {
|
||||
throw makeException(expr, I18nConstants.FHIRPATH_HO_HOST_SERVICES, "Context Reference");
|
||||
}
|
||||
return hostServices.resolveConstantType(context.appInfo, name);
|
||||
return hostServices.resolveConstantType(this, context.appInfo, name, explicitConstant);
|
||||
}
|
||||
|
||||
private TypeDetails executeType(String type, ExpressionNode exp, boolean atEntry, TypeDetails focus, Set<ElementDefinition> elementDependencies) throws PathEngineException, DefinitionException {
|
||||
|
@ -3585,7 +3585,7 @@ public class FHIRPathEngine {
|
|||
}
|
||||
|
||||
case Custom : {
|
||||
return hostServices.checkFunction(context.appInfo, exp.getName(), paramTypes);
|
||||
return hostServices.checkFunction(this, context.appInfo,exp.getName(), focus, paramTypes);
|
||||
}
|
||||
default:
|
||||
break;
|
||||
|
@ -3818,7 +3818,7 @@ public class FHIRPathEngine {
|
|||
params.add(execute(context, focus, p, true));
|
||||
}
|
||||
}
|
||||
return hostServices.executeFunction(context.appInfo, focus, exp.getName(), params);
|
||||
return hostServices.executeFunction(this, context.appInfo, focus, exp.getName(), params);
|
||||
}
|
||||
default:
|
||||
throw new Error("not Implemented yet");
|
||||
|
@ -4481,7 +4481,7 @@ public class FHIRPathEngine {
|
|||
}
|
||||
|
||||
String url = nl.get(0).primitiveValue();
|
||||
ValueSet vs = hostServices != null ? hostServices.resolveValueSet(context.appInfo, url) : worker.fetchResource(ValueSet.class, url);
|
||||
ValueSet vs = hostServices != null ? hostServices.resolveValueSet(this, context.appInfo, url) : worker.fetchResource(ValueSet.class, url);
|
||||
if (vs == null) {
|
||||
return new ArrayList<Base>();
|
||||
}
|
||||
|
@ -5108,7 +5108,7 @@ public class FHIRPathEngine {
|
|||
}
|
||||
} else if (hostServices != null) {
|
||||
try {
|
||||
res = hostServices.resolveReference(context.appInfo, s, refContext);
|
||||
res = hostServices.resolveReference(this, context.appInfo, s, refContext);
|
||||
} catch (Exception e) {
|
||||
res = null;
|
||||
}
|
||||
|
@ -5616,7 +5616,7 @@ public class FHIRPathEngine {
|
|||
result.add(new BooleanType(false).noExtensions());
|
||||
} else {
|
||||
String url = convertToString(execute(context, focus, expr.getParameters().get(0), true));
|
||||
result.add(new BooleanType(hostServices.conformsToProfile(context.appInfo, focus.get(0), url)).noExtensions());
|
||||
result.add(new BooleanType(hostServices.conformsToProfile(this, context.appInfo, focus.get(0), url)).noExtensions());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -741,7 +741,7 @@ public class LiquidEngine implements IEvaluationContext {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<Base> resolveConstant(Object appContext, String name, boolean beforeContext) throws PathEngineException {
|
||||
public List<Base> resolveConstant(FHIRPathEngine engine, Object appContext, String name, boolean beforeContext, boolean explicitConstant) throws PathEngineException {
|
||||
LiquidEngineContext ctxt = (LiquidEngineContext) appContext;
|
||||
if (ctxt.loopVars.containsKey(name))
|
||||
return new ArrayList<Base>(Arrays.asList(ctxt.loopVars.get(name)));
|
||||
|
@ -749,15 +749,15 @@ public class LiquidEngine implements IEvaluationContext {
|
|||
return new ArrayList<Base>(Arrays.asList(ctxt.globalVars.get(name)));
|
||||
if (externalHostServices == null)
|
||||
return new ArrayList<Base>();
|
||||
return externalHostServices.resolveConstant(ctxt.externalContext, name, beforeContext);
|
||||
return externalHostServices.resolveConstant(engine, ctxt.externalContext, name, beforeContext, explicitConstant);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeDetails resolveConstantType(Object appContext, String name) throws PathEngineException {
|
||||
public TypeDetails resolveConstantType(FHIRPathEngine engine, Object appContext, String name, boolean explicitConstant) throws PathEngineException {
|
||||
if (externalHostServices == null)
|
||||
return null;
|
||||
LiquidEngineContext ctxt = (LiquidEngineContext) appContext;
|
||||
return externalHostServices.resolveConstantType(ctxt.externalContext, name);
|
||||
return externalHostServices.resolveConstantType(engine, ctxt.externalContext, name, explicitConstant);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -768,49 +768,49 @@ public class LiquidEngine implements IEvaluationContext {
|
|||
}
|
||||
|
||||
@Override
|
||||
public FunctionDetails resolveFunction(String functionName) {
|
||||
public FunctionDetails resolveFunction(FHIRPathEngine engine, String functionName) {
|
||||
if (externalHostServices == null)
|
||||
return null;
|
||||
return externalHostServices.resolveFunction(functionName);
|
||||
return externalHostServices.resolveFunction(engine, functionName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeDetails checkFunction(Object appContext, String functionName, List<TypeDetails> parameters) throws PathEngineException {
|
||||
public TypeDetails checkFunction(FHIRPathEngine engine, Object appContext, String functionName, TypeDetails focus, List<TypeDetails> parameters) throws PathEngineException {
|
||||
if (externalHostServices == null)
|
||||
return null;
|
||||
LiquidEngineContext ctxt = (LiquidEngineContext) appContext;
|
||||
return externalHostServices.checkFunction(ctxt.externalContext, functionName, parameters);
|
||||
return externalHostServices.checkFunction(engine, ctxt.externalContext, functionName, focus, parameters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Base> executeFunction(Object appContext, List<Base> focus, String functionName, List<List<Base>> parameters) {
|
||||
public List<Base> executeFunction(FHIRPathEngine engine, Object appContext, List<Base> focus, String functionName, List<List<Base>> parameters) {
|
||||
if (externalHostServices == null)
|
||||
return null;
|
||||
LiquidEngineContext ctxt = (LiquidEngineContext) appContext;
|
||||
return externalHostServices.executeFunction(ctxt.externalContext, focus, functionName, parameters);
|
||||
return externalHostServices.executeFunction(engine, ctxt.externalContext, focus, functionName, parameters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Base resolveReference(Object appContext, String url, Base refContext) throws FHIRException {
|
||||
public Base resolveReference(FHIRPathEngine engine, Object appContext, String url, Base refContext) throws FHIRException {
|
||||
if (externalHostServices == null)
|
||||
return null;
|
||||
LiquidEngineContext ctxt = (LiquidEngineContext) appContext;
|
||||
return resolveReference(ctxt.externalContext, url, refContext);
|
||||
return resolveReference(engine, ctxt.externalContext, url, refContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean conformsToProfile(Object appContext, Base item, String url) throws FHIRException {
|
||||
public boolean conformsToProfile(FHIRPathEngine engine, Object appContext, Base item, String url) throws FHIRException {
|
||||
if (externalHostServices == null)
|
||||
return false;
|
||||
LiquidEngineContext ctxt = (LiquidEngineContext) appContext;
|
||||
return conformsToProfile(ctxt.externalContext, item, url);
|
||||
return conformsToProfile(engine, ctxt.externalContext, item, url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueSet resolveValueSet(Object appContext, String url) {
|
||||
public ValueSet resolveValueSet(FHIRPathEngine engine, Object appContext, String url) {
|
||||
LiquidEngineContext ctxt = (LiquidEngineContext) appContext;
|
||||
if (externalHostServices != null)
|
||||
return externalHostServices.resolveValueSet(ctxt.externalContext, url);
|
||||
return externalHostServices.resolveValueSet(engine, ctxt.externalContext, url);
|
||||
else
|
||||
return engine.getWorker().fetchResource(ValueSet.class, url);
|
||||
}
|
||||
|
|
|
@ -318,12 +318,12 @@ public class Runner implements IEvaluationContext {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<Base> resolveConstant(Object appContext, String name, boolean beforeContext) throws PathEngineException {
|
||||
public List<Base> resolveConstant(FHIRPathEngine engine, Object appContext, String name, boolean beforeContext, boolean explicitConstant) throws PathEngineException {
|
||||
throw new Error("Not implemented yet: resolveConstant");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeDetails resolveConstantType(Object appContext, String name) throws PathEngineException {
|
||||
public TypeDetails resolveConstantType(FHIRPathEngine engine, Object appContext, String name, boolean explicitConstant) throws PathEngineException {
|
||||
throw new Error("Not implemented yet: resolveConstantType");
|
||||
}
|
||||
|
||||
|
@ -333,7 +333,7 @@ public class Runner implements IEvaluationContext {
|
|||
}
|
||||
|
||||
@Override
|
||||
public FunctionDetails resolveFunction(String functionName) {
|
||||
public FunctionDetails resolveFunction(FHIRPathEngine engine, String functionName) {
|
||||
switch (functionName) {
|
||||
case "getResourceKey" : return new FunctionDetails("Unique Key for resource", 0, 0);
|
||||
case "getReferenceKey" : return new FunctionDetails("Unique Key for resource that is the target of the reference", 0, 1);
|
||||
|
@ -341,7 +341,7 @@ public class Runner implements IEvaluationContext {
|
|||
}
|
||||
}
|
||||
@Override
|
||||
public TypeDetails checkFunction(Object appContext, String functionName, List<TypeDetails> parameters) throws PathEngineException {
|
||||
public TypeDetails checkFunction(FHIRPathEngine engine, Object appContext, String functionName, TypeDetails focus, List<TypeDetails> parameters) throws PathEngineException {
|
||||
switch (functionName) {
|
||||
case "getResourceKey" : return new TypeDetails(CollectionStatus.SINGLETON, "string");
|
||||
case "getReferenceKey" : return new TypeDetails(CollectionStatus.SINGLETON, "string");
|
||||
|
@ -350,7 +350,7 @@ public class Runner implements IEvaluationContext {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<Base> executeFunction(Object appContext, List<Base> focus, String functionName, List<List<Base>> parameters) {
|
||||
public List<Base> executeFunction(FHIRPathEngine engine, Object appContext, List<Base> focus, String functionName, List<List<Base>> parameters) {
|
||||
switch (functionName) {
|
||||
case "getResourceKey" : return executeResourceKey(focus);
|
||||
case "getReferenceKey" : return executeReferenceKey(focus, parameters);
|
||||
|
@ -420,17 +420,17 @@ public class Runner implements IEvaluationContext {
|
|||
return null;
|
||||
}
|
||||
@Override
|
||||
public Base resolveReference(Object appContext, String url, Base refContext) throws FHIRException {
|
||||
public Base resolveReference(FHIRPathEngine engine, Object appContext, String url, Base refContext) throws FHIRException {
|
||||
throw new Error("Not implemented yet: resolveReference");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean conformsToProfile(Object appContext, Base item, String url) throws FHIRException {
|
||||
public boolean conformsToProfile(FHIRPathEngine engine, Object appContext, Base item, String url) throws FHIRException {
|
||||
throw new Error("Not implemented yet: conformsToProfile");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ValueSet resolveValueSet(Object appContext, String url) {
|
||||
public ValueSet resolveValueSet(FHIRPathEngine engine, Object appContext, String url) {
|
||||
throw new Error("Not implemented yet: resolveValueSet");
|
||||
}
|
||||
@Override
|
||||
|
|
|
@ -24,7 +24,7 @@ public class FHIRPathHostServices implements FHIRPathEngine.IEvaluationContext {
|
|||
this.structureMapUtilities = structureMapUtilities;
|
||||
}
|
||||
|
||||
public List<Base> resolveConstant(Object appContext, String name, boolean beforeContext) throws PathEngineException {
|
||||
public List<Base> resolveConstant(FHIRPathEngine engine, Object appContext, String name, boolean beforeContext, boolean explicitConstant) throws PathEngineException {
|
||||
Variables vars = (Variables) appContext;
|
||||
Base res = vars.get(VariableMode.INPUT, name);
|
||||
if (res == null)
|
||||
|
@ -36,7 +36,7 @@ public class FHIRPathHostServices implements FHIRPathEngine.IEvaluationContext {
|
|||
}
|
||||
|
||||
@Override
|
||||
public TypeDetails resolveConstantType(Object appContext, String name) throws PathEngineException {
|
||||
public TypeDetails resolveConstantType(FHIRPathEngine engine, Object appContext, String name, boolean explicitConstant) throws PathEngineException {
|
||||
if (!(appContext instanceof VariablesForProfiling))
|
||||
throw new Error("Internal Logic Error (wrong type '" + appContext.getClass().getName() + "' in resolveConstantType)");
|
||||
VariablesForProfiling vars = (VariablesForProfiling) appContext;
|
||||
|
@ -52,22 +52,22 @@ public class FHIRPathHostServices implements FHIRPathEngine.IEvaluationContext {
|
|||
}
|
||||
|
||||
@Override
|
||||
public FunctionDetails resolveFunction(String functionName) {
|
||||
public FunctionDetails resolveFunction(FHIRPathEngine engine, String functionName) {
|
||||
return null; // throw new Error("Not Implemented Yet");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeDetails checkFunction(Object appContext, String functionName, List<TypeDetails> parameters) throws PathEngineException {
|
||||
public TypeDetails checkFunction(FHIRPathEngine engine, Object appContext, String functionName, TypeDetails focus, List<TypeDetails> parameters) throws PathEngineException {
|
||||
throw new Error("Not Implemented Yet");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Base> executeFunction(Object appContext, List<Base> focus, String functionName, List<List<Base>> parameters) {
|
||||
public List<Base> executeFunction(FHIRPathEngine engine, Object appContext, List<Base> focus, String functionName, List<List<Base>> parameters) {
|
||||
throw new Error("Not Implemented Yet");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Base resolveReference(Object appContext, String url, Base refContext) throws FHIRException {
|
||||
public Base resolveReference(FHIRPathEngine engine, Object appContext, String url, Base refContext) throws FHIRException {
|
||||
if (structureMapUtilities.getServices() == null)
|
||||
return null;
|
||||
return structureMapUtilities.getServices().resolveReference(appContext, url);
|
||||
|
@ -81,7 +81,7 @@ public class FHIRPathHostServices implements FHIRPathEngine.IEvaluationContext {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean conformsToProfile(Object appContext, Base item, String url) throws FHIRException {
|
||||
public boolean conformsToProfile(FHIRPathEngine engine, Object appContext, Base item, String url) throws FHIRException {
|
||||
IResourceValidator val = structureMapUtilities.getWorker().newValidator();
|
||||
List<ValidationMessage> valerrors = new ArrayList<ValidationMessage>();
|
||||
if (item instanceof Resource) {
|
||||
|
@ -96,7 +96,7 @@ public class FHIRPathHostServices implements FHIRPathEngine.IEvaluationContext {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ValueSet resolveValueSet(Object appContext, String url) {
|
||||
public ValueSet resolveValueSet(FHIRPathEngine engine, Object appContext, String url) {
|
||||
return structureMapUtilities.getWorker().fetchResource(ValueSet.class, url);
|
||||
}
|
||||
|
||||
|
|
|
@ -46,12 +46,12 @@ public class FHIRPathTests {
|
|||
public class FHIRPathTestEvaluationServices implements IEvaluationContext {
|
||||
|
||||
@Override
|
||||
public List<Base> resolveConstant(Object appContext, String name, boolean beforeContext) throws PathEngineException {
|
||||
public List<Base> resolveConstant(FHIRPathEngine engine, Object appContext, String name, boolean beforeContext, boolean explicitConstant) throws PathEngineException {
|
||||
throw new NotImplementedException("Not done yet (FHIRPathTestEvaluationServices.resolveConstant), when item is element");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeDetails resolveConstantType(Object appContext, String name) throws PathEngineException {
|
||||
public TypeDetails resolveConstantType(FHIRPathEngine engine, Object appContext, String name, boolean explicitConstant) throws PathEngineException {
|
||||
throw new NotImplementedException("Not done yet (FHIRPathTestEvaluationServices.resolveConstantType), when item is element");
|
||||
}
|
||||
|
||||
|
@ -61,27 +61,27 @@ public class FHIRPathTests {
|
|||
}
|
||||
|
||||
@Override
|
||||
public FunctionDetails resolveFunction(String functionName) {
|
||||
public FunctionDetails resolveFunction(FHIRPathEngine engine, String functionName) {
|
||||
throw new NotImplementedException("Not done yet (FHIRPathTestEvaluationServices.resolveFunction), when item is element (for " + functionName + ")");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeDetails checkFunction(Object appContext, String functionName, List<TypeDetails> parameters) throws PathEngineException {
|
||||
public TypeDetails checkFunction(FHIRPathEngine engine, Object appContext, String functionName, TypeDetails focus, List<TypeDetails> parameters) throws PathEngineException {
|
||||
throw new NotImplementedException("Not done yet (FHIRPathTestEvaluationServices.checkFunction), when item is element");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Base> executeFunction(Object appContext, List<Base> focus, String functionName, List<List<Base>> parameters) {
|
||||
public List<Base> executeFunction(FHIRPathEngine engine, Object appContext, List<Base> focus, String functionName, List<List<Base>> parameters) {
|
||||
throw new NotImplementedException("Not done yet (FHIRPathTestEvaluationServices.executeFunction), when item is element");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Base resolveReference(Object appContext, String url, Base refContext) throws FHIRException {
|
||||
public Base resolveReference(FHIRPathEngine engine, Object appContext, String url, Base refContext) throws FHIRException {
|
||||
throw new NotImplementedException("Not done yet (FHIRPathTestEvaluationServices.resolveReference), when item is element");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean conformsToProfile(Object appContext, Base item, String url) throws FHIRException {
|
||||
public boolean conformsToProfile(FHIRPathEngine engine, Object appContext, Base item, String url) throws FHIRException {
|
||||
if (url.equals("http://hl7.org/fhir/StructureDefinition/Patient"))
|
||||
return true;
|
||||
if (url.equals("http://hl7.org/fhir/StructureDefinition/Person"))
|
||||
|
@ -91,7 +91,7 @@ public class FHIRPathTests {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ValueSet resolveValueSet(Object appContext, String url) {
|
||||
public ValueSet resolveValueSet(FHIRPathEngine engine, Object appContext, String url) {
|
||||
return TestingUtilities.getSharedWorkerContext().fetchResource(ValueSet.class, url);
|
||||
}
|
||||
|
||||
|
@ -291,7 +291,7 @@ public class FHIRPathTests {
|
|||
final String DUMMY_CONSTANT_2 = "dummyConstant2";
|
||||
fp.setHostServices(new FHIRPathTestEvaluationServices() {
|
||||
@Override
|
||||
public List<Base> resolveConstant(Object appContext, String name, boolean beforeContext) throws PathEngineException {
|
||||
public List<Base> resolveConstant(FHIRPathEngine engine, Object appContext, String name, boolean beforeContext, boolean explicitConstant) throws PathEngineException {
|
||||
|
||||
return Arrays.asList(
|
||||
new StringType(DUMMY_CONSTANT_1).noExtensions(),
|
||||
|
|
|
@ -337,12 +337,12 @@ public class SnapShotGenerationTests {
|
|||
|
||||
// FHIRPath methods
|
||||
@Override
|
||||
public List<Base> resolveConstant(Object appContext, String name, boolean beforeContext) throws PathEngineException {
|
||||
public List<Base> resolveConstant(FHIRPathEngine engine, Object appContext, String name, boolean beforeContext, boolean explicitConstant) throws PathEngineException {
|
||||
throw new Error("Not implemented yet");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeDetails resolveConstantType(Object appContext, String name) throws PathEngineException {
|
||||
public TypeDetails resolveConstantType(FHIRPathEngine engine, Object appContext, String name, boolean explicitConstant) throws PathEngineException {
|
||||
throw new Error("Not implemented yet");
|
||||
}
|
||||
|
||||
|
@ -353,21 +353,21 @@ public class SnapShotGenerationTests {
|
|||
}
|
||||
|
||||
@Override
|
||||
public FunctionDetails resolveFunction(String functionName) {
|
||||
public FunctionDetails resolveFunction(FHIRPathEngine engine, String functionName) {
|
||||
if ("fixture".equals(functionName))
|
||||
return new FunctionDetails("Access a fixture defined in the testing context", 0, 1);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeDetails checkFunction(Object appContext, String functionName, List<TypeDetails> parameters) throws PathEngineException {
|
||||
public TypeDetails checkFunction(FHIRPathEngine engine, Object appContext, String functionName, TypeDetails focus, List<TypeDetails> parameters) throws PathEngineException {
|
||||
if ("fixture".equals(functionName))
|
||||
return new TypeDetails(CollectionStatus.SINGLETON, TestingUtilities.getSharedWorkerContext().getResourceNamesAsSet());
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Base> executeFunction(Object appContext, List<Base> focus, String functionName, List<List<Base>> parameters) {
|
||||
public List<Base> executeFunction(FHIRPathEngine engine, Object appContext, List<Base> focus, String functionName, List<List<Base>> parameters) {
|
||||
if ("fixture".equals(functionName)) {
|
||||
String id = fp.convertToString(parameters.get(0));
|
||||
Resource res = fetchFixture(id);
|
||||
|
@ -382,13 +382,13 @@ public class SnapShotGenerationTests {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Base resolveReference(Object appContext, String url, Base refContext) {
|
||||
public Base resolveReference(FHIRPathEngine engine, Object appContext, String url, Base refContext) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean conformsToProfile(Object appContext, Base item, String url) throws FHIRException {
|
||||
public boolean conformsToProfile(FHIRPathEngine engine, Object appContext, Base item, String url) throws FHIRException {
|
||||
IResourceValidator val = TestingUtilities.getSharedWorkerContext().newValidator();
|
||||
List<ValidationMessage> valerrors = new ArrayList<ValidationMessage>();
|
||||
if (item instanceof Resource) {
|
||||
|
@ -416,7 +416,7 @@ public class SnapShotGenerationTests {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ValueSet resolveValueSet(Object appContext, String url) {
|
||||
public ValueSet resolveValueSet(FHIRPathEngine engine, Object appContext, String url) {
|
||||
throw new Error("Not implemented yet");
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ class FHIRPathHostServicesTest {
|
|||
public void testrResolveValueSet() throws IOException, FHIRException {
|
||||
StructureMapUtilities scu = new StructureMapUtilities(context);
|
||||
FHIRPathHostServices fphs = new FHIRPathHostServices(scu);
|
||||
ValueSet v = fphs.resolveValueSet(null, "http://hl7.org/fhir/ValueSet/FHIR-version");
|
||||
ValueSet v = fphs.resolveValueSet(null, null, "http://hl7.org/fhir/ValueSet/FHIR-version");
|
||||
Assertions.assertNotNull(v);
|
||||
Assertions.assertEquals("http://hl7.org/fhir/ValueSet/FHIR-version", v.getUrl());
|
||||
}
|
||||
|
|
|
@ -316,12 +316,12 @@ public class SnapShotGenerationXTests {
|
|||
|
||||
// FHIRPath methods
|
||||
@Override
|
||||
public List<Base> resolveConstant(Object appContext, String name, boolean beforeContext) throws PathEngineException {
|
||||
public List<Base> resolveConstant(FHIRPathEngine engine, Object appContext, String name, boolean beforeContext, boolean explicitConstant) throws PathEngineException {
|
||||
throw new Error("Not implemented yet");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeDetails resolveConstantType(Object appContext, String name) throws PathEngineException {
|
||||
public TypeDetails resolveConstantType(FHIRPathEngine engine, Object appContext, String name, boolean explicitConstant) throws PathEngineException {
|
||||
throw new Error("Not implemented yet");
|
||||
}
|
||||
|
||||
|
@ -332,21 +332,21 @@ public class SnapShotGenerationXTests {
|
|||
}
|
||||
|
||||
@Override
|
||||
public FunctionDetails resolveFunction(String functionName) {
|
||||
public FunctionDetails resolveFunction(FHIRPathEngine engine, String functionName) {
|
||||
if ("fixture".equals(functionName))
|
||||
return new FunctionDetails("Access a fixture defined in the testing context", 0, 1);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeDetails checkFunction(Object appContext, String functionName, List<TypeDetails> parameters) throws PathEngineException {
|
||||
public TypeDetails checkFunction(FHIRPathEngine engine, Object appContext, String functionName, TypeDetails focus, List<TypeDetails> parameters) throws PathEngineException {
|
||||
if ("fixture".equals(functionName))
|
||||
return new TypeDetails(CollectionStatus.SINGLETON, UtilitiesXTests.context(version).getResourceNamesAsSet());
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Base> executeFunction(Object appContext, List<Base> focus, String functionName, List<List<Base>> parameters) {
|
||||
public List<Base> executeFunction(FHIRPathEngine engine, Object appContext, List<Base> focus, String functionName, List<List<Base>> parameters) {
|
||||
if ("fixture".equals(functionName)) {
|
||||
String id = fp.convertToString(parameters.get(0));
|
||||
Resource res = fetchFixture(id);
|
||||
|
@ -361,13 +361,13 @@ public class SnapShotGenerationXTests {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Base resolveReference(Object appContext, String url, Base refContext) {
|
||||
public Base resolveReference(FHIRPathEngine engine, Object appContext, String url, Base refContext) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean conformsToProfile(Object appContext, Base item, String url) throws FHIRException {
|
||||
public boolean conformsToProfile(FHIRPathEngine engine, Object appContext, Base item, String url) throws FHIRException {
|
||||
IResourceValidator val = UtilitiesXTests.context(version).newValidator();
|
||||
List<ValidationMessage> valerrors = new ArrayList<ValidationMessage>();
|
||||
if (item instanceof Resource) {
|
||||
|
@ -393,7 +393,7 @@ public class SnapShotGenerationXTests {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ValueSet resolveValueSet(Object appContext, String url) {
|
||||
public ValueSet resolveValueSet(FHIRPathEngine engine, Object appContext, String url) {
|
||||
throw new Error("Not implemented yet");
|
||||
}
|
||||
|
||||
|
|
|
@ -656,12 +656,12 @@ public class ValidationTests implements IEvaluationContext, IValidatorResourceFe
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<Base> resolveConstant(Object appContext, String name, boolean beforeContext) throws PathEngineException {
|
||||
public List<Base> resolveConstant(FHIRPathEngine engine, Object appContext, String name, boolean beforeContext, boolean explicitConstant) throws PathEngineException {
|
||||
return new ArrayList<Base>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeDetails resolveConstantType(Object appContext, String name) throws PathEngineException {
|
||||
public TypeDetails resolveConstantType(FHIRPathEngine engine, Object appContext, String name, boolean explicitConstant) throws PathEngineException {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -671,22 +671,22 @@ public class ValidationTests implements IEvaluationContext, IValidatorResourceFe
|
|||
}
|
||||
|
||||
@Override
|
||||
public FunctionDetails resolveFunction(String functionName) {
|
||||
public FunctionDetails resolveFunction(FHIRPathEngine engine, String functionName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeDetails checkFunction(Object appContext, String functionName, List<TypeDetails> parameters) throws PathEngineException {
|
||||
public TypeDetails checkFunction(FHIRPathEngine engine, Object appContext, String functionName, TypeDetails focus, List<TypeDetails> parameters) throws PathEngineException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Base> executeFunction(Object appContext, List<Base> focus, String functionName, List<List<Base>> parameters) {
|
||||
public List<Base> executeFunction(FHIRPathEngine engine, Object appContext, List<Base> focus, String functionName, List<List<Base>> parameters) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Base resolveReference(Object appContext, String url, Base refContext) {
|
||||
public Base resolveReference(FHIRPathEngine engine, Object appContext, String url, Base refContext) {
|
||||
if (url.equals("Patient/test"))
|
||||
return new Patient();
|
||||
return null;
|
||||
|
@ -752,7 +752,7 @@ public class ValidationTests implements IEvaluationContext, IValidatorResourceFe
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean conformsToProfile(Object appContext, Base item, String url) throws FHIRException {
|
||||
public boolean conformsToProfile(FHIRPathEngine engine, Object appContext, Base item, String url) throws FHIRException {
|
||||
IResourceValidator val = vCurr.getContext().newValidator();
|
||||
List<ValidationMessage> valerrors = new ArrayList<ValidationMessage>();
|
||||
if (item instanceof Resource) {
|
||||
|
@ -766,7 +766,7 @@ public class ValidationTests implements IEvaluationContext, IValidatorResourceFe
|
|||
}
|
||||
|
||||
@Override
|
||||
public ValueSet resolveValueSet(Object appContext, String url) {
|
||||
public ValueSet resolveValueSet(FHIRPathEngine engine, Object appContext, String url) {
|
||||
return vCurr.getContext().fetchResource(ValueSet.class, url);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue