Fixed problem with inconsistent values for refTypes

Check that when referencing resources by type/id when the target has a urn:uuid fullUrl that the type matches as well as the id.
This commit is contained in:
Lloyd McKenzie 2019-06-05 20:38:00 -04:00
parent 2a2005f93b
commit f44bb526c2
3 changed files with 36 additions and 5 deletions

View File

@ -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;

View File

@ -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>

View File

@ -746,6 +746,9 @@
"source": "multi-profile-same-resource-profile.xml",
"errorCount": 0
}
},
"bad-bundle-reference-type.xml": {
"errorCount": 1
}
}
}