From e8e8c1af4e201f5fd21e08d7efb8633e3cdbff89 Mon Sep 17 00:00:00 2001 From: Lloyd McKenzie Date: Sat, 13 Apr 2019 17:11:12 -0600 Subject: [PATCH] Fixed problem where discriminators containing the extension function didn't properly look for fixed value in the profile but instead always went to the extension definition. --- .../org/hl7/fhir/r5/utils/FHIRPathEngine.java | 10 ++-- .../extension-slice-profile.xml | 47 +++++++++++++++++++ .../validation-examples/extension-slice.xml | 13 +++++ .../validation-examples/manifest.json | 7 +++ 4 files changed, 73 insertions(+), 4 deletions(-) create mode 100644 org.hl7.fhir.validation/src/test/resources/validation-examples/extension-slice-profile.xml create mode 100644 org.hl7.fhir.validation/src/test/resources/validation-examples/extension-slice.xml diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/FHIRPathEngine.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/FHIRPathEngine.java index c86f2fa98..33bd3bf81 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/FHIRPathEngine.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/FHIRPathEngine.java @@ -4145,10 +4145,12 @@ public class FHIRPathEngine { List childDefinitions = ProfileUtilities.getChildMap(sd, element); for (ElementDefinition t : childDefinitions) { if (t.getPath().endsWith(".extension") && t.hasSliceName()) { - sd = worker.fetchResource(StructureDefinition.class, t.getType().get(0).getProfile().get(0).getValue()); - while (sd!=null && !sd.getBaseDefinition().equals("http://hl7.org/fhir/StructureDefinition/Extension")) - sd = worker.fetchResource(StructureDefinition.class, sd.getBaseDefinition()); - if (sd.getUrl().equals(targetUrl)) { + StructureDefinition exsd = worker.fetchResource(StructureDefinition.class, t.getType().get(0).getProfile().get(0).getValue()); + while (exsd!=null && !exsd.getBaseDefinition().equals("http://hl7.org/fhir/StructureDefinition/Extension")) + exsd = worker.fetchResource(StructureDefinition.class, exsd.getBaseDefinition()); + if (exsd.getUrl().equals(targetUrl)) { + if (ProfileUtilities.getChildMap(sd, t).isEmpty()) + sd = exsd; focus = t; break; } diff --git a/org.hl7.fhir.validation/src/test/resources/validation-examples/extension-slice-profile.xml b/org.hl7.fhir.validation/src/test/resources/validation-examples/extension-slice-profile.xml new file mode 100644 index 000000000..613ee17b4 --- /dev/null +++ b/org.hl7.fhir.validation/src/test/resources/validation-examples/extension-slice-profile.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/org.hl7.fhir.validation/src/test/resources/validation-examples/extension-slice.xml b/org.hl7.fhir.validation/src/test/resources/validation-examples/extension-slice.xml new file mode 100644 index 000000000..4fa5a6581 --- /dev/null +++ b/org.hl7.fhir.validation/src/test/resources/validation-examples/extension-slice.xml @@ -0,0 +1,13 @@ + + + + +
+
+
+ + + + + +
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 9a560d816..b869d73ae 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 @@ -460,6 +460,13 @@ "version" : "3.0", "questionnaire" : "questionnaire-enableWhen-test3.xml", "errorCount": 0 + }, + "extension-slice.xml" : { + "errorCount": 0, + "profile" : { + "source" : "extension-slice-profile.xml", + "errorCount": 0 + } } } }