From 00f3dfc4b943d312d6e52aa8d7ac1a91bfb5feb1 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Fri, 3 Dec 2021 15:25:54 +1100 Subject: [PATCH] set up release --- RELEASE_NOTES.md | 1 + .../hl7/fhir/r5/utils/ToolingExtensions.java | 23 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index e69de29bb..43f4d6510 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -0,0 +1 @@ +* Add usesExtension to ToolingExtensions diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/ToolingExtensions.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/ToolingExtensions.java index a107dfc26..2c40dff4d 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/ToolingExtensions.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/utils/ToolingExtensions.java @@ -69,7 +69,9 @@ import java.util.Map; import org.apache.commons.lang3.StringUtils; import org.fhir.ucum.Utilities; import org.hl7.fhir.exceptions.FHIRException; +import org.hl7.fhir.r5.model.Base; import org.hl7.fhir.r5.model.BooleanType; +import org.hl7.fhir.r5.model.CanonicalResource; import org.hl7.fhir.r5.model.CanonicalType; import org.hl7.fhir.r5.model.CodeSystem.ConceptDefinitionComponent; import org.hl7.fhir.r5.model.CodeType; @@ -89,6 +91,7 @@ import org.hl7.fhir.r5.model.IntegerType; import org.hl7.fhir.r5.model.MarkdownType; import org.hl7.fhir.r5.model.OperationOutcome.OperationOutcomeIssueComponent; import org.hl7.fhir.r5.model.PrimitiveType; +import org.hl7.fhir.r5.model.Property; import org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemComponent; import org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType; import org.hl7.fhir.r5.model.StringType; @@ -900,5 +903,25 @@ public class ToolingExtensions { dr.getExtension().add(Factory.newExtension(url, new UriType(value), true)); } + public static boolean usesExtension(String url, Base base) { + if ("Extension".equals(base.fhirType())) { + Property p = base.getNamedProperty("url"); + for (Base b : p.getValues()) { + if (url.equals(b.primitiveValue())) { + return true; + } + } + } + + for (Property p : base.children() ) { + for (Base v : p.getValues()) { + if (usesExtension(url, v)) { + return true; + } + } + } + return false; + } + } \ No newline at end of file