- PRSPLVA1 ;WOIFO/SAB - AUTOPOST LEAVE FOR PTP (CONT) ;03/30/2005
- ;;4.0;PAID;**93**;Sep 21, 1995;Build 7
- ;;Per VHA Directive 2004-038, this routine should not be modified.
- Q
- ;
- PDAY ; Process Day (within Pay Period loop)
- ; called from PRSPLVA
- ; input variables LVDTE,LVDTS,LVY0,PPDN,PPI,PRSIEN,PRSFDA(),
- ; TCST,TCUNPOST()
- ; output variable
- ; FATAL = 1^PPI, only defined if fatal exception occurred
- ; PRSFDA() may be updated with additional data to post to ESR
- ; TCUNPOST() may be updated with another day to unpost from timecard
- ;
- N ESR,ESRRG,ESRLVM,ESRST,FOUND,OVERLAP,PPDIENS,PRSDT,PRSX
- N PSTDTE,PSTDTS,PSTMEAL,PSTSEG,PSTTYP,SEGI,TC,TOD,TODD,TODL,TOURLV
- N TSE,TSID,TSS,TSY
- ;
- ; skip day if not a scheduled tour
- Q:$P($G(^PRST(458,PPI,"E",PRSIEN,"D",PPDN,1)),U)=""
- ;
- S PPDIENS=PPDN_","_PRSIEN_","_PPI_","
- ;
- S PRSDT=$P($G(^PRST(458,PPI,1)),U,PPDN) ; FileMan date of day number
- ;
- ; load tour segments from both tours into arrays TOD() and TODD()
- D LOADTOD^PRSPLVU(PPI,PRSIEN,PPDN,.TOD,.TODD)
- ;
- ; load ESR segments into array ESR()
- D LOADESR^PRSPLVU(PPI,PRSIEN,PPDN,.ESR)
- ;
- ; load time card segments into array TC()
- D LOADTC^PRSPLVU(PPI,PRSIEN,PPDN,.TC)
- ;
- ; determine leave postings
- ; loop thru tour segments
- S TSID="" F S TSID=$O(TOD(TSID)) Q:TSID="" D Q:$G(FATAL)
- . S TSY=TOD(TSID)
- . S TSS=$P(TSY,U)
- . S TSE=$P(TSY,U,2)
- . ; skip if tour seg. end < OR = to leave start
- . Q:TSE'>LVDTS
- . ; skip if tour seg. start > OR = to leave end
- . Q:TSS'<LVDTE
- . ;
- . ; leave overlaps tour segment
- . ;
- . ; determine posting times
- . ; posting start is greater of leave start and tour seg. start
- . S PSTDTS=$S(LVDTS>TSS:LVDTS,1:TSS)
- . ; posting end is lesser of leave end and tour seg. end
- . S PSTDTE=$S(LVDTE<TSE:LVDTE,1:TSE)
- . ;
- . ; determine type of time to post
- . S PSTTYP=$P(LVY0,U,7)
- . I $P(TSY,U,3)'="RG","TR TV"'[PSTTYP S PSTTYP="UN"
- . ;
- . S PSTMEAL=0 ; init meal time
- . ;
- . ; if leave is within or equal to the tour segment then calculate
- . ; a meal based on the user-specified leave request hours
- . I LVDTS'<TSS,LVDTE'>TSE D
- . . N CLM,FLD,TODI,TODN
- . . Q:$P(TSY,U,3)'="RG"
- . . S CLM=($$FMDIFF^XLFDT(LVDTE,LVDTS,2))/60 ; calc lv length min
- . . S PSTMEAL=CLM-($P(LVY0,U,15)*60)
- . . I PSTMEAL<0 S PSTMEAL=0 Q ; must be positive or zero
- . . I PSTMEAL#15 S PSTMEAL=0 Q ; must be multiple of 15
- . . ; must not exceed meal time for TOD
- . . S TODN=$P(TSID,"-",1) ; determine tour # (1 or 2) for segment
- . . I PSTMEAL>$P($G(TODD(TODN)),U,3) S PSTMEAL=$P($G(TODD(TODN)),U,3)
- . ;
- . ; if meal was not set based on leave request hours then check if it
- . ; can be set based on tour info
- . I PSTMEAL=0 D
- . . N TODN
- . . S TODN=$P(TSID,"-",1) ; tour # (1 or 2)
- . . ; quit if tour does not have a meal
- . . Q:$P($G(TODD(TODN)),U,3)'>0
- . . ; quit if segment # currently being processed is not the longest
- . . ; (better to place meal in the longest segment when more than one)
- . . Q:$P($G(TODD(TODN)),U,4)'=$P(TSID,"-",2)
- . . ; quit if leave started after tour began
- . . Q:LVDTS>$P($G(TODD(TODN)),U,1)
- . . ; quit if leave ended before tour ended
- . . Q:LVDTE<$P($G(TODD(TODN)),U,2)
- . . ; since leave covers the entire tour - set meal time based on tour
- . . S PSTMEAL=$P($G(TODD(TODN)),U,3)
- . ;
- . ; skip if proposed posting covered by holiday excused on ESR
- . S FOUND=0
- . ; loop thru ESR segments
- . S SEGI="" F S SEGI=$O(ESR(SEGI)) Q:SEGI="" D Q:FOUND
- . . N ESRY
- . . S ESRY=ESR(SEGI)
- . . Q:$P(ESRY,U,3)'="HX" ; quit if not holiday ex
- . . I PSTDTS'<$P(ESRY,U),PSTDTE'>$P(ESRY,U,2) S FOUND=1
- . Q:FOUND ; skip because posting is within HX (holiday excused)
- . ;
- . ; skip if proposed posting is already on the ESR
- . S FOUND=0
- . ; loop thru ESR segments
- . S SEGI="" F S SEGI=$O(ESR(SEGI)) Q:SEGI="" D Q:FOUND
- . . N ESRY
- . . S ESRY=ESR(SEGI)
- . . Q:$P(ESRY,U,3)'=PSTTYP ; quit if same type
- . . I PSTDTS'<$P(ESRY,U),PSTDTE'>$P(ESRY,U,2) S FOUND=1
- . Q:FOUND ; skip because posting is already covered on ESR
- . ;
- . ; if time card status = "P" and proposed posting in not on the
- . ; current time card then record a fatal exception and quit
- . ; loop thru time card exception segments
- . I TCST="P" D I 'FOUND S FATAL="1^"_PPI Q
- . . S FOUND=0
- . . S SEGI="" F S SEGI=$O(TC(SEGI)) Q:SEGI="" D Q:FOUND
- . . . N TCY
- . . . S TCY=TC(SEGI)
- . . . Q:$P(TCY,U,3)'=PSTTYP ; quit if not same type
- . . . I PSTDTS'<$P(TCY,U),PSTDTE'>$P(TCY,U,2) S FOUND=1
- . ;
- . ; OK to add posting to FDA array
- . ;
- . ; review ESR and FDA to determine next open segment
- . S PSTSEG=0 F SEGI=1:1:7 I '$D(ESR(SEGI)) S PSTSEG=SEGI Q
- . ;
- . ; if segment not available then report exception and skip?
- . Q:'PSTSEG
- . ;
- . ; add posting to FDA() array and ESR() array
- . S PRSFDA(458.02,PPDIENS,(PSTSEG-1)*5+110)=$$FMETA^PRSPLVU($P(PSTDTS,".",2)) ; start time
- . S PRSFDA(458.02,PPDIENS,(PSTSEG-1)*5+111)=$$FMETA^PRSPLVU($P(PSTDTE,".",2)) ; stop time
- . S PRSFDA(458.02,PPDIENS,(PSTSEG-1)*5+112)=PSTTYP ; type time
- . S PRSFDA(458.02,PPDIENS,(PSTSEG-1)*5+114)=PSTMEAL ; meal
- . S ESR(PSTSEG)=PSTDTS_U_PSTDTE_U_PSTTYP_U_PRSFDA(458.02,PPDIENS,(PSTSEG-1)*5+110)_U_PRSFDA(458.02,PPDIENS,(PSTSEG-1)*5+111)_U_PSTMEAL
- ;
- ; quit if fatal exception
- Q:$G(FATAL)
- ;
- ; quit if nothing will be posted to ESR day
- Q:'$D(PRSFDA(458.02,PPDIENS))
- ;
- ; obtain current ESR daily status
- S ESRST=$P($G(^PRST(458,PPI,"E",PRSIEN,"D",PPDN,7)),U)
- ;
- ; determine proposed new status of ESR day
- ;
- ; determine if any ESR time segments overlap
- ; (some types of time are excluded from check)
- S OVERLAP=0
- S SEGI=0 F S SEGI=$O(ESR(SEGI)) Q:'SEGI D
- . N SEGJ,SEGX,SEGY
- . S SEGX=ESR(SEGI)
- . Q:"ON SB UN"[$P(SEGX,U,3)
- . S SEGJ=SEGI F S SEGJ=$O(ESR(SEGJ)) Q:'SEGJ D
- . . S SEGY=ESR(SEGJ)
- . . Q:"ON SB UN"[$P(SEGY,U,3)
- . . Q:$P(SEGX,U,2)'>$P(SEGY,U,1)
- . . Q:$P(SEGX,U,1)'<$P(SEGY,U,2)
- . . S OVERLAP=1
- ;
- ; determine if entire tour covered by leave
- S PRSX=$G(^PRST(458,PPI,"E",PRSIEN,"D",PPDN,0))
- S TODL=$P(PRSX,U,8)+$P(PRSX,U,14) ; tour of duty length in hours
- ; loop thru ESR segments to add up leave
- S ESRLVM=0 ; leave in minutes
- S SEGI="" F S SEGI=$O(ESR(SEGI)) Q:SEGI="" D
- . N ESRY,SEGLVM
- . S ESRY=ESR(SEGI)
- . Q:"AL SL WP CU AA ML RL NL CB AD DL"'[$P(ESRY,U,3)
- . S SEGLVM=($$FMDIFF^XLFDT($P(ESRY,U,2),$P(ESRY,U,1),2)/60)-$P(ESRY,U,6)
- . S ESRLVM=ESRLVM+SEGLVM
- S TOURLV=$S((ESRLVM/60)'<TODL:1,1:0) ; true if tour covered by leave
- ;
- ; determine if any RG time on ESR
- S ESRRG=$S($G(^PRST(458,PPI,"E",PRSIEN,"D",PPDN,5))["RG":1,1:0)
- ;
- ; if not started/pending/resubmit and no RG, no overlaps, and
- ; tour covered by leave then auto sign based on leave. Otherwise,
- ; if not started then change to pending
- I "^1^2^3^"[(U_ESRST_U) D
- . N SIGNED
- . S SIGNED=0
- . I 'ESRRG,'OVERLAP,TOURLV D
- . . S PRSFDA(458.02,PPDIENS,146)="4" ; status = signed
- . . S PRSFDA(458.02,PPDIENS,147)=$$NOW^XLFDT() ; signed d/t
- . . S PRSFDA(458.02,PPDIENS,149)="3" ; signed method = leave request
- . . S SIGNED=1
- . I 'SIGNED,ESRST=1 S PRSFDA(458.02,PPDIENS,146)="2" ; status = pending
- ;
- ; if signed or approved and no overlap then re-sign. Otherwise
- ; change to pending.
- I "^4^5^"[(U_ESRST_U) D
- . ;
- . I 'OVERLAP D
- . . S PRSFDA(458.02,PPDIENS,146)="4" ; status = signed
- . . S PRSFDA(458.02,PPDIENS,147)=$$NOW^XLFDT() ; signed d/t
- . . ; if tour covered by leave and method is extended absence then
- . . ; change signed method to leave
- . . I TOURLV,$P($G(^PRST(458,PPI,"E",PRSIEN,"D",PPDN,7)),U,3)=2 S PRSFDA(458.02,PPDIENS,149)="3"
- . ;
- . I OVERLAP D
- . . S PRSFDA(458.02,PPDIENS,146)="2" ; status = pending
- . . S PRSFDA(458.02,PPDIENS,147)="@" ; delete signed d/t
- . . S PRSFDA(458.02,PPDIENS,149)="@" ; delete signed method
- . ;
- . ; if day was approved and time card status = T then add to unpost list
- . I ESRST=5,TCST="T" S TCUNPOST(PPI,PPDN)=""
- ;
- Q
- ;
- ;PRSPLVA1
- --- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPRSPLVA1 8069 printed Feb 18, 2025@23:54:39 Page 2
- PRSPLVA1 ;WOIFO/SAB - AUTOPOST LEAVE FOR PTP (CONT) ;03/30/2005
- +1 ;;4.0;PAID;**93**;Sep 21, 1995;Build 7
- +2 ;;Per VHA Directive 2004-038, this routine should not be modified.
- +3 QUIT
- +4 ;
- PDAY ; Process Day (within Pay Period loop)
- +1 ; called from PRSPLVA
- +2 ; input variables LVDTE,LVDTS,LVY0,PPDN,PPI,PRSIEN,PRSFDA(),
- +3 ; TCST,TCUNPOST()
- +4 ; output variable
- +5 ; FATAL = 1^PPI, only defined if fatal exception occurred
- +6 ; PRSFDA() may be updated with additional data to post to ESR
- +7 ; TCUNPOST() may be updated with another day to unpost from timecard
- +8 ;
- +9 NEW ESR,ESRRG,ESRLVM,ESRST,FOUND,OVERLAP,PPDIENS,PRSDT,PRSX
- +10 NEW PSTDTE,PSTDTS,PSTMEAL,PSTSEG,PSTTYP,SEGI,TC,TOD,TODD,TODL,TOURLV
- +11 NEW TSE,TSID,TSS,TSY
- +12 ;
- +13 ; skip day if not a scheduled tour
- +14 if $PIECE($GET(^PRST(458,PPI,"E",PRSIEN,"D",PPDN,1)),U)=""
- QUIT
- +15 ;
- +16 SET PPDIENS=PPDN_","_PRSIEN_","_PPI_","
- +17 ;
- +18 ; FileMan date of day number
- SET PRSDT=$PIECE($GET(^PRST(458,PPI,1)),U,PPDN)
- +19 ;
- +20 ; load tour segments from both tours into arrays TOD() and TODD()
- +21 DO LOADTOD^PRSPLVU(PPI,PRSIEN,PPDN,.TOD,.TODD)
- +22 ;
- +23 ; load ESR segments into array ESR()
- +24 DO LOADESR^PRSPLVU(PPI,PRSIEN,PPDN,.ESR)
- +25 ;
- +26 ; load time card segments into array TC()
- +27 DO LOADTC^PRSPLVU(PPI,PRSIEN,PPDN,.TC)
- +28 ;
- +29 ; determine leave postings
- +30 ; loop thru tour segments
- +31 SET TSID=""
- FOR
- SET TSID=$ORDER(TOD(TSID))
- if TSID=""
- QUIT
- Begin DoDot:1
- +32 SET TSY=TOD(TSID)
- +33 SET TSS=$PIECE(TSY,U)
- +34 SET TSE=$PIECE(TSY,U,2)
- +35 ; skip if tour seg. end < OR = to leave start
- +36 if TSE'>LVDTS
- QUIT
- +37 ; skip if tour seg. start > OR = to leave end
- +38 if TSS'<LVDTE
- QUIT
- +39 ;
- +40 ; leave overlaps tour segment
- +41 ;
- +42 ; determine posting times
- +43 ; posting start is greater of leave start and tour seg. start
- +44 SET PSTDTS=$SELECT(LVDTS>TSS:LVDTS,1:TSS)
- +45 ; posting end is lesser of leave end and tour seg. end
- +46 SET PSTDTE=$SELECT(LVDTE<TSE:LVDTE,1:TSE)
- +47 ;
- +48 ; determine type of time to post
- +49 SET PSTTYP=$PIECE(LVY0,U,7)
- +50 IF $PIECE(TSY,U,3)'="RG"
- IF "TR TV"'[PSTTYP
- SET PSTTYP="UN"
- +51 ;
- +52 ; init meal time
- SET PSTMEAL=0
- +53 ;
- +54 ; if leave is within or equal to the tour segment then calculate
- +55 ; a meal based on the user-specified leave request hours
- +56 IF LVDTS'<TSS
- IF LVDTE'>TSE
- Begin DoDot:2
- +57 NEW CLM,FLD,TODI,TODN
- +58 if $PIECE(TSY,U,3)'="RG"
- QUIT
- +59 ; calc lv length min
- SET CLM=($$FMDIFF^XLFDT(LVDTE,LVDTS,2))/60
- +60 SET PSTMEAL=CLM-($PIECE(LVY0,U,15)*60)
- +61 ; must be positive or zero
- IF PSTMEAL<0
- SET PSTMEAL=0
- QUIT
- +62 ; must be multiple of 15
- IF PSTMEAL#15
- SET PSTMEAL=0
- QUIT
- +63 ; must not exceed meal time for TOD
- +64 ; determine tour # (1 or 2) for segment
- SET TODN=$PIECE(TSID,"-",1)
- +65 IF PSTMEAL>$PIECE($GET(TODD(TODN)),U,3)
- SET PSTMEAL=$PIECE($GET(TODD(TODN)),U,3)
- End DoDot:2
- +66 ;
- +67 ; if meal was not set based on leave request hours then check if it
- +68 ; can be set based on tour info
- +69 IF PSTMEAL=0
- Begin DoDot:2
- +70 NEW TODN
- +71 ; tour # (1 or 2)
- SET TODN=$PIECE(TSID,"-",1)
- +72 ; quit if tour does not have a meal
- +73 if $PIECE($GET(TODD(TODN)),U,3)'>0
- QUIT
- +74 ; quit if segment # currently being processed is not the longest
- +75 ; (better to place meal in the longest segment when more than one)
- +76 if $PIECE($GET(TODD(TODN)),U,4)'=$PIECE(TSID,"-",2)
- QUIT
- +77 ; quit if leave started after tour began
- +78 if LVDTS>$PIECE($GET(TODD(TODN)),U,1)
- QUIT
- +79 ; quit if leave ended before tour ended
- +80 if LVDTE<$PIECE($GET(TODD(TODN)),U,2)
- QUIT
- +81 ; since leave covers the entire tour - set meal time based on tour
- +82 SET PSTMEAL=$PIECE($GET(TODD(TODN)),U,3)
- End DoDot:2
- +83 ;
- +84 ; skip if proposed posting covered by holiday excused on ESR
- +85 SET FOUND=0
- +86 ; loop thru ESR segments
- +87 SET SEGI=""
- FOR
- SET SEGI=$ORDER(ESR(SEGI))
- if SEGI=""
- QUIT
- Begin DoDot:2
- +88 NEW ESRY
- +89 SET ESRY=ESR(SEGI)
- +90 ; quit if not holiday ex
- if $PIECE(ESRY,U,3)'="HX"
- QUIT
- +91 IF PSTDTS'<$PIECE(ESRY,U)
- IF PSTDTE'>$PIECE(ESRY,U,2)
- SET FOUND=1
- End DoDot:2
- if FOUND
- QUIT
- +92 ; skip because posting is within HX (holiday excused)
- if FOUND
- QUIT
- +93 ;
- +94 ; skip if proposed posting is already on the ESR
- +95 SET FOUND=0
- +96 ; loop thru ESR segments
- +97 SET SEGI=""
- FOR
- SET SEGI=$ORDER(ESR(SEGI))
- if SEGI=""
- QUIT
- Begin DoDot:2
- +98 NEW ESRY
- +99 SET ESRY=ESR(SEGI)
- +100 ; quit if same type
- if $PIECE(ESRY,U,3)'=PSTTYP
- QUIT
- +101 IF PSTDTS'<$PIECE(ESRY,U)
- IF PSTDTE'>$PIECE(ESRY,U,2)
- SET FOUND=1
- End DoDot:2
- if FOUND
- QUIT
- +102 ; skip because posting is already covered on ESR
- if FOUND
- QUIT
- +103 ;
- +104 ; if time card status = "P" and proposed posting in not on the
- +105 ; current time card then record a fatal exception and quit
- +106 ; loop thru time card exception segments
- +107 IF TCST="P"
- Begin DoDot:2
- +108 SET FOUND=0
- +109 SET SEGI=""
- FOR
- SET SEGI=$ORDER(TC(SEGI))
- if SEGI=""
- QUIT
- Begin DoDot:3
- +110 NEW TCY
- +111 SET TCY=TC(SEGI)
- +112 ; quit if not same type
- if $PIECE(TCY,U,3)'=PSTTYP
- QUIT
- +113 IF PSTDTS'<$PIECE(TCY,U)
- IF PSTDTE'>$PIECE(TCY,U,2)
- SET FOUND=1
- End DoDot:3
- if FOUND
- QUIT
- End DoDot:2
- IF 'FOUND
- SET FATAL="1^"_PPI
- QUIT
- +114 ;
- +115 ; OK to add posting to FDA array
- +116 ;
- +117 ; review ESR and FDA to determine next open segment
- +118 SET PSTSEG=0
- FOR SEGI=1:1:7
- IF '$DATA(ESR(SEGI))
- SET PSTSEG=SEGI
- QUIT
- +119 ;
- +120 ; if segment not available then report exception and skip?
- +121 if 'PSTSEG
- QUIT
- +122 ;
- +123 ; add posting to FDA() array and ESR() array
- +124 ; start time
- SET PRSFDA(458.02,PPDIENS,(PSTSEG-1)*5+110)=$$FMETA^PRSPLVU($PIECE(PSTDTS,".",2))
- +125 ; stop time
- SET PRSFDA(458.02,PPDIENS,(PSTSEG-1)*5+111)=$$FMETA^PRSPLVU($PIECE(PSTDTE,".",2))
- +126 ; type time
- SET PRSFDA(458.02,PPDIENS,(PSTSEG-1)*5+112)=PSTTYP
- +127 ; meal
- SET PRSFDA(458.02,PPDIENS,(PSTSEG-1)*5+114)=PSTMEAL
- +128 SET ESR(PSTSEG)=PSTDTS_U_PSTDTE_U_PSTTYP_U_PRSFDA(458.02,PPDIENS,(PSTSEG-1)*5+110)_U_PRSFDA(458.02,PPDIENS,(PSTSEG-1)*5+111)_U_PSTMEAL
- End DoDot:1
- if $GET(FATAL)
- QUIT
- +129 ;
- +130 ; quit if fatal exception
- +131 if $GET(FATAL)
- QUIT
- +132 ;
- +133 ; quit if nothing will be posted to ESR day
- +134 if '$DATA(PRSFDA(458.02,PPDIENS))
- QUIT
- +135 ;
- +136 ; obtain current ESR daily status
- +137 SET ESRST=$PIECE($GET(^PRST(458,PPI,"E",PRSIEN,"D",PPDN,7)),U)
- +138 ;
- +139 ; determine proposed new status of ESR day
- +140 ;
- +141 ; determine if any ESR time segments overlap
- +142 ; (some types of time are excluded from check)
- +143 SET OVERLAP=0
- +144 SET SEGI=0
- FOR
- SET SEGI=$ORDER(ESR(SEGI))
- if 'SEGI
- QUIT
- Begin DoDot:1
- +145 NEW SEGJ,SEGX,SEGY
- +146 SET SEGX=ESR(SEGI)
- +147 if "ON SB UN"[$PIECE(SEGX,U,3)
- QUIT
- +148 SET SEGJ=SEGI
- FOR
- SET SEGJ=$ORDER(ESR(SEGJ))
- if 'SEGJ
- QUIT
- Begin DoDot:2
- +149 SET SEGY=ESR(SEGJ)
- +150 if "ON SB UN"[$PIECE(SEGY,U,3)
- QUIT
- +151 if $PIECE(SEGX,U,2)'>$PIECE(SEGY,U,1)
- QUIT
- +152 if $PIECE(SEGX,U,1)'<$PIECE(SEGY,U,2)
- QUIT
- +153 SET OVERLAP=1
- End DoDot:2
- End DoDot:1
- +154 ;
- +155 ; determine if entire tour covered by leave
- +156 SET PRSX=$GET(^PRST(458,PPI,"E",PRSIEN,"D",PPDN,0))
- +157 ; tour of duty length in hours
- SET TODL=$PIECE(PRSX,U,8)+$PIECE(PRSX,U,14)
- +158 ; loop thru ESR segments to add up leave
- +159 ; leave in minutes
- SET ESRLVM=0
- +160 SET SEGI=""
- FOR
- SET SEGI=$ORDER(ESR(SEGI))
- if SEGI=""
- QUIT
- Begin DoDot:1
- +161 NEW ESRY,SEGLVM
- +162 SET ESRY=ESR(SEGI)
- +163 if "AL SL WP CU AA ML RL NL CB AD DL"'[$PIECE(ESRY,U,3)
- QUIT
- +164 SET SEGLVM=($$FMDIFF^XLFDT($PIECE(ESRY,U,2),$PIECE(ESRY,U,1),2)/60)-$PIECE(ESRY,U,6)
- +165 SET ESRLVM=ESRLVM+SEGLVM
- End DoDot:1
- +166 ; true if tour covered by leave
- SET TOURLV=$SELECT((ESRLVM/60)'<TODL:1,1:0)
- +167 ;
- +168 ; determine if any RG time on ESR
- +169 SET ESRRG=$SELECT($GET(^PRST(458,PPI,"E",PRSIEN,"D",PPDN,5))["RG":1,1:0)
- +170 ;
- +171 ; if not started/pending/resubmit and no RG, no overlaps, and
- +172 ; tour covered by leave then auto sign based on leave. Otherwise,
- +173 ; if not started then change to pending
- +174 IF "^1^2^3^"[(U_ESRST_U)
- Begin DoDot:1
- +175 NEW SIGNED
- +176 SET SIGNED=0
- +177 IF 'ESRRG
- IF 'OVERLAP
- IF TOURLV
- Begin DoDot:2
- +178 ; status = signed
- SET PRSFDA(458.02,PPDIENS,146)="4"
- +179 ; signed d/t
- SET PRSFDA(458.02,PPDIENS,147)=$$NOW^XLFDT()
- +180 ; signed method = leave request
- SET PRSFDA(458.02,PPDIENS,149)="3"
- +181 SET SIGNED=1
- End DoDot:2
- +182 ; status = pending
- IF 'SIGNED
- IF ESRST=1
- SET PRSFDA(458.02,PPDIENS,146)="2"
- End DoDot:1
- +183 ;
- +184 ; if signed or approved and no overlap then re-sign. Otherwise
- +185 ; change to pending.
- +186 IF "^4^5^"[(U_ESRST_U)
- Begin DoDot:1
- +187 ;
- +188 IF 'OVERLAP
- Begin DoDot:2
- +189 ; status = signed
- SET PRSFDA(458.02,PPDIENS,146)="4"
- +190 ; signed d/t
- SET PRSFDA(458.02,PPDIENS,147)=$$NOW^XLFDT()
- +191 ; if tour covered by leave and method is extended absence then
- +192 ; change signed method to leave
- +193 IF TOURLV
- IF $PIECE($GET(^PRST(458,PPI,"E",PRSIEN,"D",PPDN,7)),U,3)=2
- SET PRSFDA(458.02,PPDIENS,149)="3"
- End DoDot:2
- +194 ;
- +195 IF OVERLAP
- Begin DoDot:2
- +196 ; status = pending
- SET PRSFDA(458.02,PPDIENS,146)="2"
- +197 ; delete signed d/t
- SET PRSFDA(458.02,PPDIENS,147)="@"
- +198 ; delete signed method
- SET PRSFDA(458.02,PPDIENS,149)="@"
- End DoDot:2
- +199 ;
- +200 ; if day was approved and time card status = T then add to unpost list
- +201 IF ESRST=5
- IF TCST="T"
- SET TCUNPOST(PPI,PPDN)=""
- End DoDot:1
- +202 ;
- +203 QUIT
- +204 ;
- +205 ;PRSPLVA1