PRS8PP ;HISC/MRL,WIRMFO/MGD-DECOMP, PREMIUM PAYS ;05/10/07
;;4.0;PAID;**22,40,75,92,96,112,117**;Sep 21, 1995;Build 32
;;Per VHA Directive 2004-038, this routine should not be modified.
;
;This routine is the entry point for determining certain premium
;pays for an employee. Included are overtime (OT),
;night differential (ND), unscheduled hours (UH), etc.
;
;Called by Routines: PRS8ST
;
S D=DAY(DAY,"W") ; Daily activity string.
S W=$S(DAY<8:1,1:2) ; Week.
I D?1"0"."0" Q ; No activity this date.
S NDC=1,(HT,HTP,HTFFOT)=0 ; Counter for hrs worked this
; day (HT=Hours total).
N HYBRID ; HYBRID under P.L 107-135
S HYBRID=$$HYBRID^PRSAENT1($G(DFN))
D ^PRS8HR ; calculate Norm hrs first
F M=1:1:96 S VAL=$E(D,M) I VAL'=0 D ;loop thru minutes of day
.S DH=DAY(DAY,"DH1")
.I TWO,M'<+$P(DAY(DAY,"TWO"),"^",2) S DH=DAY(DAY,"DH2") ; Daily hrs.
.I NDC,"CWB"'[VAL D ND ; Get ND.
.I TYP["B",+VAL Q ; Baylor get no premium during tod.
.I "1234OosEe"'[VAL Q ; Don't chk for non-work status.
.S X=$E(D,M,96) ; Remainder of day.
.I X?1N.N,X'[4 Q ; No hrs left other than normal.
.I "J123MLSWNARXYOFGD"'[VAL!(VAL="O"&($E(DAY(DAY,"HOL"),M)'=2)) S AV="OosEe" D CALC^PRS8HR
K AV,D,GO,M,NDC,X,X1,J1,J2 Q
;
ND ; --- compute ND
; Process wagegrade
I TYP["W" D Q
. ; process WG scheduled time
. I "J23LSARMXYUVFGDZq"[VAL!(VAL="O"&($E(DAY(DAY,"HOL"),M)=2)) D
. . N DAT,DAYN,FND,M1,NODE,SC,TS
. . ; find tour segment that contains the time and get it's special code
. . S FND=0,SC="" ; FND true if found in schedule, SC = special code
. . ; look in schedule of current day for M and previous day for M+96
. . ; (in 2day tour, previous day's schedules >96 are Today's activity)
. . F DAYN=DAY,DAY-1 D Q:FND
. . . S M1=$S(DAYN=DAY:M,1:M+96)
. . . ; loop thru both tours in day
. . . F NODE=1,4 S DAT=$G(^TMP($J,"PRS8",DAYN,NODE)) Q:DAT="" D Q:FND
. . . . ; loop thru tour segments in tour
. . . . F TS=1:1:7 Q:$P(DAT,U,(TS-1)*3+1)="" D Q:FND
. . . . . ; check if time contained in tour segment
. . . . . I M1'<$P(DAT,U,(TS-1)*3+1),M1'>$P(DAT,U,(TS-1)*3+2) S FND=1,SC=$P(DAT,U,(TS-1)*3+3)
. . ;
. . ; if time not found in any schedule, base SC on value of variable
. . ; TOUR for Today (or previous day when no scheduled tour Today).
. . I 'FND S SC=$S($G(^TMP($J,"PRS8",DAY,1))=""&(DAY(DAY-1,"TOUR")>1):DAY(DAY-1,"TOUR")+4,1:TOUR+4)
. . Q:"^6^7^"'[(U_SC_U) ; tour segment not coded for shift 2 or 3
. . S X=(SC-4)+8 ; determine where to store in WK array
. . I $E(ENT,X-4) D SET ; if employee entitled then store result
. ;
. ; process WG unscheduled time
. I VAL=4!(VAL="O") D
. . N T,SD
. . ; unscheduled regular tours for 'shift coverage' that are eligible
. . ; for shift 2 or 3 differential were saved in "SD" by PRS8EX.
. . S SD=$G(^TMP($J,"PRS8",DAY,"SD"))
. . Q:SD=""
. . ; see if time belongs to a tour saved in "SD" and if so use the
. . ; associated shift (2 or 3)
. . S SD(1)=0 ; init shift
. . F T=1:3 S SD(0)=$P(SD,U,T,T+2) Q:SD(0)=""!(SD(0)?1."^") D Q:SD(1)
. . . I M'<+SD(0),M'>$P(SD(0),"^",2) S SD(1)=$P(SD(0),"^",3)
. . I SD(1) S X=SD(1)+8 I $E(ENT,X-4) D SET
;
; Process Other Employees (non-Wage Grade)
;
; Not entitled to ND
I '$E(ENT,6) Q
;
; not entitled to ND if No Premium Pay tour
I $P(DAY(DAY,1),"^",3)=8 Q
;
; check if time segment could be eligible for ND
I $$NOTND(TYP,DAY,M) Q
;
S AV="J1234ALSRMUEOosecbVXYFGDZq"
;
; Grant ND for time before 6a/after 6p or anytime when nurse/hybrid
; works tour coverage
I M<25!(M>72)!($E(DAY(DAY,"P"),M)="N"&(TYP["N"!(TYP["H")!(HYBRID))),AV[VAL D
. ; The Hybrids defined in Public Law 107-135 will only receive Night
. ; Differential time for OT and CT worked between 6 p.m. and 6 a.m.
. Q:HYBRID!(PMP'=""&("^S^T^U^V^"[(U_PMP_U)))&(M'<25&(M'>72))
. ; Tour time between 6 p.m. and 6 a.m. counts toward ND
. N DAT,DAYN,FND,M1,NODE,SC,TS,TOT
. ; find tour segment that contains the time and get it's special code
. S FND=0,SC="" ; FND true if found in schedule, SC = special code
. S TOT="" ; Type Of Time
. ; look in schedule of current day for M and previous day for M+96
. ; (in 2day tour, previous day's schedules >96 are Today's activity)
. F DAYN=DAY,DAY-1 D Q:FND
. . S M1=$S(DAYN=DAY:M,1:M+96)
. . S DAT=$G(^TMP($J,"PRS8",DAYN,2)) D Q:FND
. . . ; loop thru tour segments in exceptions
. . . F TS=1:1:7 Q:$P(DAT,U,(TS-1)*4+1)="" D Q:FND
. . . . ; check if time contained in exception segment
. . . . I M1'<$P(DAT,U,(TS-1)*4+1),M1'>$P(DAT,U,(TS-1)*4+2) D
. . . . . S TOT=$P(DAT,U,(TS-1)*4+3)
. . . . . ; On-Call and Recess are the only types of exceptions
. . . . . ; where OT, CT and RG can be posted for the same 15 minute
. . . . . ; segment of time, so don't stop searching if you find these.
. . . . . I TOT="ON"!(TOT="RS") S TOT="" Q
. . . . . S FND=1,SC=$P(DAT,U,(TS-1)*4+4)
. . . . . Q
. Q:TOT="OT"&("^11^12^17^"'[(U_SC_U)) ; Pre-Scheduled & Tour Coverage & OT/CT With Premiums
. Q:TOT="CT"&("^12^17^"'[(U_SC_U)) ; Tour Coverage & OT/CT With Premiums
. ; Code 17 - OT/CT with premiums only get ND for 6p-6a
. Q:TOT="OT"!(TOT="CT")!(TOT="RG")&(SC=17)&((M'<25)&(M'>72))
. Q:TOT="RG"&(SC'=7)&(SC'=17) ; Shift Coverage & OT/CT With Premiums
. S X=10
. ; for 36/40 AWS, premium time resulting from their tour
. ; will be mapped to Night Differential-AWS (ND/NU) and
. ; Paid at the AAC with the 1872 divisor for the hourly rate (36*52)
. I +NAWS=36,("OEc"'[VAL!(TOT="HW")) S X=51
. D SET
. ; keep leave count since it may need to be backed out by PRS8MSC0
. I "LSRUFGDZq"[VAL S WKL(WK)=WKL(WK)+1
;
; Nurse can get ND for 6a-6p time when part of tour with 4+ hrs in 6p-6a
; check is made when M=24 (just before 6am) or M=73 (just after 6pm).
; if tour eligible (4+ hours in 'night' time) then ND is granted for
; the portion of the tour that falls within the 'day' time.
I TYP["N"!(TYP["H"),M=73!(M=24),AV_"m"[VAL D
. N C,J,Q,X,X1,X2,XD
. ;
. ; quit if 'day' time is for tour coverage since already counted
. I $E(DAY(DAY,"P"),$S(M=73:72,1:25))="N" Q
. ;
. ; first check if tour has at least 4 hours of 'night' (6pm-6am) time
. S XD=$S(M=24:-1,1:1) ; loop direction, [6am back, 6pm forward]
. S X1=M,X2=X1+(XD*15) ; start and stop of 4 hour range
. ; loop thru tour 'night' time - stop if tour ends or after 4 hours
. S C=1 ; init flag, false when tour has less than 4 hours of 'night'
. F J=X1:XD:X2 D Q:'C
. . I AV_"m"'[$E(D,J) S C=0 Q ; inappropriate type of time
. . I $$NOTND(TYP,DAY,J) S C=0 Q
. . ; scheduled TOD considered as separate from covered TOD
. . I $E(DAY(DAY,"P"),M)'=$E(DAY(DAY,"P"),J) S C=0 Q
. ;
. Q:'C ; tour not eligible (less than 4 hours of 'night')
. ;
. ; loop thru day time (6am-6pm) portion of tour and grant ND
. ; don't pay ND for meal-time (m) but continue loop
. S XD=$S(M=24:1,1:-1) ; loop direction [6am forward, 6pm back]
. S X1=M+XD,X2=X1+(47*XD) ; start and stop for day time (12 hours)
. S Q=0 ; init flag, true when end of tour reached
. F J=X1:XD:X2 D Q:Q
. . I AV_"m"'[$E(D,J) S Q=1 Q ; inappropriate time
. . I $$NOTND(TYP,DAY,J) S Q=1 Q
. . ; scheduled TOD considered as separate from covered TOD
. . I $E(DAY(DAY,"P"),M)'=$E(DAY(DAY,"P"),J) S Q=1 Q
. . ; grant ND (unless meal-time, etc.), keep count of leave since it
. . ; may need to be backed out by PRS8MSC0
. . I AV[$E(D,J) D
. . . S X=10
. . . ; For 36/46 AWS nurses ND for Holiday Worked (HA/HL) and normal
. . . ; tour time will be reported as Night Differential-AWS (ND/NU)
. . . I +NAWS=36 D
. . . . I $E(DAY(DAY,"HOL"),J)=2 S X=51 Q ; Holiday Worked
. . . . I "OEc"'[VAL S X=51 ; Tour time
. . . D SET
. . . S:"LSRUFGDZq"[$E(D,J) WKL(WK)=WKL(WK)+1
;
Q
;
SETJ ; --- set week node (J variable defined)
Q:$E(D,J)="m"
;
SET ; --- actually set the piece
S $P(WK(WK),"^",X)=$P(WK(WK),"^",X)+1
Q
;
NOTND(PRSTY,PRSDY,PRSTM) ; Not Eligible Night Differential
; in PRSTY type of employee
; PRSDY day (1-14)
; PRSTM time segment (1-96)
; returns 0 or 1 (True when not eligible for ND)
;
N VAL
S VAL=$E(DAY(PRSDY,"W"),PRSTM)
;
; not entitled to ND
I ($E(DAY(PRSDY,"P"),PRSTM)=5) Q 1
;
; OT on non-premium T&L
I "EOosecb"[VAL,$E(DAY(PRSDY,"P"),PRSTM),VAL'="O"!(VAL="O"&($E(DAY(PRSDY,"HOL"),PRSTM)'=2)) Q 1
;
; Nurses do not get ND for OT that is not for ND Tour Coverage
I "Ecb"[VAL!(VAL="O"&'$E(DAY(PRSDY,"HOL"),PRSTM)),PRSTY["N"!(PRSTY["H")!(HYBRID)!("^S^T^U^V^"[(U_PMP_U)),$E(DAY(PRSDY,"P"),PRSTM)'="N" Q 1
;
; Baylor gets no ND for work time on regularly scheduled day
I TYP["B","^1^7^8^14^"[("^"_DAY_"^"),"1234ALSRMUNVXYFGDZq"[VAL Q 1
;
; GS Employees do not get ND for OT that is not Pre-Scheduled
I "Ecb"[VAL!(VAL="O"&'$E(DAY(PRSDY,"HOL"),PRSTM)),PRSTY'["N",PRSTY'["H",'HYBRID,("^S^T^U^V^"'[(U_PMP_U)),$E(DAY(PRSDY,"P"),PRSTM)'="n" Q 1
;
; Unsch Reg time needs to be Pre-scheduled to get ND
I VAL=4,PRSTY["P"!(PRSTY["I"&(PRSTY["N"!(PRSTY["H"))),"Nn"'[$E(DAY(PRSDY,"P"),PRSTM) Q 1
Q 0 ; did not fail any of the checks
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPRS8PP 9494 printed Dec 13, 2024@02:22:58 Page 2
PRS8PP ;HISC/MRL,WIRMFO/MGD-DECOMP, PREMIUM PAYS ;05/10/07
+1 ;;4.0;PAID;**22,40,75,92,96,112,117**;Sep 21, 1995;Build 32
+2 ;;Per VHA Directive 2004-038, this routine should not be modified.
+3 ;
+4 ;This routine is the entry point for determining certain premium
+5 ;pays for an employee. Included are overtime (OT),
+6 ;night differential (ND), unscheduled hours (UH), etc.
+7 ;
+8 ;Called by Routines: PRS8ST
+9 ;
+10 ; Daily activity string.
SET D=DAY(DAY,"W")
+11 ; Week.
SET W=$SELECT(DAY<8:1,1:2)
+12 ; No activity this date.
IF D?1"0"."0"
QUIT
+13 ; Counter for hrs worked this
SET NDC=1
SET (HT,HTP,HTFFOT)=0
+14 ; day (HT=Hours total).
+15 ; HYBRID under P.L 107-135
NEW HYBRID
+16 SET HYBRID=$$HYBRID^PRSAENT1($GET(DFN))
+17 ; calculate Norm hrs first
DO ^PRS8HR
+18 ;loop thru minutes of day
FOR M=1:1:96
SET VAL=$EXTRACT(D,M)
IF VAL'=0
Begin DoDot:1
+19 SET DH=DAY(DAY,"DH1")
+20 ; Daily hrs.
IF TWO
IF M'<+$PIECE(DAY(DAY,"TWO"),"^",2)
SET DH=DAY(DAY,"DH2")
+21 ; Get ND.
IF NDC
IF "CWB"'[VAL
DO ND
+22 ; Baylor get no premium during tod.
IF TYP["B"
IF +VAL
QUIT
+23 ; Don't chk for non-work status.
IF "1234OosEe"'[VAL
QUIT
+24 ; Remainder of day.
SET X=$EXTRACT(D,M,96)
+25 ; No hrs left other than normal.
IF X?1N.N
IF X'[4
QUIT
+26 IF "J123MLSWNARXYOFGD"'[VAL!(VAL="O"&($EXTRACT(DAY(DAY,"HOL"),M)'=2))
SET AV="OosEe"
DO CALC^PRS8HR
End DoDot:1
+27 KILL AV,D,GO,M,NDC,X,X1,J1,J2
QUIT
+28 ;
ND ; --- compute ND
+1 ; Process wagegrade
+2 IF TYP["W"
Begin DoDot:1
+3 ; process WG scheduled time
+4 IF "J23LSARMXYUVFGDZq"[VAL!(VAL="O"&($EXTRACT(DAY(DAY,"HOL"),M)=2))
Begin DoDot:2
+5 NEW DAT,DAYN,FND,M1,NODE,SC,TS
+6 ; find tour segment that contains the time and get it's special code
+7 ; FND true if found in schedule, SC = special code
SET FND=0
SET SC=""
+8 ; look in schedule of current day for M and previous day for M+96
+9 ; (in 2day tour, previous day's schedules >96 are Today's activity)
+10 FOR DAYN=DAY,DAY-1
Begin DoDot:3
+11 SET M1=$SELECT(DAYN=DAY:M,1:M+96)
+12 ; loop thru both tours in day
+13 FOR NODE=1,4
SET DAT=$GET(^TMP($JOB,"PRS8",DAYN,NODE))
if DAT=""
QUIT
Begin DoDot:4
+14 ; loop thru tour segments in tour
+15 FOR TS=1:1:7
if $PIECE(DAT,U,(TS-1)*3+1)=""
QUIT
Begin DoDot:5
+16 ; check if time contained in tour segment
+17 IF M1'<$PIECE(DAT,U,(TS-1)*3+1)
IF M1'>$PIECE(DAT,U,(TS-1)*3+2)
SET FND=1
SET SC=$PIECE(DAT,U,(TS-1)*3+3)
End DoDot:5
if FND
QUIT
End DoDot:4
if FND
QUIT
End DoDot:3
if FND
QUIT
+18 ;
+19 ; if time not found in any schedule, base SC on value of variable
+20 ; TOUR for Today (or previous day when no scheduled tour Today).
+21 IF 'FND
SET SC=$SELECT($GET(^TMP($JOB,"PRS8",DAY,1))=""&(DAY(DAY-1,"TOUR")>1):DAY(DAY-1,"TOUR")+4,1:TOUR+4)
+22 ; tour segment not coded for shift 2 or 3
if "^6^7^"'[(U_SC_U)
QUIT
+23 ; determine where to store in WK array
SET X=(SC-4)+8
+24 ; if employee entitled then store result
IF $EXTRACT(ENT,X-4)
DO SET
End DoDot:2
+25 ;
+26 ; process WG unscheduled time
+27 IF VAL=4!(VAL="O")
Begin DoDot:2
+28 NEW T,SD
+29 ; unscheduled regular tours for 'shift coverage' that are eligible
+30 ; for shift 2 or 3 differential were saved in "SD" by PRS8EX.
+31 SET SD=$GET(^TMP($JOB,"PRS8",DAY,"SD"))
+32 if SD=""
QUIT
+33 ; see if time belongs to a tour saved in "SD" and if so use the
+34 ; associated shift (2 or 3)
+35 ; init shift
SET SD(1)=0
+36 FOR T=1:3
SET SD(0)=$PIECE(SD,U,T,T+2)
if SD(0)=""!(SD(0)?1."^")
QUIT
Begin DoDot:3
+37 IF M'<+SD(0)
IF M'>$PIECE(SD(0),"^",2)
SET SD(1)=$PIECE(SD(0),"^",3)
End DoDot:3
if SD(1)
QUIT
+38 IF SD(1)
SET X=SD(1)+8
IF $EXTRACT(ENT,X-4)
DO SET
End DoDot:2
End DoDot:1
QUIT
+39 ;
+40 ; Process Other Employees (non-Wage Grade)
+41 ;
+42 ; Not entitled to ND
+43 IF '$EXTRACT(ENT,6)
QUIT
+44 ;
+45 ; not entitled to ND if No Premium Pay tour
+46 IF $PIECE(DAY(DAY,1),"^",3)=8
QUIT
+47 ;
+48 ; check if time segment could be eligible for ND
+49 IF $$NOTND(TYP,DAY,M)
QUIT
+50 ;
+51 SET AV="J1234ALSRMUEOosecbVXYFGDZq"
+52 ;
+53 ; Grant ND for time before 6a/after 6p or anytime when nurse/hybrid
+54 ; works tour coverage
+55 IF M<25!(M>72)!($EXTRACT(DAY(DAY,"P"),M)="N"&(TYP["N"!(TYP["H")!(HYBRID)))
IF AV[VAL
Begin DoDot:1
+56 ; The Hybrids defined in Public Law 107-135 will only receive Night
+57 ; Differential time for OT and CT worked between 6 p.m. and 6 a.m.
+58 if HYBRID!(PMP'=""&("^S^T^U^V^"[(U_PMP_U)))&(M'<25&(M'>72))
QUIT
+59 ; Tour time between 6 p.m. and 6 a.m. counts toward ND
+60 NEW DAT,DAYN,FND,M1,NODE,SC,TS,TOT
+61 ; find tour segment that contains the time and get it's special code
+62 ; FND true if found in schedule, SC = special code
SET FND=0
SET SC=""
+63 ; Type Of Time
SET TOT=""
+64 ; look in schedule of current day for M and previous day for M+96
+65 ; (in 2day tour, previous day's schedules >96 are Today's activity)
+66 FOR DAYN=DAY,DAY-1
Begin DoDot:2
+67 SET M1=$SELECT(DAYN=DAY:M,1:M+96)
+68 SET DAT=$GET(^TMP($JOB,"PRS8",DAYN,2))
Begin DoDot:3
+69 ; loop thru tour segments in exceptions
+70 FOR TS=1:1:7
if $PIECE(DAT,U,(TS-1)*4+1)=""
QUIT
Begin DoDot:4
+71 ; check if time contained in exception segment
+72 IF M1'<$PIECE(DAT,U,(TS-1)*4+1)
IF M1'>$PIECE(DAT,U,(TS-1)*4+2)
Begin DoDot:5
+73 SET TOT=$PIECE(DAT,U,(TS-1)*4+3)
+74 ; On-Call and Recess are the only types of exceptions
+75 ; where OT, CT and RG can be posted for the same 15 minute
+76 ; segment of time, so don't stop searching if you find these.
+77 IF TOT="ON"!(TOT="RS")
SET TOT=""
QUIT
+78 SET FND=1
SET SC=$PIECE(DAT,U,(TS-1)*4+4)
+79 QUIT
End DoDot:5
End DoDot:4
if FND
QUIT
End DoDot:3
if FND
QUIT
End DoDot:2
if FND
QUIT
+80 ; Pre-Scheduled & Tour Coverage & OT/CT With Premiums
if TOT="OT"&("^11^12^17^"'[(U_SC_U))
QUIT
+81 ; Tour Coverage & OT/CT With Premiums
if TOT="CT"&("^12^17^"'[(U_SC_U))
QUIT
+82 ; Code 17 - OT/CT with premiums only get ND for 6p-6a
+83 if TOT="OT"!(TOT="CT")!(TOT="RG")&(SC=17)&((M'<25)&(M'>72))
QUIT
+84 ; Shift Coverage & OT/CT With Premiums
if TOT="RG"&(SC'=7)&(SC'=17)
QUIT
+85 SET X=10
+86 ; for 36/40 AWS, premium time resulting from their tour
+87 ; will be mapped to Night Differential-AWS (ND/NU) and
+88 ; Paid at the AAC with the 1872 divisor for the hourly rate (36*52)
+89 IF +NAWS=36
IF ("OEc"'[VAL!(TOT="HW"))
SET X=51
+90 DO SET
+91 ; keep leave count since it may need to be backed out by PRS8MSC0
+92 IF "LSRUFGDZq"[VAL
SET WKL(WK)=WKL(WK)+1
End DoDot:1
+93 ;
+94 ; Nurse can get ND for 6a-6p time when part of tour with 4+ hrs in 6p-6a
+95 ; check is made when M=24 (just before 6am) or M=73 (just after 6pm).
+96 ; if tour eligible (4+ hours in 'night' time) then ND is granted for
+97 ; the portion of the tour that falls within the 'day' time.
+98 IF TYP["N"!(TYP["H")
IF M=73!(M=24)
IF AV_"m"[VAL
Begin DoDot:1
+99 NEW C,J,Q,X,X1,X2,XD
+100 ;
+101 ; quit if 'day' time is for tour coverage since already counted
+102 IF $EXTRACT(DAY(DAY,"P"),$SELECT(M=73:72,1:25))="N"
QUIT
+103 ;
+104 ; first check if tour has at least 4 hours of 'night' (6pm-6am) time
+105 ; loop direction, [6am back, 6pm forward]
SET XD=$SELECT(M=24:-1,1:1)
+106 ; start and stop of 4 hour range
SET X1=M
SET X2=X1+(XD*15)
+107 ; loop thru tour 'night' time - stop if tour ends or after 4 hours
+108 ; init flag, false when tour has less than 4 hours of 'night'
SET C=1
+109 FOR J=X1:XD:X2
Begin DoDot:2
+110 ; inappropriate type of time
IF AV_"m"'[$EXTRACT(D,J)
SET C=0
QUIT
+111 IF $$NOTND(TYP,DAY,J)
SET C=0
QUIT
+112 ; scheduled TOD considered as separate from covered TOD
+113 IF $EXTRACT(DAY(DAY,"P"),M)'=$EXTRACT(DAY(DAY,"P"),J)
SET C=0
QUIT
End DoDot:2
if 'C
QUIT
+114 ;
+115 ; tour not eligible (less than 4 hours of 'night')
if 'C
QUIT
+116 ;
+117 ; loop thru day time (6am-6pm) portion of tour and grant ND
+118 ; don't pay ND for meal-time (m) but continue loop
+119 ; loop direction [6am forward, 6pm back]
SET XD=$SELECT(M=24:1,1:-1)
+120 ; start and stop for day time (12 hours)
SET X1=M+XD
SET X2=X1+(47*XD)
+121 ; init flag, true when end of tour reached
SET Q=0
+122 FOR J=X1:XD:X2
Begin DoDot:2
+123 ; inappropriate time
IF AV_"m"'[$EXTRACT(D,J)
SET Q=1
QUIT
+124 IF $$NOTND(TYP,DAY,J)
SET Q=1
QUIT
+125 ; scheduled TOD considered as separate from covered TOD
+126 IF $EXTRACT(DAY(DAY,"P"),M)'=$EXTRACT(DAY(DAY,"P"),J)
SET Q=1
QUIT
+127 ; grant ND (unless meal-time, etc.), keep count of leave since it
+128 ; may need to be backed out by PRS8MSC0
+129 IF AV[$EXTRACT(D,J)
Begin DoDot:3
+130 SET X=10
+131 ; For 36/46 AWS nurses ND for Holiday Worked (HA/HL) and normal
+132 ; tour time will be reported as Night Differential-AWS (ND/NU)
+133 IF +NAWS=36
Begin DoDot:4
+134 ; Holiday Worked
IF $EXTRACT(DAY(DAY,"HOL"),J)=2
SET X=51
QUIT
+135 ; Tour time
IF "OEc"'[VAL
SET X=51
End DoDot:4
+136 DO SET
+137 if "LSRUFGDZq"[$EXTRACT(D,J)
SET WKL(WK)=WKL(WK)+1
End DoDot:3
End DoDot:2
if Q
QUIT
End DoDot:1
+138 ;
+139 QUIT
+140 ;
SETJ ; --- set week node (J variable defined)
+1 if $EXTRACT(D,J)="m"
QUIT
+2 ;
SET ; --- actually set the piece
+1 SET $PIECE(WK(WK),"^",X)=$PIECE(WK(WK),"^",X)+1
+2 QUIT
+3 ;
NOTND(PRSTY,PRSDY,PRSTM) ; Not Eligible Night Differential
+1 ; in PRSTY type of employee
+2 ; PRSDY day (1-14)
+3 ; PRSTM time segment (1-96)
+4 ; returns 0 or 1 (True when not eligible for ND)
+5 ;
+6 NEW VAL
+7 SET VAL=$EXTRACT(DAY(PRSDY,"W"),PRSTM)
+8 ;
+9 ; not entitled to ND
+10 IF ($EXTRACT(DAY(PRSDY,"P"),PRSTM)=5)
QUIT 1
+11 ;
+12 ; OT on non-premium T&L
+13 IF "EOosecb"[VAL
IF $EXTRACT(DAY(PRSDY,"P"),PRSTM)
IF VAL'="O"!(VAL="O"&($EXTRACT(DAY(PRSDY,"HOL"),PRSTM)'=2))
QUIT 1
+14 ;
+15 ; Nurses do not get ND for OT that is not for ND Tour Coverage
+16 IF "Ecb"[VAL!(VAL="O"&'$EXTRACT(DAY(PRSDY,"HOL"),PRSTM))
IF PRSTY["N"!(PRSTY["H")!(HYBRID)!("^S^T^U^V^"[(U_PMP_U))
IF $EXTRACT(DAY(PRSDY,"P"),PRSTM)'="N"
QUIT 1
+17 ;
+18 ; Baylor gets no ND for work time on regularly scheduled day
+19 IF TYP["B"
IF "^1^7^8^14^"[("^"_DAY_"^")
IF "1234ALSRMUNVXYFGDZq"[VAL
QUIT 1
+20 ;
+21 ; GS Employees do not get ND for OT that is not Pre-Scheduled
+22 IF "Ecb"[VAL!(VAL="O"&'$EXTRACT(DAY(PRSDY,"HOL"),PRSTM))
IF PRSTY'["N"
IF PRSTY'["H"
IF 'HYBRID
IF ("^S^T^U^V^"'[(U_PMP_U))
IF $EXTRACT(DAY(PRSDY,"P"),PRSTM)'="n"
QUIT 1
+23 ;
+24 ; Unsch Reg time needs to be Pre-scheduled to get ND
+25 IF VAL=4
IF PRSTY["P"!(PRSTY["I"&(PRSTY["N"!(PRSTY["H")))
IF "Nn"'[$EXTRACT(DAY(PRSDY,"P"),PRSTM)
QUIT 1
+26 ; did not fail any of the checks
QUIT 0