You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -191,6 +191,10 @@ POST /fhir/AidboxSubscriptionTopic
191
191
192
192
### Step 2: Create ViewDefinition
193
193
194
+
A [ViewDefinition](../../modules/sql-on-fhir/defining-flat-views-with-view-definitions.md) defines how to transform a complex FHIR resource into a flat table structure suitable for analytics. Each `column` maps a [FHIRPath](https://hl7.org/fhirpath/) expression to a named column in the output table.
195
+
196
+
In this example, we flatten Patient into 5 columns: `id`, `gender`, `birth_date` from top-level fields, and `family_name`, `given_name` from the first official name (using `forEach` to navigate into the nested `name` array).
197
+
194
198
```http
195
199
POST /fhir/ViewDefinition
196
200
@@ -219,6 +223,8 @@ POST /fhir/ViewDefinition
219
223
}
220
224
```
221
225
226
+
The column names you define here must match the columns in the BigQuery table (Step 4). See [ViewDefinition documentation](../../modules/sql-on-fhir/defining-flat-views-with-view-definitions.md) for the full syntax including `where` filters, `unionAll`, and type casting.
227
+
222
228
### Step 3: Materialize ViewDefinition
223
229
224
230
The ViewDefinition must be [materialized](../../modules/sql-on-fhir/operation-materialize.md) as a database view before the BigQuery module can use it to transform data. Materialization creates a SQL view in the `sof` schema that maps FHIR resources to the flat column structure you defined.
@@ -365,7 +371,7 @@ When a new destination is created, the module automatically exports all existing
365
371
To skip the initial export (e.g., the table is already populated or you only need real-time data), add `skipInitialExport`:
0 commit comments