FHIR Chat · Provenance in a bundle · implementers

Stream: implementers

Topic: Provenance in a bundle


view this post on Zulip David Hay (Jul 15 2019 at 19:09):

If you are updating a resource using a transaction containing the updated resource and a provenance resource that refers to it, how can you ensure that Provenance.target will refer to the newly updated version on the server?

view this post on Zulip Lloyd McKenzie (Jul 15 2019 at 20:19):

Good question. In a transaction, you can have the id resolve to a newly created id, but we haven't talked about how to have a reference resolve to a specific version...

view this post on Zulip Domenico Corapi (Jan 15 2020 at 16:34):

I'm having thee same problem @David Hay mentioned here. Just looking for more context, does anyone have a workaround or is it something that could be added to the standard?

view this post on Zulip Lloyd McKenzie (Jan 15 2020 at 16:48):

@Grahame Grieve

view this post on Zulip Grahame Grieve (Jan 17 2020 at 01:40):

have you looked at the X-Provenance header?

view this post on Zulip Domenico Corapi (Jan 17 2020 at 18:36):

Thanks @Grahame Grieve I missed that. It looks like the the docs are not prescriptive on how target is populated so it could be a good place to enforce some implementation specific behaviour and link to a specific version.

view this post on Zulip Nath (Jan 20 2020 at 19:48):

I looked at the documenation for Provenance https://www.hl7.org/fhir/provenance.html.
=================
"For new resources that need to have a corresponding Provenance resource, the version-specific reference is often not knowable until after the target resource has been updated. This can create an integrity problem for the system - what if the Provenance resource cannot be created after the target resource has been updated? To avoid any such integrity problems, the target resource and the Provenance resources should be submitted as a pair using a transaction.
6.3.4.2.1 HTTP Header

The custom header X-Provenance to provide a provenance resource when performing PUT or POST operations using the RESTful interface:

POST [base]/Observation
Content-Type: application/fhir+?
X-Provenance: { "resourceType": "Provenance", "location": { "reference": "Location/1" }," agent" ... } "
======================

I also looked at the examples but didn't see an example for the above usecase.
I wanted to do this in atomic way i.e.
transaction bundle contains the following:
/resource 1
/resource 2
/provenance
I am not sure how should I use this X-Provenance?. Should I pass this when I post my transaction /bundle ?

Can you please kindly share me full "transaction bundle" example or point me to a link ?.

thanks for your help

view this post on Zulip Domenico Corapi (Jan 21 2020 at 13:21):

@Nath the idea of the X-Provenance header is to have a provenance object that specifies everything except the targets. The server should create a transaction that adds references to the specific version of resource 1 and resource 2 being created in the same transaction.

Another way to see it is as if your provenance header was added to a new bundle request, where the target is populated with references to Resource/id/_history/newversion for both resources. Unfortunately there is no way for you to know newversion in advance and dynamic references in a bundle/transaction do not support versions. So you'll have to implement ad hoc behaviour for the performance header.

Just realised the explanation is a bit convoluted, let me know if that's not clear, I can give it another go :)

view this post on Zulip Nath (Jan 21 2020 at 15:31):

thanks @Domenico Corapi. Let me read and digest this and ask if I have further questions. appreciate your help. thanks.

view this post on Zulip Larry Shields (Jan 23 2020 at 17:30):

I was dealing with something similar and one way I worked around this was utilizing the Transaction Response bundle from the Post of the Transaction Bundle to construct the Provenance Record then submit this in a transaction. It does essentially double your HTTP Calls to the server but would give you the version specific URLs for the Targets.

The issue I did run into with implementing this behavior in the HAPI FHIR Server was that the JSON/XML Parsers remove the versions from the References in Provenance Target so I lose them anyway.

view this post on Zulip Nath (Jan 24 2020 at 16:34):

thanks @Domenico Corapi .
I went thru' the specs for Provenance and I understand the limitation of provenance.target cannot have /resource/id/_history/<newversion>. So, I have to pass X-Provenance in the header.
My question is how to implement this:

I wanted to do this in atomic way i.e.
transaction bundle contains the following:
/resource 1
/resource 2
/provenance

after the bundle is posted to the server, I want the /provenance to have the versioned resources(i.e. /resource/1/_history/<newversion>, /resource/2/_history/<newversion>) in the target.

So, my question is this:

  1. what should I pass in X-Provenance ?. (Please note that I am posting the /bundle)

Could you please kindly explain this ?

view this post on Zulip Nath (Jan 24 2020 at 16:38):

thanks @Larry Shields . So, you had 2 transactions?. 1. create the resources with a txn bundle and get the txn response in a txn. 2. create another txn and using the values from response bundle construct /provenace ?. So, in this case, the creation of resources and proveance are not in the same txn right ?

view this post on Zulip Larry Shields (Jan 24 2020 at 16:44):

@Nath
Yes that's correct. I had two separate transactions. One that contained the resources and then a second one that contained the Provenance resource with the version specific references in the Target.

view this post on Zulip Nath (Jan 24 2020 at 17:38):

thanks @Larry Shields for clarifying. In my case, trying to them in a single txn. thanks.

view this post on Zulip Nath (Jan 24 2020 at 21:07):

reading the spec again to understand how to pass X-Provenance. Is it I just need to pass
X-Provenance : {resourceType: "provenance", agent : {...other related fields of provenance .. } } ?

Also, I saw this thread https://chat.fhir.org/#narrow/stream/179166-implementers/topic/x-provenance.20header and it says the workaround "And if you don't like it.. then don't use it.. the alternative is to do all Create using a Batch/Transaction with the Bundle holding the resource you want to create and the Provenance. This x-provenance header is just an alternative to the same thing.".

So, this workaround does not work for versioned resources right ?.

view this post on Zulip Nath (Jan 25 2020 at 04:47):

I tried passing X-Provenance in header of the transaction-bundle. It didn't create Provenance resource. I was not sure which release this header was added . I was using R4.0.0 and upgraded to 4.0.1 but still not working. I manually created /provenance resource and that worked but not thru' X-Provenance.

Can someone point me to an example how to pass would be of great help. thanks.
@Domenico Corapi

view this post on Zulip Domenico Corapi (Jan 28 2020 at 11:02):

@Nath , what server are you using? If you use HAPI, there's no support for the header I believe (it's in the standard, just not supported by the implementation). You will have to build a custom interceptor that handles it.

view this post on Zulip Nath (Jan 28 2020 at 15:01):

@Domenico Corapi thanks.


Last updated: Apr 12 2022 at 19:14 UTC