What is the previous/next event?
Getting the previous or next value in an array is quite easy! We can use #GETASOF, as long as you remember that the previous value of the first value in an array is always zero, and the next value of the last value in an array is always zero.
For purposes of this discussion, we are assuming the event history is stored in a coded effective date array called EventHistory, where the start event codes are 10, 11, and 12, and the following temporary variables have been assigned:
Code:= #VALUE EventHistory &
IsStart:= Code #IN (10, 11, 12) & ; i.e., #IN (all the start event codes)
Use this expression to determine the previous value in an event array:
'P' #GETASOF Code
; the previous code of the first value in the array is zero
Use this expression to determine the next value in an event array:
'N' #GETASOF Code
; the next code of the last value in the array is zero
You can also use this methodology to determine other details about the previous or next events, for example:
Is the current event a start event and is the prior event a stop event?
IsStart #AND (0={'P' #GETASOF IsStart})
Is the current event a start event and is the next event a stop event?
IsStart #AND (0={'N' #GETASOF IsStart})
Is the current event within 30 days of the prior event?
30 > [EV_DT - ('P' #GETASOF IsStart)]
Is the current event within 30 days of the next event?
30 > [('N' #GETASOF IsStart) - EV_DT]
Is the current event within 1 year of the prior event?
1 > [EV_DT #YEARDIF ('P' #GETASOF IsStart)]
Is the current event within 1 year of the next event?