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 2021.
policy.copyAndEndDateContractPeriod(java.sql.Date.valueOf("2021-01-01"))
Explanation
The above logic uses a Predefined Methods 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 2020 (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 2021 (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 2021.
policy.policyEnrollmentList.each { policyEnrollment -> def pepWithProductA = policyEnrollment.policyEnrollmentProductList.find { pep -> pep.derivedEnrollmentProduct.code == "A" } if(pepWithProductA != null) { policyEnrollment.copyAndEndDateEnrollmentProduct("A", "B", java.sql.Date.valueOf("2021-01-01"), 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 Methods 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 2020 (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 2021 (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 2021.
policy.copyAndEndDateBrokerAgent("B", java.sql.Date.valueOf("2021-01-01")
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 Methods 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 2020 (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 2021 (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 2021.
policy.copyAndEndDateBrokerAgent("B", java.sql.Date.valueOf("2021-01-01"))
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 Methods 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 2020 (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 2021 (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) }
Scenario 6
Use Bulk Update to create a policy enrollment event when a member on the policy went 26 today. As part of the business event, the update needs to create a policy enrollment event on the policy.
def peWithMemberAge26 = { policy.policyEnrollmentList.find { pe -> pe.person.dateOfBirth == new Date.clearTime() - 26.year } if(peWithMemberAge26 != null) { def newPolicyEnrollmentEvent = policy.addPolicyEnrollmentEvent("Member reached age 26", java.sql.Date.valueOf("2021-01-01"), null, person.code, null) } }