Policy Generation API
The Policy Generation API is responsible for generating generic policies into the core system. Requests for policy generation can be received from various external systems. Once the integration with an eternal system is achieved, some information should be received from the external system in order for the action to be successful - namely, policies are generated into the core system according to the information received from the external system.
Below you can find examples about generating a new policy by an insurance broker and by an insurance agent.
A Broker registers a new generic Policy into the system.
var p = {
policyList: [
{
insuranceTypeName: "Home",
productCode: "BA_EMB",
insuranceProductItemList: [{
code: "HHR0",
insuredAmount: 4000.0,
finalPremiumAmount: 64.25,
excessType: 'flat', //null, 'flat', 'percentageOfSumInsured', 'percentageOfLoss'
excessValue: '10'
}, {
code: "HA",
insuredAmount: 4000.0,
finalPremiumAmount: 64.53,
excessType: 'flat', //null, 'flat', 'percentageOfSumInsured', 'percentageOfLoss'
excessValue: '20'
}],
issuedDate: "2021-07-16",
startDate: "2021-07-17",
renewedPolicyNo: null,
quoteNo: "John21",
totalIndemnityLimit: 10000,
validityType: "Months",
validity: 12,
agent: {
agentId: null,
type: null
},
broker: {
brokerId: "Broker1"
},
contractor: {
uniqueIdentifier: "0000000000000",
type: "Individual person",
firstName: "John",
lastName: "Smith",
email: "john.smith@gmail.com",
phone: "0720202020"
},
insured: {
uniqueIdentifier: "0000000000000",
type: "Individual person",
firstName: "John",
lastName: "Smith",
email: "john.smith@gmail.com",
phone: "0720202020"
},
beneficiary: {
uniqueIdentifier: "0000000000000",
type: "Individual person",
firstName: "John",
lastName: "Smith",
email: "john.smith@gmail.com",
phone: "0720202020"
},
currency: "EUR",
paymentType: "BrokerCollection",
paymentFrequency: "monthly",
mentions: "Insert comment here"
},
],
};
ebs.callActionByNameAsync("PolicyGenerationAPI", p)
.then(
function(e){
console.log(e.UIResult.Data)
}
);
An Agent registers a new generic Policy into the system.
var p = {
policyList: [
{
insuranceTypeName: "Home",
productCode: "BA_EMB",
insuranceProductItemList: [{
code: "HHR0",
insuredAmount: 4000.0,
finalPremiumAmount: 64.25,
excessType: 'flat', //null, 'flat', 'percentageOfSumInsured', 'percentageOfLoss'
excessValue: '20'
}, {
code: "HA",
insuredAmount: 4000.0,
finalPremiumAmount: 64.53,
excessType: 'flat', //null, 'flat', 'percentageOfSumInsured', 'percentageOfLoss'
excessValue: '20'
}],
issuedDate: "2021-07-16",
startDate: "2021-07-17",
renewedPolicyNo: null,
quoteNo: "John21",
totalIndemnityLimit: 10000,
validityType: "Months",
validity: 12,
agent: {
agentId: "23435788",
type: "Individual person"
},
broker: {
brokerId: null
},
contractor: {
uniqueIdentifier: "0000000000000",
type: "Individual person",
firstName: "John",
lastName: "Smith",
email: "john.smith@gmail.com",
phone: "0720202020"
},
insured: {
uniqueIdentifier: "0000000000000",
type: "Individual person",
firstName: "John",
lastName: "Smith",
email: "john.smith@gmail.com",
phone: "0720202020"
},
beneficiary: {
uniqueIdentifier: "0000000000000",
type: "Individual person",
firstName: "John",
lastName: "Smith",
email: "john.smith@gmail.com",
phone: "0720202020"
},
currency: "EUR",
paymentType: "BrokerCollection",
paymentFrequency: "monthly",
mentions: "Insert comment here",
renewType: "Manual"
},
],
};
ebs.callActionByNameAsync("PolicyGenerationAPI", p)
.then(
function(e){
console.log(e.UIResult.Data)
}
);
Here is the list of data parameters included in the request:
Parameter |
Description |
---|---|
insuredObject
|
Object containing keys to describe the insured object. |
address |
Object describing address of the insured object. |
apartmentNo |
Apartment number. |
buildingNo |
Building number. |
city |
City name of a record from City entity or null. City name value must exist in the city nomenclature. |
subcity |
Subcity name. |
districtCode |
District code of a record from District entity or null. District code must exist in the district nomenclature. |
entrance |
Entrance. |
floorNo |
Floor. |
postalCode |
Postal code. |
street |
Street name. |
streetNo |
Street number. |
streetType |
Street type – one of the values existing in StreetType entity |
policyList |
List of policies to generate; Multiple policies can be generated at once |
insuranceTypeName |
The name of an insurance type configured in the system, in FTOS_IP_InsuranceType entity. |
productCode |
Insurance product code. |
insuranceProductItemList |
List of items to be included on the policy. |
code |
Item code. |
insuredAmount |
Item insured amount. |
finalPremiumAmount |
Item premium amount. |
excessType |
Deductibles for coverages. |
excessValue |
Value of deductibles. |
issuedDate |
Date of issuance, basic format ISO 8601 YYYY-MM-DD. |
startDate |
Policy begin date, basic format ISO 8601 YYYY-MM-DD. |
renewedPolicyNo |
Old policy number, in case of renewal. |
quoteNo |
Quote number. |
totalIndemnityLimit |
Total indemnity limit on the policy. |
validityType |
Type of validity. Months value supported in the first version of the API. |
validity |
How many years/months/days we want this policy to be valid for. 12 value supported in the first version of the API. |
agent |
Object containing the agent details. |
agentId |
Agent Id. |
type |
Type of the agent issuing the policy (“Individual person” or “Legal person”). |
broker |
Object containing broker details. |
brokerId |
Broker ID. |
contractor |
Area containing contractor details. |
uniqueIdentifier |
CNP or CUI, depending on the contractor’s type. |
type |
Contractor type (“Individual person” or “Legal person”). |
firstName |
Contractor first name. |
lastName |
Contractor last name. |
Contractor email. |
|
phone |
Contractor mobile phone. |
insured |
Area containing insured details. |
uniqueIdentifier |
CNP or CUI, depending on the insured type. |
type |
Insured type (“Individual person” or “Legal person”). |
firstName |
Insured first name. |
lastName |
Insured last name. |
Insured email. |
|
phone |
Insured mobile phone. |
beneficiary |
Area containing beneficiary details. |
uniqueIdentifier |
CNP or CUI, depending on the beneficiary type. |
type |
Beneficiary type (“Individual person” or “Legal person”). |
firstName |
Beneficiary first name. |
lastName |
Beneficiary last name. |
Beneficiary email. |
|
phone |
Beneficiary mobile phone. |
currency |
Currency. |
paymentType |
Payment type. Values:
|
paymentFrequency |
Payment Frequency. Values:
|
mentions |
Special mentions at Policy level. |
renewType: |
The tipe of the renewal. It can be manual or automatic etc. |
This is an example of a response:
{
"errorMessage": null,
"errorCode": null,
"isSuccess": true,
"result": {
"policyData": [{
"policyBeginDate": "2021-07-17",
"policyEndDate": "2022-07-16",
"policyId": "8707f5a4-4fae-40b2-b899-e27735c5b98e",
"policyNumber": "80000480",
}]
}
}
Response description:
Key | Description |
---|---|
Error code | Error code. |
Error message | Error message. |
isSuccess | Marks if the request was successful or not. |
result | Array of objects containing details about the identified policies. |
policyData | Array of details for each generated policy. |
policyBeginDate | Policy Start Date. |
policyEndDate | Policy End Date. |
policyId | GUID identifying the policy inside the Core Insurance Master system. |
policyNumber | Policy Number. |
The following are the error messages that can be encountered during the policy generation process:
Code |
Text |
Description |
---|---|---|
ERR06.01 |
ERR06.01 - Invalid issued date!
|
Issue date value provided on issuedDate key is less than current date |
ERR06.02 |
ERR06.02 - Invalid start date! |
Start date value provided on startDate key is less than or equal with issuedDate value |
ERR06.03 |
ERR06.03 - Invalid paymentType! |
Value provided on paymentType key is not valid (not part of the accepted values) |
ERR06.05 |
ERR06.05 - Invalid currency! |
Currency code provided on currency key is not identifed |
ERR06.08 |
ERR06.08 - Existing policy for the same quote and insurance type! |
Another policy of the same insurance type is already registered |
ERR06.09 |
ERR06.09 - Broker data cannot be identified! |
Broker does not exist |
ERR06.10 |
ERR06.10 - Invalid Excess Type! |
Excess type invalid |
ERR06.11 |
ERR06.11 - Invalid Renew Type! |
Renew type invalid |
ERR06.12 |
ERR06.12 - Quote Number missing! |
Quote number is mandatory when creating new policies (but not for renewal) |
Endpoints
The endpoint is responsible for generating generic policies in the Core system. When generating a policy, some information should be sent in order for the action to be successful. This endpoint also aligns the policies payment schedule with the one from the associated Master Policy.
In the moment a new policy is added on the Master Policy (this happens when the policy is generated, meaning the policy is in the Proposal status), the payment schedule for that policy is set up taking into consideration the unpaid installments of the associated Master Policy. More precisely, the system verifies the Master Policy payment schedule and retrieves the number of unpaid installments of that Master Policy. The resulting numberis the number of the installments for that newly added policy.
Example:
Say the Master Policy Payment Frequency is set as Quarterly.
In the fourth month from the Begin Date of the Master Policy, a new policy is added, where the End Date of the policy is the same as the End Date of the Master Policy. In this moment, on the Master Policy, the system checks the number of unpaid installments for that Master Policy and finds that there are 2 unpaid installments.
-
The new policy is generated with 2 installments of the newly issued policy. These have the same due date as the 2 unpaid installments of the Master Policy.
-
The total premium amount of the policy is divided into 2.
-
The system updated the following elements of the Master Policy:
-
The Payment Schedule is updated by adding the 2 installment sums of the policy to those 2 unpaid installment sums of the Master Policy;
-
The Payment Amount is updated by adding to the old premium amount of the Master Policy the newly added policy premium amount;
-
The IPT Amount is updated by adding to the old IPT amount of the Master Policy the newly added policy IPT amount.
-
PolicyAdminAPIs - This library contains all the necessary functions for manipulating, updating or inserting data whenever a policy generation endpoint is being called. It is split in three objects for grouping the methods based on what type of process they cover.
Function | Input parameters | Output parameters |
---|---|---|
getItemCoveredRisk(insuranceProductItemid)
Function returns all the covered risks that have been configured for an insurance product item. |
insuranceProductItemid - the id of each insurance product item found on the requested insurance product.
|
cr - list with objects for all the covered risks that have been found for the insurance product item. |
getInsuranceProductItemModuleList(insuranceProductItemId)
Function returns all the insurance product items that are part of a specific module - the fetch inside the function selects all the product items that have the same item parent id. |
insuranceProductItemId - the id of each insurance product item found on the requested insurance product.
|
fetchModules - list with objects for all the insurance product items found. |
getPolicyByQuote(quoteNo, insuranceTypeId)
Function checks if there is any existing policy that has the same quote number and insurance type. This is important for validating the generation process so there are no duplicates in the system. |
quoteNo - the quote number obtained from the generation object.insuranceTypeId - the id of the insurance type requested.
|
policyData - the existing policy found in the system. |
getInsuranceTypeIdByName(insuranceTypeName)
Function returns the id of an insurance type based on the name given at generation. |
insuranceTypeName - the insurance type name obtained from the generation object.
|
typeId - id of the insurance type found. |
isNullOrEmpty(value)
Function checks if a value is invalid. |
value - what needs to be validated.
|
True or false. |
getProductByFilters(filters)
Function selects from FTOS_IP_InsuranceProduct all the insurance products that meet the condition given through a chosen filter. |
filters - object on which the filtering is being done. It can either be an insurance type name, a product code or an insurance product id.
|
rezProduct - list with objects for all the insurance products that have been found. |
getSubcityId(subcityName, cityid)
Function returns from the Subcity entity the id of the subcity that has a specific id and name. |
subcityName - name of the subcity obtained from the generation object.cityid - id of the city for which the subcity is part of.
|
result[0]["a_Subcityid"] - the id of the first subcity found. |
getCityIdByName(cityName, districtid)
Function returns from the City entity the id of the city that is part of a specific district and has a certain name. |
cityName - name of the city obtained from the generation object
districtid - id of the district for which the city is part of.
|
result[0]["c_Cityid"] - the id of the first city found. |
compareValues(key, order)
Function compares the values of two properties, when sorting an object. If the second parameter is missing, the order is set as being ascending. Then it goes on and returns a function that compares a property of the first element with the same property of the second element. Based on that comparison, the function returns 1 or -1, value to be used when sorting the object on a function call. |
key - value of the object property on which the sorting is made.order - string stating the order of sorting (ascending/ descending). |
comparison - value of 1 or -1 depending on which value is bigger. |
getIdByAttrib(entityName, searchAttribute, searchValue)
Function builds a fetch object using it's parameters. It returns the id attribute of an entity, based on an attribute and value given on a function call. |
entityName - name of the entity the search is made on.searchAttribute - the attribute on which we want the condition to be made.searchValue - the value that the searchAttribute needs to have.
|
result[0]["a_" + entityName + "id"] - Id of the first element found. |
calculateEndDate(validity, validityType, startDate)
The function firstly checks what is the type of validity and then, based on that, it adds to the start date the number of validity units (years/ months/ days). |
validity - number of validity units.
validityType - type of validity selected for the policy.startDate - policy begin date.
|
endDate - the calculated end date for the policy. |
dateDiffInMonths(d1, d2)
Function calculates the difference in months between two dates. |
d1 - first date.
d2 - second date.
|
months - months between the two dates. |
validateInput(input)
Function contains a set of rules used for validating the policy generation object represented by the input parameter. The conditions that the function has to pass in order to go ahead with the policy generation process are based on the issued date, start date, payment type, currency, quote number and insurance type. |
input - object containing all the details necessary for generating a policy.
|
rez - object containing the generation status, an error message, an error code and a result list. |
insertAccountObject(obj)
If there isn't an existing account with the same uniqueIdentifier, based on the account type, the function inserts a new person in the Account entity and then returns the id of that entry. |
obj - object containing all the account details. |
objId - Id of the new account added. |
checkExistingAccount(uniqueIdentifier)
Function goes in the Account entity and checks if there is an existing account with the same unique identifier as the one given through the function parameter. |
uniqueIdentifier - value used in the query as a condition for finding existing accounts. |
acc[0].Accountid - Id of the first account found by the query. |
addAccountsOnPolicy(policyId, contractorObj, insuredObj, beneficiaryObj)
This function is in charge of updating the generated policy with the new ids for the contractor, insured and beneficiary. |
policyId - id of the newly generated policy.
contractorObj - object containing all the contractor details.
insuredObj - object containing all the insured details.
beneficiaryObj - object containing all the beneficiary details.
|
It returns an object containing all three ids. |
addPolicyInsItemXCoveredRisk(policyInsuranceItemId, insuranceProductItemId, insuredAmount, currencyId)
The function adds the covered risks of the insurance item on the policy. It calls the getItemCoveredRisk function with the id of the insurance product item as a parameter to get the covered risks and then it inserts all the details in the FTOS_INSPA_PolicyInsItemXCoveredRisk entity. |
policyInsuranceItemId - id of the policy insurance item.
insuranceProductItemId - id of the insurance product item. insuredAmount - the amount that is set as valueLimit if there is none on the covered risk.
currencyId - the currency set for the risk value.
|
N/A |
addProductItem(insertValues)
The function gets all the necessary details of the product item ready to be added on the policy. After processing the data received during policy generation, the function inserts a new product item in the FTOS_INSPA_PolicyInsuranceItem entity. |
insertValues - object containing all the required details for finding and adding a new product item on the new policy.
|
N/A |
adjustSchedule(paymentScheduleId, PremiumAmount, installmentId, brokerCommission, tax)
Function selects the specific installment that needs to be adjusted and then it updates it with the correct amount so that the sum of all the installments amount would be equal with the policy premium amount. |
paymentScheduleId - id of the payment schedule which the installment is part of.PremiumAmount - total premium amount of the policy.installmentId - id of the installment that needs adjusting.
brokerCommission - commission of the broker.
tax - tax rate of the broker. |
diff - the difference between the policy premium amount and the total of the other installments premium amount. |
calculateFirstInstallmentDueDate(startDate)
Function that calculates the first installment due date by subtracting one day from the start date. |
startDate - date from which the day gets subtracted.
|
firstDateFinal - final version of the date. |
calculateInstallments(firstInstallmentDueDate, installmentsNo, PremiumAmount, validity, policyValidityType)
It calculates, based on the policy validity type, how many installments should be created for a particular schedule and it increments the due date accordingly. It also sorts the list of installments in the desired order and returns it. |
firstInstallmentDueDate - due date of the first installment.
installmentsNo - how many installments should be generated.PremiumAmount - policy premium amount.validity - number of the validity units.
policyValidityType - type of the policy validity.
|
result - list of installment objects sorted by the due date. |
generateSchedule(policyId, param, policyValidityType, firstInstallmentDueDate, adjustFirstInstallment, adjustLastInstallment)
This function generates a schedule of installments sorted by the due date on the new policy. It needs to be specified on a function call, by using the adjustFirstInstallment and adjustLastInstallment boolean parameters, which installment needs to be adjusted. If both are true the function throws an error. |
policyId - id of the newly generated policy.
param - object with parameters used for calculating the installments details.policyValidityType - type of the policy validity.
firstInstallmentDueDate - due date of the first installment.
adjustFirstInstallment - boolean value on which the first installment is adjusted or not.
adjustLastInstallment - boolean value on which the last installment is adjusted or not. |
installmentsList - list of installment objects sorted by the due date. |
getBrokerDataByName(brokerName)
The functions returns from the FTOS_IP_InsuranceBroker entity a broker with a given name received as a parameter. If nothing was found, the function returns null. |
brokerName - the name of the broker on which the filtering is done.
|
fetchResult[0] - the broker found by the query. |
addInsuredObject(policyId, objectDetails)
When this function gets called it performs three inserts, on three different entities: FTOS_INSQB_InsuredObject, FTOS_INSQB_Address and FTOS_INSQB_InsuredObjectProperty. With the help of other functions, it manipulates the data in order to insert it in the related table. |
policyId - id of the newly generated policy.
objectDetails - details of the object that gets insured.
|
It returns an object with all three ids of the new entries. |
getProductItemsByProductId(productId)
The function selects the product items configured on a product from the FTOS_IP_InsuranceProductItem entity, filtered by the product id. If any product item was found, the function goes on and gets all the modules configured on each item. If no items were found, the function returns null. |
productId - id of the product on which the items are configured.
|
rez - object with all the product items found by the query together with their modules. |
calculatePolicyPremiumAmount(itemList)
This function calculates the policy premium amount, which is a sum between all the finalPremiumAmount attributes from all the product items. |
itemList - list of all product items. |
totalAmount - policy's total premium amount. |
calculateTotalInsuredAmount(itemList)
This short function calculates the total insured amount, which is a sum between all the insuredAmount attributes the product items have. |
itemList - list of all product items. |
totalAmount - policy's total insured amount. |
generatePolicy(inputValues)
This function collects and manipulates all the required data for generating a new policy. It receives the generation object with all the policy details as a parameter and it builds different objects with them, used for inserting or updating data in the required entities. The main one is the objInsert object, which contains most of the policy details that get inserted in the FTOS_INSPA_Policy entity. The second one is the insertProductItemObj object used for adding all the product items on the newly generated policy. And last one is installmentsBrokerParameters containing details for generating the schedule. After all the data was added or updated, the function returns an object with some information about the new policy.
|
inputValues - object with the policy configuration details used in the policy generation process.
|
response - object with information about the new policy. |
The endpoint is used for selecting all the data for a module that has the Id matching to the one obtained from the context JSON object.
Function: getModuleData()
- The function contains a fluent query that returns the required attributes from the FTOS_INSPA_PolicyInsuranceItem entity for a module with a specific Id. After retrieving the results, the function calls the setData
method for passing the object to the result parameter of the client-side callback function.
Input parameters: N/A.
Output parameters: moduleList
- JSON object containing the module data.
The endpoint is used for selecting all the data for a policy covered risk that has the Id matching to the one obtained from the context JSON object. When calling the endpoint with the ebs.callActionByNameAsync
method, an object containing the formData.id
gets passed as a parameter.
Function: getCoveredRisk()
- The function contains a fluent query that returns the required attributes from the FTOS_INSPA_PolicyInsItemXCoveredRisk entity for a covered risk with a specific id. After retrieving the results the function calls the setData method for passing the object to the result parameter of the client-side callback function.
Input parameters: N/A.
Output parameters: coveredRiskList
- JSON object containing the covered risk data
This endpoint is used to generate a term life guaranteed/jet issue policy.
Input parameters:
-
insuranceTypeName: ''Term Life''
-
productCode: "TLF"
-
termLifeType: option set
-
insuranceProductItemList
-
code: "TLF0"
-
sumInsured: numeric
-
regularPremiumBase: numeric
-
annualizedPremiumBase: numeric (attribute to be added, numeric)
-
-
code: "CI0"
-
isCriticalIllnessIncluded: (attribute to be added, Boolean type)
-
regularPremiumCriticalIllness: numeric
-
annualizedPremiumCriticalIllness: numeric (attribute to be added)
-
-
regularPremiumTotal: numeric
-
annualizedPremiumTotal: numeric (attribute to be added)
-
policyFee: numeric
-
-
issuedDate ( invariant Date type)
-
startDate (invariant Date type)
-
renewedPolicyNo: null (text type)
-
renewTypeId: null (option set)
-
quoteNo: text
-
validityType: option set (days, months, years)
-
validity: numeric
-
policyTerm: numeric
-
frequency: option set
-
currency: currency code
-
paymentType: option set (FTOS_INSPA_PolicyPaymentType, with "directDebit" our only option here)
-
agent:
-
FTOS_INS_Agentid (lookup)
-
-
broker:
-
brokerId: null (attribute to be added, lookup)
-
-
contractor (policyholder):
-
Name
-
PIN
-
dateOfBirth
-
email
-
phone
-
-
insured:
-
Name
-
PIN
-
dateOfBirth
-
email
-
phone
-
Response:
-
policyBeginDate;
-
policyEndDate;
-
policyId;
-
policyNumber.
Validations:
-
If the issue date value provided on
issuedDate
is less than current date, the following error message is displayed:"Invalid issued date!"
; -
If the start date value provided on
startDate
is less than or equal withissuedDate
value, the following error message is displayed:"Invalid start date!"
; -
If the value provided on
paymentType
is not valid, not part of the accepted values, the following error message is displayed:"Invalid payment Type!"
; -
If the currency code provided on
currency
is not identified, the following error message is displayed:"Invalid currency!"
; -
If another policy of the same insurance type is already registered, the following error message is displayed:
"Existing policy for the same quote and insurance type!"
.