helios_persistence/sof/mod.rs
1//! SQL-on-FHIR support for storage backends.
2//!
3//! The ViewDefinition → SQL pipeline:
4//!
5//! 1. [`ir`] — `PlanNode` tree and value types (`LitValue`, `Expr`, …).
6//! 2. [`compile_path`] — FHIRPath expression → `Expr` lowering.
7//! 3. [`compile_view`] — ViewDefinition JSON → `PlanNode` (`build_plan`).
8//! 4. [`dialect`] — `SqliteDialect` / `PgDialect` implementations of the
9//! `Dialect` trait (JSON accessors, parameter syntax, etc.).
10//! 5. [`emit`] — `PlanNode` → parameterised SQL (`emit_plan`).
11//! 6. [`compiler`] — public façade combining `build_plan` + `emit_plan` into
12//! `compile_view_definition_dialect`, the entry point used by the runners.
13//!
14//! Backend runners:
15//! - [`sqlite`] — `SqliteInDbRunner` (SQL) for SQLite.
16//! - [`postgres`] — `PgInDbRunner` (SQL) for PostgreSQL.
17//! - [`mongodb`] — `MongoInDbRunner` (aggregation pipeline) for MongoDB.
18//! - [`in_process`] — `InProcessSofRunner`, a backend-agnostic runner that
19//! evaluates the view with the `helios-sof` engine over scanned resources
20//! (used by S3 / S3-primary composites, which have no query engine).
21//!
22//! Inline `resource:` parameters on `$viewdefinition-run` are handled by the
23//! REST layer via the in-process `helios-sof` FHIRPath evaluator, so this
24//! module does not need a per-backend inline runner.
25
26pub mod compile_path;
27pub mod compile_view;
28pub mod compiler;
29pub mod dialect;
30pub mod emit;
31pub mod in_process;
32pub mod ir;
33
34#[cfg(feature = "sqlite")]
35pub mod sqlite;
36
37#[cfg(feature = "sqlite")]
38pub mod sqlite_udfs;
39
40#[cfg(feature = "postgres")]
41pub mod postgres;
42
43#[cfg(feature = "mongodb")]
44pub mod emit_mongo;
45
46#[cfg(feature = "mongodb")]
47pub mod mongodb;
48
49use helios_fhir::FhirVersion;
50
51/// Thin alias for [`helios_fhir::get_field_type`] — keeps existing
52/// `super::lookup_field_type(...)` call sites inside this crate working
53/// without sprinkling the `helios_fhir::` prefix everywhere.
54pub(super) fn lookup_field_type(
55 version: FhirVersion,
56 parent_type: &str,
57 field_name: &str,
58) -> Option<(&'static str, bool)> {
59 helios_fhir::get_field_type(version, parent_type, field_name)
60}
61
62/// Thin alias for [`helios_fhir::field_exists_anywhere`] — see the canonical
63/// definition there.
64pub(super) fn field_exists_anywhere(version: FhirVersion, field_name: &str) -> bool {
65 helios_fhir::field_exists_anywhere(version, field_name)
66}