Aidbox Forms support a subset of the Lisp language for document definition, data retrieval and initialization, calculation of dynamic (derived) attributes, and data extraction.
Supported Lisp functions are tested and documented using zen-lang. It is possible to implement your own Lisp interpreter in a programming language other than Clojure by adhering to this specification.
Custom symbols
global
Operations
for
get
get-in
get-schema
vals
includes?
nil?
+
-
*
divide
mod
=
>
>=
<
<=
when
if
cond
or
and
not
count
select-keys
dissoc
matcho-filter
matcho-remove
matcho-path
date
timestamp
period
sql
sql*
sdc->fhir-value
global
Reference to global document & rules , for use in get, get-in
See examples for for
for
For (loop) expression. Takes a vector of one binding-form (example: [ ]), and returns a sequence of evaluations of expr
Evaluates test. If not the singular values nil or false, evaluates and yields then, otherwise, evaluates and yields else. If else is not supplied it defaults to nil.
Takes a set of test/expr pairs. It evaluates each test one at a time. If a test returns logical true, cond evaluates and returns the value of the corresponding expr and doesn't evaluate any of the other tests or exprs. (cond) returns nil.
Evaluates exprs one at a time, from left to right. If a form returns a logical true value, or returns that value and doesn't evaluate any of the other expressions, otherwise it returns the value of the last expression. (or) returns nil.
Evaluates exprs one at a time, from left to right. If a form returns logical false (nil or false), and returns that value and doesn't evaluate any of the other expressions, otherwise it returns the value of the last expr. (and) returns true.
Returns difference between two dates in given units. Arguments order is not matter - returns absolute value. Possible units are: :years :months :weeks :days
Run SQL query. Returns first row(as map) of result. When selected only one column - automatically unwraps result and return just value of column. To suppress unwrapping you should add column alias - it returns map with {:column-name value} Support 3 formats of query:
Pure sql string - "select * from Patient"
Parametrized sql vector ["select * from patient where id = ?" 101 ]
(sql"select * from patient where id = '1'");; => {:id "1" :name [{:family "Smith"}]}(sql ["select resource#>>'{name,0,family}' from patient where id = ?"101]);; => "Smith"(sql ["select resource#>>'{name,0,family}' as name from patient where id = ?"101]);; => {:name "Smith"}(sql {:select [#>> :resource [:name0:family]]:from:Patient:where [:=:id (get:patient-id)]});; => "Smith"(sql {:select {:patient-name [#>> :resource [:name0:family]]}:from:Patient:where [:=:id (get:patient-id)]});; => {:patient-name "Smith"}(sql {:select:*:from:Patient:where [:=:id (get:patient-id)]});; => {:id "1" :name [{:family "Smith" :given ["John"]}]}
sql*
Run SQL query. Same as sql but returns all rows. When selected only one column - automatically unwraps result and return just value of column. To suppress unwrapping you should add column alias - it returns map with {:column-name value} Support 3 formats of query:
Pure sql string - "select * from Patient"
Parametrized sql vector ["select * from patient where id = ?" 101 ]