PRS8OTFF ;WCIOFO/MGD-OVERTIME/UNSCH FOR CODE R,C FIREFIGHTERS ;01/11/08
;;4.0;PAID;**45,54,102,117**;Sep 21, 1995;Build 32
;;Per VHA Directive 2004-038, this routine should not be modified.
;
; routine called from PRS8ST when a premium pay indicator for
; a firefighter is R or C.
;
FFOTUN ;CALCULATE CODE R AND C FIREFIGHTERS OVERTIME AND UNSCHEDULED REGULAR
;
N SCHWRK,XTRAWRK
;
;Count up scheduled and unscheduled work for week 1 and 2
;
D WORKCNT(.SCHWRK,.XTRAWRK,.XWRK)
;
; Determine overtime and unscheduled based on 53/106 hour rule
; and update the week array with OA/OE, RA/RE and UN/US.
; Code C and R firefighters overtime calculation is the same
; whether on compressed tour or not.
;
D CALCOT(.SCHWRK,.XTRAWRK,.XWRK)
;
Q
;
;==============================================================
;
WORKCNT(SCHWRK,XTRAWRK,XWRK) ;
;
;VARIABLE LIST
; DAY: current day of pay period--1 through 14 and 1st day of next (15)
; WEEK: Week 1 or 2 of pay period--days 1-7 are week 1, 8-14 week 2.
; QHRCNT: Counter for a single Quarter Hour segment of day. There are
; 96 quarter hours in a 24 hour day.
; EXCSTR: 96 char day string with exceptions
; WRKSTR: 96 char string with work codes.
; AFFSTR: 96 char string with additional fire fighter hour segments
; coded with 1's.
; XWRK: string of extra work time
; QHTCODE: Time code for a single quarter hour segment.
; 1:scheduled work A:annual leave S:sick leave,
; W:leave without pay n:non pay status U:comp used,
; E:comp earned M:military leave X:training,
; Y:travel O:overtime 4:unscheduled,
; T:ot in travel B:standby C:on call,
; N:non pay annual lv h:holiday worked F:Care and Bereavement
; G:adoption D:donor leave R:restored annual leave
; M:military leave J:jury duty n:non pay time
; V:continuation of pay e:sched comp earn s:scheduled OT
; Note: T:overtime for travel is counted elsewhere so it can not
; also be recounted as overtime here.
;
N DAY,WEEK,QHRCNT,QHRSEG,WRKSTR,QHTCODE,HOLIDAY
;
;Initialize scheduled work and xtra work counters
;
F WEEK=1:1:2 S (SCHWRK(WEEK),XTRAWRK(WEEK))=0,XWRK(WEEK)=""
;
;Loop through Each day of the pay period
;
F DAY=1:1:14 D
.S WEEK=$S(DAY>7:2,1:1)
.S WRKSTR=$G(^TMP($J,"PRS8",DAY,"W")) ; work node includes addt ff hrs.
.;
.; loop through each 15 min increment of the current day
.; totaling scheduled and unscheduled work
.;
.F QHRCNT=1:1:96 S QHTCODE=$E(WRKSTR,QHRCNT) Q:'$L(QHTCODE) D
. . ;
. . ; SET HOLIDAY TO 0,1,2 FOR NO HOLIDAY, HOL EXUSED, OR HOLIDAY WORKED
. . ;
. . S HOLIDAY=$$HOLIDAY(QHRCNT,DAY)
. . ;
. . ; INCREMENT SCHEDULED WORK IF ACCOUNTED FOR WITH APPROPRIATE CODE.
. . I "1SLWAUXYBCFGDJRMVnZq"[QHTCODE!(QHTCODE="O"&(HOLIDAY=2)) D
. . . S SCHWRK(WEEK)=SCHWRK(WEEK)+1
. . ;
. . ; Increment any unscheduled work or unscheduled CT or OT
. . I "4EeOs"[QHTCODE&(HOLIDAY<1) D
. . . S XTRAWRK(WEEK)=XTRAWRK(WEEK)+1
. . . S XWRK(WEEK)=XWRK(WEEK)_QHTCODE
;
Q
;
;==============================================================
;
CALCOT(SW,XW,XWS) ;
; Update the week array with overtime
;
;Possible permutations of Scheduled and Unscheduled
; |
; 53|HRS
; |
; 1. SSSSSSSSSSSSSSSSSSSSS|SSSSSSSSS
; 2. SSSSSSSSSSSSSSSSSSSSS|SSSSSUUUUUUUUUUUU
; 3. SSSSSSSSSSSSSSSSSSSSS|UUUUUUUUUUUUU
; 4. SSSSSSSSSSSSSSSSUUUUU|UUUUUUUUUUU
; 5. SSSSSSSSSSSSSSSSSS |
; 6. SSSSSSSSSSSSUUU |
;
; |------------------------------------------|
; | After Patch 85 |<= 212 |> 212 |
; |------------------------------------------|
; |Code| Type of Time | Piece | Piece |
; |------------------------------------------|
; | ** |All Scheduled Time | | 26 |
; | 4 |Unscheduled Regular | 9 | 20 |
; | E |Comp Time Earned | 9 | 7 |
; | e |Scheduled Comp Time | 9 | 20 |
; | O |Overtime | 9 | 20 |
; | s |Scheduled Overtime | 9 | 20 |
; |------------------------------------------|
;
N I,P,WEEK,Y,Z
F WEEK=1:1:2 D
. ;
. ; Post Regular Scheduled Hours In Excess of 53 as RA/RE
. ; Scenarios 1 & 2
. I SW(WEEK)>212 D
. . S Y=SW(WEEK)-212,P=26 D SET
. ;
. ; Post Extra Hours per chart. Scenarios 2,3,4 & 6
. I $L(XWS(WEEK))>0 D
. . S Y=1
. . ;
. . ; step thru extra time segments
. . F I=1:1:$L(XWS(WEEK)) D
. . . S Z=$E(XWS(WEEK),I)
. . . S P=$S(SW(WEEK)+I'>212:9,Z="E":7,Z="e":20,Z="s":20,1:20)
. . . D SET
. . . ;
. . . ; If Scheduled OT or CT after 53 hours, also count as Unscheduled Regular
. . . I P=26 S P=9 D SET
Q
;
;==============================================================
;
SET ; Set sleep time into WK array
S $P(WK(WEEK),"^",P)=$P(WK(WEEK),"^",P)+Y
Q
;
;==============================================================
;
HOLIDAY(TIMESEG,DAY) ;
;INPUT:
; DAY--day of pay period 1 through 14 or 15 for 1st day of next pp
; TIMESEG--position in 96 character day string (1 to 96)
;OUTPUT:
; code for holiday worked, holiday exused or neither from the
; ^TMP($J,"PRS8",DAY,"HOL") global
; holiday worked coded: 2
; holiday exused coded: 1
; neither coded: 0
;
Q $E($G(^TMP($J,"PRS8",DAY,"HOL")),TIMESEG)
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPRS8OTFF 5572 printed Dec 13, 2024@02:22:57 Page 2
PRS8OTFF ;WCIOFO/MGD-OVERTIME/UNSCH FOR CODE R,C FIREFIGHTERS ;01/11/08
+1 ;;4.0;PAID;**45,54,102,117**;Sep 21, 1995;Build 32
+2 ;;Per VHA Directive 2004-038, this routine should not be modified.
+3 ;
+4 ; routine called from PRS8ST when a premium pay indicator for
+5 ; a firefighter is R or C.
+6 ;
FFOTUN ;CALCULATE CODE R AND C FIREFIGHTERS OVERTIME AND UNSCHEDULED REGULAR
+1 ;
+2 NEW SCHWRK,XTRAWRK
+3 ;
+4 ;Count up scheduled and unscheduled work for week 1 and 2
+5 ;
+6 DO WORKCNT(.SCHWRK,.XTRAWRK,.XWRK)
+7 ;
+8 ; Determine overtime and unscheduled based on 53/106 hour rule
+9 ; and update the week array with OA/OE, RA/RE and UN/US.
+10 ; Code C and R firefighters overtime calculation is the same
+11 ; whether on compressed tour or not.
+12 ;
+13 DO CALCOT(.SCHWRK,.XTRAWRK,.XWRK)
+14 ;
+15 QUIT
+16 ;
+17 ;==============================================================
+18 ;
WORKCNT(SCHWRK,XTRAWRK,XWRK) ;
+1 ;
+2 ;VARIABLE LIST
+3 ; DAY: current day of pay period--1 through 14 and 1st day of next (15)
+4 ; WEEK: Week 1 or 2 of pay period--days 1-7 are week 1, 8-14 week 2.
+5 ; QHRCNT: Counter for a single Quarter Hour segment of day. There are
+6 ; 96 quarter hours in a 24 hour day.
+7 ; EXCSTR: 96 char day string with exceptions
+8 ; WRKSTR: 96 char string with work codes.
+9 ; AFFSTR: 96 char string with additional fire fighter hour segments
+10 ; coded with 1's.
+11 ; XWRK: string of extra work time
+12 ; QHTCODE: Time code for a single quarter hour segment.
+13 ; 1:scheduled work A:annual leave S:sick leave,
+14 ; W:leave without pay n:non pay status U:comp used,
+15 ; E:comp earned M:military leave X:training,
+16 ; Y:travel O:overtime 4:unscheduled,
+17 ; T:ot in travel B:standby C:on call,
+18 ; N:non pay annual lv h:holiday worked F:Care and Bereavement
+19 ; G:adoption D:donor leave R:restored annual leave
+20 ; M:military leave J:jury duty n:non pay time
+21 ; V:continuation of pay e:sched comp earn s:scheduled OT
+22 ; Note: T:overtime for travel is counted elsewhere so it can not
+23 ; also be recounted as overtime here.
+24 ;
+25 NEW DAY,WEEK,QHRCNT,QHRSEG,WRKSTR,QHTCODE,HOLIDAY
+26 ;
+27 ;Initialize scheduled work and xtra work counters
+28 ;
+29 FOR WEEK=1:1:2
SET (SCHWRK(WEEK),XTRAWRK(WEEK))=0
SET XWRK(WEEK)=""
+30 ;
+31 ;Loop through Each day of the pay period
+32 ;
+33 FOR DAY=1:1:14
Begin DoDot:1
+34 SET WEEK=$SELECT(DAY>7:2,1:1)
+35 ; work node includes addt ff hrs.
SET WRKSTR=$GET(^TMP($JOB,"PRS8",DAY,"W"))
+36 ;
+37 ; loop through each 15 min increment of the current day
+38 ; totaling scheduled and unscheduled work
+39 ;
+40 FOR QHRCNT=1:1:96
SET QHTCODE=$EXTRACT(WRKSTR,QHRCNT)
if '$LENGTH(QHTCODE)
QUIT
Begin DoDot:2
+41 ;
+42 ; SET HOLIDAY TO 0,1,2 FOR NO HOLIDAY, HOL EXUSED, OR HOLIDAY WORKED
+43 ;
+44 SET HOLIDAY=$$HOLIDAY(QHRCNT,DAY)
+45 ;
+46 ; INCREMENT SCHEDULED WORK IF ACCOUNTED FOR WITH APPROPRIATE CODE.
+47 IF "1SLWAUXYBCFGDJRMVnZq"[QHTCODE!(QHTCODE="O"&(HOLIDAY=2))
Begin DoDot:3
+48 SET SCHWRK(WEEK)=SCHWRK(WEEK)+1
End DoDot:3
+49 ;
+50 ; Increment any unscheduled work or unscheduled CT or OT
+51 IF "4EeOs"[QHTCODE&(HOLIDAY<1)
Begin DoDot:3
+52 SET XTRAWRK(WEEK)=XTRAWRK(WEEK)+1
+53 SET XWRK(WEEK)=XWRK(WEEK)_QHTCODE
End DoDot:3
End DoDot:2
End DoDot:1
+54 ;
+55 QUIT
+56 ;
+57 ;==============================================================
+58 ;
CALCOT(SW,XW,XWS) ;
+1 ; Update the week array with overtime
+2 ;
+3 ;Possible permutations of Scheduled and Unscheduled
+4 ; |
+5 ; 53|HRS
+6 ; |
+7 ; 1. SSSSSSSSSSSSSSSSSSSSS|SSSSSSSSS
+8 ; 2. SSSSSSSSSSSSSSSSSSSSS|SSSSSUUUUUUUUUUUU
+9 ; 3. SSSSSSSSSSSSSSSSSSSSS|UUUUUUUUUUUUU
+10 ; 4. SSSSSSSSSSSSSSSSUUUUU|UUUUUUUUUUU
+11 ; 5. SSSSSSSSSSSSSSSSSS |
+12 ; 6. SSSSSSSSSSSSUUU |
+13 ;
+14 ; |------------------------------------------|
+15 ; | After Patch 85 |<= 212 |> 212 |
+16 ; |------------------------------------------|
+17 ; |Code| Type of Time | Piece | Piece |
+18 ; |------------------------------------------|
+19 ; | ** |All Scheduled Time | | 26 |
+20 ; | 4 |Unscheduled Regular | 9 | 20 |
+21 ; | E |Comp Time Earned | 9 | 7 |
+22 ; | e |Scheduled Comp Time | 9 | 20 |
+23 ; | O |Overtime | 9 | 20 |
+24 ; | s |Scheduled Overtime | 9 | 20 |
+25 ; |------------------------------------------|
+26 ;
+27 NEW I,P,WEEK,Y,Z
+28 FOR WEEK=1:1:2
Begin DoDot:1
+29 ;
+30 ; Post Regular Scheduled Hours In Excess of 53 as RA/RE
+31 ; Scenarios 1 & 2
+32 IF SW(WEEK)>212
Begin DoDot:2
+33 SET Y=SW(WEEK)-212
SET P=26
DO SET
End DoDot:2
+34 ;
+35 ; Post Extra Hours per chart. Scenarios 2,3,4 & 6
+36 IF $LENGTH(XWS(WEEK))>0
Begin DoDot:2
+37 SET Y=1
+38 ;
+39 ; step thru extra time segments
+40 FOR I=1:1:$LENGTH(XWS(WEEK))
Begin DoDot:3
+41 SET Z=$EXTRACT(XWS(WEEK),I)
+42 SET P=$SELECT(SW(WEEK)+I'>212:9,Z="E":7,Z="e":20,Z="s":20,1:20)
+43 DO SET
+44 ;
+45 ; If Scheduled OT or CT after 53 hours, also count as Unscheduled Regular
+46 IF P=26
SET P=9
DO SET
End DoDot:3
End DoDot:2
End DoDot:1
+47 QUIT
+48 ;
+49 ;==============================================================
+50 ;
SET ; Set sleep time into WK array
+1 SET $PIECE(WK(WEEK),"^",P)=$PIECE(WK(WEEK),"^",P)+Y
+2 QUIT
+3 ;
+4 ;==============================================================
+5 ;
HOLIDAY(TIMESEG,DAY) ;
+1 ;INPUT:
+2 ; DAY--day of pay period 1 through 14 or 15 for 1st day of next pp
+3 ; TIMESEG--position in 96 character day string (1 to 96)
+4 ;OUTPUT:
+5 ; code for holiday worked, holiday exused or neither from the
+6 ; ^TMP($J,"PRS8",DAY,"HOL") global
+7 ; holiday worked coded: 2
+8 ; holiday exused coded: 1
+9 ; neither coded: 0
+10 ;
+11 QUIT $EXTRACT($GET(^TMP($JOB,"PRS8",DAY,"HOL")),TIMESEG)