Oracle Policy Automation Tutorial

Functions and Validations in Oracle Policy Modeling

In the previous article we wrote few different types of rules and one of which included a function, in this article we will look into some more functions provided by OPM so that we get comfortable writing rules. We will also look into validation options provided by OPM and how to test them.

As stated before, Functions are inbuilt methods provided by OPM to assist in rule writing.

Now going back to our Mortgage Eligibility application, in the previous article we wrote the following rule:

Writing Rules with Functions in Oracle Policy Modeling
Writing Rules with Functions in Oracle Policy Modeling

In the above rule we had to write “and” after every conditions, but that could have been avoided if we would have used one of the functions provided by OPM. The above rule can be simplified using function as followed:

Writing Rules with Functions in Oracle Policy Modeling
Writing Rules with Functions in Oracle Policy Modeling

The function “all of the following are true” becomes true if all the conditions provided on the next level are true. If we need any one of the conditions to be true then the same rule can be written as below:

Writing Rules with Functions in Oracle Policy Modeling
Writing Rules with Functions in Oracle Policy Modeling

Comparison Operators:

In the previous article we saw the following comparison operator in our rule document.

Writing Rules with Functions in Oracle Policy Modeling
Writing Rules with Functions in Oracle Policy Modeling

The following comparison operators can be used in the similar way:

<x> <y> Less than
<x> <y> Greater than
<x> <= <y> Less than or equal to
<x> >= <y> Greater than or equal to
<x> <y> Equals
<x> <> <y> Not equal

 

Numeric Functions

We can use the numeric functions as below:

Writing Rules with Functions in Oracle Policy Modeling
Writing Rules with Functions in Oracle Policy Modeling
<x> + <y> Addition
<x>  <y> Subtraction
<x> * <y> Multiplication
<x> / <y> Division
Number(<text>) Convert string into number
Maximum(x, y) Returns the greater of the two value

 

Some functions in Oracle Policy Modeling have short forms and long forms. For example, the date function can be written as:

Writing Rules with Functions in Oracle Policy Modeling

We will look into some more functions in the later articles when we look into Entities and Relationships and Temporal Reasoning.

A complete list of OPM functions can be found at the below link:

http://documentation.custhelp.com/euf/assets/devdocs/august2016/PolicyAutomation/en/Default.htm#Guides/Policy_Modeling_User_Guide/FunctionReference.en-US.html%3FTocPath%3DPolicy%2520Modeling%2520User%2520Guide%7CWork%2520with%2520rules%7C_____16

 Validations: Validations in OPM are used to validate an input when using the Interview screens in OPM. Oracle Policy Modeling provides a wide range of inbuilt validators.

Let’s look at some of the inbuilt input validations provided by OPM.

Go back to the “Data” tab where we have the list of all the attributes. As mentioned earlier, attributes are the way in which OPM collects data/information. So in order for us to collect the right data and get rid of corrupt data we need to put validations in place.

Also Oracle Policy Modeling provides some default validations based on the “Type” of the attribute. For example, if the “Type” of the attribute in Number then OPM will not accept any Text for that attribute.

The below is our Data Tab.

Data Tab in Oracle Policy Modeling

The first attribute “the applicant’s credit score” is of Type Number. So when we Debug and run it as an Interview with screens, OPM will validate this input to make sure that only a Number can be entered in the input box.

Validations in Oracle Policy Modeling

Additional validation can be added to the attribute by double clicking the attribute from the Data tab and clicking on the “Input Validation” drop down. This provides you with additional validation options based on the Type of the attribute.

For Number type we get the following:

Validations in Oracle Policy Modeling

In the above screenshot, we can see the options provided for Numeric attribute validation. The Minimum and the Maximum number will restrict the attribute to only take an input whose value is between those 2 numbers. Integer Only checkbox will make sure the number is a whole number for example used to take a person’s age. In the Error Message field, we can provide a custom message to be displayed when the input is not correct.

For Date type we have the Minimum and the Maximum date as the validation options.

For Text type we have the Regular Expression field which can be used to restrict the text entered in the input.

Interview

Interview in OPA means a front-end web application to collect the data (for base-level attributes). The data collected is then used to run the rules and show the result on the screen.

By default, when we create a project in Oracle Policy Modeling we get one screen.

In the previous article we saw how this screen is used to collect the data when we do Debug. But the problem with that was that each question was asked individually and we had to keep pressing Next several times to complete the Interview.

This can be changed by adding a New Screen and collecting all the data required in that screen or you can have it on more than 1 screen.

Let’s go the Interview tab and see how this can be done.

Interview Tab in Oracle Policy Modeling

The above screenshot shows our current view.

Click on Stage 1 from the left hand panel and click New Screen from the top Ribbon.

Interview Tab in OPM

This will create a New Screen as shown in the above screenshot. Edit the text “New Screen” from the right hand panel and type “Mortgage Eligibility Questions”.

Now let’s add our questions on to the screen.

Click on the “Mortgage Eligibility Questions” from the left hand panel and Click “New Input” from the top Ribbon.

Interview Tab in OPM

Add all the attributes and re-arrange as you like. You can move the position of the question by clicking on it from the left hand panel and moving it up and down.

Click on the Interview Complete Screen and edit the “Interview Complete” text to “Mortgage Eligibility Outcome”.

Interview Debugger in OPM

This is how our Interview tab looks.

Now let’s Debug and see how our Interview works.

Interview Debugger in OPM

All required questions to determine the eligibility are now asked on the Mortgage Eligibility Questions Screen.

You can now try the validations out by entering incorrect data in date of birth or regular income or side income text box.

Once we enter the correct information and click Next, OPA run the rules using the data we provided and the result is show on the next screen.

Interview Debugger in OPM

Interview Debugger in OPM

And on expanding the drop down it also shows how it was able to reach the result.

To summarise the above, in the article we learnt the following:

  1. Using the OPM inbuilt functions to write rules
  2. Validating the Screen Input using OPM inbuilt validation methods
  3. Creating New Screens in OPA and testing them using Debugger.

In the later articles we will learn how to define Entities and Relationships to create our Data Model in OPM while writing more rules using the functions provided by OPM.