[Home] [Help]
PACKAGE BODY: APPS.BEN_PRTT_ENRT_RESULT_API
Source
1 Package Body ben_PRTT_ENRT_RESULT_api as
2 /* $Header: bepenapi.pkb 120.65.12010000.10 2008/11/07 10:46:26 sallumwa ship $ */
3 --
4 /* ============================================================================
5 File Information
6 ================
7 This file was originally copied from the bpapiskl.pkb file.
8 Skeleton Version: 40.3
9 --------------------------------------------------------------------------
10 Change List
11 ===========
12 Version Date Author Comment
13 -------+-----------+--------------+---------------------------------------
14 110.0 May 27 98 Hugh Dang initial created
15 110.1 Jun 04 98 Hugh Dang add columns
16 110.6 Jun 16 98 Hugh Dang Add Messages call and fixed cvg end dt.
17 110.7 Jun 17 98 Hugh Dang Un-comment Element Entry procedure call.
18 110.7 Jun 17 98 Hugh Dang comment Element Entry procedure call.
19 and change rate end date to end of time.
20 110.8 Jun 17 98 Hugh Dang Add Create_credit_ledger_entry.
21 110.9 Jun 23 98 Hugh Dang Remove Dpnt coverage end date check.
22 110.11 Jun 26 98 jcarpent Replaced create_credit_ledger_entry with
23 accumulate_pools
24 110.12 Jul 22 98 Hugh Dang Add prtt_resulst OVN in/out parmater to
25 determine action item call.
26 110.13 Jul 22 98 Hugh dang Add p_multi_row_actn in ben_elig_cvrd_
27 dpnt_api.update_elig_cvrd_dpnt and
28 ben_plan_beneficiary_api.delete_plan_
29 beneficiary
30 110.14 Sep 25 98 bbulusu Added out nocopy parameters (warnings) to create
31 _enrollment and in the call to determine_
32 action_items.
33 115.11 Oct-02-98 Hugh Dang Remove Rt_strt_dt, Rt_end_dt,
34 enrld_cvrd_flag and Change BNFT_UOM
35 to UOM.
36 * Change Create/Delete enrollment logic.
37 115.11 Oct-13-98 Hugh Dang Make Enrt_bnft_id as default parameters.
38 115.12 Oct 13 1998 Hugh Dang Make enrt_cvg_thru_dt default to eot
39 instead of NULL
40 115.14 Oct 19 98 bbulusu added p_new_enrt_rslt_ovn in the call to
41 ben_mng_dpnt_bnf.recycle_dpnt_bnf
42 115.15 Oct 21 98 Hugh Dang Add business_group_id for all dpnt api.
43 115.16 Oct 21 98 Siok Tee Call Manage Primary care provider if plan
44 has not changed but oipl changes.
45 115.17 Oct 25 98 Jon Carpenter Added call to rate_and_coverage_dates
46 Removed get_rate_and_cvg_start_end_date
47 115.18 Oct 26 98 Hugh Dang Add p_per_in_ler_id, p_enrt_perd_id,
48 p_lee_rsn_id in delete enrollment and
49 make sure if electable choice is not passed
50 then above infor. need to passed.
51 115.19 Oct 29 98 Graham Perry Added in datetrack check for update_
52 enrollment, switches mode to correction
53 if needed.
54 115.20 Oct 29 98 lmcdonal Added new parms to call to delete prtt rt
55 val.
56 115.21 Oct 30 98 Hugh Dang Added new parms to call to update prtt
57 rt val.set post_rslt_flag to multi_row_
58 edit flag.
59 115.22 Oct 31 98 bbulusu Modified unhook_bnf procedure to zap all
60 bnf's when zapping enrt rslt. Siok fixed
61 the c_pen cursor in delete_enrollment.
62 115.23 Nov 01 98 Hdang Change logic on per_in_ler_id on delete
63 enrollment and Change C_pen cursor to
64 eliminate duplicate Electable choice.
65 115.24 Nov 02 98 Hdang Add business group id parms for update_prtt
66 rt_val.
67 115.26 Nov 04 98 Hdang add l_elig_per_elctbl_chc_id to make the
68 the per_in_ler for cursor is current.
69 115.27 Nov 04 98 Hdang Change C_prv cursor to eliminate others
70 outer join.
71 115.28 Nov 05 98 Hdang Change update enrollment's compare oipl
72 from equal to not equal
73 115.29 Nov 10 98 Hdang - Add call to delete ben_pl_bnf_ctfn api
74 to remove children before call prtt_actn
75 items.
76 - Add logic to handle Saving plan.
77 Zap enrollments elected today and delete
78 same day.
79 115.30 Dec 07 1998 Hdang Add parameter into multi-row edit to
80 handle last year enrollment but not
81 default current year.
82 115.31 Dec 10 1998 Hdang modify the c_prv to eliminate duplicate
83 row cause by multi-row ben_enrt_rt.
84 115.32 Dec 11 1998 lmcdonal When deleting rows in multi-row, join to
85 choice table.
86 115.33 Dec 15 1998 pxdas Added Code for logging change event
87 115.34 Dec 16 1998 pxdas Modified Change_exists_in_db procedure
88 115.35 Dec 16 1998 Hdang Add person_id and pgm_id to limit the fetch
89 and fix the c_prv cursor.
90 115.36 Dec 28 1998 Stee Fix cursor to zap beneficiaries in delete
91 enrollment.
92 115.37 Dec 28 1998 Hdang Remove per_in_ler check and pass per_in_ler
93 for all dependent procedure.
94 115.38 Dec 28 1998 Hdang Remove per_in_ler_id from update_prtt_rt_val.
95 115.39 Dec 29 1998 pxdas Modified Create_Change_Log procedure
96 115.40 Dec 29 1998 lmcdonal Because p_suspend_flag is an out, not an
97 in/out we have to always set it. It is
98 usually set when calling the action_item
99 proc, but when that proc is not called, we
100 must set the flag.
101 115.41 Jan 01 1999 pxdas Modified effective date when calling
102 Create_Change_Log procedure
103 115.42 Jan 04 1999 Hdang C_pil%notfound check.
104 115.43 Jan 12 1999 maagrawa p_acty_base_rt_id removed from call to
105 delete_prtt_rt_val.
106 115.44 Jan 21 1999 Hdang Avoid de-enrolled any enrollmente which has
107 the earliest de-enrollment date has not been
108 reached.
109 115.45 Jan 26 1999 Hdang * Remove mandatory check in delete enrollment.
110 * Change SVG_PL_FLAG to ENRT_PL_OPT_FLAG for
111 Create_enrollment to determine if
112 "Determine action item" need to be called.
113 115.46 Jan 30 1999 Yrathman Add no_lngr_elig_flag column
114 Modify delete_enrollment to assign cvg end date
115 1 day prior to new cvg start date, if found.
116 Modify multi_rows_edit to delete enrollments
117 no longer eligible for if elections were made
118 for program or plan type.
119 115.47 Feb 04 1999 jcarpent Added ended_per_in_ler_id to update_prv.
120 115.48 Feb 18 1999 Hdang Fixed cursor for remove old enrollments
121 which pick up all plan not in program.
122 115.49 Feb 24 1999 Yrathman Added bnft_ordr_num, prtt_enrt_rslt_stat_cd column
123 115.50 Mar 03 1999 jcarpent Removed dbms_output.put_lines
124 115.51 Mar 04 1999 jcarpent Populate p_prtt_enrt_interim_id out nocopy parm
125 115.52 Mar 10 1999 T Mathers
126 115.53 Mar 29 1999 T Hayden Added calls to ben_ext_chlg,
127 Added parameter p_source,
128 Removed old way of writing to chg log.
129 115.54 Apr 15 1999 mhoyes Un datetracked per in ler
130 115.55 Apr 16 1999 jcarpent Removed update to choice of crntly_enrd.
131 115.56 Apr 24 1999 lmcdonal prtt-rt-val has a status code now. Added
132 override condition to multi row c1 cursors.
133 prtt_enrt_rslt also has status code.
134 115.57 May 02 1999 maagrawa Added condition in multi row c1 cursors,
135 to exclude flex and imputed income plans.
136 115.58 May 03 1999 TGUY Added condition in multi to check for overall
137 min/max cvg across ptip.
138 115.59 May 10, 1999 lmcdonal Add void_enrollment procedure.
139 Changes to delete_enrollment:
140 1.Modify c_prv cursor so that it gets
141 rates even if tied to a bnft, not a chc.
142 2.Remove c_rt cursor and it's use.
143 3.Case 1 no longer zaps rows but instead
144 marks the rows as voided.
145 4.Since only case 3 and 4 delete, removed
146 the use of the delete_flag.
147 5.on insert, do not load choice fk to rslt
148 if rslt is void or backed out.
149 115.60 May 13, 1999 jcarpent Check ('VOIDD', 'BCKDT') for pil stat cd
150 115.61 May 19, 1999 lmcdonal Added parm to create_enrollment to trigger
151 which save point to set and rollback.
152 Also changed c_interim_enrt per Jon.
153 115.62 May 20, 1999 jcarpent Changed c_interim_enrt p_pen_id=>l_pen_id
154 115.63 May 25, 1999 maagrawa Fixed c_prv cursor to fetch enrt_rt
155 records for the current choice, if
156 it exists.
157 115.64 Jun 03, 1999 tmathers Leapfrog of 115.60 incorporating cursor
158 change from 115.63
159 115.65 Jun 03, 1999 tmathers Leapfrog of 115.63
160 115.66 Jun 04 1999 lmcdonal added comp_lvl_cd.
161 115.67 Jun 14 1999 tguy fixed cursor c_prtt_total_bnft_amt.
162 115.68 Jun 14 1999 tguy fixed cursor c_prtt_total_bnft_amt to
163 look at table and not a view.
164 115.69 Jul 1 1999 tguy added prtt_prem_f creating, update and
165 deleting. Also deals with deleting child
166 records.
167 115.70 Jul 2 1999 stee Add an edit for COBRA to not allow a
168 person to be covered in the same
169 plan as a dependent.
170 115.71 Jul 7 1999 jcarpent Add pil_id to most ben_prtt_prem_api calls
171 115.72 Jul 9 1999 jcarpent Added checks for backed out nocopy pil
172 115.73 Jul 14 1999 jcarpent close c_check_cvrd_in_plan moved to fix
173 invalid cursor error.
174 115.74 Jul 14 1999 stee Fix delete_enrollment to check for a
175 correctly check for a null per_in_ler id.
176 bug #1885.
177 115.75 Jul 23 1999 tguy fixed creating/update/delete prtt_prem_f
178 issues.
179 115.76 Jul 28 1999 jcarpent Commented out nocopy code in create_enrollment
180 which checked for update condition, will
181 no longer do an update, always a create.
182 115.77 Aug 06 1999 isen Added new and old values for extract change log
183 115.78 Aug 10, 1999 lmcdonal Leapfrog version 75 with fix listed in 79.
184 115.79 Aug 10, 1999 lmcdonal Modify delete_enrollment, case 2. It was trying
185 to call update_prtt_prem/by_mo in delete mode.
186 Since rslt is being updated for case2, the
187 prem process will pick up the change, no need to
188 do anything here. Bug 3061.
189 115.80 Aug 10, 1999 lmcdonal uncomment exit, remove ctrl-M's.
190 115.81 Aug 23, 1999 maagrawa add premium_warning(lmcdonal)
191 In Delete-result, remove call to delete
192 prtt-ctfns because they are deleted as part
193 of call to delete-prtt-actions.(lmcdonal)
194 Made Changes related to breaking of
195 dependents table. (maagrawa)
196 115.82 Aug 23, 1999 shdas added pl_ordr_num,plip_ordr_num,
197 ptip_ordr_num, oipl_ordr_num.
198 115.83 Sep 02, 1999 maagrawa Added HIPAA communications.
199 115.84 Sep 29, 1999 isen Modified calls to log_benefit_chg
200 115.85 Oct 02 ,1999 stee Change COBRA program type selection
201 to use 'COBRA%'instead of 'COBRA'
202 115.86 Oct 13 ,1999 lmcdonal Attempt to copy dpnts more freely - not
203 just if new rslt is written over old result.
204 Call recycle_dpnts in multi-row when non-
205 elected results are about to be deleted.
206 115.87 Oct 20, 1999 lmcdonal If the result being created is the
207 dummy flex or imputed income plan, do not
208 create ledgers (don't call accumulate pools).
209 115.88 Oct 29, 1999 lmcdonal Edit check the datetrack mode before updating
210 premiums in step 72.
211 115.89 Oct 29, 1999 maagrawa By-pass the erlst_deenrt_dt check in delete
212 enrollment, when calling from beninelg.
213 115.90 12-Nov-99 lmcdonal Better debugging messages.
214 115.91 30-Nov-99 jcarpent - replace datetrack strings with globals
215 update_override was spelled with 1 r. b3846
216 - Pass enrt_bnft_id to void enrollment.
217 115.92 01-Dec-99 lmcdonal When automatically de-enrolling prtt from
218 results that are choices but the prtt did
219 not choose them, only deenroll from choices
220 with elctbl_flag = 'Y'.
221 115.93 03-Dec-99 jcarpent - Changed c_prv cursors to eliminate dups
222 115.94 16-Dec-99 jcarpent - Create enrt - call action items more often
223 - Fix acrs_ptip to actually check ptip enrts
224 115.95 20-Dec-99 maagrawa Do not call manage_enrt_bnft when called
225 from election_information (benelinf).
226 115.96 30-Dec-99 jcarpent - Changed strtd to not in voidd bckdt n c_epe
227 Fixed 91902 message name so error shows.
228 115.97 11-Jan-00 jcarpent - Changed how erlst_deenrt_dt is checked.
229 115.98 13-Jan-00 maagrawa - Removed HIPAA Communications. Now called
230 from close enrollment.
231 115.99 18-Jan-00 shdas Added calls to remove_bnft_prvdd_ldgr in
232 first case of delete enrollment.
233 115.100 19-Jan-00 lmcdonal Bug 1132739. Cases where a date-track delete
234 was being done on a row where the eed of the
235 row = the eff dt of the dt-delete.
236 115.101 25-Jan-00 thayden - Changed existing calls to Change event log,
237 and added new calls to it, mostly in the
238 delete and void enrollment areas.
239 115.102 27-Jan-00 thayden - Pass end cvg thru date when creating chg log.
240 115.103 08-Feb-00 lmcdonal Bug 1166174. We need to re-calc certain
241 premiums after save of enrollment.
242 115.104 08-Feb-00 lmcdonal Bug 1169607 - chg to delete-enrollment
243 so that rows will be end-dated.
244 115.105 08-Feb-00 maagrawa Delete the interim coverage when the
245 suspended result is deleted.(1173011)
246 115.106 11-Feb-00 maagrawa Do not issue the savepoint delete_enrollment
247 in procedure delete_enrollment when calling
248 itself to delete interim coverage.
249 115.107 17-Feb-00 jcarpent - Fixed unhook dpnt bug 4715
250 - Fix result not found error in recalc_prem
251 115.108 17-Feb-00 thayden - Fix date passed into log_benefit_chg.
252 115.109 25-Feb-00 jcarpent - If delete_enrollment called from benuneai
253 don't delete interim.
254 115.110 26-Feb-00 maagrawa - Call action item routine from
255 update_enrollment. (1211553)
256 - Added parameters dpnt_actn_warning and
257 bnf_actn_warning to update_enrollment.
258 115.111 28-Feb-00 maagrawa - Delete interim enrollment only when called
259 from enrollment forms and from
260 election_information in delete_enrollment.
261 115.112 29-Feb-00 gperry Fixed caching problem when calling elig
262 dpnt api since business group id wasn't
263 being passed.
264 115.113 01-Mar-00 stee Added check for backed out nocopy result in
265 COBRA edit.
266 115.114 02-Mar-00 bbulusu Incorrect dt mode being
267 passed to update_prtt_prem
268 115.115 03-Mar-00 shdas modify determine_dpnt_cvg_dt_cd(4280)
269 115.116 04-Mar-00 pbodla - Bug 4822 :Check for min/max across ptip
270 is moved, called after delete enrollment.
271 115.117 05-Mar-00 jcarpent - Bug 4783 :changed c_prv2 cursor.
272 115.118 10-Mar-00 jcarpent - Bug 4839 :handle create of prtt_prem
273 115.119 31-Mar-00 maagrawa - Datetrack delete premium rows if they are
274 not end-dated in delete_enrollment. (4924)
275 115.120 05-Apr-00 lmcdonal Bug 1253007. Using globals for epe, pil,
276 pel, pen, enb, asg data for performance.
277 115.121 05-Apr-00 shdas Bug 4444--changed get_election_date to
278 consider per_in_ler_id while updating
279 enrollment result.
280 115.122 06-Apr-00 stee Remove per_in_ler_id from get_election_date
281 as enrollment results are voided when
282 a person is found newly ineligible.
283 115.123 07-Apr-00 lmcdonal Call to clear_pen.
284 115.124 11-Apr-00 shdas changed get_election_date to add 2 out nocopy parameters
285 to decide when to void an enrollment(4444).
286 115.125 14-Apr-00 jcarpent Refresh pen cache after action items calls
287 bug 5083
288 115.126 19-Apr-00 maagrawa Do not delete the interim coverage when it
289 is used by some other result also.(1274214)
290 115.127 24-Apr-00 gperry Fixed Internal Bug 4924.
291 115.128 25-Apr-00 maagrawa Fidelity P1(1278255): Cursor c_prv2 fixed.
292 Delete rates which are not end-dated
293 i.e. rate end date is end of time (eot).
294 115.129 26-Apr-00 jcarpent Fixed dt_mode for update of elig_cvrd_dpnt
295 in unhook_dpnts. (4938)
296 115.130 01-May-00 shdas added effective date adjustment in delete enrolment
297 when coverage has not started and source is benelinf(5129)
298 115.131 02-May-00 jcarpent Removed check for pel.elcns_made_dt or
299 pel.dflt_asnd_dt from no_lngr_elig_pnip_c.
300 From Clenr order of calls was
301 multi_rows_edit, post_results..., then
302 post enrt so dflt_asnd_dt was not yet set.
303 115.132 02-May-00 jcarpent bug # for above change is 5020.
304 115.133 12-May-00 lmcdonal Leapfrog of 128 with fix in 134 for
305 Fido P1 1299007.
306 115.134 12-May-00 lmcdonal Added actl_prem_id to c_ppe cursor.
307 115.135 13-May-00 lmcdonal Bug 1298802: re-open dpnt records for result
308 more often.
309 115.136 15-May-00 jcarpent Recycle dependents when ptip enrollment was
310 ended by benmngle. (4981/1259094)
311 115.137 14-jun-00 jcarpent p2 bug 1311768, handle 1 prior rt_end_dt.
312 based on 115.133.
313 115.138 14-jun-00 jcarpent Leapfrog: based on 115.136 with changes from 137.
314 115.139 28-jun-00 bbulusu Fixed cursor c_ptip_enrollment_info so that
315 it ignores the enrt_rslt row just created.
316 Fix for bug 4981.
317 115.140 14-jul-00 kmahendr Bug#5123 - Date Track end date of place holder plan for imputed income
318 when the prtt becomes ineligible after eligible need not be done.
319 Added one more elsif clause in delete_enrollment procedure to handle
320 this kind of situation
321 115.141 19-jul-00 gperry Fixed WWBUG 1349363.
322 Now pass in less of life event occurred
323 date-1 or effective date -1.
324 Changed remove_cert_action_items.
325 115.142 20-jul-00 kmahendr Effective date is to be passed if effective date -1 >
326 life event occurred - related to version -115.141
327 115.143 11-aug-00 gperry Fixed call to ben_determine_date.
328 Was passing cvg_end_dt_cd and
329 cvg_strt_dt_rl. Should have passed
330 cvg_end_dt_rl.
331 Fix for WWBUG 1375481.
332 115.144 06-Sep-00 jcarpent 1269016. Fixed handling of future dated
333 covered dependents when deleting an enrt.
334 115.145 14-Sep-00 jcarpent 1394044. Object version number issue.
335 also undo some of fix from prev version
336 so that don't delete rows for voided pils.
337 115.146 21-Sep-00 maagrawa 1406914. Do not decrease the effective_date
338 in remove_cert_action_items, if it is
339 less than the effective_start_date.
340 115.147 13-Oct-00 pbodla bug : 1418754 : added call to
341 chk_max_num_dpnt_for_pen after call to
342 update_elig_cvrd_dpnt.
343 115.148 25-Oct-00 bbulusu Bug fix 1471158. Don't zap elig_cvrd_dpnt
344 if cvg is already ended.
345 115.149 08-NOV-00 vputtiga Fixed bug 1485814. Added procedure
346 update_person_type_usages
347 115.150 19-nov-00 tilak mesage 91902 changed
348 pen cursor in delete enrollemt changed to get
349 plan and option name
350 ECVG_threu date is validated instead of effctived date
351 with erlst_deenrt_dt to deenroll
352 115.151 05-Jan-01 maagrawa Added parameters enrt_cvg_thru_dt and p_mode
353 to delete_enrollment to handle special
354 cases when the cvg_thru_dt is entered by
355 the user.
356 115.152 08-feb-01 tilak cursor for OPT/PTIP/PL created to validate
357 deentrolment allowed bug : 1620161
358 115.153 19-feb-01 tilak flex credit amout changes is not affecting
359 on next enrollment
360 cursor c_flex and c_bpl is creatd
361 to update the ledger
362 115.154 21-Feb-01 maagrawa In delete_enrollment, pass the coverage
363 end date to rate_and_coverage_dates
364 procedure when it is enterable by the user.
365 (1647095).
366 115.155 23-Feb-01 ikasire fix the '1 prior' date code in
367 delete_enrollment procedure by
368 adding 'WL' cases and changing the cursor
369 used for it (1633284,1558809,1584238)
370 115.156 15-Mar-01 kmahendr Bug#1684498 - added enrt_cvg_thru_dt condition
371 in the cursor c_prtt_total_bnft_amt in procedure
372 multi_rows_edit
373 115.157 23-Mar-01 maagrawa Call to ben_env_object.init added to
374 delete_enrollment.
375 115.158 26-Apr-01 maagrawa Performance changes.
376 Bypass dependent,beneficiary,flex credit,
377 premium logic based on plan design.
378 115.159 30-Apr-01 maagrawa Call ben_env_object.init to initialize
379 cache variables.
380 115.160 04-May-01 ikasire 1712890 Added the validation conditions for
381 attribute columns in UPDATE routine
382 115.161 08-May-01 jcarpent Bug 158783. Reset l_ppe.prtt_prem_id before
383 fetch since this is used instead of %found
384 115.162 17-May-01 maagrawa Changed the calls to ben_global_enrt.
385 115.164 21-May-01 kmahendr Merged version 163 and 162 as 163 was a
386 leapfrog version on 153
387 115.165 22-May-01 maagrawa Fixed bug introduced by performance changes
388 for premiums.
389 115.167 29-May-01 kmahendr Version 165 brought forward as version 166 was
390 a leapfrog version of 156 and fixes in 160
391 115.168 01-jun-01 tilak bug : 1186192 unhook_bnf is changed to end date
392 usage , unhhok_bnf is called from update
393 115.169 14-Jul-01 kmahendr Non-recurring element entries are not removed when
394 deenrolling from comp. objects - added cursor c_prv3
395 115.170 16-jul-01 kmahendr Change history for 115.169 entered
396 115.171 16-jul-01 shdas added p_enrt_cvg_end_dt to calc_dpnt_cvg_dt
397 115.172 17-Aug-01 kmahendr Bug#1939522 - for unhook_dpnt and unhook_bnf, per_in_ler
398 is passed null from delete_enrollment when delete_enro
399 is called from ben_newly_ineligible in selection mode
400 115.173 28-Aug-01 kmahendr cursor c_abr added to check non-recurring element entries
401 as unrestricted per_in_ler_id will always be same
402 115.174 17-Oct-01 kmahendr Bug#2038814 - new cursor c_prv4 added in the delete_enroll
403 ment procedure
404 115.175 02-Nov-01 kmahendr Changed paramater value from p_datetrack_mode to l_date
405 115.176 09-Nov-01 pbodla Bug 2093859 : zap the enrollment data if
406 coverage is not started yet. Case 3 and 4
407 ( Mahendran and Manish have knowledge of the issue
408 before changing please consult one )
409 115.177 12-Nov-01 kmahendr Bug-2093859 - conc_request_id in self_service is given 0
410 - benmngle mode is checked with in clause for 0, -1
411 115.178 05-dec-01 dschwart/ - WWBUG#1646442:
412 bburns - added block of variable declarations in
413 create_enrolment
414 - replaced c_ppe in create_enrolment
415 - added c_pel and processing in create_enrolment
416 - added processing to get correct date/update mode
417 115.179 31-Jan-02 kmahendr -Bug#2209048-if delete_enrollment is called from beninelg
418 delete_mode is assigned 'DELETE'.
419 115.181 01-Apr-02 shdas reopen cvrd dpnt record only if he is still eligible.
420 changed c_egd cursor in update_enrollment to add
421 filtering on dpnt_inelig_flag.
422 115.182 23-May-02 ikasire Bug 2200139 Override Enhancements there may be
423 future enrollments needs to be deleted. To handle this
424 if the pen esd is >= p eff date, then we are passing
425 esd + 1 for p eff date from multi row edit.
426 115.183 29-May-02 ikasire 1.Bug 2386000 If the delete enrollment is called from
427 benuneai, pass this to p_called_from parameter of
428 unhook_dpnt.
429 2. When elig_per_elctbl_chc_id is null, we need to pass
430 lee_rsn_id and enrt_perd_id also along with pgm,pl,oipl
431 to ben_determine_date.rate_and_coverage_dates call.
432 115.184 25-Jun-02 tjesumic bug:2479616 for the 1 prior rate end date code, the date is
433 calcualted on coverage start date, that was changed to
434 calculate on rate start date
435 115.185 05-Jul-02 ikasire bug:2479616 fixed a typo in the 1 prior rate if condition
436 115.186 29-Aug-02 ikasire Bug 2537720 fix for the effective date in suspend
437 enrollment update case.
438 115.187 10-Sep-02 kmahendr Bug#2545915 - c_prv cursor in void_enrollment modified.
439 115.188 28-Sep-02 ikasire Bug 2600087 cursor C1 is not selecting the future
440 enrollements.
441 115.189 29-Sep-02 bmanyam Bug 2597005 - Changed the dt-mode to 'correction'
442 before calling 'update_elig_cvrd_dpnt'
443 115.190 30-sep-02 kmahendr Bug#2602124 - cursor c1 modified to not to pick the ones
444 with electable choice having result ids.
445 115.191 03-Oct -02 bmanyam Bug 2597005 - Reversed the changes made in 115.189 version
446 115.192 15-oct-02 tjesumic Bug 2546259 - Delete_enrolment Delete(ZAP) the result if
447 Coverage Started in the Future Date. If the current LE is
448 backedout , deleted result is required to restore the previous
449 LE. This fix Void the enrollment result instead of deleting
450 result of the future dated coverage
451 115.193 15-Oct-02 ikasire Bug 2627078 added the cursor to update the epe with
452 the current result id when the interim records are deleted
453
454 115.194 09-Nov-02 tjesumic Bug 2546259 - Suspend_flag control removed
455 115.195 14-Nov-02 kmahendr Bug#2625060 - in delete_enrollment procedure, activity base rt id is not
456 passed when calling update_prtt_rt_val api.
457 115.196 28-Nov-02 lakrish Bug 2519378, Set tokens for error message
458 BEN_91711_ENRT_RSLT_NOT_FND
459 115.197 07-Jan-03 ikasire Bug 2739965 delete enrollment for unrestricted.
460 added p_ler_typ_cd parameter to get_ben_pen_upd_dt_mode
461 procedure
462 115.199 15-Feb-03 pbodla DEBUG : hr_utility.set_location calls wrpped
463 around if statements.
464 115.200 14-Mar-03 kmahendr Bug#2785410 - code added in void_enrollment proc.
465 115.201 14-Mar-03 ikasire Bug2847110 and 2852703 1 Prior Code fixes
466 115.202 24-Mar-03 ikasire Bug 2739965 Added a warning message while deleting the future
467 rate changes.
468 115.203 10-Apr-03 kmahendr Bug#2893826 - cursor c_prem changed to look for per_in_ler_stat
469 cd strd
470 115.204 17-Jul-03 ikasire Bug3051674 fixes for the multi-row edits to happen
471 as of the lf_evt_ocrd_dt
472 115.205 28-Aug-03 tjesumic bug # 3086161 when the open LE reprocessed on the same day of
473 the previous LE process date. the previous LE result are
474 updated with open per in ler id. if the open LE is backedout
475 then the result of previous LE are lost. this is fixed
476 by copying the result of LE to backop table and copy
477 back to result when the open is backed out
478 bepenapi modified to copy to the backup table in update_prtt_reslt
479 and delete_enrollment to update the result from backup tabe
480 Related changes are in benbolfe.pkb
481 115.206 16-Sep-03 vsethi Bug 3123698 - Added tokens to messages BEN_92179_BELOW_MIN_AMOUNT and
482 BEN_92180_ABOVE_MAX_AMOUNT
483 115.207 26-Sep-03 kmahendr Added void_rate procedure and codes in delete_enroll - GHR fix
484 115.208 07-Oct-03 tjesumic if the dpnt enrolled in same type of plan the dpnt are recyled
485 even if alws_dpnt_dsgn_flag is 'N'
486 115.209 10-Oct-03 tjesumic even if the old result_id not passed the dpnt carry forward for
487 alws_dpnt_dsgn_flag is 'N' # 3175382
488 115.210 13-Nov-03 ikasire Bug 3256056 We want remove the penid from the enb record
489 while zaping or voiding the pen
490 115.211 14-Nov-03 mmudigon Bug 3222057. Step 155 Bypass call to
491 ben_cobj_cache.get_pgm_dets for plnip
492 115.212 15-Nov-03 kmahendr Bug#3260564 - assign rt_end_dt at the time delete_enrollment
493 for 1 prior codes based on new enrollment.
494 115.213 29-Dec-03 rpgupta Bug#3327224 - Make dpnt cvg end dt independent of prtt cvg end dt
495 115.214 08-Jan-04 vvprabhu Bug 1620171 - Changes to date format in message 91902
496 115.215 05-Feb-04 ikasire Bug 3412562 void_rate
497 115.216 11-Mar-04 bmanyam BUG: 3398353 - END-DATE/VOID Dependent Designation records
498 (BEN_ELIG_CVRD_DPNT_F) in void_enrollment procedure
499 for Unrestricted Enrollment.
500 Bug: 1620171 - For msg 91902, used fnd_date.date_to_chardate
501 instead of a fixed format-mask.
502 115.217 07=Apr-04 tjesumic FONM changes added
503 115.218 19-apr-04 bmanyam Bug# 3573173 : In c_prem cursor, added
504 condition NVL(ecr.enrt_bnft_id, -1) = NVL(p_enrt_bnft_id, -1) to
505 make sure the ben_enrt_prem record refers to the correct ben_enrt_bnft_f
506 record while creating ben_prtt_prem.
507 115.219 21-Apr-04 kmahendr Bug#3568529 - ben_env_object.init is called only if the
508 object was not initialised.
509 115.220 04-May-04 bmanyam Bug: 3574168 - In void_enrollment, delete_enrollment and
510 unhook_dpnt procedures, added code to delete the assigned
511 Primary-Care-Providers for the enrollment.
512 115.221 13-May-04 bmanyam Bug# 3574168: Removed delete_prmry_care_prvdr
513 from unhook_dpnt, as "update_elig_cvrd_dpnt"
514 procedure will do it.
515 115.222 17-May-04 ikasire Bug# 3631117 fixes for APP-PAY-07155 and APP-BEN-91711 errors
516 115.223 18-May-04 ikasire Bug# 3631117 change null to to_number(null)
517 115.224 18-May-04 nhunur Bug# 3626176
518 115.225 21-May-04 bmanyam Bug# 3631067 - changed cursors c_pcp and c_pcp_future
519 to fetch records based on cvg_thru_date and NOT p_effective_date
520 115.226 16-Jun-04 bmanyam Bug# 3657077 : In procedure determine_dpnt_cvg_dt_cd,
521 check if DPNT_DSGN_CD is specified at plan-level.
522 If it is specified then dependent designation level is PL.
523 This overrides PGM and PTIP levels
524 115.230 Leapfroged version of 115.228 by Amit Parekh
525 115.231 28-Jun-04 kmahendr Bug#3714789 - Effective date is derived from benmngle
526 parameter for Selection mode in delete_enrollment
527 115.232 30-Jun-04 abparekh Bug 3733213 : In delete_enrollment while setting new Coverage End Date
528 for CVG_END_DT_CD starting with W or LW, check for NULL value of
529 l_new_enrt_cvg_strt_dt and not whether cursor C_NEW_CVG_STRT_DT
530 fetched any row since the cursor uses aggregate function.
531 115.233 06-Jul-04 ikasire Bug 3695005 consider suspended enrollment also in the multi
532 row edits in evaluating coverage across plan types.
533 115.234 23-Jul-04 kmahendr Bug#3772143 - added parameter - p_include_erl
534 115.234 29-Jul-04 tjesumic Bug#3259447 - nvl added to recalc_premium for p_enrt_cvg_strt_dt
535 115.236 09-Aug-04 nhunur Bug - 3797391 - call unhook_dpnt / unhook_bnf .
536 115.237 23-Aug-04 mmudigon CFW. changes to delete_enrollment
537 2534391 :NEED TO LEAVE ACTION ITEMS
538 115.238 01-Sep-04 abparekh Bug# 3866580 : Call determine_action_items only for savings plan enrollment
539 at plan level (and not option in plan level). For rest of the plans
540 call for enrollment in plan as well as option in plan level
541 115.239 07-sep-04 mmudigon CFW. Continued
542 115.240 09-sep-04 mmudigon Bug fixes 3865108 and 3882130
543 115.241 30-sep-04 tmathers Overloaded multi_rows_edit as
544 not all libraries have the new parameter
545 p_include_erl.392661
546 115.242 07-oct-04 ssarkar BUG: 3904792: MAINLINE FIX FOR 3894240: WHEN UPDATING A SAVINGS
547 PLAN RATE SYSTEM IS END DATE
548 115.243 12-Oct-04 ikasire Bug 3939785 Need to handled the override thru date properly
549 115.244 19-Oct-04 abparekh Bug 3958064 Need to handled the override thru date properly only for Overriden records
550 115.245 12-Jan-05 lakrish 4114012, Added SS wrapper procedure delete_enrollment_w
551 115.246 18-Jan-05 ikasire Bug 4064635 CF SUSP and INTERIM 'W' and 'WL' cases
552 115.247 21-jan-05 nhunur Added c_prvdel cursor
553 115.248 07-Feb-05 tjesumic backout_future_coverage function removed from benelinf.pkb. future coverages are
554 copied into backup table in delete_enrollmet. multo_rows_edit take care of voiding
555 # 4118315
556 115.248 09-Mar-05 mmudigon Bug 4157759 . Added var l_prtt_rt_val_stat_cd in
557 proc delete_enrollment.
558 115.249 05-Apr-05 bmanyam Bug 4268494: Added '1 Prior' logic for
559 LDPPOEFD - 1 Prior or End of Pay Period On or After Effective Date
560 LDPPFEFD - 1 Prior or End of Pay Period after Effective Date
561 115.250 13-Apr-05 ikasire Added new parameter to manage_enrt_bnft call
562 115.251 15-Apr-05 kmahendr Added a condition for 1 prior codes in delete_enrollment
563 115.252 18-May-05 ikasire Bug 4262697 don't delete the results of previous life events if there
564 are no electable choices in the current life event of the comp
565 object.
566 115.253 23-may-05 ssarkar bug 3123698 : added cursor c_pl_typ_names to proc multi_row_edit.
567 115.255 26-May-05 vborkar Bug 4387247 : In wrapper method exception
568 handlers changes made to avoid null errors
569 on SS pages
570 115.256 01-Jun-05 vborkar Bug 4387247 : Modifications to take care of
571 application exceptions.
572 115.257 04-Jul-05 rgajula Bug 4431511 Added checks in get_ben_pen_upd_dt_modes to ensure update_override is passed as
573 effective datetrack mode if the desired date track mode is
574 delete next change in case of unrestricted enrollments
575 115.258 20-Jul-05 ikasire Bug 4463836 added new parameter p_called_from_ss
576 115.259 27-Jul-05 kmahendr Bug#4509665 - modified the cursor c_pl_typ_names
577 and increased the length of variable l_pl_typ_name
578 115.260 29-jul-05 tjesumic BUG 4510798 : fonm variable intialised on delete_enrollment
579 115.261 24-Aug-05 swjain Bug 4520785 : Updated cursor c_old_dpnt in procedure unhook_dpnt
580 115.262 24-Aug-05 ikasire Indented delete_enrollment procedure to improve productivity
581 in bug resolutions.
582 115.263 06-Oct-05 bmanyam Bug 4642299 : Added 'LODBEWM','ODBEWM' too for 1 Prior logic.
583 115.264 07-oct-05 ssarkar Bug 4616225 : Call to pl/oipl cache is set to nvl(life_event_dt/effective_date).
584 proc delete_enrollment modified for same .Also ben_cobj_cache.get_pl_dets/get_oipl_dets
585 are called after ben_global_enrt.get_pil .
586 115.265 17-Oct-05 vborkar BUG 4663971 : In delete_enrollment, called update_prtt_enrt_result
587 instead of delete_prtt_enrt_result for datetrack mode other than zap.
588 Also if eff date equals PEN start date then called update_prtt_enrt_result
589 in correction mode, otherwise in update mode.
590 115.266 18-Oct-05 abparekh Bug 4662362 : Unhook dependents / beneficiary in all case
591 115.267 31-Oct-05 ikasire Bug 4690334 : multi_rows_edit from overview page
592 115.268 31-Oct-05 ikasire Bug 4710937 cursor c_old_dpnt regression from 4520785
593 115.269 02-Nov-05 ikasire Bug 4709601 multi_rows_edit not required for CFW call
594 115.270 10-Nov-05 abparekh Bug 4723828 Correctly handle nullifying of benefit amount
595 115.271 18-Nov-05 bmanyam Bug 4739922: In delete_enrollment, Case 4:
596 Backout the Result/ (do not VOIDD).
597 115.272 18-Nov-05 bmanyam If enrollment api's are called from
598 concurrent manager for conversion or ivr kind of interfaces, call raises error.
599 benutils.get_batch_parameters
600 115.273 13-Dec-05 vborkar Bug 4695708 : Made changes to delete_enrollment
601 and delete_enrollment_w exception handlers
602 so that error messages are correctly shown
603 in SS.
604 115.275 24-Jan-06 vborkar 4962138 : In remove_cert_action_items, when p_source is null
605 changed datetrack mode from DELETE to ZAP,
606 in order to avoid display of action item(s) in PUI
607 for de-enrolled selections.
608 115.276 31-Jan-06 kmahendr Bug#4967063 - modified cursor c_new_cvg_strt in
609 delete_enrollment
610 115.277 02-Feb-06 bmanyam BUG 4919591 - Changed c_rslt_ptip, c_rslt_pl, c_rslt_oipl
611 to check Earliest De-enrollment date in case of Unrestricted.
612 115.278 17-Feb-06 kmahendr Bug#5032364 - modified cursor c_old_corr_pen in
613 delete_enrollment
614 115.279 28-Feb-06 rgajula Bug 4770367 : Added the NVL condition so as to allow the user to update
615 the attributes with NULL values if the user wishes to do so
616 115.280 03-Mar-06 rtagarra Bug 5018328 : Added condition in exception block for delete_enrollment so
617 that it will take care for this specific exception condition.
618 115.281 03-Mar-06 kmahendr Added check for automatic enrollment in
619 delete_enrollment - enh
620 115.282 13-Mar-06 kmahendr Bug#5082245 - savings plan is determined by flag
621 than opt type code
622 115.283 16_mar-06 rtagarra Bug 5018328 :Added a check for exception l_fnd_message_exception
623 in exception block for delete_enrollment procedure.
624 115.285 10-Apr-06 kmahendr Bug#5126242 - added a parameter to delete_prmry_care
625 115.286 19Apr-06 rtagarra Added cursor c_crntly_enrd_flag and c_crntly_enrd_flag_unres for Bug#5018328 which checks
626 whether the deenrollment should be allowed in subsequesnt LE depending on earliest deenrollment date
627 both for LE and Unrestricted.
628 115.286 02-May-06 ikasired Bug 5102337
629 115.291 13-jun-06 ssarkar bug 5287988 - leap -frog of 115.287 as ver 288 to 290 r reverted
630 115.292 28-jun-06 ssarkar bug 5347887 - need to populate rplcs_sspndd_rslt_id while end-dating sspndd pen.
631 115.293 29-jun-06 kmahendra/ bug 5363388 - marking pen as 'BCKDT' when cvg st dt > cvg end dt
632 ssarkar
633 115.294 10-Jul-06 rgajula Bug 5368060
634 Dont void the rate if the PEN record is Backed-Out
635 If the PEN record is end-dated in the subsequent life event dont void the rate
636 115.295 03-aug-06 ssarkar bug 5417132 - by passing chk of enrt method for flex and impute
637 115.297 04-Sep-06 rgajula Bug 5499809 - Void the enrollment and rate if the delete enrollment is being performed in the same life event and that life event is not unrestricted LE
638 115.298 27-Sep-06 stee Bug 5391554 - Adjust overlapping rates.
639 115.299 10/4/2006 gsehgal Bug 5550679 - void_rate void the rates for all per_in_ler_id whereas it should void the
640 rate only calling that per_in_ler_id
641 115.300 12-Oct-06 rtagarra Bug 5567840 - Added check so that error 94596 wont be raised for imputed income plans.
642 115.301 30-Oct-06 abparekh Bug 5626835 - For delete cases 3/4 : For Enter Value At Enrollment cases,
643 we need to void rate instead of deleting them.
644 115.302 01-Nov-06 swjain Bug 5637595 - Added more checks in procedure delete_enrollment so that for open
645 enrollment cases, if future dated coverages are there in previous
646 and subsequent LEs, then changing enrollments should not backout the
647 end dated coverage record.
648 115.303 22-Nov-06 vborkar Bug 5663280 - Do not 'VOID' carry forwarded enrollments which are end-dated in
649 current life event
650 115.304 24-nov-06 rtagarra Bug 5664907 - Application Exceptions for delete_enrollment are handled.
651 115.305 19-dec-06 ssarkar Bug 5717428
652 115.306 24-Jan-07 swjain Bug 5739530 - Updated procedure delete_enrollment, update future prvs only if
653 they haven't been updated previously.
654 115.307 30-Jan-07 rgajula Bug 5768795 - Moved the code for validation of "Coverage Across Plan Types" from multi_rows_edit
655 to a seperate procedure chk_coverage_across_plan_types.
656 115.309 21-feb-07 rgajula Bug 5859714 :Updated the field BEN_PER_IN_LER.BCKT_PER_IN_LER_ID of
657 the backed out L.E with the per_in_ler_id of the causing L.E
658 115.310 11-May-07 ikasired Bug 5985777 Backup the future completed action items.
659 115.311 14-May-06 rtagarra Bug 6000303 : Defer Deenrollment ENH.
660 115.312 04-Jul-07 swjain Bug 6165501 : Updated cursor c_intm_other_rslt in delete_enrollment procedure
661 115.313 04-Oct-07 rtagarra Bug 6471236 : void_rate should only be called for the PRV for which void should happen
662 instead of calling for all PRV's associated with the PEN for entr_val_at_enrt_flag.
663 115.314 26-Oct-07 swjain Bug 6528876 : Added order by clause in get_election_date
664 115.315 30-Nov-06 rtagarra Bug 6656136 : While calling multi_rows_edit pass l_lf_evt_ocrd_dt only for Open and for others pass p_effective_date.
665 115.316 01-Dec-07 sshetty Bug 6641853 : The enrollment is set to correction
666 when the changes are done within
667 enrollment period and does not
668 void.
669 115.317 14-Dec-07 sallumwa Bug 6683229 : Removed a condition,which is satisfied always because l_other_pen_rec
670 is not populated before it is used.
671
672 115.318 23-Dec-07 sshetty Bug 6641853 : Handled some more conditions for
673 same bug
674 115.318 06-Jan-08 sshetty Bug 6641853 : Fixed rate issue
675 115.319 14-Jan-08 rtagarra Bug 6747807 : Fixed cursor c_check_cvrd_in_plan
676 115.320 04-APR-08 sshetty Bug 6641853 : Added per_in_ler_id as cursor
677 param to make sure the correction
678 is not read as update
679 115.321 30-apr-08 sallumwa Bug 6925893 : A Rate Gap exists when Rate Start dates Code
680 is set to First of Next Pay period,
681 Rate end date is 1 Prior and enrollments
682 are saved on different dates
683 crossing pay periods.
684
685 115.322 19-may-08 bachakra Bug 6963660: Updated the effective start date of the
686 corrected result in the back up table to the more
687 recent date so, that the previous enrollment gets opened up
688 on backing out the current life event which has two
689 records attached to it for the same plan. Please refer bug
690 for test case.
691 115.325 24-jul-08 bachakra Bug 7206471: Adjusted coverage overlap.
692 115.326 10-sep-08 sallumwa Bug 7311284 : Modified the condition while setting the effective date in
693 delete_enrollment procedure.
694 115.327 12-Jun-08 sallumwa Bug 7133998: Modified the update_enrollment procedure to delete the future
695 premium records corresponding to the previous Le.
696 115.328 15-Oct-08 stee Bug 7197868: Remove fix for bug 6963660. Change cursor c_old_corr_pen
697 to check for effective_start_date.
698 115.329 07-Nov-08 sallumwa Bug 7458990: Reverted back the fix 5018328,so that the system throws the error
699 when trying to change the plan before the earliest de-enrol date.
700 ==================================================================================================================
701 */
702 --
703 -- Package Variables
704 --
705 g_package Varchar2(33) := ' ben_PRTT_ENRT_RESULT_api.';
706 g_debug boolean := hr_utility.debug_enabled;
707 --
708 Function display_boolean(p_condition boolean) return varchar2 is
709 begin
710 if (p_condition) then
711 return 'TRUE';
712 else
713 return 'FALSE';
714 end if;
715 end display_boolean;
716 --
717 procedure rpt_error (p_proc in varchar2
718 ,p_step in number
719 ) is
720 begin
721 if g_debug then
722 hr_utility.set_location('Fail in '|| p_proc || ' at step ' ||
723 to_char(p_step),999);
724 end if;
725 end;
726
727
728
729 --
730 -- ----------------------------------------------------------------------------
731 -- |----------------------< Remove_Cert_Action_items >------------------------|
732 -- ----------------------------------------------------------------------------
733 --
734
735 procedure remove_cert_action_items
736 (p_prtt_enrt_rslt_id in number
737 ,p_effective_date in date
738 ,p_end_date in date default null
739 ,p_business_group_id in number
740 ,p_validate in boolean default FALSE
741 ,p_datetrack_mode in varchar2
742 ,p_source in varchar2 default null
743 ,p_per_in_ler_id in number default null
744 ,p_per_in_ler_ended_id in number default null
745 ) is
746 l_proc varchar2(80); -- := g_package||'.remove_cert_action_items';
747 l_step number(5);
748 l_tmp number(15);
749
750 cursor c_bnf_types is
751 select pea.prtt_enrt_actn_id
752 ,pea.object_version_number
753 ,pea.effective_start_date
754 ,pea.effective_end_date
755 ,pil.lf_evt_ocrd_dt
756 from ben_prtt_enrt_actn_f pea,
757 ben_per_in_ler pil
758 where pea.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
759 and pea.business_group_id = p_business_group_id
760 and p_effective_date
761 between pea.effective_start_date and pea.effective_end_date
762 and pil.per_in_ler_id=pea.per_in_ler_id
763 and pil.business_group_id=pea.business_group_id
764 and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT') ;
765
766 cursor c_min_max_dt(p_prtt_enrt_actn_id number) is
767 select min(effective_start_date),
768 max(effective_end_date)
769 from ben_prtt_enrt_actn_f
770 where prtt_enrt_actn_id = p_prtt_enrt_actn_id;
771 --
772 cursor c_pea_ovn(p_prtt_enrt_actn_id number,
773 p_effective_date date) is
774 select pea.object_version_number
775 from ben_prtt_enrt_actn_f pea
776 where pea.prtt_enrt_actn_id = p_prtt_enrt_actn_id
777 and p_effective_date between pea.effective_start_date
778 and pea.effective_end_date ;
779 --
780 cursor c_future_pea(p_prtt_enrt_actn_id number,p_effective_date date ) is
781 select *
782 from ben_prtt_enrt_actn_f
783 where prtt_enrt_actn_id = p_prtt_enrt_actn_id
784 and effective_start_date > p_effective_date
785 order by effective_start_date desc ;
786
787 --
788 cursor c_future_pcs(p_prtt_enrt_actn_id number,p_effective_date date ) is
789 select *
790 from ben_prtt_enrt_ctfn_prvdd_f
791 where prtt_enrt_actn_id = p_prtt_enrt_actn_id
792 and effective_start_date > p_effective_date
793 order by effective_start_date desc ;
794 --
795 l_effective_date date;
796 l_min_start_date date;
797 l_max_end_date date;
798 l_datetrack_mode varchar2(30);
799 --
800 begin
801 if g_debug then
802 l_proc := g_package||'.remove_cert_action_items';
803 hr_utility.set_location ('Entering '||l_proc,10);
804 hr_utility.set_location ('p_end_date '||p_end_date,10);
805 end if;
806 --
807 l_step := 10;
808 /* leslie removed this call
809 for l_prtt_ctfn_prvdd in c_prtt_ctfn_prvdd loop
810 ben_prtt_enrt_ctfn_prvdd_api.delete_prtt_enrt_ctfn_prvdd
811 (p_validate => FALSE
812 ,p_prtt_enrt_ctfn_prvdd_id=> l_prtt_ctfn_prvdd.prtt_enrt_ctfn_prvdd_id
813 ,p_effective_start_date => l_prtt_ctfn_prvdd.effective_start_date
814 ,p_effective_end_date => l_prtt_ctfn_prvdd.effective_end_date
815 ,p_object_version_number => l_prtt_ctfn_prvdd.object_version_number
816 ,p_effective_date => p_effective_date
817 ,p_datetrack_mode => p_datetrack_mode
818 );
819 end loop;
820 l_step := 20;
821 */
822 for l_bnf_types in c_bnf_types loop
823 l_step := 25;
824 if p_end_date is not null then
825
826 l_min_start_date := null;
827 l_max_end_date := null;
828
829 open c_min_max_dt(l_bnf_types.prtt_enrt_actn_id);
830 fetch c_min_max_dt into l_min_start_date,l_max_end_date;
831 close c_min_max_dt;
832
833 if p_end_date < l_min_start_date then
834 l_effective_date := p_effective_date;
835 l_datetrack_mode := hr_api.g_zap;
836 elsif p_end_date < l_max_end_date then
837 l_effective_date := p_end_date;
838 l_datetrack_mode := hr_api.g_delete;
839 --
840 --get the correct ovn
841 --
842 open c_pea_ovn(l_bnf_types.prtt_enrt_actn_id, p_end_date);
843 fetch c_pea_ovn into l_bnf_types.object_version_number;
844 close c_pea_ovn;
845 --
846 else
847 l_datetrack_mode := null;
848 end if;
849
850 if l_datetrack_mode is not null then
851 --
852 --BUG 5985777 writing future action items to backup table
853 --
854 --Find if there are any future action items. If exists
855 --backup those rows.
856 --
857 --ben_prtt_enrt_actn_f
858 --
859 for l_pea in c_future_pea(l_bnf_types.prtt_enrt_actn_id,l_effective_date) loop
860 --
861 insert into BEN_LE_CLSN_N_RSTR (
862 BKUP_TBL_TYP_CD,
863 BKUP_TBL_ID,
864 EFFECTIVE_START_DATE,
865 EFFECTIVE_END_DATE,
866 PRTT_IS_CVRD_FLAG, -- RQD_FLAG
867 ASSIGNMENT_ID, -- ACTN_TYP_ID
868 PRTT_ENRT_RSLT_ID,
869 PER_IN_LER_ID,
870 BUSINESS_GROUP_ID,
871 ENRT_CVG_THRU_DT, -- CMPLTD_DT
872 ENRT_OVRID_THRU_DT, -- DUE_DT
873 PGM_ID, -- PL_BNF_ID
874 PTIP_ID, -- ELIG_CVRD_DPNT_ID
875 LCR_ATTRIBUTE_CATEGORY,
876 LCR_ATTRIBUTE1,
877 LCR_ATTRIBUTE2,
878 LCR_ATTRIBUTE3,
879 LCR_ATTRIBUTE4,
880 LCR_ATTRIBUTE5,
881 LCR_ATTRIBUTE6,
882 LCR_ATTRIBUTE7,
883 LCR_ATTRIBUTE8,
884 LCR_ATTRIBUTE9,
885 LCR_ATTRIBUTE10,
886 LCR_ATTRIBUTE11,
887 LCR_ATTRIBUTE12,
888 LCR_ATTRIBUTE13,
889 LCR_ATTRIBUTE14,
890 LCR_ATTRIBUTE15 ,
891 LCR_ATTRIBUTE16,
892 LCR_ATTRIBUTE17,
893 LCR_ATTRIBUTE18,
894 LCR_ATTRIBUTE19,
895 LCR_ATTRIBUTE20,
896 LCR_ATTRIBUTE21,
897 LCR_ATTRIBUTE22,
898 LCR_ATTRIBUTE23,
899 LCR_ATTRIBUTE24,
900 LCR_ATTRIBUTE25,
901 LCR_ATTRIBUTE26,
902 LCR_ATTRIBUTE27,
903 LCR_ATTRIBUTE28,
904 LCR_ATTRIBUTE29,
905 LCR_ATTRIBUTE30,
906 LAST_UPDATE_DATE,
907 LAST_UPDATED_BY,
908 LAST_UPDATE_LOGIN,
909 CREATED_BY,
910 CREATION_DATE,
911 REQUEST_ID,
912 PROGRAM_APPLICATION_ID,
913 PROGRAM_ID,
914 PROGRAM_UPDATE_DATE,
915 OBJECT_VERSION_NUMBER,
916 PER_IN_LER_ENDED_ID)
917 values (
918 'BEN_PRTT_ENRT_ACTN_F_UPD'
919 ,l_pea.PRTT_ENRT_ACTN_ID
920 ,l_pea.EFFECTIVE_START_DATE
921 ,l_pea.EFFECTIVE_END_DATE
922 ,l_pea.RQD_FLAG
923 ,l_pea.ACTN_TYP_ID
924 ,l_pea.PRTT_ENRT_RSLT_ID
925 ,P_PER_IN_LER_ID
926 ,l_pea.BUSINESS_GROUP_ID
927 ,l_pea.CMPLTD_DT
928 ,l_pea.DUE_DT
929 ,l_pea.PL_BNF_ID
930 ,l_pea.ELIG_CVRD_DPNT_ID
931 ,l_pea.PEA_ATTRIBUTE_CATEGORY
932 ,l_pea.PEA_ATTRIBUTE1
933 ,l_pea.PEA_ATTRIBUTE2
934 ,l_pea.PEA_ATTRIBUTE3
935 ,l_pea.PEA_ATTRIBUTE4
936 ,l_pea.PEA_ATTRIBUTE5
937 ,l_pea.PEA_ATTRIBUTE6
938 ,l_pea.PEA_ATTRIBUTE7
939 ,l_pea.PEA_ATTRIBUTE8
940 ,l_pea.PEA_ATTRIBUTE9
941 ,l_pea.PEA_ATTRIBUTE10
942 ,l_pea.PEA_ATTRIBUTE11
943 ,l_pea.PEA_ATTRIBUTE12
944 ,l_pea.PEA_ATTRIBUTE13
945 ,l_pea.PEA_ATTRIBUTE14
946 ,l_pea.PEA_ATTRIBUTE15
947 ,l_pea.PEA_ATTRIBUTE16
948 ,l_pea.PEA_ATTRIBUTE17
949 ,l_pea.PEA_ATTRIBUTE18
950 ,l_pea.PEA_ATTRIBUTE19
951 ,l_pea.PEA_ATTRIBUTE20
952 ,l_pea.PEA_ATTRIBUTE21
953 ,l_pea.PEA_ATTRIBUTE22
954 ,l_pea.PEA_ATTRIBUTE23
955 ,l_pea.PEA_ATTRIBUTE24
956 ,l_pea.PEA_ATTRIBUTE25
957 ,l_pea.PEA_ATTRIBUTE26
958 ,l_pea.PEA_ATTRIBUTE27
959 ,l_pea.PEA_ATTRIBUTE28
960 ,l_pea.PEA_ATTRIBUTE29
961 ,l_pea.PEA_ATTRIBUTE30
962 ,l_pea.LAST_UPDATE_DATE
963 ,l_pea.LAST_UPDATED_BY
964 ,l_pea.LAST_UPDATE_LOGIN
965 ,l_pea.CREATED_BY
966 ,l_pea.CREATION_DATE
967 ,l_pea.REQUEST_ID
968 ,l_pea.PROGRAM_APPLICATION_ID
969 ,l_pea.PROGRAM_ID
970 ,l_pea.PROGRAM_UPDATE_DATE
971 ,l_pea.OBJECT_VERSION_NUMBER
972 ,p_per_in_ler_ended_id
973 );
974
975 end loop;
976 --
977 --ben_prtt_enrt_ctfn_prvdd_f
978 --
979 for l_lcs in c_future_pcs(l_bnf_types.prtt_enrt_actn_id,l_effective_date) loop
980 --
981 insert into BEN_LE_CLSN_N_RSTR (
982 BKUP_TBL_TYP_CD,
983 BKUP_TBL_ID,
984 EFFECTIVE_START_DATE,
985 EFFECTIVE_END_DATE,
986 PRTT_IS_CVRD_FLAG, -- ENRT_CTFN_RQD_FLAG
987 COMP_LVL_CD, -- ENRT_CTFN_TYP_CD
988 ENRT_CVG_THRU_DT, -- ENRT_CTFN_RECD_DT
989 PRTT_ENRT_RSLT_ID,
990 PGM_ID, -- PRTT_ENRT_ACTN_ID
991 ENRT_OVRID_THRU_DT, -- ENRT_CTFN_DND_DT
992 BNFT_TYP_CD, -- ENRT_R_BNFT_CTFN_CD
993 BUSINESS_GROUP_ID,
994 LCR_ATTRIBUTE_CATEGORY,
995 LCR_ATTRIBUTE1,
996 LCR_ATTRIBUTE2,
997 LCR_ATTRIBUTE3,
998 LCR_ATTRIBUTE4,
999 LCR_ATTRIBUTE5,
1000 LCR_ATTRIBUTE6,
1001 LCR_ATTRIBUTE7,
1002 LCR_ATTRIBUTE8,
1003 LCR_ATTRIBUTE9,
1004 LCR_ATTRIBUTE10,
1005 LCR_ATTRIBUTE11,
1006 LCR_ATTRIBUTE12,
1007 LCR_ATTRIBUTE13,
1008 LCR_ATTRIBUTE14,
1009 LCR_ATTRIBUTE15 ,
1010 LCR_ATTRIBUTE16,
1011 LCR_ATTRIBUTE17,
1012 LCR_ATTRIBUTE18,
1013 LCR_ATTRIBUTE19,
1014 LCR_ATTRIBUTE20,
1015 LCR_ATTRIBUTE21,
1016 LCR_ATTRIBUTE22,
1017 LCR_ATTRIBUTE23,
1018 LCR_ATTRIBUTE24,
1019 LCR_ATTRIBUTE25,
1020 LCR_ATTRIBUTE26,
1021 LCR_ATTRIBUTE27,
1022 LCR_ATTRIBUTE28,
1023 LCR_ATTRIBUTE29,
1024 LCR_ATTRIBUTE30,
1025 LAST_UPDATE_DATE,
1026 LAST_UPDATED_BY,
1027 LAST_UPDATE_LOGIN,
1028 CREATED_BY,
1029 CREATION_DATE,
1030 REQUEST_ID,
1031 PROGRAM_APPLICATION_ID,
1032 PROGRAM_ID,
1033 PROGRAM_UPDATE_DATE,
1034 OBJECT_VERSION_NUMBER,
1035 PER_IN_LER_ID,
1036 PER_IN_LER_ENDED_ID)
1037 values (
1038 'BEN_PRTT_ENRT_CTFN_PRVDD_F_UPD'
1039 ,l_lcs.PRTT_ENRT_CTFN_PRVDD_ID
1040 ,l_lcs.EFFECTIVE_START_DATE
1041 ,l_lcs.EFFECTIVE_END_DATE
1042 ,l_lcs.ENRT_CTFN_RQD_FLAG
1043 ,l_lcs.ENRT_CTFN_TYP_CD
1044 ,l_lcs.ENRT_CTFN_RECD_DT
1045 ,l_lcs.PRTT_ENRT_RSLT_ID
1046 ,l_lcs.PRTT_ENRT_ACTN_ID
1047 ,l_lcs.ENRT_CTFN_DND_DT
1048 ,l_lcs.ENRT_R_BNFT_CTFN_CD
1049 ,l_lcs.BUSINESS_GROUP_ID
1050 ,l_lcs.PCS_ATTRIBUTE_CATEGORY
1051 ,l_lcs.PCS_ATTRIBUTE1
1052 ,l_lcs.PCS_ATTRIBUTE2
1053 ,l_lcs.PCS_ATTRIBUTE3
1054 ,l_lcs.PCS_ATTRIBUTE4
1055 ,l_lcs.PCS_ATTRIBUTE5
1056 ,l_lcs.PCS_ATTRIBUTE6
1057 ,l_lcs.PCS_ATTRIBUTE7
1058 ,l_lcs.PCS_ATTRIBUTE8
1059 ,l_lcs.PCS_ATTRIBUTE9
1060 ,l_lcs.PCS_ATTRIBUTE10
1061 ,l_lcs.PCS_ATTRIBUTE11
1062 ,l_lcs.PCS_ATTRIBUTE12
1063 ,l_lcs.PCS_ATTRIBUTE13
1064 ,l_lcs.PCS_ATTRIBUTE14
1065 ,l_lcs.PCS_ATTRIBUTE15
1066 ,l_lcs.PCS_ATTRIBUTE16
1067 ,l_lcs.PCS_ATTRIBUTE17
1068 ,l_lcs.PCS_ATTRIBUTE18
1069 ,l_lcs.PCS_ATTRIBUTE19
1070 ,l_lcs.PCS_ATTRIBUTE20
1071 ,l_lcs.PCS_ATTRIBUTE21
1072 ,l_lcs.PCS_ATTRIBUTE22
1073 ,l_lcs.PCS_ATTRIBUTE23
1074 ,l_lcs.PCS_ATTRIBUTE24
1075 ,l_lcs.PCS_ATTRIBUTE25
1076 ,l_lcs.PCS_ATTRIBUTE26
1077 ,l_lcs.PCS_ATTRIBUTE27
1078 ,l_lcs.PCS_ATTRIBUTE28
1079 ,l_lcs.PCS_ATTRIBUTE29
1080 ,l_lcs.PCS_ATTRIBUTE30
1081 ,l_lcs.LAST_UPDATE_DATE
1082 ,l_lcs.LAST_UPDATED_BY
1083 ,l_lcs.LAST_UPDATE_LOGIN
1084 ,l_lcs.CREATED_BY
1085 ,l_lcs.CREATION_DATE
1086 ,l_lcs.REQUEST_ID
1087 ,l_lcs.PROGRAM_APPLICATION_ID
1088 ,l_lcs.PROGRAM_ID
1089 ,l_lcs.PROGRAM_UPDATE_DATE
1090 ,l_lcs.OBJECT_VERSION_NUMBER
1091 ,p_per_in_ler_id
1092 ,p_per_in_ler_ended_id
1093 );
1094
1095 --
1096 end loop;
1097 --
1098 ben_prtt_enrt_actn_api.delete_prtt_enrt_actn
1099 (p_validate => FALSE
1100 ,p_prtt_enrt_actn_id => l_bnf_types.prtt_enrt_actn_id
1101 ,p_effective_start_date => l_bnf_types.effective_start_date
1102 ,p_effective_end_date => l_bnf_types.effective_end_date
1103 ,p_object_version_number => l_bnf_types.object_version_number
1104 ,p_effective_date => l_effective_date
1105 ,p_datetrack_mode => l_datetrack_mode
1106 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
1107 ,p_unsuspend_enrt_flag => 'N'
1108 ,p_rslt_object_version_number => l_tmp
1109 ,p_business_group_id => p_business_group_id);
1110 end if;
1111
1112 else
1113 --
1114 -- Datetrack delete the action items, one day before.
1115 -- Do not decrease the effective date, when called from 'benelinf',
1116 -- as the date is already modified in delete_enrollment in such cases.
1117 --
1118 if l_bnf_types.effective_start_date < p_effective_date and
1119 p_datetrack_mode = hr_api.g_delete and
1120 nvl(p_source,'benelinf') <> 'benelinf' then
1121 l_datetrack_mode := p_datetrack_mode;
1122 l_effective_date := p_effective_date -1;
1123 -- 4962138
1124 elsif l_bnf_types.effective_start_date <= p_effective_date and
1125 p_datetrack_mode = hr_api.g_delete and
1126 p_source is null then
1127 l_datetrack_mode := hr_api.g_zap;
1128 l_effective_date := p_effective_date;
1129 -- end 4962138
1130 else
1131 l_datetrack_mode := p_datetrack_mode;
1132 l_effective_date := p_effective_date;
1133 end if;
1134 --
1135 -- Do not attempt dt delete if the row selected already has an effective
1136 -- end date equal to(or less than) the date you are trying to delete it on.
1137 -- Bug 1132739
1138 --
1139 if (p_datetrack_mode = hr_api.g_delete and
1140 l_bnf_types.effective_end_date > l_effective_date) or
1141 p_datetrack_mode <> hr_api.g_delete then
1142 ben_prtt_enrt_actn_api.delete_prtt_enrt_actn
1143 (p_validate => FALSE
1144 ,p_prtt_enrt_actn_id => l_bnf_types.prtt_enrt_actn_id
1145 ,p_effective_start_date => l_bnf_types.effective_start_date
1146 ,p_effective_end_date => l_bnf_types.effective_end_date
1147 ,p_object_version_number => l_bnf_types.object_version_number
1148 ,p_effective_date => l_effective_date
1149 ,p_datetrack_mode => l_datetrack_mode -- 4962138
1150 ,P_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
1151 ,P_unsuspend_enrt_flag => 'N'
1152 ,P_rslt_object_version_number => l_tmp
1153 ,P_business_group_id => p_business_group_id);
1154 end if;
1155 end if;
1156 end loop;
1157 if g_debug then
1158 hr_utility.set_location ('Leaving '||l_proc,70);
1159 end if;
1160 --
1161 exception
1162 when others then
1163 if g_debug then
1164 hr_utility.set_location ('Fail in '||l_proc|| ' at step ' ||
1165 to_char(l_step),999);
1166 end if;
1167 raise;
1168 end;
1169 --
1170 -- ----------------------------------------------------------------------------
1171 -- |-------------------------< Get_ben_upd_dt_mode >---------------------------|
1172 -- ----------------------------------------------------------------------------
1173
1174 procedure get_ben_pen_upd_dt_mode
1175 (p_effective_date in date
1176 ,p_base_key_value in number
1177 ,P_desired_datetrack_mode in varchar2
1178 ,P_datetrack_allow in out nocopy varchar2
1179 ,p_ler_typ_cd in varchar2 default null
1180 )is
1181 l_dt_correction boolean;
1182 l_dt_update boolean;
1183 l_dt_update_override boolean;
1184 l_dt_update_change_insert boolean;
1185 -- Bug 4431511 new variables created
1186 l_dt_delete_next_change boolean;
1187 l_dt_delete boolean;
1188 l_dt_zap boolean;
1189 l_dt_future_change boolean;
1190 -- End Bug 4431511
1191 l_step number(9);
1192 l_proc varchar2(80) ; -- := g_package||'.get_ben_pen_upd_dt_mode';
1193 begin
1194 --
1195 g_debug := hr_utility.debug_enabled;
1196 if g_debug then
1197 l_proc := g_package||'.get_ben_pen_upd_dt_mode';
1198 hr_utility.set_location ('Entering '||l_proc,10);
1199 hr_utility.set_location('IK p_effective_date'||p_effective_date,1234);
1200 hr_utility.set_location('IK P_desired_datetrack_mode '||P_desired_datetrack_mode,1234);
1201 end if;
1202 --
1203 l_step := 10;
1204 --
1205 ben_pen_shd.find_dt_upd_modes
1206 (p_effective_date => p_effective_date
1207 ,p_base_key_value => p_base_key_value
1208 ,p_correction => l_dt_correction
1209 ,p_update => l_dt_update
1210 ,p_update_override => l_dt_update_override
1211 ,p_update_change_insert => l_dt_update_change_insert
1212 );
1213 --Bug 4431511 calling the find_dt_del_modes
1214 if(p_ler_typ_cd = 'SCHEDDU'
1215 and p_desired_datetrack_mode = hr_api.g_delete_next_change) then
1216
1217 ben_pen_shd.find_dt_del_modes
1218 (p_effective_date => p_effective_date
1219 ,p_base_key_value => p_base_key_value
1220 ,p_delete_next_change => l_dt_delete_next_change
1221 ,p_zap => l_dt_zap
1222 ,p_delete => l_dt_delete
1223 ,p_future_change => l_dt_future_change
1224 );
1225 END if;
1226
1227 if(p_ler_typ_cd = 'SCHEDDU'
1228 and p_desired_datetrack_mode = hr_api.g_delete) then
1229
1230 ben_pen_shd.find_dt_del_modes
1231 (p_effective_date => p_effective_date
1232 ,p_base_key_value => p_base_key_value
1233 ,p_delete_next_change => l_dt_delete_next_change
1234 ,p_zap => l_dt_zap
1235 ,p_delete => l_dt_delete
1236 ,p_future_change => l_dt_future_change
1237 );
1238 END if;
1239 -- End 4431511
1240
1241 --
1242 l_step := 20;
1243 --
1244 if l_dt_correction then
1245 if g_debug then
1246 hr_utility.set_location( 'l_dt_correction',1234);
1247 end if;
1248 end if;
1249 --
1250 if l_dt_update then
1251 if g_debug then
1252 hr_utility.set_location( 'l_dt_update',1234);
1253 end if;
1254 end if;
1255 --
1256 if l_dt_update_override then
1257 if g_debug then
1258 hr_utility.set_location( 'l_dt_update_override',1234);
1259 end if;
1260 end if;
1261 --
1262 if l_dt_update_change_insert then
1263 if g_debug then
1264 hr_utility.set_location( 'l_dt_update_change_insert',1234);
1265 end if;
1266 end if;
1267
1268 if l_dt_delete_next_change then
1269 if g_debug then
1270 hr_utility.set_location( 'l_dt_delete_next_change',1234);
1271 end if;
1272 end if;
1273
1274 if l_dt_delete then
1275 if g_debug then
1276 hr_utility.set_location( 'l_dt_delete',1234);
1277 end if;
1278 end if;
1279
1280 --
1281 if (p_desired_datetrack_mode = hr_api.g_update and l_dt_update) then
1282 p_datetrack_allow := hr_api.g_update;
1283 elsif (p_desired_datetrack_mode = hr_api.g_correction and l_dt_correction) then
1284 p_datetrack_allow := hr_api.g_correction;
1285 elsif (l_dt_update) then
1286 p_datetrack_allow := hr_api.g_update;
1287 --Bug 2739965 In case of unrestricted we need to take the
1288 -- l_dt_update_override case also.
1289 elsif (l_dt_update_override and -- p_ler_typ_cd = 'SCHEDDU' and --Bug 5102337 this applied to LE mode also
1290 p_desired_datetrack_mode = hr_api.g_update) then
1291 p_datetrack_allow := hr_api.g_update_override;
1292 --Bug 4431511 Added this check to ensure update_override is passed as
1293 --effective datetrack mode if the desired date track mode is
1294 --delete next change in case of unrestricted enrollments
1295 elsif (l_dt_delete_next_change and p_ler_typ_cd = 'SCHEDDU' and
1296 p_desired_datetrack_mode = hr_api.g_delete_next_change) then
1297 p_datetrack_allow := hr_api.g_update_override;
1298 elsif (l_dt_delete and p_ler_typ_cd = 'SCHEDDU' and
1299 p_desired_datetrack_mode = hr_api.g_delete) then
1300 p_datetrack_allow := hr_api.g_update_override;
1301 --End Bug 4431511
1302 elsif (l_dt_correction) then
1303 p_datetrack_allow := hr_api.g_correction;
1304 else
1305 rpt_error(p_proc => l_proc, p_step => l_step);
1306 fnd_message.set_name('BEN', 'BEN_91700_DATETRACK_NOT_ALWD');
1307 fnd_message.set_token('MODE',p_desired_datetrack_mode);
1308 fnd_message.raise_error;
1309 end if;
1310 --
1311 if g_debug then
1312 hr_utility.set_location(' P_datetrack_allow '||P_datetrack_allow ,1234);
1313 end if;
1314 l_step := 30;
1315 --
1316 if g_debug then
1317 hr_utility.set_location ('Leaving '||l_proc,70);
1318 end if;
1319 Exception
1320 when others then
1321 rpt_error(p_proc => l_proc, p_step => l_step);
1322 raise;
1323 end;
1324 --
1325 --
1326 -- Added by pxdas for logging change event needed for extract.
1327 --
1328 -- ----------------------------------------------------------------------------
1329 -- |-------------------------< Change_Exists_In_DB >---------------------------|
1330 -- ----------------------------------------------------------------------------
1331 -- Private Function:
1332 -- This procedure checks whether change already exists in DB.
1333 -- Returns:
1334 -- TRUE - if exists
1335 -- FALSE - otherwise
1336 --
1337 function change_exists_in_db
1338 (p_person_id in number
1339 ,p_chg_evt_cd in varchar2
1340 ,p_chg_eff_dt in date
1341 ,p_pl_id in number
1342 ,p_oipl_id in number
1343 ) return boolean is
1344 --
1345 cursor get_change is
1346 SELECT null
1347 FROM ben_ext_chg_evt_log a
1348 WHERE a.person_id = p_person_id
1349 AND a.chg_evt_cd = p_chg_evt_cd
1350 AND a.prmtr_01 = to_char(p_pl_id)
1351 AND a.prmtr_02 = to_char(p_oipl_id)
1352 AND trunc(a.chg_eff_dt) = trunc(p_chg_eff_dt);
1353 --
1354 l_proc varchar2(80) ; -- := g_package || '.change_exists_in_db';
1355 l_dummy varchar2(30);
1356 l_return boolean;
1357 --
1358 begin
1359 --
1360 if g_debug then
1361 l_proc := g_package || '.change_exists_in_db';
1362 hr_utility.set_location ('Entering '||l_proc,10);
1363 end if;
1364 --
1365 open get_change;
1366 fetch get_change into l_dummy;
1367 --
1368 if get_change%found then
1369 l_return := TRUE;
1370 else
1371 l_return := FALSE;
1372 end if;
1373 --
1374 close get_change;
1375 --
1376 return (l_return);
1377 --
1378 if g_debug then
1379 hr_utility.set_location ('Leaving '||l_proc,70);
1380 end if;
1381 --
1382 end change_exists_in_db;
1383 --
1384 -- ----------------------------------------------------------------------------
1385 -- |---------------------------< create_enrollment >--------------------------|
1386 -- ----------------------------------------------------------------------------
1387 --
1388 procedure create_enrollment
1389 (p_validate in boolean default false
1390 ,p_prtt_enrt_rslt_id out nocopy number
1391 ,p_effective_start_date out nocopy date
1392 ,p_effective_end_date out nocopy date
1393 ,p_business_group_id in number default null
1394 ,p_oipl_id in number default null
1395 ,p_person_id in number default null
1396 ,p_assignment_id in number default null
1397 ,p_pgm_id in number default null
1398 ,p_pl_id in number default null
1399 ,p_rplcs_sspndd_rslt_id in number default null
1400 ,p_ptip_id in number default null
1401 ,p_pl_typ_id in number default null
1402 ,p_ler_id in number default null
1403 ,p_sspndd_flag in varchar2 default 'N'
1404 ,p_called_from_sspnd in varchar2 default 'N'
1405 ,p_prtt_is_cvrd_flag in varchar2 default 'N'
1406 ,p_bnft_amt in number default null
1407 ,p_uom in varchar2 default null
1408 ,p_orgnl_enrt_dt in date default null
1409 ,p_enrt_mthd_cd in varchar2 default null
1410 ,p_enrt_ovridn_flag in varchar2 default 'N'
1411 ,p_enrt_ovrid_rsn_cd in varchar2 default null
1412 ,p_erlst_deenrt_dt in date default null
1413 ,p_enrt_cvg_strt_dt in date default null
1414 ,p_enrt_cvg_thru_dt in date default hr_api.g_eot
1415 ,p_enrt_ovrid_thru_dt in date default null
1416 ,p_pl_ordr_num in number default null
1417 ,p_plip_ordr_num in number default null
1418 ,p_ptip_ordr_num in number default null
1419 ,p_oipl_ordr_num in number default null
1420 ,p_pen_attribute_category in varchar2 default null
1421 ,p_pen_attribute1 in varchar2 default null
1422 ,p_pen_attribute2 in varchar2 default null
1423 ,p_pen_attribute3 in varchar2 default null
1424 ,p_pen_attribute4 in varchar2 default null
1425 ,p_pen_attribute5 in varchar2 default null
1426 ,p_pen_attribute6 in varchar2 default null
1427 ,p_pen_attribute7 in varchar2 default null
1428 ,p_pen_attribute8 in varchar2 default null
1429 ,p_pen_attribute9 in varchar2 default null
1430 ,p_pen_attribute10 in varchar2 default null
1431 ,p_pen_attribute11 in varchar2 default null
1432 ,p_pen_attribute12 in varchar2 default null
1433 ,p_pen_attribute13 in varchar2 default null
1434 ,p_pen_attribute14 in varchar2 default null
1435 ,p_pen_attribute15 in varchar2 default null
1436 ,p_pen_attribute16 in varchar2 default null
1437 ,p_pen_attribute17 in varchar2 default null
1438 ,p_pen_attribute18 in varchar2 default null
1439 ,p_pen_attribute19 in varchar2 default null
1440 ,p_pen_attribute20 in varchar2 default null
1441 ,p_pen_attribute21 in varchar2 default null
1442 ,p_pen_attribute22 in varchar2 default null
1443 ,p_pen_attribute23 in varchar2 default null
1444 ,p_pen_attribute24 in varchar2 default null
1445 ,p_pen_attribute25 in varchar2 default null
1446 ,p_pen_attribute26 in varchar2 default null
1447 ,p_pen_attribute27 in varchar2 default null
1448 ,p_pen_attribute28 in varchar2 default null
1449 ,p_pen_attribute29 in varchar2 default null
1450 ,p_pen_attribute30 in varchar2 default null
1451 ,p_request_id in number default null
1452 ,p_program_application_id in number default null
1453 ,p_program_id in number default null
1454 ,p_program_update_date in date default null
1455 ,p_object_version_number out nocopy number
1456 ,p_per_in_ler_id in number default null
1457 ,p_bnft_typ_cd in varchar2 default null
1458 ,p_bnft_ordr_num in number default null
1459 ,p_prtt_enrt_rslt_stat_cd in varchar2 default null
1460 ,p_bnft_nnmntry_uom in varchar2 default null
1461 ,p_comp_lvl_cd in varchar2 default null
1462 ,p_effective_date in date
1463 ,p_multi_row_validate in boolean default TRUE
1464 ,p_elig_per_elctbl_chc_id in number
1465 ,p_prtt_enrt_rslt_id_o in number
1466 ,p_suspend_flag out nocopy varchar2
1467 ,p_prtt_enrt_interim_id out nocopy number
1468 ,p_datetrack_mode in varchar2
1469 ,p_dpnt_actn_warning out nocopy boolean
1470 ,p_bnf_actn_warning out nocopy boolean
1471 ,p_ctfn_actn_warning out nocopy boolean
1472 ,p_enrt_bnft_id in number default NULL
1473 ,p_source in varchar2 default null
1474 ) is
1475 --
1476 -- Declare cursors and local variables
1477 --
1478 l_chg_evt_cd hr_lookups.lookup_code%type;
1479 l_prtt_enrt_rslt_id ben_prtt_enrt_rslt_f.prtt_enrt_rslt_id%TYPE;
1480 l_effective_start_date ben_prtt_enrt_rslt_f.effective_start_date%TYPE;
1481 l_effective_end_date ben_prtt_enrt_rslt_f.effective_end_date%TYPE;
1482 l_effective_date date;
1483 l_proc varchar2(72); -- := g_package||'create_enrollment';
1484 l_object_version_number ben_prtt_enrt_rslt_f.object_version_number%TYPE;
1485 l_return_to_exist_cvg_flag varchar2(30) := 'N';
1486 l_datetrack_mode varchar2(30);
1487 l_step integer;
1488 l_crntly_enrd_flag varchar2(30) := 'N';
1489 l_post_rslt_flag varchar2(30) := 'Y';
1490 l_prtt_prem_id number;
1491 l_exists varchar2(1);
1492 l_create varchar2(1) := 'N';
1493 l_update varchar2(1) := 'N';
1494 l_dummy varchar2(1);
1495 --
1496 /* Start of Changes for WWBUG: 1646442 : added declarations */
1497 l_ppe_datetrack_mode varchar2(30);
1498 l_ppe_dt_to_use date;
1499 lb_correction boolean;
1500 lb_update boolean;
1501 lb_update_override boolean;
1502 lb_update_change_insert boolean;
1503 l_enrt_cvg_strt_dt date;
1504 l_enrt_cvg_strt_dt_cd varchar2(30);
1505 l_enrt_cvg_strt_dt_rl number;
1506 l_rt_strt_dt date;
1507 l_rt_strt_dt_cd varchar2(30);
1508 l_rt_strt_dt_rl number;
1509 l_enrt_cvg_end_dt date;
1510 l_enrt_cvg_end_dt_cd varchar2(30);
1511 l_enrt_cvg_end_dt_rl number;
1512 l_rt_end_dt date;
1513 l_rt_end_dt_cd varchar2(30);
1514 l_rt_end_dt_rl number;
1515 /* End of Changes for WWBUG: 1646442 : added declarations */
1516 --
1517 l_global_epe_rec ben_global_enrt.g_global_epe_rec_type;
1518 l_global_pen_rec ben_prtt_enrt_rslt_f%rowtype;
1519 l_pl_rec ben_cobj_cache.g_pl_inst_row;
1520 l_pgm_rec ben_cobj_cache.g_pgm_inst_row;
1521 l_oipl_rec ben_cobj_cache.g_oipl_inst_row;
1522 --
1523 cursor c_ptip_enrollment_info is
1524 select pen.prtt_enrt_rslt_id,
1525 pen.pl_id,
1526 pen.oipl_id,
1527 pen.pl_typ_id
1528 from ben_prtt_enrt_rslt_f pen
1529 where pen.person_id=p_person_id and
1530 pen.business_group_id =p_business_group_id and
1531 pen.prtt_enrt_rslt_stat_cd is null and
1532 pen.sspndd_flag='N' and
1533 pen.prtt_enrt_rslt_id <> l_prtt_enrt_rslt_id and
1534 pen.effective_end_date = hr_api.g_eot and
1535 p_enrt_cvg_strt_dt-1 <=
1536 pen.enrt_cvg_thru_dt and
1537 pen.enrt_cvg_strt_dt < pen.effective_end_date and
1538 p_ptip_id=pen.ptip_id;
1539
1540 l_ptip_enrt c_ptip_enrollment_info%rowtype;
1541
1542 cursor c_pen (l_prtt_enrt_rslt_id number) is
1543 select prtt_enrt_rslt_id
1544 ,effective_start_date
1545 ,enrt_cvg_strt_dt
1546 ,enrt_cvg_thru_dt
1547 ,pgm_id
1548 ,ptip_id
1549 ,pl_typ_id
1550 ,pl_id
1551 ,oipl_id
1552 ,object_version_number
1553 from ben_prtt_enrt_rslt_f
1554 where prtt_enrt_rslt_id = l_prtt_enrt_rslt_id
1555 and p_effective_date between
1556 effective_start_date and effective_end_date;
1557 --
1558 l_pen_o c_pen%rowtype;
1559 --
1560 cursor c_prem is
1561 select ecr.val,
1562 ecr.uom,
1563 ecr.actl_prem_id,
1564 pil.lf_evt_ocrd_dt,
1565 pil.ler_id
1566 from ben_enrt_prem ecr,
1567 ben_per_in_ler pil,
1568 ben_elig_per_elctbl_chc epe
1569 where ecr.elig_per_elctbl_chc_id = p_elig_per_elctbl_chc_id
1570 and epe.elig_per_elctbl_chc_id = ecr.elig_per_elctbl_chc_id
1571 and pil.per_in_ler_id = epe.per_in_ler_id
1572 and pil.per_in_ler_stat_cd = 'STRTD'
1573 and NVL(ecr.enrt_bnft_id, -1) = NVL(p_enrt_bnft_id, -1); -- 3573173. Added this condition.
1574 -- and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT');
1575 --
1576 l_prem c_prem%rowtype;
1577 --
1578 -- Commented out the join to per-in-ler for performance. I belive that
1579 -- any result we are processing could not be attached to a backed out
1580 -- life event. lamc 4/5/00.
1581 --
1582 -- Bug#1646442: replaced following cursor:
1583 --
1584 /*********************** START OF CODE PRIOR TO WWBUG:1646442 ********
1585 cursor c_ppe (p_prtt_enrt_rslt_id in number,
1586 p_actl_prem_id in number) is
1587 select ppe.prtt_prem_id,
1588 ppe.std_prem_uom,
1589 ppe.std_prem_val,
1590 ppe.actl_prem_id,
1591 ppe.object_version_number
1592 from ben_prtt_prem_f ppe
1593 -- ben_per_in_ler pil
1594 where ppe.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
1595 and ppe.actl_prem_id = p_actl_prem_id
1596 and p_effective_date between
1597 ppe.effective_start_date and ppe.effective_end_date;
1598 -- and pil.per_in_ler_id=ppe.per_in_ler_id
1599 -- and pil.business_group_id=ppe.business_group_id
1600 -- and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT')
1601 ***************************END OF CODE PRIOR TO WWBUG:1646442 ************/
1602 /* Start of Changes for WWBUG: 1646442 */
1603 cursor c_ppe (p_prtt_enrt_rslt_id in number,
1604 p_actl_prem_id in number,
1605 p_ppe_dt_to_use in date) is
1606 select ppe.prtt_prem_id,
1607 ppe.std_prem_uom,
1608 ppe.std_prem_val,
1609 ppe.actl_prem_id,
1610 ppe.object_version_number
1611 from ben_prtt_prem_f ppe
1612 where ppe.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
1613 and ppe.actl_prem_id = p_actl_prem_id
1614 and /*p_effective_date*/ p_ppe_dt_to_use between
1615 ppe.effective_start_date and ppe.effective_end_date;
1616 /* End of Changes for WWBUG: 1646442 */
1617 --
1618 l_ppe c_ppe%rowtype;
1619 --
1620 cursor c_check_cvrd_in_plan is
1621 select null
1622 from ben_elig_cvrd_dpnt_f pdp
1623 ,ben_prtt_enrt_rslt_f pen
1624 ,ben_pgm_f pgm
1625 where pdp.dpnt_person_id = p_person_id
1626 and pdp.business_group_id = p_business_group_id
1627 and p_effective_date
1628 between pdp.effective_start_date and pdp.effective_end_date
1629 and pdp.prtt_enrt_rslt_id = pen.prtt_enrt_rslt_id
1630 --and pen.prtt_enrt_rslt_stat_cd not in ('BCKDT', 'VOIDD')
1631 and pen.prtt_enrt_rslt_stat_cd is null
1632 and pdp.cvg_thru_dt = hr_api.g_eot
1633 and pen.pgm_id = p_pgm_id
1634 and pen.pgm_id = pgm.pgm_id
1635 and pen.prtt_enrt_rslt_stat_cd is null
1636 and pgm.pgm_typ_cd like 'COBRA%'
1637 and p_effective_date between
1638 pen.effective_start_date and pen.effective_end_date
1639 and pen.pl_id = p_pl_id
1640 and pen.business_group_id = pdp.business_group_id
1641 and p_effective_date between
1642 pen.effective_start_date and pen.effective_end_date
1643 and pgm.business_group_id = pen.business_group_id
1644 and p_effective_date between
1645 pgm.effective_start_date and pgm.effective_end_date;
1646 --
1647 /* Start of Changes for Bug: 1646442: added cursor */
1648 cursor c_pel (p_elig_pe_elctbl_chc_id number) is
1649 select pel.enrt_perd_id,pel.lee_rsn_id
1650 from ben_pil_elctbl_chc_popl pel
1651 ,ben_elig_per_elctbl_chc epe
1652 where pel.pil_elctbl_chc_popl_id = epe.pil_elctbl_chc_popl_id
1653 and epe.elig_per_elctbl_chc_id = p_elig_pe_elctbl_chc_id;
1654 --
1655 -- Bug : 3866580
1656 cursor c_pl_typ_opt_typ_cd (pl_typ_id number, p_effective_date date) is
1657 select ptp.opt_typ_cd
1658 from ben_pl_typ_f ptp
1659 where ptp.pl_typ_id = p_pl_typ_id
1660 and p_effective_date between ptp.effective_start_date
1661 and ptp.effective_end_date;
1662
1663 l_pl_typ_opt_typ_cd ben_pl_typ.opt_typ_cd%type;
1664 -- Bug : 3866580
1665 --
1666 l_pel c_pel%rowtype;
1667 /* End of Changes for Bug: 1646442: added cursor */
1668 l_process_dpnt boolean := false;
1669 l_process_bnf boolean := false;
1670 --
1671 begin
1672 --
1673 g_debug := hr_utility.debug_enabled;
1674 if g_debug then
1675 l_proc := g_package||'create_enrollment';
1676 hr_utility.set_location('Entering:'|| l_proc, 10);
1677 end if;
1678 g_multi_rows_validate := p_multi_row_validate;
1679 l_step := 10;
1680 If (p_multi_row_validate) then
1681 l_post_rslt_flag := 'Y';
1682 Else
1683 l_post_rslt_flag := 'N';
1684 End if;
1685 --
1686 -- Ensure elctbl_chc_id is not NULL.
1687 --
1688 hr_api.mandatory_arg_error
1689 (p_api_name => l_proc
1690 ,p_argument => 'elig_per_elctbl_chc_id'
1691 ,p_argument_value => p_elig_per_elctbl_chc_id
1692 );
1693 --
1694 -- Issue a savepoint if operating in validation only mode
1695 --
1696 if p_called_from_sspnd = 'N' then
1697 savepoint create_enrollment;
1698 else
1699 savepoint create_enrollment_sspnd;
1700 end if;
1701 --
1702 l_step := 15;
1703 --
1704 l_crntly_enrd_flag := 'N';
1705 if g_debug then
1706 hr_utility.set_location(l_proc, 20);
1707 end if;
1708 l_step := 20;
1709 --
1710 -- Get choice data from prtt_per_elctbl_chc table
1711 --
1712 ben_global_enrt.get_epe -- choice
1713 (p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id
1714 ,p_global_epe_rec => l_global_epe_rec);
1715
1716 ben_cobj_cache.get_pl_dets
1717 (p_business_group_id => p_business_group_id
1718 ,p_effective_date => p_effective_date
1719 ,p_pl_id => l_global_epe_rec.pl_id
1720 ,p_inst_row => l_pl_rec);
1721
1722 if l_global_epe_rec.oipl_id is not null then
1723 ben_cobj_cache.get_oipl_dets
1724 (p_business_group_id => p_business_group_id
1725 ,p_effective_date => p_effective_date
1726 ,p_oipl_id => l_global_epe_rec.oipl_id
1727 ,p_inst_row => l_oipl_rec);
1728 end if;
1729
1730 l_step:=25;
1731 --
1732 -- Check if person is also a covered dependent in the plan.
1733 -- This is a COBRA edit. For example,if the person is covered under
1734 -- employee + family, he/she cannot separate coverage.
1735 --
1736 if p_pgm_id is not null then
1737 open c_check_cvrd_in_plan;
1738 fetch c_check_cvrd_in_plan into l_exists;
1739 if c_check_cvrd_in_plan%found then
1740 close c_check_cvrd_in_plan;
1741 fnd_message.set_name('BEN','BEN_92243_CVRD_IN_PLAN');
1742 fnd_message.raise_error;
1743 end if;
1744 close c_check_cvrd_in_plan;
1745 end if;
1746 --
1747 l_step := 30;
1748 --
1749 if (l_global_epe_rec.prtt_enrt_rslt_id is not NULL) then
1750 ben_global_enrt.get_pen -- result
1751 (p_prtt_enrt_rslt_id => l_global_epe_rec.prtt_enrt_rslt_id
1752 ,p_effective_date => p_effective_date
1753 ,p_global_pen_rec => l_global_pen_rec);
1754 else
1755 ben_global_enrt.clear_pen -- result
1756 (p_global_pen_rec => l_global_pen_rec);
1757 end if;
1758 l_step := 40;
1759 --
1760 -- commented out to allow for creation of a new result
1761 -- when the benefit amount changes (in benelinf). It looks
1762 -- like benelinf is the only process which calls create_enrt
1763 -- so... would like it to only do a create and copy the child
1764 -- stuff over if a p_prtt_enrt_rslt_id is passed in.
1765 -- jcarpent 7/28/1999
1766 -- lamc removed commented code 4/5/00
1767 l_step := 80;
1768 if (p_prtt_enrt_rslt_id_o is not NULL) then
1769 open c_pen(p_prtt_enrt_rslt_id_o);
1770 fetch c_pen into l_pen_o;
1771 if c_pen%notfound then
1772 l_step := 90;
1773 close c_pen;
1774 rpt_error(p_proc => l_proc, p_step => l_step);
1775 fnd_message.set_name('BEN','BEN_91711_ENRT_RSLT_NOT_FND');
1776 fnd_message.set_token('PROC',l_proc);
1777 fnd_message.set_token('ID', to_char(p_prtt_enrt_rslt_id_o));
1778 fnd_message.set_token('PERSON_ID', to_char(p_person_id));
1779 fnd_message.set_token('LER_ID', to_char(p_ler_id));
1780 fnd_message.set_token('EFFECTIVE_DATE',to_char(p_effective_date));
1781 fnd_message.raise_error;
1782 else
1783 close c_pen;
1784 if (p_datetrack_mode = hr_api.g_correction) then
1785 l_effective_date := l_pen_o.effective_start_date;
1786 else
1787 l_effective_date := p_effective_date;
1788 end if;
1789 end if;
1790 else
1791 l_pen_o := NULL;
1792 l_effective_date := p_effective_date;
1793 end if;
1794 l_step := 100;
1795 create_PRTT_ENRT_RESULT
1796 (p_validate => FALSE
1797 ,p_prtt_enrt_rslt_id => l_prtt_enrt_rslt_id
1798 ,p_effective_start_date => l_effective_start_date
1799 ,p_effective_end_date => l_effective_end_date
1800 ,p_business_group_id => p_business_group_id
1801 ,p_oipl_id => p_oipl_id
1802 ,p_person_id => p_person_id
1803 ,p_assignment_id => p_assignment_id
1804 ,p_pgm_id => p_pgm_id
1805 ,p_pl_id => p_pl_id
1806 ,p_rplcs_sspndd_rslt_id => p_rplcs_sspndd_rslt_id
1807 ,p_ptip_id => p_ptip_id
1808 ,p_pl_typ_id => p_pl_typ_id
1809 ,p_ler_id => p_ler_id
1810 ,p_sspndd_flag => p_sspndd_flag
1811 ,p_prtt_is_cvrd_flag => p_prtt_is_cvrd_flag
1812 ,p_bnft_amt => p_bnft_amt
1813 ,p_uom => p_uom
1814 ,p_orgnl_enrt_dt => p_orgnl_enrt_dt
1815 ,p_enrt_mthd_cd => p_enrt_mthd_cd
1816 ,p_enrt_ovridn_flag => p_enrt_ovridn_flag
1817 ,p_enrt_ovrid_rsn_cd => p_enrt_ovrid_rsn_cd
1818 ,p_erlst_deenrt_dt => p_erlst_deenrt_dt
1819 ,p_enrt_cvg_strt_dt => p_enrt_cvg_strt_dt
1820 ,p_enrt_cvg_thru_dt => p_enrt_cvg_thru_dt
1821 ,p_enrt_ovrid_thru_dt => p_enrt_ovrid_thru_dt
1822 ,p_pl_ordr_num => p_pl_ordr_num
1823 ,p_plip_ordr_num => p_plip_ordr_num
1824 ,p_ptip_ordr_num => p_ptip_ordr_num
1825 ,p_oipl_ordr_num => p_oipl_ordr_num
1826 ,p_pen_attribute_category => p_pen_attribute_category
1827 ,p_pen_attribute1 => p_pen_attribute1
1828 ,p_pen_attribute2 => p_pen_attribute2
1829 ,p_pen_attribute3 => p_pen_attribute3
1830 ,p_pen_attribute4 => p_pen_attribute4
1831 ,p_pen_attribute5 => p_pen_attribute5
1832 ,p_pen_attribute6 => p_pen_attribute6
1833 ,p_pen_attribute7 => p_pen_attribute7
1834 ,p_pen_attribute8 => p_pen_attribute8
1835 ,p_pen_attribute9 => p_pen_attribute9
1836 ,p_pen_attribute10 => p_pen_attribute10
1837 ,p_pen_attribute11 => p_pen_attribute11
1838 ,p_pen_attribute12 => p_pen_attribute12
1839 ,p_pen_attribute13 => p_pen_attribute13
1840 ,p_pen_attribute14 => p_pen_attribute14
1841 ,p_pen_attribute15 => p_pen_attribute15
1842 ,p_pen_attribute16 => p_pen_attribute16
1843 ,p_pen_attribute17 => p_pen_attribute17
1844 ,p_pen_attribute18 => p_pen_attribute18
1845 ,p_pen_attribute19 => p_pen_attribute19
1846 ,p_pen_attribute20 => p_pen_attribute20
1847 ,p_pen_attribute21 => p_pen_attribute21
1848 ,p_pen_attribute22 => p_pen_attribute22
1849 ,p_pen_attribute23 => p_pen_attribute23
1850 ,p_pen_attribute24 => p_pen_attribute24
1851 ,p_pen_attribute25 => p_pen_attribute25
1852 ,p_pen_attribute26 => p_pen_attribute26
1853 ,p_pen_attribute27 => p_pen_attribute27
1854 ,p_pen_attribute28 => p_pen_attribute28
1855 ,p_pen_attribute29 => p_pen_attribute29
1856 ,p_pen_attribute30 => p_pen_attribute30
1857 ,p_request_id => fnd_global.conc_request_id
1858 ,p_program_application_id => fnd_global.prog_appl_id
1859 ,p_program_id => fnd_global.conc_program_id
1860 ,p_program_update_date => sysdate
1861 ,p_object_version_number => l_object_version_number
1862 ,p_per_in_ler_id => p_per_in_ler_id
1863 ,p_bnft_typ_cd => p_bnft_typ_cd
1864 ,p_bnft_ordr_num => p_bnft_ordr_num
1865 ,p_prtt_enrt_rslt_stat_cd => p_prtt_enrt_rslt_stat_cd
1866 ,p_bnft_nnmntry_uom => p_bnft_nnmntry_uom
1867 ,p_comp_lvl_cd => p_comp_lvl_cd
1868 ,p_effective_date => l_effective_date
1869 ,p_multi_row_validate => p_multi_row_validate
1870 );
1871
1872 l_create := 'Y';
1873
1874 ben_global_enrt.reload_pen -- result globals loaded after insert.
1875 (p_prtt_enrt_rslt_id => l_prtt_enrt_rslt_id
1876 ,p_effective_date => p_effective_date
1877 ,p_global_pen_rec => l_global_pen_rec);
1878
1879 --
1880 l_step := 105;
1881 -- if the result will be voided in the rhi or the rslt is being
1882 -- inserted as 'backed out', do not update choice fk.
1883 -- This call needs to be before the update to premiums because it
1884 -- assumes the chc was already updated with the rslt id.
1885 if p_enrt_cvg_strt_dt > nvl(p_enrt_cvg_thru_dt,p_enrt_cvg_strt_dt)
1886 or p_prtt_enrt_rslt_stat_cd = 'BCKDT' then
1887 null;
1888 else
1889 l_step := 110;
1890 ben_ELIG_PER_ELC_CHC_api.update_ELIG_PER_ELC_CHC
1891 (p_validate => FALSE
1892 ,p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id
1893 ,p_prtt_enrt_rslt_id => l_prtt_enrt_rslt_id
1894 ,p_object_version_number =>
1895 l_global_epe_rec.object_version_number
1896 ,p_effective_date => p_effective_date
1897 ,p_request_id => fnd_global.conc_request_id
1898 ,p_program_application_id => fnd_global.prog_appl_id
1899 ,p_program_id => fnd_global.conc_program_id
1900 ,p_program_update_date => sysdate
1901 );
1902
1903 ben_global_enrt.reload_epe -- chc globals re-loaded after update.
1904 (p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id
1905 ,p_global_epe_rec => l_global_epe_rec);
1906
1907 end if;
1908
1909 l_step := 115;
1910
1911 if (l_update = 'Y' or l_create = 'Y') then
1912 --
1913 for l_prem in c_prem loop
1914 --
1915 l_step := 120;
1916 -- bug 1587837. jcarpent reset l_ppe.prtt_prem_id
1917 l_ppe.prtt_prem_id:=null;
1918 --
1919 /* Start of Changes for WWBUG: 1646442: added */
1920 open c_pel(p_elig_per_elctbl_chc_id);
1921 fetch c_pel into l_pel;
1922 close c_pel;
1923
1924 ben_determine_date.rate_and_coverage_dates
1925 (p_which_dates_cd => 'R'
1926 ,p_date_mandatory_flag => 'Y'
1927 ,p_compute_dates_flag => 'Y'
1928 ,p_business_group_id => p_business_group_id
1929 ,P_PER_IN_LER_ID => p_per_in_ler_id
1930 ,P_PERSON_ID => p_person_id
1931 ,P_PGM_ID => p_pgm_id
1932 ,P_PL_ID => p_pl_id
1933 ,P_OIPL_ID => p_oipl_id
1934 ,P_LEE_RSN_ID => l_pel.lee_rsn_id
1935 ,P_ENRT_PERD_ID => l_pel.enrt_perd_id
1936 ,p_enrt_cvg_strt_dt => l_enrt_cvg_strt_dt --out
1937 ,p_enrt_cvg_strt_dt_cd => l_enrt_cvg_strt_dt_cd --out
1938 ,p_enrt_cvg_strt_dt_rl => l_enrt_cvg_strt_dt_rl --out
1939 ,p_rt_strt_dt => l_rt_strt_dt --out
1940 ,p_rt_strt_dt_cd => l_rt_strt_dt_cd --out
1941 ,p_rt_strt_dt_rl => l_rt_strt_dt_rl --out
1942 ,p_enrt_cvg_end_dt => l_enrt_cvg_end_dt --out
1943 ,p_enrt_cvg_end_dt_cd => l_enrt_cvg_end_dt_cd --out
1944 ,p_enrt_cvg_end_dt_rl => l_enrt_cvg_end_dt_rl --out
1945 ,p_rt_end_dt => l_rt_end_dt --out
1946 ,p_rt_end_dt_cd => l_rt_end_dt_cd --out
1947 ,p_rt_end_dt_rl => l_rt_end_dt_rl --out
1948 ,p_effective_date => p_effective_date
1949 ,p_lf_evt_ocrd_dt => nvl(l_prem.lf_evt_ocrd_dt,p_effective_date)
1950 );
1951
1952 l_ppe_dt_to_use := greatest(p_enrt_cvg_strt_dt,l_rt_strt_dt);
1953 hr_utility.set_location( 'cvg start dt ' || p_enrt_cvg_strt_dt, 99 ) ;
1954 hr_utility.set_location( 'l_ppe_dt_to_use ' || l_ppe_dt_to_use, 99 ) ;
1955
1956 /* End of Changes for WWBUG: 1646442: addition */
1957 --
1958 /*
1959 CODE PRIOR TO WWBUG: 1646442
1960 open c_ppe(l_prtt_enrt_rslt_id, l_prem.actl_prem_id);
1961 */
1962 /* Start of Changes for WWBUG: 1646442 */
1963 open c_ppe(l_prtt_enrt_rslt_id, l_prem.actl_prem_id,l_ppe_dt_to_use);
1964 /* End of Changes for WWBUG: 1646442 */
1965 fetch c_ppe into l_ppe;
1966 close c_ppe;
1967 --
1968 l_step := 125;
1969 if l_ppe.prtt_prem_id is not null and l_update = 'Y' then
1970 -- Because the benefit amount could have changed, and the premiums
1971 -- can be based on the benefit amount, re-calc it. It does a recalc
1972 -- if the benefit amount is entered at enrollment.
1973 -- PPE is from prtt-prem. prem is from enrt-prem.
1974 ben_PRTT_PREM_api.recalc_PRTT_PREM
1975 (p_prtt_prem_id => l_ppe.prtt_prem_id
1976 ,p_std_prem_uom => l_prem.uom
1977 ,p_std_prem_val => l_prem.val -- in/out
1978 ,p_actl_prem_id => l_prem.actl_prem_id
1979 ,p_prtt_enrt_rslt_id => l_prtt_enrt_rslt_id
1980 ,p_per_in_ler_id => p_per_in_ler_id
1981 ,p_ler_id => l_prem.ler_id
1982 ,p_lf_evt_ocrd_dt => l_prem.lf_evt_ocrd_dt
1983 ,p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id
1984 ,p_enrt_bnft_id => p_enrt_bnft_id
1985 ,p_business_group_id => p_business_group_id
1986 ,p_effective_date => p_effective_date
1987 -- bof FONM
1988 ,p_enrt_cvg_strt_dt => nvl(l_enrt_cvg_strt_dt ,l_ppe_dt_to_use)
1989 ,p_rt_strt_dt => l_rt_strt_dt
1990 -- eof FONM
1991 );
1992 l_step := 127;
1993 --
1994 /* Start of Changes for WWBUG: 1646442: added */
1995 --
1996 -- Find the valid datetrack modes.
1997 --
1998 dt_api.find_dt_upd_modes
1999 (p_effective_date => l_ppe_dt_to_use,
2000 p_base_table_name => 'BEN_PRTT_PREM_F',
2001 p_base_key_column => 'prtt_prem_id',
2002 p_base_key_value => l_ppe.prtt_prem_id,
2003 p_correction => lb_correction,
2004 p_update => lb_update,
2005 p_update_override => lb_update_override,
2006 p_update_change_insert => lb_update_change_insert);
2007
2008 if lb_update_override then
2009 --
2010 l_ppe_datetrack_mode := hr_api.g_update_override;
2011 --
2012 elsif lb_update then
2013 --
2014 l_ppe_datetrack_mode := hr_api.g_update;
2015 --
2016 else
2017 --
2018 l_ppe_datetrack_mode := hr_api.g_correction;
2019 end if;
2020 /* End of Changes for WWBUG: 1646442 */
2021
2022 ben_prtt_prem_api.update_prtt_prem
2023 ( p_validate => FALSE
2024 ,p_prtt_prem_id => l_ppe.prtt_prem_id
2025 ,p_effective_start_date => p_effective_start_date
2026 ,p_effective_end_date => p_effective_end_date
2027 ,p_std_prem_uom => l_prem.uom
2028 ,p_std_prem_val => l_prem.val
2029 ,p_actl_prem_id => l_prem.actl_prem_id
2030 ,p_prtt_enrt_rslt_id => l_prtt_enrt_rslt_id
2031 ,p_per_in_ler_id => p_per_in_ler_id
2032 ,p_business_group_id => p_business_group_id
2033 ,p_object_version_number => l_ppe.object_version_number
2034 ,p_request_id => fnd_global.conc_request_id
2035 ,p_program_application_id => fnd_global.prog_appl_id
2036 ,p_program_id => fnd_global.conc_program_id
2037 ,p_program_update_date => sysdate
2038 /* CODE PRIOR TO WWBUG: 1646442
2039 ,p_effective_date => p_effective_date
2040 ,p_datetrack_mode => l_datetrack_mode
2041 */
2042 /* Start of Changes for WWBUG: 1646442 */
2043 ,p_effective_date => l_ppe_dt_to_use
2044 ,p_datetrack_mode => l_ppe_datetrack_mode
2045 /* End of Changes for WWBUG: 1646442 */
2046 );
2047 --
2048 elsif l_create = 'Y' or l_ppe.prtt_prem_id is null then
2049 -- Because the benefit amount could have changed, and the premiums
2050 -- can be based on the benefit amount, re-calc it. It does a recalc
2051 -- if the benefit amount is entered at enrollment.
2052 -- PPE is from prtt-prem. prem is from enrt-prem.
2053 ben_PRTT_PREM_api.recalc_PRTT_PREM
2054 (p_prtt_prem_id => null
2055 ,p_std_prem_uom => l_prem.uom
2056 ,p_std_prem_val => l_prem.val -- in/out
2057 ,p_actl_prem_id => l_prem.actl_prem_id
2058 ,p_prtt_enrt_rslt_id => l_prtt_enrt_rslt_id
2059 ,p_per_in_ler_id => p_per_in_ler_id
2060 ,p_ler_id => l_prem.ler_id
2061 ,p_lf_evt_ocrd_dt => l_prem.lf_evt_ocrd_dt
2062 ,p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id
2063 ,p_enrt_bnft_id => p_enrt_bnft_id
2064 ,p_business_group_id => p_business_group_id
2065 ,p_effective_date => p_effective_date
2066 -- bof FONM
2067 ,p_enrt_cvg_strt_dt => nvl(l_enrt_cvg_strt_dt,l_ppe_dt_to_use)
2068 ,p_rt_strt_dt => l_rt_strt_dt
2069 -- eof FONM
2070 );
2071 l_step := 130;
2072 ben_prtt_prem_api.create_prtt_prem
2073 ( p_validate => FALSE
2074 ,p_prtt_prem_id => l_prtt_prem_id
2075 ,p_effective_start_date => p_effective_start_date
2076 ,p_effective_end_date => p_effective_end_date
2077 ,p_std_prem_uom => l_prem.uom
2078 ,p_std_prem_val => l_prem.val
2079 ,p_actl_prem_id => l_prem.actl_prem_id
2080 ,p_prtt_enrt_rslt_id => l_prtt_enrt_rslt_id
2081 ,p_per_in_ler_id => p_per_in_ler_id
2082 ,p_business_group_id => p_business_group_id
2083 ,p_object_version_number => l_object_version_number
2084 ,p_request_id => fnd_global.conc_request_id
2085 ,p_program_application_id => fnd_global.prog_appl_id
2086 ,p_program_id => fnd_global.conc_program_id
2087 ,p_program_update_date => sysdate
2088 /*
2089 CODE PRIOR TO WWBUG: 1646442
2090 ,p_effective_date => p_effective_date
2091 */
2092 /* Start of Changes for WWBUG: 1646442 */
2093 ,p_effective_date => l_ppe_dt_to_use
2094 /* End of Changes for WWBUG: 1646442 */
2095 );
2096 --
2097 end if;
2098 --
2099 end loop;
2100 --
2101 end if;
2102 --
2103 l_step := 135;
2104 if p_comp_lvl_cd in ('PLANFC', 'PLANIMP') then
2105 null;
2106 else
2107 if l_global_epe_rec.pgm_id is not null then
2108 ben_provider_pools.accumulate_pools
2109 (p_validate => FALSE
2110 ,p_person_id => p_person_id
2111 ,p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id
2112 ,p_business_group_id => p_business_group_id
2113 ,p_enrt_mthd_cd => p_enrt_mthd_cd
2114 ,p_effective_date => p_effective_date);
2115 end if;
2116 end if;
2117 l_step := 140;
2118 if (l_global_epe_rec.prtt_enrt_rslt_id is not NULL
2119 and l_crntly_enrd_flag = 'Y') then
2120 l_return_to_exist_cvg_flag := 'Y';
2121 else
2122 l_return_to_exist_cvg_flag := 'N';
2123 end if;
2124 --
2125 -- write to change log, except for when called by benelinf where
2126 -- the change log is written directly from there.
2127 --
2128 l_step := 145;
2129 if p_source is null or
2130 p_source <> 'benelinf' then
2131 ben_ext_chlg.log_benefit_chg
2132 (p_action => 'CREATE'
2133 ,p_pl_id => p_pl_id
2134 ,p_oipl_id => p_oipl_id
2135 ,p_enrt_cvg_strt_dt => p_enrt_cvg_strt_dt
2136 ,p_enrt_cvg_end_dt => p_enrt_cvg_thru_dt
2137 ,p_prtt_enrt_rslt_id => l_prtt_enrt_rslt_id
2138 ,p_per_in_ler_id => p_per_in_ler_id
2139 ,p_person_id => p_person_id
2140 ,p_business_group_id => p_business_group_id
2141 ,p_effective_date => l_effective_date
2142 );
2143 end if;
2144 --
2145 --
2146 -- If there was enrollment terminated before this new choice elected,
2147 -- then the dependents for old enrollment can be re-used, or user select
2148 -- the currently coveraged enrollment as his/her election, then use old
2149 -- dependent information as well.
2150 --
2151 l_step := 150;
2152 if g_debug then
2153 hr_utility.set_location('p_prtt_enrt_rslt_id_o'||
2154 to_char(p_prtt_enrt_rslt_id_o)||' l_epe.prtt_enrt_rslt_id'||
2155 to_char(l_global_epe_rec.prtt_enrt_rslt_id),150);
2156 hr_utility.set_location(
2157 ' flag'||l_global_epe_rec.crntly_enrd_flag, 150);
2158 end if;
2159
2160 if (p_prtt_enrt_rslt_id_o is not NULL
2161 or (l_global_epe_rec.prtt_enrt_rslt_id is not NULL
2162 and nvl(l_global_epe_rec.crntly_enrd_flag, 'X') = 'Y') ) then
2163 l_step := 155;
2164 if l_global_epe_rec.alws_dpnt_dsgn_flag = 'Y' then
2165 l_process_dpnt := true;
2166 else
2167 l_process_dpnt := false;
2168 if l_global_epe_rec.pgm_id is not null then
2169 ben_cobj_cache.get_pgm_dets
2170 (p_business_group_id => p_business_group_id
2171 ,p_effective_date => p_effective_date
2172 ,p_pgm_id => l_global_epe_rec.pgm_id
2173 ,p_inst_row => l_pgm_rec);
2174 hr_utility.set_location('process dptn level ' ||l_pgm_rec.dpnt_dsgn_lvl_cd , 150);
2175 if l_pgm_rec.dpnt_dsgn_lvl_cd='PTIP' then
2176 open c_ptip_enrollment_info;
2177 fetch c_ptip_enrollment_info into l_ptip_enrt;
2178 if c_ptip_enrollment_info%found then
2179 l_process_dpnt:= true;
2180 hr_utility.set_location('process dptn true ', 150);
2181 end if ;
2182 end if ;
2183 end if ;
2184 end if;
2185 if l_pl_rec.bnf_dsgn_cd is not null then
2186 l_process_bnf := true;
2187 else
2188 l_process_bnf := false;
2189 end if;
2190 ben_mng_dpnt_bnf.recycle_dpnt_bnf
2191 (p_validate => FALSE
2192 ,p_new_prtt_enrt_rslt_id => l_prtt_enrt_rslt_id
2193 ,p_old_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id_o
2194 ,P_NEW_ENRT_RSLT_OVN => l_object_version_number
2195 ,p_new_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id
2196 ,p_person_id => p_person_id
2197 ,p_return_to_exist_cvg_flag => l_return_to_exist_cvg_flag
2198 ,p_old_pl_id => l_pen_o.pl_id
2199 ,p_new_pl_id => p_pl_id
2200 ,p_old_oipl_id => l_pen_o.oipl_id
2201 ,p_new_oipl_id => p_oipl_id
2202 ,p_old_pl_typ_id => l_pen_o.pl_typ_id
2203 ,p_new_pl_typ_id => p_pl_typ_id
2204 ,p_pgm_id => p_pgm_id
2205 ,p_ler_id => p_ler_id
2206 ,p_per_in_ler_id => p_per_in_ler_id
2207 ,p_dpnt_cvg_strt_dt_cd => l_global_epe_rec.dpnt_cvg_strt_dt_cd
2208 ,p_dpnt_cvg_strt_dt_rl => l_global_epe_rec.dpnt_cvg_strt_dt_rl
2209 ,p_business_group_id => p_business_group_id
2210 ,p_ENRT_CVG_STRT_DT => l_global_pen_rec.enrt_cvg_strt_dt
2211 ,p_effective_date => p_effective_date
2212 ,p_datetrack_mode => p_datetrack_mode
2213 ,p_process_dpnt => l_process_dpnt
2214 ,p_process_bnf => l_process_bnf
2215 );
2216 --
2217 -- Copy primary care provider if the plan has not changed but the
2218 -- option in plan has changed.
2219 --
2220 l_step := 160;
2221 If (l_pen_o.pl_id = p_pl_id and l_pen_o.oipl_id <> p_oipl_id) then
2222 ben_mng_prmry_care_prvdr.recycle_ppr
2223 (P_VALIDATE => FALSE
2224 ,P_NEW_PRTT_ENRT_RSLT_ID => l_prtt_enrt_rslt_id
2225 ,P_OLD_PRTT_ENRT_RSLT_ID => p_prtt_enrt_rslt_id_o
2226 ,P_BUSINESS_GROUP_ID => P_business_group_id
2227 ,P_EFFECTIVE_DATE => p_effective_date
2228 ,P_DATETRACK_MODE => p_datetrack_mode
2229 );
2230 End if;
2231 elsif p_pgm_id is not null
2232 /*and l_global_epe_rec.alws_dpnt_dsgn_flag = 'Y'
2233 if previously enrolled then carry forward even if the flaf is 'N' */
2234 then
2235 --
2236 -- no old result passed in or not reenrolling in same choice
2237 -- different coverage, sooo..
2238 -- handle dependent recycling at ptip level if used to be
2239 -- enrolled in plan type but coverage ended due to eligibility.
2240 --
2241 ben_cobj_cache.get_pgm_dets
2242 (p_business_group_id => p_business_group_id
2243 ,p_effective_date => p_effective_date
2244 ,p_pgm_id => l_global_epe_rec.pgm_id
2245 ,p_inst_row => l_pgm_rec);
2246 if l_pgm_rec.dpnt_dsgn_lvl_cd='PTIP' then
2247 open c_ptip_enrollment_info;
2248 fetch c_ptip_enrollment_info into l_ptip_enrt;
2249 if c_ptip_enrollment_info%found then
2250 ben_mng_dpnt_bnf.recycle_dpnt_bnf
2251 (p_validate => FALSE
2252 ,p_new_prtt_enrt_rslt_id => l_prtt_enrt_rslt_id
2253 ,p_old_prtt_enrt_rslt_id => l_ptip_enrt.prtt_enrt_rslt_id
2254 ,P_NEW_ENRT_RSLT_OVN => l_object_version_number
2255 ,p_new_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id
2256 ,p_person_id => p_person_id
2257 ,p_return_to_exist_cvg_flag => l_return_to_exist_cvg_flag
2258 ,p_old_pl_id => l_ptip_enrt.pl_id
2259 ,p_new_pl_id => p_pl_id
2260 ,p_old_oipl_id => l_ptip_enrt.oipl_id
2261 ,p_new_oipl_id => p_oipl_id
2262 ,p_old_pl_typ_id => l_ptip_enrt.pl_typ_id
2263 ,p_new_pl_typ_id => p_pl_typ_id
2264 ,p_pgm_id => p_pgm_id
2265 ,p_ler_id => p_ler_id
2266 ,p_per_in_ler_id => p_per_in_ler_id
2267 ,p_dpnt_cvg_strt_dt_cd => l_global_epe_rec.dpnt_cvg_strt_dt_cd
2268 ,p_dpnt_cvg_strt_dt_rl => l_global_epe_rec.dpnt_cvg_strt_dt_rl
2269 ,p_business_group_id => p_business_group_id
2270 ,p_ENRT_CVG_STRT_DT => l_global_pen_rec.enrt_cvg_strt_dt
2271 ,p_effective_date => p_effective_date
2272 ,p_datetrack_mode => p_datetrack_mode
2273 ,p_process_dpnt => true
2274 ,p_process_bnf => false
2275 );
2276 close c_ptip_enrollment_info;
2277 end if;
2278 end if;
2279 end if;
2280 --
2281 -- If new choice is not currently coverage, call action_item RCO to
2282 -- determine any action need to be taken.
2283 --
2284 -- Bug 3866580
2285 --
2286 -- Find out the Option Type of Plan Type of the Plan being enrolled in
2287 /* It is better to go by savings plan flag rather option type code as
2288 the type code is only informational
2289 open c_pl_typ_opt_typ_cd (l_pl_rec.pl_typ_id, p_effective_date);
2290 fetch c_pl_typ_opt_typ_cd into l_pl_typ_opt_typ_cd;
2291 close c_pl_typ_opt_typ_cd;
2292 --
2293 */
2294 if ( l_pl_rec.svgs_pl_flag = 'Y' and p_oipl_id is null and l_pl_rec.ENRT_PL_OPT_FLAG = 'Y' )
2295 or ( l_pl_rec.svgs_pl_flag = 'N')
2296 then
2297 /*
2298 Commented this part as, Enrollment Action Items for all enrollment in "Plans"
2299 as well as "Option In Plans" should be determined except for savings plan. In case
2300 of savings plan, enrollment actions items should be determined only if enrollment is in
2301 plan level (i.e. p_oipl_id = NULL
2302 --
2303 If l_pl_rec.ENRT_PL_OPT_FLAG = 'N'
2304 or (l_pl_rec.ENRT_PL_OPT_FLAG = 'Y'
2305 and p_oipl_id is NULL) then
2306 */
2307 --
2308 l_step := 165;
2309 ben_enrollment_action_items.determine_action_items
2310 (p_prtt_enrt_rslt_id => l_prtt_enrt_rslt_id
2311 ,p_effective_date => p_effective_date
2312 ,p_business_group_id => p_business_group_id
2313 ,p_datetrack_mode => p_datetrack_mode
2314 ,p_suspend_flag => p_suspend_flag
2315 ,p_rslt_object_version_number => l_object_version_number
2316 ,p_enrt_bnft_id => p_enrt_bnft_id
2317 ,p_post_rslt_flag => l_post_rslt_flag
2318 ,p_dpnt_actn_warning => p_dpnt_actn_warning
2319 ,p_bnf_actn_warning => p_bnf_actn_warning
2320 ,p_ctfn_actn_warning => p_ctfn_actn_warning
2321 );
2322 if (l_global_epe_rec.prtt_enrt_rslt_id is not NULL) then
2323 ben_global_enrt.get_pen -- result
2324 (p_prtt_enrt_rslt_id => l_global_epe_rec.prtt_enrt_rslt_id
2325 ,p_effective_date => p_effective_date
2326 ,p_global_pen_rec => l_global_pen_rec);
2327 else
2328 ben_global_enrt.clear_pen -- result
2329 (p_global_pen_rec => l_global_pen_rec);
2330 end if;
2331 --
2332 l_step := 167;
2333 -- if action item's calls update-enrollment, the globals will be
2334 -- reloaded for us.
2335 p_prtt_enrt_interim_id :=
2336 ben_global_enrt.g_global_pen_rec.rplcs_sspndd_rslt_id;
2337 end if;
2338 --
2339 -- When in validation only mode raise the Validate_Enabled exception
2340 --
2341 if p_validate then
2342 raise hr_api.validate_enabled;
2343 end if;
2344 --
2345 -- Set all output arguments
2346 --
2347 p_prtt_enrt_rslt_id := l_prtt_enrt_rslt_id;
2348 p_effective_start_date := l_effective_start_date;
2349 p_effective_end_date := l_effective_end_date;
2350 p_object_version_number := l_object_version_number;
2351 if g_debug then
2352 hr_utility.set_location(' Leaving:'||l_proc, 999);
2353 end if;
2354 exception
2355 when hr_api.validate_enabled then
2356 -- As the Validate_Enabled exception has been raised
2357 -- we must rollback to the savepoint
2358 --
2359 if p_called_from_sspnd = 'N' then
2360 ROLLBACK TO create_enrollment;
2361 else
2362 ROLLBACK TO create_enrollment_sspnd;
2363 end if;
2364
2365 --
2366 -- Only set output warning arguments
2367 -- (Any key or derived arguments must be set to null
2368 -- when validation only mode is being used.)
2369 --
2370 p_prtt_enrt_rslt_id := null;
2371 p_effective_start_date := null;
2372 p_effective_end_date := null;
2373 p_object_version_number := null;
2374 if g_debug then
2375 hr_utility.set_location(' Leaving:'||l_proc, 80);
2376 end if;
2377 when others then
2378 --
2379 -- A validation or unexpected error has occured
2380 --
2381 rpt_error(p_proc => l_proc, p_step => l_step);
2382 if p_called_from_sspnd = 'N' then
2383 ROLLBACK TO create_enrollment;
2384 else
2385 ROLLBACK TO create_enrollment_sspnd;
2386 end if;
2387 -- nocopy, reset
2388 p_prtt_enrt_rslt_id := null;
2389 p_effective_start_date := null;
2390 p_effective_end_date := null;
2391 p_object_version_number := null;
2392 raise;
2393 end create_enrollment;
2394 --
2395 -- ----------------------------------------------------------------------------
2396 -- |------------------------< create_PRTT_ENRT_RESULT >-----------------------|
2397 -- ----------------------------------------------------------------------------
2398 --
2399 procedure create_PRTT_ENRT_RESULT
2400 (p_validate in boolean default false
2401 ,p_prtt_enrt_rslt_id out nocopy number
2402 ,p_effective_start_date out nocopy date
2403 ,p_effective_end_date out nocopy date
2404 ,p_business_group_id in number default null
2405 ,p_oipl_id in number default null
2406 ,p_person_id in number default null
2407 ,p_assignment_id in number default null
2408 ,p_pgm_id in number default null
2409 ,p_pl_id in number default null
2410 ,p_rplcs_sspndd_rslt_id in number default null
2411 ,p_ptip_id in number default null
2412 ,p_pl_typ_id in number default null
2413 ,p_ler_id in number default null
2414 ,p_sspndd_flag in varchar2 default 'N'
2415 ,p_prtt_is_cvrd_flag in varchar2 default 'N'
2416 ,p_bnft_amt in number default null
2417 ,p_uom in varchar2 default null
2418 ,p_orgnl_enrt_dt in date default null
2419 ,p_enrt_mthd_cd in varchar2 default null
2420 ,p_no_lngr_elig_flag in varchar2 default 'N'
2421 ,p_enrt_ovridn_flag in varchar2 default 'N'
2422 ,p_enrt_ovrid_rsn_cd in varchar2 default null
2423 ,p_erlst_deenrt_dt in date default null
2424 ,p_enrt_cvg_strt_dt in date default null
2425 ,p_enrt_cvg_thru_dt in date default hr_api.g_eot
2426 ,p_enrt_ovrid_thru_dt in date default null
2427 ,p_pl_ordr_num in number default null
2428 ,p_plip_ordr_num in number default null
2429 ,p_ptip_ordr_num in number default null
2430 ,p_oipl_ordr_num in number default null
2431 ,p_pen_attribute_category in varchar2 default null
2432 ,p_pen_attribute1 in varchar2 default null
2433 ,p_pen_attribute2 in varchar2 default null
2434 ,p_pen_attribute3 in varchar2 default null
2435 ,p_pen_attribute4 in varchar2 default null
2436 ,p_pen_attribute5 in varchar2 default null
2437 ,p_pen_attribute6 in varchar2 default null
2438 ,p_pen_attribute7 in varchar2 default null
2439 ,p_pen_attribute8 in varchar2 default null
2440 ,p_pen_attribute9 in varchar2 default null
2441 ,p_pen_attribute10 in varchar2 default null
2442 ,p_pen_attribute11 in varchar2 default null
2443 ,p_pen_attribute12 in varchar2 default null
2444 ,p_pen_attribute13 in varchar2 default null
2445 ,p_pen_attribute14 in varchar2 default null
2446 ,p_pen_attribute15 in varchar2 default null
2447 ,p_pen_attribute16 in varchar2 default null
2448 ,p_pen_attribute17 in varchar2 default null
2449 ,p_pen_attribute18 in varchar2 default null
2450 ,p_pen_attribute19 in varchar2 default null
2451 ,p_pen_attribute20 in varchar2 default null
2452 ,p_pen_attribute21 in varchar2 default null
2453 ,p_pen_attribute22 in varchar2 default null
2454 ,p_pen_attribute23 in varchar2 default null
2455 ,p_pen_attribute24 in varchar2 default null
2456 ,p_pen_attribute25 in varchar2 default null
2457 ,p_pen_attribute26 in varchar2 default null
2458 ,p_pen_attribute27 in varchar2 default null
2459 ,p_pen_attribute28 in varchar2 default null
2460 ,p_pen_attribute29 in varchar2 default null
2461 ,p_pen_attribute30 in varchar2 default null
2462 ,p_request_id in number default null
2463 ,p_program_application_id in number default null
2464 ,p_program_id in number default null
2465 ,p_program_update_date in date default null
2466 ,p_object_version_number out nocopy number
2467 ,p_per_in_ler_id in number default null
2468 ,p_bnft_typ_cd in varchar2 default null
2469 ,p_bnft_ordr_num in number default null
2470 ,p_prtt_enrt_rslt_stat_cd in varchar2 default null
2471 ,p_bnft_nnmntry_uom in varchar2 default null
2472 ,p_comp_lvl_cd in varchar2 default null
2473 ,p_effective_date in date
2474 ,p_multi_row_validate in boolean default TRUE
2475 ) is
2476 --
2477 -- Declare cursors and local variables
2478 --
2479 l_prtt_enrt_rslt_id ben_prtt_enrt_rslt_f.prtt_enrt_rslt_id%TYPE;
2480 l_effective_start_date ben_prtt_enrt_rslt_f.effective_start_date%TYPE;
2481 l_effective_end_date ben_prtt_enrt_rslt_f.effective_end_date%TYPE;
2482 l_proc varchar2(72) ; -- := g_package||'create_PRTT_ENRT_RESULT';
2483 l_object_version_number ben_prtt_enrt_rslt_f.object_version_number%TYPE;
2484 begin
2485 g_debug := hr_utility.debug_enabled;
2486 if g_debug then
2487 l_proc := g_package||'create_PRTT_ENRT_RESULT';
2488 hr_utility.set_location('Entering:'|| l_proc, 10);
2489 end if;
2490 --
2491 g_multi_rows_validate := p_multi_row_validate;
2492 --
2493 -- Issue a savepoint if operating in validation only mode
2494 --
2495 savepoint create_PRTT_ENRT_RESULT;
2496 --
2497 if fnd_global.conc_request_id in (0,-1) then
2498 --
2499 --
2500 ben_env_object.init(p_business_group_id => p_business_group_id,
2501 p_effective_date => p_effective_date,
2502 p_thread_id => 1,
2503 p_chunk_size => 1,
2504 p_threads => 1,
2505 p_max_errors => 1,
2506 p_benefit_action_id => null);
2507 --
2508 end if;
2509 if g_debug then
2510 hr_utility.set_location(l_proc, 20);
2511 end if;
2512 --
2513 -- Process Logic
2514 --
2515 begin
2516 --
2517 -- Start of API User Hook for the before hook of create_PRTT_ENRT_RESULT
2518 --
2519 ben_PRTT_ENRT_RESULT_bk1.create_PRTT_ENRT_RESULT_b
2520 (p_business_group_id => p_business_group_id
2521 ,p_oipl_id => p_oipl_id
2522 ,p_person_id => p_person_id
2523 ,p_assignment_id => p_assignment_id
2524 ,p_pgm_id => p_pgm_id
2525 ,p_pl_id => p_pl_id
2526 ,p_rplcs_sspndd_rslt_id => p_rplcs_sspndd_rslt_id
2527 ,p_ptip_id => p_ptip_id
2528 ,p_pl_typ_id => p_pl_typ_id
2529 ,p_ler_id => p_ler_id
2530 ,p_sspndd_flag => p_sspndd_flag
2531 ,p_prtt_is_cvrd_flag => p_prtt_is_cvrd_flag
2532 ,p_bnft_amt => p_bnft_amt
2533 ,p_uom => p_uom
2534 ,p_orgnl_enrt_dt => p_orgnl_enrt_dt
2535 ,p_enrt_mthd_cd => p_enrt_mthd_cd
2536 ,p_no_lngr_elig_flag => p_no_lngr_elig_flag
2537 ,p_enrt_ovridn_flag => p_enrt_ovridn_flag
2538 ,p_enrt_ovrid_rsn_cd => p_enrt_ovrid_rsn_cd
2539 ,p_erlst_deenrt_dt => p_erlst_deenrt_dt
2540 ,p_enrt_cvg_strt_dt => p_enrt_cvg_strt_dt
2541 ,p_enrt_cvg_thru_dt => p_enrt_cvg_thru_dt
2542 ,p_enrt_ovrid_thru_dt => p_enrt_ovrid_thru_dt
2543 ,p_pl_ordr_num => p_pl_ordr_num
2544 ,p_plip_ordr_num => p_plip_ordr_num
2545 ,p_ptip_ordr_num => p_ptip_ordr_num
2546 ,p_oipl_ordr_num => p_oipl_ordr_num
2547 ,p_pen_attribute_category => p_pen_attribute_category
2548 ,p_pen_attribute1 => p_pen_attribute1
2549 ,p_pen_attribute2 => p_pen_attribute2
2550 ,p_pen_attribute3 => p_pen_attribute3
2551 ,p_pen_attribute4 => p_pen_attribute4
2552 ,p_pen_attribute5 => p_pen_attribute5
2553 ,p_pen_attribute6 => p_pen_attribute6
2554 ,p_pen_attribute7 => p_pen_attribute7
2555 ,p_pen_attribute8 => p_pen_attribute8
2556 ,p_pen_attribute9 => p_pen_attribute9
2557 ,p_pen_attribute10 => p_pen_attribute10
2558 ,p_pen_attribute11 => p_pen_attribute11
2559 ,p_pen_attribute12 => p_pen_attribute12
2560 ,p_pen_attribute13 => p_pen_attribute13
2561 ,p_pen_attribute14 => p_pen_attribute14
2562 ,p_pen_attribute15 => p_pen_attribute15
2563 ,p_pen_attribute16 => p_pen_attribute16
2564 ,p_pen_attribute17 => p_pen_attribute17
2565 ,p_pen_attribute18 => p_pen_attribute18
2566 ,p_pen_attribute19 => p_pen_attribute19
2567 ,p_pen_attribute20 => p_pen_attribute20
2568 ,p_pen_attribute21 => p_pen_attribute21
2569 ,p_pen_attribute22 => p_pen_attribute22
2570 ,p_pen_attribute23 => p_pen_attribute23
2571 ,p_pen_attribute24 => p_pen_attribute24
2572 ,p_pen_attribute25 => p_pen_attribute25
2573 ,p_pen_attribute26 => p_pen_attribute26
2574 ,p_pen_attribute27 => p_pen_attribute27
2575 ,p_pen_attribute28 => p_pen_attribute28
2576 ,p_pen_attribute29 => p_pen_attribute29
2577 ,p_pen_attribute30 => p_pen_attribute30
2578 ,p_request_id => p_request_id
2579 ,p_program_application_id => p_program_application_id
2580 ,p_program_id => p_program_id
2581 ,p_program_update_date => p_program_update_date
2582 ,p_per_in_ler_id => p_per_in_ler_id
2583 ,p_bnft_typ_cd => p_bnft_typ_cd
2584 ,p_bnft_ordr_num => p_bnft_ordr_num
2585 ,p_prtt_enrt_rslt_stat_cd => p_prtt_enrt_rslt_stat_cd
2586 ,p_bnft_nnmntry_uom => p_bnft_nnmntry_uom
2587 ,p_comp_lvl_cd => p_comp_lvl_cd
2588 ,p_effective_date => trunc(p_effective_date)
2589 );
2590 exception
2591 when hr_api.cannot_find_prog_unit then
2592 hr_api.cannot_find_prog_unit_error
2593 (p_module_name => 'CREATE_PRTT_ENRT_RESULT'
2594 ,p_hook_type => 'BP'
2595 );
2596 --
2597 -- End of API User Hook for the before hook of create_PRTT_ENRT_RESULT
2598 --
2599 end;
2600 ben_pen_ins.ins
2601 (p_prtt_enrt_rslt_id => l_prtt_enrt_rslt_id
2602 ,p_effective_start_date => l_effective_start_date
2603 ,p_effective_end_date => l_effective_end_date
2604 ,p_business_group_id => p_business_group_id
2605 ,p_oipl_id => p_oipl_id
2606 ,p_person_id => p_person_id
2607 ,p_assignment_id => p_assignment_id
2608 ,p_pgm_id => p_pgm_id
2609 ,p_pl_id => p_pl_id
2610 ,p_rplcs_sspndd_rslt_id => p_rplcs_sspndd_rslt_id
2611 ,p_ptip_id => p_ptip_id
2612 ,p_pl_typ_id => p_pl_typ_id
2613 ,p_ler_id => p_ler_id
2614 ,p_sspndd_flag => p_sspndd_flag
2615 ,p_prtt_is_cvrd_flag => p_prtt_is_cvrd_flag
2616 ,p_bnft_amt => p_bnft_amt
2617 ,p_uom => p_uom
2618 ,p_orgnl_enrt_dt => p_orgnl_enrt_dt
2619 ,p_enrt_mthd_cd => p_enrt_mthd_cd
2620 ,p_no_lngr_elig_flag => p_no_lngr_elig_flag
2621 ,p_enrt_ovridn_flag => p_enrt_ovridn_flag
2622 ,p_enrt_ovrid_rsn_cd => p_enrt_ovrid_rsn_cd
2623 ,p_erlst_deenrt_dt => p_erlst_deenrt_dt
2624 ,p_enrt_cvg_strt_dt => p_enrt_cvg_strt_dt
2625 ,p_enrt_cvg_thru_dt => p_enrt_cvg_thru_dt
2626 ,p_enrt_ovrid_thru_dt => p_enrt_ovrid_thru_dt
2627 ,p_pl_ordr_num => p_pl_ordr_num
2628 ,p_plip_ordr_num => p_plip_ordr_num
2629 ,p_ptip_ordr_num => p_ptip_ordr_num
2630 ,p_oipl_ordr_num => p_oipl_ordr_num
2631 ,p_pen_attribute_category => p_pen_attribute_category
2632 ,p_pen_attribute1 => p_pen_attribute1
2633 ,p_pen_attribute2 => p_pen_attribute2
2634 ,p_pen_attribute3 => p_pen_attribute3
2635 ,p_pen_attribute4 => p_pen_attribute4
2636 ,p_pen_attribute5 => p_pen_attribute5
2637 ,p_pen_attribute6 => p_pen_attribute6
2638 ,p_pen_attribute7 => p_pen_attribute7
2639 ,p_pen_attribute8 => p_pen_attribute8
2640 ,p_pen_attribute9 => p_pen_attribute9
2641 ,p_pen_attribute10 => p_pen_attribute10
2642 ,p_pen_attribute11 => p_pen_attribute11
2643 ,p_pen_attribute12 => p_pen_attribute12
2644 ,p_pen_attribute13 => p_pen_attribute13
2645 ,p_pen_attribute14 => p_pen_attribute14
2646 ,p_pen_attribute15 => p_pen_attribute15
2647 ,p_pen_attribute16 => p_pen_attribute16
2648 ,p_pen_attribute17 => p_pen_attribute17
2649 ,p_pen_attribute18 => p_pen_attribute18
2650 ,p_pen_attribute19 => p_pen_attribute19
2651 ,p_pen_attribute20 => p_pen_attribute20
2652 ,p_pen_attribute21 => p_pen_attribute21
2653 ,p_pen_attribute22 => p_pen_attribute22
2654 ,p_pen_attribute23 => p_pen_attribute23
2655 ,p_pen_attribute24 => p_pen_attribute24
2656 ,p_pen_attribute25 => p_pen_attribute25
2657 ,p_pen_attribute26 => p_pen_attribute26
2658 ,p_pen_attribute27 => p_pen_attribute27
2659 ,p_pen_attribute28 => p_pen_attribute28
2660 ,p_pen_attribute29 => p_pen_attribute29
2661 ,p_pen_attribute30 => p_pen_attribute30
2662 ,p_request_id => p_request_id
2663 ,p_program_application_id => p_program_application_id
2664 ,p_program_id => p_program_id
2665 ,p_program_update_date => p_program_update_date
2666 ,p_object_version_number => l_object_version_number
2667 ,p_per_in_ler_id => p_per_in_ler_id
2668 ,p_bnft_typ_cd => p_bnft_typ_cd
2669 ,p_bnft_ordr_num => p_bnft_ordr_num
2670 ,p_prtt_enrt_rslt_stat_cd => p_prtt_enrt_rslt_stat_cd
2671 ,p_bnft_nnmntry_uom => p_bnft_nnmntry_uom
2672 ,p_comp_lvl_cd => p_comp_lvl_cd
2673 ,p_effective_date => trunc(p_effective_date)
2674 );
2675 begin
2676 --
2677 -- Start of API User Hook for the after hook of create_PRTT_ENRT_RESULT
2678 --
2679 ben_PRTT_ENRT_RESULT_bk1.create_PRTT_ENRT_RESULT_a
2680 (p_prtt_enrt_rslt_id => l_prtt_enrt_rslt_id
2681 ,p_effective_start_date => l_effective_start_date
2682 ,p_effective_end_date => l_effective_end_date
2683 ,p_business_group_id => p_business_group_id
2684 ,p_oipl_id => p_oipl_id
2685 ,p_person_id => p_person_id
2686 ,p_assignment_id => p_assignment_id
2687 ,p_pgm_id => p_pgm_id
2688 ,p_pl_id => p_pl_id
2689 ,p_rplcs_sspndd_rslt_id => p_rplcs_sspndd_rslt_id
2690 ,p_ptip_id => p_ptip_id
2691 ,p_pl_typ_id => p_pl_typ_id
2692 ,p_ler_id => p_ler_id
2693 ,p_sspndd_flag => p_sspndd_flag
2694 ,p_prtt_is_cvrd_flag => p_prtt_is_cvrd_flag
2695 ,p_bnft_amt => p_bnft_amt
2696 ,p_uom => p_uom
2697 ,p_orgnl_enrt_dt => p_orgnl_enrt_dt
2698 ,p_enrt_mthd_cd => p_enrt_mthd_cd
2699 ,p_no_lngr_elig_flag => p_no_lngr_elig_flag
2700 ,p_enrt_ovridn_flag => p_enrt_ovridn_flag
2701 ,p_enrt_ovrid_rsn_cd => p_enrt_ovrid_rsn_cd
2702 ,p_erlst_deenrt_dt => p_erlst_deenrt_dt
2703 ,p_enrt_cvg_strt_dt => p_enrt_cvg_strt_dt
2704 ,p_enrt_cvg_thru_dt => p_enrt_cvg_thru_dt
2705 ,p_enrt_ovrid_thru_dt => p_enrt_ovrid_thru_dt
2706 ,p_pl_ordr_num => p_pl_ordr_num
2707 ,p_plip_ordr_num => p_plip_ordr_num
2708 ,p_ptip_ordr_num => p_ptip_ordr_num
2709 ,p_oipl_ordr_num => p_oipl_ordr_num
2710 ,p_pen_attribute_category => p_pen_attribute_category
2711 ,p_pen_attribute1 => p_pen_attribute1
2712 ,p_pen_attribute2 => p_pen_attribute2
2713 ,p_pen_attribute3 => p_pen_attribute3
2714 ,p_pen_attribute4 => p_pen_attribute4
2715 ,p_pen_attribute5 => p_pen_attribute5
2716 ,p_pen_attribute6 => p_pen_attribute6
2717 ,p_pen_attribute7 => p_pen_attribute7
2718 ,p_pen_attribute8 => p_pen_attribute8
2719 ,p_pen_attribute9 => p_pen_attribute9
2720 ,p_pen_attribute10 => p_pen_attribute10
2721 ,p_pen_attribute11 => p_pen_attribute11
2722 ,p_pen_attribute12 => p_pen_attribute12
2723 ,p_pen_attribute13 => p_pen_attribute13
2724 ,p_pen_attribute14 => p_pen_attribute14
2725 ,p_pen_attribute15 => p_pen_attribute15
2726 ,p_pen_attribute16 => p_pen_attribute16
2727 ,p_pen_attribute17 => p_pen_attribute17
2728 ,p_pen_attribute18 => p_pen_attribute18
2729 ,p_pen_attribute19 => p_pen_attribute19
2730 ,p_pen_attribute20 => p_pen_attribute20
2731 ,p_pen_attribute21 => p_pen_attribute21
2732 ,p_pen_attribute22 => p_pen_attribute22
2733 ,p_pen_attribute23 => p_pen_attribute23
2734 ,p_pen_attribute24 => p_pen_attribute24
2735 ,p_pen_attribute25 => p_pen_attribute25
2736 ,p_pen_attribute26 => p_pen_attribute26
2737 ,p_pen_attribute27 => p_pen_attribute27
2738 ,p_pen_attribute28 => p_pen_attribute28
2739 ,p_pen_attribute29 => p_pen_attribute29
2740 ,p_pen_attribute30 => p_pen_attribute30
2741 ,p_request_id => p_request_id
2742 ,p_program_application_id => p_program_application_id
2743 ,p_program_id => p_program_id
2744 ,p_program_update_date => p_program_update_date
2745 ,p_object_version_number => l_object_version_number
2746 ,p_per_in_ler_id => p_per_in_ler_id
2747 ,p_bnft_typ_cd => p_bnft_typ_cd
2748 ,p_bnft_ordr_num => p_bnft_ordr_num
2749 ,p_prtt_enrt_rslt_stat_cd => p_prtt_enrt_rslt_stat_cd
2750 ,p_bnft_nnmntry_uom => p_bnft_nnmntry_uom
2751 ,p_comp_lvl_cd => p_comp_lvl_cd
2752 ,p_effective_date => trunc(p_effective_date)
2753 );
2754 exception
2755 when hr_api.cannot_find_prog_unit then
2756 hr_api.cannot_find_prog_unit_error
2757 (p_module_name => 'CREATE_PRTT_ENRT_RESULT'
2758 ,p_hook_type => 'AP'
2759 );
2760 end;
2761 if g_debug then
2762 hr_utility.set_location(l_proc, 60);
2763 end if;
2764 --
2765 -- When in validation only mode raise the Validate_Enabled exception
2766 --
2767 if p_validate then
2768 raise hr_api.validate_enabled;
2769 end if;
2770 --
2771 -- Set all output arguments
2772 --
2773 p_prtt_enrt_rslt_id := l_prtt_enrt_rslt_id;
2774 p_effective_start_date := l_effective_start_date;
2775 p_effective_end_date := l_effective_end_date;
2776 p_object_version_number := l_object_version_number;
2777 if g_debug then
2778 hr_utility.set_location(' Leaving:'||l_proc, 70);
2779 end if;
2780 exception
2781 when hr_api.validate_enabled then
2782 --
2783 -- As the Validate_Enabled exception has been raised
2784 -- we must rollback to the savepoint
2785 --
2786 ROLLBACK TO create_PRTT_ENRT_RESULT;
2787 --
2788 -- Only set output warning arguments
2789 -- (Any key or derived arguments must be set to null
2790 -- when validation only mode is being used.)
2791 --
2792 p_prtt_enrt_rslt_id := null;
2793 p_effective_start_date := null;
2794 p_effective_end_date := null;
2795 p_object_version_number := null;
2796 if g_debug then
2797 hr_utility.set_location(' Leaving:'||l_proc, 80);
2798 end if;
2799 when others then
2800 --
2801 -- A validation or unexpected error has occured
2802 --
2803 ROLLBACK TO create_PRTT_ENRT_RESULT;
2804 --nocopy, reset
2805 p_prtt_enrt_rslt_id := null;
2806 p_effective_start_date := null;
2807 p_effective_end_date := null;
2808 p_object_version_number := null;
2809
2810 raise;
2811 end create_PRTT_ENRT_RESULT;
2812 --
2813 -- ----------------------------------------------------------------------------
2814 -- ----------------------------------------------------------------------------
2815 --
2816 procedure update_ENROLLMENT
2817 (p_validate in boolean default false
2818 ,p_prtt_enrt_rslt_id in number
2819 ,p_effective_start_date out nocopy date
2820 ,p_effective_end_date out nocopy date
2821 ,p_business_group_id in number default hr_api.g_number
2822 ,p_oipl_id in number default hr_api.g_number
2823 ,p_person_id in number default hr_api.g_number
2824 ,p_assignment_id in number default hr_api.g_number
2825 ,p_pgm_id in number default hr_api.g_number
2826 ,p_pl_id in number default hr_api.g_number
2827 ,p_rplcs_sspndd_rslt_id in number default hr_api.g_number
2828 ,p_ptip_id in number default hr_api.g_number
2829 ,p_pl_typ_id in number default hr_api.g_number
2830 ,p_ler_id in number default hr_api.g_number
2831 ,p_sspndd_flag in varchar2 default hr_api.g_varchar2
2832 ,p_prtt_is_cvrd_flag in varchar2 default hr_api.g_varchar2
2833 ,p_enrt_bnft_id in number default NULL
2834 ,p_bnft_amt in number default hr_api.g_number
2835 ,p_uom in varchar2 default hr_api.g_varchar2
2836 ,p_orgnl_enrt_dt in date default hr_api.g_date
2837 ,p_enrt_mthd_cd in varchar2 default hr_api.g_varchar2
2838 ,p_enrt_ovridn_flag in varchar2 default hr_api.g_varchar2
2839 ,p_enrt_ovrid_rsn_cd in varchar2 default hr_api.g_varchar2
2840 ,p_erlst_deenrt_dt in date default hr_api.g_date
2841 ,p_enrt_cvg_strt_dt in date default hr_api.g_date
2842 ,p_enrt_cvg_thru_dt in date default hr_api.g_date
2843 ,p_enrt_ovrid_thru_dt in date default hr_api.g_date
2844 ,p_pl_ordr_num in number default hr_api.g_number
2845 ,p_plip_ordr_num in number default hr_api.g_number
2846 ,p_ptip_ordr_num in number default hr_api.g_number
2847 ,p_oipl_ordr_num in number default hr_api.g_number
2848 ,p_pen_attribute_category in varchar2 default hr_api.g_varchar2
2849 ,p_pen_attribute1 in varchar2 default hr_api.g_varchar2
2850 ,p_pen_attribute2 in varchar2 default hr_api.g_varchar2
2851 ,p_pen_attribute3 in varchar2 default hr_api.g_varchar2
2852 ,p_pen_attribute4 in varchar2 default hr_api.g_varchar2
2853 ,p_pen_attribute5 in varchar2 default hr_api.g_varchar2
2854 ,p_pen_attribute6 in varchar2 default hr_api.g_varchar2
2855 ,p_pen_attribute7 in varchar2 default hr_api.g_varchar2
2856 ,p_pen_attribute8 in varchar2 default hr_api.g_varchar2
2857 ,p_pen_attribute9 in varchar2 default hr_api.g_varchar2
2858 ,p_pen_attribute10 in varchar2 default hr_api.g_varchar2
2859 ,p_pen_attribute11 in varchar2 default hr_api.g_varchar2
2860 ,p_pen_attribute12 in varchar2 default hr_api.g_varchar2
2861 ,p_pen_attribute13 in varchar2 default hr_api.g_varchar2
2862 ,p_pen_attribute14 in varchar2 default hr_api.g_varchar2
2863 ,p_pen_attribute15 in varchar2 default hr_api.g_varchar2
2864 ,p_pen_attribute16 in varchar2 default hr_api.g_varchar2
2865 ,p_pen_attribute17 in varchar2 default hr_api.g_varchar2
2866 ,p_pen_attribute18 in varchar2 default hr_api.g_varchar2
2867 ,p_pen_attribute19 in varchar2 default hr_api.g_varchar2
2868 ,p_pen_attribute20 in varchar2 default hr_api.g_varchar2
2869 ,p_pen_attribute21 in varchar2 default hr_api.g_varchar2
2870 ,p_pen_attribute22 in varchar2 default hr_api.g_varchar2
2871 ,p_pen_attribute23 in varchar2 default hr_api.g_varchar2
2872 ,p_pen_attribute24 in varchar2 default hr_api.g_varchar2
2873 ,p_pen_attribute25 in varchar2 default hr_api.g_varchar2
2874 ,p_pen_attribute26 in varchar2 default hr_api.g_varchar2
2875 ,p_pen_attribute27 in varchar2 default hr_api.g_varchar2
2876 ,p_pen_attribute28 in varchar2 default hr_api.g_varchar2
2877 ,p_pen_attribute29 in varchar2 default hr_api.g_varchar2
2878 ,p_pen_attribute30 in varchar2 default hr_api.g_varchar2
2879 ,p_request_id in number default hr_api.g_number
2880 ,p_program_application_id in number default hr_api.g_number
2881 ,p_program_id in number default hr_api.g_number
2882 ,p_program_update_date in date default hr_api.g_date
2883 ,p_object_version_number in out nocopy number
2884 ,p_per_in_ler_id in number default hr_api.g_number
2885 ,p_bnft_typ_cd in varchar2 default hr_api.g_varchar2
2886 ,p_bnft_ordr_num in number default hr_api.g_number
2887 ,p_prtt_enrt_rslt_stat_cd in varchar2 default hr_api.g_varchar2
2888 ,p_bnft_nnmntry_uom in varchar2 default hr_api.g_varchar2
2889 ,p_comp_lvl_cd in varchar2 default hr_api.g_varchar2
2890 ,p_effective_date in date
2891 ,p_datetrack_mode in varchar2
2892 ,p_multi_row_validate in boolean default TRUE
2893 ,p_suspend_flag out nocopy varchar2
2894 ,p_prtt_enrt_interim_id out nocopy number
2895 ,p_dpnt_actn_warning out nocopy boolean
2896 ,p_bnf_actn_warning out nocopy boolean
2897 ,p_ctfn_actn_warning out nocopy boolean
2898 ) is
2899 --
2900 -- Declare cursors and local variables
2901 --
2902 l_pl_rec ben_cobj_cache.g_pl_inst_row;
2903 l_oipl_rec ben_cobj_cache.g_oipl_inst_row;
2904 --
2905 l_global_pen_rec ben_prtt_enrt_rslt_f%rowtype;
2906
2907
2908 cursor c_interim_enrt is
2909 select pen.rplcs_sspndd_rslt_id
2910 from ben_prtt_enrt_rslt_f pen
2911 where pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id and
2912 pen.business_group_id = p_business_group_id and
2913 p_effective_date between
2914 pen.effective_start_date and pen.effective_end_date;
2915
2916 cursor c_prem is
2917 select ecr.val,
2918 ecr.uom,
2919 ecr.actl_prem_id,
2920 pil.lf_evt_ocrd_dt,
2921 pil.ler_id,
2922 epe.elig_per_elctbl_chc_id
2923 from ben_enrt_prem ecr,
2924 ben_per_in_ler pil,
2925 ben_elig_per_elctbl_chc epe
2926 where epe.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
2927 and epe.elig_per_elctbl_chc_id = ecr.elig_per_elctbl_chc_id
2928 and pil.per_in_ler_id = epe.per_in_ler_id
2929 and pil.per_in_ler_stat_cd = 'STRTD';
2930 --and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT');
2931 --
2932 l_prem c_prem%rowtype;
2933 --
2934 /*
2935 CODE PRIOR TO WWBUG: 1646442
2936 cursor c_ppe (p_prtt_enrt_rslt_id in number,
2937 p_actl_prem_id in number) is
2938 */
2939 /* Start of Changes for WWBUG: 1646442 */
2940 cursor c_ppe (p_prtt_enrt_rslt_id in number,
2941 p_actl_prem_id in number,
2942 p_ppe_dt_to_use in date) is
2943 /* End of Changes for WWBUG: 1646442 */
2944 select ppe.prtt_prem_id,
2945 ppe.std_prem_uom,
2946 ppe.std_prem_val,
2947 ppe.actl_prem_id,
2948 ppe.object_version_number,
2949 ppe.effective_start_date
2950 from ben_prtt_prem_f ppe,
2951 ben_per_in_ler pil
2952 where ppe.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
2953 and ppe.actl_prem_id = p_actl_prem_id
2954 /*
2955 CODE PRIOR TO WWBUG: 1646442
2956 and p_effective_date between
2957 */
2958 /* Start of Changes for WWBUG: 1646442 */
2959 and p_ppe_dt_to_use between
2960 /* End of Changes for WWBUG: 1646442 */
2961 ppe.effective_start_date and ppe.effective_end_date
2962 and pil.per_in_ler_id=ppe.per_in_ler_id
2963 and pil.business_group_id=ppe.business_group_id
2964 and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT')
2965 ;
2966 --
2967 l_ppe c_ppe%rowtype;
2968
2969 ----For Bug : 7133998
2970 cursor c_ppe1 (p_prtt_enrt_rslt_id in number,
2971 p_actl_prem_id in number,
2972 p_ppe_dt_to_use in date) is
2973 select ppe.*
2974 from ben_prtt_prem_f ppe,
2975 ben_per_in_ler pil
2976 where ppe.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
2977 and ppe.actl_prem_id = p_actl_prem_id
2978 and p_ppe_dt_to_use <= ppe.effective_start_date
2979 and pil.per_in_ler_id=ppe.per_in_ler_id
2980 and pil.business_group_id=ppe.business_group_id
2981 and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT')
2982 ;
2983 l_count number := 0;
2984 l_objversion_no number;
2985 ---For Bug : 7133998
2986 --
2987 -- This cursor is used to update the elig_cvrd_dpnt records
2988 -- when the participant stays in the same plan and we need
2989 -- to copy his dependents from elig_dpnt to elig_cvrd_dpnt.
2990 --
2991 -- Note: Result Id is same on the choice and elig_cvrd_dpnt record,
2992 -- but per_in_ler_id is DIFFERENT.
2993 -- Do not do any updates for same per_in_ler_id as we would have
2994 -- done the updates when per_in_ler_id changed and the user would
2995 -- have changed his designation since then. (Basically do not repeat it.)
2996 --
2997 -- Bug 1298802: sometimes per-in-ler is the same...when have a ler and move
2998 -- out of this result then right back into this result on same day. If prtt
2999 -- does an uncover, change option, then back into option, I think
3000 -- it's better to re-cover the dpnts....then user can uncover them again.
3001 --
3002 cursor c_egd is
3003 select egd.elig_cvrd_dpnt_id,
3004 egd.per_in_ler_id,
3005 pdp.effective_start_date,
3006 pdp.object_version_number
3007 from ben_elig_per_elctbl_chc epe,
3008 ben_elig_dpnt egd,
3009 ben_elig_cvrd_dpnt_f pdp,
3010 ben_per_in_ler egd_pil,
3011 ben_per_in_ler pdp_pil
3012 where epe.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
3013 and epe.per_in_ler_id = p_per_in_ler_id
3014 and epe.elig_per_elctbl_chc_id = egd.elig_per_elctbl_chc_id
3015 and egd.elig_cvrd_dpnt_id = pdp.elig_cvrd_dpnt_id
3016 and pdp.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
3017 -- and egd.per_in_ler_id <> pdp.per_in_ler_id
3018 and egd.per_in_ler_id = egd_pil.per_in_ler_id
3019 and egd_pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT')
3020 and pdp.per_in_ler_id = pdp_pil.per_in_ler_id
3021 and pdp_pil.per_in_ler_stat_cd not in ('VOIDD', 'BCKDT')
3022 and p_effective_date between
3023 pdp.effective_start_date and pdp.effective_end_date
3024 and p_effective_date >= pdp.cvg_strt_dt
3025 and egd.dpnt_inelig_flag = 'N'
3026 -- and p_effective_date between
3027 -- pdp.cvg_strt_dt and pdp.cvg_thru_dt
3028 ;
3029
3030 --- to find the flex credit place holder choice and rate
3031 --- flex credit amount is changes is not effecting the ledger
3032 ---- this find the flex credit place holder plan prvdd amount
3033 --- then the amount will be compared with bnft_prvdd_ldgr row
3034 -- if a rate cahnge found update the bnft_prvdd_ldgr
3035 cursor c_flex_choice is
3036 select epe.bnft_prvdr_pool_id,
3037 epe.elig_per_elctbl_chc_id,
3038 epe.prtt_enrt_rslt_id,
3039 epe.business_group_id,
3040 epe.per_in_ler_id,
3041 ecr.enrt_rt_id,
3042 ecr.acty_base_rt_id,
3043 nvl(ecr.dflt_val, ecr.val) val
3044 from ben_elig_per_elctbl_chc epe1,
3045 ben_elig_per_elctbl_chc epe,
3046 ben_enrt_rt ecr
3047 where epe1.prtt_enrt_rslt_id =p_prtt_enrt_rslt_id and
3048 epe1.per_in_ler_id = p_per_in_ler_id and
3049 epe1.business_group_id=p_business_group_id and
3050 epe1.pgm_id = epe.pgm_id and
3051 epe1.per_in_ler_id = epe.per_in_ler_id and
3052 epe.bnft_prvdr_pool_id is not null and
3053 epe.business_group_id=p_business_group_id and
3054 ecr.elig_per_elctbl_chc_id = epe.elig_per_elctbl_chc_id and
3055 ecr.rt_usg_cd = 'FLXCR' and
3056 ecr.business_group_id = p_business_group_id;
3057
3058
3059
3060 cursor c_bpl ( c_acty_base_rt_id number ,
3061 c_bnft_prvdr_pool_id number ,
3062 c_prtt_enrt_rslt_id number) is
3063 select prvdd_val
3064 from ben_bnft_prvdd_ldgr_f bpl,
3065 ben_per_in_ler pil
3066 where bpl.acty_base_rt_id = c_acty_base_rt_id
3067 and bpl.bnft_prvdr_pool_id = c_bnft_prvdr_pool_id
3068 and bpl.prtt_enrt_rslt_id = c_prtt_enrt_rslt_id
3069 and pil.per_in_ler_id = bpl.per_in_ler_id
3070 and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT')
3071 and bpl.business_group_id = p_business_group_id
3072 and p_effective_date between
3073 bpl.effective_start_date and bpl.effective_end_date ;
3074 --
3075 cursor c_prtt_enrt is
3076 select prtt_enrt_rslt_id
3077 from ben_elig_per_elctbl_chc epe
3078 where epe.per_in_ler_id = p_per_in_ler_id
3079 and epe.comp_lvl_cd = 'PLANFC'
3080 and epe.business_group_id = p_business_group_id;
3081 --
3082 cursor c_elig_per_elctbl_chc is
3083 select elig_per_elctbl_chc_id
3084 from ben_elig_per_elctbl_chc
3085 where prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
3086 and per_in_ler_id = p_per_in_ler_id;
3087 --
3088 /* Start of Changes for WWBUG: 1646442: added */
3089 cursor c_pel (p_elig_pe_elctbl_chc_id number) is
3090 select pel.enrt_perd_id,pel.lee_rsn_id
3091 from ben_pil_elctbl_chc_popl pel
3092 ,ben_elig_per_elctbl_chc epe
3093 where pel.pil_elctbl_chc_popl_id = epe.pil_elctbl_chc_popl_id
3094 and epe.elig_per_elctbl_chc_id = p_elig_pe_elctbl_chc_id;
3095
3096 l_pel c_pel%rowtype;
3097 --
3098 -- Bug : 3866580
3099 cursor c_pl_typ_opt_typ_cd (pl_typ_id number, p_effective_date date) is
3100 select ptp.opt_typ_cd
3101 from ben_pl_typ_f ptp
3102 where ptp.pl_typ_id = p_pl_typ_id
3103 and p_effective_date between ptp.effective_start_date
3104 and ptp.effective_end_date;
3105
3106 l_pl_typ_opt_typ_cd ben_pl_typ.opt_typ_cd%type;
3107 -- Bug : 3866580
3108 --
3109 --
3110 l_ppe_dt_to_use date;
3111 l_enrt_cvg_strt_dt date;
3112 l_enrt_cvg_strt_dt_cd varchar2(30);
3113 l_enrt_cvg_strt_dt_rl number;
3114 l_rt_strt_dt date;
3115 l_rt_strt_dt_cd varchar2(30);
3116 l_rt_strt_dt_rl number;
3117 l_enrt_cvg_end_dt date;
3118 l_enrt_cvg_end_dt_cd varchar2(30);
3119 l_enrt_cvg_end_dt_rl number;
3120 l_rt_end_dt date;
3121 l_rt_end_dt_cd varchar2(30);
3122 l_rt_end_dt_rl number;
3123 /* End of Changes for WWBUG: 1646442 */
3124 --
3125 l_proc varchar2(72); -- := g_package||'update_ENROLLMENT';
3126 l_object_version_number ben_prtt_enrt_rslt_f.object_version_number%TYPE;
3127 l_effective_start_date ben_prtt_enrt_rslt_f.effective_start_date%TYPE;
3128 l_effective_end_date ben_prtt_enrt_rslt_f.effective_end_date%TYPE;
3129 l_prev_bnft_amt ben_prtt_enrt_rslt_f.bnft_amt%TYPE;
3130 l_enrt_pl_opt_flag ben_pl_f.enrt_pl_opt_flag%TYPE;
3131 l_prvdd_val ben_bnft_prvdd_ldgr_f.prvdd_Val%type ;
3132 l_chg boolean := FALSE;
3133 l_step number(9);
3134 l_datetrack_mode varchar2(30) := p_datetrack_mode;
3135 l_correction boolean;
3136 l_update boolean;
3137 l_update_override boolean;
3138 l_update_change_insert boolean;
3139 l_post_rslt_flag varchar2(30) := 'Y';
3140 l_egd_datetrack_mode varchar2(30);
3141 l_ppe_datetrack_mode varchar2(30);
3142 l_prtt_enrt_rslt_id number ;
3143 l_elig_per_elctbl_chc_id number;
3144 --
3145 begin
3146 --
3147 l_step := 10;
3148 g_debug := hr_utility.debug_enabled;
3149 if g_debug then
3150 l_proc := g_package||'update_ENROLLMENT';
3151 hr_utility.set_location('Entering:'|| l_proc, 10);
3152 end if;
3153 --
3154 g_multi_rows_validate := p_multi_row_validate;
3155 If (p_multi_row_validate) then
3156 l_post_rslt_flag := 'Y';
3157 Else
3158 l_post_rslt_flag := 'N';
3159 End if;
3160 --
3161 -- Issue a savepoint if operating in validation only mode
3162 --
3163 savepoint update_ENROLLMENT;
3164 if g_debug then
3165 hr_utility.set_location(l_proc, 20);
3166 end if;
3167 --
3168 -- Process Logic
3169 --
3170 l_object_version_number := p_object_version_number;
3171 l_step := 20;
3172 ben_global_enrt.get_pen -- result
3173 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
3174 ,p_effective_date => p_effective_date
3175 ,p_global_pen_rec => l_global_pen_rec);
3176 --
3177 ben_cobj_cache.get_pl_dets
3178 (p_business_group_id => p_business_group_id
3179 ,p_effective_date => p_effective_date
3180 ,p_pl_id => l_global_pen_rec.pl_id
3181 ,p_inst_row => l_pl_rec);
3182 if l_global_pen_rec.oipl_id is not null then
3183 ben_cobj_cache.get_oipl_dets
3184 (p_business_group_id => p_business_group_id
3185 ,p_effective_date => p_effective_date
3186 ,p_oipl_id => l_global_pen_rec.oipl_id
3187 ,p_inst_row => l_oipl_rec);
3188 end if;
3189 --
3190 l_step := 30;
3191 if (p_oipl_id <> hr_api.g_number and
3192 nvl(l_global_pen_rec.oipl_id,hr_api.g_number) <>
3193 nvl(p_oipl_id,hr_api.g_number)) then
3194 l_chg := TRUE;
3195 end if;
3196 if (p_assignment_id <> hr_api.g_number and
3197 nvl(l_global_pen_rec.assignment_id,hr_api.g_number) <>
3198 nvl(p_assignment_id,hr_api.g_number)) then
3199 l_chg := TRUE;
3200 end if;
3201 if (p_pgm_id <> hr_api.g_number and
3202 nvl(l_global_pen_rec.pgm_id,hr_api.g_number) <>
3203 nvl(p_pgm_id,hr_api.g_number)) then
3204 l_chg := TRUE;
3205 end if;
3206 if (p_pl_id <> hr_api.g_number and
3207 nvl(l_global_pen_rec.pl_id,hr_api.g_number) <>
3208 nvl(p_pl_id, hr_api.g_number)) then
3209 l_chg := TRUE;
3210 end if;
3211 if (p_rplcs_sspndd_rslt_id <> hr_api.g_number and
3212 nvl(l_global_pen_rec.rplcs_sspndd_rslt_id,hr_api.g_number) <>
3213 nvl(p_rplcs_sspndd_rslt_id,hr_api.g_number) ) then
3214 l_chg := TRUE;
3215 end if;
3216 l_step := 35;
3217 if (p_ptip_id <> hr_api.g_number and
3218 nvl(l_global_pen_rec.ptip_id,hr_api.g_number) <>
3219 nvl(p_ptip_id,hr_api.g_number)) then
3220 l_chg := TRUE;
3221 end if;
3222 if (p_pl_typ_id <> hr_api.g_number and
3223 nvl(l_global_pen_rec.pl_typ_id,hr_api.g_number) <>
3224 nvl(p_pl_typ_id,hr_api.g_number)) then
3225 l_chg := TRUE;
3226 end if;
3227 if (p_ler_id <> hr_api.g_number and
3228 nvl(l_global_pen_rec.ler_id,hr_api.g_number) <>
3229 nvl(p_ler_id,hr_api.g_number)) then
3230 l_chg := TRUE;
3231 end if;
3232 if (p_sspndd_flag <> hr_api.g_varchar2 and
3233 nvl(l_global_pen_rec.sspndd_flag,hr_api.g_varchar2) <>
3234 nvl(p_sspndd_flag,hr_api.g_varchar2)) then
3235 l_chg := TRUE;
3236 end if;
3237 if (p_prtt_is_cvrd_flag <> hr_api.g_varchar2 and
3238 nvl(l_global_pen_rec.prtt_is_cvrd_flag,hr_api.g_varchar2) <>
3239 nvl(p_prtt_is_cvrd_flag,hr_api.g_varchar2)) then
3240 l_chg := TRUE;
3241 end if;
3242 --
3243 -- Bug 4723828 : If benefit amount changes from non-zero value to NULL
3244 -- we need to detect that nullify the coverage. So added
3245 -- nvl(p_bnft_amt, -9999)
3246 --
3247 if (nvl(p_bnft_amt, -9999) <> hr_api.g_number and
3248 nvl(l_global_pen_rec.bnft_amt,hr_api.g_number) <>
3249 nvl(p_bnft_amt,hr_api.g_number)) then
3250 l_chg := TRUE;
3251 end if;
3252 l_step := 40;
3253 if (p_uom <> hr_api.g_varchar2 and
3254 nvl(l_global_pen_rec.uom,hr_api.g_varchar2) <>
3255 nvl(p_uom,hr_api.g_varchar2)) then
3256 l_chg := TRUE;
3257 end if;
3258 if (p_orgnl_enrt_dt <> hr_api.g_date and
3259 nvl(l_global_pen_rec.orgnl_enrt_dt,hr_api.g_date) <>
3260 nvl(p_orgnl_enrt_dt,hr_api.g_date)) then
3261 l_chg := TRUE;
3262 end if;
3263 -- 5417132 by pass enrt_mthd_cd chk for Imputed/flex rows
3264 if p_comp_lvl_cd not in ('PLANFC','PLANIMP') then
3265 if (p_enrt_mthd_cd <> hr_api.g_varchar2 and
3266 nvl(l_global_pen_rec.enrt_mthd_cd,hr_api.g_varchar2) <>
3267 nvl(p_enrt_mthd_cd,hr_api.g_varchar2)) then
3268 l_chg := TRUE;
3269 end if;
3270 end if;
3271 if (p_enrt_ovridn_flag <> hr_api.g_varchar2 and
3272 nvl(l_global_pen_rec.enrt_ovridn_flag,hr_api.g_varchar2) <>
3273 nvl(p_enrt_ovridn_flag,hr_api.g_varchar2)) then
3274 l_chg := TRUE;
3275 end if;
3276 if (p_enrt_ovrid_rsn_cd <> hr_api.g_varchar2 and
3277 nvl(l_global_pen_rec.enrt_ovrid_rsn_cd,hr_api.g_varchar2) <>
3278 nvl(p_enrt_ovrid_rsn_cd,hr_api.g_varchar2)) then
3279 l_chg := TRUE;
3280 end if;
3281 if (p_erlst_deenrt_dt <> hr_api.g_date and
3282 nvl(l_global_pen_rec.erlst_deenrt_dt,hr_api.g_date) <>
3283 nvl(p_erlst_deenrt_dt,hr_api.g_date)) then
3284 l_chg := TRUE;
3285 end if;
3286 if (p_enrt_cvg_strt_dt <> hr_api.g_date and
3287 nvl(l_global_pen_rec.enrt_cvg_strt_dt,hr_api.g_date) <>
3288 nvl(p_enrt_cvg_strt_dt,hr_api.g_date)) then
3289 l_chg := TRUE;
3290 end if;
3291 if (p_enrt_cvg_thru_dt <> hr_api.g_date and
3292 nvl(l_global_pen_rec.enrt_cvg_thru_dt,hr_api.g_date) <>
3293 nvl(p_enrt_cvg_thru_dt,hr_api.g_date)) then
3294 l_chg := TRUE;
3295 end if;
3296 if (p_enrt_ovrid_thru_dt <> hr_api.g_date and
3297 nvl(l_global_pen_rec.enrt_ovrid_thru_dt,hr_api.g_date) <>
3298 nvl(p_enrt_ovrid_thru_dt,hr_api.g_date)) then
3299 l_chg := TRUE;
3300 end if;
3301 l_step := 50;
3302 if (p_per_in_ler_id <> hr_api.g_number and
3303 nvl(l_global_pen_rec.per_in_ler_id,hr_api.g_number) <>
3304 nvl(p_per_in_ler_id,hr_api.g_number)) then
3305 l_chg := TRUE;
3306 end if;
3307 if (p_bnft_typ_cd <> hr_api.g_varchar2 and
3308 nvl(l_global_pen_rec.bnft_typ_cd,hr_api.g_varchar2) <>
3309 nvl(p_bnft_typ_cd,hr_api.g_varchar2)) then
3310 l_chg := TRUE;
3311 end if;
3312 if (p_bnft_ordr_num <> hr_api.g_number and
3313 nvl(l_global_pen_rec.bnft_ordr_num,hr_api.g_number) <>
3314 nvl(p_bnft_ordr_num,hr_api.g_number)) then
3315 l_chg := TRUE;
3316 end if;
3317 if (p_prtt_enrt_rslt_stat_cd <> hr_api.g_varchar2 and
3318 nvl(l_global_pen_rec.prtt_enrt_rslt_stat_cd,hr_api.g_varchar2) <>
3319 nvl(p_prtt_enrt_rslt_stat_cd,hr_api.g_varchar2)) then
3320 l_chg := TRUE;
3321 end if;
3322 if (p_bnft_nnmntry_uom <> hr_api.g_varchar2 and
3323 nvl(l_global_pen_rec.bnft_nnmntry_uom,hr_api.g_varchar2) <>
3324 nvl(p_bnft_nnmntry_uom,hr_api.g_varchar2)) then
3325 l_chg := TRUE;
3326 end if;
3327 if (p_comp_lvl_cd <> hr_api.g_varchar2 and
3328 nvl(l_global_pen_rec.comp_lvl_cd,hr_api.g_varchar2) <>
3329 nvl(p_comp_lvl_cd,hr_api.g_varchar2)) then
3330 l_chg := TRUE;
3331 end if;
3332 --
3333 -- bug 1712890 added the following columns
3334 --
3335
3336 --Bug 4770367 : Added the NVL condition so as to allow the user to update
3337 -- the attributes with NULL values if the user wishes to do so
3338
3339 --If DFF field changes from non-zero value to NULL
3340 -- we need to detect that nullify the coverage. So added
3341 -- nvl(p_pen_attributexx, '~')
3342
3343 if (nvl(p_pen_attribute1 ,'~')<> hr_api.g_varchar2 and
3344 nvl(l_global_pen_rec.pen_attribute1,hr_api.g_varchar2) <>
3345 nvl(p_pen_attribute1,hr_api.g_varchar2)) then
3346 l_chg := TRUE;
3347 end if;
3348 if (nvl(p_pen_attribute2 ,'~')<> hr_api.g_varchar2 and
3349 nvl(l_global_pen_rec.pen_attribute2,hr_api.g_varchar2) <>
3350 nvl(p_pen_attribute2,hr_api.g_varchar2)) then
3351 l_chg := TRUE;
3352 end if;
3353 if (nvl(p_pen_attribute3 ,'~')<> hr_api.g_varchar2 and
3354 nvl(l_global_pen_rec.pen_attribute3,hr_api.g_varchar2) <>
3355 nvl(p_pen_attribute3,hr_api.g_varchar2)) then
3356 l_chg := TRUE;
3357 end if;
3358 if (nvl(p_pen_attribute4 ,'~')<> hr_api.g_varchar2 and
3359 nvl(l_global_pen_rec.pen_attribute4,hr_api.g_varchar2) <>
3360 nvl(p_pen_attribute4,hr_api.g_varchar2)) then
3361 l_chg := TRUE;
3362 end if;
3363 if (nvl(p_pen_attribute5 ,'~')<> hr_api.g_varchar2 and
3364 nvl(l_global_pen_rec.pen_attribute5,hr_api.g_varchar2) <>
3365 nvl(p_pen_attribute5,hr_api.g_varchar2)) then
3366 l_chg := TRUE;
3367 end if;
3368 if (nvl(p_pen_attribute6 ,'~')<> hr_api.g_varchar2 and
3369 nvl(l_global_pen_rec.pen_attribute6,hr_api.g_varchar2) <>
3370 nvl(p_pen_attribute6,hr_api.g_varchar2)) then
3371 l_chg := TRUE;
3372 end if;
3373 if (nvl(p_pen_attribute7 ,'~')<> hr_api.g_varchar2 and
3374 nvl(l_global_pen_rec.pen_attribute7,hr_api.g_varchar2) <>
3375 nvl(p_pen_attribute7,hr_api.g_varchar2)) then
3376 l_chg := TRUE;
3377 end if;
3378 if (nvl(p_pen_attribute8 ,'~')<> hr_api.g_varchar2 and
3379 nvl(l_global_pen_rec.pen_attribute8,hr_api.g_varchar2) <>
3380 nvl(p_pen_attribute8,hr_api.g_varchar2)) then
3381 l_chg := TRUE;
3382 end if;
3383 if (nvl(p_pen_attribute9 ,'~')<> hr_api.g_varchar2 and
3384 nvl(l_global_pen_rec.pen_attribute9,hr_api.g_varchar2) <>
3385 nvl(p_pen_attribute9,hr_api.g_varchar2)) then
3386 l_chg := TRUE;
3387 end if;
3388 if (nvl(p_pen_attribute10 ,'~')<> hr_api.g_varchar2 and
3389 nvl(l_global_pen_rec.pen_attribute10,hr_api.g_varchar2) <>
3390 nvl(p_pen_attribute10,hr_api.g_varchar2)) then
3391 l_chg := TRUE;
3392 end if;
3393 if (nvl(p_pen_attribute11 ,'~')<> hr_api.g_varchar2 and
3394 nvl(l_global_pen_rec.pen_attribute11,hr_api.g_varchar2) <>
3395 nvl(p_pen_attribute11,hr_api.g_varchar2)) then
3396 l_chg := TRUE;
3397 end if;
3398 if (nvl(p_pen_attribute12 ,'~')<> hr_api.g_varchar2 and
3399 nvl(l_global_pen_rec.pen_attribute12,hr_api.g_varchar2) <>
3400 nvl(p_pen_attribute12,hr_api.g_varchar2)) then
3401 l_chg := TRUE;
3402 end if;
3403 if (nvl(p_pen_attribute13 ,'~')<> hr_api.g_varchar2 and
3404 nvl(l_global_pen_rec.pen_attribute13,hr_api.g_varchar2) <>
3405 nvl(p_pen_attribute13,hr_api.g_varchar2)) then
3406 l_chg := TRUE;
3407 end if;
3408 if (nvl(p_pen_attribute14 ,'~')<> hr_api.g_varchar2 and
3409 nvl(l_global_pen_rec.pen_attribute14,hr_api.g_varchar2) <>
3410 nvl(p_pen_attribute14,hr_api.g_varchar2)) then
3411 l_chg := TRUE;
3412 end if;
3413 if (nvl(p_pen_attribute15 ,'~')<> hr_api.g_varchar2 and
3414 nvl(l_global_pen_rec.pen_attribute15,hr_api.g_varchar2) <>
3415 nvl(p_pen_attribute15,hr_api.g_varchar2)) then
3416 l_chg := TRUE;
3417 end if;
3418 if (nvl(p_pen_attribute16 ,'~')<> hr_api.g_varchar2 and
3419 nvl(l_global_pen_rec.pen_attribute16,hr_api.g_varchar2) <>
3420 nvl(p_pen_attribute16,hr_api.g_varchar2)) then
3421 l_chg := TRUE;
3422 end if;
3423 if (nvl(p_pen_attribute17 ,'~')<> hr_api.g_varchar2 and
3424 nvl(l_global_pen_rec.pen_attribute17,hr_api.g_varchar2) <>
3425 nvl(p_pen_attribute17,hr_api.g_varchar2)) then
3426 l_chg := TRUE;
3427 end if;
3428 if (nvl(p_pen_attribute18 ,'~')<> hr_api.g_varchar2 and
3429 nvl(l_global_pen_rec.pen_attribute18,hr_api.g_varchar2) <>
3430 nvl(p_pen_attribute18,hr_api.g_varchar2)) then
3431 l_chg := TRUE;
3432 end if;
3433 if (nvl(p_pen_attribute19 ,'~')<> hr_api.g_varchar2 and
3434 nvl(l_global_pen_rec.pen_attribute19,hr_api.g_varchar2) <>
3435 nvl(p_pen_attribute19,hr_api.g_varchar2)) then
3436 l_chg := TRUE;
3437 end if;
3438 if (nvl(p_pen_attribute20 ,'~')<> hr_api.g_varchar2 and
3439 nvl(l_global_pen_rec.pen_attribute20,hr_api.g_varchar2) <>
3440 nvl(p_pen_attribute20,hr_api.g_varchar2)) then
3441 l_chg := TRUE;
3442 end if;
3443 if (nvl(p_pen_attribute21 ,'~')<> hr_api.g_varchar2 and
3444 nvl(l_global_pen_rec.pen_attribute21,hr_api.g_varchar2) <>
3445 nvl(p_pen_attribute21,hr_api.g_varchar2)) then
3446 l_chg := TRUE;
3447 end if;
3448 if (nvl(p_pen_attribute22 ,'~')<> hr_api.g_varchar2 and
3449 nvl(l_global_pen_rec.pen_attribute22,hr_api.g_varchar2) <>
3450 nvl(p_pen_attribute22,hr_api.g_varchar2)) then
3451 l_chg := TRUE;
3452 end if;
3453 if (nvl(p_pen_attribute23 ,'~')<> hr_api.g_varchar2 and
3454 nvl(l_global_pen_rec.pen_attribute23,hr_api.g_varchar2) <>
3455 nvl(p_pen_attribute23,hr_api.g_varchar2)) then
3456 l_chg := TRUE;
3457 end if;
3458 if (nvl(p_pen_attribute24 ,'~')<> hr_api.g_varchar2 and
3459 nvl(l_global_pen_rec.pen_attribute24,hr_api.g_varchar2) <>
3460 nvl(p_pen_attribute24,hr_api.g_varchar2)) then
3461 l_chg := TRUE;
3462 end if;
3463 if (nvl(p_pen_attribute25 ,'~')<> hr_api.g_varchar2 and
3464 nvl(l_global_pen_rec.pen_attribute25,hr_api.g_varchar2) <>
3465 nvl(p_pen_attribute25,hr_api.g_varchar2)) then
3466 l_chg := TRUE;
3467 end if;
3468 if (nvl(p_pen_attribute26 ,'~')<> hr_api.g_varchar2 and
3469 nvl(l_global_pen_rec.pen_attribute26,hr_api.g_varchar2) <>
3470 nvl(p_pen_attribute26,hr_api.g_varchar2)) then
3471 l_chg := TRUE;
3472 end if;
3473 if (nvl(p_pen_attribute27 ,'~')<> hr_api.g_varchar2 and
3474 nvl(l_global_pen_rec.pen_attribute27,hr_api.g_varchar2) <>
3475 nvl(p_pen_attribute27,hr_api.g_varchar2)) then
3476 l_chg := TRUE;
3477 end if;
3478 if (nvl(p_pen_attribute28 ,'~')<> hr_api.g_varchar2 and
3479 nvl(l_global_pen_rec.pen_attribute28,hr_api.g_varchar2) <>
3480 nvl(p_pen_attribute28,hr_api.g_varchar2)) then
3481 l_chg := TRUE;
3482 end if;
3483 if (nvl(p_pen_attribute29 ,'~')<> hr_api.g_varchar2 and
3484 nvl(l_global_pen_rec.pen_attribute29,hr_api.g_varchar2) <>
3485 nvl(p_pen_attribute29,hr_api.g_varchar2)) then
3486 l_chg := TRUE;
3487 end if;
3488 if (nvl(p_pen_attribute30 ,'~')<> hr_api.g_varchar2 and
3489 nvl(l_global_pen_rec.pen_attribute30,hr_api.g_varchar2) <>
3490 nvl(p_pen_attribute30,hr_api.g_varchar2)) then
3491 l_chg := TRUE;
3492 end if;
3493 --End Bug 4770367
3494
3495 if (l_chg) then
3496 l_step := 60;
3497
3498
3499 -- Check dt mode is valid
3500 --
3501 dt_api.find_dt_upd_modes
3502 (p_effective_date => p_effective_date,
3503 p_base_table_name => 'BEN_PRTT_ENRT_RSLT_F',
3504 p_base_key_column => 'prtt_enrt_rslt_id',
3505 p_base_key_value => p_prtt_enrt_rslt_id,
3506 p_correction => l_correction,
3507 p_update => l_update,
3508 p_update_override => l_update_override,
3509 p_update_change_insert => l_update_change_insert);
3510 --
3511 if l_update_override then
3512 --
3513 l_datetrack_mode := hr_api.g_update_override;
3514 --
3515 elsif l_update then
3516 --
3517 l_datetrack_mode := hr_api.g_update;
3518 --
3519 else
3520 --
3521 l_datetrack_mode := hr_api.g_correction;
3522 --
3523 end if;
3524 --
3525 -- Start of API User Hook for the before hook of
3526 -- update_PRTT_ENRT_RESULT
3527 --
3528 ben_PRTT_ENRT_RESULT_API.update_PRTT_ENRT_RESULT
3529 (p_validate => FALSE
3530 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
3531 ,p_effective_start_date => l_effective_start_date
3532 ,p_effective_end_date => l_effective_end_date
3533 ,p_business_group_id => p_business_group_id
3534 ,p_oipl_id => p_oipl_id
3535 ,p_person_id => p_person_id
3536 ,p_assignment_id => p_assignment_id
3537 ,p_pgm_id => p_pgm_id
3538 ,p_pl_id => p_pl_id
3539 ,p_rplcs_sspndd_rslt_id => p_rplcs_sspndd_rslt_id
3540 ,p_ptip_id => p_ptip_id
3541 ,p_pl_typ_id => p_pl_typ_id
3542 ,p_ler_id => p_ler_id
3543 ,p_sspndd_flag => p_sspndd_flag
3544 ,p_prtt_is_cvrd_flag => p_prtt_is_cvrd_flag
3545 ,p_bnft_amt => p_bnft_amt
3546 ,p_uom => p_uom
3547 ,p_orgnl_enrt_dt => p_orgnl_enrt_dt
3548 ,p_enrt_mthd_cd => p_enrt_mthd_cd
3549 ,p_enrt_ovridn_flag => p_enrt_ovridn_flag
3550 ,p_enrt_ovrid_rsn_cd => p_enrt_ovrid_rsn_cd
3551 ,p_erlst_deenrt_dt => p_erlst_deenrt_dt
3552 ,p_enrt_cvg_strt_dt => p_enrt_cvg_strt_dt
3553 ,p_enrt_cvg_thru_dt => p_enrt_cvg_thru_dt
3554 ,p_enrt_ovrid_thru_dt => p_enrt_ovrid_thru_dt
3555 ,p_pl_ordr_num => p_pl_ordr_num
3556 ,p_plip_ordr_num => p_plip_ordr_num
3557 ,p_ptip_ordr_num => p_ptip_ordr_num
3558 ,p_oipl_ordr_num => p_oipl_ordr_num
3559 ,p_pen_attribute_category => p_pen_attribute_category
3560 ,p_pen_attribute1 => p_pen_attribute1
3561 ,p_pen_attribute2 => p_pen_attribute2
3562 ,p_pen_attribute3 => p_pen_attribute3
3563 ,p_pen_attribute4 => p_pen_attribute4
3564 ,p_pen_attribute5 => p_pen_attribute5
3565 ,p_pen_attribute6 => p_pen_attribute6
3566 ,p_pen_attribute7 => p_pen_attribute7
3567 ,p_pen_attribute8 => p_pen_attribute8
3568 ,p_pen_attribute9 => p_pen_attribute9
3569 ,p_pen_attribute10 => p_pen_attribute10
3570 ,p_pen_attribute11 => p_pen_attribute11
3571 ,p_pen_attribute12 => p_pen_attribute12
3572 ,p_pen_attribute13 => p_pen_attribute13
3573 ,p_pen_attribute14 => p_pen_attribute14
3574 ,p_pen_attribute15 => p_pen_attribute15
3575 ,p_pen_attribute16 => p_pen_attribute16
3576 ,p_pen_attribute17 => p_pen_attribute17
3577 ,p_pen_attribute18 => p_pen_attribute18
3578 ,p_pen_attribute19 => p_pen_attribute19
3579 ,p_pen_attribute20 => p_pen_attribute20
3580 ,p_pen_attribute21 => p_pen_attribute21
3581 ,p_pen_attribute22 => p_pen_attribute22
3582 ,p_pen_attribute23 => p_pen_attribute23
3583 ,p_pen_attribute24 => p_pen_attribute24
3584 ,p_pen_attribute25 => p_pen_attribute25
3585 ,p_pen_attribute26 => p_pen_attribute26
3586 ,p_pen_attribute27 => p_pen_attribute27
3587 ,p_pen_attribute28 => p_pen_attribute28
3588 ,p_pen_attribute29 => p_pen_attribute29
3589 ,p_pen_attribute30 => p_pen_attribute30
3590 ,p_request_id => fnd_global.conc_request_id
3591 ,p_program_application_id => fnd_global.prog_appl_id
3592 ,p_program_id => fnd_global.conc_program_id
3593 ,p_program_update_date => sysdate
3594 ,p_object_version_number => l_object_version_number
3595 ,p_per_in_ler_id => p_per_in_ler_id
3596 ,p_bnft_typ_cd => p_bnft_typ_cd
3597 ,p_bnft_ordr_num => p_bnft_ordr_num
3598 ,p_prtt_enrt_rslt_stat_cd => p_prtt_enrt_rslt_stat_cd
3599 ,p_bnft_nnmntry_uom => p_bnft_nnmntry_uom
3600 ,p_comp_lvl_cd => p_comp_lvl_cd
3601 ,p_effective_date => trunc(p_effective_date)
3602 ,p_datetrack_mode => l_datetrack_mode
3603 ,p_multi_row_validate => p_multi_row_validate
3604 );
3605
3606 ben_global_enrt.reload_pen -- result globals re-loaded after update.
3607 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
3608 ,p_effective_date => p_effective_date
3609 ,p_global_pen_rec => l_global_pen_rec);
3610 ----call update for flex cedit entries for rate change
3611 if p_comp_lvl_cd in ('PLANFC', 'PLANIMP') then
3612 null;
3613 else
3614 if l_global_pen_rec.pgm_id is not null then
3615 open c_prtt_enrt;
3616 fetch c_prtt_enrt into l_prtt_enrt_rslt_id;
3617 close c_prtt_enrt;
3618 for i in c_flex_choice Loop
3619 l_prvdd_val := null;
3620 open c_bpl ( i.acty_base_rt_id ,
3621 i.bnft_prvdr_pool_id,
3622 l_prtt_enrt_rslt_id ) ;
3623 fetch c_bpl into l_prvdd_val ;
3624 close c_bpl ;
3625 --if there is amount change call the updating
3626 if g_debug then
3627 hr_utility.set_location( 'prvdd val ' || l_prvdd_val ||
3628 ' ; changed val ' || i.val , 1001);
3629 end if;
3630
3631 if l_prvdd_val is not null and l_prvdd_val <> i.val then
3632 ben_provider_pools.create_credit_ledger_entry
3633 ( p_person_id => p_person_id ,
3634 p_elig_per_elctbl_chc_id => i.elig_per_elctbl_chc_id ,
3635 p_per_in_ler_id => i.per_in_ler_id,
3636 p_business_group_id => p_business_group_id ,
3637 p_bnft_prvdr_pool_id => i.bnft_prvdr_pool_id,
3638 p_enrt_mthd_cd => p_enrt_mthd_cd,
3639 p_effective_date => p_effective_date );
3640 end if;
3641 end loop ;
3642 open c_elig_per_elctbl_chc;
3643 fetch c_elig_per_elctbl_chc into l_elig_per_elctbl_chc_id;
3644 close c_elig_per_elctbl_chc;
3645
3646 ben_provider_pools.accumulate_pools
3647 (p_validate => FALSE
3648 ,p_person_id => p_person_id
3649 ,p_elig_per_elctbl_chc_id => l_elig_per_elctbl_chc_id
3650 ,p_business_group_id => p_business_group_id
3651 ,p_enrt_mthd_cd => p_enrt_mthd_cd
3652 ,p_effective_date => p_effective_date
3653 );
3654
3655 end if; -- pgm_id is not null.
3656 end if;
3657
3658 for l_prem in c_prem loop
3659 l_step := 70;
3660 -- bug 158783. jcarpent reset l_ppe.prtt_prem_id
3661 l_ppe.prtt_prem_id:=null;
3662 /* Start of Changes for WWBUG: 1646442: added */
3663 open c_pel(l_prem.elig_per_elctbl_chc_id);
3664 fetch c_pel into l_pel;
3665 close c_pel;
3666
3667 ben_determine_date.rate_and_coverage_dates
3668 (p_which_dates_cd => 'R'
3669 ,p_date_mandatory_flag => 'Y'
3670 ,p_compute_dates_flag => 'Y'
3671 ,p_business_group_id => p_business_group_id
3672 ,P_PER_IN_LER_ID => p_per_in_ler_id
3673 ,P_PERSON_ID => p_person_id
3674 ,P_PGM_ID => p_pgm_id
3675 ,P_PL_ID => p_pl_id
3676 ,P_OIPL_ID => p_oipl_id
3677 ,P_LEE_RSN_ID => l_pel.lee_rsn_id
3678 ,P_ENRT_PERD_ID => l_pel.enrt_perd_id
3679 ,p_enrt_cvg_strt_dt => l_enrt_cvg_strt_dt --out
3680 ,p_enrt_cvg_strt_dt_cd => l_enrt_cvg_strt_dt_cd --out
3681 ,p_enrt_cvg_strt_dt_rl => l_enrt_cvg_strt_dt_rl --out
3682 ,p_rt_strt_dt => l_rt_strt_dt --out
3683 ,p_rt_strt_dt_cd => l_rt_strt_dt_cd --out
3684 ,p_rt_strt_dt_rl => l_rt_strt_dt_rl --out
3685 ,p_enrt_cvg_end_dt => l_enrt_cvg_end_dt --out
3686 ,p_enrt_cvg_end_dt_cd => l_enrt_cvg_end_dt_cd --out
3687 ,p_enrt_cvg_end_dt_rl => l_enrt_cvg_end_dt_rl --out
3688 ,p_rt_end_dt => l_rt_end_dt --out
3689 ,p_rt_end_dt_cd => l_rt_end_dt_cd --out
3690 ,p_rt_end_dt_rl => l_rt_end_dt_rl --out
3691 ,p_effective_date => p_effective_date
3692 ,p_lf_evt_ocrd_dt => nvl(l_prem.lf_evt_ocrd_dt,p_effective_date)
3693 );
3694
3695 l_ppe_dt_to_use := greatest(p_enrt_cvg_strt_dt,l_rt_strt_dt);
3696 /* End of Changes for WWBUG: 1646442 */
3697 /*
3698 CODE PRIOR TO WWBUG: 1646442
3699 open c_ppe(p_prtt_enrt_rslt_id, l_prem.actl_prem_id);
3700 */
3701 /* Start of Changes for WWBUG: 1646442 */
3702 open c_ppe(p_prtt_enrt_rslt_id, l_prem.actl_prem_id,l_ppe_dt_to_use);
3703 /* End of Changes for WWBUG: 1646442 */
3704 fetch c_ppe into l_ppe;
3705 close c_ppe;
3706 l_step := 71;
3707 if l_ppe.prtt_prem_id is not null then
3708 /********************* CODE PRIOR TO WWBUG: 1646442 *****
3709 *** moved this code below ****
3710 --
3711 -- Find the valid datetrack modes.
3712 --
3713 dt_api.find_dt_upd_modes
3714 (p_effective_date => p_effective_date,
3715 p_base_table_name => 'BEN_PRTT_PREM_F',
3716 p_base_key_column => 'prtt_prem_id',
3717 p_base_key_value => l_ppe.prtt_prem_id,
3718 p_correction => l_correction,
3719 p_update => l_update,
3720 p_update_override => l_update_override,
3721 p_update_change_insert => l_update_change_insert);
3722 --
3723 if l_update_override then
3724 --
3725 l_ppe_datetrack_mode := hr_api.g_update_override;
3726 --
3727 elsif l_update then
3728 --
3729 l_ppe_datetrack_mode := hr_api.g_update;
3730 --
3731 else
3732 --
3733 l_ppe_datetrack_mode := hr_api.g_correction;
3734 end if;
3735 ********************* END CODE PRIOR TO WWBUG: 1646442 *********/
3736 -- Because the benefit amount could have changed, and the premiums
3737 -- can be based on the benefit amount, re-calc it. It does a recalc
3738 -- if the benefit amount is entered at enrollment.
3739 -- PPE is from prtt-prem. prem is from enrt-prem.
3740 ben_PRTT_PREM_api.recalc_PRTT_PREM
3741 (p_prtt_prem_id => l_ppe.prtt_prem_id
3742 ,p_std_prem_uom => l_prem.uom
3743 ,p_std_prem_val => l_prem.val -- in/out
3744 ,p_actl_prem_id => l_prem.actl_prem_id
3745 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
3746 ,p_per_in_ler_id => p_per_in_ler_id
3747 ,p_ler_id => l_prem.ler_id
3748 ,p_lf_evt_ocrd_dt => l_prem.lf_evt_ocrd_dt
3749 ,p_elig_per_elctbl_chc_id => l_prem.elig_per_elctbl_chc_id
3750 ,p_enrt_bnft_id => p_enrt_bnft_id
3751 ,p_business_group_id => p_business_group_id
3752 ,p_effective_date => p_effective_date
3753 -- bof FONM
3754 ,p_enrt_cvg_strt_dt => nvl(l_enrt_cvg_strt_dt,l_ppe_dt_to_use)
3755 ,p_rt_strt_dt => l_rt_strt_dt
3756 -- eof FONM
3757 );
3758
3759 l_step := 72;
3760 ---For the Bug : 7133998
3761
3762 hr_utility.set_location('p_prtt_enrt_rslt_id,srav : '||p_prtt_enrt_rslt_id,1);
3763 hr_utility.set_location('l_prem.actl_prem_id : '||l_prem.actl_prem_id,1);
3764 hr_utility.set_location('l_ppe_dt_to_use : '||l_ppe_dt_to_use,1);
3765
3766 -----check if there are any future rows corresponding to the Previous LE's.
3767 --------7133998
3768 l_count := 0;
3769 hr_utility.set_location('srav,in else',1);
3770 for l_ppe1 in c_ppe1(p_prtt_enrt_rslt_id, l_prem.actl_prem_id,l_ppe_dt_to_use) loop
3771 l_count := l_count + 1;
3772 hr_utility.set_location('c_ppe1 found',1);
3773 hr_utility.set_location('l_ppe1.prtt_prem_id : '||l_ppe1.prtt_prem_id,1);
3774 ---bkup table
3775 insert into BEN_LE_CLSN_N_RSTR (
3776 BKUP_TBL_TYP_CD,
3777 LCR_ATTRIBUTE6,
3778 LCR_ATTRIBUTE7,
3779 LCR_ATTRIBUTE8,
3780 LCR_ATTRIBUTE9,
3781 LCR_ATTRIBUTE10,
3782 LCR_ATTRIBUTE11,
3783 LCR_ATTRIBUTE12,
3784 LCR_ATTRIBUTE13,
3785 LCR_ATTRIBUTE14,
3786 LCR_ATTRIBUTE15,
3787 LCR_ATTRIBUTE16,
3788 LCR_ATTRIBUTE17,
3789 LCR_ATTRIBUTE18,
3790 LCR_ATTRIBUTE19,
3791 LCR_ATTRIBUTE20,
3792 LCR_ATTRIBUTE21,
3793 LCR_ATTRIBUTE22,
3794 LCR_ATTRIBUTE23,
3795 LCR_ATTRIBUTE24,
3796 LCR_ATTRIBUTE25,
3797 LCR_ATTRIBUTE26,
3798 LCR_ATTRIBUTE27,
3799 LCR_ATTRIBUTE28,
3800 LCR_ATTRIBUTE29,
3801 LCR_ATTRIBUTE30,
3802 LAST_UPDATE_DATE,
3803 LAST_UPDATED_BY,
3804 LAST_UPDATE_LOGIN,
3805 CREATED_BY,
3806 CREATION_DATE,
3807 OBJECT_VERSION_NUMBER,
3808 REQUEST_ID,
3809 PROGRAM_APPLICATION_ID,
3810 PROGRAM_ID,
3811 PROGRAM_UPDATE_DATE,
3812 PER_IN_LER_ID,
3813 PER_IN_LER_ENDED_ID,
3814 BKUP_TBL_ID, -- PRTT_PREM_ID,
3815 EFFECTIVE_START_DATE,
3816 EFFECTIVE_END_DATE,
3817 STD_PREM_UOM,
3818 STD_PREM_VAL,
3819 ACTL_PREM_ID,
3820 PRTT_ENRT_RSLT_ID,
3821 BUSINESS_GROUP_ID,
3822 LCR_ATTRIBUTE_CATEGORY,
3823 LCR_ATTRIBUTE1,
3824 LCR_ATTRIBUTE2,
3825 LCR_ATTRIBUTE3,
3826 LCR_ATTRIBUTE4,
3827 LCR_ATTRIBUTE5
3828 )
3829 values (
3830 'BEN_PRTT_PREM_F_CORR',
3831 l_ppe1.PPE_ATTRIBUTE6,
3832 l_ppe1.PPE_ATTRIBUTE7,
3833 l_ppe1.PPE_ATTRIBUTE8,
3834 l_ppe1.PPE_ATTRIBUTE9,
3835 l_ppe1.PPE_ATTRIBUTE10,
3836 l_ppe1.PPE_ATTRIBUTE11,
3837 l_ppe1.PPE_ATTRIBUTE12,
3838 l_ppe1.PPE_ATTRIBUTE13,
3839 l_ppe1.PPE_ATTRIBUTE14,
3840 l_ppe1.PPE_ATTRIBUTE15,
3841 l_ppe1.PPE_ATTRIBUTE16,
3842 l_ppe1.PPE_ATTRIBUTE17,
3843 l_ppe1.PPE_ATTRIBUTE18,
3844 l_ppe1.PPE_ATTRIBUTE19,
3845 l_ppe1.PPE_ATTRIBUTE20,
3846 l_ppe1.PPE_ATTRIBUTE21,
3847 l_ppe1.PPE_ATTRIBUTE22,
3848 l_ppe1.PPE_ATTRIBUTE23,
3849 l_ppe1.PPE_ATTRIBUTE24,
3850 l_ppe1.PPE_ATTRIBUTE25,
3851 l_ppe1.PPE_ATTRIBUTE26,
3852 l_ppe1.PPE_ATTRIBUTE27,
3853 l_ppe1.PPE_ATTRIBUTE28,
3854 l_ppe1.PPE_ATTRIBUTE29,
3855 l_ppe1.PPE_ATTRIBUTE30,
3856 l_ppe1.LAST_UPDATE_DATE,
3857 l_ppe1.LAST_UPDATED_BY,
3858 l_ppe1.LAST_UPDATE_LOGIN,
3859 l_ppe1.CREATED_BY,
3860 l_ppe1.CREATION_DATE,
3861 l_ppe1.OBJECT_VERSION_NUMBER,
3862 l_ppe1.REQUEST_ID,
3863 l_ppe1.PROGRAM_APPLICATION_ID,
3864 l_ppe1.PROGRAM_ID,
3865 l_ppe1.PROGRAM_UPDATE_DATE,
3866 l_ppe1.PER_IN_LER_ID,
3867 p_per_in_ler_id,
3868 l_ppe1.PRTT_PREM_ID,
3869 l_ppe1.EFFECTIVE_START_DATE,
3870 l_ppe1.EFFECTIVE_END_DATE,
3871 l_ppe1.STD_PREM_UOM,
3872 l_ppe1.STD_PREM_VAL,
3873 l_ppe1.ACTL_PREM_ID,
3874 l_ppe1.PRTT_ENRT_RSLT_ID,
3875 l_ppe1.BUSINESS_GROUP_ID,
3876 l_ppe1.PPE_ATTRIBUTE_CATEGORY,
3877 l_ppe1.PPE_ATTRIBUTE1,
3878 l_ppe1.PPE_ATTRIBUTE2,
3879 l_ppe1.PPE_ATTRIBUTE3,
3880 l_ppe1.PPE_ATTRIBUTE4,
3881 l_ppe1.PPE_ATTRIBUTE5
3882 );
3883
3884 ben_prtt_prem_api.update_prtt_prem
3885 ( p_validate => FALSE
3886 ,p_prtt_prem_id => l_ppe1.prtt_prem_id
3887 ,p_effective_start_date => p_effective_start_date
3888 ,p_effective_end_date => p_effective_end_date
3889 ,p_per_in_ler_id => p_per_in_ler_id
3890 ,p_business_group_id => p_business_group_id
3891 ,p_prtt_enrt_rslt_id => l_ppe1.prtt_enrt_rslt_id
3892 ,p_object_version_number => l_ppe1.object_version_number
3893 ,p_request_id => fnd_global.conc_request_id
3894 ,p_program_application_id => fnd_global.prog_appl_id
3895 ,p_program_id => fnd_global.conc_program_id
3896 ,p_program_update_date => sysdate
3897 ,p_effective_date => l_ppe1.effective_start_date
3898 ,p_datetrack_mode => 'CORRECTION'
3899
3900 );
3901 end loop;
3902 open c_ppe(p_prtt_enrt_rslt_id, l_prem.actl_prem_id,l_ppe_dt_to_use);
3903 fetch c_ppe into l_ppe;
3904 close c_ppe;
3905 /* Start of Changes for WWBUG: 1646442 */
3906 /* moved from above */
3907 --
3908 If l_count = 0 then --------7133998
3909 -- Find the valid datetrack modes.
3910 --
3911 dt_api.find_dt_upd_modes
3912 (p_effective_date => l_ppe_dt_to_use,
3913 p_base_table_name => 'BEN_PRTT_PREM_F',
3914 p_base_key_column => 'prtt_prem_id',
3915 p_base_key_value => l_ppe.prtt_prem_id,
3916 p_correction => l_correction,
3917 p_update => l_update,
3918 p_update_override => l_update_override,
3919 p_update_change_insert => l_update_change_insert);
3920
3921 if l_update_override then
3922 --
3923 l_ppe_datetrack_mode := hr_api.g_update_override;
3924 --
3925 elsif l_update then
3926 --
3927 l_ppe_datetrack_mode := hr_api.g_update;
3928 --
3929 else
3930 --
3931 l_ppe_datetrack_mode := hr_api.g_correction;
3932 end if;
3933 /* End of Changes for WWBUG: 1646442 */
3934
3935 ben_prtt_prem_api.update_prtt_prem
3936 ( p_validate => FALSE
3937 ,p_prtt_prem_id => l_ppe.prtt_prem_id
3938 ,p_effective_start_date => p_effective_start_date
3939 ,p_effective_end_date => p_effective_end_date
3940 ,p_std_prem_uom => l_prem.uom
3941 ,p_std_prem_val => l_prem.val
3942 ,p_actl_prem_id => l_prem.actl_prem_id
3943 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
3944 ,p_per_in_ler_id => p_per_in_ler_id
3945 ,p_business_group_id => p_business_group_id
3946 ,p_object_version_number => l_ppe.object_version_number
3947 ,p_request_id => fnd_global.conc_request_id
3948 ,p_program_application_id => fnd_global.prog_appl_id
3949 ,p_program_id => fnd_global.conc_program_id
3950 ,p_program_update_date => sysdate
3951 /*
3952 CODE PRIOR TO WWBUG: 1646442
3953 ,p_effective_date => p_effective_date
3954 */
3955 /* Start of Changes for WWBUG: 1646442 */
3956 ,p_effective_date => l_ppe_dt_to_use
3957 /* End of Changes for WWBUG: 1646442 */
3958 ,p_datetrack_mode => l_ppe_datetrack_mode
3959 );
3960 end if;------7133998
3961 else
3962 ben_PRTT_PREM_api.recalc_PRTT_PREM
3963 (p_prtt_prem_id => null
3964 ,p_std_prem_uom => l_prem.uom
3965 ,p_std_prem_val => l_prem.val -- in/out
3966 ,p_actl_prem_id => l_prem.actl_prem_id
3967 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
3968 ,p_per_in_ler_id => p_per_in_ler_id
3969 ,p_ler_id => l_prem.ler_id
3970 ,p_lf_evt_ocrd_dt => l_prem.lf_evt_ocrd_dt
3971 ,p_elig_per_elctbl_chc_id => l_prem.elig_per_elctbl_chc_id
3972 ,p_enrt_bnft_id => p_enrt_bnft_id
3973 ,p_business_group_id => p_business_group_id
3974 ,p_effective_date => p_effective_date
3975 -- bof FONM
3976 ,p_enrt_cvg_strt_dt => nvl(l_enrt_cvg_strt_dt,l_ppe_dt_to_use)
3977 ,p_rt_strt_dt => l_rt_strt_dt
3978 -- eof FONM
3979 );
3980 l_step := 130;
3981 ben_prtt_prem_api.create_prtt_prem
3982 ( p_validate => FALSE
3983 ,p_prtt_prem_id => l_ppe.prtt_prem_id
3984 ,p_effective_start_date => p_effective_start_date
3985 ,p_effective_end_date => p_effective_end_date
3986 ,p_std_prem_uom => l_prem.uom
3987 ,p_std_prem_val => l_prem.val
3988 ,p_actl_prem_id => l_prem.actl_prem_id
3989 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
3990 ,p_per_in_ler_id => p_per_in_ler_id
3991 ,p_business_group_id => p_business_group_id
3992 ,p_object_version_number => l_ppe.object_version_number
3993 ,p_request_id => fnd_global.conc_request_id
3994 ,p_program_application_id => fnd_global.prog_appl_id
3995 ,p_program_id => fnd_global.conc_program_id
3996 ,p_program_update_date => sysdate
3997 /*
3998 CODE PRIOR TO WWBUG: 1646442
3999 ,p_effective_date => p_effective_date
4000 */
4001 /* Start of Changes for WWBUG: 1646442 */
4002 ,p_effective_date => l_ppe_dt_to_use
4003 /* End of Changes for WWBUG: 1646442 */
4004 );
4005 --
4006 end if;
4007 end loop;
4008
4009 -- un-end dpnt coverage for existing dependents.
4010 for l_egd in c_egd loop
4011 --
4012 -- Find the valid datetrack modes.
4013 --
4014 dt_api.find_dt_upd_modes
4015 (p_effective_date => p_effective_date,
4016 p_base_table_name => 'BEN_ELIG_CVRD_DPNT_F',
4017 p_base_key_column => 'elig_cvrd_dpnt_id',
4018 p_base_key_value => l_egd.elig_cvrd_dpnt_id,
4019 p_correction => l_correction,
4020 p_update => l_update,
4021 p_update_override => l_update_override,
4022 p_update_change_insert => l_update_change_insert);
4023
4024 if l_update_override then
4025 l_egd_datetrack_mode := hr_api.g_update_override;
4026 elsif l_update then
4027 l_egd_datetrack_mode := hr_api.g_update;
4028 else
4029 l_egd_datetrack_mode := hr_api.g_correction;
4030 end if;
4031
4032 ben_elig_cvrd_dpnt_api.update_elig_cvrd_dpnt(
4033 p_elig_cvrd_dpnt_id => l_egd.elig_cvrd_dpnt_id,
4034 p_effective_start_date => p_effective_start_date,
4035 p_effective_end_date => p_effective_end_date,
4036 p_business_group_id => p_business_group_id,
4037 p_per_in_ler_id => p_per_in_ler_id,
4038 p_cvg_thru_dt => hr_api.g_eot,
4039 p_object_version_number => l_egd.object_version_number,
4040 p_datetrack_mode => l_egd_datetrack_mode,
4041 p_request_id => fnd_global.conc_request_id,
4042 p_program_application_id => fnd_global.prog_appl_id,
4043 p_program_id => fnd_global.conc_program_id,
4044 p_program_update_date => sysdate,
4045 p_effective_date => p_effective_date,
4046 p_multi_row_actn => FALSE);
4047 --
4048 -- Bug 1418754
4049 --
4050 ben_ELIG_CVRD_DPNT_api.chk_max_num_dpnt_for_pen (
4051 p_prtt_enrt_rslt_id => p_PRTT_ENRT_RSLT_ID,
4052 p_effective_date => p_effective_date,
4053 p_business_group_id => p_business_group_id);
4054 --
4055 end loop;
4056 --
4057 -- write to the change event log. thayden.
4058 --
4059 ben_ext_chlg.log_benefit_chg
4060 (p_action => 'UPDATE'
4061 ,p_pl_id => p_pl_id
4062 ,p_old_pl_id => l_global_pen_rec.pl_id
4063 ,p_oipl_id => p_oipl_id
4064 ,p_old_oipl_id => l_global_pen_rec.oipl_id
4065 ,p_enrt_cvg_strt_dt => p_enrt_cvg_strt_dt
4066 ,p_old_enrt_cvg_strt_dt => l_global_pen_rec.enrt_cvg_strt_dt
4067 ,p_bnft_amt => p_bnft_amt
4068 ,p_old_bnft_amt => l_global_pen_rec.bnft_amt
4069 ,p_pen_attribute1 => p_pen_attribute1
4070 ,p_old_pen_attribute1 => l_global_pen_rec.pen_attribute1
4071 ,p_pen_attribute2 => p_pen_attribute2
4072 ,p_old_pen_attribute2 => l_global_pen_rec.pen_attribute2
4073 ,p_pen_attribute3 => p_pen_attribute3
4074 ,p_old_pen_attribute3 => l_global_pen_rec.pen_attribute3
4075 ,p_pen_attribute4 => p_pen_attribute4
4076 ,p_old_pen_attribute4 => l_global_pen_rec.pen_attribute4
4077 ,p_pen_attribute5 => p_pen_attribute5
4078 ,p_old_pen_attribute5 => l_global_pen_rec.pen_attribute5
4079 ,p_pen_attribute6 => p_pen_attribute6
4080 ,p_old_pen_attribute6 => l_global_pen_rec.pen_attribute6
4081 ,p_pen_attribute7 => p_pen_attribute7
4082 ,p_old_pen_attribute7 => l_global_pen_rec.pen_attribute7
4083 ,p_pen_attribute8 => p_pen_attribute8
4084 ,p_old_pen_attribute8 => l_global_pen_rec.pen_attribute8
4085 ,p_pen_attribute9 => p_pen_attribute9
4086 ,p_old_pen_attribute9 => l_global_pen_rec.pen_attribute9
4087 ,p_pen_attribute10 => p_pen_attribute10
4088 ,p_old_pen_attribute10 => l_global_pen_rec.pen_attribute10
4089 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
4090 ,p_per_in_ler_id => l_global_pen_rec.per_in_ler_id
4091 ,p_person_id => p_person_id
4092 ,p_business_group_id => p_business_group_id
4093 ,p_effective_date => p_effective_date
4094 );
4095 -- Bug 3866580
4096 --
4097 -- Find out the Option Type of Plan Type of the Plan being enrolled in
4098 /*
4099 It is better to go by savings plan flag rather option type code as
4100 the type code is only informational
4101 open c_pl_typ_opt_typ_cd (l_pl_rec.pl_typ_id, p_effective_date);
4102 fetch c_pl_typ_opt_typ_cd into l_pl_typ_opt_typ_cd;
4103 close c_pl_typ_opt_typ_cd;
4104 --
4105 */
4106 if ( l_pl_rec.svgs_pl_flag = 'Y' and p_oipl_id is null and l_pl_rec.ENRT_PL_OPT_FLAG = 'Y' )
4107 or ( l_pl_rec.svgs_pl_flag = 'N')
4108 then
4109 /*
4110 if ( l_pl_typ_opt_typ_cd = 'SVG' and p_oipl_id is null and l_pl_rec.ENRT_PL_OPT_FLAG = 'Y' )
4111 or ( nvl(l_pl_typ_opt_typ_cd, 'XXXX') <> 'SVG' )
4112 then
4113 /*
4114 Commented this part, as Enrollment Action Items for all enrollment in "Plans"
4115 as well as "Option In Plans" should be determined except for savings plan. In case
4116 of savings plan, enrollment actions items should be determined only if enrollment is in
4117 plan level (i.e. p_oipl_id = NULL
4118 --
4119 If l_pl_rec.enrt_pl_opt_flag = 'N'
4120 or (l_pl_rec.enrt_pl_opt_flag = 'Y' and l_global_pen_rec.oipl_id is NULL) then
4121 */
4122 l_step := 165;
4123 ben_enrollment_action_items.determine_action_items
4124 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
4125 ,p_effective_date => p_effective_date
4126 ,p_business_group_id => p_business_group_id
4127 ,p_datetrack_mode => l_datetrack_mode
4128 ,p_suspend_flag => p_suspend_flag
4129 ,p_rslt_object_version_number => l_object_version_number
4130 ,p_enrt_bnft_id => p_enrt_bnft_id
4131 ,p_post_rslt_flag => l_post_rslt_flag
4132 ,p_dpnt_actn_warning => p_dpnt_actn_warning
4133 ,p_bnf_actn_warning => p_bnf_actn_warning
4134 ,p_ctfn_actn_warning => p_ctfn_actn_warning
4135 );
4136 ben_global_enrt.get_pen -- result
4137 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
4138 ,p_effective_date => p_effective_date
4139 ,p_global_pen_rec => l_global_pen_rec);
4140 l_step :=71;
4141 open c_interim_enrt;
4142 fetch c_interim_enrt into p_prtt_enrt_interim_id;
4143 close c_interim_enrt;
4144 else
4145 -- set the out parms that would have come from action item.
4146 p_dpnt_actn_warning := false;
4147 p_bnf_actn_warning := false;
4148 p_ctfn_actn_warning := false;
4149 p_suspend_flag := l_global_pen_rec.sspndd_flag;
4150 if l_global_pen_rec.sspndd_flag='Y' then
4151 open c_interim_enrt;
4152 fetch c_interim_enrt into p_prtt_enrt_interim_id;
4153 close c_interim_enrt;
4154 end if;
4155 end if;
4156 end if;
4157 if g_debug then
4158 hr_utility.set_location(l_proc, 60);
4159 end if;
4160 --
4161 -- When in validation only mode raise the Validate_Enabled exception
4162 --
4163 if p_validate then
4164 raise hr_api.validate_enabled;
4165 end if;
4166 --
4167 -- Set all output arguments
4168 --
4169 p_object_version_number := l_object_version_number;
4170 p_effective_start_date := l_effective_start_date;
4171 p_effective_end_date := l_effective_end_date;
4172 if g_debug then
4173 hr_utility.set_location(' Leaving:'||l_proc, 70);
4174 end if;
4175 exception
4176 when hr_api.validate_enabled then
4177 --
4178 -- As the Validate_Enabled exception has been raised
4179 -- we must rollback to the savepoint
4180 --
4181 ROLLBACK TO update_ENROLLMENT;
4182 --
4183 -- Only set output warning arguments
4184 -- (Any key or derived arguments must be set to null
4185 -- when validation only mode is being used.)
4186 --
4187 if g_debug then
4188 hr_utility.set_location(' Leaving:'||l_proc, 80);
4189 end if;
4190 when others then
4191 --
4192 -- A validation or unexpected error has occured
4193 --
4194 ROLLBACK TO update_ENROLLMENT;
4195 rpt_error(p_proc => l_proc, p_step => l_step);
4196 p_effective_start_date := null; --nocopy change
4197 p_effective_end_date := null; --nocopy change
4198 raise;
4199 end update_ENROLLMENT;
4200 --
4201 -- ----------------------------------------------------------------------------
4202 -- |------------------------< update_PRTT_ENRT_RESULT >--- ------------------|
4203 -- ----------------------------------------------------------------------------
4204 --
4205 procedure update_PRTT_ENRT_RESULT
4206 (p_validate in boolean default false
4207 ,p_prtt_enrt_rslt_id in number
4208 ,p_effective_start_date out nocopy date
4209 ,p_effective_end_date out nocopy date
4210 ,p_business_group_id in number default hr_api.g_number
4211 ,p_oipl_id in number default hr_api.g_number
4212 ,p_person_id in number default hr_api.g_number
4213 ,p_assignment_id in number default hr_api.g_number
4214 ,p_pgm_id in number default hr_api.g_number
4215 ,p_pl_id in number default hr_api.g_number
4216 ,p_rplcs_sspndd_rslt_id in number default hr_api.g_number
4217 ,p_ptip_id in number default hr_api.g_number
4218 ,p_pl_typ_id in number default hr_api.g_number
4219 ,p_ler_id in number default hr_api.g_number
4220 ,p_sspndd_flag in varchar2 default hr_api.g_varchar2
4221 ,p_prtt_is_cvrd_flag in varchar2 default hr_api.g_varchar2
4222 ,p_bnft_amt in number default hr_api.g_number
4223 ,p_uom in varchar2 default hr_api.g_varchar2
4224 ,p_orgnl_enrt_dt in date default hr_api.g_date
4225 ,p_enrt_mthd_cd in varchar2 default hr_api.g_varchar2
4226 ,p_no_lngr_elig_flag in varchar2 default hr_api.g_varchar2
4227 ,p_enrt_ovridn_flag in varchar2 default hr_api.g_varchar2
4228 ,p_enrt_ovrid_rsn_cd in varchar2 default hr_api.g_varchar2
4229 ,p_erlst_deenrt_dt in date default hr_api.g_date
4230 ,p_enrt_cvg_strt_dt in date default hr_api.g_date
4231 ,p_enrt_cvg_thru_dt in date default hr_api.g_date
4232 ,p_enrt_ovrid_thru_dt in date default hr_api.g_date
4233 ,p_pl_ordr_num in number default hr_api.g_number
4234 ,p_plip_ordr_num in number default hr_api.g_number
4235 ,p_ptip_ordr_num in number default hr_api.g_number
4236 ,p_oipl_ordr_num in number default hr_api.g_number
4237 ,p_pen_attribute_category in varchar2 default hr_api.g_varchar2
4238 ,p_pen_attribute1 in varchar2 default hr_api.g_varchar2
4239 ,p_pen_attribute2 in varchar2 default hr_api.g_varchar2
4240 ,p_pen_attribute3 in varchar2 default hr_api.g_varchar2
4241 ,p_pen_attribute4 in varchar2 default hr_api.g_varchar2
4242 ,p_pen_attribute5 in varchar2 default hr_api.g_varchar2
4243 ,p_pen_attribute6 in varchar2 default hr_api.g_varchar2
4244 ,p_pen_attribute7 in varchar2 default hr_api.g_varchar2
4245 ,p_pen_attribute8 in varchar2 default hr_api.g_varchar2
4246 ,p_pen_attribute9 in varchar2 default hr_api.g_varchar2
4247 ,p_pen_attribute10 in varchar2 default hr_api.g_varchar2
4248 ,p_pen_attribute11 in varchar2 default hr_api.g_varchar2
4249 ,p_pen_attribute12 in varchar2 default hr_api.g_varchar2
4250 ,p_pen_attribute13 in varchar2 default hr_api.g_varchar2
4251 ,p_pen_attribute14 in varchar2 default hr_api.g_varchar2
4252 ,p_pen_attribute15 in varchar2 default hr_api.g_varchar2
4253 ,p_pen_attribute16 in varchar2 default hr_api.g_varchar2
4254 ,p_pen_attribute17 in varchar2 default hr_api.g_varchar2
4255 ,p_pen_attribute18 in varchar2 default hr_api.g_varchar2
4256 ,p_pen_attribute19 in varchar2 default hr_api.g_varchar2
4257 ,p_pen_attribute20 in varchar2 default hr_api.g_varchar2
4258 ,p_pen_attribute21 in varchar2 default hr_api.g_varchar2
4259 ,p_pen_attribute22 in varchar2 default hr_api.g_varchar2
4260 ,p_pen_attribute23 in varchar2 default hr_api.g_varchar2
4261 ,p_pen_attribute24 in varchar2 default hr_api.g_varchar2
4262 ,p_pen_attribute25 in varchar2 default hr_api.g_varchar2
4263 ,p_pen_attribute26 in varchar2 default hr_api.g_varchar2
4264 ,p_pen_attribute27 in varchar2 default hr_api.g_varchar2
4265 ,p_pen_attribute28 in varchar2 default hr_api.g_varchar2
4266 ,p_pen_attribute29 in varchar2 default hr_api.g_varchar2
4267 ,p_pen_attribute30 in varchar2 default hr_api.g_varchar2
4268 ,p_request_id in number default hr_api.g_number
4269 ,p_program_application_id in number default hr_api.g_number
4270 ,p_program_id in number default hr_api.g_number
4271 ,p_program_update_date in date default hr_api.g_date
4272 ,p_object_version_number in out nocopy number
4273 ,p_per_in_ler_id in number default hr_api.g_number
4274 ,p_bnft_typ_cd in varchar2 default hr_api.g_varchar2
4275 ,p_bnft_ordr_num in number default hr_api.g_number
4276 ,p_prtt_enrt_rslt_stat_cd in varchar2 default hr_api.g_varchar2
4277 ,p_bnft_nnmntry_uom in varchar2 default hr_api.g_varchar2
4278 ,p_comp_lvl_cd in varchar2 default hr_api.g_varchar2
4279 ,p_effective_date in date
4280 ,p_datetrack_mode in varchar2
4281 ,p_multi_row_validate in boolean default TRUE
4282 ) is
4283 --
4284 -- Declare cursors and local variables
4285 --
4286 l_proc varchar2(72) ; -- := g_package||'update_PRTT_ENRT_RESULT';
4287 l_object_version_number ben_prtt_enrt_rslt_f.object_version_number%TYPE;
4288 l_effective_start_date ben_prtt_enrt_rslt_f.effective_start_date%TYPE;
4289 l_effective_end_date ben_prtt_enrt_rslt_f.effective_end_date%TYPE;
4290
4291 --
4292 cursor c_old_rslt is
4293 select *
4294 from ben_prtt_enrt_rslt_f
4295 where prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
4296 and prtt_enrt_rslt_stat_cd is null
4297 and p_effective_date between effective_start_date and effective_end_date ;
4298 l_old_rslt c_old_rslt%rowtype ;
4299
4300 -- if there is entry for the same id
4301 -- dont create new value , the backout must restore
4302 -- origianl entry.
4303 cursor c_bckup_tbl_restore (
4304 c_pil_end_id number ,
4305 c_pen_id number ,
4306 c_pil_id number ,
4307 c_eff_strt_dt date ,
4308 c_eff_end_dt date ,
4309 c_cvg_strt_dt date ,
4310 c_cvg_thru_dt date ,
4311 c_pen_stat_cd varchar2 ) is
4312 select 'x'
4313 from BEN_LE_CLSN_N_RSTR
4314 where bkup_tbl_id = c_pen_id
4315 and ((per_in_ler_id = c_pil_id
4316 and per_in_ler_ended_id = c_pil_end_id)
4317 or per_in_ler_ended_id = c_pil_id) -- 7197868
4318 and BKUP_TBL_TYP_CD = 'BEN_PRTT_ENRT_RSLT_F_CORR'
4319 union
4320 select 'x'
4321 from BEN_LE_CLSN_N_RSTR
4322 where bkup_tbl_id = c_pen_id
4323 and per_in_ler_id = c_pil_id
4324 and BKUP_TBL_TYP_CD = 'BEN_PRTT_ENRT_RSLT_F'
4325 and c_eff_strt_dt = EFFECTIVE_START_DATE
4326 and c_eff_end_dt = EFFECTIVE_END_DATE
4327 and c_cvg_strt_dt = ENRT_CVG_STRT_DT
4328 and c_cvg_thru_dt = ENRT_CVG_THRU_DT
4329 and nvl(c_pen_stat_cd,'-1') = nvl(PRTT_ENRT_RSLT_STAT_CD,'-1')
4330 ;
4331
4332 l_env_rec ben_env_object.g_global_env_rec_type;
4333
4334 l_dummy varchar2(1) ;
4335
4336 --
4337 begin
4338 --
4339 g_debug := hr_utility.debug_enabled;
4340 if g_debug then
4341 l_proc := g_package||'update_PRTT_ENRT_RESULT';
4342 hr_utility.set_location('Entering:'|| l_proc, 10);
4343 end if;
4344 g_multi_rows_validate := p_multi_row_validate;
4345 --
4346 -- Issue a savepoint if operating in validation only mode
4347 --
4348 savepoint update_PRTT_ENRT_RESULT;
4349 --
4350 if fnd_global.conc_request_id in (0,-1) and
4351 p_business_group_id <> hr_api.g_number then
4352 --
4353 --bug#3568529
4354 ben_env_object.get(p_rec => l_env_rec);
4355 if l_env_rec.benefit_action_id is null then
4356 --
4357 ben_env_object.init(p_business_group_id => p_business_group_id,
4358 p_effective_date => p_effective_date,
4359 p_thread_id => 1,
4360 p_chunk_size => 1,
4361 p_threads => 1,
4362 p_max_errors => 1,
4363 p_benefit_action_id => null);
4364 end if;
4365 --
4366 end if;
4367 --
4368 if g_debug then
4369 hr_utility.set_location(l_proc, 20);
4370 hr_utility.set_location(' old per in ler id ' || l_old_rslt.per_in_ler_id, 99 );
4371 hr_utility.set_location(' new per in ler id ' || p_per_in_ler_id, 99 );
4372 hr_utility.set_location(' mode ' || p_datetrack_mode, 99 );
4373
4374 end if;
4375 --
4376 -- Process Logic
4377 --
4378 l_object_version_number := p_object_version_number;
4379 --
4380 -- whne the mode is correction and the old per_in_ler id is not the same of
4381 -- new per_in_ler_id and effective state date is same of effecitve date
4382 -- then copy the result record to backup table
4383 -- when the open LE then gain dpnt ,then process the opne on the same dt of GD
4384 -- the result of GD are lost. because the per_in_ler id of open updated in gd
4385
4386 --bug # 3086161
4387 if p_datetrack_mode = hr_api.g_correction and p_per_in_ler_id <> hr_api.g_number then
4388 open c_old_rslt ;
4389 fetch c_old_rslt into l_old_rslt ;
4390 close c_old_rslt ;
4391 if l_old_rslt.per_in_ler_id <> p_per_in_ler_id
4392 and p_effective_date=l_old_rslt.effective_start_date then
4393
4394 hr_utility.set_location(' old per in ler id ' || l_old_rslt.per_in_ler_id, 99 );
4395 hr_utility.set_location(' new per in ler id ' || p_per_in_ler_id, 99 );
4396 hr_utility.set_location(' corrected result id ' ||p_prtt_enrt_rslt_id , 99 );
4397 hr_utility.set_location(' mode ' || p_datetrack_mode, 99 );
4398 hr_utility.set_location(' insertin the row of ' || p_prtt_enrt_rslt_id , 99 );
4399
4400
4401 --- if the update called to reverse the stored row from
4402 --- from backup table dont insert to backup table
4403 open c_bckup_tbl_restore (
4404 p_per_in_ler_id ,
4405 p_prtt_enrt_rslt_id ,
4406 l_old_rslt.per_in_ler_id,
4407 l_old_rslt.EFFECTIVE_START_DATE,
4408 l_old_rslt.EFFECTIVE_END_DATE ,
4409 l_old_rslt.ENRT_CVG_STRT_DT ,
4410 l_old_rslt.ENRT_CVG_THRU_DT ,
4411 l_old_rslt.PRTT_ENRT_RSLT_STAT_CD ) ;
4412 fetch c_bckup_tbl_restore into l_dummy ;
4413 if c_bckup_tbl_restore%notfound then
4414 hr_utility.set_location(' backup row not found ' || p_prtt_enrt_rslt_id , 99 );
4415
4416 insert into BEN_LE_CLSN_N_RSTR (
4417 BKUP_TBL_TYP_CD,
4418 COMP_LVL_CD,
4419 LCR_ATTRIBUTE16,
4420 LCR_ATTRIBUTE17,
4421 LCR_ATTRIBUTE18,
4422 LCR_ATTRIBUTE19,
4423 LCR_ATTRIBUTE20,
4424 LCR_ATTRIBUTE21,
4425 LCR_ATTRIBUTE22,
4426 LCR_ATTRIBUTE23,
4427 LCR_ATTRIBUTE24,
4428 LCR_ATTRIBUTE25,
4429 LCR_ATTRIBUTE26,
4430 LCR_ATTRIBUTE27,
4431 LCR_ATTRIBUTE28,
4432 LCR_ATTRIBUTE29,
4433 LCR_ATTRIBUTE30,
4434 LAST_UPDATE_DATE,
4435 LAST_UPDATED_BY,
4436 LAST_UPDATE_LOGIN,
4437 CREATED_BY,
4438 CREATION_DATE,
4439 REQUEST_ID,
4440 PROGRAM_APPLICATION_ID,
4441 PROGRAM_ID,
4442 PROGRAM_UPDATE_DATE,
4443 OBJECT_VERSION_NUMBER,
4444 BKUP_TBL_ID, -- PRTT_ENRT_RSLT_ID,
4445 EFFECTIVE_START_DATE,
4446 EFFECTIVE_END_DATE,
4447 ENRT_CVG_STRT_DT,
4448 ENRT_CVG_THRU_DT,
4449 SSPNDD_FLAG,
4450 PRTT_IS_CVRD_FLAG,
4451 BNFT_AMT,
4452 BNFT_NNMNTRY_UOM,
4453 BNFT_TYP_CD,
4454 UOM,
4455 ORGNL_ENRT_DT,
4456 ENRT_MTHD_CD,
4457 ENRT_OVRIDN_FLAG,
4458 ENRT_OVRID_RSN_CD,
4459 ERLST_DEENRT_DT,
4460 ENRT_OVRID_THRU_DT,
4461 NO_LNGR_ELIG_FLAG,
4462 BNFT_ORDR_NUM,
4463 PERSON_ID,
4464 ASSIGNMENT_ID,
4465 PGM_ID,
4466 PRTT_ENRT_RSLT_STAT_CD,
4467 PL_ID,
4468 OIPL_ID,
4469 PTIP_ID,
4470 PL_TYP_ID,
4471 LER_ID,
4472 PER_IN_LER_ID,
4473 RPLCS_SSPNDD_RSLT_ID,
4474 BUSINESS_GROUP_ID,
4475 LCR_ATTRIBUTE_CATEGORY,
4476 LCR_ATTRIBUTE1,
4477 LCR_ATTRIBUTE2,
4478 LCR_ATTRIBUTE3,
4479 LCR_ATTRIBUTE4,
4480 LCR_ATTRIBUTE5,
4481 LCR_ATTRIBUTE6,
4482 LCR_ATTRIBUTE7,
4483 LCR_ATTRIBUTE8,
4484 LCR_ATTRIBUTE9,
4485 LCR_ATTRIBUTE10,
4486 LCR_ATTRIBUTE11,
4487 LCR_ATTRIBUTE12,
4488 LCR_ATTRIBUTE13,
4489 LCR_ATTRIBUTE14,
4490 LCR_ATTRIBUTE15 ,
4491 PER_IN_LER_ENDED_ID,
4492 PL_ORDR_NUM,
4493 PLIP_ORDR_NUM,
4494 PTIP_ORDR_NUM,
4495 OIPL_ORDR_NUM)
4496 values (
4497 'BEN_PRTT_ENRT_RSLT_F_CORR',
4498 l_old_rslt.COMP_LVL_CD,
4499 l_old_rslt.PEN_ATTRIBUTE16,
4500 l_old_rslt.PEN_ATTRIBUTE17,
4501 l_old_rslt.PEN_ATTRIBUTE18,
4502 l_old_rslt.PEN_ATTRIBUTE19,
4503 l_old_rslt.PEN_ATTRIBUTE20,
4504 l_old_rslt.PEN_ATTRIBUTE21,
4505 l_old_rslt.PEN_ATTRIBUTE22,
4506 l_old_rslt.PEN_ATTRIBUTE23,
4507 l_old_rslt.PEN_ATTRIBUTE24,
4508 l_old_rslt.PEN_ATTRIBUTE25,
4509 l_old_rslt.PEN_ATTRIBUTE26,
4510 l_old_rslt.PEN_ATTRIBUTE27,
4511 l_old_rslt.PEN_ATTRIBUTE28,
4512 l_old_rslt.PEN_ATTRIBUTE29,
4513 l_old_rslt.PEN_ATTRIBUTE30,
4514 l_old_rslt.LAST_UPDATE_DATE,
4515 l_old_rslt.LAST_UPDATED_BY,
4516 l_old_rslt.LAST_UPDATE_LOGIN,
4517 l_old_rslt.CREATED_BY,
4518 l_old_rslt.CREATION_DATE,
4519 l_old_rslt.REQUEST_ID,
4520 l_old_rslt.PROGRAM_APPLICATION_ID,
4521 l_old_rslt.PROGRAM_ID,
4522 l_old_rslt.PROGRAM_UPDATE_DATE,
4523 l_old_rslt.OBJECT_VERSION_NUMBER,
4524 l_old_rslt.PRTT_ENRT_RSLT_ID,
4525 l_old_rslt.EFFECTIVE_START_DATE,
4526 l_old_rslt.EFFECTIVE_END_DATE,
4527 l_old_rslt.ENRT_CVG_STRT_DT,
4528 l_old_rslt.ENRT_CVG_THRU_DT,
4529 l_old_rslt.SSPNDD_FLAG,
4530 l_old_rslt.PRTT_IS_CVRD_FLAG,
4531 l_old_rslt.BNFT_AMT,
4532 l_old_rslt.BNFT_NNMNTRY_UOM,
4533 l_old_rslt.BNFT_TYP_CD,
4534 l_old_rslt.UOM,
4535 l_old_rslt.ORGNL_ENRT_DT,
4536 l_old_rslt.ENRT_MTHD_CD,
4537 l_old_rslt.ENRT_OVRIDN_FLAG,
4538 l_old_rslt.ENRT_OVRID_RSN_CD,
4539 l_old_rslt.ERLST_DEENRT_DT,
4540 l_old_rslt.ENRT_OVRID_THRU_DT,
4541 l_old_rslt.NO_LNGR_ELIG_FLAG,
4542 l_old_rslt.BNFT_ORDR_NUM,
4543 l_old_rslt.PERSON_ID,
4544 l_old_rslt.ASSIGNMENT_ID,
4545 l_old_rslt.PGM_ID,
4546 l_old_rslt.PRTT_ENRT_RSLT_STAT_CD,
4547 l_old_rslt.PL_ID,
4548 l_old_rslt.OIPL_ID,
4549 l_old_rslt.PTIP_ID,
4550 l_old_rslt.PL_TYP_ID,
4551 l_old_rslt.LER_ID,
4552 l_old_rslt.PER_IN_LER_ID,
4553 l_old_rslt.RPLCS_SSPNDD_RSLT_ID,
4554 l_old_rslt.BUSINESS_GROUP_ID,
4555 l_old_rslt.PEN_ATTRIBUTE_CATEGORY,
4556 l_old_rslt.PEN_ATTRIBUTE1,
4557 l_old_rslt.PEN_ATTRIBUTE2,
4558 l_old_rslt.PEN_ATTRIBUTE3,
4559 l_old_rslt.PEN_ATTRIBUTE4,
4560 l_old_rslt.PEN_ATTRIBUTE5,
4561 l_old_rslt.PEN_ATTRIBUTE6,
4562 l_old_rslt.PEN_ATTRIBUTE7,
4563 l_old_rslt.PEN_ATTRIBUTE8,
4564 l_old_rslt.PEN_ATTRIBUTE9,
4565 l_old_rslt.PEN_ATTRIBUTE10,
4566 l_old_rslt.PEN_ATTRIBUTE11,
4567 l_old_rslt.PEN_ATTRIBUTE12,
4568 l_old_rslt.PEN_ATTRIBUTE13,
4569 l_old_rslt.PEN_ATTRIBUTE14,
4570 l_old_rslt.PEN_ATTRIBUTE15,
4571 p_per_in_ler_id ,
4572 l_old_rslt.PL_ORDR_NUM,
4573 l_old_rslt.PLIP_ORDR_NUM,
4574 l_old_rslt.PTIP_ORDR_NUM,
4575 l_old_rslt.OIPL_ORDR_NUM
4576 );
4577 end if;
4578 close c_bckup_tbl_restore ;
4579
4580
4581 end if ;
4582 --eof bug # 3086161
4583
4584
4585
4586 end if ;
4587
4588 begin
4589 --
4590 -- Start of API User Hook for the before hook of update_PRTT_ENRT_RESULT
4591 --
4592 ben_PRTT_ENRT_RESULT_bk2.update_PRTT_ENRT_RESULT_b
4593 (
4594 p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
4595 ,p_business_group_id => p_business_group_id
4596 ,p_oipl_id => p_oipl_id
4597 ,p_person_id => p_person_id
4598 ,p_assignment_id => p_assignment_id
4599 ,p_pgm_id => p_pgm_id
4600 ,p_pl_id => p_pl_id
4601 ,p_rplcs_sspndd_rslt_id => p_rplcs_sspndd_rslt_id
4602 ,p_ptip_id => p_ptip_id
4603 ,p_pl_typ_id => p_pl_typ_id
4604 ,p_ler_id => p_ler_id
4605 ,p_sspndd_flag => p_sspndd_flag
4606 ,p_prtt_is_cvrd_flag => p_prtt_is_cvrd_flag
4607 ,p_bnft_amt => p_bnft_amt
4608 ,p_uom => p_uom
4609 ,p_orgnl_enrt_dt => p_orgnl_enrt_dt
4610 ,p_enrt_mthd_cd => p_enrt_mthd_cd
4611 ,p_no_lngr_elig_flag => p_no_lngr_elig_flag
4612 ,p_enrt_ovridn_flag => p_enrt_ovridn_flag
4613 ,p_enrt_ovrid_rsn_cd => p_enrt_ovrid_rsn_cd
4614 ,p_erlst_deenrt_dt => p_erlst_deenrt_dt
4615 ,p_enrt_cvg_strt_dt => p_enrt_cvg_strt_dt
4616 ,p_enrt_cvg_thru_dt => p_enrt_cvg_thru_dt
4617 ,p_enrt_ovrid_thru_dt => p_enrt_ovrid_thru_dt
4618 ,p_pl_ordr_num => p_pl_ordr_num
4619 ,p_plip_ordr_num => p_plip_ordr_num
4620 ,p_ptip_ordr_num => p_ptip_ordr_num
4621 ,p_oipl_ordr_num => p_oipl_ordr_num
4622 ,p_pen_attribute_category => p_pen_attribute_category
4623 ,p_pen_attribute1 => p_pen_attribute1
4624 ,p_pen_attribute2 => p_pen_attribute2
4625 ,p_pen_attribute3 => p_pen_attribute3
4626 ,p_pen_attribute4 => p_pen_attribute4
4627 ,p_pen_attribute5 => p_pen_attribute5
4628 ,p_pen_attribute6 => p_pen_attribute6
4629 ,p_pen_attribute7 => p_pen_attribute7
4630 ,p_pen_attribute8 => p_pen_attribute8
4631 ,p_pen_attribute9 => p_pen_attribute9
4632 ,p_pen_attribute10 => p_pen_attribute10
4633 ,p_pen_attribute11 => p_pen_attribute11
4634 ,p_pen_attribute12 => p_pen_attribute12
4635 ,p_pen_attribute13 => p_pen_attribute13
4636 ,p_pen_attribute14 => p_pen_attribute14
4637 ,p_pen_attribute15 => p_pen_attribute15
4638 ,p_pen_attribute16 => p_pen_attribute16
4639 ,p_pen_attribute17 => p_pen_attribute17
4640 ,p_pen_attribute18 => p_pen_attribute18
4641 ,p_pen_attribute19 => p_pen_attribute19
4642 ,p_pen_attribute20 => p_pen_attribute20
4643 ,p_pen_attribute21 => p_pen_attribute21
4644 ,p_pen_attribute22 => p_pen_attribute22
4645 ,p_pen_attribute23 => p_pen_attribute23
4646 ,p_pen_attribute24 => p_pen_attribute24
4647 ,p_pen_attribute25 => p_pen_attribute25
4648 ,p_pen_attribute26 => p_pen_attribute26
4649 ,p_pen_attribute27 => p_pen_attribute27
4650 ,p_pen_attribute28 => p_pen_attribute28
4651 ,p_pen_attribute29 => p_pen_attribute29
4652 ,p_pen_attribute30 => p_pen_attribute30
4653 ,p_request_id => p_request_id
4654 ,p_program_application_id => p_program_application_id
4655 ,p_program_id => p_program_id
4656 ,p_program_update_date => p_program_update_date
4657 ,p_object_version_number => p_object_version_number
4658 ,p_per_in_ler_id => p_per_in_ler_id
4659 ,p_bnft_typ_cd => p_bnft_typ_cd
4660 ,p_bnft_ordr_num => p_bnft_ordr_num
4661 ,p_prtt_enrt_rslt_stat_cd => p_prtt_enrt_rslt_stat_cd
4662 ,p_bnft_nnmntry_uom => p_bnft_nnmntry_uom
4663 ,p_comp_lvl_cd => p_comp_lvl_cd
4664 ,p_effective_date => trunc(p_effective_date)
4665 ,p_datetrack_mode => p_datetrack_mode
4666 );
4667 exception
4668 when hr_api.cannot_find_prog_unit then
4669 hr_api.cannot_find_prog_unit_error
4670 (p_module_name => 'UPDATE_PRTT_ENRT_RESULT'
4671 ,p_hook_type => 'BP'
4672 );
4673 --
4674 -- End of API User Hook for the before hook of update_PRTT_ENRT_RESULT
4675 --
4676 end;
4677 --
4678 hr_utility.set_location ( ' eff date ' || p_effective_date, 99 );
4679 hr_utility.set_location ( ' OVN ' || l_object_version_number, 99 );
4680 ben_pen_upd.upd
4681 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
4682 ,p_effective_start_date => l_effective_start_date
4683 ,p_effective_end_date => l_effective_end_date
4684 ,p_business_group_id => p_business_group_id
4685 ,p_oipl_id => p_oipl_id
4686 ,p_person_id => p_person_id
4687 ,p_assignment_id => p_assignment_id
4688 ,p_pgm_id => p_pgm_id
4689 ,p_pl_id => p_pl_id
4690 ,p_rplcs_sspndd_rslt_id => p_rplcs_sspndd_rslt_id
4691 ,p_ptip_id => p_ptip_id
4692 ,p_pl_typ_id => p_pl_typ_id
4693 ,p_ler_id => p_ler_id
4694 ,p_sspndd_flag => p_sspndd_flag
4695 ,p_prtt_is_cvrd_flag => p_prtt_is_cvrd_flag
4696 ,p_bnft_amt => p_bnft_amt
4697 ,p_uom => p_uom
4698 ,p_orgnl_enrt_dt => p_orgnl_enrt_dt
4699 ,p_enrt_mthd_cd => p_enrt_mthd_cd
4700 ,p_no_lngr_elig_flag => p_no_lngr_elig_flag
4701 ,p_enrt_ovridn_flag => p_enrt_ovridn_flag
4702 ,p_enrt_ovrid_rsn_cd => p_enrt_ovrid_rsn_cd
4703 ,p_erlst_deenrt_dt => p_erlst_deenrt_dt
4704 ,p_enrt_cvg_strt_dt => p_enrt_cvg_strt_dt
4705 ,p_enrt_cvg_thru_dt => p_enrt_cvg_thru_dt
4706 ,p_enrt_ovrid_thru_dt => p_enrt_ovrid_thru_dt
4707 ,p_pl_ordr_num => p_pl_ordr_num
4708 ,p_plip_ordr_num => p_plip_ordr_num
4709 ,p_ptip_ordr_num => p_ptip_ordr_num
4710 ,p_oipl_ordr_num => p_oipl_ordr_num
4711 ,p_pen_attribute_category => p_pen_attribute_category
4712 ,p_pen_attribute1 => p_pen_attribute1
4713 ,p_pen_attribute2 => p_pen_attribute2
4714 ,p_pen_attribute3 => p_pen_attribute3
4715 ,p_pen_attribute4 => p_pen_attribute4
4716 ,p_pen_attribute5 => p_pen_attribute5
4717 ,p_pen_attribute6 => p_pen_attribute6
4718 ,p_pen_attribute7 => p_pen_attribute7
4719 ,p_pen_attribute8 => p_pen_attribute8
4720 ,p_pen_attribute9 => p_pen_attribute9
4721 ,p_pen_attribute10 => p_pen_attribute10
4722 ,p_pen_attribute11 => p_pen_attribute11
4723 ,p_pen_attribute12 => p_pen_attribute12
4724 ,p_pen_attribute13 => p_pen_attribute13
4725 ,p_pen_attribute14 => p_pen_attribute14
4726 ,p_pen_attribute15 => p_pen_attribute15
4727 ,p_pen_attribute16 => p_pen_attribute16
4728 ,p_pen_attribute17 => p_pen_attribute17
4729 ,p_pen_attribute18 => p_pen_attribute18
4730 ,p_pen_attribute19 => p_pen_attribute19
4731 ,p_pen_attribute20 => p_pen_attribute20
4732 ,p_pen_attribute21 => p_pen_attribute21
4733 ,p_pen_attribute22 => p_pen_attribute22
4734 ,p_pen_attribute23 => p_pen_attribute23
4735 ,p_pen_attribute24 => p_pen_attribute24
4736 ,p_pen_attribute25 => p_pen_attribute25
4737 ,p_pen_attribute26 => p_pen_attribute26
4738 ,p_pen_attribute27 => p_pen_attribute27
4739 ,p_pen_attribute28 => p_pen_attribute28
4740 ,p_pen_attribute29 => p_pen_attribute29
4741 ,p_pen_attribute30 => p_pen_attribute30
4742 ,p_request_id => p_request_id
4743 ,p_program_application_id => p_program_application_id
4744 ,p_program_id => p_program_id
4745 ,p_program_update_date => p_program_update_date
4746 ,p_object_version_number => l_object_version_number
4747 ,p_per_in_ler_id => p_per_in_ler_id
4748 ,p_bnft_typ_cd => p_bnft_typ_cd
4749 ,p_bnft_ordr_num => p_bnft_ordr_num
4750 ,p_prtt_enrt_rslt_stat_cd => p_prtt_enrt_rslt_stat_cd
4751 ,p_bnft_nnmntry_uom => p_bnft_nnmntry_uom
4752 ,p_comp_lvl_cd => p_comp_lvl_cd
4753 ,p_effective_date => trunc(p_effective_date)
4754 ,p_datetrack_mode => p_datetrack_mode
4755 );
4756 --
4757 --
4758 begin
4759 --
4760 -- Start of API User Hook for the after hook of update_PRTT_ENRT_RESULT
4761 --
4762 ben_PRTT_ENRT_RESULT_bk2.update_PRTT_ENRT_RESULT_a
4763 (
4764 p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
4765 ,p_effective_start_date => l_effective_start_date
4766 ,p_effective_end_date => l_effective_end_date
4767 ,p_business_group_id => p_business_group_id
4768 ,p_oipl_id => p_oipl_id
4769 ,p_person_id => p_person_id
4770 ,p_assignment_id => p_assignment_id
4771 ,p_pgm_id => p_pgm_id
4772 ,p_pl_id => p_pl_id
4773 ,p_rplcs_sspndd_rslt_id => p_rplcs_sspndd_rslt_id
4774 ,p_ptip_id => p_ptip_id
4775 ,p_pl_typ_id => p_pl_typ_id
4776 ,p_ler_id => p_ler_id
4777 ,p_sspndd_flag => p_sspndd_flag
4778 ,p_prtt_is_cvrd_flag => p_prtt_is_cvrd_flag
4779 ,p_bnft_amt => p_bnft_amt
4780 ,p_uom => p_uom
4781 ,p_orgnl_enrt_dt => p_orgnl_enrt_dt
4782 ,p_enrt_mthd_cd => p_enrt_mthd_cd
4783 ,p_no_lngr_elig_flag => p_no_lngr_elig_flag
4784 ,p_enrt_ovridn_flag => p_enrt_ovridn_flag
4785 ,p_enrt_ovrid_rsn_cd => p_enrt_ovrid_rsn_cd
4786 ,p_erlst_deenrt_dt => p_erlst_deenrt_dt
4787 ,p_enrt_cvg_strt_dt => p_enrt_cvg_strt_dt
4788 ,p_enrt_cvg_thru_dt => p_enrt_cvg_thru_dt
4789 ,p_enrt_ovrid_thru_dt => p_enrt_ovrid_thru_dt
4790 ,p_pl_ordr_num => p_pl_ordr_num
4791 ,p_plip_ordr_num => p_plip_ordr_num
4792 ,p_ptip_ordr_num => p_ptip_ordr_num
4793 ,p_oipl_ordr_num => p_oipl_ordr_num
4794 ,p_pen_attribute_category => p_pen_attribute_category
4795 ,p_pen_attribute1 => p_pen_attribute1
4796 ,p_pen_attribute2 => p_pen_attribute2
4797 ,p_pen_attribute3 => p_pen_attribute3
4798 ,p_pen_attribute4 => p_pen_attribute4
4799 ,p_pen_attribute5 => p_pen_attribute5
4800 ,p_pen_attribute6 => p_pen_attribute6
4801 ,p_pen_attribute7 => p_pen_attribute7
4802 ,p_pen_attribute8 => p_pen_attribute8
4803 ,p_pen_attribute9 => p_pen_attribute9
4804 ,p_pen_attribute10 => p_pen_attribute10
4805 ,p_pen_attribute11 => p_pen_attribute11
4806 ,p_pen_attribute12 => p_pen_attribute12
4807 ,p_pen_attribute13 => p_pen_attribute13
4808 ,p_pen_attribute14 => p_pen_attribute14
4809 ,p_pen_attribute15 => p_pen_attribute15
4810 ,p_pen_attribute16 => p_pen_attribute16
4811 ,p_pen_attribute17 => p_pen_attribute17
4812 ,p_pen_attribute18 => p_pen_attribute18
4813 ,p_pen_attribute19 => p_pen_attribute19
4814 ,p_pen_attribute20 => p_pen_attribute20
4815 ,p_pen_attribute21 => p_pen_attribute21
4816 ,p_pen_attribute22 => p_pen_attribute22
4817 ,p_pen_attribute23 => p_pen_attribute23
4818 ,p_pen_attribute24 => p_pen_attribute24
4819 ,p_pen_attribute25 => p_pen_attribute25
4820 ,p_pen_attribute26 => p_pen_attribute26
4821 ,p_pen_attribute27 => p_pen_attribute27
4822 ,p_pen_attribute28 => p_pen_attribute28
4823 ,p_pen_attribute29 => p_pen_attribute29
4824 ,p_pen_attribute30 => p_pen_attribute30
4825 ,p_request_id => p_request_id
4826 ,p_program_application_id => p_program_application_id
4827 ,p_program_id => p_program_id
4828 ,p_program_update_date => p_program_update_date
4829 ,p_object_version_number => l_object_version_number
4830 ,p_per_in_ler_id => p_per_in_ler_id
4831 ,p_bnft_typ_cd => p_bnft_typ_cd
4832 ,p_bnft_ordr_num => p_bnft_ordr_num
4833 ,p_prtt_enrt_rslt_stat_cd => p_prtt_enrt_rslt_stat_cd
4834 ,p_bnft_nnmntry_uom => p_bnft_nnmntry_uom
4835 ,p_comp_lvl_cd => p_comp_lvl_cd
4836 ,p_effective_date => trunc(p_effective_date)
4837 ,p_datetrack_mode => p_datetrack_mode
4838 );
4839 exception
4840 when hr_api.cannot_find_prog_unit then
4841 hr_api.cannot_find_prog_unit_error
4842 (p_module_name => 'UPDATE_PRTT_ENRT_RESULT'
4843 ,p_hook_type => 'AP'
4844 );
4845 --
4846 -- End of API User Hook for the after hook of update_PRTT_ENRT_RESULT
4847 --
4848 end;
4849 --
4850 if g_debug then
4851 hr_utility.set_location(l_proc, 60);
4852 end if;
4853 --
4854 -- When in validation only mode raise the Validate_Enabled exception
4855 --
4856 if p_validate then
4857 raise hr_api.validate_enabled;
4858 end if;
4859 --
4860 -- Set all output arguments
4861 --
4862 p_object_version_number := l_object_version_number;
4863 p_effective_start_date := l_effective_start_date;
4864 p_effective_end_date := l_effective_end_date;
4865 --
4866 if g_debug then
4867 hr_utility.set_location(' Leaving:'||l_proc, 70);
4868 end if;
4869 --
4870 exception
4871 --
4872 when hr_api.validate_enabled then
4873 --
4874 -- As the Validate_Enabled exception has been raised
4875 -- we must rollback to the savepoint
4876 --
4877 ROLLBACK TO update_PRTT_ENRT_RESULT;
4878 --
4879 -- Only set output warning arguments
4880 -- (Any key or derived arguments must be set to null
4881 -- when validation only mode is being used.)
4882 --
4883 if g_debug then
4884 hr_utility.set_location(' Leaving:'||l_proc, 80);
4885 end if;
4886 --
4887 when others then
4888 --
4889 -- A validation or unexpected error has occured
4890 --
4891 ROLLBACK TO update_PRTT_ENRT_RESULT;
4892 p_effective_start_date := null; --nocopy change
4893 p_effective_end_date := null; --nocopy change
4894 raise;
4895 --
4896 end update_PRTT_ENRT_RESULT;
4897 --
4898 -- ----------------------------------------------------------------------------
4899 -- |------------------------< delete_PRTT_ENRT_RESULT >----------------------|
4900 -- ----------------------------------------------------------------------------
4901 --
4902 procedure delete_PRTT_ENRT_RESULT
4903 (p_validate in boolean default false
4904 ,p_prtt_enrt_rslt_id in number
4905 ,p_effective_start_date out nocopy date
4906 ,p_effective_end_date out nocopy date
4907 ,p_object_version_number in out nocopy number
4908 ,p_effective_date in date
4909 ,p_datetrack_mode in varchar2
4910 ,p_multi_row_validate in boolean default TRUE
4911 ) is
4912 --
4913 -- Declare cursors and local variables
4914 --
4915 l_proc varchar2(72) ; -- := g_package||'delete_PRTT_ENRT_RESULT';
4916 l_object_version_number ben_prtt_enrt_rslt_f.object_version_number%TYPE;
4917 l_effective_start_date ben_prtt_enrt_rslt_f.effective_start_date%TYPE;
4918 l_effective_end_date ben_prtt_enrt_rslt_f.effective_end_date%TYPE;
4919 --
4920 begin
4921 --
4922 g_debug := hr_utility.debug_enabled;
4923 if g_debug then
4924 l_proc := g_package||'delete_PRTT_ENRT_RESULT';
4925 hr_utility.set_location('Entering:'|| l_proc, 10);
4926 end if;
4927 g_multi_rows_validate := p_multi_row_validate;
4928 --
4929 -- Issue a savepoint if operating in validation only mode
4930 --
4931 savepoint delete_PRTT_ENRT_RESULT;
4932 --
4933 if g_debug then
4934 hr_utility.set_location(l_proc, 20);
4935 end if;
4936 --
4937 -- Process Logic
4938 --
4939 l_object_version_number := p_object_version_number;
4940 --
4941 --
4942 begin
4943 --
4944 -- Start of API User Hook for the before hook of delete_PRTT_ENRT_RESULT
4945 --
4946 ben_PRTT_ENRT_RESULT_bk3.delete_PRTT_ENRT_RESULT_b
4947 (
4948 p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
4949 ,p_object_version_number => p_object_version_number
4950 ,p_effective_date => trunc(p_effective_date)
4951 ,p_datetrack_mode => p_datetrack_mode
4952 );
4953 exception
4954 when hr_api.cannot_find_prog_unit then
4955 hr_api.cannot_find_prog_unit_error
4956 (p_module_name => 'DELETE_PRTT_ENRT_RESULT'
4957 ,p_hook_type => 'BP'
4958 );
4959 --
4960 -- End of API User Hook for the before hook of delete_PRTT_ENRT_RESULT
4961 --
4962 end;
4963 --
4964 ben_pen_del.del
4965 (
4966 p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
4967 ,p_effective_start_date => l_effective_start_date
4968 ,p_effective_end_date => l_effective_end_date
4969 ,p_object_version_number => l_object_version_number
4970 ,p_effective_date => p_effective_date
4971 ,p_datetrack_mode => p_datetrack_mode
4972 );
4973 --
4974 begin
4975 --
4976 -- Start of API User Hook for the after hook of delete_PRTT_ENRT_RESULT
4977 --
4978 ben_PRTT_ENRT_RESULT_bk3.delete_PRTT_ENRT_RESULT_a
4979 (
4980 p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
4981 ,p_effective_start_date => l_effective_start_date
4982 ,p_effective_end_date => l_effective_end_date
4983 ,p_object_version_number => l_object_version_number
4984 ,p_effective_date => trunc(p_effective_date)
4985 ,p_datetrack_mode => p_datetrack_mode
4986 );
4987 exception
4988 when hr_api.cannot_find_prog_unit then
4989 hr_api.cannot_find_prog_unit_error
4990 (p_module_name => 'DELETE_PRTT_ENRT_RESULT'
4991 ,p_hook_type => 'AP'
4992 );
4993 --
4994 -- End of API User Hook for the after hook of delete_PRTT_ENRT_RESULT
4995 --
4996 end;
4997 --
4998 if g_debug then
4999 hr_utility.set_location(l_proc, 60);
5000 end if;
5001 --
5002 -- When in validation only mode raise the Validate_Enabled exception
5003 --
5004 if p_validate then
5005 raise hr_api.validate_enabled;
5006 end if;
5007 --
5008 p_effective_start_date := l_effective_start_date;
5009 p_effective_end_date := l_effective_end_date;
5010 p_object_version_number := l_object_version_number;
5011
5012 if g_debug then
5013 hr_utility.set_location(' Leaving:'||l_proc, 70);
5014 end if;
5015 --
5016 exception
5017 --
5018 when hr_api.validate_enabled then
5019 --
5020 -- As the Validate_Enabled exception has been raised
5021 -- we must rollback to the savepoint
5022 --
5023 ROLLBACK TO delete_PRTT_ENRT_RESULT;
5024 --
5025 -- Only set output warning arguments
5026 -- (Any key or derived arguments must be set to null
5027 -- when validation only mode is being used.)
5028 --
5029 p_effective_start_date := null;
5030 p_effective_end_date := null;
5031 if g_debug then
5032 hr_utility.set_location(' Leaving:'||l_proc, 80);
5033 end if;
5034 --
5035 when others then
5036 --
5037 -- A validation or unexpected error has occured
5038 --
5039 ROLLBACK TO delete_PRTT_ENRT_RESULT;
5040 p_effective_start_date := null; --nocopy change
5041 p_effective_end_date := null; --nocopy change
5042 raise;
5043 --
5044 end delete_PRTT_ENRT_RESULT;
5045 --
5046 --
5047 -- ----------------------------------------------------------------------------
5048 -- |---------------------< calc_dpnt_cvg_end_date >-------------------------|
5049 -- ----------------------------------------------------------------------------
5050 --
5051 procedure calc_dpnt_cvg_dt
5052 (p_calc_end_dt in boolean default FALSE
5053 ,P_calc_strt_dt in boolean default FALSE
5054 ,P_per_in_ler_id in number default NULL
5055 ,p_person_id in number default NULL
5056 ,p_pgm_id in number default NULL
5057 ,p_pl_id in number default NULL
5058 ,p_oipl_id in number default NULL
5059 ,p_ptip_id in number default NULL
5060 ,p_ler_id in number default NULL
5061 ,p_elig_per_elctbl_chc_id in number default NULL
5062 ,p_business_group_id in number
5063 ,p_effective_date in date
5064 ,p_enrt_cvg_end_dt in date default NULL
5065 ,p_returned_strt_dt out nocopy date
5066 ,p_returned_end_dt out nocopy date
5067 ) is
5068 l_proc varchar2(72); -- := g_package||'calc_dpnt_cvg_dt';
5069 l_enrt_cvg_end_dt date;
5070 l_cvg_strt_dt date;
5071 l_cvg_strt_cd varchar2(30);
5072 l_cvg_strt_rl number(15);
5073 l_cvg_end_cd varchar2(30);
5074 l_cvg_end_rl number(15);
5075 l_step integer;
5076 begin
5077 g_debug := hr_utility.debug_enabled;
5078 if g_debug then
5079 l_proc := g_package||'calc_dpnt_cvg_dt';
5080 hr_utility.set_location(' Entering:'||l_proc,10);
5081 end if;
5082 l_step := 10;
5083 if (p_elig_per_elctbl_chc_id is not NULL) then
5084 determine_dpnt_cvg_dt_cd
5085 (p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id
5086 ,p_effective_date => p_effective_date
5087 ,p_business_group_id => p_business_group_id
5088 ,p_cvg_strt_cd => l_cvg_strt_cd
5089 ,p_cvg_strt_rl => l_cvg_strt_rl
5090 ,p_cvg_end_cd => l_cvg_end_cd
5091 ,p_cvg_end_rl => l_cvg_end_rl
5092 );
5093 if g_debug then
5094 hr_utility.set_location('dpnt_end_cd' || l_cvg_end_cd,15);
5095 hr_utility.set_location('dpnt_strt_cd'|| l_cvg_strt_cd,15);
5096 end if;
5097 if (p_calc_strt_dt and l_cvg_strt_cd is not NULL) then
5098 l_step := 20;
5099 ben_determine_date.main
5100 (P_DATE_CD => l_cvg_strt_cd
5101 ,p_formula_id => l_cvg_strt_rl
5102 ,P_ELIG_PER_ELCTBL_CHC_ID => p_elig_per_elctbl_chc_id
5103 ,P_BUSINESS_GROUP_ID => p_business_group_id
5104 ,P_EFFECTIVE_DATE => p_effective_date
5105 ,P_RETURNED_DATE => l_cvg_strt_dt
5106 );
5107 else
5108 l_cvg_strt_dt := NULL;
5109 end if;
5110 if (p_calc_end_dt and l_cvg_end_cd is not NULL) then
5111 l_step := 30;
5112 ben_determine_date.main
5113 (P_DATE_CD => l_cvg_end_cd
5114 ,p_formula_id => l_cvg_end_rl
5115 ,p_enrt_cvg_end_dt => p_enrt_cvg_end_dt
5116 ,P_ELIG_PER_ELCTBL_CHC_ID => p_elig_per_elctbl_chc_id
5117 ,P_BUSINESS_GROUP_ID => p_business_group_id
5118 ,P_EFFECTIVE_DATE => p_effective_date
5119 ,P_RETURNED_DATE => l_enrt_cvg_end_dt
5120 );
5121 else
5122 l_enrt_cvg_end_dt := NULL;
5123 end if;
5124 else
5125 l_step := 40;
5126 determine_dpnt_cvg_dt_cd
5127 (p_pgm_id => p_pgm_id
5128 ,P_ptip_id => p_ptip_id
5129 ,p_pl_id => p_pl_id
5130 ,p_ler_id => p_ler_id
5131 ,p_effective_date => p_effective_date
5132 ,p_business_group_id => p_business_group_id
5133 ,p_cvg_strt_cd => l_cvg_strt_cd
5134 ,p_cvg_strt_rl => l_cvg_strt_rl
5135 ,p_cvg_end_cd => l_cvg_end_cd
5136 ,p_cvg_end_rl => l_cvg_end_rl
5137 );
5138 if (p_calc_strt_dt and l_cvg_strt_cd is not null) then
5139 l_step := 50;
5140 ben_determine_date.main
5141 (P_DATE_CD => l_cvg_strt_cd
5142 ,p_formula_id => l_cvg_strt_rl
5143 ,P_PER_IN_LER_ID => p_per_in_ler_id
5144 ,P_PERSON_ID => p_person_id
5145 ,P_PGM_ID => p_pgm_id
5146 ,P_PL_ID => p_pl_id
5147 ,P_OIPL_ID => p_oipl_id
5148 ,P_BUSINESS_GROUP_ID => p_business_group_id
5149 ,P_EFFECTIVE_DATE => p_effective_date
5150 ,P_RETURNED_DATE => l_cvg_strt_dt
5151 );
5152 else
5153 l_cvg_strt_dt := NULL;
5154 end if;
5155 if (p_calc_end_dt and l_cvg_end_cd is not NULL) then
5156 l_step := 60;
5157 ben_determine_date.main
5158 (P_DATE_CD => l_cvg_end_cd
5159 ,p_formula_id => l_cvg_end_rl
5160 ,p_enrt_cvg_end_dt => p_enrt_cvg_end_dt
5161 ,P_PER_IN_LER_ID => p_per_in_ler_id
5162 ,P_PERSON_ID => p_person_id
5163 ,P_PGM_ID => p_pgm_id
5164 ,P_PL_ID => p_pl_id
5165 ,P_OIPL_ID => p_oipl_id
5166 ,P_BUSINESS_GROUP_ID => p_business_group_id
5167 ,P_EFFECTIVE_DATE => p_effective_date
5168 ,P_RETURNED_DATE => l_enrt_cvg_end_dt
5169 );
5170 else
5171 l_enrt_cvg_end_dt := NULL;
5172 end if;
5173 end if;
5174 l_step := 70;
5175 p_returned_end_dt := l_enrt_cvg_end_dt;
5176 p_returned_strt_dt := l_cvg_strt_dt;
5177 if g_debug then
5178 hr_utility.set_location(' Leaving:'||l_proc, 70);
5179 end if;
5180 exception
5181 when others then
5182 rpt_error(p_proc => l_proc, p_step => l_step);
5183 raise;
5184 end calc_dpnt_cvg_dt;
5185 --
5186 -- ----------------------------------------------------------------------------
5187 -- |---------------------< determine_dpnt_cvg_dt_cd >------------------------|
5188 -- ----------------------------------------------------------------------------
5189 --
5190 procedure determine_dpnt_cvg_dt_cd
5191 (p_elig_per_elctbl_chc_id in number default NULL
5192 ,p_pgm_id in number default NULL
5193 ,p_pl_id in number default NULL
5194 ,p_ptip_id in number default NULL
5195 ,p_ler_id in number default NULL
5196 ,p_effective_date in date
5197 ,p_business_group_id in number
5198 ,p_cvg_strt_cd out nocopy varchar2
5199 ,p_cvg_strt_rl out nocopy number
5200 ,p_cvg_end_cd out nocopy varchar2
5201 ,p_cvg_end_rl out nocopy number
5202 ) is
5203 l_proc varchar2(80); -- := 'determine_dpnt_cvg_dt_cd';
5204 l_level varchar2(10) :=NULL;
5205 l_cvg_strt_cd varchar2(30);
5206 l_cvg_strt_rl number(15);
5207 l_cvg_end_cd varchar2(30);
5208 l_cvg_end_rl number(15);
5209 l_step integer;
5210 --
5211 l_pl_rec ben_cobj_cache.g_pl_inst_row;
5212 l_pgm_rec ben_cobj_cache.g_pgm_inst_row;
5213 l_ptip_rec ben_cobj_cache.g_ptip_inst_row;
5214 --
5215 cursor c_epe is
5216 select epe.elig_per_elctbl_chc_id
5217 ,epe.pgm_id
5218 ,epe.ptip_id
5219 ,epe.pl_id
5220 ,pil.ler_id
5221 from ben_elig_per_elctbl_chc epe
5222 ,ben_per_in_ler pil
5223 where elig_per_elctbl_chc_id = p_elig_per_elctbl_chc_id
5224 and epe.business_group_id = p_business_group_id
5225 and epe.per_in_ler_id = pil.per_in_ler_id
5226 and pil.per_in_ler_stat_cd not in ('VOIDD', 'BCKDT')
5227 ;
5228 l_epe c_epe%rowtype;
5229 --
5230 cursor c_ler_chg_dep(p_level varchar2) is
5231 select chg.cvg_eff_strt_cd
5232 ,chg.cvg_eff_end_cd
5233 ,chg.cvg_eff_strt_rl
5234 ,chg.cvg_eff_end_rl
5235 ,chg.ler_chg_dpnt_cvg_cd
5236 ,chg.ler_chg_dpnt_cvg_rl
5237 from ben_ler_chg_dpnt_cvg_f chg
5238 where chg.ler_id = l_epe.ler_id
5239 and chg.business_group_id = p_business_group_id
5240 and decode(p_level
5241 ,'PL',l_epe.pl_id
5242 ,'PTIP', l_epe.ptip_id
5243 ,'PGM', l_epe.pgm_id) = decode(p_level
5244 ,'PL',chg.pl_id
5245 ,'PTIP', chg.ptip_id
5246 ,'PGM', chg.pgm_id)
5247 and p_effective_date between
5248 chg.effective_start_date and chg.effective_end_date
5249 ;
5250 l_chg c_ler_chg_dep%rowtype;
5251 l_env_rec ben_env_object.g_global_env_rec_type;
5252 --
5253 begin
5254 g_debug := hr_utility.debug_enabled;
5255 if g_debug then
5256 l_proc := 'determine_dpnt_cvg_dt_cd';
5257 hr_utility.set_location ('Entering '||l_proc,10);
5258 end if;
5259 l_step := 10;
5260 if fnd_global.conc_request_id in (0,-1) then
5261 --
5262 --bug#3568529
5263 ben_env_object.get(p_rec => l_env_rec);
5264 if l_env_rec.benefit_action_id is null then
5265 --
5266 ben_env_object.init(p_business_group_id => p_business_group_id,
5267 p_effective_date => p_effective_date,
5268 p_thread_id => 1,
5269 p_chunk_size => 1,
5270 p_threads => 1,
5271 p_max_errors => 1,
5272 p_benefit_action_id => null);
5273 end if;
5274 --
5275 end if;
5276 if p_elig_per_elctbl_chc_id is not null then
5277 open c_epe;
5278 fetch c_epe into l_epe;
5279 if c_epe%notfound then
5280 close c_epe;
5281 rpt_error(p_proc => l_proc, p_step => l_step);
5282 if g_debug then
5283 hr_utility.set_location('BEN_91457_ELCTBL_CHC_NOT_FOUND id:'||
5284 to_char(p_elig_per_elctbl_chc_id), 15);
5285 end if;
5286 fnd_message.set_name('BEN','BEN_91457_ELCTBL_CHC_NOT_FOUND');
5287 fnd_message.set_token('ID', to_char(p_elig_per_elctbl_chc_id) );
5288 fnd_message.set_token('PROC','2:'||l_proc );
5289 fnd_message.raise_error;
5290 end if;
5291 close c_epe;
5292 else
5293 l_epe.elig_per_elctbl_chc_id := NULL;
5294 l_epe.pgm_id := p_pgm_id;
5295 l_epe.pl_id := p_pl_id;
5296 l_epe.ptip_id := p_ptip_id;
5297 l_epe.ler_id := p_ler_id;
5298 end if;
5299 if g_debug then
5300 hr_utility.set_location ('Determining designation level '||l_proc,30);
5301 end if;
5302 l_step := 20;
5303 --
5304 -- If program Id is specified, then use program Id to retreive dependent
5305 -- designation level. If not, use plan as dependent designation level.
5306 --
5307 if (l_epe.pl_id is not null ) then
5308 ben_cobj_cache.get_pl_dets
5309 (p_business_group_id => p_business_group_id
5310 ,p_effective_date => p_effective_date
5311 ,p_pl_id => l_epe.pl_id
5312 ,p_inst_row => l_pl_rec);
5313 end if;
5314
5315 if ( (l_epe.pgm_id is not null)) then
5316 ben_cobj_cache.get_pgm_dets
5317 (p_business_group_id => p_business_group_id
5318 ,p_effective_date => p_effective_date
5319 ,p_pgm_id => l_epe.pgm_id
5320 ,p_inst_row => l_pgm_rec);
5321 -- 3657077 : Added the below IF-condition.
5322 -- check if DPNT_DSGN_CD is specified at plan-level. If it is specified
5323 -- then dependent designation level is PL. This overrides all PGM and PTIP levels
5324 if (l_pl_rec.dpnt_dsgn_cd IS NULL) then
5325 l_level := l_pgm_rec.dpnt_dsgn_lvl_cd;
5326 else
5327 l_level := 'PL';
5328 end if;
5329 if l_level not in ('PL', 'PGM', 'PTIP') then
5330 rpt_error(p_proc => l_proc, p_step => l_step);
5331 fnd_message.set_name('BEN', 'BEN_91712_INVALID_DP_DSGN_LVL');
5332 fnd_message.set_token('LVL', l_level);
5333 end if;
5334 else
5335 l_level := 'PL';
5336 end if;
5337
5338 if (l_epe.ptip_id is not null and l_level = 'PTIP') then
5339 ben_cobj_cache.get_ptip_dets
5340 (p_business_group_id => p_business_group_id
5341 ,p_effective_date => p_effective_date
5342 ,p_ptip_id => l_epe.ptip_id
5343 ,p_inst_row => l_ptip_rec);
5344 end if;
5345 l_step := 30;
5346 open c_ler_chg_dep(l_level);
5347 fetch c_ler_chg_dep into l_chg;
5348 if c_ler_chg_dep%notfound then
5349 --
5350 -- If there are no records, continue to get start date code and
5351 -- end date code from program or Plan.
5352 --
5353 l_cvg_strt_cd := NULL;
5354 l_cvg_strt_rl := NULL;
5355 l_cvg_end_cd := NULL;
5356 l_cvg_end_rl := NULL;
5357 else
5358 l_cvg_strt_cd := l_chg.cvg_eff_strt_cd;
5359 l_cvg_strt_rl := l_chg.cvg_eff_strt_rl;
5360 l_cvg_end_cd := l_chg.cvg_eff_end_cd;
5361 l_cvg_end_rl := l_chg.cvg_eff_end_rl;
5362 end if;
5363 close c_ler_chg_dep;
5364 l_step := 40;
5365 if (l_cvg_strt_cd is NULL) then
5366 if (l_level = 'PL') then
5367 l_cvg_strt_cd := l_pl_rec.dpnt_cvg_strt_dt_cd;
5368 l_cvg_strt_rl := l_pl_rec.dpnt_cvg_strt_dt_rl;
5369 elsif (l_level = 'PTIP') then
5370 l_cvg_strt_cd := l_ptip_rec.dpnt_cvg_strt_dt_cd;
5371 l_cvg_strt_rl := l_ptip_rec.dpnt_cvg_strt_dt_rl;
5372 elsif (l_level = 'PGM') then
5373 l_cvg_strt_cd := l_pgm_rec.dpnt_cvg_strt_dt_cd;
5374 l_cvg_strt_rl := l_pgm_rec.dpnt_cvg_strt_dt_rl;
5375 end if;
5376 end if;
5377 l_step := 50;
5378 if (l_cvg_end_cd is NULL) then
5379 if (l_level = 'PL') then
5380 l_cvg_end_cd := l_pl_rec.dpnt_cvg_end_dt_cd;
5381 l_cvg_end_rl := l_pl_rec.dpnt_cvg_end_dt_rl;
5382 elsif (l_level = 'PTIP') then
5383 l_cvg_end_cd := l_ptip_rec.dpnt_cvg_end_dt_cd;
5384 l_cvg_end_rl := l_ptip_rec.dpnt_cvg_end_dt_rl;
5385 elsif (l_level = 'PGM') then
5386 l_cvg_end_cd := l_pgm_rec.dpnt_cvg_end_dt_cd;
5387 l_cvg_end_rl := l_pgm_rec.dpnt_cvg_end_dt_rl;
5388 end if;
5389 end if;
5390 l_step := 60;
5391 p_cvg_strt_cd := l_cvg_strt_cd;
5392 p_cvg_strt_rl := l_cvg_strt_rl;
5393 p_cvg_end_cd := l_cvg_end_cd;
5394 p_cvg_end_rl := l_cvg_end_rl;
5395 exception
5396 when others then
5397 rpt_error(p_proc => l_proc, p_step => l_step);
5398 raise;
5399 end determine_dpnt_cvg_dt_cd;
5400 --
5401 -- ----------------------------------------------------------------------------
5402 -- |------------------------<Get_election_date >-----------------------------|
5403 -- ----------------------------------------------------------------------------
5404 --
5405 Procedure Get_election_date(p_effective_date in Date
5406 ,p_prtt_enrt_rslt_id in Number
5407 ,p_business_group_id in Number
5408 ,p_date out nocopy date
5409 ,p_pil_id out nocopy number
5410 ) is
5411 Cursor c1 is
5412 Select min(effective_start_date),pen.per_in_ler_id
5413 From ben_prtt_enrt_rslt_f pen
5414 Where pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
5415 And pen.business_group_id = p_business_group_id
5416 and pen.prtt_enrt_rslt_stat_cd is null
5417 Group by pen.per_in_ler_id
5418 order by pen.per_in_ler_id asc; -- Bug 6528876
5419
5420 l_date date;
5421 l_pil_id number;
5422 Begin
5423 Open c1;
5424 Fetch c1 into l_date,l_pil_id;
5425 If c1%notfound then
5426 l_date := hr_api.g_date;
5427 l_pil_id := to_number(null);
5428 End if;
5429 Close c1;
5430 p_date := l_date;
5431 p_pil_id := l_pil_id;
5432 End;
5433
5434 -- ----------------------------------------------------------------------------
5435 -- |------------------------< void_enrollment >-----------------------------|
5436 -- ----------------------------------------------------------------------------
5437 --
5438 procedure void_enrollment
5439 (p_validate in boolean default false
5440 ,p_per_in_ler_id in number
5441 ,p_prtt_enrt_rslt_id in number
5442 ,p_business_group_id in number
5443 ,p_enrt_cvg_strt_dt in date default null
5444 ,p_person_id in number default null
5445 ,p_elig_per_elctbl_chc_id in number default null
5446 ,p_epe_ovn in number default null
5447 ,p_object_version_number in number default null
5448 ,p_effective_date in date
5449 ,p_datetrack_mode in varchar2
5450 ,p_multi_row_validate in boolean default TRUE
5451 ,p_source in varchar2 default null
5452 ,p_enrt_bnft_id in number default null)
5453 is
5454 --
5455 -- Declare cursors and local variables
5456 --
5457 /*
5458 cursor c_pen
5459 is
5460 select pen.ler_id
5461 ,pen.person_id
5462 ,pen.ENRT_CVG_STRT_DT
5463 ,pen.ENRT_CVG_THRU_DT
5464 ,pen.effective_start_date
5465 ,pen.effective_end_date
5466 ,pen.pl_id
5467 ,pen.oipl_id
5468 ,pen.object_version_number
5469 ,epe.elig_per_elctbl_chc_id
5470 ,epe.per_in_ler_id
5471 ,epe.object_version_number epe_ovn
5472 ,enb.enrt_bnft_id
5473 from ben_prtt_enrt_rslt_f pen
5474 ,ben_elig_per_elctbl_chc epe
5475 ,ben_per_in_ler pil
5476 ,ben_enrt_bnft enb
5477 where pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
5478 and pen.prtt_enrt_rslt_id = epe.prtt_enrt_rslt_id (+)
5479 and nvl(epe.elig_per_elctbl_chc_id, -1) = enb.elig_per_elctbl_chc_id (+)
5480 and pen.business_group_id = p_business_group_id
5481 and p_effective_date between pen.effective_start_date
5482 and pen.effective_end_date
5483 and pil.per_in_ler_id(+)=epe.per_in_ler_id
5484 and pil.business_group_id(+)=epe.business_group_id
5485 and ( pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT') -- found row condition
5486 or pil.per_in_ler_stat_cd is null -- outer join condition
5487 )
5488 ;
5489 */
5490 --
5491 cursor c_pen
5492 is
5493 select pen.ler_id
5494 ,pen.person_id
5495 ,pen.ENRT_CVG_STRT_DT
5496 ,pen.ENRT_CVG_THRU_DT
5497 ,pen.effective_start_date
5498 ,pen.effective_end_date
5499 ,pen.pl_id
5500 ,pen.oipl_id
5501 ,pen.object_version_number
5502 ,to_number(null) elig_per_elctbl_chc_id
5503 ,to_number(null) per_in_ler_id
5504 ,to_number(null) epe_ovn
5505 ,to_number(null) enrt_bnft_id
5506 from ben_prtt_enrt_rslt_f pen
5507 where pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
5508 and p_effective_date between pen.effective_start_date
5509 and pen.effective_end_date
5510 ;
5511 --
5512 cursor c_epe
5513 is
5514 select epe.elig_per_elctbl_chc_id
5515 ,epe.per_in_ler_id
5516 ,epe.object_version_number epe_ovn
5517 ,enb.enrt_bnft_id
5518 from ben_elig_per_elctbl_chc epe
5519 ,ben_per_in_ler pil
5520 ,ben_enrt_bnft enb
5521 where epe.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
5522 and nvl(epe.elig_per_elctbl_chc_id, -1) = enb.elig_per_elctbl_chc_id (+)
5523 and pil.per_in_ler_id=epe.per_in_ler_id
5524 and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT')
5525 ;
5526
5527 -- ???? should we have that effective date check?
5528 l_pen c_pen%rowtype;
5529 --
5530 /*
5531 cursor c_prv is
5532 select prv.prtt_rt_val_id
5533 --,max(ecr.enrt_rt_id) enrt_rt_id
5534 ,ecr.enrt_rt_id
5535 ,prv.object_version_number
5536 ,ecr.acty_base_rt_id
5537 ,abr.element_type_id
5538 ,abr.input_value_id
5539 ,prv.rt_strt_dt
5540 from ben_prtt_rt_val prv
5541 ,ben_enrt_rt ecr
5542 ,ben_acty_base_rt_f abr
5543 where prv.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
5544 and prv.prtt_rt_val_stat_cd is null
5545 and prv.prtt_rt_val_id = ecr.prtt_rt_val_id (+) */
5546 /* joining ecr with choice id or benefit id is removed as ecr will be
5547 having prtt_rt_val_id only for that particular benefit record in the case of
5548 flat range - bug#2545915 - this one matches with the cursor in delete_enrollment
5549 */
5550 /*
5551 and (l_pen.elig_per_elctbl_chc_id is null or
5552 l_pen.enrt_bnft_id is not null or
5553 l_pen.elig_per_elctbl_chc_id = ecr.elig_per_elctbl_chc_id)
5554 and (l_pen.enrt_bnft_id is null or
5555 l_pen.enrt_bnft_id = ecr.enrt_bnft_id)
5556 and prv.business_group_id = p_business_group_id
5557 and nvl(prv.acty_base_rt_id,-1) = abr.acty_base_rt_id (+)
5558 and p_effective_date between abr.effective_start_date (+)
5559 and abr.effective_end_date (+)
5560 order by prv.rt_strt_dt desc; */
5561 /*
5562 group by
5563 prv.prtt_rt_val_id
5564 ,prv.object_version_number
5565 ,ecr.acty_base_rt_id
5566 ,abr.element_type_id
5567 ,abr.input_value_id
5568 ,prv.rt_strt_dt
5569 */
5570 --
5571 cursor c_prv is
5572 select distinct prv.prtt_rt_val_id
5573 ,prv.object_version_number
5574 ,abr.element_type_id
5575 ,abr.input_value_id
5576 ,prv.rt_strt_dt
5577 from ben_prtt_rt_val prv
5578 ,ben_acty_base_rt_f abr
5579 where prv.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
5580 and prv.prtt_rt_val_stat_cd is null
5581 and prv.business_group_id = p_business_group_id
5582 and prv.acty_base_rt_id = abr.acty_base_rt_id
5583 and p_effective_date between abr.effective_start_date
5584 and abr.effective_end_date
5585 order by prv.rt_strt_dt desc;
5586 --
5587 -- Rates with non-recurring element entries- prtt rt val are end dated
5588 cursor c_prv3 (p_per_in_ler_id number)is
5589 select prv.prtt_rt_val_id
5590 ,prv.object_version_number
5591 ,ecr.enrt_rt_id
5592 ,ecr.acty_base_rt_id
5593 from ben_prtt_rt_val prv,
5594 ben_enrt_rt ecr
5595 where prv.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
5596 and prv.prtt_rt_val_id = ecr.prtt_rt_val_id
5597 and prv.rt_end_dt <> hr_api.g_eot
5598 and prv.business_group_id = p_business_group_id
5599 and prv.per_in_ler_id = p_per_in_ler_id
5600 and prv.prtt_rt_val_stat_cd is null;
5601 --
5602 cursor c_abr (p_acty_base_rt_id number) is
5603 select py.processing_type,
5604 abr.rcrrg_cd
5605 from ben_acty_base_rt_f abr,
5606 pay_element_types_f py
5607 where abr.element_type_id = py.element_type_id(+)
5608 and abr.acty_base_rt_id = p_acty_base_rt_id
5609 and p_effective_date between abr.effective_start_date
5610 and abr.effective_end_date
5611 and p_effective_date between py.effective_start_date(+)
5612 and py.effective_end_date(+);
5613 --
5614 cursor c_unrestricted_future (p_per_in_ler_id number,
5615 p_prtt_enrt_rslt_id number,
5616 p_effective_start_date date) is
5617 select null
5618 from ben_prtt_enrt_rslt_f pen,
5619 ben_per_in_ler pil,
5620 ben_ler_f ler
5621 where pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
5622 and pen.effective_start_date > p_effective_start_date
5623 and pen.per_in_ler_id = pil.per_in_ler_id
5624 and pil.ler_id = ler.ler_id
5625 and ler.typ_cd = 'SCHEDDU'
5626 and p_effective_start_date between ler.effective_start_date
5627 and ler.effective_end_date
5628 and pen.business_group_id = p_business_group_id;
5629
5630 -- 3574168
5631 -- Fetch all Primary Care Provider records.
5632 Cursor c_pcp
5633 is
5634 select pcp.PRMRY_CARE_PRVDR_ID
5635 ,pcp.EFFECTIVE_START_DATE
5636 ,pcp.EFFECTIVE_END_DATE
5637 ,pcp.PRTT_ENRT_RSLT_ID
5638 ,pcp.BUSINESS_GROUP_ID
5639 ,pcp.OBJECT_VERSION_NUMBER
5640 from ben_prmry_care_prvdr_f pcp
5641 where pcp.business_group_id = p_business_group_id
5642 and pcp.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
5643 and p_effective_date between pcp.effective_start_date
5644 and pcp.effective_end_date
5645 ;
5646 --
5647 -- Fetch all PCP records in future.
5648 Cursor c_pcp_future
5649 is
5650 select pcp.PRMRY_CARE_PRVDR_ID
5651 ,pcp.EFFECTIVE_START_DATE
5652 ,pcp.EFFECTIVE_END_DATE
5653 ,pcp.PRTT_ENRT_RSLT_ID
5654 ,pcp.BUSINESS_GROUP_ID
5655 ,pcp.OBJECT_VERSION_NUMBER
5656 from ben_prmry_care_prvdr_f pcp
5657 where pcp.business_group_id = p_business_group_id
5658 and pcp.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
5659 and p_effective_date < pcp.effective_start_date
5660 and NVL(pcp.effective_end_date, hr_api.g_eot) = hr_api.g_eot
5661 ;
5662 -- 3574168
5663
5664 l_abr c_abr%rowtype;
5665
5666 -- Local variable declaration.
5667 l_proc varchar2(72); -- := g_package||'void_enrollment';
5668 l_datetrack_mode varchar2(20);
5669 l_step integer;
5670 l_tmp_ovn integer;
5671 l_effective_start_date date;
5672 l_effective_end_date date;
5673 l_eff_dt date;
5674 l_dummy varchar2(30);
5675 l_pcp_effective_date date;
5676
5677 --
5678 begin
5679 g_debug := hr_utility.debug_enabled;
5680 if g_debug then
5681 l_proc := g_package||'void_enrollment';
5682 hr_utility.set_location('Entering:'|| l_proc, 10);
5683 end if;
5684 --
5685 -- Issue a savepoint if operating in validation only mode
5686 --
5687 savepoint void_enrollment;
5688 --
5689 l_step := 10;
5690
5691 -- Person id is needed for call to update_prtt_rt (because it calls
5692 -- element-entry proc that needs it as input).
5693 -- P_elig_per_elctbl_chc_id and p_epe_ovn are needed for update to chc table.
5694 -- Others are needed for update to result table.
5695
5696 open c_pen;
5697 fetch c_pen into l_pen;
5698 if c_pen%notfound then
5699 close c_pen;
5700 rpt_error(p_proc => l_proc, p_step => l_step);
5701 fnd_message.set_name('BEN','BEN_91711_ENRT_RSLT_NOT_FND');
5702 fnd_message.set_token('ID', to_char(p_prtt_enrt_rslt_id));
5703 fnd_message.set_token('PROC',l_proc);
5704 fnd_message.set_token('PERSON_ID', to_char(p_person_id));
5705 fnd_message.set_token('LER_ID', null);
5706 fnd_message.set_token('EFFECTIVE_DATE',to_char(p_effective_date));
5707 fnd_message.raise_error;
5708 else
5709 --
5710 open c_epe;
5711 fetch c_epe into l_pen.elig_per_elctbl_chc_id,
5712 l_pen.per_in_ler_id,
5713 l_pen.epe_ovn,
5714 l_pen.enrt_bnft_id ;
5715 close c_epe ;
5716 --
5717 end if;
5718 close c_pen;
5719 -- always fetch the above data because other values are needed.
5720 /*
5721 l_pen.enrt_cvg_strt_dt := p_enrt_cvg_strt_dt;
5722 l_pen.person_id := p_person_id;
5723 l_pen.elig_per_elctbl_chc_id := p_elig_per_elctbl_chc_id;
5724 l_pen.epe_ovn := p_epe_ovn;
5725 l_pen.object_version_number := p_object_version_number;
5726 l_pen.enrt_bnft_id := p_enrt_bnft_id; */
5727 --
5728 if g_debug then
5729 hr_utility.set_location('Rate Non recurring',3459);
5730 end if;
5731 for l_prv in c_prv3 (p_per_in_ler_id) loop
5732 --check whether rate is non-recurring
5733 open c_abr(l_prv.acty_base_rt_id);
5734 fetch c_abr into l_abr;
5735 close c_abr;
5736 --
5737 if l_abr.processing_type = 'N' or
5738 l_abr.rcrrg_cd = 'ONCE' then
5739 null;
5740 else
5741 exit;
5742 end if;
5743
5744 if g_debug then
5745 hr_utility.set_location('delete prtt',3459);
5746 end if;
5747 update ben_enrt_rt
5748 set prtt_rt_val_id = null
5749 where enrt_rt_id = l_prv.enrt_rt_id;
5750 --
5751 ben_prtt_rt_val_api.delete_prtt_rt_val
5752 (P_VALIDATE => FALSE
5753 ,P_PRTT_RT_VAL_ID => l_prv.prtt_rt_val_id
5754 ,P_OBJECT_VERSION_NUMBER => l_prv.object_version_number
5755 ,P_EFFECTIVE_DATE => l_eff_dt
5756 ,p_person_id => l_pen.person_id
5757 ,p_business_group_id => p_business_group_id
5758 );
5759 end loop;
5760
5761
5762
5763 l_step := 14;
5764 --
5765 -- Update rt_end_dt in prtt_rate_val table
5766 --
5767 hr_utility.set_location(' c_prv EPE'||l_pen.elig_per_elctbl_chc_id,10);
5768 hr_utility.set_location(' c_prv ENB'||l_pen.enrt_bnft_id,10);
5769 hr_utility.set_location(' c_prv PEN'||p_prtt_enrt_rslt_id,10);
5770 --
5771 For l_prv in c_prv loop
5772 --
5773 hr_utility.set_location(' l_prv PRV'||l_prv.prtt_rt_val_id,10);
5774 --
5775 ben_prtt_rt_val_api.update_prtt_rt_val
5776 (P_VALIDATE => FALSE
5777 ,P_PRTT_RT_VAL_ID => l_prv.prtt_rt_val_id
5778 ,P_RT_END_DT => (l_prv.rt_strt_dt - 1)
5779 ,p_person_id => l_pen.person_id
5780 -- ,p_acty_base_rt_id => l_prv.acty_base_rt_id
5781 ,p_input_value_id => l_prv.input_value_id
5782 ,p_element_type_id => l_prv.element_type_id
5783 ,p_ended_per_in_ler_id => p_per_in_ler_id
5784 ,p_prtt_rt_val_stat_cd => 'VOIDD'
5785 ,p_business_group_id => p_business_group_id
5786 ,P_OBJECT_VERSION_NUMBER => l_prv.object_version_number
5787 ,P_EFFECTIVE_DATE => p_effective_date
5788 );
5789 end loop;
5790 --
5791 --
5792 -- 3574168: Remove PCP records
5793 -- Set End-date to coverage-end-date.
5794 --
5795 for l_pcp in c_pcp loop
5796 --
5797 hr_utility.set_location('Delete prmry_care_prvdr_id '|| l_pcp.prmry_care_prvdr_id,15);
5798 --
5799 ben_prmry_care_prvdr_api.delete_prmry_care_prvdr
5800 (P_VALIDATE => FALSE
5801 ,P_PRMRY_CARE_PRVDR_ID => l_pcp.prmry_care_prvdr_id
5802 ,P_EFFECTIVE_START_DATE => l_pcp.effective_start_date
5803 ,P_EFFECTIVE_END_DATE => l_pcp.effective_end_date
5804 ,P_OBJECT_VERSION_NUMBER => l_pcp.object_version_number
5805 ,P_EFFECTIVE_DATE => p_effective_date
5806 ,P_DATETRACK_MODE => hr_api.g_zap
5807 ,p_called_from => 'delete_enrollment'
5808 );
5809 --
5810 End loop;
5811 --
5812 -- Get future PCP records if any and zap - delete all of them.
5813 --
5814 for l_pcp_future in c_pcp_future loop
5815 --
5816 hr_utility.set_location('ZAP prmry_care_prvdr_id '|| l_pcp_future.prmry_care_prvdr_id, 15);
5817 --
5818 l_pcp_effective_date := l_pcp_future.effective_start_date ;
5819 --
5820 ben_prmry_care_prvdr_api.delete_prmry_care_prvdr
5821 (P_VALIDATE => FALSE
5822 ,P_PRMRY_CARE_PRVDR_ID => l_pcp_future.prmry_care_prvdr_id
5823 ,P_EFFECTIVE_START_DATE => l_pcp_future.effective_start_date
5824 ,P_EFFECTIVE_END_DATE => l_pcp_future.effective_end_date
5825 ,P_OBJECT_VERSION_NUMBER => l_pcp_future.object_version_number
5826 ,P_EFFECTIVE_DATE => l_pcp_effective_date
5827 ,P_DATETRACK_MODE => hr_api.g_zap
5828 ,p_called_from => 'delete_enrollment'
5829 );
5830 --
5831 End loop;
5832
5833 -- 3574168
5834 --
5835
5836 l_step := 120;
5837
5838 get_ben_pen_upd_dt_mode
5839 (p_effective_date => p_effective_date
5840 ,p_base_key_value => p_prtt_enrt_rslt_id
5841 ,P_desired_datetrack_mode => p_datetrack_mode
5842 ,P_datetrack_allow => l_datetrack_mode
5843 );
5844
5845 l_step := 125;
5846 --
5847 --2785410 - if the deenrollment record is already there in the case of unrestricted
5848 -- and now if the result gets voided the datetrack mode needs to be changed
5849 open c_unrestricted_future(p_per_in_ler_id => l_pen.per_in_ler_id,
5850 p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id,
5851 p_effective_start_date =>l_pen.effective_start_date);
5852 fetch c_unrestricted_future into l_dummy;
5853 if c_unrestricted_future%found then
5854 --
5855 ben_prtt_enrt_result_api.delete_prtt_enrt_result
5856 (p_validate => false,
5857 p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id,
5858 p_effective_start_date => l_effective_start_date,
5859 p_effective_end_date => l_effective_end_date,
5860 p_object_version_number => l_pen.object_version_number,
5861 p_effective_date => p_effective_date,
5862 p_datetrack_mode => hr_api.g_future_change,
5863 p_multi_row_validate => FALSE);
5864 --
5865 open c_pen;
5866 fetch c_pen into l_pen;
5867 close c_pen;
5868 --
5869 end if;
5870 close c_unrestricted_future;
5871
5872 ben_prtt_enrt_result_api.update_prtt_enrt_result
5873 (p_validate => FALSE
5874 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
5875 ,p_effective_start_date => l_effective_start_date
5876 ,p_effective_end_date => l_effective_end_date
5877 ,p_per_in_ler_id => l_pen.per_in_ler_id
5878 ,p_enrt_cvg_thru_dt => (l_pen.enrt_cvg_strt_dt - 1)
5879 ,p_prtt_enrt_rslt_stat_cd => 'VOIDD'
5880 ,p_object_version_number => l_pen.object_version_number
5881 ,p_effective_date => p_effective_date
5882 ,p_datetrack_mode => l_datetrack_mode
5883 ,p_multi_row_validate => p_multi_row_validate
5884 ,p_business_group_id => p_business_group_id );
5885
5886
5887 l_step := 136;
5888 --
5889 -- Do not call manage_enrt_bnft, if it is called from election_information
5890 -- as the call is always made from there.
5891 --
5892 --Bug 3256056 This call from election_information is associated with the
5893 --New results - That other call works fine if the result was continued from
5894 --the prevoius enrollment. But if the user made the change in the
5895 --current enrollment olny [I mean selected option 1 , saved and then now
5896 --changing to option 2 ] we don't want to keep the pen id on the enb record.
5897 --
5898 --if p_source is null or
5899 -- p_source <> 'benelinf' then
5900 --
5901 ben_election_information.manage_enrt_bnft
5902 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
5903 ,p_business_group_id => p_business_group_id
5904 ,p_effective_date => p_effective_date
5905 ,p_object_version_number => l_tmp_ovn
5906 ,p_per_in_ler_id => p_per_in_ler_id
5907 );
5908 --
5909 --end if;
5910 --
5911 l_step := 177;
5912
5913
5914 -- leslie code begin:
5915 -- when result is voided in correction mode, we can't compute premium
5916 -- credits. Tell use that they may want to manually.
5917 -- If in correction and esd of result is before first day of this month...
5918 if l_datetrack_mode = hr_api.g_correction and l_pen.effective_start_date <
5919 to_date(to_char(p_effective_date, 'mm-yyyy'), 'mm-yyyy') then
5920 ben_prem_prtt_monthly.premium_warning
5921 (p_person_id => l_pen.person_id
5922 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
5923 ,p_effective_start_date => l_pen.effective_start_date
5924 ,p_effective_date => p_effective_date
5925 ,p_warning => 'VOID');
5926
5927 end if;
5928 -- leslie code end.
5929
5930 -- write to change event log. -thayden
5931 l_step := 178;
5932 --
5933 if p_source is null or
5934 p_source <> 'benelinf' then
5935 ben_ext_chlg.log_benefit_chg
5936 (p_action => 'DELETE'
5937 ,p_old_pl_id => l_pen.pl_id
5938 ,p_old_oipl_id => l_pen.oipl_id
5939 ,p_old_enrt_cvg_strt_dt => l_pen.enrt_cvg_strt_dt
5940 ,p_old_enrt_cvg_end_dt => l_pen.enrt_cvg_thru_dt
5941 ,p_pl_id => l_pen.pl_id
5942 ,p_oipl_id => l_pen.oipl_id
5943 ,p_enrt_cvg_strt_dt => l_pen.enrt_cvg_strt_dt
5944 ,p_enrt_cvg_end_dt => (l_pen.enrt_cvg_strt_dt - 1)
5945 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
5946 ,p_per_in_ler_id => l_pen.per_in_ler_id
5947 ,p_person_id => l_pen.person_id
5948 ,p_business_group_id => p_business_group_id
5949 ,p_effective_date => p_effective_date
5950 );
5951 end if;
5952
5953 if g_debug then
5954 hr_utility.set_location(l_proc, 60);
5955 end if;
5956 --
5957 -- When in validation only mode raise the Validate_Enabled exception
5958 --
5959 if p_validate then
5960 raise hr_api.validate_enabled;
5961 end if;
5962 --
5963 if g_debug then
5964 hr_utility.set_location(' Leaving:'||l_proc, 70);
5965 end if;
5966 --
5967 Exception
5968 --
5969 when hr_api.validate_enabled
5970 then
5971 --
5972 -- As the Validate_Enabled exception has been raised
5973 -- we must rollback to the savepoint
5974 --
5975 ROLLBACK TO void_enrollment;
5976 --
5977 -- Only set output warning arguments
5978 -- (Any key or derived arguments must be set to null
5979 -- when validation only mode is being used.)
5980 --
5981 if g_debug then
5982 hr_utility.set_location(' Leaving:'||l_proc, 80);
5983 end if;
5984 when others then
5985 --
5986 -- A validation or unexpected error has occured
5987 --
5988 ROLLBACK TO void_enrollment;
5989 rpt_error(p_proc => l_proc, p_step => l_step);
5990 fnd_message.raise_error;
5991 --
5992 end void_enrollment;
5993 --
5994 -- ----------------------------------------------------------------------------
5995 -- |------------------------< delete_enrollment >-----------------------------|
5996 -- ----------------------------------------------------------------------------
5997 --
5998 procedure delete_enrollment
5999 (p_validate in boolean default false
6000 ,p_per_in_ler_id in number default NULL
6001 ,p_lee_rsn_id in number default NULL
6002 ,p_enrt_perd_id in number default NULL
6003 ,p_prtt_enrt_rslt_id in number
6004 ,p_business_group_id in number
6005 ,p_effective_start_date out nocopy date
6006 ,p_effective_end_date out nocopy date
6007 ,p_object_version_number in out nocopy number
6008 ,p_effective_date in date
6009 ,p_datetrack_mode in varchar2
6010 ,p_multi_row_validate in boolean default TRUE
6011 ,p_source in varchar2 default null
6012 ,p_enrt_cvg_thru_dt in date default null
6013 ,p_mode in varchar2 default null)
6014 is
6015 --
6016 l_fnd_message_exception exception;
6017 -- Get result and choice information for row we are trying to end.
6018 --
6019 cursor c_pen is
6020 select pen.pl_id
6021 ,pen.pgm_id
6022 ,pen.ptip_id
6023 ,pen.pl_typ_id
6024 ,pen.oipl_id
6025 ,pen.ler_id
6026 ,pen.person_id
6027 ,pen.business_group_id
6028 ,pen.ENRT_CVG_STRT_DT
6029 ,pen.ENRT_CVG_THRU_DT
6030 ,pen.SSPNDD_FLAG
6031 ,pen.ERLST_DEENRT_DT
6032 ,pen.effective_start_date
6033 ,pen.effective_end_date
6034 ,pen.object_version_number pen_ovn
6035 ,pen.rplcs_sspndd_rslt_id
6036 ,pen.per_in_ler_id pen_per_in_ler_id
6037 ,epe.elig_per_elctbl_chc_id
6038 ,epe.per_in_ler_id
6039 ,epe.object_version_number epe_ovn
6040 ,epe.MNDTRY_FLAG
6041 ,epe.fonm_cvg_strt_dt
6042 ,epe.ELCTBL_FLAG
6043 ,epe.AUTO_ENRT_FLAG
6044 ,enb.enrt_bnft_id
6045 ,pil.per_in_ler_stat_cd
6046 ,oipl.opt_id
6047 ,pl.name pl_name
6048 ,opt.name opt_name
6049 ,pl.imptd_incm_calc_cd
6050 from ben_prtt_enrt_rslt_f pen
6051 ,ben_elig_per_elctbl_chc epe
6052 ,ben_per_in_ler pil
6053 ,ben_enrt_bnft enb
6054 ,ben_oipl_f oipl
6055 ,ben_pl_f pl
6056 ,ben_opt_f opt
6057 where pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
6058 and pen.prtt_enrt_rslt_id = epe.prtt_enrt_rslt_id (+)
6059 and nvl(epe.elig_per_elctbl_chc_id, -1) = enb.elig_per_elctbl_chc_id (+)
6060 and pen.business_group_id = epe.business_group_id (+)
6061 and nvl(p_per_in_ler_id, pen.per_in_Ler_id) = epe.per_in_ler_id (+)
6062 and pen.business_group_id = p_business_group_id
6063 and p_effective_date between pen.effective_start_date
6064 and pen.effective_end_date
6065 and pil.per_in_ler_id(+)=epe.per_in_ler_id
6066 and pil.business_group_id(+)=epe.business_group_id
6067 and ( pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT') -- found row condition
6068 or pil.per_in_ler_stat_cd is null -- outer join condition
6069 )
6070 and pl.business_group_id=p_business_group_id
6071 and pl.pl_id =pen.pl_id
6072 and p_effective_date between
6073 pl.effective_start_date and pl.effective_end_date
6074 and oipl.business_group_id(+)=p_business_group_id
6075 and oipl.oipl_id(+)=pen.oipl_id
6076 and p_effective_date between
6077 oipl.effective_start_date(+) and oipl.effective_end_date(+)
6078 and opt.business_group_id(+)=p_business_group_id
6079 and opt.opt_id(+)=oipl.opt_id
6080 and p_effective_date between
6081 opt.effective_start_date(+) and opt.effective_end_date(+)
6082 ;
6083 l_pen c_pen%rowtype;
6084 l_prtt_prem_id number;
6085 --
6086 -- get all prtt_prem for result
6087 --
6088 /****************** CODE PRIOR TO WWBUG: 1646442 *******************
6089 cursor c_ppe is
6090 select ppe.prtt_prem_id,
6091 ppe.object_version_number,
6092 ppe.effective_start_date,
6093 ppe.effective_end_date,
6094 ppe.actl_prem_id
6095 from ben_prtt_prem_f ppe,
6096 ben_per_in_ler pil
6097 where ppe.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
6098 and pil.per_in_ler_id=ppe.per_in_ler_id
6099 and pil.business_group_id=ppe.business_group_id
6100 and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT');
6101 ******************** END CODE PRIOR TO WBUG: 1646442 ****************/
6102 /* Start of Changes for WWBUG: 1646442 */
6103 cursor c_ppe (p_ppe_dt_to_use IN DATE) is
6104 select ppe.prtt_prem_id,
6105 ppe.object_version_number,
6106 ppe.effective_start_date,
6107 ppe.effective_end_date,
6108 ppe.actl_prem_id
6109 from ben_prtt_prem_f ppe,
6110 ben_per_in_ler pil
6111 where ppe.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
6112 and pil.per_in_ler_id=ppe.per_in_ler_id
6113 and pil.business_group_id=ppe.business_group_id
6114 and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT')
6115 -- jcarpent added additional logic below to fix primary key error.
6116 -- case 1 is where you want the dt effective row
6117 -- case 2 is where you want the future dated rows to zap.
6118 and p_ppe_dt_to_use between ppe.effective_start_date and ppe.effective_end_date
6119 UNION
6120 select ppe1.prtt_prem_id,
6121 ppe1.object_version_number,
6122 ppe1.effective_start_date,
6123 ppe1.effective_end_date,
6124 ppe1.actl_prem_id
6125 from ben_prtt_prem_f ppe1,
6126 ben_per_in_ler pil
6127 where ppe1.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
6128 and pil.per_in_ler_id=ppe1.per_in_ler_id
6129 and pil.business_group_id=ppe1.business_group_id
6130 and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT')
6131 and ppe1.effective_start_date > p_ppe_dt_to_use
6132 and not exists
6133 (select 1
6134 from ben_prtt_prem_f ppe2,
6135 ben_per_in_ler pil
6136 where ppe2.prtt_prem_id = ppe1.prtt_prem_id
6137 and ppe2.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
6138 and pil.per_in_ler_id=ppe2.per_in_ler_id
6139 and pil.business_group_id=ppe2.business_group_id
6140 and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT')
6141 and p_ppe_dt_to_use between
6142 ppe2.effective_start_date and ppe2.effective_end_date);
6143 /* End of Changes for WWBUG: 1646442 */
6144 --
6145 l_ppe c_ppe%rowtype;
6146 --
6147 cursor c_prm is
6148 select prm.prtt_prem_by_mo_id,
6149 prm.object_version_number,
6150 prm.effective_start_date,
6151 prm.effective_end_date
6152 from ben_prtt_prem_by_mo_f prm
6153 where prm.prtt_prem_id = l_prtt_prem_id;
6154 --
6155 l_prm c_prm%rowtype;
6156 --
6157 -- Get all rates for result row we are trying to end.
6158 --
6159 cursor c_prv2 is
6160 select prv.prtt_rt_val_id
6161 ,prv.rt_strt_dt
6162 ,prv.per_in_ler_id
6163 ,prv.object_version_number
6164 ,prv.acty_base_rt_id
6165 ,abr.element_type_id
6166 ,abr.input_value_id
6167 from ben_prtt_rt_val prv
6168 ,ben_acty_base_rt_f abr
6169 where prv.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
6170 and prv.rt_end_dt = hr_api.g_eot
6171 and prv.business_group_id = p_business_group_id
6172 and prv.acty_base_rt_id = abr.acty_base_rt_id
6173 and p_effective_date between abr.effective_start_date
6174 and abr.effective_end_date
6175 ;
6176 --
6177 -- overlapped adj
6178 --
6179 cursor c_prv5(p_rt_end_dt date) is
6180 select prv.prtt_rt_val_id
6181 ,prv.rt_strt_dt
6182 ,prv.per_in_ler_id
6183 ,prv.object_version_number
6184 ,prv.acty_base_rt_id
6185 ,abr.element_type_id
6186 ,abr.input_value_id
6187 from ben_prtt_rt_val prv
6188 ,ben_acty_base_rt_f abr
6189 where prv.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
6190 and prv.per_in_ler_id <> p_per_in_ler_id -- basu
6191 and prv.rt_end_dt > p_rt_end_dt
6192 and prv.rt_end_dt <> hr_api.g_eot
6193 and prv.business_group_id = p_business_group_id
6194 and prv.acty_base_rt_id = abr.acty_base_rt_id
6195 and p_effective_date between abr.effective_start_date
6196 and abr.effective_end_date
6197 ;
6198 -- for bug 7206471
6199 -- overlapped coverage adj
6200 -- basu
6201 Cursor c_enrt_in_curr_le is
6202 select 'Y'
6203 from ben_prtt_enrt_rslt_f pen
6204 where pen.per_in_ler_id = p_per_in_ler_id
6205 and pen.effective_end_date = hr_api.g_eot
6206 and pen.enrt_cvg_thru_dt = hr_api.g_eot
6207 and pen.prtt_enrt_rslt_stat_cd is null;
6208 --
6209 l_enrt_in_curr_le varchar2(2);
6210 -- basu
6211 cursor c_pen5(p_cvg_end_dt date) is
6212 select pen.prtt_enrt_rslt_id
6213 ,pen.enrt_cvg_strt_dt
6214 ,pen.per_in_ler_id
6215 ,pen.object_version_number
6216 from ben_prtt_enrt_rslt_f pen
6217 ,ben_ptip_f ptip
6218 where pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id -- 245535
6219 and pen.per_in_ler_id <> p_per_in_ler_id -- basu
6220 and pen.enrt_cvg_thru_dt > p_cvg_end_dt -- '20-jan-2008'
6221 and pen.enrt_cvg_thru_dt <> hr_api.g_eot -- '31-dec-4712'
6222 and pen.business_group_id = p_business_group_id --81545
6223 and pen.ptip_id = ptip.ptip_id
6224 and p_effective_date between ptip.effective_start_date
6225 and ptip.effective_end_date;
6226
6227 l_cvg_adjust varchar2(1);
6228 l_effective_start_date date;
6229 l_effective_end_date date;
6230 -- end bug 7206471
6231 --
6232 -- Get program extra info to determine if rates should be adjusted.
6233 --
6234 cursor c_get_pgm_extra_info(p_pgm_id number) is
6235 select pgi_information1
6236 from ben_pgm_extra_info
6237 where information_type = 'ADJ_RATE_PREV_LF_EVT'
6238 and pgm_id = p_pgm_id;
6239 --
6240 -- Added for bug 7206471
6241 --
6242 cursor c_get_pgm_extra_info_cvg(p_pgm_id number) is
6243 select pgi_information1
6244 from ben_pgm_extra_info
6245 where information_type = 'ADJ_CVG_PREV_LF_EVT'
6246 and pgm_id = p_pgm_id;
6247 --
6248 -- End bug 7206471
6249 -- Get all rates for result row we are trying to end without looking at end date.
6250 --
6251 cursor c_prvdel is
6252 select prv.prtt_rt_val_id
6253 ,max(ecr.enrt_rt_id) enrt_rt_id
6254 ,prv.object_version_number
6255 ,ecr.acty_base_rt_id
6256 ,abr.element_type_id
6257 ,abr.input_value_id
6258 ,abr.entr_val_at_enrt_flag
6259 ,prv.rt_strt_dt
6260 from ben_prtt_rt_val prv
6261 ,ben_enrt_rt ecr
6262 ,ben_acty_base_rt_f abr
6263 where prv.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
6264 and prv.prtt_rt_val_id = ecr.prtt_rt_val_id (+)
6265 and prv.business_group_id = p_business_group_id
6266 and nvl(prv.acty_base_rt_id,-1) = abr.acty_base_rt_id (+)
6267 and p_effective_date between abr.effective_start_date (+)
6268 and abr.effective_end_date (+)
6269 group by
6270 prv.prtt_rt_val_id
6271 ,prv.object_version_number
6272 ,ecr.acty_base_rt_id
6273 ,abr.element_type_id
6274 ,abr.input_value_id
6275 ,abr.entr_val_at_enrt_flag
6276 ,prv.rt_strt_dt;
6277 --
6278 -- Rates having non-recurring element entries - prtt rt vals are end dated
6279 cursor c_prv3 (p_per_in_ler_id number)is
6280 select prv.prtt_rt_val_id
6281 ,prv.object_version_number
6282 ,ecr.enrt_rt_id
6283 ,ecr.acty_base_rt_id
6284 from ben_prtt_rt_val prv,
6285 ben_enrt_rt ecr
6286 where prv.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
6287 and prv.prtt_rt_val_id = ecr.prtt_rt_val_id
6288 and prv.rt_end_dt <> hr_api.g_eot
6289 and prv.business_group_id = p_business_group_id
6290 and prv.per_in_ler_id = p_per_in_ler_id
6291 and prv.prtt_rt_val_stat_cd is null;
6292 --
6293 cursor c_prv4 (p_rt_end_dt date) is
6294 select prv.prtt_rt_val_id
6295 ,ecr.enrt_rt_id enrt_rt_id
6296 ,prv.object_version_number
6297 ,ecr.acty_base_rt_id
6298 ,abr.element_type_id
6299 ,abr.input_value_id
6300 ,prv.rt_end_dt --This is needed to determine the future started rate
6301 from ben_prtt_rt_val prv
6302 ,ben_enrt_rt ecr
6303 ,ben_acty_base_rt_f abr
6304 where prv.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
6305 and prv.rt_end_dt > p_rt_end_dt
6306 and prv.prtt_rt_val_id = ecr.prtt_rt_val_id (+)
6307 and prv.business_group_id = p_business_group_id
6308 and prv.prtt_rt_val_stat_cd is null
6309 and nvl(prv.acty_base_rt_id,-1) = abr.acty_base_rt_id (+)
6310 and p_effective_date between abr.effective_start_date (+)
6311 and abr.effective_end_date (+);
6312 --
6313 cursor c_abr (p_acty_base_rt_id number) is
6314 select py.processing_type,
6315 abr.rcrrg_cd
6316 from ben_acty_base_rt_f abr,
6317 pay_element_types_f py
6318 where abr.element_type_id = py.element_type_id(+)
6319 and abr.acty_base_rt_id = p_acty_base_rt_id
6320 and p_effective_date between abr.effective_start_date
6321 and abr.effective_end_date
6322 and p_effective_date between py.effective_start_date(+)
6323 and py.effective_end_date(+);
6324 --
6325 l_abr c_abr%rowtype;
6326 --
6327 Cursor c_pcp(c_pcp_effective_date DATE)
6328 is
6329 select pcp.PRMRY_CARE_PRVDR_ID
6330 ,pcp.EFFECTIVE_START_DATE
6331 ,pcp.EFFECTIVE_END_DATE
6332 ,pcp.PRTT_ENRT_RSLT_ID
6333 ,pcp.BUSINESS_GROUP_ID
6334 ,pcp.OBJECT_VERSION_NUMBER
6335 from ben_prmry_care_prvdr_f pcp
6336 where business_group_id = p_business_group_id
6337 and prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
6338 and c_pcp_effective_date between effective_start_date --3631067: Changed p_effective_date to c_pcp_effective_date
6339 and effective_end_date
6340 ;
6341 -- 3574168
6342 -- Fetch all PCP records in future.
6343 Cursor c_pcp_future (c_pcp_effective_date DATE)
6344 is
6345 select pcp.PRMRY_CARE_PRVDR_ID
6346 ,pcp.EFFECTIVE_START_DATE
6347 ,pcp.EFFECTIVE_END_DATE
6348 ,pcp.PRTT_ENRT_RSLT_ID
6349 ,pcp.BUSINESS_GROUP_ID
6350 ,pcp.OBJECT_VERSION_NUMBER
6351 from ben_prmry_care_prvdr_f pcp
6352 where business_group_id = p_business_group_id
6353 and prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
6354 and c_pcp_effective_date < effective_start_date ----3631067: Changed p_effective_date to c_pcp_effective_date
6355 and NVL(effective_end_date, hr_api.g_eot) = hr_api.g_eot
6356 ;
6357 -- 3574168
6358
6359 --
6360 l_global_pil_rec ben_global_enrt.g_global_pil_rec_type;
6361 --
6362 -- ikasire: deleted the condition
6363 -- pen.enrt_cvg_strt_dt >= p_effective_date
6364 -- since it may not be always true. Instead added the
6365 -- condition pen.ENRT_CVG_THRU_DT = hr_api.g_eot
6366 -- to get the new prtt enrt record. Still there is a
6367 -- gap in this '1 prior' coding, which has to be
6368 -- handled with more detailed study.
6369 --Bug 2847110
6370 --18-Jan-2005
6371 --CF SUSP and INTERIM CASE
6372 --
6373 --bug#4967063 - added strt dt condition for getting new coverage at plan type
6374 --level - otherwise if multiple plans enrolled in same plan type leads to bug
6375 cursor c_new_cvg_strt_dt(l_pl_typ_id number, l_ptip_id number, l_pl_id number,
6376 p_enrt_cvg_strt_dt date ) is
6377 select max(enrt_cvg_strt_dt)
6378 from ben_prtt_enrt_rslt_f pen
6379 where pen.per_in_ler_id = nvl(p_per_in_ler_id, -1) -- is this OK?
6380 and ((pen.pgm_id is null and pen.pl_typ_id is not null
6381 and pen.pl_typ_id = nvl(l_pl_typ_id, -1))
6382 or (pen.ptip_id is not null and pen.ptip_id = nvl(l_ptip_id, -1))
6383 )
6384 and pen.no_lngr_elig_flag = 'N'
6385 and ((l_pl_id =-999 and pen.enrt_cvg_strt_dt >= p_enrt_cvg_strt_dt)
6386 or pen.pl_id = l_pl_id ) -- Bug 2847110
6387 and pen.prtt_enrt_rslt_stat_cd is null
6388 -- and pen.enrt_cvg_strt_dt >= p_effective_date
6389 and pen.ENRT_CVG_THRU_DT = hr_api.g_eot
6390 and pen.effective_end_date = hr_api.g_eot
6391 -- and pen.business_group_id = p_business_group_id
6392 --and p_effective_date between pen.effective_start_date
6393 -- and pen.effective_end_date
6394 and pen.prtt_enrt_rslt_id <> p_prtt_enrt_rslt_id
6395 ;
6396 --
6397 cursor c_intm_other_rslt(p_per_in_ler_id number) is
6398 select 'Y'
6399 from ben_prtt_enrt_rslt_f pen
6400 where pen.rplcs_sspndd_rslt_id = l_pen.rplcs_sspndd_rslt_id
6401 and pen.business_group_id = p_business_group_id
6402 and pen.sspndd_flag = 'Y'
6403 and pen.enrt_cvg_thru_dt = hr_api.g_eot
6404 and pen.effective_end_date = hr_api.g_eot
6405 and pen.prtt_enrt_rslt_stat_cd is null
6406 and p_effective_date between
6407 pen.effective_start_date and pen.effective_end_date
6408 -- Bug 6165501 : Added union clause if its a Correction case, and interim has already
6409 -- been end-dated by the new pil, then no need to call delete_enrollment for the interim
6410 UNION
6411 select 'Y'
6412 from ben_prtt_enrt_rslt_f pen, ben_le_clsn_n_rstr cls
6413 where pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
6414 and pen.prtt_enrt_rslt_stat_cd is null
6415 and pen.enrt_cvg_thru_dt <> hr_api.g_eot
6416 and pen.per_in_ler_id = p_per_in_ler_id
6417 and cls.bkup_tbl_id = pen.prtt_enrt_rslt_id
6418 and cls.bkup_tbl_typ_cd = 'BEN_PRTT_ENRT_RSLT_F_CORR'
6419 and cls.per_in_ler_ended_id = p_per_in_ler_id;
6420 -- End Bug 6165501
6421
6422 --
6423 cursor c_interim is
6424 select pen.prtt_enrt_rslt_id,
6425 pen.object_version_number,
6426 pen.effective_start_date,
6427 pen.effective_end_date
6428 from ben_prtt_enrt_rslt_f pen
6429 where pen.prtt_enrt_rslt_id = l_pen.rplcs_sspndd_rslt_id
6430 and pen.business_group_id = p_business_group_id
6431 and pen.prtt_enrt_rslt_stat_cd is null
6432 and p_effective_date between
6433 pen.effective_start_date and pen.effective_end_date;
6434
6435 cursor c_rslt_opt (p_person_id number ,
6436 p_pgm_id number ,
6437 p_pl_id number ,
6438 p_oipl_id number ,
6439 p_per_in_ler_id number ,
6440 p_effective_date date
6441 ) is
6442 select 'x'
6443 from ben_prtt_enrt_rslt_f pen
6444 where pen.person_id = p_person_id
6445 and nvl(p_pgm_id,-1) = nvl(pen.pgm_id,-1)
6446 and nvl(p_pl_id ,-1) = nvl(pen.pl_id,-1)
6447 and nvl(p_oipl_id,-1) = nvl(pen.oipl_id, -1)
6448 and (p_per_in_ler_id <> pen.per_in_ler_id
6449 or l_global_pil_rec.typ_cd = 'SCHEDDU') -- 4919591
6450 and pen.prtt_enrt_rslt_stat_cd is null
6451 and pen.sspndd_flag = 'N'
6452 and p_effective_date > pen.effective_start_date
6453 and pen.enrt_cvg_thru_dt > p_effective_date -- 4919591
6454 and pen.effective_end_date = hr_api.g_eot; --4919591
6455
6456
6457 cursor c_rslt_pl ( p_person_id number ,
6458 p_pgm_id number ,
6459 p_pl_id number ,
6460 p_per_in_ler_id number ,
6461 p_effective_date date
6462 ) is
6463 select 'x'
6464 from ben_prtt_enrt_rslt_f pen
6465 where pen.person_id = p_person_id
6466 and nvl(p_pgm_id,-1) = nvl(pen.pgm_id,-1)
6467 and p_pl_id = pen.pl_id
6468 and (p_per_in_ler_id <> pen.per_in_ler_id
6469 or l_global_pil_rec.typ_cd = 'SCHEDDU') -- 4919591
6470 and pen.prtt_enrt_rslt_stat_cd is null
6471 and pen.sspndd_flag = 'N'
6472 and p_effective_date > pen.effective_start_date
6473 and pen.enrt_cvg_thru_dt > p_effective_date; -- 4919591
6474 -- and pen.effective_end_date = hr_api.g_eot; -- 4919591------------7458990
6475
6476 cursor c_rslt_ptip( p_person_id number ,
6477 p_pgm_id number ,
6478 p_ptip_id number ,
6479 p_per_in_ler_id number ,
6480 p_effective_date date
6481 ) is
6482 select 'x'
6483 from ben_prtt_enrt_rslt_f pen
6484 where pen.person_id = p_person_id
6485 and p_pgm_id = pen.pgm_id
6486 and p_ptip_id = pen.ptip_id
6487 and (p_per_in_ler_id <> pen.per_in_ler_id
6488 or l_global_pil_rec.typ_cd = 'SCHEDDU')
6489 and pen.prtt_enrt_rslt_stat_cd is null
6490 and pen.sspndd_flag = 'N'
6491 and p_effective_date > pen.effective_start_date
6492 and pen.enrt_cvg_thru_dt > p_effective_date
6493 and pen.effective_end_date = hr_api.g_eot;
6494 --
6495 cursor c_per_in_ler (p_per_in_ler_id number) is
6496 select *
6497 from ben_per_in_ler
6498 where per_in_ler_id = p_per_in_ler_id
6499 and business_group_id = p_business_group_id;
6500
6501 --
6502 l_per_in_ler c_per_in_ler%rowtype;
6503 --
6504 cursor c_pen_ovn (p_prtt_enrt_rslt_id number, p_effective_date date ) is
6505 select pen.object_version_number,pen.effective_start_date --4663971
6506 from ben_prtt_enrt_rslt_f pen
6507 where pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
6508 and p_effective_date between pen.effective_start_date and pen.effective_end_date ;
6509 l_pen_ovn c_pen_ovn%rowtype;
6510 --
6511 cursor c_pel (p_elig_pe_elctbl_chc_id number) is
6512 select pel.enrt_perd_id,pel.lee_rsn_id
6513 from ben_pil_elctbl_chc_popl pel
6514 ,ben_elig_per_elctbl_chc epe
6515 where pel.pil_elctbl_chc_popl_id = epe.pil_elctbl_chc_popl_id
6516 and epe.elig_per_elctbl_chc_id = p_elig_pe_elctbl_chc_id;
6517 --
6518 CURSOR c_lee_rsn_for_plan (c_ler_id number, c_pl_id number,c_effective_date date ) IS
6519 SELECT leer.lee_rsn_id
6520 FROM ben_lee_rsn_f leer,
6521 ben_popl_enrt_typ_cycl_f petc
6522 WHERE leer.ler_id = c_ler_id
6523 AND leer.business_group_id = p_business_group_id
6524 AND c_effective_date BETWEEN leer.effective_start_date
6525 AND leer.effective_end_date
6526 AND leer.popl_enrt_typ_cycl_id = petc.popl_enrt_typ_cycl_id
6527 AND petc.pl_id = c_pl_id
6528 AND petc.enrt_typ_cycl_cd = 'L' -- life event
6529 AND petc.business_group_id = p_business_group_id
6530 AND c_effective_date BETWEEN petc.effective_start_date
6531 AND petc.effective_end_date;
6532 --
6533 CURSOR c_lee_rsn_for_program (c_ler_id number, c_pgm_id number,c_effective_date date )IS
6534 SELECT leer.lee_rsn_id
6535 FROM ben_lee_rsn_f leer,
6536 ben_popl_enrt_typ_cycl_f petc
6537 WHERE leer.ler_id = c_ler_id
6538 AND leer.business_group_id = p_business_group_id
6539 AND c_effective_date BETWEEN leer.effective_start_date
6540 AND leer.effective_end_date
6541 AND leer.popl_enrt_typ_cycl_id = petc.popl_enrt_typ_cycl_id
6542 AND petc.pgm_id = c_pgm_id
6543 AND petc.enrt_typ_cycl_cd = 'L'
6544 AND petc.business_group_id = p_business_group_id
6545 AND c_effective_date BETWEEN petc.effective_start_date
6546 AND petc.effective_end_date;
6547 --
6548 l_pel c_pel%rowtype;
6549 l_interim c_interim%rowtype;
6550 --
6551 -- Bug 2627078 update epe with current pen_id
6552 cursor c_curr_rslt (p_person_id number ,
6553 p_pgm_id number ,
6554 p_pl_id number ,
6555 p_oipl_id number ,
6556 p_per_in_ler_id number
6557 ) is
6558 select prtt_enrt_rslt_id
6559 from ben_prtt_enrt_rslt_f pen
6560 where pen.person_id = p_person_id
6561 and nvl(p_pgm_id,-1) = nvl(pen.pgm_id,-1)
6562 and nvl(p_pl_id ,-1) = nvl(pen.pl_id,-1)
6563 and nvl(p_oipl_id,-1) = nvl(pen.oipl_id, -1)
6564 and p_per_in_ler_id = pen.per_in_ler_id
6565 and pen.prtt_enrt_rslt_stat_cd is null
6566 and pen.enrt_cvg_thru_dt <> hr_api.g_eot
6567 ;
6568 --
6569 l_current_result_id number ;
6570 --
6571 -- Bug 2689915
6572 cursor c_ler is
6573 select typ_cd
6574 from ben_ler_f ler,
6575 ben_prtt_enrt_rslt_f pen
6576 where pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
6577 and pen.ler_id = ler.ler_id ;
6578 --
6579 cursor c_old_corr_pen (c_pil_id number
6580 ,c_pen_id number
6581 ,c_pen_effective_start_date date) is -- bug 7197868
6582 select per_in_ler_id
6583 from BEN_LE_CLSN_N_RSTR
6584 where bkup_tbl_id = c_pen_id
6585 and per_in_ler_ended_id = c_pil_id
6586 and per_in_ler_id <> c_pil_id
6587 and effective_start_date = c_pen_effective_start_date -- bug 7197868
6588 and enrt_cvg_thru_dt = hr_api.g_eot;
6589 l_corr_pil_id BEN_LE_CLSN_N_RSTR.per_in_ler_id%type ;
6590
6591 cursor c_pen_obj_no (c_pil_id number
6592 ,c_pen_id number ) is
6593 select object_version_number
6594 from ben_prtt_enrt_rslt_f pen
6595 where pen.prtt_enrt_rslt_id = c_pen_id
6596 and pen.per_in_ler_id = c_pil_id
6597 and p_effective_date between
6598 pen.effective_start_date and pen.effective_end_date ;
6599 --
6600 --Added for Bug#5018328
6601
6602 cursor c_crntly_enrd_flag(p_elig_pe_elctbl_chc_id number) is
6603 select epe.crntly_enrd_flag,ler.typ_cd
6604 from ben_elig_per_elctbl_chc epe,
6605 ben_ler_f ler,
6606 ben_prtt_enrt_rslt_f pen
6607 where epe.per_in_ler_id=p_per_in_ler_id
6608 and epe.elig_per_elctbl_chc_id=p_elig_pe_elctbl_chc_id
6609 and epe.prtt_enrt_rslt_id=pen.prtt_enrt_rslt_id
6610 and pen.per_in_ler_id=p_per_in_ler_id
6611 and pen.ler_id = ler.ler_id
6612 and nvl(epe.erlst_deenrt_dt,hr_api.g_sot) > p_effective_date;
6613
6614 l_crntly_enrd_flag varchar2(10);
6615 l_ler_type_cd varchar2(20);
6616
6617 --Added for Bug#5018328
6618
6619 cursor c_crntly_enrd_flag_unres(p_elig_pe_elctbl_chc_id number) is
6620 select ler.typ_cd
6621 from ben_prtt_enrt_rslt_f pen,
6622 ben_elig_per_elctbl_chc epe,
6623 ben_ler_f ler
6624 where epe.elig_per_elctbl_chc_id=p_elig_pe_elctbl_chc_id
6625 and epe.per_in_ler_id=p_per_in_ler_id
6626 and pen.ler_id = ler.ler_id
6627 and epe.prtt_enrt_rslt_id=pen.prtt_enrt_rslt_id
6628 and pen.per_in_ler_id=p_per_in_ler_id
6629 and nvl(epe.erlst_deenrt_dt,hr_api.g_sot) > p_effective_date;
6630
6631 l_typ_cd varchar2(20);
6632 --
6633
6634 --5663280
6635 cursor c_check_carry_fwd_enrt(p_prtt_enrt_rslt_id number,
6636 p_per_in_ler_id number,
6637 p_enrt_cvg_strt_dt date,
6638 p_effective_start_date date) is
6639 select 'Y'
6640 from ben_prtt_enrt_rslt_f pen
6641 where pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
6642 and pen.prtt_enrt_rslt_stat_cd is null
6643 and pen.enrt_cvg_thru_dt = to_date('4712/12/31','rrrr/mm/dd')
6644 and pen.per_in_ler_id <> p_per_in_ler_id
6645 and pen.enrt_cvg_strt_dt = p_enrt_cvg_strt_dt
6646 and pen.effective_end_date < p_effective_start_date;
6647
6648 l_check_carry_fwd_enrt varchar2(1);
6649 --
6650
6651 -----Bug 6925893
6652 cursor c_get_old_prv is
6653 SELECT oldprv.prtt_rt_val_id,
6654 oldprv.prtt_rt_val_stat_cd ,
6655 oldprv.object_version_number,
6656 abr.input_value_id,
6657 abr.element_type_id
6658 FROM ben_prtt_rt_val oldprv,
6659 ben_prtt_rt_val curprv,
6660 ben_acty_base_rt_f abr
6661 WHERE curprv.business_group_id=oldprv.business_group_id
6662 AND curprv.per_in_ler_id = oldprv.ended_per_in_ler_id
6663 AND oldprv.rt_end_dt <> hr_api.g_eot
6664 AND oldprv.acty_base_rt_id = curprv.acty_base_rt_id
6665 AND oldprv.prtt_rt_val_stat_cd IS NULL
6666 and curprv.prtt_enrt_rslt_id=p_prtt_enrt_rslt_id
6667 AND abr.acty_base_rt_id = oldprv.acty_base_rt_id
6668 AND p_effective_date BETWEEN abr.effective_start_date
6669 AND abr.effective_end_date
6670 and oldprv.ended_per_in_ler_id= p_per_in_ler_id
6671 AND oldprv.business_group_id= p_business_group_id;
6672
6673 l_get_old_prv c_get_old_prv%ROWTYPE;
6674 --
6675 -- Bug No 5637595 Added to get the lf_evt_ocrd_dt of the pil
6676 --
6677 cursor get_lf_evt_dt is
6678 select lf_evt_ocrd_dt from
6679 ben_per_in_ler where
6680 per_in_ler_id = p_per_in_ler_id and
6681 per_in_ler_stat_cd not in ('VOIDD','BCKDT');
6682 l_lf_evt_ocrd_dt date;
6683
6684
6685 --this is a fix for bug#:6641853 when
6686 --in the scenario where there is a
6687 --LE process and then the open process
6688 --on the same day.
6689 --The first LE is FONM and the person is enrolled
6690 --then again the person enrolls on the same day for the open
6691 --again the person chages the election on the other
6692 --day, which voids the current enrollment.
6693 --Now we check in the backup table to see
6694 --if any correction has happened and then we
6695 --dont void.
6696 cursor c_get_correction_info (cp_prtt_enrt_rslt_id NUMBER
6697 ,cp_effective_date DATE
6698 ,cp_per_in_ler_id NUMBER
6699 ) IS
6700 SELECT 'X' place_holder
6701 FROM ben_le_clsn_n_rstr bcr
6702 WHERE bcr.bkup_tbl_id=cp_prtt_enrt_rslt_id
6703 AND bcr.effective_start_date=cp_effective_date
6704 UNION
6705 SELECT 'X' place_holder
6706 FROM ben_le_clsn_n_rstr bcr
6707 WHERE bcr.bkup_tbl_id=cp_prtt_enrt_rslt_id
6708 AND bcr.per_in_ler_id <> cp_per_in_ler_id
6709 AND bcr.bkup_tbl_typ_cd LIKE '%CORR' ;
6710
6711 l_get_correction_info c_get_correction_info%ROWTYPE;
6712
6713 -- Local variable declaration.
6714 --
6715 l_temp_stat_cd VARCHAR2(30);
6716 l_temp_date DATE;
6717 l_proc varchar2(72); -- := g_package||'delete_enrollment';
6718 l_dpnt_cvg_end_dt date;
6719 l_dpnt_cvg_thru_dt date;
6720 l_dump_date date;
6721 l_datetrack_mode varchar2(20);
6722 l_step integer;
6723 l_tmp_ovn integer;
6724 l_enrt_cvg_strt_dt date;
6725 l_enrt_cvg_strt_dt_cd varchar2(30);
6726 l_enrt_cvg_strt_dt_rl number;
6727 l_rt_strt_dt date;
6728 l_rt_strt_dt_cd varchar2(30);
6729 l_rt_strt_dt_rl number;
6730 l_enrt_cvg_end_dt date;
6731 l_enrt_cvg_end_dt_cd varchar2(30);
6732 l_enrt_cvg_end_dt_rl number;
6733 l_rt_end_dt date;
6734 l_eff_dt date;
6735 l_rt_end_dt_cd varchar2(30);
6736 l_rt_end_dt_rl number;
6737 l_elig_per_elctbl_chc_id number(15);
6738 l_new_enrt_cvg_strt_dt date;
6739 l_date date;
6740 l_pil_id number;
6741 l_cvg_end_dt_cd varchar2(30);
6742 l_dummy varchar2(1);
6743 l_rqd_perd_enrt_nenrt_uom varchar2(30);
6744 l_rqd_perd_enrt_nenrt_val number;
6745 l_rqd_perd_enrt_nenrt_rl number;
6746 l_level varchar2(30);
6747 l_other_pen_rec ben_prtt_enrt_rslt_f%rowtype;
6748 l_intm_other_rslt varchar2(30) := 'N';
6749 l_new_enrollment varchar2(1) := 'N' ;
6750 l_object_version_number number ;
6751 --
6752 l_pl_rec ben_cobj_cache.g_pl_inst_row;
6753 l_oipl_rec ben_cobj_cache.g_oipl_inst_row;
6754 l_deenrol_dt date;
6755 l_prv_count number;
6756 l_env_rec ben_env_object.g_global_env_rec_type;
6757 l_benmngle_parm_rec benutils.g_batch_param_rec;
6758 l_enrt_perd_id number ;
6759 l_lee_rsn_id number := null ;
6760 /* Start of Changes WWBUG: 1646442: added */
6761 l_ppe_dt_to_use date;
6762 l_ppe_datetrack_mode varchar2(30);
6763 /* End of Changes WWBUG: 1646442 */
6764 l_ler_typ_cd varchar2(30);
6765 l_pcp_effective_date date;
6766 l_pcp_effective_start_date date;
6767 l_process_date date;
6768 l_rplcs_sspndd_rslt_id number;
6769 l_prtt_rt_val_stat_cd varchar2(30);
6770 l_sub varchar2(300);
6771 l_prtt_enrt_rslt_Stat_cd varchar2(300);
6772 l_adjust varchar2(1);
6773 prev_prtt_rt_val_id number := -1; -- Bug 5739530
6774 --
6775 procedure void_rate (p_prtt_enrt_rslt_id number,
6776 p_business_group_id number,
6777 p_person_id number,
6778 p_per_in_ler_id number,
6779 p_effective_date date) is
6780 --
6781 --Bug 3412562 Doesn't look like we need link to ben_enrt_rt table here.
6782 --
6783 cursor c_prv is
6784 select prv.prtt_rt_val_id
6785 ,prv.object_version_number
6786 ,prv.acty_base_rt_id
6787 ,abr.element_type_id
6788 ,abr.input_value_id
6789 ,prv.rt_strt_dt
6790 from ben_prtt_rt_val prv
6791 ,ben_acty_base_rt_f abr
6792 where prv.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
6793 -- bug: 5550679
6794 and prv.per_in_ler_id = p_per_in_ler_id
6795 --
6796 and prv.prtt_rt_val_stat_cd is null
6797 and prv.business_group_id = p_business_group_id
6798 and prv.acty_base_rt_id = abr.acty_base_rt_id
6799 and p_effective_date between abr.effective_start_date
6800 and abr.effective_end_date
6801 order by prv.rt_strt_dt desc;
6802 l_prv c_prv%rowtype;
6803
6804 begin
6805 --
6806 For l_prv in c_prv loop
6807 ben_prtt_rt_val_api.update_prtt_rt_val
6808 (P_VALIDATE => FALSE
6809 ,P_PRTT_RT_VAL_ID => l_prv.prtt_rt_val_id
6810 ,P_RT_END_DT => (l_prv.rt_strt_dt - 1)
6811 ,p_person_id => p_person_id
6812 ,p_input_value_id => l_prv.input_value_id
6813 ,p_element_type_id => l_prv.element_type_id
6814 ,p_ended_per_in_ler_id => p_per_in_ler_id
6815 ,p_prtt_rt_val_stat_cd => 'VOIDD'
6816 ,p_business_group_id => p_business_group_id
6817 ,P_OBJECT_VERSION_NUMBER => l_prv.object_version_number
6818 ,P_EFFECTIVE_DATE => p_effective_date
6819 );
6820 end loop;
6821 --
6822 end;
6823
6824
6825 --
6826 begin
6827 g_debug := hr_utility.debug_enabled;
6828
6829 if g_debug then
6830 l_proc := g_package||'delete_enrollment';
6831 hr_utility.set_location('Entering:'|| l_proc, 10);
6832 hr_utility.set_location('p_prtt_enrt_rslt_id'||
6833 to_char(p_prtt_enrt_rslt_id),10);
6834 end if;
6835
6836 --
6837 -- Issue a savepoint if operating in validation only mode
6838 --
6839 if p_source is null or
6840 p_source <> 'delete_enrollment' then
6841 --
6842 -- Do not issue the savepoint if this procedure called itself.
6843 --
6844 savepoint delete_enrollment;
6845 --
6846 end if;
6847 --
6848 -- Work out if we are being called from a concurrent program
6849 -- otherwise we need to initialize the environment
6850 --
6851 ben_env_object.get(p_rec => l_env_rec);
6852 if fnd_global.conc_request_id in (0,-1) then
6853 --bug#3568529
6854 -- ben_env_object.get(p_rec => l_env_rec);
6855 if l_env_rec.benefit_action_id is null then
6856 --
6857 hr_utility.set_location('Intialise env object',11);
6858 ben_env_object.init(p_business_group_id => p_business_group_id,
6859 p_effective_date => p_effective_date,
6860 p_thread_id => 1,
6861 p_chunk_size => 1,
6862 p_threads => 1,
6863 p_max_errors => 1,
6864 p_benefit_action_id => null);
6865 end if;
6866 --
6867 else
6868 -- to check whether it is called in benmngle selection mode
6869 ben_env_object.get(p_rec => l_env_rec);
6870 --
6871 -- If enrollment api's are called from concurrent manager for
6872 -- conversion or ivr kind of interfaces, call raises error.
6873 --
6874 if l_env_rec.benefit_action_id is not null then
6875
6876 benutils.get_batch_parameters(p_benefit_action_id => l_env_rec.benefit_action_id
6877 ,p_rec => l_benmngle_parm_rec);
6878 end if;
6879 --
6880 end if;
6881 --
6882 --bug#3714789 - the effective date is manipulated in beninelg and in selection
6883 --mode the lf evt ocrd dt is null- the actual effective date of the process is
6884 --used for coverage end date determination mode
6885 if p_per_in_ler_id is null and l_benmngle_parm_rec.process_date is not null then
6886 --
6887 l_process_date := l_benmngle_parm_rec.process_date;
6888 --
6889 else
6890 --
6891 l_process_date := p_effective_date;
6892 --
6893 end if;
6894 --
6895 l_step := 10;
6896 --
6897 open c_pen;
6898 fetch c_pen into l_pen;
6899 if c_pen%notfound then
6900 close c_pen;
6901 rpt_error(p_proc => l_proc, p_step => l_step);
6902 fnd_message.set_name('BEN','BEN_91711_ENRT_RSLT_NOT_FND');
6903 fnd_message.set_token('ID', to_char(p_prtt_enrt_rslt_id));
6904 fnd_message.set_token('PROC',l_proc);
6905 fnd_message.set_token('PERSON_ID', null);
6906 fnd_message.set_token('LER_ID', null);
6907 fnd_message.set_token('EFFECTIVE_DATE',to_char(p_effective_date));
6908 -- fnd_message.raise_error;
6909 raise l_fnd_message_exception;
6910
6911 end if;
6912 close c_pen;
6913 --
6914
6915 --Bug 2739965 we need this for unrestricted also.
6916 --
6917 open c_ler ;
6918 fetch c_ler into l_ler_typ_cd ;
6919 close c_ler ;
6920
6921 ---Bug 7458990
6922 /* open c_crntly_enrd_flag(l_pen.elig_per_elctbl_chc_id);
6923 fetch c_crntly_enrd_flag into l_crntly_enrd_flag,l_ler_type_cd;
6924 close c_crntly_enrd_flag;
6925
6926 --Bug#5018328
6927 if l_crntly_enrd_flag = 'Y' and l_ler_type_cd <> 'SCHEDDU' then
6928 fnd_message.set_name('BEN','BEN_91902_ENRT_NOT_ALWD_DELETE');
6929 fnd_message.set_token('PLANNAMEANDOPTIONNAME',l_pen.pl_name || ' '||l_pen.opt_name );
6930 fnd_message.set_token('EARLIESTDEENROLLMENTDATE',fnd_date.date_to_chardate(l_pen.erlst_deenrt_dt));
6931 -- fnd_message.raise_error;
6932 raise l_fnd_message_exception;
6933 end if;
6934
6935 open c_crntly_enrd_flag_unres(l_pen.elig_per_elctbl_chc_id);
6936 fetch c_crntly_enrd_flag_unres into l_typ_cd;
6937 close c_crntly_enrd_flag_unres;
6938
6939 if l_typ_cd='SCHEDDU' then
6940 fnd_message.set_name('BEN','BEN_91902_ENRT_NOT_ALWD_DELETE');
6941 fnd_message.set_token('PLANNAMEANDOPTIONNAME',l_pen.pl_name || ' '||l_pen.opt_name );
6942 fnd_message.set_token('EARLIESTDEENROLLMENTDATE',fnd_date.date_to_chardate(l_pen.erlst_deenrt_dt));
6943 -- fnd_message.raise_error;
6944 raise l_fnd_message_exception;
6945 end if; */
6946 ---Bug 7458990
6947
6948
6949 --Bug#5018328
6950 -----bug :1527086
6951 -- calcaulte the coverage end date to check the ERLST_DEENRT_DT
6952 -- this part is moved from updation part
6953
6954 -- If Electable choice ID is not passed, then per_in_ler, and either
6955 -- Enrt_perd_id or Lee_rsn_id need to be passed.
6956 --
6957 l_step := 14;
6958 If ( nvl(l_pen.per_in_ler_id, -1) <> nvl(p_per_in_ler_id,-1) ) then
6959 l_elig_per_elctbl_chc_id := NULL;
6960 Else
6961 --
6962 --Bug 5567840 added check for imputed income plan
6963 if l_pen.auto_enrt_flag = 'Y' and l_pen.elctbl_flag = 'N' and l_pen.imptd_incm_calc_cd is null then
6964 --
6965 fnd_message.set_name('BEN','BEN_94596_DEENROL_NOT_ALL');
6966 fnd_message.set_token('PLANNAME', l_pen.pl_name);
6967 -- fnd_message.raise_error;
6968 raise l_fnd_message_exception;
6969
6970 --
6971 end if;
6972 --
6973 l_elig_per_elctbl_chc_id := l_pen.elig_per_elctbl_chc_id;
6974 End if;
6975 l_pen.per_in_ler_id := p_per_in_ler_id;
6976 --
6977 ben_global_enrt.get_pil
6978 (p_per_in_ler_id => p_per_in_ler_id
6979 ,p_global_pil_rec => l_global_pil_rec);
6980
6981 -- bug 4616225 : cache built on date,de-enrollment date of a plan,may not have
6982 -- correct comp objects built.So,life event occured date to be considered first .
6983 -- And so both get_pl_dets,get_oipl_dets calls are moved down and are called after
6984 -- ben_global_enrt.get_pil call.
6985 ben_cobj_cache.get_pl_dets
6986 (p_business_group_id => p_business_group_id
6987 ,p_effective_date => nvl(l_global_pil_rec.lf_evt_ocrd_dt,p_effective_date)
6988 ,p_pl_id => l_pen.pl_id
6989 ,p_inst_row => l_pl_rec);
6990
6991 if l_pen.oipl_id is not null then
6992 ben_cobj_cache.get_oipl_dets
6993 (p_business_group_id => p_business_group_id
6994 ,p_effective_date => nvl(l_global_pil_rec.lf_evt_ocrd_dt,p_effective_date) --
6995 ,p_oipl_id => l_pen.oipl_id
6996 ,p_inst_row => l_oipl_rec);
6997 end if;
6998 -- end bug 4616225
6999 if l_global_pil_rec.person_id is not null then
7000 l_pen.person_id := l_global_pil_rec.person_id;
7001 l_pen.ler_id := l_global_pil_rec.ler_id;
7002 end if;
7003 -- 2386000 Find lee_rsn_id at popl level
7004 if l_elig_per_elctbl_chc_id is null then
7005 if l_pen.elig_per_elctbl_chc_id is not null then
7006 open c_pel(l_pen.elig_per_elctbl_chc_id);
7007 fetch c_pel into l_enrt_perd_id,l_lee_rsn_id ;
7008 close c_pel ;
7009 end if;
7010 -- If not found find at plan level
7011 if l_lee_rsn_id is null then
7012 open c_lee_rsn_for_plan(l_pen.ler_id, l_pen.pl_id,p_effective_date );
7013 fetch c_lee_rsn_for_plan into l_lee_rsn_id ;
7014 close c_lee_rsn_for_plan ;
7015 end if ;
7016 --
7017 if l_lee_rsn_id is null and l_pen.pgm_id is not null then
7018 open c_lee_rsn_for_program(l_pen.ler_id, l_pen.pgm_id,p_effective_date);
7019 fetch c_lee_rsn_for_program into l_lee_rsn_id ;
7020 close c_lee_rsn_for_program ;
7021 end if;
7022 end if ;
7023 -- Locate end date and rate codes and rules for participant.
7024 l_step := 30;
7025 /* Bug 2386000
7026 l_elig_per_elctbl_chc_id is passed as null we need to pass these ids to
7027 rate_and_coverage_dates procedure.
7028 p_pl_id;
7029 p_pgm_id;
7030 p_enrt_perd_id;
7031 p_lee_rsn_id;
7032 p_oipl_id;
7033 p_per_in_ler_id;
7034 p_person_id;
7035 */
7036 --- Determine FONM for delete enrollment
7037 if nvl( ben_manage_life_events.fonm,'N') = 'Y' then
7038
7039 if l_pen.fonm_cvg_strt_dt is not null then
7040 if l_pen.fonm_cvg_strt_dt <> ben_manage_life_events.g_fonm_cvg_strt_dt then
7041 ben_manage_life_events.g_fonm_cvg_strt_dt := l_pen.fonm_cvg_strt_dt ;
7042 end if ;
7043
7044 else
7045 -- set theflag and date to null
7046 ben_manage_life_events.fonm := 'N';
7047 ben_manage_life_events.g_fonm_cvg_strt_dt := null;
7048 ben_manage_life_events.g_fonm_rt_strt_dt := null;
7049
7050 end if ;
7051 else
7052 if l_pen.fonm_cvg_strt_dt is not null then
7053 ben_manage_life_events.fonm := 'Y';
7054 ben_manage_life_events.g_fonm_cvg_strt_dt := l_pen.fonm_cvg_strt_dt ;
7055 else
7056 ben_manage_life_events.fonm := 'N';
7057 ben_manage_life_events.g_fonm_cvg_strt_dt := null;
7058 ben_manage_life_events.g_fonm_rt_strt_dt := null;
7059 end if ;
7060 end if ;
7061 hr_utility.set_location (' FONM ' || ben_manage_life_events.fonm , 99 ) ;
7062 hr_utility.set_location (' FONM CVG ' || ben_manage_life_events.g_fonm_cvg_strt_dt , 99 ) ;
7063 -- eof FONM
7064
7065 ben_determine_date.rate_and_coverage_dates
7066 (p_which_dates_cd => 'C'
7067 ,p_date_mandatory_flag => 'N'
7068 ,p_compute_dates_flag => 'N'
7069 ,p_elig_per_elctbl_chc_id => l_elig_per_elctbl_chc_id
7070 ,p_business_group_id => l_pen.business_group_id
7071 ,P_PER_IN_LER_ID => l_pen.per_in_ler_id
7072 ,P_PERSON_ID => l_pen.person_id
7073 ,P_PGM_ID => l_pen.pgm_id
7074 ,P_PL_ID => l_pen.pl_id
7075 ,P_OIPL_ID => l_pen.oipl_id
7076 ,P_LEE_RSN_ID => nvl(p_lee_rsn_id,l_lee_rsn_id) -- 2386000
7077 ,P_ENRT_PERD_ID => nvl(p_enrt_perd_id,l_enrt_perd_id) -- 2386000
7078 ,p_enrt_cvg_strt_dt => l_enrt_cvg_strt_dt
7079 ,p_enrt_cvg_strt_dt_cd => l_enrt_cvg_strt_dt_cd
7080 ,p_enrt_cvg_strt_dt_rl => l_enrt_cvg_strt_dt_rl
7081 ,p_rt_strt_dt => l_rt_strt_dt
7082 ,p_rt_strt_dt_cd => l_rt_strt_dt_cd
7083 ,p_rt_strt_dt_rl => l_rt_strt_dt_rl
7084 ,p_enrt_cvg_end_dt => l_enrt_cvg_end_dt
7085 ,p_enrt_cvg_end_dt_cd => l_enrt_cvg_end_dt_cd
7086 ,p_enrt_cvg_end_dt_rl => l_enrt_cvg_end_dt_rl
7087 ,p_rt_end_dt => l_rt_end_dt
7088 ,p_rt_end_dt_cd => l_rt_end_dt_cd
7089 ,p_rt_end_dt_rl => l_rt_end_dt_rl
7090 ,p_effective_date => nvl(l_global_pil_rec.lf_evt_ocrd_dt,l_process_date) --p_effective_date
7091 );
7092 --
7093 l_cvg_end_dt_cd := l_enrt_cvg_end_dt_cd;
7094 --
7095 -- If called in the special mode which allows the cvg_thru_dt to be entered,
7096 -- the cvg_thru_dt_cd should be 'ENTRBL'. If it is not,no processing required.
7097 --
7098 if p_mode = 'CVG_END_DATE_ENTERABLE' and
7099 nvl(l_enrt_cvg_end_dt_cd, 'XXX') <> 'ENTRBL' then
7100 return;
7101 end if;
7102
7103 --
7104 ben_determine_date.rate_and_coverage_dates
7105 (p_elig_per_elctbl_chc_id => l_elig_per_elctbl_chc_id
7106 ,p_business_group_id => l_pen.business_group_id
7107 ,P_PER_IN_LER_ID => l_pen.per_in_ler_id
7108 ,P_PERSON_ID => l_pen.person_id
7109 ,P_PGM_ID => l_pen.pgm_id
7110 ,P_PL_ID => l_pen.pl_id
7111 ,P_OIPL_ID => l_pen.oipl_id
7112 ,P_LEE_RSN_ID => nvl(p_lee_rsn_id,l_lee_rsn_id)
7113 ,P_ENRT_PERD_ID => nvl(p_enrt_perd_id,l_enrt_perd_id)
7114 ,p_enrt_cvg_strt_dt => l_enrt_cvg_strt_dt
7115 ,p_enrt_cvg_strt_dt_cd => l_enrt_cvg_strt_dt_cd
7116 ,p_enrt_cvg_strt_dt_rl => l_enrt_cvg_strt_dt_rl
7117 ,p_rt_strt_dt => l_rt_strt_dt
7118 ,p_rt_strt_dt_cd => l_rt_strt_dt_cd
7119 ,p_rt_strt_dt_rl => l_rt_strt_dt_rl
7120 ,p_enrt_cvg_end_dt => l_enrt_cvg_end_dt
7121 ,p_enrt_cvg_end_dt_cd => l_enrt_cvg_end_dt_cd
7122 ,p_enrt_cvg_end_dt_rl => l_enrt_cvg_end_dt_rl
7123 ,p_rt_end_dt => l_rt_end_dt
7124 ,p_rt_end_dt_cd => l_rt_end_dt_cd
7125 ,p_rt_end_dt_rl => l_rt_end_dt_rl
7126 ,p_effective_date => nvl(l_global_pil_rec.lf_evt_ocrd_dt,l_process_date) --p_effective_date
7127 ,p_end_date => p_enrt_cvg_thru_dt
7128 );
7129 --
7130 ----Bug 6925893
7131 if substr(nvl(l_rt_end_dt_cd, 'X'), 1, 1) = 'W'
7132 and l_ler_typ_cd not in ('IREC','GSP','COMP','ABS','SCHEDDU') then
7133 --determine new rt start date
7134 ben_determine_date.rate_and_coverage_dates
7135 (p_elig_per_elctbl_chc_id => l_elig_per_elctbl_chc_id
7136 ,p_business_group_id => l_pen.business_group_id
7137 ,P_PER_IN_LER_ID => l_pen.per_in_ler_id
7138 ,P_PERSON_ID => l_pen.person_id
7139 ,P_PGM_ID => l_pen.pgm_id
7140 ,P_PL_ID => l_pen.pl_id
7141 ,P_OIPL_ID => l_pen.oipl_id
7142 ,P_LEE_RSN_ID => nvl(p_lee_rsn_id,l_lee_rsn_id)
7143 ,P_ENRT_PERD_ID => nvl(p_enrt_perd_id,l_enrt_perd_id)
7144 ,p_enrt_cvg_strt_dt => l_enrt_cvg_strt_dt
7145 ,p_enrt_cvg_strt_dt_cd => l_enrt_cvg_strt_dt_cd
7146 ,p_enrt_cvg_strt_dt_rl => l_enrt_cvg_strt_dt_rl
7147 ,p_rt_strt_dt => l_rt_strt_dt
7148 ,p_rt_strt_dt_cd => l_rt_strt_dt_cd
7149 ,p_rt_strt_dt_rl => l_rt_strt_dt_rl
7150 ,p_enrt_cvg_end_dt => l_enrt_cvg_end_dt
7151 ,p_enrt_cvg_end_dt_cd => l_enrt_cvg_end_dt_cd
7152 ,p_enrt_cvg_end_dt_rl => l_enrt_cvg_end_dt_rl
7153 ,p_rt_end_dt => l_rt_end_dt
7154 ,p_rt_end_dt_cd => l_rt_end_dt_cd
7155 ,p_rt_end_dt_rl => l_rt_end_dt_rl
7156 ,p_effective_date => p_effective_date
7157 ,p_end_date => p_enrt_cvg_thru_dt
7158 );
7159 end if;
7160 -----Bug 6925893
7161 if l_cvg_end_dt_cd = 'ENTRBL' and
7162 p_enrt_cvg_thru_dt is not null then
7163 l_enrt_cvg_end_dt := p_enrt_cvg_thru_dt;
7164 end if;
7165
7166 -----bug :1527086
7167
7168
7169 -- Check ERLST_DEENRT_DT
7170 --
7171 l_step := 15;
7172
7173 if p_source = 'beninelg' then
7174 --
7175 -- If called from newly ineligible package (beninelg), the comp-obejct
7176 -- need to de-enrolled even if there is a locking period.
7177 -- **** By-pass the check.
7178 --
7179 null;
7180 --
7181 --elsif (p_effective_date < nvl(l_pen.erlst_deenrt_dt,hr_api.g_sot) and
7182 -- on the erlst_deenrt_dt then deenrt is allowd so -1 is compared
7183 if g_debug then
7184 hr_utility.set_location('cvg end dt ' || l_enrt_cvg_end_dt , 7086);
7185 hr_utility.set_location('denrt ' || l_pen.erlst_deenrt_dt , 7086);
7186 end if;
7187 elsif (l_enrt_cvg_end_dt < nvl(l_pen.erlst_deenrt_dt,hr_api.g_sot)-1 and
7188 l_pen.sspndd_flag = 'N' /*and p_effective_date > l_pen.enrt_cvg_strt_dt */) then
7189 --
7190 -- Must now check if can deenroll legally. If an enrollment is
7191 -- found for the level at which the the required period of enrollment
7192 -- was defined where the per_in_ler is different, then delete is OK
7193 --
7194 -- Find the required period of enrollment code/rule/uom/level defined at
7195
7196 --Removed because the below condition is satisfied always.Bug : 6683229
7197
7198 /* if l_other_pen_rec.prtt_enrt_rslt_id is null then
7199 fnd_message.set_name('BEN','BEN_91902_ENRT_NOT_ALWD_DELETE');
7200 fnd_message.set_token('PLANNAMEANDOPTIONNAME',l_pen.pl_name || ' '||l_pen.opt_name );
7201 fnd_message.set_token('EARLIESTDEENROLLMENTDATE',fnd_date.date_to_chardate(l_pen.erlst_deenrt_dt));
7202 -- fnd_message.raise_error;
7203 raise l_fnd_message_exception;
7204 End if;
7205 */
7206 --- Bug : 6683229
7207
7208 ben_enrolment_requirements.find_rqd_perd_enrt(
7209 p_oipl_id =>l_pen.oipl_id
7210 ,p_opt_id =>l_pen.opt_id
7211 ,p_pl_id =>l_pen.pl_id
7212 ,p_ptip_id =>l_pen.ptip_id
7213 ,p_effective_date =>p_effective_date
7214 ,p_business_group_id =>p_business_group_id
7215 ,p_rqd_perd_enrt_nenrt_uom =>l_rqd_perd_enrt_nenrt_uom
7216 ,p_rqd_perd_enrt_nenrt_val =>l_rqd_perd_enrt_nenrt_val
7217 ,p_rqd_perd_enrt_nenrt_rl =>l_rqd_perd_enrt_nenrt_rl
7218 ,p_level =>l_level
7219 );
7220
7221 ---after getting the level chek enrollemnt is not new one or
7222 --- processed (for over riding) then then chek any other election before error
7223
7224 l_new_enrollment := 'N' ;
7225 if l_level = 'PTIP' then
7226 open c_rslt_ptip( l_pen.person_id ,
7227 l_pen.pgm_id ,
7228 l_pen.ptip_id ,
7229 l_pen.per_in_ler_id ,
7230 p_effective_date
7231 );
7232
7233 fetch c_rslt_ptip into l_dummy ;
7234 if c_rslt_ptip%notfound then
7235 l_new_enrollment := 'Y' ;
7236 end if ;
7237 close c_rslt_ptip ;
7238 elsif l_level = 'PL' then
7239 if g_debug then
7240 hr_utility.set_location('in pl level' , 161);
7241 end if;
7242 open c_rslt_pl(l_pen.person_id ,
7243 l_pen.pgm_id ,
7244 l_pen.pl_id ,
7245 l_pen.per_in_ler_id ,
7246 p_effective_date
7247 ) ;
7248
7249 fetch c_rslt_pl into l_dummy ;
7250 if c_rslt_pl%notfound then
7251 l_new_enrollment := 'Y' ;
7252 end if ;
7253 close c_rslt_pl ;
7254 else -- OPT,OIPL
7255 if g_debug then
7256 hr_utility.set_location('per in ler ' || l_pen.per_in_ler_id,161);
7257 hr_utility.set_location('start date ' || l_pen.effective_start_date,161);
7258 hr_utility.set_location('in opt level' , 161);
7259 end if;
7260 open c_rslt_opt ( l_pen.person_id ,
7261 l_pen.pgm_id ,
7262 l_pen.pl_id ,
7263 l_pen.oipl_id ,
7264 l_pen.per_in_ler_id,
7265 p_effective_date
7266 ) ;
7267
7268 fetch c_rslt_opt into l_dummy ;
7269 if c_rslt_opt%notfound then
7270 l_new_enrollment := 'Y' ;
7271 end if ;
7272 close c_rslt_opt ;
7273 end if;
7274 if g_debug then
7275 hr_utility.set_location(' l_new_enrollment ' || l_new_enrollment , 161 );
7276 end if;
7277 if (l_new_enrollment <> 'Y' or l_pen.per_in_ler_stat_cd = 'PROCD') then
7278 --
7279 -- Got level now see if other enrt in level exists
7280 --
7281 ben_enrolment_requirements.find_enrt_at_same_level(
7282 p_person_id =>l_pen.person_id
7283 ,p_opt_id =>l_pen.opt_id
7284 ,p_oipl_id =>l_pen.oipl_id
7285 ,p_pl_id =>l_pen.pl_id
7286 ,p_ptip_id =>l_pen.ptip_id
7287 ,p_pl_typ_id =>l_pen.pl_typ_id
7288 ,p_pgm_id =>l_pen.pgm_id
7289 ,p_effective_date =>p_effective_date
7290 ,p_business_group_id =>p_business_group_id
7291 ,p_prtt_enrt_rslt_id =>p_prtt_enrt_rslt_id
7292 ,p_level =>l_level
7293 ,p_pen_rec =>l_other_pen_rec
7294 );
7295 if g_debug then
7296 hr_utility.set_location('result ' || l_other_pen_rec.prtt_enrt_rslt_id ,161);
7297 end if;
7298 if l_other_pen_rec.prtt_enrt_rslt_id is null/* or l_crntly_enrd_flag='Y'*/ then -------7458990
7299 hr_utility.set_location('entering',9999);
7300 fnd_message.set_name('BEN','BEN_91902_ENRT_NOT_ALWD_DELETE');
7301 fnd_message.set_token('PLANNAMEANDOPTIONNAME',l_pen.pl_name || ' '||l_pen.opt_name );
7302 fnd_message.set_token('EARLIESTDEENROLLMENTDATE',fnd_date.date_to_chardate(l_pen.erlst_deenrt_dt));
7303 -- fnd_message.raise_error;
7304 raise l_fnd_message_exception;
7305
7306 End if;
7307 end if ;
7308 --
7309 end if;
7310 --
7311 -- Check if coverage has started. If coverage has started, then
7312 -- the coverage end date is updated and the enrollment result is
7313 -- updated with the coverage end date.
7314 --
7315 -- There are 4 cases:
7316 -- Case 1: Coverage started, Coverage Elected and delete in same day.
7317 -- * void result and its rates.
7318 -- Case 2: Coverage Started, Coverage Elected and delete but not in same
7319 -- day. (Elected earlier before Today)
7320 -- * Calculate its coverage end date.
7321 -- Case 3: Coverage not started yet. Elected and deleted in same day.
7322 -- * Date-track end dated.
7323 -- Case 4: Coverage not started yet. Elected and deleted not in same day.
7324 -- * Date-track end dated.
7325 --
7326 -- There is one more case - Bug#5123
7327 -- Coverage started, Coverage Ended and no election is possible
7328 -- Coverage Ended on account of newly Ineligible - This procedure
7329 -- called for imputed income plan when election is made and the
7330 -- row need not be Date-tracked
7331 --
7332 -- (maagrawa Jan 05,2001).
7333 -- One special modification is made here.
7334 -- When the coverage through date is allowed to be entered, then we need to
7335 -- always update the result by updating it with that date irrespective
7336 -- of when the coverage starts and when the elections are made.
7337 --
7338
7339 hr_utility.set_location('p_effective_date '|| to_char(p_effective_date) , 100);
7340 hr_utility.set_location('l_pen.ENRT_CVG_STRT_DT '|| to_char(l_pen.ENRT_CVG_STRT_DT) , 100);
7341 hr_utility.set_location('l_pen.enrt_cvg_thru_dt '|| to_char(l_pen.enrt_cvg_thru_dt) , 100);
7342 hr_utility.set_location('enrt_cvg_start_dt tilak '|| l_enrt_cvg_strt_dt , 100);
7343 hr_utility.set_location('enrt_cvg_start_dt tilak '|| l_enrt_cvg_strt_dt , 100);
7344 hr_utility.set_location('prtt_id tilak '|| p_prtt_enrt_rslt_id , 100);
7345 hr_utility.set_location('PLIPID tilak '|| l_pen.per_in_ler_id , 100);
7346 hr_utility.set_location('PLIPID tilak '|| l_pen.pen_per_in_ler_id , 100);
7347 hr_utility.set_location('p_mode '|| p_mode , 100);
7348
7349 -- future enrollment is deleted
7350 -- copy the data into backup table
7351
7352 if l_enrt_cvg_strt_dt < l_pen.enrt_cvg_strt_dt and l_pen.enrt_cvg_strt_dt < l_pen.enrt_cvg_thru_dt
7353 and l_pen.pen_per_in_ler_id <> l_pen.per_in_ler_id then
7354 ben_back_out_life_event.back_out_life_events
7355 (p_per_in_ler_id => l_pen.pen_per_in_ler_id ,
7356 p_bckt_per_in_ler_id => l_pen.per_in_ler_id , --Bug 5859714
7357 p_bckt_stat_cd => null ,
7358 p_business_group_id => p_business_group_id,
7359 p_bckdt_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id,
7360 p_copy_only => 'Y' ,
7361 p_effective_date => p_effective_date) ;
7362 end if ;
7363 l_step := 20;
7364 --
7365 -- Bug No 5637595 Moved the get_election date before if check as
7366 -- p_pil_id is required in if condition. Also added more checks to
7367 -- to see that for future dates coverages, if change of enrollment is done
7368 -- then previous end-dated coverage pen record should not be backout out.
7369 -- i.e. for this case code should go in Case 1 or Case 2 and not later ones.
7370 --
7371 Get_election_date(p_effective_date => p_effective_date
7372 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
7373 ,p_business_group_id => p_business_group_id
7374 ,p_date => l_date
7375 ,p_pil_id => l_pil_id
7376 );
7377 --
7378 open get_lf_evt_dt;
7379 fetch get_lf_evt_dt into l_lf_evt_ocrd_dt;
7380 if get_lf_evt_dt%NOTFOUND then
7381 l_lf_evt_ocrd_dt := p_effective_date;
7382 end if;
7383 close get_lf_evt_dt;
7384 --
7385 If ((p_effective_date between
7386 l_pen.ENRT_CVG_STRT_DT and nvl(l_pen.enrt_cvg_thru_dt, hr_api.g_eot))
7387 and ( (l_pen.SSPNDD_FLAG = 'N') or
7388 ( nvl(p_source,'x') <> 'benuneai' and l_pen.SSPNDD_FLAG = 'Y') --CFW
7389 )) or
7390 ((l_lf_evt_ocrd_dt between
7391 l_pen.ENRT_CVG_STRT_DT and nvl(l_pen.enrt_cvg_thru_dt, hr_api.g_eot))
7392 and l_pil_id <> p_per_in_ler_id
7393 and ( (l_pen.SSPNDD_FLAG = 'N') or
7394 ( nvl(p_source,'x') <> 'benuneai' and l_pen.SSPNDD_FLAG = 'Y') --CFW
7395 )) or
7396 p_mode = 'CVG_END_DATE_ENTERABLE' then
7397 --
7398 open c_old_corr_pen (p_per_in_ler_id
7399 , p_prtt_enrt_rslt_id
7400 , l_pen.effective_start_date) ; -- 7197868
7401 fetch c_old_corr_pen into l_corr_pil_id ;
7402 if c_old_corr_pen%found then
7403 l_pil_id := l_corr_pil_id ;
7404 hr_utility.set_location('not found corrected '|| l_proc , 99 ) ;
7405 end if ;
7406 close c_old_corr_pen ;
7407 hr_utility.set_location('p_per_in_ler_id '|| p_per_in_ler_id , 100);
7408 hr_utility.set_location('l_date '|| to_char(l_date) , 100);
7409 hr_utility.set_location('l_pil_id '|| l_pil_id , 100);
7410 hr_utility.set_location('p_mode '|| p_mode , 100);
7411 -- Case 1: Coverage started, Coverage Elected and delete in same day.
7412 -- * void result and its rates.
7413 if (l_date = p_effective_date) and
7414 ((p_per_in_ler_id is not null and p_per_in_ler_id = l_pil_id) or
7415 p_per_in_ler_id is null) and
7416 (p_mode is null or p_mode <> 'CVG_END_DATE_ENTERABLE')then
7417 if g_debug then
7418 hr_utility.set_location('p_effective_date='||p_effective_date,19);
7419 end if;
7420 hr_utility.set_location(' p_date '|| p_effective_date || '--'||l_pen.effective_start_date , 99 ) ;
7421 hr_utility.set_location(' p_datetrack_mode '|| p_datetrack_mode , 99 ) ;
7422 hr_utility.set_location(' p_source '|| p_source , 99 ) ;
7423 hr_utility.set_location(' result ' || p_prtt_enrt_rslt_id , 99 ) ;
7424 hr_utility.set_location(' thru date ' || p_enrt_cvg_thru_dt , 99 ) ;
7425 l_step := 21;
7426 void_enrollment
7427 (p_validate => p_validate
7428 ,p_per_in_ler_id => p_per_in_ler_id
7429 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
7430 ,p_business_group_id => p_business_group_id
7431 ,p_enrt_cvg_strt_dt => l_pen.enrt_cvg_strt_dt
7432 ,p_person_id => l_pen.person_id
7433 ,p_elig_per_elctbl_chc_id => l_pen.elig_per_elctbl_chc_id
7434 ,p_epe_ovn => l_pen.epe_ovn
7435 ,p_object_version_number => l_pen.pen_ovn
7436 ,p_effective_date => p_effective_date
7437 ,p_datetrack_mode => p_datetrack_mode
7438 ,p_multi_row_validate => p_multi_row_validate
7439 ,p_source => p_source
7440 ,p_enrt_bnft_id => l_pen.enrt_bnft_id);
7441 --
7442 if l_pen.pgm_id is not null then
7443 ben_provider_pools.remove_bnft_prvdd_ldgr
7444 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
7445 ,p_effective_date => p_effective_date
7446 ,p_business_group_id => p_business_group_id
7447 ,p_validate => FALSE
7448 ,p_datetrack_mode => hr_api.g_delete
7449 );
7450 end if;
7451 hr_utility.set_location('l_benmngle_parm_rec.mode_cd '|| l_benmngle_parm_rec.mode_cd , 100);
7452 hr_utility.set_location('l_env_rec.mode_cd '|| l_env_rec.mode_cd , 100);
7453 hr_utility.set_location('p_source '|| p_source , 100);
7454 -- 3398353
7455 /* In case of Unrestricted Enrollment running on the same-day,
7456 the dependent designation records (ben_elig_cvrd_dpnt_f) also
7457 needs to be end-dated / voided, when the enrollment is voided.
7458 */
7459 -- Also call the below code for 3797391 when source is benelinf
7460 --
7461 -- IF-UNRESTRICTED-OR-SCHEDULED
7462 -- Bug 4662362 : Removing the following IF condition since dependents / beneficiaries
7463 -- should be UNHOOKED for all cases
7464 --
7465 -- if (l_benmngle_parm_rec.mode_cd = 'S' or l_ler_typ_cd = 'SCHEDDU' ) or ( p_source = 'benelinf' ) then
7466 --
7467 if g_debug then
7468 hr_utility.set_location('Updating Dependent Records. l_enrt_cvg_end_dt: '||l_enrt_cvg_end_dt, 100);
7469 end if;
7470 --
7471 l_step := 30;
7472 --
7473 if g_debug then
7474 hr_utility.set_location('calc_dpnt_cvg_dt ', 100);
7475 end if;
7476 --
7477 calc_dpnt_cvg_dt
7478 (p_calc_end_dt => TRUE
7479 ,P_calc_strt_dt => FALSE
7480 ,p_per_in_ler_id => l_pen.per_in_ler_id
7481 ,P_person_id => l_pen.person_id
7482 ,p_pgm_id => l_pen.pgm_id
7483 ,p_pl_id => l_pen.pl_id
7484 ,p_oipl_id => l_pen.oipl_id
7485 ,p_ptip_id => l_pen.ptip_id
7486 ,p_ler_id => l_pen.ler_id
7487 ,P_BUSINESS_GROUP_ID => p_business_group_id
7488 ,P_EFFECTIVE_DATE => p_effective_date
7489 ,P_RETURNED_END_DT => l_dpnt_cvg_end_dt
7490 ,P_RETURNED_STRT_DT => l_dump_date
7491 ,p_enrt_cvg_end_dt => l_enrt_cvg_end_dt
7492 );
7493 --
7494 l_step := 40;
7495 --
7496 l_dpnt_cvg_thru_dt := l_dpnt_cvg_end_dt;
7497 --
7498 -- In this case we are voiding the enrollment. so, the dependent coverage should
7499 -- end the same day as the participants.
7500 --
7501 if l_dpnt_cvg_end_dt is not NULL then
7502 l_dpnt_cvg_thru_dt := least(l_enrt_cvg_end_dt, l_dpnt_cvg_end_dt);
7503 End if;
7504 --
7505 -- Unhook dependent rows
7506 --
7507 l_step := 50;
7508 --
7509 if g_debug then
7510 hr_utility.set_location('unhook_dpnt cvg-end-date: '||l_dpnt_cvg_thru_dt, 100);
7511 end if;
7512 --
7513 unhook_dpnt
7514 (p_validate => FALSE
7515 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
7516 ,p_per_in_ler_id => l_pen.per_in_ler_id
7517 ,p_cvg_thru_dt => l_dpnt_cvg_thru_dt
7518 ,p_business_group_id => p_business_group_id
7519 ,p_effective_date => p_effective_date
7520 ,p_datetrack_mode => p_datetrack_mode
7521 ,p_called_from => p_source
7522 );
7523 --
7524 if g_debug then
7525 hr_utility.set_location('unhook_bnf cvg-end-date: '||l_dpnt_cvg_thru_dt, 100);
7526 end if;
7527 --
7528 unhook_bnf
7529 (p_validate => FALSE
7530 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
7531 ,p_per_in_ler_id => l_pen.per_in_ler_id
7532 ,p_dsgn_thru_dt => l_enrt_cvg_end_dt
7533 ,p_business_group_id => p_business_group_id
7534 ,p_effective_date => p_effective_date
7535 ,p_datetrack_mode => p_datetrack_mode
7536 );
7537 -- end if;-- IF-UNRESTRICTED-OR-SCHEDULED
7538 ---
7539 remove_cert_action_items
7540 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
7541 ,p_effective_date => p_effective_date
7542 ,p_business_group_id => p_business_group_id
7543 ,p_validate => FALSE
7544 ,p_datetrack_mode => hr_api.g_zap
7545 ,p_source => p_source
7546 ,p_per_in_ler_id => l_pen.pen_per_in_ler_id
7547 ,p_per_in_ler_ended_id=> l_pen.per_in_ler_id
7548 );
7549 -- 3398353
7550 -- Case 2: Coverage Started, Coverage Elected and delete but not in same
7551 -- day. (Elected earlier before Today)
7552 -- * Calculated its coverage end date.
7553 else
7554 --
7555 -- 4642299: For either Rate or Coverage Code of '1 Prior'
7556 -- Open c_new_cvg_strt_dt to determine if new coverage exists
7557 -- If so, change the Rate / Coverage end-date to 1 day prior.
7558 -- Added 'LODBEWM','ODBEWM' too for 1 Prior logic.
7559 If (substr(nvl(l_cvg_end_dt_cd, 'X'), 1, 1) = 'W' or
7560 substr(nvl(l_cvg_end_dt_cd, 'X'), 1, 2) = 'LW' or
7561 substr(nvl(l_rt_end_dt_cd, 'X'), 1, 1) = 'W' or
7562 substr(nvl(l_rt_end_dt_cd, 'X'), 1, 2) = 'LW' or
7563 l_rt_end_dt_cd in ('LDPPOEFD','LDPPFEFD','LODBEWM','ODBEWM') ) and
7564 (p_per_in_ler_id <> l_pil_id or l_ler_typ_cd = 'SCHEDDU' or
7565 (p_per_in_ler_id = l_pil_id and l_ler_typ_cd not in ('IREC','GSP','COMP','ABS'))) then
7566 -- Bug 2847110
7567 hr_utility.set_location('c_new_cvg_strt_dt,srav : '||l_new_enrt_cvg_strt_dt,199);
7568 open c_new_cvg_strt_dt(l_pen.pl_typ_id, l_pen.ptip_id,l_pen.pl_id,
7569 l_enrt_cvg_strt_dt );
7570 fetch c_new_cvg_strt_dt into l_new_enrt_cvg_strt_dt;
7571 close c_new_cvg_strt_dt;
7572 --
7573 if l_new_enrt_cvg_strt_dt is null then
7574 open c_new_cvg_strt_dt(l_pen.pl_typ_id, l_pen.ptip_id,-999,
7575 l_enrt_cvg_strt_dt );
7576 fetch c_new_cvg_strt_dt into l_new_enrt_cvg_strt_dt;
7577 close c_new_cvg_strt_dt;
7578 end if;
7579 --
7580 End if;
7581 --
7582 -- Change Coverage Dates to 1 Prior
7583 if (substr(nvl(l_cvg_end_dt_cd, 'X'), 1, 1) = 'W' or
7584 substr(nvl(l_cvg_end_dt_cd, 'X'), 1, 2) = 'LW' ) and
7585 (p_per_in_ler_id <> l_pil_id or l_ler_typ_cd = 'SCHEDDU' ) then
7586 --
7587 if l_new_enrt_cvg_strt_dt is not null then
7588 l_enrt_cvg_end_dt := nvl(l_new_enrt_cvg_strt_dt - 1, l_enrt_cvg_end_dt ) ;
7589 end if;
7590 --
7591 end if;
7592 --
7593 if g_debug then
7594 hr_utility.set_location('c_new_cvg_strt_dt'||l_new_enrt_cvg_strt_dt,199);
7595 hr_utility.set_location('l_enrt_cvg_end_dt'||l_enrt_cvg_end_dt,199);
7596 end if;
7597 --
7598 -- Change Rate Dates to 1 Prior
7599 If (substr(nvl(l_rt_end_dt_cd, 'X'), 1, 1) = 'W' or
7600 substr(nvl(l_rt_end_dt_cd, 'X'), 1, 2) = 'LW' or
7601 l_rt_end_dt_cd in ('LDPPOEFD','LDPPFEFD','LODBEWM','ODBEWM') )
7602 -- Bug: 4268494. Evaluate '1 Prior' for these codes as well.
7603 -- Bug: 4642299 Added 'LODBEWM','ODBEWM' too for 1 Prior logic.
7604 then
7605 --
7606 if g_debug then
7607 hr_utility.set_location(' pen api rt strt dt ' || l_rt_strt_dt, 299 );
7608 hr_utility.set_location(' pen api rt end dt ' || l_rt_end_dt, 299 );
7609 end if;
7610 --bug#3260564
7611 if l_new_enrt_cvg_strt_dt is not null then
7612 l_rt_end_dt := nvl(l_rt_strt_dt - 1,l_rt_end_dt) ;
7613 end if;
7614 --
7615 End if;
7616 --
7617 If l_enrt_cvg_end_dt is NULL then
7618 rpt_error(p_proc => l_proc, p_step => l_step);
7619 fnd_message.set_name('BEN','BEN_91702_NOT_DET_CVG_END_DT');
7620 -- fnd_message.raise_error;
7621 raise l_fnd_message_exception;
7622
7623 End if;
7624 --
7625 If l_rt_end_dt is NULL then
7626 rpt_error(p_proc => l_proc, p_step => l_step);
7627 fnd_message.set_name('BEN','BEN_91703_NOT_DET_RATE_END_DT');
7628 -- fnd_message.raise_error;
7629 raise l_fnd_message_exception;
7630 end if;
7631 --
7632 -- when the result is voided the participant rate rows also should be voided as sometimes
7633 -- the rate end date comes greater or equal to rate start date which is not voiding the rate rows
7634 -- Update rt_end_dt in prtt_rate_val table
7635 --
7636 --Bug 5368060
7637 --Dont void the rate if the PEN record is Backed-Out
7638 --If the PEN record is end-dated in the subsequent life event dont void the rate
7639
7640 --Bug 5499809
7641 --Void the enrollment rate if the delete enrollment is being performed in the same life event and that life event is not unrestricted LE
7642
7643 -- Commented the below if condition
7644 -- if l_pen.enrt_cvg_strt_dt > l_enrt_cvg_end_dt then
7645
7646 if ((l_pen.per_in_ler_id = l_pen.pen_per_in_ler_id) and (l_ler_typ_cd <> 'SCHEDDU')) then
7647 --
7648 --5663280
7649 open c_check_carry_fwd_enrt(p_prtt_enrt_rslt_id, p_per_in_ler_id, l_pen.enrt_cvg_strt_dt,
7650 l_pen.effective_start_date);
7651 fetch c_check_carry_fwd_enrt into l_check_carry_fwd_enrt;
7652 close c_check_carry_fwd_enrt;
7653
7654 if l_check_carry_fwd_enrt is null then
7655 hr_utility.set_location('Void Rate procedure is called',3455);
7656 void_rate (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id,
7657 p_business_group_id => p_business_group_id,
7658 p_person_id => l_pen.person_id,
7659 p_per_in_ler_id => p_per_in_ler_id,
7660 p_effective_date => p_effective_date );
7661
7662 -----Bug 6925893
7663 If substr(nvl(l_rt_end_dt_cd, 'X'), 1, 1) = 'W' then
7664 open c_get_old_prv;
7665 fetch c_get_old_prv into l_get_old_prv;
7666 if c_get_old_prv%found then
7667 hr_utility.set_location('l_get_old_prv.input_value_id,srav : '||l_get_old_prv.input_value_id,3455);
7668 hr_utility.set_location('l_get_old_prv.prtt_rt_val_id :'||l_get_old_prv.prtt_rt_val_id,3455);
7669 hr_utility.set_location('p_prtt_enrt_rslt_id :'||p_prtt_enrt_rslt_id,3455);
7670 hr_utility.set_location('l_rt_end_dt :'||l_rt_end_dt,3455);
7671
7672 ben_prtt_rt_val_api.update_prtt_rt_val
7673 (P_VALIDATE => FALSE
7674 ,P_PRTT_RT_VAL_ID => l_get_old_prv.prtt_rt_val_id
7675 ,P_RT_END_DT => l_rt_end_dt
7676 ,p_person_id => l_pen.person_id
7677 ,p_input_value_id => l_get_old_prv.input_value_id
7678 ,p_element_type_id => l_get_old_prv.element_type_id
7679 ,p_prtt_rt_val_stat_cd => null
7680 ,p_business_group_id => p_business_group_id
7681 ,P_OBJECT_VERSION_NUMBER => l_get_old_prv.object_version_number
7682 ,P_EFFECTIVE_DATE => p_effective_date
7683 );
7684 hr_utility.set_location('P_RT_END_DT,srav :'||hr_api.g_eot,3455);
7685 end if;
7686 close c_get_old_prv;
7687 hr_utility.set_location('P_RT_END_DT,srav,not fund :'||hr_api.g_eot,3455);
7688 hr_utility.set_location('p_effective_start_date :'||p_effective_start_date,3455);
7689 hr_utility.set_location('p_effective_date :'||p_effective_date,3455);
7690 end if;
7691 -----Bug 6925893
7692 end if;
7693 end if;
7694 --End Bug 5499809
7695
7696 hr_utility.set_location('P_RT_END_DT,srav,not fund1 :'||hr_api.g_eot,3455);
7697 --
7698 l_step := 35;
7699 if g_debug then
7700 hr_utility.set_location(l_proc,3456);
7701 end if;
7702 -- rate is having non recurring
7703 if g_debug then
7704 hr_utility.set_location(l_deenrol_dt,3459);
7705 end if;
7706 for l_prv in c_prv3 (p_per_in_ler_id) loop
7707 --check whether rate is non-recurring
7708 open c_abr(l_prv.acty_base_rt_id);
7709 fetch c_abr into l_abr;
7710 close c_abr;
7711 --
7712 if (l_abr.processing_type = 'N' or
7713 l_abr.rcrrg_cd = 'ONCE' ) and
7714 l_pen.enrt_cvg_strt_dt > l_enrt_cvg_end_dt then
7715 null;
7716 else
7717 exit;
7718 end if;
7719 if g_debug then
7720 hr_utility.set_location('delete prtt',3459);
7721 end if;
7722 update ben_enrt_rt
7723 set prtt_rt_val_id = null
7724 where enrt_rt_id = l_prv.enrt_rt_id;
7725 --
7726 ben_prtt_rt_val_api.delete_prtt_rt_val
7727 (P_VALIDATE => FALSE
7728 ,P_PRTT_RT_VAL_ID => l_prv.prtt_rt_val_id
7729 ,P_OBJECT_VERSION_NUMBER => l_prv.object_version_number
7730 ,P_EFFECTIVE_DATE => l_eff_dt
7731 ,p_person_id => l_pen.person_id
7732 ,p_business_group_id => p_business_group_id
7733 );
7734 end loop;
7735 For l_prv in c_prv2 loop
7736 if g_debug then
7737 hr_utility.set_location(l_proc,3457);
7738 end if;
7739 l_prv_count := l_prv_count + 1;
7740 if (nvl(l_prv.per_in_ler_id, -1) <> nvl(p_per_in_ler_id,-1)) and
7741 l_rt_end_dt < l_prv.rt_strt_dt then
7742 l_prtt_rt_val_stat_cd := 'BCKDT';
7743 end if;
7744 ben_prtt_rt_val_api.update_prtt_rt_val
7745 (P_VALIDATE => FALSE
7746 ,P_PRTT_RT_VAL_ID => l_prv.prtt_rt_val_id
7747 ,P_RT_END_DT => l_rt_end_dt
7748 ,p_person_id => l_pen.person_id
7749 --Bug#2625060 - for converted data, null is passed for activity base rt id
7750 -- ,p_acty_base_rt_id => l_prv.acty_base_rt_id
7751 ,p_input_value_id => l_prv.input_value_id
7752 ,p_prtt_rt_val_stat_cd => l_prtt_rt_val_stat_cd
7753 ,p_element_type_id => l_prv.element_type_id
7754 ,p_ended_per_in_ler_id => p_per_in_ler_id
7755 ,p_business_group_id => p_business_group_id
7756 ,P_OBJECT_VERSION_NUMBER => l_prv.object_version_number
7757 ,P_EFFECTIVE_DATE => p_effective_date
7758 );
7759 if g_debug then
7760 hr_utility.set_location(l_proc,3458);
7761 end if;
7762 end loop;
7763 --
7764 -- Adjust overlapping rates . Bug 5391554
7765 --
7766 -- basu
7767 hr_utility.set_location('p_per_in_ler_id '||p_per_in_ler_id,44333);
7768 --
7769 open c_enrt_in_curr_le;
7770 fetch c_enrt_in_curr_le into l_enrt_in_curr_le;
7771 --
7772 if c_enrt_in_curr_le%found then
7773 --
7774 hr_utility.set_location('l_enrt_in_curr_le '||l_enrt_in_curr_le,44333);
7775 --
7776 if l_enrt_in_curr_le = 'Y' then
7777 -- basu
7778 open c_get_pgm_extra_info(l_pen.pgm_id);
7779 fetch c_get_pgm_extra_info into l_adjust;
7780 if c_get_pgm_extra_info%found then
7781 if l_adjust = 'Y' then
7782 for l_prv5 in c_prv5(l_rt_end_dt) loop
7783 --
7784 if g_debug then
7785 hr_utility.set_location('Adjusting rate '||l_rt_end_dt,111);
7786 end if;
7787 ben_prtt_rt_val_api.update_prtt_rt_val
7788 (P_VALIDATE => FALSE
7789 ,P_PRTT_RT_VAL_ID => l_prv5.prtt_rt_val_id
7790 ,P_RT_END_DT => l_rt_end_dt
7791 ,p_person_id => l_pen.person_id
7792 ,p_input_value_id => l_prv5.input_value_id
7793 ,p_element_type_id => l_prv5.element_type_id
7794 ,p_ended_per_in_ler_id => p_per_in_ler_id
7795 ,p_business_group_id => p_business_group_id
7796 ,P_OBJECT_VERSION_NUMBER => l_prv5.object_version_number
7797 ,P_EFFECTIVE_DATE => p_effective_date
7798 );
7799 end loop;
7800 end if;
7801 end if;
7802 close c_get_pgm_extra_info;
7803 --
7804 -- Adjust overlapping coverages . Bug 7206471
7805 --
7806 open c_get_pgm_extra_info_cvg(l_pen.pgm_id);
7807 fetch c_get_pgm_extra_info_cvg into l_cvg_adjust;
7808 if c_get_pgm_extra_info_cvg%found then
7809 if l_cvg_adjust = 'Y' then
7810 --
7811 for l_pen5 in c_pen5(l_enrt_cvg_end_dt) loop
7812 --
7813 if g_debug then
7814 hr_utility.set_location('Adjusting coverage for '||l_enrt_cvg_end_dt,44333);
7815 end if;
7816 ben_prtt_enrt_result_api.update_prtt_enrt_result
7817 (p_validate => FALSE,
7818 p_prtt_enrt_rslt_id => l_pen5.prtt_enrt_rslt_id,
7819 p_effective_start_date => l_effective_start_date,
7820 p_effective_end_date => l_effective_end_date,
7821 p_business_group_id => p_business_group_id,
7822 p_object_version_number => l_pen5.object_version_number,
7823 p_effective_date => p_effective_date,
7824 p_datetrack_mode => hr_api.g_correction,
7825 p_multi_row_validate => FALSE,
7826 p_enrt_cvg_thru_dt => l_enrt_cvg_end_dt,
7827 p_person_id => l_pen.person_id
7828 );
7829 end loop; -- c_pen5
7830 end if; -- if l_cvg_adjust = 'Y'
7831 end if; -- c_get_pgm_extra_info_cvg found
7832 close c_get_pgm_extra_info_cvg;
7833 end if; -- basu
7834 end if; -- basu
7835 close c_enrt_in_curr_le; -- basu
7836 --
7837 -- end bug 7206471
7838 --
7839 -- Bug#2038814 - cursor above updates only the last prtt_rt_val and if there is
7840 -- any future dated prtt_rt_val, rows with rt end date greater than the calculated rt end
7841 -- date needs to be updated
7842 -- Bug 2739965
7843 if l_benmngle_parm_rec.mode_cd = 'S' or l_ler_typ_cd = 'SCHEDDU' then
7844 if g_debug then
7845 hr_utility.set_location('ben mngle mode',111);
7846 hr_utility.set_location('rate end date'||l_rt_end_dt,111);
7847 end if;
7848 For l_prv4 in c_prv4 (l_rt_end_dt) loop
7849 if g_debug then
7850 hr_utility.set_location(l_proc,3459);
7851 end if;
7852 -- 2739965 In case of unrestricted enrollment, this happens only when there are future rates
7853 -- and they got deleted as part of c_prv2 process above. Lets us throw this error
7854 -- here warning the user about the deletion of the future rate.
7855 --
7856 /* Bug 5739530 : Update prv only if it has not been updated previously */
7857 if l_prv4.prtt_rt_val_id <> prev_prtt_rt_val_id then
7858 --
7859 prev_prtt_rt_val_id := l_prv4.prtt_rt_val_id;
7860 --
7861 if fnd_global.conc_request_id in ( 0,-1) then
7862 -- Issue a warning to the user. These will display on the enrt forms.
7863 ben_warnings.load_warning
7864 (p_application_short_name => 'BEN',
7865 p_message_name => 'BEN_93369_DEL_FUT_RATE',
7866 p_parma => fnd_date.date_to_chardate( l_prv4.rt_end_dt+1 ),
7867 p_parmb => l_pen.pl_name || ' '||l_pen.opt_name,
7868 p_person_id => l_pen.person_id);
7869 end if;
7870 --
7871 ben_prtt_rt_val_api.update_prtt_rt_val
7872 (P_VALIDATE => FALSE
7873 ,P_PRTT_RT_VAL_ID => l_prv4.prtt_rt_val_id
7874 ,P_RT_END_DT => l_rt_end_dt
7875 ,p_person_id => l_pen.person_id
7876 --Bug#2625060 - for converted data, null is passed for activity base rt id
7877 -- ,p_acty_base_rt_id => l_prv4.acty_base_rt_id
7878 ,p_input_value_id => l_prv4.input_value_id
7879 ,p_element_type_id => l_prv4.element_type_id
7880 ,p_ended_per_in_ler_id => p_per_in_ler_id
7881 ,p_business_group_id => p_business_group_id
7882 ,P_OBJECT_VERSION_NUMBER => l_prv4.object_version_number
7883 ,P_EFFECTIVE_DATE => p_effective_date
7884 );
7885 if g_debug then
7886 hr_utility.set_location(l_proc,3460);
7887 end if;
7888 --
7889 end if; /* End Bug 5739530 */
7890 --
7891 end loop;
7892 --
7893 end if;
7894 if g_debug then
7895 hr_utility.set_location(l_proc,3459);
7896 end if;
7897 --
7898 -- 3574168: Remove PCP records
7899 -- Set End-date to coverage-end-date.
7900 --
7901 l_pcp_effective_date := NVL(l_enrt_cvg_end_dt+1, p_effective_date);
7902 --
7903 for l_pcp in c_pcp(l_pcp_effective_date) loop
7904 --
7905 hr_utility.set_location('DELETE prmry_care_prvdr_id '|| l_pcp.prmry_care_prvdr_id, 15);
7906 hr_utility.set_location('PCP ESD: EED '|| l_pcp.effective_start_date ||': '||l_pcp.effective_end_date, 15);
7907 hr_utility.set_location('Effective Date to delete '|| l_pcp_effective_date, 15);
7908 hr_utility.set_location('DATETRACK_MODE '|| hr_api.g_delete, 15);
7909 -- Since, deletion automatically sets end-date to 1 day less than effective-date,
7910 -- call the delete-api with effective_date = cvg_thru_date+1.
7911 --
7912 ben_prmry_care_prvdr_api.delete_prmry_care_prvdr
7913 (P_VALIDATE => FALSE
7914 ,P_PRMRY_CARE_PRVDR_ID => l_pcp.prmry_care_prvdr_id
7915 ,P_EFFECTIVE_START_DATE => l_pcp.effective_start_date
7916 ,P_EFFECTIVE_END_DATE => l_pcp.effective_end_date
7917 ,P_OBJECT_VERSION_NUMBER => l_pcp.object_version_number
7918 ,P_EFFECTIVE_DATE => l_pcp_effective_date
7919 ,P_DATETRACK_MODE => hr_api.g_delete
7920 ,p_called_from => 'delete_enrollment'
7921 );
7922 --
7923 End loop;
7924 --
7925 -- Get future PCP records if any and zap - delete all of them.
7926 --
7927 for l_pcp_future in c_pcp_future(l_pcp_effective_date) loop
7928 --
7929 l_pcp_effective_start_date := l_pcp_future.effective_start_date;
7930 --
7931 hr_utility.set_location('ZAP prmry_care_prvdr_id '|| l_pcp_future.prmry_care_prvdr_id, 15);
7932 hr_utility.set_location('PCP ESD: EED '|| l_pcp_future.effective_start_date ||': '||l_pcp_future.effective_end_date, 15);
7933 hr_utility.set_location('Effective Date to delete '|| l_pcp_effective_start_date, 15);
7934 --
7935 ben_prmry_care_prvdr_api.delete_prmry_care_prvdr
7936 (P_VALIDATE => FALSE
7937 ,P_PRMRY_CARE_PRVDR_ID => l_pcp_future.prmry_care_prvdr_id
7938 ,P_EFFECTIVE_START_DATE => l_pcp_future.effective_start_date
7939 ,P_EFFECTIVE_END_DATE => l_pcp_future.effective_end_date
7940 ,P_OBJECT_VERSION_NUMBER => l_pcp_future.object_version_number
7941 ,P_EFFECTIVE_DATE => l_pcp_effective_start_date
7942 ,P_DATETRACK_MODE => hr_api.g_zap
7943 ,p_called_from => 'delete_enrollment'
7944 );
7945 End loop;
7946 -- 3574168
7947 --
7948 -- Get dependent coverage End date. If Participant coverage end date
7949 -- is greater than dependent coverage end date, then use participant.
7950 --
7951 l_step := 40;
7952 --
7953 calc_dpnt_cvg_dt
7954 (p_calc_end_dt => TRUE
7955 ,P_calc_strt_dt => FALSE
7956 ,p_per_in_ler_id => l_pen.per_in_ler_id
7957 ,P_person_id => l_pen.person_id
7958 ,p_pgm_id => l_pen.pgm_id
7959 ,p_pl_id => l_pen.pl_id
7960 ,p_oipl_id => l_pen.oipl_id
7961 ,p_ptip_id => l_pen.ptip_id
7962 ,p_ler_id => l_pen.ler_id
7963 ,P_BUSINESS_GROUP_ID => p_business_group_id
7964 ,P_EFFECTIVE_DATE => p_effective_date
7965 ,P_RETURNED_END_DT => l_dpnt_cvg_end_dt
7966 ,P_RETURNED_STRT_DT => l_dump_date
7967 ,p_enrt_cvg_end_dt => l_enrt_cvg_end_dt
7968 );
7969 --
7970 l_step := 90;
7971 --
7972 -- bug 3327224 -- make dpnt cvg independent of prtt's cvg
7973 /*
7974 If l_dpnt_cvg_end_dt is not NULL then
7975 l_dpnt_cvg_thru_dt := least(l_enrt_cvg_end_dt, l_dpnt_cvg_end_dt);
7976 End if;
7977 */
7978 l_dpnt_cvg_thru_dt := l_dpnt_cvg_end_dt;
7979 --
7980 -- Unhook dependent rows
7981 --
7982 l_step := 110;
7983 unhook_dpnt
7984 (p_validate => FALSE
7985 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
7986 ,p_per_in_ler_id => l_pen.per_in_ler_id
7987 ,p_cvg_thru_dt => l_dpnt_cvg_thru_dt
7988 ,p_business_group_id => p_business_group_id
7989 ,p_effective_date => p_effective_date
7990 ,p_datetrack_mode => p_datetrack_mode
7991 ,p_called_from => p_source
7992 );
7993 unhook_bnf
7994 (p_validate => FALSE
7995 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
7996 ,p_per_in_ler_id => l_pen.per_in_ler_id
7997 ,p_dsgn_thru_dt => l_enrt_cvg_end_dt
7998 ,p_business_group_id => p_business_group_id
7999 ,p_effective_date => p_effective_date
8000 ,p_datetrack_mode => p_datetrack_mode
8001 );
8002 remove_cert_action_items
8003 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8004 ,p_effective_date => p_effective_date
8005 ,p_end_date => l_enrt_cvg_end_dt
8006 ,p_business_group_id => p_business_group_id
8007 ,p_validate => FALSE
8008 ,p_datetrack_mode => hr_api.g_delete
8009 ,p_source => p_source
8010 ,p_per_in_ler_id => l_pen.pen_per_in_ler_id
8011 ,p_per_in_ler_ended_id=> l_pen.per_in_ler_id
8012 );
8013 --
8014 l_step := 120;
8015 --
8016 hr_utility.set_location(' Before get_ben_pen_upd_dt_mode '||p_datetrack_mode,123);
8017 get_ben_pen_upd_dt_mode
8018 (p_effective_date => p_effective_date
8019 ,p_base_key_value => p_prtt_enrt_rslt_id
8020 ,P_desired_datetrack_mode => p_datetrack_mode
8021 ,P_datetrack_allow => l_datetrack_mode
8022 ,p_ler_typ_cd => l_ler_typ_cd -- Bug 2739965
8023 );
8024 hr_utility.set_location(' After get_ben_pen_upd_dt_mode '||l_datetrack_mode,123);
8025 --
8026 l_step := 125;
8027 --
8028 if g_debug then
8029 hr_utility.set_location('enrt_cvg_end_dt='||l_enrt_cvg_end_dt,19);
8030 end if;
8031 --
8032 --CFW. If deleting a suspended result, remove interim pen id
8033 -- below code is commenetd as part of 5347887.
8034 /*l_rplcs_sspndd_rslt_id := hr_api.g_number;
8035 if l_pen.sspndd_flag = 'Y' then
8036 l_rplcs_sspndd_rslt_id := null;
8037 end if;*/
8038 -- bug#5363388
8039 if l_enrt_cvg_end_dt < l_pen.enrt_cvg_strt_dt then
8040 --
8041 if l_pen.per_in_ler_id <> l_pen.pen_per_in_ler_id then
8042 l_prtt_enrt_rslt_Stat_cd := 'BCKDT';
8043 end if;
8044 --
8045 end if;
8046 --Bug 5499809
8047 --Void the enrollment if the delete is being performed in the same life event and that life event is not unrestricted LE
8048 if ((l_pen.per_in_ler_id = l_pen.pen_per_in_ler_id) and (l_ler_typ_cd <> 'SCHEDDU') ) then
8049
8050 --Bug#:6641853
8051 OPEN c_get_correction_info (p_prtt_enrt_rslt_id,
8052 l_pen.effective_start_date,
8053 l_pen.per_in_ler_id
8054 );
8055 FETCH c_get_correction_info INTO l_get_correction_info;
8056 CLOSE c_get_correction_info;
8057
8058 IF l_get_correction_info.place_holder='X' THEN
8059 l_prtt_enrt_rslt_Stat_cd:=NULL;
8060 l_datetrack_mode:='CORRECTION';
8061 ELSE
8062
8063 --5663280
8064 open c_check_carry_fwd_enrt(p_prtt_enrt_rslt_id, p_per_in_ler_id, l_pen.enrt_cvg_strt_dt,
8065 l_pen.effective_start_date);
8066 fetch c_check_carry_fwd_enrt into l_check_carry_fwd_enrt;
8067 close c_check_carry_fwd_enrt;
8068
8069 if l_check_carry_fwd_enrt is null then
8070 l_prtt_enrt_rslt_Stat_cd := 'VOIDD';
8071 end if;
8072 END IF;
8073 end if;
8074
8075 if g_debug then
8076 hr_utility.set_location('prtt stat cd'||l_prtt_enrt_rslt_Stat_cd,20);
8077 hr_utility.set_location('l_ler_typ_cd'||l_ler_typ_cd,20);
8078 end if;
8079
8080 --End Bug 5499809
8081
8082 ben_prtt_enrt_result_api.update_prtt_enrt_result
8083 (p_validate => FALSE
8084 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8085 ,p_effective_start_date => p_effective_start_date
8086 ,p_effective_end_date => p_effective_end_date
8087 ,p_per_in_ler_id => l_pen.per_in_ler_id
8088 ,p_ler_id => l_pen.ler_id
8089 ,p_enrt_cvg_thru_dt => l_enrt_cvg_end_dt
8090 --,p_rplcs_sspndd_rslt_id => l_rplcs_sspndd_rslt_id /* 5347887*/
8091 ,p_object_version_number => l_pen.pen_ovn
8092 ,p_effective_date => p_effective_date
8093 ,p_datetrack_mode => l_datetrack_mode
8094 ,p_multi_row_validate => p_multi_row_validate
8095 ,p_business_group_id => p_business_group_id
8096 ,p_prtt_enrt_rslt_stat_cd => l_prtt_enrt_rslt_Stat_cd
8097 );
8098 l_step := 126;
8099 --
8100 if p_source is null or
8101 p_source <> 'benelinf' then
8102 ben_ext_chlg.log_benefit_chg
8103 (p_action => 'DELETE'
8104 ,p_old_pl_id => l_pen.pl_id
8105 ,p_old_oipl_id => l_pen.oipl_id
8106 ,p_old_enrt_cvg_strt_dt => l_pen.enrt_cvg_strt_dt
8107 ,p_old_enrt_cvg_end_dt => l_pen.enrt_cvg_thru_dt
8108 ,p_pl_id => l_pen.pl_id
8109 ,p_oipl_id => l_pen.oipl_id
8110 ,p_enrt_cvg_strt_dt => l_pen.enrt_cvg_strt_dt
8111 ,p_enrt_cvg_end_dt => l_enrt_cvg_end_dt
8112 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8113 ,p_per_in_ler_id => l_pen.per_in_ler_id
8114 ,p_person_id => l_pen.person_id
8115 ,p_business_group_id => p_business_group_id
8116 ,p_effective_date => p_effective_date
8117 );
8118 end if;
8119 l_step := 127;
8120 --
8121 if l_pen.pgm_id is not null then
8122 ben_provider_pools.remove_bnft_prvdd_ldgr
8123 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8124 ,p_effective_date => p_effective_date
8125 ,p_business_group_id => p_business_group_id
8126 ,p_validate => FALSE
8127 ,p_datetrack_mode => hr_api.g_delete
8128 );
8129 end if;
8130 --
8131 end if;
8132 -- Special Case - Bug#5123
8133 Elsif (p_effective_date > l_pen.enrt_cvg_thru_dt)
8134 /* and l_pen.SSPNDD_FLAG = 'N'*/ then
8135 -- do nothing
8136 null;
8137 --
8138 -- Case 3: Coverage not started yet. Elected and deleted in same day.
8139 -- Case 4: Coverage not started yet. Elected and deleted not in same day.
8140 -- * Date-track end dated.
8141 Else
8142 --- if the coverage starts in future date and the per_in_ler_id is not the same
8143 --- the result are not deleted (ZAP), zaping create the problem if the current
8144 --- LE is backedout, it need the result to reintiate the previos LE
8145 ---
8146 Get_election_date(p_effective_date => p_effective_date
8147 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8148 ,p_business_group_id => p_business_group_id
8149 ,p_date => l_date
8150 ,p_pil_id => l_pil_id
8151 );
8152 l_step := 135;
8153 if g_debug then
8154 hr_utility.set_location('p_datetrack_mode='||p_datetrack_mode,20);
8155 end if;
8156 if p_source is null or p_source = 'benelinf' then
8157 -- Bug 2537720
8158 -- This is not allowing to update the enrollment on the same date for
8159 -- the suspended enrollment.So added the l_pen.effective_start_date < p_effective_date
8160 -- condition.
8161 if p_datetrack_mode=hr_api.g_update
8162 and l_pen.effective_start_date < p_effective_date
8163 and p_per_in_ler_id <> l_pil_id then -----Added for the Bug 7311284
8164 --
8165 l_eff_dt:=p_effective_date-1;
8166 else
8167 l_eff_dt:=p_effective_date;
8168 end if;
8169 else
8170 l_eff_dt := p_effective_date;
8171 end if;
8172 if g_debug then
8173 hr_utility.set_location('per in ler ='|| p_per_in_ler_id ||' old ' || l_pil_id,21);
8174 hr_utility.set_location('future dated cvg ='||l_pen.enrt_cvg_strt_dt,21);
8175 end if;
8176 --- bug 2546259 the if condition added to treat the future dated Coverage
8177 --- if future dated cvg exisit dont zap the result, if the current LE
8178 --- Backedout then the future dated result hase to be restored
8179 --- Instead of zaping the result it is voided now
8180 if p_effective_date < l_pen.enrt_cvg_strt_dt
8181 and p_per_in_ler_id <> l_pil_id /* and l_pen.SSPNDD_FLAG = 'N' */ then
8182 -- Voiding future dated coverage started in previous LE
8183 --
8184 if g_debug then
8185 hr_utility.set_location('future dated cvg ='||l_pen.enrt_cvg_strt_dt,21);
8186 end if;
8187 If substr(nvl(l_cvg_end_dt_cd, 'X'), 1, 1) = 'W' or
8188 substr(nvl(l_cvg_end_dt_cd, 'X'), 1, 2) = 'LW' then
8189 --Bug 2847110
8190 open c_new_cvg_strt_dt(l_pen.pl_typ_id, l_pen.ptip_id, l_pen.pl_id,
8191 l_enrt_cvg_strt_dt );
8192 fetch c_new_cvg_strt_dt into l_new_enrt_cvg_strt_dt;
8193 if c_new_cvg_strt_dt%found then
8194 --
8195 l_enrt_cvg_end_dt := nvl(l_new_enrt_cvg_strt_dt- 1,l_enrt_cvg_end_dt);
8196 close c_new_cvg_strt_dt;
8197 else
8198 close c_new_cvg_strt_dt;
8199 --
8200 open c_new_cvg_strt_dt(l_pen.pl_typ_id, l_pen.ptip_id,-999,
8201 l_enrt_cvg_strt_dt );
8202 fetch c_new_cvg_strt_dt into l_new_enrt_cvg_strt_dt;
8203 if c_new_cvg_strt_dt%found then
8204 l_enrt_cvg_end_dt := nvl(l_new_enrt_cvg_strt_dt - 1, l_enrt_cvg_end_dt ) ;
8205 end if;
8206 close c_new_cvg_strt_dt;
8207 --
8208 end if;
8209 --
8210 End if;
8211 --
8212 if g_debug then
8213 hr_utility.set_location('c_new_cvg_strt_dt'||l_new_enrt_cvg_strt_dt,199);
8214 hr_utility.set_location('l_enrt_cvg_end_dt'||l_enrt_cvg_end_dt,199);
8215 end if;
8216 -- ikasire: Added the cases starting with 'LW'
8217 -- fixed typo - changed from l_cvg_end_dt_cd to l_rt_end_dt_cd in
8218 -- the if condition
8219 If substr(nvl(l_rt_end_dt_cd, 'X'), 1, 1) = 'W' or
8220 substr(nvl(l_rt_end_dt_cd, 'X'), 1, 2) = 'LW'
8221 then
8222 --
8223 if g_debug then
8224 hr_utility.set_location(' pen api rt strt dt ' || l_rt_strt_dt, 299 );
8225 hr_utility.set_location(' pen api rt end dt ' || l_rt_end_dt, 299 );
8226 end if;
8227 l_rt_end_dt := nvl(l_rt_strt_dt - 1,l_rt_end_dt) ;
8228 End if;
8229 --
8230 If l_enrt_cvg_end_dt is NULL then
8231 rpt_error(p_proc => l_proc, p_step => l_step);
8232 fnd_message.set_name('BEN','BEN_91702_NOT_DET_CVG_END_DT');
8233 -- fnd_message.raise_error;
8234 raise l_fnd_message_exception;
8235 End if;
8236 --
8237 If l_rt_end_dt is NULL then
8238 rpt_error(p_proc => l_proc, p_step => l_step);
8239 fnd_message.set_name('BEN','BEN_91703_NOT_DET_RATE_END_DT');
8240 -- fnd_message.raise_error;
8241 raise l_fnd_message_exception;
8242 end if;
8243 --
8244 -- Update rt_end_dt in prtt_rate_val table
8245 --
8246 l_step := 35;
8247 if g_debug then
8248 hr_utility.set_location(l_proc,3456);
8249 end if;
8250 -- rate is having non recurring
8251 for l_prv in c_prv3 (p_per_in_ler_id) loop
8252 --check whether rate is non-recurring
8253 open c_abr(l_prv.acty_base_rt_id);
8254 fetch c_abr into l_abr;
8255 close c_abr;
8256 --
8257 if l_abr.processing_type = 'N' or
8258 l_abr.rcrrg_cd = 'ONCE' then
8259 null;
8260 else
8261 exit;
8262 end if;
8263 if g_debug then
8264 hr_utility.set_location('delete prtt',3459);
8265 end if;
8266 update ben_enrt_rt
8267 set prtt_rt_val_id = null
8268 where enrt_rt_id = l_prv.enrt_rt_id;
8269 --
8270 ben_prtt_rt_val_api.delete_prtt_rt_val
8271 (P_VALIDATE => FALSE
8272 ,P_PRTT_RT_VAL_ID => l_prv.prtt_rt_val_id
8273 ,P_OBJECT_VERSION_NUMBER => l_prv.object_version_number
8274 ,P_EFFECTIVE_DATE => l_eff_dt
8275 ,p_person_id => l_pen.person_id
8276 ,p_business_group_id => p_business_group_id
8277 );
8278 end loop;
8279 For l_prv in c_prv2 loop
8280 if g_debug then
8281 hr_utility.set_location(l_proc,3457);
8282 end if;
8283 l_prv_count := l_prv_count + 1;
8284 ben_prtt_rt_val_api.update_prtt_rt_val
8285 (P_VALIDATE => FALSE
8286 ,P_PRTT_RT_VAL_ID => l_prv.prtt_rt_val_id
8287 ,P_RT_END_DT => l_rt_end_dt
8288 ,p_person_id => l_pen.person_id
8289 --Bug#2625060 - for converted data, null is passed for activity base rt id
8290 -- ,p_acty_base_rt_id => l_prv.acty_base_rt_id
8291 ,p_input_value_id => l_prv.input_value_id
8292 ,p_element_type_id => l_prv.element_type_id
8293 ,p_ended_per_in_ler_id => p_per_in_ler_id
8294 ,p_business_group_id => p_business_group_id
8295 ,p_prtt_rt_val_stat_cd => 'BCKDT'
8296 ,P_OBJECT_VERSION_NUMBER => l_prv.object_version_number
8297 ,P_EFFECTIVE_DATE => p_effective_date
8298 );
8299 if g_debug then
8300 hr_utility.set_location(l_proc,3458);
8301 end if;
8302 end loop;
8303 --
8304 -- Adjust overlapping rates . Bug 5391554
8305 --
8306 -- basu
8307 hr_utility.set_location('p_per_in_ler_id '||p_per_in_ler_id,44333);
8308 --
8309 open c_enrt_in_curr_le;
8310 fetch c_enrt_in_curr_le into l_enrt_in_curr_le;
8311 --
8312 hr_utility.set_location('l_enrt_in_curr_le '||l_enrt_in_curr_le,44333);
8313 --
8314 if c_enrt_in_curr_le%found then
8315 if l_enrt_in_curr_le = 'Y' then
8316 -- basu
8317 open c_get_pgm_extra_info(l_pen.pgm_id);
8318 fetch c_get_pgm_extra_info into l_adjust;
8319 if c_get_pgm_extra_info%found then
8320 if l_adjust = 'Y' then
8321 for l_prv5 in c_prv5(l_rt_end_dt) loop
8322 --
8323 if g_debug then
8324 hr_utility.set_location('Adjusting rate '||l_rt_end_dt,111);
8325 end if;
8326 ben_prtt_rt_val_api.update_prtt_rt_val
8327 (P_VALIDATE => FALSE
8328 ,P_PRTT_RT_VAL_ID => l_prv5.prtt_rt_val_id
8329 ,P_RT_END_DT => l_rt_end_dt
8330 ,p_person_id => l_pen.person_id
8331 ,p_input_value_id => l_prv5.input_value_id
8332 ,p_element_type_id => l_prv5.element_type_id
8333 ,p_ended_per_in_ler_id => p_per_in_ler_id
8334 ,p_business_group_id => p_business_group_id
8335 ,P_OBJECT_VERSION_NUMBER => l_prv5.object_version_number
8336 ,P_EFFECTIVE_DATE => p_effective_date
8337 );
8338 end loop;
8339 end if;
8340 end if;
8341 close c_get_pgm_extra_info;
8342 --
8343 -- Adjust overlapping coverages . Bug 7206471
8344 --
8345 open c_get_pgm_extra_info_cvg(l_pen.pgm_id);
8346 fetch c_get_pgm_extra_info_cvg into l_cvg_adjust;
8347 if c_get_pgm_extra_info_cvg%found then
8348 if l_cvg_adjust = 'Y' then
8349 --
8350 for l_pen5 in c_pen5(l_enrt_cvg_end_dt) loop
8351 --
8352 if g_debug then
8353 hr_utility.set_location('Adjusting coverage for '||l_enrt_cvg_end_dt,44333);
8354 end if;
8355 ben_prtt_enrt_result_api.update_prtt_enrt_result
8356 (p_validate => FALSE,
8357 p_prtt_enrt_rslt_id => l_pen5.prtt_enrt_rslt_id,
8358 p_effective_start_date => l_effective_start_date,
8359 p_effective_end_date => l_effective_end_date,
8360 p_business_group_id => p_business_group_id,
8361 p_object_version_number => l_pen5.object_version_number,
8362 p_effective_date => p_effective_date,
8363 p_datetrack_mode => hr_api.g_correction,
8364 p_multi_row_validate => FALSE,
8365 p_enrt_cvg_thru_dt => l_enrt_cvg_end_dt,
8366 p_person_id => l_pen.person_id
8367 );
8368 end loop; -- c_pen5
8369 end if; -- if l_cvg_adjust = 'Y'
8370 end if; -- c_get_pgm_extra_info_cvg found
8371 close c_get_pgm_extra_info_cvg;
8372 end if; -- basu
8373 end if; -- basu
8374 close c_enrt_in_curr_le; -- basu
8375 --
8376 -- end bug 7206471
8377 --
8378 -- Bug#2038814 - cursor above updates only the last prtt_rt_val and if there
8379 -- any future dated prtt_rt_val, rows with rt end date greater than the calc
8380 --- ulated rt end
8381 -- date needs to be updated
8382 -- Bug 2739965
8383 if l_benmngle_parm_rec.mode_cd = 'S' or l_ler_typ_cd = 'SCHEDDU' then
8384 if g_debug then
8385 hr_utility.set_location('ben mngle mode',111);
8386 hr_utility.set_location('rate end date'||l_rt_end_dt,111);
8387 end if;
8388 --
8389 For l_prv4 in c_prv4 (l_rt_end_dt) loop
8390 -- 2739965 In case of unrestricted enrollment, this happens only when there are future rates
8391 -- and they got deleted as part of c_prv2 process above. Lets us throw this error
8392 -- here warning the user about the deletion of the future rate.
8393 --
8394 if fnd_global.conc_request_id in ( 0,-1) then
8395 -- Issue a warning to the user. These will display on the enrt forms.
8396 ben_warnings.load_warning
8397 (p_application_short_name => 'BEN',
8398 p_message_name => 'BEN_93369_DEL_FUT_RATE',
8399 p_parma => fnd_date.date_to_chardate( l_prv4.rt_end_dt+1 ),
8400 p_parmb => l_pen.pl_name || ' '||l_pen.opt_name,
8401 p_person_id => l_pen.person_id);
8402 end if;
8403 --
8404 ben_prtt_rt_val_api.update_prtt_rt_val
8405 (P_VALIDATE => FALSE
8406 ,P_PRTT_RT_VAL_ID => l_prv4.prtt_rt_val_id
8407 ,P_RT_END_DT => l_rt_end_dt
8408 ,p_person_id => l_pen.person_id
8409 --Bug#2625060 - for converted data, null is passed for activity base rt id
8410 -- ,p_acty_base_rt_id => l_prv4.acty_base_rt_id
8411 ,p_input_value_id => l_prv4.input_value_id
8412 ,p_element_type_id => l_prv4.element_type_id
8413 ,p_ended_per_in_ler_id => p_per_in_ler_id
8414 ,p_business_group_id => p_business_group_id
8415 ,p_prtt_rt_val_stat_cd => 'BCKDT' -- Bug 4739922: Backout the Result/ (do not VOIDD).
8416 ,P_OBJECT_VERSION_NUMBER => l_prv4.object_version_number
8417 ,P_EFFECTIVE_DATE => p_effective_date
8418 );
8419 end loop;
8420 end if;
8421 if g_debug then
8422 hr_utility.set_location(l_proc,3459);
8423 end if;
8424 --
8425 -- Get dependent coverage End date. If Participant coverage end date
8426 -- is greater than dependent coverage end date, then use participant.
8427 --
8428 l_step := 40;
8429 --
8430 calc_dpnt_cvg_dt
8431 (p_calc_end_dt => TRUE
8432 ,P_calc_strt_dt => FALSE
8433 ,p_per_in_ler_id => l_pen.per_in_ler_id
8434 ,P_person_id => l_pen.person_id
8435 ,p_pgm_id => l_pen.pgm_id
8436 ,p_pl_id => l_pen.pl_id
8437 ,p_oipl_id => l_pen.oipl_id
8438 ,p_ptip_id => l_pen.ptip_id
8439 ,p_ler_id => l_pen.ler_id
8440 ,P_BUSINESS_GROUP_ID => p_business_group_id
8441 ,P_EFFECTIVE_DATE => p_effective_date
8442 ,P_RETURNED_END_DT => l_dpnt_cvg_end_dt
8443 ,P_RETURNED_STRT_DT => l_dump_date
8444 ,p_enrt_cvg_end_dt => l_enrt_cvg_end_dt
8445 );
8446 --
8447 l_step := 90;
8448 --
8449 -- bug 3327224
8450 /*
8451 If l_dpnt_cvg_end_dt is not NULL then
8452 l_dpnt_cvg_thru_dt := least(l_enrt_cvg_end_dt, l_dpnt_cvg_end_dt);
8453 End if;
8454 */
8455 l_dpnt_cvg_thru_dt := l_dpnt_cvg_end_dt;
8456 --
8457 -- Unhook dependent rows
8458 --
8459 l_step := 110;
8460 unhook_dpnt
8461 (p_validate => FALSE
8462 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8463 ,p_per_in_ler_id => l_pen.per_in_ler_id
8464 ,p_cvg_thru_dt => l_dpnt_cvg_thru_dt
8465 ,p_business_group_id => p_business_group_id
8466 ,p_effective_date => p_effective_date
8467 ,p_datetrack_mode => p_datetrack_mode
8468 ,p_called_from => p_source
8469 );
8470 unhook_bnf
8471 (p_validate => FALSE
8472 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8473 ,p_per_in_ler_id => l_pen.per_in_ler_id
8474 ,p_dsgn_thru_dt => l_enrt_cvg_end_dt
8475 ,p_business_group_id => p_business_group_id
8476 ,p_effective_date => p_effective_date
8477 ,p_datetrack_mode => p_datetrack_mode
8478 );
8479 --
8480 l_step := 120;
8481 --
8482 get_ben_pen_upd_dt_mode
8483 (p_effective_date => p_effective_date
8484 ,p_base_key_value => p_prtt_enrt_rslt_id
8485 ,P_desired_datetrack_mode => p_datetrack_mode
8486 ,P_datetrack_allow => l_datetrack_mode
8487 ,p_ler_typ_cd => l_ler_typ_cd -- Bug 2739965
8488 );
8489 --
8490 l_step := 125;
8491 if g_debug then
8492 hr_utility.set_location('enrt_cvg_end_dt='||l_enrt_cvg_end_dt,19);
8493 end if;
8494 ben_prtt_enrt_result_api.update_prtt_enrt_result
8495 (p_validate => FALSE
8496 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8497 ,p_effective_start_date => p_effective_start_date
8498 ,p_effective_end_date => p_effective_end_date
8499 ,p_per_in_ler_id => l_pen.per_in_ler_id
8500 ,p_ler_id => l_pen.ler_id
8501 ,p_enrt_cvg_thru_dt => l_enrt_cvg_end_dt
8502 ,p_object_version_number => l_pen.pen_ovn
8503 ,p_prtt_enrt_rslt_stat_cd => 'BCKDT' -- Bug 4739922: Backout the Result/ (do not VOIDD).
8504 ,p_effective_date => p_effective_date
8505 ,p_datetrack_mode => l_datetrack_mode
8506 ,p_multi_row_validate => p_multi_row_validate
8507 ,p_business_group_id => p_business_group_id
8508 );
8509 --
8510 l_step := 126;
8511 --
8512 if l_pen.pgm_id is not null then
8513 ben_provider_pools.remove_bnft_prvdd_ldgr
8514 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8515 ,p_effective_date => p_effective_date
8516 ,p_business_group_id => p_business_group_id
8517 ,p_validate => FALSE
8518 ,p_datetrack_mode => hr_api.g_delete
8519 );
8520 end if;
8521 --
8522 --- # 2546259
8523 Else
8524 --
8525 -- Bug 2093859 : When coverage is not started just zap all the data.
8526 --
8527 --Bug#:6641853
8528 OPEN c_get_correction_info (p_prtt_enrt_rslt_id,
8529 l_pen.effective_start_date,
8530 l_pen.per_in_ler_id
8531 );
8532 FETCH c_get_correction_info INTO l_get_correction_info;
8533 CLOSE c_get_correction_info;
8534 IF l_get_correction_info.place_holder='X' THEN
8535 l_prtt_enrt_rslt_Stat_cd:=NULL;
8536 l_datetrack_mode:='CORRECTION';
8537 ELSE
8538 l_datetrack_mode := hr_api.g_zap;
8539 END IF;
8540 --
8541 if p_source = 'beninelg' then
8542 l_datetrack_mode := hr_api.g_delete;
8543 elsif p_source is null or --CFW
8544 p_source = 'benuneai' then
8545 l_datetrack_mode := p_datetrack_mode;
8546 end if;
8547 if g_debug then
8548 hr_utility.set_location('l_datetrack_mode='||l_datetrack_mode,20);
8549 end if;
8550 l_step := 140;
8551 --
8552 -- Added call the below code for 3797391 to get all dates properly
8553 --
8554 if g_debug then
8555 hr_utility.set_location('calc_dpnt_cvg_dt ', 100);
8556 end if;
8557 --
8558 calc_dpnt_cvg_dt
8559 (p_calc_end_dt => TRUE
8560 ,P_calc_strt_dt => FALSE
8561 ,p_per_in_ler_id => l_pen.per_in_ler_id
8562 ,P_person_id => l_pen.person_id
8563 ,p_pgm_id => l_pen.pgm_id
8564 ,p_pl_id => l_pen.pl_id
8565 ,p_oipl_id => l_pen.oipl_id
8566 ,p_ptip_id => l_pen.ptip_id
8567 ,p_ler_id => l_pen.ler_id
8568 ,P_BUSINESS_GROUP_ID => p_business_group_id
8569 ,P_EFFECTIVE_DATE => p_effective_date
8570 ,P_RETURNED_END_DT => l_dpnt_cvg_end_dt
8571 ,P_RETURNED_STRT_DT => l_dump_date
8572 ,p_enrt_cvg_end_dt => l_enrt_cvg_end_dt
8573 );
8574 --
8575 l_step := 40;
8576 --
8577 l_dpnt_cvg_thru_dt := l_dpnt_cvg_end_dt;
8578 --
8579 -- bug 3797391
8580 --
8581 unhook_bnf
8582 (p_validate => FALSE
8583 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8584 ,p_per_in_ler_id => l_pen.per_in_ler_id
8585 ,p_dsgn_thru_dt => l_enrt_cvg_end_dt
8586 ,p_business_group_id => p_business_group_id
8587 ,p_effective_date => l_eff_dt -- Bug 2093859 p_effective_date
8588 ,p_datetrack_mode => l_datetrack_mode
8589 ,p_rslt_delete_flag => TRUE
8590 );
8591
8592 hr_utility.set_location('p_prtt_enrt_rslt_id ='||p_prtt_enrt_rslt_id,20);
8593 hr_utility.set_location('l_pen.per_in_ler_id ='||l_pen.per_in_ler_id,20);
8594 hr_utility.set_location('l_dpnt_cvg_thru_dt ='||to_char(l_dpnt_cvg_thru_dt),20);
8595 hr_utility.set_location('l_eff_dt ='||to_char(l_eff_dt),20);
8596 hr_utility.set_location('p_source ='||p_source,20);
8597 --
8598 l_step := 150;
8599 --
8600 unhook_dpnt
8601 (p_validate => FALSE
8602 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8603 ,p_per_in_ler_id => l_pen.per_in_ler_id
8604 ,p_cvg_thru_dt => l_dpnt_cvg_thru_dt
8605 ,p_business_group_id => p_business_group_id
8606 ,p_effective_date => l_eff_dt
8607 ,p_datetrack_mode => l_datetrack_mode
8608 ,p_rslt_delete_flag => TRUE
8609 ,p_called_from => p_source );
8610 --
8611 l_step := 160;
8612 --
8613 if (l_pen.elig_per_elctbl_chc_id is not NULL) then
8614 -- Bug 2627078
8615 -- if called from delete_enrollment then
8616 -- we need to get the current_enrollment result id
8617 -- populated when the interim is getting deleted.
8618 --
8619 l_current_result_id := null ;
8620 --
8621 if p_source = 'delete_enrollment' then
8622 --
8623 open c_curr_rslt (l_pen.person_id, l_pen.pgm_id,
8624 l_pen.pl_id, l_pen.oipl_id, p_per_in_ler_id ) ;
8625 fetch c_curr_rslt into l_current_result_id ;
8626 close c_curr_rslt ;
8627 --
8628 end if ;
8629 --
8630 ben_ELIG_PER_ELC_CHC_api.update_ELIG_PER_ELC_CHC
8631 (p_validate => FALSE
8632 ,p_elig_per_elctbl_chc_id => l_pen.elig_per_elctbl_chc_id
8633 ,p_prtt_enrt_rslt_id => l_current_result_id -- NULL
8634 ,p_object_version_number => l_pen.epe_ovn
8635 ,p_effective_date => l_eff_dt
8636 );
8637 end if;
8638 --
8639 l_step := 136;
8640 --
8641 remove_cert_action_items
8642 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8643 ,p_effective_date => l_eff_dt
8644 ,p_business_group_id => p_business_group_id
8645 ,p_validate => FALSE
8646 ,p_datetrack_mode => l_datetrack_mode
8647 ,p_source => p_source
8648 ,p_per_in_ler_id => l_pen.pen_per_in_ler_id
8649 ,p_per_in_ler_ended_id=> l_pen.per_in_ler_id
8650 );
8651 --
8652 l_step := 137;
8653 --
8654 if l_pen.pgm_id is not null then
8655 ben_provider_pools.remove_bnft_prvdd_ldgr
8656 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8657 ,p_effective_date => l_eff_dt
8658 ,p_business_group_id => p_business_group_id
8659 ,p_validate => FALSE
8660 ,p_datetrack_mode => l_datetrack_mode
8661 );
8662 end if;
8663 --
8664 -- Remove all participant Rate Values rows
8665 --
8666 l_step := 170;
8667 --
8668 -- Bug 4136432
8669 for l_prv in c_prvdel
8670 loop
8671 --
8672 hr_utility.set_location('p_prtt_enrt_rslt_id ='||p_prtt_enrt_rslt_id,20);
8673 hr_utility.set_location('l_eff_dt ='||to_char(l_eff_dt),20);
8674 hr_utility.set_location('l_prv.prtt_rt_val_id ='||l_prv.prtt_rt_val_id,20);
8675 hr_utility.set_location('l_pen.person_id ='|| l_pen.person_id,20);
8676 hr_utility.set_location('l_prv.enrt_rt_id ='||l_prv.enrt_rt_id,20);
8677 --
8678 -- Bug 5626835 : For Enter Value At Enrollment cases, we need to just BCKDT PRV, so that
8679 -- during reinstatement of corresponding PEN, we can get the actual PRV
8680 -- and hence the previously selected RT_VAL
8681 -- Note : Probably we need this fix for all cases, but I made change for Enter Value At
8682 -- Enrollment case only. Right now for other cases, while reinstating we create records
8683 -- from BEPENAPI.MULTI_ROWS_EDIT >> BEN_DET_ENRT_RATES using ECR
8684 --
8685 IF l_prv.entr_val_at_enrt_flag = 'Y'
8686 THEN
8687 --
8688 -- Bug 6471236
8689 /* void_rate
8690 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id,
8691 p_business_group_id => p_business_group_id,
8692 p_person_id => l_pen.person_id,
8693 p_per_in_ler_id => p_per_in_ler_id,
8694 p_effective_date => p_effective_date
8695 ); */
8696 if l_datetrack_mode='CORRECTION' then
8697 l_temp_date:=l_enrt_cvg_end_dt;
8698 l_temp_stat_cd:=NULL;
8699 --Bug#:6641853
8700 else
8701 l_temp_date:=l_prv.rt_strt_dt - 1;
8702 l_temp_stat_cd:='VOIDD';
8703 end if;
8704 ben_prtt_rt_val_api.update_prtt_rt_val
8705 (P_VALIDATE => FALSE
8706 ,P_PRTT_RT_VAL_ID => l_prv.prtt_rt_val_id
8707 ,P_RT_END_DT => l_temp_date
8708 ,p_person_id => l_pen.person_id
8709 ,p_input_value_id => l_prv.input_value_id
8710 ,p_element_type_id => l_prv.element_type_id
8711 ,p_ended_per_in_ler_id => p_per_in_ler_id
8712 ,p_prtt_rt_val_stat_cd => l_temp_stat_cd
8713 ,p_business_group_id => p_business_group_id
8714 ,P_OBJECT_VERSION_NUMBER => l_prv.object_version_number
8715 ,P_EFFECTIVE_DATE => p_effective_date
8716 );
8717 l_temp_date:=NULL;
8718 -- Bug 6471236
8719 --
8720 ELSE
8721 --
8722 if l_datetrack_mode='CORRECTION' then
8723
8724
8725 ben_prtt_rt_val_api.update_prtt_rt_val
8726 (P_VALIDATE => FALSE
8727 ,P_PRTT_RT_VAL_ID => l_prv.prtt_rt_val_id
8728 ,P_RT_END_DT => l_enrt_cvg_end_dt
8729 ,p_person_id => l_pen.person_id
8730 ,p_input_value_id => l_prv.input_value_id
8731 ,p_element_type_id => l_prv.element_type_id
8732 ,p_ended_per_in_ler_id => p_per_in_ler_id
8733 -- ,p_prtt_rt_val_stat_cd => l_temp_stat_cd
8734 ,p_business_group_id => p_business_group_id
8735 ,P_OBJECT_VERSION_NUMBER => l_prv.object_version_number
8736 ,P_EFFECTIVE_DATE => p_effective_date
8737 );
8738
8739 ELSE
8740 --Bug#:6641853
8741 ben_prtt_rt_val_api.delete_prtt_rt_val
8742 (P_VALIDATE => FALSE
8743 ,P_PRTT_RT_VAL_ID => l_prv.prtt_rt_val_id
8744 ,P_ENRT_RT_ID => l_prv.enrt_rt_id
8745 ,P_OBJECT_VERSION_NUMBER => l_prv.object_version_number
8746 ,P_EFFECTIVE_DATE => l_eff_dt
8747 ,p_person_id => l_pen.person_id
8748 ,p_business_group_id => p_business_group_id
8749 );
8750 END IF;
8751 --
8752 END IF;
8753 --
8754 end loop;
8755 --
8756 -- Remove PCP records
8757 --
8758 for l_pcp in c_pcp(l_eff_dt) loop
8759 ben_prmry_care_prvdr_api.delete_prmry_care_prvdr
8760 (P_VALIDATE => FALSE
8761 ,P_PRMRY_CARE_PRVDR_ID => l_pcp.prmry_care_prvdr_id
8762 ,P_EFFECTIVE_START_DATE => l_pcp.effective_start_date
8763 ,P_EFFECTIVE_END_DATE => l_pcp.effective_end_date
8764 ,P_OBJECT_VERSION_NUMBER => l_pcp.object_version_number
8765 ,P_EFFECTIVE_DATE => l_eff_dt
8766 ,P_DATETRACK_MODE => l_datetrack_mode
8767 ,p_called_from => 'delete_enrollment'
8768 );
8769 End loop;
8770 --
8771 -- Remove ppe records and children
8772 --
8773 /* Start of Code Change for WWBUG: 1646442: added */
8774 l_ppe_dt_to_use := least(l_enrt_cvg_end_dt,l_rt_end_dt);
8775 /* End of Code Change for WWBUG: 1646442 */
8776 /*
8777 CODE PRIOR TO WWBUG: 1646442
8778 for l_ppe in c_ppe loop
8779 */
8780 /* Start of Code Change for WWBUG: 1646442 */
8781 for l_ppe in c_ppe(l_ppe_dt_to_use) loop
8782 /* End of Code Change for WWBUG: 1646442 */
8783 --
8784 l_prtt_prem_id := l_ppe.prtt_prem_id;
8785 --
8786 /******************** BEGIN CODE PRIOR TO WWBUG: 1646442 **********
8787 This whole section has been deleted
8788 ** BBurns 15aug2001
8789 ** A 'invalid primary key' error occurred when a date track delete
8790 ** was attempted with a p_effective_date prior to the start of
8791 ** the ben_prtt_prem_by_mo_f row. The ben_prtt_prem_by_mo_f rows have
8792 ** already been reported to the carrier and should not be modified
8793 ** by this procedure.
8794 ** A review of how prtt_prem_by_mo_f is defined and the functionality
8795 ** of this procedure is in order.
8796 **
8797 --
8798 -- delete child ben_prtt_prem_by_mo_f records
8799 --
8800 for l_prm in c_prm loop
8801 --
8802 if (l_datetrack_mode = hr_api.g_delete and
8803 l_prm.effective_end_date > l_eff_dt) or
8804 l_datetrack_mode <> hr_api.g_delete then
8805 --
8806 ben_prtt_prem_by_mo_api.delete_prtt_prem_by_mo
8807 (p_validate => false,
8808 p_prtt_prem_by_mo_id => l_prm.prtt_prem_by_mo_id,
8809 p_object_version_number => l_prm.object_version_number,
8810 p_effective_date => l_eff_dt,
8811 p_effective_start_date => l_prm.effective_end_date,
8812 p_effective_end_date => l_prm.effective_start_date,
8813 p_datetrack_mode => l_datetrack_mode
8814 );
8815 --
8816 end if;
8817 --
8818 end loop;
8819 ******************** END CODE PRIOR TO WWBUG: 1646442 ************/
8820 --
8821 if (l_datetrack_mode = hr_api.g_delete and
8822 l_ppe.effective_end_date > l_eff_dt) or
8823 l_datetrack_mode <> hr_api.g_delete then
8824 --
8825 /* Start of Changes for WWBUG: 1646442: added */
8826 l_ppe_dt_to_use := least(l_enrt_cvg_end_dt,l_rt_end_dt);
8827 l_ppe_datetrack_mode := l_datetrack_mode;
8828 if l_ppe_dt_to_use < l_ppe.effective_start_date
8829 then
8830 l_ppe_dt_to_use := l_ppe.effective_start_date;
8831 l_ppe_datetrack_mode := hr_api.g_zap;
8832 end if;
8833 /* End of Changes for WWBUG: 1646442 */
8834 /***************** BEGIN CODE PRIOR TO WWBUG: 1646442 **********
8835 ben_prtt_prem_api.delete_prtt_prem
8836 (p_validate => false,
8837 p_prtt_prem_id => l_ppe.prtt_prem_id,
8838 p_object_version_number => l_ppe.object_version_number,
8839 p_effective_date => l_eff_dt,
8840 p_effective_start_date => l_ppe.effective_end_date,
8841 p_effective_end_date => l_ppe.effective_start_date,
8842 p_datetrack_mode => l_datetrack_mode
8843 );
8844 ******************* END CODE PRIOR TO WWBUG: 1646442 *****************/
8845 /* Start of Code Changes for WWBUG: 1646442 */
8846 ben_prtt_prem_api.delete_prtt_prem
8847 (p_validate => false,
8848 p_prtt_prem_id => l_ppe.prtt_prem_id,
8849 p_object_version_number => l_ppe.object_version_number,
8850 p_effective_date => l_ppe_dt_to_use, /*l_eff_dt*/
8851 p_effective_start_date => l_ppe.effective_end_date,
8852 p_effective_end_date => l_ppe.effective_start_date,
8853 p_datetrack_mode => l_ppe_datetrack_mode /*l_datetrack_mode*/
8854 );
8855 /* End of Code Changes for WWBUG: 1646442 */
8856 --
8857 end if;
8858 --
8859 end loop;
8860 --
8861 -- Clear out ben_enrt_bnft table's prtt_enrt_rslt_id
8862 --
8863 l_step := 176;
8864 --
8865 -- Do not call manage_enrt_bnft, if it is called from election_information
8866 -- as the call is always made from there.
8867 --
8868 --Bug 3256056 This call from election_information is associated with the
8869 --New results - That other call works fine if the result was continued from
8870 --the prevoius enrollment. But if the user made the change in the
8871 --current enrollment olny [I mean selected option 1 , saved and then now
8872 --changing to option 2 ] we don't want to keep the pen id on the enb record.
8873 --When we are zaping the records for the call from election information we
8874 --we want to remove the penid from enb also.
8875 --
8876 if p_source = 'benelinf' and l_datetrack_mode = hr_api.g_zap then
8877 --
8878 ben_election_information.manage_enrt_bnft
8879 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8880 ,p_business_group_id => p_business_group_id
8881 ,p_effective_date => l_eff_dt
8882 ,p_object_version_number => l_tmp_ovn
8883 ,p_per_in_ler_id => p_per_in_ler_id
8884 );
8885 --
8886 end if;
8887 --
8888 if p_source is null or
8889 p_source <> 'benelinf' then
8890 --
8891 ben_election_information.manage_enrt_bnft
8892 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8893 ,p_business_group_id => p_business_group_id
8894 ,p_effective_date => l_eff_dt
8895 ,p_object_version_number => l_tmp_ovn
8896 ,p_per_in_ler_id => p_per_in_ler_id
8897 );
8898 --
8899 end if;
8900 --
8901 l_step := 177;
8902 -- Do not attempt dt delete if the row selected already has an effective
8903 -- end date equal to (or less than) the date you are trying to delete it on.
8904 -- Bug 1132739
8905 -- Bug 2386000 If the result got update as part of on of the above calls,
8906 -- we need to get the latest object_version_number
8907 --
8908 if (l_datetrack_mode = hr_api.g_delete and
8909 l_pen.effective_end_date > l_eff_dt) or
8910 l_datetrack_mode <> hr_api.g_delete then
8911 --
8912 -- 4663971
8913 open c_pen_ovn( p_prtt_enrt_rslt_id,l_eff_dt ) ;
8914 fetch c_pen_ovn into l_pen_ovn.object_version_number,l_pen_ovn.effective_start_date ;
8915 close c_pen_ovn ;
8916 --
8917 -- BUG 4663971 we should never call delete process with other than zap mode
8918 -- if the datetrack mode is other than zap we need to call
8919 -- update_prtt_enrt_result procedure
8920 --
8921 if p_source = 'benuneai' or l_datetrack_mode <> hr_api.g_zap then
8922 hr_utility.set_location('called from benuneai',99);
8923 --
8924 -- 4663971
8925 if l_pen_ovn.effective_start_date = l_eff_dt
8926 or l_datetrack_mode='CORRECTION' then
8927 l_datetrack_mode := hr_api.g_correction ;
8928 l_temp_date:=l_enrt_cvg_end_dt;
8929 --Bug#:6641853
8930 else
8931 l_datetrack_mode := hr_api.g_update ;
8932 l_temp_date:=l_pen.enrt_cvg_strt_dt-1;
8933 end if;
8934 --
8935 ben_prtt_enrt_result_api.update_prtt_enrt_result
8936 (p_validate => FALSE
8937 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8938 ,p_effective_start_date => p_effective_start_date
8939 ,p_effective_end_date => p_effective_end_date
8940 ,p_per_in_ler_id => l_pen.per_in_ler_id
8941 ,p_ler_id => l_pen.ler_id
8942 ,p_enrt_cvg_thru_dt => l_temp_date
8943 ,p_rplcs_sspndd_rslt_id => null
8944 ,p_object_version_number => l_pen_ovn.object_version_number
8945 ,p_effective_date => l_eff_dt
8946 ,p_datetrack_mode => l_datetrack_mode --4663971
8947 ,p_multi_row_validate => p_multi_row_validate
8948 ,p_business_group_id => p_business_group_id
8949 );
8950 else
8951 ben_prtt_enrt_result_api.delete_prtt_enrt_result
8952 (p_validate => FALSE
8953 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8954 ,p_effective_start_date => p_effective_start_date
8955 ,p_effective_end_date => p_effective_end_date
8956 ,p_object_version_number => l_pen_ovn.object_version_number -- 2386000
8957 ,p_effective_date => l_eff_dt
8958 ,p_datetrack_mode => l_datetrack_mode
8959 ,p_multi_row_validate => p_multi_row_validate);
8960 end if;
8961 end if;
8962 end if ; ----2546259
8963 -- write to change event log. -thayden
8964 --
8965 l_step := 178;
8966 --
8967 if p_source is null or
8968 p_source <> 'benelinf' then
8969 ben_ext_chlg.log_benefit_chg
8970 (p_action => 'DELETE'
8971 ,p_old_pl_id => l_pen.pl_id
8972 ,p_old_oipl_id => l_pen.oipl_id
8973 ,p_old_enrt_cvg_strt_dt => l_pen.enrt_cvg_strt_dt
8974 ,p_old_enrt_cvg_end_dt => l_pen.enrt_cvg_thru_dt
8975 ,p_pl_id => l_pen.pl_id
8976 ,p_oipl_id => l_pen.oipl_id
8977 ,p_enrt_cvg_strt_dt => l_pen.enrt_cvg_strt_dt
8978 ,p_enrt_cvg_end_dt => l_eff_dt
8979 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8980 ,p_per_in_ler_id => l_pen.per_in_ler_id
8981 ,p_person_id => l_pen.person_id
8982 ,p_business_group_id => p_business_group_id
8983 ,p_effective_date => l_eff_dt
8984 );
8985 end if;
8986 --
8987 end if;
8988 --bug # 3086161
8989 if l_corr_pil_id is not null then
8990 hr_utility.set_location(' correcting the resulst for ' || l_corr_pil_id , 999 );
8991 open c_pen_obj_no (p_per_in_ler_id ,p_prtt_enrt_rslt_id ) ;
8992 fetch c_pen_obj_no into l_object_version_number ;
8993 if c_pen_obj_no%found then
8994 hr_utility.set_location(' correcting the result ovn ' || l_object_version_number , 999 );
8995 ben_prtt_enrt_result_api.update_prtt_enrt_result
8996 (p_validate => FALSE
8997 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8998 ,p_effective_start_date => p_effective_start_date
8999 ,p_effective_end_date => p_effective_end_date
9000 ,p_per_in_ler_id => l_corr_pil_id
9001 ,p_ler_id => l_pen.ler_id
9002 ,p_object_version_number => l_object_version_number
9003 ,p_effective_date => p_effective_date
9004 ,p_datetrack_mode => hr_api.g_correction
9005 ,p_multi_row_validate => FALSE
9006 ,p_business_group_id => p_business_group_id
9007 );
9008 end if ;
9009 /* -- added here for bug 6963660
9010 -- updated the corrected result in the back up table so that it behaves as
9011 -- if corrected on the p_effective_start_date
9012 --
9013 update ben_le_clsn_n_rstr
9014 set effective_start_date = p_effective_start_date
9015 where per_in_ler_id = l_corr_pil_id
9016 and bkup_tbl_id = p_prtt_enrt_rslt_id
9017 and bkup_tbl_typ_cd = 'BEN_PRTT_ENRT_RSLT_F_CORR';
9018 --
9019 -- added till here for bug 6963660 */
9020 close c_pen_obj_no ;
9021 end if ;
9022 --- eof bug # 3086161
9023 --
9024 -- Delete the interim coverage also.
9025 -- Delete interim only when called from enrollment forms (p_source is null)
9026 -- and when called from election_information (p_source='benelinf')
9027 --
9028 if l_pen.sspndd_flag = 'Y' and
9029 l_pen.rplcs_sspndd_rslt_id is not null and
9030 (p_source is null or
9031 p_source = 'benelinf') then
9032 --
9033 -- Check if the interim result is been used by some other suspended
9034 -- result. If yes, do not delete the interim result.
9035 -- This case is most important when I'm moving from a suspended result
9036 -- to other result, which also gets suspended and both have the same
9037 -- interim. In this case, we create the new suspended result first
9038 -- and when interim needs to be created, it finds interim result to be
9039 -- already present. Now when the old suspended result is deleted in the
9040 -- same run, it tries to delete the interim result along with it.
9041 -- So the new suspended result is without any interims.
9042 -- In order to avoid this, this new cursor is introduced. (Bug 1274214)
9043 --
9044 open c_intm_other_rslt(p_per_in_ler_id); -- Bug 6165501 : Added Input param
9045 fetch c_intm_other_rslt into l_intm_other_rslt;
9046 close c_intm_other_rslt;
9047 --
9048 if l_intm_other_rslt is null or
9049 l_intm_other_rslt <> 'Y' then
9050 --
9051 open c_interim;
9052 fetch c_interim into l_interim;
9053 --
9054 if c_interim%found then
9055 --
9056 delete_enrollment(
9057 p_validate => false,
9058 p_per_in_ler_id => p_per_in_ler_id,
9059 p_prtt_enrt_rslt_id => l_interim.prtt_enrt_rslt_id,
9060 p_effective_start_date => l_interim.effective_start_date,
9061 p_effective_end_date => l_interim.effective_end_date,
9062 p_object_version_number => l_interim.object_version_number,
9063 p_business_group_id => p_business_group_id,
9064 p_effective_date => p_effective_date,
9065 p_datetrack_mode => p_datetrack_mode,
9066 p_source => 'delete_enrollment',
9067 p_lee_rsn_id => p_lee_rsn_id,
9068 p_enrt_perd_id => p_enrt_perd_id,
9069 p_multi_row_validate => false);
9070 --
9071 end if;
9072 --
9073 close c_interim;
9074 --
9075 end if;
9076 --
9077 end if;
9078 --
9079 if g_debug then
9080 hr_utility.set_location(l_proc, 60);
9081 end if;
9082 --
9083 -- When in validation only mode raise the Validate_Enabled exception
9084 --
9085 if p_validate then
9086 raise hr_api.validate_enabled;
9087 end if;
9088 --
9089 if g_debug then
9090 hr_utility.set_location(' Leaving:'||l_proc, 70);
9091 end if;
9092 --
9093 Exception
9094 --
9095 when hr_api.validate_enabled
9096 then
9097 --
9098 -- As the Validate_Enabled exception has been raised
9099 -- we must rollback to the savepoint
9100 --
9101 ROLLBACK TO delete_enrollment;
9102 --
9103 -- Only set output warning arguments
9104 -- (Any key or derived arguments must be set to null
9105 -- when validation only mode is being used.)
9106 --
9107 if g_debug then
9108 hr_utility.set_location(' Leaving:'||l_proc, 80);
9109 end if;
9110 --
9111 when l_fnd_message_exception then
9112 ROLLBACK TO delete_enrollment;
9113 rpt_error(p_proc => l_proc, p_step => l_step);
9114 p_effective_start_date := null; --nocopy change
9115 p_effective_end_date := null; --nocopy change
9116 fnd_message.raise_error;
9117 --
9118 --Bug 5664907
9119 when app_exception.application_exception then
9120 ROLLBACK TO delete_enrollment;
9121 rpt_error(p_proc => l_proc, p_step => l_step);
9122 p_effective_start_date := null; --nocopy change
9123 p_effective_end_date := null; --nocopy change
9124 fnd_message.raise_error;
9125 --
9126 --Bug 5664907
9127 when others then
9128 --
9129 --
9130 -- A validation or unexpected error has occured
9131 --
9132 ROLLBACK TO delete_enrollment;
9133 rpt_error(p_proc => l_proc, p_step => l_step);
9134 p_effective_start_date := null; --nocopy change
9135 p_effective_end_date := null; --nocopy change
9136 fnd_message.set_name('PER','FFU10_GENERAL_ORACLE_ERROR');
9137 fnd_message.set_token('2',substr(sqlerrm,1,500)); -- 4695708
9138 fnd_message.raise_error;
9139 --
9140 end delete_enrollment;
9141 --
9142 -- --------------------------------------------------------------------------
9143 -- |--------------------------< unhook_bnf >--------------------------------|
9144 -- --------------------------------------------------------------------------
9145 --
9146 procedure unhook_bnf
9147 (p_validate in boolean default FALSE
9148 ,p_prtt_enrt_rslt_id in number
9149 ,p_per_in_ler_id in number
9150 ,p_dsgn_thru_dt in date
9151 ,p_business_group_id in number
9152 ,p_effective_date in date
9153 ,p_datetrack_mode in varchar2
9154 ,p_rslt_delete_flag in boolean default FALSE
9155
9156 ) is
9157
9158
9159 cursor c_old_bnf
9160 is
9161 select pbf.pl_bnf_id
9162 ,pbf.effective_start_date
9163 ,pbf.effective_end_date
9164 ,pbf.object_version_number
9165 ,pbf.dsgn_strt_dt
9166 ,pbf.dsgn_thru_dt
9167 ,pbf.per_in_ler_id
9168 from ben_pl_bnf_f pbf,
9169 ben_per_in_ler pil
9170 where pbf.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
9171 and pbf.business_group_id = p_business_group_id
9172 and p_effective_date between pbf.effective_start_date
9173 and pbf.effective_end_date
9174 and pil.per_in_ler_id=pbf.per_in_ler_id
9175 and pil.business_group_id=pbf.business_group_id
9176 and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT')
9177 ;
9178 --
9179 cursor c_zap_bnf
9180 is
9181 select pbf.pl_bnf_id
9182 ,pbf.object_version_number
9183 from ben_pl_bnf_f pbf,
9184 ben_per_in_ler pil
9185 where pbf.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
9186 and p_effective_date
9187 between pbf.effective_start_date
9188 and pbf.effective_end_date
9189 and pil.per_in_ler_id=pbf.per_in_ler_id
9190 and pil.business_group_id=pbf.business_group_id
9191 and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT')
9192 ;
9193
9194 l_proc varchar2(72); -- := g_package||'unhook_bnf';
9195
9196 l_effective_start_date date;
9197 l_effective_end_date date;
9198 l_object_version_number number(9);
9199 l_step integer;
9200 l_datetrack_mode varchar2(30);
9201 l_correction boolean;
9202 l_update boolean;
9203 l_update_override boolean;
9204 l_update_change_insert boolean;
9205 l_last number:=-1;
9206 l_effective_date date;
9207 l_per_in_ler_id number := p_per_in_ler_id;
9208 --
9209 begin
9210 --
9211 g_debug := hr_utility.debug_enabled;
9212 if g_debug then
9213 l_proc := g_package||'unhook_bnf';
9214 hr_utility.set_location('Entering'||l_proc, 5);
9215 end if;
9216 --
9217 l_step := 10;
9218 --
9219 for orec in c_old_bnf loop
9220 --
9221 -- Only pick up first occurrence of each ID.
9222 -- This was added to zap future dated rows
9223 -- because result delete fails if children
9224 -- are not ended.
9225 --
9226 if l_last=-1 or l_last<>orec.pl_bnf_id then
9227 l_last:=orec.pl_bnf_id;
9228 l_effective_date:=p_effective_date;
9229 if (p_effective_date<nvl(orec.effective_start_date,hr_api.g_date)) then
9230 l_effective_date:=orec.effective_start_date;
9231 l_datetrack_mode := hr_api.g_zap;
9232 elsIf (p_effective_date = nvl(orec.effective_start_date,hr_api.g_date)) then
9233 l_datetrack_mode := hr_api.g_correction;
9234 Elsif (p_datetrack_mode in (hr_api.g_correction, hr_api.g_zap)) then
9235 l_datetrack_mode := hr_api.g_correction;
9236 Else
9237 l_datetrack_mode := hr_api.g_update;
9238 End if;
9239 --
9240 --
9241 If (p_effective_date between nvl(orec.dsgn_strt_dt, p_effective_date+1)
9242 and nvl(orec.dsgn_thru_dt, hr_api.g_eot)
9243 and not p_rslt_delete_flag
9244 and l_datetrack_mode<>hr_api.g_zap
9245 ) then
9246 --
9247 -- If Coverage started, then end the coverage by set the coverage
9248 -- thru date.
9249 --
9250
9251 dt_api.find_dt_upd_modes
9252 (p_effective_date => p_effective_date,
9253 p_base_table_name => 'BEN_PL_BNF_F',
9254 p_base_key_column => 'PL_BNF_ID',
9255 p_base_key_value => orec.PL_BNF_ID,
9256 p_correction => l_correction,
9257 p_update => l_update,
9258 p_update_override => l_update_override,
9259 p_update_change_insert => l_update_change_insert);
9260 --
9261 if l_update_override then
9262 --
9263 l_datetrack_mode := hr_api.g_update_override;
9264 --
9265 elsif l_update then
9266 --
9267 l_datetrack_mode := hr_api.g_update;
9268 --
9269 else
9270 --
9271 l_datetrack_mode := hr_api.g_correction;
9272 --
9273 end if;
9274 if g_debug then
9275 hr_utility.set_location('dt_mode='||l_datetrack_mode,11);
9276 end if;
9277 --
9278 l_step := 20;
9279 --
9280 If p_dsgn_thru_dt is null then
9281 rpt_error(p_proc => l_proc, p_step => l_step);
9282 fnd_message.set_name('BEN','BEN_91704_NOT_DET_DP_CVG_E_DT');
9283 fnd_message.raise_error;
9284 End if;
9285 --
9286 if l_per_in_ler_id is null then
9287 l_per_in_ler_id := orec.per_in_ler_id;
9288 end if;
9289 --
9290 if g_debug then
9291 hr_utility.set_location('calling update mode' || l_datetrack_mode , 192 );
9292 end if;
9293 ben_PLAN_BENEFICIARY_api.update_PLAN_BENEFICIARY
9294 (p_validate => FALSE
9295 ,p_business_group_id => p_business_group_id
9296 ,p_pl_bnf_id => orec.pl_bnf_id
9297 ,p_effective_start_date => orec.effective_start_date
9298 ,p_effective_end_date => orec.effective_end_date
9299 ,p_dsgn_thru_dt => p_dsgn_thru_dt
9300 ,p_per_in_ler_id => l_per_in_ler_id
9301 ,p_object_version_number => orec.object_version_number
9302 ,p_effective_date => p_effective_date
9303 ,p_datetrack_mode => l_datetrack_mode
9304 ,p_multi_row_actn => FALSE);
9305 --
9306 elsif orec.dsgn_thru_dt < p_effective_date then
9307 --
9308 -- Coverage is already ended. Don't do anything.
9309 --
9310 null;
9311 --
9312 Else
9313 --
9314 -- If coverage not yet started, then reset coverage start/end date
9315 -- to NULL and coverage flag to 'N'
9316 --
9317 l_step := 40;
9318 --
9319 If (p_effective_date <= nvl(orec.effective_start_date,hr_api.g_date)) then
9320 l_datetrack_mode := hr_api.g_zap;
9321 Elsif (p_datetrack_mode in (hr_api.g_correction, hr_api.g_zap)) then
9322 l_datetrack_mode := hr_api.g_zap;
9323 Else
9324 l_datetrack_mode := hr_api.g_delete;
9325
9326 End if;
9327 --
9328 -- Start of fix for INTERNAL bug 4924
9329 --
9330 if l_datetrack_mode = hr_api.g_delete and
9331 p_effective_date = orec.effective_end_date then
9332 --
9333 -- Already end dated
9334 --
9335 null;
9336 --
9337 else
9338 --
9339 if g_debug then
9340 hr_utility.set_location('calling delete ' || l_datetrack_mode , 192 );
9341 end if;
9342 ben_plan_beneficiary_api.delete_plan_beneficiary
9343 (p_validate => p_validate
9344 ,p_pl_bnf_id => orec.pl_bnf_id
9345 ,p_effective_start_date => orec.effective_start_date
9346 ,p_effective_end_date => orec.effective_end_date
9347 ,p_object_version_number => orec.object_version_number
9348 ,p_effective_date => p_effective_date
9349 ,p_datetrack_mode => nvl(l_datetrack_mode,p_datetrack_mode)
9350 ,p_multi_row_actn => FALSE
9351 ,p_business_group_id => p_business_group_id);
9352
9353 --
9354 end if;
9355 --
9356 -- End of fix for INTERNAL BUG 4924.
9357 --
9358 End if;
9359 end if;
9360 End loop;
9361 if g_debug then
9362 hr_utility.set_location('Exiting'||l_proc, 30);
9363 end if;
9364
9365 exception
9366 --
9367 when others then
9368 rpt_error(p_proc => l_proc, p_step => l_step);
9369 fnd_message.raise_error;
9370 End unhook_bnf;
9371 --
9372
9373
9374 --
9375 -- ---------------------------------------------------------------------------
9376 -- |----------------------------< unhook_dpnt >------------------------------|
9377 -- ---------------------------------------------------------------------------
9378 --
9379 Procedure unhook_dpnt
9380 (p_validate in boolean default FALSE
9381 ,p_prtt_enrt_rslt_id in number
9382 ,p_per_in_ler_id in number
9383 ,p_cvg_thru_dt in date
9384 ,p_business_group_id in number
9385 ,p_effective_date in date
9386 ,p_datetrack_mode in varchar2
9387 ,p_rslt_delete_flag in boolean default FALSE
9388 ,p_called_from in varchar2 default 'bepenapi'
9389 ) is
9390 cursor c_old_dpnt is
9391 select ecd.elig_cvrd_dpnt_id
9392 ,ecd.effective_start_date
9393 ,ecd.effective_end_date
9394 ,ecd.dpnt_person_id
9395 ,ecd.cvg_strt_dt
9396 ,ecd.CVG_PNDG_FLAG
9397 ,ecd.cvg_thru_dt
9398 ,ecd.object_version_number
9399 ,ecd.per_in_ler_id
9400 from ben_elig_cvrd_dpnt_f ecd,
9401 ben_per_in_ler pil
9402 where ecd.prtt_enrt_rslt_id=p_prtt_enrt_rslt_id
9403 and ecd.cvg_strt_dt is not null
9404 -- and ecd.cvg_thru_dt = hr_api.g_eot
9405 and ecd.business_group_id=p_business_group_id
9406 -- and p_effective_date between
9407 -- ecd.effective_start_date and ecd.effective_end_date
9408 and p_effective_date <= ecd.effective_end_date
9409 and pil.per_in_ler_id(+)=ecd.per_in_ler_id
9410 and pil.business_group_id(+)=ecd.business_group_id
9411 and (pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT') or
9412 -- outer join condition below
9413 -- above is case where found pil,
9414 -- below is case where pil not found and want row
9415 pil.per_in_ler_stat_cd is null)
9416 /* Bug 4520785 Pick only those cvrd dependent records where either cvg thru date hasn't
9417 been end dated yet or cvg thru date is more than effective date */
9418 and ecd.elig_cvrd_dpnt_id not in (select ecd1.elig_cvrd_dpnt_id
9419 from ben_elig_cvrd_dpnt_f ecd1
9420 where ecd1.elig_cvrd_dpnt_id = ecd.elig_cvrd_dpnt_id
9421 and ecd1.cvg_thru_dt <= p_effective_date
9422 and p_effective_date <= ecd1.effective_end_date ) -- Bug 4710937
9423 /* End Bug 4520785 */
9424 order by ecd.elig_cvrd_dpnt_id,
9425 ecd.effective_start_date;
9426
9427 -- 3574168
9428 -- Fetch all PCP records on effective date
9429 Cursor c_pcp (c_elig_cvrd_dpnt_id NUMBER)
9430 is
9431 select pcp.PRMRY_CARE_PRVDR_ID
9432 ,pcp.EFFECTIVE_START_DATE
9433 ,pcp.EFFECTIVE_END_DATE
9434 ,pcp.PRTT_ENRT_RSLT_ID
9435 ,pcp.BUSINESS_GROUP_ID
9436 ,pcp.OBJECT_VERSION_NUMBER
9437 from ben_prmry_care_prvdr_f pcp
9438 where business_group_id = p_business_group_id
9439 and elig_cvrd_dpnt_id = c_elig_cvrd_dpnt_id
9440 and p_effective_date between effective_start_date
9441 and effective_end_date
9442 ;
9443 --
9444 -- Fetch all PCP records in future
9445 Cursor c_pcp_future (c_elig_cvrd_dpnt_id NUMBER)
9446 is
9447 select pcp.PRMRY_CARE_PRVDR_ID
9448 ,pcp.EFFECTIVE_START_DATE
9449 ,pcp.EFFECTIVE_END_DATE
9450 ,pcp.PRTT_ENRT_RSLT_ID
9451 ,pcp.BUSINESS_GROUP_ID
9452 ,pcp.OBJECT_VERSION_NUMBER
9453 from ben_prmry_care_prvdr_f pcp
9454 where pcp.business_group_id = p_business_group_id
9455 and pcp.elig_cvrd_dpnt_id = c_elig_cvrd_dpnt_id
9456 and p_effective_date < pcp.effective_start_date
9457 and NVL(pcp.effective_end_date, hr_api.g_eot) = hr_api.g_eot
9458 ;
9459 -- 3574168
9460
9461 l_proc varchar2(72); -- := g_package||'unhook_dpnt';
9462 l_effective_start_date date;
9463 l_effective_end_date date;
9464 l_object_version_number number(9);
9465 l_step integer;
9466 l_datetrack_mode varchar2(30);
9467 l_correction boolean;
9468 l_update boolean;
9469 l_update_override boolean;
9470 l_update_change_insert boolean;
9471 l_last number:=-1;
9472 l_effective_date date;
9473 l_per_in_ler_id number := p_per_in_ler_id;
9474 l_pcp_effective_date date;
9475 --
9476 begin
9477 --
9478 g_debug := hr_utility.debug_enabled;
9479 if g_debug then
9480 l_proc := g_package||'unhook_dpnt';
9481 hr_utility.set_location('Entering'||l_proc, 5);
9482 hr_utility.set_location('p_effective_date '||to_char(p_effective_date), 5);
9483 end if;
9484 --
9485 l_step := 10;
9486 --
9487 for orec in c_old_dpnt loop
9488 --
9489 -- Only pick up first occurrence of each ID.
9490 -- This was added to zap future dated rows
9491 -- because result delete fails if children
9492 -- are not ended.
9493 --
9494 hr_utility.set_location('orec.effective_start_date '||to_char(orec.effective_start_date), 5);
9495 hr_utility.set_location('p_datetrack_mode '||p_datetrack_mode , 5);
9496 hr_utility.set_location('orec.cvg_strt_dt '||to_char(orec.cvg_strt_dt), 5);
9497 hr_utility.set_location('orec.cvg_thru_dt '||to_char(orec.cvg_thru_dt), 5);
9498
9499 if l_last=-1 or
9500 l_last<>orec.elig_cvrd_dpnt_id then
9501 l_last:=orec.elig_cvrd_dpnt_id;
9502 l_effective_date:=p_effective_date;
9503 if (p_effective_date<nvl(orec.effective_start_date,hr_api.g_date)) then
9504 l_effective_date:=orec.effective_start_date;
9505 l_datetrack_mode := hr_api.g_zap;
9506 elsIf (p_effective_date = nvl(orec.effective_start_date,hr_api.g_date)) then
9507 l_datetrack_mode := hr_api.g_correction;
9508 Elsif (p_datetrack_mode in (hr_api.g_correction, hr_api.g_zap)) then
9509 l_datetrack_mode := hr_api.g_correction;
9510 Else
9511 l_datetrack_mode := hr_api.g_update;
9512 End if;
9513 --
9514 If (p_effective_date between nvl(orec.cvg_strt_dt, p_effective_date+1)
9515 and nvl(orec.cvg_thru_dt, hr_api.g_eot)
9516 and orec.CVG_PNDG_FLAG = 'N'
9517 and not p_rslt_delete_flag
9518 and l_datetrack_mode<>hr_api.g_zap
9519 ) then
9520 --
9521 -- If Coverage started, then end the coverage by set the coverage
9522 -- thru date.
9523 --
9524 dt_api.find_dt_upd_modes
9525 (p_effective_date => p_effective_date,
9526 p_base_table_name => 'BEN_ELIG_CVRD_DPNT_F',
9527 p_base_key_column => 'ELIG_CVRD_DPNT_ID',
9528 p_base_key_value => orec.elig_cvrd_dpnt_id,
9529 p_correction => l_correction,
9530 p_update => l_update,
9531 p_update_override => l_update_override,
9532 p_update_change_insert => l_update_change_insert);
9533 --
9534 if l_update_override then
9535 --
9536 l_datetrack_mode := hr_api.g_update_override;
9537 --
9538 elsif l_update then
9539 --
9540 l_datetrack_mode := hr_api.g_update;
9541
9542 /* Bug 2597005: Reverse changes (Update the coverages of Dependents in correction mode )*/
9543 -- l_datetrack_mode := hr_api.g_correction;
9544 /* Bug 2597005: Reverse changes (Update the coverages of Dependents in correction mode) */
9545 --
9546 else
9547 --
9548 l_datetrack_mode := hr_api.g_correction;
9549 --
9550
9551 end if;
9552 if g_debug then
9553 hr_utility.set_location('dt_mode='||l_datetrack_mode,11);
9554 end if;
9555 --
9556 l_step := 20;
9557 --
9558 If p_cvg_thru_dt is null then
9559 rpt_error(p_proc => l_proc, p_step => l_step);
9560 fnd_message.set_name('BEN','BEN_91704_NOT_DET_DP_CVG_E_DT');
9561 fnd_message.raise_error;
9562 End if;
9563 --
9564 if l_per_in_ler_id is null then
9565 l_per_in_ler_id := orec.per_in_ler_id;
9566 end if;
9567 ben_elig_cvrd_dpnt_api.update_elig_cvrd_dpnt
9568 (p_validate => FALSE
9569 ,p_business_group_id => p_business_group_id
9570 ,p_elig_cvrd_dpnt_id => orec.elig_cvrd_dpnt_id
9571 ,p_effective_start_date => orec.effective_start_date
9572 ,p_effective_end_date => orec.effective_end_date
9573 ,p_cvg_thru_dt => p_cvg_thru_dt
9574 ,p_per_in_ler_id => l_per_in_ler_id
9575 ,p_object_version_number => orec.object_version_number
9576 ,p_effective_date => p_effective_date
9577 ,p_datetrack_mode => l_datetrack_mode
9578 ,p_multi_row_actn => FALSE);
9579 --
9580 /* --
9581 -- 3617724: Remove PCP records
9582 -- NO NEED TO REMOVE PCP's here as "update_elig_cvrd_dpnt" procedure above will do it.
9583 -- 3617724
9584 */
9585
9586 elsif orec.cvg_thru_dt < p_effective_date then
9587 --
9588 -- Coverage is already ended. Don't do anything.
9589 --
9590 null;
9591 --
9592 Else
9593 --
9594 -- If coverage not yet started, then reset coverage start/end date
9595 -- to NULL and coverage flag to 'N'
9596 --
9597 l_step := 40;
9598 --
9599 If (p_effective_date <= nvl(orec.effective_start_date,hr_api.g_date)) then
9600 l_datetrack_mode := hr_api.g_zap;
9601 Elsif (p_datetrack_mode in (hr_api.g_correction, hr_api.g_zap)) then
9602 l_datetrack_mode := hr_api.g_zap;
9603 Else
9604 l_datetrack_mode := hr_api.g_delete;
9605 if g_debug then
9606 hr_utility.set_location('in dt_mode='||l_datetrack_mode,11);
9607 end if;
9608 End if;
9609 --
9610 -- Start of fix for INTERNAL bug 4924
9611 --
9612 if g_debug then
9613 hr_utility.set_location('dt_mode='||l_datetrack_mode,11);
9614 end if;
9615 if l_datetrack_mode = hr_api.g_delete and
9616 p_effective_date = orec.effective_end_date then
9617 --
9618 -- Already end dated
9619 --
9620 null;
9621 --
9622 else
9623
9624 --
9625 -- 3574168: Remove PCP records
9626 -- Set End-date to coverage-end-date.
9627 --
9628 for l_pcp in c_pcp(orec.elig_cvrd_dpnt_id) loop
9629 --
9630 hr_utility.set_location('Delete prmry_care_prvdr_id '|| l_pcp.prmry_care_prvdr_id, 15);
9631 --
9632 ben_prmry_care_prvdr_api.delete_prmry_care_prvdr
9633 (P_VALIDATE => FALSE
9634 ,P_PRMRY_CARE_PRVDR_ID => l_pcp.prmry_care_prvdr_id
9635 ,P_EFFECTIVE_START_DATE => l_pcp.effective_start_date
9636 ,P_EFFECTIVE_END_DATE => l_pcp.effective_end_date
9637 ,P_OBJECT_VERSION_NUMBER => l_pcp.object_version_number
9638 ,P_EFFECTIVE_DATE => l_effective_date
9639 ,P_DATETRACK_MODE => l_datetrack_mode
9640 ,p_called_from => 'delete_enrollment'
9641 );
9642 --
9643 End loop;
9644 --
9645 -- Get future PCP records if any and zap - delete all of them.
9646 --
9647 for l_pcp_future in c_pcp_future(orec.elig_cvrd_dpnt_id) loop
9648 --
9649 hr_utility.set_location('ZAP prmry_care_prvdr_id '|| l_pcp_future.prmry_care_prvdr_id, 15);
9650 --
9651 l_pcp_effective_date := l_pcp_future.effective_start_date;
9652 --
9653 ben_prmry_care_prvdr_api.delete_prmry_care_prvdr
9654 (P_VALIDATE => FALSE
9655 ,P_PRMRY_CARE_PRVDR_ID => l_pcp_future.prmry_care_prvdr_id
9656 ,P_EFFECTIVE_START_DATE => l_pcp_future.effective_start_date
9657 ,P_EFFECTIVE_END_DATE => l_pcp_future.effective_end_date
9658 ,P_OBJECT_VERSION_NUMBER => l_pcp_future.object_version_number
9659 ,P_EFFECTIVE_DATE => l_pcp_effective_date
9660 ,P_DATETRACK_MODE => hr_api.g_zap
9661 ,p_called_from => 'delete_enrollment'
9662 );
9663 End loop;
9664 -- 3574168
9665
9666 --
9667 -- Bug 2386000 Added new parameter p_called_from not to unsuspend the
9668 -- enrollment which is going to be deleted.
9669 ben_elig_cvrd_dpnt_api.delete_elig_cvrd_dpnt
9670 (p_validate => FALSE
9671 ,p_elig_cvrd_dpnt_id => orec.elig_cvrd_dpnt_id
9672 ,p_effective_start_date => orec.effective_start_date
9673 ,p_business_group_id => p_business_group_id
9674 ,p_effective_end_date => orec.effective_end_date
9675 ,p_object_version_number => orec.object_version_number
9676 ,p_effective_date => l_effective_date
9677 ,p_datetrack_mode => l_datetrack_mode
9678 ,p_multi_row_actn => FALSE
9679 ,p_called_from => p_called_from
9680 );
9681 --
9682 end if;
9683 --
9684 -- End of fix for INTERNAL BUG 4924.
9685 --
9686 End if;
9687 end if;
9688 End loop;
9689 if g_debug then
9690 hr_utility.set_location('Exiting'||l_proc, 30);
9691 end if;
9692 exception
9693 --
9694 when others then
9695 rpt_error(p_proc => l_proc, p_step => l_step);
9696 fnd_message.raise_error;
9697 End unhook_dpnt;
9698 --
9699 -- ----------------------------------------------------------------------------
9700 -- |-------------------------------< lck >------------------------------------|
9701 -- ----------------------------------------------------------------------------
9702 --
9703 procedure lck
9704 (
9705 p_prtt_enrt_rslt_id in number
9706 ,p_object_version_number in number
9707 ,p_effective_date in date
9708 ,p_datetrack_mode in varchar2
9709 ,p_validation_start_date out nocopy date
9710 ,p_validation_end_date out nocopy date
9711 ) is
9712 --
9713 --
9714 -- Declare cursors and local variables
9715 --
9716 l_proc varchar2(72); -- := g_package||'lck';
9717 l_validation_start_date date;
9718 l_validation_end_date date;
9719 --
9720 begin
9721 --
9722 g_debug := hr_utility.debug_enabled;
9723 if g_debug then
9724 l_proc := g_package||'lck';
9725 hr_utility.set_location('Entering:'|| l_proc, 10);
9726 end if;
9727 --
9728 ben_pen_shd.lck
9729 (
9730 p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
9731 ,p_validation_start_date => l_validation_start_date
9732 ,p_validation_end_date => l_validation_end_date
9733 ,p_object_version_number => p_object_version_number
9734 ,p_effective_date => p_effective_date
9735 ,p_datetrack_mode => p_datetrack_mode
9736 );
9737 --
9738 if g_debug then
9739 hr_utility.set_location(' Leaving:'||l_proc, 70);
9740 end if;
9741 --
9742 end lck;
9743
9744 --Start Bug 5768795
9745
9746 procedure chk_coverage_across_plan_types
9747 ( p_person_id in number,
9748 p_effective_date in date,
9749 p_lf_evt_ocrd_dt in date,
9750 p_business_group_id in number,
9751 p_pgm_id in number,
9752 p_minimum_check_flag in varchar default 'Y',
9753 p_suspended_enrt_check_flag in varchar default 'Y') is
9754
9755 cursor c_acrs_ptip is
9756 select acrs_ptip_cvg_id,
9757 mx_cvg_alwd_amt,
9758 mn_cvg_alwd_amt
9759 from ben_acrs_ptip_cvg_f
9760 where pgm_id = p_pgm_id
9761 and --p_effective_date between BUG 3051674
9762 p_lf_evt_ocrd_dt between
9763 effective_start_date and effective_end_date
9764 and business_group_id = p_business_group_id;
9765 --
9766 cursor c_prtt_total_bnft_amt(p_acrs_ptip_cvg_id number) is
9767 select sum(prt.bnft_amt)
9768 from ben_prtt_enrt_rslt_f prt,
9769 ben_ptip_f ptp
9770 where prt.pgm_id = p_pgm_id
9771 and prt.person_id = p_person_id
9772 and prt.sspndd_flag = 'N' -- # 3626176
9773 and prt.prtt_enrt_rslt_stat_cd is null
9774 and prt.effective_end_date = hr_api.g_eot
9775 and nvl(prt.enrt_cvg_thru_dt,hr_api.g_eot) = hr_api.g_eot
9776 and p_effective_date between
9777 prt.effective_start_date and prt.effective_end_date
9778 and prt.business_group_id = p_business_group_id
9779 and p_lf_evt_ocrd_dt between -- BUG 3051674 p_effective_date between
9780 ptp.effective_start_date and ptp.effective_end_date
9781 and ptp.acrs_ptip_cvg_id=p_acrs_ptip_cvg_id
9782 and ptp.ptip_id=prt.ptip_id
9783 and ptp.business_group_id=prt.business_group_id
9784 ;
9785 --Bug 3695005 fixes
9786 --This cursor needs to get suspended enrollments and
9787 --other enrollments. But it should exclude Interim coverages
9788 --here.
9789 --
9790 cursor c_prtt_total_bnft_amt_sspndd(p_acrs_ptip_cvg_id number) is
9791 select sum(prt.bnft_amt)
9792 from ben_prtt_enrt_rslt_f prt,
9793 ben_ptip_f ptp
9794 where prt.pgm_id = p_pgm_id
9795 and prt.person_id = p_person_id
9796 and ( prt.sspndd_flag = 'Y' or (
9797 prt.sspndd_flag = 'N' and not exists (
9798 select 'x'
9799 from ben_prtt_enrt_rslt_f prt1
9800 where prt1.person_id = p_person_id
9801 and prt1.pgm_id = p_pgm_id
9802 and PRT1.rplcs_sspndd_rslt_id = prt.prtt_enrt_rslt_id
9803 and prt1.per_in_ler_id = prt.per_in_ler_id
9804 and prt1.sspndd_flag = 'Y'
9805 and p_lf_evt_ocrd_dt between
9806 prt1.effective_start_date and prt1.effective_end_date
9807 and prt1.effective_end_date = hr_api.g_eot
9808 and prt1.enrt_cvg_thru_dt = hr_api.g_eot
9809 and prt1.prtt_enrt_rslt_stat_cd is null)))
9810 and prt.prtt_enrt_rslt_stat_cd is null
9811 and prt.effective_end_date = hr_api.g_eot
9812 and prt.enrt_cvg_thru_dt = hr_api.g_eot
9813 and p_effective_date between
9814 prt.effective_start_date and prt.effective_end_date
9815 and prt.business_group_id = p_business_group_id
9816 and p_lf_evt_ocrd_dt between -- BUG 3051674 p_effective_date between
9817 ptp.effective_start_date and ptp.effective_end_date
9818 and ptp.acrs_ptip_cvg_id=p_acrs_ptip_cvg_id
9819 and ptp.ptip_id=prt.ptip_id
9820 and ptp.business_group_id=prt.business_group_id
9821 ;
9822
9823 cursor c_pl_typ_names(p_acrs_ptip_cvg_id number) is
9824 select name
9825 from ben_pl_typ_f
9826 where pl_typ_id in
9827 ( select pl_typ_id
9828 from ben_ptip_f
9829 where pgm_id = p_pgm_id
9830 and acrs_ptip_cvg_id = p_acrs_ptip_cvg_id
9831 and business_group_id = p_business_group_id)
9832 and p_lf_evt_ocrd_dt between
9833 effective_start_date and effective_end_date;
9834 --
9835 l_output_names varchar2(4000);
9836 l_total_amt number;
9837 l_pl_typ_names varchar2(600);
9838 l_acrs_ptip c_acrs_ptip%rowtype;
9839
9840 l_proc varchar2(72) := 'ben_PRTT_ENRT_RESULT_api.chk_coverage_across_plan_types';
9841
9842 begin
9843
9844 if g_debug then
9845 hr_utility.set_location(' Entering '||l_proc, 70);
9846 end if;
9847
9848 if p_pgm_id is not NULL then
9849 --
9850 if g_debug then
9851 hr_utility.set_location('Check for min/max across ptip', 77);
9852 end if;
9853 --
9854 for l_acrs_ptip in c_acrs_ptip loop
9855 --
9856 if g_debug then
9857 hr_utility.set_location('Check for min/max across ptip', 78);
9858 end if;
9859 open c_prtt_total_bnft_amt(l_acrs_ptip.acrs_ptip_cvg_id);
9860 fetch c_prtt_total_bnft_amt into l_total_amt;
9861 close c_prtt_total_bnft_amt;
9862 if g_debug then
9863 hr_utility.set_location('total='||l_total_amt||' mn='||
9864 l_acrs_ptip.mn_cvg_alwd_amt||' mx='||l_acrs_ptip.mx_cvg_alwd_amt,20);
9865 end if;
9866 --
9867 -- bug 3123698
9868 open c_pl_typ_names(l_acrs_ptip.acrs_ptip_cvg_id);
9869 loop
9870 fetch c_pl_typ_names into l_pl_typ_names ;
9871 if c_pl_typ_names%notfound then
9872 exit;
9873 else if l_output_names is null then
9874 l_output_names := l_output_names||l_pl_typ_names;
9875 else if length(l_output_names ||','||l_pl_typ_names) <= 4000 then
9876 l_output_names := l_output_names ||','||l_pl_typ_names;
9877 else
9878 exit;
9879 end if;
9880 end if;
9881 end if;
9882 end loop;
9883 close c_pl_typ_names;
9884 -- end 3123698
9885 if l_acrs_ptip.mn_cvg_alwd_amt is not null and
9886 nvl(l_total_amt,0) < l_acrs_ptip.mn_cvg_alwd_amt and p_minimum_check_flag ='Y' then
9887
9888 --
9889 fnd_message.set_name('BEN','BEN_92179_BELOW_MIN_AMOUNT');
9890 fnd_message.set_token('TOT_AMT',nvl(l_total_amt,0));
9891 fnd_message.set_token('MIN_AMT',l_acrs_ptip.mn_cvg_alwd_amt);
9892 fnd_message.set_token('PL_TYP_NAMES',l_output_names); -- bug 3123698
9893 fnd_message.raise_error;
9894 --
9895 elsif l_acrs_ptip.mx_cvg_alwd_amt is not null and
9896 l_total_amt > l_acrs_ptip.mx_cvg_alwd_amt then
9897 --
9898 fnd_message.set_name('BEN','BEN_92180_ABOVE_MAX_AMOUNT');
9899 fnd_message.set_token('TOT_AMT',nvl(l_total_amt,0));
9900 fnd_message.set_token('MX_AMT',l_acrs_ptip.mx_cvg_alwd_amt);
9901 fnd_message.set_token('PL_TYP_NAMES',l_output_names); -- bug 3123698
9902 fnd_message.raise_error;
9903 --
9904 end if;
9905 --
9906 --Bug 3695005 Coverage Across Plan type considering
9907 --Suspended enrollment.
9908 --
9909
9910 if p_suspended_enrt_check_flag = 'Y' then
9911
9912 open c_prtt_total_bnft_amt_sspndd(l_acrs_ptip.acrs_ptip_cvg_id);
9913 fetch c_prtt_total_bnft_amt_sspndd into l_total_amt;
9914 close c_prtt_total_bnft_amt_sspndd;
9915 --
9916 if l_acrs_ptip.mx_cvg_alwd_amt is not null and
9917 l_total_amt > l_acrs_ptip.mx_cvg_alwd_amt then
9918 --
9919 fnd_message.set_name('BEN','BEN_92180_ABOVE_MAX_AMOUNT');
9920 fnd_message.set_token('TOT_AMT',nvl(l_total_amt,0));
9921 fnd_message.set_token('MX_AMT',l_acrs_ptip.mx_cvg_alwd_amt);
9922 fnd_message.set_token('PL_TYP_NAMES',l_output_names); -- bug 3123698
9923 fnd_message.raise_error;
9924 --
9925 end if;
9926 --
9927 if g_debug then
9928 hr_utility.set_location('total='||l_total_amt||' mn='||
9929 l_acrs_ptip.mn_cvg_alwd_amt||' mx='||l_acrs_ptip.mx_cvg_alwd_amt,20);
9930 end if;
9931 --
9932 end if; --p_suspended_enrt_check_flag
9933
9934 end loop; --c_acrs_ptip
9935 --
9936 end if;
9937
9938 if g_debug then
9939 hr_utility.set_location(' Leaving '||l_proc, 70);
9940 end if;
9941
9942
9943 end chk_coverage_across_plan_types;
9944
9945 --End Bug 5768795
9946 --
9947 -- ----------------------------------------------------------------------------
9948 -- |---------------------< multi_rows_edit >----------------------------------|
9949 -- ----------------------------------------------------------------------------
9950 --
9951 procedure multi_rows_edit
9952 (p_person_id in number,
9953 p_effective_date in date,
9954 p_business_group_id in number,
9955 p_pgm_id in number,
9956 p_per_in_ler_id in number default NULL,
9957 p_include_erl in varchar2,
9958 p_called_frm_ss in Boolean default FALSE
9959
9960 ) is
9961 --
9962 --Bug 3051674 We need to validate the edits with the life events
9963 --occured on date. This is an issue mainly for the open enrollment
9964 --If there is a change in the restrictions for the coverages etc.
9965 --Not using this for delete enrollment calls and corresponding
9966 --cursors.
9967 --
9968 cursor c_le_date(p_per_in_ler_id number) is
9969 select
9970 lf_evt_ocrd_dt
9971 from
9972 ben_per_in_ler pil
9973 where pil.per_in_ler_id = p_per_in_ler_id ;
9974 --
9975 l_lf_evt_ocrd_dt date ;
9976 --
9977 --End of 3051674 changes
9978 --
9979 -- If c1 or c1_pnip change, change the matching cursor in BENUTILS.pld
9980 -- enrt_pfc_deenrol procedure
9981 --
9982 Cursor c1 is
9983 Select r.prtt_enrt_rslt_id
9984 ,r.effective_start_date
9985 ,r.effective_end_date
9986 ,r.object_version_number
9987 ,r.pl_id
9988 ,r.pl_typ_id
9989 ,r.oipl_id
9990 ,r.pgm_id
9991 ,r.erlst_deenrt_dt
9992 ,r.person_id
9993 ,oipl.opt_id
9994 ,r.ptip_id
9995 ,r.enrt_mthd_cd --Bug 2200139
9996 From ben_prtt_enrt_rslt_f r,
9997 ben_oipl_f oipl,
9998 ben_elig_per_elctbl_chc c
9999 Where c.per_in_ler_id = p_per_in_ler_id
10000 and r.prtt_enrt_rslt_id = c.prtt_enrt_rslt_id
10001 and r.per_in_ler_id <> c.per_in_ler_id
10002 and r.person_id = p_person_id
10003 and nvl(r.pgm_id,-1) = p_pgm_id
10004 and r.effective_end_date = hr_api.g_eot
10005 and nvl(enrt_cvg_thru_dt,hr_api.g_eot) = hr_api.g_eot
10006 and r.prtt_enrt_rslt_stat_cd is null
10007 and c.comp_lvl_cd not in ('PLANFC', 'PLANIMP')
10008 and c.elctbl_flag = 'Y'
10009 /* BUG 3939785
10010 and (r.ENRT_OVRID_THRU_DT is null or
10011 r.ENRT_OVRID_THRU_DT < p_effective_date)
10012 */
10013 and ( r.enrt_ovridn_flag = 'N' /* Bug 3958064 */
10014 or
10015 ( r.enrt_ovridn_flag = 'Y' and nvl(r.ENRT_OVRID_THRU_DT,hr_api.g_eot) <= p_effective_date )
10016 )
10017 and oipl.oipl_id(+)=r.oipl_id
10018 and oipl.business_group_id(+)=r.business_group_id
10019 and p_effective_date between
10020 oipl.effective_start_date(+) and oipl.effective_end_date(+)
10021 --
10022 -- Bug 2600087 Added for finding the results which are not found
10023 -- when linked with epe records
10024 union
10025 Select r.prtt_enrt_rslt_id
10026 ,r.effective_start_date
10027 ,r.effective_end_date
10028 ,r.object_version_number
10029 ,r.pl_id
10030 ,r.pl_typ_id
10031 ,r.oipl_id
10032 ,r.pgm_id
10033 ,r.erlst_deenrt_dt
10034 ,r.person_id
10035 ,oipl.opt_id
10036 ,r.ptip_id
10037 ,r.enrt_mthd_cd
10038 From ben_prtt_enrt_rslt_f r,
10039 ben_oipl_f oipl
10040 Where r.per_in_ler_id <> p_per_in_ler_id
10041 and r.person_id = p_person_id
10042 and nvl(r.pgm_id,-1) = p_pgm_id
10043 and r.effective_end_date = hr_api.g_eot
10044 and nvl(enrt_cvg_thru_dt,hr_api.g_eot) = hr_api.g_eot
10045 and r.prtt_enrt_rslt_stat_cd is null
10046 and r.comp_lvl_cd not in ('PLANFC', 'PLANIMP')
10047 /* BUG 3939785
10048 and (r.ENRT_OVRID_THRU_DT is null or
10049 r.ENRT_OVRID_THRU_DT < p_effective_date)
10050 */
10051 and ( r.enrt_ovridn_flag = 'N' /* Bug 3958064 */
10052 or
10053 ( r.enrt_ovridn_flag = 'Y' and nvl(r.ENRT_OVRID_THRU_DT,hr_api.g_eot) <= p_effective_date )
10054 )
10055 and oipl.oipl_id(+)=r.oipl_id
10056 and oipl.business_group_id(+)=r.business_group_id
10057 and p_effective_date between
10058 oipl.effective_start_date(+) and oipl.effective_end_date(+)
10059 --bug#2602124
10060 and not exists
10061 (
10062 select k.prtt_enrt_rslt_id
10063 from ben_elig_per_elctbl_chc k
10064 Where k.per_in_ler_id = p_per_in_ler_id
10065 and k.prtt_enrt_rslt_id = r.prtt_enrt_rslt_id
10066 and k.comp_lvl_cd not in ('PLANFC', 'PLANIMP')
10067 )
10068 --bug 4262697 We need to delete only if there are electable choices exists in this life event
10069 -- otherwise we don't need to delete.
10070 and exists
10071 (
10072 select k.elig_per_elctbl_chc_id
10073 from ben_elig_per_elctbl_chc k
10074 Where k.per_in_ler_id = p_per_in_ler_id
10075 and k.pl_id = r.pl_id
10076 and k.pgm_id= p_pgm_id
10077 and ((k.oipl_id is null and r.oipl_id is null) or
10078 (k.oipl_id = r.oipl_id )
10079 )
10080 )
10081 ;
10082
10083 --
10084 Cursor c1_pnip is
10085 Select r.prtt_enrt_rslt_id
10086 ,r.effective_start_date
10087 ,r.effective_end_date
10088 ,r.object_version_number
10089 ,r.pl_id
10090 ,r.pl_typ_id
10091 ,r.oipl_id
10092 ,r.pgm_id
10093 ,r.erlst_deenrt_dt
10094 ,r.person_id
10095 ,oipl.opt_id
10096 ,r.ptip_id
10097 ,r.enrt_mthd_cd
10098 From ben_prtt_enrt_rslt_f r
10099 ,ben_elig_per_elctbl_chc c
10100 ,ben_oipl_f oipl
10101 ,ben_pil_elctbl_chc_popl pel
10102 Where c.per_in_ler_id = p_per_in_ler_id
10103 and r.prtt_enrt_rslt_id = c.prtt_enrt_rslt_id
10104 and r.per_in_ler_id <> c.per_in_ler_id
10105 and r.person_id = p_person_id
10106 and r.prtt_enrt_rslt_stat_cd is null
10107 and r.pgm_id is NULL
10108 and pel.pgm_id is NULL
10109 and (pel.elcns_made_dt is not null or pel.dflt_asnd_dt is not NULL)
10110 and pel.pl_id = r.pl_id
10111 and c.pil_elctbl_chc_popl_id = pel.pil_elctbl_chc_popl_id
10112 and r.effective_end_date = hr_api.g_eot
10113 and nvl(enrt_cvg_thru_dt,hr_api.g_eot) = hr_api.g_eot
10114 and c.comp_lvl_cd not in ('PLANFC', 'PLANIMP')
10115 and c.elctbl_flag = 'Y'
10116 /*
10117 and (r.ENRT_OVRID_THRU_DT is null or
10118 r.ENRT_OVRID_THRU_DT < p_effective_date)
10119 */
10120 and ( r.enrt_ovridn_flag = 'N' /* Bug 3958064 */
10121 or
10122 ( r.enrt_ovridn_flag = 'Y' and nvl(r.ENRT_OVRID_THRU_DT,hr_api.g_eot) <= p_effective_date )
10123 )
10124 and oipl.oipl_id(+)=r.oipl_id
10125 and oipl.business_group_id(+)=r.business_group_id
10126 and p_effective_date between
10127 oipl.effective_start_date(+) and oipl.effective_end_date(+)
10128 -- BUG: 3904792: MAINLINE FIX FOR 3894240: WHEN UPDATING A SAVINGS PLAN RATE SYSTEM IS END DATE
10129 AND NOT EXISTS
10130 (SELECT NULL
10131 FROM ben_ler_f ler,
10132 ben_pl_f pln
10133 WHERE ler.ler_id = r.ler_id
10134 AND ler.typ_cd = 'SCHEDDU'
10135 AND pln.SVGS_PL_FLAG = 'Y'
10136 and pln.pl_id = r.pl_id
10137 AND p_effective_date between pln.effective_start_date
10138 AND pln.effective_end_date
10139 AND p_effective_date between ler.effective_start_date
10140 AND ler.effective_end_date
10141 )
10142 -- BUG: 3904792: ENDS --
10143 ;
10144 --
10145 type l_tbl is table of c1%rowtype index by binary_integer;
10146 l_rec l_tbl;
10147 l_cnt Binary_integer := 0;
10148 l_proc varchar2(72); -- := g_package||'multi_rows_edit';
10149 l_effective_start_date date;
10150 l_effective_end_date date;
10151 l_pl_typ_id number;
10152 l_total_amt number;
10153 l_other_pen_rec ben_prtt_enrt_rslt_f%rowtype;
10154 l_rqd_perd_enrt_nenrt_uom varchar2(30);
10155 l_rqd_perd_enrt_nenrt_val number;
10156 l_rqd_perd_enrt_nenrt_rl number;
10157 l_level varchar2(30);
10158 l_effective_date date ;
10159 --
10160 --
10161 -- For program (if p_pgm_id is not null)
10162 --
10163 cursor no_lngr_elig_pgm_c is
10164 select pen.prtt_enrt_rslt_id,
10165 pen.object_version_number,
10166 pen.effective_start_date
10167 from ben_prtt_enrt_rslt_f pen
10168 where pen.per_in_ler_id = p_per_in_ler_id
10169 and pen.pgm_id = p_pgm_id
10170 and pen.prtt_enrt_rslt_stat_cd is null
10171 and pen.no_lngr_elig_flag = 'Y'
10172 and pen.effective_end_date = hr_api.g_eot
10173 and nvl(enrt_cvg_thru_dt,hr_api.g_eot) = hr_api.g_eot
10174 and pen.business_group_id = p_business_group_id;
10175 --
10176 -- For plan not in program (p_pgm_id is null)
10177 --
10178 cursor pl_typ_c is
10179 select distinct pln.pl_typ_id
10180 from ben_pil_elctbl_chc_popl pel,
10181 ben_pl_f pln
10182 where pel.per_in_ler_id = p_per_in_ler_id
10183 and pel.pgm_id is null
10184 and (pel.elcns_made_dt is not null or pel.dflt_asnd_dt is not NULL)
10185 and pln.pl_id = nvl(pel.pl_id, -1)
10186 and p_effective_date between
10187 pln.effective_start_date and pln.effective_end_date
10188 and pel.business_group_id = p_business_group_id
10189 and pln.business_group_id = p_business_group_id;
10190 --
10191 cursor no_lngr_elig_pnip_c is
10192 select pen.prtt_enrt_rslt_id,
10193 pen.object_version_number,
10194 pen.effective_start_date
10195 from ben_prtt_enrt_rslt_f pen
10196 where pen.pgm_id is null
10197 and pl_typ_id = l_pl_typ_id
10198 and pen.per_in_ler_id = p_per_in_ler_id
10199 and pen.prtt_enrt_rslt_stat_cd is null
10200 and pen.no_lngr_elig_flag = 'Y'
10201 and pen.effective_end_date = hr_api.g_eot
10202 and nvl(enrt_cvg_thru_dt,hr_api.g_eot) = hr_api.g_eot
10203 and pen.business_group_id = p_business_group_id;
10204 --
10205 cursor c_acrs_ptip is
10206 select acrs_ptip_cvg_id,
10207 mx_cvg_alwd_amt,
10208 mn_cvg_alwd_amt
10209 from ben_acrs_ptip_cvg_f
10210 where pgm_id = p_pgm_id
10211 and --p_effective_date between BUG 3051674
10212 l_lf_evt_ocrd_dt between
10213 effective_start_date and effective_end_date
10214 and business_group_id = p_business_group_id;
10215 --
10216 l_acrs_ptip c_acrs_ptip%rowtype;
10217 -- bug 3123698
10218 cursor c_pl_typ_names(p_acrs_ptip_cvg_id number) is
10219 select name
10220 from ben_pl_typ_f
10221 where pl_typ_id in
10222 ( select pl_typ_id
10223 from ben_ptip_f
10224 where pgm_id = p_pgm_id
10225 and acrs_ptip_cvg_id = p_acrs_ptip_cvg_id
10226 and business_group_id = p_business_group_id)
10227 and l_lf_evt_ocrd_dt between
10228 effective_start_date and effective_end_date;
10229 --
10230 l_pl_typ_names varchar2(600);
10231 l_output_names varchar2(4000);
10232 -- end 3123698
10233 --
10234 cursor c_prtt_total_bnft_amt(p_acrs_ptip_cvg_id number) is
10235 select sum(prt.bnft_amt)
10236 from ben_prtt_enrt_rslt_f prt,
10237 ben_ptip_f ptp
10238 where prt.pgm_id = p_pgm_id
10239 and prt.person_id = p_person_id
10240 and prt.sspndd_flag = 'N' -- # 3626176
10241 and prt.prtt_enrt_rslt_stat_cd is null
10242 and prt.effective_end_date = hr_api.g_eot
10243 and nvl(prt.enrt_cvg_thru_dt,hr_api.g_eot) = hr_api.g_eot
10244 and p_effective_date between
10245 prt.effective_start_date and prt.effective_end_date
10246 and prt.business_group_id = p_business_group_id
10247 and l_lf_evt_ocrd_dt between -- BUG 3051674 p_effective_date between
10248 ptp.effective_start_date and ptp.effective_end_date
10249 and ptp.acrs_ptip_cvg_id=p_acrs_ptip_cvg_id
10250 and ptp.ptip_id=prt.ptip_id
10251 and ptp.business_group_id=prt.business_group_id
10252 ;
10253 --Bug 3695005 fixes
10254 --This cursor needs to get suspended enrollments and
10255 --other enrollments. But it should exclude Interim coverages
10256 --here.
10257 --
10258 cursor c_prtt_total_bnft_amt_sspndd(p_acrs_ptip_cvg_id number) is
10259 select sum(prt.bnft_amt)
10260 from ben_prtt_enrt_rslt_f prt,
10261 ben_ptip_f ptp
10262 where prt.pgm_id = p_pgm_id
10263 and prt.person_id = p_person_id
10264 and ( prt.sspndd_flag = 'Y' or (
10265 prt.sspndd_flag = 'N' and not exists (
10266 select 'x'
10267 from ben_prtt_enrt_rslt_f prt1
10268 where prt1.person_id = p_person_id
10269 and prt1.pgm_id = p_pgm_id
10270 and PRT1.rplcs_sspndd_rslt_id = prt.prtt_enrt_rslt_id
10271 and prt1.per_in_ler_id = prt.per_in_ler_id
10272 and prt1.sspndd_flag = 'Y'
10273 and l_lf_evt_ocrd_dt between
10274 prt1.effective_start_date and prt1.effective_end_date
10275 and prt1.effective_end_date = hr_api.g_eot
10276 and prt1.enrt_cvg_thru_dt = hr_api.g_eot
10277 and prt1.prtt_enrt_rslt_stat_cd is null)))
10278 and prt.prtt_enrt_rslt_stat_cd is null
10279 and prt.effective_end_date = hr_api.g_eot
10280 and prt.enrt_cvg_thru_dt = hr_api.g_eot
10281 and p_effective_date between
10282 prt.effective_start_date and prt.effective_end_date
10283 and prt.business_group_id = p_business_group_id
10284 and l_lf_evt_ocrd_dt between -- BUG 3051674 p_effective_date between
10285 ptp.effective_start_date and ptp.effective_end_date
10286 and ptp.acrs_ptip_cvg_id=p_acrs_ptip_cvg_id
10287 and ptp.ptip_id=prt.ptip_id
10288 and ptp.business_group_id=prt.business_group_id
10289 ;
10290
10291 Cursor c_needs_dpnts (p_pl_typ_id number) is
10292 Select distinct r.prtt_enrt_rslt_id
10293 ,r.effective_start_date
10294 ,r.effective_end_date
10295 ,r.object_version_number
10296 ,r.pl_id
10297 ,r.pl_typ_id
10298 ,r.oipl_id
10299 ,r.pgm_id
10300 ,r.enrt_cvg_strt_dt
10301 ,c.elig_per_elctbl_chc_id
10302 ,c.dpnt_cvg_strt_dt_cd
10303 ,c.dpnt_cvg_strt_dt_rl
10304 ,pil.ler_id
10305 ,c.alws_dpnt_dsgn_flag
10306 ,pl.bnf_dsgn_cd
10307 From ben_prtt_enrt_rslt_f r,
10308 ben_elig_per_elctbl_chc c,
10309 ben_per_in_ler pil,
10310 ben_pl_f pl
10311 Where r.pl_typ_id = p_pl_typ_id
10312 and r.per_in_ler_id = p_per_in_ler_id
10313 and r.pgm_id = p_pgm_id
10314 and r.person_id = p_person_id
10315 and r.effective_end_date = hr_api.g_eot
10316 and r.enrt_cvg_thru_dt = hr_api.g_eot
10317 and r.prtt_enrt_rslt_stat_cd is null
10318 and r.prtt_enrt_rslt_id = c.prtt_enrt_rslt_id
10319 and r.per_in_ler_id = c.per_in_ler_id
10320 and c.comp_lvl_cd not in ('PLANFC', 'PLANIMP')
10321 and pil.per_in_ler_id = c.per_in_ler_id
10322 and pil.per_in_ler_stat_cd = 'STRTD'
10323 and pl.pl_id = r.pl_id
10324 and p_effective_date between
10325 pl.effective_start_date and pl.effective_end_date
10326 and ((c.alws_dpnt_dsgn_flag = 'Y'
10327 and not exists (select 'x' from ben_elig_cvrd_dpnt_f pdp
10328 where pdp.prtt_enrt_rslt_id = r.prtt_enrt_rslt_id
10329 and p_effective_date between
10330 pdp.effective_start_date and pdp.effective_end_date))
10331 OR
10332 (pl.bnf_dsgn_cd is not null
10333 and not exists (select 'x' from ben_pl_bnf_f pbn
10334 where pbn.prtt_enrt_rslt_id = r.prtt_enrt_rslt_id
10335 and p_effective_date between
10336 pbn.effective_start_date and pbn.effective_end_date)));
10337 --
10338 l_needs_dpnts c_needs_dpnts%rowtype;
10339 l_process_dpnt boolean := false;
10340 l_process_bnf boolean := false;
10341 l_env_rec ben_env_object.g_global_env_rec_type;
10342 --
10343 -- Bug 6656136
10344 cursor c_ler_typ_cd is
10345 --
10346 select ler.typ_cd
10347 from ben_per_in_ler pil,
10348 ben_ler_f ler
10349 where pil.per_in_ler_id = p_per_in_ler_id
10350 and pil.ler_id = ler.ler_id
10351 and pil.business_group_id = p_business_group_id
10352 and pil.business_group_id = ler.business_group_id
10353 and p_effective_date between
10354 ler.effective_start_date and ler.effective_end_date;
10355 --
10356 l_ler_typ_cd ben_ler_f.typ_cd%type;
10357 --
10358 begin
10359 --
10360 g_debug := hr_utility.debug_enabled;
10361 if g_debug then
10362 l_proc := g_package||'multi_rows_edit';
10363 hr_utility.set_location('Entering:'|| l_proc, 10);
10364 end if;
10365 --
10366 --Bug 4709601 we dont need to call multi_rows_edit in this case
10367 --
10368 if ben_sspndd_enrollment.g_cfw_flag = 'Y' then
10369 hr_utility.set_location('Leaving- called from CFW action items',15);
10370 return;
10371 end if;
10372 --
10373 if fnd_global.conc_request_id in (0,-1) then
10374 --
10375 --bug#3568529
10376 ben_env_object.get(p_rec => l_env_rec);
10377 if l_env_rec.benefit_action_id is null then
10378 --
10379 ben_env_object.init(p_business_group_id => p_business_group_id,
10380 p_effective_date => p_effective_date,
10381 p_thread_id => 1,
10382 p_chunk_size => 1,
10383 p_threads => 1,
10384 p_max_errors => 1,
10385 p_benefit_action_id => null);
10386 end if;
10387 --
10388 end if;
10389 --
10390 If p_per_in_ler_id is not NULL then
10391 If (p_pgm_id is not NULL) then
10392 For lrec in c1 loop
10393 l_cnt := l_cnt + 1;
10394 l_rec(l_cnt) := lrec;
10395 End loop;
10396 Else
10397 For lrec in c1_pnip loop
10398 l_cnt := l_cnt + 1;
10399 l_rec(l_cnt) := lrec;
10400 End loop;
10401 End if;
10402 --
10403 -- Remove any old enrollments - These are results where there was a choice
10404 -- in this same program for that comp object. And they didn't elect the
10405 -- comp object (the result doesn't have this per-in-ler). That must mean
10406 -- they don't want the enrollment anymore.
10407 --
10408 -- Before removing the enrollment, see if we can copy some of the dpnts or
10409 -- bnf's from the old enrollment (of the same plan type and program)
10410 -- to a new result.
10411 --
10412 For i in 1..l_cnt loop
10413
10414
10415 hr_utility.set_location('result id :'|| l_rec(i).prtt_enrt_rslt_id , 10);
10416
10417
10418 if l_rec(i).erlst_deenrt_dt is not null and
10419 l_rec(i).erlst_deenrt_dt>p_effective_date then
10420 ben_enrolment_requirements.find_rqd_perd_enrt(
10421 p_oipl_id =>l_rec(i).oipl_id
10422 ,p_opt_id =>l_rec(i).opt_id
10423 ,p_pl_id =>l_rec(i).pl_id
10424 ,p_ptip_id =>l_rec(i).ptip_id
10425 ,p_effective_date =>p_effective_date
10426 ,p_business_group_id =>p_business_group_id
10427 ,p_rqd_perd_enrt_nenrt_uom =>l_rqd_perd_enrt_nenrt_uom
10428 ,p_rqd_perd_enrt_nenrt_val =>l_rqd_perd_enrt_nenrt_val
10429 ,p_rqd_perd_enrt_nenrt_rl =>l_rqd_perd_enrt_nenrt_rl
10430 ,p_level =>l_level
10431 );
10432 --
10433 -- Got level now see if other enrt in level exists
10434 --
10435 if l_level is not null then
10436 ben_enrolment_requirements.find_enrt_at_same_level(
10437 p_person_id =>l_rec(i).person_id
10438 ,p_opt_id =>l_rec(i).opt_id
10439 ,p_oipl_id =>l_rec(i).oipl_id
10440 ,p_pl_id =>l_rec(i).pl_id
10441 ,p_ptip_id =>l_rec(i).ptip_id
10442 ,p_pl_typ_id =>l_rec(i).pl_typ_id
10443 ,p_pgm_id =>l_rec(i).pgm_id
10444 ,p_effective_date =>p_effective_date
10445 ,p_business_group_id =>p_business_group_id
10446 ,p_prtt_enrt_rslt_id =>l_rec(i).prtt_enrt_rslt_id
10447 ,p_level =>l_level
10448 ,p_pen_rec =>l_other_pen_rec
10449 );
10450 end if;
10451 end if;
10452 if l_other_pen_rec.prtt_enrt_rslt_id is not null or
10453 l_level is null or
10454 l_rec(i).erlst_deenrt_dt is null or
10455 l_rec(i).erlst_deenrt_dt<=p_effective_date then
10456 --
10457 if p_pgm_id is not null then
10458 for l_needs_dpnts in c_needs_dpnts(p_pl_typ_id => l_rec(i).pl_typ_id)
10459 loop
10460 --
10461 if l_needs_dpnts.alws_dpnt_dsgn_flag = 'Y' then
10462 l_process_dpnt := true;
10463 else
10464 l_process_dpnt := false;
10465 end if;
10466 if l_needs_dpnts.bnf_dsgn_cd is not null then
10467 l_process_bnf := true;
10468 else
10469 l_process_bnf := false;
10470 end if;
10471 --
10472 ben_mng_dpnt_bnf.recycle_dpnt_bnf
10473 (p_validate => FALSE
10474 ,p_new_prtt_enrt_rslt_id => l_needs_dpnts.prtt_enrt_rslt_id
10475 ,p_old_prtt_enrt_rslt_id => l_rec(i).prtt_enrt_rslt_id
10476 ,P_NEW_ENRT_RSLT_OVN => l_needs_dpnts.object_version_number
10477 ,p_new_elig_per_elctbl_chc_id => l_needs_dpnts.elig_per_elctbl_chc_id
10478 ,p_person_id => p_person_id
10479 ,p_return_to_exist_cvg_flag => 'N'
10480 ,p_old_pl_id => l_rec(i).pl_id
10481 ,p_new_pl_id => l_needs_dpnts.pl_id
10482 ,p_old_oipl_id => l_rec(i).oipl_id
10483 ,p_new_oipl_id => l_needs_dpnts.oipl_id
10484 ,p_old_pl_typ_id => l_rec(i).pl_typ_id
10485 ,p_new_pl_typ_id => l_needs_dpnts.pl_typ_id
10486 ,p_pgm_id => p_pgm_id
10487 ,p_ler_id => l_needs_dpnts.ler_id
10488 ,p_per_in_ler_id => p_per_in_ler_id
10489 ,p_dpnt_cvg_strt_dt_cd => l_needs_dpnts.dpnt_cvg_strt_dt_cd
10490 ,p_dpnt_cvg_strt_dt_rl => l_needs_dpnts.dpnt_cvg_strt_dt_rl
10491 ,p_business_group_id => p_business_group_id
10492 ,p_ENRT_CVG_STRT_DT => l_needs_dpnts.enrt_cvg_strt_dt
10493 ,p_effective_date => p_effective_date
10494 ,p_datetrack_mode => hr_api.g_update -- note below
10495 ,p_process_dpnt => l_process_dpnt
10496 ,p_process_bnf => l_process_bnf);
10497 -- if the datetrack mode of update causes problems, then we'll need
10498 -- to pass the datetrack mode in from the form. Each enrollment
10499 -- library will need to change. We'd also probably want to pass in
10500 -- the dtmode from benauten, beneadeb and bensuenr.
10501 end loop;
10502 end if; -- if pgm_id is not null
10503 --
10504 -- Bug 2200139 If the old enrollment started in Future from Override Enrollment
10505 -- Pass the p_effective_date as effective_start_date + 1 to handle
10506 -- the deenroll and also backout cases.
10507 --
10508 if l_rec(i).effective_start_date >= p_effective_date then
10509 l_effective_date := l_rec(i).effective_start_date + 1 ;
10510 else
10511 l_effective_date := p_effective_date ;
10512 end if ;
10513 --
10514 delete_enrollment
10515 (p_validate => FALSE
10516 ,p_per_in_ler_id => p_per_in_ler_id
10517 ,p_prtt_enrt_rslt_id => l_rec(i).prtt_enrt_rslt_id
10518 ,p_business_group_id => p_business_group_id
10519 ,p_effective_start_date => l_rec(i).effective_start_date
10520 ,p_effective_end_date => l_rec(i).effective_end_date
10521 ,p_object_version_number => l_rec(i).object_version_number
10522 ,p_effective_date => l_effective_date
10523 ,p_datetrack_mode => hr_api.g_delete
10524 ,p_multi_row_validate => FALSE
10525 ,p_source => 'bepenapi'
10526 );
10527 end if;
10528 End loop;
10529 --
10530 if g_debug then
10531 hr_utility.set_location('Del rslts no lngr elig for', 30);
10532 end if;
10533 --
10534 -- Take care of enrollments no longer eligible for
10535 --
10536 -- In Program
10537 --
10538 if p_pgm_id is not null then
10539 --
10540 For rslt in no_lngr_elig_pgm_c Loop
10541 -- Bug 2200139
10542 if rslt.effective_start_date >= p_effective_date then
10543 l_effective_date := rslt.effective_start_date + 1 ;
10544 else
10545 l_effective_date := p_effective_date ;
10546 end if ;
10547 --
10548 if g_debug then
10549
10550 hr_utility.set_location('Del rslt in Pgm no lngr elig for:' ||
10551 to_char(p_pgm_id)||' rslt:'||
10552 to_char(rslt.prtt_enrt_rslt_id), 35);
10553 end if;
10554 delete_enrollment
10555 (p_validate => FALSE
10556 ,p_per_in_ler_id => p_per_in_ler_id
10557 ,p_prtt_enrt_rslt_id => rslt.prtt_enrt_rslt_id
10558 ,p_business_group_id => p_business_group_id
10559 ,p_effective_start_date => l_effective_start_date
10560 ,p_effective_end_date => l_effective_end_date
10561 ,p_object_version_number => rslt.object_version_number
10562 ,p_effective_date => l_effective_date
10563 ,p_datetrack_mode => hr_api.g_delete
10564 ,p_multi_row_validate => FALSE
10565 ,p_source => 'bepenapi'
10566 );
10567 --
10568 End Loop;
10569 --
10570 else
10571 -- not in program
10572 --
10573 For typ In pl_typ_c Loop
10574 --
10575 l_pl_typ_id := typ.pl_typ_id;
10576 --
10577 if g_debug then
10578 hr_utility.set_location('Del rslt no lngr elig for for pl type '||
10579 to_char(l_pl_typ_id), 37);
10580 end if;
10581 --
10582 For rslt In no_lngr_elig_pnip_c Loop
10583 --
10584 -- Bug 2200139
10585 if rslt.effective_start_date >= p_effective_date then
10586 l_effective_date := rslt.effective_start_date + 1 ;
10587 else
10588 l_effective_date := p_effective_date ;
10589 end if ;
10590 --
10591 delete_enrollment
10592 (p_validate => FALSE
10593 ,p_per_in_ler_id => p_per_in_ler_id
10594 ,p_prtt_enrt_rslt_id => rslt.prtt_enrt_rslt_id
10595 ,p_business_group_id => p_business_group_id
10596 ,p_effective_start_date => l_effective_start_date
10597 ,p_effective_end_date => l_effective_end_date
10598 ,p_object_version_number => rslt.object_version_number
10599 ,p_effective_date => l_effective_date
10600 ,p_datetrack_mode => hr_api.g_delete
10601 ,p_multi_row_validate => FALSE
10602 ,p_source => 'bepenapi'
10603 );
10604 --
10605 End Loop;
10606 --
10607 End Loop;
10608 --
10609 End if;
10610 --
10611 End if;
10612 --
10613 --Bug 3051674 Get the le date
10614 --
10615 if p_per_in_ler_id is not null then
10616 --
10617 open c_le_date(p_per_in_ler_id);
10618 fetch c_le_date into l_lf_evt_ocrd_dt ;
10619 close c_le_date ;
10620 --
10621 end if ;
10622 --
10623 l_lf_evt_ocrd_dt := nvl(l_lf_evt_ocrd_dt,p_effective_date);
10624 --
10625 if not p_called_frm_ss then
10626 --
10627 ben_newly_ineligible.defer_delete_enrollment -- Defer ENH
10628 (p_per_in_ler_id => p_per_in_ler_id,
10629 p_person_id => p_person_id,
10630 p_business_group_id => p_business_group_id,
10631 p_effective_date => l_lf_evt_ocrd_dt
10632 );
10633 --
10634 --Start Bug 5768795
10635 --Moved the Code to the below called procedure. chk_coverage_across_plan_types is now externalized
10636 --to be called from benrtchg.pkb.
10637
10638 chk_coverage_across_plan_types
10639 ( p_person_id => p_person_id,
10640 p_effective_date => p_effective_date,
10641 p_lf_evt_ocrd_dt => l_lf_evt_ocrd_dt,
10642 p_business_group_id => p_business_group_id,
10643 p_pgm_id => p_pgm_id);
10644
10645 --End Bug 5768795
10646
10647 --
10648 -- Call multi row edit.
10649 --
10650 open c_ler_typ_cd;
10651 fetch c_ler_typ_cd into l_ler_typ_cd;
10652 close c_ler_typ_cd;
10653 --
10654 -- Bug 6656136
10655 if l_ler_typ_cd in ('SCHEDDO','SCHEDDA') then
10656 --
10657 BEN_PEN_bus.multi_rows_edit
10658 (p_person_id => p_person_id
10659 ,p_effective_date => l_lf_evt_ocrd_dt
10660 ,p_business_group_id => p_business_group_id
10661 ,p_pgm_id => p_pgm_id
10662 ,p_include_erl => p_include_erl
10663 );
10664 --
10665 else
10666 --
10667 BEN_PEN_bus.multi_rows_edit
10668 (p_person_id => p_person_id
10669 ,p_effective_date => p_effective_date
10670 ,p_business_group_id => p_business_group_id
10671 ,p_pgm_id => p_pgm_id
10672 ,p_include_erl => p_include_erl
10673 );
10674 --
10675 end if;
10676 --
10677 -- Bug 6656136
10678 end if; -- p_called_frm_ss
10679 --
10680 if g_debug then
10681 hr_utility.set_location(' Leaving:'||l_proc, 70);
10682 end if;
10683 --
10684 end multi_rows_edit;
10685 --
10686 -- Overloaded
10687 --
10688
10689
10690
10691
10692 procedure multi_rows_edit
10693 (p_person_id in number,
10694 p_effective_date in date,
10695 p_business_group_id in number,
10696 p_pgm_id in number,
10697 p_per_in_ler_id in number default NULL,
10698 p_called_frm_ss in Boolean default FALSE
10699
10700 ) is
10701 begin
10702 ben_prtt_enrt_result_api.multi_rows_edit(p_person_id=> p_person_id
10703 ,p_effective_date => p_effective_date
10704 ,p_business_group_id => p_business_group_id
10705 ,p_pgm_id => p_pgm_id
10706 ,p_per_in_ler_id => p_per_in_ler_id
10707 ,p_include_erl => 'N'
10708 ,p_called_frm_ss => p_called_frm_ss ); -- BUG 4690334
10709 end multi_rows_edit;
10710 --
10711 --
10712 -- ----------------------------------------------------------------------------
10713 -- |---------------------------< update_person_type_usages >----------------------------|
10714 -- ----------------------------------------------------------------------------
10715 --
10716 -- VP 11/08/00
10717 --
10718 Procedure update_person_type_usages
10719 (p_person_id in number,
10720 p_business_group_id in number,
10721 p_effective_date in date
10722 ) is
10723 --
10724 l_proc varchar2(72); -- := g_package||'update_person_type_usages';
10725 --
10726 Begin
10727
10728 g_debug := hr_utility.debug_enabled;
10729 if g_debug then
10730 l_proc := g_package||'update_person_type_usages';
10731 hr_utility.set_location('Entering:'||l_proc, 5);
10732 end if;
10733 --
10734 --
10735 if (g_enrollment_change) then
10736 --
10737 ben_pen_bus.manage_per_type_usages
10738 (p_person_id => p_person_id
10739 ,p_business_group_id => p_business_group_id
10740 ,p_effective_date => p_effective_date
10741 );
10742 null;
10743 --
10744 end if;
10745
10746 g_enrollment_change := FALSE;
10747 --
10748 if g_debug then
10749 hr_utility.set_location(' Leaving:'||l_proc, 10);
10750 end if;
10751 --
10752 End update_person_type_usages;
10753
10754 -- ----------------------------------------------------------------------------
10755 -- |------------------------< delete_enrollment_w >-----------------------------|
10756 -- ----------------------------------------------------------------------------
10757 --
10758 -- Description: Self-service wrapper for delete_enrollment to handle exceptions
10759 --
10760 procedure delete_enrollment_w
10761 (p_validate in boolean default false
10762 ,p_per_in_ler_id in number default NULL
10763 ,p_lee_rsn_id in number default NULL
10764 ,p_enrt_perd_id in number default NULL
10765 ,p_prtt_enrt_rslt_id in number
10766 ,p_business_group_id in number
10767 ,p_effective_start_date out nocopy date
10768 ,p_effective_end_date out nocopy date
10769 ,p_object_version_number in out nocopy number
10770 ,p_effective_date in date
10771 ,p_datetrack_mode in varchar2
10772 ,p_multi_row_validate in boolean default TRUE
10773 ,p_source in varchar2 default null
10774 ,p_enrt_cvg_thru_dt in date default null
10775 ,p_mode in varchar2 default null)
10776 is
10777 l_proc varchar2(72) := g_package||'delete_enrollment_w';
10778 begin
10779 fnd_msg_pub.initialize;
10780
10781 if g_debug then
10782 hr_utility.set_location('Entering:'||l_proc, 5);
10783 end if;
10784
10785 delete_enrollment
10786 (p_validate => p_validate
10787 ,p_per_in_ler_id => p_per_in_ler_id
10788 ,p_lee_rsn_id => p_lee_rsn_id
10789 ,p_enrt_perd_id => p_enrt_perd_id
10790 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
10791 ,p_business_group_id => p_business_group_id
10792 ,p_effective_start_date => p_effective_start_date
10793 ,p_effective_end_date => p_effective_end_date
10794 ,p_object_version_number => p_object_version_number
10795 ,p_effective_date => p_effective_date
10796 ,p_datetrack_mode => p_datetrack_mode
10797 ,p_multi_row_validate => p_multi_row_validate
10798 ,p_enrt_cvg_thru_dt => p_enrt_cvg_thru_dt
10799 ,p_mode => p_mode);
10800
10801 if g_debug then
10802 hr_utility.set_location('Leaving:'||l_proc, 10);
10803 end if;
10804
10805 exception
10806 --
10807 when app_exception.application_exception then --Bug 4387247
10808 hr_utility.set_location ('Application Error in delete_enrollment_w.', 88);
10809 fnd_msg_pub.add;
10810 when others then
10811 if g_debug then
10812 hr_utility.set_location('Exception:'||l_proc, 100);
10813 end if;
10814 hr_utility.set_location ('Other Error in delete_enrollment_w : '|| sqlerrm , 89);
10815 --Bug 4387247
10816 fnd_message.set_name('PER','FFU10_GENERAL_ORACLE_ERROR');
10817 fnd_message.set_token('2',substr(sqlerrm,1,200));
10818 fnd_msg_pub.add;
10819 --
10820 end delete_enrollment_w;
10821 --
10822
10823 end ben_PRTT_ENRT_RESULT_api;