Add new validation to check these words in R3+: "Except for transactions and batches, each entry in a Bundle must have a fullUrl which is the identity of the resource in the entry"
This commit is contained in:
parent
1e16f02b48
commit
87e8f5a36a
|
@ -27,6 +27,7 @@ public class I18nConstants {
|
||||||
public static final String BUNDLE_BUNDLE_ENTRY_NOFIRST = "Bundle_BUNDLE_Entry_NoFirst";
|
public static final String BUNDLE_BUNDLE_ENTRY_NOFIRST = "Bundle_BUNDLE_Entry_NoFirst";
|
||||||
public static final String BUNDLE_BUNDLE_ENTRY_NOFIRSTRESOURCE = "Bundle_BUNDLE_Entry_NoFirstResource";
|
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_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 = "Bundle_BUNDLE_Entry_NoProfile";
|
||||||
public static final String BUNDLE_BUNDLE_ENTRY_MULTIPLE_PROFILES = "BUNDLE_BUNDLE_ENTRY_MULTIPLE_PROFILES";
|
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_NOTFOUND = "Bundle_BUNDLE_Entry_NotFound";
|
||||||
|
|
|
@ -7,6 +7,7 @@ Bundle_BUNDLE_Entry_MismatchIdUrl = The canonical URL ({0}) cannot match the ful
|
||||||
Bundle_BUNDLE_Entry_NoFirst = Documents or Messages must contain at least one entry
|
Bundle_BUNDLE_Entry_NoFirst = Documents or Messages must contain at least one entry
|
||||||
Bundle_BUNDLE_Entry_NoFirstResource = No resource on first entry
|
Bundle_BUNDLE_Entry_NoFirstResource = No resource on first entry
|
||||||
Bundle_BUNDLE_Entry_NoFullUrl = Bundle entry missing fullUrl
|
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 = No profile found for contained resource of type ''{0}''
|
||||||
Bundle_BUNDLE_Entry_NotFound = Can''t find ''{0}'' in the bundle ({1})
|
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_Orphan = Entry {0} isn''t reachable by traversing from first Bundle entry
|
||||||
|
|
|
@ -79,6 +79,8 @@ public class BundleValidator extends BaseValidator{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
Map<String, Integer> counter = new HashMap<>();
|
Map<String, Integer> counter = new HashMap<>();
|
||||||
|
|
||||||
|
boolean fullUrlOptional = Utilities.existsInList(type, "transaction", "transaction-response", "batch", "batch-response");
|
||||||
|
|
||||||
for (Element entry : entries) {
|
for (Element entry : entries) {
|
||||||
NodeStack estack = stack.push(entry, count, null, null);
|
NodeStack estack = stack.push(entry, count, null, null);
|
||||||
String fullUrl = entry.getNamedChildValue(FULL_URL);
|
String fullUrl = entry.getNamedChildValue(FULL_URL);
|
||||||
|
@ -90,6 +92,9 @@ public class BundleValidator extends BaseValidator{
|
||||||
rule(errors, IssueType.INVALID, entry.line(), entry.col(), stack.addToLiteralPath(ENTRY, PATH_ARG), !url.equals(fullUrl) || serverBase == null || (url.equals(Utilities.pathURL(serverBase, entry.getNamedChild(RESOURCE).fhirType(), id))), I18nConstants.BUNDLE_BUNDLE_ENTRY_CANONICAL, url, fullUrl);
|
rule(errors, IssueType.INVALID, entry.line(), entry.col(), stack.addToLiteralPath(ENTRY, PATH_ARG), !url.equals(fullUrl) || serverBase == null || (url.equals(Utilities.pathURL(serverBase, entry.getNamedChild(RESOURCE).fhirType(), id))), I18nConstants.BUNDLE_BUNDLE_ENTRY_CANONICAL, url, fullUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!VersionUtilities.isR2Ver(context.getVersion())) {
|
||||||
|
rule(errors, IssueType.INVALID, entry.line(), entry.col(), estack.getLiteralPath(), fullUrlOptional || fullUrl != null, I18nConstants.BUNDLE_BUNDLE_ENTRY_FULLURL_REQUIRED);
|
||||||
|
}
|
||||||
// check bundle profile requests
|
// check bundle profile requests
|
||||||
if (entry.hasChild(RESOURCE)) {
|
if (entry.hasChild(RESOURCE)) {
|
||||||
String rtype = entry.getNamedChild(RESOURCE).fhirType();
|
String rtype = entry.getNamedChild(RESOURCE).fhirType();
|
||||||
|
|
Loading…
Reference in New Issue