From 0f74c312ebb220febb3d81e37ece11bb4550c709 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81d=C3=A1m=20Z=2E=20K=C3=B6v=C3=A9r?= Date: Wed, 8 Nov 2023 09:40:30 +0100 Subject: [PATCH 1/2] When autoloading document Bundles, read title from Composition --- .../hl7/fhir/igtools/publisher/Publisher.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/org.hl7.fhir.publisher.core/src/main/java/org/hl7/fhir/igtools/publisher/Publisher.java b/org.hl7.fhir.publisher.core/src/main/java/org/hl7/fhir/igtools/publisher/Publisher.java index 203385434..f6300d6d1 100644 --- a/org.hl7.fhir.publisher.core/src/main/java/org/hl7/fhir/igtools/publisher/Publisher.java +++ b/org.hl7.fhir.publisher.core/src/main/java/org/hl7/fhir/igtools/publisher/Publisher.java @@ -183,6 +183,7 @@ import org.hl7.fhir.r5.model.CodeType; import org.hl7.fhir.r5.model.CodeableConcept; import org.hl7.fhir.r5.model.Coding; +import org.hl7.fhir.r5.model.Composition; import org.hl7.fhir.r5.model.ConceptMap; import org.hl7.fhir.r5.model.ConceptMap.ConceptMapGroupComponent; import org.hl7.fhir.r5.model.Constants; @@ -4773,7 +4774,21 @@ private boolean load() throws Exception { rg.setName(r.getElement().getExtensionValue(ToolingExtensions.EXT_ARTIFACT_NAME).primitiveValue()); } else if (!rg.hasName()) { if (r.getElement().hasChild("title")) { - rg.setName(r.getElement().getChildValue("title")); + rg.setName(r.getElement().getChildValue("title")); + } else if (r.getResource() instanceof Bundle) { + // If the resource is a document Bundle, get the title from the Composition + Bundle bundle = (Bundle) r.getResource(); + if (BundleType.DOCUMENT == bundle.getType()) { + List entryList = bundle.getEntry(); + if (entryList != null && !entryList.isEmpty()) { + BundleEntryComponent entryComponent = entryList.get(0); + Resource entryResource = entryComponent.getResource(); + if (entryResource instanceof Composition) { + Composition composition = (Composition) entryResource; + rg.setName(composition.getTitle() + " (Bundle)"); + } + } + } } } if (r.getElement().hasExtension(ToolingExtensions.EXT_RESOURCE_DESC)) { From a480c00731c976cc5c7e282dfa019d485393697f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81d=C3=A1m=20Z=2E=20K=C3=B6v=C3=A9r?= Date: Wed, 8 Nov 2023 16:01:26 +0100 Subject: [PATCH 2/2] When autoloading document Bundles, read title from Composition (with getElement()) --- .../hl7/fhir/igtools/publisher/Publisher.java | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/org.hl7.fhir.publisher.core/src/main/java/org/hl7/fhir/igtools/publisher/Publisher.java b/org.hl7.fhir.publisher.core/src/main/java/org/hl7/fhir/igtools/publisher/Publisher.java index f6300d6d1..c90a54645 100644 --- a/org.hl7.fhir.publisher.core/src/main/java/org/hl7/fhir/igtools/publisher/Publisher.java +++ b/org.hl7.fhir.publisher.core/src/main/java/org/hl7/fhir/igtools/publisher/Publisher.java @@ -183,7 +183,6 @@ import org.hl7.fhir.r5.model.CodeType; import org.hl7.fhir.r5.model.CodeableConcept; import org.hl7.fhir.r5.model.Coding; -import org.hl7.fhir.r5.model.Composition; import org.hl7.fhir.r5.model.ConceptMap; import org.hl7.fhir.r5.model.ConceptMap.ConceptMapGroupComponent; import org.hl7.fhir.r5.model.Constants; @@ -4775,18 +4774,13 @@ private boolean load() throws Exception { } else if (!rg.hasName()) { if (r.getElement().hasChild("title")) { rg.setName(r.getElement().getChildValue("title")); - } else if (r.getResource() instanceof Bundle) { + } else if ("Bundle".equals(r.getElement().getName())) { // If the resource is a document Bundle, get the title from the Composition - Bundle bundle = (Bundle) r.getResource(); - if (BundleType.DOCUMENT == bundle.getType()) { - List entryList = bundle.getEntry(); - if (entryList != null && !entryList.isEmpty()) { - BundleEntryComponent entryComponent = entryList.get(0); - Resource entryResource = entryComponent.getResource(); - if (entryResource instanceof Composition) { - Composition composition = (Composition) entryResource; - rg.setName(composition.getTitle() + " (Bundle)"); - } + List entryList = r.getElement().getChildren("entry"); + if (entryList != null && !entryList.isEmpty()) { + Element resource = entryList.get(0).getNamedChild("resource"); + if (resource != null) { + rg.setName(resource.getChildValue("title") + " (Bundle)"); } } }