PRSATP8 ;HISC/MGD-Timekeeper Post Absence ;01/27/06
;;4.0;PAID;**102**;Sep 21, 1995
;
FNDHOL(PPIP,DFN,WDAY,HOL,QUIT) ;
; Procedure to determine if there was a holiday in a PP
; Will also check to see if there was any On-Call posted
; as an exception that abuts the scheduled tour and if
; the first/last 15 minutes of the On-call was worked
;
; Input:
; PPIP - IEN of Pay Period to be checked
; DFN - IEN of employee to be checked
; WDAY - Day to start looping backwards from
; HOL - null
; QUIT - null
;
; Output:
; HOL - IF not found = ""
; IF found = PPIP^WDAY^SOH
; PPIP - IEN of pay period containing the holiday
; WDAY - the day number on which the holiday occurs
; SOH - The status of the timecard containing the holiday
; QUIT - Will be set to 1 if the holiday encapsulation
; rules are broken
;
N DADRFM,HTAFTER,HTPRIOR,HTSTRT,HTEND,NODE0,NODE1,NODE2,NODE4
N REGHRS1,REGHRS2,SOH,TOUR1,TOUR2,TPPIP,TWDAY
N HT,HE,HO,HC,NT,NE,NO,NC,PT,PE,PO,PC ; New ordered arrays
S NODE0=$G(^PRST(458,PPIP,"E",DFN,"D",WDAY,0))
S SOH=$P($G(^PRST(458,PPIP,"E",DFN,0)),U,2)
S TPPIP=PPIP,TWDAY=WDAY
I NODE0="" S QUIT=1 Q ; Corrupted data
Q:$P(NODE0,U,2)=1 ; Scheduled day off
;
; 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)
;
; Quit if day has a tour with regular hours and it is not
; a holiday (#10.2)OBSERVED HOLIDAY
I REGHRS1,$P(NODE0,U,12)="" S QUIT=1 Q
;
; If the holiday has two tours, Timekeepers will post
I $P(NODE0,U,13)'="" S QUIT=1 Q
;
; Load Holiday exceptions and check for HW & HX
S NODE2=$G(^PRST(458,PPIP,"E",DFN,"D",WDAY,2))
I NODE2["HW" S QUIT=1 Q ; worked was performed on a holiday
I NODE2'["HX" S QUIT=1 Q ; no HX to convert
;
; Checks for employees with DAILY tours
I $P(NODE0,U,2)=2!($P(NODE0,U,2)=3) S HOL=PPIP_U_WDAY_U_SOH Q
;
; Load nodes 1, 4
S NODE1=$G(^PRST(458,PPIP,"E",DFN,"D",WDAY,1))
S NODE4=$G(^PRST(458,PPIP,"E",DFN,"D",WDAY,4))
;
; Convert Start/Stop times and create all
; ordered arrays
S DADRFM=1
D CNV96^PRSATP5(.NODE1,3,"HT",NODE0,.DADRFM)
I NODE4'="" D CNV96^PRSATP5(.NODE4,3,"HT",NODE0,.DADRFM)
D CNV96^PRSATP5(.NODE2,4,"HE",NODE0,.DADRFM)
;
; Get start/end times of holiday tour
S HTSTRT="",HTSTRT=$O(HT(HTSTRT))
S HTEND="",HTEND=$O(HT(HTEND),-1)
I HTEND S HTEND=$P(HT(HTEND),U,2)
;
; Load prior days info
S WDAY=WDAY-1
I WDAY=0 D Q:QUIT
. N BACK S BACK=0
. D GETPPP^PRSATP5(.PPIP,DFN,.WDAY,.BACK,.QUIT)
S NODE0=$G(^PRST(458,PPIP,"E",DFN,"D",WDAY,0))
S NODE1=$G(^PRST(458,PPIP,"E",DFN,"D",WDAY,1))
S DADRFM=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)
S NODE2=$G(^PRST(458,PPIP,"E",DFN,"D",WDAY,2))
D CNV96^PRSATP5(.NODE2,4,"PE",NODE0,.DADRFM)
;
; Load next day's info
S PPIP=TPPIP,WDAY=TWDAY+1
I WDAY=15 D Q:QUIT
. N NEXT S NEXT=0
. D GETNPP^PRSATP5(.PPIP,DFN,.WDAY,.NEXT,.QUIT)
S NODE0=$G(^PRST(458,PPIP,"E",DFN,"D",WDAY,0))
S NODE1=$G(^PRST(458,PPIP,"E",DFN,"D",WDAY,1))
S DADRFM=1
D CNV96^PRSATP5(.NODE1,3,"NT",NODE0,.DADRFM)
S NODE4=$G(^PRST(458,PPIP,"E",DFN,"D",WDAY,4))
I NODE4'="" D CNV96^PRSATP5(.NODE4,3,"NT",NODE0,.DADRFM)
S NODE2=$G(^PRST(458,PPIP,"E",DFN,"D",WDAY,2))
D CNV96^PRSATP5(.NODE2,4,"NE",NODE0,.DADRFM)
;
; init flags as 0 (false)
S HTPRIOR("OC")=0 ; time immediately prior to holiday tour was on-call
S HTPRIOR("WK")=0 ; time immediately prior to holiday tour was worked
S HTAFTER("OC")=0 ; time immediately after holiday tour was on-call
S HTAFTER("WK")=0 ; time immediately after holiday tour was worked
;
; check if on-call segments posted on prior day abut the holiday tour
I $$INCTM(HTSTRT-1+96,.PO) S HTPRIOR("OC")=1
I $$INCTM(HTEND+1+96,.PO) S HTAFTER("OC")=1
;
; check if on-call segments posted on holiday abut the holiday tour
I $$INCTM(HTSTRT-1,.HO) S HTPRIOR("OC")=1
I $$INCTM(HTEND+1,.HO) S HTAFTER("OC")=1
;
; check if on-call segments posted on next day abut the holiday tour
I $$INCTM(HTEND+1-96,.NO) S HTAFTER("OC")=1
;
; check if extra work segments posted on prior day abut the holiday tour
I $$INCTM(HTSTRT-1+96,.PC) S HTPRIOR("WK")=1
;
; check if extra work segments posted on holiday abut the holiday tour
I $$INCTM(HTSTRT-1,.HC) S HTPRIOR("WK")=1
I $$INCTM(HTEND+1,.HC) S HTAFTER("WK")=1
;
; check if extra work segments posted on next day abut the holiday tour
I $$INCTM(HTEND+1-96,.NC) S HTAFTER("WK")=1
;
; if call-back abuts the holiday tour then it is not considered encap.
I HTPRIOR("OC"),HTPRIOR("WK") S QUIT=1 Q ; call-back abuts beginning
I HTAFTER("OC"),HTAFTER("WK") S QUIT=1 Q ; call-back abuts end
;
; checks done so holiday excused is considered encapsulated by non-pay
S HOL=TPPIP_U_TWDAY_U_SOH
Q
;
INCTM(PRST,PRSARR) ; Includes Time Extrinsic Function
; determines if a time is included within any time segments in array
; input
; PRST - number that represents a time segment (1-192)
; PRSARR - array, passed by reference with following format
; PRSARR(start)=start^stop^type of time
; returns 1 if PRST included within a time segment or 0 if not
;
N RET,START,STOP
S RET=0 ; initialize return value
;
; loop thru array
I PRST>0 S START="" F S START=$O(PRSARR(START)) Q:START="" D Q:RET
. S STOP=$P(PRSARR(START),U,2)
. I PRST'<START,PRST'>STOP S RET=1 ; check if time included in segment
;
Q RET
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPRSATP8 5808 printed Dec 13, 2024@02:24:45 Page 2
PRSATP8 ;HISC/MGD-Timekeeper Post Absence ;01/27/06
+1 ;;4.0;PAID;**102**;Sep 21, 1995
+2 ;
FNDHOL(PPIP,DFN,WDAY,HOL,QUIT) ;
+1 ; Procedure to determine if there was a holiday in a PP
+2 ; Will also check to see if there was any On-Call posted
+3 ; as an exception that abuts the scheduled tour and if
+4 ; the first/last 15 minutes of the On-call was worked
+5 ;
+6 ; Input:
+7 ; PPIP - IEN of Pay Period to be checked
+8 ; DFN - IEN of employee to be checked
+9 ; WDAY - Day to start looping backwards from
+10 ; HOL - null
+11 ; QUIT - null
+12 ;
+13 ; Output:
+14 ; HOL - IF not found = ""
+15 ; IF found = PPIP^WDAY^SOH
+16 ; PPIP - IEN of pay period containing the holiday
+17 ; WDAY - the day number on which the holiday occurs
+18 ; SOH - The status of the timecard containing the holiday
+19 ; QUIT - Will be set to 1 if the holiday encapsulation
+20 ; rules are broken
+21 ;
+22 NEW DADRFM,HTAFTER,HTPRIOR,HTSTRT,HTEND,NODE0,NODE1,NODE2,NODE4
+23 NEW REGHRS1,REGHRS2,SOH,TOUR1,TOUR2,TPPIP,TWDAY
+24 ; New ordered arrays
NEW HT,HE,HO,HC,NT,NE,NO,NC,PT,PE,PO,PC
+25 SET NODE0=$GET(^PRST(458,PPIP,"E",DFN,"D",WDAY,0))
+26 SET SOH=$PIECE($GET(^PRST(458,PPIP,"E",DFN,0)),U,2)
+27 SET TPPIP=PPIP
SET TWDAY=WDAY
+28 ; Corrupted data
IF NODE0=""
SET QUIT=1
QUIT
+29 ; Scheduled day off
if $PIECE(NODE0,U,2)=1
QUIT
+30 ;
+31 ; Check for tours with no regular hours
+32 SET TOUR1=+$PIECE(NODE0,U,2)
SET TOUR2=+$PIECE(NODE0,U,13)
+33 SET REGHRS1=$PIECE($GET(^PRST(457.1,TOUR1,0)),U,6)
+34 SET REGHRS2=$SELECT(TOUR2:$PIECE($GET(^PRST(457.1,TOUR2,0)),U,6),1:"")
+35 if $PIECE(NODE0,U,2)'=2&($PIECE(NODE0,U,2)'=3)&(REGHRS1+REGHRS2=0)
QUIT
+36 ;
+37 ; Quit if day has a tour with regular hours and it is not
+38 ; a holiday (#10.2)OBSERVED HOLIDAY
+39 IF REGHRS1
IF $PIECE(NODE0,U,12)=""
SET QUIT=1
QUIT
+40 ;
+41 ; If the holiday has two tours, Timekeepers will post
+42 IF $PIECE(NODE0,U,13)'=""
SET QUIT=1
QUIT
+43 ;
+44 ; Load Holiday exceptions and check for HW & HX
+45 SET NODE2=$GET(^PRST(458,PPIP,"E",DFN,"D",WDAY,2))
+46 ; worked was performed on a holiday
IF NODE2["HW"
SET QUIT=1
QUIT
+47 ; no HX to convert
IF NODE2'["HX"
SET QUIT=1
QUIT
+48 ;
+49 ; Checks for employees with DAILY tours
+50 IF $PIECE(NODE0,U,2)=2!($PIECE(NODE0,U,2)=3)
SET HOL=PPIP_U_WDAY_U_SOH
QUIT
+51 ;
+52 ; Load nodes 1, 4
+53 SET NODE1=$GET(^PRST(458,PPIP,"E",DFN,"D",WDAY,1))
+54 SET NODE4=$GET(^PRST(458,PPIP,"E",DFN,"D",WDAY,4))
+55 ;
+56 ; Convert Start/Stop times and create all
+57 ; ordered arrays
+58 SET DADRFM=1
+59 DO CNV96^PRSATP5(.NODE1,3,"HT",NODE0,.DADRFM)
+60 IF NODE4'=""
DO CNV96^PRSATP5(.NODE4,3,"HT",NODE0,.DADRFM)
+61 DO CNV96^PRSATP5(.NODE2,4,"HE",NODE0,.DADRFM)
+62 ;
+63 ; Get start/end times of holiday tour
+64 SET HTSTRT=""
SET HTSTRT=$ORDER(HT(HTSTRT))
+65 SET HTEND=""
SET HTEND=$ORDER(HT(HTEND),-1)
+66 IF HTEND
SET HTEND=$PIECE(HT(HTEND),U,2)
+67 ;
+68 ; Load prior days info
+69 SET WDAY=WDAY-1
+70 IF WDAY=0
Begin DoDot:1
+71 NEW BACK
SET BACK=0
+72 DO GETPPP^PRSATP5(.PPIP,DFN,.WDAY,.BACK,.QUIT)
End DoDot:1
if QUIT
QUIT
+73 SET NODE0=$GET(^PRST(458,PPIP,"E",DFN,"D",WDAY,0))
+74 SET NODE1=$GET(^PRST(458,PPIP,"E",DFN,"D",WDAY,1))
+75 SET DADRFM=1
+76 DO CNV96^PRSATP5(.NODE1,3,"PT",NODE0,.DADRFM)
+77 SET NODE4=$GET(^PRST(458,PPIP,"E",DFN,"D",WDAY,4))
+78 IF NODE4'=""
DO CNV96^PRSATP5(.NODE4,3,"PT",NODE0,.DADRFM)
+79 SET NODE2=$GET(^PRST(458,PPIP,"E",DFN,"D",WDAY,2))
+80 DO CNV96^PRSATP5(.NODE2,4,"PE",NODE0,.DADRFM)
+81 ;
+82 ; Load next day's info
+83 SET PPIP=TPPIP
SET WDAY=TWDAY+1
+84 IF WDAY=15
Begin DoDot:1
+85 NEW NEXT
SET NEXT=0
+86 DO GETNPP^PRSATP5(.PPIP,DFN,.WDAY,.NEXT,.QUIT)
End DoDot:1
if QUIT
QUIT
+87 SET NODE0=$GET(^PRST(458,PPIP,"E",DFN,"D",WDAY,0))
+88 SET NODE1=$GET(^PRST(458,PPIP,"E",DFN,"D",WDAY,1))
+89 SET DADRFM=1
+90 DO CNV96^PRSATP5(.NODE1,3,"NT",NODE0,.DADRFM)
+91 SET NODE4=$GET(^PRST(458,PPIP,"E",DFN,"D",WDAY,4))
+92 IF NODE4'=""
DO CNV96^PRSATP5(.NODE4,3,"NT",NODE0,.DADRFM)
+93 SET NODE2=$GET(^PRST(458,PPIP,"E",DFN,"D",WDAY,2))
+94 DO CNV96^PRSATP5(.NODE2,4,"NE",NODE0,.DADRFM)
+95 ;
+96 ; init flags as 0 (false)
+97 ; time immediately prior to holiday tour was on-call
SET HTPRIOR("OC")=0
+98 ; time immediately prior to holiday tour was worked
SET HTPRIOR("WK")=0
+99 ; time immediately after holiday tour was on-call
SET HTAFTER("OC")=0
+100 ; time immediately after holiday tour was worked
SET HTAFTER("WK")=0
+101 ;
+102 ; check if on-call segments posted on prior day abut the holiday tour
+103 IF $$INCTM(HTSTRT-1+96,.PO)
SET HTPRIOR("OC")=1
+104 IF $$INCTM(HTEND+1+96,.PO)
SET HTAFTER("OC")=1
+105 ;
+106 ; check if on-call segments posted on holiday abut the holiday tour
+107 IF $$INCTM(HTSTRT-1,.HO)
SET HTPRIOR("OC")=1
+108 IF $$INCTM(HTEND+1,.HO)
SET HTAFTER("OC")=1
+109 ;
+110 ; check if on-call segments posted on next day abut the holiday tour
+111 IF $$INCTM(HTEND+1-96,.NO)
SET HTAFTER("OC")=1
+112 ;
+113 ; check if extra work segments posted on prior day abut the holiday tour
+114 IF $$INCTM(HTSTRT-1+96,.PC)
SET HTPRIOR("WK")=1
+115 ;
+116 ; check if extra work segments posted on holiday abut the holiday tour
+117 IF $$INCTM(HTSTRT-1,.HC)
SET HTPRIOR("WK")=1
+118 IF $$INCTM(HTEND+1,.HC)
SET HTAFTER("WK")=1
+119 ;
+120 ; check if extra work segments posted on next day abut the holiday tour
+121 IF $$INCTM(HTEND+1-96,.NC)
SET HTAFTER("WK")=1
+122 ;
+123 ; if call-back abuts the holiday tour then it is not considered encap.
+124 ; call-back abuts beginning
IF HTPRIOR("OC")
IF HTPRIOR("WK")
SET QUIT=1
QUIT
+125 ; call-back abuts end
IF HTAFTER("OC")
IF HTAFTER("WK")
SET QUIT=1
QUIT
+126 ;
+127 ; checks done so holiday excused is considered encapsulated by non-pay
+128 SET HOL=TPPIP_U_TWDAY_U_SOH
+129 QUIT
+130 ;
INCTM(PRST,PRSARR) ; Includes Time Extrinsic Function
+1 ; determines if a time is included within any time segments in array
+2 ; input
+3 ; PRST - number that represents a time segment (1-192)
+4 ; PRSARR - array, passed by reference with following format
+5 ; PRSARR(start)=start^stop^type of time
+6 ; returns 1 if PRST included within a time segment or 0 if not
+7 ;
+8 NEW RET,START,STOP
+9 ; initialize return value
SET RET=0
+10 ;
+11 ; loop thru array
+12 IF PRST>0
SET START=""
FOR
SET START=$ORDER(PRSARR(START))
if START=""
QUIT
Begin DoDot:1
+13 SET STOP=$PIECE(PRSARR(START),U,2)
+14 ; check if time included in segment
IF PRST'<START
IF PRST'>STOP
SET RET=1
End DoDot:1
if RET
QUIT
+15 ;
+16 QUIT RET