From 7c1786279f87838a285cf4fef3dcf393420f90f1 Mon Sep 17 00:00:00 2001 From: Lloyd McKenzie Date: Tue, 30 Jul 2019 23:23:48 -0600 Subject: [PATCH] Fix problem with link resolution within Bundles - and add test case that checks it. (Also update Synthea test case to reflect new status codes for Encounter.) --- .../fhir/r5/validation/InstanceValidator.java | 5 ++- .../validation-examples/bundle-local-refs.xml | 45 +++++++++++++++++++ .../validation-examples/manifest.json | 4 ++ .../validation-examples/synthea.json | 2 +- 4 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 org.hl7.fhir.validation/src/test/resources/validation-examples/bundle-local-refs.xml diff --git a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/InstanceValidator.java b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/InstanceValidator.java index c9bdf12d8..e26b2b636 100644 --- a/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/InstanceValidator.java +++ b/org.hl7.fhir.validation/src/main/java/org/hl7/fhir/r5/validation/InstanceValidator.java @@ -2527,14 +2527,15 @@ public class InstanceValidator extends BaseValidator implements IResourceValidat String u = null; if (fullUrl != null && fullUrl.endsWith(type+"/"+id)) // fullUrl = complex - u = fullUrl.substring((type+"/"+id).length())+ref; + u = fullUrl.substring(0, fullUrl.length() - (type+"/"+id).length())+ref; +// u = fullUrl.substring((type+"/"+id).length())+ref; String[] parts = ref.split("\\/"); if (parts.length >= 2) { String t = parts[0]; String i = parts[1]; for (Element entry : entries) { String fu = entry.getNamedChildValue("fullUrl"); - if (u != null && fullUrl.equals(u)) + if (u != null && fu.equals(u)) return entry; if (u == null) { Element resource = entry.getNamedChild("resource"); diff --git a/org.hl7.fhir.validation/src/test/resources/validation-examples/bundle-local-refs.xml b/org.hl7.fhir.validation/src/test/resources/validation-examples/bundle-local-refs.xml new file mode 100644 index 000000000..5e123eddf --- /dev/null +++ b/org.hl7.fhir.validation/src/test/resources/validation-examples/bundle-local-refs.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + </Composition> + </resource> + </entry> + <entry> + <fullUrl value="http://example.org/fhir/Patient/1"/> + <resource> + <Patient> + <id value="1"/> + <name> + <family value="SMITH"/> + <given value="JOE"/> + </name> + </Patient> + </resource> + </entry> +</Bundle> diff --git a/org.hl7.fhir.validation/src/test/resources/validation-examples/manifest.json b/org.hl7.fhir.validation/src/test/resources/validation-examples/manifest.json index e42401c5c..3caa7cc76 100644 --- a/org.hl7.fhir.validation/src/test/resources/validation-examples/manifest.json +++ b/org.hl7.fhir.validation/src/test/resources/validation-examples/manifest.json @@ -790,6 +790,10 @@ "source": "azatadha/param-profile.xml", "errorCount": 0 } + }, + "bundle-local-refs.xml" : { + "errorCount": 0, + "warningCount": 0 } } } diff --git a/org.hl7.fhir.validation/src/test/resources/validation-examples/synthea.json b/org.hl7.fhir.validation/src/test/resources/validation-examples/synthea.json index b7693ffde..988725669 100644 --- a/org.hl7.fhir.validation/src/test/resources/validation-examples/synthea.json +++ b/org.hl7.fhir.validation/src/test/resources/validation-examples/synthea.json @@ -17,7 +17,7 @@ "value": "v6751" } ], - "status": "finished", + "status": "completed", "subject": { "reference": "Patient/f001", "display": "P. van de Heuvel"