# Car Insurance

Contents

This sample project is for the Car Insurance industry and calculates the premium of a car based on Auto and Base premium components. The business rules are for risk classification and calculation of the insurance premium.

### Decision Model

The main Car Premium.xml decision graph automatically resolves the dependencies between different logic implementations (i.e. decision table, natural language, etc.).

There are two inputs to this graph, Car and the High Theft Probability. The Car details input feeds into the Base premium, Car Style premium and the rating determination decisions.

The High Theft Probability data and two business knowledge documents are used to determine the rating.

The Rating, Car style calculate the Auto premium. This along with the Base premium decision feed into the final car premium decision. There is a Knowledge source document Underwriting Guidelines that is reference to the overarching Premium calculation.

### Decision Flow

If a Flow is preferred, then the decision requirement diagram above can be presented as a Decision Flow. For this example, add a start node and link to an Activity node that loads High risk cars from the Database. This is then linked to three Decision tables, Theft Rating, Injury Rating and a final Premium calculation. Finally an End node completes the flow.

This sample project calculates the premium of a car based on Auto and Base premium components. The following business rules are for risk classification and calculation of the premium of a car.

#### Potential Theft Category definition

• If the car is a convertible, then the car’s potential theft rating is high.
• If the car’s price is greater than \$45,000, then the car’s potential theft rating is high.
• If the car model is on the list of “High Theft Probability Auto”, then the car’s potential theft rating is high.
• If all of the following are true, then the car’s potential theft rating is moderate.
• car’s price is between \$20,000 and \$45,000,
• the car model is not on the list of “High Theft Probability Auto”
• If all of the following are true, then the car’s potential theft rating is low:
• car’s price is less than \$20,000
• the car model is not on the list of “High Theft Probability Auto”

(The “High Theft Probability Auto” list is maintained by Risk Management and provided as input to the eligibility rating process. This list is retrieved from a Database e.g. MS SQL SERVER)

#### Potential Occupant Injury Category

• If the car has no airbags, then the car’s potential occupant injury rating is extremely high.
• If the car only has driver’s side airbags, then the car’s potential occupant injury rating is high.
• If the car has driver’s side and front passenger airbags, then the car’s potential occupant injury rating is moderate.
• If the car has a driver, front passenger and side panel airbags, then the car’s potential occupant injury is low.
• If the car is a convertible and has no roll bar, then the potential occupant injury is extremely high.

• If a compact car, then the base premium is \$250.
• If sedan, then the base premium is \$400.
• If a luxury car, then the base premium is \$500.
• If the car is new, then increase the premium by \$400.
• If the model year is the same as the current year, then this is a new car.
• If the model year is the same as next year, then the car is new.
• If the car is less than 5 years old, then increase the premium by \$300.
• If the car is between 5 and 10 years old, then increase the premium by \$250.
• If uninsured motorist coverage is included, then increase the premium by \$300
• If medical coverage is included, then increase the premium by \$600.
• If Potential Occupant Injury is Extremely High, then increase the premium by \$1,000.
• If Potential Occupant Injury is High, then increase the premium by \$500.
• If Potential Theft is High, then increase the premium by \$500.

### Decision Tables

The above business rules in each decision are formalized as shown in the Decision Tables below:

## Open the Car Insurance sample project

On the Home screen, under Sample Gallery, search for “Car Insurance”. Then click on Download & Install.

Looking at the logic documents in the Project Explorer view, Car Flow.xml is the main model that connects all the sub-models.

## Database Setup

Install MS SQL and MS SQL Server Management Studio.

Once installed, open MS SQL Studio and create the following database and tables.

### HighRiskCars

The Potential Theft Category decision needs to access a list of “High Theft Probability Auto” which is maintained in our sample database. You can follow the instructions below to create your own sample database.

#### Create Table

Create a Database called Car-Insurance and then run the following script against it to create a table called HighRiskCars

```USE [Car-Insurance]
GO

CREATE TABLE [dbo].[HighRiskCars](
[Id] [int] IDENTITY(1,1) NOT NULL,
[Model] [nvarchar](50) NULL,
CONSTRAINT [PK_HighRiskCars] PRIMARY KEY CLUSTERED
( [Id] ASC ) ON [PRIMARY]
)
GO
```

#### Prepare Data

Once you create the database called Car-Insurance Run the script below to create the required data records:

```USE [Car-Insurance]
GO

INSERT INTO [dbo].[HighRiskCars] VALUES ('Hyundai','IX35')
INSERT INTO [dbo].[HighRiskCars] VALUES ('BMW','E63')
GO
```

### Thefts

In this version of the sample project, an Information Requirements Diagram is used to build up the HighTheftAutoList rather than reading it directly from the database.

#### Create Table

Create a Database called Car-Insurance and then run the following script against it to create a table called Thefts

```USE [Car-Insurance]
GO

CREATE TABLE [dbo].[Thefts](
[Id] [int] IDENTITY(1,1) NOT NULL,
[Model] [nvarchar](50) NOT NULL,
[Year] [int] NOT NULL,
[Type] [nvarchar](50) NOT NULL,
[Location] [nvarchar](50) NOT NULL,
[Use] [nvarchar](50) NULL
)

GO
```

#### Prepare Data

Once you create the database called Car-Insurance Run the script below to create the required data records:

```USE [Car-Insurance]
GO

INSERT INTO [dbo].[Thefts] VALUES ('Honda','CR-Z',2014,'Sedan','VIC','City')
INSERT INTO [dbo].[Thefts] VALUES ('BMW','E63',2016,'Sedan','VIC','City')
INSERT INTO [dbo].[Thefts] VALUES ('Ford','Pickup',2010,'Van','NT','City')
INSERT INTO [dbo].[Thefts] VALUES ('Ford','Taurus',2000,'Sedan','VIC','City')
INSERT INTO [dbo].[Thefts] VALUES ('Austin','Mini',2000,'Mini','NSW','City')
INSERT INTO [dbo].[Thefts] VALUES ('Hyundai','Santa Fe',2010,'SUV','VIC','City')
INSERT INTO [dbo].[Thefts] VALUES ('Hyundai','Tucson',2010,'SUV','VIC','City')
INSERT INTO [dbo].[Thefts] VALUES ('Ford','Pickup',2010,'Van','NSW','City')
INSERT INTO [dbo].[Thefts] VALUES ('Ford','Ranger',1920,'Wagon','NSW','City')
INSERT INTO [dbo].[Thefts] VALUES ('Hyundai','Santa Fe',2010,'SUV','NSW','Off-road')
INSERT INTO [dbo].[Thefts] VALUES ('Aprila','RS250',2010,'Motorcycle','VIC','City')
INSERT INTO [dbo].[Thefts] VALUES ('Suzuki','RGV250',2015,'Motorcycle','VIC','City')
INSERT INTO [dbo].[Thefts] VALUES ('Yamaha','TZR250',2015,'Motorcycle','VIC','City')
GO
```

### Cars

#### Create Table

Create a Database called Car-Insurance and then run the following script against it to create a table called Cars

```USE [Car-Insurance]
GO

CREATE TABLE [dbo].[Cars](
[Id] [int] IDENTITY(1,1) NOT NULL,
[Model] [nvarchar](50) NOT NULL,
[Year] [int] NOT NULL,
[Type] [nvarchar](50) NOT NULL,
[Location] [nvarchar](50) NOT NULL,
[Use] [nvarchar](50) NULL
)

GO
```

#### Prepare Data

Once you create the database called Car-Insurance Run the script below to create the required data records:

```USE [Car-Insurance]
GO

INSERT INTO [dbo].[Cars] VALUES ('Honda','CR-Z',2014,'Sedan','VIC','City')
INSERT INTO [dbo].[Cars] VALUES ('BMW','E63',2016,'Sedan','VIC','City')
INSERT INTO [dbo].[Cars] VALUES ('Ford','Pickup',2010,'Van','NT','City')
INSERT INTO [dbo].[Cars] VALUES ('Ford','Taurus',2000,'Sedan','VIC','City')
INSERT INTO [dbo].[Cars] VALUES ('Austin','Mini',2000,'Mini','NSW','City')
INSERT INTO [dbo].[Cars] VALUES ('Hyundai','Santa Fe',2010,'SUV','VIC','City')
INSERT INTO [dbo].[Cars] VALUES ('Hyundai','Tucson',2010,'SUV','VIC','City')
INSERT INTO [dbo].[Cars] VALUES ('Ford','Pickup',2010,'Van','NSW','City')
INSERT INTO [dbo].[Cars] VALUES ('Ford','Ranger',1920,'Wagon','NSW','City')
INSERT INTO [dbo].[Cars] VALUES ('Hyundai','Santa Fe',2010,'SUV','NSW','Off-road')
INSERT INTO [dbo].[Cars] VALUES ('Aprila','RS250',2010,'Motorcycle','VIC','City')
INSERT INTO [dbo].[Cars] VALUES ('Suzuki','RGV250',2015,'Motorcycle','VIC','City')
INSERT INTO [dbo].[Cars] VALUES ('Yamaha','TZR250',2015,'Motorcycle','VIC','City')
GO
```

## Project Steps

1. Create the database following the steps above

2. Create a New project in Designer

3. Add a new Generic Flow document to the project

4. Validate the car

Validate the car using an Input Validation Logic file.

The purpose of creating this logic file is to check the car’s brand and car’s model in the input, which should not be empty. This logic document notifies us if the input does not include the model of the car, giving the notification with the text ‘Car model must be provided,’ and if the input does not include the car’s brand, it gives us ‘Car made must be provided.’

How to create the validation document:

Add a new Input Validation Logic document to the project.

In 2 steps, we create this validation document.

• Define which part of input we want to validate.
• Define the rules.

To define which part of the input should be validated, use the toolbar to drag a Logic operator, drop it under the validation, and change the name of the logic to main.

Then drag and drop the And operator under the Logic (because we want to check two different input parts) and also the Null operator under the And operator. For the Null operator, change ‘Is Negative’ to True from the properties window since we need to check first whether we have a car in our input.

In the next step, add the Validate operation under And operation from the toolbar, and set which value should be checked in the input. In this scenario, we add car. Model as a value to validate the operator in the Properties window. In the same window, add the text that you want to get as a notification in the message under the notice drop-down. Doing the same work for car-made as well.

To define the rules, we add another Logic under the validation to say, check two things: first, these two parts of the input are not Null, and second, these two parts are not empty.

Drag and drop the OR operator under the logic and leave the Null and Empty operators under that. Just put the \$v for the value of these two operators in the properties window.

5. Once the car is valid, connect the database and get the required data to calculate the premium value

6. Build High Thefts Probability List

Use an Information Requirements Diagram to define the High Theft Probability depending on the model, city and the country in which the car is being used.

Use a Decision Requirements Diagram to calculate the car insurance premium.

Decision tables are used to define the rules.

Natural Language files were also used for defining the rules.

8. The result shows the Payable amount for the premium

## How to run the project

1. Open the file Car Flow.xml

2. Click on the Logic Run Template from the main toolbar menu.

3. Select a template from the Logic Run Template modal. There are two templates, one with Valid and one with Invalid data. This allows testing of valid and invalid inputs.

4. Click Debug.

5. Click Next Step to go to each step of the flow.

If you want to stop debugging and see the output, click Stop Debugging.

6. When your model is linked to other models and you are trying to navigate into the child model, FlexRule Designer will ask you to confirm that you wish to open and navigate to the child model and show debug navigation through the child. Or just execute the child model and return the output.

7. Once the execution is successful, you will see a success notification modal appear.

8. Navigate to the Parameters view and you will see the final output in this window.