Container node is a node that contains several children elements.
Typical description of node:
{:type aidbox.sdc/fields
:children [{...} {...}]
children - an array of child elements
Input node
Minimal example of input node:
{:bind [:blood-pressure]}
bind - binding to SDCDocument field
Input node type
By default Aidbox FormLayouts supports five types of inputs:
text input
number input
choice
quantity
calculated field
Aidbox Forms has input-node inference logic based on special properties of the field schemas. But you also have ability to force some input types by specifying sdc-type in SDCDocument field
Text input
To define text input just define your field as zen/string:
Since choice and quantity types are usually represented as zen/map in SDCDocument we should help input-type inference engine to select correect input-type by specifing additional properties of node or specify input-type directly by special key: sdc-type in SDCDocument definition:
Example:
SuperDocument
{...
:type zen/map
:keys {
;; use direct input-style set
:choice-field {:type zen/map
:confirms #{aidbox.sdc.fhir/coding}
:sdc-type aidbox.sdc/choice ;; <---- special type
:enum [{:value {:code "Option 1"}} ;; in enum we declaring available options for select
{:value {:code "Option 2}}]}
:body-temperature {:type zen/map
:keys {:value {:type zen/number}
:unit {:type zen/string}}
:sdc-type aidbox.sdc/quantity ;; <--- use special type
:units [{:name "kg"} ;; available units for this field
{:name "lb"}]}
;; use inference
:choice-field-inferred-1 {:type zen/map
:enum [{:value {:code "Option 1"}} ;; <--- declare :enum property (helps inference)
{:value {:code "Option 2}}]}
:choice-field-inferred-2 {:type zen/map
:sdc/option :aidbox.sdc.options/valueset ;; <--- declare :sdc/options (helps inference)
:valueset "my-valueset-id"}
:quantity-inferred-1 {:confirms #{aidbox.sdc.fhir/quantity}} ;; <--- declare :confirms with aidbox.sdc.fhir/quantity (helps inference)
:quantity-inferred-2 {:confirms #{aidbox.sdc.fhir/quantity}
:units [{:name "kg"} ;; <--- declare available units for this field (helps inference)
{:name "lb"}]}
...
}
SuperDocumentLayout
{...
:type zen/map
:layout {:type aidbox.sdc/fields
:children [{:bind [:choice-field]}
{:bind [:quantity-field]}]}
...}
Subforms
If you need to to group input fields or handle multiple readings of some field, you can use subforms.
Then in form definition we can use subforms with their relative paths. We state that subforms binds to blood pressure map. Then all child elements in this subforms will be binded to fields in this blood-pressure map
BloodPressureLayout
{:zen/tags #{aidbox.sdc/Layout}
:document BloodPresureDocument
:layout {:type aidbox.sdc/subform
:bind [:blood-pressure]
:layout {:type aidbox.sdc/fields
:children [{:bind [:systolic]} ;; full path will be [:blood-pressure :systolic]
{:bind [:diastolic]}]}}}
Collection subforms
If you have vector fields in your Document, you might need to use collection subforms to capture values.
Just declare your field as zen/vector in the document: