diff --git a/fhir-model/FHIRPath.g4 b/fhir-model/FHIRPath.g4 index e7a9b3d7702..f8820c57e88 100644 --- a/fhir-model/FHIRPath.g4 +++ b/fhir-model/FHIRPath.g4 @@ -1,6 +1,7 @@ grammar FHIRPath; // Grammar rules +// [FHIRPath](http://hl7.org/fhirpath/N1) Normative Release //prog: line (line)*; //line: ID ( '(' expr ')') ':' expr '\r'? '\n'; @@ -35,13 +36,14 @@ literal | ('true' | 'false') #booleanLiteral | STRING #stringLiteral | NUMBER #numberLiteral + | DATE #dateLiteral | DATETIME #dateTimeLiteral | TIME #timeLiteral | quantity #quantityLiteral ; externalConstant - : '%' identifier + : '%' ( identifier | STRING ) ; invocation // Terms that can be used after the function/member invocation '.' @@ -90,6 +92,8 @@ identifier : IDENTIFIER | DELIMITEDIDENTIFIER | 'as' + | 'contains' + | 'in' | 'is' ; @@ -98,40 +102,34 @@ identifier Lexical rules *****************************************************************/ -// Not sure why, but with these as lexical rules, when the grammar is imported into CQL, they are not correctly recognized -// Moving the same rules into the literal production rule above corrects the issue -//EMPTY -// : '{' '}' -// ; // To create an empty array (and avoid a NULL literal) +/* +NOTE: The goal of these rules in the grammar is to provide a date +token to the parser. As such it is not attempting to validate that +the date is a correct date, that task is for the parser or interpreter. +*/ -//BOOL -// : 'true' -// | 'false' -// ; +DATE + : '@' DATEFORMAT + ; DATETIME - : '@' - [0-9][0-9][0-9][0-9] // year - ( - '-'[0-9][0-9] // month - ( - '-'[0-9][0-9] // day - ( - 'T' TIMEFORMAT - )? - )? - )? - 'Z'? // UTC specifier + : '@' DATEFORMAT 'T' (TIMEFORMAT TIMEZONEOFFSETFORMAT?)? ; TIME : '@' 'T' TIMEFORMAT ; +fragment DATEFORMAT + : [0-9][0-9][0-9][0-9] ('-'[0-9][0-9] ('-'[0-9][0-9])?)? + ; + fragment TIMEFORMAT - : - [0-9][0-9] (':'[0-9][0-9] (':'[0-9][0-9] ('.'[0-9]+)?)?)? - ('Z' | ('+' | '-') [0-9][0-9]':'[0-9][0-9])? // timezone + : [0-9][0-9] (':'[0-9][0-9] (':'[0-9][0-9] ('.'[0-9]+)?)?)? + ; + +fragment TIMEZONEOFFSETFORMAT + : ('Z' | ('+' | '-') [0-9][0-9]':'[0-9][0-9]) ; IDENTIFIER diff --git a/fhir-model/pom.xml b/fhir-model/pom.xml index f448e7461c0..2559b55a5ce 100644 --- a/fhir-model/pom.xml +++ b/fhir-model/pom.xml @@ -18,7 +18,7 @@ org.antlr antlr4-runtime - 4.5.3 + 4.7.2 net.jcip diff --git a/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPath.interp b/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPath.interp new file mode 100644 index 00000000000..fcda0d2c8f9 --- /dev/null +++ b/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPath.interp @@ -0,0 +1,153 @@ +token literal names: +null +'.' +'[' +']' +'+' +'-' +'*' +'/' +'div' +'mod' +'&' +'is' +'as' +'|' +'<=' +'<' +'>' +'>=' +'=' +'~' +'!=' +'!~' +'in' +'contains' +'and' +'or' +'xor' +'implies' +'(' +')' +'{' +'}' +'true' +'false' +'%' +'$this' +'$index' +'$total' +',' +'year' +'month' +'week' +'day' +'hour' +'minute' +'second' +'millisecond' +'years' +'months' +'weeks' +'days' +'hours' +'minutes' +'seconds' +'milliseconds' +null +null +null +null +null +null +null +null +null +null + +token symbolic names: +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +DATE +DATETIME +TIME +IDENTIFIER +DELIMITEDIDENTIFIER +STRING +NUMBER +WS +COMMENT +LINE_COMMENT + +rule names: +expression +term +literal +externalConstant +invocation +function +paramList +quantity +unit +dateTimePrecision +pluralDateTimePrecision +typeSpecifier +qualifiedIdentifier +identifier + + +atn: +[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 66, 152, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 3, 2, 3, 2, 3, 2, 3, 2, 5, 2, 35, 10, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 7, 2, 75, 10, 2, 12, 2, 14, 2, 78, 11, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 3, 87, 10, 3, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 5, 4, 98, 10, 4, 3, 5, 3, 5, 3, 5, 5, 5, 103, 10, 5, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 5, 6, 110, 10, 6, 3, 7, 3, 7, 3, 7, 5, 7, 115, 10, 7, 3, 7, 3, 7, 3, 8, 3, 8, 3, 8, 7, 8, 122, 10, 8, 12, 8, 14, 8, 125, 11, 8, 3, 9, 3, 9, 5, 9, 129, 10, 9, 3, 10, 3, 10, 3, 10, 5, 10, 134, 10, 10, 3, 11, 3, 11, 3, 12, 3, 12, 3, 13, 3, 13, 3, 14, 3, 14, 3, 14, 7, 14, 145, 10, 14, 12, 14, 14, 14, 148, 11, 14, 3, 15, 3, 15, 3, 15, 2, 3, 2, 16, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 2, 14, 3, 2, 6, 7, 3, 2, 8, 11, 4, 2, 6, 7, 12, 12, 3, 2, 16, 19, 3, 2, 20, 23, 3, 2, 24, 25, 3, 2, 27, 28, 3, 2, 13, 14, 3, 2, 34, 35, 3, 2, 41, 48, 3, 2, 49, 56, 5, 2, 13, 14, 24, 25, 60, 61, 2, 171, 2, 34, 3, 2, 2, 2, 4, 86, 3, 2, 2, 2, 6, 97, 3, 2, 2, 2, 8, 99, 3, 2, 2, 2, 10, 109, 3, 2, 2, 2, 12, 111, 3, 2, 2, 2, 14, 118, 3, 2, 2, 2, 16, 126, 3, 2, 2, 2, 18, 133, 3, 2, 2, 2, 20, 135, 3, 2, 2, 2, 22, 137, 3, 2, 2, 2, 24, 139, 3, 2, 2, 2, 26, 141, 3, 2, 2, 2, 28, 149, 3, 2, 2, 2, 30, 31, 8, 2, 1, 2, 31, 35, 5, 4, 3, 2, 32, 33, 9, 2, 2, 2, 33, 35, 5, 2, 2, 13, 34, 30, 3, 2, 2, 2, 34, 32, 3, 2, 2, 2, 35, 76, 3, 2, 2, 2, 36, 37, 12, 12, 2, 2, 37, 38, 9, 3, 2, 2, 38, 75, 5, 2, 2, 13, 39, 40, 12, 11, 2, 2, 40, 41, 9, 4, 2, 2, 41, 75, 5, 2, 2, 12, 42, 43, 12, 9, 2, 2, 43, 44, 7, 15, 2, 2, 44, 75, 5, 2, 2, 10, 45, 46, 12, 8, 2, 2, 46, 47, 9, 5, 2, 2, 47, 75, 5, 2, 2, 9, 48, 49, 12, 7, 2, 2, 49, 50, 9, 6, 2, 2, 50, 75, 5, 2, 2, 8, 51, 52, 12, 6, 2, 2, 52, 53, 9, 7, 2, 2, 53, 75, 5, 2, 2, 7, 54, 55, 12, 5, 2, 2, 55, 56, 7, 26, 2, 2, 56, 75, 5, 2, 2, 6, 57, 58, 12, 4, 2, 2, 58, 59, 9, 8, 2, 2, 59, 75, 5, 2, 2, 5, 60, 61, 12, 3, 2, 2, 61, 62, 7, 29, 2, 2, 62, 75, 5, 2, 2, 4, 63, 64, 12, 15, 2, 2, 64, 65, 7, 3, 2, 2, 65, 75, 5, 10, 6, 2, 66, 67, 12, 14, 2, 2, 67, 68, 7, 4, 2, 2, 68, 69, 5, 2, 2, 2, 69, 70, 7, 5, 2, 2, 70, 75, 3, 2, 2, 2, 71, 72, 12, 10, 2, 2, 72, 73, 9, 9, 2, 2, 73, 75, 5, 24, 13, 2, 74, 36, 3, 2, 2, 2, 74, 39, 3, 2, 2, 2, 74, 42, 3, 2, 2, 2, 74, 45, 3, 2, 2, 2, 74, 48, 3, 2, 2, 2, 74, 51, 3, 2, 2, 2, 74, 54, 3, 2, 2, 2, 74, 57, 3, 2, 2, 2, 74, 60, 3, 2, 2, 2, 74, 63, 3, 2, 2, 2, 74, 66, 3, 2, 2, 2, 74, 71, 3, 2, 2, 2, 75, 78, 3, 2, 2, 2, 76, 74, 3, 2, 2, 2, 76, 77, 3, 2, 2, 2, 77, 3, 3, 2, 2, 2, 78, 76, 3, 2, 2, 2, 79, 87, 5, 10, 6, 2, 80, 87, 5, 6, 4, 2, 81, 87, 5, 8, 5, 2, 82, 83, 7, 30, 2, 2, 83, 84, 5, 2, 2, 2, 84, 85, 7, 31, 2, 2, 85, 87, 3, 2, 2, 2, 86, 79, 3, 2, 2, 2, 86, 80, 3, 2, 2, 2, 86, 81, 3, 2, 2, 2, 86, 82, 3, 2, 2, 2, 87, 5, 3, 2, 2, 2, 88, 89, 7, 32, 2, 2, 89, 98, 7, 33, 2, 2, 90, 98, 9, 10, 2, 2, 91, 98, 7, 62, 2, 2, 92, 98, 7, 63, 2, 2, 93, 98, 7, 57, 2, 2, 94, 98, 7, 58, 2, 2, 95, 98, 7, 59, 2, 2, 96, 98, 5, 16, 9, 2, 97, 88, 3, 2, 2, 2, 97, 90, 3, 2, 2, 2, 97, 91, 3, 2, 2, 2, 97, 92, 3, 2, 2, 2, 97, 93, 3, 2, 2, 2, 97, 94, 3, 2, 2, 2, 97, 95, 3, 2, 2, 2, 97, 96, 3, 2, 2, 2, 98, 7, 3, 2, 2, 2, 99, 102, 7, 36, 2, 2, 100, 103, 5, 28, 15, 2, 101, 103, 7, 62, 2, 2, 102, 100, 3, 2, 2, 2, 102, 101, 3, 2, 2, 2, 103, 9, 3, 2, 2, 2, 104, 110, 5, 28, 15, 2, 105, 110, 5, 12, 7, 2, 106, 110, 7, 37, 2, 2, 107, 110, 7, 38, 2, 2, 108, 110, 7, 39, 2, 2, 109, 104, 3, 2, 2, 2, 109, 105, 3, 2, 2, 2, 109, 106, 3, 2, 2, 2, 109, 107, 3, 2, 2, 2, 109, 108, 3, 2, 2, 2, 110, 11, 3, 2, 2, 2, 111, 112, 5, 28, 15, 2, 112, 114, 7, 30, 2, 2, 113, 115, 5, 14, 8, 2, 114, 113, 3, 2, 2, 2, 114, 115, 3, 2, 2, 2, 115, 116, 3, 2, 2, 2, 116, 117, 7, 31, 2, 2, 117, 13, 3, 2, 2, 2, 118, 123, 5, 2, 2, 2, 119, 120, 7, 40, 2, 2, 120, 122, 5, 2, 2, 2, 121, 119, 3, 2, 2, 2, 122, 125, 3, 2, 2, 2, 123, 121, 3, 2, 2, 2, 123, 124, 3, 2, 2, 2, 124, 15, 3, 2, 2, 2, 125, 123, 3, 2, 2, 2, 126, 128, 7, 63, 2, 2, 127, 129, 5, 18, 10, 2, 128, 127, 3, 2, 2, 2, 128, 129, 3, 2, 2, 2, 129, 17, 3, 2, 2, 2, 130, 134, 5, 20, 11, 2, 131, 134, 5, 22, 12, 2, 132, 134, 7, 62, 2, 2, 133, 130, 3, 2, 2, 2, 133, 131, 3, 2, 2, 2, 133, 132, 3, 2, 2, 2, 134, 19, 3, 2, 2, 2, 135, 136, 9, 11, 2, 2, 136, 21, 3, 2, 2, 2, 137, 138, 9, 12, 2, 2, 138, 23, 3, 2, 2, 2, 139, 140, 5, 26, 14, 2, 140, 25, 3, 2, 2, 2, 141, 146, 5, 28, 15, 2, 142, 143, 7, 3, 2, 2, 143, 145, 5, 28, 15, 2, 144, 142, 3, 2, 2, 2, 145, 148, 3, 2, 2, 2, 146, 144, 3, 2, 2, 2, 146, 147, 3, 2, 2, 2, 147, 27, 3, 2, 2, 2, 148, 146, 3, 2, 2, 2, 149, 150, 9, 13, 2, 2, 150, 29, 3, 2, 2, 2, 14, 34, 74, 76, 86, 97, 102, 109, 114, 123, 128, 133, 146] \ No newline at end of file diff --git a/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPath.tokens b/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPath.tokens index 0fe45617b71..38c5116464f 100644 --- a/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPath.tokens +++ b/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPath.tokens @@ -52,15 +52,16 @@ T__50=51 T__51=52 T__52=53 T__53=54 -DATETIME=55 -TIME=56 -IDENTIFIER=57 -DELIMITEDIDENTIFIER=58 -STRING=59 -NUMBER=60 -WS=61 -COMMENT=62 -LINE_COMMENT=63 +DATE=55 +DATETIME=56 +TIME=57 +IDENTIFIER=58 +DELIMITEDIDENTIFIER=59 +STRING=60 +NUMBER=61 +WS=62 +COMMENT=63 +LINE_COMMENT=64 '.'=1 '['=2 ']'=3 diff --git a/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathAbstractNode.java b/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathAbstractNode.java index 33cd2eb1279..2b54929fac7 100644 --- a/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathAbstractNode.java +++ b/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathAbstractNode.java @@ -17,7 +17,7 @@ public abstract class FHIRPathAbstractNode implements FHIRPathNode { protected final String name; protected final String path; protected final FHIRPathType type; - protected final FHIRPathPrimitiveValue value; + protected final FHIRPathSystemValue value; protected final Collection children; protected FHIRPathAbstractNode(Builder builder) { @@ -49,7 +49,7 @@ public boolean hasValue() { } @Override - public FHIRPathPrimitiveValue getValue() { + public FHIRPathSystemValue getValue() { return value; } @@ -87,7 +87,7 @@ public static abstract class Builder implements FHIRPathNode.Builder { // optional protected String name; protected String path; - protected FHIRPathPrimitiveValue value; + protected FHIRPathSystemValue value; protected Collection children = new ArrayList<>(); protected Builder(FHIRPathType type) { @@ -108,7 +108,7 @@ public Builder path(String path) { } @Override - public Builder value(FHIRPathPrimitiveValue value) { + public Builder value(FHIRPathSystemValue value) { children.remove(this.value); this.value = value; children.add(this.value); diff --git a/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathBaseVisitor.java b/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathBaseVisitor.java index 76ae4bc1f88..e01099c8aa0 100644 --- a/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathBaseVisitor.java +++ b/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathBaseVisitor.java @@ -1,498 +1,301 @@ -/* - * (C) Copyright IBM Corp. 2019 - * - * SPDX-License-Identifier: Apache-2.0 - */ - +// Generated from FHIRPath.g4 by ANTLR 4.7.2 package com.ibm.fhir.model.path; - import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor; /** - * This class provides an empty implementation of {@link FHIRPathVisitor}, which can be extended to create a visitor - * which only needs to handle a subset of the available methods. + * This class provides an empty implementation of {@link FHIRPathVisitor}, + * which can be extended to create a visitor which only needs to handle a subset + * of the available methods. * - * @param - * The return type of the visit operation. Use {@link Void} for operations with no return type. + * @param The return type of the visit operation. Use {@link Void} for + * operations with no return type. */ public class FHIRPathBaseVisitor extends AbstractParseTreeVisitor implements FHIRPathVisitor { /** * {@inheritDoc} * - *

- * The default implementation returns the result of calling {@link #visitChildren} on {@code ctx}. - *

+ *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

*/ - @Override - public T visitIndexerExpression(FHIRPathParser.IndexerExpressionContext ctx) { - return visitChildren(ctx); - } - + @Override public T visitIndexerExpression(FHIRPathParser.IndexerExpressionContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * - *

- * The default implementation returns the result of calling {@link #visitChildren} on {@code ctx}. - *

+ *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

*/ - @Override - public T visitPolarityExpression(FHIRPathParser.PolarityExpressionContext ctx) { - return visitChildren(ctx); - } - + @Override public T visitPolarityExpression(FHIRPathParser.PolarityExpressionContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * - *

- * The default implementation returns the result of calling {@link #visitChildren} on {@code ctx}. - *

+ *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

*/ - @Override - public T visitAdditiveExpression(FHIRPathParser.AdditiveExpressionContext ctx) { - return visitChildren(ctx); - } - + @Override public T visitAdditiveExpression(FHIRPathParser.AdditiveExpressionContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * - *

- * The default implementation returns the result of calling {@link #visitChildren} on {@code ctx}. - *

+ *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

*/ - @Override - public T visitMultiplicativeExpression(FHIRPathParser.MultiplicativeExpressionContext ctx) { - return visitChildren(ctx); - } - + @Override public T visitMultiplicativeExpression(FHIRPathParser.MultiplicativeExpressionContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * - *

- * The default implementation returns the result of calling {@link #visitChildren} on {@code ctx}. - *

+ *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

*/ - @Override - public T visitUnionExpression(FHIRPathParser.UnionExpressionContext ctx) { - return visitChildren(ctx); - } - + @Override public T visitUnionExpression(FHIRPathParser.UnionExpressionContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * - *

- * The default implementation returns the result of calling {@link #visitChildren} on {@code ctx}. - *

+ *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

*/ - @Override - public T visitOrExpression(FHIRPathParser.OrExpressionContext ctx) { - return visitChildren(ctx); - } - + @Override public T visitOrExpression(FHIRPathParser.OrExpressionContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * - *

- * The default implementation returns the result of calling {@link #visitChildren} on {@code ctx}. - *

+ *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

*/ - @Override - public T visitAndExpression(FHIRPathParser.AndExpressionContext ctx) { - return visitChildren(ctx); - } - + @Override public T visitAndExpression(FHIRPathParser.AndExpressionContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * - *

- * The default implementation returns the result of calling {@link #visitChildren} on {@code ctx}. - *

+ *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

*/ - @Override - public T visitMembershipExpression(FHIRPathParser.MembershipExpressionContext ctx) { - return visitChildren(ctx); - } - + @Override public T visitMembershipExpression(FHIRPathParser.MembershipExpressionContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * - *

- * The default implementation returns the result of calling {@link #visitChildren} on {@code ctx}. - *

+ *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

*/ - @Override - public T visitInequalityExpression(FHIRPathParser.InequalityExpressionContext ctx) { - return visitChildren(ctx); - } - + @Override public T visitInequalityExpression(FHIRPathParser.InequalityExpressionContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * - *

- * The default implementation returns the result of calling {@link #visitChildren} on {@code ctx}. - *

+ *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

*/ - @Override - public T visitInvocationExpression(FHIRPathParser.InvocationExpressionContext ctx) { - return visitChildren(ctx); - } - + @Override public T visitInvocationExpression(FHIRPathParser.InvocationExpressionContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * - *

- * The default implementation returns the result of calling {@link #visitChildren} on {@code ctx}. - *

+ *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

*/ - @Override - public T visitEqualityExpression(FHIRPathParser.EqualityExpressionContext ctx) { - return visitChildren(ctx); - } - + @Override public T visitEqualityExpression(FHIRPathParser.EqualityExpressionContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * - *

- * The default implementation returns the result of calling {@link #visitChildren} on {@code ctx}. - *

+ *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

*/ - @Override - public T visitImpliesExpression(FHIRPathParser.ImpliesExpressionContext ctx) { - return visitChildren(ctx); - } - + @Override public T visitImpliesExpression(FHIRPathParser.ImpliesExpressionContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * - *

- * The default implementation returns the result of calling {@link #visitChildren} on {@code ctx}. - *

+ *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

*/ - @Override - public T visitTermExpression(FHIRPathParser.TermExpressionContext ctx) { - return visitChildren(ctx); - } - + @Override public T visitTermExpression(FHIRPathParser.TermExpressionContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * - *

- * The default implementation returns the result of calling {@link #visitChildren} on {@code ctx}. - *

+ *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

*/ - @Override - public T visitTypeExpression(FHIRPathParser.TypeExpressionContext ctx) { - return visitChildren(ctx); - } - + @Override public T visitTypeExpression(FHIRPathParser.TypeExpressionContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * - *

- * The default implementation returns the result of calling {@link #visitChildren} on {@code ctx}. - *

+ *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

*/ - @Override - public T visitInvocationTerm(FHIRPathParser.InvocationTermContext ctx) { - return visitChildren(ctx); - } - + @Override public T visitInvocationTerm(FHIRPathParser.InvocationTermContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * - *

- * The default implementation returns the result of calling {@link #visitChildren} on {@code ctx}. - *

+ *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

*/ - @Override - public T visitLiteralTerm(FHIRPathParser.LiteralTermContext ctx) { - return visitChildren(ctx); - } - + @Override public T visitLiteralTerm(FHIRPathParser.LiteralTermContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * - *

- * The default implementation returns the result of calling {@link #visitChildren} on {@code ctx}. - *

+ *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

*/ - @Override - public T visitExternalConstantTerm(FHIRPathParser.ExternalConstantTermContext ctx) { - return visitChildren(ctx); - } - + @Override public T visitExternalConstantTerm(FHIRPathParser.ExternalConstantTermContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * - *

- * The default implementation returns the result of calling {@link #visitChildren} on {@code ctx}. - *

+ *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

*/ - @Override - public T visitParenthesizedTerm(FHIRPathParser.ParenthesizedTermContext ctx) { - return visitChildren(ctx); - } - + @Override public T visitParenthesizedTerm(FHIRPathParser.ParenthesizedTermContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * - *

- * The default implementation returns the result of calling {@link #visitChildren} on {@code ctx}. - *

+ *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

*/ - @Override - public T visitNullLiteral(FHIRPathParser.NullLiteralContext ctx) { - return visitChildren(ctx); - } - + @Override public T visitNullLiteral(FHIRPathParser.NullLiteralContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * - *

- * The default implementation returns the result of calling {@link #visitChildren} on {@code ctx}. - *

+ *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

*/ - @Override - public T visitBooleanLiteral(FHIRPathParser.BooleanLiteralContext ctx) { - return visitChildren(ctx); - } - + @Override public T visitBooleanLiteral(FHIRPathParser.BooleanLiteralContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * - *

- * The default implementation returns the result of calling {@link #visitChildren} on {@code ctx}. - *

+ *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

*/ - @Override - public T visitStringLiteral(FHIRPathParser.StringLiteralContext ctx) { - return visitChildren(ctx); - } - + @Override public T visitStringLiteral(FHIRPathParser.StringLiteralContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * - *

- * The default implementation returns the result of calling {@link #visitChildren} on {@code ctx}. - *

+ *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

*/ - @Override - public T visitNumberLiteral(FHIRPathParser.NumberLiteralContext ctx) { - return visitChildren(ctx); - } - + @Override public T visitNumberLiteral(FHIRPathParser.NumberLiteralContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * - *

- * The default implementation returns the result of calling {@link #visitChildren} on {@code ctx}. - *

+ *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

*/ - @Override - public T visitDateTimeLiteral(FHIRPathParser.DateTimeLiteralContext ctx) { - return visitChildren(ctx); - } - + @Override public T visitDateLiteral(FHIRPathParser.DateLiteralContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * - *

- * The default implementation returns the result of calling {@link #visitChildren} on {@code ctx}. - *

+ *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

*/ - @Override - public T visitTimeLiteral(FHIRPathParser.TimeLiteralContext ctx) { - return visitChildren(ctx); - } - + @Override public T visitDateTimeLiteral(FHIRPathParser.DateTimeLiteralContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * - *

- * The default implementation returns the result of calling {@link #visitChildren} on {@code ctx}. - *

+ *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

*/ - @Override - public T visitQuantityLiteral(FHIRPathParser.QuantityLiteralContext ctx) { - return visitChildren(ctx); - } - + @Override public T visitTimeLiteral(FHIRPathParser.TimeLiteralContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * - *

- * The default implementation returns the result of calling {@link #visitChildren} on {@code ctx}. - *

+ *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

*/ - @Override - public T visitExternalConstant(FHIRPathParser.ExternalConstantContext ctx) { - return visitChildren(ctx); - } - + @Override public T visitQuantityLiteral(FHIRPathParser.QuantityLiteralContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * - *

- * The default implementation returns the result of calling {@link #visitChildren} on {@code ctx}. - *

+ *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

*/ - @Override - public T visitMemberInvocation(FHIRPathParser.MemberInvocationContext ctx) { - return visitChildren(ctx); - } - + @Override public T visitExternalConstant(FHIRPathParser.ExternalConstantContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * - *

- * The default implementation returns the result of calling {@link #visitChildren} on {@code ctx}. - *

+ *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

*/ - @Override - public T visitFunctionInvocation(FHIRPathParser.FunctionInvocationContext ctx) { - return visitChildren(ctx); - } - + @Override public T visitMemberInvocation(FHIRPathParser.MemberInvocationContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * - *

- * The default implementation returns the result of calling {@link #visitChildren} on {@code ctx}. - *

+ *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

*/ - @Override - public T visitThisInvocation(FHIRPathParser.ThisInvocationContext ctx) { - return visitChildren(ctx); - } - + @Override public T visitFunctionInvocation(FHIRPathParser.FunctionInvocationContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * - *

- * The default implementation returns the result of calling {@link #visitChildren} on {@code ctx}. - *

+ *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

*/ - @Override - public T visitIndexInvocation(FHIRPathParser.IndexInvocationContext ctx) { - return visitChildren(ctx); - } - + @Override public T visitThisInvocation(FHIRPathParser.ThisInvocationContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * - *

- * The default implementation returns the result of calling {@link #visitChildren} on {@code ctx}. - *

+ *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

*/ - @Override - public T visitTotalInvocation(FHIRPathParser.TotalInvocationContext ctx) { - return visitChildren(ctx); - } - + @Override public T visitIndexInvocation(FHIRPathParser.IndexInvocationContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * - *

- * The default implementation returns the result of calling {@link #visitChildren} on {@code ctx}. - *

+ *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

*/ - @Override - public T visitFunction(FHIRPathParser.FunctionContext ctx) { - return visitChildren(ctx); - } - + @Override public T visitTotalInvocation(FHIRPathParser.TotalInvocationContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * - *

- * The default implementation returns the result of calling {@link #visitChildren} on {@code ctx}. - *

+ *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

*/ - @Override - public T visitParamList(FHIRPathParser.ParamListContext ctx) { - return visitChildren(ctx); - } - + @Override public T visitFunction(FHIRPathParser.FunctionContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * - *

- * The default implementation returns the result of calling {@link #visitChildren} on {@code ctx}. - *

+ *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

*/ - @Override - public T visitQuantity(FHIRPathParser.QuantityContext ctx) { - return visitChildren(ctx); - } - + @Override public T visitParamList(FHIRPathParser.ParamListContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * - *

- * The default implementation returns the result of calling {@link #visitChildren} on {@code ctx}. - *

+ *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

*/ - @Override - public T visitUnit(FHIRPathParser.UnitContext ctx) { - return visitChildren(ctx); - } - + @Override public T visitQuantity(FHIRPathParser.QuantityContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * - *

- * The default implementation returns the result of calling {@link #visitChildren} on {@code ctx}. - *

+ *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

*/ - @Override - public T visitDateTimePrecision(FHIRPathParser.DateTimePrecisionContext ctx) { - return visitChildren(ctx); - } - + @Override public T visitUnit(FHIRPathParser.UnitContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * - *

- * The default implementation returns the result of calling {@link #visitChildren} on {@code ctx}. - *

+ *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

*/ - @Override - public T visitPluralDateTimePrecision(FHIRPathParser.PluralDateTimePrecisionContext ctx) { - return visitChildren(ctx); - } - + @Override public T visitDateTimePrecision(FHIRPathParser.DateTimePrecisionContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * - *

- * The default implementation returns the result of calling {@link #visitChildren} on {@code ctx}. - *

+ *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

*/ - @Override - public T visitTypeSpecifier(FHIRPathParser.TypeSpecifierContext ctx) { - return visitChildren(ctx); - } - + @Override public T visitPluralDateTimePrecision(FHIRPathParser.PluralDateTimePrecisionContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * - *

- * The default implementation returns the result of calling {@link #visitChildren} on {@code ctx}. - *

+ *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

*/ - @Override - public T visitQualifiedIdentifier(FHIRPathParser.QualifiedIdentifierContext ctx) { - return visitChildren(ctx); - } - + @Override public T visitTypeSpecifier(FHIRPathParser.TypeSpecifierContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitQualifiedIdentifier(FHIRPathParser.QualifiedIdentifierContext ctx) { return visitChildren(ctx); } /** * {@inheritDoc} * - *

- * The default implementation returns the result of calling {@link #visitChildren} on {@code ctx}. - *

+ *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

*/ - @Override - public T visitIdentifier(FHIRPathParser.IdentifierContext ctx) { - return visitChildren(ctx); - } -} + @Override public T visitIdentifier(FHIRPathParser.IdentifierContext ctx) { return visitChildren(ctx); } +} \ No newline at end of file diff --git a/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathBooleanValue.java b/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathBooleanValue.java index 78e66b6faff..f44381196e6 100644 --- a/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathBooleanValue.java +++ b/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathBooleanValue.java @@ -11,7 +11,7 @@ import com.ibm.fhir.model.path.visitor.FHIRPathNodeVisitor; -public class FHIRPathBooleanValue extends FHIRPathAbstractNode implements FHIRPathPrimitiveValue { +public class FHIRPathBooleanValue extends FHIRPathAbstractNode implements FHIRPathSystemValue { public static final FHIRPathBooleanValue TRUE = FHIRPathBooleanValue.booleanValue(true); public static final FHIRPathBooleanValue FALSE = FHIRPathBooleanValue.booleanValue(false); @@ -75,7 +75,7 @@ public Builder path(String path) { } @Override - public Builder value(FHIRPathPrimitiveValue value) { + public Builder value(FHIRPathSystemValue value) { return this; } @@ -164,7 +164,7 @@ public String toString() { } @Override - public void accept(T param, FHIRPathNodeVisitor visitor) { - visitor.visit(param, this); + public void accept(FHIRPathNodeVisitor visitor) { + visitor.visit(this); } } diff --git a/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathDateTimeValue.java b/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathDateTimeValue.java index 952073c1c12..dd9f051820b 100644 --- a/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathDateTimeValue.java +++ b/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathDateTimeValue.java @@ -25,7 +25,7 @@ import com.ibm.fhir.model.path.visitor.FHIRPathNodeVisitor; -public class FHIRPathDateTimeValue extends FHIRPathAbstractNode implements FHIRPathPrimitiveValue { +public class FHIRPathDateTimeValue extends FHIRPathAbstractNode implements FHIRPathTemporalValue { private static final DateTimeFormatter DATE_TIME_PARSER_FORMATTER = new DateTimeFormatterBuilder() .appendPattern("yyyy") .optionalStart() @@ -44,10 +44,12 @@ public class FHIRPathDateTimeValue extends FHIRPathAbstractNode implements FHIRP .toFormatter(); private final TemporalAccessor dateTime; + private final Temporal temporal; protected FHIRPathDateTimeValue(Builder builder) { super(builder); dateTime = builder.dateTime; + temporal = getTemporal(dateTime); } @Override @@ -63,6 +65,11 @@ public TemporalAccessor dateTime() { return dateTime; } + @Override + public Temporal temporal() { + return temporal; + } + public static FHIRPathDateTimeValue dateTimeValue(String dateTime) { return FHIRPathDateTimeValue.builder(DATE_TIME_PARSER_FORMATTER.parseBest(dateTime, ZonedDateTime::from, LocalDate::from, YearMonth::from, Year::from)).build(); } @@ -103,7 +110,7 @@ public Builder path(String path) { } @Override - public Builder value(FHIRPathPrimitiveValue value) { + public Builder value(FHIRPathSystemValue value) { return this; } @@ -123,15 +130,17 @@ public FHIRPathDateTimeValue build() { } } - public FHIRPathDateTimeValue add(FHIRPathQuantityNode quantityNode) { + @Override + public FHIRPathDateTimeValue add(FHIRPathQuantityValue quantityValue) { Temporal temporal = getTemporal(dateTime); - TemporalAmount temporalAmount = getTemporalAmount(quantityNode); + TemporalAmount temporalAmount = getTemporalAmount(quantityValue); return dateTimeValue(getTemporalAccessor(temporal.plus(temporalAmount), dateTime.getClass())); } - public FHIRPathDateTimeValue subtract(FHIRPathQuantityNode quantityNode) { + @Override + public FHIRPathDateTimeValue subtract(FHIRPathQuantityValue quantityValue) { Temporal temporal = getTemporal(dateTime); - TemporalAmount temporalAmount = getTemporalAmount(quantityNode); + TemporalAmount temporalAmount = getTemporalAmount(quantityValue); return dateTimeValue(getTemporalAccessor(temporal.minus(temporalAmount), dateTime.getClass())); } @@ -201,7 +210,7 @@ public static void main(String[] args) { } @Override - public void accept(T param, FHIRPathNodeVisitor visitor) { - visitor.visit(param, this); + public void accept(FHIRPathNodeVisitor visitor) { + visitor.visit(this); } } diff --git a/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathDateValue.java b/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathDateValue.java new file mode 100644 index 00000000000..2598c6ddbd6 --- /dev/null +++ b/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathDateValue.java @@ -0,0 +1,204 @@ +/* + * (C) Copyright IBM Corp. 2019 + * + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.ibm.fhir.model.path; + +import static com.ibm.fhir.model.path.util.FHIRPathUtil.getTemporal; +import static com.ibm.fhir.model.path.util.FHIRPathUtil.getTemporalAccessor; +import static com.ibm.fhir.model.path.util.FHIRPathUtil.getTemporalAmount; + +import java.time.LocalDate; +import java.time.Year; +import java.time.YearMonth; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeFormatterBuilder; +import java.time.temporal.Temporal; +import java.time.temporal.TemporalAccessor; +import java.time.temporal.TemporalAmount; +import java.util.Collection; +import java.util.Objects; + +import com.ibm.fhir.model.path.visitor.FHIRPathNodeVisitor; + +public class FHIRPathDateValue extends FHIRPathAbstractNode implements FHIRPathTemporalValue { + private static final DateTimeFormatter DATE_PARSER_FORMATTER = new DateTimeFormatterBuilder() + .appendPattern("yyyy") + .optionalStart() + .appendPattern("-MM") + .optionalStart() + .appendPattern("-dd") + .optionalEnd() + .optionalEnd() + .toFormatter(); + + private final TemporalAccessor date; + private final Temporal temporal; + + protected FHIRPathDateValue(Builder builder) { + super(builder); + date = builder.date; + temporal = getTemporal(date); + } + + @Override + public boolean isDateValue() { + return true; + } + + public boolean isPartial() { + return !(date instanceof LocalDate); + } + + public TemporalAccessor date() { + return date; + } + + @Override + public Temporal temporal() { + return temporal; + } + + public static FHIRPathDateValue dateValue(String date) { + return FHIRPathDateValue.builder(DATE_PARSER_FORMATTER.parseBest(date, LocalDate::from, YearMonth::from, Year::from)).build(); + } + + public static FHIRPathDateValue dateValue(TemporalAccessor date) { + return FHIRPathDateValue.builder(date).build(); + } + + public static FHIRPathDateValue dateValue(String name, TemporalAccessor date) { + return FHIRPathDateValue.builder(date).name(name).build(); + } + + @Override + public Builder toBuilder() { + return new Builder(type, date); + } + + public static Builder builder(TemporalAccessor dateTime) { + return new Builder(FHIRPathType.SYSTEM_DATE_TIME, dateTime); + } + + public static class Builder extends FHIRPathAbstractNode.Builder { + private final TemporalAccessor date; + + private Builder(FHIRPathType type, TemporalAccessor dateTime) { + super(type); + this.date = dateTime; + } + + @Override + public Builder name(String name) { + return (Builder) super.name(name); + } + + @Override + public Builder path(String path) { + return (Builder) super.path(path); + } + + @Override + public Builder value(FHIRPathSystemValue value) { + return this; + } + + @Override + public Builder children(FHIRPathNode... children) { + return this; + } + + @Override + public Builder children(Collection children) { + return this; + } + + @Override + public FHIRPathDateValue build() { + return new FHIRPathDateValue(this); + } + } + + @Override + public FHIRPathDateValue add(FHIRPathQuantityValue quantityValue) { + Temporal temporal = getTemporal(date); + TemporalAmount temporalAmount = getTemporalAmount(quantityValue); + return dateValue(getTemporalAccessor(temporal.plus(temporalAmount), date.getClass())); + } + + @Override + public FHIRPathDateValue subtract(FHIRPathQuantityValue quantityValue) { + Temporal temporal = getTemporal(date); + TemporalAmount temporalAmount = getTemporalAmount(quantityValue); + return dateValue(getTemporalAccessor(temporal.minus(temporalAmount), date.getClass())); + } + + @Override + public boolean isComparableTo(FHIRPathNode other) { + return other instanceof FHIRPathDateValue || + other.getValue() instanceof FHIRPathDateValue; + } + + @Override + public int compareTo(FHIRPathNode other) { + if (!isComparableTo(other)) { + throw new IllegalArgumentException(); + } + if (other instanceof FHIRPathDateValue) { + return compareTo((FHIRPathDateValue) other); + } + return compareTo((FHIRPathDateValue) other.getValue()); + } + + private int compareTo(FHIRPathDateValue value) { + if (date instanceof Year || value.date instanceof Year) { + return Year.from(date).compareTo(Year.from(value.date)); + } + if (date instanceof YearMonth || value.date instanceof YearMonth) { + return YearMonth.from(date).compareTo(YearMonth.from(value.date)); + } + return LocalDate.from(date).compareTo(LocalDate.from(value.date)); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (!(obj instanceof FHIRPathNode)) { + return false; + } + FHIRPathNode other = (FHIRPathNode) obj; + if (other instanceof FHIRPathDateValue) { + return Objects.equals(date, ((FHIRPathDateValue) other).date()); + } + if (other.getValue() instanceof FHIRPathElementNode) { + return Objects.equals(date, ((FHIRPathDateValue) other.getValue()).date()); + } + return false; + } + + @Override + public int hashCode() { + return Objects.hashCode(date); + } + + @Override + public String toString() { + return DATE_PARSER_FORMATTER.format(date); + } + + public static void main(String[] args) { + System.out.println(LocalDate.from(Year.now())); + } + + @Override + public void accept(FHIRPathNodeVisitor visitor) { + visitor.visit(this); + } +} diff --git a/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathDecimalValue.java b/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathDecimalValue.java index f48487bbe73..15f3cf952fb 100644 --- a/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathDecimalValue.java +++ b/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathDecimalValue.java @@ -71,7 +71,7 @@ public Builder path(String path) { } @Override - public Builder value(FHIRPathPrimitiveValue value) { + public Builder value(FHIRPathSystemValue value) { return this; } @@ -163,7 +163,7 @@ public String toString() { } @Override - public void accept(T param, FHIRPathNodeVisitor visitor) { - visitor.visit(param, this); + public void accept(FHIRPathNodeVisitor visitor) { + visitor.visit(this); } } diff --git a/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathElementNode.java b/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathElementNode.java index d76844b2a7e..be824237b2d 100644 --- a/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathElementNode.java +++ b/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathElementNode.java @@ -75,7 +75,7 @@ public Builder path(String path) { return (Builder) super.path(path); } - public Builder value(FHIRPathPrimitiveValue value) { + public Builder value(FHIRPathSystemValue value) { return (Builder) super.value(value); } @@ -96,7 +96,7 @@ public FHIRPathElementNode build() { @Override public boolean isComparableTo(FHIRPathNode other) { if (hasValue()) { - if (other instanceof FHIRPathPrimitiveValue) { + if (other instanceof FHIRPathSystemValue) { return getValue().isComparableTo(other); } if (other.hasValue()) { @@ -111,7 +111,7 @@ public int compareTo(FHIRPathNode other) { if (!isComparableTo(other)) { throw new IllegalArgumentException(); } - if (other instanceof FHIRPathPrimitiveValue) { + if (other instanceof FHIRPathSystemValue) { return getValue().compareTo(other); } return getValue().compareTo(other.getValue()); @@ -130,8 +130,8 @@ public boolean equals(Object obj) { } FHIRPathNode other = (FHIRPathNode) obj; if (hasValue()) { - if (other instanceof FHIRPathPrimitiveValue) { - return getValue().equals((FHIRPathPrimitiveValue) other); + if (other instanceof FHIRPathSystemValue) { + return getValue().equals((FHIRPathSystemValue) other); } if (other.hasValue()) { return getValue().equals(other.getValue()); @@ -148,6 +148,7 @@ public int hashCode() { return Objects.hashCode(element); } + @Override public String toString() { if (hasValue()) { return "FHIRPathElementNode: [type: " + type() + ", value: " + value.toString() + "]"; @@ -156,7 +157,7 @@ public String toString() { } @Override - public void accept(T param, FHIRPathNodeVisitor visitor) { - visitor.visit(param, this); + public void accept(FHIRPathNodeVisitor visitor) { + visitor.visit(this); } } diff --git a/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathIntegerValue.java b/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathIntegerValue.java index 8012892a990..811eb178144 100644 --- a/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathIntegerValue.java +++ b/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathIntegerValue.java @@ -72,7 +72,7 @@ public Builder path(String path) { } @Override - public Builder value(FHIRPathPrimitiveValue value) { + public Builder value(FHIRPathSystemValue value) { return this; } @@ -182,7 +182,7 @@ public String toString() { } @Override - public void accept(T param, FHIRPathNodeVisitor visitor) { - visitor.visit(param, this); + public void accept(FHIRPathNodeVisitor visitor) { + visitor.visit(this); } } diff --git a/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathLexer.interp b/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathLexer.interp new file mode 100644 index 00000000000..f757765fd57 --- /dev/null +++ b/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathLexer.interp @@ -0,0 +1,215 @@ +token literal names: +null +'.' +'[' +']' +'+' +'-' +'*' +'/' +'div' +'mod' +'&' +'is' +'as' +'|' +'<=' +'<' +'>' +'>=' +'=' +'~' +'!=' +'!~' +'in' +'contains' +'and' +'or' +'xor' +'implies' +'(' +')' +'{' +'}' +'true' +'false' +'%' +'$this' +'$index' +'$total' +',' +'year' +'month' +'week' +'day' +'hour' +'minute' +'second' +'millisecond' +'years' +'months' +'weeks' +'days' +'hours' +'minutes' +'seconds' +'milliseconds' +null +null +null +null +null +null +null +null +null +null + +token symbolic names: +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +null +DATE +DATETIME +TIME +IDENTIFIER +DELIMITEDIDENTIFIER +STRING +NUMBER +WS +COMMENT +LINE_COMMENT + +rule names: +T__0 +T__1 +T__2 +T__3 +T__4 +T__5 +T__6 +T__7 +T__8 +T__9 +T__10 +T__11 +T__12 +T__13 +T__14 +T__15 +T__16 +T__17 +T__18 +T__19 +T__20 +T__21 +T__22 +T__23 +T__24 +T__25 +T__26 +T__27 +T__28 +T__29 +T__30 +T__31 +T__32 +T__33 +T__34 +T__35 +T__36 +T__37 +T__38 +T__39 +T__40 +T__41 +T__42 +T__43 +T__44 +T__45 +T__46 +T__47 +T__48 +T__49 +T__50 +T__51 +T__52 +T__53 +DATE +DATETIME +TIME +DATEFORMAT +TIMEFORMAT +TIMEZONEOFFSETFORMAT +IDENTIFIER +DELIMITEDIDENTIFIER +STRING +NUMBER +WS +COMMENT +LINE_COMMENT +ESC +UNICODE +HEX + +channel names: +DEFAULT_TOKEN_CHANNEL +HIDDEN + +mode names: +DEFAULT_MODE + +atn: +[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 66, 525, 8, 1, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, 18, 9, 18, 4, 19, 9, 19, 4, 20, 9, 20, 4, 21, 9, 21, 4, 22, 9, 22, 4, 23, 9, 23, 4, 24, 9, 24, 4, 25, 9, 25, 4, 26, 9, 26, 4, 27, 9, 27, 4, 28, 9, 28, 4, 29, 9, 29, 4, 30, 9, 30, 4, 31, 9, 31, 4, 32, 9, 32, 4, 33, 9, 33, 4, 34, 9, 34, 4, 35, 9, 35, 4, 36, 9, 36, 4, 37, 9, 37, 4, 38, 9, 38, 4, 39, 9, 39, 4, 40, 9, 40, 4, 41, 9, 41, 4, 42, 9, 42, 4, 43, 9, 43, 4, 44, 9, 44, 4, 45, 9, 45, 4, 46, 9, 46, 4, 47, 9, 47, 4, 48, 9, 48, 4, 49, 9, 49, 4, 50, 9, 50, 4, 51, 9, 51, 4, 52, 9, 52, 4, 53, 9, 53, 4, 54, 9, 54, 4, 55, 9, 55, 4, 56, 9, 56, 4, 57, 9, 57, 4, 58, 9, 58, 4, 59, 9, 59, 4, 60, 9, 60, 4, 61, 9, 61, 4, 62, 9, 62, 4, 63, 9, 63, 4, 64, 9, 64, 4, 65, 9, 65, 4, 66, 9, 66, 4, 67, 9, 67, 4, 68, 9, 68, 4, 69, 9, 69, 4, 70, 9, 70, 4, 71, 9, 71, 3, 2, 3, 2, 3, 3, 3, 3, 3, 4, 3, 4, 3, 5, 3, 5, 3, 6, 3, 6, 3, 7, 3, 7, 3, 8, 3, 8, 3, 9, 3, 9, 3, 9, 3, 9, 3, 10, 3, 10, 3, 10, 3, 10, 3, 11, 3, 11, 3, 12, 3, 12, 3, 12, 3, 13, 3, 13, 3, 13, 3, 14, 3, 14, 3, 15, 3, 15, 3, 15, 3, 16, 3, 16, 3, 17, 3, 17, 3, 18, 3, 18, 3, 18, 3, 19, 3, 19, 3, 20, 3, 20, 3, 21, 3, 21, 3, 21, 3, 22, 3, 22, 3, 22, 3, 23, 3, 23, 3, 23, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 25, 3, 25, 3, 25, 3, 25, 3, 26, 3, 26, 3, 26, 3, 27, 3, 27, 3, 27, 3, 27, 3, 28, 3, 28, 3, 28, 3, 28, 3, 28, 3, 28, 3, 28, 3, 28, 3, 29, 3, 29, 3, 30, 3, 30, 3, 31, 3, 31, 3, 32, 3, 32, 3, 33, 3, 33, 3, 33, 3, 33, 3, 33, 3, 34, 3, 34, 3, 34, 3, 34, 3, 34, 3, 34, 3, 35, 3, 35, 3, 36, 3, 36, 3, 36, 3, 36, 3, 36, 3, 36, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 38, 3, 38, 3, 38, 3, 38, 3, 38, 3, 38, 3, 38, 3, 39, 3, 39, 3, 40, 3, 40, 3, 40, 3, 40, 3, 40, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 41, 3, 42, 3, 42, 3, 42, 3, 42, 3, 42, 3, 43, 3, 43, 3, 43, 3, 43, 3, 44, 3, 44, 3, 44, 3, 44, 3, 44, 3, 45, 3, 45, 3, 45, 3, 45, 3, 45, 3, 45, 3, 45, 3, 46, 3, 46, 3, 46, 3, 46, 3, 46, 3, 46, 3, 46, 3, 47, 3, 47, 3, 47, 3, 47, 3, 47, 3, 47, 3, 47, 3, 47, 3, 47, 3, 47, 3, 47, 3, 47, 3, 48, 3, 48, 3, 48, 3, 48, 3, 48, 3, 48, 3, 49, 3, 49, 3, 49, 3, 49, 3, 49, 3, 49, 3, 49, 3, 50, 3, 50, 3, 50, 3, 50, 3, 50, 3, 50, 3, 51, 3, 51, 3, 51, 3, 51, 3, 51, 3, 52, 3, 52, 3, 52, 3, 52, 3, 52, 3, 52, 3, 53, 3, 53, 3, 53, 3, 53, 3, 53, 3, 53, 3, 53, 3, 53, 3, 54, 3, 54, 3, 54, 3, 54, 3, 54, 3, 54, 3, 54, 3, 54, 3, 55, 3, 55, 3, 55, 3, 55, 3, 55, 3, 55, 3, 55, 3, 55, 3, 55, 3, 55, 3, 55, 3, 55, 3, 55, 3, 56, 3, 56, 3, 56, 3, 57, 3, 57, 3, 57, 3, 57, 3, 57, 5, 57, 388, 10, 57, 5, 57, 390, 10, 57, 3, 58, 3, 58, 3, 58, 3, 58, 3, 59, 3, 59, 3, 59, 3, 59, 3, 59, 3, 59, 3, 59, 3, 59, 3, 59, 3, 59, 5, 59, 406, 10, 59, 5, 59, 408, 10, 59, 3, 60, 3, 60, 3, 60, 3, 60, 3, 60, 3, 60, 3, 60, 3, 60, 3, 60, 3, 60, 6, 60, 420, 10, 60, 13, 60, 14, 60, 421, 5, 60, 424, 10, 60, 5, 60, 426, 10, 60, 5, 60, 428, 10, 60, 3, 61, 3, 61, 3, 61, 3, 61, 3, 61, 3, 61, 3, 61, 5, 61, 437, 10, 61, 3, 62, 5, 62, 440, 10, 62, 3, 62, 7, 62, 443, 10, 62, 12, 62, 14, 62, 446, 11, 62, 3, 63, 3, 63, 3, 63, 7, 63, 451, 10, 63, 12, 63, 14, 63, 454, 11, 63, 3, 63, 3, 63, 3, 64, 3, 64, 3, 64, 7, 64, 461, 10, 64, 12, 64, 14, 64, 464, 11, 64, 3, 64, 3, 64, 3, 65, 6, 65, 469, 10, 65, 13, 65, 14, 65, 470, 3, 65, 3, 65, 6, 65, 475, 10, 65, 13, 65, 14, 65, 476, 5, 65, 479, 10, 65, 3, 66, 6, 66, 482, 10, 66, 13, 66, 14, 66, 483, 3, 66, 3, 66, 3, 67, 3, 67, 3, 67, 3, 67, 7, 67, 492, 10, 67, 12, 67, 14, 67, 495, 11, 67, 3, 67, 3, 67, 3, 67, 3, 67, 3, 67, 3, 68, 3, 68, 3, 68, 3, 68, 7, 68, 506, 10, 68, 12, 68, 14, 68, 509, 11, 68, 3, 68, 3, 68, 3, 69, 3, 69, 3, 69, 5, 69, 516, 10, 69, 3, 70, 3, 70, 3, 70, 3, 70, 3, 70, 3, 70, 3, 71, 3, 71, 5, 452, 462, 493, 2, 72, 3, 3, 5, 4, 7, 5, 9, 6, 11, 7, 13, 8, 15, 9, 17, 10, 19, 11, 21, 12, 23, 13, 25, 14, 27, 15, 29, 16, 31, 17, 33, 18, 35, 19, 37, 20, 39, 21, 41, 22, 43, 23, 45, 24, 47, 25, 49, 26, 51, 27, 53, 28, 55, 29, 57, 30, 59, 31, 61, 32, 63, 33, 65, 34, 67, 35, 69, 36, 71, 37, 73, 38, 75, 39, 77, 40, 79, 41, 81, 42, 83, 43, 85, 44, 87, 45, 89, 46, 91, 47, 93, 48, 95, 49, 97, 50, 99, 51, 101, 52, 103, 53, 105, 54, 107, 55, 109, 56, 111, 57, 113, 58, 115, 59, 117, 2, 119, 2, 121, 2, 123, 60, 125, 61, 127, 62, 129, 63, 131, 64, 133, 65, 135, 66, 137, 2, 139, 2, 141, 2, 3, 2, 10, 3, 2, 50, 59, 4, 2, 45, 45, 47, 47, 5, 2, 67, 92, 97, 97, 99, 124, 6, 2, 50, 59, 67, 92, 97, 97, 99, 124, 5, 2, 11, 12, 15, 15, 34, 34, 4, 2, 12, 12, 15, 15, 10, 2, 41, 41, 49, 49, 94, 94, 98, 98, 104, 104, 112, 112, 116, 116, 118, 118, 5, 2, 50, 59, 67, 72, 99, 104, 2, 539, 2, 3, 3, 2, 2, 2, 2, 5, 3, 2, 2, 2, 2, 7, 3, 2, 2, 2, 2, 9, 3, 2, 2, 2, 2, 11, 3, 2, 2, 2, 2, 13, 3, 2, 2, 2, 2, 15, 3, 2, 2, 2, 2, 17, 3, 2, 2, 2, 2, 19, 3, 2, 2, 2, 2, 21, 3, 2, 2, 2, 2, 23, 3, 2, 2, 2, 2, 25, 3, 2, 2, 2, 2, 27, 3, 2, 2, 2, 2, 29, 3, 2, 2, 2, 2, 31, 3, 2, 2, 2, 2, 33, 3, 2, 2, 2, 2, 35, 3, 2, 2, 2, 2, 37, 3, 2, 2, 2, 2, 39, 3, 2, 2, 2, 2, 41, 3, 2, 2, 2, 2, 43, 3, 2, 2, 2, 2, 45, 3, 2, 2, 2, 2, 47, 3, 2, 2, 2, 2, 49, 3, 2, 2, 2, 2, 51, 3, 2, 2, 2, 2, 53, 3, 2, 2, 2, 2, 55, 3, 2, 2, 2, 2, 57, 3, 2, 2, 2, 2, 59, 3, 2, 2, 2, 2, 61, 3, 2, 2, 2, 2, 63, 3, 2, 2, 2, 2, 65, 3, 2, 2, 2, 2, 67, 3, 2, 2, 2, 2, 69, 3, 2, 2, 2, 2, 71, 3, 2, 2, 2, 2, 73, 3, 2, 2, 2, 2, 75, 3, 2, 2, 2, 2, 77, 3, 2, 2, 2, 2, 79, 3, 2, 2, 2, 2, 81, 3, 2, 2, 2, 2, 83, 3, 2, 2, 2, 2, 85, 3, 2, 2, 2, 2, 87, 3, 2, 2, 2, 2, 89, 3, 2, 2, 2, 2, 91, 3, 2, 2, 2, 2, 93, 3, 2, 2, 2, 2, 95, 3, 2, 2, 2, 2, 97, 3, 2, 2, 2, 2, 99, 3, 2, 2, 2, 2, 101, 3, 2, 2, 2, 2, 103, 3, 2, 2, 2, 2, 105, 3, 2, 2, 2, 2, 107, 3, 2, 2, 2, 2, 109, 3, 2, 2, 2, 2, 111, 3, 2, 2, 2, 2, 113, 3, 2, 2, 2, 2, 115, 3, 2, 2, 2, 2, 123, 3, 2, 2, 2, 2, 125, 3, 2, 2, 2, 2, 127, 3, 2, 2, 2, 2, 129, 3, 2, 2, 2, 2, 131, 3, 2, 2, 2, 2, 133, 3, 2, 2, 2, 2, 135, 3, 2, 2, 2, 3, 143, 3, 2, 2, 2, 5, 145, 3, 2, 2, 2, 7, 147, 3, 2, 2, 2, 9, 149, 3, 2, 2, 2, 11, 151, 3, 2, 2, 2, 13, 153, 3, 2, 2, 2, 15, 155, 3, 2, 2, 2, 17, 157, 3, 2, 2, 2, 19, 161, 3, 2, 2, 2, 21, 165, 3, 2, 2, 2, 23, 167, 3, 2, 2, 2, 25, 170, 3, 2, 2, 2, 27, 173, 3, 2, 2, 2, 29, 175, 3, 2, 2, 2, 31, 178, 3, 2, 2, 2, 33, 180, 3, 2, 2, 2, 35, 182, 3, 2, 2, 2, 37, 185, 3, 2, 2, 2, 39, 187, 3, 2, 2, 2, 41, 189, 3, 2, 2, 2, 43, 192, 3, 2, 2, 2, 45, 195, 3, 2, 2, 2, 47, 198, 3, 2, 2, 2, 49, 207, 3, 2, 2, 2, 51, 211, 3, 2, 2, 2, 53, 214, 3, 2, 2, 2, 55, 218, 3, 2, 2, 2, 57, 226, 3, 2, 2, 2, 59, 228, 3, 2, 2, 2, 61, 230, 3, 2, 2, 2, 63, 232, 3, 2, 2, 2, 65, 234, 3, 2, 2, 2, 67, 239, 3, 2, 2, 2, 69, 245, 3, 2, 2, 2, 71, 247, 3, 2, 2, 2, 73, 253, 3, 2, 2, 2, 75, 260, 3, 2, 2, 2, 77, 267, 3, 2, 2, 2, 79, 269, 3, 2, 2, 2, 81, 274, 3, 2, 2, 2, 83, 280, 3, 2, 2, 2, 85, 285, 3, 2, 2, 2, 87, 289, 3, 2, 2, 2, 89, 294, 3, 2, 2, 2, 91, 301, 3, 2, 2, 2, 93, 308, 3, 2, 2, 2, 95, 320, 3, 2, 2, 2, 97, 326, 3, 2, 2, 2, 99, 333, 3, 2, 2, 2, 101, 339, 3, 2, 2, 2, 103, 344, 3, 2, 2, 2, 105, 350, 3, 2, 2, 2, 107, 358, 3, 2, 2, 2, 109, 366, 3, 2, 2, 2, 111, 379, 3, 2, 2, 2, 113, 382, 3, 2, 2, 2, 115, 391, 3, 2, 2, 2, 117, 395, 3, 2, 2, 2, 119, 409, 3, 2, 2, 2, 121, 436, 3, 2, 2, 2, 123, 439, 3, 2, 2, 2, 125, 447, 3, 2, 2, 2, 127, 457, 3, 2, 2, 2, 129, 468, 3, 2, 2, 2, 131, 481, 3, 2, 2, 2, 133, 487, 3, 2, 2, 2, 135, 501, 3, 2, 2, 2, 137, 512, 3, 2, 2, 2, 139, 517, 3, 2, 2, 2, 141, 523, 3, 2, 2, 2, 143, 144, 7, 48, 2, 2, 144, 4, 3, 2, 2, 2, 145, 146, 7, 93, 2, 2, 146, 6, 3, 2, 2, 2, 147, 148, 7, 95, 2, 2, 148, 8, 3, 2, 2, 2, 149, 150, 7, 45, 2, 2, 150, 10, 3, 2, 2, 2, 151, 152, 7, 47, 2, 2, 152, 12, 3, 2, 2, 2, 153, 154, 7, 44, 2, 2, 154, 14, 3, 2, 2, 2, 155, 156, 7, 49, 2, 2, 156, 16, 3, 2, 2, 2, 157, 158, 7, 102, 2, 2, 158, 159, 7, 107, 2, 2, 159, 160, 7, 120, 2, 2, 160, 18, 3, 2, 2, 2, 161, 162, 7, 111, 2, 2, 162, 163, 7, 113, 2, 2, 163, 164, 7, 102, 2, 2, 164, 20, 3, 2, 2, 2, 165, 166, 7, 40, 2, 2, 166, 22, 3, 2, 2, 2, 167, 168, 7, 107, 2, 2, 168, 169, 7, 117, 2, 2, 169, 24, 3, 2, 2, 2, 170, 171, 7, 99, 2, 2, 171, 172, 7, 117, 2, 2, 172, 26, 3, 2, 2, 2, 173, 174, 7, 126, 2, 2, 174, 28, 3, 2, 2, 2, 175, 176, 7, 62, 2, 2, 176, 177, 7, 63, 2, 2, 177, 30, 3, 2, 2, 2, 178, 179, 7, 62, 2, 2, 179, 32, 3, 2, 2, 2, 180, 181, 7, 64, 2, 2, 181, 34, 3, 2, 2, 2, 182, 183, 7, 64, 2, 2, 183, 184, 7, 63, 2, 2, 184, 36, 3, 2, 2, 2, 185, 186, 7, 63, 2, 2, 186, 38, 3, 2, 2, 2, 187, 188, 7, 128, 2, 2, 188, 40, 3, 2, 2, 2, 189, 190, 7, 35, 2, 2, 190, 191, 7, 63, 2, 2, 191, 42, 3, 2, 2, 2, 192, 193, 7, 35, 2, 2, 193, 194, 7, 128, 2, 2, 194, 44, 3, 2, 2, 2, 195, 196, 7, 107, 2, 2, 196, 197, 7, 112, 2, 2, 197, 46, 3, 2, 2, 2, 198, 199, 7, 101, 2, 2, 199, 200, 7, 113, 2, 2, 200, 201, 7, 112, 2, 2, 201, 202, 7, 118, 2, 2, 202, 203, 7, 99, 2, 2, 203, 204, 7, 107, 2, 2, 204, 205, 7, 112, 2, 2, 205, 206, 7, 117, 2, 2, 206, 48, 3, 2, 2, 2, 207, 208, 7, 99, 2, 2, 208, 209, 7, 112, 2, 2, 209, 210, 7, 102, 2, 2, 210, 50, 3, 2, 2, 2, 211, 212, 7, 113, 2, 2, 212, 213, 7, 116, 2, 2, 213, 52, 3, 2, 2, 2, 214, 215, 7, 122, 2, 2, 215, 216, 7, 113, 2, 2, 216, 217, 7, 116, 2, 2, 217, 54, 3, 2, 2, 2, 218, 219, 7, 107, 2, 2, 219, 220, 7, 111, 2, 2, 220, 221, 7, 114, 2, 2, 221, 222, 7, 110, 2, 2, 222, 223, 7, 107, 2, 2, 223, 224, 7, 103, 2, 2, 224, 225, 7, 117, 2, 2, 225, 56, 3, 2, 2, 2, 226, 227, 7, 42, 2, 2, 227, 58, 3, 2, 2, 2, 228, 229, 7, 43, 2, 2, 229, 60, 3, 2, 2, 2, 230, 231, 7, 125, 2, 2, 231, 62, 3, 2, 2, 2, 232, 233, 7, 127, 2, 2, 233, 64, 3, 2, 2, 2, 234, 235, 7, 118, 2, 2, 235, 236, 7, 116, 2, 2, 236, 237, 7, 119, 2, 2, 237, 238, 7, 103, 2, 2, 238, 66, 3, 2, 2, 2, 239, 240, 7, 104, 2, 2, 240, 241, 7, 99, 2, 2, 241, 242, 7, 110, 2, 2, 242, 243, 7, 117, 2, 2, 243, 244, 7, 103, 2, 2, 244, 68, 3, 2, 2, 2, 245, 246, 7, 39, 2, 2, 246, 70, 3, 2, 2, 2, 247, 248, 7, 38, 2, 2, 248, 249, 7, 118, 2, 2, 249, 250, 7, 106, 2, 2, 250, 251, 7, 107, 2, 2, 251, 252, 7, 117, 2, 2, 252, 72, 3, 2, 2, 2, 253, 254, 7, 38, 2, 2, 254, 255, 7, 107, 2, 2, 255, 256, 7, 112, 2, 2, 256, 257, 7, 102, 2, 2, 257, 258, 7, 103, 2, 2, 258, 259, 7, 122, 2, 2, 259, 74, 3, 2, 2, 2, 260, 261, 7, 38, 2, 2, 261, 262, 7, 118, 2, 2, 262, 263, 7, 113, 2, 2, 263, 264, 7, 118, 2, 2, 264, 265, 7, 99, 2, 2, 265, 266, 7, 110, 2, 2, 266, 76, 3, 2, 2, 2, 267, 268, 7, 46, 2, 2, 268, 78, 3, 2, 2, 2, 269, 270, 7, 123, 2, 2, 270, 271, 7, 103, 2, 2, 271, 272, 7, 99, 2, 2, 272, 273, 7, 116, 2, 2, 273, 80, 3, 2, 2, 2, 274, 275, 7, 111, 2, 2, 275, 276, 7, 113, 2, 2, 276, 277, 7, 112, 2, 2, 277, 278, 7, 118, 2, 2, 278, 279, 7, 106, 2, 2, 279, 82, 3, 2, 2, 2, 280, 281, 7, 121, 2, 2, 281, 282, 7, 103, 2, 2, 282, 283, 7, 103, 2, 2, 283, 284, 7, 109, 2, 2, 284, 84, 3, 2, 2, 2, 285, 286, 7, 102, 2, 2, 286, 287, 7, 99, 2, 2, 287, 288, 7, 123, 2, 2, 288, 86, 3, 2, 2, 2, 289, 290, 7, 106, 2, 2, 290, 291, 7, 113, 2, 2, 291, 292, 7, 119, 2, 2, 292, 293, 7, 116, 2, 2, 293, 88, 3, 2, 2, 2, 294, 295, 7, 111, 2, 2, 295, 296, 7, 107, 2, 2, 296, 297, 7, 112, 2, 2, 297, 298, 7, 119, 2, 2, 298, 299, 7, 118, 2, 2, 299, 300, 7, 103, 2, 2, 300, 90, 3, 2, 2, 2, 301, 302, 7, 117, 2, 2, 302, 303, 7, 103, 2, 2, 303, 304, 7, 101, 2, 2, 304, 305, 7, 113, 2, 2, 305, 306, 7, 112, 2, 2, 306, 307, 7, 102, 2, 2, 307, 92, 3, 2, 2, 2, 308, 309, 7, 111, 2, 2, 309, 310, 7, 107, 2, 2, 310, 311, 7, 110, 2, 2, 311, 312, 7, 110, 2, 2, 312, 313, 7, 107, 2, 2, 313, 314, 7, 117, 2, 2, 314, 315, 7, 103, 2, 2, 315, 316, 7, 101, 2, 2, 316, 317, 7, 113, 2, 2, 317, 318, 7, 112, 2, 2, 318, 319, 7, 102, 2, 2, 319, 94, 3, 2, 2, 2, 320, 321, 7, 123, 2, 2, 321, 322, 7, 103, 2, 2, 322, 323, 7, 99, 2, 2, 323, 324, 7, 116, 2, 2, 324, 325, 7, 117, 2, 2, 325, 96, 3, 2, 2, 2, 326, 327, 7, 111, 2, 2, 327, 328, 7, 113, 2, 2, 328, 329, 7, 112, 2, 2, 329, 330, 7, 118, 2, 2, 330, 331, 7, 106, 2, 2, 331, 332, 7, 117, 2, 2, 332, 98, 3, 2, 2, 2, 333, 334, 7, 121, 2, 2, 334, 335, 7, 103, 2, 2, 335, 336, 7, 103, 2, 2, 336, 337, 7, 109, 2, 2, 337, 338, 7, 117, 2, 2, 338, 100, 3, 2, 2, 2, 339, 340, 7, 102, 2, 2, 340, 341, 7, 99, 2, 2, 341, 342, 7, 123, 2, 2, 342, 343, 7, 117, 2, 2, 343, 102, 3, 2, 2, 2, 344, 345, 7, 106, 2, 2, 345, 346, 7, 113, 2, 2, 346, 347, 7, 119, 2, 2, 347, 348, 7, 116, 2, 2, 348, 349, 7, 117, 2, 2, 349, 104, 3, 2, 2, 2, 350, 351, 7, 111, 2, 2, 351, 352, 7, 107, 2, 2, 352, 353, 7, 112, 2, 2, 353, 354, 7, 119, 2, 2, 354, 355, 7, 118, 2, 2, 355, 356, 7, 103, 2, 2, 356, 357, 7, 117, 2, 2, 357, 106, 3, 2, 2, 2, 358, 359, 7, 117, 2, 2, 359, 360, 7, 103, 2, 2, 360, 361, 7, 101, 2, 2, 361, 362, 7, 113, 2, 2, 362, 363, 7, 112, 2, 2, 363, 364, 7, 102, 2, 2, 364, 365, 7, 117, 2, 2, 365, 108, 3, 2, 2, 2, 366, 367, 7, 111, 2, 2, 367, 368, 7, 107, 2, 2, 368, 369, 7, 110, 2, 2, 369, 370, 7, 110, 2, 2, 370, 371, 7, 107, 2, 2, 371, 372, 7, 117, 2, 2, 372, 373, 7, 103, 2, 2, 373, 374, 7, 101, 2, 2, 374, 375, 7, 113, 2, 2, 375, 376, 7, 112, 2, 2, 376, 377, 7, 102, 2, 2, 377, 378, 7, 117, 2, 2, 378, 110, 3, 2, 2, 2, 379, 380, 7, 66, 2, 2, 380, 381, 5, 117, 59, 2, 381, 112, 3, 2, 2, 2, 382, 383, 7, 66, 2, 2, 383, 384, 5, 117, 59, 2, 384, 389, 7, 86, 2, 2, 385, 387, 5, 119, 60, 2, 386, 388, 5, 121, 61, 2, 387, 386, 3, 2, 2, 2, 387, 388, 3, 2, 2, 2, 388, 390, 3, 2, 2, 2, 389, 385, 3, 2, 2, 2, 389, 390, 3, 2, 2, 2, 390, 114, 3, 2, 2, 2, 391, 392, 7, 66, 2, 2, 392, 393, 7, 86, 2, 2, 393, 394, 5, 119, 60, 2, 394, 116, 3, 2, 2, 2, 395, 396, 9, 2, 2, 2, 396, 397, 9, 2, 2, 2, 397, 398, 9, 2, 2, 2, 398, 407, 9, 2, 2, 2, 399, 400, 7, 47, 2, 2, 400, 401, 9, 2, 2, 2, 401, 405, 9, 2, 2, 2, 402, 403, 7, 47, 2, 2, 403, 404, 9, 2, 2, 2, 404, 406, 9, 2, 2, 2, 405, 402, 3, 2, 2, 2, 405, 406, 3, 2, 2, 2, 406, 408, 3, 2, 2, 2, 407, 399, 3, 2, 2, 2, 407, 408, 3, 2, 2, 2, 408, 118, 3, 2, 2, 2, 409, 410, 9, 2, 2, 2, 410, 427, 9, 2, 2, 2, 411, 412, 7, 60, 2, 2, 412, 413, 9, 2, 2, 2, 413, 425, 9, 2, 2, 2, 414, 415, 7, 60, 2, 2, 415, 416, 9, 2, 2, 2, 416, 423, 9, 2, 2, 2, 417, 419, 7, 48, 2, 2, 418, 420, 9, 2, 2, 2, 419, 418, 3, 2, 2, 2, 420, 421, 3, 2, 2, 2, 421, 419, 3, 2, 2, 2, 421, 422, 3, 2, 2, 2, 422, 424, 3, 2, 2, 2, 423, 417, 3, 2, 2, 2, 423, 424, 3, 2, 2, 2, 424, 426, 3, 2, 2, 2, 425, 414, 3, 2, 2, 2, 425, 426, 3, 2, 2, 2, 426, 428, 3, 2, 2, 2, 427, 411, 3, 2, 2, 2, 427, 428, 3, 2, 2, 2, 428, 120, 3, 2, 2, 2, 429, 437, 7, 92, 2, 2, 430, 431, 9, 3, 2, 2, 431, 432, 9, 2, 2, 2, 432, 433, 9, 2, 2, 2, 433, 434, 7, 60, 2, 2, 434, 435, 9, 2, 2, 2, 435, 437, 9, 2, 2, 2, 436, 429, 3, 2, 2, 2, 436, 430, 3, 2, 2, 2, 437, 122, 3, 2, 2, 2, 438, 440, 9, 4, 2, 2, 439, 438, 3, 2, 2, 2, 440, 444, 3, 2, 2, 2, 441, 443, 9, 5, 2, 2, 442, 441, 3, 2, 2, 2, 443, 446, 3, 2, 2, 2, 444, 442, 3, 2, 2, 2, 444, 445, 3, 2, 2, 2, 445, 124, 3, 2, 2, 2, 446, 444, 3, 2, 2, 2, 447, 452, 7, 98, 2, 2, 448, 451, 5, 137, 69, 2, 449, 451, 11, 2, 2, 2, 450, 448, 3, 2, 2, 2, 450, 449, 3, 2, 2, 2, 451, 454, 3, 2, 2, 2, 452, 453, 3, 2, 2, 2, 452, 450, 3, 2, 2, 2, 453, 455, 3, 2, 2, 2, 454, 452, 3, 2, 2, 2, 455, 456, 7, 98, 2, 2, 456, 126, 3, 2, 2, 2, 457, 462, 7, 41, 2, 2, 458, 461, 5, 137, 69, 2, 459, 461, 11, 2, 2, 2, 460, 458, 3, 2, 2, 2, 460, 459, 3, 2, 2, 2, 461, 464, 3, 2, 2, 2, 462, 463, 3, 2, 2, 2, 462, 460, 3, 2, 2, 2, 463, 465, 3, 2, 2, 2, 464, 462, 3, 2, 2, 2, 465, 466, 7, 41, 2, 2, 466, 128, 3, 2, 2, 2, 467, 469, 9, 2, 2, 2, 468, 467, 3, 2, 2, 2, 469, 470, 3, 2, 2, 2, 470, 468, 3, 2, 2, 2, 470, 471, 3, 2, 2, 2, 471, 478, 3, 2, 2, 2, 472, 474, 7, 48, 2, 2, 473, 475, 9, 2, 2, 2, 474, 473, 3, 2, 2, 2, 475, 476, 3, 2, 2, 2, 476, 474, 3, 2, 2, 2, 476, 477, 3, 2, 2, 2, 477, 479, 3, 2, 2, 2, 478, 472, 3, 2, 2, 2, 478, 479, 3, 2, 2, 2, 479, 130, 3, 2, 2, 2, 480, 482, 9, 6, 2, 2, 481, 480, 3, 2, 2, 2, 482, 483, 3, 2, 2, 2, 483, 481, 3, 2, 2, 2, 483, 484, 3, 2, 2, 2, 484, 485, 3, 2, 2, 2, 485, 486, 8, 66, 2, 2, 486, 132, 3, 2, 2, 2, 487, 488, 7, 49, 2, 2, 488, 489, 7, 44, 2, 2, 489, 493, 3, 2, 2, 2, 490, 492, 11, 2, 2, 2, 491, 490, 3, 2, 2, 2, 492, 495, 3, 2, 2, 2, 493, 494, 3, 2, 2, 2, 493, 491, 3, 2, 2, 2, 494, 496, 3, 2, 2, 2, 495, 493, 3, 2, 2, 2, 496, 497, 7, 44, 2, 2, 497, 498, 7, 49, 2, 2, 498, 499, 3, 2, 2, 2, 499, 500, 8, 67, 2, 2, 500, 134, 3, 2, 2, 2, 501, 502, 7, 49, 2, 2, 502, 503, 7, 49, 2, 2, 503, 507, 3, 2, 2, 2, 504, 506, 10, 7, 2, 2, 505, 504, 3, 2, 2, 2, 506, 509, 3, 2, 2, 2, 507, 505, 3, 2, 2, 2, 507, 508, 3, 2, 2, 2, 508, 510, 3, 2, 2, 2, 509, 507, 3, 2, 2, 2, 510, 511, 8, 68, 2, 2, 511, 136, 3, 2, 2, 2, 512, 515, 7, 94, 2, 2, 513, 516, 9, 8, 2, 2, 514, 516, 5, 139, 70, 2, 515, 513, 3, 2, 2, 2, 515, 514, 3, 2, 2, 2, 516, 138, 3, 2, 2, 2, 517, 518, 7, 119, 2, 2, 518, 519, 5, 141, 71, 2, 519, 520, 5, 141, 71, 2, 520, 521, 5, 141, 71, 2, 521, 522, 5, 141, 71, 2, 522, 140, 3, 2, 2, 2, 523, 524, 9, 9, 2, 2, 524, 142, 3, 2, 2, 2, 26, 2, 387, 389, 405, 407, 421, 423, 425, 427, 436, 439, 442, 444, 450, 452, 460, 462, 470, 476, 478, 483, 493, 507, 515, 3, 2, 3, 2] \ No newline at end of file diff --git a/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathLexer.java b/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathLexer.java index 79f80ddf54d..d9226a9123a 100644 --- a/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathLexer.java +++ b/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathLexer.java @@ -1,52 +1,79 @@ -/* - * (C) Copyright IBM Corp. 2019 - * - * SPDX-License-Identifier: Apache-2.0 - */ - +// Generated from FHIRPath.g4 by ANTLR 4.7.2 package com.ibm.fhir.model.path; - -import org.antlr.v4.runtime.CharStream; import org.antlr.v4.runtime.Lexer; -import org.antlr.v4.runtime.RuntimeMetaData; -import org.antlr.v4.runtime.Vocabulary; -import org.antlr.v4.runtime.VocabularyImpl; -import org.antlr.v4.runtime.atn.ATN; -import org.antlr.v4.runtime.atn.ATNDeserializer; -import org.antlr.v4.runtime.atn.LexerATNSimulator; -import org.antlr.v4.runtime.atn.PredictionContextCache; +import org.antlr.v4.runtime.CharStream; +import org.antlr.v4.runtime.Token; +import org.antlr.v4.runtime.TokenStream; +import org.antlr.v4.runtime.*; +import org.antlr.v4.runtime.atn.*; import org.antlr.v4.runtime.dfa.DFA; +import org.antlr.v4.runtime.misc.*; -@SuppressWarnings({ "all", "warnings", "unchecked", "unused", "cast" }) +@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"}) public class FHIRPathLexer extends Lexer { - static { - RuntimeMetaData.checkVersion("4.5.3", RuntimeMetaData.VERSION); - } + static { RuntimeMetaData.checkVersion("4.7.2", RuntimeMetaData.VERSION); } protected static final DFA[] _decisionToDFA; - protected static final PredictionContextCache _sharedContextCache = new PredictionContextCache(); - public static final int T__0 = 1, T__1 = 2, T__2 = 3, T__3 = 4, T__4 = 5, T__5 = 6, T__6 = 7, T__7 = 8, T__8 = 9, T__9 = 10, T__10 = 11, T__11 = 12, - T__12 = 13, T__13 = 14, T__14 = 15, T__15 = 16, T__16 = 17, T__17 = 18, T__18 = 19, T__19 = 20, T__20 = 21, T__21 = 22, T__22 = 23, T__23 = 24, - T__24 = 25, T__25 = 26, T__26 = 27, T__27 = 28, T__28 = 29, T__29 = 30, T__30 = 31, T__31 = 32, T__32 = 33, T__33 = 34, T__34 = 35, T__35 = 36, - T__36 = 37, T__37 = 38, T__38 = 39, T__39 = 40, T__40 = 41, T__41 = 42, T__42 = 43, T__43 = 44, T__44 = 45, T__45 = 46, T__46 = 47, T__47 = 48, - T__48 = 49, T__49 = 50, T__50 = 51, T__51 = 52, T__52 = 53, T__53 = 54, DATETIME = 55, TIME = 56, IDENTIFIER = 57, DELIMITEDIDENTIFIER = 58, - STRING = 59, NUMBER = 60, WS = 61, COMMENT = 62, LINE_COMMENT = 63; - public static String[] modeNames = { "DEFAULT_MODE" }; + protected static final PredictionContextCache _sharedContextCache = + new PredictionContextCache(); + public static final int + T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, T__5=6, T__6=7, T__7=8, T__8=9, + T__9=10, T__10=11, T__11=12, T__12=13, T__13=14, T__14=15, T__15=16, T__16=17, + T__17=18, T__18=19, T__19=20, T__20=21, T__21=22, T__22=23, T__23=24, + T__24=25, T__25=26, T__26=27, T__27=28, T__28=29, T__29=30, T__30=31, + T__31=32, T__32=33, T__33=34, T__34=35, T__35=36, T__36=37, T__37=38, + T__38=39, T__39=40, T__40=41, T__41=42, T__42=43, T__43=44, T__44=45, + T__45=46, T__46=47, T__47=48, T__48=49, T__49=50, T__50=51, T__51=52, + T__52=53, T__53=54, DATE=55, DATETIME=56, TIME=57, IDENTIFIER=58, DELIMITEDIDENTIFIER=59, + STRING=60, NUMBER=61, WS=62, COMMENT=63, LINE_COMMENT=64; + public static String[] channelNames = { + "DEFAULT_TOKEN_CHANNEL", "HIDDEN" + }; + + public static String[] modeNames = { + "DEFAULT_MODE" + }; - public static final String[] ruleNames = { "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", "T__7", "T__8", "T__9", "T__10", "T__11", "T__12", - "T__13", "T__14", "T__15", "T__16", "T__17", "T__18", "T__19", "T__20", "T__21", "T__22", "T__23", "T__24", "T__25", "T__26", "T__27", "T__28", - "T__29", "T__30", "T__31", "T__32", "T__33", "T__34", "T__35", "T__36", "T__37", "T__38", "T__39", "T__40", "T__41", "T__42", "T__43", "T__44", - "T__45", "T__46", "T__47", "T__48", "T__49", "T__50", "T__51", "T__52", "T__53", "DATETIME", "TIME", "TIMEFORMAT", "IDENTIFIER", - "DELIMITEDIDENTIFIER", "STRING", "NUMBER", "WS", "COMMENT", "LINE_COMMENT", "ESC", "UNICODE", "HEX" }; + private static String[] makeRuleNames() { + return new String[] { + "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", "T__7", "T__8", + "T__9", "T__10", "T__11", "T__12", "T__13", "T__14", "T__15", "T__16", + "T__17", "T__18", "T__19", "T__20", "T__21", "T__22", "T__23", "T__24", + "T__25", "T__26", "T__27", "T__28", "T__29", "T__30", "T__31", "T__32", + "T__33", "T__34", "T__35", "T__36", "T__37", "T__38", "T__39", "T__40", + "T__41", "T__42", "T__43", "T__44", "T__45", "T__46", "T__47", "T__48", + "T__49", "T__50", "T__51", "T__52", "T__53", "DATE", "DATETIME", "TIME", + "DATEFORMAT", "TIMEFORMAT", "TIMEZONEOFFSETFORMAT", "IDENTIFIER", "DELIMITEDIDENTIFIER", + "STRING", "NUMBER", "WS", "COMMENT", "LINE_COMMENT", "ESC", "UNICODE", + "HEX" + }; + } + public static final String[] ruleNames = makeRuleNames(); - private static final String[] _LITERAL_NAMES = { null, "'.'", "'['", "']'", "'+'", "'-'", "'*'", "'/'", "'div'", "'mod'", "'&'", "'is'", "'as'", "'|'", - "'<='", "'<'", "'>'", "'>='", "'='", "'~'", "'!='", "'!~'", "'in'", "'contains'", "'and'", "'or'", "'xor'", "'implies'", "'('", "')'", "'{'", "'}'", - "'true'", "'false'", "'%'", "'$this'", "'$index'", "'$total'", "','", "'year'", "'month'", "'week'", "'day'", "'hour'", "'minute'", "'second'", - "'millisecond'", "'years'", "'months'", "'weeks'", "'days'", "'hours'", "'minutes'", "'seconds'", "'milliseconds'" }; - private static final String[] _SYMBOLIC_NAMES = { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, - null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, - null, null, null, null, null, null, null, null, null, null, null, null, null, null, "DATETIME", "TIME", "IDENTIFIER", "DELIMITEDIDENTIFIER", - "STRING", "NUMBER", "WS", "COMMENT", "LINE_COMMENT" }; + private static String[] makeLiteralNames() { + return new String[] { + null, "'.'", "'['", "']'", "'+'", "'-'", "'*'", "'/'", "'div'", "'mod'", + "'&'", "'is'", "'as'", "'|'", "'<='", "'<'", "'>'", "'>='", "'='", "'~'", + "'!='", "'!~'", "'in'", "'contains'", "'and'", "'or'", "'xor'", "'implies'", + "'('", "')'", "'{'", "'}'", "'true'", "'false'", "'%'", "'$this'", "'$index'", + "'$total'", "','", "'year'", "'month'", "'week'", "'day'", "'hour'", + "'minute'", "'second'", "'millisecond'", "'years'", "'months'", "'weeks'", + "'days'", "'hours'", "'minutes'", "'seconds'", "'milliseconds'" + }; + } + private static final String[] _LITERAL_NAMES = makeLiteralNames(); + private static String[] makeSymbolicNames() { + return new String[] { + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, "DATE", "DATETIME", "TIME", + "IDENTIFIER", "DELIMITEDIDENTIFIER", "STRING", "NUMBER", "WS", "COMMENT", + "LINE_COMMENT" + }; + } + private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames(); public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); /** @@ -80,180 +107,212 @@ public Vocabulary getVocabulary() { return VOCABULARY; } + public FHIRPathLexer(CharStream input) { super(input); - _interp = new LexerATNSimulator(this, _ATN, _decisionToDFA, _sharedContextCache); + _interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); } @Override - public String getGrammarFileName() { - return "FHIRPath.g4"; - } + public String getGrammarFileName() { return "FHIRPath.g4"; } @Override - public String[] getRuleNames() { - return ruleNames; - } + public String[] getRuleNames() { return ruleNames; } @Override - public String getSerializedATN() { - return _serializedATN; - } + public String getSerializedATN() { return _serializedATN; } @Override - public String[] getModeNames() { - return modeNames; - } + public String[] getChannelNames() { return channelNames; } @Override - public ATN getATN() { - return _ATN; - } + public String[] getModeNames() { return modeNames; } + + @Override + public ATN getATN() { return _ATN; } - public static final String _serializedATN = "\3\u0430\ud6d1\u8206\uad2d\u4417\uaef1\u8d80\uaadd\2A\u0203\b\1\4\2\t" - + "\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13" - + "\t\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22" - + "\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30\4\31\t\31" + "\4\32\t\32\4\33\t\33\4\34\t\34\4\35\t\35\4\36\t\36\4\37\t\37\4 \t \4!" - + "\t!\4\"\t\"\4#\t#\4$\t$\4%\t%\4&\t&\4\'\t\'\4(\t(\4)\t)\4*\t*\4+\t+\4" + ",\t,\4-\t-\4.\t.\4/\t/\4\60\t\60\4\61\t\61\4\62\t\62\4\63\t\63\4\64\t" - + "\64\4\65\t\65\4\66\t\66\4\67\t\67\48\t8\49\t9\4:\t:\4;\t;\4<\t<\4=\t=" + "\4>\t>\4?\t?\4@\t@\4A\tA\4B\tB\4C\tC\4D\tD\3\2\3\2\3\3\3\3\3\4\3\4\3\5" - + "\3\5\3\6\3\6\3\7\3\7\3\b\3\b\3\t\3\t\3\t\3\t\3\n\3\n\3\n\3\n\3\13\3\13" + "\3\f\3\f\3\f\3\r\3\r\3\r\3\16\3\16\3\17\3\17\3\17\3\20\3\20\3\21\3\21" - + "\3\22\3\22\3\22\3\23\3\23\3\24\3\24\3\25\3\25\3\25\3\26\3\26\3\26\3\27" - + "\3\27\3\27\3\30\3\30\3\30\3\30\3\30\3\30\3\30\3\30\3\30\3\31\3\31\3\31" - + "\3\31\3\32\3\32\3\32\3\33\3\33\3\33\3\33\3\34\3\34\3\34\3\34\3\34\3\34" + "\3\34\3\34\3\35\3\35\3\36\3\36\3\37\3\37\3 \3 \3!\3!\3!\3!\3!\3\"\3\"" - + "\3\"\3\"\3\"\3\"\3#\3#\3$\3$\3$\3$\3$\3$\3%\3%\3%\3%\3%\3%\3%\3&\3&\3" + "&\3&\3&\3&\3&\3\'\3\'\3(\3(\3(\3(\3(\3)\3)\3)\3)\3)\3)\3*\3*\3*\3*\3*" - + "\3+\3+\3+\3+\3,\3,\3,\3,\3,\3-\3-\3-\3-\3-\3-\3-\3.\3.\3.\3.\3.\3.\3." - + "\3/\3/\3/\3/\3/\3/\3/\3/\3/\3/\3/\3/\3\60\3\60\3\60\3\60\3\60\3\60\3\61" - + "\3\61\3\61\3\61\3\61\3\61\3\61\3\62\3\62\3\62\3\62\3\62\3\62\3\63\3\63" - + "\3\63\3\63\3\63\3\64\3\64\3\64\3\64\3\64\3\64\3\65\3\65\3\65\3\65\3\65" - + "\3\65\3\65\3\65\3\66\3\66\3\66\3\66\3\66\3\66\3\66\3\66\3\67\3\67\3\67" - + "\3\67\3\67\3\67\3\67\3\67\3\67\3\67\3\67\3\67\3\67\38\38\38\38\38\38\3" + "8\38\38\38\38\38\38\58\u0183\n8\58\u0185\n8\58\u0187\n8\38\58\u018a\n" - + "8\39\39\39\39\3:\3:\3:\3:\3:\3:\3:\3:\3:\3:\6:\u019a\n:\r:\16:\u019b\5" + ":\u019e\n:\5:\u01a0\n:\5:\u01a2\n:\3:\3:\3:\3:\3:\3:\3:\5:\u01ab\n:\3" - + ";\5;\u01ae\n;\3;\7;\u01b1\n;\f;\16;\u01b4\13;\3<\3<\3<\7<\u01b9\n<\f<" + "\16<\u01bc\13<\3<\3<\3=\3=\3=\7=\u01c3\n=\f=\16=\u01c6\13=\3=\3=\3>\6" - + ">\u01cb\n>\r>\16>\u01cc\3>\3>\6>\u01d1\n>\r>\16>\u01d2\5>\u01d5\n>\3?" - + "\6?\u01d8\n?\r?\16?\u01d9\3?\3?\3@\3@\3@\3@\7@\u01e2\n@\f@\16@\u01e5\13" - + "@\3@\3@\3@\3@\3@\3A\3A\3A\3A\7A\u01f0\nA\fA\16A\u01f3\13A\3A\3A\3B\3B" + "\3B\5B\u01fa\nB\3C\3C\3C\3C\3C\3C\3D\3D\5\u01ba\u01c4\u01e3\2E\3\3\5\4" - + "\7\5\t\6\13\7\r\b\17\t\21\n\23\13\25\f\27\r\31\16\33\17\35\20\37\21!\22" - + "#\23%\24\'\25)\26+\27-\30/\31\61\32\63\33\65\34\67\359\36;\37= ?!A\"C" + "#E$G%I&K\'M(O)Q*S+U,W-Y.[/]\60_\61a\62c\63e\64g\65i\66k\67m8o9q:s\2u;" - + "w}?\177@\u0081A\u0083\2\u0085\2\u0087\2\3\2\n\3\2\62;\4\2--//\5\2" + "C\\aac|\6\2\62;C\\aac|\5\2\13\f\17\17\"\"\4\2\f\f\17\17\n\2))\61\61^^" - + "bbhhppttvv\5\2\62;CHch\u0214\2\3\3\2\2\2\2\5\3\2\2\2\2\7\3\2\2\2\2\t\3" - + "\2\2\2\2\13\3\2\2\2\2\r\3\2\2\2\2\17\3\2\2\2\2\21\3\2\2\2\2\23\3\2\2\2" - + "\2\25\3\2\2\2\2\27\3\2\2\2\2\31\3\2\2\2\2\33\3\2\2\2\2\35\3\2\2\2\2\37" + "\3\2\2\2\2!\3\2\2\2\2#\3\2\2\2\2%\3\2\2\2\2\'\3\2\2\2\2)\3\2\2\2\2+\3" - + "\2\2\2\2-\3\2\2\2\2/\3\2\2\2\2\61\3\2\2\2\2\63\3\2\2\2\2\65\3\2\2\2\2" + "\67\3\2\2\2\29\3\2\2\2\2;\3\2\2\2\2=\3\2\2\2\2?\3\2\2\2\2A\3\2\2\2\2C" - + "\3\2\2\2\2E\3\2\2\2\2G\3\2\2\2\2I\3\2\2\2\2K\3\2\2\2\2M\3\2\2\2\2O\3\2" - + "\2\2\2Q\3\2\2\2\2S\3\2\2\2\2U\3\2\2\2\2W\3\2\2\2\2Y\3\2\2\2\2[\3\2\2\2" + "\2]\3\2\2\2\2_\3\2\2\2\2a\3\2\2\2\2c\3\2\2\2\2e\3\2\2\2\2g\3\2\2\2\2i" - + "\3\2\2\2\2k\3\2\2\2\2m\3\2\2\2\2o\3\2\2\2\2q\3\2\2\2\2u\3\2\2\2\2w\3\2" + "\2\2\2y\3\2\2\2\2{\3\2\2\2\2}\3\2\2\2\2\177\3\2\2\2\2\u0081\3\2\2\2\3" - + "\u0089\3\2\2\2\5\u008b\3\2\2\2\7\u008d\3\2\2\2\t\u008f\3\2\2\2\13\u0091" - + "\3\2\2\2\r\u0093\3\2\2\2\17\u0095\3\2\2\2\21\u0097\3\2\2\2\23\u009b\3" + "\2\2\2\25\u009f\3\2\2\2\27\u00a1\3\2\2\2\31\u00a4\3\2\2\2\33\u00a7\3\2" - + "\2\2\35\u00a9\3\2\2\2\37\u00ac\3\2\2\2!\u00ae\3\2\2\2#\u00b0\3\2\2\2%" + "\u00b3\3\2\2\2\'\u00b5\3\2\2\2)\u00b7\3\2\2\2+\u00ba\3\2\2\2-\u00bd\3" - + "\2\2\2/\u00c0\3\2\2\2\61\u00c9\3\2\2\2\63\u00cd\3\2\2\2\65\u00d0\3\2\2" - + "\2\67\u00d4\3\2\2\29\u00dc\3\2\2\2;\u00de\3\2\2\2=\u00e0\3\2\2\2?\u00e2" - + "\3\2\2\2A\u00e4\3\2\2\2C\u00e9\3\2\2\2E\u00ef\3\2\2\2G\u00f1\3\2\2\2I" + "\u00f7\3\2\2\2K\u00fe\3\2\2\2M\u0105\3\2\2\2O\u0107\3\2\2\2Q\u010c\3\2" - + "\2\2S\u0112\3\2\2\2U\u0117\3\2\2\2W\u011b\3\2\2\2Y\u0120\3\2\2\2[\u0127" - + "\3\2\2\2]\u012e\3\2\2\2_\u013a\3\2\2\2a\u0140\3\2\2\2c\u0147\3\2\2\2e" + "\u014d\3\2\2\2g\u0152\3\2\2\2i\u0158\3\2\2\2k\u0160\3\2\2\2m\u0168\3\2" - + "\2\2o\u0175\3\2\2\2q\u018b\3\2\2\2s\u018f\3\2\2\2u\u01ad\3\2\2\2w\u01b5" - + "\3\2\2\2y\u01bf\3\2\2\2{\u01ca\3\2\2\2}\u01d7\3\2\2\2\177\u01dd\3\2\2" - + "\2\u0081\u01eb\3\2\2\2\u0083\u01f6\3\2\2\2\u0085\u01fb\3\2\2\2\u0087\u0201" - + "\3\2\2\2\u0089\u008a\7\60\2\2\u008a\4\3\2\2\2\u008b\u008c\7]\2\2\u008c" - + "\6\3\2\2\2\u008d\u008e\7_\2\2\u008e\b\3\2\2\2\u008f\u0090\7-\2\2\u0090" - + "\n\3\2\2\2\u0091\u0092\7/\2\2\u0092\f\3\2\2\2\u0093\u0094\7,\2\2\u0094" - + "\16\3\2\2\2\u0095\u0096\7\61\2\2\u0096\20\3\2\2\2\u0097\u0098\7f\2\2\u0098" - + "\u0099\7k\2\2\u0099\u009a\7x\2\2\u009a\22\3\2\2\2\u009b\u009c\7o\2\2\u009c" - + "\u009d\7q\2\2\u009d\u009e\7f\2\2\u009e\24\3\2\2\2\u009f\u00a0\7(\2\2\u00a0" - + "\26\3\2\2\2\u00a1\u00a2\7k\2\2\u00a2\u00a3\7u\2\2\u00a3\30\3\2\2\2\u00a4" - + "\u00a5\7c\2\2\u00a5\u00a6\7u\2\2\u00a6\32\3\2\2\2\u00a7\u00a8\7~\2\2\u00a8" - + "\34\3\2\2\2\u00a9\u00aa\7>\2\2\u00aa\u00ab\7?\2\2\u00ab\36\3\2\2\2\u00ac" - + "\u00ad\7>\2\2\u00ad \3\2\2\2\u00ae\u00af\7@\2\2\u00af\"\3\2\2\2\u00b0" - + "\u00b1\7@\2\2\u00b1\u00b2\7?\2\2\u00b2$\3\2\2\2\u00b3\u00b4\7?\2\2\u00b4" - + "&\3\2\2\2\u00b5\u00b6\7\u0080\2\2\u00b6(\3\2\2\2\u00b7\u00b8\7#\2\2\u00b8" - + "\u00b9\7?\2\2\u00b9*\3\2\2\2\u00ba\u00bb\7#\2\2\u00bb\u00bc\7\u0080\2" + "\2\u00bc,\3\2\2\2\u00bd\u00be\7k\2\2\u00be\u00bf\7p\2\2\u00bf.\3\2\2\2" - + "\u00c0\u00c1\7e\2\2\u00c1\u00c2\7q\2\2\u00c2\u00c3\7p\2\2\u00c3\u00c4" + "\7v\2\2\u00c4\u00c5\7c\2\2\u00c5\u00c6\7k\2\2\u00c6\u00c7\7p\2\2\u00c7" - + "\u00c8\7u\2\2\u00c8\60\3\2\2\2\u00c9\u00ca\7c\2\2\u00ca\u00cb\7p\2\2\u00cb" - + "\u00cc\7f\2\2\u00cc\62\3\2\2\2\u00cd\u00ce\7q\2\2\u00ce\u00cf\7t\2\2\u00cf" - + "\64\3\2\2\2\u00d0\u00d1\7z\2\2\u00d1\u00d2\7q\2\2\u00d2\u00d3\7t\2\2\u00d3" - + "\66\3\2\2\2\u00d4\u00d5\7k\2\2\u00d5\u00d6\7o\2\2\u00d6\u00d7\7r\2\2\u00d7" - + "\u00d8\7n\2\2\u00d8\u00d9\7k\2\2\u00d9\u00da\7g\2\2\u00da\u00db\7u\2\2" - + "\u00db8\3\2\2\2\u00dc\u00dd\7*\2\2\u00dd:\3\2\2\2\u00de\u00df\7+\2\2\u00df" - + "<\3\2\2\2\u00e0\u00e1\7}\2\2\u00e1>\3\2\2\2\u00e2\u00e3\7\177\2\2\u00e3" - + "@\3\2\2\2\u00e4\u00e5\7v\2\2\u00e5\u00e6\7t\2\2\u00e6\u00e7\7w\2\2\u00e7" - + "\u00e8\7g\2\2\u00e8B\3\2\2\2\u00e9\u00ea\7h\2\2\u00ea\u00eb\7c\2\2\u00eb" - + "\u00ec\7n\2\2\u00ec\u00ed\7u\2\2\u00ed\u00ee\7g\2\2\u00eeD\3\2\2\2\u00ef" - + "\u00f0\7\'\2\2\u00f0F\3\2\2\2\u00f1\u00f2\7&\2\2\u00f2\u00f3\7v\2\2\u00f3" - + "\u00f4\7j\2\2\u00f4\u00f5\7k\2\2\u00f5\u00f6\7u\2\2\u00f6H\3\2\2\2\u00f7" - + "\u00f8\7&\2\2\u00f8\u00f9\7k\2\2\u00f9\u00fa\7p\2\2\u00fa\u00fb\7f\2\2" - + "\u00fb\u00fc\7g\2\2\u00fc\u00fd\7z\2\2\u00fdJ\3\2\2\2\u00fe\u00ff\7&\2" - + "\2\u00ff\u0100\7v\2\2\u0100\u0101\7q\2\2\u0101\u0102\7v\2\2\u0102\u0103" - + "\7c\2\2\u0103\u0104\7n\2\2\u0104L\3\2\2\2\u0105\u0106\7.\2\2\u0106N\3" + "\2\2\2\u0107\u0108\7{\2\2\u0108\u0109\7g\2\2\u0109\u010a\7c\2\2\u010a" - + "\u010b\7t\2\2\u010bP\3\2\2\2\u010c\u010d\7o\2\2\u010d\u010e\7q\2\2\u010e" - + "\u010f\7p\2\2\u010f\u0110\7v\2\2\u0110\u0111\7j\2\2\u0111R\3\2\2\2\u0112" - + "\u0113\7y\2\2\u0113\u0114\7g\2\2\u0114\u0115\7g\2\2\u0115\u0116\7m\2\2" - + "\u0116T\3\2\2\2\u0117\u0118\7f\2\2\u0118\u0119\7c\2\2\u0119\u011a\7{\2" + "\2\u011aV\3\2\2\2\u011b\u011c\7j\2\2\u011c\u011d\7q\2\2\u011d\u011e\7" - + "w\2\2\u011e\u011f\7t\2\2\u011fX\3\2\2\2\u0120\u0121\7o\2\2\u0121\u0122" - + "\7k\2\2\u0122\u0123\7p\2\2\u0123\u0124\7w\2\2\u0124\u0125\7v\2\2\u0125" - + "\u0126\7g\2\2\u0126Z\3\2\2\2\u0127\u0128\7u\2\2\u0128\u0129\7g\2\2\u0129" - + "\u012a\7e\2\2\u012a\u012b\7q\2\2\u012b\u012c\7p\2\2\u012c\u012d\7f\2\2" + "\u012d\\\3\2\2\2\u012e\u012f\7o\2\2\u012f\u0130\7k\2\2\u0130\u0131\7n" - + "\2\2\u0131\u0132\7n\2\2\u0132\u0133\7k\2\2\u0133\u0134\7u\2\2\u0134\u0135" - + "\7g\2\2\u0135\u0136\7e\2\2\u0136\u0137\7q\2\2\u0137\u0138\7p\2\2\u0138" - + "\u0139\7f\2\2\u0139^\3\2\2\2\u013a\u013b\7{\2\2\u013b\u013c\7g\2\2\u013c" - + "\u013d\7c\2\2\u013d\u013e\7t\2\2\u013e\u013f\7u\2\2\u013f`\3\2\2\2\u0140" - + "\u0141\7o\2\2\u0141\u0142\7q\2\2\u0142\u0143\7p\2\2\u0143\u0144\7v\2\2" - + "\u0144\u0145\7j\2\2\u0145\u0146\7u\2\2\u0146b\3\2\2\2\u0147\u0148\7y\2" - + "\2\u0148\u0149\7g\2\2\u0149\u014a\7g\2\2\u014a\u014b\7m\2\2\u014b\u014c" - + "\7u\2\2\u014cd\3\2\2\2\u014d\u014e\7f\2\2\u014e\u014f\7c\2\2\u014f\u0150" - + "\7{\2\2\u0150\u0151\7u\2\2\u0151f\3\2\2\2\u0152\u0153\7j\2\2\u0153\u0154" - + "\7q\2\2\u0154\u0155\7w\2\2\u0155\u0156\7t\2\2\u0156\u0157\7u\2\2\u0157" - + "h\3\2\2\2\u0158\u0159\7o\2\2\u0159\u015a\7k\2\2\u015a\u015b\7p\2\2\u015b" - + "\u015c\7w\2\2\u015c\u015d\7v\2\2\u015d\u015e\7g\2\2\u015e\u015f\7u\2\2" - + "\u015fj\3\2\2\2\u0160\u0161\7u\2\2\u0161\u0162\7g\2\2\u0162\u0163\7e\2" - + "\2\u0163\u0164\7q\2\2\u0164\u0165\7p\2\2\u0165\u0166\7f\2\2\u0166\u0167" - + "\7u\2\2\u0167l\3\2\2\2\u0168\u0169\7o\2\2\u0169\u016a\7k\2\2\u016a\u016b" - + "\7n\2\2\u016b\u016c\7n\2\2\u016c\u016d\7k\2\2\u016d\u016e\7u\2\2\u016e" - + "\u016f\7g\2\2\u016f\u0170\7e\2\2\u0170\u0171\7q\2\2\u0171\u0172\7p\2\2" - + "\u0172\u0173\7f\2\2\u0173\u0174\7u\2\2\u0174n\3\2\2\2\u0175\u0176\7B\2" - + "\2\u0176\u0177\t\2\2\2\u0177\u0178\t\2\2\2\u0178\u0179\t\2\2\2\u0179\u0186" - + "\t\2\2\2\u017a\u017b\7/\2\2\u017b\u017c\t\2\2\2\u017c\u0184\t\2\2\2\u017d" - + "\u017e\7/\2\2\u017e\u017f\t\2\2\2\u017f\u0182\t\2\2\2\u0180\u0181\7V\2" - + "\2\u0181\u0183\5s:\2\u0182\u0180\3\2\2\2\u0182\u0183\3\2\2\2\u0183\u0185" - + "\3\2\2\2\u0184\u017d\3\2\2\2\u0184\u0185\3\2\2\2\u0185\u0187\3\2\2\2\u0186" - + "\u017a\3\2\2\2\u0186\u0187\3\2\2\2\u0187\u0189\3\2\2\2\u0188\u018a\7\\" - + "\2\2\u0189\u0188\3\2\2\2\u0189\u018a\3\2\2\2\u018ap\3\2\2\2\u018b\u018c" - + "\7B\2\2\u018c\u018d\7V\2\2\u018d\u018e\5s:\2\u018er\3\2\2\2\u018f\u0190" - + "\t\2\2\2\u0190\u01a1\t\2\2\2\u0191\u0192\7<\2\2\u0192\u0193\t\2\2\2\u0193" - + "\u019f\t\2\2\2\u0194\u0195\7<\2\2\u0195\u0196\t\2\2\2\u0196\u019d\t\2" - + "\2\2\u0197\u0199\7\60\2\2\u0198\u019a\t\2\2\2\u0199\u0198\3\2\2\2\u019a" - + "\u019b\3\2\2\2\u019b\u0199\3\2\2\2\u019b\u019c\3\2\2\2\u019c\u019e\3\2" - + "\2\2\u019d\u0197\3\2\2\2\u019d\u019e\3\2\2\2\u019e\u01a0\3\2\2\2\u019f" - + "\u0194\3\2\2\2\u019f\u01a0\3\2\2\2\u01a0\u01a2\3\2\2\2\u01a1\u0191\3\2" - + "\2\2\u01a1\u01a2\3\2\2\2\u01a2\u01aa\3\2\2\2\u01a3\u01ab\7\\\2\2\u01a4" + "\u01a5\t\3\2\2\u01a5\u01a6\t\2\2\2\u01a6\u01a7\t\2\2\2\u01a7\u01a8\7<" - + "\2\2\u01a8\u01a9\t\2\2\2\u01a9\u01ab\t\2\2\2\u01aa\u01a3\3\2\2\2\u01aa" + "\u01a4\3\2\2\2\u01aa\u01ab\3\2\2\2\u01abt\3\2\2\2\u01ac\u01ae\t\4\2\2" - + "\u01ad\u01ac\3\2\2\2\u01ae\u01b2\3\2\2\2\u01af\u01b1\t\5\2\2\u01b0\u01af" - + "\3\2\2\2\u01b1\u01b4\3\2\2\2\u01b2\u01b0\3\2\2\2\u01b2\u01b3\3\2\2\2\u01b3" - + "v\3\2\2\2\u01b4\u01b2\3\2\2\2\u01b5\u01ba\7b\2\2\u01b6\u01b9\5\u0083B" + "\2\u01b7\u01b9\13\2\2\2\u01b8\u01b6\3\2\2\2\u01b8\u01b7\3\2\2\2\u01b9" - + "\u01bc\3\2\2\2\u01ba\u01bb\3\2\2\2\u01ba\u01b8\3\2\2\2\u01bb\u01bd\3\2" - + "\2\2\u01bc\u01ba\3\2\2\2\u01bd\u01be\7b\2\2\u01bex\3\2\2\2\u01bf\u01c4" + "\7)\2\2\u01c0\u01c3\5\u0083B\2\u01c1\u01c3\13\2\2\2\u01c2\u01c0\3\2\2" - + "\2\u01c2\u01c1\3\2\2\2\u01c3\u01c6\3\2\2\2\u01c4\u01c5\3\2\2\2\u01c4\u01c2" - + "\3\2\2\2\u01c5\u01c7\3\2\2\2\u01c6\u01c4\3\2\2\2\u01c7\u01c8\7)\2\2\u01c8" - + "z\3\2\2\2\u01c9\u01cb\t\2\2\2\u01ca\u01c9\3\2\2\2\u01cb\u01cc\3\2\2\2" - + "\u01cc\u01ca\3\2\2\2\u01cc\u01cd\3\2\2\2\u01cd\u01d4\3\2\2\2\u01ce\u01d0" - + "\7\60\2\2\u01cf\u01d1\t\2\2\2\u01d0\u01cf\3\2\2\2\u01d1\u01d2\3\2\2\2" - + "\u01d2\u01d0\3\2\2\2\u01d2\u01d3\3\2\2\2\u01d3\u01d5\3\2\2\2\u01d4\u01ce" - + "\3\2\2\2\u01d4\u01d5\3\2\2\2\u01d5|\3\2\2\2\u01d6\u01d8\t\6\2\2\u01d7" + "\u01d6\3\2\2\2\u01d8\u01d9\3\2\2\2\u01d9\u01d7\3\2\2\2\u01d9\u01da\3\2" - + "\2\2\u01da\u01db\3\2\2\2\u01db\u01dc\b?\2\2\u01dc~\3\2\2\2\u01dd\u01de" + "\7\61\2\2\u01de\u01df\7,\2\2\u01df\u01e3\3\2\2\2\u01e0\u01e2\13\2\2\2" - + "\u01e1\u01e0\3\2\2\2\u01e2\u01e5\3\2\2\2\u01e3\u01e4\3\2\2\2\u01e3\u01e1" - + "\3\2\2\2\u01e4\u01e6\3\2\2\2\u01e5\u01e3\3\2\2\2\u01e6\u01e7\7,\2\2\u01e7" - + "\u01e8\7\61\2\2\u01e8\u01e9\3\2\2\2\u01e9\u01ea\b@\2\2\u01ea\u0080\3\2" - + "\2\2\u01eb\u01ec\7\61\2\2\u01ec\u01ed\7\61\2\2\u01ed\u01f1\3\2\2\2\u01ee" - + "\u01f0\n\7\2\2\u01ef\u01ee\3\2\2\2\u01f0\u01f3\3\2\2\2\u01f1\u01ef\3\2" - + "\2\2\u01f1\u01f2\3\2\2\2\u01f2\u01f4\3\2\2\2\u01f3\u01f1\3\2\2\2\u01f4" - + "\u01f5\bA\2\2\u01f5\u0082\3\2\2\2\u01f6\u01f9\7^\2\2\u01f7\u01fa\t\b\2" - + "\2\u01f8\u01fa\5\u0085C\2\u01f9\u01f7\3\2\2\2\u01f9\u01f8\3\2\2\2\u01fa" - + "\u0084\3\2\2\2\u01fb\u01fc\7w\2\2\u01fc\u01fd\5\u0087D\2\u01fd\u01fe\5" + "\u0087D\2\u01fe\u01ff\5\u0087D\2\u01ff\u0200\5\u0087D\2\u0200\u0086\3" - + "\2\2\2\u0201\u0202\t\t\2\2\u0202\u0088\3\2\2\2\32\2\u0182\u0184\u0186" - + "\u0189\u019b\u019d\u019f\u01a1\u01aa\u01ad\u01b0\u01b2\u01b8\u01ba\u01c2" + "\u01c4\u01cc\u01d2\u01d4\u01d9\u01e3\u01f1\u01f9\3\2\3\2"; - public static final ATN _ATN = new ATNDeserializer().deserialize(_serializedATN.toCharArray()); + public static final String _serializedATN = + "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\2B\u020d\b\1\4\2\t"+ + "\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13"+ + "\t\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22"+ + "\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30\4\31\t\31"+ + "\4\32\t\32\4\33\t\33\4\34\t\34\4\35\t\35\4\36\t\36\4\37\t\37\4 \t \4!"+ + "\t!\4\"\t\"\4#\t#\4$\t$\4%\t%\4&\t&\4\'\t\'\4(\t(\4)\t)\4*\t*\4+\t+\4"+ + ",\t,\4-\t-\4.\t.\4/\t/\4\60\t\60\4\61\t\61\4\62\t\62\4\63\t\63\4\64\t"+ + "\64\4\65\t\65\4\66\t\66\4\67\t\67\48\t8\49\t9\4:\t:\4;\t;\4<\t<\4=\t="+ + "\4>\t>\4?\t?\4@\t@\4A\tA\4B\tB\4C\tC\4D\tD\4E\tE\4F\tF\4G\tG\3\2\3\2\3"+ + "\3\3\3\3\4\3\4\3\5\3\5\3\6\3\6\3\7\3\7\3\b\3\b\3\t\3\t\3\t\3\t\3\n\3\n"+ + "\3\n\3\n\3\13\3\13\3\f\3\f\3\f\3\r\3\r\3\r\3\16\3\16\3\17\3\17\3\17\3"+ + "\20\3\20\3\21\3\21\3\22\3\22\3\22\3\23\3\23\3\24\3\24\3\25\3\25\3\25\3"+ + "\26\3\26\3\26\3\27\3\27\3\27\3\30\3\30\3\30\3\30\3\30\3\30\3\30\3\30\3"+ + "\30\3\31\3\31\3\31\3\31\3\32\3\32\3\32\3\33\3\33\3\33\3\33\3\34\3\34\3"+ + "\34\3\34\3\34\3\34\3\34\3\34\3\35\3\35\3\36\3\36\3\37\3\37\3 \3 \3!\3"+ + "!\3!\3!\3!\3\"\3\"\3\"\3\"\3\"\3\"\3#\3#\3$\3$\3$\3$\3$\3$\3%\3%\3%\3"+ + "%\3%\3%\3%\3&\3&\3&\3&\3&\3&\3&\3\'\3\'\3(\3(\3(\3(\3(\3)\3)\3)\3)\3)"+ + "\3)\3*\3*\3*\3*\3*\3+\3+\3+\3+\3,\3,\3,\3,\3,\3-\3-\3-\3-\3-\3-\3-\3."+ + "\3.\3.\3.\3.\3.\3.\3/\3/\3/\3/\3/\3/\3/\3/\3/\3/\3/\3/\3\60\3\60\3\60"+ + "\3\60\3\60\3\60\3\61\3\61\3\61\3\61\3\61\3\61\3\61\3\62\3\62\3\62\3\62"+ + "\3\62\3\62\3\63\3\63\3\63\3\63\3\63\3\64\3\64\3\64\3\64\3\64\3\64\3\65"+ + "\3\65\3\65\3\65\3\65\3\65\3\65\3\65\3\66\3\66\3\66\3\66\3\66\3\66\3\66"+ + "\3\66\3\67\3\67\3\67\3\67\3\67\3\67\3\67\3\67\3\67\3\67\3\67\3\67\3\67"+ + "\38\38\38\39\39\39\39\39\59\u0184\n9\59\u0186\n9\3:\3:\3:\3:\3;\3;\3;"+ + "\3;\3;\3;\3;\3;\3;\3;\5;\u0196\n;\5;\u0198\n;\3<\3<\3<\3<\3<\3<\3<\3<"+ + "\3<\3<\6<\u01a4\n<\r<\16<\u01a5\5<\u01a8\n<\5<\u01aa\n<\5<\u01ac\n<\3"+ + "=\3=\3=\3=\3=\3=\3=\5=\u01b5\n=\3>\5>\u01b8\n>\3>\7>\u01bb\n>\f>\16>\u01be"+ + "\13>\3?\3?\3?\7?\u01c3\n?\f?\16?\u01c6\13?\3?\3?\3@\3@\3@\7@\u01cd\n@"+ + "\f@\16@\u01d0\13@\3@\3@\3A\6A\u01d5\nA\rA\16A\u01d6\3A\3A\6A\u01db\nA"+ + "\rA\16A\u01dc\5A\u01df\nA\3B\6B\u01e2\nB\rB\16B\u01e3\3B\3B\3C\3C\3C\3"+ + "C\7C\u01ec\nC\fC\16C\u01ef\13C\3C\3C\3C\3C\3C\3D\3D\3D\3D\7D\u01fa\nD"+ + "\fD\16D\u01fd\13D\3D\3D\3E\3E\3E\5E\u0204\nE\3F\3F\3F\3F\3F\3F\3G\3G\5"+ + "\u01c4\u01ce\u01ed\2H\3\3\5\4\7\5\t\6\13\7\r\b\17\t\21\n\23\13\25\f\27"+ + "\r\31\16\33\17\35\20\37\21!\22#\23%\24\'\25)\26+\27-\30/\31\61\32\63\33"+ + "\65\34\67\359\36;\37= ?!A\"C#E$G%I&K\'M(O)Q*S+U,W-Y.[/]\60_\61a\62c\63"+ + "e\64g\65i\66k\67m8o9q:s;u\2w\2y\2{<}=\177>\u0081?\u0083@\u0085A\u0087"+ + "B\u0089\2\u008b\2\u008d\2\3\2\n\3\2\62;\4\2--//\5\2C\\aac|\6\2\62;C\\"+ + "aac|\5\2\13\f\17\17\"\"\4\2\f\f\17\17\n\2))\61\61^^bbhhppttvv\5\2\62;"+ + "CHch\2\u021b\2\3\3\2\2\2\2\5\3\2\2\2\2\7\3\2\2\2\2\t\3\2\2\2\2\13\3\2"+ + "\2\2\2\r\3\2\2\2\2\17\3\2\2\2\2\21\3\2\2\2\2\23\3\2\2\2\2\25\3\2\2\2\2"+ + "\27\3\2\2\2\2\31\3\2\2\2\2\33\3\2\2\2\2\35\3\2\2\2\2\37\3\2\2\2\2!\3\2"+ + "\2\2\2#\3\2\2\2\2%\3\2\2\2\2\'\3\2\2\2\2)\3\2\2\2\2+\3\2\2\2\2-\3\2\2"+ + "\2\2/\3\2\2\2\2\61\3\2\2\2\2\63\3\2\2\2\2\65\3\2\2\2\2\67\3\2\2\2\29\3"+ + "\2\2\2\2;\3\2\2\2\2=\3\2\2\2\2?\3\2\2\2\2A\3\2\2\2\2C\3\2\2\2\2E\3\2\2"+ + "\2\2G\3\2\2\2\2I\3\2\2\2\2K\3\2\2\2\2M\3\2\2\2\2O\3\2\2\2\2Q\3\2\2\2\2"+ + "S\3\2\2\2\2U\3\2\2\2\2W\3\2\2\2\2Y\3\2\2\2\2[\3\2\2\2\2]\3\2\2\2\2_\3"+ + "\2\2\2\2a\3\2\2\2\2c\3\2\2\2\2e\3\2\2\2\2g\3\2\2\2\2i\3\2\2\2\2k\3\2\2"+ + "\2\2m\3\2\2\2\2o\3\2\2\2\2q\3\2\2\2\2s\3\2\2\2\2{\3\2\2\2\2}\3\2\2\2\2"+ + "\177\3\2\2\2\2\u0081\3\2\2\2\2\u0083\3\2\2\2\2\u0085\3\2\2\2\2\u0087\3"+ + "\2\2\2\3\u008f\3\2\2\2\5\u0091\3\2\2\2\7\u0093\3\2\2\2\t\u0095\3\2\2\2"+ + "\13\u0097\3\2\2\2\r\u0099\3\2\2\2\17\u009b\3\2\2\2\21\u009d\3\2\2\2\23"+ + "\u00a1\3\2\2\2\25\u00a5\3\2\2\2\27\u00a7\3\2\2\2\31\u00aa\3\2\2\2\33\u00ad"+ + "\3\2\2\2\35\u00af\3\2\2\2\37\u00b2\3\2\2\2!\u00b4\3\2\2\2#\u00b6\3\2\2"+ + "\2%\u00b9\3\2\2\2\'\u00bb\3\2\2\2)\u00bd\3\2\2\2+\u00c0\3\2\2\2-\u00c3"+ + "\3\2\2\2/\u00c6\3\2\2\2\61\u00cf\3\2\2\2\63\u00d3\3\2\2\2\65\u00d6\3\2"+ + "\2\2\67\u00da\3\2\2\29\u00e2\3\2\2\2;\u00e4\3\2\2\2=\u00e6\3\2\2\2?\u00e8"+ + "\3\2\2\2A\u00ea\3\2\2\2C\u00ef\3\2\2\2E\u00f5\3\2\2\2G\u00f7\3\2\2\2I"+ + "\u00fd\3\2\2\2K\u0104\3\2\2\2M\u010b\3\2\2\2O\u010d\3\2\2\2Q\u0112\3\2"+ + "\2\2S\u0118\3\2\2\2U\u011d\3\2\2\2W\u0121\3\2\2\2Y\u0126\3\2\2\2[\u012d"+ + "\3\2\2\2]\u0134\3\2\2\2_\u0140\3\2\2\2a\u0146\3\2\2\2c\u014d\3\2\2\2e"+ + "\u0153\3\2\2\2g\u0158\3\2\2\2i\u015e\3\2\2\2k\u0166\3\2\2\2m\u016e\3\2"+ + "\2\2o\u017b\3\2\2\2q\u017e\3\2\2\2s\u0187\3\2\2\2u\u018b\3\2\2\2w\u0199"+ + "\3\2\2\2y\u01b4\3\2\2\2{\u01b7\3\2\2\2}\u01bf\3\2\2\2\177\u01c9\3\2\2"+ + "\2\u0081\u01d4\3\2\2\2\u0083\u01e1\3\2\2\2\u0085\u01e7\3\2\2\2\u0087\u01f5"+ + "\3\2\2\2\u0089\u0200\3\2\2\2\u008b\u0205\3\2\2\2\u008d\u020b\3\2\2\2\u008f"+ + "\u0090\7\60\2\2\u0090\4\3\2\2\2\u0091\u0092\7]\2\2\u0092\6\3\2\2\2\u0093"+ + "\u0094\7_\2\2\u0094\b\3\2\2\2\u0095\u0096\7-\2\2\u0096\n\3\2\2\2\u0097"+ + "\u0098\7/\2\2\u0098\f\3\2\2\2\u0099\u009a\7,\2\2\u009a\16\3\2\2\2\u009b"+ + "\u009c\7\61\2\2\u009c\20\3\2\2\2\u009d\u009e\7f\2\2\u009e\u009f\7k\2\2"+ + "\u009f\u00a0\7x\2\2\u00a0\22\3\2\2\2\u00a1\u00a2\7o\2\2\u00a2\u00a3\7"+ + "q\2\2\u00a3\u00a4\7f\2\2\u00a4\24\3\2\2\2\u00a5\u00a6\7(\2\2\u00a6\26"+ + "\3\2\2\2\u00a7\u00a8\7k\2\2\u00a8\u00a9\7u\2\2\u00a9\30\3\2\2\2\u00aa"+ + "\u00ab\7c\2\2\u00ab\u00ac\7u\2\2\u00ac\32\3\2\2\2\u00ad\u00ae\7~\2\2\u00ae"+ + "\34\3\2\2\2\u00af\u00b0\7>\2\2\u00b0\u00b1\7?\2\2\u00b1\36\3\2\2\2\u00b2"+ + "\u00b3\7>\2\2\u00b3 \3\2\2\2\u00b4\u00b5\7@\2\2\u00b5\"\3\2\2\2\u00b6"+ + "\u00b7\7@\2\2\u00b7\u00b8\7?\2\2\u00b8$\3\2\2\2\u00b9\u00ba\7?\2\2\u00ba"+ + "&\3\2\2\2\u00bb\u00bc\7\u0080\2\2\u00bc(\3\2\2\2\u00bd\u00be\7#\2\2\u00be"+ + "\u00bf\7?\2\2\u00bf*\3\2\2\2\u00c0\u00c1\7#\2\2\u00c1\u00c2\7\u0080\2"+ + "\2\u00c2,\3\2\2\2\u00c3\u00c4\7k\2\2\u00c4\u00c5\7p\2\2\u00c5.\3\2\2\2"+ + "\u00c6\u00c7\7e\2\2\u00c7\u00c8\7q\2\2\u00c8\u00c9\7p\2\2\u00c9\u00ca"+ + "\7v\2\2\u00ca\u00cb\7c\2\2\u00cb\u00cc\7k\2\2\u00cc\u00cd\7p\2\2\u00cd"+ + "\u00ce\7u\2\2\u00ce\60\3\2\2\2\u00cf\u00d0\7c\2\2\u00d0\u00d1\7p\2\2\u00d1"+ + "\u00d2\7f\2\2\u00d2\62\3\2\2\2\u00d3\u00d4\7q\2\2\u00d4\u00d5\7t\2\2\u00d5"+ + "\64\3\2\2\2\u00d6\u00d7\7z\2\2\u00d7\u00d8\7q\2\2\u00d8\u00d9\7t\2\2\u00d9"+ + "\66\3\2\2\2\u00da\u00db\7k\2\2\u00db\u00dc\7o\2\2\u00dc\u00dd\7r\2\2\u00dd"+ + "\u00de\7n\2\2\u00de\u00df\7k\2\2\u00df\u00e0\7g\2\2\u00e0\u00e1\7u\2\2"+ + "\u00e18\3\2\2\2\u00e2\u00e3\7*\2\2\u00e3:\3\2\2\2\u00e4\u00e5\7+\2\2\u00e5"+ + "<\3\2\2\2\u00e6\u00e7\7}\2\2\u00e7>\3\2\2\2\u00e8\u00e9\7\177\2\2\u00e9"+ + "@\3\2\2\2\u00ea\u00eb\7v\2\2\u00eb\u00ec\7t\2\2\u00ec\u00ed\7w\2\2\u00ed"+ + "\u00ee\7g\2\2\u00eeB\3\2\2\2\u00ef\u00f0\7h\2\2\u00f0\u00f1\7c\2\2\u00f1"+ + "\u00f2\7n\2\2\u00f2\u00f3\7u\2\2\u00f3\u00f4\7g\2\2\u00f4D\3\2\2\2\u00f5"+ + "\u00f6\7\'\2\2\u00f6F\3\2\2\2\u00f7\u00f8\7&\2\2\u00f8\u00f9\7v\2\2\u00f9"+ + "\u00fa\7j\2\2\u00fa\u00fb\7k\2\2\u00fb\u00fc\7u\2\2\u00fcH\3\2\2\2\u00fd"+ + "\u00fe\7&\2\2\u00fe\u00ff\7k\2\2\u00ff\u0100\7p\2\2\u0100\u0101\7f\2\2"+ + "\u0101\u0102\7g\2\2\u0102\u0103\7z\2\2\u0103J\3\2\2\2\u0104\u0105\7&\2"+ + "\2\u0105\u0106\7v\2\2\u0106\u0107\7q\2\2\u0107\u0108\7v\2\2\u0108\u0109"+ + "\7c\2\2\u0109\u010a\7n\2\2\u010aL\3\2\2\2\u010b\u010c\7.\2\2\u010cN\3"+ + "\2\2\2\u010d\u010e\7{\2\2\u010e\u010f\7g\2\2\u010f\u0110\7c\2\2\u0110"+ + "\u0111\7t\2\2\u0111P\3\2\2\2\u0112\u0113\7o\2\2\u0113\u0114\7q\2\2\u0114"+ + "\u0115\7p\2\2\u0115\u0116\7v\2\2\u0116\u0117\7j\2\2\u0117R\3\2\2\2\u0118"+ + "\u0119\7y\2\2\u0119\u011a\7g\2\2\u011a\u011b\7g\2\2\u011b\u011c\7m\2\2"+ + "\u011cT\3\2\2\2\u011d\u011e\7f\2\2\u011e\u011f\7c\2\2\u011f\u0120\7{\2"+ + "\2\u0120V\3\2\2\2\u0121\u0122\7j\2\2\u0122\u0123\7q\2\2\u0123\u0124\7"+ + "w\2\2\u0124\u0125\7t\2\2\u0125X\3\2\2\2\u0126\u0127\7o\2\2\u0127\u0128"+ + "\7k\2\2\u0128\u0129\7p\2\2\u0129\u012a\7w\2\2\u012a\u012b\7v\2\2\u012b"+ + "\u012c\7g\2\2\u012cZ\3\2\2\2\u012d\u012e\7u\2\2\u012e\u012f\7g\2\2\u012f"+ + "\u0130\7e\2\2\u0130\u0131\7q\2\2\u0131\u0132\7p\2\2\u0132\u0133\7f\2\2"+ + "\u0133\\\3\2\2\2\u0134\u0135\7o\2\2\u0135\u0136\7k\2\2\u0136\u0137\7n"+ + "\2\2\u0137\u0138\7n\2\2\u0138\u0139\7k\2\2\u0139\u013a\7u\2\2\u013a\u013b"+ + "\7g\2\2\u013b\u013c\7e\2\2\u013c\u013d\7q\2\2\u013d\u013e\7p\2\2\u013e"+ + "\u013f\7f\2\2\u013f^\3\2\2\2\u0140\u0141\7{\2\2\u0141\u0142\7g\2\2\u0142"+ + "\u0143\7c\2\2\u0143\u0144\7t\2\2\u0144\u0145\7u\2\2\u0145`\3\2\2\2\u0146"+ + "\u0147\7o\2\2\u0147\u0148\7q\2\2\u0148\u0149\7p\2\2\u0149\u014a\7v\2\2"+ + "\u014a\u014b\7j\2\2\u014b\u014c\7u\2\2\u014cb\3\2\2\2\u014d\u014e\7y\2"+ + "\2\u014e\u014f\7g\2\2\u014f\u0150\7g\2\2\u0150\u0151\7m\2\2\u0151\u0152"+ + "\7u\2\2\u0152d\3\2\2\2\u0153\u0154\7f\2\2\u0154\u0155\7c\2\2\u0155\u0156"+ + "\7{\2\2\u0156\u0157\7u\2\2\u0157f\3\2\2\2\u0158\u0159\7j\2\2\u0159\u015a"+ + "\7q\2\2\u015a\u015b\7w\2\2\u015b\u015c\7t\2\2\u015c\u015d\7u\2\2\u015d"+ + "h\3\2\2\2\u015e\u015f\7o\2\2\u015f\u0160\7k\2\2\u0160\u0161\7p\2\2\u0161"+ + "\u0162\7w\2\2\u0162\u0163\7v\2\2\u0163\u0164\7g\2\2\u0164\u0165\7u\2\2"+ + "\u0165j\3\2\2\2\u0166\u0167\7u\2\2\u0167\u0168\7g\2\2\u0168\u0169\7e\2"+ + "\2\u0169\u016a\7q\2\2\u016a\u016b\7p\2\2\u016b\u016c\7f\2\2\u016c\u016d"+ + "\7u\2\2\u016dl\3\2\2\2\u016e\u016f\7o\2\2\u016f\u0170\7k\2\2\u0170\u0171"+ + "\7n\2\2\u0171\u0172\7n\2\2\u0172\u0173\7k\2\2\u0173\u0174\7u\2\2\u0174"+ + "\u0175\7g\2\2\u0175\u0176\7e\2\2\u0176\u0177\7q\2\2\u0177\u0178\7p\2\2"+ + "\u0178\u0179\7f\2\2\u0179\u017a\7u\2\2\u017an\3\2\2\2\u017b\u017c\7B\2"+ + "\2\u017c\u017d\5u;\2\u017dp\3\2\2\2\u017e\u017f\7B\2\2\u017f\u0180\5u"+ + ";\2\u0180\u0185\7V\2\2\u0181\u0183\5w<\2\u0182\u0184\5y=\2\u0183\u0182"+ + "\3\2\2\2\u0183\u0184\3\2\2\2\u0184\u0186\3\2\2\2\u0185\u0181\3\2\2\2\u0185"+ + "\u0186\3\2\2\2\u0186r\3\2\2\2\u0187\u0188\7B\2\2\u0188\u0189\7V\2\2\u0189"+ + "\u018a\5w<\2\u018at\3\2\2\2\u018b\u018c\t\2\2\2\u018c\u018d\t\2\2\2\u018d"+ + "\u018e\t\2\2\2\u018e\u0197\t\2\2\2\u018f\u0190\7/\2\2\u0190\u0191\t\2"+ + "\2\2\u0191\u0195\t\2\2\2\u0192\u0193\7/\2\2\u0193\u0194\t\2\2\2\u0194"+ + "\u0196\t\2\2\2\u0195\u0192\3\2\2\2\u0195\u0196\3\2\2\2\u0196\u0198\3\2"+ + "\2\2\u0197\u018f\3\2\2\2\u0197\u0198\3\2\2\2\u0198v\3\2\2\2\u0199\u019a"+ + "\t\2\2\2\u019a\u01ab\t\2\2\2\u019b\u019c\7<\2\2\u019c\u019d\t\2\2\2\u019d"+ + "\u01a9\t\2\2\2\u019e\u019f\7<\2\2\u019f\u01a0\t\2\2\2\u01a0\u01a7\t\2"+ + "\2\2\u01a1\u01a3\7\60\2\2\u01a2\u01a4\t\2\2\2\u01a3\u01a2\3\2\2\2\u01a4"+ + "\u01a5\3\2\2\2\u01a5\u01a3\3\2\2\2\u01a5\u01a6\3\2\2\2\u01a6\u01a8\3\2"+ + "\2\2\u01a7\u01a1\3\2\2\2\u01a7\u01a8\3\2\2\2\u01a8\u01aa\3\2\2\2\u01a9"+ + "\u019e\3\2\2\2\u01a9\u01aa\3\2\2\2\u01aa\u01ac\3\2\2\2\u01ab\u019b\3\2"+ + "\2\2\u01ab\u01ac\3\2\2\2\u01acx\3\2\2\2\u01ad\u01b5\7\\\2\2\u01ae\u01af"+ + "\t\3\2\2\u01af\u01b0\t\2\2\2\u01b0\u01b1\t\2\2\2\u01b1\u01b2\7<\2\2\u01b2"+ + "\u01b3\t\2\2\2\u01b3\u01b5\t\2\2\2\u01b4\u01ad\3\2\2\2\u01b4\u01ae\3\2"+ + "\2\2\u01b5z\3\2\2\2\u01b6\u01b8\t\4\2\2\u01b7\u01b6\3\2\2\2\u01b8\u01bc"+ + "\3\2\2\2\u01b9\u01bb\t\5\2\2\u01ba\u01b9\3\2\2\2\u01bb\u01be\3\2\2\2\u01bc"+ + "\u01ba\3\2\2\2\u01bc\u01bd\3\2\2\2\u01bd|\3\2\2\2\u01be\u01bc\3\2\2\2"+ + "\u01bf\u01c4\7b\2\2\u01c0\u01c3\5\u0089E\2\u01c1\u01c3\13\2\2\2\u01c2"+ + "\u01c0\3\2\2\2\u01c2\u01c1\3\2\2\2\u01c3\u01c6\3\2\2\2\u01c4\u01c5\3\2"+ + "\2\2\u01c4\u01c2\3\2\2\2\u01c5\u01c7\3\2\2\2\u01c6\u01c4\3\2\2\2\u01c7"+ + "\u01c8\7b\2\2\u01c8~\3\2\2\2\u01c9\u01ce\7)\2\2\u01ca\u01cd\5\u0089E\2"+ + "\u01cb\u01cd\13\2\2\2\u01cc\u01ca\3\2\2\2\u01cc\u01cb\3\2\2\2\u01cd\u01d0"+ + "\3\2\2\2\u01ce\u01cf\3\2\2\2\u01ce\u01cc\3\2\2\2\u01cf\u01d1\3\2\2\2\u01d0"+ + "\u01ce\3\2\2\2\u01d1\u01d2\7)\2\2\u01d2\u0080\3\2\2\2\u01d3\u01d5\t\2"+ + "\2\2\u01d4\u01d3\3\2\2\2\u01d5\u01d6\3\2\2\2\u01d6\u01d4\3\2\2\2\u01d6"+ + "\u01d7\3\2\2\2\u01d7\u01de\3\2\2\2\u01d8\u01da\7\60\2\2\u01d9\u01db\t"+ + "\2\2\2\u01da\u01d9\3\2\2\2\u01db\u01dc\3\2\2\2\u01dc\u01da\3\2\2\2\u01dc"+ + "\u01dd\3\2\2\2\u01dd\u01df\3\2\2\2\u01de\u01d8\3\2\2\2\u01de\u01df\3\2"+ + "\2\2\u01df\u0082\3\2\2\2\u01e0\u01e2\t\6\2\2\u01e1\u01e0\3\2\2\2\u01e2"+ + "\u01e3\3\2\2\2\u01e3\u01e1\3\2\2\2\u01e3\u01e4\3\2\2\2\u01e4\u01e5\3\2"+ + "\2\2\u01e5\u01e6\bB\2\2\u01e6\u0084\3\2\2\2\u01e7\u01e8\7\61\2\2\u01e8"+ + "\u01e9\7,\2\2\u01e9\u01ed\3\2\2\2\u01ea\u01ec\13\2\2\2\u01eb\u01ea\3\2"+ + "\2\2\u01ec\u01ef\3\2\2\2\u01ed\u01ee\3\2\2\2\u01ed\u01eb\3\2\2\2\u01ee"+ + "\u01f0\3\2\2\2\u01ef\u01ed\3\2\2\2\u01f0\u01f1\7,\2\2\u01f1\u01f2\7\61"+ + "\2\2\u01f2\u01f3\3\2\2\2\u01f3\u01f4\bC\2\2\u01f4\u0086\3\2\2\2\u01f5"+ + "\u01f6\7\61\2\2\u01f6\u01f7\7\61\2\2\u01f7\u01fb\3\2\2\2\u01f8\u01fa\n"+ + "\7\2\2\u01f9\u01f8\3\2\2\2\u01fa\u01fd\3\2\2\2\u01fb\u01f9\3\2\2\2\u01fb"+ + "\u01fc\3\2\2\2\u01fc\u01fe\3\2\2\2\u01fd\u01fb\3\2\2\2\u01fe\u01ff\bD"+ + "\2\2\u01ff\u0088\3\2\2\2\u0200\u0203\7^\2\2\u0201\u0204\t\b\2\2\u0202"+ + "\u0204\5\u008bF\2\u0203\u0201\3\2\2\2\u0203\u0202\3\2\2\2\u0204\u008a"+ + "\3\2\2\2\u0205\u0206\7w\2\2\u0206\u0207\5\u008dG\2\u0207\u0208\5\u008d"+ + "G\2\u0208\u0209\5\u008dG\2\u0209\u020a\5\u008dG\2\u020a\u008c\3\2\2\2"+ + "\u020b\u020c\t\t\2\2\u020c\u008e\3\2\2\2\32\2\u0183\u0185\u0195\u0197"+ + "\u01a5\u01a7\u01a9\u01ab\u01b4\u01b7\u01ba\u01bc\u01c2\u01c4\u01cc\u01ce"+ + "\u01d6\u01dc\u01de\u01e3\u01ed\u01fb\u0203\3\2\3\2"; + public static final ATN _ATN = + new ATNDeserializer().deserialize(_serializedATN.toCharArray()); static { _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); } } -} +} \ No newline at end of file diff --git a/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathLexer.tokens b/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathLexer.tokens index 0fe45617b71..38c5116464f 100644 --- a/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathLexer.tokens +++ b/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathLexer.tokens @@ -52,15 +52,16 @@ T__50=51 T__51=52 T__52=53 T__53=54 -DATETIME=55 -TIME=56 -IDENTIFIER=57 -DELIMITEDIDENTIFIER=58 -STRING=59 -NUMBER=60 -WS=61 -COMMENT=62 -LINE_COMMENT=63 +DATE=55 +DATETIME=56 +TIME=57 +IDENTIFIER=58 +DELIMITEDIDENTIFIER=59 +STRING=60 +NUMBER=61 +WS=62 +COMMENT=63 +LINE_COMMENT=64 '.'=1 '['=2 ']'=3 diff --git a/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathNode.java b/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathNode.java index 7300a273aee..1968684da17 100644 --- a/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathNode.java +++ b/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathNode.java @@ -16,7 +16,7 @@ public interface FHIRPathNode extends Comparable { String path(); FHIRPathType type(); boolean hasValue(); - FHIRPathPrimitiveValue getValue(); + FHIRPathSystemValue getValue(); Collection children(); Stream stream(); Collection descendants(); @@ -31,7 +31,7 @@ default boolean isElementNode() { default boolean isResourceNode() { return false; } - default boolean isPrimitiveValue() { + default boolean isSystemValue() { return false; } default boolean isTypeInfoNode() { @@ -43,8 +43,8 @@ default FHIRPathElementNode asElementNode() { default FHIRPathResourceNode asResourceNode() { return as(FHIRPathResourceNode.class); } - default FHIRPathPrimitiveValue asPrimitiveValue() { - return as(FHIRPathPrimitiveValue.class); + default FHIRPathSystemValue asSystemValue() { + return as(FHIRPathSystemValue.class); } default FHIRPathTypeInfoNode asTypeInfoNode() { return as(FHIRPathTypeInfoNode.class); @@ -52,13 +52,10 @@ default FHIRPathTypeInfoNode asTypeInfoNode() { interface Builder { Builder name(String name); Builder path(String path); - Builder value(FHIRPathPrimitiveValue value); + Builder value(FHIRPathSystemValue value); Builder children(FHIRPathNode... children); Builder children(Collection children); FHIRPathNode build(); } - void accept(T param, FHIRPathNodeVisitor visitor); - default void accept(FHIRPathNodeVisitor visitor) { - accept(null, visitor); - } + void accept(FHIRPathNodeVisitor visitor); } \ No newline at end of file diff --git a/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathNumberValue.java b/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathNumberValue.java index 77706456f04..d055952a272 100644 --- a/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathNumberValue.java +++ b/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathNumberValue.java @@ -8,7 +8,7 @@ import java.math.BigDecimal; -public interface FHIRPathNumberValue extends FHIRPathPrimitiveValue { +public interface FHIRPathNumberValue extends FHIRPathSystemValue { @Override default boolean isNumberValue() { return true; @@ -52,10 +52,9 @@ default Number number() { @Override default boolean isComparableTo(FHIRPathNode other) { - if (other instanceof FHIRPathQuantityNode) { - return ((FHIRPathQuantityNode) other).isComparableTo(this); - } - return other instanceof FHIRPathNumberValue || + return other instanceof FHIRPathQuantityValue || + other.getValue() instanceof FHIRPathQuantityValue || + other instanceof FHIRPathNumberValue || other.getValue() instanceof FHIRPathNumberValue; } @@ -64,8 +63,11 @@ default int compareTo(FHIRPathNode other) { if (!isComparableTo(other)) { throw new IllegalArgumentException(); } - if (other instanceof FHIRPathQuantityNode) { - return decimal().compareTo(((FHIRPathQuantityNode) other).getQuantityValue()); + if (other instanceof FHIRPathQuantityValue) { + return decimal().compareTo(((FHIRPathQuantityValue) other).value()); + } + if (other.getValue() instanceof FHIRPathQuantityValue) { + return decimal().compareTo(((FHIRPathQuantityValue) other.getValue()).value()); } FHIRPathNumberValue value = (FHIRPathNumberValue) ((other instanceof FHIRPathNumberValue) ? other : other.getValue()); return decimal().compareTo(value.decimal()); diff --git a/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathParser.java b/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathParser.java index 2ee01385b91..7267a68b5d3 100644 --- a/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathParser.java +++ b/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathParser.java @@ -1,59 +1,69 @@ -/* - * (C) Copyright IBM Corp. 2019 - * - * SPDX-License-Identifier: Apache-2.0 - */ - +// Generated from FHIRPath.g4 by ANTLR 4.7.2 package com.ibm.fhir.model.path; - -import java.util.List; - -import org.antlr.v4.runtime.FailedPredicateException; -import org.antlr.v4.runtime.NoViableAltException; -import org.antlr.v4.runtime.Parser; -import org.antlr.v4.runtime.ParserRuleContext; -import org.antlr.v4.runtime.RecognitionException; -import org.antlr.v4.runtime.RuleContext; -import org.antlr.v4.runtime.RuntimeMetaData; -import org.antlr.v4.runtime.TokenStream; -import org.antlr.v4.runtime.Vocabulary; -import org.antlr.v4.runtime.VocabularyImpl; -import org.antlr.v4.runtime.atn.ATN; -import org.antlr.v4.runtime.atn.ATNDeserializer; -import org.antlr.v4.runtime.atn.ParserATNSimulator; -import org.antlr.v4.runtime.atn.PredictionContextCache; +import org.antlr.v4.runtime.atn.*; import org.antlr.v4.runtime.dfa.DFA; -import org.antlr.v4.runtime.tree.ParseTreeVisitor; -import org.antlr.v4.runtime.tree.TerminalNode; +import org.antlr.v4.runtime.*; +import org.antlr.v4.runtime.misc.*; +import org.antlr.v4.runtime.tree.*; +import java.util.List; +import java.util.Iterator; +import java.util.ArrayList; -@SuppressWarnings({ "all", "warnings", "unchecked", "unused", "cast" }) +@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"}) public class FHIRPathParser extends Parser { - static { - RuntimeMetaData.checkVersion("4.5.3", RuntimeMetaData.VERSION); - } + static { RuntimeMetaData.checkVersion("4.7.2", RuntimeMetaData.VERSION); } protected static final DFA[] _decisionToDFA; - protected static final PredictionContextCache _sharedContextCache = new PredictionContextCache(); - public static final int T__0 = 1, T__1 = 2, T__2 = 3, T__3 = 4, T__4 = 5, T__5 = 6, T__6 = 7, T__7 = 8, T__8 = 9, T__9 = 10, T__10 = 11, T__11 = 12, - T__12 = 13, T__13 = 14, T__14 = 15, T__15 = 16, T__16 = 17, T__17 = 18, T__18 = 19, T__19 = 20, T__20 = 21, T__21 = 22, T__22 = 23, T__23 = 24, - T__24 = 25, T__25 = 26, T__26 = 27, T__27 = 28, T__28 = 29, T__29 = 30, T__30 = 31, T__31 = 32, T__32 = 33, T__33 = 34, T__34 = 35, T__35 = 36, - T__36 = 37, T__37 = 38, T__38 = 39, T__39 = 40, T__40 = 41, T__41 = 42, T__42 = 43, T__43 = 44, T__44 = 45, T__45 = 46, T__46 = 47, T__47 = 48, - T__48 = 49, T__49 = 50, T__50 = 51, T__51 = 52, T__52 = 53, T__53 = 54, DATETIME = 55, TIME = 56, IDENTIFIER = 57, DELIMITEDIDENTIFIER = 58, - STRING = 59, NUMBER = 60, WS = 61, COMMENT = 62, LINE_COMMENT = 63; - public static final int RULE_expression = 0, RULE_term = 1, RULE_literal = 2, RULE_externalConstant = 3, RULE_invocation = 4, RULE_function = 5, - RULE_paramList = 6, RULE_quantity = 7, RULE_unit = 8, RULE_dateTimePrecision = 9, RULE_pluralDateTimePrecision = 10, RULE_typeSpecifier = 11, - RULE_qualifiedIdentifier = 12, RULE_identifier = 13; - public static final String[] ruleNames = { "expression", "term", "literal", "externalConstant", "invocation", "function", "paramList", "quantity", "unit", - "dateTimePrecision", "pluralDateTimePrecision", "typeSpecifier", "qualifiedIdentifier", "identifier" }; - - private static final String[] _LITERAL_NAMES = { null, "'.'", "'['", "']'", "'+'", "'-'", "'*'", "'/'", "'div'", "'mod'", "'&'", "'is'", "'as'", "'|'", - "'<='", "'<'", "'>'", "'>='", "'='", "'~'", "'!='", "'!~'", "'in'", "'contains'", "'and'", "'or'", "'xor'", "'implies'", "'('", "')'", "'{'", "'}'", - "'true'", "'false'", "'%'", "'$this'", "'$index'", "'$total'", "','", "'year'", "'month'", "'week'", "'day'", "'hour'", "'minute'", "'second'", - "'millisecond'", "'years'", "'months'", "'weeks'", "'days'", "'hours'", "'minutes'", "'seconds'", "'milliseconds'" }; - private static final String[] _SYMBOLIC_NAMES = { null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, - null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, - null, null, null, null, null, null, null, null, null, null, null, null, null, null, "DATETIME", "TIME", "IDENTIFIER", "DELIMITEDIDENTIFIER", - "STRING", "NUMBER", "WS", "COMMENT", "LINE_COMMENT" }; + protected static final PredictionContextCache _sharedContextCache = + new PredictionContextCache(); + public static final int + T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, T__5=6, T__6=7, T__7=8, T__8=9, + T__9=10, T__10=11, T__11=12, T__12=13, T__13=14, T__14=15, T__15=16, T__16=17, + T__17=18, T__18=19, T__19=20, T__20=21, T__21=22, T__22=23, T__23=24, + T__24=25, T__25=26, T__26=27, T__27=28, T__28=29, T__29=30, T__30=31, + T__31=32, T__32=33, T__33=34, T__34=35, T__35=36, T__36=37, T__37=38, + T__38=39, T__39=40, T__40=41, T__41=42, T__42=43, T__43=44, T__44=45, + T__45=46, T__46=47, T__47=48, T__48=49, T__49=50, T__50=51, T__51=52, + T__52=53, T__53=54, DATE=55, DATETIME=56, TIME=57, IDENTIFIER=58, DELIMITEDIDENTIFIER=59, + STRING=60, NUMBER=61, WS=62, COMMENT=63, LINE_COMMENT=64; + public static final int + RULE_expression = 0, RULE_term = 1, RULE_literal = 2, RULE_externalConstant = 3, + RULE_invocation = 4, RULE_function = 5, RULE_paramList = 6, RULE_quantity = 7, + RULE_unit = 8, RULE_dateTimePrecision = 9, RULE_pluralDateTimePrecision = 10, + RULE_typeSpecifier = 11, RULE_qualifiedIdentifier = 12, RULE_identifier = 13; + private static String[] makeRuleNames() { + return new String[] { + "expression", "term", "literal", "externalConstant", "invocation", "function", + "paramList", "quantity", "unit", "dateTimePrecision", "pluralDateTimePrecision", + "typeSpecifier", "qualifiedIdentifier", "identifier" + }; + } + public static final String[] ruleNames = makeRuleNames(); + + private static String[] makeLiteralNames() { + return new String[] { + null, "'.'", "'['", "']'", "'+'", "'-'", "'*'", "'/'", "'div'", "'mod'", + "'&'", "'is'", "'as'", "'|'", "'<='", "'<'", "'>'", "'>='", "'='", "'~'", + "'!='", "'!~'", "'in'", "'contains'", "'and'", "'or'", "'xor'", "'implies'", + "'('", "')'", "'{'", "'}'", "'true'", "'false'", "'%'", "'$this'", "'$index'", + "'$total'", "','", "'year'", "'month'", "'week'", "'day'", "'hour'", + "'minute'", "'second'", "'millisecond'", "'years'", "'months'", "'weeks'", + "'days'", "'hours'", "'minutes'", "'seconds'", "'milliseconds'" + }; + } + private static final String[] _LITERAL_NAMES = makeLiteralNames(); + private static String[] makeSymbolicNames() { + return new String[] { + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, null, null, null, null, null, + null, null, null, null, null, null, null, "DATE", "DATETIME", "TIME", + "IDENTIFIER", "DELIMITEDIDENTIFIER", "STRING", "NUMBER", "WS", "COMMENT", + "LINE_COMMENT" + }; + } + private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames(); public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); /** @@ -88,345 +98,221 @@ public Vocabulary getVocabulary() { } @Override - public String getGrammarFileName() { - return "FHIRPath.g4"; - } + public String getGrammarFileName() { return "FHIRPath.g4"; } @Override - public String[] getRuleNames() { - return ruleNames; - } + public String[] getRuleNames() { return ruleNames; } @Override - public String getSerializedATN() { - return _serializedATN; - } + public String getSerializedATN() { return _serializedATN; } @Override - public ATN getATN() { - return _ATN; - } + public ATN getATN() { return _ATN; } public FHIRPathParser(TokenStream input) { super(input); - _interp = new ParserATNSimulator(this, _ATN, _decisionToDFA, _sharedContextCache); + _interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); } public static class ExpressionContext extends ParserRuleContext { public ExpressionContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } - - @Override - public int getRuleIndex() { - return RULE_expression; - } - - public ExpressionContext() { - } - + @Override public int getRuleIndex() { return RULE_expression; } + + public ExpressionContext() { } public void copyFrom(ExpressionContext ctx) { super.copyFrom(ctx); } } - public static class IndexerExpressionContext extends ExpressionContext { public List expression() { return getRuleContexts(ExpressionContext.class); } - public ExpressionContext expression(int i) { - return getRuleContext(ExpressionContext.class, i); - } - - public IndexerExpressionContext(ExpressionContext ctx) { - copyFrom(ctx); + return getRuleContext(ExpressionContext.class,i); } - + public IndexerExpressionContext(ExpressionContext ctx) { copyFrom(ctx); } @Override public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof FHIRPathVisitor) - return ((FHIRPathVisitor) visitor).visitIndexerExpression(this); - else - return visitor.visitChildren(this); + if ( visitor instanceof FHIRPathVisitor ) return ((FHIRPathVisitor)visitor).visitIndexerExpression(this); + else return visitor.visitChildren(this); } } - public static class PolarityExpressionContext extends ExpressionContext { public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class, 0); - } - - public PolarityExpressionContext(ExpressionContext ctx) { - copyFrom(ctx); + return getRuleContext(ExpressionContext.class,0); } - + public PolarityExpressionContext(ExpressionContext ctx) { copyFrom(ctx); } @Override public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof FHIRPathVisitor) - return ((FHIRPathVisitor) visitor).visitPolarityExpression(this); - else - return visitor.visitChildren(this); + if ( visitor instanceof FHIRPathVisitor ) return ((FHIRPathVisitor)visitor).visitPolarityExpression(this); + else return visitor.visitChildren(this); } } - public static class AdditiveExpressionContext extends ExpressionContext { public List expression() { return getRuleContexts(ExpressionContext.class); } - public ExpressionContext expression(int i) { - return getRuleContext(ExpressionContext.class, i); - } - - public AdditiveExpressionContext(ExpressionContext ctx) { - copyFrom(ctx); + return getRuleContext(ExpressionContext.class,i); } - + public AdditiveExpressionContext(ExpressionContext ctx) { copyFrom(ctx); } @Override public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof FHIRPathVisitor) - return ((FHIRPathVisitor) visitor).visitAdditiveExpression(this); - else - return visitor.visitChildren(this); + if ( visitor instanceof FHIRPathVisitor ) return ((FHIRPathVisitor)visitor).visitAdditiveExpression(this); + else return visitor.visitChildren(this); } } - public static class MultiplicativeExpressionContext extends ExpressionContext { public List expression() { return getRuleContexts(ExpressionContext.class); } - public ExpressionContext expression(int i) { - return getRuleContext(ExpressionContext.class, i); + return getRuleContext(ExpressionContext.class,i); } - - public MultiplicativeExpressionContext(ExpressionContext ctx) { - copyFrom(ctx); - } - + public MultiplicativeExpressionContext(ExpressionContext ctx) { copyFrom(ctx); } @Override public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof FHIRPathVisitor) - return ((FHIRPathVisitor) visitor).visitMultiplicativeExpression(this); - else - return visitor.visitChildren(this); + if ( visitor instanceof FHIRPathVisitor ) return ((FHIRPathVisitor)visitor).visitMultiplicativeExpression(this); + else return visitor.visitChildren(this); } } - public static class UnionExpressionContext extends ExpressionContext { public List expression() { return getRuleContexts(ExpressionContext.class); } - public ExpressionContext expression(int i) { - return getRuleContext(ExpressionContext.class, i); - } - - public UnionExpressionContext(ExpressionContext ctx) { - copyFrom(ctx); + return getRuleContext(ExpressionContext.class,i); } - + public UnionExpressionContext(ExpressionContext ctx) { copyFrom(ctx); } @Override public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof FHIRPathVisitor) - return ((FHIRPathVisitor) visitor).visitUnionExpression(this); - else - return visitor.visitChildren(this); + if ( visitor instanceof FHIRPathVisitor ) return ((FHIRPathVisitor)visitor).visitUnionExpression(this); + else return visitor.visitChildren(this); } } - public static class OrExpressionContext extends ExpressionContext { public List expression() { return getRuleContexts(ExpressionContext.class); } - public ExpressionContext expression(int i) { - return getRuleContext(ExpressionContext.class, i); - } - - public OrExpressionContext(ExpressionContext ctx) { - copyFrom(ctx); + return getRuleContext(ExpressionContext.class,i); } - + public OrExpressionContext(ExpressionContext ctx) { copyFrom(ctx); } @Override public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof FHIRPathVisitor) - return ((FHIRPathVisitor) visitor).visitOrExpression(this); - else - return visitor.visitChildren(this); + if ( visitor instanceof FHIRPathVisitor ) return ((FHIRPathVisitor)visitor).visitOrExpression(this); + else return visitor.visitChildren(this); } } - public static class AndExpressionContext extends ExpressionContext { public List expression() { return getRuleContexts(ExpressionContext.class); } - public ExpressionContext expression(int i) { - return getRuleContext(ExpressionContext.class, i); + return getRuleContext(ExpressionContext.class,i); } - - public AndExpressionContext(ExpressionContext ctx) { - copyFrom(ctx); - } - + public AndExpressionContext(ExpressionContext ctx) { copyFrom(ctx); } @Override public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof FHIRPathVisitor) - return ((FHIRPathVisitor) visitor).visitAndExpression(this); - else - return visitor.visitChildren(this); + if ( visitor instanceof FHIRPathVisitor ) return ((FHIRPathVisitor)visitor).visitAndExpression(this); + else return visitor.visitChildren(this); } } - public static class MembershipExpressionContext extends ExpressionContext { public List expression() { return getRuleContexts(ExpressionContext.class); } - public ExpressionContext expression(int i) { - return getRuleContext(ExpressionContext.class, i); - } - - public MembershipExpressionContext(ExpressionContext ctx) { - copyFrom(ctx); + return getRuleContext(ExpressionContext.class,i); } - + public MembershipExpressionContext(ExpressionContext ctx) { copyFrom(ctx); } @Override public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof FHIRPathVisitor) - return ((FHIRPathVisitor) visitor).visitMembershipExpression(this); - else - return visitor.visitChildren(this); + if ( visitor instanceof FHIRPathVisitor ) return ((FHIRPathVisitor)visitor).visitMembershipExpression(this); + else return visitor.visitChildren(this); } } - public static class InequalityExpressionContext extends ExpressionContext { public List expression() { return getRuleContexts(ExpressionContext.class); } - public ExpressionContext expression(int i) { - return getRuleContext(ExpressionContext.class, i); + return getRuleContext(ExpressionContext.class,i); } - - public InequalityExpressionContext(ExpressionContext ctx) { - copyFrom(ctx); - } - + public InequalityExpressionContext(ExpressionContext ctx) { copyFrom(ctx); } @Override public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof FHIRPathVisitor) - return ((FHIRPathVisitor) visitor).visitInequalityExpression(this); - else - return visitor.visitChildren(this); + if ( visitor instanceof FHIRPathVisitor ) return ((FHIRPathVisitor)visitor).visitInequalityExpression(this); + else return visitor.visitChildren(this); } } - public static class InvocationExpressionContext extends ExpressionContext { public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class, 0); + return getRuleContext(ExpressionContext.class,0); } - public InvocationContext invocation() { - return getRuleContext(InvocationContext.class, 0); + return getRuleContext(InvocationContext.class,0); } - - public InvocationExpressionContext(ExpressionContext ctx) { - copyFrom(ctx); - } - + public InvocationExpressionContext(ExpressionContext ctx) { copyFrom(ctx); } @Override public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof FHIRPathVisitor) - return ((FHIRPathVisitor) visitor).visitInvocationExpression(this); - else - return visitor.visitChildren(this); + if ( visitor instanceof FHIRPathVisitor ) return ((FHIRPathVisitor)visitor).visitInvocationExpression(this); + else return visitor.visitChildren(this); } } - public static class EqualityExpressionContext extends ExpressionContext { public List expression() { return getRuleContexts(ExpressionContext.class); } - public ExpressionContext expression(int i) { - return getRuleContext(ExpressionContext.class, i); - } - - public EqualityExpressionContext(ExpressionContext ctx) { - copyFrom(ctx); + return getRuleContext(ExpressionContext.class,i); } - + public EqualityExpressionContext(ExpressionContext ctx) { copyFrom(ctx); } @Override public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof FHIRPathVisitor) - return ((FHIRPathVisitor) visitor).visitEqualityExpression(this); - else - return visitor.visitChildren(this); + if ( visitor instanceof FHIRPathVisitor ) return ((FHIRPathVisitor)visitor).visitEqualityExpression(this); + else return visitor.visitChildren(this); } } - public static class ImpliesExpressionContext extends ExpressionContext { public List expression() { return getRuleContexts(ExpressionContext.class); } - public ExpressionContext expression(int i) { - return getRuleContext(ExpressionContext.class, i); - } - - public ImpliesExpressionContext(ExpressionContext ctx) { - copyFrom(ctx); + return getRuleContext(ExpressionContext.class,i); } - + public ImpliesExpressionContext(ExpressionContext ctx) { copyFrom(ctx); } @Override public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof FHIRPathVisitor) - return ((FHIRPathVisitor) visitor).visitImpliesExpression(this); - else - return visitor.visitChildren(this); + if ( visitor instanceof FHIRPathVisitor ) return ((FHIRPathVisitor)visitor).visitImpliesExpression(this); + else return visitor.visitChildren(this); } } - public static class TermExpressionContext extends ExpressionContext { public TermContext term() { - return getRuleContext(TermContext.class, 0); - } - - public TermExpressionContext(ExpressionContext ctx) { - copyFrom(ctx); + return getRuleContext(TermContext.class,0); } - + public TermExpressionContext(ExpressionContext ctx) { copyFrom(ctx); } @Override public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof FHIRPathVisitor) - return ((FHIRPathVisitor) visitor).visitTermExpression(this); - else - return visitor.visitChildren(this); + if ( visitor instanceof FHIRPathVisitor ) return ((FHIRPathVisitor)visitor).visitTermExpression(this); + else return visitor.visitChildren(this); } } - public static class TypeExpressionContext extends ExpressionContext { public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class, 0); + return getRuleContext(ExpressionContext.class,0); } - public TypeSpecifierContext typeSpecifier() { - return getRuleContext(TypeSpecifierContext.class, 0); + return getRuleContext(TypeSpecifierContext.class,0); } - - public TypeExpressionContext(ExpressionContext ctx) { - copyFrom(ctx); - } - + public TypeExpressionContext(ExpressionContext ctx) { copyFrom(ctx); } @Override public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof FHIRPathVisitor) - return ((FHIRPathVisitor) visitor).visitTypeExpression(this); - else - return visitor.visitChildren(this); + if ( visitor instanceof FHIRPathVisitor ) return ((FHIRPathVisitor)visitor).visitTypeExpression(this); + else return visitor.visitChildren(this); } } @@ -446,258 +332,289 @@ private ExpressionContext expression(int _p) throws RecognitionException { int _alt; enterOuterAlt(_localctx, 1); { - setState(32); - switch (_input.LA(1)) { - case T__10: - case T__11: - case T__27: - case T__29: - case T__31: - case T__32: - case T__33: - case T__34: - case T__35: - case T__36: - case DATETIME: - case TIME: - case IDENTIFIER: - case DELIMITEDIDENTIFIER: - case STRING: - case NUMBER: { - _localctx = new TermExpressionContext(_localctx); - _ctx = _localctx; - _prevctx = _localctx; + setState(32); + _errHandler.sync(this); + switch (_input.LA(1)) { + case T__10: + case T__11: + case T__21: + case T__22: + case T__27: + case T__29: + case T__31: + case T__32: + case T__33: + case T__34: + case T__35: + case T__36: + case DATE: + case DATETIME: + case TIME: + case IDENTIFIER: + case DELIMITEDIDENTIFIER: + case STRING: + case NUMBER: + { + _localctx = new TermExpressionContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; - setState(29); - term(); + setState(29); + term(); } - break; - case T__3: - case T__4: { - _localctx = new PolarityExpressionContext(_localctx); - _ctx = _localctx; - _prevctx = _localctx; - setState(30); - _la = _input.LA(1); - if (!(_la == T__3 || _la == T__4)) { - _errHandler.recoverInline(this); - } else { - consume(); - } - setState(31); - expression(11); + break; + case T__3: + case T__4: + { + _localctx = new PolarityExpressionContext(_localctx); + _ctx = _localctx; + _prevctx = _localctx; + setState(30); + _la = _input.LA(1); + if ( !(_la==T__3 || _la==T__4) ) { + _errHandler.recoverInline(this); } - break; - default: - throw new NoViableAltException(this); + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); } - _ctx.stop = _input.LT(-1); - setState(74); - _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input, 2, _ctx); - while (_alt != 2 && _alt != org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER) { - if (_alt == 1) { - if (_parseListeners != null) - triggerExitRuleEvent(); - _prevctx = _localctx; + setState(31); + expression(11); + } + break; + default: + throw new NoViableAltException(this); + } + _ctx.stop = _input.LT(-1); + setState(74); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,2,_ctx); + while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + if ( _alt==1 ) { + if ( _parseListeners!=null ) triggerExitRuleEvent(); + _prevctx = _localctx; + { + setState(72); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,1,_ctx) ) { + case 1: + { + _localctx = new MultiplicativeExpressionContext(new ExpressionContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_expression); + setState(34); + if (!(precpred(_ctx, 10))) throw new FailedPredicateException(this, "precpred(_ctx, 10)"); + setState(35); + _la = _input.LA(1); + if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__5) | (1L << T__6) | (1L << T__7) | (1L << T__8))) != 0)) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + setState(36); + expression(11); + } + break; + case 2: + { + _localctx = new AdditiveExpressionContext(new ExpressionContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_expression); + setState(37); + if (!(precpred(_ctx, 9))) throw new FailedPredicateException(this, "precpred(_ctx, 9)"); + setState(38); + _la = _input.LA(1); + if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__3) | (1L << T__4) | (1L << T__9))) != 0)) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + setState(39); + expression(10); + } + break; + case 3: + { + _localctx = new UnionExpressionContext(new ExpressionContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_expression); + setState(40); + if (!(precpred(_ctx, 7))) throw new FailedPredicateException(this, "precpred(_ctx, 7)"); + setState(41); + match(T__12); + setState(42); + expression(8); + } + break; + case 4: + { + _localctx = new InequalityExpressionContext(new ExpressionContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_expression); + setState(43); + if (!(precpred(_ctx, 6))) throw new FailedPredicateException(this, "precpred(_ctx, 6)"); + setState(44); + _la = _input.LA(1); + if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__13) | (1L << T__14) | (1L << T__15) | (1L << T__16))) != 0)) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + setState(45); + expression(7); + } + break; + case 5: { - setState(72); - _errHandler.sync(this); - switch (getInterpreter().adaptivePredict(_input, 1, _ctx)) { - case 1: { - _localctx = new MultiplicativeExpressionContext(new ExpressionContext(_parentctx, _parentState)); - pushNewRecursionContext(_localctx, _startState, RULE_expression); - setState(34); - if (!(precpred(_ctx, 10))) - throw new FailedPredicateException(this, "precpred(_ctx, 10)"); - setState(35); - _la = _input.LA(1); - if (!((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__5) | (1L << T__6) | (1L << T__7) | (1L << T__8))) != 0))) { - _errHandler.recoverInline(this); - } else { - consume(); - } - setState(36); - expression(11); - } - break; - case 2: { - _localctx = new AdditiveExpressionContext(new ExpressionContext(_parentctx, _parentState)); - pushNewRecursionContext(_localctx, _startState, RULE_expression); - setState(37); - if (!(precpred(_ctx, 9))) - throw new FailedPredicateException(this, "precpred(_ctx, 9)"); - setState(38); - _la = _input.LA(1); - if (!((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__3) | (1L << T__4) | (1L << T__9))) != 0))) { - _errHandler.recoverInline(this); - } else { - consume(); - } - setState(39); - expression(10); - } - break; - case 3: { - _localctx = new UnionExpressionContext(new ExpressionContext(_parentctx, _parentState)); - pushNewRecursionContext(_localctx, _startState, RULE_expression); - setState(40); - if (!(precpred(_ctx, 7))) - throw new FailedPredicateException(this, "precpred(_ctx, 7)"); - setState(41); - match(T__12); - setState(42); - expression(8); - } - break; - case 4: { - _localctx = new InequalityExpressionContext(new ExpressionContext(_parentctx, _parentState)); - pushNewRecursionContext(_localctx, _startState, RULE_expression); - setState(43); - if (!(precpred(_ctx, 6))) - throw new FailedPredicateException(this, "precpred(_ctx, 6)"); - setState(44); - _la = _input.LA(1); - if (!((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__13) | (1L << T__14) | (1L << T__15) | (1L << T__16))) != 0))) { - _errHandler.recoverInline(this); - } else { - consume(); - } - setState(45); - expression(7); - } - break; - case 5: { - _localctx = new EqualityExpressionContext(new ExpressionContext(_parentctx, _parentState)); - pushNewRecursionContext(_localctx, _startState, RULE_expression); - setState(46); - if (!(precpred(_ctx, 5))) - throw new FailedPredicateException(this, "precpred(_ctx, 5)"); - setState(47); - _la = _input.LA(1); - if (!((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__17) | (1L << T__18) | (1L << T__19) | (1L << T__20))) != 0))) { - _errHandler.recoverInline(this); - } else { - consume(); - } - setState(48); - expression(6); - } - break; - case 6: { - _localctx = new MembershipExpressionContext(new ExpressionContext(_parentctx, _parentState)); - pushNewRecursionContext(_localctx, _startState, RULE_expression); - setState(49); - if (!(precpred(_ctx, 4))) - throw new FailedPredicateException(this, "precpred(_ctx, 4)"); - setState(50); - _la = _input.LA(1); - if (!(_la == T__21 || _la == T__22)) { - _errHandler.recoverInline(this); - } else { - consume(); - } - setState(51); - expression(5); - } - break; - case 7: { - _localctx = new AndExpressionContext(new ExpressionContext(_parentctx, _parentState)); - pushNewRecursionContext(_localctx, _startState, RULE_expression); - setState(52); - if (!(precpred(_ctx, 3))) - throw new FailedPredicateException(this, "precpred(_ctx, 3)"); - setState(53); - match(T__23); - setState(54); - expression(4); - } - break; - case 8: { - _localctx = new OrExpressionContext(new ExpressionContext(_parentctx, _parentState)); - pushNewRecursionContext(_localctx, _startState, RULE_expression); - setState(55); - if (!(precpred(_ctx, 2))) - throw new FailedPredicateException(this, "precpred(_ctx, 2)"); - setState(56); - _la = _input.LA(1); - if (!(_la == T__24 || _la == T__25)) { - _errHandler.recoverInline(this); - } else { - consume(); - } - setState(57); - expression(3); - } - break; - case 9: { - _localctx = new ImpliesExpressionContext(new ExpressionContext(_parentctx, _parentState)); - pushNewRecursionContext(_localctx, _startState, RULE_expression); - setState(58); - if (!(precpred(_ctx, 1))) - throw new FailedPredicateException(this, "precpred(_ctx, 1)"); - setState(59); - match(T__26); - setState(60); - expression(2); - } - break; - case 10: { - _localctx = new InvocationExpressionContext(new ExpressionContext(_parentctx, _parentState)); - pushNewRecursionContext(_localctx, _startState, RULE_expression); - setState(61); - if (!(precpred(_ctx, 13))) - throw new FailedPredicateException(this, "precpred(_ctx, 13)"); - setState(62); - match(T__0); - setState(63); - invocation(); - } - break; - case 11: { - _localctx = new IndexerExpressionContext(new ExpressionContext(_parentctx, _parentState)); - pushNewRecursionContext(_localctx, _startState, RULE_expression); - setState(64); - if (!(precpred(_ctx, 12))) - throw new FailedPredicateException(this, "precpred(_ctx, 12)"); - setState(65); - match(T__1); - setState(66); - expression(0); - setState(67); - match(T__2); - } - break; - case 12: { - _localctx = new TypeExpressionContext(new ExpressionContext(_parentctx, _parentState)); - pushNewRecursionContext(_localctx, _startState, RULE_expression); - setState(69); - if (!(precpred(_ctx, 8))) - throw new FailedPredicateException(this, "precpred(_ctx, 8)"); - setState(70); - _la = _input.LA(1); - if (!(_la == T__10 || _la == T__11)) { - _errHandler.recoverInline(this); - } else { - consume(); - } - setState(71); - typeSpecifier(); - } - break; - } + _localctx = new EqualityExpressionContext(new ExpressionContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_expression); + setState(46); + if (!(precpred(_ctx, 5))) throw new FailedPredicateException(this, "precpred(_ctx, 5)"); + setState(47); + _la = _input.LA(1); + if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__17) | (1L << T__18) | (1L << T__19) | (1L << T__20))) != 0)) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); } + setState(48); + expression(6); + } + break; + case 6: + { + _localctx = new MembershipExpressionContext(new ExpressionContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_expression); + setState(49); + if (!(precpred(_ctx, 4))) throw new FailedPredicateException(this, "precpred(_ctx, 4)"); + setState(50); + _la = _input.LA(1); + if ( !(_la==T__21 || _la==T__22) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + setState(51); + expression(5); + } + break; + case 7: + { + _localctx = new AndExpressionContext(new ExpressionContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_expression); + setState(52); + if (!(precpred(_ctx, 3))) throw new FailedPredicateException(this, "precpred(_ctx, 3)"); + setState(53); + match(T__23); + setState(54); + expression(4); + } + break; + case 8: + { + _localctx = new OrExpressionContext(new ExpressionContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_expression); + setState(55); + if (!(precpred(_ctx, 2))) throw new FailedPredicateException(this, "precpred(_ctx, 2)"); + setState(56); + _la = _input.LA(1); + if ( !(_la==T__24 || _la==T__25) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + setState(57); + expression(3); + } + break; + case 9: + { + _localctx = new ImpliesExpressionContext(new ExpressionContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_expression); + setState(58); + if (!(precpred(_ctx, 1))) throw new FailedPredicateException(this, "precpred(_ctx, 1)"); + setState(59); + match(T__26); + setState(60); + expression(2); + } + break; + case 10: + { + _localctx = new InvocationExpressionContext(new ExpressionContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_expression); + setState(61); + if (!(precpred(_ctx, 13))) throw new FailedPredicateException(this, "precpred(_ctx, 13)"); + setState(62); + match(T__0); + setState(63); + invocation(); + } + break; + case 11: + { + _localctx = new IndexerExpressionContext(new ExpressionContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_expression); + setState(64); + if (!(precpred(_ctx, 12))) throw new FailedPredicateException(this, "precpred(_ctx, 12)"); + setState(65); + match(T__1); + setState(66); + expression(0); + setState(67); + match(T__2); + } + break; + case 12: + { + _localctx = new TypeExpressionContext(new ExpressionContext(_parentctx, _parentState)); + pushNewRecursionContext(_localctx, _startState, RULE_expression); + setState(69); + if (!(precpred(_ctx, 8))) throw new FailedPredicateException(this, "precpred(_ctx, 8)"); + setState(70); + _la = _input.LA(1); + if ( !(_la==T__10 || _la==T__11) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + setState(71); + typeSpecifier(); + } + break; } - setState(76); - _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input, 2, _ctx); + } } + setState(76); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,2,_ctx); } - } catch (RecognitionException re) { + } + } + catch (RecognitionException re) { _localctx.exception = re; _errHandler.reportError(this, re); _errHandler.recover(this, re); - } finally { + } + finally { unrollRecursionContexts(_parentctx); } return _localctx; @@ -707,89 +624,55 @@ public static class TermContext extends ParserRuleContext { public TermContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } - - @Override - public int getRuleIndex() { - return RULE_term; - } - - public TermContext() { - } - + @Override public int getRuleIndex() { return RULE_term; } + + public TermContext() { } public void copyFrom(TermContext ctx) { super.copyFrom(ctx); } } - public static class ExternalConstantTermContext extends TermContext { public ExternalConstantContext externalConstant() { - return getRuleContext(ExternalConstantContext.class, 0); - } - - public ExternalConstantTermContext(TermContext ctx) { - copyFrom(ctx); + return getRuleContext(ExternalConstantContext.class,0); } - + public ExternalConstantTermContext(TermContext ctx) { copyFrom(ctx); } @Override public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof FHIRPathVisitor) - return ((FHIRPathVisitor) visitor).visitExternalConstantTerm(this); - else - return visitor.visitChildren(this); + if ( visitor instanceof FHIRPathVisitor ) return ((FHIRPathVisitor)visitor).visitExternalConstantTerm(this); + else return visitor.visitChildren(this); } } - public static class LiteralTermContext extends TermContext { public LiteralContext literal() { - return getRuleContext(LiteralContext.class, 0); - } - - public LiteralTermContext(TermContext ctx) { - copyFrom(ctx); + return getRuleContext(LiteralContext.class,0); } - + public LiteralTermContext(TermContext ctx) { copyFrom(ctx); } @Override public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof FHIRPathVisitor) - return ((FHIRPathVisitor) visitor).visitLiteralTerm(this); - else - return visitor.visitChildren(this); + if ( visitor instanceof FHIRPathVisitor ) return ((FHIRPathVisitor)visitor).visitLiteralTerm(this); + else return visitor.visitChildren(this); } } - public static class ParenthesizedTermContext extends TermContext { public ExpressionContext expression() { - return getRuleContext(ExpressionContext.class, 0); - } - - public ParenthesizedTermContext(TermContext ctx) { - copyFrom(ctx); + return getRuleContext(ExpressionContext.class,0); } - + public ParenthesizedTermContext(TermContext ctx) { copyFrom(ctx); } @Override public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof FHIRPathVisitor) - return ((FHIRPathVisitor) visitor).visitParenthesizedTerm(this); - else - return visitor.visitChildren(this); + if ( visitor instanceof FHIRPathVisitor ) return ((FHIRPathVisitor)visitor).visitParenthesizedTerm(this); + else return visitor.visitChildren(this); } } - public static class InvocationTermContext extends TermContext { public InvocationContext invocation() { - return getRuleContext(InvocationContext.class, 0); - } - - public InvocationTermContext(TermContext ctx) { - copyFrom(ctx); + return getRuleContext(InvocationContext.class,0); } - + public InvocationTermContext(TermContext ctx) { copyFrom(ctx); } @Override public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof FHIRPathVisitor) - return ((FHIRPathVisitor) visitor).visitInvocationTerm(this); - else - return visitor.visitChildren(this); + if ( visitor instanceof FHIRPathVisitor ) return ((FHIRPathVisitor)visitor).visitInvocationTerm(this); + else return visitor.visitChildren(this); } } @@ -798,59 +681,69 @@ public final TermContext term() throws RecognitionException { enterRule(_localctx, 2, RULE_term); try { setState(84); + _errHandler.sync(this); switch (_input.LA(1)) { case T__10: case T__11: + case T__21: + case T__22: case T__34: case T__35: case T__36: case IDENTIFIER: case DELIMITEDIDENTIFIER: _localctx = new InvocationTermContext(_localctx); - enterOuterAlt(_localctx, 1); { + enterOuterAlt(_localctx, 1); + { setState(77); invocation(); - } + } break; case T__29: case T__31: case T__32: + case DATE: case DATETIME: case TIME: case STRING: case NUMBER: _localctx = new LiteralTermContext(_localctx); - enterOuterAlt(_localctx, 2); { + enterOuterAlt(_localctx, 2); + { setState(78); literal(); - } + } break; case T__33: _localctx = new ExternalConstantTermContext(_localctx); - enterOuterAlt(_localctx, 3); { + enterOuterAlt(_localctx, 3); + { setState(79); externalConstant(); - } + } break; case T__27: _localctx = new ParenthesizedTermContext(_localctx); - enterOuterAlt(_localctx, 4); { + enterOuterAlt(_localctx, 4); + { setState(80); match(T__27); setState(81); expression(0); setState(82); match(T__28); - } + } break; default: throw new NoViableAltException(this); } - } catch (RecognitionException re) { + } + catch (RecognitionException re) { _localctx.exception = re; _errHandler.reportError(this, re); _errHandler.recover(this, re); - } finally { + } + finally { exitRule(); } return _localctx; @@ -860,135 +753,83 @@ public static class LiteralContext extends ParserRuleContext { public LiteralContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } - - @Override - public int getRuleIndex() { - return RULE_literal; - } - - public LiteralContext() { - } - + @Override public int getRuleIndex() { return RULE_literal; } + + public LiteralContext() { } public void copyFrom(LiteralContext ctx) { super.copyFrom(ctx); } } - public static class TimeLiteralContext extends LiteralContext { - public TerminalNode TIME() { - return getToken(FHIRPathParser.TIME, 0); - } - - public TimeLiteralContext(LiteralContext ctx) { - copyFrom(ctx); - } - + public TerminalNode TIME() { return getToken(FHIRPathParser.TIME, 0); } + public TimeLiteralContext(LiteralContext ctx) { copyFrom(ctx); } @Override public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof FHIRPathVisitor) - return ((FHIRPathVisitor) visitor).visitTimeLiteral(this); - else - return visitor.visitChildren(this); + if ( visitor instanceof FHIRPathVisitor ) return ((FHIRPathVisitor)visitor).visitTimeLiteral(this); + else return visitor.visitChildren(this); } } - public static class NullLiteralContext extends LiteralContext { - public NullLiteralContext(LiteralContext ctx) { - copyFrom(ctx); - } - + public NullLiteralContext(LiteralContext ctx) { copyFrom(ctx); } @Override public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof FHIRPathVisitor) - return ((FHIRPathVisitor) visitor).visitNullLiteral(this); - else - return visitor.visitChildren(this); + if ( visitor instanceof FHIRPathVisitor ) return ((FHIRPathVisitor)visitor).visitNullLiteral(this); + else return visitor.visitChildren(this); } } - public static class DateTimeLiteralContext extends LiteralContext { - public TerminalNode DATETIME() { - return getToken(FHIRPathParser.DATETIME, 0); - } - - public DateTimeLiteralContext(LiteralContext ctx) { - copyFrom(ctx); - } - + public TerminalNode DATETIME() { return getToken(FHIRPathParser.DATETIME, 0); } + public DateTimeLiteralContext(LiteralContext ctx) { copyFrom(ctx); } @Override public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof FHIRPathVisitor) - return ((FHIRPathVisitor) visitor).visitDateTimeLiteral(this); - else - return visitor.visitChildren(this); + if ( visitor instanceof FHIRPathVisitor ) return ((FHIRPathVisitor)visitor).visitDateTimeLiteral(this); + else return visitor.visitChildren(this); } } - public static class StringLiteralContext extends LiteralContext { - public TerminalNode STRING() { - return getToken(FHIRPathParser.STRING, 0); - } - - public StringLiteralContext(LiteralContext ctx) { - copyFrom(ctx); + public TerminalNode STRING() { return getToken(FHIRPathParser.STRING, 0); } + public StringLiteralContext(LiteralContext ctx) { copyFrom(ctx); } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof FHIRPathVisitor ) return ((FHIRPathVisitor)visitor).visitStringLiteral(this); + else return visitor.visitChildren(this); } - + } + public static class DateLiteralContext extends LiteralContext { + public TerminalNode DATE() { return getToken(FHIRPathParser.DATE, 0); } + public DateLiteralContext(LiteralContext ctx) { copyFrom(ctx); } @Override public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof FHIRPathVisitor) - return ((FHIRPathVisitor) visitor).visitStringLiteral(this); - else - return visitor.visitChildren(this); + if ( visitor instanceof FHIRPathVisitor ) return ((FHIRPathVisitor)visitor).visitDateLiteral(this); + else return visitor.visitChildren(this); } } - public static class BooleanLiteralContext extends LiteralContext { - public BooleanLiteralContext(LiteralContext ctx) { - copyFrom(ctx); - } - + public BooleanLiteralContext(LiteralContext ctx) { copyFrom(ctx); } @Override public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof FHIRPathVisitor) - return ((FHIRPathVisitor) visitor).visitBooleanLiteral(this); - else - return visitor.visitChildren(this); + if ( visitor instanceof FHIRPathVisitor ) return ((FHIRPathVisitor)visitor).visitBooleanLiteral(this); + else return visitor.visitChildren(this); } } - public static class NumberLiteralContext extends LiteralContext { - public TerminalNode NUMBER() { - return getToken(FHIRPathParser.NUMBER, 0); - } - - public NumberLiteralContext(LiteralContext ctx) { - copyFrom(ctx); - } - + public TerminalNode NUMBER() { return getToken(FHIRPathParser.NUMBER, 0); } + public NumberLiteralContext(LiteralContext ctx) { copyFrom(ctx); } @Override public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof FHIRPathVisitor) - return ((FHIRPathVisitor) visitor).visitNumberLiteral(this); - else - return visitor.visitChildren(this); + if ( visitor instanceof FHIRPathVisitor ) return ((FHIRPathVisitor)visitor).visitNumberLiteral(this); + else return visitor.visitChildren(this); } } - public static class QuantityLiteralContext extends LiteralContext { public QuantityContext quantity() { - return getRuleContext(QuantityContext.class, 0); + return getRuleContext(QuantityContext.class,0); } - - public QuantityLiteralContext(LiteralContext ctx) { - copyFrom(ctx); - } - + public QuantityLiteralContext(LiteralContext ctx) { copyFrom(ctx); } @Override public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof FHIRPathVisitor) - return ((FHIRPathVisitor) visitor).visitQuantityLiteral(this); - else - return visitor.visitChildren(this); + if ( visitor instanceof FHIRPathVisitor ) return ((FHIRPathVisitor)visitor).visitQuantityLiteral(this); + else return visitor.visitChildren(this); } } @@ -997,71 +838,91 @@ public final LiteralContext literal() throws RecognitionException { enterRule(_localctx, 4, RULE_literal); int _la; try { - setState(94); + setState(95); _errHandler.sync(this); - switch (getInterpreter().adaptivePredict(_input, 4, _ctx)) { + switch ( getInterpreter().adaptivePredict(_input,4,_ctx) ) { case 1: _localctx = new NullLiteralContext(_localctx); - enterOuterAlt(_localctx, 1); { + enterOuterAlt(_localctx, 1); + { setState(86); match(T__29); setState(87); match(T__30); - } + } break; case 2: _localctx = new BooleanLiteralContext(_localctx); - enterOuterAlt(_localctx, 2); { + enterOuterAlt(_localctx, 2); + { setState(88); _la = _input.LA(1); - if (!(_la == T__31 || _la == T__32)) { - _errHandler.recoverInline(this); - } else { + if ( !(_la==T__31 || _la==T__32) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); consume(); } - } + } break; case 3: _localctx = new StringLiteralContext(_localctx); - enterOuterAlt(_localctx, 3); { + enterOuterAlt(_localctx, 3); + { setState(89); match(STRING); - } + } break; case 4: _localctx = new NumberLiteralContext(_localctx); - enterOuterAlt(_localctx, 4); { + enterOuterAlt(_localctx, 4); + { setState(90); match(NUMBER); - } + } break; case 5: - _localctx = new DateTimeLiteralContext(_localctx); - enterOuterAlt(_localctx, 5); { + _localctx = new DateLiteralContext(_localctx); + enterOuterAlt(_localctx, 5); + { setState(91); - match(DATETIME); - } + match(DATE); + } break; case 6: - _localctx = new TimeLiteralContext(_localctx); - enterOuterAlt(_localctx, 6); { + _localctx = new DateTimeLiteralContext(_localctx); + enterOuterAlt(_localctx, 6); + { setState(92); - match(TIME); - } + match(DATETIME); + } break; case 7: - _localctx = new QuantityLiteralContext(_localctx); - enterOuterAlt(_localctx, 7); { + _localctx = new TimeLiteralContext(_localctx); + enterOuterAlt(_localctx, 7); + { setState(93); + match(TIME); + } + break; + case 8: + _localctx = new QuantityLiteralContext(_localctx); + enterOuterAlt(_localctx, 8); + { + setState(94); quantity(); - } + } break; } - } catch (RecognitionException re) { + } + catch (RecognitionException re) { _localctx.exception = re; _errHandler.reportError(this, re); _errHandler.recover(this, re); - } finally { + } + finally { exitRule(); } return _localctx; @@ -1069,24 +930,17 @@ public final LiteralContext literal() throws RecognitionException { public static class ExternalConstantContext extends ParserRuleContext { public IdentifierContext identifier() { - return getRuleContext(IdentifierContext.class, 0); + return getRuleContext(IdentifierContext.class,0); } - + public TerminalNode STRING() { return getToken(FHIRPathParser.STRING, 0); } public ExternalConstantContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } - - @Override - public int getRuleIndex() { - return RULE_externalConstant; - } - + @Override public int getRuleIndex() { return RULE_externalConstant; } @Override public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof FHIRPathVisitor) - return ((FHIRPathVisitor) visitor).visitExternalConstant(this); - else - return visitor.visitChildren(this); + if ( visitor instanceof FHIRPathVisitor ) return ((FHIRPathVisitor)visitor).visitExternalConstant(this); + else return visitor.visitChildren(this); } } @@ -1096,16 +950,39 @@ public final ExternalConstantContext externalConstant() throws RecognitionExcept try { enterOuterAlt(_localctx, 1); { - setState(96); - match(T__33); - setState(97); + setState(97); + match(T__33); + setState(100); + _errHandler.sync(this); + switch (_input.LA(1)) { + case T__10: + case T__11: + case T__21: + case T__22: + case IDENTIFIER: + case DELIMITEDIDENTIFIER: + { + setState(98); identifier(); + } + break; + case STRING: + { + setState(99); + match(STRING); + } + break; + default: + throw new NoViableAltException(this); + } } - } catch (RecognitionException re) { + } + catch (RecognitionException re) { _localctx.exception = re; _errHandler.reportError(this, re); _errHandler.recover(this, re); - } finally { + } + finally { exitRule(); } return _localctx; @@ -1115,95 +992,57 @@ public static class InvocationContext extends ParserRuleContext { public InvocationContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } - - @Override - public int getRuleIndex() { - return RULE_invocation; - } - - public InvocationContext() { - } - + @Override public int getRuleIndex() { return RULE_invocation; } + + public InvocationContext() { } public void copyFrom(InvocationContext ctx) { super.copyFrom(ctx); } } - public static class TotalInvocationContext extends InvocationContext { - public TotalInvocationContext(InvocationContext ctx) { - copyFrom(ctx); - } - + public TotalInvocationContext(InvocationContext ctx) { copyFrom(ctx); } @Override public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof FHIRPathVisitor) - return ((FHIRPathVisitor) visitor).visitTotalInvocation(this); - else - return visitor.visitChildren(this); + if ( visitor instanceof FHIRPathVisitor ) return ((FHIRPathVisitor)visitor).visitTotalInvocation(this); + else return visitor.visitChildren(this); } } - public static class ThisInvocationContext extends InvocationContext { - public ThisInvocationContext(InvocationContext ctx) { - copyFrom(ctx); - } - + public ThisInvocationContext(InvocationContext ctx) { copyFrom(ctx); } @Override public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof FHIRPathVisitor) - return ((FHIRPathVisitor) visitor).visitThisInvocation(this); - else - return visitor.visitChildren(this); + if ( visitor instanceof FHIRPathVisitor ) return ((FHIRPathVisitor)visitor).visitThisInvocation(this); + else return visitor.visitChildren(this); } } - public static class IndexInvocationContext extends InvocationContext { - public IndexInvocationContext(InvocationContext ctx) { - copyFrom(ctx); - } - + public IndexInvocationContext(InvocationContext ctx) { copyFrom(ctx); } @Override public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof FHIRPathVisitor) - return ((FHIRPathVisitor) visitor).visitIndexInvocation(this); - else - return visitor.visitChildren(this); + if ( visitor instanceof FHIRPathVisitor ) return ((FHIRPathVisitor)visitor).visitIndexInvocation(this); + else return visitor.visitChildren(this); } } - public static class FunctionInvocationContext extends InvocationContext { public FunctionContext function() { - return getRuleContext(FunctionContext.class, 0); + return getRuleContext(FunctionContext.class,0); } - - public FunctionInvocationContext(InvocationContext ctx) { - copyFrom(ctx); - } - + public FunctionInvocationContext(InvocationContext ctx) { copyFrom(ctx); } @Override public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof FHIRPathVisitor) - return ((FHIRPathVisitor) visitor).visitFunctionInvocation(this); - else - return visitor.visitChildren(this); + if ( visitor instanceof FHIRPathVisitor ) return ((FHIRPathVisitor)visitor).visitFunctionInvocation(this); + else return visitor.visitChildren(this); } } - public static class MemberInvocationContext extends InvocationContext { public IdentifierContext identifier() { - return getRuleContext(IdentifierContext.class, 0); + return getRuleContext(IdentifierContext.class,0); } - - public MemberInvocationContext(InvocationContext ctx) { - copyFrom(ctx); - } - + public MemberInvocationContext(InvocationContext ctx) { copyFrom(ctx); } @Override public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof FHIRPathVisitor) - return ((FHIRPathVisitor) visitor).visitMemberInvocation(this); - else - return visitor.visitChildren(this); + if ( visitor instanceof FHIRPathVisitor ) return ((FHIRPathVisitor)visitor).visitMemberInvocation(this); + else return visitor.visitChildren(this); } } @@ -1211,50 +1050,57 @@ public final InvocationContext invocation() throws RecognitionException { InvocationContext _localctx = new InvocationContext(_ctx, getState()); enterRule(_localctx, 8, RULE_invocation); try { - setState(104); + setState(107); _errHandler.sync(this); - switch (getInterpreter().adaptivePredict(_input, 5, _ctx)) { + switch ( getInterpreter().adaptivePredict(_input,6,_ctx) ) { case 1: _localctx = new MemberInvocationContext(_localctx); - enterOuterAlt(_localctx, 1); { - setState(99); + enterOuterAlt(_localctx, 1); + { + setState(102); identifier(); - } + } break; case 2: _localctx = new FunctionInvocationContext(_localctx); - enterOuterAlt(_localctx, 2); { - setState(100); + enterOuterAlt(_localctx, 2); + { + setState(103); function(); - } + } break; case 3: _localctx = new ThisInvocationContext(_localctx); - enterOuterAlt(_localctx, 3); { - setState(101); + enterOuterAlt(_localctx, 3); + { + setState(104); match(T__34); - } + } break; case 4: _localctx = new IndexInvocationContext(_localctx); - enterOuterAlt(_localctx, 4); { - setState(102); + enterOuterAlt(_localctx, 4); + { + setState(105); match(T__35); - } + } break; case 5: _localctx = new TotalInvocationContext(_localctx); - enterOuterAlt(_localctx, 5); { - setState(103); + enterOuterAlt(_localctx, 5); + { + setState(106); match(T__36); - } + } break; } - } catch (RecognitionException re) { + } + catch (RecognitionException re) { _localctx.exception = re; _errHandler.reportError(this, re); _errHandler.recover(this, re); - } finally { + } + finally { exitRule(); } return _localctx; @@ -1262,28 +1108,19 @@ public final InvocationContext invocation() throws RecognitionException { public static class FunctionContext extends ParserRuleContext { public IdentifierContext identifier() { - return getRuleContext(IdentifierContext.class, 0); + return getRuleContext(IdentifierContext.class,0); } - public ParamListContext paramList() { - return getRuleContext(ParamListContext.class, 0); + return getRuleContext(ParamListContext.class,0); } - public FunctionContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } - - @Override - public int getRuleIndex() { - return RULE_function; - } - + @Override public int getRuleIndex() { return RULE_function; } @Override public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof FHIRPathVisitor) - return ((FHIRPathVisitor) visitor).visitFunction(this); - else - return visitor.visitChildren(this); + if ( visitor instanceof FHIRPathVisitor ) return ((FHIRPathVisitor)visitor).visitFunction(this); + else return visitor.visitChildren(this); } } @@ -1294,29 +1131,30 @@ public final FunctionContext function() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(106); - identifier(); - setState(107); - match(T__27); - setState(109); - _la = _input.LA(1); - if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__3) | (1L << T__4) | (1L << T__10) | (1L << T__11) | (1L << T__27) | (1L << T__29) - | (1L << T__31) | (1L << T__32) | (1L << T__33) | (1L << T__34) | (1L << T__35) | (1L << T__36) | (1L << DATETIME) | (1L << TIME) - | (1L << IDENTIFIER) | (1L << DELIMITEDIDENTIFIER) | (1L << STRING) | (1L << NUMBER))) != 0)) { - { - setState(108); - paramList(); - } + setState(109); + identifier(); + setState(110); + match(T__27); + setState(112); + _errHandler.sync(this); + _la = _input.LA(1); + if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__3) | (1L << T__4) | (1L << T__10) | (1L << T__11) | (1L << T__21) | (1L << T__22) | (1L << T__27) | (1L << T__29) | (1L << T__31) | (1L << T__32) | (1L << T__33) | (1L << T__34) | (1L << T__35) | (1L << T__36) | (1L << DATE) | (1L << DATETIME) | (1L << TIME) | (1L << IDENTIFIER) | (1L << DELIMITEDIDENTIFIER) | (1L << STRING) | (1L << NUMBER))) != 0)) { + { + setState(111); + paramList(); } + } - setState(111); - match(T__28); + setState(114); + match(T__28); } - } catch (RecognitionException re) { + } + catch (RecognitionException re) { _localctx.exception = re; _errHandler.reportError(this, re); _errHandler.recover(this, re); - } finally { + } + finally { exitRule(); } return _localctx; @@ -1326,26 +1164,17 @@ public static class ParamListContext extends ParserRuleContext { public List expression() { return getRuleContexts(ExpressionContext.class); } - public ExpressionContext expression(int i) { - return getRuleContext(ExpressionContext.class, i); + return getRuleContext(ExpressionContext.class,i); } - public ParamListContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } - - @Override - public int getRuleIndex() { - return RULE_paramList; - } - + @Override public int getRuleIndex() { return RULE_paramList; } @Override public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof FHIRPathVisitor) - return ((FHIRPathVisitor) visitor).visitParamList(this); - else - return visitor.visitChildren(this); + if ( visitor instanceof FHIRPathVisitor ) return ((FHIRPathVisitor)visitor).visitParamList(this); + else return visitor.visitChildren(this); } } @@ -1356,59 +1185,50 @@ public final ParamListContext paramList() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(113); - expression(0); + setState(116); + expression(0); + setState(121); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==T__37) { + { + { + setState(117); + match(T__37); setState(118); + expression(0); + } + } + setState(123); _errHandler.sync(this); _la = _input.LA(1); - while (_la == T__37) { - { - { - setState(114); - match(T__37); - setState(115); - expression(0); - } - } - setState(120); - _errHandler.sync(this); - _la = _input.LA(1); - } } - } catch (RecognitionException re) { + } + } + catch (RecognitionException re) { _localctx.exception = re; _errHandler.reportError(this, re); _errHandler.recover(this, re); - } finally { + } + finally { exitRule(); } return _localctx; } public static class QuantityContext extends ParserRuleContext { - public TerminalNode NUMBER() { - return getToken(FHIRPathParser.NUMBER, 0); - } - + public TerminalNode NUMBER() { return getToken(FHIRPathParser.NUMBER, 0); } public UnitContext unit() { - return getRuleContext(UnitContext.class, 0); + return getRuleContext(UnitContext.class,0); } - public QuantityContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } - - @Override - public int getRuleIndex() { - return RULE_quantity; - } - + @Override public int getRuleIndex() { return RULE_quantity; } @Override public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof FHIRPathVisitor) - return ((FHIRPathVisitor) visitor).visitQuantity(this); - else - return visitor.visitChildren(this); + if ( visitor instanceof FHIRPathVisitor ) return ((FHIRPathVisitor)visitor).visitQuantity(this); + else return visitor.visitChildren(this); } } @@ -1418,23 +1238,26 @@ public final QuantityContext quantity() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(121); - match(NUMBER); - setState(123); - _errHandler.sync(this); - switch (getInterpreter().adaptivePredict(_input, 8, _ctx)) { - case 1: { - setState(122); - unit(); - } - break; + setState(124); + match(NUMBER); + setState(126); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,9,_ctx) ) { + case 1: + { + setState(125); + unit(); } + break; } - } catch (RecognitionException re) { + } + } + catch (RecognitionException re) { _localctx.exception = re; _errHandler.reportError(this, re); _errHandler.recover(this, re); - } finally { + } + finally { exitRule(); } return _localctx; @@ -1442,32 +1265,20 @@ public final QuantityContext quantity() throws RecognitionException { public static class UnitContext extends ParserRuleContext { public DateTimePrecisionContext dateTimePrecision() { - return getRuleContext(DateTimePrecisionContext.class, 0); + return getRuleContext(DateTimePrecisionContext.class,0); } - public PluralDateTimePrecisionContext pluralDateTimePrecision() { - return getRuleContext(PluralDateTimePrecisionContext.class, 0); - } - - public TerminalNode STRING() { - return getToken(FHIRPathParser.STRING, 0); + return getRuleContext(PluralDateTimePrecisionContext.class,0); } - + public TerminalNode STRING() { return getToken(FHIRPathParser.STRING, 0); } public UnitContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } - - @Override - public int getRuleIndex() { - return RULE_unit; - } - + @Override public int getRuleIndex() { return RULE_unit; } @Override public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof FHIRPathVisitor) - return ((FHIRPathVisitor) visitor).visitUnit(this); - else - return visitor.visitChildren(this); + if ( visitor instanceof FHIRPathVisitor ) return ((FHIRPathVisitor)visitor).visitUnit(this); + else return visitor.visitChildren(this); } } @@ -1475,7 +1286,8 @@ public final UnitContext unit() throws RecognitionException { UnitContext _localctx = new UnitContext(_ctx, getState()); enterRule(_localctx, 16, RULE_unit); try { - setState(128); + setState(131); + _errHandler.sync(this); switch (_input.LA(1)) { case T__38: case T__39: @@ -1485,10 +1297,11 @@ public final UnitContext unit() throws RecognitionException { case T__43: case T__44: case T__45: - enterOuterAlt(_localctx, 1); { - setState(125); + enterOuterAlt(_localctx, 1); + { + setState(128); dateTimePrecision(); - } + } break; case T__46: case T__47: @@ -1498,25 +1311,29 @@ public final UnitContext unit() throws RecognitionException { case T__51: case T__52: case T__53: - enterOuterAlt(_localctx, 2); { - setState(126); + enterOuterAlt(_localctx, 2); + { + setState(129); pluralDateTimePrecision(); - } + } break; case STRING: - enterOuterAlt(_localctx, 3); { - setState(127); + enterOuterAlt(_localctx, 3); + { + setState(130); match(STRING); - } + } break; default: throw new NoViableAltException(this); } - } catch (RecognitionException re) { + } + catch (RecognitionException re) { _localctx.exception = re; _errHandler.reportError(this, re); _errHandler.recover(this, re); - } finally { + } + finally { exitRule(); } return _localctx; @@ -1526,18 +1343,11 @@ public static class DateTimePrecisionContext extends ParserRuleContext { public DateTimePrecisionContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } - - @Override - public int getRuleIndex() { - return RULE_dateTimePrecision; - } - + @Override public int getRuleIndex() { return RULE_dateTimePrecision; } @Override public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof FHIRPathVisitor) - return ((FHIRPathVisitor) visitor).visitDateTimePrecision(this); - else - return visitor.visitChildren(this); + if ( visitor instanceof FHIRPathVisitor ) return ((FHIRPathVisitor)visitor).visitDateTimePrecision(this); + else return visitor.visitChildren(this); } } @@ -1548,20 +1358,24 @@ public final DateTimePrecisionContext dateTimePrecision() throws RecognitionExce try { enterOuterAlt(_localctx, 1); { - setState(130); - _la = _input.LA(1); - if (!((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__38) | (1L << T__39) | (1L << T__40) | (1L << T__41) | (1L << T__42) | (1L << T__43) - | (1L << T__44) | (1L << T__45))) != 0))) { - _errHandler.recoverInline(this); - } else { - consume(); - } + setState(133); + _la = _input.LA(1); + if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__38) | (1L << T__39) | (1L << T__40) | (1L << T__41) | (1L << T__42) | (1L << T__43) | (1L << T__44) | (1L << T__45))) != 0)) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); } - } catch (RecognitionException re) { + } + } + catch (RecognitionException re) { _localctx.exception = re; _errHandler.reportError(this, re); _errHandler.recover(this, re); - } finally { + } + finally { exitRule(); } return _localctx; @@ -1571,18 +1385,11 @@ public static class PluralDateTimePrecisionContext extends ParserRuleContext { public PluralDateTimePrecisionContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } - - @Override - public int getRuleIndex() { - return RULE_pluralDateTimePrecision; - } - + @Override public int getRuleIndex() { return RULE_pluralDateTimePrecision; } @Override public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof FHIRPathVisitor) - return ((FHIRPathVisitor) visitor).visitPluralDateTimePrecision(this); - else - return visitor.visitChildren(this); + if ( visitor instanceof FHIRPathVisitor ) return ((FHIRPathVisitor)visitor).visitPluralDateTimePrecision(this); + else return visitor.visitChildren(this); } } @@ -1593,20 +1400,24 @@ public final PluralDateTimePrecisionContext pluralDateTimePrecision() throws Rec try { enterOuterAlt(_localctx, 1); { - setState(132); - _la = _input.LA(1); - if (!((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__46) | (1L << T__47) | (1L << T__48) | (1L << T__49) | (1L << T__50) | (1L << T__51) - | (1L << T__52) | (1L << T__53))) != 0))) { - _errHandler.recoverInline(this); - } else { - consume(); - } + setState(135); + _la = _input.LA(1); + if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__46) | (1L << T__47) | (1L << T__48) | (1L << T__49) | (1L << T__50) | (1L << T__51) | (1L << T__52) | (1L << T__53))) != 0)) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); } - } catch (RecognitionException re) { + } + } + catch (RecognitionException re) { _localctx.exception = re; _errHandler.reportError(this, re); _errHandler.recover(this, re); - } finally { + } + finally { exitRule(); } return _localctx; @@ -1614,24 +1425,16 @@ public final PluralDateTimePrecisionContext pluralDateTimePrecision() throws Rec public static class TypeSpecifierContext extends ParserRuleContext { public QualifiedIdentifierContext qualifiedIdentifier() { - return getRuleContext(QualifiedIdentifierContext.class, 0); + return getRuleContext(QualifiedIdentifierContext.class,0); } - public TypeSpecifierContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } - - @Override - public int getRuleIndex() { - return RULE_typeSpecifier; - } - + @Override public int getRuleIndex() { return RULE_typeSpecifier; } @Override public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof FHIRPathVisitor) - return ((FHIRPathVisitor) visitor).visitTypeSpecifier(this); - else - return visitor.visitChildren(this); + if ( visitor instanceof FHIRPathVisitor ) return ((FHIRPathVisitor)visitor).visitTypeSpecifier(this); + else return visitor.visitChildren(this); } } @@ -1641,14 +1444,16 @@ public final TypeSpecifierContext typeSpecifier() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(134); - qualifiedIdentifier(); + setState(137); + qualifiedIdentifier(); } - } catch (RecognitionException re) { + } + catch (RecognitionException re) { _localctx.exception = re; _errHandler.reportError(this, re); _errHandler.recover(this, re); - } finally { + } + finally { exitRule(); } return _localctx; @@ -1658,26 +1463,17 @@ public static class QualifiedIdentifierContext extends ParserRuleContext { public List identifier() { return getRuleContexts(IdentifierContext.class); } - public IdentifierContext identifier(int i) { - return getRuleContext(IdentifierContext.class, i); + return getRuleContext(IdentifierContext.class,i); } - public QualifiedIdentifierContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } - - @Override - public int getRuleIndex() { - return RULE_qualifiedIdentifier; - } - + @Override public int getRuleIndex() { return RULE_qualifiedIdentifier; } @Override public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof FHIRPathVisitor) - return ((FHIRPathVisitor) visitor).visitQualifiedIdentifier(this); - else - return visitor.visitChildren(this); + if ( visitor instanceof FHIRPathVisitor ) return ((FHIRPathVisitor)visitor).visitQualifiedIdentifier(this); + else return visitor.visitChildren(this); } } @@ -1688,61 +1484,50 @@ public final QualifiedIdentifierContext qualifiedIdentifier() throws Recognition int _alt; enterOuterAlt(_localctx, 1); { - setState(136); - identifier(); - setState(141); - _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input, 10, _ctx); - while (_alt != 2 && _alt != org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER) { - if (_alt == 1) { - { - { - setState(137); - match(T__0); - setState(138); - identifier(); - } - } + setState(139); + identifier(); + setState(144); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,11,_ctx); + while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) { + if ( _alt==1 ) { + { + { + setState(140); + match(T__0); + setState(141); + identifier(); } - setState(143); - _errHandler.sync(this); - _alt = getInterpreter().adaptivePredict(_input, 10, _ctx); + } } + setState(146); + _errHandler.sync(this); + _alt = getInterpreter().adaptivePredict(_input,11,_ctx); } - } catch (RecognitionException re) { + } + } + catch (RecognitionException re) { _localctx.exception = re; _errHandler.reportError(this, re); _errHandler.recover(this, re); - } finally { + } + finally { exitRule(); } return _localctx; } public static class IdentifierContext extends ParserRuleContext { - public TerminalNode IDENTIFIER() { - return getToken(FHIRPathParser.IDENTIFIER, 0); - } - - public TerminalNode DELIMITEDIDENTIFIER() { - return getToken(FHIRPathParser.DELIMITEDIDENTIFIER, 0); - } - + public TerminalNode IDENTIFIER() { return getToken(FHIRPathParser.IDENTIFIER, 0); } + public TerminalNode DELIMITEDIDENTIFIER() { return getToken(FHIRPathParser.DELIMITEDIDENTIFIER, 0); } public IdentifierContext(ParserRuleContext parent, int invokingState) { super(parent, invokingState); } - - @Override - public int getRuleIndex() { - return RULE_identifier; - } - + @Override public int getRuleIndex() { return RULE_identifier; } @Override public T accept(ParseTreeVisitor visitor) { - if (visitor instanceof FHIRPathVisitor) - return ((FHIRPathVisitor) visitor).visitIdentifier(this); - else - return visitor.visitChildren(this); + if ( visitor instanceof FHIRPathVisitor ) return ((FHIRPathVisitor)visitor).visitIdentifier(this); + else return visitor.visitChildren(this); } } @@ -1753,19 +1538,24 @@ public final IdentifierContext identifier() throws RecognitionException { try { enterOuterAlt(_localctx, 1); { - setState(144); - _la = _input.LA(1); - if (!((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__10) | (1L << T__11) | (1L << IDENTIFIER) | (1L << DELIMITEDIDENTIFIER))) != 0))) { - _errHandler.recoverInline(this); - } else { - consume(); - } + setState(147); + _la = _input.LA(1); + if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << T__10) | (1L << T__11) | (1L << T__21) | (1L << T__22) | (1L << IDENTIFIER) | (1L << DELIMITEDIDENTIFIER))) != 0)) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } } - } catch (RecognitionException re) { + } + catch (RecognitionException re) { _localctx.exception = re; _errHandler.reportError(this, re); _errHandler.recover(this, re); - } finally { + } + finally { exitRule(); } return _localctx; @@ -1774,11 +1564,10 @@ public final IdentifierContext identifier() throws RecognitionException { public boolean sempred(RuleContext _localctx, int ruleIndex, int predIndex) { switch (ruleIndex) { case 0: - return expression_sempred((ExpressionContext) _localctx, predIndex); + return expression_sempred((ExpressionContext)_localctx, predIndex); } return true; } - private boolean expression_sempred(ExpressionContext _localctx, int predIndex) { switch (predIndex) { case 0: @@ -1809,37 +1598,57 @@ private boolean expression_sempred(ExpressionContext _localctx, int predIndex) { return true; } - public static final String _serializedATN = "\3\u0430\ud6d1\u8206\uad2d\u4417\uaef1\u8d80\uaadd\3A\u0095\4\2\t\2\4" - + "\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t" + "\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\3\2\3\2\3\2\3\2\5\2#\n\2\3\2\3" - + "\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2" - + "\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3" + "\2\3\2\7\2K\n\2\f\2\16\2N\13\2\3\3\3\3\3\3\3\3\3\3\3\3\3\3\5\3W\n\3\3" - + "\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\5\4a\n\4\3\5\3\5\3\5\3\6\3\6\3\6\3\6\3" + "\6\5\6k\n\6\3\7\3\7\3\7\5\7p\n\7\3\7\3\7\3\b\3\b\3\b\7\bw\n\b\f\b\16\b" - + "z\13\b\3\t\3\t\5\t~\n\t\3\n\3\n\3\n\5\n\u0083\n\n\3\13\3\13\3\f\3\f\3" + "\r\3\r\3\16\3\16\3\16\7\16\u008e\n\16\f\16\16\16\u0091\13\16\3\17\3\17" - + "\3\17\2\3\2\20\2\4\6\b\n\f\16\20\22\24\26\30\32\34\2\16\3\2\6\7\3\2\b" + "\13\4\2\6\7\f\f\3\2\20\23\3\2\24\27\3\2\30\31\3\2\33\34\3\2\r\16\3\2\"" - + "#\3\2)\60\3\2\618\4\2\r\16;<\u00a6\2\"\3\2\2\2\4V\3\2\2\2\6`\3\2\2\2\b" - + "b\3\2\2\2\nj\3\2\2\2\fl\3\2\2\2\16s\3\2\2\2\20{\3\2\2\2\22\u0082\3\2\2" - + "\2\24\u0084\3\2\2\2\26\u0086\3\2\2\2\30\u0088\3\2\2\2\32\u008a\3\2\2\2" - + "\34\u0092\3\2\2\2\36\37\b\2\1\2\37#\5\4\3\2 !\t\2\2\2!#\5\2\2\r\"\36\3" + "\2\2\2\" \3\2\2\2#L\3\2\2\2$%\f\f\2\2%&\t\3\2\2&K\5\2\2\r\'(\f\13\2\2" - + "()\t\4\2\2)K\5\2\2\f*+\f\t\2\2+,\7\17\2\2,K\5\2\2\n-.\f\b\2\2./\t\5\2" + "\2/K\5\2\2\t\60\61\f\7\2\2\61\62\t\6\2\2\62K\5\2\2\b\63\64\f\6\2\2\64" - + "\65\t\7\2\2\65K\5\2\2\7\66\67\f\5\2\2\678\7\32\2\28K\5\2\2\69:\f\4\2\2" - + ":;\t\b\2\2;K\5\2\2\5<=\f\3\2\2=>\7\35\2\2>K\5\2\2\4?@\f\17\2\2@A\7\3\2" + "\2AK\5\n\6\2BC\f\16\2\2CD\7\4\2\2DE\5\2\2\2EF\7\5\2\2FK\3\2\2\2GH\f\n" - + "\2\2HI\t\t\2\2IK\5\30\r\2J$\3\2\2\2J\'\3\2\2\2J*\3\2\2\2J-\3\2\2\2J\60" - + "\3\2\2\2J\63\3\2\2\2J\66\3\2\2\2J9\3\2\2\2J<\3\2\2\2J?\3\2\2\2JB\3\2\2" + "\2JG\3\2\2\2KN\3\2\2\2LJ\3\2\2\2LM\3\2\2\2M\3\3\2\2\2NL\3\2\2\2OW\5\n" - + "\6\2PW\5\6\4\2QW\5\b\5\2RS\7\36\2\2ST\5\2\2\2TU\7\37\2\2UW\3\2\2\2VO\3" + "\2\2\2VP\3\2\2\2VQ\3\2\2\2VR\3\2\2\2W\5\3\2\2\2XY\7 \2\2Ya\7!\2\2Za\t" - + "\n\2\2[a\7=\2\2\\a\7>\2\2]a\79\2\2^a\7:\2\2_a\5\20\t\2`X\3\2\2\2`Z\3\2" - + "\2\2`[\3\2\2\2`\\\3\2\2\2`]\3\2\2\2`^\3\2\2\2`_\3\2\2\2a\7\3\2\2\2bc\7" + "$\2\2cd\5\34\17\2d\t\3\2\2\2ek\5\34\17\2fk\5\f\7\2gk\7%\2\2hk\7&\2\2i" - + "k\7\'\2\2je\3\2\2\2jf\3\2\2\2jg\3\2\2\2jh\3\2\2\2ji\3\2\2\2k\13\3\2\2" + "\2lm\5\34\17\2mo\7\36\2\2np\5\16\b\2on\3\2\2\2op\3\2\2\2pq\3\2\2\2qr\7" - + "\37\2\2r\r\3\2\2\2sx\5\2\2\2tu\7(\2\2uw\5\2\2\2vt\3\2\2\2wz\3\2\2\2xv" + "\3\2\2\2xy\3\2\2\2y\17\3\2\2\2zx\3\2\2\2{}\7>\2\2|~\5\22\n\2}|\3\2\2\2" - + "}~\3\2\2\2~\21\3\2\2\2\177\u0083\5\24\13\2\u0080\u0083\5\26\f\2\u0081" + "\u0083\7=\2\2\u0082\177\3\2\2\2\u0082\u0080\3\2\2\2\u0082\u0081\3\2\2" - + "\2\u0083\23\3\2\2\2\u0084\u0085\t\13\2\2\u0085\25\3\2\2\2\u0086\u0087" + "\t\f\2\2\u0087\27\3\2\2\2\u0088\u0089\5\32\16\2\u0089\31\3\2\2\2\u008a" - + "\u008f\5\34\17\2\u008b\u008c\7\3\2\2\u008c\u008e\5\34\17\2\u008d\u008b" - + "\3\2\2\2\u008e\u0091\3\2\2\2\u008f\u008d\3\2\2\2\u008f\u0090\3\2\2\2\u0090" - + "\33\3\2\2\2\u0091\u008f\3\2\2\2\u0092\u0093\t\r\2\2\u0093\35\3\2\2\2\r" + "\"JLV`jox}\u0082\u008f"; - public static final ATN _ATN = new ATNDeserializer().deserialize(_serializedATN.toCharArray()); + public static final String _serializedATN = + "\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\3B\u0098\4\2\t\2\4"+ + "\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t"+ + "\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\3\2\3\2\3\2\3\2\5\2#\n\2\3\2\3"+ + "\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2"+ + "\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3\2\3"+ + "\2\3\2\7\2K\n\2\f\2\16\2N\13\2\3\3\3\3\3\3\3\3\3\3\3\3\3\3\5\3W\n\3\3"+ + "\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\5\4b\n\4\3\5\3\5\3\5\5\5g\n\5\3\6\3"+ + "\6\3\6\3\6\3\6\5\6n\n\6\3\7\3\7\3\7\5\7s\n\7\3\7\3\7\3\b\3\b\3\b\7\bz"+ + "\n\b\f\b\16\b}\13\b\3\t\3\t\5\t\u0081\n\t\3\n\3\n\3\n\5\n\u0086\n\n\3"+ + "\13\3\13\3\f\3\f\3\r\3\r\3\16\3\16\3\16\7\16\u0091\n\16\f\16\16\16\u0094"+ + "\13\16\3\17\3\17\3\17\2\3\2\20\2\4\6\b\n\f\16\20\22\24\26\30\32\34\2\16"+ + "\3\2\6\7\3\2\b\13\4\2\6\7\f\f\3\2\20\23\3\2\24\27\3\2\30\31\3\2\33\34"+ + "\3\2\r\16\3\2\"#\3\2)\60\3\2\618\5\2\r\16\30\31<=\2\u00ab\2\"\3\2\2\2"+ + "\4V\3\2\2\2\6a\3\2\2\2\bc\3\2\2\2\nm\3\2\2\2\fo\3\2\2\2\16v\3\2\2\2\20"+ + "~\3\2\2\2\22\u0085\3\2\2\2\24\u0087\3\2\2\2\26\u0089\3\2\2\2\30\u008b"+ + "\3\2\2\2\32\u008d\3\2\2\2\34\u0095\3\2\2\2\36\37\b\2\1\2\37#\5\4\3\2 "+ + "!\t\2\2\2!#\5\2\2\r\"\36\3\2\2\2\" \3\2\2\2#L\3\2\2\2$%\f\f\2\2%&\t\3"+ + "\2\2&K\5\2\2\r\'(\f\13\2\2()\t\4\2\2)K\5\2\2\f*+\f\t\2\2+,\7\17\2\2,K"+ + "\5\2\2\n-.\f\b\2\2./\t\5\2\2/K\5\2\2\t\60\61\f\7\2\2\61\62\t\6\2\2\62"+ + "K\5\2\2\b\63\64\f\6\2\2\64\65\t\7\2\2\65K\5\2\2\7\66\67\f\5\2\2\678\7"+ + "\32\2\28K\5\2\2\69:\f\4\2\2:;\t\b\2\2;K\5\2\2\5<=\f\3\2\2=>\7\35\2\2>"+ + "K\5\2\2\4?@\f\17\2\2@A\7\3\2\2AK\5\n\6\2BC\f\16\2\2CD\7\4\2\2DE\5\2\2"+ + "\2EF\7\5\2\2FK\3\2\2\2GH\f\n\2\2HI\t\t\2\2IK\5\30\r\2J$\3\2\2\2J\'\3\2"+ + "\2\2J*\3\2\2\2J-\3\2\2\2J\60\3\2\2\2J\63\3\2\2\2J\66\3\2\2\2J9\3\2\2\2"+ + "J<\3\2\2\2J?\3\2\2\2JB\3\2\2\2JG\3\2\2\2KN\3\2\2\2LJ\3\2\2\2LM\3\2\2\2"+ + "M\3\3\2\2\2NL\3\2\2\2OW\5\n\6\2PW\5\6\4\2QW\5\b\5\2RS\7\36\2\2ST\5\2\2"+ + "\2TU\7\37\2\2UW\3\2\2\2VO\3\2\2\2VP\3\2\2\2VQ\3\2\2\2VR\3\2\2\2W\5\3\2"+ + "\2\2XY\7 \2\2Yb\7!\2\2Zb\t\n\2\2[b\7>\2\2\\b\7?\2\2]b\79\2\2^b\7:\2\2"+ + "_b\7;\2\2`b\5\20\t\2aX\3\2\2\2aZ\3\2\2\2a[\3\2\2\2a\\\3\2\2\2a]\3\2\2"+ + "\2a^\3\2\2\2a_\3\2\2\2a`\3\2\2\2b\7\3\2\2\2cf\7$\2\2dg\5\34\17\2eg\7>"+ + "\2\2fd\3\2\2\2fe\3\2\2\2g\t\3\2\2\2hn\5\34\17\2in\5\f\7\2jn\7%\2\2kn\7"+ + "&\2\2ln\7\'\2\2mh\3\2\2\2mi\3\2\2\2mj\3\2\2\2mk\3\2\2\2ml\3\2\2\2n\13"+ + "\3\2\2\2op\5\34\17\2pr\7\36\2\2qs\5\16\b\2rq\3\2\2\2rs\3\2\2\2st\3\2\2"+ + "\2tu\7\37\2\2u\r\3\2\2\2v{\5\2\2\2wx\7(\2\2xz\5\2\2\2yw\3\2\2\2z}\3\2"+ + "\2\2{y\3\2\2\2{|\3\2\2\2|\17\3\2\2\2}{\3\2\2\2~\u0080\7?\2\2\177\u0081"+ + "\5\22\n\2\u0080\177\3\2\2\2\u0080\u0081\3\2\2\2\u0081\21\3\2\2\2\u0082"+ + "\u0086\5\24\13\2\u0083\u0086\5\26\f\2\u0084\u0086\7>\2\2\u0085\u0082\3"+ + "\2\2\2\u0085\u0083\3\2\2\2\u0085\u0084\3\2\2\2\u0086\23\3\2\2\2\u0087"+ + "\u0088\t\13\2\2\u0088\25\3\2\2\2\u0089\u008a\t\f\2\2\u008a\27\3\2\2\2"+ + "\u008b\u008c\5\32\16\2\u008c\31\3\2\2\2\u008d\u0092\5\34\17\2\u008e\u008f"+ + "\7\3\2\2\u008f\u0091\5\34\17\2\u0090\u008e\3\2\2\2\u0091\u0094\3\2\2\2"+ + "\u0092\u0090\3\2\2\2\u0092\u0093\3\2\2\2\u0093\33\3\2\2\2\u0094\u0092"+ + "\3\2\2\2\u0095\u0096\t\r\2\2\u0096\35\3\2\2\2\16\"JLVafmr{\u0080\u0085"+ + "\u0092"; + public static final ATN _ATN = + new ATNDeserializer().deserialize(_serializedATN.toCharArray()); static { _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); } } -} +} \ No newline at end of file diff --git a/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathQuantityNode.java b/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathQuantityNode.java index 869f38e3c02..57481880b77 100644 --- a/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathQuantityNode.java +++ b/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathQuantityNode.java @@ -6,7 +6,6 @@ package com.ibm.fhir.model.path; -import static com.ibm.fhir.model.path.util.FHIRPathUtil.hasValueAndUnit; import static com.ibm.fhir.model.type.String.string; import java.math.BigDecimal; @@ -17,34 +16,68 @@ public class FHIRPathQuantityNode extends FHIRPathElementNode { private final Quantity quantity; + private final String quantitySystem; + private final String quantityCode; + private final String quantityUnit; + private final BigDecimal quantityValue; protected FHIRPathQuantityNode(Builder builder) { super(builder); quantity = builder.quantity; + quantitySystem = getQuantitySystem(quantity); + quantityCode = getQuantityCode(quantity); + quantityUnit = getQuantityUnit(quantity); + quantityValue = getQuantityValue(quantity); } public Quantity quantity() { return quantity; } + public String getQuantitySystem() { + return quantitySystem; + } + + public String getQuantityCode() { + return quantityCode; + } + + public String getQuantityUnit() { + return quantityUnit; + } + public BigDecimal getQuantityValue() { - if (quantity.getValue() != null && quantity.getValue().getValue() != null) { - return quantity.getValue().getValue(); + return quantityValue; + } + + private String getQuantitySystem(Quantity quantity) { + if (quantity.getSystem() != null) { + return quantity.getSystem().getValue(); } return null; } - public String getQuantityUnit() { - // prefer code over unit - if (quantity.getCode() != null && quantity.getCode().getValue() != null) { + private String getQuantityCode(Quantity quantity) { + if (quantity.getCode() != null) { return quantity.getCode().getValue(); } - if (quantity.getUnit() != null && quantity.getUnit().getValue() != null) { + return null; + } + + private String getQuantityUnit(Quantity quantity) { + if (quantity.getUnit() != null) { return quantity.getUnit().getValue(); } return null; } + private BigDecimal getQuantityValue(Quantity quantity) { + if (quantity.getValue() != null) { + return quantity.getValue().getValue(); + } + return null; + } + @Override public boolean isQuantityNode() { return true; @@ -71,7 +104,7 @@ public Builder path(String path) { return (Builder) super.path(path); } - public Builder value(FHIRPathPrimitiveValue value) { + public Builder value(FHIRPathSystemValue value) { return (Builder) super.value(value); } @@ -107,32 +140,48 @@ public FHIRPathQuantityNode subtract(FHIRPathQuantityNode node) { @Override public boolean isComparableTo(FHIRPathNode other) { - BigDecimal value = getQuantityValue(); - if (other instanceof FHIRPathQuantityNode) { - return hasValueAndUnit(this) && - hasValueAndUnit((FHIRPathQuantityNode) other) && - // units must be equal - getQuantityUnit().equals(((FHIRPathQuantityNode) other).getQuantityUnit()); - } - if (other instanceof FHIRPathNumberValue || other.getValue() instanceof FHIRPathNumberValue) { - return value != null; + if (hasValue()) { + if (other instanceof FHIRPathQuantityValue) { + return getValue().isComparableTo(other); + } + if (other.getValue() instanceof FHIRPathQuantityValue) { + return getValue().isComparableTo(other.getValue()); + } + } else if (other instanceof FHIRPathQuantityNode) { + return isComparableTo((FHIRPathQuantityNode) other); + } else if (other instanceof FHIRPathNumberValue || other.getValue() instanceof FHIRPathNumberValue) { + return getQuantityValue() != null; } return false; } + + private boolean isComparableTo(FHIRPathQuantityNode other) { + return getQuantityValue() != null && other.getQuantityValue() != null && + ((getQuantitySystem() !=null && other.getQuantitySystem() != null && getQuantitySystem().equals(other.getQuantitySystem()) && + getQuantityCode() != null && other.getQuantityCode() != null && getQuantityCode().equals(other.getQuantityCode())) || + (getQuantityUnit() != null && other.getQuantityUnit() != null && getQuantityUnit().equals(other.getQuantityUnit()))); + } @Override public int compareTo(FHIRPathNode other) { if (!isComparableTo(other)) { throw new IllegalArgumentException(); } - BigDecimal value = getQuantityValue(); - if (other instanceof FHIRPathNumberValue) { - return value.compareTo(((FHIRPathNumberValue) other).decimal()); - } - if (other.getValue() instanceof FHIRPathNumberValue) { - return value.compareTo(((FHIRPathNumberValue) other.getValue()).decimal()); + if (hasValue()) { + if (other instanceof FHIRPathQuantityValue) { + return getValue().compareTo(other); + } + if (other.getValue() instanceof FHIRPathQuantityValue) { + return getValue().compareTo(other.getValue()); + } + } else if (other instanceof FHIRPathQuantityNode) { + return getQuantityValue().compareTo(((FHIRPathQuantityNode) other).getQuantityValue()); + } else if (other instanceof FHIRPathNumberValue) { + return getQuantityValue().compareTo(((FHIRPathNumberValue) other).decimal()); + } else if (other.getValue() instanceof FHIRPathNumberValue) { + return getQuantityValue().compareTo(((FHIRPathNumberValue) other.getValue()).decimal()); } - return value.compareTo(((FHIRPathQuantityNode) other).getQuantityValue()); + throw new IllegalStateException(); } @Override @@ -147,4 +196,4 @@ public String toString() { sb.append("'"); return sb.toString(); } -} +} \ No newline at end of file diff --git a/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathQuantityValue.java b/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathQuantityValue.java new file mode 100644 index 00000000000..4b9202c5a4d --- /dev/null +++ b/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathQuantityValue.java @@ -0,0 +1,192 @@ +/* + * (C) Copyright IBM Corp. 2019 + * + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.ibm.fhir.model.path; + +import java.math.BigDecimal; +import java.util.Collection; +import java.util.Objects; + +import com.ibm.fhir.model.path.visitor.FHIRPathNodeVisitor; +import com.ibm.fhir.model.type.Quantity; + +public class FHIRPathQuantityValue extends FHIRPathAbstractNode implements FHIRPathSystemValue { + private final BigDecimal value; + private final String unit; + + protected FHIRPathQuantityValue(Builder builder) { + super(builder); + this.value = builder.value; + this.unit = builder.unit; + } + + @Override + public boolean isQuantityValue() { + return true; + } + + public BigDecimal value() { + return value; + } + + public String unit() { + return unit; + } + + public static FHIRPathQuantityValue quantityValue(Quantity quantity) { + if (quantity.getValue() != null && + quantity.getValue().getValue() != null && + quantity.getSystem() != null && + "http://unitsofmeasure.org".equals(quantity.getSystem().getValue()) && + quantity.getCode() != null && + quantity.getCode().getValue() != null) { + BigDecimal value = quantity.getValue().getValue(); + String unit = getUnit(quantity.getCode().getValue()); + return quantityValue(value, unit); + } + return null; + } + + private static String getUnit(String code) { + switch (code) { + case "a": + return "year"; + case "mo": + return "month"; + case "d": + return "day"; + case "h": + return "hour"; + case "min": + return "minute"; + case "s": + return "second"; + } + return code; + } + + public static FHIRPathQuantityValue quantityValue(BigDecimal value, String unit) { + return FHIRPathQuantityValue.builder(value, unit).build(); + } + + @Override + public Builder toBuilder() { + return new Builder(type, value, unit); + } + + public static Builder builder(BigDecimal value, String unit) { + return new Builder(FHIRPathType.SYSTEM_QUANTITY, value, unit); + } + + public static class Builder extends FHIRPathAbstractNode.Builder { + private final BigDecimal value; + private final String unit; + + private Builder(FHIRPathType type, BigDecimal value, String unit) { + super(type); + this.value = value; + this.unit = unit; + } + + @Override + public Builder name(String name) { + return (Builder) super.name(name); + } + + @Override + public Builder path(String path) { + return (Builder) super.path(path); + } + + @Override + public Builder value(FHIRPathSystemValue value) { + return this; + } + + @Override + public Builder children(FHIRPathNode... children) { + return this; + } + + @Override + public Builder children(Collection children) { + return this; + } + + @Override + public FHIRPathQuantityValue build() { + return new FHIRPathQuantityValue(this); + } + } + + public FHIRPathQuantityValue add(FHIRPathQuantityValue quantityValue) { + return FHIRPathQuantityValue.quantityValue(value.add(quantityValue.value()), unit); + } + + public FHIRPathQuantityValue subtract(FHIRPathQuantityValue quantityValue) { + return FHIRPathQuantityValue.quantityValue(value.subtract(quantityValue.value()), unit); + } + + @Override + public boolean isComparableTo(FHIRPathNode other) { + if (other instanceof FHIRPathQuantityValue) { + return unit.equals(((FHIRPathQuantityValue) other).unit()); + } + if (other.getValue() instanceof FHIRPathQuantityValue) { + return unit.equals(((FHIRPathQuantityValue) other.getValue()).unit()); + } + return (other instanceof FHIRPathNumberValue) || (other.getValue() instanceof FHIRPathNumberValue); + } + + @Override + public int compareTo(FHIRPathNode other) { + if (!isComparableTo(other)) { + throw new IllegalArgumentException(); + } + if (other instanceof FHIRPathQuantityValue) { + return value.compareTo(((FHIRPathQuantityValue) other).value()); + } + return value.compareTo(((FHIRPathQuantityValue) other.getValue()).value()); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (!(obj instanceof FHIRPathNode)) { + return false; + } + FHIRPathNode other = (FHIRPathNode) obj; + if (other instanceof FHIRPathQuantityValue) { + return Objects.equals(value, ((FHIRPathQuantityValue) other).value()) && + Objects.equals(unit, ((FHIRPathQuantityValue) other).unit()); + } + if (other.getValue() instanceof FHIRPathQuantityValue) { + return Objects.equals(value, ((FHIRPathQuantityValue) other.getValue()).value()) && + Objects.equals(unit, ((FHIRPathQuantityValue) other.getValue()).unit()); + } + return false; + } + + @Override + public int hashCode() { + return Objects.hash(value, unit); + } + + @Override + public String toString() { + return String.format("%s '%s'", value.toPlainString(), unit); + } + + @Override + public void accept(FHIRPathNodeVisitor visitor) { + visitor.visit(this); + } +} \ No newline at end of file diff --git a/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathResourceNode.java b/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathResourceNode.java index 6d1e5274847..ed83c8722cd 100644 --- a/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathResourceNode.java +++ b/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathResourceNode.java @@ -111,7 +111,7 @@ public int hashCode() { } @Override - public void accept(T param, FHIRPathNodeVisitor visitor) { - visitor.visit(param, this); + public void accept(FHIRPathNodeVisitor visitor) { + visitor.visit(this); } } diff --git a/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathStringValue.java b/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathStringValue.java index 908b82ffcbb..6a83a99a527 100644 --- a/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathStringValue.java +++ b/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathStringValue.java @@ -11,7 +11,7 @@ import com.ibm.fhir.model.path.visitor.FHIRPathNodeVisitor; -public class FHIRPathStringValue extends FHIRPathAbstractNode implements FHIRPathPrimitiveValue { +public class FHIRPathStringValue extends FHIRPathAbstractNode implements FHIRPathSystemValue { public static final FHIRPathStringValue EMPTY_STRING = stringValue(""); private final String string; @@ -66,7 +66,7 @@ public Builder path(String path) { } @Override - public Builder value(FHIRPathPrimitiveValue value) { + public Builder value(FHIRPathSystemValue value) { return this; } @@ -183,7 +183,7 @@ public String toString() { } @Override - public void accept(T param, FHIRPathNodeVisitor visitor) { - visitor.visit(param, this); + public void accept(FHIRPathNodeVisitor visitor) { + visitor.visit(this); } } diff --git a/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathPrimitiveValue.java b/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathSystemValue.java similarity index 67% rename from fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathPrimitiveValue.java rename to fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathSystemValue.java index 1b244f3f8ba..4f662f8b4b3 100644 --- a/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathPrimitiveValue.java +++ b/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathSystemValue.java @@ -6,43 +6,43 @@ package com.ibm.fhir.model.path; -public interface FHIRPathPrimitiveValue extends FHIRPathNode { +public interface FHIRPathSystemValue extends FHIRPathNode { @Override default boolean hasValue() { return false; } @Override - default boolean isPrimitiveValue() { + default boolean isSystemValue() { return true; } default boolean isBooleanValue() { return false; } - default boolean isDateTimeValue() { - return false; - } default boolean isStringValue() { return false; } - default boolean isTimeValue() { + default boolean isQuantityValue() { return false; } default boolean isNumberValue() { return false; } + default boolean isTemporalValue() { + return false; + } default FHIRPathBooleanValue asBooleanValue() { return as(FHIRPathBooleanValue.class); } - default FHIRPathDateTimeValue asDateTimeValue() { - return as(FHIRPathDateTimeValue.class); - } default FHIRPathStringValue asStringValue() { return as(FHIRPathStringValue.class); } - default FHIRPathTimeValue asTimeValue() { - return as(FHIRPathTimeValue.class); + default FHIRPathQuantityValue asQuantityValue() { + return as(FHIRPathQuantityValue.class); } default FHIRPathNumberValue asNumberValue() { return as(FHIRPathNumberValue.class); } + default FHIRPathTemporalValue asTemporalValue() { + return as(FHIRPathTemporalValue.class); + } } diff --git a/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathTemporalValue.java b/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathTemporalValue.java new file mode 100644 index 00000000000..ddd2957f0e3 --- /dev/null +++ b/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathTemporalValue.java @@ -0,0 +1,45 @@ +/* + * (C) Copyright IBM Corp. 2019 + * + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.ibm.fhir.model.path; + +import java.time.temporal.Temporal; + +public interface FHIRPathTemporalValue extends FHIRPathSystemValue { + @Override + default boolean isTemporalValue() { + return true; + } + + default boolean isDateValue() { + return false; + } + + default boolean isDateTimeValue() { + return false; + } + + default boolean isTimeValue() { + return false; + } + + Temporal temporal(); + + default FHIRPathDateValue asDateValue() { + return as(FHIRPathDateValue.class); + } + + default FHIRPathDateTimeValue asDateTimeValue() { + return as(FHIRPathDateTimeValue.class); + } + + default FHIRPathTimeValue asTimeValue() { + return as(FHIRPathTimeValue.class); + } + + FHIRPathTemporalValue add(FHIRPathQuantityValue quantityValue); + FHIRPathTemporalValue subtract(FHIRPathQuantityValue quantityValue); +} \ No newline at end of file diff --git a/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathTimeValue.java b/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathTimeValue.java index 14f5452e3f1..38425186c86 100644 --- a/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathTimeValue.java +++ b/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathTimeValue.java @@ -23,7 +23,7 @@ import com.ibm.fhir.model.path.visitor.FHIRPathNodeVisitor; -public class FHIRPathTimeValue extends FHIRPathAbstractNode implements FHIRPathPrimitiveValue { +public class FHIRPathTimeValue extends FHIRPathAbstractNode implements FHIRPathTemporalValue { private static final DateTimeFormatter TIME_PARSER_FORMATTER = new DateTimeFormatterBuilder() .appendPattern("'T'HH:mm:ss") .optionalStart() @@ -35,10 +35,12 @@ public class FHIRPathTimeValue extends FHIRPathAbstractNode implements FHIRPathP .toFormatter(); private final TemporalAccessor time; + private final Temporal temporal; protected FHIRPathTimeValue(Builder builder) { super(builder); time = builder.time; + temporal = getTemporal(time); } @Override @@ -61,6 +63,11 @@ public TemporalAccessor time() { return time; } + @Override + public Temporal temporal() { + return temporal; + } + public static FHIRPathTimeValue timeValue(String time) { return FHIRPathTimeValue.builder(TIME_PARSER_FORMATTER.parseBest(time, OffsetTime::from, LocalTime::from)).build(); } @@ -101,7 +108,7 @@ public Builder path(String path) { } @Override - public Builder value(FHIRPathPrimitiveValue value) { + public Builder value(FHIRPathSystemValue value) { return this; } @@ -121,15 +128,15 @@ public FHIRPathTimeValue build() { } } - public FHIRPathTimeValue add(FHIRPathQuantityNode quantityNode) { + public FHIRPathTimeValue add(FHIRPathQuantityValue quantityValue) { Temporal temporal = getTemporal(time); - TemporalAmount temporalAmount = getTemporalAmount(quantityNode); + TemporalAmount temporalAmount = getTemporalAmount(quantityValue); return timeValue(temporal.plus(temporalAmount)); } - public FHIRPathTimeValue subtract(FHIRPathQuantityNode quantityNode) { + public FHIRPathTimeValue subtract(FHIRPathQuantityValue quantityValue) { Temporal temporal = getTemporal(time); - TemporalAmount temporalAmount = getTemporalAmount(quantityNode); + TemporalAmount temporalAmount = getTemporalAmount(quantityValue); return timeValue(temporal.minus(temporalAmount)); } @@ -193,7 +200,7 @@ public String toString() { } @Override - public void accept(T param, FHIRPathNodeVisitor visitor) { - visitor.visit(param, this); + public void accept(FHIRPathNodeVisitor visitor) { + visitor.visit(this); } } diff --git a/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathTree.java b/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathTree.java index c8610babf50..109962f444d 100644 --- a/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathTree.java +++ b/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathTree.java @@ -100,7 +100,12 @@ protected void doVisitEnd(String elementName, int elementIndex, Resource resourc @Override protected void doVisitStart(String elementName, int elementIndex, Element element) { if (element instanceof Quantity) { - builderStack.push(FHIRPathQuantityNode.builder((Quantity) element).name(elementName)); + Quantity quantity = (Quantity) element; + builderStack.push(FHIRPathQuantityNode.builder(quantity).name(elementName)); + FHIRPathQuantityValue value = FHIRPathQuantityValue.quantityValue(quantity); + if (value != null) { + builderStack.peek().value(value); + } } else { builderStack.push(FHIRPathElementNode.builder(element).name(elementName)); } diff --git a/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathType.java b/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathType.java index 265640c847f..c3067760b9a 100644 --- a/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathType.java +++ b/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathType.java @@ -6,9 +6,6 @@ package com.ibm.fhir.model.path; -import java.math.BigDecimal; -import java.time.LocalTime; -import java.time.temporal.TemporalAccessor; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; @@ -306,30 +303,34 @@ public enum FHIRPathType { // FHIRPath system types SYSTEM_ANY("System", "Any"), - SYSTEM_BOOLEAN("System", "Boolean", SYSTEM_ANY, java.lang.Boolean.class), - SYSTEM_STRING("System", "String", SYSTEM_ANY, java.lang.String.class), - SYSTEM_INTEGER("System", "Integer", SYSTEM_ANY, java.lang.Integer.class), - SYSTEM_DECIMAL("System", "Decimal", SYSTEM_ANY, BigDecimal.class), - SYSTEM_DATE_TIME("System", "DateTime", SYSTEM_ANY, TemporalAccessor.class), - SYSTEM_TIME("System", "Time", SYSTEM_ANY, LocalTime.class), + SYSTEM_BOOLEAN("System", "Boolean", SYSTEM_ANY), + SYSTEM_STRING("System", "String", SYSTEM_ANY), + SYSTEM_INTEGER("System", "Integer", SYSTEM_ANY), + SYSTEM_DECIMAL("System", "Decimal", SYSTEM_ANY), + SYSTEM_DATE("System", "Date", SYSTEM_ANY), + SYSTEM_DATE_TIME("System", "DateTime", SYSTEM_ANY), + SYSTEM_QUANTITY("System", "Quantity", SYSTEM_ANY), + SYSTEM_TIME("System", "Time", SYSTEM_ANY), // FHIRPath metamodel types - SYSTEM_TYPE_INFO("System", "TypeInfo", SYSTEM_ANY, TypeInfo.class), - SYSTEM_CLASS_INFO("System", "ClassInfo", SYSTEM_TYPE_INFO, ClassInfo.class), - SYSTEM_TUPLE_TYPE_INFO("System", "TupleTypeInfo", SYSTEM_TYPE_INFO, TupleTypeInfo.class), - SYSTEM_LIST_TYPE_INFO("System", "ListTypeInfo", SYSTEM_TYPE_INFO, ListTypeInfo.class), - SYSTEM_SIMPLE_TYPE_INFO("System", "SystemTypeInfo", SYSTEM_TYPE_INFO, SimpleTypeInfo.class); + SYSTEM_TYPE_INFO("System", "TypeInfo", SYSTEM_ANY), + SYSTEM_CLASS_INFO("System", "ClassInfo", SYSTEM_TYPE_INFO), + SYSTEM_TUPLE_TYPE_INFO("System", "TupleTypeInfo", SYSTEM_TYPE_INFO), + SYSTEM_LIST_TYPE_INFO("System", "ListTypeInfo", SYSTEM_TYPE_INFO), + SYSTEM_SIMPLE_TYPE_INFO("System", "SystemTypeInfo", SYSTEM_TYPE_INFO); private final java.lang.String namespace; private final java.lang.String name; private final FHIRPathType baseType; private final Class modelClass; - private static final Map TYPE_NAME_MAP = createTypeNameMap(); - private static final Map, FHIRPathType> TYPE_MAP = createTypeMap(); - private static final Set SYSTEM_TYPES = new HashSet<>(Arrays.asList(SYSTEM_BOOLEAN, SYSTEM_STRING, SYSTEM_INTEGER, SYSTEM_DECIMAL, SYSTEM_DATE_TIME, SYSTEM_TIME)); + private static final Map TYPE_NAME_MAP = buildTypeNameMap(); + private static final Map, FHIRPathType> TYPE_MAP = buildTypeMap(); + private static final Set SYSTEM_TYPES = new HashSet<>(Arrays.asList(SYSTEM_BOOLEAN, SYSTEM_STRING, SYSTEM_INTEGER, SYSTEM_DECIMAL, SYSTEM_DATE, SYSTEM_DATE_TIME, SYSTEM_QUANTITY, SYSTEM_TIME)); + private static final Set METAMODEL_TYPES = new HashSet<>(Arrays.asList(SYSTEM_TYPE_INFO, SYSTEM_CLASS_INFO, SYSTEM_TUPLE_TYPE_INFO, SYSTEM_LIST_TYPE_INFO, SYSTEM_SIMPLE_TYPE_INFO)); + private static final Map, FHIRPathType> METAMODEL_TYPE_MAP = buildMetamodelTypeMap(); - private static Map createTypeNameMap() { + private static Map buildTypeNameMap() { Map typeNameMap = new HashMap<>(); for (FHIRPathType type : FHIRPathType.values()) { typeNameMap.put(type.namespace + "." + type.name, type); @@ -337,11 +338,21 @@ private static Map createTypeNameMap() { return typeNameMap; } - private static Map, FHIRPathType> createTypeMap() { + private static Map, FHIRPathType> buildMetamodelTypeMap() { + Map, FHIRPathType> metamodelTypeMap = new HashMap<>(); + metamodelTypeMap.put(TypeInfo.class, SYSTEM_TYPE_INFO); + metamodelTypeMap.put(ClassInfo.class, SYSTEM_CLASS_INFO); + metamodelTypeMap.put(TupleTypeInfo.class, SYSTEM_TUPLE_TYPE_INFO); + metamodelTypeMap.put(ListTypeInfo.class, SYSTEM_LIST_TYPE_INFO); + metamodelTypeMap.put(SimpleTypeInfo.class, SYSTEM_SIMPLE_TYPE_INFO); + return metamodelTypeMap; + } + + private static Map, FHIRPathType> buildTypeMap() { Map, FHIRPathType> typeMap = new HashMap<>(); for (FHIRPathType type : FHIRPathType.values()) { if (type.modelClass != null) { - typeMap.put(type.modelClass, type); + typeMap.put(type.modelClass, type); } } return typeMap; @@ -350,6 +361,10 @@ private static Map, FHIRPathType> createTypeMap() { FHIRPathType(java.lang.String namespace, java.lang.String name) { this(namespace, name, null, null); } + + FHIRPathType(java.lang.String namespace, java.lang.String name, FHIRPathType baseType) { + this(namespace, name, baseType, null); + } FHIRPathType(java.lang.String namespace, java.lang.String name, FHIRPathType baseType, Class modelClass) { this.namespace = namespace; @@ -421,16 +436,22 @@ public static FHIRPathType from(java.lang.String namespace, java.lang.String nam return TYPE_NAME_MAP.get(namespace + "." + name); } - public static FHIRPathType from(Class modelClass) { - FHIRPathType type = TYPE_MAP.get(ModelSupport.getConcreteType(modelClass)); - if (type == null) { - if (BackboneElement.class.isAssignableFrom(modelClass)) { - type = FHIR_BACKBONE_ELEMENT; - } else if (Code.class.isAssignableFrom(modelClass)) { - type = FHIR_CODE; + public static FHIRPathType from(Class clazz) { + if (TypeInfo.class.isAssignableFrom(clazz)) { + return METAMODEL_TYPE_MAP.get(clazz); + } + if (ModelSupport.isModelClass(clazz)) { + FHIRPathType type = TYPE_MAP.get(ModelSupport.getConcreteType(clazz)); + if (type == null) { + if (BackboneElement.class.isAssignableFrom(clazz)) { + type = FHIR_BACKBONE_ELEMENT; + } else if (Code.class.isAssignableFrom(clazz)) { + type = FHIR_CODE; + } } + return type; } - return type; + return null; } public static Set getSystemTypes() { @@ -440,4 +461,12 @@ public static Set getSystemTypes() { public static boolean isSystemType(FHIRPathType type) { return SYSTEM_TYPES.contains(type); } + + public static Set getMetamodelTypes() { + return METAMODEL_TYPES; + } + + public static boolean isMetamodelType(FHIRPathType type) { + return METAMODEL_TYPES.contains(type); + } } \ No newline at end of file diff --git a/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathTypeInfoNode.java b/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathTypeInfoNode.java index 0db3ee29ddf..921c185651d 100644 --- a/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathTypeInfoNode.java +++ b/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathTypeInfoNode.java @@ -46,8 +46,8 @@ public FHIRPathTypeInfoNode build() { } @Override - public void accept(T param, FHIRPathNodeVisitor visitor) { - visitor.visit(param, this); + public void accept(FHIRPathNodeVisitor visitor) { + visitor.visit(this); } @Override diff --git a/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathVisitor.java b/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathVisitor.java index 4b6f5669d98..31e1de1202c 100644 --- a/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathVisitor.java +++ b/fhir-model/src/main/java/com/ibm/fhir/model/path/FHIRPathVisitor.java @@ -1,396 +1,290 @@ -/* - * (C) Copyright IBM Corp. 2019 - * - * SPDX-License-Identifier: Apache-2.0 - */ - +// Generated from FHIRPath.g4 by ANTLR 4.7.2 package com.ibm.fhir.model.path; - import org.antlr.v4.runtime.tree.ParseTreeVisitor; /** - * This interface defines a complete generic visitor for a parse tree produced by {@link FHIRPathParser}. + * This interface defines a complete generic visitor for a parse tree produced + * by {@link FHIRPathParser}. * - * @param - * The return type of the visit operation. Use {@link Void} for operations with no return type. + * @param The return type of the visit operation. Use {@link Void} for + * operations with no return type. */ public interface FHIRPathVisitor extends ParseTreeVisitor { /** - * Visit a parse tree produced by the {@code indexerExpression} labeled alternative in - * {@link FHIRPathParser#expression}. - * - * @param ctx - * the parse tree + * Visit a parse tree produced by the {@code indexerExpression} + * labeled alternative in {@link FHIRPathParser#expression}. + * @param ctx the parse tree * @return the visitor result */ T visitIndexerExpression(FHIRPathParser.IndexerExpressionContext ctx); - /** - * Visit a parse tree produced by the {@code polarityExpression} labeled alternative in - * {@link FHIRPathParser#expression}. - * - * @param ctx - * the parse tree + * Visit a parse tree produced by the {@code polarityExpression} + * labeled alternative in {@link FHIRPathParser#expression}. + * @param ctx the parse tree * @return the visitor result */ T visitPolarityExpression(FHIRPathParser.PolarityExpressionContext ctx); - /** - * Visit a parse tree produced by the {@code additiveExpression} labeled alternative in - * {@link FHIRPathParser#expression}. - * - * @param ctx - * the parse tree + * Visit a parse tree produced by the {@code additiveExpression} + * labeled alternative in {@link FHIRPathParser#expression}. + * @param ctx the parse tree * @return the visitor result */ T visitAdditiveExpression(FHIRPathParser.AdditiveExpressionContext ctx); - /** - * Visit a parse tree produced by the {@code multiplicativeExpression} labeled alternative in - * {@link FHIRPathParser#expression}. - * - * @param ctx - * the parse tree + * Visit a parse tree produced by the {@code multiplicativeExpression} + * labeled alternative in {@link FHIRPathParser#expression}. + * @param ctx the parse tree * @return the visitor result */ T visitMultiplicativeExpression(FHIRPathParser.MultiplicativeExpressionContext ctx); - /** - * Visit a parse tree produced by the {@code unionExpression} labeled alternative in - * {@link FHIRPathParser#expression}. - * - * @param ctx - * the parse tree + * Visit a parse tree produced by the {@code unionExpression} + * labeled alternative in {@link FHIRPathParser#expression}. + * @param ctx the parse tree * @return the visitor result */ T visitUnionExpression(FHIRPathParser.UnionExpressionContext ctx); - /** - * Visit a parse tree produced by the {@code orExpression} labeled alternative in {@link FHIRPathParser#expression}. - * - * @param ctx - * the parse tree + * Visit a parse tree produced by the {@code orExpression} + * labeled alternative in {@link FHIRPathParser#expression}. + * @param ctx the parse tree * @return the visitor result */ T visitOrExpression(FHIRPathParser.OrExpressionContext ctx); - /** - * Visit a parse tree produced by the {@code andExpression} labeled alternative in - * {@link FHIRPathParser#expression}. - * - * @param ctx - * the parse tree + * Visit a parse tree produced by the {@code andExpression} + * labeled alternative in {@link FHIRPathParser#expression}. + * @param ctx the parse tree * @return the visitor result */ T visitAndExpression(FHIRPathParser.AndExpressionContext ctx); - /** - * Visit a parse tree produced by the {@code membershipExpression} labeled alternative in - * {@link FHIRPathParser#expression}. - * - * @param ctx - * the parse tree + * Visit a parse tree produced by the {@code membershipExpression} + * labeled alternative in {@link FHIRPathParser#expression}. + * @param ctx the parse tree * @return the visitor result */ T visitMembershipExpression(FHIRPathParser.MembershipExpressionContext ctx); - /** - * Visit a parse tree produced by the {@code inequalityExpression} labeled alternative in - * {@link FHIRPathParser#expression}. - * - * @param ctx - * the parse tree + * Visit a parse tree produced by the {@code inequalityExpression} + * labeled alternative in {@link FHIRPathParser#expression}. + * @param ctx the parse tree * @return the visitor result */ T visitInequalityExpression(FHIRPathParser.InequalityExpressionContext ctx); - /** - * Visit a parse tree produced by the {@code invocationExpression} labeled alternative in - * {@link FHIRPathParser#expression}. - * - * @param ctx - * the parse tree + * Visit a parse tree produced by the {@code invocationExpression} + * labeled alternative in {@link FHIRPathParser#expression}. + * @param ctx the parse tree * @return the visitor result */ T visitInvocationExpression(FHIRPathParser.InvocationExpressionContext ctx); - /** - * Visit a parse tree produced by the {@code equalityExpression} labeled alternative in - * {@link FHIRPathParser#expression}. - * - * @param ctx - * the parse tree + * Visit a parse tree produced by the {@code equalityExpression} + * labeled alternative in {@link FHIRPathParser#expression}. + * @param ctx the parse tree * @return the visitor result */ T visitEqualityExpression(FHIRPathParser.EqualityExpressionContext ctx); - /** - * Visit a parse tree produced by the {@code impliesExpression} labeled alternative in - * {@link FHIRPathParser#expression}. - * - * @param ctx - * the parse tree + * Visit a parse tree produced by the {@code impliesExpression} + * labeled alternative in {@link FHIRPathParser#expression}. + * @param ctx the parse tree * @return the visitor result */ T visitImpliesExpression(FHIRPathParser.ImpliesExpressionContext ctx); - /** - * Visit a parse tree produced by the {@code termExpression} labeled alternative in - * {@link FHIRPathParser#expression}. - * - * @param ctx - * the parse tree + * Visit a parse tree produced by the {@code termExpression} + * labeled alternative in {@link FHIRPathParser#expression}. + * @param ctx the parse tree * @return the visitor result */ T visitTermExpression(FHIRPathParser.TermExpressionContext ctx); - /** - * Visit a parse tree produced by the {@code typeExpression} labeled alternative in - * {@link FHIRPathParser#expression}. - * - * @param ctx - * the parse tree + * Visit a parse tree produced by the {@code typeExpression} + * labeled alternative in {@link FHIRPathParser#expression}. + * @param ctx the parse tree * @return the visitor result */ T visitTypeExpression(FHIRPathParser.TypeExpressionContext ctx); - /** - * Visit a parse tree produced by the {@code invocationTerm} labeled alternative in {@link FHIRPathParser#term}. - * - * @param ctx - * the parse tree + * Visit a parse tree produced by the {@code invocationTerm} + * labeled alternative in {@link FHIRPathParser#term}. + * @param ctx the parse tree * @return the visitor result */ T visitInvocationTerm(FHIRPathParser.InvocationTermContext ctx); - /** - * Visit a parse tree produced by the {@code literalTerm} labeled alternative in {@link FHIRPathParser#term}. - * - * @param ctx - * the parse tree + * Visit a parse tree produced by the {@code literalTerm} + * labeled alternative in {@link FHIRPathParser#term}. + * @param ctx the parse tree * @return the visitor result */ T visitLiteralTerm(FHIRPathParser.LiteralTermContext ctx); - /** - * Visit a parse tree produced by the {@code externalConstantTerm} labeled alternative in - * {@link FHIRPathParser#term}. - * - * @param ctx - * the parse tree + * Visit a parse tree produced by the {@code externalConstantTerm} + * labeled alternative in {@link FHIRPathParser#term}. + * @param ctx the parse tree * @return the visitor result */ T visitExternalConstantTerm(FHIRPathParser.ExternalConstantTermContext ctx); - /** - * Visit a parse tree produced by the {@code parenthesizedTerm} labeled alternative in {@link FHIRPathParser#term}. - * - * @param ctx - * the parse tree + * Visit a parse tree produced by the {@code parenthesizedTerm} + * labeled alternative in {@link FHIRPathParser#term}. + * @param ctx the parse tree * @return the visitor result */ T visitParenthesizedTerm(FHIRPathParser.ParenthesizedTermContext ctx); - /** - * Visit a parse tree produced by the {@code nullLiteral} labeled alternative in {@link FHIRPathParser#literal}. - * - * @param ctx - * the parse tree + * Visit a parse tree produced by the {@code nullLiteral} + * labeled alternative in {@link FHIRPathParser#literal}. + * @param ctx the parse tree * @return the visitor result */ T visitNullLiteral(FHIRPathParser.NullLiteralContext ctx); - /** - * Visit a parse tree produced by the {@code booleanLiteral} labeled alternative in {@link FHIRPathParser#literal}. - * - * @param ctx - * the parse tree + * Visit a parse tree produced by the {@code booleanLiteral} + * labeled alternative in {@link FHIRPathParser#literal}. + * @param ctx the parse tree * @return the visitor result */ T visitBooleanLiteral(FHIRPathParser.BooleanLiteralContext ctx); - /** - * Visit a parse tree produced by the {@code stringLiteral} labeled alternative in {@link FHIRPathParser#literal}. - * - * @param ctx - * the parse tree + * Visit a parse tree produced by the {@code stringLiteral} + * labeled alternative in {@link FHIRPathParser#literal}. + * @param ctx the parse tree * @return the visitor result */ T visitStringLiteral(FHIRPathParser.StringLiteralContext ctx); - /** - * Visit a parse tree produced by the {@code numberLiteral} labeled alternative in {@link FHIRPathParser#literal}. - * - * @param ctx - * the parse tree + * Visit a parse tree produced by the {@code numberLiteral} + * labeled alternative in {@link FHIRPathParser#literal}. + * @param ctx the parse tree * @return the visitor result */ T visitNumberLiteral(FHIRPathParser.NumberLiteralContext ctx); - /** - * Visit a parse tree produced by the {@code dateTimeLiteral} labeled alternative in {@link FHIRPathParser#literal}. - * - * @param ctx - * the parse tree + * Visit a parse tree produced by the {@code dateLiteral} + * labeled alternative in {@link FHIRPathParser#literal}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitDateLiteral(FHIRPathParser.DateLiteralContext ctx); + /** + * Visit a parse tree produced by the {@code dateTimeLiteral} + * labeled alternative in {@link FHIRPathParser#literal}. + * @param ctx the parse tree * @return the visitor result */ T visitDateTimeLiteral(FHIRPathParser.DateTimeLiteralContext ctx); - /** - * Visit a parse tree produced by the {@code timeLiteral} labeled alternative in {@link FHIRPathParser#literal}. - * - * @param ctx - * the parse tree + * Visit a parse tree produced by the {@code timeLiteral} + * labeled alternative in {@link FHIRPathParser#literal}. + * @param ctx the parse tree * @return the visitor result */ T visitTimeLiteral(FHIRPathParser.TimeLiteralContext ctx); - /** - * Visit a parse tree produced by the {@code quantityLiteral} labeled alternative in {@link FHIRPathParser#literal}. - * - * @param ctx - * the parse tree + * Visit a parse tree produced by the {@code quantityLiteral} + * labeled alternative in {@link FHIRPathParser#literal}. + * @param ctx the parse tree * @return the visitor result */ T visitQuantityLiteral(FHIRPathParser.QuantityLiteralContext ctx); - /** * Visit a parse tree produced by {@link FHIRPathParser#externalConstant}. - * - * @param ctx - * the parse tree + * @param ctx the parse tree * @return the visitor result */ T visitExternalConstant(FHIRPathParser.ExternalConstantContext ctx); - /** - * Visit a parse tree produced by the {@code memberInvocation} labeled alternative in - * {@link FHIRPathParser#invocation}. - * - * @param ctx - * the parse tree + * Visit a parse tree produced by the {@code memberInvocation} + * labeled alternative in {@link FHIRPathParser#invocation}. + * @param ctx the parse tree * @return the visitor result */ T visitMemberInvocation(FHIRPathParser.MemberInvocationContext ctx); - /** - * Visit a parse tree produced by the {@code functionInvocation} labeled alternative in - * {@link FHIRPathParser#invocation}. - * - * @param ctx - * the parse tree + * Visit a parse tree produced by the {@code functionInvocation} + * labeled alternative in {@link FHIRPathParser#invocation}. + * @param ctx the parse tree * @return the visitor result */ T visitFunctionInvocation(FHIRPathParser.FunctionInvocationContext ctx); - /** - * Visit a parse tree produced by the {@code thisInvocation} labeled alternative in - * {@link FHIRPathParser#invocation}. - * - * @param ctx - * the parse tree + * Visit a parse tree produced by the {@code thisInvocation} + * labeled alternative in {@link FHIRPathParser#invocation}. + * @param ctx the parse tree * @return the visitor result */ T visitThisInvocation(FHIRPathParser.ThisInvocationContext ctx); - /** - * Visit a parse tree produced by the {@code indexInvocation} labeled alternative in - * {@link FHIRPathParser#invocation}. - * - * @param ctx - * the parse tree + * Visit a parse tree produced by the {@code indexInvocation} + * labeled alternative in {@link FHIRPathParser#invocation}. + * @param ctx the parse tree * @return the visitor result */ T visitIndexInvocation(FHIRPathParser.IndexInvocationContext ctx); - /** - * Visit a parse tree produced by the {@code totalInvocation} labeled alternative in - * {@link FHIRPathParser#invocation}. - * - * @param ctx - * the parse tree + * Visit a parse tree produced by the {@code totalInvocation} + * labeled alternative in {@link FHIRPathParser#invocation}. + * @param ctx the parse tree * @return the visitor result */ T visitTotalInvocation(FHIRPathParser.TotalInvocationContext ctx); - /** * Visit a parse tree produced by {@link FHIRPathParser#function}. - * - * @param ctx - * the parse tree + * @param ctx the parse tree * @return the visitor result */ T visitFunction(FHIRPathParser.FunctionContext ctx); - /** * Visit a parse tree produced by {@link FHIRPathParser#paramList}. - * - * @param ctx - * the parse tree + * @param ctx the parse tree * @return the visitor result */ T visitParamList(FHIRPathParser.ParamListContext ctx); - /** * Visit a parse tree produced by {@link FHIRPathParser#quantity}. - * - * @param ctx - * the parse tree + * @param ctx the parse tree * @return the visitor result */ T visitQuantity(FHIRPathParser.QuantityContext ctx); - /** * Visit a parse tree produced by {@link FHIRPathParser#unit}. - * - * @param ctx - * the parse tree + * @param ctx the parse tree * @return the visitor result */ T visitUnit(FHIRPathParser.UnitContext ctx); - /** * Visit a parse tree produced by {@link FHIRPathParser#dateTimePrecision}. - * - * @param ctx - * the parse tree + * @param ctx the parse tree * @return the visitor result */ T visitDateTimePrecision(FHIRPathParser.DateTimePrecisionContext ctx); - /** * Visit a parse tree produced by {@link FHIRPathParser#pluralDateTimePrecision}. - * - * @param ctx - * the parse tree + * @param ctx the parse tree * @return the visitor result */ T visitPluralDateTimePrecision(FHIRPathParser.PluralDateTimePrecisionContext ctx); - /** * Visit a parse tree produced by {@link FHIRPathParser#typeSpecifier}. - * - * @param ctx - * the parse tree + * @param ctx the parse tree * @return the visitor result */ T visitTypeSpecifier(FHIRPathParser.TypeSpecifierContext ctx); - /** * Visit a parse tree produced by {@link FHIRPathParser#qualifiedIdentifier}. - * - * @param ctx - * the parse tree + * @param ctx the parse tree * @return the visitor result */ T visitQualifiedIdentifier(FHIRPathParser.QualifiedIdentifierContext ctx); - /** * Visit a parse tree produced by {@link FHIRPathParser#identifier}. - * - * @param ctx - * the parse tree + * @param ctx the parse tree * @return the visitor result */ T visitIdentifier(FHIRPathParser.IdentifierContext ctx); -} +} \ No newline at end of file diff --git a/fhir-model/src/main/java/com/ibm/fhir/model/path/evaluator/FHIRPathEvaluator.java b/fhir-model/src/main/java/com/ibm/fhir/model/path/evaluator/FHIRPathEvaluator.java index cc4a4416b68..1981e5a6c5e 100644 --- a/fhir-model/src/main/java/com/ibm/fhir/model/path/evaluator/FHIRPathEvaluator.java +++ b/fhir-model/src/main/java/com/ibm/fhir/model/path/evaluator/FHIRPathEvaluator.java @@ -14,16 +14,20 @@ import static com.ibm.fhir.model.path.util.FHIRPathUtil.empty; import static com.ibm.fhir.model.path.util.FHIRPathUtil.evaluatesToBoolean; import static com.ibm.fhir.model.path.util.FHIRPathUtil.getInteger; -import static com.ibm.fhir.model.path.util.FHIRPathUtil.getPrimitiveValue; +import static com.ibm.fhir.model.path.util.FHIRPathUtil.getQuantityNode; +import static com.ibm.fhir.model.path.util.FHIRPathUtil.getQuantityValue; import static com.ibm.fhir.model.path.util.FHIRPathUtil.getSingleton; import static com.ibm.fhir.model.path.util.FHIRPathUtil.getString; -import static com.ibm.fhir.model.path.util.FHIRPathUtil.hasPrimitiveValue; -import static com.ibm.fhir.model.path.util.FHIRPathUtil.hasValueAndUnit; +import static com.ibm.fhir.model.path.util.FHIRPathUtil.getSystemValue; +import static com.ibm.fhir.model.path.util.FHIRPathUtil.getTemporalValue; +import static com.ibm.fhir.model.path.util.FHIRPathUtil.hasQuantityNode; +import static com.ibm.fhir.model.path.util.FHIRPathUtil.hasQuantityValue; +import static com.ibm.fhir.model.path.util.FHIRPathUtil.hasSystemValue; +import static com.ibm.fhir.model.path.util.FHIRPathUtil.hasTemporalValue; import static com.ibm.fhir.model.path.util.FHIRPathUtil.isFalse; import static com.ibm.fhir.model.path.util.FHIRPathUtil.isSingleton; import static com.ibm.fhir.model.path.util.FHIRPathUtil.isTrue; import static com.ibm.fhir.model.path.util.FHIRPathUtil.singleton; -import static com.ibm.fhir.model.type.String.string; import java.math.BigDecimal; import java.util.ArrayList; @@ -38,29 +42,30 @@ import java.util.Stack; import java.util.stream.Collectors; -import org.antlr.v4.runtime.ANTLRInputStream; +import org.antlr.v4.runtime.CharStreams; import org.antlr.v4.runtime.CommonTokenStream; import org.antlr.v4.runtime.tree.ParseTree; import com.ibm.fhir.model.path.FHIRPathBaseVisitor; import com.ibm.fhir.model.path.FHIRPathBooleanValue; import com.ibm.fhir.model.path.FHIRPathDateTimeValue; +import com.ibm.fhir.model.path.FHIRPathDateValue; import com.ibm.fhir.model.path.FHIRPathLexer; import com.ibm.fhir.model.path.FHIRPathNode; import com.ibm.fhir.model.path.FHIRPathParser; import com.ibm.fhir.model.path.FHIRPathParser.ExpressionContext; import com.ibm.fhir.model.path.FHIRPathParser.ParamListContext; -import com.ibm.fhir.model.path.FHIRPathPrimitiveValue; import com.ibm.fhir.model.path.FHIRPathQuantityNode; +import com.ibm.fhir.model.path.FHIRPathQuantityValue; +import com.ibm.fhir.model.path.FHIRPathSystemValue; +import com.ibm.fhir.model.path.FHIRPathTemporalValue; import com.ibm.fhir.model.path.FHIRPathTimeValue; import com.ibm.fhir.model.path.FHIRPathTree; import com.ibm.fhir.model.path.FHIRPathType; import com.ibm.fhir.model.path.exception.FHIRPathException; import com.ibm.fhir.model.path.function.FHIRPathFunction; import com.ibm.fhir.model.resource.Resource; -import com.ibm.fhir.model.type.Decimal; import com.ibm.fhir.model.type.Element; -import com.ibm.fhir.model.type.Quantity; public class FHIRPathEvaluator { public static boolean DEBUG = false; @@ -115,7 +120,7 @@ private static ExpressionContext getExpressionContext(String expr) { } private static ExpressionContext compile(String expr) { - FHIRPathLexer lexer = new FHIRPathLexer(new ANTLRInputStream(expr)); + FHIRPathLexer lexer = new FHIRPathLexer(CharStreams.fromString(expr)); CommonTokenStream tokens = new CommonTokenStream(lexer); FHIRPathParser parser = new FHIRPathParser(tokens); return parser.expression(); @@ -351,10 +356,7 @@ private Collection where(List arguments) { } return result; } - - /** - * expression '[' expression ']' - */ + @Override public Collection visitIndexerExpression(FHIRPathParser.IndexerExpressionContext ctx) { debug(ctx); @@ -375,9 +377,6 @@ public Collection visitIndexerExpression(FHIRPathParser.IndexerExp return result; } - /** - * ('+' | '-') expression - */ @Override public Collection visitPolarityExpression(FHIRPathParser.PolarityExpressionContext ctx) { debug(ctx); @@ -392,7 +391,7 @@ public Collection visitPolarityExpression(FHIRPathParser.PolarityE Collection result = empty(); - FHIRPathPrimitiveValue value = getPrimitiveValue(nodes); + FHIRPathSystemValue value = getSystemValue(nodes); String polarity = ctx.getChild(0).getText(); if (value.isNumberValue()) { @@ -410,9 +409,6 @@ public Collection visitPolarityExpression(FHIRPathParser.PolarityE return result; } - /** - * expression ('+' | '-' | '&') expression - */ @Override public Collection visitAdditiveExpression(FHIRPathParser.AdditiveExpressionContext ctx) { debug(ctx); @@ -425,10 +421,9 @@ public Collection visitAdditiveExpression(FHIRPathParser.AdditiveE String operator = ctx.getChild(1).getText(); - if (hasPrimitiveValue(left) && hasPrimitiveValue(right)) { - FHIRPathPrimitiveValue leftValue = getPrimitiveValue(left); - FHIRPathPrimitiveValue rightValue = getPrimitiveValue(right); - + if (hasSystemValue(left) && hasSystemValue(right)) { + FHIRPathSystemValue leftValue = getSystemValue(left); + FHIRPathSystemValue rightValue = getSystemValue(right); if (leftValue.isNumberValue() && rightValue.isNumberValue()) { switch (operator) { case "+": @@ -442,105 +437,61 @@ public Collection visitAdditiveExpression(FHIRPathParser.AdditiveE // concatenation result = singleton(leftValue.asStringValue().concat(rightValue.asStringValue())); } - } else if (((hasPrimitiveValue(left) && right.isEmpty()) || (left.isEmpty() && hasPrimitiveValue(right))) && "&".equals(operator)) { + } else if (((hasSystemValue(left) && right.isEmpty()) || (left.isEmpty() && hasSystemValue(right))) && "&".equals(operator)) { // concatenation where an empty collection is treated as an empty string - if (hasPrimitiveValue(left) && right.isEmpty()) { - FHIRPathPrimitiveValue leftValue = getPrimitiveValue(left); + if (hasSystemValue(left) && right.isEmpty()) { + FHIRPathSystemValue leftValue = getSystemValue(left); if (leftValue.isStringValue()) { result = singleton(leftValue.asStringValue().concat(EMPTY_STRING)); } - } else if (left.isEmpty() && hasPrimitiveValue(right)) { - FHIRPathPrimitiveValue rightValue = getPrimitiveValue(right); + } else if (left.isEmpty() && hasSystemValue(right)) { + FHIRPathSystemValue rightValue = getSystemValue(right); if (rightValue.isStringValue()) { result = singleton(EMPTY_STRING.concat(rightValue.asStringValue())); } } else if (left.isEmpty() && right.isEmpty()) { result = singleton(EMPTY_STRING); } - } else if (isSingleton(left) && isSingleton(right)) { - FHIRPathNode leftNode = getSingleton(left); - FHIRPathNode rightNode = getSingleton(right); - - if (leftNode instanceof FHIRPathQuantityNode && rightNode instanceof FHIRPathQuantityNode) { - FHIRPathQuantityNode leftQuantity = (FHIRPathQuantityNode) leftNode; - FHIRPathQuantityNode rightQuantity = (FHIRPathQuantityNode) rightNode; - - if (hasValueAndUnit(leftQuantity) && hasValueAndUnit(rightQuantity) && - // units are the same - leftQuantity.getQuantityUnit().equals(rightQuantity.getQuantityUnit())) { - switch (operator) { - case "+": - result = singleton(leftQuantity.add(rightQuantity)); - break; - case "-": - result = singleton(leftQuantity.subtract(rightQuantity)); - break; - } - } - } else if ((leftNode instanceof FHIRPathDateTimeValue && rightNode instanceof FHIRPathQuantityNode) || - (leftNode instanceof FHIRPathQuantityNode && rightNode instanceof FHIRPathDateTimeValue)) { - - FHIRPathDateTimeValue dateTimeValue; - if (leftNode instanceof FHIRPathDateTimeValue) { - dateTimeValue = (FHIRPathDateTimeValue) leftNode; - } else { - dateTimeValue = (FHIRPathDateTimeValue) rightNode; - } - - FHIRPathQuantityNode quantityNode; - if (leftNode instanceof FHIRPathQuantityNode) { - quantityNode = (FHIRPathQuantityNode) leftNode; - } else { - quantityNode = (FHIRPathQuantityNode) rightNode; - } - - if (hasValueAndUnit(quantityNode)) { - switch (operator) { - case "+": - result = singleton(dateTimeValue.add(quantityNode)); - break; - case "-": - result = singleton(dateTimeValue.subtract(quantityNode)); - break; - } - } - } else if ((leftNode instanceof FHIRPathTimeValue && rightNode instanceof FHIRPathQuantityNode) || - (leftNode instanceof FHIRPathQuantityNode && rightNode instanceof FHIRPathTimeValue)) { - - FHIRPathTimeValue timeValue; - if (leftNode instanceof FHIRPathTimeValue) { - timeValue = (FHIRPathTimeValue) leftNode; - } else { - timeValue = (FHIRPathTimeValue) rightNode; - } - - FHIRPathQuantityNode quantityNode; - if (leftNode instanceof FHIRPathQuantityNode) { - quantityNode = (FHIRPathQuantityNode) leftNode; - } else { - quantityNode = (FHIRPathQuantityNode) rightNode; - } - - if (hasValueAndUnit(quantityNode)) { - switch (operator) { - case "+": - result = singleton(timeValue.add(quantityNode)); - break; - case "-": - result = singleton(timeValue.subtract(quantityNode)); - break; - } - } + } else if (hasQuantityValue(left) && hasQuantityValue(right)) { + FHIRPathQuantityValue leftValue = getQuantityValue(left); + FHIRPathQuantityValue rightValue = getQuantityValue(right); + switch (operator) { + case "+": + result = singleton(leftValue.add(rightValue)); + break; + case "-": + result = singleton(leftValue.subtract(rightValue)); + break; + } + } else if ((hasTemporalValue(left) && hasQuantityValue(right)) || + (hasQuantityValue(left) && hasTemporalValue(right))) { + FHIRPathTemporalValue temporalValue = hasTemporalValue(left) ? getTemporalValue(left) : getTemporalValue(right); + FHIRPathQuantityValue quantityValue = hasQuantityValue(left) ? getQuantityValue(left) : getQuantityValue(right); + switch (operator) { + case "+": + result = singleton(temporalValue.add(quantityValue)); + break; + case "-": + result = singleton(temporalValue.subtract(quantityValue)); + break; + } + } else if (hasQuantityNode(left) && hasQuantityNode(right)) { + FHIRPathQuantityNode leftNode = getQuantityNode(left); + FHIRPathQuantityNode rightNode = getQuantityNode(right); + switch(operator) { + case "+": + result = singleton(leftNode.add(rightNode)); + break; + case "-": + result = singleton(leftNode.subtract(rightNode)); + break; } } indentLevel--; return result; } - - /** - * expression ('*' | '/' | 'div' | 'mod') expression - */ + @Override public Collection visitMultiplicativeExpression(FHIRPathParser.MultiplicativeExpressionContext ctx) { debug(ctx); @@ -549,15 +500,15 @@ public Collection visitMultiplicativeExpression(FHIRPathParser.Mul Collection left = visit(ctx.expression(0)); Collection right = visit(ctx.expression(1)); - if (!hasPrimitiveValue(left) || !hasPrimitiveValue(right)) { + if (!hasSystemValue(left) || !hasSystemValue(right)) { indentLevel--; return empty(); } Collection result = empty(); - FHIRPathPrimitiveValue leftValue = getPrimitiveValue(left); - FHIRPathPrimitiveValue rightValue = getPrimitiveValue(right); + FHIRPathSystemValue leftValue = getSystemValue(left); + FHIRPathSystemValue rightValue = getSystemValue(right); String operator = ctx.getChild(1).getText(); @@ -586,10 +537,7 @@ public Collection visitMultiplicativeExpression(FHIRPathParser.Mul indentLevel--; return result; } - - /** - * expression '|' expression - */ + @Override public Collection visitUnionExpression(FHIRPathParser.UnionExpressionContext ctx) { debug(ctx); @@ -605,10 +553,7 @@ public Collection visitUnionExpression(FHIRPathParser.UnionExpress // return union; return new ArrayList<>(union); } - - /** - * expression ('or' | 'xor') expression - */ + @Override public Collection visitOrExpression(FHIRPathParser.OrExpressionContext ctx) { debug(ctx); @@ -662,10 +607,7 @@ public Collection visitOrExpression(FHIRPathParser.OrExpressionCon indentLevel--; return result; } - - /** - * expression 'and' expression - */ + @Override public Collection visitAndExpression(FHIRPathParser.AndExpressionContext ctx) { debug(ctx); @@ -704,10 +646,7 @@ public Collection visitAndExpression(FHIRPathParser.AndExpressionC indentLevel--; return result; } - - /** - * expression ('in' | 'contains') expression - */ + @Override public Collection visitMembershipExpression(FHIRPathParser.MembershipExpressionContext ctx) { debug(ctx); @@ -736,10 +675,7 @@ public Collection visitMembershipExpression(FHIRPathParser.Members indentLevel--; return result; } - - /** - * expression ('<=' | '<' | '>' | '>=') expression - */ + @Override public Collection visitInequalityExpression(FHIRPathParser.InequalityExpressionContext ctx) { debug(ctx); @@ -788,10 +724,7 @@ public Collection visitInequalityExpression(FHIRPathParser.Inequal indentLevel--; return result; } - - /** - * expression '.' invocation - */ + @Override public Collection visitInvocationExpression(FHIRPathParser.InvocationExpressionContext ctx) { debug(ctx); @@ -804,10 +737,7 @@ public Collection visitInvocationExpression(FHIRPathParser.Invocat indentLevel--; return result; } - - /** - * expression ('=' | '~' | '!=' | '!~') expression - */ + @Override public Collection visitEqualityExpression(FHIRPathParser.EqualityExpressionContext ctx) { debug(ctx); @@ -844,10 +774,7 @@ public Collection visitEqualityExpression(FHIRPathParser.EqualityE indentLevel--; return result; } - - /** - * expression 'implies' expression - */ + @Override public Collection visitImpliesExpression(FHIRPathParser.ImpliesExpressionContext ctx) { debug(ctx); @@ -870,9 +797,6 @@ public Collection visitImpliesExpression(FHIRPathParser.ImpliesExp return result; } - /** - * term - */ @Override public Collection visitTermExpression(FHIRPathParser.TermExpressionContext ctx) { debug(ctx); @@ -881,10 +805,7 @@ public Collection visitTermExpression(FHIRPathParser.TermExpressio indentLevel--; return result; } - - /** - * expression ('is' | 'as') typeSpecifier - */ + @Override public Collection visitTypeExpression(FHIRPathParser.TypeExpressionContext ctx) { debug(ctx); @@ -925,10 +846,7 @@ public Collection visitTypeExpression(FHIRPathParser.TypeExpressio indentLevel--; return Collections.unmodifiableCollection(result); } - - /** - * invocation - */ + @Override public Collection visitInvocationTerm(FHIRPathParser.InvocationTermContext ctx) { debug(ctx); @@ -937,10 +855,7 @@ public Collection visitInvocationTerm(FHIRPathParser.InvocationTer indentLevel--; return result; } - - /** - * literal - */ + @Override public Collection visitLiteralTerm(FHIRPathParser.LiteralTermContext ctx) { debug(ctx); @@ -949,10 +864,7 @@ public Collection visitLiteralTerm(FHIRPathParser.LiteralTermConte indentLevel--; return result; } - - /** - * externalConstant - */ + @Override public Collection visitExternalConstantTerm(FHIRPathParser.ExternalConstantTermContext ctx) { debug(ctx); @@ -961,10 +873,7 @@ public Collection visitExternalConstantTerm(FHIRPathParser.Externa indentLevel--; return result; } - - /** - * '(' expression ')' - */ + @Override public Collection visitParenthesizedTerm(FHIRPathParser.ParenthesizedTermContext ctx) { debug(ctx); @@ -973,39 +882,27 @@ public Collection visitParenthesizedTerm(FHIRPathParser.Parenthesi indentLevel--; return result; } - - /** - * '{' '}' - */ + @Override public Collection visitNullLiteral(FHIRPathParser.NullLiteralContext ctx) { debug(ctx); return empty(); } - - /** - * ('true' | 'false') - */ + @Override public Collection visitBooleanLiteral(FHIRPathParser.BooleanLiteralContext ctx) { debug(ctx); Boolean _boolean = Boolean.valueOf(ctx.getText()); return _boolean ? SINGLETON_TRUE : SINGLETON_FALSE; } - - /** - * '\'' (ESC | .)*? '\'' - */ + @Override public Collection visitStringLiteral(FHIRPathParser.StringLiteralContext ctx) { debug(ctx); String text = ctx.getText(); return singleton(stringValue(text.substring(1, text.length() - 1))); } - - /** - * [0-9]+('.' [0-9]+)? - */ + @Override public Collection visitNumberLiteral(FHIRPathParser.NumberLiteralContext ctx) { debug(ctx); @@ -1018,40 +915,25 @@ public Collection visitNumberLiteral(FHIRPathParser.NumberLiteralC return singleton(decimalValue(decimal)); } } - - /** - * '@' - * [0-9][0-9][0-9][0-9] // year - * ( - * '-'[0-9][0-9] // month - * ( - * '-'[0-9][0-9] // day - * ( - * 'T' TIMEFORMAT - * )? - * )? - * )? - * 'Z'? // UTC specifier - */ + + @Override + public Collection visitDateLiteral(FHIRPathParser.DateLiteralContext ctx) { + debug(ctx); + return singleton(FHIRPathDateValue.dateValue(ctx.getText().substring(1))); + } + @Override public Collection visitDateTimeLiteral(FHIRPathParser.DateTimeLiteralContext ctx) { debug(ctx); return singleton(FHIRPathDateTimeValue.dateTimeValue(ctx.getText().substring(1))); } - - /** - * [0-9][0-9] (':'[0-9][0-9] (':'[0-9][0-9] ('.'[0-9]+)?)?)? - * ('Z' | ('+' | '-') [0-9][0-9]':'[0-9][0-9])? // timezone - */ + @Override public Collection visitTimeLiteral(FHIRPathParser.TimeLiteralContext ctx) { debug(ctx); return singleton(FHIRPathTimeValue.timeValue(ctx.getText().substring(1))); } - - /** - * NUMBER unit? - */ + @Override public Collection visitQuantityLiteral(FHIRPathParser.QuantityLiteralContext ctx) { debug(ctx); @@ -1060,10 +942,7 @@ public Collection visitQuantityLiteral(FHIRPathParser.QuantityLite indentLevel--; return result; } - - /** - * '%' identifier - */ + @Override public Collection visitExternalConstant(FHIRPathParser.ExternalConstantContext ctx) { debug(ctx); @@ -1072,10 +951,7 @@ public Collection visitExternalConstant(FHIRPathParser.ExternalCon indentLevel--; return evaluationContext.getExternalConstant(identifier); } - - /** - * identifier - */ + @Override public Collection visitMemberInvocation(FHIRPathParser.MemberInvocationContext ctx) { debug(ctx); @@ -1101,9 +977,6 @@ public Collection visitMemberInvocation(FHIRPathParser.MemberInvoc return result; } - /** - * function - */ @Override public Collection visitFunctionInvocation(FHIRPathParser.FunctionInvocationContext ctx) { debug(ctx); @@ -1112,19 +985,13 @@ public Collection visitFunctionInvocation(FHIRPathParser.FunctionI indentLevel--; return result; } - - /** - * '$this' - */ + @Override public Collection visitThisInvocation(FHIRPathParser.ThisInvocationContext ctx) { debug(ctx); return getCurrentContext(); } - - /** - * '$index' - */ + @Override public Collection visitIndexInvocation(FHIRPathParser.IndexInvocationContext ctx) { debug(ctx); @@ -1133,10 +1000,7 @@ public Collection visitIndexInvocation(FHIRPathParser.IndexInvocat indentLevel--; return result; } - - /** - * '$total' - */ + @Override public Collection visitTotalInvocation(FHIRPathParser.TotalInvocationContext ctx) { debug(ctx); @@ -1146,9 +1010,6 @@ public Collection visitTotalInvocation(FHIRPathParser.TotalInvocat return result; } - /** - * identifier '(' paramList? ')' - */ @Override public Collection visitFunction(FHIRPathParser.FunctionContext ctx) { debug(ctx); @@ -1229,14 +1090,8 @@ public Collection visitQuantity(FHIRPathParser.QuantityContext ctx String number = ctx.NUMBER().getText(); String text = ctx.unit().getText(); String unit = text.substring(1, text.length() - 1); - - Quantity quantity = Quantity.builder() - .value(Decimal.of(number)) - .unit(string(unit)) - .build(); - indentLevel--; - return singleton(FHIRPathQuantityNode.builder(quantity).build()); + return singleton(FHIRPathQuantityValue.quantityValue(new BigDecimal(number), unit)); } @Override diff --git a/fhir-model/src/main/java/com/ibm/fhir/model/path/function/AllFalseFunction.java b/fhir-model/src/main/java/com/ibm/fhir/model/path/function/AllFalseFunction.java index 4f344e258ca..68e5426c8fd 100644 --- a/fhir-model/src/main/java/com/ibm/fhir/model/path/function/AllFalseFunction.java +++ b/fhir-model/src/main/java/com/ibm/fhir/model/path/function/AllFalseFunction.java @@ -33,9 +33,9 @@ public int getMaxArity() { @Override public Collection apply(EvaluationContext evaluationContext, Collection context, List> arguments) { - return context.stream().allMatch(node -> node.isPrimitiveValue() && - node.asPrimitiveValue().isBooleanValue() && - node.asPrimitiveValue().asBooleanValue().isFalse()) ? + return context.stream().allMatch(node -> node.isSystemValue() && + node.asSystemValue().isBooleanValue() && + node.asSystemValue().asBooleanValue().isFalse()) ? SINGLETON_TRUE : SINGLETON_FALSE; } } diff --git a/fhir-model/src/main/java/com/ibm/fhir/model/path/function/AllTrueFunction.java b/fhir-model/src/main/java/com/ibm/fhir/model/path/function/AllTrueFunction.java index 91239c43b97..59f138baa82 100644 --- a/fhir-model/src/main/java/com/ibm/fhir/model/path/function/AllTrueFunction.java +++ b/fhir-model/src/main/java/com/ibm/fhir/model/path/function/AllTrueFunction.java @@ -33,9 +33,9 @@ public int getMaxArity() { @Override public Collection apply(EvaluationContext evaluationContext, Collection context, List> arguments) { - return context.stream().allMatch(node -> node.isPrimitiveValue() && - node.asPrimitiveValue().isBooleanValue() && - node.asPrimitiveValue().asBooleanValue().isTrue()) ? + return context.stream().allMatch(node -> node.isSystemValue() && + node.asSystemValue().isBooleanValue() && + node.asSystemValue().asBooleanValue().isTrue()) ? SINGLETON_TRUE : SINGLETON_FALSE; } } diff --git a/fhir-model/src/main/java/com/ibm/fhir/model/path/function/AnyFalseFunction.java b/fhir-model/src/main/java/com/ibm/fhir/model/path/function/AnyFalseFunction.java index e0a18de0573..5576daef489 100644 --- a/fhir-model/src/main/java/com/ibm/fhir/model/path/function/AnyFalseFunction.java +++ b/fhir-model/src/main/java/com/ibm/fhir/model/path/function/AnyFalseFunction.java @@ -33,9 +33,9 @@ public int getMaxArity() { @Override public Collection apply(EvaluationContext evaluationContext, Collection context, List> arguments) { - return context.stream().anyMatch(node -> node.isPrimitiveValue() && - node.asPrimitiveValue().isBooleanValue() && - node.asPrimitiveValue().asBooleanValue().isFalse()) ? + return context.stream().anyMatch(node -> node.isSystemValue() && + node.asSystemValue().isBooleanValue() && + node.asSystemValue().asBooleanValue().isFalse()) ? SINGLETON_TRUE : SINGLETON_FALSE; } } diff --git a/fhir-model/src/main/java/com/ibm/fhir/model/path/function/AnyTrueFunction.java b/fhir-model/src/main/java/com/ibm/fhir/model/path/function/AnyTrueFunction.java index 01c71f9680b..137e856a3f0 100644 --- a/fhir-model/src/main/java/com/ibm/fhir/model/path/function/AnyTrueFunction.java +++ b/fhir-model/src/main/java/com/ibm/fhir/model/path/function/AnyTrueFunction.java @@ -33,9 +33,9 @@ public int getMaxArity() { @Override public Collection apply(EvaluationContext evaluationContext, Collection context, List> arguments) { - return context.stream().anyMatch(node -> node.isPrimitiveValue() && - node.asPrimitiveValue().isBooleanValue() && - node.asPrimitiveValue().asBooleanValue().isTrue()) ? + return context.stream().anyMatch(node -> node.isSystemValue() && + node.asSystemValue().isBooleanValue() && + node.asSystemValue().asBooleanValue().isTrue()) ? SINGLETON_TRUE : SINGLETON_FALSE; } } diff --git a/fhir-model/src/main/java/com/ibm/fhir/model/path/function/ConformsToFunction.java b/fhir-model/src/main/java/com/ibm/fhir/model/path/function/ConformsToFunction.java index 01098bbed2a..47295b92566 100644 --- a/fhir-model/src/main/java/com/ibm/fhir/model/path/function/ConformsToFunction.java +++ b/fhir-model/src/main/java/com/ibm/fhir/model/path/function/ConformsToFunction.java @@ -6,6 +6,14 @@ package com.ibm.fhir.model.path.function; +import static com.ibm.fhir.model.path.evaluator.FHIRPathEvaluator.SINGLETON_TRUE; + +import java.util.Collection; +import java.util.List; + +import com.ibm.fhir.model.path.FHIRPathNode; +import com.ibm.fhir.model.path.evaluator.FHIRPathEvaluator.EvaluationContext; + public class ConformsToFunction extends FHIRPathAbstractFunction { @Override public String getName() { @@ -21,4 +29,9 @@ public int getMinArity() { public int getMaxArity() { return 1; } + + @Override + public Collection apply(EvaluationContext evaluationContext, Collection context, List> arguments) { + return SINGLETON_TRUE; + } } diff --git a/fhir-model/src/main/java/com/ibm/fhir/model/path/function/ExtensionFunction.java b/fhir-model/src/main/java/com/ibm/fhir/model/path/function/ExtensionFunction.java index 630723fedeb..b8eaabc026b 100644 --- a/fhir-model/src/main/java/com/ibm/fhir/model/path/function/ExtensionFunction.java +++ b/fhir-model/src/main/java/com/ibm/fhir/model/path/function/ExtensionFunction.java @@ -6,6 +6,17 @@ package com.ibm.fhir.model.path.function; +import static com.ibm.fhir.model.path.util.FHIRPathUtil.getStringValue; +import static com.ibm.fhir.model.path.util.FHIRPathUtil.hasStringValue; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import com.ibm.fhir.model.path.FHIRPathNode; +import com.ibm.fhir.model.path.evaluator.FHIRPathEvaluator.EvaluationContext; +import com.ibm.fhir.model.type.Extension; + public class ExtensionFunction extends FHIRPathAbstractFunction { @Override public String getName() { @@ -21,4 +32,21 @@ public int getMinArity() { public int getMaxArity() { return 1; } + + @Override + public Collection apply(EvaluationContext evaluationContext, Collection context, List> arguments) { + List result = new ArrayList<>(); + if (hasStringValue(arguments.get(0))) { + String url = getStringValue(arguments.get(0)).string(); + for (FHIRPathNode node : context) { + if (node.isElementNode() && node.asElementNode().element().is(Extension.class)) { + Extension extension = node.asElementNode().element().as(Extension.class); + if (extension.getUrl().equals(url)) { + result.add(node); + } + } + } + } + return result; + } } diff --git a/fhir-model/src/main/java/com/ibm/fhir/model/path/function/MemberOfFunction.java b/fhir-model/src/main/java/com/ibm/fhir/model/path/function/MemberOfFunction.java index 9dae1c3a6b3..39ba9f6b14f 100644 --- a/fhir-model/src/main/java/com/ibm/fhir/model/path/function/MemberOfFunction.java +++ b/fhir-model/src/main/java/com/ibm/fhir/model/path/function/MemberOfFunction.java @@ -6,6 +6,14 @@ package com.ibm.fhir.model.path.function; +import static com.ibm.fhir.model.path.evaluator.FHIRPathEvaluator.SINGLETON_TRUE; + +import java.util.Collection; +import java.util.List; + +import com.ibm.fhir.model.path.FHIRPathNode; +import com.ibm.fhir.model.path.evaluator.FHIRPathEvaluator.EvaluationContext; + public class MemberOfFunction extends FHIRPathAbstractFunction { @Override public String getName() { @@ -21,4 +29,9 @@ public int getMinArity() { public int getMaxArity() { return 1; } + + @Override + public Collection apply(EvaluationContext evaluationContext, Collection context, List> arguments) { + return SINGLETON_TRUE; + } } diff --git a/fhir-model/src/main/java/com/ibm/fhir/model/path/function/ToIntegerFunction.java b/fhir-model/src/main/java/com/ibm/fhir/model/path/function/ToIntegerFunction.java index d9ff617cd36..5e19f856c31 100644 --- a/fhir-model/src/main/java/com/ibm/fhir/model/path/function/ToIntegerFunction.java +++ b/fhir-model/src/main/java/com/ibm/fhir/model/path/function/ToIntegerFunction.java @@ -8,15 +8,15 @@ import static com.ibm.fhir.model.path.FHIRPathIntegerValue.integerValue; import static com.ibm.fhir.model.path.util.FHIRPathUtil.empty; -import static com.ibm.fhir.model.path.util.FHIRPathUtil.getPrimitiveValue; -import static com.ibm.fhir.model.path.util.FHIRPathUtil.hasPrimitiveValue; +import static com.ibm.fhir.model.path.util.FHIRPathUtil.getSystemValue; +import static com.ibm.fhir.model.path.util.FHIRPathUtil.hasSystemValue; import static com.ibm.fhir.model.path.util.FHIRPathUtil.singleton; import java.util.Collection; import java.util.List; import com.ibm.fhir.model.path.FHIRPathNode; -import com.ibm.fhir.model.path.FHIRPathPrimitiveValue; +import com.ibm.fhir.model.path.FHIRPathSystemValue; import com.ibm.fhir.model.path.evaluator.FHIRPathEvaluator.EvaluationContext; public class ToIntegerFunction extends FHIRPathAbstractFunction { @@ -37,10 +37,10 @@ public int getMaxArity() { @Override public Collection apply(EvaluationContext evaluationContext, Collection context, List> arguments) { - if (!hasPrimitiveValue(context)) { + if (!hasSystemValue(context)) { return empty(); } - FHIRPathPrimitiveValue value = getPrimitiveValue(context); + FHIRPathSystemValue value = getSystemValue(context); if (value.isNumberValue() && value.asNumberValue().isIntegerValue()) { return singleton(value); } diff --git a/fhir-model/src/main/java/com/ibm/fhir/model/path/function/ToStringFunction.java b/fhir-model/src/main/java/com/ibm/fhir/model/path/function/ToStringFunction.java index 4c0cd95dec7..732b47d2cfd 100644 --- a/fhir-model/src/main/java/com/ibm/fhir/model/path/function/ToStringFunction.java +++ b/fhir-model/src/main/java/com/ibm/fhir/model/path/function/ToStringFunction.java @@ -8,9 +8,8 @@ import static com.ibm.fhir.model.path.FHIRPathStringValue.stringValue; import static com.ibm.fhir.model.path.util.FHIRPathUtil.empty; -import static com.ibm.fhir.model.path.util.FHIRPathUtil.getPrimitiveValue; -import static com.ibm.fhir.model.path.util.FHIRPathUtil.getSingleton; -import static com.ibm.fhir.model.path.util.FHIRPathUtil.hasPrimitiveValue; +import static com.ibm.fhir.model.path.util.FHIRPathUtil.getSystemValue; +import static com.ibm.fhir.model.path.util.FHIRPathUtil.hasSystemValue; import static com.ibm.fhir.model.path.util.FHIRPathUtil.isSingleton; import static com.ibm.fhir.model.path.util.FHIRPathUtil.singleton; @@ -18,8 +17,7 @@ import java.util.List; import com.ibm.fhir.model.path.FHIRPathNode; -import com.ibm.fhir.model.path.FHIRPathPrimitiveValue; -import com.ibm.fhir.model.path.FHIRPathQuantityNode; +import com.ibm.fhir.model.path.FHIRPathSystemValue; import com.ibm.fhir.model.path.evaluator.FHIRPathEvaluator.EvaluationContext; public class ToStringFunction extends FHIRPathAbstractFunction { @@ -43,14 +41,10 @@ public Collection apply(EvaluationContext evaluationContext, Colle if (!isSingleton(context)) { return empty(); } - if (hasPrimitiveValue(context)) { - FHIRPathPrimitiveValue value = getPrimitiveValue(context); + if (hasSystemValue(context)) { + FHIRPathSystemValue value = getSystemValue(context); return singleton(stringValue(value.toString())); } - FHIRPathNode node = getSingleton(context); - if (node instanceof FHIRPathQuantityNode) { - return singleton(stringValue(node.toString())); - } return empty(); } } diff --git a/fhir-model/src/main/java/com/ibm/fhir/model/path/util/FHIRPathUtil.java b/fhir-model/src/main/java/com/ibm/fhir/model/path/util/FHIRPathUtil.java index cec5b9d76a0..fbdbf586330 100644 --- a/fhir-model/src/main/java/com/ibm/fhir/model/path/util/FHIRPathUtil.java +++ b/fhir-model/src/main/java/com/ibm/fhir/model/path/util/FHIRPathUtil.java @@ -34,9 +34,11 @@ import com.ibm.fhir.model.path.FHIRPathIntegerValue; import com.ibm.fhir.model.path.FHIRPathNode; import com.ibm.fhir.model.path.FHIRPathNumberValue; -import com.ibm.fhir.model.path.FHIRPathPrimitiveValue; import com.ibm.fhir.model.path.FHIRPathQuantityNode; +import com.ibm.fhir.model.path.FHIRPathQuantityValue; import com.ibm.fhir.model.path.FHIRPathStringValue; +import com.ibm.fhir.model.path.FHIRPathSystemValue; +import com.ibm.fhir.model.path.FHIRPathTemporalValue; import com.ibm.fhir.model.path.FHIRPathType; import com.ibm.fhir.model.path.SimpleTypeInfo; import com.ibm.fhir.model.path.TupleTypeInfo; @@ -89,75 +91,107 @@ public static String delimit(String identifier) { return String.format("`%s`", identifier); } + public static boolean hasQuantityNode(Collection nodes) { + if (isSingleton(nodes)) { + FHIRPathNode node = getSingleton(nodes); + return (node instanceof FHIRPathQuantityNode); + } + return false; + } + + public static FHIRPathQuantityNode getQuantityNode(Collection nodes) { + return getSingleton(nodes).asElementNode().asQuantityNode(); + } + public static BigDecimal getDecimal(Collection nodes) { - return getPrimitiveValue(nodes).asNumberValue().decimal(); + return getSystemValue(nodes).asNumberValue().decimal(); } public static Integer getInteger(Collection nodes) { - return getPrimitiveValue(nodes).asNumberValue().asIntegerValue().integer(); + return getSystemValue(nodes).asNumberValue().asIntegerValue().integer(); } public static String getString(Collection nodes) { - return getPrimitiveValue(nodes).asStringValue().string(); + return getSystemValue(nodes).asStringValue().string(); } public static Boolean getBoolean(Collection nodes) { - return getPrimitiveValue(nodes).asBooleanValue()._boolean(); + return getSystemValue(nodes).asBooleanValue()._boolean(); + } + + public static TemporalAccessor getDate(Collection nodes) { + return getSystemValue(nodes).asTemporalValue().asDateValue().date(); } public static TemporalAccessor getDateTime(Collection nodes) { - return getPrimitiveValue(nodes).asDateTimeValue().dateTime(); + return getSystemValue(nodes).asTemporalValue().asDateTimeValue().dateTime(); } public static TemporalAccessor getTime(Collection nodes) { - return getPrimitiveValue(nodes).asTimeValue().time(); + return getSystemValue(nodes).asTemporalValue().asTimeValue().time(); } - public static boolean hasPrimitiveValue(Collection nodes) { + public static boolean hasSystemValue(Collection nodes) { if (isSingleton(nodes)) { FHIRPathNode node = getSingleton(nodes); - return (node instanceof FHIRPathPrimitiveValue) || node.hasValue(); + return (node instanceof FHIRPathSystemValue) || node.hasValue(); } return false; } - public static FHIRPathPrimitiveValue getPrimitiveValue(Collection nodes) { - if (!hasPrimitiveValue(nodes)) { + public static FHIRPathSystemValue getSystemValue(Collection nodes) { + if (!hasSystemValue(nodes)) { throw new IllegalArgumentException(); } FHIRPathNode node = getSingleton(nodes); - if (node instanceof FHIRPathPrimitiveValue) { - return (FHIRPathPrimitiveValue) node; + if (node instanceof FHIRPathSystemValue) { + return (FHIRPathSystemValue) node; } return node.getValue(); } public static FHIRPathStringValue getStringValue(Collection nodes) { - return getPrimitiveValue(nodes).asStringValue(); + return getSystemValue(nodes).asStringValue(); + } + + public static FHIRPathQuantityValue getQuantityValue(Collection nodes) { + return getSystemValue(nodes).asQuantityValue(); } public static FHIRPathIntegerValue getIntegerValue(Collection nodes) { - return getPrimitiveValue(nodes).asNumberValue().asIntegerValue(); + return getSystemValue(nodes).asNumberValue().asIntegerValue(); } public static FHIRPathNumberValue getNumberValue(Collection nodes) { - return getPrimitiveValue(nodes).asNumberValue(); + return getSystemValue(nodes).asNumberValue(); + } + + public static FHIRPathTemporalValue getTemporalValue(Collection nodes) { + return getSystemValue(nodes).asTemporalValue(); } public static FHIRPathBooleanValue getBooleanValue(Collection nodes) { - return getPrimitiveValue(nodes).asBooleanValue(); + return getSystemValue(nodes).asBooleanValue(); } public static boolean hasBooleanValue(Collection nodes) { - return hasPrimitiveValue(nodes) && getPrimitiveValue(nodes).isBooleanValue(); + return hasSystemValue(nodes) && getSystemValue(nodes).isBooleanValue(); } public static boolean hasNumberValue(Collection nodes) { - return hasPrimitiveValue(nodes) && getPrimitiveValue(nodes).isNumberValue(); + return hasSystemValue(nodes) && getSystemValue(nodes).isNumberValue(); + } + + public static boolean hasTemporalValue(Collection nodes) { + return hasSystemValue(nodes) && getSystemValue(nodes).isTemporalValue(); } public static boolean hasStringValue(Collection nodes) { - return hasPrimitiveValue(nodes) && getPrimitiveValue(nodes).isStringValue(); + return hasSystemValue(nodes) && getSystemValue(nodes).isStringValue(); + } + + public static boolean hasQuantityValue(Collection nodes) { + return hasSystemValue(nodes) && getSystemValue(nodes).isQuantityValue(); } public static boolean evaluatesToBoolean(Collection nodes) { @@ -198,10 +232,6 @@ public static Collection empty() { return emptyList(); } - public static boolean hasValueAndUnit(FHIRPathQuantityNode quantityNode) { - return quantityNode.getQuantityValue() != null && quantityNode.getQuantityUnit() != null; - } - public static TemporalAccessor getTemporalAccessor(Temporal temporal, Class targetType) { if (temporal.getClass().equals(targetType)) { return temporal; @@ -237,12 +267,9 @@ public static Temporal getTemporal(TemporalAccessor temporalAccessor) { throw new IllegalArgumentException(); } - public static TemporalAmount getTemporalAmount(FHIRPathQuantityNode quantityNode) { - if (!hasValueAndUnit(quantityNode)) { - throw new IllegalArgumentException(); - } - int value = quantityNode.getQuantityValue().intValue(); - String unit = quantityNode.getQuantityUnit(); + public static TemporalAmount getTemporalAmount(FHIRPathQuantityValue quantityValue) { + int value = quantityValue.value().intValue(); + String unit = quantityValue.unit(); switch (unit) { case "year": case "years": diff --git a/fhir-model/src/main/java/com/ibm/fhir/model/path/visitor/FHIRPathAbstractNodeVisitor.java b/fhir-model/src/main/java/com/ibm/fhir/model/path/visitor/FHIRPathAbstractNodeVisitor.java deleted file mode 100644 index 8b5328ec47c..00000000000 --- a/fhir-model/src/main/java/com/ibm/fhir/model/path/visitor/FHIRPathAbstractNodeVisitor.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019 - * - * SPDX-License-Identifier: Apache-2.0 - */ - -package com.ibm.fhir.model.path.visitor; - -import com.ibm.fhir.model.path.FHIRPathBooleanValue; -import com.ibm.fhir.model.path.FHIRPathDateTimeValue; -import com.ibm.fhir.model.path.FHIRPathDecimalValue; -import com.ibm.fhir.model.path.FHIRPathElementNode; -import com.ibm.fhir.model.path.FHIRPathIntegerValue; -import com.ibm.fhir.model.path.FHIRPathNode; -import com.ibm.fhir.model.path.FHIRPathQuantityNode; -import com.ibm.fhir.model.path.FHIRPathResourceNode; -import com.ibm.fhir.model.path.FHIRPathStringValue; -import com.ibm.fhir.model.path.FHIRPathTimeValue; -import com.ibm.fhir.model.path.FHIRPathTypeInfoNode; - -public abstract class FHIRPathAbstractNodeVisitor implements FHIRPathNodeVisitor { - // called by template methods - protected abstract void doVisit(T param, FHIRPathBooleanValue value); - protected abstract void doVisit(T param, FHIRPathDateTimeValue value); - protected abstract void doVisit(T param, FHIRPathDecimalValue value); - protected abstract void doVisit(T param, FHIRPathElementNode node); - protected abstract void doVisit(T param, FHIRPathIntegerValue value); - protected abstract void doVisit(T param, FHIRPathQuantityNode node); - protected abstract void doVisit(T param, FHIRPathResourceNode node); - protected abstract void doVisit(T param, FHIRPathStringValue value); - protected abstract void doVisit(T param, FHIRPathTimeValue value); - protected abstract void doVisit(T param, FHIRPathTypeInfoNode node); - - @Override - public final void visit(T param, FHIRPathBooleanValue value) { - doVisit(param, value); - } - - @Override - public final void visit(T param, FHIRPathDateTimeValue value) { - doVisit(param, value); - } - - @Override - public final void visit(T param, FHIRPathDecimalValue value) { - doVisit(param, value); - } - - @Override - public final void visit(T param, FHIRPathElementNode node) { - doVisit(param, node); - visitChildren(param, node); - } - - @Override - public final void visit(T param, FHIRPathIntegerValue value) { - doVisit(param, value); - } - - @Override - public final void visit(T param, FHIRPathQuantityNode node) { - doVisit(param, node); - visitChildren(param, node); - } - - @Override - public final void visit(T param, FHIRPathResourceNode node) { - doVisit(param, node); - visitChildren(param, node); - } - - @Override - public final void visit(T param, FHIRPathStringValue value) { - doVisit(param, value); - } - - @Override - public final void visit(T param, FHIRPathTimeValue value) { - doVisit(param, value); - } - - @Override - public final void visit(T param, FHIRPathTypeInfoNode node) { - doVisit(param, node); - } - - private void visitChildren(T param, FHIRPathNode node) { - for (FHIRPathNode child : node.children()) { - child.accept(param, this); - } - } -} \ No newline at end of file diff --git a/fhir-model/src/main/java/com/ibm/fhir/model/path/visitor/FHIRPathDefaultNodeVisitor.java b/fhir-model/src/main/java/com/ibm/fhir/model/path/visitor/FHIRPathDefaultNodeVisitor.java new file mode 100644 index 00000000000..8b7d1b8307b --- /dev/null +++ b/fhir-model/src/main/java/com/ibm/fhir/model/path/visitor/FHIRPathDefaultNodeVisitor.java @@ -0,0 +1,99 @@ +/* + * (C) Copyright IBM Corp. 2019 + * + * SPDX-License-Identifier: Apache-2.0 + */ + +package com.ibm.fhir.model.path.visitor; + +import com.ibm.fhir.model.path.FHIRPathBooleanValue; +import com.ibm.fhir.model.path.FHIRPathDateTimeValue; +import com.ibm.fhir.model.path.FHIRPathDateValue; +import com.ibm.fhir.model.path.FHIRPathDecimalValue; +import com.ibm.fhir.model.path.FHIRPathElementNode; +import com.ibm.fhir.model.path.FHIRPathIntegerValue; +import com.ibm.fhir.model.path.FHIRPathNode; +import com.ibm.fhir.model.path.FHIRPathQuantityNode; +import com.ibm.fhir.model.path.FHIRPathQuantityValue; +import com.ibm.fhir.model.path.FHIRPathResourceNode; +import com.ibm.fhir.model.path.FHIRPathStringValue; +import com.ibm.fhir.model.path.FHIRPathTimeValue; +import com.ibm.fhir.model.path.FHIRPathTypeInfoNode; + +public class FHIRPathDefaultNodeVisitor implements FHIRPathNodeVisitor { + protected void doVisit(FHIRPathResourceNode node) { + // do nothing + } + + protected void doVisit(FHIRPathElementNode node) { + // do nothing + } + + protected void visitChildren(FHIRPathNode node) { + for (FHIRPathNode child : node.children()) { + child.accept(this); + } + } + + @Override + public void visit(FHIRPathBooleanValue value) { + // do nothing + } + + @Override + public void visit(FHIRPathDateValue value) { + // do nothing + } + + @Override + public void visit(FHIRPathDateTimeValue value) { + // do nothing + } + + @Override + public void visit(FHIRPathDecimalValue value) { + // do nothing + } + + @Override + public final void visit(FHIRPathElementNode node) { + doVisit(node); + visitChildren(node); + } + + @Override + public void visit(FHIRPathIntegerValue value) { + // do nothing + } + + @Override + public void visit(FHIRPathQuantityValue value) { + // do nothing + } + + @Override + public void visit(FHIRPathQuantityNode node) { + visit((FHIRPathElementNode) node); + } + + @Override + public final void visit(FHIRPathResourceNode node) { + doVisit(node); + visitChildren(node); + } + + @Override + public void visit(FHIRPathStringValue value) { + // do nothing + } + + @Override + public void visit(FHIRPathTimeValue value) { + // do nothing + } + + @Override + public void visit(FHIRPathTypeInfoNode node) { + // do nothing + } +} \ No newline at end of file diff --git a/fhir-model/src/main/java/com/ibm/fhir/model/path/visitor/FHIRPathNodeVisitor.java b/fhir-model/src/main/java/com/ibm/fhir/model/path/visitor/FHIRPathNodeVisitor.java index 57a31fbcf25..f8fe770b69f 100644 --- a/fhir-model/src/main/java/com/ibm/fhir/model/path/visitor/FHIRPathNodeVisitor.java +++ b/fhir-model/src/main/java/com/ibm/fhir/model/path/visitor/FHIRPathNodeVisitor.java @@ -8,24 +8,28 @@ import com.ibm.fhir.model.path.FHIRPathBooleanValue; import com.ibm.fhir.model.path.FHIRPathDateTimeValue; +import com.ibm.fhir.model.path.FHIRPathDateValue; import com.ibm.fhir.model.path.FHIRPathDecimalValue; import com.ibm.fhir.model.path.FHIRPathElementNode; import com.ibm.fhir.model.path.FHIRPathIntegerValue; import com.ibm.fhir.model.path.FHIRPathQuantityNode; +import com.ibm.fhir.model.path.FHIRPathQuantityValue; import com.ibm.fhir.model.path.FHIRPathResourceNode; import com.ibm.fhir.model.path.FHIRPathStringValue; import com.ibm.fhir.model.path.FHIRPathTimeValue; import com.ibm.fhir.model.path.FHIRPathTypeInfoNode; -public interface FHIRPathNodeVisitor { - void visit(T param, FHIRPathBooleanValue value); - void visit(T param, FHIRPathDateTimeValue value); - void visit(T param, FHIRPathDecimalValue value); - void visit(T param, FHIRPathElementNode node); - void visit(T param, FHIRPathIntegerValue value); - void visit(T param, FHIRPathQuantityNode node); - void visit(T param, FHIRPathResourceNode node); - void visit(T param, FHIRPathStringValue value); - void visit(T param, FHIRPathTimeValue value); - void visit(T param, FHIRPathTypeInfoNode node); +public interface FHIRPathNodeVisitor { + void visit(FHIRPathBooleanValue value); + void visit(FHIRPathDateValue value); + void visit(FHIRPathDateTimeValue value); + void visit(FHIRPathDecimalValue value); + void visit(FHIRPathElementNode node); + void visit(FHIRPathIntegerValue value); + void visit(FHIRPathQuantityNode node); + void visit(FHIRPathQuantityValue value); + void visit(FHIRPathResourceNode node); + void visit(FHIRPathStringValue value); + void visit(FHIRPathTimeValue value); + void visit(FHIRPathTypeInfoNode node); } \ No newline at end of file diff --git a/fhir-model/src/main/java/com/ibm/fhir/model/path/visitor/FHIRPathNodeVisitorAdapter.java b/fhir-model/src/main/java/com/ibm/fhir/model/path/visitor/FHIRPathNodeVisitorAdapter.java deleted file mode 100644 index 5b8db65ff39..00000000000 --- a/fhir-model/src/main/java/com/ibm/fhir/model/path/visitor/FHIRPathNodeVisitorAdapter.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019 - * - * SPDX-License-Identifier: Apache-2.0 - */ - -package com.ibm.fhir.model.path.visitor; - -import com.ibm.fhir.model.path.FHIRPathBooleanValue; -import com.ibm.fhir.model.path.FHIRPathDateTimeValue; -import com.ibm.fhir.model.path.FHIRPathDecimalValue; -import com.ibm.fhir.model.path.FHIRPathElementNode; -import com.ibm.fhir.model.path.FHIRPathIntegerValue; -import com.ibm.fhir.model.path.FHIRPathQuantityNode; -import com.ibm.fhir.model.path.FHIRPathResourceNode; -import com.ibm.fhir.model.path.FHIRPathStringValue; -import com.ibm.fhir.model.path.FHIRPathTimeValue; -import com.ibm.fhir.model.path.FHIRPathTypeInfoNode; - -public class FHIRPathNodeVisitorAdapter extends FHIRPathAbstractNodeVisitor { - @Override - protected void doVisit(T param, FHIRPathBooleanValue value) { - // do nothing - } - - @Override - protected void doVisit(T param, FHIRPathDateTimeValue value) { - // do nothing - } - - @Override - protected void doVisit(T param, FHIRPathDecimalValue value) { - // do nothing - } - - @Override - protected void doVisit(T param, FHIRPathElementNode node) { - // do nothing - } - - @Override - protected void doVisit(T param, FHIRPathIntegerValue value) { - // do nothing - } - - @Override - protected void doVisit(T param, FHIRPathQuantityNode node) { - // do nothing - } - - @Override - protected void doVisit(T param, FHIRPathResourceNode node) { - // do nothing - } - - @Override - protected void doVisit(T param, FHIRPathStringValue value) { - // do nothing - } - - @Override - protected void doVisit(T param, FHIRPathTimeValue value) { - // do nothing - } - - @Override - protected void doVisit(T param, FHIRPathTypeInfoNode node) { - // do nothing - } -} \ No newline at end of file diff --git a/fhir-model/src/main/java/com/ibm/fhir/model/path/visitor/FHIRPathVoidParameterAbstractNodeVisitor.java b/fhir-model/src/main/java/com/ibm/fhir/model/path/visitor/FHIRPathVoidParameterAbstractNodeVisitor.java deleted file mode 100644 index fbea5ee7605..00000000000 --- a/fhir-model/src/main/java/com/ibm/fhir/model/path/visitor/FHIRPathVoidParameterAbstractNodeVisitor.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019 - * SPDX-License-Identifier: Apache-2.0 - */ -package com.ibm.fhir.model.path.visitor; - -import com.ibm.fhir.model.path.FHIRPathBooleanValue; -import com.ibm.fhir.model.path.FHIRPathDateTimeValue; -import com.ibm.fhir.model.path.FHIRPathDecimalValue; -import com.ibm.fhir.model.path.FHIRPathElementNode; -import com.ibm.fhir.model.path.FHIRPathIntegerValue; -import com.ibm.fhir.model.path.FHIRPathQuantityNode; -import com.ibm.fhir.model.path.FHIRPathResourceNode; -import com.ibm.fhir.model.path.FHIRPathStringValue; -import com.ibm.fhir.model.path.FHIRPathTimeValue; -import com.ibm.fhir.model.path.FHIRPathTypeInfoNode; - -public abstract class FHIRPathVoidParameterAbstractNodeVisitor extends FHIRPathAbstractNodeVisitor { - // called by template methods - protected abstract void doVisit(FHIRPathBooleanValue value); - protected abstract void doVisit(FHIRPathDateTimeValue value); - protected abstract void doVisit(FHIRPathDecimalValue value); - protected abstract void doVisit(FHIRPathElementNode node); - protected abstract void doVisit(FHIRPathIntegerValue value); - protected abstract void doVisit(FHIRPathQuantityNode node); - protected abstract void doVisit(FHIRPathResourceNode node); - protected abstract void doVisit(FHIRPathStringValue value); - protected abstract void doVisit(FHIRPathTimeValue value); - protected abstract void doVisit(FHIRPathTypeInfoNode node); - - @Override - protected final void doVisit(Void param, FHIRPathBooleanValue value) { - doVisit(value); - } - - @Override - protected final void doVisit(Void param, FHIRPathDateTimeValue value) { - doVisit(value); - } - - @Override - protected final void doVisit(Void param, FHIRPathDecimalValue value) { - doVisit(value); - } - - @Override - protected final void doVisit(Void param, FHIRPathElementNode node) { - doVisit(node); - } - - @Override - protected final void doVisit(Void param, FHIRPathIntegerValue value) { - doVisit(value); - } - - @Override - protected final void doVisit(Void param, FHIRPathQuantityNode node) { - doVisit(node); - } - - @Override - protected final void doVisit(Void param, FHIRPathResourceNode node) { - doVisit(node); - } - - @Override - protected final void doVisit(Void param, FHIRPathStringValue value) { - doVisit(value); - } - - @Override - protected final void doVisit(Void param, FHIRPathTimeValue value) { - doVisit(value); - } - - @Override - protected final void doVisit(Void param, FHIRPathTypeInfoNode node) { - doVisit(node); - } -} \ No newline at end of file diff --git a/fhir-model/src/main/java/com/ibm/fhir/model/path/visitor/FHIRPathVoidParameterNodeVisitorAdapter.java b/fhir-model/src/main/java/com/ibm/fhir/model/path/visitor/FHIRPathVoidParameterNodeVisitorAdapter.java deleted file mode 100644 index 448c8614bc2..00000000000 --- a/fhir-model/src/main/java/com/ibm/fhir/model/path/visitor/FHIRPathVoidParameterNodeVisitorAdapter.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * (C) Copyright IBM Corp. 2019 - * SPDX-License-Identifier: Apache-2.0 - */ -package com.ibm.fhir.model.path.visitor; - -import com.ibm.fhir.model.path.FHIRPathBooleanValue; -import com.ibm.fhir.model.path.FHIRPathDateTimeValue; -import com.ibm.fhir.model.path.FHIRPathDecimalValue; -import com.ibm.fhir.model.path.FHIRPathElementNode; -import com.ibm.fhir.model.path.FHIRPathIntegerValue; -import com.ibm.fhir.model.path.FHIRPathQuantityNode; -import com.ibm.fhir.model.path.FHIRPathResourceNode; -import com.ibm.fhir.model.path.FHIRPathStringValue; -import com.ibm.fhir.model.path.FHIRPathTimeValue; -import com.ibm.fhir.model.path.FHIRPathTypeInfoNode; - -public class FHIRPathVoidParameterNodeVisitorAdapter extends FHIRPathVoidParameterAbstractNodeVisitor { - @Override - protected void doVisit(FHIRPathBooleanValue value) { - // do nothing - } - - @Override - protected void doVisit(FHIRPathDateTimeValue value) { - // do nothing - } - - @Override - protected void doVisit(FHIRPathDecimalValue value) { - // do nothing - } - - @Override - protected void doVisit(FHIRPathElementNode node) { - // do nothing - } - - @Override - protected void doVisit(FHIRPathIntegerValue value) { - // do nothing - } - - @Override - protected void doVisit(FHIRPathQuantityNode node) { - // do nothing - } - - @Override - protected void doVisit(FHIRPathResourceNode node) { - // do nothing - } - - @Override - protected void doVisit(FHIRPathStringValue value) { - // do nothing - } - - @Override - protected void doVisit(FHIRPathTimeValue value) { - // do nothing - } - - @Override - protected void doVisit(FHIRPathTypeInfoNode node) { - // do nothing - } -} \ No newline at end of file diff --git a/fhir-model/src/test/java/com/ibm/fhir/model/path/test/FHIRPathNodeVisitorTest.java b/fhir-model/src/test/java/com/ibm/fhir/model/path/test/FHIRPathNodeVisitorTest.java index 460caf56f02..1e9c381cb7d 100644 --- a/fhir-model/src/test/java/com/ibm/fhir/model/path/test/FHIRPathNodeVisitorTest.java +++ b/fhir-model/src/test/java/com/ibm/fhir/model/path/test/FHIRPathNodeVisitorTest.java @@ -22,13 +22,13 @@ import com.ibm.fhir.model.path.FHIRPathDecimalValue; import com.ibm.fhir.model.path.FHIRPathElementNode; import com.ibm.fhir.model.path.FHIRPathIntegerValue; -import com.ibm.fhir.model.path.FHIRPathQuantityNode; +import com.ibm.fhir.model.path.FHIRPathQuantityValue; import com.ibm.fhir.model.path.FHIRPathResourceNode; import com.ibm.fhir.model.path.FHIRPathStringValue; import com.ibm.fhir.model.path.FHIRPathTimeValue; import com.ibm.fhir.model.path.FHIRPathTree; import com.ibm.fhir.model.path.FHIRPathTypeInfoNode; -import com.ibm.fhir.model.path.visitor.FHIRPathAbstractNodeVisitor; +import com.ibm.fhir.model.path.visitor.FHIRPathDefaultNodeVisitor; import com.ibm.fhir.model.resource.Patient; import com.ibm.fhir.model.type.Boolean; import com.ibm.fhir.model.type.Date; @@ -48,7 +48,7 @@ public class FHIRPathNodeVisitorTest { "FHIRPathElementNode: Id", "FHIRPathStringValue: 1", "FHIRPathElementNode: Instant", - "FHIRPathBooleanValue: 2019-08-20T20:09:30.841Z", + "FHIRPathDateTimeValue: 2019-08-20T20:09:30.841Z", "FHIRPathElementNode: Narrative", "FHIRPathElementNode: NarrativeStatus", "FHIRPathStringValue: generated", @@ -62,7 +62,7 @@ public class FHIRPathNodeVisitorTest { "FHIRPathElementNode: String", "FHIRPathStringValue: John", "FHIRPathElementNode: Date", - "FHIRPathBooleanValue: 1980-01-01" + "FHIRPathDateTimeValue: 1980-01-01" ); @BeforeClass @@ -72,61 +72,67 @@ public void setUp() { @Test public void testFHIRPathNodeVisitor() { Patient patient = buildPatient(); - FHIRPathTree tree = FHIRPathTree.tree(patient); - List list = new ArrayList<>(); - tree.getRoot().accept(list, new ListBuildingVisitor()); - Assert.assertEquals(list, EXPECTED); + FHIRPathTree tree = FHIRPathTree.tree(patient); + ListBuildingVisitor visitor = new ListBuildingVisitor(); + tree.getRoot().accept(visitor); + Assert.assertEquals(visitor.getResult(), EXPECTED); } - public static class ListBuildingVisitor extends FHIRPathAbstractNodeVisitor> { + public static class ListBuildingVisitor extends FHIRPathDefaultNodeVisitor { + private List result = new ArrayList<>(); + + public List getResult() { + return result; + } + @Override - protected void doVisit(List param, FHIRPathBooleanValue value) { - param.add("FHIRPathBooleanValue: " + value._boolean()); + public void visit(FHIRPathBooleanValue value) { + result.add("FHIRPathBooleanValue: " + value._boolean()); } @Override - protected void doVisit(List param, FHIRPathDateTimeValue value) { - param.add("FHIRPathBooleanValue: " + value.dateTime()); + public void visit(FHIRPathDateTimeValue value) { + result.add("FHIRPathDateTimeValue: " + value.dateTime()); } @Override - protected void doVisit(List param, FHIRPathDecimalValue value) { - param.add("FHIRPathDecimalValue: " + value.decimal()); + public void visit(FHIRPathDecimalValue value) { + result.add("FHIRPathDecimalValue: " + value.decimal()); } @Override - protected void doVisit(List param, FHIRPathElementNode node) { - param.add("FHIRPathElementNode: " + node.element().getClass().getSimpleName()); + public void doVisit(FHIRPathElementNode node) { + result.add("FHIRPathElementNode: " + node.element().getClass().getSimpleName()); } @Override - protected void doVisit(List param, FHIRPathIntegerValue value) { - param.add("FHIRPathIntegerValue: " + value.integer()); + public void visit(FHIRPathIntegerValue value) { + result.add("FHIRPathIntegerValue: " + value.integer()); } @Override - protected void doVisit(List param, FHIRPathQuantityNode node) { - param.add("FHIRPathQuantityNode: " + node.quantity()); + public void visit(FHIRPathQuantityValue value) { + result.add("FHIRPathQuantityValue: " + value.toString()); } @Override - protected void doVisit(List param, FHIRPathResourceNode node) { - param.add("FHIRPathResourceNode: " + node.resource().getClass().getSimpleName()); + public void doVisit(FHIRPathResourceNode node) { + result.add("FHIRPathResourceNode: " + node.resource().getClass().getSimpleName()); } @Override - protected void doVisit(List param, FHIRPathStringValue value) { - param.add("FHIRPathStringValue: " + value.string()); + public void visit(FHIRPathStringValue value) { + result.add("FHIRPathStringValue: " + value.string()); } @Override - protected void doVisit(List param, FHIRPathTimeValue value) { - param.add("FHIRPathTimeValue: " + value.time()); + public void visit(FHIRPathTimeValue value) { + result.add("FHIRPathTimeValue: " + value.time()); } @Override - protected void doVisit(List param, FHIRPathTypeInfoNode node) { - param.add("FHIRPathTypeInfoNode: " + node.typeInfo()); + public void visit(FHIRPathTypeInfoNode node) { + result.add("FHIRPathTypeInfoNode: " + node.typeInfo()); } } diff --git a/fhir-model/src/test/java/com/ibm/fhir/model/path/test/FHIRPathSpecTest.java b/fhir-model/src/test/java/com/ibm/fhir/model/path/test/FHIRPathSpecTest.java index ac5ace1ed8b..6c340d062fa 100644 --- a/fhir-model/src/test/java/com/ibm/fhir/model/path/test/FHIRPathSpecTest.java +++ b/fhir-model/src/test/java/com/ibm/fhir/model/path/test/FHIRPathSpecTest.java @@ -30,11 +30,10 @@ import org.testng.annotations.DataProvider; import org.testng.annotations.Factory; import org.testng.annotations.Test; - import org.testng.internal.BaseTestMethod; import com.ibm.fhir.model.path.FHIRPathNode; -import com.ibm.fhir.model.path.FHIRPathQuantityNode; +import com.ibm.fhir.model.path.FHIRPathQuantityValue; import com.ibm.fhir.model.path.evaluator.FHIRPathEvaluator; import com.ibm.fhir.model.path.evaluator.FHIRPathEvaluator.EvaluationContext; import com.ibm.fhir.model.path.exception.FHIRPathException; @@ -129,7 +128,7 @@ private void executeTest() throws Exception { assertEquals(getNumberValue(singleton(result)).toString(), expectedOutput.text); break; case "quantity": - assertEquals(result.as(FHIRPathQuantityNode.class).toString(), expectedOutput.text); + assertEquals(result.as(FHIRPathQuantityValue.class).toString(), expectedOutput.text); break; case "string": assertEquals(getStringValue(singleton(result)).toString(), expectedOutput.text); diff --git a/fhir-model/src/test/java/com/ibm/fhir/model/path/test/NodeVisitorTest.java b/fhir-model/src/test/java/com/ibm/fhir/model/path/test/NodeVisitorTest.java index 3c0809245c1..19a815f0ca7 100644 --- a/fhir-model/src/test/java/com/ibm/fhir/model/path/test/NodeVisitorTest.java +++ b/fhir-model/src/test/java/com/ibm/fhir/model/path/test/NodeVisitorTest.java @@ -17,10 +17,9 @@ import com.ibm.fhir.model.format.Format; import com.ibm.fhir.model.parser.FHIRParser; import com.ibm.fhir.model.path.FHIRPathElementNode; -import com.ibm.fhir.model.path.FHIRPathQuantityNode; import com.ibm.fhir.model.path.FHIRPathResourceNode; import com.ibm.fhir.model.path.FHIRPathTree; -import com.ibm.fhir.model.path.visitor.FHIRPathNodeVisitorAdapter; +import com.ibm.fhir.model.path.visitor.FHIRPathDefaultNodeVisitor; import com.ibm.fhir.model.resource.Patient; import com.ibm.fhir.model.resource.Resource; import com.ibm.fhir.model.type.Element; @@ -47,19 +46,14 @@ public void doVisitStart(String elementName, int elementIndex, Element element) List treePaths = new ArrayList<>(); FHIRPathTree tree = FHIRPathTree.tree(patient); - tree.getRoot().accept(new FHIRPathNodeVisitorAdapter() { + tree.getRoot().accept(new FHIRPathDefaultNodeVisitor() { @Override - protected void doVisit(Void param, FHIRPathElementNode node) { + public void doVisit(FHIRPathElementNode node) { treePaths.add(node.path()); } @Override - protected void doVisit(Void param, FHIRPathQuantityNode node) { - treePaths.add(node.path()); - } - - @Override - protected void doVisit(Void param, FHIRPathResourceNode node) { + public void doVisit(FHIRPathResourceNode node) { treePaths.add(node.path()); } }); diff --git a/fhir-persistence-jdbc/src/main/java/com/ibm/fhir/persistence/jdbc/JDBCConstants.java b/fhir-persistence-jdbc/src/main/java/com/ibm/fhir/persistence/jdbc/JDBCConstants.java index 20b0338137c..82998d43626 100644 --- a/fhir-persistence-jdbc/src/main/java/com/ibm/fhir/persistence/jdbc/JDBCConstants.java +++ b/fhir-persistence-jdbc/src/main/java/com/ibm/fhir/persistence/jdbc/JDBCConstants.java @@ -41,6 +41,9 @@ public class JDBCConstants { public static final String ESCAPE_UNDERSCORE = ESCAPE_CHAR + "_"; public static final String ESCAPE_PERCENT = ESCAPE_CHAR + PERCENT_WILDCARD; public static final String ESCAPE_EXPR = " ESCAPE '" + ESCAPE_CHAR + "'"; + public static final String WHEN = " WHEN "; + public static final String THEN = " THEN "; + public static final String END = " END"; /** * Maps Parameter modifiers to SQL operators. diff --git a/fhir-persistence-jdbc/src/main/java/com/ibm/fhir/persistence/jdbc/dao/api/ResourceDAO.java b/fhir-persistence-jdbc/src/main/java/com/ibm/fhir/persistence/jdbc/dao/api/ResourceDAO.java index 1eba8cd9a23..dd7320ad6ad 100644 --- a/fhir-persistence-jdbc/src/main/java/com/ibm/fhir/persistence/jdbc/dao/api/ResourceDAO.java +++ b/fhir-persistence-jdbc/src/main/java/com/ibm/fhir/persistence/jdbc/dao/api/ResourceDAO.java @@ -118,19 +118,18 @@ List search(String sqlSelect) * @throws FHIRPersistenceDataAccessException * @throws FHIRPersistenceDBConnectException */ - List searchForIds(String sqlSelect) - throws FHIRPersistenceDataAccessException, FHIRPersistenceDBConnectException; + List searchForIds(SqlQueryData queryData) throws FHIRPersistenceDataAccessException, FHIRPersistenceDBConnectException; /** * Searches for Resources that contain one of the passed ids. + * @param resourceType - The type of the FHIR Resource * @param resourceIds - A List of resource ids. * @return List - A List of resources matching the the passed list of ids. * @throws FHIRPersistenceDataAccessException * @throws FHIRPersistenceDBConnectException */ - List searchByIds(List resourceIds) - throws FHIRPersistenceDataAccessException, FHIRPersistenceDBConnectException; - + List searchByIds(String resourceType, List resourceIds) throws FHIRPersistenceDataAccessException, FHIRPersistenceDBConnectException; + /** * Executes a count query based on the data contained in the passed SqlQueryData, using it's encapsulated search string and bind variables. * @param queryData - Contains a search string and (optionally) bind variables. @@ -173,27 +172,6 @@ List searchByIds(List resourceIds) * @throws FHIRPersistenceDataAccessException */ Integer readResourceTypeId(String parameterName) throws FHIRPersistenceDBConnectException, FHIRPersistenceDataAccessException; - - /** - * This method supports the execution of a specialized query designed to return Resource ids, based on the contents - * of the passed select statement. - * Note that the first column to be selected MUST be the Resource.id column. - * @param sqlSelect - A select for Resource ids. - * @return - A List of resource ids that satisfy the passed SQL query. - * @throws FHIRPersistenceDataAccessException - * @throws FHIRPersistenceDBConnectException - */ - List searchForIds(SqlQueryData queryData) throws FHIRPersistenceDataAccessException, FHIRPersistenceDBConnectException; - - /** - * Searches for Resources that contain one of the passed ids. - * @param resourceType - The type of the FHIR Resource. - * @param resourceIds - A List of resource ids. - * @return List - A List of resources matching the the passed list of ids. - * @throws FHIRPersistenceDataAccessException - * @throws FHIRPersistenceDBConnectException - */ - List searchByIds(String resourceType, List resourceIds) throws FHIRPersistenceDataAccessException, FHIRPersistenceDBConnectException; /** * Adds a resource type / resource id pair to a candidate collection for population into the ResourceTypesCache. diff --git a/fhir-persistence-jdbc/src/main/java/com/ibm/fhir/persistence/jdbc/dao/impl/ResourceDAOImpl.java b/fhir-persistence-jdbc/src/main/java/com/ibm/fhir/persistence/jdbc/dao/impl/ResourceDAOImpl.java index 4483aa32b4b..9e20cc2106e 100644 --- a/fhir-persistence-jdbc/src/main/java/com/ibm/fhir/persistence/jdbc/dao/impl/ResourceDAOImpl.java +++ b/fhir-persistence-jdbc/src/main/java/com/ibm/fhir/persistence/jdbc/dao/impl/ResourceDAOImpl.java @@ -6,6 +6,8 @@ package com.ibm.fhir.persistence.jdbc.dao.impl; +import static com.ibm.fhir.persistence.jdbc.JDBCConstants.*; + import java.sql.CallableStatement; import java.sql.Connection; import java.sql.PreparedStatement; @@ -90,6 +92,8 @@ public class ResourceDAOImpl extends FHIRDbDAOImpl implements ResourceDAO { "FROM %s_RESOURCES R, %s_LOGICAL_RESOURCES LR WHERE R.LOGICAL_RESOURCE_ID = LR.LOGICAL_RESOURCE_ID AND " + "R.RESOURCE_ID IN "; + private static final String SQL_ORDER_BY_IDS = "ORDER BY CASE R.RESOURCE_ID "; + private static final String DERBY_PAGINATION_PARMS = "OFFSET ? ROWS FETCH NEXT ? ROWS ONLY"; private static final String DB2_PAGINATION_PARMS = "LIMIT ? OFFSET ?"; @@ -418,64 +422,7 @@ public List searchForIds(SqlQueryData queryData) throws FHIRPersistenceDat return resourceIds; } - @Override - public List searchByIds(String resourceType, List resourceIds) throws FHIRPersistenceDataAccessException, FHIRPersistenceDBConnectException { - final String METHODNAME = "searchByIds"; - log.entering(CLASSNAME, METHODNAME); - - if (resourceIds.isEmpty()) { - return Collections.emptyList(); - } - - Connection connection = null; - PreparedStatement stmt = null; - ResultSet resultSet = null; - String errMsg; - StringBuilder idQuery = new StringBuilder(); - List resources = new ArrayList<>(); - String stmtString = null; - long dbCallStartTime; - double dbCallDuration; - - try { - stmtString = String.format(this.getSearchByIdsSql(resourceType)); - idQuery.append(stmtString); - idQuery.append("("); - for (int i = 0; i < resourceIds.size(); i++) { - if (i > 0) { - idQuery.append(","); - } - idQuery.append(resourceIds.get(i)); - } - idQuery.append(")"); - - connection = this.getConnection(); - stmt = connection.prepareStatement(idQuery.toString()); - dbCallStartTime = System.nanoTime(); - resultSet = stmt.executeQuery(); - dbCallDuration = (System.nanoTime()-dbCallStartTime)/1e6; - if (log.isLoggable(Level.FINE)) { - log.fine("DB search by ids complete. SQL=[" + idQuery + "] executionTime=" + dbCallDuration + "ms"); - } - resources = this.createDTOs(resultSet); - } catch(FHIRPersistenceException e) { - throw e; - } catch (Throwable e) { - FHIRPersistenceDataAccessException fx = new FHIRPersistenceDataAccessException("Failure retrieving FHIR Resources"); - errMsg = "Failure retrieving FHIR Resources. SQL=[" + idQuery + "]"; - throw severe(log, fx, errMsg, e); - } finally { - this.cleanup(resultSet, stmt, connection); - log.exiting(CLASSNAME, METHODNAME); - } - return resources; - } - - protected String getSearchByIdsSql(String resourceType) { - String stmtString; - stmtString = String.format(SQL_SEARCH_BY_IDS, resourceType, resourceType); - return stmtString; - } + /** * Adds a resource type/ resource id pair to a candidate collection for population into the ResourceTypesCache. @@ -734,78 +681,55 @@ public List search(String sqlSelect) throws FHIRPersistenceDataAccessE } @Override - public List searchForIds(String sqlSelect) throws FHIRPersistenceDataAccessException, FHIRPersistenceDBConnectException { - final String METHODNAME = "searchForIds"; - log.entering(CLASSNAME, METHODNAME); - - List resourceIds = new ArrayList<>(); - Connection connection = null; - PreparedStatement stmt = null; - ResultSet resultSet = null; - String errMsg; - - try { - connection = this.getConnection(); - stmt = connection.prepareStatement(sqlSelect); - resultSet = stmt.executeQuery(); - while (resultSet.next()) { - resourceIds.add(resultSet.getLong(1)); - } - } catch(FHIRPersistenceException e) { - throw e; - } catch (Throwable e) { - // Log the SQL but don't expose it in the exception - FHIRPersistenceDataAccessException fx = new FHIRPersistenceDataAccessException("Failure retrieving FHIR Resource Ids."); - errMsg = "Failure retrieving FHIR Resource Ids. SQL=" + sqlSelect; - throw severe(log, fx, errMsg, e); - } finally { - this.cleanup(resultSet, stmt, connection); - log.exiting(CLASSNAME, METHODNAME); - } - return resourceIds; - } - - @Override - public List searchByIds(List resourceIds) throws FHIRPersistenceDataAccessException, FHIRPersistenceDBConnectException { + public List searchByIds(String resourceType, List resourceIds) throws FHIRPersistenceDataAccessException, FHIRPersistenceDBConnectException { final String METHODNAME = "searchByIds"; log.entering(CLASSNAME, METHODNAME); if (resourceIds.isEmpty()) { return Collections.emptyList(); } - + Connection connection = null; PreparedStatement stmt = null; ResultSet resultSet = null; String errMsg; StringBuilder idQuery = new StringBuilder(); List resources = new ArrayList<>(); - + String stmtString = null; + long dbCallStartTime; + double dbCallDuration; + try { - idQuery.append(SQL_SEARCH_BY_IDS); + stmtString = getSearchByIdsSql(resourceType); + idQuery.append(stmtString); idQuery.append("("); + // resourceIds should have a max length of 1000 (the max page size) + StringBuilder caseStmts = new StringBuilder(); for (int i = 0; i < resourceIds.size(); i++) { if (i > 0) { idQuery.append(","); } - idQuery.append("?"); + idQuery.append(resourceIds.get(i)); + + // build up the caseStmts here so we only need to iterate the list once + caseStmts.append(WHEN + resourceIds.get(i) + THEN + i); } - idQuery.append(")"); - + idQuery.append(") " + SQL_ORDER_BY_IDS + caseStmts + END); + connection = this.getConnection(); stmt = connection.prepareStatement(idQuery.toString()); - // Inject IDs into the prepared stmt. - for (int i = 0; i < resourceIds.size(); i++) { - stmt.setObject(i+1, resourceIds.get(i)); - } + dbCallStartTime = System.nanoTime(); resultSet = stmt.executeQuery(); + dbCallDuration = (System.nanoTime()-dbCallStartTime)/1e6; + if (log.isLoggable(Level.FINE)) { + log.fine("DB search by ids complete. SQL=[" + idQuery + "] executionTime=" + dbCallDuration + "ms"); + } resources = this.createDTOs(resultSet); } catch(FHIRPersistenceException e) { throw e; } catch (Throwable e) { - // Log the SQL but don't expose it in the exception - FHIRPersistenceDataAccessException fx = new FHIRPersistenceDataAccessException("Failure retrieving FHIR Resources."); - errMsg = "Failure retrieving FHIR Resources. SQL=" + idQuery; + FHIRPersistenceDataAccessException fx = new FHIRPersistenceDataAccessException("Failure retrieving FHIR Resources"); + errMsg = "Failure retrieving FHIR Resources. SQL=[" + idQuery + "]"; throw severe(log, fx, errMsg, e); } finally { this.cleanup(resultSet, stmt, connection); @@ -814,6 +738,10 @@ public List searchByIds(List resourceIds) throws FHIRPersistence return resources; } + protected String getSearchByIdsSql(String resourceType) { + return String.format(SQL_SEARCH_BY_IDS, resourceType, resourceType); + } + @Override public int searchCount(String sqlSelectCount) throws FHIRPersistenceDataAccessException, FHIRPersistenceDBConnectException { final String METHODNAME = "searchCount"; diff --git a/fhir-persistence-jdbc/src/main/java/com/ibm/fhir/persistence/jdbc/impl/FHIRPersistenceJDBCImpl.java b/fhir-persistence-jdbc/src/main/java/com/ibm/fhir/persistence/jdbc/impl/FHIRPersistenceJDBCImpl.java index 200783cfc01..2ce67af5acc 100644 --- a/fhir-persistence-jdbc/src/main/java/com/ibm/fhir/persistence/jdbc/impl/FHIRPersistenceJDBCImpl.java +++ b/fhir-persistence-jdbc/src/main/java/com/ibm/fhir/persistence/jdbc/impl/FHIRPersistenceJDBCImpl.java @@ -50,7 +50,7 @@ import com.ibm.fhir.model.parser.FHIRJsonParser; import com.ibm.fhir.model.parser.FHIRParser; import com.ibm.fhir.model.path.FHIRPathNode; -import com.ibm.fhir.model.path.FHIRPathPrimitiveValue; +import com.ibm.fhir.model.path.FHIRPathSystemValue; import com.ibm.fhir.model.resource.OperationOutcome; import com.ibm.fhir.model.resource.Resource; import com.ibm.fhir.model.resource.SearchParameter; @@ -1020,8 +1020,8 @@ private List extractSearchParameters(Resource fhirResource, com.ibm.f if (value.isElementNode()) { // parameterBuilder aggregates the results for later retrieval value.asElementNode().element().accept(parameterBuilder); - } else if (value.isPrimitiveValue()){ - Parameter p = processPrimitiveValue(value.asPrimitiveValue()); + } else if (value.isSystemValue()){ + Parameter p = processPrimitiveValue(value.asSystemValue()); p.setName(code); p.setType(Type.fromValue(type)); p.setResourceId(resourceDTO.getId()); @@ -1076,22 +1076,20 @@ private List extractSearchParameters(Resource fhirResource, com.ibm.f * Note: this method only sets the value; * caller is responsible for setting all other fields on the created Parameter. */ - private Parameter processPrimitiveValue(FHIRPathPrimitiveValue primitiveValue) { + private Parameter processPrimitiveValue(FHIRPathSystemValue systemValue) { Parameter p = new Parameter(); - if (primitiveValue.isBooleanValue()) { - if (primitiveValue.asBooleanValue()._boolean()) { + if (systemValue.isBooleanValue()) { + if (systemValue.asBooleanValue()._boolean()) { p.setValueCode("true"); } else { p.setValueCode("false"); } - } else if (primitiveValue.isDateTimeValue()) { - p.setValueDate(Timestamp.from(QueryBuilderUtil.getInstantFromPartial(primitiveValue.asDateTimeValue().dateTime()))); - } else if (primitiveValue.isStringValue()) { - p.setValueString(primitiveValue.asStringValue().string()); - } else if (primitiveValue.isTimeValue()) { - p.setValueDate(Timestamp.from(QueryBuilderUtil.getInstantFromPartial(primitiveValue.asTimeValue().time()))); - } else if (primitiveValue.isNumberValue()) { - p.setValueNumber(primitiveValue.asNumberValue().decimal()); + } else if (systemValue.isTemporalValue()) { + p.setValueDate(Timestamp.from(QueryBuilderUtil.getInstantFromPartial(systemValue.asTemporalValue().temporal()))); + } else if (systemValue.isStringValue()) { + p.setValueString(systemValue.asStringValue().string()); + } else if (systemValue.isNumberValue()) { + p.setValueNumber(systemValue.asNumberValue().decimal()); } return p; } diff --git a/fhir-persistence-jdbc/src/main/java/com/ibm/fhir/persistence/jdbc/util/SortedQuerySegmentAggregator.java b/fhir-persistence-jdbc/src/main/java/com/ibm/fhir/persistence/jdbc/util/SortedQuerySegmentAggregator.java index cdc03c70490..bed4442dc60 100644 --- a/fhir-persistence-jdbc/src/main/java/com/ibm/fhir/persistence/jdbc/util/SortedQuerySegmentAggregator.java +++ b/fhir-persistence-jdbc/src/main/java/com/ibm/fhir/persistence/jdbc/util/SortedQuerySegmentAggregator.java @@ -57,15 +57,14 @@ protected SortedQuerySegmentAggregator(Class resourceType, int offset, int pa *

* A simple example query produced by this method: *

-     * SELECT R.RESOURCE_ID,MIN(S1.STR_VALUE) FROM 
-     * Patient_RESOURCES R JOIN 
-     * Patient_LOGICAL_RESOURCES LR ON R.LOGICAL_RESOURCE_ID=LR.LOGICAL_RESOURCE_ID  JOIN 
-     * Patient_TOKEN_VALUES P1 ON P1.RESOURCE_ID=R.RESOURCE_ID  
-     * LEFT OUTER JOIN Patient_STR_VALUES S1 ON (S1.PARAMETER_NAME_ID=50 AND S1.RESOURCE_ID = R.RESOURCE_ID) WHERE 
-     * R.RESOURCE_ID = LR.CURRENT_RESOURCE_ID AND 
-     * R.IS_DELETED <> 'Y' AND 
-     * P1.RESOURCE_ID = R.RESOURCE_ID AND 
-     * (P1.PARAMETER_NAME_ID=196 AND ((P1.TOKEN_VALUE = false))) 
+     * SELECT R.RESOURCE_ID,MIN(S1.STR_VALUE) FROM Patient_RESOURCES R 
+     *   JOIN Patient_LOGICAL_RESOURCES LR ON R.LOGICAL_RESOURCE_ID=LR.LOGICAL_RESOURCE_ID
+     *   JOIN Patient_TOKEN_VALUES P1 ON P1.RESOURCE_ID=R.RESOURCE_ID  
+     *   LEFT OUTER JOIN Patient_STR_VALUES S1 ON (S1.PARAMETER_NAME_ID=50 AND S1.RESOURCE_ID = R.RESOURCE_ID)
+     *   WHERE R.RESOURCE_ID = LR.CURRENT_RESOURCE_ID AND 
+     *         R.IS_DELETED <> 'Y' AND 
+     *         P1.RESOURCE_ID = R.RESOURCE_ID AND 
+     *         (P1.PARAMETER_NAME_ID=196 AND ((P1.TOKEN_VALUE = false))) 
      * GROUP BY R.RESOURCE_ID  
      * ORDER BY MIN(S1.STR_VALUE) asc NULLS LAST 
      * OFFSET 0 ROWS FETCH NEXT 100 ROWS ONLY;
diff --git a/fhir-persistence/src/main/java/com/ibm/fhir/persistence/util/Processor.java b/fhir-persistence/src/main/java/com/ibm/fhir/persistence/util/Processor.java
index 713ce52faaa..4e684b327d3 100644
--- a/fhir-persistence/src/main/java/com/ibm/fhir/persistence/util/Processor.java
+++ b/fhir-persistence/src/main/java/com/ibm/fhir/persistence/util/Processor.java
@@ -18,7 +18,7 @@
 import com.ibm.fhir.model.path.FHIRPathDecimalValue;
 import com.ibm.fhir.model.path.FHIRPathElementNode;
 import com.ibm.fhir.model.path.FHIRPathIntegerValue;
-import com.ibm.fhir.model.path.FHIRPathQuantityNode;
+import com.ibm.fhir.model.path.FHIRPathQuantityValue;
 import com.ibm.fhir.model.path.FHIRPathResourceNode;
 import com.ibm.fhir.model.path.FHIRPathStringValue;
 import com.ibm.fhir.model.path.FHIRPathTimeValue;
@@ -193,7 +193,7 @@ public interface Processor {
 
     T process(SearchParameter parameter, FHIRPathBooleanValue value) throws FHIRPersistenceProcessorException;
 
-    T process(SearchParameter parameter, FHIRPathQuantityNode value) throws FHIRPersistenceProcessorException;
+    T process(SearchParameter parameter, FHIRPathQuantityValue value) throws FHIRPersistenceProcessorException;
 
     T process(SearchParameter parameter, ZonedDateTime value) throws FHIRPersistenceProcessorException;
 
diff --git a/fhir-persistence/src/test/java/com/ibm/fhir/persistence/test/ProcessorTest.java b/fhir-persistence/src/test/java/com/ibm/fhir/persistence/test/ProcessorTest.java
index 3eecb126490..8c91288ea4b 100644
--- a/fhir-persistence/src/test/java/com/ibm/fhir/persistence/test/ProcessorTest.java
+++ b/fhir-persistence/src/test/java/com/ibm/fhir/persistence/test/ProcessorTest.java
@@ -22,7 +22,7 @@
 import com.ibm.fhir.model.path.FHIRPathDecimalValue;
 import com.ibm.fhir.model.path.FHIRPathElementNode;
 import com.ibm.fhir.model.path.FHIRPathIntegerValue;
-import com.ibm.fhir.model.path.FHIRPathQuantityNode;
+import com.ibm.fhir.model.path.FHIRPathQuantityValue;
 import com.ibm.fhir.model.path.FHIRPathResourceNode;
 import com.ibm.fhir.model.path.FHIRPathStringValue;
 import com.ibm.fhir.model.path.FHIRPathTimeValue;
@@ -406,8 +406,8 @@ public String process(SearchParameter parameter, YearMonth value) throws FHIRPer
         }
         
         @Override
-        public String process(SearchParameter parameter, FHIRPathQuantityNode value) throws FHIRPersistenceProcessorException {
-            return "process(SearchParameter, FHIRPathQuantityNode)";
+        public String process(SearchParameter parameter, FHIRPathQuantityValue value) throws FHIRPersistenceProcessorException {
+            return "process(SearchParameter, FHIRPathQuantityValue)";
         }
 
         @Override
diff --git a/fhir-search/src/test/java/com/ibm/fhir/search/test/ExtractorValidator.java b/fhir-search/src/test/java/com/ibm/fhir/search/test/ExtractorValidator.java
index 626dc5638fb..7e5b0ef3cc4 100644
--- a/fhir-search/src/test/java/com/ibm/fhir/search/test/ExtractorValidator.java
+++ b/fhir-search/src/test/java/com/ibm/fhir/search/test/ExtractorValidator.java
@@ -25,7 +25,7 @@
 import com.ibm.fhir.model.path.FHIRPathDateTimeValue;
 import com.ibm.fhir.model.path.FHIRPathElementNode;
 import com.ibm.fhir.model.path.FHIRPathNode;
-import com.ibm.fhir.model.path.FHIRPathPrimitiveValue;
+import com.ibm.fhir.model.path.FHIRPathSystemValue;
 import com.ibm.fhir.model.path.FHIRPathResourceNode;
 import com.ibm.fhir.model.path.FHIRPathStringValue;
 import com.ibm.fhir.model.resource.SearchParameter;
@@ -43,7 +43,7 @@ public void addExpected(String name, List values) {
     }
 
     /**
-     * validates the FHIR Path expectations for a specific search parameter. 
+     * validates the FHIR Path expectations for a specific search parameter.
      * @param output
      */
     public void validate(Map> output) {
@@ -117,7 +117,7 @@ private void printOutput(Map> output) {
      * Process the FHIRPathNode into a String value
      */
     private static String processOutput(FHIRPathNode node) {
-        
+
         String val = "";
         if (node.getClass().getSimpleName().contains("FHIRPathBooleanValue")) {
             FHIRPathBooleanValue booleanValue = (FHIRPathBooleanValue) node;
@@ -127,11 +127,12 @@ private static String processOutput(FHIRPathNode node) {
                 val = "false";
             }
 
-        } else if (node.isPrimitiveValue()) {
-            FHIRPathPrimitiveValue nodeConverted = node.asPrimitiveValue();
-            if (nodeConverted.isDateTimeValue()) {
-                FHIRPathDateTimeValue v = (FHIRPathDateTimeValue) node;
-                val = "" + v.toString();
+        } else if (node.isSystemValue()) {
+            FHIRPathSystemValue nodeConverted = node.asSystemValue();
+            if (nodeConverted.isTemporalValue() && nodeConverted.asTemporalValue().isDateTimeValue()) {
+              FHIRPathDateTimeValue v = (FHIRPathDateTimeValue) nodeConverted.asTemporalValue();
+              val = "" + v.toString();
+
             } else if (nodeConverted.isStringValue()) {
                 FHIRPathStringValue v = nodeConverted.asStringValue();
                 val = "" + v.string();
@@ -140,14 +141,14 @@ private static String processOutput(FHIRPathNode node) {
         } else if (node.is(FHIRPathElementNode.class)) {
             FHIRPathElementNode tNode = node.asElementNode();
 
-            FHIRPathPrimitiveValue v = tNode.getValue();
+            FHIRPathSystemValue v = tNode.getValue();
             if (v != null) {
 
                 if (v.isStringValue()) {
                     FHIRPathStringValue sv = v.asStringValue();
                     val = "" + sv.string();
-                } else if (v.isDateTimeValue()) {
-                    FHIRPathDateTimeValue vv = v.asDateTimeValue();
+                } else if (v.isTemporalValue() && v.asTemporalValue().isDateTimeValue()) {
+                    FHIRPathDateTimeValue vv = v.asTemporalValue().asDateTimeValue();
                     TemporalAccessor acc = vv.dateTime();
                     val = "" + acc.toString(); //DATE_TIME_FORMATTER.format(acc);
                 }
@@ -158,8 +159,8 @@ private static String processOutput(FHIRPathNode node) {
                         FHIRPathElementNode nx = child.asElementNode();
                         val = "" + nx.getValue();
 
-                    } else if (child.isPrimitiveValue()) {
-                        FHIRPathPrimitiveValue v1 = child.asPrimitiveValue();
+                    } else if (child.isSystemValue()) {
+                        FHIRPathSystemValue v1 = child.asSystemValue();
                         if (v1.isStringValue()) {
                             FHIRPathStringValue sv = v1.asStringValue();
                             val = "" + sv.string() + ",";
diff --git a/fhir-server-test/src/test/java/com/ibm/fhir/server/test/SearchPerformaceTest.java b/fhir-server-test/src/test/java/com/ibm/fhir/server/test/SearchPerformaceTest.java
index a439e316d8a..66d60723b44 100644
--- a/fhir-server-test/src/test/java/com/ibm/fhir/server/test/SearchPerformaceTest.java
+++ b/fhir-server-test/src/test/java/com/ibm/fhir/server/test/SearchPerformaceTest.java
@@ -15,6 +15,7 @@
 import static org.testng.Assert.assertTrue;
 
 import java.lang.reflect.Method;
+import java.math.BigDecimal;
 import java.util.List;
 
 import javax.ws.rs.client.Entity;
@@ -27,9 +28,14 @@
 import com.ibm.fhir.model.resource.Bundle;
 import com.ibm.fhir.model.resource.Observation;
 import com.ibm.fhir.model.resource.Patient;
+import com.ibm.fhir.model.resource.Observation.Component;
 import com.ibm.fhir.model.test.TestUtil;
 import com.ibm.fhir.model.type.Code;
+import com.ibm.fhir.model.type.CodeableConcept;
 import com.ibm.fhir.model.type.Coding;
+import com.ibm.fhir.model.type.Decimal;
+import com.ibm.fhir.model.type.Quantity;
+import com.ibm.fhir.model.type.Uri;
 import com.ibm.fhir.model.type.code.AdministrativeGender;
 import com.ibm.fhir.model.util.FHIRUtil;
 
@@ -44,7 +50,7 @@ public class SearchPerformaceTest extends FHIRServerTestBase {
     // Controls how many observations and patients to create for the test.
     // Using invocationCount of testng can cause the testng report grows too big, so
     // this config is used to make sure all test users are created in one testng step.
-    private final int numOfPatientObservationsToCreate = 100;
+    private final int numOfPatientObservationsToCreate = 1000;
 
     /**
      * Retrieve the server's conformance statement to determine the status of certain runtime options.
@@ -87,6 +93,21 @@ public void testCreatePatientAndObservation() throws Exception {
             // create observation for the patient
             Observation observation =
                     TestUtil.buildPatientObservation(patientId, "Observation1.json");
+            observation = observation.toBuilder()
+                    .code(CodeableConcept.builder()
+                            .coding(Coding.builder()
+                                    .system(Uri.of("http://loinc.org"))
+                                    .code(Code.of("55284-4"))
+                                    .build())
+                            .build())
+                    .component(Component.builder()
+                            .code(CodeableConcept.builder().text(string("component1")).build())
+                            .value(Quantity.builder()
+                                    .value(Decimal.of(BigDecimal.valueOf(Math.random())))
+                                    .unit(string("mmHg"))
+                                    .build())
+                            .build())
+                    .build();
             Entity entity2 =
                     Entity.entity(observation, FHIRMediaType.APPLICATION_FHIR_JSON);
             response =
diff --git a/fhir-server-test/src/test/java/com/ibm/fhir/server/test/SortingTest.java b/fhir-server-test/src/test/java/com/ibm/fhir/server/test/SortingTest.java
index 34f5ec9332d..b402b3047a8 100644
--- a/fhir-server-test/src/test/java/com/ibm/fhir/server/test/SortingTest.java
+++ b/fhir-server-test/src/test/java/com/ibm/fhir/server/test/SortingTest.java
@@ -674,6 +674,7 @@ private void assertTrueNaturalOrdering(List sortedList) {
                 }
 
                 assertTrue(prior.compareTo(current) <= 0);
+                prior = current;
             }
             done = true;
         }
diff --git a/fhir-validation/pom.xml b/fhir-validation/pom.xml
index cee259cd213..653719323a1 100644
--- a/fhir-validation/pom.xml
+++ b/fhir-validation/pom.xml
@@ -40,6 +40,12 @@
             fhir-examples
             test
         
+        
+            ${project.groupId}
+            fhir-ig-us-core
+            ${project.version}
+            test
+        
     
 
     
diff --git a/fhir-validation/src/main/java/com/ibm/fhir/validation/FHIRValidator.java b/fhir-validation/src/main/java/com/ibm/fhir/validation/FHIRValidator.java
index 034f81a8c26..299e035d84b 100644
--- a/fhir-validation/src/main/java/com/ibm/fhir/validation/FHIRValidator.java
+++ b/fhir-validation/src/main/java/com/ibm/fhir/validation/FHIRValidator.java
@@ -19,12 +19,11 @@
 import com.ibm.fhir.model.annotation.Constraint;
 import com.ibm.fhir.model.path.FHIRPathElementNode;
 import com.ibm.fhir.model.path.FHIRPathNode;
-import com.ibm.fhir.model.path.FHIRPathQuantityNode;
 import com.ibm.fhir.model.path.FHIRPathResourceNode;
 import com.ibm.fhir.model.path.FHIRPathTree;
 import com.ibm.fhir.model.path.evaluator.FHIRPathEvaluator;
 import com.ibm.fhir.model.path.evaluator.FHIRPathEvaluator.EvaluationContext;
-import com.ibm.fhir.model.path.visitor.FHIRPathVoidParameterNodeVisitorAdapter;
+import com.ibm.fhir.model.path.visitor.FHIRPathDefaultNodeVisitor;
 import com.ibm.fhir.model.resource.DomainResource;
 import com.ibm.fhir.model.resource.OperationOutcome.Issue;
 import com.ibm.fhir.model.resource.Resource;
@@ -143,7 +142,7 @@ public static FHIRValidator validator() {
         return new FHIRValidator();
     }
 
-    private static class ValidatingNodeVisitor extends FHIRPathVoidParameterNodeVisitorAdapter {
+    private static class ValidatingNodeVisitor extends FHIRPathDefaultNodeVisitor {
         private FHIRPathEvaluator evaluator = FHIRPathEvaluator.evaluator();
         private EvaluationContext evaluationContext;
         private boolean includeResourceAssertedProfiles;
@@ -166,17 +165,12 @@ private void reset() {
         }
         
         @Override
-        protected void doVisit(FHIRPathElementNode node) {
+        public void doVisit(FHIRPathElementNode node) {
             validate(node);
         }
         
         @Override
-        protected void doVisit(FHIRPathResourceNode node) {
-            validate(node);
-        }
-        
-        @Override
-        protected void doVisit(FHIRPathQuantityNode node) {
+        public void doVisit(FHIRPathResourceNode node) {
             validate(node);
         }
 
diff --git a/fhir-validation/src/main/java/com/ibm/fhir/validation/util/ConstraintGenerator.java b/fhir-validation/src/main/java/com/ibm/fhir/validation/util/ConstraintGenerator.java
index e9e4ff34d54..83a40f8edba 100644
--- a/fhir-validation/src/main/java/com/ibm/fhir/validation/util/ConstraintGenerator.java
+++ b/fhir-validation/src/main/java/com/ibm/fhir/validation/util/ConstraintGenerator.java
@@ -19,6 +19,10 @@
 import java.util.Map;
 import java.util.Objects;
 import java.util.StringJoiner;
+import java.util.logging.Handler;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+import java.util.logging.Logger;
 
 import com.ibm.fhir.model.annotation.Constraint;
 import com.ibm.fhir.model.resource.StructureDefinition;
@@ -39,6 +43,8 @@
  * A class used to generate FHIRPath expressions from a profile
  */
 public class ConstraintGenerator {
+    private static final Logger log = Logger.getLogger(ConstraintGenerator.class.getName());
+    
     private final StructureDefinition profile;
     private final Tree tree;
 
@@ -56,12 +62,15 @@ public List generate() {
     
         int index = 1;
     
+        log.fine("Generated constraint expressions:");
         for (Node child : tree.root.children) {
             String expr = generate(child);
+            log.fine(expr);
             String description = "Constraint violation: " + expr;
             constraints.add(constraint("generated-" + prefix + "-" + index, expr, description));
             index++;
         }
+        log.fine("");
     
         return constraints;
     }
@@ -100,25 +109,29 @@ private Tree buildTree(StructureDefinition profile) {
         tree.nodeMap = nodeMap;
         tree.sliceDefinitionMap = sliceDefinitionMap;
         
-        System.out.println("Paths before pruning:");
-        for (String path : nodeMap.keySet()) {
-            System.out.println("path: " + path);
+        if (log.isLoggable(Level.FINE)) {
+            log.fine("Element definitions BEFORE pruning:");
+            for (String id : nodeMap.keySet()) {
+                log.fine(id);
+            }
+            log.fine("");
         }
-        System.out.println("");
 
         prune(tree);
 
-        System.out.println("Paths after pruning:");
-        for (String path : nodeMap.keySet()) {
-            System.out.println("path: " + path);
-        }
-        System.out.println("");
-
-        System.out.println("Slice definitions:");
-        for (String id : sliceDefinitionMap.keySet()) {
-            System.out.println("id: " + id);
+        if (log.isLoggable(Level.FINE)) {
+            log.fine("Element definitions AFTER pruning:");
+            for (String id : nodeMap.keySet()) {
+                log.fine(id);
+            }
+            log.fine("");
+    
+            log.fine("Slice definitions:");
+            for (String id : sliceDefinitionMap.keySet()) {
+                log.fine(id);
+            }
+            log.fine("");
         }
-        System.out.println("");
 
         return tree;
     }
@@ -190,7 +203,11 @@ private String generate(Node node) {
                 if (isExtensionUrl(child.elementDefinition)) {
                     continue;
                 }
-                joiner.add(generate(child));
+                if (isOptional(child.elementDefinition)) {
+                    joiner.add("(" + generate(child) + ")");
+                } else {
+                    joiner.add(generate(child));
+                }
             }
             sb.append(joiner.toString());
             sb.append(")");
@@ -583,8 +600,25 @@ static class Tree {
     }
 
     public static void main(String[] args) throws Exception {
-        StructureDefinition profile = FHIRRegistry.getInstance().getResource("http://hl7.org/fhir/StructureDefinition/bp", StructureDefinition.class);
+        Logger logger = Logger.getLogger("");
+        logger.setLevel(Level.FINE);
+        logger.addHandler(new Handler() {
+            @Override
+            public void publish(LogRecord record) {
+                System.out.println(record.getMessage());
+            }
+
+            @Override
+            public void flush() {                
+            }
+
+            @Override
+            public void close() throws SecurityException {                
+            }
+        });
+        StructureDefinition profile = FHIRRegistry.getInstance().getResource("http://hl7.org/fhir/StructureDefinition/bodyweight", StructureDefinition.class);
         ConstraintGenerator generator = new ConstraintGenerator(profile);
+        System.out.println("Generated constraints: ");
         generator.generate().stream().map(constraint -> constraint.expression()).forEach(System.out::println);
     }
 }
\ No newline at end of file
diff --git a/fhir-validation/src/main/java/com/ibm/fhir/validation/util/ProfileSupport.java b/fhir-validation/src/main/java/com/ibm/fhir/validation/util/ProfileSupport.java
index c720d355f0f..260735e2dda 100644
--- a/fhir-validation/src/main/java/com/ibm/fhir/validation/util/ProfileSupport.java
+++ b/fhir-validation/src/main/java/com/ibm/fhir/validation/util/ProfileSupport.java
@@ -76,6 +76,8 @@ private static List computeConstraints(StructureDefinition profile,
             }
         }
         Collections.sort(constraints, CONSTRAINT_COMPARATOR);
+        ConstraintGenerator generator = new ConstraintGenerator(profile);
+        constraints.addAll(generator.generate());
         return constraints;
     }
 
@@ -180,7 +182,6 @@ public static List getConstraints(List urls, Class resour
     }
     
     public static List getConstraints(Resource resource) {
-        List constraints = new ArrayList<>();
         Meta meta = resource.getMeta();
         if (meta != null) {
             List urls = new ArrayList<>();
@@ -191,7 +192,7 @@ public static List getConstraints(Resource resource) {
             }
             return getConstraints(urls, resource.getClass());
         }
-        return constraints;
+        return Collections.emptyList();
     }
 
     public static List getConstraints(String url, Class resourceType) {
diff --git a/fhir-validation/src/test/java/com/ibm/fhir/validation/test/BloodPressureObservationTest.java b/fhir-validation/src/test/java/com/ibm/fhir/validation/test/BloodPressureObservationTest.java
new file mode 100644
index 00000000000..084d8be276e
--- /dev/null
+++ b/fhir-validation/src/test/java/com/ibm/fhir/validation/test/BloodPressureObservationTest.java
@@ -0,0 +1,142 @@
+/*
+ * (C) Copyright IBM Corp. 2019
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package com.ibm.fhir.validation.test;
+
+import static com.ibm.fhir.model.type.String.string;
+
+import java.util.List;
+import java.util.logging.Handler;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+import java.util.logging.Logger;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import com.ibm.fhir.model.format.Format;
+import com.ibm.fhir.model.generator.FHIRGenerator;
+import com.ibm.fhir.model.resource.Observation;
+import com.ibm.fhir.model.resource.Observation.Component;
+import com.ibm.fhir.model.resource.OperationOutcome.Issue;
+import com.ibm.fhir.model.type.Canonical;
+import com.ibm.fhir.model.type.Code;
+import com.ibm.fhir.model.type.CodeableConcept;
+import com.ibm.fhir.model.type.Coding;
+import com.ibm.fhir.model.type.DateTime;
+import com.ibm.fhir.model.type.Decimal;
+import com.ibm.fhir.model.type.Meta;
+import com.ibm.fhir.model.type.Quantity;
+import com.ibm.fhir.model.type.Reference;
+import com.ibm.fhir.model.type.Uri;
+import com.ibm.fhir.model.type.code.ObservationStatus;
+import com.ibm.fhir.validation.FHIRValidator;
+
+public class BloodPressureObservationTest {
+    @Test
+    public static void testBloodPressureObservation() throws Exception {
+        // build a blood pressure observation
+        Observation bloodPressureObservation = Observation.builder()
+            // resource metadata
+            .meta(Meta.builder()
+                // asssert conformance to the blood pressure profile
+                .profile(Canonical.of("http://hl7.org/fhir/StructureDefinition/bp"))
+                .build())
+            
+            // observation status
+            .status(ObservationStatus.FINAL)
+            
+            // observation subject (Patient)
+            .subject(Reference.builder()
+                .reference(string("Patient/1234"))
+                .build())
+            
+            // observation effective time
+            .effective(DateTime.builder()
+                .value("2019-01-01")
+                .build())
+                        
+            // observation category (vital signs)
+            .category(CodeableConcept.builder()
+                .coding(Coding.builder()
+                    .system(Uri.of("http://terminology.hl7.org/CodeSystem/observation-category"))
+                    .code(Code.of("vital-signs"))
+                    .build())
+                .build())
+            
+            // observation code (blood pressure)
+            .code(CodeableConcept.builder()
+                .coding(Coding.builder()
+                    .system(Uri.of("http://loinc.org"))
+                    .code(Code.of("85354-9"))
+                    .build())
+                .build())
+            
+            // observation component (systolic blood pressure)
+            .component(Component.builder()
+                .code(CodeableConcept.builder()
+                    .coding(Coding.builder()
+                        .system(Uri.of("http://loinc.org"))
+//                      .code(Code.of("8480-6"))
+                        .display(string("Systolic Blood Pressure"))
+                        .build())
+                    .build())
+                .value(Quantity.builder()
+                    .value(Decimal.of(120))
+                    .system(Uri.of("http://unitsofmeasure.org"))
+                    .code(Code.of("mm[Hg]"))
+                    .unit(string("mm[Hg]"))
+                    .build())
+                .build())
+            
+            // observation component (diastolic blood pressure)
+            .component(Component.builder()
+                .code(CodeableConcept.builder()
+                    .coding(Coding.builder()
+                        .system(Uri.of("http://loinc.org"))
+                        .code(Code.of("8462-4"))
+                        .display(string("Diastolic Blood Pressure"))
+                        .build())
+                    .build())
+                .value(Quantity.builder()
+                    .value(Decimal.of(80))
+                    .system(Uri.of("http://unitsofmeasure.org"))
+                    .code(Code.of("mm[Hg]"))
+                    .unit(string("mm[Hg]"))
+                    .build())
+                .build())
+            .build();
+        
+        // print the blood pressure observation to the console
+        FHIRGenerator.generator(Format.JSON, true).generate(bloodPressureObservation, System.out);
+        System.out.println("");
+        
+        // validate the blood pressure observation in debug mode and print issues to console
+        Logger logger = Logger.getLogger("");
+        logger.setLevel(Level.FINE);
+        logger.addHandler(new Handler() {
+            @Override
+            public void publish(LogRecord record) {
+                System.out.println(record.getMessage());
+            }
+
+            @Override
+            public void flush() {                
+            }
+
+            @Override
+            public void close() throws SecurityException {                
+            }
+        });
+        List issues = FHIRValidator.validator().validate(bloodPressureObservation);
+        issues.forEach(System.out::println);
+        Assert.assertEquals(issues.size(), 2);
+        Assert.assertTrue(issues.get(0).getDetails().getText().getValue().startsWith("dom-6"));
+        Assert.assertTrue(issues.get(1).getDetails().getText().getValue().startsWith("generated-bp-8"));
+
+        System.out.println("");
+    }
+}
\ No newline at end of file
diff --git a/fhir-validation/src/test/java/com/ibm/fhir/validation/test/BodyWeightProfileTest.java b/fhir-validation/src/test/java/com/ibm/fhir/validation/test/BodyWeightProfileTest.java
index 98270ff60f8..122ea284a6f 100644
--- a/fhir-validation/src/test/java/com/ibm/fhir/validation/test/BodyWeightProfileTest.java
+++ b/fhir-validation/src/test/java/com/ibm/fhir/validation/test/BodyWeightProfileTest.java
@@ -36,7 +36,7 @@ public class BodyWeightProfileTest {
     public static void testBodyWeightProfile() throws Exception {
         List constraints = getConstraints(BODY_WEIGHT_PROFILE_URL, Observation.class);
 
-        Assert.assertEquals(constraints.size(), 3);
+        Assert.assertEquals(constraints.size(), 10);
         Assert.assertTrue(constraints.stream().filter(constraint -> constraint.id().equals("vs-1")).count() == 1);
         Assert.assertTrue(constraints.stream().filter(constraint -> constraint.id().equals("vs-2")).count() == 1);
         Assert.assertTrue(constraints.stream().filter(constraint -> constraint.id().equals("vs-3")).count() == 1);
@@ -76,10 +76,14 @@ public static void testBodyWeightProfile() throws Exception {
                 .build();
 
         List issues = FHIRValidator.validator().validate(bodyWeight);
-        Assert.assertEquals(issues.size(), 2);
+        
+        issues.forEach(System.out::println);
+        
+        Assert.assertEquals(issues.size(), 3);
         Assert.assertTrue(issues.stream().filter(issue -> issue.getDetails().getText().getValue().startsWith("dom-6")).count() == 1);
         Assert.assertTrue(issues.stream().filter(issue -> issue.getDetails().getText().getValue().startsWith("vs-1")).count() == 1);
-        
+        Assert.assertTrue(issues.stream().filter(issue -> issue.getDetails().getText().getValue().startsWith("generated-bodyweight-3")).count() == 1);
+
         bodyWeight = bodyWeight.toBuilder()
                 .meta(null)
                 .build();
@@ -89,7 +93,7 @@ public static void testBodyWeightProfile() throws Exception {
         Assert.assertTrue(issues.stream().filter(issue -> issue.getDetails().getText().getValue().startsWith("dom-6")).count() == 1);
         
         issues = FHIRValidator.validator().validate(bodyWeight, BODY_WEIGHT_PROFILE_URL);
-        Assert.assertEquals(issues.size(), 2);
+        Assert.assertEquals(issues.size(), 3);
         Assert.assertTrue(issues.stream().filter(issue -> issue.getDetails().getText().getValue().startsWith("dom-6")).count() == 1);
         Assert.assertTrue(issues.stream().filter(issue -> issue.getDetails().getText().getValue().startsWith("vs-1")).count() == 1);
     }
diff --git a/fhir-validation/src/test/java/com/ibm/fhir/validation/test/ConstraintGeneratorTest.java b/fhir-validation/src/test/java/com/ibm/fhir/validation/test/ConstraintGeneratorTest.java
new file mode 100644
index 00000000000..5fb69649368
--- /dev/null
+++ b/fhir-validation/src/test/java/com/ibm/fhir/validation/test/ConstraintGeneratorTest.java
@@ -0,0 +1,421 @@
+/*
+ * (C) Copyright IBM Corp. 2019
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+package com.ibm.fhir.validation.test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.antlr.v4.runtime.CharStreams;
+import org.antlr.v4.runtime.CommonTokenStream;
+import org.antlr.v4.runtime.tree.ParseTree;
+
+import com.ibm.fhir.model.path.FHIRPathBaseVisitor;
+import com.ibm.fhir.model.path.FHIRPathLexer;
+import com.ibm.fhir.model.path.FHIRPathParser;
+import com.ibm.fhir.model.path.FHIRPathParser.ExpressionContext;
+import com.ibm.fhir.model.resource.StructureDefinition;
+import com.ibm.fhir.registry.FHIRRegistry;
+import com.ibm.fhir.validation.util.ConstraintGenerator;
+
+public class ConstraintGeneratorTest {
+    public static void main(String[] args) throws Exception {
+        StructureDefinition profile = FHIRRegistry.getInstance().getResource("http://hl7.org/fhir/us/core/StructureDefinition/us-core-patient", StructureDefinition.class);
+        ConstraintGenerator generator = new ConstraintGenerator(profile);
+        List list = new ArrayList<>();
+        generator.generate().stream().map(constraint -> constraint.expression()).forEach(expr -> list.add(expr));
+        for (String expr : list) {
+        	System.out.println("expr: " + expr);
+        	ExpressionContext ctx = compile(expr);
+        	ctx.accept(new PrintingVisitor());
+        	System.out.println("");
+        }
+    }
+
+    public static ExpressionContext compile(String expr) {
+        FHIRPathLexer lexer = new FHIRPathLexer(CharStreams.fromString(expr));
+        CommonTokenStream tokens = new CommonTokenStream(lexer);
+        FHIRPathParser parser = new FHIRPathParser(tokens);
+        return parser.expression();
+    }
+
+    public static class PrintingVisitor extends FHIRPathBaseVisitor {
+        int indentLevel = 0;
+
+        private String indent() {
+            StringBuilder builder = new StringBuilder();
+            for (int i = 0;i < indentLevel; i++) {
+                builder.append("    ");
+            }
+            return builder.toString();
+        }
+        
+        private void print(ParseTree ctx) {
+            System.out.println(indent() + ctx.getClass().getSimpleName() + ": " + ctx.getText() + ", childCount: " + ctx.getChildCount());
+        }
+
+        @Override
+        public Object visitIndexerExpression(FHIRPathParser.IndexerExpressionContext ctx) {
+            print(ctx);
+            indentLevel++;
+            Object result = visitChildren(ctx);
+            indentLevel--;
+            return result;
+        }
+
+        @Override
+        public Object visitPolarityExpression(FHIRPathParser.PolarityExpressionContext ctx) {
+            print(ctx);
+            indentLevel++;
+            Object result = visitChildren(ctx);
+            indentLevel--;
+            return result;
+        }
+
+        @Override
+        public Object visitAdditiveExpression(FHIRPathParser.AdditiveExpressionContext ctx) {
+            print(ctx);
+            indentLevel++;
+            Object result = visitChildren(ctx);
+            indentLevel--;
+            return result;
+        }
+
+        @Override
+        public Object visitMultiplicativeExpression(FHIRPathParser.MultiplicativeExpressionContext ctx) {
+            print(ctx);
+            indentLevel++;
+            Object result = visitChildren(ctx);
+            indentLevel--;
+            return result;
+        }
+
+        @Override
+        public Object visitUnionExpression(FHIRPathParser.UnionExpressionContext ctx) {
+            print(ctx);
+            indentLevel++;
+            Object result = visitChildren(ctx);
+            indentLevel--;
+            return result;
+        }
+
+        @Override
+        public Object visitOrExpression(FHIRPathParser.OrExpressionContext ctx) {
+            print(ctx);
+            indentLevel++;
+            Object result = visitChildren(ctx);
+            indentLevel--;
+            return result;
+        }
+
+        @Override
+        public Object visitAndExpression(FHIRPathParser.AndExpressionContext ctx) {
+            print(ctx);
+            indentLevel++;
+            Object result = visitChildren(ctx);
+            indentLevel--;
+            return result;
+        }
+
+        @Override
+        public Object visitMembershipExpression(FHIRPathParser.MembershipExpressionContext ctx) {
+            print(ctx);
+            indentLevel++;
+            Object result = visitChildren(ctx);
+            indentLevel--;
+            return result;
+        }
+
+        @Override
+        public Object visitInequalityExpression(FHIRPathParser.InequalityExpressionContext ctx) {
+            print(ctx);
+            indentLevel++;
+            Object result = visitChildren(ctx);
+            indentLevel--;
+            return result;
+        }
+
+        @Override
+        public Object visitInvocationExpression(FHIRPathParser.InvocationExpressionContext ctx) {
+            print(ctx);
+            indentLevel++;
+            Object result = visitChildren(ctx);
+            indentLevel--;
+            return result;
+        }
+
+        @Override
+        public Object visitEqualityExpression(FHIRPathParser.EqualityExpressionContext ctx) {
+            print(ctx);
+            indentLevel++;
+            Object result = visitChildren(ctx);
+            indentLevel--;
+            return result;
+        }
+
+        @Override
+        public Object visitImpliesExpression(FHIRPathParser.ImpliesExpressionContext ctx) {
+            print(ctx);
+            indentLevel++;
+            Object result = visitChildren(ctx);
+            indentLevel--;
+            return result;
+        }
+
+        @Override
+        public Object visitTermExpression(FHIRPathParser.TermExpressionContext ctx) {
+            print(ctx);
+            indentLevel++;
+            Object result = visitChildren(ctx);
+            indentLevel--;
+            return result;
+        }
+
+        @Override
+        public Object visitTypeExpression(FHIRPathParser.TypeExpressionContext ctx) {
+            print(ctx);
+            indentLevel++;
+            Object result = visitChildren(ctx);
+            indentLevel--;
+            return result;
+        }
+
+        @Override
+        public Object visitInvocationTerm(FHIRPathParser.InvocationTermContext ctx) {
+            print(ctx);
+            indentLevel++;
+            Object result = visitChildren(ctx);
+            indentLevel--;
+            return result;
+        }
+
+        @Override
+        public Object visitLiteralTerm(FHIRPathParser.LiteralTermContext ctx) {
+            print(ctx);
+            indentLevel++;
+            Object result = visitChildren(ctx);
+            indentLevel--;
+            return result;
+        }
+
+        @Override
+        public Object visitExternalConstantTerm(FHIRPathParser.ExternalConstantTermContext ctx) {
+            print(ctx);
+            indentLevel++;
+            Object result = visitChildren(ctx);
+            indentLevel--;
+            return result;
+        }
+
+        @Override
+        public Object visitParenthesizedTerm(FHIRPathParser.ParenthesizedTermContext ctx) {
+            print(ctx);
+            indentLevel++;
+            Object result = visitChildren(ctx);
+            indentLevel--;
+            return result;
+        }
+
+        @Override
+        public Object visitNullLiteral(FHIRPathParser.NullLiteralContext ctx) {
+            print(ctx);
+            indentLevel++;
+            Object result = visitChildren(ctx);
+            indentLevel--;
+            return result;
+        }
+
+        @Override
+        public Object visitBooleanLiteral(FHIRPathParser.BooleanLiteralContext ctx) {
+            print(ctx);
+            indentLevel++;
+            Object result = visitChildren(ctx);
+            indentLevel--;
+            return result;
+        }
+
+        @Override
+        public Object visitStringLiteral(FHIRPathParser.StringLiteralContext ctx) {
+            print(ctx);
+            indentLevel++;
+            Object result = visitChildren(ctx);
+            indentLevel--;
+            return result;
+        }
+
+        @Override
+        public Object visitNumberLiteral(FHIRPathParser.NumberLiteralContext ctx) {
+            print(ctx);
+            indentLevel++;
+            Object result = visitChildren(ctx);
+            indentLevel--;
+            return result;
+        }
+
+        @Override
+        public Object visitDateTimeLiteral(FHIRPathParser.DateTimeLiteralContext ctx) {
+            print(ctx);
+            indentLevel++;
+            Object result = visitChildren(ctx);
+            indentLevel--;
+            return result;
+        }
+
+        @Override
+        public Object visitTimeLiteral(FHIRPathParser.TimeLiteralContext ctx) {
+            print(ctx);
+            indentLevel++;
+            Object result = visitChildren(ctx);
+            indentLevel--;
+            return result;
+        }
+
+        @Override
+        public Object visitQuantityLiteral(FHIRPathParser.QuantityLiteralContext ctx) {
+            print(ctx);
+            indentLevel++;
+            Object result = visitChildren(ctx);
+            indentLevel--;
+            return result;
+        }
+
+        @Override
+        public Object visitExternalConstant(FHIRPathParser.ExternalConstantContext ctx) {
+            print(ctx);
+            indentLevel++;
+            Object result = visitChildren(ctx);
+            indentLevel--;
+            return result;
+        }
+
+        @Override
+        public Object visitMemberInvocation(FHIRPathParser.MemberInvocationContext ctx) {
+            print(ctx);
+            indentLevel++;
+            Object result = visitChildren(ctx);
+            indentLevel--;
+            return result;
+        }
+
+        @Override
+        public Object visitFunctionInvocation(FHIRPathParser.FunctionInvocationContext ctx) {
+            print(ctx);
+            indentLevel++;
+            Object result = visitChildren(ctx);
+            indentLevel--;
+            return result;
+        }
+
+        @Override
+        public Object visitThisInvocation(FHIRPathParser.ThisInvocationContext ctx) {
+            print(ctx);
+            indentLevel++;
+            Object result = visitChildren(ctx);
+            indentLevel--;
+            return result;
+        }
+
+        @Override
+        public Object visitIndexInvocation(FHIRPathParser.IndexInvocationContext ctx) {
+            print(ctx);
+            indentLevel++;
+            Object result = visitChildren(ctx);
+            indentLevel--;
+            return result;
+        }
+
+
+        @Override
+        public Object visitTotalInvocation(FHIRPathParser.TotalInvocationContext ctx) {
+            print(ctx);
+            indentLevel++;
+            Object result = visitChildren(ctx);
+            indentLevel--;
+            return result;
+        }
+
+        @Override
+        public Object visitFunction(FHIRPathParser.FunctionContext ctx) {
+            print(ctx);
+            indentLevel++;
+            Object result = visitChildren(ctx);
+            indentLevel--;
+            return result;
+        }
+
+        @Override
+        public Object visitParamList(FHIRPathParser.ParamListContext ctx) {
+            print(ctx);
+            indentLevel++;
+            Object result = visitChildren(ctx);
+            indentLevel--;
+            return result;
+        }
+
+        @Override
+        public Object visitQuantity(FHIRPathParser.QuantityContext ctx) {
+            print(ctx);
+            indentLevel++;
+            Object result = visitChildren(ctx);
+            indentLevel--;
+            return result;
+        }
+
+        @Override
+        public Object visitUnit(FHIRPathParser.UnitContext ctx) {
+            print(ctx);
+            indentLevel++;
+            Object result = visitChildren(ctx);
+            indentLevel--;
+            return result;
+        }
+
+        @Override
+        public Object visitDateTimePrecision(FHIRPathParser.DateTimePrecisionContext ctx) {
+            print(ctx);
+            indentLevel++;
+            Object result = visitChildren(ctx);
+            indentLevel--;
+            return result;
+        }
+
+        @Override
+        public Object visitPluralDateTimePrecision(FHIRPathParser.PluralDateTimePrecisionContext ctx) {
+            print(ctx);
+            indentLevel++;
+            Object result = visitChildren(ctx);
+            indentLevel--;
+            return result;
+        }
+
+        @Override
+        public Object visitTypeSpecifier(FHIRPathParser.TypeSpecifierContext ctx) {
+            print(ctx);
+            indentLevel++;
+            Object result = visitChildren(ctx);
+            indentLevel--;
+            return result;
+        }
+
+        @Override
+        public Object visitQualifiedIdentifier(FHIRPathParser.QualifiedIdentifierContext ctx) {
+            print(ctx);
+            indentLevel++;
+            Object result = visitChildren(ctx);
+            indentLevel--;
+            return result;
+        }
+
+        @Override
+        public Object visitIdentifier(FHIRPathParser.IdentifierContext ctx) {
+            print(ctx);
+            indentLevel++;
+            Object result = visitChildren(ctx);
+            indentLevel--;
+            return result;
+        }
+    }
+}
\ No newline at end of file