microsoft / microsoft/fhir-server

Filter versioned references from _include or _revinclude bundles

Open
#2,529 2 comments 0 reactions 0 assignees View on GitHub
Question VSTS-Backlog
Dominant language
TSQL
Stars
1.4k
Forks
592
Avg merge
2d 7h
Merged PRs (30d)
41

Description

**Question**

* How can outdated references be filtered from the result set of reference inclusion searches?
* Is there a way to make _include_ or _revinclude_ version aware

**Description**

In our API implementation we building a bundle to include all the documents we need. This includes a primary document and a secondary reverse included Diagnostic Report document that contains the reference to the primary document (Service Request) in the _based-on_ field. This reference (ex: `ServiceRequest/123`) works perfectly fine. However, since our dataset makes it difficult to reliably link existing Diagnostic Reports, if we need to update data we are creating a new DR and deprecating any old ones. This led us to updating this reference to include the last relevant 'version' to the end of the reference (ex: `ServiceRequest/123/5` or `ServiceRequest/123/_history/5`).

The issue with 'deprecating' these documents like this is that the reference is still valid in the __revinclude_ search. We can work around this by filtering out the old references in our custom logic, but it seems like there could be a better way to approach this from the search or implementation standpoint. If the version is known, then the _above_ or _below_ attributes can be used to filter out older references; this does not work in our case, since our search doesn't know the version until after the bundle is returned.

We may need to approach this in a different way, or this may just not be supported. It would be nice to see a way to exclude these outdated references from the outset.

**References**
https://www.hl7.org/fhir/search.html#versions

Contributor guide

Open the contributing guide

Research direction

No implementation files, tests, or entry points are named in the issue. Start by reviewing the FHIR search versions reference and the existing _include/_revinclude behavior; define whether versioned references can be excluded before bundle construction and document or test the supported behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
sql
Domain
api, backend, search
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.