Skip to main content

The UI Vocabulary: The Rule-to-UI Contract

An effective dynamic form depends on a clear "contract" between the rules that define the logic and the front-end code that renders the user interface. This document describes that contract.

As a rule author, you must use the entities and attributes defined here to construct the form. The front-end application is built to understand this specific vocabulary and will render the UI accordingly.

The core entity for defining a user interface is UI.


UI

The UI entity is the root element for defining the overall state and flow of the dynamic form.

AttributeData TypeDescription
pathToDataStringDefines the primary data object where user-entered information will be stored. This attribute acts as the crucial bridge between the UI definition and the form's specific data model.
noUItoRenderBooleanSet to true for stages where no UI needs to be rendered, but background processing (like calculations or data augmentation) should occur. Defaults to false.
doneBooleanSet to true by the rules to signal the end of the dynamic form flow. The front-end uses this flag to trigger final data submission or transition to the next part of the application.
nextStageNumberInteger(Action) Set this in your rulesheet actions to indicate which stage the form should proceed to next. If this is the final stage, leave this null and set UI.done = true.
currentStageNumberInteger(Precondition/Filter) The front-end sends this value in the input payload. Use it in a rulesheet's filter or precondition to ensure rules only apply to the current stage.
languageStringDefines the language context. Rules can set this (e.g., UI.language = 'italian') to change the language dynamically during the form flow.

Container

Represents a logical grouping or panel within a form stage, containing UI controls. A Container is referenced in the rules via the UI.containers collection.

AttributeData TypeDescription
idStringA required, unique identifier for the container within the current stage.
titleStringText rendered as the header (e.g., using an <h3> tag) for the container.
validationMsgStringOptional text displayed as a validation message associated with the entire container.
descriptionStringAn optional descriptive string, not rendered by default but useful for rule troubleshooting or documentation.

UIControl

Represents an individual form element like an input field, text display, or button.

Common UIControl Attributes

AttributeData TypeDescription
typeStringThe specific type of UI Control to render. This choice determines which other attributes are required or optional. The various types are detailed below.
fieldNameStringCrucial for data binding. Links the control's value to an attribute within the entity defined by UI.pathToData.
idStringA required, unique identifier for the control within its container.
labelStringThe text displayed as the label for the UI control.
valueString, Number, BooleanProvides a default value for input controls. For read-only controls, this holds the text to display.
labelPositionStringOptionally specifies where to place the label relative to the control (e.g., 'Above', 'Side').
dataSourceURL (String)A URL to a REST endpoint used to dynamically populate choice-based controls.
emphasizeBooleanIf true, instructs the front-end to render the label with emphasis (e.g., bold).
min / maxNumberSpecifies the minimum/maximum numeric value for a Number control or character length for a TextArea.
minDT / maxDTDate (String)Specifies the minimum/maximum selectable date for DateTime controls (e.g., 'YYYY-MM-DD').
sortOptionsStringOptionally instructs the front-end to sort options ('A to Z' or 'Z to A') for choice-based controls.
tooltipStringOptional text to display as a tooltip when the user hovers over the control.
triggeredByControlWithIdStringThe id of another control that must be interacted with before this control becomes visible.
triggeredWhenSelectionStringThe specific value that must be selected in the triggering control for this control to become visible.

UIControl Types

TypeDescriptionKey Attributes & Rule Examples
ReadOnlyTextRenders non-editable HTML text.value: The text to display.
javascript <br/> // Display static text <br/> UIControl.new [type='ReadOnlyText', value = '...'] <br/>
TextAreaRenders a multi-line text input field.fieldName, rows, cols, min, max.
javascript <br/> // A comment box <br/> UIControl.new [type='TextArea', fieldName='comments', rows=3] <br/>
TextRenders a single-line text input field.fieldName: Links to a vocabulary attribute.
javascript <br/> // Street address input <br/> UIControl.new [type='Text', fieldName='streetAddress'] <br/>
NumberRenders an input field for numeric entry.fieldName, min, max.
javascript <br/> // Age input with validation <br/> UIControl.new [type='Number', fieldName='age', min=18] <br/>
DateTimeRenders a date or date-time picker.fieldName, showTime (Boolean).
javascript <br/> // Date only <br/> UIControl.new [type='DateTime', fieldName='dob', showTime=false] <br/>
SingleChoiceRenders a single choice input, typically a checkbox.fieldName: Links to a Boolean vocabulary attribute.
javascript <br/> // Opt-in checkbox <br/> UIControl.new [type='SingleChoice', fieldName='agreedToTerms'] <br/>
MultipleChoicesRenders a multi-choice input (like a dropdown) for single selection.fieldName, dataSource. Options defined via Option entities.
javascript <br/> // Static options <br/> myControl.option += Option.new [value='M', displayName='Male'] <br/>
MultipleChoicesMultiSelectRenders a multi-choice input for multiple selections.fieldName: Must link to a collection. Options defined via Option entities.
javascript <br/> UIControl.new [type='...', fieldName='symptoms'] <br/>
MultiTextAllows for a dynamic number of single-line text inputs.fieldName: Must link to a collection.
javascript <br/> UIControl.new [type='MultiText', fieldName='drugToCover'] <br/>
YesNoRenders a binary choice, storing the string 'yes' or 'no'.fieldName: Links to a String attribute.
javascript <br/> UIControl.new [type='YesNo', fieldName='smokerResponse'] <br/>
YesNoBooleanRenders a binary choice, storing a Boolean (true/false).fieldName: Links to a Boolean attribute.
javascript <br/> UIControl.new [type='YesNoBoolean', fieldName='onHTN_meds'] <br/>
FileUploadRenders a file selection button.fieldName.
javascript <br/> UIControl.new [type='FileUpload', fieldName='justificationDoc'] <br/>
MultiExpensesA complex control for entering multiple expense items.fieldName: Links to a collection. Option entities define choices within the control.
javascript <br/> UIControl.new [type='MultiExpenses', fieldName='expenses'] <br/>

DataSourceOptions

Configuration for a UIControl.dataSource if the REST endpoint's JSON structure doesn't match the default.

AttributeData TypeDescription
dataTextFieldStringThe key in the fetched JSON to use for the option's display text.
dataValueFieldStringThe key in the fetched JSON to use for the option's stored value.
pathToOptionsArrayString (JSONPath)The path to the array of options within the JSON response if it's not at the root level (e.g., $.results[*]).

Option

Defines a single choice for a MultipleChoices or similar control.

AttributeData TypeDescription
displayNameStringThe text displayed to the user for this option.
valueString, Number, etc.The actual value stored in the data model when this option is selected.

BackgroundData

Retrieves data from a REST endpoint to populate the data model without rendering UI controls.

AttributeData TypeDescription
urlURL (String)The URL of the JSON REST endpoint to fetch data from.
fieldNameNStringThe name of the attribute (e.g., fieldName1) where the fetched data will be stored.
labelNameNStringThe name of the key (e.g., labelName1) in the fetched JSON whose value should be extracted.
pathToDataNString (JSONPath)Optional JSONPath expression to locate labelNameN within the fetched JSON.
arrayToCollectionBooleanIf true, maps a JSON array to a collection of new entities in the data model. Requires collectionName.
arrayToSetBooleanIf true, extracts values from a fetched array and stores them as a single, comma-separated string.
collectionNameStringRequired when arrayToCollection is true. Specifies the name of the collection attribute in the vocabulary.