PRS8WE2 ;WCIOFO/MGD-DECOMPOSITION, WEEKEND PREMIUM PART 2 ;3/23/07
;;4.0;PAID;**90,92,96,112,119**;Sep 21, 1995;Build 4
;;Per VHA Directive 2004-038, this routine should not be modified.
COUNT(DAYN,SEG) ; Increase count of premium for tour
; input
; DAYN = day # (0-15) being counted
; SEG = segment # (1-96) in DAYN being counted
; D(DAYN)
; P(DAYN)
; H(DAYN)
; CNT(DAYN,shift) - optional
; output
; CNT(DAYN,shift) = current count for tour being processed
;
N DAT,FND,M1,NODE,NOTELG,POST,PREVDAY,RC,SC,SHIFT,TDAY,TOUR,TOURS,TS
; perform final checks
I ("EetOscbT"[$E(D(DAYN),SEG)),$E(H(DAYN),SEG)'=2,$E(P(DAYN),SEG) Q
I TYP["P","4"[$E(D(DAYN),SEG),$E(H(DAYN),SEG)'=2,$E(P(DAYN),SEG)=0 Q
;
; If Hybrid employee as defined by Public Law P.L. 107-135, check
; to see if the time was on a tour of duty or an exception. Tours
; worked on Sat or Sun qualify for Premium time. If the time was
; an exception, check the Remarks Code to see if the segment can be
; counted as Premium time.
;
S (FND,NOTELG)=0
; Quit if Sunday and employee is not entitled to Sun Prem Pay
Q:SATNOSUN&("^1^8^15^"[(U_DAY_U))&(TP="SUN")
I HYBRID!(PMP'=""&("^S^T^U^V^"[(U_PMP_U))) D Q:NOTELG
. ; Check to see if the time was on a tour or an exception
. N INC,END
. F TOURS=1,4,2 D Q:NOTELG!(FND)
. . S TOUR=$G(^TMP($J,"PRS8",DAYN,TOURS))
. . Q:TOUR=""
. . S INC=$S(TOURS=2:4,1:3)
. . S END=$S(TOURS=2:25,1:19)
. . F POST=1:INC:END I $P(TOUR,"^",POST)'="" D Q:NOTELG!(FND)
. . . ; Quit if SEG is not within the start/stop time
. . . Q:SEG<$P(TOUR,"^",POST)!(SEG>$P(TOUR,"^",POST+1))
. . . S FND=1
. . . Q:TOURS=1!(TOURS=4) ; If on a Tour it counts as Premium
. . . S RC=$P(TOUR,"^",POST+3)
. . . ; Remarks Code must be OT/CT on Premium (#9), Tour Coverage (#12),
. . . ; CB - Premium T&L (#14) or OT/CT With Premiums (#17) to qualify for Premium pay.
. . . I "^9^12^14^17^"'[("^"_RC_"^") S NOTELG=1
. Q:FND
. ;
. ; If we didn't find SEG in either of the two tours or the
. ; exceptions then check to see if it crossed over into this day.
. S PREVDAY=DAYN-1
. N INC,END
. F TOURS=1,4,2 D Q:NOTELG!(FND)
. . S TOUR=$G(^TMP($J,"PRS8",PREVDAY,TOURS))
. . Q:TOUR=""
. . S INC=$S(TOURS=2:4,1:3)
. . S END=$S(TOURS=2:25,1:19)
. . F POST=1:4:25 I $P(TOUR,"^",POST)'="" D Q:NOTELG!(FND)
. . . ; Quit if SEG is not within the start/stop time
. . . Q:(SEG+96)<$P(TOUR,"^",POST)!((SEG+96)>$P(TOUR,"^",POST+1))
. . . S FND=1
. . . Q:TOURS=1!(TOURS=4) ; If on a Tour it counts as Premium
. . . S RC=$P(TOUR,"^",POST+3)
. . . ; Remarks Code must be OT/CT on Premium (#9), Tour Coverage (#12),
. . . ; CB - Premium T&L (#14) or OT/CT With Premiums to qualify for premium pay.
. . . I "^9^12^14^17^"'[("^"_RC_"^") S NOTELG=1
;
I $E(H(DAYN),SEG)=1!($E(P(DAYN),SEG)=5) Q
; determine special code
S SHIFT=1
I TP="SUN",TYP["W" D
. ; Check to see if shift 2 or 3 is recorded for the segment worked
. I "^2^3^"[(U_$E(D(DAYN),SEG)_U) S SHIFT=$E(D(DAYN),SEG) Q
. S FND=0,SC=""
. ; Check for Holiday Worked on a Holiday
. I $E(D(DAYN),SEG)="O",$E(H(DAYN),SEG)=2 D
. . F TDAY=DAYN,DAYN-1 D Q:FND
. . . S M1=$S(TDAY=DAYN:SEG,1:SEG+96)
. . . ; loop through both tours in day
. . . F NODE=1,4 S DAT=$G(^TMP($J,"PRS8",TDAY,NODE)) Q:DAT="" D Q:FND
. . . . ; loop through tour segments in tour
. . . . F TS=1:1:7 Q:$P(DAT,U,(TS-1)*3+1)="" D Q:FND
. . . . . ; check if time is contained in tour segment
. . . . . I M1'<$P(DAT,U,(TS-1)*3+1),M1'>$P(DAT,U,(TS-1)*3+2) D
. . . . . . S SC=$P(DAT,U,(TS-1)*3+3),SHIFT=$S(SC=6:2,SC=7:3,1:1)
. . . . . . I "^2^3^"[(U_SHIFT_U) S FND=1
;
;Set shift 2 for 36/40 AWS nurses with premium time outside tour
;for this time segment i.e. overtime(O), comp time(C) or called in from
;on-call(c)
I +NAWS=36,"cOE"[$E(D(DAYN),SEG) S SHIFT=2
; add to count
S CNT(DAYN,SHIFT)=$G(CNT(DAYN,SHIFT))+1
Q
;
SAVE ; Update WK array with final count for tour
; input
; TP - type of premium (SAT or SUN)
; CNT(day,shift)=amount
;
N AMT,DAYN,PC,SHIFT,WEEK
S DAYN=0 F S DAYN=$O(CNT(DAYN)) Q:DAYN="" D
. Q:DAYN<1!(DAYN>14)
. S WEEK=$S(DAYN<8:1,1:2)
. S SHIFT="" F S SHIFT=$O(CNT(DAYN,SHIFT)) Q:SHIFT="" D
. . S AMT=CNT(DAYN,SHIFT)
. . S PC=$S(TP="SAT":0,1:SHIFT)+12
. . ;Shift 2 used for 36/40 nurses premium time within tour using the 2080 divisor (40*52).
. . ;Saturday Premium-AWS (SR/SS) and Sunday Premium-AWS (SD/SH)
. . ;Paid at the AAC with the 1872 divisor for the hourly rate (36*52)
. . ;for time outside the tour.
. . S:+NAWS=36 PC=$S(SHIFT=2:$S(TP="SAT":12,1:13),TP="SAT":49,1:50)
. . S $P(WK(WEEK),U,PC)=$P(WK(WEEK),U,PC)+AMT
Q
;
;PRS8WE
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPRS8WE2 4768 printed Dec 13, 2024@02:23:09 Page 2
PRS8WE2 ;WCIOFO/MGD-DECOMPOSITION, WEEKEND PREMIUM PART 2 ;3/23/07
+1 ;;4.0;PAID;**90,92,96,112,119**;Sep 21, 1995;Build 4
+2 ;;Per VHA Directive 2004-038, this routine should not be modified.
COUNT(DAYN,SEG) ; Increase count of premium for tour
+1 ; input
+2 ; DAYN = day # (0-15) being counted
+3 ; SEG = segment # (1-96) in DAYN being counted
+4 ; D(DAYN)
+5 ; P(DAYN)
+6 ; H(DAYN)
+7 ; CNT(DAYN,shift) - optional
+8 ; output
+9 ; CNT(DAYN,shift) = current count for tour being processed
+10 ;
+11 NEW DAT,FND,M1,NODE,NOTELG,POST,PREVDAY,RC,SC,SHIFT,TDAY,TOUR,TOURS,TS
+12 ; perform final checks
+13 IF ("EetOscbT"[$EXTRACT(D(DAYN),SEG))
IF $EXTRACT(H(DAYN),SEG)'=2
IF $EXTRACT(P(DAYN),SEG)
QUIT
+14 IF TYP["P"
IF "4"[$EXTRACT(D(DAYN),SEG)
IF $EXTRACT(H(DAYN),SEG)'=2
IF $EXTRACT(P(DAYN),SEG)=0
QUIT
+15 ;
+16 ; If Hybrid employee as defined by Public Law P.L. 107-135, check
+17 ; to see if the time was on a tour of duty or an exception. Tours
+18 ; worked on Sat or Sun qualify for Premium time. If the time was
+19 ; an exception, check the Remarks Code to see if the segment can be
+20 ; counted as Premium time.
+21 ;
+22 SET (FND,NOTELG)=0
+23 ; Quit if Sunday and employee is not entitled to Sun Prem Pay
+24 if SATNOSUN&("^1^8^15^"[(U_DAY_U))&(TP="SUN")
QUIT
+25 IF HYBRID!(PMP'=""&("^S^T^U^V^"[(U_PMP_U)))
Begin DoDot:1
+26 ; Check to see if the time was on a tour or an exception
+27 NEW INC,END
+28 FOR TOURS=1,4,2
Begin DoDot:2
+29 SET TOUR=$GET(^TMP($JOB,"PRS8",DAYN,TOURS))
+30 if TOUR=""
QUIT
+31 SET INC=$SELECT(TOURS=2:4,1:3)
+32 SET END=$SELECT(TOURS=2:25,1:19)
+33 FOR POST=1:INC:END
IF $PIECE(TOUR,"^",POST)'=""
Begin DoDot:3
+34 ; Quit if SEG is not within the start/stop time
+35 if SEG<$PIECE(TOUR,"^",POST)!(SEG>$PIECE(TOUR,"^",POST+1))
QUIT
+36 SET FND=1
+37 ; If on a Tour it counts as Premium
if TOURS=1!(TOURS=4)
QUIT
+38 SET RC=$PIECE(TOUR,"^",POST+3)
+39 ; Remarks Code must be OT/CT on Premium (#9), Tour Coverage (#12),
+40 ; CB - Premium T&L (#14) or OT/CT With Premiums (#17) to qualify for Premium pay.
+41 IF "^9^12^14^17^"'[("^"_RC_"^")
SET NOTELG=1
End DoDot:3
if NOTELG!(FND)
QUIT
End DoDot:2
if NOTELG!(FND)
QUIT
+42 if FND
QUIT
+43 ;
+44 ; If we didn't find SEG in either of the two tours or the
+45 ; exceptions then check to see if it crossed over into this day.
+46 SET PREVDAY=DAYN-1
+47 NEW INC,END
+48 FOR TOURS=1,4,2
Begin DoDot:2
+49 SET TOUR=$GET(^TMP($JOB,"PRS8",PREVDAY,TOURS))
+50 if TOUR=""
QUIT
+51 SET INC=$SELECT(TOURS=2:4,1:3)
+52 SET END=$SELECT(TOURS=2:25,1:19)
+53 FOR POST=1:4:25
IF $PIECE(TOUR,"^",POST)'=""
Begin DoDot:3
+54 ; Quit if SEG is not within the start/stop time
+55 if (SEG+96)<$PIECE(TOUR,"^",POST)!((SEG+96)>$PIECE(TOUR,"^",POST+1))
QUIT
+56 SET FND=1
+57 ; If on a Tour it counts as Premium
if TOURS=1!(TOURS=4)
QUIT
+58 SET RC=$PIECE(TOUR,"^",POST+3)
+59 ; Remarks Code must be OT/CT on Premium (#9), Tour Coverage (#12),
+60 ; CB - Premium T&L (#14) or OT/CT With Premiums to qualify for premium pay.
+61 IF "^9^12^14^17^"'[("^"_RC_"^")
SET NOTELG=1
End DoDot:3
if NOTELG!(FND)
QUIT
End DoDot:2
if NOTELG!(FND)
QUIT
End DoDot:1
if NOTELG
QUIT
+62 ;
+63 IF $EXTRACT(H(DAYN),SEG)=1!($EXTRACT(P(DAYN),SEG)=5)
QUIT
+64 ; determine special code
+65 SET SHIFT=1
+66 IF TP="SUN"
IF TYP["W"
Begin DoDot:1
+67 ; Check to see if shift 2 or 3 is recorded for the segment worked
+68 IF "^2^3^"[(U_$EXTRACT(D(DAYN),SEG)_U)
SET SHIFT=$EXTRACT(D(DAYN),SEG)
QUIT
+69 SET FND=0
SET SC=""
+70 ; Check for Holiday Worked on a Holiday
+71 IF $EXTRACT(D(DAYN),SEG)="O"
IF $EXTRACT(H(DAYN),SEG)=2
Begin DoDot:2
+72 FOR TDAY=DAYN,DAYN-1
Begin DoDot:3
+73 SET M1=$SELECT(TDAY=DAYN:SEG,1:SEG+96)
+74 ; loop through both tours in day
+75 FOR NODE=1,4
SET DAT=$GET(^TMP($JOB,"PRS8",TDAY,NODE))
if DAT=""
QUIT
Begin DoDot:4
+76 ; loop through tour segments in tour
+77 FOR TS=1:1:7
if $PIECE(DAT,U,(TS-1)*3+1)=""
QUIT
Begin DoDot:5
+78 ; check if time is contained in tour segment
+79 IF M1'<$PIECE(DAT,U,(TS-1)*3+1)
IF M1'>$PIECE(DAT,U,(TS-1)*3+2)
Begin DoDot:6
+80 SET SC=$PIECE(DAT,U,(TS-1)*3+3)
SET SHIFT=$SELECT(SC=6:2,SC=7:3,1:1)
+81 IF "^2^3^"[(U_SHIFT_U)
SET FND=1
End DoDot:6
End DoDot:5
if FND
QUIT
End DoDot:4
if FND
QUIT
End DoDot:3
if FND
QUIT
End DoDot:2
End DoDot:1
+82 ;
+83 ;Set shift 2 for 36/40 AWS nurses with premium time outside tour
+84 ;for this time segment i.e. overtime(O), comp time(C) or called in from
+85 ;on-call(c)
+86 IF +NAWS=36
IF "cOE"[$EXTRACT(D(DAYN),SEG)
SET SHIFT=2
+87 ; add to count
+88 SET CNT(DAYN,SHIFT)=$GET(CNT(DAYN,SHIFT))+1
+89 QUIT
+90 ;
SAVE ; Update WK array with final count for tour
+1 ; input
+2 ; TP - type of premium (SAT or SUN)
+3 ; CNT(day,shift)=amount
+4 ;
+5 NEW AMT,DAYN,PC,SHIFT,WEEK
+6 SET DAYN=0
FOR
SET DAYN=$ORDER(CNT(DAYN))
if DAYN=""
QUIT
Begin DoDot:1
+7 if DAYN<1!(DAYN>14)
QUIT
+8 SET WEEK=$SELECT(DAYN<8:1,1:2)
+9 SET SHIFT=""
FOR
SET SHIFT=$ORDER(CNT(DAYN,SHIFT))
if SHIFT=""
QUIT
Begin DoDot:2
+10 SET AMT=CNT(DAYN,SHIFT)
+11 SET PC=$SELECT(TP="SAT":0,1:SHIFT)+12
+12 ;Shift 2 used for 36/40 nurses premium time within tour using the 2080 divisor (40*52).
+13 ;Saturday Premium-AWS (SR/SS) and Sunday Premium-AWS (SD/SH)
+14 ;Paid at the AAC with the 1872 divisor for the hourly rate (36*52)
+15 ;for time outside the tour.
+16 if +NAWS=36
SET PC=$SELECT(SHIFT=2:$SELECT(TP="SAT":12,1:13),TP="SAT":49,1:50)
+17 SET $PIECE(WK(WEEK),U,PC)=$PIECE(WK(WEEK),U,PC)+AMT
End DoDot:2
End DoDot:1
+18 QUIT
+19 ;
+20 ;PRS8WE