Merge pull request #764 from hapifhir/issue_761

issue_761 fix
This commit is contained in:
dotasek 2022-03-14 13:59:44 -04:00 committed by GitHub
commit b3fd5a9075
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 71 additions and 67 deletions

View File

@ -2112,12 +2112,14 @@ public class FHIRPathEngine {
private List<Base> funcReplaceMatches(ExecutionContext context, List<Base> focus, ExpressionNode exp) throws PathEngineException { private List<Base> funcReplaceMatches(ExecutionContext context, List<Base> focus, ExpressionNode exp) throws PathEngineException {
List<Base> result = new ArrayList<Base>(); List<Base> result = new ArrayList<Base>();
String sw = convertToString(execute(context, focus, exp.getParameters().get(0), true)); String regex = convertToString(execute(context, focus, exp.getParameters().get(0), true));
String repl = convertToString(execute(context, focus, exp.getParameters().get(1), true));
if (focus.size() == 1 && !Utilities.noString(sw)) if (focus.size() == 1 && !Utilities.noString(regex)) {
result.add(new BooleanType(convertToString(focus.get(0)).contains(sw))); result.add(new StringType(convertToString(focus.get(0)).replaceAll(regex, repl)));
else } else {
result.add(new BooleanType(false)); result.add(new StringType(convertToString(focus.get(0))));
}
return result; return result;
} }

View File

@ -2244,12 +2244,14 @@ public class FHIRPathEngine {
private List<Base> funcReplaceMatches(ExecutionContext context, List<Base> focus, ExpressionNode exp) throws FHIRException { private List<Base> funcReplaceMatches(ExecutionContext context, List<Base> focus, ExpressionNode exp) throws FHIRException {
List<Base> result = new ArrayList<Base>(); List<Base> result = new ArrayList<Base>();
String sw = convertToString(execute(context, focus, exp.getParameters().get(0), true)); String regex = convertToString(execute(context, focus, exp.getParameters().get(0), true));
String repl = convertToString(execute(context, focus, exp.getParameters().get(1), true));
if (focus.size() == 1 && !Utilities.noString(sw)) if (focus.size() == 1 && !Utilities.noString(regex)) {
result.add(new BooleanType(convertToString(focus.get(0)).contains(sw))); result.add(new StringType(convertToString(focus.get(0)).replaceAll(regex, repl)));
else } else {
result.add(new BooleanType(false)); result.add(new StringType(convertToString(focus.get(0))));
}
return result; return result;
} }