Click or drag to resize
TOPICA Basic

[This is preliminary documentation and is subject to change.]

TOPICA Basic is a domain specific language that is used to configure SERVER-SIDE computations within TOPICA (CLIENT-SIDE computations are written in JavaScript).

In some cases it is possible to implement the same functionality either server-side (using TOPICA Basic) or client-side (using JavaScript). In these cases it is advisable to use the server-side solution using TOPICA Basic. TOPICA Basic is typically easier to work with and dbug thatn JavaScript. Also, TOPICA Basic tyopically provides better error messages in case you get it wrong.

TOPICA Basic can only be used to write single expressions. Every piece of TOPICA Basic code is evaluated as one expression, and it returns one (and only one) value. It is NOT a full-blown programming language - it cannot be used to write multi-statement blocks of code, flow of control is rudimentary, etc.

TOPICA Basic is primarily a tool for the configurator. It may also be used by application developer and framework developer for development purposes.

Uses for TOPICA Basic

TOPICA Basic is used in many places when configuring applications:

  • Computation of default values for fields in (dynamic) input forms.

  • Defining validation rules in (dynamic) input forms.

  • Computing visibility of parts of forms:

  • Computation of the value displayed by the View template item type in dynamic forms.

  • Computation of URL values for IFrame, PopUpWindow, and SubForm template item types.

  • Computation of URL values for command button actions in the Form template item type.

  • Computation of URL values for pre- an post-processing.

  • Computation of names, start dates, display dates, and open/closed status - specified in The Structure File and used for example in displaying the Patient Record Tree

  • Computation of access rights - specified in The Structure File These computations also influence the security (what kind of access user have to data) - see Configuring Security. This security influences for example how the Patient Record Tree may be used.

  • Computation of SQL strings used in reports to read data from database - see TOPICA built-in report format.

  • Computation of SQL strings used in the TableView template type.

  • Computation of "dynamic" values stored in the .config files: text stored in some .config file parameters may contain TOPICA Basic expressions.

Context

In the TOPICA web application, there is always some kind of context. The context consists of several elements, e.g. the current user, the current patient, current organizational unit, current record, etc.

Much of the context is directly visible in the user interface. Examples:

  • The current user is always displayed in the top frame (below the main menu).

  • When the user selects a patient, the patient sub-menu is displayed showing patient identification.

Practically everywhere TOPICA Basic is used, it is important to use information regarding the context in the TOPICA Basic code.

TOPICA Basic uses an object oriented syntax to access the context. The context is available as TOPICA Basic Global Variables, which are objects of the TOPICA Basic Classes.

Note that some elements in the context may be "not set" (which translates to the value null in TOPICA Basic). For example, when a patient has NOT been selected, the global variable that holds the patient in context is null.

Besides the above mentioned global variables (objects) holding the context, TOPICA Basic has mechanisms for accessing various other context information, e.g.:

  • Values of keys defined in the Configuration Files

  • The parameters passed in the URL to the current page.

  • Various information about the web server and the database server.

Expression language

TOPICA Basic is built on top of the expression language implemented in the generic "Rule Engine". The "Rule Engine" is not specific to TOPICA (it is used in other contexts, too).

All the fundamentalt operators, constants and functions, relating to standard data types (integers, floating-point numbers, string, date/time, boolean) are part of this language (documented separately).

TOPICA Basic is an extension of this expression language, adding TOPICA specific classes and constants.

TOPICA Basic Elements