From 1dd1c4ad9071d18c6ce93f1f2a8a39d8ca9a9891 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Sat, 5 Aug 2023 20:58:49 +1000 Subject: [PATCH] better error when extension URL not fixed --- .../java/org/hl7/fhir/utilities/i18n/I18nConstants.java | 1 + .../src/main/resources/Messages.properties | 2 ++ .../instance/type/StructureDefinitionValidator.java | 6 +++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/i18n/I18nConstants.java b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/i18n/I18nConstants.java index a961106212..c4494e86aa 100644 --- a/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/i18n/I18nConstants.java +++ b/org.hl7.fhir.utilities/src/main/java/org/hl7/fhir/utilities/i18n/I18nConstants.java @@ -955,6 +955,7 @@ public class I18nConstants { public static final String MSG_WITHDRAWN = "MSG_WITHDRAWN"; public static final String MSG_RETIRED = "MSG_RETIRED"; public static final String INACTIVE_CODE_WARNING = "INACTIVE_CODE_WARNING"; + public static final String SD_EXTENSION_URL_MISSING = "SD_EXTENSION_URL_MISSING"; } diff --git a/org.hl7.fhir.utilities/src/main/resources/Messages.properties b/org.hl7.fhir.utilities/src/main/resources/Messages.properties index 545e3ac014..5de2104e7b 100644 --- a/org.hl7.fhir.utilities/src/main/resources/Messages.properties +++ b/org.hl7.fhir.utilities/src/main/resources/Messages.properties @@ -1008,7 +1008,9 @@ FHIRPATH_COLLECTION_STATUS_OPERATION_RIGHT = The right side is inherently a coll FHIRPATH_OFTYPE_IMPOSSIBLE = The type specified in ofType is {1} which is not a possible candidate for the existing types ({0}) in the expression {2}. Check the paths and types to be sure this is what is intended ED_SEARCH_EXPRESSION_ERROR = Error in search expression ''{0}'': {1} SD_EXTENSION_URL_MISMATCH = The fixed value for the extension URL is {1} which doesn''t match the canonical URL {0} +SD_EXTENSION_URL_MISSING = The value of Extension.url is not fixed to the extension URL {0} MSG_DEPRECATED = Reference to deprecated item {0} MSG_WITHDRAWN = Reference to withdrawn item {0} MSG_RETIRED = Reference to retired item {0} INACTIVE_CODE_WARNING = The code ''{0}'' is valid but is not active +SD_ED_TYPE_PROFILE_WRONG_TYPE = The type {0} is not in the list of allowed types {1} in the profile {2} diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/type/StructureDefinitionValidator.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/type/StructureDefinitionValidator.java index b39da1e417..6ed6958fb1 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/type/StructureDefinitionValidator.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/validation/instance/type/StructureDefinitionValidator.java @@ -169,7 +169,11 @@ public boolean validateStructureDefinition(List errors, Eleme String baseD = src.getNamedChildValue("baseDefinition"); if ("http://hl7.org/fhir/StructureDefinition/Extension".equals(baseD) && url != null) { String fixedUrl = getFixedValue(src); - ok = rule(errors, "2023-05-27", IssueType.INVALID, stack.getLiteralPath(), url.equals(fixedUrl), I18nConstants.SD_EXTENSION_URL_MISMATCH, url, fixedUrl) && ok; + if (rule(errors, "2023-08-05", IssueType.INVALID, stack.getLiteralPath(), fixedUrl != null, I18nConstants.SD_EXTENSION_URL_MISSING, url)) { + ok = rule(errors, "2023-08-05", IssueType.INVALID, stack.getLiteralPath(), url.equals(fixedUrl), I18nConstants.SD_EXTENSION_URL_MISMATCH, url, fixedUrl) && ok; + } else { + ok = false; + } } } } catch (Exception e) {