From 43253e8d10528921a45c01ab8668a92016e49806 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Sun, 12 Mar 2023 21:53:38 +1100 Subject: [PATCH] improve extension representation --- .../hl7/fhir/r5/conformance/profile/ProfileUtilities.java | 8 ++++++++ .../java/org/hl7/fhir/r5/model/StructureDefinition.java | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/profile/ProfileUtilities.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/profile/ProfileUtilities.java index 3864901c3..9b32e57e4 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/profile/ProfileUtilities.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/conformance/profile/ProfileUtilities.java @@ -3906,5 +3906,13 @@ public class ProfileUtilities extends TranslatingUtilities { this.allowUnknownProfile = allowUnknownProfile; } + public static boolean isSimpleExtension(StructureDefinition sd) { + if (!isExtensionDefinition(sd)) { + return false; + } + ElementDefinition value = sd.getSnapshot().getElementByPath("Extension.value"); + return value != null && !value.isProhibited(); + } + } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/StructureDefinition.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/StructureDefinition.java index 912ae8444..0861ad248 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/StructureDefinition.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/model/StructureDefinition.java @@ -1234,8 +1234,11 @@ public class StructureDefinition extends CanonicalResource { // added from java-adornments.txt: public ElementDefinition getElementByPath(String path) { + if (path == null) { + return null; + } for (ElementDefinition ed : getElement()) { - if (path.equals(ed.getPath())) { + if (path.equals(ed.getPath()) || (path+"[x]").equals(ed.getPath())) { return ed; } }