Merge pull request #1339 from hapifhir/2023-07-gg-r5-invariants

fix issue checking invariant expressions in R5
This commit is contained in:
Grahame Grieve 2023-07-08 22:07:10 +10:00 committed by GitHub
commit 1384b143d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 16 deletions

View File

@ -485,22 +485,24 @@ public class StructureDefinitionValidator extends BaseValidator {
String source = invariant.getNamedChildValue("source"); String source = invariant.getNamedChildValue("source");
if (warning(errors, "2023-06-19", IssueType.INFORMATIONAL, stack, !Utilities.noString(key), I18nConstants.ED_INVARIANT_NO_KEY)) { if (warning(errors, "2023-06-19", IssueType.INFORMATIONAL, stack, !Utilities.noString(key), I18nConstants.ED_INVARIANT_NO_KEY)) {
if (hint(errors, "2023-06-19", IssueType.INFORMATIONAL, stack, !Utilities.noString(expression) || VersionUtilities.isR5Plus(context.getVersion()), I18nConstants.ED_INVARIANT_NO_EXPRESSION, key)) { // not for R5 - there's an invariant if (hint(errors, "2023-06-19", IssueType.INFORMATIONAL, stack, !Utilities.noString(expression) || VersionUtilities.isR5Plus(context.getVersion()), I18nConstants.ED_INVARIANT_NO_EXPRESSION, key)) { // not for R5 - there's an invariant
if (invariantMap.containsKey(key)) { if (!Utilities.noString(expression)) {
// it's legal - and common - for a list of elemnts to contain the same invariant more than once, but it's not valid if it's not always the same if (invariantMap.containsKey(key)) {
ok = rule(errors, "2023-06-19", IssueType.INVALID, stack, expression.equals(invariantMap.get(key)) || "ele-1".equals(key), I18nConstants.ED_INVARIANT_EXPRESSION_CONFLICT, key, expression, invariantMap.get(key)); // it's legal - and common - for a list of elemnts to contain the same invariant more than once, but it's not valid if it's not always the same
} else { ok = rule(errors, "2023-06-19", IssueType.INVALID, stack, expression.equals(invariantMap.get(key)) || "ele-1".equals(key), I18nConstants.ED_INVARIANT_EXPRESSION_CONFLICT, key, expression, invariantMap.get(key));
invariantMap.put(key, expression); } else {
} invariantMap.put(key, expression);
if (Utilities.noString(source) || (source.equals(profileUrl))) { // no need to revalidate FHIRPath from elsewhere }
try { if (Utilities.noString(source) || (source.equals(profileUrl))) { // no need to revalidate FHIRPath from elsewhere
// String upath = profileUrl+"#"+path; try {
fpe.check(invariant, rootPath, path, fpe.parse(expression)); // String upath = profileUrl+"#"+path;
} catch (Exception e) { fpe.check(invariant, rootPath, path, fpe.parse(expression));
if (debug) { } catch (Exception e) {
e.printStackTrace(); if (debug) {
} e.printStackTrace();
ok = rule(errors, "2023-06-19", IssueType.INVALID, stack, false, I18nConstants.ED_INVARIANT_EXPRESSION_ERROR, key, expression, e.getMessage()) && ok; }
} ok = rule(errors, "2023-06-19", IssueType.INVALID, stack, false, I18nConstants.ED_INVARIANT_EXPRESSION_ERROR, key, expression, e.getMessage()) && ok;
}
}
} }
} }
} }