Wednesday, March 11, 2009

Oracle Advanced Benefit (OAB) Queries

I will try to give the basic queries without joining with plans or options or programs. So that everyone can understand the basic underlying conditions. Later on you can add all plan and program joins to add to the reports.

1. Enrollment Results


SELECT *
FROM ben_prtt_enrt_rslt_f pen
WHERE business_group_id = p_business_group_id
AND p_effective_date BETWEEN pen.enrt_cvg_strt_dt AND pen.enrt_cvg_thru_dt
AND pen.enrt_cvg_thru_dt <= pen.effective_end_date
AND pen.prtt_enrt_rslt_stat_cd IS NULL
AND pen.sspndd_flag = 'N'
AND pen.person_id = p_person_id


Same query will give you coverage amount stored as bnft_amt in the table.

2. Enrollment Rates
For each enrollment you can have different rates. Rates are store in table ben_prtt_rt_val
you can use the following query for rates

SELECT *
FROM ben_prtt_rt_val
WHERE prtt_enrt_rslt_id = p_prtt_enrt_rslt_id;


But here main things to take care is rt_strt_dt and rt_end_dt. rt_strt_dt will always be less than equal to rt_end_date for a recurring rate but rt_strt_dt and rt_end_dt are equal when rt is non-recurring.

3. Eligibility Results
These results are store for each life event in person record. Also in this table you will find if a particular enrollments is set for default or auto enrollment with dflt_flag and auto_enrt_flag.

SELECT epe.*
FROM ben_elig_per_elctbl_chc epe,
ben_per_in_ler pil
WHERE pil.person_id = p_person_id
AND epe.per_in_ler_id = pil.per_in_ler_id;


4. Enrolled Dependents

SELECT *
FROM ben_elig_cvrd_dpnt_f dpnt,
ben_prtt_enrt_rslt_f pen
WHERE dpnt.prtt_enrt_rslt_id = pen.prtt_enrt_rslt_id
AND EXISTS (SELECT pil.per_in_ler_id
FROM ben_per_in_ler pil
WHERE pil.per_in_ler_id = pen.per_in_ler_id
AND pil.business_group_id = p_business_group_id
AND pil.per_in_ler_stat_cd NOT IN ('VOIDD','BCKDT'))
AND p_effective_date BETWEEN dpnt.cvg_strt_dt AND Nvl(dpnt.cvg_thru_dt,p_effective_date)
AND (Nvl(dpnt.cvg_thru_dt,p_effective_date) <= dpnt.effective_end_date
OR p_effective_date BETWEEN dpnt.effective_start_date AND Nvl(dpnt.effective_end_date,p_effective_date))
AND dpnt.dpnt_person_id = p_person_id



In above query you can dpnt_person_id is the dependent. You can see the enrolled person in ben_prtt_enrt_rslt_f table.

5. Pending Action Items
SELECT *
FROM ben_prtt_enrt_rslt_f pen,
ben_prtt_enrt_actn_f pea,
ben_per_in_ler pil
WHERE pen.prtt_enrt_rslt_id = pea.prtt_enrt_rslt_id
AND pil.per_in_ler_id (+) = pea.per_in_ler_id
AND (pil.per_in_ler_stat_cd NOT IN ('VOIDD','BCKDT')
OR pil.per_in_ler_stat_cd IS NULL)
AND pen.sspndd_flag = 'Y'
AND p_effective_date BETWEEN pen.enrt_cvg_strt_dt AND pen.enrt_cvg_thru_dt
AND pen.enrt_cvg_thru_dt <= pen.effective_end_date
AND pen.prtt_enrt_rslt_stat_cd IS NULL



I will come up with some queries. Please let me know what kind of queries I can add here.

34 comments:

mahi said...

Gaurav

it was very useful queries ti understand the basic concepts...Good work go head

Unknown said...

Thanks and very helpful. Could you tell me what p_effective_date represents? System Date? Sorry if I am demonstrating my ignorance

Gaurav Sehgal said...

Hi Thomas
p_effective_date is basically the date on which you want to see the coverage details or all the enrollments i.e. it will tell you what all benefits person is enrolled into on p_effective_date

Sam33k said...

why I am not getting unprocess life events in ben_per_in_ler ?

how this flow works? please explain.

Thanks,

Gaurav Sehgal said...

Hi Sam
Unprocessed life events are in ben_ptnl_ler_for_per. All unprocessed, detected, manual status life events will be in this table. Once the life event is processed this record changed to processed and according to processing record in ben_per_in_ler is inserted in "Started" or "Processed" status.

vanitha said...

Hi Gaurav,
I haev this issue where an error pops up saying Overlapping dates when I change the rate amount fro a plan fro a particular program.
-Non Flex program Screen

The query below returns a row as such throwing that error.
Plz tell me as to I can interpret it functionally

select rt_strt_dt,
rt_end_dt
from ben_prtt_rt_val
where prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
and acty_base_rt_id = p_acty_base_rt_id
and prtt_rt_val_id <> nvl(p_prtt_rt_val_id,-1)
and prtt_rt_val_stat_cd is null
and ((p_new_rt_strt_dt between rt_strt_dt and rt_end_dt) or
(rt_strt_dt between p_new_rt_strt_dt and p_new_rt_end_dt));

Taken from Std API ben_prtt_rt_val_api

Please help at the earliest

Gaurav Sehgal said...

Vanitha
This error generally comes when you update an enrollment and coverage or rate dates overlap.

When we update the enrollment, old enrollment rate and converage ends and new rate and coverage starts. When the rate or coverage dates overlap between new and old records this error comes.

You have to check your plan/ program enrollment rules applicable to that enrollment. Check Coverage and Rate Start and End Date codes and make sure they are set properly

Deeps said...

Gaurav,

During Open Enrollment, there was some error in our set ups for Short Term Disability plan and the employee has incorrect coverage start dates for the plan. Can we set up a life event to correct the coverage start date?

Please advice.

Thank you

Gaurav Sehgal said...

If you are getting this error that means your plan setup is not correct. Check plan or program enrollment requirements.

Deeps said...

yes will do that for fixing the coverage start date going forward. I was trying to figure out a way to fix the employees who already have an incorrect coverage start date. I havs about 1000 of them, so override will not be a good option.

Deepthi Dasari said...

Hi Gaurav,

If Husband and wife work in the same company. The Kids and wife come under the Husband Benefits.

WIfe has her own Life Insurence.
Can you give me a query where i give the Husband (or) Wife Person_id and it would return the list of dependants and their Benefits?

The Issue i have is if i give the Person_id of the wife the children are coming under her which is wronfg; they are only under her husband.

Any Help will be really appreciated.

Thanks,
Deepthi

Nimisha said...
This comment has been removed by the author.
Nimisha said...

Hi Gaurav,

Please comment on the issue I am having.

I was looking at the Plan set up for the Life Insurance in in PROD and I clicked on one of the chkbox by mistake and I removed it. And instead of ‘Find’, I clicked on ‘Save’ and it updated the effective date as of 06-JUN-2011.

What should I should I do to make effective from 01-Jan-2001(what it previously was)and remove the effective end date of 05-Jun-2011.

Please respond asap.

Thanks

Gaurav Sehgal said...

Nimisha
What system did is that it datetracked the information. You can go to 5th June, Press Delete. System will give you option and then you can choose delete next change or delete all future changes in this case.

Nimisha said...

Thanks for the quick turn around.
IS there anyways I can share an attachment to show you what exact date/screen I am referring to.

Gaurav Sehgal said...

share a link through flicker or picasa

Nimisha said...

See the screenshot below -
http://www.flickr.com/photos/63311474@N08/5806815184/in/photostream/

The Effective Dates - 06-JUN-2011.

Is it like, as soon as hit 'save' it created another record for the same plan? if so, would it affect process/program using this date element? Its in PROD and so I am little cautious making any changes further.

If I datetrack to 01-Jan-2001 and save it would it leave effective end date as 05-JUN-2011?

Nimisha said...

I got it fixed with the solution you suggested.

Thanks a lot Gaurav.

Aslam said...

Hi Gaurav

I've trying to make a query to get staff's benefit selection and their rate. However my query returning duplicate lines. Can you help to see which filter or join am I missing? Below is my sql statement.

select pen.person_id, plt.name benefit, plf.name plan, opt.name Option_Name,
pen.effective_start_date, pen.effective_end_date, pen.bnft_amt,
prt.rt_val
from ben_prtt_enrt_rslt_v pen,
ben_pl_typ_f plt,
ben_oipl_f oipl,
ben_opt_f opt,
ben_pl_f plf,
ben_prtt_rt_val prt
where pen.pl_typ_id = plt.pl_typ_id
and pen.oipl_id = oipl.oipl_id(+)
and oipl.opt_id = opt.opt_id(+)
and pen.pl_id = plf.pl_id(+)
and pen.prtt_enrt_rslt_id = prt.prtt_enrt_rslt_id
and pen.per_in_ler_id = prt.per_in_ler_id
and pen.prtt_enrt_rslt_stat_cd is null
and prt.prtt_rt_val_stat_cd is null
and sysdate between pen.enrt_cvg_strt_dt and pen.enrt_cvg_thru_dt
and pen.person_id = 300430
order by plt.name


Thanks

Gaurav Sehgal said...

Sorry for the late reply Aslam. You might already have figured out the solution, but still adding my 2 cents..


First looks says that you have a lot of "_F" tables i.e. date track tables so write the "sysdate between plt.effective_start_date and plt.effective_End_Date" for all "_F" tables.

Also you can add the following condition

AND pen.enrt_cvg_thru_dt <= pen.effective_end_date

This makes sure you get only valid enrollments.

See if this helps

Vittal said...

How do we find out Employee rates and employer rates for a plan?

Abhishek said...

Hi Gaurav,

I tried to query this view in Oracle OAB 'BEN_CVRD_DPNT_CTFN_PRVDD_V' but it does not have any data, I need to run a report which includes only the dependents with covered flag checked on designate dependent tabe on OAB screen.



select distinct

TO_CHAR(sysdate, 'MM/DD/YYYY') RUN_DATE
,TO_CHAR(sysdate + 31, 'MM/DD/YYYY') AS_OF_DATE
,per2.employee_number employee_number
,per2.national_identifier EE_SSN
,per2.person_id person_id
, per2.full_name EE_name
, substr(plan.name,1,30) plan_name
, substr(opt.name, 1,30) option_name
, to_char(prtt.enrt_cvg_strt_dt,'MM/DD/YYYY') emp_enrt_dt
, per.national_identifier dpnt_SSN
, per.employee_number dpnt_employee_number
, per.full_name dpnt_name
, to_char(dpnt.cvg_strt_dt,'MM/DD/YYYY') dpnt_enrt_dt
,per.person_id dpnt_person_id
FROM ben.BEN_PRTT_ENRT_RSLT_F prtt
, ben.ben_elig_cvrd_dpnt_f dpnt
, apps.per_all_people_f per
, apps.per_all_people_f per2
, ben.ben_pl_f plan
, ben.ben_oipl_f oipl
, ben.ben_opt_f opt
where prtt.person_id = per2.person_id
and prtt.pl_id = plan.pl_id
and NVL(prtt.oipl_id,-99) = oipl.oipl_id (+)
and prtt.prtt_enrt_rslt_id = dpnt.prtt_enrt_rslt_id
--- and prtt.per_in_ler_id = dpnt.per_in_ler_id
and dpnt.dpnt_person_id = per.person_id
and oipl.opt_id = opt.opt_id (+)
and to_date(sysdate + 31) between prtt.effective_start_date and prtt.effective_end_date
AND to_date(sysdate + 31) between prtt.enrt_cvg_strt_dt and prtt.enrt_cvg_thru_dt
and to_date(sysdate + 31) between dpnt.effective_start_date(+) and dpnt.effective_end_date(+)
and to_date(sysdate + 31) between dpnt.cvg_strt_dt(+) and dpnt.cvg_thru_dt(+)
and to_date(sysdate + 31) between per.effective_start_date(+) and per.effective_end_date(+)
and to_date(sysdate + 31) between per2.effective_start_date(+) and per2.effective_end_date(+)
and to_date(sysdate + 31) between plan.effective_start_date(+) and plan.effective_end_date(+)
and to_date(sysdate + 31) between oipl.effective_start_date(+) and oipl.effective_end_date(+)
and prtt.prtt_enrt_rslt_stat_cd is null

ORDER BY per2.national_identifier, substr(plan.name,1,30)


Please advice.

Regards,
AJ

Gaurav Sehgal said...

@Vittal:

For Employee and Employer Rates you have to define two Standard Rates for the Plan (or Option in Plan or which ever enrollable object). After defining and enrolling employees to the benefit, final rates are created in BEN_PRTT_RT_VAL table.

Gaurav Sehgal said...

@Abhishek

Covered Dependents are stored in ben_elig_cvrd_dpnt_f and not in this BEN_CVRD_DPNT_CTFN_PRVDD_V.

Your SQL seems correct, what problem you are facing in the SQL. Also whenever you are creating reports using Oracle View, check the definition of the view. Sometimes view definition refers the date by FND_SESSIONS table. if you dont insert the date in SQL session manually you will not get any results.

Gaurav Sehgal said...

@Abhishek
Also add the condition per_in_ler_stat_cd NOT IN ( 'VOIDD', 'BCKDT' )in the SQL

Jason said...

Hi Gaurav,
I am trying to set up supplemental life insurance plans for employee, spouse and dependent coverage. The after tax rate is based on age and coverage amount. For example, the monthly rate for a 32 years old employee with $70k coverage = 0.14x(70000/1000)=9.8 I have setup age factors. Can you let me know how to set up variable rate profile, standard rate and coverage calculation? I don't if coverage amount $70k should be entered at enrollment or build in as an option. Thanks for your help.

Gaurav Sehgal said...

@Jason
Sorry for the late reply, but here are my two pennies -
Looks like your driving amount in the calculation is Coverage so you will have to create coverage and and specify it as flat amount, enter value at enrollment. Once you define the coverage, go to standard rate and choose the calculation method as multiple of coverage and specify "Calculate for Enrollment". If you want to specify the variable rate profiles, then specify the variable rate profiles with calculation method as multiple of coverage and specify appropriate multiplier (0.14 in the example you gave). When you specify multiple of coverage system will ask to enter Coverage as well. Specify the coverage you created earlier (flat amount, enter value at enrollment, in the the first line of my answer).

Unknown said...

Hi Gaurav,
Your queries are very helpful.. I am trying to extract data for specific life events (i.e. termination, aged out, retirement, etcs) what is the and linking these to dependents .. can you show mean how i can do this?
thanks,

Anonymous said...

Hi Gaurave

I am trying to work on Advaced benefis for the first time now - and have got a requirement which is little difficult for me to work on. Your views and suggestion will help me.

Requirement below -

For the Employees joining the benefit plan between 01 until 15 of any month should have the Rate Start Date from the 1st of the current month.
While Employees joining or electing the benefit plan between 16 until 31 of any month should have the Rate Start Date as from the 1st of the next month.

Similarly, the Employees who make the request to leave the benefit plan between 01 until 15 of any month should have the Rate End Date from the 1st of the current month.
While Employees making the request to leave the benefit plan between 16 until 31 of any month should have the Rate Start Date as from the 1st of the next month.

The requirement is similar for the Coverage Start Date and Coverage End Dates.

Thanks
Mono

LK said...

Good one

Unknown said...
This comment has been removed by the author.
Unknown said...

Hi need query regarding process enrollment requiment with schedule start and end date..please help me in this

Unknown said...

Hi guarav, this is really helpful but could u pls explain about how to fetch details of employee enrolled in current plan i.e recent plan

Unknown said...

Hi guarav, this is really helpful but could u pls explain about how to fetch details of employee dependants who are enrolled in current plan i.e recent plan and also the latest previous plan