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

PRS8OC.m

Go to the documentation of this file.
  1. PRS8OC ;HISC/MGD-DECOMPOSITION, ON-CALL ;02/27/07
  1. ;;4.0;PAID;**63,92,112,117**;Sep 21, 1995;Build 32
  1. ;;Per VHA Directive 2004-038, this routine should not be modified.
  1. ;
  1. ;The following MUMPS code is used to credit the appropriate
  1. ;categories on the timecard for work performed while On-Call.
  1. ;All hours during which an individual is identified as being
  1. ;On-Call are credited to blocks YD and YH (On Call Hrs) on
  1. ;the timecard. Hours during an On-Call episode where an
  1. ;individual is actually called in to perform work are credited
  1. ;to blocks YA and YE (Sch CB OT) as appropriate. This credit
  1. ;is given under the 2-hour minimum rule. When OT work is
  1. ;performed during On-Call the actual On-Call Hours reported
  1. ;are reduced by the ACTUAL number of hours worked (not by the
  1. ;2-hour minimum).
  1. ;
  1. ;Called by Routines: PRS8ST
  1. ;
  1. ;C = On-Call
  1. ;c = OT during OC
  1. ;t = CT during OC
  1. ;
  1. S (I,D)=$S(T'>96:DAY,1:(DAY+1))
  1. S OC=$G(OC),OC(DAY)=$G(OC(DAY)),OC(DAY+1)=$G(OC(DAY+1)) ;oc variables
  1. S CC=$G(CC),CC(DAY)=$G(CC(DAY)),CC(DAY+1)=$G(CC(DAY+1)) ;CT on OC count
  1. S Y=35,Y(1)=1 D SET
  1. I VAR1="C" D:OC!(CC) OCS ;on-call episode (ot OR ct)
  1. S:"ct"[VAR1 OC=OC+1,OC(D)=OC(D)+1 S:VAR1="t" CC=CC+1,CC(D)=CC(D)+1
  1. I "ct"[VAR1,DAY>0,DAY<15 S CBCK(WK)=CBCK(WK)+1 ;count actual CB hrs
  1. Q:'OK!('$D(OC))
  1. I OC S Y=23 D OCS ;get rest of them
  1. K OC,CC,Y,D Q
  1. ;
  1. OCS ; --- set On-Call minimum hours
  1. ;set YA/YE for PPI="W" or "V" else set OT
  1. I +NAWS=0 S Y=$S(CC:7,'DOUB:TOUR+19,1:23)
  1. I +NAWS S Y=$S(CC:7,1:TOUR+19)
  1. ;
  1. N X,Z,DD,TT,CCCNT,NEXTT,OCCNT,TIMECNT
  1. S TT=$S(T>96:T-96,1:T),TIMECNT=0
  1. S X=$E(DAY($S(T>96:DAY+1,1:DAY),"W"),TT)
  1. ;
  1. ; If the current segment is the last of the On-Call OR the last of
  1. ; the On-Call Callback and the next time segment is Unavailable ("-")
  1. ; or not a type of work ("0") check to see if OT/reg sched is prior
  1. ; to on call worked.
  1. ;
  1. S NEXTT=$S(T+1>96:T-95,1:TT+1) ; Next time segment
  1. I "C"[X!(("ct"[X)&("-0"[$E($S(T+1>96:DAY(DAY+1,"W"),1:DAY(DAY,"W")),NEXTT))) D
  1. .K XH S X=0 F Z=1:1:8-(OC(DAY)+$G(OC(DAY+1))) D Q:"01"[X
  1. ..S DD=OC(DAY)+OC(DAY+1)+Z
  1. ..I TT-DD>0 S X=$E(DAY(DAY,"W"),TT-DD) S:X="O"&($E(DAY(DAY,"HOL"),TT-DD)=2) X="h"
  1. ..E S X=$E(DAY(DAY-1,"W"),96+T-DD) S:X="O"&($E(DAY(DAY-1,"HOL"),96+T-DD)=2) X="h"
  1. ..I "123nHMLSWNARXYFGDUZq"[X S X=1 Q ; on call abuts a reg sched TOD.
  1. ..E I "EOhoscteQ"[X D ; on call abuts time worked outside posted TOD.
  1. ...I "ct"'[X S TIMECNT=TIMECNT+1 ; Time already counted in WK().
  1. ...S XH=$S(X'="h":0,1:1),X=2
  1. ..E S X=0
  1. ..Q
  1. .Q
  1. E D ; Check to see if OT/reg sched is after on call worked
  1. .K XH S X=0 F Z=1:1:8-(OC(DAY)+$G(OC(DAY+1))) D Q:"01"[X
  1. ..S DD=OC(DAY)+OC(DAY+1)+Z
  1. ..I T+Z'>96 S X=$E(DAY(DAY,"W"),T+Z) S:X="O"&($E(DAY(DAY,"HOL"),T+Z)=2) X="h"
  1. ..E S X=$E(DAY(DAY+1,"W"),T-96+Z) S:X="O"&($E(DAY(DAY+1,"HOL"),T-96+Z)=2) X="h"
  1. ..I "123nHMLSWNARXYFGDUZq"[X S X=1 Q ; on call abuts a reg sched TOD.
  1. ..E I "EOhoscteQ"[X D
  1. ...I "ct"'[X S TIMECNT=TIMECNT+1 ; Time already counted in WK().
  1. ...S XH=$S(X'="h":0,1:1),X=2
  1. ..E S X=0
  1. ..Q
  1. .Q
  1. I $G(XH)'="" S:XH=1!'X Z=Z-1,X=2
  1. ;
  1. ; Check if Scheduled Call-Back OT crosses Midnight
  1. ;
  1. I '$D(CRSMID(D)),$E(DAY(DAY,"W"),1)="c",$E(DAY(DAY-1,"W"),96)="c" S FG=0 D Q:FG=1
  1. .S CRSMID(D)=1
  1. .I OC<7 D Q:FG=1
  1. ..; crosses midnight, check if its <2 hours, CRSMID variable set to
  1. ..; only do on segment that cross mid, not others
  1. ..S CNTR=0 F CX=1:1:8-OC S:$E(DAY(DAY-1,"W"),97-CX)="c" CNTR=CNTR+1
  1. ..I OC+CNTR'>8 D
  1. ...S Y(1)=$S(X=1:OC,1:8-CNTR)
  1. ...I +NAWS=0 D CHOL ; Process everyone but AWS nurses
  1. ...I +NAWS D CHOL1 ; Process AWS nurses
  1. ...S (OC,OC(D),CC,CC(D))=0,FG=1
  1. ..Q
  1. ;
  1. ; Check if Comp Time crosses Midnight
  1. ;
  1. I '$D(CRSMID(D)),$E(DAY(DAY,"W"),1)="t",$E(DAY(DAY-1,"W"),96)="t" S FG=0 D Q:FG=1
  1. .S CRSMID(D)=1
  1. .I OC<7 D Q:FG=1
  1. ..; crosses midnight, check if its <2 hours, CRSMID variable set to
  1. ..; only do on segment that cross mid, not others
  1. ..S CNTR=0 F CX=1:1:8-OC S:$E(DAY(DAY-1,"W"),97-CX)="t" CNTR=CNTR+1
  1. ..I OC+CNTR'>8 D
  1. ...S Y(1)=$S(X=1:OC,1:8-CNTR)
  1. ...I +NAWS=0 D CHOL ; Process everyone but AWS nurses
  1. ...I +NAWS D CHOL1 ; Process AWS nurses
  1. ...S (OC,OC(D),CC,CC(D))=0,FG=1
  1. ..Q
  1. ;
  1. I CC>0,CC<OC D ;SPLIT SEGMENT, MUST DO TWICE (FOR CT THEN FOR OT)
  1. .F I=DAY:1:(DAY+1) I OC(I) D
  1. ..S (OCCNT,CCCNT)=0
  1. ..I X=2,OC(I)+TIMECNT<8 D ; Add time if 2 hour minimum was not met.
  1. ...S TIMECNT=8-OC(I)-TIMECNT ; Amount of time short of the 2 hour min.
  1. ...;
  1. ...; If TIMECNT is an even number divide needed time equally among the
  1. ...; CT and OT.
  1. ...I TIMECNT#2=0 S CCCNT=TIMECNT/2,OCCNT=TIMECNT/2
  1. ...;
  1. ...; If TIMECNT is not an even number divide the time needed as equally
  1. ...; as possible among the CT and OT w/ remaining 15 minutes going to OC.
  1. ...I TIMECNT#2=1 S CCCNT=TIMECNT\2,OCCNT=(TIMECNT\2)+1
  1. ...;
  1. ..S Y(1)=$S(X=2:CC(I)+CCCNT,X:CC(I),OC(I)>7:CC(I),1:4),Y=7
  1. ..I +NAWS=0 D CHOL ; Process everyone but AWS nurses
  1. ..I +NAWS D CHOL1 ; Process AWS nurses
  1. ..S Y(1)=$S(X=2:OC(I)-CC(I)+OCCNT,X:OC(I)-CC(I),OC(I)>7:OC(I)-CC(I),1:4)
  1. ..S Y=$S('DOUB:TOUR+19,1:23)
  1. ..I +NAWS=0 D CHOL ; Process everyone but AWS nurses
  1. ..I +NAWS D CHOL1 ; Process AWS nurses
  1. ..Q
  1. .Q
  1. E D ;NOT SPLIT SEGMENT
  1. .F I=DAY:1:(DAY+1) I OC(I) D
  1. ..I OC(I)<8,X=2 D
  1. ...I T'=96 S OC(I)=8-TIMECNT
  1. ...I T=96,"ct"'[$E(DAY(DAY+1,"W"),1) S OC(I)=8-TIMECNT
  1. ..S Y(1)=$S(X:OC(I),OC(I)>7:OC(I),1:8)
  1. ..I +NAWS=0 D CHOL ; Process everyone but AWS nurses
  1. ..I +NAWS D CHOL1 ; Process AWS nurses
  1. ..Q
  1. .Q
  1. K OC,CC Q
  1. ;
  1. CHOL ; --- Check for Holiday Callback
  1. S TMP=Y,Y=0
  1. ; Don't convert Overtime to Comptime
  1. I TMP'=7,$E(ENT,25),$$HOLIDAY^PRS8UT(PY,DFN,+D) S Y=24 ;ot on actual hol
  1. I 'Y,$E($G(DAY(I,"HOL")),$S(T>96:(T-96),1:T)) S Y=TOUR+28 ;holiday callback
  1. I 'Y S Y=TMP
  1. D SET S Y=$S(CC:7,'DOUB:TOUR+19,1:23)
  1. Q
  1. ;
  1. SET ; --- set WK array
  1. S W=$S(I<8:1,1:2)
  1. I I<1!(I>14) Q
  1. I Y(1)>32,'DOUB,$P(C0,"^",12)="N",Y'=7 D
  1. .S $P(WK(W),"^",TOUR+15)=$P(WK(W),"^",TOUR+15)+(Y(1)-32)
  1. .S $P(WK(W),"^",Y)=$P(WK(W),"^",Y)+32 ;if FLSA=N set >8 = DA
  1. E S $P(WK(W),"^",Y)=$P(WK(W),"^",Y)+Y(1)
  1. Q
  1. ;
  1. CHOL1 ; Checks for AWS nurses
  1. N HT,J,K,T2ADD
  1. S K=0,TMP=Y,Y=0
  1. S T2ADD=$S(CC:Y(1)-CC,1:Y(1)-OC-CC)
  1. ; Apply normal checks for OT on Hol and Hol Callback
  1. I TMP'=7,$E(ENT,25),$$HOLIDAY^PRS8UT(PY,DFN,+D) S Y=24 ;ot on actual hol
  1. I 'Y,$E($G(DAY(I,"HOL")),$S(T>96:(T-96),1:T)) S Y=TOUR+28 ;holiday callback
  1. I 'Y S Y=TMP
  1. I Y=24!(Y=(TOUR+28)) D SET Q
  1. ; If not OT on Hol or Hol Callback Determine if we are setting OT or CT
  1. S K=$S(Y=7:CC,1:OC)
  1. F J=1:1:K D AWSWK ; Update actual time worked
  1. F J=1:1:T2ADD D AWSWK ; Update time added to reach 2 hour min
  1. Q
  1. ;
  1. AWSWK ; Determine what type of time to add based on 8/day and 40/wk
  1. S HT=+$G(^TMP($J,"PRS8",D,"HT"))
  1. I HT'<32 S Y=$S(Y'=7:TOUR+15,1:Y) D SET1 Q
  1. I TH(W)'<160 S Y=$S(Y'=7:TOUR+19,1:Y) D SET1 Q
  1. I HT<32,TH(W)<160 S Y=9 D SET1
  1. Q
  1. ;
  1. SET1 ; Set WK array for AWS nurses
  1. S $P(WK(W),"^",Y)=$P(WK(W),"^",Y)+1
  1. Q:HT'<32
  1. S TH=TH+1,TH(WK)=TH(WK)+1
  1. S ^TMP($J,"PRS8",DAY,"HT")=HT+1
  1. Q