JavaScript basics

Before working with rules in Oracle Clinical One Platform, you should have a basic understanding of JavaScript. While you do not need advanced programming skills, an understanding of JavaScript functions and variables is critical to your success.

JavaScript is a widely-used programming language most often used in web development. This language is straightforward to learn and can be used to develop both basic expressions and those with more complex logic. We use this language to write custom rules in Oracle Clinical One Platform. Within the rule expressions, we can invoke JavaScript functions (blocks of code) and the provided helper functions, together with variables, constants, operators, and various methods to accomplish specific tasks.

Teaching you the fundamentals of JavaScript is beyond the scope of this document. There are many excellent resources available on the web (such as W3schools) that can help you understand JavaScript concepts and basic programming methodology.

JavaScript functions

Functions are simply blocks of code designed to accomplish a specific task. You can use functions in your rules to perform a variety of tasks. When writing your rules, you invoke these functions from the rules interface. You can use native JavaScript functions or special helper functions that are provided as part of Oracle Clinical One Platform.

  • Native JavaScript functions are functions that are part of standard JavaScript programming. These functions are familiar to JavaScript programmers and not specific to Oracle Clinical One Platform. You can invoke your code with parameters and the blocks of code you write are visible within the rule expression.

    Be sure to understand the limitations and usage caveats for using JavasScript in Oracle Clinical One Platform before programming your rules. For guidance, see Javascript usage tips.

  • Oracle helper functions are also invoked using specific parameters and a value is returned by the helper function. The return value for a helper function is available to you for use in your rule expression and the logic of your rule can use this value to perform an action. However, the code within these functions is not visible to you in the rules interface. Refer to the Rules helper function reference for details on each function.

JavaScript variables

When working with JavaScript functions, you use variables to pass your data. Variables are simply containers used to hold values that you want to use in your rule. You must declare and define variables as part of your rule.

Note:

When writing rules, you must consider two types of variables, ones that hold values taken directly from the data entered into forms and ones that can be created within your rule code to store values generated within the code. Form variables are defined in the top portion of the rule editor and are populated by form values. Variables used in your code are defined in the code itself.

Rule validation

The rules interface provides a simple way for you to add your rule code and includes syntax validation. However, you should keep in mind that this validation is used to ensure that the syntax used in your rule is valid JavaScript (that is, you have not made a coding error such as forgetting a closing parentheses or required semi-colon).

Understanding and defining the logic you want for your rule is a difficult process regardless of your level of JavaScript knowledge! The system does not provide verification of your rule logic so it is critical that you verify your rule and ensure the rule is functioning as expected. To help you with the creation of your rule logic, we provide a number of examples as part of our helper function reference and a library of Rules examples. Reviewing these examples can help you gain a better understanding of the logic and functions used when writing JavaScript rule expressions for complex tasks. These examples can also be used as a base for your own custom code. This can significantly decrease your development time.

Note:

Rule verification should always be done in Testing mode for your study before it is deployed to Production. You must always verify the behavior of your rule at run time.