CachingforBenefitsEnrollment

Caching for Benefits Enrollment

Minor Business Rule

Object Name: B0800078

Parent DLL: CHRM

Location: Client/Server

Language: C

Functional Description

Purpose

The purpose of this function is to store new coverage and election changes in cache. This information 
will be used to update table F08320WF.


Setup Notes and Prerequisites

Records can be Read, Added, Deleted, or Updated to the cache, depending on Cache Action Code, CACTN, 
passed in. The following is a list of the modes used to select cache processing options:

Input

Processing TypeType

============                                  

Cache Get 1

Cache Add 2

Cache Update 3

Cache Delete 4

Cache Delete All 5

Cache Get Next 6

Cache Add/Update 7 (Do Not Use)

Cache End  8
Cache Close Cursor 9


Return errors through Error Message ID, DTAI.


The cache Key is as follows:

JobNumberAKey1   (from next number server X0010)

mnEnrollmentEventTypeKey2
szBenefitGroupCategoryKey3

szPlanIdKey4

szPlanAdditionalOptionKey5  

  

The data can be accessed using the full key or a partial key using NumberKeys, NKEYS, to distinguish 
between a full or a partial fetch.  JobNumberAKey1 must always be part of the key. 


The Cache Cursor, GENLNG must be past to and from the BSFN.


When adding a record always attempt to Get the record first.  If no error is returned then the record 
already exists and it cannot be added.

Special Logic


Technical Specifications

include the header file B0800078.h
    

Declare Variable     

 IDnJDBReturn;
ID          idReturnValue= ER_SUCCESS;

char        szErrorID[11];           

int         iCacheActionCode;

      

Declare Data Structures

  DSD0800078          dsCacheKey;
DSD0800078          dsSaveData;  

Declare pointers

    HUSER               hUser                    = (HUSER) NULL;
HCACHE              hCacheHandle             = (HCACHE) NULL;

Check for NULL pointers, if there are null pointers set error '4363'


Begin Main Processing

 
Initialization Of DS Structure and Save of Workfields  


Initialize the Behavior

If an error occurs initializing the behavior and if cSuppressErrorMessage does not = '1' then 
set error.

  

   iCacheActionCode=atoi(lpDS->szCacheActionCode);


Initialize the Cache 

Call internal function I0800078_InitCache
If no error initializing cache then Process Action code


If iCacheActionCode past in = 1 (Get) then call internal function 

I0800078_CacheGet.
If iCacheActionCode past in = 2 (Add) then call internal function 

 I0800078_CacheAdd.

If iCacheActionCode past in = 3 (Update) then call internal function

I0800078_CacheUpdate.
If iCacheActionCode past in = 4 (Delete) then call internal function

I0800078_CacheDelete.
If iCacheActionCode past in = 5 (Delete All) then call internal function

I0800078_CacheDeleteAll.

If iCacheActionCode past in = 6 (Get Next) then call internal functionI0800078_CacheGetNext.

If iCacheActionCode past in = 7 (Add Update) then call internal function

I0800078_CacheAddUpdate.

If iCacheActionCode past in = 8 (End) then call JDE function

 JdeCacheTerminateAll.

If iCacheActionCode past in = 9 (Close Cursor) then call internal 

Function I0800078_CloseCursor.
If iCacheActionCode = anything else then Error.


Return value of saved fields after cache processing is completed

szErrorMessageID = szErrorID

cSuppressErrorMessage = cSuppressErrorMessage
    szCacheActionCode = dsSaveData.szCacheActionCode

    mnNumberKeys = mnNumberKeys);



Function Clean Up

Free the Behavior
If the pointer szErrorMessageID is not blank and cSuppressErrorMessage does not = '1' then set error.


Internal functions

Function:  I0800078_InitCache   
Initialize cache for Benefit Categories

Declare Variables

JDECM_RESULT       jdeCacheCode = JDECM_PASSED;
Declare structures
DSD0800078dsCacheKey;
JDECMINDEXSTRUCTIndex[1]; 

Main Processing

Initialize output

SzErrorID = ""
Initialize the cache

Setup And Initialize Cache-Keys to Create Cache once
Set Memory, memset(Index, 0x00, sizeof(JDECMINDEXSTRUCT));


Set the number of segments of the key to = '5'

The first segment of the key is mnJobNumberA

Index->CacheKey[0].nOffset = offsetof(DSD0800078, mnJobnumberAKey1);

Index->CacheKey[2].nOffset = offsetof(DSD0800078, mnEnrollmentEventTypeKey2);

Index->CacheKey[3].nOffset = offsetof(DSD0800078, szBenefitGroupCategoryKey3); 

Index->CacheKey[4].nOffset = offsetof(DSD0800078, szPlanIdKey4); 

Index->CacheKey[5].nOffset = offsetof(DSD0800078, szPlanAdditionalOptionKey5); 


Set lphCacheHandle = "B0800078", 

If there is an error szErrorID = ERR_INIT_CACHE



Function:
  I0800078_CacheGet   
Declare Variables

JDECM_RESULT       jdeCacheCode = JDECM_PASSED;
int   iNumberOfKeys;

    HJDECURSOR     hCursor        =  (HJDECURSOR) NULL;

   DSD0800078dsCacheData;

BOOLbChangedKey;

Main Processing

Initialize output

Set Memory
memset((void *) (lpdsCacheKey),0x00,sizeof(DSD0800078));
memset((void *) (&dsCacheData),0x00,sizeof(DSD0800078));

szErrorID = ""

Initialize Variables  

MathNumericToInt((LPMATH_NUMERIC) &lpDS-
>mnNumberKeys,(LPINT)&iNumberOfKeys);

Open the Cursor if error then szErrorID = "ERR_OPEN_CURSOR"

If no error Reset Cursor 

If iNumberOfKeys = '0' then Fetch the first record

Else fetch the record matching the keys

If there is an error with the fetch then szErrorID = ERR_FETCH_RECORD

if the Cursor does not = NULL then close the cursor



Function:  I0800078_CacheAdd 

Declare Variables

JDECM_RESULT       jdeCacheCode = JDECM_PASSED;
     int iNumberOfKeys;
HJDECURSOR        hCursor      = (HJDECURSOR) NULL;    
ID                idCacheCursor;                       

Main Processing

Initialize output
 
SzErrorID = ""

Set the cache with the number or keys = mnNumberKeys

Set the cursor = idCacheCursor

Copy the memory needed the size of DSD0800078


Add the record the size of DSD0800078

If Add fails then szErrorID = ERR_ADD_RECORD



Function:  I0800078_CacheUpdate   

Declare Variables 

int                iNumberOfKeys;
JDECM_RESULT       jdeCacheCode = JDECM_PASSED;
HJDECURSOR        hCursor      = (HJDECURSOR) NULL;  

   DSD0800078dsCacheData;

ID                idCacheCursor;                       
Main Processing

Initialize output

SzErrorID = ""
Set the cache with the number or keys = mnNumberKeys

Set the cursor = idCacheCursor

Set the memory needed the size of DSD0800078


Fetch the record, if record is found Update the record

If there is an error then szErrorID = ERR_UPDATE_RECORD


Close the Cursor



Function:  I0800078_CacheDelete   

Declare Variables

JDECM_RESULT       jdeCacheCode = JDECM_PASSED;
int   iNumberOfKeys;

HJDECURSOR       hCursor       = (HJDECURSOR) NULL;  

Main Processing

Initialize Variables

SzErrorID = ""
Set the cache with the number or keys = mnNumberKeys


If Number Of Keys = 0 Then call internal function I0800078_CacheDeleteAll

else

Initialize the cursor

Set the memory the size of DSD0800078

Fetch the record

If fetch is successful then delete the record

If there is an error deleting then szErrorID = ERR_DELETE_RECORD

If there is an error fetching then szErrorID = ERR_FETCH_RECORD


Close the cursor



Function:  I0800078_CacheDeleteAll   

Declare Variables

JDECM_RESULT       jdeCacheCode = JDECM_PASSED;

int   iNumberOfKeys;

HJDECURSOR       hCursor       = (HJDECURSOR) NULL;  


Main Processing

Initialize input and output

SzErrorID = ""
Copy the memory needed the size of DSD0800078

Set the cache with the number or keys = mnNumberKeys


Open the Cursor

Delete all records

If there is an error on delete then szErrorID = ERR_DELETE_RECORD


 Close Cursor



Function:  I0800078_CacheGetNext   

Notes:Assumption is made this function will be performed until the

Cache Index is no longer equal to the input index. If this function is prematurely ended, the cursor 

will have to be closed using function I0800078_CloseCursor, or memory leaks will result from the 

cursor being left open.

 

Declare Variables

JDECM_RESULTjdeCacheCode = JDECM_PASSED;
intiNumberOfKeys;

BOOLbMatchKey=FALSE;

BOOLbChangedKey;

    HJDECURSOR     hCursor        = (HJDECURSOR) NULL;

    DSD0800078dsCacheData;

    ID                idCacheCursor;                       

Main Processing

Initialize output
 
SzErrorID = ""

Set the memory needed the size of DSD0800078

Initialize Variables  

Set the cache with the number or keys = mnNumberKeys

Set cursor for either initial fetch or subsequent fetches

If idCacheCursor = 0L then this is a subsequent search 

Open Cursor

Copy the memory needed the size of DSD0800078
Fetch the Next record

if hCursor does not = NULL then fetch the next record

If idCacheCursor <> 0L fetch the first record

If the fetch was successful 

If iNumberOfKeys > 0 then call I0800078_ChangedKey and check that the keys match
If the keys do not match then szErrorID = ERR_FETCH_RECORD

If hCursor does not = NULL then close the cursor

set idCacheCursor   = 0L



Function:  I0800078_CacheAddUpdate 

DO NOT USE THIS FUNCTION



Function:
  I0800078_CloseCursor   
Declare Variables    

HJDECURSOR         hCursor      = (HJDECURSOR) NULL;
Main Processing

If idCacheCursor does not equal 0L then close cursor 
Set idCacheCursor = 0L



Function:  I0800078_ChangedKey   

Test to see if the key matches the key in cache

If it has changed then bChangedKey = True

Else

bChangedKey = FALSE;


End of Internal functions








Data Structure

D0800078 - Caching for Benefits Enrollment

Parameter NameData ItemData TypeReq/OptI/O/Both
mnJobnumberAKey1JOBSMATH_NUMERICREQINPUT

The job number (work station ID) which executed the particular job.

mnEnrollmentEventTypeKey2EVETMATH_NUMERICOPTBOTH

A field that indicates the event during which the enrollment occurs. Valid values include:    1   Open Enrollment    2   Enrollment for current plan 
year

szBenefitGroupCategoryKey3SBGRcharOPTBOTH

The category of a benefit group. The category is used to group benefit plans according to the type and/or rule. For 
example: MEDICAL Required Medical Selections   DENTAL Optional Dental Selections   LIFE Required Life Ins Selections Valid categories are set up in the Generic 
Rate and Message table (F00191) for system 08/type SG. Associated text for categories is stored in the General Message Detail table 
(F00192). For more information, see program P00191.

szPlanIdKey4PLANcharOPTBOTH

An abbreviation or number that identifies a specific employee benefit. Examples are:   o  Employee Health Insurance   o  Accidental Death 
and Dismemberment   o  Health Club Expense Reimbursement   o  Employee Stock Appreciation Rights  A benefit plan typically is associated 
with a deduction, benefit, or accrual. For example, a medical plan is a benefit that might also require a deduction to withhold premiums from 
an employee's pay.

szPlanAdditionalOptionKey5AOPTcharOPTBOTH

A code that identifies any additional options available for a benefit plan that have been defined in the Plan Additional Options table 
(F083202). Note: Additional options must have the same provider, policy number, and enrollment and eligibility rules as the benefit plan to which they 
are associated.

cSelection001SL01charOPTBOTH

A code used to prompt detail selection from a list of items. Typically, the legitimate selection codes are explained at the bottom of the 
screen of the video display. If not, see the program help instructions.

mnDeductionAmtRateDRTMMATH_NUMERICOPTBOTH

The value of this field is either a percentage, a dollar amount or an hourly rate depending upon where it is being used;    A When used in 
conjunction with a Deduction, Benefit or Accrual Type this field may represent many of the above values depending upon the value of the D/B/A 
method code (DEDM).

mnBenefitAmtRateBRTMMATH_NUMERICOPTBOTH

The value of this field is either a percentage, a dollar amount or an hourly rate depending upon where it is being used. When used in 
conjunction with a Deduction, Benefit or Accrual Type this field may represent many of the above values depending upon the value of the D/B/A 
method code (DEDM).

mnPlanCostPCOSMATH_NUMERICOPTBOTH

The cost that the system calculates for a plan or plan option.

mnPlanCreditPCREMATH_NUMERICOPTBOTH

The credit that the system calculates for a plan or plan option.

szErrorMessageIDDTAIcharOPTOUTPUT

A code that identifies and defines a unit of information. It is an alphanumeric code up to 8 characters long that does not allow blanks or 
special characters such as %, &, or +. You create new data items using system codes 55-59. You cannot change the alias.

idCacheCursorGENLNGIDREQBOTH

General purpose ID variable.

szCacheActionCodeCACTNcharREQINPUT

A code that indicates the activity you want to perform. Valid codes:     o Get - Retrieve the cache element     o Add - Add a cache element     o 
Update - Update a cache element     o Delete - Delete a cache element     o Delete All - Delete all cache elements     o Get Next - Retrieve the 
next cache element     o Add/Update - Add a cache element if it does not exist; Update a cache element if it does exist     o Terminate - 
Terminate Cache

mnNumberKeysNKEYSMATH_NUMERICREQINPUT

The number of keys in an index that will be used to retrieve, delete, or update a record.

cSuppressErrorMessageSUPPScharOPTINPUT

A flag indicating whether or not runtime error messaging will occur when an error message is issued from a business function.        0 = allow 
runtime error message handling.        1 = suppress runtime error message handling.

mnSequenceNumberViewSEQ#MATH_NUMERICOPTBOTH

A number used to sequence information for review purposes only.

cSelectionChangedFlagEV01charOPTINPUT

An option that specifies the type of processing for an event.

szPlanandOptionDesc50DS50charOPTBOTH

A descriptive statement of up to 50 characters in length.

mnTrackPCPNumberFlagPCPFMATH_NUMERICOPTBOTH

An option that specifies whether the benefit plan or benefit plan option tracks primary care physician numbers. If you choose this option, 
then the system displays a form during the enrollment process for an employee to enter the number for a primary care physician.

mnEmployeeFlexCostEEFCMATH_NUMERICOPTBOTH

The amount of flex credits given to an employee by the employer when the employee chooses the benefit plan.

cDepBenDBENcharOPTBOTH

A code that indicates whether the person is a dependent or a beneficiary of the employee. Valid codes are: D The person is a 
dependent. B The person is a beneficiary.    Blank The system automatically designates the person as a beneficiary or dependent, depending on the 
benefit plan type.

Related Functions

None

Related Tables

None