From 2b0d778767502a6b650de62d4ab56b46f2f4eea5 Mon Sep 17 00:00:00 2001 From: Grahame Grieve Date: Fri, 20 Oct 2023 16:26:46 +1100 Subject: [PATCH] Element.removeExtension (support for instance-name and instance-description extensions in IG publisher) --- .../org/hl7/fhir/r5/context/BaseWorkerContext.java | 2 +- .../java/org/hl7/fhir/r5/elementmodel/Element.java | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java index c03f2b92e..d83f572ea 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/context/BaseWorkerContext.java @@ -2546,7 +2546,7 @@ public abstract class BaseWorkerContext extends I18nBase implements IWorkerConte } } catch (Exception e) { // not sure what to do in this case? - System.out.println("Unable to generate snapshot @4 for "+p.getVersionedUrl()+": "+e.getMessage()); + System.out.println("Unable to generate snapshot @5 for "+p.getVersionedUrl()+": "+e.getMessage()); if (logger.isDebugLogging()) { e.printStackTrace(); } diff --git a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/Element.java b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/Element.java index bc73c401f..546dfd9a6 100644 --- a/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/Element.java +++ b/org.hl7.fhir.r5/src/main/java/org/hl7/fhir/r5/elementmodel/Element.java @@ -1488,4 +1488,15 @@ public class Element extends Base implements NamedItem { return this; } + public void removeExtension(String url) { + List rem = new ArrayList<>(); + for (Element e : children) { + if ("extension".equals(e.getName()) && url.equals(e.getChildValue("url"))) { + rem.add(e); + } + } + children.removeAll(rem); + } + + } \ No newline at end of file