Merge pull request #45 from lmckenzi/bad-bundle-reference-types
Bad bundle reference types
This commit is contained in:
commit
299014c606
|
@ -1810,10 +1810,10 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
|||
if (we == null) {
|
||||
refType = "remote";
|
||||
} else {
|
||||
refType = "bundle";
|
||||
refType = "bundled";
|
||||
}
|
||||
}
|
||||
ReferenceValidationPolicy pol = refType.equals("contained") || refType.equals("bundle") ? ReferenceValidationPolicy.CHECK_VALID : fetcher == null ? ReferenceValidationPolicy.IGNORE : fetcher.validationPolicy(hostContext.appContext, path, ref);
|
||||
ReferenceValidationPolicy pol = refType.equals("contained") || refType.equals("bundled") ? ReferenceValidationPolicy.CHECK_VALID : fetcher == null ? ReferenceValidationPolicy.IGNORE : fetcher.validationPolicy(hostContext.appContext, path, ref);
|
||||
|
||||
if (pol.checkExists()) {
|
||||
if (we == null) {
|
||||
|
@ -2182,6 +2182,7 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
|||
private Element getFromBundle(Element bundle, String ref, String fullUrl, List<ValidationMessage> errors, String path, String type) {
|
||||
String targetUrl = null;
|
||||
String version = "";
|
||||
String resourceType = null;
|
||||
if (ref.startsWith("http") || ref.startsWith("urn")) {
|
||||
// We've got an absolute reference, no need to calculate
|
||||
if (ref.contains("/_history/")) {
|
||||
|
@ -2218,10 +2219,13 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
|||
String id = null;
|
||||
if (ref.contains("/_history/")) {
|
||||
version = ref.substring(ref.indexOf("/_history/") + 10);
|
||||
id = ref.substring(0, ref.indexOf("/_history/")).split("/")[1];
|
||||
} else if (base.startsWith("urn"))
|
||||
String[] refBaseParts = ref.substring(0, ref.indexOf("/_history/")).split("/");
|
||||
resourceType = refBaseParts[0];
|
||||
id = refBaseParts[1];
|
||||
} else if (base.startsWith("urn")) {
|
||||
resourceType = ref.split("/")[0];
|
||||
id = ref.split("/")[1];
|
||||
else
|
||||
} else
|
||||
id = ref;
|
||||
|
||||
targetUrl = base + id;
|
||||
|
@ -2250,6 +2254,8 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat
|
|||
}
|
||||
}
|
||||
|
||||
if (match!=null && resourceType!=null)
|
||||
rule(errors, IssueType.REQUIRED, -1, -1, path, match.getType().equals(resourceType), "Matching reference for reference " + ref + " has resourceType " + match.getType());
|
||||
if (match == null)
|
||||
warning(errors, IssueType.REQUIRED, -1, -1, path, !ref.startsWith("urn"), "URN reference is not locally contained within the bundle " + ref);
|
||||
return match;
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Bundle xmlns="http://hl7.org/fhir">
|
||||
<type value="collection"/>
|
||||
<entry>
|
||||
<fullUrl value="urn:uuid:54fc3e09-e279-4b74-a8ff-2649ec968642"/>
|
||||
<resource>
|
||||
<Patient>
|
||||
<generalPractitioner>
|
||||
<reference value="Practitioner/5d9588d8-3cd6-4b32-8fb7-ad13694e069d"/>
|
||||
</generalPractitioner>
|
||||
</Patient>
|
||||
</resource>
|
||||
</entry>
|
||||
<entry>
|
||||
<fullUrl value="urn:uuid:5d9588d8-3cd6-4b32-8fb7-ad13694e069d"/>
|
||||
<resource>
|
||||
<Organization>
|
||||
<name value="foo"/>
|
||||
</Organization>
|
||||
</resource>
|
||||
</entry>
|
||||
</Bundle>
|
|
@ -746,6 +746,9 @@
|
|||
"source": "multi-profile-same-resource-profile.xml",
|
||||
"errorCount": 0
|
||||
}
|
||||
},
|
||||
"bad-bundle-reference-type.xml": {
|
||||
"errorCount": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue