From 98f218fe781722a7a845c1f0ce40aae9f11c136f Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Wed, 22 Dec 2021 22:39:54 +1100 Subject: [PATCH] Improved Error messages validating bundle entries --- .../java/org/hl7/fhir/r5/elementmodel/Element.java | 10 ++++++++++ .../org/hl7/fhir/utilities/i18n/I18nConstants.java | 3 ++- .../src/main/resources/Messages.properties | 7 ++++--- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/Element.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/Element.java index c46e85c01..86dc38ea3 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/Element.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/Element.java @@ -86,6 +86,16 @@ public class Element extends Base { return CONTAINED; throw new FHIRException("Unknown resource containing a native resource: "+property.getDefinition().getId()); } + + public String toHuman() { + switch (this) { + case BUNDLE_ENTRY: return "entry"; + case BUNDLE_OUTCOME: return "outcome"; + case CONTAINED: return "contained"; + case PARAMETER: return "parameter"; + default: return "??"; + } + } } private List comments;// not relevant for production, but useful in documentation 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 5deaf2ba9..2a60d01e9 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 @@ -29,7 +29,8 @@ public class I18nConstants { public static final String BUNDLE_BUNDLE_ENTRY_NOFIRSTRESOURCE = "Bundle_BUNDLE_Entry_NoFirstResource"; public static final String BUNDLE_BUNDLE_ENTRY_NOFULLURL = "Bundle_BUNDLE_Entry_NoFullUrl"; public static final String BUNDLE_BUNDLE_ENTRY_FULLURL_REQUIRED = "BUNDLE_BUNDLE_ENTRY_FULLURL_REQUIRED"; - public static final String BUNDLE_BUNDLE_ENTRY_NOPROFILE = "Bundle_BUNDLE_Entry_NoProfile"; + public static final String BUNDLE_BUNDLE_ENTRY_NOPROFILE_EXPL = "Bundle_BUNDLE_Entry_NoProfile_EXPL"; + public static final String BUNDLE_BUNDLE_ENTRY_NOPROFILE_TYPE = "Bundle_BUNDLE_Entry_NoProfile_TYPE"; public static final String BUNDLE_BUNDLE_ENTRY_MULTIPLE_PROFILES = "BUNDLE_BUNDLE_ENTRY_MULTIPLE_PROFILES"; public static final String BUNDLE_BUNDLE_ENTRY_NOTFOUND = "Bundle_BUNDLE_Entry_NotFound"; public static final String BUNDLE_BUNDLE_ENTRY_ORPHAN = "Bundle_BUNDLE_Entry_Orphan"; diff --git a/org.hl7.fhir.utilities/src/main/resources/Messages.properties b/org.hl7.fhir.utilities/src/main/resources/Messages.properties index 0d5935dcb..146063cba 100644 --- a/org.hl7.fhir.utilities/src/main/resources/Messages.properties +++ b/org.hl7.fhir.utilities/src/main/resources/Messages.properties @@ -8,7 +8,8 @@ Bundle_BUNDLE_Entry_NoFirst = Documents or Messages must contain at least one en Bundle_BUNDLE_Entry_NoFirstResource = No resource on first entry Bundle_BUNDLE_Entry_NoFullUrl = Bundle entry missing fullUrl BUNDLE_BUNDLE_ENTRY_FULLURL_REQUIRED = Except for transactions and batches, each entry in a Bundle must have a fullUrl which is the identity of the resource in the entry -Bundle_BUNDLE_Entry_NoProfile = No profile found for contained resource of type ''{0}'' +Bundle_BUNDLE_Entry_NoProfile_TYPE = No profile found for {0} resource of type ''{1}'' +Bundle_BUNDLE_Entry_NoProfile_EXPL = Specified profile {2} not found for {0} resource of type ''{0}'' Bundle_BUNDLE_Entry_NotFound = Can''t find ''{0}'' in the bundle ({1}) Bundle_BUNDLE_Entry_Orphan = Entry {0} isn''t reachable by traversing from first Bundle entry BUNDLE_BUNDLE_ENTRY_REVERSE = Entry {0} isn''t reachable by traversing forwards from first Bundle entry, and isn''t a resource type that is typically used that way - check this is not missed somewhere @@ -225,7 +226,7 @@ Validation_VAL_Profile_NoCheckMin = {2}: Unable to check minimum required ({1}) Validation_VAL_Profile_MultipleMatches = Found multiple matching profiles among choices: {0} Validation_VAL_Profile_NoDefinition = No definition found for resource type ''{0}'' Validation_VAL_Profile_NoMatch = Unable to find a match for the specified profile among choices: {0} -Validation_VAL_Profile_NoSnapshot = StructureDefinition has no snapshot - validation is against the snapshot, so it must be provided +Validation_VAL_Profile_NoSnapshot = StructureDefinition {0} has no snapshot - validation is against the snapshot, so it must be provided Validation_VAL_Profile_NoType = The type of element {0} is not known, which is illegal. Valid types at this point are {1} Validation_VAL_Profile_NotAllowed = This element is not allowed by the profile {0} Validation_VAL_Profile_NotSlice = This element does not match any known slice {0} and slicing is CLOSED: {1} @@ -589,7 +590,7 @@ SD_MUST_HAVE_DERIVATION = StructureDefinition {0} must have a derivation, since VALIDATION_VAL_PROFILE_OTHER_VERSION = Profile is for a different version of FHIR ({0}) so has been ignored VALIDATION_VAL_PROFILE_THIS_VERSION_OK = Profile for this version of FHIR - all OK VALIDATION_VAL_PROFILE_THIS_VERSION_OTHER = Profile is for this version of FHIR, but is an invalid type {0} -BUNDLE_BUNDLE_ENTRY_MULTIPLE_PROFILES = Multiple profiles found for contained resource. This is not supported at this time. (Type {0}: {1}) +BUNDLE_BUNDLE_ENTRY_MULTIPLE_PROFILES = Multiple profiles found for {0} resource. This is not supported at this time. (Type {1}: {2}) RENDER_BUNDLE_HEADER_ROOT = Bundle {0} of type {1} RENDER_BUNDLE_HEADER_ENTRY = Entry {0} RENDER_BUNDLE_HEADER_ENTRY_URL = Entry {0} - Full URL = {1}