FHIR Chat · Relative reference between transaction bundle entries · implementers

Stream: implementers

Topic: Relative reference between transaction bundle entries


view this post on Zulip Yan Wang (May 27 2020 at 13:01):

Is it recommended to use fullUrl instead of relative url for reference between transaction bundle entries ? The hl7 spec says:

2.36.4 Resource URL & Uniqueness rules in a bundle
Except for transactions and batches, each entry in a Bundle must have a fullUrl which is the identity of the resource in the entry. Note that this is not a versioned reference to the resource, but its identity. Where a resource is not assigned a persistent identity that can be used in the Bundle, a UUID should be used (urn:uuid:...).

For transactions and batches, entries MAY not have fullURLs when the entry.request.method = POST, and the resource has no identity. Note that even in this case, there may still be a fullURL in a transaction on a POST so that relationships between resources can be represented (see Transactions).

And 2.36.4.1 Resolving references in Bundles

  • If the reference is not an absolute reference, convert it to an absolute URL:
    • if the reference has the format [type]/[id], and
    • if the fullUrl for the bundle entry containing the resource is a RESTful one (see the RESTful URL regex)
      • extract the [root] from the fullUrl, and append the reference (type/id) to it
      • then try to resolve within the bundle as for a RESTful URL reference.
      • If no resolution is possible, then the reference has no defined meaning within this specification
    • else no resolution is possible and the reference has no defined meaning within this specification
  • else
    • Look for an entry with a fullUrl that matches the URI in the reference
    • if no match is found, and the URI is a URL that can be resolved (e.g. if an http: URL), try accessing it directly)

My interpretation is relative url is allowed for transaction and batch bundle. However when testing with Vonk FHIR endpint, the server is expecting fullUrl to represent relation between bundle entries. For example when posting the following bundle:

{
  "resourceType": "Bundle",
  "id": "e0a07c37-8df7-4d75-aa11-3085369e8d36",
  "type": "transaction",
  "entry": [
    {
      "resource": {
        "resourceType": "List",
        "id": "xyz",
        "status": "current",
        "mode": "snapshot",
        "date": "2020-05-27T08:55:40-04:00",
        "entry": [
          {
            "item": {
              "reference": "Patient/abc",
              "display": "Betsy Smith-Johnson"
            }
          }
        ]
      },
      "request": {
        "method": "POST",
        "url": "List"
      }
    },
    {
      "resource": {
        "resourceType": "Patient",
        "id": "abc",
        "name": [
          {
            "family": "Smith-Johnson",
            "given": [
              "Betsy"
            ]
          }
        ]
      },
      "request": {
        "method": "POST",
        "url": "Patient"
      }
    }
  ]
}

The server won’t update list.entry[0].item.reference "Patient/abc” (because the server expects fullUrl here) when generates new local id for the Patient resource.

Is it server's responsibility to support relative url reference for transaction/batch bundle? Or is it recommended for the client to use fullUrl for reference ?

Thanks,
Yan

view this post on Zulip Lloyd McKenzie (May 27 2020 at 14:09):

Relative URLs should be ok. However, I don't see fullURLs being declared for your entries - those are mandatory in a transaction

view this post on Zulip Vassil Peytchev (May 27 2020 at 15:24):

Maybe the confusion is here:

For transactions and batches, entries MAY not have fullURLs when the entry.request.method = POST, and the resource has no identity. Note that even in this case, there may still be a fullURL in a transaction on a POST so that relationships between resources can be represented (see Transactions).

I am not quite sure how to interpret that...

view this post on Zulip Lloyd McKenzie (May 27 2020 at 16:10):

My interpretation of that is that anything you're referencing and anything containing a 'local' reference must have a fullUrl. Without those, the references cannot be resolved. Agree we could be clearer. @Vassil Peytchev can you submit a change request?

view this post on Zulip Vassil Peytchev (May 27 2020 at 16:45):

In the case of POST in a transaction, does that mean that the fullURLs must be UUIDs? And if there have to be fullUrls, do references within the transaction have to use the fulUrl?

view this post on Zulip Lloyd McKenzie (May 27 2020 at 16:58):

References can use relative URLs even if the baseUrl is a UUID. The fullUrl could be the URL of the resource on the sending system or another system (if one exists). Otherwise, yes it should be a UUID.

view this post on Zulip Christiaan Knaap (May 28 2020 at 09:58):

Since you POST the Patient/abc, the id is ignored so I think there is no point in referencing Patient/abc.
IMHO the correct way to reference this Patient from the list is by adding a fullUrl to the entry and reference that from the List.entry.item.reference.

{
  "resourceType": "Bundle",
  "id": "e0a07c37-8df7-4d75-aa11-3085369e8d36",
  "type": "transaction",
  "entry": [
    {
            "fullUrl": "urn:uuid:d2a13b37-6611-48a7-a00a-92670e24665f",
      "resource": {
        "resourceType": "List",
        "id": "xyz",
        "status": "current",
        "mode": "snapshot",
        "date": "2020-05-27T08:55:40-04:00",
        "entry": [
          {
            "item": {
              "reference": "urn:uuid:f4534fe7-5e7a-4ebd-85aa-cc4efd187b13", //note that the fullUrl of the Patient entry is used.
              "display": "Betsy Smith-Johnson"
            }
          }
        ]
      },
      "request": {
        "method": "POST",
        "url": "List"
      }
    },
    {
            "fullUrl": "urn:uuid:f4534fe7-5e7a-4ebd-85aa-cc4efd187b13",
      "resource": {
        "resourceType": "Patient",
        "id": "abc",
        "name": [
          {
            "family": "Smith-Johnson",
            "given": [
              "Betsy"
            ]
          }
        ]
      },
      "request": {
        "method": "POST",
        "url": "Patient"
      }
    }
  ]
}

view this post on Zulip Vassil Peytchev (May 28 2020 at 14:23):

FHIR#27742 - note that the current language strongly supports @Christiaan Knaap's position.

view this post on Zulip Paul Church (May 28 2020 at 14:24):

+1, that has been my interpretation as well

view this post on Zulip Yan Wang (Jun 02 2020 at 20:58):

Thank you all for the clarification


Last updated: Apr 12 2022 at 19:14 UTC