Fix handling resources in bundles when type is profiled
This commit is contained in:
parent
e33ffca749
commit
fa778fbf03
|
@ -10,8 +10,8 @@ Bundle_BUNDLE_Entry_NoFullUrl = Bundle entry missing fullUrl
|
||||||
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
|
||||||
Bundle_BUNDLE_Entry_Type = The type ''{0}'' is not valid - no resources allowed here
|
Bundle_BUNDLE_Entry_Type = The type ''{0}'' is not valid - no resources allowed here (allowed = {1})
|
||||||
Bundle_BUNDLE_Entry_Type2 = The type ''{0}'' is not valid - must be {1}
|
Bundle_BUNDLE_Entry_Type2 = The type ''{0}'' is not valid - must be {1} (allowed = {2})
|
||||||
Bundle_BUNDLE_Entry_Type3 = The type ''{0}'' is not valid - must be one of {1}
|
Bundle_BUNDLE_Entry_Type3 = The type ''{0}'' is not valid - must be one of {1}
|
||||||
Bundle_BUNDLE_FullUrl_Missing = Relative Reference appears inside Bundle whose entry is missing a fullUrl
|
Bundle_BUNDLE_FullUrl_Missing = Relative Reference appears inside Bundle whose entry is missing a fullUrl
|
||||||
Bundle_BUNDLE_FullUrl_NeedVersion = Entries matching fullURL {0} should declare meta/versionId because there are version-specific references
|
Bundle_BUNDLE_FullUrl_NeedVersion = Entries matching fullURL {0} should declare meta/versionId because there are version-specific references
|
||||||
|
|
|
@ -3943,15 +3943,17 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
||||||
private void validateContains(ValidatorHostContext hostContext, List<ValidationMessage> errors, String path, ElementDefinition child, ElementDefinition context, Element resource, Element element, NodeStack stack, IdStatus idstatus) throws FHIRException {
|
private void validateContains(ValidatorHostContext hostContext, List<ValidationMessage> errors, String path, ElementDefinition child, ElementDefinition context, Element resource, Element element, NodeStack stack, IdStatus idstatus) throws FHIRException {
|
||||||
String resourceName = element.getType();
|
String resourceName = element.getType();
|
||||||
TypeRefComponent trr = null;
|
TypeRefComponent trr = null;
|
||||||
|
CommaSeparatedStringBuilder bt = new CommaSeparatedStringBuilder();
|
||||||
for (TypeRefComponent tr : child.getType()) {
|
for (TypeRefComponent tr : child.getType()) {
|
||||||
if (tr.getCode().equals("Resource")) {
|
bt.append(tr.getCode());
|
||||||
|
if (tr.getCode().equals("Resource") || tr.getCode().equals(resourceName) ) {
|
||||||
trr = tr;
|
trr = tr;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stack.qualifyPath(".ofType("+resourceName+")");
|
stack.qualifyPath(".ofType("+resourceName+")");
|
||||||
if (trr == null) {
|
if (trr == null) {
|
||||||
rule(errors, IssueType.INFORMATIONAL, element.line(), element.col(), stack.getLiteralPath(), false, I18nConstants.BUNDLE_BUNDLE_ENTRY_TYPE, resourceName);
|
rule(errors, IssueType.INFORMATIONAL, element.line(), element.col(), stack.getLiteralPath(), false, I18nConstants.BUNDLE_BUNDLE_ENTRY_TYPE, resourceName, bt.toString());
|
||||||
} else if (isValidResourceType(resourceName, trr)) {
|
} else if (isValidResourceType(resourceName, trr)) {
|
||||||
// special case: resource wrapper is reset if we're crossing a bundle boundary, but not otherwise
|
// special case: resource wrapper is reset if we're crossing a bundle boundary, but not otherwise
|
||||||
ValidatorHostContext hc = null;
|
ValidatorHostContext hc = null;
|
||||||
|
@ -4002,7 +4004,10 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isValidResourceType(String type, TypeRefComponent def) {
|
private boolean isValidResourceType(String type, TypeRefComponent def) {
|
||||||
if (!def.hasProfile()) {
|
if (!def.hasProfile() && def.getCode().equals("Resource")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (def.getCode().equals(type)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
List<StructureDefinition> list = new ArrayList<>();
|
List<StructureDefinition> list = new ArrayList<>();
|
||||||
|
|
Loading…
Reference in New Issue