Stream: dotnet
Topic: transaction bundle
Angus Millar (Mar 10 2017 at 02:52):
I have been working on implementing the processing of a Transaction bundle as a server and have come across the challenge of updating all the references between resource when the server is to assign a resource id on a POST or PUT. So as a very simplified problem let say I have a transaction Bundle that contains two resource and requires a POST of a Patient resource and the POST of a DiagnosticReport resource. The DiagnosticReport has the ‘Subject’ reference to the Patient resource.
Initially the references between the resources in the bundle are just UUIDs. Yet, as I begin to commit the resource to the server the server will assign new resource IDs and then be required to update the reference between the resources to refer to the new IDs so not to offend the DiagnosticReport from its Patient.
The difficulty is in performing this task in a generic fashion to cater for any resource type and any references between the resource within the transaction bundle. I’m trying to fulfil this requirement from the FHIR standard:
“A transaction may include references from one resource to another in the bundle, including circular references where resources refer to each other. If the server assigns a new id to any resource in the bundle as part of the processing rules above, it SHALL also update any references to that resource in the same bundle as they are processed. References to resources that are not part of the bundle are left untouched. Version-specific references should remain as version-specific references after the references have been updated. Servers SHALL replace all matching links in the bundle, whether they are found in the resource ids, resource references, url elements, or <a href="" & <img src="" in the narrative. “
So my question is, given the Transaction Bundle in parsed into the .net API FHIR POCO class graph, how would one update all the references generically across all possible resource in the transaction bundle?
Christiaan Knaap (Mar 14 2017 at 08:14):
The idea is to keep a dictionary of old an new id's and use the visitor pattern to update backreferences in subsequent requests in the transaction. Actually building this will take you some time. You could study Spark to see how it's done there.
Brian Postlethwaite (Mar 14 2017 at 20:24):
I went through how I implemented it in sqlonfhir...
Last updated: Apr 12 2022 at 19:14 UTC