Get UW Rules Result API
Use this API to run underwriting formulas, based on the underwriting rules (UW Rules) defined at product level. In order to use the API, the request needs to include all the keys expected by formula engine, for each context type. If necessary, in the API call you can specify a date and get the underwriting decision that was valid at that date, for your product.
A user makes a call for the underwriting decision result for an insurance product item, based on the code of the insurance product. The user wants the decision which was valid at a certain date - respectively, 2021-05-21.
let p = {
"productCode": "HH01",
"validityDate": "2021-05-21",
"uwRules": [{
"contextType": "Underwriting",
"details": {
"resistanceStructure": "Metal",
"usageType": "Main residence",
"constructionYear": 2000,
"coverage": "Content",
"insuredAmount": 200000
}
}]
};
ebs.callActionByNameAsync("FTOS_IP_GetUWRulesResultAPI", p).then(function(e) {
console.log(e)
})
Here is the list of data parameters included in the request:
| Parameter | Description |
|---|---|
| productCode | The code of the Insurance Product. |
| validityDate | The reference date, prior to the current date, for getting an earlier version of the product formulas structure. This key is not mandatory. When it is not provided, the API calls the current version of the formula. Accepted formats are: yyyy-mm-dd, dd/mm/yyyy, dd-mm-yyyy, or dd.mm.yyyy. |
| uwRules | Array with the objects keys listed and described bellow. The array is used to identify and run the underwriting formulas for the specified Item. |
| contextType | The context type object key needed to run the UW formula. |
| details | An object containing the keys needed to run the UW formula. The object structure can be different for each product, based on the formula configuration. |
This is an example of a response:
{
"isSuccess": true,
"errorMessage": null,
"errorCode": null,
"result": [
{
"contexType": "Underwriting",
"decision": {
"resistanceStructure": "Metal",
"usageType": "Main residence",
"constructionYear": 2000.0,
"coverage": "Content",
"insuredAmount": 200000.0,
"uwBuildingSumInsured": "Passed",
"uwConstructionYyear": "Passed",
"uwResistanceStructure": "Passed",
"uwUsageType": "Passed",
"uwDecision": "Passed"
}
}
]
}
| Key | Description |
|---|---|
| Error code | Error code. |
| Error message | Error message. |
| isSuccess | Marks whether the request was successful or not. |
| result | Array of objects containing details about the UW decision results. |
| contextType | The context type defined on UW formula (underwriting). |
| decision | The result returned after running the UW formula. |
The following are the error messages that can be encountered while calling the Get UW Rules API:
| Code | Text | Description |
|---|---|---|
| ERR.IP.50301 | ERR.IP.50201 - Invalid validityDate format! Please, use yyyy-mm-dd or dd/mm/yyyy or dd-mm-yyyy or dd.mm.yyyy! | Invalid date format for validityDate input parameter. |
| ERR.IP.50302 | ERR.IP.50202 - Invalid validityDate! | Invalid date for validityDate input parameter. |
| ERR.IP.50303 | ERR.IP.50303 - Invalid key request! + “inputKeyName”+ "! | Missing parameters in the request or wrong parameter name. |
| ERR.IP.50304 | ERR.IP.50304 - No active product identified! | No active insurance product found. |
| ERR.IP.50305 | ERR.IP.50305 - Error! The "code of product" insurance product was not approved at the requested date!" | No active insurance product factory found at the date specified in validityDate input parameter. |
| ERR.IP.50306 | ERR.IP.50306 - Underwriting context type is not defined! | The underwriting context type is not defined on the requested product. |
| ERR.IP.50307 | ERR.IP.50307 - Product doesn't have any UW formula configured. | Product doesn't have any UW formula configured. |
| ERR.IP.50308 | ERR.IP.50308 - Invalid context type value: + “contextTypeInputValue”. | The key for underwriting context type has a wrong value. |
| ERR.IP.50309 | ERR.IP.50309 - Formula definition includes other input values. Check the definition: + “invalidCodes”. | Formula input parameters names are wrong. |
The FTOS_IP_GetUWRulesResultAPI endpoint is responsible for running the underwriting formula defined on product level, and retuning the underwriting decision results. The endpoint runs the formulas assigned to the product, simulating the Test Scenario functionality available on product level, in Innovation Studio.
From the FTOS_IP_InsuranceProductAPIs library, the GetUWRulesResult() function is used for returning the underwriting decision results. The GetFormulaInputParameters() function wraps the following functions, necessary for validating and returning the results:
This function validates the request fields.
Input parameters: inputData - The object containing the keys needed to call the endpoint.
Output parameters: An object containing the following keys to describe the result of the validation:
-
isSuccess- true/ false - The boolean that shows whether the validation is successful. -
errorMessage- A null value or an error message as described in the error messages list. -
errorCode- A null value or an error code as described in the error messages list. -
result= An empty array [] or an array with details about the UW formula input parameters , as described in the response description section.
This function executes the following:
-
Runs the underwriting formulas attached to the specified product - identified by the code provided in the request.
-
Uses other helper functions, implemented in the same library, to get the product details.
-
Calls the testUnderwritting function from FTOS.IP_CALC.FormulaEngineHelper library.
-
Returns the underwriting decision results.
The getUWRulesResult() function is called inside the endpoint only if the isSuccess key from the response of the validateRequest function is true.
Input parameters: inputData - The object containing the keys needed to call the function.
Output parameters: An array containing objects with 2 keys:
-
contextType- The underwriting context type used for the selected product. -
decision- An object containing the keys and the values from the input object (details about the UW rules) and also the corresponding keys and values for decision results.