Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: PRS8MSC0

PRS8MSC0.m

Go to the documentation of this file.
  1. PRS8MSC0 ;HISC/DAD,WCIOFO/JAH,SAB - MISC TIME CARD ADJUST(contd) ;4/04/2007
  1. ;;4.0;PAID;**22,35,40,56,111,112**;Sep 21, 1995;Build 54
  1. ;;Per VHA Directive 2004-038, this routine should not be modified.
  1. ;
  1. ; for employee on daily tour check if no duty performed during week
  1. I TYP["D" D NODUTY^PRS8MSC1
  1. ;
  1. S B="",Z0="" S $P(B,"B",97)="",$P(Z0,"0",97)="",FLAG=0
  1. F X=1:1:PEROWK S Y=$P(PEROWK(X),"^",4),DAT=$P(PEROWK(X),"^",1,3),DY=$P(DAT,"^",1),BEG=$P(DAT,"^",2),END=$P(DAT,"^",3) D
  1. .I $L(Y)'<96,TYP'["Ff",$E(ENT,27) D ; slp for 24hr cvg
  1. ..S SLMAX=32,(SLW,SLY,SLST,SLSTR,SLST1,SLY1,SL1,SL2,SL3)=""
  1. ..I END=96 D
  1. ...S SLST=$P($G(PEROWK(X)),"^",4),SL2=$E(SLST,SST,$L(SLST)),SL1=$E(SLST,1,SLMAX-$L(SL2)),SL3=$L(SL2)
  1. ...S SLSTR=SL1_SL2
  1. ...I DOUB S SLSTR=$TR(SLSTR,"Cct","Bbb") ; if PPC = W then OC = SB
  1. ...S SLSTR=$TR(SLSTR,$TR(SLSTR,"Bb"),Z0)
  1. ...S SLY=$L($TR(SLSTR,"b0")),SLW=$L($TR(SLSTR,"B0"))
  1. ...I SLW>12 Q
  1. ...I DY=0 S FLAG=SL3
  1. ...S Y=$L(SLSTR)-SLW
  1. ...I FLAG>0&(DY=1) S Y=Y-FLAG,FLAG=0
  1. ...S D=DY,P=25 D SET Q
  1. ..E D
  1. ...S SLST=$G(^TMP($J,"PRS8",DY,"W"))_$G(^TMP($J,"PRS8",DY+1,"W"))
  1. ...S SLSTR=$E(SLST,1,SST+(SLMAX-1))
  1. ...I DOUB S SLSTR=$TR(SLSTR,"Cct","Bbb") ; if PPC = W then OC = SB
  1. ...S SLSTR=$TR(SLSTR,$TR(SLSTR,"Bb"),Z0)
  1. ...S SLY=$E(SLSTR,SST,96),SLY1=$E(SLSTR,97,$L(SLSTR))
  1. ...S SLSTR=SLY_SLY1,SLW=$L($TR(SLSTR,"B0"))
  1. ...I SLW>12 Q
  1. ...S D=DY,Y=$L($TR(SLY,"b0")),P=25 D SET
  1. ...Q:DY=0 S D=DY+1,Y=$L($TR(SLY1,"b0")) D SET
  1. ...Q
  1. ..K BEG,DAT,END,NL,SLW,SLY,SLST,SLSTR,SLST1,SLY1,SL1,SL2,SL3 Q
  1. .Q
  1. S D="",(H,ROSS)=1 K OT,UN,DA,CT
  1. F H=H:ROSS:PEROT D ; calculate CB OT and FF OT/sleep time
  1. .S Y=PEROT(H),Z=$P(Y,"^",3)
  1. .I "Ff"[TYP D ;K OT,UN,DA D ; FF sleep time
  1. ..F M=1:1:$L(Z) D ; following FF OT per Mary Baker 4/1/93
  1. ...I D'=+Y+(($P(Y,"^",2)+M-2)\96) D
  1. ....S D=+Y+(($P(Y,"^",2)+M-2)\96),HT=0
  1. ....Q
  1. ...S HT=HT+1
  1. ...I $E(Z,H)="E" S CT(D)=$G(CT(D))+1 Q
  1. ...I M'>32 S:HT'>32 OT(D)=$G(OT(D))+1 S:HT>32 DA(D)=$G(DA(D))+1 ; FF OT
  1. ...I M>32,$L(Z)'<96&(M'>64)!($L(Z)<96) S DA(D)=$G(DA(D))+1 ; FF hrs>8
  1. ...I $L(Z)'<96,M>64 D ; FF 2/3 rule
  1. ....I M'>96 S UN(D)=$G(UN(D))+1 ; first 8 sleep time
  1. ....E S DA(D)=$G(DA(D))+1 ; rest hrs >8
  1. ....Q
  1. ...Q
  1. ..Q
  1. .I $L(Z)<8 D ; call back OT at least 2 hrs
  1. ..S YY=Y,ZZ=Z N X,Y,START,STOP,T,TT,Z,DD,TL S Y=YY,Z=ZZ
  1. ..S CB=$G(^TMP($J,"PRS8",+Y,"CB"))
  1. ..;no call back OT today or send bulletin
  1. ..Q:(CB="")!($$OTNXTPP(+Y,CB,$P(C0,"^",1),PY,$P(C0,"^",8)))
  1. ..S Q=0 F ZZ=1:2 Q:'$P(CB,"^",ZZ) I $P(Y,"^",2)=$P(CB,"^",ZZ) S Q=1
  1. ..Q:'Q ; this OT episode not call back
  1. ..S OT=Y,START=$P(OT,"^",2),STOP=$P(OT,"^",2)+$L(Z)-1,T=START,TT=$S(T>96:T-96,1:T)
  1. ..S W=$G(^TMP($J,"PRS8",+OT,"W")),WEEK=$S(+OT>7:2,1:1)
  1. ..S W1=$G(^TMP($J,"PRS8",OT-1,"W"))
  1. ..S W2=$G(^TMP($J,"PRS8",OT+1,"W"))
  1. ..S (Z,X)=0 F Z=1:1:8-(STOP-START+1) D Q:X=0
  1. ...S DD=Z
  1. ...I TT-DD>0 S X=$E(W,TT-DD)
  1. ...E S X=$E(W1,96+T-DD)
  1. ...I "123m"[X,$E($G(^TMP($J,"PRS8",$S(TT-DD>0:+OT,1:OT-1),"HOL")),$S(TT-DD>0:TT-DD,1:96+T-DD))=1 S X=0 ; HX becomes time off
  1. ...Q
  1. ..S ZZ=Z S:X=0&Z ZZ=ZZ-1 S X=0,T=STOP,TT=$S(T>96:T-96,1:T)
  1. ..F Z=1:1:8-(STOP-START+1+ZZ) D Q:X=0
  1. ...S DD=STOP-START+1+ZZ+Z
  1. ...I T+Z'>96 S X=$E(W,T+Z)
  1. ...E S X=$E(W2,T-96+Z)
  1. ...I "123m"[X,$E($G(^TMP($J,"PRS8",$S(T+Z'>96:+OT,1:OT+1),"HOL")),$S(T+Z'>96:T+Z,1:T-96+Z))=1 S X=0 ; HX becomes time off
  1. ...Q
  1. ..S Z=ZZ+Z-(X=0&Z)
  1. ..I STOP-START+1+Z<8 D
  1. ...I TYP["W",$E($P(PEROT(H),"^",3))'="E"&($G(^TMP($J,"PRS8",$P(PEROT(H),"^",1),"OFF"))=0) S TOUR=$G(^TMP($J,"PRS8",$P(PEROT(H),"^",1),"TOUR"))
  1. ...S D=+OT,P=$S($E($P(PEROT(H),"^",3))'="E":TOUR+19,1:7),Y=8-(STOP-START+1+Z)
  1. ...;
  1. ...I TYP["P",TYP'["B",P'=7,'+NAWS D
  1. ....I $P($G(^TMP($J,"PRS8",$P(PEROT(H),"^",1),"OFF")),"^",1)=1&(TH(WEEK)'>160) S Y=0 Q
  1. ....I $P(C0,"^",12)="E" S P=$S($L($TR(W,"0O"))>31&(TH(WEEK)'>160):TOUR+25,1:P) D:Y SET S Y=$S(TH(WEEK)'>160:Y,1:0) S P=9 D:Y SET S Y=0
  1. ...I $P(C0,"^",12)="N",P'=7 S P=$S($L($TR(W,"0O"))>31:TOUR+15,1:P) D:Y SET S Y=0
  1. ...D:Y&('+NAWS) SET
  1. ...;
  1. ...I +NAWS D Q ; Checks for just the AWS nurses
  1. ....N CNT,HT,I
  1. ....S CNT=Y,Y=1,HT=$G(^TMP($J,"PRS8",D,"HT"))
  1. ....F I=1:1:CNT D
  1. .....I HT'<32 S P=$S(P'=7:TOUR+15,1:P) D SET1 Q ; DA/DE or CE/CT
  1. .....I TH($S(+OT>7:2,1:1))'<160 S P=$S(P'=7:TOUR+19,1:P) D SET1 Q ; OA/OE or CE/CT
  1. .....I HT<32,TH($S(+OT>7:2,1:1))<160 S P=9 D SET1 Q ; UN/US
  1. ..Q
  1. .Q
  1. F X="OT","DA","UN","CT" D ; store FF OT into WK array
  1. .N Y S P=$S(X="OT":TOUR+19,X="DA"&$E(ENT,TOUR+18):TOUR+15,X="DA":TOUR+19,X="CT":TOUR+6,1:9)
  1. .F D=0:0 S D=$O(@(X_"("_D_")")) Q:D'>0 S Y=@(X_"("_D_")") D SET
  1. .Q
  1. ;
  1. ; check/adjust night differential granted for leave
  1. D LVND
  1. Q
  1. SET ; Set sleep time into WK array
  1. Q:D<1!(D>14)
  1. S WEEK=$S(D>7:2,1:1)
  1. S $P(WK(WEEK),"^",P)=$P(WK(WEEK),"^",P)+Y
  1. Q
  1. ;
  1. SET1 ; Set sleep time into WK array
  1. Q:D<1!(D>14)
  1. S WEEK=$S(D>7:2,1:1)
  1. S $P(WK(WEEK),"^",P)=$P(WK(WEEK),"^",P)+Y
  1. Q:(HT>32)&(TH(WEEK)<160)&(NH<320)&($E(ENT,19)=1)
  1. Q:(HT>32)&(TH(WEEK)<160)&(NH=320)&($E(ENT,19)=1)&($E(AC,2)=2) ; 9month AWS
  1. S HT=HT+1,TH(WEEK)=TH(WEEK)+1
  1. S ^TMP($J,"PRS8",D,"HT")=^TMP($J,"PRS8",D,"HT")+1
  1. Q
  1. ;
  1. OTNXTPP(DAY,CALLBK,EMPNM,PPIEN,TLU) ;
  1. ;OT or CT connects to a tour of duty in the next pay period.
  1. ;JAH-patch PRS*4*22
  1. ;If OT or CT are worked in last 2 hours of pay period & 1st day
  1. ;of next pay period is missing a tour beginning at midnight, send
  1. ;a bulletin warning that call back will be paid unless corrective
  1. ;action is taken.
  1. ;(i.e a nurse comes in before midnight on last saturday of
  1. ;pay period & works for a period less than 2 hrs. before her tour
  1. ;that begins at midnight on Sunday, first day of the next pp)
  1. ;
  1. ; CALLBK = start and stop position in 96 char BCD string.
  1. ; RECORD = pointer from employee's tour info to a record
  1. ; in tour of duty file.
  1. ; DAY = day of the pay period
  1. ; D1NXTPP = BOOLEAN; set to true if tour on day 1 of next pay period
  1. ; begins at midnight, otherwise false
  1. ; NEXTP = next pay period in 97-05 format.
  1. ; CURP = current pay period in 99-02 format.
  1. ; TLU = 3 digit time & leave unit of employee.
  1. N D1NXTPP,RECORD,CURP,NEXTP,XMDUZ,XMB,XMY,XMDUZ
  1. S (RTN,D1NXTPP)=0
  1. S RECORD=$P($G(^TMP($J,"PRS8",15,0)),"^",2)
  1. I RECORD'="" S D1NXTPP=($P($G(^PRST(457.1,RECORD,1)),"^")="MID")
  1. I (DAY=14)&($P(CALLBK,"^",2)=96) D
  1. . I (D1NXTPP) S RTN=1
  1. . E D
  1. .. S CURP=$P($G(^PRST(458,PPIEN,0)),"^",1)
  1. .. S NXTP=$E($$NXTPP^PRSAPPU(CURP),3,7)
  1. ..; Send bulletin to G.PAD
  1. .. S XMY("G.PAD@"_^XMB("NETNAME"))=""
  1. .. S XMDUZ="DHCP PAID package"
  1. .. S XMB="PRS LAST SAT OT/CT"
  1. ..;
  1. ..; employee name, pay period number, next pay period
  1. .. S XMB(1)=EMPNM,XMB(2)=CURP,XMB(3)=NXTP,XMB(4)=TLU
  1. .. D ^XMB
  1. Q RTN
  1. ;
  1. LVND ; Leave Night Differential
  1. ; back out ND granted for leave if employee took 8 or more hrs of leave
  1. ; a non-wage grade employee can receive night differential when
  1. ; on leave as long as the employee has taken less than 8 hours of
  1. ; leave during the pay period.
  1. ; input (note: units are count of 15min time segments):
  1. ; LU - leave taken during pay period (set in PRS8AC, PRS8MT)
  1. ; WK(#) - piece 10 contains total shift-2 ND for week #
  1. ; WKL(#) - ND granted for leave during week # (set in PRS8PP)
  1. ; output:
  1. ; WK(#) - piece 10 may be modified
  1. ; WKL(#) - may be modified
  1. N W
  1. Q:TYP["W" ; Doesn't apply to Wage Grade
  1. Q:LU'>31 ; Didn't take 8hrs of leave
  1. F W=1,2 D ; For each week subtract leave ND from total ND
  1. . Q:'WKL(W) ; No leave ND to subtract
  1. . I +NAWS'=36 S $P(WK(W),"^",10)=$P(WK(W),"^",10)-WKL(W) ; Subtract
  1. . ; For 36/40 AWS subtract time from Night Differential-AWS (piece 51)
  1. . I +NAWS=36 S $P(WK(W),"^",51)=$P(WK(W),"^",51)-WKL(W)
  1. . S WKL(W)=0 ; Reset leave ND amount
  1. Q