Skip to content
This repository has been archived by the owner on Oct 8, 2024. It is now read-only.

FHIRPath and SQL #2

Open
niquola opened this issue Sep 6, 2018 · 0 comments
Open

FHIRPath and SQL #2

niquola opened this issue Sep 6, 2018 · 0 comments

Comments

@niquola
Copy link
Member

niquola commented Sep 6, 2018

FHIRPath offers path-based extraction of data from FHIR data and is used extensively within the FHIR specification itself. It is an excellent fit for its role, but is not sufficient for users looking for join, aggregation, or statistical operations over FHIR datasets. This proposal attempts to fill that need, but will follow conventions established by FHIRPath wherever applicable.

We tested very efficient implementation of FHIRPath in PostgreSQL, which has good fits with SQL.
If database is able to support FHIRPath (at least basic subset) - it can be very useful for SQL-on-FHIR.

Here is your sample using fhirpath:

SELECT fhirpath(resource, 'subject.reference'), 
       AVG(fhirpath(resource, 'value.quantity.value'))
FROM observation o
WHERE 
      fhirpath(resource, "code.where(system = 'http://loinc.org'') =  '2085-9' 
      fhirpath(resource,"effectiveDateTime') > '2017'
GROUP BY fhirpath(resource, 'subject.reference')

Using functional indexes - this query can be optimised very well

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant