samply / blaze

A FHIR® Server with internal, fast CQL Evaluation Engine
https://samply.github.io/blaze
Apache License 2.0
153 stars 18 forks source link

Implement Conditional References #433

Open alexanderkiel opened 3 years ago

alexanderkiel commented 3 years ago

Conditional references are relevant in #359 and #361. Especially since #361 currently only works if no other resource refers to a conditional created resource in the same transaction bundle.

For resources that contain conditional references, that references have to be resolved at transaction processing time. However in Blaze, resource contents are put in the resource store before the transaction processing occurs. Because resource contents are immutable, we can't update them with resolved references. Instead we have to store the resolved references in the index database and replace them every time a resource is used.

In addition to that reference resolution, we have to add index entries for the resolved references. That also means that the index process will have three phases instead of the current two phases. Currently we index the resource content that is independent of the transaction in the first phase followed by the transaction dependent indices. With this issue we will add a third index phase that indexes resolved references.

alexanderkiel commented 2 years ago

Transaction Handling

On Receiving Node

Transaction Bundle V Node x
V
ID genration for all POST Requests
V Static Reference Resolution
V Calculate Resource Content Hashes V Store Resource Contents into Resource Store

V Put Transaction Commands into TX-Log

On All Nodes

Receive Transaction Data (List of Transaction Commands, T) V Index all Resources according to enabled search params in parallel -> Index Entries with Hashes

V Transaction Processing -> Index Entries with T

On All Nodes - New

Receive Transaction Data (List of Transaction Commands, T) V Transaction Processing -> Index Entries with T + Reference Mapping
V Resource Content Update according to Reference Mapping + Deletion of Non-Used Resources V Calculate Resource Content Hashes of Updated Resources
V Store Updated Resource Contents into Resource Store V Update Hashes in Index Entries with T

V Index all Resources according to enabled search params in parallel -> Index Entries with Hashes

Static Reference Resolution