PRS8EX0 ;HISC/MRL,WOIFO/JAH,SAB-DECOMP,EXCEPTIONS (cont'd) ;1/30/2007
;;4.0;PAID;**2,22,56,111**;Sep 21, 1995;Build 2
;;Per VHA Directive 2004-038, this routine should not be modified.
;
ENCAP ;
; This routine checks if the current day encapsulates other days that
; should be automatically charged to WP or NP by the software. If so,
; appropriate encapsulated days are charged. This routine is only
; called when the employee has a daily tour.
; inputs
; PY - current pay period IEN
; DY - current day number
; TT - type of time posted on current day
; TT(1) - data from ACT^PRS8EX for the type of time in TT
; DFN - employee IEN
;
; day must be in pay period and posted with WP or NP
Q:(DY<1)!(DY>14)
Q:"^NP^WP^"'[(U_TT_U)
;
N SCHDY,SCHEX,SCHPY,CHGDAY
;
; find prior scheduled work day that is not holiday excused
D WORKDAY(DFN,PY,DY,-1,.SCHPY,.SCHDY,.SCHEX,.CHGDAY)
;
; If prior work day is in a previous pay period and has same exception
; as the current day then charge the encapsulated days found between.
; Note: If prior work day is in current pay period then no action
; needed since the look forward from that prior day would have
; already taken care of encapsulated days.
I SCHEX=TT,$D(CHGDAY),SCHPY'=PY D SET(DFN,PY,TT,$P(TT(1),U,4),.CHGDAY)
;
; find next scheduled work day that is not holiday excused
D WORKDAY(DFN,PY,DY,1,.SCHPY,.SCHDY,.SCHEX,.CHGDAY)
;
; If next work day has same exception as current day then charge
; encapsulated days found between.
I SCHEX=TT,$D(CHGDAY) D SET(DFN,PY,TT,$P(TT(1),U,4),.CHGDAY)
;
Q
;
WORKDAY(DFN,PY,DY,PRSDIR,SCHPY,SCHDY,SCHEX,CHGDAY) ; find work day
; inputs
; DFN - employee IEN
; PY - current pay period IEN
; DY - current day number
; PRSDIR - direction (-1 to look back or +1 to look forward)
; outputs
; SCHPY - passed by reference, work day pay period or null
; SCHDY - passed by reference, work day day number or null
; SCHEX - passed by reference, work day exception or null
; CHGDAY() - passed by reference, array of days in current pay period
; that could be charged due to encapsulation and were
; encounted during the search for the work day
; format ENCDAY(day number)=null value
;
N DONE,EXC,LOOPPY,LOOPDY,PPCNT,TOD
; init outputs
S (SCHPY,SCHDY,SCHEX)=""
K CHGDAY
;
; loop thru days to find the first scheduled work day that is
; not holiday excused
S DONE=0,LOOPPY=PY,LOOPDY=DY,PPCNT=1
F D I DONE Q
. ; move one day in appropriate direction
. S LOOPDY=LOOPDY+PRSDIR
. ;
. ; check if loop day moved into a different pay period
. I LOOPDY<1 S LOOPPY=$O(^PRST(458,LOOPPY),-1),LOOPDY=14,PPCNT=PPCNT+1
. I LOOPDY>14 S LOOPPY=$O(^PRST(458,LOOPPY),1),LOOPDY=1,PPCNT=PPCNT+1
. ;
. ; check for loop ending conditions (related to pay period/time card)
. I PPCNT>2 S DONE=1 Q ; only check current and one other pay period
. I LOOPPY'>0 S DONE=1 Q ; ran out of pay periods
. I '$D(^PRST(458,LOOPPY,"E",DFN,0)) S DONE=1 Q ; no empl. time card
. ;
. ; determine tour and exception for loop day
. S TOD=$P($G(^PRST(458,LOOPPY,"E",DFN,"D",LOOPDY,0)),U,2)
. S EXC=$P($G(^PRST(458,LOOPPY,"E",DFN,"D",LOOPDY,2)),U,3)
. ;
. ; check if work day found
. I TOD'=1,EXC'="HX" S SCHPY=LOOPPY,SCHDY=LOOPDY,SCHEX=EXC,DONE=1 Q
. ;
. ; work day was not found yet
. ; add this day to list if it could potentially be charged
. Q:LOOPPY'=PY ; not in current pay period
. Q:$D(^TMP($J,"PRS8",LOOPDY,2,0)) ; day already charged
. I TOD=1,"^CP^NP^"'[(U_EXC_U) S CHGDAY(LOOPDY)="" ; add day off to list
. I TOD>1,EXC="HX" S CHGDAY(LOOPDY)="" ; add holiday to list
Q
;
SET(DFN,PY,TT,PC,CHGDAY) ; automatically charge days
;
; inputs
; DFN - employee IEN
; PY - pay period IEN
; TT - type of time to charge
; PC - 4th piece of data from ACT^PRS8EX for TT
; CHGDAY - array of days passed by reference, CHGDAY(day number)=""
;
N LOOPDY,PC3,WEEK
;
; loop thru days in list
S LOOPDY=0 F S LOOPDY=$O(CHGDAY(LOOPDY)) Q:'LOOPDY D
. ;
. ; increment WK() count
. I +PC S WEEK=$S(LOOPDY>7:2,1:1),$P(WK(WEEK),"^",+PC)=$P(WK(WEEK),"^",+PC)+1
. E S PC3=$A(PC)-64,$P(WK(3),"^",+PC3)=$P(WK(3),"^",+PC3)+1
. ;
. ; track days have been automatically charged in ^TMP
. S ^TMP($J,"PRS8",LOOPDY,2,0)=TT
. ;
. ; update time card if decomp called from pay period certification
. I $G(APDT) D
. . S $P(^PRST(458,PY,"E",DFN,"D",LOOPDY,2),"^",3)=TT
. . S ^PRST(458,PY,"E",DFN,"D",LOOPDY,3)="Leave posted automatically"
. . S $P(^PRST(458,PY,"E",DFN,"D",LOOPDY,10),"^",1,4)="T^.5^"_APDT_"^2"
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPRS8EX0 4722 printed Oct 16, 2024@18:23:32 Page 2
PRS8EX0 ;HISC/MRL,WOIFO/JAH,SAB-DECOMP,EXCEPTIONS (cont'd) ;1/30/2007
+1 ;;4.0;PAID;**2,22,56,111**;Sep 21, 1995;Build 2
+2 ;;Per VHA Directive 2004-038, this routine should not be modified.
+3 ;
ENCAP ;
+1 ; This routine checks if the current day encapsulates other days that
+2 ; should be automatically charged to WP or NP by the software. If so,
+3 ; appropriate encapsulated days are charged. This routine is only
+4 ; called when the employee has a daily tour.
+5 ; inputs
+6 ; PY - current pay period IEN
+7 ; DY - current day number
+8 ; TT - type of time posted on current day
+9 ; TT(1) - data from ACT^PRS8EX for the type of time in TT
+10 ; DFN - employee IEN
+11 ;
+12 ; day must be in pay period and posted with WP or NP
+13 if (DY<1)!(DY>14)
QUIT
+14 if "^NP^WP^"'[(U_TT_U)
QUIT
+15 ;
+16 NEW SCHDY,SCHEX,SCHPY,CHGDAY
+17 ;
+18 ; find prior scheduled work day that is not holiday excused
+19 DO WORKDAY(DFN,PY,DY,-1,.SCHPY,.SCHDY,.SCHEX,.CHGDAY)
+20 ;
+21 ; If prior work day is in a previous pay period and has same exception
+22 ; as the current day then charge the encapsulated days found between.
+23 ; Note: If prior work day is in current pay period then no action
+24 ; needed since the look forward from that prior day would have
+25 ; already taken care of encapsulated days.
+26 IF SCHEX=TT
IF $DATA(CHGDAY)
IF SCHPY'=PY
DO SET(DFN,PY,TT,$PIECE(TT(1),U,4),.CHGDAY)
+27 ;
+28 ; find next scheduled work day that is not holiday excused
+29 DO WORKDAY(DFN,PY,DY,1,.SCHPY,.SCHDY,.SCHEX,.CHGDAY)
+30 ;
+31 ; If next work day has same exception as current day then charge
+32 ; encapsulated days found between.
+33 IF SCHEX=TT
IF $DATA(CHGDAY)
DO SET(DFN,PY,TT,$PIECE(TT(1),U,4),.CHGDAY)
+34 ;
+35 QUIT
+36 ;
WORKDAY(DFN,PY,DY,PRSDIR,SCHPY,SCHDY,SCHEX,CHGDAY) ; find work day
+1 ; inputs
+2 ; DFN - employee IEN
+3 ; PY - current pay period IEN
+4 ; DY - current day number
+5 ; PRSDIR - direction (-1 to look back or +1 to look forward)
+6 ; outputs
+7 ; SCHPY - passed by reference, work day pay period or null
+8 ; SCHDY - passed by reference, work day day number or null
+9 ; SCHEX - passed by reference, work day exception or null
+10 ; CHGDAY() - passed by reference, array of days in current pay period
+11 ; that could be charged due to encapsulation and were
+12 ; encounted during the search for the work day
+13 ; format ENCDAY(day number)=null value
+14 ;
+15 NEW DONE,EXC,LOOPPY,LOOPDY,PPCNT,TOD
+16 ; init outputs
+17 SET (SCHPY,SCHDY,SCHEX)=""
+18 KILL CHGDAY
+19 ;
+20 ; loop thru days to find the first scheduled work day that is
+21 ; not holiday excused
+22 SET DONE=0
SET LOOPPY=PY
SET LOOPDY=DY
SET PPCNT=1
+23 FOR
Begin DoDot:1
+24 ; move one day in appropriate direction
+25 SET LOOPDY=LOOPDY+PRSDIR
+26 ;
+27 ; check if loop day moved into a different pay period
+28 IF LOOPDY<1
SET LOOPPY=$ORDER(^PRST(458,LOOPPY),-1)
SET LOOPDY=14
SET PPCNT=PPCNT+1
+29 IF LOOPDY>14
SET LOOPPY=$ORDER(^PRST(458,LOOPPY),1)
SET LOOPDY=1
SET PPCNT=PPCNT+1
+30 ;
+31 ; check for loop ending conditions (related to pay period/time card)
+32 ; only check current and one other pay period
IF PPCNT>2
SET DONE=1
QUIT
+33 ; ran out of pay periods
IF LOOPPY'>0
SET DONE=1
QUIT
+34 ; no empl. time card
IF '$DATA(^PRST(458,LOOPPY,"E",DFN,0))
SET DONE=1
QUIT
+35 ;
+36 ; determine tour and exception for loop day
+37 SET TOD=$PIECE($GET(^PRST(458,LOOPPY,"E",DFN,"D",LOOPDY,0)),U,2)
+38 SET EXC=$PIECE($GET(^PRST(458,LOOPPY,"E",DFN,"D",LOOPDY,2)),U,3)
+39 ;
+40 ; check if work day found
+41 IF TOD'=1
IF EXC'="HX"
SET SCHPY=LOOPPY
SET SCHDY=LOOPDY
SET SCHEX=EXC
SET DONE=1
QUIT
+42 ;
+43 ; work day was not found yet
+44 ; add this day to list if it could potentially be charged
+45 ; not in current pay period
if LOOPPY'=PY
QUIT
+46 ; day already charged
if $DATA(^TMP($JOB,"PRS8",LOOPDY,2,0))
QUIT
+47 ; add day off to list
IF TOD=1
IF "^CP^NP^"'[(U_EXC_U)
SET CHGDAY(LOOPDY)=""
+48 ; add holiday to list
IF TOD>1
IF EXC="HX"
SET CHGDAY(LOOPDY)=""
End DoDot:1
IF DONE
QUIT
+49 QUIT
+50 ;
SET(DFN,PY,TT,PC,CHGDAY) ; automatically charge days
+1 ;
+2 ; inputs
+3 ; DFN - employee IEN
+4 ; PY - pay period IEN
+5 ; TT - type of time to charge
+6 ; PC - 4th piece of data from ACT^PRS8EX for TT
+7 ; CHGDAY - array of days passed by reference, CHGDAY(day number)=""
+8 ;
+9 NEW LOOPDY,PC3,WEEK
+10 ;
+11 ; loop thru days in list
+12 SET LOOPDY=0
FOR
SET LOOPDY=$ORDER(CHGDAY(LOOPDY))
if 'LOOPDY
QUIT
Begin DoDot:1
+13 ;
+14 ; increment WK() count
+15 IF +PC
SET WEEK=$SELECT(LOOPDY>7:2,1:1)
SET $PIECE(WK(WEEK),"^",+PC)=$PIECE(WK(WEEK),"^",+PC)+1
+16 IF '$TEST
SET PC3=$ASCII(PC)-64
SET $PIECE(WK(3),"^",+PC3)=$PIECE(WK(3),"^",+PC3)+1
+17 ;
+18 ; track days have been automatically charged in ^TMP
+19 SET ^TMP($JOB,"PRS8",LOOPDY,2,0)=TT
+20 ;
+21 ; update time card if decomp called from pay period certification
+22 IF $GET(APDT)
Begin DoDot:2
+23 SET $PIECE(^PRST(458,PY,"E",DFN,"D",LOOPDY,2),"^",3)=TT
+24 SET ^PRST(458,PY,"E",DFN,"D",LOOPDY,3)="Leave posted automatically"
+25 SET $PIECE(^PRST(458,PY,"E",DFN,"D",LOOPDY,10),"^",1,4)="T^.5^"_APDT_"^2"
End DoDot:2
End DoDot:1
+26 QUIT