Skip to content

Latest commit

 

History

History
 
 

query

Query FHIR Data and Views

This directory contains our new (under development) approach for querying transformed FHIR data. The new approach is currently based on pure SQL queries but will gradually move to FHIR-views and eventually SQL-on-FHIR v2 spec. The idea is to create flat views for FHIR resources which are easy to work with.

When the data is transformed into Analytics friendly formats (e.g., Parquet) using the pipelines, it resembles the nested and repeated structure of FHIR resources. It is hard to write SQL queries for these structures. With FHIR-views we can define custom flat views using FHIRPath statements. Until the Spark runner of FHIR-views is stable enough, we provide sample flat views for commonly used FHIR resources, using pure SQL.

To see examples of this approach, see queries_and_views.ipynb which shows both approaches. The defaults in this notebook assume that you are running a local Spark Thrift server container as described here. You can also create a docker image to easily experiment with Spark SQL and FHIR-views by doing:

docker build -t my-fhir-views .

and then:

docker run -p 10002:8888 --network cloudbuild my-fhir-views

The --network part is to make it easy to communicate with the sample Thrift server mentioned above. If you want to connect to another Thrift server, you don't need to use that network.

After the container starts, copy the token printed on the screen, connect to http://localhost:10002/lab?token=TOKEN and start experimenting. queries_and_views.ipynb is also copied into this image which can be used as a starting point.