All notebooks
Prepare for analytics
Description
28 cells · updated Dec 12, 2025
This is a read-only view. Responses shown were saved when the notebook was published —
open it in your own Aidbox to run the cells against live data.
Upload resources
REST
Send
Cells run only inside Aidbox. Use Run in Aidbox above to open this notebook in your own instance.
POST /fhir/$import
Accept: text/yaml
Content-Type: text/yaml
id: synthea
contentEncoding: gzip
inputs:
- resourceType: Practitioner
url: https://storage.googleapis.com/aidbox-public/synthea/100/Practitioner.ndjson.gz
- resourceType: Patient
url: https://storage.googleapis.com/aidbox-public/synthea/100/Patient.ndjson.gz
Response:
Body
Status:
200
Create view definition for Appointment
REST
Send
Cells run only inside Aidbox. Use Run in Aidbox above to open this notebook in your own instance.
POST fhir/ViewDefinition
content-type: application/json
accept: application/json
{
"name": "appointment_cancelation",
"select": [
{
"column": [
{
"name": "id",
"path": "id",
"type": "id"
},
{
"name": "status",
"path": "status",
"type": "string"
},
{
"name": "cancelationReason",
"path": "cancelationReason.text",
"type": "string"
},
{
"name": "cts",
"path": "getAidboxCts()"
},
{
"name": "ts",
"path": "getAidboxTs()"
}
]
}
],
"status": "draft",
"resource": "Appointment",
"description": "Appointment cancelations",
"id": "appointment_cancelation",
"resourceType": "ViewDefinition"
}
Response:
Body
Status:
201
{
"description": "Appointment cancelations",
"meta": {
"lastUpdated": "2025-12-12T08:20:05.978703Z",
"versionId": "17",
"extension": [
{
"url": "https://aidbox.app/ex/createdAt",
"valueInstant": "2025-12-12T08:20:05.978703Z"
}
]
},
"name": "appointment_cancelation",
"resourceType": "ViewDefinition",
"status": "draft",
"id": "appointment_cancelation",
"resource": "Appointment",
"select": [
{
"column": [
{
"name": "id",
"path": "id",
"type": "id"
},
{
"name": "status",
"path": "status",
"type": "string"
},
{
"name": "cancelationReason",
"path": "cancelationReason.text",
"type": "string"
},
{
"name": "cts",
"path": "getAidboxCts()"
},
{
"name": "ts",
"path": "getAidboxTs()"
}
]
}
]
}Materialize view definition for Appointment
REST
Send
Cells run only inside Aidbox. Use Run in Aidbox above to open this notebook in your own instance.
POST fhir/ViewDefinition/appointment_cancelation/$materialize
{
"resourceType": "Parameters",
"parameter": [
{
"name": "type",
"valueCode": "materialized-view"
}
]
}
Response:
Body
Status:
201
{
"resourceType": "Parameters",
"parameter": [
{
"name": "viewName",
"valueString": "sof.appointment_cancelation"
},
{
"name": "viewType",
"valueString": "materialized-view"
},
{
"name": "viewSchema",
"valueString": "sof"
}
]
}Create view definition for encounter patient and practitioner
REST
Send
Cells run only inside Aidbox. Use Run in Aidbox above to open this notebook in your own instance.
POST fhir/ViewDefinition
content-type: application/json
accept: application/json
{
"name": "encounter_patient_and_practitioner",
"select": [
{
"column": [
{
"name": "id",
"path": "id",
"type": "id"
},
{
"name": "type",
"path": "type.first().coding.first().display",
"type": "string"
},
{
"name": "class",
"path": "class.display",
"type": "string"
},
{
"name": "period_start",
"path": "period.start",
"type": "dateTime"
},
{
"name": "period_end",
"path": "period.end",
"type": "dateTime"
},
{
"name": "patient",
"path": "subject.id"
},
{
"name": "practitioner",
"path": "participant.first().individual.id"
},
{
"name": "cts",
"path": "getAidboxCts()"
},
{
"name": "ts",
"path": "getAidboxTs()"
}
]
}
],
"status": "draft",
"resource": "Encounter",
"description": "Encounter patient and practitioner",
"id": "encounter_patient_and_practitioner",
"resourceType": "ViewDefinition"
}
Response:
Body
Status:
201
{
"description": "Encounter patient and practitioner",
"meta": {
"lastUpdated": "2025-12-12T08:20:21.753215Z",
"versionId": "21",
"extension": [
{
"url": "https://aidbox.app/ex/createdAt",
"valueInstant": "2025-12-12T08:20:21.753215Z"
}
]
},
"name": "encounter_patient_and_practitioner",
"resourceType": "ViewDefinition",
"status": "draft",
"id": "encounter_patient_and_practitioner",
"resource": "Encounter",
"select": [
{
"column": [
{
"name": "id",
"path": "id",
"type": "id"
},
{
"name": "type",
"path": "type.first().coding.first().display",
"type": "string"
},
{
"name": "class",
"path": "class.display",
"type": "string"
},
{
"name": "period_start",
"path": "period.start",
"type": "dateTime"
},
{
"name": "period_end",
"path": "period.end",
"type": "dateTime"
},
{
"name": "patient",
"path": "subject.id"
},
{
"name": "practitioner",
"path": "participant.first().individual.id"
},
{
"name": "cts",
"path": "getAidboxCts()"
},
{
"name": "ts",
"path": "getAidboxTs()"
}
]
}
]
}Materialize it
REST
Send
Cells run only inside Aidbox. Use Run in Aidbox above to open this notebook in your own instance.
POST fhir/ViewDefinition/encounter_patient_and_practitioner/$materialize
{
"resourceType": "Parameters",
"parameter": [
{
"name": "type",
"valueCode": "materialized-view"
}
]
}
Response:
Body
Status:
201
{
"resourceType": "Parameters",
"parameter": [
{
"name": "viewName",
"valueString": "sof.encounter_patient_and_practitioner"
},
{
"name": "viewType",
"valueString": "materialized-view"
},
{
"name": "viewSchema",
"valueString": "sof"
}
]
}Create view definition for practitioner
REST
Send
Cells run only inside Aidbox. Use Run in Aidbox above to open this notebook in your own instance.
POST fhir/ViewDefinition
content-type: application/json
accept: application/json
{
"name": "practitioner_flat",
"select": [
{
"column": [
{
"name": "id",
"path": "id",
"type": "id"
},
{
"name": "given",
"path": "name.given.first()",
"type": "string"
},
{
"name": "family",
"path": "name.family",
"type": "string"
},
{
"name": "cts",
"path": "getAidboxCts()"
},
{
"name": "ts",
"path": "getAidboxTs()"
}
]
}
],
"status": "draft",
"resource": "Practitioner",
"id": "practitioner_flat",
"resourceType": "ViewDefinition"
}
Response:
Body
Status:
409
{
"resourceType": "OperationOutcome",
"id": "duplicate",
"text": {
"status": "generated",
"div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><p>ERROR: duplicate key value violates unique constraint \"viewdefinition_pkey\"\n Detail: Key (id)=(practitioner_flat) already exists.</p></div>"
},
"issue": [
{
"severity": "fatal",
"code": "duplicate",
"diagnostics": "ERROR: duplicate key value violates unique constraint \"viewdefinition_pkey\"\n Detail: Key (id)=(practitioner_flat) already exists."
}
]
}Materialize it
REST
Send
Cells run only inside Aidbox. Use Run in Aidbox above to open this notebook in your own instance.
POST fhir/ViewDefinition/practitioner_flat/$materialize
{
"resourceType": "Parameters",
"parameter": [
{
"name": "type",
"valueCode": "materialized-view"
}
]
}
Response:
Body
Status:
201
{
"resourceType": "Parameters",
"parameter": [
{
"name": "viewName",
"valueString": "sof.practitioner_flat"
},
{
"name": "viewType",
"valueString": "materialized-view"
},
{
"name": "viewSchema",
"valueString": "sof"
}
]
}Create view definition for encounter type
REST
Send
Cells run only inside Aidbox. Use Run in Aidbox above to open this notebook in your own instance.
POST fhir/ViewDefinition
content-type: application/json
accept: application/json
{
"name": "encounter_class_and_type",
"select": [
{
"column": [
{
"name": "id",
"path": "id",
"type": "id"
},
{
"name": "type",
"path": "type.first().coding.first().display",
"type": "string"
},
{
"name": "class",
"path": "class.display",
"type": "string"
},
{
"name": "period_start",
"path": "period.start",
"type": "dateTime"
},
{
"name": "period_end",
"path": "period.end",
"type": "dateTime"
},
{
"name": "cts",
"path": "getAidboxCts()"
},
{
"name": "ts",
"path": "getAidboxTs()"
}
]
}
],
"status": "draft",
"resource": "Encounter",
"description": "Encounter types",
"id": "encounter_class_and_type",
"resourceType": "ViewDefinition"
}
Response:
Body
Status:
201
{
"description": "Encounter types",
"meta": {
"lastUpdated": "2025-12-12T08:20:29.594597Z",
"versionId": "25",
"extension": [
{
"url": "https://aidbox.app/ex/createdAt",
"valueInstant": "2025-12-12T08:20:29.594597Z"
}
]
},
"name": "encounter_class_and_type",
"resourceType": "ViewDefinition",
"status": "draft",
"id": "encounter_class_and_type",
"resource": "Encounter",
"select": [
{
"column": [
{
"name": "id",
"path": "id",
"type": "id"
},
{
"name": "type",
"path": "type.first().coding.first().display",
"type": "string"
},
{
"name": "class",
"path": "class.display",
"type": "string"
},
{
"name": "period_start",
"path": "period.start",
"type": "dateTime"
},
{
"name": "period_end",
"path": "period.end",
"type": "dateTime"
},
{
"name": "cts",
"path": "getAidboxCts()"
},
{
"name": "ts",
"path": "getAidboxTs()"
}
]
}
]
}Materialize it
REST
Send
Cells run only inside Aidbox. Use Run in Aidbox above to open this notebook in your own instance.
POST fhir/ViewDefinition/encounter_class_and_type/$materialize
{
"resourceType": "Parameters",
"parameter": [
{
"name": "type",
"valueCode": "materialized-view"
}
]
}
Response:
Body
Status:
201
{
"resourceType": "Parameters",
"parameter": [
{
"name": "viewName",
"valueString": "sof.encounter_class_and_type"
},
{
"name": "viewType",
"valueString": "materialized-view"
},
{
"name": "viewSchema",
"valueString": "sof"
}
]
}Next. Create Aidbox topic destination.
REST
Send
Cells run only inside Aidbox. Use Run in Aidbox above to open this notebook in your own instance.
POST /fhir/AidboxSubscriptionTopic
content-type: application/json
accept: application/json
{
"url": "http://example.org/subscriptions/encounter_class_and_type",
"status": "active",
"trigger": [
{
"resource": "Encounter",
"supportedInteraction": [
"create",
"update"
]
}
],
"id": "encounter_class_and_type",
"resourceType": "AidboxSubscriptionTopic"
}
Response:
Body
Status:
201
{
"url": "http://example.org/subscriptions/encounter_class_and_type",
"status": "active",
"trigger": [
{
"resource": "Encounter",
"supportedInteraction": [
"create",
"update"
]
}
],
"id": "encounter_class_and_type",
"resourceType": "AidboxSubscriptionTopic",
"meta": {
"lastUpdated": "2025-12-12T08:20:37.225839Z",
"versionId": "29",
"extension": [
{
"url": "https://aidbox.app/ex/createdAt",
"valueInstant": "2025-12-12T08:20:37.225839Z"
}
]
}
}
REST
Send
Cells run only inside Aidbox. Use Run in Aidbox above to open this notebook in your own instance.
POST /fhir/AidboxSubscriptionTopic
content-type: application/json
accept: application/json
{
"url": "http://example.org/subscriptions/encounter_patient_and_practitioner",
"status": "active",
"trigger": [
{
"resource": "Encounter",
"supportedInteraction": [
"create",
"update"
]
}
],
"id": "encounter_patient_and_practitioner",
"resourceType": "AidboxSubscriptionTopic"
}
Response:
Body
Status:
201
{
"url": "http://example.org/subscriptions/encounter_patient_and_practitioner",
"status": "active",
"trigger": [
{
"resource": "Encounter",
"supportedInteraction": [
"create",
"update"
]
}
],
"id": "encounter_patient_and_practitioner",
"resourceType": "AidboxSubscriptionTopic",
"meta": {
"lastUpdated": "2025-12-12T08:20:39.989167Z",
"versionId": "32",
"extension": [
{
"url": "https://aidbox.app/ex/createdAt",
"valueInstant": "2025-12-12T08:20:39.989167Z"
}
]
}
}
REST
Send
Cells run only inside Aidbox. Use Run in Aidbox above to open this notebook in your own instance.
POST /fhir/AidboxSubscriptionTopic
content-type: application/json
accept: application/json
{
"url": "http://example.org/subscriptions/appointment_cancelation",
"status": "active",
"trigger": [
{
"resource": "Appointment",
"supportedInteraction": [
"create",
"update"
]
}
],
"id": "appointment_cancelation",
"resourceType": "AidboxSubscriptionTopic"
}
Response:
Body
Status:
201
{
"url": "http://example.org/subscriptions/appointment_cancelation",
"status": "active",
"trigger": [
{
"resource": "Appointment",
"supportedInteraction": [
"create",
"update"
]
}
],
"id": "appointment_cancelation",
"resourceType": "AidboxSubscriptionTopic",
"meta": {
"lastUpdated": "2025-12-12T08:20:42.087637Z",
"versionId": "35",
"extension": [
{
"url": "https://aidbox.app/ex/createdAt",
"valueInstant": "2025-12-12T08:20:42.087637Z"
}
]
}
}
REST
Send
Cells run only inside Aidbox. Use Run in Aidbox above to open this notebook in your own instance.
POST /fhir/AidboxSubscriptionTopic
content-type: application/json
accept: application/json
{
"url": "http://example.org/subscriptions/practitioner_flat",
"status": "active",
"trigger": [
{
"resource": "Practitioner",
"supportedInteraction": [
"create",
"update"
]
}
],
"id": "practitioner_flat",
"resourceType": "AidboxSubscriptionTopic"
}
Response:
Body
Status:
201
{
"url": "http://example.org/subscriptions/practitioner_flat",
"status": "active",
"trigger": [
{
"resource": "Practitioner",
"supportedInteraction": [
"create",
"update"
]
}
],
"id": "practitioner_flat",
"resourceType": "AidboxSubscriptionTopic",
"meta": {
"lastUpdated": "2025-12-12T09:06:29.639296Z",
"versionId": "6101",
"extension": [
{
"url": "https://aidbox.app/ex/createdAt",
"valueInstant": "2025-12-12T09:06:29.639296Z"
}
]
}
}Next. Create topic destinations.
REST
Send
Cells run only inside Aidbox. Use Run in Aidbox above to open this notebook in your own instance.
POST /fhir/AidboxTopicDestination
content-type: text/yaml
accept: text/yaml
kind: clickhouse
meta:
profile:
- http://aidbox.app/StructureDefinition/aidboxtopicdestination-clickhouse
topic: http://example.org/subscriptions/appointment_cancelation
parameter:
- name: url
valueString: http://clickhouse:8123
- name: database
valueString: default
- name: user
valueString: default
- name: password
valueString: changeme
- name: viewDefinition
valueString: appointment_cancelation
- name: destinationTable
valueString: appointment_cancelation
id: appointment_cancelation
resourceType: AidboxTopicDestination
Response:
Body
Status:
201
kind: clickhouse
meta:
profile: ['http://aidbox.app/StructureDefinition/aidboxtopicdestination-clickhouse']
lastUpdated: '2025-12-12T08:21:38.833590Z'
versionId: '44'
extension:
- {url: 'https://aidbox.app/ex/createdAt', valueInstant: '2025-12-12T08:21:38.833590Z'}
topic: http://example.org/subscriptions/appointment_cancelation
parameter:
- {name: url, valueString: 'http://clickhouse:8123'}
- {name: database, valueString: default}
- {name: user, valueString: default}
- {name: password, valueString: changeme}
- {name: viewDefinition, valueString: appointment_cancelation}
- {name: destinationTable, valueString: appointment_cancelation}
id: appointment_cancelation
resourceType: AidboxTopicDestination
REST
Send
Cells run only inside Aidbox. Use Run in Aidbox above to open this notebook in your own instance.
POST /fhir/AidboxTopicDestination
content-type: text/yaml
accept: text/yaml
kind: clickhouse
meta:
profile:
- http://aidbox.app/StructureDefinition/aidboxtopicdestination-clickhouse
topic: http://example.org/subscriptions/encounter_class_and_type
parameter:
- name: url
valueString: http://clickhouse:8123
- name: database
valueString: default
- name: user
valueString: default
- name: password
valueString: changeme
- name: viewDefinition
valueString: encounter_class_and_type
- name: destinationTable
valueString: encounter_class_and_type
id: encounter_class_and_type
resourceType: AidboxTopicDestination
Response:
Body
Status:
201
kind: clickhouse
meta:
profile: ['http://aidbox.app/StructureDefinition/aidboxtopicdestination-clickhouse']
lastUpdated: '2025-12-12T08:21:43.723192Z'
versionId: '47'
extension:
- {url: 'https://aidbox.app/ex/createdAt', valueInstant: '2025-12-12T08:21:43.723192Z'}
topic: http://example.org/subscriptions/encounter_class_and_type
parameter:
- {name: url, valueString: 'http://clickhouse:8123'}
- {name: database, valueString: default}
- {name: user, valueString: default}
- {name: password, valueString: changeme}
- {name: viewDefinition, valueString: encounter_class_and_type}
- {name: destinationTable, valueString: encounter_class_and_type}
id: encounter_class_and_type
resourceType: AidboxTopicDestination
REST
Send
Cells run only inside Aidbox. Use Run in Aidbox above to open this notebook in your own instance.
POST /fhir/AidboxTopicDestination
content-type: text/yaml
accept: text/yaml
kind: clickhouse
meta:
profile:
- http://aidbox.app/StructureDefinition/aidboxtopicdestination-clickhouse
topic: http://example.org/subscriptions/encounter_patient_and_practitioner
parameter:
- name: url
valueString: http://clickhouse:8123
- name: database
valueString: default
- name: user
valueString: default
- name: password
valueString: changeme
- name: viewDefinition
valueString: encounter_patient_and_practitioner
- name: destinationTable
valueString: encounter_patient_and_practitioner
id: encounter_patient_and_practitioner
resourceType: AidboxTopicDestination
Response:
Body
Status:
201
kind: clickhouse
meta:
profile: ['http://aidbox.app/StructureDefinition/aidboxtopicdestination-clickhouse']
lastUpdated: '2025-12-12T08:21:45.831233Z'
versionId: '50'
extension:
- {url: 'https://aidbox.app/ex/createdAt', valueInstant: '2025-12-12T08:21:45.831233Z'}
topic: http://example.org/subscriptions/encounter_patient_and_practitioner
parameter:
- {name: url, valueString: 'http://clickhouse:8123'}
- {name: database, valueString: default}
- {name: user, valueString: default}
- {name: password, valueString: changeme}
- {name: viewDefinition, valueString: encounter_patient_and_practitioner}
- {name: destinationTable, valueString: encounter_patient_and_practitioner}
id: encounter_patient_and_practitioner
resourceType: AidboxTopicDestination
REST
Send
Cells run only inside Aidbox. Use Run in Aidbox above to open this notebook in your own instance.
POST /fhir/AidboxTopicDestination
content-type: text/yaml
accept: text/yaml
kind: clickhouse
meta:
profile:
- http://aidbox.app/StructureDefinition/aidboxtopicdestination-clickhouse
topic: http://example.org/subscriptions/practitioner_flat
parameter:
- name: url
valueString: http://clickhouse:8123
- name: database
valueString: default
- name: user
valueString: default
- name: password
valueString: changeme
- name: viewDefinition
valueString: practitioner_flat
- name: destinationTable
valueString: practitioner_flat
id: practitioner_flat
resourceType: AidboxTopicDestination
Response:
Body
Status:
201
kind: clickhouse
meta:
profile: ['http://aidbox.app/StructureDefinition/aidboxtopicdestination-clickhouse']
lastUpdated: '2025-12-12T09:12:11.809530Z'
versionId: '6118'
extension:
- {url: 'https://aidbox.app/ex/createdAt', valueInstant: '2025-12-12T09:12:11.809530Z'}
topic: http://example.org/subscriptions/practitioner_flat
parameter:
- {name: url, valueString: 'http://clickhouse:8123'}
- {name: database, valueString: default}
- {name: user, valueString: default}
- {name: password, valueString: changeme}
- {name: viewDefinition, valueString: practitioner_flat}
- {name: destinationTable, valueString: practitioner_flat}
id: practitioner_flat
resourceType: AidboxTopicDestination