[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.105.12020000.4 2013/03/05 22:51:16 stee 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.326 10-sep-08 sallumwa Bug 7311284 : Modified the condition while setting the effective date in
692 delete_enrollment procedure.
693 115.327 12-Jun-08 sallumwa Bug 7133998: Modified the update_enrollment procedure to delete the future
694 premium records corresponding to the previous Le.
695 115.328 15-Oct-08 stee Bug 7197868: Remove fix for bug 6963660. Change cursor c_old_corr_pen
696 to check for effective_start_date.
697 115.329 07-Nov-08 sallumwa Bug 7458990: Reverted back the fix 5018328,so that the system throws the error
698 when trying to change the plan before the earliest de-enrol date.
699 115.330 29-Jan-09 sallumwa Bug 7711723 :Whenever future certification prvdd records are found,move them to
700 back-up table and delete the same from ben_prtt_enrt_actn_f and
701 ben_prtt_enrt_ctfn_prvdd_f tables.
702 115.332 16-Feb-09 velvanop Bug 7561395: If Coverage Amount is changed multiple times for the same Life Event, then Required
703 Certication alert should not popup. When the Benefit Amount is changed, New penid will
704 be generated for the enrollment. This causes action item and certification records
705 to be deleted of the old penid. When Benefit Amount is changed for the third time, since there are no
706 action item records, certification is still required although produced. Fix will create
707 new Action Item and Certification record for the new penid. History of the previous action items
708 and certification records are not created, but only latest record from the previous penid
709 will be restored.
710 115.333 20-Mar-09 sallumwa Bug 8304294 : Reverted the fix made for the bug 7711723.The fix is implemented in
711 bepeaapi.pkb.
712 115.334 23-Mar-09 sallumwa Bug 8222481 : Modified the procedure delete_enrollment to handle the coverage gaps
713 when multiple changed are made within the same enrollment period,
714 whenever Coverage End Date Code is set as 1 Prior.
715 115.335 28-Apr-09 sallumwa Bug 7209243 : Handled the rate gap when multiple changes are made in the same Life
716 event with Rate end date code as "1 Prior".
717 115.336 06-Jun-09 velvanop Bug 8578358 : APP-BEN-91902 error should not be thrown when changing the option with
718 in the same plan within the required period of enrollment
719 115.338 10-Jun-09 velvanop Bug 8573195 : Ended_per_in_ler_id of future backedout lifeevent is being updated while adjusting the rates
720 on processing and saving the elctions of intervening LifeEvent.
721 115.340 10-Aug-09 velvanop Bug 8669907 : Fix 7561395 copies the action items when ever the coverage amount is changed multiple time in the same lifevent.
722 This results in action item being created even if the Participant selects
723 No Coverage plans against the new pen_id.. Only completed action items will be copied and check will be made whether to copy the
724 completed actions items or not.
725 115.341 25-Aug-09 sallumwa Bug 8688513 : Modified the fix done for 8222481 to handle the coverage gaps when no electability exists for the
726 previous life event.
727 115.343 07-Oct-09 sallumwa Bug 8919376 : Update the elig cvrd dpnt ID in the ben_elig_cvrd_dpnt_f table correponding to the
728 enrollment result if the participant is currently enrolled in the plan.
729 115.344 14-Oct-09 stee Bug 8972844 : Changed cursor c_bckup_tbl_restore.
730 115.345 13-Nov-09 stee Bug 9114147 : Use life event occurred date to check if an enrollment is
731 overriden when determining if an enrollment should be terminated
732 in multi_rows_edit.
733 115.346 08-Jan-09 velvanop Bug 9256641 : Do not generate communications while creating the action items
734 115.348 16-Apr-10 sallumwa Bug 9534364 : Modified the IF condition to update the row in ben_elig_cvrd_dpnt_f table.
735 115.349 20-Apr-10 sagnanas Bug 9501588 : Modified cursor c_old_dpnt in procedure unhook_dpnt
736 115.350 08-Jun-10 velvanop Bug 9748558 : If a person move out of the result and re-enroll into the same result
737 on a different day in the same enrollment period,then re-cover the dependents.
738 115.351 30-Aug-10 velvanop Bug 10048313 : For a plan having Required Period of enrollment defined and participant changes the option with in the same plan
739 and again deenrolls from the plan to a new plan, Error 'BEN_91902_ENRT_NOT_ALWD_DELETE' is not thrown.
740 Modified cursor 'c_rslt_pl'
741 115.352 01-Sep-10 sagnanas Bug 9881657 : Modified cursor c_egd to pick the correct dependents for whom the coverage existed as on the newly determined
742 coverage start date. Same with cursor c_check_cvrd_dpnt too.
743 115.353 19-Nov-10 stee Bug 10283346 : When deleting premium rows check for the date-track mode.
744 115.354 29-Apr-11 velvanop Bug 12356840 : If in the backup table, bkup_tbl_id is same for different tables and exists a _CORR record(ex pen_id and elig_per_id can be same because of the
745 number generated by sequence), c_get_correction_info fails and finds record of other table for a given pen table bkup_tbl_id .
746 amnaraya 120.40.12000000.54 18-May-11 Bug 12566240: PAssed person_id to the cursor c_get_correction_info.
747 usaraswa 120.40.12000000.55 24-06-11 Bug 12662110:'APP-BEN-91587' should not be thrown when deenrolling from existing plan and enrolling in to new plan of same PlanType
748 Which is having 'MAX' restriction. cursor c_new_cvg_strt_dt is modified to handle the diferent plans of Same Plantype.
749 usaraswa 120.40.12000000.56 17-Aug-11 Bug 12876320: 'APP-BEN-91587' should not be thrown when Unrestricted Le is processed and deenrolling from existing option in plan and
750 enrolling in to different option of the same plan Which is having 'MAX' restriction.
751 cursor c_new_cvg_strt_dt is modified to handle the diferent options of Same Plan.
752 120.40.12000000.57 29-Sep-11 velvanop Bug 13034863 : When suspended enrollment is deleted/end dated because of certification is denied, enrollments that
753 are end dated for previous life event should not be touched
754 120.40.12000000.58 05-Mar-12 stee Bug 12583091 : If rates are voided for an enrollment
755 that was previously suspended, reinstate
756 the rate start date if it was updated
757 when the action item was completed.
758 120.40.12000000.59 10-Sep-12 stee Bug 14599287 : Fix c_new_cvg_strt_dt to check for enrollment in
759 multiple plans in a plan type.
760 120.40.12000000.60 10-Feb-12 stee Bug 16068560: Fix c_get_old_prv1 to select the
761 rate for the same enrollment result.
762
763 ==================================================================================================================
764 */
765 --
766 -- Package Variables
767 --
768 g_package Varchar2(33) := ' ben_PRTT_ENRT_RESULT_api.';
769 g_debug boolean := hr_utility.debug_enabled;
770
771 /* Added for Bug 7561395*/
772
773 g_new_prtt_enrt_rslt_id number;
774 TYPE g_enrt_list_tab IS TABLE OF NUMBER;
775 g_enrt_list g_enrt_list_tab := g_enrt_list_tab();
776
777 /*End for 7561395 */
778 --
779 Function display_boolean(p_condition boolean) return varchar2 is
780 begin
781 if (p_condition) then
782 return 'TRUE';
783 else
784 return 'FALSE';
785 end if;
786 end display_boolean;
787 --
788 procedure rpt_error (p_proc in varchar2
789 ,p_step in number
790 ) is
791 begin
792 if g_debug then
793 hr_utility.set_location('Fail in '|| p_proc || ' at step ' ||
794 to_char(p_step),999);
795 end if;
796 end;
797
798
799
800 --
801 -- ----------------------------------------------------------------------------
802 -- |----------------------< Remove_Cert_Action_items >------------------------|
803 -- ----------------------------------------------------------------------------
804 --
805
806 procedure remove_cert_action_items
807 (p_prtt_enrt_rslt_id in number
808 ,p_effective_date in date
809 ,p_end_date in date default null
810 ,p_business_group_id in number
811 ,p_validate in boolean default FALSE
812 ,p_datetrack_mode in varchar2
813 ,p_source in varchar2 default null
814 ,p_per_in_ler_id in number default null
815 ,p_per_in_ler_ended_id in number default null
816 ) is
817 l_proc varchar2(80); -- := g_package||'.remove_cert_action_items';
818 l_step number(5);
819 l_tmp number(15);
820
821 cursor c_bnf_types is
822 select pea.prtt_enrt_actn_id
823 ,pea.object_version_number
824 ,pea.effective_start_date
825 ,pea.effective_end_date
826 ,pil.lf_evt_ocrd_dt
827 from ben_prtt_enrt_actn_f pea,
828 ben_per_in_ler pil
829 where pea.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
830 and pea.business_group_id = p_business_group_id
831 and p_effective_date
832 between pea.effective_start_date and pea.effective_end_date
833 and pil.per_in_ler_id=pea.per_in_ler_id
834 and pil.business_group_id=pea.business_group_id
835 and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT') ;
836
837 cursor c_min_max_dt(p_prtt_enrt_actn_id number) is
838 select min(effective_start_date),
839 max(effective_end_date)
840 from ben_prtt_enrt_actn_f
841 where prtt_enrt_actn_id = p_prtt_enrt_actn_id;
842 --
843 cursor c_pea_ovn(p_prtt_enrt_actn_id number,
844 p_effective_date date) is
845 select pea.object_version_number
846 from ben_prtt_enrt_actn_f pea
847 where pea.prtt_enrt_actn_id = p_prtt_enrt_actn_id
848 and p_effective_date between pea.effective_start_date
849 and pea.effective_end_date ;
850 --
851 cursor c_future_pea(p_prtt_enrt_actn_id number,p_effective_date date ) is
852 select *
853 from ben_prtt_enrt_actn_f
854 where prtt_enrt_actn_id = p_prtt_enrt_actn_id
855 and effective_start_date > p_effective_date
856 order by effective_start_date desc ;
857
858 --
859 cursor c_future_pcs(p_prtt_enrt_actn_id number,p_effective_date date ) is
860 select *
861 from ben_prtt_enrt_ctfn_prvdd_f
862 where prtt_enrt_actn_id = p_prtt_enrt_actn_id
863 and effective_start_date > p_effective_date
864 order by effective_start_date desc ;
865 --
866 l_effective_date date;
867 l_min_start_date date;
868 l_max_end_date date;
869 l_datetrack_mode varchar2(30);
870 --
871 begin
872 if g_debug then
873 l_proc := g_package||'.remove_cert_action_items';
874 hr_utility.set_location ('Entering '||l_proc,10);
875 hr_utility.set_location ('p_end_date '||p_end_date,10);
876 end if;
877 --
878 l_step := 10;
879 /* leslie removed this call
880 for l_prtt_ctfn_prvdd in c_prtt_ctfn_prvdd loop
881 ben_prtt_enrt_ctfn_prvdd_api.delete_prtt_enrt_ctfn_prvdd
882 (p_validate => FALSE
883 ,p_prtt_enrt_ctfn_prvdd_id=> l_prtt_ctfn_prvdd.prtt_enrt_ctfn_prvdd_id
884 ,p_effective_start_date => l_prtt_ctfn_prvdd.effective_start_date
885 ,p_effective_end_date => l_prtt_ctfn_prvdd.effective_end_date
886 ,p_object_version_number => l_prtt_ctfn_prvdd.object_version_number
887 ,p_effective_date => p_effective_date
888 ,p_datetrack_mode => p_datetrack_mode
889 );
890 end loop;
891 l_step := 20;
892 */
893 for l_bnf_types in c_bnf_types loop
894 l_step := 25;
895 if p_end_date is not null then
896
897 l_min_start_date := null;
898 l_max_end_date := null;
899
900 open c_min_max_dt(l_bnf_types.prtt_enrt_actn_id);
901 fetch c_min_max_dt into l_min_start_date,l_max_end_date;
902 close c_min_max_dt;
903
904 if p_end_date < l_min_start_date then
905 l_effective_date := p_effective_date;
906 l_datetrack_mode := hr_api.g_zap;
907 elsif p_end_date < l_max_end_date then
908 l_effective_date := p_end_date;
909 l_datetrack_mode := hr_api.g_delete;
910 --
911 --get the correct ovn
912 --
913 open c_pea_ovn(l_bnf_types.prtt_enrt_actn_id, p_end_date);
914 fetch c_pea_ovn into l_bnf_types.object_version_number;
915 close c_pea_ovn;
916 --
917 else
918 l_datetrack_mode := null;
919 end if;
920
921 if l_datetrack_mode is not null then
922 --
923 --BUG 5985777 writing future action items to backup table
924 --
925 --Find if there are any future action items. If exists
926 --backup those rows.
927 --
928 --ben_prtt_enrt_actn_f
929 --
930 for l_pea in c_future_pea(l_bnf_types.prtt_enrt_actn_id,l_effective_date) loop
931 --
932 insert into BEN_LE_CLSN_N_RSTR (
933 BKUP_TBL_TYP_CD,
934 BKUP_TBL_ID,
935 EFFECTIVE_START_DATE,
936 EFFECTIVE_END_DATE,
937 PRTT_IS_CVRD_FLAG, -- RQD_FLAG
938 ASSIGNMENT_ID, -- ACTN_TYP_ID
939 PRTT_ENRT_RSLT_ID,
940 PER_IN_LER_ID,
941 BUSINESS_GROUP_ID,
942 ENRT_CVG_THRU_DT, -- CMPLTD_DT
943 ENRT_OVRID_THRU_DT, -- DUE_DT
944 PGM_ID, -- PL_BNF_ID
945 PTIP_ID, -- ELIG_CVRD_DPNT_ID
946 LCR_ATTRIBUTE_CATEGORY,
947 LCR_ATTRIBUTE1,
948 LCR_ATTRIBUTE2,
949 LCR_ATTRIBUTE3,
950 LCR_ATTRIBUTE4,
951 LCR_ATTRIBUTE5,
952 LCR_ATTRIBUTE6,
953 LCR_ATTRIBUTE7,
954 LCR_ATTRIBUTE8,
955 LCR_ATTRIBUTE9,
956 LCR_ATTRIBUTE10,
957 LCR_ATTRIBUTE11,
958 LCR_ATTRIBUTE12,
959 LCR_ATTRIBUTE13,
960 LCR_ATTRIBUTE14,
961 LCR_ATTRIBUTE15 ,
962 LCR_ATTRIBUTE16,
963 LCR_ATTRIBUTE17,
964 LCR_ATTRIBUTE18,
965 LCR_ATTRIBUTE19,
966 LCR_ATTRIBUTE20,
967 LCR_ATTRIBUTE21,
968 LCR_ATTRIBUTE22,
969 LCR_ATTRIBUTE23,
970 LCR_ATTRIBUTE24,
971 LCR_ATTRIBUTE25,
972 LCR_ATTRIBUTE26,
973 LCR_ATTRIBUTE27,
974 LCR_ATTRIBUTE28,
975 LCR_ATTRIBUTE29,
976 LCR_ATTRIBUTE30,
977 LAST_UPDATE_DATE,
978 LAST_UPDATED_BY,
979 LAST_UPDATE_LOGIN,
980 CREATED_BY,
981 CREATION_DATE,
982 REQUEST_ID,
983 PROGRAM_APPLICATION_ID,
984 PROGRAM_ID,
985 PROGRAM_UPDATE_DATE,
986 OBJECT_VERSION_NUMBER,
987 PER_IN_LER_ENDED_ID)
988 values (
989 'BEN_PRTT_ENRT_ACTN_F_UPD'
990 ,l_pea.PRTT_ENRT_ACTN_ID
991 ,l_pea.EFFECTIVE_START_DATE
992 ,l_pea.EFFECTIVE_END_DATE
993 ,l_pea.RQD_FLAG
994 ,l_pea.ACTN_TYP_ID
995 ,l_pea.PRTT_ENRT_RSLT_ID
996 ,P_PER_IN_LER_ID
997 ,l_pea.BUSINESS_GROUP_ID
998 ,l_pea.CMPLTD_DT
999 ,l_pea.DUE_DT
1000 ,l_pea.PL_BNF_ID
1001 ,l_pea.ELIG_CVRD_DPNT_ID
1002 ,l_pea.PEA_ATTRIBUTE_CATEGORY
1003 ,l_pea.PEA_ATTRIBUTE1
1004 ,l_pea.PEA_ATTRIBUTE2
1005 ,l_pea.PEA_ATTRIBUTE3
1006 ,l_pea.PEA_ATTRIBUTE4
1007 ,l_pea.PEA_ATTRIBUTE5
1008 ,l_pea.PEA_ATTRIBUTE6
1009 ,l_pea.PEA_ATTRIBUTE7
1010 ,l_pea.PEA_ATTRIBUTE8
1011 ,l_pea.PEA_ATTRIBUTE9
1012 ,l_pea.PEA_ATTRIBUTE10
1013 ,l_pea.PEA_ATTRIBUTE11
1014 ,l_pea.PEA_ATTRIBUTE12
1015 ,l_pea.PEA_ATTRIBUTE13
1016 ,l_pea.PEA_ATTRIBUTE14
1017 ,l_pea.PEA_ATTRIBUTE15
1018 ,l_pea.PEA_ATTRIBUTE16
1019 ,l_pea.PEA_ATTRIBUTE17
1020 ,l_pea.PEA_ATTRIBUTE18
1021 ,l_pea.PEA_ATTRIBUTE19
1022 ,l_pea.PEA_ATTRIBUTE20
1023 ,l_pea.PEA_ATTRIBUTE21
1024 ,l_pea.PEA_ATTRIBUTE22
1025 ,l_pea.PEA_ATTRIBUTE23
1026 ,l_pea.PEA_ATTRIBUTE24
1027 ,l_pea.PEA_ATTRIBUTE25
1028 ,l_pea.PEA_ATTRIBUTE26
1029 ,l_pea.PEA_ATTRIBUTE27
1030 ,l_pea.PEA_ATTRIBUTE28
1031 ,l_pea.PEA_ATTRIBUTE29
1032 ,l_pea.PEA_ATTRIBUTE30
1033 ,l_pea.LAST_UPDATE_DATE
1034 ,l_pea.LAST_UPDATED_BY
1035 ,l_pea.LAST_UPDATE_LOGIN
1036 ,l_pea.CREATED_BY
1037 ,l_pea.CREATION_DATE
1038 ,l_pea.REQUEST_ID
1039 ,l_pea.PROGRAM_APPLICATION_ID
1040 ,l_pea.PROGRAM_ID
1041 ,l_pea.PROGRAM_UPDATE_DATE
1042 ,l_pea.OBJECT_VERSION_NUMBER
1043 ,p_per_in_ler_ended_id
1044 );
1045
1046 end loop;
1047 --
1048 --ben_prtt_enrt_ctfn_prvdd_f
1049 --
1050 for l_lcs in c_future_pcs(l_bnf_types.prtt_enrt_actn_id,l_effective_date) loop
1051 --
1052 insert into BEN_LE_CLSN_N_RSTR (
1053 BKUP_TBL_TYP_CD,
1054 BKUP_TBL_ID,
1055 EFFECTIVE_START_DATE,
1056 EFFECTIVE_END_DATE,
1057 PRTT_IS_CVRD_FLAG, -- ENRT_CTFN_RQD_FLAG
1058 COMP_LVL_CD, -- ENRT_CTFN_TYP_CD
1059 ENRT_CVG_THRU_DT, -- ENRT_CTFN_RECD_DT
1060 PRTT_ENRT_RSLT_ID,
1061 PGM_ID, -- PRTT_ENRT_ACTN_ID
1062 ENRT_OVRID_THRU_DT, -- ENRT_CTFN_DND_DT
1063 BNFT_TYP_CD, -- ENRT_R_BNFT_CTFN_CD
1064 BUSINESS_GROUP_ID,
1065 LCR_ATTRIBUTE_CATEGORY,
1066 LCR_ATTRIBUTE1,
1067 LCR_ATTRIBUTE2,
1068 LCR_ATTRIBUTE3,
1069 LCR_ATTRIBUTE4,
1070 LCR_ATTRIBUTE5,
1071 LCR_ATTRIBUTE6,
1072 LCR_ATTRIBUTE7,
1073 LCR_ATTRIBUTE8,
1074 LCR_ATTRIBUTE9,
1075 LCR_ATTRIBUTE10,
1076 LCR_ATTRIBUTE11,
1077 LCR_ATTRIBUTE12,
1078 LCR_ATTRIBUTE13,
1079 LCR_ATTRIBUTE14,
1080 LCR_ATTRIBUTE15 ,
1081 LCR_ATTRIBUTE16,
1082 LCR_ATTRIBUTE17,
1083 LCR_ATTRIBUTE18,
1084 LCR_ATTRIBUTE19,
1085 LCR_ATTRIBUTE20,
1086 LCR_ATTRIBUTE21,
1087 LCR_ATTRIBUTE22,
1088 LCR_ATTRIBUTE23,
1089 LCR_ATTRIBUTE24,
1090 LCR_ATTRIBUTE25,
1091 LCR_ATTRIBUTE26,
1092 LCR_ATTRIBUTE27,
1093 LCR_ATTRIBUTE28,
1094 LCR_ATTRIBUTE29,
1095 LCR_ATTRIBUTE30,
1096 LAST_UPDATE_DATE,
1097 LAST_UPDATED_BY,
1098 LAST_UPDATE_LOGIN,
1099 CREATED_BY,
1100 CREATION_DATE,
1101 REQUEST_ID,
1102 PROGRAM_APPLICATION_ID,
1103 PROGRAM_ID,
1104 PROGRAM_UPDATE_DATE,
1105 OBJECT_VERSION_NUMBER,
1106 PER_IN_LER_ID,
1107 PER_IN_LER_ENDED_ID)
1108 values (
1109 'BEN_PRTT_ENRT_CTFN_PRVDD_F_UPD'
1110 ,l_lcs.PRTT_ENRT_CTFN_PRVDD_ID
1111 ,l_lcs.EFFECTIVE_START_DATE
1112 ,l_lcs.EFFECTIVE_END_DATE
1113 ,l_lcs.ENRT_CTFN_RQD_FLAG
1114 ,l_lcs.ENRT_CTFN_TYP_CD
1115 ,l_lcs.ENRT_CTFN_RECD_DT
1116 ,l_lcs.PRTT_ENRT_RSLT_ID
1117 ,l_lcs.PRTT_ENRT_ACTN_ID
1118 ,l_lcs.ENRT_CTFN_DND_DT
1119 ,l_lcs.ENRT_R_BNFT_CTFN_CD
1120 ,l_lcs.BUSINESS_GROUP_ID
1121 ,l_lcs.PCS_ATTRIBUTE_CATEGORY
1122 ,l_lcs.PCS_ATTRIBUTE1
1123 ,l_lcs.PCS_ATTRIBUTE2
1124 ,l_lcs.PCS_ATTRIBUTE3
1125 ,l_lcs.PCS_ATTRIBUTE4
1126 ,l_lcs.PCS_ATTRIBUTE5
1127 ,l_lcs.PCS_ATTRIBUTE6
1128 ,l_lcs.PCS_ATTRIBUTE7
1129 ,l_lcs.PCS_ATTRIBUTE8
1130 ,l_lcs.PCS_ATTRIBUTE9
1131 ,l_lcs.PCS_ATTRIBUTE10
1132 ,l_lcs.PCS_ATTRIBUTE11
1133 ,l_lcs.PCS_ATTRIBUTE12
1134 ,l_lcs.PCS_ATTRIBUTE13
1135 ,l_lcs.PCS_ATTRIBUTE14
1136 ,l_lcs.PCS_ATTRIBUTE15
1137 ,l_lcs.PCS_ATTRIBUTE16
1138 ,l_lcs.PCS_ATTRIBUTE17
1139 ,l_lcs.PCS_ATTRIBUTE18
1140 ,l_lcs.PCS_ATTRIBUTE19
1141 ,l_lcs.PCS_ATTRIBUTE20
1142 ,l_lcs.PCS_ATTRIBUTE21
1143 ,l_lcs.PCS_ATTRIBUTE22
1144 ,l_lcs.PCS_ATTRIBUTE23
1145 ,l_lcs.PCS_ATTRIBUTE24
1146 ,l_lcs.PCS_ATTRIBUTE25
1147 ,l_lcs.PCS_ATTRIBUTE26
1148 ,l_lcs.PCS_ATTRIBUTE27
1149 ,l_lcs.PCS_ATTRIBUTE28
1150 ,l_lcs.PCS_ATTRIBUTE29
1151 ,l_lcs.PCS_ATTRIBUTE30
1152 ,l_lcs.LAST_UPDATE_DATE
1153 ,l_lcs.LAST_UPDATED_BY
1154 ,l_lcs.LAST_UPDATE_LOGIN
1155 ,l_lcs.CREATED_BY
1156 ,l_lcs.CREATION_DATE
1157 ,l_lcs.REQUEST_ID
1158 ,l_lcs.PROGRAM_APPLICATION_ID
1159 ,l_lcs.PROGRAM_ID
1160 ,l_lcs.PROGRAM_UPDATE_DATE
1161 ,l_lcs.OBJECT_VERSION_NUMBER
1162 ,p_per_in_ler_id
1163 ,p_per_in_ler_ended_id
1164 );
1165
1166 --
1167 -- Bug 8304294,the fix for 7711723 is reverted.
1168 -- l_datetrack_mode := hr_api.g_future_change; ----Bug 7711723
1169 end loop;
1170 --
1171 ben_prtt_enrt_actn_api.delete_prtt_enrt_actn
1172 (p_validate => FALSE
1173 ,p_prtt_enrt_actn_id => l_bnf_types.prtt_enrt_actn_id
1174 ,p_effective_start_date => l_bnf_types.effective_start_date
1175 ,p_effective_end_date => l_bnf_types.effective_end_date
1176 ,p_object_version_number => l_bnf_types.object_version_number
1177 ,p_effective_date => l_effective_date
1178 ,p_datetrack_mode => l_datetrack_mode
1179 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
1180 ,p_unsuspend_enrt_flag => 'N'
1181 ,p_rslt_object_version_number => l_tmp
1182 ,p_business_group_id => p_business_group_id);
1183 end if;
1184
1185 else
1186 --
1187 -- Datetrack delete the action items, one day before.
1188 -- Do not decrease the effective date, when called from 'benelinf',
1189 -- as the date is already modified in delete_enrollment in such cases.
1190 --
1191 if l_bnf_types.effective_start_date < p_effective_date and
1192 p_datetrack_mode = hr_api.g_delete and
1193 nvl(p_source,'benelinf') <> 'benelinf' then
1194 l_datetrack_mode := p_datetrack_mode;
1195 l_effective_date := p_effective_date -1;
1196 -- 4962138
1197 elsif l_bnf_types.effective_start_date <= p_effective_date and
1198 p_datetrack_mode = hr_api.g_delete and
1199 p_source is null then
1200 l_datetrack_mode := hr_api.g_zap;
1201 l_effective_date := p_effective_date;
1202 -- end 4962138
1203 else
1204 l_datetrack_mode := p_datetrack_mode;
1205 l_effective_date := p_effective_date;
1206 end if;
1207 --
1208 -- Do not attempt dt delete if the row selected already has an effective
1209 -- end date equal to(or less than) the date you are trying to delete it on.
1210 -- Bug 1132739
1211 --
1212 if (p_datetrack_mode = hr_api.g_delete and
1213 l_bnf_types.effective_end_date > l_effective_date) or
1214 p_datetrack_mode <> hr_api.g_delete then
1215 ben_prtt_enrt_actn_api.delete_prtt_enrt_actn
1216 (p_validate => FALSE
1217 ,p_prtt_enrt_actn_id => l_bnf_types.prtt_enrt_actn_id
1218 ,p_effective_start_date => l_bnf_types.effective_start_date
1219 ,p_effective_end_date => l_bnf_types.effective_end_date
1220 ,p_object_version_number => l_bnf_types.object_version_number
1221 ,p_effective_date => l_effective_date
1222 ,p_datetrack_mode => l_datetrack_mode -- 4962138
1223 ,P_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
1224 ,P_unsuspend_enrt_flag => 'N'
1225 ,P_rslt_object_version_number => l_tmp
1226 ,P_business_group_id => p_business_group_id);
1227 end if;
1228 end if;
1229 end loop;
1230 if g_debug then
1231 hr_utility.set_location ('Leaving '||l_proc,70);
1232 end if;
1233 --
1234 exception
1235 when others then
1236 if g_debug then
1237 hr_utility.set_location ('Fail in '||l_proc|| ' at step ' ||
1238 to_char(l_step),999);
1239 end if;
1240 raise;
1241 end;
1242 --
1243 -- ----------------------------------------------------------------------------
1244 -- |-------------------------< Get_ben_upd_dt_mode >---------------------------|
1245 -- ----------------------------------------------------------------------------
1246
1247 procedure get_ben_pen_upd_dt_mode
1248 (p_effective_date in date
1249 ,p_base_key_value in number
1250 ,P_desired_datetrack_mode in varchar2
1251 ,P_datetrack_allow in out nocopy varchar2
1252 ,p_ler_typ_cd in varchar2 default null
1253 )is
1254 l_dt_correction boolean;
1255 l_dt_update boolean;
1256 l_dt_update_override boolean;
1257 l_dt_update_change_insert boolean;
1258 -- Bug 4431511 new variables created
1259 l_dt_delete_next_change boolean;
1260 l_dt_delete boolean;
1261 l_dt_zap boolean;
1262 l_dt_future_change boolean;
1263 -- End Bug 4431511
1264 l_step number(9);
1265 l_proc varchar2(80) ; -- := g_package||'.get_ben_pen_upd_dt_mode';
1266 begin
1267 --
1268 g_debug := hr_utility.debug_enabled;
1269 if g_debug then
1270 l_proc := g_package||'.get_ben_pen_upd_dt_mode';
1271 hr_utility.set_location ('Entering '||l_proc,10);
1272 hr_utility.set_location('IK p_effective_date'||p_effective_date,1234);
1273 hr_utility.set_location('IK P_desired_datetrack_mode '||P_desired_datetrack_mode,1234);
1274 end if;
1275 --
1276 l_step := 10;
1277 --
1278 ben_pen_shd.find_dt_upd_modes
1279 (p_effective_date => p_effective_date
1280 ,p_base_key_value => p_base_key_value
1281 ,p_correction => l_dt_correction
1282 ,p_update => l_dt_update
1283 ,p_update_override => l_dt_update_override
1284 ,p_update_change_insert => l_dt_update_change_insert
1285 );
1286 --Bug 4431511 calling the find_dt_del_modes
1287 if(p_ler_typ_cd = 'SCHEDDU'
1288 and p_desired_datetrack_mode = hr_api.g_delete_next_change) then
1289
1290 ben_pen_shd.find_dt_del_modes
1291 (p_effective_date => p_effective_date
1292 ,p_base_key_value => p_base_key_value
1293 ,p_delete_next_change => l_dt_delete_next_change
1294 ,p_zap => l_dt_zap
1295 ,p_delete => l_dt_delete
1296 ,p_future_change => l_dt_future_change
1297 );
1298 END if;
1299
1300 if(p_ler_typ_cd = 'SCHEDDU'
1301 and p_desired_datetrack_mode = hr_api.g_delete) then
1302
1303 ben_pen_shd.find_dt_del_modes
1304 (p_effective_date => p_effective_date
1305 ,p_base_key_value => p_base_key_value
1306 ,p_delete_next_change => l_dt_delete_next_change
1307 ,p_zap => l_dt_zap
1308 ,p_delete => l_dt_delete
1309 ,p_future_change => l_dt_future_change
1310 );
1311 END if;
1312 -- End 4431511
1313
1314 --
1315 l_step := 20;
1316 --
1317 if l_dt_correction then
1318 if g_debug then
1319 hr_utility.set_location( 'l_dt_correction',1234);
1320 end if;
1321 end if;
1322 --
1323 if l_dt_update then
1324 if g_debug then
1325 hr_utility.set_location( 'l_dt_update',1234);
1326 end if;
1327 end if;
1328 --
1329 if l_dt_update_override then
1330 if g_debug then
1331 hr_utility.set_location( 'l_dt_update_override',1234);
1332 end if;
1333 end if;
1334 --
1335 if l_dt_update_change_insert then
1336 if g_debug then
1337 hr_utility.set_location( 'l_dt_update_change_insert',1234);
1338 end if;
1339 end if;
1340
1341 if l_dt_delete_next_change then
1342 if g_debug then
1343 hr_utility.set_location( 'l_dt_delete_next_change',1234);
1344 end if;
1345 end if;
1346
1347 if l_dt_delete then
1348 if g_debug then
1349 hr_utility.set_location( 'l_dt_delete',1234);
1350 end if;
1351 end if;
1352
1353 --
1354 if (p_desired_datetrack_mode = hr_api.g_update and l_dt_update) then
1355 p_datetrack_allow := hr_api.g_update;
1356 elsif (p_desired_datetrack_mode = hr_api.g_correction and l_dt_correction) then
1357 p_datetrack_allow := hr_api.g_correction;
1358 elsif (l_dt_update) then
1359 p_datetrack_allow := hr_api.g_update;
1360 --Bug 2739965 In case of unrestricted we need to take the
1361 -- l_dt_update_override case also.
1362 elsif (l_dt_update_override and -- p_ler_typ_cd = 'SCHEDDU' and --Bug 5102337 this applied to LE mode also
1363 p_desired_datetrack_mode = hr_api.g_update) then
1364 p_datetrack_allow := hr_api.g_update_override;
1365 --Bug 4431511 Added this check to ensure update_override is passed as
1366 --effective datetrack mode if the desired date track mode is
1367 --delete next change in case of unrestricted enrollments
1368 elsif (l_dt_delete_next_change and p_ler_typ_cd = 'SCHEDDU' and
1369 p_desired_datetrack_mode = hr_api.g_delete_next_change) then
1370 p_datetrack_allow := hr_api.g_update_override;
1371 elsif (l_dt_delete and p_ler_typ_cd = 'SCHEDDU' and
1372 p_desired_datetrack_mode = hr_api.g_delete) then
1373 p_datetrack_allow := hr_api.g_update_override;
1374 --End Bug 4431511
1375 elsif (l_dt_correction) then
1376 p_datetrack_allow := hr_api.g_correction;
1377 else
1378 rpt_error(p_proc => l_proc, p_step => l_step);
1379 fnd_message.set_name('BEN', 'BEN_91700_DATETRACK_NOT_ALWD');
1380 fnd_message.set_token('MODE',p_desired_datetrack_mode);
1381 fnd_message.raise_error;
1382 end if;
1383 --
1384 if g_debug then
1385 hr_utility.set_location(' P_datetrack_allow '||P_datetrack_allow ,1234);
1386 end if;
1387 l_step := 30;
1388 --
1389 if g_debug then
1390 hr_utility.set_location ('Leaving '||l_proc,70);
1391 end if;
1392 Exception
1393 when others then
1394 rpt_error(p_proc => l_proc, p_step => l_step);
1395 raise;
1396 end;
1397 --
1398 --
1399 -- Added by pxdas for logging change event needed for extract.
1400 --
1401 -- ----------------------------------------------------------------------------
1402 -- |-------------------------< Change_Exists_In_DB >---------------------------|
1403 -- ----------------------------------------------------------------------------
1404 -- Private Function:
1405 -- This procedure checks whether change already exists in DB.
1406 -- Returns:
1407 -- TRUE - if exists
1408 -- FALSE - otherwise
1409 --
1410 function change_exists_in_db
1411 (p_person_id in number
1412 ,p_chg_evt_cd in varchar2
1413 ,p_chg_eff_dt in date
1414 ,p_pl_id in number
1415 ,p_oipl_id in number
1416 ) return boolean is
1417 --
1418 cursor get_change is
1419 SELECT null
1420 FROM ben_ext_chg_evt_log a
1421 WHERE a.person_id = p_person_id
1422 AND a.chg_evt_cd = p_chg_evt_cd
1423 AND a.prmtr_01 = to_char(p_pl_id)
1424 AND a.prmtr_02 = to_char(p_oipl_id)
1425 AND trunc(a.chg_eff_dt) = trunc(p_chg_eff_dt);
1426 --
1427 l_proc varchar2(80) ; -- := g_package || '.change_exists_in_db';
1428 l_dummy varchar2(30);
1429 l_return boolean;
1430 --
1431 begin
1432 --
1433 if g_debug then
1434 l_proc := g_package || '.change_exists_in_db';
1435 hr_utility.set_location ('Entering '||l_proc,10);
1436 end if;
1437 --
1438 open get_change;
1439 fetch get_change into l_dummy;
1440 --
1441 if get_change%found then
1442 l_return := TRUE;
1443 else
1444 l_return := FALSE;
1445 end if;
1446 --
1447 close get_change;
1448 --
1449 return (l_return);
1450 --
1451 if g_debug then
1452 hr_utility.set_location ('Leaving '||l_proc,70);
1453 end if;
1454 --
1455 end change_exists_in_db;
1456 --
1457 -- ----------------------------------------------------------------------------
1458 -- |---------------------------< create_enrollment >--------------------------|
1459 -- ----------------------------------------------------------------------------
1460 --
1461 procedure create_enrollment
1462 (p_validate in boolean default false
1463 ,p_prtt_enrt_rslt_id out nocopy number
1464 ,p_effective_start_date out nocopy date
1465 ,p_effective_end_date out nocopy date
1466 ,p_business_group_id in number default null
1467 ,p_oipl_id in number default null
1468 ,p_person_id in number default null
1469 ,p_assignment_id in number default null
1470 ,p_pgm_id in number default null
1471 ,p_pl_id in number default null
1472 ,p_rplcs_sspndd_rslt_id in number default null
1473 ,p_ptip_id in number default null
1474 ,p_pl_typ_id in number default null
1475 ,p_ler_id in number default null
1476 ,p_sspndd_flag in varchar2 default 'N'
1477 ,p_called_from_sspnd in varchar2 default 'N'
1478 ,p_prtt_is_cvrd_flag in varchar2 default 'N'
1479 ,p_bnft_amt in number default null
1480 ,p_uom in varchar2 default null
1481 ,p_orgnl_enrt_dt in date default null
1482 ,p_enrt_mthd_cd in varchar2 default null
1483 ,p_enrt_ovridn_flag in varchar2 default 'N'
1484 ,p_enrt_ovrid_rsn_cd in varchar2 default null
1485 ,p_erlst_deenrt_dt in date default null
1486 ,p_enrt_cvg_strt_dt in date default null
1487 ,p_enrt_cvg_thru_dt in date default hr_api.g_eot
1488 ,p_enrt_ovrid_thru_dt in date default null
1489 ,p_pl_ordr_num in number default null
1490 ,p_plip_ordr_num in number default null
1491 ,p_ptip_ordr_num in number default null
1492 ,p_oipl_ordr_num in number default null
1493 ,p_pen_attribute_category in varchar2 default null
1494 ,p_pen_attribute1 in varchar2 default null
1495 ,p_pen_attribute2 in varchar2 default null
1496 ,p_pen_attribute3 in varchar2 default null
1497 ,p_pen_attribute4 in varchar2 default null
1498 ,p_pen_attribute5 in varchar2 default null
1499 ,p_pen_attribute6 in varchar2 default null
1500 ,p_pen_attribute7 in varchar2 default null
1501 ,p_pen_attribute8 in varchar2 default null
1502 ,p_pen_attribute9 in varchar2 default null
1503 ,p_pen_attribute10 in varchar2 default null
1504 ,p_pen_attribute11 in varchar2 default null
1505 ,p_pen_attribute12 in varchar2 default null
1506 ,p_pen_attribute13 in varchar2 default null
1507 ,p_pen_attribute14 in varchar2 default null
1508 ,p_pen_attribute15 in varchar2 default null
1509 ,p_pen_attribute16 in varchar2 default null
1510 ,p_pen_attribute17 in varchar2 default null
1511 ,p_pen_attribute18 in varchar2 default null
1512 ,p_pen_attribute19 in varchar2 default null
1513 ,p_pen_attribute20 in varchar2 default null
1514 ,p_pen_attribute21 in varchar2 default null
1515 ,p_pen_attribute22 in varchar2 default null
1516 ,p_pen_attribute23 in varchar2 default null
1517 ,p_pen_attribute24 in varchar2 default null
1518 ,p_pen_attribute25 in varchar2 default null
1519 ,p_pen_attribute26 in varchar2 default null
1520 ,p_pen_attribute27 in varchar2 default null
1521 ,p_pen_attribute28 in varchar2 default null
1522 ,p_pen_attribute29 in varchar2 default null
1523 ,p_pen_attribute30 in varchar2 default null
1524 ,p_request_id in number default null
1525 ,p_program_application_id in number default null
1526 ,p_program_id in number default null
1527 ,p_program_update_date in date default null
1528 ,p_object_version_number out nocopy number
1529 ,p_per_in_ler_id in number default null
1530 ,p_bnft_typ_cd in varchar2 default null
1531 ,p_bnft_ordr_num in number default null
1532 ,p_prtt_enrt_rslt_stat_cd in varchar2 default null
1533 ,p_bnft_nnmntry_uom in varchar2 default null
1534 ,p_comp_lvl_cd in varchar2 default null
1535 ,p_effective_date in date
1536 ,p_multi_row_validate in boolean default TRUE
1537 ,p_elig_per_elctbl_chc_id in number
1538 ,p_prtt_enrt_rslt_id_o in number
1539 ,p_suspend_flag out nocopy varchar2
1540 ,p_prtt_enrt_interim_id out nocopy number
1541 ,p_datetrack_mode in varchar2
1542 ,p_dpnt_actn_warning out nocopy boolean
1543 ,p_bnf_actn_warning out nocopy boolean
1544 ,p_ctfn_actn_warning out nocopy boolean
1545 ,p_enrt_bnft_id in number default NULL
1546 ,p_source in varchar2 default null
1547 ) is
1548 --
1549 -- Declare cursors and local variables
1550 --
1551 l_chg_evt_cd hr_lookups.lookup_code%type;
1552 l_prtt_enrt_rslt_id ben_prtt_enrt_rslt_f.prtt_enrt_rslt_id%TYPE;
1553 l_effective_start_date ben_prtt_enrt_rslt_f.effective_start_date%TYPE;
1554 l_effective_end_date ben_prtt_enrt_rslt_f.effective_end_date%TYPE;
1555 l_effective_date date;
1556 l_proc varchar2(72); -- := g_package||'create_enrollment';
1557 l_object_version_number ben_prtt_enrt_rslt_f.object_version_number%TYPE;
1558 l_return_to_exist_cvg_flag varchar2(30) := 'N';
1559 l_datetrack_mode varchar2(30);
1560 l_step integer;
1561 l_crntly_enrd_flag varchar2(30) := 'N';
1562 l_post_rslt_flag varchar2(30) := 'Y';
1563 l_prtt_prem_id number;
1564 l_exists varchar2(1);
1565 l_create varchar2(1) := 'N';
1566 l_update varchar2(1) := 'N';
1567 l_dummy varchar2(1);
1568 --
1569 /* Start of Changes for WWBUG: 1646442 : added declarations */
1570 l_ppe_datetrack_mode varchar2(30);
1571 l_ppe_dt_to_use date;
1572 lb_correction boolean;
1573 lb_update boolean;
1574 lb_update_override boolean;
1575 lb_update_change_insert boolean;
1576 l_enrt_cvg_strt_dt date;
1577 l_enrt_cvg_strt_dt_cd varchar2(30);
1578 l_enrt_cvg_strt_dt_rl number;
1579 l_rt_strt_dt date;
1580 l_rt_strt_dt_cd varchar2(30);
1581 l_rt_strt_dt_rl number;
1582 l_enrt_cvg_end_dt date;
1583 l_enrt_cvg_end_dt_cd varchar2(30);
1584 l_enrt_cvg_end_dt_rl number;
1585 l_rt_end_dt date;
1586 l_rt_end_dt_cd varchar2(30);
1587 l_rt_end_dt_rl number;
1588 /* End of Changes for WWBUG: 1646442 : added declarations */
1589 --
1590 l_global_epe_rec ben_global_enrt.g_global_epe_rec_type;
1591 l_global_pen_rec ben_prtt_enrt_rslt_f%rowtype;
1592 l_pl_rec ben_cobj_cache.g_pl_inst_row;
1593 l_pgm_rec ben_cobj_cache.g_pgm_inst_row;
1594 l_oipl_rec ben_cobj_cache.g_oipl_inst_row;
1595 --
1596 cursor c_ptip_enrollment_info is
1597 select pen.prtt_enrt_rslt_id,
1598 pen.pl_id,
1599 pen.oipl_id,
1600 pen.pl_typ_id
1601 from ben_prtt_enrt_rslt_f pen
1602 where pen.person_id=p_person_id and
1603 pen.business_group_id =p_business_group_id and
1604 pen.prtt_enrt_rslt_stat_cd is null and
1605 pen.sspndd_flag='N' and
1606 pen.prtt_enrt_rslt_id <> l_prtt_enrt_rslt_id and
1607 pen.effective_end_date = hr_api.g_eot and
1608 p_enrt_cvg_strt_dt-1 <=
1609 pen.enrt_cvg_thru_dt and
1610 pen.enrt_cvg_strt_dt < pen.effective_end_date and
1611 p_ptip_id=pen.ptip_id;
1612
1613 l_ptip_enrt c_ptip_enrollment_info%rowtype;
1614
1615 cursor c_pen (l_prtt_enrt_rslt_id number) is
1616 select prtt_enrt_rslt_id
1617 ,effective_start_date
1618 ,enrt_cvg_strt_dt
1619 ,enrt_cvg_thru_dt
1620 ,pgm_id
1621 ,ptip_id
1622 ,pl_typ_id
1623 ,pl_id
1624 ,oipl_id
1625 ,object_version_number
1626 from ben_prtt_enrt_rslt_f
1627 where prtt_enrt_rslt_id = l_prtt_enrt_rslt_id
1628 and p_effective_date between
1629 effective_start_date and effective_end_date;
1630 --
1631 l_pen_o c_pen%rowtype;
1632 --
1633 cursor c_prem is
1634 select ecr.val,
1635 ecr.uom,
1636 ecr.actl_prem_id,
1637 pil.lf_evt_ocrd_dt,
1638 pil.ler_id
1639 from ben_enrt_prem ecr,
1640 ben_per_in_ler pil,
1641 ben_elig_per_elctbl_chc epe
1642 where ecr.elig_per_elctbl_chc_id = p_elig_per_elctbl_chc_id
1643 and epe.elig_per_elctbl_chc_id = ecr.elig_per_elctbl_chc_id
1644 and pil.per_in_ler_id = epe.per_in_ler_id
1645 and pil.per_in_ler_stat_cd = 'STRTD'
1646 and NVL(ecr.enrt_bnft_id, -1) = NVL(p_enrt_bnft_id, -1); -- 3573173. Added this condition.
1647 -- and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT');
1648 --
1649 l_prem c_prem%rowtype;
1650 --
1651 -- Commented out the join to per-in-ler for performance. I belive that
1652 -- any result we are processing could not be attached to a backed out
1653 -- life event. lamc 4/5/00.
1654 --
1655 -- Bug#1646442: replaced following cursor:
1656 --
1657 /*********************** START OF CODE PRIOR TO WWBUG:1646442 ********
1658 cursor c_ppe (p_prtt_enrt_rslt_id in number,
1659 p_actl_prem_id in number) is
1660 select ppe.prtt_prem_id,
1661 ppe.std_prem_uom,
1662 ppe.std_prem_val,
1663 ppe.actl_prem_id,
1664 ppe.object_version_number
1665 from ben_prtt_prem_f ppe
1666 -- ben_per_in_ler pil
1667 where ppe.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
1668 and ppe.actl_prem_id = p_actl_prem_id
1669 and p_effective_date between
1670 ppe.effective_start_date and ppe.effective_end_date;
1671 -- and pil.per_in_ler_id=ppe.per_in_ler_id
1672 -- and pil.business_group_id=ppe.business_group_id
1673 -- and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT')
1674 ***************************END OF CODE PRIOR TO WWBUG:1646442 ************/
1675 /* Start of Changes for WWBUG: 1646442 */
1676 cursor c_ppe (p_prtt_enrt_rslt_id in number,
1677 p_actl_prem_id in number,
1678 p_ppe_dt_to_use in date) is
1679 select ppe.prtt_prem_id,
1680 ppe.std_prem_uom,
1681 ppe.std_prem_val,
1682 ppe.actl_prem_id,
1683 ppe.object_version_number
1684 from ben_prtt_prem_f ppe
1685 where ppe.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
1686 and ppe.actl_prem_id = p_actl_prem_id
1687 and /*p_effective_date*/ p_ppe_dt_to_use between
1688 ppe.effective_start_date and ppe.effective_end_date;
1689 /* End of Changes for WWBUG: 1646442 */
1690 --
1691 l_ppe c_ppe%rowtype;
1692 --
1693 cursor c_check_cvrd_in_plan is
1694 select null
1695 from ben_elig_cvrd_dpnt_f pdp
1696 ,ben_prtt_enrt_rslt_f pen
1697 ,ben_pgm_f pgm
1698 where pdp.dpnt_person_id = p_person_id
1699 and pdp.business_group_id = p_business_group_id
1700 and p_effective_date
1701 between pdp.effective_start_date and pdp.effective_end_date
1702 and pdp.prtt_enrt_rslt_id = pen.prtt_enrt_rslt_id
1703 --and pen.prtt_enrt_rslt_stat_cd not in ('BCKDT', 'VOIDD')
1704 and pen.prtt_enrt_rslt_stat_cd is null
1705 and pdp.cvg_thru_dt = hr_api.g_eot
1706 and pen.pgm_id = p_pgm_id
1707 and pen.pgm_id = pgm.pgm_id
1708 and pen.prtt_enrt_rslt_stat_cd is null
1709 and pgm.pgm_typ_cd like 'COBRA%'
1710 and p_effective_date between
1711 pen.effective_start_date and pen.effective_end_date
1712 and pen.pl_id = p_pl_id
1713 and pen.business_group_id = pdp.business_group_id
1714 and p_effective_date between
1715 pen.effective_start_date and pen.effective_end_date
1716 and pgm.business_group_id = pen.business_group_id
1717 and p_effective_date between
1718 pgm.effective_start_date and pgm.effective_end_date;
1719 --
1720 /* Start of Changes for Bug: 1646442: added cursor */
1721 cursor c_pel (p_elig_pe_elctbl_chc_id number) is
1722 select pel.enrt_perd_id,pel.lee_rsn_id
1723 from ben_pil_elctbl_chc_popl pel
1724 ,ben_elig_per_elctbl_chc epe
1725 where pel.pil_elctbl_chc_popl_id = epe.pil_elctbl_chc_popl_id
1726 and epe.elig_per_elctbl_chc_id = p_elig_pe_elctbl_chc_id;
1727 --
1728 -- Bug : 3866580
1729 cursor c_pl_typ_opt_typ_cd (pl_typ_id number, p_effective_date date) is
1730 select ptp.opt_typ_cd
1731 from ben_pl_typ_f ptp
1732 where ptp.pl_typ_id = p_pl_typ_id
1733 and p_effective_date between ptp.effective_start_date
1734 and ptp.effective_end_date;
1735
1736 l_pl_typ_opt_typ_cd ben_pl_typ.opt_typ_cd%type;
1737 -- Bug : 3866580
1738 --
1739 l_pel c_pel%rowtype;
1740 /* End of Changes for Bug: 1646442: added cursor */
1741 l_process_dpnt boolean := false;
1742 l_process_bnf boolean := false;
1743 --
1744 begin
1745 --
1746 g_debug := hr_utility.debug_enabled;
1747 if g_debug then
1748 l_proc := g_package||'create_enrollment';
1749 hr_utility.set_location('Entering:'|| l_proc, 10);
1750 end if;
1751 g_multi_rows_validate := p_multi_row_validate;
1752 l_step := 10;
1753 If (p_multi_row_validate) then
1754 l_post_rslt_flag := 'Y';
1755 Else
1756 l_post_rslt_flag := 'N';
1757 End if;
1758 --
1759 -- Ensure elctbl_chc_id is not NULL.
1760 --
1761 hr_api.mandatory_arg_error
1762 (p_api_name => l_proc
1763 ,p_argument => 'elig_per_elctbl_chc_id'
1764 ,p_argument_value => p_elig_per_elctbl_chc_id
1765 );
1766 --
1767 -- Issue a savepoint if operating in validation only mode
1768 --
1769 if p_called_from_sspnd = 'N' then
1770 savepoint create_enrollment;
1771 else
1772 savepoint create_enrollment_sspnd;
1773 end if;
1774 --
1775 l_step := 15;
1776 --
1777 l_crntly_enrd_flag := 'N';
1778 if g_debug then
1779 hr_utility.set_location(l_proc, 20);
1780 end if;
1781 l_step := 20;
1782 --
1783 -- Get choice data from prtt_per_elctbl_chc table
1784 --
1785 ben_global_enrt.get_epe -- choice
1786 (p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id
1787 ,p_global_epe_rec => l_global_epe_rec);
1788
1789 ben_cobj_cache.get_pl_dets
1790 (p_business_group_id => p_business_group_id
1791 ,p_effective_date => p_effective_date
1792 ,p_pl_id => l_global_epe_rec.pl_id
1793 ,p_inst_row => l_pl_rec);
1794
1795 if l_global_epe_rec.oipl_id is not null then
1796 ben_cobj_cache.get_oipl_dets
1797 (p_business_group_id => p_business_group_id
1798 ,p_effective_date => p_effective_date
1799 ,p_oipl_id => l_global_epe_rec.oipl_id
1800 ,p_inst_row => l_oipl_rec);
1801 end if;
1802
1803 l_step:=25;
1804 --
1805 -- Check if person is also a covered dependent in the plan.
1806 -- This is a COBRA edit. For example,if the person is covered under
1807 -- employee + family, he/she cannot separate coverage.
1808 --
1809 if p_pgm_id is not null then
1810 open c_check_cvrd_in_plan;
1811 fetch c_check_cvrd_in_plan into l_exists;
1812 if c_check_cvrd_in_plan%found then
1813 close c_check_cvrd_in_plan;
1814 fnd_message.set_name('BEN','BEN_92243_CVRD_IN_PLAN');
1815 fnd_message.raise_error;
1816 end if;
1817 close c_check_cvrd_in_plan;
1818 end if;
1819 --
1820 l_step := 30;
1821 --
1822 if (l_global_epe_rec.prtt_enrt_rslt_id is not NULL) then
1823 ben_global_enrt.get_pen -- result
1824 (p_prtt_enrt_rslt_id => l_global_epe_rec.prtt_enrt_rslt_id
1825 ,p_effective_date => p_effective_date
1826 ,p_global_pen_rec => l_global_pen_rec);
1827 else
1828 ben_global_enrt.clear_pen -- result
1829 (p_global_pen_rec => l_global_pen_rec);
1830 end if;
1831 l_step := 40;
1832 --
1833 -- commented out to allow for creation of a new result
1834 -- when the benefit amount changes (in benelinf). It looks
1835 -- like benelinf is the only process which calls create_enrt
1836 -- so... would like it to only do a create and copy the child
1837 -- stuff over if a p_prtt_enrt_rslt_id is passed in.
1838 -- jcarpent 7/28/1999
1839 -- lamc removed commented code 4/5/00
1840 l_step := 80;
1841 if (p_prtt_enrt_rslt_id_o is not NULL) then
1842 open c_pen(p_prtt_enrt_rslt_id_o);
1843 fetch c_pen into l_pen_o;
1844 if c_pen%notfound then
1845 l_step := 90;
1846 close c_pen;
1847 rpt_error(p_proc => l_proc, p_step => l_step);
1848 fnd_message.set_name('BEN','BEN_91711_ENRT_RSLT_NOT_FND');
1849 fnd_message.set_token('PROC',l_proc);
1850 fnd_message.set_token('ID', to_char(p_prtt_enrt_rslt_id_o));
1851 fnd_message.set_token('PERSON_ID', to_char(p_person_id));
1852 fnd_message.set_token('LER_ID', to_char(p_ler_id));
1853 fnd_message.set_token('EFFECTIVE_DATE',to_char(p_effective_date));
1854 fnd_message.raise_error;
1855 else
1856 close c_pen;
1857 if (p_datetrack_mode = hr_api.g_correction) then
1858 l_effective_date := l_pen_o.effective_start_date;
1859 else
1860 l_effective_date := p_effective_date;
1861 end if;
1862 end if;
1863 else
1864 l_pen_o := NULL;
1865 l_effective_date := p_effective_date;
1866 end if;
1867 l_step := 100;
1868 create_PRTT_ENRT_RESULT
1869 (p_validate => FALSE
1870 ,p_prtt_enrt_rslt_id => l_prtt_enrt_rslt_id
1871 ,p_effective_start_date => l_effective_start_date
1872 ,p_effective_end_date => l_effective_end_date
1873 ,p_business_group_id => p_business_group_id
1874 ,p_oipl_id => p_oipl_id
1875 ,p_person_id => p_person_id
1876 ,p_assignment_id => p_assignment_id
1877 ,p_pgm_id => p_pgm_id
1878 ,p_pl_id => p_pl_id
1879 ,p_rplcs_sspndd_rslt_id => p_rplcs_sspndd_rslt_id
1880 ,p_ptip_id => p_ptip_id
1881 ,p_pl_typ_id => p_pl_typ_id
1882 ,p_ler_id => p_ler_id
1883 ,p_sspndd_flag => p_sspndd_flag
1884 ,p_prtt_is_cvrd_flag => p_prtt_is_cvrd_flag
1885 ,p_bnft_amt => p_bnft_amt
1886 ,p_uom => p_uom
1887 ,p_orgnl_enrt_dt => p_orgnl_enrt_dt
1888 ,p_enrt_mthd_cd => p_enrt_mthd_cd
1889 ,p_enrt_ovridn_flag => p_enrt_ovridn_flag
1890 ,p_enrt_ovrid_rsn_cd => p_enrt_ovrid_rsn_cd
1891 ,p_erlst_deenrt_dt => p_erlst_deenrt_dt
1892 ,p_enrt_cvg_strt_dt => p_enrt_cvg_strt_dt
1893 ,p_enrt_cvg_thru_dt => p_enrt_cvg_thru_dt
1894 ,p_enrt_ovrid_thru_dt => p_enrt_ovrid_thru_dt
1895 ,p_pl_ordr_num => p_pl_ordr_num
1896 ,p_plip_ordr_num => p_plip_ordr_num
1897 ,p_ptip_ordr_num => p_ptip_ordr_num
1898 ,p_oipl_ordr_num => p_oipl_ordr_num
1899 ,p_pen_attribute_category => p_pen_attribute_category
1900 ,p_pen_attribute1 => p_pen_attribute1
1901 ,p_pen_attribute2 => p_pen_attribute2
1902 ,p_pen_attribute3 => p_pen_attribute3
1903 ,p_pen_attribute4 => p_pen_attribute4
1904 ,p_pen_attribute5 => p_pen_attribute5
1905 ,p_pen_attribute6 => p_pen_attribute6
1906 ,p_pen_attribute7 => p_pen_attribute7
1907 ,p_pen_attribute8 => p_pen_attribute8
1908 ,p_pen_attribute9 => p_pen_attribute9
1909 ,p_pen_attribute10 => p_pen_attribute10
1910 ,p_pen_attribute11 => p_pen_attribute11
1911 ,p_pen_attribute12 => p_pen_attribute12
1912 ,p_pen_attribute13 => p_pen_attribute13
1913 ,p_pen_attribute14 => p_pen_attribute14
1914 ,p_pen_attribute15 => p_pen_attribute15
1915 ,p_pen_attribute16 => p_pen_attribute16
1916 ,p_pen_attribute17 => p_pen_attribute17
1917 ,p_pen_attribute18 => p_pen_attribute18
1918 ,p_pen_attribute19 => p_pen_attribute19
1919 ,p_pen_attribute20 => p_pen_attribute20
1920 ,p_pen_attribute21 => p_pen_attribute21
1921 ,p_pen_attribute22 => p_pen_attribute22
1922 ,p_pen_attribute23 => p_pen_attribute23
1923 ,p_pen_attribute24 => p_pen_attribute24
1924 ,p_pen_attribute25 => p_pen_attribute25
1925 ,p_pen_attribute26 => p_pen_attribute26
1926 ,p_pen_attribute27 => p_pen_attribute27
1927 ,p_pen_attribute28 => p_pen_attribute28
1928 ,p_pen_attribute29 => p_pen_attribute29
1929 ,p_pen_attribute30 => p_pen_attribute30
1930 ,p_request_id => fnd_global.conc_request_id
1931 ,p_program_application_id => fnd_global.prog_appl_id
1932 ,p_program_id => fnd_global.conc_program_id
1933 ,p_program_update_date => sysdate
1934 ,p_object_version_number => l_object_version_number
1935 ,p_per_in_ler_id => p_per_in_ler_id
1936 ,p_bnft_typ_cd => p_bnft_typ_cd
1937 ,p_bnft_ordr_num => p_bnft_ordr_num
1938 ,p_prtt_enrt_rslt_stat_cd => p_prtt_enrt_rslt_stat_cd
1939 ,p_bnft_nnmntry_uom => p_bnft_nnmntry_uom
1940 ,p_comp_lvl_cd => p_comp_lvl_cd
1941 ,p_effective_date => l_effective_date
1942 ,p_multi_row_validate => p_multi_row_validate
1943 );
1944
1945 l_create := 'Y';
1946
1947 /*Added for Bug 7561395*/
1948 g_enrt_list.extend;
1949 g_enrt_list(g_enrt_list.last) := l_prtt_enrt_rslt_id;
1950 hr_utility.set_location(' Extend table ',500);
1951 hr_utility.set_location('New pen_id '|| g_new_prtt_enrt_rslt_id,500);
1952 hr_utility.set_location('Intmr Rslt Id '|| p_rplcs_sspndd_rslt_id,500);
1953 hr_utility.set_location('oipl id cr '|| p_oipl_id,500);
1954 /*Ended for Bug 7561395*/
1955
1956 ben_global_enrt.reload_pen -- result globals loaded after insert.
1957 (p_prtt_enrt_rslt_id => l_prtt_enrt_rslt_id
1958 ,p_effective_date => p_effective_date
1959 ,p_global_pen_rec => l_global_pen_rec);
1960
1961 --
1962 l_step := 105;
1963 -- if the result will be voided in the rhi or the rslt is being
1964 -- inserted as 'backed out', do not update choice fk.
1965 -- This call needs to be before the update to premiums because it
1966 -- assumes the chc was already updated with the rslt id.
1967 if p_enrt_cvg_strt_dt > nvl(p_enrt_cvg_thru_dt,p_enrt_cvg_strt_dt)
1968 or p_prtt_enrt_rslt_stat_cd = 'BCKDT' then
1969 null;
1970 else
1971 l_step := 110;
1972 ben_ELIG_PER_ELC_CHC_api.update_ELIG_PER_ELC_CHC
1973 (p_validate => FALSE
1974 ,p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id
1975 ,p_prtt_enrt_rslt_id => l_prtt_enrt_rslt_id
1976 ,p_object_version_number =>
1977 l_global_epe_rec.object_version_number
1978 ,p_effective_date => p_effective_date
1979 ,p_request_id => fnd_global.conc_request_id
1980 ,p_program_application_id => fnd_global.prog_appl_id
1981 ,p_program_id => fnd_global.conc_program_id
1982 ,p_program_update_date => sysdate
1983 );
1984
1985 ben_global_enrt.reload_epe -- chc globals re-loaded after update.
1986 (p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id
1987 ,p_global_epe_rec => l_global_epe_rec);
1988
1989 end if;
1990
1991 l_step := 115;
1992
1993 if (l_update = 'Y' or l_create = 'Y') then
1994 --
1995 for l_prem in c_prem loop
1996 --
1997 l_step := 120;
1998 -- bug 1587837. jcarpent reset l_ppe.prtt_prem_id
1999 l_ppe.prtt_prem_id:=null;
2000 --
2001 /* Start of Changes for WWBUG: 1646442: added */
2002 open c_pel(p_elig_per_elctbl_chc_id);
2003 fetch c_pel into l_pel;
2004 close c_pel;
2005
2006 ben_determine_date.rate_and_coverage_dates
2007 (p_which_dates_cd => 'R'
2008 ,p_date_mandatory_flag => 'Y'
2009 ,p_compute_dates_flag => 'Y'
2010 ,p_business_group_id => p_business_group_id
2011 ,P_PER_IN_LER_ID => p_per_in_ler_id
2012 ,P_PERSON_ID => p_person_id
2013 ,P_PGM_ID => p_pgm_id
2014 ,P_PL_ID => p_pl_id
2015 ,P_OIPL_ID => p_oipl_id
2016 ,P_LEE_RSN_ID => l_pel.lee_rsn_id
2017 ,P_ENRT_PERD_ID => l_pel.enrt_perd_id
2018 ,p_enrt_cvg_strt_dt => l_enrt_cvg_strt_dt --out
2019 ,p_enrt_cvg_strt_dt_cd => l_enrt_cvg_strt_dt_cd --out
2020 ,p_enrt_cvg_strt_dt_rl => l_enrt_cvg_strt_dt_rl --out
2021 ,p_rt_strt_dt => l_rt_strt_dt --out
2022 ,p_rt_strt_dt_cd => l_rt_strt_dt_cd --out
2023 ,p_rt_strt_dt_rl => l_rt_strt_dt_rl --out
2024 ,p_enrt_cvg_end_dt => l_enrt_cvg_end_dt --out
2025 ,p_enrt_cvg_end_dt_cd => l_enrt_cvg_end_dt_cd --out
2026 ,p_enrt_cvg_end_dt_rl => l_enrt_cvg_end_dt_rl --out
2027 ,p_rt_end_dt => l_rt_end_dt --out
2028 ,p_rt_end_dt_cd => l_rt_end_dt_cd --out
2029 ,p_rt_end_dt_rl => l_rt_end_dt_rl --out
2030 ,p_effective_date => p_effective_date
2031 ,p_lf_evt_ocrd_dt => nvl(l_prem.lf_evt_ocrd_dt,p_effective_date)
2032 );
2033
2034 l_ppe_dt_to_use := greatest(p_enrt_cvg_strt_dt,l_rt_strt_dt);
2035 hr_utility.set_location( 'cvg start dt ' || p_enrt_cvg_strt_dt, 99 ) ;
2036 hr_utility.set_location( 'l_ppe_dt_to_use ' || l_ppe_dt_to_use, 99 ) ;
2037
2038 /* End of Changes for WWBUG: 1646442: addition */
2039 --
2040 /*
2041 CODE PRIOR TO WWBUG: 1646442
2042 open c_ppe(l_prtt_enrt_rslt_id, l_prem.actl_prem_id);
2043 */
2044 /* Start of Changes for WWBUG: 1646442 */
2045 open c_ppe(l_prtt_enrt_rslt_id, l_prem.actl_prem_id,l_ppe_dt_to_use);
2046 /* End of Changes for WWBUG: 1646442 */
2047 fetch c_ppe into l_ppe;
2048 close c_ppe;
2049 --
2050 l_step := 125;
2051 if l_ppe.prtt_prem_id is not null and l_update = 'Y' then
2052 -- Because the benefit amount could have changed, and the premiums
2053 -- can be based on the benefit amount, re-calc it. It does a recalc
2054 -- if the benefit amount is entered at enrollment.
2055 -- PPE is from prtt-prem. prem is from enrt-prem.
2056 ben_PRTT_PREM_api.recalc_PRTT_PREM
2057 (p_prtt_prem_id => l_ppe.prtt_prem_id
2058 ,p_std_prem_uom => l_prem.uom
2059 ,p_std_prem_val => l_prem.val -- in/out
2060 ,p_actl_prem_id => l_prem.actl_prem_id
2061 ,p_prtt_enrt_rslt_id => l_prtt_enrt_rslt_id
2062 ,p_per_in_ler_id => p_per_in_ler_id
2063 ,p_ler_id => l_prem.ler_id
2064 ,p_lf_evt_ocrd_dt => l_prem.lf_evt_ocrd_dt
2065 ,p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id
2066 ,p_enrt_bnft_id => p_enrt_bnft_id
2067 ,p_business_group_id => p_business_group_id
2068 ,p_effective_date => p_effective_date
2069 -- bof FONM
2070 ,p_enrt_cvg_strt_dt => nvl(l_enrt_cvg_strt_dt ,l_ppe_dt_to_use)
2071 ,p_rt_strt_dt => l_rt_strt_dt
2072 -- eof FONM
2073 );
2074 l_step := 127;
2075 --
2076 /* Start of Changes for WWBUG: 1646442: added */
2077 --
2078 -- Find the valid datetrack modes.
2079 --
2080 dt_api.find_dt_upd_modes
2081 (p_effective_date => l_ppe_dt_to_use,
2082 p_base_table_name => 'BEN_PRTT_PREM_F',
2083 p_base_key_column => 'prtt_prem_id',
2084 p_base_key_value => l_ppe.prtt_prem_id,
2085 p_correction => lb_correction,
2086 p_update => lb_update,
2087 p_update_override => lb_update_override,
2088 p_update_change_insert => lb_update_change_insert);
2089
2090 if lb_update_override then
2091 --
2092 l_ppe_datetrack_mode := hr_api.g_update_override;
2093 --
2094 elsif lb_update then
2095 --
2096 l_ppe_datetrack_mode := hr_api.g_update;
2097 --
2098 else
2099 --
2100 l_ppe_datetrack_mode := hr_api.g_correction;
2101 end if;
2102 /* End of Changes for WWBUG: 1646442 */
2103
2104 ben_prtt_prem_api.update_prtt_prem
2105 ( p_validate => FALSE
2106 ,p_prtt_prem_id => l_ppe.prtt_prem_id
2107 ,p_effective_start_date => p_effective_start_date
2108 ,p_effective_end_date => p_effective_end_date
2109 ,p_std_prem_uom => l_prem.uom
2110 ,p_std_prem_val => l_prem.val
2111 ,p_actl_prem_id => l_prem.actl_prem_id
2112 ,p_prtt_enrt_rslt_id => l_prtt_enrt_rslt_id
2113 ,p_per_in_ler_id => p_per_in_ler_id
2114 ,p_business_group_id => p_business_group_id
2115 ,p_object_version_number => l_ppe.object_version_number
2116 ,p_request_id => fnd_global.conc_request_id
2117 ,p_program_application_id => fnd_global.prog_appl_id
2118 ,p_program_id => fnd_global.conc_program_id
2119 ,p_program_update_date => sysdate
2120 /* CODE PRIOR TO WWBUG: 1646442
2121 ,p_effective_date => p_effective_date
2122 ,p_datetrack_mode => l_datetrack_mode
2123 */
2124 /* Start of Changes for WWBUG: 1646442 */
2125 ,p_effective_date => l_ppe_dt_to_use
2126 ,p_datetrack_mode => l_ppe_datetrack_mode
2127 /* End of Changes for WWBUG: 1646442 */
2128 );
2129 --
2130 elsif l_create = 'Y' or l_ppe.prtt_prem_id is null then
2131 -- Because the benefit amount could have changed, and the premiums
2132 -- can be based on the benefit amount, re-calc it. It does a recalc
2133 -- if the benefit amount is entered at enrollment.
2134 -- PPE is from prtt-prem. prem is from enrt-prem.
2135 ben_PRTT_PREM_api.recalc_PRTT_PREM
2136 (p_prtt_prem_id => null
2137 ,p_std_prem_uom => l_prem.uom
2138 ,p_std_prem_val => l_prem.val -- in/out
2139 ,p_actl_prem_id => l_prem.actl_prem_id
2140 ,p_prtt_enrt_rslt_id => l_prtt_enrt_rslt_id
2141 ,p_per_in_ler_id => p_per_in_ler_id
2142 ,p_ler_id => l_prem.ler_id
2143 ,p_lf_evt_ocrd_dt => l_prem.lf_evt_ocrd_dt
2144 ,p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id
2145 ,p_enrt_bnft_id => p_enrt_bnft_id
2146 ,p_business_group_id => p_business_group_id
2147 ,p_effective_date => p_effective_date
2148 -- bof FONM
2149 ,p_enrt_cvg_strt_dt => nvl(l_enrt_cvg_strt_dt,l_ppe_dt_to_use)
2150 ,p_rt_strt_dt => l_rt_strt_dt
2151 -- eof FONM
2152 );
2153 l_step := 130;
2154 ben_prtt_prem_api.create_prtt_prem
2155 ( p_validate => FALSE
2156 ,p_prtt_prem_id => l_prtt_prem_id
2157 ,p_effective_start_date => p_effective_start_date
2158 ,p_effective_end_date => p_effective_end_date
2159 ,p_std_prem_uom => l_prem.uom
2160 ,p_std_prem_val => l_prem.val
2161 ,p_actl_prem_id => l_prem.actl_prem_id
2162 ,p_prtt_enrt_rslt_id => l_prtt_enrt_rslt_id
2163 ,p_per_in_ler_id => p_per_in_ler_id
2164 ,p_business_group_id => p_business_group_id
2165 ,p_object_version_number => l_object_version_number
2166 ,p_request_id => fnd_global.conc_request_id
2167 ,p_program_application_id => fnd_global.prog_appl_id
2168 ,p_program_id => fnd_global.conc_program_id
2169 ,p_program_update_date => sysdate
2170 /*
2171 CODE PRIOR TO WWBUG: 1646442
2172 ,p_effective_date => p_effective_date
2173 */
2174 /* Start of Changes for WWBUG: 1646442 */
2175 ,p_effective_date => l_ppe_dt_to_use
2176 /* End of Changes for WWBUG: 1646442 */
2177 );
2178 --
2179 end if;
2180 --
2181 end loop;
2182 --
2183 end if;
2184 --
2185 l_step := 135;
2186 if p_comp_lvl_cd in ('PLANFC', 'PLANIMP') then
2187 null;
2188 else
2189 if l_global_epe_rec.pgm_id is not null then
2190 ben_provider_pools.accumulate_pools
2191 (p_validate => FALSE
2192 ,p_person_id => p_person_id
2193 ,p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id
2194 ,p_business_group_id => p_business_group_id
2195 ,p_enrt_mthd_cd => p_enrt_mthd_cd
2196 ,p_effective_date => p_effective_date);
2197 end if;
2198 end if;
2199 l_step := 140;
2200 if (l_global_epe_rec.prtt_enrt_rslt_id is not NULL
2201 and l_crntly_enrd_flag = 'Y') then
2202 l_return_to_exist_cvg_flag := 'Y';
2203 else
2204 l_return_to_exist_cvg_flag := 'N';
2205 end if;
2206 --
2207 -- write to change log, except for when called by benelinf where
2208 -- the change log is written directly from there.
2209 --
2210 l_step := 145;
2211 if p_source is null or
2212 p_source <> 'benelinf' then
2213 ben_ext_chlg.log_benefit_chg
2214 (p_action => 'CREATE'
2215 ,p_pl_id => p_pl_id
2216 ,p_oipl_id => p_oipl_id
2217 ,p_enrt_cvg_strt_dt => p_enrt_cvg_strt_dt
2218 ,p_enrt_cvg_end_dt => p_enrt_cvg_thru_dt
2219 ,p_prtt_enrt_rslt_id => l_prtt_enrt_rslt_id
2220 ,p_per_in_ler_id => p_per_in_ler_id
2221 ,p_person_id => p_person_id
2222 ,p_business_group_id => p_business_group_id
2223 ,p_effective_date => l_effective_date
2224 );
2225 end if;
2226 --
2227 --
2228 -- If there was enrollment terminated before this new choice elected,
2229 -- then the dependents for old enrollment can be re-used, or user select
2230 -- the currently coveraged enrollment as his/her election, then use old
2231 -- dependent information as well.
2232 --
2233 l_step := 150;
2234 if g_debug then
2235 hr_utility.set_location('p_prtt_enrt_rslt_id_o'||
2236 to_char(p_prtt_enrt_rslt_id_o)||' l_epe.prtt_enrt_rslt_id'||
2237 to_char(l_global_epe_rec.prtt_enrt_rslt_id),150);
2238 hr_utility.set_location(
2239 ' flag'||l_global_epe_rec.crntly_enrd_flag, 150);
2240 end if;
2241
2242 if (p_prtt_enrt_rslt_id_o is not NULL
2243 or (l_global_epe_rec.prtt_enrt_rslt_id is not NULL
2244 and nvl(l_global_epe_rec.crntly_enrd_flag, 'X') = 'Y') ) then
2245 l_step := 155;
2246 if l_global_epe_rec.alws_dpnt_dsgn_flag = 'Y' then
2247 l_process_dpnt := true;
2248 else
2249 l_process_dpnt := false;
2250 if l_global_epe_rec.pgm_id is not null then
2251 ben_cobj_cache.get_pgm_dets
2252 (p_business_group_id => p_business_group_id
2253 ,p_effective_date => p_effective_date
2254 ,p_pgm_id => l_global_epe_rec.pgm_id
2255 ,p_inst_row => l_pgm_rec);
2256 hr_utility.set_location('process dptn level ' ||l_pgm_rec.dpnt_dsgn_lvl_cd , 150);
2257 if l_pgm_rec.dpnt_dsgn_lvl_cd='PTIP' then
2258 open c_ptip_enrollment_info;
2259 fetch c_ptip_enrollment_info into l_ptip_enrt;
2260 if c_ptip_enrollment_info%found then
2261 l_process_dpnt:= true;
2262 hr_utility.set_location('process dptn true ', 150);
2263 end if ;
2264 end if ;
2265 end if ;
2266 end if;
2267 if l_pl_rec.bnf_dsgn_cd is not null then
2268 l_process_bnf := true;
2269 else
2270 l_process_bnf := false;
2271 end if;
2272 ben_mng_dpnt_bnf.recycle_dpnt_bnf
2273 (p_validate => FALSE
2274 ,p_new_prtt_enrt_rslt_id => l_prtt_enrt_rslt_id
2275 ,p_old_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id_o
2276 ,P_NEW_ENRT_RSLT_OVN => l_object_version_number
2277 ,p_new_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id
2278 ,p_person_id => p_person_id
2279 ,p_return_to_exist_cvg_flag => l_return_to_exist_cvg_flag
2280 ,p_old_pl_id => l_pen_o.pl_id
2281 ,p_new_pl_id => p_pl_id
2282 ,p_old_oipl_id => l_pen_o.oipl_id
2283 ,p_new_oipl_id => p_oipl_id
2284 ,p_old_pl_typ_id => l_pen_o.pl_typ_id
2285 ,p_new_pl_typ_id => p_pl_typ_id
2286 ,p_pgm_id => p_pgm_id
2287 ,p_ler_id => p_ler_id
2288 ,p_per_in_ler_id => p_per_in_ler_id
2289 ,p_dpnt_cvg_strt_dt_cd => l_global_epe_rec.dpnt_cvg_strt_dt_cd
2290 ,p_dpnt_cvg_strt_dt_rl => l_global_epe_rec.dpnt_cvg_strt_dt_rl
2291 ,p_business_group_id => p_business_group_id
2292 ,p_ENRT_CVG_STRT_DT => l_global_pen_rec.enrt_cvg_strt_dt
2293 ,p_effective_date => p_effective_date
2294 ,p_datetrack_mode => p_datetrack_mode
2295 ,p_process_dpnt => l_process_dpnt
2296 ,p_process_bnf => l_process_bnf
2297 );
2298 --
2299 -- Copy primary care provider if the plan has not changed but the
2300 -- option in plan has changed.
2301 --
2302 l_step := 160;
2303 If (l_pen_o.pl_id = p_pl_id and l_pen_o.oipl_id <> p_oipl_id) then
2304 ben_mng_prmry_care_prvdr.recycle_ppr
2305 (P_VALIDATE => FALSE
2306 ,P_NEW_PRTT_ENRT_RSLT_ID => l_prtt_enrt_rslt_id
2307 ,P_OLD_PRTT_ENRT_RSLT_ID => p_prtt_enrt_rslt_id_o
2308 ,P_BUSINESS_GROUP_ID => P_business_group_id
2309 ,P_EFFECTIVE_DATE => p_effective_date
2310 ,P_DATETRACK_MODE => p_datetrack_mode
2311 );
2312 End if;
2313 elsif p_pgm_id is not null
2314 /*and l_global_epe_rec.alws_dpnt_dsgn_flag = 'Y'
2315 if previously enrolled then carry forward even if the flaf is 'N' */
2316 then
2317 --
2318 -- no old result passed in or not reenrolling in same choice
2319 -- different coverage, sooo..
2320 -- handle dependent recycling at ptip level if used to be
2321 -- enrolled in plan type but coverage ended due to eligibility.
2322 --
2323 ben_cobj_cache.get_pgm_dets
2324 (p_business_group_id => p_business_group_id
2325 ,p_effective_date => p_effective_date
2326 ,p_pgm_id => l_global_epe_rec.pgm_id
2327 ,p_inst_row => l_pgm_rec);
2328 if l_pgm_rec.dpnt_dsgn_lvl_cd='PTIP' then
2329 open c_ptip_enrollment_info;
2330 fetch c_ptip_enrollment_info into l_ptip_enrt;
2331 if c_ptip_enrollment_info%found then
2332 ben_mng_dpnt_bnf.recycle_dpnt_bnf
2333 (p_validate => FALSE
2334 ,p_new_prtt_enrt_rslt_id => l_prtt_enrt_rslt_id
2335 ,p_old_prtt_enrt_rslt_id => l_ptip_enrt.prtt_enrt_rslt_id
2336 ,P_NEW_ENRT_RSLT_OVN => l_object_version_number
2337 ,p_new_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id
2338 ,p_person_id => p_person_id
2339 ,p_return_to_exist_cvg_flag => l_return_to_exist_cvg_flag
2340 ,p_old_pl_id => l_ptip_enrt.pl_id
2341 ,p_new_pl_id => p_pl_id
2342 ,p_old_oipl_id => l_ptip_enrt.oipl_id
2343 ,p_new_oipl_id => p_oipl_id
2344 ,p_old_pl_typ_id => l_ptip_enrt.pl_typ_id
2345 ,p_new_pl_typ_id => p_pl_typ_id
2346 ,p_pgm_id => p_pgm_id
2347 ,p_ler_id => p_ler_id
2348 ,p_per_in_ler_id => p_per_in_ler_id
2349 ,p_dpnt_cvg_strt_dt_cd => l_global_epe_rec.dpnt_cvg_strt_dt_cd
2350 ,p_dpnt_cvg_strt_dt_rl => l_global_epe_rec.dpnt_cvg_strt_dt_rl
2351 ,p_business_group_id => p_business_group_id
2352 ,p_ENRT_CVG_STRT_DT => l_global_pen_rec.enrt_cvg_strt_dt
2353 ,p_effective_date => p_effective_date
2354 ,p_datetrack_mode => p_datetrack_mode
2355 ,p_process_dpnt => true
2356 ,p_process_bnf => false
2357 );
2358 close c_ptip_enrollment_info;
2359 end if;
2360 end if;
2361 end if;
2362 --
2363 -- If new choice is not currently coverage, call action_item RCO to
2364 -- determine any action need to be taken.
2365 --
2366 -- Bug 3866580
2367 --
2368 -- Find out the Option Type of Plan Type of the Plan being enrolled in
2369 /* It is better to go by savings plan flag rather option type code as
2370 the type code is only informational
2371 open c_pl_typ_opt_typ_cd (l_pl_rec.pl_typ_id, p_effective_date);
2372 fetch c_pl_typ_opt_typ_cd into l_pl_typ_opt_typ_cd;
2373 close c_pl_typ_opt_typ_cd;
2374 --
2375 */
2376 if ( l_pl_rec.svgs_pl_flag = 'Y' and p_oipl_id is null and l_pl_rec.ENRT_PL_OPT_FLAG = 'Y' )
2377 or ( l_pl_rec.svgs_pl_flag = 'N')
2378 then
2379 /*
2380 Commented this part as, Enrollment Action Items for all enrollment in "Plans"
2381 as well as "Option In Plans" should be determined except for savings plan. In case
2382 of savings plan, enrollment actions items should be determined only if enrollment is in
2383 plan level (i.e. p_oipl_id = NULL
2384 --
2385 If l_pl_rec.ENRT_PL_OPT_FLAG = 'N'
2386 or (l_pl_rec.ENRT_PL_OPT_FLAG = 'Y'
2387 and p_oipl_id is NULL) then
2388 */
2389 --
2390 l_step := 165;
2391 ben_enrollment_action_items.determine_action_items
2392 (p_prtt_enrt_rslt_id => l_prtt_enrt_rslt_id
2393 ,p_effective_date => p_effective_date
2394 ,p_business_group_id => p_business_group_id
2395 ,p_datetrack_mode => p_datetrack_mode
2396 ,p_suspend_flag => p_suspend_flag
2397 ,p_rslt_object_version_number => l_object_version_number
2398 ,p_enrt_bnft_id => p_enrt_bnft_id
2399 ,p_post_rslt_flag => l_post_rslt_flag
2400 ,p_dpnt_actn_warning => p_dpnt_actn_warning
2401 ,p_bnf_actn_warning => p_bnf_actn_warning
2402 ,p_ctfn_actn_warning => p_ctfn_actn_warning
2403 );
2404 if (l_global_epe_rec.prtt_enrt_rslt_id is not NULL) then
2405 ben_global_enrt.get_pen -- result
2406 (p_prtt_enrt_rslt_id => l_global_epe_rec.prtt_enrt_rslt_id
2407 ,p_effective_date => p_effective_date
2408 ,p_global_pen_rec => l_global_pen_rec);
2409 else
2410 ben_global_enrt.clear_pen -- result
2411 (p_global_pen_rec => l_global_pen_rec);
2412 end if;
2413 --
2414 l_step := 167;
2415 -- if action item's calls update-enrollment, the globals will be
2416 -- reloaded for us.
2417 p_prtt_enrt_interim_id :=
2418 ben_global_enrt.g_global_pen_rec.rplcs_sspndd_rslt_id;
2419 end if;
2420 --
2421 -- When in validation only mode raise the Validate_Enabled exception
2422 --
2423 if p_validate then
2424 raise hr_api.validate_enabled;
2425 end if;
2426 --
2427 -- Set all output arguments
2428 --
2429 p_prtt_enrt_rslt_id := l_prtt_enrt_rslt_id;
2430 p_effective_start_date := l_effective_start_date;
2431 p_effective_end_date := l_effective_end_date;
2432 p_object_version_number := l_object_version_number;
2433
2434 /* Added for Bug 7561395*/
2435 if(g_enrt_list.count > 1) then
2436 g_enrt_list.trim(1);
2437 hr_utility.set_location(' count gt 1 ',5522);
2438 else
2439 if(g_enrt_list.count = 1) then
2440 hr_utility.set_location(' count is 1 ',5522);
2441 g_new_prtt_enrt_rslt_id := g_enrt_list(g_enrt_list.last);
2442 g_enrt_list.trim(1);
2443 hr_utility.set_location(' g_new_prtt_enrt_rslt_id '||g_new_prtt_enrt_rslt_id ,5522);
2444 end if;
2445 end if;
2446 /* Ended for Bug 7561395*/
2447
2448 if g_debug then
2449 hr_utility.set_location(' Leaving:'||l_proc, 999);
2450 end if;
2451 exception
2452 when hr_api.validate_enabled then
2453 -- As the Validate_Enabled exception has been raised
2454 -- we must rollback to the savepoint
2455 --
2456
2457 /* Added for Bug 7561395*/
2458 if(g_enrt_list.count > 1 ) then
2459 g_enrt_list.trim(g_enrt_list.count);
2460 end if;
2461 /* Ended for Bug 7561395*/
2462
2463 if p_called_from_sspnd = 'N' then
2464 ROLLBACK TO create_enrollment;
2465 else
2466 ROLLBACK TO create_enrollment_sspnd;
2467 end if;
2468
2469 --
2470 -- Only set output warning arguments
2471 -- (Any key or derived arguments must be set to null
2472 -- when validation only mode is being used.)
2473 --
2474 p_prtt_enrt_rslt_id := null;
2475 p_effective_start_date := null;
2476 p_effective_end_date := null;
2477 p_object_version_number := null;
2478 if g_debug then
2479 hr_utility.set_location(' Leaving:'||l_proc, 80);
2480 end if;
2481 when others then
2482 --
2483 -- A validation or unexpected error has occured
2484 --
2485 /* Added for Bug 7561395*/
2486 if(g_enrt_list.count > 1 ) then
2487 g_enrt_list.trim(g_enrt_list.count);
2488 end if;
2489 /* Ended for Bug 7561395*/
2490
2491 rpt_error(p_proc => l_proc, p_step => l_step);
2492 if p_called_from_sspnd = 'N' then
2493 ROLLBACK TO create_enrollment;
2494 else
2495 ROLLBACK TO create_enrollment_sspnd;
2496 end if;
2497 -- nocopy, reset
2498 p_prtt_enrt_rslt_id := null;
2499 p_effective_start_date := null;
2500 p_effective_end_date := null;
2501 p_object_version_number := null;
2502 raise;
2503 end create_enrollment;
2504 --
2505 -- ----------------------------------------------------------------------------
2506 -- |------------------------< create_PRTT_ENRT_RESULT >-----------------------|
2507 -- ----------------------------------------------------------------------------
2508 --
2509 procedure create_PRTT_ENRT_RESULT
2510 (p_validate in boolean default false
2511 ,p_prtt_enrt_rslt_id out nocopy number
2512 ,p_effective_start_date out nocopy date
2513 ,p_effective_end_date out nocopy date
2514 ,p_business_group_id in number default null
2515 ,p_oipl_id in number default null
2516 ,p_person_id in number default null
2517 ,p_assignment_id in number default null
2518 ,p_pgm_id in number default null
2519 ,p_pl_id in number default null
2520 ,p_rplcs_sspndd_rslt_id in number default null
2521 ,p_ptip_id in number default null
2522 ,p_pl_typ_id in number default null
2523 ,p_ler_id in number default null
2524 ,p_sspndd_flag in varchar2 default 'N'
2525 ,p_prtt_is_cvrd_flag in varchar2 default 'N'
2526 ,p_bnft_amt in number default null
2527 ,p_uom in varchar2 default null
2528 ,p_orgnl_enrt_dt in date default null
2529 ,p_enrt_mthd_cd in varchar2 default null
2530 ,p_no_lngr_elig_flag in varchar2 default 'N'
2531 ,p_enrt_ovridn_flag in varchar2 default 'N'
2532 ,p_enrt_ovrid_rsn_cd in varchar2 default null
2533 ,p_erlst_deenrt_dt in date default null
2534 ,p_enrt_cvg_strt_dt in date default null
2535 ,p_enrt_cvg_thru_dt in date default hr_api.g_eot
2536 ,p_enrt_ovrid_thru_dt in date default null
2537 ,p_pl_ordr_num in number default null
2538 ,p_plip_ordr_num in number default null
2539 ,p_ptip_ordr_num in number default null
2540 ,p_oipl_ordr_num in number default null
2541 ,p_pen_attribute_category in varchar2 default null
2542 ,p_pen_attribute1 in varchar2 default null
2543 ,p_pen_attribute2 in varchar2 default null
2544 ,p_pen_attribute3 in varchar2 default null
2545 ,p_pen_attribute4 in varchar2 default null
2546 ,p_pen_attribute5 in varchar2 default null
2547 ,p_pen_attribute6 in varchar2 default null
2548 ,p_pen_attribute7 in varchar2 default null
2549 ,p_pen_attribute8 in varchar2 default null
2550 ,p_pen_attribute9 in varchar2 default null
2551 ,p_pen_attribute10 in varchar2 default null
2552 ,p_pen_attribute11 in varchar2 default null
2553 ,p_pen_attribute12 in varchar2 default null
2554 ,p_pen_attribute13 in varchar2 default null
2555 ,p_pen_attribute14 in varchar2 default null
2556 ,p_pen_attribute15 in varchar2 default null
2557 ,p_pen_attribute16 in varchar2 default null
2558 ,p_pen_attribute17 in varchar2 default null
2559 ,p_pen_attribute18 in varchar2 default null
2560 ,p_pen_attribute19 in varchar2 default null
2561 ,p_pen_attribute20 in varchar2 default null
2562 ,p_pen_attribute21 in varchar2 default null
2563 ,p_pen_attribute22 in varchar2 default null
2564 ,p_pen_attribute23 in varchar2 default null
2565 ,p_pen_attribute24 in varchar2 default null
2566 ,p_pen_attribute25 in varchar2 default null
2567 ,p_pen_attribute26 in varchar2 default null
2568 ,p_pen_attribute27 in varchar2 default null
2569 ,p_pen_attribute28 in varchar2 default null
2570 ,p_pen_attribute29 in varchar2 default null
2571 ,p_pen_attribute30 in varchar2 default null
2572 ,p_request_id in number default null
2573 ,p_program_application_id in number default null
2574 ,p_program_id in number default null
2575 ,p_program_update_date in date default null
2576 ,p_object_version_number out nocopy number
2577 ,p_per_in_ler_id in number default null
2578 ,p_bnft_typ_cd in varchar2 default null
2579 ,p_bnft_ordr_num in number default null
2580 ,p_prtt_enrt_rslt_stat_cd in varchar2 default null
2581 ,p_bnft_nnmntry_uom in varchar2 default null
2582 ,p_comp_lvl_cd in varchar2 default null
2583 ,p_effective_date in date
2584 ,p_multi_row_validate in boolean default TRUE
2585 ) is
2586 --
2587 -- Declare cursors and local variables
2588 --
2589 l_prtt_enrt_rslt_id ben_prtt_enrt_rslt_f.prtt_enrt_rslt_id%TYPE;
2590 l_effective_start_date ben_prtt_enrt_rslt_f.effective_start_date%TYPE;
2591 l_effective_end_date ben_prtt_enrt_rslt_f.effective_end_date%TYPE;
2592 l_proc varchar2(72) ; -- := g_package||'create_PRTT_ENRT_RESULT';
2593 l_object_version_number ben_prtt_enrt_rslt_f.object_version_number%TYPE;
2594 begin
2595 g_debug := hr_utility.debug_enabled;
2596 if g_debug then
2597 l_proc := g_package||'create_PRTT_ENRT_RESULT';
2598 hr_utility.set_location('Entering:'|| l_proc, 10);
2599 end if;
2600 --
2601 g_multi_rows_validate := p_multi_row_validate;
2602 --
2603 -- Issue a savepoint if operating in validation only mode
2604 --
2605 savepoint create_PRTT_ENRT_RESULT;
2606 --
2607 if fnd_global.conc_request_id in (0,-1) then
2608 --
2609 --
2610 ben_env_object.init(p_business_group_id => p_business_group_id,
2611 p_effective_date => p_effective_date,
2612 p_thread_id => 1,
2613 p_chunk_size => 1,
2614 p_threads => 1,
2615 p_max_errors => 1,
2616 p_benefit_action_id => null);
2617 --
2618 end if;
2619 if g_debug then
2620 hr_utility.set_location(l_proc, 20);
2621 end if;
2622 --
2623 -- Process Logic
2624 --
2625 begin
2626 --
2627 -- Start of API User Hook for the before hook of create_PRTT_ENRT_RESULT
2628 --
2629 ben_PRTT_ENRT_RESULT_bk1.create_PRTT_ENRT_RESULT_b
2630 (p_business_group_id => p_business_group_id
2631 ,p_oipl_id => p_oipl_id
2632 ,p_person_id => p_person_id
2633 ,p_assignment_id => p_assignment_id
2634 ,p_pgm_id => p_pgm_id
2635 ,p_pl_id => p_pl_id
2636 ,p_rplcs_sspndd_rslt_id => p_rplcs_sspndd_rslt_id
2637 ,p_ptip_id => p_ptip_id
2638 ,p_pl_typ_id => p_pl_typ_id
2639 ,p_ler_id => p_ler_id
2640 ,p_sspndd_flag => p_sspndd_flag
2641 ,p_prtt_is_cvrd_flag => p_prtt_is_cvrd_flag
2642 ,p_bnft_amt => p_bnft_amt
2643 ,p_uom => p_uom
2644 ,p_orgnl_enrt_dt => p_orgnl_enrt_dt
2645 ,p_enrt_mthd_cd => p_enrt_mthd_cd
2646 ,p_no_lngr_elig_flag => p_no_lngr_elig_flag
2647 ,p_enrt_ovridn_flag => p_enrt_ovridn_flag
2648 ,p_enrt_ovrid_rsn_cd => p_enrt_ovrid_rsn_cd
2649 ,p_erlst_deenrt_dt => p_erlst_deenrt_dt
2650 ,p_enrt_cvg_strt_dt => p_enrt_cvg_strt_dt
2651 ,p_enrt_cvg_thru_dt => p_enrt_cvg_thru_dt
2652 ,p_enrt_ovrid_thru_dt => p_enrt_ovrid_thru_dt
2653 ,p_pl_ordr_num => p_pl_ordr_num
2654 ,p_plip_ordr_num => p_plip_ordr_num
2655 ,p_ptip_ordr_num => p_ptip_ordr_num
2656 ,p_oipl_ordr_num => p_oipl_ordr_num
2657 ,p_pen_attribute_category => p_pen_attribute_category
2658 ,p_pen_attribute1 => p_pen_attribute1
2659 ,p_pen_attribute2 => p_pen_attribute2
2660 ,p_pen_attribute3 => p_pen_attribute3
2661 ,p_pen_attribute4 => p_pen_attribute4
2662 ,p_pen_attribute5 => p_pen_attribute5
2663 ,p_pen_attribute6 => p_pen_attribute6
2664 ,p_pen_attribute7 => p_pen_attribute7
2665 ,p_pen_attribute8 => p_pen_attribute8
2666 ,p_pen_attribute9 => p_pen_attribute9
2667 ,p_pen_attribute10 => p_pen_attribute10
2668 ,p_pen_attribute11 => p_pen_attribute11
2669 ,p_pen_attribute12 => p_pen_attribute12
2670 ,p_pen_attribute13 => p_pen_attribute13
2671 ,p_pen_attribute14 => p_pen_attribute14
2672 ,p_pen_attribute15 => p_pen_attribute15
2673 ,p_pen_attribute16 => p_pen_attribute16
2674 ,p_pen_attribute17 => p_pen_attribute17
2675 ,p_pen_attribute18 => p_pen_attribute18
2676 ,p_pen_attribute19 => p_pen_attribute19
2677 ,p_pen_attribute20 => p_pen_attribute20
2678 ,p_pen_attribute21 => p_pen_attribute21
2679 ,p_pen_attribute22 => p_pen_attribute22
2680 ,p_pen_attribute23 => p_pen_attribute23
2681 ,p_pen_attribute24 => p_pen_attribute24
2682 ,p_pen_attribute25 => p_pen_attribute25
2683 ,p_pen_attribute26 => p_pen_attribute26
2684 ,p_pen_attribute27 => p_pen_attribute27
2685 ,p_pen_attribute28 => p_pen_attribute28
2686 ,p_pen_attribute29 => p_pen_attribute29
2687 ,p_pen_attribute30 => p_pen_attribute30
2688 ,p_request_id => p_request_id
2689 ,p_program_application_id => p_program_application_id
2690 ,p_program_id => p_program_id
2691 ,p_program_update_date => p_program_update_date
2692 ,p_per_in_ler_id => p_per_in_ler_id
2693 ,p_bnft_typ_cd => p_bnft_typ_cd
2694 ,p_bnft_ordr_num => p_bnft_ordr_num
2695 ,p_prtt_enrt_rslt_stat_cd => p_prtt_enrt_rslt_stat_cd
2696 ,p_bnft_nnmntry_uom => p_bnft_nnmntry_uom
2697 ,p_comp_lvl_cd => p_comp_lvl_cd
2698 ,p_effective_date => trunc(p_effective_date)
2699 );
2700 exception
2701 when hr_api.cannot_find_prog_unit then
2702 hr_api.cannot_find_prog_unit_error
2703 (p_module_name => 'CREATE_PRTT_ENRT_RESULT'
2704 ,p_hook_type => 'BP'
2705 );
2706 --
2707 -- End of API User Hook for the before hook of create_PRTT_ENRT_RESULT
2708 --
2709 end;
2710 ben_pen_ins.ins
2711 (p_prtt_enrt_rslt_id => l_prtt_enrt_rslt_id
2712 ,p_effective_start_date => l_effective_start_date
2713 ,p_effective_end_date => l_effective_end_date
2714 ,p_business_group_id => p_business_group_id
2715 ,p_oipl_id => p_oipl_id
2716 ,p_person_id => p_person_id
2717 ,p_assignment_id => p_assignment_id
2718 ,p_pgm_id => p_pgm_id
2719 ,p_pl_id => p_pl_id
2720 ,p_rplcs_sspndd_rslt_id => p_rplcs_sspndd_rslt_id
2721 ,p_ptip_id => p_ptip_id
2722 ,p_pl_typ_id => p_pl_typ_id
2723 ,p_ler_id => p_ler_id
2724 ,p_sspndd_flag => p_sspndd_flag
2725 ,p_prtt_is_cvrd_flag => p_prtt_is_cvrd_flag
2726 ,p_bnft_amt => p_bnft_amt
2727 ,p_uom => p_uom
2728 ,p_orgnl_enrt_dt => p_orgnl_enrt_dt
2729 ,p_enrt_mthd_cd => p_enrt_mthd_cd
2730 ,p_no_lngr_elig_flag => p_no_lngr_elig_flag
2731 ,p_enrt_ovridn_flag => p_enrt_ovridn_flag
2732 ,p_enrt_ovrid_rsn_cd => p_enrt_ovrid_rsn_cd
2733 ,p_erlst_deenrt_dt => p_erlst_deenrt_dt
2734 ,p_enrt_cvg_strt_dt => p_enrt_cvg_strt_dt
2735 ,p_enrt_cvg_thru_dt => p_enrt_cvg_thru_dt
2736 ,p_enrt_ovrid_thru_dt => p_enrt_ovrid_thru_dt
2737 ,p_pl_ordr_num => p_pl_ordr_num
2738 ,p_plip_ordr_num => p_plip_ordr_num
2739 ,p_ptip_ordr_num => p_ptip_ordr_num
2740 ,p_oipl_ordr_num => p_oipl_ordr_num
2741 ,p_pen_attribute_category => p_pen_attribute_category
2742 ,p_pen_attribute1 => p_pen_attribute1
2743 ,p_pen_attribute2 => p_pen_attribute2
2744 ,p_pen_attribute3 => p_pen_attribute3
2745 ,p_pen_attribute4 => p_pen_attribute4
2746 ,p_pen_attribute5 => p_pen_attribute5
2747 ,p_pen_attribute6 => p_pen_attribute6
2748 ,p_pen_attribute7 => p_pen_attribute7
2749 ,p_pen_attribute8 => p_pen_attribute8
2750 ,p_pen_attribute9 => p_pen_attribute9
2751 ,p_pen_attribute10 => p_pen_attribute10
2752 ,p_pen_attribute11 => p_pen_attribute11
2753 ,p_pen_attribute12 => p_pen_attribute12
2754 ,p_pen_attribute13 => p_pen_attribute13
2755 ,p_pen_attribute14 => p_pen_attribute14
2756 ,p_pen_attribute15 => p_pen_attribute15
2757 ,p_pen_attribute16 => p_pen_attribute16
2758 ,p_pen_attribute17 => p_pen_attribute17
2759 ,p_pen_attribute18 => p_pen_attribute18
2760 ,p_pen_attribute19 => p_pen_attribute19
2761 ,p_pen_attribute20 => p_pen_attribute20
2762 ,p_pen_attribute21 => p_pen_attribute21
2763 ,p_pen_attribute22 => p_pen_attribute22
2764 ,p_pen_attribute23 => p_pen_attribute23
2765 ,p_pen_attribute24 => p_pen_attribute24
2766 ,p_pen_attribute25 => p_pen_attribute25
2767 ,p_pen_attribute26 => p_pen_attribute26
2768 ,p_pen_attribute27 => p_pen_attribute27
2769 ,p_pen_attribute28 => p_pen_attribute28
2770 ,p_pen_attribute29 => p_pen_attribute29
2771 ,p_pen_attribute30 => p_pen_attribute30
2772 ,p_request_id => p_request_id
2773 ,p_program_application_id => p_program_application_id
2774 ,p_program_id => p_program_id
2775 ,p_program_update_date => p_program_update_date
2776 ,p_object_version_number => l_object_version_number
2777 ,p_per_in_ler_id => p_per_in_ler_id
2778 ,p_bnft_typ_cd => p_bnft_typ_cd
2779 ,p_bnft_ordr_num => p_bnft_ordr_num
2780 ,p_prtt_enrt_rslt_stat_cd => p_prtt_enrt_rslt_stat_cd
2781 ,p_bnft_nnmntry_uom => p_bnft_nnmntry_uom
2782 ,p_comp_lvl_cd => p_comp_lvl_cd
2783 ,p_effective_date => trunc(p_effective_date)
2784 );
2785 begin
2786 --
2787 -- Start of API User Hook for the after hook of create_PRTT_ENRT_RESULT
2788 --
2789 ben_PRTT_ENRT_RESULT_bk1.create_PRTT_ENRT_RESULT_a
2790 (p_prtt_enrt_rslt_id => l_prtt_enrt_rslt_id
2791 ,p_effective_start_date => l_effective_start_date
2792 ,p_effective_end_date => l_effective_end_date
2793 ,p_business_group_id => p_business_group_id
2794 ,p_oipl_id => p_oipl_id
2795 ,p_person_id => p_person_id
2796 ,p_assignment_id => p_assignment_id
2797 ,p_pgm_id => p_pgm_id
2798 ,p_pl_id => p_pl_id
2799 ,p_rplcs_sspndd_rslt_id => p_rplcs_sspndd_rslt_id
2800 ,p_ptip_id => p_ptip_id
2801 ,p_pl_typ_id => p_pl_typ_id
2802 ,p_ler_id => p_ler_id
2803 ,p_sspndd_flag => p_sspndd_flag
2804 ,p_prtt_is_cvrd_flag => p_prtt_is_cvrd_flag
2805 ,p_bnft_amt => p_bnft_amt
2806 ,p_uom => p_uom
2807 ,p_orgnl_enrt_dt => p_orgnl_enrt_dt
2808 ,p_enrt_mthd_cd => p_enrt_mthd_cd
2809 ,p_no_lngr_elig_flag => p_no_lngr_elig_flag
2810 ,p_enrt_ovridn_flag => p_enrt_ovridn_flag
2811 ,p_enrt_ovrid_rsn_cd => p_enrt_ovrid_rsn_cd
2812 ,p_erlst_deenrt_dt => p_erlst_deenrt_dt
2813 ,p_enrt_cvg_strt_dt => p_enrt_cvg_strt_dt
2814 ,p_enrt_cvg_thru_dt => p_enrt_cvg_thru_dt
2815 ,p_enrt_ovrid_thru_dt => p_enrt_ovrid_thru_dt
2816 ,p_pl_ordr_num => p_pl_ordr_num
2817 ,p_plip_ordr_num => p_plip_ordr_num
2818 ,p_ptip_ordr_num => p_ptip_ordr_num
2819 ,p_oipl_ordr_num => p_oipl_ordr_num
2820 ,p_pen_attribute_category => p_pen_attribute_category
2821 ,p_pen_attribute1 => p_pen_attribute1
2822 ,p_pen_attribute2 => p_pen_attribute2
2823 ,p_pen_attribute3 => p_pen_attribute3
2824 ,p_pen_attribute4 => p_pen_attribute4
2825 ,p_pen_attribute5 => p_pen_attribute5
2826 ,p_pen_attribute6 => p_pen_attribute6
2827 ,p_pen_attribute7 => p_pen_attribute7
2828 ,p_pen_attribute8 => p_pen_attribute8
2829 ,p_pen_attribute9 => p_pen_attribute9
2830 ,p_pen_attribute10 => p_pen_attribute10
2831 ,p_pen_attribute11 => p_pen_attribute11
2832 ,p_pen_attribute12 => p_pen_attribute12
2833 ,p_pen_attribute13 => p_pen_attribute13
2834 ,p_pen_attribute14 => p_pen_attribute14
2835 ,p_pen_attribute15 => p_pen_attribute15
2836 ,p_pen_attribute16 => p_pen_attribute16
2837 ,p_pen_attribute17 => p_pen_attribute17
2838 ,p_pen_attribute18 => p_pen_attribute18
2839 ,p_pen_attribute19 => p_pen_attribute19
2840 ,p_pen_attribute20 => p_pen_attribute20
2841 ,p_pen_attribute21 => p_pen_attribute21
2842 ,p_pen_attribute22 => p_pen_attribute22
2843 ,p_pen_attribute23 => p_pen_attribute23
2844 ,p_pen_attribute24 => p_pen_attribute24
2845 ,p_pen_attribute25 => p_pen_attribute25
2846 ,p_pen_attribute26 => p_pen_attribute26
2847 ,p_pen_attribute27 => p_pen_attribute27
2848 ,p_pen_attribute28 => p_pen_attribute28
2849 ,p_pen_attribute29 => p_pen_attribute29
2850 ,p_pen_attribute30 => p_pen_attribute30
2851 ,p_request_id => p_request_id
2852 ,p_program_application_id => p_program_application_id
2853 ,p_program_id => p_program_id
2854 ,p_program_update_date => p_program_update_date
2855 ,p_object_version_number => l_object_version_number
2856 ,p_per_in_ler_id => p_per_in_ler_id
2857 ,p_bnft_typ_cd => p_bnft_typ_cd
2858 ,p_bnft_ordr_num => p_bnft_ordr_num
2859 ,p_prtt_enrt_rslt_stat_cd => p_prtt_enrt_rslt_stat_cd
2860 ,p_bnft_nnmntry_uom => p_bnft_nnmntry_uom
2861 ,p_comp_lvl_cd => p_comp_lvl_cd
2862 ,p_effective_date => trunc(p_effective_date)
2863 );
2864 exception
2865 when hr_api.cannot_find_prog_unit then
2866 hr_api.cannot_find_prog_unit_error
2867 (p_module_name => 'CREATE_PRTT_ENRT_RESULT'
2868 ,p_hook_type => 'AP'
2869 );
2870 end;
2871 if g_debug then
2872 hr_utility.set_location(l_proc, 60);
2873 end if;
2874 --
2875 -- When in validation only mode raise the Validate_Enabled exception
2876 --
2877 if p_validate then
2878 raise hr_api.validate_enabled;
2879 end if;
2880 --
2881 -- Set all output arguments
2882 --
2883 p_prtt_enrt_rslt_id := l_prtt_enrt_rslt_id;
2884 p_effective_start_date := l_effective_start_date;
2885 p_effective_end_date := l_effective_end_date;
2886 p_object_version_number := l_object_version_number;
2887 if g_debug then
2888 hr_utility.set_location(' Leaving:'||l_proc, 70);
2889 end if;
2890 exception
2891 when hr_api.validate_enabled then
2892 --
2893 -- As the Validate_Enabled exception has been raised
2894 -- we must rollback to the savepoint
2895 --
2896 ROLLBACK TO create_PRTT_ENRT_RESULT;
2897 --
2898 -- Only set output warning arguments
2899 -- (Any key or derived arguments must be set to null
2900 -- when validation only mode is being used.)
2901 --
2902 p_prtt_enrt_rslt_id := null;
2903 p_effective_start_date := null;
2904 p_effective_end_date := null;
2905 p_object_version_number := null;
2906 if g_debug then
2907 hr_utility.set_location(' Leaving:'||l_proc, 80);
2908 end if;
2909 when others then
2910 --
2911 -- A validation or unexpected error has occured
2912 --
2913 ROLLBACK TO create_PRTT_ENRT_RESULT;
2914 --nocopy, reset
2915 p_prtt_enrt_rslt_id := null;
2916 p_effective_start_date := null;
2917 p_effective_end_date := null;
2918 p_object_version_number := null;
2919
2920 raise;
2921 end create_PRTT_ENRT_RESULT;
2922 --
2923 -- ----------------------------------------------------------------------------
2924 -- ----------------------------------------------------------------------------
2925 --
2926 procedure update_ENROLLMENT
2927 (p_validate in boolean default false
2928 ,p_prtt_enrt_rslt_id in number
2929 ,p_effective_start_date out nocopy date
2930 ,p_effective_end_date out nocopy date
2931 ,p_business_group_id in number default hr_api.g_number
2932 ,p_oipl_id in number default hr_api.g_number
2933 ,p_person_id in number default hr_api.g_number
2934 ,p_assignment_id in number default hr_api.g_number
2935 ,p_pgm_id in number default hr_api.g_number
2936 ,p_pl_id in number default hr_api.g_number
2937 ,p_rplcs_sspndd_rslt_id in number default hr_api.g_number
2938 ,p_ptip_id in number default hr_api.g_number
2939 ,p_pl_typ_id in number default hr_api.g_number
2940 ,p_ler_id in number default hr_api.g_number
2941 ,p_sspndd_flag in varchar2 default hr_api.g_varchar2
2942 ,p_prtt_is_cvrd_flag in varchar2 default hr_api.g_varchar2
2943 ,p_enrt_bnft_id in number default NULL
2944 ,p_bnft_amt in number default hr_api.g_number
2945 ,p_uom in varchar2 default hr_api.g_varchar2
2946 ,p_orgnl_enrt_dt in date default hr_api.g_date
2947 ,p_enrt_mthd_cd in varchar2 default hr_api.g_varchar2
2948 ,p_enrt_ovridn_flag in varchar2 default hr_api.g_varchar2
2949 ,p_enrt_ovrid_rsn_cd in varchar2 default hr_api.g_varchar2
2950 ,p_erlst_deenrt_dt in date default hr_api.g_date
2951 ,p_enrt_cvg_strt_dt in date default hr_api.g_date
2952 ,p_enrt_cvg_thru_dt in date default hr_api.g_date
2953 ,p_enrt_ovrid_thru_dt in date default hr_api.g_date
2954 ,p_pl_ordr_num in number default hr_api.g_number
2955 ,p_plip_ordr_num in number default hr_api.g_number
2956 ,p_ptip_ordr_num in number default hr_api.g_number
2957 ,p_oipl_ordr_num in number default hr_api.g_number
2958 ,p_pen_attribute_category in varchar2 default hr_api.g_varchar2
2959 ,p_pen_attribute1 in varchar2 default hr_api.g_varchar2
2960 ,p_pen_attribute2 in varchar2 default hr_api.g_varchar2
2961 ,p_pen_attribute3 in varchar2 default hr_api.g_varchar2
2962 ,p_pen_attribute4 in varchar2 default hr_api.g_varchar2
2963 ,p_pen_attribute5 in varchar2 default hr_api.g_varchar2
2964 ,p_pen_attribute6 in varchar2 default hr_api.g_varchar2
2965 ,p_pen_attribute7 in varchar2 default hr_api.g_varchar2
2966 ,p_pen_attribute8 in varchar2 default hr_api.g_varchar2
2967 ,p_pen_attribute9 in varchar2 default hr_api.g_varchar2
2968 ,p_pen_attribute10 in varchar2 default hr_api.g_varchar2
2969 ,p_pen_attribute11 in varchar2 default hr_api.g_varchar2
2970 ,p_pen_attribute12 in varchar2 default hr_api.g_varchar2
2971 ,p_pen_attribute13 in varchar2 default hr_api.g_varchar2
2972 ,p_pen_attribute14 in varchar2 default hr_api.g_varchar2
2973 ,p_pen_attribute15 in varchar2 default hr_api.g_varchar2
2974 ,p_pen_attribute16 in varchar2 default hr_api.g_varchar2
2975 ,p_pen_attribute17 in varchar2 default hr_api.g_varchar2
2976 ,p_pen_attribute18 in varchar2 default hr_api.g_varchar2
2977 ,p_pen_attribute19 in varchar2 default hr_api.g_varchar2
2978 ,p_pen_attribute20 in varchar2 default hr_api.g_varchar2
2979 ,p_pen_attribute21 in varchar2 default hr_api.g_varchar2
2980 ,p_pen_attribute22 in varchar2 default hr_api.g_varchar2
2981 ,p_pen_attribute23 in varchar2 default hr_api.g_varchar2
2982 ,p_pen_attribute24 in varchar2 default hr_api.g_varchar2
2983 ,p_pen_attribute25 in varchar2 default hr_api.g_varchar2
2984 ,p_pen_attribute26 in varchar2 default hr_api.g_varchar2
2985 ,p_pen_attribute27 in varchar2 default hr_api.g_varchar2
2986 ,p_pen_attribute28 in varchar2 default hr_api.g_varchar2
2987 ,p_pen_attribute29 in varchar2 default hr_api.g_varchar2
2988 ,p_pen_attribute30 in varchar2 default hr_api.g_varchar2
2989 ,p_request_id in number default hr_api.g_number
2990 ,p_program_application_id in number default hr_api.g_number
2991 ,p_program_id in number default hr_api.g_number
2992 ,p_program_update_date in date default hr_api.g_date
2993 ,p_object_version_number in out nocopy number
2994 ,p_per_in_ler_id in number default hr_api.g_number
2995 ,p_bnft_typ_cd in varchar2 default hr_api.g_varchar2
2996 ,p_bnft_ordr_num in number default hr_api.g_number
2997 ,p_prtt_enrt_rslt_stat_cd in varchar2 default hr_api.g_varchar2
2998 ,p_bnft_nnmntry_uom in varchar2 default hr_api.g_varchar2
2999 ,p_comp_lvl_cd in varchar2 default hr_api.g_varchar2
3000 ,p_effective_date in date
3001 ,p_datetrack_mode in varchar2
3002 ,p_multi_row_validate in boolean default TRUE
3003 ,p_suspend_flag out nocopy varchar2
3004 ,p_prtt_enrt_interim_id out nocopy number
3005 ,p_dpnt_actn_warning out nocopy boolean
3006 ,p_bnf_actn_warning out nocopy boolean
3007 ,p_ctfn_actn_warning out nocopy boolean
3008 ) is
3009 --
3010 -- Declare cursors and local variables
3011 --
3012 l_pl_rec ben_cobj_cache.g_pl_inst_row;
3013 l_oipl_rec ben_cobj_cache.g_oipl_inst_row;
3014 --
3015 l_global_pen_rec ben_prtt_enrt_rslt_f%rowtype;
3016
3017
3018 cursor c_interim_enrt is
3019 select pen.rplcs_sspndd_rslt_id
3020 from ben_prtt_enrt_rslt_f pen
3021 where pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id and
3022 pen.business_group_id = p_business_group_id and
3023 p_effective_date between
3024 pen.effective_start_date and pen.effective_end_date;
3025
3026 cursor c_prem is
3027 select ecr.val,
3028 ecr.uom,
3029 ecr.actl_prem_id,
3030 pil.lf_evt_ocrd_dt,
3031 pil.ler_id,
3032 epe.elig_per_elctbl_chc_id
3033 from ben_enrt_prem ecr,
3034 ben_per_in_ler pil,
3035 ben_elig_per_elctbl_chc epe
3036 where epe.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
3037 and epe.elig_per_elctbl_chc_id = ecr.elig_per_elctbl_chc_id
3038 and pil.per_in_ler_id = epe.per_in_ler_id
3039 and pil.per_in_ler_stat_cd = 'STRTD';
3040 --and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT');
3041 --
3042 l_prem c_prem%rowtype;
3043 --
3044 /*
3045 CODE PRIOR TO WWBUG: 1646442
3046 cursor c_ppe (p_prtt_enrt_rslt_id in number,
3047 p_actl_prem_id in number) is
3048 */
3049 /* Start of Changes for WWBUG: 1646442 */
3050 cursor c_ppe (p_prtt_enrt_rslt_id in number,
3051 p_actl_prem_id in number,
3052 p_ppe_dt_to_use in date) is
3053 /* End of Changes for WWBUG: 1646442 */
3054 select ppe.prtt_prem_id,
3055 ppe.std_prem_uom,
3056 ppe.std_prem_val,
3057 ppe.actl_prem_id,
3058 ppe.object_version_number,
3059 ppe.effective_start_date
3060 from ben_prtt_prem_f ppe,
3061 ben_per_in_ler pil
3062 where ppe.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
3063 and ppe.actl_prem_id = p_actl_prem_id
3064 /*
3065 CODE PRIOR TO WWBUG: 1646442
3066 and p_effective_date between
3067 */
3068 /* Start of Changes for WWBUG: 1646442 */
3069 and p_ppe_dt_to_use between
3070 /* End of Changes for WWBUG: 1646442 */
3071 ppe.effective_start_date and ppe.effective_end_date
3072 and pil.per_in_ler_id=ppe.per_in_ler_id
3073 and pil.business_group_id=ppe.business_group_id
3074 and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT')
3075 ;
3076 --
3077 l_ppe c_ppe%rowtype;
3078
3079 ----For Bug : 7133998
3080 cursor c_ppe1 (p_prtt_enrt_rslt_id in number,
3081 p_actl_prem_id in number,
3082 p_ppe_dt_to_use in date) is
3083 select ppe.*
3084 from ben_prtt_prem_f ppe,
3085 ben_per_in_ler pil
3086 where ppe.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
3087 and ppe.actl_prem_id = p_actl_prem_id
3088 and p_ppe_dt_to_use <= ppe.effective_start_date
3089 and pil.per_in_ler_id=ppe.per_in_ler_id
3090 and pil.business_group_id=ppe.business_group_id
3091 and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT')
3092 ;
3093 l_count number := 0;
3094 l_objversion_no number;
3095 ---For Bug : 7133998
3096 --
3097 -- This cursor is used to update the elig_cvrd_dpnt records
3098 -- when the participant stays in the same plan and we need
3099 -- to copy his dependents from elig_dpnt to elig_cvrd_dpnt.
3100 --
3101 -- Note: Result Id is same on the choice and elig_cvrd_dpnt record,
3102 -- but per_in_ler_id is DIFFERENT.
3103 -- Do not do any updates for same per_in_ler_id as we would have
3104 -- done the updates when per_in_ler_id changed and the user would
3105 -- have changed his designation since then. (Basically do not repeat it.)
3106 --
3107 -- Bug 1298802: sometimes per-in-ler is the same...when have a ler and move
3108 -- out of this result then right back into this result on same day. If prtt
3109 -- does an uncover, change option, then back into option, I think
3110 -- it's better to re-cover the dpnts....then user can uncover them again.
3111 --
3112 cursor c_egd(p_dpnt_cvg_thru_dt date) is --9881657
3113 select egd.elig_cvrd_dpnt_id,
3114 egd.per_in_ler_id,
3115 pdp.effective_start_date,
3116 pdp.object_version_number,
3117 pdp.cvg_thru_dt --9881657
3118 from ben_elig_per_elctbl_chc epe,
3119 ben_elig_dpnt egd,
3120 ben_elig_cvrd_dpnt_f pdp,
3121 ben_per_in_ler egd_pil,
3122 ben_per_in_ler pdp_pil
3123 where epe.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
3124 and epe.per_in_ler_id = p_per_in_ler_id
3125 and epe.elig_per_elctbl_chc_id = egd.elig_per_elctbl_chc_id
3126 and egd.elig_cvrd_dpnt_id = pdp.elig_cvrd_dpnt_id
3127 and pdp.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
3128 -- and egd.per_in_ler_id <> pdp.per_in_ler_id
3129 and egd.per_in_ler_id = egd_pil.per_in_ler_id
3130 and egd_pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT')
3131 and pdp.per_in_ler_id = pdp_pil.per_in_ler_id
3132 and pdp_pil.per_in_ler_stat_cd not in ('VOIDD', 'BCKDT')
3133 and p_effective_date between
3134 pdp.effective_start_date and pdp.effective_end_date
3135 and p_effective_date >= pdp.cvg_strt_dt
3136 and egd.dpnt_inelig_flag = 'N'
3137 and p_dpnt_cvg_thru_dt <= pdp.cvg_thru_dt --9881657
3138 -- and p_effective_date between
3139 -- pdp.cvg_strt_dt and pdp.cvg_thru_dt
3140 ;
3141
3142
3143 /* Bug 9748558:-If a person move out of the result and re-enroll into the same result
3144 on a different day in the same enrollment period,then re-cover the dependents.*/
3145 cursor c_check_dup_dep(p_pdp_id number) is
3146 select pdp.*
3147 from ben_elig_cvrd_dpnt_f pdp,
3148 ben_prtt_enrt_rslt_f pen
3149 where pdp.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
3150 and pdp.elig_cvrd_dpnt_id = p_pdp_id
3151 and pdp.per_in_ler_id = p_per_in_ler_id
3152 and pdp.cvg_thru_dt <> hr_api.g_eot
3153 and pdp.effective_end_date = hr_api.g_eot
3154 and pen.prtt_enrt_rslt_id = pdp.prtt_enrt_rslt_id
3155 and pen.per_in_ler_id = pdp.per_in_ler_id
3156 and pen.prtt_enrt_rslt_stat_cd is null
3157 and pen.effective_end_date = hr_api.g_eot
3158 and pen.enrt_cvg_thru_dt = hr_api.g_eot;
3159
3160 l_check_dup_dep c_check_dup_dep%rowtype;
3161
3162 cursor c_get_last_pil is
3163 SELECT pil.per_in_ler_id
3164 FROM ben_per_in_ler pil
3165 WHERE pil.per_in_ler_stat_cd = 'PROCD'
3166 AND pil.lf_evt_ocrd_dt = (SELECT Max(pil1.lf_evt_ocrd_dt)
3167 FROM ben_per_in_ler pil1,
3168 ben_prtt_enrt_rslt_f pen
3169 WHERE pil1.person_id = pil.person_id
3170 AND pil1.per_in_ler_stat_cd = 'PROCD'
3171 AND pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
3172 AND pen.prtt_enrt_rslt_stat_cd IS NULL
3173 AND pen.per_in_ler_id = pil1.per_in_ler_id
3174 AND pen.enrt_cvg_thru_dt >= pen.enrt_cvg_strt_dt
3175 )
3176 and pil.person_id = p_person_id ;
3177 l_get_last_pil c_get_last_pil%rowtype;
3178
3179 cursor c_last_pil_pdp(p_pil_id number,p_pdp_id number) is
3180 SELECT pdp.*
3181 FROM ben_elig_cvrd_dpnt_f pdp
3182 WHERE pdp.per_in_ler_id = p_pil_id
3183 AND pdp.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
3184 AND pdp.elig_cvrd_dpnt_id = p_pdp_id;
3185
3186 l_last_pil_pdp c_last_pil_pdp%rowtype;
3187
3188 cursor c_pdp_rec(p_pdp_id number) is
3189 select pdp.*
3190 from ben_elig_cvrd_dpnt_f pdp
3191 where pdp.elig_cvrd_dpnt_id = p_pdp_id;
3192 /* Bug 9748558 */
3193
3194 ------Check if the elig_cvrd_dpnt_id is set in ben_elig_dpnt table,Bug 8919376
3195 cursor c_check_cvrd_dpnt(p_dpnt_cvg_thru_dt date) is --9881657
3196 select egd.*,pdp.elig_cvrd_dpnt_id cvrd_dpnt_id
3197 from ben_elig_per_elctbl_chc epe,
3198 ben_elig_dpnt egd,
3199 ben_elig_cvrd_dpnt_f pdp,
3200 ben_per_in_ler egd_pil,
3201 ben_per_in_ler pdp_pil
3202 where epe.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
3203 and epe.per_in_ler_id = p_per_in_ler_id
3204 AND epe.crntly_enrd_flag = 'Y'
3205 and epe.elig_per_elctbl_chc_id = egd.elig_per_elctbl_chc_id
3206 and egd.elig_cvrd_dpnt_id IS NULL
3207 AND egd.dpnt_person_id = pdp.dpnt_person_id
3208 and pdp.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
3209 and egd.per_in_ler_id = egd_pil.per_in_ler_id
3210 and egd_pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT')
3211 and pdp.per_in_ler_id = pdp_pil.per_in_ler_id
3212 and pdp_pil.per_in_ler_stat_cd not in ('VOIDD', 'BCKDT')
3213 and p_effective_date between
3214 pdp.effective_start_date and pdp.effective_end_date
3215 and p_effective_date >= pdp.cvg_strt_dt
3216 and p_dpnt_cvg_thru_dt <= pdp.cvg_thru_dt --9881657
3217 and egd.dpnt_inelig_flag = 'N';
3218 ----------Bug 8919376
3219 --- to find the flex credit place holder choice and rate
3220 --- flex credit amount is changes is not effecting the ledger
3221 ---- this find the flex credit place holder plan prvdd amount
3222 --- then the amount will be compared with bnft_prvdd_ldgr row
3223 -- if a rate cahnge found update the bnft_prvdd_ldgr
3224 cursor c_flex_choice is
3225 select epe.bnft_prvdr_pool_id,
3226 epe.elig_per_elctbl_chc_id,
3227 epe.prtt_enrt_rslt_id,
3228 epe.business_group_id,
3229 epe.per_in_ler_id,
3230 ecr.enrt_rt_id,
3231 ecr.acty_base_rt_id,
3232 nvl(ecr.dflt_val, ecr.val) val
3233 from ben_elig_per_elctbl_chc epe1,
3234 ben_elig_per_elctbl_chc epe,
3235 ben_enrt_rt ecr
3236 where epe1.prtt_enrt_rslt_id =p_prtt_enrt_rslt_id and
3237 epe1.per_in_ler_id = p_per_in_ler_id and
3238 epe1.business_group_id=p_business_group_id and
3239 epe1.pgm_id = epe.pgm_id and
3240 epe1.per_in_ler_id = epe.per_in_ler_id and
3241 epe.bnft_prvdr_pool_id is not null and
3242 epe.business_group_id=p_business_group_id and
3243 ecr.elig_per_elctbl_chc_id = epe.elig_per_elctbl_chc_id and
3244 ecr.rt_usg_cd = 'FLXCR' and
3245 ecr.business_group_id = p_business_group_id;
3246
3247
3248
3249 cursor c_bpl ( c_acty_base_rt_id number ,
3250 c_bnft_prvdr_pool_id number ,
3251 c_prtt_enrt_rslt_id number) is
3252 select prvdd_val
3253 from ben_bnft_prvdd_ldgr_f bpl,
3254 ben_per_in_ler pil
3255 where bpl.acty_base_rt_id = c_acty_base_rt_id
3256 and bpl.bnft_prvdr_pool_id = c_bnft_prvdr_pool_id
3257 and bpl.prtt_enrt_rslt_id = c_prtt_enrt_rslt_id
3258 and pil.per_in_ler_id = bpl.per_in_ler_id
3259 and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT')
3260 and bpl.business_group_id = p_business_group_id
3261 and p_effective_date between
3262 bpl.effective_start_date and bpl.effective_end_date ;
3263 --
3264 cursor c_prtt_enrt is
3265 select prtt_enrt_rslt_id
3266 from ben_elig_per_elctbl_chc epe
3267 where epe.per_in_ler_id = p_per_in_ler_id
3268 and epe.comp_lvl_cd = 'PLANFC'
3269 and epe.business_group_id = p_business_group_id;
3270 --
3271 cursor c_elig_per_elctbl_chc is
3272 select elig_per_elctbl_chc_id
3273 from ben_elig_per_elctbl_chc
3274 where prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
3275 and per_in_ler_id = p_per_in_ler_id;
3276 --
3277 /* Start of Changes for WWBUG: 1646442: added */
3278 cursor c_pel (p_elig_pe_elctbl_chc_id number) is
3279 select pel.enrt_perd_id,pel.lee_rsn_id
3280 from ben_pil_elctbl_chc_popl pel
3281 ,ben_elig_per_elctbl_chc epe
3282 where pel.pil_elctbl_chc_popl_id = epe.pil_elctbl_chc_popl_id
3283 and epe.elig_per_elctbl_chc_id = p_elig_pe_elctbl_chc_id;
3284
3285 l_pel c_pel%rowtype;
3286 --
3287 -- Bug : 3866580
3288 cursor c_pl_typ_opt_typ_cd (pl_typ_id number, p_effective_date date) is
3289 select ptp.opt_typ_cd
3290 from ben_pl_typ_f ptp
3291 where ptp.pl_typ_id = p_pl_typ_id
3292 and p_effective_date between ptp.effective_start_date
3293 and ptp.effective_end_date;
3294
3295 l_pl_typ_opt_typ_cd ben_pl_typ.opt_typ_cd%type;
3296 -- Bug : 3866580
3297 --
3298 --
3299 l_ppe_dt_to_use date;
3300 l_enrt_cvg_strt_dt date;
3301 l_enrt_cvg_strt_dt_cd varchar2(30);
3302 l_enrt_cvg_strt_dt_rl number;
3303 l_rt_strt_dt date;
3304 l_rt_strt_dt_cd varchar2(30);
3305 l_rt_strt_dt_rl number;
3306 l_enrt_cvg_end_dt date;
3307 l_enrt_cvg_end_dt_cd varchar2(30);
3308 l_enrt_cvg_end_dt_rl number;
3309 l_rt_end_dt date;
3310 l_rt_end_dt_cd varchar2(30);
3311 l_rt_end_dt_rl number;
3312 /* End of Changes for WWBUG: 1646442 */
3313 --
3314 l_proc varchar2(72); -- := g_package||'update_ENROLLMENT';
3315 l_object_version_number ben_prtt_enrt_rslt_f.object_version_number%TYPE;
3316 l_effective_start_date ben_prtt_enrt_rslt_f.effective_start_date%TYPE;
3317 l_effective_end_date ben_prtt_enrt_rslt_f.effective_end_date%TYPE;
3318 l_prev_bnft_amt ben_prtt_enrt_rslt_f.bnft_amt%TYPE;
3319 l_enrt_pl_opt_flag ben_pl_f.enrt_pl_opt_flag%TYPE;
3320 l_prvdd_val ben_bnft_prvdd_ldgr_f.prvdd_Val%type ;
3321 l_chg boolean := FALSE;
3322 l_step number(9);
3323 l_datetrack_mode varchar2(30) := p_datetrack_mode;
3324 l_correction boolean;
3325 l_update boolean;
3326 l_update_override boolean;
3327 l_update_change_insert boolean;
3328 l_post_rslt_flag varchar2(30) := 'Y';
3329 l_egd_datetrack_mode varchar2(30);
3330 l_ppe_datetrack_mode varchar2(30);
3331 l_prtt_enrt_rslt_id number ;
3332 l_elig_per_elctbl_chc_id number;
3333 --9881657
3334 l_dpnt_cvg_end_dt date;
3335 l_dpnt_cvg_thru_dt date;
3336 l_dump_date date;
3337 l_new_dpnt_cvg_thru_dt date;
3338 --9881657
3339 --
3340 begin
3341 --
3342 l_step := 10;
3343 g_debug := hr_utility.debug_enabled;
3344 if g_debug then
3345 l_proc := g_package||'update_ENROLLMENT';
3346 hr_utility.set_location('Entering:'|| l_proc, 10);
3347 end if;
3348 --
3349 g_multi_rows_validate := p_multi_row_validate;
3350 If (p_multi_row_validate) then
3351 l_post_rslt_flag := 'Y';
3352 Else
3353 l_post_rslt_flag := 'N';
3354 End if;
3355 --
3356 -- Issue a savepoint if operating in validation only mode
3357 --
3358 savepoint update_ENROLLMENT;
3359 if g_debug then
3360 hr_utility.set_location(l_proc, 20);
3361 end if;
3362 --
3363 -- Process Logic
3364 --
3365 l_object_version_number := p_object_version_number;
3366 l_step := 20;
3367 ben_global_enrt.get_pen -- result
3368 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
3369 ,p_effective_date => p_effective_date
3370 ,p_global_pen_rec => l_global_pen_rec);
3371 --
3372 ben_cobj_cache.get_pl_dets
3373 (p_business_group_id => p_business_group_id
3374 ,p_effective_date => p_effective_date
3375 ,p_pl_id => l_global_pen_rec.pl_id
3376 ,p_inst_row => l_pl_rec);
3377 if l_global_pen_rec.oipl_id is not null then
3378 ben_cobj_cache.get_oipl_dets
3379 (p_business_group_id => p_business_group_id
3380 ,p_effective_date => p_effective_date
3381 ,p_oipl_id => l_global_pen_rec.oipl_id
3382 ,p_inst_row => l_oipl_rec);
3383 end if;
3384 --
3385 l_step := 30;
3386 if (p_oipl_id <> hr_api.g_number and
3387 nvl(l_global_pen_rec.oipl_id,hr_api.g_number) <>
3388 nvl(p_oipl_id,hr_api.g_number)) then
3389 l_chg := TRUE;
3390 end if;
3391 if (p_assignment_id <> hr_api.g_number and
3392 nvl(l_global_pen_rec.assignment_id,hr_api.g_number) <>
3393 nvl(p_assignment_id,hr_api.g_number)) then
3394 l_chg := TRUE;
3395 end if;
3396 if (p_pgm_id <> hr_api.g_number and
3397 nvl(l_global_pen_rec.pgm_id,hr_api.g_number) <>
3398 nvl(p_pgm_id,hr_api.g_number)) then
3399 l_chg := TRUE;
3400 end if;
3401 if (p_pl_id <> hr_api.g_number and
3402 nvl(l_global_pen_rec.pl_id,hr_api.g_number) <>
3403 nvl(p_pl_id, hr_api.g_number)) then
3404 l_chg := TRUE;
3405 end if;
3406 if (p_rplcs_sspndd_rslt_id <> hr_api.g_number and
3407 nvl(l_global_pen_rec.rplcs_sspndd_rslt_id,hr_api.g_number) <>
3408 nvl(p_rplcs_sspndd_rslt_id,hr_api.g_number) ) then
3409 l_chg := TRUE;
3410 end if;
3411 l_step := 35;
3412 if (p_ptip_id <> hr_api.g_number and
3413 nvl(l_global_pen_rec.ptip_id,hr_api.g_number) <>
3414 nvl(p_ptip_id,hr_api.g_number)) then
3415 l_chg := TRUE;
3416 end if;
3417 if (p_pl_typ_id <> hr_api.g_number and
3418 nvl(l_global_pen_rec.pl_typ_id,hr_api.g_number) <>
3419 nvl(p_pl_typ_id,hr_api.g_number)) then
3420 l_chg := TRUE;
3421 end if;
3422 if (p_ler_id <> hr_api.g_number and
3423 nvl(l_global_pen_rec.ler_id,hr_api.g_number) <>
3424 nvl(p_ler_id,hr_api.g_number)) then
3425 l_chg := TRUE;
3426 end if;
3427 if (p_sspndd_flag <> hr_api.g_varchar2 and
3428 nvl(l_global_pen_rec.sspndd_flag,hr_api.g_varchar2) <>
3429 nvl(p_sspndd_flag,hr_api.g_varchar2)) then
3430 l_chg := TRUE;
3431 end if;
3432 if (p_prtt_is_cvrd_flag <> hr_api.g_varchar2 and
3433 nvl(l_global_pen_rec.prtt_is_cvrd_flag,hr_api.g_varchar2) <>
3434 nvl(p_prtt_is_cvrd_flag,hr_api.g_varchar2)) then
3435 l_chg := TRUE;
3436 end if;
3437 --
3438 -- Bug 4723828 : If benefit amount changes from non-zero value to NULL
3439 -- we need to detect that nullify the coverage. So added
3440 -- nvl(p_bnft_amt, -9999)
3441 --
3442 if (nvl(p_bnft_amt, -9999) <> hr_api.g_number and
3443 nvl(l_global_pen_rec.bnft_amt,hr_api.g_number) <>
3444 nvl(p_bnft_amt,hr_api.g_number)) then
3445 l_chg := TRUE;
3446 end if;
3447 l_step := 40;
3448 if (p_uom <> hr_api.g_varchar2 and
3449 nvl(l_global_pen_rec.uom,hr_api.g_varchar2) <>
3450 nvl(p_uom,hr_api.g_varchar2)) then
3451 l_chg := TRUE;
3452 end if;
3453 if (p_orgnl_enrt_dt <> hr_api.g_date and
3454 nvl(l_global_pen_rec.orgnl_enrt_dt,hr_api.g_date) <>
3455 nvl(p_orgnl_enrt_dt,hr_api.g_date)) then
3456 l_chg := TRUE;
3457 end if;
3458 -- 5417132 by pass enrt_mthd_cd chk for Imputed/flex rows
3459 if p_comp_lvl_cd not in ('PLANFC','PLANIMP') then
3460 if (p_enrt_mthd_cd <> hr_api.g_varchar2 and
3461 nvl(l_global_pen_rec.enrt_mthd_cd,hr_api.g_varchar2) <>
3462 nvl(p_enrt_mthd_cd,hr_api.g_varchar2)) then
3463 l_chg := TRUE;
3464 end if;
3465 end if;
3466 if (p_enrt_ovridn_flag <> hr_api.g_varchar2 and
3467 nvl(l_global_pen_rec.enrt_ovridn_flag,hr_api.g_varchar2) <>
3468 nvl(p_enrt_ovridn_flag,hr_api.g_varchar2)) then
3469 l_chg := TRUE;
3470 end if;
3471 if (p_enrt_ovrid_rsn_cd <> hr_api.g_varchar2 and
3472 nvl(l_global_pen_rec.enrt_ovrid_rsn_cd,hr_api.g_varchar2) <>
3473 nvl(p_enrt_ovrid_rsn_cd,hr_api.g_varchar2)) then
3474 l_chg := TRUE;
3475 end if;
3476 if (p_erlst_deenrt_dt <> hr_api.g_date and
3477 nvl(l_global_pen_rec.erlst_deenrt_dt,hr_api.g_date) <>
3478 nvl(p_erlst_deenrt_dt,hr_api.g_date)) then
3479 l_chg := TRUE;
3480 end if;
3481 if (p_enrt_cvg_strt_dt <> hr_api.g_date and
3482 nvl(l_global_pen_rec.enrt_cvg_strt_dt,hr_api.g_date) <>
3483 nvl(p_enrt_cvg_strt_dt,hr_api.g_date)) then
3484 l_chg := TRUE;
3485 end if;
3486 if (p_enrt_cvg_thru_dt <> hr_api.g_date and
3487 nvl(l_global_pen_rec.enrt_cvg_thru_dt,hr_api.g_date) <>
3488 nvl(p_enrt_cvg_thru_dt,hr_api.g_date)) then
3489 l_chg := TRUE;
3490 end if;
3491 if (p_enrt_ovrid_thru_dt <> hr_api.g_date and
3492 nvl(l_global_pen_rec.enrt_ovrid_thru_dt,hr_api.g_date) <>
3493 nvl(p_enrt_ovrid_thru_dt,hr_api.g_date)) then
3494 l_chg := TRUE;
3495 end if;
3496 l_step := 50;
3497 if (p_per_in_ler_id <> hr_api.g_number and
3498 nvl(l_global_pen_rec.per_in_ler_id,hr_api.g_number) <>
3499 nvl(p_per_in_ler_id,hr_api.g_number)) then
3500 l_chg := TRUE;
3501 end if;
3502 if (p_bnft_typ_cd <> hr_api.g_varchar2 and
3503 nvl(l_global_pen_rec.bnft_typ_cd,hr_api.g_varchar2) <>
3504 nvl(p_bnft_typ_cd,hr_api.g_varchar2)) then
3505 l_chg := TRUE;
3506 end if;
3507 if (p_bnft_ordr_num <> hr_api.g_number and
3508 nvl(l_global_pen_rec.bnft_ordr_num,hr_api.g_number) <>
3509 nvl(p_bnft_ordr_num,hr_api.g_number)) then
3510 l_chg := TRUE;
3511 end if;
3512 if (p_prtt_enrt_rslt_stat_cd <> hr_api.g_varchar2 and
3513 nvl(l_global_pen_rec.prtt_enrt_rslt_stat_cd,hr_api.g_varchar2) <>
3514 nvl(p_prtt_enrt_rslt_stat_cd,hr_api.g_varchar2)) then
3515 l_chg := TRUE;
3516 end if;
3517 if (p_bnft_nnmntry_uom <> hr_api.g_varchar2 and
3518 nvl(l_global_pen_rec.bnft_nnmntry_uom,hr_api.g_varchar2) <>
3519 nvl(p_bnft_nnmntry_uom,hr_api.g_varchar2)) then
3520 l_chg := TRUE;
3521 end if;
3522 if (p_comp_lvl_cd <> hr_api.g_varchar2 and
3523 nvl(l_global_pen_rec.comp_lvl_cd,hr_api.g_varchar2) <>
3524 nvl(p_comp_lvl_cd,hr_api.g_varchar2)) then
3525 l_chg := TRUE;
3526 end if;
3527 --
3528 -- bug 1712890 added the following columns
3529 --
3530
3531 --Bug 4770367 : Added the NVL condition so as to allow the user to update
3532 -- the attributes with NULL values if the user wishes to do so
3533
3534 --If DFF field changes from non-zero value to NULL
3535 -- we need to detect that nullify the coverage. So added
3536 -- nvl(p_pen_attributexx, '~')
3537
3538 if (nvl(p_pen_attribute1 ,'~')<> hr_api.g_varchar2 and
3539 nvl(l_global_pen_rec.pen_attribute1,hr_api.g_varchar2) <>
3540 nvl(p_pen_attribute1,hr_api.g_varchar2)) then
3541 l_chg := TRUE;
3542 end if;
3543 if (nvl(p_pen_attribute2 ,'~')<> hr_api.g_varchar2 and
3544 nvl(l_global_pen_rec.pen_attribute2,hr_api.g_varchar2) <>
3545 nvl(p_pen_attribute2,hr_api.g_varchar2)) then
3546 l_chg := TRUE;
3547 end if;
3548 if (nvl(p_pen_attribute3 ,'~')<> hr_api.g_varchar2 and
3549 nvl(l_global_pen_rec.pen_attribute3,hr_api.g_varchar2) <>
3550 nvl(p_pen_attribute3,hr_api.g_varchar2)) then
3551 l_chg := TRUE;
3552 end if;
3553 if (nvl(p_pen_attribute4 ,'~')<> hr_api.g_varchar2 and
3554 nvl(l_global_pen_rec.pen_attribute4,hr_api.g_varchar2) <>
3555 nvl(p_pen_attribute4,hr_api.g_varchar2)) then
3556 l_chg := TRUE;
3557 end if;
3558 if (nvl(p_pen_attribute5 ,'~')<> hr_api.g_varchar2 and
3559 nvl(l_global_pen_rec.pen_attribute5,hr_api.g_varchar2) <>
3560 nvl(p_pen_attribute5,hr_api.g_varchar2)) then
3561 l_chg := TRUE;
3562 end if;
3563 if (nvl(p_pen_attribute6 ,'~')<> hr_api.g_varchar2 and
3564 nvl(l_global_pen_rec.pen_attribute6,hr_api.g_varchar2) <>
3565 nvl(p_pen_attribute6,hr_api.g_varchar2)) then
3566 l_chg := TRUE;
3567 end if;
3568 if (nvl(p_pen_attribute7 ,'~')<> hr_api.g_varchar2 and
3569 nvl(l_global_pen_rec.pen_attribute7,hr_api.g_varchar2) <>
3570 nvl(p_pen_attribute7,hr_api.g_varchar2)) then
3571 l_chg := TRUE;
3572 end if;
3573 if (nvl(p_pen_attribute8 ,'~')<> hr_api.g_varchar2 and
3574 nvl(l_global_pen_rec.pen_attribute8,hr_api.g_varchar2) <>
3575 nvl(p_pen_attribute8,hr_api.g_varchar2)) then
3576 l_chg := TRUE;
3577 end if;
3578 if (nvl(p_pen_attribute9 ,'~')<> hr_api.g_varchar2 and
3579 nvl(l_global_pen_rec.pen_attribute9,hr_api.g_varchar2) <>
3580 nvl(p_pen_attribute9,hr_api.g_varchar2)) then
3581 l_chg := TRUE;
3582 end if;
3583 if (nvl(p_pen_attribute10 ,'~')<> hr_api.g_varchar2 and
3584 nvl(l_global_pen_rec.pen_attribute10,hr_api.g_varchar2) <>
3585 nvl(p_pen_attribute10,hr_api.g_varchar2)) then
3586 l_chg := TRUE;
3587 end if;
3588 if (nvl(p_pen_attribute11 ,'~')<> hr_api.g_varchar2 and
3589 nvl(l_global_pen_rec.pen_attribute11,hr_api.g_varchar2) <>
3590 nvl(p_pen_attribute11,hr_api.g_varchar2)) then
3591 l_chg := TRUE;
3592 end if;
3593 if (nvl(p_pen_attribute12 ,'~')<> hr_api.g_varchar2 and
3594 nvl(l_global_pen_rec.pen_attribute12,hr_api.g_varchar2) <>
3595 nvl(p_pen_attribute12,hr_api.g_varchar2)) then
3596 l_chg := TRUE;
3597 end if;
3598 if (nvl(p_pen_attribute13 ,'~')<> hr_api.g_varchar2 and
3599 nvl(l_global_pen_rec.pen_attribute13,hr_api.g_varchar2) <>
3600 nvl(p_pen_attribute13,hr_api.g_varchar2)) then
3601 l_chg := TRUE;
3602 end if;
3603 if (nvl(p_pen_attribute14 ,'~')<> hr_api.g_varchar2 and
3604 nvl(l_global_pen_rec.pen_attribute14,hr_api.g_varchar2) <>
3605 nvl(p_pen_attribute14,hr_api.g_varchar2)) then
3606 l_chg := TRUE;
3607 end if;
3608 if (nvl(p_pen_attribute15 ,'~')<> hr_api.g_varchar2 and
3609 nvl(l_global_pen_rec.pen_attribute15,hr_api.g_varchar2) <>
3610 nvl(p_pen_attribute15,hr_api.g_varchar2)) then
3611 l_chg := TRUE;
3612 end if;
3613 if (nvl(p_pen_attribute16 ,'~')<> hr_api.g_varchar2 and
3614 nvl(l_global_pen_rec.pen_attribute16,hr_api.g_varchar2) <>
3615 nvl(p_pen_attribute16,hr_api.g_varchar2)) then
3616 l_chg := TRUE;
3617 end if;
3618 if (nvl(p_pen_attribute17 ,'~')<> hr_api.g_varchar2 and
3619 nvl(l_global_pen_rec.pen_attribute17,hr_api.g_varchar2) <>
3620 nvl(p_pen_attribute17,hr_api.g_varchar2)) then
3621 l_chg := TRUE;
3622 end if;
3623 if (nvl(p_pen_attribute18 ,'~')<> hr_api.g_varchar2 and
3624 nvl(l_global_pen_rec.pen_attribute18,hr_api.g_varchar2) <>
3625 nvl(p_pen_attribute18,hr_api.g_varchar2)) then
3626 l_chg := TRUE;
3627 end if;
3628 if (nvl(p_pen_attribute19 ,'~')<> hr_api.g_varchar2 and
3629 nvl(l_global_pen_rec.pen_attribute19,hr_api.g_varchar2) <>
3630 nvl(p_pen_attribute19,hr_api.g_varchar2)) then
3631 l_chg := TRUE;
3632 end if;
3633 if (nvl(p_pen_attribute20 ,'~')<> hr_api.g_varchar2 and
3634 nvl(l_global_pen_rec.pen_attribute20,hr_api.g_varchar2) <>
3635 nvl(p_pen_attribute20,hr_api.g_varchar2)) then
3636 l_chg := TRUE;
3637 end if;
3638 if (nvl(p_pen_attribute21 ,'~')<> hr_api.g_varchar2 and
3639 nvl(l_global_pen_rec.pen_attribute21,hr_api.g_varchar2) <>
3640 nvl(p_pen_attribute21,hr_api.g_varchar2)) then
3641 l_chg := TRUE;
3642 end if;
3643 if (nvl(p_pen_attribute22 ,'~')<> hr_api.g_varchar2 and
3644 nvl(l_global_pen_rec.pen_attribute22,hr_api.g_varchar2) <>
3645 nvl(p_pen_attribute22,hr_api.g_varchar2)) then
3646 l_chg := TRUE;
3647 end if;
3648 if (nvl(p_pen_attribute23 ,'~')<> hr_api.g_varchar2 and
3649 nvl(l_global_pen_rec.pen_attribute23,hr_api.g_varchar2) <>
3650 nvl(p_pen_attribute23,hr_api.g_varchar2)) then
3651 l_chg := TRUE;
3652 end if;
3653 if (nvl(p_pen_attribute24 ,'~')<> hr_api.g_varchar2 and
3654 nvl(l_global_pen_rec.pen_attribute24,hr_api.g_varchar2) <>
3655 nvl(p_pen_attribute24,hr_api.g_varchar2)) then
3656 l_chg := TRUE;
3657 end if;
3658 if (nvl(p_pen_attribute25 ,'~')<> hr_api.g_varchar2 and
3659 nvl(l_global_pen_rec.pen_attribute25,hr_api.g_varchar2) <>
3660 nvl(p_pen_attribute25,hr_api.g_varchar2)) then
3661 l_chg := TRUE;
3662 end if;
3663 if (nvl(p_pen_attribute26 ,'~')<> hr_api.g_varchar2 and
3664 nvl(l_global_pen_rec.pen_attribute26,hr_api.g_varchar2) <>
3665 nvl(p_pen_attribute26,hr_api.g_varchar2)) then
3666 l_chg := TRUE;
3667 end if;
3668 if (nvl(p_pen_attribute27 ,'~')<> hr_api.g_varchar2 and
3669 nvl(l_global_pen_rec.pen_attribute27,hr_api.g_varchar2) <>
3670 nvl(p_pen_attribute27,hr_api.g_varchar2)) then
3671 l_chg := TRUE;
3672 end if;
3673 if (nvl(p_pen_attribute28 ,'~')<> hr_api.g_varchar2 and
3674 nvl(l_global_pen_rec.pen_attribute28,hr_api.g_varchar2) <>
3675 nvl(p_pen_attribute28,hr_api.g_varchar2)) then
3676 l_chg := TRUE;
3677 end if;
3678 if (nvl(p_pen_attribute29 ,'~')<> hr_api.g_varchar2 and
3679 nvl(l_global_pen_rec.pen_attribute29,hr_api.g_varchar2) <>
3680 nvl(p_pen_attribute29,hr_api.g_varchar2)) then
3681 l_chg := TRUE;
3682 end if;
3683 if (nvl(p_pen_attribute30 ,'~')<> hr_api.g_varchar2 and
3684 nvl(l_global_pen_rec.pen_attribute30,hr_api.g_varchar2) <>
3685 nvl(p_pen_attribute30,hr_api.g_varchar2)) then
3686 l_chg := TRUE;
3687 end if;
3688 --End Bug 4770367
3689
3690 if (l_chg) then
3691 l_step := 60;
3692
3693
3694 -- Check dt mode is valid
3695 --
3696 dt_api.find_dt_upd_modes
3697 (p_effective_date => p_effective_date,
3698 p_base_table_name => 'BEN_PRTT_ENRT_RSLT_F',
3699 p_base_key_column => 'prtt_enrt_rslt_id',
3700 p_base_key_value => p_prtt_enrt_rslt_id,
3701 p_correction => l_correction,
3702 p_update => l_update,
3703 p_update_override => l_update_override,
3704 p_update_change_insert => l_update_change_insert);
3705 --
3706 if l_update_override then
3707 --
3708 l_datetrack_mode := hr_api.g_update_override;
3709 --
3710 elsif l_update then
3711 --
3712 l_datetrack_mode := hr_api.g_update;
3713 --
3714 else
3715 --
3716 l_datetrack_mode := hr_api.g_correction;
3717 --
3718 end if;
3719 --
3720 -- Start of API User Hook for the before hook of
3721 -- update_PRTT_ENRT_RESULT
3722 --
3723 ben_PRTT_ENRT_RESULT_API.update_PRTT_ENRT_RESULT
3724 (p_validate => FALSE
3725 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
3726 ,p_effective_start_date => l_effective_start_date
3727 ,p_effective_end_date => l_effective_end_date
3728 ,p_business_group_id => p_business_group_id
3729 ,p_oipl_id => p_oipl_id
3730 ,p_person_id => p_person_id
3731 ,p_assignment_id => p_assignment_id
3732 ,p_pgm_id => p_pgm_id
3733 ,p_pl_id => p_pl_id
3734 ,p_rplcs_sspndd_rslt_id => p_rplcs_sspndd_rslt_id
3735 ,p_ptip_id => p_ptip_id
3736 ,p_pl_typ_id => p_pl_typ_id
3737 ,p_ler_id => p_ler_id
3738 ,p_sspndd_flag => p_sspndd_flag
3739 ,p_prtt_is_cvrd_flag => p_prtt_is_cvrd_flag
3740 ,p_bnft_amt => p_bnft_amt
3741 ,p_uom => p_uom
3742 ,p_orgnl_enrt_dt => p_orgnl_enrt_dt
3743 ,p_enrt_mthd_cd => p_enrt_mthd_cd
3744 ,p_enrt_ovridn_flag => p_enrt_ovridn_flag
3745 ,p_enrt_ovrid_rsn_cd => p_enrt_ovrid_rsn_cd
3746 ,p_erlst_deenrt_dt => p_erlst_deenrt_dt
3747 ,p_enrt_cvg_strt_dt => p_enrt_cvg_strt_dt
3748 ,p_enrt_cvg_thru_dt => p_enrt_cvg_thru_dt
3749 ,p_enrt_ovrid_thru_dt => p_enrt_ovrid_thru_dt
3750 ,p_pl_ordr_num => p_pl_ordr_num
3751 ,p_plip_ordr_num => p_plip_ordr_num
3752 ,p_ptip_ordr_num => p_ptip_ordr_num
3753 ,p_oipl_ordr_num => p_oipl_ordr_num
3754 ,p_pen_attribute_category => p_pen_attribute_category
3755 ,p_pen_attribute1 => p_pen_attribute1
3756 ,p_pen_attribute2 => p_pen_attribute2
3757 ,p_pen_attribute3 => p_pen_attribute3
3758 ,p_pen_attribute4 => p_pen_attribute4
3759 ,p_pen_attribute5 => p_pen_attribute5
3760 ,p_pen_attribute6 => p_pen_attribute6
3761 ,p_pen_attribute7 => p_pen_attribute7
3762 ,p_pen_attribute8 => p_pen_attribute8
3763 ,p_pen_attribute9 => p_pen_attribute9
3764 ,p_pen_attribute10 => p_pen_attribute10
3765 ,p_pen_attribute11 => p_pen_attribute11
3766 ,p_pen_attribute12 => p_pen_attribute12
3767 ,p_pen_attribute13 => p_pen_attribute13
3768 ,p_pen_attribute14 => p_pen_attribute14
3769 ,p_pen_attribute15 => p_pen_attribute15
3770 ,p_pen_attribute16 => p_pen_attribute16
3771 ,p_pen_attribute17 => p_pen_attribute17
3772 ,p_pen_attribute18 => p_pen_attribute18
3773 ,p_pen_attribute19 => p_pen_attribute19
3774 ,p_pen_attribute20 => p_pen_attribute20
3775 ,p_pen_attribute21 => p_pen_attribute21
3776 ,p_pen_attribute22 => p_pen_attribute22
3777 ,p_pen_attribute23 => p_pen_attribute23
3778 ,p_pen_attribute24 => p_pen_attribute24
3779 ,p_pen_attribute25 => p_pen_attribute25
3780 ,p_pen_attribute26 => p_pen_attribute26
3781 ,p_pen_attribute27 => p_pen_attribute27
3782 ,p_pen_attribute28 => p_pen_attribute28
3783 ,p_pen_attribute29 => p_pen_attribute29
3784 ,p_pen_attribute30 => p_pen_attribute30
3785 ,p_request_id => fnd_global.conc_request_id
3786 ,p_program_application_id => fnd_global.prog_appl_id
3787 ,p_program_id => fnd_global.conc_program_id
3788 ,p_program_update_date => sysdate
3789 ,p_object_version_number => l_object_version_number
3790 ,p_per_in_ler_id => p_per_in_ler_id
3791 ,p_bnft_typ_cd => p_bnft_typ_cd
3792 ,p_bnft_ordr_num => p_bnft_ordr_num
3793 ,p_prtt_enrt_rslt_stat_cd => p_prtt_enrt_rslt_stat_cd
3794 ,p_bnft_nnmntry_uom => p_bnft_nnmntry_uom
3795 ,p_comp_lvl_cd => p_comp_lvl_cd
3796 ,p_effective_date => trunc(p_effective_date)
3797 ,p_datetrack_mode => l_datetrack_mode
3798 ,p_multi_row_validate => p_multi_row_validate
3799 );
3800
3801 ben_global_enrt.reload_pen -- result globals re-loaded after update.
3802 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
3803 ,p_effective_date => p_effective_date
3804 ,p_global_pen_rec => l_global_pen_rec);
3805 ----call update for flex cedit entries for rate change
3806 if p_comp_lvl_cd in ('PLANFC', 'PLANIMP') then
3807 null;
3808 else
3809 if l_global_pen_rec.pgm_id is not null then
3810 open c_prtt_enrt;
3811 fetch c_prtt_enrt into l_prtt_enrt_rslt_id;
3812 close c_prtt_enrt;
3813 for i in c_flex_choice Loop
3814 l_prvdd_val := null;
3815 open c_bpl ( i.acty_base_rt_id ,
3816 i.bnft_prvdr_pool_id,
3817 l_prtt_enrt_rslt_id ) ;
3818 fetch c_bpl into l_prvdd_val ;
3819 close c_bpl ;
3820 --if there is amount change call the updating
3821 if g_debug then
3822 hr_utility.set_location( 'prvdd val ' || l_prvdd_val ||
3823 ' ; changed val ' || i.val , 1001);
3824 end if;
3825
3826 if l_prvdd_val is not null and l_prvdd_val <> i.val then
3827 ben_provider_pools.create_credit_ledger_entry
3828 ( p_person_id => p_person_id ,
3829 p_elig_per_elctbl_chc_id => i.elig_per_elctbl_chc_id ,
3830 p_per_in_ler_id => i.per_in_ler_id,
3831 p_business_group_id => p_business_group_id ,
3832 p_bnft_prvdr_pool_id => i.bnft_prvdr_pool_id,
3833 p_enrt_mthd_cd => p_enrt_mthd_cd,
3834 p_effective_date => p_effective_date );
3835 end if;
3836 end loop ;
3837 open c_elig_per_elctbl_chc;
3838 fetch c_elig_per_elctbl_chc into l_elig_per_elctbl_chc_id;
3839 close c_elig_per_elctbl_chc;
3840
3841 ben_provider_pools.accumulate_pools
3842 (p_validate => FALSE
3843 ,p_person_id => p_person_id
3844 ,p_elig_per_elctbl_chc_id => l_elig_per_elctbl_chc_id
3845 ,p_business_group_id => p_business_group_id
3846 ,p_enrt_mthd_cd => p_enrt_mthd_cd
3847 ,p_effective_date => p_effective_date
3848 );
3849
3850 end if; -- pgm_id is not null.
3851 end if;
3852
3853 for l_prem in c_prem loop
3854 l_step := 70;
3855 -- bug 158783. jcarpent reset l_ppe.prtt_prem_id
3856 l_ppe.prtt_prem_id:=null;
3857 /* Start of Changes for WWBUG: 1646442: added */
3858 open c_pel(l_prem.elig_per_elctbl_chc_id);
3859 fetch c_pel into l_pel;
3860 close c_pel;
3861
3862 ben_determine_date.rate_and_coverage_dates
3863 (p_which_dates_cd => 'R'
3864 ,p_date_mandatory_flag => 'Y'
3865 ,p_compute_dates_flag => 'Y'
3866 ,p_business_group_id => p_business_group_id
3867 ,P_PER_IN_LER_ID => p_per_in_ler_id
3868 ,P_PERSON_ID => p_person_id
3869 ,P_PGM_ID => p_pgm_id
3870 ,P_PL_ID => p_pl_id
3871 ,P_OIPL_ID => p_oipl_id
3872 ,P_LEE_RSN_ID => l_pel.lee_rsn_id
3873 ,P_ENRT_PERD_ID => l_pel.enrt_perd_id
3874 ,p_enrt_cvg_strt_dt => l_enrt_cvg_strt_dt --out
3875 ,p_enrt_cvg_strt_dt_cd => l_enrt_cvg_strt_dt_cd --out
3876 ,p_enrt_cvg_strt_dt_rl => l_enrt_cvg_strt_dt_rl --out
3877 ,p_rt_strt_dt => l_rt_strt_dt --out
3878 ,p_rt_strt_dt_cd => l_rt_strt_dt_cd --out
3879 ,p_rt_strt_dt_rl => l_rt_strt_dt_rl --out
3880 ,p_enrt_cvg_end_dt => l_enrt_cvg_end_dt --out
3881 ,p_enrt_cvg_end_dt_cd => l_enrt_cvg_end_dt_cd --out
3882 ,p_enrt_cvg_end_dt_rl => l_enrt_cvg_end_dt_rl --out
3883 ,p_rt_end_dt => l_rt_end_dt --out
3884 ,p_rt_end_dt_cd => l_rt_end_dt_cd --out
3885 ,p_rt_end_dt_rl => l_rt_end_dt_rl --out
3886 ,p_effective_date => p_effective_date
3887 ,p_lf_evt_ocrd_dt => nvl(l_prem.lf_evt_ocrd_dt,p_effective_date)
3888 );
3889
3890 l_ppe_dt_to_use := greatest(p_enrt_cvg_strt_dt,l_rt_strt_dt);
3891 /* End of Changes for WWBUG: 1646442 */
3892 /*
3893 CODE PRIOR TO WWBUG: 1646442
3894 open c_ppe(p_prtt_enrt_rslt_id, l_prem.actl_prem_id);
3895 */
3896 /* Start of Changes for WWBUG: 1646442 */
3897 open c_ppe(p_prtt_enrt_rslt_id, l_prem.actl_prem_id,l_ppe_dt_to_use);
3898 /* End of Changes for WWBUG: 1646442 */
3899 fetch c_ppe into l_ppe;
3900 close c_ppe;
3901 l_step := 71;
3902 if l_ppe.prtt_prem_id is not null then
3903 /********************* CODE PRIOR TO WWBUG: 1646442 *****
3904 *** moved this code below ****
3905 --
3906 -- Find the valid datetrack modes.
3907 --
3908 dt_api.find_dt_upd_modes
3909 (p_effective_date => p_effective_date,
3910 p_base_table_name => 'BEN_PRTT_PREM_F',
3911 p_base_key_column => 'prtt_prem_id',
3912 p_base_key_value => l_ppe.prtt_prem_id,
3913 p_correction => l_correction,
3914 p_update => l_update,
3915 p_update_override => l_update_override,
3916 p_update_change_insert => l_update_change_insert);
3917 --
3918 if l_update_override then
3919 --
3920 l_ppe_datetrack_mode := hr_api.g_update_override;
3921 --
3922 elsif l_update then
3923 --
3924 l_ppe_datetrack_mode := hr_api.g_update;
3925 --
3926 else
3927 --
3928 l_ppe_datetrack_mode := hr_api.g_correction;
3929 end if;
3930 ********************* END CODE PRIOR TO WWBUG: 1646442 *********/
3931 -- Because the benefit amount could have changed, and the premiums
3932 -- can be based on the benefit amount, re-calc it. It does a recalc
3933 -- if the benefit amount is entered at enrollment.
3934 -- PPE is from prtt-prem. prem is from enrt-prem.
3935 ben_PRTT_PREM_api.recalc_PRTT_PREM
3936 (p_prtt_prem_id => l_ppe.prtt_prem_id
3937 ,p_std_prem_uom => l_prem.uom
3938 ,p_std_prem_val => l_prem.val -- in/out
3939 ,p_actl_prem_id => l_prem.actl_prem_id
3940 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
3941 ,p_per_in_ler_id => p_per_in_ler_id
3942 ,p_ler_id => l_prem.ler_id
3943 ,p_lf_evt_ocrd_dt => l_prem.lf_evt_ocrd_dt
3944 ,p_elig_per_elctbl_chc_id => l_prem.elig_per_elctbl_chc_id
3945 ,p_enrt_bnft_id => p_enrt_bnft_id
3946 ,p_business_group_id => p_business_group_id
3947 ,p_effective_date => p_effective_date
3948 -- bof FONM
3949 ,p_enrt_cvg_strt_dt => nvl(l_enrt_cvg_strt_dt,l_ppe_dt_to_use)
3950 ,p_rt_strt_dt => l_rt_strt_dt
3951 -- eof FONM
3952 );
3953
3954 l_step := 72;
3955 ---For the Bug : 7133998
3956
3957 hr_utility.set_location('p_prtt_enrt_rslt_id,srav : '||p_prtt_enrt_rslt_id,1);
3958 hr_utility.set_location('l_prem.actl_prem_id : '||l_prem.actl_prem_id,1);
3959 hr_utility.set_location('l_ppe_dt_to_use : '||l_ppe_dt_to_use,1);
3960
3961 -----check if there are any future rows corresponding to the Previous LE's.
3962 --------7133998
3963 l_count := 0;
3964 hr_utility.set_location('srav,in else',1);
3965 for l_ppe1 in c_ppe1(p_prtt_enrt_rslt_id, l_prem.actl_prem_id,l_ppe_dt_to_use) loop
3966 l_count := l_count + 1;
3967 hr_utility.set_location('c_ppe1 found',1);
3968 hr_utility.set_location('l_ppe1.prtt_prem_id : '||l_ppe1.prtt_prem_id,1);
3969 ---bkup table
3970 insert into BEN_LE_CLSN_N_RSTR (
3971 BKUP_TBL_TYP_CD,
3972 LCR_ATTRIBUTE6,
3973 LCR_ATTRIBUTE7,
3974 LCR_ATTRIBUTE8,
3975 LCR_ATTRIBUTE9,
3976 LCR_ATTRIBUTE10,
3977 LCR_ATTRIBUTE11,
3978 LCR_ATTRIBUTE12,
3979 LCR_ATTRIBUTE13,
3980 LCR_ATTRIBUTE14,
3981 LCR_ATTRIBUTE15,
3982 LCR_ATTRIBUTE16,
3983 LCR_ATTRIBUTE17,
3984 LCR_ATTRIBUTE18,
3985 LCR_ATTRIBUTE19,
3986 LCR_ATTRIBUTE20,
3987 LCR_ATTRIBUTE21,
3988 LCR_ATTRIBUTE22,
3989 LCR_ATTRIBUTE23,
3990 LCR_ATTRIBUTE24,
3991 LCR_ATTRIBUTE25,
3992 LCR_ATTRIBUTE26,
3993 LCR_ATTRIBUTE27,
3994 LCR_ATTRIBUTE28,
3995 LCR_ATTRIBUTE29,
3996 LCR_ATTRIBUTE30,
3997 LAST_UPDATE_DATE,
3998 LAST_UPDATED_BY,
3999 LAST_UPDATE_LOGIN,
4000 CREATED_BY,
4001 CREATION_DATE,
4002 OBJECT_VERSION_NUMBER,
4003 REQUEST_ID,
4004 PROGRAM_APPLICATION_ID,
4005 PROGRAM_ID,
4006 PROGRAM_UPDATE_DATE,
4007 PER_IN_LER_ID,
4008 PER_IN_LER_ENDED_ID,
4009 BKUP_TBL_ID, -- PRTT_PREM_ID,
4010 EFFECTIVE_START_DATE,
4011 EFFECTIVE_END_DATE,
4012 STD_PREM_UOM,
4013 STD_PREM_VAL,
4014 ACTL_PREM_ID,
4015 PRTT_ENRT_RSLT_ID,
4016 BUSINESS_GROUP_ID,
4017 LCR_ATTRIBUTE_CATEGORY,
4018 LCR_ATTRIBUTE1,
4019 LCR_ATTRIBUTE2,
4020 LCR_ATTRIBUTE3,
4021 LCR_ATTRIBUTE4,
4022 LCR_ATTRIBUTE5
4023 )
4024 values (
4025 'BEN_PRTT_PREM_F_CORR',
4026 l_ppe1.PPE_ATTRIBUTE6,
4027 l_ppe1.PPE_ATTRIBUTE7,
4028 l_ppe1.PPE_ATTRIBUTE8,
4029 l_ppe1.PPE_ATTRIBUTE9,
4030 l_ppe1.PPE_ATTRIBUTE10,
4031 l_ppe1.PPE_ATTRIBUTE11,
4032 l_ppe1.PPE_ATTRIBUTE12,
4033 l_ppe1.PPE_ATTRIBUTE13,
4034 l_ppe1.PPE_ATTRIBUTE14,
4035 l_ppe1.PPE_ATTRIBUTE15,
4036 l_ppe1.PPE_ATTRIBUTE16,
4037 l_ppe1.PPE_ATTRIBUTE17,
4038 l_ppe1.PPE_ATTRIBUTE18,
4039 l_ppe1.PPE_ATTRIBUTE19,
4040 l_ppe1.PPE_ATTRIBUTE20,
4041 l_ppe1.PPE_ATTRIBUTE21,
4042 l_ppe1.PPE_ATTRIBUTE22,
4043 l_ppe1.PPE_ATTRIBUTE23,
4044 l_ppe1.PPE_ATTRIBUTE24,
4045 l_ppe1.PPE_ATTRIBUTE25,
4046 l_ppe1.PPE_ATTRIBUTE26,
4047 l_ppe1.PPE_ATTRIBUTE27,
4048 l_ppe1.PPE_ATTRIBUTE28,
4049 l_ppe1.PPE_ATTRIBUTE29,
4050 l_ppe1.PPE_ATTRIBUTE30,
4051 l_ppe1.LAST_UPDATE_DATE,
4052 l_ppe1.LAST_UPDATED_BY,
4053 l_ppe1.LAST_UPDATE_LOGIN,
4054 l_ppe1.CREATED_BY,
4055 l_ppe1.CREATION_DATE,
4056 l_ppe1.OBJECT_VERSION_NUMBER,
4057 l_ppe1.REQUEST_ID,
4058 l_ppe1.PROGRAM_APPLICATION_ID,
4059 l_ppe1.PROGRAM_ID,
4060 l_ppe1.PROGRAM_UPDATE_DATE,
4061 l_ppe1.PER_IN_LER_ID,
4062 p_per_in_ler_id,
4063 l_ppe1.PRTT_PREM_ID,
4064 l_ppe1.EFFECTIVE_START_DATE,
4065 l_ppe1.EFFECTIVE_END_DATE,
4066 l_ppe1.STD_PREM_UOM,
4067 l_ppe1.STD_PREM_VAL,
4068 l_ppe1.ACTL_PREM_ID,
4069 l_ppe1.PRTT_ENRT_RSLT_ID,
4070 l_ppe1.BUSINESS_GROUP_ID,
4071 l_ppe1.PPE_ATTRIBUTE_CATEGORY,
4072 l_ppe1.PPE_ATTRIBUTE1,
4073 l_ppe1.PPE_ATTRIBUTE2,
4074 l_ppe1.PPE_ATTRIBUTE3,
4075 l_ppe1.PPE_ATTRIBUTE4,
4076 l_ppe1.PPE_ATTRIBUTE5
4077 );
4078
4079 ben_prtt_prem_api.update_prtt_prem
4080 ( p_validate => FALSE
4081 ,p_prtt_prem_id => l_ppe1.prtt_prem_id
4082 ,p_effective_start_date => p_effective_start_date
4083 ,p_effective_end_date => p_effective_end_date
4084 ,p_per_in_ler_id => p_per_in_ler_id
4085 ,p_business_group_id => p_business_group_id
4086 ,p_prtt_enrt_rslt_id => l_ppe1.prtt_enrt_rslt_id
4087 ,p_object_version_number => l_ppe1.object_version_number
4088 ,p_request_id => fnd_global.conc_request_id
4089 ,p_program_application_id => fnd_global.prog_appl_id
4090 ,p_program_id => fnd_global.conc_program_id
4091 ,p_program_update_date => sysdate
4092 ,p_effective_date => l_ppe1.effective_start_date
4093 ,p_datetrack_mode => 'CORRECTION'
4094
4095 );
4096 end loop;
4097 open c_ppe(p_prtt_enrt_rslt_id, l_prem.actl_prem_id,l_ppe_dt_to_use);
4098 fetch c_ppe into l_ppe;
4099 close c_ppe;
4100 /* Start of Changes for WWBUG: 1646442 */
4101 /* moved from above */
4102 --
4103 If l_count = 0 then --------7133998
4104 -- Find the valid datetrack modes.
4105 --
4106 dt_api.find_dt_upd_modes
4107 (p_effective_date => l_ppe_dt_to_use,
4108 p_base_table_name => 'BEN_PRTT_PREM_F',
4109 p_base_key_column => 'prtt_prem_id',
4110 p_base_key_value => l_ppe.prtt_prem_id,
4111 p_correction => l_correction,
4112 p_update => l_update,
4113 p_update_override => l_update_override,
4114 p_update_change_insert => l_update_change_insert);
4115
4116 if l_update_override then
4117 --
4118 l_ppe_datetrack_mode := hr_api.g_update_override;
4119 --
4120 elsif l_update then
4121 --
4122 l_ppe_datetrack_mode := hr_api.g_update;
4123 --
4124 else
4125 --
4126 l_ppe_datetrack_mode := hr_api.g_correction;
4127 end if;
4128 /* End of Changes for WWBUG: 1646442 */
4129
4130 ben_prtt_prem_api.update_prtt_prem
4131 ( p_validate => FALSE
4132 ,p_prtt_prem_id => l_ppe.prtt_prem_id
4133 ,p_effective_start_date => p_effective_start_date
4134 ,p_effective_end_date => p_effective_end_date
4135 ,p_std_prem_uom => l_prem.uom
4136 ,p_std_prem_val => l_prem.val
4137 ,p_actl_prem_id => l_prem.actl_prem_id
4138 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
4139 ,p_per_in_ler_id => p_per_in_ler_id
4140 ,p_business_group_id => p_business_group_id
4141 ,p_object_version_number => l_ppe.object_version_number
4142 ,p_request_id => fnd_global.conc_request_id
4143 ,p_program_application_id => fnd_global.prog_appl_id
4144 ,p_program_id => fnd_global.conc_program_id
4145 ,p_program_update_date => sysdate
4146 /*
4147 CODE PRIOR TO WWBUG: 1646442
4148 ,p_effective_date => p_effective_date
4149 */
4150 /* Start of Changes for WWBUG: 1646442 */
4151 ,p_effective_date => l_ppe_dt_to_use
4152 /* End of Changes for WWBUG: 1646442 */
4153 ,p_datetrack_mode => l_ppe_datetrack_mode
4154 );
4155 end if;------7133998
4156 else
4157 ben_PRTT_PREM_api.recalc_PRTT_PREM
4158 (p_prtt_prem_id => null
4159 ,p_std_prem_uom => l_prem.uom
4160 ,p_std_prem_val => l_prem.val -- in/out
4161 ,p_actl_prem_id => l_prem.actl_prem_id
4162 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
4163 ,p_per_in_ler_id => p_per_in_ler_id
4164 ,p_ler_id => l_prem.ler_id
4165 ,p_lf_evt_ocrd_dt => l_prem.lf_evt_ocrd_dt
4166 ,p_elig_per_elctbl_chc_id => l_prem.elig_per_elctbl_chc_id
4167 ,p_enrt_bnft_id => p_enrt_bnft_id
4168 ,p_business_group_id => p_business_group_id
4169 ,p_effective_date => p_effective_date
4170 -- bof FONM
4171 ,p_enrt_cvg_strt_dt => nvl(l_enrt_cvg_strt_dt,l_ppe_dt_to_use)
4172 ,p_rt_strt_dt => l_rt_strt_dt
4173 -- eof FONM
4174 );
4175 l_step := 130;
4176 ben_prtt_prem_api.create_prtt_prem
4177 ( p_validate => FALSE
4178 ,p_prtt_prem_id => l_ppe.prtt_prem_id
4179 ,p_effective_start_date => p_effective_start_date
4180 ,p_effective_end_date => p_effective_end_date
4181 ,p_std_prem_uom => l_prem.uom
4182 ,p_std_prem_val => l_prem.val
4183 ,p_actl_prem_id => l_prem.actl_prem_id
4184 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
4185 ,p_per_in_ler_id => p_per_in_ler_id
4186 ,p_business_group_id => p_business_group_id
4187 ,p_object_version_number => l_ppe.object_version_number
4188 ,p_request_id => fnd_global.conc_request_id
4189 ,p_program_application_id => fnd_global.prog_appl_id
4190 ,p_program_id => fnd_global.conc_program_id
4191 ,p_program_update_date => sysdate
4192 /*
4193 CODE PRIOR TO WWBUG: 1646442
4194 ,p_effective_date => p_effective_date
4195 */
4196 /* Start of Changes for WWBUG: 1646442 */
4197 ,p_effective_date => l_ppe_dt_to_use
4198 /* End of Changes for WWBUG: 1646442 */
4199 );
4200 --
4201 end if;
4202 end loop;
4203
4204 --9881657
4205 calc_dpnt_cvg_dt
4206 (p_calc_end_dt => TRUE
4207 ,P_calc_strt_dt => FALSE
4208 ,p_per_in_ler_id => p_per_in_ler_id
4209 ,P_person_id => p_person_id
4210 ,p_pgm_id => p_pgm_id
4211 ,p_pl_id => p_pl_id
4212 ,p_oipl_id => p_oipl_id
4213 ,p_ptip_id => p_ptip_id
4214 ,p_ler_id => p_ler_id
4215 ,P_BUSINESS_GROUP_ID => p_business_group_id
4216 ,P_EFFECTIVE_DATE => p_effective_date
4217 ,P_RETURNED_END_DT => l_dpnt_cvg_end_dt
4218 ,P_RETURNED_STRT_DT => l_dump_date
4219 ,p_enrt_cvg_end_dt => l_enrt_cvg_end_dt
4220 );
4221
4222 l_dpnt_cvg_thru_dt := l_dpnt_cvg_end_dt;
4223 hr_utility.set_location('9881657 l_dpnt_cvg_thru_dt ' || l_dpnt_cvg_thru_dt, 123.123);
4224 --9881657
4225
4226 --------Bug 8919376
4227 for l_chk_cvrd_dpnt in c_check_cvrd_dpnt(l_dpnt_cvg_thru_dt) loop --9881657
4228 ben_elig_dpnt_api.update_perf_elig_dpnt
4229 (p_elig_dpnt_id => l_chk_cvrd_dpnt.elig_dpnt_id
4230 ,p_per_in_ler_id => l_chk_cvrd_dpnt.per_in_ler_id
4231 ,p_elig_thru_dt => l_chk_cvrd_dpnt.elig_thru_dt
4232 ,p_elig_cvrd_dpnt_id => l_chk_cvrd_dpnt.cvrd_dpnt_id
4233 ,p_object_version_number => l_chk_cvrd_dpnt.object_version_number
4234 ,p_effective_date => l_chk_cvrd_dpnt.create_dt
4235 ,p_program_application_id => fnd_global.prog_appl_id
4236 ,p_program_id => fnd_global.conc_program_id
4237 ,p_request_id => fnd_global.conc_request_id
4238 ,p_program_update_date => sysdate
4239 );
4240 end loop;
4241 ----------Bug 8919376
4242 -- un-end dpnt coverage for existing dependents.
4243 for l_egd in c_egd(l_dpnt_cvg_thru_dt) loop --9881657
4244
4245 ----Bug 9748558
4246 ---check if corresponding to the same per_in_ler,any other records exists with same pdp_id
4247 open c_check_dup_dep(l_egd.elig_cvrd_dpnt_id);
4248 fetch c_check_dup_dep into l_check_dup_dep;
4249 if c_check_dup_dep%found then
4250 hr_utility.set_location('dup dep row found',1);
4251 hr_utility.set_location('pdp_id : '||l_check_dup_dep.elig_cvrd_dpnt_id,1);
4252 ---Get the previous pil,which has enrollment result attached to it.
4253 open c_get_last_pil;
4254 fetch c_get_last_pil into l_get_last_pil;
4255 if c_get_last_pil%found then
4256 hr_utility.set_location('pil_id : '||l_get_last_pil.per_in_ler_id,1);
4257 open c_last_pil_pdp(l_get_last_pil.per_in_ler_id,l_egd.elig_cvrd_dpnt_id);
4258 fetch c_last_pil_pdp into l_last_pil_pdp;
4259 if c_last_pil_pdp%found then
4260 hr_utility.set_location('last pil pdp found',1);
4261 hr_utility.set_location('l_last_pil_pdp.elig_cvrd_dpnt_id : '|| l_last_pil_pdp.elig_cvrd_dpnt_id,1);
4262 hr_utility.set_location('l_last_pil_pdp.effective_start_date : '|| l_last_pil_pdp.effective_start_date,1);
4263 hr_utility.set_location('l_last_pil_pdp.object_version_number : '|| l_last_pil_pdp.object_version_number,1);
4264 ben_elig_cvrd_dpnt_api.delete_elig_cvrd_dpnt
4265 (p_validate => FALSE
4266 ,p_elig_cvrd_dpnt_id => l_last_pil_pdp.elig_cvrd_dpnt_id
4267 ,p_effective_start_date => p_effective_start_date
4268 ,p_business_group_id => p_business_group_id
4269 ,p_effective_end_date => p_effective_end_date
4270 ,p_object_version_number => l_last_pil_pdp.object_version_number
4271 ,p_effective_date => l_last_pil_pdp.effective_start_date
4272 ,p_datetrack_mode => hr_api.g_future_change
4273 ,p_multi_row_actn => FALSE
4274 ,p_called_from => 'UPDATE_ENROLLMENT'
4275 );
4276 end if;
4277 close c_last_pil_pdp;
4278 ---re-fetch the OVN
4279 open c_last_pil_pdp(l_get_last_pil.per_in_ler_id,l_egd.elig_cvrd_dpnt_id);
4280 fetch c_last_pil_pdp into l_last_pil_pdp;
4281 if c_last_pil_pdp%found then
4282 hr_utility.set_location('l_last_pil_pdp.object_version_number : '|| l_last_pil_pdp.object_version_number,1);
4283 l_egd.object_version_number := l_last_pil_pdp.object_version_number;
4284 end if;
4285 close c_last_pil_pdp;
4286 end if;
4287 close c_get_last_pil;
4288 end if;
4289 close c_check_dup_dep;
4290 ----Bug 9748558
4291 --
4292 -- Find the valid datetrack modes.
4293 --
4294 dt_api.find_dt_upd_modes
4295 (p_effective_date => p_effective_date,
4296 p_base_table_name => 'BEN_ELIG_CVRD_DPNT_F',
4297 p_base_key_column => 'elig_cvrd_dpnt_id',
4298 p_base_key_value => l_egd.elig_cvrd_dpnt_id,
4299 p_correction => l_correction,
4300 p_update => l_update,
4301 p_update_override => l_update_override,
4302 p_update_change_insert => l_update_change_insert);
4303
4304 if l_update_override then
4305 l_egd_datetrack_mode := hr_api.g_update_override;
4306 elsif l_update then
4307 l_egd_datetrack_mode := hr_api.g_update;
4308 else
4309 l_egd_datetrack_mode := hr_api.g_correction;
4310 end if;
4311
4312 --9881657
4313 l_new_dpnt_cvg_thru_dt := hr_api.g_eot;
4314 if l_egd.cvg_thru_dt <> hr_api.g_eot then
4315 l_new_dpnt_cvg_thru_dt := l_dpnt_cvg_thru_dt;
4316 end if;
4317 hr_utility.set_location('9881657 l_new_dpnt_cvg_thru_dt' || l_new_dpnt_cvg_thru_dt, 123.123);
4318 --9881657
4319
4320 ben_elig_cvrd_dpnt_api.update_elig_cvrd_dpnt(
4321 p_elig_cvrd_dpnt_id => l_egd.elig_cvrd_dpnt_id,
4322 p_effective_start_date => p_effective_start_date,
4323 p_effective_end_date => p_effective_end_date,
4324 p_business_group_id => p_business_group_id,
4325 p_per_in_ler_id => p_per_in_ler_id,
4326 p_cvg_thru_dt => l_new_dpnt_cvg_thru_dt, --9881657
4327 p_object_version_number => l_egd.object_version_number,
4328 p_datetrack_mode => l_egd_datetrack_mode,
4329 p_request_id => fnd_global.conc_request_id,
4330 p_program_application_id => fnd_global.prog_appl_id,
4331 p_program_id => fnd_global.conc_program_id,
4332 p_program_update_date => sysdate,
4333 p_effective_date => p_effective_date,
4334 p_multi_row_actn => FALSE);
4335 --
4336 -- Bug 1418754
4337 --
4338 ben_ELIG_CVRD_DPNT_api.chk_max_num_dpnt_for_pen (
4339 p_prtt_enrt_rslt_id => p_PRTT_ENRT_RSLT_ID,
4340 p_effective_date => p_effective_date,
4341 p_business_group_id => p_business_group_id);
4342 --
4343 end loop;
4344 --
4345 -- write to the change event log. thayden.
4346 --
4347 ben_ext_chlg.log_benefit_chg
4348 (p_action => 'UPDATE'
4349 ,p_pl_id => p_pl_id
4350 ,p_old_pl_id => l_global_pen_rec.pl_id
4351 ,p_oipl_id => p_oipl_id
4352 ,p_old_oipl_id => l_global_pen_rec.oipl_id
4353 ,p_enrt_cvg_strt_dt => p_enrt_cvg_strt_dt
4354 ,p_old_enrt_cvg_strt_dt => l_global_pen_rec.enrt_cvg_strt_dt
4355 ,p_bnft_amt => p_bnft_amt
4356 ,p_old_bnft_amt => l_global_pen_rec.bnft_amt
4357 ,p_pen_attribute1 => p_pen_attribute1
4358 ,p_old_pen_attribute1 => l_global_pen_rec.pen_attribute1
4359 ,p_pen_attribute2 => p_pen_attribute2
4360 ,p_old_pen_attribute2 => l_global_pen_rec.pen_attribute2
4361 ,p_pen_attribute3 => p_pen_attribute3
4362 ,p_old_pen_attribute3 => l_global_pen_rec.pen_attribute3
4363 ,p_pen_attribute4 => p_pen_attribute4
4364 ,p_old_pen_attribute4 => l_global_pen_rec.pen_attribute4
4365 ,p_pen_attribute5 => p_pen_attribute5
4366 ,p_old_pen_attribute5 => l_global_pen_rec.pen_attribute5
4367 ,p_pen_attribute6 => p_pen_attribute6
4368 ,p_old_pen_attribute6 => l_global_pen_rec.pen_attribute6
4369 ,p_pen_attribute7 => p_pen_attribute7
4370 ,p_old_pen_attribute7 => l_global_pen_rec.pen_attribute7
4371 ,p_pen_attribute8 => p_pen_attribute8
4372 ,p_old_pen_attribute8 => l_global_pen_rec.pen_attribute8
4373 ,p_pen_attribute9 => p_pen_attribute9
4374 ,p_old_pen_attribute9 => l_global_pen_rec.pen_attribute9
4375 ,p_pen_attribute10 => p_pen_attribute10
4376 ,p_old_pen_attribute10 => l_global_pen_rec.pen_attribute10
4377 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
4378 ,p_per_in_ler_id => l_global_pen_rec.per_in_ler_id
4379 ,p_person_id => p_person_id
4380 ,p_business_group_id => p_business_group_id
4381 ,p_effective_date => p_effective_date
4382 );
4383 -- Bug 3866580
4384 --
4385 -- Find out the Option Type of Plan Type of the Plan being enrolled in
4386 /*
4387 It is better to go by savings plan flag rather option type code as
4388 the type code is only informational
4389 open c_pl_typ_opt_typ_cd (l_pl_rec.pl_typ_id, p_effective_date);
4390 fetch c_pl_typ_opt_typ_cd into l_pl_typ_opt_typ_cd;
4391 close c_pl_typ_opt_typ_cd;
4392 --
4393 */
4394 if ( l_pl_rec.svgs_pl_flag = 'Y' and p_oipl_id is null and l_pl_rec.ENRT_PL_OPT_FLAG = 'Y' )
4395 or ( l_pl_rec.svgs_pl_flag = 'N')
4396 then
4397 /*
4398 if ( l_pl_typ_opt_typ_cd = 'SVG' and p_oipl_id is null and l_pl_rec.ENRT_PL_OPT_FLAG = 'Y' )
4399 or ( nvl(l_pl_typ_opt_typ_cd, 'XXXX') <> 'SVG' )
4400 then
4401 /*
4402 Commented this part, as Enrollment Action Items for all enrollment in "Plans"
4403 as well as "Option In Plans" should be determined except for savings plan. In case
4404 of savings plan, enrollment actions items should be determined only if enrollment is in
4405 plan level (i.e. p_oipl_id = NULL
4406 --
4407 If l_pl_rec.enrt_pl_opt_flag = 'N'
4408 or (l_pl_rec.enrt_pl_opt_flag = 'Y' and l_global_pen_rec.oipl_id is NULL) then
4409 */
4410 l_step := 165;
4411 ben_enrollment_action_items.determine_action_items
4412 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
4413 ,p_effective_date => p_effective_date
4414 ,p_business_group_id => p_business_group_id
4415 ,p_datetrack_mode => l_datetrack_mode
4416 ,p_suspend_flag => p_suspend_flag
4417 ,p_rslt_object_version_number => l_object_version_number
4418 ,p_enrt_bnft_id => p_enrt_bnft_id
4419 ,p_post_rslt_flag => l_post_rslt_flag
4420 ,p_dpnt_actn_warning => p_dpnt_actn_warning
4421 ,p_bnf_actn_warning => p_bnf_actn_warning
4422 ,p_ctfn_actn_warning => p_ctfn_actn_warning
4423 );
4424 ben_global_enrt.get_pen -- result
4425 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
4426 ,p_effective_date => p_effective_date
4427 ,p_global_pen_rec => l_global_pen_rec);
4428 l_step :=71;
4429 open c_interim_enrt;
4430 fetch c_interim_enrt into p_prtt_enrt_interim_id;
4431 close c_interim_enrt;
4432 else
4433 -- set the out parms that would have come from action item.
4434 p_dpnt_actn_warning := false;
4435 p_bnf_actn_warning := false;
4436 p_ctfn_actn_warning := false;
4437 p_suspend_flag := l_global_pen_rec.sspndd_flag;
4438 if l_global_pen_rec.sspndd_flag='Y' then
4439 open c_interim_enrt;
4440 fetch c_interim_enrt into p_prtt_enrt_interim_id;
4441 close c_interim_enrt;
4442 end if;
4443 end if;
4444 end if;
4445 if g_debug then
4446 hr_utility.set_location(l_proc, 60);
4447 end if;
4448 --
4449 -- When in validation only mode raise the Validate_Enabled exception
4450 --
4451 if p_validate then
4452 raise hr_api.validate_enabled;
4453 end if;
4454 --
4455 -- Set all output arguments
4456 --
4457 p_object_version_number := l_object_version_number;
4458 p_effective_start_date := l_effective_start_date;
4459 p_effective_end_date := l_effective_end_date;
4460 if g_debug then
4461 hr_utility.set_location(' Leaving:'||l_proc, 70);
4462 end if;
4463 exception
4464 when hr_api.validate_enabled then
4465 --
4466 -- As the Validate_Enabled exception has been raised
4467 -- we must rollback to the savepoint
4468 --
4469 ROLLBACK TO update_ENROLLMENT;
4470 --
4471 -- Only set output warning arguments
4472 -- (Any key or derived arguments must be set to null
4473 -- when validation only mode is being used.)
4474 --
4475 if g_debug then
4476 hr_utility.set_location(' Leaving:'||l_proc, 80);
4477 end if;
4478 when others then
4479 --
4480 -- A validation or unexpected error has occured
4481 --
4482 ROLLBACK TO update_ENROLLMENT;
4483 rpt_error(p_proc => l_proc, p_step => l_step);
4484 p_effective_start_date := null; --nocopy change
4485 p_effective_end_date := null; --nocopy change
4486 raise;
4487 end update_ENROLLMENT;
4488 --
4489 -- ----------------------------------------------------------------------------
4490 -- |------------------------< update_PRTT_ENRT_RESULT >--- ------------------|
4491 -- ----------------------------------------------------------------------------
4492 --
4493 procedure update_PRTT_ENRT_RESULT
4494 (p_validate in boolean default false
4495 ,p_prtt_enrt_rslt_id in number
4496 ,p_effective_start_date out nocopy date
4497 ,p_effective_end_date out nocopy date
4498 ,p_business_group_id in number default hr_api.g_number
4499 ,p_oipl_id in number default hr_api.g_number
4500 ,p_person_id in number default hr_api.g_number
4501 ,p_assignment_id in number default hr_api.g_number
4502 ,p_pgm_id in number default hr_api.g_number
4503 ,p_pl_id in number default hr_api.g_number
4504 ,p_rplcs_sspndd_rslt_id in number default hr_api.g_number
4505 ,p_ptip_id in number default hr_api.g_number
4506 ,p_pl_typ_id in number default hr_api.g_number
4507 ,p_ler_id in number default hr_api.g_number
4508 ,p_sspndd_flag in varchar2 default hr_api.g_varchar2
4509 ,p_prtt_is_cvrd_flag in varchar2 default hr_api.g_varchar2
4510 ,p_bnft_amt in number default hr_api.g_number
4511 ,p_uom in varchar2 default hr_api.g_varchar2
4512 ,p_orgnl_enrt_dt in date default hr_api.g_date
4513 ,p_enrt_mthd_cd in varchar2 default hr_api.g_varchar2
4514 ,p_no_lngr_elig_flag in varchar2 default hr_api.g_varchar2
4515 ,p_enrt_ovridn_flag in varchar2 default hr_api.g_varchar2
4516 ,p_enrt_ovrid_rsn_cd in varchar2 default hr_api.g_varchar2
4517 ,p_erlst_deenrt_dt in date default hr_api.g_date
4518 ,p_enrt_cvg_strt_dt in date default hr_api.g_date
4519 ,p_enrt_cvg_thru_dt in date default hr_api.g_date
4520 ,p_enrt_ovrid_thru_dt in date default hr_api.g_date
4521 ,p_pl_ordr_num in number default hr_api.g_number
4522 ,p_plip_ordr_num in number default hr_api.g_number
4523 ,p_ptip_ordr_num in number default hr_api.g_number
4524 ,p_oipl_ordr_num in number default hr_api.g_number
4525 ,p_pen_attribute_category in varchar2 default hr_api.g_varchar2
4526 ,p_pen_attribute1 in varchar2 default hr_api.g_varchar2
4527 ,p_pen_attribute2 in varchar2 default hr_api.g_varchar2
4528 ,p_pen_attribute3 in varchar2 default hr_api.g_varchar2
4529 ,p_pen_attribute4 in varchar2 default hr_api.g_varchar2
4530 ,p_pen_attribute5 in varchar2 default hr_api.g_varchar2
4531 ,p_pen_attribute6 in varchar2 default hr_api.g_varchar2
4532 ,p_pen_attribute7 in varchar2 default hr_api.g_varchar2
4533 ,p_pen_attribute8 in varchar2 default hr_api.g_varchar2
4534 ,p_pen_attribute9 in varchar2 default hr_api.g_varchar2
4535 ,p_pen_attribute10 in varchar2 default hr_api.g_varchar2
4536 ,p_pen_attribute11 in varchar2 default hr_api.g_varchar2
4537 ,p_pen_attribute12 in varchar2 default hr_api.g_varchar2
4538 ,p_pen_attribute13 in varchar2 default hr_api.g_varchar2
4539 ,p_pen_attribute14 in varchar2 default hr_api.g_varchar2
4540 ,p_pen_attribute15 in varchar2 default hr_api.g_varchar2
4541 ,p_pen_attribute16 in varchar2 default hr_api.g_varchar2
4542 ,p_pen_attribute17 in varchar2 default hr_api.g_varchar2
4543 ,p_pen_attribute18 in varchar2 default hr_api.g_varchar2
4544 ,p_pen_attribute19 in varchar2 default hr_api.g_varchar2
4545 ,p_pen_attribute20 in varchar2 default hr_api.g_varchar2
4546 ,p_pen_attribute21 in varchar2 default hr_api.g_varchar2
4547 ,p_pen_attribute22 in varchar2 default hr_api.g_varchar2
4548 ,p_pen_attribute23 in varchar2 default hr_api.g_varchar2
4549 ,p_pen_attribute24 in varchar2 default hr_api.g_varchar2
4550 ,p_pen_attribute25 in varchar2 default hr_api.g_varchar2
4551 ,p_pen_attribute26 in varchar2 default hr_api.g_varchar2
4552 ,p_pen_attribute27 in varchar2 default hr_api.g_varchar2
4553 ,p_pen_attribute28 in varchar2 default hr_api.g_varchar2
4554 ,p_pen_attribute29 in varchar2 default hr_api.g_varchar2
4555 ,p_pen_attribute30 in varchar2 default hr_api.g_varchar2
4556 ,p_request_id in number default hr_api.g_number
4557 ,p_program_application_id in number default hr_api.g_number
4558 ,p_program_id in number default hr_api.g_number
4559 ,p_program_update_date in date default hr_api.g_date
4560 ,p_object_version_number in out nocopy number
4561 ,p_per_in_ler_id in number default hr_api.g_number
4562 ,p_bnft_typ_cd in varchar2 default hr_api.g_varchar2
4563 ,p_bnft_ordr_num in number default hr_api.g_number
4564 ,p_prtt_enrt_rslt_stat_cd in varchar2 default hr_api.g_varchar2
4565 ,p_bnft_nnmntry_uom in varchar2 default hr_api.g_varchar2
4566 ,p_comp_lvl_cd in varchar2 default hr_api.g_varchar2
4567 ,p_effective_date in date
4568 ,p_datetrack_mode in varchar2
4569 ,p_multi_row_validate in boolean default TRUE
4570 ) is
4571 --
4572 -- Declare cursors and local variables
4573 --
4574 l_proc varchar2(72) ; -- := g_package||'update_PRTT_ENRT_RESULT';
4575 l_object_version_number ben_prtt_enrt_rslt_f.object_version_number%TYPE;
4576 l_effective_start_date ben_prtt_enrt_rslt_f.effective_start_date%TYPE;
4577 l_effective_end_date ben_prtt_enrt_rslt_f.effective_end_date%TYPE;
4578
4579 --
4580 cursor c_old_rslt is
4581 select *
4582 from ben_prtt_enrt_rslt_f
4583 where prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
4584 and prtt_enrt_rslt_stat_cd is null
4585 and p_effective_date between effective_start_date and effective_end_date ;
4586 l_old_rslt c_old_rslt%rowtype ;
4587
4588 -- if there is entry for the same id
4589 -- dont create new value , the backout must restore
4590 -- origianl entry.
4591 cursor c_bckup_tbl_restore (
4592 c_pil_end_id number ,
4593 c_pen_id number ,
4594 c_pil_id number ,
4595 c_eff_strt_dt date ,
4596 c_eff_end_dt date ,
4597 c_cvg_strt_dt date ,
4598 c_cvg_thru_dt date ,
4599 c_pen_stat_cd varchar2 ) is
4600 select 'x'
4601 from BEN_LE_CLSN_N_RSTR
4602 where bkup_tbl_id = c_pen_id
4603 and ((per_in_ler_id = c_pil_id
4604 and per_in_ler_ended_id = c_pil_end_id)
4605 or (per_in_ler_ended_id = c_pil_id -- 8972844
4606 and per_in_ler_id = c_pil_end_id)) -- 7197868
4607 and BKUP_TBL_TYP_CD = 'BEN_PRTT_ENRT_RSLT_F_CORR'
4608 union
4609 select 'x'
4610 from BEN_LE_CLSN_N_RSTR
4611 where bkup_tbl_id = c_pen_id
4612 and per_in_ler_id = c_pil_id
4613 and BKUP_TBL_TYP_CD = 'BEN_PRTT_ENRT_RSLT_F'
4614 and c_eff_strt_dt = EFFECTIVE_START_DATE
4615 and c_eff_end_dt = EFFECTIVE_END_DATE
4616 and c_cvg_strt_dt = ENRT_CVG_STRT_DT
4617 and c_cvg_thru_dt = ENRT_CVG_THRU_DT
4618 and nvl(c_pen_stat_cd,'-1') = nvl(PRTT_ENRT_RSLT_STAT_CD,'-1')
4619 ;
4620
4621 l_env_rec ben_env_object.g_global_env_rec_type;
4622
4623 l_dummy varchar2(1) ;
4624
4625 --
4626 begin
4627 --
4628 g_debug := hr_utility.debug_enabled;
4629 if g_debug then
4630 l_proc := g_package||'update_PRTT_ENRT_RESULT';
4631 hr_utility.set_location('Entering:'|| l_proc, 10);
4632 end if;
4633 g_multi_rows_validate := p_multi_row_validate;
4634 --
4635 -- Issue a savepoint if operating in validation only mode
4636 --
4637 savepoint update_PRTT_ENRT_RESULT;
4638 --
4639 if fnd_global.conc_request_id in (0,-1) and
4640 p_business_group_id <> hr_api.g_number then
4641 --
4642 --bug#3568529
4643 ben_env_object.get(p_rec => l_env_rec);
4644 if l_env_rec.benefit_action_id is null then
4645 --
4646 ben_env_object.init(p_business_group_id => p_business_group_id,
4647 p_effective_date => p_effective_date,
4648 p_thread_id => 1,
4649 p_chunk_size => 1,
4650 p_threads => 1,
4651 p_max_errors => 1,
4652 p_benefit_action_id => null);
4653 end if;
4654 --
4655 end if;
4656 --
4657 if g_debug then
4658 hr_utility.set_location(l_proc, 20);
4659 hr_utility.set_location(' old per in ler id ' || l_old_rslt.per_in_ler_id, 99 );
4660 hr_utility.set_location(' new per in ler id ' || p_per_in_ler_id, 99 );
4661 hr_utility.set_location(' mode ' || p_datetrack_mode, 99 );
4662
4663 end if;
4664 --
4665 -- Process Logic
4666 --
4667 l_object_version_number := p_object_version_number;
4668 --
4669 -- whne the mode is correction and the old per_in_ler id is not the same of
4670 -- new per_in_ler_id and effective state date is same of effecitve date
4671 -- then copy the result record to backup table
4672 -- when the open LE then gain dpnt ,then process the opne on the same dt of GD
4673 -- the result of GD are lost. because the per_in_ler id of open updated in gd
4674
4675 --bug # 3086161
4676 if p_datetrack_mode = hr_api.g_correction and p_per_in_ler_id <> hr_api.g_number then
4677 open c_old_rslt ;
4678 fetch c_old_rslt into l_old_rslt ;
4679 close c_old_rslt ;
4680 if l_old_rslt.per_in_ler_id <> p_per_in_ler_id
4681 and p_effective_date=l_old_rslt.effective_start_date then
4682
4683 hr_utility.set_location(' old per in ler id ' || l_old_rslt.per_in_ler_id, 99 );
4684 hr_utility.set_location(' new per in ler id ' || p_per_in_ler_id, 99 );
4685 hr_utility.set_location(' corrected result id ' ||p_prtt_enrt_rslt_id , 99 );
4686 hr_utility.set_location(' mode ' || p_datetrack_mode, 99 );
4687 hr_utility.set_location(' insertin the row of ' || p_prtt_enrt_rslt_id , 99 );
4688
4689
4690 --- if the update called to reverse the stored row from
4691 --- from backup table dont insert to backup table
4692 open c_bckup_tbl_restore (
4693 p_per_in_ler_id ,
4694 p_prtt_enrt_rslt_id ,
4695 l_old_rslt.per_in_ler_id,
4696 l_old_rslt.EFFECTIVE_START_DATE,
4697 l_old_rslt.EFFECTIVE_END_DATE ,
4698 l_old_rslt.ENRT_CVG_STRT_DT ,
4699 l_old_rslt.ENRT_CVG_THRU_DT ,
4700 l_old_rslt.PRTT_ENRT_RSLT_STAT_CD ) ;
4701 fetch c_bckup_tbl_restore into l_dummy ;
4702 if c_bckup_tbl_restore%notfound then
4703 hr_utility.set_location(' backup row not found ' || p_prtt_enrt_rslt_id , 99 );
4704
4705 insert into BEN_LE_CLSN_N_RSTR (
4706 BKUP_TBL_TYP_CD,
4707 COMP_LVL_CD,
4708 LCR_ATTRIBUTE16,
4709 LCR_ATTRIBUTE17,
4710 LCR_ATTRIBUTE18,
4711 LCR_ATTRIBUTE19,
4712 LCR_ATTRIBUTE20,
4713 LCR_ATTRIBUTE21,
4714 LCR_ATTRIBUTE22,
4715 LCR_ATTRIBUTE23,
4716 LCR_ATTRIBUTE24,
4717 LCR_ATTRIBUTE25,
4718 LCR_ATTRIBUTE26,
4719 LCR_ATTRIBUTE27,
4720 LCR_ATTRIBUTE28,
4721 LCR_ATTRIBUTE29,
4722 LCR_ATTRIBUTE30,
4723 LAST_UPDATE_DATE,
4724 LAST_UPDATED_BY,
4725 LAST_UPDATE_LOGIN,
4726 CREATED_BY,
4727 CREATION_DATE,
4728 REQUEST_ID,
4729 PROGRAM_APPLICATION_ID,
4730 PROGRAM_ID,
4731 PROGRAM_UPDATE_DATE,
4732 OBJECT_VERSION_NUMBER,
4733 BKUP_TBL_ID, -- PRTT_ENRT_RSLT_ID,
4734 EFFECTIVE_START_DATE,
4735 EFFECTIVE_END_DATE,
4736 ENRT_CVG_STRT_DT,
4737 ENRT_CVG_THRU_DT,
4738 SSPNDD_FLAG,
4739 PRTT_IS_CVRD_FLAG,
4740 BNFT_AMT,
4741 BNFT_NNMNTRY_UOM,
4742 BNFT_TYP_CD,
4743 UOM,
4744 ORGNL_ENRT_DT,
4745 ENRT_MTHD_CD,
4746 ENRT_OVRIDN_FLAG,
4747 ENRT_OVRID_RSN_CD,
4748 ERLST_DEENRT_DT,
4749 ENRT_OVRID_THRU_DT,
4750 NO_LNGR_ELIG_FLAG,
4751 BNFT_ORDR_NUM,
4752 PERSON_ID,
4753 ASSIGNMENT_ID,
4754 PGM_ID,
4755 PRTT_ENRT_RSLT_STAT_CD,
4756 PL_ID,
4757 OIPL_ID,
4758 PTIP_ID,
4759 PL_TYP_ID,
4760 LER_ID,
4761 PER_IN_LER_ID,
4762 RPLCS_SSPNDD_RSLT_ID,
4763 BUSINESS_GROUP_ID,
4764 LCR_ATTRIBUTE_CATEGORY,
4765 LCR_ATTRIBUTE1,
4766 LCR_ATTRIBUTE2,
4767 LCR_ATTRIBUTE3,
4768 LCR_ATTRIBUTE4,
4769 LCR_ATTRIBUTE5,
4770 LCR_ATTRIBUTE6,
4771 LCR_ATTRIBUTE7,
4772 LCR_ATTRIBUTE8,
4773 LCR_ATTRIBUTE9,
4774 LCR_ATTRIBUTE10,
4775 LCR_ATTRIBUTE11,
4776 LCR_ATTRIBUTE12,
4777 LCR_ATTRIBUTE13,
4778 LCR_ATTRIBUTE14,
4779 LCR_ATTRIBUTE15 ,
4780 PER_IN_LER_ENDED_ID,
4781 PL_ORDR_NUM,
4782 PLIP_ORDR_NUM,
4783 PTIP_ORDR_NUM,
4784 OIPL_ORDR_NUM)
4785 values (
4786 'BEN_PRTT_ENRT_RSLT_F_CORR',
4787 l_old_rslt.COMP_LVL_CD,
4788 l_old_rslt.PEN_ATTRIBUTE16,
4789 l_old_rslt.PEN_ATTRIBUTE17,
4790 l_old_rslt.PEN_ATTRIBUTE18,
4791 l_old_rslt.PEN_ATTRIBUTE19,
4792 l_old_rslt.PEN_ATTRIBUTE20,
4793 l_old_rslt.PEN_ATTRIBUTE21,
4794 l_old_rslt.PEN_ATTRIBUTE22,
4795 l_old_rslt.PEN_ATTRIBUTE23,
4796 l_old_rslt.PEN_ATTRIBUTE24,
4797 l_old_rslt.PEN_ATTRIBUTE25,
4798 l_old_rslt.PEN_ATTRIBUTE26,
4799 l_old_rslt.PEN_ATTRIBUTE27,
4800 l_old_rslt.PEN_ATTRIBUTE28,
4801 l_old_rslt.PEN_ATTRIBUTE29,
4802 l_old_rslt.PEN_ATTRIBUTE30,
4803 l_old_rslt.LAST_UPDATE_DATE,
4804 l_old_rslt.LAST_UPDATED_BY,
4805 l_old_rslt.LAST_UPDATE_LOGIN,
4806 l_old_rslt.CREATED_BY,
4807 l_old_rslt.CREATION_DATE,
4808 l_old_rslt.REQUEST_ID,
4809 l_old_rslt.PROGRAM_APPLICATION_ID,
4810 l_old_rslt.PROGRAM_ID,
4811 l_old_rslt.PROGRAM_UPDATE_DATE,
4812 l_old_rslt.OBJECT_VERSION_NUMBER,
4813 l_old_rslt.PRTT_ENRT_RSLT_ID,
4814 l_old_rslt.EFFECTIVE_START_DATE,
4815 l_old_rslt.EFFECTIVE_END_DATE,
4816 l_old_rslt.ENRT_CVG_STRT_DT,
4817 l_old_rslt.ENRT_CVG_THRU_DT,
4818 l_old_rslt.SSPNDD_FLAG,
4819 l_old_rslt.PRTT_IS_CVRD_FLAG,
4820 l_old_rslt.BNFT_AMT,
4821 l_old_rslt.BNFT_NNMNTRY_UOM,
4822 l_old_rslt.BNFT_TYP_CD,
4823 l_old_rslt.UOM,
4824 l_old_rslt.ORGNL_ENRT_DT,
4825 l_old_rslt.ENRT_MTHD_CD,
4826 l_old_rslt.ENRT_OVRIDN_FLAG,
4827 l_old_rslt.ENRT_OVRID_RSN_CD,
4828 l_old_rslt.ERLST_DEENRT_DT,
4829 l_old_rslt.ENRT_OVRID_THRU_DT,
4830 l_old_rslt.NO_LNGR_ELIG_FLAG,
4831 l_old_rslt.BNFT_ORDR_NUM,
4832 l_old_rslt.PERSON_ID,
4833 l_old_rslt.ASSIGNMENT_ID,
4834 l_old_rslt.PGM_ID,
4835 l_old_rslt.PRTT_ENRT_RSLT_STAT_CD,
4836 l_old_rslt.PL_ID,
4837 l_old_rslt.OIPL_ID,
4838 l_old_rslt.PTIP_ID,
4839 l_old_rslt.PL_TYP_ID,
4840 l_old_rslt.LER_ID,
4841 l_old_rslt.PER_IN_LER_ID,
4842 l_old_rslt.RPLCS_SSPNDD_RSLT_ID,
4843 l_old_rslt.BUSINESS_GROUP_ID,
4844 l_old_rslt.PEN_ATTRIBUTE_CATEGORY,
4845 l_old_rslt.PEN_ATTRIBUTE1,
4846 l_old_rslt.PEN_ATTRIBUTE2,
4847 l_old_rslt.PEN_ATTRIBUTE3,
4848 l_old_rslt.PEN_ATTRIBUTE4,
4849 l_old_rslt.PEN_ATTRIBUTE5,
4850 l_old_rslt.PEN_ATTRIBUTE6,
4851 l_old_rslt.PEN_ATTRIBUTE7,
4852 l_old_rslt.PEN_ATTRIBUTE8,
4853 l_old_rslt.PEN_ATTRIBUTE9,
4854 l_old_rslt.PEN_ATTRIBUTE10,
4855 l_old_rslt.PEN_ATTRIBUTE11,
4856 l_old_rslt.PEN_ATTRIBUTE12,
4857 l_old_rslt.PEN_ATTRIBUTE13,
4858 l_old_rslt.PEN_ATTRIBUTE14,
4859 l_old_rslt.PEN_ATTRIBUTE15,
4860 p_per_in_ler_id ,
4861 l_old_rslt.PL_ORDR_NUM,
4862 l_old_rslt.PLIP_ORDR_NUM,
4863 l_old_rslt.PTIP_ORDR_NUM,
4864 l_old_rslt.OIPL_ORDR_NUM
4865 );
4866 end if;
4867 close c_bckup_tbl_restore ;
4868
4869
4870 end if ;
4871 --eof bug # 3086161
4872
4873
4874
4875 end if ;
4876
4877 begin
4878 --
4879 -- Start of API User Hook for the before hook of update_PRTT_ENRT_RESULT
4880 --
4881 ben_PRTT_ENRT_RESULT_bk2.update_PRTT_ENRT_RESULT_b
4882 (
4883 p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
4884 ,p_business_group_id => p_business_group_id
4885 ,p_oipl_id => p_oipl_id
4886 ,p_person_id => p_person_id
4887 ,p_assignment_id => p_assignment_id
4888 ,p_pgm_id => p_pgm_id
4889 ,p_pl_id => p_pl_id
4890 ,p_rplcs_sspndd_rslt_id => p_rplcs_sspndd_rslt_id
4891 ,p_ptip_id => p_ptip_id
4892 ,p_pl_typ_id => p_pl_typ_id
4893 ,p_ler_id => p_ler_id
4894 ,p_sspndd_flag => p_sspndd_flag
4895 ,p_prtt_is_cvrd_flag => p_prtt_is_cvrd_flag
4896 ,p_bnft_amt => p_bnft_amt
4897 ,p_uom => p_uom
4898 ,p_orgnl_enrt_dt => p_orgnl_enrt_dt
4899 ,p_enrt_mthd_cd => p_enrt_mthd_cd
4900 ,p_no_lngr_elig_flag => p_no_lngr_elig_flag
4901 ,p_enrt_ovridn_flag => p_enrt_ovridn_flag
4902 ,p_enrt_ovrid_rsn_cd => p_enrt_ovrid_rsn_cd
4903 ,p_erlst_deenrt_dt => p_erlst_deenrt_dt
4904 ,p_enrt_cvg_strt_dt => p_enrt_cvg_strt_dt
4905 ,p_enrt_cvg_thru_dt => p_enrt_cvg_thru_dt
4906 ,p_enrt_ovrid_thru_dt => p_enrt_ovrid_thru_dt
4907 ,p_pl_ordr_num => p_pl_ordr_num
4908 ,p_plip_ordr_num => p_plip_ordr_num
4909 ,p_ptip_ordr_num => p_ptip_ordr_num
4910 ,p_oipl_ordr_num => p_oipl_ordr_num
4911 ,p_pen_attribute_category => p_pen_attribute_category
4912 ,p_pen_attribute1 => p_pen_attribute1
4913 ,p_pen_attribute2 => p_pen_attribute2
4914 ,p_pen_attribute3 => p_pen_attribute3
4915 ,p_pen_attribute4 => p_pen_attribute4
4916 ,p_pen_attribute5 => p_pen_attribute5
4917 ,p_pen_attribute6 => p_pen_attribute6
4918 ,p_pen_attribute7 => p_pen_attribute7
4919 ,p_pen_attribute8 => p_pen_attribute8
4920 ,p_pen_attribute9 => p_pen_attribute9
4921 ,p_pen_attribute10 => p_pen_attribute10
4922 ,p_pen_attribute11 => p_pen_attribute11
4923 ,p_pen_attribute12 => p_pen_attribute12
4924 ,p_pen_attribute13 => p_pen_attribute13
4925 ,p_pen_attribute14 => p_pen_attribute14
4926 ,p_pen_attribute15 => p_pen_attribute15
4927 ,p_pen_attribute16 => p_pen_attribute16
4928 ,p_pen_attribute17 => p_pen_attribute17
4929 ,p_pen_attribute18 => p_pen_attribute18
4930 ,p_pen_attribute19 => p_pen_attribute19
4931 ,p_pen_attribute20 => p_pen_attribute20
4932 ,p_pen_attribute21 => p_pen_attribute21
4933 ,p_pen_attribute22 => p_pen_attribute22
4934 ,p_pen_attribute23 => p_pen_attribute23
4935 ,p_pen_attribute24 => p_pen_attribute24
4936 ,p_pen_attribute25 => p_pen_attribute25
4937 ,p_pen_attribute26 => p_pen_attribute26
4938 ,p_pen_attribute27 => p_pen_attribute27
4939 ,p_pen_attribute28 => p_pen_attribute28
4940 ,p_pen_attribute29 => p_pen_attribute29
4941 ,p_pen_attribute30 => p_pen_attribute30
4942 ,p_request_id => p_request_id
4943 ,p_program_application_id => p_program_application_id
4944 ,p_program_id => p_program_id
4945 ,p_program_update_date => p_program_update_date
4946 ,p_object_version_number => p_object_version_number
4947 ,p_per_in_ler_id => p_per_in_ler_id
4948 ,p_bnft_typ_cd => p_bnft_typ_cd
4949 ,p_bnft_ordr_num => p_bnft_ordr_num
4950 ,p_prtt_enrt_rslt_stat_cd => p_prtt_enrt_rslt_stat_cd
4951 ,p_bnft_nnmntry_uom => p_bnft_nnmntry_uom
4952 ,p_comp_lvl_cd => p_comp_lvl_cd
4953 ,p_effective_date => trunc(p_effective_date)
4954 ,p_datetrack_mode => p_datetrack_mode
4955 );
4956 exception
4957 when hr_api.cannot_find_prog_unit then
4958 hr_api.cannot_find_prog_unit_error
4959 (p_module_name => 'UPDATE_PRTT_ENRT_RESULT'
4960 ,p_hook_type => 'BP'
4961 );
4962 --
4963 -- End of API User Hook for the before hook of update_PRTT_ENRT_RESULT
4964 --
4965 end;
4966 --
4967 hr_utility.set_location ( ' eff date ' || p_effective_date, 99 );
4968 hr_utility.set_location ( ' OVN ' || l_object_version_number, 99 );
4969 ben_pen_upd.upd
4970 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
4971 ,p_effective_start_date => l_effective_start_date
4972 ,p_effective_end_date => l_effective_end_date
4973 ,p_business_group_id => p_business_group_id
4974 ,p_oipl_id => p_oipl_id
4975 ,p_person_id => p_person_id
4976 ,p_assignment_id => p_assignment_id
4977 ,p_pgm_id => p_pgm_id
4978 ,p_pl_id => p_pl_id
4979 ,p_rplcs_sspndd_rslt_id => p_rplcs_sspndd_rslt_id
4980 ,p_ptip_id => p_ptip_id
4981 ,p_pl_typ_id => p_pl_typ_id
4982 ,p_ler_id => p_ler_id
4983 ,p_sspndd_flag => p_sspndd_flag
4984 ,p_prtt_is_cvrd_flag => p_prtt_is_cvrd_flag
4985 ,p_bnft_amt => p_bnft_amt
4986 ,p_uom => p_uom
4987 ,p_orgnl_enrt_dt => p_orgnl_enrt_dt
4988 ,p_enrt_mthd_cd => p_enrt_mthd_cd
4989 ,p_no_lngr_elig_flag => p_no_lngr_elig_flag
4990 ,p_enrt_ovridn_flag => p_enrt_ovridn_flag
4991 ,p_enrt_ovrid_rsn_cd => p_enrt_ovrid_rsn_cd
4992 ,p_erlst_deenrt_dt => p_erlst_deenrt_dt
4993 ,p_enrt_cvg_strt_dt => p_enrt_cvg_strt_dt
4994 ,p_enrt_cvg_thru_dt => p_enrt_cvg_thru_dt
4995 ,p_enrt_ovrid_thru_dt => p_enrt_ovrid_thru_dt
4996 ,p_pl_ordr_num => p_pl_ordr_num
4997 ,p_plip_ordr_num => p_plip_ordr_num
4998 ,p_ptip_ordr_num => p_ptip_ordr_num
4999 ,p_oipl_ordr_num => p_oipl_ordr_num
5000 ,p_pen_attribute_category => p_pen_attribute_category
5001 ,p_pen_attribute1 => p_pen_attribute1
5002 ,p_pen_attribute2 => p_pen_attribute2
5003 ,p_pen_attribute3 => p_pen_attribute3
5004 ,p_pen_attribute4 => p_pen_attribute4
5005 ,p_pen_attribute5 => p_pen_attribute5
5006 ,p_pen_attribute6 => p_pen_attribute6
5007 ,p_pen_attribute7 => p_pen_attribute7
5008 ,p_pen_attribute8 => p_pen_attribute8
5009 ,p_pen_attribute9 => p_pen_attribute9
5010 ,p_pen_attribute10 => p_pen_attribute10
5011 ,p_pen_attribute11 => p_pen_attribute11
5012 ,p_pen_attribute12 => p_pen_attribute12
5013 ,p_pen_attribute13 => p_pen_attribute13
5014 ,p_pen_attribute14 => p_pen_attribute14
5015 ,p_pen_attribute15 => p_pen_attribute15
5016 ,p_pen_attribute16 => p_pen_attribute16
5017 ,p_pen_attribute17 => p_pen_attribute17
5018 ,p_pen_attribute18 => p_pen_attribute18
5019 ,p_pen_attribute19 => p_pen_attribute19
5020 ,p_pen_attribute20 => p_pen_attribute20
5021 ,p_pen_attribute21 => p_pen_attribute21
5022 ,p_pen_attribute22 => p_pen_attribute22
5023 ,p_pen_attribute23 => p_pen_attribute23
5024 ,p_pen_attribute24 => p_pen_attribute24
5025 ,p_pen_attribute25 => p_pen_attribute25
5026 ,p_pen_attribute26 => p_pen_attribute26
5027 ,p_pen_attribute27 => p_pen_attribute27
5028 ,p_pen_attribute28 => p_pen_attribute28
5029 ,p_pen_attribute29 => p_pen_attribute29
5030 ,p_pen_attribute30 => p_pen_attribute30
5031 ,p_request_id => p_request_id
5032 ,p_program_application_id => p_program_application_id
5033 ,p_program_id => p_program_id
5034 ,p_program_update_date => p_program_update_date
5035 ,p_object_version_number => l_object_version_number
5036 ,p_per_in_ler_id => p_per_in_ler_id
5037 ,p_bnft_typ_cd => p_bnft_typ_cd
5038 ,p_bnft_ordr_num => p_bnft_ordr_num
5039 ,p_prtt_enrt_rslt_stat_cd => p_prtt_enrt_rslt_stat_cd
5040 ,p_bnft_nnmntry_uom => p_bnft_nnmntry_uom
5041 ,p_comp_lvl_cd => p_comp_lvl_cd
5042 ,p_effective_date => trunc(p_effective_date)
5043 ,p_datetrack_mode => p_datetrack_mode
5044 );
5045 --
5046 --
5047 begin
5048 --
5049 -- Start of API User Hook for the after hook of update_PRTT_ENRT_RESULT
5050 --
5051 ben_PRTT_ENRT_RESULT_bk2.update_PRTT_ENRT_RESULT_a
5052 (
5053 p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
5054 ,p_effective_start_date => l_effective_start_date
5055 ,p_effective_end_date => l_effective_end_date
5056 ,p_business_group_id => p_business_group_id
5057 ,p_oipl_id => p_oipl_id
5058 ,p_person_id => p_person_id
5059 ,p_assignment_id => p_assignment_id
5060 ,p_pgm_id => p_pgm_id
5061 ,p_pl_id => p_pl_id
5062 ,p_rplcs_sspndd_rslt_id => p_rplcs_sspndd_rslt_id
5063 ,p_ptip_id => p_ptip_id
5064 ,p_pl_typ_id => p_pl_typ_id
5065 ,p_ler_id => p_ler_id
5066 ,p_sspndd_flag => p_sspndd_flag
5067 ,p_prtt_is_cvrd_flag => p_prtt_is_cvrd_flag
5068 ,p_bnft_amt => p_bnft_amt
5069 ,p_uom => p_uom
5070 ,p_orgnl_enrt_dt => p_orgnl_enrt_dt
5071 ,p_enrt_mthd_cd => p_enrt_mthd_cd
5072 ,p_no_lngr_elig_flag => p_no_lngr_elig_flag
5073 ,p_enrt_ovridn_flag => p_enrt_ovridn_flag
5074 ,p_enrt_ovrid_rsn_cd => p_enrt_ovrid_rsn_cd
5075 ,p_erlst_deenrt_dt => p_erlst_deenrt_dt
5076 ,p_enrt_cvg_strt_dt => p_enrt_cvg_strt_dt
5077 ,p_enrt_cvg_thru_dt => p_enrt_cvg_thru_dt
5078 ,p_enrt_ovrid_thru_dt => p_enrt_ovrid_thru_dt
5079 ,p_pl_ordr_num => p_pl_ordr_num
5080 ,p_plip_ordr_num => p_plip_ordr_num
5081 ,p_ptip_ordr_num => p_ptip_ordr_num
5082 ,p_oipl_ordr_num => p_oipl_ordr_num
5083 ,p_pen_attribute_category => p_pen_attribute_category
5084 ,p_pen_attribute1 => p_pen_attribute1
5085 ,p_pen_attribute2 => p_pen_attribute2
5086 ,p_pen_attribute3 => p_pen_attribute3
5087 ,p_pen_attribute4 => p_pen_attribute4
5088 ,p_pen_attribute5 => p_pen_attribute5
5089 ,p_pen_attribute6 => p_pen_attribute6
5090 ,p_pen_attribute7 => p_pen_attribute7
5091 ,p_pen_attribute8 => p_pen_attribute8
5092 ,p_pen_attribute9 => p_pen_attribute9
5093 ,p_pen_attribute10 => p_pen_attribute10
5094 ,p_pen_attribute11 => p_pen_attribute11
5095 ,p_pen_attribute12 => p_pen_attribute12
5096 ,p_pen_attribute13 => p_pen_attribute13
5097 ,p_pen_attribute14 => p_pen_attribute14
5098 ,p_pen_attribute15 => p_pen_attribute15
5099 ,p_pen_attribute16 => p_pen_attribute16
5100 ,p_pen_attribute17 => p_pen_attribute17
5101 ,p_pen_attribute18 => p_pen_attribute18
5102 ,p_pen_attribute19 => p_pen_attribute19
5103 ,p_pen_attribute20 => p_pen_attribute20
5104 ,p_pen_attribute21 => p_pen_attribute21
5105 ,p_pen_attribute22 => p_pen_attribute22
5106 ,p_pen_attribute23 => p_pen_attribute23
5107 ,p_pen_attribute24 => p_pen_attribute24
5108 ,p_pen_attribute25 => p_pen_attribute25
5109 ,p_pen_attribute26 => p_pen_attribute26
5110 ,p_pen_attribute27 => p_pen_attribute27
5111 ,p_pen_attribute28 => p_pen_attribute28
5112 ,p_pen_attribute29 => p_pen_attribute29
5113 ,p_pen_attribute30 => p_pen_attribute30
5114 ,p_request_id => p_request_id
5115 ,p_program_application_id => p_program_application_id
5116 ,p_program_id => p_program_id
5117 ,p_program_update_date => p_program_update_date
5118 ,p_object_version_number => l_object_version_number
5119 ,p_per_in_ler_id => p_per_in_ler_id
5120 ,p_bnft_typ_cd => p_bnft_typ_cd
5121 ,p_bnft_ordr_num => p_bnft_ordr_num
5122 ,p_prtt_enrt_rslt_stat_cd => p_prtt_enrt_rslt_stat_cd
5123 ,p_bnft_nnmntry_uom => p_bnft_nnmntry_uom
5124 ,p_comp_lvl_cd => p_comp_lvl_cd
5125 ,p_effective_date => trunc(p_effective_date)
5126 ,p_datetrack_mode => p_datetrack_mode
5127 );
5128 exception
5129 when hr_api.cannot_find_prog_unit then
5130 hr_api.cannot_find_prog_unit_error
5131 (p_module_name => 'UPDATE_PRTT_ENRT_RESULT'
5132 ,p_hook_type => 'AP'
5133 );
5134 --
5135 -- End of API User Hook for the after hook of update_PRTT_ENRT_RESULT
5136 --
5137 end;
5138 --
5139 if g_debug then
5140 hr_utility.set_location(l_proc, 60);
5141 end if;
5142 --
5143 -- When in validation only mode raise the Validate_Enabled exception
5144 --
5145 if p_validate then
5146 raise hr_api.validate_enabled;
5147 end if;
5148 --
5149 -- Set all output arguments
5150 --
5151 p_object_version_number := l_object_version_number;
5152 p_effective_start_date := l_effective_start_date;
5153 p_effective_end_date := l_effective_end_date;
5154 --
5155 if g_debug then
5156 hr_utility.set_location(' Leaving:'||l_proc, 70);
5157 end if;
5158 --
5159 exception
5160 --
5161 when hr_api.validate_enabled then
5162 --
5163 -- As the Validate_Enabled exception has been raised
5164 -- we must rollback to the savepoint
5165 --
5166 ROLLBACK TO update_PRTT_ENRT_RESULT;
5167 --
5168 -- Only set output warning arguments
5169 -- (Any key or derived arguments must be set to null
5170 -- when validation only mode is being used.)
5171 --
5172 if g_debug then
5173 hr_utility.set_location(' Leaving:'||l_proc, 80);
5174 end if;
5175 --
5176 when others then
5177 --
5178 -- A validation or unexpected error has occured
5179 --
5180 ROLLBACK TO update_PRTT_ENRT_RESULT;
5181 p_effective_start_date := null; --nocopy change
5182 p_effective_end_date := null; --nocopy change
5183 raise;
5184 --
5185 end update_PRTT_ENRT_RESULT;
5186 --
5187 -- ----------------------------------------------------------------------------
5188 -- |------------------------< delete_PRTT_ENRT_RESULT >----------------------|
5189 -- ----------------------------------------------------------------------------
5190 --
5191 procedure delete_PRTT_ENRT_RESULT
5192 (p_validate in boolean default false
5193 ,p_prtt_enrt_rslt_id in number
5194 ,p_effective_start_date out nocopy date
5195 ,p_effective_end_date out nocopy date
5196 ,p_object_version_number in out nocopy number
5197 ,p_effective_date in date
5198 ,p_datetrack_mode in varchar2
5199 ,p_multi_row_validate in boolean default TRUE
5200 ) is
5201 --
5202 -- Declare cursors and local variables
5203 --
5204 l_proc varchar2(72) ; -- := g_package||'delete_PRTT_ENRT_RESULT';
5205 l_object_version_number ben_prtt_enrt_rslt_f.object_version_number%TYPE;
5206 l_effective_start_date ben_prtt_enrt_rslt_f.effective_start_date%TYPE;
5207 l_effective_end_date ben_prtt_enrt_rslt_f.effective_end_date%TYPE;
5208 --
5209 begin
5210 --
5211 g_debug := hr_utility.debug_enabled;
5212 if g_debug then
5213 l_proc := g_package||'delete_PRTT_ENRT_RESULT';
5214 hr_utility.set_location('Entering:'|| l_proc, 10);
5215 end if;
5216 g_multi_rows_validate := p_multi_row_validate;
5217 --
5218 -- Issue a savepoint if operating in validation only mode
5219 --
5220 savepoint delete_PRTT_ENRT_RESULT;
5221 --
5222 if g_debug then
5223 hr_utility.set_location(l_proc, 20);
5224 end if;
5225 --
5226 -- Process Logic
5227 --
5228 l_object_version_number := p_object_version_number;
5229 --
5230 --
5231 begin
5232 --
5233 -- Start of API User Hook for the before hook of delete_PRTT_ENRT_RESULT
5234 --
5235 ben_PRTT_ENRT_RESULT_bk3.delete_PRTT_ENRT_RESULT_b
5236 (
5237 p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
5238 ,p_object_version_number => p_object_version_number
5239 ,p_effective_date => trunc(p_effective_date)
5240 ,p_datetrack_mode => p_datetrack_mode
5241 );
5242 exception
5243 when hr_api.cannot_find_prog_unit then
5244 hr_api.cannot_find_prog_unit_error
5245 (p_module_name => 'DELETE_PRTT_ENRT_RESULT'
5246 ,p_hook_type => 'BP'
5247 );
5248 --
5249 -- End of API User Hook for the before hook of delete_PRTT_ENRT_RESULT
5250 --
5251 end;
5252 --
5253 ben_pen_del.del
5254 (
5255 p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
5256 ,p_effective_start_date => l_effective_start_date
5257 ,p_effective_end_date => l_effective_end_date
5258 ,p_object_version_number => l_object_version_number
5259 ,p_effective_date => p_effective_date
5260 ,p_datetrack_mode => p_datetrack_mode
5261 );
5262 --
5263 begin
5264 --
5265 -- Start of API User Hook for the after hook of delete_PRTT_ENRT_RESULT
5266 --
5267 ben_PRTT_ENRT_RESULT_bk3.delete_PRTT_ENRT_RESULT_a
5268 (
5269 p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
5270 ,p_effective_start_date => l_effective_start_date
5271 ,p_effective_end_date => l_effective_end_date
5272 ,p_object_version_number => l_object_version_number
5273 ,p_effective_date => trunc(p_effective_date)
5274 ,p_datetrack_mode => p_datetrack_mode
5275 );
5276 exception
5277 when hr_api.cannot_find_prog_unit then
5278 hr_api.cannot_find_prog_unit_error
5279 (p_module_name => 'DELETE_PRTT_ENRT_RESULT'
5280 ,p_hook_type => 'AP'
5281 );
5282 --
5283 -- End of API User Hook for the after hook of delete_PRTT_ENRT_RESULT
5284 --
5285 end;
5286 --
5287 if g_debug then
5288 hr_utility.set_location(l_proc, 60);
5289 end if;
5290 --
5291 -- When in validation only mode raise the Validate_Enabled exception
5292 --
5293 if p_validate then
5294 raise hr_api.validate_enabled;
5295 end if;
5296 --
5297 p_effective_start_date := l_effective_start_date;
5298 p_effective_end_date := l_effective_end_date;
5299 p_object_version_number := l_object_version_number;
5300
5301 if g_debug then
5302 hr_utility.set_location(' Leaving:'||l_proc, 70);
5303 end if;
5304 --
5305 exception
5306 --
5307 when hr_api.validate_enabled then
5308 --
5309 -- As the Validate_Enabled exception has been raised
5310 -- we must rollback to the savepoint
5311 --
5312 ROLLBACK TO delete_PRTT_ENRT_RESULT;
5313 --
5314 -- Only set output warning arguments
5315 -- (Any key or derived arguments must be set to null
5316 -- when validation only mode is being used.)
5317 --
5318 p_effective_start_date := null;
5319 p_effective_end_date := null;
5320 if g_debug then
5321 hr_utility.set_location(' Leaving:'||l_proc, 80);
5322 end if;
5323 --
5324 when others then
5325 --
5326 -- A validation or unexpected error has occured
5327 --
5328 ROLLBACK TO delete_PRTT_ENRT_RESULT;
5329 p_effective_start_date := null; --nocopy change
5330 p_effective_end_date := null; --nocopy change
5331 raise;
5332 --
5333 end delete_PRTT_ENRT_RESULT;
5334 --
5335 --
5336 -- ----------------------------------------------------------------------------
5337 -- |---------------------< calc_dpnt_cvg_end_date >-------------------------|
5338 -- ----------------------------------------------------------------------------
5339 --
5340 procedure calc_dpnt_cvg_dt
5341 (p_calc_end_dt in boolean default FALSE
5342 ,P_calc_strt_dt in boolean default FALSE
5343 ,P_per_in_ler_id in number default NULL
5344 ,p_person_id in number default NULL
5345 ,p_pgm_id in number default NULL
5346 ,p_pl_id in number default NULL
5347 ,p_oipl_id in number default NULL
5348 ,p_ptip_id in number default NULL
5349 ,p_ler_id in number default NULL
5350 ,p_elig_per_elctbl_chc_id in number default NULL
5351 ,p_business_group_id in number
5352 ,p_effective_date in date
5353 ,p_enrt_cvg_end_dt in date default NULL
5354 ,p_returned_strt_dt out nocopy date
5355 ,p_returned_end_dt out nocopy date
5356 ) is
5357 l_proc varchar2(72); -- := g_package||'calc_dpnt_cvg_dt';
5358 l_enrt_cvg_end_dt date;
5359 l_cvg_strt_dt date;
5360 l_cvg_strt_cd varchar2(30);
5361 l_cvg_strt_rl number(15);
5362 l_cvg_end_cd varchar2(30);
5363 l_cvg_end_rl number(15);
5364 l_step integer;
5365 begin
5366 g_debug := hr_utility.debug_enabled;
5367 if g_debug then
5368 l_proc := g_package||'calc_dpnt_cvg_dt';
5369 hr_utility.set_location(' Entering:'||l_proc,10);
5370 end if;
5371 l_step := 10;
5372 if (p_elig_per_elctbl_chc_id is not NULL) then
5373 determine_dpnt_cvg_dt_cd
5374 (p_elig_per_elctbl_chc_id => p_elig_per_elctbl_chc_id
5375 ,p_effective_date => p_effective_date
5376 ,p_business_group_id => p_business_group_id
5377 ,p_cvg_strt_cd => l_cvg_strt_cd
5378 ,p_cvg_strt_rl => l_cvg_strt_rl
5379 ,p_cvg_end_cd => l_cvg_end_cd
5380 ,p_cvg_end_rl => l_cvg_end_rl
5381 );
5382 if g_debug then
5383 hr_utility.set_location('dpnt_end_cd' || l_cvg_end_cd,15);
5384 hr_utility.set_location('dpnt_strt_cd'|| l_cvg_strt_cd,15);
5385 end if;
5386 if (p_calc_strt_dt and l_cvg_strt_cd is not NULL) then
5387 l_step := 20;
5388 ben_determine_date.main
5389 (P_DATE_CD => l_cvg_strt_cd
5390 ,p_formula_id => l_cvg_strt_rl
5391 ,P_ELIG_PER_ELCTBL_CHC_ID => p_elig_per_elctbl_chc_id
5392 ,P_BUSINESS_GROUP_ID => p_business_group_id
5393 ,P_EFFECTIVE_DATE => p_effective_date
5394 ,P_RETURNED_DATE => l_cvg_strt_dt
5395 );
5396 else
5397 l_cvg_strt_dt := NULL;
5398 end if;
5399 if (p_calc_end_dt and l_cvg_end_cd is not NULL) then
5400 l_step := 30;
5401 ben_determine_date.main
5402 (P_DATE_CD => l_cvg_end_cd
5403 ,p_formula_id => l_cvg_end_rl
5404 ,p_enrt_cvg_end_dt => p_enrt_cvg_end_dt
5405 ,P_ELIG_PER_ELCTBL_CHC_ID => p_elig_per_elctbl_chc_id
5406 ,P_BUSINESS_GROUP_ID => p_business_group_id
5407 ,P_EFFECTIVE_DATE => p_effective_date
5408 ,P_RETURNED_DATE => l_enrt_cvg_end_dt
5409 );
5410 else
5411 l_enrt_cvg_end_dt := NULL;
5412 end if;
5413 else
5414 l_step := 40;
5415 determine_dpnt_cvg_dt_cd
5416 (p_pgm_id => p_pgm_id
5417 ,P_ptip_id => p_ptip_id
5418 ,p_pl_id => p_pl_id
5419 ,p_ler_id => p_ler_id
5420 ,p_effective_date => p_effective_date
5421 ,p_business_group_id => p_business_group_id
5422 ,p_cvg_strt_cd => l_cvg_strt_cd
5423 ,p_cvg_strt_rl => l_cvg_strt_rl
5424 ,p_cvg_end_cd => l_cvg_end_cd
5425 ,p_cvg_end_rl => l_cvg_end_rl
5426 );
5427 if (p_calc_strt_dt and l_cvg_strt_cd is not null) then
5428 l_step := 50;
5429 ben_determine_date.main
5430 (P_DATE_CD => l_cvg_strt_cd
5431 ,p_formula_id => l_cvg_strt_rl
5432 ,P_PER_IN_LER_ID => p_per_in_ler_id
5433 ,P_PERSON_ID => p_person_id
5434 ,P_PGM_ID => p_pgm_id
5435 ,P_PL_ID => p_pl_id
5436 ,P_OIPL_ID => p_oipl_id
5437 ,P_BUSINESS_GROUP_ID => p_business_group_id
5438 ,P_EFFECTIVE_DATE => p_effective_date
5439 ,P_RETURNED_DATE => l_cvg_strt_dt
5440 );
5441 else
5442 l_cvg_strt_dt := NULL;
5443 end if;
5444 if (p_calc_end_dt and l_cvg_end_cd is not NULL) then
5445 l_step := 60;
5446 ben_determine_date.main
5447 (P_DATE_CD => l_cvg_end_cd
5448 ,p_formula_id => l_cvg_end_rl
5449 ,p_enrt_cvg_end_dt => p_enrt_cvg_end_dt
5450 ,P_PER_IN_LER_ID => p_per_in_ler_id
5451 ,P_PERSON_ID => p_person_id
5452 ,P_PGM_ID => p_pgm_id
5453 ,P_PL_ID => p_pl_id
5454 ,P_OIPL_ID => p_oipl_id
5455 ,P_BUSINESS_GROUP_ID => p_business_group_id
5456 ,P_EFFECTIVE_DATE => p_effective_date
5457 ,P_RETURNED_DATE => l_enrt_cvg_end_dt
5458 );
5459 else
5460 l_enrt_cvg_end_dt := NULL;
5461 end if;
5462 end if;
5463 l_step := 70;
5464 p_returned_end_dt := l_enrt_cvg_end_dt;
5465 p_returned_strt_dt := l_cvg_strt_dt;
5466 if g_debug then
5467 hr_utility.set_location(' Leaving:'||l_proc, 70);
5468 end if;
5469 exception
5470 when others then
5471 rpt_error(p_proc => l_proc, p_step => l_step);
5472 raise;
5473 end calc_dpnt_cvg_dt;
5474 --
5475 -- ----------------------------------------------------------------------------
5476 -- |---------------------< determine_dpnt_cvg_dt_cd >------------------------|
5477 -- ----------------------------------------------------------------------------
5478 --
5479 procedure determine_dpnt_cvg_dt_cd
5480 (p_elig_per_elctbl_chc_id in number default NULL
5481 ,p_pgm_id in number default NULL
5482 ,p_pl_id in number default NULL
5483 ,p_ptip_id in number default NULL
5484 ,p_ler_id in number default NULL
5485 ,p_effective_date in date
5486 ,p_business_group_id in number
5487 ,p_cvg_strt_cd out nocopy varchar2
5488 ,p_cvg_strt_rl out nocopy number
5489 ,p_cvg_end_cd out nocopy varchar2
5490 ,p_cvg_end_rl out nocopy number
5491 ) is
5492 l_proc varchar2(80); -- := 'determine_dpnt_cvg_dt_cd';
5493 l_level varchar2(10) :=NULL;
5494 l_cvg_strt_cd varchar2(30);
5495 l_cvg_strt_rl number(15);
5496 l_cvg_end_cd varchar2(30);
5497 l_cvg_end_rl number(15);
5498 l_step integer;
5499 --
5500 l_pl_rec ben_cobj_cache.g_pl_inst_row;
5501 l_pgm_rec ben_cobj_cache.g_pgm_inst_row;
5502 l_ptip_rec ben_cobj_cache.g_ptip_inst_row;
5503 --
5504 cursor c_epe is
5505 select epe.elig_per_elctbl_chc_id
5506 ,epe.pgm_id
5507 ,epe.ptip_id
5508 ,epe.pl_id
5509 ,pil.ler_id
5510 from ben_elig_per_elctbl_chc epe
5511 ,ben_per_in_ler pil
5512 where elig_per_elctbl_chc_id = p_elig_per_elctbl_chc_id
5513 and epe.business_group_id = p_business_group_id
5514 and epe.per_in_ler_id = pil.per_in_ler_id
5515 and pil.per_in_ler_stat_cd not in ('VOIDD', 'BCKDT')
5516 ;
5517 l_epe c_epe%rowtype;
5518 --
5519 cursor c_ler_chg_dep(p_level varchar2) is
5520 select chg.cvg_eff_strt_cd
5521 ,chg.cvg_eff_end_cd
5522 ,chg.cvg_eff_strt_rl
5523 ,chg.cvg_eff_end_rl
5524 ,chg.ler_chg_dpnt_cvg_cd
5525 ,chg.ler_chg_dpnt_cvg_rl
5526 from ben_ler_chg_dpnt_cvg_f chg
5527 where chg.ler_id = l_epe.ler_id
5528 and chg.business_group_id = p_business_group_id
5529 and decode(p_level
5530 ,'PL',l_epe.pl_id
5531 ,'PTIP', l_epe.ptip_id
5532 ,'PGM', l_epe.pgm_id) = decode(p_level
5533 ,'PL',chg.pl_id
5534 ,'PTIP', chg.ptip_id
5535 ,'PGM', chg.pgm_id)
5536 and p_effective_date between
5537 chg.effective_start_date and chg.effective_end_date
5538 ;
5539 l_chg c_ler_chg_dep%rowtype;
5540 l_env_rec ben_env_object.g_global_env_rec_type;
5541 --
5542 begin
5543 g_debug := hr_utility.debug_enabled;
5544 if g_debug then
5545 l_proc := 'determine_dpnt_cvg_dt_cd';
5546 hr_utility.set_location ('Entering '||l_proc,10);
5547 end if;
5548 l_step := 10;
5549 if fnd_global.conc_request_id in (0,-1) then
5550 --
5551 --bug#3568529
5552 ben_env_object.get(p_rec => l_env_rec);
5553 if l_env_rec.benefit_action_id is null then
5554 --
5555 ben_env_object.init(p_business_group_id => p_business_group_id,
5556 p_effective_date => p_effective_date,
5557 p_thread_id => 1,
5558 p_chunk_size => 1,
5559 p_threads => 1,
5560 p_max_errors => 1,
5561 p_benefit_action_id => null);
5562 end if;
5563 --
5564 end if;
5565 if p_elig_per_elctbl_chc_id is not null then
5566 open c_epe;
5567 fetch c_epe into l_epe;
5568 if c_epe%notfound then
5569 close c_epe;
5570 rpt_error(p_proc => l_proc, p_step => l_step);
5571 if g_debug then
5572 hr_utility.set_location('BEN_91457_ELCTBL_CHC_NOT_FOUND id:'||
5573 to_char(p_elig_per_elctbl_chc_id), 15);
5574 end if;
5575 fnd_message.set_name('BEN','BEN_91457_ELCTBL_CHC_NOT_FOUND');
5576 fnd_message.set_token('ID', to_char(p_elig_per_elctbl_chc_id) );
5577 fnd_message.set_token('PROC','2:'||l_proc );
5578 fnd_message.raise_error;
5579 end if;
5580 close c_epe;
5581 else
5582 l_epe.elig_per_elctbl_chc_id := NULL;
5583 l_epe.pgm_id := p_pgm_id;
5584 l_epe.pl_id := p_pl_id;
5585 l_epe.ptip_id := p_ptip_id;
5586 l_epe.ler_id := p_ler_id;
5587 end if;
5588 if g_debug then
5589 hr_utility.set_location ('Determining designation level '||l_proc,30);
5590 end if;
5591 l_step := 20;
5592 --
5593 -- If program Id is specified, then use program Id to retreive dependent
5594 -- designation level. If not, use plan as dependent designation level.
5595 --
5596 if (l_epe.pl_id is not null ) then
5597 ben_cobj_cache.get_pl_dets
5598 (p_business_group_id => p_business_group_id
5599 ,p_effective_date => p_effective_date
5600 ,p_pl_id => l_epe.pl_id
5601 ,p_inst_row => l_pl_rec);
5602 end if;
5603
5604 if ( (l_epe.pgm_id is not null)) then
5605 ben_cobj_cache.get_pgm_dets
5606 (p_business_group_id => p_business_group_id
5607 ,p_effective_date => p_effective_date
5608 ,p_pgm_id => l_epe.pgm_id
5609 ,p_inst_row => l_pgm_rec);
5610 -- 3657077 : Added the below IF-condition.
5611 -- check if DPNT_DSGN_CD is specified at plan-level. If it is specified
5612 -- then dependent designation level is PL. This overrides all PGM and PTIP levels
5613 if (l_pl_rec.dpnt_dsgn_cd IS NULL) then
5614 l_level := l_pgm_rec.dpnt_dsgn_lvl_cd;
5615 else
5616 l_level := 'PL';
5617 end if;
5618 if l_level not in ('PL', 'PGM', 'PTIP') then
5619 rpt_error(p_proc => l_proc, p_step => l_step);
5620 fnd_message.set_name('BEN', 'BEN_91712_INVALID_DP_DSGN_LVL');
5621 fnd_message.set_token('LVL', l_level);
5622 end if;
5623 else
5624 l_level := 'PL';
5625 end if;
5626
5627 if (l_epe.ptip_id is not null and l_level = 'PTIP') then
5628 ben_cobj_cache.get_ptip_dets
5629 (p_business_group_id => p_business_group_id
5630 ,p_effective_date => p_effective_date
5631 ,p_ptip_id => l_epe.ptip_id
5632 ,p_inst_row => l_ptip_rec);
5633 end if;
5634 l_step := 30;
5635 open c_ler_chg_dep(l_level);
5636 fetch c_ler_chg_dep into l_chg;
5637 if c_ler_chg_dep%notfound then
5638 --
5639 -- If there are no records, continue to get start date code and
5640 -- end date code from program or Plan.
5641 --
5642 l_cvg_strt_cd := NULL;
5643 l_cvg_strt_rl := NULL;
5644 l_cvg_end_cd := NULL;
5645 l_cvg_end_rl := NULL;
5646 else
5647 l_cvg_strt_cd := l_chg.cvg_eff_strt_cd;
5648 l_cvg_strt_rl := l_chg.cvg_eff_strt_rl;
5649 l_cvg_end_cd := l_chg.cvg_eff_end_cd;
5650 l_cvg_end_rl := l_chg.cvg_eff_end_rl;
5651 end if;
5652 close c_ler_chg_dep;
5653 l_step := 40;
5654 if (l_cvg_strt_cd is NULL) then
5655 if (l_level = 'PL') then
5656 l_cvg_strt_cd := l_pl_rec.dpnt_cvg_strt_dt_cd;
5657 l_cvg_strt_rl := l_pl_rec.dpnt_cvg_strt_dt_rl;
5658 elsif (l_level = 'PTIP') then
5659 l_cvg_strt_cd := l_ptip_rec.dpnt_cvg_strt_dt_cd;
5660 l_cvg_strt_rl := l_ptip_rec.dpnt_cvg_strt_dt_rl;
5661 elsif (l_level = 'PGM') then
5662 l_cvg_strt_cd := l_pgm_rec.dpnt_cvg_strt_dt_cd;
5663 l_cvg_strt_rl := l_pgm_rec.dpnt_cvg_strt_dt_rl;
5664 end if;
5665 end if;
5666 l_step := 50;
5667 if (l_cvg_end_cd is NULL) then
5668 if (l_level = 'PL') then
5669 l_cvg_end_cd := l_pl_rec.dpnt_cvg_end_dt_cd;
5670 l_cvg_end_rl := l_pl_rec.dpnt_cvg_end_dt_rl;
5671 elsif (l_level = 'PTIP') then
5672 l_cvg_end_cd := l_ptip_rec.dpnt_cvg_end_dt_cd;
5673 l_cvg_end_rl := l_ptip_rec.dpnt_cvg_end_dt_rl;
5674 elsif (l_level = 'PGM') then
5675 l_cvg_end_cd := l_pgm_rec.dpnt_cvg_end_dt_cd;
5676 l_cvg_end_rl := l_pgm_rec.dpnt_cvg_end_dt_rl;
5677 end if;
5678 end if;
5679 l_step := 60;
5680 p_cvg_strt_cd := l_cvg_strt_cd;
5681 p_cvg_strt_rl := l_cvg_strt_rl;
5682 p_cvg_end_cd := l_cvg_end_cd;
5683 p_cvg_end_rl := l_cvg_end_rl;
5684 exception
5685 when others then
5686 rpt_error(p_proc => l_proc, p_step => l_step);
5687 raise;
5688 end determine_dpnt_cvg_dt_cd;
5689 --
5690 -- ----------------------------------------------------------------------------
5691 -- |------------------------<Get_election_date >-----------------------------|
5692 -- ----------------------------------------------------------------------------
5693 --
5694 Procedure Get_election_date(p_effective_date in Date
5695 ,p_prtt_enrt_rslt_id in Number
5696 ,p_business_group_id in Number
5697 ,p_date out nocopy date
5698 ,p_pil_id out nocopy number
5699 ) is
5700 Cursor c1 is
5701 Select min(effective_start_date),pen.per_in_ler_id
5702 From ben_prtt_enrt_rslt_f pen
5703 Where pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
5704 And pen.business_group_id = p_business_group_id
5705 and pen.prtt_enrt_rslt_stat_cd is null
5706 Group by pen.per_in_ler_id
5707 order by pen.per_in_ler_id asc; -- Bug 6528876
5708
5709 l_date date;
5710 l_pil_id number;
5711 Begin
5712 Open c1;
5713 Fetch c1 into l_date,l_pil_id;
5714 If c1%notfound then
5715 l_date := hr_api.g_date;
5716 l_pil_id := to_number(null);
5717 End if;
5718 Close c1;
5719 p_date := l_date;
5720 p_pil_id := l_pil_id;
5721 End;
5722
5723 -- ----------------------------------------------------------------------------
5724 -- |------------------------< void_enrollment >-----------------------------|
5725 -- ----------------------------------------------------------------------------
5726 --
5727 procedure void_enrollment
5728 (p_validate in boolean default false
5729 ,p_per_in_ler_id in number
5730 ,p_prtt_enrt_rslt_id in number
5731 ,p_business_group_id in number
5732 ,p_enrt_cvg_strt_dt in date default null
5733 ,p_person_id in number default null
5734 ,p_elig_per_elctbl_chc_id in number default null
5735 ,p_epe_ovn in number default null
5736 ,p_object_version_number in number default null
5737 ,p_effective_date in date
5738 ,p_datetrack_mode in varchar2
5739 ,p_multi_row_validate in boolean default TRUE
5740 ,p_source in varchar2 default null
5741 ,p_enrt_bnft_id in number default null)
5742 is
5743 --
5744 -- Declare cursors and local variables
5745 --
5746 /*
5747 cursor c_pen
5748 is
5749 select pen.ler_id
5750 ,pen.person_id
5751 ,pen.ENRT_CVG_STRT_DT
5752 ,pen.ENRT_CVG_THRU_DT
5753 ,pen.effective_start_date
5754 ,pen.effective_end_date
5755 ,pen.pl_id
5756 ,pen.oipl_id
5757 ,pen.object_version_number
5758 ,epe.elig_per_elctbl_chc_id
5759 ,epe.per_in_ler_id
5760 ,epe.object_version_number epe_ovn
5761 ,enb.enrt_bnft_id
5762 from ben_prtt_enrt_rslt_f pen
5763 ,ben_elig_per_elctbl_chc epe
5764 ,ben_per_in_ler pil
5765 ,ben_enrt_bnft enb
5766 where pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
5767 and pen.prtt_enrt_rslt_id = epe.prtt_enrt_rslt_id (+)
5768 and nvl(epe.elig_per_elctbl_chc_id, -1) = enb.elig_per_elctbl_chc_id (+)
5769 and pen.business_group_id = p_business_group_id
5770 and p_effective_date between pen.effective_start_date
5771 and pen.effective_end_date
5772 and pil.per_in_ler_id(+)=epe.per_in_ler_id
5773 and pil.business_group_id(+)=epe.business_group_id
5774 and ( pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT') -- found row condition
5775 or pil.per_in_ler_stat_cd is null -- outer join condition
5776 )
5777 ;
5778 */
5779 --
5780 cursor c_pen
5781 is
5782 select pen.ler_id
5783 ,pen.person_id
5784 ,pen.ENRT_CVG_STRT_DT
5785 ,pen.ENRT_CVG_THRU_DT
5786 ,pen.effective_start_date
5787 ,pen.effective_end_date
5788 ,pen.pl_id
5789 ,pen.oipl_id
5790 ,pen.object_version_number
5791 ,to_number(null) elig_per_elctbl_chc_id
5792 ,to_number(null) per_in_ler_id
5793 ,to_number(null) epe_ovn
5794 ,to_number(null) enrt_bnft_id
5795 from ben_prtt_enrt_rslt_f pen
5796 where pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
5797 and p_effective_date between pen.effective_start_date
5798 and pen.effective_end_date
5799 ;
5800 --
5801 cursor c_epe
5802 is
5803 select epe.elig_per_elctbl_chc_id
5804 ,epe.per_in_ler_id
5805 ,epe.object_version_number epe_ovn
5806 ,enb.enrt_bnft_id
5807 from ben_elig_per_elctbl_chc epe
5808 ,ben_per_in_ler pil
5809 ,ben_enrt_bnft enb
5810 where epe.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
5811 and nvl(epe.elig_per_elctbl_chc_id, -1) = enb.elig_per_elctbl_chc_id (+)
5812 and pil.per_in_ler_id=epe.per_in_ler_id
5813 and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT')
5814 ;
5815
5816 -- ???? should we have that effective date check?
5817 l_pen c_pen%rowtype;
5818 --
5819 /*
5820 cursor c_prv is
5821 select prv.prtt_rt_val_id
5822 --,max(ecr.enrt_rt_id) enrt_rt_id
5823 ,ecr.enrt_rt_id
5824 ,prv.object_version_number
5825 ,ecr.acty_base_rt_id
5826 ,abr.element_type_id
5827 ,abr.input_value_id
5828 ,prv.rt_strt_dt
5829 from ben_prtt_rt_val prv
5830 ,ben_enrt_rt ecr
5831 ,ben_acty_base_rt_f abr
5832 where prv.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
5833 and prv.prtt_rt_val_stat_cd is null
5834 and prv.prtt_rt_val_id = ecr.prtt_rt_val_id (+) */
5835 /* joining ecr with choice id or benefit id is removed as ecr will be
5836 having prtt_rt_val_id only for that particular benefit record in the case of
5837 flat range - bug#2545915 - this one matches with the cursor in delete_enrollment
5838 */
5839 /*
5840 and (l_pen.elig_per_elctbl_chc_id is null or
5841 l_pen.enrt_bnft_id is not null or
5842 l_pen.elig_per_elctbl_chc_id = ecr.elig_per_elctbl_chc_id)
5843 and (l_pen.enrt_bnft_id is null or
5844 l_pen.enrt_bnft_id = ecr.enrt_bnft_id)
5845 and prv.business_group_id = p_business_group_id
5846 and nvl(prv.acty_base_rt_id,-1) = abr.acty_base_rt_id (+)
5847 and p_effective_date between abr.effective_start_date (+)
5848 and abr.effective_end_date (+)
5849 order by prv.rt_strt_dt desc; */
5850 /*
5851 group by
5852 prv.prtt_rt_val_id
5853 ,prv.object_version_number
5854 ,ecr.acty_base_rt_id
5855 ,abr.element_type_id
5856 ,abr.input_value_id
5857 ,prv.rt_strt_dt
5858 */
5859 --
5860 cursor c_prv is
5861 select distinct prv.prtt_rt_val_id
5862 ,prv.object_version_number
5863 ,abr.element_type_id
5864 ,abr.input_value_id
5865 ,prv.rt_strt_dt
5866 from ben_prtt_rt_val prv
5867 ,ben_acty_base_rt_f abr
5868 where prv.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
5869 and prv.prtt_rt_val_stat_cd is null
5870 and prv.business_group_id = p_business_group_id
5871 and prv.acty_base_rt_id = abr.acty_base_rt_id
5872 and p_effective_date between abr.effective_start_date
5873 and abr.effective_end_date
5874 order by prv.rt_strt_dt desc;
5875 --
5876 -- Rates with non-recurring element entries- prtt rt val are end dated
5877 cursor c_prv3 (p_per_in_ler_id number)is
5878 select prv.prtt_rt_val_id
5879 ,prv.object_version_number
5880 ,ecr.enrt_rt_id
5881 ,ecr.acty_base_rt_id
5882 from ben_prtt_rt_val prv,
5883 ben_enrt_rt ecr
5884 where prv.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
5885 and prv.prtt_rt_val_id = ecr.prtt_rt_val_id
5886 and prv.rt_end_dt <> hr_api.g_eot
5887 and prv.business_group_id = p_business_group_id
5888 and prv.per_in_ler_id = p_per_in_ler_id
5889 and prv.prtt_rt_val_stat_cd is null;
5890 --
5891 cursor c_abr (p_acty_base_rt_id number) is
5892 select py.processing_type,
5893 abr.rcrrg_cd
5894 from ben_acty_base_rt_f abr,
5895 pay_element_types_f py
5896 where abr.element_type_id = py.element_type_id(+)
5897 and abr.acty_base_rt_id = p_acty_base_rt_id
5898 and p_effective_date between abr.effective_start_date
5899 and abr.effective_end_date
5900 and p_effective_date between py.effective_start_date(+)
5901 and py.effective_end_date(+);
5902 --
5903 cursor c_unrestricted_future (p_per_in_ler_id number,
5904 p_prtt_enrt_rslt_id number,
5905 p_effective_start_date date) is
5906 select null
5907 from ben_prtt_enrt_rslt_f pen,
5908 ben_per_in_ler pil,
5909 ben_ler_f ler
5910 where pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
5911 and pen.effective_start_date > p_effective_start_date
5912 and pen.per_in_ler_id = pil.per_in_ler_id
5913 and pil.ler_id = ler.ler_id
5914 and ler.typ_cd = 'SCHEDDU'
5915 and p_effective_start_date between ler.effective_start_date
5916 and ler.effective_end_date
5917 and pen.business_group_id = p_business_group_id;
5918
5919 -- 3574168
5920 -- Fetch all Primary Care Provider records.
5921 Cursor c_pcp
5922 is
5923 select pcp.PRMRY_CARE_PRVDR_ID
5924 ,pcp.EFFECTIVE_START_DATE
5925 ,pcp.EFFECTIVE_END_DATE
5926 ,pcp.PRTT_ENRT_RSLT_ID
5927 ,pcp.BUSINESS_GROUP_ID
5928 ,pcp.OBJECT_VERSION_NUMBER
5929 from ben_prmry_care_prvdr_f pcp
5930 where pcp.business_group_id = p_business_group_id
5931 and pcp.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
5932 and p_effective_date between pcp.effective_start_date
5933 and pcp.effective_end_date
5934 ;
5935 --
5936 -- Fetch all PCP records in future.
5937 Cursor c_pcp_future
5938 is
5939 select pcp.PRMRY_CARE_PRVDR_ID
5940 ,pcp.EFFECTIVE_START_DATE
5941 ,pcp.EFFECTIVE_END_DATE
5942 ,pcp.PRTT_ENRT_RSLT_ID
5943 ,pcp.BUSINESS_GROUP_ID
5944 ,pcp.OBJECT_VERSION_NUMBER
5945 from ben_prmry_care_prvdr_f pcp
5946 where pcp.business_group_id = p_business_group_id
5947 and pcp.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
5948 and p_effective_date < pcp.effective_start_date
5949 and NVL(pcp.effective_end_date, hr_api.g_eot) = hr_api.g_eot
5950 ;
5951 -- 3574168
5952
5953 l_abr c_abr%rowtype;
5954
5955 -- Local variable declaration.
5956 l_proc varchar2(72); -- := g_package||'void_enrollment';
5957 l_datetrack_mode varchar2(20);
5958 l_step integer;
5959 l_tmp_ovn integer;
5960 l_effective_start_date date;
5961 l_effective_end_date date;
5962 l_eff_dt date;
5963 l_dummy varchar2(30);
5964 l_pcp_effective_date date;
5965
5966 --
5967 begin
5968 g_debug := hr_utility.debug_enabled;
5969 if g_debug then
5970 l_proc := g_package||'void_enrollment';
5971 hr_utility.set_location('Entering:'|| l_proc, 10);
5972 end if;
5973 --
5974 -- Issue a savepoint if operating in validation only mode
5975 --
5976 savepoint void_enrollment;
5977 --
5978 l_step := 10;
5979
5980 -- Person id is needed for call to update_prtt_rt (because it calls
5981 -- element-entry proc that needs it as input).
5982 -- P_elig_per_elctbl_chc_id and p_epe_ovn are needed for update to chc table.
5983 -- Others are needed for update to result table.
5984
5985 open c_pen;
5986 fetch c_pen into l_pen;
5987 if c_pen%notfound then
5988 close c_pen;
5989 rpt_error(p_proc => l_proc, p_step => l_step);
5990 fnd_message.set_name('BEN','BEN_91711_ENRT_RSLT_NOT_FND');
5991 fnd_message.set_token('ID', to_char(p_prtt_enrt_rslt_id));
5992 fnd_message.set_token('PROC',l_proc);
5993 fnd_message.set_token('PERSON_ID', to_char(p_person_id));
5994 fnd_message.set_token('LER_ID', null);
5995 fnd_message.set_token('EFFECTIVE_DATE',to_char(p_effective_date));
5996 fnd_message.raise_error;
5997 else
5998 --
5999 open c_epe;
6000 fetch c_epe into l_pen.elig_per_elctbl_chc_id,
6001 l_pen.per_in_ler_id,
6002 l_pen.epe_ovn,
6003 l_pen.enrt_bnft_id ;
6004 close c_epe ;
6005 --
6006 end if;
6007 close c_pen;
6008 -- always fetch the above data because other values are needed.
6009 /*
6010 l_pen.enrt_cvg_strt_dt := p_enrt_cvg_strt_dt;
6011 l_pen.person_id := p_person_id;
6012 l_pen.elig_per_elctbl_chc_id := p_elig_per_elctbl_chc_id;
6013 l_pen.epe_ovn := p_epe_ovn;
6014 l_pen.object_version_number := p_object_version_number;
6015 l_pen.enrt_bnft_id := p_enrt_bnft_id; */
6016 --
6017 if g_debug then
6018 hr_utility.set_location('Rate Non recurring',3459);
6019 end if;
6020 for l_prv in c_prv3 (p_per_in_ler_id) loop
6021 --check whether rate is non-recurring
6022 open c_abr(l_prv.acty_base_rt_id);
6023 fetch c_abr into l_abr;
6024 close c_abr;
6025 --
6026 if l_abr.processing_type = 'N' or
6027 l_abr.rcrrg_cd = 'ONCE' then
6028 null;
6029 else
6030 exit;
6031 end if;
6032
6033 if g_debug then
6034 hr_utility.set_location('delete prtt',3459);
6035 end if;
6036 update ben_enrt_rt
6037 set prtt_rt_val_id = null
6038 where enrt_rt_id = l_prv.enrt_rt_id;
6039 --
6040 ben_prtt_rt_val_api.delete_prtt_rt_val
6041 (P_VALIDATE => FALSE
6042 ,P_PRTT_RT_VAL_ID => l_prv.prtt_rt_val_id
6043 ,P_OBJECT_VERSION_NUMBER => l_prv.object_version_number
6044 ,P_EFFECTIVE_DATE => l_eff_dt
6045 ,p_person_id => l_pen.person_id
6046 ,p_business_group_id => p_business_group_id
6047 );
6048 end loop;
6049
6050
6051
6052 l_step := 14;
6053 --
6054 -- Update rt_end_dt in prtt_rate_val table
6055 --
6056 hr_utility.set_location(' c_prv EPE'||l_pen.elig_per_elctbl_chc_id,10);
6057 hr_utility.set_location(' c_prv ENB'||l_pen.enrt_bnft_id,10);
6058 hr_utility.set_location(' c_prv PEN'||p_prtt_enrt_rslt_id,10);
6059 --
6060 For l_prv in c_prv loop
6061 --
6062 hr_utility.set_location(' l_prv PRV'||l_prv.prtt_rt_val_id,10);
6063 --
6064 ben_prtt_rt_val_api.update_prtt_rt_val
6065 (P_VALIDATE => FALSE
6066 ,P_PRTT_RT_VAL_ID => l_prv.prtt_rt_val_id
6067 ,P_RT_END_DT => (l_prv.rt_strt_dt - 1)
6068 ,p_person_id => l_pen.person_id
6069 -- ,p_acty_base_rt_id => l_prv.acty_base_rt_id
6070 ,p_input_value_id => l_prv.input_value_id
6071 ,p_element_type_id => l_prv.element_type_id
6072 ,p_ended_per_in_ler_id => p_per_in_ler_id
6073 ,p_prtt_rt_val_stat_cd => 'VOIDD'
6074 ,p_business_group_id => p_business_group_id
6075 ,P_OBJECT_VERSION_NUMBER => l_prv.object_version_number
6076 ,P_EFFECTIVE_DATE => p_effective_date
6077 );
6078 end loop;
6079 --
6080 --
6081 -- 3574168: Remove PCP records
6082 -- Set End-date to coverage-end-date.
6083 --
6084 for l_pcp in c_pcp loop
6085 --
6086 hr_utility.set_location('Delete prmry_care_prvdr_id '|| l_pcp.prmry_care_prvdr_id,15);
6087 --
6088 ben_prmry_care_prvdr_api.delete_prmry_care_prvdr
6089 (P_VALIDATE => FALSE
6090 ,P_PRMRY_CARE_PRVDR_ID => l_pcp.prmry_care_prvdr_id
6091 ,P_EFFECTIVE_START_DATE => l_pcp.effective_start_date
6092 ,P_EFFECTIVE_END_DATE => l_pcp.effective_end_date
6093 ,P_OBJECT_VERSION_NUMBER => l_pcp.object_version_number
6094 ,P_EFFECTIVE_DATE => p_effective_date
6095 ,P_DATETRACK_MODE => hr_api.g_zap
6096 ,p_called_from => 'delete_enrollment'
6097 );
6098 --
6099 End loop;
6100 --
6101 -- Get future PCP records if any and zap - delete all of them.
6102 --
6103 for l_pcp_future in c_pcp_future loop
6104 --
6105 hr_utility.set_location('ZAP prmry_care_prvdr_id '|| l_pcp_future.prmry_care_prvdr_id, 15);
6106 --
6107 l_pcp_effective_date := l_pcp_future.effective_start_date ;
6108 --
6109 ben_prmry_care_prvdr_api.delete_prmry_care_prvdr
6110 (P_VALIDATE => FALSE
6111 ,P_PRMRY_CARE_PRVDR_ID => l_pcp_future.prmry_care_prvdr_id
6112 ,P_EFFECTIVE_START_DATE => l_pcp_future.effective_start_date
6113 ,P_EFFECTIVE_END_DATE => l_pcp_future.effective_end_date
6114 ,P_OBJECT_VERSION_NUMBER => l_pcp_future.object_version_number
6115 ,P_EFFECTIVE_DATE => l_pcp_effective_date
6116 ,P_DATETRACK_MODE => hr_api.g_zap
6117 ,p_called_from => 'delete_enrollment'
6118 );
6119 --
6120 End loop;
6121
6122 -- 3574168
6123 --
6124
6125 l_step := 120;
6126
6127 get_ben_pen_upd_dt_mode
6128 (p_effective_date => p_effective_date
6129 ,p_base_key_value => p_prtt_enrt_rslt_id
6130 ,P_desired_datetrack_mode => p_datetrack_mode
6131 ,P_datetrack_allow => l_datetrack_mode
6132 );
6133
6134 l_step := 125;
6135 --
6136 --2785410 - if the deenrollment record is already there in the case of unrestricted
6137 -- and now if the result gets voided the datetrack mode needs to be changed
6138 open c_unrestricted_future(p_per_in_ler_id => l_pen.per_in_ler_id,
6139 p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id,
6140 p_effective_start_date =>l_pen.effective_start_date);
6141 fetch c_unrestricted_future into l_dummy;
6142 if c_unrestricted_future%found then
6143 --
6144 ben_prtt_enrt_result_api.delete_prtt_enrt_result
6145 (p_validate => false,
6146 p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id,
6147 p_effective_start_date => l_effective_start_date,
6148 p_effective_end_date => l_effective_end_date,
6149 p_object_version_number => l_pen.object_version_number,
6150 p_effective_date => p_effective_date,
6151 p_datetrack_mode => hr_api.g_future_change,
6152 p_multi_row_validate => FALSE);
6153 --
6154 open c_pen;
6155 fetch c_pen into l_pen;
6156 close c_pen;
6157 --
6158 end if;
6159 close c_unrestricted_future;
6160
6161 ben_prtt_enrt_result_api.update_prtt_enrt_result
6162 (p_validate => FALSE
6163 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
6164 ,p_effective_start_date => l_effective_start_date
6165 ,p_effective_end_date => l_effective_end_date
6166 ,p_per_in_ler_id => l_pen.per_in_ler_id
6167 ,p_enrt_cvg_thru_dt => (l_pen.enrt_cvg_strt_dt - 1)
6168 ,p_prtt_enrt_rslt_stat_cd => 'VOIDD'
6169 ,p_object_version_number => l_pen.object_version_number
6170 ,p_effective_date => p_effective_date
6171 ,p_datetrack_mode => l_datetrack_mode
6172 ,p_multi_row_validate => p_multi_row_validate
6173 ,p_business_group_id => p_business_group_id );
6174
6175
6176 l_step := 136;
6177 --
6178 -- Do not call manage_enrt_bnft, if it is called from election_information
6179 -- as the call is always made from there.
6180 --
6181 --Bug 3256056 This call from election_information is associated with the
6182 --New results - That other call works fine if the result was continued from
6183 --the prevoius enrollment. But if the user made the change in the
6184 --current enrollment olny [I mean selected option 1 , saved and then now
6185 --changing to option 2 ] we don't want to keep the pen id on the enb record.
6186 --
6187 --if p_source is null or
6188 -- p_source <> 'benelinf' then
6189 --
6190 ben_election_information.manage_enrt_bnft
6191 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
6192 ,p_business_group_id => p_business_group_id
6193 ,p_effective_date => p_effective_date
6194 ,p_object_version_number => l_tmp_ovn
6195 ,p_per_in_ler_id => p_per_in_ler_id
6196 );
6197 --
6198 --end if;
6199 --
6200 l_step := 177;
6201
6202
6203 -- leslie code begin:
6204 -- when result is voided in correction mode, we can't compute premium
6205 -- credits. Tell use that they may want to manually.
6206 -- If in correction and esd of result is before first day of this month...
6207 if l_datetrack_mode = hr_api.g_correction and l_pen.effective_start_date <
6208 to_date(to_char(p_effective_date, 'mm-yyyy'), 'mm-yyyy') then
6209 ben_prem_prtt_monthly.premium_warning
6210 (p_person_id => l_pen.person_id
6211 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
6212 ,p_effective_start_date => l_pen.effective_start_date
6213 ,p_effective_date => p_effective_date
6214 ,p_warning => 'VOID');
6215
6216 end if;
6217 -- leslie code end.
6218
6219 -- write to change event log. -thayden
6220 l_step := 178;
6221 --
6222 if p_source is null or
6223 p_source <> 'benelinf' then
6224 ben_ext_chlg.log_benefit_chg
6225 (p_action => 'DELETE'
6226 ,p_old_pl_id => l_pen.pl_id
6227 ,p_old_oipl_id => l_pen.oipl_id
6228 ,p_old_enrt_cvg_strt_dt => l_pen.enrt_cvg_strt_dt
6229 ,p_old_enrt_cvg_end_dt => l_pen.enrt_cvg_thru_dt
6230 ,p_pl_id => l_pen.pl_id
6231 ,p_oipl_id => l_pen.oipl_id
6232 ,p_enrt_cvg_strt_dt => l_pen.enrt_cvg_strt_dt
6233 ,p_enrt_cvg_end_dt => (l_pen.enrt_cvg_strt_dt - 1)
6234 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
6235 ,p_per_in_ler_id => l_pen.per_in_ler_id
6236 ,p_person_id => l_pen.person_id
6237 ,p_business_group_id => p_business_group_id
6238 ,p_effective_date => p_effective_date
6239 );
6240 end if;
6241
6242 if g_debug then
6243 hr_utility.set_location(l_proc, 60);
6244 end if;
6245 --
6246 -- When in validation only mode raise the Validate_Enabled exception
6247 --
6248 if p_validate then
6249 raise hr_api.validate_enabled;
6250 end if;
6251 --
6252 if g_debug then
6253 hr_utility.set_location(' Leaving:'||l_proc, 70);
6254 end if;
6255 --
6256 Exception
6257 --
6258 when hr_api.validate_enabled
6259 then
6260 --
6261 -- As the Validate_Enabled exception has been raised
6262 -- we must rollback to the savepoint
6263 --
6264 ROLLBACK TO void_enrollment;
6265 --
6266 -- Only set output warning arguments
6267 -- (Any key or derived arguments must be set to null
6268 -- when validation only mode is being used.)
6269 --
6270 if g_debug then
6271 hr_utility.set_location(' Leaving:'||l_proc, 80);
6272 end if;
6273 when others then
6274 --
6275 -- A validation or unexpected error has occured
6276 --
6277 ROLLBACK TO void_enrollment;
6278 rpt_error(p_proc => l_proc, p_step => l_step);
6279 fnd_message.raise_error;
6280 --
6281 end void_enrollment;
6282 --
6283 -- ----------------------------------------------------------------------------
6284 -- |------------------------< delete_enrollment >-----------------------------|
6285 -- ----------------------------------------------------------------------------
6286 --
6287 procedure delete_enrollment
6288 (p_validate in boolean default false
6289 ,p_per_in_ler_id in number default NULL
6290 ,p_lee_rsn_id in number default NULL
6291 ,p_enrt_perd_id in number default NULL
6292 ,p_prtt_enrt_rslt_id in number
6293 ,p_business_group_id in number
6294 ,p_effective_start_date out nocopy date
6295 ,p_effective_end_date out nocopy date
6296 ,p_object_version_number in out nocopy number
6297 ,p_effective_date in date
6298 ,p_datetrack_mode in varchar2
6299 ,p_multi_row_validate in boolean default TRUE
6300 ,p_source in varchar2 default null
6301 ,p_enrt_cvg_thru_dt in date default null
6302 ,p_mode in varchar2 default null)
6303 is
6304 --
6305 l_fnd_message_exception exception;
6306 -- Get result and choice information for row we are trying to end.
6307 --
6308 cursor c_pen is
6309 select pen.pl_id
6310 ,pen.pgm_id
6311 ,pen.ptip_id
6312 ,pen.pl_typ_id
6313 ,pen.oipl_id
6314 ,pen.ler_id
6315 ,pen.person_id
6316 ,pen.business_group_id
6317 ,pen.ENRT_CVG_STRT_DT
6318 ,pen.ENRT_CVG_THRU_DT
6319 ,pen.SSPNDD_FLAG
6320 ,pen.ERLST_DEENRT_DT
6321 ,pen.effective_start_date
6322 ,pen.effective_end_date
6323 ,pen.object_version_number pen_ovn
6324 ,pen.rplcs_sspndd_rslt_id
6325 ,pen.per_in_ler_id pen_per_in_ler_id
6326 ,epe.elig_per_elctbl_chc_id
6327 ,epe.per_in_ler_id
6328 ,epe.object_version_number epe_ovn
6329 ,epe.MNDTRY_FLAG
6330 ,epe.fonm_cvg_strt_dt
6331 ,epe.ELCTBL_FLAG
6332 ,epe.AUTO_ENRT_FLAG
6333 ,enb.enrt_bnft_id
6334 ,pil.per_in_ler_stat_cd
6335 ,oipl.opt_id
6336 ,pl.name pl_name
6337 ,opt.name opt_name
6338 ,pl.imptd_incm_calc_cd
6339 from ben_prtt_enrt_rslt_f pen
6340 ,ben_elig_per_elctbl_chc epe
6341 ,ben_per_in_ler pil
6342 ,ben_enrt_bnft enb
6343 ,ben_oipl_f oipl
6344 ,ben_pl_f pl
6345 ,ben_opt_f opt
6346 where pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
6347 and pen.prtt_enrt_rslt_id = epe.prtt_enrt_rslt_id (+)
6348 and nvl(epe.elig_per_elctbl_chc_id, -1) = enb.elig_per_elctbl_chc_id (+)
6349 and pen.business_group_id = epe.business_group_id (+)
6350 and nvl(p_per_in_ler_id, pen.per_in_Ler_id) = epe.per_in_ler_id (+)
6351 and pen.business_group_id = p_business_group_id
6352 and p_effective_date between pen.effective_start_date
6353 and pen.effective_end_date
6354 and pil.per_in_ler_id(+)=epe.per_in_ler_id
6355 and pil.business_group_id(+)=epe.business_group_id
6356 and ( pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT') -- found row condition
6357 or pil.per_in_ler_stat_cd is null -- outer join condition
6358 )
6359 and pl.business_group_id=p_business_group_id
6360 and pl.pl_id =pen.pl_id
6361 and p_effective_date between
6362 pl.effective_start_date and pl.effective_end_date
6363 and oipl.business_group_id(+)=p_business_group_id
6364 and oipl.oipl_id(+)=pen.oipl_id
6365 and p_effective_date between
6366 oipl.effective_start_date(+) and oipl.effective_end_date(+)
6367 and opt.business_group_id(+)=p_business_group_id
6368 and opt.opt_id(+)=oipl.opt_id
6369 and p_effective_date between
6370 opt.effective_start_date(+) and opt.effective_end_date(+)
6371 ;
6372 l_pen c_pen%rowtype;
6373 l_prtt_prem_id number;
6374 --
6375 -- get all prtt_prem for result
6376 --
6377 /****************** CODE PRIOR TO WWBUG: 1646442 *******************
6378 cursor c_ppe is
6379 select ppe.prtt_prem_id,
6380 ppe.object_version_number,
6381 ppe.effective_start_date,
6382 ppe.effective_end_date,
6383 ppe.actl_prem_id
6384 from ben_prtt_prem_f ppe,
6385 ben_per_in_ler pil
6386 where ppe.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
6387 and pil.per_in_ler_id=ppe.per_in_ler_id
6388 and pil.business_group_id=ppe.business_group_id
6389 and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT');
6390 ******************** END CODE PRIOR TO WBUG: 1646442 ****************/
6391 /* Start of Changes for WWBUG: 1646442 */
6392 cursor c_ppe (p_ppe_dt_to_use IN DATE) is
6393 select ppe.prtt_prem_id,
6394 ppe.object_version_number,
6395 ppe.effective_start_date,
6396 ppe.effective_end_date,
6397 ppe.actl_prem_id
6398 from ben_prtt_prem_f ppe,
6399 ben_per_in_ler pil
6400 where ppe.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
6401 and pil.per_in_ler_id=ppe.per_in_ler_id
6402 and pil.business_group_id=ppe.business_group_id
6403 and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT')
6404 -- jcarpent added additional logic below to fix primary key error.
6405 -- case 1 is where you want the dt effective row
6406 -- case 2 is where you want the future dated rows to zap.
6407 and p_ppe_dt_to_use between ppe.effective_start_date and ppe.effective_end_date
6408 UNION
6409 select ppe1.prtt_prem_id,
6410 ppe1.object_version_number,
6411 ppe1.effective_start_date,
6412 ppe1.effective_end_date,
6413 ppe1.actl_prem_id
6414 from ben_prtt_prem_f ppe1,
6415 ben_per_in_ler pil
6416 where ppe1.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
6417 and pil.per_in_ler_id=ppe1.per_in_ler_id
6418 and pil.business_group_id=ppe1.business_group_id
6419 and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT')
6420 and ppe1.effective_start_date > p_ppe_dt_to_use
6421 and not exists
6422 (select 1
6423 from ben_prtt_prem_f ppe2,
6424 ben_per_in_ler pil
6425 where ppe2.prtt_prem_id = ppe1.prtt_prem_id
6426 and ppe2.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
6427 and pil.per_in_ler_id=ppe2.per_in_ler_id
6428 and pil.business_group_id=ppe2.business_group_id
6429 and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT')
6430 and p_ppe_dt_to_use between
6431 ppe2.effective_start_date and ppe2.effective_end_date);
6432 /* End of Changes for WWBUG: 1646442 */
6433 --
6434 l_ppe c_ppe%rowtype;
6435 --
6436 cursor c_prm is
6437 select prm.prtt_prem_by_mo_id,
6438 prm.object_version_number,
6439 prm.effective_start_date,
6440 prm.effective_end_date
6441 from ben_prtt_prem_by_mo_f prm
6442 where prm.prtt_prem_id = l_prtt_prem_id;
6443 --
6444 l_prm c_prm%rowtype;
6445 --
6446 -- Get all rates for result row we are trying to end.
6447 --
6448 cursor c_prv2 is
6449 select prv.prtt_rt_val_id
6450 ,prv.rt_strt_dt
6451 ,prv.per_in_ler_id
6452 ,prv.object_version_number
6453 ,prv.acty_base_rt_id
6454 ,abr.element_type_id
6455 ,abr.input_value_id
6456 from ben_prtt_rt_val prv
6457 ,ben_acty_base_rt_f abr
6458 where prv.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
6459 and prv.rt_end_dt = hr_api.g_eot
6460 and prv.business_group_id = p_business_group_id
6461 and prv.acty_base_rt_id = abr.acty_base_rt_id
6462 and p_effective_date between abr.effective_start_date
6463 and abr.effective_end_date
6464 ;
6465 --
6466 -- overlapped adj
6467 --
6468 cursor c_prv5(p_rt_end_dt date) is
6469 select prv.prtt_rt_val_id
6470 ,prv.rt_strt_dt
6471 ,prv.per_in_ler_id
6472 ,prv.object_version_number
6473 ,prv.acty_base_rt_id
6474 ,abr.element_type_id
6475 ,abr.input_value_id
6476 from ben_prtt_rt_val prv
6477 ,ben_acty_base_rt_f abr
6478 ,ben_per_in_ler pil -- Bug 8573195,not to pick the rows of backed out lifevent for rate adjustment
6479 where prv.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
6480 and prv.rt_end_dt > p_rt_end_dt
6481 and prv.per_in_ler_id <> p_per_in_ler_id
6482 and prv.rt_end_dt <> hr_api.g_eot
6483 and prv.business_group_id = p_business_group_id
6484 and prv.acty_base_rt_id = abr.acty_base_rt_id
6485 and pil.per_in_ler_id = prv.per_in_ler_id
6486 and pil.per_in_ler_stat_cd not in ('BCKDT','VOIDD')
6487 and p_effective_date between abr.effective_start_date
6488 and abr.effective_end_date
6489 ;
6490
6491 --
6492 -- Get program extra info to determine if rates should be adjusted.
6493 --
6494 cursor c_get_pgm_extra_info(p_pgm_id number) is
6495 select pgi_information1
6496 from ben_pgm_extra_info
6497 where information_type = 'ADJ_RATE_PREV_LF_EVT'
6498 and pgm_id = p_pgm_id;
6499
6500 -- Get all rates for result row we are trying to end without looking at end date.
6501 --
6502 cursor c_prvdel is
6503 select prv.prtt_rt_val_id
6504 ,max(ecr.enrt_rt_id) enrt_rt_id
6505 ,prv.object_version_number
6506 ,ecr.acty_base_rt_id
6507 ,abr.element_type_id
6508 ,abr.input_value_id
6509 ,abr.entr_val_at_enrt_flag
6510 ,prv.rt_strt_dt
6511 from ben_prtt_rt_val prv
6512 ,ben_enrt_rt ecr
6513 ,ben_acty_base_rt_f abr
6514 where prv.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
6515 and prv.prtt_rt_val_id = ecr.prtt_rt_val_id (+)
6516 and prv.business_group_id = p_business_group_id
6517 and nvl(prv.acty_base_rt_id,-1) = abr.acty_base_rt_id (+)
6518 and p_effective_date between abr.effective_start_date (+)
6519 and abr.effective_end_date (+)
6520 group by
6521 prv.prtt_rt_val_id
6522 ,prv.object_version_number
6523 ,ecr.acty_base_rt_id
6524 ,abr.element_type_id
6525 ,abr.input_value_id
6526 ,abr.entr_val_at_enrt_flag
6527 ,prv.rt_strt_dt;
6528 --
6529 -- Rates having non-recurring element entries - prtt rt vals are end dated
6530 cursor c_prv3 (p_per_in_ler_id number)is
6531 select prv.prtt_rt_val_id
6532 ,prv.object_version_number
6533 ,ecr.enrt_rt_id
6534 ,ecr.acty_base_rt_id
6535 from ben_prtt_rt_val prv,
6536 ben_enrt_rt ecr
6537 where prv.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
6538 and prv.prtt_rt_val_id = ecr.prtt_rt_val_id
6539 and prv.rt_end_dt <> hr_api.g_eot
6540 and prv.business_group_id = p_business_group_id
6541 and prv.per_in_ler_id = p_per_in_ler_id
6542 and prv.prtt_rt_val_stat_cd is null;
6543 --
6544 cursor c_prv4 (p_rt_end_dt date) is
6545 select prv.prtt_rt_val_id
6546 ,ecr.enrt_rt_id enrt_rt_id
6547 ,prv.object_version_number
6548 ,ecr.acty_base_rt_id
6549 ,abr.element_type_id
6550 ,abr.input_value_id
6551 ,prv.rt_end_dt --This is needed to determine the future started rate
6552 from ben_prtt_rt_val prv
6553 ,ben_enrt_rt ecr
6554 ,ben_acty_base_rt_f abr
6555 where prv.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
6556 and prv.rt_end_dt > p_rt_end_dt
6557 and prv.prtt_rt_val_id = ecr.prtt_rt_val_id (+)
6558 and prv.business_group_id = p_business_group_id
6559 and prv.prtt_rt_val_stat_cd is null
6560 and nvl(prv.acty_base_rt_id,-1) = abr.acty_base_rt_id (+)
6561 and p_effective_date between abr.effective_start_date (+)
6562 and abr.effective_end_date (+);
6563 --
6564 cursor c_abr (p_acty_base_rt_id number) is
6565 select py.processing_type,
6566 abr.rcrrg_cd
6567 from ben_acty_base_rt_f abr,
6568 pay_element_types_f py
6569 where abr.element_type_id = py.element_type_id(+)
6570 and abr.acty_base_rt_id = p_acty_base_rt_id
6571 and p_effective_date between abr.effective_start_date
6572 and abr.effective_end_date
6573 and p_effective_date between py.effective_start_date(+)
6574 and py.effective_end_date(+);
6575 --
6576 l_abr c_abr%rowtype;
6577 --
6578 Cursor c_pcp(c_pcp_effective_date DATE)
6579 is
6580 select pcp.PRMRY_CARE_PRVDR_ID
6581 ,pcp.EFFECTIVE_START_DATE
6582 ,pcp.EFFECTIVE_END_DATE
6583 ,pcp.PRTT_ENRT_RSLT_ID
6584 ,pcp.BUSINESS_GROUP_ID
6585 ,pcp.OBJECT_VERSION_NUMBER
6586 from ben_prmry_care_prvdr_f pcp
6587 where business_group_id = p_business_group_id
6588 and prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
6589 and c_pcp_effective_date between effective_start_date --3631067: Changed p_effective_date to c_pcp_effective_date
6590 and effective_end_date
6591 ;
6592 -- 3574168
6593 -- Fetch all PCP records in future.
6594 Cursor c_pcp_future (c_pcp_effective_date DATE)
6595 is
6596 select pcp.PRMRY_CARE_PRVDR_ID
6597 ,pcp.EFFECTIVE_START_DATE
6598 ,pcp.EFFECTIVE_END_DATE
6599 ,pcp.PRTT_ENRT_RSLT_ID
6600 ,pcp.BUSINESS_GROUP_ID
6601 ,pcp.OBJECT_VERSION_NUMBER
6602 from ben_prmry_care_prvdr_f pcp
6603 where business_group_id = p_business_group_id
6604 and prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
6605 and c_pcp_effective_date < effective_start_date ----3631067: Changed p_effective_date to c_pcp_effective_date
6606 and NVL(effective_end_date, hr_api.g_eot) = hr_api.g_eot
6607 ;
6608 -- 3574168
6609
6610 --
6611 l_global_pil_rec ben_global_enrt.g_global_pil_rec_type;
6612 --
6613 -- ikasire: deleted the condition
6614 -- pen.enrt_cvg_strt_dt >= p_effective_date
6615 -- since it may not be always true. Instead added the
6616 -- condition pen.ENRT_CVG_THRU_DT = hr_api.g_eot
6617 -- to get the new prtt enrt record. Still there is a
6618 -- gap in this '1 prior' coding, which has to be
6619 -- handled with more detailed study.
6620 --Bug 2847110
6621 --18-Jan-2005
6622 --CF SUSP and INTERIM CASE
6623 --
6624 --bug#4967063 - added strt dt condition for getting new coverage at plan type
6625 --level - otherwise if multiple plans enrolled in same plan type leads to bug
6626 --10116920 added l_oipl_id
6627
6628 --12662110 added the conditions for '1 prior' coding to end the coverage dates correctly.
6629 -- If Plan Type are same and plans are Diferrent no need to check at the plan level and option level.
6630 -- so added (l_pl_id <> pen.pl_id) at plan level and option level.
6631 -- If the Plan is same then check at plan level and option level
6632 --12876320 added (prtt_enrt_rslt_id <> p_prtt_enrt_rslt_id) check at oipl level to Handle when
6633 -- Unrestricted LE is Processed.
6634
6635 cursor c_new_cvg_strt_dt(l_pl_typ_id number, l_ptip_id number, l_pl_id number, l_oipl_id number,
6636 p_enrt_cvg_strt_dt date ) is
6637 select max(enrt_cvg_strt_dt)
6638 from ben_prtt_enrt_rslt_f pen
6639 where pen.per_in_ler_id = nvl(p_per_in_ler_id, -1) -- is this OK?
6640 and ((pen.pgm_id is null and pen.pl_typ_id is not null
6641 and pen.pl_typ_id = nvl(l_pl_typ_id, -1))
6642 or (pen.ptip_id is not null and pen.ptip_id = nvl(l_ptip_id, -1))
6643 )
6644 and pen.no_lngr_elig_flag = 'N'
6645 and ((l_pl_id = -999 and pen.enrt_cvg_strt_dt >= p_enrt_cvg_strt_dt)
6646 or ((pen.pl_id = l_pl_id and -- Bug 2847110
6647 -- Bug# 12662110 start
6648 exists (select * from ben_prtt_enrt_rslt_f
6649 where per_in_ler_id = p_per_in_ler_id
6650 and pl_id = l_pl_id
6651 and pl_typ_id = l_pl_typ_id
6652 and ENRT_CVG_THRU_DT = hr_api.g_eot
6653 and effective_end_date = hr_api.g_eot))
6654 or (l_pl_id <> pen.pl_id
6655 and pen.effective_start_date >= p_effective_date)) -- 14599287
6656
6657 )
6658 --Bug #12662110 end
6659 -- and nvl(pen.oipl_id, -1) = nvl(l_oipl_id, -1) --10116920 -- comented for Bug #12662110
6660 -- Bug #12662110 start
6661 and ((pen.pl_id = l_pl_id and nvl(pen.oipl_id, -1) = nvl(l_oipl_id, -1))
6662 or (l_pl_id <> pen.pl_id)
6663 or ((nvl(pen.oipl_id, -1) <> nvl(l_oipl_id, -1) and pen.pl_id = l_pl_id)
6664 and not exists (select * from ben_prtt_enrt_rslt_f
6665 where oipl_id = l_oipl_id
6666 and per_in_ler_id = p_per_in_ler_id
6667 and ENRT_CVG_THRU_DT = hr_api.g_eot
6668 and EFFECTIVE_END_DATE = hr_api.g_eot
6669 and prtt_enrt_rslt_id <> p_prtt_enrt_rslt_id))--12876320
6670 )
6671 --Bug #12662110 end
6672 and pen.prtt_enrt_rslt_stat_cd is null
6673 -- and pen.enrt_cvg_strt_dt >= p_effective_date
6674 and pen.ENRT_CVG_THRU_DT = hr_api.g_eot
6675 and pen.effective_end_date = hr_api.g_eot
6676 -- and pen.business_group_id = p_business_group_id
6677 --and p_effective_date between pen.effective_start_date
6678 -- and pen.effective_end_date
6679 and pen.prtt_enrt_rslt_id <> p_prtt_enrt_rslt_id
6680 ;
6681 --
6682 cursor c_intm_other_rslt(p_per_in_ler_id number) is
6683 select 'Y'
6684 from ben_prtt_enrt_rslt_f pen
6685 where pen.rplcs_sspndd_rslt_id = l_pen.rplcs_sspndd_rslt_id
6686 and pen.business_group_id = p_business_group_id
6687 and pen.sspndd_flag = 'Y'
6688 and pen.enrt_cvg_thru_dt = hr_api.g_eot
6689 and pen.effective_end_date = hr_api.g_eot
6690 and pen.prtt_enrt_rslt_stat_cd is null
6691 and p_effective_date between
6692 pen.effective_start_date and pen.effective_end_date
6693 -- Bug 6165501 : Added union clause if its a Correction case, and interim has already
6694 -- been end-dated by the new pil, then no need to call delete_enrollment for the interim
6695 UNION
6696 select 'Y'
6697 from ben_prtt_enrt_rslt_f pen, ben_le_clsn_n_rstr cls
6698 where pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
6699 and pen.prtt_enrt_rslt_stat_cd is null
6700 and pen.enrt_cvg_thru_dt <> hr_api.g_eot
6701 and pen.per_in_ler_id = p_per_in_ler_id
6702 and cls.bkup_tbl_id = pen.prtt_enrt_rslt_id
6703 and cls.bkup_tbl_typ_cd = 'BEN_PRTT_ENRT_RSLT_F_CORR'
6704 and cls.per_in_ler_ended_id = p_per_in_ler_id;
6705 -- End Bug 6165501
6706
6707 --
6708 cursor c_interim is
6709 select pen.prtt_enrt_rslt_id,
6710 pen.object_version_number,
6711 pen.effective_start_date,
6712 pen.effective_end_date
6713 from ben_prtt_enrt_rslt_f pen
6714 where pen.prtt_enrt_rslt_id = l_pen.rplcs_sspndd_rslt_id
6715 and pen.business_group_id = p_business_group_id
6716 and pen.prtt_enrt_rslt_stat_cd is null
6717 and p_effective_date between
6718 pen.effective_start_date and pen.effective_end_date;
6719 --
6720 -- 12583091
6721 --
6722 cursor c_get_interim is
6723 select pen.*
6724 from ben_prtt_enrt_rslt_f pen
6725 where pen.prtt_enrt_rslt_id =
6726 (select pen2.rplcs_sspndd_rslt_id
6727 from ben_prtt_enrt_rslt_f pen2
6728 where pen2.per_in_ler_id = p_per_in_ler_id
6729 and pen2.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
6730 and pen2.sspndd_flag = 'Y'
6731 and pen2.prtt_enrt_rslt_stat_cd is null
6732 and pen2.effective_end_date <> hr_api.g_eot
6733 and pen2.business_group_id = p_business_group_id)
6734 and pen.business_group_id = p_business_group_id
6735 -- and pen.prtt_enrt_rslt_stat_cd is null
6736 and pen.enrt_cvg_thru_dt <> hr_api.g_eot
6737 and pen.per_in_ler_id = p_per_in_ler_id
6738 and p_effective_date between
6739 pen.effective_start_date and pen.effective_end_date;
6740
6741 cursor c_rslt_opt (p_person_id number ,
6742 p_pgm_id number ,
6743 p_pl_id number ,
6744 p_oipl_id number ,
6745 p_per_in_ler_id number ,
6746 p_effective_date date
6747 ) is
6748 select 'x'
6749 from ben_prtt_enrt_rslt_f pen
6750 where pen.person_id = p_person_id
6751 and nvl(p_pgm_id,-1) = nvl(pen.pgm_id,-1)
6752 and nvl(p_pl_id ,-1) = nvl(pen.pl_id,-1)
6753 and nvl(p_oipl_id,-1) = nvl(pen.oipl_id, -1)
6754 and (p_per_in_ler_id <> pen.per_in_ler_id
6755 or l_global_pil_rec.typ_cd = 'SCHEDDU') -- 4919591
6756 and pen.prtt_enrt_rslt_stat_cd is null
6757 and pen.sspndd_flag = 'N'
6758 and p_effective_date > pen.effective_start_date
6759 and pen.enrt_cvg_thru_dt > p_effective_date -- 4919591
6760 and pen.effective_end_date = hr_api.g_eot; --4919591
6761
6762
6763 cursor c_rslt_pl ( p_person_id number ,
6764 p_pgm_id number ,
6765 p_pl_id number ,
6766 p_per_in_ler_id number ,
6767 p_effective_date date
6768 ) is
6769 select 'x'
6770 from ben_prtt_enrt_rslt_f pen
6771 where pen.person_id = p_person_id
6772 and nvl(p_pgm_id,-1) = nvl(pen.pgm_id,-1)
6773 and p_pl_id = pen.pl_id
6774 and (p_per_in_ler_id <> pen.per_in_ler_id
6775 or l_global_pil_rec.typ_cd = 'SCHEDDU') -- 4919591
6776 and pen.prtt_enrt_rslt_stat_cd is null
6777 and pen.sspndd_flag = 'N'
6778 and p_effective_date > pen.effective_start_date
6779 and p_effective_date < nvl(pen.erlst_deenrt_dt,(p_effective_date + 1)); ----Bug 8578358
6780 /*Bug : Commented below conditions. Check only for if erlst_deenrt_dt is greater than
6781 p_effective_date for previous per_in_ler's
6782 /*
6783 and pen.enrt_cvg_thru_dt > p_effective_date -- 4919591
6784 and pen.effective_end_date = hr_api.g_eot; -- 4919591------------7458990
6785 */
6786
6787 cursor c_rslt_ptip( p_person_id number ,
6788 p_pgm_id number ,
6789 p_ptip_id number ,
6790 p_per_in_ler_id number ,
6791 p_effective_date date
6792 ) is
6793 select 'x'
6794 from ben_prtt_enrt_rslt_f pen
6795 where pen.person_id = p_person_id
6796 and p_pgm_id = pen.pgm_id
6797 and p_ptip_id = pen.ptip_id
6798 and (p_per_in_ler_id <> pen.per_in_ler_id
6799 or l_global_pil_rec.typ_cd = 'SCHEDDU')
6800 and pen.prtt_enrt_rslt_stat_cd is null
6801 and pen.sspndd_flag = 'N'
6802 and p_effective_date > pen.effective_start_date
6803 and pen.enrt_cvg_thru_dt > p_effective_date
6804 and pen.effective_end_date = hr_api.g_eot;
6805 --
6806 cursor c_per_in_ler (p_per_in_ler_id number) is
6807 select *
6808 from ben_per_in_ler
6809 where per_in_ler_id = p_per_in_ler_id
6810 and business_group_id = p_business_group_id;
6811
6812 --
6813 l_per_in_ler c_per_in_ler%rowtype;
6814 --
6815 cursor c_pen_ovn (p_prtt_enrt_rslt_id number, p_effective_date date ) is
6816 select pen.object_version_number,pen.effective_start_date --4663971
6817 from ben_prtt_enrt_rslt_f pen
6818 where pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
6819 and p_effective_date between pen.effective_start_date and pen.effective_end_date ;
6820 l_pen_ovn c_pen_ovn%rowtype;
6821 --
6822 cursor c_pel (p_elig_pe_elctbl_chc_id number) is
6823 select pel.enrt_perd_id,pel.lee_rsn_id
6824 from ben_pil_elctbl_chc_popl pel
6825 ,ben_elig_per_elctbl_chc epe
6826 where pel.pil_elctbl_chc_popl_id = epe.pil_elctbl_chc_popl_id
6827 and epe.elig_per_elctbl_chc_id = p_elig_pe_elctbl_chc_id;
6828 --
6829 CURSOR c_lee_rsn_for_plan (c_ler_id number, c_pl_id number,c_effective_date date ) IS
6830 SELECT leer.lee_rsn_id
6831 FROM ben_lee_rsn_f leer,
6832 ben_popl_enrt_typ_cycl_f petc
6833 WHERE leer.ler_id = c_ler_id
6834 AND leer.business_group_id = p_business_group_id
6835 AND c_effective_date BETWEEN leer.effective_start_date
6836 AND leer.effective_end_date
6837 AND leer.popl_enrt_typ_cycl_id = petc.popl_enrt_typ_cycl_id
6838 AND petc.pl_id = c_pl_id
6839 AND petc.enrt_typ_cycl_cd = 'L' -- life event
6840 AND petc.business_group_id = p_business_group_id
6841 AND c_effective_date BETWEEN petc.effective_start_date
6842 AND petc.effective_end_date;
6843 --
6844 CURSOR c_lee_rsn_for_program (c_ler_id number, c_pgm_id number,c_effective_date date )IS
6845 SELECT leer.lee_rsn_id
6846 FROM ben_lee_rsn_f leer,
6847 ben_popl_enrt_typ_cycl_f petc
6848 WHERE leer.ler_id = c_ler_id
6849 AND leer.business_group_id = p_business_group_id
6850 AND c_effective_date BETWEEN leer.effective_start_date
6851 AND leer.effective_end_date
6852 AND leer.popl_enrt_typ_cycl_id = petc.popl_enrt_typ_cycl_id
6853 AND petc.pgm_id = c_pgm_id
6854 AND petc.enrt_typ_cycl_cd = 'L'
6855 AND petc.business_group_id = p_business_group_id
6856 AND c_effective_date BETWEEN petc.effective_start_date
6857 AND petc.effective_end_date;
6858 --
6859 l_pel c_pel%rowtype;
6860 l_interim c_interim%rowtype;
6861 l_interim_enrt c_get_interim%rowtype; -- 12583091
6862 --
6863 -- Bug 2627078 update epe with current pen_id
6864 cursor c_curr_rslt (p_person_id number ,
6865 p_pgm_id number ,
6866 p_pl_id number ,
6867 p_oipl_id number ,
6868 p_per_in_ler_id number
6869 ) is
6870 select prtt_enrt_rslt_id
6871 from ben_prtt_enrt_rslt_f pen
6872 where pen.person_id = p_person_id
6873 and nvl(p_pgm_id,-1) = nvl(pen.pgm_id,-1)
6874 and nvl(p_pl_id ,-1) = nvl(pen.pl_id,-1)
6875 and nvl(p_oipl_id,-1) = nvl(pen.oipl_id, -1)
6876 and p_per_in_ler_id = pen.per_in_ler_id
6877 and pen.prtt_enrt_rslt_stat_cd is null
6878 and pen.enrt_cvg_thru_dt <> hr_api.g_eot
6879 ;
6880 --
6881 l_current_result_id number ;
6882 --
6883 -- Bug 2689915
6884 cursor c_ler is
6885 select typ_cd
6886 from ben_ler_f ler,
6887 ben_prtt_enrt_rslt_f pen
6888 where pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
6889 and pen.ler_id = ler.ler_id ;
6890 --
6891 cursor c_old_corr_pen (c_pil_id number
6892 ,c_pen_id number
6893 ,c_pen_effective_start_date date) is -- bug 7197868
6894 select per_in_ler_id
6895 from BEN_LE_CLSN_N_RSTR
6896 where bkup_tbl_id = c_pen_id
6897 and per_in_ler_ended_id = c_pil_id
6898 and per_in_ler_id <> c_pil_id
6899 and effective_start_date = c_pen_effective_start_date -- bug 7197868
6900 and enrt_cvg_thru_dt = hr_api.g_eot;
6901 l_corr_pil_id BEN_LE_CLSN_N_RSTR.per_in_ler_id%type ;
6902
6903 cursor c_pen_obj_no (c_pil_id number
6904 ,c_pen_id number ) is
6905 select object_version_number
6906 from ben_prtt_enrt_rslt_f pen
6907 where pen.prtt_enrt_rslt_id = c_pen_id
6908 and pen.per_in_ler_id = c_pil_id
6909 and p_effective_date between
6910 pen.effective_start_date and pen.effective_end_date ;
6911 --
6912 --Added for Bug#5018328
6913
6914 cursor c_crntly_enrd_flag(p_elig_pe_elctbl_chc_id number) is
6915 select epe.crntly_enrd_flag,ler.typ_cd
6916 from ben_elig_per_elctbl_chc epe,
6917 ben_ler_f ler,
6918 ben_prtt_enrt_rslt_f pen
6919 where epe.per_in_ler_id=p_per_in_ler_id
6920 and epe.elig_per_elctbl_chc_id=p_elig_pe_elctbl_chc_id
6921 and epe.prtt_enrt_rslt_id=pen.prtt_enrt_rslt_id
6922 and pen.per_in_ler_id=p_per_in_ler_id
6923 and pen.ler_id = ler.ler_id
6924 and nvl(epe.erlst_deenrt_dt,hr_api.g_sot) > p_effective_date;
6925
6926 l_crntly_enrd_flag varchar2(10);
6927 l_ler_type_cd varchar2(20);
6928
6929 --Added for Bug#5018328
6930
6931 cursor c_crntly_enrd_flag_unres(p_elig_pe_elctbl_chc_id number) is
6932 select ler.typ_cd
6933 from ben_prtt_enrt_rslt_f pen,
6934 ben_elig_per_elctbl_chc epe,
6935 ben_ler_f ler
6936 where epe.elig_per_elctbl_chc_id=p_elig_pe_elctbl_chc_id
6937 and epe.per_in_ler_id=p_per_in_ler_id
6938 and pen.ler_id = ler.ler_id
6939 and epe.prtt_enrt_rslt_id=pen.prtt_enrt_rslt_id
6940 and pen.per_in_ler_id=p_per_in_ler_id
6941 and nvl(epe.erlst_deenrt_dt,hr_api.g_sot) > p_effective_date;
6942
6943 l_typ_cd varchar2(20);
6944 --
6945
6946 --5663280
6947 cursor c_check_carry_fwd_enrt(p_prtt_enrt_rslt_id number,
6948 p_per_in_ler_id number,
6949 p_enrt_cvg_strt_dt date,
6950 p_effective_start_date date) is
6951 select 'Y'
6952 from ben_prtt_enrt_rslt_f pen
6953 where pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
6954 and pen.prtt_enrt_rslt_stat_cd is null
6955 and pen.enrt_cvg_thru_dt = to_date('4712/12/31','rrrr/mm/dd')
6956 and pen.per_in_ler_id <> p_per_in_ler_id
6957 and pen.enrt_cvg_strt_dt = p_enrt_cvg_strt_dt
6958 and pen.effective_end_date < p_effective_start_date;
6959
6960 l_check_carry_fwd_enrt varchar2(1);
6961 --
6962
6963 -----Bug 6925893
6964 cursor c_get_old_prv is
6965 SELECT oldprv.prtt_rt_val_id,
6966 oldprv.prtt_rt_val_stat_cd ,
6967 oldprv.object_version_number,
6968 abr.input_value_id,
6969 abr.element_type_id
6970 FROM ben_prtt_rt_val oldprv,
6971 ben_prtt_rt_val curprv,
6972 ben_acty_base_rt_f abr
6973 WHERE curprv.business_group_id=oldprv.business_group_id
6974 AND curprv.per_in_ler_id = oldprv.ended_per_in_ler_id
6975 AND oldprv.rt_end_dt <> hr_api.g_eot
6976 AND oldprv.acty_base_rt_id = curprv.acty_base_rt_id
6977 AND oldprv.prtt_rt_val_stat_cd IS NULL
6978 and curprv.prtt_enrt_rslt_id=p_prtt_enrt_rslt_id
6979 AND abr.acty_base_rt_id = oldprv.acty_base_rt_id
6980 AND p_effective_date BETWEEN abr.effective_start_date
6981 AND abr.effective_end_date
6982 and oldprv.ended_per_in_ler_id= p_per_in_ler_id
6983 AND oldprv.business_group_id= p_business_group_id;
6984
6985 l_get_old_prv c_get_old_prv%ROWTYPE;
6986 ------------Bug 7209243
6987 --The cursor is written based on the assumption that there will be only plan per plan type
6988 --elected in a Life Event.
6989 cursor c_get_epe(p_pl_typ_id number) is
6990 SELECT epe.*
6991 FROM ben_prtt_enrt_rslt_f pen,
6992 ben_elig_per_elctbl_chc epe
6993 WHERE pen.per_in_ler_id = p_per_in_ler_id
6994 AND pen.business_group_id = p_business_group_id
6995 AND epe.per_in_ler_id = pen.per_in_ler_id
6996 AND epe.prtt_enrt_rslt_id = pen.prtt_enrt_rslt_id
6997 and pen.pl_typ_id = p_pl_typ_id
6998 AND pen.effective_end_date = hr_api.g_eot
6999 AND pen.enrt_cvg_thru_dt = hr_api.g_eot
7000 ORDER BY pen.effective_start_date desc;
7001 l_get_epe c_get_epe%rowtype;
7002
7003 cursor c_get_old_prv1 is
7004 SELECT distinct oldprv.prtt_rt_val_id, ---Bug 9290518
7005 oldprv.prtt_rt_val_stat_cd ,
7006 oldprv.object_version_number,
7007 abr.input_value_id,
7008 abr.element_type_id
7009 FROM ben_prtt_rt_val oldprv,
7010 ben_prtt_rt_val curprv,
7011 ben_acty_base_rt_f abr,
7012 ben_acty_base_rt_f abr2 ,
7013 ben_prtt_enrt_rslt_f pen
7014 WHERE curprv.business_group_id=oldprv.business_group_id
7015 AND curprv.per_in_ler_id = oldprv.ended_per_in_ler_id
7016 AND oldprv.rt_end_dt <> hr_api.g_eot
7017 AND oldprv.prtt_rt_val_stat_cd IS NULL
7018 AND abr.acty_base_rt_id = oldprv.acty_base_rt_id
7019 AND p_effective_date BETWEEN abr.effective_start_date
7020 AND abr.effective_end_date
7021 AND abr2.acty_base_rt_id = curprv.acty_base_rt_id
7022 AND p_effective_date BETWEEN abr2.effective_start_date
7023 AND abr2.effective_end_date
7024 AND oldprv.acty_base_rt_id <> curprv.acty_base_rt_id
7025 and oldprv.ended_per_in_ler_id= p_per_in_ler_id
7026 AND oldprv.business_group_id= p_business_group_id
7027 AND pen.per_in_ler_id = oldprv.per_in_ler_id
7028 AND pen.prtt_enrt_rslt_id = oldprv.prtt_enrt_rslt_id
7029 and oldprv.prtt_enrt_rslt_id = curprv.prtt_enrt_rslt_id -- 16068560
7030 AND pen.business_group_id = p_business_group_id
7031 and curprv.prtt_enrt_rslt_id=p_prtt_enrt_rslt_id
7032 AND EXISTS (SELECT pen1.pl_typ_id
7033 FROM ben_prtt_enrt_rslt_f pen1
7034 WHERE pen1.business_group_id = pen.business_group_id
7035 AND pen1.per_in_ler_id = curprv.per_in_ler_id
7036 AND pen1.pl_typ_id = pen.pl_typ_id
7037 AND pen1.prtt_enrt_rslt_id = curprv.prtt_enrt_rslt_id
7038 AND pen1.effective_end_date = hr_api.g_eot
7039 AND pen1.enrt_cvg_thru_dt = hr_api.g_eot);
7040 -- l_get_old_prv1 c_get_old_prv1%rowtype; ---Bug 9290518
7041 l_rt_strt_dt1 date;
7042 l_enrt_cvg_end_dt1 date;
7043 l_enrt_cvg_strt_dt1 date;
7044 l_rt_end_dt1 date;
7045 ------------Bug 7209243
7046 --
7047 -- Bug No 5637595 Added to get the lf_evt_ocrd_dt of the pil
7048 --
7049 cursor get_lf_evt_dt is
7050 select lf_evt_ocrd_dt from
7051 ben_per_in_ler where
7052 per_in_ler_id = p_per_in_ler_id and
7053 per_in_ler_stat_cd not in ('VOIDD','BCKDT');
7054 l_lf_evt_ocrd_dt date;
7055
7056
7057 --this is a fix for bug#:6641853 when
7058 --in the scenario where there is a
7059 --LE process and then the open process
7060 --on the same day.
7061 --The first LE is FONM and the person is enrolled
7062 --then again the person enrolls on the same day for the open
7063 --again the person chages the election on the other
7064 --day, which voids the current enrollment.
7065 --Now we check in the backup table to see
7066 --if any correction has happened and then we
7067 --dont void.
7068 cursor c_get_correction_info (cp_prtt_enrt_rslt_id NUMBER
7069 ,cp_effective_date DATE
7070 ,cp_per_in_ler_id NUMBER
7071 ,cp_person_id NUMBER --12566240
7072 ) IS
7073 SELECT 'X' place_holder
7074 FROM ben_le_clsn_n_rstr bcr
7075 WHERE bcr.bkup_tbl_id=cp_prtt_enrt_rslt_id
7076 AND bcr.effective_start_date=cp_effective_date
7077 AND bcr.person_id = cp_person_id -- Bug 12356840
7078 UNION
7079 SELECT 'X' place_holder
7080 FROM ben_le_clsn_n_rstr bcr
7081 WHERE bcr.bkup_tbl_id=cp_prtt_enrt_rslt_id
7082 AND bcr.per_in_ler_id <> cp_per_in_ler_id
7083 AND bcr.person_id = cp_person_id -- Bug 12356840
7084 --AND bcr.bkup_tbl_typ_cd LIKE '%CORR' -- Bug 12356840
7085 AND bcr.bkup_tbl_typ_cd = 'BEN_PRTT_ENRT_RSLT_F_CORR' ;
7086
7087 l_get_correction_info c_get_correction_info%ROWTYPE;
7088
7089 -- Local variable declaration.
7090 --
7091 -----Bug 9290518
7092 l_old_prv_found boolean := false;
7093 -----Bug 9290518
7094 l_temp_stat_cd VARCHAR2(30);
7095 l_temp_date DATE;
7096 l_proc varchar2(72); -- := g_package||'delete_enrollment';
7097 l_dpnt_cvg_end_dt date;
7098 l_dpnt_cvg_thru_dt date;
7099 l_dump_date date;
7100 l_datetrack_mode varchar2(20);
7101 l_step integer;
7102 l_tmp_ovn integer;
7103 l_enrt_cvg_strt_dt date;
7104 l_enrt_cvg_strt_dt_cd varchar2(30);
7105 l_enrt_cvg_strt_dt_rl number;
7106 l_rt_strt_dt date;
7107 l_rt_strt_dt_cd varchar2(30);
7108 l_rt_strt_dt_rl number;
7109 l_enrt_cvg_end_dt date;
7110 l_enrt_cvg_end_dt_cd varchar2(30);
7111 l_enrt_cvg_end_dt_rl number;
7112 l_rt_end_dt date;
7113 l_eff_dt date;
7114 l_rt_end_dt_cd varchar2(30);
7115 l_rt_end_dt_rl number;
7116 l_elig_per_elctbl_chc_id number(15);
7117 l_new_enrt_cvg_strt_dt date;
7118 l_date date;
7119 l_pil_id number;
7120 l_cvg_end_dt_cd varchar2(30);
7121 l_dummy varchar2(1);
7122 l_rqd_perd_enrt_nenrt_uom varchar2(30);
7123 l_rqd_perd_enrt_nenrt_val number;
7124 l_rqd_perd_enrt_nenrt_rl number;
7125 l_level varchar2(30);
7126 l_other_pen_rec ben_prtt_enrt_rslt_f%rowtype;
7127 l_intm_other_rslt varchar2(30) := 'N';
7128 l_new_enrollment varchar2(1) := 'N' ;
7129 l_object_version_number number ;
7130 --
7131 l_pl_rec ben_cobj_cache.g_pl_inst_row;
7132 l_oipl_rec ben_cobj_cache.g_oipl_inst_row;
7133 l_deenrol_dt date;
7134 l_prv_count number;
7135 l_env_rec ben_env_object.g_global_env_rec_type;
7136 l_benmngle_parm_rec benutils.g_batch_param_rec;
7137 l_enrt_perd_id number ;
7138 l_lee_rsn_id number := null ;
7139 /* Start of Changes WWBUG: 1646442: added */
7140 l_ppe_dt_to_use date;
7141 l_ppe_datetrack_mode varchar2(30);
7142 /* End of Changes WWBUG: 1646442 */
7143 l_ler_typ_cd varchar2(30);
7144 l_pcp_effective_date date;
7145 l_pcp_effective_start_date date;
7146 l_process_date date;
7147 l_rplcs_sspndd_rslt_id number;
7148 l_prtt_rt_val_stat_cd varchar2(30);
7149 l_sub varchar2(300);
7150 l_prtt_enrt_rslt_Stat_cd varchar2(300);
7151 l_adjust varchar2(1);
7152 prev_prtt_rt_val_id number := -1; -- Bug 5739530
7153
7154 /*Added for Bug 7561395*/
7155 l_actn_start_date date;
7156 l_actn_end_date date;
7157 l_rslt_object_version_number number;
7158 l_actn_object_version_number number;
7159 l_prtt_enrt_actn_id number;
7160 l_ctfn_start_date date;
7161 l_ctfn_end_date date;
7162 l_ctfn_object_version_number number;
7163 l_prtt_enrt_ctfn_prvdd_id number;
7164 l_act_flag boolean default false;
7165 l_ctfn_flag boolean default false;
7166 l_same_per_in_ler_id number;
7167 l_dummy1 varchar2(1);
7168 l_oper_in_ler_id number;
7169 l_nper_in_ler_id number;
7170
7171 cursor c_grt_new_ovn is
7172 select object_version_number from ben_prtt_enrt_rslt_f
7173 where prtt_enrt_rslt_id = g_new_prtt_enrt_rslt_id;
7174
7175 cursor c_get_actn_items is
7176 select actn.* from ben_prtt_enrt_actn_f actn,
7177 (select max(effective_start_date) max_effective_date,prtt_enrt_actn_id from ben_prtt_enrt_actn_f
7178 where prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
7179 and per_in_ler_id = p_per_in_ler_id
7180 and cmpltd_dt is not null --Bug 8669907: Get only the completed action items for creation
7181 group by prtt_enrt_actn_id) new_actn
7182 where new_actn.max_effective_date=actn.effective_start_date
7183 and new_actn.prtt_enrt_actn_id=actn.prtt_enrt_actn_id
7184 and actn.cmpltd_dt is not null;
7185
7186 l_act_items_rec c_get_actn_items%rowtype;
7187 TYPE l_act_items_table IS TABLE OF ben_prtt_enrt_actn_f%rowtype
7188 INDEX BY BINARY_INTEGER;
7189 l_act_items l_act_items_table;
7190
7191 cursor c_get_ctfn is
7192 select ctfn.* from ben_prtt_enrt_ctfn_prvdd_f ctfn,ben_prtt_enrt_actn_f actn,
7193 (select max(effective_start_date) max_effective_date,prtt_enrt_actn_id,prtt_enrt_ctfn_prvdd_id
7194 from ben_prtt_enrt_ctfn_prvdd_f
7195 where prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
7196 group by prtt_enrt_actn_id,prtt_enrt_ctfn_prvdd_id) max_ctfn_rec
7197 where ctfn.prtt_enrt_ctfn_prvdd_id=max_ctfn_rec.prtt_enrt_ctfn_prvdd_id
7198 and ctfn.prtt_enrt_actn_id=max_ctfn_rec.prtt_enrt_actn_id
7199 and ctfn.effective_start_date=max_ctfn_rec.max_effective_date
7200 and actn.prtt_enrt_actn_id = ctfn.prtt_enrt_actn_id
7201 and actn.cmpltd_dt is not null; -- Bug 8669907: Get only the completed action items for creation
7202
7203 cursor c_chk_same_event(c_prtt_enrt_rslt_id number) is
7204 select per_in_ler_id from ben_prtt_enrt_rslt_f
7205 where prtt_enrt_rslt_id = c_prtt_enrt_rslt_id
7206 and prtt_enrt_rslt_stat_cd is NULL;
7207
7208 l_ctfn_rec c_get_ctfn%rowtype;
7209 TYPE l_ctfn_table IS TABLE OF ben_prtt_enrt_ctfn_prvdd_f%rowtype
7210 INDEX BY BINARY_INTEGER;
7211 l_ctfn l_ctfn_table;
7212
7213 cursor c_chk_act_item_exits(c_prtt_enrt_rslt_id number) is
7214 select '1' from ben_prtt_enrt_actn_f actn
7215 where actn.prtt_enrt_rslt_id=c_prtt_enrt_rslt_id;
7216
7217 /* Added for Bug 8669907 */
7218 cursor c_chk_same_comp_obj(c_new_pen_id number,c_old_pen_id number,c_per_in_ler_id number) is
7219 select 'Y' from
7220 ben_prtt_enrt_rslt_f new_pen,
7221 ben_prtt_enrt_rslt_f old_pen
7222 where new_pen.prtt_enrt_rslt_id = c_new_pen_id
7223 and old_pen.prtt_enrt_rslt_id = c_old_pen_id
7224 and old_pen.per_in_ler_id = c_per_in_ler_id
7225 and new_pen.per_in_ler_id = c_per_in_ler_id
7226 and nvl(old_pen.pgm_id,-1) = nvl(new_pen.pgm_id,-1)
7227 and nvl(old_pen.pl_id,-1) = nvl(new_pen.pl_id,-1)
7228 and nvl(old_pen.oipl_id,-1) = nvl(new_pen.oipl_id,-1)
7229 and old_pen.pl_typ_id = new_pen.pl_typ_id;
7230
7231 cursor c_bnft_amt(c_prtt_enrt_rslt_id number,c_per_in_ler_id number) is
7232 select bnft_amt,
7233 mn_val,
7234 mx_val ,
7235 entr_val_at_enrt_flag,
7236 cvg_mlt_cd,
7237 mx_wout_ctfn_val
7238 from ben_enrt_bnft bnft,
7239 ben_elig_per_elctbl_chc epe,
7240 ben_prtt_enrt_rslt_f pen
7241 where epe.prtt_enrt_rslt_id = c_prtt_enrt_rslt_id
7242 and epe.per_in_ler_id = c_per_in_ler_id
7243 and pen.per_in_ler_id = c_per_in_ler_id
7244 and pen.prtt_enrt_rslt_id = epe.prtt_enrt_rslt_id
7245 and epe.elig_per_elctbl_chc_id = bnft.elig_per_elctbl_chc_id;
7246
7247 l_bnft c_bnft_amt%rowtype;
7248 l_create_flag varchar2(1) default 'N';
7249 l_sspnd_flag varchar2(1) default 'N';
7250 /*End of Bug 8669907 */
7251
7252 /*Ended for Bug 7561395*/
7253
7254 --
7255 ------------Bug 8222481
7256 cursor c_get_last_pil(p_person_id number,p_pen_id number) is
7257 SELECT pil.per_in_ler_id
7258 FROM ben_per_in_ler pil
7259 WHERE pil.per_in_ler_stat_cd = 'PROCD'
7260 AND pil.lf_evt_ocrd_dt = (SELECT Max(pil1.lf_evt_ocrd_dt)
7261 FROM ben_per_in_ler pil1,
7262 ben_prtt_enrt_rslt_f pen ------------Bug 8688513
7263 WHERE pil1.person_id = pil.person_id
7264 AND pil1.per_in_ler_stat_cd = 'PROCD'
7265 AND pen.prtt_enrt_rslt_id = p_pen_id
7266 AND pen.prtt_enrt_rslt_stat_cd IS NULL
7267 AND pen.per_in_ler_id = pil1.per_in_ler_id
7268 AND pen.enrt_cvg_thru_dt >= pen.enrt_cvg_strt_dt
7269 )
7270 and pil.person_id = p_person_id ;
7271 l_get_last_pil c_get_last_pil%rowtype;
7272 cursor c_get_ended_pen(p_per_in_ler_id number,
7273 p_pl_typ_id number,
7274 p_pgm_id number) is
7275 SELECT *
7276 FROM ben_prtt_enrt_rslt_f pen
7277 WHERE pen.per_in_ler_id = p_per_in_ler_id
7278 AND pen.pl_typ_id = p_pl_typ_id
7279 AND pen.pgm_id = p_pgm_id
7280 AND enrt_cvg_thru_dt <> hr_api.g_eot
7281 AND pen.prtt_enrt_rslt_stat_cd IS NULL;
7282
7283 type l_get_ended_pen1 is table of c_get_ended_pen%rowtype;
7284 l_get_ended_pen l_get_ended_pen1;
7285
7286 cursor c_last_pil_pen(p_per_in_ler_id number,p_pen_id number) is
7287 SELECT *
7288 FROM ben_prtt_enrt_rslt_f pen
7289 WHERE pen.per_in_ler_id = p_per_in_ler_id
7290 AND pen.prtt_enrt_rslt_id = p_pen_id
7291 AND pen.prtt_enrt_rslt_stat_cd IS NULL;
7292
7293 l_last_pil_pen c_last_pil_pen%rowtype;
7294
7295 cursor c_last_pil_pen1(p_per_in_ler_id number,
7296 p_pl_id number,
7297 p_pgm_id number) is
7298 SELECT *
7299 FROM ben_prtt_enrt_rslt_f pen
7300 WHERE pen.per_in_ler_id = p_per_in_ler_id
7301 AND pen.pl_id = p_pl_id
7302 and pen.pgm_id = p_pgm_id
7303 AND pen.prtt_enrt_rslt_stat_cd IS NULL;
7304
7305 l_last_pil_pen1 c_last_pil_pen1%rowtype;
7306
7307 l_del_next_chg_pen c_last_pil_pen1%rowtype;
7308 --
7309 -- bug 12583091
7310 --
7311 cursor c_enrt_rt(p_prtt_rt_val_id number
7312 ) is
7313 select ecr.*
7314 ,enb.elig_per_elctbl_chc_id enb_per_elctbl_chc_id
7315 from ben_enrt_rt ecr
7316 ,ben_enrt_bnft enb
7317 where ecr.prtt_rt_val_id = p_prtt_rt_val_id
7318 and exists (select null
7319 from ben_prtt_enrt_rslt_f pen
7320 where pen.prtt_enrt_rslt_stat_cd is null
7321 and pen.sspndd_flag = 'Y'
7322 and pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
7323 and pen.per_in_ler_id = p_per_in_ler_id
7324 )
7325 and ecr.enrt_bnft_id = enb.enrt_bnft_id (+);
7326
7327 l_enrt_rt c_enrt_rt%rowtype;
7328 l_dummy_date date;
7329 l_dummy_varchar varchar2(30);
7330 l_dummy_number number;
7331 l_prv_rt_strt_dt date;
7332 --
7333 -- end 12583091
7334 --
7335 ----------------Bug 8222481
7336 procedure void_rate (p_prtt_enrt_rslt_id number,
7337 p_business_group_id number,
7338 p_person_id number,
7339 p_per_in_ler_id number,
7340 p_effective_date date) is
7341 --
7342 --Bug 3412562 Doesn't look like we need link to ben_enrt_rt table here.
7343 --
7344 cursor c_prv is
7345 select prv.prtt_rt_val_id
7346 ,prv.object_version_number
7347 ,prv.acty_base_rt_id
7348 ,abr.element_type_id
7349 ,abr.input_value_id
7350 ,prv.rt_strt_dt
7351 from ben_prtt_rt_val prv
7352 ,ben_acty_base_rt_f abr
7353 where prv.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
7354 -- bug: 5550679
7355 and prv.per_in_ler_id = p_per_in_ler_id
7356 --
7357 and prv.prtt_rt_val_stat_cd is null
7358 and prv.business_group_id = p_business_group_id
7359 and prv.acty_base_rt_id = abr.acty_base_rt_id
7360 and p_effective_date between abr.effective_start_date
7361 and abr.effective_end_date
7362 order by prv.rt_strt_dt desc;
7363 l_prv c_prv%rowtype;
7364 --
7365 -- bug 12583091
7366 --
7367 cursor c_enrt_rt(p_prtt_rt_val_id number
7368 ) is
7369 select ecr.*
7370 ,enb.elig_per_elctbl_chc_id enb_per_elctbl_chc_id
7371 from ben_enrt_rt ecr
7372 ,ben_enrt_bnft enb
7373 where ecr.prtt_rt_val_id = p_prtt_rt_val_id
7374 and exists (select null
7375 from ben_prtt_enrt_rslt_f pen
7376 where pen.prtt_enrt_rslt_stat_cd is null
7377 and pen.sspndd_flag = 'Y'
7378 and pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
7379 and pen.per_in_ler_id = p_per_in_ler_id
7380 )
7381 and ecr.enrt_bnft_id = enb.enrt_bnft_id (+);
7382
7383 l_enrt_rt c_enrt_rt%rowtype;
7384 l_dummy_date date;
7385 l_dummy_varchar varchar2(30);
7386 l_dummy_number number;
7387 l_rt_strt_dt date;
7388 --
7389 -- end 12583091
7390 --
7391 begin
7392 --
7393 For l_prv in c_prv loop
7394 --
7395 -- bug 12583091
7396 -- If the rate was for an enrollment that was previously
7397 -- suspended and the prtt_rt_val rt start date has been updated
7398 -- in the unsuspend process, re-instate the original rt start date.
7399 --
7400 hr_utility.set_location('l_prv.prtt_rt_val_id:'|| l_prv.prtt_rt_val_id, 10);
7401 open c_enrt_rt(l_prv.prtt_rt_val_id);
7402 fetch c_enrt_rt into l_enrt_rt;
7403 if c_enrt_rt%found then
7404 close c_enrt_rt;
7405 hr_utility.set_location('l_enrt_rt.elig_per_elctbl_chc_id '|| l_enrt_rt.enb_per_elctbl_chc_id, 10);
7406 --
7407 ben_determine_date.rate_and_coverage_dates
7408 (p_which_dates_cd => 'R'
7409 ,p_business_group_id => p_business_group_id
7410 ,p_elig_per_elctbl_chc_id => nvl(l_enrt_rt.elig_per_elctbl_chc_id,
7411 l_enrt_rt.enb_per_elctbl_chc_id)
7412 ,p_enrt_cvg_strt_dt => l_dummy_date
7413 ,p_enrt_cvg_strt_dt_cd => l_dummy_varchar
7414 ,p_enrt_cvg_strt_dt_rl => l_dummy_number
7415 ,p_rt_strt_dt => l_rt_strt_dt
7416 ,p_rt_strt_dt_cd => l_dummy_varchar
7417 ,p_rt_strt_dt_rl => l_dummy_number
7418 ,p_enrt_cvg_end_dt => l_dummy_date
7419 ,p_enrt_cvg_end_dt_cd => l_dummy_varchar
7420 ,p_enrt_cvg_end_dt_rl => l_dummy_number
7421 ,p_rt_end_dt => l_dummy_date
7422 ,p_rt_end_dt_cd => l_dummy_varchar
7423 ,p_rt_end_dt_rl => l_dummy_number
7424 ,p_acty_base_rt_id => l_enrt_rt.acty_base_rt_id
7425 ,p_effective_date => p_effective_date
7426 );
7427 hr_utility.set_location('l_rt_strt_dt:'|| l_rt_strt_dt, 10);
7428 hr_utility.set_location('l_prv.rt_strt_dt:'|| l_prv.rt_strt_dt, 10);
7429 --
7430 if l_rt_strt_dt <> l_prv.rt_strt_dt then
7431 ben_enrollment_rate_api.update_enrollment_rate
7432 (p_enrt_rt_id => l_enrt_rt.enrt_rt_id
7433 ,p_rt_strt_dt => l_rt_strt_dt
7434 ,p_object_version_number => l_enrt_rt.object_version_number
7435 ,p_effective_date => p_effective_date
7436 );
7437 end if;
7438 else
7439 close c_enrt_rt; -- 16068560
7440 end if;
7441 --
7442 -- end 12583091
7443 --
7444 ben_prtt_rt_val_api.update_prtt_rt_val
7445 (P_VALIDATE => FALSE
7446 ,P_PRTT_RT_VAL_ID => l_prv.prtt_rt_val_id
7447 ,P_RT_END_DT => (l_prv.rt_strt_dt - 1)
7448 ,p_person_id => p_person_id
7449 ,p_input_value_id => l_prv.input_value_id
7450 ,p_element_type_id => l_prv.element_type_id
7451 ,p_ended_per_in_ler_id => p_per_in_ler_id
7452 ,p_prtt_rt_val_stat_cd => 'VOIDD'
7453 ,p_business_group_id => p_business_group_id
7454 ,P_OBJECT_VERSION_NUMBER => l_prv.object_version_number
7455 ,P_EFFECTIVE_DATE => p_effective_date
7456 );
7457 end loop;
7458 --
7459 end;
7460
7461
7462 --
7463 begin
7464 g_debug := hr_utility.debug_enabled;
7465
7466 if g_debug then
7467 l_proc := g_package||'delete_enrollment';
7468 hr_utility.set_location('Entering:'|| l_proc, 10);
7469 hr_utility.set_location('p_prtt_enrt_rslt_id'||
7470 to_char(p_prtt_enrt_rslt_id),10);
7471 end if;
7472
7473 /* Added for Bug 7561395*/
7474 open c_grt_new_ovn;
7475 fetch c_grt_new_ovn into l_rslt_object_version_number;
7476 close c_grt_new_ovn;
7477 /* Ended for Bug 7561395*/
7478
7479 --
7480 -- Issue a savepoint if operating in validation only mode
7481 --
7482 if p_source is null or
7483 p_source <> 'delete_enrollment' then
7484 --
7485 -- Do not issue the savepoint if this procedure called itself.
7486 --
7487 savepoint delete_enrollment;
7488 --
7489 end if;
7490 --
7491 -- Work out if we are being called from a concurrent program
7492 -- otherwise we need to initialize the environment
7493 --
7494 ben_env_object.get(p_rec => l_env_rec);
7495 if fnd_global.conc_request_id in (0,-1) then
7496 --bug#3568529
7497 -- ben_env_object.get(p_rec => l_env_rec);
7498 if l_env_rec.benefit_action_id is null then
7499 --
7500 hr_utility.set_location('Intialise env object',11);
7501 ben_env_object.init(p_business_group_id => p_business_group_id,
7502 p_effective_date => p_effective_date,
7503 p_thread_id => 1,
7504 p_chunk_size => 1,
7505 p_threads => 1,
7506 p_max_errors => 1,
7507 p_benefit_action_id => null);
7508 end if;
7509 --
7510 else
7511 -- to check whether it is called in benmngle selection mode
7512 ben_env_object.get(p_rec => l_env_rec);
7513 --
7514 -- If enrollment api's are called from concurrent manager for
7515 -- conversion or ivr kind of interfaces, call raises error.
7516 --
7517 if l_env_rec.benefit_action_id is not null then
7518
7519 benutils.get_batch_parameters(p_benefit_action_id => l_env_rec.benefit_action_id
7520 ,p_rec => l_benmngle_parm_rec);
7521 end if;
7522 --
7523 end if;
7524 --
7525 --bug#3714789 - the effective date is manipulated in beninelg and in selection
7526 --mode the lf evt ocrd dt is null- the actual effective date of the process is
7527 --used for coverage end date determination mode
7528 if p_per_in_ler_id is null and l_benmngle_parm_rec.process_date is not null then
7529 --
7530 l_process_date := l_benmngle_parm_rec.process_date;
7531 --
7532 else
7533 --
7534 l_process_date := p_effective_date;
7535 --
7536 end if;
7537 --
7538 l_step := 10;
7539 --
7540 open c_pen;
7541 fetch c_pen into l_pen;
7542 if c_pen%notfound then
7543 close c_pen;
7544 rpt_error(p_proc => l_proc, p_step => l_step);
7545 fnd_message.set_name('BEN','BEN_91711_ENRT_RSLT_NOT_FND');
7546 fnd_message.set_token('ID', to_char(p_prtt_enrt_rslt_id));
7547 fnd_message.set_token('PROC',l_proc);
7548 fnd_message.set_token('PERSON_ID', null);
7549 fnd_message.set_token('LER_ID', null);
7550 fnd_message.set_token('EFFECTIVE_DATE',to_char(p_effective_date));
7551 -- fnd_message.raise_error;
7552 raise l_fnd_message_exception;
7553
7554 end if;
7555 close c_pen;
7556 --
7557
7558 --Bug 2739965 we need this for unrestricted also.
7559 --
7560 open c_ler ;
7561 fetch c_ler into l_ler_typ_cd ;
7562 close c_ler ;
7563
7564 ---Bug 7458990
7565 /* open c_crntly_enrd_flag(l_pen.elig_per_elctbl_chc_id);
7566 fetch c_crntly_enrd_flag into l_crntly_enrd_flag,l_ler_type_cd;
7567 close c_crntly_enrd_flag;
7568
7569 --Bug#5018328
7570 if l_crntly_enrd_flag = 'Y' and l_ler_type_cd <> 'SCHEDDU' then
7571 fnd_message.set_name('BEN','BEN_91902_ENRT_NOT_ALWD_DELETE');
7572 fnd_message.set_token('PLANNAMEANDOPTIONNAME',l_pen.pl_name || ' '||l_pen.opt_name );
7573 fnd_message.set_token('EARLIESTDEENROLLMENTDATE',fnd_date.date_to_chardate(l_pen.erlst_deenrt_dt,calendar_aware=>2));
7574 -- fnd_message.raise_error;
7575 raise l_fnd_message_exception;
7576 end if;
7577
7578 open c_crntly_enrd_flag_unres(l_pen.elig_per_elctbl_chc_id);
7579 fetch c_crntly_enrd_flag_unres into l_typ_cd;
7580 close c_crntly_enrd_flag_unres;
7581
7582 if l_typ_cd='SCHEDDU' then
7583 fnd_message.set_name('BEN','BEN_91902_ENRT_NOT_ALWD_DELETE');
7584 fnd_message.set_token('PLANNAMEANDOPTIONNAME',l_pen.pl_name || ' '||l_pen.opt_name );
7585 fnd_message.set_token('EARLIESTDEENROLLMENTDATE',fnd_date.date_to_chardate(l_pen.erlst_deenrt_dt));
7586 -- fnd_message.raise_error;
7587 raise l_fnd_message_exception;
7588 end if; */
7589 ---Bug 7458990
7590
7591
7592 --Bug#5018328
7593 -----bug :1527086
7594 -- calcaulte the coverage end date to check the ERLST_DEENRT_DT
7595 -- this part is moved from updation part
7596
7597 -- If Electable choice ID is not passed, then per_in_ler, and either
7598 -- Enrt_perd_id or Lee_rsn_id need to be passed.
7599 --
7600 l_step := 14;
7601 If ( nvl(l_pen.per_in_ler_id, -1) <> nvl(p_per_in_ler_id,-1) ) then
7602 l_elig_per_elctbl_chc_id := NULL;
7603 Else
7604 --
7605 --Bug 5567840 added check for imputed income plan
7606 if l_pen.auto_enrt_flag = 'Y' and l_pen.elctbl_flag = 'N' and l_pen.imptd_incm_calc_cd is null then
7607 --
7608 fnd_message.set_name('BEN','BEN_94596_DEENROL_NOT_ALL');
7609 fnd_message.set_token('PLANNAME', l_pen.pl_name);
7610 -- fnd_message.raise_error;
7611 raise l_fnd_message_exception;
7612
7613 --
7614 end if;
7615 --
7616 l_elig_per_elctbl_chc_id := l_pen.elig_per_elctbl_chc_id;
7617 End if;
7618 l_pen.per_in_ler_id := p_per_in_ler_id;
7619 --
7620 ben_global_enrt.get_pil
7621 (p_per_in_ler_id => p_per_in_ler_id
7622 ,p_global_pil_rec => l_global_pil_rec);
7623
7624 -- bug 4616225 : cache built on date,de-enrollment date of a plan,may not have
7625 -- correct comp objects built.So,life event occured date to be considered first .
7626 -- And so both get_pl_dets,get_oipl_dets calls are moved down and are called after
7627 -- ben_global_enrt.get_pil call.
7628 ben_cobj_cache.get_pl_dets
7629 (p_business_group_id => p_business_group_id
7630 ,p_effective_date => nvl(l_global_pil_rec.lf_evt_ocrd_dt,p_effective_date)
7631 ,p_pl_id => l_pen.pl_id
7632 ,p_inst_row => l_pl_rec);
7633
7634 if l_pen.oipl_id is not null then
7635 ben_cobj_cache.get_oipl_dets
7636 (p_business_group_id => p_business_group_id
7637 ,p_effective_date => nvl(l_global_pil_rec.lf_evt_ocrd_dt,p_effective_date) --
7638 ,p_oipl_id => l_pen.oipl_id
7639 ,p_inst_row => l_oipl_rec);
7640 end if;
7641 -- end bug 4616225
7642 if l_global_pil_rec.person_id is not null then
7643 l_pen.person_id := l_global_pil_rec.person_id;
7644 l_pen.ler_id := l_global_pil_rec.ler_id;
7645 end if;
7646 -- 2386000 Find lee_rsn_id at popl level
7647 if l_elig_per_elctbl_chc_id is null then
7648 if l_pen.elig_per_elctbl_chc_id is not null then
7649 open c_pel(l_pen.elig_per_elctbl_chc_id);
7650 fetch c_pel into l_enrt_perd_id,l_lee_rsn_id ;
7651 close c_pel ;
7652 end if;
7653 -- If not found find at plan level
7654 if l_lee_rsn_id is null then
7655 open c_lee_rsn_for_plan(l_pen.ler_id, l_pen.pl_id,p_effective_date );
7656 fetch c_lee_rsn_for_plan into l_lee_rsn_id ;
7657 close c_lee_rsn_for_plan ;
7658 end if ;
7659 --
7660 if l_lee_rsn_id is null and l_pen.pgm_id is not null then
7661 open c_lee_rsn_for_program(l_pen.ler_id, l_pen.pgm_id,p_effective_date);
7662 fetch c_lee_rsn_for_program into l_lee_rsn_id ;
7663 close c_lee_rsn_for_program ;
7664 end if;
7665 end if ;
7666 -- Locate end date and rate codes and rules for participant.
7667 l_step := 30;
7668 /* Bug 2386000
7669 l_elig_per_elctbl_chc_id is passed as null we need to pass these ids to
7670 rate_and_coverage_dates procedure.
7671 p_pl_id;
7672 p_pgm_id;
7673 p_enrt_perd_id;
7674 p_lee_rsn_id;
7675 p_oipl_id;
7676 p_per_in_ler_id;
7677 p_person_id;
7678 */
7679 --- Determine FONM for delete enrollment
7680 if nvl( ben_manage_life_events.fonm,'N') = 'Y' then
7681
7682 if l_pen.fonm_cvg_strt_dt is not null then
7683 if l_pen.fonm_cvg_strt_dt <> ben_manage_life_events.g_fonm_cvg_strt_dt then
7684 ben_manage_life_events.g_fonm_cvg_strt_dt := l_pen.fonm_cvg_strt_dt ;
7685 end if ;
7686
7687 else
7688 -- set theflag and date to null
7689 ben_manage_life_events.fonm := 'N';
7690 ben_manage_life_events.g_fonm_cvg_strt_dt := null;
7691 ben_manage_life_events.g_fonm_rt_strt_dt := null;
7692
7693 end if ;
7694 else
7695 if l_pen.fonm_cvg_strt_dt is not null then
7696 ben_manage_life_events.fonm := 'Y';
7697 ben_manage_life_events.g_fonm_cvg_strt_dt := l_pen.fonm_cvg_strt_dt ;
7698 else
7699 ben_manage_life_events.fonm := 'N';
7700 ben_manage_life_events.g_fonm_cvg_strt_dt := null;
7701 ben_manage_life_events.g_fonm_rt_strt_dt := null;
7702 end if ;
7703 end if ;
7704 hr_utility.set_location (' FONM ' || ben_manage_life_events.fonm , 99 ) ;
7705 hr_utility.set_location (' FONM CVG ' || ben_manage_life_events.g_fonm_cvg_strt_dt , 99 ) ;
7706 -- eof FONM
7707
7708 ben_determine_date.rate_and_coverage_dates
7709 (p_which_dates_cd => 'C'
7710 ,p_date_mandatory_flag => 'N'
7711 ,p_compute_dates_flag => 'N'
7712 ,p_elig_per_elctbl_chc_id => l_elig_per_elctbl_chc_id
7713 ,p_business_group_id => l_pen.business_group_id
7714 ,P_PER_IN_LER_ID => l_pen.per_in_ler_id
7715 ,P_PERSON_ID => l_pen.person_id
7716 ,P_PGM_ID => l_pen.pgm_id
7717 ,P_PL_ID => l_pen.pl_id
7718 ,P_OIPL_ID => l_pen.oipl_id
7719 ,P_LEE_RSN_ID => nvl(p_lee_rsn_id,l_lee_rsn_id) -- 2386000
7720 ,P_ENRT_PERD_ID => nvl(p_enrt_perd_id,l_enrt_perd_id) -- 2386000
7721 ,p_enrt_cvg_strt_dt => l_enrt_cvg_strt_dt
7722 ,p_enrt_cvg_strt_dt_cd => l_enrt_cvg_strt_dt_cd
7723 ,p_enrt_cvg_strt_dt_rl => l_enrt_cvg_strt_dt_rl
7724 ,p_rt_strt_dt => l_rt_strt_dt
7725 ,p_rt_strt_dt_cd => l_rt_strt_dt_cd
7726 ,p_rt_strt_dt_rl => l_rt_strt_dt_rl
7727 ,p_enrt_cvg_end_dt => l_enrt_cvg_end_dt
7728 ,p_enrt_cvg_end_dt_cd => l_enrt_cvg_end_dt_cd
7729 ,p_enrt_cvg_end_dt_rl => l_enrt_cvg_end_dt_rl
7730 ,p_rt_end_dt => l_rt_end_dt
7731 ,p_rt_end_dt_cd => l_rt_end_dt_cd
7732 ,p_rt_end_dt_rl => l_rt_end_dt_rl
7733 ,p_effective_date => nvl(l_global_pil_rec.lf_evt_ocrd_dt,l_process_date) --p_effective_date
7734 );
7735 --
7736 l_cvg_end_dt_cd := l_enrt_cvg_end_dt_cd;
7737 --
7738 -- If called in the special mode which allows the cvg_thru_dt to be entered,
7739 -- the cvg_thru_dt_cd should be 'ENTRBL'. If it is not,no processing required.
7740 --
7741 if p_mode = 'CVG_END_DATE_ENTERABLE' and
7742 nvl(l_enrt_cvg_end_dt_cd, 'XXX') <> 'ENTRBL' then
7743 return;
7744 end if;
7745
7746 --
7747 ben_determine_date.rate_and_coverage_dates
7748 (p_elig_per_elctbl_chc_id => l_elig_per_elctbl_chc_id
7749 ,p_business_group_id => l_pen.business_group_id
7750 ,P_PER_IN_LER_ID => l_pen.per_in_ler_id
7751 ,P_PERSON_ID => l_pen.person_id
7752 ,P_PGM_ID => l_pen.pgm_id
7753 ,P_PL_ID => l_pen.pl_id
7754 ,P_OIPL_ID => l_pen.oipl_id
7755 ,P_LEE_RSN_ID => nvl(p_lee_rsn_id,l_lee_rsn_id)
7756 ,P_ENRT_PERD_ID => nvl(p_enrt_perd_id,l_enrt_perd_id)
7757 ,p_enrt_cvg_strt_dt => l_enrt_cvg_strt_dt
7758 ,p_enrt_cvg_strt_dt_cd => l_enrt_cvg_strt_dt_cd
7759 ,p_enrt_cvg_strt_dt_rl => l_enrt_cvg_strt_dt_rl
7760 ,p_rt_strt_dt => l_rt_strt_dt
7761 ,p_rt_strt_dt_cd => l_rt_strt_dt_cd
7762 ,p_rt_strt_dt_rl => l_rt_strt_dt_rl
7763 ,p_enrt_cvg_end_dt => l_enrt_cvg_end_dt
7764 ,p_enrt_cvg_end_dt_cd => l_enrt_cvg_end_dt_cd
7765 ,p_enrt_cvg_end_dt_rl => l_enrt_cvg_end_dt_rl
7766 ,p_rt_end_dt => l_rt_end_dt
7767 ,p_rt_end_dt_cd => l_rt_end_dt_cd
7768 ,p_rt_end_dt_rl => l_rt_end_dt_rl
7769 ,p_effective_date => nvl(l_global_pil_rec.lf_evt_ocrd_dt,l_process_date) --p_effective_date
7770 ,p_end_date => p_enrt_cvg_thru_dt
7771 );
7772 --
7773 ----Bug 6925893
7774 if (substr(nvl(l_rt_end_dt_cd, 'X'), 1, 1) = 'W' or
7775 substr(nvl(l_rt_end_dt_cd, 'X'), 1, 2) = 'LW' or ------Bug 7209243
7776 l_rt_end_dt_cd in ('LDPPOEFD','LDPPFEFD','LODBEWM','ODBEWM')) ------Bug 7209243
7777 and l_ler_typ_cd not in ('IREC','GSP','COMP','ABS','SCHEDDU') then
7778 --determine new rt start date
7779 ben_determine_date.rate_and_coverage_dates
7780 (p_elig_per_elctbl_chc_id => l_elig_per_elctbl_chc_id
7781 ,p_business_group_id => l_pen.business_group_id
7782 ,P_PER_IN_LER_ID => l_pen.per_in_ler_id
7783 ,P_PERSON_ID => l_pen.person_id
7784 ,P_PGM_ID => l_pen.pgm_id
7785 ,P_PL_ID => l_pen.pl_id
7786 ,P_OIPL_ID => l_pen.oipl_id
7787 ,P_LEE_RSN_ID => nvl(p_lee_rsn_id,l_lee_rsn_id)
7788 ,P_ENRT_PERD_ID => nvl(p_enrt_perd_id,l_enrt_perd_id)
7789 ,p_enrt_cvg_strt_dt => l_enrt_cvg_strt_dt
7790 ,p_enrt_cvg_strt_dt_cd => l_enrt_cvg_strt_dt_cd
7791 ,p_enrt_cvg_strt_dt_rl => l_enrt_cvg_strt_dt_rl
7792 ,p_rt_strt_dt => l_rt_strt_dt
7793 ,p_rt_strt_dt_cd => l_rt_strt_dt_cd
7794 ,p_rt_strt_dt_rl => l_rt_strt_dt_rl
7795 ,p_enrt_cvg_end_dt => l_enrt_cvg_end_dt
7796 ,p_enrt_cvg_end_dt_cd => l_enrt_cvg_end_dt_cd
7797 ,p_enrt_cvg_end_dt_rl => l_enrt_cvg_end_dt_rl
7798 ,p_rt_end_dt => l_rt_end_dt
7799 ,p_rt_end_dt_cd => l_rt_end_dt_cd
7800 ,p_rt_end_dt_rl => l_rt_end_dt_rl
7801 ,p_effective_date => p_effective_date
7802 ,p_end_date => p_enrt_cvg_thru_dt
7803 );
7804 end if;
7805 -----Bug 6925893
7806 if l_cvg_end_dt_cd = 'ENTRBL' and
7807 p_enrt_cvg_thru_dt is not null then
7808 l_enrt_cvg_end_dt := p_enrt_cvg_thru_dt;
7809 end if;
7810
7811 -----bug :1527086
7812
7813
7814 -- Check ERLST_DEENRT_DT
7815 --
7816 l_step := 15;
7817
7818 if p_source = 'beninelg' then
7819 --
7820 -- If called from newly ineligible package (beninelg), the comp-obejct
7821 -- need to de-enrolled even if there is a locking period.
7822 -- **** By-pass the check.
7823 --
7824 null;
7825 --
7826 --elsif (p_effective_date < nvl(l_pen.erlst_deenrt_dt,hr_api.g_sot) and
7827 -- on the erlst_deenrt_dt then deenrt is allowd so -1 is compared
7828 if g_debug then
7829 hr_utility.set_location('cvg end dt ' || l_enrt_cvg_end_dt , 7086);
7830 hr_utility.set_location('denrt ' || l_pen.erlst_deenrt_dt , 7086);
7831 end if;
7832 elsif (l_enrt_cvg_end_dt < nvl(l_pen.erlst_deenrt_dt,hr_api.g_sot)-1 and
7833 l_pen.sspndd_flag = 'N' /*and p_effective_date > l_pen.enrt_cvg_strt_dt */) then
7834 --
7835 -- Must now check if can deenroll legally. If an enrollment is
7836 -- found for the level at which the the required period of enrollment
7837 -- was defined where the per_in_ler is different, then delete is OK
7838 --
7839 -- Find the required period of enrollment code/rule/uom/level defined at
7840
7841 --Removed because the below condition is satisfied always.Bug : 6683229
7842
7843 /* if l_other_pen_rec.prtt_enrt_rslt_id is null then
7844 fnd_message.set_name('BEN','BEN_91902_ENRT_NOT_ALWD_DELETE');
7845 fnd_message.set_token('PLANNAMEANDOPTIONNAME',l_pen.pl_name || ' '||l_pen.opt_name );
7846 fnd_message.set_token('EARLIESTDEENROLLMENTDATE',fnd_date.date_to_chardate(l_pen.erlst_deenrt_dt));
7847 -- fnd_message.raise_error;
7848 raise l_fnd_message_exception;
7849 End if;
7850 */
7851 --- Bug : 6683229
7852
7853 ben_enrolment_requirements.find_rqd_perd_enrt(
7854 p_oipl_id =>l_pen.oipl_id
7855 ,p_opt_id =>l_pen.opt_id
7856 ,p_pl_id =>l_pen.pl_id
7857 ,p_ptip_id =>l_pen.ptip_id
7858 ,p_effective_date =>p_effective_date
7859 ,p_business_group_id =>p_business_group_id
7860 ,p_rqd_perd_enrt_nenrt_uom =>l_rqd_perd_enrt_nenrt_uom
7861 ,p_rqd_perd_enrt_nenrt_val =>l_rqd_perd_enrt_nenrt_val
7862 ,p_rqd_perd_enrt_nenrt_rl =>l_rqd_perd_enrt_nenrt_rl
7863 ,p_level =>l_level
7864 );
7865
7866 ---after getting the level chek enrollemnt is not new one or
7867 --- processed (for over riding) then then chek any other election before error
7868
7869 l_new_enrollment := 'N' ;
7870 if l_level = 'PTIP' then
7871 open c_rslt_ptip( l_pen.person_id ,
7872 l_pen.pgm_id ,
7873 l_pen.ptip_id ,
7874 l_pen.per_in_ler_id ,
7875 p_effective_date
7876 );
7877
7878 fetch c_rslt_ptip into l_dummy ;
7879 if c_rslt_ptip%notfound then
7880 l_new_enrollment := 'Y' ;
7881 end if ;
7882 close c_rslt_ptip ;
7883 elsif l_level = 'PL' then
7884 if g_debug then
7885 hr_utility.set_location('in pl level' , 161);
7886 end if;
7887 open c_rslt_pl(l_pen.person_id ,
7888 l_pen.pgm_id ,
7889 l_pen.pl_id ,
7890 l_pen.per_in_ler_id ,
7891 p_effective_date
7892 ) ;
7893
7894 fetch c_rslt_pl into l_dummy ;
7895 if c_rslt_pl%notfound then
7896 l_new_enrollment := 'Y' ;
7897 end if ;
7898 close c_rslt_pl ;
7899 else -- OPT,OIPL
7900 if g_debug then
7901 hr_utility.set_location('per in ler ' || l_pen.per_in_ler_id,161);
7902 hr_utility.set_location('start date ' || l_pen.effective_start_date,161);
7903 hr_utility.set_location('in opt level' , 161);
7904 end if;
7905 open c_rslt_opt ( l_pen.person_id ,
7906 l_pen.pgm_id ,
7907 l_pen.pl_id ,
7908 l_pen.oipl_id ,
7909 l_pen.per_in_ler_id,
7910 p_effective_date
7911 ) ;
7912
7913 fetch c_rslt_opt into l_dummy ;
7914 if c_rslt_opt%notfound then
7915 l_new_enrollment := 'Y' ;
7916 end if ;
7917 close c_rslt_opt ;
7918 end if;
7919 if g_debug then
7920 hr_utility.set_location(' l_new_enrollment ' || l_new_enrollment , 161 );
7921 end if;
7922 if (l_new_enrollment <> 'Y' or l_pen.per_in_ler_stat_cd = 'PROCD') then
7923 --
7924 -- Got level now see if other enrt in level exists
7925 --
7926 ben_enrolment_requirements.find_enrt_at_same_level(
7927 p_person_id =>l_pen.person_id
7928 ,p_opt_id =>l_pen.opt_id
7929 ,p_oipl_id =>l_pen.oipl_id
7930 ,p_pl_id =>l_pen.pl_id
7931 ,p_ptip_id =>l_pen.ptip_id
7932 ,p_pl_typ_id =>l_pen.pl_typ_id
7933 ,p_pgm_id =>l_pen.pgm_id
7934 ,p_effective_date =>p_effective_date
7935 ,p_business_group_id =>p_business_group_id
7936 ,p_prtt_enrt_rslt_id =>p_prtt_enrt_rslt_id
7937 ,p_level =>l_level
7938 ,p_pen_rec =>l_other_pen_rec
7939 );
7940 if g_debug then
7941 hr_utility.set_location('result ' || l_other_pen_rec.prtt_enrt_rslt_id ,161);
7942 end if;
7943 if l_other_pen_rec.prtt_enrt_rslt_id is null/* or l_crntly_enrd_flag='Y'*/ then -------7458990
7944 hr_utility.set_location('entering',9999);
7945 fnd_message.set_name('BEN','BEN_91902_ENRT_NOT_ALWD_DELETE');
7946 fnd_message.set_token('PLANNAMEANDOPTIONNAME',l_pen.pl_name || ' '||l_pen.opt_name );
7947 fnd_message.set_token('EARLIESTDEENROLLMENTDATE',fnd_date.date_to_chardate(l_pen.erlst_deenrt_dt));
7948 -- fnd_message.raise_error;
7949 raise l_fnd_message_exception;
7950
7951 End if;
7952 end if ;
7953 --
7954 end if;
7955 --
7956 -- Check if coverage has started. If coverage has started, then
7957 -- the coverage end date is updated and the enrollment result is
7958 -- updated with the coverage end date.
7959 --
7960 -- There are 4 cases:
7961 -- Case 1: Coverage started, Coverage Elected and delete in same day.
7962 -- * void result and its rates.
7963 -- Case 2: Coverage Started, Coverage Elected and delete but not in same
7964 -- day. (Elected earlier before Today)
7965 -- * Calculate its coverage end date.
7966 -- Case 3: Coverage not started yet. Elected and deleted in same day.
7967 -- * Date-track end dated.
7968 -- Case 4: Coverage not started yet. Elected and deleted not in same day.
7969 -- * Date-track end dated.
7970 --
7971 -- There is one more case - Bug#5123
7972 -- Coverage started, Coverage Ended and no election is possible
7973 -- Coverage Ended on account of newly Ineligible - This procedure
7974 -- called for imputed income plan when election is made and the
7975 -- row need not be Date-tracked
7976 --
7977 -- (maagrawa Jan 05,2001).
7978 -- One special modification is made here.
7979 -- When the coverage through date is allowed to be entered, then we need to
7980 -- always update the result by updating it with that date irrespective
7981 -- of when the coverage starts and when the elections are made.
7982 --
7983
7984 hr_utility.set_location('p_effective_date '|| to_char(p_effective_date) , 100);
7985 hr_utility.set_location('l_pen.ENRT_CVG_STRT_DT '|| to_char(l_pen.ENRT_CVG_STRT_DT) , 100);
7986 hr_utility.set_location('l_pen.enrt_cvg_thru_dt '|| to_char(l_pen.enrt_cvg_thru_dt) , 100);
7987 hr_utility.set_location('enrt_cvg_start_dt tilak '|| l_enrt_cvg_strt_dt , 100);
7988 hr_utility.set_location('enrt_cvg_start_dt tilak '|| l_enrt_cvg_strt_dt , 100);
7989 hr_utility.set_location('prtt_id tilak '|| p_prtt_enrt_rslt_id , 100);
7990 hr_utility.set_location('PLIPID tilak '|| l_pen.per_in_ler_id , 100);
7991 hr_utility.set_location('PLIPID tilak '|| l_pen.pen_per_in_ler_id , 100);
7992 hr_utility.set_location('p_mode '|| p_mode , 100);
7993
7994 -- future enrollment is deleted
7995 -- copy the data into backup table
7996
7997 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
7998 and l_pen.pen_per_in_ler_id <> l_pen.per_in_ler_id then
7999 ben_back_out_life_event.back_out_life_events
8000 (p_per_in_ler_id => l_pen.pen_per_in_ler_id ,
8001 p_bckt_per_in_ler_id => l_pen.per_in_ler_id , --Bug 5859714
8002 p_bckt_stat_cd => null ,
8003 p_business_group_id => p_business_group_id,
8004 p_bckdt_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id,
8005 p_copy_only => 'Y' ,
8006 p_effective_date => p_effective_date) ;
8007 end if ;
8008 l_step := 20;
8009 --
8010 -- Bug No 5637595 Moved the get_election date before if check as
8011 -- p_pil_id is required in if condition. Also added more checks to
8012 -- to see that for future dates coverages, if change of enrollment is done
8013 -- then previous end-dated coverage pen record should not be backout out.
8014 -- i.e. for this case code should go in Case 1 or Case 2 and not later ones.
8015 --
8016 Get_election_date(p_effective_date => p_effective_date
8017 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8018 ,p_business_group_id => p_business_group_id
8019 ,p_date => l_date
8020 ,p_pil_id => l_pil_id
8021 );
8022 --
8023 open get_lf_evt_dt;
8024 fetch get_lf_evt_dt into l_lf_evt_ocrd_dt;
8025 if get_lf_evt_dt%NOTFOUND then
8026 l_lf_evt_ocrd_dt := p_effective_date;
8027 end if;
8028 close get_lf_evt_dt;
8029 --
8030 If ((p_effective_date between
8031 l_pen.ENRT_CVG_STRT_DT and nvl(l_pen.enrt_cvg_thru_dt, hr_api.g_eot))
8032 and ( (l_pen.SSPNDD_FLAG = 'N') or
8033 ( nvl(p_source,'x') <> 'benuneai' and l_pen.SSPNDD_FLAG = 'Y') --CFW
8034 )) or
8035 ((l_lf_evt_ocrd_dt between
8036 l_pen.ENRT_CVG_STRT_DT and nvl(l_pen.enrt_cvg_thru_dt, hr_api.g_eot))
8037 and l_pil_id <> p_per_in_ler_id
8038 and ( (l_pen.SSPNDD_FLAG = 'N') or
8039 ( nvl(p_source,'x') <> 'benuneai' and l_pen.SSPNDD_FLAG = 'Y') --CFW
8040 )) or
8041 p_mode = 'CVG_END_DATE_ENTERABLE' then
8042 --
8043 open c_old_corr_pen (p_per_in_ler_id
8044 , p_prtt_enrt_rslt_id
8045 , l_pen.effective_start_date) ; -- 7197868
8046 fetch c_old_corr_pen into l_corr_pil_id ;
8047 if c_old_corr_pen%found then
8048 l_pil_id := l_corr_pil_id ;
8049 hr_utility.set_location('not found corrected '|| l_proc , 99 ) ;
8050 end if ;
8051 close c_old_corr_pen ;
8052 hr_utility.set_location('p_per_in_ler_id '|| p_per_in_ler_id , 100);
8053 hr_utility.set_location('l_date '|| to_char(l_date) , 100);
8054 hr_utility.set_location('l_pil_id '|| l_pil_id , 100);
8055 hr_utility.set_location('p_mode '|| p_mode , 100);
8056 -- Case 1: Coverage started, Coverage Elected and delete in same day.
8057 -- * void result and its rates.
8058 if (l_date = p_effective_date) and
8059 ((p_per_in_ler_id is not null and p_per_in_ler_id = l_pil_id) or
8060 p_per_in_ler_id is null) and
8061 (p_mode is null or p_mode <> 'CVG_END_DATE_ENTERABLE')then
8062 if g_debug then
8063 hr_utility.set_location('p_effective_date='||p_effective_date,19);
8064 end if;
8065 hr_utility.set_location(' p_date '|| p_effective_date || '--'||l_pen.effective_start_date , 99 ) ;
8066 hr_utility.set_location(' p_datetrack_mode '|| p_datetrack_mode , 99 ) ;
8067 hr_utility.set_location(' p_source '|| p_source , 99 ) ;
8068 hr_utility.set_location(' result ' || p_prtt_enrt_rslt_id , 99 ) ;
8069 hr_utility.set_location(' thru date ' || p_enrt_cvg_thru_dt , 99 ) ;
8070 l_step := 21;
8071 void_enrollment
8072 (p_validate => p_validate
8073 ,p_per_in_ler_id => p_per_in_ler_id
8074 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8075 ,p_business_group_id => p_business_group_id
8076 ,p_enrt_cvg_strt_dt => l_pen.enrt_cvg_strt_dt
8077 ,p_person_id => l_pen.person_id
8078 ,p_elig_per_elctbl_chc_id => l_pen.elig_per_elctbl_chc_id
8079 ,p_epe_ovn => l_pen.epe_ovn
8080 ,p_object_version_number => l_pen.pen_ovn
8081 ,p_effective_date => p_effective_date
8082 ,p_datetrack_mode => p_datetrack_mode
8083 ,p_multi_row_validate => p_multi_row_validate
8084 ,p_source => p_source
8085 ,p_enrt_bnft_id => l_pen.enrt_bnft_id);
8086 --
8087 if l_pen.pgm_id is not null then
8088 ben_provider_pools.remove_bnft_prvdd_ldgr
8089 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8090 ,p_effective_date => p_effective_date
8091 ,p_business_group_id => p_business_group_id
8092 ,p_validate => FALSE
8093 ,p_datetrack_mode => hr_api.g_delete
8094 );
8095 end if;
8096 hr_utility.set_location('l_benmngle_parm_rec.mode_cd '|| l_benmngle_parm_rec.mode_cd , 100);
8097 hr_utility.set_location('l_env_rec.mode_cd '|| l_env_rec.mode_cd , 100);
8098 hr_utility.set_location('p_source '|| p_source , 100);
8099 -- 3398353
8100 /* In case of Unrestricted Enrollment running on the same-day,
8101 the dependent designation records (ben_elig_cvrd_dpnt_f) also
8102 needs to be end-dated / voided, when the enrollment is voided.
8103 */
8104 -- Also call the below code for 3797391 when source is benelinf
8105 --
8106 -- IF-UNRESTRICTED-OR-SCHEDULED
8107 -- Bug 4662362 : Removing the following IF condition since dependents / beneficiaries
8108 -- should be UNHOOKED for all cases
8109 --
8110 -- if (l_benmngle_parm_rec.mode_cd = 'S' or l_ler_typ_cd = 'SCHEDDU' ) or ( p_source = 'benelinf' ) then
8111 --
8112 if g_debug then
8113 hr_utility.set_location('Updating Dependent Records. l_enrt_cvg_end_dt: '||l_enrt_cvg_end_dt, 100);
8114 end if;
8115 --
8116 l_step := 30;
8117 --
8118 if g_debug then
8119 hr_utility.set_location('calc_dpnt_cvg_dt ', 100);
8120 end if;
8121 --
8122 calc_dpnt_cvg_dt
8123 (p_calc_end_dt => TRUE
8124 ,P_calc_strt_dt => FALSE
8125 ,p_per_in_ler_id => l_pen.per_in_ler_id
8126 ,P_person_id => l_pen.person_id
8127 ,p_pgm_id => l_pen.pgm_id
8128 ,p_pl_id => l_pen.pl_id
8129 ,p_oipl_id => l_pen.oipl_id
8130 ,p_ptip_id => l_pen.ptip_id
8131 ,p_ler_id => l_pen.ler_id
8132 ,P_BUSINESS_GROUP_ID => p_business_group_id
8133 ,P_EFFECTIVE_DATE => p_effective_date
8134 ,P_RETURNED_END_DT => l_dpnt_cvg_end_dt
8135 ,P_RETURNED_STRT_DT => l_dump_date
8136 ,p_enrt_cvg_end_dt => l_enrt_cvg_end_dt
8137 );
8138 --
8139 l_step := 40;
8140 --
8141 l_dpnt_cvg_thru_dt := l_dpnt_cvg_end_dt;
8142 --
8143 -- In this case we are voiding the enrollment. so, the dependent coverage should
8144 -- end the same day as the participants.
8145 --
8146 if l_dpnt_cvg_end_dt is not NULL then
8147 l_dpnt_cvg_thru_dt := least(l_enrt_cvg_end_dt, l_dpnt_cvg_end_dt);
8148 End if;
8149 --
8150 -- Unhook dependent rows
8151 --
8152 l_step := 50;
8153 --
8154 if g_debug then
8155 hr_utility.set_location('unhook_dpnt cvg-end-date: '||l_dpnt_cvg_thru_dt, 100);
8156 end if;
8157 --
8158 unhook_dpnt
8159 (p_validate => FALSE
8160 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8161 ,p_per_in_ler_id => l_pen.per_in_ler_id
8162 ,p_cvg_thru_dt => l_dpnt_cvg_thru_dt
8163 ,p_business_group_id => p_business_group_id
8164 ,p_effective_date => p_effective_date
8165 ,p_datetrack_mode => p_datetrack_mode
8166 ,p_called_from => p_source
8167 );
8168 --
8169 if g_debug then
8170 hr_utility.set_location('unhook_bnf cvg-end-date: '||l_dpnt_cvg_thru_dt, 100);
8171 end if;
8172 --
8173 unhook_bnf
8174 (p_validate => FALSE
8175 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8176 ,p_per_in_ler_id => l_pen.per_in_ler_id
8177 ,p_dsgn_thru_dt => l_enrt_cvg_end_dt
8178 ,p_business_group_id => p_business_group_id
8179 ,p_effective_date => p_effective_date
8180 ,p_datetrack_mode => p_datetrack_mode
8181 );
8182 -- end if;-- IF-UNRESTRICTED-OR-SCHEDULED
8183 ---
8184
8185 /*Ended code for Bug 7561395*/
8186 hr_utility.set_location('IF-UNRESTRICTED-OR-SCHEDULED ', 500);
8187 hr_utility.set_location('Unhook dependent rows ', 500);
8188 hr_utility.set_location('p_prtt_enrt_rslt_ids '||p_prtt_enrt_rslt_id, 502);
8189 hr_utility.set_location('l_pen.pen_per_in_ler_id '||l_pen.pen_per_in_ler_id, 502);
8190 hr_utility.set_location('p_pen_per_in_ler_id '||p_per_in_ler_id, 502);
8191 hr_utility.set_location('g_new_prtt_enrt_rslt_id '||g_new_prtt_enrt_rslt_id, 502);
8192
8193 /* Bug 8669907:
8194 if(action item exists for the pen_id ) do not create
8195 else
8196 if(Participant has selected diff comp obj) do not create
8197 else if(not enter value at enrollment) perform validations before creating action items
8198 else perform validations before creating action items
8199 Set the l_create_flag to 'Y' if action item has to be created */
8200
8201 open c_chk_act_item_exits(g_new_prtt_enrt_rslt_id);
8202 fetch c_chk_act_item_exits into l_dummy1;
8203 if(c_chk_act_item_exits%found) then
8204 hr_utility.set_location('No Create 1',500);
8205 close c_chk_act_item_exits;
8206 l_create_flag := 'N';
8207 else
8208 close c_chk_act_item_exits;
8209 open c_chk_same_comp_obj(g_new_prtt_enrt_rslt_id,p_prtt_enrt_rslt_id,p_per_in_ler_id);
8210 fetch c_chk_same_comp_obj into l_create_flag;
8211 if(c_chk_same_comp_obj%notfound) then
8212 hr_utility.set_location('No Create 2',500);
8213 close c_chk_same_comp_obj;
8214 l_create_flag := 'N';
8215 else
8216 close c_chk_same_comp_obj;
8217 open c_bnft_amt(g_new_prtt_enrt_rslt_id,p_per_in_ler_id);
8218 fetch c_bnft_amt into l_bnft ;
8219 close c_bnft_amt;
8220 if(l_bnft.entr_val_at_enrt_flag = 'N') then
8221 if(l_bnft.cvg_mlt_cd = 'FLRNG') then
8222 if(l_bnft.bnft_amt > l_bnft.mx_val) then
8223 hr_utility.set_location('FLRNG Create ',500);
8224 l_create_flag := 'Y';
8225 else
8226 hr_utility.set_location('FLRNG No Create',500);
8227 l_create_flag := 'N';
8228 end if;
8229 else
8230 hr_utility.set_location('Create 1',500);
8231 l_create_flag := 'Y';
8232 end if;
8233 else
8234 if(l_bnft.mx_wout_ctfn_val is not null and l_bnft.bnft_amt > l_bnft.mx_wout_ctfn_val ) then
8235 hr_utility.set_location('Create 2',500);
8236 l_create_flag := 'Y';
8237 elsif(l_bnft.mx_wout_ctfn_val is not null and l_bnft.bnft_amt <= l_bnft.mx_wout_ctfn_val ) then
8238 hr_utility.set_location('No Create 4',500);
8239 l_create_flag := 'N';
8240 else
8241 hr_utility.set_location('Create 3',500);
8242 l_create_flag := 'Y';
8243 end if;
8244 end if;
8245 end if;
8246 end if;
8247 hr_utility.set_location('l_create_flag '||l_create_flag,500);
8248
8249 open c_chk_same_event(g_new_prtt_enrt_rslt_id);
8250 fetch c_chk_same_event into l_nper_in_ler_id ;
8251 close c_chk_same_event;
8252 open c_chk_same_event(p_prtt_enrt_rslt_id);
8253 fetch c_chk_same_event into l_oper_in_ler_id ;
8254 close c_chk_same_event;
8255 open c_chk_act_item_exits(p_prtt_enrt_rslt_id);
8256 fetch c_chk_act_item_exits into l_dummy1;
8257 if(c_chk_act_item_exits%found) then
8258 l_act_flag := true;
8259 hr_utility.set_location('In loop2 false',500);
8260 else
8261 l_act_flag := false;
8262 hr_utility.set_location('In loop2 true',500);
8263 end if;
8264 close c_chk_act_item_exits;
8265 if(l_nper_in_ler_id = l_oper_in_ler_id and l_act_flag) then
8266
8267 open c_get_actn_items;
8268 fetch c_get_actn_items BULK COLLECT into l_act_items;
8269 hr_utility.set_location('In loop1',500);
8270 if(l_act_items.count > 0) then
8271 l_act_flag := true;
8272 hr_utility.set_location('In loop10 '||l_act_items.count,500);
8273 else
8274 l_act_flag := false;
8275 hr_utility.set_location('In loop11',500);
8276 end if;
8277 close c_get_actn_items;
8278
8279
8280 open c_get_ctfn;
8281 fetch c_get_ctfn BULK COLLECT into l_ctfn;
8282 if(l_ctfn.count > 0) then
8283 l_ctfn_flag := true;
8284 hr_utility.set_location('In loop10 '||l_ctfn.count,500);
8285 end if;
8286 close c_get_ctfn;
8287
8288 hr_utility.set_location('Remving action items',500);
8289 remove_cert_action_items
8290 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8291 ,p_effective_date => p_effective_date
8292 ,p_business_group_id => p_business_group_id
8293 ,p_validate => FALSE
8294 ,p_datetrack_mode => hr_api.g_zap
8295 ,p_source => p_source
8296 ,p_per_in_ler_id => l_pen.pen_per_in_ler_id
8297 ,p_per_in_ler_ended_id=> l_pen.per_in_ler_id
8298 );
8299
8300 if(l_act_flag and l_create_flag = 'Y' ) then
8301 hr_utility.set_location('creating action items',500);
8302 for i IN l_act_items.FIRST..l_act_items.LAST loop
8303 ben_PRTT_ENRT_ACTN_api.create_PRTT_ENRT_ACTN
8304 (p_validate => false
8305 ,p_effective_date => p_effective_date
8306 ,p_cmpltd_dt => l_act_items(i).cmpltd_dt
8307 ,p_due_dt => l_act_items(i).due_dt
8308 ,p_rqd_flag => l_act_items(i).rqd_flag
8309 ,p_prtt_enrt_rslt_id => g_new_prtt_enrt_rslt_id
8310 ,p_per_in_ler_id => p_per_in_ler_id
8311 ,p_rslt_object_version_number => l_rslt_object_version_number
8312 ,p_actn_typ_id => l_act_items(i).actn_typ_id
8313 ,p_elig_cvrd_dpnt_id => l_act_items(i).elig_cvrd_dpnt_id
8314 ,p_pl_bnf_id => l_act_items(i).pl_bnf_id
8315 ,p_business_group_id => l_act_items(i).business_group_id
8316 ,p_pea_attribute_category => l_act_items(i).pea_attribute_category
8317 ,p_pea_attribute1 => l_act_items(i).pea_attribute1
8318 ,p_pea_attribute2 => l_act_items(i).pea_attribute2
8319 ,p_pea_attribute3 => l_act_items(i).pea_attribute3
8320 ,p_pea_attribute4 => l_act_items(i).pea_attribute4
8321 ,p_pea_attribute5 => l_act_items(i).pea_attribute5
8322 ,p_pea_attribute6 => l_act_items(i).pea_attribute6
8323 ,p_pea_attribute7 => l_act_items(i).pea_attribute7
8324 ,p_pea_attribute8 => l_act_items(i).pea_attribute8
8325 ,p_pea_attribute9 => l_act_items(i).pea_attribute9
8326 ,p_pea_attribute10 => l_act_items(i).pea_attribute10
8327 ,p_pea_attribute11 => l_act_items(i).pea_attribute11
8328 ,p_pea_attribute12 => l_act_items(i).pea_attribute12
8329 ,p_pea_attribute13 => l_act_items(i).pea_attribute13
8330 ,p_pea_attribute14 => l_act_items(i).pea_attribute14
8331 ,p_pea_attribute15 => l_act_items(i).pea_attribute15
8332 ,p_pea_attribute16 => l_act_items(i).pea_attribute16
8333 ,p_pea_attribute17 => l_act_items(i).pea_attribute17
8334 ,p_pea_attribute18 => l_act_items(i).pea_attribute18
8335 ,p_pea_attribute19 => l_act_items(i).pea_attribute19
8336 ,p_pea_attribute20 => l_act_items(i).pea_attribute20
8337 ,p_pea_attribute21 => l_act_items(i).pea_attribute21
8338 ,p_pea_attribute22 => l_act_items(i).pea_attribute22
8339 ,p_pea_attribute23 => l_act_items(i).pea_attribute23
8340 ,p_pea_attribute24 => l_act_items(i).pea_attribute24
8341 ,p_pea_attribute25 => l_act_items(i).pea_attribute25
8342 ,p_pea_attribute26 => l_act_items(i).pea_attribute26
8343 ,p_pea_attribute27 => l_act_items(i).pea_attribute27
8344 ,p_pea_attribute28 => l_act_items(i).pea_attribute28
8345 ,p_pea_attribute29 => l_act_items(i).pea_attribute29
8346 ,p_pea_attribute30 => l_act_items(i).pea_attribute30
8347 ,p_object_version_number => l_actn_object_version_number
8348 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
8349 ,p_effective_start_date => l_actn_start_date
8350 ,p_effective_end_date => l_actn_end_date
8351 ,p_gnrt_cm => false -- Bug 9256641 : Do not generate communications
8352 );
8353 end loop;
8354 hr_utility.set_location('created action items',500);
8355 end if;
8356
8357 hr_utility.set_location('before creating cert',500);
8358 if(l_ctfn_flag and l_create_flag = 'Y' ) then
8359 hr_utility.set_location('creating certifications ',500);
8360 for j IN l_ctfn.FIRST..l_ctfn.LAST loop
8361 hr_utility.set_location('looping cert ',500);
8362 ben_PRTT_ENRT_CTFN_PRVDD_api.create_PRTT_ENRT_CTFN_PRVDD
8363 (p_validate => false
8364 ,p_prtt_enrt_ctfn_prvdd_id => l_prtt_enrt_ctfn_prvdd_id
8365 ,p_effective_start_date => l_ctfn_start_date
8366 ,p_effective_end_date => l_ctfn_end_date
8367 ,p_enrt_ctfn_rqd_flag => l_ctfn(j).enrt_ctfn_rqd_flag
8368 ,p_enrt_ctfn_typ_cd => l_ctfn(j).enrt_ctfn_typ_cd
8369 ,p_enrt_ctfn_recd_dt => l_ctfn(j).enrt_ctfn_recd_dt
8370 ,p_enrt_ctfn_dnd_dt => l_ctfn(j).enrt_ctfn_dnd_dt
8371 ,p_enrt_r_bnft_ctfn_cd => l_ctfn(j).enrt_r_bnft_ctfn_cd
8372 ,p_prtt_enrt_rslt_id => g_new_prtt_enrt_rslt_id
8373 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
8374 ,p_business_group_id => l_ctfn(j).business_group_id
8375 ,p_pcs_attribute_category => l_ctfn(j).pcs_attribute_category
8376 ,p_pcs_attribute1 => l_ctfn(j).pcs_attribute1
8377 ,p_pcs_attribute2 => l_ctfn(j).pcs_attribute2
8378 ,p_pcs_attribute3 => l_ctfn(j).pcs_attribute3
8379 ,p_pcs_attribute4 => l_ctfn(j).pcs_attribute4
8380 ,p_pcs_attribute5 => l_ctfn(j).pcs_attribute5
8381 ,p_pcs_attribute6 => l_ctfn(j).pcs_attribute6
8382 ,p_pcs_attribute7 => l_ctfn(j).pcs_attribute7
8383 ,p_pcs_attribute8 => l_ctfn(j).pcs_attribute8
8384 ,p_pcs_attribute9 => l_ctfn(j).pcs_attribute9
8385 ,p_pcs_attribute10 => l_ctfn(j).pcs_attribute10
8386 ,p_pcs_attribute11 => l_ctfn(j).pcs_attribute11
8387 ,p_pcs_attribute12 => l_ctfn(j).pcs_attribute12
8388 ,p_pcs_attribute13=> l_ctfn(j).pcs_attribute13
8389 ,p_pcs_attribute14 => l_ctfn(j).pcs_attribute14
8390 ,p_pcs_attribute15 => l_ctfn(j).pcs_attribute15
8391 ,p_pcs_attribute16=> l_ctfn(j).pcs_attribute16
8392 ,p_pcs_attribute17 => l_ctfn(j).pcs_attribute17
8393 ,p_pcs_attribute18 => l_ctfn(j).pcs_attribute18
8394 ,p_pcs_attribute19 => l_ctfn(j).pcs_attribute19
8395 ,p_pcs_attribute20 => l_ctfn(j).pcs_attribute20
8396 ,p_pcs_attribute21=> l_ctfn(j).pcs_attribute21
8397 ,p_pcs_attribute22 => l_ctfn(j).pcs_attribute22
8398 ,p_pcs_attribute23 => l_ctfn(j).pcs_attribute23
8399 ,p_pcs_attribute24=>l_ctfn(j).pcs_attribute24
8400 ,p_pcs_attribute25 =>l_ctfn(j).pcs_attribute25
8401 ,p_pcs_attribute26 => l_ctfn(j).pcs_attribute26
8402 ,p_pcs_attribute27 => l_ctfn(j).pcs_attribute27
8403 ,p_pcs_attribute28 => l_ctfn(j).pcs_attribute28
8404 ,p_pcs_attribute29 => l_ctfn(j).pcs_attribute29
8405 ,p_pcs_attribute30 => l_ctfn(j).pcs_attribute30
8406 ,p_object_version_number => l_ctfn_object_version_number
8407 ,p_effective_date => p_effective_date
8408 );
8409 end loop;
8410 end if;
8411 g_new_prtt_enrt_rslt_id := -1;
8412 else
8413 remove_cert_action_items
8414 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8415 ,p_effective_date => p_effective_date
8416 ,p_business_group_id => p_business_group_id
8417 ,p_validate => FALSE
8418 ,p_datetrack_mode => hr_api.g_zap
8419 ,p_source => p_source
8420 ,p_per_in_ler_id => l_pen.pen_per_in_ler_id
8421 ,p_per_in_ler_ended_id=> l_pen.per_in_ler_id
8422 );
8423 end if;
8424
8425 -- Commented for Bug 7561395
8426 /*remove_cert_action_items
8427 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8428 ,p_effective_date => p_effective_date
8429 ,p_business_group_id => p_business_group_id
8430 ,p_validate => FALSE
8431 ,p_datetrack_mode => hr_api.g_zap
8432 ,p_source => p_source
8433 ,p_per_in_ler_id => l_pen.pen_per_in_ler_id
8434 ,p_per_in_ler_ended_id=> l_pen.per_in_ler_id
8435 );*/
8436
8437 /*Ended code for Bug 7561395*/
8438
8439
8440
8441 -- 3398353
8442 -- Case 2: Coverage Started, Coverage Elected and delete but not in same
8443 -- day. (Elected earlier before Today)
8444 -- * Calculated its coverage end date.
8445 else
8446 --
8447 -- 4642299: For either Rate or Coverage Code of '1 Prior'
8448 -- Open c_new_cvg_strt_dt to determine if new coverage exists
8449 -- If so, change the Rate / Coverage end-date to 1 day prior.
8450 -- Added 'LODBEWM','ODBEWM' too for 1 Prior logic.
8451 If (substr(nvl(l_cvg_end_dt_cd, 'X'), 1, 1) = 'W' or
8452 substr(nvl(l_cvg_end_dt_cd, 'X'), 1, 2) = 'LW' or
8453 substr(nvl(l_rt_end_dt_cd, 'X'), 1, 1) = 'W' or
8454 substr(nvl(l_rt_end_dt_cd, 'X'), 1, 2) = 'LW' or
8455 l_rt_end_dt_cd in ('LDPPOEFD','LDPPFEFD','LODBEWM','ODBEWM') ) and
8456 (p_per_in_ler_id <> l_pil_id or l_ler_typ_cd = 'SCHEDDU' or
8457 (p_per_in_ler_id = l_pil_id and l_ler_typ_cd not in ('IREC','GSP','COMP','ABS'))) then
8458 -- Bug 2847110
8459 hr_utility.set_location('c_new_cvg_strt_dt,srav : '||l_new_enrt_cvg_strt_dt,199);
8460 open c_new_cvg_strt_dt(l_pen.pl_typ_id, l_pen.ptip_id,l_pen.pl_id, l_pen.oipl_id,
8461 l_enrt_cvg_strt_dt );
8462 fetch c_new_cvg_strt_dt into l_new_enrt_cvg_strt_dt;
8463 close c_new_cvg_strt_dt;
8464 --commented for 10116920
8465 /* if l_new_enrt_cvg_strt_dt is null then
8466 open c_new_cvg_strt_dt(l_pen.pl_typ_id, l_pen.ptip_id,-999,
8467 l_enrt_cvg_strt_dt );
8468 fetch c_new_cvg_strt_dt into l_new_enrt_cvg_strt_dt;
8469 close c_new_cvg_strt_dt;
8470 end if;
8471 */
8472 --commented for 10116920
8473 End if;
8474 --
8475 -- Change Coverage Dates to 1 Prior
8476 if (substr(nvl(l_cvg_end_dt_cd, 'X'), 1, 1) = 'W' or
8477 substr(nvl(l_cvg_end_dt_cd, 'X'), 1, 2) = 'LW' ) and
8478 (p_per_in_ler_id <> l_pil_id or l_ler_typ_cd = 'SCHEDDU' ) then
8479 --
8480 if l_new_enrt_cvg_strt_dt is not null then
8481 l_enrt_cvg_end_dt := nvl(l_new_enrt_cvg_strt_dt - 1, l_enrt_cvg_end_dt ) ;
8482 end if;
8483 --
8484 end if;
8485 --
8486 if g_debug then
8487 hr_utility.set_location('c_new_cvg_strt_dt'||l_new_enrt_cvg_strt_dt,199);
8488 hr_utility.set_location('l_enrt_cvg_end_dt'||l_enrt_cvg_end_dt,199);
8489 end if;
8490 --
8491 -- Change Rate Dates to 1 Prior
8492 If (substr(nvl(l_rt_end_dt_cd, 'X'), 1, 1) = 'W' or
8493 substr(nvl(l_rt_end_dt_cd, 'X'), 1, 2) = 'LW' or
8494 l_rt_end_dt_cd in ('LDPPOEFD','LDPPFEFD','LODBEWM','ODBEWM') )
8495 -- Bug: 4268494. Evaluate '1 Prior' for these codes as well.
8496 -- Bug: 4642299 Added 'LODBEWM','ODBEWM' too for 1 Prior logic.
8497 then
8498 --
8499 if g_debug then
8500 hr_utility.set_location(' pen api rt strt dt ' || l_rt_strt_dt, 299 );
8501 hr_utility.set_location(' pen api rt end dt ' || l_rt_end_dt, 299 );
8502 end if;
8503 --bug#3260564
8504 if l_new_enrt_cvg_strt_dt is not null then
8505 l_rt_end_dt := nvl(l_rt_strt_dt - 1,l_rt_end_dt) ;
8506 end if;
8507 --
8508 End if;
8509 --
8510 If l_enrt_cvg_end_dt is NULL then
8511 rpt_error(p_proc => l_proc, p_step => l_step);
8512 fnd_message.set_name('BEN','BEN_91702_NOT_DET_CVG_END_DT');
8513 -- fnd_message.raise_error;
8514 raise l_fnd_message_exception;
8515
8516 End if;
8517 --
8518 If l_rt_end_dt is NULL then
8519 rpt_error(p_proc => l_proc, p_step => l_step);
8520 fnd_message.set_name('BEN','BEN_91703_NOT_DET_RATE_END_DT');
8521 -- fnd_message.raise_error;
8522 raise l_fnd_message_exception;
8523 end if;
8524 --
8525 -- when the result is voided the participant rate rows also should be voided as sometimes
8526 -- the rate end date comes greater or equal to rate start date which is not voiding the rate rows
8527 -- Update rt_end_dt in prtt_rate_val table
8528 --
8529 --Bug 5368060
8530 --Dont void the rate if the PEN record is Backed-Out
8531 --If the PEN record is end-dated in the subsequent life event dont void the rate
8532
8533 --Bug 5499809
8534 --Void the enrollment rate if the delete enrollment is being performed in the same life event and that life event is not unrestricted LE
8535
8536 -- Commented the below if condition
8537 -- if l_pen.enrt_cvg_strt_dt > l_enrt_cvg_end_dt then
8538
8539 if ((l_pen.per_in_ler_id = l_pen.pen_per_in_ler_id) and (l_ler_typ_cd <> 'SCHEDDU')) then
8540 --
8541 --5663280
8542 open c_check_carry_fwd_enrt(p_prtt_enrt_rslt_id, p_per_in_ler_id, l_pen.enrt_cvg_strt_dt,
8543 l_pen.effective_start_date);
8544 fetch c_check_carry_fwd_enrt into l_check_carry_fwd_enrt;
8545 close c_check_carry_fwd_enrt;
8546
8547 if l_check_carry_fwd_enrt is null then
8548 hr_utility.set_location('Void Rate procedure is called',3455);
8549 void_rate (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id,
8550 p_business_group_id => p_business_group_id,
8551 p_person_id => l_pen.person_id,
8552 p_per_in_ler_id => p_per_in_ler_id,
8553 p_effective_date => p_effective_date );
8554
8555 -----Bug 6925893
8556 If substr(nvl(l_rt_end_dt_cd, 'X'), 1, 1) = 'W' or
8557 substr(nvl(l_rt_end_dt_cd, 'X'), 1, 2) = 'LW' or
8558 l_rt_end_dt_cd in ('LDPPOEFD','LDPPFEFD','LODBEWM','ODBEWM') then ---Bug 7209243
8559 /* open c_get_old_prv;
8560 fetch c_get_old_prv into l_get_old_prv;
8561 if c_get_old_prv%found then
8562 hr_utility.set_location('l_get_old_prv.prtt_rt_val_id :'||l_get_old_prv.prtt_rt_val_id,3455); */
8563 --Bug 9290518
8564 l_old_prv_found := false;
8565 for l_old_prv in c_get_old_prv loop
8566 hr_utility.set_location('l_old_prv.prtt_rt_val_id :'|| l_old_prv.prtt_rt_val_id,3455);
8567 l_old_prv_found := true;
8568 ben_prtt_rt_val_api.update_prtt_rt_val
8569 (P_VALIDATE => FALSE
8570 ,P_PRTT_RT_VAL_ID => l_old_prv.prtt_rt_val_id --l_get_old_prv.prtt_rt_val_id
8571 ,P_RT_END_DT => l_rt_end_dt
8572 ,p_person_id => l_pen.person_id
8573 ,p_input_value_id => l_old_prv.input_value_id --l_get_old_prv.input_value_id
8574 ,p_element_type_id => l_old_prv.element_type_id --l_get_old_prv.element_type_id
8575 ,p_prtt_rt_val_stat_cd => null
8576 ,p_business_group_id => p_business_group_id
8577 ,P_OBJECT_VERSION_NUMBER => l_old_prv.object_version_number --l_get_old_prv.object_version_number
8578 ,P_EFFECTIVE_DATE => p_effective_date
8579 );
8580 end loop;
8581 ---Bug 9290518
8582 hr_utility.set_location('P_RT_END_DT :'||hr_api.g_eot,3455);
8583 -- else ------------Bug 7209243
8584 if not(l_old_prv_found) then --Bug 9290518
8585 hr_utility.set_location('c_get_old_prv not found',3455);
8586 ---get the new rt start dat to compute the end date
8587 open c_get_epe(l_pen.pl_typ_id);
8588 fetch c_get_epe into l_get_epe;
8589 if c_get_epe%found then
8590 ben_determine_date.rate_and_coverage_dates
8591 (p_elig_per_elctbl_chc_id => l_get_epe.elig_per_elctbl_chc_id
8592 ,p_business_group_id => l_get_epe.business_group_id
8593 ,P_PER_IN_LER_ID => l_get_epe.per_in_ler_id
8594 ,P_PERSON_ID => l_pen.person_id
8595 ,P_PGM_ID => l_get_epe.pgm_id
8596 ,P_PL_ID => l_get_epe.pl_id
8597 ,P_OIPL_ID => l_get_epe.oipl_id
8598 ,P_LEE_RSN_ID => nvl(p_lee_rsn_id,l_lee_rsn_id)
8599 ,P_ENRT_PERD_ID => nvl(p_enrt_perd_id,l_enrt_perd_id)
8600 ,p_enrt_cvg_strt_dt => l_enrt_cvg_strt_dt1
8601 ,p_enrt_cvg_strt_dt_cd => l_enrt_cvg_strt_dt_cd
8602 ,p_enrt_cvg_strt_dt_rl => l_enrt_cvg_strt_dt_rl
8603 ,p_rt_strt_dt => l_rt_strt_dt1
8604 ,p_rt_strt_dt_cd => l_rt_strt_dt_cd
8605 ,p_rt_strt_dt_rl => l_rt_strt_dt_rl
8606 ,p_enrt_cvg_end_dt => l_enrt_cvg_end_dt1
8607 ,p_enrt_cvg_end_dt_cd => l_enrt_cvg_end_dt_cd
8608 ,p_enrt_cvg_end_dt_rl => l_enrt_cvg_end_dt_rl
8609 ,p_rt_end_dt => l_rt_end_dt1
8610 ,p_rt_end_dt_cd => l_rt_end_dt_cd
8611 ,p_rt_end_dt_rl => l_rt_end_dt_rl
8612 ,p_effective_date => p_effective_date
8613 ,p_end_date => p_enrt_cvg_thru_dt
8614 );
8615 l_rt_end_dt1 := l_rt_strt_dt1 - 1;
8616 ---Bug 9290518
8617 /* open c_get_old_prv1;
8618 fetch c_get_old_prv1 into l_get_old_prv1;
8619 if c_get_old_prv1%found then */
8620 for l_get_old_prv1 in c_get_old_prv1 loop
8621 hr_utility.set_location('l_get_old_prv1.prtt_rt_val_id :'||l_get_old_prv1.prtt_rt_val_id,3455);
8622 hr_utility.set_location('l_get_old_prv1.ovn :'||l_get_old_prv1.object_version_number,3455.1);
8623 hr_utility.set_location('l_rt_end_dt1 :'||l_rt_end_dt1,3455.1);
8624
8625 ben_prtt_rt_val_api.update_prtt_rt_val
8626 (P_VALIDATE => FALSE
8627 ,P_PRTT_RT_VAL_ID => l_get_old_prv1.prtt_rt_val_id
8628 ,P_RT_END_DT => l_rt_end_dt1
8629 ,p_person_id => l_pen.person_id
8630 ,p_input_value_id => l_get_old_prv1.input_value_id
8631 ,p_element_type_id => l_get_old_prv1.element_type_id
8632 ,p_prtt_rt_val_stat_cd => null
8633 ,p_business_group_id => p_business_group_id
8634 ,P_OBJECT_VERSION_NUMBER => l_get_old_prv1.object_version_number
8635 ,P_EFFECTIVE_DATE => p_effective_date
8636 );
8637 /* end if;
8638 close c_get_old_prv1; */
8639 end loop;
8640 --Bug 9290518
8641 end if;
8642 close c_get_epe; -------------Bug 7209243
8643 end if;
8644 -- close c_get_old_prv; ---Bug 9290518
8645 hr_utility.set_location('P_RT_END_DT not fund :'||hr_api.g_eot,3455);
8646 hr_utility.set_location('p_effective_start_date :'||p_effective_start_date,3455);
8647 hr_utility.set_location('p_effective_date :'||p_effective_date,3455);
8648 end if;
8649 -----Bug 6925893
8650 end if;
8651 end if;
8652 --End Bug 5499809
8653
8654 hr_utility.set_location('P_RT_END_DT not fund1 :'||hr_api.g_eot,3455);
8655 --
8656 l_step := 35;
8657 if g_debug then
8658 hr_utility.set_location(l_proc,3456);
8659 end if;
8660 -- rate is having non recurring
8661 if g_debug then
8662 hr_utility.set_location(l_deenrol_dt,3459);
8663 end if;
8664 for l_prv in c_prv3 (p_per_in_ler_id) loop
8665 --check whether rate is non-recurring
8666 open c_abr(l_prv.acty_base_rt_id);
8667 fetch c_abr into l_abr;
8668 close c_abr;
8669 --
8670 if (l_abr.processing_type = 'N' or
8671 l_abr.rcrrg_cd = 'ONCE' ) and
8672 l_pen.enrt_cvg_strt_dt > l_enrt_cvg_end_dt then
8673 null;
8674 else
8675 exit;
8676 end if;
8677 if g_debug then
8678 hr_utility.set_location('delete prtt',3459);
8679 end if;
8680 update ben_enrt_rt
8681 set prtt_rt_val_id = null
8682 where enrt_rt_id = l_prv.enrt_rt_id;
8683 --
8684 ben_prtt_rt_val_api.delete_prtt_rt_val
8685 (P_VALIDATE => FALSE
8686 ,P_PRTT_RT_VAL_ID => l_prv.prtt_rt_val_id
8687 ,P_OBJECT_VERSION_NUMBER => l_prv.object_version_number
8688 ,P_EFFECTIVE_DATE => l_eff_dt
8689 ,p_person_id => l_pen.person_id
8690 ,p_business_group_id => p_business_group_id
8691 );
8692 end loop;
8693 For l_prv in c_prv2 loop
8694 if g_debug then
8695 hr_utility.set_location(l_proc,3457);
8696 end if;
8697 l_prv_count := l_prv_count + 1;
8698 if (nvl(l_prv.per_in_ler_id, -1) <> nvl(p_per_in_ler_id,-1)) and
8699 l_rt_end_dt < l_prv.rt_strt_dt then
8700 l_prtt_rt_val_stat_cd := 'BCKDT';
8701 end if;
8702 ben_prtt_rt_val_api.update_prtt_rt_val
8703 (P_VALIDATE => FALSE
8704 ,P_PRTT_RT_VAL_ID => l_prv.prtt_rt_val_id
8705 ,P_RT_END_DT => l_rt_end_dt
8706 ,p_person_id => l_pen.person_id
8707 --Bug#2625060 - for converted data, null is passed for activity base rt id
8708 -- ,p_acty_base_rt_id => l_prv.acty_base_rt_id
8709 ,p_input_value_id => l_prv.input_value_id
8710 ,p_prtt_rt_val_stat_cd => l_prtt_rt_val_stat_cd
8711 ,p_element_type_id => l_prv.element_type_id
8712 ,p_ended_per_in_ler_id => p_per_in_ler_id
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 if g_debug then
8718 hr_utility.set_location(l_proc,3458);
8719 end if;
8720 end loop;
8721 --
8722 -- Adjust overlapping rates . Bug 5391554
8723 --
8724 -- basu
8725 hr_utility.set_location('p_per_in_ler_id '||p_per_in_ler_id,44333);
8726 --
8727 open c_get_pgm_extra_info(l_pen.pgm_id);
8728 fetch c_get_pgm_extra_info into l_adjust;
8729 if c_get_pgm_extra_info%found then
8730 if l_adjust = 'Y' then
8731 for l_prv5 in c_prv5(l_rt_end_dt) loop
8732 --
8733 if g_debug then
8734 hr_utility.set_location('Adjusting rate '||l_rt_end_dt,111);
8735 end if;
8736 ben_prtt_rt_val_api.update_prtt_rt_val
8737 (P_VALIDATE => FALSE
8738 ,P_PRTT_RT_VAL_ID => l_prv5.prtt_rt_val_id
8739 ,P_RT_END_DT => l_rt_end_dt
8740 ,p_person_id => l_pen.person_id
8741 ,p_input_value_id => l_prv5.input_value_id
8742 ,p_element_type_id => l_prv5.element_type_id
8743 ,p_ended_per_in_ler_id => p_per_in_ler_id
8744 ,p_business_group_id => p_business_group_id
8745 ,P_OBJECT_VERSION_NUMBER => l_prv5.object_version_number
8746 ,P_EFFECTIVE_DATE => p_effective_date
8747 );
8748 end loop;
8749 end if;
8750 end if;
8751 close c_get_pgm_extra_info;
8752
8753 -- Bug#2038814 - cursor above updates only the last prtt_rt_val and if there is
8754 -- any future dated prtt_rt_val, rows with rt end date greater than the calculated rt end
8755 -- date needs to be updated
8756 -- Bug 2739965
8757 if l_benmngle_parm_rec.mode_cd = 'S' or l_ler_typ_cd = 'SCHEDDU' then
8758 if g_debug then
8759 hr_utility.set_location('ben mngle mode',111);
8760 hr_utility.set_location('rate end date'||l_rt_end_dt,111);
8761 end if;
8762 For l_prv4 in c_prv4 (l_rt_end_dt) loop
8763 if g_debug then
8764 hr_utility.set_location(l_proc,3459);
8765 end if;
8766 -- 2739965 In case of unrestricted enrollment, this happens only when there are future rates
8767 -- and they got deleted as part of c_prv2 process above. Lets us throw this error
8768 -- here warning the user about the deletion of the future rate.
8769 --
8770 /* Bug 5739530 : Update prv only if it has not been updated previously */
8771 if l_prv4.prtt_rt_val_id <> prev_prtt_rt_val_id then
8772 --
8773 prev_prtt_rt_val_id := l_prv4.prtt_rt_val_id;
8774 --
8775 if fnd_global.conc_request_id in ( 0,-1) then
8776 -- Issue a warning to the user. These will display on the enrt forms.
8777 ben_warnings.load_warning
8778 (p_application_short_name => 'BEN',
8779 p_message_name => 'BEN_93369_DEL_FUT_RATE',
8780 p_parma => fnd_date.date_to_chardate( l_prv4.rt_end_dt+1 ),
8781 p_parmb => l_pen.pl_name || ' '||l_pen.opt_name,
8782 p_person_id => l_pen.person_id);
8783 end if;
8784 --
8785 ben_prtt_rt_val_api.update_prtt_rt_val
8786 (P_VALIDATE => FALSE
8787 ,P_PRTT_RT_VAL_ID => l_prv4.prtt_rt_val_id
8788 ,P_RT_END_DT => l_rt_end_dt
8789 ,p_person_id => l_pen.person_id
8790 --Bug#2625060 - for converted data, null is passed for activity base rt id
8791 -- ,p_acty_base_rt_id => l_prv4.acty_base_rt_id
8792 ,p_input_value_id => l_prv4.input_value_id
8793 ,p_element_type_id => l_prv4.element_type_id
8794 ,p_ended_per_in_ler_id => p_per_in_ler_id
8795 ,p_business_group_id => p_business_group_id
8796 ,P_OBJECT_VERSION_NUMBER => l_prv4.object_version_number
8797 ,P_EFFECTIVE_DATE => p_effective_date
8798 );
8799 if g_debug then
8800 hr_utility.set_location(l_proc,3460);
8801 end if;
8802 --
8803 end if; /* End Bug 5739530 */
8804 --
8805 end loop;
8806 --
8807 end if;
8808 if g_debug then
8809 hr_utility.set_location(l_proc,3459);
8810 end if;
8811 --
8812 -- 3574168: Remove PCP records
8813 -- Set End-date to coverage-end-date.
8814 --
8815 l_pcp_effective_date := NVL(l_enrt_cvg_end_dt+1, p_effective_date);
8816 --
8817 for l_pcp in c_pcp(l_pcp_effective_date) loop
8818 --
8819 hr_utility.set_location('DELETE prmry_care_prvdr_id '|| l_pcp.prmry_care_prvdr_id, 15);
8820 hr_utility.set_location('PCP ESD: EED '|| l_pcp.effective_start_date ||': '||l_pcp.effective_end_date, 15);
8821 hr_utility.set_location('Effective Date to delete '|| l_pcp_effective_date, 15);
8822 hr_utility.set_location('DATETRACK_MODE '|| hr_api.g_delete, 15);
8823 -- Since, deletion automatically sets end-date to 1 day less than effective-date,
8824 -- call the delete-api with effective_date = cvg_thru_date+1.
8825 --
8826 ben_prmry_care_prvdr_api.delete_prmry_care_prvdr
8827 (P_VALIDATE => FALSE
8828 ,P_PRMRY_CARE_PRVDR_ID => l_pcp.prmry_care_prvdr_id
8829 ,P_EFFECTIVE_START_DATE => l_pcp.effective_start_date
8830 ,P_EFFECTIVE_END_DATE => l_pcp.effective_end_date
8831 ,P_OBJECT_VERSION_NUMBER => l_pcp.object_version_number
8832 ,P_EFFECTIVE_DATE => l_pcp_effective_date
8833 ,P_DATETRACK_MODE => hr_api.g_delete
8834 ,p_called_from => 'delete_enrollment'
8835 );
8836 --
8837 End loop;
8838 --
8839 -- Get future PCP records if any and zap - delete all of them.
8840 --
8841 for l_pcp_future in c_pcp_future(l_pcp_effective_date) loop
8842 --
8843 l_pcp_effective_start_date := l_pcp_future.effective_start_date;
8844 --
8845 hr_utility.set_location('ZAP prmry_care_prvdr_id '|| l_pcp_future.prmry_care_prvdr_id, 15);
8846 hr_utility.set_location('PCP ESD: EED '|| l_pcp_future.effective_start_date ||': '||l_pcp_future.effective_end_date, 15);
8847 hr_utility.set_location('Effective Date to delete '|| l_pcp_effective_start_date, 15);
8848 --
8849 ben_prmry_care_prvdr_api.delete_prmry_care_prvdr
8850 (P_VALIDATE => FALSE
8851 ,P_PRMRY_CARE_PRVDR_ID => l_pcp_future.prmry_care_prvdr_id
8852 ,P_EFFECTIVE_START_DATE => l_pcp_future.effective_start_date
8853 ,P_EFFECTIVE_END_DATE => l_pcp_future.effective_end_date
8854 ,P_OBJECT_VERSION_NUMBER => l_pcp_future.object_version_number
8855 ,P_EFFECTIVE_DATE => l_pcp_effective_start_date
8856 ,P_DATETRACK_MODE => hr_api.g_zap
8857 ,p_called_from => 'delete_enrollment'
8858 );
8859 End loop;
8860 -- 3574168
8861 --
8862 -- Get dependent coverage End date. If Participant coverage end date
8863 -- is greater than dependent coverage end date, then use participant.
8864 --
8865 l_step := 40;
8866 --
8867 calc_dpnt_cvg_dt
8868 (p_calc_end_dt => TRUE
8869 ,P_calc_strt_dt => FALSE
8870 ,p_per_in_ler_id => l_pen.per_in_ler_id
8871 ,P_person_id => l_pen.person_id
8872 ,p_pgm_id => l_pen.pgm_id
8873 ,p_pl_id => l_pen.pl_id
8874 ,p_oipl_id => l_pen.oipl_id
8875 ,p_ptip_id => l_pen.ptip_id
8876 ,p_ler_id => l_pen.ler_id
8877 ,P_BUSINESS_GROUP_ID => p_business_group_id
8878 ,P_EFFECTIVE_DATE => p_effective_date
8879 ,P_RETURNED_END_DT => l_dpnt_cvg_end_dt
8880 ,P_RETURNED_STRT_DT => l_dump_date
8881 ,p_enrt_cvg_end_dt => l_enrt_cvg_end_dt
8882 );
8883 --
8884 l_step := 90;
8885 --
8886 -- bug 3327224 -- make dpnt cvg independent of prtt's cvg
8887 /*
8888 If l_dpnt_cvg_end_dt is not NULL then
8889 l_dpnt_cvg_thru_dt := least(l_enrt_cvg_end_dt, l_dpnt_cvg_end_dt);
8890 End if;
8891 */
8892 l_dpnt_cvg_thru_dt := l_dpnt_cvg_end_dt;
8893 --
8894 -- Unhook dependent rows
8895 --
8896 l_step := 110;
8897 unhook_dpnt
8898 (p_validate => FALSE
8899 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8900 ,p_per_in_ler_id => l_pen.per_in_ler_id
8901 ,p_cvg_thru_dt => l_dpnt_cvg_thru_dt
8902 ,p_business_group_id => p_business_group_id
8903 ,p_effective_date => p_effective_date
8904 ,p_datetrack_mode => p_datetrack_mode
8905 ,p_called_from => p_source
8906 );
8907 unhook_bnf
8908 (p_validate => FALSE
8909 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8910 ,p_per_in_ler_id => l_pen.per_in_ler_id
8911 ,p_dsgn_thru_dt => l_enrt_cvg_end_dt
8912 ,p_business_group_id => p_business_group_id
8913 ,p_effective_date => p_effective_date
8914 ,p_datetrack_mode => p_datetrack_mode
8915 );
8916
8917 /* Added code for Bug 7561395*/
8918 hr_utility.set_location('Unhook dependent rows ', 500);
8919 hr_utility.set_location('p_prtt_enrt_rslt_ids '||p_prtt_enrt_rslt_id, 503);
8920 hr_utility.set_location('l_pen.pen_per_in_ler_id '||l_pen.pen_per_in_ler_id, 503);
8921 hr_utility.set_location('p_pen_per_in_ler_id '||p_per_in_ler_id, 503);
8922 hr_utility.set_location('g_new_prtt_enrt_rslt_id '||g_new_prtt_enrt_rslt_id, 503);
8923
8924 /* Bug 8669907:
8925 if(action item exists for the pen_id ) do not create
8926 else
8927 if(Participant has selected diff comp obj) do not create
8928 else if(not enter value at enrollment) perform validations before creating action items
8929 else perform validations before creating action items
8930 Set the l_create_flag to 'Y' if action item has to be created */
8931
8932 open c_chk_act_item_exits(g_new_prtt_enrt_rslt_id);
8933 fetch c_chk_act_item_exits into l_dummy1;
8934 if(c_chk_act_item_exits%found) then
8935 hr_utility.set_location('No Create 1',500);
8936 close c_chk_act_item_exits;
8937 l_create_flag := 'N';
8938 else
8939 close c_chk_act_item_exits;
8940 open c_chk_same_comp_obj(g_new_prtt_enrt_rslt_id,p_prtt_enrt_rslt_id,p_per_in_ler_id);
8941 fetch c_chk_same_comp_obj into l_create_flag;
8942 if(c_chk_same_comp_obj%notfound) then
8943 hr_utility.set_location('No Create 2',500);
8944 close c_chk_same_comp_obj;
8945 l_create_flag := 'N';
8946 else
8947 close c_chk_same_comp_obj;
8948 open c_bnft_amt(g_new_prtt_enrt_rslt_id,p_per_in_ler_id);
8949 fetch c_bnft_amt into l_bnft ;
8950 close c_bnft_amt;
8951 if(l_bnft.entr_val_at_enrt_flag = 'N') then
8952 if(l_bnft.cvg_mlt_cd = 'FLRNG') then
8953 if(l_bnft.bnft_amt > l_bnft.mx_val) then
8954 hr_utility.set_location('FLRNG Create ',500);
8955 l_create_flag := 'Y';
8956 else
8957 hr_utility.set_location('FLRNG No Create',500);
8958 l_create_flag := 'N';
8959 end if;
8960 else
8961 hr_utility.set_location('Create 1',500);
8962 l_create_flag := 'Y';
8963 end if;
8964 else
8965 if(l_bnft.mx_wout_ctfn_val is not null and l_bnft.bnft_amt > l_bnft.mx_wout_ctfn_val ) then
8966 hr_utility.set_location('Create 2',500);
8967 l_create_flag := 'Y';
8968 elsif(l_bnft.mx_wout_ctfn_val is not null and l_bnft.bnft_amt <= l_bnft.mx_wout_ctfn_val ) then
8969 hr_utility.set_location('No Create 4',500);
8970 l_create_flag := 'N';
8971 else
8972 hr_utility.set_location('Create 3',500);
8973 l_create_flag := 'Y';
8974 end if;
8975 end if;
8976 end if;
8977 end if;
8978 hr_utility.set_location('l_create_flag '||l_create_flag,500);
8979
8980 /* open c_chk_same_comp_obj(g_new_prtt_enrt_rslt_id,p_prtt_enrt_rslt_id,p_per_in_ler_id);
8981 fetch c_chk_same_comp_obj into l_create_flag;
8982 if(c_chk_same_comp_obj%notfound) then
8983 l_create_flag := 'N';
8984 end if;
8985 close c_chk_same_comp_obj;*/
8986
8987 open c_chk_same_event(g_new_prtt_enrt_rslt_id);
8988 fetch c_chk_same_event into l_nper_in_ler_id ;
8989 close c_chk_same_event;
8990 open c_chk_same_event(p_prtt_enrt_rslt_id);
8991 fetch c_chk_same_event into l_oper_in_ler_id ;
8992 close c_chk_same_event;
8993 open c_chk_act_item_exits(p_prtt_enrt_rslt_id);
8994 fetch c_chk_act_item_exits into l_dummy1;
8995 if(c_chk_act_item_exits%found) then
8996 l_act_flag := true;
8997 hr_utility.set_location('In loop2 false',500);
8998 else
8999 l_act_flag := false;
9000 hr_utility.set_location('In loop2 true',500);
9001 end if;
9002 close c_chk_act_item_exits;
9003 if(l_nper_in_ler_id = l_oper_in_ler_id and l_act_flag) then
9004
9005 open c_get_actn_items;
9006 fetch c_get_actn_items BULK COLLECT into l_act_items;
9007 hr_utility.set_location('In loop1',500);
9008 if(l_act_items.count > 0) then
9009 l_act_flag := true;
9010 hr_utility.set_location('In loop10 '||l_act_items.count,500);
9011 else
9012 l_act_flag := false;
9013 hr_utility.set_location('In loop11',500);
9014 end if;
9015 close c_get_actn_items;
9016
9017
9018 open c_get_ctfn;
9019 fetch c_get_ctfn BULK COLLECT into l_ctfn;
9020 if(l_ctfn.count > 0) then
9021 l_ctfn_flag := true;
9022 end if;
9023 close c_get_ctfn;
9024
9025 hr_utility.set_location('Remving action items',500);
9026 remove_cert_action_items
9027 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
9028 ,p_effective_date => p_effective_date
9029 ,p_end_date => l_enrt_cvg_end_dt
9030 ,p_business_group_id => p_business_group_id
9031 ,p_validate => FALSE
9032 ,p_datetrack_mode => hr_api.g_delete
9033 ,p_source => p_source
9034 ,p_per_in_ler_id => l_pen.pen_per_in_ler_id
9035 ,p_per_in_ler_ended_id=> l_pen.per_in_ler_id
9036 );
9037
9038 if(l_act_flag and l_create_flag = 'Y' ) then
9039 hr_utility.set_location('creating action items',500);
9040 for i IN l_act_items.FIRST..l_act_items.LAST loop
9041 ben_PRTT_ENRT_ACTN_api.create_PRTT_ENRT_ACTN
9042 (p_validate => false
9043 ,p_effective_date => p_effective_date
9044 ,p_cmpltd_dt => l_act_items(i).cmpltd_dt
9045 ,p_due_dt => l_act_items(i).due_dt
9046 ,p_rqd_flag => l_act_items(i).rqd_flag
9047 ,p_prtt_enrt_rslt_id => g_new_prtt_enrt_rslt_id
9048 ,p_per_in_ler_id => p_per_in_ler_id
9049 ,p_rslt_object_version_number => l_rslt_object_version_number
9050 ,p_actn_typ_id => l_act_items(i).actn_typ_id
9051 ,p_elig_cvrd_dpnt_id => l_act_items(i).elig_cvrd_dpnt_id
9052 ,p_pl_bnf_id => l_act_items(i).pl_bnf_id
9053 ,p_business_group_id => l_act_items(i).business_group_id
9054 ,p_pea_attribute_category => l_act_items(i).pea_attribute_category
9055 ,p_pea_attribute1 => l_act_items(i).pea_attribute1
9056 ,p_pea_attribute2 => l_act_items(i).pea_attribute2
9057 ,p_pea_attribute3 => l_act_items(i).pea_attribute3
9058 ,p_pea_attribute4 => l_act_items(i).pea_attribute4
9059 ,p_pea_attribute5 => l_act_items(i).pea_attribute5
9060 ,p_pea_attribute6 => l_act_items(i).pea_attribute6
9061 ,p_pea_attribute7 => l_act_items(i).pea_attribute7
9062 ,p_pea_attribute8 => l_act_items(i).pea_attribute8
9063 ,p_pea_attribute9 => l_act_items(i).pea_attribute9
9064 ,p_pea_attribute10 => l_act_items(i).pea_attribute10
9065 ,p_pea_attribute11 => l_act_items(i).pea_attribute11
9066 ,p_pea_attribute12 => l_act_items(i).pea_attribute12
9067 ,p_pea_attribute13 => l_act_items(i).pea_attribute13
9068 ,p_pea_attribute14 => l_act_items(i).pea_attribute14
9069 ,p_pea_attribute15 => l_act_items(i).pea_attribute15
9070 ,p_pea_attribute16 => l_act_items(i).pea_attribute16
9071 ,p_pea_attribute17 => l_act_items(i).pea_attribute17
9072 ,p_pea_attribute18 => l_act_items(i).pea_attribute18
9073 ,p_pea_attribute19 => l_act_items(i).pea_attribute19
9074 ,p_pea_attribute20 => l_act_items(i).pea_attribute20
9075 ,p_pea_attribute21 => l_act_items(i).pea_attribute21
9076 ,p_pea_attribute22 => l_act_items(i).pea_attribute22
9077 ,p_pea_attribute23 => l_act_items(i).pea_attribute23
9078 ,p_pea_attribute24 => l_act_items(i).pea_attribute24
9079 ,p_pea_attribute25 => l_act_items(i).pea_attribute25
9080 ,p_pea_attribute26 => l_act_items(i).pea_attribute26
9081 ,p_pea_attribute27 => l_act_items(i).pea_attribute27
9082 ,p_pea_attribute28 => l_act_items(i).pea_attribute28
9083 ,p_pea_attribute29 => l_act_items(i).pea_attribute29
9084 ,p_pea_attribute30 => l_act_items(i).pea_attribute30
9085 ,p_object_version_number => l_actn_object_version_number
9086 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
9087 ,p_effective_start_date => l_actn_start_date
9088 ,p_effective_end_date => l_actn_end_date
9089 ,p_gnrt_cm => false -- Bug 9256641 : Do not generate communications
9090 );
9091 end loop;
9092 hr_utility.set_location('created action items',500);
9093 end if;
9094
9095 hr_utility.set_location('before creating cert',500);
9096 if(l_ctfn_flag and l_create_flag = 'Y' ) then
9097 hr_utility.set_location('creating certifications ',500);
9098 for j IN l_ctfn.FIRST..l_ctfn.LAST loop
9099 hr_utility.set_location('looping cert ',500);
9100 ben_PRTT_ENRT_CTFN_PRVDD_api.create_PRTT_ENRT_CTFN_PRVDD
9101 (p_validate => false
9102 ,p_prtt_enrt_ctfn_prvdd_id => l_prtt_enrt_ctfn_prvdd_id
9103 ,p_effective_start_date => l_ctfn_start_date
9104 ,p_effective_end_date => l_ctfn_end_date
9105 ,p_enrt_ctfn_rqd_flag => l_ctfn(j).enrt_ctfn_rqd_flag
9106 ,p_enrt_ctfn_typ_cd => l_ctfn(j).enrt_ctfn_typ_cd
9107 ,p_enrt_ctfn_recd_dt => l_ctfn(j).enrt_ctfn_recd_dt
9108 ,p_enrt_ctfn_dnd_dt => l_ctfn(j).enrt_ctfn_dnd_dt
9109 ,p_enrt_r_bnft_ctfn_cd => l_ctfn(j).enrt_r_bnft_ctfn_cd
9110 ,p_prtt_enrt_rslt_id => g_new_prtt_enrt_rslt_id
9111 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
9112 ,p_business_group_id => l_ctfn(j).business_group_id
9113 ,p_pcs_attribute_category => l_ctfn(j).pcs_attribute_category
9114 ,p_pcs_attribute1 => l_ctfn(j).pcs_attribute1
9115 ,p_pcs_attribute2 => l_ctfn(j).pcs_attribute2
9116 ,p_pcs_attribute3 => l_ctfn(j).pcs_attribute3
9117 ,p_pcs_attribute4 => l_ctfn(j).pcs_attribute4
9118 ,p_pcs_attribute5 => l_ctfn(j).pcs_attribute5
9119 ,p_pcs_attribute6 => l_ctfn(j).pcs_attribute6
9120 ,p_pcs_attribute7 => l_ctfn(j).pcs_attribute7
9121 ,p_pcs_attribute8 => l_ctfn(j).pcs_attribute8
9122 ,p_pcs_attribute9 => l_ctfn(j).pcs_attribute9
9123 ,p_pcs_attribute10 => l_ctfn(j).pcs_attribute10
9124 ,p_pcs_attribute11 => l_ctfn(j).pcs_attribute11
9125 ,p_pcs_attribute12 => l_ctfn(j).pcs_attribute12
9126 ,p_pcs_attribute13=> l_ctfn(j).pcs_attribute13
9127 ,p_pcs_attribute14 => l_ctfn(j).pcs_attribute14
9128 ,p_pcs_attribute15 => l_ctfn(j).pcs_attribute15
9129 ,p_pcs_attribute16=> l_ctfn(j).pcs_attribute16
9130 ,p_pcs_attribute17 => l_ctfn(j).pcs_attribute17
9131 ,p_pcs_attribute18 => l_ctfn(j).pcs_attribute18
9132 ,p_pcs_attribute19 => l_ctfn(j).pcs_attribute19
9133 ,p_pcs_attribute20 => l_ctfn(j).pcs_attribute20
9134 ,p_pcs_attribute21=> l_ctfn(j).pcs_attribute21
9135 ,p_pcs_attribute22 => l_ctfn(j).pcs_attribute22
9136 ,p_pcs_attribute23 => l_ctfn(j).pcs_attribute23
9137 ,p_pcs_attribute24=>l_ctfn(j).pcs_attribute24
9138 ,p_pcs_attribute25 =>l_ctfn(j).pcs_attribute25
9139 ,p_pcs_attribute26 => l_ctfn(j).pcs_attribute26
9140 ,p_pcs_attribute27 => l_ctfn(j).pcs_attribute27
9141 ,p_pcs_attribute28 => l_ctfn(j).pcs_attribute28
9142 ,p_pcs_attribute29 => l_ctfn(j).pcs_attribute29
9143 ,p_pcs_attribute30 => l_ctfn(j).pcs_attribute30
9144 ,p_object_version_number => l_ctfn_object_version_number
9145 ,p_effective_date => p_effective_date
9146 );
9147 end loop;
9148 end if;
9149 g_new_prtt_enrt_rslt_id := -1;
9150 else
9151 remove_cert_action_items
9152 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
9153 ,p_effective_date => p_effective_date
9154 ,p_end_date => l_enrt_cvg_end_dt
9155 ,p_business_group_id => p_business_group_id
9156 ,p_validate => FALSE
9157 ,p_datetrack_mode => hr_api.g_delete
9158 ,p_source => p_source
9159 ,p_per_in_ler_id => l_pen.pen_per_in_ler_id
9160 ,p_per_in_ler_ended_id=> l_pen.per_in_ler_id
9161 );
9162 end if;
9163
9164 /* Commented code for Bug 7561395
9165 remove_cert_action_items
9166 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
9167 ,p_effective_date => p_effective_date
9168 ,p_end_date => l_enrt_cvg_end_dt
9169 ,p_business_group_id => p_business_group_id
9170 ,p_validate => FALSE
9171 ,p_datetrack_mode => hr_api.g_delete
9172 ,p_source => p_source
9173 ,p_per_in_ler_id => l_pen.pen_per_in_ler_id
9174 ,p_per_in_ler_ended_id=> l_pen.per_in_ler_id
9175 );*/
9176
9177 /* Ended code for Bug 7561395*/
9178
9179 --
9180 l_step := 120;
9181 --
9182 hr_utility.set_location(' Before get_ben_pen_upd_dt_mode '||p_datetrack_mode,123);
9183 get_ben_pen_upd_dt_mode
9184 (p_effective_date => p_effective_date
9185 ,p_base_key_value => p_prtt_enrt_rslt_id
9186 ,P_desired_datetrack_mode => p_datetrack_mode
9187 ,P_datetrack_allow => l_datetrack_mode
9188 ,p_ler_typ_cd => l_ler_typ_cd -- Bug 2739965
9189 );
9190 hr_utility.set_location(' After get_ben_pen_upd_dt_mode '||l_datetrack_mode,123);
9191 --
9192 l_step := 125;
9193 --
9194 if g_debug then
9195 hr_utility.set_location('enrt_cvg_end_dt='||l_enrt_cvg_end_dt,19);
9196 end if;
9197 --
9198 --CFW. If deleting a suspended result, remove interim pen id
9199 -- below code is commenetd as part of 5347887.
9200 /*l_rplcs_sspndd_rslt_id := hr_api.g_number;
9201 if l_pen.sspndd_flag = 'Y' then
9202 l_rplcs_sspndd_rslt_id := null;
9203 end if;*/
9204 -- bug#5363388
9205 if l_enrt_cvg_end_dt < l_pen.enrt_cvg_strt_dt then
9206 --
9207 if l_pen.per_in_ler_id <> l_pen.pen_per_in_ler_id then
9208 l_prtt_enrt_rslt_Stat_cd := 'BCKDT';
9209 end if;
9210 --
9211 end if;
9212 --Bug 5499809
9213 --Void the enrollment if the delete is being performed in the same life event and that life event is not unrestricted LE
9214 if ((l_pen.per_in_ler_id = l_pen.pen_per_in_ler_id) and (l_ler_typ_cd <> 'SCHEDDU') ) then
9215
9216 --Bug#:6641853
9217 OPEN c_get_correction_info (p_prtt_enrt_rslt_id,
9218 l_pen.effective_start_date,
9219 l_pen.per_in_ler_id,
9220 l_pen.person_id--12566240
9221 );
9222 FETCH c_get_correction_info INTO l_get_correction_info;
9223 CLOSE c_get_correction_info;
9224
9225 IF l_get_correction_info.place_holder='X' THEN
9226 l_prtt_enrt_rslt_Stat_cd:=NULL;
9227 l_datetrack_mode:='CORRECTION';
9228 ELSE
9229
9230 --5663280
9231 open c_check_carry_fwd_enrt(p_prtt_enrt_rslt_id, p_per_in_ler_id, l_pen.enrt_cvg_strt_dt,
9232 l_pen.effective_start_date);
9233 fetch c_check_carry_fwd_enrt into l_check_carry_fwd_enrt;
9234 close c_check_carry_fwd_enrt;
9235
9236 if l_check_carry_fwd_enrt is null then
9237 l_prtt_enrt_rslt_Stat_cd := 'VOIDD';
9238 end if;
9239 END IF;
9240 end if;
9241
9242 if g_debug then
9243 hr_utility.set_location('prtt stat cd'||l_prtt_enrt_rslt_Stat_cd,20);
9244 hr_utility.set_location('l_ler_typ_cd'||l_ler_typ_cd,20);
9245 end if;
9246 ----------------------------Bug 8222481
9247 /*Bug 13034863: When delete_enrollment is called for end dating the suspended enrollment because of
9248 certification being denied, end dated enrollments of previous LE should remain untouched. Modified the below
9249 if condition*/
9250 if (l_prtt_enrt_rslt_Stat_cd = 'VOIDD'
9251 and ( (p_source is NULL) or (p_source is not NULL and p_source <> 'bepcsapi') ))then
9252 If (substr(nvl(l_cvg_end_dt_cd, 'X'), 1, 1) = 'W' or
9253 substr(nvl(l_cvg_end_dt_cd, 'X'), 1, 2) = 'LW' ) then
9254 -------get the ended pen ID
9255 open c_get_ended_pen(p_per_in_ler_id,l_pen.pl_typ_id,l_pen.pgm_id);
9256 fetch c_get_ended_pen bulk collect into l_get_ended_pen;
9257 hr_utility.set_location('Total ended pen : '||c_get_ended_pen%rowcount,1);
9258 --Removed this part,since the fix works only if one plan in a plan type is de-enrolled.
9259 /* if c_get_ended_pen%rowcount > 1 then
9260 hr_utility.set_location('enrolled into more than 1 plan',1);
9261 open c_get_last_pil(l_get_ended_pen(1).person_id);
9262 fetch c_get_last_pil into l_get_last_pil;
9263
9264 if c_get_last_pil%found then
9265 for i in l_get_ended_pen.first..l_get_ended_pen.last loop
9266 open c_last_pil_pen1(l_get_last_pil.per_in_ler_id,l_pen.pl_id,l_get_ended_pen(i).pgm_id);
9267 fetch c_last_pil_pen1 into l_last_pil_pen1;
9268 if c_last_pil_pen1%found then
9269 l_del_next_chg_pen := l_last_pil_pen1;
9270 hr_utility.set_location('l_del_next_chg_pen.pen_id : '||l_del_next_chg_pen.prtt_enrt_rslt_id,1);
9271 end if;
9272 close c_last_pil_pen1;
9273 end loop;
9274 end if;
9275 close c_get_last_pil;
9276 elsif c_get_ended_pen%rowcount = 1 then */
9277 if c_get_ended_pen%rowcount = 1 then
9278 hr_utility.set_location('enroled into 1 plan only',1);
9279 open c_get_last_pil(l_get_ended_pen(1).person_id,l_get_ended_pen(1).prtt_enrt_rslt_id); -----Bug 8688513
9280 fetch c_get_last_pil into l_get_last_pil;
9281
9282 if c_get_last_pil%found then
9283 hr_utility.set_location('l_get_last_pil.per_in_ler_id : '||l_get_last_pil.per_in_ler_id,1);
9284 open c_last_pil_pen(l_get_last_pil.per_in_ler_id,l_get_ended_pen(1).prtt_enrt_rslt_id);
9285 fetch c_last_pil_pen into l_last_pil_pen;
9286 close c_last_pil_pen;
9287 l_del_next_chg_pen := l_last_pil_pen;
9288 hr_utility.set_location('l_del_next_chg_pen.prtt_enrt_rslt_id : '||l_del_next_chg_pen.prtt_enrt_rslt_id,1);
9289 --------delete the next change corresponding to old pen
9290 ben_prtt_enrt_result_api.delete_prtt_enrt_result
9291 (p_validate => false,
9292 p_prtt_enrt_rslt_id => l_del_next_chg_pen.prtt_enrt_rslt_id,
9293 p_effective_start_date => p_effective_start_date,
9294 p_effective_end_date => p_effective_end_date,
9295 p_object_version_number => l_del_next_chg_pen.object_version_number,
9296 p_effective_date => l_del_next_chg_pen.effective_start_date,
9297 p_datetrack_mode => hr_api.g_delete_next_change,
9298 p_multi_row_validate => FALSE);
9299
9300 end if;
9301 close c_get_last_pil;
9302 end if;
9303 close c_get_ended_pen;
9304
9305 end if;
9306 end if;
9307 ---------------Bug 8222481
9308 --End Bug 5499809
9309
9310 ben_prtt_enrt_result_api.update_prtt_enrt_result
9311 (p_validate => FALSE
9312 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
9313 ,p_effective_start_date => p_effective_start_date
9314 ,p_effective_end_date => p_effective_end_date
9315 ,p_per_in_ler_id => l_pen.per_in_ler_id
9316 ,p_ler_id => l_pen.ler_id
9317 ,p_enrt_cvg_thru_dt => l_enrt_cvg_end_dt
9318 --,p_rplcs_sspndd_rslt_id => l_rplcs_sspndd_rslt_id /* 5347887*/
9319 ,p_object_version_number => l_pen.pen_ovn
9320 ,p_effective_date => p_effective_date
9321 ,p_datetrack_mode => l_datetrack_mode
9322 ,p_multi_row_validate => p_multi_row_validate
9323 ,p_business_group_id => p_business_group_id
9324 ,p_prtt_enrt_rslt_stat_cd => l_prtt_enrt_rslt_Stat_cd
9325 );
9326 l_step := 126;
9327 --
9328 if p_source is null or
9329 p_source <> 'benelinf' then
9330 ben_ext_chlg.log_benefit_chg
9331 (p_action => 'DELETE'
9332 ,p_old_pl_id => l_pen.pl_id
9333 ,p_old_oipl_id => l_pen.oipl_id
9334 ,p_old_enrt_cvg_strt_dt => l_pen.enrt_cvg_strt_dt
9335 ,p_old_enrt_cvg_end_dt => l_pen.enrt_cvg_thru_dt
9336 ,p_pl_id => l_pen.pl_id
9337 ,p_oipl_id => l_pen.oipl_id
9338 ,p_enrt_cvg_strt_dt => l_pen.enrt_cvg_strt_dt
9339 ,p_enrt_cvg_end_dt => l_enrt_cvg_end_dt
9340 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
9341 ,p_per_in_ler_id => l_pen.per_in_ler_id
9342 ,p_person_id => l_pen.person_id
9343 ,p_business_group_id => p_business_group_id
9344 ,p_effective_date => p_effective_date
9345 );
9346 end if;
9347 l_step := 127;
9348 --
9349 if l_pen.pgm_id is not null then
9350 ben_provider_pools.remove_bnft_prvdd_ldgr
9351 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
9352 ,p_effective_date => p_effective_date
9353 ,p_business_group_id => p_business_group_id
9354 ,p_validate => FALSE
9355 ,p_datetrack_mode => hr_api.g_delete
9356 );
9357 end if;
9358 --
9359 end if;
9360 -- Special Case - Bug#5123
9361 Elsif (p_effective_date > l_pen.enrt_cvg_thru_dt)
9362 /* and l_pen.SSPNDD_FLAG = 'N'*/ then
9363 -- do nothing
9364 null;
9365 --
9366 -- Case 3: Coverage not started yet. Elected and deleted in same day.
9367 -- Case 4: Coverage not started yet. Elected and deleted not in same day.
9368 -- * Date-track end dated.
9369 Else
9370 --- if the coverage starts in future date and the per_in_ler_id is not the same
9371 --- the result are not deleted (ZAP), zaping create the problem if the current
9372 --- LE is backedout, it need the result to reintiate the previos LE
9373 ---
9374 Get_election_date(p_effective_date => p_effective_date
9375 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
9376 ,p_business_group_id => p_business_group_id
9377 ,p_date => l_date
9378 ,p_pil_id => l_pil_id
9379 );
9380 l_step := 135;
9381 if g_debug then
9382 hr_utility.set_location('p_datetrack_mode='||p_datetrack_mode,20);
9383 end if;
9384 if p_source is null or p_source = 'benelinf' then
9385 -- Bug 2537720
9386 -- This is not allowing to update the enrollment on the same date for
9387 -- the suspended enrollment.So added the l_pen.effective_start_date < p_effective_date
9388 -- condition.
9389 if p_datetrack_mode=hr_api.g_update
9390 and l_pen.effective_start_date < p_effective_date
9391 and p_per_in_ler_id <> l_pil_id then -----Added for the Bug 7311284
9392 --
9393 l_eff_dt:=p_effective_date-1;
9394 else
9395 l_eff_dt:=p_effective_date;
9396 end if;
9397 else
9398 l_eff_dt := p_effective_date;
9399 end if;
9400 if g_debug then
9401 hr_utility.set_location('per in ler ='|| p_per_in_ler_id ||' old ' || l_pil_id,21);
9402 hr_utility.set_location('future dated cvg ='||l_pen.enrt_cvg_strt_dt,21);
9403 end if;
9404 --- bug 2546259 the if condition added to treat the future dated Coverage
9405 --- if future dated cvg exisit dont zap the result, if the current LE
9406 --- Backedout then the future dated result hase to be restored
9407 --- Instead of zaping the result it is voided now
9408 if p_effective_date < l_pen.enrt_cvg_strt_dt
9409 and p_per_in_ler_id <> l_pil_id /* and l_pen.SSPNDD_FLAG = 'N' */ then
9410 -- Voiding future dated coverage started in previous LE
9411 --
9412 if g_debug then
9413 hr_utility.set_location('future dated cvg ='||l_pen.enrt_cvg_strt_dt,21);
9414 end if;
9415 If substr(nvl(l_cvg_end_dt_cd, 'X'), 1, 1) = 'W' or
9416 substr(nvl(l_cvg_end_dt_cd, 'X'), 1, 2) = 'LW' then
9417 --Bug 2847110
9418 open c_new_cvg_strt_dt(l_pen.pl_typ_id, l_pen.ptip_id, l_pen.pl_id, l_pen.oipl_id,
9419 l_enrt_cvg_strt_dt );
9420 fetch c_new_cvg_strt_dt into l_new_enrt_cvg_strt_dt;
9421 if c_new_cvg_strt_dt%found then
9422 --
9423 l_enrt_cvg_end_dt := nvl(l_new_enrt_cvg_strt_dt- 1,l_enrt_cvg_end_dt);
9424 close c_new_cvg_strt_dt;
9425 --commented for 10116920
9426 /* else
9427 close c_new_cvg_strt_dt;
9428 --
9429 open c_new_cvg_strt_dt(l_pen.pl_typ_id, l_pen.ptip_id,-999,
9430 l_enrt_cvg_strt_dt );
9431 fetch c_new_cvg_strt_dt into l_new_enrt_cvg_strt_dt;
9432 if c_new_cvg_strt_dt%found then
9433 l_enrt_cvg_end_dt := nvl(l_new_enrt_cvg_strt_dt - 1, l_enrt_cvg_end_dt ) ;
9434 end if;
9435 close c_new_cvg_strt_dt;
9436 --
9437 */
9438 --commented for 10116920
9439 end if;
9440 --
9441 End if;
9442 --
9443 if g_debug then
9444 hr_utility.set_location('c_new_cvg_strt_dt'||l_new_enrt_cvg_strt_dt,199);
9445 hr_utility.set_location('l_enrt_cvg_end_dt'||l_enrt_cvg_end_dt,199);
9446 end if;
9447 -- ikasire: Added the cases starting with 'LW'
9448 -- fixed typo - changed from l_cvg_end_dt_cd to l_rt_end_dt_cd in
9449 -- the if condition
9450 If substr(nvl(l_rt_end_dt_cd, 'X'), 1, 1) = 'W' or
9451 substr(nvl(l_rt_end_dt_cd, 'X'), 1, 2) = 'LW'
9452 then
9453 --
9454 if g_debug then
9455 hr_utility.set_location(' pen api rt strt dt ' || l_rt_strt_dt, 299 );
9456 hr_utility.set_location(' pen api rt end dt ' || l_rt_end_dt, 299 );
9457 end if;
9458 l_rt_end_dt := nvl(l_rt_strt_dt - 1,l_rt_end_dt) ;
9459 End if;
9460 --
9461 If l_enrt_cvg_end_dt is NULL then
9462 rpt_error(p_proc => l_proc, p_step => l_step);
9463 fnd_message.set_name('BEN','BEN_91702_NOT_DET_CVG_END_DT');
9464 -- fnd_message.raise_error;
9465 raise l_fnd_message_exception;
9466 End if;
9467 --
9468 If l_rt_end_dt is NULL then
9469 rpt_error(p_proc => l_proc, p_step => l_step);
9470 fnd_message.set_name('BEN','BEN_91703_NOT_DET_RATE_END_DT');
9471 -- fnd_message.raise_error;
9472 raise l_fnd_message_exception;
9473 end if;
9474 --
9475 -- Update rt_end_dt in prtt_rate_val table
9476 --
9477 l_step := 35;
9478 if g_debug then
9479 hr_utility.set_location(l_proc,3456);
9480 end if;
9481 -- rate is having non recurring
9482 for l_prv in c_prv3 (p_per_in_ler_id) loop
9483 --check whether rate is non-recurring
9484 open c_abr(l_prv.acty_base_rt_id);
9485 fetch c_abr into l_abr;
9486 close c_abr;
9487 --
9488 if l_abr.processing_type = 'N' or
9489 l_abr.rcrrg_cd = 'ONCE' then
9490 null;
9491 else
9492 exit;
9493 end if;
9494 if g_debug then
9495 hr_utility.set_location('delete prtt',3459);
9496 end if;
9497 update ben_enrt_rt
9498 set prtt_rt_val_id = null
9499 where enrt_rt_id = l_prv.enrt_rt_id;
9500 --
9501 ben_prtt_rt_val_api.delete_prtt_rt_val
9502 (P_VALIDATE => FALSE
9503 ,P_PRTT_RT_VAL_ID => l_prv.prtt_rt_val_id
9504 ,P_OBJECT_VERSION_NUMBER => l_prv.object_version_number
9505 ,P_EFFECTIVE_DATE => l_eff_dt
9506 ,p_person_id => l_pen.person_id
9507 ,p_business_group_id => p_business_group_id
9508 );
9509 end loop;
9510 For l_prv in c_prv2 loop
9511 if g_debug then
9512 hr_utility.set_location(l_proc,3457);
9513 end if;
9514 l_prv_count := l_prv_count + 1;
9515 ben_prtt_rt_val_api.update_prtt_rt_val
9516 (P_VALIDATE => FALSE
9517 ,P_PRTT_RT_VAL_ID => l_prv.prtt_rt_val_id
9518 ,P_RT_END_DT => l_rt_end_dt
9519 ,p_person_id => l_pen.person_id
9520 --Bug#2625060 - for converted data, null is passed for activity base rt id
9521 -- ,p_acty_base_rt_id => l_prv.acty_base_rt_id
9522 ,p_input_value_id => l_prv.input_value_id
9523 ,p_element_type_id => l_prv.element_type_id
9524 ,p_ended_per_in_ler_id => p_per_in_ler_id
9525 ,p_business_group_id => p_business_group_id
9526 ,p_prtt_rt_val_stat_cd => 'BCKDT'
9527 ,P_OBJECT_VERSION_NUMBER => l_prv.object_version_number
9528 ,P_EFFECTIVE_DATE => p_effective_date
9529 );
9530 if g_debug then
9531 hr_utility.set_location(l_proc,3458);
9532 end if;
9533 end loop;
9534 --
9535 -- Adjust overlapping rates . Bug 5391554
9536 --
9537 -- basu
9538 hr_utility.set_location('p_per_in_ler_id '||p_per_in_ler_id,44333);
9539 --
9540 open c_get_pgm_extra_info(l_pen.pgm_id);
9541 fetch c_get_pgm_extra_info into l_adjust;
9542 if c_get_pgm_extra_info%found then
9543 if l_adjust = 'Y' then
9544 for l_prv5 in c_prv5(l_rt_end_dt) loop
9545 --
9546 if g_debug then
9547 hr_utility.set_location('Adjusting rate '||l_rt_end_dt,111);
9548 end if;
9549 ben_prtt_rt_val_api.update_prtt_rt_val
9550 (P_VALIDATE => FALSE
9551 ,P_PRTT_RT_VAL_ID => l_prv5.prtt_rt_val_id
9552 ,P_RT_END_DT => l_rt_end_dt
9553 ,p_person_id => l_pen.person_id
9554 ,p_input_value_id => l_prv5.input_value_id
9555 ,p_element_type_id => l_prv5.element_type_id
9556 ,p_ended_per_in_ler_id => p_per_in_ler_id
9557 ,p_business_group_id => p_business_group_id
9558 ,P_OBJECT_VERSION_NUMBER => l_prv5.object_version_number
9559 ,P_EFFECTIVE_DATE => p_effective_date
9560 );
9561 end loop;
9562 end if;
9563 end if;
9564 close c_get_pgm_extra_info;
9565
9566 -- Bug#2038814 - cursor above updates only the last prtt_rt_val and if there
9567 -- any future dated prtt_rt_val, rows with rt end date greater than the calc
9568 --- ulated rt end
9569 -- date needs to be updated
9570 -- Bug 2739965
9571 if l_benmngle_parm_rec.mode_cd = 'S' or l_ler_typ_cd = 'SCHEDDU' then
9572 if g_debug then
9573 hr_utility.set_location('ben mngle mode',111);
9574 hr_utility.set_location('rate end date'||l_rt_end_dt,111);
9575 end if;
9576 --
9577 For l_prv4 in c_prv4 (l_rt_end_dt) loop
9578 -- 2739965 In case of unrestricted enrollment, this happens only when there are future rates
9579 -- and they got deleted as part of c_prv2 process above. Lets us throw this error
9580 -- here warning the user about the deletion of the future rate.
9581 --
9582 if fnd_global.conc_request_id in ( 0,-1) then
9583 -- Issue a warning to the user. These will display on the enrt forms.
9584 ben_warnings.load_warning
9585 (p_application_short_name => 'BEN',
9586 p_message_name => 'BEN_93369_DEL_FUT_RATE',
9587 p_parma => fnd_date.date_to_chardate( l_prv4.rt_end_dt+1 ),
9588 p_parmb => l_pen.pl_name || ' '||l_pen.opt_name,
9589 p_person_id => l_pen.person_id);
9590 end if;
9591 --
9592 ben_prtt_rt_val_api.update_prtt_rt_val
9593 (P_VALIDATE => FALSE
9594 ,P_PRTT_RT_VAL_ID => l_prv4.prtt_rt_val_id
9595 ,P_RT_END_DT => l_rt_end_dt
9596 ,p_person_id => l_pen.person_id
9597 --Bug#2625060 - for converted data, null is passed for activity base rt id
9598 -- ,p_acty_base_rt_id => l_prv4.acty_base_rt_id
9599 ,p_input_value_id => l_prv4.input_value_id
9600 ,p_element_type_id => l_prv4.element_type_id
9601 ,p_ended_per_in_ler_id => p_per_in_ler_id
9602 ,p_business_group_id => p_business_group_id
9603 ,p_prtt_rt_val_stat_cd => 'BCKDT' -- Bug 4739922: Backout the Result/ (do not VOIDD).
9604 ,P_OBJECT_VERSION_NUMBER => l_prv4.object_version_number
9605 ,P_EFFECTIVE_DATE => p_effective_date
9606 );
9607 end loop;
9608 end if;
9609 if g_debug then
9610 hr_utility.set_location(l_proc,3459);
9611 end if;
9612 --
9613 -- Get dependent coverage End date. If Participant coverage end date
9614 -- is greater than dependent coverage end date, then use participant.
9615 --
9616 l_step := 40;
9617 --
9618 calc_dpnt_cvg_dt
9619 (p_calc_end_dt => TRUE
9620 ,P_calc_strt_dt => FALSE
9621 ,p_per_in_ler_id => l_pen.per_in_ler_id
9622 ,P_person_id => l_pen.person_id
9623 ,p_pgm_id => l_pen.pgm_id
9624 ,p_pl_id => l_pen.pl_id
9625 ,p_oipl_id => l_pen.oipl_id
9626 ,p_ptip_id => l_pen.ptip_id
9627 ,p_ler_id => l_pen.ler_id
9628 ,P_BUSINESS_GROUP_ID => p_business_group_id
9629 ,P_EFFECTIVE_DATE => p_effective_date
9630 ,P_RETURNED_END_DT => l_dpnt_cvg_end_dt
9631 ,P_RETURNED_STRT_DT => l_dump_date
9632 ,p_enrt_cvg_end_dt => l_enrt_cvg_end_dt
9633 );
9634 --
9635 l_step := 90;
9636 --
9637 -- bug 3327224
9638 /*
9639 If l_dpnt_cvg_end_dt is not NULL then
9640 l_dpnt_cvg_thru_dt := least(l_enrt_cvg_end_dt, l_dpnt_cvg_end_dt);
9641 End if;
9642 */
9643 l_dpnt_cvg_thru_dt := l_dpnt_cvg_end_dt;
9644 --
9645 -- Unhook dependent rows
9646 --
9647 l_step := 110;
9648 unhook_dpnt
9649 (p_validate => FALSE
9650 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
9651 ,p_per_in_ler_id => l_pen.per_in_ler_id
9652 ,p_cvg_thru_dt => l_dpnt_cvg_thru_dt
9653 ,p_business_group_id => p_business_group_id
9654 ,p_effective_date => p_effective_date
9655 ,p_datetrack_mode => p_datetrack_mode
9656 ,p_called_from => p_source
9657 );
9658 unhook_bnf
9659 (p_validate => FALSE
9660 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
9661 ,p_per_in_ler_id => l_pen.per_in_ler_id
9662 ,p_dsgn_thru_dt => l_enrt_cvg_end_dt
9663 ,p_business_group_id => p_business_group_id
9664 ,p_effective_date => p_effective_date
9665 ,p_datetrack_mode => p_datetrack_mode
9666 );
9667 --
9668 l_step := 120;
9669 --
9670 get_ben_pen_upd_dt_mode
9671 (p_effective_date => p_effective_date
9672 ,p_base_key_value => p_prtt_enrt_rslt_id
9673 ,P_desired_datetrack_mode => p_datetrack_mode
9674 ,P_datetrack_allow => l_datetrack_mode
9675 ,p_ler_typ_cd => l_ler_typ_cd -- Bug 2739965
9676 );
9677 --
9678 l_step := 125;
9679 if g_debug then
9680 hr_utility.set_location('enrt_cvg_end_dt='||l_enrt_cvg_end_dt,19);
9681 end if;
9682 ben_prtt_enrt_result_api.update_prtt_enrt_result
9683 (p_validate => FALSE
9684 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
9685 ,p_effective_start_date => p_effective_start_date
9686 ,p_effective_end_date => p_effective_end_date
9687 ,p_per_in_ler_id => l_pen.per_in_ler_id
9688 ,p_ler_id => l_pen.ler_id
9689 ,p_enrt_cvg_thru_dt => l_enrt_cvg_end_dt
9690 ,p_object_version_number => l_pen.pen_ovn
9691 ,p_prtt_enrt_rslt_stat_cd => 'BCKDT' -- Bug 4739922: Backout the Result/ (do not VOIDD).
9692 ,p_effective_date => p_effective_date
9693 ,p_datetrack_mode => l_datetrack_mode
9694 ,p_multi_row_validate => p_multi_row_validate
9695 ,p_business_group_id => p_business_group_id
9696 );
9697 --
9698 l_step := 126;
9699 --
9700 if l_pen.pgm_id is not null then
9701 ben_provider_pools.remove_bnft_prvdd_ldgr
9702 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
9703 ,p_effective_date => p_effective_date
9704 ,p_business_group_id => p_business_group_id
9705 ,p_validate => FALSE
9706 ,p_datetrack_mode => hr_api.g_delete
9707 );
9708 end if;
9709 --
9710 --- # 2546259
9711 Else
9712 --
9713 -- Bug 2093859 : When coverage is not started just zap all the data.
9714 --
9715 --Bug#:6641853
9716 OPEN c_get_correction_info (p_prtt_enrt_rslt_id,
9717 l_pen.effective_start_date,
9718 l_pen.per_in_ler_id,
9719 l_pen.person_id--12566240
9720 );
9721 FETCH c_get_correction_info INTO l_get_correction_info;
9722 CLOSE c_get_correction_info;
9723 IF l_get_correction_info.place_holder='X' THEN
9724 l_prtt_enrt_rslt_Stat_cd:=NULL;
9725 l_datetrack_mode:='CORRECTION';
9726 ELSE
9727 l_datetrack_mode := hr_api.g_zap;
9728 END IF;
9729 --
9730 if p_source = 'beninelg' then
9731 l_datetrack_mode := hr_api.g_delete;
9732 elsif p_source is null or --CFW
9733 p_source = 'benuneai' then
9734 l_datetrack_mode := p_datetrack_mode;
9735 end if;
9736 if g_debug then
9737 hr_utility.set_location('l_datetrack_mode='||l_datetrack_mode,20);
9738 end if;
9739 l_step := 140;
9740 --
9741 -- Added call the below code for 3797391 to get all dates properly
9742 --
9743 if g_debug then
9744 hr_utility.set_location('calc_dpnt_cvg_dt ', 100);
9745 end if;
9746 --
9747 calc_dpnt_cvg_dt
9748 (p_calc_end_dt => TRUE
9749 ,P_calc_strt_dt => FALSE
9750 ,p_per_in_ler_id => l_pen.per_in_ler_id
9751 ,P_person_id => l_pen.person_id
9752 ,p_pgm_id => l_pen.pgm_id
9753 ,p_pl_id => l_pen.pl_id
9754 ,p_oipl_id => l_pen.oipl_id
9755 ,p_ptip_id => l_pen.ptip_id
9756 ,p_ler_id => l_pen.ler_id
9757 ,P_BUSINESS_GROUP_ID => p_business_group_id
9758 ,P_EFFECTIVE_DATE => p_effective_date
9759 ,P_RETURNED_END_DT => l_dpnt_cvg_end_dt
9760 ,P_RETURNED_STRT_DT => l_dump_date
9761 ,p_enrt_cvg_end_dt => l_enrt_cvg_end_dt
9762 );
9763 --
9764 l_step := 40;
9765 --
9766 l_dpnt_cvg_thru_dt := l_dpnt_cvg_end_dt;
9767 --
9768 -- bug 3797391
9769 --
9770 unhook_bnf
9771 (p_validate => FALSE
9772 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
9773 ,p_per_in_ler_id => l_pen.per_in_ler_id
9774 ,p_dsgn_thru_dt => l_enrt_cvg_end_dt
9775 ,p_business_group_id => p_business_group_id
9776 ,p_effective_date => l_eff_dt -- Bug 2093859 p_effective_date
9777 ,p_datetrack_mode => l_datetrack_mode
9778 ,p_rslt_delete_flag => TRUE
9779 );
9780
9781 hr_utility.set_location('p_prtt_enrt_rslt_id ='||p_prtt_enrt_rslt_id,20);
9782 hr_utility.set_location('l_pen.per_in_ler_id ='||l_pen.per_in_ler_id,20);
9783 hr_utility.set_location('l_dpnt_cvg_thru_dt ='||to_char(l_dpnt_cvg_thru_dt),20);
9784 hr_utility.set_location('l_eff_dt ='||to_char(l_eff_dt),20);
9785 hr_utility.set_location('p_source ='||p_source,20);
9786 --
9787 l_step := 150;
9788 --
9789 unhook_dpnt
9790 (p_validate => FALSE
9791 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
9792 ,p_per_in_ler_id => l_pen.per_in_ler_id
9793 ,p_cvg_thru_dt => l_dpnt_cvg_thru_dt
9794 ,p_business_group_id => p_business_group_id
9795 ,p_effective_date => l_eff_dt
9796 ,p_datetrack_mode => l_datetrack_mode
9797 ,p_rslt_delete_flag => TRUE
9798 ,p_called_from => p_source );
9799 --
9800 l_step := 160;
9801 --
9802 if (l_pen.elig_per_elctbl_chc_id is not NULL) then
9803 -- Bug 2627078
9804 -- if called from delete_enrollment then
9805 -- we need to get the current_enrollment result id
9806 -- populated when the interim is getting deleted.
9807 --
9808 l_current_result_id := null ;
9809 --
9810 if p_source = 'delete_enrollment' then
9811 --
9812 open c_curr_rslt (l_pen.person_id, l_pen.pgm_id,
9813 l_pen.pl_id, l_pen.oipl_id, p_per_in_ler_id ) ;
9814 fetch c_curr_rslt into l_current_result_id ;
9815 close c_curr_rslt ;
9816 --
9817 end if ;
9818 --
9819 ben_ELIG_PER_ELC_CHC_api.update_ELIG_PER_ELC_CHC
9820 (p_validate => FALSE
9821 ,p_elig_per_elctbl_chc_id => l_pen.elig_per_elctbl_chc_id
9822 ,p_prtt_enrt_rslt_id => l_current_result_id -- NULL
9823 ,p_object_version_number => l_pen.epe_ovn
9824 ,p_effective_date => l_eff_dt
9825 );
9826 end if;
9827 --
9828 l_step := 136;
9829 --
9830
9831 /* Added code for Bug 7561395*/
9832 hr_utility.set_location('delete_enrollment ',500);
9833 hr_utility.set_location('Unhook dependent rows ', 500);
9834 hr_utility.set_location('p_prtt_enrt_rslt_ids '||p_prtt_enrt_rslt_id, 504);
9835 hr_utility.set_location('l_pen.pen_per_in_ler_id '||l_pen.pen_per_in_ler_id, 504);
9836 hr_utility.set_location('l_pen.per_in_ler_id '||l_pen.per_in_ler_id, 504);
9837 hr_utility.set_location('p_pen_per_in_ler_id '||p_per_in_ler_id, 504);
9838 hr_utility.set_location('g_new_prtt_enrt_rslt_id '||g_new_prtt_enrt_rslt_id, 504);
9839
9840 /* Bug 8669907:
9841 if(action item exists for the pen_id ) do not create
9842 else
9843 if(Participant has selected diff comp obj) do not create
9844 else if(not enter value at enrollment) perform validations before creating action items
9845 else perform validations before creating action items
9846 Set the l_create_flag to 'Y' if action item has to be created */
9847
9848 open c_chk_act_item_exits(g_new_prtt_enrt_rslt_id);
9849 fetch c_chk_act_item_exits into l_dummy1;
9850 if(c_chk_act_item_exits%found) then
9851 hr_utility.set_location('No Create 1',500);
9852 close c_chk_act_item_exits;
9853 l_create_flag := 'N';
9854 else
9855 close c_chk_act_item_exits;
9856 open c_chk_same_comp_obj(g_new_prtt_enrt_rslt_id,p_prtt_enrt_rslt_id,p_per_in_ler_id);
9857 fetch c_chk_same_comp_obj into l_create_flag;
9858 if(c_chk_same_comp_obj%notfound) then
9859 hr_utility.set_location('No Create 2',500);
9860 close c_chk_same_comp_obj;
9861 l_create_flag := 'N';
9862 else
9863 close c_chk_same_comp_obj;
9864 open c_bnft_amt(g_new_prtt_enrt_rslt_id,p_per_in_ler_id);
9865 fetch c_bnft_amt into l_bnft ;
9866 close c_bnft_amt;
9867 if(l_bnft.entr_val_at_enrt_flag = 'N') then
9868 if(l_bnft.cvg_mlt_cd = 'FLRNG') then
9869 if(l_bnft.bnft_amt > l_bnft.mx_val) then
9870 hr_utility.set_location('FLRNG Create ',500);
9871 l_create_flag := 'Y';
9872 else
9873 hr_utility.set_location('FLRNG No Create',500);
9874 l_create_flag := 'N';
9875 end if;
9876 else
9877 hr_utility.set_location('Create 1',500);
9878 l_create_flag := 'Y';
9879 end if;
9880 else
9881 if(l_bnft.mx_wout_ctfn_val is not null and l_bnft.bnft_amt > l_bnft.mx_wout_ctfn_val ) then
9882 hr_utility.set_location('Create 2',500);
9883 l_create_flag := 'Y';
9884 elsif(l_bnft.mx_wout_ctfn_val is not null and l_bnft.bnft_amt <= l_bnft.mx_wout_ctfn_val ) then
9885 hr_utility.set_location('No Create 4',500);
9886 l_create_flag := 'N';
9887 else
9888 hr_utility.set_location('Create 3',500);
9889 l_create_flag := 'Y';
9890 end if;
9891 end if;
9892 end if;
9893 end if;
9894 hr_utility.set_location('l_create_flag '||l_create_flag,500);
9895
9896 /*open c_chk_same_comp_obj(g_new_prtt_enrt_rslt_id,p_prtt_enrt_rslt_id,p_per_in_ler_id);
9897 fetch c_chk_same_comp_obj into l_create_flag;
9898 if(c_chk_same_comp_obj%notfound) then
9899 l_create_flag := 'N';
9900 end if;
9901 close c_chk_same_comp_obj;*/
9902
9903 open c_chk_same_event(g_new_prtt_enrt_rslt_id);
9904 fetch c_chk_same_event into l_nper_in_ler_id ;
9905 close c_chk_same_event;
9906 open c_chk_same_event(p_prtt_enrt_rslt_id);
9907 fetch c_chk_same_event into l_oper_in_ler_id ;
9908 close c_chk_same_event;
9909 hr_utility.set_location('Old per_in_ler '||l_oper_in_ler_id, 500);
9910 hr_utility.set_location('new per_in_ler '||l_nper_in_ler_id, 500);
9911 open c_chk_act_item_exits(p_prtt_enrt_rslt_id);
9912 fetch c_chk_act_item_exits into l_dummy1;
9913 if(c_chk_act_item_exits%found) then
9914 l_act_flag := true;
9915 hr_utility.set_location('In loop2 false',500);
9916 else
9917 l_act_flag := false;
9918 hr_utility.set_location('In loop2 true',500);
9919 end if;
9920 close c_chk_act_item_exits;
9921 if(l_nper_in_ler_id = l_oper_in_ler_id and l_act_flag) then
9922 open c_get_actn_items;
9923 fetch c_get_actn_items BULK COLLECT into l_act_items;
9924 hr_utility.set_location('In loop1',500);
9925 if(l_act_items.count > 0) then
9926 l_act_flag := true;
9927 hr_utility.set_location('In loop10 '||l_act_items.count,500);
9928 else
9929 l_act_flag := false;
9930 hr_utility.set_location('In loop11',500);
9931 end if;
9932 close c_get_actn_items;
9933
9934
9935 open c_get_ctfn;
9936 fetch c_get_ctfn BULK COLLECT into l_ctfn;
9937 if(l_ctfn.count > 0) then
9938 l_ctfn_flag := true;
9939 end if;
9940 close c_get_ctfn;
9941
9942 hr_utility.set_location('Remving action items',500);
9943 remove_cert_action_items
9944 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
9945 ,p_effective_date => l_eff_dt
9946 ,p_business_group_id => p_business_group_id
9947 ,p_validate => FALSE
9948 ,p_datetrack_mode => l_datetrack_mode
9949 ,p_source => p_source
9950 ,p_per_in_ler_id => l_pen.pen_per_in_ler_id
9951 ,p_per_in_ler_ended_id=> l_pen.per_in_ler_id
9952 );
9953
9954 if(l_act_flag and l_create_flag = 'Y' ) then
9955 hr_utility.set_location('creating action items',500);
9956 for i IN l_act_items.FIRST..l_act_items.LAST loop
9957 ben_PRTT_ENRT_ACTN_api.create_PRTT_ENRT_ACTN
9958 (p_validate => false
9959 ,p_effective_date => p_effective_date
9960 ,p_cmpltd_dt => l_act_items(i).cmpltd_dt
9961 ,p_due_dt => l_act_items(i).due_dt
9962 ,p_rqd_flag => l_act_items(i).rqd_flag
9963 ,p_prtt_enrt_rslt_id => g_new_prtt_enrt_rslt_id
9964 ,p_per_in_ler_id => p_per_in_ler_id
9965 ,p_rslt_object_version_number => l_rslt_object_version_number
9966 ,p_actn_typ_id => l_act_items(i).actn_typ_id
9967 ,p_elig_cvrd_dpnt_id => l_act_items(i).elig_cvrd_dpnt_id
9968 ,p_pl_bnf_id => l_act_items(i).pl_bnf_id
9969 ,p_business_group_id => l_act_items(i).business_group_id
9970 ,p_pea_attribute_category => l_act_items(i).pea_attribute_category
9971 ,p_pea_attribute1 => l_act_items(i).pea_attribute1
9972 ,p_pea_attribute2 => l_act_items(i).pea_attribute2
9973 ,p_pea_attribute3 => l_act_items(i).pea_attribute3
9974 ,p_pea_attribute4 => l_act_items(i).pea_attribute4
9975 ,p_pea_attribute5 => l_act_items(i).pea_attribute5
9976 ,p_pea_attribute6 => l_act_items(i).pea_attribute6
9977 ,p_pea_attribute7 => l_act_items(i).pea_attribute7
9978 ,p_pea_attribute8 => l_act_items(i).pea_attribute8
9979 ,p_pea_attribute9 => l_act_items(i).pea_attribute9
9980 ,p_pea_attribute10 => l_act_items(i).pea_attribute10
9981 ,p_pea_attribute11 => l_act_items(i).pea_attribute11
9982 ,p_pea_attribute12 => l_act_items(i).pea_attribute12
9983 ,p_pea_attribute13 => l_act_items(i).pea_attribute13
9984 ,p_pea_attribute14 => l_act_items(i).pea_attribute14
9985 ,p_pea_attribute15 => l_act_items(i).pea_attribute15
9986 ,p_pea_attribute16 => l_act_items(i).pea_attribute16
9987 ,p_pea_attribute17 => l_act_items(i).pea_attribute17
9988 ,p_pea_attribute18 => l_act_items(i).pea_attribute18
9989 ,p_pea_attribute19 => l_act_items(i).pea_attribute19
9990 ,p_pea_attribute20 => l_act_items(i).pea_attribute20
9991 ,p_pea_attribute21 => l_act_items(i).pea_attribute21
9992 ,p_pea_attribute22 => l_act_items(i).pea_attribute22
9993 ,p_pea_attribute23 => l_act_items(i).pea_attribute23
9994 ,p_pea_attribute24 => l_act_items(i).pea_attribute24
9995 ,p_pea_attribute25 => l_act_items(i).pea_attribute25
9996 ,p_pea_attribute26 => l_act_items(i).pea_attribute26
9997 ,p_pea_attribute27 => l_act_items(i).pea_attribute27
9998 ,p_pea_attribute28 => l_act_items(i).pea_attribute28
9999 ,p_pea_attribute29 => l_act_items(i).pea_attribute29
10000 ,p_pea_attribute30 => l_act_items(i).pea_attribute30
10001 ,p_object_version_number => l_actn_object_version_number
10002 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
10003 ,p_effective_start_date => l_actn_start_date
10004 ,p_effective_end_date => l_actn_end_date
10005 ,p_gnrt_cm => false -- Bug 9256641 : Do not generate communications
10006 );
10007 end loop;
10008 hr_utility.set_location('created action items',500);
10009 end if;
10010
10011 hr_utility.set_location('before creating cert',500);
10012 if(l_ctfn_flag and l_create_flag = 'Y' ) then
10013 hr_utility.set_location('creating certifications ',500);
10014 for j IN l_ctfn.FIRST..l_ctfn.LAST loop
10015 hr_utility.set_location('looping cert ',500);
10016 ben_PRTT_ENRT_CTFN_PRVDD_api.create_PRTT_ENRT_CTFN_PRVDD
10017 (p_validate => false
10018 ,p_prtt_enrt_ctfn_prvdd_id => l_prtt_enrt_ctfn_prvdd_id
10019 ,p_effective_start_date => l_ctfn_start_date
10020 ,p_effective_end_date => l_ctfn_end_date
10021 ,p_enrt_ctfn_rqd_flag => l_ctfn(j).enrt_ctfn_rqd_flag
10022 ,p_enrt_ctfn_typ_cd => l_ctfn(j).enrt_ctfn_typ_cd
10023 ,p_enrt_ctfn_recd_dt => l_ctfn(j).enrt_ctfn_recd_dt
10024 ,p_enrt_ctfn_dnd_dt => l_ctfn(j).enrt_ctfn_dnd_dt
10025 ,p_enrt_r_bnft_ctfn_cd => l_ctfn(j).enrt_r_bnft_ctfn_cd
10026 ,p_prtt_enrt_rslt_id => g_new_prtt_enrt_rslt_id
10027 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
10028 ,p_business_group_id => l_ctfn(j).business_group_id
10029 ,p_pcs_attribute_category => l_ctfn(j).pcs_attribute_category
10030 ,p_pcs_attribute1 => l_ctfn(j).pcs_attribute1
10031 ,p_pcs_attribute2 => l_ctfn(j).pcs_attribute2
10032 ,p_pcs_attribute3 => l_ctfn(j).pcs_attribute3
10033 ,p_pcs_attribute4 => l_ctfn(j).pcs_attribute4
10034 ,p_pcs_attribute5 => l_ctfn(j).pcs_attribute5
10035 ,p_pcs_attribute6 => l_ctfn(j).pcs_attribute6
10036 ,p_pcs_attribute7 => l_ctfn(j).pcs_attribute7
10037 ,p_pcs_attribute8 => l_ctfn(j).pcs_attribute8
10038 ,p_pcs_attribute9 => l_ctfn(j).pcs_attribute9
10039 ,p_pcs_attribute10 => l_ctfn(j).pcs_attribute10
10040 ,p_pcs_attribute11 => l_ctfn(j).pcs_attribute11
10041 ,p_pcs_attribute12 => l_ctfn(j).pcs_attribute12
10042 ,p_pcs_attribute13=> l_ctfn(j).pcs_attribute13
10043 ,p_pcs_attribute14 => l_ctfn(j).pcs_attribute14
10044 ,p_pcs_attribute15 => l_ctfn(j).pcs_attribute15
10045 ,p_pcs_attribute16=> l_ctfn(j).pcs_attribute16
10046 ,p_pcs_attribute17 => l_ctfn(j).pcs_attribute17
10047 ,p_pcs_attribute18 => l_ctfn(j).pcs_attribute18
10048 ,p_pcs_attribute19 => l_ctfn(j).pcs_attribute19
10049 ,p_pcs_attribute20 => l_ctfn(j).pcs_attribute20
10050 ,p_pcs_attribute21=> l_ctfn(j).pcs_attribute21
10051 ,p_pcs_attribute22 => l_ctfn(j).pcs_attribute22
10052 ,p_pcs_attribute23 => l_ctfn(j).pcs_attribute23
10053 ,p_pcs_attribute24=>l_ctfn(j).pcs_attribute24
10054 ,p_pcs_attribute25 =>l_ctfn(j).pcs_attribute25
10055 ,p_pcs_attribute26 => l_ctfn(j).pcs_attribute26
10056 ,p_pcs_attribute27 => l_ctfn(j).pcs_attribute27
10057 ,p_pcs_attribute28 => l_ctfn(j).pcs_attribute28
10058 ,p_pcs_attribute29 => l_ctfn(j).pcs_attribute29
10059 ,p_pcs_attribute30 => l_ctfn(j).pcs_attribute30
10060 ,p_object_version_number => l_ctfn_object_version_number
10061 ,p_effective_date => p_effective_date
10062 );
10063 end loop;
10064 end if;
10065 g_new_prtt_enrt_rslt_id := -1;
10066 else
10067 remove_cert_action_items
10068 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
10069 ,p_effective_date => l_eff_dt
10070 ,p_business_group_id => p_business_group_id
10071 ,p_validate => FALSE
10072 ,p_datetrack_mode => l_datetrack_mode
10073 ,p_source => p_source
10074 ,p_per_in_ler_id => l_pen.pen_per_in_ler_id
10075 ,p_per_in_ler_ended_id=> l_pen.per_in_ler_id
10076 );
10077 end if;
10078
10079 /* Commented code for Bug 7561395
10080 remove_cert_action_items
10081 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
10082 ,p_effective_date => l_eff_dt
10083 ,p_business_group_id => p_business_group_id
10084 ,p_validate => FALSE
10085 ,p_datetrack_mode => l_datetrack_mode
10086 ,p_source => p_source
10087 ,p_per_in_ler_id => l_pen.pen_per_in_ler_id
10088 ,p_per_in_ler_ended_id=> l_pen.per_in_ler_id
10089 ); */
10090
10091 /* Ended code for Bug 7561395 */
10092 --
10093 l_step := 137;
10094 --
10095 if l_pen.pgm_id is not null then
10096 ben_provider_pools.remove_bnft_prvdd_ldgr
10097 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
10098 ,p_effective_date => l_eff_dt
10099 ,p_business_group_id => p_business_group_id
10100 ,p_validate => FALSE
10101 ,p_datetrack_mode => l_datetrack_mode
10102 );
10103 end if;
10104 --
10105 -- Remove all participant Rate Values rows
10106 --
10107 l_step := 170;
10108 --
10109 -- Bug 4136432
10110 for l_prv in c_prvdel
10111 loop
10112 --
10113 hr_utility.set_location('p_prtt_enrt_rslt_id ='||p_prtt_enrt_rslt_id,20);
10114 hr_utility.set_location('l_eff_dt ='||to_char(l_eff_dt),20);
10115 hr_utility.set_location('l_prv.prtt_rt_val_id ='||l_prv.prtt_rt_val_id,20);
10116 hr_utility.set_location('l_pen.person_id ='|| l_pen.person_id,20);
10117 hr_utility.set_location('l_prv.enrt_rt_id ='||l_prv.enrt_rt_id,20);
10118 --
10119 -- Bug 5626835 : For Enter Value At Enrollment cases, we need to just BCKDT PRV, so that
10120 -- during reinstatement of corresponding PEN, we can get the actual PRV
10121 -- and hence the previously selected RT_VAL
10122 -- Note : Probably we need this fix for all cases, but I made change for Enter Value At
10123 -- Enrollment case only. Right now for other cases, while reinstating we create records
10124 -- from BEPENAPI.MULTI_ROWS_EDIT >> BEN_DET_ENRT_RATES using ECR
10125 --
10126 IF l_prv.entr_val_at_enrt_flag = 'Y'
10127 THEN
10128 --
10129 -- Bug 6471236
10130 /* void_rate
10131 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id,
10132 p_business_group_id => p_business_group_id,
10133 p_person_id => l_pen.person_id,
10134 p_per_in_ler_id => p_per_in_ler_id,
10135 p_effective_date => p_effective_date
10136 ); */
10137 if l_datetrack_mode='CORRECTION' then
10138 l_temp_date:=l_enrt_cvg_end_dt;
10139 l_temp_stat_cd:=NULL;
10140 --Bug#:6641853
10141 else
10142 l_temp_date:=l_prv.rt_strt_dt - 1;
10143 l_temp_stat_cd:='VOIDD';
10144 end if;
10145 ben_prtt_rt_val_api.update_prtt_rt_val
10146 (P_VALIDATE => FALSE
10147 ,P_PRTT_RT_VAL_ID => l_prv.prtt_rt_val_id
10148 ,P_RT_END_DT => l_temp_date
10149 ,p_person_id => l_pen.person_id
10150 ,p_input_value_id => l_prv.input_value_id
10151 ,p_element_type_id => l_prv.element_type_id
10152 ,p_ended_per_in_ler_id => p_per_in_ler_id
10153 ,p_prtt_rt_val_stat_cd => l_temp_stat_cd
10154 ,p_business_group_id => p_business_group_id
10155 ,P_OBJECT_VERSION_NUMBER => l_prv.object_version_number
10156 ,P_EFFECTIVE_DATE => p_effective_date
10157 );
10158 l_temp_date:=NULL;
10159 -- Bug 6471236
10160 --
10161 ELSE
10162 --
10163 if l_datetrack_mode='CORRECTION' then
10164
10165
10166 ben_prtt_rt_val_api.update_prtt_rt_val
10167 (P_VALIDATE => FALSE
10168 ,P_PRTT_RT_VAL_ID => l_prv.prtt_rt_val_id
10169 ,P_RT_END_DT => l_enrt_cvg_end_dt
10170 ,p_person_id => l_pen.person_id
10171 ,p_input_value_id => l_prv.input_value_id
10172 ,p_element_type_id => l_prv.element_type_id
10173 ,p_ended_per_in_ler_id => p_per_in_ler_id
10174 -- ,p_prtt_rt_val_stat_cd => l_temp_stat_cd
10175 ,p_business_group_id => p_business_group_id
10176 ,P_OBJECT_VERSION_NUMBER => l_prv.object_version_number
10177 ,P_EFFECTIVE_DATE => p_effective_date
10178 );
10179
10180 ELSE
10181 --Bug#:6641853
10182 hr_utility.set_location ('stee delete rate '||l_prv.prtt_rt_val_id,10);
10183 --
10184 -- bug 12583091
10185 -- If the rate was for an enrollment that was previously
10186 -- suspended and the prtt_rt_val rt start date has been updated
10187 -- in the unsuspend process, re-instate the original rt start date.
10188 --
10189 hr_utility.set_location('l_prv.prtt_rt_val_id:'|| l_prv.prtt_rt_val_id, 10);
10190 open c_enrt_rt(l_prv.prtt_rt_val_id);
10191 fetch c_enrt_rt into l_enrt_rt;
10192 if c_enrt_rt%found then
10193 close c_enrt_rt;
10194 hr_utility.set_location('l_enrt_rt.elig_per_elctbl_chc_id '|| l_enrt_rt.enb_per_elctbl_chc_id, 10);
10195 --
10196 ben_determine_date.rate_and_coverage_dates
10197 (p_which_dates_cd => 'R'
10198 ,p_business_group_id => p_business_group_id
10199 ,p_elig_per_elctbl_chc_id => nvl(l_enrt_rt.elig_per_elctbl_chc_id,
10200 l_enrt_rt.enb_per_elctbl_chc_id)
10201 ,p_enrt_cvg_strt_dt => l_dummy_date
10202 ,p_enrt_cvg_strt_dt_cd => l_dummy_varchar
10203 ,p_enrt_cvg_strt_dt_rl => l_dummy_number
10204 ,p_rt_strt_dt => l_prv_rt_strt_dt
10205 ,p_rt_strt_dt_cd => l_dummy_varchar
10206 ,p_rt_strt_dt_rl => l_dummy_number
10207 ,p_enrt_cvg_end_dt => l_dummy_date
10208 ,p_enrt_cvg_end_dt_cd => l_dummy_varchar
10209 ,p_enrt_cvg_end_dt_rl => l_dummy_number
10210 ,p_rt_end_dt => l_dummy_date
10211 ,p_rt_end_dt_cd => l_dummy_varchar
10212 ,p_rt_end_dt_rl => l_dummy_number
10213 ,p_acty_base_rt_id => l_enrt_rt.acty_base_rt_id
10214 ,p_effective_date => p_effective_date
10215 );
10216 hr_utility.set_location('l_prv_rt_strt_dt:'|| l_prv_rt_strt_dt, 10);
10217 hr_utility.set_location('l_prv.rt_strt_dt:'|| l_prv.rt_strt_dt, 10);
10218 --
10219 if l_prv_rt_strt_dt <> l_prv.rt_strt_dt then
10220 ben_enrollment_rate_api.update_enrollment_rate
10221 (p_enrt_rt_id => l_enrt_rt.enrt_rt_id
10222 ,p_rt_strt_dt => l_prv_rt_strt_dt
10223 ,p_object_version_number => l_enrt_rt.object_version_number
10224 ,p_effective_date => p_effective_date
10225 );
10226 end if;
10227 else
10228 close c_enrt_rt; -- 16068560
10229 end if;
10230 --
10231 -- end 12583091
10232 --
10233 ben_prtt_rt_val_api.delete_prtt_rt_val
10234 (P_VALIDATE => FALSE
10235 ,P_PRTT_RT_VAL_ID => l_prv.prtt_rt_val_id
10236 ,P_ENRT_RT_ID => l_prv.enrt_rt_id
10237 ,P_OBJECT_VERSION_NUMBER => l_prv.object_version_number
10238 ,P_EFFECTIVE_DATE => l_eff_dt
10239 ,p_person_id => l_pen.person_id
10240 ,p_business_group_id => p_business_group_id
10241 );
10242 END IF;
10243 --
10244 END IF;
10245 --
10246 end loop;
10247 --
10248 -- Remove PCP records
10249 --
10250 for l_pcp in c_pcp(l_eff_dt) loop
10251 ben_prmry_care_prvdr_api.delete_prmry_care_prvdr
10252 (P_VALIDATE => FALSE
10253 ,P_PRMRY_CARE_PRVDR_ID => l_pcp.prmry_care_prvdr_id
10254 ,P_EFFECTIVE_START_DATE => l_pcp.effective_start_date
10255 ,P_EFFECTIVE_END_DATE => l_pcp.effective_end_date
10256 ,P_OBJECT_VERSION_NUMBER => l_pcp.object_version_number
10257 ,P_EFFECTIVE_DATE => l_eff_dt
10258 ,P_DATETRACK_MODE => l_datetrack_mode
10259 ,p_called_from => 'delete_enrollment'
10260 );
10261 End loop;
10262 --
10263 -- Remove ppe records and children
10264 --
10265 /* Start of Code Change for WWBUG: 1646442: added */
10266 l_ppe_dt_to_use := least(l_enrt_cvg_end_dt,l_rt_end_dt);
10267 /* End of Code Change for WWBUG: 1646442 */
10268 /*
10269 CODE PRIOR TO WWBUG: 1646442
10270 for l_ppe in c_ppe loop
10271 */
10272 /* Start of Code Change for WWBUG: 1646442 */
10273 for l_ppe in c_ppe(l_ppe_dt_to_use) loop
10274 /* End of Code Change for WWBUG: 1646442 */
10275 --
10276 l_prtt_prem_id := l_ppe.prtt_prem_id;
10277 --
10278 /******************** BEGIN CODE PRIOR TO WWBUG: 1646442 **********
10279 This whole section has been deleted
10280 ** BBurns 15aug2001
10281 ** A 'invalid primary key' error occurred when a date track delete
10282 ** was attempted with a p_effective_date prior to the start of
10283 ** the ben_prtt_prem_by_mo_f row. The ben_prtt_prem_by_mo_f rows have
10284 ** already been reported to the carrier and should not be modified
10285 ** by this procedure.
10286 ** A review of how prtt_prem_by_mo_f is defined and the functionality
10287 ** of this procedure is in order.
10288 **
10289 --
10290 -- delete child ben_prtt_prem_by_mo_f records
10291 --
10292 for l_prm in c_prm loop
10293 --
10294 if (l_datetrack_mode = hr_api.g_delete and
10295 l_prm.effective_end_date > l_eff_dt) or
10296 l_datetrack_mode <> hr_api.g_delete then
10297 --
10298 ben_prtt_prem_by_mo_api.delete_prtt_prem_by_mo
10299 (p_validate => false,
10300 p_prtt_prem_by_mo_id => l_prm.prtt_prem_by_mo_id,
10301 p_object_version_number => l_prm.object_version_number,
10302 p_effective_date => l_eff_dt,
10303 p_effective_start_date => l_prm.effective_end_date,
10304 p_effective_end_date => l_prm.effective_start_date,
10305 p_datetrack_mode => l_datetrack_mode
10306 );
10307 --
10308 end if;
10309 --
10310 end loop;
10311 ******************** END CODE PRIOR TO WWBUG: 1646442 ************/
10312 --
10313 if (l_datetrack_mode = hr_api.g_delete and
10314 l_ppe.effective_end_date > l_eff_dt) or
10315 l_datetrack_mode <> hr_api.g_delete then
10316 --
10317 /* Start of Changes for WWBUG: 1646442: added */
10318 l_ppe_dt_to_use := least(l_enrt_cvg_end_dt,l_rt_end_dt);
10319 l_ppe_datetrack_mode := l_datetrack_mode;
10320 if l_ppe_dt_to_use < l_ppe.effective_start_date
10321 then
10322 l_ppe_dt_to_use := l_ppe.effective_start_date;
10323 l_ppe_datetrack_mode := hr_api.g_zap;
10324 end if;
10325 /* End of Changes for WWBUG: 1646442 */
10326 /***************** BEGIN CODE PRIOR TO WWBUG: 1646442 **********
10327 ben_prtt_prem_api.delete_prtt_prem
10328 (p_validate => false,
10329 p_prtt_prem_id => l_ppe.prtt_prem_id,
10330 p_object_version_number => l_ppe.object_version_number,
10331 p_effective_date => l_eff_dt,
10332 p_effective_start_date => l_ppe.effective_end_date,
10333 p_effective_end_date => l_ppe.effective_start_date,
10334 p_datetrack_mode => l_datetrack_mode
10335 );
10336 ******************* END CODE PRIOR TO WWBUG: 1646442 *****************/
10337 /* Start of Code Changes for WWBUG: 1646442 */
10338 if l_datetrack_mode <> 'CORRECTION' then -- 10283346
10339 ben_prtt_prem_api.delete_prtt_prem
10340 (p_validate => false,
10341 p_prtt_prem_id => l_ppe.prtt_prem_id,
10342 p_object_version_number => l_ppe.object_version_number,
10343 p_effective_date => l_ppe_dt_to_use, /*l_eff_dt*/
10344 p_effective_start_date => l_ppe.effective_end_date,
10345 p_effective_end_date => l_ppe.effective_start_date,
10346 p_datetrack_mode => l_ppe_datetrack_mode /*l_datetrack_mode*/
10347 );
10348 end if; -- 10283346
10349 /* End of Code Changes for WWBUG: 1646442 */
10350 --
10351 end if;
10352 --
10353 end loop;
10354 --
10355 -- Clear out ben_enrt_bnft table's prtt_enrt_rslt_id
10356 --
10357 l_step := 176;
10358 --
10359 -- Do not call manage_enrt_bnft, if it is called from election_information
10360 -- as the call is always made from there.
10361 --
10362 --Bug 3256056 This call from election_information is associated with the
10363 --New results - That other call works fine if the result was continued from
10364 --the prevoius enrollment. But if the user made the change in the
10365 --current enrollment olny [I mean selected option 1 , saved and then now
10366 --changing to option 2 ] we don't want to keep the pen id on the enb record.
10367 --When we are zaping the records for the call from election information we
10368 --we want to remove the penid from enb also.
10369 --
10370 if p_source = 'benelinf' and l_datetrack_mode = hr_api.g_zap then
10371 --
10372 ben_election_information.manage_enrt_bnft
10373 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
10374 ,p_business_group_id => p_business_group_id
10375 ,p_effective_date => l_eff_dt
10376 ,p_object_version_number => l_tmp_ovn
10377 ,p_per_in_ler_id => p_per_in_ler_id
10378 );
10379 --
10380 end if;
10381 --
10382 if p_source is null or
10383 p_source <> 'benelinf' then
10384 --
10385 ben_election_information.manage_enrt_bnft
10386 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
10387 ,p_business_group_id => p_business_group_id
10388 ,p_effective_date => l_eff_dt
10389 ,p_object_version_number => l_tmp_ovn
10390 ,p_per_in_ler_id => p_per_in_ler_id
10391 );
10392 --
10393 end if;
10394 --
10395 l_step := 177;
10396 -- Do not attempt dt delete if the row selected already has an effective
10397 -- end date equal to (or less than) the date you are trying to delete it on.
10398 -- Bug 1132739
10399 -- Bug 2386000 If the result got update as part of on of the above calls,
10400 -- we need to get the latest object_version_number
10401 --
10402 if (l_datetrack_mode = hr_api.g_delete and
10403 l_pen.effective_end_date > l_eff_dt) or
10404 l_datetrack_mode <> hr_api.g_delete then
10405 --
10406 -- 4663971
10407 open c_pen_ovn( p_prtt_enrt_rslt_id,l_eff_dt ) ;
10408 fetch c_pen_ovn into l_pen_ovn.object_version_number,l_pen_ovn.effective_start_date ;
10409 close c_pen_ovn ;
10410 --
10411 -- BUG 4663971 we should never call delete process with other than zap mode
10412 -- if the datetrack mode is other than zap we need to call
10413 -- update_prtt_enrt_result procedure
10414 --
10415 if p_source = 'benuneai' or l_datetrack_mode <> hr_api.g_zap then
10416 hr_utility.set_location('called from benuneai',99);
10417 --
10418 -- 4663971
10419 if l_pen_ovn.effective_start_date = l_eff_dt
10420 or l_datetrack_mode='CORRECTION' then
10421 l_datetrack_mode := hr_api.g_correction ;
10422 l_temp_date:=l_enrt_cvg_end_dt;
10423 --Bug#:6641853
10424 else
10425 l_datetrack_mode := hr_api.g_update ;
10426 l_temp_date:=l_pen.enrt_cvg_strt_dt-1;
10427 end if;
10428 --
10429 ben_prtt_enrt_result_api.update_prtt_enrt_result
10430 (p_validate => FALSE
10431 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
10432 ,p_effective_start_date => p_effective_start_date
10433 ,p_effective_end_date => p_effective_end_date
10434 ,p_per_in_ler_id => l_pen.per_in_ler_id
10435 ,p_ler_id => l_pen.ler_id
10436 ,p_enrt_cvg_thru_dt => l_temp_date
10437 ,p_rplcs_sspndd_rslt_id => null
10438 ,p_object_version_number => l_pen_ovn.object_version_number
10439 ,p_effective_date => l_eff_dt
10440 ,p_datetrack_mode => l_datetrack_mode --4663971
10441 ,p_multi_row_validate => p_multi_row_validate
10442 ,p_business_group_id => p_business_group_id
10443 );
10444 else
10445 --
10446 -- 12583091 -- Check if enrollment was previously suspended and there
10447 -- is an interim enrollment for the current event. Delete the interim
10448 -- if the enrollment is deleted. Void the interim of the enrollment is
10449 -- voided.
10450 --
10451 hr_utility.set_location('stee l_datetrack_mode '||l_datetrack_mode, 60);
10452 hr_utility.set_location('stee l_prtt_enrt_rslt_Stat_cd '||l_prtt_enrt_rslt_Stat_cd,60);
10453 if l_pen.sspndd_flag = 'N' and
10454 (p_source is null or
10455 p_source = 'benelinf') and
10456 l_datetrack_mode = hr_api.g_zap then
10457 --
10458 -- Check if enrollment was previously suspended in the current
10459 -- event
10460 --
10461 open c_get_interim;
10462 fetch c_get_interim into l_interim_enrt;
10463 if c_get_interim%found then
10464 --
10465 close c_get_interim;
10466 --
10467 hr_utility.set_location('stee l_datetrack_mode '||l_datetrack_mode, 60);
10468 delete_enrollment(
10469 p_validate => false,
10470 p_per_in_ler_id => p_per_in_ler_id,
10471 p_prtt_enrt_rslt_id => l_interim_enrt.prtt_enrt_rslt_id,
10472 p_effective_start_date => l_interim_enrt.effective_start_date,
10473 p_effective_end_date => l_interim_enrt.effective_end_date,
10474 p_object_version_number => l_interim_enrt.object_version_number,
10475 p_business_group_id => p_business_group_id,
10476 p_effective_date => p_effective_date,
10477 p_datetrack_mode => p_datetrack_mode,
10478 p_source => 'delete_enrollment',
10479 p_lee_rsn_id => p_lee_rsn_id,
10480 p_enrt_perd_id => p_enrt_perd_id,
10481 p_multi_row_validate => false);
10482 else
10483 close c_get_interim;
10484 end if;
10485 --
10486 end if; -- sspndd_flag = 'N'
10487 --
10488 -- end 12583091
10489 --
10490 ben_prtt_enrt_result_api.delete_prtt_enrt_result
10491 (p_validate => FALSE
10492 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
10493 ,p_effective_start_date => p_effective_start_date
10494 ,p_effective_end_date => p_effective_end_date
10495 ,p_object_version_number => l_pen_ovn.object_version_number -- 2386000
10496 ,p_effective_date => l_eff_dt
10497 ,p_datetrack_mode => l_datetrack_mode
10498 ,p_multi_row_validate => p_multi_row_validate);
10499 end if;
10500 end if;
10501 end if ; ----2546259
10502 -- write to change event log. -thayden
10503 --
10504 l_step := 178;
10505 --
10506 if p_source is null or
10507 p_source <> 'benelinf' then
10508 ben_ext_chlg.log_benefit_chg
10509 (p_action => 'DELETE'
10510 ,p_old_pl_id => l_pen.pl_id
10511 ,p_old_oipl_id => l_pen.oipl_id
10512 ,p_old_enrt_cvg_strt_dt => l_pen.enrt_cvg_strt_dt
10513 ,p_old_enrt_cvg_end_dt => l_pen.enrt_cvg_thru_dt
10514 ,p_pl_id => l_pen.pl_id
10515 ,p_oipl_id => l_pen.oipl_id
10516 ,p_enrt_cvg_strt_dt => l_pen.enrt_cvg_strt_dt
10517 ,p_enrt_cvg_end_dt => l_eff_dt
10518 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
10519 ,p_per_in_ler_id => l_pen.per_in_ler_id
10520 ,p_person_id => l_pen.person_id
10521 ,p_business_group_id => p_business_group_id
10522 ,p_effective_date => l_eff_dt
10523 );
10524 end if;
10525 --
10526 end if;
10527 --bug # 3086161
10528 if l_corr_pil_id is not null then
10529 hr_utility.set_location(' correcting the resulst for ' || l_corr_pil_id , 999 );
10530 open c_pen_obj_no (p_per_in_ler_id ,p_prtt_enrt_rslt_id ) ;
10531 fetch c_pen_obj_no into l_object_version_number ;
10532 if c_pen_obj_no%found then
10533 hr_utility.set_location(' correcting the result ovn ' || l_object_version_number , 999 );
10534 ben_prtt_enrt_result_api.update_prtt_enrt_result
10535 (p_validate => FALSE
10536 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
10537 ,p_effective_start_date => p_effective_start_date
10538 ,p_effective_end_date => p_effective_end_date
10539 ,p_per_in_ler_id => l_corr_pil_id
10540 ,p_ler_id => l_pen.ler_id
10541 ,p_object_version_number => l_object_version_number
10542 ,p_effective_date => p_effective_date
10543 ,p_datetrack_mode => hr_api.g_correction
10544 ,p_multi_row_validate => FALSE
10545 ,p_business_group_id => p_business_group_id
10546 );
10547 end if ;
10548 /* -- added here for bug 6963660
10549 -- updated the corrected result in the back up table so that it behaves as
10550 -- if corrected on the p_effective_start_date
10551 --
10552 update ben_le_clsn_n_rstr
10553 set effective_start_date = p_effective_start_date
10554 where per_in_ler_id = l_corr_pil_id
10555 and bkup_tbl_id = p_prtt_enrt_rslt_id
10556 and bkup_tbl_typ_cd = 'BEN_PRTT_ENRT_RSLT_F_CORR';
10557 --
10558 -- added till here for bug 6963660 */
10559 close c_pen_obj_no ;
10560 end if ;
10561 --- eof bug # 3086161
10562 --
10563 -- Delete the interim coverage also.
10564 -- Delete interim only when called from enrollment forms (p_source is null)
10565 -- and when called from election_information (p_source='benelinf')
10566 --
10567 if l_pen.sspndd_flag = 'Y' and
10568 l_pen.rplcs_sspndd_rslt_id is not null and
10569 (p_source is null or
10570 p_source = 'benelinf') then
10571 --
10572 -- Check if the interim result is been used by some other suspended
10573 -- result. If yes, do not delete the interim result.
10574 -- This case is most important when I'm moving from a suspended result
10575 -- to other result, which also gets suspended and both have the same
10576 -- interim. In this case, we create the new suspended result first
10577 -- and when interim needs to be created, it finds interim result to be
10578 -- already present. Now when the old suspended result is deleted in the
10579 -- same run, it tries to delete the interim result along with it.
10580 -- So the new suspended result is without any interims.
10581 -- In order to avoid this, this new cursor is introduced. (Bug 1274214)
10582 --
10583 open c_intm_other_rslt(p_per_in_ler_id); -- Bug 6165501 : Added Input param
10584 fetch c_intm_other_rslt into l_intm_other_rslt;
10585 close c_intm_other_rslt;
10586 --
10587 if l_intm_other_rslt is null or
10588 l_intm_other_rslt <> 'Y' then
10589 --
10590 open c_interim;
10591 fetch c_interim into l_interim;
10592 --
10593 if c_interim%found then
10594 --
10595 delete_enrollment(
10596 p_validate => false,
10597 p_per_in_ler_id => p_per_in_ler_id,
10598 p_prtt_enrt_rslt_id => l_interim.prtt_enrt_rslt_id,
10599 p_effective_start_date => l_interim.effective_start_date,
10600 p_effective_end_date => l_interim.effective_end_date,
10601 p_object_version_number => l_interim.object_version_number,
10602 p_business_group_id => p_business_group_id,
10603 p_effective_date => p_effective_date,
10604 p_datetrack_mode => p_datetrack_mode,
10605 p_source => 'delete_enrollment',
10606 p_lee_rsn_id => p_lee_rsn_id,
10607 p_enrt_perd_id => p_enrt_perd_id,
10608 p_multi_row_validate => false);
10609 --
10610 end if;
10611 --
10612 close c_interim;
10613 --
10614 end if;
10615 --
10616 -- 12583091 -- Check if enrollment was previously suspended and there
10617 -- is an interim enrollment for the current event. Delete the interim
10618 -- if the enrollment is voided. Void the interim of the enrollment is
10619 -- voided.
10620 --
10621 else
10622 hr_utility.set_location('stee l_datetrack_mode '||l_datetrack_mode, 60);
10623 hr_utility.set_location('stee l_prtt_enrt_rslt_Stat_cd '||l_prtt_enrt_rslt_Stat_cd,60);
10624 if l_pen.sspndd_flag = 'N' and
10625 (p_source is null or
10626 p_source = 'benelinf') and
10627 (l_prtt_enrt_rslt_stat_cd = 'VOIDD'
10628 and l_datetrack_mode = hr_api.g_update) then
10629 --
10630 -- Check if enrollment was previously suspended in the current
10631 -- event
10632 --
10633 open c_get_interim;
10634 fetch c_get_interim into l_interim_enrt;
10635 if c_get_interim%found then
10636 --
10637 close c_get_interim;
10638 --
10639 hr_utility.set_location('stee l_enrt_cvg_end_dt '||l_enrt_cvg_end_dt,60);
10640 hr_utility.set_location('stee l_interim stat cd '||l_interim_enrt.prtt_enrt_rslt_stat_cd,60);
10641 if l_interim_enrt.prtt_enrt_rslt_stat_cd is null then
10642 ben_prtt_enrt_result_api.update_prtt_enrt_result
10643 (p_validate => FALSE
10644 ,p_prtt_enrt_rslt_id => l_interim_enrt.prtt_enrt_rslt_id
10645 ,p_effective_start_date => p_effective_start_date
10646 ,p_effective_end_date => p_effective_end_date
10647 ,p_per_in_ler_id => p_per_in_ler_id
10648 ,p_enrt_cvg_thru_dt => l_enrt_cvg_end_dt
10649 ,p_object_version_number => l_interim_enrt.object_version_number
10650 ,p_effective_date => p_effective_date
10651 ,p_datetrack_mode => l_datetrack_mode
10652 ,p_multi_row_validate => p_multi_row_validate
10653 ,p_business_group_id => p_business_group_id
10654 ,p_prtt_enrt_rslt_stat_cd => l_prtt_enrt_rslt_Stat_cd
10655 );
10656 end if;
10657 --
10658 -- void the interim enrollment rate.
10659 --
10660 void_rate (p_prtt_enrt_rslt_id => l_interim_enrt.prtt_enrt_rslt_id,
10661 p_business_group_id => p_business_group_id,
10662 p_person_id => l_interim_enrt.person_id,
10663 p_per_in_ler_id => p_per_in_ler_id,
10664 p_effective_date => p_effective_date );
10665 else
10666 close c_get_interim;
10667 --
10668 end if;
10669 end if;
10670 -- end 12583091
10671 end if;
10672 --
10673 if g_debug then
10674 hr_utility.set_location(l_proc, 60);
10675 end if;
10676 --
10677 -- When in validation only mode raise the Validate_Enabled exception
10678 --
10679 if p_validate then
10680 raise hr_api.validate_enabled;
10681 end if;
10682 --
10683 if g_debug then
10684 hr_utility.set_location(' Leaving:'||l_proc, 70);
10685 end if;
10686 --
10687 Exception
10688 --
10689 when hr_api.validate_enabled
10690 then
10691 --
10692 -- As the Validate_Enabled exception has been raised
10693 -- we must rollback to the savepoint
10694 --
10695 ROLLBACK TO delete_enrollment;
10696 --
10697 -- Only set output warning arguments
10698 -- (Any key or derived arguments must be set to null
10699 -- when validation only mode is being used.)
10700 --
10701 if g_debug then
10702 hr_utility.set_location(' Leaving:'||l_proc, 80);
10703 end if;
10704 --
10705 when l_fnd_message_exception then
10706 ROLLBACK TO delete_enrollment;
10707 rpt_error(p_proc => l_proc, p_step => l_step);
10708 p_effective_start_date := null; --nocopy change
10709 p_effective_end_date := null; --nocopy change
10710 fnd_message.raise_error;
10711 --
10712 --Bug 5664907
10713 when app_exception.application_exception then
10714 ROLLBACK TO delete_enrollment;
10715 rpt_error(p_proc => l_proc, p_step => l_step);
10716 p_effective_start_date := null; --nocopy change
10717 p_effective_end_date := null; --nocopy change
10718 fnd_message.raise_error;
10719 --
10720 --Bug 5664907
10721 when others then
10722 --
10723 --
10724 -- A validation or unexpected error has occured
10725 --
10726 ROLLBACK TO delete_enrollment;
10727 rpt_error(p_proc => l_proc, p_step => l_step);
10728 p_effective_start_date := null; --nocopy change
10729 p_effective_end_date := null; --nocopy change
10730 fnd_message.set_name('PER','FFU10_GENERAL_ORACLE_ERROR');
10731 fnd_message.set_token('2',substr(sqlerrm,1,500)); -- 4695708
10732 fnd_message.raise_error;
10733 --
10734 end delete_enrollment;
10735 --
10736 -- --------------------------------------------------------------------------
10737 -- |--------------------------< unhook_bnf >--------------------------------|
10738 -- --------------------------------------------------------------------------
10739 --
10740 procedure unhook_bnf
10741 (p_validate in boolean default FALSE
10742 ,p_prtt_enrt_rslt_id in number
10743 ,p_per_in_ler_id in number
10744 ,p_dsgn_thru_dt in date
10745 ,p_business_group_id in number
10746 ,p_effective_date in date
10747 ,p_datetrack_mode in varchar2
10748 ,p_rslt_delete_flag in boolean default FALSE
10749
10750 ) is
10751
10752
10753 cursor c_old_bnf
10754 is
10755 select pbf.pl_bnf_id
10756 ,pbf.effective_start_date
10757 ,pbf.effective_end_date
10758 ,pbf.object_version_number
10759 ,pbf.dsgn_strt_dt
10760 ,pbf.dsgn_thru_dt
10761 ,pbf.per_in_ler_id
10762 from ben_pl_bnf_f pbf,
10763 ben_per_in_ler pil
10764 where pbf.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
10765 and pbf.business_group_id = p_business_group_id
10766 and p_effective_date between pbf.effective_start_date
10767 and pbf.effective_end_date
10768 and pil.per_in_ler_id=pbf.per_in_ler_id
10769 and pil.business_group_id=pbf.business_group_id
10770 and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT')
10771 ;
10772 --
10773 cursor c_zap_bnf
10774 is
10775 select pbf.pl_bnf_id
10776 ,pbf.object_version_number
10777 from ben_pl_bnf_f pbf,
10778 ben_per_in_ler pil
10779 where pbf.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
10780 and p_effective_date
10781 between pbf.effective_start_date
10782 and pbf.effective_end_date
10783 and pil.per_in_ler_id=pbf.per_in_ler_id
10784 and pil.business_group_id=pbf.business_group_id
10785 and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT')
10786 ;
10787
10788 l_proc varchar2(72); -- := g_package||'unhook_bnf';
10789
10790 l_effective_start_date date;
10791 l_effective_end_date date;
10792 l_object_version_number number(9);
10793 l_step integer;
10794 l_datetrack_mode varchar2(30);
10795 l_correction boolean;
10796 l_update boolean;
10797 l_update_override boolean;
10798 l_update_change_insert boolean;
10799 l_last number:=-1;
10800 l_effective_date date;
10801 l_per_in_ler_id number := p_per_in_ler_id;
10802 --
10803 begin
10804 --
10805 g_debug := hr_utility.debug_enabled;
10806 if g_debug then
10807 l_proc := g_package||'unhook_bnf';
10808 hr_utility.set_location('Entering'||l_proc, 5);
10809 end if;
10810 --
10811 l_step := 10;
10812 --
10813 for orec in c_old_bnf loop
10814 --
10815 -- Only pick up first occurrence of each ID.
10816 -- This was added to zap future dated rows
10817 -- because result delete fails if children
10818 -- are not ended.
10819 --
10820 if l_last=-1 or l_last<>orec.pl_bnf_id then
10821 l_last:=orec.pl_bnf_id;
10822 l_effective_date:=p_effective_date;
10823 if (p_effective_date<nvl(orec.effective_start_date,hr_api.g_date)) then
10824 l_effective_date:=orec.effective_start_date;
10825 l_datetrack_mode := hr_api.g_zap;
10826 elsIf (p_effective_date = nvl(orec.effective_start_date,hr_api.g_date)) then
10827 l_datetrack_mode := hr_api.g_correction;
10828 Elsif (p_datetrack_mode in (hr_api.g_correction, hr_api.g_zap)) then
10829 l_datetrack_mode := hr_api.g_correction;
10830 Else
10831 l_datetrack_mode := hr_api.g_update;
10832 End if;
10833 --
10834 --
10835 If (p_effective_date between nvl(orec.dsgn_strt_dt, p_effective_date+1)
10836 and nvl(orec.dsgn_thru_dt, hr_api.g_eot)
10837 and not p_rslt_delete_flag
10838 and l_datetrack_mode<>hr_api.g_zap
10839 ) then
10840 --
10841 -- If Coverage started, then end the coverage by set the coverage
10842 -- thru date.
10843 --
10844
10845 dt_api.find_dt_upd_modes
10846 (p_effective_date => p_effective_date,
10847 p_base_table_name => 'BEN_PL_BNF_F',
10848 p_base_key_column => 'PL_BNF_ID',
10849 p_base_key_value => orec.PL_BNF_ID,
10850 p_correction => l_correction,
10851 p_update => l_update,
10852 p_update_override => l_update_override,
10853 p_update_change_insert => l_update_change_insert);
10854 --
10855 if l_update_override then
10856 --
10857 l_datetrack_mode := hr_api.g_update_override;
10858 --
10859 elsif l_update then
10860 --
10861 l_datetrack_mode := hr_api.g_update;
10862 --
10863 else
10864 --
10865 l_datetrack_mode := hr_api.g_correction;
10866 --
10867 end if;
10868 if g_debug then
10869 hr_utility.set_location('dt_mode='||l_datetrack_mode,11);
10870 end if;
10871 --
10872 l_step := 20;
10873 --
10874 If p_dsgn_thru_dt is null then
10875 rpt_error(p_proc => l_proc, p_step => l_step);
10876 fnd_message.set_name('BEN','BEN_91704_NOT_DET_DP_CVG_E_DT');
10877 fnd_message.raise_error;
10878 End if;
10879 --
10880 if l_per_in_ler_id is null then
10881 l_per_in_ler_id := orec.per_in_ler_id;
10882 end if;
10883 --
10884 if g_debug then
10885 hr_utility.set_location('calling update mode' || l_datetrack_mode , 192 );
10886 end if;
10887 ben_PLAN_BENEFICIARY_api.update_PLAN_BENEFICIARY
10888 (p_validate => FALSE
10889 ,p_business_group_id => p_business_group_id
10890 ,p_pl_bnf_id => orec.pl_bnf_id
10891 ,p_effective_start_date => orec.effective_start_date
10892 ,p_effective_end_date => orec.effective_end_date
10893 ,p_dsgn_thru_dt => p_dsgn_thru_dt
10894 ,p_per_in_ler_id => l_per_in_ler_id
10895 ,p_object_version_number => orec.object_version_number
10896 ,p_effective_date => p_effective_date
10897 ,p_datetrack_mode => l_datetrack_mode
10898 ,p_multi_row_actn => FALSE);
10899 --
10900 elsif orec.dsgn_thru_dt < p_effective_date then
10901 --
10902 -- Coverage is already ended. Don't do anything.
10903 --
10904 null;
10905 --
10906 Else
10907 --
10908 -- If coverage not yet started, then reset coverage start/end date
10909 -- to NULL and coverage flag to 'N'
10910 --
10911 l_step := 40;
10912 --
10913 If (p_effective_date <= nvl(orec.effective_start_date,hr_api.g_date)) then
10914 l_datetrack_mode := hr_api.g_zap;
10915 Elsif (p_datetrack_mode in (hr_api.g_correction, hr_api.g_zap)) then
10916 l_datetrack_mode := hr_api.g_zap;
10917 Else
10918 l_datetrack_mode := hr_api.g_delete;
10919
10920 End if;
10921 --
10922 -- Start of fix for INTERNAL bug 4924
10923 --
10924 if l_datetrack_mode = hr_api.g_delete and
10925 p_effective_date = orec.effective_end_date then
10926 --
10927 -- Already end dated
10928 --
10929 null;
10930 --
10931 else
10932 --
10933 if g_debug then
10934 hr_utility.set_location('calling delete ' || l_datetrack_mode , 192 );
10935 end if;
10936 ben_plan_beneficiary_api.delete_plan_beneficiary
10937 (p_validate => p_validate
10938 ,p_pl_bnf_id => orec.pl_bnf_id
10939 ,p_effective_start_date => orec.effective_start_date
10940 ,p_effective_end_date => orec.effective_end_date
10941 ,p_object_version_number => orec.object_version_number
10942 ,p_effective_date => p_effective_date
10943 ,p_datetrack_mode => nvl(l_datetrack_mode,p_datetrack_mode)
10944 ,p_multi_row_actn => FALSE
10945 ,p_business_group_id => p_business_group_id);
10946
10947 --
10948 end if;
10949 --
10950 -- End of fix for INTERNAL BUG 4924.
10951 --
10952 End if;
10953 end if;
10954 End loop;
10955 if g_debug then
10956 hr_utility.set_location('Exiting'||l_proc, 30);
10957 end if;
10958
10959 exception
10960 --
10961 when others then
10962 rpt_error(p_proc => l_proc, p_step => l_step);
10963 fnd_message.raise_error;
10964 End unhook_bnf;
10965 --
10966
10967
10968 --
10969 -- ---------------------------------------------------------------------------
10970 -- |----------------------------< unhook_dpnt >------------------------------|
10971 -- ---------------------------------------------------------------------------
10972 --
10973 Procedure unhook_dpnt
10974 (p_validate in boolean default FALSE
10975 ,p_prtt_enrt_rslt_id in number
10976 ,p_per_in_ler_id in number
10977 ,p_cvg_thru_dt in date
10978 ,p_business_group_id in number
10979 ,p_effective_date in date
10980 ,p_datetrack_mode in varchar2
10981 ,p_rslt_delete_flag in boolean default FALSE
10982 ,p_called_from in varchar2 default 'bepenapi'
10983 ) is
10984 cursor c_old_dpnt is
10985 select ecd.elig_cvrd_dpnt_id
10986 ,ecd.effective_start_date
10987 ,ecd.effective_end_date
10988 ,ecd.dpnt_person_id
10989 ,ecd.cvg_strt_dt
10990 ,ecd.CVG_PNDG_FLAG
10991 ,ecd.cvg_thru_dt
10992 ,ecd.object_version_number
10993 ,ecd.per_in_ler_id
10994 from ben_elig_cvrd_dpnt_f ecd,
10995 ben_per_in_ler pil
10996 where ecd.prtt_enrt_rslt_id=p_prtt_enrt_rslt_id
10997 and ecd.cvg_strt_dt is not null
10998 -- and ecd.cvg_thru_dt = hr_api.g_eot
10999 and ecd.business_group_id=p_business_group_id
11000 -- and p_effective_date between
11001 -- ecd.effective_start_date and ecd.effective_end_date
11002 and p_effective_date <= ecd.effective_end_date
11003 and pil.per_in_ler_id(+)=ecd.per_in_ler_id
11004 and pil.business_group_id(+)=ecd.business_group_id
11005 and (pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT') or
11006 -- outer join condition below
11007 -- above is case where found pil,
11008 -- below is case where pil not found and want row
11009 pil.per_in_ler_stat_cd is null)
11010 /* Bug 4520785 Pick only those cvrd dependent records where either cvg thru date hasn't
11011 been end dated yet or cvg thru date is more than effective date */
11012 and ecd.elig_cvrd_dpnt_id not in (select ecd1.elig_cvrd_dpnt_id
11013 from ben_elig_cvrd_dpnt_f ecd1
11014 where ecd1.elig_cvrd_dpnt_id = ecd.elig_cvrd_dpnt_id
11015 and ecd1.cvg_thru_dt <= p_cvg_thru_dt --9501588
11016 and p_effective_date <= ecd1.effective_end_date ) -- Bug 4710937
11017 /* End Bug 4520785 */
11018 order by ecd.elig_cvrd_dpnt_id,
11019 ecd.effective_start_date;
11020
11021 -- 3574168
11022 -- Fetch all PCP records on effective date
11023 Cursor c_pcp (c_elig_cvrd_dpnt_id NUMBER)
11024 is
11025 select pcp.PRMRY_CARE_PRVDR_ID
11026 ,pcp.EFFECTIVE_START_DATE
11027 ,pcp.EFFECTIVE_END_DATE
11028 ,pcp.PRTT_ENRT_RSLT_ID
11029 ,pcp.BUSINESS_GROUP_ID
11030 ,pcp.OBJECT_VERSION_NUMBER
11031 from ben_prmry_care_prvdr_f pcp
11032 where business_group_id = p_business_group_id
11033 and elig_cvrd_dpnt_id = c_elig_cvrd_dpnt_id
11034 and p_effective_date between effective_start_date
11035 and effective_end_date
11036 ;
11037 --
11038 -- Fetch all PCP records in future
11039 Cursor c_pcp_future (c_elig_cvrd_dpnt_id NUMBER)
11040 is
11041 select pcp.PRMRY_CARE_PRVDR_ID
11042 ,pcp.EFFECTIVE_START_DATE
11043 ,pcp.EFFECTIVE_END_DATE
11044 ,pcp.PRTT_ENRT_RSLT_ID
11045 ,pcp.BUSINESS_GROUP_ID
11046 ,pcp.OBJECT_VERSION_NUMBER
11047 from ben_prmry_care_prvdr_f pcp
11048 where pcp.business_group_id = p_business_group_id
11049 and pcp.elig_cvrd_dpnt_id = c_elig_cvrd_dpnt_id
11050 and p_effective_date < pcp.effective_start_date
11051 and NVL(pcp.effective_end_date, hr_api.g_eot) = hr_api.g_eot
11052 ;
11053 -- 3574168
11054
11055 l_proc varchar2(72); -- := g_package||'unhook_dpnt';
11056 l_effective_start_date date;
11057 l_effective_end_date date;
11058 l_object_version_number number(9);
11059 l_step integer;
11060 l_datetrack_mode varchar2(30);
11061 l_correction boolean;
11062 l_update boolean;
11063 l_update_override boolean;
11064 l_update_change_insert boolean;
11065 l_last number:=-1;
11066 l_effective_date date;
11067 l_per_in_ler_id number := p_per_in_ler_id;
11068 l_pcp_effective_date date;
11069 --
11070 begin
11071 --
11072 g_debug := hr_utility.debug_enabled;
11073 if g_debug then
11074 l_proc := g_package||'unhook_dpnt';
11075 hr_utility.set_location('Entering'||l_proc, 5);
11076 hr_utility.set_location('p_effective_date '||to_char(p_effective_date), 5);
11077 end if;
11078 --
11079 l_step := 10;
11080 --
11081 for orec in c_old_dpnt loop
11082 --
11083 -- Only pick up first occurrence of each ID.
11084 -- This was added to zap future dated rows
11085 -- because result delete fails if children
11086 -- are not ended.
11087 --
11088 hr_utility.set_location('orec.effective_start_date '||to_char(orec.effective_start_date), 5);
11089 hr_utility.set_location('p_datetrack_mode '||p_datetrack_mode , 5);
11090 hr_utility.set_location('orec.cvg_strt_dt '||to_char(orec.cvg_strt_dt), 5);
11091 hr_utility.set_location('orec.cvg_thru_dt '||to_char(orec.cvg_thru_dt), 5);
11092
11093 if l_last=-1 or
11094 l_last<>orec.elig_cvrd_dpnt_id then
11095 l_last:=orec.elig_cvrd_dpnt_id;
11096 l_effective_date:=p_effective_date;
11097 if (p_effective_date<nvl(orec.effective_start_date,hr_api.g_date)) then
11098 l_effective_date:=orec.effective_start_date;
11099 l_datetrack_mode := hr_api.g_zap;
11100 elsIf (p_effective_date = nvl(orec.effective_start_date,hr_api.g_date)) then
11101 l_datetrack_mode := hr_api.g_correction;
11102 Elsif (p_datetrack_mode in (hr_api.g_correction, hr_api.g_zap)) then
11103 l_datetrack_mode := hr_api.g_correction;
11104 Else
11105 l_datetrack_mode := hr_api.g_update;
11106 End if;
11107 --
11108 --Bug 9534364,modified the IF condition.
11109 If ( ((p_effective_date between nvl(orec.cvg_strt_dt, p_effective_date+1)
11110 and nvl(orec.cvg_thru_dt, hr_api.g_eot) )
11111 or (nvl(orec.cvg_thru_dt, hr_api.g_eot) = hr_api.g_eot
11112 and p_effective_date between nvl(orec.effective_start_date, p_effective_date+1)
11113 and nvl(orec.effective_end_date, hr_api.g_eot)))
11114 and orec.CVG_PNDG_FLAG = 'N'
11115 and not p_rslt_delete_flag
11116 and l_datetrack_mode<>hr_api.g_zap
11117 ) then
11118 --
11119 -- If Coverage started, then end the coverage by set the coverage
11120 -- thru date.
11121 --
11122 dt_api.find_dt_upd_modes
11123 (p_effective_date => p_effective_date,
11124 p_base_table_name => 'BEN_ELIG_CVRD_DPNT_F',
11125 p_base_key_column => 'ELIG_CVRD_DPNT_ID',
11126 p_base_key_value => orec.elig_cvrd_dpnt_id,
11127 p_correction => l_correction,
11128 p_update => l_update,
11129 p_update_override => l_update_override,
11130 p_update_change_insert => l_update_change_insert);
11131 --
11132 if l_update_override then
11133 --
11134 l_datetrack_mode := hr_api.g_update_override;
11135 --
11136 elsif l_update then
11137 --
11138 l_datetrack_mode := hr_api.g_update;
11139
11140 /* Bug 2597005: Reverse changes (Update the coverages of Dependents in correction mode )*/
11141 -- l_datetrack_mode := hr_api.g_correction;
11142 /* Bug 2597005: Reverse changes (Update the coverages of Dependents in correction mode) */
11143 --
11144 else
11145 --
11146 l_datetrack_mode := hr_api.g_correction;
11147 --
11148
11149 end if;
11150 if g_debug then
11151 hr_utility.set_location('dt_mode='||l_datetrack_mode,11);
11152 end if;
11153 --
11154 l_step := 20;
11155 --
11156 If p_cvg_thru_dt is null then
11157 rpt_error(p_proc => l_proc, p_step => l_step);
11158 fnd_message.set_name('BEN','BEN_91704_NOT_DET_DP_CVG_E_DT');
11159 fnd_message.raise_error;
11160 End if;
11161 --
11162 if l_per_in_ler_id is null then
11163 l_per_in_ler_id := orec.per_in_ler_id;
11164 end if;
11165 ben_elig_cvrd_dpnt_api.update_elig_cvrd_dpnt
11166 (p_validate => FALSE
11167 ,p_business_group_id => p_business_group_id
11168 ,p_elig_cvrd_dpnt_id => orec.elig_cvrd_dpnt_id
11169 ,p_effective_start_date => orec.effective_start_date
11170 ,p_effective_end_date => orec.effective_end_date
11171 ,p_cvg_thru_dt => p_cvg_thru_dt
11172 ,p_per_in_ler_id => l_per_in_ler_id
11173 ,p_object_version_number => orec.object_version_number
11174 ,p_effective_date => p_effective_date
11175 ,p_datetrack_mode => l_datetrack_mode
11176 ,p_multi_row_actn => FALSE);
11177 --
11178 /* --
11179 -- 3617724: Remove PCP records
11180 -- NO NEED TO REMOVE PCP's here as "update_elig_cvrd_dpnt" procedure above will do it.
11181 -- 3617724
11182 */
11183
11184 elsif orec.cvg_thru_dt < p_effective_date then
11185 --
11186 -- Coverage is already ended. Don't do anything.
11187 --
11188 null;
11189 --
11190 Else
11191 --
11192 -- If coverage not yet started, then reset coverage start/end date
11193 -- to NULL and coverage flag to 'N'
11194 --
11195 l_step := 40;
11196 --
11197 If (p_effective_date <= nvl(orec.effective_start_date,hr_api.g_date)) then
11198 l_datetrack_mode := hr_api.g_zap;
11199 Elsif (p_datetrack_mode in (hr_api.g_correction, hr_api.g_zap)) then
11200 l_datetrack_mode := hr_api.g_zap;
11201 Else
11202 l_datetrack_mode := hr_api.g_delete;
11203 if g_debug then
11204 hr_utility.set_location('in dt_mode='||l_datetrack_mode,11);
11205 end if;
11206 End if;
11207 --
11208 -- Start of fix for INTERNAL bug 4924
11209 --
11210 if g_debug then
11211 hr_utility.set_location('dt_mode='||l_datetrack_mode,11);
11212 end if;
11213 if l_datetrack_mode = hr_api.g_delete and
11214 p_effective_date = orec.effective_end_date then
11215 --
11216 -- Already end dated
11217 --
11218 null;
11219 --
11220 else
11221
11222 --
11223 -- 3574168: Remove PCP records
11224 -- Set End-date to coverage-end-date.
11225 --
11226 for l_pcp in c_pcp(orec.elig_cvrd_dpnt_id) loop
11227 --
11228 hr_utility.set_location('Delete prmry_care_prvdr_id '|| l_pcp.prmry_care_prvdr_id, 15);
11229 --
11230 ben_prmry_care_prvdr_api.delete_prmry_care_prvdr
11231 (P_VALIDATE => FALSE
11232 ,P_PRMRY_CARE_PRVDR_ID => l_pcp.prmry_care_prvdr_id
11233 ,P_EFFECTIVE_START_DATE => l_pcp.effective_start_date
11234 ,P_EFFECTIVE_END_DATE => l_pcp.effective_end_date
11235 ,P_OBJECT_VERSION_NUMBER => l_pcp.object_version_number
11236 ,P_EFFECTIVE_DATE => l_effective_date
11237 ,P_DATETRACK_MODE => l_datetrack_mode
11238 ,p_called_from => 'delete_enrollment'
11239 );
11240 --
11241 End loop;
11242 --
11243 -- Get future PCP records if any and zap - delete all of them.
11244 --
11245 for l_pcp_future in c_pcp_future(orec.elig_cvrd_dpnt_id) loop
11246 --
11247 hr_utility.set_location('ZAP prmry_care_prvdr_id '|| l_pcp_future.prmry_care_prvdr_id, 15);
11248 --
11249 l_pcp_effective_date := l_pcp_future.effective_start_date;
11250 --
11251 ben_prmry_care_prvdr_api.delete_prmry_care_prvdr
11252 (P_VALIDATE => FALSE
11253 ,P_PRMRY_CARE_PRVDR_ID => l_pcp_future.prmry_care_prvdr_id
11254 ,P_EFFECTIVE_START_DATE => l_pcp_future.effective_start_date
11255 ,P_EFFECTIVE_END_DATE => l_pcp_future.effective_end_date
11256 ,P_OBJECT_VERSION_NUMBER => l_pcp_future.object_version_number
11257 ,P_EFFECTIVE_DATE => l_pcp_effective_date
11258 ,P_DATETRACK_MODE => hr_api.g_zap
11259 ,p_called_from => 'delete_enrollment'
11260 );
11261 End loop;
11262 -- 3574168
11263
11264 --
11265 -- Bug 2386000 Added new parameter p_called_from not to unsuspend the
11266 -- enrollment which is going to be deleted.
11267 ben_elig_cvrd_dpnt_api.delete_elig_cvrd_dpnt
11268 (p_validate => FALSE
11269 ,p_elig_cvrd_dpnt_id => orec.elig_cvrd_dpnt_id
11270 ,p_effective_start_date => orec.effective_start_date
11271 ,p_business_group_id => p_business_group_id
11272 ,p_effective_end_date => orec.effective_end_date
11273 ,p_object_version_number => orec.object_version_number
11274 ,p_effective_date => l_effective_date
11275 ,p_datetrack_mode => l_datetrack_mode
11276 ,p_multi_row_actn => FALSE
11277 ,p_called_from => p_called_from
11278 );
11279 --
11280 end if;
11281 --
11282 -- End of fix for INTERNAL BUG 4924.
11283 --
11284 End if;
11285 end if;
11286 End loop;
11287 if g_debug then
11288 hr_utility.set_location('Exiting'||l_proc, 30);
11289 end if;
11290 exception
11291 --
11292 when others then
11293 rpt_error(p_proc => l_proc, p_step => l_step);
11294 fnd_message.raise_error;
11295 End unhook_dpnt;
11296 --
11297 -- ----------------------------------------------------------------------------
11298 -- |-------------------------------< lck >------------------------------------|
11299 -- ----------------------------------------------------------------------------
11300 --
11301 procedure lck
11302 (
11303 p_prtt_enrt_rslt_id in number
11304 ,p_object_version_number in number
11305 ,p_effective_date in date
11306 ,p_datetrack_mode in varchar2
11307 ,p_validation_start_date out nocopy date
11308 ,p_validation_end_date out nocopy date
11309 ) is
11310 --
11311 --
11312 -- Declare cursors and local variables
11313 --
11314 l_proc varchar2(72); -- := g_package||'lck';
11315 l_validation_start_date date;
11316 l_validation_end_date date;
11317 --
11318 begin
11319 --
11320 g_debug := hr_utility.debug_enabled;
11321 if g_debug then
11322 l_proc := g_package||'lck';
11323 hr_utility.set_location('Entering:'|| l_proc, 10);
11324 end if;
11325 --
11326 ben_pen_shd.lck
11327 (
11328 p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
11329 ,p_validation_start_date => l_validation_start_date
11330 ,p_validation_end_date => l_validation_end_date
11331 ,p_object_version_number => p_object_version_number
11332 ,p_effective_date => p_effective_date
11333 ,p_datetrack_mode => p_datetrack_mode
11334 );
11335 --
11336 if g_debug then
11337 hr_utility.set_location(' Leaving:'||l_proc, 70);
11338 end if;
11339 --
11340 end lck;
11341
11342 --Start Bug 5768795
11343
11344 procedure chk_coverage_across_plan_types
11345 ( p_person_id in number,
11346 p_effective_date in date,
11347 p_lf_evt_ocrd_dt in date,
11348 p_business_group_id in number,
11349 p_pgm_id in number,
11350 p_minimum_check_flag in varchar default 'Y',
11351 p_suspended_enrt_check_flag in varchar default 'Y') is
11352
11353 cursor c_acrs_ptip is
11354 select acrs_ptip_cvg_id,
11355 mx_cvg_alwd_amt,
11356 mn_cvg_alwd_amt
11357 from ben_acrs_ptip_cvg_f
11358 where pgm_id = p_pgm_id
11359 and --p_effective_date between BUG 3051674
11360 p_lf_evt_ocrd_dt between
11361 effective_start_date and effective_end_date
11362 and business_group_id = p_business_group_id;
11363 --
11364 cursor c_prtt_total_bnft_amt(p_acrs_ptip_cvg_id number) is
11365 select sum(prt.bnft_amt)
11366 from ben_prtt_enrt_rslt_f prt,
11367 ben_ptip_f ptp
11368 where prt.pgm_id = p_pgm_id
11369 and prt.person_id = p_person_id
11370 and prt.sspndd_flag = 'N' -- # 3626176
11371 and prt.prtt_enrt_rslt_stat_cd is null
11372 and prt.effective_end_date = hr_api.g_eot
11373 and nvl(prt.enrt_cvg_thru_dt,hr_api.g_eot) = hr_api.g_eot
11374 and p_effective_date between
11375 prt.effective_start_date and prt.effective_end_date
11376 and prt.business_group_id = p_business_group_id
11377 and p_lf_evt_ocrd_dt between -- BUG 3051674 p_effective_date between
11378 ptp.effective_start_date and ptp.effective_end_date
11379 and ptp.acrs_ptip_cvg_id=p_acrs_ptip_cvg_id
11380 and ptp.ptip_id=prt.ptip_id
11381 and ptp.business_group_id=prt.business_group_id
11382 ;
11383 --Bug 3695005 fixes
11384 --This cursor needs to get suspended enrollments and
11385 --other enrollments. But it should exclude Interim coverages
11386 --here.
11387 --
11388 cursor c_prtt_total_bnft_amt_sspndd(p_acrs_ptip_cvg_id number) is
11389 select sum(prt.bnft_amt)
11390 from ben_prtt_enrt_rslt_f prt,
11391 ben_ptip_f ptp
11392 where prt.pgm_id = p_pgm_id
11393 and prt.person_id = p_person_id
11394 and ( prt.sspndd_flag = 'Y' or (
11395 prt.sspndd_flag = 'N' and not exists (
11396 select 'x'
11397 from ben_prtt_enrt_rslt_f prt1
11398 where prt1.person_id = p_person_id
11399 and prt1.pgm_id = p_pgm_id
11400 and PRT1.rplcs_sspndd_rslt_id = prt.prtt_enrt_rslt_id
11401 and prt1.per_in_ler_id = prt.per_in_ler_id
11402 and prt1.sspndd_flag = 'Y'
11403 and p_lf_evt_ocrd_dt between
11404 prt1.effective_start_date and prt1.effective_end_date
11405 and prt1.effective_end_date = hr_api.g_eot
11406 and prt1.enrt_cvg_thru_dt = hr_api.g_eot
11407 and prt1.prtt_enrt_rslt_stat_cd is null)))
11408 and prt.prtt_enrt_rslt_stat_cd is null
11409 and prt.effective_end_date = hr_api.g_eot
11410 and prt.enrt_cvg_thru_dt = hr_api.g_eot
11411 and p_effective_date between
11412 prt.effective_start_date and prt.effective_end_date
11413 and prt.business_group_id = p_business_group_id
11414 and p_lf_evt_ocrd_dt between -- BUG 3051674 p_effective_date between
11415 ptp.effective_start_date and ptp.effective_end_date
11416 and ptp.acrs_ptip_cvg_id=p_acrs_ptip_cvg_id
11417 and ptp.ptip_id=prt.ptip_id
11418 and ptp.business_group_id=prt.business_group_id
11419 ;
11420
11421 cursor c_pl_typ_names(p_acrs_ptip_cvg_id number) is
11422 select name
11423 from ben_pl_typ_f
11424 where pl_typ_id in
11425 ( select pl_typ_id
11426 from ben_ptip_f
11427 where pgm_id = p_pgm_id
11428 and acrs_ptip_cvg_id = p_acrs_ptip_cvg_id
11429 and business_group_id = p_business_group_id)
11430 and p_lf_evt_ocrd_dt between
11431 effective_start_date and effective_end_date;
11432 --
11433 l_output_names varchar2(4000);
11434 l_total_amt number;
11435 l_pl_typ_names varchar2(600);
11436 l_acrs_ptip c_acrs_ptip%rowtype;
11437
11438 l_proc varchar2(72) := 'ben_PRTT_ENRT_RESULT_api.chk_coverage_across_plan_types';
11439
11440 begin
11441
11442 if g_debug then
11443 hr_utility.set_location(' Entering '||l_proc, 70);
11444 end if;
11445
11446 if p_pgm_id is not NULL then
11447 --
11448 if g_debug then
11449 hr_utility.set_location('Check for min/max across ptip', 77);
11450 end if;
11451 --
11452 for l_acrs_ptip in c_acrs_ptip loop
11453 --
11454 if g_debug then
11455 hr_utility.set_location('Check for min/max across ptip', 78);
11456 end if;
11457 open c_prtt_total_bnft_amt(l_acrs_ptip.acrs_ptip_cvg_id);
11458 fetch c_prtt_total_bnft_amt into l_total_amt;
11459 close c_prtt_total_bnft_amt;
11460 if g_debug then
11461 hr_utility.set_location('total='||l_total_amt||' mn='||
11462 l_acrs_ptip.mn_cvg_alwd_amt||' mx='||l_acrs_ptip.mx_cvg_alwd_amt,20);
11463 end if;
11464 --
11465 -- bug 3123698
11466 open c_pl_typ_names(l_acrs_ptip.acrs_ptip_cvg_id);
11467 loop
11468 fetch c_pl_typ_names into l_pl_typ_names ;
11469 if c_pl_typ_names%notfound then
11470 exit;
11471 else if l_output_names is null then
11472 l_output_names := l_output_names||l_pl_typ_names;
11473 else if length(l_output_names ||','||l_pl_typ_names) <= 4000 then
11474 l_output_names := l_output_names ||','||l_pl_typ_names;
11475 else
11476 exit;
11477 end if;
11478 end if;
11479 end if;
11480 end loop;
11481 close c_pl_typ_names;
11482 -- end 3123698
11483 if l_acrs_ptip.mn_cvg_alwd_amt is not null and
11484 nvl(l_total_amt,0) < l_acrs_ptip.mn_cvg_alwd_amt and p_minimum_check_flag ='Y' then
11485
11486 --
11487 fnd_message.set_name('BEN','BEN_92179_BELOW_MIN_AMOUNT');
11488 fnd_message.set_token('TOT_AMT',nvl(l_total_amt,0));
11489 fnd_message.set_token('MIN_AMT',l_acrs_ptip.mn_cvg_alwd_amt);
11490 fnd_message.set_token('PL_TYP_NAMES',l_output_names); -- bug 3123698
11491 fnd_message.raise_error;
11492 --
11493 elsif l_acrs_ptip.mx_cvg_alwd_amt is not null and
11494 l_total_amt > l_acrs_ptip.mx_cvg_alwd_amt then
11495 --
11496 fnd_message.set_name('BEN','BEN_92180_ABOVE_MAX_AMOUNT');
11497 fnd_message.set_token('TOT_AMT',nvl(l_total_amt,0));
11498 fnd_message.set_token('MX_AMT',l_acrs_ptip.mx_cvg_alwd_amt);
11499 fnd_message.set_token('PL_TYP_NAMES',l_output_names); -- bug 3123698
11500 fnd_message.raise_error;
11501 --
11502 end if;
11503 --
11504 --Bug 3695005 Coverage Across Plan type considering
11505 --Suspended enrollment.
11506 --
11507
11508 if p_suspended_enrt_check_flag = 'Y' then
11509
11510 open c_prtt_total_bnft_amt_sspndd(l_acrs_ptip.acrs_ptip_cvg_id);
11511 fetch c_prtt_total_bnft_amt_sspndd into l_total_amt;
11512 close c_prtt_total_bnft_amt_sspndd;
11513 --
11514 if l_acrs_ptip.mx_cvg_alwd_amt is not null and
11515 l_total_amt > l_acrs_ptip.mx_cvg_alwd_amt then
11516 --
11517 fnd_message.set_name('BEN','BEN_92180_ABOVE_MAX_AMOUNT');
11518 fnd_message.set_token('TOT_AMT',nvl(l_total_amt,0));
11519 fnd_message.set_token('MX_AMT',l_acrs_ptip.mx_cvg_alwd_amt);
11520 fnd_message.set_token('PL_TYP_NAMES',l_output_names); -- bug 3123698
11521 fnd_message.raise_error;
11522 --
11523 end if;
11524 --
11525 if g_debug then
11526 hr_utility.set_location('total='||l_total_amt||' mn='||
11527 l_acrs_ptip.mn_cvg_alwd_amt||' mx='||l_acrs_ptip.mx_cvg_alwd_amt,20);
11528 end if;
11529 --
11530 end if; --p_suspended_enrt_check_flag
11531
11532 end loop; --c_acrs_ptip
11533 --
11534 end if;
11535
11536 if g_debug then
11537 hr_utility.set_location(' Leaving '||l_proc, 70);
11538 end if;
11539
11540
11541 end chk_coverage_across_plan_types;
11542
11543 --End Bug 5768795
11544 --
11545 -- ----------------------------------------------------------------------------
11546 -- |---------------------< multi_rows_edit >----------------------------------|
11547 -- ----------------------------------------------------------------------------
11548 --
11549 procedure multi_rows_edit
11550 (p_person_id in number,
11551 p_effective_date in date,
11552 p_business_group_id in number,
11553 p_pgm_id in number,
11554 p_per_in_ler_id in number default NULL,
11555 p_include_erl in varchar2,
11556 p_called_frm_ss in Boolean default FALSE
11557
11558 ) is
11559 --
11560 --Bug 3051674 We need to validate the edits with the life events
11561 --occured on date. This is an issue mainly for the open enrollment
11562 --If there is a change in the restrictions for the coverages etc.
11563 --Not using this for delete enrollment calls and corresponding
11564 --cursors.
11565 --
11566 cursor c_le_date(p_per_in_ler_id number) is
11567 select
11568 lf_evt_ocrd_dt
11569 from
11570 ben_per_in_ler pil
11571 where pil.per_in_ler_id = p_per_in_ler_id ;
11572 --
11573 l_lf_evt_ocrd_dt date ;
11574 --
11575 --End of 3051674 changes
11576 --
11577 -- If c1 or c1_pnip change, change the matching cursor in BENUTILS.pld
11578 -- enrt_pfc_deenrol procedure
11579 --
11580 Cursor c1 is
11581 Select r.prtt_enrt_rslt_id
11582 ,r.effective_start_date
11583 ,r.effective_end_date
11584 ,r.object_version_number
11585 ,r.pl_id
11586 ,r.pl_typ_id
11587 ,r.oipl_id
11588 ,r.pgm_id
11589 ,r.erlst_deenrt_dt
11590 ,r.person_id
11591 ,oipl.opt_id
11592 ,r.ptip_id
11593 ,r.enrt_mthd_cd --Bug 2200139
11594 From ben_prtt_enrt_rslt_f r,
11595 ben_oipl_f oipl,
11596 ben_elig_per_elctbl_chc c
11597 Where c.per_in_ler_id = p_per_in_ler_id
11598 and r.prtt_enrt_rslt_id = c.prtt_enrt_rslt_id
11599 and r.per_in_ler_id <> c.per_in_ler_id
11600 and r.person_id = p_person_id
11601 and nvl(r.pgm_id,-1) = p_pgm_id
11602 and r.effective_end_date = hr_api.g_eot
11603 and nvl(enrt_cvg_thru_dt,hr_api.g_eot) = hr_api.g_eot
11604 and r.prtt_enrt_rslt_stat_cd is null
11605 and c.comp_lvl_cd not in ('PLANFC', 'PLANIMP')
11606 and c.elctbl_flag = 'Y'
11607 /* BUG 3939785
11608 and (r.ENRT_OVRID_THRU_DT is null or
11609 r.ENRT_OVRID_THRU_DT < p_effective_date)
11610 */
11611 and ( r.enrt_ovridn_flag = 'N' /* Bug 3958064 */
11612 or
11613 ( r.enrt_ovridn_flag = 'Y' and nvl(r.ENRT_OVRID_THRU_DT,hr_api.g_eot) <= l_lf_evt_ocrd_dt ) -- 9114147
11614 )
11615 and oipl.oipl_id(+)=r.oipl_id
11616 and oipl.business_group_id(+)=r.business_group_id
11617 and p_effective_date between
11618 oipl.effective_start_date(+) and oipl.effective_end_date(+)
11619 --
11620 -- Bug 2600087 Added for finding the results which are not found
11621 -- when linked with epe records
11622 union
11623 Select r.prtt_enrt_rslt_id
11624 ,r.effective_start_date
11625 ,r.effective_end_date
11626 ,r.object_version_number
11627 ,r.pl_id
11628 ,r.pl_typ_id
11629 ,r.oipl_id
11630 ,r.pgm_id
11631 ,r.erlst_deenrt_dt
11632 ,r.person_id
11633 ,oipl.opt_id
11634 ,r.ptip_id
11635 ,r.enrt_mthd_cd
11636 From ben_prtt_enrt_rslt_f r,
11637 ben_oipl_f oipl
11638 Where r.per_in_ler_id <> p_per_in_ler_id
11639 and r.person_id = p_person_id
11640 and nvl(r.pgm_id,-1) = p_pgm_id
11641 and r.effective_end_date = hr_api.g_eot
11642 and nvl(enrt_cvg_thru_dt,hr_api.g_eot) = hr_api.g_eot
11643 and r.prtt_enrt_rslt_stat_cd is null
11644 and r.comp_lvl_cd not in ('PLANFC', 'PLANIMP')
11645 /* BUG 3939785
11646 and (r.ENRT_OVRID_THRU_DT is null or
11647 r.ENRT_OVRID_THRU_DT < p_effective_date)
11648 */
11649 and ( r.enrt_ovridn_flag = 'N' /* Bug 3958064 */
11650 or
11651 ( r.enrt_ovridn_flag = 'Y' and nvl(r.ENRT_OVRID_THRU_DT,hr_api.g_eot) <= l_lf_evt_ocrd_dt) -- 9114147
11652 )
11653 and oipl.oipl_id(+)=r.oipl_id
11654 and oipl.business_group_id(+)=r.business_group_id
11655 and p_effective_date between
11656 oipl.effective_start_date(+) and oipl.effective_end_date(+)
11657 --bug#2602124
11658 and not exists
11659 (
11660 select k.prtt_enrt_rslt_id
11661 from ben_elig_per_elctbl_chc k
11662 Where k.per_in_ler_id = p_per_in_ler_id
11663 and k.prtt_enrt_rslt_id = r.prtt_enrt_rslt_id
11664 and k.comp_lvl_cd not in ('PLANFC', 'PLANIMP')
11665 )
11666 --bug 4262697 We need to delete only if there are electable choices exists in this life event
11667 -- otherwise we don't need to delete.
11668 and exists
11669 (
11670 select k.elig_per_elctbl_chc_id
11671 from ben_elig_per_elctbl_chc k
11672 Where k.per_in_ler_id = p_per_in_ler_id
11673 and k.pl_id = r.pl_id
11674 and k.pgm_id= p_pgm_id
11675 and ((k.oipl_id is null and r.oipl_id is null) or
11676 (k.oipl_id = r.oipl_id )
11677 )
11678 )
11679 ;
11680
11681 --
11682 Cursor c1_pnip is
11683 Select r.prtt_enrt_rslt_id
11684 ,r.effective_start_date
11685 ,r.effective_end_date
11686 ,r.object_version_number
11687 ,r.pl_id
11688 ,r.pl_typ_id
11689 ,r.oipl_id
11690 ,r.pgm_id
11691 ,r.erlst_deenrt_dt
11692 ,r.person_id
11693 ,oipl.opt_id
11694 ,r.ptip_id
11695 ,r.enrt_mthd_cd
11696 From ben_prtt_enrt_rslt_f r
11697 ,ben_elig_per_elctbl_chc c
11698 ,ben_oipl_f oipl
11699 ,ben_pil_elctbl_chc_popl pel
11700 Where c.per_in_ler_id = p_per_in_ler_id
11701 and r.prtt_enrt_rslt_id = c.prtt_enrt_rslt_id
11702 and r.per_in_ler_id <> c.per_in_ler_id
11703 and r.person_id = p_person_id
11704 and r.prtt_enrt_rslt_stat_cd is null
11705 and r.pgm_id is NULL
11706 and pel.pgm_id is NULL
11707 and (pel.elcns_made_dt is not null or pel.dflt_asnd_dt is not NULL)
11708 and pel.pl_id = r.pl_id
11709 and c.pil_elctbl_chc_popl_id = pel.pil_elctbl_chc_popl_id
11710 and r.effective_end_date = hr_api.g_eot
11711 and nvl(enrt_cvg_thru_dt,hr_api.g_eot) = hr_api.g_eot
11712 and c.comp_lvl_cd not in ('PLANFC', 'PLANIMP')
11713 and c.elctbl_flag = 'Y'
11714 /*
11715 and (r.ENRT_OVRID_THRU_DT is null or
11716 r.ENRT_OVRID_THRU_DT < p_effective_date)
11717 */
11718 and ( r.enrt_ovridn_flag = 'N' /* Bug 3958064 */
11719 or
11720 ( r.enrt_ovridn_flag = 'Y' and nvl(r.ENRT_OVRID_THRU_DT,hr_api.g_eot) <= l_lf_evt_ocrd_dt) -- 9114147
11721 )
11722 and oipl.oipl_id(+)=r.oipl_id
11723 and oipl.business_group_id(+)=r.business_group_id
11724 and p_effective_date between
11725 oipl.effective_start_date(+) and oipl.effective_end_date(+)
11726 -- BUG: 3904792: MAINLINE FIX FOR 3894240: WHEN UPDATING A SAVINGS PLAN RATE SYSTEM IS END DATE
11727 AND NOT EXISTS
11728 (SELECT NULL
11729 FROM ben_ler_f ler,
11730 ben_pl_f pln
11731 WHERE ler.ler_id = r.ler_id
11732 AND ler.typ_cd = 'SCHEDDU'
11733 AND pln.SVGS_PL_FLAG = 'Y'
11734 and pln.pl_id = r.pl_id
11735 AND p_effective_date between pln.effective_start_date
11736 AND pln.effective_end_date
11737 AND p_effective_date between ler.effective_start_date
11738 AND ler.effective_end_date
11739 )
11740 -- BUG: 3904792: ENDS --
11741 ;
11742 --
11743 type l_tbl is table of c1%rowtype index by binary_integer;
11744 l_rec l_tbl;
11745 l_cnt Binary_integer := 0;
11746 l_proc varchar2(72); -- := g_package||'multi_rows_edit';
11747 l_effective_start_date date;
11748 l_effective_end_date date;
11749 l_pl_typ_id number;
11750 l_total_amt number;
11751 l_other_pen_rec ben_prtt_enrt_rslt_f%rowtype;
11752 l_rqd_perd_enrt_nenrt_uom varchar2(30);
11753 l_rqd_perd_enrt_nenrt_val number;
11754 l_rqd_perd_enrt_nenrt_rl number;
11755 l_level varchar2(30);
11756 l_effective_date date ;
11757 --
11758 --
11759 -- For program (if p_pgm_id is not null)
11760 --
11761 cursor no_lngr_elig_pgm_c is
11762 select pen.prtt_enrt_rslt_id,
11763 pen.object_version_number,
11764 pen.effective_start_date
11765 from ben_prtt_enrt_rslt_f pen
11766 where pen.per_in_ler_id = p_per_in_ler_id
11767 and pen.pgm_id = p_pgm_id
11768 and pen.prtt_enrt_rslt_stat_cd is null
11769 and pen.no_lngr_elig_flag = 'Y'
11770 and pen.effective_end_date = hr_api.g_eot
11771 and nvl(enrt_cvg_thru_dt,hr_api.g_eot) = hr_api.g_eot
11772 and pen.business_group_id = p_business_group_id;
11773 --
11774 -- For plan not in program (p_pgm_id is null)
11775 --
11776 cursor pl_typ_c is
11777 select distinct pln.pl_typ_id
11778 from ben_pil_elctbl_chc_popl pel,
11779 ben_pl_f pln
11780 where pel.per_in_ler_id = p_per_in_ler_id
11781 and pel.pgm_id is null
11782 and (pel.elcns_made_dt is not null or pel.dflt_asnd_dt is not NULL)
11783 and pln.pl_id = nvl(pel.pl_id, -1)
11784 and p_effective_date between
11785 pln.effective_start_date and pln.effective_end_date
11786 and pel.business_group_id = p_business_group_id
11787 and pln.business_group_id = p_business_group_id;
11788 --
11789 cursor no_lngr_elig_pnip_c is
11790 select pen.prtt_enrt_rslt_id,
11791 pen.object_version_number,
11792 pen.effective_start_date
11793 from ben_prtt_enrt_rslt_f pen
11794 where pen.pgm_id is null
11795 and pl_typ_id = l_pl_typ_id
11796 and pen.per_in_ler_id = p_per_in_ler_id
11797 and pen.prtt_enrt_rslt_stat_cd is null
11798 and pen.no_lngr_elig_flag = 'Y'
11799 and pen.effective_end_date = hr_api.g_eot
11800 and nvl(enrt_cvg_thru_dt,hr_api.g_eot) = hr_api.g_eot
11801 and pen.business_group_id = p_business_group_id;
11802 --
11803 cursor c_acrs_ptip is
11804 select acrs_ptip_cvg_id,
11805 mx_cvg_alwd_amt,
11806 mn_cvg_alwd_amt
11807 from ben_acrs_ptip_cvg_f
11808 where pgm_id = p_pgm_id
11809 and --p_effective_date between BUG 3051674
11810 l_lf_evt_ocrd_dt between
11811 effective_start_date and effective_end_date
11812 and business_group_id = p_business_group_id;
11813 --
11814 l_acrs_ptip c_acrs_ptip%rowtype;
11815 -- bug 3123698
11816 cursor c_pl_typ_names(p_acrs_ptip_cvg_id number) is
11817 select name
11818 from ben_pl_typ_f
11819 where pl_typ_id in
11820 ( select pl_typ_id
11821 from ben_ptip_f
11822 where pgm_id = p_pgm_id
11823 and acrs_ptip_cvg_id = p_acrs_ptip_cvg_id
11824 and business_group_id = p_business_group_id)
11825 and l_lf_evt_ocrd_dt between
11826 effective_start_date and effective_end_date;
11827 --
11828 l_pl_typ_names varchar2(600);
11829 l_output_names varchar2(4000);
11830 -- end 3123698
11831 --
11832 cursor c_prtt_total_bnft_amt(p_acrs_ptip_cvg_id number) is
11833 select sum(prt.bnft_amt)
11834 from ben_prtt_enrt_rslt_f prt,
11835 ben_ptip_f ptp
11836 where prt.pgm_id = p_pgm_id
11837 and prt.person_id = p_person_id
11838 and prt.sspndd_flag = 'N' -- # 3626176
11839 and prt.prtt_enrt_rslt_stat_cd is null
11840 and prt.effective_end_date = hr_api.g_eot
11841 and nvl(prt.enrt_cvg_thru_dt,hr_api.g_eot) = hr_api.g_eot
11842 and p_effective_date between
11843 prt.effective_start_date and prt.effective_end_date
11844 and prt.business_group_id = p_business_group_id
11845 and l_lf_evt_ocrd_dt between -- BUG 3051674 p_effective_date between
11846 ptp.effective_start_date and ptp.effective_end_date
11847 and ptp.acrs_ptip_cvg_id=p_acrs_ptip_cvg_id
11848 and ptp.ptip_id=prt.ptip_id
11849 and ptp.business_group_id=prt.business_group_id
11850 ;
11851 --Bug 3695005 fixes
11852 --This cursor needs to get suspended enrollments and
11853 --other enrollments. But it should exclude Interim coverages
11854 --here.
11855 --
11856 cursor c_prtt_total_bnft_amt_sspndd(p_acrs_ptip_cvg_id number) is
11857 select sum(prt.bnft_amt)
11858 from ben_prtt_enrt_rslt_f prt,
11859 ben_ptip_f ptp
11860 where prt.pgm_id = p_pgm_id
11861 and prt.person_id = p_person_id
11862 and ( prt.sspndd_flag = 'Y' or (
11863 prt.sspndd_flag = 'N' and not exists (
11864 select 'x'
11865 from ben_prtt_enrt_rslt_f prt1
11866 where prt1.person_id = p_person_id
11867 and prt1.pgm_id = p_pgm_id
11868 and PRT1.rplcs_sspndd_rslt_id = prt.prtt_enrt_rslt_id
11869 and prt1.per_in_ler_id = prt.per_in_ler_id
11870 and prt1.sspndd_flag = 'Y'
11871 and l_lf_evt_ocrd_dt between
11872 prt1.effective_start_date and prt1.effective_end_date
11873 and prt1.effective_end_date = hr_api.g_eot
11874 and prt1.enrt_cvg_thru_dt = hr_api.g_eot
11875 and prt1.prtt_enrt_rslt_stat_cd is null)))
11876 and prt.prtt_enrt_rslt_stat_cd is null
11877 and prt.effective_end_date = hr_api.g_eot
11878 and prt.enrt_cvg_thru_dt = hr_api.g_eot
11879 and p_effective_date between
11880 prt.effective_start_date and prt.effective_end_date
11881 and prt.business_group_id = p_business_group_id
11882 and l_lf_evt_ocrd_dt between -- BUG 3051674 p_effective_date between
11883 ptp.effective_start_date and ptp.effective_end_date
11884 and ptp.acrs_ptip_cvg_id=p_acrs_ptip_cvg_id
11885 and ptp.ptip_id=prt.ptip_id
11886 and ptp.business_group_id=prt.business_group_id
11887 ;
11888
11889 Cursor c_needs_dpnts (p_pl_typ_id number) is
11890 Select distinct r.prtt_enrt_rslt_id
11891 ,r.effective_start_date
11892 ,r.effective_end_date
11893 ,r.object_version_number
11894 ,r.pl_id
11895 ,r.pl_typ_id
11896 ,r.oipl_id
11897 ,r.pgm_id
11898 ,r.enrt_cvg_strt_dt
11899 ,c.elig_per_elctbl_chc_id
11900 ,c.dpnt_cvg_strt_dt_cd
11901 ,c.dpnt_cvg_strt_dt_rl
11902 ,pil.ler_id
11903 ,c.alws_dpnt_dsgn_flag
11904 ,pl.bnf_dsgn_cd
11905 From ben_prtt_enrt_rslt_f r,
11906 ben_elig_per_elctbl_chc c,
11907 ben_per_in_ler pil,
11908 ben_pl_f pl
11909 Where r.pl_typ_id = p_pl_typ_id
11910 and r.per_in_ler_id = p_per_in_ler_id
11911 and r.pgm_id = p_pgm_id
11912 and r.person_id = p_person_id
11913 and r.effective_end_date = hr_api.g_eot
11914 and r.enrt_cvg_thru_dt = hr_api.g_eot
11915 and r.prtt_enrt_rslt_stat_cd is null
11916 and r.prtt_enrt_rslt_id = c.prtt_enrt_rslt_id
11917 and r.per_in_ler_id = c.per_in_ler_id
11918 and c.comp_lvl_cd not in ('PLANFC', 'PLANIMP')
11919 and pil.per_in_ler_id = c.per_in_ler_id
11920 and pil.per_in_ler_stat_cd = 'STRTD'
11921 and pl.pl_id = r.pl_id
11922 and p_effective_date between
11923 pl.effective_start_date and pl.effective_end_date
11924 and ((c.alws_dpnt_dsgn_flag = 'Y'
11925 and not exists (select 'x' from ben_elig_cvrd_dpnt_f pdp
11926 where pdp.prtt_enrt_rslt_id = r.prtt_enrt_rslt_id
11927 and p_effective_date between
11928 pdp.effective_start_date and pdp.effective_end_date))
11929 OR
11930 (pl.bnf_dsgn_cd is not null
11931 and not exists (select 'x' from ben_pl_bnf_f pbn
11932 where pbn.prtt_enrt_rslt_id = r.prtt_enrt_rslt_id
11933 and p_effective_date between
11934 pbn.effective_start_date and pbn.effective_end_date)));
11935 --
11936 l_needs_dpnts c_needs_dpnts%rowtype;
11937 l_process_dpnt boolean := false;
11938 l_process_bnf boolean := false;
11939 l_env_rec ben_env_object.g_global_env_rec_type;
11940 --
11941 -- Bug 6656136
11942 cursor c_ler_typ_cd is
11943 --
11944 select ler.typ_cd
11945 from ben_per_in_ler pil,
11946 ben_ler_f ler
11947 where pil.per_in_ler_id = p_per_in_ler_id
11948 and pil.ler_id = ler.ler_id
11949 and pil.business_group_id = p_business_group_id
11950 and pil.business_group_id = ler.business_group_id
11951 and p_effective_date between
11952 ler.effective_start_date and ler.effective_end_date;
11953 --
11954 l_ler_typ_cd ben_ler_f.typ_cd%type;
11955 --
11956 begin
11957 --
11958 g_debug := hr_utility.debug_enabled;
11959 if g_debug then
11960 l_proc := g_package||'multi_rows_edit';
11961 hr_utility.set_location('Entering:'|| l_proc, 10);
11962 end if;
11963 --
11964 --Bug 4709601 we dont need to call multi_rows_edit in this case
11965 --
11966 if ben_sspndd_enrollment.g_cfw_flag = 'Y' then
11967 hr_utility.set_location('Leaving- called from CFW action items',15);
11968 return;
11969 end if;
11970 --
11971 if fnd_global.conc_request_id in (0,-1) then
11972 --
11973 --bug#3568529
11974 ben_env_object.get(p_rec => l_env_rec);
11975 if l_env_rec.benefit_action_id is null then
11976 --
11977 ben_env_object.init(p_business_group_id => p_business_group_id,
11978 p_effective_date => p_effective_date,
11979 p_thread_id => 1,
11980 p_chunk_size => 1,
11981 p_threads => 1,
11982 p_max_errors => 1,
11983 p_benefit_action_id => null);
11984 end if;
11985 --
11986 end if;
11987 --
11988 --
11989 --Bug 3051674 Get the le date
11990 --
11991 if p_per_in_ler_id is not null then
11992 --
11993 open c_le_date(p_per_in_ler_id);
11994 fetch c_le_date into l_lf_evt_ocrd_dt ;
11995 close c_le_date ;
11996 --
11997 end if ;
11998 --
11999 l_lf_evt_ocrd_dt := nvl(l_lf_evt_ocrd_dt,p_effective_date);
12000 --
12001 If p_per_in_ler_id is not NULL then
12002 If (p_pgm_id is not NULL) then
12003 For lrec in c1 loop
12004 l_cnt := l_cnt + 1;
12005 l_rec(l_cnt) := lrec;
12006 End loop;
12007 Else
12008 For lrec in c1_pnip loop
12009 l_cnt := l_cnt + 1;
12010 l_rec(l_cnt) := lrec;
12011 End loop;
12012 End if;
12013 --
12014 -- Remove any old enrollments - These are results where there was a choice
12015 -- in this same program for that comp object. And they didn't elect the
12016 -- comp object (the result doesn't have this per-in-ler). That must mean
12017 -- they don't want the enrollment anymore.
12018 --
12019 -- Before removing the enrollment, see if we can copy some of the dpnts or
12020 -- bnf's from the old enrollment (of the same plan type and program)
12021 -- to a new result.
12022 --
12023 For i in 1..l_cnt loop
12024
12025
12026 hr_utility.set_location('result id :'|| l_rec(i).prtt_enrt_rslt_id , 10);
12027
12028
12029 if l_rec(i).erlst_deenrt_dt is not null and
12030 l_rec(i).erlst_deenrt_dt>p_effective_date then
12031 ben_enrolment_requirements.find_rqd_perd_enrt(
12032 p_oipl_id =>l_rec(i).oipl_id
12033 ,p_opt_id =>l_rec(i).opt_id
12034 ,p_pl_id =>l_rec(i).pl_id
12035 ,p_ptip_id =>l_rec(i).ptip_id
12036 ,p_effective_date =>p_effective_date
12037 ,p_business_group_id =>p_business_group_id
12038 ,p_rqd_perd_enrt_nenrt_uom =>l_rqd_perd_enrt_nenrt_uom
12039 ,p_rqd_perd_enrt_nenrt_val =>l_rqd_perd_enrt_nenrt_val
12040 ,p_rqd_perd_enrt_nenrt_rl =>l_rqd_perd_enrt_nenrt_rl
12041 ,p_level =>l_level
12042 );
12043 --
12044 -- Got level now see if other enrt in level exists
12045 --
12046 if l_level is not null then
12047 ben_enrolment_requirements.find_enrt_at_same_level(
12048 p_person_id =>l_rec(i).person_id
12049 ,p_opt_id =>l_rec(i).opt_id
12050 ,p_oipl_id =>l_rec(i).oipl_id
12051 ,p_pl_id =>l_rec(i).pl_id
12052 ,p_ptip_id =>l_rec(i).ptip_id
12053 ,p_pl_typ_id =>l_rec(i).pl_typ_id
12054 ,p_pgm_id =>l_rec(i).pgm_id
12055 ,p_effective_date =>p_effective_date
12056 ,p_business_group_id =>p_business_group_id
12057 ,p_prtt_enrt_rslt_id =>l_rec(i).prtt_enrt_rslt_id
12058 ,p_level =>l_level
12059 ,p_pen_rec =>l_other_pen_rec
12060 );
12061 end if;
12062 end if;
12063 if l_other_pen_rec.prtt_enrt_rslt_id is not null or
12064 l_level is null or
12065 l_rec(i).erlst_deenrt_dt is null or
12066 l_rec(i).erlst_deenrt_dt<=p_effective_date then
12067 --
12068 if p_pgm_id is not null then
12069 for l_needs_dpnts in c_needs_dpnts(p_pl_typ_id => l_rec(i).pl_typ_id)
12070 loop
12071 --
12072 if l_needs_dpnts.alws_dpnt_dsgn_flag = 'Y' then
12073 l_process_dpnt := true;
12074 else
12075 l_process_dpnt := false;
12076 end if;
12077 if l_needs_dpnts.bnf_dsgn_cd is not null then
12078 l_process_bnf := true;
12079 else
12080 l_process_bnf := false;
12081 end if;
12082 --
12083 ben_mng_dpnt_bnf.recycle_dpnt_bnf
12084 (p_validate => FALSE
12085 ,p_new_prtt_enrt_rslt_id => l_needs_dpnts.prtt_enrt_rslt_id
12086 ,p_old_prtt_enrt_rslt_id => l_rec(i).prtt_enrt_rslt_id
12087 ,P_NEW_ENRT_RSLT_OVN => l_needs_dpnts.object_version_number
12088 ,p_new_elig_per_elctbl_chc_id => l_needs_dpnts.elig_per_elctbl_chc_id
12089 ,p_person_id => p_person_id
12090 ,p_return_to_exist_cvg_flag => 'N'
12091 ,p_old_pl_id => l_rec(i).pl_id
12092 ,p_new_pl_id => l_needs_dpnts.pl_id
12093 ,p_old_oipl_id => l_rec(i).oipl_id
12094 ,p_new_oipl_id => l_needs_dpnts.oipl_id
12095 ,p_old_pl_typ_id => l_rec(i).pl_typ_id
12096 ,p_new_pl_typ_id => l_needs_dpnts.pl_typ_id
12097 ,p_pgm_id => p_pgm_id
12098 ,p_ler_id => l_needs_dpnts.ler_id
12099 ,p_per_in_ler_id => p_per_in_ler_id
12100 ,p_dpnt_cvg_strt_dt_cd => l_needs_dpnts.dpnt_cvg_strt_dt_cd
12101 ,p_dpnt_cvg_strt_dt_rl => l_needs_dpnts.dpnt_cvg_strt_dt_rl
12102 ,p_business_group_id => p_business_group_id
12103 ,p_ENRT_CVG_STRT_DT => l_needs_dpnts.enrt_cvg_strt_dt
12104 ,p_effective_date => p_effective_date
12105 ,p_datetrack_mode => hr_api.g_update -- note below
12106 ,p_process_dpnt => l_process_dpnt
12107 ,p_process_bnf => l_process_bnf);
12108 -- if the datetrack mode of update causes problems, then we'll need
12109 -- to pass the datetrack mode in from the form. Each enrollment
12110 -- library will need to change. We'd also probably want to pass in
12111 -- the dtmode from benauten, beneadeb and bensuenr.
12112 end loop;
12113 end if; -- if pgm_id is not null
12114 --
12115 -- Bug 2200139 If the old enrollment started in Future from Override Enrollment
12116 -- Pass the p_effective_date as effective_start_date + 1 to handle
12117 -- the deenroll and also backout cases.
12118 --
12119 if l_rec(i).effective_start_date >= p_effective_date then
12120 l_effective_date := l_rec(i).effective_start_date + 1 ;
12121 else
12122 l_effective_date := p_effective_date ;
12123 end if ;
12124 --
12125 delete_enrollment
12126 (p_validate => FALSE
12127 ,p_per_in_ler_id => p_per_in_ler_id
12128 ,p_prtt_enrt_rslt_id => l_rec(i).prtt_enrt_rslt_id
12129 ,p_business_group_id => p_business_group_id
12130 ,p_effective_start_date => l_rec(i).effective_start_date
12131 ,p_effective_end_date => l_rec(i).effective_end_date
12132 ,p_object_version_number => l_rec(i).object_version_number
12133 ,p_effective_date => l_effective_date
12134 ,p_datetrack_mode => hr_api.g_delete
12135 ,p_multi_row_validate => FALSE
12136 ,p_source => 'bepenapi'
12137 );
12138 end if;
12139 End loop;
12140 --
12141 if g_debug then
12142 hr_utility.set_location('Del rslts no lngr elig for', 30);
12143 end if;
12144 --
12145 -- Take care of enrollments no longer eligible for
12146 --
12147 -- In Program
12148 --
12149 if p_pgm_id is not null then
12150 --
12151 For rslt in no_lngr_elig_pgm_c Loop
12152 -- Bug 2200139
12153 if rslt.effective_start_date >= p_effective_date then
12154 l_effective_date := rslt.effective_start_date + 1 ;
12155 else
12156 l_effective_date := p_effective_date ;
12157 end if ;
12158 --
12159 if g_debug then
12160
12161 hr_utility.set_location('Del rslt in Pgm no lngr elig for:' ||
12162 to_char(p_pgm_id)||' rslt:'||
12163 to_char(rslt.prtt_enrt_rslt_id), 35);
12164 end if;
12165 delete_enrollment
12166 (p_validate => FALSE
12167 ,p_per_in_ler_id => p_per_in_ler_id
12168 ,p_prtt_enrt_rslt_id => rslt.prtt_enrt_rslt_id
12169 ,p_business_group_id => p_business_group_id
12170 ,p_effective_start_date => l_effective_start_date
12171 ,p_effective_end_date => l_effective_end_date
12172 ,p_object_version_number => rslt.object_version_number
12173 ,p_effective_date => l_effective_date
12174 ,p_datetrack_mode => hr_api.g_delete
12175 ,p_multi_row_validate => FALSE
12176 ,p_source => 'bepenapi'
12177 );
12178 --
12179 End Loop;
12180 --
12181 else
12182 -- not in program
12183 --
12184 For typ In pl_typ_c Loop
12185 --
12186 l_pl_typ_id := typ.pl_typ_id;
12187 --
12188 if g_debug then
12189 hr_utility.set_location('Del rslt no lngr elig for for pl type '||
12190 to_char(l_pl_typ_id), 37);
12191 end if;
12192 --
12193 For rslt In no_lngr_elig_pnip_c Loop
12194 --
12195 -- Bug 2200139
12196 if rslt.effective_start_date >= p_effective_date then
12197 l_effective_date := rslt.effective_start_date + 1 ;
12198 else
12199 l_effective_date := p_effective_date ;
12200 end if ;
12201 --
12202 delete_enrollment
12203 (p_validate => FALSE
12204 ,p_per_in_ler_id => p_per_in_ler_id
12205 ,p_prtt_enrt_rslt_id => rslt.prtt_enrt_rslt_id
12206 ,p_business_group_id => p_business_group_id
12207 ,p_effective_start_date => l_effective_start_date
12208 ,p_effective_end_date => l_effective_end_date
12209 ,p_object_version_number => rslt.object_version_number
12210 ,p_effective_date => l_effective_date
12211 ,p_datetrack_mode => hr_api.g_delete
12212 ,p_multi_row_validate => FALSE
12213 ,p_source => 'bepenapi'
12214 );
12215 --
12216 End Loop;
12217 --
12218 End Loop;
12219 --
12220 End if;
12221 --
12222 End if;
12223 --
12224 if not p_called_frm_ss then
12225 --
12226 ben_newly_ineligible.defer_delete_enrollment -- Defer ENH
12227 (p_per_in_ler_id => p_per_in_ler_id,
12228 p_person_id => p_person_id,
12229 p_business_group_id => p_business_group_id,
12230 p_effective_date => l_lf_evt_ocrd_dt
12231 );
12232 --
12233 --Start Bug 5768795
12234 --Moved the Code to the below called procedure. chk_coverage_across_plan_types is now externalized
12235 --to be called from benrtchg.pkb.
12236
12237 chk_coverage_across_plan_types
12238 ( p_person_id => p_person_id,
12239 p_effective_date => p_effective_date,
12240 p_lf_evt_ocrd_dt => l_lf_evt_ocrd_dt,
12241 p_business_group_id => p_business_group_id,
12242 p_pgm_id => p_pgm_id);
12243
12244 --End Bug 5768795
12245
12246 --
12247 -- Call multi row edit.
12248 --
12249 open c_ler_typ_cd;
12250 fetch c_ler_typ_cd into l_ler_typ_cd;
12251 close c_ler_typ_cd;
12252 --
12253 -- Bug 6656136
12254 if l_ler_typ_cd in ('SCHEDDO','SCHEDDA') then
12255 --
12256 BEN_PEN_bus.multi_rows_edit
12257 (p_person_id => p_person_id
12258 ,p_effective_date => l_lf_evt_ocrd_dt
12259 ,p_business_group_id => p_business_group_id
12260 ,p_pgm_id => p_pgm_id
12261 ,p_include_erl => p_include_erl
12262 );
12263 --
12264 else
12265 --
12266 BEN_PEN_bus.multi_rows_edit
12267 (p_person_id => p_person_id
12268 ,p_effective_date => p_effective_date
12269 ,p_business_group_id => p_business_group_id
12270 ,p_pgm_id => p_pgm_id
12271 ,p_include_erl => p_include_erl
12272 );
12273 --
12274 end if;
12275 --
12276 -- Bug 6656136
12277 end if; -- p_called_frm_ss
12278 --
12279 if g_debug then
12280 hr_utility.set_location(' Leaving:'||l_proc, 70);
12281 end if;
12282 --
12283 end multi_rows_edit;
12284 --
12285 -- Overloaded
12286 --
12287
12288
12289
12290
12291 procedure multi_rows_edit
12292 (p_person_id in number,
12293 p_effective_date in date,
12294 p_business_group_id in number,
12295 p_pgm_id in number,
12296 p_per_in_ler_id in number default NULL,
12297 p_called_frm_ss in Boolean default FALSE
12298
12299 ) is
12300 begin
12301 ben_prtt_enrt_result_api.multi_rows_edit(p_person_id=> p_person_id
12302 ,p_effective_date => p_effective_date
12303 ,p_business_group_id => p_business_group_id
12304 ,p_pgm_id => p_pgm_id
12305 ,p_per_in_ler_id => p_per_in_ler_id
12306 ,p_include_erl => 'N'
12307 ,p_called_frm_ss => p_called_frm_ss ); -- BUG 4690334
12308 end multi_rows_edit;
12309 --
12310 --
12311 -- ----------------------------------------------------------------------------
12312 -- |---------------------------< update_person_type_usages >----------------------------|
12313 -- ----------------------------------------------------------------------------
12314 --
12315 -- VP 11/08/00
12316 --
12317 Procedure update_person_type_usages
12318 (p_person_id in number,
12319 p_business_group_id in number,
12320 p_effective_date in date
12321 ) is
12322 --
12323 l_proc varchar2(72); -- := g_package||'update_person_type_usages';
12324 --
12325 Begin
12326
12327 g_debug := hr_utility.debug_enabled;
12328 if g_debug then
12329 l_proc := g_package||'update_person_type_usages';
12330 hr_utility.set_location('Entering:'||l_proc, 5);
12331 end if;
12332 --
12333 --
12334 if (g_enrollment_change) then
12335 --
12336 ben_pen_bus.manage_per_type_usages
12337 (p_person_id => p_person_id
12338 ,p_business_group_id => p_business_group_id
12339 ,p_effective_date => p_effective_date
12340 );
12341 null;
12342 --
12343 end if;
12344
12345 g_enrollment_change := FALSE;
12346 --
12347 if g_debug then
12348 hr_utility.set_location(' Leaving:'||l_proc, 10);
12349 end if;
12350 --
12351 End update_person_type_usages;
12352
12353 -- ----------------------------------------------------------------------------
12354 -- |------------------------< delete_enrollment_w >-----------------------------|
12355 -- ----------------------------------------------------------------------------
12356 --
12357 -- Description: Self-service wrapper for delete_enrollment to handle exceptions
12358 --
12359 procedure delete_enrollment_w
12360 (p_validate in boolean default false
12361 ,p_per_in_ler_id in number default NULL
12362 ,p_lee_rsn_id in number default NULL
12363 ,p_enrt_perd_id in number default NULL
12364 ,p_prtt_enrt_rslt_id in number
12365 ,p_business_group_id in number
12366 ,p_effective_start_date out nocopy date
12367 ,p_effective_end_date out nocopy date
12368 ,p_object_version_number in out nocopy number
12369 ,p_effective_date in date
12370 ,p_datetrack_mode in varchar2
12371 ,p_multi_row_validate in boolean default TRUE
12372 ,p_source in varchar2 default null
12373 ,p_enrt_cvg_thru_dt in date default null
12374 ,p_mode in varchar2 default null)
12375 is
12376 l_proc varchar2(72) := g_package||'delete_enrollment_w';
12377 begin
12378 fnd_msg_pub.initialize;
12379
12380 if g_debug then
12381 hr_utility.set_location('Entering:'||l_proc, 5);
12382 end if;
12383
12384 delete_enrollment
12385 (p_validate => p_validate
12386 ,p_per_in_ler_id => p_per_in_ler_id
12387 ,p_lee_rsn_id => p_lee_rsn_id
12388 ,p_enrt_perd_id => p_enrt_perd_id
12389 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
12390 ,p_business_group_id => p_business_group_id
12391 ,p_effective_start_date => p_effective_start_date
12392 ,p_effective_end_date => p_effective_end_date
12393 ,p_object_version_number => p_object_version_number
12394 ,p_effective_date => p_effective_date
12395 ,p_datetrack_mode => p_datetrack_mode
12396 ,p_multi_row_validate => p_multi_row_validate
12397 ,p_enrt_cvg_thru_dt => p_enrt_cvg_thru_dt
12398 ,p_mode => p_mode);
12399
12400 if g_debug then
12401 hr_utility.set_location('Leaving:'||l_proc, 10);
12402 end if;
12403
12404 exception
12405 --
12406 when app_exception.application_exception then --Bug 4387247
12407 hr_utility.set_location ('Application Error in delete_enrollment_w.', 88);
12408 fnd_msg_pub.add;
12409 when others then
12410 if g_debug then
12411 hr_utility.set_location('Exception:'||l_proc, 100);
12412 end if;
12413 hr_utility.set_location ('Other Error in delete_enrollment_w : '|| sqlerrm , 89);
12414 --Bug 4387247
12415 fnd_message.set_name('PER','FFU10_GENERAL_ORACLE_ERROR');
12416 fnd_message.set_token('2',substr(sqlerrm,1,200));
12417 fnd_msg_pub.add;
12418 --
12419 end delete_enrollment_w;
12420 --
12421
12422 end ben_PRTT_ENRT_RESULT_api;