PRSATP6 ;HISC/MGD-Timekeeper Post Absence ;04/18/06
;;4.0;PAID;**102,108**;Sep 21, 1995
;
DBH(PPIP,DFN,WDAY,DBH,QUIT) ;
; Find Day Before Holiday
; Input:
; PPIP - IEN of pay period to check
; DFN - IEN of employee to check
; WDAY - Day to start looping from
; DAH - Null
; QUIT - Null
;
; Output:
; DAH - PPIP^WDAY^Type of non-pay
; QUIT - Will be set to 1 if the holiday encapsulation
; rules are broken
;
N DADRFM,EDATA,EEND,EIN,EINDX,ETOT,NODE0,NODE1,NODE2,NODE4
N TEND,TINDX,TOUR1,TOUR2,REGHRS1,REGHRS2
N PT,PE,PO,PC ; New ordered arrays
S NODE0=$G(^PRST(458,PPIP,"E",DFN,"D",WDAY,0))
I NODE0="" S QUIT=1 Q ; Corrupted data
S NODE2=$G(^PRST(458,PPIP,"E",DFN,"D",WDAY,2))
;
; Skip Days off
Q:$P(NODE0,U,2)=1
;
; Check for tours with no regular hours
S TOUR1=+$P(NODE0,U,2),TOUR2=+$P(NODE0,U,13)
S REGHRS1=$P($G(^PRST(457.1,TOUR1,0)),U,6)
S REGHRS2=$S(TOUR2:$P($G(^PRST(457.1,TOUR2,0)),U,6),1:"")
Q:$P(NODE0,U,2)'=2&($P(NODE0,U,2)'=3)&(REGHRS1+REGHRS2=0)
;
; If the day has a tour that defines work and there are no exceptions
; encapsulation is broken
I $P(NODE0,U,2)>1,NODE2'["NP",NODE2'["WP" S QUIT=1 Q
;
; Checks for employees with DAILY tours
I $P(NODE0,U,2)=2!($P(NODE0,U,2)=3) S DBH=PPIP_U_DFN_U_$P(NODE2,U,3) Q
;
; Load tours and convert to numeric equivalents
; This creates the ordered arrays
S DADRFM=1
S NODE1=$G(^PRST(458,PPIP,"E",DFN,"D",WDAY,1))
D CNV96^PRSATP5(.NODE1,3,"PT",NODE0,.DADRFM)
S NODE4=$G(^PRST(458,PPIP,"E",DFN,"D",WDAY,4))
I NODE4'="" D CNV96^PRSATP5(.NODE4,3,"PT",NODE0,.DADRFM)
D CNV96^PRSATP5(.NODE2,4,"PE",NODE0,.DADRFM)
;
; Identify end of tour
S TINDX="",TINDX=$O(PT(TINDX),-1)
S TEND=$P(PT(TINDX),U,2)
;
; Loop backwards through ordered exceptions to see if last 15
; minutes of tour was non-pay
S (EINDX,EDATA)=""
F EIN=1:1:7 D Q:QUIT!(EINDX="")!(DBH'="")
. S EINDX=$O(PE(EINDX),-1)
. Q:EINDX=""
. S EDATA=PE(EINDX),EEND=$P(EDATA,U,2),ETOT=$P(EDATA,U,3)
. Q:EEND'=TEND ; not last 15 minutes
. I ETOT'="NP"&(ETOT'="WP") S QUIT=1 Q ; last 15 wasn't non-pay
. S DBH=PPIP_U_WDAY_U_ETOT
I DBH="" S QUIT=1
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPRSATP6 2214 printed Oct 16, 2024@18:25:28 Page 2
PRSATP6 ;HISC/MGD-Timekeeper Post Absence ;04/18/06
+1 ;;4.0;PAID;**102,108**;Sep 21, 1995
+2 ;
DBH(PPIP,DFN,WDAY,DBH,QUIT) ;
+1 ; Find Day Before Holiday
+2 ; Input:
+3 ; PPIP - IEN of pay period to check
+4 ; DFN - IEN of employee to check
+5 ; WDAY - Day to start looping from
+6 ; DAH - Null
+7 ; QUIT - Null
+8 ;
+9 ; Output:
+10 ; DAH - PPIP^WDAY^Type of non-pay
+11 ; QUIT - Will be set to 1 if the holiday encapsulation
+12 ; rules are broken
+13 ;
+14 NEW DADRFM,EDATA,EEND,EIN,EINDX,ETOT,NODE0,NODE1,NODE2,NODE4
+15 NEW TEND,TINDX,TOUR1,TOUR2,REGHRS1,REGHRS2
+16 ; New ordered arrays
NEW PT,PE,PO,PC
+17 SET NODE0=$GET(^PRST(458,PPIP,"E",DFN,"D",WDAY,0))
+18 ; Corrupted data
IF NODE0=""
SET QUIT=1
QUIT
+19 SET NODE2=$GET(^PRST(458,PPIP,"E",DFN,"D",WDAY,2))
+20 ;
+21 ; Skip Days off
+22 if $PIECE(NODE0,U,2)=1
QUIT
+23 ;
+24 ; Check for tours with no regular hours
+25 SET TOUR1=+$PIECE(NODE0,U,2)
SET TOUR2=+$PIECE(NODE0,U,13)
+26 SET REGHRS1=$PIECE($GET(^PRST(457.1,TOUR1,0)),U,6)
+27 SET REGHRS2=$SELECT(TOUR2:$PIECE($GET(^PRST(457.1,TOUR2,0)),U,6),1:"")
+28 if $PIECE(NODE0,U,2)'=2&($PIECE(NODE0,U,2)'=3)&(REGHRS1+REGHRS2=0)
QUIT
+29 ;
+30 ; If the day has a tour that defines work and there are no exceptions
+31 ; encapsulation is broken
+32 IF $PIECE(NODE0,U,2)>1
IF NODE2'["NP"
IF NODE2'["WP"
SET QUIT=1
QUIT
+33 ;
+34 ; Checks for employees with DAILY tours
+35 IF $PIECE(NODE0,U,2)=2!($PIECE(NODE0,U,2)=3)
SET DBH=PPIP_U_DFN_U_$PIECE(NODE2,U,3)
QUIT
+36 ;
+37 ; Load tours and convert to numeric equivalents
+38 ; This creates the ordered arrays
+39 SET DADRFM=1
+40 SET NODE1=$GET(^PRST(458,PPIP,"E",DFN,"D",WDAY,1))
+41 DO CNV96^PRSATP5(.NODE1,3,"PT",NODE0,.DADRFM)
+42 SET NODE4=$GET(^PRST(458,PPIP,"E",DFN,"D",WDAY,4))
+43 IF NODE4'=""
DO CNV96^PRSATP5(.NODE4,3,"PT",NODE0,.DADRFM)
+44 DO CNV96^PRSATP5(.NODE2,4,"PE",NODE0,.DADRFM)
+45 ;
+46 ; Identify end of tour
+47 SET TINDX=""
SET TINDX=$ORDER(PT(TINDX),-1)
+48 SET TEND=$PIECE(PT(TINDX),U,2)
+49 ;
+50 ; Loop backwards through ordered exceptions to see if last 15
+51 ; minutes of tour was non-pay
+52 SET (EINDX,EDATA)=""
+53 FOR EIN=1:1:7
Begin DoDot:1
+54 SET EINDX=$ORDER(PE(EINDX),-1)
+55 if EINDX=""
QUIT
+56 SET EDATA=PE(EINDX)
SET EEND=$PIECE(EDATA,U,2)
SET ETOT=$PIECE(EDATA,U,3)
+57 ; not last 15 minutes
if EEND'=TEND
QUIT
+58 ; last 15 wasn't non-pay
IF ETOT'="NP"&(ETOT'="WP")
SET QUIT=1
QUIT
+59 SET DBH=PPIP_U_WDAY_U_ETOT
End DoDot:1
if QUIT!(EINDX="")!(DBH'="")
QUIT
+60 IF DBH=""
SET QUIT=1
+61 QUIT