1 PACKAGE BODY ben_enrollment_action_items as
2 /* $Header: benactcm.pkb 120.38 2011/02/07 09:59:34 pvelvano ship $ */
3 --
4 /*
5 --
6 Name
7 Determine Enrollment Action Items - ENTE66R06
8 Purpose
9 This package is used to check enrollment action items. It is meant to be
10 used in the enrollment process. As a batch job with several entry points
11 callable by other processes.
12 Process 1) Determines if an enrollment action item(s) need to be written
13 when a person enrolls in a plan. Check dependents and beneficiary info.
14 2) Updates new enrollment action item(s) when an enrollment is changed.
15 3) Updates enrollment when an action item is completed in Designate Dpnt,
16 Desginate Beneficiary or Certification forms.
17 4) Create Certifications required for a person to complete action items.
18 5) Suspends an enrollment when an action item is created.
19 --------------------------------------------------------------------------------
20 History
21 -------
22 Version Date Author Comment
23 -------+----------+----------------+------------------------------------------
24 110.0 22 Apr 98 J Schneider Created.
25 110.1 06 Jun 98 S Tee Fixed invalid cursor when creating a BNF
26 action item and also BNFADDNL cursor,
27 c_cntngnt_types as it was not selecting
28 any rows.
29 110.2 06 Jun 98 J Schneider fixed DD if no dependents. changed
30 get_enrt_actn_id to return object_version_
31 number for updates.
32 110.3 08 Jun 98 J Schneider change to write multiple DDCTFN, BNFCTFN
33 added deenrollment proc
34 110.4 09 Jun 98 J Schneider added cmpltd_dt support get_enrt_actn_id
35 p_suspend_flag added
36 110.5 10 Jun 98 J Schneider uncommented exit
37 110.6 11 Jun 98 J Schneider moved suspend_actn stuff to API ben_prtt_
38 enrt_actn_f so all action items will
39 suspend enrt if new or cmpltd_dt is NULL
40 110.7 13 Jun 98 J Schneider l_g_suspend,l_suspend_flag rechecked for
41 problems
42 110.8 15 Jun 98 J Schneider ben_dsgn_rqmt_f now uses oipl_id
43 110.9 15 Jun 98 J Schneider redo oipl pl dsgn_rqmt
44 110.10 16 Jun 98 J Schneider dsgn_rqmt needs more work for DDADDNL
45 110.11 17 Jun 98 J Schneider recheck for DDADDNL if no dependents found
46 110.12 18 Jun 98 J Schneider return suspend flag at all times
47 110.13 18 Jun 98 J Schneider 110.13 typo
48 110.14 18 Jun 98 J Schneider DDADDNL redone
49 110.15 23 Jun 98 J Schneider fix DD and suspend mode
50 110.16 30 Jun 98 J Schneider datetrack_mode changes when doing updates,
51 get_enrt_actn_id a proc
52 110.17 07 Jul 98 J Mohapatra Added batch who cols in call to ben_cvrd_
53 dpnt_ctfn_prvdd_api.create...
54 110.18 15 Jul 98 J Schneider add exception handlers, fix dpnt ctfns.
55 110.19 16 Jul 98 J Schneider dependent certifications changes
56 110.20 17 Jul 98 J Schneider post rslt flag added for calls to suspend
57 enrollment
58 110.21 22 Jul 98 maagrawa rslt_object_version_number added to calls
59 to suspend enrollment.
60 115.10 12 Oct 98 bbulusu Modified a lot of procedures and functions
61 that go against action items to handle
62 dpnts and bnfs. Added out nocopy parameters to
63 determine_action_items to send msgs back
64 to forms. Made dpnt dsgn rqmts work at
65 plan and option level. Modified call to
66 delete_prtt_enrt_actn_. Wrote the get_due_
67 date function. Modified the check_bnf_ttee
68 func to check if a trustee is assigned.
69 115.11 26 Oct 98 bbulusu Modified get_due_dt function
70 115.12 06 Nov 98 bbulusu Fixed determine_bnf_action_items to insert
71 an opitional action item if the dsgn rqmt
72 is optional. Fixed the get_due_date func
73 to not error out nocopy if popl_actn_typ notfound
74 115.13 09 Dec 98 bbulusu Fixed problem with warning flags not being
75 returned.
76 115.14 10-Dec-98 lmcdonal re-write complete_dependent_designation.
77 115.15 22-Dec-98 bbulusu Fixed determine_bnf_actn_items to complete
78 a BNF actn item if one already exists and
79 bnfs are found Fixed determine_dpnt_actn_
80 items to complete a DD actn item if one
81 already exists and dpns are found Added
82 calls to the close unresolved actn items
83 batch process. Removed complete_all_actn_
84 items procedure (redundant). Fixed determ
85 ine_bnf_actn_items to delete all other bnf
86 actn item when a BNF actn item is written.
87 Minor fix to complete_dpnt_dsgn don't
88 need to check to see if an actn item was
89 found before calling process_action_item.
90 115.16 22-Dec-98 bbulusu uncommented exit statement.
91 115.17 28-Dec-98 stee Set the default for post_rslt_flag = 'Y'.
92 115.18 30-Dec-98 bbulusu Removed call to cls unresolved actn items.
93 115.19 24-Feb-99 bbulusu Modified check_dpnt_ctfn. Modified cursors
94 c_dpnt_ctfn_pl, c_dpnt_ctfn_pgm, c_dpnt_
95 ctfn_ptip to select dpnt ctfns based on
96 the contact type. Added function
97 check_ctfns_defined.
98 115.20 02-Mar-99 bbulusu Modified check_bnf_ctfn and determine_bnf
99 _actn_items for bug fixes.
100 115.21 04-Mar-99 bbulusu Modified get_due_dt and determine_bnf_miss
101 _actn_items.
102 115.22 08-Mar-99 tmathers Changed the not-equal operators to <>.
103 115.23 23-Mar-99 bbulusu Modified determine_addnl_bnf
104 115.24 29-Apr-99 bbulusu Fixed determine_addnl_bnf to pick up all
105 bnfs that are not spouses.
106 115.25 29-APR-99 shdas Added pl_typ_id,opt_id,ler_id,
107 business_group_id organization_id,
108 assignment_id to the parameter list of
109 genutils.formula
110 115.26 03-may-99 shdas Added jurisdiction_code.
111 115.28 08-may-99 jcarpent Check ('VOIDD', 'BCKDT') for pil stat cd
112 115.29 13-may-99 jcarpent More of same.
113 115.30 02-Jun-99 bbulusu Fix to not call check_bnf_ttee if dob is
114 not found for the bnf.
115 115.31 07-Jul-99 maagrawa Modified determine_dpnt_miss_actn_items
116 to work for plans not in programs.
117 115.32 09-Jul-99 bbulusu Added checks for backed out nocopy life evts.
118 115.33 14-Jul-99 maagrawa Corrected opening of cursor c_nsc_ctfn_pl.
119 Use of bnf_ctfn_rqd_flag and
120 dpnt_dsgn_no_ctfn_rqd_flag negated.
121 115.34 20-JUL-99 Gperry genutils -> benutils package rename.
122 115.35 24-Aug-99 maagrawa Changes related to breaking of dependents
123 table.
124 115.36 07-Sep-99 tguy fixed call to pay_mag_util
125 115.37 27-Sep-99 maagrawa Modified Check procedures for prtt, dpnt,
126 bnf certifications. Created new procedure
127 process_new_ctfn_action to create/update
128 a action item when new ctfn is created.
129 115.38 27-Sep-99 tguy Modified call to determine_date to
130 accomadate new codes.
131 115.39 12-Oct-99 stee Fixed enrollment certification for
132 benefit amount. Cursor c_ecc2 was
133 selecting comparing choice id to bnft_id.
134 Also set the enrt_ctfn_warning flag.
135 115.40 12-Nov-99 lmcdonal Better debugging messages.
136 115.41 09-Dec-99 maagrawa Call the date routine to calculate the
137 action item due date only if the date
138 code is not null.
139 115.42 10-Jan-00 lmcdonal If bnf dsgn is optional, do not make the
140 BNF% actions rqd.
141 115.43 14-Jan-00 lmcdonal Bug 1148447: When dpnt ctfn's are at PTIP lvl,
142 process was not writing actions nor ctfns
143 because pgm and ptip ids were not being passed
144 to check_ctfns_defined. Also, removed use of
145 lack...flag, using rqd_flag instead for dpnts.
146 115.44 17-Jan-00 TMathers Fixed syntax error in previous fix.
147 115.45 31-Mar-00 MMogel Added tokens to messages to make messages
148 more meaningful to the user
149 115.46 31-mar-00 shdas don't always create a rqd action item for addnl dpnt(3629).
150 115.47 03-apr-00 shdas bring c_chc_flags cursor into process_dpnt_action_items
151 from complete_dependent_desigantion and determine_dpnt_action_items.
152 115.48 12-May-00 lmcdonal Bug 1249901. before writing bnft ctfn's, check
153 if cvg entered at enrt, then entered amt greater
154 than max-wout-ctfn.
155 115.49 06-Jul-00 kmahendr Bug 5140- sub-query to get contact_type returns more than
156 one row as dependent may be a contact to more than one
157 participant. All the sub-query to get contact_type were
158 modified by adding prtt_person_id in the where clause
159 115.50 07-Jul-00 kmahendr Bug#1319520 is fixed on version 115.46 for aera
160 115.51 07-Jul-00 kmahendr Changes made in 115.50 applied to 115.49
161 115.52 18-Jul-00 bbulusu Fixed bug #5386. Added code to check for
162 ctfns defined in the ben_ler_chg_dpnt_
163 cvg_ctfn_f table for dpnt change of life
164 events.
165 115.53 08-Aug-00 bbulusu Bug 5432. Ctfn being recreated in
166 subsequenct life event.
167 115.54 15-Aug-00 IAli PCP Required for Participant and for Dependent process is added
168 115.55 16-Aug-00 IAli Fixed the infinite loop in determine_pcp_action procedure
169 115.56 19-Aug-00 Shdas added process_pcp_actn_items and
170 and process_pcp_dpnt_actn_items.
171 115.57 25-Aug-00 Shdas added warnings for process_pcp_actn_items
172 and process_pcp_dpnt_actn_items.
173 115.58 28-Aug-00 cdaniels OraBug# 4988. Suppressed raising of
174 error 91457 when alws_dpnt_desgn_flag
175 and dpnt_dsgn_cd not found for a
176 specified enrt_rslt_id and effective
177 date. Defaulted these values to 'N'
178 and 'O', respectively, for the case
179 when not found.
180 115.59 29-Aug-00 jcarpent Merge of 57 and 58 changes. 57 changes
181 were not ready for primetime so leaped
182 now in synch.
183 115.60 06-Sep-00 jcarpent 1269016. Handling of future change dt mode.
184 115.61 07-Sep-00 jcarpent Changes from 115.60 based on version 115.58.
185 Leapfrog version not containing pcp stuff.
186 115.62 07-Sep-00 jcarpent Same as version
187 115.63 26-Oct-00 pbodla - Enhancement : Pass contact person id as
188 input value for "certification required
189 when rule" if the rule is for contacts.
190 115.64 27-Oct-00 pbodla - param1(CON_PERSON_ID) passed to formula
191 115.65 15-Nov-00 jcarpent Bug 1488666. Was creating same ctfn
192 2 times because both cursors ecc1+2
193 were returning the same row.
194 115.66 22-Nov-00 jcarpent Bug 1488666. Was creating same ctfn
195 when one was a benefit ctfn and one
196 was an enrt ctfn. No need for both.
197 115.67 29-Dec-00 ikasire bug fix 1491912
198 115.68 08-mar-01 ikasire bug fix 1421978 modified the pcp cursors
199 for dependent and participant
200 115.69 20-apr-01 ikasire bug 1421978 Only one action item for pcp
201 is created for all the dependents of the
202 prtt. This is fixed to get the pcp
203 action item one for each dependent.
204 Added p_elig_cvrd_dpnt_id parameter to the
205 determine_pcp_dpnt_actn_items procedure.
206 Also passed p_elig_cvrd_dpnt_id parameter
207 for the call to get_prtt_enrt_actn_id and
208 process_action_item procedures from the
209 determine_pcp_dpnt_actn_items procedure.
210 115.70 25-Apr-01 maagrawa Performance changes.
211 115.71 17-May-01 maagrawa More Performance changes.
212 115.72 17-May-01 maagrawa Added exit statement.
213 115.73 02-Jul-01 kmahendr Bug#1842614- increased l_pln_name variable to 80
214 115.74 27-aug-01 tilak bug:1949361 jurisdiction code is
215 derived inside benutils.formula.
216 115.75 26-Dec-01 pabodla bug:1857685 - Do not create dependent and
217 beneficiary related action items for
218 waive plans and options.
219 115.76 08-FEB-02 aprabhak added an action item for future salary
220 increase
221 115.77 21-FEB-02 ikasire bug 2228123 getting the suspend_flag in
222 determine_action_items procedure
223 115.78 02-MAR-02 aprabhak modified the salary cursor to pickup
224 only salary increase plan
225 115.79 08-MAR-02 aprabhak Modified the future salary cursor.
226 Removed the rate join.
227 115.80 14-Mar-02 rpillay UTF8 Changes Bug 2254683
228 115.81 30-Apr-02 kmahendr Added token to message 91832.
229 115.82 23-May-02 ikasire Bug 2389261 Inconsistent results due to
230 not exclusion on epe with bnft_prvdr_pool_id
231 from the cursors
232 115.83 30-May-02 ikasire Bug 2386000 Added p_called_from to the
233 delete_cvrd_dpnt_ctfn_prvdd call
234 115.84 08-Jun-02 pabodla Do not select the contingent worker
235 assignment when assignment data is
236 fetched.
237 115.85 30-jul-02 hnarayan bug 1169240 - added the function
238 check_bnf_actn_item_dfnd to check for
239 any action items defined for beneficiaries
240 115.86 26-DEC-02 kichoudh NOCOPY changes
241 115.87 13-feb-03 hnarayan hr_utility.set_location - 'if g_debug' changes
242 115.88 21-Mar-03 mmudigon Bug 2858700. Added dt condition and order
243 by clause to cursor c_dpnt_bnf_adrs.
244 115.89 24-Mar-03 mmudigon Bug 2858700 continued. Added order by
245 clause to cursor c_prtt_adrs.
246 115.90 22-Jul-03 ikasire Bug 3042379 dont create action items for the
247 interim enrollment. defensive code.
248 115.91 19-Aug-03 ikasire Bug 3105160 added raise in the exception clause.
249 115.92 25-aug-03 kmahendr Bug#3108422 - if ERL is the cvg_mlt_cd certification action item
250 is called.
251 115.93 26-aug-03 kmahendr Condition modified for ERL
252 115.94 08-aug-03 pbodla Bug 3183266 : For flat range mx_wout_ctfn_val
253 will be null, so use nvl around it.
254 115.95 17-oct-03 hmani Modified the arg passed to
255 write_new_bnf_ctfn_item call - Bug 3196152
256 115.96 05-Nov-03 tjesumic contact_type are expected to have more than one row for epnt
257 sub query failing due to =, now changed to in # 3228530
258 115.97 13-Nov-03 bmanyam Bug.3248711. Allowing Dpnt Dsgn Action item to get created,
259 when (epe.alws_dpnt_dsgn_flag = 'Y' OR epe.dpnt_dsgn_cd = 'R'
260 115.98 17-Dec-03 vvprabhu Added the assignment for g_debug at the start
261 of each public procedure
262 115.99 21-Jan-2003 vvprabhu Added the assignment for g_debug at the start
263 of each public Function
264 115.100 20-Feb-2004 kmahendr Bug#3442729 - added codes to set_cmpltd_dt
265 115.101 19-Apr-2004 bmanyam Bug# 3510501 - In the date_track_verify method,
266 set the date-track-mode to UPDATE, in the ELSE..part.
267 115.102 01-Jun-2004 kmahendr Bug#3643597 - added a new private procedure
268 check_ctfn_prvdd.
269 115.103 02-Jun-2004 kmahendr Bug#3643597 - cursor c_prtt_enrt_rslt modified.
270 115.104 03-jun-2004 kmahendr Bug#3643597 - cursor c_prtt_enrt_rslt modified.
271 115.105 01-jul-2004 bmanyam Bug#3730053 - cursor c_emp_only modified.
272 OIPL level DSGN_RQMTS override OPT level
273 115.106 01-jul-2004 kmahendr bug#3590524 - Added codes to check_ctfn_prvdd
274 115.107 21-jul-2004 rpgupta bug#3771346 - If waive flag not checked at option level, check at the plan level
275 115.108 29-jul-2004 kmahendr bug#3748133 - Added codes to check_ctfn_prvdd
276 115.109 17-Aug-2004 hmani bug#3806262 - p_crntly_enrd_flag can be 'N' for new enrollment
277 115.110 19-Aug-2004 kmahendr Optional certification changes
278 115.111 23-Aug-2004 mmudigon CFW. Added p_act_item flag
279 2534391 :NEED TO LEAVE ACTION ITEMS
280 115.112 26-aug-2004 nhunur gscc compliance
281 115.113 26-Aug-2004 abparekh Bug# 3854556 - Modified cursor c_dsgn_bnf
282 115.114 31-Aug-2004 abparekh Bug# 3851427 Added p_susp_if_ctfn_not_prvd_flag to function
283 check_ctfns_defined. Consider "Suspend Enrollment" flag at
284 LER_CHG_DPNT level when certifications are considered at
285 LER_CHG_DPNT level. Modified p_rqd flag parameter in write_new_action_item
286 115.115 31-Aug-2004 pbodla CFW. Several cursors modified to join per_in_ler
287 115.116 09-sep-2004 mmudigon CFW. p_act_item flag no longer needed
288 115.117 03-nov-2004 kmahendr Bug3976575- cursor c_ctfn_defined modified to pl_id and
289 added codes in write_new_action_items for handling message
290 115.118 01-Dec-2004 abparekh Bug 4039404 : Fixed cursor c_pl_name in write_new_action_item
291 115.119 30-dec-2004 nhunur 4031733 - No need to open cursor c_state.
292 115.120 18-Mar-2005 swjain 4241743 - Added cursor c_prev_actn_ler in determine_other_actn_items
293 and modified if conditions to create action items also when ler id is different
294 115.121 22-Mar-2005 swjain Removed show errors
295 115.122 12-Apr-2005 swjain 4241743 - Removed cursor c_prev_actn_ler and added c_enrt_actn
296 115.123 13-Jun-2005 rbingi Bug:4396160 - Curosr name is changed from c_emp_only to c_tot_mn_mx_dpnts_req
297 cursor query changed to selects the total no. of Min and Max Dpnts req for the CompObj.
298 Changed Procedure: determine_dpnt_actn_items sothat,
299 For both Min and Max = 0, Action Item will NOT be created.
300 For Min = 0 and Max > 0, Action Item will be created IF Elig dpnts exists
301 For both Min and Max > 0, Action Item will be created irrespective of Elig dpnts.
302 115.124 13-Jun-2005 rbingi Corrected previuos change to create Action Item when no DD record is defined.
303 115.125 13-Jun-2005 rbingi Corrected compilation errors had in previuos version
304 115.126 29-Jun-2005 ikasire Bug 4422667 getting into loop issue
305 115.127 13-Jul-2005 ikasire Bug 4454990 fixed for the code
306 115.128 02-Aug-2005 rgajula Bug No 4525608
307 115.129 10-Aug-2005 A new parameter l_ctfn_actn_warning_o
308 was defined in determine_action_items which is passed on to
309 process_dpnt_actn_items and inturn passed to determine_other_actn_items
310 as out parameters.The signatures of the procedures have been changed accordingly
311 This flag whould capture the certification required action warning
312 if dependent details have been furnished and plan level certification have
313 not been furnished.
314 115.130 31-Aug-2005 ikasire BUG 4558512 completion date fix in set_cmpltd_dt procedure
315 115.131 01-Sep-2005 ikasire BUG 4558512 more changes
316 115.132 15-sep-2005 rgajula Bug 4610971 Passed the p_business_group_id to the procedure
317 ben_determine_date.main in procedure get_due_date so that
318 it ill be available to Action Type Due Date rule .
319 115.133 27-Apr-2006 swjain Bug 5156111 : Added additional logic for certications for organizations
320 in procedure determine_additional_bnf
321 115.134 28-Apr-2006 swjain Bug 5156111 : Updated cursor c_nsc_ctfn_pl in procedure determine_additional_bnf
322 115.135 02-May-2006 swjain Bug 5156111 : Updated cursor c_spouse to check for BNF_MAY_DSGT_ORG_FLAG flag
323 115.136 29-jun-2006 nhunur bug 5362890 : Added date clauses for pcr in c_spouse
324 114.137 11-Aug-2006 abparekh Bug 5461171 : Modified clauses in CURSOR c_nsc_ctfn_pl
325 115.138 9/20/2006 gsehgal bug 5513339 : added cursor c_curr_ovn_of_actn to pass right ovn
326 to delete_action_item
327 115.139 10-Jan-2007 bmanyam 5736589: No need for to check for Option Restrictions
328 when ctfn_determine_cd = 'ENRAT', as certifications are
329 determined at bendenrr (check_ctfn_prvdd)
330 115.141 23-Feb-07 swjain Bug 5887665: In procedure determine_other_actn_items, for coverage
331 certifications, added code to evaluate suspended codes
332 115.142 27-Feb-07 swjain Additional changes in procedure determine_other_actn_items and added new
333 parameter p_enrt_r_bnft_ctfn_cd in call to procedure check_ctfn_prvdd.
334 115.143 2-May-2007 rgajula Bug 5998009 : Corrected the code in the procedure determine_dpnt_miss_actn_items so as to make the system behaviour
335 ideal when Formula for 'Dependent Certification Required' type is used
336 115.144 04-May-2007 swjain Bug 6022327: Updated cursor c_ctfn_exists in procedure write_new_prtt_ctfn_prvdd_item
337 115.145 18-May-2007 swjain Bug 5965415: In procedure check_ctfn_prvdd, updated the cursor c_ctfn_prvdd and
338 c_ctfn_prvdd2 to check if any certification received in past for the same plan-option
339 (and not based on pen_id as it changes when coverage amount changes)
340 115.146 19-Jun-2007 gsehgal bug 6010780: checking future rows in update and correction mode also
341 115.147
342 115.148
343 115.149 23-Aug-2007 rgajula Bug 6353069 : Modified the procedure process_new_ctfn_action to check for dpnt certification suspend flag at various levels.
344 115.150 24-Sep-2007 rtagarra Bug 6434143 : before suspending enrollment check for SUSP_IF_CTFN_NOT_PRVD_FLAG flag.
345 115.151 22-Feb-2008 rtagarra 6840074
346 115.152 22-Sep-2008 sallumwa Bug 7417593 : Modified the cursor c_ctfn_prvdd to check if the certification is already received
347 in the past or not for the same plan and option.
348 115.153 24-sep-2008 sallumwa Bug 7417474 : Modified the cursor c_prtt_enrt_rslt,so that it doesn't fetch the record if two options
349 from the same plan are enrolled.
350 115.154 12-Nov-2008 pvelvano Bug 7513897 : If Coverage Amount is changed multiple times for the same Life Event, then Required
351 Certication alert should not popup.
352 115.155 11-Dec-2008 krupani Bug 7516987 : For open life event, the designation requirement does not get evaluated as of
353 life event occurred date.
354 115.156 16-Feb-2009 velvanop Bug 7561395: Same fix as 7513897. Bug 7513897 has been obsoleted for more changes in the fix.
355 115.157 29-May-2009 velvanop Bug 8549599 : cursor 'c_get_ler_typ' is modified to get the latest LifeEvent occured date
356 to determine the number of dependent covered as on that date.
357 115.158 10-Aug-2009 velvanop Bug 8669907: Modified cursor c_ctfn_prvdd to check if certification is received on p_effective_date.
358 115.159 30-Sep-2010 velvanop Bug 9758763: Do not suspend the reinstated result on reprocessing a LE. Case specific to Bug 9758763 and 9538592
359 115.160 07-Feb-2011 velvanop Bug 11711605: If the enrollment period for Open LE is on after the life event occured date of Open, determine
360 the number of dependents covered as of p_effective_date(session date) and not as of life event occured date because
361 cursors 'c_min_no_grp' and 'c_min_typ' will not find any record as of lf_evt_ocrd_dt if the elections are made
362 after lf_evt_ocrd_dt.
363 -------------------------------------------------------------------------------------------------------------------------------------------
364 */
365 --
366 -- Package Variables
367 --
368 g_debug boolean := hr_utility.debug_enabled;
369 --
370 -- -----------------------------------------------------------------------------
371 -- |-----------------------< check_ctfns_defined >-----------------------------|
372 -- -----------------------------------------------------------------------------
373 --
374 function check_ctfns_defined
375 (p_dpnt_person_id in number
376 ,p_person_id in number
377 ,p_prtt_enrt_rslt_id in number
378 ,p_lvl_cd in varchar2
379 ,p_pgm_id in number default null
380 ,p_pl_id in number default null
381 ,p_ptip_id in number default null
382 ,p_effective_date in date
383 ,p_business_group_id in number
384 ,p_ctfn_at_ler_chg out nocopy boolean
385 ,p_susp_if_ctfn_not_prvd_flag out nocopy varchar2
386 )
387 return boolean is
388 --
389 -- This function checks whether certifications have defined for a certain
390 -- contact type and sets the out parameter if the ctfn has been found at the
391 -- ben_ler_chg_dpnt_cvg_ctfn_f table.
392 -- Here the assumption is that if a certification is defined
393 -- without a contact type, then it is for all contact types. The function
394 -- returns TRUE if either a certification is found for the person's contact
395 -- type or a certification with a contact type of null is found.
396 --
397 -- Bug# 3851427 : Defined out parameter P_SUSP_IF_CTFN_NOT_PRVD_FLAG. This
398 -- parameter holds the value of "Suspend Enrollment" flag defined for
399 -- Dependent Change Of Life Event (BEN_LER_CHG_DPNT_CVG_F). Whenever certifications
400 -- are considered at "Dependent Change Of Life Event" level and NOT at PLN, PTIP or PGM
401 -- level, suspension should also be considered based on "Suspension Enrollment" flag value
402 -- at the "Dependent Change Of Life Event" level. Hence this flag will return valid
403 -- value only when P_CTFN_AT_LER_CHG is also true.
404 --
405 cursor c_ctfns_ler_chg is
406 select ldc.susp_if_ctfn_not_prvd_flag
407 from ben_ler_chg_dpnt_cvg_ctfn_f lcc,
408 ben_ler_chg_dpnt_cvg_f ldc,
409 ben_prtt_enrt_rslt_f pen
410 where pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
411 and pen.business_group_id = p_business_group_id
412 and p_effective_date between pen.effective_start_date
413 and pen.effective_end_date
414 and pen.ler_id = ldc.ler_id
415 and p_effective_date between ldc.effective_start_date
416 and ldc.effective_end_date
417 and pen.prtt_enrt_rslt_stat_cd is null
418 and ((p_lvl_cd = 'PTIP' and ldc.ptip_id = p_ptip_id) OR
419 (p_lvl_cd = 'PL' and ldc.pl_id = p_pl_id) OR
420 (p_lvl_cd = 'PGM' and ldc.pgm_id = p_pgm_id))
421 and ldc.ler_chg_dpnt_cvg_id = lcc.ler_chg_dpnt_cvg_id
422 and p_effective_date between lcc.effective_start_date
423 and lcc.effective_end_date
424 and (lcc.rlshp_typ_cd is null
425 or
426 lcc.rlshp_typ_cd in (select contact_type
427 from per_contact_relationships
428 where contact_person_id = p_dpnt_person_id
429 and person_id = p_person_id
430 and business_group_id = p_business_group_id
431 and p_effective_date
432 between nvl(date_start, p_effective_date)
433 and nvl(date_end, hr_api.g_eot)));
434
435 --
436 cursor c_ctfns_pgm is
437 select 'x'
438 from ben_pgm_dpnt_cvg_ctfn_f
439 where pgm_id = p_pgm_id
440 and business_group_id = p_business_group_id
441 and p_effective_date between effective_start_date
442 and effective_end_date
443 and (rlshp_typ_cd is null
444 or
445 rlshp_typ_cd in (select contact_type
446 from per_contact_relationships
447 where contact_person_id = p_dpnt_person_id
448 and person_id = p_person_id
449 and business_group_id = p_business_group_id
450 and p_effective_date
451 between nvl(date_start, p_effective_date)
452 and nvl(date_end, hr_api.g_eot)));
453 --
454 cursor c_ctfns_ptip is
455 select 'x'
456 from ben_ptip_dpnt_cvg_ctfn_f
457 where ptip_id = p_ptip_id
458 and business_group_id = p_business_group_id
459 and p_effective_date between effective_start_date
460 and effective_end_date
461 and (rlshp_typ_cd is null
462 or
463 rlshp_typ_cd in (select contact_type
464 from per_contact_relationships
465 where contact_person_id = p_dpnt_person_id
466 and person_id = p_person_id
467 and business_group_id = p_business_group_id
468 and p_effective_date
469 between nvl(date_start, p_effective_date)
470 and nvl(date_end, hr_api.g_eot)));
471 --
472 cursor c_ctfns_pl is
473 select 'x'
474 from ben_pl_dpnt_cvg_ctfn_f
475 where pl_id = p_pl_id
476 and business_group_id = p_business_group_id
477 and p_effective_date between effective_start_date
478 and effective_end_date
479 and (rlshp_typ_cd is null
480 or
481 rlshp_typ_cd in (select contact_type
482 from per_contact_relationships
483 where contact_person_id = p_dpnt_person_id
484 and person_id = p_person_id
485 and business_group_id = p_business_group_id
486 and p_effective_date
487 between nvl(date_start, p_effective_date)
488 and nvl(date_end, hr_api.g_eot)));
489 --
490 l_dummy varchar2(1);
491 l_return boolean := FALSE;
492 --
493 l_proc varchar2(80) ;
494 l_susp_if_ctfn_not_prvd_flag varchar2(30);
495 --
496 begin
497 --
498 if g_debug then
499 l_proc := g_package || '.check_ctfns_defined';
500 hr_utility.set_location('Entering ' || l_proc, 10);
501 end if;
502 if g_debug then
503 hr_utility.set_location('Dpnt dsgn level code : ' || p_lvl_cd, 10);
504 end if;
505 --
506 l_susp_if_ctfn_not_prvd_flag := null;
507 --
508 if p_lvl_cd = 'PGM' then
509 --
510 -- At the program level, first check for ctfns defined for the ler change
511 -- and then check for regular ctfns.
512 --
513 open c_ctfns_ler_chg;
514 fetch c_ctfns_ler_chg into l_susp_if_ctfn_not_prvd_flag;
515 if c_ctfns_ler_chg%found then
516 close c_ctfns_ler_chg;
517 l_return := TRUE;
518 p_ctfn_at_ler_chg := TRUE;
519 else
520 close c_ctfns_ler_chg;
521 open c_ctfns_pgm;
522 fetch c_ctfns_pgm into l_dummy;
523 if c_ctfns_pgm%found then
524 l_return := TRUE;
525 else
526 l_return := FALSE;
527 end if;
528 close c_ctfns_pgm;
529 end if;
530 --
531 elsif p_lvl_cd = 'PTIP' then
532 --
533 -- At the ptip level, first check for ctfns defined for the ler change
534 -- and then check for regular ctfns.
535 --
536 open c_ctfns_ler_chg;
537 fetch c_ctfns_ler_chg into l_susp_if_ctfn_not_prvd_flag;
538 if c_ctfns_ler_chg%found then
539 close c_ctfns_ler_chg;
540 l_return := TRUE;
541 p_ctfn_at_ler_chg := TRUE;
542 else
543 close c_ctfns_ler_chg;
544 open c_ctfns_ptip;
545 fetch c_ctfns_ptip into l_dummy;
546 if c_ctfns_ptip%found then
547 l_return := TRUE;
548 else
549 l_return := FALSE;
550 end if;
551 close c_ctfns_ptip;
552 end if;
553 --
554 else
555 --
556 -- At the plan level, first check for ctfns defined for the ler change
557 -- and then check for regular ctfns.
558 --
559 open c_ctfns_ler_chg;
560 fetch c_ctfns_ler_chg into l_susp_if_ctfn_not_prvd_flag;
561 if c_ctfns_ler_chg%found then
562 close c_ctfns_ler_chg;
563 l_return := TRUE;
564 p_ctfn_at_ler_chg := TRUE;
565 else
566 close c_ctfns_ler_chg;
567 open c_ctfns_pl;
568 fetch c_ctfns_pl into l_dummy;
569 if c_ctfns_pl%found then
570 l_return := TRUE;
571 else
572 l_return := FALSE;
573 end if;
574 close c_ctfns_pl;
575 end if;
576 --
577 end if;
578 --
579 p_susp_if_ctfn_not_prvd_flag := l_susp_if_ctfn_not_prvd_flag;
580 --
581 if l_return then
582 if g_debug then
583 hr_utility.set_location('CTFNS are defined', 99);
584 end if;
585 else
586 if g_debug then
587 hr_utility.set_location('CTFNS not defined', 99);
588 end if;
589 end if;
590 --
591 if g_debug then
592 hr_utility.set_location('Leaving ' || l_proc, 99);
593 end if;
594 --
595 return l_return;
596 --
597 end check_ctfns_defined;
598 --
599 -- -----------------------------------------------------------------------------
600 -- |-----------------------------< get_due_date >------------------------------|
601 -- -----------------------------------------------------------------------------
602 --
603 function get_due_date
604 (p_prtt_enrt_rslt_id in number
605 ,p_actn_typ_id in number
606 ,p_effective_date in date
607 ,p_business_group_id in number)
608 return date is
609 --
610 l_proc varchar2(80) := g_package || '.get_due_date';
611 --
612 -- Cursor to fetch the due date code for an action item. The action type can
613 -- be defined at either the program or the plan level. If an action type is
614 -- defined at both levels, then the one at the plan level should be selected.
615 --
616 cursor c_pl_popl_actn_typ(v_pl_id number) is
617 select pat.popl_actn_typ_id,
618 pat.effective_start_date,
619 pat.effective_end_date,
620 pat.actn_typ_due_dt_cd,
621 pat.actn_typ_due_dt_rl
622 from ben_popl_actn_typ_f pat
623 where pat.pl_id = v_pl_id
624 and pat.actn_typ_id = p_actn_typ_id
625 and pat.business_group_id = p_business_group_id
626 and p_effective_date between pat.effective_start_date
627 and pat.effective_end_date;
628 --
629 cursor c_pgm_popl_actn_typ(v_pgm_id number) is
630 select pat.popl_actn_typ_id,
631 pat.effective_start_date,
632 pat.effective_end_date,
633 pat.actn_typ_due_dt_cd,
634 pat.actn_typ_due_dt_rl
635 from ben_popl_actn_typ_f pat
636 where pat.pgm_id = v_pgm_id
637 and pat.actn_typ_id = p_actn_typ_id
638 and pat.business_group_id = p_business_group_id
639 and p_effective_date between pat.effective_start_date
640 and pat.effective_end_date;
641 --
642 l_pat c_pl_popl_actn_typ%rowtype;
643 --
644 -- Cursor to fetch elctbl_chc_id for the prtt_enrt_rslt_id
645 --
646 cursor c_elctbl_chc is
647 select epe.elig_per_elctbl_chc_id,
648 epe.pl_id,
649 epe.pgm_id
650 from ben_prtt_enrt_rslt_f pen,
651 ben_elig_per_elctbl_chc epe,
652 ben_per_in_ler pil
653 where pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
654 and pen.prtt_enrt_rslt_stat_cd is null
655 and p_effective_date between
656 pen.effective_start_date and pen.effective_end_date
657 and pen.prtt_enrt_rslt_id = epe.prtt_enrt_rslt_id
658 and pen.per_in_ler_id = epe.per_in_ler_id
659 and pil.per_in_ler_id = epe.per_in_ler_id
660 and pil.business_group_id = p_business_group_id
661 and pil.per_in_ler_stat_cd not in ('VOIDD', 'BCKDT');
662 --
663 l_elig_per_elctbl_chc_id number(15) := null;
664 l_pl_id number;
665 l_pgm_id number;
666 --
667 -- Cursor to fetch the start date for the enrollment period
668 --
669 l_returned_date date := null;
670 --
671 pat_not_found exception;
672 --
673 begin
674 --
675 if g_debug then
676 hr_utility.set_location ('Entering '||l_proc,10);
677 end if;
678 --
679 if p_actn_typ_id is null then
680 --
681 fnd_message.set_name('BEN','BEN_91832_PACKAGE_PARAM_NULL');
682 fnd_message.set_token('PACKAGE',l_proc);
683 fnd_message.set_token('PROC','Enrollment Action Items');
684 fnd_message.set_token('PARAM','p_actn_typ_id');
685 fnd_message.raise_error;
686 --
687 end if;
688 --
689 open c_elctbl_chc;
690 fetch c_elctbl_chc into l_elig_per_elctbl_chc_id, l_pl_id, l_pgm_id;
691 close c_elctbl_chc;
692 --
693 open c_pl_popl_actn_typ(l_pl_id);
694 fetch c_pl_popl_actn_typ into l_pat;
695 close c_pl_popl_actn_typ;
696 --
697 if l_pat.popl_actn_typ_id is null and
698 l_pgm_id is not null then
699 --
700 open c_pgm_popl_actn_typ(l_pgm_id);
701 fetch c_pgm_popl_actn_typ into l_pat;
702 close c_pgm_popl_actn_typ;
703 --
704 end if;
705 --
706 if l_pat.popl_actn_typ_id is null then
707 raise pat_not_found;
708 end if;
709 --
710 --
711 -- Call the ben_determine_date.main procedure
712 --
713 --
714 -- Call the date routine only if the due date code is not null.
715 --
716 if l_pat.actn_typ_due_dt_cd is not null then
717 --
718 --Bug 4610971 Passed the p_business_group_id to the procedure
719 -- ben_determine_date.main so that it ill be available to Action Type Due Date rule
720 ben_determine_date.main
721 (p_date_cd => l_pat.actn_typ_due_dt_cd
722 ,p_effective_date => p_effective_date
723 ,p_elig_per_elctbl_chc_id => l_elig_per_elctbl_chc_id
724 ,p_formula_id => l_pat.actn_typ_due_dt_rl
725 ,p_business_group_id => p_business_group_id
726 ,p_returned_date => l_returned_date);
727 --
728 --End Bug 4610971
729 end if;
730 --
731 if g_debug then
732 hr_utility.set_location ('Leaving '||l_proc,10);
733 end if;
734 --
735 return l_returned_date;
736 --
737 exception
738 --
739 when pat_not_found then
740 --
741 if g_debug then
742 hr_utility.set_location('Leaving : ' || l_proc, 10);
743 end if;
744 l_returned_date := NULL;
745 return l_returned_date;
746 --
747 when others then
748 if g_debug then
749 hr_utility.set_location('Exception Raised '||l_proc, 10);
750 end if;
751 raise;
752 --
753 end get_due_date;
754 --
755 -- ----------------------------------------------------------------------------
756 -- |--------------------------< get_actn_typ_id >-----------------------------|
757 -- ----------------------------------------------------------------------------
758 --
759 function get_actn_typ_id
760 (p_type_cd in varchar2
761 ,p_business_group_id in number)
762 return number is
763 --
764 -- Return the actn_typ_id or NULL when given the ben_actn_typ.type_cd
765 -- type_cd examples DDDOB, DDSSN, BNFADDR, etc.
766 -- note: future improvement could be to get this list once and then find
767 -- the values from the pl/sql record
768 --
769 l_proc varchar2(80);
770 l_actn_typ_id ben_actn_typ.actn_typ_id%type := NULL;
771 --
772 cursor c_actn_typ_id is
773 select bat.actn_typ_id
774 from ben_actn_typ bat
775 where bat.type_cd = p_type_cd
776 and bat.business_group_id = p_business_group_id;
777 --
778 begin
779 --
780 g_debug := hr_utility.debug_enabled;
781 if g_debug then
782 l_proc := g_package||'.get_actn_typ_id';
783 hr_utility.set_location ('Entering '||l_proc,10);
784 end if;
785 --
786 open c_actn_typ_id;
787 fetch c_actn_typ_id into l_actn_typ_id;
788 --
789 if c_actn_typ_id%notfound then
790 l_actn_typ_id := NULL;
791 end if;
792 --
793 close c_actn_typ_id;
794 --
795 if g_debug then
796 hr_utility.set_location ('Leaving '||l_proc, 10);
797 end if;
798 --
799 return l_actn_typ_id;
800 --
801 exception
802 when others then
803 if g_debug then
804 hr_utility.set_location('Exception Raised '||l_proc, 10);
805 end if;
806 raise;
807 --
808 end get_actn_typ_id;
809 --
810 -- ----------------------------------------------------------------------------
811 -- |-------------------------< get_prtt_enrt_actn_id >------------------------|
812 -- ----------------------------------------------------------------------------
813 --
814 procedure get_prtt_enrt_actn_id
815 (p_actn_typ_id in number
816 ,p_prtt_enrt_rslt_id in number
817 ,p_elig_cvrd_dpnt_id in number default null
818 ,p_pl_bnf_id in number default null
819 ,p_effective_date in date
820 ,p_business_group_id in number
821 ,p_prtt_enrt_actn_id out nocopy number
822 ,p_cmpltd_dt out nocopy date
823 ,p_object_version_number in out nocopy number) is
824 --
825 -- This procedure returns the prtt_enrt_actn_id for either a general action
826 -- type like DD that can only be associated with an enrt rslt or it can be
827 -- used to retrieve a more specific action id like DDDOB which is tied to an
828 -- eligible covered dependent using the elig_cvrd_dpnt_id
829 --
830 l_proc varchar2(80);
831 --
832 -- Cursor to fetch an action item record that is not associated with any dpnt
833 -- or a bnf but is tied to the participant's enrt rslt id and is of a general
834 -- action type like DD or BNF
835 --
836 cursor c_enrt_actn is
837 select pea.prtt_enrt_actn_id,
838 pea.cmpltd_dt,
839 pea.object_version_number
840 from ben_prtt_enrt_actn_f pea,
841 ben_per_in_ler pil
842 where pea.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
843 and pea.actn_typ_id = p_actn_typ_id
844 and pea.pl_bnf_id is null
845 and pea.elig_cvrd_dpnt_id is null
846 and pea.per_in_ler_id = pil.per_in_ler_id
847 and pil.per_in_ler_stat_cd not in ('BCKDT', 'VOIDD')
848 and pea.business_group_id = p_business_group_id
849 and p_effective_date between pea.effective_start_date
850 and pea.effective_end_date ;
851 --
852 l_enrt_actn c_enrt_actn%rowtype;
853 l_object_version_number number(15);
854
855 --
856 -- Cursor to fetch an action item record for a particular dependent and for
857 -- a particular action type.
858 --
859 cursor c_enrt_actn_dpnt is
860 select pea.prtt_enrt_actn_id,
861 pea.cmpltd_dt,
862 pea.object_version_number
863 from ben_prtt_enrt_actn_f pea,
864 ben_per_in_ler pil
865 where pea.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
866 and pea.actn_typ_id = p_actn_typ_id
867 and pea.per_in_ler_id = pil.per_in_ler_id
868 and pil.per_in_ler_stat_cd not in ('BCKDT', 'VOIDD')
869 and pea.elig_cvrd_dpnt_id = p_elig_cvrd_dpnt_id
870 and pea.business_group_id = p_business_group_id
871 and p_effective_date between pea.effective_start_date
872 and pea.effective_end_date;
873 --
874 l_enrt_actn_dpnt c_enrt_actn_dpnt%rowtype;
875 --
876 -- Cursor to fetch an action item record for a particular beneficiary and for
877 -- a particular action type.
878 --
879 cursor c_enrt_actn_bnf is
880 select pea.prtt_enrt_actn_id,
881 pea.cmpltd_dt,
882 pea.object_version_number
883 from ben_prtt_enrt_actn_f pea,
884 ben_per_in_ler pil
885 where pea.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
886 and pea.actn_typ_id = p_actn_typ_id
887 and pea.pl_bnf_id = p_pl_bnf_id
888 and pea.per_in_ler_id = pil.per_in_ler_id
889 and pil.per_in_ler_stat_cd not in ('BCKDT', 'VOIDD')
890 and pea.business_group_id = p_business_group_id
891 and p_effective_date between pea.effective_start_date
892 and pea.effective_end_date;
893 --
894 l_enrt_actn_bnf c_enrt_actn_bnf%rowtype;
895
896 --
897 begin
898 --
899 g_debug := hr_utility.debug_enabled;
900 if g_debug then
901 l_proc := g_package||'.get_prtt_enrt_actn_id';
902 hr_utility.set_location ('Entering '||l_proc,10);
903 end if;
904 l_object_version_number := p_object_version_number ;
905
906 hr_utility.set_location ('p_prtt_enrt_rslt_id '|| p_prtt_enrt_rslt_id,10);
907 hr_utility.set_location ('p_elig_cvrd_dpnt_id '|| p_elig_cvrd_dpnt_id,10);
908 hr_utility.set_location ('p_pl_bnf_id '|| p_pl_bnf_id,10);
909
910 --
911 if p_prtt_enrt_rslt_id is not null then
912 --
913 if p_elig_cvrd_dpnt_id is null and
914 p_pl_bnf_id is null then
915 --
916 -- A general enrt action id was requested from the calling proc.
917 -- Open the appropriate cursor
918 --
919 open c_enrt_actn;
920 fetch c_enrt_actn into l_enrt_actn;
921 --
922 if c_enrt_actn%notfound then
923 p_prtt_enrt_actn_id := NULL;
924 p_cmpltd_dt := NULL;
925 else
926 p_prtt_enrt_actn_id := l_enrt_actn.prtt_enrt_actn_id;
927 p_cmpltd_dt := l_enrt_actn.cmpltd_dt;
928 p_object_version_number := l_enrt_actn.object_version_number;
929 end if;
930 --
931 close c_enrt_actn;
932 --
933 hr_utility.set_location ('p_prtt_enrt_actn_id '|| p_prtt_enrt_actn_id,11);
934 hr_utility.set_location ('p_cmpltd_dt '|| p_cmpltd_dt,11);
935
936
937
938 elsif p_elig_cvrd_dpnt_id is not null and
939 p_pl_bnf_id is null then
940 --
941 -- A request for a dependent's specific action item was made
942 --
943 open c_enrt_actn_dpnt;
944 fetch c_enrt_actn_dpnt into l_enrt_actn_dpnt;
945 --
946 if c_enrt_actn_dpnt%notfound then
947 p_prtt_enrt_actn_id := NULL;
948 p_cmpltd_dt := NULL;
949 else
950 p_prtt_enrt_actn_id := l_enrt_actn_dpnt.prtt_enrt_actn_id;
951 p_cmpltd_dt := l_enrt_actn_dpnt.cmpltd_dt;
952 p_object_version_number := l_enrt_actn_dpnt.object_version_number;
953 end if;
954 --
955 close c_enrt_actn_dpnt;
956 --
957 hr_utility.set_location ('p_prtt_enrt_actn_id '|| p_prtt_enrt_actn_id,12);
958 hr_utility.set_location ('p_cmpltd_dt '|| p_cmpltd_dt,12);
959
960 elsif p_elig_cvrd_dpnt_id is null and
961 p_pl_bnf_id is not null then
962 --
963 -- A request for a benefiary's specific action item was made
964 --
965 open c_enrt_actn_bnf;
966 fetch c_enrt_actn_bnf into l_enrt_actn_bnf;
967 --
968 if c_enrt_actn_bnf%notfound then
969 p_prtt_enrt_actn_id := NULL;
970 p_cmpltd_dt := NULL;
971 else
972 p_prtt_enrt_actn_id := l_enrt_actn_bnf.prtt_enrt_actn_id;
973 p_cmpltd_dt := l_enrt_actn_bnf.cmpltd_dt;
974 p_object_version_number := l_enrt_actn_bnf.object_version_number;
975 end if;
976 --
977 close c_enrt_actn_bnf;
978 --
979 hr_utility.set_location ('p_prtt_enrt_actn_id '|| p_prtt_enrt_actn_id,13);
980 hr_utility.set_location ('p_cmpltd_dt '|| p_cmpltd_dt,13);
981
982 end if;
983 --
984 else
985 -- p_enrt_rslt_id is null
986 --
987 p_prtt_enrt_actn_id := NULL;
988 p_cmpltd_dt := NULL;
989 p_object_version_number := NULL;
990 end if;
991 --
992 if g_debug then
993 hr_utility.set_location ('Leaving '||l_proc, 10);
994 end if;
995 --
996 exception
997 when others then
998
999 -- Init Variables for NOCOPY
1000 p_prtt_enrt_actn_id :=null ;
1001 p_cmpltd_dt :=null ;
1002 p_object_version_number := l_object_version_number ;
1003 --
1004 if g_debug then
1005 hr_utility.set_location('Exception Raised '||l_proc, 10);
1006 end if;
1007 raise;
1008 --
1009 end get_prtt_enrt_actn_id;
1010 --
1011 -- ----------------------------------------------------------------------------
1012 -- |--------------------------< date_track_verify >---------------------------|
1013 -- ----------------------------------------------------------------------------
1014 --
1015 function date_track_verify
1016 (p_dt_mode in varchar2
1017 ,p_dflt_mode in varchar2
1018 ,p_eff_date in date
1019 ,p_start_date in date)
1020 return varchar2 is
1021 --
1022 l_proc varchar2(80);
1023 l_datetrack_mode varchar2(30);
1024 --
1025 begin
1026 --
1027 if g_debug then
1028 l_proc := g_package||'.date_track_verify';
1029 hr_utility.set_location ('Entering '||l_proc,10);
1030 end if;
1031 --
1032 -- Date track settings need some massaging right now.
1033 -- This routine is used to set the rules for mode settings depending
1034 -- on what we are passed and action we are doing.
1035 --
1036 if p_dt_mode IS NULL then
1037 l_datetrack_mode := p_dflt_mode;
1038 else
1039 l_datetrack_mode := p_dt_mode;
1040 end if;
1041 --
1042 -- there are other rules now that we must apply
1043 --
1044 if l_datetrack_mode = DTMODE_ZAP then
1045 -- zap mode converts to correction
1046 l_datetrack_mode := hr_api.g_correction;
1047 --
1048 elsif l_datetrack_mode = DTMODE_DELETE then
1049 -- delete mode converts to update
1050 l_datetrack_mode := DTMODE_UPDATE;
1051 elsif l_datetrack_mode = hr_api.g_future_change then
1052 l_datetrack_mode := DTMODE_UPDATE;
1053 --
1054 else
1055 -- Bug: 3510501: In all other cases, set date-track mode to 'UPDATE'.
1056 -- NULL;
1057 l_datetrack_mode := DTMODE_UPDATE;
1058 end if;
1059 --
1060 -- recheck the DTMODE_UPDATE by comparing effective date with effective start
1061 -- date
1062 --
1063 if l_datetrack_mode = DTMODE_UPDATE and
1064 p_eff_date IS NOT NULL and
1065 p_start_date IS NOT NULL and
1066 p_eff_date = p_start_date then
1067 l_datetrack_mode := hr_api.g_correction;
1068 end if;
1069 --
1070 if g_debug then
1071 hr_utility.set_location ('Leaving '||l_proc, 10);
1072 end if;
1073 --
1074 return l_datetrack_mode;
1075 --
1076 exception
1077 when others then
1078 if g_debug then
1079 hr_utility.set_location('Exception Raised '||l_proc, 10);
1080 end if;
1081 raise;
1082 --
1083 end date_track_verify;
1084 --
1085 -- ----------------------------------------------------------------------------
1086 -- |-----------------------< write_new_action_item >--------------------------|
1087 -- ----------------------------------------------------------------------------
1088 --
1089 procedure write_new_action_item
1090 (p_prtt_enrt_rslt_id in number
1091 ,p_rslt_object_version_number in out nocopy number
1092 ,p_actn_typ_id in number
1093 ,p_elig_cvrd_dpnt_id in number default null
1094 ,p_pl_bnf_id in number default null
1095 ,p_rqd_flag in varchar2 default 'Y'
1096 ,p_cmpltd_dt in date default null
1097 ,p_effective_date in date
1098 ,p_business_group_id in number
1099 ,p_post_rslt_flag in varchar2 default 'Y'
1100 ,p_object_version_number out nocopy number
1101 ,p_prtt_enrt_actn_id out nocopy number) is
1102 --
1103 cursor c_act_name is
1104 select tl.name actn_typ_name
1105 from ben_actn_typ typ,
1106 ben_actn_typ_tl tl
1107 where p_actn_typ_id = typ.actn_typ_id
1108 and typ.actn_typ_id = tl.actn_typ_id
1109 and tl.language = userenv('lang')
1110 and typ.type_cd <> 'BNF'
1111 and typ.type_cd like 'BNF%'
1112 and typ.business_group_id = p_business_group_id;
1113 --
1114 cursor c_pl_name is
1115 select pln.name,
1116 pen.person_id
1117 from ben_pl_f pln,
1118 ben_prtt_enrt_rslt_f pen
1119 where pln.pl_id = pen.pl_id
1120 and pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id /* Bug 4039404 */
1121 and pen.prtt_enrt_rslt_stat_cd is null
1122 and p_effective_date between pln.effective_Start_date
1123 and pln.effective_end_date
1124 and p_effective_date between pen.effective_Start_date
1125 and pen.effective_end_date;
1126 --
1127 l_act_name varchar2(300);
1128 l_pl_name varchar2(300);
1129 l_person_id number;
1130 l_proc varchar2(80);
1131 l_effective_start_date date;
1132 l_effective_end_date date;
1133 l_due_dt date;
1134 l_rslt_object_version_number number(15);
1135 l_message1 varchar2(300) := 'BEN_94108_BNF_ACT_ITEM';
1136
1137 --
1138 begin
1139 --
1140 g_debug := hr_utility.debug_enabled;
1141 if g_debug then
1142 l_proc := g_package||'.write_new_action_item';
1143 hr_utility.set_location ('Entering '||l_proc,10);
1144 end if;
1145 l_rslt_object_version_number := p_rslt_object_version_number ;
1146 --
1147 -- Get the due date for the action item
1148 --
1149 l_due_dt := get_due_date
1150 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
1151 ,p_actn_typ_id => p_actn_typ_id
1152 ,p_effective_date => p_effective_date
1153 ,p_business_group_id => p_business_group_id);
1154 --
1155 -- Using table api write a new record for an action item
1156 --
1157 ben_prtt_enrt_actn_api.create_prtt_enrt_actn
1158 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
1159 ,p_rslt_object_version_number => p_rslt_object_version_number
1160 ,p_actn_typ_id => p_actn_typ_id
1161 ,p_elig_cvrd_dpnt_id => p_elig_cvrd_dpnt_id
1162 ,p_pl_bnf_id => p_pl_bnf_id
1163 ,p_due_dt => l_due_dt
1164 ,p_rqd_flag => p_rqd_flag
1165 ,p_cmpltd_dt => p_cmpltd_dt
1166 ,p_effective_date => p_effective_date
1167 ,p_post_rslt_flag => p_post_rslt_flag
1168 ,p_business_group_id => p_business_group_id
1169 ,p_object_version_number => p_object_version_number
1170 ,p_effective_start_date => l_effective_start_date
1171 ,p_effective_end_date => l_effective_end_date
1172 ,p_prtt_enrt_actn_id => p_prtt_enrt_actn_id);
1173 if p_pl_bnf_id is not null then
1174 --
1175 open c_act_name;
1176 fetch c_act_name into l_act_name;
1177 close c_act_name;
1178 --
1179 open c_pl_name;
1180 fetch c_pl_name into l_pl_name, l_person_id;
1181 close c_pl_name;
1182 --
1183
1184 ben_warnings.load_warning
1185 (p_application_short_name => 'BEN',
1186 p_message_name => l_message1,
1187 p_parma => l_act_name,
1188 p_parmb => l_pl_name,
1189 p_person_id => l_person_id);
1190
1191 --
1192 end if;
1193 --
1194 if g_debug then
1195 hr_utility.set_location ('Leaving '||l_proc, 10);
1196 end if;
1197 --
1198 exception
1199 when others then
1200
1201
1202 -- Init Variables for NOCOPY
1203 p_rslt_object_version_number :=l_rslt_object_version_number;
1204 p_object_version_number :=null;
1205 p_prtt_enrt_actn_id :=null;
1206
1207 if g_debug then
1208 hr_utility.set_location('Exception Raised '||l_proc, 10);
1209 end if;
1210 raise;
1211 --
1212 end write_new_action_item;
1213 --
1214 -- ----------------------------------------------------------------------------
1215 -- |-----------------------< write_new_dpnt_ctfn_item >-----------------------|
1216 -- ----------------------------------------------------------------------------
1217 --
1218 procedure write_new_dpnt_ctfn_item
1219 (p_elig_cvrd_dpnt_id in number
1220 ,p_prtt_enrt_actn_id in number
1221 ,p_dpnt_dsgn_ctfn_typ_cd in varchar2
1222 ,p_dpnt_dsgn_ctfn_rqd_flag in varchar2
1223 ,p_effective_date in date
1224 ,p_business_group_id in number
1225 ,p_object_version_number out nocopy number
1226 ,p_cvrd_dpnt_ctfn_prvdd_id out nocopy number) is
1227 --
1228 -- this procedure writes a dependent certification to
1229 -- ben_cvrd_dpnt_ctfn_prvdd_f
1230 --
1231 l_proc varchar2(80);
1232 l_effective_start_date date;
1233 l_effective_end_date date;
1234 --
1235 begin
1236 --
1237 if g_debug then
1238 l_proc := g_package||'.write_new_dpnt_ctfn_item';
1239 hr_utility.set_location ('Entering '||l_proc,10);
1240 end if;
1241 --
1242 -- write a new record for a dependent certification item
1243 --
1244 ben_cvrd_dpnt_ctfn_prvdd_api.create_cvrd_dpnt_ctfn_prvdd
1245 (p_elig_cvrd_dpnt_id => p_elig_cvrd_dpnt_id
1246 ,p_prtt_enrt_actn_id => p_prtt_enrt_actn_id
1247 ,p_dpnt_dsgn_ctfn_typ_cd => p_dpnt_dsgn_ctfn_typ_cd
1248 ,p_dpnt_dsgn_ctfn_rqd_flag => p_dpnt_dsgn_ctfn_rqd_flag
1249 ,p_effective_date => p_effective_date
1250 ,p_business_group_id => p_business_group_id
1251 ,p_object_version_number => p_object_version_number
1252 ,p_effective_start_date => l_effective_start_date
1253 ,p_effective_end_date => l_effective_end_date
1254 ,p_cvrd_dpnt_ctfn_prvdd_id => p_cvrd_dpnt_ctfn_prvdd_id
1255 ,p_program_application_id => fnd_global.prog_appl_id
1256 ,p_program_id => fnd_global.conc_program_id
1257 ,p_request_id => fnd_global.conc_request_id
1258 ,p_program_update_date => sysdate);
1259 --
1260 if g_debug then
1261 hr_utility.set_location ('Leaving '||l_proc, 10);
1262 end if;
1263 --
1264 exception
1265 /* we could have duplicates already here from prior run
1266 - BEN_91632_DUP_DPNT_CTFN */
1267 when others then
1268
1269 -- Init Variables for NOCOPY
1270 p_object_version_number :=null ;
1271 p_cvrd_dpnt_ctfn_prvdd_id :=null ;
1272 if g_debug then
1273 hr_utility.set_location('Exception Raised '||l_proc, 10);
1274 end if;
1275 raise;
1276 --
1277 end write_new_dpnt_ctfn_item;
1278 --
1279 -- ----------------------------------------------------------------------------
1280 -- |-------------------< write_new_prtt_ctfn_prvdd_item >---------------------|
1281 -- ----------------------------------------------------------------------------
1282 --
1283 procedure write_new_prtt_ctfn_prvdd_item
1284 (p_rqd_flag in varchar2
1285 ,p_enrt_ctfn_typ_cd in varchar2
1286 ,p_enrt_r_bnft_ctfn_cd in varchar2
1287 ,p_prtt_enrt_rslt_id in number
1288 ,p_prtt_enrt_actn_id in number
1289 ,p_effective_date in date
1290 ,p_business_group_id in number
1291 ,p_object_version_number out nocopy number
1292 ,p_prtt_enrt_ctfn_prvdd_id out nocopy number) is
1293 --
1294 -- Does this ctfn already exist for this action item?
1295 --
1296 cursor c_ctfn_exists is
1297 select null
1298 from ben_prtt_enrt_ctfn_prvdd_f ecp
1299 where ecp.enrt_ctfn_typ_cd=p_enrt_ctfn_typ_cd
1300 and ecp.enrt_ctfn_rqd_flag=p_rqd_flag
1301 and p_effective_date between
1302 ecp.effective_start_date and ecp.effective_end_date
1303 and ecp.business_group_id=p_business_group_id
1304 and ecp.prtt_enrt_actn_id=p_prtt_enrt_actn_id
1305 and exists -- Bug 6022327: Changed from not exists to exists
1306 ( select pea.prtt_enrt_actn_id
1307 from ben_prtt_enrt_actn_f pea,
1308 ben_per_in_ler pil
1309 where pea.per_in_ler_id = pil.per_in_ler_id
1310 and pil.per_in_ler_stat_cd not in ('BCKDT', 'VOIDD')
1311 and pea.prtt_enrt_actn_id = p_prtt_enrt_actn_id
1312 and p_effective_date between
1313 pea.effective_start_date and pea.effective_end_date);
1314 --
1315 -- this procedure writes to the ben_prtt_enrt_ctfn_prvdd_f
1316 --
1317 l_proc varchar2(80);
1318 l_effective_start_date date;
1319 l_effective_end_date date;
1320 l_ctfn_exists varchar2(30):='N';
1321 --
1322 begin
1323 --
1324 if g_debug then
1325 l_proc := g_package||'.write_new_prtt_ctfn_prvdd_item';
1326 hr_utility.set_location ('Entering '||l_proc,10);
1327 end if;
1328 --
1329 -- write a new record for a participant certification item
1330 --
1331 -- if it does not already exist
1332 --
1333 open c_ctfn_exists;
1334 fetch c_ctfn_exists into l_ctfn_exists;
1335 close c_ctfn_exists;
1336 if l_ctfn_exists='N' then
1337 ben_prtt_enrt_ctfn_prvdd_api.create_prtt_enrt_ctfn_prvdd
1338 (p_enrt_ctfn_rqd_flag => p_rqd_flag
1339 ,p_enrt_ctfn_typ_cd => p_enrt_ctfn_typ_cd
1340 ,p_enrt_r_bnft_ctfn_cd => p_enrt_r_bnft_ctfn_cd
1341 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
1342 ,p_prtt_enrt_actn_id => p_prtt_enrt_actn_id
1343 ,p_effective_date => p_effective_date
1344 ,p_business_group_id => p_business_group_id
1345 ,p_object_version_number => p_object_version_number
1346 ,p_effective_start_date => l_effective_start_date
1347 ,p_effective_end_date => l_effective_end_date
1348 ,p_prtt_enrt_ctfn_prvdd_id => p_prtt_enrt_ctfn_prvdd_id
1349 );
1350 else
1351 hr_utility.set_location ('Already certification exists. No need to create new one', 10);
1352 end if;
1353 --
1354 if g_debug then
1355 hr_utility.set_location ('Leaving '||l_proc, 10);
1356 end if;
1357 --
1358 exception
1359 when others then
1360
1361 -- Init Variables for NOCOPY
1362 p_object_version_number := null ;
1363 p_prtt_enrt_ctfn_prvdd_id:= null;
1364
1365 if g_debug then
1366 hr_utility.set_location('Exception Raised '||l_proc, 10);
1367 end if;
1368 raise;
1369 --
1370 end write_new_prtt_ctfn_prvdd_item;
1371 --
1372 -- ----------------------------------------------------------------------------
1373 -- |---------------------------< set_cmpltd_dt >------------------------------|
1374 -- ----------------------------------------------------------------------------
1375 --
1376 procedure set_cmpltd_dt
1377 (p_prtt_enrt_actn_id in number
1378 ,p_prtt_enrt_rslt_id in number
1379 ,p_rslt_object_version_number in out nocopy number
1380 ,p_actn_typ_id in number
1381 ,p_rqd_flag in varchar2 default 'Y'
1382 ,p_effective_date in date
1383 ,p_post_rslt_flag in varchar2 default 'Y'
1384 ,p_business_group_id in number
1385 ,p_object_version_number in out nocopy number
1386 ,p_open_close in varchar2
1387 ,p_datetrack_mode in varchar2 default hr_api.g_correction) is
1388 --
1389 l_proc varchar2(80);
1390 l_datetrack_mode varchar2(30);
1391 -- bug 6010780
1392 l_datetrack_mode2 varchar2(30);
1393 l_cmpltd_dt date := NULL;
1394 l_effective_start_date date;
1395 l_effective_end_date date;
1396 l_rslt_object_version_number number ;
1397 l_object_version_number number ;
1398
1399 --
1400 -- the cursor is for datetrack mode verify
1401 --
1402 cursor c_start_date is
1403 select pea.effective_start_date
1404 from ben_prtt_enrt_actn_f pea
1405 where pea.prtt_enrt_actn_id = p_prtt_enrt_actn_id
1406 and pea.business_group_id = p_business_group_id
1407 and p_effective_date between pea.effective_start_date
1408 and pea.effective_end_date;
1409 --
1410 cursor c_future_row is
1411 select object_version_number
1412 from ben_prtt_enrt_actn_f pea
1413 where pea.prtt_enrt_actn_id = p_prtt_enrt_actn_id
1414 and pea.business_group_id = p_business_group_id
1415 and p_effective_date < pea.effective_start_date
1416 ;
1417 --
1418 --BUG 4558512 new cursors to determine the right completion date
1419 --
1420 cursor c_pcs(p_prtt_enrt_rslt_id number,p_prtt_enrt_actn_id number) is
1421 select max(pcs.enrt_ctfn_recd_dt) ctfn_recd_dt
1422 from ben_prtt_enrt_ctfn_prvdd_f pcs
1423 where pcs.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
1424 and pcs.prtt_enrt_actn_id = p_prtt_enrt_actn_id
1425 and p_effective_date between
1426 pcs.effective_start_date and pcs.effective_end_date;
1427 --
1428 cursor c_ccp(p_prtt_enrt_actn_id number) is
1429 select max(ccp.dpnt_dsgn_ctfn_recd_dt) ctfn_recd_dt
1430 from ben_cvrd_dpnt_ctfn_prvdd_f ccp,
1431 ben_prtt_enrt_actn_f pea
1432 where ccp.prtt_enrt_actn_id = p_prtt_enrt_actn_id
1433 and pea.prtt_enrt_actn_id = p_prtt_enrt_actn_id
1434 and ccp.elig_cvrd_dpnt_id = pea.elig_cvrd_dpnt_id
1435 and p_effective_date between
1436 pea.effective_start_date and pea.effective_end_date
1437 and p_effective_date between
1438 ccp.effective_start_date and ccp.effective_end_date;
1439 --
1440 cursor c_pbc(p_prtt_enrt_actn_id number) is
1441 select max(pbc.bnf_ctfn_recd_dt) ctfn_recd_dt
1442 from ben_pl_bnf_ctfn_prvdd_f pbc,
1443 ben_prtt_enrt_actn_f pea
1444 where pbc.prtt_enrt_actn_id = p_prtt_enrt_actn_id
1445 and pea.prtt_enrt_actn_id = p_prtt_enrt_actn_id
1446 and pbc.pl_bnf_id = pea.pl_bnf_id
1447 and p_effective_date between
1448 pea.effective_start_date and pea.effective_end_date
1449 and p_effective_date between
1450 pbc.effective_start_date and pbc.effective_end_date;
1451 --
1452 l_object_version_number2 number;
1453 l_start_date c_start_date%rowtype;
1454 l_dummy_number number;
1455 l_prvdd_dt date := NULL;
1456
1457 --
1458 cursor c_curr_ovn_of_actn (c_prtt_enrt_actn_id number) is
1459 select object_version_number
1460 from ben_prtt_enrt_actn_f
1461 where prtt_enrt_actn_id = c_prtt_enrt_actn_id
1462 and business_group_id = p_business_group_id
1463 and p_effective_date between effective_start_date
1464 and effective_end_date;
1465
1466 curr_ovn ben_prtt_enrt_actn_f.object_version_number%TYPE;
1467 --
1468 --
1469 begin
1470 --
1471 if g_debug then
1472 l_proc := g_package||'.set_cmpltd_dt';
1473 hr_utility.set_location ('Entering '||l_proc,10);
1474 hr_utility.set_location('p_prtt_enrt_actn_id '||p_prtt_enrt_actn_id,119);
1475 hr_utility.set_location('p_prtt_enrt_rslt_id '||p_prtt_enrt_rslt_id,119);
1476 --
1477 end if;
1478 --
1479
1480 l_rslt_object_version_number := p_rslt_object_version_number ;
1481 l_object_version_number := p_object_version_number ;
1482
1483 -- Using table api update existing record for an action item
1484 -- setting the cmpltd_dt to effective_date
1485 --
1486 open c_start_date;
1487 fetch c_start_date into l_start_date;
1488 close c_start_date;
1489 --
1490 if p_open_close = 'OPEN' then
1491 l_cmpltd_dt := NULL;
1492 elsif p_open_close = 'CLOSE' then
1493 --
1494 if p_prtt_enrt_rslt_id is not null and
1495 p_prtt_enrt_actn_id is not null then
1496 --
1497 open c_pcs(p_prtt_enrt_rslt_id,p_prtt_enrt_actn_id);
1498 fetch c_pcs into l_prvdd_dt ;
1499 close c_pcs ;
1500 --
1501 end if;
1502 --
1503 l_cmpltd_dt := l_prvdd_dt ;
1504 --
1505 hr_utility.set_location('FIRST l_cmpltd_dt '||l_cmpltd_dt,119);
1506 --
1507 open c_ccp(p_prtt_enrt_actn_id);
1508 fetch c_ccp into l_prvdd_dt ;
1509 close c_ccp ;
1510 --
1511 if l_prvdd_dt > nvl(l_cmpltd_dt,l_prvdd_dt-1) then
1512 l_cmpltd_dt := l_prvdd_dt ;
1513 end if;
1514 --
1515 hr_utility.set_location('SECOND l_cmpltd_dt '||l_cmpltd_dt,119);
1516 --
1517 open c_pbc(p_prtt_enrt_actn_id);
1518 fetch c_pbc into l_prvdd_dt ;
1519 close c_pbc ;
1520 --
1521 if l_prvdd_dt > nvl(l_cmpltd_dt,l_prvdd_dt-1) then
1522 l_cmpltd_dt := l_prvdd_dt ;
1523 end if;
1524 --
1525 hr_utility.set_location(' p_effective_date '||p_effective_date,119);
1526 hr_utility.set_location(' l_cmpltd_dt '||l_cmpltd_dt,119);
1527 l_cmpltd_dt := nvl(l_cmpltd_dt,p_effective_date) ;
1528 --
1529 end if;
1530 --
1531 l_datetrack_mode := date_track_verify
1532 (p_dt_mode => p_datetrack_mode
1533 ,p_dflt_mode => DTMODE_CORRECT
1534 ,p_eff_date => p_effective_date
1535 ,p_start_date => l_start_date.effective_start_date);
1536 --
1537 -- if p_datetrack_mode = hr_api.g_future_change then -- bug 6010780
1538 --
1539 open c_future_row;
1540 fetch c_future_row into l_object_version_number2;
1541 close c_future_row;
1542 --
1543 -- end if;
1544 if l_object_version_number2 is not null
1545 and p_datetrack_mode = hr_api.g_future_change
1546 then -- future rows exists
1547 --
1548 ben_prtt_enrt_actn_api.delete_PRTT_ENRT_ACTN
1549 (
1550 p_prtt_enrt_actn_id => p_prtt_enrt_actn_id
1551 ,p_business_group_id => p_business_group_id
1552 ,p_effective_date => p_effective_date
1553 ,p_datetrack_mode => p_datetrack_mode
1554 ,p_object_version_number => p_object_version_number
1555 ,p_unsuspend_enrt_flag => 'N'
1556 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
1557 ,p_rslt_object_version_number => l_dummy_number
1558 ,p_effective_start_date => l_effective_start_date
1559 ,p_effective_end_date => l_effective_end_date
1560 );
1561 --
1562 else
1563 --
1564 -- bug 6010780
1565 if l_object_version_number2 is not null then
1566 l_datetrack_mode2 := 'FUTURE_CHANGE';
1567
1568 hr_utility.set_location(' Future change exists fo update or correction ', 121 );
1569 hr_utility.set_location(' p_object_version_number 1 ' || p_object_version_number , 121 );
1570
1571 ben_prtt_enrt_actn_api.delete_prtt_enrt_actn
1572 (p_prtt_enrt_actn_id => p_prtt_enrt_actn_id,
1573 p_business_group_id => p_business_group_id,
1574 p_effective_date => p_effective_date,
1575 p_datetrack_mode => l_datetrack_mode2,
1576 p_object_version_number => p_object_version_number,
1577 p_unsuspend_enrt_flag => 'N',
1578 p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id,
1579 p_rslt_object_version_number => l_dummy_number,
1580 p_effective_start_date => l_effective_start_date,
1581 p_effective_end_date => l_effective_end_date
1582 );
1583 end if;
1584 hr_utility.set_location(' p_object_version_number 2 ' || p_object_version_number , 121 );
1585 open c_curr_ovn_of_actn(p_prtt_enrt_actn_id);
1586 fetch c_curr_ovn_of_actn into curr_ovn;
1587 close c_curr_ovn_of_actn;
1588 hr_utility.set_location('curr_ovn ' || curr_ovn , 121 );
1589 if curr_ovn is not null then
1590 ben_prtt_enrt_actn_api.update_prtt_enrt_actn
1591 (p_cmpltd_dt => l_cmpltd_dt
1592 ,p_prtt_enrt_actn_id => p_prtt_enrt_actn_id
1593 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
1594 ,p_rslt_object_version_number => p_rslt_object_version_number
1595 ,p_actn_typ_id => p_actn_typ_id
1596 ,p_rqd_flag => p_rqd_flag
1597 ,p_effective_date => p_effective_date
1598 ,p_post_rslt_flag => p_post_rslt_flag
1599 ,p_business_group_id => p_business_group_id
1600 ,p_effective_start_date => l_effective_start_date
1601 ,p_effective_end_date => l_effective_end_date
1602 -- ,p_object_version_number => p_object_version_number 6010780
1603 ,p_object_version_number => curr_ovn
1604 ,p_datetrack_mode => l_datetrack_mode
1605 );
1606 end if;
1607 end if;
1608 --
1609 if g_debug then
1610 hr_utility.set_location ('Leaving '||l_proc, 10);
1611 end if;
1612 --
1613 exception
1614 when others then
1615
1616 if g_debug then
1617 hr_utility.set_location('Exception Raised '||l_proc, 10);
1618 end if;
1619 -- Init Variables for NOCOPY
1620 p_rslt_object_version_number := l_rslt_object_version_number ;
1621 p_object_version_number := l_object_version_number ;
1622
1623 raise;
1624 --
1625 end set_cmpltd_dt;
1626 --
1627 -- ----------------------------------------------------------------------------
1628 -- |---------------------< complete_this_action_item >-----------------------|
1629 -- ----------------------------------------------------------------------------
1630 --
1631 procedure complete_this_action_item
1632 (p_prtt_enrt_actn_id in number
1633 ,p_effective_date in date
1634 ,p_validate in boolean default false
1635 ,p_datetrack_mode in varchar2 default hr_api.g_correction
1636 ,p_post_rslt_flag in varchar2 default 'Y') is
1637 --
1638 -- this procedure will set the completed date for a single open action item
1639 -- for a participant result both dependent and beneficiary
1640 --
1641 l_proc varchar2(80);
1642 --
1643 cursor c_actn_this is
1644 select pea.prtt_enrt_rslt_id,
1645 pea.actn_typ_id,
1646 pea.object_version_number,
1647 pea.business_group_id,
1648 pea.effective_start_date,
1649 pea.effective_end_date,
1650 pen.object_version_number rslt_object_version_number
1651 from ben_prtt_enrt_actn_f pea,
1652 ben_prtt_enrt_rslt_f pen
1653 where pea.prtt_enrt_actn_id = p_prtt_enrt_actn_id
1654 and pea.cmpltd_dt IS NULL
1655 and pen.prtt_enrt_rslt_stat_cd is null
1656 and p_effective_date between pea.effective_start_date
1657 and pea.effective_end_date
1658 and pea.prtt_enrt_rslt_id = pen.prtt_enrt_rslt_id
1659 and p_effective_date between pen.effective_start_date
1660 and pen.effective_end_date
1661 ;
1662 --
1663 begin
1664 --
1665 g_debug := hr_utility.debug_enabled;
1666 if g_debug then
1667 l_proc := g_package||'.complete_this_action_item';
1668 hr_utility.set_location ('Entering '||l_proc,10);
1669 end if;
1670 --
1671 -- Using table api update the record for an action item
1672 --
1673 for l_actn_this in c_actn_this loop
1674 --
1675 set_cmpltd_dt
1676 (p_prtt_enrt_actn_id => p_prtt_enrt_actn_id
1677 ,p_prtt_enrt_rslt_id => l_actn_this.prtt_enrt_rslt_id
1678 ,p_rslt_object_version_number => l_actn_this.rslt_object_version_number
1679 ,p_actn_typ_id => l_actn_this.actn_typ_id
1680 ,p_effective_date => p_effective_date
1681 ,p_post_rslt_flag => p_post_rslt_flag
1682 ,p_business_group_id => l_actn_this.business_group_id
1683 ,p_object_version_number => l_actn_this.object_version_number
1684 ,p_open_close => 'CLOSE'
1685 ,p_datetrack_mode => p_datetrack_mode);
1686 --
1687 end loop;
1688 --
1689 if g_debug then
1690 hr_utility.set_location ('Leaving '||l_proc, 10);
1691 end if;
1692 --
1693 exception
1694 when others then
1695 if g_debug then
1696 hr_utility.set_location('Exception Raised '||l_proc, 10);
1697 end if;
1698 raise;
1699 --
1700 end complete_this_action_item;
1701 --
1702 -- ----------------------------------------------------------------------------
1703 -- |------------------------< delete_prtt_ctfn_prvdd >------------------------|
1704 -- ----------------------------------------------------------------------------
1705 --
1706 procedure delete_prtt_ctfn_prvdd
1707 (p_prtt_enrt_ctfn_prvdd_id in number
1708 ,p_object_version_number in out nocopy number
1709 ,p_effective_date in date
1710 ,p_datetrack_mode in varchar2 default DTMODE_DELETE) is
1711 --
1712 -- for participant certifications
1713 -- this procedure datetrack deletes the ben_prtt_enrt_ctfn_prvdd_f
1714 --
1715 l_proc varchar2(80);
1716 l_effective_start_date date;
1717 l_effective_end_date date;
1718 l_object_version_number number(15);
1719
1720 --
1721 begin
1722 --
1723 if g_debug then
1724 l_proc := g_package||'.delete_prtt_ctfn_prvdd';
1725 hr_utility.set_location ('Entering '||l_proc,10);
1726 end if;
1727 --
1728 l_object_version_number := p_object_version_number ;
1729
1730 -- date track delete the record for a participant certification item
1731 --
1732 ben_prtt_enrt_ctfn_prvdd_api.delete_prtt_enrt_ctfn_prvdd
1733 (p_prtt_enrt_ctfn_prvdd_id => p_prtt_enrt_ctfn_prvdd_id
1734 ,p_effective_start_date => l_effective_start_date
1735 ,p_effective_end_date => l_effective_end_date
1736 ,p_object_version_number => p_object_version_number
1737 ,p_effective_date => p_effective_date
1738 ,p_datetrack_mode => p_datetrack_mode);
1739 --
1740 if g_debug then
1741 hr_utility.set_location ('Leaving '||l_proc, 10);
1742 end if;
1743 --
1744 exception
1745 when others then
1746
1747 if g_debug then
1748 hr_utility.set_location('Exception Raised '||l_proc, 10);
1749 end if;
1750 p_object_version_number := l_object_version_number ;
1751
1752 raise;
1753 --
1754 end delete_prtt_ctfn_prvdd;
1755 --
1756 -- ----------------------------------------------------------------------------
1757 -- |-----------------------< delete_dpnt_ctfn_prvdd >-------------------------|
1758 -- ----------------------------------------------------------------------------
1759 --
1760 procedure delete_dpnt_ctfn_prvdd
1761 (p_cvrd_dpnt_ctfn_prvdd_id in number
1762 ,p_object_version_number in out nocopy number
1763 ,p_effective_date in date
1764 ,p_business_group_id in number
1765 ,p_datetrack_mode in varchar2 default DTMODE_DELETE) is
1766 --
1767 -- for a dependent certification for a participant
1768 -- datetrack_mode delete
1769 --
1770 l_proc varchar2(80);
1771 l_effective_start_date date;
1772 l_effective_end_date date;
1773 l_object_version_number number(15);
1774
1775 --
1776 begin
1777 --
1778 if g_debug then
1779 l_proc := g_package||'.delete_dpnt_ctfn_prvdd';
1780 hr_utility.set_location ('Entering '||l_proc,10);
1781 end if;
1782 --
1783 l_object_version_number := p_object_version_number ;
1784
1785 -- date track delete the record for a dependent certification item
1786 --
1787 ben_cvrd_dpnt_ctfn_prvdd_api.delete_cvrd_dpnt_ctfn_prvdd
1788 (p_cvrd_dpnt_ctfn_prvdd_id => p_cvrd_dpnt_ctfn_prvdd_id
1789 ,p_effective_start_date => l_effective_start_date
1790 ,p_effective_end_date => l_effective_end_date
1791 ,p_object_version_number => p_object_version_number
1792 ,p_effective_date => p_effective_date
1793 ,p_business_group_id => p_business_group_id
1794 ,p_datetrack_mode => p_datetrack_mode
1795 ,p_called_from => 'benactcm' );
1796 --
1797 if g_debug then
1798 hr_utility.set_location ('Leaving '||l_proc, 10);
1799 end if;
1800 --
1801 exception
1802 when others then
1803 if g_debug then
1804 hr_utility.set_location('Exception Raised '||l_proc, 10);
1805 end if;
1806 p_object_version_number := l_object_version_number ;
1807 raise;
1808 --
1809 end delete_dpnt_ctfn_prvdd;
1810 --
1811 -- ----------------------------------------------------------------------------
1812 -- |----------------------< remove_prtt_certifications >----------------------|
1813 -- ----------------------------------------------------------------------------
1814 --
1815 procedure remove_prtt_certifications
1816 (p_prtt_enrt_rslt_id in number
1817 ,p_effective_date in date
1818 ,p_business_group_id in number
1819 ,p_datetrack_mode in varchar2 default DTMODE_DELETE) is
1820 --
1821 -- this procedure removes participant certifications from
1822 -- ben_prtt_enrt_ctfn_prvdd_f. This is datetrack_mode controlled
1823 --
1824 l_proc varchar2(80);
1825 -- CFW2
1826 cursor c_prtt_ctfn_prvdd is
1827 select pcs.prtt_enrt_ctfn_prvdd_id,
1828 pcs.object_version_number
1829 from ben_prtt_enrt_ctfn_prvdd_f pcs,
1830 ben_prtt_enrt_actn_f pea,
1831 ben_per_in_ler pil
1832 where pcs.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
1833 and pcs.enrt_ctfn_recd_dt is NULL
1834 and pcs.business_group_id = p_business_group_id
1835 and p_effective_date between pcs.effective_start_date
1836 and pcs.effective_end_date
1837 and pea.prtt_enrt_actn_id=pcs.prtt_enrt_actn_id
1838 and pea.pl_bnf_id is null
1839 and pea.elig_cvrd_dpnt_id is null
1840 and pea.per_in_ler_id = pil.per_in_ler_id
1841 and pil.per_in_ler_stat_cd not in ('BCKDT', 'VOIDD')
1842 and pea.business_group_id=p_business_group_id
1843 and p_effective_date between pea.effective_start_date
1844 and pea.effective_end_date
1845 ;
1846 --
1847 begin
1848 --
1849 if g_debug then
1850 l_proc := g_package||'.remove_prtt_certifications';
1851 hr_utility.set_location ('Entering '||l_proc,10);
1852 end if;
1853 --
1854 -- Using table api write a new record for an action item
1855 --
1856 for l_prtt_ctfn_prvdd in c_prtt_ctfn_prvdd loop
1857 --
1858 delete_prtt_ctfn_prvdd
1859 (p_prtt_enrt_ctfn_prvdd_id => l_prtt_ctfn_prvdd.prtt_enrt_ctfn_prvdd_id
1860 ,p_object_version_number => l_prtt_ctfn_prvdd.object_version_number
1861 ,p_effective_date => p_effective_date
1862 ,p_datetrack_mode => p_datetrack_mode);
1863 --
1864 end loop;
1865 --
1866 if g_debug then
1867 hr_utility.set_location ('Leaving '||l_proc, 10);
1868 end if;
1869 --
1870 exception
1871 when others then
1872 if g_debug then
1873 hr_utility.set_location('Exception Raised '||l_proc, 10);
1874 end if;
1875 raise;
1876 --
1877 end remove_prtt_certifications;
1878 --
1879 -- ----------------------------------------------------------------------------
1880 -- |----------------------< remove_dpnt_certifications >----------------------|
1881 -- ----------------------------------------------------------------------------
1882 --
1883 procedure remove_dpnt_certifications
1884 (p_prtt_enrt_rslt_id in number
1885 ,p_effective_date in date
1886 ,p_business_group_id in number
1887 ,p_datetrack_mode in varchar2 default DTMODE_DELETE
1888 ,p_effective_start_date out nocopy date
1889 ,p_effective_end_date out nocopy date) is
1890 --
1891 -- this procedure removes certifications for dependents of a participant
1892 -- if cvrd_flag = Y and dpnt_dsgn_ctfn_recd_dt is NULL
1893 -- this is datetrack_mode controlled
1894 --
1895 l_proc varchar2(80);
1896
1897 --
1898 cursor c_dpnt_ctfn_prvdd is
1899 select prv.cvrd_dpnt_ctfn_prvdd_id,
1900 prv.object_version_number
1901 from ben_elig_cvrd_dpnt_f ecd, ben_cvrd_dpnt_ctfn_prvdd_f prv,
1902 ben_per_in_ler pil
1903 where ecd.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
1904 and ecd.cvg_strt_dt is not null
1905 and nvl(ecd.cvg_thru_dt, hr_api.g_eot) = hr_api.g_eot
1906 and ecd.elig_cvrd_dpnt_id = prv.elig_cvrd_dpnt_id
1907 and prv.dpnt_dsgn_ctfn_recd_dt is NULL
1908 and ecd.business_group_id = p_business_group_id
1909 and p_effective_date between ecd.effective_start_date
1910 and ecd.effective_end_date
1911 and prv.business_group_id = p_business_group_id
1912 and p_effective_date between prv.effective_start_date
1913 and prv.effective_end_date
1914 and pil.per_in_ler_id=ecd.per_in_ler_id
1915 and pil.business_group_id=p_business_group_id
1916 and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT');
1917 --
1918 begin
1919 --
1920 if g_debug then
1921 l_proc := g_package||'.remove_dpnt_certifications';
1922 hr_utility.set_location ('Entering '||l_proc,10);
1923 end if;
1924 --
1925 for l_dpnt_ctfn_prvdd in c_dpnt_ctfn_prvdd loop
1926 --
1927 delete_dpnt_ctfn_prvdd
1928 (p_cvrd_dpnt_ctfn_prvdd_id => l_dpnt_ctfn_prvdd.cvrd_dpnt_ctfn_prvdd_id
1929 ,p_object_version_number => l_dpnt_ctfn_prvdd.object_version_number
1930 ,p_effective_date => p_effective_date
1931 ,p_business_group_id => p_business_group_id
1932 ,p_datetrack_mode => p_datetrack_mode);
1933 --
1934 end loop;
1935 --
1936 if g_debug then
1937 hr_utility.set_location ('Leaving '||l_proc, 10);
1938 end if;
1939 --
1940 exception
1941 when others then
1942 p_effective_start_date := null;
1943 p_effective_end_date := null;
1944
1945 if g_debug then
1946 hr_utility.set_location('Exception Raised '||l_proc, 10);
1947 end if;
1948 raise;
1949 --
1950 end remove_dpnt_certifications;
1951 --
1952 -- ----------------------------------------------------------------------------
1953 -- |-------------------------< delete_action_item >---------------------------|
1954 -- ----------------------------------------------------------------------------
1955 --
1956 procedure delete_action_item
1957 (p_prtt_enrt_actn_id in number
1958 ,p_object_version_number in out nocopy number
1959 ,p_business_group_id in number
1960 ,p_effective_date in date
1961 ,p_datetrack_mode in varchar2 default DTMODE_DELETE
1962 ,p_prtt_enrt_rslt_id in number
1963 ,p_rslt_object_version_number in out nocopy number
1964 ,p_post_rslt_flag in varchar2) is
1965 --
1966 l_proc varchar2(80);
1967 l_effective_start_date date;
1968 l_effective_end_date date;
1969 l_object_version_number number(15);
1970 l_rslt_object_version_number number(15);
1971
1972 --
1973 begin
1974 --
1975 if g_debug then
1976 l_proc := g_package||'.delete_action_item';
1977 hr_utility.set_location ('Entering '||l_proc,10);
1978 end if;
1979 if g_debug then
1980 hr_utility.set_location(p_datetrack_mode || ' ' || l_proc, 10);
1981 end if;
1982 --
1983 l_object_version_number := p_object_version_number;
1984 l_rslt_object_version_number := p_rslt_object_version_number ;
1985
1986 -- Using table api datetrack delete the record for an action item
1987 --
1988 ben_prtt_enrt_actn_api.delete_prtt_enrt_actn
1989 (p_prtt_enrt_actn_id => p_prtt_enrt_actn_id
1990 ,p_business_group_id => p_business_group_id
1991 ,p_effective_date => p_effective_date
1992 ,p_datetrack_mode => p_datetrack_mode
1993 ,p_object_version_number => p_object_version_number
1994 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
1995 ,p_rslt_object_version_number => p_rslt_object_version_number
1996 ,p_post_rslt_flag => p_post_rslt_flag
1997 ,p_effective_start_date => l_effective_start_date
1998 ,p_effective_end_date => l_effective_end_date);
1999 --
2000 if g_debug then
2001 hr_utility.set_location ('Leaving '||l_proc, 10);
2002 end if;
2003 --
2004 exception
2005 when others then
2006 if g_debug then
2007 hr_utility.set_location('Exception Raised '||l_proc, 10);
2008 end if;
2009 p_object_version_number := l_object_version_number ;
2010 p_rslt_object_version_number := l_rslt_object_version_number ;
2011 raise;
2012 --
2013 end delete_action_item;
2014 --
2015 --
2016 procedure get_ctfn_count
2017 (p_prtt_enrt_actn_id in number,
2018 p_prtt_enrt_rslt_id in number default null,
2019 p_elig_cvrd_dpnt_id in number default null,
2020 p_pl_bnf_id in number default null,
2021 p_effective_date in date,
2022 p_optional_count out nocopy number,
2023 p_required_count out nocopy number,
2024 p_open_optional_count out nocopy number,
2025 p_open_required_count out nocopy number) is
2026 --
2027 cursor c_pcs is
2028 select sum(1) tot_ctfn,
2029 sum(decode(pcs.enrt_ctfn_rqd_flag,'Y',1,0)) tot_rqd,
2030 sum(decode(pcs.enrt_ctfn_recd_dt,null,1,0)) tot_open_ctfn,
2031 sum(decode(pcs.enrt_ctfn_rqd_flag,'N',0,
2032 decode(pcs.enrt_ctfn_recd_dt,null,1,0))) tot_open_rqd
2033 from ben_prtt_enrt_ctfn_prvdd_f pcs
2034 where pcs.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
2035 and pcs.prtt_enrt_actn_id = p_prtt_enrt_actn_id
2036 and p_effective_date between
2037 pcs.effective_start_date and pcs.effective_end_date;
2038 --
2039 cursor c_ccp is
2040 select sum(1) tot_ctfn,
2041 sum(decode(ccp.dpnt_dsgn_ctfn_rqd_flag,'Y',1,0)) tot_rqd,
2042 sum(decode(ccp.dpnt_dsgn_ctfn_recd_dt,null,1,0)) tot_open_ctfn,
2043 sum(decode(ccp.dpnt_dsgn_ctfn_rqd_flag,'N',0,
2044 decode(ccp.dpnt_dsgn_ctfn_recd_dt,null,1,0))) tot_open_rqd
2045 from ben_cvrd_dpnt_ctfn_prvdd_f ccp
2046 where ccp.prtt_enrt_actn_id = p_prtt_enrt_actn_id
2047 and ccp.elig_cvrd_dpnt_id = p_elig_cvrd_dpnt_id
2048 and p_effective_date between
2049 ccp.effective_start_date and ccp.effective_end_date;
2050 --
2051 cursor c_pbc is
2052 select sum(1) tot_ctfn,
2053 sum(decode(pbc.bnf_ctfn_rqd_flag,'Y',1,0)) tot_rqd,
2054 sum(decode(pbc.bnf_ctfn_recd_dt,null,1,0)) tot_open_ctfn,
2055 sum(decode(pbc.bnf_ctfn_rqd_flag,'N',0,
2056 decode(pbc.bnf_ctfn_recd_dt,null,1,0))) tot_open_rqd
2057 from ben_pl_bnf_ctfn_prvdd_f pbc
2058 where pbc.prtt_enrt_actn_id = p_prtt_enrt_actn_id
2059 and pbc.pl_bnf_id = p_pl_bnf_id
2060 and p_effective_date between
2061 pbc.effective_start_date and pbc.effective_end_date;
2062 --
2063 l_ctfn c_pbc%rowtype;
2064 --
2065 l_proc varchar2(80) ;
2066 --
2067 begin
2068 --
2069 if g_debug then
2070 l_proc := g_package || '.get_ctfn_count';
2071 hr_utility.set_location ('Entering '||l_proc,10);
2072 end if;
2073 --
2074 p_optional_count := 0;
2075 p_required_count := 0;
2076 p_open_required_count := 0;
2077 p_open_optional_count := 0;
2078 --
2079 if p_prtt_enrt_actn_id is null then
2080 if g_debug then
2081 hr_utility.set_location ('Leaving '||l_proc,97);
2082 end if;
2083 return;
2084 end if;
2085 --
2086 if p_elig_cvrd_dpnt_id is not null then
2087 --
2088 open c_ccp;
2089 fetch c_ccp into l_ctfn;
2090 close c_ccp;
2091 --
2092 elsif p_pl_bnf_id is not null then
2093 --
2094 open c_pbc;
2095 fetch c_pbc into l_ctfn;
2096 close c_pbc;
2097 --
2098 elsif p_prtt_enrt_rslt_id is not null then
2099 --
2100 open c_pcs;
2101 fetch c_pcs into l_ctfn;
2102 close c_pcs;
2103 --
2104 else
2105 if g_debug then
2106 hr_utility.set_location ('Leaving '||l_proc,98);
2107 end if;
2108 return;
2109 --
2110 end if;
2111 --
2112 p_required_count := l_ctfn.tot_rqd +0;
2113 p_optional_count := l_ctfn.tot_ctfn - l_ctfn.tot_rqd + 0;
2114 p_open_required_count := l_ctfn.tot_open_rqd + 0;
2115 p_open_optional_count := l_ctfn.tot_open_ctfn - p_open_required_count +0;
2116
2117 hr_utility.set_location ('l_ctfn.tot_rqd '|| l_ctfn.tot_rqd,10);
2118 hr_utility.set_location ('l_ctfn.tot_ctfn '|| l_ctfn.tot_ctfn,10);
2119 hr_utility.set_location ('l_ctfn.tot_open_rqd '|| l_ctfn.tot_open_rqd,10);
2120 hr_utility.set_location ('l_ctfn.tot_open_ctfn '|| l_ctfn.tot_open_ctfn,10);
2121 hr_utility.set_location ('p_open_required_count '|| p_open_required_count,10);
2122
2123 --
2124 if g_debug then
2125 hr_utility.set_location ('Leaving '||l_proc,99);
2126 end if;
2127 --
2128 end get_ctfn_count;
2129 --
2130 --
2131 -- ----------------------------------------------------------------------------
2132 -- |-------------------------< process_action_item >--------------------------|
2133 -- ----------------------------------------------------------------------------
2134 --
2135 procedure process_action_item
2136 (p_prtt_enrt_actn_id in out nocopy number
2137 ,p_actn_typ_id in number
2138 ,p_cmpltd_dt in date
2139 ,p_object_version_number in out nocopy number
2140 ,p_effective_date in date
2141 ,p_rqd_data_found in boolean
2142 ,p_prtt_enrt_rslt_id in number
2143 ,p_elig_cvrd_dpnt_id in number default null
2144 ,p_pl_bnf_id in number default null
2145 ,p_rqd_flag in varchar2 default 'Y'
2146 ,p_post_rslt_flag in varchar2 default 'Y'
2147 ,p_business_group_id in number
2148 ,p_datetrack_mode in varchar2
2149 ,p_rslt_object_version_number in out nocopy number) is
2150 --
2151 l_proc varchar2(80);
2152
2153 l_prtt_enrt_actn_id number(15);
2154 l_object_version_number number(15);
2155 l_rslt_object_version_number number(15);
2156
2157
2158 --
2159 begin
2160 --
2161 g_debug := hr_utility.debug_enabled;
2162 if g_debug then
2163 l_proc := g_package||'.process_action_item';
2164 hr_utility.set_location ('Entering '||l_proc,10);
2165 end if;
2166 --
2167 l_prtt_enrt_actn_id := p_prtt_enrt_actn_id ;
2168 l_object_version_number := p_object_version_number ;
2169 l_rslt_object_version_number := p_rslt_object_version_number;
2170
2171 --
2172 if (p_prtt_enrt_actn_id IS NULL and p_rqd_data_found = FALSE) then
2173 --
2174 -- An action item does not exist and required data is not found. Write a
2175 -- new action item
2176 --
2177 write_new_action_item
2178 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
2179 ,p_rslt_object_version_number => p_rslt_object_version_number
2180 ,p_actn_typ_id => p_actn_typ_id
2181 ,p_effective_date => p_effective_date
2182 ,p_post_rslt_flag => p_post_rslt_flag
2183 ,p_business_group_id => p_business_group_id
2184 ,p_elig_cvrd_dpnt_id => p_elig_cvrd_dpnt_id
2185 ,p_pl_bnf_id => p_pl_bnf_id
2186 ,p_rqd_flag => p_rqd_flag
2187 ,p_cmpltd_dt => p_cmpltd_dt
2188 ,p_prtt_enrt_actn_id => p_prtt_enrt_actn_id
2189 ,p_object_version_number => p_object_version_number);
2190 --
2191 elsif p_prtt_enrt_actn_id IS NOT NULL and
2192 p_rqd_data_found = TRUE and
2193 p_cmpltd_dt IS NULL then
2194 --
2195 -- Existing open action item but we now have required data. Close the open
2196 -- action item by setting cmpltd_dt field
2197 --
2198 set_cmpltd_dt
2199 (p_prtt_enrt_actn_id => p_prtt_enrt_actn_id
2200 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
2201 ,p_rslt_object_version_number => p_rslt_object_version_number
2202 ,p_actn_typ_id => p_actn_typ_id
2203 ,p_rqd_flag => p_rqd_flag
2204 ,p_effective_date => p_effective_date
2205 ,p_post_rslt_flag => p_post_rslt_flag
2206 ,p_business_group_id => p_business_group_id
2207 ,p_object_version_number => p_object_version_number
2208 ,p_open_close => 'CLOSE'
2209 ,p_datetrack_mode => p_datetrack_mode);
2210 --
2211 elsif p_prtt_enrt_actn_id IS NOT NULL and
2212 p_rqd_data_found = FALSE and
2213 p_cmpltd_dt IS NOT NULL then
2214 --
2215 -- Found a closed action item. But required data is missing. Reopen item
2216 --
2217 set_cmpltd_dt
2218 (p_prtt_enrt_actn_id => p_prtt_enrt_actn_id
2219 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
2220 ,p_rslt_object_version_number => p_rslt_object_version_number
2221 ,p_actn_typ_id => p_actn_typ_id
2222 ,p_rqd_flag => p_rqd_flag
2223 ,p_effective_date => p_effective_date
2224 ,p_post_rslt_flag => p_post_rslt_flag
2225 ,p_business_group_id => p_business_group_id
2226 ,p_object_version_number => p_object_version_number
2227 ,p_open_close => 'OPEN'
2228 ,p_datetrack_mode => p_datetrack_mode);
2229 --
2230 else
2231 -- p_prtt_enrt_actn_id IS NOT NULL and p_rqd_data_found = FALSE
2232 -- and p_cmpltd_dt is null
2233 -- i.e. existing action still no information and not completed.
2234 -- p_prtt_enrt_actn_id IS NOT NULL and p_rqd_data_found=TRUE
2235 -- and p_cmpltd_dt is not null.
2236 -- i.e. action action had already been completed with all information.
2237 -- p_prtt_enrt_actn_id IS NULL and p_rqd_data_found = TRUE
2238 -- i.e. have always had information
2239 NULL;
2240 end if;
2241 --
2242 if g_debug then
2243 hr_utility.set_location ('Leaving '||l_proc, 10);
2244 end if;
2245 --
2246 exception
2247 when others then
2248
2249 if g_debug then
2250 hr_utility.set_location('Exception Raised '||l_proc, 10);
2251 end if;
2252
2253 p_prtt_enrt_actn_id := l_prtt_enrt_actn_id ;
2254 p_object_version_number := l_object_version_number ;
2255 p_rslt_object_version_number := l_rslt_object_version_number ;
2256
2257 raise;
2258 --
2259 end process_action_item;
2260 --
2261 procedure process_new_ctfn_action(
2262 p_prtt_enrt_rslt_id in number,
2263 p_elig_cvrd_dpnt_id in number default null,
2264 p_pl_bnf_id in number default null,
2265 p_actn_typ_cd in varchar2,
2266 p_ctfn_rqd_flag in varchar2,
2267 p_ctfn_recd_dt in date default null,
2268 p_business_group_id in number,
2269 p_effective_date in date,
2270 p_prtt_enrt_actn_id out nocopy number) is
2271 --
2272 l_proc varchar2(80);
2273 --
2274 l_actn_typ_id number := null;
2275 l_cmpltd_dt date := null;
2276 l_data_found boolean := false;
2277 l_object_version_number number := null;
2278 l_rslt_object_version_number number := null;
2279 l_optional number;
2280 l_required number;
2281 l_open_optional number;
2282 l_open_required number;
2283 --
2284 --Bug 6353069
2285 cursor c_pen is
2286 select pen.pgm_id,
2287 pen.ptip_id,
2288 pen.pl_id,
2289 pen.pl_typ_id,
2290 pen.oipl_id,
2291 pen.ler_id,
2292 pen.person_id,
2293 pen.object_version_number
2294 from ben_prtt_enrt_rslt_f pen
2295 where pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
2296 and pen.business_group_id = p_business_group_id
2297 and pen.prtt_enrt_rslt_stat_cd is null
2298 and p_effective_date between
2299 pen.effective_start_date and pen.effective_end_date;
2300
2301 l_rslt c_pen%rowtype;
2302
2303 -- Cursor to retrieve the dependent designation level
2304 --
2305 cursor c_dpnt_lvl_cd (p_pgm_id number) is
2306 select pgm.dpnt_dsgn_lvl_cd
2307 from ben_pgm_f pgm
2308 where pgm.pgm_id = p_pgm_id
2309 and pgm.business_group_id = p_business_group_id
2310 and p_effective_date between
2311 pgm.effective_start_date and pgm.effective_end_date;
2312 --
2313 -- Cursor to retrieve dependant required flags at the pgm level
2314 --
2315 cursor c_dpnt_pgm (p_pgm_id number) is
2316 select pgm.susp_if_ctfn_not_dpnt_flag
2317 from ben_pgm_f pgm
2318 where pgm.pgm_id = p_pgm_id
2319 and pgm.business_group_id = p_business_group_id
2320 and p_effective_date between
2321 pgm.effective_start_date and pgm.effective_end_date;
2322 --
2323 l_dpnt c_dpnt_pgm%rowtype;
2324 --
2325 -- cursor to retrieve dpnts' required-info-flags at the ptip level
2326 --
2327 cursor c_dpnt_ptip (p_ptip_id number) is
2328 select ptip.susp_if_ctfn_not_dpnt_flag
2329 from ben_ptip_f ptip
2330 where ptip.ptip_id = p_ptip_id
2331 and ptip.business_group_id = p_business_group_id
2332 and p_effective_date between
2333 ptip.effective_start_date and ptip.effective_end_date;
2334 --
2335 -- Cursor to retrieve dpnt required flags at the plan level
2336 --
2337 cursor c_dpnt_pl (p_pl_id number) is
2338 select pl.susp_if_ctfn_not_dpnt_flag
2339 from ben_pl_f pl
2340 where pl.pl_id = p_pl_id
2341 and pl.business_group_id = p_business_group_id
2342 and p_effective_date between
2343 pl.effective_start_date and pl.effective_end_date;
2344 --
2345 -- Cursor to retrieve Suspend Enrollment Flag at the various levels
2346 --
2347 cursor c_ldc (p_lvl_cd varchar) is
2348 select ldc.susp_if_ctfn_not_prvd_flag
2349 from BEN_LER_CHG_DPNT_CVG_f ldc,
2350 ben_prtt_enrt_rslt_f pen
2351 where pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
2352 and pen.business_group_id = p_business_group_id
2353 and p_effective_date between pen.effective_start_date
2354 and pen.effective_end_date
2355 and pen.ler_id = ldc.ler_id
2356 and pen.prtt_enrt_rslt_stat_cd is null
2357 and p_effective_date between ldc.effective_start_date
2358 and ldc.effective_end_date
2359 and ((p_lvl_cd = 'PTIP' and ldc.ptip_id = pen.ptip_id) OR
2360 (p_lvl_cd = 'PL' and ldc.pl_id = pen.pl_id) OR
2361 (p_lvl_cd = 'PGM' and ldc.pgm_id = pen.pgm_id));
2362
2363
2364 l_ler_susp_if_ctfn_not_prvd varchar2(30);
2365 l_rqd_flag varchar2(30) := 'Y';
2366 l_lvl_cd ben_pgm_f.dpnt_dsgn_lvl_cd%type;
2367
2368 --End Bug 6353069
2369
2370
2371 --
2372 begin
2373 --
2374 g_debug := hr_utility.debug_enabled;
2375 if g_debug then
2376 l_proc := g_package||'.process_ctfn_action_item';
2377 hr_utility.set_location ('Entering '||l_proc, 10);
2378 end if;
2379 --
2380 p_prtt_enrt_actn_id := null;
2381 --
2382 l_actn_typ_id := get_actn_typ_id
2383 (p_type_cd => p_actn_typ_cd,
2384 p_business_group_id => p_business_group_id);
2385 --
2386 get_prtt_enrt_actn_id
2387 (p_actn_typ_id => l_actn_typ_id,
2388 p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id,
2389 p_elig_cvrd_dpnt_id => p_elig_cvrd_dpnt_id,
2390 p_pl_bnf_id => p_pl_bnf_id,
2391 p_effective_date => p_effective_date,
2392 p_business_group_id => p_business_group_id,
2393 p_prtt_enrt_actn_id => p_prtt_enrt_actn_id,
2394 p_cmpltd_dt => l_cmpltd_dt,
2395 p_object_version_number => l_object_version_number);
2396 --
2397 if p_ctfn_rqd_flag = 'Y' and p_ctfn_recd_dt is null then
2398 --
2399 -- Case 1: Required open ctfn
2400 -- We require a open action item for this open required ctfn.
2401 --
2402 l_data_found := false;
2403 --
2404 elsif p_ctfn_rqd_flag = 'Y' and p_ctfn_recd_dt is not null then
2405 --
2406 -- Case 2: Required Closed Ctfn.
2407 --
2408 if p_prtt_enrt_actn_id is not null then
2409 --
2410 -- The ctfn we are inserting is required but also closed, so
2411 -- we just require the action item id to write the ctfn.
2412 -- Action item found, do not do anything with action items.
2413 --
2414 return;
2415 --
2416 else
2417 --
2418 -- No action item found, so we need to create a closed
2419 -- action item.
2420 --
2421 l_data_found := false;
2422 l_cmpltd_dt := p_effective_date;
2423 --
2424 end if;
2425 --
2426 elsif p_ctfn_rqd_flag = 'N' and p_ctfn_recd_dt is null then
2427 --
2428 -- Case 3: Optional Open Ctfn.
2429 --
2430 hr_utility.set_location ('p_ctfn_rqd_flag '|| p_ctfn_rqd_flag,10);
2431 hr_utility.set_location ('p_ctfn_recd_dt '|| p_ctfn_recd_dt,10);
2432
2433 get_ctfn_count
2434 (p_prtt_enrt_actn_id => p_prtt_enrt_actn_id
2435 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
2436 ,p_elig_cvrd_dpnt_id => p_elig_cvrd_dpnt_id
2437 ,p_pl_bnf_id => p_pl_bnf_id
2438 ,p_effective_date => p_effective_date
2439 ,p_required_count => l_required
2440 ,p_optional_count => l_optional
2441 ,p_open_required_count => l_open_required
2442 ,p_open_optional_count => l_open_optional);
2443 --
2444 if l_optional > 0 then
2445 --
2446 -- Optional Ctfn already exists. It means the action item would
2447 -- have been already created. Creation of new Optional Open Ctfn
2448 -- does not change anything, so just return.
2449 --
2450 return;
2451 --
2452 else
2453 --
2454 -- No optional ctfn. exists. So we need to have a open action item.
2455 --
2456 l_data_found := false;
2457 --
2458 end if;
2459 --
2460 elsif p_ctfn_rqd_flag = 'N' and p_ctfn_recd_dt is not null then
2461 --
2462 -- Case 4: Optional Closed Ctfn.
2463 --
2464 hr_utility.set_location ('p_ctfn_rqd_flag '|| p_ctfn_rqd_flag,11);
2465 hr_utility.set_location ('p_ctfn_recd_dt '|| p_ctfn_recd_dt,11);
2466
2467 get_ctfn_count
2468 (p_prtt_enrt_actn_id => p_prtt_enrt_actn_id
2469 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
2470 ,p_elig_cvrd_dpnt_id => p_elig_cvrd_dpnt_id
2471 ,p_pl_bnf_id => p_pl_bnf_id
2472 ,p_effective_date => p_effective_date
2473 ,p_required_count => l_required
2474 ,p_optional_count => l_optional
2475 ,p_open_required_count => l_open_required
2476 ,p_open_optional_count => l_open_optional);
2477 --
2478 if l_optional > 0 and
2479 l_open_optional = l_optional and
2480 l_open_required = 0 then
2481 --
2482 -- All required Ctfn closed and optional ctfn exists and none of
2483 -- the optional ctfn is closed. It means that the new optional closed
2484 -- ctfn. which we are inserting, should close the action item.
2485 --
2486 l_data_found := true;
2487 --
2488 elsif p_prtt_enrt_actn_id is null then
2489 --
2490 -- No action item exists, so we need to create a closed action item.
2491 --
2492 l_data_found := false;
2493 l_cmpltd_dt := p_effective_date;
2494 --
2495 else
2496 --
2497 -- The state of action item remains the same in all other cases,
2498 -- so just return
2499 --
2500 return;
2501 --
2502 end if;
2503 --
2504 else
2505 --
2506 -- Invalid Case.
2507 --
2508 return;
2509 --
2510 end if;
2511 --
2512
2513 --Bug 6353069
2514 OPEN c_pen;
2515 FETCH c_pen INTO l_rslt;
2516 CLOSE c_pen;
2517
2518 IF (p_prtt_enrt_actn_id IS NULL AND l_data_found = FALSE AND p_elig_cvrd_dpnt_id is not NULL)
2519 THEN
2520 --
2521 -- Fetch the designation level code from the ben_pgm_f table.
2522 --
2523 IF l_rslt.pgm_id IS NOT NULL
2524 THEN
2525 OPEN c_dpnt_lvl_cd (p_pgm_id => l_rslt.pgm_id);
2526 FETCH c_dpnt_lvl_cd INTO l_lvl_cd;
2527 CLOSE c_dpnt_lvl_cd;
2528 END IF;
2529
2530 --
2531
2532 IF g_debug
2533 THEN
2534 hr_utility.set_location ('Designation level code : ' || l_lvl_cd,14 );
2535 END IF;
2536
2537 --
2538 -- check the level code for program, ptip or plan (default) and fetch the
2539 -- appropriate required-info-flags.
2540 --
2541 IF (l_lvl_cd = 'PGM' AND l_rslt.pgm_id IS NOT NULL)
2542 THEN
2543 -- Fetch the flags at the program level
2544 OPEN c_dpnt_pgm (p_pgm_id => l_rslt.pgm_id);
2545 FETCH c_dpnt_pgm INTO l_dpnt;
2546 CLOSE c_dpnt_pgm;
2547 --
2548 ELSIF (l_lvl_cd = 'PTIP' AND l_rslt.pgm_id IS NOT NULL)
2549 THEN
2550 -- Fetch the flags at the ptip level
2551 OPEN c_dpnt_ptip (p_ptip_id => l_rslt.ptip_id);
2552 FETCH c_dpnt_ptip INTO l_dpnt;
2553 CLOSE c_dpnt_ptip;
2554 --
2555 ELSE
2556 -- always use plan as default
2557 OPEN c_dpnt_pl (p_pl_id => l_rslt.pl_id);
2558 FETCH c_dpnt_pl INTO l_dpnt;
2559 CLOSE c_dpnt_pl;
2560 l_lvl_cd := 'PL';
2561 --
2562 END IF;
2563
2564 l_rqd_flag := l_dpnt.susp_if_ctfn_not_dpnt_flag;
2565 OPEN c_ldc (l_lvl_cd);
2566 FETCH c_ldc INTO l_ler_susp_if_ctfn_not_prvd;
2567 CLOSE c_ldc;
2568
2569 IF (l_ler_susp_if_ctfn_not_prvd <> NULL)
2570 THEN
2571 l_rqd_flag := l_ler_susp_if_ctfn_not_prvd;
2572 END IF;
2573 ELSE
2574 l_rqd_flag := 'Y';
2575 END IF;
2576
2577 IF g_debug
2578 THEN
2579 hr_utility.set_location ('l_rqd_flag : ' || l_rqd_flag, 14);
2580 END IF;
2581 --End Bug 6353069
2582 --
2583 process_action_item
2584 (p_prtt_enrt_actn_id => p_prtt_enrt_actn_id,
2585 p_actn_typ_id => l_actn_typ_id,
2586 p_cmpltd_dt => l_cmpltd_dt,
2587 p_object_version_number => l_object_version_number,
2588 p_effective_date => p_effective_date,
2589 p_rqd_data_found => l_data_found,
2590 p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id,
2591 p_elig_cvrd_dpnt_id => p_elig_cvrd_dpnt_id,
2592 p_pl_bnf_id => p_pl_bnf_id,
2593 p_rqd_flag => l_rqd_flag, --Bug 6353069
2594 p_post_rslt_flag => 'N',
2595 p_business_group_id => p_business_group_id,
2596 p_datetrack_mode => hr_api.g_update,
2597 p_rslt_object_version_number => l_rslt.object_version_number);
2598 --
2599 if g_debug then
2600 hr_utility.set_location ('Leaving '||l_proc, 10);
2601 end if;
2602 --
2603 end process_new_ctfn_action;
2604 --
2605 -- ----------------------------------------------------------------------------
2606 -- |----------------------------< check_dob >---------------------------------|
2607 -- ----------------------------------------------------------------------------
2608 --
2609 function check_dob
2610 (p_person_id in number
2611 ,p_effective_date in date
2612 ,p_business_group_id in number)
2613 return boolean is
2614 --
2615 l_proc varchar2(80) ;
2616 l_dob_found boolean;
2617 --
2618 cursor c_date_of_birth is
2619 select per.date_of_birth
2620 from per_all_people_f per
2621 where per.person_id = p_person_id
2622 and per.business_group_id = p_business_group_id
2623 and p_effective_date between per.effective_start_date
2624 and per.effective_end_date;
2625 --
2626 l_date_of_birth date;
2627 --
2628 begin
2629 --
2630 g_debug := hr_utility.debug_enabled;
2631 if g_debug then
2632 l_proc := g_package||'.check_dob';
2633 hr_utility.set_location ('Entering '||l_proc,10);
2634 end if;
2635 --
2636 open c_date_of_birth;
2637 fetch c_date_of_birth into l_date_of_birth;
2638 close c_date_of_birth;
2639 --
2640 if l_date_of_birth is not null then
2641 l_dob_found := TRUE;
2642 else
2643 l_dob_found := FALSE;
2644 end if;
2645 --
2646 if g_debug then
2647 hr_utility.set_location ('Leaving ' ||l_proc,10);
2648 end if;
2649 --
2650 return l_dob_found;
2651 --
2652 exception
2653 when others then
2654 if g_debug then
2655 hr_utility.set_location('Exception Raised '||l_proc, 10);
2656 end if;
2657 raise;
2658 --
2659 end check_dob;
2660 --
2661 -- ----------------------------------------------------------------------------
2662 -- |----------------------------< check_adrs >--------------------------------|
2663 -- ----------------------------------------------------------------------------
2664 --
2665 function check_adrs
2666 (p_prtt_enrt_rslt_id in number
2667 ,p_dpnt_bnf_person_id in number
2668 ,p_effective_date in date
2669 ,p_business_group_id in number)
2670 return boolean is
2671 --
2672 -- this function has many things to do. We need to check person resides with
2673 -- the participant. Does the participant have a primary address. A valid
2674 -- zip code. If person does not reside with participant do they have a
2675 -- primary address and a valid zip code.
2676 --
2677 l_proc varchar2(80) ;
2678 l_rsds per_contact_relationships.rltd_per_rsds_w_dsgntr_flag%type;
2679 l_valid_adrs boolean;
2680 --
2681 -- Cursor to check if person resides with participant
2682 --
2683 cursor c_rsds is
2684 select pcr.rltd_per_rsds_w_dsgntr_flag
2685 from per_contact_relationships pcr, ben_prtt_enrt_rslt_f perslt
2686 where perslt.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
2687 and perslt.person_id = pcr.person_id
2688 and pcr.contact_person_id = p_dpnt_bnf_person_id
2689 and pcr.business_group_id = p_business_group_id
2690 and perslt.business_group_id = p_business_group_id
2691 and perslt.prtt_enrt_rslt_stat_cd is null
2692 and p_effective_date between
2693 perslt.effective_start_date and perslt.effective_end_date;
2694 --
2695 -- Cursor to check if participant has primary address
2696 --
2697 cursor c_prtt_adrs is
2698 select peradd.primary_flag,
2699 peradd.address_line1,
2700 peradd.postal_code
2701 from per_addresses peradd,
2702 ben_prtt_enrt_rslt_f perslt
2703 where perslt.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
2704 and perslt.person_id = peradd.person_id
2705 and peradd.business_group_id = p_business_group_id
2706 and perslt.business_group_id = p_business_group_id
2707 and perslt.prtt_enrt_rslt_stat_cd is null
2708 and p_effective_date between
2709 perslt.effective_start_date and perslt.effective_end_date
2710 order by decode(peradd.primary_flag,'Y',1,2);
2711 --
2712 l_prtt_adrs c_prtt_adrs%rowtype;
2713 --
2714 -- Cursor to check if the dependent or beneficiary has their own primary addr
2715 --
2716 -- Bug 2858700. Added dt condition and order by clause to the original
2717 -- cursor (commented below).
2718 cursor c_dpnt_bnf_adrs is
2719 select peradd.primary_flag,
2720 peradd.address_line1,
2721 peradd.postal_code
2722 from per_addresses peradd
2723 where peradd.person_id = p_dpnt_bnf_person_id
2724 and peradd.business_group_id = p_business_group_id
2725 and p_effective_date between peradd.date_from and
2726 nvl(peradd.date_to,p_effective_date)
2727 order by decode(peradd.primary_flag,'Y',1,2);
2728
2729 /* cursor c_dpnt_bnf_adrs is
2730 select peradd.primary_flag,
2731 peradd.address_line1,
2732 peradd.postal_code
2733 from per_addresses peradd
2734 where peradd.person_id = p_dpnt_bnf_person_id
2735 and peradd.business_group_id = p_business_group_id; */
2736 --
2737 l_dpnt_bnf_adrs c_dpnt_bnf_adrs%rowtype;
2738 --
2739 begin
2740 --
2741 g_debug := hr_utility.debug_enabled;
2742 if g_debug then
2743 l_proc := g_package||'.check_adrs';
2744 hr_utility.set_location ('Entering '||l_proc,10);
2745 end if;
2746 --
2747 -- check if the person resides with the participant
2748 --
2749 open c_rsds;
2750 fetch c_rsds into l_rsds;
2751 close c_rsds;
2752 --
2753 -- if they reside together. Does participant have primary address and zipcode
2754 --
2755 if l_rsds = 'Y' then
2756 open c_prtt_adrs;
2757 fetch c_prtt_adrs into l_prtt_adrs;
2758 close c_prtt_adrs;
2759 --
2760 -- now check if participant has valid primary address and valid zipcode
2761 --
2762 if l_prtt_adrs.primary_flag = 'Y' and
2763 l_prtt_adrs.postal_code IS NOT NULL then
2764 l_valid_adrs := TRUE;
2765 else
2766 l_valid_adrs := FALSE;
2767 end if;
2768 --
2769 elsif l_rsds = 'N' or l_rsds is null then
2770 --
2771 -- dependent or beneficiary does not reside with participant.
2772 -- Then check if the dependent/beneficiary has a primary address
2773 -- and valid zipcode.
2774 --
2775 open c_dpnt_bnf_adrs;
2776 fetch c_dpnt_bnf_adrs into l_dpnt_bnf_adrs;
2777 close c_dpnt_bnf_adrs;
2778 --
2779 if l_dpnt_bnf_adrs.primary_flag = 'Y' and
2780 l_dpnt_bnf_adrs.postal_code IS NOT NULL then
2781 l_valid_adrs := TRUE;
2782 else
2783 l_valid_adrs := FALSE;
2784 end if;
2785 --
2786 end if; -- l_rsds
2787 --
2788 if g_debug then
2789 hr_utility.set_location ('Leaving ' ||l_proc,10);
2790 end if;
2791 --
2792 return l_valid_adrs;
2793 --
2794 exception
2795 when others then
2796 if g_debug then
2797 hr_utility.set_location('Exception Raised '||l_proc, 10);
2798 end if;
2799 raise;
2800 --
2801 end check_adrs;
2802 --
2803 -- ----------------------------------------------------------------------------
2804 -- |----------------------------< check_legid >-------------------------------|
2805 -- ----------------------------------------------------------------------------
2806 --
2807 function check_legid
2808 (p_person_id in number
2809 ,p_effective_date in date
2810 ,p_business_group_id in number)
2811 return boolean is
2812 --
2813 -- this function checks the social security number, ssn, or
2814 -- national identifier. We are just checking if NULL, not the value.
2815 -- return Y if there is a value found otherwise N.
2816 --
2817 l_proc varchar2(80) ;
2818 l_legid_found boolean;
2819 --
2820 cursor c_leg_id is
2821 select per.national_identifier
2822 from per_all_people_f per
2823 where per.person_id = p_person_id
2824 and per.business_group_id = p_business_group_id
2825 and p_effective_date between
2826 per.effective_start_date and per.effective_end_date;
2827 --
2828 l_leg_id c_leg_id%rowtype;
2829 --
2830 begin
2831 --
2832 g_debug := hr_utility.debug_enabled;
2833 if g_debug then
2834 l_proc := g_package||'.check_legid';
2835 hr_utility.set_location ('Entering '||l_proc,10);
2836 end if;
2837 --
2838 open c_leg_id;
2839 fetch c_leg_id into l_leg_id;
2840 close c_leg_id;
2841 --
2842 if l_leg_id.national_identifier IS NOT NULL then
2843 l_legid_found := TRUE;
2844 else
2845 l_legid_found := FALSE;
2846 end if;
2847 --
2848 if g_debug then
2849 hr_utility.set_location ('Leaving ' ||l_proc,10);
2850 end if;
2851 --
2852 return l_legid_found;
2853 --
2854 exception
2855 when others then
2856 if g_debug then
2857 hr_utility.set_location('Exception Raised '||l_proc, 10);
2858 end if;
2859 raise;
2860 --
2861 end check_legid;
2862 --
2863 -- ----------------------------------------------------------------------------
2864 -- |----------------------------< check_ctfn >--------------------------------|
2865 -- ----------------------------------------------------------------------------
2866 --
2867 function check_ctfn(p_required_count in number
2868 ,p_optional_count in number
2869 ,p_open_required_count in number
2870 ,p_open_optional_count in number)
2871 return boolean is
2872 --
2873 l_proc varchar2(80) ;
2874 --
2875 begin
2876 --
2877 if g_debug then
2878 l_proc := g_package ||'.check_ctfn';
2879 hr_utility.set_location ('Entering '||l_proc,10);
2880 end if;
2881 --
2882 if (p_required_count + p_optional_count) = 0 then
2883 --
2884 -- No certifications were found. Return FALSE.
2885 if g_debug then
2886 hr_utility.set_location ('Leaving '||l_proc,95);
2887 end if;
2888 return FALSE;
2889 --
2890 end if;
2891 --
2892 --
2893 if p_open_required_count = 0 and
2894 p_optional_count = 0 then
2895 -- all reqd provided and no optional ones found
2896 if g_debug then
2897 hr_utility.set_location ('Leaving '||l_proc,96);
2898 end if;
2899 return TRUE;
2900 --
2901 elsif p_open_required_count = 0 and
2902 p_optional_count <> p_open_optional_count then
2903 -- all rqd prvdd and atleast one optional prvdd
2904 if g_debug then
2905 hr_utility.set_location ('Leaving '||l_proc,97);
2906 end if;
2907 return TRUE;
2908 --
2909 else
2910 -- certifications missing or no optional ones provided
2911 if g_debug then
2912 hr_utility.set_location ('Leaving '||l_proc,98);
2913 end if;
2914 return FALSE;
2915 --
2916 end if;
2917 --
2918 if g_debug then
2919 hr_utility.set_location ('Leaving '||l_proc,99);
2920 end if;
2921 --
2922 end check_ctfn;
2923 --
2924 -- ----------------------------------------------------------------------------
2925 -- |----------------------------< check_enrt_ctfn >---------------------------|
2926 -- ----------------------------------------------------------------------------
2927 --
2928 function check_enrt_ctfn
2929 (p_prtt_enrt_actn_id in number
2930 ,p_prtt_enrt_rslt_id in number
2931 ,p_effective_date in date)
2932 return boolean is
2933 --
2934 -- This function checks for certifications for an enrollment result.
2935 -- Check if certifications were provided. For this participant
2936 -- if the enrt_ctfn_rqd_flag is 'Y'if the enrt_ctfn_recd_dt IS NULL
2937 -- The recd_dt is filled in via a form interface.
2938 -- we are also checking for at least one optional certification.
2939 -- optional means dpnt_dsgn_ctfn_rqd_flag is 'N' for the ctfn_prvdd entry
2940 -- with the dpnt_dsgn_ctfn_recd_dt not NULL
2941 --
2942 l_required number;
2943 l_optional number;
2944 l_open_required number;
2945 l_open_optional number;
2946 l_return boolean;
2947 --
2948 l_proc varchar2(80) ;
2949 --
2950 begin
2951 --
2952 g_debug := hr_utility.debug_enabled;
2953 if g_debug then
2954 l_proc := g_package||'.check_enrt_ctfn';
2955 hr_utility.set_location ('Entering '||l_proc,10);
2956 end if;
2957 --
2958 get_ctfn_count
2959 (p_prtt_enrt_actn_id => p_prtt_enrt_actn_id
2960 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
2961 ,p_effective_date => p_effective_date
2962 ,p_required_count => l_required
2963 ,p_optional_count => l_optional
2964 ,p_open_required_count => l_open_required
2965 ,p_open_optional_count => l_open_optional);
2966 --
2967 l_return := check_ctfn(p_required_count => l_required
2968 ,p_optional_count => l_optional
2969 ,p_open_required_count => l_open_required
2970 ,p_open_optional_count => l_open_optional);
2971 --
2972 if g_debug then
2973 hr_utility.set_location ('Leaving '||l_proc,10);
2974 end if;
2975 --
2976 return l_return;
2977 --
2978 exception
2979 when others then
2980 if g_debug then
2981 hr_utility.set_location('Exception Raised '||l_proc, 10);
2982 end if;
2983 raise;
2984 --
2985 end check_enrt_ctfn;
2986 --
2987 -- ----------------------------------------------------------------------------
2988 -- |----------------------------< check_dpnt_ctfn >---------------------------|
2989 -- ----------------------------------------------------------------------------
2990 --
2991 function check_dpnt_ctfn
2992 (p_prtt_enrt_actn_id in number
2993 ,p_elig_cvrd_dpnt_id in number
2994 ,p_effective_date in date)
2995 return boolean is
2996 --
2997 -- This function checks for certifications for an enrollment result.
2998 -- Check if certifications were provided. For this covered dependent check
2999 -- if the dpnt_dsgn_ctfn_rqd_flag is 'Y'if the dpnt_dsgn_ctfn_recd_dt IS NULL
3000 -- The recd_dt is filled in via a form interface.
3001 -- we are also checking for at least one optional certification.
3002 -- optional means dpnt_dsgn_ctfn_rqd_flag is 'N' for the ctfn_prvdd entry
3003 -- with the dpnt_dsgn_ctfn_recd_dt not NULL
3004 --
3005 l_required number;
3006 l_optional number;
3007 l_open_required number;
3008 l_open_optional number;
3009 l_return boolean;
3010 --
3011 l_proc varchar2(80) ;
3012 --
3013 begin
3014 --
3015 g_debug := hr_utility.debug_enabled;
3016 if g_debug then
3017 l_proc := g_package||'.check_dpnt_ctfn';
3018 hr_utility.set_location ('Entering '||l_proc,10);
3019 end if;
3020 --
3021 get_ctfn_count
3022 (p_prtt_enrt_actn_id => p_prtt_enrt_actn_id
3023 ,p_elig_cvrd_dpnt_id => p_elig_cvrd_dpnt_id
3024 ,p_effective_date => p_effective_date
3025 ,p_required_count => l_required
3026 ,p_optional_count => l_optional
3027 ,p_open_required_count => l_open_required
3028 ,p_open_optional_count => l_open_optional);
3029 --
3030 l_return := check_ctfn(p_required_count => l_required
3031 ,p_optional_count => l_optional
3032 ,p_open_required_count => l_open_required
3033 ,p_open_optional_count => l_open_optional);
3034 --
3035 if g_debug then
3036 hr_utility.set_location ('Leaving '||l_proc,99);
3037 end if;
3038 --
3039 return l_return;
3040 --
3041 exception
3042 when others then
3043 if g_debug then
3044 hr_utility.set_location('Exception Raised '||l_proc, 999);
3045 end if;
3046 raise;
3047 --
3048 end check_dpnt_ctfn;
3049 --
3050 -- ----------------------------------------------------------------------------
3051 -- |-----------------------< check_write_ctfn >-------------------------------|
3052 -- ----------------------------------------------------------------------------
3053 --
3054 function check_write_ctfn
3055 (p_formula_id in number
3056 ,p_pgm_id in number default NULL
3057 ,p_pl_id in number default NULL
3058 ,p_pl_typ_id in number default NULL
3059 ,p_oipl_id in number default NULL
3060 ,p_ler_id in number default NULL
3061 ,p_param1 in varchar2 default NULL
3062 ,p_param1_value in varchar2 default NULL
3063 ,p_business_group_id in number default NULL
3064 ,p_assignment_id in number default NULL
3065 ,p_organization_id in number default NULL
3066 ,p_jurisdiction_code in varchar2
3067 ,p_effective_date in date)
3068 return boolean is
3069 --
3070 l_write_ctfn boolean := TRUE;
3071 l_outputs ff_exec.outputs_t;
3072 l_proc varchar2(80) ;
3073 --
3074 cursor c_opt is
3075 select oipl.opt_id
3076 from ben_oipl_f oipl
3077 where oipl.oipl_id = p_oipl_id
3078 and business_group_id = p_business_group_id
3079 and p_effective_date between
3080 oipl.effective_start_date and oipl.effective_end_date;
3081
3082 l_opt c_opt%rowtype;
3083 --
3084 begin
3085 --
3086 if g_debug then
3087 l_proc := g_package||'.check_write_ctfn';
3088 hr_utility.set_location ('Entering '||l_proc,10);
3089 end if;
3090 --
3091 if p_formula_id IS NOT NULL then
3092 --
3093 if p_oipl_id is not null then
3094 open c_opt;
3095 fetch c_opt into l_opt;
3096 close c_opt;
3097 end if;
3098 --
3099 l_outputs := benutils.formula
3100 (p_formula_id => p_formula_id
3101 ,p_pgm_id => p_pgm_id
3102 ,p_pl_id => p_pl_id
3103 ,p_pl_typ_id => p_pl_typ_id
3104 ,p_opt_id => l_opt.opt_id
3105 ,p_ler_id => p_ler_id
3106 ,p_param1 => p_param1
3107 ,p_param1_value => p_param1_value
3108 ,p_business_group_id => p_business_group_id
3109 ,p_assignment_id => p_assignment_id
3110 ,p_organization_id => p_organization_id
3111 ,p_jurisdiction_code => p_jurisdiction_code
3112 ,p_effective_date => p_effective_date);
3113 --
3114 if l_outputs(l_outputs.first).value = 'N' then
3115 l_write_ctfn := FALSE;
3116 end if;
3117 --
3118 else
3119 NULL; -- nothing to do at this time
3120 end if;
3121 --
3122 if g_debug then
3123 hr_utility.set_location ('Leaving ' ||l_proc,10);
3124 end if;
3125 --
3126 return l_write_ctfn;
3127 --
3128 exception
3129 when others then
3130 if g_debug then
3131 hr_utility.set_location('Exception Raised '||l_proc, 10);
3132 end if;
3133 raise;
3134 --
3135 end check_write_ctfn;
3136 --
3137 -- ----------------------------------------------------------------------------
3138 -- |-------------------< determine_dpnt_miss_actn_items >---------------------|
3139 -- ----------------------------------------------------------------------------
3140 --
3141 procedure determine_dpnt_miss_actn_items
3142 (p_validate in boolean default false
3143 ,p_effective_date in date
3144 ,p_business_group_id in number
3145 ,p_datetrack_mode in varchar2 default hr_api.g_correction
3146 ,p_prtt_enrt_rslt_id in number
3147 ,p_rslt_object_version_number in out nocopy number
3148 ,p_post_rslt_flag in varchar2 default 'Y'
3149 ,p_dpnt_actn_warning out nocopy boolean) is
3150 --
3151 -- This procedure determines if a desgnated dependent has missing information
3152 -- DOB, SSN, ADRS, CTFN that are required to complete an enrollment. It also
3153 -- completes the DD action. The dependent information requirements are defined
3154 -- at the program, plan, and plan type in program level.
3155 --
3156 l_proc varchar2(80) ;
3157 l_rslt_object_version_number number(15);
3158
3159 --
3160 l_allws_flag varchar2(30);
3161 l_lvl_cd ben_pgm_f.dpnt_dsgn_lvl_cd%type;
3162 l_actn_typ_id number;
3163 l_rqd_data_found boolean; -- holds return value from check_xxx functions
3164 l_effective_start_date date;
3165 l_effective_end_date date;
3166 l_object_version_number number;
3167 l_cmpltd_dt date;
3168 l_prtt_enrt_actn_id number;
3169 l_prtt_enrt_ctfn_prvdd_id number;
3170 --
3171 l_dpnt_actn_warning boolean := FALSE;
3172
3173 l_dpnt_ctfn_actn_warning boolean := FALSE; -- Bug 5998009
3174
3175 l_all_lvls varchar2(30); -- flag for processing levels of dpnt certs
3176 l_outputs ff_exec.outputs_t;
3177 l_write_ctfn boolean := FALSE;
3178 l_ctfns_defined boolean := FALSE;
3179 l_ff_ctfns_exists boolean := FALSE ; -- Bug1491912
3180 l_susp_if_ctfn_not_prvd_flag varchar2(30);
3181
3182 -- Cursor to select context parameters for benutils.formula
3183
3184 cursor c_rslt is
3185 select rslt.pgm_id,
3186 rslt.ptip_id,
3187 rslt.pl_id,
3188 rslt.pl_typ_id,
3189 rslt.oipl_id,
3190 rslt.ler_id,
3191 rslt.person_id,
3192 rslt.business_group_id
3193 from ben_prtt_enrt_rslt_f rslt
3194 where rslt.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
3195 and rslt.prtt_enrt_rslt_stat_cd is null
3196 and p_effective_date between
3197 rslt.effective_start_date and rslt.effective_end_date;
3198
3199 l_rslt c_rslt%rowtype;
3200
3201 cursor c_asg is
3202 select asg.assignment_id,asg.organization_id
3203 from per_all_assignments_f asg
3204 where asg.person_id = l_rslt.person_id
3205 and asg.assignment_type <> 'C'
3206 and asg.primary_flag = 'Y'
3207 and p_effective_date between
3208 asg.effective_start_date and asg.effective_end_date;
3209
3210 l_asg c_asg%rowtype;
3211
3212 Cursor c_state is
3213 select region_2
3214 from hr_locations_all loc,per_all_assignments_f asg
3215 where loc.location_id = asg.location_id
3216 and asg.person_id = l_rslt.person_id
3217 and asg.assignment_type <> 'C'
3218 and p_effective_date between
3219 asg.effective_start_date and asg.effective_end_date
3220 and asg.business_group_id=p_business_group_id;
3221
3222 l_state c_state%rowtype;
3223
3224 -- Cursor to retrieve the dependent designation level
3225 --
3226 cursor c_dpnt_lvl_cd (p_pgm_id number) is
3227 select pgm.dpnt_dsgn_lvl_cd
3228 from ben_pgm_f pgm
3229 where pgm.pgm_id = p_pgm_id
3230 and pgm.business_group_id = p_business_group_id
3231 and p_effective_date between
3232 pgm.effective_start_date and pgm.effective_end_date;
3233 --
3234 -- Cursor to retrieve dependant required flags at the pgm level
3235 --
3236 cursor c_dpnt_pgm (p_pgm_id number) is
3237 select pgm.susp_if_dpnt_ssn_nt_prv_cd,
3238 pgm.susp_if_dpnt_dob_nt_prv_cd,
3239 pgm.susp_if_dpnt_adr_nt_prv_cd,
3240 pgm.susp_if_ctfn_not_dpnt_flag,
3241 pgm.dpnt_ctfn_determine_cd,
3242 pgm.dpnt_dsgn_no_ctfn_rqd_flag
3243 from ben_pgm_f pgm
3244 where pgm.pgm_id = p_pgm_id
3245 and pgm.business_group_id = p_business_group_id
3246 and p_effective_date between
3247 pgm.effective_start_date and pgm.effective_end_date;
3248 --
3249 l_dpnt c_dpnt_pgm%rowtype;
3250 --
3251 -- cursor to retrieve dpnts' required-info-flags at the ptip level
3252 --
3253 cursor c_dpnt_ptip (p_ptip_id number) is
3254 select ptip.susp_if_dpnt_ssn_nt_prv_cd,
3255 ptip.susp_if_dpnt_dob_nt_prv_cd,
3256 ptip.susp_if_dpnt_adr_nt_prv_cd,
3257 ptip.susp_if_ctfn_not_dpnt_flag,
3258 ptip.dpnt_ctfn_determine_cd,
3259 ptip.dpnt_cvg_no_ctfn_rqd_flag
3260 from ben_ptip_f ptip
3261 where ptip.ptip_id = p_ptip_id
3262 and ptip.business_group_id = p_business_group_id
3263 and p_effective_date between
3264 ptip.effective_start_date and ptip.effective_end_date;
3265 --
3266 -- Cursor to retrieve dpnt required flags at the plan level
3267 --
3268 cursor c_dpnt_pl (p_pl_id number) is
3269 select pl.susp_if_dpnt_ssn_nt_prv_cd,
3270 pl.susp_if_dpnt_dob_nt_prv_cd,
3271 pl.susp_if_dpnt_adr_nt_prv_cd,
3272 pl.susp_if_ctfn_not_dpnt_flag,
3273 pl.dpnt_ctfn_determine_cd,
3274 pl.dpnt_no_ctfn_rqd_flag
3275 from ben_pl_f pl
3276 where pl.pl_id = p_pl_id
3277 and pl.business_group_id = p_business_group_id
3278 and p_effective_date between
3279 pl.effective_start_date and pl.effective_end_date;
3280 --
3281 cursor c_ctfns_ler_chg(v_lvl_cd varchar2
3282 ,v_dpnt_person_id number
3283 ,v_person_id number
3284 ,v_pgm_id number
3285 ,v_pl_id number
3286 ,v_ptip_id number) is
3287 select lcc.dpnt_cvg_ctfn_typ_cd,
3288 lcc.ctfn_rqd_when_rl,
3289 lcc.rqd_flag,
3290 lcc.rlshp_typ_cd,
3291 ldc.susp_if_ctfn_not_prvd_flag,
3292 ldc.ctfn_determine_cd
3293 from ben_ler_chg_dpnt_cvg_ctfn_f lcc,
3294 ben_ler_chg_dpnt_cvg_f ldc,
3295 ben_prtt_enrt_rslt_f pen
3296 where pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
3297 and pen.business_group_id = p_business_group_id
3298 and p_effective_date between pen.effective_start_date
3299 and pen.effective_end_date
3300 and pen.ler_id = ldc.ler_id
3301 and pen.prtt_enrt_rslt_stat_cd is null
3302 and p_effective_date between ldc.effective_start_date
3303 and ldc.effective_end_date
3304 and ((v_lvl_cd = 'PTIP' and ldc.ptip_id = v_ptip_id) OR
3305 (v_lvl_cd = 'PL' and ldc.pl_id = v_pl_id) OR
3306 (v_lvl_cd = 'PGM' and ldc.pgm_id = v_pgm_id))
3307 and ldc.ler_chg_dpnt_cvg_id = lcc.ler_chg_dpnt_cvg_id
3308 and p_effective_date between lcc.effective_start_date
3309 and lcc.effective_end_date
3310 and (lcc.rlshp_typ_cd is null
3311 or
3312 lcc.rlshp_typ_cd in (select contact_type
3313 from per_contact_relationships
3314 where contact_person_id = v_dpnt_person_id
3315 and person_id = v_person_id
3316 and business_group_id = p_business_group_id
3317 and p_effective_date
3318 between nvl(date_start, p_effective_date)
3319 and nvl(date_end, hr_api.g_eot)));
3320 --
3321 -- Cursor to retrieve dependent certification information at the plan level
3322 --
3323 cursor c_dpnt_ctfn_pl(v_pl_id number, v_dpnt_person_id number, v_person_id number) is
3324 select pl.dpnt_cvg_ctfn_typ_cd ctcvgcd,
3325 pl.ctfn_rqd_when_rl ctrrl,
3326 pl.rqd_flag,
3327 pl.rlshp_typ_cd ctrlshcd,
3328 pl.pl_id
3329 from ben_pl_dpnt_cvg_ctfn_f pl
3330 where pl.pl_id = v_pl_id
3331 and pl.business_group_id = p_business_group_id
3332 and p_effective_date between pl.effective_start_date
3333 and pl.effective_end_date
3334 and (pl.rlshp_typ_cd is null
3335 or
3336 pl.rlshp_typ_cd in (select contact_type
3337 from per_contact_relationships
3338 where contact_person_id = v_dpnt_person_id
3339 and person_id = v_person_id
3340 and business_group_id = p_business_group_id
3341 and p_effective_date
3342 between nvl(date_start, p_effective_date)
3343 and nvl(date_end, hr_api.g_eot)));
3344 --
3345 -- Cursor to retrieve dependent certification at the program level
3346 --
3347 cursor c_dpnt_ctfn_pgm(v_pgm_id number, v_dpnt_person_id number, v_person_id number) is
3348 select pgm.dpnt_cvg_ctfn_typ_cd ctcvgcd,
3349 pgm.ctfn_rqd_when_rl ctrrl,
3350 pgm.rqd_flag,
3351 pgm.rlshp_typ_cd ctrlshcd,
3352 pgm.pgm_id
3353 from ben_pgm_dpnt_cvg_ctfn_f pgm
3354 where pgm.pgm_id = v_pgm_id
3355 and pgm.business_group_id = p_business_group_id
3356 and p_effective_date between pgm.effective_start_date
3357 and pgm.effective_end_date
3358 and (pgm.rlshp_typ_cd is null
3359 or
3360 pgm.rlshp_typ_cd in (select contact_type
3361 from per_contact_relationships
3362 where contact_person_id = v_dpnt_person_id
3363 and person_id = v_person_id
3364 and business_group_id = p_business_group_id
3365 and p_effective_date
3366 between nvl(date_start, p_effective_date)
3367 and nvl(date_end, hr_api.g_eot)));
3368
3369 --
3370 -- Cursor to retrieve dependent certifications at the ptip level
3371 --
3372 cursor c_dpnt_ctfn_ptip(v_ptip_id number, v_dpnt_person_id number, v_person_id number) is
3373 select ptip.dpnt_cvg_ctfn_typ_cd ctcvgcd,
3374 ptip.ctfn_rqd_when_rl ctrrl,
3375 ptip.rqd_flag,
3376 ptip.rlshp_typ_cd ctrlshcd,
3377 ptip.ptip_id
3378 from ben_ptip_dpnt_cvg_ctfn_f ptip
3379 where ptip.ptip_id = v_ptip_id
3380 and ptip.business_group_id = p_business_group_id
3381 and p_effective_date between ptip.effective_start_date
3382 and ptip.effective_end_date
3383 and (ptip.rlshp_typ_cd is null
3384 or
3385 ptip.rlshp_typ_cd in (select contact_type
3386 from per_contact_relationships
3387 where contact_person_id = v_dpnt_person_id
3388 and person_id = v_person_id
3389 and business_group_id = p_business_group_id
3390 and p_effective_date
3391 between nvl(date_start, p_effective_date)
3392 and nvl(date_end, hr_api.g_eot)));
3393
3394 --
3395 -- Cursor to fetch the covered dependents for an enrt_rslt_id
3396 --
3397 cursor c_cvrd_dpnt is
3398 select ecd.dpnt_person_id,
3399 ecd.elig_cvrd_dpnt_id,
3400 pen.pgm_id,
3401 pen.ptip_id,
3402 pen.pl_id
3403 from ben_elig_cvrd_dpnt_f ecd,
3404 ben_prtt_enrt_rslt_f pen,
3405 ben_per_in_ler pil
3406 where pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
3407 and pen.prtt_enrt_rslt_id = ecd.prtt_enrt_rslt_id
3408 and ecd.cvg_strt_dt is not null
3409 and nvl(ecd.cvg_thru_dt, hr_api.g_eot) = hr_api.g_eot
3410 and ecd.business_group_id = p_business_group_id
3411 and p_effective_date between
3412 ecd.effective_start_date and ecd.effective_end_date
3413 and p_effective_date between
3414 pen.effective_start_date and pen.effective_end_date
3415 and pen.prtt_enrt_rslt_stat_cd is null
3416 and pil.per_in_ler_id=ecd.per_in_ler_id
3417 and pil.business_group_id=p_business_group_id
3418 and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT');
3419 --
3420 cursor c_mng_dpnts (cl_dpnt_id number) is
3421 select ccp.elig_cvrd_dpnt_id,
3422 ccp.dpnt_dsgn_ctfn_typ_cd,
3423 ccp.dpnt_dsgn_ctfn_rqd_flag,
3424 ccp.dpnt_dsgn_ctfn_recd_dt
3425 from ben_cvrd_dpnt_ctfn_prvdd_f ccp,
3426 ben_elig_cvrd_dpnt_f ecd,
3427 ben_per_in_ler pil
3428 where ccp.elig_cvrd_dpnt_id = cl_dpnt_id
3429 and ccp.dpnt_dsgn_ctfn_recd_dt IS NULL
3430 and ccp.business_group_id = p_business_group_id
3431 and p_effective_date between
3432 ccp.effective_start_date and ccp.effective_end_date
3433 and ecd.elig_cvrd_dpnt_id=ccp.elig_cvrd_dpnt_id
3434 and ecd.business_group_id = p_business_group_id
3435 and p_effective_date between
3436 ecd.effective_start_date and ecd.effective_end_date
3437 and pil.per_in_ler_id=ecd.per_in_ler_id
3438 and pil.business_group_id=p_business_group_id
3439 and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT');
3440 --
3441 -- bug: 5513339
3442 cursor c_curr_ovn_of_actn (c_prtt_enrt_actn_id number) is
3443 select object_version_number
3444 from ben_prtt_enrt_actn_f
3445 where prtt_enrt_actn_id = c_prtt_enrt_actn_id
3446 and business_group_id = p_business_group_id
3447 and p_effective_date between effective_start_date
3448 and effective_end_date;
3449
3450 --
3451 l_mng_dpnts c_mng_dpnts%rowtype;
3452 l_jurisdiction_code varchar2(30);
3453 l_ctfn_at_ler_chg boolean := FALSE;
3454 l_rqd_flag varchar2(30);
3455
3456 --
3457 begin
3458 --
3459 if g_debug then
3460 l_proc := g_package||'.determine_dpnt_miss_actn_items';
3461 hr_utility.set_location ('Entering '||l_proc,10);
3462 end if;
3463
3464 l_rslt_object_version_number := p_rslt_object_version_number ;
3465
3466 --
3467 if p_prtt_enrt_rslt_id is not null then
3468 open c_rslt;
3469 fetch c_rslt into l_rslt;
3470 close c_rslt;
3471 else
3472 if g_debug then
3473 hr_utility.set_location('RESULT ID IS NULL!!' , 13);
3474 end if;
3475 end if;
3476 --
3477 if l_rslt.person_id is not null then
3478 open c_asg;
3479 fetch c_asg into l_asg;
3480 close c_asg;
3481 end if;
3482 --
3483
3484 /* -- 4031733 - Cursor used to populate l_state.region_2 param for benutils.limit_checks
3485 -- which is not used down the line
3486 --
3487 if l_rslt.person_id is not null then
3488 open c_state;
3489 fetch c_state into l_state;
3490 close c_state;
3491
3492 -- if l_state.region_2 is not null then
3493
3494 -- l_jurisdiction_code :=
3495 -- pay_mag_utils.lookup_jurisdiction_code
3496 -- (p_state => l_state.region_2);
3497
3498 -- end if;
3499 end if;
3500 */
3501
3502 --
3503 -- Fetch the designation level code from the ben_pgm_f table.
3504 --
3505 if l_rslt.pgm_id is not null then
3506 open c_dpnt_lvl_cd(p_pgm_id => l_rslt.pgm_id);
3507 fetch c_dpnt_lvl_cd into l_lvl_cd;
3508 close c_dpnt_lvl_cd;
3509 end if;
3510 --
3511 if g_debug then
3512 hr_utility.set_location('Designation level code : ' || l_lvl_cd, 14);
3513 end if;
3514 --
3515 -- check the level code for program, ptip or plan (default) and fetch the
3516 -- appropriate required-info-flags.
3517 --
3518 if (l_lvl_cd = 'PGM' and l_rslt.pgm_id IS NOT NULL) then
3519 -- Fetch the flags at the program level
3520 open c_dpnt_pgm(p_pgm_id => l_rslt.pgm_id);
3521 fetch c_dpnt_pgm into l_dpnt;
3522 close c_dpnt_pgm;
3523 --
3524 elsif (l_lvl_cd = 'PTIP' and l_rslt.pgm_id IS NOT NULL) then
3525 -- Fetch the flags at the ptip level
3526 open c_dpnt_ptip(p_ptip_id => l_rslt.ptip_id);
3527 fetch c_dpnt_ptip into l_dpnt;
3528 close c_dpnt_ptip;
3529 --
3530 else
3531 -- always use plan as default
3532 open c_dpnt_pl(p_pl_id => l_rslt.pl_id);
3533 fetch c_dpnt_pl into l_dpnt;
3534 close c_dpnt_pl;
3535 l_lvl_cd := 'PL';
3536 --
3537 end if;
3538 --
3539 -- for each dependent covered by participant check
3540 -- date of birth, address, national id, certifications
3541 --
3542 for l_cvrd_dpnt in c_cvrd_dpnt loop
3543 -- date of birth action item
3544 --
3545 -- Check if a DDDOB action item exists for the dependent
3546 --
3547 l_ff_ctfns_exists := FALSE ;
3548 --
3549 if g_debug then
3550 hr_utility.set_location('DOB action item ', 30);
3551 end if;
3552 --
3553 l_actn_typ_id := get_actn_typ_id
3554 (p_type_cd => 'DDDOB'
3555 ,p_business_group_id => p_business_group_id);
3556 --
3557 get_prtt_enrt_actn_id
3558 (p_actn_typ_id => l_actn_typ_id
3559 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
3560 ,p_elig_cvrd_dpnt_id => l_cvrd_dpnt.elig_cvrd_dpnt_id
3561 ,p_effective_date => p_effective_date
3562 ,p_business_group_id => p_business_group_id
3563 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
3564 ,p_cmpltd_dt => l_cmpltd_dt
3565 ,p_object_version_number => l_object_version_number);
3566 --
3567 if l_dpnt.susp_if_dpnt_dob_nt_prv_cd is not null then
3568 --
3569 -- check if person has a date of birth entry
3570 --
3571 if g_debug then
3572 hr_utility.set_location('DOB is rqd', 35);
3573 end if;
3574 --
3575 if l_dpnt.susp_if_dpnt_dob_nt_prv_cd = 'RQDS' then
3576 l_rqd_flag := 'Y';
3577 else
3578 l_rqd_flag := 'N';
3579 end if;
3580 l_rqd_data_found := check_dob
3581 (p_person_id => l_cvrd_dpnt.dpnt_person_id
3582 ,p_effective_date => p_effective_date
3583 ,p_business_group_id => p_business_group_id);
3584 --
3585 -- Process the action item
3586 --
3587 process_action_item
3588 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
3589 ,p_actn_typ_id => l_actn_typ_id
3590 ,p_cmpltd_dt => l_cmpltd_dt
3591 ,p_object_version_number => l_object_version_number
3592 ,p_effective_date => p_effective_date
3593 ,p_rqd_data_found => l_rqd_data_found
3594 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
3595 ,p_elig_cvrd_dpnt_id => l_cvrd_dpnt.elig_cvrd_dpnt_id
3596 ,p_rqd_flag => l_rqd_flag --'Y'
3597 ,p_post_rslt_flag => p_post_rslt_flag
3598 ,p_business_group_id => p_business_group_id
3599 ,p_datetrack_mode => p_datetrack_mode
3600 ,p_rslt_object_version_number => p_rslt_object_version_number);
3601 --
3602 if l_rqd_data_found = FALSE then
3603 l_dpnt_actn_warning := TRUE;
3604 end if;
3605 --
3606 else
3607 -- dpnt_dob_rqd_flag is 'N'
3608 -- if date_track mode is updating and designation at plan level
3609 -- delete action item of type DDDOB.
3610 --
3611 if g_debug then
3612 hr_utility.set_location('DOB is not required', 40);
3613 end if;
3614 --
3615 if (l_prtt_enrt_actn_id IS NOT NULL and p_datetrack_mode = DTMODE_DELETE) then
3616 --
3617 delete_action_item
3618 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
3619 ,p_object_version_number => l_object_version_number
3620 ,p_business_group_id => p_business_group_id
3621 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
3622 ,p_rslt_object_version_number => p_rslt_object_version_number
3623 ,p_effective_date => p_effective_date
3624 ,p_datetrack_mode => p_datetrack_mode
3625 ,p_post_rslt_flag => p_post_rslt_flag);
3626 --
3627 else
3628 NULL; -- nothing to do at this time.
3629 end if;
3630 --
3631 end if; -- dpnt_dob_rqd_flag
3632 --
3633 -- Social security number/national identifier action item
3634 --
3635 if g_debug then
3636 hr_utility.set_location('SSN action item ', 45);
3637 end if;
3638 --
3639 l_actn_typ_id := get_actn_typ_id
3640 (p_type_cd => 'DDSSN'
3641 ,p_business_group_id => p_business_group_id);
3642 --
3643 get_prtt_enrt_actn_id
3644 (p_actn_typ_id => l_actn_typ_id
3645 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
3646 ,p_elig_cvrd_dpnt_id => l_cvrd_dpnt.elig_cvrd_dpnt_id
3647 ,p_effective_date => p_effective_date
3648 ,p_business_group_id => p_business_group_id
3649 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
3650 ,p_cmpltd_dt => l_cmpltd_dt
3651 ,p_object_version_number => l_object_version_number);
3652 --
3653 if l_dpnt.susp_if_dpnt_ssn_nt_prv_cd is not null then
3654 --
3655 -- check if person has a national identifier entry
3656 --
3657 if g_debug then
3658 hr_utility.set_location('SSN is rqd', 50);
3659 end if;
3660 --
3661 if l_dpnt.susp_if_dpnt_ssn_nt_prv_cd = 'RQDS' then
3662 l_rqd_flag := 'Y';
3663 else
3664 l_rqd_flag := 'N';
3665 end if;
3666 l_rqd_data_found := check_legid
3667 (p_person_id => l_cvrd_dpnt.dpnt_person_id
3668 ,p_effective_date => p_effective_date
3669 ,p_business_group_id => p_business_group_id);
3670 --
3671 -- Process the action item
3672 --
3673 process_action_item
3674 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
3675 ,p_actn_typ_id => l_actn_typ_id
3676 ,p_cmpltd_dt => l_cmpltd_dt
3677 ,p_object_version_number => l_object_version_number
3678 ,p_effective_date => p_effective_date
3679 ,p_rqd_data_found => l_rqd_data_found
3680 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
3681 ,p_elig_cvrd_dpnt_id => l_cvrd_dpnt.elig_cvrd_dpnt_id
3682 ,p_rqd_flag => l_rqd_flag --'Y'
3683 ,p_post_rslt_flag => p_post_rslt_flag
3684 ,p_business_group_id => p_business_group_id
3685 ,p_datetrack_mode => p_datetrack_mode
3686 ,p_rslt_object_version_number => p_rslt_object_version_number);
3687 --
3688 if l_rqd_data_found = FALSE then
3689 l_dpnt_actn_warning := TRUE;
3690 end if;
3691 --
3692 else
3693 --
3694 if g_debug then
3695 hr_utility.set_location('SSN is not rqd', 55);
3696 end if;
3697 --
3698 -- dpnt_leg_id_rqd_flag is 'N'
3699 -- if date_track mode is updating and designation at plan level
3700 -- delete action type of type DDSSN.
3701 --
3702 if l_prtt_enrt_actn_id IS NOT NULL and
3703 p_datetrack_mode = DTMODE_DELETE then
3704 --
3705 delete_action_item
3706 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
3707 ,p_object_version_number => l_object_version_number
3708 ,p_business_group_id => p_business_group_id
3709 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
3710 ,p_rslt_object_version_number => p_rslt_object_version_number
3711 ,p_effective_date => p_effective_date
3712 ,p_datetrack_mode => p_datetrack_mode
3713 ,p_post_rslt_flag => p_post_rslt_flag);
3714 --
3715 else
3716 NULL; -- nothing to do at this time.
3717 end if;
3718 --
3719 end if; -- dpnt_leg_id_rqd_flag
3720 --
3721 -- address action item
3722 --
3723 if g_debug then
3724 hr_utility.set_location('ADDR action item ' , 60);
3725 end if;
3726 --
3727 l_actn_typ_id := get_actn_typ_id
3728 (p_type_cd => 'DDADDR'
3729 ,p_business_group_id => p_business_group_id);
3730 --
3731 get_prtt_enrt_actn_id
3732 (p_actn_typ_id => l_actn_typ_id
3733 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
3734 ,p_elig_cvrd_dpnt_id => l_cvrd_dpnt.elig_cvrd_dpnt_id
3735 ,p_effective_date => p_effective_date
3736 ,p_business_group_id => p_business_group_id
3737 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
3738 ,p_cmpltd_dt => l_cmpltd_dt
3739 ,p_object_version_number => l_object_version_number);
3740 --
3741 if l_dpnt.susp_if_dpnt_adr_nt_prv_cd is not null then
3742 --
3743 -- check if person has an address
3744 --
3745 if g_debug then
3746 hr_utility.set_location('ADDR is rqd', 65);
3747 end if;
3748 --
3749 if l_dpnt.susp_if_dpnt_adr_nt_prv_cd = 'RQDS' then
3750 l_rqd_flag := 'Y';
3751 else
3752 l_rqd_flag := 'N';
3753 end if;
3754 l_rqd_data_found := check_adrs
3755 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
3756 ,p_dpnt_bnf_person_id => l_cvrd_dpnt.dpnt_person_id
3757 ,p_effective_date => p_effective_date
3758 ,p_business_group_id => p_business_group_id);
3759 --
3760 -- Process the action item
3761 --
3762 process_action_item
3763 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
3764 ,p_actn_typ_id => l_actn_typ_id
3765 ,p_cmpltd_dt => l_cmpltd_dt
3766 ,p_object_version_number => l_object_version_number
3767 ,p_effective_date => p_effective_date
3768 ,p_rqd_data_found => l_rqd_data_found
3769 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
3770 ,p_elig_cvrd_dpnt_id => l_cvrd_dpnt.elig_cvrd_dpnt_id
3771 ,p_rqd_flag => l_rqd_flag --'Y'
3772 ,p_post_rslt_flag => p_post_rslt_flag
3773 ,p_business_group_id => p_business_group_id
3774 ,p_datetrack_mode => p_datetrack_mode
3775 ,p_rslt_object_version_number => p_rslt_object_version_number);
3776 --
3777 if l_rqd_data_found = FALSE then
3778 l_dpnt_actn_warning := TRUE;
3779 end if;
3780 --
3781 else
3782 --
3783 if g_debug then
3784 hr_utility.set_location('ADD is not rqd', 70);
3785 end if;
3786 --
3787 -- dpnt_adrs_rqd_flag is 'N'
3788 -- if date_track mode is updating and designation at plan level
3789 -- delete action type of type DDADDR.
3790 --
3791 if (l_prtt_enrt_actn_id IS NOT NULL and p_datetrack_mode = DTMODE_DELETE) then
3792 --
3793 delete_action_item
3794 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
3795 ,p_object_version_number => l_object_version_number
3796 ,p_business_group_id => p_business_group_id
3797 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
3798 ,p_rslt_object_version_number => p_rslt_object_version_number
3799 ,p_effective_date => p_effective_date
3800 ,p_datetrack_mode => p_datetrack_mode
3801 ,p_post_rslt_flag => p_post_rslt_flag);
3802 --
3803 end if;
3804 --
3805 end if; -- dpnt_adrs_rqd_flag
3806 --
3807 -- certification action item
3808 --
3809 if g_debug then
3810 hr_utility.set_location('CTFN action item ' , 75);
3811 end if;
3812 --
3813 l_actn_typ_id := get_actn_typ_id
3814 (p_type_cd => 'DDCTFN'
3815 ,p_business_group_id => p_business_group_id);
3816 --
3817 -- Check if a dpnt ctfn action item exists.
3818 --
3819 get_prtt_enrt_actn_id
3820 (p_actn_typ_id => l_actn_typ_id
3821 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
3822 ,p_elig_cvrd_dpnt_id => l_cvrd_dpnt.elig_cvrd_dpnt_id
3823 ,p_effective_date => p_effective_date
3824 ,p_business_group_id => p_business_group_id
3825 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
3826 ,p_cmpltd_dt => l_cmpltd_dt
3827 ,p_object_version_number => l_object_version_number);
3828 --
3829 -- ************************************************************
3830 -- Note, the flag says NO Dependent Certification Required.
3831 -- ************************************************************
3832 --
3833 if l_dpnt.dpnt_dsgn_no_ctfn_rqd_flag = 'N' then
3834 -- double negative....ctfn is required.
3835 if g_debug then
3836 hr_utility.set_location('DPNT CTFN is rqd', 80);
3837 end if;
3838 --
3839 --
3840 -- check if person has certification
3841 --
3842 l_rqd_data_found := check_dpnt_ctfn
3843 (p_elig_cvrd_dpnt_id => l_cvrd_dpnt.elig_cvrd_dpnt_id
3844 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
3845 ,p_effective_date => p_effective_date);
3846 --
3847 -- Check if any certifications are defined for the comp object.
3848 --
3849 l_ctfns_defined := check_ctfns_defined
3850 (p_dpnt_person_id => l_cvrd_dpnt.dpnt_person_id
3851 ,p_person_id => l_rslt.person_id
3852 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
3853 ,p_lvl_cd => l_lvl_cd
3854 ,p_pgm_id => l_rslt.pgm_id
3855 ,p_pl_id => l_cvrd_dpnt.pl_id
3856 ,p_ptip_id => l_rslt.ptip_id
3857 ,p_effective_date => p_effective_date
3858 ,p_business_group_id => p_business_group_id
3859 ,p_ctfn_at_ler_chg => l_ctfn_at_ler_chg
3860 ,p_susp_if_ctfn_not_prvd_flag => l_susp_if_ctfn_not_prvd_flag);
3861 --
3862 if l_prtt_enrt_actn_id IS NULL and
3863 not(l_rqd_data_found) and
3864 (l_ctfns_defined) then
3865 --
3866 if g_debug then
3867 hr_utility.set_location('Ctfn defined and not provided', 85);
3868 end if;
3869 --
3870 -- Bug 3851427 : If certifications are considered at LER_CHG_DPNT level, then Suspension of
3871 -- enrollment ( SUSP_IF_CTFN_NOT_PRVD_FLAG ) should also be considered at LER_CHG_DPNT level
3872 --
3873 if l_ctfn_at_ler_chg = true
3874 then
3875 --
3876 l_rqd_flag := l_susp_if_ctfn_not_prvd_flag; -- This flag is at LER_CHG_DPNT
3877 --
3878 else
3879 --
3880 l_rqd_flag := l_dpnt.susp_if_ctfn_not_dpnt_flag; -- This flag is at PTIP, PLN or PGM level
3881 --
3882 end if;
3883 --
3884 -- Since an action item is being written set the out warning param
3885 --
3886 -- l_dpnt_actn_warning := TRUE; -- Bug 5998009 Commented out the assignment statement
3887 --
3888 -- Certifications are required and certifications are defined. However
3889 -- no certifications were found for this person. Create an action item.
3890 --
3891 write_new_action_item
3892 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
3893 ,p_rslt_object_version_number => p_rslt_object_version_number
3894 ,p_actn_typ_id => l_actn_typ_id
3895 ,p_elig_cvrd_dpnt_id => l_cvrd_dpnt.elig_cvrd_dpnt_id
3896 ,p_rqd_flag => l_rqd_flag -- Bug 3851427
3897 ,p_effective_date => p_effective_date
3898 ,p_post_rslt_flag => p_post_rslt_flag
3899 ,p_business_group_id => p_business_group_id
3900 ,p_object_version_number => l_object_version_number
3901 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id);
3902 --
3903 -- loop thru all the specified certifications at the proper level
3904 -- write each one specified to the cvrd_dpnt_ctfn_prvdd_f table
3905 -- if no records then write them for all levels. Otherwise just
3906 -- the level they are requested for
3907 --
3908 -- first check if there are any existing certification
3909 -- for this dependent moved over from Managed Dependent process
3910 --
3911 l_all_lvls := YES_FOUND; -- init value
3912 --
3913 open c_mng_dpnts(l_cvrd_dpnt.elig_cvrd_dpnt_id);
3914 fetch c_mng_dpnts into l_mng_dpnts;
3915 --
3916 if c_mng_dpnts%NOTFOUND then
3917 l_all_lvls := NOT_FOUND; -- write for all levels since nothing found
3918 end if;
3919 --
3920 close c_mng_dpnts;
3921 --
3922 if g_debug then
3923 hr_utility.set_location('l_all_lvls:'||l_all_lvls|| 'l_lvl_cd:'||
3924 l_lvl_cd||' l_pgm_id:'||to_char(l_rslt.pgm_id), 87);
3925 end if;
3926 --
3927 -- now write out the appropriate certifications for each level
3928 --
3929 if l_all_lvls = NOT_FOUND and
3930 l_lvl_cd = 'PGM' and
3931 l_rslt.pgm_id IS NOT NULL then
3932 --
3933 if l_ctfn_at_ler_chg = TRUE then
3934 --
3935 -- Certifications defined for dpnt ler change
3936 --
3937 for l_ctfn in c_ctfns_ler_chg(l_lvl_cd
3938 ,l_cvrd_dpnt.dpnt_person_id
3939 ,l_rslt.person_id
3940 ,l_cvrd_dpnt.pgm_id
3941 ,l_cvrd_dpnt.pl_id
3942 ,l_cvrd_dpnt.ptip_id) loop
3943 --
3944 l_write_ctfn := check_write_ctfn
3945 (p_formula_id => l_ctfn.ctfn_rqd_when_rl
3946 ,p_pgm_id => l_rslt.pgm_id
3947 ,p_pl_id => l_rslt.pl_id
3948 ,p_pl_typ_id => l_rslt.pl_typ_id
3949 ,p_oipl_id => l_rslt.oipl_id
3950 ,p_ler_id => l_rslt.ler_id
3951 ,p_param1 => 'CON_PERSON_ID'
3952 ,p_param1_value => to_char(l_cvrd_dpnt.dpnt_person_id)
3953 ,p_business_group_id => l_rslt.business_group_id
3954 ,p_assignment_id => l_asg.assignment_id
3955 ,p_organization_id => l_asg.organization_id
3956 ,p_jurisdiction_code => l_jurisdiction_code
3957 ,p_effective_date => p_effective_date);
3958 --
3959 if l_write_ctfn then
3960 -- 9999
3961 l_ff_ctfns_exists := TRUE ;
3962 --
3963 -- presently we want to write the certifications always.
3964 -- unless the above rule indicates not to.
3965 --
3966 write_new_dpnt_ctfn_item
3967 (p_elig_cvrd_dpnt_id => l_cvrd_dpnt.elig_cvrd_dpnt_id
3968 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
3969 ,p_dpnt_dsgn_ctfn_typ_cd => l_ctfn.dpnt_cvg_ctfn_typ_cd
3970 ,p_dpnt_dsgn_ctfn_rqd_flag => l_ctfn.rqd_flag
3971 ,p_effective_date => p_effective_date
3972 ,p_business_group_id => p_business_group_id
3973 ,p_object_version_number => l_object_version_number
3974 ,p_cvrd_dpnt_ctfn_prvdd_id => l_prtt_enrt_ctfn_prvdd_id);
3975 --
3976 end if;
3977 --
3978 end loop;
3979 --
3980 else
3981 --
3982 -- No ctfns for ler change. Fetch the regular ctfns
3983 --
3984 for l_dpnt_ctfn_pgm in c_dpnt_ctfn_pgm(l_cvrd_dpnt.pgm_id
3985 ,l_cvrd_dpnt.dpnt_person_id
3986 ,l_rslt.person_id) loop
3987 --
3988 l_write_ctfn := check_write_ctfn
3989 (p_formula_id => l_dpnt_ctfn_pgm.ctrrl
3990 ,p_pgm_id => l_rslt.pgm_id
3991 ,p_pl_id => l_rslt.pl_id
3992 ,p_pl_typ_id => l_rslt.pl_typ_id
3993 ,p_oipl_id => l_rslt.oipl_id
3994 ,p_ler_id => l_rslt.ler_id
3995 ,p_param1 => 'CON_PERSON_ID'
3996 ,p_param1_value => to_char(l_cvrd_dpnt.dpnt_person_id)
3997 ,p_business_group_id => l_rslt.business_group_id
3998 ,p_assignment_id => l_asg.assignment_id
3999 ,p_organization_id => l_asg.organization_id
4000 ,p_jurisdiction_code => l_jurisdiction_code
4001 ,p_effective_date => p_effective_date);
4002 --
4003 if l_write_ctfn then
4004 --
4005 -- 9999
4006 l_ff_ctfns_exists := TRUE ;
4007 --
4008 -- presently we want to write the certifications always.
4009 -- unless the above rule indicates not to.
4010 --
4011 write_new_dpnt_ctfn_item
4012 (p_elig_cvrd_dpnt_id => l_cvrd_dpnt.elig_cvrd_dpnt_id
4013 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
4014 ,p_dpnt_dsgn_ctfn_typ_cd => l_dpnt_ctfn_pgm.ctcvgcd
4015 ,p_dpnt_dsgn_ctfn_rqd_flag => l_dpnt_ctfn_pgm.rqd_flag
4016 ,p_effective_date => p_effective_date
4017 ,p_business_group_id => p_business_group_id
4018 ,p_object_version_number => l_object_version_number
4019 ,p_cvrd_dpnt_ctfn_prvdd_id => l_prtt_enrt_ctfn_prvdd_id);
4020 --
4021 end if;
4022 --
4023 end loop;
4024 --
4025 end if;
4026 --
4027 end if;
4028 --
4029 if l_all_lvls = NOT_FOUND and
4030 l_lvl_cd = 'PTIP' and
4031 l_rslt.pgm_id IS NOT NULL then
4032 --
4033 if l_ctfn_at_ler_chg = TRUE then
4034 --
4035 -- Certifications defined for dpnt ler change
4036 --
4037 for l_ctfn in c_ctfns_ler_chg(l_lvl_cd
4038 ,l_cvrd_dpnt.dpnt_person_id
4039 ,l_rslt.person_id
4040 ,l_cvrd_dpnt.pgm_id
4041 ,l_cvrd_dpnt.pl_id
4042 ,l_cvrd_dpnt.ptip_id) loop
4043 --
4044 l_write_ctfn := check_write_ctfn
4045 (p_formula_id => l_ctfn.ctfn_rqd_when_rl
4046 ,p_pgm_id => l_rslt.pgm_id
4047 ,p_pl_id => l_rslt.pl_id
4048 ,p_pl_typ_id => l_rslt.pl_typ_id
4049 ,p_oipl_id => l_rslt.oipl_id
4050 ,p_ler_id => l_rslt.ler_id
4051 ,p_param1 => 'CON_PERSON_ID'
4052 ,p_param1_value => to_char(l_cvrd_dpnt.dpnt_person_id)
4053 ,p_business_group_id => l_rslt.business_group_id
4054 ,p_assignment_id => l_asg.assignment_id
4055 ,p_organization_id => l_asg.organization_id
4056 ,p_jurisdiction_code => l_jurisdiction_code
4057 ,p_effective_date => p_effective_date);
4058 --
4059 if l_write_ctfn then
4060 --
4061 -- 9999
4062 l_ff_ctfns_exists := TRUE ;
4063 --
4064 -- presently we want to write the certifications always.
4065 -- unless the above rule indicates not to.
4066 --
4067 write_new_dpnt_ctfn_item
4068 (p_elig_cvrd_dpnt_id => l_cvrd_dpnt.elig_cvrd_dpnt_id
4069 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
4070 ,p_dpnt_dsgn_ctfn_typ_cd => l_ctfn.dpnt_cvg_ctfn_typ_cd
4071 ,p_dpnt_dsgn_ctfn_rqd_flag => l_ctfn.rqd_flag
4072 ,p_effective_date => p_effective_date
4073 ,p_business_group_id => p_business_group_id
4074 ,p_object_version_number => l_object_version_number
4075 ,p_cvrd_dpnt_ctfn_prvdd_id => l_prtt_enrt_ctfn_prvdd_id);
4076 --
4077 else
4078 if g_debug then
4079 hr_utility.set_location('Dpnt ctfns at ptip in else - false returned ', 111);
4080 end if;
4081 end if;
4082 --
4083 end loop;
4084 if g_debug then
4085 hr_utility.set_location('Dpnt ctfns at ptip level - false returned ', 990);
4086 end if;
4087 --
4088 else
4089 --
4090 for l_dpnt_ctfn_ptip in c_dpnt_ctfn_ptip(l_cvrd_dpnt.ptip_id
4091 ,l_cvrd_dpnt.dpnt_person_id
4092 ,l_rslt.person_id) loop
4093 --
4094 l_write_ctfn := check_write_ctfn
4095 (p_formula_id => l_dpnt_ctfn_ptip.ctrrl
4096 ,p_pgm_id => l_rslt.pgm_id
4097 ,p_pl_id => l_rslt.pl_id
4098 ,p_pl_typ_id => l_rslt.pl_typ_id
4099 ,p_oipl_id => l_rslt.oipl_id
4100 ,p_ler_id => l_rslt.ler_id
4101 ,p_param1 => 'CON_PERSON_ID'
4102 ,p_param1_value => to_char(l_cvrd_dpnt.dpnt_person_id)
4103 ,p_business_group_id => l_rslt.business_group_id
4104 ,p_assignment_id => l_asg.assignment_id
4105 ,p_organization_id => l_asg.organization_id
4106 ,p_jurisdiction_code => l_jurisdiction_code
4107 ,p_effective_date => p_effective_date);
4108 --
4109 if l_write_ctfn then
4110 --
4111 -- 9999
4112 l_ff_ctfns_exists := TRUE ;
4113 --
4114 -- presently we want to write the certifications always.
4115 -- unless the above rule indicates not to.
4116 --
4117 write_new_dpnt_ctfn_item
4118 (p_elig_cvrd_dpnt_id => l_cvrd_dpnt.elig_cvrd_dpnt_id
4119 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
4120 ,p_dpnt_dsgn_ctfn_typ_cd => l_dpnt_ctfn_ptip.ctcvgcd
4121 ,p_dpnt_dsgn_ctfn_rqd_flag => l_dpnt_ctfn_ptip.rqd_flag
4122 ,p_effective_date => p_effective_date
4123 ,p_business_group_id => p_business_group_id
4124 ,p_object_version_number => l_object_version_number
4125 ,p_cvrd_dpnt_ctfn_prvdd_id => l_prtt_enrt_ctfn_prvdd_id);
4126 --
4127 end if;
4128 --
4129 end loop;
4130 --
4131 end if;
4132 --
4133 end if;
4134 --
4135 --
4136 if l_all_lvls = NOT_FOUND and
4137 (l_lvl_cd = 'PL' ) then
4138 --
4139 if g_debug then
4140 hr_utility.set_location('Dpnt ctfns at plan level', 90);
4141 end if;
4142 --
4143 if l_ctfn_at_ler_chg = TRUE then
4144 --
4145 -- Certifications defined for dpnt ler change
4146 --
4147 for l_ctfn in c_ctfns_ler_chg(l_lvl_cd
4148 ,l_cvrd_dpnt.dpnt_person_id
4149 ,l_rslt.person_id
4150 ,l_cvrd_dpnt.pgm_id
4151 ,l_cvrd_dpnt.pl_id
4152 ,l_cvrd_dpnt.ptip_id) loop
4153 --
4154 l_write_ctfn := check_write_ctfn
4155 (p_formula_id => l_ctfn.ctfn_rqd_when_rl
4156 ,p_pgm_id => l_rslt.pgm_id
4157 ,p_pl_id => l_rslt.pl_id
4158 ,p_pl_typ_id => l_rslt.pl_typ_id
4159 ,p_oipl_id => l_rslt.oipl_id
4160 ,p_ler_id => l_rslt.ler_id
4161 ,p_param1 => 'CON_PERSON_ID'
4162 ,p_param1_value => to_char(l_cvrd_dpnt.dpnt_person_id)
4163 ,p_business_group_id => l_rslt.business_group_id
4164 ,p_assignment_id => l_asg.assignment_id
4165 ,p_organization_id => l_asg.organization_id
4166 ,p_jurisdiction_code => l_jurisdiction_code
4167 ,p_effective_date => p_effective_date);
4168 --
4169 if l_write_ctfn then
4170 --
4171 --
4172 -- 9999
4173 l_ff_ctfns_exists := TRUE ;
4174 --
4175 -- presently we want to write the certifications always.
4176 -- unless the above rule indicates not to.
4177 --
4178 write_new_dpnt_ctfn_item
4179 (p_elig_cvrd_dpnt_id => l_cvrd_dpnt.elig_cvrd_dpnt_id
4180 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
4181 ,p_dpnt_dsgn_ctfn_typ_cd => l_ctfn.dpnt_cvg_ctfn_typ_cd
4182 ,p_dpnt_dsgn_ctfn_rqd_flag => l_ctfn.rqd_flag
4183 ,p_effective_date => p_effective_date
4184 ,p_business_group_id => p_business_group_id
4185 ,p_object_version_number => l_object_version_number
4186 ,p_cvrd_dpnt_ctfn_prvdd_id => l_prtt_enrt_ctfn_prvdd_id);
4187 --
4188 end if;
4189 --
4190 end loop;
4191 --
4192 else
4193 --
4194 for l_dpnt_ctfn_pl in c_dpnt_ctfn_pl(l_cvrd_dpnt.pl_id
4195 ,l_cvrd_dpnt.dpnt_person_id
4196 ,l_rslt.person_id) loop
4197 --
4198 l_write_ctfn := check_write_ctfn
4199 (p_formula_id => l_dpnt_ctfn_pl.ctrrl
4200 ,p_pgm_id => l_rslt.pgm_id
4201 ,p_pl_id => l_rslt.pl_id
4202 ,p_pl_typ_id => l_rslt.pl_typ_id
4203 ,p_oipl_id => l_rslt.oipl_id
4204 ,p_ler_id => l_rslt.ler_id
4205 ,p_param1 => 'CON_PERSON_ID'
4206 ,p_param1_value => to_char(l_cvrd_dpnt.dpnt_person_id)
4207 ,p_business_group_id => l_rslt.business_group_id
4208 ,p_assignment_id => l_asg.assignment_id
4209 ,p_organization_id => l_asg.organization_id
4210 ,p_jurisdiction_code => l_jurisdiction_code
4211 ,p_effective_date => p_effective_date);
4212 --
4213 --
4214 if l_write_ctfn then
4215 --
4216 --
4217 -- 9999
4218 l_ff_ctfns_exists := TRUE ;
4219 --
4220 -- presently we want to write the certifications always.
4221 -- unless the above rule indicates not to.
4222 --
4223 if g_debug then
4224 hr_utility.set_location('Writing Certification', 95);
4225 end if;
4226 --
4227 write_new_dpnt_ctfn_item
4228 (p_elig_cvrd_dpnt_id => l_cvrd_dpnt.elig_cvrd_dpnt_id
4229 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
4230 ,p_dpnt_dsgn_ctfn_typ_cd => l_dpnt_ctfn_pl.ctcvgcd
4231 ,p_dpnt_dsgn_ctfn_rqd_flag => l_dpnt_ctfn_pl.rqd_flag
4232 ,p_effective_date => p_effective_date
4233 ,p_business_group_id => p_business_group_id
4234 ,p_object_version_number => l_object_version_number
4235 ,p_cvrd_dpnt_ctfn_prvdd_id => l_prtt_enrt_ctfn_prvdd_id);
4236 --
4237 else
4238 if g_debug then
4239 hr_utility.set_location('Rule failed.. not writing ctfn', 100);
4240 end if;
4241 end if;
4242 --
4243 end loop;
4244 --
4245 end if;
4246 --
4247 end if;
4248 --
4249
4250 -- 9999 Bug1491912 prtt act item row is deleted if there are no certifications created for
4251 -- for that action item.
4252 IF l_ff_ctfns_exists = FALSE
4253 THEN
4254 --
4255 if g_debug then
4256 hr_utility.set_location ('Entering l_ff_ctfns_exists',999);
4257 end if;
4258 --
4259 -- bug: 5513339
4260 open c_curr_ovn_of_actn (l_prtt_enrt_actn_id);
4261 fetch c_curr_ovn_of_actn into l_object_version_number;
4262 close c_curr_ovn_of_actn ;
4263 delete_action_item
4264 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
4265 ,p_object_version_number => l_object_version_number
4266 ,p_business_group_id => p_business_group_id
4267 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
4268 ,p_rslt_object_version_number => p_rslt_object_version_number
4269 ,p_effective_date => p_effective_date
4270 ,p_datetrack_mode => hr_api.g_zap
4271 ,p_post_rslt_flag => p_post_rslt_flag);
4272 --
4273 if g_debug then
4274 hr_utility.set_location ('Leaving l_ff_ctfns_exists',999);
4275 end if;
4276 --Start Bug 5998009
4277 ELSE
4278 l_dpnt_ctfn_actn_warning := TRUE;
4279 --End Bug 5998009
4280 END IF ;
4281 --
4282 elsif l_prtt_enrt_actn_id IS NOT NULL and
4283 l_rqd_data_found = TRUE and
4284 l_cmpltd_dt IS NULL then
4285 --
4286 -- Bug 6434143
4287 if l_ctfn_at_ler_chg = true
4288 then
4289 --
4290 l_rqd_flag := l_susp_if_ctfn_not_prvd_flag; -- This flag is at LER_CHG_DPNT
4291 --
4292 else
4293 --
4294 l_rqd_flag := l_dpnt.susp_if_ctfn_not_dpnt_flag; -- This flag is at PTIP, PLN or PGM level
4295 --
4296 end if;
4297 --
4298 -- Bug 6434143
4299 if g_debug then
4300 hr_utility.set_location('Existing actn item. Have rqd info', 110);
4301 end if;
4302 --
4303 -- Existing open action item. But we now have required info. Close the
4304 -- action item by setting the cmpltd_dt field.
4305 --
4306 set_cmpltd_dt
4307 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
4308 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
4309 ,p_rslt_object_version_number => p_rslt_object_version_number
4310 ,p_actn_typ_id => l_actn_typ_id
4311 -- ,p_rqd_flag => 'Y' -- Bug 6434143
4312 ,p_rqd_flag => l_rqd_flag
4313 ,p_effective_date => p_effective_date
4314 ,p_post_rslt_flag => p_post_rslt_flag
4315 ,p_business_group_id => p_business_group_id
4316 ,p_object_version_number => l_object_version_number
4317 ,p_open_close => 'CLOSE'
4318 ,p_datetrack_mode => p_datetrack_mode);
4319 --
4320 elsif l_prtt_enrt_actn_id IS NOT NULL and
4321 l_rqd_data_found = FALSE and
4322 l_cmpltd_dt IS NULL then
4323 --
4324 -- Existing closed action item. But required info is missing. Reopen the
4325 -- action item.
4326 --
4327 if g_debug then
4328 hr_utility.set_location('Existing actn item. Rqd info missing', 115);
4329 end if;
4330 --
4331 --Bug 6434143
4332 if l_ctfn_at_ler_chg = true
4333 then
4334 --
4335 l_rqd_flag := l_susp_if_ctfn_not_prvd_flag;
4336 --
4337 else
4338 --
4339 l_rqd_flag := l_dpnt.susp_if_ctfn_not_dpnt_flag;
4340 --
4341 end if;
4342 --
4343 --Bug 6434143
4344
4345 set_cmpltd_dt
4346 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
4347 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
4348 ,p_rslt_object_version_number => p_rslt_object_version_number
4349 ,p_actn_typ_id => l_actn_typ_id
4350 -- ,p_rqd_flag => 'Y' -- Bug 6434143
4351 ,p_rqd_flag => l_rqd_flag
4352 ,p_effective_date => p_effective_date
4353 ,p_post_rslt_flag => p_post_rslt_flag
4354 ,p_business_group_id => p_business_group_id
4355 ,p_object_version_number => l_object_version_number
4356 ,p_open_close => 'OPEN'
4357 ,p_datetrack_mode => p_datetrack_mode);
4358 --
4359 end if;
4360 --
4361 else
4362 --
4363 if g_debug then
4364 hr_utility.set_location('Dpnt ctfn rqd flag is N', 120);
4365 end if;
4366 --
4367 -- dpnt_ctfn_rqd_flag is 'N'
4368 -- if date_track mode is updating and designation at plan level
4369 -- delete action type of type DDCTFN.
4370 --
4371 if (l_prtt_enrt_actn_id IS NOT NULL and p_datetrack_mode = DTMODE_DELETE) then
4372 --
4373 delete_action_item
4374 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
4375 ,p_object_version_number => l_object_version_number
4376 ,p_business_group_id => p_business_group_id
4377 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
4378 ,p_rslt_object_version_number => p_rslt_object_version_number
4379 ,p_effective_date => p_effective_date
4380 ,p_datetrack_mode => p_datetrack_mode
4381 ,p_post_rslt_flag => p_post_rslt_flag);
4382 --
4383 else
4384 NULL; -- nothing to do at this time
4385 end if;
4386 --
4387 end if; -- dpnt_ctfn_rqd_flag
4388 --
4389 end loop; -- dpnt loop
4390 --
4391 if g_debug then
4392 hr_utility.set_location ('Leaving '||l_proc,999);
4393 end if;
4394 --
4395 p_dpnt_actn_warning := l_dpnt_actn_warning;
4396 --
4397
4398 --Start Bug 5998009
4399 if(l_dpnt_ctfn_actn_warning = TRUE) then
4400 p_dpnt_actn_warning := TRUE;
4401 end if;
4402 --End Bug 5998009
4403
4404
4405 exception
4406 --
4407 when others then
4408 if g_debug then
4409 hr_utility.set_location('Exception Raised '||l_proc, 997);
4410 end if;
4411 p_rslt_object_version_number :=l_rslt_object_version_number;
4412 p_dpnt_actn_warning := null;
4413
4414 raise;
4415 --
4416 end determine_dpnt_miss_actn_items;
4417 --
4418 -- Added by Anil
4419 -- ----------------------------------------------------------------------------
4420 -- |--------------------< determine_future_sal_incr_actn_items >----- ---------|
4421 -- ----------------------------------------------------------------------------
4422 --
4423 procedure det_fut_sal_incr_actn_items
4424 (
4425 p_prtt_enrt_rslt_id in number
4426 ,p_effective_date in date
4427 ,p_business_group_id in number
4428 ,p_validate in boolean default FALSE
4429 ,p_datetrack_mode in varchar2 default hr_api.g_correction
4430 ,p_post_rslt_flag in varchar2 default 'Y'
4431 ,p_rslt_object_version_number in out nocopy number
4432 ,p_suspend_flag in out nocopy varchar2
4433 ) is
4434 --
4435 l_proc varchar2(80) := g_package||'.determine_future_sal_incr_actn_items';
4436 l_actn_typ_id number(15);
4437 l_dummy varchar2(30);
4438 l_object_version_number number;
4439 l_prtt_enrt_actn_id number(15);
4440 l_rslt_object_version_number number(15);
4441 l_suspend_flag varchar2(10);
4442 --
4443 cursor c_future_sal_inc is
4444 Select 'X'
4445 from per_pay_proposals pay
4446 ,ben_prtt_enrt_rslt_f rslt
4447 ,ben_pl_typ_f tyP
4448 Where rslt.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
4449 and p_effective_date between rslt.effective_start_date and rslt.effective_end_date
4450 and pay.approved = 'Y'
4451 and rslt.assignment_id = pay.assignment_id
4452 and pay.business_group_id = p_business_group_id
4453 and pay.change_date >= p_effective_date
4454 and typ.pl_typ_id = rslt.pl_typ_id
4455 and rslt.prtt_enrt_rslt_stat_cd is null
4456 and p_effective_date between typ.effective_start_date and typ.effective_end_date
4457 and typ.comp_typ_cd = 'ICM7';
4458 --
4459 l_future_sal_inc c_future_sal_inc%ROWTYPE;
4460 --
4461 BEGIN
4462 --
4463 if g_debug then
4464 hr_utility.set_location ('Entering '||l_proc,10);
4465 end if;
4466 --
4467
4468 l_rslt_object_version_number := p_rslt_object_version_number ;
4469 l_suspend_flag := p_suspend_flag ;
4470
4471 -- Issue a savepoint if operating in validate only mode
4472 --
4473 OPEN c_future_sal_inc;
4474 fetch c_future_sal_inc into l_future_sal_inc;
4475 /*fnd_file.put_line(fnd_file.log,'-->The info garnered from the sal cursor');
4476 fnd_file.put_line(fnd_file.log,'-->l_future_sal_inc.prtt_enrt_rslt_id'||l_future_sal_inc.rslt_id);
4477 fnd_file.put_line(fnd_file.log,'-->l_future_sal_inc.per_in_ler_id'||l_future_sal_inc.per_in_ler_id);
4478 fnd_file.put_line(fnd_file.log,'-->l_future_sal_inc.assignment_id'||l_future_sal_inc.assignment_id);*/
4479 IF c_future_sal_inc%FOUND THEN
4480 l_actn_typ_id := get_actn_typ_id
4481 (p_type_cd => 'MRRFS'
4482 ,p_business_group_id => p_business_group_id);
4483 /*fnd_file.put_line(fnd_file.log,'-->The Action item type is l_actn_typ_id'||l_actn_typ_id);
4484 fnd_file.put_line(fnd_file.log,'-->wrt_actn_item writing the action item with the following parameters');
4485 fnd_file.put_line(fnd_file.log,'-->wrt_actn_item p_prtt_enrt_rslt_id '||p_prtt_enrt_rslt_id);
4486 fnd_file.put_line(fnd_file.log,'-->wrt_actn_item p_effective_date '||p_effective_date);
4487 fnd_file.put_line(fnd_file.log,'-->wrt_actn_item p_business_group_id '||p_business_group_id );
4488 fnd_file.put_line(fnd_file.log,'-->wrt_actn_item p_datetrack_mode '||p_datetrack_mode);
4489 fnd_file.put_line(fnd_file.log,'-->wrt_actn_item p_post_rslt_flag '||p_post_rslt_flag);
4490 fnd_file.put_line(fnd_file.log,'-->wrt_actn_item p_rslt_object_version_number'||p_rslt_object_version_number);
4491 fnd_file.put_line(fnd_file.log,'-->wrt_actn_item p_prtt_enrt_actn_id '||l_prtt_enrt_actn_id);
4492 fnd_file.put_line(fnd_file.log,'---------------------------------------------------------------------------');*/
4493 write_new_action_item
4494 ( p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
4495 ,p_rslt_object_version_number => p_rslt_object_version_number
4496 ,p_actn_typ_id => l_actn_typ_id
4497 ,p_effective_date => p_effective_date
4498 ,p_post_rslt_flag => p_post_rslt_flag
4499 ,p_business_group_id => p_business_group_id
4500 ,p_object_version_number => l_object_version_number
4501 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id);
4502 p_suspend_flag := 'Y';
4503 END IF;
4504
4505 CLOSE c_future_sal_inc;
4506 -- new call to write to ben_reporting
4507 if g_debug then
4508 hr_utility.set_location ('Leaving '||l_proc, 10);
4509 end if;
4510 --
4511 EXCEPTION
4512 WHEN OTHERS THEN
4513 if g_debug then
4514 hr_utility.set_location('Exception Raised '||l_proc, 10);
4515 end if;
4516 fnd_file.put_line(fnd_file.log,'Exception Raised -'||l_proc);
4517 fnd_file.put_line(fnd_file.log,fnd_message.get);
4518 fnd_file.put_line(fnd_file.log,sqlerrm);
4519
4520 p_rslt_object_version_number :=l_rslt_object_version_number;
4521 p_suspend_flag :=l_suspend_flag ;
4522 RAISE;
4523 --
4524 END DET_FUT_SAL_INCR_ACTN_ITEMS;
4525 --
4526 -- ----------------------------------------------------------------------------
4527 -- |--------------------< process_cwb_actn_items >----------------------------|
4528 -- ----------------------------------------------------------------------------
4529 --
4530 procedure process_cwb_actn_items
4531 (p_validate in boolean default FALSE
4532 ,p_prtt_enrt_rslt_id in number
4533 ,p_effective_date in date
4534 ,p_business_group_id in number
4535 ,p_datetrack_mode in varchar2 default hr_api.g_correction
4536 ,p_post_rslt_flag in varchar2 default 'Y'
4537 ,p_rslt_object_version_number in out nocopy number
4538 ,p_suspend_flag in out nocopy varchar2) is
4539 --
4540 l_proc varchar2(80);
4541 l_rslt_object_version_number number(15);
4542 l_suspend_flag varchar2(15);
4543
4544
4545 --
4546 begin
4547 --
4548 g_debug := hr_utility.debug_enabled;
4549 if g_debug then
4550 l_proc := g_package||'.process_cwb_actn_items';
4551 hr_utility.set_location ('Entering '||l_proc,10);
4552 end if;
4553 if g_debug then
4554 hr_utility.set_location ('Entering rslt id '||to_char(p_prtt_enrt_rslt_id),11);
4555 end if;
4556 --
4557 l_rslt_object_version_number := p_rslt_object_version_number ;
4558 l_suspend_flag := p_suspend_flag ;
4559
4560 -- Issue a savepoint if operating in validate only mode
4561 --
4562 savepoint process_cwb_actn_items;
4563 --
4564 /*fnd_file.put_line(fnd_file.log,'-->fut_sal_incr det_fut_sal_incr_actn_items with the following parameters');
4565 fnd_file.put_line(fnd_file.log,'-->fut_sal_incr p_prtt_enrt_rslt_id '||p_prtt_enrt_rslt_id);
4566 fnd_file.put_line(fnd_file.log,'-->fut_sal_incr p_effective_date '||p_effective_date);
4567 fnd_file.put_line(fnd_file.log,'-->fut_sal_incr p_business_group_id '||p_business_group_id );
4568 fnd_file.put_line(fnd_file.log,'-->fut_sal_incr p_datetrack_mode '||p_datetrack_mode);
4569 fnd_file.put_line(fnd_file.log,'-->fut_sal_incr p_post_rslt_flag '||p_post_rslt_flag);
4570 fnd_file.put_line(fnd_file.log,'-->fut_sal_incr p_rslt_object_version_number'||p_rslt_object_version_number);
4571 fnd_file.put_line(fnd_file.log,'-->fut_sal_incr p_suspend_flag '||p_suspend_flag);
4572 fnd_file.put_line(fnd_file.log,'---------------------------------------------------------------------------');*/
4573 --
4574 det_fut_sal_incr_actn_items
4575 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
4576 ,p_rslt_object_version_number => p_rslt_object_version_number
4577 ,p_effective_date => p_effective_date
4578 ,p_business_group_id => p_business_group_id
4579 ,p_datetrack_mode => p_datetrack_mode
4580 ,p_post_rslt_flag => p_post_rslt_flag
4581 ,p_suspend_flag => p_suspend_flag
4582 ,p_validate => p_validate);
4583
4584 if p_validate then
4585 raise hr_api.validate_enabled;
4586 end if;
4587 --
4588 if g_debug then
4589 hr_utility.set_location ('Leaving '||l_proc, 10);
4590 end if;
4591 --
4592 exception
4593 --
4594 when hr_api.validate_enabled
4595 then
4596 rollback to process_cwb_actn_items;
4597 --
4598 if g_debug then
4599 hr_utility.set_location(' Leaving:'||l_proc, 10);
4600 end if;
4601 --
4602 when others then
4603 if g_debug then
4604 hr_utility.set_location('Exception Raised '||l_proc, 10);
4605 end if;
4606 p_rslt_object_version_number := l_rslt_object_version_number ;
4607 p_suspend_flag := l_suspend_flag ;
4608 raise;
4609 --
4610 end process_cwb_actn_items;
4611 --
4612 -- ----------------------------------------------------------------------------
4613 -- |-------------------< determine_dpnt_actn_items >--------------------------|
4614 -- ----------------------------------------------------------------------------
4615 --
4616 procedure determine_dpnt_actn_items
4617 (p_validate in boolean default FALSE
4618 ,p_prtt_enrt_rslt_id in number
4619 ,p_effective_date in date
4620 ,p_business_group_id in number
4621 ,p_datetrack_mode in varchar2 default hr_api.g_correction
4622 ,p_post_rslt_flag in varchar2 default 'Y'
4623 ,p_allws_flag in varchar2
4624 ,p_dsgn_cd in varchar2
4625 ,p_rslt_object_version_number in out nocopy number
4626 ,p_dd_actn_item_open out nocopy boolean
4627 ,p_hack out nocopy varchar2) is
4628 -- this procedure determines if dependents are required to complete enrollment
4629 -- for an enrollment result check ben_elig_per_elctbl_chc.alws_dpnt_dsgn_flag
4630 -- if 'Y' and a new enrollment result write DD action item.
4631 -- A DD action item is only written when no dependents were designated.
4632 -- in additon if the dependent designation is 'R' required, suspend enrollment
4633 -- or if designation 'O' optional, do not suspend.
4634 --
4635 l_proc varchar2(80) ;
4636 --
4637 l_actn_typ_id number(15);
4638 l_cmpltd_dt date;
4639 l_object_version_number number;
4640 l_prtt_enrt_actn_id number(15);
4641 l_rqd_flag varchar2(30);
4642
4643 l_rslt_object_version_number number(15);
4644
4645
4646
4647 --
4648 cursor c_dpnt_dsgn is
4649 select ecd.dpnt_person_id
4650 from ben_elig_cvrd_dpnt_f ecd,
4651 ben_per_in_ler pil
4652 where ecd.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
4653 and ecd.cvg_strt_dt is not null
4654 and nvl(ecd.cvg_thru_dt, hr_api.g_eot) = hr_api.g_eot
4655 and ecd.business_group_id = p_business_group_id
4656 and p_effective_date between
4657 ecd.effective_start_date and ecd.effective_end_date
4658 and pil.per_in_ler_id=ecd.per_in_ler_id
4659 and pil.business_group_id=p_business_group_id
4660 and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT');
4661 --
4662 l_dpnt_dsgn c_dpnt_dsgn%rowtype;
4663 --
4664 -- Cursor to fetch dependent action items other than the DD item. this will
4665 -- be used to delete all dependent action items after a DD action item is
4666 -- written
4667 --
4668 cursor c_other_dpnt_actn_items is
4669 select pea.prtt_enrt_actn_id,
4670 pea.object_version_number
4671 from ben_prtt_enrt_actn_f pea,
4672 ben_actn_typ typ,
4673 ben_per_in_ler pil
4674 where pea.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
4675 and pea.business_group_id = p_business_group_id
4676 and typ.type_cd <> 'DD'
4677 and typ.type_cd like 'DD%'
4678 and pea.per_in_ler_id = pil.per_in_ler_id
4679 and pil.per_in_ler_stat_cd not in ('BCKDT', 'VOIDD')
4680 and typ.business_group_id = p_business_group_id
4681 and pea.actn_typ_id = typ.actn_typ_id
4682 and p_effective_date between
4683 pea.effective_start_date and pea.effective_end_date
4684 ;
4685 --
4686 -- Cursor to check if the enrt rslt is for an employee only option where the
4687 -- min and max dpnts will be 0.
4688 -- 3730053: Designation Requirements for OPT overrides OIPL overrides PLN.
4689 -- Bug 4396160: Curosr name is changed from c_emp_only to c_tot_mn_mx_dpnts_req
4690 -- sothat total number of Min and Max no of dpnts calculated
4691 -- If no DD record is defined, Query will result in Both totals as NULL
4692 cursor c_tot_mn_mx_dpnts_req is -- c_not_emp_only is
4693 select sum(tot_mn_dpnts_rqd_num) tot_mn_dpnts_rqd_num,
4694 sum(tot_mx_dpnts_alwd_num) tot_mx_dpnts_alwd_num
4695 from (select sum(nvl(drq.mn_dpnts_rqd_num, 0 )) tot_mn_dpnts_rqd_num,
4696 sum(nvl(drq.mx_dpnts_alwd_num,9999999999)) tot_mx_dpnts_alwd_num
4697 from ben_dsgn_rqmt_f drq,
4698 ben_oipl_f cop,
4699 ben_prtt_enrt_rslt_f pen
4700 where pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
4701 -- and drq.oipl_id = pen.oipl_id -- 3730053: OPT level DSGN_RQMTS override OIPL level
4702 and pen.oipl_id = cop.oipl_id
4703 and ( (drq.oipl_id = pen.oipl_id
4704 and not exists
4705 (select null
4706 from ben_dsgn_rqmt_f drq2
4707 where drq2.opt_id = cop.opt_id
4708 and p_effective_date between drq2.effective_start_date
4709 and drq2.effective_end_date))
4710 or cop.opt_id = drq.opt_id)
4711 and drq.dsgn_typ_cd = 'DPNT'
4712 --and drq.mn_dpnts_rqd_num > 0
4713 --and drq.mx_dpnts_alwd_num = 0
4714 and cop.business_group_id = p_business_group_id
4715 and p_effective_date between cop.effective_start_date
4716 and cop.effective_end_date
4717 and pen.business_group_id = p_business_group_id
4718 and p_effective_date between pen.effective_start_date
4719 and pen.effective_end_date
4720 and drq.business_group_id = p_business_group_id
4721 and p_effective_date between drq.effective_start_date
4722 and drq.effective_end_date
4723 UNION -- 3730053: Added this to check PL-level designation requirements are specified at PLAN-LEVEL.
4724 select sum(nvl(drq.mn_dpnts_rqd_num, 0 )) tot_mn_dpnts_rqd_num,
4725 sum(nvl(drq.mx_dpnts_alwd_num,9999999999)) tot_mx_dpnts_alwd_num
4726 from ben_dsgn_rqmt_f drq,
4727 ben_prtt_enrt_rslt_f pen
4728 where pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
4729 and drq.pl_id = pen.pl_id
4730 and drq.dsgn_typ_cd = 'DPNT'
4731 --and drq.mn_dpnts_rqd_num > 0
4732 --and drq.mx_dpnts_alwd_num = 0
4733 and pen.business_group_id = p_business_group_id
4734 and p_effective_date between pen.effective_start_date
4735 and pen.effective_end_date
4736 and drq.business_group_id = p_business_group_id
4737 and p_effective_date between drq.effective_start_date
4738 and drq.effective_end_date
4739 and (pen.oipl_id IS NULL
4740 OR NOT EXISTS (select null
4741 from ben_dsgn_rqmt_f drq3
4742 where drq3.oipl_id = pen.oipl_id
4743 and p_effective_date between drq3.effective_start_date and drq3.effective_end_date
4744 UNION ALL
4745 select null
4746 from ben_dsgn_rqmt_f drq4,
4747 ben_oipl_f cop
4748 where cop.oipl_id = pen.oipl_id
4749 and drq4.opt_id = cop.opt_id
4750 and p_effective_date between cop.effective_start_date and cop.effective_end_date
4751 and p_effective_date between drq4.effective_start_date and drq4.effective_end_date))
4752 );
4753 --
4754 --
4755 cursor c_elig_dpnts is
4756 SELECT 'S'
4757 from BEN_ELIG_DPNT egd,
4758 BEN_ELIG_PER_ELCTBL_CHC epe,
4759 BEN_PRTT_ENRT_RSLT_F pen
4760 where pen.PRTT_ENRT_RSLT_ID = p_prtt_enrt_rslt_id
4761 and pen.PRTT_ENRT_RSLT_ID = epe.PRTT_ENRT_RSLT_ID
4762 and egd.elig_per_elctbl_chc_id = epe.elig_per_elctbl_chc_id
4763 and pen.prtt_enrt_rslt_stat_cd is null
4764 and p_effective_date between pen.effective_start_date and pen.effective_end_date
4765 and dpnt_inelig_flag = 'N' ;
4766 --
4767 l_dummy varchar2(1);
4768 l_open_act_item_flag boolean := TRUE;
4769 l_mn_tot_dpnts_req number ;
4770 l_mx_tot_dpnts_alwd number ;
4771 --
4772 begin
4773 --
4774 if g_debug then
4775 l_proc := g_package||'.determine_dpnt_actn_items';
4776 hr_utility.set_location ('Entering '||l_proc,10);
4777 end if;
4778 --
4779 l_rslt_object_version_number :=p_rslt_object_version_number ;
4780
4781 --
4782 l_actn_typ_id := get_actn_typ_id
4783 (p_type_cd => 'DD'
4784 ,p_business_group_id => p_business_group_id);
4785 --
4786 get_prtt_enrt_actn_id
4787 (p_actn_typ_id => l_actn_typ_id
4788 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
4789 ,p_effective_date => p_effective_date
4790 ,p_business_group_id => p_business_group_id
4791 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
4792 ,p_cmpltd_dt => l_cmpltd_dt
4793 ,p_object_version_number => l_object_version_number);
4794 --
4795
4796 -- BUG:3248711: Since epe.alws_dpnt_dsgn_flag = 'N' (LE doesn't allow dpnt dsgn)
4797 -- and yet epe.dpnt_dsgn_cd = 'R' (Dpnt Dsgn is Required)
4798 -- In this case.. we'll have to show the the message that 'Dpnt design is pending'
4799 -- and also suspend the plan. Hence the or-condition (l_dsgn_cd = 'R') as been added
4800 -- to below if-condition
4801
4802 if ((p_allws_flag = 'Y') or (p_dsgn_cd = 'R')) then
4803 --
4804 if g_debug then
4805 hr_utility.set_location('Dpnt dsgn allowed', 10);
4806 end if;
4807 --
4808 -- Check if any dependents are designated
4809 --
4810 open c_dpnt_dsgn;
4811 fetch c_dpnt_dsgn into l_dpnt_dsgn;
4812 --
4813 -- check the dsgn code for R - required or O - optional and set the
4814 -- parameter to be passed to process_action_items. This will ensure that
4815 -- the enrollment is suspended if required.
4816 --
4817 if p_dsgn_cd = 'R' then
4818 l_rqd_flag := 'Y';
4819 else
4820 l_rqd_flag := 'N';
4821 end if;
4822 --
4823 if g_debug then
4824 hr_utility.set_location('Dpnt dsgn rqd flag : ' || l_rqd_flag || ' ' || l_proc, 20);
4825 end if;
4826 --
4827 if c_dpnt_dsgn%NOTFOUND then
4828 --
4829 if g_debug then
4830 hr_utility.set_location('No dpnts designated', 10);
4831 end if;
4832 --
4833 -- there are no dependents designated
4834 --
4835 -- If the enrt is for an employee only option then a DD actn item
4836 -- need not be written.
4837 --
4838 -- Changed for Bug: 4396160,
4839 -- Action Items will not be created if both total min and max are zero for the Paln/Option
4840 -- For Min = 0 and Max > 0, Action Item will be created if Elig dpnts exists
4841 -- For both Min and Max > 0, Action Items will be created irrespective of Elig dpnts.
4842 -- Added case to create Action Items if no DD records defined also.
4843 open c_tot_mn_mx_dpnts_req;
4844 fetch c_tot_mn_mx_dpnts_req into l_mn_tot_dpnts_req, l_mx_tot_dpnts_alwd ;
4845 close c_tot_mn_mx_dpnts_req;
4846 --
4847 if l_mn_tot_dpnts_req is not null and l_mx_tot_dpnts_alwd is not null then -- DD record is defined
4848 if l_mn_tot_dpnts_req = 0 then
4849 --
4850 if l_mx_tot_dpnts_alwd = 0 then
4851 --
4852 l_open_act_item_flag := FALSE ;
4853 --
4854 else
4855 --
4856 Open c_elig_dpnts;
4857 Fetch c_elig_dpnts into l_Dummy;
4858 --
4859 If c_elig_dpnts%FOUND then
4860 --
4861 l_open_act_item_flag := TRUE ;
4862 if g_debug then
4863 hr_utility.set_location('Eligible dpnts found: ', 10);
4864 end if;
4865 --
4866 Else
4867 l_open_act_item_flag := FALSE ;
4868 End if;
4869 --
4870 Close c_elig_dpnts;
4871 --
4872 End if;
4873 Else
4874 --
4875 l_open_act_item_flag := TRUE ;
4876 --
4877 End if;
4878 --
4879 Else -- if No DD record is defined, Then also create Action Item.
4880 l_open_act_item_flag := TRUE ;
4881 --
4882 End if;
4883
4884 /* if c_not_emp_only%found then
4885 --
4886 if g_debug then
4887 hr_utility.set_location('c_not_emp_only found', 10);
4888 end if;
4889 --
4890 l_open_act_item_flag := TRUE ;
4891 --
4892 else
4893 --
4894 if g_debug then
4895 hr_utility.set_location('c_not_emp_only not found: l_mx_dpnts_alwd_num: '||l_mx_dpnts_alwd_num, 10);
4896 end if;
4897 --
4898 Open c_elig_dpnts;
4899 Fetch c_elig_dpnts into l_Dummy;
4900 --
4901 If c_elig_dpnts%FOUND then
4902 --
4903 l_open_act_item_flag := TRUE ;
4904 if g_debug then
4905 hr_utility.set_location('c_lig_dpnts found: ', 10);
4906 end if;
4907 --
4908 Else
4909 l_open_act_item_flag := FALSE ;
4910 End if;
4911 Close c_elig_dpnts;
4912 End if;
4913 Close c_not_emp_only;*/
4914
4915 If l_open_act_item_flag then
4916
4917 --
4918 -- There is no desination requirement defined for the option that
4919 -- doesn't allow dpnts. Write a DD action item.
4920 --
4921 -- process the action item
4922 --
4923 process_action_item
4924 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
4925 ,p_actn_typ_id => l_actn_typ_id
4926 ,p_cmpltd_dt => l_cmpltd_dt
4927 ,p_object_version_number => l_object_version_number
4928 ,p_effective_date => p_effective_date
4929 ,p_rqd_data_found => FALSE
4930 ,p_rqd_flag => l_rqd_flag
4931 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
4932 ,p_post_rslt_flag => p_post_rslt_flag
4933 ,p_business_group_id => p_business_group_id
4934 ,p_datetrack_mode => p_datetrack_mode
4935 ,p_rslt_object_version_number => p_rslt_object_version_number);
4936 --
4937 -- Since the action item was opened/reopened, set the flag to TRUE and
4938 -- also the p_hack flag to 'N' so that the calling procedure knows
4939 -- that action items were actually written and this not to fool it.
4940 --
4941 p_dd_actn_item_open := TRUE;
4942 p_hack := 'N';
4943 --
4944 -- Also, delete all other "dependent" action items that might exist for
4945 -- the prtt_enrt_rslt_id.
4946 --
4947 if g_debug then
4948 hr_utility.set_location('Deleting other dpnt actn items', 10);
4949 end if;
4950 --
4951 for actn_item_rec in c_other_dpnt_actn_items loop
4952 --
4953 delete_action_item
4954 (p_prtt_enrt_actn_id => actn_item_rec.prtt_enrt_actn_id
4955 ,p_object_version_number => actn_item_rec.object_version_number
4956 ,p_business_group_id => p_business_group_id
4957 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
4958 ,p_rslt_object_version_number => p_rslt_object_version_number
4959 ,p_effective_date => p_effective_date
4960 ,p_datetrack_mode => hr_api.g_zap
4961 ,p_post_rslt_flag => p_post_rslt_flag);
4962 --
4963 end loop;
4964 else
4965 --
4966 -- The option does not allow designation of any dependents. Don't write
4967 -- any DD action items.
4968 --
4969 --
4970 -- Set the parameter to TRUE and the hack flag to 'Y' so that the
4971 -- calling procedure does not check for dpnt missing info.
4972 --
4973 p_dd_actn_item_open := TRUE;
4974 p_hack := 'Y';
4975 --
4976 End if;
4977 --
4978 else
4979 --
4980 if g_debug then
4981 hr_utility.set_location('Dpnts designated', 10);
4982 end if;
4983 --
4984 -- Dependents found. Set the out parameter.
4985 --
4986 p_dd_actn_item_open := FALSE;
4987 --
4988 -- If a DD action item was found, we need to complete it. Set the
4989 -- p_rqd_data_found flag to TRUE so that the process_action_item can
4990 -- close the DD action item.
4991 --
4992 process_action_item
4993 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
4994 ,p_actn_typ_id => l_actn_typ_id
4995 ,p_cmpltd_dt => l_cmpltd_dt
4996 ,p_object_version_number => l_object_version_number
4997 ,p_effective_date => p_effective_date
4998 ,p_rqd_data_found => TRUE
4999 ,p_rqd_flag => l_rqd_flag
5000 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
5001 ,p_post_rslt_flag => p_post_rslt_flag
5002 ,p_business_group_id => p_business_group_id
5003 ,p_datetrack_mode => p_datetrack_mode
5004 ,p_rslt_object_version_number => p_rslt_object_version_number);
5005 end if;
5006 --
5007 close c_dpnt_dsgn;
5008 --
5009 end if;
5010 --
5011 if g_debug then
5012 hr_utility.set_location('Leaving ' ||l_proc,10);
5013 end if;
5014 --
5015 exception
5016 when others then
5017 if g_debug then
5018 hr_utility.set_location('Exception Raised '||l_proc, 10);
5019 end if;
5020 p_rslt_object_version_number := l_rslt_object_version_number ;
5021 p_dd_actn_item_open := null;
5022 p_hack := null;
5023
5024 raise;
5025 --
5026 end determine_dpnt_actn_items;
5027 --
5028 -- ----------------------------------------------------------------------------
5029 -- |-----------------< complete_dependent_designation >-----------------------|
5030 -- ----------------------------------------------------------------------------
5031 --
5032 procedure complete_dependent_designation
5033 (p_prtt_enrt_rslt_id in number
5034 ,p_effective_date in date
5035 ,p_business_group_id in number
5036 ,p_datetrack_mode in varchar2 default hr_api.g_correction
5037 ,p_post_rslt_flag in varchar2 default 'Y'
5038 ,p_dsgn_cd in varchar2
5039 ,p_rslt_object_version_number in out nocopy number
5040 ,p_dpnt_actn_warning in out nocopy boolean) is
5041 --
5042 -- this procedure determines if desginated dependents meet all the criteria
5043 -- to complete an open DD action item. The participant can change plans to
5044 -- where designation requirements such as the minimum number of dependents or
5045 -- maximum number of dependents has changed. If a participant changes option
5046 -- within a plan they are required to re-designate their dependents so this is
5047 -- only relevent for a 'plan' change.
5048 --
5049 l_proc varchar2(80) ;
5050 --
5051 l_meets_rqmt varchar2(1) := 'Y';
5052 l_actn_typ_id number(15);
5053 l_cmpltd_dt date;
5054 l_object_version_number number;
5055 l_prtt_enrt_actn_id ben_prtt_enrt_actn_f.prtt_enrt_actn_id%type;
5056 l_rslt_object_version_number number(15);
5057 l_dpnt_actn_warning boolean ;
5058 --
5059 --
5060 -- look for dsgn rqmt records that have no group code. These indicate
5061 -- a general mininum (and/or maximum) number of dpnts that can be
5062 -- designated for this comp object.
5063 --
5064 -- cursor c_min_no_grp modified against Bug 7516987
5065 cursor c_min_no_grp (c_effective_date date) is
5066 select mn_dpnts_rqd_num
5067 from ben_prtt_enrt_rslt_f perslt,
5068 ben_dsgn_rqmt_f drq
5069 where perslt.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
5070 and perslt.prtt_enrt_rslt_stat_cd is null
5071 and drq.dsgn_typ_cd = 'DPNT'
5072 and drq.grp_rlshp_cd is null
5073 and (nvl(drq.pl_id,0) = perslt.pl_id
5074 or
5075 nvl(drq.oipl_id,0) = perslt.oipl_id
5076 or
5077 nvl(drq.opt_id,0) = (select o.opt_id
5078 from ben_oipl_f o
5079 where o.oipl_id = perslt.oipl_id
5080 and c_effective_date
5081 between o.effective_start_date
5082 and o.effective_end_date)
5083 )
5084 and drq.business_group_id = p_business_group_id
5085 and c_effective_date between drq.effective_start_date
5086 and drq.effective_end_date
5087 and perslt.business_group_id = p_business_group_id
5088 and c_effective_date between perslt.effective_start_date
5089 and perslt.effective_end_date;
5090 --
5091 l_min_no_grp c_min_no_grp%rowtype;
5092 --
5093 cursor c_num_of_dpnts is
5094 select count(1) cnt
5095 from ben_elig_cvrd_dpnt_f ecd,
5096 ben_per_in_ler pil
5097 where p_prtt_enrt_rslt_id = ecd.prtt_enrt_rslt_id
5098 and ecd.cvg_strt_dt is not null
5099 and nvl(ecd.cvg_thru_dt, hr_api.g_eot) = hr_api.g_eot
5100 and ecd.business_group_id = p_business_group_id
5101 and p_effective_date between ecd.effective_start_date
5102 and ecd.effective_end_date
5103 and pil.per_in_ler_id=ecd.per_in_ler_id
5104 and pil.business_group_id=p_business_group_id
5105 and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT');
5106 --
5107 l_num_of_dpnts c_num_of_dpnts%rowtype;
5108 --
5109 -- Select 'x' where there are dsgn rqmts for specific contact types
5110 -- and we don't have the minimum number of that contact type
5111 -- designated.
5112 --
5113 -- cursor c_min_typ modified against Bug 7516987
5114 cursor c_min_typ (c_effective_date date) is
5115 select distinct 'X' -- mn_dpnts_rqd_num
5116 from ben_prtt_enrt_rslt_f perslt,
5117 ben_dsgn_rqmt_f drq
5118 where perslt.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
5119 and drq.dsgn_typ_cd = 'DPNT'
5120 and drq.grp_rlshp_cd is not null
5121 and perslt.prtt_enrt_rslt_stat_cd is null
5122 and (nvl(drq.pl_id,0) = perslt.pl_id
5123 or
5124 nvl(drq.oipl_id,0) = perslt.oipl_id
5125 or
5126 nvl(drq.opt_id,0) = (select o.opt_id
5127 from ben_oipl_f o
5128 where o.oipl_id = perslt.oipl_id
5129 and c_effective_date
5130 between o.effective_start_date
5131 and o.effective_end_date)
5132 )
5133 and drq.business_group_id = p_business_group_id
5134 and c_effective_date between drq.effective_start_date
5135 and drq.effective_end_date
5136 and perslt.business_group_id = p_business_group_id
5137 and c_effective_date between perslt.effective_start_date
5138 and perslt.effective_end_date
5139 and mn_dpnts_rqd_num >
5140 (select count(1)
5141 from ben_elig_cvrd_dpnt_f ecd,
5142 per_contact_relationships pcr,
5143 ben_per_in_ler pil
5144 where ecd.prtt_enrt_rslt_id = perslt.prtt_enrt_rslt_id
5145 and ecd.cvg_strt_dt is not null
5146 and nvl(ecd.cvg_thru_dt, hr_api.g_eot) = hr_api.g_eot
5147 and ecd.business_group_id = p_business_group_id
5148 and c_effective_date between
5149 ecd.effective_start_date and ecd.effective_end_date
5150 and perslt.person_id = pcr.person_id
5151 and ecd.dpnt_person_id = pcr.contact_person_id
5152 and pcr.business_group_id = p_business_group_id
5153 and pcr.contact_type in
5154 (select drrt.rlshp_typ_cd
5155 from ben_dsgn_rqmt_rlshp_typ drrt
5156 where drrt.dsgn_rqmt_id = drq.dsgn_rqmt_id)
5157 and pil.per_in_ler_id=ecd.per_in_ler_id
5158 and pil.business_group_id=p_business_group_id
5159 and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT'));
5160 --
5161 l_min_typ c_min_typ%rowtype;
5162
5163 -- added cursor c_get_ler_typ against Bug 7516987 to check for open life event
5164 -- Bug 7516987
5165 cursor c_get_ler_typ is
5166 select ler.typ_cd,
5167 pil.lf_evt_ocrd_dt
5168 from ben_prtt_enrt_rslt_f pen,
5169 ben_per_in_ler pil,
5170 ben_ler_f ler
5171 where pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
5172 and pen.per_in_ler_id = pil.per_in_ler_id
5173 and ler.ler_id = pil.ler_id
5174 and pil.lf_evt_ocrd_dt between ler.effective_start_date and ler.effective_end_date
5175 order by pil.lf_evt_ocrd_dt desc; --Bug 8549599: Added order by clause to get the latest LifeEvent occured date
5176
5177 l_get_ler_typ c_get_ler_typ%rowtype;
5178
5179 -- Bug 7516987
5180
5181 l_rqd_flag varchar2(30);
5182 --
5183 begin
5184 --
5185 if g_debug then
5186 l_proc := g_package||'.complete_dependent_designation';
5187 hr_utility.set_location ('Entering '||l_proc,10);
5188 end if;
5189 --
5190 l_rslt_object_version_number :=p_rslt_object_version_number;
5191 l_dpnt_actn_warning :=p_dpnt_actn_warning ;
5192
5193 -- Bug 7516987
5194 open c_get_ler_typ;
5195 fetch c_get_ler_typ into l_get_ler_typ;
5196 close c_get_ler_typ;
5197 -- Bug 7516987
5198
5199 hr_utility.set_location ('l_get_ler_typ.typ_cd '||to_char(l_get_ler_typ.typ_cd),20);
5200 hr_utility.set_location ('l_get_ler_typ.lf_evt_ocrd_dt '||to_char(l_get_ler_typ.lf_evt_ocrd_dt),20);
5201 hr_utility.set_location ('p_effective_date '||p_effective_date,20);
5202 hr_utility.set_location ('p_prtt_enrt_rslt_id '||p_prtt_enrt_rslt_id,20);
5203 hr_utility.set_location ('l_get_ler_typ '||l_get_ler_typ.typ_cd,20);
5204
5205 --
5206 -- Check the total number of dpnts designated. See if it's less
5207 -- than the minimum number of dpnts of any contact type. There
5208 -- should only be one rqmt record with no group code for this
5209 -- comp object, so no need for a loop.
5210 --
5211
5212 -- Bug 7516987
5213 -- For Open life event, look for the setup of designation requirement as of life event occurred date
5214 if l_get_ler_typ.typ_cd in ('SCHEDDO', 'SCHEDDA') then
5215 /* Added if else condition for Bug 11711605 */
5216 if(l_get_ler_typ.lf_evt_ocrd_dt > p_effective_date) then
5217 open c_min_no_grp (l_get_ler_typ.lf_evt_ocrd_dt);
5218 fetch c_min_no_grp into l_min_no_grp;
5219 else
5220 open c_min_no_grp ( p_effective_date);
5221 fetch c_min_no_grp into l_min_no_grp;
5222 end if;
5223
5224 else
5225 open c_min_no_grp (p_effective_date);
5226 fetch c_min_no_grp into l_min_no_grp;
5227 end if;
5228
5229 -- Bug 7516987
5230 --
5231 if c_min_no_grp%FOUND and
5232 nvl(l_min_no_grp.mn_dpnts_rqd_num,0) > 0 then
5233 --
5234 open c_num_of_dpnts;
5235 fetch c_num_of_dpnts into l_num_of_dpnts;
5236 --
5237 if l_num_of_dpnts.cnt < l_min_no_grp.mn_dpnts_rqd_num then
5238 -- create action item for additional dpnts needed.
5239 l_meets_rqmt := 'N';
5240 end if;
5241 --
5242 close c_num_of_dpnts;
5243 --
5244 end if;
5245 --
5246 close c_min_no_grp;
5247 --
5248 if g_debug then
5249 hr_utility.set_location ('After c_min_no_grp '||l_proc,20);
5250 end if;
5251 --
5252 -- Check the other dsgn rqmts. If there are any rows returned from
5253 -- this cursor, then the person must designate more dependents of
5254 -- some contact type.
5255 --
5256
5257 -- Bug 7516987
5258 -- For Open life event, look for the setup of designation requirement as of life event occurred date
5259 if l_get_ler_typ.typ_cd in ('SCHEDDO', 'SCHEDDA') then
5260 /* Added if else condition for Bug 11711605 */
5261 if(l_get_ler_typ.lf_evt_ocrd_dt > p_effective_date) then
5262 open c_min_typ (l_get_ler_typ.lf_evt_ocrd_dt);
5263 fetch c_min_typ into l_min_typ;
5264 else
5265 open c_min_typ ( p_effective_date);
5266 fetch c_min_typ into l_min_typ;
5267 end if;
5268 else
5269 open c_min_typ (p_effective_date);
5270 fetch c_min_typ into l_min_typ;
5271 end if;
5272 -- Bug 7516987
5273
5274 if c_min_typ%FOUND then
5275 -- create action item for additional dpnts needed.
5276 l_meets_rqmt := 'N';
5277 end if;
5278 --
5279 close c_min_typ;
5280 --
5281 if g_debug then
5282 hr_utility.set_location ('After c_min_typ '||l_proc,30);
5283 end if;
5284 --
5285 --
5286 -- find DDADDNL action item, if it exists.
5287 --
5288 l_actn_typ_id := get_actn_typ_id
5289 (p_type_cd => 'DDADDNL'
5290 ,p_business_group_id => p_business_group_id);
5291 --
5292 get_prtt_enrt_actn_id
5293 (p_actn_typ_id => l_actn_typ_id
5294 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
5295 ,p_effective_date => p_effective_date
5296 ,p_business_group_id => p_business_group_id
5297 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
5298 ,p_cmpltd_dt => l_cmpltd_dt
5299 ,p_object_version_number => l_object_version_number);
5300 --
5301 if g_debug then
5302 hr_utility.set_location ('After get_prtt_enrt_actn_id call '||l_proc,30);
5303 end if;
5304 --
5305 if p_dsgn_cd = 'R' then
5306 l_rqd_flag := 'Y';
5307 else
5308 l_rqd_flag := 'N';
5309 end if;
5310 --
5311 if l_meets_rqmt = 'Y' then
5312 --
5313 if g_debug then
5314 hr_utility.set_location('Meets addnl dpnt rqmts', 10);
5315 end if;
5316 --
5317 -- they meet the minimum number of dpnts, call process-action-item with
5318 -- rqd-data 'true'
5319 --
5320 process_action_item
5321 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
5322 ,p_actn_typ_id => l_actn_typ_id
5323 ,p_cmpltd_dt => l_cmpltd_dt
5324 ,p_object_version_number => l_object_version_number
5325 ,p_effective_date => p_effective_date
5326 ,p_rqd_data_found => TRUE
5327 ,p_rqd_flag => l_rqd_flag
5328 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
5329 ,p_post_rslt_flag => p_post_rslt_flag
5330 ,p_business_group_id => p_business_group_id
5331 ,p_datetrack_mode => p_datetrack_mode
5332 ,p_rslt_object_version_number => p_rslt_object_version_number);
5333 --
5334 elsif l_meets_rqmt = 'N' then
5335 --
5336 if g_debug then
5337 hr_utility.set_location('Does not meet rqmts', 10);
5338 end if;
5339 --
5340 --
5341 -- Doesn't meet requirements. set rqd-data 'FALSE'
5342 --
5343 process_action_item
5344 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
5345 ,p_actn_typ_id => l_actn_typ_id
5346 ,p_cmpltd_dt => l_cmpltd_dt
5347 ,p_object_version_number => l_object_version_number
5348 ,p_effective_date => p_effective_date
5349 ,p_rqd_data_found => FALSE
5350 ,p_rqd_flag => l_rqd_flag
5351 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
5352 ,p_post_rslt_flag => p_post_rslt_flag
5353 ,p_business_group_id => p_business_group_id
5354 ,p_datetrack_mode => p_datetrack_mode
5355 ,p_rslt_object_version_number => p_rslt_object_version_number);
5356 --
5357 end if;
5358 --
5359 -- Pass a warning back to the calling proc only if the requirements are not
5360 -- met and the incoming value was FALSE.
5361 --
5362 if l_meets_rqmt = 'N' and p_dpnt_actn_warning = FALSE then
5363 p_dpnt_actn_warning := TRUE;
5364 end if;
5365 --
5366 if g_debug then
5367 hr_utility.set_location ('Leaving ' ||l_proc,90);
5368 end if;
5369 --
5370 exception
5371 when others then
5372 if g_debug then
5373 hr_utility.set_location('Exception Raised '||l_proc, 99);
5374 end if;
5375 p_rslt_object_version_number := l_rslt_object_version_number;
5376 p_dpnt_actn_warning := l_dpnt_actn_warning ;
5377 raise;
5378 --
5379 end complete_dependent_designation;
5380 --
5381 -- ----------------------------------------------------------------------------
5382 -- |----------------------< process_dpnt_actn_items >-------------------------|
5383 -- ----------------------------------------------------------------------------
5384 --
5385 procedure process_dpnt_actn_items
5386 (p_validate in boolean default FALSE
5387 ,p_prtt_enrt_rslt_id in number
5388 ,p_effective_date in date
5389 ,p_business_group_id in number
5390 ,p_datetrack_mode in varchar2 default hr_api.g_correction
5391 ,p_post_rslt_flag in varchar2 default 'Y'
5392 ,p_rslt_object_version_number in out nocopy number
5393 ,p_suspend_flag in out nocopy varchar2
5394 ,p_dpnt_actn_warning out nocopy boolean
5395 --Bug No 4525608 to capture the certification required warning
5396 ,p_ctfn_actn_warning out nocopy boolean) is
5397 --End Bug 4525608
5398 --
5399 l_proc varchar2(80);
5400 l_rslt_object_version_number number(15);
5401 l_suspend_flag varchar2(15);
5402
5403 --
5404 l_dd_actn_item_open boolean := FALSE; -- flag is set to TRUE if a DD actn item
5405 -- is written/opened.
5406 l_dpnt_actn_warning boolean := FALSE;
5407
5408 --Bug No 4525608 Addtional local parameter
5409 l_ctfn_actn_warning boolean := FALSE;
5410 --End Bug 4525608
5411
5412 l_hack varchar2(1) := 'N';
5413 l_allws_flag varchar2(30);
5414 l_dsgn_cd varchar2(30);
5415
5416 cursor c_chc_flags is
5417 select epe.alws_dpnt_dsgn_flag, epe.dpnt_dsgn_cd
5418 from ben_prtt_enrt_rslt_f pen,
5419 ben_elig_per_elctbl_chc epe,
5420 ben_per_in_ler pil
5421 where pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
5422 and pen.prtt_enrt_rslt_stat_cd is null
5423 and p_effective_date between
5424 pen.effective_start_date and pen.effective_end_date
5425 -- Join by comp object not result_id
5426 and nvl(pen.pgm_id,-1)=nvl(epe.pgm_id,-1)
5427 and pen.pl_id=epe.pl_id
5428 and epe.bnft_prvdr_pool_id is null -- Bug 2389261 exclude these records
5429 and nvl(pen.oipl_id,-1)=nvl(epe.oipl_id,-1)
5430 -- and pen.prtt_enrt_rslt_id = epe.prtt_enrt_rslt_id
5431 and pen.per_in_ler_id = epe.per_in_ler_id
5432 and epe.business_group_id = p_business_group_id
5433 and pil.per_in_ler_id = epe.per_in_ler_id
5434 and pil.business_group_id = p_business_group_id
5435 and pil.per_in_ler_stat_cd not in ('VOIDD', 'BCKDT');
5436 --
5437 begin
5438 --
5439 g_debug := hr_utility.debug_enabled;
5440 if g_debug then
5441 l_proc := g_package||'.process_dpnt_actn_items';
5442 hr_utility.set_location ('Entering '||l_proc,10);
5443 end if;
5444 --
5445 l_rslt_object_version_number :=p_rslt_object_version_number;
5446 l_suspend_flag :=p_suspend_flag ;
5447
5448
5449 -- Issue a savepoint if operating in validate only mode
5450 --
5451 savepoint process_dpnt_actn_items;
5452 --
5453 open c_chc_flags;
5454 fetch c_chc_flags into l_allws_flag, l_dsgn_cd;
5455 if c_chc_flags%notfound then
5456 l_allws_flag := 'N';
5457 l_dsgn_cd := 'O';
5458 end if;
5459 close c_chc_flags;
5460 --
5461 -- BUG:3248711: Since epe.alws_dpnt_dsgn_flag = 'N' (LE doesn't allow dpnt dsgn)
5462 -- and yet epe.dpnt_dsgn_cd = 'R' (Dpnt Dsgn is Required)
5463 -- In this case.. we'll have to show the the message that 'Dpnt design is pending'
5464 -- and also suspend the plan. Hence the or-condition (l_dsgn_cd = 'R') as been added
5465 -- to below if-condition
5466
5467 if ( (l_allws_flag = 'Y') or (l_dsgn_cd = 'R') ) then
5468
5469 determine_dpnt_actn_items
5470 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
5471 ,p_rslt_object_version_number => p_rslt_object_version_number
5472 ,p_effective_date => p_effective_date
5473 ,p_business_group_id => p_business_group_id
5474 ,p_datetrack_mode => p_datetrack_mode
5475 ,p_post_rslt_flag => p_post_rslt_flag
5476 ,p_allws_flag => l_allws_flag
5477 ,p_dsgn_cd => l_dsgn_cd
5478 ,p_dd_actn_item_open => l_dd_actn_item_open
5479 ,p_hack => l_hack);
5480 --
5481 if l_dd_actn_item_open = FALSE then
5482 --
5483 -- The following is executed only if a DD action item was not written, i.e.
5484 -- dependents were found
5485 --
5486 determine_dpnt_miss_actn_items
5487 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
5488 ,p_effective_date => p_effective_date
5489 ,p_business_group_id => p_business_group_id
5490 ,p_datetrack_mode => p_datetrack_mode
5491 ,p_post_rslt_flag => p_post_rslt_flag
5492 ,p_rslt_object_version_number => p_rslt_object_version_number
5493 ,p_dpnt_actn_warning => l_dpnt_actn_warning);
5494 --
5495 complete_dependent_designation
5496 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
5497 ,p_effective_date => p_effective_date
5498 ,p_business_group_id => p_business_group_id
5499 ,p_datetrack_mode => p_datetrack_mode
5500 ,p_post_rslt_flag => p_post_rslt_flag
5501 ,p_dsgn_cd => l_dsgn_cd
5502 ,p_rslt_object_version_number => p_rslt_object_version_number
5503 ,p_dpnt_actn_warning => l_dpnt_actn_warning);
5504 --
5505 --Bug No 4525608
5506 --Passed additional parameter p_ctfn_actn_warning
5507 --to capture the certification action warning
5508 determine_other_actn_items
5509 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
5510 ,p_rslt_object_version_number => p_rslt_object_version_number
5511 ,p_effective_date => p_effective_date
5512 ,p_post_rslt_flag => p_post_rslt_flag
5513 ,p_business_group_id => p_business_group_id
5514 ,p_validate => FALSE
5515 ,p_datetrack_mode => p_datetrack_mode
5516 ,p_suspend_flag => l_suspend_flag
5517 ,p_ctfn_actn_warning => l_ctfn_actn_warning);
5518 --End Bug 4525608
5519 --
5520 else
5521 --
5522 -- l_dd_actn_item_open is TRUE. Set l_dpnt_actn_warning to TRUE to indicate
5523 -- that an action item has been written or reopened
5524 --
5525 if l_hack = 'Y' then
5526 -- This indicates that the l_dd_actn_item_open was set to TRUE only to
5527 -- fool this process to not check for dependent mising items and no
5528 -- DD action item was written. Set the l_dpnt_actn_warning to FALSE
5529 --
5530 l_dpnt_actn_warning := FALSE;
5531 else
5532 l_dpnt_actn_warning := TRUE;
5533 end if;
5534 --
5535 end if;
5536 --
5537 end if; -- allws_dpnt_flag = 'Y'
5538 --
5539 p_dpnt_actn_warning := l_dpnt_actn_warning;
5540
5541 --Bug No 4525608 capture the certification required action item warning
5542 p_ctfn_actn_warning := l_ctfn_actn_warning;
5543 -- End Bug No 4525608
5544
5545 --
5546 if p_validate then
5547 raise hr_api.validate_enabled;
5548 end if;
5549 --
5550 if g_debug then
5551 hr_utility.set_location ('Leaving '||l_proc, 10);
5552 end if;
5553 --
5554 exception
5555 --
5556 when hr_api.validate_enabled
5557 then
5558 rollback to process_dpnt_actn_items;
5559 --
5560 if g_debug then
5561 hr_utility.set_location(' Leaving:'||l_proc, 10);
5562 end if;
5563 --
5564 when others then
5565 if g_debug then
5566 hr_utility.set_location('Exception Raised '||l_proc, 10);
5567 end if;
5568
5569 p_rslt_object_version_number := l_rslt_object_version_number ;
5570 p_suspend_flag := l_suspend_flag ;
5571 p_dpnt_actn_warning := null ;
5572
5573 --Bug No 4525608 when any exception
5574 p_ctfn_actn_warning := null ;
5575 --End Bug No 4525608
5576
5577 raise;
5578 --
5579 end process_dpnt_actn_items;
5580 --
5581 procedure check_ctfn_prvdd
5582 (p_prtt_enrt_rslt_id in number
5583 ,p_effective_date in date
5584 ,p_business_group_id in number
5585 ,p_enrt_ctfn_typ_cd in varchar2
5586 ,p_oipl_id in number
5587 ,p_rqd_flag in varchar2
5588 ,p_pl_id in number
5589 ,p_per_in_ler_id in number
5590 ,p_bnft_amt in number
5591 ,p_ctfn_determine_cd in varchar2
5592 ,p_crntly_enrd_flag in varchar2
5593 ,p_enrt_r_bnft_ctfn_cd in varchar2 default null -- Bug 5887665
5594 ,p_ctfn_prvdd out nocopy boolean) is
5595 --
5596 --Determine the level of the certification
5597 --
5598 cursor c_pl_ctfn ( p_pl_id number,
5599 p_per_in_ler_id number,
5600 p_effective_date date,
5601 p_enrt_ctfn_typ_cd varchar2 ) is
5602 select 'Y'
5603 from ben_ler_rqrs_enrt_ctfn_f lre,
5604 ben_ler_enrt_ctfn_f lec,
5605 ben_per_in_ler pil
5606 where lre.pl_id = p_pl_id
5607 and pil.per_in_ler_id = p_per_in_ler_id
5608 and lre.ler_id = pil.ler_id
5609 and p_effective_date between lre.effective_start_date
5610 and lre.effective_end_date
5611 and p_effective_date between lec.effective_start_date
5612 and lec.effective_end_date
5613 and lec.ler_rqrs_enrt_ctfn_id = lre.ler_rqrs_enrt_ctfn_id
5614 and lec.enrt_ctfn_typ_cd = p_enrt_ctfn_typ_cd
5615 union
5616 select 'Y'
5617 from ben_enrt_ctfn_f ec
5618 where ec.pl_id = p_pl_id
5619 and p_effective_date between ec.effective_start_date
5620 and ec.effective_end_date
5621 and ec.enrt_ctfn_typ_cd = p_enrt_ctfn_typ_cd ;
5622 --
5623 --Determine if currently enrolled at the plan level
5624 --
5625 /* ikasire
5626 Bug 4454990 See the details below. Keep in mind that this happens before the
5627 delete enrollment call from election information.
5628 So these are the following cases we need to keep in mind. If you see issues
5629 please do add the example here so that the future developer won't intruduce another
5630 regression.
5631
5632 Here is the status of the records when this procedure is being called
5633
5634 LE1 LE2
5635
5636 |------------------------------------|---------------------------------------------
5637
5638 Case 1: Continuing in the same enrollment
5639 OldOipl OldOipl
5640 OldPIL NewPIL
5641 OldPEN OldPEN
5642 CTD EOT
5643 EED EOT
5644
5645 Case 2: Continuing in the same enrollment save and then change with new option again
5646
5647 OldOipl OldOipl
5648 OldPIL NewPIL
5649 OldPEN OldPEN
5650 CTD EOT
5651 EED EOT
5652 [the data will change once the delete enrollment is called]
5653 NewOipl
5654 NewPIL
5655 NewPEN
5656 CTD EOT
5657 EED EOT
5658
5659 Case 3: Replace the enrollment with a new Plan Option
5660
5661 OldOipl OldOipl
5662 OldPIL OldPIL [Important]
5663 OldPEN OldPEN
5664 CTD EOT
5665 EED EOT
5666 [the data will change once the delete enrollment is called]
5667 NewOipl
5668 NewPIL
5669 NewPEN
5670 CTD EOT
5671 EED EOT
5672
5673 Case 4: delete the current enrollment and enroll in a new one later
5674
5675 OldOipl OldOipl
5676 OldPIL NewPIL
5677 OldPEN OldPEN
5678 CTD Date will be filled in
5679 EED EOT
5680 [the data will change once the delete enrollment is called]
5681 NewOipl
5682 NewPIL
5683 NewPEN
5684 CTD EOT
5685 EED EOT
5686
5687 */
5688
5689 cursor c_current_pl_enrollment (p_prtt_enrt_rslt_id number) is
5690 select 'Y'
5691 from ben_prtt_enrt_rslt_f pen,
5692 ben_prtt_enrt_rslt_f pen2
5693 where pen2.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
5694 and nvl(pen2.rplcs_sspndd_rslt_id,-999) <> pen.prtt_enrt_rslt_id --NO Interim
5695 and pen2.effective_end_date = to_date('31-12-4712','dd-mm-yyyy')
5696 and pen2.pl_id = pen.pl_id
5697 and pen2.person_id = pen.person_id
5698 and pen.sspndd_flag = 'N'
5699 and (
5700 ( pen2.per_in_ler_id = pen.per_in_ler_id and
5701 ( pen.enrt_cvg_thru_dt <> to_date('31-12-4712','dd-mm-yyyy') or
5702 ( (-- pen.prtt_enrt_rslt_id <> pen2.prtt_enrt_rslt_id and
5703 exists (select 'x' from ben_elig_per_elctbl_chc epe,
5704 ben_prtt_enrt_rslt_f pen3
5705 where epe.per_in_ler_id = pen.per_in_ler_id and
5706 epe.pl_id = pen.pl_id and
5707 ( epe.pgm_id = pen.pgm_id or pen.pgm_id is null) and
5708 ( epe.oipl_id = pen.oipl_id or pen.oipl_id is null) and
5709 epe.crntly_enrd_flag = 'Y' and
5710 epe.elctbl_flag = 'Y' and
5711 epe.bnft_prvdr_pool_id is null and
5712 pen3.prtt_enrt_rslt_id = pen.prtt_enrt_rslt_id and
5713 pen3.prtt_enrt_rslt_stat_cd is null and
5714 pen3.sspndd_flag = 'N' and
5715 pen3.effective_end_date = pen.effective_start_date - 1
5716 )
5717 ) and
5718 pen.enrt_cvg_thru_dt = to_date('31-12-4712','dd-mm-yyyy')
5719 )
5720 ) and
5721 pen.effective_end_date = to_date('31-12-4712','dd-mm-yyyy')
5722 )
5723 or
5724 ( pen.enrt_cvg_thru_dt = to_date('31-12-4712','dd-mm-yyyy') and
5725 pen.effective_end_date = to_date('31-12-4712','dd-mm-yyyy') and
5726 pen.per_in_ler_id <> pen2.per_in_ler_id
5727 )
5728 )
5729 and pen2.prtt_enrt_rslt_stat_cd is null
5730 and pen.prtt_enrt_rslt_stat_cd is null ;
5731 --
5732 --Current Option enrollment
5733 --
5734 cursor c_current_oipl_enrollment (p_prtt_enrt_rslt_id number) is
5735 select 'Y'
5736 from ben_prtt_enrt_rslt_f pen,
5737 ben_prtt_enrt_rslt_f pen2
5738 where pen2.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
5739 and nvl(pen2.rplcs_sspndd_rslt_id,-999) <> pen.prtt_enrt_rslt_id --NO Interim
5740 and pen2.effective_end_date = to_date('31-12-4712','dd-mm-yyyy')
5741 and pen2.pl_id = pen.pl_id
5742 and pen2.oipl_id = pen.oipl_id
5743 and pen2.person_id = pen.person_id
5744 and pen.sspndd_flag = 'N'
5745 and (
5746 ( pen2.per_in_ler_id = pen.per_in_ler_id and
5747 ( pen.enrt_cvg_thru_dt <> to_date('31-12-4712','dd-mm-yyyy') or
5748 ( (-- pen.prtt_enrt_rslt_id <> pen2.prtt_enrt_rslt_id or
5749 exists (select 'x' from ben_elig_per_elctbl_chc epe,
5750 ben_prtt_enrt_rslt_f pen3
5751 where epe.per_in_ler_id = pen2.per_in_ler_id and
5752 epe.pl_id = pen2.pl_id and
5753 ( epe.pgm_id = pen2.pgm_id or pen2.pgm_id is null) and
5754 ( epe.oipl_id = pen2.oipl_id ) and
5755 epe.crntly_enrd_flag = 'Y' and
5756 epe.elctbl_flag = 'Y' and
5757 epe.bnft_prvdr_pool_id is null and
5758 pen3.prtt_enrt_rslt_id = pen2.prtt_enrt_rslt_id and
5759 pen3.prtt_enrt_rslt_stat_cd is null and
5760 pen3.sspndd_flag = 'N' and
5761 pen3.effective_end_date = pen2.effective_start_date - 1
5762 )
5763 ) and
5764 pen.enrt_cvg_thru_dt = to_date('31-12-4712','dd-mm-yyyy')
5765 )
5766 ) and
5767 pen.effective_end_date = to_date('31-12-4712','dd-mm-yyyy')
5768 )
5769 or
5770 ( pen.enrt_cvg_thru_dt = to_date('31-12-4712','dd-mm-yyyy') and
5771 pen.effective_end_date = to_date('31-12-4712','dd-mm-yyyy') and
5772 pen.per_in_ler_id <> pen2.per_in_ler_id
5773 )
5774 )
5775 and pen2.prtt_enrt_rslt_stat_cd is null
5776 and pen.prtt_enrt_rslt_stat_cd is null ;
5777 --
5778 --End Determine the level of the certification
5779 --
5780
5781 --
5782 -- Bug 5965415 : Updated the cursor to check if any certification received in past
5783 -- for the same plan-option (and not based on pen_id as it changes
5784 -- when coverage amount changes)
5785 --
5786 cursor c_ctfn_prvdd (p_prtt_enrt_rslt_id number) is
5787 select null
5788 from ben_prtt_enrt_ctfn_prvdd_f pcs
5789 where pcs.prtt_enrt_rslt_id in
5790 (select distinct(pen1.prtt_enrt_rslt_id) from ben_prtt_enrt_rslt_f pen1, ben_prtt_enrt_rslt_f pen2
5791 where pen2.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
5792 and pen1.person_id = pen2.person_id
5793 and pen1.prtt_enrt_rslt_stat_cd is null
5794 and pen2.prtt_enrt_rslt_stat_cd is null
5795 and pen1.pl_id = pen2.pl_id
5796 --and pen1.per_in_ler_id <> pen2.per_in_ler_id /* Bug 7513897 : If Coverage Amount is changed multiple times for the same Life Event */
5797 and nvl(pen2.oipl_id,0) = nvl(pen1.oipl_id,0)
5798 and pen1.enrt_cvg_thru_dt >= pen1.effective_start_date
5799 and pen1.enrt_cvg_strt_dt <= pen1.enrt_cvg_thru_dt
5800 and pen2.enrt_cvg_thru_dt = to_date('4712/12/31','rrrr/mm/dd')
5801 and p_effective_date between pen2.effective_start_date and
5802 pen2.effective_end_date
5803 and pen1.orgnl_enrt_dt = pen2.orgnl_enrt_dt)
5804 and pcs.ENRT_CTFN_TYP_CD = p_enrt_ctfn_typ_cd
5805 and pcs.ENRT_CTFN_RECD_DT is not null
5806 and pcs.enrt_ctfn_rqd_flag = 'Y'
5807 and pcs.ENRT_R_BNFT_CTFN_CD = nvl(p_enrt_r_bnft_ctfn_cd,'ENRT') -- Bug 5887665
5808 ---Bug 7417593
5809 /* and p_effective_date between pcs.effective_start_date and
5810 pcs.effective_end_date*/
5811 and p_effective_date >= pcs.enrt_ctfn_recd_dt -- Bug 8669907: Changed condition to >=
5812 ---Bug 7417593
5813 ;
5814 --
5815 cursor c_ctfn_prvdd2 (p_prtt_enrt_rslt_id number) is
5816 select null
5817 from ben_prtt_enrt_ctfn_prvdd_f pcs
5818 where pcs.prtt_enrt_rslt_id in
5819 (select distinct(pen1.prtt_enrt_rslt_id) from ben_prtt_enrt_rslt_f pen1, ben_prtt_enrt_rslt_f pen2
5820 where pen2.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
5821 and pen1.person_id = pen2.person_id
5822 and pen1.prtt_enrt_rslt_stat_cd is null
5823 and pen2.prtt_enrt_rslt_stat_cd is null
5824 and pen1.pl_id = pen2.pl_id
5825 --and pen1.per_in_ler_id <> pen2.per_in_ler_id /* Bug 7513897 : If Coverage Amount is changed multiple times for the same Life Event */
5826 and nvl(pen2.oipl_id,0) = nvl(pen1.oipl_id,0)
5827 and pen1.enrt_cvg_thru_dt >= pen1.effective_start_date
5828 and pen1.enrt_cvg_strt_dt <= pen1.enrt_cvg_thru_dt
5829 and pen2.enrt_cvg_thru_dt = to_date('4712/12/31','rrrr/mm/dd')
5830 and p_effective_date between pen2.effective_start_date and
5831 pen2.effective_end_date
5832 and pen1.orgnl_enrt_dt = pen2.orgnl_enrt_dt)
5833 and pcs.ENRT_CTFN_RECD_DT is not null
5834 and pcs.ENRT_R_BNFT_CTFN_CD = nvl(p_enrt_r_bnft_ctfn_cd,'ENRT') -- Bug 5887665
5835 and pcs.enrt_ctfn_rqd_flag = 'N'
5836 and exists (select null from ben_prtt_enrt_ctfn_prvdd_f pcs2
5837 where pcs2.prtt_enrt_rslt_id = pcs.prtt_enrt_rslt_id
5838 and pcs2.ENRT_CTFN_TYP_CD = p_enrt_ctfn_typ_cd
5839 and p_effective_date between pcs2.effective_start_date and
5840 pcs2.effective_end_date)
5841 and p_effective_date between pcs.effective_start_date and
5842 pcs.effective_end_date;
5843 --
5844 -- End Bug 5965415
5845 --
5846 cursor c_prtt_enrt_rslt (p_prtt_enrt_rslt_id number) is
5847 select pen.prtt_enrt_rslt_id
5848 from ben_prtt_enrt_rslt_f pen,
5849 ben_prtt_enrt_rslt_f pen2
5850 where pen2.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
5851 -- and pen2.bnft_amt is null -- Bug 5887665 Need to call this code for benefit level certifications as well
5852 and pen2.effective_end_date = to_date('31-12-4712','dd-mm-yyyy')
5853 and pen2.pl_id = pen.pl_id
5854 and pen2.person_id = pen.person_id
5855 and ((pen2.per_in_ler_id = pen.per_in_ler_id and
5856 pen2.oipl_id <> pen.oipl_id and -- Bug 5887665 Only in same LE we need to chk if option is changed
5857 pen.enrt_cvg_thru_dt <> to_date('31-12-4712','dd-mm-yyyy') and
5858 pen.effective_end_date = to_date('31-12-4712','dd-mm-yyyy')) or
5859 (pen.enrt_cvg_thru_dt = to_date('31-12-4712','dd-mm-yyyy') and
5860 pen.effective_end_date = to_date('31-12-4712','dd-mm-yyyy') and -----Bug 7417474
5861 pen2.oipl_id = pen.oipl_id)) ----Bug 7417474
5862 and pen2.prtt_enrt_rslt_stat_cd is null
5863 and pen.prtt_enrt_rslt_stat_cd is null;
5864 --
5865 cursor c_ler_rstrn(p_effective_date date,
5866 p_per_in_ler_id number,
5867 p_pl_id number) is
5868 select rstrn.cvg_incr_r_decr_only_cd
5869 from ben_ler_bnft_rstrn_f rstrn,
5870 ben_per_in_ler pil
5871 where rstrn.ler_id = pil.ler_id
5872 and rstrn.pl_id = p_pl_id
5873 and pil.per_in_ler_id = p_per_in_ler_id
5874 and p_effective_date
5875 between rstrn.effective_start_date
5876 and rstrn.effective_end_date;
5877 --
5878 cursor c_pl_rstrn (p_effective_date date,
5879 p_pl_id number) is
5880 select pln.cvg_incr_r_decr_only_cd,
5881 pln.bnft_or_option_rstrctn_cd
5882 from ben_pl_f pln
5883 where pln.pl_id = p_pl_id
5884 and p_effective_date
5885 between pln.effective_start_date
5886 and pln.effective_end_date;
5887 --
5888 cursor c_prev_enrollment (p_prtt_enrt_rslt_id number) is
5889 select pen.bnft_amt
5890 from ben_prtt_enrt_rslt_f pen,
5891 ben_prtt_enrt_rslt_f pen2
5892 where pen2.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
5893 and pen2.bnft_amt <> pen.bnft_amt
5894 and pen2.effective_end_date = to_date('31-12-4712','dd-mm-yyyy')
5895 and pen2.pl_id = pen.pl_id
5896 and pen2.person_id = pen.person_id
5897 and ((pen2.per_in_ler_id = pen.per_in_ler_id and
5898 pen.enrt_cvg_thru_dt <> to_date('31-12-4712','dd-mm-yyyy') and
5899 pen.effective_end_date = to_date('31-12-4712','dd-mm-yyyy')) or
5900 (pen.enrt_cvg_thru_dt = to_date('31-12-4712','dd-mm-yyyy') and
5901 pen.effective_end_date = to_date('31-12-4712','dd-mm-yyyy')))
5902 and pen2.prtt_enrt_rslt_stat_cd is null
5903 and pen.prtt_enrt_rslt_stat_cd is null;
5904 --
5905 cursor c_new_dependent (p_prtt_enrt_rslt_id number) is
5906 select 'Y'
5907 from ben_elig_cvrd_dpnt_f egd
5908 where egd.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
5909 and egd.per_in_ler_id = p_per_in_ler_id
5910 and egd.cvg_thru_dt = hr_api.g_eot
5911 and not exists (select null
5912 from ben_elig_cvrd_dpnt_f egd2
5913 where egd.elig_cvrd_dpnt_id = egd2.elig_cvrd_dpnt_id
5914 and egd.dpnt_person_id = egd2.dpnt_person_id
5915 and egd2.per_in_ler_id <> p_per_in_ler_id);
5916 --
5917 l_prtt_enrt_rslt_id number;
5918 l_ctfn_prvdd boolean := false;
5919 l_dummy varchar2(30) ;
5920 l_cvg_incr_code varchar2(240);
5921 l_old_amt number;
5922 l_bnft_or_option_rstrctn_cd VARCHAR2(30);
5923 l_cvg_incr_code_pln varchar(30);
5924
5925 --
5926 Begin
5927 --
5928 hr_utility.set_location('Entering - Check certification prvdd',10);
5929 --
5930 hr_utility.set_location('ctfn_determine_cd'||p_ctfn_determine_cd,11);
5931 hr_utility.set_location('enrt_ctfn_typ_cd'||p_enrt_ctfn_typ_cd,11);
5932 hr_utility.set_location('prtt_enrt_rslt_id'||p_prtt_enrt_rslt_id,11);
5933 hr_utility.set_location('enrt_r_bnft_ctfn_cd'||p_enrt_r_bnft_ctfn_cd,11);
5934 --bug#3748133
5935 /*
5936 if p_crntly_enrd_flag = 'Y' and p_ctfn_determine_cd = 'ENRFT' then
5937 if p_bnft_amt = 0 then
5938 l_ctfn_prvdd := TRUE;
5939 else
5940 --
5941 open c_prev_enrollment (p_prtt_enrt_rslt_id);
5942 fetch c_prev_enrollment into l_old_amt;
5943 close c_prev_enrollment;
5944 --
5945 if l_old_amt = p_bnft_amt then
5946 l_ctfn_prvdd := TRUE;
5947 end if;
5948 end if;
5949 end if;
5950 */
5951 --
5952 --BUG 4454990 Multiple Changes. See bug for the expected functionality
5953 --
5954 if p_ctfn_determine_cd = 'ENRFT' then
5955 --Check if the certification is defined at the plan level
5956 --If defined at the plan level, then need to see the previous enrollment in
5957 --any option in plan. If the ctfn is not defined at the plan level just check
5958 --for the currently enrolled
5959 --
5960 hr_utility.set_location(' p_ctfn_determine_cd = '||p_ctfn_determine_cd,122);
5961 --
5962 open c_pl_ctfn(p_pl_id,p_per_in_ler_id,p_effective_date,p_enrt_ctfn_typ_cd);
5963 fetch c_pl_ctfn into l_dummy;
5964 if c_pl_ctfn%found then
5965 --
5966 hr_utility.set_location(' Plan Level Cert',122);
5967 --
5968 open c_current_pl_enrollment(p_prtt_enrt_rslt_id);
5969 --
5970 fetch c_current_pl_enrollment into l_dummy;
5971 if c_current_pl_enrollment%found then
5972 hr_utility.set_location(' Plan Level - Currently Enrolled in',122);
5973 l_ctfn_prvdd := TRUE;
5974 end if;
5975 --
5976 close c_current_pl_enrollment;
5977 --
5978 elsif p_crntly_enrd_flag = 'Y' and p_oipl_id is not null then
5979 --
5980 hr_utility.set_location(' Option Level -',123);
5981 --Now we need to check if the previous enrollment was unsuspeded or not
5982 open c_current_oipl_enrollment(p_prtt_enrt_rslt_id);
5983 --
5984 fetch c_current_oipl_enrollment into l_dummy;
5985 if c_current_oipl_enrollment%found then
5986 hr_utility.set_location(' Option in Plan Level - Currently Enrolled in',122);
5987 l_ctfn_prvdd := TRUE;
5988 end if;
5989 --
5990 close c_current_oipl_enrollment;
5991 --
5992 else
5993 hr_utility.set_location('Not Currently Enrolled in- why here ', 123);
5994 end if;
5995 close c_pl_ctfn ;
5996 end if;
5997 --
5998 if not l_ctfn_prvdd and p_ctfn_determine_cd = 'ENRNP' then
5999 --
6000 if p_rqd_flag = 'Y' then
6001 open c_ctfn_prvdd (p_prtt_enrt_rslt_id);
6002 fetch c_ctfn_prvdd into l_dummy;
6003 if c_ctfn_prvdd%found then
6004 l_ctfn_prvdd := TRUE;
6005 end if;
6006 close c_ctfn_prvdd;
6007 --
6008 else
6009 --
6010 open c_ctfn_prvdd2 (p_prtt_enrt_rslt_id);
6011 fetch c_ctfn_prvdd2 into l_dummy;
6012 if c_ctfn_prvdd2%found then
6013 l_ctfn_prvdd := TRUE;
6014 end if;
6015 close c_ctfn_prvdd2;
6016 --
6017 end if;
6018 --
6019 end if;
6020 --
6021 if not l_ctfn_prvdd and p_oipl_id is not null and
6022 p_ctfn_determine_cd = 'ENRNP'then
6023 --
6024 hr_utility.set_location('different opt',12);
6025 open c_prtt_enrt_rslt(p_prtt_enrt_rslt_id);
6026 fetch c_prtt_enrt_rslt into l_prtt_enrt_rslt_id;
6027 close c_prtt_enrt_rslt;
6028 --
6029 hr_utility.set_location('Prtt result Id'||l_prtt_enrt_rslt_id,13);
6030 if l_prtt_enrt_rslt_id is not null then
6031 --
6032 if p_rqd_flag = 'Y' then
6033 hr_utility.set_location('inside',11);
6034 open c_ctfn_prvdd(l_prtt_enrt_rslt_id);
6035 fetch c_ctfn_prvdd into l_dummy;
6036 if c_ctfn_prvdd%found then
6037 l_ctfn_prvdd := TRUE;
6038 end if;
6039 close c_ctfn_prvdd;
6040 --
6041 else
6042 --
6043 open c_ctfn_prvdd2(l_prtt_enrt_rslt_id);
6044 fetch c_ctfn_prvdd2 into l_dummy;
6045 if c_ctfn_prvdd2%found then
6046 hr_utility.set_location('True',14);
6047 l_ctfn_prvdd := TRUE;
6048 end if;
6049 close c_ctfn_prvdd2;
6050 --
6051 end if;
6052 end if;
6053 end if;
6054 if not l_ctfn_prvdd and p_ctfn_determine_cd = 'ENRDP' then
6055 if p_crntly_enrd_flag = 'Y' then
6056 --check any new dependents designated
6057 l_dummy := null;
6058 open c_new_dependent(p_prtt_enrt_rslt_id);
6059 fetch c_new_dependent into l_dummy;
6060 close c_new_dependent;
6061 if l_dummy = 'Y' then
6062 l_ctfn_prvdd := FALSE;
6063 else
6064 l_ctfn_prvdd := TRUE;
6065 end if;
6066 else
6067 l_ctfn_prvdd := TRUE;
6068 end if;
6069 --
6070 end if;
6071 --
6072 --
6073 if not l_ctfn_prvdd and
6074 (p_ctfn_determine_cd is null or p_ctfn_determine_cd = 'ENRAT') then
6075 --check for increase/decrease certification -bug#3590524
6076 open c_ler_rstrn (p_effective_date, p_per_in_ler_id, p_pl_id);
6077 fetch c_ler_rstrn into l_cvg_incr_code;
6078 close c_ler_rstrn;
6079 --
6080 --if l_cvg_incr_code is null then
6081 open c_pl_rstrn (p_effective_date, p_pl_id);
6082 fetch c_pl_rstrn into l_cvg_incr_code_pln, l_bnft_or_option_rstrctn_cd;
6083 close c_pl_rstrn;
6084 --end if;
6085 l_cvg_incr_code := NVL(l_cvg_incr_code, l_cvg_incr_code_pln);
6086 --
6087 if l_cvg_incr_code is not null then
6088 --
6089 -- new enrollment
6090 --
6091 if (NVL(l_bnft_or_option_rstrctn_cd,'BNFT') = 'BNFT') then -- 5736589
6092 --
6093 if (p_crntly_enrd_flag is null or p_crntly_enrd_flag = 'N') then -- 3806262
6094 l_ctfn_prvdd := TRUE;
6095 else
6096 --only if the enrollment is new then certication is required
6097 open c_prev_enrollment (p_prtt_enrt_rslt_id);
6098 fetch c_prev_enrollment into l_old_amt;
6099 close c_prev_enrollment;
6100 if l_old_amt is null then
6101 l_ctfn_prvdd := TRUE;
6102 elsif l_cvg_incr_code = 'DECRCTF' and p_bnft_amt > l_old_amt then
6103 l_ctfn_prvdd := TRUE;
6104 elsif l_cvg_incr_code = 'INCRCTF' and p_bnft_amt < l_old_amt then
6105 l_ctfn_prvdd := TRUE;
6106 end if;
6107 end if;
6108 --
6109 end if; -- 5736589
6110 --
6111 end if;
6112 end if;
6113 p_ctfn_prvdd := l_ctfn_prvdd;
6114 --
6115 if p_ctfn_prvdd then
6116 hr_utility.set_location('Leaving Check Ctfn Prvdd TRUE',13);
6117 else
6118 hr_utility.set_location('Leaving Check Ctfn Prvdd FALSE',14);
6119 end if;
6120 --
6121 end;
6122
6123
6124 -- ----------------------------------------------------------------------------
6125 -- |--------------------< determine_other_actn_items >------------------------|
6126 -- ----------------------------------------------------------------------------
6127 --
6128 procedure determine_other_actn_items
6129 (p_prtt_enrt_rslt_id in number
6130 ,p_effective_date in date
6131 ,p_business_group_id in number
6132 ,p_validate in boolean default FALSE
6133 ,p_enrt_bnft_id in number default NULL
6134 ,p_datetrack_mode in varchar2 default hr_api.g_correction
6135 ,p_post_rslt_flag in varchar2 default 'Y'
6136 ,p_rslt_object_version_number in out nocopy number
6137 ,p_suspend_flag in out nocopy varchar2
6138 ,p_ctfn_actn_warning out nocopy boolean) is
6139 --
6140 -- this procedure determines all other enrollment action items that need to
6141 -- be written. We are checking the participant enrollment results looking for
6142 -- certifications, ENRTCTFN, and required specific rates.
6143 --
6144 l_proc varchar2(80) := g_package||'.determine_other_actn_items';
6145 l_meets_rqmt varchar2(3);
6146 l_actn_typ_id number(15);
6147 l_prtt_enrt_ctfn_prvdd_id number(15);
6148 l_cmpltd_dt date;
6149 l_object_version_number number;
6150 l_prtt_enrt_actn_id number(15);
6151 l_datetrack_mode varchar2(30);
6152 l_enrt_exist varchar2(1);
6153
6154 l_rslt_object_version_number number(15);
6155 l_suspend_flag varchar2(15);
6156
6157
6158 --
6159 cursor c_epe is
6160 select epe.ctfn_rqd_flag,
6161 epe.elig_per_elctbl_chc_id,
6162 epe.crntly_enrd_flag,
6163 epe.per_in_ler_id,
6164 epe.pl_id,
6165 nvl(pen.bnft_amt, 0) bnft_amt,
6166 pen.oipl_id
6167 from ben_prtt_enrt_rslt_f pen,
6168 ben_elig_per_elctbl_chc epe,
6169 ben_per_in_ler pil
6170 where pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
6171 and pen.prtt_enrt_rslt_stat_cd is null
6172 and p_effective_date between
6173 pen.effective_start_date and pen.effective_end_date
6174 -- join by comp object
6175 and nvl(pen.pgm_id,-1)=nvl(epe.pgm_id,-1)
6176 and pen.pl_id=epe.pl_id
6177 and epe.bnft_prvdr_pool_id is null -- Bug 2389261 exclude these records
6178 and nvl(pen.oipl_id,-1)=nvl(epe.oipl_id,-1)
6179 -- and pen.prtt_enrt_rslt_id = epe.prtt_enrt_rslt_id
6180 and pen.per_in_ler_id = epe.per_in_ler_id
6181 and epe.business_group_id = p_business_group_id
6182 and pil.per_in_ler_id = epe.per_in_ler_id
6183 and pil.business_group_id = p_business_group_id
6184 and pil.per_in_ler_stat_cd not in ('VOIDD', 'BCKDT');
6185 --
6186 l_epe c_epe%rowtype;
6187 --
6188 cursor c_ecc1(v_elig_per_elctbl_chc_id number) is
6189 select ecc.rqd_flag,
6190 ecc.enrt_ctfn_typ_cd,
6191 ecc.SUSP_IF_CTFN_NOT_PRVD_FLAG,
6192 ecc.ctfn_determine_cd
6193 from ben_elctbl_chc_ctfn ecc
6194 where ecc.elig_per_elctbl_chc_id = v_elig_per_elctbl_chc_id
6195 -- jcarpent added line below for bug 1488666
6196 and ecc.enrt_bnft_id is null
6197 and ecc.business_group_id = p_business_group_id;
6198 --
6199 cursor c_enrt_bnft is
6200 select enb.ctfn_rqd_flag,
6201 nvl(enb.entr_val_at_enrt_flag, 'N') entr_val_at_enrt_flag,
6202 mx_wout_ctfn_val,
6203 cvg_mlt_cd
6204 from ben_enrt_bnft enb
6205 where enb.enrt_bnft_id = p_enrt_bnft_id
6206 and enb.business_group_id = p_business_group_id;
6207 --
6208 l_enrt_bnft c_enrt_bnft%rowtype;
6209 --
6210 cursor c_ecc2(v_enrt_bnft_id number,
6211 v_elig_per_elctbl_chc_id number) is
6212 select ecc.rqd_flag,
6213 ecc.enrt_ctfn_typ_cd,
6214 ecc.SUSP_IF_CTFN_NOT_PRVD_FLAG,
6215 ecc.ctfn_determine_cd
6216 from ben_elctbl_chc_ctfn ecc
6217 where ecc.enrt_bnft_id = v_enrt_bnft_id
6218 and ecc.elig_per_elctbl_chc_id = v_elig_per_elctbl_chc_id
6219 and ecc.business_group_id = p_business_group_id;
6220 --
6221 cursor c_enrt_ctfn(v_prtt_enrt_actn_id number) is
6222 select pec.prtt_enrt_ctfn_prvdd_id,
6223 pec.enrt_ctfn_recd_dt,
6224 pec.object_version_number
6225 from ben_prtt_enrt_ctfn_prvdd_f pec
6226 where pec.prtt_enrt_actn_id = v_prtt_enrt_actn_id
6227 and pec.enrt_r_bnft_ctfn_cd = 'BNFT'
6228 and pec.business_group_id = p_business_group_id
6229 and p_effective_date between pec.effective_start_date
6230 and pec.effective_end_date;
6231 l_enrt_ctfn c_enrt_ctfn%rowtype;
6232 --
6233 -- Bug No 4241743
6234 cursor c_enrt_actn ( p_actn_typ_id number
6235 ,p_prtt_enrt_rslt_id number
6236 ,p_effective_date date
6237 ,p_business_group_id number)
6238 is
6239 select pea.prtt_enrt_actn_id,
6240 pea.per_in_ler_id
6241 from ben_prtt_enrt_actn_f pea,
6242 ben_per_in_ler pil
6243 where pea.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
6244 and pea.actn_typ_id = p_actn_typ_id
6245 and pea.pl_bnf_id is null
6246 and pea.elig_cvrd_dpnt_id is null
6247 and pea.per_in_ler_id = pil.per_in_ler_id
6248 and pil.per_in_ler_stat_cd not in ('BCKDT', 'VOIDD')
6249 and pea.business_group_id = p_business_group_id
6250 and p_effective_date between pea.effective_start_date
6251 and pea.effective_end_date ;
6252 l_enrt_actn c_enrt_actn%rowtype;
6253 --
6254 l_write_new_ctfn boolean := TRUE;
6255 l_ctfn_prvdd boolean ;
6256 l_actn_exists varchar2(10) := 'N'; -- Bug No 4241743
6257 --
6258 -- Bug 5887665
6259 --
6260 cursor c_ler_rstrn(p_effective_date date,
6261 p_per_in_ler_id number,
6262 p_pl_id number) is
6263 select rstrn.cvg_incr_r_decr_only_cd
6264 from ben_ler_bnft_rstrn_f rstrn,
6265 ben_per_in_ler pil
6266 where rstrn.ler_id = pil.ler_id
6267 and rstrn.pl_id = p_pl_id
6268 and pil.per_in_ler_id = p_per_in_ler_id
6269 and p_effective_date
6270 between rstrn.effective_start_date
6271 and rstrn.effective_end_date;
6272 --
6273 cursor c_pl_rstrn (p_effective_date date,
6274 p_pl_id number) is
6275 select pln.cvg_incr_r_decr_only_cd,
6276 pln.bnft_or_option_rstrctn_cd
6277 from ben_pl_f pln
6278 where pln.pl_id = p_pl_id
6279 and p_effective_date
6280 between pln.effective_start_date
6281 and pln.effective_end_date;
6282 --
6283 l_bnft_or_option_rstrctn_cd VARCHAR2(30);
6284 l_cvg_incr_code_pln varchar(30);
6285 l_cvg_incr_code varchar2(240);
6286 --
6287 -- End Bug 5887665
6288 --
6289 begin
6290 --
6291 g_debug := hr_utility.debug_enabled;
6292 if g_debug then
6293 hr_utility.set_location ('Entering '||l_proc,10);
6294 end if;
6295 --
6296 l_rslt_object_version_number :=p_rslt_object_version_number ;
6297 l_suspend_flag :=p_suspend_flag ;
6298
6299 --
6300 savepoint determine_other_actn_items;
6301 --
6302 -- Get elig_per_elctbl_chc id
6303 --
6304 open c_epe;
6305 fetch c_epe into l_epe;
6306 --
6307 if c_epe%notfound then
6308 close c_epe;
6309 /* Bug 2386000 When you run the close action items process after due date
6310 when enrollment was originally suspended due to the BOD certification
6311 requirement (for example) the enrollment might already be end dated
6312 as part of calls from bepenapi delete_enrollment and this may fail.
6313 Instead let us return without doing anything if this cursor doesnot
6314 return any records */
6315 -- fnd_message.set_name('BEN', 'BEN_91578_BENACPRM_EPE_NF');
6316 -- fnd_message.set_token('PROC',l_proc);
6317 -- fnd_message.set_token('PRTT_ENRT_RSLT_ID',to_char(p_prtt_enrt_rslt_id));
6318 -- fnd_message.set_token('EFFECTIVE_DATE',p_effective_date);
6319 -- fnd_message.set_token('BUSINESS_GROUP_ID',to_char(p_business_group_id));
6320 -- fnd_message.raise_error;
6321 if g_debug then
6322 hr_utility.set_location('Enrollment already ended/ZAPed by another process ',22);
6323 end if;
6324 return ;
6325 else
6326 close c_epe;
6327 end if;
6328 --
6329 l_actn_typ_id := get_actn_typ_id
6330 (p_type_cd => 'ENRTCTFN'
6331 ,p_business_group_id => p_business_group_id);
6332 --
6333 /* get_prtt_enrt_actn_id
6334 (p_actn_typ_id => l_actn_typ_id,
6335 p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id,
6336 p_effective_date => p_effective_date,
6337 p_business_group_id => p_business_group_id,
6338 p_prtt_enrt_actn_id => l_prtt_enrt_actn_id,
6339 p_cmpltd_dt => l_cmpltd_dt,
6340 p_object_version_number => l_object_version_number); */ -- Commented for 4241743
6341 --
6342 hr_utility.set_location('CTFN rqd flag '||l_epe.ctfn_rqd_flag,9);
6343 /*Bug 9758763: When a backed out result is reinstated on reprocessing a Life Event,
6344 and the reinstated result is an interim enrollment and the
6345 interim result became effective enrollment because of deleted suspended enrollment
6346 (Action item denied) before backing out the LE and interim and suspended corresponds to same plan(ie only
6347 on epe record), on reinstating the election, result should not be suspended because before backing out
6348 the LE, the reinstated result is not an suspended enrollment. Added check g_create_new_result.
6349 This is continuation of Bug 9538592 */
6350 if(l_epe.ctfn_rqd_flag = 'Y' and ben_lf_evt_clps_restore.g_create_new_result = 'N') then
6351 --
6352 if g_debug then
6353 hr_utility.set_location('CTFN rqd flag is Y', 10);
6354 hr_utility.set_location('l_actn_exists '||l_actn_exists,10);
6355 end if;
6356 -- Bug No 4241743
6357 l_prtt_enrt_actn_id := null;
6358 open c_enrt_actn
6359 (p_actn_typ_id => l_actn_typ_id,
6360 p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id,
6361 p_effective_date => p_effective_date,
6362 p_business_group_id => p_business_group_id
6363 );
6364 loop
6365 fetch c_enrt_actn into l_enrt_actn;
6366 exit when c_enrt_actn%notfound;
6367 l_prtt_enrt_actn_id := l_enrt_actn.prtt_enrt_actn_id;
6368 if l_epe.per_in_ler_id = l_enrt_actn.per_in_ler_id then
6369 hr_utility.set_location('Actn Id '||l_prtt_enrt_actn_id||'found in per_in_ler_id '||l_enrt_actn.per_in_ler_id,12);
6370 l_actn_exists := 'Y';
6371 exit;
6372 end if;
6373 end loop;
6374 close c_enrt_actn;
6375 hr_utility.set_location('After loop l_actn_exists '||l_actn_exists,12);
6376 --
6377 -- Loop through the certifications that might exist for the eltbl chc and
6378 -- write required certifications to the prtt_enrt_ctfn_prvdd table
6379 --
6380 -- Bug No 4241743 Added l_actn_exists check in if condition
6381 if (l_prtt_enrt_actn_id is null or l_actn_exists = 'N') then
6382 --
6383 for l_ecc in c_ecc1(l_epe.elig_per_elctbl_chc_id) loop
6384 --
6385 check_ctfn_prvdd
6386 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
6387 ,p_effective_date => p_effective_date
6388 ,p_business_group_id => p_business_group_id
6389 ,p_enrt_ctfn_typ_cd => l_ecc.enrt_ctfn_typ_cd
6390 ,p_oipl_id => l_epe.oipl_id
6391 ,p_rqd_flag => l_ecc.rqd_flag
6392 ,p_pl_id => l_epe.pl_id
6393 ,p_per_in_ler_id => l_epe.per_in_ler_id
6394 ,p_bnft_amt => l_epe.bnft_amt
6395 ,p_ctfn_determine_cd => l_ecc.ctfn_determine_cd
6396 ,p_crntly_enrd_flag => l_epe.crntly_enrd_flag
6397 ,p_ctfn_prvdd => l_ctfn_prvdd);
6398 --
6399 -- Bug No 4241743 Added l_actn_exists check in if condition
6400 if ((l_prtt_enrt_actn_id is null or l_actn_exists = 'N') and not l_ctfn_prvdd) then
6401 --
6402 hr_utility.set_location('write action ',12);
6403 write_new_action_item
6404 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
6405 ,p_rslt_object_version_number => p_rslt_object_version_number
6406 ,p_actn_typ_id => l_actn_typ_id
6407 ,p_rqd_flag => l_ecc.SUSP_IF_CTFN_NOT_PRVD_FLAG --'Y'
6408 ,p_effective_date => p_effective_date
6409 ,p_post_rslt_flag => p_post_rslt_flag
6410 ,p_business_group_id => p_business_group_id
6411 ,p_object_version_number => l_object_version_number
6412 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id);
6413 --
6414 p_ctfn_actn_warning := true;
6415 end if;
6416 --
6417 if not l_ctfn_prvdd then
6418 --
6419 write_new_prtt_ctfn_prvdd_item
6420 (p_rqd_flag => l_ecc.rqd_flag
6421 ,p_enrt_ctfn_typ_cd => l_ecc.enrt_ctfn_typ_cd
6422 ,p_enrt_r_bnft_ctfn_cd => 'ENRT'
6423 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
6424 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
6425 ,p_effective_date => p_effective_date
6426 ,p_business_group_id => p_business_group_id
6427 ,p_object_version_number => l_object_version_number
6428 ,p_prtt_enrt_ctfn_prvdd_id => l_prtt_enrt_ctfn_prvdd_id);
6429 --
6430 end if;
6431 --
6432 end loop;
6433 --
6434 end if;
6435 --
6436 end if;
6437 --
6438 -- If an enrt_bnft_id was passed we need to check if the enrollment benefit
6439 -- needs any certifications.
6440 --
6441 if p_enrt_bnft_id is not null then
6442 --
6443 open c_enrt_bnft;
6444 fetch c_enrt_bnft into l_enrt_bnft;
6445 --
6446 if c_enrt_bnft%notfound then
6447 close c_enrt_bnft;
6448 fnd_message.set_name('BEN', 'BEN_91580_BENACPRM_ENB_NF');
6449 fnd_message.set_token('PROC',l_proc);
6450 fnd_message.set_token('ENRT_BNFT_ID',to_char(p_enrt_bnft_id));
6451 fnd_message.set_token('BUSINESS_GROUP_ID',to_char(p_business_group_id));
6452 fnd_message.set_token('EFFECTIVE_DATE',p_effective_date);
6453 fnd_message.raise_error;
6454 else
6455 close c_enrt_bnft;
6456 if g_debug then
6457 hr_utility.set_location('c_enrt_bnft found', 10);
6458 end if;
6459 end if;
6460 --
6461 -- Check if there are any ENRTCTFN action items and certifications that
6462 -- already exist. There may be a need to delete them if the enrt bnft record
6463 -- was changed from a one that requires ctfn to a one that doesn't.
6464 --
6465 get_prtt_enrt_actn_id
6466 (p_actn_typ_id => l_actn_typ_id
6467 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
6468 ,p_effective_date => p_effective_date
6469 ,p_business_group_id => p_business_group_id
6470 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
6471 ,p_cmpltd_dt => l_cmpltd_dt
6472 ,p_object_version_number => l_object_version_number);
6473 --
6474 -- swjain - This code seems to be redundant as l_prtt_enrt_actn_id won't be not null
6475 -- in any case. Need to review this part of code.
6476 --
6477 if (l_prtt_enrt_actn_id is not null) then
6478 --
6479 -- Delete all certifications of type 'BNFT' for the action item
6480 --
6481 If p_datetrack_mode = hr_api.g_zap then
6482 l_datetrack_mode := hr_api.g_zap;
6483 Elsif p_datetrack_mode = hr_api.g_delete then
6484 l_datetrack_mode := hr_api.g_delete;
6485 Elsif p_datetrack_mode = hr_api.g_correction then
6486 l_datetrack_mode := hr_api.g_zap;
6487 Elsif p_datetrack_mode = hr_api.g_update then
6488 l_datetrack_mode := hr_api.g_delete;
6489 Else
6490 l_datetrack_mode := hr_api.g_delete;
6491 End if;
6492 --
6493 for l_enrt_ctfn in c_enrt_ctfn(l_prtt_enrt_actn_id) loop
6494 --
6495 if l_enrt_ctfn.enrt_ctfn_recd_dt = null then
6496 l_write_new_ctfn := TRUE;
6497 delete_prtt_ctfn_prvdd
6498 (p_prtt_enrt_ctfn_prvdd_id => l_enrt_ctfn.prtt_enrt_ctfn_prvdd_id
6499 ,p_object_version_number => l_enrt_ctfn.object_version_number
6500 ,p_effective_date => p_effective_date
6501 ,p_datetrack_mode => l_datetrack_mode);
6502 else
6503 l_write_new_ctfn := FALSE;
6504 end if;
6505 --
6506 end loop;
6507 --
6508 end if;
6509
6510 -- write the ctfn's only if the flag is 'Y' AND if the cvg amt was
6511 -- enterable, the entered amt was more than the mx_wout_ctfn_val.Bug 1249901
6512 hr_utility.set_location('Benefit amount '||l_epe.bnft_amt,11);
6513 --
6514 open c_ler_rstrn (p_effective_date, l_epe.per_in_ler_id, l_epe.pl_id);
6515 fetch c_ler_rstrn into l_cvg_incr_code;
6516 close c_ler_rstrn;
6517 --
6518 --if l_cvg_incr_code is null then
6519 open c_pl_rstrn (p_effective_date, l_epe.pl_id);
6520 fetch c_pl_rstrn into l_cvg_incr_code_pln, l_bnft_or_option_rstrctn_cd;
6521 close c_pl_rstrn;
6522 --end if;
6523 l_cvg_incr_code := NVL(l_cvg_incr_code, l_cvg_incr_code_pln);
6524 --
6525 if l_enrt_bnft.ctfn_rqd_flag = 'Y'
6526 and (l_epe.bnft_amt > nvl(l_enrt_bnft.mx_wout_ctfn_val, 0) or
6527 (l_bnft_or_option_rstrctn_cd = 'BNFT' and l_cvg_incr_code = 'DECRCTF')) then
6528 --
6529 -- swjain -- No need for other conditions. Also for 'DECRCTF' codes, no need to chk if
6530 -- bnft_amt > l_enrt_bnft.mx_wout_ctfn_val
6531 --
6532 /* and ((l_enrt_bnft.entr_val_at_enrt_flag = 'N' or
6533 l_enrt_bnft.entr_val_at_enrt_flag = 'Y'or l_enrt_bnft.cvg_mlt_cd in ('ERL')) */
6534 --
6535 -- Bug 3183266 : For flat range l_enrt_bnft.mx_wout_ctfn_val will be null
6536 --
6537 if g_debug then
6538 hr_utility.set_location('CTFN rqd flag is Y', 10);
6539 end if;
6540 --
6541 -- Loop through the certifications that might exist for the eltbl chc and
6542 -- write required certifications to the prtt_enrt_ctfn_prvdd table
6543 --
6544 for l_ecc in c_ecc2(p_enrt_bnft_id
6545 ,l_epe.elig_per_elctbl_chc_id) loop
6546 --
6547 -- Bug 5887665 - Even for coverage ctfns, we need to see the suspended codes, and
6548 -- then create action items and ctfns accordingly
6549 --
6550 check_ctfn_prvdd
6551 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
6552 ,p_effective_date => p_effective_date
6553 ,p_business_group_id => p_business_group_id
6554 ,p_enrt_ctfn_typ_cd => l_ecc.enrt_ctfn_typ_cd
6555 ,p_oipl_id => l_epe.oipl_id
6556 ,p_rqd_flag => l_ecc.rqd_flag
6557 ,p_pl_id => l_epe.pl_id
6558 ,p_per_in_ler_id => l_epe.per_in_ler_id
6559 ,p_bnft_amt => l_epe.bnft_amt
6560 ,p_ctfn_determine_cd => l_ecc.ctfn_determine_cd
6561 ,p_crntly_enrd_flag => l_epe.crntly_enrd_flag
6562 ,p_enrt_r_bnft_ctfn_cd => 'BNFT'
6563 ,p_ctfn_prvdd => l_ctfn_prvdd);
6564 --
6565 if (l_prtt_enrt_actn_id is null and not l_ctfn_prvdd) then
6566 --
6567 write_new_action_item
6568 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
6569 ,p_rslt_object_version_number => p_rslt_object_version_number
6570 ,p_actn_typ_id => l_actn_typ_id
6571 ,p_rqd_flag => l_ecc.SUSP_IF_CTFN_NOT_PRVD_FLAG --'Y'
6572 ,p_effective_date => p_effective_date
6573 ,p_post_rslt_flag => p_post_rslt_flag
6574 ,p_business_group_id => p_business_group_id
6575 ,p_object_version_number => l_object_version_number
6576 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id);
6577 --
6578 p_ctfn_actn_warning := true;
6579 --
6580 end if;
6581 --
6582 if (not l_ctfn_prvdd and (l_prtt_enrt_actn_id is null or
6583 (l_prtt_enrt_actn_id is not null and l_write_new_ctfn))) then
6584 --
6585 write_new_prtt_ctfn_prvdd_item
6586 (p_rqd_flag => l_ecc.rqd_flag
6587 ,p_enrt_ctfn_typ_cd => l_ecc.enrt_ctfn_typ_cd
6588 ,p_enrt_r_bnft_ctfn_cd => 'BNFT'
6589 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
6590 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
6591 ,p_effective_date => p_effective_date
6592 ,p_business_group_id => p_business_group_id
6593 ,p_object_version_number => l_object_version_number
6594 ,p_prtt_enrt_ctfn_prvdd_id => l_prtt_enrt_ctfn_prvdd_id);
6595 --
6596 end if;
6597 --
6598 end loop;
6599 --
6600 end if; -- ctfn_rqd_flag
6601 --
6602 end if; -- p_enrt_bnft_id
6603 --
6604 if p_validate then
6605 raise hr_api.validate_enabled;
6606 end if;
6607 --
6608 if g_debug then
6609 hr_utility.set_location ('Leaving ' ||l_proc,10);
6610 end if;
6611 --
6612 exception
6613 --
6614 when hr_api.validate_enabled
6615 then
6616 rollback to determine_other_actn_items;
6617 if g_debug then
6618 hr_utility.set_location ('Leaving ' ||l_proc,10);
6619 end if;
6620 --
6621 when others then
6622 if g_debug then
6623 hr_utility.set_location('Exception Raised '||l_proc, 10);
6624 end if;
6625 raise;
6626 --
6627 end determine_other_actn_items;
6628 --
6629 -- ----------------------------------------------------------------------------
6630 -- |--------------------< determine_pcp_dpnt_actn_items >------------------------|
6631 -- ----------------------------------------------------------------------------
6632 --
6633 procedure determine_pcp_dpnt_actn_items
6634 (p_prtt_enrt_rslt_id in number
6635 ,p_effective_date in date
6636 ,p_business_group_id in number
6637 ,p_elig_cvrd_dpnt_id in number
6638 ,p_validate in boolean default FALSE
6639 ,p_datetrack_mode in varchar2 default hr_api.g_correction
6640 ,p_post_rslt_flag in varchar2 default 'Y'
6641 ,p_pcp_dpnt_dsgn_cd in varchar2
6642 ,p_rslt_object_version_number in out nocopy number
6643 ,p_suspend_flag in out nocopy varchar2
6644 ,p_pcp_dpnt_actn_warning out nocopy boolean) is
6645 --
6646 l_proc varchar2(80) ;
6647 l_actn_typ_id number(15);
6648 l_prtt_enrt_ctfn_prvdd_id number(15);
6649 l_cmpltd_dt date;
6650 l_datetrack_mode varchar2(30);
6651 l_pcp_dpnt_actn_warning boolean := FALSE;
6652 l_dummy varchar2(30);
6653 l_prtt_enrt_actn_id number(15);
6654 l_object_version_number number;
6655 l_rqd_flag varchar2(30);
6656 l_rqd_data_found boolean := FALSE;
6657
6658 l_rslt_object_version_number number(15);
6659 l_suspend_flag varchar2(20);
6660
6661
6662 cursor c_prmry_care_actn is
6663 select 'x'
6664 from ben_prmry_care_prvdr_f pf,
6665 ben_elig_cvrd_dpnt_f ecd
6666 where pf.elig_cvrd_dpnt_id = ecd.elig_cvrd_dpnt_id
6667 -- and ecd.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id bug 1421978
6668 and ecd.elig_cvrd_dpnt_id = p_elig_cvrd_dpnt_id
6669 and pf.business_group_id = p_business_group_id
6670 and ecd.business_group_id = p_business_group_id
6671 and p_effective_date between ecd.effective_start_date
6672 and ecd.effective_end_date
6673 and p_effective_date between pf.effective_start_date
6674 and pf.effective_end_date;
6675 --
6676 begin
6677 --
6678 if g_debug then
6679 l_proc := g_package||'.determine_pcp_dpnt_actn_items';
6680 hr_utility.set_location ('Entering '||l_proc,10);
6681 end if;
6682 --
6683 l_rslt_object_version_number := p_rslt_object_version_number ;
6684 l_suspend_flag := p_suspend_flag ;
6685
6686 -- Issue a savepoint if operating in validate only mode
6687 --
6688 savepoint determine_pcp_dpnt_actn_items;
6689 --
6690 if p_pcp_dpnt_dsgn_cd = 'R' then
6691 l_rqd_flag := 'Y';
6692 else
6693 l_rqd_flag := 'N';
6694 end if;
6695 --
6696 if g_debug then
6697 hr_utility.set_location('pcp dpnt dsgn rqd flag : ' || l_rqd_flag || ' ' ||
6698 l_proc, 20);
6699 end if;
6700 --
6701 -- As the only modification happening in the code is for rqd_flag = 'Y',
6702 -- restrict the code execution only when it's on.
6703 --
6704 if l_rqd_flag = 'Y' then
6705 open c_prmry_care_actn;
6706 fetch c_prmry_care_actn into l_dummy;
6707 if c_prmry_care_actn%notfound then
6708 l_rqd_data_found := FALSE;
6709 if g_debug then
6710 hr_utility.set_location('c_prmry_care_actn notfound' , 90 );
6711 end if;
6712 elsif c_prmry_care_actn%found then
6713 l_rqd_data_found := TRUE;
6714 if g_debug then
6715 hr_utility.set_location('c_prmry_care_actn found' , 91 );
6716 end if;
6717 end if;
6718 close c_prmry_care_actn;
6719 --
6720 if g_debug then
6721 hr_utility.set_location('PCPDPNT action item ', 30);
6722 end if;
6723 --
6724 l_actn_typ_id := get_actn_typ_id
6725 (p_type_cd => 'PCPDPNT'
6726 ,p_business_group_id => p_business_group_id);
6727 --
6728 if g_debug then
6729 hr_utility.set_location ('Entering get_prtt_enrt_actn_id ' , 101);
6730 end if;
6731 get_prtt_enrt_actn_id
6732 (p_actn_typ_id => l_actn_typ_id,
6733 p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id,
6734 p_elig_cvrd_dpnt_id => p_elig_cvrd_dpnt_id,
6735 p_effective_date => p_effective_date,
6736 p_business_group_id => p_business_group_id,
6737 p_prtt_enrt_actn_id => l_prtt_enrt_actn_id,
6738 p_cmpltd_dt => l_cmpltd_dt,
6739 p_object_version_number => l_object_version_number);
6740
6741 --
6742 if (l_prtt_enrt_actn_id IS NULL and
6743 l_rqd_data_found = FALSE) then
6744 l_pcp_dpnt_actn_warning := TRUE;
6745 elsif l_prtt_enrt_actn_id IS NOT NULL and
6746 l_rqd_data_found = TRUE and
6747 l_cmpltd_dt IS NULL then
6748 --
6749 if g_debug then
6750 hr_utility.set_location ('Case 1 ',102);
6751 end if;
6752 -- Existing open action item but we now have required data. Close the open
6753 -- action item by setting cmpltd_dt field
6754 --
6755 l_pcp_dpnt_actn_warning := FALSE;
6756 elsif l_prtt_enrt_actn_id IS NOT NULL and
6757 l_rqd_data_found = FALSE and
6758 l_cmpltd_dt IS NOT NULL then
6759 --
6760 -- Found a closed action item. But required data is missing. Reopen item
6761 --
6762 if g_debug then
6763 hr_utility.set_location ('Case2 ',103);
6764 end if;
6765 l_pcp_dpnt_actn_warning := TRUE;
6766 else
6767 if g_debug then
6768 hr_utility.set_location ('Case3 ',104);
6769 end if;
6770 l_pcp_dpnt_actn_warning := FALSE;
6771 end if;
6772 -- process the action item
6773 --
6774 process_action_item
6775 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
6776 ,p_actn_typ_id => l_actn_typ_id
6777 ,p_cmpltd_dt => l_cmpltd_dt
6778 ,p_object_version_number => l_object_version_number
6779 ,p_effective_date => p_effective_date
6780 ,p_rqd_data_found => l_rqd_data_found
6781 ,p_rqd_flag => l_rqd_flag
6782 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
6783 ,p_elig_cvrd_dpnt_id => p_elig_cvrd_dpnt_id --bug 1421978
6784 ,p_post_rslt_flag => p_post_rslt_flag
6785 ,p_business_group_id => p_business_group_id
6786 ,p_datetrack_mode => p_datetrack_mode
6787 ,p_rslt_object_version_number => p_rslt_object_version_number);
6788 --
6789 end if; -- rqd_flag = 'Y'
6790 --
6791 p_pcp_dpnt_actn_warning := l_pcp_dpnt_actn_warning;
6792 if p_validate then
6793 raise hr_api.validate_enabled;
6794 end if;
6795 --
6796 if g_debug then
6797 hr_utility.set_location ('Leaving '||l_proc, 10);
6798 end if;
6799 --
6800
6801 exception
6802 --
6803 when hr_api.validate_enabled
6804 then
6805 rollback to determine_pcp_dpnt_actn_items;
6806 --
6807 if g_debug then
6808 hr_utility.set_location(' Leaving:'||l_proc, 10);
6809 end if;
6810 --
6811 when others then
6812 if g_debug then
6813 hr_utility.set_location('Exception Raised '||l_proc, 10);
6814 end if;
6815 p_rslt_object_version_number := l_rslt_object_version_number;
6816 p_suspend_flag := l_suspend_flag ;
6817 p_pcp_dpnt_actn_warning := null ;
6818
6819 raise;
6820 --
6821 end determine_pcp_dpnt_actn_items;
6822 --
6823 -- ----------------------------------------------------------------------------
6824 -- |--------------------< determine_pcp_actn_items >--------------------------|
6825 -- ----------------------------------------------------------------------------
6826 --
6827 procedure determine_pcp_actn_items
6828 (p_prtt_enrt_rslt_id in number
6829 ,p_effective_date in date
6830 ,p_business_group_id in number
6831 ,p_validate in boolean default FALSE
6832 ,p_datetrack_mode in varchar2 default hr_api.g_correction
6833 ,p_post_rslt_flag in varchar2 default 'Y'
6834 ,p_pcp_dsgn_cd in varchar2
6835 ,p_rslt_object_version_number in out nocopy number
6836 ,p_suspend_flag in out nocopy varchar2
6837 ,p_pcp_actn_warning out nocopy boolean) is
6838 --
6839 l_proc varchar2(80) ;
6840 l_actn_typ_id number(15);
6841 l_prtt_enrt_ctfn_prvdd_id number(15);
6842 l_cmpltd_dt date;
6843 l_datetrack_mode varchar2(30);
6844 l_pcp_actn_warning boolean := FALSE;
6845 l_dummy varchar2(30);
6846 l_prtt_enrt_actn_id number(15);
6847 l_object_version_number number;
6848 l_rqd_flag varchar2(30);
6849 l_rqd_data_found boolean := FALSE;
6850
6851 l_rslt_object_version_number number(15);
6852 l_suspend_flag varchar2(20);
6853
6854 cursor c_prmry_care_actn is
6855 select 'x'
6856 from ben_prmry_care_prvdr_f pf
6857 where pf.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
6858 and pf.business_group_id = p_business_group_id
6859 and p_effective_date between pf.effective_start_date
6860 and pf.effective_end_date;
6861 --
6862 begin
6863 --
6864 if g_debug then
6865 l_proc := g_package||'.determine_pcp_actn_items';
6866 hr_utility.set_location ('Entering '||l_proc,10);
6867 end if;
6868 --
6869
6870 l_rslt_object_version_number := p_rslt_object_version_number ;
6871 l_suspend_flag := p_suspend_flag ;
6872
6873 -- Issue a savepoint if operating in validate only mode
6874 --
6875 savepoint determine_pcp_actn_items;
6876 --
6877 if p_pcp_dsgn_cd = 'R' then
6878 l_rqd_flag := 'Y';
6879 else
6880 l_rqd_flag := 'N';
6881 end if;
6882 --
6883 if g_debug then
6884 hr_utility.set_location('pcp dsgn rqd flag : ' || l_rqd_flag || ' ' ||
6885 l_proc, 20);
6886 end if;
6887 --
6888 -- As the only modification happening in the code is for rqd_flag = 'Y',
6889 -- restrict the code execution only when it's on.
6890 --
6891 if l_rqd_flag = 'Y' then
6892 open c_prmry_care_actn;
6893 fetch c_prmry_care_actn into l_dummy;
6894 if c_prmry_care_actn%notfound then
6895 l_rqd_data_found := FALSE;
6896 elsif c_prmry_care_actn%found then
6897 l_rqd_data_found := TRUE;
6898 end if;
6899 close c_prmry_care_actn;
6900 --
6901 if g_debug then
6902 hr_utility.set_location('PCPPRTT action item ', 30);
6903 end if;
6904 --
6905 l_actn_typ_id := get_actn_typ_id
6906 (p_type_cd => 'PCPPRTT'
6907 ,p_business_group_id => p_business_group_id);
6908 --
6909 get_prtt_enrt_actn_id
6910 (p_actn_typ_id => l_actn_typ_id,
6911 p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id,
6912 p_effective_date => p_effective_date,
6913 p_business_group_id => p_business_group_id,
6914 p_prtt_enrt_actn_id => l_prtt_enrt_actn_id,
6915 p_cmpltd_dt => l_cmpltd_dt,
6916 p_object_version_number => l_object_version_number);
6917
6918 --
6919 if (l_prtt_enrt_actn_id IS NULL and
6920 l_rqd_data_found = FALSE) then
6921 l_pcp_actn_warning := TRUE;
6922 if g_debug then
6923 hr_utility.set_location ('Leaving '||'TRUE', 11);
6924 end if;
6925 elsif l_prtt_enrt_actn_id IS NOT NULL and
6926 l_rqd_data_found = TRUE and
6927 l_cmpltd_dt IS NULL then
6928 --
6929 -- Existing open action item but we now have required data. Close the open
6930 -- action item by setting cmpltd_dt field
6931 --
6932 if g_debug then
6933 hr_utility.set_location ('Leaving '||'FALSE', 12);
6934 end if;
6935 l_pcp_actn_warning := FALSE;
6936 elsif l_prtt_enrt_actn_id IS NOT NULL and
6937 l_rqd_data_found = FALSE and
6938 l_cmpltd_dt IS NOT NULL then
6939 --
6940 -- Found a closed action item. But required data is missing. Reopen item
6941 --
6942 if g_debug then
6943 hr_utility.set_location ('Leaving '||'TRUE', 13);
6944 end if;
6945 l_pcp_actn_warning := TRUE;
6946 else
6947 if g_debug then
6948 hr_utility.set_location ('Leaving '||'FALSE', 14);
6949 end if;
6950 l_pcp_actn_warning := FALSE;
6951 end if;
6952 -- process the action item
6953 --
6954 process_action_item
6955 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
6956 ,p_actn_typ_id => l_actn_typ_id
6957 ,p_cmpltd_dt => l_cmpltd_dt
6958 ,p_object_version_number => l_object_version_number
6959 ,p_effective_date => p_effective_date
6960 ,p_rqd_data_found => l_rqd_data_found
6961 ,p_rqd_flag => l_rqd_flag
6962 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
6963 ,p_post_rslt_flag => p_post_rslt_flag
6964 ,p_business_group_id => p_business_group_id
6965 ,p_datetrack_mode => p_datetrack_mode
6966 ,p_rslt_object_version_number => p_rslt_object_version_number);
6967 --
6968 end if; -- rqd_flag = 'Y'
6969 --
6970 p_pcp_actn_warning := l_pcp_actn_warning;
6971 if p_validate then
6972 raise hr_api.validate_enabled;
6973 end if;
6974 --
6975 if g_debug then
6976 hr_utility.set_location ('Leaving '||l_proc, 10);
6977 end if;
6978 --
6979
6980 exception
6981 --
6982 when hr_api.validate_enabled
6983 then
6984 rollback to determine_pcp_actn_items;
6985 --
6986 if g_debug then
6987 hr_utility.set_location(' Leaving:'||l_proc, 10);
6988 end if;
6989 --
6990 when others then
6991 if g_debug then
6992 hr_utility.set_location('Exception Raised '||l_proc, 10);
6993 end if;
6994
6995 p_rslt_object_version_number := l_rslt_object_version_number;
6996 p_suspend_flag := l_suspend_flag ;
6997 p_pcp_actn_warning := null ;
6998
6999 raise;
7000 --
7001 end determine_pcp_actn_items;
7002
7003
7004 -- ----------------------------------------------------------------------------
7005 -- |--------------------< process_pcp_dpnt_actn_items >------------------------|
7006 -- ----------------------------------------------------------------------------
7007 --
7008 procedure process_pcp_dpnt_actn_items
7009 (p_validate in boolean default FALSE
7010 ,p_prtt_enrt_rslt_id in number
7011 ,p_effective_date in date
7012 ,p_business_group_id in number
7013 ,p_datetrack_mode in varchar2 default hr_api.g_correction
7014 ,p_post_rslt_flag in varchar2 default 'Y'
7015 ,p_rslt_object_version_number in out nocopy number
7016 ,p_suspend_flag in out nocopy varchar2
7017 ,p_pcp_dpnt_actn_warning out nocopy boolean) is
7018 --
7019 l_proc varchar2(80);
7020
7021 l_rslt_object_version_number number(15);
7022 l_suspend_flag varchar2(20);
7023
7024
7025 --
7026 --this procedure determines whether the result correspoding to dependent
7027 -- designation has pcp_dpnt_dsgn_cd turned on.if it's on we need to create
7028 -- an action item and suspend the result during dependent designation.
7029 --
7030 l_pcp_dpnt_dsgn_cd varchar2(30) := null;
7031 l_elig_cvrd_dpnt_id ben_elig_cvrd_dpnt_f.elig_cvrd_dpnt_id%TYPE;
7032 l_pcp_dpnt_actn_warning boolean := FALSE;
7033
7034 cursor c_pcp_dpnt_cd_oipl is
7035 select cop.pcp_dpnt_dsgn_cd,
7036 ecd.elig_cvrd_dpnt_id
7037 from ben_prtt_enrt_rslt_f pen,
7038 ben_elig_cvrd_dpnt_f ecd,
7039 ben_oipl_f cop
7040 where cop.oipl_id = pen.oipl_id
7041 and pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
7042 and pen.prtt_enrt_rslt_id = ecd.prtt_enrt_rslt_id
7043 and ecd.cvg_strt_dt is not null
7044 and nvl(ecd.cvg_thru_dt,hr_api.g_eot) = hr_api.g_eot
7045 and pen.business_group_id = p_business_group_id
7046 and cop.business_group_id = p_business_group_id
7047 and ecd.business_group_id = p_business_group_id
7048 and p_effective_date between ecd.effective_start_date
7049 and ecd.effective_end_date
7050 and p_effective_date between cop.effective_start_date
7051 and cop.effective_end_date
7052 and p_effective_date between pen.effective_start_date
7053 and pen.effective_end_date
7054 and cop.pcp_dpnt_dsgn_cd is not null ;
7055 -- added the cop.pcp_dpnt_dsgn_cd is not null condition bug 1421978
7056 --
7057 cursor c_pcp_dpnt_cd is
7058 select pcp.pcp_dpnt_dsgn_cd ,
7059 ecd.elig_cvrd_dpnt_id
7060 from ben_prtt_enrt_rslt_f pen,
7061 ben_elig_cvrd_dpnt_f ecd,
7062 ben_pl_pcp pcp
7063 where pcp.pl_id = pen.pl_id
7064 and pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
7065 and pen.prtt_enrt_rslt_id = ecd.prtt_enrt_rslt_id
7066 and ecd.cvg_strt_dt is not null
7067 and nvl(ecd.cvg_thru_dt,hr_api.g_eot) = hr_api.g_eot
7068 and pen.business_group_id = p_business_group_id
7069 and pcp.business_group_id = p_business_group_id
7070 and p_effective_date between ecd.effective_start_date
7071 and ecd.effective_end_date
7072 and p_effective_date between pen.effective_start_date
7073 and pen.effective_end_date;
7074 --
7075 begin
7076 --
7077 g_debug := hr_utility.debug_enabled;
7078 if g_debug then
7079 l_proc := g_package||'.process_pcp_dpnt_actn_items';
7080 hr_utility.set_location ('Entering '||l_proc,10);
7081 end if;
7082 if g_debug then
7083 hr_utility.set_location ('Entering rslt id '||to_char(p_prtt_enrt_rslt_id),11);
7084 end if;
7085 --
7086 --
7087
7088 l_rslt_object_version_number := p_rslt_object_version_number ;
7089 l_suspend_flag := p_suspend_flag ;
7090
7091
7092
7093 -- Issue a savepoint if operating in validate only mode
7094 --
7095 savepoint process_pcp_dpnt_actn_items;
7096 --
7097
7098 open c_pcp_dpnt_cd_oipl;
7099 fetch c_pcp_dpnt_cd_oipl into l_pcp_dpnt_dsgn_cd,l_elig_cvrd_dpnt_id;
7100 if c_pcp_dpnt_cd_oipl%notfound then
7101 close c_pcp_dpnt_cd_oipl;
7102 open c_pcp_dpnt_cd;
7103 fetch c_pcp_dpnt_cd into l_pcp_dpnt_dsgn_cd,l_elig_cvrd_dpnt_id;
7104 if c_pcp_dpnt_cd%notfound then
7105 close c_pcp_dpnt_cd;
7106 if g_debug then
7107 hr_utility.set_location('pcp not required ' , 298);
7108 end if;
7109 return;
7110 else
7111 loop
7112 if g_debug then
7113 hr_utility.set_location('l_pcp_dpnt_dsgn_cd '||l_pcp_dpnt_dsgn_cd , 299);
7114 end if;
7115 if g_debug then
7116 hr_utility.set_location('l_elig_cvrd_dpnt_id '||l_elig_cvrd_dpnt_id, 299);
7117 end if;
7118 determine_pcp_dpnt_actn_items
7119 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
7120 ,p_elig_cvrd_dpnt_id => l_elig_cvrd_dpnt_id
7121 ,p_effective_date => p_effective_date
7122 ,p_business_group_id => p_business_group_id
7123 ,p_datetrack_mode => p_datetrack_mode
7124 ,p_post_rslt_flag => p_post_rslt_flag
7125 ,p_pcp_dpnt_dsgn_cd => l_pcp_dpnt_dsgn_cd
7126 ,p_rslt_object_version_number => p_rslt_object_version_number
7127 ,p_suspend_flag => p_suspend_flag
7128 ,p_pcp_dpnt_actn_warning => l_pcp_dpnt_actn_warning);
7129 --
7130 fetch c_pcp_dpnt_cd into l_pcp_dpnt_dsgn_cd,l_elig_cvrd_dpnt_id;
7131 exit when c_pcp_dpnt_cd%notfound ;
7132 end loop ;
7133 --
7134 close c_pcp_dpnt_cd;
7135 --
7136 end if;
7137 else
7138 if g_debug then
7139 hr_utility.set_location('l_pcp_dpnt_dsgn_cd '||l_pcp_dpnt_dsgn_cd , 399);
7140 end if;
7141 loop
7142 --
7143 determine_pcp_dpnt_actn_items
7144 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
7145 ,p_elig_cvrd_dpnt_id => l_elig_cvrd_dpnt_id
7146 ,p_effective_date => p_effective_date
7147 ,p_business_group_id => p_business_group_id
7148 ,p_datetrack_mode => p_datetrack_mode
7149 ,p_post_rslt_flag => p_post_rslt_flag
7150 ,p_pcp_dpnt_dsgn_cd => l_pcp_dpnt_dsgn_cd
7151 ,p_rslt_object_version_number => p_rslt_object_version_number
7152 ,p_suspend_flag => p_suspend_flag
7153 ,p_pcp_dpnt_actn_warning => l_pcp_dpnt_actn_warning);
7154 --
7155 fetch c_pcp_dpnt_cd_oipl into l_pcp_dpnt_dsgn_cd,l_elig_cvrd_dpnt_id;
7156 exit when c_pcp_dpnt_cd_oipl%notfound ;
7157 end loop;
7158 --
7159 close c_pcp_dpnt_cd_oipl;
7160 --
7161 end if;
7162 --
7163 p_pcp_dpnt_actn_warning := l_pcp_dpnt_actn_warning;
7164 --
7165 if p_validate then
7166 raise hr_api.validate_enabled;
7167 end if;
7168 --
7169 if g_debug then
7170 hr_utility.set_location ('Leaving '||l_proc, 10);
7171 end if;
7172 --
7173 exception
7174 --
7175 when hr_api.validate_enabled
7176 then
7177 rollback to process_pcp_dpnt_actn_items;
7178 --
7179 if g_debug then
7180 hr_utility.set_location(' Leaving:'||l_proc, 10);
7181 end if;
7182 --
7183 when others then
7184 if g_debug then
7185 hr_utility.set_location('Exception Raised '||l_proc, 10);
7186 end if;
7187
7188 p_rslt_object_version_number := l_rslt_object_version_number ;
7189 p_suspend_flag := l_suspend_flag ;
7190 p_pcp_dpnt_actn_warning := null ;
7191
7192 raise;
7193 --
7194 end process_pcp_dpnt_actn_items;
7195 --
7196 -- ----------------------------------------------------------------------------
7197 -- |--------------------< process_pcp_actn_items >------------------------|
7198 -- ----------------------------------------------------------------------------
7199 --
7200 procedure process_pcp_actn_items
7201 (p_validate in boolean default FALSE
7202 ,p_prtt_enrt_rslt_id in number
7203 ,p_effective_date in date
7204 ,p_business_group_id in number
7205 ,p_datetrack_mode in varchar2 default hr_api.g_correction
7206 ,p_post_rslt_flag in varchar2 default 'Y'
7207 ,p_rslt_object_version_number in out nocopy number
7208 ,p_suspend_flag in out nocopy varchar2
7209 ,p_pcp_actn_warning out nocopy boolean) is
7210 --
7211 l_proc varchar2(80);
7212
7213 l_rslt_object_version_number number(15);
7214 l_suspend_flag varchar2(20);
7215
7216 --
7217 -- this procedure determines if the plan in the result has pcp_dsgn_cd on
7218 -- if it's on we need to write an action item and suspend the result
7219 l_pcp_dsgn_cd varchar2(30) := null;
7220 l_pcp_actn_warning boolean := FALSE;
7221
7222 cursor c_pcp_cd_oipl is
7223 select cop.pcp_dsgn_cd
7224 from ben_prtt_enrt_rslt_f perf,
7225 ben_oipl_f cop
7226 where cop.oipl_id = perf.oipl_id
7227 and perf.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
7228 and perf.business_group_id = p_business_group_id
7229 and cop.business_group_id = p_business_group_id
7230 and p_effective_date between cop.effective_start_date
7231 and cop.effective_end_date
7232 and p_effective_date between perf.effective_start_date
7233 and perf.effective_end_date
7234 and cop.pcp_dsgn_cd is not null ;
7235 -- added the cop.pcp_dsgn_cd is not null condition bug 1421978
7236 cursor c_pcp_cd is
7237 select pcp.pcp_dsgn_cd
7238 from ben_prtt_enrt_rslt_f perf,
7239 ben_pl_pcp pcp
7240 where pcp.pl_id = perf.pl_id
7241 and perf.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
7242 and perf.business_group_id = p_business_group_id
7243 and pcp.business_group_id = p_business_group_id
7244 and p_effective_date between perf.effective_start_date
7245 and perf.effective_end_date;
7246 --
7247 begin
7248 --
7249 g_debug := hr_utility.debug_enabled;
7250 if g_debug then
7251 l_proc := g_package||'.process_pcp_actn_items';
7252 hr_utility.set_location ('Entering '||l_proc,10);
7253 end if;
7254 --
7255 l_rslt_object_version_number := p_rslt_object_version_number ;
7256 l_suspend_flag := p_suspend_flag ;
7257
7258 -- Issue a savepoint if operating in validate only mode
7259 --
7260 savepoint process_pcp_actn_items;
7261 --
7262 open c_pcp_cd_oipl;
7263 fetch c_pcp_cd_oipl into l_pcp_dsgn_cd;
7264 if c_pcp_cd_oipl%notfound then
7265 close c_pcp_cd_oipl;
7266 open c_pcp_cd;
7267 fetch c_pcp_cd into l_pcp_dsgn_cd;
7268 if c_pcp_cd%notfound then
7269 close c_pcp_cd;
7270 return;
7271 else
7272 close c_pcp_cd;
7273 if g_debug then
7274 hr_utility.set_location('l_pcp_dsgn_cd '||l_pcp_dsgn_cd , 198);
7275 end if;
7276 if g_debug then
7277 hr_utility.set_location('p_prtt_enrt_rslt_id '||p_prtt_enrt_rslt_id ,198);
7278 end if;
7279
7280 determine_pcp_actn_items
7281 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
7282 ,p_effective_date => p_effective_date
7283 ,p_business_group_id => p_business_group_id
7284 ,p_datetrack_mode => p_datetrack_mode
7285 ,p_post_rslt_flag => p_post_rslt_flag
7286 ,p_pcp_dsgn_cd => l_pcp_dsgn_cd
7287 ,p_rslt_object_version_number => p_rslt_object_version_number
7288 ,p_suspend_flag => p_suspend_flag
7289 ,p_pcp_actn_warning => l_pcp_actn_warning);
7290 end if;
7291 else
7292 close c_pcp_cd_oipl;
7293 if g_debug then
7294 hr_utility.set_location('l_pcp_dsgn_cd '||l_pcp_dsgn_cd , 199);
7295 end if;
7296 if g_debug then
7297 hr_utility.set_location('p_prtt_enrt_rslt_id '||p_prtt_enrt_rslt_id ,199);
7298 end if;
7299
7300 determine_pcp_actn_items
7301 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
7302 ,p_effective_date => p_effective_date
7303 ,p_business_group_id => p_business_group_id
7304 ,p_datetrack_mode => p_datetrack_mode
7305 ,p_post_rslt_flag => p_post_rslt_flag
7306 ,p_pcp_dsgn_cd => l_pcp_dsgn_cd
7307 ,p_rslt_object_version_number => p_rslt_object_version_number
7308 ,p_suspend_flag => p_suspend_flag
7309 ,p_pcp_actn_warning => l_pcp_actn_warning);
7310 end if;
7311 --
7312 p_pcp_actn_warning := l_pcp_actn_warning;
7313 --
7314 if p_validate then
7315 raise hr_api.validate_enabled;
7316 end if;
7317 --
7318 if g_debug then
7319 hr_utility.set_location ('Leaving '||l_proc, 10);
7320 end if;
7321 --
7322 exception
7323 --
7324 when hr_api.validate_enabled
7325 then
7326 rollback to process_pcp_actn_items;
7327 --
7328 if g_debug then
7329 hr_utility.set_location(' Leaving:'||l_proc, 10);
7330 end if;
7331 --
7332 when others then
7333 if g_debug then
7334 hr_utility.set_location('Exception Raised '||l_proc, 10);
7335 end if;
7336
7337 p_rslt_object_version_number := l_rslt_object_version_number ;
7338 p_suspend_flag := l_suspend_flag ;
7339 p_pcp_actn_warning := null;
7340
7341 raise;
7342 --
7343 end process_pcp_actn_items;
7344 --
7345 -- ----------------------------------------------------------------------------
7346 -- |---------------------------< check_bnf_ttee >-----------------------------|
7347 -- ----------------------------------------------------------------------------
7348 --
7349 function check_bnf_ttee
7350 (p_pl_bnf_id in number
7351 ,p_effective_date in date
7352 ,p_business_group_id in number)
7353 return boolean is
7354 --
7355 -- This routine will check if designated brneficiary is over the age 18 and
7356 -- will return FALSE if under 18 and TRUE if over 18
7357 --
7358 l_proc varchar2(80) ;
7359 --
7360 cursor c_bnf_age is
7361 select round
7362 (trunc
7363 (months_between(p_effective_date, per.date_of_birth))/ 12
7364 ) bnf_age,
7365 pb.ttee_person_id
7366 from per_all_people_f per,
7367 ben_pl_bnf_f pb
7368 where pb.pl_bnf_id = p_pl_bnf_id
7369 and per.person_id = pb.bnf_person_id
7370 and per.business_group_id = p_business_group_id
7371 and p_effective_date between per.effective_start_date
7372 and per.effective_end_date;
7373 --
7374 l_bnf_age c_bnf_age%rowtype;
7375 --
7376 --
7377 begin
7378 --
7379 if g_debug then
7380 l_proc := g_package||'.check_bnf_ttee';
7381 hr_utility.set_location ('Entering '||l_proc,10);
7382 end if;
7383 --
7384 open c_bnf_age;
7385 fetch c_bnf_age into l_bnf_age;
7386 close c_bnf_age;
7387 --
7388 if g_debug then
7389 hr_utility.set_location ('Leaving ' ||l_proc,10);
7390 end if;
7391 --
7392 if (l_bnf_age.bnf_age IS NOT NULL and
7393 l_bnf_age.bnf_age >= 18)
7394 OR
7395 (l_bnf_age.bnf_age is not null and
7396 l_bnf_age.bnf_age < 18 and
7397 l_bnf_age.ttee_person_id is not null) then
7398 return TRUE;
7399 elsif l_bnf_age.bnf_age is not null and
7400 l_bnf_age.bnf_age < 18 and
7401 l_bnf_age.ttee_person_id is null then
7402 return FALSE;
7403 end if;
7404 --
7405 exception
7406 when others then
7407 if g_debug then
7408 hr_utility.set_location('Exception Raised '||l_proc, 10);
7409 end if;
7410 raise;
7411 --
7412 end check_bnf_ttee;
7413 --
7414 -- ----------------------------------------------------------------------------
7415 -- |--------------------------< check_bnf_ctfn >------------------------------|
7416 -- ----------------------------------------------------------------------------
7417 --
7418 function check_bnf_ctfn
7419 (p_prtt_enrt_actn_id in number
7420 ,p_pl_bnf_id in number
7421 ,p_effective_date in date)
7422 return boolean is
7423 --
7424 -- This function checks for certifications for an enrollment result.
7425 -- Check if certifications were provided. For this beneficiary check
7426 -- if the bnf_ctfn_rqd_flag is 'Y' then write action item
7427 -- if the bnf_ctfn_recd_dt IS NULL. The bnf_ctfn_recd_dt is filled in via
7428 -- a form interface.
7429 --
7430 l_required number;
7431 l_optional number;
7432 l_open_required number;
7433 l_open_optional number;
7434 l_return boolean;
7435 --
7436 l_proc varchar2(80) ;
7437 --
7438 begin
7439 --
7440 g_debug := hr_utility.debug_enabled;
7441 if g_debug then
7442 l_proc := g_package||'.check_bnf_ctfn';
7443 hr_utility.set_location ('Entering '||l_proc,10);
7444 end if;
7445 --
7446 get_ctfn_count
7447 (p_prtt_enrt_actn_id => p_prtt_enrt_actn_id
7448 ,p_pl_bnf_id => p_pl_bnf_id
7449 ,p_effective_date => p_effective_date
7450 ,p_required_count => l_required
7451 ,p_optional_count => l_optional
7452 ,p_open_required_count => l_open_required
7453 ,p_open_optional_count => l_open_optional);
7454 --
7455 l_return := check_ctfn(p_required_count => l_required
7456 ,p_optional_count => l_optional
7457 ,p_open_required_count => l_open_required
7458 ,p_open_optional_count => l_open_optional);
7459 --
7460 if g_debug then
7461 hr_utility.set_location ('Leaving '||l_proc,10);
7462 end if;
7463 --
7464 return l_return;
7465 --
7466 exception
7467 --
7468 when others then
7469 if g_debug then
7470 hr_utility.set_location('Exception Raised '||l_proc, 10);
7471 end if;
7472 raise;
7473 --
7474 end check_bnf_ctfn;
7475 --
7476 -- ----------------------------------------------------------------------------
7477 -- |-------------------< check_bnf_actn_item_dfnd >----------------------------|
7478 -- ----------------------------------------------------------------------------
7479 --
7480 function check_bnf_actn_item_dfnd
7481 (p_pl_id number
7482 ,p_actn_type_cd varchar2
7483 ,p_business_group_id number
7484 ,p_effective_date date)
7485 return boolean is
7486 --
7487 -- Bug 1169240 - checking the popl_actn_typ table to see if action item defined
7488 -- This check is being done because the flags in ben_pl_f table are not getting
7489 -- updated when enrollment action items are attached to a plan . This was noticed
7490 -- for beneficiary related action types.
7491 --
7492 cursor c_bnf_actn_item is
7493 select null
7494 from ben_popl_actn_typ_f pat,
7495 ben_actn_typ eat
7496 where pat.pl_id = p_pl_id
7497 and pat.actn_typ_id = eat.actn_typ_id
7498 and eat.type_cd = p_actn_type_cd
7499 and pat.business_group_id = p_business_group_id
7500 and p_effective_date between
7501 pat.effective_start_date and pat.effective_end_date ;
7502 --
7503 l_dummy char ;
7504 l_exists boolean ;
7505 --
7506 l_proc varchar2(80) ;
7507 --
7508 begin
7509 --
7510 if g_debug then
7511 l_proc := g_package||'.check_bnf_actn_item_dfnd' ;
7512 hr_utility.set_location ('Entering '||l_proc,10);
7513 end if;
7514 --
7515 open c_bnf_actn_item ;
7516 fetch c_bnf_actn_item into l_dummy;
7517 --
7518 if c_bnf_actn_item%FOUND then
7519 --
7520 l_exists := TRUE;
7521 --
7522 else
7523 --
7524 l_exists := FALSE;
7525 --
7526 end if;
7527 --
7528 close c_bnf_actn_item;
7529 --
7530 if g_debug then
7531 hr_utility.set_location ('Leaving '||l_proc,10);
7532 end if;
7533 --
7534 return l_exists;
7535 --
7536 end check_bnf_actn_item_dfnd ;
7537 --
7538 -- ----------------------------------------------------------------------------
7539 -- |----------------------< write_new_bnf_ctfn_item >-------------------------|
7540 -- ----------------------------------------------------------------------------
7541 --
7542 procedure write_new_bnf_ctfn_item
7543 (p_pl_bnf_id in number
7544 ,p_prtt_enrt_actn_id in number
7545 ,p_bnf_ctfn_typ_cd in varchar2
7546 ,p_bnf_ctfn_rqd_flag in varchar2
7547 ,p_effective_date in date
7548 ,p_business_group_id in number
7549 ,p_object_version_number out nocopy number
7550 ,p_pl_bnf_ctfn_prvdd_id out nocopy number) is
7551 --
7552 -- this procedure writes a beneficiary certification to
7553 -- ben_pl_bnf_ctfn_prvdd_f
7554 --
7555 l_proc varchar2(80);
7556 l_effective_start_date date;
7557 l_effective_end_date date;
7558 --
7559 begin
7560 --
7561 if g_debug then
7562 l_proc := g_package||'.write_new_bnf_ctfn_item';
7563 hr_utility.set_location ('Entering '||l_proc,10);
7564 end if;
7565 --
7566 -- write a new record for each beneficiary certification item
7567 --
7568 ben_pl_bnf_ctfn_prvdd_api.create_pl_bnf_ctfn_prvdd
7569 (p_pl_bnf_id => p_pl_bnf_id
7570 ,p_prtt_enrt_actn_id => p_prtt_enrt_actn_id
7571 ,p_bnf_ctfn_typ_cd => p_bnf_ctfn_typ_cd
7572 ,p_bnf_ctfn_rqd_flag => p_bnf_ctfn_rqd_flag
7573 ,p_effective_date => p_effective_date
7574 ,p_business_group_id => p_business_group_id
7575 ,p_object_version_number => p_object_version_number
7576 ,p_effective_start_date => l_effective_start_date
7577 ,p_effective_end_date => l_effective_end_date
7578 ,p_pl_bnf_ctfn_prvdd_id => p_pl_bnf_ctfn_prvdd_id);
7579 --
7580 if g_debug then
7581 hr_utility.set_location ('Leaving '||l_proc, 10);
7582 end if;
7583 --
7584 exception
7585 /* we could have duplicates already here from prior run */
7586 when others then
7587 if g_debug then
7588 hr_utility.set_location('Exception Raised '||l_proc, 10);
7589 end if;
7590
7591 p_object_version_number := null ;
7592 p_pl_bnf_ctfn_prvdd_id := null;
7593
7594 raise;
7595 --
7596 end write_new_bnf_ctfn_item;
7597 --
7598 -- ----------------------------------------------------------------------------
7599 -- |-------------------< determine_bnf_miss_actn_items >----------------------|
7600 -- ----------------------------------------------------------------------------
7601 --
7602 procedure determine_bnf_miss_actn_items
7603 (p_prtt_enrt_rslt_id in number
7604 ,p_effective_date in date
7605 ,p_business_group_id in number
7606 ,p_datetrack_mode in varchar2 default hr_api.g_correction
7607 ,p_post_rslt_flag in varchar2 default 'Y'
7608 ,p_rslt_object_version_number in out nocopy number
7609 ,p_bnf_actn_warning out nocopy boolean) is
7610 --
7611 -- This procedure determines if a designated beneficiary has missing info like
7612 -- DOB, SSN, ADRS, CTFN, TTEE that is required to complete an enrollment and
7613 -- writes action items if required data is missing.
7614 --
7615 l_proc varchar2(80) ;
7616 --
7617 l_bnf_dsgn_cd varchar2(30);
7618 l_rqd_data_found boolean;
7619 l_prtt_enrt_ctfn_prvdd_id number;
7620 l_outputs ff_exec.outputs_t;
7621 l_bnf_actn_warning boolean := FALSE;
7622 l_actn_typ_id number(15);
7623 l_prtt_enrt_actn_id number(15);
7624 l_cmpltd_dt date;
7625 l_object_version_number number(15);
7626 l_pl_bnf_ctfn_prvdd_id number;
7627 l_dob_found boolean;
7628 l_dummy varchar2(30);
7629 l_ctfn_defined boolean := FALSE;
7630 l_person_id number;
7631 l_rslt_object_version_number number(15) ;
7632
7633 --
7634 --
7635 -- Cursor to retrieve certifications defined for a plan and for the bnf
7636 -- person's contact_type.
7637 --
7638 cursor c_ctfns(v_bnf_person_id number, v_pl_id number, v_person_id number) is
7639 select pl.lack_ctfn_sspnd_enrt_flag ctflag,
7640 pl.bnf_ctfn_typ_cd ctcvgcd,
7641 pl.ctfn_rqd_when_rl ctrrl,
7642 pl.rqd_flag rqd_flag,
7643 pl.rlshp_typ_cd ctrlshcd,
7644 pl.bnf_typ_cd, pl.pl_id
7645 from ben_pl_bnf_ctfn_f pl
7646 where pl.bnf_ctfn_typ_cd <> 'NSC'
7647 and pl.pl_id = v_pl_id
7648 and (pl.rlshp_typ_cd is null or
7649 pl.rlshp_typ_cd in (select contact_type
7650 from per_contact_relationships
7651 where contact_person_id = v_bnf_person_id
7652 and person_id = v_person_id
7653 and business_group_id = p_business_group_id
7654 and p_effective_date
7655 between nvl(date_start, p_effective_date)
7656 and nvl(date_end, hr_api.g_eot)))
7657 and pl.business_group_id = p_business_group_id
7658 and p_effective_date between
7659 pl.effective_start_date and pl.effective_end_date;
7660 --
7661 cursor c_ctfns_exist(v_pl_bnf_id number) is
7662 select 's'
7663 from ben_pl_bnf_ctfn_prvdd_f
7664 where pl_bnf_id = v_pl_bnf_id
7665 and p_effective_date between effective_start_date
7666 and effective_end_date
7667 and business_group_id = p_business_group_id;
7668 --
7669 cursor c_dsgn_bnf is
7670 select pbd.pl_bnf_id,
7671 pbd.bnf_person_id
7672 from ben_pl_bnf_f pbd,
7673 ben_per_in_ler pil
7674 where pbd.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
7675 and pbd.dsgn_strt_dt is not null
7676 and nvl(pbd.dsgn_thru_dt, hr_api.g_eot) = hr_api.g_eot
7677 and pbd.business_group_id = p_business_group_id
7678 and p_effective_date between pbd.effective_start_date
7679 and pbd.effective_end_date
7680 and pil.per_in_ler_id=pbd.per_in_ler_id
7681 and pil.business_group_id=p_business_group_id
7682 and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT')
7683 -- Check fo DOB, SSN, ADDRESS only for person beneficiaries
7684 -- and not for Organization Beneficiaries
7685 and pbd.bnf_person_id is not null; -- Bug : 3854556
7686 --
7687 cursor c_ctfn_defined(v_bnf_person_id number,
7688 v_person_id number,
7689 p_pl_id number) is
7690 select 's'
7691 from ben_pl_bnf_ctfn_f
7692 where bnf_ctfn_typ_cd <> 'NSC'
7693 and pl_id = p_pl_id
7694 and (bnf_typ_cd is null or bnf_typ_cd = 'P')
7695 and (rlshp_typ_cd is null
7696 or
7697 rlshp_typ_cd in (select contact_type
7698 from per_contact_relationships
7699 where contact_person_id = v_bnf_person_id
7700 and person_id = v_person_id
7701 and business_group_id = p_business_group_id
7702 and p_effective_date
7703 between nvl(date_start, p_effective_date)
7704 and nvl(date_end, hr_api.g_eot)))
7705 and business_group_id = p_business_group_id
7706 and p_effective_date between effective_start_date
7707 and effective_end_date;
7708 cursor c_person_id is
7709 select person_id,
7710 pl_id
7711 from ben_prtt_enrt_rslt_f
7712 where prtt_enrt_rslt_id = p_prtt_enrt_rslt_id;
7713 --
7714 l_bnf_actn_typ_dfnd boolean; -- bug 1169240
7715 l_rqd_flag varchar2(1);
7716 l_pl_id number;
7717 --
7718 -- start bug 5667528
7719 cursor c_pen_info is
7720 SELECT pen.pgm_id, pen.pl_id, pen.pl_typ_id, pen.oipl_id, pen.ler_id,
7721 pen.person_id, pen.business_group_id
7722 FROM ben_prtt_enrt_rslt_f pen
7723 WHERE pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
7724 AND p_effective_date BETWEEN pen.effective_start_date
7725 AND pen.effective_end_date;
7726 --
7727 pen_info_rec c_pen_info%ROWTYPE;
7728 --
7729 cursor c_asg(v_person_id in number) is
7730 SELECT asg.assignment_id, asg.organization_id
7731 FROM per_all_assignments_f asg
7732 WHERE asg.person_id = v_person_id
7733 AND asg.assignment_type <> 'C'
7734 AND asg.primary_flag = 'Y'
7735 AND p_effective_date BETWEEN asg.effective_start_date
7736 AND asg.effective_end_date;
7737 asg_rec c_asg%ROWTYPE;
7738 --
7739 cursor c_opt (v_oipl_id in number) is
7740 SELECT opt_id
7741 FROM ben_oipl_f oipl
7742 WHERE oipl.oipl_id = v_oipl_id
7743 AND oipl.business_group_id = p_business_group_id
7744 AND p_effective_date BETWEEN oipl.effective_start_date
7745 AND oipl.effective_end_date;
7746 opt_rec c_opt%ROWTYPE;
7747 --
7748 CURSOR c_curr_ovn_of_actn (c_prtt_enrt_actn_id NUMBER)
7749 IS
7750 SELECT object_version_number
7751 FROM ben_prtt_enrt_actn_f
7752 WHERE prtt_enrt_actn_id = c_prtt_enrt_actn_id
7753 AND business_group_id = p_business_group_id
7754 AND p_effective_date BETWEEN effective_start_date
7755 AND effective_end_date;
7756
7757 cursor c_act_name (v_actn_typ_id in number) is
7758 select tl.name actn_typ_name
7759 from ben_actn_typ typ,
7760 ben_actn_typ_tl tl
7761 where v_actn_typ_id = typ.actn_typ_id
7762 and typ.actn_typ_id = tl.actn_typ_id
7763 and tl.language = userenv('lang')
7764 and typ.type_cd <> 'BNF'
7765 and typ.type_cd like 'BNF%'
7766 and typ.business_group_id = p_business_group_id;
7767 --
7768 CURSOR c_plan_name(v_plan_id in number)
7769 IS
7770 SELECT pl.NAME
7771 FROM ben_pl_f pl
7772 WHERE pl.pl_id = v_plan_id
7773 AND p_effective_date BETWEEN pl.effective_start_date
7774 AND pl.effective_end_date;
7775
7776 plan_name_rec c_plan_name%ROWTYPE;
7777 l_act_name ben_actn_typ_tl.name%TYPE;
7778 l_message_name fnd_new_messages.message_name%TYPE := 'BEN_94108_BNF_ACT_ITEM';
7779 l_write_ctfn BOOLEAN;
7780 l_ff_ctfn_exits BOOLEAN;
7781 --
7782 -- end bug 5667528
7783 begin
7784 --
7785
7786 if g_debug then
7787 l_proc := g_package||'.determine_bnf_miss_actn_items';
7788 hr_utility.set_location ('Entering '||l_proc,10);
7789 end if;
7790 --
7791 l_rslt_object_version_number := p_rslt_object_version_number;
7792 --
7793 open c_person_id;
7794 fetch c_person_id into l_person_id, l_pl_id;
7795 close c_person_id;
7796 --
7797 -- get data from pl table.
7798 open g_bnf_pl(p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
7799 ,p_effective_date => p_effective_date);
7800 fetch g_bnf_pl into g_bnf_pl_rec;
7801 close g_bnf_pl;
7802 --
7803 for l_dsgn_bnf in c_dsgn_bnf loop
7804 --
7805 -- date of birth action item
7806 --
7807 if g_debug then
7808 hr_utility.set_location('DOB action item ' || l_proc, 20);
7809 end if;
7810 --
7811 l_actn_typ_id := get_actn_typ_id
7812 (p_type_cd => 'BNFDOB'
7813 ,p_business_group_id => p_business_group_id);
7814 --
7815 -- bug 1169240
7816 --
7817 l_bnf_actn_typ_dfnd := check_bnf_actn_item_dfnd
7818 (p_pl_id => g_bnf_pl_rec.pl_id
7819 ,p_actn_type_cd => 'BNFDOB'
7820 ,p_business_group_id => p_business_group_id
7821 ,p_effective_date => p_effective_date);
7822 --
7823 -- end bug 1169240
7824 --
7825 get_prtt_enrt_actn_id
7826 (p_actn_typ_id => l_actn_typ_id
7827 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
7828 ,p_pl_bnf_id => l_dsgn_bnf.pl_bnf_id
7829 ,p_effective_date => p_effective_date
7830 ,p_business_group_id => p_business_group_id
7831 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
7832 ,p_cmpltd_dt => l_cmpltd_dt
7833 ,p_object_version_number => l_object_version_number);
7834 --
7835 if g_bnf_pl_rec.susp_if_bnf_dob_nt_prv_cd is not null or l_bnf_actn_typ_dfnd then --date of birth is required for plan
7836 --
7837 if g_debug then
7838 hr_utility.set_location('DOB rqd flag is Y', 10);
7839 end if;
7840 --
7841 --
7842 -- check if person has a date of birth entry
7843 --
7844 l_rqd_data_found := check_dob
7845 (p_person_id => l_dsgn_bnf.bnf_person_id
7846 ,p_effective_date => p_effective_date
7847 ,p_business_group_id => p_business_group_id);
7848 --
7849 if l_rqd_data_found = FALSE then
7850 l_bnf_actn_warning := TRUE;
7851 l_dob_found := FALSE;
7852 elsif l_rqd_data_found = TRUE then
7853 l_dob_found := TRUE;
7854 end if;
7855 --
7856 if g_bnf_pl_rec.susp_if_bnf_dob_nt_prv_cd = 'RQDS' then
7857 l_rqd_flag := 'Y';
7858 else
7859 l_rqd_flag := 'N';
7860 end if;
7861 --
7862 process_action_item
7863 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
7864 ,p_actn_typ_id => l_actn_typ_id
7865 ,p_cmpltd_dt => l_cmpltd_dt
7866 ,p_object_version_number => l_object_version_number
7867 ,p_effective_date => p_effective_date
7868 ,p_rqd_data_found => l_rqd_data_found
7869 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
7870 ,p_pl_bnf_id => l_dsgn_bnf.pl_bnf_id
7871 ,p_rqd_flag => l_rqd_flag --g_bnf_pl_rec.rqd
7872 ,p_post_rslt_flag => p_post_rslt_flag
7873 ,p_business_group_id => p_business_group_id
7874 ,p_datetrack_mode => p_datetrack_mode
7875 ,p_rslt_object_version_number => p_rslt_object_version_number);
7876 --
7877 else
7878 --
7879 if g_debug then
7880 hr_utility.set_location('DOB rqd flag is N', 10);
7881 end if;
7882 --
7883 -- bnf_dob_rqd_flag is 'N';
7884 -- if date_track mode is updating and designation at plan level
7885 -- delete action type of type BNFDOB
7886 --
7887 if l_prtt_enrt_actn_id IS NOT NULL and p_datetrack_mode = DTMODE_DELETE then
7888 --
7889 delete_action_item
7890 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
7891 ,p_object_version_number => l_object_version_number
7892 ,p_business_group_id => p_business_group_id
7893 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
7894 ,p_rslt_object_version_number => p_rslt_object_version_number
7895 ,p_effective_date => p_effective_date
7896 ,p_datetrack_mode => p_datetrack_mode
7897 ,p_post_rslt_flag => p_post_rslt_flag);
7898 --
7899 else
7900 NULL; -- nothing to do at this time.
7901 end if;
7902 --
7903 end if; -- bnf_dob_rqd_flag
7904 --
7905 -- legislative code (social security number/national identifier) action item
7906 --
7907 if g_debug then
7908 hr_utility.set_location('SSN action item ' || l_proc, 35);
7909 end if;
7910 --
7911 l_actn_typ_id := get_actn_typ_id
7912 (p_type_cd => 'BNFSSN'
7913 ,p_business_group_id => p_business_group_id);
7914 --
7915 -- bug 1169240
7916 --
7917 l_bnf_actn_typ_dfnd := check_bnf_actn_item_dfnd
7918 (p_pl_id => g_bnf_pl_rec.pl_id
7919 ,p_actn_type_cd => 'BNFSSN'
7920 ,p_business_group_id => p_business_group_id
7921 ,p_effective_date => p_effective_date);
7922 --
7923 -- end bug 1169240
7924 --
7925 get_prtt_enrt_actn_id
7926 (p_actn_typ_id => l_actn_typ_id
7927 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
7928 ,p_effective_date => p_effective_date
7929 ,p_business_group_id => p_business_group_id
7930 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
7931 ,p_pl_bnf_id => l_dsgn_bnf.pl_bnf_id
7932 ,p_cmpltd_dt => l_cmpltd_dt
7933 ,p_object_version_number => l_object_version_number);
7934 --
7935 if g_bnf_pl_rec.susp_if_bnf_ssn_nt_prv_cd is not null or l_bnf_actn_typ_dfnd then --legislative id is rqd for plan
7936 --
7937 if g_debug then
7938 hr_utility.set_location('SSN rqd flag is Y', 10);
7939 end if;
7940 --
7941 -- check if person has a national identifier entry
7942 --
7943 l_rqd_data_found := check_legid
7944 (p_person_id => l_dsgn_bnf.bnf_person_id
7945 ,p_effective_date => p_effective_date
7946 ,p_business_group_id => p_business_group_id);
7947 --
7948 if l_rqd_data_found = FALSE then
7949 l_bnf_actn_warning := TRUE;
7950 end if;
7951 --
7952 if g_bnf_pl_rec.susp_if_bnf_ssn_nt_prv_cd = 'RQDS' then
7953 l_rqd_flag := 'Y';
7954 else
7955 l_rqd_flag := 'N';
7956 end if;
7957 --
7958 process_action_item
7959 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
7960 ,p_actn_typ_id => l_actn_typ_id
7961 ,p_cmpltd_dt => l_cmpltd_dt
7962 ,p_object_version_number => l_object_version_number
7963 ,p_effective_date => p_effective_date
7964 ,p_rqd_data_found => l_rqd_data_found
7965 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
7966 ,p_pl_bnf_id => l_dsgn_bnf.pl_bnf_id
7967 ,p_rqd_flag => l_rqd_flag --rqd
7968 ,p_post_rslt_flag => p_post_rslt_flag
7969 ,p_business_group_id => p_business_group_id
7970 ,p_datetrack_mode => p_datetrack_mode
7971 ,p_rslt_object_version_number => p_rslt_object_version_number);
7972 --
7973 else
7974 --
7975 if g_debug then
7976 hr_utility.set_location('SSN rqd flag is N', 10);
7977 end if;
7978 --
7979 -- bnf_legv_id_rqd_flag is 'N'
7980 -- if date_track mode is updating and designation at plan level
7981 -- delete action type of type BNFSSN.
7982 --
7983 if l_prtt_enrt_actn_id IS NOT NULL and p_datetrack_mode = DTMODE_DELETE then
7984 --
7985 delete_action_item
7986 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
7987 ,p_object_version_number => l_object_version_number
7988 ,p_business_group_id => p_business_group_id
7989 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
7990 ,p_rslt_object_version_number => p_rslt_object_version_number
7991 ,p_effective_date => p_effective_date
7992 ,p_datetrack_mode => p_datetrack_mode
7993 ,p_post_rslt_flag => p_post_rslt_flag);
7994 --
7995 else
7996 NULL; -- nothing to do at this time.
7997 end if;
7998 --
7999 end if; -- bnf_legv_id_rqd_flag
8000 --
8001 -- address action item
8002 --
8003 l_actn_typ_id := get_actn_typ_id
8004 (p_type_cd => 'BNFADDR'
8005 ,p_business_group_id => p_business_group_id);
8006 --
8007 -- bug 1169240
8008 --
8009 l_bnf_actn_typ_dfnd := check_bnf_actn_item_dfnd
8010 (p_pl_id => g_bnf_pl_rec.pl_id
8011 ,p_actn_type_cd => 'BNFADDR'
8012 ,p_business_group_id => p_business_group_id
8013 ,p_effective_date => p_effective_date);
8014 --
8015 -- end bug 1169240
8016 --
8017 get_prtt_enrt_actn_id
8018 (p_actn_typ_id => l_actn_typ_id
8019 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8020 ,p_pl_bnf_id => l_dsgn_bnf.pl_bnf_id
8021 ,p_effective_date => p_effective_date
8022 ,p_business_group_id => p_business_group_id
8023 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
8024 ,p_cmpltd_dt => l_cmpltd_dt
8025 ,p_object_version_number => l_object_version_number);
8026 --
8027 if g_bnf_pl_rec.susp_if_bnf_adr_nt_prv_cd is not null or l_bnf_actn_typ_dfnd then -- address is required for plan
8028 --
8029 if g_debug then
8030 hr_utility.set_location('ADDR rqd flag is Y', 10);
8031 end if;
8032 --
8033 -- check if person has an address
8034 --
8035 l_rqd_data_found := check_adrs
8036 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8037 ,p_dpnt_bnf_person_id => l_dsgn_bnf.bnf_person_id
8038 ,p_effective_date => p_effective_date
8039 ,p_business_group_id => p_business_group_id);
8040 --
8041 if l_rqd_data_found = FALSE then
8042 l_bnf_actn_warning := TRUE;
8043 end if;
8044 --
8045 if g_bnf_pl_rec.susp_if_bnf_adr_nt_prv_cd = 'RQDS' then
8046 l_rqd_flag := 'Y';
8047 else
8048 l_rqd_flag := 'N';
8049 end if;
8050 --
8051 process_action_item
8052 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
8053 ,p_actn_typ_id => l_actn_typ_id
8054 ,p_cmpltd_dt => l_cmpltd_dt
8055 ,p_object_version_number => l_object_version_number
8056 ,p_effective_date => p_effective_date
8057 ,p_rqd_data_found => l_rqd_data_found
8058 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8059 ,p_pl_bnf_id => l_dsgn_bnf.pl_bnf_id
8060 ,p_rqd_flag => l_rqd_flag --g_bnf_pl_rec.rqd
8061 ,p_post_rslt_flag => p_post_rslt_flag
8062 ,p_business_group_id => p_business_group_id
8063 ,p_datetrack_mode => p_datetrack_mode
8064 ,p_rslt_object_version_number => p_rslt_object_version_number);
8065 --
8066 else
8067 --
8068 if g_debug then
8069 hr_utility.set_location('ADDR rqd flag is N', 10);
8070 end if;
8071 --
8072 -- bnf_adrs_rqd_flag is 'N'
8073 -- if date_track mode is updating and designation at plan level
8074 -- delete action type of type BNFADDR.
8075 --
8076 if l_prtt_enrt_actn_id IS NOT NULL and p_datetrack_mode = DTMODE_DELETE then
8077 --
8078 delete_action_item
8079 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
8080 ,p_object_version_number => l_object_version_number
8081 ,p_business_group_id => p_business_group_id
8082 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8083 ,p_rslt_object_version_number => p_rslt_object_version_number
8084 ,p_effective_date => p_effective_date
8085 ,p_datetrack_mode => p_datetrack_mode
8086 ,p_post_rslt_flag => p_post_rslt_flag);
8087 --
8088 else
8089 NULL; -- nothing to do at this time.
8090 end if;
8091 --
8092 end if; -- bnf_adrs_rqd_flag
8093 --
8094 -- trustee action item
8095 --
8096 l_actn_typ_id := get_actn_typ_id
8097 (p_type_cd => 'BNFTTEE'
8098 ,p_business_group_id => p_business_group_id);
8099 --
8100 -- bug 1169240
8101 --
8102 l_bnf_actn_typ_dfnd := check_bnf_actn_item_dfnd
8103 (p_pl_id => g_bnf_pl_rec.pl_id
8104 ,p_actn_type_cd => 'BNFTTEE'
8105 ,p_business_group_id => p_business_group_id
8106 ,p_effective_date => p_effective_date);
8107 --
8108 -- end bug 1169240
8109 --
8110 get_prtt_enrt_actn_id
8111 (p_actn_typ_id => l_actn_typ_id
8112 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8113 ,p_pl_bnf_id => l_dsgn_bnf.pl_bnf_id
8114 ,p_effective_date => p_effective_date
8115 ,p_business_group_id => p_business_group_id
8116 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
8117 ,p_cmpltd_dt => l_cmpltd_dt
8118 ,p_object_version_number => l_object_version_number);
8119 --
8120 -- Check the trustee action item only if the DOB of beneficiary is present
8121 --
8122 if ( g_bnf_pl_rec.bnf_dsge_mnr_ttee_rqd_flag = 'Y' or l_bnf_actn_typ_dfnd ) and
8123 l_dob_found = TRUE then
8124 --
8125 if g_debug then
8126 hr_utility.set_location('TTEE rqd flag is Y and DOB found', 10);
8127 end if;
8128 --
8129 --
8130 -- check if the designated beneficiary is over age of 18
8131 --
8132 l_rqd_data_found := check_bnf_ttee
8133 (p_pl_bnf_id => l_dsgn_bnf.pl_bnf_id
8134 ,p_effective_date => p_effective_date
8135 ,p_business_group_id => p_business_group_id);
8136 --
8137 if l_rqd_data_found = FALSE then
8138 -- designated beneficiary is a minor
8139 l_bnf_actn_warning := TRUE;
8140 --
8141 end if;
8142 --
8143 process_action_item
8144 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
8145 ,p_actn_typ_id => l_actn_typ_id
8146 ,p_cmpltd_dt => l_cmpltd_dt
8147 ,p_object_version_number => l_object_version_number
8148 ,p_effective_date => p_effective_date
8149 ,p_rqd_data_found => l_rqd_data_found
8150 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8151 ,p_pl_bnf_id => l_dsgn_bnf.pl_bnf_id
8152 ,p_rqd_flag => g_bnf_pl_rec.rqd
8153 ,p_post_rslt_flag => p_post_rslt_flag
8154 ,p_business_group_id => p_business_group_id
8155 ,p_datetrack_mode => p_datetrack_mode
8156 ,p_rslt_object_version_number => p_rslt_object_version_number);
8157 --
8158 else
8159 --
8160 if g_debug then
8161 hr_utility.set_location('TTEE rqd flag is N or DOB not found', 10);
8162 end if;
8163 --
8164 -- bnf_dsge_mnr_ttee_rqd_flag is 'N'
8165 -- if date_track mode is updating and designation at plan level
8166 -- delete action type of type BNFTTEE.
8167 --
8168 if l_prtt_enrt_actn_id IS NOT NULL and p_datetrack_mode = DTMODE_DELETE then
8169 --
8170 delete_action_item
8171 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
8172 ,p_object_version_number => l_object_version_number
8173 ,p_business_group_id => p_business_group_id
8174 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8175 ,p_rslt_object_version_number => p_rslt_object_version_number
8176 ,p_effective_date => p_effective_date
8177 ,p_datetrack_mode => p_datetrack_mode
8178 ,p_post_rslt_flag => p_post_rslt_flag);
8179 --
8180 else
8181 NULL; -- nothing to do at this time.
8182 end if;
8183 --
8184 end if; -- bnf_dsge_mnr_ttee_rqd_flag
8185 --
8186 --
8187 -- certification action item
8188 --
8189 l_actn_typ_id := get_actn_typ_id
8190 (p_type_cd => 'BNFCTFN'
8191 ,p_business_group_id => p_business_group_id);
8192 --
8193 -- bug 1169240
8194 --
8195 l_bnf_actn_typ_dfnd := check_bnf_actn_item_dfnd
8196 (p_pl_id => g_bnf_pl_rec.pl_id
8197 ,p_actn_type_cd => 'BNFCTFN'
8198 ,p_business_group_id => p_business_group_id
8199 ,p_effective_date => p_effective_date);
8200 --
8201 -- end bug 1169240
8202 --
8203 get_prtt_enrt_actn_id
8204 (p_actn_typ_id => l_actn_typ_id
8205 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8206 ,p_pl_bnf_id => l_dsgn_bnf.pl_bnf_id
8207 ,p_effective_date => p_effective_date
8208 ,p_business_group_id => p_business_group_id
8209 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
8210 ,p_cmpltd_dt => l_cmpltd_dt
8211 ,p_object_version_number => l_object_version_number);
8212 --
8213 -- ******************************************************
8214 -- ****************Very Important************************
8215 -- The flag here says Beneficiary Certification Required,
8216 -- but in the form it says the opposite, No Ctfn Required.
8217 -- The name of this flag needs to be changed, so till this
8218 -- happens bear with the name and assume it to be something
8219 -- "bnf_no_ctfn_rqd_flag" (Column re-naming).
8220 -- *******************************************************
8221 --
8222 if g_bnf_pl_rec.bnf_ctfn_rqd_flag = 'N' or l_bnf_actn_typ_dfnd then
8223 --
8224 if g_debug then
8225 hr_utility.set_location('Ctfn rqd flag is N', 10);
8226 end if;
8227 --
8228 -- Certifications are required for the plan.
8229 -- Check if there are any certifications defined for the plan that are
8230 -- not of the Notarized Spousal Consent (NSC) type.
8231 --
8232 open c_ctfn_defined(l_dsgn_bnf.bnf_person_id,l_person_id, l_pl_id);
8233 fetch c_ctfn_defined into l_dummy;
8234 --
8235 if c_ctfn_defined%found then
8236 l_ctfn_defined := TRUE;
8237 else
8238 l_ctfn_defined := FALSE;
8239 end if;
8240 --
8241 close c_ctfn_defined;
8242 --
8243 -- If certifications were defined, then check to see if all the proper
8244 -- certifications were provided for the bnf person.
8245 --
8246 if l_ctfn_defined = TRUE then
8247 --
8248 if g_debug then
8249 hr_utility.set_location('Certifications defined', 10);
8250 end if;
8251 --
8252 l_rqd_data_found := check_bnf_ctfn
8253 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
8254 ,p_pl_bnf_id => l_dsgn_bnf.pl_bnf_id
8255 ,p_effective_date => p_effective_date);
8256 --
8257 if l_rqd_data_found = FALSE then
8258 l_bnf_actn_warning := TRUE;
8259 end if;
8260 --
8261 process_action_item
8262 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
8263 ,p_actn_typ_id => l_actn_typ_id
8264 ,p_cmpltd_dt => l_cmpltd_dt
8265 ,p_object_version_number => l_object_version_number
8266 ,p_effective_date => p_effective_date
8267 ,p_rqd_data_found => l_rqd_data_found
8268 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8269 ,p_pl_bnf_id => l_dsgn_bnf.pl_bnf_id
8270 ,p_rqd_flag => g_bnf_pl_rec.susp_if_ctfn_not_bnf_flag
8271 ,p_post_rslt_flag => p_post_rslt_flag
8272 ,p_business_group_id => p_business_group_id
8273 ,p_datetrack_mode => p_datetrack_mode
8274 ,p_rslt_object_version_number => p_rslt_object_version_number);
8275 --
8276 if l_rqd_data_found = FALSE then
8277 --
8278 if g_debug then
8279 hr_utility.set_location('Ctfn rqmts not met', 10);
8280 end if;
8281 --
8282 -- Ctfn rqmts are not met or no ctfns were found. Check if ctfns
8283 -- exist for the person in ben_pl_bnf_ctfn_prvdd_f.
8284 --
8285 open c_ctfns_exist(l_dsgn_bnf.pl_bnf_id);
8286 fetch c_ctfns_exist into l_dummy;
8287 --
8288 if c_ctfns_exist%notfound then
8289 --
8290 if g_debug then
8291 hr_utility.set_location('Person has no ctfns defined', 10);
8292 end if;
8293 --
8294 -- No ctfns exist for this person. Write new ctfns.
8295 --
8296 for l_ctfn_rec in c_ctfns(l_dsgn_bnf.bnf_person_id
8297 ,g_bnf_pl_rec.pl_id,l_person_id) loop
8298 --
8299 -- start bug 5667528
8300 l_write_ctfn := TRUE;
8301 l_ff_ctfn_exits := FALSE;
8302 hr_utility.set_location (' l_ctfn_rec.ctrrl ' || l_ctfn_rec.ctrrl,
8303 12.12
8304 );
8305
8306 IF l_ctfn_rec.ctrrl IS NOT NULL
8307 THEN
8308 OPEN c_pen_info;
8309
8310 FETCH c_pen_info
8311 INTO pen_info_rec;
8312
8313 CLOSE c_pen_info;
8314
8315 OPEN c_asg (pen_info_rec.person_id);
8316
8317 FETCH c_asg
8318 INTO asg_rec;
8319
8320 CLOSE c_asg;
8321
8322 OPEN c_opt (pen_info_rec.oipl_id);
8323
8324 FETCH c_opt
8325 INTO opt_rec;
8326
8327 CLOSE c_opt;
8328
8329 l_outputs :=
8330 benutils.formula
8331 (p_formula_id => l_ctfn_rec.ctrrl,
8332 p_pgm_id => pen_info_rec.pgm_id,
8333 p_pl_id => pen_info_rec.pl_id,
8334 p_pl_typ_id => pen_info_rec.pl_typ_id,
8335 p_opt_id => opt_rec.opt_id,
8336 p_ler_id => pen_info_rec.ler_id,
8337 p_business_group_id => pen_info_rec.business_group_id,
8338 p_assignment_id => asg_rec.assignment_id,
8339 p_organization_id => asg_rec.organization_id,
8340 p_effective_date => p_effective_date
8341 );
8342 hr_utility.set_location ( ' formula result '
8343 || l_outputs (l_outputs.FIRST).VALUE,
8344 12.12
8345 );
8346
8347 IF l_outputs (l_outputs.FIRST).VALUE <> 'Y'
8348 THEN
8349 l_write_ctfn := FALSE;
8350 hr_utility.set_location (' setting ctfn to false ', 12.12);
8351 END IF;
8352 END IF; -- end if l_ctfn_rec.ctrrl is not null
8353 IF l_write_ctfn = TRUE THEN
8354 l_ff_ctfn_exits := true;
8355 hr_utility.set_location(' writing certification ',12.12);
8356
8357 write_new_bnf_ctfn_item
8358 (p_pl_bnf_id => l_dsgn_bnf.pl_bnf_id
8359 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
8360 ,p_bnf_ctfn_typ_cd => l_ctfn_rec.ctcvgcd
8361 --,p_bnf_ctfn_rqd_flag => l_ctfn_rec.ctflag Bug 3196152
8362 ,p_bnf_ctfn_rqd_flag => l_ctfn_rec.rqd_flag
8363 ,p_effective_date => p_effective_date
8364 ,p_business_group_id => p_business_group_id
8365 ,p_object_version_number => l_object_version_number
8366 ,p_pl_bnf_ctfn_prvdd_id => l_pl_bnf_ctfn_prvdd_id);
8367 --
8368 END IF;
8369 end loop;
8370 --
8371 end if; -- ctfns_exist
8372 --
8373 close c_ctfns_exist;
8374 --
8375 end if; -- rqd_data_found
8376 --
8377 IF l_ff_ctfn_exits = FALSE
8378 THEN
8379 hr_utility.set_location
8380 ('Deleting enrollment action item when formula fails ',
8381 12.12
8382 );
8383
8384 OPEN c_curr_ovn_of_actn (l_prtt_enrt_actn_id);
8385
8386 FETCH c_curr_ovn_of_actn
8387 INTO l_object_version_number;
8388
8389 CLOSE c_curr_ovn_of_actn;
8390
8391 delete_action_item
8392 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id,
8393 p_object_version_number => l_object_version_number,
8394 p_business_group_id => p_business_group_id,
8395 p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id,
8396 p_rslt_object_version_number => p_rslt_object_version_number,
8397 p_effective_date => p_effective_date,
8398 p_datetrack_mode => hr_api.g_zap,
8399 p_post_rslt_flag => p_post_rslt_flag
8400 );
8401
8402 -- we need to delete warning also that was created for this action item
8403 OPEN c_act_name (l_actn_typ_id);
8404
8405 FETCH c_act_name
8406 INTO l_act_name;
8407
8408 CLOSE c_act_name;
8409
8410 OPEN c_plan_name (pen_info_rec.pl_id);
8411
8412 FETCH c_plan_name
8413 INTO plan_name_rec;
8414
8415 CLOSE c_plan_name;
8416
8417 ben_warnings.delete_warnings
8418 (p_application_short_name => 'BEN',
8419 p_message_name => l_message_name,
8420 p_parma => l_act_name,
8421 p_parmb => plan_name_rec.NAME,
8422 p_person_id => pen_info_rec.person_id
8423 );
8424 END IF;
8425 -- end bug 5667528
8426 end if; -- ctfn_defined
8427 --
8428 else
8429 --
8430 -- bnf_ctfn_rqd_flag is 'Y'
8431 -- if date_track mode is updating and designation at plan level
8432 -- delete action type of type BNFCTFN.
8433 --
8434 if l_prtt_enrt_actn_id IS NOT NULL and p_datetrack_mode = DTMODE_DELETE then
8435 --
8436 delete_action_item
8437 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
8438 ,p_object_version_number => l_object_version_number
8439 ,p_business_group_id => p_business_group_id
8440 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8441 ,p_rslt_object_version_number => p_rslt_object_version_number
8442 ,p_effective_date => p_effective_date
8443 ,p_datetrack_mode => p_datetrack_mode
8444 ,p_post_rslt_flag => p_post_rslt_flag);
8445 --
8446 end if;
8447 --
8448 end if; -- bnf_ctfn_rqd_flag
8449 --
8450 end loop; -- bnf loop
8451 --
8452 if g_debug then
8453 hr_utility.set_location ('Leaving '||l_proc,10);
8454 end if;
8455 --
8456 exception
8457 when others then
8458 if g_debug then
8459 hr_utility.set_location('Exception Raised '||l_proc, 10);
8460 end if;
8461
8462 p_rslt_object_version_number :=l_rslt_object_version_number ;
8463 p_bnf_actn_warning := null;
8464
8465 raise;
8466 --
8467 end determine_bnf_miss_actn_items;
8468 --
8469 -- ----------------------------------------------------------------------------
8470 -- |-----------------------< determine_bnf_actn_items >-----------------------|
8471 -- ----------------------------------------------------------------------------
8472 --
8473 procedure determine_bnf_actn_items
8474 (p_prtt_enrt_rslt_id in number
8475 ,p_effective_date in date
8476 ,p_business_group_id in number
8477 ,p_datetrack_mode in varchar2 default hr_api.g_correction
8478 ,p_post_rslt_flag in varchar2 default 'Y'
8479 ,p_rslt_object_version_number in out nocopy number
8480 ,p_bnf_actn_item_open out nocopy boolean
8481 ,p_hack out nocopy varchar2) is
8482 --
8483 -- this procedure determines if beneficiaries are required to complete
8484 -- enrollment. For an enrollment result check ben_pl_f.bnf_dsgn_cd
8485 -- if not NULL then a beneficiary is requested so write BNF action item.
8486 -- in additon if the bnf designation is 'R' required, suspend enrollment.
8487 -- or if designation 'O' optional, do not suspend.
8488 --
8489 cursor c_find_bnf is
8490 select pl_bnf_id
8491 from ben_pl_bnf_f,
8492 ben_per_in_ler pil
8493 where prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
8494 and p_effective_date between
8495 effective_start_date and effective_end_date
8496 and pil.per_in_ler_id=ben_pl_bnf_f.per_in_ler_id
8497 and pil.business_group_id=p_business_group_id
8498 and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT');
8499 --
8500 l_find_bnf c_find_bnf%rowtype;
8501 --
8502 -- Cursor to fetch bnf action items other than the BNF item. this will
8503 -- be used to delete all beneficiary action items after a BNF action item is
8504 -- written
8505 --
8506 cursor c_other_bnf_actn_items is
8507 select pea.prtt_enrt_actn_id,
8508 pea.object_version_number
8509 from ben_prtt_enrt_actn_f pea,
8510 ben_actn_typ typ,
8511 ben_per_in_ler pil
8512 where pea.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
8513 and pea.business_group_id = p_business_group_id
8514 and typ.type_cd <> 'BNF'
8515 and typ.type_cd like 'BNF%'
8516 and typ.business_group_id = p_business_group_id
8517 and pea.per_in_ler_id = pil.per_in_ler_id
8518 and pil.per_in_ler_stat_cd not in ('BCKDT', 'VOIDD')
8519 and pea.actn_typ_id = typ.actn_typ_id
8520 and p_effective_date between pea.effective_start_date
8521 and pea.effective_end_date
8522 ;
8523 --
8524 l_actn_typ_id number;
8525 l_cmpltd_dt date;
8526 l_object_version_number number;
8527 l_prtt_enrt_actn_id number;
8528 l_bnf_found boolean;
8529 l_rslt_object_version_number number(15);
8530
8531 --
8532 bnf_dsgn_cd_null exception;
8533 --
8534 l_proc varchar2(80) ;
8535 --
8536 begin
8537 --
8538 if g_debug then
8539 l_proc := g_package||'.determine_bnf_actn_items';
8540 hr_utility.set_location ('Entering '||l_proc,10);
8541 end if;
8542 --
8543 l_rslt_object_version_number := p_rslt_object_version_number;
8544
8545 -- get data from pl table.
8546 open g_bnf_pl(p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8547 ,p_effective_date => p_effective_date);
8548 fetch g_bnf_pl into g_bnf_pl_rec;
8549 if g_bnf_pl_rec.rqd is null then
8550 -- if bnf_dsgn_cd is null, skip out of this procedure.
8551 close g_bnf_pl;
8552 raise bnf_dsgn_cd_null;
8553 end if;
8554 close g_bnf_pl;
8555 --
8556 -- Check if beneficiaries are designated.
8557 --
8558 open c_find_bnf;
8559 fetch c_find_bnf into l_find_bnf;
8560 --
8561 if c_find_bnf%found then
8562 l_bnf_found := TRUE;
8563 else
8564 l_bnf_found := FALSE;
8565 end if;
8566 --
8567 close c_find_bnf;
8568 --
8569 -- Get the actn type id for the BNF action item
8570 --
8571 l_actn_typ_id := get_actn_typ_id
8572 (p_type_cd => 'BNF'
8573 ,p_business_group_id => p_business_group_id);
8574 --
8575 -- Get the action item id if one exists
8576 --
8577 get_prtt_enrt_actn_id
8578 (p_actn_typ_id => l_actn_typ_id
8579 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8580 ,p_effective_date => p_effective_date
8581 ,p_business_group_id => p_business_group_id
8582 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
8583 ,p_cmpltd_dt => l_cmpltd_dt
8584 ,p_object_version_number => l_object_version_number);
8585 --
8586 if l_bnf_found = FALSE then
8587 --
8588 if g_debug then
8589 hr_utility.set_location('Beneficiaries not designated', 10);
8590 end if;
8591 --
8592 --
8593 -- There are no beneficiaries designated
8594 --
8595 -- Set the p_rqd_data_found parameter to FALSE so that the procedure writes
8596 -- an action item
8597 --
8598 process_action_item
8599 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
8600 ,p_actn_typ_id => l_actn_typ_id
8601 ,p_cmpltd_dt => l_cmpltd_dt
8602 ,p_object_version_number => l_object_version_number
8603 ,p_effective_date => p_effective_date
8604 ,p_rqd_data_found => FALSE
8605 ,p_rqd_flag => g_bnf_pl_rec.rqd
8606 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8607 ,p_post_rslt_flag => p_post_rslt_flag
8608 ,p_business_group_id => p_business_group_id
8609 ,p_datetrack_mode => p_datetrack_mode
8610 ,p_rslt_object_version_number => p_rslt_object_version_number);
8611 --
8612 p_bnf_actn_item_open := TRUE;
8613 --
8614 -- Set the hack flag to N so that the calling program knows that an action
8615 -- item was actually written
8616 --
8617 p_hack := 'N';
8618 --
8619 -- Delete all other beneficiary action items.
8620 --
8621 for actn_item_rec in c_other_bnf_actn_items loop
8622 --
8623 delete_action_item
8624 (p_prtt_enrt_actn_id => actn_item_rec.prtt_enrt_actn_id
8625 ,p_object_version_number => actn_item_rec.object_version_number
8626 ,p_business_group_id => p_business_group_id
8627 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8628 ,p_rslt_object_version_number => p_rslt_object_version_number
8629 ,p_effective_date => p_effective_date
8630 ,p_datetrack_mode => hr_api.g_zap
8631 ,p_post_rslt_flag => p_post_rslt_flag);
8632 --
8633 end loop;
8634 --
8635 else
8636 --
8637 -- Beneficiaries found
8638 --
8639 if g_debug then
8640 hr_utility.set_location('Beneficiaries found', 10);
8641 end if;
8642 --
8643 --
8644 -- Set the p_rqd_data_found = TRUE so that the proc below closes an open
8645 -- action item of type BNF, if found.
8646 --
8647 process_action_item
8648 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
8649 ,p_actn_typ_id => l_actn_typ_id
8650 ,p_cmpltd_dt => l_cmpltd_dt
8651 ,p_object_version_number => l_object_version_number
8652 ,p_effective_date => p_effective_date
8653 ,p_rqd_data_found => TRUE
8654 ,p_rqd_flag => g_bnf_pl_rec.rqd
8655 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8656 ,p_post_rslt_flag => p_post_rslt_flag
8657 ,p_business_group_id => p_business_group_id
8658 ,p_datetrack_mode => p_datetrack_mode
8659 ,p_rslt_object_version_number => p_rslt_object_version_number);
8660 --
8661 p_bnf_actn_item_open := FALSE;
8662 p_hack := 'N';
8663 --
8664 end if;
8665 --
8666 if g_debug then
8667 hr_utility.set_location ('Leaving ' ||l_proc,10);
8668 end if;
8669 --
8670 exception
8671 --
8672 when bnf_dsgn_cd_null
8673 then
8674 -- Since designation of beneficiaries is not required for the plan, we don't
8675 -- have to write any action item. Set the out parameter so that the calling
8676 -- proc does not call determine_bnf_miss_actn_items. Also set the hack flag
8677 -- to Y so that the calling procedure knows that no action items were
8678 -- written.
8679 --
8680 p_bnf_actn_item_open := TRUE;
8681 p_hack := 'Y';
8682 --
8683 if g_debug then
8684 hr_utility.set_location('Bnf dsgn not specified.', 10);
8685 end if;
8686 if g_debug then
8687 hr_utility.set_location('Leaving : ' || l_proc, 10);
8688 end if;
8689 --
8690 when others then
8691 if g_debug then
8692 hr_utility.set_location('Exception Raised '||l_proc, 10);
8693 end if;
8694
8695 p_rslt_object_version_number :=l_rslt_object_version_number ;
8696 p_bnf_actn_item_open := null;
8697 p_hack := null ;
8698 raise;
8699 --
8700 end determine_bnf_actn_items;
8701 --
8702 -- ----------------------------------------------------------------------------
8703 -- |-----------------------< determine_additional_bnf >-----------------------|
8704 -- ----------------------------------------------------------------------------
8705 --
8706 procedure determine_additional_bnf
8707 (p_validate in boolean default FALSE
8708 ,p_prtt_enrt_rslt_id in number
8709 ,p_effective_date in date
8710 ,p_business_group_id in number
8711 ,p_datetrack_mode in varchar2 default hr_api.g_correction
8712 ,p_post_rslt_flag in varchar2 default 'Y'
8713 ,p_rslt_object_version_number in out nocopy number
8714 ,p_bnf_actn_warning in out nocopy boolean) is
8715 --
8716 -- This procedure is run after all beneficiaries have been designated. If an
8717 -- additonal beneficiary designation is needed an action item of type BNFADDNL
8718 -- is written. It also writes a BNFSCCTFN (spousal consent certification)
8719 -- aciton item when a prtt has designated a person other than his/her spouse
8720 -- as a primary beneficiary and spousal consent certification is required and
8721 -- has not been provided.
8722 --
8723 l_proc varchar2(80) ;
8724 l_actn_typ_id number;
8725 l_cmpltd_dt date;
8726 l_object_version_number number;
8727 l_prtt_enrt_actn_id number;
8728 l_prtt_enrt_ctfn_prvdd_id number;
8729 l_meets_rqmt boolean;
8730 l_outputs ff_exec.outputs_t;
8731 l_write_ctfn boolean := TRUE;
8732 l_bnf_actn_warning boolean := FALSE;
8733 l_rslt_object_version_number number(15);
8734
8735 l_dummy varchar2(30);
8736 --
8737 -- Cursor to compute the sum of the primary and contingent beneficiaries'
8738 -- designated percentages
8739 --
8740 cursor c_rslt is select
8741 rslt.pgm_id,
8742 rslt.pl_id,
8743 rslt.pl_typ_id,
8744 rslt.oipl_id,
8745 rslt.ler_id,
8746 rslt.person_id,
8747 rslt.business_group_id
8748 from ben_prtt_enrt_rslt_f rslt
8749 where rslt.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
8750 and p_effective_date between
8751 rslt.effective_start_date and rslt.effective_end_date;
8752
8753 l_rslt c_rslt%rowtype;
8754
8755 cursor c_opt is
8756 select oipl.opt_id
8757 from ben_oipl_f oipl
8758 where oipl.oipl_id = l_rslt.oipl_id
8759 and business_group_id = p_business_group_id
8760 and p_effective_date between
8761 oipl.effective_start_date and oipl.effective_end_date;
8762
8763 l_opt c_opt%rowtype;
8764
8765 cursor c_asg is
8766 select asg.assignment_id,asg.organization_id
8767 from per_all_assignments_f asg
8768 where asg.person_id = l_rslt.person_id
8769 and asg.assignment_type <> 'C'
8770 and asg.primary_flag = 'Y'
8771 and p_effective_date between
8772 asg.effective_start_date and asg.effective_end_date;
8773
8774 l_asg c_asg%rowtype;
8775
8776 cursor c_sum_bnf_pct is
8777 select prmry_cntngnt_cd cntgcd,
8778 sum(pct_dsgd_num) prcnt
8779 from ben_pl_bnf_f ,
8780 ben_per_in_ler pil
8781 where prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
8782 and ben_pl_bnf_f.business_group_id = p_business_group_id
8783 and p_effective_date between
8784 ben_pl_bnf_f.effective_start_date and ben_pl_bnf_f.effective_end_date
8785 and pil.per_in_ler_id=ben_pl_bnf_f.per_in_ler_id
8786 and pil.business_group_id=p_business_group_id
8787 and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT')
8788 group by prmry_cntngnt_cd;
8789 --
8790 l_sum_bnf_pct c_sum_bnf_pct%rowtype;
8791 --
8792 -- Cursor to pick up any NSC ctfns that may be defined for the plan and
8793 -- contact type.
8794 -- Bug 5461171 - Modified conditions. See Bug Closure for all scenarios
8795 -- satisfied by the cursor
8796 --
8797 CURSOR c_nsc_ctfn_pl (v_contact_type IN VARCHAR2, v_pl_id IN NUMBER)
8798 IS
8799 SELECT pcx.rqd_flag ctflag, pcx.bnf_ctfn_typ_cd ctcvgcd,
8800 pcx.ctfn_rqd_when_rl ctrrl, pcx.rlshp_typ_cd ctrlshcd,
8801 pcx.bnf_typ_cd, pcx.pl_id
8802 FROM ben_pl_bnf_ctfn_f pcx
8803 WHERE pcx.pl_id = v_pl_id
8804 AND ( ( NVL (pcx.bnf_typ_cd, 'O') = 'O'
8805 AND v_contact_type = 'O'
8806 AND pcx.rlshp_typ_cd IS NULL
8807 )
8808 OR -- Bug 5156111
8809 ( NVL (pcx.bnf_typ_cd, 'P') = 'P'
8810 AND NVL (pcx.rlshp_typ_cd, v_contact_type) = v_contact_type
8811 AND v_contact_type <> 'O'
8812 )
8813 )
8814 AND pcx.bnf_ctfn_typ_cd = 'NSC'
8815 AND pcx.business_group_id = p_business_group_id
8816 AND p_effective_date BETWEEN pcx.effective_start_date
8817 AND pcx.effective_end_date;
8818
8819 --
8820 -- check if the participant is married and the spouse the primary beneficiary
8821 --
8822 cursor c_spouse is
8823 select pcr.contact_type,
8824 plb.bnf_person_id,
8825 plb.pl_bnf_id,
8826 pl.pl_id
8827 from per_all_people_f per,
8828 per_contact_relationships pcr,
8829 ben_pl_f pl,
8830 ben_pl_bnf_f plb,
8831 ben_prtt_enrt_rslt_f pen,
8832 ben_per_in_ler pil
8833 where pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
8834 and pen.pl_id = pl.pl_id
8835 and pl.bnf_qdro_rl_apls_flag = 'Y'
8836 and pl.bnf_ctfn_rqd_flag = 'N' -- Flag is named incorrectly(opposite).
8837 and plb.prtt_enrt_rslt_id = pen.prtt_enrt_rslt_id
8838 and plb.prmry_cntngnt_cd = 'PRIMY'
8839 and pcr.contact_person_id = plb.bnf_person_id
8840 and pcr.person_id = pen.person_id
8841 and per.person_id = pen.person_id
8842 and per.marital_status = 'M'
8843 and pcr.business_group_id = p_business_group_id
8844 and pen.business_group_id = p_business_group_id
8845 and p_effective_date between pen.effective_start_date
8846 and pen.effective_end_date
8847 and per.business_group_id = p_business_group_id
8848 and p_effective_date between per.effective_start_date
8849 and per.effective_end_date
8850 and pl.business_group_id = p_business_group_id
8851 and p_effective_date between pl.effective_start_date
8852 and pl.effective_end_date
8853 and plb.business_group_id = p_business_group_id
8854 and p_effective_date between plb.effective_start_date
8855 and plb.effective_end_date
8856 and p_effective_date between nvl(date_start, p_effective_date) -- bug 5362890
8857 and nvl(date_end, hr_api.g_eot)
8858 and pil.per_in_ler_id=plb.per_in_ler_id
8859 and pil.business_group_id=p_business_group_id
8860 and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT')
8861 UNION -- Bug 5156111 : Added union clause
8862 select 'O',
8863 plb.organization_id,
8864 plb.pl_bnf_id,
8865 pl.pl_id
8866 from per_all_people_f per,
8867 hr_all_organization_units o,
8868 ben_pl_f pl,
8869 ben_pl_bnf_f plb,
8870 ben_prtt_enrt_rslt_f pen,
8871 ben_per_in_ler pil
8872 where pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
8873 and pen.pl_id = pl.pl_id
8874 and pl.bnf_qdro_rl_apls_flag = 'Y'
8875 and pl.bnf_may_dsgt_org_flag = 'Y'
8876 and pl.bnf_ctfn_rqd_flag = 'N' -- Flag is named incorrectly(opposite).
8877 and plb.prtt_enrt_rslt_id = pen.prtt_enrt_rslt_id
8878 and plb.prmry_cntngnt_cd = 'PRIMY'
8879 and o.organization_id = plb.organization_id
8880 and per.person_id = pen.person_id
8881 and per.marital_status = 'M'
8882 and o.business_group_id = p_business_group_id
8883 and pen.business_group_id = p_business_group_id
8884 and p_effective_date between pen.effective_start_date
8885 and pen.effective_end_date
8886 and per.business_group_id = p_business_group_id
8887 and p_effective_date between per.effective_start_date
8888 and per.effective_end_date
8889 and pl.business_group_id = p_business_group_id
8890 and p_effective_date between pl.effective_start_date
8891 and pl.effective_end_date
8892 and plb.business_group_id = p_business_group_id
8893 and p_effective_date between o.date_from
8894 and nvl(o.date_to, p_effective_date)
8895 and pil.per_in_ler_id=plb.per_in_ler_id
8896 and pil.business_group_id=p_business_group_id
8897 and pil.per_in_ler_stat_cd not in ('VOIDD','BCKDT');
8898
8899 --
8900 -- Cursor to check if the NSC ctfn has been provided.
8901 --
8902 cursor c_nsc_prvdd(v_pl_bnf_id number) is
8903 select 's'
8904 from ben_pl_bnf_ctfn_prvdd_f
8905 where pl_bnf_id = v_pl_bnf_id
8906 and bnf_ctfn_recd_dt is not null
8907 and business_group_id = p_business_group_id
8908 and p_effective_date between effective_start_date
8909 and effective_end_date;
8910
8911 begin
8912 --
8913 if g_debug then
8914 l_proc := g_package||'.determine_additional_bnf';
8915 hr_utility.set_location ('Entering '||l_proc,10);
8916 end if;
8917 --
8918
8919 l_rslt_object_version_number := p_rslt_object_version_number;
8920
8921 --
8922 if p_prtt_enrt_rslt_id is not null then
8923 open c_rslt;
8924 fetch c_rslt into l_rslt;
8925 close c_rslt;
8926
8927 -- get data from pl table.
8928 open g_bnf_pl(p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8929 ,p_effective_date => p_effective_date);
8930 fetch g_bnf_pl into g_bnf_pl_rec;
8931 close g_bnf_pl;
8932 end if;
8933
8934
8935 if l_rslt.person_id is not null then
8936 open c_asg;
8937 fetch c_asg into l_asg;
8938 close c_asg;
8939 end if;
8940
8941 l_meets_rqmt := TRUE;
8942 --
8943 open c_sum_bnf_pct;
8944 --
8945 -- Check if the sum total of the percentages is 100% for either primary or
8946 -- contingent beneficiaries. If not, then write an action item of type
8947 -- BNFADDNL for designating addtional beneficiaryies.
8948 --
8949 loop
8950 --
8951 fetch c_sum_bnf_pct into l_sum_bnf_pct;
8952 exit when c_sum_bnf_pct%notfound;
8953 --
8954 if l_sum_bnf_pct.prcnt < 100 then
8955 l_meets_rqmt := FALSE;
8956 end if;
8957 --
8958 end loop;
8959 --
8960 close c_sum_bnf_pct;
8961 --
8962 -- Check if an action item of type BNFADDNL exists.
8963 --
8964 l_actn_typ_id := get_actn_typ_id
8965 (p_type_cd => 'BNFADDNL'
8966 ,p_business_group_id => p_business_group_id);
8967 --
8968 get_prtt_enrt_actn_id
8969 (p_actn_typ_id => l_actn_typ_id
8970 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8971 ,p_effective_date => p_effective_date
8972 ,p_business_group_id => p_business_group_id
8973 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
8974 ,p_cmpltd_dt => l_cmpltd_dt
8975 ,p_object_version_number => l_object_version_number);
8976 --
8977 if l_meets_rqmt = TRUE then
8978 --
8979 if g_debug then
8980 hr_utility.set_location('rqmts met for BNFADDNL', 10);
8981 end if;
8982 --
8983 -- Set the p_rqd_data_found = TRUE so that the procedure closes an open
8984 -- action item of type BNFADDNL, if found.
8985 --
8986 process_action_item
8987 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
8988 ,p_actn_typ_id => l_actn_typ_id
8989 ,p_cmpltd_dt => l_cmpltd_dt
8990 ,p_object_version_number => l_object_version_number
8991 ,p_effective_date => p_effective_date
8992 ,p_rqd_data_found => TRUE
8993 ,p_rqd_flag => g_bnf_pl_rec.rqd
8994 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
8995 ,p_post_rslt_flag => p_post_rslt_flag
8996 ,p_business_group_id => p_business_group_id
8997 ,p_datetrack_mode => p_datetrack_mode
8998 ,p_rslt_object_version_number => p_rslt_object_version_number);
8999 --
9000 else
9001 --
9002 if g_debug then
9003 hr_utility.set_location('rqmts not met for BNFADDNL', 10);
9004 end if;
9005
9006 --
9007 -- Requirements are not met. Set the p_rqd_data_found = FALSE so that the
9008 -- procedure reopens or writes a new action item of type BNFADDNL.
9009 --
9010 process_action_item
9011 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
9012 ,p_actn_typ_id => l_actn_typ_id
9013 ,p_cmpltd_dt => l_cmpltd_dt
9014 ,p_object_version_number => l_object_version_number
9015 ,p_effective_date => p_effective_date
9016 ,p_rqd_data_found => FALSE
9017 ,p_rqd_flag => g_bnf_pl_rec.rqd
9018 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
9019 ,p_post_rslt_flag => p_post_rslt_flag
9020 ,p_business_group_id => p_business_group_id
9021 ,p_datetrack_mode => p_datetrack_mode
9022 ,p_rslt_object_version_number => p_rslt_object_version_number);
9023 --
9024 end if;
9025 --
9026 --
9027 -- SPOUSAL CONSENT CERTIFICATTION
9028 --
9029 -- Check if the primary bnf is a spouse and if not, whether the plan requires
9030 -- a spousal consent ctfn.
9031 --
9032 for l_bnf_rec in c_spouse loop
9033 --
9034 -- Reset the enrt actn id for each new iteration.
9035 --
9036 l_prtt_enrt_actn_id := NULL;
9037 --
9038 if l_bnf_rec.contact_type <> 'S' then
9039 --
9040 -- The primary bnf is not a spouse.
9041 --
9042 if g_debug then
9043 hr_utility.set_location('Contact type ' || l_bnf_rec.contact_type ||
9044 ' is not a spouse', 10);
9045 end if;
9046 --
9047 -- Check if an BNFSCCTFN actn item already exists for the bnf.
9048 --
9049 l_actn_typ_id := get_actn_typ_id
9050 (p_type_cd => 'BNFSCCTFN'
9051 ,p_business_group_id => p_business_group_id);
9052 --
9053 get_prtt_enrt_actn_id
9054 (p_actn_typ_id => l_actn_typ_id
9055 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
9056 ,p_pl_bnf_id => l_bnf_rec.pl_bnf_id
9057 ,p_effective_date => p_effective_date
9058 ,p_business_group_id => p_business_group_id
9059 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
9060 ,p_cmpltd_dt => l_cmpltd_dt
9061 ,p_object_version_number => l_object_version_number);
9062 --
9063 -- Loop through sposal consent ctfns that are defined for this contact
9064 -- type and write to pl_bnf_ctfn_prvdd_f.
9065 --
9066 for l_nsc_ctfn_pl in c_nsc_ctfn_pl(l_bnf_rec.contact_type
9067 ,l_bnf_rec.pl_id) loop
9068 --
9069 -- We will be in this loop only if a ctfn is defined for this contact
9070 -- type. If the action item was not found earlier, we need to create
9071 -- one and then write ctfns into the ctfn_prvdd table.
9072 --
9073 if l_prtt_enrt_actn_id IS NULL then
9074 --
9075 -- no BNFSCCTFN action item yet so create a new entry
9076 --
9077 if g_debug then
9078 hr_utility.set_location('No BNFSCCTFN actn item.', 10);
9079 end if;
9080 --
9081 write_new_action_item
9082 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
9083 ,p_rslt_object_version_number => p_rslt_object_version_number
9084 ,p_actn_typ_id => l_actn_typ_id
9085 ,p_pl_bnf_id => l_bnf_rec.pl_bnf_id
9086 ,p_rqd_flag => g_bnf_pl_rec.rqd
9087 ,p_effective_date => p_effective_date
9088 ,p_post_rslt_flag => p_post_rslt_flag
9089 ,p_business_group_id => p_business_group_id
9090 ,p_object_version_number => l_object_version_number
9091 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id);
9092 --
9093 l_write_ctfn := true;
9094 --
9095 if l_nsc_ctfn_pl.ctrrl IS NOT NULL then
9096 --
9097 if l_rslt.oipl_id is not null then
9098 open c_opt;
9099 fetch c_opt into l_opt;
9100 close c_opt;
9101 end if;
9102 --
9103 l_outputs := benutils.formula
9104 (p_formula_id => l_nsc_ctfn_pl.ctrrl
9105 ,p_pgm_id => NULL
9106 ,p_pl_id => l_nsc_ctfn_pl.pl_id
9107 ,p_pl_typ_id => l_rslt.pl_typ_id
9108 ,p_opt_id => l_opt.opt_id
9109 ,p_ler_id => l_rslt.ler_id
9110 ,p_business_group_id => l_rslt.business_group_id
9111 ,p_assignment_id => l_asg.assignment_id
9112 ,p_organization_id => l_asg.organization_id
9113 ,p_effective_date => p_effective_date);
9114 --
9115 if l_outputs(l_outputs.first).value <> 'Y' then
9116 l_write_ctfn := FALSE;
9117 end if;
9118 --
9119 end if;
9120 --
9121 if l_write_ctfn = TRUE then
9122 --
9123 write_new_bnf_ctfn_item
9124 (p_pl_bnf_id => l_bnf_rec.pl_bnf_id
9125 ,p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
9126 ,p_bnf_ctfn_typ_cd => l_nsc_ctfn_pl.ctcvgcd
9127 ,p_bnf_ctfn_rqd_flag => l_nsc_ctfn_pl.ctflag
9128 ,p_effective_date => p_effective_date
9129 ,p_business_group_id => p_business_group_id
9130 ,p_object_version_number => l_object_version_number
9131 ,p_pl_bnf_ctfn_prvdd_id => l_prtt_enrt_ctfn_prvdd_id);
9132 --
9133 end if; -- write_ctfn
9134 --
9135 end if; -- prtt_enrt_actn_id
9136 --
9137 end loop; -- inner loop
9138 --
9139 if l_prtt_enrt_actn_id IS NOT NULL then
9140 --
9141 -- A BNFSCCTFN action item was written in an earlier run. Check if the
9142 -- NSC ctfn has been provided and if yes, close the action item.
9143 --
9144 if g_debug then
9145 hr_utility.set_location('BNFSCCTFN actn item found', 10);
9146 end if;
9147 --
9148 open c_nsc_prvdd(l_bnf_rec.pl_bnf_id);
9149 fetch c_nsc_prvdd into l_dummy;
9150 --
9151 if c_nsc_prvdd%found then
9152 --
9153 -- Ctfn provided. Close action item.
9154 --
9155 if g_debug then
9156 hr_utility.set_location('SCCTFN provided. Close actn item.', 10);
9157 end if;
9158 --
9159 set_cmpltd_dt
9160 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
9161 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
9162 ,p_rslt_object_version_number => p_rslt_object_version_number
9163 ,p_actn_typ_id => l_actn_typ_id
9164 ,p_rqd_flag => g_bnf_pl_rec.rqd
9165 ,p_effective_date => p_effective_date
9166 ,p_post_rslt_flag => p_post_rslt_flag
9167 ,p_business_group_id => p_business_group_id
9168 ,p_object_version_number => l_object_version_number
9169 ,p_open_close => 'CLOSE'
9170 ,p_datetrack_mode => p_datetrack_mode);
9171 --
9172 else
9173 --
9174 -- Ctfn not provided. Open action item if already closed.
9175 --
9176 if g_debug then
9177 hr_utility.set_location('CTFN not prvdd. Open actn item.', 10);
9178 end if;
9179 --
9180 if l_cmpltd_dt is null then
9181 set_cmpltd_dt
9182 (p_prtt_enrt_actn_id => l_prtt_enrt_actn_id
9183 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
9184 ,p_rslt_object_version_number => p_rslt_object_version_number
9185 ,p_actn_typ_id => l_actn_typ_id
9186 ,p_rqd_flag => g_bnf_pl_rec.rqd
9187 ,p_effective_date => p_effective_date
9188 ,p_post_rslt_flag => p_post_rslt_flag
9189 ,p_business_group_id => p_business_group_id
9190 ,p_object_version_number => l_object_version_number
9191 ,p_open_close => 'OPEN'
9192 ,p_datetrack_mode => p_datetrack_mode);
9193 --
9194 end if;
9195 --
9196 end if;
9197 --
9198 close c_nsc_prvdd;
9199 --
9200 end if; -- prtt_enrt_actn_id
9201 --
9202 end if; -- contact type <> 'S'
9203 --
9204 end loop; -- outer loop
9205 --
9206 if g_debug then
9207 hr_utility.set_location ('Leaving ' ||l_proc,10);
9208 end if;
9209 --
9210 exception
9211 when others then
9212 if g_debug then
9213 hr_utility.set_location('Exception Raised '||l_proc, 10);
9214 end if;
9215 p_rslt_object_version_number :=l_rslt_object_version_number ;
9216 p_bnf_actn_warning :=l_bnf_actn_warning ;
9217 raise;
9218 --
9219 end determine_additional_bnf;
9220 --
9221 -- ----------------------------------------------------------------------------
9222 -- |-----------------------< process_bnf_actn_items >-------------------------|
9223 -- ----------------------------------------------------------------------------
9224 --
9225 procedure process_bnf_actn_items
9226 (p_prtt_enrt_rslt_id in number
9227 ,p_effective_date in date
9228 ,p_business_group_id in number
9229 ,p_validate in boolean default FALSE
9230 ,p_datetrack_mode in varchar2 default hr_api.g_correction
9231 ,p_post_rslt_flag in varchar2 default 'Y'
9232 ,p_rslt_object_version_number in out nocopy number
9233 ,p_suspend_flag in out nocopy varchar2
9234 ,p_bnf_actn_warning out nocopy boolean) is
9235 --
9236 l_proc varchar2(80) ;
9237 --
9238 l_bnf_actn_item_open boolean := FALSE;
9239 l_bnf_actn_warning boolean := FALSE;
9240 l_hack varchar2(1) := 'N';
9241
9242 l_rslt_object_version_number number(15);
9243 l_suspend_flag varchar2(20);
9244
9245 --
9246 begin
9247 --
9248 g_debug := hr_utility.debug_enabled;
9249 if g_debug then
9250 l_proc := g_package || '.process_bnf_actn_items';
9251 hr_utility.set_location ('Entering '||l_proc,10);
9252 end if;
9253 --
9254
9255 l_rslt_object_version_number:= p_rslt_object_version_number ;
9256 l_suspend_flag := p_suspend_flag ;
9257
9258 --
9259 savepoint process_bnf_actn_items;
9260 --
9261 determine_bnf_actn_items
9262 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
9263 ,p_rslt_object_version_number => p_rslt_object_version_number
9264 ,p_effective_date => p_effective_date
9265 ,p_business_group_id => p_business_group_id
9266 ,p_datetrack_mode => p_datetrack_mode
9267 ,p_post_rslt_flag => p_post_rslt_flag
9268 ,p_bnf_actn_item_open => l_bnf_actn_item_open
9269 ,p_hack => l_hack);
9270 --
9271 if l_bnf_actn_item_open = FALSE then
9272 --
9273 -- A BNF actn item was not written by the previous procedure. i.e. bnf's are
9274 -- designated. Determine missing bnf information
9275 --
9276 determine_bnf_miss_actn_items
9277 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
9278 ,p_rslt_object_version_number => p_rslt_object_version_number
9279 ,p_effective_date => p_effective_date
9280 ,p_business_group_id => p_business_group_id
9281 ,p_datetrack_mode => p_datetrack_mode
9282 ,p_post_rslt_flag => p_post_rslt_flag
9283 ,p_bnf_actn_warning => l_bnf_actn_warning);
9284 --
9285 determine_additional_bnf
9286 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
9287 ,p_rslt_object_version_number => p_rslt_object_version_number
9288 ,p_effective_date => p_effective_date
9289 ,p_business_group_id => p_business_group_id
9290 ,p_datetrack_mode => p_datetrack_mode
9291 ,p_post_rslt_flag => p_post_rslt_flag
9292 ,p_bnf_actn_warning => l_bnf_actn_warning);
9293 --
9294 else
9295 --
9296 -- l_bnf_actn_item_open is TRUE. Set the l_bnf_actn_warning flag.
9297 --
9298 if l_hack = 'Y' then
9299 -- This indicates that the l_bnf_actn_item_open was set to TRUE only to
9300 -- fool this process to not check for bnf missing items and no
9301 -- BNF action item was written. Set the l_dpnt_actn_warning to FALSE
9302 --
9303 l_bnf_actn_warning := FALSE;
9304 --
9305 else
9306 --
9307 -- A BNF actn item was actually written. Set the flag to TRUE.
9308 --
9309 l_bnf_actn_warning := TRUE;
9310 --
9311 end if;
9312 --
9313 end if;
9314 --
9315 p_bnf_actn_warning := l_bnf_actn_warning;
9316 --
9317 if p_validate then
9318 raise hr_api.validate_enabled;
9319 end if;
9320 --
9321 if g_debug then
9322 hr_utility.set_location ('Leaving '||l_proc, 10);
9323 end if;
9324 --
9325 exception
9326 --
9327 when hr_api.validate_enabled
9328 then
9329 --
9330 rollback to process_bnf_actn_items;
9331 if g_debug then
9332 hr_utility.set_location ('Leaving '||l_proc, 10);
9333 end if;
9334 --
9335 when others then
9336 if g_debug then
9337 hr_utility.set_location('Exception Raised '||l_proc, 10);
9338 end if;
9339
9340 p_rslt_object_version_number :=l_rslt_object_version_number ;
9341 p_suspend_flag :=l_suspend_flag ;
9342 p_bnf_actn_warning :=null;
9343
9344 raise;
9345 --
9346 end process_bnf_actn_items;
9347 --
9348 -- ----------------------------------------------------------------------------
9349 -- |-----------------------< determine_action_items >-------------------------|
9350 -- ----------------------------------------------------------------------------
9351 --
9352 procedure determine_action_items
9353 (p_prtt_enrt_rslt_id in number
9354 ,p_effective_date in date
9355 ,p_business_group_id in number
9356 ,p_validate in boolean default false
9357 ,p_enrt_bnft_id in number default null
9358 ,p_datetrack_mode in varchar2 default hr_api.g_correction
9359 ,p_post_rslt_flag in varchar2 default 'Y'
9360 ,p_rslt_object_version_number in out nocopy number
9361 ,p_suspend_flag out nocopy varchar2
9362 ,p_dpnt_actn_warning out nocopy boolean
9363 ,p_bnf_actn_warning out nocopy boolean
9364 ,p_ctfn_actn_warning out nocopy boolean
9365 ) is
9366 --
9367 -- this procedure is the main driver/entry point for action items
9368 -- determines if designated dependents and benficiaries meet all the criteria
9369 -- for PL, PGM, and PTIP where necessary.
9370 --
9371 l_proc varchar2(80) ;
9372 --
9373 l_suspend_flag varchar2(30) := 'N';
9374 l_dpnt_actn_warning boolean := FALSE;
9375 l_bnf_actn_warning boolean := FALSE;
9376 l_ctfn_actn_warning boolean := FALSE;
9377
9378 --Bug 4525608 New variable to handle the case when dependent details are
9379 -- provided and plan level certification has not been furnished
9380 -- this flag will be set when plan certification is not provided
9381 -- and dependent details are provided
9382 l_ctfn_actn_warning_o boolean := FALSE;
9383 --End Bug 4525608
9384
9385
9386 l_pcp_actn_warning boolean := FALSE;
9387 l_pcp_dpnt_actn_warning boolean := FALSE;
9388 l_pln_name ben_pl_f.name%type; -- UTF8 Change Bug 2254683
9389 l_person_id per_all_people_f.person_id%type;
9390 l_rslt_object_version_number number(15);
9391
9392 --
9393 -- Bug : 1857685
9394 --
9395 l_waive_flag varchar2(2) := 'N';
9396 l_pl_id ben_pl_f.pl_id%type;
9397 l_oipl_id ben_oipl_f.oipl_id%type;
9398 l_comp_lvl_cd ben_prtt_enrt_rslt_f.comp_lvl_cd%type;
9399
9400 --
9401 cursor c_waive_info_flag is
9402 select pen.pl_id, pen.oipl_id,pen.sspndd_flag --Bug 2228123 added sspndd_flag
9403 from ben_prtt_enrt_rslt_f pen
9404 where pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
9405 and pen.business_group_id = p_business_group_id
9406 and p_effective_date between pen.effective_start_date
9407 and pen.effective_end_date;
9408 --
9409 -- Bug 1857685 : Do not create dependents and beneficiaries for
9410 -- Waive plans and options
9411 --
9412 cursor c_waive_pl_flag is
9413 select pln.invk_dcln_prtn_pl_flag
9414 from ben_pl_f pln
9415 where pln.pl_id = l_pl_id
9416 and p_effective_date between
9417 pln.effective_start_date and pln.effective_end_date;
9418 --
9419 -- Bug : 1857685
9420 --
9421 cursor c_waive_opt_flag is
9422 select invk_wv_opt_flag
9423 from ben_opt_f opt,
9424 ben_oipl_f oipl
9425 where opt.opt_id = oipl.opt_id
9426 and oipl.oipl_id = l_oipl_id
9427 and p_effective_date between
9428 opt.effective_start_date and opt.effective_end_date
9429 and p_effective_date between
9430 oipl.effective_start_date and oipl.effective_end_date;
9431 --
9432 cursor c_info_for_msg is
9433 select pen.person_id,
9434 pln.name
9435 from ben_prtt_enrt_rslt_f pen
9436 ,ben_pl_f pln
9437 where pen.prtt_enrt_rslt_id = p_prtt_enrt_rslt_id
9438 and pen.pl_id= pln.pl_id
9439 and pen.business_group_id = p_business_group_id
9440 and pln.business_group_id = p_business_group_id
9441 and p_effective_date between pen.effective_start_date
9442 and pen.effective_end_date
9443 and p_effective_date between pln.effective_start_date
9444 and pln.effective_end_date;
9445
9446 l_message1 fnd_new_messages.message_name%type := 'BEN_92596_PRTTPCP_ERR';
9447 l_message2 fnd_new_messages.message_name%type := 'BEN_92597_DPNTPCP_ERR';
9448 --
9449 /*
9450 --BUG 3042379 Don't create action items for the interim
9451 --enrollment.
9452 cursor c_interim is
9453 select 'x'
9454 from ben_prtt_enrt_rslt_f pen
9455 where pen.rplcs_sspndd_rslt_id = p_prtt_enrt_rslt_id
9456 and p_effective_date between pen.effective_start_date
9457 and pen.effective_end_date
9458 and pen.prtt_enrt_rslt_stat_cd is null ;
9459 */
9460 --
9461 l_dummy varchar2(30);
9462 l_interim boolean := false ;
9463 --
9464 begin
9465 --
9466 g_debug := hr_utility.debug_enabled;
9467 if g_debug then
9468 l_proc := g_package||'.determine_action_items';
9469 hr_utility.set_location ('Entering '||l_proc,10);
9470 end if;
9471 --
9472 l_rslt_object_version_number :=p_rslt_object_version_number ;
9473
9474
9475 -- Issue a savepoint if operating in validation only mode
9476 --
9477 savepoint detemine_action_items;
9478 --BUG 3042379 Don't create action items for the interim
9479 --enrollment
9480 /*
9481 open c_interim;
9482 fetch c_interim into l_dummy;
9483 if c_interim%found then
9484 --
9485 l_interim := true ;
9486 --
9487 end if;
9488 close c_interim ;
9489 */
9490 --
9491 --Bug 4422667 The above commented condition doesnot work some times.
9492 --
9493 if ben_sspndd_enrollment.g_interim_flag = 'Y' then
9494 --
9495 l_interim := true;
9496 --
9497 end if;
9498 --
9499 -- Bug : 185768
9500 --
9501 if p_prtt_enrt_rslt_id is not null then
9502 open c_waive_info_flag;
9503 fetch c_waive_info_flag into l_pl_id, l_oipl_id,l_suspend_flag ; --Bug 2228123;
9504 close c_waive_info_flag;
9505 end if;
9506 --
9507 if l_oipl_id is null then
9508 --
9509 open c_waive_pl_flag;
9510 fetch c_waive_pl_flag into l_waive_flag;
9511 close c_waive_pl_flag;
9512 --
9513 else
9514 --
9515 open c_waive_opt_flag;
9516 fetch c_waive_opt_flag into l_waive_flag;
9517 close c_waive_opt_flag;
9518
9519 if g_debug then
9520 hr_utility.set_location ('waive_flag = '||l_waive_flag,9);
9521 end if;
9522
9523 --
9524 -- un comment the following code 3771346 /*
9525 if nvl(l_waive_flag, 'N') = 'N' then
9526 --
9527 -- Check at plan level.
9528 --
9529 open c_waive_pl_flag;
9530 fetch c_waive_pl_flag into l_waive_flag;
9531 close c_waive_pl_flag;
9532 --
9533 end if;
9534 --end 3771346 */
9535 end if;
9536
9537 if g_debug then
9538 hr_utility.set_location ('waive_flag = '||l_waive_flag,10);
9539 end if;
9540 --BUG 3042379 We don't need to process the action items for the
9541 --interim enrollment.
9542
9543 --
9544 -- Dependents
9545 --
9546 -- Bug : 185768
9547 -- If result is associated with waive plan or option do not create
9548 -- dependent or beneficiary action items.
9549 --
9550 -- BUG 3042379 Don't create action items for the interim
9551 if not l_interim then
9552 -- BUG 3042379 Don't create action items for the interim
9553 --
9554 if nvl(l_waive_flag, 'N') = 'N' then
9555 --
9556 process_dpnt_actn_items
9557 (p_validate => FALSE
9558 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
9559 ,p_effective_date => p_effective_date
9560 ,p_business_group_id => p_business_group_id
9561 ,p_datetrack_mode => p_datetrack_mode
9562 ,p_post_rslt_flag => p_post_rslt_flag
9563 ,p_rslt_object_version_number => p_rslt_object_version_number
9564 ,p_suspend_flag => l_suspend_flag
9565 ,p_dpnt_actn_warning => l_dpnt_actn_warning
9566 --Bug No 4525608 to capture the plan level certification required warning
9567 ,p_ctfn_actn_warning => l_ctfn_actn_warning_o);
9568 -- End Bug 4525608
9569 --
9570 -- Beneficiaries
9571 --
9572 process_bnf_actn_items
9573 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
9574 ,p_effective_date => p_effective_date
9575 ,p_business_group_id => p_business_group_id
9576 ,p_validate => FALSE
9577 ,p_datetrack_mode => p_datetrack_mode
9578 ,p_post_rslt_flag => p_post_rslt_flag
9579 ,p_rslt_object_version_number => p_rslt_object_version_number
9580 ,p_suspend_flag => l_suspend_flag
9581 ,p_bnf_actn_warning => l_bnf_actn_warning);
9582 --
9583 process_pcp_actn_items
9584 (p_validate => FALSE
9585 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
9586 ,p_effective_date => p_effective_date
9587 ,p_business_group_id => p_business_group_id
9588 ,p_datetrack_mode => p_datetrack_mode
9589 ,p_post_rslt_flag => p_post_rslt_flag
9590 ,p_rslt_object_version_number => p_rslt_object_version_number
9591 ,p_suspend_flag => l_suspend_flag
9592 ,p_pcp_actn_warning => l_pcp_actn_warning);
9593 --
9594 process_pcp_dpnt_actn_items
9595 (p_validate => FALSE
9596 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
9597 ,p_effective_date => p_effective_date
9598 ,p_business_group_id => p_business_group_id
9599 ,p_datetrack_mode => p_datetrack_mode
9600 ,p_post_rslt_flag => p_post_rslt_flag
9601 ,p_rslt_object_version_number => p_rslt_object_version_number
9602 ,p_suspend_flag => l_suspend_flag
9603 ,p_pcp_dpnt_actn_warning => l_pcp_dpnt_actn_warning);
9604 --
9605 end if;
9606 --
9607 -- Determine all other enrollment action items that need writing
9608 --
9609 determine_other_actn_items
9610 (p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
9611 ,p_rslt_object_version_number => p_rslt_object_version_number
9612 ,p_effective_date => p_effective_date
9613 ,p_post_rslt_flag => p_post_rslt_flag
9614 ,p_business_group_id => p_business_group_id
9615 ,p_validate => FALSE
9616 ,p_enrt_bnft_id => p_enrt_bnft_id
9617 ,p_datetrack_mode => p_datetrack_mode
9618 ,p_suspend_flag => l_suspend_flag
9619 ,p_ctfn_actn_warning => l_ctfn_actn_warning);
9620
9621 --
9622 --
9623 -- Added by Anil --
9624 --
9625 /*fnd_file.put_line(fnd_file.log,'-->cwb_actn process_cwb_actn_items with the following parameters');
9626 fnd_file.put_line(fnd_file.log,'-->cwb_actn p_prtt_enrt_rslt_id '||p_prtt_enrt_rslt_id);
9627 fnd_file.put_line(fnd_file.log,'-->cwb_actn p_effective_date '||p_effective_date);
9628 fnd_file.put_line(fnd_file.log,'-->cwb_actn p_business_group_id '||p_business_group_id );
9629 fnd_file.put_line(fnd_file.log,'-->cwb_actn p_datetrack_mode '||p_datetrack_mode);
9630 fnd_file.put_line(fnd_file.log,'-->cwb_actn p_post_rslt_flag '||p_post_rslt_flag);
9631 fnd_file.put_line(fnd_file.log,'-->cwb_actn p_rslt_object_version_number'||p_rslt_object_version_number);
9632 fnd_file.put_line(fnd_file.log,'-->cwb_actn l_suspend_flag '||l_suspend_flag);
9633 fnd_file.put_line(fnd_file.log,'---------------------------------------------------------------------------');*/
9634 --
9635 process_cwb_actn_items
9636 (p_validate => FALSE
9637 ,p_prtt_enrt_rslt_id => p_prtt_enrt_rslt_id
9638 ,p_effective_date => p_effective_date
9639 ,p_business_group_id => p_business_group_id
9640 ,p_datetrack_mode => p_datetrack_mode
9641 ,p_post_rslt_flag => p_post_rslt_flag
9642 ,p_rslt_object_version_number => p_rslt_object_version_number
9643 ,p_suspend_flag => l_suspend_flag);
9644 --
9645 -- BUG 3042379 Don't create action items for the interim
9646 else
9647 if g_debug then
9648 hr_utility.set_location ('Interim Enrt- No action item created PEN '||p_prtt_enrt_rslt_id,110);
9649 end if;
9650 end if ;
9651 -- BUG 3042379 Don't create action items for the interim
9652 --
9653 -- Set the warning flags
9654 --
9655 p_bnf_actn_warning := l_bnf_actn_warning;
9656 p_dpnt_actn_warning := l_dpnt_actn_warning;
9657
9658 -- Bug 4525608 set the certification required flag if any of the
9659 -- flags is true
9660 if l_ctfn_actn_warning or l_ctfn_actn_warning_o then
9661 p_ctfn_actn_warning := TRUE;
9662 end if;
9663 -- End Bug 4525608
9664
9665
9666 if l_pcp_actn_warning or l_pcp_dpnt_actn_warning then
9667
9668 if p_prtt_enrt_rslt_id is not null then
9669 open c_info_for_msg;
9670 fetch c_info_for_msg into l_person_id,l_pln_name;
9671 close c_info_for_msg;
9672 end if;
9673
9674 end if;
9675 --
9676 l_pln_name := substr(l_pln_name,1,60);
9677 if l_pcp_actn_warning then
9678 ben_warnings.load_warning
9679 (p_application_short_name => 'BEN',
9680 p_message_name => l_message1,
9681 p_parma => l_pln_name,
9682 p_person_id => l_person_id);
9683 end if;
9684 --
9685 if l_pcp_dpnt_actn_warning then
9686 ben_warnings.load_warning
9687 (p_application_short_name => 'BEN',
9688 p_message_name => l_message2,
9689 p_parma => l_pln_name,
9690 p_person_id => l_person_id);
9691 end if;
9692 --
9693 -- When in validation only mode raise the Validate_Enabled exception
9694 --
9695 if p_validate then
9696 raise hr_api.validate_enabled;
9697 end if;
9698 --
9699 p_suspend_flag := l_suspend_flag;
9700 --
9701 if g_debug then
9702 hr_utility.set_location ('Leaving ' ||l_proc,10);
9703 end if;
9704 --
9705 exception
9706 --
9707 when hr_api.validate_enabled
9708 then
9709 -- rollback to the savepoint
9710 --
9711 ROLLBACK TO determine_action_items;
9712 --
9713 when others then
9714 if g_debug then
9715 hr_utility.set_location('Exception Raised '||l_proc, 10);
9716 end if;
9717 p_rslt_object_version_number :=l_rslt_object_version_number ;
9718 p_suspend_flag :=l_suspend_flag ;
9719 p_ctfn_actn_warning := null ;
9720
9721 p_dpnt_actn_warning := null;
9722 p_bnf_actn_warning := null;
9723 p_ctfn_actn_warning := null;
9724 --
9725 raise; -- Bug 3105160
9726 --
9727 end determine_action_items;
9728 --
9729 end ben_enrollment_action_items;