Get bundle documents from specific patient

Hi, when I have a bundle (type=document) stored on a FHIR server, is there a way to search for it with a GET request by using the patient identifier (which is for example stored in the Composition entry within the Bundle)? Thanks in advance!

There is if the server in question supports chaining to the degree needed



There are multiple possibilities, you need to understand the import policy on the server and the capabilities of the server.
One possibility is that the server will index any document bundles with DocumentReference resources. Thus you can search on DocumentReference given the patient.

Thanks for the responses! I’m currently having issues to search bundle documents by using the patient identifier. Would be thankful for any advice/help.

I tried using following GET request:
GET http://localhost:8080/fhir/Bundle?composition.patient.identifier=1111241261|urn:oid:
This is the response from the server:

  <id value="7513bedf-3d37-435b-9510-43d261b79d36"/>
    <lastUpdated value="2021-07-12T14:17:25.308+00:00"/>
  <type value="searchset"/>
  <total value="0"/>
    <relation value="self"/>
    <url value="http://localhost:8080/fhir/Bundle?composition.patient.identifier=1111241261%7Curn%3Aoid%3A1."/>

From the response which I’m getting from the server, I think it seems to be supported. What should the capability statement say, so that I know if the server supports chaining?

Here is a snippet of my document bundle:

<Bundle xmlns="">
   <id value="119"/>
      <versionId value="1"/>
      <lastUpdated value="2021-07-12T13:57:58.137+00:00"/>
      <source value="#LdZJwXP1fzVmATER"/>
   <type value="document"/>
   <timestamp value="2021-07-12T13:58:02+00:00"/>
      <fullUrl value="urn:uuid:cd326fbd-570f-43f6-b731-878be5abbb95"/>
         <Composition xmlns="">
            <language value="de-AT"/>
            <status value="preliminary"/>
                  <system value=""/>
                  <code value="60591-5"/>
                  <display value="Patient summary Document"/>
               <reference value="urn:uuid:33050ce1-c169-44cb-992f-12772313bcf5"/>
            <date value="2021-07-12T13:58:02+00:00"/>
               <reference value="urn:uuid:f330e2ca-7053-428e-820b-16bf89df8744"/>
            <title value="International Patient Summary"/>
            .... SECTIONS ....
      <fullUrl value="urn:uuid:33050ce1-c169-44cb-992f-12772313bcf5"/>
         <Patient xmlns="">
               <use value="usual"/>
                     <system value=""/>
                     <code value="SS"/>
                     <display value="Social Security number"/>
               <system value="urn:oid:"/>
               <value value="1111241261"/>
                  <display value="Dachverband der �sterreichischen Sozialversicherungstr�ger"/>
   .... remaining Entries from Composition ...

Should I insert a different path, so that the GET requests returns the bundle? (from the subject reference which is inside the composition?)

Thanks in advance!

From manual inspection, it seems like your search should have returned your document - you may need to take the issue up with the author of the server.

Would you know a public FHIR server which definitely supports the chaining functionality, so I can make also some tests on it?
Could it also be an issue that the entry resources from the bundle (for example patient) are not uploaded on the FHIR server separately? In my case only the bundle document is uploaded to the FHIR server.

Firely seems to -


Yes, Firely Server has support for chaining, and it should work. However, you have reversed the system and value in your query, and that is probably why you do not get results.
Try doing a GET http://localhost:8080/fhir/Bundle?composition.patient.identifier=urn:oid:|1111241261.


I also tried to change the request like that, but unfortunately I still get no results. Can it be that the reference from the Composition to the subject (Patient) is not correct so this being the reason why I dont receive the patient identifier with my search request?

I’m not sure what happens on a HAPI server, which I think you are using given the meta.source value. The public HAPI server does not like the chain in the search request, so it gives an OperationOutcome. But if you try this search on the public Firely Server, you get a result:|79121137740

You can see there is a difference in the references, which hold the actual resource type and id (for example Patient/patient1) and the Patient resource has an id value of patient1 as well, even though the fullUrls look similar to yours. On Firely Server, if you change the reference to an urn:uuid notation, the search no longer finds results. It would be worth a try to set your references to [resourceType]/[resourceId] plus add the resourceId to the resources and see if that resolves the problem.

Thanks a lot @mirjam will try this out on a Firely Server as well and update the ticket. What I was wondering, how exactly should references to resources within a bundle look like? I saw that in the bundle example you have entered the ressources fully (example: <reference value="" />). Is it okay if the reference is shortened <reference value="Patient/patient1" />?
Also btw:
I’m generating the Bundle with the FHIR Mapping Language and it seems to be not possible to add an id for the resources within the Bundle, when Bunde type is set to ‘document’. Should I therefore set the references to [resourceType]/[fullUrl of Resource within Bundle] (for example Patient/urn:uuid:7c16c9c0-c471-4098-ae18-48abcadd8d42)
As you mentioned the chaining would not work, but would this be semantically correct?

Yes, it is certainly okay to use the shortened form of the reference. Firely Server follows the FHIR standard that says a Bundle should have absolute references when the server responds, which is why you see the endpoint in those references.

Your example reference is not correct like that. It would have to be the urn:uuid only, or an actual id that follows the regex allowed for ids. With the Mapping Language imho it should be possible to set any field, so also id. Here’s an example of a map where the id field in Patient is set: FHIR Mapper - Tutorial (STU3) | FHIRMapperTutorial - Custom Resource to FHIR - SIMPLIFIER.NET.

about the ID generation within resources:
When bundle type=collection (as in the example), then it also generated the id’s for the resources, but when it is set to bundle type=document, then it seems to not generate them (at least thats how it works for me :confused: )

Since the ids are not generated in my case: a reference to the fullUrl without the ‘/Patient’ would be semantically correct, right? <reference value="urn:uuid:42dfc849-318a-423c-8dcd-90a54db0199e"/>