Skip to content
This repository was archived by the owner on Oct 6, 2025. It is now read-only.

Commit 8146b52

Browse files
committed
fixed resource order in generated bundle, includes from search first
The change will result in observation reference in blood-gas-panel to occur first in the generated bundle and as such being created first.
1 parent e99f8f2 commit 8146b52

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

  • codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/client/fhir

codex-process-data-transfer/src/main/java/de/netzwerk_universitaetsmedizin/codex/processes/data_transfer/client/fhir/AbstractFhirClient.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.hl7.fhir.r4.model.Bundle.BundleEntryComponent;
3131
import org.hl7.fhir.r4.model.Bundle.BundleType;
3232
import org.hl7.fhir.r4.model.Bundle.HTTPVerb;
33+
import org.hl7.fhir.r4.model.Bundle.SearchEntryMode;
3334
import org.hl7.fhir.r4.model.DomainResource;
3435
import org.hl7.fhir.r4.model.IdType;
3536
import org.hl7.fhir.r4.model.Identifier;
@@ -587,9 +588,16 @@ protected Stream<DomainResource> getDomainResources(Bundle bundle)
587588

588589
private Stream<DomainResource> getDomainResourcesFromBundle(Bundle bundle)
589590
{
590-
return bundle.getEntry().stream().filter(BundleEntryComponent::hasResource)
591-
.map(BundleEntryComponent::getResource).filter(r -> r instanceof DomainResource)
592-
.map(r -> (DomainResource) r);
591+
// includes first
592+
return Stream.concat(
593+
bundle.getEntry().stream().filter(BundleEntryComponent::hasResource)
594+
.filter(e -> e.hasSearch() && SearchEntryMode.INCLUDE.equals(e.getSearch().getMode()))
595+
.map(BundleEntryComponent::getResource).filter(r -> r instanceof DomainResource)
596+
.map(r -> (DomainResource) r),
597+
bundle.getEntry().stream().filter(BundleEntryComponent::hasResource)
598+
.filter(e -> e.hasSearch() && SearchEntryMode.MATCH.equals(e.getSearch().getMode()))
599+
.map(BundleEntryComponent::getResource).filter(r -> r instanceof DomainResource)
600+
.map(r -> (DomainResource) r));
593601
}
594602

595603
private Stream<DomainResource> doGetDomainResources(String nextUrl, int subTotal)

0 commit comments

Comments
 (0)