Skip to content

Commit

Permalink
When autoloading document Bundles, read title from Composition (with …
Browse files Browse the repository at this point in the history
…getElement())
  • Loading branch information
adamzkover committed Nov 8, 2023
1 parent 0f74c31 commit a480c00
Showing 1 changed file with 6 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<BundleEntryComponent> 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<Element> 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)");
}
}
}
Expand Down

0 comments on commit a480c00

Please sign in to comment.