Library (crates)
Three crates make up the project:
octofhir-sof— the network-free engine: parsing, in-memory evaluation, and SQL generation.octofhir-sof-lint— offline lint and validation of ViewDefinitions.octofhir-sof-cli— the thinoctofhir-sofbinary over the two above.
octofhir-sof
Section titled “octofhir-sof”use octofhir_sof::{ViewDefinition, execute, SqlGenerator};
let view = ViewDefinition::parse(&json_text)?;
// In-memory evaluation — returns a ViewResult (rows + column metadata):let result = execute(&view, &resources)?;
// Or generate SQL:let sql = SqlGenerator::new().generate(&view)?.sql;Execution
Section titled “Execution”execute(&view, &resources) -> Result<ViewResult>— evaluate a view over a slice ofserde_json::Valueresources in memory.CompiledView::compile(&view)?thencompiled.execute_resource(&resource)?— compile once and run resource-at-a-time for bounded-memory streaming;compiled.columns()exposes the output columns.ViewRunner::new(pool).run(&view).await— run against a PostgreSQL pool.ViewResultcarriescolumns,row_count,to_json_array(), etc.
SQL generation
Section titled “SQL generation”SqlGenerator::new()/SqlGenerator::with_dialect(Dialect)— build a generator;.generate(&view)?returns aGeneratedSql(sqlpluscolumns: Vec<GeneratedColumn>).Dialect—PostgresorDuckdb(parses from"postgres"/"duckdb"/"ansi").create_table(name, &columns, dialect) -> String— emitCREATE TABLEDDL.
ViewDefinition model
Section titled “ViewDefinition model”ViewDefinition (with Column, SelectColumn, Constant, WhereClause)
parses from text with ViewDefinition::parse(&str) or from a value with
ViewDefinition::from_json(&value).
Output writers
Section titled “Output writers”octofhir_sof::output::get_writer(format) returns a writer for csv, ndjson,
json (and parquet with the feature) that serializes a ViewResult to any
Write sink.
octofhir-sof-lint
Section titled “octofhir-sof-lint”use octofhir_sof_lint::{ lint, lint_view, lint_sql, lint_shareable, validate_structure, FhirSchemaProvider, Finding, Severity,};validate_structure(&view) -> Vec<Finding>— structural spec checks (FH06–FH10), no package needed.lint(&view, &provider) -> Vec<Finding>— structural + schema-driven selector checks (FH01–FH05) + generated-SQL analysis.lint_view/lint_sql— the selector-only and generated-SQL-only halves.lint_shareable(&view, &allowed_custom) -> Vec<Finding>— the ShareableViewDefinition FHIRPath subset check (FH11).FhirSchemaProvider::load(package, version).await?— load a FHIR package through the canonical manager;with_schemas([...])builds one from in-memory schemas.Finding—{ code, message, severity, location, help_url }; thehelp_urlfor anFH*rule points at its rule reference page.