Is there an example for querying a relationship join?

Hi,

I am investigating using FHIR / HL7 to build a home care software product. While the spec is very well documented, most of the examples and tutorials only cater for simple CRUD operations on a single resource.

Our model, though relatively simple (in SQL) does rely on nested Location resources and Patient -> Location -> Device joins.

I am using Location.partOf to handle references to the parent Location, e.g.

POST /Location
{ "resourceType": "Location", "status": "active", "name": "Room 40", "description": "Room 40", "mode": "instance", "type": { "text": "room" }, "partOf": { "reference": "http://localhost:8888/Location/d50a9ea3-fc81-4691-8f03-3186945f7bdf", "type": "Location" } }

I need to fetch all of the child locations for a resource (zones within rooms within a house). Does anyone know what the query should be, or what my error is with the reference above please?

I have tried several variations of:

GET /Location?partof=9829df72-6a7a-444b-ba57-79cd0a33f32f, along with :contains, :below, etc.

Are there any more advanced tutorials around? It may be that I need to design a GraphDefinition in order to follow child links?

Many thanks

Mark

Have you looked at the _include search parameter? Specifically
[base]/Location?_include=Location:partof

Thanks @lloyd

The pattern [base]/Location?_include=Location:partof appears to return the same as plain [base]/Location.

How should the starting location id be specified? The equals token is already used, so I can’t append another ={uuid}.

And e.g. [base]/Location/9829df72-6a7a-444b-ba57-79cd0a33f32f?_include=Location:partof does not include any ‘child’ records, linked through reference.

Appreciate the help.

[base]/Location?_id=someid&_include=Location:partof

Note that not all servers will support _include (or support it on all search criteria)

Thanks.

That doesn’t work, so Airbox may not support, as you suggest.

Looks like FHIR won’t work for us if I can’t get a simple join to work. Back to SQL.

Hi Mark,

Have you looked into FHIR Search Chaining? https://www.hl7.org/fhir/search.html#chaining
Ex: GET Patient?general-practitioner.name=Joe&general-practitioner.address-state=MN
Here it seems to imply that the specification would allow a SQL Join between Patient and Genera-Practitioner. However, it is not clear what if you also have an extensible attribute that share the same name as the FHIR resource.