fix error in FHIRPath handling for incomplete FHIR Path expressions

This commit is contained in:
Grahame Grieve 2022-01-12 17:44:11 +11:00
parent ecad7cc5f8
commit 7d3f34b0ca
5 changed files with 10 additions and 4 deletions

View File

@ -519,5 +519,8 @@ public class FHIRLexer {
public int getCurrentStart() {
return currentStart;
}
public String getSource() {
return source;
}
}

View File

@ -1000,7 +1000,9 @@ public class FHIRPathEngine {
wrapper.setProximal(proximal);
}
if (lexer.isConstant()) {
if (lexer.getCurrent() == null) {
throw lexer.error("Expression terminated unexpectedly");
} else if (lexer.isConstant()) {
boolean isString = lexer.isStringConstant();
if (!isString && (lexer.getCurrent().startsWith("-") || lexer.getCurrent().startsWith("+"))) {
// the grammar says that this is a unary operation; it affects the correct processing order of the inner operations

View File

@ -246,7 +246,7 @@ All_observations_should_have_a_performer = All observations should have a perfor
All_observations_should_have_a_subject = All observations should have a subject
Unable_to_resolve_slice_matching__no_fixed_value_or_required_value_set = Unable to resolve slice matching - no fixed value or required value set
Unable_to_resolve_slice_matching__slice_matching_by_value_set_not_done = Unable to resolve slice matching - slice matching by value set not done
Problem_processing_expression__in_profile__path__ = Problem processing expression {0} in profile {1} path {2}: {3}
Problem_processing_expression__in_profile__path__ = Problem processing expression ''{0}'' in profile ''{1}'' at path ''{2}'': {3}
Unable_to_find_element_with_id_ = Unable to find element with id ''{0}''
Slice_encountered_midway_through_set_path___id___ = Slice encountered midway through set (path = {0}, id = {1}); {2}
Unable_to_resolve_actual_type_ = Unable to resolve actual type {0}

View File

@ -5490,7 +5490,8 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
try {
n = fpe.parse(fixExpr(inv.getExpression(), inv.getKey()));
} catch (FHIRLexerException e) {
throw new FHIRException(context.formatMessage(I18nConstants.PROBLEM_PROCESSING_EXPRESSION__IN_PROFILE__PATH__, inv.getExpression(), profile.getUrl(), path, e.getMessage()));
rule(errors, IssueType.INVARIANT, element.line(), element.col(), path, false, I18nConstants.PROBLEM_PROCESSING_EXPRESSION__IN_PROFILE__PATH__, inv.getExpression(), profile.getUrl(), path, e.getMessage());
return;
}
timeTracker.fpe(t);
inv.setUserData("validator.expression.cache", n);

View File

@ -19,7 +19,7 @@
<properties>
<hapi_fhir_version>5.1.0</hapi_fhir_version>
<validator_test_case_version>1.1.86</validator_test_case_version>
<validator_test_case_version>1.1.87-SNAPSHOT</validator_test_case_version>
<junit_jupiter_version>5.7.1</junit_jupiter_version>
<junit_platform_launcher_version>1.7.1</junit_platform_launcher_version>
<maven_surefire_version>3.0.0-M5</maven_surefire_version>