fix test, revert var patch
This commit is contained in:
parent
d69a8e3e43
commit
2f165863e7
|
@ -1075,16 +1075,19 @@ public class StructureMapUtilities {
|
|||
if (lexer.hasToken("where")) {
|
||||
lexer.take();
|
||||
ExpressionNode node = fpe.parse(lexer);
|
||||
source.setUserData(MAP_WHERE_EXPRESSION, node);
|
||||
source.setCondition(node.toString());
|
||||
}
|
||||
if (lexer.hasToken("check")) {
|
||||
lexer.take();
|
||||
ExpressionNode node = fpe.parse(lexer);
|
||||
source.setUserData(MAP_WHERE_CHECK, node);
|
||||
source.setCheck(node.toString());
|
||||
}
|
||||
if (lexer.hasToken("log")) {
|
||||
lexer.take();
|
||||
ExpressionNode node = fpe.parse(lexer);
|
||||
source.setUserData(MAP_WHERE_LOG, node);
|
||||
source.setLogMessage(node.toString());
|
||||
}
|
||||
}
|
||||
|
@ -1598,7 +1601,6 @@ public class StructureMapUtilities {
|
|||
ExpressionNode expr = (ExpressionNode) src.getUserData(MAP_SEARCH_EXPRESSION);
|
||||
if (expr == null) {
|
||||
expr = fpe.parse(src.getElement());
|
||||
patchVariablesInExpression(expr, vars);
|
||||
src.setUserData(MAP_SEARCH_EXPRESSION, expr);
|
||||
}
|
||||
String search = fpe.evaluateToString(vars, null, null, new StringType(), expr); // string is a holder of nothing to ensure that variables are processed correctly
|
||||
|
@ -1632,7 +1634,6 @@ public class StructureMapUtilities {
|
|||
ExpressionNode expr = (ExpressionNode) src.getUserData(MAP_WHERE_EXPRESSION);
|
||||
if (expr == null) {
|
||||
expr = fpe.parse(src.getCondition());
|
||||
patchVariablesInExpression(expr, vars);
|
||||
src.setUserData(MAP_WHERE_EXPRESSION, expr);
|
||||
}
|
||||
List<Base> remove = new ArrayList<Base>();
|
||||
|
@ -1654,7 +1655,6 @@ public class StructureMapUtilities {
|
|||
ExpressionNode expr = (ExpressionNode) src.getUserData(MAP_WHERE_CHECK);
|
||||
if (expr == null) {
|
||||
expr = fpe.parse(src.getCheck());
|
||||
patchVariablesInExpression(expr, vars);
|
||||
src.setUserData(MAP_WHERE_CHECK, expr);
|
||||
}
|
||||
for (Base item : items) {
|
||||
|
@ -1671,7 +1671,6 @@ public class StructureMapUtilities {
|
|||
ExpressionNode expr = (ExpressionNode) src.getUserData(MAP_WHERE_LOG);
|
||||
if (expr == null) {
|
||||
expr = fpe.parse(src.getLogMessage());
|
||||
patchVariablesInExpression(expr, vars);
|
||||
src.setUserData(MAP_WHERE_LOG, expr);
|
||||
}
|
||||
CommaSeparatedStringBuilder b = new CommaSeparatedStringBuilder();
|
||||
|
@ -1764,29 +1763,6 @@ public class StructureMapUtilities {
|
|||
vars.add(VariableMode.OUTPUT, tgt.getVariable(), v);
|
||||
}
|
||||
|
||||
public static void patchVariablesInExpression(ExpressionNode node, Variables vars) {
|
||||
if (node.isProximal() && node.getKind() == ExpressionNode.Kind.Name && node.getName() !=null && node.getName().length()>0 && !node.getName().startsWith("%")) {
|
||||
// Check if this name is in the variables
|
||||
if (vars.get(VariableMode.INPUT, node.getName())!=null)
|
||||
node.setName("%" + node.getName());
|
||||
}
|
||||
// walk into children
|
||||
var next = node.getOpNext();
|
||||
if (next != null)
|
||||
patchVariablesInExpression(next, vars);
|
||||
var grp = node.getGroup();
|
||||
if (grp != null)
|
||||
patchVariablesInExpression(grp, vars);
|
||||
var inner = node.getInner();
|
||||
if (inner != null)
|
||||
patchVariablesInExpression(inner, vars);
|
||||
if (node.parameterCount() > 0) {
|
||||
for(ExpressionNode p : node.getParameters()) {
|
||||
patchVariablesInExpression(p, vars);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Base runTransform(String rulePath, TransformContext context, StructureMap map, StructureMapGroupComponent group, StructureMapGroupRuleTargetComponent tgt, Variables vars, Base dest, String element, String srcVar, boolean root) throws FHIRException {
|
||||
try {
|
||||
switch (tgt.getTransform()) {
|
||||
|
@ -1826,7 +1802,6 @@ public class StructureMapUtilities {
|
|||
ExpressionNode expr = (ExpressionNode) tgt.getUserData(MAP_EXPRESSION);
|
||||
if (expr == null) {
|
||||
expr = fpe.parse(getParamStringNoNull(vars, tgt.getParameter().get(tgt.getParameter().size() - 1), tgt.toString()));
|
||||
patchVariablesInExpression(expr, vars);
|
||||
tgt.setUserData(MAP_EXPRESSION, expr);
|
||||
}
|
||||
List<Base> v = fpe.evaluate(vars, null, null, tgt.getParameter().size() == 2 ? getParam(vars, tgt.getParameter().get(0)) : new BooleanType(false), expr);
|
||||
|
|
Loading…
Reference in New Issue