Skip to content

Commit

Permalink
Clarify that Include Ignores Dead Links
Browse files Browse the repository at this point in the history
The spec says:

If there is no reference, or no matching resource, the resource cannot
be retrieved (e.g. on a different server), then the resource is omitted,
and no error is returned.

http://hl7.org/fhir/R4/search.html#include
  • Loading branch information
alexanderkiel committed Nov 19, 2024
1 parent cb28b15 commit 3d22447
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions .github/scripts/include-without-referential-integrity.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
#!/bin/bash -e

# This test creates two observations both referencing different patients where
# only one of the patients exists.
#
# An observation query including the subjects of the observations is executed.
# The expected result contains both observations and the single patient. It's
# important that the dead reference doesn't result in an error. It is just
# ignored.

BASE="http://localhost:8080/fhir"

curl -sXPUT -d '{"resourceType": "Observation", "id": "0", "subject": {"reference": "Patient/0"}}' -H 'Content-Type: application/fhir+json' "$BASE/Observation/0" > /dev/null
curl -sXPUT -d '{"resourceType": "Observation", "id": "1", "subject": {"reference": "Patient/1"}}' -H 'Content-Type: application/fhir+json' "$BASE/Observation/1" > /dev/null
curl -sXPUT -d '{"resourceType" : "Patient", "id": "0"}' -H 'Content-Type: application/fhir+json' "$BASE/Patient/0" > /dev/null

RESULT=$(curl -s "$BASE/Observation?_include=Observation:subject" | jq -r '.entry[].search.mode' | tr '\n' '|')
RESULT=$(curl -s "$BASE/Observation?_include=Observation:subject" | jq -r '[.entry[].search.mode] | join(",")')

if [ "$RESULT" = "match|include|" ]; then
if [ "$RESULT" = "match,match,include" ]; then
echo "✅ include works"
else
echo "🆘 include doesn't work"
Expand Down

0 comments on commit 3d22447

Please sign in to comment.