This formula is designed to automate the default enrollment process for benefits, specifically focusing on the Vision Plan. It works within a benefits enrollment system to determine the correct default coverage option based on an employee’s previous plan and their current dependent eligibility.
/**************************************************************
Formula Name: BEN_VISION_DEFAULT_ENROLLMENT
Formula Type: Default Enrollment
Purpose: Default Enrollment
Change History:
/*************************************************************/
INPUTS are NUM_ELIG_DPNT
Default for NUM_ELIG_DPNT is 0
DEFAULT FOR BEN_PLN_NAME is 'X'
DEFAULT FOR BEN_OPT_NAME IS 'Y'
default_data_value for PER_EXT_CONT_CONTACT_TYPE is 'X'
default_data_value for PER_EXT_CONT_DATE_OF_BIRTH is '1951-01-01' (date)
default_data_value for PER_EXT_CONT_PER_PERSON_ID is 1
DEFAULT FOR BEN_LER_NAME IS 'ABC'
DEFAULT FOR BEN_PIL_LF_EVT_OCRD_DT is '01-Jan-1950' (date)
l_pln_name = BEN_PLN_NAME
l_opt_name = BEN_OPT_NAME
l_ler_name = BEN_LER_NAME
l_num_elig_dpnt = NUM_ELIG_DPNT
l_lf_evt_ocrd_dt = BEN_PIL_LF_EVT_OCRD_DT
l_cvg_strt_dt = BEN_PIL_LF_EVT_OCRD_DT
l_sp_count = 0
l_dp_count = 0
l_eec_count = 0
l_dpc_count = 0
l_prev_emp = 'N'
l_prev_emp_s = 'N'
l_prev_emp_c = 'N'
l_prev_emp_fam = 'N'
l_prev_plan_name = 'NA'
l_prev_plan_1='Vision Plan1'
l_prev_plan_2='Vision Plan2'
AUTO_DFLT_VAL = 'N'
CARRY_FORWARD_ELIG_DPNT = 'CFWP'
l_log_data = ess_log_write('The new Coverage Date is '||to_char(l_cvg_strt_dt, 'YYYYMMDD'))
/* Get Dependent Count */
i=1
CHANGE_CONTEXTS(EFFECTIVE_DATE = l_lf_evt_ocrd_dt)
(
WHILE PER_EXT_CONT_CONTACT_TYPE.exists(i)
LOOP
(
l_person_id=PER_EXT_CONT_PER_PERSON_ID[i]
l_per_dob=PER_EXT_CONT_DATE_OF_BIRTH[i]
log = ess_log_write('l_per_dob =>'+ to_char(l_per_dob))
l_DOD_char=GET_VALUE_SET('DATE_OF_DEATH','|=P_PERSON_ID='''||TO_CHAR(l_person_id)||''''||'|P_EFFECTIVE_DATE='''|| to_char(l_lf_evt_ocrd_dt,'YYYY/MM/DD') ||'''')
IF ISNULL(l_DOD_char) = 'Y'
THEN
(
L_dod=to_date(l_DOD_char,'YYYY/MM/DD')
)
ELSE
(
L_dod=to_date(l_DOD_char,'4712/12/31')
)
log = ess_log_write('l_per_dob =>'+ to_char(l_per_dob))
log = ess_log_write('l_DOD_char =>'+ l_DOD_char)
log = ess_log_write('l_per_dob =>'+ to_char(l_per_dob))
if PER_EXT_CONT_CONTACT_TYPE[i] = 'DP' and ISNULL(l_DOD_char) <> 'Y' then
l_dp_count = l_dp_count + 1
if PER_EXT_CONT_CONTACT_TYPE[i] = 'S' and ISNULL(l_DOD_char) <> 'Y' then
l_sp_count = l_sp_count + 1
if ( PER_EXT_CONT_CONTACT_TYPE[i] = 'C' and MONTHS_BETWEEN( l_lf_evt_ocrd_dt,l_per_dob) < 312 and ISNULL(l_DOD_char) <> 'Y')
then
l_eec_count = l_eec_count + 1
if (PER_EXT_CONT_CONTACT_TYPE[i] = 'R' and MONTHS_BETWEEN( l_lf_evt_ocrd_dt,l_per_dob) < 312 and ISNULL(l_DOD_char) <> 'Y')
then
l_dpc_count = l_dpc_count + 1
i = i+1
)
)
l_log_data = ess_log_write('l_sp_count '||to_char(l_sp_count))
l_log_data = ess_log_write('l_dpc_count '||to_char(l_dpc_count))
l_log_data = ess_log_write('l_eec_count '||to_char(l_eec_count))
l_log_data = ess_log_write('l_dp_count '||to_char(l_dp_count))
/* Get Previous Enrollment */
CHANGE_CONTEXTS(EFFECTIVE_DATE = add_days(l_cvg_strt_dt, -1))
(
l_enrolled_1 = ben_fn_get_char_value('BEN_PRTT_ENRT_RSLT', 'ENROLLED', l_prev_plan_1)
l_enrolled_2 = ben_fn_get_char_value('BEN_PRTT_ENRT_RSLT', 'ENROLLED', l_prev_plan_2)
IF l_enrolled_1='Y'
then
(
l_prev_plan_name='Vision Base Plan'
)
ELSE IF l_enrolled_2='Y'
then
(
l_prev_plan_name='Vision Premium Plan'
)
ELSE
(
l_prev_plan_name='Waived Vision Plan'
)
l_prev_emp = ben_fn_get_char_value('BEN_PRTT_ENRT_RSLT', 'ENROLLED', l_prev_plan_name, 'Employee')
l_prev_emp_s = ben_fn_get_char_value('BEN_PRTT_ENRT_RSLT', 'ENROLLED', l_prev_plan_name, 'Employee + Spouse')
l_prev_emp_c = ben_fn_get_char_value('BEN_PRTT_ENRT_RSLT', 'ENROLLED', l_prev_plan_name, 'Employee + Child(ren)')
l_prev_emp_fam = ben_fn_get_char_value('BEN_PRTT_ENRT_RSLT', 'ENROLLED', l_prev_plan_name, 'Employee + Family')
)
IF l_pln_name=l_prev_plan_name and l_prev_plan_name='Waived Vision Plan'
then
(
AUTO_DFLT_VAL = 'Y'
CARRY_FORWARD_ELIG_DPNT = 'CFWP'
l_log_data = ess_log_write('1 Defaulting into Employee')
return AUTO_DFLT_VAL, CARRY_FORWARD_ELIG_DPNT
)
ELSE IF l_pln_name=l_prev_plan_name and l_prev_plan_name<>'Waived Vision Plan'
then
(
/*Employee*/
IF l_prev_emp = 'Y' and l_opt_name = 'Employee' then
(
AUTO_DFLT_VAL = 'Y'
CARRY_FORWARD_ELIG_DPNT = 'CFWP'
l_log_data = ess_log_write('1 Defaulting into Employee')
return AUTO_DFLT_VAL, CARRY_FORWARD_ELIG_DPNT
)
/*Employee Plus Spouse*/
ELSE IF l_prev_emp_s = 'Y' and l_sp_count >= 1 and l_opt_name = 'Employee + Spouse' then
(
AUTO_DFLT_VAL = 'Y'
CARRY_FORWARD_ELIG_DPNT = 'CFWP'
l_log_data = ess_log_write('2 Defaulting into Employee + Spouse')
return AUTO_DFLT_VAL, CARRY_FORWARD_ELIG_DPNT
)
ELSE IF l_prev_emp_s = 'Y' and l_sp_count = 0 and l_opt_name = 'Employee' then
(
AUTO_DFLT_VAL = 'Y'
CARRY_FORWARD_ELIG_DPNT = 'CFWP'
l_log_data = ess_log_write('2 Defaulting into Employee Only')
return AUTO_DFLT_VAL, CARRY_FORWARD_ELIG_DPNT
)
/*Employee Plus Children*/
ELSE IF l_prev_emp_c = 'Y' and l_eec_count >= 1 and l_opt_name = 'Employee + Child(ren)' then
(
AUTO_DFLT_VAL = 'Y'
CARRY_FORWARD_ELIG_DPNT = 'CFWP'
l_log_data = ess_log_write('5 Defaulting into Employee + Child(ren)')
return AUTO_DFLT_VAL, CARRY_FORWARD_ELIG_DPNT
)
ELSE IF l_prev_emp_c = 'Y' and l_eec_count = 0 and l_opt_name = 'Employee' then
(
AUTO_DFLT_VAL = 'Y'
CARRY_FORWARD_ELIG_DPNT = 'CFWP'
l_log_data = ess_log_write('6 Defaulting into Employee Only')
return AUTO_DFLT_VAL, CARRY_FORWARD_ELIG_DPNT
)
/*Employee PLus Family*/
else if l_prev_emp_fam = 'Y' and l_sp_count >= 1 and l_eec_count >= 1 and l_opt_name = 'Employee + Family' then
(
AUTO_DFLT_VAL = 'Y'
PREV_PRTT_ENRT_RSLT_ID = ben_fn_get_char_value('BEN_PRTT_ENRT_RSLT','PRTT_ENRT_RSLT_ID','Metlife Dental', 'Employee + Family with Spouse')
CARRY_FORWARD_ELIG_DPNT = 'CFWP'
l_log_data = ess_log_write('10 Defaulting into Employee + Family')
return AUTO_DFLT_VAL, CARRY_FORWARD_ELIG_DPNT,PREV_PRTT_ENRT_RSLT_ID
)
ELSE IF l_prev_emp_fam = 'Y' and l_sp_count >= 1 and l_eec_count = 0 and l_opt_name = 'Employee + Spouse' then
(
AUTO_DFLT_VAL = 'Y'
CARRY_FORWARD_ELIG_DPNT = 'CFWP'
l_log_data = ess_log_write('11 Defaulting into Employee + Spouse')
return AUTO_DFLT_VAL, CARRY_FORWARD_ELIG_DPNT
)
ELSE IF l_prev_emp_fam = 'Y' and l_sp_count = 0 and l_eec_count >= 1 and l_dpc_count = 0 and l_opt_name = 'Employee + Child(ren)' then
(
AUTO_DFLT_VAL = 'Y'
CARRY_FORWARD_ELIG_DPNT = 'CFWP'
l_log_data = ess_log_write('12 Defaulting into Employee + Child(ren)')
return AUTO_DFLT_VAL, CARRY_FORWARD_ELIG_DPNT
)
ELSE if l_prev_emp_fam = 'Y' and l_sp_count = 0 and l_eec_count = 0 and l_opt_name = 'Employee' then
(
AUTO_DFLT_VAL = 'Y'
CARRY_FORWARD_ELIG_DPNT = 'CFWP'
l_log_data = ess_log_write('13 Defaulting into Employee Only')
return AUTO_DFLT_VAL, CARRY_FORWARD_ELIG_DPNT
)
)
ELSE
(
return AUTO_DFLT_VAL, CARRY_FORWARD_ELIG_DPNT
)