Overview
After mastering the basics of DMN, you’re ready to explore more advanced modeling techniques. This guide builds on your foundation to help you create sophisticated decision models that can handle complex business scenarios. We’ll cover advanced features like Business Knowledge Models (BKMs), complex data types, list operations, and context expressions. Throughout this guide, we’ll use a travel insurance pricing example to illustrate these concepts. This guide describes the Decision Model & Notation (DMN) structure that could be used as a basis for assessing travel insurance premiums based on traveler details, trip details, and associated risks with their locations and medical conditions.The Business Problem to be Solved
In this decision, the company has a few factors that impact how much the insurance premium will be for the customer looking to go on a trip. There are a few factors that impact this, there’s a base price of the premium itself, we will look at claims that have been done by this person, a medical condition assessment and a destination risk factor. After gathering these sub-decisions, we will build a final price for the premium for the trip.Walkthrough of the Decision Building
Let’s break down the process of building out this travel insurance decision model:Identify the main decision and sub-factors
- The main decision is calculating the Final Premium
- We’ve also identified four key sub-factors that feed into this:
- Base Premium by Age
- Claims Assessment
- Medical Condition Assessment
- Destination Risk Factor
Start at the End!
With DMN, the best way to model a decision is with the final question to be answered at the top. This aligns with the Top-Down design approach. While it will be mapped first, it will be the last decision we will ultimately build, which is the Final Premium:- Combine the outputs of the four sub-decisions
- Uses a simple mathematical formula
- Demonstrates how modular decisions can be composed
Start Mapping Out Each Decision
- Base Premium: A simple decision table mapping age ranges to base premium amounts. Uses Unique hit policy since each age maps to one premium.
- Claims Assessment: Filters the claim history to only consider approved claims. Uses Collect Max to return highest value. Demonstrates filtering arrays and using ?-notation.
- Medical Assessment: Evaluates medical conditions list against condition severity tiers. Shows iterating over lists in decision tables.
- Destination Risk: Here we use a Business Knowledge Model (BKM) to encapsulate the logic for determining country risk level based on a predefined mapping. The decision table then looks up the highest risk among all countries on the trip.
Putting it Together - The Final Premium
Last decision we will need to do is build the Final Premium:- Combine the outputs of the four sub-decisions
- Uses a simple mathematical formula
- Demonstrates how modular decisions can be composed
Key Concepts to be Showcased
This example will showcase several key DMN concepts:- Structuring decisions into sub-decisions
- Input data mapping
- Hit policies (Unique, Collect Max)
- Filtering and iterating over lists
- Using BKMs for complex logic
- Composing decisions together
Working with Complex Data Types
Real-world decisions often require more complex data than a simple flat model with just numbers and strings. DMN allows you to define custom data structures to model your business domain accurately. In this case we’re going to build a DMN model for a travel insurance situation for someone building an itinerary to travel to potentially multiple countries and we want to determine how much it will cost to give that person a travel insurance policy. The factors that will be discussed in the next section focused on Creating Custom Data Types.Creating the Input Data Structure with Custom Data Types
In our travel insurance example we are going to be looking at building a both a traveler and the trip details as complex data objects:- Traveler:
- age (number)
- claim history (collection of a claim structure)
- medical conditions (string collection)
- Trip Details:
- countries (string collection)
- start date (date)
- end date (date)
Creating the Data Types in Aletyx Playground
Here’s how to create these data structures:- Navigate to Aletyx Playground in your browser
- From the landing page, click New Decision to create a new DMN model
- You’ll be presented with an empty DMN model editor. This is where we’ll design our decision model
- First, change the name of the model from “Untitled” to “travelPremium”
- In Aletyx Playground, open the properties panel (press “i” with nothing selected)
- Click on “Data Types”
- Click “Add” to create a new data type
Creating Traveler in the Data Types
Create a Claim Structure
For the claim structure you need to create 4 different properties as outlined in the table. If you add an Enumeration to the claim history it will help facilitate an easier implementation of the decisions.
Creating the Trip Data Type
When building the model for the Trip Details, the dates could be used for start and end of the trip and for further enhancement in the decisions. The country list being a collection allows for multiple countries to be added to the data payload so that multiple can be evaluated against.
Using Complex Types in Decision Models
Once defined, you can use these types for Input Data nodes:- Create an Input Data node named “Traveler”
- Set its data type to “Traveler”
- Create an Input Data node named “Trip Details”
- Set its data type to “Trip Details”
Traveler.ageTraveler.medical conditionsTrip Details.country
Decision Nodes Logic
Base Premium (Decision Table)
Hit Policy: U (Unique)
Claims Assessment
Hit Policy C> (Collect Max)
Medical Assessment
Country Risk Level BKM
First, we need to build our BKM. This is done by creating a BKM Function with the type FEEL. The function will be called Country Risk Level of type String and has a parameter country of type string. Then you will create a Decision Table attached to it with the following parameters for it.
Country Risk Assessment BKM
The way we would approach this in typical approaches would be to do something like the following in pseudocode:Destination Risk Factor - Building a Decision Using a Context
In FEEL, we can simplify this some with the use of our function we created in the previous section. This will allow us to invoke the function and return the results of the risk factor of a given country. Once this function is created, we need to edit our Decision for the Destination Risk Factor. This will be handled as a Context. When you create the context, you will need to do it in a few steps.- First when editing the Destination Risk Factor, for the Select expression menu, select Context
- Edit ContextEntry-1 to being Highest Risk with a type string by clicking the first box.
What each numbered part of the context expression is
What each numbered part of the context expression is
- Context Variable — In a Context expression you first define named variables usable within the calculation. “Highest Risk” is defined here as a string variable, available to the later parts of the decision. Click this box to open the definition window for that context variable.
- Context Variable Definition — What you name in this box defines the context variable that holds the returned value for the rest of this Context decision.
- Data Type Dropdown — DMN requires explicit typing of all variables. This dropdown selects from built-in types (string, number, boolean, date) or custom complex types.
- Type Management — The Manage button lets you create, edit, or import custom data types for use in your decision model.