Examples

This document details some of the common examples of bulk updates and their corresponding dynamic logic excerpts.

Scenario 1

Use Bulk Update to automatically renew a policy. As part of automatic renewal, the update needs to create a new contract period on the policy for year 2017.

policy.copyAndEndDateContractPeriod(Date.parse("yyyy-MM-dd", "2017-01-01").time)

Explanation

The above logic uses a predefined method on policies. The predefined method 'copyAndEndDateContractPeriod' iterates over the existing contract period list on policy, picks up the latest contract, end dates the contract on 31st Dec 2016 (1 day less than the date passed in as a parameter to the method). It creates a new contract period record as a copy of the latest contract period, giving it the start date as 1st Jan 2017 (date passed in as a parameter) and adds it as a detail to the policy.

Scenario 2

Use Bulk Update to change the enrollment product on the policy from product A to product B.

As part of a plan change all members on the policy that have product A must get product B starting 1st Jan 2017.

policy.policyEnrollmentList.each { policyEnrollment ->

    def pepWithProductA = policyEnrollment.policyEnrollmentProductList.find { pep ->
       pep.derivedEnrollmentProduct.code == "A"
    }
    if(pepWithProductA != null) {
         policyEnrollment.copyAndEndDateEnrollmentProduct("A", "B",  new java.sql.Date(Date.parse("yyyy-MM-dd", "2019-01-01").time), true, false)
    }
}

Explanation

In order to achieve the above requirement, only the policies having enrollment product A, are picked up for the bulk update activity. This can be achieved by configuring the bulk update definition with enrollment product A. To update the product to B, the logic uses predefined method on policy enrollments.

The dynamic logic iterates over the list of policy enrollments to find the policy enrollment with product A. If it finds such a policy enrollment, it uses the predefined method to copy the enrollment product.

The predefined method 'copyAndEndDateEnrollmentProduct' picks up the policy enrollment product for enrollment product A and end dates the product on 31st Dec 2016 (1 day less than the date passed in as a parameter to the method). It creates a new enrollment product record as a copy of the end dated enrollment product, giving it the start date as 1st Jan 2017 (date passed in as a parameter), assigns the enrollment product as B and adds it as a detail to the policy enrollment.

Scenario 3

Use Bulk Update to change the broker on the policy. As part of a broker change for a group of policies, all policies with broker A need to have broker B starting 1st Jan 2017.

policy.copyAndEndDateBrokerAgent("B", Date.parse("yyyy-MM-dd", "2017-01-01").time)

Explanation

In order to achieve the above requirement, only the policies having broker A, are picked up for the bulk update activity. This can be achieved by configuring the bulk update definition with broker A. To update the broker to B, the logic uses a predefined method on policies.

The predefined method 'copyAndEndDateBrokerAgent' iterates over the existing broker agent list on policy enrollment, picks up the latest broker agent, end dates the broker agent on 31st Dec 2016 (1 day less than the date passed in as a parameter to the method). It creates a new broker agent record as a copy of the latest broker agent, giving it the start date as 1st Jan 2017 (date passed in as a parameter), assigns the broker as B and adds it as a detail to the policy.

Scenario 4

Use Bulk Update to change the agent on the policy. As part of an agent change for a group of policies, all policies with agent A need to have agent B starting 1st Jan 2017.

policy.copyAndEndDateBrokerAgent("B", Date.parse("yyyy-MM-dd",  "2017-01-01").time)

Explanation

In order to achieve the above requirement, only the policies having agent A, are picked up for the bulk update activity. This can be achieved by configuring the bulk update definition with agent A. To update the agent to B, the logic uses a predefined method on policies.

The predefined method 'copyAndEndDateBrokerAgent' iterates over the existing broker agent list on policy enrollment, picks up the latest broker agent, end dates the broker agent on 31st Dec 2016 (1 day less than the date passed in as a parameter to the method). It creates a new broker agent record as a copy of the latest broker agent, giving it the start date as 1st Jan 2017 (date passed in as a parameter), assigns the agent as B and adds it as a detail to the policy.

Scenario 5

Use Bulk Update to add a new bill receiver to the latest collection setting on the policy for all premium splits. The following needs to happen:

  • Add a bill receiver retrieved by dynamic logic function NEW with percentage 10 to the latest policy collection setting on the policy.

policy.policyPremiumBillAllocationList.sort( { policyPremiumBillAllocation ->
       policyPremiumBillAllocation.startDate } ).last().policyBillReceiverList.each {
policyBillReceiver ->
       policyPremiumBillAllocation.addPolicyBillReceiver("NEW", 10)
    }

Explanation

In order to achieve the above requirement, the logic picks up the latest policy premium bill allocation. To add a new policy bill receiver, the logic uses a predefined method on policyPremiumBillAllocation, addPolicyBillReceiver with the dynamic logic function code and percentage.