On this page ⌄
Tutorial · Visualize Parquet DWH with Apache Superset
Connect Apache Superset to Apache Spark SQL and build clinical indicator dashboards from flattened FHIR tables.
Overview
After transforming FHIR resources into flattened analytical tables, you can connect business intelligence tools to visualize key health metrics.
In this tutorial, you will connect Apache Superset to Apache Spark SQL or PostgreSQL, create datasets and charts, assemble a multi-metric clinical dashboard, and test live incremental updates.
Prerequisites
- Completed Single Machine Analytics Deployment with Spark Thrift Server running on port
10001 - Apache Superset running locally (such as
http://localhost:8088) curlcommand line utility installed
Step 1 · Connect Superset to Spark SQL
- Log into Apache Superset at
http://localhost:8088with administrator credentials. - In the top navigation bar, navigate to Settings > Database Connections.
- Click + Database and select Apache Spark SQL (or PostgreSQL if connecting directly to
views). - Set the connection URI to the Thrift endpoint.
hive://localhost:10001/default
- Test the connection and click Connect.
Step 2 · Create a patient count metric chart
- Open SQL Lab in Superset and select your database connection.
- Run a query to count total patients.
SELECT COUNT(1) AS patient_count FROM Patient;
- Click Create Chart, choose chart type Big Number, and configure the metric as
MAX(patient_count). - Save the chart with the name Patient Count and add it to a new dashboard named Key Program Metrics.
Step 3 · Create a gender distribution chart
- In SQL Lab, write an aggregation query over patient gender.
SELECT gender, COUNT(gender) AS count_gender
FROM Patient
GROUP BY gender
ORDER BY count_gender DESC;
- Click Create Chart and select the Pie Chart visualizer.
- Assign
genderas the dimension andMAX(count_gender)as the metric. - Save the chart as Gender Split and attach it to your Key Program Metrics dashboard.
Step 4 · Build an HIV treatment trend chart
Query longitudinal observation records to track treatment numbers over time.
SELECT
COUNT(*) AS total_patients,
YEAR(o.obs_date) AS obs_year
FROM observation_flat AS o
WHERE o.code LIKE '1255%'
AND o.val_code LIKE '1256%'
AND YEAR(o.obs_date) < 2023
GROUP BY YEAR(o.obs_date)
ORDER BY obs_year ASC;
Save this visualization as a Bar Chart titled HIV Treatment Trends and add it to the dashboard.
Step 5 · Arrange dashboard layout
- Navigate to Dashboards and open Key Program Metrics.
- Click Edit Dashboard and add a top header component.
- Position the Patient Count and Gender Split charts side by side in the top row.
- Place the HIV Treatment Trends bar chart spanning the full width of the second row.
- Click Save.
Step 6 · Verify live incremental pipeline updates
Test that the analytics pipeline captures new patient records.
Post a new patient resource to the source FHIR server.
curl -X POST \
-H "Content-Type: application/fhir+json; charset=utf-8" \
'http://localhost:8091/fhir/Patient/' \
-d '{"resourceType": "Patient"}'
Open the Pipelines Controller at http://localhost:8090 and trigger an incremental run.
Once finished, return to Superset, click the dashboard menu, and select Refresh dashboard. The patient count metric increases dynamically.
Where to go next
- Learn how to author custom schema projections in the Streaming Analytics with SQL-on-FHIR Tutorial.
- Connect cloud datasets in Create GCP FHIR Store and BigQuery Dataset.