start working on R3 string functions
This commit is contained in:
parent
211ac8fc12
commit
f169a4315f
|
@ -73,8 +73,10 @@ public class ExpressionNode {
|
||||||
First, Last, Tail, Skip, Take, Union, Combine, Intersect, Exclude, Iif, Upper, Lower, ToChars, IndexOf, Substring, StartsWith, EndsWith, Matches, ReplaceMatches, Contains, Replace, Length,
|
First, Last, Tail, Skip, Take, Union, Combine, Intersect, Exclude, Iif, Upper, Lower, ToChars, IndexOf, Substring, StartsWith, EndsWith, Matches, ReplaceMatches, Contains, Replace, Length,
|
||||||
Children, Descendants, MemberOf, Trace, Check, Today, Now, Resolve, Extension, AllFalse, AnyFalse, AllTrue, AnyTrue,
|
Children, Descendants, MemberOf, Trace, Check, Today, Now, Resolve, Extension, AllFalse, AnyFalse, AllTrue, AnyTrue,
|
||||||
HasValue, OfType, Type, ConvertsToBoolean, ConvertsToInteger, ConvertsToString, ConvertsToDecimal, ConvertsToQuantity, ConvertsToDateTime, ConvertsToTime, ToBoolean, ToInteger, ToString, ToDecimal, ToQuantity, ToDateTime, ToTime, ConformsTo,
|
HasValue, OfType, Type, ConvertsToBoolean, ConvertsToInteger, ConvertsToString, ConvertsToDecimal, ConvertsToQuantity, ConvertsToDateTime, ConvertsToTime, ToBoolean, ToInteger, ToString, ToDecimal, ToQuantity, ToDateTime, ToTime, ConformsTo,
|
||||||
|
// R3 functions
|
||||||
|
Encode, Decode, Escape, Trim, Split, Join,
|
||||||
// Local extensions to FHIRPath
|
// Local extensions to FHIRPath
|
||||||
HtmlChecks, AliasAs, Alias, fromBase64, toBase64;
|
HtmlChecks, AliasAs, Alias;
|
||||||
|
|
||||||
public static Function fromCode(String name) {
|
public static Function fromCode(String name) {
|
||||||
if (name.equals("empty")) return Function.Empty;
|
if (name.equals("empty")) return Function.Empty;
|
||||||
|
@ -134,8 +136,12 @@ public class ExpressionNode {
|
||||||
if (name.equals("aliasAs")) return Function.AliasAs;
|
if (name.equals("aliasAs")) return Function.AliasAs;
|
||||||
if (name.equals("htmlChecks")) return Function.HtmlChecks;
|
if (name.equals("htmlChecks")) return Function.HtmlChecks;
|
||||||
if (name.equals("htmlchecks")) return Function.HtmlChecks; // support change of care from R3
|
if (name.equals("htmlchecks")) return Function.HtmlChecks; // support change of care from R3
|
||||||
if (name.equals("fromBase64")) return Function.fromBase64;
|
if (name.equals("encode")) return Function.Encode;
|
||||||
if (name.equals("toBase64")) return Function.toBase64;
|
if (name.equals("decode")) return Function.Decode;
|
||||||
|
if (name.equals("escape")) return Function.Escape;
|
||||||
|
if (name.equals("trim")) return Function.Trim;
|
||||||
|
if (name.equals("split")) return Function.Split;
|
||||||
|
if (name.equals("join")) return Function.Join;
|
||||||
if (name.equals("ofType")) return Function.OfType;
|
if (name.equals("ofType")) return Function.OfType;
|
||||||
if (name.equals("type")) return Function.Type;
|
if (name.equals("type")) return Function.Type;
|
||||||
if (name.equals("toInteger")) return Function.ToInteger;
|
if (name.equals("toInteger")) return Function.ToInteger;
|
||||||
|
@ -212,8 +218,12 @@ public class ExpressionNode {
|
||||||
case HasValue : return "hasValue";
|
case HasValue : return "hasValue";
|
||||||
case Alias : return "alias";
|
case Alias : return "alias";
|
||||||
case AliasAs : return "aliasAs";
|
case AliasAs : return "aliasAs";
|
||||||
case fromBase64 : return "fromBase64";
|
case Encode : return "encode";
|
||||||
case toBase64 : return "toBase64";
|
case Decode : return "decode";
|
||||||
|
case Escape : return "escape";
|
||||||
|
case Trim : return "trim";
|
||||||
|
case Split : return "split";
|
||||||
|
case Join : return "join";
|
||||||
case HtmlChecks : return "htmlChecks";
|
case HtmlChecks : return "htmlChecks";
|
||||||
case OfType : return "ofType";
|
case OfType : return "ofType";
|
||||||
case Type : return "type";
|
case Type : return "type";
|
||||||
|
|
|
@ -1147,8 +1147,12 @@ public class FHIRPathEngine {
|
||||||
case HasValue: return checkParamCount(lexer, location, exp, 0);
|
case HasValue: return checkParamCount(lexer, location, exp, 0);
|
||||||
case Alias: return checkParamCount(lexer, location, exp, 1);
|
case Alias: return checkParamCount(lexer, location, exp, 1);
|
||||||
case AliasAs: return checkParamCount(lexer, location, exp, 1);
|
case AliasAs: return checkParamCount(lexer, location, exp, 1);
|
||||||
case fromBase64: return checkParamCount(lexer, location, exp, 0);
|
case Encode: return checkParamCount(lexer, location, exp, 1);
|
||||||
case toBase64: return checkParamCount(lexer, location, exp, 0);
|
case Decode: return checkParamCount(lexer, location, exp, 1);
|
||||||
|
case Escape: return checkParamCount(lexer, location, exp, 1);
|
||||||
|
case Trim: return checkParamCount(lexer, location, exp, 0);
|
||||||
|
case Split: return checkParamCount(lexer, location, exp, 1);
|
||||||
|
case Join: return checkParamCount(lexer, location, exp, 1);
|
||||||
case HtmlChecks: return checkParamCount(lexer, location, exp, 0);
|
case HtmlChecks: return checkParamCount(lexer, location, exp, 0);
|
||||||
case ToInteger: return checkParamCount(lexer, location, exp, 0);
|
case ToInteger: return checkParamCount(lexer, location, exp, 0);
|
||||||
case ToDecimal: return checkParamCount(lexer, location, exp, 0);
|
case ToDecimal: return checkParamCount(lexer, location, exp, 0);
|
||||||
|
@ -2647,9 +2651,22 @@ public class FHIRPathEngine {
|
||||||
case AliasAs :
|
case AliasAs :
|
||||||
checkParamTypes(exp.getFunction().toCode(), paramTypes, new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_String));
|
checkParamTypes(exp.getFunction().toCode(), paramTypes, new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_String));
|
||||||
return focus;
|
return focus;
|
||||||
case fromBase64:
|
case Encode:
|
||||||
|
checkParamTypes(exp.getFunction().toCode(), paramTypes, new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_String));
|
||||||
return new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_String);
|
return new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_String);
|
||||||
case toBase64:
|
case Decode:
|
||||||
|
checkParamTypes(exp.getFunction().toCode(), paramTypes, new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_String));
|
||||||
|
return new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_String);
|
||||||
|
case Escape:
|
||||||
|
checkParamTypes(exp.getFunction().toCode(), paramTypes, new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_String));
|
||||||
|
return new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_String);
|
||||||
|
case Trim:
|
||||||
|
return new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_String);
|
||||||
|
case Split:
|
||||||
|
checkParamTypes(exp.getFunction().toCode(), paramTypes, new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_String));
|
||||||
|
return new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_String);
|
||||||
|
case Join:
|
||||||
|
checkParamTypes(exp.getFunction().toCode(), paramTypes, new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_String));
|
||||||
return new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_String);
|
return new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_String);
|
||||||
case ToInteger : {
|
case ToInteger : {
|
||||||
checkContextPrimitive(focus, "toInteger", true);
|
checkContextPrimitive(focus, "toInteger", true);
|
||||||
|
@ -2825,8 +2842,12 @@ public class FHIRPathEngine {
|
||||||
case AllTrue: return funcAllTrue(context, focus, exp);
|
case AllTrue: return funcAllTrue(context, focus, exp);
|
||||||
case HasValue : return funcHasValue(context, focus, exp);
|
case HasValue : return funcHasValue(context, focus, exp);
|
||||||
case AliasAs : return funcAliasAs(context, focus, exp);
|
case AliasAs : return funcAliasAs(context, focus, exp);
|
||||||
case fromBase64 : return funcFromBase64(context, focus, exp);
|
case Encode : return funcEncode(context, focus, exp);
|
||||||
case toBase64 : return funcToBase64(context, focus, exp);
|
case Decode : return funcDecode(context, focus, exp);
|
||||||
|
case Escape : return funcEscape(context, focus, exp);
|
||||||
|
case Trim : return funcTrim(context, focus, exp);
|
||||||
|
case Split : return funcSplit(context, focus, exp);
|
||||||
|
case Join : return funcJoin(context, focus, exp);
|
||||||
case Alias : return funcAlias(context, focus, exp);
|
case Alias : return funcAlias(context, focus, exp);
|
||||||
case HtmlChecks : return funcHtmlChecks(context, focus, exp);
|
case HtmlChecks : return funcHtmlChecks(context, focus, exp);
|
||||||
case ToInteger : return funcToInteger(context, focus, exp);
|
case ToInteger : return funcToInteger(context, focus, exp);
|
||||||
|
@ -2855,25 +2876,41 @@ public class FHIRPathEngine {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Base> funcToBase64(ExecutionContext context, List<Base> focus, ExpressionNode exp) {
|
private List<Base> funcEncode(ExecutionContext context, List<Base> focus, ExpressionNode exp) {
|
||||||
List<Base> result = new ArrayList<Base>();
|
List<Base> result = new ArrayList<Base>();
|
||||||
if (focus.size() == 1) {
|
|
||||||
String s = convertToString(focus.get(0));
|
|
||||||
result.add(new StringType(Base64.encodeBase64String(s.getBytes())));
|
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<Base> funcDecode(ExecutionContext context, List<Base> focus, ExpressionNode exp) {
|
||||||
private List<Base> funcFromBase64(ExecutionContext context, List<Base> focus, ExpressionNode exp) {
|
|
||||||
List<Base> result = new ArrayList<Base>();
|
List<Base> result = new ArrayList<Base>();
|
||||||
if (focus.size() == 1) {
|
|
||||||
String s = convertToString(focus.get(0));
|
|
||||||
result.add(new StringType(new String(Base64.decodeBase64(s))));
|
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<Base> funcEscape(ExecutionContext context, List<Base> focus, ExpressionNode exp) {
|
||||||
|
List<Base> result = new ArrayList<Base>();
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Base> funcTrim(ExecutionContext context, List<Base> focus, ExpressionNode exp) {
|
||||||
|
List<Base> result = new ArrayList<Base>();
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Base> funcSplit(ExecutionContext context, List<Base> focus, ExpressionNode exp) {
|
||||||
|
List<Base> result = new ArrayList<Base>();
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Base> funcJoin(ExecutionContext context, List<Base> focus, ExpressionNode exp) {
|
||||||
|
List<Base> result = new ArrayList<Base>();
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
private List<Base> funcAliasAs(ExecutionContext context, List<Base> focus, ExpressionNode exp) throws FHIRException {
|
private List<Base> funcAliasAs(ExecutionContext context, List<Base> focus, ExpressionNode exp) throws FHIRException {
|
||||||
List<Base> nl = execute(context, focus, exp.getParameters().get(0), true);
|
List<Base> nl = execute(context, focus, exp.getParameters().get(0), true);
|
||||||
|
|
Loading…
Reference in New Issue