The generate-rte-schema command generates a minimal Realtime Export (RTE) json ruleset and an SQL schema creation script based on a package-spec.json which identifies a source Implementation Guide (IG) which has been saved to the classpath where smileutil is running.
See Realtime Export for information on RTE and and Packages and Implementation Guides for information on IGs and package-spec.json.
Example using FHIR Version R4 and POSTGRES database engine.
bin/smileutil generate-rte-schema
-i "./path/to/package-spec.json"
-o "./output/files/path"
-v "R4"
-s "POSTGRES_9_4"
-c "/path/to/child/tables/file.txt"
and the package-spec.json file should look like:
{
"name": "hl7.fhir.r4.core",
"version": "4.0.1",
"packageUrl": "classpath:hl7.fhir.r4.core-4.0.1.tgz",
...
}
The packageUrl parameter MUST be specified and be pointing at a valid IG NPM package in either the classes or customerlib folders.
The following output files will be saved in the specified directory (./outputfiles/path):
output.json the RTE schemaoutput.sql the SQL scripts for the specified engine to create the desired tablesunmapped_columns.csv a CSV file containing a list of columns that could not be mapped and the reasons why-i [implementation-guide] – The input package-spec.json defining the IG to use.-o [output] – Path where output json and sql files should be saved.-v [version] – The FHIR version that is to be used. Currently, only supported value is R4-s [sql-engine] – The SQL engine to target for table creation scripts. Supported values are [MSSQL_2012, ORACLE_12C, POSTGRES_9_4, SNOWFLAKE, SNOWFLAKE_HYBRID]-p [table-name-prefix] – (optional) Tables are named after the resource type with some prefix. The default prefix is rte_; but another can be specified with this parameter.-c [child-tables] – (optional) An input text file containing a list of FHIR paths (one path per line) defining child tables to create. For example, specifying Patient.name would generate a child patient name table (provided Patient.name is a FHIR path utilized by a SearchParameter in the given IG). If not provided, no child tables will be created.Smile CDR supports two types of Snowflake table generation for RTE: standard tables and hybrid tables.
| Feature | SNOWFLAKE (Standard) | SNOWFLAKE_HYBRID (Recommended) |
|---|---|---|
| Use Case | Append-only analytical workloads | Transactional RTE with updates/deletes |
| PRIMARY KEY | Optional | Required (enforced by Snowflake) |
| FOREIGN KEY | Not enforced | Enforced with referential integrity |
| Row-level locking | No | Yes |
| ACID transactions | Limited | Full ACID guarantees |
| Concurrent writes | Not recommended | Supported |
| Updates/Deletes | Poor performance | Optimized |
| DDL Syntax | CREATE TABLE | CREATE HYBRID TABLE |
| Best for | Data warehouse, analytics | OLTP, RTE exports with referential integrity |
Use standard Snowflake tables when:
Example use case: Archiving historical patient data for analytics where records are never updated once written.
Use hybrid tables when:
Example use case: Real-time export of actively changing FHIR data where resources are frequently updated and relationships must be maintained.
Standard Snowflake tables are optimized for analytical workloads and append-only data.
bin/smileutil generate-rte-schema \
-i "./path/to/package-spec.json" \
-o "./output/files/path" \
-v "R4" \
-s "SNOWFLAKE" \
-p "rte_"
The generated DDL will use CREATE TABLE syntax. PRIMARY KEY and FOREIGN KEY constraints are optional.
Snowflake hybrid tables provide transactional ACID guarantees with row-level locking, making them suitable for transactional workloads while maintaining the performance characteristics of Snowflake.
To generate DDL for Snowflake hybrid tables, use the SNOWFLAKE_HYBRID SQL engine:
bin/smileutil generate-rte-schema \
-i "./path/to/package-spec.json" \
-o "./output/files/path" \
-v "R4" \
-s "SNOWFLAKE_HYBRID" \
-p "rte_"
The generated DDL will use CREATE HYBRID TABLE syntax with explicit PRIMARY KEY and FOREIGN KEY constraints.
id column as the primary key (standard RTE pattern)net.snowflake.client.jdbc.SnowflakeDriverFor runtime RTE execution with hybrid tables:
# Snowflake Connection (same configuration for both regular and hybrid tables)
module.realtime_export.config.db.driver=SNOWFLAKE
module.realtime_export.config.db.url=jdbc:snowflake://<snowflake-account>.snowflakecomputing.com?db=<snowflake-db-name>&schema=<snowflake-schema>&warehouse=<snowflake-warehouse>&role=<snowflake-role>&JDBC_QUERY_RESULT_FORMAT=JSON
module.realtime_export.config.db.username=<snowflake-usr>
module.realtime_export.config.rte.snowflake.pat=<snowflake-programmatic-access-token>
Prerequisites:
Naming Conventions:
cdr_production)rte_exports)-p parameter when generating the schema to namespace tables (default is rte_)SNOWFLAKE engine) for append-only analytical workloadsYou are about to leave the Smile Digital Health documentation and navigate to the Open Source HAPI-FHIR Documentation.