fhirpath indexOf support for R4
This commit is contained in:
parent
861e95e754
commit
9c7673c473
|
@ -60,7 +60,7 @@ public class ExpressionNode {
|
|||
Custom,
|
||||
|
||||
Empty, Not, Exists, SubsetOf, SupersetOf, IsDistinct, Distinct, Count, Where, Select, All, Repeat, Aggregate, Item /*implicit from name[]*/, As, Is, Single,
|
||||
First, Last, Tail, Skip, Take, Union, Combine, Intersect, Exclude, Iif, Upper, Lower, ToChars, 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,
|
||||
HasValue, AliasAs, Alias, HtmlChecks, OfType, Type,
|
||||
ConvertsToBoolean, ConvertsToInteger, ConvertsToString, ConvertsToDecimal, ConvertsToQuantity, ConvertsToDateTime, ConvertsToTime, ToBoolean, ToInteger, ToString, ToDecimal, ToQuantity, ToDateTime, ToTime, ConformsTo;
|
||||
|
@ -96,6 +96,7 @@ public class ExpressionNode {
|
|||
if (name.equals("lower")) return Function.Lower;
|
||||
if (name.equals("upper")) return Function.Upper;
|
||||
if (name.equals("toChars")) return Function.ToChars;
|
||||
if (name.equals("indexOf")) return Function.IndexOf;
|
||||
if (name.equals("substring")) return Function.Substring;
|
||||
if (name.equals("startsWith")) return Function.StartsWith;
|
||||
if (name.equals("endsWith")) return Function.EndsWith;
|
||||
|
@ -172,6 +173,7 @@ public class ExpressionNode {
|
|||
case ToChars : return "toChars";
|
||||
case Lower : return "lower";
|
||||
case Upper : return "upper";
|
||||
case IndexOf : return "indexOf";
|
||||
case Substring : return "substring";
|
||||
case StartsWith : return "startsWith";
|
||||
case EndsWith : return "endsWith";
|
||||
|
|
|
@ -2486,6 +2486,11 @@ public class FHIRPathEngine {
|
|||
checkContextString(focus, "toChars");
|
||||
return new TypeDetails(CollectionStatus.ORDERED, TypeDetails.FP_String);
|
||||
}
|
||||
case IndexOf : {
|
||||
checkContextString(focus, "indexOf");
|
||||
checkParamTypes(exp.getFunction().toCode(), paramTypes, new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_String));
|
||||
return new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_Integer);
|
||||
}
|
||||
case Substring : {
|
||||
checkContextString(focus, "subString");
|
||||
checkParamTypes(exp.getFunction().toCode(), paramTypes, new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_Integer), new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_Integer));
|
||||
|
@ -2722,6 +2727,7 @@ public class FHIRPathEngine {
|
|||
case Lower : return funcLower(context, focus, exp);
|
||||
case Upper : return funcUpper(context, focus, exp);
|
||||
case ToChars : return funcToChars(context, focus, exp);
|
||||
case IndexOf : return funcIndexOf(context, focus, exp);
|
||||
case Substring : return funcSubstring(context, focus, exp);
|
||||
case StartsWith : return funcStartsWith(context, focus, exp);
|
||||
case EndsWith : return funcEndsWith(context, focus, exp);
|
||||
|
@ -3611,6 +3617,24 @@ public class FHIRPathEngine {
|
|||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private List<Base> funcIndexOf(ExecutionContext context, List<Base> focus, ExpressionNode exp) throws FHIRException {
|
||||
List<Base> result = new ArrayList<Base>();
|
||||
|
||||
String sw = convertToString(execute(context, focus, exp.getParameters().get(0), true));
|
||||
if (focus.size() == 0) {
|
||||
result.add(new IntegerType(0).noExtensions());
|
||||
} else if (Utilities.noString(sw)) {
|
||||
result.add(new IntegerType(0).noExtensions());
|
||||
} else {
|
||||
String s = convertToString(focus.get(0));
|
||||
if (s == null)
|
||||
result.add(new IntegerType(0).noExtensions());
|
||||
else
|
||||
result.add(new IntegerType(s.indexOf(sw)).noExtensions());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private List<Base> funcSubstring(ExecutionContext context, List<Base> focus, ExpressionNode exp) throws FHIRException {
|
||||
List<Base> result = new ArrayList<Base>();
|
||||
|
|
Loading…
Reference in New Issue