diff --git a/org.hl7.fhir.r4/src/test/java/org/hl7/fhir/r4/test/SnapShotGenerationTests.java b/org.hl7.fhir.r4/src/test/java/org/hl7/fhir/r4/test/SnapShotGenerationTests.java index a730bab4e..5885726b2 100644 --- a/org.hl7.fhir.r4/src/test/java/org/hl7/fhir/r4/test/SnapShotGenerationTests.java +++ b/org.hl7.fhir.r4/src/test/java/org/hl7/fhir/r4/test/SnapShotGenerationTests.java @@ -277,6 +277,7 @@ public class SnapShotGenerationTests { @Parameters(name = "{index}: file {0}") public static Iterable data() throws ParserConfigurationException, IOException, FHIRFormatError { SnapShotGenerationTestsContext context = new SnapShotGenerationTestsContext(); + System.out.println("Snapshot tests using "+TestingUtilities.resourceNameToFile("snapshot-generation-tests.xml")); context.tests = (TestScript) new XmlParser().parse(new FileInputStream(TestingUtilities.resourceNameToFile("snapshot-generation-tests.xml"))); context.checkTestsDetails(); diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/ExpressionNode.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/ExpressionNode.java index 7a4c29f10..c8a66fe1c 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/ExpressionNode.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/ExpressionNode.java @@ -61,7 +61,7 @@ public class ExpressionNode { 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, - Children, Descendants, MemberOf, Trace, Today, Now, Resolve, Extension, AllFalse, AnyFalse, AllTrue, AnyTrue, + 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; @@ -108,6 +108,7 @@ public class ExpressionNode { if (name.equals("descendants")) return Function.Descendants; if (name.equals("memberOf")) return Function.MemberOf; if (name.equals("trace")) return Function.Trace; + if (name.equals("check")) return Function.Check; if (name.equals("today")) return Function.Today; if (name.equals("now")) return Function.Now; if (name.equals("resolve")) return Function.Resolve; @@ -183,6 +184,7 @@ public class ExpressionNode { case Descendants : return "descendants"; case MemberOf : return "memberOf"; case Trace : return "trace"; + case Check : return "check"; case Today : return "today"; case Now : return "now"; case Resolve : return "resolve"; diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/FHIRPathEngine.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/FHIRPathEngine.java index e8ab0e93a..33fbd220b 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/FHIRPathEngine.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/FHIRPathEngine.java @@ -1110,6 +1110,7 @@ public class FHIRPathEngine { case Descendants: return checkParamCount(lexer, location, exp, 0); case MemberOf: return checkParamCount(lexer, location, exp, 1); case Trace: return checkParamCount(lexer, location, exp, 1, 2); + case Check: return checkParamCount(lexer, location, exp, 2); case Today: return checkParamCount(lexer, location, exp, 0); case Now: return checkParamCount(lexer, location, exp, 0); case Resolve: return checkParamCount(lexer, location, exp, 0); @@ -2549,6 +2550,10 @@ public class FHIRPathEngine { checkParamTypes(exp.getFunction().toCode(), paramTypes, new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_String)); return focus; } + case Check : { + checkParamTypes(exp.getFunction().toCode(), paramTypes, new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_String)); + return focus; + } case Today : return new TypeDetails(CollectionStatus.SINGLETON, TypeDetails.FP_DateTime); case Now : @@ -2741,6 +2746,7 @@ public class FHIRPathEngine { case Descendants : return funcDescendants(context, focus, exp); case MemberOf : return funcMemberOf(context, focus, exp); case Trace : return funcTrace(context, focus, exp); + case Check : return funcCheck(context, focus, exp); case Today : return funcToday(context, focus, exp); case Now : return funcNow(context, focus, exp); case Resolve : return funcResolve(context, focus, exp); @@ -3484,6 +3490,16 @@ public class FHIRPathEngine { return focus; } + private List funcCheck(ExecutionContext context, List focus, ExpressionNode exp) throws FHIRException { + List n1 = execute(context, focus, exp.getParameters().get(0), true); + if (!convertToBoolean(n1)) { + List n2 = execute(context, focus, exp.getParameters().get(1), true); + String name = n2.get(0).primitiveValue(); + throw new FHIRException("check failed: "+name); + } + return focus; + } + private List funcDistinct(ExecutionContext context, List focus, ExpressionNode exp) { if (focus.size() <= 1) return focus; diff --git a/org.hl7.fhir.r5/src/main/resources/snapshot-generation-tests.xml b/org.hl7.fhir.r5/src/main/resources/snapshot-generation-tests.xml index f0ba003aa..f8df40aea 100644 --- a/org.hl7.fhir.r5/src/main/resources/snapshot-generation-tests.xml +++ b/org.hl7.fhir.r5/src/main/resources/snapshot-generation-tests.xml @@ -2086,7 +2086,7 @@ - + @@ -2168,7 +2168,7 @@ - + @@ -2180,7 +2180,7 @@ - + @@ -4310,4 +4310,288 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +