Documentation
¶
Overview ¶
Package sof runs SQL on FHIR v2 ViewDefinitions: a view turns each FHIR resource of one type into rows of named columns, by FHIRPath, so FHIR data can be read as tables by SQL engines, spreadsheets and quality measures.
It follows the ViewDefinition's processing algorithm (column, select, forEach, forEachOrNull, repeat, unionAll, where, constants, %rowIndex, getResourceKey and getReferenceKey) and is checked against the official sql-on-fhir test fixtures.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalid = errors.New("the ViewDefinition is not valid")
ErrInvalid is a ViewDefinition that cannot be run: a structural error found before any resource is read.
var ErrRun = errors.New("the view could not be run")
ErrRun is an error while running a view over a resource (multiple values in a non-collection column, a where clause that is not Boolean).
var Formats = map[string]string{
"csv": "text/csv",
"ndjson": "application/x-ndjson",
"json": "application/json",
"parquet": "application/vnd.apache.parquet",
}
Formats are the output formats a view's rows are written in.
Functions ¶
func ReadResources ¶
ReadResources reads FHIR resources from NDJSON (a bulk export file), a Bundle, a JSON array, or one resource, calling fn for each (a Bundle's entries are unwrapped).
Types ¶
type Column ¶
type Column struct {
Name string `json:"name"`
Type string `json:"type,omitempty"`
Collection bool `json:"collection,omitempty"`
Description string `json:"description,omitempty"`
// contains filtered or unexported fields
}
Column is one output column.
type Example ¶
type Example struct {
Name string `json:"name"`
Title string `json:"title"`
View json.RawMessage `json:"view"`
}
Example is a ViewDefinition shipped as a starting point.
type Row ¶
type Row []any
Row is one output row: a value per column, in View.Columns order (nil for null).
type View ¶
type View struct {
Name string
Title string
URL string
Resource string
// Columns are the output columns in order.
Columns []*Column
// contains filtered or unexported fields
}
View is a compiled ViewDefinition.
func CompileMap ¶
CompileMap is Compile for a decoded ViewDefinition (decoded with UseNumber).